Skip to content

Add Vercel Sandbox guide - #963

Closed
theoephraim wants to merge 1 commit into
mainfrom
vercel-sandbox-guide
Closed

Add Vercel Sandbox guide#963
theoephraim wants to merge 1 commit into
mainfrom
vercel-sandbox-guide

Conversation

@theoephraim

Copy link
Copy Markdown
Member

Adds a Vercel Sandbox recipe to the sandbox guides, following the same shape as the E2B and Fly.io guides from #931: pass resolved values for trusted workloads, broker sandbox with the built-in tunnel for agentic ones, egress lockdown via the platform firewall, and a comparison note on Vercel's native firewall transforms.

The whole topology was validated live on real Vercel sandboxes, including wire substitution (hash oracle), response scrubbing, strict egress, and a live networkPolicy clamp. Vercel-specific facts baked into the recipe, all verified empirically:

  • public sandbox URLs carry the WS tunnel as-is
  • persistent sandboxes keep their domain, filesystem, and create-time env across stop/resume, so getOrCreate + onResume + --persist-ca makes broker wakes invisible to agents
  • npm i -g varlock works on the default runtime
  • default session timeout is 5 minutes, so the recipe always passes an explicit timeout

Docs only; no varlock code changes needed.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
varlock-website 35cb4f2 Commit Preview URL

Branch Preview URL
Jul 31 2026, 12:05 AM

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The copyable broker recipe has three lifecycle and provisioning failures that should be fixed before merging.

Reviewed changes in the new Vercel Sandbox documentation and navigation, including the recipe's contracts with the Vercel SDK and varlock proxy.

  • Direct value delivery: Documents loading validated values in the orchestrator and passing them through Vercel's sandbox environment.
  • Persistent broker topology: Adds broker creation, proxy startup, agent tunnel wiring, CA persistence, and lifecycle guidance.
  • Network controls: Covers live egress lockdown and compares varlock policy with Vercel firewall transforms.
  • Documentation navigation: Adds the guide to the sandbox overview and site sidebar.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using azure/gpt-5.6-sol𝕏

// yourself (or let the broker mint one and read it back with `varlock proxy
// token`). It is the credential to USE the broker over the tunnel, not to read
// its secrets.
const PROXY_TOKEN = crypto.randomUUID();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Because this token is regenerated on every orchestrator invocation, an existing named broker keeps its create-time token while the new agent below receives a different token. Re-running the recipe against a running or resumed broker therefore makes new agents fail tunnel authentication; use a stable externally managed token, or rotate the broker and agents together.

Technical details
# Keep the broker token stable across `getOrCreate`

## Affected sites
- `packages/varlock-website/src/content/docs/sandboxes/vercel.mdx:73` generates a new token for each orchestrator process.
- `packages/varlock-website/src/content/docs/sandboxes/vercel.mdx:95` uses `Sandbox.getOrCreate`, whose creation parameters are ignored when the named sandbox already exists.
- `packages/varlock-website/src/content/docs/sandboxes/vercel.mdx:136` passes the newly generated token to each agent.

## Required outcome
- Existing and resumed brokers must receive the same `VARLOCK_PROXY_TOKEN` as every agent that connects to them.

## Suggested approach
- Resolve `PROXY_TOKEN` from durable orchestrator configuration rather than calling `crypto.randomUUID()` on each invocation.
- If intentional rotation is shown instead, recreate or update all affected broker and agent state as one operation.

## References
- https://vercel.com/docs/sandbox/sdk-reference#sandbox.getorcreate
- https://vercel.com/docs/sandbox/concepts/persistent-sandboxes

// upload the schema (plus any other .env files your project loads);
// real values arrive via env above instead
await sbx.writeFiles([
{ path: 'proj/.env.schema', content: Buffer.from(envSchemaContents) },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A fresh sandbox does not contain proj, and Vercel documents that writeFiles() requires callers to create a missing target directory first. Add await sbx.mkDir('proj') before this upload, otherwise onCreate fails before the proxy can start. See https://vercel.com/docs/sandbox/sdk-reference#sandbox.mkdir.

name: 'varlock-broker',
runtime: 'node24',
ports: [8080],
timeout: 60 * 60 * 1000, // default is only 5 minutes; max 45m (Hobby) / 24h (Pro)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This requests 60 minutes even though the adjacent comment correctly notes Hobby's 45-minute maximum, so the generic recipe is rejected on Hobby. Use a value valid on every supported plan or show how to select a plan-specific timeout, and make the same change to the agent timeout on line 133. See https://vercel.com/docs/sandbox/pricing#runtime-limits.

@theoephraim

Copy link
Copy Markdown
Member Author

Closing for now -- I think we actually want to hold off here and make something more like what we are planning for cloudflare.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant