Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
test: the screenshot-store and Mac voice tests stop depending on a fast CI machine
milind-soni785eff2a5c04
diff --git a/server/browser-evidence.test.ts b/server/browser-evidence.test.tsindex 33fcb893ef..6f3625d455 100644--- a/server/browser-evidence.test.ts+++ b/server/browser-evidence.test.ts@@ -1,4 +1,4 @@-import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync } from "node:fs";+import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, truncateSync, utimesSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";import { join } from "node:path";import { PassThrough } from "node:stream";@@ -7,6 +7,8 @@ import { Parser } from "tar";import { BrowserEvidence, EVIDENCE_LIMITS, imageFileName, type StepRecord } from "./browser-evidence.ts";+const fileOfSize = (path: string, bytes: number) => { writeFileSync(path, ""); truncateSync(path, bytes); };+const posix = process.platform !== "win32";const GEN = "6f1c2a3b-4d5e-4f60-8a7b-9c0d1e2f3a4b";const GEN2 = "7a1c2a3b-4d5e-4f60-8a7b-9c0d1e2f3a4b";@@ -89,7 +91,7 @@ describe("the browser step store", () => {const small = store({ free: 1.25 * 1024 ** 3 });await small.sweep();mkdirSync(join(small.root, "thread-old", GEN), { recursive: true });- writeFileSync(join(small.root, "thread-old", GEN, imageFileName(9)), Buffer.alloc(330 * 1024 ** 2));+ fileOfSize(join(small.root, "thread-old", GEN, imageFileName(9)), 330 * 1024 ** 2);await small.sweep();// Over the cap: the oldest other conversation's screenshots go first, its steps stay.writeFileSync(join(small.root, "thread-old", GEN, "steps.jsonl"), `${JSON.stringify({ v: 1, step: 9, threadId: "thread-old", generation: GEN, image: imageFileName(9) })}\n`);@@ -102,7 +104,7 @@ describe("the browser step store", () => {it("caps one conversation at 200 MB of screenshots", async () => {const evidence = store();mkdirSync(join(evidence.root, "thread-1", GEN2), { recursive: true });- writeFileSync(join(evidence.root, "thread-1", GEN2, imageFileName(5)), Buffer.alloc(EVIDENCE_LIMITS.threadBytes));+ fileOfSize(join(evidence.root, "thread-1", GEN2, imageFileName(5)), EVIDENCE_LIMITS.threadBytes);expect((await shot(evidence, "thread-1", Buffer.from("x"))).imageSkipped).toBe("thread-cap");expect((await shot(evidence, "thread-2", Buffer.from("x"))).image).not.toBeNull();});@@ -130,9 +132,9 @@ describe("the browser step store", () => {const evidence = store({ free: 1.25 * 1024 ** 3, now: () => now });await shot(evidence, "thread-busy", Buffer.from("live turn"));// The store is over its 320 MB cap, and the busy turn holds most of it.- writeFileSync(join(evidence.root, "thread-busy", GEN, imageFileName(500)), Buffer.alloc(300 * 1024 ** 2));+ fileOfSize(join(evidence.root, "thread-busy", GEN, imageFileName(500)), 300 * 1024 ** 2);mkdirSync(join(evidence.root, "thread-idle", GEN2), { recursive: true });- writeFileSync(join(evidence.root, "thread-idle", GEN2, imageFileName(7)), Buffer.alloc(40 * 1024 ** 2));+ fileOfSize(join(evidence.root, "thread-idle", GEN2, imageFileName(7)), 40 * 1024 ** 2);now += 60_000;await evidence.sweep();expect(readdirSync(join(evidence.root, "thread-busy", GEN)).filter((name) => name.endsWith(".jpg"))).toHaveLength(2);diff --git a/server/voice-notes.e2e.test.ts b/server/voice-notes.e2e.test.tsindex 4e6a20c369..ccecf0e4ce 100644--- a/server/voice-notes.e2e.test.ts+++ b/server/voice-notes.e2e.test.ts@@ -1,12 +1,16 @@// The TTS provider is a loopback Chatterbox stub, so no external service is reached.+import { execFile } from "node:child_process";import { createServer, type Server } from "node:http";import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";import { join } from "node:path";+import { promisify } from "node:util";import { expect, it } from "vitest";import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";import { request } from "../scripts/mcp-server.ts";import { listSystemVoices } from "./tts/system-voices.ts";+const execFileAsync = promisify(execFile);+const MP3 = Buffer.from("ID3 fake mp3 for the voice note fixture");async function withVoiceFixture(test: (f: any) => Promise<void>, options?: { failFirstAudioAppend?: boolean }) {@@ -154,13 +158,17 @@ it("delivers a WAV voice note from a provider that answers in WAV", async () =>expect((await sendWavNote(f)).equals(wav)).toBe(true);}), 60_000);-it.runIf(process.platform === "darwin")("delivers a voice note spoken by the built-in Mac voices", async () => withVoiceFixture(async (f) => {- const [voice] = await listSystemVoices();- await f.api("/api/config", { tts: { provider: "system", voice: voice!.id } }, "PUT");- const served = await sendWavNote(f);- expect(served.subarray(0, 4).toString("latin1")).toBe("RIFF");- expect(served.subarray(8, 12).toString("latin1")).toBe("WAVE");-}), 60_000);+it.runIf(process.platform === "darwin")("delivers a voice note spoken by the built-in Mac voices", async ({ skip }) => {+ // A cold CI Mac can take longer than the app's 5 s to list its voices, and some runner images have none.+ const [voice] = await listSystemVoices((file, args) => execFileAsync(file, args, { timeout: 30_000 }));+ if (!voice) return skip("this Mac lists no system voices");+ await withVoiceFixture(async (f) => {+ await f.api("/api/config", { tts: { provider: "system", voice: voice.id } }, "PUT");+ const served = await sendWavNote(f);+ expect(served.subarray(0, 4).toString("latin1")).toBe("RIFF");+ expect(served.subarray(8, 12).toString("latin1")).toBe("WAVE");+ });+}, 60_000);it("keeps a voice-only reply's words on the attachment as its transcript when the turn writes no reply", async () => withVoiceFixture(async (f) => {const baseUrl = await f.serveTts();