@rivet-dev/agentos-core 0.0.0-main.2f99c77 → 0.0.0-main.5ac5a14

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 (62) hide show
  1. package/README.md +10 -196
  2. package/dist/agent-os.d.ts +508 -271
  3. package/dist/agent-os.js +2277 -1243
  4. package/dist/agentos-package.d.ts +6 -4
  5. package/dist/agentos-package.js +6 -3
  6. package/dist/base-filesystem.js +2 -2
  7. package/dist/{host-tools-zod.d.ts → bindings-zod.d.ts} +1 -1
  8. package/dist/{host-tools-zod.js → bindings-zod.js} +27 -20
  9. package/dist/bindings.d.ts +43 -0
  10. package/dist/bindings.js +34 -0
  11. package/dist/code-execution.d.ts +70 -0
  12. package/dist/code-execution.js +115 -0
  13. package/dist/cron/cron-manager.js +43 -10
  14. package/dist/cron/index.d.ts +1 -1
  15. package/dist/cron/types.d.ts +25 -9
  16. package/dist/filesystem-snapshot.d.ts +1 -2
  17. package/dist/filesystem-snapshot.js +0 -43
  18. package/dist/generated/AcpLimitsConfig.d.ts +16 -0
  19. package/dist/generated/BindingLimitsConfig.d.ts +10 -0
  20. package/dist/generated/CreateVmConfig.d.ts +2 -0
  21. package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
  22. package/dist/generated/ProcessLimitsConfig.js +2 -0
  23. package/dist/generated/VmGroupConfig.d.ts +5 -0
  24. package/dist/generated/VmGroupConfig.js +2 -0
  25. package/dist/generated/VmLimitsConfig.d.ts +4 -2
  26. package/dist/generated/VmUserAccountConfig.d.ts +9 -0
  27. package/dist/generated/VmUserAccountConfig.js +2 -0
  28. package/dist/generated/VmUserConfig.d.ts +19 -0
  29. package/dist/generated/WasmLimitsConfig.d.ts +1 -0
  30. package/dist/index.d.ts +7 -5
  31. package/dist/index.js +5 -5
  32. package/dist/language-execution.d.ts +170 -0
  33. package/dist/language-execution.js +1 -0
  34. package/dist/layers.d.ts +5 -2
  35. package/dist/layers.js +0 -185
  36. package/dist/options-schema.d.ts +150 -31
  37. package/dist/options-schema.js +159 -26
  38. package/dist/packages.d.ts +1 -1
  39. package/dist/runtime-compat.d.ts +6 -35
  40. package/dist/runtime-compat.js +85 -373
  41. package/dist/runtime.d.ts +5 -1
  42. package/dist/sandbox.d.ts +4 -4
  43. package/dist/sandbox.js +34 -21
  44. package/dist/session-api.d.ts +180 -0
  45. package/dist/session-api.js +1 -0
  46. package/dist/sidecar/agentos-protocol.d.ts +434 -32
  47. package/dist/sidecar/agentos-protocol.js +693 -93
  48. package/dist/sidecar/rpc-client.d.ts +18 -6
  49. package/dist/sidecar/rpc-client.js +88 -39
  50. package/dist/test/runtime.d.ts +2 -1
  51. package/dist/test/runtime.js +2 -1
  52. package/dist/test/terminal-harness.js +0 -3
  53. package/dist/types.d.ts +7 -6
  54. package/package.json +38 -28
  55. package/dist/agent-session-types.d.ts +0 -67
  56. package/dist/generated/ToolLimitsConfig.d.ts +0 -10
  57. package/dist/host-tools.d.ts +0 -45
  58. package/dist/host-tools.js +0 -35
  59. package/dist/overlay-filesystem.d.ts +0 -19
  60. package/dist/overlay-filesystem.js +0 -645
  61. /package/dist/generated/{ToolLimitsConfig.js → BindingLimitsConfig.js} +0 -0
  62. /package/dist/{agent-session-types.js → generated/VmUserConfig.js} +0 -0
@@ -1,15 +1,16 @@
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";
5
- import type { ConnectTerminalOptions, Kernel, KernelExecOptions, KernelExecResult, ProcessInfo as KernelProcessInfo, KernelSpawnOptions, OpenShellOptions, Permissions, VirtualFileSystem, VirtualStat } from "./runtime-compat.js";
2
+ import type { VmUserConfig } from "@rivet-dev/agentos-runtime-core/vm-config";
3
+ import { type Bindings } from "./bindings.js";
4
+ import type { CodeEvaluationResult, CodeExecutionResult, ContextDescriptor, ExecutionSignal, InlineExecutionOptions, JavaScriptEvaluationOptions, JavaScriptExecutionOptions, LanguageExecutionOptions, LanguageSpawnOptions, NpmPackageInstallOptions, NpmProjectInstallOptions, OutputReplay, ProcessDescriptor, ProcessExit, PythonInstallOptions, SpawnOptions, TypeScriptCheckOptions, TypeScriptCheckResult, TypeScriptEvaluationOptions, TypeScriptExecutionOptions, TypeScriptFileExecutionOptions } from "./language-execution.js";
5
+ import type { ConnectTerminalOptions, Kernel, KernelExecOptions, KernelExecResult, OpenShellOptions, Permissions, VirtualFileSystem, VirtualStat } from "./runtime-compat.js";
6
+ import { type AgentOsSandboxInput } from "./sandbox.js";
7
+ import type { CancelPromptResult, PromptResult as DurablePromptResult, SessionInfo as DurableSessionInfo, HistoryPage, JsonValue, ListSessionsInput, OpenSessionInput, PermissionResponse, PermissionResponseResult, PromptInput, ReadHistoryInput, SessionAgentInfo, SessionCapabilities, SessionConfig, SessionPage, SessionStreamEntry, SessionTarget, SetSessionConfigOptionInput } from "./session-api.js";
6
8
  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
9
  export type { ConnectTerminalOptions } from "./runtime-compat.js";
