@agentskit/sandbox

中文文档
0.6.13发布于 2026/10/10MITTypeScriptESM + CJS构建来源已验证近 30 天下载 3936

Secure code execution for AgentsKit agents.

原始使用文档
文档目录13 节
  1. Verified proof
  2. How this fits the ecosystem
  3. Why sandbox
  4. Install
  5. Quick example
  6. Features
  7. Honest isolation claims
  8. Ecosystem
  9. Contributors
  10. License
  11. Docs
  12. Maturity and compatibility
  13. Contributing

@agentskit/sandbox

Profile: concise-package

AgentsKit

Let agents write and run code safely — in isolated cloud VMs (E2B), constrained local runtimes, or a browser Web Worker.

npm version npm downloads bundle size license stability GitHub stars

Tags: ai · agents · llm · agentskit · ai-agents · sandbox · code-execution · e2b · secure-execution · code-interpreter

Verified proof

How this fits the ecosystem

@agentskit/sandbox gives agents a safer place to execute code and commands instead of trusting arbitrary tool calls in your app process.

  • AgentsKit: compose it with the other packages in this repo to build agents from small, swappable parts.
  • Registry: look for ready agents and templates that already use this layer at registry.agentskit.io.
  • Playbook: learn the production patterns behind this layer at playbook.agentskit.io.

Docs: package guide · agent handoff

Why sandbox

  • Code generation that actually executes — agents can write, run, and iterate without unrestricted host access
  • E2B cloud VMs — optional peer @e2b/code-interpreter; defaults to no internet (allowInternetAccess: false); per-execute timeout; combined stdout/stderr byte cap
  • Bring your own backend — SandboxBackend is two methods; plug in Docker, Firecracker, or any custom isolation layer
  • Policy wrapper — createMandatorySandbox allow/deny/requireSandbox (requireSandbox routes only { code, language? } args to the sandbox tool; incompatible schemas fail closed and the original body is never run)
  • Works alongside any other tools — add sandboxTool to the same tools array as webSearch or filesystem

Install

npm install @agentskit/sandbox @e2b/code-interpreter

Quick example

import { createRuntime } from '@agentskit/runtime'
import { anthropic } from '@agentskit/adapters'
import { sandboxTool } from '@agentskit/sandbox'

const runtime = createRuntime({
  adapter: anthropic({ apiKey: process.env.ANTHROPIC_API_KEY, model: 'claude-sonnet-4-6' }),
  tools: [sandboxTool({ apiKey: process.env.E2B_API_KEY })],
})

const result = await runtime.run('Write and run a Python script that generates a Fibonacci sequence up to 100')
console.log(result.content)

Features

  • sandboxTool({ apiKey }) — drop-in tool for code execution via E2B (optional peer)
  • createSandbox({ backend | apiKey, network?, timeout?, language? }) — facade with security defaults
  • Defaults: network: false, timeout: 30_000 ms per execute, language javascript
  • memoryLimit: accepted for compatibility; not enforced by E2B or Web Worker (custom backends may honor it)
  • SandboxBackend interface — execute + optional dispose
  • Local runtimes: process, macOS seatbelt, Linux bwrap (beta), Docker
  • Browser: @agentskit/sandbox/web — Web Worker (thread + DOM isolation only; not WebContainer)
  • Follows ToolDefinition contract — works in runtime, useChat, or any custom loop

Honest isolation claims

BackendWhat you getWhat you do not get
E2BRemote VM isolation, optional network denyPer-instance memoryLimit via AgentsKit
Web WorkerOff-main-thread + no DOMNetwork/FS security boundary; WebContainer
processSandboxChild process + env allowlist (PATH, HOME, TZ, LANG, LC_ALL, NODE_ENV, AGENTSKIT_*)OS-level fs/net isolation
seatbelt / bwrap / dockerPlatform jails (beta)A stable multi-tenant guarantee yet

Ecosystem

PackageRole
@agentskit/runtimecreateRuntime({ tools })
@agentskit/toolstools that pair with mandatory sandbox policy
@agentskit/adaptersLLM for codegen tasks
@agentskit/coreTool contract

Contributors

AgentsKit contributors

License

MIT — see LICENSE.

Docs

Full documentation · GitHub

Maturity and compatibility

  • Stability: beta — see docs/STABILITY.md. Not 1.0.
  • Node.js 20+ and TypeScript strict mode
  • Published as @agentskit/sandbox

Contributing

See CONTRIBUTING.md and the monorepo LICENSE.

版本与发布记录

@agentskit/sandbox 共发布 42 个版本,首次发布于 2026/04/06;过去 12 个月发布了 42 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.6.13latest2026/10/1028 天前
0.6.122026/10/031 个月前
0.6.112026/10/031 个月前
0.6.102026/09/291 个月前
0.6.92026/09/281 个月前
0.6.82026/09/281 个月前

关于 @agentskit/sandbox 的常见问题

@agentskit/sandbox 是什么?

Secure code execution for AgentsKit agents.

如何安装 @agentskit/sandbox?

在项目目录运行 npm install @agentskit/sandbox,或使用 pnpm add / yarn add / bun add。

@agentskit/sandbox 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agentskit/sandbox 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@agentskit/sandbox 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@agentskit/sandbox 可以商用吗?

@agentskit/sandbox 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agentskit/sandbox 的下载量有多少?

根据 npm 官方下载统计,@agentskit/sandbox 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,936 次,日均约 131 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agentskit/sandbox 还在维护吗?

最新版本 0.6.13 发布于 2026/10/10(28 天前);至今共发布 42 个版本,其中过去 12 个月发布了 42 个;首次发布于 2026/04/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。