Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Tests: cloud-send-big saves each bot once; fixture servers never download the model list (#6777)
Milind Soni1a7c4a16d3a5
diff --git a/scripts/control-omb.test.ts b/scripts/control-omb.test.tsindex 91e6bc161e..dc36d7ce55 100644--- a/scripts/control-omb.test.ts+++ b/scripts/control-omb.test.ts@@ -14,6 +14,11 @@ describe("a fixture driven from a real browser", () => {expect(childEnv({}).OMB_DEV_TRUST_LOCAL_BROWSER).toBe("1");expect(childEnv({ OMB_DEV_TRUST_LOCAL_BROWSER: "0" })).not.toHaveProperty("OMB_DEV_TRUST_LOCAL_BROWSER");});++ it("boots on the bundled model list, never the one published on main", () => {+ expect(childEnv({}).OMB_DISABLE_MODEL_MANIFEST_FETCH).toBe("1");+ expect(childEnv({ OMB_DISABLE_MODEL_MANIFEST_FETCH: "0" }).OMB_DISABLE_MODEL_MANIFEST_FETCH).toBe("1");+ });});describe("the fixture's fake engine knobs", () => {diff --git a/scripts/control-omb.ts b/scripts/control-omb.tsindex 30ded8cfa3..4246510b89 100644--- a/scripts/control-omb.ts+++ b/scripts/control-omb.ts@@ -164,6 +164,9 @@ export function verificationServerEnvironment(parentEnv: NodeJS.ProcessEnv, dataOMB_TEST_SEALED_PATH: "1",// The project's live announcement cards would sit over the corner the UI tests click in.OMB_DISABLE_ANNOUNCEMENTS: "1",+ // The bundled model list, as in-process tests use: a downloaded one that differs makes the engines read their status+ // again mid-boot, so what a fixture probes would depend on what is published on main.+ OMB_DISABLE_MODEL_MANIFEST_FETCH: "1",});// The fake engines' knobs are the one thing a caller may script into the child.for (const [key, value] of Object.entries(parentEnv)) {diff --git a/server/cloud-send-big.test.ts b/server/cloud-send-big.test.tsindex 95055c938e..ae6a63eb95 100644--- a/server/cloud-send-big.test.ts+++ b/server/cloud-send-big.test.ts@@ -9,7 +9,8 @@ import { cloudSendManifest } from "./cloud-send-manifest.ts";import { attachmentNamesOf, linkedPath, threadLinks } from "./cloud-send-rows.ts";import { DATA_DIR } from "./config.ts";import { deleteThread, threadHeads } from "./message-db.ts";-import { Store, type Message } from "./store.ts";+import { Store, type Message, type TaskRecord } from "./store.ts";+import { buildTask } from "./task-record.ts";const BOTS = 100, TASKS = 20, ROWS = 12;@@ -27,14 +28,19 @@ function counted(store: Store) {}/** 100 bots with 20 conversations each, 12 rows to a conversation, every fourth line with a stored attachment; a few rows- * stored without a parent, as an old app stored them. */+ * stored without a parent, as an old app stored them. Each bot is saved once with all its threads, newest first as+ * createTask leaves them: a save per thread would rewrite the whole of bots.json 2,000 times (464 MB, each synced). */function bigWorkspace() {const store = new Store(() => ({ instanceId: "fixture", model: "fixture-model" }));const threads: string[] = [];let at = 1_000, attachment = 0;for (let b = 0; b < BOTS; b++) {- const bot = store.createBot({ name: `Bot ${b}` }, { seedMessages: false });- const conversations = [bot.threadId, ...Array.from({ length: TASKS - 1 }, (_, i) => store.createTask(bot.id, `Task ${i}`, false)!.threadId)];+ const added: TaskRecord[] = [];+ const bot = store.createBot({ name: `Bot ${b}` }, { seedMessages: false, settle: (made) => {+ added.push(...Array.from({ length: TASKS - 1 }, (_, i) => buildTask(made, `Task ${i}`)));+ made.tasks = [...[...added].reverse(), ...made.tasks!];+ } });+ const conversations = [bot.threadId, ...added.map((task) => task.threadId)];for (const threadId of conversations) {const rows: Message[] = [];for (let r = 0; r < ROWS; r++) {diff --git a/server/engine-status-reads.e2e.test.ts b/server/engine-status-reads.e2e.test.tsindex 6a526fb15a..c3ad79b2cd 100644--- a/server/engine-status-reads.e2e.test.ts+++ b/server/engine-status-reads.e2e.test.ts@@ -56,11 +56,14 @@ async function boot(home: string, knobs: Record<string, string> = {}) {return response.json() as Promise<any>;};const stop = () => waitForExit(child, { signal: "SIGTERM" });- return { call, control: (...args: string[]) => runControlOmb([...args, "--url", base]) as Promise<any>, stop };+ return { call, control: (...args: string[]) => runControlOmb([...args, "--url", base]) as Promise<any>, stop, output: () => output };}const probeCount = (log: string, probe: "version" | "help" | "auth") =>existsSync(log) ? readFileSync(log, "utf8").split("\n").filter((line) => line.startsWith(`${probe} `)).length : 0;+/** For a count that is off: each probe in order (a re-read repeats version and auth; a reloaded engine repeats help too),+ * and the server's own log. */+const probeEvidence = (log: string, output: string) => `probes:\n${existsSync(log) ? readFileSync(log, "utf8") : "(none)"}\nserver:\n${output.slice(-6_000)}`;const claudeStatus = (body: { instances: Array<{ instanceId: string; snapshot: Record<string, unknown> }> }) =>body.instances.find((instance) => instance.instanceId === "claude")!.snapshot;@@ -73,7 +76,7 @@ it.each(["slow", "empty-once"])("detects a %s CLI across concurrent status reads});const lists = await Promise.all([server.call("GET", "/api/instances"), server.call("GET", "/api/instances"), server.call("GET", "/api/instances")]);for (const list of lists) expect(claudeStatus(list)).toMatchObject({ state: "available", authenticated: true, version: expect.stringContaining("Claude Code") });- expect(probeCount(probes, "version")).toBe(mode === "slow" ? 1 : 2);+ expect(probeCount(probes, "version"), probeEvidence(probes, server.output())).toBe(mode === "slow" ? 1 : 2);const { bot } = await server.control("new-bot", "--name", "Detection fixture");const read = async () => (await server.call("GET", "/api/bots?messages=0")).bots.find((item: { id: string }) => item.id === bot.id);const selection = (await read()).modelSelection;