Communitygithub.com

vercel-labs/vercel-sandbox

Führe agent-browser + Chrome in Vercel Sandbox MicroVMs für Browser-Automatisierung in jeder Vercel-App aus – ideal für Next.js, SvelteKit, Nuxt, Remix, Astro und andere.

Was ist vercel-sandbox?

Dieses Skill ermöglicht Browser-Automatisierung innerhalb von flüchtigen Vercel Sandbox MicroVMs, die bei Bedarf gestartet werden. Es kombiniert `agent-browser` mit einem headless Chrome, sodass du Webseitenaufrufe, Screenshots, Barrierefreiheits-Snapshots und mehrstufige Workflows (z. B. Formularausfüllungen) aus jeder auf Vercel gehosteten Anwendung heraus durchführen kannst. Der Skill nutzt das `@agent-browser/sandbox`-Paket, das automatisch die benötigten Systemabhängigkeiten (Chromium-Bibliotheken) sowie `agent-browser` installiert. Für einen schnellen Start (unter einer Sekunde) kannst du einen Sandbox-Snapshot erstellen – ein vorinstalliertes VM-Image, das die übliche 30-Sekunden-Installationszeit umgeht. Die Integration unterstützt sowohl API-Routen als auch Server-Aktionen aller gängigen Vercel-Frameworks (Next.js, SvelteKit, Nuxt, Remix, Astro) und kann mit Vercel Cron-Jobs für wiederkehrende Aufgaben kombiniert werden. Die Authentifizierung erfolgt auf Vercel automatisch über OIDC; für die lokale Entwicklung sind Token-Umgebungsvariablen erforderlich.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/vercel-labs/agent-browser/tree/main/skill-data/vercel-sandbox

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Browser-Automatisierung mit Vercel Sandbox

Führe agent-browser + headless Chrome in flüchtigen Vercel Sandbox MicroVMs aus. Eine Linux-VM wird bei Bedarf gestartet, führt Browser-Befehle aus und fährt wieder herunter. Funktioniert mit jedem auf Vercel bereitgestellten Framework (Next.js, SvelteKit, Nuxt, Remix, Astro usw.).

Abhängigkeiten

pnpm add @agent-browser/sandbox @vercel/sandbox

Die Sandbox-VM benötigt Systemabhängigkeiten für Chromium sowie agent-browser selbst. Die @agent-browser/sandbox-Helfer installieren diese standardmäßig für neue Sandboxen und verwenden Sandbox-Snapshots (siehe unten) für einen Start unter einer Sekunde. Gib installSystemDependencies: false nur an, wenn das Sandbox-Image bereits die erforderlichen Chromium-Bibliotheken bereitstellt.

Kernmuster

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

async function withBrowser<T>(
  fn: (sandbox: VercelSandboxSession) => Promise<T>,
): Promise<T> {
  return withAgentBrowserSandbox(fn);
}

Screenshot

Der Befehl screenshot --json speichert die Datei und gibt den Pfad zurück. Lies die Datei als Base64 aus:

export async function screenshotUrl(url: string) {
  return withBrowser(async (sandbox) => {
    await runAgentBrowserCommand(sandbox, ["open", url]);

    const titleResult = await runAgentBrowserCommand<{ data?: { title?: string } }>(sandbox, [
      "get", "title",
    ]);
    const title = titleResult.json?.data?.title || url;

    const ssResult = await runAgentBrowserCommand<{ data?: { path?: string } }>(sandbox, [
      "screenshot",
    ]);
    const ssPath = ssResult.json?.data?.path;
    if (!ssPath) throw new Error("Screenshot hat keinen Dateipfad zurückgegeben.");
    const b64Result = await sandbox.runCommand("base64", ["-w", "0", ssPath]);
    const screenshot = (await b64Result.stdout()).trim();

    await runAgentBrowserCommand(sandbox, ["close"], { json: false });

    return { title, screenshot };
  });
}

Barrierefreiheits-Snapshot

