Cloudflare Sandbox Bridge Template
This Worker is the operator-facing bridge used by @paperclipai/plugin-cloudflare-sandbox.
It exposes a small authenticated JSON API under /api/paperclip-sandbox/v1 and translates Paperclip lease and command requests into Cloudflare Sandbox SDK calls.
What it does
- health and probe
- acquire, resume, release, and destroy leases
- execute commands in a sandbox session
- clean up timed-out sessions so Paperclip does not inherit wedged background processes
Prerequisites
- Cloudflare account with Sandbox / Containers access
wranglerconfigured for that account- Docker running locally for
wrangler deploy - A bridge auth token set as a Worker secret:
npx wrangler secret put BRIDGE_AUTH_TOKEN
Local development
cd bridge-template
pnpm install --ignore-workspace --no-lockfile
pnpm test
pnpm typecheck
pnpm dev
Deploy
pnpm deploy
After deploy, configure Paperclip with:
bridgeBaseUrl: your Worker URLbridgeAuthToken: the same bearer token value stored inBRIDGE_AUTH_TOKEN
Notes
reuseLease: trueshould only be used together withkeepAlive: true.workers.devis fine for bridge HTTP traffic, but preview/wildcard host flows are intentionally out of scope here- keep the Docker image aligned with the installed
@cloudflare/sandboxversion