Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions apps/server/src/codexAppServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,9 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
};

const codexOptions = readCodexProviderOptions(input);
const codexBinaryPath = codexOptions.binaryPath ?? "codex";
const codexHomePath = codexOptions.homePath;
this.assertSupportedCodexCliVersion({
binaryPath: codexBinaryPath,
const codexBinaryPath = resolveCodexBinaryPath({
binaryPath: codexOptions.binaryPath ?? "codex",
cwd: resolvedCwd,
...(codexHomePath ? { homePath: codexHomePath } : {}),
});
Expand Down Expand Up @@ -1566,6 +1565,35 @@ function assertSupportedCodexCliVersion(input: {
}
}

function resolveCodexBinaryPath(input: {
readonly binaryPath: string;
readonly cwd: string;
readonly homePath?: string;
}): string {
try {
assertSupportedCodexCliVersion(input);
return input.binaryPath;
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (
input.binaryPath !== "codex" &&
message.includes("is not installed or not executable")
) {
assertSupportedCodexCliVersion({
binaryPath: "codex",
cwd: input.cwd,
...(input.homePath ? { homePath: input.homePath } : {}),
});
console.warn(
"codex cli binary path not executable; falling back to PATH lookup",
{ binaryPath: input.binaryPath },
);
return "codex";
}
throw error;
}
}

function readResumeCursorThreadId(resumeCursor: unknown): string | undefined {
if (!resumeCursor || typeof resumeCursor !== "object" || Array.isArray(resumeCursor)) {
return undefined;
Expand Down