Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Tests expect a title one-shot on every new thread
milind-soni3091c6c5077c
diff --git a/server/live-approval.e2e.test.ts b/server/live-approval.e2e.test.tsindex 8775cbf4a5..3c55383844 100644--- a/server/live-approval.e2e.test.ts+++ b/server/live-approval.e2e.test.ts@@ -3,6 +3,7 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";import { join } from "node:path";import { expect, it } from "vitest";import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";+import { isTitleCall } from "./testing/title-call.ts";// The fixture can only append to one fixed file in the launcher's disposable home: provider arguments cannot select a path.const MCP_FIXTURE = `@@ -42,6 +43,7 @@ it("applies a level picked while the bot is working to its next tool call, and llet text = "";for await (const chunk of req) text += chunk;const body = JSON.parse(text) as { messages: Array<{ role: string }>; tools?: Array<{ function: { name: string; description?: string } }> };+ if (isTitleCall(body)) { res.writeHead(500).end(); return; }const first = !body.messages.some((message) => message.role === "tool");if (first) await new Promise<void>((resolve) => { release = resolve; held = true; });const name = body.tools?.find((tool) => tool.function.description?.includes("level fixture artifact"))?.function.name;diff --git a/server/mistral-key-flow.test.ts b/server/mistral-key-flow.test.tsindex 88eaa34dd4..10ac79adca 100644--- a/server/mistral-key-flow.test.ts+++ b/server/mistral-key-flow.test.ts@@ -6,11 +6,12 @@ import { launchVerificationServer } from "../scripts/control-omb.ts";import { fixtureApi } from "../scripts/testing/preview-fixture.ts";import { hostTimeout } from "./testing/host-timeout.ts";import { openSse } from "./testing/sse.ts";+import { isTitleCall } from "./testing/title-call.ts";it("Mistral keys persist, rotate, clear and reach real HTTP turns without leaking into public state", async () => {const received: string[] = [];let reply = 0;- const provider = createServer((req, res) => {+ const provider = createServer(async (req, res) => {if (req.url === "/v1/models") {// Deliberately public: this must never be presented as authenticated.res.setHeader("content-type", "application/json");@@ -18,9 +19,11 @@ it("Mistral keys persist, rotate, clear and reach real HTTP turns without leakinreturn;}if (req.url !== "/v1/chat/completions") { res.writeHead(404).end(); return; }+ let body = "";+ for await (const chunk of req) body += chunk;+ if (isTitleCall(body)) { res.writeHead(500).end(); return; }const key = req.headers.authorization ?? "";received.push(key);- req.resume();if (!["Bearer fixture-first-key", "Bearer fixture-replacement-key"].includes(key)) {res.writeHead(401, { "content-type": "application/json" });res.end(JSON.stringify({ error: { message: "Invalid fixture credential" } }));diff --git a/server/native-replay.e2e.test.ts b/server/native-replay.e2e.test.tsindex 23b6053f93..31aad922f9 100644--- a/server/native-replay.e2e.test.ts+++ b/server/native-replay.e2e.test.ts@@ -3,6 +3,7 @@ import { writeFileSync } from "node:fs";import { expect, it } from "vitest";import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";import { fixtureApi } from "../scripts/testing/preview-fixture.ts";+import { isTitleCall } from "./testing/title-call.ts";it("sends history once through the real OpenAI-compatible server route after a rewind", async () => {const requests: any[] = [];@@ -16,7 +17,9 @@ it("sends history once through the real OpenAI-compatible server route after a rif (req.method === "GET") { res.statusCode = 404; res.end(); return; }let body = "";for await (const chunk of req) body += chunk;- requests.push(JSON.parse(body));+ const request = JSON.parse(body);+ if (isTitleCall(request)) { res.writeHead(500).end(); return; }+ requests.push(request);res.writeHead(200, { "content-type": "text/event-stream" });res.end(`data: ${JSON.stringify({ choices: [{ delta: { content: "Fixture reply" }, finish_reason: "stop" }] })}\n\ndata: [DONE]\n\n`);});diff --git a/server/openai-boat.e2e.test.ts b/server/openai-boat.e2e.test.tsindex 5bb8cc1197..f8f426f55b 100644--- a/server/openai-boat.e2e.test.ts+++ b/server/openai-boat.e2e.test.ts@@ -1,6 +1,7 @@import { createServer } from "node:http";import { expect, it } from "vitest";import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";+import { isTitleCall } from "./testing/title-call.ts";it("keeps the selected API model for direct, group and scheduled Boat turns and preserves human control", async () => {const rows: Array<{ id: string; name: string; state: string }> = [];@@ -28,6 +29,7 @@ it("keeps the selected API model for direct, group and scheduled Boat turns and}if (path === "/v1/models") return res.end(JSON.stringify({ data: [{ id: "chosen-vision-model" }, { id: "other-default" }] }));if (path === "/v1/chat/completions") {+ if (isTitleCall(body)) { res.statusCode = 500; return res.end("{}"); }requests.push(body);const completed = body.messages.some((message: any) => message.role === "tool");const tool = body.tools?.find((entry: any) => entry.function.name === "computer_screenshot");diff --git a/server/openai-compat-vm.e2e.test.ts b/server/openai-compat-vm.e2e.test.tsindex 167f27d4ab..97106d3239 100644--- a/server/openai-compat-vm.e2e.test.ts+++ b/server/openai-compat-vm.e2e.test.ts@@ -9,6 +9,7 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest";import { writeFileAtomic } from "./atomic.ts";import { freePortBlock } from "./testing/ports.ts";import { removeTempDir, waitForExit } from "./testing/cleanup.ts";+import { isTitleCall } from "./testing/title-call.ts";const ROOT = fileURLToPath(new URL("..", import.meta.url));let child: ChildProcess;@@ -105,6 +106,7 @@ beforeAll(async () => {let raw = "";for await (const chunk of req) raw += chunk;const request = JSON.parse(raw || "{}") as ChatRequest;+ if (isTitleCall(request)) { res.statusCode = 500; return res.end(); }requests.push(request);const toolResult = request.messages?.some(message => message.role === "tool");res.writeHead(200, { "content-type": "text/event-stream" });diff --git a/server/openai-tools.e2e.test.ts b/server/openai-tools.e2e.test.tsindex 165981b20d..1891af27c1 100644--- a/server/openai-tools.e2e.test.ts+++ b/server/openai-tools.e2e.test.ts@@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";import { join } from "node:path";import { expect, it } from "vitest";import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";+import { isTitleCall } from "./testing/title-call.ts";// The fixture can only write one fixed file in the launcher's disposable home: provider arguments cannot select a path.const MCP_FIXTURE = `@@ -67,6 +68,7 @@ it.each(["openaiCompat", "groq", "meta"] as const)("%s runs structured MCP callslet body = "";for await (const chunk of req) body += chunk;const request = JSON.parse(body) as ChatRequest;+ if (isTitleCall(request)) { res.writeHead(500).end(); return; }requests.push(request);if (scenario === "tools-off" && "tools" in request) {res.writeHead(400, { "content-type": "application/json" });diff --git a/server/parallel-threads.e2e.test.ts b/server/parallel-threads.e2e.test.tsindex 78f26c52ab..2f9340fc0d 100644--- a/server/parallel-threads.e2e.test.ts+++ b/server/parallel-threads.e2e.test.ts@@ -13,6 +13,7 @@ import { CONTROL_BUSY } from "./control-client.ts";import { BROWSER_HANDED_OVER, browserBusyText } from "./host/browser-seats.ts";import { removeTempDir, waitForExit } from "./testing/cleanup.ts";import { freePortBlock } from "./testing/ports.ts";+import { isTitleCall } from "./testing/title-call.ts";const SERVER_DIR = dirname(fileURLToPath(import.meta.url));const HOST = "omb-t-0123456789ab.fly.dev";@@ -80,6 +81,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-acreq.on("data", (chunk) => { raw += chunk; });req.on("end", () => {const body = JSON.parse(raw) as { messages?: { role: string; content: unknown }[]; stream?: boolean };+ if (isTitleCall(body)) { res.writeHead(500).end("{}"); return; }const last = JSON.stringify(body.messages?.findLast((m) => m.role === "user")?.content ?? "");const entry = { thread: last, release: () => {res.writeHead(200, { "content-type": "application/json" });diff --git a/server/provider-key-flow.test.ts b/server/provider-key-flow.test.tsindex 601654dd11..cfbda86031 100644--- a/server/provider-key-flow.test.ts+++ b/server/provider-key-flow.test.ts@@ -5,11 +5,12 @@ import { expect, it } from "vitest";import { launchVerificationServer } from "../scripts/control-omb.ts";import { fixtureApi } from "../scripts/testing/preview-fixture.ts";import { openSse } from "./testing/sse.ts";+import { isTitleCall } from "./testing/title-call.ts";it("saving and replacing a workspace key reaches an existing bot's next request without leaking keys", async () => {const received: string[] = [];let reply = 0;- const provider = createServer((req, res) => {+ const provider = createServer(async (req, res) => {if (req.url === "/v1/models") {// Deliberately public: this must never be presented as authenticated.res.setHeader("content-type", "application/json");@@ -17,9 +18,11 @@ it("saving and replacing a workspace key reaches an existing bot's next requestreturn;}if (req.url !== "/v1/chat/completions") { res.writeHead(404).end(); return; }+ let body = "";+ for await (const chunk of req) body += chunk;+ if (isTitleCall(body)) { res.writeHead(500).end(); return; }const key = req.headers.authorization ?? "";received.push(key);- req.resume();if (!["Bearer fixture-first-key", "Bearer fixture-replacement-key"].includes(key)) {res.writeHead(401, { "content-type": "application/json" });res.end(JSON.stringify({ error: { message: "Invalid fixture credential" } }));diff --git a/server/runtime-roots.e2e.test.ts b/server/runtime-roots.e2e.test.tsindex 7417a0f770..640aeeb093 100644--- a/server/runtime-roots.e2e.test.ts+++ b/server/runtime-roots.e2e.test.ts@@ -15,6 +15,7 @@ import { freePortBlock } from "./testing/ports.ts";import { hostTimeout } from "./testing/host-timeout.ts";import { ownTurnText } from "./testing/room-handoff-agent.ts";import { withAnswer } from "./testing/your-computer.ts";+import { isTitleCall } from "./testing/title-call.ts";const ROOT = fileURLToPath(new URL("..", import.meta.url));const RERUN_NOTE = "OpenMausBot restarted while your previous turn here was running";@@ -68,6 +69,7 @@ async function loopbackModel() {if (req.method !== "POST") { res.writeHead(404); res.end(); return; }for await (const chunk of req) body += chunk;const sent = JSON.parse(body) as { messages: Array<{ role: string; content?: unknown }>; tools?: Array<{ function: { name: string } }> };+ if (isTitleCall(sent)) { res.writeHead(500); res.end(); return; }const text = (message: { content?: unknown }) => typeof message.content === "string" ? message.content: Array.isArray(message.content) ? message.content.map((part: any) => part?.text ?? "").join("\n") : "";const lastUserAt = sent.messages.map((message) => message.role).lastIndexOf("user");diff --git a/server/testing/fake-claude-cli.ts b/server/testing/fake-claude-cli.tsindex 74410254a3..285ab1e67c 100755--- a/server/testing/fake-claude-cli.ts+++ b/server/testing/fake-claude-cli.ts@@ -499,8 +499,20 @@ if (["text", "json"].includes(argAfter("--output-format") ?? "")) {process.stderr.write("fake setup answers failed\n");process.exit(1);}+ // Every new thread asks its engine for a title (server/thread-title-generate.ts), so that call stays out of the captures+ // below unless a test answers it: by FAKE_CLAUDE_TEXT_FILE or a FAKE_CLAUDE_TEXT_ROUTES marker. Otherwise it fails at+ // once and the thread keeps its first-message title. Answered, it still never overwrites the turn dump.+ const titleCall = prompt.includes("Reply with only a short title: 3 to 6 words");+ const routes = process.env.FAKE_CLAUDE_TEXT_ROUTES;+ const routed = () => {+ try { return Object.keys(JSON.parse(readFileSync(routes!, "utf8"))).some((marker) => prompt.includes(marker)); } catch { return false; }+ };+ if (titleCall && !process.env.FAKE_CLAUDE_TEXT_FILE && !(routes && routed())) {+ process.stderr.write("fake title failed\n");+ replyText("fake title failed", 1, null);+ }// Background one-shots never overwrite the shared turn dump; FAKE_CLAUDE_TEXT_DUMP records them.- const upkeepCall = /You are the (?:CAPTURE|TIDY|ORGANIZE) step of a memory system|You are the SKILL REVIEW step/.test(prompt);+ const upkeepCall = titleCall || /You are the (?:CAPTURE|TIDY|ORGANIZE) step of a memory system|You are the SKILL REVIEW step/.test(prompt);const oneShotDump = process.env.FAKE_CLAUDE_TEXT_DUMP ?? (upkeepCall ? undefined : process.env.FAKE_CLAUDE_DUMP);if (oneShotDump) {writeDumpAtomic(diff --git a/server/testing/title-call.ts b/server/testing/title-call.tsnew file mode 100644index 0000000000..18a34b3f33--- /dev/null+++ b/server/testing/title-call.ts@@ -0,0 +1,6 @@+// Every new thread asks its engine for a title (server/thread-title-generate.ts). A fake provider that counts, holds or+// scripts model calls answers that one-shot with a failure first, on the request body it received, so the thread keeps+// its first-message title and the test sees only the calls it makes.+export function isTitleCall(body: unknown): boolean {+ return JSON.stringify(body ?? null).includes("Reply with only a short title: 3 to 6 words");+}