feat(providers): add base image support and improve forward compatibility

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>
This commit is contained in:
Nathan Flurry 2026-03-17 15:25:21 -07:00
parent ffb9f1082b
commit 4e76038a0d
10 changed files with 242 additions and 34 deletions

View file

@ -17,8 +17,10 @@ export async function setupE2BSandboxAgent(): Promise<{
token?: string;
cleanup: () => Promise<void>;
}> {
const template = process.env.E2B_TEMPLATE;
const client = await SandboxAgent.start({
sandbox: e2b({
template,
create: { envs: collectEnvVars() },
}),
});

View file

@ -5,10 +5,11 @@ import { detectAgent } from "@sandbox-agent/example-shared";
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 client = await SandboxAgent.start({
// ✨ NEW ✨
sandbox: e2b({ create: { envs } }),
sandbox: e2b({ template, create: { envs } }),
});
const session = await client.createSession({