Skip to content

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

fix(browser): Linux servers download Chrome for Testing when no Chrome is installed

AdityaUmale7bfee2fa57cc
diff --git a/apps/docs/content/docs/self-hosting/deploy-vps.mdx b/apps/docs/content/docs/self-hosting/deploy-vps.mdx
index d589aca5e5..8db7ecc40e 100644
--- a/apps/docs/content/docs/self-hosting/deploy-vps.mdx
+++ b/apps/docs/content/docs/self-hosting/deploy-vps.mdx
@@ -168,7 +168,10 @@ npx --yes openmausbot browser install
```
The administrator's browser download is in a different home; it does not install
-the service account's browser. Both commands must finish successfully.
+the service account's browser. Both commands must finish successfully. If the
+service account has no browser, `serve` downloads Chrome for Testing (about
+190 MB) into its data directory when it starts; the system
+libraries from the first command are still needed.
On Ubuntu 24.04, AppArmor may also require [administrator sandbox setup](#ubuntu-2404-browser-sandbox).
The one-click installer downloads the browser; it does not grant these OS permissions.
diff --git a/docs/browser-packaging.md b/docs/browser-packaging.md
index 06ef3669a0..01bd95e073 100644
--- a/docs/browser-packaging.md
+++ b/docs/browser-packaging.md
@@ -39,8 +39,9 @@ real Chrome whenever this machine has one, chosen once per machine
2. Otherwise **Chrome for Testing** 153.0.8010.47, downloaded once into
`tools/chrome/` in the data directory at first launch, checked against its
pinned size and SHA-256 before it is unpacked, and moved into place in one
- rename. Only platforms with a pin download (Apple silicon Macs today;
- `scripts/pin-chrome-for-testing.ts` measures more). A browser call made
+ rename. Only platforms with a pin download (Apple silicon Macs and Linux
+ servers on x64 or arm64 today; `scripts/pin-chrome-for-testing.ts` measures
+ more). A browser call made
during the download waits up to 45 seconds, then says how far it got.
3. A Linux desktop without Google Chrome, and a platform without a pin, keep
the bundled headless shell. That stays the machine's choice; it never
@@ -48,7 +49,8 @@ real Chrome whenever this machine has one, chosen once per machine
Servers and the Docker image name their browser with
`AGENT_BROWSER_EXECUTABLE_PATH` (the image's Chrome for Testing), or use the
-Chrome for Testing `agent-browser install` put in place. `OMB_CHROME_PATH`
+Chrome for Testing `agent-browser install` put in place; with neither, a
+server downloads its own as in step 2. `OMB_CHROME_PATH`
names one explicitly. An `OMB_AGENT_BROWSER_PATH` engine keeps its own choice
unless a Chrome is named too.
diff --git a/server/browser/chrome/install.test.ts b/server/browser/chrome/install.test.ts
index bb58e2425b..e10cffeb51 100644
--- a/server/browser/chrome/install.test.ts
+++ b/server/browser/chrome/install.test.ts
@@ -143,6 +143,8 @@ describe("downloading Chrome for Testing", () => {
it("downloads from Google's Chrome for Testing bucket, by pinned version and platform", () => {
expect(chromeForTestingUrl(pin())).toBe("https://storage.googleapis.com/chrome-for-testing-public/153.0.8010.47/mac-arm64/chrome-mac-arm64.zip");
expect(chromeForTestingPin("darwin", "arm64")).toMatchObject({ platform: "mac-arm64", bytes: 190878359 });
- expect(chromeForTestingPin("linux", "x64")).toBeNull();
+ expect(chromeForTestingPin("linux", "x64")).toMatchObject({ platform: "linux64", bytes: 195709628 });
+ expect(chromeForTestingPin("linux", "arm64")).toMatchObject({ platform: "linux-arm64", bytes: 195919275 });
+ expect(chromeForTestingPin("win32", "x64")).toBeNull();
});
});
diff --git a/server/browser/chrome/install.ts b/server/browser/chrome/install.ts
index 6467515135..8458b1282e 100644
--- a/server/browser/chrome/install.ts
+++ b/server/browser/chrome/install.ts
@@ -21,6 +21,8 @@ export interface ChromeForTestingPin {
/** A platform without a SHA-256 here downloads nothing; scripts/pin-chrome-for-testing.ts measures new pins. */
const PINS: Record<string, Omit<ChromeForTestingPin, "version">> = {
"darwin-arm64": { platform: "mac-arm64", bytes: 190878359, sha256: "939ef9dc3aa74240c929d793e123edab0fda89c5a9cfeb029686c34141d2ed58" },
+ "linux-x64": { platform: "linux64", bytes: 195709628, sha256: "89778cbf7a852726b6f51649b2586b894c00737e81f8031733721560d21bbea7" },
+ "linux-arm64": { platform: "linux-arm64", bytes: 195919275, sha256: "ef3d2fea85e675ba8e9a7894c0be4595e5130659a9ac95e04c6064ed09f411da" },
};
const EXECUTABLES: Record<string, string> = {
diff --git a/server/browser/chrome/resolve.test.ts b/server/browser/chrome/resolve.test.ts
index 42194631f2..f1cf9f64eb 100644
--- a/server/browser/chrome/resolve.test.ts
+++ b/server/browser/chrome/resolve.test.ts
@@ -69,7 +69,7 @@ describe("which Chrome the bots' browser runs", () => {
it("on a Linux desktop without its own Google Chrome keeps the bundled shell, as a fixed choice", () => {
const linuxDesktop = (files: string[]) => host("linux", files, { env: { OMB_RESOURCES_PATH: "/opt/OpenMausBot/resources" } });
- expect(resolveChromePlan(linuxDesktop(["/opt/google/chrome/chrome"]), managed)).toMatchObject({ kind: "chrome", chrome: { source: "installed" } });
+ expect(resolveChromePlan(linuxDesktop(["/opt/google/chrome/chrome"]), managed)).toMatchObject({ kind: "chrome", chrome: { source: "installed" }, fallback: null });
expect(resolveChromePlan(linuxDesktop([]), managed)).toEqual({ kind: "legacy", reason: "Google Chrome is not installed" });
const policy = linuxDesktop(["/opt/google/chrome/chrome", "/etc/opt/chrome/policies/managed/corp.json"]);
expect(chromePolicyManaged(policy)).toBe(true);
@@ -80,7 +80,16 @@ describe("which Chrome the bots' browser runs", () => {
it("on a server uses the Chrome for Testing agent-browser installed, newest first", () => {
const server = host("linux", ["/home/ada/.agent-browser/browsers/chrome-152.0.1.2/chrome", "/home/ada/.agent-browser/browsers/chrome-153.0.8010.47/chrome"]);
expect(resolveChromePlan(server, managed)).toEqual({ kind: "chrome", chrome: { path: "/home/ada/.agent-browser/browsers/chrome-153.0.8010.47/chrome", source: "agent-browser" }, fallback: null });
- expect(resolveChromePlan(host("linux", []), managed)).toEqual({ kind: "legacy", reason: "no Chrome is installed and none is pinned for this platform" });
+ });
+
+ it("on a Linux server without any Chrome downloads Chrome for Testing, as on a Mac", () => {
+ expect(resolveChromePlan(host("linux", []), managed)).toEqual({ kind: "download", pin: chromeForTestingPin("linux", "arm64") });
+ expect(resolveChromePlan({ ...host("linux", []), arch: "x64" }, managed)).toEqual({ kind: "download", pin: chromeForTestingPin("linux", "x64") });
+ const downloaded = chromeForTestingExecutable("/data", chromeForTestingPin("linux", "arm64")!);
+ expect(downloaded).toBe("/data/tools/chrome/153.0.8010.47/linux-arm64/chrome-linux-arm64/chrome");
+ expect(resolveChromePlan(host("linux", [downloaded]), managed)).toEqual({ kind: "chrome", chrome: { path: downloaded, source: "downloaded" }, fallback: null });
+ expect(resolveChromePlan(host("linux", ["/opt/google/chrome/chrome"]), managed)).toEqual({ kind: "chrome", chrome: { path: "/opt/google/chrome/chrome", source: "installed" }, fallback: chromeForTestingPin("linux", "arm64") });
+ expect(resolveChromePlan({ ...host("linux", []), arch: "ia32" }, managed)).toEqual({ kind: "legacy", reason: "no Chrome is installed and none is pinned for this platform" });
});
it("wraps a Chrome named by the environment, as the Docker image names its Chrome for Testing", () => {
diff --git a/server/browser/chrome/resolve.ts b/server/browser/chrome/resolve.ts
index e7226fae49..5e11288b96 100644
--- a/server/browser/chrome/resolve.ts
+++ b/server/browser/chrome/resolve.ts
@@ -110,7 +110,8 @@ export function resolveChromePlan(host: ChromeHost, engine: ChromeEngine | null)
return { kind: "chrome", chrome: { path: paths(platform).isAbsolute(named) ? named : resolve(named), source: "named" }, fallback: null };
}
if (!engine?.managed) return { kind: "legacy", reason: "agent-browser was named, so it picks its own browser" };
- const pin = platform === "darwin" || platform === "win32" ? chromeForTestingPin(platform, host.arch) : null;
+ // The Linux desktop app keeps its bundled browser; a Linux server downloads Chrome for Testing like a Mac.
+ const pin = platform === "linux" && env.OMB_RESOURCES_PATH ? null : chromeForTestingPin(platform, host.arch);
const installed = installedGoogleChrome(host);
if (installed && !chromePolicyManaged(host)) return { kind: "chrome", chrome: { path: installed, source: "installed" }, fallback: pin };
if (platform === "linux" && env.OMB_RESOURCES_PATH) return { kind: "legacy", reason: installed ? "Google Chrome here is managed by an organization" : "Google Chrome is not installed" };