export async function snapshotUrl(url: string) {
  return withBrowser(async (sandbox) => {
    await runAgentBrowserCommand(sandbox, ["open", url]);

    const titleResult = await runAgentBrowserCommand<{ data?: { title?: string } }>(sandbox, [
      "get", "title",
    ]);
    const title = titleResult.json?.data?.title || url;

    const snapResult = await runAgentBrowserCommand(sandbox, ["snapshot", "-i", "-c"], {
      json: false,
    });

    await runAgentBrowserCommand(sandbox, ["close"], { json: false });

    return { title, snapshot: snapResult.stdout };
  });
}

Mehrstufige Workflows

Die Sandbox bleibt zwischen Befehlen bestehen, sodass du vollständige Automatisierungssequenzen ausführen kannst:

export async function fillAndSubmitForm(
  url: string,
  data: Record<string, string>,
  postSubmitWaitArgs: string[],
) {
  return withBrowser(async (sandbox) => {
    await runAgentBrowserCommand(sandbox, ["open", url]);

    const snapResult = await runAgentBrowserCommand(sandbox, ["snapshot", "-i"], {
      json: false,
    });
    const snapshot = snapResult.stdout;
    // Snapshot parsen, um Element-Referenzen zu finden...

    for (const [ref, value] of Object.entries(data)) {
      await runAgentBrowserCommand(sandbox, ["fill", ref, value]);
    }

    await runAgentBrowserCommand(sandbox, ["click", "@e5"]);
    // Übergib eine app-spezifische Wartezeit, z. B. ["--url", "**/checkout/complete"],
    // ["--text", "Vielen Dank"] oder ["#confirmation"].
    await runAgentBrowserCommand(sandbox, ["wait", ...postSubmitWaitArgs]);

    const ssResult = await runAgentBrowserCommand<{ data?: { path?: string } }>(sandbox, [
      "screenshot",
    ]);
    const ssPath = ssResult.json?.data?.path;
    if (!ssPath) throw new Error("Screenshot hat keinen Dateipfad zurückgegeben.");
    const b64Result = await sandbox.runCommand("base64", ["-w", "0", ssPath]);
    const screenshot = (await b64Result.stdout()).trim();

    await runAgentBrowserCommand(sandbox, ["close"], { json: false });

    return { screenshot };
  });
}

Sandbox-Snapshots (Schneller Start)

Ein Sandbox-Snapshot ist ein gespeichertes VM-Image einer Vercel Sandbox, in dem bereits Systemabhängigkeiten + agent-browser + Chromium installiert sind. Stell es dir wie ein Docker-Image vor: Anstatt jedes Mal Abhängigkeiten von Grund auf zu installieren, startet die Sandbox aus dem vorgefertigten Image.

Dies ist nicht zu verwechseln mit der Barrierefreiheits-Snapshot-Funktion von agent-browser (agent-browser snapshot), die den Barrierefreiheitsbaum einer Seite ausgibt. Ein Sandbox-Snapshot ist ein Vercel-Infrastrukturkonzept für schnellen VM-Start.

Ohne Sandbox-Snapshot installiert jeder Durchlauf Systemabhängigkeiten + agent-browser + Chromium (~30s). Mit einem Snapshot erfolgt der Start in unter einer Sekunde.

Erstellen eines Sandbox-Snapshots

Der Snapshot muss Systemabhängigkeiten (über dnf), agent-browser und Chromium enthalten:

const snapshotId = await createAgentBrowserSnapshot();

Führe dies einmal aus und setze dann die Umgebungsvariable:

AGENT_BROWSER_SNAPSHOT_ID=snap_xxxxxxxxxxxx

Ein Hilfsskript ist in der Demo-App verfügbar:

npx tsx examples/environments/scripts/create-snapshot.ts

Empfohlen für jede Produktionsbereitstellung, die das Sandbox-Muster verwendet.

Authentifizierung

Auf Vercel-Deployments authentifiziert sich das Sandbox SDK automatisch über OIDC. Für lokale Entwicklung oder explizite Steuerung setze:

VERCEL_TOKEN=<personal-access-token>
VERCEL_TEAM_ID=<team-id>
VERCEL_PROJECT_ID=<project-id>

Diese werden in Sandbox.create()-Aufrufe eingestreut. Fehlen sie, fällt das SDK auf VERCEL_OIDC_TOKEN zurück (automatisch auf Vercel).

