cloudflare/sandbox-sdk @cloudflare/sandbox@0.7.0
cloudflare/sandbox-sdk
Captured source
source ↗@cloudflare/sandbox@0.7.0
Repository: cloudflare/sandbox-sdk
Tag: @cloudflare/sandbox@0.7.0
Published: 2026-01-14T14:10:39Z
Prerelease: no
Release notes:
Minor Changes
- #329 `fc1a8ea` Thanks @mikenomitch! - Add support for custom tokens in
exposePort()to enable stable preview URLs across deployments.
You can now pass a custom token when exposing ports to maintain consistent preview URLs between container restarts and deployments. This is useful for sharing URLs with users or maintaining stable references in production environments.
// With custom token - URL stays the same across restarts
const { url } = await sandbox.exposePort(8080, {
hostname: 'example.com',
token: 'my_token_v1' // 1-16 chars: a-z, 0-9, _
});
// url: https://8080-sandbox-id-my-token-v1.example.com
// Without token - generates random 16-char token (existing behavior)
const { url } = await sandbox.exposePort(8080, {
hostname: 'example.com'
});
// url: https://8080-sandbox-id-abc123random4567.example.comCustom tokens must be 1-16 characters containing only lowercase letters, numbers, and underscores.
Breaking change: Tokens can no longer contain hyphens. Existing preview URLs with hyphenated tokens (including some auto-generated ones) will stop working until the port is re-exposed.
Patch Changes
- #347 `efdd0d7` Thanks @roerohan! - Add Cloudflare AI Gateway support to OpenCode integration. Users can now route AI provider requests through Cloudflare AI Gateway for monitoring, caching, and rate limiting by adding a
cloudflareAIGatewayprovider configuration withaccountId,gatewayId, and optionalapiToken.
- #342 `7da85c0` Thanks @ghostwriternr! - Handle undefined environment variables as "unset" in setEnvVars
Environment variable APIs now properly handle undefined values:
- String values are exported as before
- undefined/null values now unset the variable (runs
unset VAR)
This enables idiomatic JavaScript patterns:
await sandbox.setEnvVars({
API_KEY: 'new-key',
OLD_SECRET: undefined // unsets OLD_SECRET
});Before: sandbox.setEnvVars({ KEY: undefined }) threw a runtime error After: sandbox.setEnvVars({ KEY: undefined }) runs unset KEY
TypeScript types now honestly accept Record.