mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 13:03:46 +00:00
* remove website .astro * fix default origin * docs: comprehensive documentation overhaul - Add quickstart with multi-platform examples (E2B, Daytona, Docker, local) - Add environment variables setup with platform-specific tabs - Add Python SDK page (coming soon) - Add local deployment guide - Update E2B/Daytona/Docker guides with TypeScript examples - Configure OpenAPI auto-generation for API reference - Add CORS configuration guide - Update manage-sessions with Rivet Actors examples - Fix SDK method names and URLs throughout - Add icons to main documentation pages - Remove outdated universal-api and http-api pages * docs: add universal schema and agent compatibility docs - Create universal-schema.mdx with full event/item schema reference - Create agent-compatibility.mdx mirroring README feature matrix - Rename glossary.md to universal-schema.mdx - Update CLAUDE.md with sync requirements for new docs - Add links in README to building-chat-ui, manage-sessions, universal-schema - Fix CLI docs link (rivet.dev -> sandboxagent.dev) * docs: add inspector page and daytona network limits warning
90 lines
2.5 KiB
Text
90 lines
2.5 KiB
Text
---
|
|
title: "Daytona"
|
|
description: "Run the daemon in a Daytona workspace."
|
|
---
|
|
|
|
<Note>
|
|
Daytona has [network egress limits](https://www.daytona.io/docs/en/network-limits/) on lower tiers. OpenAI and Anthropic APIs are whitelisted on all tiers, but other external services may be restricted on Tier 1 & 2.
|
|
</Note>
|
|
|
|
## Prerequisites
|
|
|
|
- `DAYTONA_API_KEY` environment variable
|
|
- `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` for the coding agents
|
|
|
|
## TypeScript Example
|
|
|
|
```typescript
|
|
import { Daytona, Image } from "@daytonaio/sdk";
|
|
import { SandboxAgent } from "sandbox-agent";
|
|
|
|
const daytona = new Daytona();
|
|
|
|
// Pass API keys to the sandbox
|
|
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 sandbox = await daytona.create({ envVars });
|
|
|
|
// Install sandbox-agent
|
|
await sandbox.process.executeCommand(
|
|
"curl -fsSL https://releases.rivet.dev/sandbox-agent/latest/install.sh | sh"
|
|
);
|
|
|
|
// Start the server in the background
|
|
await sandbox.process.executeCommand(
|
|
"nohup sandbox-agent server --no-token --host 0.0.0.0 --port 3000 >/tmp/sandbox-agent.log 2>&1 &"
|
|
);
|
|
|
|
// Wait for server to be ready
|
|
await new Promise((r) => setTimeout(r, 2000));
|
|
|
|
// Get the public URL
|
|
const baseUrl = (await sandbox.getSignedPreviewUrl(3000, 4 * 60 * 60)).url;
|
|
|
|
// Connect and use the SDK
|
|
const client = await SandboxAgent.connect({ baseUrl });
|
|
|
|
await client.createSession("my-session", {
|
|
agent: "claude",
|
|
permissionMode: "default",
|
|
});
|
|
|
|
// Cleanup when done
|
|
await sandbox.delete();
|
|
```
|
|
|
|
## Using Snapshots for Faster Startup
|
|
|
|
For production, use snapshots with pre-installed binaries:
|
|
|
|
```typescript
|
|
import { Daytona, Image } from "@daytonaio/sdk";
|
|
|
|
const daytona = new Daytona();
|
|
const SNAPSHOT = "sandbox-agent-ready";
|
|
|
|
// Create snapshot once (takes 2-3 minutes)
|
|
const hasSnapshot = await daytona.snapshot.get(SNAPSHOT).then(() => true, () => false);
|
|
|
|
if (!hasSnapshot) {
|
|
await daytona.snapshot.create({
|
|
name: SNAPSHOT,
|
|
image: Image.base("ubuntu:22.04").runCommands(
|
|
"apt-get update && apt-get install -y curl ca-certificates",
|
|
"curl -fsSL https://releases.rivet.dev/sandbox-agent/latest/install.sh | sh",
|
|
"sandbox-agent install-agent claude",
|
|
"sandbox-agent install-agent codex",
|
|
),
|
|
});
|
|
}
|
|
|
|
// Now sandboxes start instantly
|
|
const sandbox = await daytona.create({
|
|
snapshot: SNAPSHOT,
|
|
envVars,
|
|
});
|
|
```
|
|
|
|
See [Daytona Snapshots](https://daytona.io/docs/snapshots) for details.
|