Skip to content

Commit 1977031

Browse files
committed
Merge fork/main into rebase-on-471: resolve spawn-c vs openai#471 in favor of openai#471 reconstruction
# Conflicts: # .claude-plugin/marketplace.json # README.md # plugins/codex/.claude-plugin/plugin.json # plugins/codex/commands/adversarial-review.md # plugins/codex/commands/review.md # plugins/codex/scripts/lib/app-server.mjs # plugins/codex/scripts/lib/broker-lifecycle.mjs # tests/commands.test.mjs # tests/runtime.test.mjs
2 parents 06d5dc6 + 0ddf717 commit 1977031

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

plugins/codex/scripts/app-server-broker.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async function main() {
6767
}
6868

6969
const { options } = parseArgs(argv, {
70-
valueOptions: ["cwd", "pid-file", "endpoint"]
70+
valueOptions: ["cwd", "pid-file", "endpoint", "model", "effort"]
7171
});
7272

7373
if (!options.endpoint) {
@@ -80,7 +80,7 @@ async function main() {
8080
const pidFile = options["pid-file"] ? path.resolve(options["pid-file"]) : null;
8181
writePidFile(pidFile);
8282

83-
const appClient = await CodexAppServerClient.connect(cwd, { disableBroker: true });
83+
const appClient = await CodexAppServerClient.connect(cwd, { disableBroker: true, model: options.model, effort: options.effort });
8484
let activeRequestSocket = null;
8585
let activeStreamSocket = null;
8686
let activeStreamThreadIds = null;

plugins/codex/scripts/lib/codex.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,10 @@ async function captureTurn(client, threadId, startRequest, options = {}) {
607607
}
608608
}
609609

610-
async function withAppServer(cwd, fn) {
610+
async function withAppServer(cwd, fn, clientOptions = {}) {
611611
let client = null;
612612
try {
613-
client = await CodexAppServerClient.connect(cwd);
613+
client = await CodexAppServerClient.connect(cwd, clientOptions);
614614
const result = await fn(client);
615615
await client.close();
616616
return result;
@@ -629,7 +629,7 @@ async function withAppServer(cwd, fn) {
629629
throw error;
630630
}
631631

632-
const directClient = await CodexAppServerClient.connect(cwd, { disableBroker: true });
632+
const directClient = await CodexAppServerClient.connect(cwd, { ...clientOptions, disableBroker: true });
633633
try {
634634
return await fn(directClient);
635635
} finally {
@@ -1067,7 +1067,7 @@ export async function runAppServerReview(cwd, options = {}) {
10671067
error: turnState.error,
10681068
stderr: cleanCodexStderr(client.stderr)
10691069
};
1070-
});
1070+
}, { model: options.model, effort: options.effort });
10711071
}
10721072

10731073
export async function importExternalAgentSession(cwd, options = {}) {
@@ -1203,7 +1203,7 @@ export async function runAppServerTurn(cwd, options = {}) {
12031203
touchedFiles: collectTouchedFiles(turnState.fileChanges),
12041204
commandExecutions: turnState.commandExecutions
12051205
};
1206-
});
1206+
}, { model: options.model, effort: options.effort });
12071207
}
12081208

12091209
export async function findLatestTaskThread(cwd) {

tests/fake-codex-fixture.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const readline = require("node:readline");
2020
2121
function loadState() {
2222
if (!fs.existsSync(STATE_PATH)) {
23-
return { nextThreadId: 1, nextTurnId: 1, appServerStarts: 0, threads: [], capabilities: null, lastInterrupt: null };
23+
return { nextThreadId: 1, nextTurnId: 1, appServerStarts: 0, threads: [], capabilities: null, lastInterrupt: null, lastAppServerSpawnArgs: null, lastReviewStart: null };
2424
}
2525
return JSON.parse(fs.readFileSync(STATE_PATH, "utf8"));
2626
}
@@ -298,6 +298,7 @@ if (args[0] !== "app-server") {
298298
}
299299
const bootState = loadState();
300300
bootState.appServerStarts = (bootState.appServerStarts || 0) + 1;
301+
bootState.lastAppServerSpawnArgs = args;
301302
saveState(bootState);
302303
303304
const rl = readline.createInterface({ input: process.stdin });
@@ -493,6 +494,14 @@ rl.on("line", (line) => {
493494
send({ method: "thread/started", params: { thread: { id: reviewThread.id } } });
494495
}
495496
const turnId = nextTurnId(state);
497+
state.lastReviewStart = {
498+
threadId: message.params.threadId,
499+
reviewThreadId: reviewThread.id,
500+
model: message.params.model ?? null,
501+
effort: message.params.effort ?? null,
502+
target: message.params.target
503+
};
504+
saveState(state);
496505
send({ id: message.id, result: { turn: buildTurn(turnId), reviewThreadId: reviewThread.id } });
497506
emitTurnCompleted(reviewThread.id, turnId, [
498507
{

0 commit comments

Comments
 (0)