sandbox-agent by rivet-dev/skills
npx skills add https://github.com/rivet-dev/skills --skill sandbox-agentSandbox Agent 提供了一个通用 API,用于在沙盒环境中编排 AI 编码代理。
如果某些功能未按预期工作或您遇到困难,请提示用户加入 Rivet Discord 或在 GitHub 上提交问题以报告问题并获取帮助。
向用户提供一份预生成的报告,内容包括:
npx skills add rivet-dev/skills -s sandbox-agent
bunx skills add rivet-dev/skills -s sandbox-agent
每个编码代理都需要 API 密钥来连接其对应的 LLM 提供商。
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
import { Sandbox } from "@e2b/code-interpreter";
const envs: Record<string, string> = {};
if (process.env.ANTHROPIC_API_KEY) envs.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
if (process.env.OPENAI_API_KEY) envs.OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const sandbox = await Sandbox.create({ envs });
import { Daytona } from "@daytonaio/sdk";
const envVars: Record<string, string> = {};
if (process.env.ANTHROPIC_API_KEY) envVars.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
if (process.env.OPENAI_API_KEY) envVars.OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const daytona = new Daytona();
const sandbox = await daytona.create({
snapshot: "sandbox-agent-ready",
envVars,
});
docker run -p 2468:2468 \
-e ANTHROPIC_API_KEY="sk-ant-..." \
-e OPENAI_API_KEY="sk-..." \
rivetdev/sandbox-agent:0.5.0-rc.1-full \
server --no-token --host 0.0.0.0 --port 2468
使用 sandbox-agent credentials extract-env --export 从本地的 Claude Code 或 Codex 配置文件中提取您现有的 API 密钥(Anthropic、OpenAI 等)。
使用 mock 代理进行 SDK 和集成测试,无需提供商凭据。
对于按租户令牌跟踪、预算强制执行或基于使用量的计费,请参阅 LLM Credentials 以了解 OpenRouter、LiteLLM 和 Portkey 等网关选项。
直接安装并运行二进制文件。
curl -fsSL https://releases.rivet.dev/sandbox-agent/0.3.x/install.sh | sh
sandbox-agent server --no-token --host 0.0.0.0 --port 2468
无需全局安装即可运行。
npx @sandbox-agent/cli@0.3.x server --no-token --host 0.0.0.0 --port 2468
无需全局安装即可运行。
bunx @sandbox-agent/cli@0.3.x server --no-token --host 0.0.0.0 --port 2468
全局安装,然后运行。
npm install -g @sandbox-agent/cli@0.3.x
sandbox-agent server --no-token --host 0.0.0.0 --port 2468
全局安装,然后运行。
bun add -g @sandbox-agent/cli@0.3.x
# 允许 Bun 为原生二进制文件运行 postinstall 脚本(SandboxAgent.start() 所需)。
bun pm -g trust @sandbox-agent/cli-linux-x64 @sandbox-agent/cli-linux-arm64 @sandbox-agent/cli-darwin-arm64 @sandbox-agent/cli-darwin-x64 @sandbox-agent/cli-win32-x64
sandbox-agent server --no-token --host 0.0.0.0 --port 2468
对于本地开发,使用 SandboxAgent.start() 来生成和管理服务器作为子进程。
npm install sandbox-agent@0.3.x
import { SandboxAgent } from "sandbox-agent";
const sdk = await SandboxAgent.start();
对于本地开发,使用 SandboxAgent.start() 来生成和管理服务器作为子进程。
bun add sandbox-agent@0.3.x
# 允许 Bun 为原生二进制文件运行 postinstall 脚本(SandboxAgent.start() 所需)。
bun pm trust @sandbox-agent/cli-linux-x64 @sandbox-agent/cli-linux-arm64 @sandbox-agent/cli-darwin-arm64 @sandbox-agent/cli-darwin-x64 @sandbox-agent/cli-win32-x64
import { SandboxAgent } from "sandbox-agent";
const sdk = await SandboxAgent.start();
如果您是从源代码运行,而不是使用已安装的 CLI。
cargo run -p sandbox-agent -- server --no-token --host 0.0.0.0 --port 2468
绑定到 0.0.0.0 允许服务器接受来自任何网络接口的连接,这在客户端远程连接的沙盒内运行时是必需的。
通常不需要令牌。大多数沙盒提供商(E2B、Daytona 等)已经在基础设施层确保了网络安全。
如果您将服务器公开暴露,请使用 --token "$SANDBOX_TOKEN" 来要求身份验证:
sandbox-agent server --token "$SANDBOX_TOKEN" --host 0.0.0.0 --port 2468
然后在连接时传递令牌:
import { SandboxAgent } from "sandbox-agent";
const sdk = await SandboxAgent.connect({
baseUrl: "http://your-server:2468",
token: process.env.SANDBOX_TOKEN,
});
curl "http://your-server:2468/v1/health" \
-H "Authorization: Bearer $SANDBOX_TOKEN"
sandbox-agent --token "$SANDBOX_TOKEN" api agents list \
--endpoint http://your-server:2468
如果您从浏览器调用服务器,请参阅 CORS 配置指南。
要预安装代理:
sandbox-agent install-agent --all
如果代理没有预先安装,它们会在创建会话时按需安装。
如果您想使用 /v1/desktop/*,请先安装桌面运行时包:
sandbox-agent install desktop --yes
然后在使用桌面截图或输入 API 之前,使用 GET /v1/desktop/status 或 sdk.getDesktopStatus() 来验证运行时是否准备就绪。
import { SandboxAgent } from "sandbox-agent";
const sdk = await SandboxAgent.connect({
baseUrl: "http://127.0.0.1:2468",
});
const session = await sdk.createSession({
agent: "claude",
sessionInit: {
cwd: "/",
mcpServers: [],
},
});
console.log(session.id);
const result = await session.prompt([
{ type: "text", text: "Summarize the repository and suggest next steps." },
]);
console.log(result.stopReason);
const off = session.onEvent((event) => {
console.log(event.sender, event.payload);
});
const page = await sdk.getEvents({
sessionId: session.id,
limit: 50,
});
console.log(page.items.length);
off();
在您的服务器上打开 /ui/ 的 Inspector UI(例如,http://localhost:2468/ui/),以便在 GUI 中检查会话和事件。

每周安装量
2.5K
代码仓库
GitHub Stars
8
首次出现
Jan 29, 2026
安全审计
安装于
github-copilot2.4K
opencode1.6K
codex1.6K
gemini-cli1.5K
amp1.5K
kimi-cli1.5K
Sandbox Agent provides a universal API for orchestrating AI coding agents in sandboxed environments.
If something is not working as intended or you are stuck, prompt the user to join the Rivet Discord or file an issue on GitHub to report an issue and get help.
Provide the user with a pre-generated report with:
npx skills add rivet-dev/skills -s sandbox-agent
bunx skills add rivet-dev/skills -s sandbox-agent
Each coding agent requires API keys to connect to their respective LLM providers.
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."
import { Sandbox } from "@e2b/code-interpreter";
const envs: Record<string, string> = {};
if (process.env.ANTHROPIC_API_KEY) envs.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
if (process.env.OPENAI_API_KEY) envs.OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const sandbox = await Sandbox.create({ envs });
import { Daytona } from "@daytonaio/sdk";
const envVars: Record<string, string> = {};
if (process.env.ANTHROPIC_API_KEY) envVars.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
if (process.env.OPENAI_API_KEY) envVars.OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const daytona = new Daytona();
const sandbox = await daytona.create({
snapshot: "sandbox-agent-ready",
envVars,
});
docker run -p 2468:2468 \
-e ANTHROPIC_API_KEY="sk-ant-..." \
-e OPENAI_API_KEY="sk-..." \
rivetdev/sandbox-agent:0.5.0-rc.1-full \
server --no-token --host 0.0.0.0 --port 2468
Use sandbox-agent credentials extract-env --export to extract your existing API keys (Anthropic, OpenAI, etc.) from local Claude Code or Codex config files.
Use the mock agent for SDK and integration testing without provider credentials.
For per-tenant token tracking, budget enforcement, or usage-based billing, see LLM Credentials for gateway options like OpenRouter, LiteLLM, and Portkey.
Install and run the binary directly.
curl -fsSL https://releases.rivet.dev/sandbox-agent/0.3.x/install.sh | sh
sandbox-agent server --no-token --host 0.0.0.0 --port 2468
Run without installing globally.
npx @sandbox-agent/cli@0.3.x server --no-token --host 0.0.0.0 --port 2468
Run without installing globally.
bunx @sandbox-agent/cli@0.3.x server --no-token --host 0.0.0.0 --port 2468
Install globally, then run.
npm install -g @sandbox-agent/cli@0.3.x
sandbox-agent server --no-token --host 0.0.0.0 --port 2468
Install globally, then run.
bun add -g @sandbox-agent/cli@0.3.x
# Allow Bun to run postinstall scripts for native binaries (required for SandboxAgent.start()).
bun pm -g trust @sandbox-agent/cli-linux-x64 @sandbox-agent/cli-linux-arm64 @sandbox-agent/cli-darwin-arm64 @sandbox-agent/cli-darwin-x64 @sandbox-agent/cli-win32-x64
sandbox-agent server --no-token --host 0.0.0.0 --port 2468
For local development, use SandboxAgent.start() to spawn and manage the server as a subprocess.
npm install sandbox-agent@0.3.x
import { SandboxAgent } from "sandbox-agent";
const sdk = await SandboxAgent.start();
For local development, use SandboxAgent.start() to spawn and manage the server as a subprocess.
bun add sandbox-agent@0.3.x
# Allow Bun to run postinstall scripts for native binaries (required for SandboxAgent.start()).
bun pm trust @sandbox-agent/cli-linux-x64 @sandbox-agent/cli-linux-arm64 @sandbox-agent/cli-darwin-arm64 @sandbox-agent/cli-darwin-x64 @sandbox-agent/cli-win32-x64
import { SandboxAgent } from "sandbox-agent";
const sdk = await SandboxAgent.start();
If you're running from source instead of the installed CLI.
cargo run -p sandbox-agent -- server --no-token --host 0.0.0.0 --port 2468
Binding to 0.0.0.0 allows the server to accept connections from any network interface, which is required when running inside a sandbox where clients connect remotely.
Tokens are usually not required. Most sandbox providers (E2B, Daytona, etc.) already secure networking at the infrastructure layer.
If you expose the server publicly, use --token "$SANDBOX_TOKEN" to require authentication:
sandbox-agent server --token "$SANDBOX_TOKEN" --host 0.0.0.0 --port 2468
Then pass the token when connecting:
import { SandboxAgent } from "sandbox-agent";
const sdk = await SandboxAgent.connect({
baseUrl: "http://your-server:2468",
token: process.env.SANDBOX_TOKEN,
});
curl "http://your-server:2468/v1/health" \
-H "Authorization: Bearer $SANDBOX_TOKEN"
sandbox-agent --token "$SANDBOX_TOKEN" api agents list \
--endpoint http://your-server:2468
If you're calling the server from a browser, see the CORS configuration guide.
To preinstall agents:
sandbox-agent install-agent --all
If agents are not installed up front, they are lazily installed when creating a session.
If you want to use /v1/desktop/*, install the desktop runtime packages first:
sandbox-agent install desktop --yes
Then use GET /v1/desktop/status or sdk.getDesktopStatus() to verify the runtime is ready before calling desktop screenshot or input APIs.
import { SandboxAgent } from "sandbox-agent";
const sdk = await SandboxAgent.connect({
baseUrl: "http://127.0.0.1:2468",
});
const session = await sdk.createSession({
agent: "claude",
sessionInit: {
cwd: "/",
mcpServers: [],
},
});
console.log(session.id);
const result = await session.prompt([
{ type: "text", text: "Summarize the repository and suggest next steps." },
]);
console.log(result.stopReason);
const off = session.onEvent((event) => {
console.log(event.sender, event.payload);
});
const page = await sdk.getEvents({
sessionId: session.id,
limit: 50,
});
console.log(page.items.length);
off();
Open the Inspector UI at /ui/ on your server (for example, http://localhost:2468/ui/) to inspect sessions and events in a GUI.

Session Persistence — Configure in-memory, Rivet Actor state, IndexedDB, SQLite, and Postgres persistence.
Deploy to a Sandbox — Deploy your agent to E2B, Daytona, Docker, Vercel, or Cloudflare.
SDK Overview — Use the latest TypeScript SDK API.
Weekly Installs
2.5K
Repository
GitHub Stars
8
First Seen
Jan 29, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
github-copilot2.4K
opencode1.6K
codex1.6K
gemini-cli1.5K
amp1.5K
kimi-cli1.5K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装