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
+9
View File
@@ -66,6 +66,10 @@ type PendingRequest = {
cleanup: () => void;
};
type CodexAppServerClientOptions = {
cwd?: string;
};
function asRecord(value: unknown): Record<string, unknown> | null {
if (!value || typeof value !== 'object') {
return null;
@@ -169,6 +173,10 @@ export class CodexAppServerClient extends JsonLineParser {
static readonly DEFAULT_TIMEOUT_MS = 14 * 24 * 60 * 60 * 1000;
constructor(private readonly options: CodexAppServerClientOptions = {}) {
super();
}
setStderrHandler(handler: ((text: string) => void) | null): void {
this.stderrHandler = handler;
}
@@ -181,6 +189,7 @@ export class CodexAppServerClient extends JsonLineParser {
const codexCommand = resolveCodexAppServerCommand();
logger.debug(`[CodexAppServer] Starting ${codexCommand} app-server`);
this.process = spawn(codexCommand, ['app-server'], {
cwd: this.options.cwd,
env: Object.keys(process.env).reduce((acc, key) => {
const value = process.env[key];
if (typeof value === 'string') acc[key] = value;