Repository navigation
Conversation
Promote the isolate engine behind the MCP sandboxedTool() into two unscoped
exports for chat tools and server functions:
- runSandboxed(): run an untrusted snippet in an isolate with injected facades
and hard limits (wall-clock, memory, host-call budget, result size), with no
MCP scope gate or manifest.
- sandboxedChatTool(): wrap a snippet as a plain ServerTool for chat({ tools }).
Add unit tests, a docs page (docs/tools/sandboxed-tools), and a runnable
example (examples/react/secure-sandbox-tools) that demonstrates both a
sandboxed chat tool and a sandboxed server function plus HTTP API route.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 7bce9df The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
View your CI Pipeline Execution ↗ for commit 7bce9df
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
Coverage✅ Coverage held across 79 compared package(s). Each package is measured twice in this job — on this PR and on its merge-base with
|
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-cloudflare
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-compaction
@tanstack/ai-computer-local
@tanstack/ai-computer-playwright
@tanstack/ai-computer-sandbox
@tanstack/ai-computer-use
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-effect
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-grok-build
@tanstack/ai-groq
@tanstack/ai-harness
@tanstack/ai-harness-cli
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-e2b
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-llmgateway
@tanstack/ai-lovable
@tanstack/ai-mcp
@tanstack/ai-mcp-sandbox
@tanstack/ai-memory
@tanstack/ai-mistral
@tanstack/ai-muse
@tanstack/ai-neon
@tanstack/ai-octane
@tanstack/ai-ollama
@tanstack/ai-ollaya
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-reactor
@tanstack/ai-remix
@tanstack/ai-sandbox
@tanstack/ai-sandbox-blaxel
@tanstack/ai-sandbox-boxd
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-e2b
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-railway
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-upstash-box
@tanstack/ai-sandbox-vercel
@tanstack/ai-skills
@tanstack/ai-solid
@tanstack/ai-svelte
@tanstack/ai-typesafe
@tanstack/ai-uthana
@tanstack/ai-utils
@tanstack/ai-vercel-gateway
@tanstack/ai-vertex
@tanstack/ai-vue
@tanstack/ai-worldlabs
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
@tanstack/svelte-ai-devtools
commit: |
Run an untrusted or AI-authored tool body in an isolate, so it can only reach the host functions you inject, under hard limits.
sandboxedChatTool()builds achat()tool whose body is walled to its facades.runSandboxed()does the same for a server function or endpoint. Both are the unscoped siblings of the MCP-onlysandboxedTool(), built on the same isolate engine.Stacked on #2171 (base
secure-mcp-server-base-v2), which adds the@tanstack/ai-mcp-sandboxpackage.🎯 Changes
runSandboxed()— run a snippet in an isolate with injected facades and limits (wall-clock, memory, host-call budget, result size). Driver-injected, so it stays framework-agnostic. No MCP scope gate or manifest. Returns a structured result, never throws.sandboxedChatTool()— wrap a snippet as a plainServerToolforchat({ tools }). A blocked run throws, so the agent loop sees a normal tool error.docs/tools/sandboxed-tools.md, plus a nav entry.examples/react/secure-sandbox-tools— a sandboxed chat tool, a sandboxed server function, and an HTTP API route, with four buttons that each try to escape and get stopped.packages/ai-mcp-sandbox/tests/run.test.ts.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.docs/for this change, or this change is not user-facing.pnpm changeset), or this PR does not change a published package.🚀 Release Impact
Public API change
New exports on
@tanstack/ai-mcp-sandbox. A chat tool whose body runs in the isolate:runSandboxed()is the lower-level core for a server function or endpoint. It returns{ ok, value?, error?, injectedCalls, ms }.Testing
Commands run.
pnpm test:pr— green. New unit teststests/run.test.tspass (6/6): value return + call count, wall-clock timeout, nofetch, injected-call budget, and the tool wrapper (runs + throws on block). Package typecheck/build, the example's typecheck/build,test:docs, andtest:kiiraall pass.Manual test.
cd examples/react/secure-sandbox-tools && pnpm dev(port 3100).Run (allowed)returns metrics.Infinite loop,Reach 169.254.169.254, andExceed call budgeteach showblockedwith the guardrail that stopped them.How this PR makes testing easy. Unit tests cover the engine, the example app shows both surfaces, and the API route is one
curl.Risk / rollback
Low. The exports are additive. They reuse the package's existing, tested isolate pieces (
buildBindings,buildPrelude,makeCallCounter,shapeResult). To undo, revert this PR. It targets the opensecure-mcp-server-base-v2branch, so it lands only when that branch does.