@rivet-dev/agentos-core 0.0.0-agentos-dylib-plugin.473700e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +204 -0
- package/dist/agent-os.d.ts +560 -0
- package/dist/agent-os.js +3624 -0
- package/dist/agent-session-types.d.ts +67 -0
- package/dist/agent-session-types.js +1 -0
- package/dist/agents.d.ts +63 -0
- package/dist/agents.js +42 -0
- package/dist/base-filesystem.d.ts +34 -0
- package/dist/base-filesystem.js +173 -0
- package/dist/cron/cron-manager.d.ts +22 -0
- package/dist/cron/cron-manager.js +160 -0
- package/dist/cron/index.d.ts +5 -0
- package/dist/cron/index.js +3 -0
- package/dist/cron/parse-schedule.d.ts +25 -0
- package/dist/cron/parse-schedule.js +66 -0
- package/dist/cron/schedule-driver.d.ts +19 -0
- package/dist/cron/schedule-driver.js +1 -0
- package/dist/cron/timer-driver.d.ts +17 -0
- package/dist/cron/timer-driver.js +61 -0
- package/dist/cron/types.d.ts +55 -0
- package/dist/cron/types.js +1 -0
- package/dist/filesystem-snapshot.d.ts +14 -0
- package/dist/filesystem-snapshot.js +105 -0
- package/dist/host-dir-mount.d.ts +38 -0
- package/dist/host-dir-mount.js +34 -0
- package/dist/host-tools-zod.d.ts +7 -0
- package/dist/host-tools-zod.js +243 -0
- package/dist/host-tools.d.ts +45 -0
- package/dist/host-tools.js +26 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/js-bridge.d.ts +3 -0
- package/dist/js-bridge.js +2 -0
- package/dist/json-rpc.d.ts +50 -0
- package/dist/json-rpc.js +22 -0
- package/dist/layers.d.ts +51 -0
- package/dist/layers.js +185 -0
- package/dist/overlay-filesystem.d.ts +19 -0
- package/dist/overlay-filesystem.js +645 -0
- package/dist/packages.d.ts +127 -0
- package/dist/packages.js +335 -0
- package/dist/runtime-compat.d.ts +471 -0
- package/dist/runtime-compat.js +2009 -0
- package/dist/runtime.d.ts +336 -0
- package/dist/runtime.js +1 -0
- package/dist/sidecar/agent-os-protocol.d.ts +219 -0
- package/dist/sidecar/agent-os-protocol.js +594 -0
- package/dist/sidecar/binary.d.ts +9 -0
- package/dist/sidecar/binary.js +30 -0
- package/dist/sidecar/cargo.d.ts +2 -0
- package/dist/sidecar/cargo.js +142 -0
- package/dist/sidecar/native-process-client.d.ts +2 -0
- package/dist/sidecar/native-process-client.js +1 -0
- package/dist/sidecar/permissions.d.ts +3 -0
- package/dist/sidecar/permissions.js +54 -0
- package/dist/sidecar/process.d.ts +6 -0
- package/dist/sidecar/process.js +8 -0
- package/dist/sidecar/rpc-client.d.ts +244 -0
- package/dist/sidecar/rpc-client.js +2028 -0
- package/dist/test/docker.d.ts +133 -0
- package/dist/test/docker.js +336 -0
- package/dist/test/file-system.d.ts +39 -0
- package/dist/test/file-system.js +562 -0
- package/dist/test/mock-s3.d.ts +42 -0
- package/dist/test/mock-s3.js +292 -0
- package/dist/test/runtime.d.ts +11 -0
- package/dist/test/runtime.js +9 -0
- package/dist/test/sandbox-agent.d.ts +9 -0
- package/dist/test/sandbox-agent.js +395 -0
- package/dist/test/terminal-harness.d.ts +27 -0
- package/dist/test/terminal-harness.js +122 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.js +1 -0
- package/fixtures/AGENTOS_SYSTEM_PROMPT.md +21 -0
- package/package.json +111 -0
package/README.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# @rivet-dev/agent-os-core
|
|
2
|
+
|
|
3
|
+
A high-level SDK for running coding agents in isolated VMs. agentOS manages the full lifecycle of virtual machines -- from filesystem setup and process management to launching AI agents via the Agent Communication Protocol (ACP).
|
|
4
|
+
|
|
5
|
+
Agents run inside isolated VMs with their own filesystem, process table, and network stack. The host only communicates through well-defined APIs, keeping agent execution fully contained.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **VM lifecycle** — create, configure, and dispose isolated virtual machines
|
|
10
|
+
- **Sidecar placement** — reuse the default shared sidecar or inject an explicit sidecar handle
|
|
11
|
+
- **Agent sessions (ACP)** — launch coding agents (Pi, Pi CLI, OpenCode, Claude) via JSON-RPC over stdio
|
|
12
|
+
- **Filesystem operations** — read, write, mkdir, stat, move, delete, recursive listing, batch read/write
|
|
13
|
+
- **Process management** — spawn, exec, stop, kill processes; inspect process trees across all runtimes
|
|
14
|
+
- **Agent registry** — discover available agents and their installation status
|
|
15
|
+
- **Networking** — reach services running inside the VM via `fetch()`
|
|
16
|
+
- **Shell access** — open interactive shells with PTY support
|
|
17
|
+
- **Mount backends** — memory, native host directory mounts, S3, overlay (copy-on-write), or custom VirtualFileSystem
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @rivet-dev/agent-os-core
|
|
23
|
+
# Install an agent adapter + its underlying agent
|
|
24
|
+
npm install @rivet-dev/agent-os-pi @mariozechner/pi-coding-agent
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { AgentOs } from "@rivet-dev/agent-os-core";
|
|
29
|
+
|
|
30
|
+
// 1. Create a VM
|
|
31
|
+
const vm = await AgentOs.create();
|
|
32
|
+
|
|
33
|
+
// 2. Create an agent session
|
|
34
|
+
const { sessionId } = await vm.createSession("pi");
|
|
35
|
+
|
|
36
|
+
// 3. Send a prompt
|
|
37
|
+
const response = await vm.prompt(sessionId, "Write a hello world in TypeScript");
|
|
38
|
+
|
|
39
|
+
// 4. Clean up
|
|
40
|
+
vm.closeSession(sessionId);
|
|
41
|
+
await vm.dispose();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API Reference
|
|
45
|
+
|
|
46
|
+
### Lifecycle
|
|
47
|
+
|
|
48
|
+
| Method | Signature | Description |
|
|
49
|
+
|--------|-----------|-------------|
|
|
50
|
+
| `create` | `static create(options?: AgentOsOptions): Promise<AgentOs>` | Create and boot a new VM |
|
|
51
|
+
| `getSharedSidecar` | `static getSharedSidecar(options?: AgentOsSharedSidecarOptions): Promise<AgentOsSidecar>` | Get or create a shared sidecar handle for a pool |
|
|
52
|
+
| `createSidecar` | `static createSidecar(options?: AgentOsCreateSidecarOptions): Promise<AgentOsSidecar>` | Create an explicit sidecar handle |
|
|
53
|
+
| `dispose` | `dispose(): Promise<void>` | Shut down the VM and all sessions |
|
|
54
|
+
|
|
55
|
+
### Sidecars
|
|
56
|
+
|
|
57
|
+
| Surface | Signature | Description |
|
|
58
|
+
|--------|-----------|-------------|
|
|
59
|
+
| `sidecar` | `AgentOsSidecar` | Sidecar handle backing the VM |
|
|
60
|
+
| `describe` | `sidecar.describe(): AgentOsSidecarDescription` | Inspect sidecar placement, state, and active VM count |
|
|
61
|
+
| `dispose` | `sidecar.dispose(): Promise<void>` | Dispose the sidecar handle and any active VMs leased from it |
|
|
62
|
+
|
|
63
|
+
### Filesystem
|
|
64
|
+
|
|
65
|
+
| Method | Signature | Description |
|
|
66
|
+
|--------|-----------|-------------|
|
|
67
|
+
| `readFile` | `readFile(path: string): Promise<Uint8Array>` | Read a file |
|
|
68
|
+
| `writeFile` | `writeFile(path: string, content: string \| Uint8Array): Promise<void>` | Write a file |
|
|
69
|
+
| `readFiles` | `readFiles(paths: string[]): Promise<BatchReadResult[]>` | Batch read multiple files |
|
|
70
|
+
| `writeFiles` | `writeFiles(entries: BatchWriteEntry[]): Promise<BatchWriteResult[]>` | Batch write multiple files (creates parent dirs) |
|
|
71
|
+
| `mkdir` | `mkdir(path: string): Promise<void>` | Create a directory |
|
|
72
|
+
| `readdir` | `readdir(path: string): Promise<string[]>` | List directory entries |
|
|
73
|
+
| `readdirRecursive` | `readdirRecursive(path: string, options?: ReaddirRecursiveOptions): Promise<DirEntry[]>` | Recursively list directory contents with metadata |
|
|
74
|
+
| `stat` | `stat(path: string): Promise<VirtualStat>` | Get file/directory metadata |
|
|
75
|
+
| `exists` | `exists(path: string): Promise<boolean>` | Check if a path exists |
|
|
76
|
+
| `move` | `move(from: string, to: string): Promise<void>` | Rename/move a file or directory |
|
|
77
|
+
| `delete` | `delete(path: string, options?: { recursive?: boolean }): Promise<void>` | Delete a file or directory |
|
|
78
|
+
| `mountFs` | `mountFs(path: string, driver: VirtualFileSystem, options?: { readOnly?: boolean }): void` | Mount a filesystem driver at the given path |
|
|
79
|
+
| `unmountFs` | `unmountFs(path: string): void` | Unmount a filesystem |
|
|
80
|
+
|
|
81
|
+
### Process Management
|
|
82
|
+
|
|
83
|
+
| Method | Signature | Description |
|
|
84
|
+
|--------|-----------|-------------|
|
|
85
|
+
| `exec` | `exec(command: string, options?: ExecOptions): Promise<ExecResult>` | Execute a shell command and wait for completion |
|
|
86
|
+
| `spawn` | `spawn(command: string, args: string[], options?: SpawnOptions): { pid: number }` | Spawn a long-running process |
|
|
87
|
+
| `listProcesses` | `listProcesses(): SpawnedProcessInfo[]` | List processes started via `spawn()` |
|
|
88
|
+
| `allProcesses` | `allProcesses(): ProcessInfo[]` | List all kernel processes across all runtimes |
|
|
89
|
+
| `processTree` | `processTree(): ProcessTreeNode[]` | Get processes organized as a parent-child tree |
|
|
90
|
+
| `getProcess` | `getProcess(pid: number): SpawnedProcessInfo` | Get info about a specific spawned process |
|
|
91
|
+
| `stopProcess` | `stopProcess(pid: number): void` | Send SIGTERM to a process |
|
|
92
|
+
| `killProcess` | `killProcess(pid: number): void` | Send SIGKILL to a process |
|
|
93
|
+
|
|
94
|
+
### Network
|
|
95
|
+
|
|
96
|
+
| Method | Signature | Description |
|
|
97
|
+
|--------|-----------|-------------|
|
|
98
|
+
| `fetch` | `fetch(port: number, request: Request): Promise<Response>` | Send an HTTP request to a service running inside the VM |
|
|
99
|
+
|
|
100
|
+
### Shell
|
|
101
|
+
|
|
102
|
+
| Method | Signature | Description |
|
|
103
|
+
|--------|-----------|-------------|
|
|
104
|
+
| `connectTerminal` | `connectTerminal(options?: ConnectTerminalOptions): Promise<number>` | Attach a shell directly to the host terminal and wait for exit |
|
|
105
|
+
| `openShell` | `openShell(options?: OpenShellOptions): { shellId: string }` | Open an interactive shell with PTY support |
|
|
106
|
+
| `writeShell` | `writeShell(shellId: string, data: string \| Uint8Array): void` | Write data to a shell's PTY input |
|
|
107
|
+
| `onShellData` | `onShellData(shellId: string, handler: (data: Uint8Array) => void): () => void` | Subscribe to shell output data |
|
|
108
|
+
| `resizeShell` | `resizeShell(shellId: string, cols: number, rows: number): void` | Notify terminal resize |
|
|
109
|
+
| `closeShell` | `closeShell(shellId: string): void` | Kill the shell process |
|
|
110
|
+
|
|
111
|
+
### Agent Sessions
|
|
112
|
+
|
|
113
|
+
| Method | Signature | Description |
|
|
114
|
+
|--------|-----------|-------------|
|
|
115
|
+
| `createSession` | `createSession(agentType: AgentType \| string, options?: CreateSessionOptions): Promise<{ sessionId: string }>` | Launch an agent and return a session ID |
|
|
116
|
+
| `listSessions` | `listSessions(): SessionInfo[]` | List active sessions |
|
|
117
|
+
| `destroySession` | `destroySession(sessionId: string): Promise<void>` | Gracefully cancel and close a session |
|
|
118
|
+
|
|
119
|
+
### Agent Registry
|
|
120
|
+
|
|
121
|
+
| Method | Signature | Description |
|
|
122
|
+
|--------|-----------|-------------|
|
|
123
|
+
| `listAgents` | `listAgents(): AgentRegistryEntry[]` | List registered agents with installation status |
|
|
124
|
+
|
|
125
|
+
### Agent Session Operations
|
|
126
|
+
|
|
127
|
+
| Method | Signature | Description |
|
|
128
|
+
|--------|-----------|-------------|
|
|
129
|
+
| `prompt` | `prompt(sessionId: string, text: string): Promise<PromptResult>` | Send a prompt and collect the agent text |
|
|
130
|
+
| `cancelSession` | `cancelSession(sessionId: string): Promise<JsonRpcResponse>` | Cancel ongoing agent work |
|
|
131
|
+
| `closeSession` | `closeSession(sessionId: string): void` | Kill the agent process and clean up |
|
|
132
|
+
| `onSessionEvent` | `onSessionEvent(sessionId: string, handler: SessionEventHandler): () => void` | Subscribe to session update notifications |
|
|
133
|
+
| `onPermissionRequest` | `onPermissionRequest(sessionId: string, handler: PermissionRequestHandler): () => void` | Subscribe to permission requests |
|
|
134
|
+
| `respondPermission` | `respondPermission(sessionId: string, permissionId: string, reply: PermissionReply): Promise<JsonRpcResponse>` | Reply to a permission request |
|
|
135
|
+
| `setSessionMode` | `setSessionMode(sessionId: string, modeId: string): Promise<JsonRpcResponse>` | Set the session mode |
|
|
136
|
+
| `getSessionModes` | `getSessionModes(sessionId: string): SessionModeState \| null` | Get available modes |
|
|
137
|
+
| `setSessionModel` | `setSessionModel(sessionId: string, model: string): Promise<JsonRpcResponse>` | Set the model |
|
|
138
|
+
| `setSessionThoughtLevel` | `setSessionThoughtLevel(sessionId: string, level: string): Promise<JsonRpcResponse>` | Set reasoning level |
|
|
139
|
+
| `getSessionConfigOptions` | `getSessionConfigOptions(sessionId: string): SessionConfigOption[]` | Get available config options |
|
|
140
|
+
| `rawSend` | `rawSend(sessionId: string, method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>` | Send an arbitrary ACP request |
|
|
141
|
+
|
|
142
|
+
### Exported Types
|
|
143
|
+
|
|
144
|
+
**VM & Options**
|
|
145
|
+
- `AgentOsOptions` — VM creation options (commandDirs, loopbackExemptPorts, mounts, additionalInstructions). Use `nodeModulesMount(...)` in `mounts` to expose a host `node_modules` tree at `/root/node_modules`.
|
|
146
|
+
- `AgentOsSidecarConfig` — shared-pool or explicit-handle sidecar selection for VM creation
|
|
147
|
+
- `AgentOsSharedSidecarOptions` — shared sidecar pool selection
|
|
148
|
+
- `AgentOsCreateSidecarOptions` — explicit sidecar handle creation options
|
|
149
|
+
- `CreateSessionOptions` — Session options (cwd, env, mcpServers, skipOsInstructions, additionalInstructions)
|
|
150
|
+
|
|
151
|
+
**Sidecar**
|
|
152
|
+
- `AgentOsSidecarDescription` — Sidecar identity, placement, lifecycle state, and active VM count
|
|
153
|
+
|
|
154
|
+
**Mount Configurations**
|
|
155
|
+
- `MountConfig` — Union of all mount types
|
|
156
|
+
- `MountConfigMemory` — In-memory filesystem
|
|
157
|
+
- `MountConfigCustom` — Caller-provided VirtualFileSystem
|
|
158
|
+
- `NativeMountConfig` — Declarative sidecar mount plugin configuration
|
|
159
|
+
- `MountConfigOverlay` — Copy-on-write overlay (lower + upper layers)
|
|
160
|
+
|
|
161
|
+
**Companion Filesystem Packages**
|
|
162
|
+
- `createGoogleDriveBackend()` — Declarative Google Drive native mount helper from `@secure-exec/google-drive`
|
|
163
|
+
- `createS3Backend()` — Declarative S3-compatible native mount helper from `@secure-exec/s3`
|
|
164
|
+
|
|
165
|
+
**MCP Servers**
|
|
166
|
+
- `McpServerConfig` — Union of local and remote MCP configs
|
|
167
|
+
- `McpServerConfigLocal` — Local MCP server (command, args, env)
|
|
168
|
+
- `McpServerConfigRemote` — Remote MCP server (url, headers)
|
|
169
|
+
|
|
170
|
+
**Process**
|
|
171
|
+
- `ProcessInfo` — Kernel process info (pid, ppid, pgid, sid, driver, command, args, cwd, status, exitCode, startTime, exitTime)
|
|
172
|
+
- `SpawnedProcessInfo` — Info for processes created via `spawn()` (pid, command, args, running, exitCode)
|
|
173
|
+
- `ProcessTreeNode` — ProcessInfo with `children: ProcessTreeNode[]`
|
|
174
|
+
|
|
175
|
+
**Filesystem**
|
|
176
|
+
- `DirEntry` — Directory entry (path, type, size)
|
|
177
|
+
- `ReaddirRecursiveOptions` — Options for recursive listing (maxDepth, exclude)
|
|
178
|
+
- `BatchWriteEntry` — Entry for batch writes (path, content)
|
|
179
|
+
- `BatchWriteResult` — Result of a batch write (path, success, error?)
|
|
180
|
+
- `BatchReadResult` — Result of a batch read (path, content, error?)
|
|
181
|
+
|
|
182
|
+
**Agent**
|
|
183
|
+
- `AgentType` — `"pi" | "pi-cli" | "opencode" | "claude"`
|
|
184
|
+
- `AgentConfig` — Agent configuration (acpAdapter, agentPackage, prepareInstructions)
|
|
185
|
+
- `AgentRegistryEntry` — Registry entry (id, acpAdapter, agentPackage, installed)
|
|
186
|
+
|
|
187
|
+
**Session**
|
|
188
|
+
- `SessionInfo` — Session summary (sessionId, agentType)
|
|
189
|
+
- `SessionInitData` — Data from ACP initialize response
|
|
190
|
+
- `SessionMode` — A mode the agent supports
|
|
191
|
+
- `SessionModeState` — Current mode and available modes
|
|
192
|
+
- `SessionConfigOption` — A configuration option the agent supports
|
|
193
|
+
- `AgentCapabilities` — Boolean capability flags from the agent
|
|
194
|
+
- `AgentInfo` — Agent identity (name, version)
|
|
195
|
+
- `PermissionRequest` — Permission request from an agent
|
|
196
|
+
- `PermissionReply` — `"once" | "always" | "reject"`
|
|
197
|
+
- `PermissionRequestHandler` — Handler for permission requests
|
|
198
|
+
- `SessionEventHandler` — Handler for live session update events
|
|
199
|
+
|
|
200
|
+
**Protocol**
|
|
201
|
+
- `JsonRpcRequest`, `JsonRpcResponse`, `JsonRpcNotification`, `JsonRpcError`
|
|
202
|
+
|
|
203
|
+
**Backends**
|
|
204
|
+
- `HostDirBackendOptions` — Options for the `createHostDirBackend()` native host-dir plugin helper
|