Skip to content

Sandbox platforms

@alchemy.run/ai has an AI.Sandboxes Layer for each sandbox platform, as its own import. Each takes the image sandboxes start from. The platforms differ in two ways that matter to a harness: how a sandbox is found again by its key, and what stopping one keeps.

Each platform’s package is an optional peer. Install the one you use, add its provider to the Stack, and sign in to it with your profile.

Terminal window
pnpm add https://pkg.alchemy.run/@alchemy.run/boat/pr:3743:56b4873
src/Sandbox.ts
import * as AIBoat from "@alchemy.run/ai/Boat";
import * as Boat from "@alchemy.run/boat";
export const Sandbox = AIBoat.Sandboxes(
Boat.Snapshot("Base", { run: ["npm install --global pnpm"] }),
{ type: "small", autoStop: "10 minutes" },
);

Boat finds a sandbox by a key label. suspend stops it and keeps its disk, and Boat stops one by itself after autoStop. New sandboxes get none of your account’s environments. See Boat sandboxes.

Terminal window
pnpm add https://pkg.alchemy.run/@alchemy.run/e2b/pr:3743:56b4873
src/Sandbox.ts
import * as AIE2B from "@alchemy.run/ai/E2B";
import * as E2B from "@alchemy.run/e2b";
export const Sandbox = AIE2B.Sandboxes(E2B.Template("Base", { image: "node:22-bookworm" }), {
timeout: 600,
});

E2B finds a sandbox by its key metadata. suspend pauses it, keeping its memory and files. E2B kills a sandbox that runs for timeout seconds without being used. See E2B sandboxes.

Terminal window
pnpm add https://pkg.alchemy.run/@alchemy.run/daytona/pr:3743:56b4873
src/Sandbox.ts
import * as AIDaytona from "@alchemy.run/ai/Daytona";
import * as Daytona from "@alchemy.run/daytona";
export const Sandbox = AIDaytona.Sandboxes(
Daytona.Snapshot("Base", { image: "node:22-bookworm", cpu: 1, memory: 1, disk: 3 }),
{ autoStopInterval: 15, autoDeleteInterval: 24 * 60 },
);

Daytona names a sandbox by its key. suspend stops it and keeps its disk. Daytona stops a sandbox idle for autoStopInterval minutes, and deletes one that has been stopped for autoDeleteInterval minutes. See Daytona sandboxes.

Terminal window
pnpm add https://pkg.alchemy.run/@alchemy.run/modal/pr:3743:56b4873
src/Sandbox.ts
import * as AIModal from "@alchemy.run/ai/Modal";
import * as Modal from "@alchemy.run/modal";
import * as Effect from "effect/Effect";
export const Sandbox = AIModal.Sandboxes(
Effect.gen(function* () {
const app = yield* Modal.App("App", {});
return yield* Modal.Image("Base", { app, image: "node:22-bookworm" });
}),
{ idleTimeout: "10 minutes" },
);

Modal names a sandbox by its key. It has no pause, so suspend does nothing: Modal ends a sandbox idle for idleTimeout, and the next use creates an empty one. See Modal sandboxes.

Terminal window
pnpm add https://pkg.alchemy.run/@alchemy.run/archil/pr:3743:56b4873
src/Sandbox.ts
import * as AIArchil from "@alchemy.run/ai/Archil";
import * as Archil from "@alchemy.run/archil";
export const Sandbox = AIArchil.Sandboxes(Archil.Image("Base", { image: "node:22-bookworm" }));

Archil names a sandbox by its key. suspend pauses a running sandbox, keeping its memory and files. Archil also pauses a sandbox that is idle, and resumes it on the next command. See Archil sandboxes.

Each Layer takes the image as a declaration or as an Effect that returns one. Use an Effect when the image is built from another resource, such as a repository to clone:

src/Sandbox.ts
import * as AIBoat from "@alchemy.run/ai/Boat";
import * as Boat from "@alchemy.run/boat";
import * as Output from "alchemy/Output";
import * as Effect from "effect/Effect";
import { Repo } from "./Repo.ts";
export const Sandbox = AIBoat.Sandboxes(
Effect.gen(function* () {
const repo = yield* Repo;
return yield* Boat.Snapshot("Checkout", {
run: [Output.interpolate`git clone ${repo.cloneUrl} ~/repo`],
});
}),
);

Pi installs its daemon in each new sandbox. The image needs sh, curl, tar, sha512sum, base64, dd and mkfifo, and the sandbox needs to reach registry.npmjs.org for that install. OpenCode installs nothing: its coding tools run bash, grep and base64. node:22-bookworm has them all, and so does Boat’s own image.

A platform that isn’t here, or a Layer that should work differently, is a Layer of your own. See Build your own.