Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Refuse Local VM computer use inside the bot box
Ooi Pin Jundaf566592449
diff --git a/docs/bot-box.md b/docs/bot-box.mdindex b3003c20c0..2aaac8056f 100644--- a/docs/bot-box.md+++ b/docs/bot-box.md@@ -66,6 +66,9 @@ checks it guards.## What it does not do yet+- **Local VM (Docker) computer use.** The computer MCP talks to the Local VM over the host's Docker socket. The box does not expose that socket (mounting it would be root-equivalent on the host), so with the bot box on a Local VM turn fails early with a clear message instead of "MCP server exited". Use this computer, a Cloud computer, or turn the box off for Local VM work.++- The engines' subscription logins (`~/.claude`, `~/.codex`) are in the box, because the engine needs them. API keysstay in the environment until the credential broker (T0b) replaces them with per-turn tokens.- The box runs as the server's own user inside a user namespace; a separate Linux user per bot needs a privilegeddiff --git a/server/index.ts b/server/index.tsindex 7be7f9289b..d10e7b6e37 100644--- a/server/index.ts+++ b/server/index.ts@@ -132,7 +132,6 @@ import { canManage, canReach, hasTeamAuthority, livePeerRoster, livePeerRosterBlimport {containerComputerAction,containerComputerFrame,- containerComputerMcp,containerComputerStatus,containerExec,containerRuntimeStatus,@@ -145,6 +144,7 @@ import {type LocalVmTarget,type Runtime,} from "./container-computer.ts";+import { containerComputerMcp } from "./local-vm-box.ts";import { attachForTurn, saveBotAttachment } from "./bot-attachment.ts";import {cacheUntilConfigChanges,diff --git a/server/local-vm-box.test.ts b/server/local-vm-box.test.tsnew file mode 100644index 0000000000..435a3056b5--- /dev/null+++ b/server/local-vm-box.test.ts@@ -0,0 +1,36 @@+import { describe, expect, it, vi } from "vitest";++vi.mock("./bot-box/box.ts", () => ({+ botBox: { enabled: vi.fn(() => false) },+}));++import { botBox } from "./bot-box/box.ts";+import {+ containerComputerMcp,+ LOCAL_VM_IN_BOX_MESSAGE,+ localVmInBoxMessage,+} from "./local-vm-box.ts";++describe("Local VM inside the bot box", () => {+ it("names the Docker socket limit when the box is on", () => {+ expect(localVmInBoxMessage(true)).toBe(LOCAL_VM_IN_BOX_MESSAGE);+ expect(LOCAL_VM_IN_BOX_MESSAGE).toContain("Docker socket");+ expect(LOCAL_VM_IN_BOX_MESSAGE).toContain("bot box");+ });++ it("allows the mount message when the box is off", () => {+ expect(localVmInBoxMessage(false)).toBeUndefined();+ });++ it("refuses containerComputerMcp while the bot box is enabled", () => {+ vi.mocked(botBox.enabled).mockReturnValue(true);+ expect(() => containerComputerMcp("docker")).toThrow(LOCAL_VM_IN_BOX_MESSAGE);+ });++ it("mounts normally while the bot box is off", () => {+ vi.mocked(botBox.enabled).mockReturnValue(false);+ const connection = containerComputerMcp("podman");+ expect(connection.command).toBe(process.execPath);+ expect(connection.args).toContain("podman");+ });+});diff --git a/server/local-vm-box.ts b/server/local-vm-box.tsnew file mode 100644index 0000000000..019d8c558a--- /dev/null+++ b/server/local-vm-box.ts@@ -0,0 +1,29 @@+// Local VM computer MCP needs the host Docker socket. The bot box does not expose it+// (mounting docker.sock would be root-equivalent), so refuse the mount early with a clear+// message instead of letting the MCP exit as "MCP server exited".+import { botBox } from "./bot-box/box.ts";+import {+ containerComputerMcp as mountContainerComputerMcp,+ type LocalVmTarget,+ SHARED_LOCAL_VM_TARGET,+} from "./container-computer.ts";++export const LOCAL_VM_IN_BOX_MESSAGE =+ "The Local VM needs the Docker socket, which the bot box does not expose";++export function localVmInBoxMessage(boxEnabled: boolean): string | undefined {+ return boxEnabled ? LOCAL_VM_IN_BOX_MESSAGE : undefined;+}++type Runtime = Parameters<typeof mountContainerComputerMcp>[0];++/** Drop-in for containerComputerMcp that refuses when the bot box is on. */+export function containerComputerMcp(+ runtime: Runtime,+ control?: { url: string; token: string },+ target: LocalVmTarget = SHARED_LOCAL_VM_TARGET,+): ReturnType<typeof mountContainerComputerMcp> {+ const boxed = localVmInBoxMessage(botBox.enabled());+ if (boxed) throw Object.assign(new Error(boxed), { status: 409, code: "bot_box" });+ return mountContainerComputerMcp(runtime, control, target);+}