mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-08 01:43:07 +00:00
fix(codex): harden model discovery fallback
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user