Skip to content

feat(sandbox-vercel): Vercel Sandbox provider worker#95

Open
rohitg00 wants to merge 5 commits into
mainfrom
sandbox-vercel
Open

feat(sandbox-vercel): Vercel Sandbox provider worker#95
rohitg00 wants to merge 5 commits into
mainfrom
sandbox-vercel

Conversation

@rohitg00
Copy link
Copy Markdown
Contributor

@rohitg00 rohitg00 commented May 7, 2026

Member of the sandbox worker family. Read `sandbox-CONTEXT.md` (lands via #92) for family terminology and ABI contract.

What ships

`sandbox-vercel/` — narrow Node iii worker wrapping Vercel Sandbox (Firecracker microVMs on Vercel's "Hive" infra).

Functions

REST endpoint paths verified via context7 against `vercel.com/docs/rest-api/sandboxes/*`:

Function Wired
`sandbox::vercel::create` `POST /v1/sandboxes?teamId=&slug=` body `{runtime, source, timeout, ...}`; `timeout` is in milliseconds upstream (converted from idle_timeout_secs at the boundary); `source` (git ref) required from caller as `source_url` + optional `source_revision`
`sandbox::vercel::exec` `POST /v1/sandboxes/{id}/commands` body `{command, args, cwd}`
`sandbox::vercel::stop` `POST /v1/sandboxes/{id}/stop` (POST not DELETE); 404 / 409 = idempotent success
`sandbox::vercel::list` `GET /v1/sandboxes?teamId=&slug=`
`sandbox::vercel::snapshot` / `expose_port` / `fs::*` stub — under v2-beta sessions surface; follow-up

Capabilities advertised: `["snapshot","expose_port","fs"]`.

Auth model

  • Prefers `VERCEL_OIDC_TOKEN` (auto-injected in Vercel-deployed projects, 12 h dev token via `vercel env pull`)
  • Falls back to `VERCEL_TOKEN` + `VERCEL_TEAM_ID` + `VERCEL_PROJECT_ID`
  • Optional `VERCEL_TEAM_SLUG` for the `?slug=` query param

Worker fails fast at startup if neither credential path is satisfied.

Vercel asymmetry (documented in CONTEXT.md)

Vercel's `image` field is meaningless without `source` (a git ref to clone) + `runtime` (`node24`/`python3.13`). Caller passes `source_url` and optional `source_revision` in the create payload; the canonical `image` field is informational on Vercel.

Tests

5 vitest cases against handler boundary (allowlist, in_flight rollback, exec validation, stop error mapping, list envelope). `tsc --noEmit` clean, biome ci clean.

Live test status

Wired against documented shapes; not yet end-to-end verified.

Pin

`iii-sdk: 0.11.6`.

rohitg00 added 4 commits May 7, 2026 11:36
Mirrors the sandbox::e2b::* ABI under sandbox::vercel::* with capability
negotiation, per-worker concurrency tracking, and S-code error mapping.
Same 8 functions (create, exec, stop, list, snapshot, expose_port,
fs::read, fs::write).

Auth: prefers VERCEL_OIDC_TOKEN; falls back to VERCEL_TOKEN +
VERCEL_TEAM_ID + VERCEL_PROJECT_ID. Default base URL: https://api.vercel.com.
Default runtime: node24.

5/5 vitest tests pass; biome lint clean; tsc clean. HTTP call bodies
stubbed pending verified pass against Vercel's REST surface.
Re-orders type and value imports per biome's organizeImports check so
'biome ci .' passes cleanly. No behavior change.
Replaces stubs with the surface verified at vercel.com/docs/rest-api/sandboxes
via context7:

- create: POST /v1/sandboxes?teamId=&slug= body {runtime, source, timeout}
  - timeout is in MILLISECONDS (Vercel contract); converted from
    idle_timeout_secs at the boundary
  - source is required (git ref); caller passes optional source_url +
    source_revision in the payload
- exec: POST /v1/sandboxes/{id}/commands body {command, args, cwd}
- stop: POST /v1/sandboxes/{id}/stop (POST not DELETE)
  - 404 and 409 treated as idempotent success
- list: GET /v1/sandboxes?teamId=&slug= response {sandboxes:[...]} or array

teamId from VERCEL_TEAM_ID; slug from VERCEL_TEAM_SLUG. Bearer token
from VERCEL_OIDC_TOKEN with VERCEL_TOKEN fallback. SandboxRecord
started_at is now a pass-through string to match the rest of the family.

snapshot, expose_port, and fs ops remain stubbed pending v2-beta
sessions surface. Adds .gitignore for node_modules + .venv +
package-lock.json. tsc + biome + tests clean.
registerFunction(id, async (input) => ...) handler signature unchanged
between versions; tsc + biome + vitest still clean.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Warning

Rate limit exceeded

@rohitg00 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 22 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3fabfc89-dd32-4011-a9e0-ae2ebf1b60c2

📥 Commits

Reviewing files that changed from the base of the PR and between 2e53b44 and f87d931.

📒 Files selected for processing (12)
  • sandbox-vercel/.gitignore
  • sandbox-vercel/Dockerfile
  • sandbox-vercel/README.md
  • sandbox-vercel/iii.worker.yaml
  • sandbox-vercel/package.json
  • sandbox-vercel/src/client.ts
  • sandbox-vercel/src/config.ts
  • sandbox-vercel/src/handlers.ts
  • sandbox-vercel/src/index.ts
  • sandbox-vercel/src/sandbox.ts
  • sandbox-vercel/tests/handlers.test.ts
  • sandbox-vercel/tsconfig.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sandbox-vercel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Stops shadowing the bare sandbox::* namespace. Routes through the
sandbox router worker (provider="vercel"); direct invocation stays
supported and stable.

Handler logic, tests, S-code mapping unchanged.
@rohitg00
Copy link
Copy Markdown
Contributor Author

Refactored to register only sandbox::provider::vercel::*. Caller-facing sandbox::* now owned by the new sandbox router worker in #119. Direct invocation of sandbox::provider::vercel::* stays supported.

Validation: cargo fmt --check + cargo clippy -D warnings + tests clean. Depends on #119 for end-to-end use via the router; this PR is independently mergeable if direct invocation is sufficient.

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.

1 participant