Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
#5787 fixes: stay under the pins, no browser sign-in per turn, shared install message back
milind-sonie02606fb3c77
diff --git a/scripts/testing/file-size-ratchet.test.ts b/scripts/testing/file-size-ratchet.test.tsindex 933428256b..63c3058c26 100644--- a/scripts/testing/file-size-ratchet.test.ts+++ b/scripts/testing/file-size-ratchet.test.ts@@ -22,12 +22,12 @@ const LINES: Record<string, number> = {"server/store.ts": 2289,"src/components/Sidebar.tsx": 1687,"server/drivers/claude.ts": 2087,- "server/drivers/acp/core.ts": 1717,+ "server/drivers/acp/core.ts": 1703,"server/drivers/codex.ts": 1718,"server/routines.ts": 1555,"src/components/ComputerPanel.tsx": 1782,"src/components/RoutineCalendarPage.tsx": 1622,- "server/config.ts": 1248,+ "server/config.ts": 1244,"src/components/ChatView.tsx": 1282,"server/routine-requests.ts": 1474,"src/components/GroupView.tsx": 1215,diff --git a/server/config.ts b/server/config.tsindex 98fe857941..a660ff3714 100644--- a/server/config.ts+++ b/server/config.ts@@ -1110,12 +1110,9 @@ export function instanceOwnsRouting(case "modelgo": return own(entry.environment?.MODELGO_API_KEY) || ownUrl("https://api.modelgo.ai/v1");case "meta":return own(entry.environment?.META_API_KEY) || ownUrl("https://api.meta.ai/v1", cfg.meta?.url);- case "deepseekAgent":- // A second DeepSeek Harness account brings its own key; the workspace key fills only an instance without one.- return own(entry.environment?.DEEPSEEK_API_KEY);- case "mistralVibeAgent":- // A second Vibe CLI account brings its own key; the workspace key fills only an instance without one.- return own(entry.environment?.MISTRAL_API_KEY);+ case "deepseekAgent": case "mistralVibeAgent":+ // A second DeepSeek Harness or Vibe CLI account brings its own key; the workspace key fills only an instance without one.+ return own(entry.environment?.[entry.driver === "deepseekAgent" ? "DEEPSEEK_API_KEY" : "MISTRAL_API_KEY"]);case "grok":return own(entry.environment?.XAI_API_KEY) || (own(config.apiKeyEnv) && config.apiKeyEnv !== "XAI_API_KEY")|| ownUrl("https://api.x.ai/v1", cfg.xai?.url);@@ -1127,13 +1124,12 @@ export function instanceOwnsRouting(/** Each secret goes only to the driver that reads it; the Boat token reaches no engine. */function injectedEnvironment(cfg: AppConfig, instanceId: string, driver: string): Map<string, string> {const environment = new Map<string, string>();- if (driver === "mistral" && cfg.mistral?.key) environment.set("MISTRAL_API_KEY", cfg.mistral.key);+ if ((driver === "mistral" || driver === "mistralVibeAgent") && cfg.mistral?.key) environment.set("MISTRAL_API_KEY", cfg.mistral.key);if (driver === "cerebras" && cfg.cerebras?.key) environment.set("CEREBRAS_API_KEY", cfg.cerebras.key);if (driver === "groq" && cfg.groq?.key) environment.set("GROQ_API_KEY", cfg.groq.key);if (driver === "greenference" && cfg.greenference?.key) environment.set("GREENFERENCE_API_KEY", cfg.greenference.key); if (driver === "modelgo" && cfg.modelgo?.key) environment.set("MODELGO_API_KEY", cfg.modelgo.key);if (driver === "meta" && cfg.meta?.key) environment.set("META_API_KEY", cfg.meta.key);if (driver === "deepseekAgent" && cfg.deepseek?.key) environment.set("DEEPSEEK_API_KEY", cfg.deepseek.key);- if (driver === "mistralVibeAgent" && cfg.mistral?.key) environment.set("MISTRAL_API_KEY", cfg.mistral.key);if (driver === "grok" && cfg.xai?.key) environment.set("XAI_API_KEY", cfg.xai.key);if (driver === "claudeAgent") for (const [name, value] of Object.entries(anthropicKeyEnv(cfg.anthropic, instanceId === CLAUDE_API_INSTANCE))) environment.set(name, value);if (driver === "openai-compat" && instanceId === OPENAI_API_INSTANCE) {diff --git a/server/contracts.ts b/server/contracts.tsindex 960390c65b..b422299b7d 100644--- a/server/contracts.ts+++ b/server/contracts.ts@@ -570,7 +570,8 @@ export interface ProviderInstance {/** Optional first-party runtime installation and account setup. */readonly installRuntime?: () => Promise<void>;readonly startAuthentication?: () => Promise<ProviderAuthenticationStart>;- readonly authenticationMethod?: "browser-pkce" | "browser"; readonly getAuthentication?: (flowId: string) => Promise<ProviderAuthenticationStatus>;+ readonly authenticationMethod?: "browser-pkce" | "browser";+ readonly getAuthentication?: (flowId: string) => Promise<ProviderAuthenticationStatus>;readonly completeAuthentication?: (flowId: string, callbackUrl: string) => Promise<void>;readonly cancelAuthentication?: () => Promise<void>;/** Remove the provider CLI's stored sign-in on this server; never touches another instance's home. */diff --git a/server/drivers/acp/browser-auth.ts b/server/drivers/acp/browser-auth.tsindex c5ffe9b7a9..a37acb0320 100644--- a/server/drivers/acp/browser-auth.ts+++ b/server/drivers/acp/browser-auth.ts@@ -1,4 +1,4 @@-//Browser sign-in through the engine's own ACP `authenticate`: the app starts a one-shot session much like a turn's+// Browser sign-in through the engine's own ACP `authenticate`: the app starts a one-shot session much like a turn's// spawn, initializes it, and sends `authenticate`; the engine then opens the person's browser itself and holds that// request until the person finishes there. `start` resolves as soon as the engine holds the sign-in open (the// browser pops behind it); `get` reports the flow until the authenticate response, a readiness probe, expiry or a@@ -163,7 +163,8 @@ export class AcpBrowserAuth {});child.stderr!.on("data", () => {});- const request = (method: string, params: unknown, timeoutMs: number) => new Promise<unknown>((resolve, rejectRequest) => { const id = requestSeq++;+ const request = (method: string, params: unknown, timeoutMs: number) => new Promise<unknown>((resolve, rejectRequest) => {+ const id = requestSeq++;const timer = setTimeout(() => {pending.delete(id);rejectRequest(new Error(`${method} was not answered in time`));diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.tsindex 17d5350258..219ed1a423 100644--- a/server/drivers/acp/core.ts+++ b/server/drivers/acp/core.ts@@ -1544,7 +1544,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>if (err) {const failure = err as NodeJS.ErrnoException & { killed?: boolean };const reason = failure.code === "ENOENT"- ? `${support.displayName} isn't installed where the app runs. Use the install button on this card, point Set CLI at an existing CLI, then check again.`+ ? `\`${config.cli}\` isn't installed, or isn't on this app's PATH. Install it for the user running OpenMausBot or use Set CLI, then check again.`: failure.code === "EACCES" || failure.code === "EPERM"? `\`${config.cli}\` isn't executable. Check its file permissions, then check again.`: failure.killed && failure.code == nulldiff --git a/server/drivers/acp/mistral-vibe.test.ts b/server/drivers/acp/mistral-vibe.test.tsindex 8350fb4203..5670b2b9d8 100644--- a/server/drivers/acp/mistral-vibe.test.ts+++ b/server/drivers/acp/mistral-vibe.test.ts@@ -39,6 +39,7 @@ describe("Mistral (Vibe) ACP driver", () => {enabled: true,environment: {VIBE_HOME: join(scratch, "vibe-home"),+ VIBE_KEYCHAIN_SERVICE: "omb-test-no-such-entry",FAKE_ACP_AUTH_METHOD: "browser-auth",FAKE_ACP_IMAGE_CAPABILITY: "1",FAKE_ACP_AGENT_NAME: "@mistralai/mistral-vibe",@@ -111,7 +112,8 @@ describe("Mistral (Vibe) ACP driver", () => {await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);expect(recorder.events.every((event) => event.provider === "mistralVibeAgent")).toBe(true);- expect(JSON.parse(readFileSync(join(scratch, "rpc.json"), "utf8"))).toContain("authenticate");+ // Signed in through the key: the browser sign-in is not asked for on a turn.+ expect(JSON.parse(readFileSync(join(scratch, "rpc.json"), "utf8"))).not.toContain("authenticate");const launch = JSON.parse(readFileSync(join(scratch, "launch.json"), "utf8"));expect(launch.argv).toEqual([]);expect(launch.env.MISTRAL_API_KEY).toBe("engine-fixture-key");@@ -131,6 +133,8 @@ describe("Mistral (Vibe) ACP driver", () => {expect(await instance.adapter.respondToRequest("mistral-vibe-permission", ask.requestId!, { behavior: "deny" })).toBe("rejected");await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);expect(readFileSync(answer, "utf8")).toBe("reject");+ // Not signed in anywhere: the turn asks for the engine's browser sign-in.+ expect(JSON.parse(readFileSync(join(scratch, "rpc.json"), "utf8"))).toContain("authenticate");});describe("sign-out cleanup of Vibe's fallback .env", () => {diff --git a/server/drivers/acp/mistral-vibe.ts b/server/drivers/acp/mistral-vibe.tsindex 0c75408604..047c33f180 100644--- a/server/drivers/acp/mistral-vibe.ts+++ b/server/drivers/acp/mistral-vibe.ts@@ -20,6 +20,7 @@ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";import { homedir } from "node:os";import { join } from "node:path";+import { productName } from "../../brand.ts";import type { ModelCatalog } from "../../contracts.ts";import { createAcpDriver, type AcpConfig, type AcpSupport } from "./core.ts";import { discoverAcpModels } from "./custom-model-catalog.ts";@@ -119,7 +120,8 @@ export async function removeMistralVibeSignIn(env: Record<string, string | undef}-/** Discovers models in a temporary session, so a refresh leaves no record in the person's Vibe history. */export async function resolveMistralVibeModels(+/** Discovers models in a temporary session, so a refresh leaves no record in the person's Vibe history. */+export async function resolveMistralVibeModels(env: Record<string, string | undefined>,config: Pick<AcpConfig, "cli">,): Promise<ModelCatalog> {@@ -160,12 +162,13 @@ export const mistralVibeSupport: AcpSupport = {product: "Mistral",methodId: (methods) => (methods.some((method) => method.id === "browser-auth") ? "browser-auth" : null),signedIn: (env) => vibeSignedIn(env),- serverHint:- "OpenMausBot cannot reach a browser on this server. Sign in from a machine that runs OpenMausBot, or paste a Mistral API key under Settings → Connections → Model providers.",+ get serverHint() {+ return `${productName()} cannot reach a browser on this server. Sign in from a machine that runs ${productName()}, or paste a Mistral API key under Settings → Connections → Model providers.`;+ },failure(stage, detail) {switch (stage) {case "start": return detail === "ENOENT"- ? "Mistral Vibe isn't installed where OpenMausBot runs. Install it on this card, then try again."+ ? `Mistral Vibe isn't installed where ${productName()} runs. Install it on this card, then try again.`: "Mistral Vibe did not start a sign-in in time. Update the CLI on this card, then try again.";case "initialize": return "Mistral Vibe did not answer its sign-in handshake in time. Update the CLI on this card, then try again.";case "authenticate": return "The Mistral sign-in did not finish. It may have been cancelled in the browser; start it again to retry.";@@ -186,9 +189,9 @@ export const mistralVibeSupport: AcpSupport = {return current ?? null;},- // initialize advertises exactly one method: a browser sign-in the process opens itself,- // which the authenticate request blocks on until the person finishes (see header).- pickAuthMethod: (methods) => (methods.some((method) => method.id === "browser-auth") ? "browser-auth" : null),+ // initialize advertises exactly one method: a browser sign-in the process opens itself, which the authenticate+ // request blocks on until the person finishes (see header). Already signed in, a turn skips it: no browser per turn.+ pickAuthMethod: (methods, env) => (!vibeSignedIn(env) && methods.some((method) => method.id === "browser-auth") ? "browser-auth" : null),authFailure: "continue",isAuthenticated: (env) => vibeSignedIn(env),diff --git a/server/drivers/acp/probe-errors.test.ts b/server/drivers/acp/probe-errors.test.tsindex 0c2cdc6879..a2a2cf9709 100644--- a/server/drivers/acp/probe-errors.test.ts+++ b/server/drivers/acp/probe-errors.test.ts@@ -9,7 +9,7 @@ import { KimiAgentDriver } from "./kimi.ts";afterEach(() => vi.restoreAllMocks());it.each([- [{ code: "ENOENT" }, "isn't installed where the app runs"],+ [{ code: "ENOENT" }, "isn't installed, or isn't on this app's PATH"],[{ code: "EACCES" }, "isn't executable"],[{ killed: true, signal: "SIGTERM" }, "timed out"],[{ code: 1 }, "version check failed"],diff --git a/server/routes/instances.ts b/server/routes/instances.tsindex f1366920c4..0fcc4b360b 100644--- a/server/routes/instances.ts+++ b/server/routes/instances.ts@@ -35,6 +35,7 @@ import { removeAntigravityProfile } from "../drivers/antigravity-acp.ts";import { BUILT_IN_DRIVERS } from "../drivers/builtIn.ts";import { findCliCandidates, resetPathCache } from "../env-path.ts";import type { ProviderRegistry } from "../harness/registry.ts";+import { productName } from "../brand.ts";import { checkEngine, type EngineCheck } from "../engine-check.ts";import { HOSTED_PROVIDER_SETTINGS_ERROR } from "../hosted-models.ts";import type { ProviderAuthSessions } from "../provider-auth-sessions.ts";@@ -360,7 +361,7 @@ export function createInstanceRoutes(deps: InstanceRouteDeps): RouteHandler {if ((instance.authenticationMethod === "browser-pkce" || instance.authenticationMethod === "browser")&& (isProxied(req) || !isLoopbackHost(req.socket.remoteAddress))) {if (instance.authenticationMethod === "browser") {- return json(res, 403, { error: "This sign-in happens in a browser on the computer running OpenMausBot. Open OpenMausBot there to sign in." });+ return json(res, 403, { error: `This sign-in happens in a browser on the computer running ${productName()}. Open ${productName()} there to sign in.` });}return json(res, 403, { error: "Continue with ChatGPT on the computer running OpenMausBot. Hosted Pro sign-in requires OpenAI's hosted-app approval." });}diff --git a/src/components/EngineBrowserSignIn.tsx b/src/components/EngineBrowserSignIn.tsxindex d102a9f219..29b7083d64 100644--- a/src/components/EngineBrowserSignIn.tsx+++ b/src/components/EngineBrowserSignIn.tsx@@ -1,4 +1,4 @@-//A sign-in whose engine opens the person's browser itself (Mistral Vibe's ACP authenticate): the app starts the+// A sign-in whose engine opens the person's browser itself (Mistral Vibe's ACP authenticate): the app starts the// flow, then only polls until the engine reports it done — there is no link or code to show.import { useEffect, useRef, useState } from "react";import { Loader2, LogIn } from "lucide-react";diff --git a/src/components/EngineSetup.tsx b/src/components/EngineSetup.tsxindex a7fbdd1d6a..55e723356d 100644--- a/src/components/EngineSetup.tsx+++ b/src/components/EngineSetup.tsx@@ -612,7 +612,7 @@ export function EngineSetup({}// The app's own copy is out of reach of the person's terminal, so its sign-in is finished here.- if (signInOnly && install.appCopy && !deviceSignIn && !engineBrowserSignIn && !pasteSignIn) {+ if (signInOnly && install.appCopy && !deviceSignIn && !browserSignIn && !engineBrowserSignIn && !pasteSignIn) {return <AppCopySetup instance={instance} className={className} unframed={unframed} />;}diff --git a/src/locales/en.json b/src/locales/en.jsonindex 4ba35a1163..e9c7b8d516 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -6108,7 +6108,7 @@"engineSetup.chatgpt.manageUsage": "Manage usage","engineSetup.chatgpt.welcome": "You’re using your ChatGPT plan","engineSetup.chatgpt.welcomeBody": "Eligible AI requests in {app} use your ChatGPT plan. Manage usage and access in ChatGPT settings. Your ChatGPT plan is separate from MausBot Cloud.",- "engineSetup.engineBrowser.description": "Sign in to {name} in the browser that just opened. OpenMausBot keeps the sign-in open until you finish there.",+ "engineSetup.engineBrowser.description": "Sign in to {name} in the browser that just opened. {app} keeps the sign-in open until you finish there.","engineSetup.engineBrowser.start": "Sign in to Mistral","engineSetup.engineBrowser.starting": "Opening the Mistral sign-in…","engineSetup.engineBrowser.waiting": "Finish the sign-in in the browser that opened…",@@ -6117,7 +6117,8 @@"engineSetup.engineBrowser.failed": "The Mistral sign-in did not finish. Start it again to retry.","engineSetup.engineBrowser.cancelled": "Sign-in cancelled.","engineSetup.engineBrowser.expired": "The Mistral sign-in window expired. Start it again to retry.",- "engineSetup.device.start": "Connect ChatGPT", "engineSetup.device.starting": "Getting your sign-in code…",+ "engineSetup.device.start": "Connect ChatGPT",+ "engineSetup.device.starting": "Getting your sign-in code…","engineSetup.device.enterCode": "Enter this one-time code on OpenAI's sign-in page:","engineSetup.device.copyCode": "Copy sign-in code","engineSetup.device.openChatGPT": "Open ChatGPT sign-in",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex ea1f775a76..2a0968d2ad 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -5786,7 +5786,7 @@"engineSetup.chatgpt.manageUsage": "Gerenciar uso","engineSetup.chatgpt.welcome": "Você está usando seu plano do ChatGPT","engineSetup.chatgpt.welcomeBody": "No app {app}, os pedidos de IA cobertos pelo seu plano do ChatGPT usam esse plano. Gerencie o uso e o acesso nas configurações do ChatGPT. Seu plano do ChatGPT é separado do MausBot Cloud.",- "engineSetup.engineBrowser.description": "Entre no {name} pelo navegador que acabou de abrir. O OpenMausBot mantém o login aberto até você terminar lá.",+ "engineSetup.engineBrowser.description": "Entre no {name} pelo navegador que acabou de abrir. O {app} mantém o login aberto até você terminar lá.","engineSetup.engineBrowser.start": "Entrar no Mistral","engineSetup.engineBrowser.starting": "Abrindo o login do Mistral…","engineSetup.engineBrowser.waiting": "Termine o login no navegador que foi aberto…",