Skip to content

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

Fix: resolve Android to the statically linked agent-browser build (#4868)

Juexibobi1cd63cf54b13
diff --git a/server/browser-engine-release.ts b/server/browser-engine-release.ts
index 13bcbcc9a8..c99e4690ff 100644
--- a/server/browser-engine-release.ts
+++ b/server/browser-engine-release.ts
@@ -60,12 +60,28 @@ export function agentBrowserReleaseVersion(asset: AgentBrowserReleaseAsset | nul
return asset?.version ?? AGENT_BROWSER_VERSION;
}
+/**
+ * The Linux-family key for this platform, or null when Vercel publishes nothing usable.
+ *
+ * Android is not musl: Termux runs the platform's bionic loader, so neither
+ * `linux-<arch>` (glibc) nor `linux-musl-<arch>` describes it. What actually works
+ * there is the statically linked musl build, which carries its own libc and needs no
+ * interpreter at all. Keying Android to `linux-musl-<arch>` therefore picks the one
+ * asset that runs, instead of reporting a build that does exist as missing.
+ */
+function linuxFamilyKey(platform: NodeJS.Platform, arch: string, musl: boolean): string {
+ if (platform === "android") return `linux-musl-${arch}`;
+ if (platform === "linux" && musl) return `linux-musl-${arch}`;
+ return `${platform}-${arch}`;
+}
+
/** The asset for this machine, or null where Vercel publishes none. */
export function resolveAgentBrowserReleaseAsset(
platform: NodeJS.Platform = process.platform,
arch: string = process.arch,
musl = false,
): AgentBrowserReleaseAsset | null {
- const key = platform === "linux" && musl ? `linux-musl-${arch}` : `${platform}-${arch}`;
- return RELEASES.get(key) ?? null;
+ return RELEASES.get(linuxFamilyKey(platform, arch, musl)) ?? null;
}
+
+export { linuxFamilyKey };
diff --git a/server/browser-engine.test.ts b/server/browser-engine.test.ts
index d7e4f9b6d3..8b77d6d529 100644
--- a/server/browser-engine.test.ts
+++ b/server/browser-engine.test.ts
@@ -602,6 +602,23 @@ describe("restoring exactly one browser profile", () => {
});
describe("finding the browser engine", () => {
+ it("resolves Android to the statically linked Linux build instead of reporting it missing (#4868)", () => {
+ // Android is bionic, not musl, so isMusl() is false there; the asset that actually
+ // runs is the statically linked musl build, which needs no interpreter.
+ expect(isMusl("android")).toBe(false);
+
+ const android = resolveAgentBrowserReleaseAsset("android", "arm64");
+ expect(android).not.toBeNull();
+ expect(android!.asset).toBe("agent-browser-linux-musl-arm64");
+ expect(android!.target).toBe("linux-musl-arm64");
+
+ // Every other platform keeps the key it had before.
+ expect(resolveAgentBrowserReleaseAsset("linux", "arm64", true)!.target).toBe("linux-musl-arm64");
+ expect(resolveAgentBrowserReleaseAsset("linux", "arm64", false)!.target).toBe("linux-arm64");
+ expect(resolveAgentBrowserReleaseAsset("linux", "x64", false)!.target).toBe("linux-x64");
+ expect(resolveAgentBrowserReleaseAsset("darwin", "arm64")!.target).toBe("darwin-arm64");
+ });
+
it("pins the native-verified Windows revision in both download and desktop manifests", () => {
const asset = resolveAgentBrowserReleaseAsset("win32", "x64")!;
expect(asset).toEqual({