mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 08:03:46 +00:00
103 lines
2.7 KiB
Text
103 lines
2.7 KiB
Text
---
|
|
title: "Quickstart"
|
|
description: "Start the server and send your first message."
|
|
---
|
|
|
|
## 1. Run the server
|
|
|
|
Use the installed binary, or `cargo run` in development.
|
|
|
|
```bash
|
|
sandbox-agent server --token "$SANDBOX_TOKEN" --host 127.0.0.1 --port 2468
|
|
```
|
|
|
|
If you want to run without auth (local dev only):
|
|
|
|
```bash
|
|
sandbox-agent server --no-token --host 127.0.0.1 --port 2468
|
|
```
|
|
|
|
If you're running from source instead of the installed CLI:
|
|
|
|
```bash
|
|
cargo run -p sandbox-agent -- server --token "$SANDBOX_TOKEN" --host 127.0.0.1 --port 2468
|
|
```
|
|
|
|
### CORS (frontend usage)
|
|
|
|
If you are calling the server from a browser, enable CORS explicitly:
|
|
|
|
```bash
|
|
sandbox-agent server \
|
|
--token "$SANDBOX_TOKEN" \
|
|
--cors-allow-origin "http://localhost:5173" \
|
|
--cors-allow-method "GET" \
|
|
--cors-allow-method "POST" \
|
|
--cors-allow-header "Authorization" \
|
|
--cors-allow-header "Content-Type" \
|
|
--cors-allow-credentials
|
|
```
|
|
|
|
## 2. Install agents (optional)
|
|
|
|
Agents install lazily on first use. To preinstall everything up front:
|
|
|
|
```bash
|
|
sandbox-agent install-agent claude
|
|
sandbox-agent install-agent codex
|
|
sandbox-agent install-agent opencode
|
|
sandbox-agent install-agent amp
|
|
```
|
|
|
|
## 3. Create a session
|
|
|
|
```bash
|
|
curl -X POST "http://127.0.0.1:2468/v1/sessions/my-session" \
|
|
-H "Authorization: Bearer $SANDBOX_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"agent":"claude","agentMode":"build","permissionMode":"default"}'
|
|
```
|
|
|
|
## 4. Send a message
|
|
|
|
```bash
|
|
curl -X POST "http://127.0.0.1:2468/v1/sessions/my-session/messages" \
|
|
-H "Authorization: Bearer $SANDBOX_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"message":"Summarize the repository and suggest next steps."}'
|
|
```
|
|
|
|
## 5. Read events
|
|
|
|
```bash
|
|
curl "http://127.0.0.1:2468/v1/sessions/my-session/events?offset=0&limit=50" \
|
|
-H "Authorization: Bearer $SANDBOX_TOKEN"
|
|
```
|
|
|
|
For streaming output, use SSE:
|
|
|
|
```bash
|
|
curl "http://127.0.0.1:2468/v1/sessions/my-session/events/sse?offset=0" \
|
|
-H "Authorization: Bearer $SANDBOX_TOKEN"
|
|
```
|
|
|
|
For a single-turn stream (post a message and get one streamed response):
|
|
|
|
```bash
|
|
curl -N -X POST "http://127.0.0.1:2468/v1/sessions/my-session/messages/stream" \
|
|
-H "Authorization: Bearer $SANDBOX_TOKEN" \
|
|
-H "content-type: application/json" \
|
|
-d '{"message":"Hello"}'
|
|
```
|
|
|
|
## 6. CLI shortcuts
|
|
|
|
The `sandbox-agent api` subcommand mirrors the HTTP API:
|
|
|
|
```bash
|
|
sandbox-agent api sessions create my-session --agent claude --endpoint http://127.0.0.1:2468 --token "$SANDBOX_TOKEN"
|
|
|
|
sandbox-agent api sessions send-message my-session --message "Hello" --endpoint http://127.0.0.1:2468 --token "$SANDBOX_TOKEN"
|
|
|
|
sandbox-agent api sessions send-message-stream my-session --message "Hello" --endpoint http://127.0.0.1:2468 --token "$SANDBOX_TOKEN"
|
|
```
|