feat(e2b): run Android and web targets in E2B sandboxes

Merged
TO
21d ago
+2712-7

What and why

  • New package @e2e-dev/e2b: run targets in E2B sandboxes, as agreed in #1414.
    • e2b(): a device provider for the mobile engine. Android 16 on E2B's public android-16 template, one sandbox per worker slot. The .apk is installed through agent-device, like device.installApp().
    • e2bBrowsers() from @e2e-dev/e2b/web: a browser provider for the web engine. Chromium in a sandbox per worker slot, or per attempt.
  • Sandboxes refuse public traffic. A loopback tunnel on the runner (packages/e2b/src/tunnel.ts) adds E2B's traffic token, because the web engine connects with a CDP URL alone and agent-device's client sends no custom header. A lease holds only 127.0.0.1:<port>, so the token never reaches a lease, log, or report.
  • The browser template is built once per E2B team from the Playwright image @e2e-dev/web pins. The docs page has the 8-line script.
flowchart LR
  R[e2e runner] -->|127.0.0.1| T[loopback tunnel]
  T -->|HTTPS + traffic token| E[E2B edge]
  E --> A[agent-device proxy<br/>Android sandbox]
  E --> C[Chromium DevTools<br/>browser sandbox]
engine: mobile({ platform: 'android', device: e2b() })
engine: web({ browser: e2bBrowsers() })

Issue

Fixes #1414

Verified

Ran it locally: yes

  • Live E2B sandboxes, e2e run against the built packages: Android 16 installs Privacy Friendly 2048 from an .apk, launches it, and swipes; Chromium browses Wikipedia in worker and attempt scope, and reads a download back. No sandbox is left running after a run.
  • The video is the live demo: a chat page where each message is an agent.act step on the same sandbox, Android first, then Chromium.

https://github.com/user-attachments/assets/dc294a02-f8f9-4bc2-a9b7-b94fba571f00

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.