sandbox-agent について
Sandbox Agent は、サンドボックス環境でコーディングエージェントをオーケストレーションする API と SDK です。このスキルは、エージェントやサンドボックスプロバイダーと連携する開発者向けに、設定と利用方法を案内します。
主な機能
- 01コーディングエージェントとサンドボックスプロバイダーの設定
- 02サービスの起動または接続
- 03セッションの作成とプロンプト送信
- 04セッションイベントの読み取り
- 05mock エージェントによるテスト
- 06構造化されたトラブル報告の準備
活用シーン
- 01サンドボックス内でコーディングエージェントのセッションを開始
- 02プロバイダーの API キーなしで SDK 連携をテスト
- 03デプロイ済み Sandbox Agent サーバーへクライアントを接続
- 04問題報告に必要な情報を収集
MCP 対応
資料には、MCP 設定の読み取りや更新を行うサーバー設定エンドポイントが記載されています。このスキル自体が MCP サーバーインターフェースを提供するとは説明されていません。
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ rivet-dev/ skills --skill sandbox-agentインストール後、Claude Code で/sandbox-agentを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
references/agent-sessions.mdreferences/agents/amp.mdclaude.mdcodex.mdcursor.mdopencode.mdpi.mdreferences/ai/llms-txt.mdreferences/api-reference/authentication.mdindex.mdreferences/api-reference/operations/delete_v1_acp.mddelete_v1_config_mcp.mddelete_v1_config_skills.mddelete_v1_desktop_recording.mddelete_v1_fs_entry.mddelete_v1_process.mdget_v1_acp_servers.mdget_v1_acp.mdget_v1_agent.mdget_v1_agents.mdget_v1_config_mcp.mdget_v1_config_skills.mdget_v1_desktop_clipboard.mdget_v1_desktop_display_info.mdget_v1_desktop_mouse_position.mdget_v1_desktop_recording_download.mdget_v1_desktop_recording.mdget_v1_desktop_recordings.mdget_v1_desktop_screenshot_region.mdget_v1_desktop_screenshot.md詳細
Sandbox Agent
Sandbox Agent は、サンドボックス環境で AI コーディングエージェントをオーケストレーションするための汎用 API を提供します。
行き詰まった場合の対処方法
意図したとおりに動作しない場合や行き詰まった場合は、問題を報告してサポートを受けられるよう、ユーザーに Rivet Discord への参加、または GitHub での Issue の作成を案内してください。
事前に生成したレポートをユーザーに提供してください。レポートには以下を含めます。
- 症状
- ローカル開発環境、デプロイ環境、または両方で発生しているか
- 表示されているエラー
- 関連するソースコード
- 解決のために試したこと
- 環境
- Sandbox Agent のバージョン
- 使用中の SDK(TypeScript、Python、または HTTP)
- 使用中のエージェント(Claude Code、Codex、OpenCode、Amp、Mock)
- サンドボックスプロバイダー(E2B、Daytona、Docker、local)
クイックスタート
スキルをインストールする(任意)
npx
npx skills add rivet-dev/skills -s sandbox-agent
bunx
bunx skills add rivet-dev/skills -s sandbox-agent
環境変数を設定する
各コーディングエージェントが、それぞれの LLM プロバイダーに接続するには API キーが必要です。
ローカルシェル
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.5.3-full \
server --no-token --host 0.0.0.0 --port 2468
現在のマシンから API キーを抽出する
sandbox-agent credentials extract-env --export を使うと、ローカルの Claude Code または Codex の設定ファイルから既存の API キー(Anthropic、OpenAI など)を抽出できます。
API キーなしでテストする
プロバイダーの認証情報がなくても SDK や統合をテストできるよう、mock エージェントを使用してください。
マルチテナントおよびユーザーごとの課金
テナントごとのトークン追跡、予算の適用、または使用量ベースの課金については、OpenRouter、LiteLLM、Portkey などのゲートウェイオプションを紹介する LLM Credentials を参照してください。
サーバーを実行する
curl
バイナリを直接インストールして実行します。
curl -fsSL https://releases.rivet.dev/sandbox-agent/0.5.x/install.sh | sh
sandbox-agent server --no-token --host 0.0.0.0 --port 2468
npx
グローバルにインストールせずに実行します。
npx @sandbox-agent/[email protected] server --no-token --host 0.0.0.0 --port 2468
bunx
グローバルにインストールせずに実行します。
bunx @sandbox-agent/[email protected] server --no-token --host 0.0.0.0 --port 2468
npm i -g
グローバルにインストールしてから実行します。
npm install -g @sandbox-agent/[email protected]
sandbox-agent server --no-token --host 0.0.0.0 --port 2468
bun add -g
グローバルにインストールしてから実行します。
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(ローカル)
ローカル開発では、SandboxAgent.start() を使ってサーバーをサブプロセスとして起動、管理します。
npm install [email protected]
import { SandboxAgent } from "sandbox-agent";
const sdk = await SandboxAgent.start();
Bun(ローカル)
ローカル開発では、SandboxAgent.start() を使ってサーバーをサブプロセスとして起動、管理します。
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();
ソースからビルドする
インストール済みの 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
接続時にトークンを渡します。
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
ブラウザーからサーバーを呼び出す場合は、CORS 設定ガイドを参照してください。
エージェントをインストールする(任意)
エージェントを事前にインストールするには、以下を実行します。
sandbox-agent install-agent --all
エージェントが事前にインストールされていない場合、セッションの作成時に遅延インストールされます。
デスクトップ依存関係をインストールする(任意、Linux のみ)
/v1/desktop/* を使用する場合は、まずデスクトップランタイムパッケージをインストールしてください。
sandbox-agent install desktop --yes
その後、デスクトップのスクリーンショット API または入力 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();
Inspector でテストする
サーバーの /ui/(例:http://localhost:2468/ui/)にある Inspector UI を開くと、GUI でセッションとイベントを確認できます。

次のステップ
-
セッションの永続化 — インメモリ、Rivet Actor の状態、IndexedDB、SQLite、Postgres による永続化を設定します。
-
サンドボックスへのデプロイ — エージェントを E2B、Daytona、Docker、Vercel、または Cloudflare にデプロイします。
-
SDK の概要 — 最新の TypeScript SDK API を使用します。
リファレンスマップ
エージェント
AI
API リファレンス
- AcpEnvelope
- AcpPostQuery
- AcpServerInfo
- AcpServerListResponse
- AgentCapabilities
- AgentInfo
- AgentInstallArtifact
- AgentInstallRequest
- AgentInstallResponse
- AgentListResponse
- 認証
- デスクトップの指定領域のスクリーンショットを撮影します。
- デスクトップ全体のスクリーンショットを撮影します。
- デスクトップをクリックします。
- 長時間稼働する管理対象プロセスを作成します。
- デスクトップ録画を削除します。
- プロセスレコードを削除します。
- delete_v1_acp
- delete_v1_config_mcp
- delete_v1_config_skills
- delete_v1_fs_entry
- DesktopActionResponse
- DesktopClipboardQuery
- DesktopClipboardResponse
- DesktopClipboardWriteRequest
- DesktopDisplayInfoResponse
- DesktopErrorInfo
- DesktopKeyboardDownRequest
- DesktopKeyboardPressRequest
- DesktopKeyboardTypeRequest
- DesktopKeyboardUpRequest
- DesktopKeyModifiers
- DesktopLaunchRequest
- DesktopLaunchResponse
- DesktopMouseButton
- DesktopMouseClickRequest
- DesktopMouseDownRequest
- DesktopMouseDragRequest
- DesktopMouseMoveRequest
- DesktopMousePositionResponse
- DesktopMouseScrollRequest
- DesktopMouseUpRequest
- DesktopOpenRequest
- DesktopOpenResponse
- DesktopProcessInfo
- DesktopRecordingInfo
- DesktopRecordingListResponse
- DesktopRecordingStartRequest
- DesktopRecordingStatus
- DesktopRegionScreenshotQuery
- DesktopResolution
- DesktopScreenshotFormat
- DesktopScreenshotQuery
- DesktopStartRequest
- DesktopState
- DesktopStatusResponse
- DesktopStreamStatusResponse
- DesktopWindowInfo
- DesktopWindowListResponse
- DesktopWindowMoveRequest
- DesktopWindowResizeRequest
- デスクトップ録画をダウンロードします。
- デスクトップのマウスをドラッグします。
- ErrorType
- プロセスログを取得します。
- デスクトップウィンドウにフォーカスします。
- FsActionResponse
- FsDeleteQuery
- FsEntriesQuery
- FsEntry
- FsEntryType
- FsMoveRequest
- FsMoveResponse
- FsPathQuery
- FsStat
- FsUploadBatchQuery
- FsUploadBatchResponse
- FsWriteResponse
- IDで単一のプロセスを取得します。
- デスクトップのディスプレイ情報を取得します。
- デスクトップ録画のメタデータを取得します。
- デスクトップのランタイムステータスを取得します。
- デスクトップストリームのステータスを取得します。
- プロセスのランタイム設定を取得します。
- 現在のデスクトップのマウス位置を取得します。
- 現在フォーカスされているデスクトップウィンドウを取得します。
- get_v1_acp
- get_v1_acp_servers
- get_v1_agent
- get_v1_agents
- get_v1_config_mcp
- get_v1_config_skills
- get_v1_fs_entries
- get_v1_fs_file
- get_v1_fs_stat
- get_v1_health
- HealthResponse
- HTTP API
- デスクトップアプリケーションを起動します。
- すべての管理対象プロセスを一覧表示します。
- デスクトップ録画を一覧表示します。
- 表示中のデスクトップウィンドウを一覧表示します。
- McpCommand
- McpConfigQuery
- McpOAuthConfig
- McpOAuthConfigOrDisabled
- McpRemoteTransport
- McpServerConfig
- デスクトップウィンドウを移動します。
- デスクトップのマウスを移動します。
- デスクトップのWebRTCシグナリングセッションを開きます。
- 既定のハンドラーでファイルまたはURLを開きます。
- 対話型WebSocketターミナルセッションを開きます。
- post_v1_acp
- post_v1_agent_install
- post_v1_fs_mkdir
- post_v1_fs_move
- post_v1_fs_upload_batch
- デスクトップのキーボードショートカットを押します。
- デスクトップのキーボードキーを押したままにします。
- デスクトップのマウスボタンを押したままにします。
- ProblemDetails
- ProcessConfig
- ProcessCreateRequest
- ProcessInfo
- ProcessInputRequest
- ProcessInputResponse
- ProcessListQuery
- ProcessListResponse
- ProcessLogEntry
- ProcessLogsQuery
- ProcessLogsResponse
- ProcessLogsStream
- ProcessOwner
- ProcessRunRequest
- ProcessRunResponse
- ProcessSignalQuery
- ProcessState
- ProcessTerminalResizeRequest
- ProcessTerminalResizeResponse
- put_v1_config_mcp
- put_v1_config_skills
- put_v1_fs_file
- デスクトップのクリップボードを読み取ります。
- デスクトップのキーボードキーを離します。
- デスクトップのマウスボタンを離します。
- デスクトップウィンドウのサイズを変更します。
- プロセスターミナルのサイズを変更します。
- 単発コマンドを実行します。
- スキーマ
- デスクトップのマウスホイールをスクロールします。
- プロセスにSIGKILLを送信します。
- プロセスにSIGTERMを送信します。
- ServerStatus
- ServerStatusInfo
- SkillsConfig
- SkillsConfigQuery
- SkillSource
- デスクトップ録画を開始します。
- デスクトップストリーミングを開始します。
- プライベートデスクトップランタイムを起動します。
- デスクトップ録画を停止します。
- デスクトップストリーミングを停止します。
- プライベートデスクトップランタイムを停止します。
- デスクトップのキーボードテキストを入力します。
- プロセスのランタイム設定を更新します。
- v1
- プロセスに入力を書き込みます。
- デスクトップのクリップボードに書き込みます。
Deploy
General
- Agent Sessions
- Architecture
- Attachments
- CLI Reference
- Common Software
- Computer Use
- CORS Configuration
- Custom Tools
- Daemon
- File System
- Inspector
- LLM Credentials
- Manage Sessions
- MCP
- Multiplayer
- Observability
- OpenCode Compatibility
- Orchestration Architecture
- Persisting Sessions
- Processes
- Quickstart
- React Components
- Sandbox Agent
- SDK Overview
- Security
- Session Restoration
- Skills
- Telemetry
- Troubleshooting