sandbox-agent

작성자: rivet-dev

샌드박스 환경에서 여러 AI 코딩 에이전트를 조율하기 위한 범용 API입니다. 통합된 응답, 이벤트 및 세션 관리 스키마를 통해 네 가지 코딩 에이전트(Claude Code, Codex, OpenCode, Amp)를 지원합니다. E2B, Daytona, Docker, Vercel, Cloudflare 등 환경별 구성을 통해 로컬 또는 클라우드 샌드박스에 배포할 수 있습니다. 에이전트 이벤트를 스트리밍하고, 여러 백엔드(인메모리, SQLite, Postgres, IndexedDB)에서 세션 지속성을 관리하며, 인간 개입 루프를 처리합니다...

npx skills add https://github.com/rivet-dev/skills --skill sandbox-agent

Sandbox Agent

Sandbox Agent provides a universal API for orchestrating AI coding agents in sandboxed environments.

What To Do If You Get Stuck

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:

  • Symptoms
    • If this is happening in local dev, deployed, or both
    • The error you're seeing
    • Relevant source code related to this
  • What you've tried to solve it
  • Environment
    • Sandbox Agent version
    • SDK in use (TypeScript, Python, or HTTP)
    • Agent in use (Claude Code, Codex, OpenCode, Amp, Mock)
    • Sandbox provider (E2B, Daytona, Docker, local)

Quickstart

Install skill (optional)

npx

npx skills add rivet-dev/skills -s sandbox-agent

bunx

bunx skills add rivet-dev/skills -s sandbox-agent

Set environment variables

Each coding agent requires API keys to connect to their respective LLM providers.

Local shell

export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."

E2B

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 });

Daytona

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

docker run -p 2468:2468 \
  -e ANTHROPIC_API_KEY="sk-ant-..." \
  -e OPENAI_API_KEY="sk-..." \
  rivetdev/sandbox-agent:0.4.2-full \
  server --no-token --host 0.0.0.0 --port 2468

Extracting API keys from current machine

Use sandbox-agent credentials extract-env --export to extract your existing API keys (Anthropic, OpenAI, etc.) from local Claude Code or Codex config files.

Testing without API keys

Use the mock agent for SDK and integration testing without provider credentials.

Multi-tenant and per-user billing

For per-tenant token tracking, budget enforcement, or usage-based billing, see LLM Credentials for gateway options like OpenRouter, LiteLLM, and Portkey.

Run the server

curl

Install and run the binary directly.

curl -fsSL https://releases.rivet.dev/sandbox-agent/0.4.x/install.sh | sh
sandbox-agent server --no-token --host 0.0.0.0 --port 2468

npx

Run without installing globally.

npx @sandbox-agent/[email protected] server --no-token --host 0.0.0.0 --port 2468

bunx

Run without installing globally.

bunx @sandbox-agent/[email protected] server --no-token --host 0.0.0.0 --port 2468

npm i -g

Install globally, then run.

npm install -g @sandbox-agent/[email protected]
sandbox-agent server --no-token --host 0.0.0.0 --port 2468

bun add -g

Install globally, then run.

bun add -g @sandbox-agent/[email protected]
# 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

Node.js (local)

For local development, use SandboxAgent.start() to spawn and manage the server as a subprocess.

npm install [email protected]
import { SandboxAgent } from "sandbox-agent";

const sdk = await SandboxAgent.start();

Bun (local)

For local development, use SandboxAgent.start() to spawn and manage the server as a subprocess.

bun add [email protected]
# 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();

Build from source

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.

Configuring token

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:

TypeScript

import { SandboxAgent } from "sandbox-agent";

const sdk = await SandboxAgent.connect({
  baseUrl: "http://your-server:2468",
  token: process.env.SANDBOX_TOKEN,
});

curl

curl "http://your-server:2468/v1/health" \
  -H "Authorization: Bearer $SANDBOX_TOKEN"

CLI

sandbox-agent --token "$SANDBOX_TOKEN" api agents list \
  --endpoint http://your-server:2468

CORS

If you're calling the server from a browser, see the CORS configuration guide.

Install agents (optional)

To preinstall agents:

sandbox-agent install-agent --all

If agents are not installed up front, they are lazily installed when creating a session.

Install desktop dependencies (optional, Linux only)

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.

Create a session

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);

Send a message

const result = await session.prompt([
  { type: "text", text: "Summarize the repository and suggest next steps." },
]);

console.log(result.stopReason);

Read events

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();

Test with Inspector

