Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Release tests green after today's merges (#6249)
Milind Soni964f400bd36f
diff --git a/.gitattributes b/.gitattributesindex 4bf08542a6..7e7c1b8935 100644--- a/.gitattributes+++ b/.gitattributes@@ -63,3 +63,6 @@ scripts/sync-phone-protocol.mjs text eol=lf# through vitest: Vite's transform (vitest 4.1.11) fails with "Invalid or unexpected token" on a file that starts# with a shebang and has CRLF line endings, which is what a Windows checkout made of it.skills/** text eol=lf+# The Settings places list is generated by scripts/gen-settings-places.ts (LF) and compared byte for byte with what it+# writes in src/components/settings/settings-places.test.ts; a CRLF checkout on Windows would fail that for no drift.+shared/settings-places.ts text eol=lfdiff --git a/electron/data-dir-lease.mjs b/electron/data-dir-lease.mjsindex 74320da358..68f3dbc1ea 100644--- a/electron/data-dir-lease.mjs+++ b/electron/data-dir-lease.mjs@@ -2,7 +2,7 @@ import { execFileSync } from "node:child_process";import { createHash, randomUUID } from "node:crypto";import { existsSync, linkSync, mkdirSync, readdirSync, readFileSync, readlinkSync, realpathSync, renameSync, unlinkSync, writeFileSync } from "node:fs";import { homedir, hostname, uptime } from "node:os";-import { dirname, join } from "node:path";+import { dirname, join, posix } from "node:path";const LEASE_NAME = "openmausbot-server.lease";const DELEGATED_CHILD_DIR = ".openmausbot-server-child";@@ -211,11 +211,12 @@ export function macMountIsLocal(dfOutput, mountTable) {const MAC_SYNCED_FOLDERS = [["Library", "Mobile Documents"], ["Library", "CloudStorage"]];-/** iCloud Drive and File Provider sync folders (Dropbox, OneDrive, Google Drive) are local disks other Macs write to. */+/** iCloud Drive and File Provider sync folders (Dropbox, OneDrive, Google Drive) are local disks other Macs write to. Mac+ * paths, so joined with "/" on any host. */export function inMacSyncedFolder(path, home) {const lower = path.toLowerCase();return MAC_SYNCED_FOLDERS.some((parts) => {- const root = join(home, ...parts).toLowerCase();+ const root = posix.join(home, ...parts).toLowerCase();return lower === root || lower.startsWith(`${root}/`);});}@@ -417,7 +418,7 @@ function windowsProcessListed(pid) {/** tasklist ships with every Windows and lists every running process, whatever account or session owns it. */function tasklistHasPid(pid) {try {- const output = windowsOutput("tasklist", ["/FI", `PID eq ${pid}`, "/FO", "CSV", "/NH"], 5_000);+ const output = commandOutput("tasklist", ["/FI", `PID eq ${pid}`, "/FO", "CSV", "/NH"], 5_000);return output.split(/\r?\n/).some((line) => line.startsWith('"'));} catch {return null;@@ -427,7 +428,7 @@ function tasklistHasPid(pid) {function cimHasPid(pid) {const powershell = join(process.env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");try {- const output = windowsOutput(powershell, [+ const output = commandOutput(powershell, ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command",`if (Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}' -ErrorAction Stop) { '1' }`,], 15_000);diff --git a/server/automation-reports.e2e.test.ts b/server/automation-reports.e2e.test.tsindex 1b48b89ff9..18e323e301 100644--- a/server/automation-reports.e2e.test.ts+++ b/server/automation-reports.e2e.test.ts@@ -383,7 +383,11 @@ it("does not take a person's failed turn in a run's conversation for the run's oit("says in the main chat, once per run of failures, that an automation could not finish", async () => {const s = await server();- s.script([{ key: "run", match: [s.header("Inbox watch")], reply: "never", fail: true, repeat: true }]);+ // The automatic second start does not repeat the routine's header; it fails the same way, so both runs end on one error.+ s.script([+ { key: "run", match: [s.header("Inbox watch")], reply: "never", fail: true, repeat: true },+ { key: "retry", match: ["this run's first start"], reply: "never", fail: true, repeat: true },+ ]);const routineId = await s.routine("Inbox watch");const first = await s.runNow(routineId);await s.settled(first, "failed");@@ -393,6 +397,7 @@ it("says in the main chat, once per run of failures, that an automation could no})]);const second = await s.runNow(routineId);await s.settled(second, "failed");+ expect((await s.run(first)).error).toContain("Scripted addressed agent failure");expect((await s.run(second)).error).toBe((await s.run(first)).error);expect(await s.lines()).toHaveLength(1);}, 120_000);diff --git a/server/bot-link/link.test.ts b/server/bot-link/link.test.tsindex 766def49ac..0e01244fb9 100644--- a/server/bot-link/link.test.ts+++ b/server/bot-link/link.test.ts@@ -494,7 +494,8 @@ describe("the link between a computer and its Cloud", () => {it("a computer that goes off while it works for the Cloud holds the work without a clock and without keeping the Cloud busy", async () => {const { computer, cloud } = await two();// Only the Cloud's clocks are short: the computer's own work is not what is measured.- await cloud.restart({ limits: { queueMs: 80, stallMs: 2_000 } });+ // 3 s: seeing the computer gone takes about a second, longer on a busy Windows runner, and the clock runs until then.+ await cloud.restart({ limits: { queueMs: 80, stallMs: 3_000 } });await until(() => computer.link.online() && cloud.link.online(), "the link is back after the Cloud restarted");let release!: () => void;const gate = new Promise<void>((resolve) => { release = resolve; });@@ -504,7 +505,7 @@ describe("the link between a computer and its Cloud", () => {expect(cloud.coordinator.pace()).toBe("busy");await computer.dialer.stop();await until(() => !cloud.link.online(), "the Cloud sees the computer gone");- await new Promise((resolve) => setTimeout(resolve, 3_000));+ await new Promise((resolve) => setTimeout(resolve, 4_000));expect(cloud.coordinator.node(receipts[0]!.requestId!)?.status).toBe("running");expect(cloud.coordinator.pace()).toBe("parked");release();@@ -786,12 +787,13 @@ describe("the link between a computer and its Cloud", () => {await new Promise((resolve) => setTimeout(resolve, 900));expect(waiting().map((node) => node.status)).toEqual(["queued"]);expect(computer.coordinator.pace()).not.toBe("busy");- await computer.restart({ limits: { queueMs: 80, stallMs: 400 } });+ // The clocks are proven; restarted with its usual ones, the answer's round trip once the place is back (slower on+ // Windows) is not raced by a 400 ms stall clock.+ await computer.restart();expect(waiting().map((node) => node.status)).toEqual(["queued"]);expect(cloud.runs).toEqual([]);await cloud.listen(cloud.port);computer.dialer.start();- // Waits for the answer itself: on a slow runner the computer's 400 ms stall clock can add a line before it.await until(() => computer.said(room.id).some((line) => line.startsWith("Analyst: ")), "the answer is in the room");expect(computer.said(room.id).slice(0, 3)).toEqual(["Sam: @Analyst how many orders this week?", "(server.rooms.linkedAway Analyst [My Cloud])", "Sam: @Analyst and split them by country."]);const turns = cloud.runs.filter((run) => run.botId === "cloud-analyst");diff --git a/server/cloud-owner.test.ts b/server/cloud-owner.test.tsindex 6aadacd7c5..88a9cb8562 100644--- a/server/cloud-owner.test.ts+++ b/server/cloud-owner.test.ts@@ -201,10 +201,10 @@ describe("a Cloud home is personal: settling who its owner was (server/cloud-ownsettleCloudOwnership(options(w, undefined, {}, log));expect(w.unpinned).toEqual(["guest"]);expect(w.paused).toEqual(["theirs"]);- expect(log.filter((line) => line.includes("Paired devices"))).toHaveLength(1);+ expect(log.filter((line) => line.includes("Phone & devices → Paired"))).toHaveLength(1);const again: string[] = [];settleCloudOwnership(options(w, undefined, {}, again));- expect(again.join("\n")).not.toContain("Paired devices");+ expect(again.join("\n")).not.toContain("Phone & devices → Paired");expect(w.paused).toEqual(["theirs"]);});diff --git a/server/drivers/chat-mcp-browser-args.test.ts b/server/drivers/chat-mcp-browser-args.test.tsindex 98dd437fee..a9cfb9f7fe 100644--- a/server/drivers/chat-mcp-browser-args.test.ts+++ b/server/drivers/chat-mcp-browser-args.test.ts@@ -46,7 +46,7 @@ describe("loopbackNavigationHint", () => {it("stays quiet where the browser runs on the person's computer or the setting does not exist", () => {const failed = ["agent_browser_open", { url: "http://127.0.0.1:8188/" }, "Navigation to http://127.0.0.1:8188/ failed: ERR_SOCKS_CONNECTION_FAILED"] as const;- expect(loopbackNavigationHint(...failed, {})).toMatch(/Open sites on this server/);+ expect(loopbackNavigationHint(...failed, {})).toMatch(/Settings → Desktops & browser → Built-in browser/);// The desktop app: the browser and its loopback are the person's own computer.expect(loopbackNavigationHint(...failed, { OMB_DESKTOP_PARENT: "1" })).toBe("");// A Cloud home has no "Open sites on this server" row.diff --git a/server/host-files.test.ts b/server/host-files.test.tsindex dbd8409abe..5b9c7d5a40 100644--- a/server/host-files.test.ts+++ b/server/host-files.test.ts@@ -33,7 +33,8 @@ describe("file tools on disk", () => {for (const dir of made.splice(0)) rmSync(dir, { recursive: true, force: true });});const fixture = () => {- const root = realpathSync(mkdtempSync(join(tmpdir(), "omb-host-files-")));+ // Native, as the tools resolve: on Windows it also spells out a short (8.3) temp folder name such as RUNNER~1.+ const root = realpathSync.native(mkdtempSync(join(tmpdir(), "omb-host-files-")));made.push(root);const home = join(root, "home");mkdirSync(join(home, "Documents"), { recursive: true });diff --git a/server/kill-tree.test.ts b/server/kill-tree.test.tsindex a8542014ab..fa367a096e 100644--- a/server/kill-tree.test.ts+++ b/server/kill-tree.test.ts@@ -19,10 +19,18 @@ function reportedPid(stdout: Readable): Promise<number> {});}+/** A Linux process that has exited but waits to be collected (an orphan's new parent may take a moment) still answers+ * kill(pid, 0); killCliTree counts it as stopped, and so does this. */function alive(pid: number): boolean {try {process.kill(pid, 0);- return true;+ } catch {+ return false;+ }+ if (process.platform !== "linux") return true;+ try {+ const stat = readFileSync(`/proc/${pid}/stat`, "utf8");+ return !["Z", "X"].includes(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[0]!);} catch {return false;}diff --git a/server/perf/loop-stalls.test.ts b/server/perf/loop-stalls.test.tsindex 3646085694..9e43486532 100644--- a/server/perf/loop-stalls.test.ts+++ b/server/perf/loop-stalls.test.ts@@ -39,7 +39,8 @@ describe("the loop stall recorder", () => {const report = stalls.report();expect(report.m1!.max).toBeGreaterThanOrEqual(250);expect(report.m1!.over100ms).toBeGreaterThanOrEqual(1);- expect(report.m1!.p50).toBeLessThan(5);+ // One stall does not set the median; the rest is timer slop, a few ms late on a busy runner (Windows ticks every 15.6 ms).+ expect(report.m1!.p50).toBeLessThan(50);expect(report.h1!.max).toBe(report.m1!.max);expect(report.saves.m1.n).toBe(before + 1);expect(report.runtimeReads.m1).toMatchObject({ n: 1 });