Back to Agent Browser

@agent-browser/sandbox

packages/@agent-browser/sandbox/README.md

0.29.02.1 KB
Original Source

@agent-browser/sandbox

Helpers for installing and running agent-browser inside sandbox runtimes.

This package does not define model tools. Use it from framework-specific tools, agents, route handlers, or jobs that already decide what the browser should do.

Eve

ts
import { defineSandbox } from "eve/sandbox";
import { vercel } from "eve/sandbox/vercel";
import { agentBrowserRevalidationKey, installAgentBrowser } from "@agent-browser/sandbox/eve";

export default defineSandbox({
  backend: vercel({ runtime: "node24", resources: { vcpus: 2 } }),
  revalidationKey: () => agentBrowserRevalidationKey({ installSystemDependencies: true }),
  async bootstrap({ use }) {
    const sandbox = await use();
    await installAgentBrowser(sandbox, { installSystemDependencies: true });
  },
});

Then call agent-browser from an Eve tool:

ts
import { runAgentBrowser } from "@agent-browser/sandbox/eve";

const result = await runAgentBrowser(ctx, ["open", "https://example.com"]);

The Eve helper derives a short, stable agent-browser session name from the Eve sandbox id. Pass session to runAgentBrowser when multiple independent browser sessions should share one sandbox.

Vercel Sandbox

Install @vercel/sandbox in the consuming app:

bash
pnpm add @vercel/sandbox

Then use the Vercel provider entry:

ts
import { runAgentBrowserCommand, withAgentBrowserSandbox } from "@agent-browser/sandbox/vercel";

const snapshot = await withAgentBrowserSandbox(async (sandbox) => {
  await runAgentBrowserCommand(sandbox, ["open", "https://example.com"]);
  const result = await runAgentBrowserCommand(sandbox, ["snapshot", "-i", "-c"], {
    json: false,
  });
  return result.stdout;
});

Set AGENT_BROWSER_SNAPSHOT_ID to boot from a prebuilt Vercel Sandbox snapshot. Without a snapshot, the helper installs system dependencies, agent-browser, and Chrome on first boot.

Version Pinning

By default, this package installs the matching agent-browser version:

ts
agent-browser@0.29.0

Pass installSpec: "latest" or another npm spec to override that default.