-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[Sandbox] Document v1.0 migration #31694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aron-cf
wants to merge
2
commits into
production
Choose a base branch
from
sandbox-next
base: production
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| --- | ||
| name: sandbox-migrating-to-1-0 | ||
| description: Migrate Cloudflare Sandbox SDK projects to @cloudflare/sandbox@next and update deprecated transports, execution APIs, sessions, plugins, and extensions. | ||
| --- | ||
|
|
||
| # Sandbox SDK 1.0 migration | ||
|
|
||
| Use this skill when migrating a codebase from the current `@cloudflare/sandbox` release to the `1.0` preview, published on the `@cloudflare/sandbox@next` npm tag. | ||
|
|
||
| Existing projects should migrate as soon as possible. New projects should install `@cloudflare/sandbox@next` today. | ||
|
|
||
| For the full guide, refer to [Migrate to Sandbox SDK 1.0](https://developers.cloudflare.com/sandbox/guides/migrating-to-1-0/). | ||
|
|
||
| ## Install the 1.0 preview | ||
|
|
||
| Install the `1.0` preview: | ||
|
|
||
| ```sh | ||
| npm install @cloudflare/sandbox@next | ||
| ``` | ||
|
|
||
| Deploy Worker code and the container image together when the migration changes behavior across the SDK and runtime. | ||
|
|
||
| ## Scan the codebase | ||
|
|
||
| Search for these legacy APIs and configuration values: | ||
|
|
||
| - `SANDBOX_TRANSPORT` | ||
| - `transport: "http"` | ||
| - `transport: "websocket"` | ||
| - `execStream(` | ||
| - `startProcess(` | ||
| - `enableDefaultSession` | ||
| - `createCodeContext(` | ||
| - `runCode(` | ||
| - `gitCheckout(` | ||
| - `terminal(` | ||
| - `@cloudflare/sandbox/xterm` | ||
|
|
||
| ## Migration checklist | ||
|
|
||
| ### HTTP and WebSocket transports | ||
|
|
||
| HTTP and WebSocket transports are removed in `1.0`. RPC is the supported transport path. | ||
|
|
||
| Before installing the `1.0` preview, test the project with `SANDBOX_TRANSPORT=rpc`. Remove code that forces `transport: "http"` or `transport: "websocket"`. | ||
|
|
||
| ### Execution APIs | ||
|
|
||
| `exec()`, `execStream()`, and `startProcess()` are being consolidated into one `exec()` API that mirrors the Containers `container.exec()` model. | ||
|
|
||
| Use this migration map: | ||
|
|
||
| | Current API | Next API | Notes | | ||
| | ------------------------------- | ---------------------------------------- | ------------------------------- | | ||
| | `sandbox.exec(command)` | `sandbox.exec(...)` | Use for one-shot commands. | | ||
| | `sandbox.execStream(command)` | `sandbox.exec(...)` with streamed output | Use process stream APIs. | | ||
| | `sandbox.startProcess(command)` | `sandbox.exec(...)` process handle | Use for long-running processes. | | ||
|
|
||
| Confirm the final Sandbox SDK `exec()` TypeScript interface against the installed `1.0` preview package before rewriting production code. | ||
|
|
||
| ### Default sessions | ||
|
|
||
| Hidden default sessions are removed in `1.0`. The `enableDefaultSession` flag is removed from `getSandbox()`. | ||
|
|
||
| Remove `enableDefaultSession`: | ||
|
|
||
| ```ts | ||
| const sandbox = getSandbox(env.Sandbox, "my-sandbox"); | ||
| ``` | ||
|
|
||
| Use explicit sessions when shell state must persist: | ||
|
|
||
| ```ts | ||
| const session = await sandbox.createSession(); | ||
| await session.exec("cd /workspace/app"); | ||
| await session.exec("pwd"); | ||
| ``` | ||
|
|
||
| ### Plugins | ||
|
|
||
| Code Interpreter, Git, and PTY support move from the core SDK into plugins. | ||
|
|
||
| Plugins follow this pattern: | ||
|
|
||
| ```ts | ||
| import { Sandbox } from "@cloudflare/sandbox"; | ||
| import { withFeature } from "@cloudflare/sandbox/<plugin>"; | ||
|
|
||
| export class MySandbox extends Sandbox { | ||
| feature = withFeature(this); | ||
| } | ||
| ``` | ||
|
|
||
| The public interfaces should remain the same, but they are namespaced on the sandbox instance through the plugin. | ||
|
|
||
| Expected migration patterns: | ||
|
|
||
| ```ts | ||
| import { withCodeInterpreter } from "@cloudflare/sandbox/code-interpreter"; | ||
|
|
||
| export class MySandbox extends Sandbox { | ||
| codeInterpreter = withCodeInterpreter(this); | ||
| } | ||
|
|
||
| await sandbox.codeInterpreter.runCode("1 + 1"); | ||
| ``` | ||
|
|
||
| ```ts | ||
| import { withGit } from "@cloudflare/sandbox/git"; | ||
|
|
||
| export class MySandbox extends Sandbox { | ||
| git = withGit(this); | ||
| } | ||
|
|
||
| await sandbox.git.gitCheckout("https://github.com/user/repo"); | ||
| ``` | ||
|
|
||
| ```ts | ||
| import { withPty } from "@cloudflare/sandbox/pty"; | ||
|
|
||
| export class MySandbox extends Sandbox { | ||
| pty = withPty(this); | ||
| } | ||
|
|
||
| return await sandbox.pty.terminal(request); | ||
| ``` | ||
|
|
||
| Confirm plugin identifiers and helper names against the installed `1.0` preview package before rewriting production code. | ||
|
|
||
| ### Extension API | ||
|
|
||
| Use the new extension API when you want to attach reusable methods, state, or lifecycle behavior to a Sandbox instance. | ||
|
|
||
| Extensions use the same attachment model as plugins: | ||
|
|
||
| ```ts | ||
| import { withMyExtension } from "@cloudflare/sandbox/my-extension"; | ||
|
|
||
| export class MySandbox extends Sandbox { | ||
| myExtension = withMyExtension(this); | ||
| } | ||
|
|
||
| await sandbox.myExtension.doWork(); | ||
| ``` | ||
|
|
||
| Confirm the final extension authoring interface against the installed `1.0` preview package before publishing custom extensions. | ||
|
|
||
| ## Verification | ||
|
|
||
| After migrating: | ||
|
|
||
| 1. Confirm `@cloudflare/sandbox` resolves to the `1.0` preview release. | ||
| 2. Deploy the Worker and container image together. | ||
| 3. Run one top-level `exec()` call. | ||
| 4. Test workflows that previously used default sessions. | ||
| 5. Test Code Interpreter, Git, and PTY plugin calls. | ||
| 6. Run the project integration tests. |
27 changes: 27 additions & 0 deletions
27
src/content/changelog/sandbox/2026-07-01-announcing-sandbox-sdk-1-0-preview.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| title: Announcing the Sandbox SDK 1.0 preview | ||
| description: A new preview package introduces a consolidated exec() command interface and an extensions API ahead of the 1.0.0 release. | ||
| products: | ||
| - sandbox | ||
| date: 2026-07-01 | ||
| publish_future_dated_entry: true | ||
| --- | ||
|
|
||
| import { PackageManagers } from "~/components"; | ||
|
|
||
| Following on from our [recent deprecation announcement](/changelog/post/2026-06-09-deprecating-sandbox-sdk-features/), we are announcing a new preview package that contains the replacement APIs. | ||
|
|
||
| Install the `1.0` preview with: | ||
|
|
||
| <PackageManagers pkg="@cloudflare/sandbox@next" /> | ||
|
|
||
| The preview includes: | ||
|
|
||
| - A revised command interface that consolidates `exec()`, `execStream()`, and `startProcess()` into a single `exec()` function, aligning with the Containers `container.exec()` model. | ||
| - A new extensions API for adding reusable Sandbox capabilities outside the core SDK, including the Code Interpreter, Git, and PTY features that are moving into plugins. | ||
|
|
||
| We are aiming to ship this preview as `1.0.0` on July 31, 2026. | ||
|
|
||
| To get started, refer to [Migrate to Sandbox SDK 1.0](/sandbox/guides/migrating-to-1-0/). We also provide an [agent skill](/sandbox/guides/migrating-to-1-0/SKILL.md) to help with the migration. | ||
|
|
||
| For any questions, ask in the [Cloudflare Developers Discord](https://discord.gg/cloudflaredev). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redirect validation issue. Source URLs in
public/__redirectsmust end in/(or*,.xml,.json,.html). This line ends in.md, which will fail the redirect validation step in CI (bin/validate-redirects.ts).If external traffic hits the old skill file directly, consider whether this redirect is needed. If it is, you may need to serve the skill at a path ending in
/(e.g., via anindex.mdor HTML wrapper) rather than with a.mdextension. Otherwise, removing this line is the safest fix.