Open the Inspector UI at /ui/ on your server (for example, http://localhost:2468/ui/) to inspect sessions and events in a GUI.

Sandbox Agent Inspector

Next steps

  • 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.

Reference Map

Agents

AI

Deploy

General

rivet-dev의 다른 스킬

rivetkit-actors
rivet-dev
Rivet Actors로 상태 저장형 백엔드 구축: 고성능, 장기 실행, 인메모리, 지속형 프로세스. HTTP, 데이터베이스, 큐의 한계를 넘어설 때 사용하세요.…
official
agent-browser
rivet-dev
웹 테스트, 양식 작성, 스크린샷, 데이터 추출을 위한 브라우저 상호작용을 자동화합니다. 사용자가 웹사이트를 탐색하거나 웹과 상호작용해야 할 때 사용하세요.
official
multiplayer-game
rivet-dev
멀티플레이어 게임 구축을 위한 실용적 패턴: 매치메이킹, 틱 루프, 실시간 상태, 관심 관리, 검증. 10가지 게임 유형(배틀로얄, 아레나, IO 스타일, 오픈 월드, 파티, 물리 2D/3D, 랭크, 턴제, 방치형)에 대한 시작 코드와 아키텍처 패턴, 액터 토폴로지, 생명주기 다이어그램, 넷코드 전략 포함. 고정 실시간 루프 대 액션 기반 업데이트, 물리 엔진 선택(Rapier 2D/3D), 공간... 등 서버 시뮬레이션 기본 사항 다룸.
official
rivetkit
rivet-dev
AI 에이전트, 멀티플레이어 앱, 워크플로 자동화를 위한 장기 실행 상태 저장 컴퓨팅입니다. 액터는 데이터베이스 왕복 없이 요청 간 상태를 유지하는 영구적인 인메모리 프로세스로, 0에서 수백만 개의 동시 인스턴스까지 자동 확장됩니다. WebSocket 및 이벤트를 통한 내장 실시간 통신, 순서가 지정된 메시지 처리를 위한 내구성 있는 큐, 구조화된 데이터 쿼리를 위한 SQLite를 제공합니다. 상태는 Rivet Cloud 또는 자체 호스팅을 통해 재시작 및 충돌 후에도 유지됩니다...
official
rivetkit-actors
rivet-dev
Rivet Actors로 상태 저장형 백엔드 구축: 고성능, 장기 실행, 인메모리, 지속형 프로세스. HTTP, 데이터베이스, 큐의 한계를 넘어설 때 사용하세요.…
official
rivetkit-client-javascript
rivet-dev
JavaScript 클라이언트로, 무상태 또는 상태 저장 연결을 통해 Rivet Actors에 연결합니다. 브라우저, Node.js 및 Bun 환경을 지원하며, 환경 변수 또는 명시적 구성을 통한 자동 엔드포인트 감지 기능을 제공합니다. 독립적인 요청을 위한 무상태 액션 호출과 실시간 이벤트 구독이 가능한 상태 저장 연결의 두 가지 상호작용 모드를 제공합니다. onRequest 또는 onWebSocket 핸들러를 구현하는 액터를 위한 저수준 HTTP 및 WebSocket 액세스를 포함하며, 복합 배열 기반...
official
rivetkit-client-react
rivet-dev
React 클라이언트로, 훅과 실시간 상태 관리를 통해 Rivet Actors에 연결합니다. createRivetKit()으로 타입이 지정된 훅을 생성하고, useActor()로 키와 선택적 매개변수를 사용하여 액터 인스턴스에 연결합니다. useEvent()로 액터 이벤트를 구독하고, connStatus와 error 상태를 통해 연결 수명 주기를 모니터링합니다. createClient()를 사용하여 상태 비저장 단일 호출, 액터 검색 메서드(get, getOrCreate, create, getForId), 그리고 저수준 HTTP/WebSocket 액세스를 수행합니다. 복합 배열 키를 지원합니다...
official
rivetkit-client-swift
rivet-dev
Swift 클라이언트로, 무상태 및 상태 저장 연결 모드를 통해 Rivet Actors에 연결합니다. 무상태 액션 호출과 AsyncStream을 통한 실시간 이벤트 스트리밍이 가능한 지속적 WebSocket 연결을 지원합니다. 0~5개의 위치 인수를 사용한 타입화된 액션 호출과 더 많은 인수에 대한 원시 JSON 폴백을 제공합니다. 상태 변경, 오류, 열림, 닫힘 스트림을 통한 연결 수명 주기 모니터링을 포함합니다. 커스텀 onRequest 및...을 위한 저수준 HTTP 및 WebSocket 접근을 지원합니다.
official