fix: add web terminal support to E2B sandboxes
Problem
E2B sandboxes do not start or expose the web-terminal (ttyd) when sandboxSettings.terminalEnabled is enabled. The shared sandbox supervisor supports ttyd, but the E2B provider does not supply its required binary, environment variables, port exposure, or URL propagation.
Current behavior
packages/e2b-infra/e2b.Dockerfiledoes not install thettydbinary.- The E2B template readiness command does not verify that
ttydis available. buildSandboxEnvVars()does not setTERMINAL_ENABLEDorTTYD_PROXY_PORT.E2BSandboxProvider.buildTunnelUrls()does not expose the resolved terminal proxy port or return attydUrl.- Because no
ttydUrlis returned, the lifecycle manager does not generate and broadcast the terminal JWT. - There are no E2B provider tests covering terminal enablement.
As a result, sandbox_runtime.entrypoint.start_ttyd() logs ttyd.skip because TERMINAL_ENABLED is absent. Even if that flag were added alone, startup would fail because the E2B image lacks the ttyd executable.
Expected behavior
When sandboxSettings.terminalEnabled is true, E2B should provide the same terminal behavior as Modal and Vercel:
- Install and verify a pinned
ttydbinary in the E2B template. - Set
TERMINAL_ENABLED=true. - Set
TTYD_PROXY_PORTusingresolveServicePorts(). - Generate and return the E2B hostname for the terminal proxy as
ttydUrl. - Exclude the terminal service port from duplicate generic tunnel URLs where appropriate.
- Preserve terminal URL behavior across sandbox resume.
- Add tests for environment variables, URL generation, create results, and resume results.
Relevant code
packages/e2b-infra/e2b.Dockerfilepackages/e2b-infra/build-template.pypackages/control-plane/src/sandbox/providers/e2b-helpers.tspackages/control-plane/src/sandbox/providers/e2b-provider.tspackages/control-plane/src/sandbox/providers/e2b-provider.test.tspackages/sandbox-runtime/src/sandbox_runtime/entrypoint.py
Modal provides the reference wiring in packages/modal-infra/src/sandbox/manager.py.
hey @ColeMurray i'd like to work on this if this is not stale. could you please assign it to me?
hey @ColeMurray i'd like to work on this if this is not stale. could you please assign it to me?
sounds good!
unassigning due to inactivity if someone else wants to take this on
I reviewed this against the current main branch. This issue is still needed, although the image-related part of the original description is now stale.
Current status
E2B now builds from the shared sandbox image bundle rather than packages/e2b-infra/e2b.Dockerfile (which no longer exists). That shared image already installs a pinned ttyd binary and verifies both its version and that it can start. The remaining gap is the E2B provider/control-plane wiring: terminalEnabled currently has no effect on the E2B runtime environment, E2B does not classify the terminal proxy as a dedicated service URL, and no ttydUrl reaches the lifecycle manager, so terminal credentials are never published for a newly created E2B sandbox.
Remaining requirements
- When terminal access is enabled, an E2B sandbox must start the existing ttyd + authenticated proxy runtime; when disabled, no terminal access should be advertised.
- The proxy must use the resolved terminal service port, including a configured custom port. The raw ttyd listener remains the runtime-internal localhost service and must not be exposed directly.
- E2B must expose the terminal proxy through its port hostname mechanism and return it as dedicated terminal access rather than only as a generic tunnel.
- The active terminal service port must not also appear in generic tunnel URLs. A same-numbered user tunnel should remain generic when the terminal feature is disabled.
- Terminal URLs must honor E2B custom domains, as the existing code-server and VNC URLs do.
- Both base-template and prebuilt-image creates must have the same behavior.
- A memory-preserving E2B pause/resume must leave terminal access usable without starting a second supervisor/terminal process. URL and token handling must remain valid across resume, including custom port/domain cases.
- Lifecycle behavior must continue to mint, persist securely, and broadcast terminal access only when a provider reports a terminal URL.
- Tests should cover enabled and disabled behavior, default and custom ports, generic-tunnel de-duplication, domain-aware URLs, create results, prebuilt-image creates, and paused/running resume results. Lifecycle coverage should establish that reported E2B terminal access becomes available to clients.
Relevant locations
packages/control-plane/src/sandbox/providers/e2b-provider.ts- E2B create/resume environment assembly and service URL results.packages/control-plane/src/sandbox/providers/e2b-provider.test.ts- current E2B environment, URL, prebuilt-image, and resume coverage; there are no terminal-specific cases today.packages/control-plane/src/sandbox/sandbox-env.ts- shared REST-provider runtime environment boundary. It currently handles code-server and VNC service variables, but not terminal variables.packages/control-plane/src/sandbox/providers/port-resolution.ts- authoritative resolution of the default/configured terminal port.packages/control-plane/src/sandbox/provider.ts- provider result contracts. Create/restore results carryttydUrl; resume results currently do not.packages/control-plane/src/sandbox/lifecycle/manager.ts- create/restore terminal credential storage and resume-result handling. Create already mints terminal JWTs whenttydUrlis present; resume currently handles code-server, VNC, and generic tunnels only.packages/sandbox-runtime/src/sandbox_runtime/web_terminal.pyandpackages/sandbox-runtime/src/sandbox_runtime/ttyd_proxy/server.ts- existing runtime contract for enablement, proxy port selection, and JWT authentication.packages/control-plane/src/sandbox/providers/vercel/provider.tsandpackages/modal-infra/src/sandbox/manager.py- existing provider behavior to use as a behavioral reference.
Already satisfied / no longer required
packages/sandbox-images/install/tools.shinstalls the pinned ttyd binary used by E2B.packages/sandbox-images/verify/smoke_test.pyverifies the version and performs a live service probe during the E2B template build flow inpackages/e2b-infra/build-template.py.
So the issue should remain open, but contributors should not add a new E2B Dockerfile or duplicate ttyd installation/readiness logic.
This looks resolved by #2410 (merged 2026-10-15), which exposes the web terminal on E2B create and resume. Can this be closed?
Resolved by #2410, verified on current main against the remaining requirements from the September triage comment.
- Image: the shared sandbox image installs a pinned ttyd binary, and the E2B template build smoke-tests it. No E2B-specific Dockerfile is needed.
- Runtime env:
sandbox-env.tssetsTERMINAL_ENABLEDandTTYD_PROXY_PORTfrom the resolved port plan whenterminalEnabledis on, and clears them when it's off. - Provider URLs:
E2BSandboxProvider.buildTunnelUrls()uses the sharedresolveSandboxPortPlan(). It returnsttydUrlthroughgetHostnameForPort(custom domains are honored) and excludes enabled service ports from generic tunnels. A same-numbered user tunnel stays generic when the terminal is disabled. - Create and resume:
ttydUrlis returned for base-template creates, prebuilt-image creates, and paused/running resumes. - Lifecycle: the manager stores and broadcasts terminal access when
ttydUrlis present on create, and keeps it across resume without starting a second supervisor. - Tests:
providers/e2b-terminal.test.tsandlifecycle/e2b-terminal.test.tscover enabled/disabled, default/custom ports, custom domains, tunnel de-duplication, base/prebuilt creates, paused/running resumes, and JWT verification.
Out of scope: per #2410, a resume reuses an unexpired retained terminal token, but expired tokens are not renewed (existing JWT expiry policy). These tests mock E2B, and no live E2B terminal session has been exercised. Closing.