Skip to content

feat: add E2B sandbox provider - #393

Open
vibhorgupta96 wants to merge 2 commits into
truefoundry:mainfrom
vibhorgupta96:codex/issue-387-e2b-sandbox
Open

feat: add E2B sandbox provider#393
vibhorgupta96 wants to merge 2 commits into
truefoundry:mainfrom
vibhorgupta96:codex/issue-387-e2b-sandbox

Conversation

@vibhorgupta96

@vibhorgupta96 vibhorgupta96 commented Aug 21, 2026

Copy link
Copy Markdown

Summary

Adds E2B as a secure, tenant-scoped sandbox provider that can be configured through the settings API.

Closes #387

Changes

  • add a first-class E2B core provider for deterministic image-template builds, pause/auto-resume sandboxes, command execution, file transfer, and tenant ownership checks
  • authenticate Code Mode WebSocket upgrades with the sandbox-bound E2B-Traffic-Access-Token while preserving the existing headerless Daytona and TFY paths
  • add canonical discriminated E2B manifest/catalog schemas, provider dispatch, credential handling, persisted build metadata, runtime resolution, and status refresh
  • move provider image builds outside database transactions, recheck all pre-build inputs under lock, retry concurrent changes, and return a declared 409 on exhaustion
  • keep UI status wording provider-neutral and hide variants the current shared UI runtime cannot model without inventing Daytona lifecycle fields
  • add focused core, API, schema, dispatch, persistence, and UI regression coverage plus release changesets

How was this tested?

  • pnpm build
  • pnpm test
  • pnpm typecheck
  • pnpm lint:ci
  • pnpm format:check
  • pnpm --filter @truefoundry/trueforge-core build

The restricted runner initially blocked the existing Unix-domain-socket probe with EPERM; the full root test suite passed when rerun with socket access.

Known limitation

  • No live credentialed E2B integration run was possible; SDK boundaries are covered with injected/mocked tests.
  • The current @truefoundry/assistant-ui-runtime config only models Daytona lifecycle fields. E2B is therefore API-configurable in this PR, but is intentionally not exposed as a UI catalog preset. UI creation can be enabled after the canonical runtime type is provider-neutral and CI regenerates the SDK/OpenAPI artifacts.

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

High Risk
Touches sandbox isolation, credential handling, and Code Mode WebSocket auth, plus concurrent settings persistence. A bug here can leak tenant sandboxes or hold provider credentials incorrectly.

Overview
Adds E2B as a first-class sandbox provider configurable through the settings API (not yet in the shared UI catalog).

The new E2BSandboxProvider builds a release image into an E2B template, creates secure, non-public sandboxes that pause/auto-resume, and proves ownership via trueforge_tenant_id metadata because E2B ids are opaque. Code Mode NATS now resolves a host plus optional WebSocket upgrade headers so E2B can send the sandbox-bound E2B-Traffic-Access-Token; Daytona/TFY stay headerless.

Settings manifests become a discriminated union (daytona | e2b). Image builds run outside the DB transaction, then persist only if preflight inputs still match under lock (retry, then 409). The UI keeps Daytona-only configure forms and uses provider-neutral “image build” wording.

Reviewed by Cursor Bugbot for commit 7b45dd7. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7b45dd7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@truefoundry/trueforge-core Minor
@truefoundry/trueforge Minor
@truefoundry/trueforge-ui Patch
frontend Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4fbe488. Configure here.

Comment thread packages/trueforge-core/src/core/sandbox/provider/E2BProvider.ts
Comment thread packages/trueforge-core/src/core/sandbox/provider/E2BProvider.ts Outdated
Comment thread packages/trueforge-core/src/core/sandbox/provider/E2BProvider.ts
@debajyoti-truefoundry

Copy link
Copy Markdown
Contributor

@vibhorgupta96 Please check #387 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate E2B as Sandbox Provider

2 participants