Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Browser settings: say when bots browse without Google Chrome, and how to fix it
Yash Kakade5bb3158cdaf1
diff --git a/server/host/browser.test.ts b/server/host/browser.test.tsindex dec9497d42..9d2b7473dc 100644--- a/server/host/browser.test.ts+++ b/server/host/browser.test.ts@@ -521,6 +521,22 @@ describe("the bots' browser host by default", () => {expect(host.signedInSitesRefusal("work")).toBeNull();expect(host.engineSummary({ kind: "engine", version: "0.37.0", myChrome: true })).toEqual({ kind: "engine", version: "0.37.0", myChrome: true, engine: "agent-browser" });});++ it("says when agent-browser runs its headless shell because Google Chrome is not installed", () => {+ const shell = vi.spyOn(chromeLauncher, "runsShellForWantOfChrome").mockReturnValue(true);+ try {+ const { cfg, host } = setup(undefined);+ expect(host.engineSummary({ kind: "engine", version: "0.37.0", myChrome: true })).toMatchObject({ kind: "engine", engine: "agent-browser", noChrome: true });+ expect(host.engineSummary({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true }).noChrome, "nothing runs yet").toBeUndefined();+ cfg.browserEngine = { engine: "chrome" };+ expect(host.engineSummary({ kind: "engine", version: "0.37.0", myChrome: true }).noChrome, "the new browser needs Chrome and never runs the shell").toBeUndefined();+ shell.mockReturnValue(false);+ cfg.browserEngine = { engine: "agent-browser" };+ expect(host.engineSummary({ kind: "engine", version: "0.37.0", myChrome: true }).noChrome).toBeUndefined();+ } finally {+ shell.mockRestore();+ }+ });});describe("a deleted bot's browser", () => {diff --git a/server/host/browser.ts b/server/host/browser.tsindex 1e96071be8..b43fd1e1ae 100644--- a/server/host/browser.ts+++ b/server/host/browser.ts@@ -628,7 +628,7 @@ export function createBrowserHost(deps: BrowserHostDeps) {return { binaryPath: engine.binaryPath, session, env: browserSessionSpec(engine.binaryPath, session, profile, await browserEgress.open(session)).env, encryptionKey: browserEngineEncryptionKey() };}/** What Settings shows of the engine that runs bots' browsers here; My Chrome stays on agent-browser. */- function engineSummary<T extends { myChrome: boolean }>(agentBrowser: T): (T | (ReturnType<ChromeEngine["summary"]> & { myChrome: boolean })) & { engine: BrowserEngineKind; serverSites?: boolean; proxyConfigured?: boolean; proxySaved?: boolean } {+ function engineSummary<T extends { kind: "engine" | "unavailable"; myChrome: boolean }>(agentBrowser: T): (T | (ReturnType<ChromeEngine["summary"]> & { myChrome: boolean })) & { engine: BrowserEngineKind; noChrome?: true; serverSites?: boolean; proxyConfigured?: boolean; proxySaved?: boolean } {const serverSites = sitesSwitch ? { serverSites: cfg.browserEngine?.egress?.localNetwork === true } : {};const engine = browserEngineKind(cfg);const proxyValue = cfg.browserEngine?.egress?.proxy;@@ -636,6 +636,7 @@ export function createBrowserHost(deps: BrowserHostDeps) {const proxyConfigured = builtInBrowserEnabled(cfg) && !hostedServer && parseSocks5Proxy(proxyValue) !== null;return {...(engine === "chrome" ? { ...chromeEngine.summary(), myChrome: agentBrowser.myChrome, ...lentChromeSummary(), engine } : { ...agentBrowser, engine }),+ ...(engine !== "chrome" && agentBrowser.kind === "engine" && chromeLauncher.runsShellForWantOfChrome() ? { noChrome: true as const } : {}),...serverSites,...(proxyConfigured ? { proxyConfigured: true } : {}),...(proxySaved ? { proxySaved: true } : {}),diff --git a/server/index.ts b/server/index.tsindex df7cd87924..df751594ac 100644--- a/server/index.ts+++ b/server/index.ts@@ -2403,7 +2403,7 @@ const emailIntegration = (bot: BotRecord, turn: { threadId: string; generation:let browserEngineInstall: Promise<void> | null = null;let browserEngineInstallError: string | null = null;-export function browserEngineSummary(): { kind: "engine" | "unavailable"; reason?: string; installable?: boolean; version?: string; chrome?: string; installing?: boolean; installError?: string; myChrome: boolean; proxyConfigured?: boolean; proxySaved?: boolean; myChromeOn?: { name: string; device: "PC" | "Mac" | "computer"; online: boolean }; myChromeLendable?: true; serverSites?: boolean; engine: "agent-browser" | "chrome" } {+export function browserEngineSummary(): { kind: "engine" | "unavailable"; reason?: string; installable?: boolean; version?: string; chrome?: string; noChrome?: true; installing?: boolean; installError?: string; myChrome: boolean; proxyConfigured?: boolean; proxySaved?: boolean; myChromeOn?: { name: string; device: "PC" | "Mac" | "computer"; online: boolean }; myChromeLendable?: true; serverSites?: boolean; engine: "agent-browser" | "chrome" } {const status = browserEngineStatus();const progress = { myChrome: myChromeAvailable(), ...lentChromeSummary(), ...(browserEngineInstall ? { installing: true } : {}), ...(browserEngineInstallError ? { installError: browserEngineInstallError } : {}) };return engineSummary(status.kind === "ready"diff --git a/src/components/BrowserSettingsRows.test.ts b/src/components/BrowserSettingsRows.test.tsindex 331d603e71..d0d5a31ee0 100644--- a/src/components/BrowserSettingsRows.test.ts+++ b/src/components/BrowserSettingsRows.test.ts@@ -5,7 +5,7 @@ import { createRoot, type Root } from "react-dom/client";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { setLocale } from "@/lib/i18n";-import { BrowserProxyRow, NewBrowserSettings, ServerSitesRow } from "./BrowserSettingsRows";+import { BrowserProxyRow, BuiltInBrowserRow, NewBrowserSettings, ServerSitesRow } from "./BrowserSettingsRows";const fixture = vi.hoisted(() => ({config: undefined as Record<string, unknown> | undefined,@@ -152,3 +152,33 @@ describe("Built-in browser proxy setting", () => {expect(host.querySelector('input[aria-label="SOCKS5 proxy"]')).not.toBeNull();});});++describe("Built-in browser without Google Chrome", () => {+ const show = () => flushSync(() => root.render(createElement(BuiltInBrowserRow)));+ const row = () => host.textContent ?? "";++ it("says the bots use a basic browser, and how to fix it, while Google Chrome is not installed", () => {+ fixture.config = { features: { browser: true }, browserEngine: { kind: "engine", noChrome: true, myChrome: true } };+ show();+ expect(row()).toContain("Ready. Bots use a basic browser because Google Chrome isn't installed.");+ expect(row()).toContain("Many sites block it. Install Google Chrome and restart MausBot.");+ expect(row()).toContain("If a site still blocks bots, give the bot a My Chrome profile in Browser profiles.");+ });++ it("leaves out My Chrome where there is none to use", () => {+ fixture.config = { features: { browser: true }, browserEngine: { kind: "engine", noChrome: true, myChrome: false } };+ show();+ expect(row()).toContain("Install Google Chrome and restart MausBot.");+ expect(row()).not.toContain("My Chrome");+ });++ it("says only Ready when the bots' browser is Chrome, and nothing of Chrome while the browser is off", () => {+ fixture.config = { features: { browser: true }, browserEngine: { kind: "engine", myChrome: true } };+ show();+ expect(row()).toContain("Ready");+ expect(row()).not.toContain("Google Chrome");+ fixture.config = { features: { browser: false }, browserEngine: { kind: "engine", noChrome: true, myChrome: true } };+ show();+ expect(row()).not.toContain("Google Chrome");+ });+});diff --git a/src/components/BrowserSettingsRows.tsx b/src/components/BrowserSettingsRows.tsxindex 6bf4ae26ae..3ad23c872a 100644--- a/src/components/BrowserSettingsRows.tsx+++ b/src/components/BrowserSettingsRows.tsx@@ -1,5 +1,6 @@import { useState } from "react";+import { productName } from "@/lib/brand";import { browserAvailable, browserUnavailableReason, builtInBrowserEnabled } from "@/lib/feature-flags";import { t } from "@/lib/i18n";import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";@@ -36,6 +37,8 @@ export function BuiltInBrowserRow() {const desktopBrowser = browserAvailable(state.config);const browserInstallable = state.config?.browserEngine?.installable === true;const browserBlockedOnWindows = window.ogb?.platform === "win32" && !desktopBrowser && !browserInstallable;+ const withoutChrome = desktopBrowser && browser && state.config?.browserEngine?.noChrome === true;+ const myChrome = state.config?.browserEngine?.myChrome === true;const { saving, error, save } = useConfigSave();return (@@ -44,13 +47,16 @@ export function BuiltInBrowserRow() {// While it's on, the line says how it stands (Ready, or that it installs on first use), not what the switch does.subtitle={desktopBrowser? browser- ? t("settings.ai.ready")+ ? withoutChrome ? t("settings.browser.noChrome") : t("settings.ai.ready"): t("settings.browser.offShort"): browserBlockedOnWindows? t("settings.experimental.browserWindows"): browserInstallable ? (browser ? t("settings.browser.installsFirst") : t("settings.browser.notInstalledShort")): browserUnavailableReason(state.config)}- message={error ? <p role="alert" className="text-danger">{error}</p> : null}+ message={withoutChrome || error ? <>+ {withoutChrome && <p>{t("settings.browser.noChromeFix", { app: productName() })}{myChrome && ` ${t("settings.browser.noChromeMyChrome")}`}</p>}+ {error && <p role="alert" className="text-danger">{error}</p>}+ </> : null}><Switchchecked={browser}diff --git a/src/locales/en.json b/src/locales/en.jsonindex cff141a5e7..3c7d98ae63 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -11007,6 +11007,9 @@"phone.pair.needsSignInLine": "Needs a free {app} sign-in.","settings.browser.rowTitle": "Built-in browser","settings.browser.installsFirst": "Installs the first time a bot opens a website.",+ "settings.browser.noChrome": "Ready. Bots use a basic browser because Google Chrome isn't installed.",+ "settings.browser.noChromeFix": "Many sites block it. Install Google Chrome and restart {app}.",+ "settings.browser.noChromeMyChrome": "If a site still blocks bots, give the bot a My Chrome profile in Browser profiles.","settings.browser.localSitesPlain": "Lets bots open sites on this computer and your home network.","settings.profiles.noneYet": "No shared profiles yet.","settings.profiles.addTitle": "Add a browser profile",diff --git a/src/state/config-status.ts b/src/state/config-status.tsindex 745e130157..2c28af130e 100644--- a/src/state/config-status.ts+++ b/src/state/config-status.ts@@ -206,6 +206,8 @@ export interface BrowserEngineSummary {/** The browser the engine starts, e.g. "Google Chrome 153 (installed)", or while Chrome for Testing downloads,* "Chrome for Testing 153.0.8010.47 (downloading: 52 of 182 MB)". */chrome?: string;+ /** agent-browser runs Chromium's headless shell, which many sites refuse, only because no Google Chrome is installed here. */+ noChrome?: true;installing?: boolean;installError?: string;/** Whether a browser profile can use "My Chrome", the person's own running