Packages

@cloudflare/sandbox

1.0.3 · 22 Oct 2026Apache-2.02.1M / weekRepositoryHomepagenpmAtom feed

Your version

0.7.0

14 Jan 2026Where it was published

0.12.14 is the newest release of 0.7.x.

In short

2 new1 fixed

Release note

Minor Changes

  • 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.com

    Custom 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

  • 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 cloudflareAIGateway provider configuration with accountId, gatewayId, and optional apiToken.

  • 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<string, string | undefined>.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.