From 0a02d14e73d671af1298e7e73053bd8f0c8cc6bf Mon Sep 17 00:00:00 2001 From: Michiel Voortman <135761097+MichielMAnalytics@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:35:03 +0000 Subject: [PATCH] feat(sandbox): add boxd as a remote sandbox provider Adds a boxd adapter next to E2B and Daytona. It mirrors the Daytona adapter: runtime dependency strategy, one snapshot per sandbox kind, a wall-clock lifetime, and kill() deletes the machine. Machines are created isolated. BOXD_FUNCTION_SNAPSHOT takes a version-pinned @ ref. The adapter checks the version the machine was restored from and fails closed on any other. Includes the Function snapshot builder, capability and sim-setup registration, billing rates, the conformance suite run three ways, a gated live smoke test, and self-hosting docs. --- .../platform/self-hosting/architecture.mdx | 2 +- .../self-hosting/environment-variables.mdx | 7 +- .../docs/platform/self-hosting/index.mdx | 2 +- .../self-hosting/reference-architectures.mdx | 2 +- .../docs/platform/self-hosting/sandboxes.mdx | 47 +- .../docs/platform/self-hosting/security.mdx | 2 + .../docs/workflows/blocks/function.mdx | 6 +- apps/sim/.env.example | 8 + apps/sim/lib/billing/sandbox-pricing.test.ts | 2 + apps/sim/lib/billing/sandbox-pricing.ts | 23 + .../config/env-capabilities.server.test.ts | 10 +- .../lib/core/config/env-capabilities.test.ts | 23 + apps/sim/lib/core/config/env-flags.ts | 71 +- apps/sim/lib/core/config/env.ts | 14 +- apps/sim/lib/core/execution-limits/metrics.ts | 11 +- .../remote-sandbox/boxd.live.test.ts | 184 ++++ apps/sim/lib/execution/remote-sandbox/boxd.ts | 568 +++++++++++ .../remote-sandbox/cli-tools.server.ts | 4 +- .../remote-sandbox/cli-tools.test.ts | 4 +- .../remote-sandbox/conformance.test.ts | 894 ++++++++++++++++-- .../remote-sandbox/files.live.test.ts | 3 +- .../remote-sandbox/function-resources.ts | 7 + .../remote-sandbox/pi-lifetime.test.ts | 6 + .../execution/remote-sandbox/pi-lifetime.ts | 2 +- .../execution/remote-sandbox/pi-resources.ts | 4 + .../lib/execution/remote-sandbox/provider.ts | 2 + .../sim/lib/execution/remote-sandbox/types.ts | 7 +- apps/sim/next.config.ts | 1 + apps/sim/package.json | 1 + .../scripts/build-function-boxd-snapshot.ts | 207 ++++ apps/sim/scripts/verify-sandbox-parity.ts | 19 +- apps/sim/trigger.config.ts | 9 + bun.lock | 5 + .../deployment-config/src/env-capabilities.ts | 30 + packages/sim-setup/src/capability-config.ts | 33 +- .../sim-setup/src/capability-status.test.ts | 17 + packages/sim-setup/src/capability-status.ts | 7 +- packages/utils/src/sandbox-references.test.ts | 20 + packages/utils/src/sandbox-references.ts | 35 +- 39 files changed, 2149 insertions(+), 150 deletions(-) create mode 100644 apps/sim/lib/execution/remote-sandbox/boxd.live.test.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/boxd.ts create mode 100644 apps/sim/scripts/build-function-boxd-snapshot.ts diff --git a/apps/docs/content/docs/platform/self-hosting/architecture.mdx b/apps/docs/content/docs/platform/self-hosting/architecture.mdx index e43e1a1abb5..096d96927f7 100644 --- a/apps/docs/content/docs/platform/self-hosting/architecture.mdx +++ b/apps/docs/content/docs/platform/self-hosting/architecture.mdx @@ -25,7 +25,7 @@ Sim runs an app, a realtime server, PostgreSQL, Redis, and a scheduler. This pag The Next.js app serves the workflow builder, API routes, and workflow orchestration. Local JavaScript runs in Node child workers using isolated-vm inside the app container. The app and those workers share the container's memory budget. The Helm chart requests 4 GiB and limits the app to 8 GiB; `docker-compose.prod.yml` sets an 8 GB memory limit without a reservation. -E2B or Daytona moves supported code execution to a remote sandbox. `TRIGGER_DEV_ENABLED` routes asynchronous jobs to Trigger.dev; the default deployment uses database-backed jobs. See [Sandboxes](/platform/self-hosting/sandboxes) for the provider and image requirements. +E2B, Daytona, or boxd moves supported code execution to a remote sandbox. `TRIGGER_DEV_ENABLED` routes asynchronous jobs to Trigger.dev; the default deployment uses database-backed jobs. See [Sandboxes](/platform/self-hosting/sandboxes) for the provider and image requirements. Any replica can serve files once shared object storage is configured. Before adding replicas, configure storage, Redis, and database connection capacity as described in [Scaling and high availability](/platform/self-hosting/scaling). diff --git a/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx b/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx index 11412054792..96e3849bf33 100644 --- a/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx +++ b/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx @@ -180,13 +180,16 @@ Who may sign up and sign in — the allowlists, blocklists, `DISABLE_REGISTRATIO | Variable | Description | |----------|-------------| -| `SANDBOX_PROVIDER` | Remote sandbox provider: `e2b` (default) or `daytona` | +| `SANDBOX_PROVIDER` | Remote sandbox provider: `e2b` (default), `daytona`, or `boxd` | | `E2B_ENABLED` / `E2B_API_KEY` | Enable E2B remote execution | | `DAYTONA_API_KEY` | Daytona API key (used when `SANDBOX_PROVIDER=daytona`) | | `E2B_FUNCTION_TEMPLATE_ID` | Immutable `