@rivet-dev/agentos-core 0.2.8-rc.2 → 0.2.8-rc.4

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.
Files changed (55) hide show
  1. package/README.md +40 -37
  2. package/dist/agent-os.d.ts +184 -230
  3. package/dist/agent-os.js +751 -1158
  4. package/dist/agentos-package.d.ts +5 -3
  5. package/dist/agentos-package.js +5 -2
  6. package/dist/{host-tools-zod.d.ts → bindings-zod.d.ts} +1 -1
  7. package/dist/{host-tools-zod.js → bindings-zod.js} +27 -20
  8. package/dist/bindings.d.ts +43 -0
  9. package/dist/bindings.js +34 -0
  10. package/dist/cron/cron-manager.js +43 -10
  11. package/dist/cron/index.d.ts +1 -1
  12. package/dist/cron/types.d.ts +25 -9
  13. package/dist/filesystem-snapshot.d.ts +1 -2
  14. package/dist/filesystem-snapshot.js +0 -43
  15. package/dist/generated/AcpLimitsConfig.d.ts +16 -0
  16. package/dist/generated/BindingLimitsConfig.d.ts +10 -0
  17. package/dist/generated/CreateVmConfig.d.ts +2 -0
  18. package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
  19. package/dist/generated/ProcessLimitsConfig.js +2 -0
  20. package/dist/generated/VmGroupConfig.d.ts +5 -0
  21. package/dist/generated/VmGroupConfig.js +2 -0
  22. package/dist/generated/VmLimitsConfig.d.ts +4 -2
  23. package/dist/generated/VmUserAccountConfig.d.ts +9 -0
  24. package/dist/generated/VmUserAccountConfig.js +2 -0
  25. package/dist/generated/VmUserConfig.d.ts +19 -0
  26. package/dist/generated/WasmLimitsConfig.d.ts +1 -0
  27. package/dist/index.d.ts +4 -5
  28. package/dist/index.js +4 -5
  29. package/dist/layers.d.ts +5 -2
  30. package/dist/layers.js +0 -185
  31. package/dist/options-schema.d.ts +133 -31
  32. package/dist/options-schema.js +143 -26
  33. package/dist/runtime-compat.d.ts +4 -35
  34. package/dist/runtime-compat.js +84 -372
  35. package/dist/runtime.d.ts +3 -1
  36. package/dist/sandbox.d.ts +4 -4
  37. package/dist/sandbox.js +4 -4
  38. package/dist/session-api.d.ts +180 -0
  39. package/dist/session-api.js +1 -0
  40. package/dist/sidecar/agentos-protocol.d.ts +429 -29
  41. package/dist/sidecar/agentos-protocol.js +691 -93
  42. package/dist/sidecar/rpc-client.d.ts +18 -6
  43. package/dist/sidecar/rpc-client.js +66 -18
  44. package/dist/test/runtime.d.ts +2 -1
  45. package/dist/test/runtime.js +2 -1
  46. package/dist/types.d.ts +4 -5
  47. package/package.json +28 -27
  48. package/dist/agent-session-types.d.ts +0 -67
  49. package/dist/generated/ToolLimitsConfig.d.ts +0 -10
  50. package/dist/host-tools.d.ts +0 -45
  51. package/dist/host-tools.js +0 -35
  52. package/dist/overlay-filesystem.d.ts +0 -19
  53. package/dist/overlay-filesystem.js +0 -645
  54. /package/dist/generated/{ToolLimitsConfig.js → BindingLimitsConfig.js} +0 -0
  55. /package/dist/{agent-session-types.js → generated/VmUserConfig.js} +0 -0
@@ -1,13 +1,11 @@
1
1
  import type { NativeMountPluginDescriptor } from "@rivet-dev/agentos-runtime-core/descriptors";
2
- import type { AgentCapabilities, AgentInfo, PermissionReply, PermissionRequestHandler, SessionConfigOption, SessionEventHandler, SessionModeState } from "./agent-session-types.js";
3
- import { type ToolKit } from "./host-tools.js";
4
- import type { JsonRpcResponse } from "./json-rpc.js";
2
+ import type { VmUserConfig } from "@rivet-dev/agentos-runtime-core/vm-config";
3
+ import type { CancelPromptResult, HistoryPage, ListSessionsInput, OpenSessionInput, PermissionResponse, PermissionResponseResult, PromptInput, PromptResult as DurablePromptResult, ReadHistoryInput, SessionCapabilities, SessionAgentInfo, SessionConfig, SessionInfo as DurableSessionInfo, SessionPage, SessionStreamEntry, SessionTarget, SetSessionConfigOptionInput } from "./session-api.js";
4
+ import { type Bindings } from "./bindings.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 "@rivet-dev/agentos-runtime-core/descriptors";
7
- export type { AgentCapabilities, AgentInfo, PermissionReply, PermissionRequest, PermissionRequestHandler, SessionConfigOption, SessionEventHandler, SessionInitData, SessionMode, SessionModeState, } from "./agent-session-types.js";
8
- export type { AcpTimeoutErrorData, JsonRpcError, JsonRpcErrorData, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, } from "./json-rpc.js";
9
- export { isAcpTimeoutErrorData } from "./json-rpc.js";
10
7
  export type { ConnectTerminalOptions } from "./runtime-compat.js";
