fix(codex): harden model discovery fallback

This commit is contained in:
weishu
2026-08-09 09:04:28 +08:00
parent 3da9f7780a
commit cde0507bad
17 changed files with 387 additions and 8 deletions
+4 -1
View File
@@ -1,3 +1,4 @@
import { homedir } from 'node:os';
import type { CodexModelsResponse, CodexModelSummary } from '@hapi/protocol/apiTypes';
import { CodexAppServerClient } from '@/codex/codexAppServerClient';
import { getErrorMessage } from './rpcResponses';
@@ -81,7 +82,9 @@ function normalizeModel(entry: unknown): CodexModelSummary | null {
}
export async function listCodexModels(includeHidden: boolean = false): Promise<CodexModelSummary[]> {
const client = new CodexAppServerClient();
// Model discovery is account-scoped. Never inherit a session/runner cwd:
// project config or a deleted worktree must not alter or break the catalog.
const client = new CodexAppServerClient({ cwd: homedir() });
try {
await client.connect();