Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Address follow-up browser review comments

jd23d798dfad69
diff --git a/server/browser/chrome/launcher.test.ts b/server/browser/chrome/launcher.test.ts
index 1e6896abf0..0494a96a3c 100644
--- a/server/browser/chrome/launcher.test.ts
+++ b/server/browser/chrome/launcher.test.ts
@@ -216,14 +216,16 @@ describe("the Chrome launcher", () => {
});
it("gives a started browser its identity, with the person's languages as a list, only when it is this launcher's headless Chrome", async () => {
- const machine = mac({ env: { LANG: "pt_BR.UTF-8" } });
+ const machine = mac({ env: { LANG: "en_US.UTF-8" } });
const attached = sidecars();
const chrome = launcher(machine, { sidecars: attached });
+ chrome.setLanguageProvider(() => "ko");
await chrome.started("bot-1", headless(chrome.path));
expect(attached.ensure).not.toHaveBeenCalled();
await chrome.ready(headless(chrome.path));
+ expect(readFileSync(chrome.path, "utf8")).toContain("'--lang=ko-KR'");
await chrome.started("bot-1", headless(chrome.path));
- expect(attached.ensure).toHaveBeenCalledExactlyOnceWith("bot-1", headless(chrome.path), { ...identity("155"), acceptLanguage: "pt-BR,pt,en-US,en" });
+ expect(attached.ensure).toHaveBeenCalledExactlyOnceWith("bot-1", headless(chrome.path), { ...identity("155"), acceptLanguage: "ko-KR,ko,en-US,en" });
await chrome.started("bot-2", { command: "/engine/agent-browser", env: { AGENT_BROWSER_EXECUTABLE_PATH: chrome.path } });
await chrome.started("bot-3", { command: "/engine/agent-browser", env: { ...headless(chrome.path).env, AGENT_BROWSER_AUTO_CONNECT: "1" } });
await chrome.started("bot-4", headless("/bundle/chrome-headless-shell"));
diff --git a/server/browser/chrome/launcher.ts b/server/browser/chrome/launcher.ts
index 554eb0dbdb..0caecdcfa7 100644
--- a/server/browser/chrome/launcher.ts
+++ b/server/browser/chrome/launcher.ts
@@ -81,12 +81,14 @@ export class ChromeLauncher implements BrowserLaunch {
private readonly options: Required<Pick<ChromeLauncherOptions, "dataDir" | "env" | "platform" | "readyWaitMs">> & ChromeLauncherOptions;
private readonly host: ChromeHost;
private readonly sidecars: IdentitySidecars;
+ private language: (() => string | undefined) | undefined;
private box: (() => LauncherBox | null) | null = null;
constructor(options: ChromeLauncherOptions) {
const env = options.env ?? process.env;
const platform = options.platform ?? process.platform;
this.options = { ...options, env, platform, readyWaitMs: options.readyWaitMs ?? 45_000 };
+ this.language = options.language;
this.host = options.host ?? chromeHost({ dataDir: options.dataDir, env, platform, arch: options.arch });
this.sidecars = options.sidecars ?? new IdentitySidecars();
this.path = launcherPath(options.dataDir, platform);
@@ -111,11 +113,22 @@ export class ChromeLauncher implements BrowserLaunch {
return resolveChromePlan(this.host, this.options.engine ? this.options.engine() : this.managedEngine());
}
+ /** Keep the shared agent-browser launcher and sidecar in the application's current language. */
+ setLanguageProvider(language: (() => string | undefined) | undefined): void {
+ this.language = language ?? this.options.language;
+ this.followLanguage();
+ }
+
+ private resolvedLanguage(): string | undefined {
+ return browserLanguage(this.options.env, this.language?.());
+ }
+
/** What agent-browser's environment gains: nothing while the engine keeps its own browser. */
env(): Record<string, string> {
if (this.state.kind === "failed" || this.plan().kind === "legacy") return {};
void this.prepare();
this.followTimeZone();
+ this.followLanguage();
return { AGENT_BROWSER_EXECUTABLE_PATH: this.path, AGENT_BROWSER_HIDE_SCROLLBARS: "0" };
}
@@ -136,6 +149,21 @@ export class ChromeLauncher implements BrowserLaunch {
}
}
+ private followLanguage(): void {
+ const state = this.state;
+ if (state.kind !== "ready" || !state.launcher) return;
+ const language = this.resolvedLanguage();
+ if (language === state.launcher.language) return;
+ const launcher = { ...state.launcher, language };
+ try {
+ writeLauncher(this.path, launcher, this.options.platform);
+ this.state = { ...state, launcher };
+ this.log(`browser: the next browser started uses ${language ?? "the system's language"}`);
+ } catch (error) {
+ this.log(`browser: could not change the browser language to ${language ?? "the system's language"} (${message(error)})`);
+ }
+ }
+
start(): void {
if (this.plan().kind !== "legacy") void this.prepare();
}
@@ -177,7 +205,7 @@ export class ChromeLauncher implements BrowserLaunch {
async started(session: string, spec: LaunchSpec): Promise<void> {
if (this.state.kind !== "ready" || !this.uses(spec) || !ownsBrowserViewport(spec.env ?? {})) return;
- await this.sidecars.ensure(session, spec, { ...this.state.identity, acceptLanguage: languageList(browserLanguage(this.options.env, this.options.language?.())) });
+ await this.sidecars.ensure(session, spec, { ...this.state.identity, acceptLanguage: languageList(this.resolvedLanguage()) });
}
stopped(session: string): void {
@@ -231,7 +259,7 @@ export class ChromeLauncher implements BrowserLaunch {
this.screen ??= this.options.screen ? this.options.screen() : primaryScreen(platform, env);
launcher = {
chrome: chrome.path, userAgent: identity.userAgent, screen: await this.screen,
- language: browserLanguage(env, this.options.language?.()), timeZone: browserTimeZone(env, platform),
+ language: this.resolvedLanguage(), timeZone: browserTimeZone(env, platform),
...(platform === "darwin" ? { home: userInfo().homedir } : {}),
...this.boxed(),
};
diff --git a/server/browser/chrome/wrapper.test.ts b/server/browser/chrome/wrapper.test.ts
index 053030cee9..cdcc524bdb 100644
--- a/server/browser/chrome/wrapper.test.ts
+++ b/server/browser/chrome/wrapper.test.ts
@@ -138,6 +138,7 @@ describe("the display, language and time zone the launcher gives Chrome", () =>
expect(browserLanguage({ LANG: "POSIX" })).toBe("en-US");
expect(browserLanguage({})).toBeUndefined();
expect(browserLanguage({ OMB_BROWSER_LANG: "en US; rm" })).toBeUndefined();
+ expect(browserLanguage({ OMB_BROWSER_LANG: "en US; rm" }, "ko")).toBe("ko-KR");
});
it("gives Chrome the server's time zone, where Chrome reads TZ", () => {
diff --git a/server/browser/chrome/wrapper.ts b/server/browser/chrome/wrapper.ts
index 9c3405c3d2..c0e3b97d09 100644
--- a/server/browser/chrome/wrapper.ts
+++ b/server/browser/chrome/wrapper.ts
@@ -136,7 +136,7 @@ export async function primaryScreen(platform: NodeJS.Platform, env: NodeJS.Proce
/** Explicit OMB_BROWSER_LANG, app language, then the POSIX locale; "C" and "POSIX" name no language. */
export function browserLanguage(env: NodeJS.ProcessEnv, configured?: string): string | undefined {
const named = env.OMB_BROWSER_LANG?.trim();
- if (named) return /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(named) ? named : undefined;
+ if (named && /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(named)) return named;
const app = configured?.trim();
if (app && /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(app)) {
try {
diff --git a/server/host/browser.test.ts b/server/host/browser.test.ts
index a838bc131b..ea2d896d9a 100644
--- a/server/host/browser.test.ts
+++ b/server/host/browser.test.ts
@@ -151,11 +151,25 @@ describe("the bots' browser host with browserEngine.engine set to chrome", () =>
expect(host.signedInSitesRefusal("work")).toContain("does not list signed-in sites yet");
});
- it("says in the status which engine runs the bots' browsers", () => {
+ it("reports saved and active proxy status for both built-in browser engines", () => {
const { cfg, host } = setup("chrome");
- expect(host.engineSummary({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true })).toMatchObject({ engine: "chrome", myChrome: true });
- cfg.browserEngine = { engine: "agent-browser" };
- expect(host.engineSummary({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true })).toEqual({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true, engine: "agent-browser" });
+ cfg.browserEngine = { engine: "chrome", egress: { proxy: "socks5://127.0.0.1:1080" } };
+ expect(host.engineSummary({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true })).toMatchObject({
+ engine: "chrome", myChrome: true, proxySaved: true, proxyConfigured: true,
+ });
+ cfg.browserEngine = { engine: "agent-browser", egress: { proxy: "socks5://127.0.0.1:1080" } };
+ expect(host.engineSummary({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true })).toMatchObject({
+ kind: "unavailable", engine: "agent-browser", proxySaved: true, proxyConfigured: true,
+ });
+ cfg.browserEngine = { engine: "chrome", egress: { proxy: "invalid" } };
+ expect(host.engineSummary({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true })).toMatchObject({
+ engine: "chrome", proxySaved: true,
+ });
+ expect(host.engineSummary({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true }).proxyConfigured).toBeUndefined();
+ cfg.features!.browser = false;
+ cfg.browserEngine = { engine: "chrome", egress: { proxy: "socks5://127.0.0.1:1080" } };
+ expect(host.engineSummary({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true })).toMatchObject({ proxySaved: true });
+ expect(host.engineSummary({ kind: "unavailable", reason: "agent-browser is not installed", myChrome: true }).proxyConfigured).toBeUndefined();
});
it("offers the owner's local-sites switch on a self-hosted server, but never on a shared company workspace", () => {
diff --git a/server/host/browser.ts b/server/host/browser.ts
index 55b3c2211a..202c1f89d2 100644
--- a/server/host/browser.ts
+++ b/server/host/browser.ts
@@ -101,6 +101,7 @@ const BOT_SESSION = /^bot-[A-Za-z0-9_.-]+$/;
export function createBrowserHost(deps: BrowserHostDeps) {
const { cfg, turnResources, activeInternalGenerationByThread, mintInternalCapability, DESKTOP_MANAGED, CLOUD_HOME, PORT } = deps;
+ chromeLauncher.setLanguageProvider(deps.language);
const store: Pick<Store, "bots" | "bot" | "botByThread"> = { get bots() { return deps.store().bots; }, bot: (id: string) => deps.store().bot(id),
botByThread: (threadId: string) => deps.store().botByThread(threadId) };
@@ -320,7 +321,7 @@ export function createBrowserHost(deps: BrowserHostDeps) {
return agentBrowserIntegration({
binaryPath, session, encryptionKey: browserEngineEncryptionKey(), persistent: profile !== "guest", egressPort,
env: { ...process.env, PATH: augmentedPath(), ...(locale ? { OMB_BROWSER_LANG: locale } : {}) },
- launcher: { ...chromeLauncher.env(), ...(locale ? { language: locale } : {}) },
+ launcher: chromeLauncher.env(),
...(usesMyChrome(profile) ? { attach: attachCdpUrl ? { cdpUrl: attachCdpUrl } : {} } : {}),
});
}
@@ -550,7 +551,7 @@ export function createBrowserHost(deps: BrowserHostDeps) {
const engine = browserEngineKind(cfg);
const proxyValue = cfg.browserEngine?.egress?.proxy;
const proxySaved = typeof proxyValue === "string" && proxyValue.trim().length > 0;
- const proxyConfigured = engine === "chrome" && !hostedServer && parseSocks5Proxy(proxyValue) !== null;
+ const proxyConfigured = builtInBrowserEnabled(cfg) && !hostedServer && parseSocks5Proxy(proxyValue) !== null;
return {
...(engine === "chrome" ? { ...chromeEngine.summary(), myChrome: agentBrowser.myChrome, ...lentChromeSummary(), engine } : { ...agentBrowser, engine }),
...serverSites,
diff --git a/src/components/BrowserSettingsRows.test.ts b/src/components/BrowserSettingsRows.test.ts
index 87b0528796..73e624ba5b 100644
--- a/src/components/BrowserSettingsRows.test.ts
+++ b/src/components/BrowserSettingsRows.test.ts
@@ -121,6 +121,10 @@ describe("Built-in browser proxy setting", () => {
show();
expect(host.querySelector('input[aria-label="SOCKS5 proxy"]')).toBeNull();
owner.value = true;
+ fixture.config = { features: { browser: false }, browserEngine: { kind: "engine", proxySaved: true, proxyConfigured: false } };
+ show();
+ expect(host.querySelector('input[aria-label="SOCKS5 proxy"]')).not.toBeNull();
+ expect([...host.querySelectorAll("button")].some((button) => button.textContent === "Remove")).toBe(true);
fixture.api.mockResolvedValue({ features: { browser: true }, browserEngine: { kind: "engine", proxyConfigured: true } });
show();
const input = host.querySelector<HTMLInputElement>('input[aria-label="SOCKS5 proxy"]')!;
diff --git a/src/components/BrowserSettingsRows.tsx b/src/components/BrowserSettingsRows.tsx
index 3cfcfa635d..5e66e1dd0a 100644
--- a/src/components/BrowserSettingsRows.tsx
+++ b/src/components/BrowserSettingsRows.tsx
@@ -95,7 +95,7 @@ export function BrowserProxyRow() {
const saved = state.config?.browserEngine?.proxySaved === true || configured;
const [endpoint, setEndpoint] = useState("");
const { saving, error, save } = useConfigSave();
- if (owner !== true || !builtInBrowserEnabled(state.config)) return null;
+ if (owner !== true || (!builtInBrowserEnabled(state.config) && !saved)) return null;
return (
<SettingRow
diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsx
index 45a3c71a18..21ad68259c 100644
--- a/src/components/SettingsModal.tsx
+++ b/src/components/SettingsModal.tsx
@@ -98,7 +98,7 @@ export const SECTIONS: Array<{
{ id: "imageGeneration", group: "ai", labelKey: "settings.section.imageGeneration", icon: ImagePlus, keywords: ["image", "images", "picture", "generate", "avatar", "gpt image", "grok imagine", "gemini", "nano banana", "openrouter", "flux", "backup"] },
{ id: "skills", group: "ai", labelKey: "settings.section.skills", icon: BookOpen, keywords: ["skills", "library", "assign", "agent skills", "skill md"] },
{ id: "desktopWorkspaces", group: "computers", labelKey: "settings.section.desktopWorkspaces", icon: Building2, keywords: ["workspace", "cloud", "hosted", "vps", "server", "servers", "connect", "pair", "switch", "local"] },
- { id: "computer", group: "computers", labelKey: "settings.section.computer", icon: Monitor, keywords: ["vm", "virtual", "desktop", "browser", "built-in browser", "profiles", "browser profiles"] },
+ { id: "computer", group: "computers", labelKey: "settings.section.computer", icon: Monitor, keywords: ["vm", "virtual", "desktop", "browser", "built-in browser", "profiles", "browser profiles", "proxy", "socks5"] },
{ id: "logins", group: "computers", labelKey: "settings.section.vault", icon: LockKeyhole, keywords: ["vault", "logins", "login", "passwords", "password", "sign in", "2fa", "one-time code", "totp", "fill_login", "1password", "password manager", "secrets", "secret", "token", ".env", "env"] },
{ id: "cloudAccount", group: "account", labelKey: "settings.section.cloudAccount", icon: Cloud, keywords: ["cloud", "my cloud", "account", "personal", "sign in", "pro", "subscription", "billing", "sync", "send", "this computer", "bots", "logins", "1password"] },
{ id: "organization", group: "account", labelKey: "settings.section.organization", icon: Building2, keywords: ["company", "organization", "organisation", "sign in", "enroll", "managed", "models", "disconnect"] },