Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(codex): ask for a Codex update when inject_items is an unknown variant
AdityaUmale8f34cdf1a388
diff --git a/server/drivers/codex-instructions.test.ts b/server/drivers/codex-instructions.test.tsindex 546ebf52c5..4362c09228 100644--- a/server/drivers/codex-instructions.test.ts+++ b/server/drivers/codex-instructions.test.ts@@ -96,6 +96,12 @@ describe("Codex instruction receipts", () => {expect(accepted).toHaveBeenCalledTimes(1);});+ it("asks for a Codex update when an older app-server rejects inject_items as an unknown variant", async () => {+ const key = randomUUID();+ const rejected = vi.fn().mockRejectedValue(new Error("Invalid request: unknown variant `thread/inject_items`, expected one of `initialize`, `thread/start`, `thread/resume`"));+ await expect(syncCodexInstructions(key, "native", "rules", "", true, rejected)).rejects.toThrow("This Codex version cannot update bot instructions in a resumed session. Update Codex and retry");+ });+it("keeps native sessions independent even for one OpenMausBot task", async () => {const key = randomUUID();const request = vi.fn().mockResolvedValue({});diff --git a/server/drivers/codex-instructions.ts b/server/drivers/codex-instructions.tsindex 83fbb42c6f..add62f2349 100644--- a/server/drivers/codex-instructions.ts+++ b/server/drivers/codex-instructions.ts@@ -120,7 +120,7 @@ export async function syncCodexInstructions(}],});} catch (error) {- if (error instanceof Error && /method not found|unknown method/i.test(error.message)) {+ if (error instanceof Error && /method not found|unknown method|unknown variant `thread\/inject_items`/i.test(error.message)) {throw new Error(`This Codex version cannot update bot instructions in a resumed session. Update Codex and retry: ${error.message}`, { cause: error });}throw error;diff --git a/server/drivers/codex.test.ts b/server/drivers/codex.test.tsindex 2f4e8434be..f557778135 100644--- a/server/drivers/codex.test.ts+++ b/server/drivers/codex.test.ts@@ -3019,8 +3019,8 @@ process.stdout.write(JSON.stringify({jsonrpc:'2.0',id:m.id,result})+'\\n');});`)expect(recorder.events.filter((event) => event.type === "turn.retrying")).toHaveLength(mode === "happy" ? 0 : 1);});- it("fails before user submission if native instruction updates are unsupported", async () => {- await create({ mode: "instructions-unsupported" });+ it.each(["instructions-unsupported", "instructions-unknown-variant"])("fails before user submission if native instruction updates are unsupported (%s)", async (mode) => {+ await create({ mode });const dump = join(scratch, "unsupported.json");process.env.FAKE_CODEX_DUMP = dump;await instance.adapter.sendTurn({ threadId: "t-old-codex", text: "go", system: "rules", resumeCursor: "old-session" });diff --git a/server/testing/fake-codex-app-server.ts b/server/testing/fake-codex-app-server.tsindex cd096755b7..e98f9b8c5f 100755--- a/server/testing/fake-codex-app-server.ts+++ b/server/testing/fake-codex-app-server.ts@@ -784,7 +784,7 @@ process.stdin.on("data", (chunk) => {threadReply({ jsonrpc: "2.0", id: msg.id, result: { thread: { id: msg.params?.threadId }, sandbox: resolvedSandbox(msg.params ?? {}) } });} else if (msg.params?.permissions && (!experimentalApi || mode === "config-profile-unsupported")) {out({ jsonrpc: "2.0", id: msg.id, error: { code: -32602, message: "experimental API required for permissions" } });- } else if (mode === "resume" || mode === "plan-unsupported-input" || mode === "review-events" || mode === "helper-events" || mode === "instructions-unsupported" || mode === "config-profile" || mode === "config-profile-unsupported" || mode === "async-question" ||+ } else if (mode === "resume" || mode === "plan-unsupported-input" || mode === "review-events" || mode === "helper-events" || mode === "instructions-unsupported" || mode === "instructions-unknown-variant" || mode === "config-profile" || mode === "config-profile-unsupported" || mode === "async-question" ||(mode === "resume-then-missing" && !existsSync(process.env.FAKE_CODEX_STATE ?? ""))) {threadReply({ jsonrpc: "2.0", id: msg.id, result: { thread: { id: msg.params?.threadId, ...(process.env.FAKE_CODEX_ROLLOUT ? { path: process.env.FAKE_CODEX_ROLLOUT } : {}) }, sandbox: resolvedSandbox(msg.params ?? {}) } });} else {@@ -792,9 +792,11 @@ process.stdin.on("data", (chunk) => {}break;case "thread/inject_items":- if (mode === "instructions-unsupported") {+ if (mode === "instructions-unsupported" || mode === "instructions-unknown-variant") {dump();- out({ jsonrpc: "2.0", id: msg.id, error: { code: -32601, message: "method not found" } });+ out({ jsonrpc: "2.0", id: msg.id, error: mode === "instructions-unsupported"+ ? { code: -32601, message: "method not found" }+ : { code: -32600, message: "Invalid request: unknown variant `thread/inject_items`, expected one of `initialize`, `thread/start`, `thread/resume`" } });break;}out({ jsonrpc: "2.0", id: msg.id, result: {} });