Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Train fixes: size limits, OpenCode usage row, test leftovers
milind-soni146adbef6835
diff --git a/server/config.ts b/server/config.tsindex 3d900ce24c..d0f0d77fe1 100644--- a/server/config.ts+++ b/server/config.ts@@ -395,9 +395,7 @@ const appConfigSchema = z.object({.refine((value) => !value || /^https?:\/\//i.test(value), "the Chatterbox server address must start with http:// or https://").optional(),model: optionalText,- fishModel: z.enum(FISH_TTS_MODELS).optional(),- /** Every bot's replies come with a voice note unless the bot's own `voiceNoteEveryReply` says otherwise. */- everyReply: z.boolean().optional(),+ fishModel: z.enum(FISH_TTS_MODELS).optional(), everyReply: z.boolean().optional(), // a voice note with every reply unless a bot's voiceNoteEveryReply says otherwise}).optional(),decider: deciderConfigSchema.optional(),live: liveConfigSchema.optional(),diff --git a/server/container-computer.ts b/server/container-computer.tsindex 6c06ddb626..b91418f593 100644--- a/server/container-computer.ts+++ b/server/container-computer.ts@@ -918,22 +918,12 @@ function baseImagePullArgs(runtime: Runtime): string[] {return runtime === "container" ? ["image", "pull", BASE_IMAGE] : ["pull", BASE_IMAGE];}-/**- * Docker 29's legacy builder, which it still uses when it can't find the buildx plugin or `DOCKER_BUILDKIT=0` is set,- * keeps a step's stopped container when the build fails or the client goes away during the commit. Only `--force-rm`- * removes it. BuildKit accepts the flag and leaves no containers. Apple's `container build` has no such flag and- * builds with BuildKit.- */-export function imageBuildArgs(runtime: Runtime, tag: string, context: string): string[] {- return runtime === "container" ? ["build", "-t", tag, context] : ["build", "--force-rm", "-t", tag, context];-}-async function prepareManagedImage(runtime: Runtime, runner: CommandRunner): Promise<void> {await runner(runtime, baseImagePullArgs(runtime), 10 * 60_000);const context = await mkdtemp(join(tmpdir(), "openmausbot-cua-image-"));try {await writeFile(join(context, "Dockerfile"), managedImageDockerfile(), { mode: 0o600 });- await runner(runtime, imageBuildArgs(runtime, IMAGE, context), 10 * 60_000);+ await runner(runtime, ["build", ...(runtime === "container" ? [] : ["--force-rm"]), "-t", IMAGE, context], 10 * 60_000); // the legacy builder keeps a failed step's container without --force-rm} finally {await rm(context, { recursive: true, force: true });}diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.tsindex 709872d622..1f72b115c2 100644--- a/server/drivers/acp/core.ts+++ b/server/drivers/acp/core.ts@@ -1603,8 +1603,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>return;}const version = versionFromProbe(stdout, stderr);- resolve(!version ? { reason: `\`${config.cli}\` returned no version. Check the configured executable with --version, then try again.` }- : support.cliVersion && !support.cliVersion.test(version) ? { reason: notThisCli(config.cli, support.displayName), other: true } : { version });+ resolve(!version ? { reason: `\`${config.cli}\` returned no version. Check the configured executable with --version, then try again.` } : support.cliVersion && !support.cliVersion.test(version) ? { reason: notThisCli(config.cli, support.displayName), other: true } : { version });});});if (!probe.version) return { state: "unavailable", reason: probe.reason, ...(probe.other ? { notEngineCli: true } : {}) };diff --git a/server/engine-status-reads.e2e.test.ts b/server/engine-status-reads.e2e.test.tsindex 2e8337e46d..8d5cec5ba5 100644--- a/server/engine-status-reads.e2e.test.ts+++ b/server/engine-status-reads.e2e.test.ts@@ -1,6 +1,6 @@// Real server, fake Claude CLI that logs each status probe: an engine's CLI is probed once per answer, not once per reader.import { spawn, type ChildProcess } from "node:child_process";-import { appendFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";+import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";import { join } from "node:path";import { fileURLToPath } from "node:url";@@ -39,11 +39,8 @@ async function boot(home: string, knobs: Record<string, string> = {}) {stdio: ["ignore", "pipe", "pipe"],});children.push(child);- const logDir = join(tmpdir(), "openmausbot-verification-evidence");- mkdirSync(logDir, { recursive: true });- const logPath = join(logDir, `engine-status-${port}.log`);let output = "";- const capture = (chunk: Buffer) => { output += chunk; appendFileSync(logPath, chunk); };+ const capture = (chunk: Buffer) => { output += chunk; };child.stdout!.on("data", capture);child.stderr!.on("data", capture);await expect.poll(async () => {@@ -59,7 +56,7 @@ 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, logPath };+ return { call, control: (...args: string[]) => runControlOmb([...args, "--url", base]) as Promise<any>, stop };}const probeCount = (log: string, probe: "version" | "help" | "auth") =>@@ -92,9 +89,6 @@ it.each(["slow", "empty-once"])("detects a %s CLI across concurrent status readsconst transcript = await server.control("messages", "--bot", bot.id);expect(replies(transcript.messages)).toHaveLength(replies(initial.messages).length + 2);expect((await read()).modelSelection).toEqual(selection);- const evidenceDir = join(ROOT, ".omb-scratch", "issue-4195-detection");- mkdirSync(evidenceDir, { recursive: true });- writeFileSync(join(evidenceDir, `${mode}.json`), JSON.stringify({ mode, logPath: server.logPath, statuses: lists, versionProbes: probeCount(probes, "version"), selection, turns, transcript }, null, 2));}, 90_000);it("probes the engine's CLI once on a later start while the model lists arrive and the engine list is read", async () => {diff --git a/server/plan-usage.ts b/server/plan-usage.tsindex 32e61635a4..19ee6a8a2b 100644--- a/server/plan-usage.ts+++ b/server/plan-usage.ts@@ -293,7 +293,7 @@ export function defaultCredentialReader(env: NodeJS.ProcessEnv = process.env): Cexport async function fetchPlanUsage(accounts: PlanAccount[], deps: PlanUsageDeps): Promise<PlanUsageReport> {const now = deps.now?.() ?? Date.now();- const providers = await Promise.all(accounts.filter((account) => !account.noUsage).map((account) => fetchProvider(account, deps)));+ const providers = (await Promise.all(accounts.filter((account) => !account.noUsage).map((account) => fetchProvider(account, deps)))).filter((row) => row !== null);return { fetchedAt: new Date(now).toISOString(), providers };}@@ -918,14 +918,14 @@ function okRow(account: PlanAccount, windows: PlanWindows): PlanProviderRow {};}-async function fetchProvider(account: PlanAccount, deps: PlanUsageDeps): Promise<PlanProviderRow> {+async function fetchProvider(account: PlanAccount, deps: PlanUsageDeps): Promise<PlanProviderRow | null> { // null: OpenCode, in every fleet, with no key of its ownlet credential: PlanCredential;try {credential = await deps.credentials.read(account);} catch {- return errorRow(account, signInAgain(account.driver));+ return account.driver === "opencode" ? null : errorRow(account, signInAgain(account.driver));}- if (credential.expired || !credential.token) return errorRow(account, signInAgain(account.driver));+ if (credential.expired || !credential.token) return account.driver === "opencode" && !credential.expired ? null : errorRow(account, signInAgain(account.driver));try {if (account.driver === "claude") return await fetchClaude(account, credential.token, deps);if (account.driver === "codex") return await fetchCodex(account, credential.token, credential.accountId, deps);diff --git a/server/vps-computer.ts b/server/vps-computer.tsindex 5fc61d7fbc..c3fc60a697 100644--- a/server/vps-computer.ts+++ b/server/vps-computer.ts@@ -10,7 +10,6 @@ import {IMAGE as CUA_IMAGE,cuaExecArgs,dockerSecurityIsHardened,- imageBuildArgs,imageLabelsMatch,managedImageDockerfile,wholeScreenshot,@@ -897,7 +896,7 @@ function assertUsableContainer(status: VpsComputerStatus) {async function prepareVpsImage(alias: string, runner: VpsCommandRunner) {await runner(vpsDockerArgs(alias, ["pull", BASE_IMAGE]), { timeoutMs: 10 * 60_000 });- await runner(vpsDockerArgs(alias, imageBuildArgs("docker", VPS_IMAGE, "-")), {+ await runner(vpsDockerArgs(alias, ["build", "--force-rm", "-t", VPS_IMAGE, "-"]), {input: managedImageDockerfile(),timeoutMs: 10 * 60_000,});diff --git a/shared/wire.ts b/shared/wire.tsindex 439d92776d..367766da89 100644--- a/shared/wire.ts+++ b/shared/wire.ts@@ -340,8 +340,7 @@ export interface WireBot extends DefaultBotFields, BotAccessFields {voice?: string;/** Whether this bot may send voice notes. Absent/true = allowed; false* hides the tool and refuses the route even with a voice configured. */- voiceNotes?: boolean;- /** The harness speaks each reply as a voice note; absent follows the installation's `tts.everyReply`. */ voiceNoteEveryReply?: boolean;+ voiceNotes?: boolean; /** The harness speaks each reply as a voice note; absent follows the installation's `tts.everyReply`. */ voiceNoteEveryReply?: boolean;/** Whether this bot may use the X research tools (x_search and its* actions), which spend the workspace's treg balance.* Absent/false = off: the person turns it on per bot. */diff --git a/src/state/store.tsx b/src/state/store.tsxindex 3ba0220024..472d071d5a 100644--- a/src/state/store.tsx+++ b/src/state/store.tsx@@ -308,9 +308,7 @@ export interface Bot extends DefaultBotFields, Pick<WireBot, "mascotFaceColor" |speakReplies?: boolean;replyStyle?: import("../../shared/wire").WireBot["replyStyle"];voice?: string;- voiceNotes?: boolean; xResearch?: boolean;- /** null or absent: follows the Voice setting. */- voiceNoteEveryReply?: boolean | null;+ voiceNotes?: boolean; xResearch?: boolean; voiceNoteEveryReply?: boolean | null; // null or absent: follows the Voice settingmemoryEnabled?: boolean;pinned?: boolean;hidden?: boolean;@@ -1693,12 +1691,7 @@ export function reducer(state: AppState, action: Action): AppState {const threadId = action.threadId ?? bot?.threadId;if (!bot || threadId !== bot.threadId) return animated;if (bot.messages.some((message) => message.sendId === action.sendId)) return animated;- const message = optimisticUserMessage(- action.text,- action.sendId,- action.replyToId,- bot.activeLeafId,- );+ const message = optimisticUserMessage(action.text, action.sendId, action.replyToId, bot.activeLeafId);message.optimisticThreadOrderAt = bot.tasks?.find((task) => task.threadId === threadId)?.lastThreadOrderAt;return bumpThreadUpdatedAt(updateBot(animated, bot.id, (current) => ({...current,