@rivet-dev/agentos-core 0.0.0-codex-darwin-ci-publish.61a7af3 → 0.0.0-nathan-binding-workspace.13eb4d4
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 +15 -15
- package/dist/{agent-os.d.ts → agentos.d.ts} +37 -86
- package/dist/{agent-os.js → agentos.js} +146 -188
- package/dist/agents.d.ts +1 -1
- package/dist/agents.js +2 -2
- package/dist/{host-tools-zod.d.ts → bindings-zod.d.ts} +1 -1
- package/dist/{host-tools-zod.js → bindings-zod.js} +16 -16
- package/dist/bindings.d.ts +45 -0
- package/dist/bindings.js +26 -0
- package/dist/cron/cron-manager.d.ts +3 -3
- package/dist/cron/cron-manager.js +2 -5
- package/dist/cron/types.d.ts +1 -1
- package/dist/host-dir-mount.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/json-rpc.d.ts +1 -17
- package/dist/json-rpc.js +0 -8
- package/dist/layers.d.ts +1 -1
- package/dist/layers.js +3 -3
- package/dist/packages.d.ts +1 -1
- package/dist/packages.js +1 -1
- package/dist/runtime-compat.d.ts +6 -2
- package/dist/runtime-compat.js +6 -5
- package/dist/runtime.d.ts +2 -2
- package/dist/sidecar/{agent-os-protocol.d.ts → agentos-protocol.d.ts} +0 -36
- package/dist/sidecar/{agent-os-protocol.js → agentos-protocol.js} +2 -42
- package/dist/sidecar/native-process-client.d.ts +3 -2
- package/dist/sidecar/native-process-client.js +6 -1
- package/dist/sidecar/permissions.js +3 -3
- package/dist/sidecar/process.d.ts +4 -4
- package/dist/sidecar/process.js +3 -3
- package/dist/sidecar/rpc-client.d.ts +41 -40
- package/dist/sidecar/rpc-client.js +53 -8
- package/dist/test/runtime.d.ts +1 -1
- package/dist/test/runtime.js +1 -1
- package/dist/test/sandbox-agent.js +1 -1
- package/dist/types.d.ts +3 -3
- package/package.json +25 -25
- package/dist/host-tools.d.ts +0 -45
- package/dist/host-tools.js +0 -26
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @rivet-dev/
|
|
1
|
+
# @rivet-dev/agentos-core
|
|
2
2
|
|
|
3
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
4
|
|
|
@@ -19,16 +19,16 @@ Agents run inside isolated VMs with their own filesystem, process table, and net
|
|
|
19
19
|
## Quick Start
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npm install @rivet-dev/
|
|
22
|
+
npm install @rivet-dev/agentos-core
|
|
23
23
|
# Install an agent adapter + its underlying agent
|
|
24
|
-
npm install @rivet-dev/
|
|
24
|
+
npm install @rivet-dev/agentos-pi @mariozechner/pi-coding-agent
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import {
|
|
28
|
+
import { AgentOS } from "@rivet-dev/agentos-core";
|
|
29
29
|
|
|
30
30
|
// 1. Create a VM
|
|
31
|
-
const vm = await
|
|
31
|
+
const vm = await AgentOS.create();
|
|
32
32
|
|
|
33
33
|
// 2. Create an agent session
|
|
34
34
|
const { sessionId } = await vm.createSession("pi");
|
|
@@ -47,17 +47,17 @@ await vm.dispose();
|
|
|
47
47
|
|
|
48
48
|
| Method | Signature | Description |
|
|
49
49
|
|--------|-----------|-------------|
|
|
50
|
-
| `create` | `static create(options?:
|
|
51
|
-
| `getSharedSidecar` | `static getSharedSidecar(options?:
|
|
52
|
-
| `createSidecar` | `static createSidecar(options?:
|
|
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
53
|
| `dispose` | `dispose(): Promise<void>` | Shut down the VM and all sessions |
|
|
54
54
|
|
|
55
55
|
### Sidecars
|
|
56
56
|
|
|
57
57
|
| Surface | Signature | Description |
|
|
58
58
|
|--------|-----------|-------------|
|
|
59
|
-
| `sidecar` | `
|
|
60
|
-
| `describe` | `sidecar.describe():
|
|
59
|
+
| `sidecar` | `AgentOSSidecar` | Sidecar handle backing the VM |
|
|
60
|
+
| `describe` | `sidecar.describe(): AgentOSSidecarDescription` | Inspect sidecar placement, state, and active VM count |
|
|
61
61
|
| `dispose` | `sidecar.dispose(): Promise<void>` | Dispose the sidecar handle and any active VMs leased from it |
|
|
62
62
|
|
|
63
63
|
### Filesystem
|
|
@@ -142,14 +142,14 @@ await vm.dispose();
|
|
|
142
142
|
### Exported Types
|
|
143
143
|
|
|
144
144
|
**VM & Options**
|
|
145
|
-
- `
|
|
146
|
-
- `
|
|
147
|
-
- `
|
|
148
|
-
- `
|
|
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
149
|
- `CreateSessionOptions` — Session options (cwd, env, mcpServers, skipOsInstructions, additionalInstructions)
|
|
150
150
|
|
|
151
151
|
**Sidecar**
|
|
152
|
-
- `
|
|
152
|
+
- `AgentOSSidecarDescription` — Sidecar identity, placement, lifecycle state, and active VM count
|
|
153
153
|
|
|
154
154
|
**Mount Configurations**
|
|
155
155
|
- `MountConfig` — Union of all mount types
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NativeMountPluginDescriptor } from "@secure-exec/core/descriptors";
|
|
2
2
|
import type { AgentCapabilities, AgentInfo, PermissionReply, PermissionRequestHandler, SessionConfigOption, SessionEventHandler, SessionModeState } from "./agent-session-types.js";
|
|
3
|
-
import { type
|
|
3
|
+
import { type Bindings } from "./bindings.js";
|
|
4
4
|
import type { JsonRpcResponse } from "./json-rpc.js";
|
|
5
5
|
import type { ConnectTerminalOptions, Kernel, KernelExecOptions, KernelExecResult, ProcessInfo as KernelProcessInfo, KernelSpawnOptions, OpenShellOptions, Permissions, VirtualFileSystem, VirtualStat } from "./runtime-compat.js";
|
|
6
6
|
export type { MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, NativeMountPluginDescriptor, } from "@secure-exec/core/descriptors";
|
|
@@ -55,23 +55,23 @@ import type { ScheduleDriver } from "./cron/schedule-driver.js";
|
|
|
55
55
|
import type { CronEventHandler, CronJob, CronJobInfo, CronJobOptions } from "./cron/types.js";
|
|
56
56
|
import { type LayerStore, type OverlayFilesystemMode, type RootSnapshotExport, type SnapshotLayerHandle } from "./layers.js";
|
|
57
57
|
import { type SoftwareInput } from "./packages.js";
|
|
58
|
-
import { type
|
|
59
|
-
export interface
|
|
58
|
+
import { type AgentOSSidecarPlacement } from "./sidecar/rpc-client.js";
|
|
59
|
+
export interface AgentOSSharedSidecarOptions {
|
|
60
60
|
pool?: string;
|
|
61
61
|
}
|
|
62
|
-
export interface
|
|
62
|
+
export interface AgentOSCreateSidecarOptions {
|
|
63
63
|
sidecarId?: string;
|
|
64
64
|
}
|
|
65
|
-
export type
|
|
65
|
+
export type AgentOSSidecarConfig = {
|
|
66
66
|
kind: "shared";
|
|
67
67
|
pool?: string;
|
|
68
68
|
} | {
|
|
69
69
|
kind: "explicit";
|
|
70
|
-
handle:
|
|
70
|
+
handle: AgentOSSidecar;
|
|
71
71
|
};
|
|
72
|
-
export interface
|
|
72
|
+
export interface AgentOSSidecarDescription {
|
|
73
73
|
sidecarId: string;
|
|
74
|
-
placement:
|
|
74
|
+
placement: AgentOSSidecarPlacement;
|
|
75
75
|
state: "ready" | "disposing" | "disposed";
|
|
76
76
|
activeVmCount: number;
|
|
77
77
|
}
|
|
@@ -119,7 +119,7 @@ export type MountConfig = PlainMountConfig | NativeMountConfig | OverlayMountCon
|
|
|
119
119
|
* forwarded to the native sidecar in the typed create-VM JSON config. Unknown, negative, or
|
|
120
120
|
* non-integer values are rejected by the sidecar before VM construction.
|
|
121
121
|
*/
|
|
122
|
-
export interface
|
|
122
|
+
export interface AgentOSLimits {
|
|
123
123
|
/** Kernel resource limits (processes, FDs, sockets, filesystem bytes, WASM caps, etc.). */
|
|
124
124
|
resources?: {
|
|
125
125
|
cpuCount?: number;
|
|
@@ -190,23 +190,15 @@ export interface AgentOsLimits {
|
|
|
190
190
|
syncReadLimitBytes?: number;
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
-
export interface
|
|
193
|
+
export interface AgentOSOptions {
|
|
194
194
|
/**
|
|
195
195
|
* Software to install in the VM. Each entry provides agents, tools,
|
|
196
196
|
* or WASM commands. Any object with a `commandDir` property (e.g.,
|
|
197
|
-
* registry packages like @
|
|
197
|
+
* registry packages like @agentos-software/coreutils) is treated
|
|
198
198
|
* as a WASM command source automatically. Arrays are flattened, so
|
|
199
199
|
* meta-packages that export arrays of sub-packages work directly.
|
|
200
200
|
*/
|
|
201
201
|
software?: SoftwareInput[];
|
|
202
|
-
/**
|
|
203
|
-
* Whether to auto-include the default software bundle (`@agent-os-pkgs/common`
|
|
204
|
-
* — `sh` + coreutils + the standard CLI tools agents rely on) in addition to
|
|
205
|
-
* any `software` you pass. Defaults to `true`; set `false` for a bare VM with
|
|
206
|
-
* only the software you list explicitly. Entries already present in `software`
|
|
207
|
-
* are not duplicated.
|
|
208
|
-
*/
|
|
209
|
-
defaultSoftware?: boolean;
|
|
210
202
|
/** Loopback ports to exempt from SSRF checks (for testing with host-side mock servers). */
|
|
211
203
|
loopbackExemptPorts?: number[];
|
|
212
204
|
/**
|
|
@@ -218,12 +210,17 @@ export interface AgentOsOptions {
|
|
|
218
210
|
rootFilesystem?: RootFilesystemConfig;
|
|
219
211
|
/** Filesystems to mount at boot time. */
|
|
220
212
|
mounts?: MountConfig[];
|
|
213
|
+
/**
|
|
214
|
+
* @deprecated Use `mounts: [nodeModulesMount(path)]` instead.
|
|
215
|
+
* Compatibility alias for mounting `<moduleAccessCwd>/node_modules` at `/root/node_modules`.
|
|
216
|
+
*/
|
|
217
|
+
moduleAccessCwd?: string;
|
|
221
218
|
/** Additional instructions appended to the base OS system prompt injected at session start. */
|
|
222
219
|
additionalInstructions?: string;
|
|
223
220
|
/** Custom schedule driver for cron jobs. Defaults to TimerScheduleDriver. */
|
|
224
221
|
scheduleDriver?: ScheduleDriver;
|
|
225
|
-
/** Host-side
|
|
226
|
-
|
|
222
|
+
/** Host-side bindings available to agents inside the VM. */
|
|
223
|
+
bindings?: Bindings[];
|
|
227
224
|
/**
|
|
228
225
|
* Custom permission policy for the kernel. Controls access to filesystem,
|
|
229
226
|
* network, child process, and environment operations. Defaults to allowAll.
|
|
@@ -233,12 +230,12 @@ export interface AgentOsOptions {
|
|
|
233
230
|
* Sidecar placement for the VM. Defaults to the shared `default` pool.
|
|
234
231
|
* Pass an explicit sidecar handle to pin the VM to a caller-managed sidecar.
|
|
235
232
|
*/
|
|
236
|
-
sidecar?:
|
|
233
|
+
sidecar?: AgentOSSidecarConfig;
|
|
237
234
|
/**
|
|
238
235
|
* Operator-tunable runtime limits. Unset fields use built-in defaults that match the
|
|
239
236
|
* runtime's historical constants, so omitting this leaves behavior unchanged.
|
|
240
237
|
*/
|
|
241
|
-
limits?:
|
|
238
|
+
limits?: AgentOSLimits;
|
|
242
239
|
}
|
|
243
240
|
/** Configuration for a local MCP server (spawned as a child process). */
|
|
244
241
|
export interface McpServerConfigLocal {
|
|
@@ -259,11 +256,11 @@ export interface McpServerConfigRemote {
|
|
|
259
256
|
headers?: Record<string, string>;
|
|
260
257
|
}
|
|
261
258
|
export type McpServerConfig = McpServerConfigLocal | McpServerConfigRemote;
|
|
262
|
-
export interface
|
|
259
|
+
export interface AgentOSRuntimeAdmin {
|
|
263
260
|
kernel: Kernel;
|
|
264
261
|
rootView: VirtualFileSystem;
|
|
265
262
|
env: Record<string, string>;
|
|
266
|
-
sidecar:
|
|
263
|
+
sidecar: AgentOSSidecar;
|
|
267
264
|
}
|
|
268
265
|
export interface CreateSessionOptions {
|
|
269
266
|
/** Working directory for the agent session inside the VM. */
|
|
@@ -277,49 +274,18 @@ export interface CreateSessionOptions {
|
|
|
277
274
|
/** Additional instructions appended to the base OS instructions. */
|
|
278
275
|
additionalInstructions?: string;
|
|
279
276
|
}
|
|
280
|
-
/**
|
|
281
|
-
* Options for {@link AgentOs.resumeSession}.
|
|
282
|
-
*
|
|
283
|
-
* Resume depends on a durable root: after a Rivet actor sleeps (VM destroyed) and
|
|
284
|
-
* wakes (fresh VM, actor SQLite intact) the caller can keep prompting an existing
|
|
285
|
-
* session. On a non-durable (default in-memory) root there is no surviving store,
|
|
286
|
-
* so the sidecar's universal fallback tier always runs and the transcript pointer
|
|
287
|
-
* is the only continuity mechanism.
|
|
288
|
-
*/
|
|
289
|
-
export interface ResumeSessionOptions {
|
|
290
|
-
/**
|
|
291
|
-
* Guest-readable path to the reconstructed transcript. When present, the
|
|
292
|
-
* fallback tier arms a continuation preamble pointing the agent at it.
|
|
293
|
-
*/
|
|
294
|
-
transcriptPath?: string;
|
|
295
|
-
/** Working directory for the resumed agent session (default `/home/user`). */
|
|
296
|
-
cwd?: string;
|
|
297
|
-
/** Environment variables to pass to the resumed agent process. */
|
|
298
|
-
env?: Record<string, string>;
|
|
299
|
-
}
|
|
300
|
-
/** Result from {@link AgentOs.resumeSession}. */
|
|
301
|
-
export interface ResumeSessionResult {
|
|
302
|
-
/**
|
|
303
|
-
* The live ACP session id in the fresh VM: equal to the requested id for
|
|
304
|
-
* native loads, or a freshly assigned id for the fallback tier — the caller
|
|
305
|
-
* remaps `external -> live`.
|
|
306
|
-
*/
|
|
307
|
-
sessionId: string;
|
|
308
|
-
/** `"native"` (session/load|resume) or `"fallback"` (session/new + preamble). */
|
|
309
|
-
mode: string;
|
|
310
|
-
}
|
|
311
277
|
export interface SessionInfo {
|
|
312
278
|
sessionId: string;
|
|
313
279
|
agentType: string;
|
|
314
280
|
}
|
|
315
|
-
/** Result from
|
|
281
|
+
/** Result from AgentOS.prompt(). */
|
|
316
282
|
export interface PromptResult {
|
|
317
283
|
/** Raw JSON-RPC response from the ACP adapter. */
|
|
318
284
|
response: JsonRpcResponse;
|
|
319
285
|
/** Accumulated agent text output from streamed message chunks. */
|
|
320
286
|
text: string;
|
|
321
287
|
}
|
|
322
|
-
/** Information about a process spawned via
|
|
288
|
+
/** Information about a process spawned via AgentOS.spawn(). */
|
|
323
289
|
export interface SpawnedProcessInfo {
|
|
324
290
|
pid: number;
|
|
325
291
|
command: string;
|
|
@@ -327,9 +293,9 @@ export interface SpawnedProcessInfo {
|
|
|
327
293
|
running: boolean;
|
|
328
294
|
exitCode: number | null;
|
|
329
295
|
}
|
|
330
|
-
export declare class
|
|
296
|
+
export declare class AgentOS {
|
|
331
297
|
#private;
|
|
332
|
-
readonly sidecar:
|
|
298
|
+
readonly sidecar: AgentOSSidecar;
|
|
333
299
|
private _sessions;
|
|
334
300
|
private _closedSessionIds;
|
|
335
301
|
private _sessionClosePromises;
|
|
@@ -344,7 +310,7 @@ export declare class AgentOs {
|
|
|
344
310
|
private _softwareRoots;
|
|
345
311
|
private _softwareAgentConfigs;
|
|
346
312
|
private _cronManager;
|
|
347
|
-
private
|
|
313
|
+
private _bindings;
|
|
348
314
|
private _toolReference;
|
|
349
315
|
private _permissions;
|
|
350
316
|
private _hostMounts;
|
|
@@ -356,10 +322,11 @@ export declare class AgentOs {
|
|
|
356
322
|
private readonly _sidecarVm;
|
|
357
323
|
private readonly _disposeSidecarEventListener;
|
|
358
324
|
private constructor();
|
|
359
|
-
static createSidecar(options?:
|
|
360
|
-
static getSharedSidecar(options?:
|
|
361
|
-
static create(options?:
|
|
325
|
+
static createSidecar(options?: AgentOSCreateSidecarOptions): Promise<AgentOSSidecar>;
|
|
326
|
+
static getSharedSidecar(options?: AgentOSSharedSidecarOptions): Promise<AgentOSSidecar>;
|
|
327
|
+
static create(options?: AgentOSOptions): Promise<AgentOS>;
|
|
362
328
|
exec(command: string, options?: KernelExecOptions): Promise<KernelExecResult>;
|
|
329
|
+
execArgv(command: string, args?: readonly string[], options?: KernelExecOptions): Promise<KernelExecResult>;
|
|
363
330
|
private _trackProcess;
|
|
364
331
|
spawn(command: string, args: string[], options?: KernelSpawnOptions): {
|
|
365
332
|
pid: number;
|
|
@@ -456,22 +423,6 @@ export declare class AgentOs {
|
|
|
456
423
|
createSession(agentType: AgentType | string, options?: CreateSessionOptions): Promise<{
|
|
457
424
|
sessionId: string;
|
|
458
425
|
}>;
|
|
459
|
-
/**
|
|
460
|
-
* Resume a session that exists in durable storage but is not live in this VM
|
|
461
|
-
* (e.g. after a Rivet actor slept and woke with a fresh VM). Thin forwarder:
|
|
462
|
-
* resolves the agent config + adapter entrypoint exactly as {@link createSession}
|
|
463
|
-
* does, then forwards a single `AcpResumeSessionRequest` to the sidecar, which
|
|
464
|
-
* owns the resume state machine (native `session/load` when the agent supports
|
|
465
|
-
* it, else `session/new` + a transcript-continuation preamble). The returned
|
|
466
|
-
* `sessionId` is the live id in this VM (equal to the requested id for native
|
|
467
|
-
* loads, freshly assigned for the fallback); the caller remaps `external -> live`.
|
|
468
|
-
* The new live session is registered + hydrated locally so subsequent prompts
|
|
469
|
-
* route to it.
|
|
470
|
-
*
|
|
471
|
-
* Resume depends on a durable root; on a non-durable (default in-memory) root
|
|
472
|
-
* there is no surviving store and the fallback tier always runs.
|
|
473
|
-
*/
|
|
474
|
-
resumeSession(sessionId: string, agentType: AgentType | string, options?: ResumeSessionOptions): Promise<ResumeSessionResult>;
|
|
475
426
|
/**
|
|
476
427
|
* Resolve the VM bin entry point of an ACP adapter package.
|
|
477
428
|
* Reads from the host filesystem since kernel.readFile() resolves through
|
|
@@ -551,17 +502,17 @@ export declare class AgentOs {
|
|
|
551
502
|
onCronEvent(handler: CronEventHandler): void;
|
|
552
503
|
dispose(): Promise<void>;
|
|
553
504
|
}
|
|
554
|
-
export declare function
|
|
555
|
-
export declare function
|
|
556
|
-
export declare class
|
|
557
|
-
constructor(sidecarId: string, placement:
|
|
558
|
-
describe():
|
|
505
|
+
export declare function getAgentOSRuntimeAdmin(vm: AgentOS): AgentOSRuntimeAdmin;
|
|
506
|
+
export declare function getAgentOSKernel(vm: AgentOS): Kernel;
|
|
507
|
+
export declare class AgentOSSidecar {
|
|
508
|
+
constructor(sidecarId: string, placement: AgentOSSidecarPlacement, sharedPool?: string);
|
|
509
|
+
describe(): AgentOSSidecarDescription;
|
|
559
510
|
dispose(): Promise<void>;
|
|
560
511
|
}
|
|
561
512
|
/**
|
|
562
513
|
* Test-only escape hatch: dispose every cached shared sidecar so vitest
|
|
563
514
|
* workers can exit cleanly. The shared sidecar is normally process-global and
|
|
564
|
-
* keeps its native subprocess alive across `
|
|
515
|
+
* keeps its native subprocess alive across `AgentOS.create()` calls; without
|
|
565
516
|
* this hook the vitest worker can hold open piped stdio handles after the
|
|
566
517
|
* test suite finishes and stall `pnpm test` indefinitely.
|
|
567
518
|
*/
|