Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Tests: the remaining fakes answer the Ollama probe and expect the local-model rules (#4206)
Milind Soniadc48eef3113
diff --git a/server/cancelled-turn.e2e.test.ts b/server/cancelled-turn.e2e.test.tsindex f2ccc98395..25325f89d7 100644--- a/server/cancelled-turn.e2e.test.ts+++ b/server/cancelled-turn.e2e.test.ts@@ -27,6 +27,8 @@ it("says in words that a turn nobody stopped was cut off, and retries the room rres.end(JSON.stringify({ data: [{ id: "fixture-model" }] }));return;}+ // The chat engine asks a local server whether it is Ollama (/api/version); this one is not.+ if (req.method === "GET") { res.statusCode = 404; res.end(); return; }let body = "";for await (const chunk of req) body += chunk;const request = JSON.parse(body) as ChatRequest;diff --git a/server/cloud-credit.e2e.test.ts b/server/cloud-credit.e2e.test.tsindex b0afc30e4a..fe8addc4c7 100644--- a/server/cloud-credit.e2e.test.ts+++ b/server/cloud-credit.e2e.test.ts@@ -215,7 +215,7 @@ describe("the free trial's Claude credit on a Cloud home", { timeout: 90_000 },const settled = await turn("hello");expect(answered(settled)).toBe(true);expect(completions().at(-1)).toMatchObject({ method: "POST", path: `${RELAY_PATH}/v1/chat/completions`, bearer: `Bearer ${TOKEN}`, model: "claude-sonnet-5" });- expect(relayed.filter((request) => ![`${RELAY_PATH}/v1/models`, `${RELAY_PATH}/v1/chat/completions`].includes(request.path))).toEqual([]);+ expect(relayed.filter((request) => ![`${RELAY_PATH}/v1/models`, `${RELAY_PATH}/v1/chat/completions`, `${RELAY_PATH}/api/version`].includes(request.path))).toEqual([]);expect(relayed.every((request) => request.apiKey === "")).toBe(true);expect(() => readFileSync(join(home, "own-turn.json"), "utf8")).toThrow();});diff --git a/server/direct-coordination.e2e.test.ts b/server/direct-coordination.e2e.test.tsindex a132c62bc9..eb92691664 100644--- a/server/direct-coordination.e2e.test.ts+++ b/server/direct-coordination.e2e.test.ts@@ -976,6 +976,8 @@ it("gives a teammate each request once, never also as a bare assistant line", ()async function onLoopbackEngine(f: any, answer: (res: ServerResponse) => void): Promise<() => Promise<void>> {const llm = createServer(async (req, res) => {for await (const _ of req) {}+ // The chat engine asks a local server whether it is Ollama (/api/version); this one is not, and that is no model call.+ if (req.url?.endsWith("/api/version")) { res.statusCode = 404; res.end(); return; }if (req.url?.endsWith("/models")) { res.setHeader("content-type", "application/json"); res.end(JSON.stringify({ data: [{ id: "loop-model" }] })); return; }answer(res);});@@ -990,7 +992,7 @@ it("continues a teammate's step cap in place and stops it once it makes no progrlet calls = 0;const close = await onLoopbackEngine(f, res => {// Never a final answer: one more tool call, every round.- const call = { tool_calls: [{ index: 0, id: `call_${++calls}`, type: "function", function: { name: "missing_tool", arguments: "{}" } }] };+ const call = { tool_calls: [{ index: 0, id: `call_${++calls}`, type: "function", function: { name: "missing_tool", arguments: JSON.stringify({ attempt: calls }) } }] };res.writeHead(200, { "content-type": "text/event-stream" });res.end(`data: ${JSON.stringify({ choices: [{ index: 0, delta: call, finish_reason: "tool_calls" }] })}\n\ndata: [DONE]\n\n`);});diff --git a/server/native-replay.e2e.test.ts b/server/native-replay.e2e.test.tsindex 8cace4a04f..23b6053f93 100644--- a/server/native-replay.e2e.test.ts+++ b/server/native-replay.e2e.test.ts@@ -12,6 +12,8 @@ it("sends history once through the real OpenAI-compatible server route after a rres.end(JSON.stringify({ data: [{ id: "fixture-model" }] }));return;}+ // The chat engine asks a local server whether it is Ollama (/api/version); this one is not.+ if (req.method === "GET") { res.statusCode = 404; res.end(); return; }let body = "";for await (const chunk of req) body += chunk;requests.push(JSON.parse(body));diff --git a/server/openai-boat.e2e.test.ts b/server/openai-boat.e2e.test.tsindex e344d85b65..5bb8cc1197 100644--- a/server/openai-boat.e2e.test.ts+++ b/server/openai-boat.e2e.test.ts@@ -57,7 +57,7 @@ it("keeps the selected API model for direct, group and scheduled Boat turns andconst address = upstream.address();if (!address || typeof address === "string") throw new Error("fixture failed to bind");const origin = `http://127.0.0.1:${address.port}`;- const fixture = await launchVerificationServer(process.env, undefined, undefined, undefined, undefined, undefined, [], origin).catch(async error => {+ const fixture = await launchVerificationServer({ ...process.env, OMB_AGENTS_TOOL_BRIDGE: "0" }, undefined, undefined, undefined, undefined, undefined, [], origin).catch(async error => {upstream.closeAllConnections(); await new Promise<void>(resolve => upstream.close(() => resolve())); throw error;});const api = async (method: string, path: string, body?: unknown) => {@@ -95,7 +95,8 @@ it("keeps the selected API model for direct, group and scheduled Boat turns and}const settled = await control(["wait", ...destination, "--timeout", "20"]);expect(settled.status).toBe(scenario === "held" ? "failed" : "settled");- expect(requests.slice(before)).toHaveLength(2);+ // This fake is on loopback, so it counts as a local model: a failed call gets up to two rounds to correct it.+ expect(requests.slice(before)).toHaveLength(scenario === "held" ? 4 : 2);expect(requests.slice(before).every(request => request.model === "chosen-vision-model")).toBe(true);const followup = requests[before + 1].messages;if (scenario === "held") {diff --git a/server/openai-compat-vm.e2e.test.ts b/server/openai-compat-vm.e2e.test.tsindex 5cfbf9bc63..159fa6a649 100644--- a/server/openai-compat-vm.e2e.test.ts+++ b/server/openai-compat-vm.e2e.test.ts@@ -100,6 +100,8 @@ beforeAll(async () => {upstream = createServer(async (req, res) => {res.setHeader("content-type", "application/json");if (req.url === "/v1/models") return res.end(JSON.stringify({ data: [{ id: "fixture-model" }] }));+ // The chat engine asks a local server whether it is Ollama (/api/version); this one is not.+ if (req.method === "GET") { res.statusCode = 404; return res.end(); }let raw = "";for await (const chunk of req) raw += chunk;const request = JSON.parse(raw || "{}") as ChatRequest;@@ -147,6 +149,7 @@ beforeAll(async () => {env: {PATH: [fakebin, dirname(process.execPath), "/usr/bin", "/bin"].join(delimiter),HOME: fixtureHome, USERPROFILE: fixtureHome, OMB_DATA_DIR: data,+ OMB_AGENTS_TOOL_BRIDGE: "0",APPDATA: join(fixtureHome, "appdata"), LOCALAPPDATA: join(fixtureHome, "localappdata"),TEMP: fixtureHome, TMP: fixtureHome, TMPDIR: fixtureHome,OMB_PORT: String(port), OMB_WEBHOOK_PORT: String(port + 1), OMB_STATIC_DIR: ui,diff --git a/server/server-writes.test.ts b/server/server-writes.test.tsindex ebf64bb62f..ad52bee4cb 100644--- a/server/server-writes.test.ts+++ b/server/server-writes.test.ts@@ -23,7 +23,8 @@ const bots = () => readFileSync(join(DATA_DIR, "bots.json"), "utf8");describe("bots.json saves", () => {beforeEach(() => {- rmSync(DATA_DIR, { recursive: true, force: true });+ // Not the whole folder: on Windows the open messages database holds it.+ rmSync(join(DATA_DIR, "bots.json"), { force: true });vi.mocked(fs.renameSync).mockClear();});