Rivet agentOSBeta
In-process VMs from Rivet agentOS (embedded mode). No credentials, no Docker daemon, no cloud account. Streaming exec with stdin and signals, a PTY, a stateful code interpreter for Python, JavaScript and TypeScript, and filesystem snapshots, via @rivet-dev/agentos-core.
Use the agentOS adapter when you want a sandbox without any infrastructure. AgentOs.create() boots a VM inside your Node process in about a second: a WebAssembly + V8 userland on a lightweight kernel. It is not a real Linux kernel, so it suits shell scripts, Node and Python code, and agent tool calls rather than arbitrary native binaries.
Installation
@rivet-dev/agentos-core is an optional peer dependency of sbox-sdk, imported lazily the first time you create a sandbox.
pnpm add sbox-sdk @rivet-dev/agentos-core| Requirement | Value |
|---|---|
| agentOS | 0.4.x (@rivet-dev/agentos-core) |
| Node | >= 22 |
| Platform | macOS or Linux (glibc), x64 or arm64. Windows isn't supported. |
Rivet ships native sidecar binaries only for those platforms. In agentOS 0.4.x the embedded runtime lives in @rivet-dev/agentos-core; @rivet-dev/agentos 0.4.x is only the client for hosted actors. agentOS 0.5 is expected to rename the embedded package to @rivet-dev/agentos.
No credentials are needed.
Usage
import { createSandboxClient } from "sbox-sdk";
import { agentos } from "sbox-sdk/agentos";
const client = createSandboxClient({ provider: agentos() });
const sandbox = await client.create({
env: { NODE_ENV: "development" },
network: { mode: "allow-all" }, // the default blocks most outbound traffic
});
const res = await sandbox.commands.run("echo $HOME && node -v", {
cwd: "/tmp",
});
console.log(res.stdout, res.exitCode);
const ctx = await sandbox.code!.createContext({ language: "python" });
await sandbox.code!.runCode("x = 41", { context: ctx });
const out = await sandbox.code!.runCode("print(x + 1)", { context: ctx });
const snap = await sandbox.snapshots!.create({ name: "after-setup" });
const copy = await client.create({ fromSnapshot: snap });
await client.dispose(); // disposes every VM this provider createdGuest environment
| Item | Value |
|---|---|
| User | agentos (uid 1000), HOME=/home/agentos |
| cwd | /workspace by default; /tmp is writable |
| Tools | bash 5.2, sh, coreutils, grep, sed, awk, find, tar, gzip, base64, node, npm, npx, python/python3 |
| Not here | git (add software: [{ registry: "git" }]), curl, wget, apt; arbitrary native binaries can't run |
Options
Prop
Type
| Option | Description |
|---|---|
software | Extra agentOS software: registry names like { registry: "git" }, local .aospkg paths, or descriptors. |
defaultSoftware | Install the default set (sh/bash, coreutils and standard CLI tools). Defaults to true. |
mounts | agentOS mount configs, for example hostDirMount(...) or nodeModulesMount(...) from @rivet-dev/agentos-core. |
limits | agentOS runtime limits. |
permissions | Base agentOS permission tree. spec.network replaces its network scope. |
vm | Any other AgentOs.create() option, for example sidecar, database or rootFilesystem. |
snapshotMaxBytes | Size cap for one filesystem snapshot. Defaults to 256 MiB. |
Commands
Commands run as sh -c in the VM. cwd and env are passed natively per command, exit codes are real, stdout and stderr stream separately, and stdin and signals work. timeoutMs is enforced by the adapter: it kills the process and rejects with Timeout.
env and env-mode secrets (inline values) from the spec are applied to every command, spawn and terminal.
Code interpreter
sandbox.code.runCode() supports python, javascript and typescript through agentOS language runtimes. code.createContext() returns a persistent agentOS execution context, so globals survive between calls. JavaScript contexts run as CommonJS, so top-level var and function bindings persist.
PTY
sandbox.pty.create() opens an agentOS terminal (vm.terminal) running bash by default. The guest has no termios: stty reports that terminal control is unsupported. resize() is forwarded, but programs may not see the new size.
Network
With no network in the spec, agentOS's default applies: all outbound traffic is blocked except agentOS's own service allowlist (model-provider endpoints). Pass network: { mode: "allow-all" } to open it.
spec.network is honored at creation and mapped onto agentOS permission rules:
| Policy | agentOS permissions |
|---|---|
allow-all | allow; deny.domains become deny rules |
block-all | deny |
allow-list | default deny, plus dns://<domain> and tcp://<domain>:* allow rules |
| CIDRs | rejected with Validation |
inject | rejected with Validation |
Wildcards such as *.github.com match subdomains, not the apex. Loopback and listening stay allowed. The egressControl capability is still unsupported, because agentOS 0.4 can't change a running VM's permissions, so sandbox.network.setEgressPolicy() isn't available.
Ports
There are no previews. Servers in the guest listen on VM-local ports that are never bound on the host, and agentOS has no public URLs. Reach them through the escape hatch. agentOS routes host requests only to a listener in a process it spawned directly, so start the server with raw().process.spawn() rather than commands.spawn() (which runs it as a child of sh -c):
const vm = sandbox.raw();
const server = await vm.process.spawn("node", [
"-e",
"require('http').createServer((q, s) => s.end('hi')).listen(3000)",
]);
const res = await vm.fetch(3000, new Request("http://vm/"));
// or: await vm.network.httpRequest({ port: 3000, path: "/" });
await vm.process.kill(server.pid);Other processes in the guest can reach any listener over loopback (http://127.0.0.1:3000).
Snapshots and forks
snapshots.create() exports the VM's filesystem (vm.filesystem.export()) and holds it in memory in the provider instance. create({ fromSnapshot }) boots a new VM with the snapshot as its root lower layer. There is no in-place restore and no memory snapshot. fork({ count }) is emulated as one snapshot plus count boots.
Lifecycle
VMs live only as long as your Node process and the provider instance. list(), connect() and getOrCreate() see only VMs created by this provider instance, which is why list is emulated. There is no pause, stop or TTL. client.dispose() disposes every VM the provider created.
Capabilities
| Capability | Level | Notes |
|---|---|---|
background / streaming / killProcess | native | sh -c in the VM; signals delivered natively |
stdin | native | |
pty | native | agentOS terminals; no termios |
filesUpload | native | |
codeInterpreter / statefulKernel | native | python, javascript, typescript; persistent contexts |
snapshot | native | filesystem only, held in memory by the provider |
fork | emulated | snapshot + N boots |
list | emulated | VMs from this provider instance only |
filesWatch | unsupported | agentOS has no inotify |
exposePort / privatePreview / proxiedFetch | unsupported | use sandbox.raw().fetch(port, request) |
egressControl | unsupported | policy is fixed at creation via spec.network |
ssh | unsupported | |
volumes / templateBuild | unsupported | use the mounts and software options |
stop / pause / setTimeout | unsupported | VMs end with the process or destroy() |
gpu / region / secretsVault / metrics | unsupported |
Flags: exitCodeNative: true, perCommandEnvCwd: true, preservesDiskOnStop: false, preservesMemoryOnPause: false, previewModel: "none", idempotency: "exact".
Create contract
- Idempotency is
exact. VMs live in the provider instance's own registry, and a create is recorded under its idempotency key as soon as it starts. A retry with the same key gets the same VM, even when it races the first attempt or the create was named. A failedAgentOs.create()disposes its VM before rejecting, so a retry never leaves one behind. Keys don't outlive the provider instance, and neither do VMs. - Only disk is mapped.
resources.diskMBisapproximate: it becomes the runtime'smaxFilesystemBytescap, not a provisioned disk. agentOS has no VM sizes, sovcpus,memoryMB,shmMBandgpu/gpuCountarerejected. Tune runtime caps (cpuCount, WASM memory, V8 heap) with thelimitsoption instead. - No TTL or idle policy.
lifecycle.idleTimeoutMsandlifecycle.maxAgeMs(and the deprecatedttlMs) arerejected. VMs end withdestroy(),client.dispose()or the process. - Limits.
maxPortsis0: guest servers stay VM-local, so anyspec.portsthrowsValidation. Metadata is held in memory with no cap. - Sizes. None are declared.
spec.sizeexpands through the default ladder, which setsvcpusandmemoryMB, so every preset throwsValidation. Useresources.diskMBalone.
No field is ignored, so strictSpec changes nothing here.
How the spec maps
| sbox | agentOS |
|---|---|
fromSnapshot | snapshot as the root lower layer |
env, env-mode secrets | env on every command, spawn and terminal |
network | permission rules (see Network) |
resources.diskMB | limits.resources.maxFilesystemBytes |
template / templateRef, volumes, region, ports, lifecycle / TTL, other resources, gpu | rejected with Validation |
exec user, egress secrets / inject | rejected with Validation |
Live tests
The live conformance run needs no environment variables. It runs when Node >= 22 is used on a supported platform:
SBOX_LIVE=agentos pnpm --filter sbox-sdk test:liveKnown limitations
- Not a real Linux kernel. Arbitrary native binaries can't run, and there is no package manager.
- No ports or previews. See Ports.
- Egress can't change after creation. Set
networkin the spec. - No in-place snapshot restore. Boot a new VM with
fromSnapshot. Snapshots live in the provider instance's memory. - VMs don't outlive the process. No pause, stop, TTL or reconnecting from another process.
- No file watching, GPUs, SSH or metrics.
- Hosted-actor mode isn't covered yet.
createAgentOsClient()from@rivet-dev/agentosis a planned follow-up.
Docker
Local containers through the Docker Engine API, with no npm dependency. Works with OrbStack, Docker Desktop, Colima, Rancher Desktop and Podman. Streaming exec with stdin, a PTY, pause/resume, commit-based snapshots and forks, Dockerfile template builds, volumes and published ports.
Archil
Persistent Firecracker microVMs with memory-preserving pause, forks, Archil disk mounts, native binary files, PTY and header-authenticated private previews.