mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 04:03:31 +00:00
Add support for configuring base images across all compute providers: - E2B: Accept optional `template` parameter to select custom templates - Modal: Accept optional `image` parameter (string or Image object) for base images - ComputeSDK: Expand `create` override to accept full CreateSandboxOptions payload (image, templateId, etc.) - Daytona: Improve type safety for `image` option Improve forward compatibility by making all `create` overrides accept full Partial SDK types, allowing any new provider fields to flow through without code changes. Fix Modal provider bug where `encryptedPorts` was hardcoded and would clobber user-provided values; now merges additional ports instead. Update docs and examples to demonstrate base image configuration for E2B, Modal, and ComputeSDK. Add comprehensive provider lifecycle tests for Modal and ComputeSDK, including template and image passthrough verification. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
52 lines
1.7 KiB
Text
52 lines
1.7 KiB
Text
---
|
|
title: "E2B"
|
|
description: "Deploy Sandbox Agent inside an E2B sandbox."
|
|
---
|
|
|
|
## Prerequisites
|
|
|
|
- `E2B_API_KEY`
|
|
- `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`
|
|
|
|
## TypeScript example
|
|
|
|
```bash
|
|
npm install sandbox-agent@0.3.x @e2b/code-interpreter
|
|
```
|
|
|
|
```typescript
|
|
import { SandboxAgent } from "sandbox-agent";
|
|
import { e2b } from "sandbox-agent/e2b";
|
|
|
|
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 template = process.env.E2B_TEMPLATE;
|
|
|
|
const sdk = await SandboxAgent.start({
|
|
sandbox: e2b({
|
|
template,
|
|
create: { envs },
|
|
}),
|
|
});
|
|
|
|
try {
|
|
const session = await sdk.createSession({ agent: "claude" });
|
|
const response = await session.prompt([
|
|
{ type: "text", text: "Summarize this repository" },
|
|
]);
|
|
console.log(response.stopReason);
|
|
} finally {
|
|
await sdk.destroySandbox();
|
|
}
|
|
```
|
|
|
|
The `e2b` provider handles sandbox creation, Sandbox Agent installation, agent setup, and server startup automatically. Sandboxes pause by default instead of being deleted, and reconnecting with the same `sandboxId` resumes them automatically.
|
|
|
|
Pass `template` when you want to start from a custom E2B template alias or template ID. E2B base-image selection happens when you build the template, then `sandbox-agent/e2b` uses that template at sandbox creation time.
|
|
|
|
## Faster cold starts
|
|
|
|
For faster startup, create a custom E2B template with Sandbox Agent and target agents pre-installed.
|
|
Build System 2.0 also lets you choose the template's base image in code.
|
|
See [E2B Custom Templates](https://e2b.dev/docs/sandbox-template) and [E2B Base Images](https://e2b.dev/docs/template/base-image).
|