8
+ export type * from "./session-api.js";
11
9
  /** Process tree node: extends kernel ProcessInfo with child references. */
12
10
  export interface ProcessTreeNode extends KernelProcessInfo {
13
11
  children: ProcessTreeNode[];
@@ -19,6 +17,64 @@ export interface DirEntry {
19
17
  type: "file" | "directory" | "symlink";
20
18
  size: number;
21
19
  }
20
+ /** One immediate child returned by a single readdirEntries operation. */
21
+ export interface ReaddirEntry {
22
+ name: string;
23
+ isDirectory: boolean;
24
+ isSymbolicLink: boolean;
25
+ }
26
+ /** Fully buffered request to an HTTP service listening inside the VM. */
27
+ export interface HttpRequest {
28
+ port: number;
29
+ path: string;
30
+ method?: string;
31
+ headers?: Record<string, string>;
32
+ body?: string | Uint8Array;
33
+ }
34
+ /** Fully buffered HTTP response from a service inside the VM. */
35
+ export interface HttpResponse {
36
+ status: number;
37
+ statusText: string;
38
+ headers: Record<string, string>;
39
+ body: Uint8Array;
40
+ }
41
+ export interface ProcessOutput {
42
+ pid: number;
43
+ stream: "stdout" | "stderr";
44
+ data: Uint8Array;
45
+ }
46
+ export interface ProcessExit {
47
+ pid: number;
48
+ exitCode: number;
49
+ }
50
+ export interface ShellData {
51
+ shellId: string;
52
+ data: Uint8Array;
53
+ }
54
+ export interface ShellExit {
55
+ shellId: string;
56
+ exitCode: number;
57
+ }
58
+ /** Sanitized live mount metadata. Plugin configuration is never exposed. */
59
+ export interface MountInfo {
60
+ path: string;
61
+ kind: string;
62
+ readOnly: boolean;
63
+ }
64
+ export interface ExportRootFilesystemOptions {
65
+ /** Maximum serialized snapshot bytes returned to this caller. */
66
+ maxBytes: number;
67
+ }
68
+ /** Portable, sidecar-owned dynamic mount descriptor. */
69
+ export interface DynamicMountDescriptor {
70
+ path: string;
71
+ plugin: NativeMountPluginDescriptor;
72
+ readOnly?: boolean;
73
+ }
74
+ /** Callback-free options accepted by the portable spawn API. */
75
+ export type SpawnOptions = KernelSpawnOptions;
76
+ /** Callback-free options accepted by the portable openShell API. */
77
+ export type ShellOptions = Omit<OpenShellOptions, "onStderr">;
22
78
  /** Options for readdirRecursive(). */
23
79
  export interface ReaddirRecursiveOptions {
24
80
  /** Maximum depth to recurse (0 = only immediate children). */
@@ -47,15 +103,12 @@ export interface BatchReadResult {
47
103
  export interface AgentRegistryEntry {
48
104
  id: string;
49
105
  installed: boolean;
50
- /** Guest entrypoint the sidecar launches for this agent (`/opt/agentos/bin/<acpEntrypoint>`). */
51
- adapterEntrypoint: string;
52
106
  }
53
- import type { AgentType } from "./types.js";
107
+ import { type PackageDescriptor } from "./agentos-package.js";
54
108
  import type { ScheduleDriver } from "./cron/schedule-driver.js";
55
109
  import type { CronEventHandler, CronJob, CronJobInfo, CronJobOptions } from "./cron/types.js";
56
110
  import { type LayerStore, type OverlayFilesystemMode, type RootSnapshotExport, type SnapshotLayerHandle } from "./layers.js";
57
- import { type SoftwareInput } from "./packages.js";
58
- import { type PackageRef, type SoftwarePackageRef } from "./agentos-package.js";
111
+ import type { SoftwareInput } from "./packages.js";
59
112
  import { type AgentOsSidecarPlacement } from "./sidecar/rpc-client.js";
60
113
  export interface AgentOsSharedSidecarOptions {
61
114
  pool?: string;
@@ -79,12 +132,27 @@ export interface AgentOsSidecarDescription {
79
132
  export type RootLowerInput = {
80
133
  kind: "bundled-base-filesystem";
81
134
  } | RootSnapshotExport;
82
- export interface RootFilesystemConfig {
135
+ export interface OverlayRootFilesystemConfig {
83
136
  type?: "overlay";
84
137
  mode?: OverlayFilesystemMode;
85
138
  disableDefaultBaseLayer?: boolean;
86
139
  lowers?: RootLowerInput[];
87
140
  }
141
+ /** Declarative sidecar-native root filesystem. */
142
+ export interface NativeRootFilesystemConfig {
143
+ type: "native";
144
+ plugin: NativeMountPluginDescriptor;
145
+ readOnly?: boolean;
146
+ }
147
+ export type RootFilesystemConfig = OverlayRootFilesystemConfig | NativeRootFilesystemConfig;
148
+ /** VM-scoped SQLite storage shared by VFS and AgentOS durable state. */
149
+ export type VmSqliteConfig = {
150
+ type: "actor_uds";
151
+ path: string;
152
+ } | {
153
+ type: "sqlite_file";
154
+ path: string;
155
+ };
88
156
  /**
89
157
  * Compatibility path for arbitrary caller-supplied filesystems.
90
158
  * This maps to the sidecar `js_bridge` plugin during the migration.
@@ -94,6 +162,10 @@ export interface PlainMountConfig {
94
162
  path: string;
95
163
  /** The filesystem driver to mount. */
96
164
  driver: VirtualFileSystem;
165
+ /** Filesystem type exposed through guest mount discovery. */
166
+ guestFstype?: string;
167
+ /** Source name exposed through guest mount discovery. */
168
+ guestSource?: string;
97
169
  /** If true, write operations throw EROFS. */
98
170
  readOnly?: boolean;
99
171
  }
@@ -101,6 +173,10 @@ export interface PlainMountConfig {
101
173
  export interface NativeMountConfig {
102
174
  path: string;
103
175
  plugin: NativeMountPluginDescriptor;
176
+ /** Filesystem type exposed through guest mount discovery. */
177
+ guestFstype?: string;
178
+ /** Source name exposed through guest mount discovery. */
179
+ guestSource?: string;
104
180
  readOnly?: boolean;
105
181
  }
106
182
  export interface OverlayMountConfig {
@@ -146,29 +222,42 @@ export interface AgentOsLimits {
146
222
  };
147
223
  /** HTTP body buffering limits. */
148
224
  http?: {
149
- /** Cap on `vm.fetch()` buffered response bodies. Must be <= the sidecar wire frame cap. */
225
+ /** Cap on `vm.httpRequest()` buffered response bodies. Must be <= the sidecar wire frame cap. */
150
226
  maxFetchResponseBytes?: number;
151
227
  };
152
- /** Host-tool registration and invocation limits. */
153
- tools?: {
154
- defaultToolTimeoutMs?: number;
155
- maxToolTimeoutMs?: number;
156
- maxRegisteredToolkits?: number;
157
- maxRegisteredToolsPerVm?: number;
158
- maxToolsPerToolkit?: number;
159
- maxToolSchemaBytes?: number;
160
- maxToolExamplesPerTool?: number;
161
- maxToolExampleInputBytes?: number;
228
+ /** Host binding registration and invocation limits. */
229
+ bindings?: {
230
+ defaultBindingTimeoutMs?: number;
231
+ maxBindingTimeoutMs?: number;
232
+ maxRegisteredCollections?: number;
233
+ maxRegisteredCollectionsPerVm?: number;
234
+ maxBindingsPerCollection?: number;
235
+ maxBindingSchemaBytes?: number;
236
+ maxExamplesPerBinding?: number;
237
+ maxBindingExampleInputBytes?: number;
162
238
  };
163
239
  /** Mount plugin manifest size limits. */
164
240
  plugins?: {
165
241
  maxPersistedManifestBytes?: number;
166
242
  maxPersistedManifestFileBytes?: number;
167
243
  };
168
- /** ACP adapter buffering limits. */
244
+ /** ACP adapter, active-turn, history-retention, and page limits. */
169
245
  acp?: {
170
246
  maxReadLineBytes?: number;
171
247
  stdoutBufferByteLimit?: number;
248
+ maxCompletedMessageBytes?: number;
249
+ maxTurnOutputBytes?: number;
250
+ maxPromptBytes?: number;
251
+ maxPromptBlocks?: number;
252
+ maxFallbackContinuationBytes?: number;
253
+ maxSessionHistoryBytes?: number;
254
+ maxSessionHistoryEvents?: number;
255
+ maxHistoryPageEntries?: number;
256
+ maxSessionListEntries?: number;
257
+ };
258
+ /** Shared local-file/actor-UDS SQLite result materialization limit. */
259
+ sqlite?: {
260
+ maxResultBytes?: number;
172
261
  };
173
262
  /** Guest JavaScript runtime buffering limits. */
174
263
  jsRuntime?: {
@@ -196,6 +285,15 @@ export interface AgentOsLimits {
196
285
  syncReadLimitBytes?: number;
197
286
  prewarmTimeoutMs?: number;
198
287
  runnerHeapLimitMb?: number;
288
+ runnerCpuTimeLimitMs?: number;
289
+ };
290
+ /** Process spawn, I/O, and lifecycle-event backlog limits. */
291
+ process?: {
292
+ maxSpawnFileActions?: number;
293
+ maxSpawnFileActionBytes?: number;
294
+ pendingStdinBytes?: number;
295
+ pendingEventCount?: number;
296
+ pendingEventBytes?: number;
199
297
  };
200
298
  }
201
299
  export interface AgentStderrEvent {
@@ -207,20 +305,14 @@ export interface AgentStderrEvent {
207
305
  }
208
306
  export type AgentStderrHandler = (event: AgentStderrEvent) => void;
209
307
  /**
210
- * Auto-restart outcome reported on an {@link AgentExitEvent}. Mirrors the
211
- * sidecar's `AcpAgentExitedEvent.restart` strings:
212
- * - `"restarted"` — the adapter was respawned and the session was natively
213
- * re-attached under the same session id; the session stays usable.
214
- * - `"unsupported"` — the adapter does not advertise a native resume
215
- * capability (`loadSession`/`resume`); the session was evicted.
216
- * - `"failed"` — the respawn or re-attach errored; the session was evicted.
217
- * - `"exhausted"` — the per-session restart budget was already spent; evicted.
308
+ * Restart disposition reported on an {@link AgentExitEvent}. AgentOS never
309
+ * respawns an adapter or replays an interrupted request implicitly.
218
310
  */
219
- export type AgentRestartOutcome = "restarted" | "unsupported" | "failed" | "exhausted";
311
+ export type AgentRestartOutcome = "not_attempted";
220
312
  /**
221
313
  * An unexpected ACP adapter process exit — a crash from the host's
222
- * perspective (any spontaneous exit without `closeSession()`, including exit
223
- * code 0) — plus the sidecar's bounded auto-restart outcome.
314
+ * perspective (any spontaneous exit before `unloadSession()`, including exit
315
+ * code 0). The live route is evicted and must be restored explicitly.
224
316
  */
225
317
  export interface AgentExitEvent {
226
318
  sessionId: string;
@@ -230,11 +322,11 @@ export interface AgentExitEvent {
230
322
  pid: number | null;
231
323
  /** Adapter exit code; `null` when the exit was observed indirectly. */
232
324
  exitCode: number | null;
233
- /** Auto-restart outcome; only `"restarted"` leaves the session usable. */
325
+ /** Always `"not_attempted"`; AgentOS does not restart adapters implicitly. */
234
326
  restart: AgentRestartOutcome;
235
- /** Restarts consumed for this session so far. */
327
+ /** Always zero. */
236
328
  restartCount: number;
237
- /** Per-session restart budget. */
329
+ /** Always zero. */
238
330
  maxRestarts: number;
239
331
  }
240
332
  export type AgentExitHandler = (event: AgentExitEvent) => void;
@@ -261,11 +353,12 @@ export type LimitWarningHandler = (warning: LimitWarning) => void;
261
353
  * Public core VM options.
262
354
  *
263
355
  * Keep this interface in sync with
264
- * `packages/core/src/options-schema.ts::agentOsOptionsSchema`. The Rivet
265
- * native actor intentionally accepts only a subset via
266
- * `packages/agentos/src/config.ts::nativeAgentOsOptionsSchema`.
356
+ * `packages/core/src/options-schema.ts::agentOsOptionsSchema`. The TypeScript
357
+ * Rivet actor accepts this surface directly alongside ordinary actor options.
267
358
  */
268
359
  export interface AgentOsOptions {
360
+ /** Initial virtual Linux credentials and account record. Defaults to `1000:1000` (`agentos`). */
361
+ user?: VmUserConfig;
269
362
  /**
270
363
  * Software to install in the VM. Each entry is a package-dir ref. Arrays are
271
364
  * flattened, so meta-packages that export arrays of sub-packages work directly.
@@ -294,16 +387,16 @@ export interface AgentOsOptions {
294
387
  * profiling workloads.
295
388
  */
296
389
  highResolutionTime?: boolean;
390
+ /** Durable SQLite storage for VM-owned filesystem and session state. */
391
+ database?: VmSqliteConfig;
297
392
  /** Root filesystem configuration. Defaults to an overlay with the bundled base snapshot as its deepest lower. */
298
393
  rootFilesystem?: RootFilesystemConfig;
299
394
  /** Filesystems to mount at boot time. */
300
395
  mounts?: MountConfig[];
301
- /** Additional instructions appended to the base OS system prompt injected at session start. */
302
- additionalInstructions?: string;
303
396
  /** Custom schedule driver for cron jobs. Defaults to TimerScheduleDriver. */
304
397
  scheduleDriver?: ScheduleDriver;
305
- /** Host-side toolkits available to agents inside the VM. */
306
- toolKits?: ToolKit[];
398
+ /** Host-side bindings available to agents inside the VM. */
399
+ bindings?: Bindings[];
307
400
  /**
308
401
  * Custom permission policy for the kernel. Controls access to filesystem,
309
402
  * network, child process, and environment operations. Defaults to allowAll.
@@ -327,12 +420,10 @@ export interface AgentOsOptions {
327
420
  */
328
421
  onAgentStderr?: AgentStderrHandler;
329
422
  /**
330
- * Called when the ACP adapter process behind a session exits without
331
- * `closeSession()` — i.e. an adapter crash. The sidecar auto-restarts the
332
- * adapter (bounded per session, natively re-attaching the same session id)
333
- * and reports the outcome on the event; only `restart === "restarted"`
334
- * leaves the session usable. Defaults to writing a warning line to
335
- * `process.stderr`.
423
+ * Called when the ACP adapter process behind a session exits unexpectedly.
424
+ * The sidecar evicts the live
425
+ * route and never retries the adapter or interrupted request implicitly.
426
+ * Defaults to writing a warning line to `process.stderr`.
336
427
  */
337
428
  onAgentExit?: AgentExitHandler;
338
429
  /**
@@ -342,85 +433,12 @@ export interface AgentOsOptions {
342
433
  */
343
434
  onLimitWarning?: LimitWarningHandler;
344
435
  }
345
- /** Configuration for a local MCP server (spawned as a child process). */
346
- export interface McpServerConfigLocal {
347
- type: "local";
348
- /** Command to launch the MCP server. */
349
- command: string;
350
- /** Arguments for the command. */
351
- args?: string[];
352
- /** Environment variables for the server process. */
353
- env?: Record<string, string>;
354
- }
355
- /** Configuration for a remote MCP server (connected via URL). */
356
- export interface McpServerConfigRemote {
357
- type: "remote";
358
- /** URL of the remote MCP server. */
359
- url: string;
360
- /** HTTP headers to include in requests to the server. */
361
- headers?: Record<string, string>;
362
- }
363
- export type McpServerConfig = McpServerConfigLocal | McpServerConfigRemote;
364
436
  export interface AgentOsRuntimeAdmin {
365
437
  kernel: Kernel;
366
438
  rootView: VirtualFileSystem;
367
439
  env: Record<string, string>;
368
440
  sidecar: AgentOsSidecar;
369
441
  }
370
- export interface CreateSessionOptions {
371
- /** Working directory for the agent session inside the VM. */
372
- cwd?: string;
373
- /** Environment variables to pass to the agent process. */
374
- env?: Record<string, string>;
375
- /** MCP servers to make available to the agent during the session. */
376
- mcpServers?: McpServerConfig[];
377
- /** Skip OS instructions injection entirely (default false). */
378
- skipOsInstructions?: boolean;
379
- /** Additional instructions appended to the base OS instructions. */
380
- additionalInstructions?: string;
381
- }
382
- /**
383
- * Options for {@link AgentOs.resumeSession}.
384
- *
385
- * Resume depends on a durable root: after a Rivet actor sleeps (VM destroyed) and
386
- * wakes (fresh VM, actor SQLite intact) the caller can keep prompting an existing
387
- * session. On a non-durable (default in-memory) root there is no surviving store,
388
- * so the sidecar's universal fallback tier always runs and the transcript pointer
389
- * is the only continuity mechanism.
390
- */
391
- export interface ResumeSessionOptions {
392
- /**
393
- * Guest-readable path to the reconstructed transcript. When present, the
394
- * fallback tier arms a continuation preamble pointing the agent at it.
395
- */
396
- transcriptPath?: string;
397
- /** Working directory for the resumed agent session (default `/workspace`). */
398
- cwd?: string;
399
- /** Environment variables to pass to the resumed agent process. */
400
- env?: Record<string, string>;
401
- }
402
- /** Result from {@link AgentOs.resumeSession}. */
403
- export interface ResumeSessionResult {
404
- /**
405
- * The live ACP session id in the fresh VM: equal to the requested id for
406
- * native loads, or a freshly assigned id for the fallback tier — the caller
407
- * remaps `external -> live`.
408
- */
409
- sessionId: string;
410
- /** `"native"` (session/load|resume) or `"fallback"` (session/new + preamble). */
411
- mode: string;
412
- }
413
- export interface SessionInfo {
414
- sessionId: string;
415
- agentType: string;
416
- }
417
- /** Result from AgentOs.prompt(). */
418
- export interface PromptResult {
419
- /** Raw JSON-RPC response from the ACP adapter. */
420
- response: JsonRpcResponse;
421
- /** Accumulated agent text output from streamed message chunks. */
422
- text: string;
423
- }
424
442
  /** Information about a process spawned via AgentOs.spawn(). */
425
443
  export interface SpawnedProcessInfo {
426
444
  pid: number;
@@ -432,10 +450,8 @@ export interface SpawnedProcessInfo {
432
450
  export declare class AgentOs {
433
451
  #private;
434
452
  readonly sidecar: AgentOsSidecar;
435
- private _sessions;
436
- private _closedSessionIds;
437
- private _sessionClosePromises;
438
- private _pendingSessionRequestResolvers;
453
+ private _durableSessionEventHandlers;
454
+ private _agentExitHandlers;
439
455
  private _processes;
440
456
  private _shells;
441
457
  private _closedShellIds;
@@ -445,13 +461,12 @@ export declare class AgentOs {
445
461
  private _acpTerminalCounter;
446
462
  private _softwareRoots;
447
463
  private _cronManager;
448
- private _toolKits;
449
- private _toolReference;
464
+ private _bindings;
465
+ private _bindingReference;
450
466
  private _permissions;
451
467
  private _hostMounts;
452
468
  private _env;
453
469
  private _rootFilesystem;
454
- private readonly _additionalInstructions;
455
470
  private _sidecarLease;
456
471
  private readonly _sidecarClient;
457
472
  private readonly _sidecarSession;
@@ -467,19 +482,17 @@ export declare class AgentOs {
467
482
  exec(command: string, options?: KernelExecOptions): Promise<KernelExecResult>;
468
483
  execArgv(command: string, args?: readonly string[], options?: KernelExecOptions): Promise<KernelExecResult>;
469
484
  private _trackProcess;
470
- spawn(command: string, args: string[], options?: KernelSpawnOptions): {
485
+ spawn(command: string, args: string[], options?: SpawnOptions): {
471
486
  pid: number;
472
487
  };
473
488
  /** Write data to a process's stdin. */
474
489
  writeProcessStdin(pid: number, data: string | Uint8Array): Promise<void>;
475
490
  /** Close a process's stdin stream. */
476
491
  closeProcessStdin(pid: number): Promise<void>;
477
- /** Subscribe to stdout data from a process. Returns an unsubscribe function. */
478
- onProcessStdout(pid: number, handler: (data: Uint8Array) => void): () => void;
479
- /** Subscribe to stderr data from a process. Returns an unsubscribe function. */
480
- onProcessStderr(pid: number, handler: (data: Uint8Array) => void): () => void;
492
+ /** Subscribe to stdout and stderr from a process. */
493
+ onProcessOutput(pid: number, handler: (event: ProcessOutput) => void): () => void;
481
494
  /** Subscribe to process exit. Returns an unsubscribe function. */
482
- onProcessExit(pid: number, handler: (exitCode: number) => void): () => void;
495
+ onProcessExit(pid: number, handler: (event: ProcessExit) => void): () => void;
483
496
  /** Wait for a process to exit. Returns the exit code. */
484
497
  waitProcess(pid: number): Promise<number>;
485
498
  private _assertSafeAbsolutePath;
@@ -495,26 +508,26 @@ export declare class AgentOs {
495
508
  recursive?: boolean;
496
509
  }): Promise<void>;
497
510
  readdir(path: string): Promise<string[]>;
511
+ readdirEntries(path: string): Promise<ReaddirEntry[]>;
498
512
  readdirRecursive(path: string, options?: ReaddirRecursiveOptions): Promise<DirEntry[]>;
499
513
  stat(path: string): Promise<VirtualStat>;
500
514
  exists(path: string): Promise<boolean>;
501
- snapshotRootFilesystem(): Promise<RootSnapshotExport>;
515
+ exportRootFilesystem(options: ExportRootFilesystemOptions): Promise<RootSnapshotExport>;
502
516
  /**
503
517
  * Mount a filesystem into the running VM. Resolves once the mount has been
504
518
  * delivered to the native sidecar, so guest code can use it immediately
505
519
  * after the returned promise settles; a delivery failure rejects instead of
506
520
  * leaving the mount silently host-only.
507
521
  */
508
- mountFs(path: string, driver: VirtualFileSystem, options?: {
509
- readOnly?: boolean;
510
- }): Promise<void>;
522
+ mountFs(descriptor: DynamicMountDescriptor): Promise<void>;
511
523
  unmountFs(path: string): Promise<void>;
524
+ listMounts(): Promise<MountInfo[]>;
512
525
  move(from: string, to: string): Promise<void>;
513
- delete(path: string, options?: {
526
+ remove(path: string, options?: {
514
527
  recursive?: boolean;
515
528
  }): Promise<void>;
516
- fetch(port: number, request: Request): Promise<Response>;
517
- openShell(options?: OpenShellOptions): {
529
+ httpRequest(request: HttpRequest): Promise<HttpResponse>;
530
+ openShell(options?: ShellOptions): {
518
531
  shellId: string;
519
532
  };
520
533
  connectTerminal(options?: ConnectTerminalOptions): Promise<number>;
@@ -525,7 +538,11 @@ export declare class AgentOs {
525
538
  * function. `OpenShellOptions.onStderr` is a diagnostic tap for callers that
526
539
  * need channel identity; do not render both surfaces.
527
540
  */
528
- onShellData(shellId: string, handler: (data: Uint8Array) => void): () => void;
541
+ onShellData(shellId: string, handler: (event: ShellData) => void): () => void;
542
+ /** Subscribe to the stderr-only diagnostic stream for a shell. */
543
+ onShellStderr(shellId: string, handler: (event: ShellData) => void): () => void;
544
+ /** Subscribe to shell exit. */
545
+ onShellExit(shellId: string, handler: (event: ShellExit) => void): () => void;
529
546
  /** Notify a shell of terminal resize. */
530
547
  resizeShell(shellId: string, cols: number, rows: number): void;
531
548
  /**
@@ -549,20 +566,29 @@ export declare class AgentOs {
549
566
  stopProcess(pid: number): void;
550
567
  /** Send SIGKILL to force-kill a process. No-op if already exited. */
551
568
  killProcess(pid: number): void;
552
- /** Returns all active sessions with their IDs and agent types. */
553
- listSessions(): SessionInfo[];
554
- /** Internal helper: retrieve a session or throw. */
555
- private _requireSession;
569
+ openSession(input: OpenSessionInput): Promise<void>;
570
+ getSession(input?: SessionTarget): Promise<DurableSessionInfo>;
571
+ listSessions(input?: ListSessionsInput): Promise<SessionPage>;
572
+ deleteSession(input?: SessionTarget): Promise<void>;
573
+ unloadSession(input?: SessionTarget): Promise<void>;
574
+ prompt(input: PromptInput): Promise<DurablePromptResult>;
575
+ cancelPrompt(input?: SessionTarget): Promise<CancelPromptResult>;
576
+ respondPermission(input: PermissionResponse): Promise<PermissionResponseResult>;
577
+ readHistory(input?: ReadHistoryInput): Promise<HistoryPage>;
578
+ getSessionConfig(input?: SessionTarget): Promise<SessionConfig>;
579
+ setSessionConfigOption(input: SetSessionConfigOptionInput): Promise<SessionConfig>;
580
+ getSessionCapabilities(input?: SessionTarget): Promise<SessionCapabilities | null>;
581
+ getSessionAgentInfo(input?: SessionTarget): Promise<SessionAgentInfo | null>;
556
582
  /**
557
583
  * Dynamically link a software package into the RUNNING VM. The package's
558
584
  * `bin/` commands appear under `/opt/agentos/bin` (on `$PATH`) and its `share/man`
559
585
  * pages under MANPATH immediately — the `/opt/agentos` mount is host-backed, so
560
586
  * writing into its staging dir is reflected live with no reboot. An `agent`
561
- * block registers the package for `createSession(name)`. Persists for the VM's
587
+ * block registers the package for `openSession({ agent: name })`. Persists for the VM's
562
588
  * lifetime (and across a snapshot iff the volume persists).
563
589
  */
564
- linkSoftware(descriptor: PackageRef | SoftwarePackageRef): Promise<void>;
565
- providedCommands(): Promise<{
590
+ linkSoftware(descriptor: PackageDescriptor): Promise<void>;
591
+ listSoftware(): Promise<{
566
592
  packageName: string;
567
593
  commands: string[];
568
594
  }[]>;
@@ -573,71 +599,17 @@ export declare class AgentOs {
573
599
  * agent is a package materialized into the VM, so `installed` is always `true`.
574
600
  */
575
601
  listAgents(): Promise<AgentRegistryEntry[]>;
576
- private _syncSessionState;
577
- private _applySessionUpdate;
578
- private _recordSessionNotification;
579
- private _dispatchSessionEvent;
580
- private _subscribeSessionEvents;
581
- /**
582
- * Warn once per session (host-visible) that a tool-permission request was
583
- * auto-denied because no `onPermissionRequest` handler is registered. Shared
584
- * by both the bare-callback and JSON-RPC permission paths so the message and
585
- * the once-per-session guard cannot drift between them.
586
- */
587
- private _warnNoPermissionHandlerOnce;
588
- /** Best-effort human label for the tool named in a permission request. */
589
- private _permissionToolLabel;
590
- /**
591
- * Emit a host-visible warning for a session through the same agent-process log
592
- * channel that surfaces adapter stderr (`onAgentStderr`, default: process
593
- * stderr). Used for agent-os-owned diagnostics — e.g. a permission request
594
- * that was auto-denied because no host hook is registered — so they never fire
595
- * silently inside the sidecar.
596
- */
597
- private _emitSessionWarning;
598
602
  private _recordAgentStderr;
599
603
  private _recordAgentExit;
600
- private _applySyntheticConfigOverrides;
601
604
  private _handleSidecarEvent;
602
605
  private _handleLimitWarning;
603
606
  private _handleAcpExtEvent;
604
- private _unsupportedConfigResponse;
607
+ private _emitDurableSessionEvent;
605
608
  private _sendAcpRequest;
606
- private _sendSessionRequest;
607
- private _setSessionConfigByCategory;
608
- private _removeSession;
609
- private _abortPendingSessionRequests;
610
- private _cancelPendingPromptRequests;
611
- private _rejectPendingPermissionReplies;
612
- private _rejectPendingPermissionRepliesFromSession;
613
- private _closeSessionInternal;
614
- private _hydrateSessionState;
615
- createSession(agentType: AgentType, options?: CreateSessionOptions): Promise<{
616
- sessionId: string;
617
- }>;
618
- /**
619
- * Resume a session that exists in durable storage but is not live in this VM
620
- * (e.g. after a Rivet actor slept and woke with a fresh VM). Thin forwarder:
621
- * resolves the agent config + adapter entrypoint exactly as {@link createSession}
622
- * does, then forwards a single `AcpResumeSessionRequest` to the sidecar, which
623
- * owns the resume state machine (native `session/load` when the agent supports
624
- * it, else `session/new` + a transcript-continuation preamble). The returned
625
- * `sessionId` is the live id in this VM (equal to the requested id for native
626
- * loads, freshly assigned for the fallback); the caller remaps `external -> live`.
627
- * The new live session is registered + hydrated locally so subsequent prompts
628
- * route to it.
629
- *
630
- * Resume depends on a durable root; on a non-durable (default in-memory) root
631
- * there is no surviving store and the fallback tier always runs.
632
- */
633
- resumeSession(sessionId: string, agentType: AgentType, options?: ResumeSessionOptions): Promise<ResumeSessionResult>;
634
609
  private _installSidecarRequestHandler;
635
610
  private _handleAcpExtSidecarRequest;
636
611
  private _dispatchAcpSidecarRequest;
637
612
  private _handleSupportedAcpSidecarRequest;
638
- private _normalizeAcpPermissionOptionId;
639
- private _buildAcpPermissionResult;
640
- private _handleAcpPermissionRequest;
641
613
  private _acpParams;
642
614
  private _requireAcpStringParam;
643
615
  private _optionalAcpStringParam;
@@ -656,29 +628,11 @@ export declare class AgentOs {
656
628
  private _handleAcpKillTerminal;
657
629
  private _handleAcpReleaseTerminal;
658
630
  private _handleAcpResizeTerminal;
659
- private _handleAcpPermissionCallback;
660
- /**
661
- * Gracefully destroy a session: cancel any pending work, close the client,
662
- * and remove from tracking. Unlike close() which is abrupt, this attempts
663
- * a graceful shutdown sequence.
664
- */
665
- destroySession(sessionId: string): Promise<void>;
666
- prompt(sessionId: string, text: string): Promise<PromptResult>;
667
- /** Cancel ongoing agent work for a session. */
668
- cancelSession(sessionId: string): Promise<JsonRpcResponse>;
669
- closeSession(sessionId: string): void;
670
- respondPermission(sessionId: string, permissionId: string, reply: PermissionReply): Promise<JsonRpcResponse>;
671
- setSessionMode(sessionId: string, modeId: string): Promise<JsonRpcResponse>;
672
- getSessionModes(sessionId: string): SessionModeState | null;
673
- setSessionModel(sessionId: string, model: string): Promise<JsonRpcResponse>;
674
- setSessionThoughtLevel(sessionId: string, level: string): Promise<JsonRpcResponse>;
675
- getSessionConfigOptions(sessionId: string): SessionConfigOption[];
676
- getSessionCapabilities(sessionId: string): AgentCapabilities | null;
677
- getSessionAgentInfo(sessionId: string): AgentInfo | null;
678
- rawSessionSend(sessionId: string, method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>;
679
- rawSend(sessionId: string, method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>;
680
- onSessionEvent(sessionId: string, handler: SessionEventHandler): () => void;
681
- onPermissionRequest(sessionId: string, handler: PermissionRequestHandler): () => void;
631
+ onSessionEvent(handler: (entry: SessionStreamEntry) => void): () => void;
632
+ onSessionEvent(sessionId: string | undefined, handler: (entry: SessionStreamEntry) => void): () => void;
633
+ /** Subscribe to unexpected adapter exits without changing session liveness. */
634
+ onAgentExit(handler: AgentExitHandler): () => void;
635
+ onAgentExit(sessionId: string | undefined, handler: AgentExitHandler): () => void;
682
636
  /** Schedule a cron job. Returns a handle with the job ID and a cancel method. */
683
637
  scheduleCron(options: CronJobOptions): CronJob;
684
638
  /** List all registered cron jobs. */