Geplante Workflows (Cron)

Kombiniere mit Vercel Cron Jobs für wiederkehrende Browser-Aufgaben:

// app/api/cron/route.ts  (oder Äquivalent in deinem Framework)
export async function GET() {
  const result = await withBrowser(async (sandbox) => {
    await sandbox.runCommand("agent-browser", ["open", "https://example.com/pricing"]);
    const snap = await sandbox.runCommand("agent-browser", ["snapshot", "-i", "-c"]);
    await sandbox.runCommand("agent-browser", ["close"]);
    return await snap.stdout();
  });

  // Ergebnisse verarbeiten, Benachrichtigungen senden, Daten speichern...
  return Response.json({ ok: true, snapshot: result });
}
// vercel.json
{ "crons": [{ "path": "/api/cron", "schedule": "0 9 * * *" }] }

Umgebungsvariablen

VariableErforderlichBeschreibung
AGENT_BROWSER_SNAPSHOT_IDNein (aber empfohlen)Vorgefertigte Sandbox-Snapshot-ID für subsekundenschnellen Start (siehe oben)
VERCEL_TOKENNeinVercel Personal Access Token (für lokale Entwicklung; OIDC ist automatisch auf Vercel)
VERCEL_TEAM_IDNeinVercel Team-ID (für lokale Entwicklung)
VERCEL_PROJECT_IDNeinVercel Projekt-ID (für lokale Entwicklung)

Framework-Beispiele

Das Muster funktioniert frameworksübergreifend identisch. Der einzige Unterschied ist der Ort des serverseitigen Codes:

FrameworkOrt des Server-Codes
Next.jsServer Actions, API-Routen, Route Handler
SvelteKit+page.server.ts, +server.ts
Nuxtserver/api/, server/routes/
Remixloader-, action-Funktionen
Astro.astro-Frontmatter, API-Routen

Beispiel

Siehe examples/environments/ im agent-browser-Repository für eine funktionierende App mit dem Vercel Sandbox-Muster, einschließlich eines Skripts zur Erstellung des Sandbox-Snapshots, einer Streaming-Progress-UI und Rate-Limiting.

Individual skills in this repo

This repo contains 8 individual skills — each has its own dedicated page.

agent-browser

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to

vercel-labs/agentcore

Run agent-browser on AWS Bedrock AgentCore cloud browsers. Use when the user wants to use AgentCore, run browser automation on AWS, use a cloud browser with AWS credentials, or needs a managed browser session backed by AWS infrastructure. Triggers include "use agentcore", "run on AWS", "cloud browser with AWS", "bedrock browser", "agentcore session", or any task requiring AWS-hosted browser automation.

vercel-labs/derive-client

Reverse-engineer a website's internal API by recording browser traffic into a HAR file, then generate a standalone client or CLI that calls the endpoints directly, with no browser needed after the first recording. Use when asked to "derive a client", "build a CLI for <site>", "reverse engineer this site's API", "record network requests", "turn this site into an API", or when the same site will be automated repeatedly and direct HTTP calls would beat driving the browser every time.

vercel-labs/dogfood

Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to "dogfood", "QA", "exploratory test", "find issues", "bug hunt", "test this app/site/platform", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.

vercel-labs/electron

Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include "automate Slack app", "control VS Code", "interact with Discord app", "test this Electron app", "connect to desktop app", or any task requiring automation of a native Electron application.

vercel-labs/protected-vercel-deployments

Access and test Vercel deployments protected by Vercel Authentication, SSO, or Deployment Protection with agent-browser. Use when a preview or production URL redirects to a Vercel login page, returns a protection 401 or 403, or needs short-lived Trusted Sources OIDC authentication instead of a static bypass secret or public exception.

vercel-labs/slack

Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include "check my Slack", "what channels have unreads", "send a message to", "search Slack for", "extract from Slack", "find who said", or any task requiring programmatic Slack interaction.

vercel-labs/webmcp-gen

Build and validate experimental WebMCP tools for an existing web page. Use when an agent needs to expose a site's real workflows as page tools, create webmcp.init.js, define deterministic checks, or compare WebMCP with accessibility-tree automation.

Verwandte Skills