Add new OpenCode x Sandboxes demo with remote tool calls#534
Draft
Add new OpenCode x Sandboxes demo with remote tool calls#534
Conversation
added 3 commits
March 27, 2026 11:50
Add process field to OpencodeServer so callers can inspect or interact with the underlying process. Add onStart callback to OpencodeOptions, invoked only when the server is freshly created rather than reused.
Prototype showing OpenCode running inside a Cloudflare Sandbox, with a custom plugin that routes tool calls (bash, read, write, edit, glob, grep, list) through the sandbox API rather than the local filesystem.
|
commit: |
Contributor
🐳 Docker Images Published
Usage: FROM cloudflare/sandbox:0.0.0-pr-534-c73bb6fVersion: 📦 Standalone BinaryFor arbitrary Dockerfiles: COPY --from=cloudflare/sandbox:0.0.0-pr-534-c73bb6f /container-server/sandbox /sandbox
ENTRYPOINT ["/sandbox"]Download via GitHub CLI: gh run download 23646265198 -n sandbox-binaryExtract from Docker: docker run --rm cloudflare/sandbox:0.0.0-pr-534-c73bb6f cat /container-server/sandbox > sandbox && chmod +x sandbox |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds an experimental example showing OpenCode running inside a Cloudflare Sandbox, with all tool calls (bash, read, write, edit, grep, glob, list) routed through an isolated CodeSandbox rather than the container's own filesystem.
The demo aims to demonstrate how workers can provide a
capnprotoRPC API very easily to services (either internally or externally) that allow easy interaction with those primatives.Then consumed in the OpenCode plugin:
Also includes a small addition to
@cloudflare/sandbox's OpenCode integration: exposesprocessonOpencodeServerand adds anonStartcallback toOpencodeOptions, invoked only when the server is freshly started (not reused). The example uses this to stream OpenCode logs to the Worker's console.Architecture
Two containers back the Worker:
opencode servewith a custom plugin that opens a Cap'n Web WebSocket server on port 3001The Durable Object connects to the plugin over Cap'n Web and exposes a
SandboxRpcApithat maps each tool call to the correct per-sessionCodeSandbox.Testing
cd examples/experimental/opencode npm run dev opencode attach http://localhost:8787