feat: add OMP (Oh My Pi) provider compatibility

Support OMP as a host alongside pi:
- Convert OMP's array-format system prompts to string via systemPromptToText
- Guard against OMP passing the literal env-var name as the API key value
- Add ~/.omp/agent/auth.json to default auth path lookup
- Fix --list-models output to check both stdout and stderr
- Add OMP compatibility smoke test with isolated temp HOME and mock server
- Deduplicate usage section in README, add OMP install and usage docs
This commit is contained in:
AlexVagrant
2026-05-28 04:12:35 -04:00
committed by wh.huajieyu
parent b850558199
commit c2497ed098
9 changed files with 303 additions and 37 deletions
+21 -1
View File
@@ -39,7 +39,7 @@ export function numberValue(value: unknown): number | undefined {
}
function defaultAuthPaths(home: string): string[] {
return [join(home, ".commandcode", "auth.json"), join(home, ".pi", "agent", "auth.json")]
return [join(home, ".commandcode", "auth.json"), join(home, ".omp", "agent", "auth.json"), join(home, ".pi", "agent", "auth.json")]
}
function apiKeyFromCredentialRecord(value: unknown): string | undefined {
@@ -284,3 +284,23 @@ export function mapFinishReason(reason: unknown): StopReason {
}
return "stop"
}
function promptPartToText(value: unknown, depth = 0): string {
if (depth > 10) return ""
if (typeof value === "string") return value
if (Array.isArray(value)) return value.map((v) => promptPartToText(v, depth + 1)).filter(Boolean).join("\n")
if (!isRecord(value)) return ""
const text = stringValue(value.text)
if (text) return text
const content = promptPartToText(value.content, depth + 1)
if (content) return content
return ""
}
export function systemPromptToText(value: unknown): string {
if (value === undefined || value === null) return ""
if (typeof value === "string") return value
if (Array.isArray(value)) return value.map((v) => promptPartToText(v, 0)).filter(Boolean).join("\n\n")
return promptPartToText(value, 0)
}