Showing the changes to apps/server/src/codexAppServerManager.ts (1 of 13 files). Show all
Unified · Split
| @@ -169,8 +169,9 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve · 168 unmodified lines | |||
| 169 | updatedAt: now, | 169 | updatedAt: now, |
| 170 | }; | 170 | }; |
| 171 | 171 | ||
| 172 | const codexBinaryPath = input.codexBinaryPath ?? "codex"; | 172 | const codexOptions = readCodexProviderOptions(input); |
| 173 | const codexHomePath = input.codexHomePath; | 173 | const codexBinaryPath = codexOptions.binaryPath ?? "codex"; |
| 174 | const codexHomePath = codexOptions.homePath; | ||
| 174 | const child = spawn(codexBinaryPath, ["app-server"], { | 175 | const child = spawn(codexBinaryPath, ["app-server"], { |
| 175 | cwd: resolvedCwd, | 176 | cwd: resolvedCwd, |
| 176 | env: { | 177 | env: { |
| @@ -349,13 +350,17 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve · 172 unmodified lines | |||
| 349 | this.updateSession(context, { | 350 | this.updateSession(context, { |
| 350 | status: "running", | 351 | status: "running", |
| 351 | activeTurnId: turnId, | 352 | activeTurnId: turnId, |
| 352 | resumeCursor: context.session.resumeCursor ?? { threadId: context.session.threadId }, | 353 | ...(context.session.resumeCursor !== undefined |
| 354 | ? { resumeCursor: context.session.resumeCursor } | ||
| 355 | : {}), | ||
| 353 | }); | 356 | }); |
| 354 | 357 | ||
| 355 | return { | 358 | return { |
| 356 | threadId: context.session.threadId, | 359 | threadId: context.session.threadId, |
| 357 | turnId, | 360 | turnId, |
| 358 | resumeCursor: context.session.resumeCursor ?? { threadId: context.session.threadId }, | 361 | ...(context.session.resumeCursor !== undefined |
| 362 | ? { resumeCursor: context.session.resumeCursor } | ||
| 363 | : {}), | ||
| 359 | }; | 364 | }; |
| 360 | } | 365 | } |
| 361 | 366 | ||
| @@ -980,16 +985,30 @@ function toProviderThreadId(value: string | undefined): ProviderThreadId | undef · 618 unmodified lines | |||
| 980 | return brandIfNonEmpty(value, ProviderThreadId.makeUnsafe); | 985 | return brandIfNonEmpty(value, ProviderThreadId.makeUnsafe); |
| 981 | } | 986 | } |
| 982 | 987 | ||
| 988 | function readCodexProviderOptions(input: ProviderSessionStartInput): { | ||
| 989 | readonly binaryPath?: string; | ||
| 990 | readonly homePath?: string; | ||
| 991 | } { | ||
| 992 | const options = input.providerOptions?.codex; | ||
| 993 | if (!options) { | ||
| 994 | return {}; | ||
| 995 | } | ||
| 996 | return { | ||
| 997 | ...(options.binaryPath ? { binaryPath: options.binaryPath } : {}), | ||
| 998 | ...(options.homePath ? { homePath: options.homePath } : {}), | ||
| 999 | }; | ||
| 1000 | } | ||
| 1001 | |||
| 1002 | function readResumeCursorThreadId(resumeCursor: unknown): ProviderThreadId | undefined { | ||
| 1003 | if (!resumeCursor || typeof resumeCursor !== "object" || Array.isArray(resumeCursor)) { | ||
| 1004 | return undefined; | ||
| 1005 | } | ||
| 1006 | const rawThreadId = (resumeCursor as Record<string, unknown>).threadId; | ||
| 1007 | return typeof rawThreadId === "string" ? toProviderThreadId(rawThreadId) : undefined; | ||
| 1008 | } | ||
| 1009 | |||
| 983 | function readResumeThreadId(input: ProviderSessionStartInput): ProviderThreadId | undefined { | 1010 | function readResumeThreadId(input: ProviderSessionStartInput): ProviderThreadId | undefined { |
| 984 | if ( | 1011 | return readResumeCursorThreadId(input.resumeCursor); |
| 985 | !input.resumeCursor || | ||
| 986 | typeof input.resumeCursor !== "object" || | ||
| 987 | Array.isArray(input.resumeCursor) | ||
| 988 | ) { | ||
| 989 | return input.resumeThreadId; | ||
| 990 | } | ||
| 991 | const rawThreadId = (input.resumeCursor as Record<string, unknown>).threadId; | ||
| 992 | return typeof rawThreadId === "string" ? toProviderThreadId(rawThreadId) : input.resumeThreadId; | ||
| 993 | } | 1012 | } |
| 994 | 1013 | ||
| 995 | function toProviderTurnId(value: string | undefined): ProviderTurnId | undefined { | 1014 | function toProviderTurnId(value: string | undefined): ProviderTurnId | undefined { |