硬化 Codex stdio backend 错误观测
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as readline from "node:readline";
|
||||
|
||||
const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
|
||||
const mode = process.env.AGENTRUN_FAKE_CODEX_MODE ?? "success";
|
||||
let threadCounter = 0;
|
||||
let turnCounter = 0;
|
||||
|
||||
@@ -9,6 +10,10 @@ for await (const line of rl) {
|
||||
if (trimmed.length === 0) continue;
|
||||
const message = JSON.parse(trimmed) as { id?: number; method?: string; params?: Record<string, unknown> };
|
||||
if (message.method === "initialize") {
|
||||
if (mode === "invalid-json") {
|
||||
process.stdout.write('{"token":"test-token-material"\n');
|
||||
process.exit(0);
|
||||
}
|
||||
respond(message.id, { serverInfo: { name: "fake-codex-app-server", version: "self-test" } });
|
||||
continue;
|
||||
}
|
||||
@@ -26,6 +31,17 @@ for await (const line of rl) {
|
||||
continue;
|
||||
}
|
||||
if (message.method === "turn/start") {
|
||||
if (mode === "missing-turn-result") {
|
||||
respond(message.id, {});
|
||||
continue;
|
||||
}
|
||||
if (mode === "missing-terminal") {
|
||||
turnCounter += 1;
|
||||
const turn = { id: `turn_selftest_${turnCounter}`, status: "running" };
|
||||
notify("turn/started", { turn });
|
||||
respond(message.id, { turn });
|
||||
continue;
|
||||
}
|
||||
turnCounter += 1;
|
||||
const turn = { id: `turn_selftest_${turnCounter}`, status: "completed" };
|
||||
notify("turn/started", { turn });
|
||||
|
||||
Reference in New Issue
Block a user