History

redo contracts a bit

Julius Marminge committed 8 months ago

Commit 2ed16e51 parent 37eb49213 files · +259 −45Browse files

Showing the changes to apps/server/src/codexAppServerManager.ts (1 of 13 files). Show all

Unified · Split

apps/server/src/codexAppServerManager.ts+32−13
@@ -169,8 +169,9 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve · 168 unmodified lines
169169 updatedAt: now,
170170 };
171171
172− const codexBinaryPath = input.codexBinaryPath ?? "codex";
173− const codexHomePath = input.codexHomePath;
172+ const codexOptions = readCodexProviderOptions(input);
173+ const codexBinaryPath = codexOptions.binaryPath ?? "codex";
174+ const codexHomePath = codexOptions.homePath;
174175 const child = spawn(codexBinaryPath, ["app-server"], {
175176 cwd: resolvedCwd,
176177 env: {
@@ -349,13 +350,17 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve · 172 unmodified lines
349350 this.updateSession(context, {
350351 status: "running",
351352 activeTurnId: turnId,
352− resumeCursor: context.session.resumeCursor ?? { threadId: context.session.threadId },
353+ ...(context.session.resumeCursor !== undefined
354+ ? { resumeCursor: context.session.resumeCursor }
355+ : {}),
353356 });
354357
355358 return {
356359 threadId: context.session.threadId,
357360 turnId,
358− resumeCursor: context.session.resumeCursor ?? { threadId: context.session.threadId },
361+ ...(context.session.resumeCursor !== undefined
362+ ? { resumeCursor: context.session.resumeCursor }
363+ : {}),
359364 };
360365 }
361366
@@ -980,16 +985,30 @@ function toProviderThreadId(value: string | undefined): ProviderThreadId | undef · 618 unmodified lines
980985 return brandIfNonEmpty(value, ProviderThreadId.makeUnsafe);
981986 }
982987
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+
9831010 function readResumeThreadId(input: ProviderSessionStartInput): ProviderThreadId | undefined {
984− if (
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;
1011+ return readResumeCursorThreadId(input.resumeCursor);
9931012 }
9941013
9951014 function toProviderTurnId(value: string | undefined): ProviderTurnId | undefined {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t