11
- /** Process tree node: extends kernel ProcessInfo with child references. */
12
- export interface ProcessTreeNode extends KernelProcessInfo {
10
+ export type * from "./session-api.js";
11
+ /** Process tree node using the same descriptor shape as process.get/list. */
12
+ export interface ProcessTreeNode extends ProcessDescriptor {
13
+ ppid?: number;
13
14
  children: ProcessTreeNode[];
14
15
  }
15
16
  /** A directory entry with metadata. */
@@ -19,6 +20,58 @@ export interface DirEntry {
19
20
  type: "file" | "directory" | "symlink";
20
21
  size: number;
21
22
  }
23
+ /** One immediate child returned by a single readdirEntries operation. */
24
+ export interface ReaddirEntry {
25
+ name: string;
26
+ isDirectory: boolean;
27
+ isSymbolicLink: boolean;
28
+ }
29
+ /** Fully buffered request to an HTTP service listening inside the VM. */
30
+ export interface HttpRequest {
31
+ port: number;
32
+ path: string;
33
+ method?: string;
34
+ headers?: Record<string, string>;
35
+ body?: string | Uint8Array;
36
+ }
37
+ /** Fully buffered HTTP response from a service inside the VM. */
38
+ export interface HttpResponse {
39
+ status: number;
40
+ statusText: string;
41
+ headers: Record<string, string>;
42
+ body: Uint8Array;
43
+ }
44
+ export interface ProcessOutput {
45
+ pid: number;
46
+ stream: "stdout" | "stderr";
47
+ data: Uint8Array;
48
+ }
49
+ export interface ShellData {
50
+ shellId: string;
51
+ data: Uint8Array;
52
+ }
53
+ export interface ShellExit {
54
+ shellId: string;
55
+ exitCode: number;
56
+ }
57
+ /** Sanitized live mount metadata. Plugin configuration is never exposed. */
58
+ export interface MountInfo {
59
+ path: string;
60
+ kind: string;
61
+ readOnly: boolean;
62
+ }
63
+ export interface ExportRootFilesystemOptions {
64
+ /** Maximum serialized snapshot bytes returned to this caller. */
65
+ maxBytes: number;
66
+ }
67
+ /** Portable, sidecar-owned dynamic mount descriptor. */
68
+ export interface DynamicMountDescriptor {
69
+ path: string;
70
+ plugin: NativeMountPluginDescriptor;
71
+ readOnly?: boolean;
72
+ }
73
+ /** Callback-free options accepted by the portable openShell API. */
74
+ export type ShellOptions = Omit<OpenShellOptions, "onStderr">;
22
75
  /** Options for readdirRecursive(). */
23
76
  export interface ReaddirRecursiveOptions {
24
77
  /** Maximum depth to recurse (0 = only immediate children). */
@@ -47,15 +100,12 @@ export interface BatchReadResult {
47
100
  export interface AgentRegistryEntry {
48
101
  id: string;
49
102
  installed: boolean;
50
- /** Guest entrypoint the sidecar launches for this agent (`/opt/agentos/bin/<acpEntrypoint>`). */
51
- adapterEntrypoint: string;
52
103
  }
53
- import type { AgentType } from "./types.js";
104
+ import { type PackageDescriptor } from "./agentos-package.js";
54
105
  import type { ScheduleDriver } from "./cron/schedule-driver.js";
55
106
  import type { CronEventHandler, CronJob, CronJobInfo, CronJobOptions } from "./cron/types.js";
56
107
  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";
108
+ import type { SoftwareInput } from "./packages.js";
59
109
  import { type AgentOsSidecarPlacement } from "./sidecar/rpc-client.js";
60
110
  export interface AgentOsSharedSidecarOptions {
61
111
  pool?: string;
@@ -79,12 +129,27 @@ export interface AgentOsSidecarDescription {
79
129
  export type RootLowerInput = {
80
130
  kind: "bundled-base-filesystem";
81
131
  } | RootSnapshotExport;
82
- export interface RootFilesystemConfig {
132
+ export interface OverlayRootFilesystemConfig {
83
133
  type?: "overlay";
84
134
  mode?: OverlayFilesystemMode;
85
135
  disableDefaultBaseLayer?: boolean;
86
136
  lowers?: RootLowerInput[];
87
137
  }
138
+ /** Declarative sidecar-native root filesystem. */
139
+ export interface NativeRootFilesystemConfig {
140
+ type: "native";
141
+ plugin: NativeMountPluginDescriptor;
142
+ readOnly?: boolean;
143
+ }
144
+ export type RootFilesystemConfig = OverlayRootFilesystemConfig | NativeRootFilesystemConfig;
145
+ /** VM-scoped SQLite storage shared by VFS and AgentOS durable state. */
146
+ export type VmSqliteConfig = {
147
+ type: "actor_uds";
148
+ path: string;
149
+ } | {
150
+ type: "sqlite_file";
151
+ path: string;
152
+ };
88
153
  /**
89
154
  * Compatibility path for arbitrary caller-supplied filesystems.
90
155
  * This maps to the sidecar `js_bridge` plugin during the migration.
@@ -94,6 +159,10 @@ export interface PlainMountConfig {
94
159
  path: string;
95
160
  /** The filesystem driver to mount. */
96
161
  driver: VirtualFileSystem;
162
+ /** Filesystem type exposed through guest mount discovery. */
163
+ guestFstype?: string;
164
+ /** Source name exposed through guest mount discovery. */
165
+ guestSource?: string;
97
166
  /** If true, write operations throw EROFS. */
98
167
  readOnly?: boolean;
99
168
  }
@@ -101,6 +170,10 @@ export interface PlainMountConfig {
101
170
  export interface NativeMountConfig {
102
171
  path: string;
103
172
  plugin: NativeMountPluginDescriptor;
173
+ /** Filesystem type exposed through guest mount discovery. */
174
+ guestFstype?: string;
175
+ /** Source name exposed through guest mount discovery. */
176
+ guestSource?: string;
104
177
  readOnly?: boolean;
105
178
  }
106
179
  export interface OverlayMountConfig {
@@ -146,29 +219,46 @@ export interface AgentOsLimits {
146
219
  };
147
220
  /** HTTP body buffering limits. */
148
221
  http?: {
149
- /** Cap on `vm.fetch()` buffered response bodies. Must be <= the sidecar wire frame cap. */
222
+ /** Cap on `vm.httpRequest()` buffered response bodies. Must be <= the sidecar wire frame cap. */
150
223
  maxFetchResponseBytes?: number;
151
224
  };
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;
225
+ /** TLS plaintext buffering limits. */
226
+ tls?: {
227
+ maxBufferedBytes?: number;
228
+ };
229
+ /** Host binding registration and invocation limits. */
230
+ bindings?: {
231
+ defaultBindingTimeoutMs?: number;
232
+ maxBindingTimeoutMs?: number;
233
+ maxRegisteredCollections?: number;
234
+ maxRegisteredBindingsPerVm?: number;
235
+ maxBindingsPerCollection?: number;
236
+ maxBindingSchemaBytes?: number;
237
+ maxExamplesPerBinding?: number;
238
+ maxBindingExampleInputBytes?: number;
162
239
  };
163
240
  /** Mount plugin manifest size limits. */
164
241
  plugins?: {
165
242
  maxPersistedManifestBytes?: number;
166
243
  maxPersistedManifestFileBytes?: number;
167
244
  };
168
- /** ACP adapter buffering limits. */
245
+ /** ACP adapter, active-turn, history-retention, and page limits. */
169
246
  acp?: {
170
247
  maxReadLineBytes?: number;
171
248
  stdoutBufferByteLimit?: number;
249
+ maxCompletedMessageBytes?: number;
250
+ maxTurnOutputBytes?: number;
251
+ maxPromptBytes?: number;
252
+ maxPromptBlocks?: number;
253
+ maxFallbackContinuationBytes?: number;
254
+ maxSessionHistoryBytes?: number;
255
+ maxSessionHistoryEvents?: number;
256
+ maxHistoryPageEntries?: number;
257
+ maxSessionListEntries?: number;
258
+ };
259
+ /** Shared local-file/actor-UDS SQLite result materialization limit. */
260
+ sqlite?: {
261
+ maxResultBytes?: number;
172
262
  };
173
263
  /** Guest JavaScript runtime buffering limits. */
174
264
  jsRuntime?: {
@@ -196,6 +286,15 @@ export interface AgentOsLimits {
196
286
  syncReadLimitBytes?: number;
197
287
  prewarmTimeoutMs?: number;
198
288
  runnerHeapLimitMb?: number;
289
+ runnerCpuTimeLimitMs?: number;
290
+ };
291
+ /** Process spawn, I/O, and lifecycle-event backlog limits. */
292
+ process?: {
293
+ maxSpawnFileActions?: number;
294
+ maxSpawnFileActionBytes?: number;
295
+ pendingStdinBytes?: number;
296
+ pendingEventCount?: number;
297
+ pendingEventBytes?: number;
199
298
  };
200
299
  }
201
300
  export interface AgentStderrEvent {
@@ -207,20 +306,14 @@ export interface AgentStderrEvent {
207
306
  }
208
307
  export type AgentStderrHandler = (event: AgentStderrEvent) => void;
209
308
  /**
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.
309
+ * Restart disposition reported on an {@link AgentExitEvent}. AgentOS never
310
+ * respawns an adapter or replays an interrupted request implicitly.
218
311
  */
219
- export type AgentRestartOutcome = "restarted" | "unsupported" | "failed" | "exhausted";
312
+ export type AgentRestartOutcome = "not_attempted";
220
313
  /**
221
314
  * 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.
315
+ * perspective (any spontaneous exit before `unloadSession()`, including exit
316
+ * code 0). The live route is evicted and must be restored explicitly.
224
317
  */
225
318
  export interface AgentExitEvent {
226
319
  sessionId: string;
@@ -230,11 +323,11 @@ export interface AgentExitEvent {
230
323
  pid: number | null;
231
324
  /** Adapter exit code; `null` when the exit was observed indirectly. */
232
325
  exitCode: number | null;
233
- /** Auto-restart outcome; only `"restarted"` leaves the session usable. */
326
+ /** Always `"not_attempted"`; AgentOS does not restart adapters implicitly. */
234
327
  restart: AgentRestartOutcome;
235
- /** Restarts consumed for this session so far. */
328
+ /** Always zero. */
236
329
  restartCount: number;
237
- /** Per-session restart budget. */
330
+ /** Always zero. */
238
331
  maxRestarts: number;
239
332
  }
240
333
  export type AgentExitHandler = (event: AgentExitEvent) => void;
@@ -261,11 +354,12 @@ export type LimitWarningHandler = (warning: LimitWarning) => void;
261
354
  * Public core VM options.
262
355
  *
263
356
  * 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`.
357
+ * `packages/core/src/options-schema.ts::agentOsOptionsSchema`. The TypeScript
358
+ * Rivet actor accepts this surface directly alongside ordinary actor options.
267
359
  */
268
360
  export interface AgentOsOptions {
361
+ /** Initial virtual Linux credentials and account record. Defaults to `1000:1000` (`agentos`). */
362
+ user?: VmUserConfig;
269
363
  /**
270
364
  * Software to install in the VM. Each entry is a package-dir ref. Arrays are
271
365
  * flattened, so meta-packages that export arrays of sub-packages work directly.
@@ -294,16 +388,18 @@ export interface AgentOsOptions {
294
388
  * profiling workloads.
295
389
  */
296
390
  highResolutionTime?: boolean;
391
+ /** Durable SQLite storage for VM-owned filesystem and session state. */
392
+ database?: VmSqliteConfig;
297
393
  /** Root filesystem configuration. Defaults to an overlay with the bundled base snapshot as its deepest lower. */
298
394
  rootFilesystem?: RootFilesystemConfig;
299
395
  /** Filesystems to mount at boot time. */
300
396
  mounts?: MountConfig[];
301
- /** Additional instructions appended to the base OS system prompt injected at session start. */
302
- additionalInstructions?: string;
397
+ /** External sandbox mounted into this VM with process bindings. */
398
+ sandbox?: AgentOsSandboxInput;
303
399
  /** Custom schedule driver for cron jobs. Defaults to TimerScheduleDriver. */
304
400
  scheduleDriver?: ScheduleDriver;
305
- /** Host-side toolkits available to agents inside the VM. */
306
- toolKits?: ToolKit[];
401
+ /** Host-side bindings available to agents inside the VM. */
402
+ bindings?: Bindings[];
307
403
  /**
308
404
  * Custom permission policy for the kernel. Controls access to filesystem,
309
405
  * network, child process, and environment operations. Defaults to allowAll.
@@ -327,12 +423,10 @@ export interface AgentOsOptions {
327
423
  */
328
424
  onAgentStderr?: AgentStderrHandler;
329
425
  /**
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`.
426
+ * Called when the ACP adapter process behind a session exits unexpectedly.
427
+ * The sidecar evicts the live
428
+ * route and never retries the adapter or interrupted request implicitly.
429
+ * Defaults to writing a warning line to `process.stderr`.
336
430
  */
337
431
  onAgentExit?: AgentExitHandler;
338
432
  /**
@@ -342,101 +436,22 @@ export interface AgentOsOptions {
342
436
  */
343
437
  onLimitWarning?: LimitWarningHandler;
344
438
  }
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
439
  export interface AgentOsRuntimeAdmin {
365
440
  kernel: Kernel;
366
441
  rootView: VirtualFileSystem;
367
442
  env: Record<string, string>;
368
443
  sidecar: AgentOsSidecar;
369
444
  }
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
- /** Information about a process spawned via AgentOs.spawn(). */
425
- export interface SpawnedProcessInfo {
426
- pid: number;
427
- command: string;
428
- args: string[];
429
- running: boolean;
430
- exitCode: number | null;
431
- }
432
445
  export declare class AgentOs {
433
446
  #private;
434
447
  readonly sidecar: AgentOsSidecar;
435
- private _sessions;
436
- private _closedSessionIds;
437
- private _sessionClosePromises;
438
- private _pendingSessionRequestResolvers;
448
+ private _durableSessionEventHandlers;
449
+ private _agentExitHandlers;
439
450
  private _processes;
451
+ private _languageProcesses;
452
+ private _languageProcessIds;
453
+ private _executionOutputHandlers;
454
+ private _executionCompletedHandlers;
440
455
  private _shells;
441
456
  private _closedShellIds;
442
457
  private _pendingShellExitPromises;
@@ -445,13 +460,12 @@ export declare class AgentOs {
445
460
  private _acpTerminalCounter;
446
461
  private _softwareRoots;
447
462
  private _cronManager;
448
- private _toolKits;
449
- private _toolReference;
463
+ private _bindings;
464
+ private _bindingReference;
450
465
  private _permissions;
451
466
  private _hostMounts;
452
467
  private _env;
453
468
  private _rootFilesystem;
454
- private readonly _additionalInstructions;
455
469
  private _sidecarLease;
456
470
  private readonly _sidecarClient;
457
471
  private readonly _sidecarSession;
@@ -460,180 +474,415 @@ export declare class AgentOs {
460
474
  private readonly _agentStderrHandler?;
461
475
  private readonly _agentExitHandler?;
462
476
  private readonly _limitWarningHandler?;
477
+ private readonly _disposeHooks;
478
+ /**
479
+ * Execute commands and manage child processes in the VM.
480
+ *
481
+ * `exec` evaluates a command with the configured shell, while `execFile`
482
+ * invokes an executable directly with an argv array.
483
+ */
484
+ readonly process: {
485
+ exec: (command: string, options?: LanguageExecutionOptions) => Promise<CodeExecutionResult>;
486
+ execFile: (command: string, args?: readonly string[], options?: Omit<LanguageExecutionOptions, "args">) => Promise<CodeExecutionResult>;
487
+ spawn: (command: string, args?: string[], options?: SpawnOptions) => Promise<ProcessDescriptor>;
488
+ get: (pid: number) => Promise<ProcessDescriptor>;
489
+ list: () => Promise<ProcessDescriptor[]>;
490
+ tree: () => Promise<ProcessTreeNode[]>;
491
+ wait: (pid: number) => Promise<ProcessExit>;
492
+ signal: (pid: number, signal: ExecutionSignal) => Promise<void>;
493
+ kill: (pid: number) => Promise<void>;
494
+ writeStdin: (pid: number, data: string | Uint8Array) => Promise<void>;
495
+ closeStdin: (pid: number) => Promise<void>;
496
+ resizePty: (pid: number, size: {
497
+ cols: number;
498
+ rows: number;
499
+ }) => Promise<void>;
500
+ readOutput: (pid: number, options?: {
501
+ after?: number;
502
+ }) => Promise<OutputReplay>;
503
+ };
504
+ readonly javascript: {
505
+ execute: (source: string, options?: JavaScriptExecutionOptions) => Promise<CodeExecutionResult>;
506
+ evaluate: <T = JsonValue>(expression: string, options?: JavaScriptEvaluationOptions) => Promise<CodeEvaluationResult<T>>;
507
+ executeFile: (path: string, options?: LanguageExecutionOptions) => Promise<CodeExecutionResult>;
508
+ spawn: (source: string, options?: LanguageSpawnOptions) => Promise<ProcessDescriptor>;
509
+ spawnFile: (path: string, options?: LanguageSpawnOptions) => Promise<ProcessDescriptor>;
510
+ npm: {
511
+ install: {
512
+ (options?: NpmProjectInstallOptions): Promise<CodeExecutionResult>;
513
+ (packages: string | string[], options?: NpmPackageInstallOptions): Promise<CodeExecutionResult>;
514
+ };
515
+ runScript: (script: string, options?: LanguageExecutionOptions) => Promise<CodeExecutionResult>;
516
+ runPackage: (packageSpec: string, options?: LanguageExecutionOptions & {
517
+ binary?: string;
518
+ }) => Promise<CodeExecutionResult>;
519
+ };
520
+ };
521
+ readonly typescript: {
522
+ execute: (source: string, options?: TypeScriptExecutionOptions) => Promise<CodeExecutionResult>;
523
+ evaluate: <T = JsonValue>(expression: string, options?: TypeScriptEvaluationOptions) => Promise<CodeEvaluationResult<T>>;
524
+ executeFile: (path: string, options?: TypeScriptFileExecutionOptions) => Promise<CodeExecutionResult>;
525
+ spawn: (source: string, options?: LanguageSpawnOptions) => Promise<ProcessDescriptor>;
526
+ spawnFile: (path: string, options?: LanguageSpawnOptions) => Promise<ProcessDescriptor>;
527
+ check: (source: string, options?: TypeScriptCheckOptions) => Promise<TypeScriptCheckResult>;
528
+ checkProject: (options?: Omit<TypeScriptCheckOptions, "filePath" | "compilerOptions">) => Promise<TypeScriptCheckResult>;
529
+ };
530
+ readonly python: {
531
+ execute: (source: string, options?: InlineExecutionOptions) => Promise<CodeExecutionResult>;
532
+ evaluate: <T = JsonValue>(expression: string, options?: InlineExecutionOptions) => Promise<CodeEvaluationResult<T>>;
533
+ executeFile: (path: string, options?: LanguageExecutionOptions) => Promise<CodeExecutionResult>;
534
+ executeModule: (module: string, options?: LanguageExecutionOptions) => Promise<CodeExecutionResult>;
535
+ spawn: (source: string, options?: LanguageSpawnOptions) => Promise<ProcessDescriptor>;
536
+ spawnFile: (path: string, options?: LanguageSpawnOptions) => Promise<ProcessDescriptor>;
537
+ spawnModule: (module: string, options?: LanguageSpawnOptions) => Promise<ProcessDescriptor>;
538
+ install: {
539
+ (options?: PythonInstallOptions): Promise<CodeExecutionResult>;
540
+ (packages: string | string[], options?: PythonInstallOptions): Promise<CodeExecutionResult>;
541
+ };
542
+ };
543
+ readonly contexts: {
544
+ get: (contextId: string) => Promise<ContextDescriptor>;
545
+ list: () => Promise<ContextDescriptor[]>;
546
+ reset: (contextId: string) => Promise<void>;
547
+ delete: (contextId: string) => Promise<void>;
548
+ };
549
+ readonly terminal: {
550
+ open: (options?: ShellOptions) => {
551
+ shellId: string;
552
+ };
553
+ write: (shellId: string, data: string | Uint8Array) => Promise<void>;
554
+ resize: (shellId: string, cols: number, rows: number) => void;
555
+ wait: (shellId: string) => Promise<number>;
556
+ close: (shellId: string) => void;
557
+ };
558
+ readonly filesystem: {
559
+ readFile: (path: string) => Promise<Uint8Array>;
560
+ writeFile: (path: string, content: string | Uint8Array) => Promise<void>;
561
+ readFiles: (paths: string[]) => Promise<BatchReadResult[]>;
562
+ writeFiles: (entries: BatchWriteEntry[]) => Promise<BatchWriteResult[]>;
563
+ stat: (path: string) => Promise<VirtualStat>;
564
+ mkdir: (path: string, options?: {
565
+ recursive?: boolean;
566
+ }) => Promise<void>;
567
+ readdir: (path: string) => Promise<string[]>;
568
+ readdirEntries: (path: string) => Promise<ReaddirEntry[]>;
569
+ readdirRecursive: (path: string, options?: ReaddirRecursiveOptions) => Promise<DirEntry[]>;
570
+ exists: (path: string) => Promise<boolean>;
571
+ move: (from: string, to: string) => Promise<void>;
572
+ remove: (path: string, options?: {
573
+ recursive?: boolean;
574
+ }) => Promise<void>;
575
+ export: (options: ExportRootFilesystemOptions) => Promise<RootSnapshotExport>;
576
+ mount: (descriptor: DynamicMountDescriptor) => Promise<void>;
577
+ unmount: (path: string) => Promise<void>;
578
+ listMounts: () => Promise<MountInfo[]>;
579
+ };
580
+ readonly network: {
581
+ httpRequest: (request: HttpRequest) => Promise<HttpResponse>;
582
+ };
583
+ readonly software: {
584
+ list: () => Promise<{
585
+ packageName: string;
586
+ commands: string[];
587
+ }[]>;
588
+ link: (descriptor: PackageDescriptor) => Promise<void>;
589
+ };
590
+ readonly agents: {
591
+ list: () => Promise<AgentRegistryEntry[]>;
592
+ };
593
+ readonly sessions: {
594
+ open: (input: OpenSessionInput) => Promise<void>;
595
+ get: (input?: SessionTarget) => Promise<DurableSessionInfo>;
596
+ list: (input?: ListSessionsInput) => Promise<SessionPage>;
597
+ delete: (input?: SessionTarget) => Promise<void>;
598
+ unload: (input?: SessionTarget) => Promise<void>;
599
+ prompt: (input: PromptInput) => Promise<DurablePromptResult>;
600
+ cancelPrompt: (input?: SessionTarget) => Promise<CancelPromptResult>;
601
+ respondPermission: (input: PermissionResponse) => Promise<PermissionResponseResult>;
602
+ readHistory: (input?: ReadHistoryInput) => Promise<HistoryPage>;
603
+ getConfig: (input?: SessionTarget) => Promise<SessionConfig>;
604
+ setConfigOption: (input: SetSessionConfigOptionInput) => Promise<SessionConfig>;
605
+ getCapabilities: (input?: SessionTarget) => Promise<SessionCapabilities | null>;
606
+ getAgentInfo: (input?: SessionTarget) => Promise<SessionAgentInfo | null>;
607
+ };
608
+ readonly cron: {
609
+ schedule: (options: CronJobOptions) => CronJob;
610
+ list: () => CronJobInfo[];
611
+ cancel: (id: string) => void;
612
+ };
463
613
  private constructor();
464
614
  static createSidecar(options?: AgentOsCreateSidecarOptions): Promise<AgentOsSidecar>;
465
615
  static getSharedSidecar(options?: AgentOsSharedSidecarOptions): Promise<AgentOsSidecar>;
466
616
  static create(options?: AgentOsOptions): Promise<AgentOs>;
617
+ createContext(contextId: string): Promise<void>;
618
+ private _executionOperation;
619
+ private _spawnLanguageOperation;
620
+ private _exec;
621
+ private _execFile;
622
+ /** @deprecated Use `process.exec()` for lifecycle-aware execution. */
467
623
  exec(command: string, options?: KernelExecOptions): Promise<KernelExecResult>;
624
+ /** @deprecated Use `process.execFile()` for lifecycle-aware execution. */
468
625
  execArgv(command: string, args?: readonly string[], options?: KernelExecOptions): Promise<KernelExecResult>;
626
+ private _executeJavaScript;
627
+ private _evaluationOperation;
628
+ private _evaluateJavaScript;
629
+ private _executeJavaScriptFile;
630
+ private _spawnJavaScript;
631
+ private _spawnJavaScriptFile;
632
+ private _executeTypeScript;
633
+ private _evaluateTypeScript;
634
+ private _executeTypeScriptFile;
635
+ private _spawnTypeScript;
636
+ private _spawnTypeScriptFile;
637
+ private _checkTypeScript;
638
+ private _checkTypeScriptProject;
639
+ private _installNpmPackages;
640
+ private _executeNpmScript;
641
+ private _executeNpmPackage;
642
+ private _executePython;
643
+ private _evaluatePython;
644
+ private _executePythonFile;
645
+ private _executePythonModule;
646
+ private _spawnPython;
647
+ private _spawnPythonFile;
648
+ private _spawnPythonModule;
649
+ private _installPythonPackages;
650
+ private _getContext;
651
+ private _listContexts;
652
+ private _waitExecutionResult;
653
+ private _cancelExecution;
654
+ private _signalExecution;
655
+ private _resetContext;
656
+ private _descriptorLifecycleRequest;
657
+ private _deleteContext;
658
+ private _writeExecutionStdin;
659
+ private _closeExecutionStdin;
660
+ private _resizeExecutionPty;
661
+ private _readExecutionOutput;
662
+ private _onExecutionOutput;
663
+ private _onExecutionCompleted;
469
664
  private _trackProcess;
470
- spawn(command: string, args: string[], options?: KernelSpawnOptions): {
471
- pid: number;
472
- };
665
+ private _spawnProcess;
666
+ spawn(command: string, args?: string[], options?: SpawnOptions): Promise<ProcessDescriptor>;
473
667
  /** Write data to a process's stdin. */
474
- writeProcessStdin(pid: number, data: string | Uint8Array): Promise<void>;
668
+ private _writeProcessStdin;
475
669
  /** Close a process's stdin stream. */
476
- 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;
670
+ private _closeProcessStdin;
671
+ /** Subscribe to stdout and stderr from a process. */
672
+ onProcessOutput(pid: number, handler: (event: ProcessOutput) => void): () => void;
481
673
  /** Subscribe to process exit. Returns an unsubscribe function. */
482
- onProcessExit(pid: number, handler: (exitCode: number) => void): () => void;
674
+ onProcessExit(pid: number, handler: (event: ProcessExit) => void): () => void;
483
675
  /** Wait for a process to exit. Returns the exit code. */
484
- waitProcess(pid: number): Promise<number>;
676
+ private _waitProcess;
485
677
  private _assertSafeAbsolutePath;
486
678
  private _assertWritableAbsolutePath;
487
679
  private _vfs;
680
+ private _readFile;
681
+ private _writeFile;
682
+ private _writeFiles;
683
+ private _readFiles;
684
+ /** Recursively create directories (mkdir -p). */
685
+ private _mkdirp;
686
+ private _mkdir;
687
+ private _readdir;
688
+ private _readdirEntries;
689
+ private _readdirRecursive;
690
+ private _stat;
691
+ private _exists;
692
+ private _exportRootFilesystem;
693
+ /**
694
+ * Mount a filesystem into the running VM. Resolves once the mount has been
695
+ * delivered to the native sidecar, so guest code can use it immediately
696
+ * after the returned promise settles; a delivery failure rejects instead of
697
+ * leaving the mount silently host-only.
698
+ */
699
+ private _mountFs;
700
+ private _unmountFs;
701
+ private _listMounts;
702
+ private _move;
703
+ private _remove;
704
+ /** @deprecated Use `filesystem.readFile()`. */
488
705
  readFile(path: string): Promise<Uint8Array>;
706
+ /** @deprecated Use `filesystem.writeFile()`. */
489
707
  writeFile(path: string, content: string | Uint8Array): Promise<void>;
708
+ /** @deprecated Use `filesystem.writeFiles()`. */
490
709
  writeFiles(entries: BatchWriteEntry[]): Promise<BatchWriteResult[]>;
710
+ /** @deprecated Use `filesystem.readFiles()`. */
491
711
  readFiles(paths: string[]): Promise<BatchReadResult[]>;
492
- /** Recursively create directories (mkdir -p). */
493
- private _mkdirp;
712
+ /** @deprecated Use `filesystem.mkdir()`. */
494
713
  mkdir(path: string, options?: {
495
714
  recursive?: boolean;
496
715
  }): Promise<void>;
716
+ /** @deprecated Use `filesystem.readdir()`. */
497
717
  readdir(path: string): Promise<string[]>;
718
+ /** @deprecated Use `filesystem.readdirEntries()`. */
719
+ readdirEntries(path: string): Promise<ReaddirEntry[]>;
720
+ /** @deprecated Use `filesystem.readdirRecursive()`. */
498
721
  readdirRecursive(path: string, options?: ReaddirRecursiveOptions): Promise<DirEntry[]>;
722
+ /** @deprecated Use `filesystem.stat()`. */
499
723
  stat(path: string): Promise<VirtualStat>;
724
+ /** @deprecated Use `filesystem.exists()`. */
500
725
  exists(path: string): Promise<boolean>;
501
- snapshotRootFilesystem(): Promise<RootSnapshotExport>;
502
- /**
503
- * Mount a filesystem into the running VM. Resolves once the mount has been
504
- * delivered to the native sidecar, so guest code can use it immediately
505
- * after the returned promise settles; a delivery failure rejects instead of
506
- * leaving the mount silently host-only.
507
- */
508
- mountFs(path: string, driver: VirtualFileSystem, options?: {
509
- readOnly?: boolean;
510
- }): Promise<void>;
726
+ /** @deprecated Use `filesystem.export()`. */
727
+ exportRootFilesystem(options: ExportRootFilesystemOptions): Promise<RootSnapshotExport>;
728
+ /** @deprecated Use `filesystem.mount()`. */
729
+ mountFs(descriptor: DynamicMountDescriptor): Promise<void>;
730
+ /** @deprecated Use `filesystem.unmount()`. */
511
731
  unmountFs(path: string): Promise<void>;
732
+ /** @deprecated Use `filesystem.listMounts()`. */
733
+ listMounts(): Promise<MountInfo[]>;
734
+ /** @deprecated Use `filesystem.move()`. */
512
735
  move(from: string, to: string): Promise<void>;
513
- delete(path: string, options?: {
736
+ /** @deprecated Use `filesystem.remove()`. */
737
+ remove(path: string, options?: {
514
738
  recursive?: boolean;
515
739
  }): Promise<void>;
740
+ private _httpRequest;
741
+ /** @deprecated Use `network.httpRequest()`. */
742
+ httpRequest(request: HttpRequest): Promise<HttpResponse>;
743
+ /**
744
+ * Fetch an HTTP endpoint inside the VM while preserving duplicate response
745
+ * headers and arbitrary binary bodies. agentOS Apps uses this compatibility
746
+ * surface for its direct actor API.
747
+ */
516
748
  fetch(port: number, request: Request): Promise<Response>;
517
- openShell(options?: OpenShellOptions): {
518
- shellId: string;
519
- };
749
+ fetchStreamStart(port: number, request: Request): Promise<{
750
+ streamId: string;
751
+ status: number;
752
+ statusText: string;
753
+ headers: Array<[string, string]>;
754
+ }>;
755
+ fetchStreamRead(streamId: string, maxBytes?: number): Promise<{
756
+ body: Uint8Array;
757
+ done: boolean;
758
+ }>;
759
+ fetchStreamCancel(streamId: string): Promise<void>;
760
+ private _openTerminal;
520
761
  connectTerminal(options?: ConnectTerminalOptions): Promise<number>;
521
762
  /** Write data to a shell's PTY input. */
522
- writeShell(shellId: string, data: string | Uint8Array): Promise<void>;
523
- /** Subscribe to data output from a shell. Returns an unsubscribe function. */
524
- onShellData(shellId: string, handler: (data: Uint8Array) => void): () => void;
763
+ private _writeTerminal;
764
+ /**
765
+ * Subscribe to ordered PTY output (stdout and stderr). Returns an unsubscribe
766
+ * function. `OpenShellOptions.onStderr` is a diagnostic tap for callers that
767
+ * need channel identity; do not render both surfaces.
768
+ */
769
+ onShellData(shellId: string, handler: (event: ShellData) => void): () => void;
770
+ /** Subscribe to the stderr-only diagnostic stream for a shell. */
771
+ onShellStderr(shellId: string, handler: (event: ShellData) => void): () => void;
772
+ /** Subscribe to shell exit. */
773
+ onShellExit(shellId: string, handler: (event: ShellExit) => void): () => void;
525
774
  /** Notify a shell of terminal resize. */
526
- resizeShell(shellId: string, cols: number, rows: number): void;
775
+ private _resizeTerminal;
527
776
  /**
528
777
  * Wait for a shell to exit and return its process exit code. Resolves
529
778
  * immediately for a shell that has already exited (within the closed-shell
530
779
  * retention window).
531
780
  */
532
- waitShell(shellId: string): Promise<number>;
781
+ private _waitTerminal;
533
782
  /** Kill a shell process and remove it from tracking. */
783
+ private _closeTerminal;
784
+ /** @deprecated Use `terminal.open()`. */
785
+ openShell(options?: ShellOptions): {
786
+ shellId: string;
787
+ };
788
+ /** @deprecated Use `terminal.write()`. */
789
+ writeShell(shellId: string, data: string | Uint8Array): Promise<void>;
790
+ /** @deprecated Use `terminal.resize()`. */
791
+ resizeShell(shellId: string, cols: number, rows: number): void;
792
+ /** @deprecated Use `terminal.wait()`. */
793
+ waitShell(shellId: string): Promise<number>;
794
+ /** @deprecated Use `terminal.close()`. */
534
795
  closeShell(shellId: string): void;
535
796
  private _resolveVmPathToHostPath;
536
797
  /** Returns info about all processes spawned via spawn(). */
537
- listProcesses(): SpawnedProcessInfo[];
798
+ private _listProcesses;
538
799
  /** Returns all kernel processes across all active runtimes (WASM and Node). */
539
- allProcesses(): KernelProcessInfo[];
800
+ private _listAllProcesses;
540
801
  /** Returns processes organized as a tree using ppid relationships. */
541
- processTree(): ProcessTreeNode[];
802
+ private _processTree;
542
803
  /** Returns info about a specific process by PID. Throws if not found. */
543
- getProcess(pid: number): SpawnedProcessInfo;
544
- /** Send SIGTERM to gracefully stop a process. No-op if already exited. */
545
- stopProcess(pid: number): void;
804
+ private _getProcess;
805
+ private _signalProcess;
546
806
  /** Send SIGKILL to force-kill a process. No-op if already exited. */
547
- killProcess(pid: number): void;
548
- /** Returns all active sessions with their IDs and agent types. */
549
- listSessions(): SessionInfo[];
550
- /** Internal helper: retrieve a session or throw. */
551
- private _requireSession;
807
+ private _killProcess;
808
+ private _resizeProcessPty;
809
+ private _readProcessOutput;
810
+ private _openSession;
811
+ private _getSession;
812
+ private _listSessions;
813
+ private _deleteSession;
814
+ private _unloadSession;
815
+ private _prompt;
816
+ private _cancelPrompt;
817
+ private _respondPermission;
818
+ private _readHistory;
819
+ private _getSessionConfig;
820
+ private _setSessionConfigOption;
821
+ private _getSessionCapabilities;
822
+ private _getSessionAgentInfo;
823
+ /** @deprecated Use `sessions.open()`. */
824
+ openSession(input: OpenSessionInput): Promise<void>;
825
+ /** @deprecated Use `sessions.get()`. */
826
+ getSession(input?: SessionTarget): Promise<DurableSessionInfo>;
827
+ /** @deprecated Use `sessions.list()`. */
828
+ listSessions(input?: ListSessionsInput): Promise<SessionPage>;
829
+ /** @deprecated Use `sessions.delete()`. */
830
+ deleteSession(input?: SessionTarget): Promise<void>;
831
+ /** @deprecated Use `sessions.unload()`. */
832
+ unloadSession(input?: SessionTarget): Promise<void>;
833
+ /** @deprecated Use `sessions.prompt()`. */
834
+ prompt(input: PromptInput): Promise<DurablePromptResult>;
835
+ /** @deprecated Use `sessions.cancelPrompt()`. */
836
+ cancelPrompt(input?: SessionTarget): Promise<CancelPromptResult>;
837
+ /** @deprecated Use `sessions.respondPermission()`. */
838
+ respondPermission(input: PermissionResponse): Promise<PermissionResponseResult>;
839
+ /** @deprecated Use `sessions.readHistory()`. */
840
+ readHistory(input?: ReadHistoryInput): Promise<HistoryPage>;
841
+ /** @deprecated Use `sessions.getConfig()`. */
842
+ getSessionConfig(input?: SessionTarget): Promise<SessionConfig>;
843
+ /** @deprecated Use `sessions.setConfigOption()`. */
844
+ setSessionConfigOption(input: SetSessionConfigOptionInput): Promise<SessionConfig>;
845
+ /** @deprecated Use `sessions.getCapabilities()`. */
846
+ getSessionCapabilities(input?: SessionTarget): Promise<SessionCapabilities | null>;
847
+ /** @deprecated Use `sessions.getAgentInfo()`. */
848
+ getSessionAgentInfo(input?: SessionTarget): Promise<SessionAgentInfo | null>;
552
849
  /**
553
850
  * Dynamically link a software package into the RUNNING VM. The package's
554
851
  * `bin/` commands appear under `/opt/agentos/bin` (on `$PATH`) and its `share/man`
555
852
  * pages under MANPATH immediately — the `/opt/agentos` mount is host-backed, so
556
853
  * writing into its staging dir is reflected live with no reboot. An `agent`
557
- * block registers the package for `createSession(name)`. Persists for the VM's
854
+ * block registers the package for `openSession({ agent: name })`. Persists for the VM's
558
855
  * lifetime (and across a snapshot iff the volume persists).
559
856
  */
560
- linkSoftware(descriptor: PackageRef | SoftwarePackageRef): Promise<void>;
561
- providedCommands(): Promise<{
562
- packageName: string;
563
- commands: string[];
564
- }[]>;
857
+ private _linkSoftware;
858
+ private _listSoftware;
565
859
  /**
566
860
  * Returns all registered agents with their installation status. Thin forwarder:
567
861
  * sends `AcpListAgentsRequest` and maps the response. The sidecar enumerates the
568
862
  * projected `/opt/agentos` packages (the client parses no manifests). Every such
569
863
  * agent is a package materialized into the VM, so `installed` is always `true`.
570
864
  */
865
+ private _listAgents;
866
+ /** @deprecated Use `software.link()`. */
867
+ linkSoftware(descriptor: PackageDescriptor): Promise<void>;
868
+ /** @deprecated Use `software.list()`. */
869
+ listSoftware(): Promise<{
870
+ packageName: string;
871
+ commands: string[];
872
+ }[]>;
873
+ /** @deprecated Use `agents.list()`. */
571
874
  listAgents(): Promise<AgentRegistryEntry[]>;
572
- private _syncSessionState;
573
- private _applySessionUpdate;
574
- private _recordSessionNotification;
575
- private _dispatchSessionEvent;
576
- private _subscribeSessionEvents;
577
- /**
578
- * Warn once per session (host-visible) that a tool-permission request was
579
- * auto-denied because no `onPermissionRequest` handler is registered. Shared
580
- * by both the bare-callback and JSON-RPC permission paths so the message and
581
- * the once-per-session guard cannot drift between them.
582
- */
583
- private _warnNoPermissionHandlerOnce;
584
- /** Best-effort human label for the tool named in a permission request. */
585
- private _permissionToolLabel;
586
- /**
587
- * Emit a host-visible warning for a session through the same agent-process log
588
- * channel that surfaces adapter stderr (`onAgentStderr`, default: process
589
- * stderr). Used for agent-os-owned diagnostics — e.g. a permission request
590
- * that was auto-denied because no host hook is registered — so they never fire
591
- * silently inside the sidecar.
592
- */
593
- private _emitSessionWarning;
594
875
  private _recordAgentStderr;
595
876
  private _recordAgentExit;
596
- private _applySyntheticConfigOverrides;
597
877
  private _handleSidecarEvent;
598
878
  private _handleLimitWarning;
599
879
  private _handleAcpExtEvent;
600
- private _unsupportedConfigResponse;
880
+ private _emitDurableSessionEvent;
601
881
  private _sendAcpRequest;
602
- private _sendSessionRequest;
603
- private _setSessionConfigByCategory;
604
- private _removeSession;
605
- private _abortPendingSessionRequests;
606
- private _cancelPendingPromptRequests;
607
- private _rejectPendingPermissionReplies;
608
- private _rejectPendingPermissionRepliesFromSession;
609
- private _closeSessionInternal;
610
- private _hydrateSessionState;
611
- createSession(agentType: AgentType, options?: CreateSessionOptions): Promise<{
612
- sessionId: string;
613
- }>;
614
- /**
615
- * Resume a session that exists in durable storage but is not live in this VM
616
- * (e.g. after a Rivet actor slept and woke with a fresh VM). Thin forwarder:
617
- * resolves the agent config + adapter entrypoint exactly as {@link createSession}
618
- * does, then forwards a single `AcpResumeSessionRequest` to the sidecar, which
619
- * owns the resume state machine (native `session/load` when the agent supports
620
- * it, else `session/new` + a transcript-continuation preamble). The returned
621
- * `sessionId` is the live id in this VM (equal to the requested id for native
622
- * loads, freshly assigned for the fallback); the caller remaps `external -> live`.
623
- * The new live session is registered + hydrated locally so subsequent prompts
624
- * route to it.
625
- *
626
- * Resume depends on a durable root; on a non-durable (default in-memory) root
627
- * there is no surviving store and the fallback tier always runs.
628
- */
629
- resumeSession(sessionId: string, agentType: AgentType, options?: ResumeSessionOptions): Promise<ResumeSessionResult>;
630
882
  private _installSidecarRequestHandler;
631
883
  private _handleAcpExtSidecarRequest;
632
884
  private _dispatchAcpSidecarRequest;
633
885
  private _handleSupportedAcpSidecarRequest;
634
- private _normalizeAcpPermissionOptionId;
635
- private _buildAcpPermissionResult;
636
- private _handleAcpPermissionRequest;
637
886
  private _acpParams;
638
887
  private _requireAcpStringParam;
639
888
  private _optionalAcpStringParam;
@@ -652,34 +901,22 @@ export declare class AgentOs {
652
901
  private _handleAcpKillTerminal;
653
902
  private _handleAcpReleaseTerminal;
654
903
  private _handleAcpResizeTerminal;
655
- private _handleAcpPermissionCallback;
656
- /**
657
- * Gracefully destroy a session: cancel any pending work, close the client,
658
- * and remove from tracking. Unlike close() which is abrupt, this attempts
659
- * a graceful shutdown sequence.
660
- */
661
- destroySession(sessionId: string): Promise<void>;
662
- prompt(sessionId: string, text: string): Promise<PromptResult>;
663
- /** Cancel ongoing agent work for a session. */
664
- cancelSession(sessionId: string): Promise<JsonRpcResponse>;
665
- closeSession(sessionId: string): void;
666
- respondPermission(sessionId: string, permissionId: string, reply: PermissionReply): Promise<JsonRpcResponse>;
667
- setSessionMode(sessionId: string, modeId: string): Promise<JsonRpcResponse>;
668
- getSessionModes(sessionId: string): SessionModeState | null;
669
- setSessionModel(sessionId: string, model: string): Promise<JsonRpcResponse>;
670
- setSessionThoughtLevel(sessionId: string, level: string): Promise<JsonRpcResponse>;
671
- getSessionConfigOptions(sessionId: string): SessionConfigOption[];
672
- getSessionCapabilities(sessionId: string): AgentCapabilities | null;
673
- getSessionAgentInfo(sessionId: string): AgentInfo | null;
674
- rawSessionSend(sessionId: string, method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>;
675
- rawSend(sessionId: string, method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>;
676
- onSessionEvent(sessionId: string, handler: SessionEventHandler): () => void;
677
- onPermissionRequest(sessionId: string, handler: PermissionRequestHandler): () => void;
904
+ onSessionEvent(handler: (entry: SessionStreamEntry) => void): () => void;
905
+ onSessionEvent(sessionId: string | undefined, handler: (entry: SessionStreamEntry) => void): () => void;
906
+ /** Subscribe to unexpected adapter exits without changing session liveness. */
907
+ onAgentExit(handler: AgentExitHandler): () => void;
908
+ onAgentExit(sessionId: string | undefined, handler: AgentExitHandler): () => void;
678
909
  /** Schedule a cron job. Returns a handle with the job ID and a cancel method. */
679
- scheduleCron(options: CronJobOptions): CronJob;
910
+ private _scheduleCron;
680
911
  /** List all registered cron jobs. */
681
- listCronJobs(): CronJobInfo[];
912
+ private _listCronJobs;
682
913
  /** Cancel a cron job by ID. */
914
+ private _cancelCronJob;
915
+ /** @deprecated Use `cron.schedule()`. */
916
+ scheduleCron(options: CronJobOptions): CronJob;
917
+ /** @deprecated Use `cron.list()`. */
918
+ listCronJobs(): CronJobInfo[];
919
+ /** @deprecated Use `cron.cancel()`. */
683
920
  cancelCronJob(id: string): void;
684
921
  /** Subscribe to cron lifecycle events (fire, complete, error). */
685
922
  onCronEvent(handler: CronEventHandler): void;