Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Main green: prompt and surface tests after today's merges (#6229)
Milind Soniafa9872988b2
diff --git a/server/drivers/claude.test.ts b/server/drivers/claude.test.tsindex fc9943c7e2..36d8d93ff8 100644--- a/server/drivers/claude.test.ts+++ b/server/drivers/claude.test.ts@@ -1356,7 +1356,10 @@ describe("ClaudeDriver turns (fake CLI)", () => {const agents = seen.mcpConfig.mcpServers.agents;expect(agents).toMatchObject({ type: "http", alwaysLoad: true, url: "http://127.0.0.1:1/api/internal/mcp-http/agents", headers: { authorization: "Bearer tok" } });expect(JSON.parse(Buffer.from(agents.headers["x-omb-agents-env"], "base64url").toString("utf8"))).toMatchObject({ OMB_BOT_ID: "b1", [DEFER_TOOLS_ENV]: "1" });- for (const name of ["NO_PROXY", "no_proxy"]) expect(seen.env[name].split(",")).toEqual(expect.arrayContaining(["127.0.0.1", "localhost", "::1"]));+ // Windows keeps one spelling of an environment name, so the engine sees NO_PROXY or no_proxy there, never both.+ const noProxy = Object.entries(seen.env as Record<string, string>).filter(([name]) => name.toLowerCase() === "no_proxy");+ expect(noProxy.map(([name]) => name).sort()).toEqual(process.platform === "win32" ? [expect.stringMatching(/^no_proxy$/i)] : ["NO_PROXY", "no_proxy"]);+ for (const [, value] of noProxy) expect(value.split(",")).toEqual(expect.arrayContaining(["127.0.0.1", "localhost", "::1"]));} else {expect(seen.mcpConfig.mcpServers.agents).toMatchObject({alwaysLoad: true,@@ -3743,7 +3746,13 @@ describe("ClaudeDriver turns (fake CLI)", () => {// A tool call leaves a process behind in the engine's group, as a dev server or an MCP server does.process.env.FAKE_CLAUDE_RUN_BASH = "1";process.env.FAKE_CLAUDE_TOOL_CALLS = JSON.stringify([{ name: "Bash", input: { command: `"${process.execPath}" -e "setTimeout(() => {}, 60000)" >/dev/null 2>&1 & echo $! > "${marker}"` } }]);- const alive = (value: number) => { try { process.kill(value, 0); return true; } catch { return false; } };+ // An exited process its new parent has not collected yet still answers kill(pid, 0); on Linux it is gone once /proc+ // says Z or X, as stopCliTree counts it (procs.ts linuxGroupOnlyExited).+ const alive = (value: number) => {+ try { process.kill(value, 0); } catch { return false; }+ if (process.platform !== "linux") return true;+ try { const stat = readFileSync(`/proc/${value}/stat`, "utf8"); return !["Z", "X"].includes(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[0]!); } catch { return false; }+ };let left = 0;try {await create();diff --git a/server/host-files.e2e.test.ts b/server/host-files.e2e.test.tsindex 2b31a7954e..c2c000250a 100644--- a/server/host-files.e2e.test.ts+++ b/server/host-files.e2e.test.ts@@ -164,19 +164,21 @@ describe("file tools on this computer, through its bridge", () => {const gate = await controlServer();const controller = new AbortController();const sessions: ChatToolSession[] = [];- const mount = async (env: Record<string, string>) => {+ // The first start gets the whole start budget, so a slow runner lists the real tools instead of the stand-in+ // (computer_tools_status, chat-host-computer.ts); a later turn waits only briefly and goes on with the list remembered.+ const mount = async (env: Record<string, string>, startupMs: number) => {const turn = withHostFileTools({ localComputer: gatedLocalComputer(driver(env), gate.control) });const localComputer = { ...turn!.localComputer!, env: { ...turn!.localComputer!.env, HOME: home, USERPROFILE: home } };- const session = await mountChatTools({ localComputer }, controller.signal, true, undefined, undefined, undefined, undefined, undefined, undefined, { startupMs: 300, hostComputerMs: 20_000 });+ const session = await mountChatTools({ localComputer }, controller.signal, true, undefined, undefined, undefined, undefined, undefined, undefined, { startupMs, hostComputerMs: 20_000 });sessions.push(session);return session;};const names = (session: ChatToolSession) => session.definitions.map((definition) => definition.function.name);try {- const cold = await mount({});+ const cold = await mount({}, 20_000);expect(names(cold)).toEqual(["computer_screenshot", ...FILE_TOOLS.map((name) => `computer_${name}`)]);const asked = Date.now();- const warm = await mount({ FAKE_DELAY_MS: "2500" });+ const warm = await mount({ FAKE_DELAY_MS: "2500" }, 300);expect(Date.now() - asked).toBeLessThan(2_000);expect(names(warm)).toEqual(names(cold));const saved = await warm.execute("computer_write_file", { path: join(home, "Documents", "nota.txt"), content: "oi" }, controller.signal);diff --git a/server/host-lazy-claim.e2e.test.ts b/server/host-lazy-claim.e2e.test.tsindex adcc1c4c4b..74905e0f3b 100644--- a/server/host-lazy-claim.e2e.test.ts+++ b/server/host-lazy-claim.e2e.test.ts@@ -354,7 +354,7 @@ describe("lazy host claim and pin on use (issue #1650)", () => {const first = timed(client.state(true, { app: "Chrome", site: "calendar.google.com" }));const card = await openYourComputerCard(base, task.threadId);expect(card.title).toBe("I need to use your Chrome where you're signed in to calendar.google.com. Allow once?");- expect(card.subtitle).toBe("Host Asking Bot would see your screen and click and type on it, for this request only.");+ expect(card.subtitle).toBe("Host Asking Bot can use your files and apps here: it sees your screen and clicks and types on it, for this request only.");expect((await threadState(bot.id, task.threadId))?.activity).toBe("waiting-on-you");// Unanswered, the call is not performed and says why, then waits again.const unanswered = await first;diff --git a/server/meetings/prompt.ts b/server/meetings/prompt.tsindex 5aac068fac..a8986325d8 100644--- a/server/meetings/prompt.ts+++ b/server/meetings/prompt.ts@@ -7,5 +7,5 @@ export const MEETINGS_NEED_CLOUD_COMPUTER = "Meeting notes run on a cloud comput/** The system prompt part for a bot with the agents tools on a server with no cloud computer; nothing otherwise. */export function meetingsUnavailablePrompt({ agentsTools, cloudComputer }: { agentsTools: boolean; cloudComputer: boolean }): string {if (!agentsTools || cloudComputer) return "";- return ` You can't join online meetings to take notes here, so you have no meeting tools. When the person asks you to join a meeting or sends a meeting link, tell them in one line: ${MEETINGS_NEED_CLOUD_COMPUTER}`;+ return ` You can't join meetings to take notes here, so you have no meeting tools. When the person asks you to join a meeting or sends a meeting link, tell them in one line: ${MEETINGS_NEED_CLOUD_COMPUTER}`;}diff --git a/server/shared-computers.gate.test.ts b/server/shared-computers.gate.test.tsindex 2568f46bc1..57b4be3f1e 100644--- a/server/shared-computers.gate.test.ts+++ b/server/shared-computers.gate.test.ts@@ -189,7 +189,8 @@ it("features.sharedComputers true brings the whole surface back, for every paireconst listed = await internal("GET", "/api/internal/shared-computers");expect(listed.status).toBe(200);- expect(listed.body).toEqual({ computers: [] });+ // A bot not on This computer is told it is never in this list (#6203).+ expect(listed.body).toEqual({ computers: [], thisComputer: expect.stringContaining("This computer itself is never in this list") });expect(await api("GET", "/api/shared-computers")).toEqual({ status: 200, body: { computers: [], known: [] } });expect(await descriptorCapabilities()).toMatchObject({ sharedComputers: true });diff --git a/server/turn-prompt-budget.test.ts b/server/turn-prompt-budget.test.tsindex 10364dc452..d37338989a 100644--- a/server/turn-prompt-budget.test.ts+++ b/server/turn-prompt-budget.test.ts@@ -68,8 +68,9 @@ const PROMPT_BUDGET_BASELINE: Record<string, number> = {"routine": 3367,"profile": 1016,"team-memory": 286,- "computer:vm-private": 5783,- "computer:vm-shared": 5778,+ // #6203: +130 bytes on both sandbox kinds, on purpose: the person's own files (C:\Users\…, /Users/…, Desktop) are reached only on This computer.+ "computer:vm-private": 5913,+ "computer:vm-shared": 5908,"computer:box": 4382,"computer:vps": 5026,"computer:local": 5335,diff --git a/server/use-my-mac.e2e.test.ts b/server/use-my-mac.e2e.test.tsindex ca5cd9a1ba..542cfed8d0 100644--- a/server/use-my-mac.e2e.test.ts+++ b/server/use-my-mac.e2e.test.ts@@ -227,11 +227,19 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl`, { mode: 0o755 });// The bot's browser engine as the server finds it: it names the Chrome its turns would drive, through the gate.// It writes down the egress gate each command's Chrome would go through: the bot's own, for the life of the server.+ // Its daemon's pid file (where browserDaemonFile looks) says that browser runs until it is closed, so the server's+ // sweep of ended browsers (host/browser.ts, every minute) leaves its gate open while a case still uses it.writeFileSync(join(home, "agent-browser"), `#!${process.execPath}+const fs = require("node:fs"), path = require("node:path");const args = process.argv.slice(2).filter((arg) => arg !== "--json" && arg !== "--no-webmcp");if (args[0] === "--version") { console.log("agent-browser 0.37.0"); process.exit(0); }-if (process.env.AGENT_BROWSER_PROXY) require("node:fs").appendFileSync(${JSON.stringify(join(home, "gates.txt"))}, process.env.AGENT_BROWSER_SESSION + " " + process.env.AGENT_BROWSER_PROXY + "\\n");-const running = require("node:fs").existsSync(${JSON.stringify(join(home, "browser-running"))});+const env = process.env, session = env.AGENT_BROWSER_SESSION ?? "";+const base = env.XDG_RUNTIME_DIR ? path.join(env.XDG_RUNTIME_DIR, "agent-browser") : path.join(env.HOME || require("node:os").homedir(), ".agent-browser");+const pid = env.AGENT_BROWSER_SOCKET_DIR ? path.join(env.AGENT_BROWSER_SOCKET_DIR, session + ".pid") : path.join(env.AGENT_BROWSER_NAMESPACE ? path.join(base, "namespaces", env.AGENT_BROWSER_NAMESPACE, "run") : base, session + ".pid");+if (args[0] === "close") fs.rmSync(pid, { force: true });+else if (env.AGENT_BROWSER_PROXY) { fs.mkdirSync(path.dirname(pid), { recursive: true }); fs.writeFileSync(pid, String(process.pid)); }+if (env.AGENT_BROWSER_PROXY) fs.appendFileSync(${JSON.stringify(join(home, "gates.txt"))}, session + " " + env.AGENT_BROWSER_PROXY + "\\n");+const running = fs.existsSync(${JSON.stringify(join(home, "browser-running"))});process.stdout.write(JSON.stringify({ success: true, data: args[0] === "session" ? { sessions: running ? [process.env.AGENT_BROWSER_SESSION] : [] } : {} }));`, { mode: 0o755 });chmodSync(join(home, "agent-browser"), 0o755);