@rivet-dev/agentos-core 0.0.0-abc-fixes-1.d8c4d95 → 0.0.0-agent-acp-codex-session-benchmark.d578a31

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 (128) hide show
  1. package/README.md +48 -48
  2. package/dist/agent-os.d.ts +215 -161
  3. package/dist/agent-os.js +1300 -2576
  4. package/dist/agentos-package.d.ts +27 -0
  5. package/dist/agentos-package.js +21 -0
  6. package/dist/base-filesystem.d.ts +1 -16
  7. package/dist/base-filesystem.js +1 -173
  8. package/dist/cron/cron-manager.d.ts +39 -14
  9. package/dist/cron/cron-manager.js +289 -128
  10. package/dist/cron/errors.d.ts +8 -0
  11. package/dist/cron/errors.js +16 -0
  12. package/dist/cron/index.d.ts +1 -3
  13. package/dist/cron/index.js +1 -2
  14. package/dist/cron/types.d.ts +2 -2
  15. package/dist/default-software.d.ts +8 -0
  16. package/dist/default-software.js +10 -0
  17. package/dist/filesystem-snapshot.d.ts +1 -1
  18. package/dist/filesystem-snapshot.js +1 -1
  19. package/dist/generated/AcpLimitsConfig.d.ts +4 -0
  20. package/dist/generated/AcpLimitsConfig.js +2 -0
  21. package/dist/generated/CreateVmConfig.d.ts +29 -0
  22. package/dist/generated/FsPermissionRule.d.ts +6 -0
  23. package/dist/generated/FsPermissionRule.js +1 -0
  24. package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
  25. package/dist/generated/FsPermissionRuleSet.js +1 -0
  26. package/dist/generated/FsPermissionScope.d.ts +3 -0
  27. package/dist/generated/FsPermissionScope.js +1 -0
  28. package/dist/generated/HttpLimitsConfig.d.ts +3 -0
  29. package/dist/generated/HttpLimitsConfig.js +2 -0
  30. package/dist/generated/JsModuleResolution.d.ts +1 -0
  31. package/dist/generated/JsModuleResolution.js +2 -0
  32. package/dist/generated/JsRuntimeConfig.d.ts +31 -0
  33. package/dist/generated/JsRuntimeConfig.js +1 -0
  34. package/dist/generated/JsRuntimeLimitsConfig.d.ts +8 -0
  35. package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
  36. package/dist/generated/JsRuntimePlatform.d.ts +1 -0
  37. package/dist/generated/JsRuntimePlatform.js +2 -0
  38. package/dist/generated/MountPluginDescriptor.d.ts +4 -0
  39. package/dist/generated/MountPluginDescriptor.js +2 -0
  40. package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
  41. package/dist/generated/NativeRootFilesystemConfig.js +1 -0
  42. package/dist/generated/PatternPermissionRule.d.ts +6 -0
  43. package/dist/generated/PatternPermissionRule.js +1 -0
  44. package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
  45. package/dist/generated/PatternPermissionRuleSet.js +1 -0
  46. package/dist/generated/PatternPermissionScope.d.ts +3 -0
  47. package/dist/generated/PatternPermissionScope.js +1 -0
  48. package/dist/generated/PermissionMode.d.ts +1 -0
  49. package/dist/generated/PermissionMode.js +2 -0
  50. package/dist/generated/PermissionsPolicy.d.ts +10 -0
  51. package/dist/generated/PermissionsPolicy.js +1 -0
  52. package/dist/generated/PluginLimitsConfig.d.ts +4 -0
  53. package/dist/generated/PluginLimitsConfig.js +2 -0
  54. package/dist/generated/PythonLimitsConfig.d.ts +6 -0
  55. package/dist/generated/PythonLimitsConfig.js +2 -0
  56. package/dist/generated/ResourceLimitsConfig.d.ts +25 -0
  57. package/dist/generated/ResourceLimitsConfig.js +2 -0
  58. package/dist/generated/RootFilesystemConfig.d.ts +9 -0
  59. package/dist/generated/RootFilesystemConfig.js +1 -0
  60. package/dist/generated/RootFilesystemEntry.d.ts +13 -0
  61. package/dist/generated/RootFilesystemEntry.js +1 -0
  62. package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
  63. package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
  64. package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
  65. package/dist/generated/RootFilesystemEntryKind.js +2 -0
  66. package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
  67. package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
  68. package/dist/generated/RootFilesystemMode.d.ts +1 -0
  69. package/dist/generated/RootFilesystemMode.js +2 -0
  70. package/dist/generated/ToolLimitsConfig.d.ts +10 -0
  71. package/dist/generated/ToolLimitsConfig.js +2 -0
  72. package/dist/generated/VmDnsConfig.d.ts +6 -0
  73. package/dist/generated/VmDnsConfig.js +2 -0
  74. package/dist/generated/VmLimitsConfig.d.ts +18 -0
  75. package/dist/generated/VmLimitsConfig.js +1 -0
  76. package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
  77. package/dist/generated/VmListenPolicyConfig.js +2 -0
  78. package/dist/generated/WasmLimitsConfig.d.ts +7 -0
  79. package/dist/generated/WasmLimitsConfig.js +2 -0
  80. package/dist/host-dir-mount.d.ts +5 -5
  81. package/dist/host-dir-mount.js +4 -4
  82. package/dist/host-tools-zod.js +27 -7
  83. package/dist/host-tools.d.ts +2 -9
  84. package/dist/host-tools.js +0 -18
  85. package/dist/index.d.ts +7 -4
  86. package/dist/index.js +6 -4
  87. package/dist/layers.d.ts +3 -3
  88. package/dist/layers.js +19 -10
  89. package/dist/memory-filesystem.d.ts +39 -0
  90. package/dist/memory-filesystem.js +375 -0
  91. package/dist/options-schema.d.ts +452 -0
  92. package/dist/options-schema.js +269 -0
  93. package/dist/overlay-filesystem.d.ts +1 -1
  94. package/dist/overlay-filesystem.js +3 -3
  95. package/dist/packages.d.ts +10 -123
  96. package/dist/packages.js +3 -329
  97. package/dist/runtime.d.ts +41 -184
  98. package/dist/sidecar/agentos-protocol.d.ts +232 -29
  99. package/dist/sidecar/agentos-protocol.js +456 -120
  100. package/dist/sidecar/binary.d.ts +2 -2
  101. package/dist/sidecar/binary.js +2 -2
  102. package/dist/sidecar/native-process-client.d.ts +5 -3
  103. package/dist/sidecar/native-process-client.js +5 -3
  104. package/dist/sidecar/permissions.d.ts +4 -3
  105. package/dist/sidecar/permissions.js +6 -23
  106. package/dist/sidecar/rpc-client.d.ts +74 -86
  107. package/dist/sidecar/rpc-client.js +422 -1418
  108. package/dist/test/file-system.d.ts +1 -1
  109. package/dist/test/file-system.js +3 -1
  110. package/dist/test/runtime.d.ts +2 -3
  111. package/dist/test/runtime.js +1 -1
  112. package/dist/test/terminal-harness.d.ts +5 -4
  113. package/dist/test/terminal-harness.js +12 -7
  114. package/dist/types.d.ts +12 -5
  115. package/package.json +37 -41
  116. package/dist/agents.d.ts +0 -63
  117. package/dist/agents.js +0 -42
  118. package/dist/cron/parse-schedule.d.ts +0 -25
  119. package/dist/cron/parse-schedule.js +0 -66
  120. package/dist/cron/schedule-driver.d.ts +0 -19
  121. package/dist/cron/timer-driver.d.ts +0 -17
  122. package/dist/cron/timer-driver.js +0 -61
  123. package/dist/runtime-compat.d.ts +0 -475
  124. package/dist/runtime-compat.js +0 -2010
  125. package/dist/sidecar/cargo.d.ts +0 -2
  126. package/dist/sidecar/cargo.js +0 -142
  127. package/fixtures/AGENTOS_SYSTEM_PROMPT.md +0 -21
  128. /package/dist/{cron/schedule-driver.js → generated/CreateVmConfig.js} +0 -0
@@ -1,17 +1,12 @@
1
- import type { NativeMountPluginDescriptor } from "@secure-exec/core/descriptors";
1
+ import type { NativeMountPluginDescriptor } from "@rivet-dev/agentos-runtime-core/descriptors";
2
2
  import type { AgentCapabilities, AgentInfo, PermissionReply, PermissionRequestHandler, SessionConfigOption, SessionEventHandler, SessionModeState } from "./agent-session-types.js";
3
- import { type ToolKit } from "./host-tools.js";
3
+ import type { ToolKit } from "./host-tools.js";
4
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";
6
- export type { MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, NativeMountPluginDescriptor, } from "@secure-exec/core/descriptors";
5
+ import type { Kernel, KernelExecOptions, KernelExecResult, ProcessInfo as KernelProcessInfo, KernelSpawnOptions, OpenShellOptions, Permissions, VirtualFileSystem, VirtualStat } from "./runtime.js";
6
+ export type { MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, NativeMountPluginDescriptor, } from "@rivet-dev/agentos-runtime-core/descriptors";
7
7
  export type { AgentCapabilities, AgentInfo, PermissionReply, PermissionRequest, PermissionRequestHandler, SessionConfigOption, SessionEventHandler, SessionInitData, SessionMode, SessionModeState, } from "./agent-session-types.js";
8
8
  export type { AcpTimeoutErrorData, JsonRpcError, JsonRpcErrorData, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, } from "./json-rpc.js";
9
9
  export { isAcpTimeoutErrorData } from "./json-rpc.js";
10
- export type { ConnectTerminalOptions } from "./runtime-compat.js";
11
- /** Process tree node: extends kernel ProcessInfo with child references. */
12
- export interface ProcessTreeNode extends KernelProcessInfo {
13
- children: ProcessTreeNode[];
14
- }
15
10
  /** A directory entry with metadata. */
16
11
  export interface DirEntry {
17
12
  /** Absolute path to the entry. */
@@ -23,39 +18,20 @@ export interface DirEntry {
23
18
  export interface ReaddirRecursiveOptions {
24
19
  /** Maximum depth to recurse (0 = only immediate children). */
25
20
  maxDepth?: number;
26
- /** Directory names to skip. */
27
- exclude?: string[];
28
- }
29
- /** Entry for batch write operations. */
30
- export interface BatchWriteEntry {
31
- path: string;
32
- content: string | Uint8Array;
33
- }
34
- /** Result of a single file in a batch write. */
35
- export interface BatchWriteResult {
36
- path: string;
37
- success: boolean;
38
- error?: string;
39
- }
40
- /** Result of a single file in a batch read. */
41
- export interface BatchReadResult {
42
- path: string;
43
- content: Uint8Array | null;
44
- error?: string;
45
21
  }
46
22
  /** Entry in the agent registry, describing an available agent type. */
47
23
  export interface AgentRegistryEntry {
48
24
  id: string;
49
- acpAdapter: string;
50
- agentPackage: string;
51
25
  installed: boolean;
26
+ /** Guest entrypoint the sidecar launches for this agent (`/opt/agentos/bin/<acpEntrypoint>`). */
27
+ adapterEntrypoint: string;
52
28
  }
53
- import { type AgentType } from "./agents.js";
54
- import type { ScheduleDriver } from "./cron/schedule-driver.js";
29
+ import type { PackageRef, SoftwarePackageRef } from "./agentos-package.js";
55
30
  import type { CronEventHandler, CronJob, CronJobInfo, CronJobOptions } from "./cron/types.js";
56
31
  import { type LayerStore, type OverlayFilesystemMode, type RootSnapshotExport, type SnapshotLayerHandle } from "./layers.js";
57
- import { type SoftwareInput } from "./packages.js";
32
+ import type { SoftwareInput } from "./packages.js";
58
33
  import { type AgentOsSidecarPlacement } from "./sidecar/rpc-client.js";
34
+ import type { AgentType } from "./types.js";
59
35
  export interface AgentOsSharedSidecarOptions {
60
36
  pool?: string;
61
37
  }
@@ -124,6 +100,8 @@ export interface AgentOsLimits {
124
100
  resources?: {
125
101
  cpuCount?: number;
126
102
  maxProcesses?: number;
103
+ /** Aggregate bytes retained by all active captured processes in this VM. Default: 32 MiB. */
104
+ maxCapturedOutputBytes?: number;
127
105
  maxOpenFds?: number;
128
106
  maxPipes?: number;
129
107
  maxPtys?: number;
@@ -172,15 +150,17 @@ export interface AgentOsLimits {
172
150
  /** Guest JavaScript runtime buffering limits. */
173
151
  jsRuntime?: {
174
152
  v8HeapLimitMb?: number;
153
+ syncRpcWaitTimeoutMs?: number;
154
+ cpuTimeLimitMs?: number;
155
+ wallClockLimitMs?: number;
156
+ importCacheMaterializeTimeoutMs?: number;
175
157
  capturedOutputLimitBytes?: number;
176
- stdinBufferLimitBytes?: number;
177
- eventPayloadLimitBytes?: number;
178
- v8IpcMaxFrameBytes?: number;
179
158
  };
180
159
  /** Guest Python runtime limits. */
181
160
  python?: {
182
161
  outputBufferMaxBytes?: number;
183
162
  executionTimeoutMs?: number;
163
+ maxOldSpaceMb?: number;
184
164
  vfsRpcTimeoutMs?: number;
185
165
  };
186
166
  /** Guest WASM runtime limits. */
@@ -188,15 +168,81 @@ export interface AgentOsLimits {
188
168
  maxModuleFileBytes?: number;
189
169
  capturedOutputLimitBytes?: number;
190
170
  syncReadLimitBytes?: number;
171
+ prewarmTimeoutMs?: number;
172
+ runnerHeapLimitMb?: number;
191
173
  };
192
174
  }
175
+ export interface AgentStderrEvent {
176
+ sessionId: string;
177
+ agentType: string;
178
+ processId: string;
179
+ pid: number | null;
180
+ chunk: Uint8Array;
181
+ }
182
+ export type AgentStderrHandler = (event: AgentStderrEvent) => void;
183
+ /**
184
+ * Auto-restart outcome reported on an {@link AgentExitEvent}. Mirrors the
185
+ * sidecar's `AcpAgentExitedEvent.restart` strings:
186
+ * - `"restarted"` — the adapter was respawned and the session was natively
187
+ * re-attached under the same session id; the session stays usable.
188
+ * - `"unsupported"` — the adapter does not advertise a native resume
189
+ * capability (`loadSession`/`resume`); the session was evicted.
190
+ * - `"failed"` — the respawn or re-attach errored; the session was evicted.
191
+ * - `"exhausted"` — the per-session restart budget was already spent; evicted.
192
+ */
193
+ export type AgentRestartOutcome = "restarted" | "unsupported" | "failed" | "exhausted";
194
+ /**
195
+ * An unexpected ACP adapter process exit — a crash from the host's
196
+ * perspective (any spontaneous exit without `closeSession()`, including exit
197
+ * code 0) — plus the sidecar's bounded auto-restart outcome.
198
+ */
199
+ export interface AgentExitEvent {
200
+ sessionId: string;
201
+ agentType: string;
202
+ /** Sidecar process id of the adapter that exited. */
203
+ processId: string;
204
+ pid: number | null;
205
+ /** Adapter exit code; `null` when the exit was observed indirectly. */
206
+ exitCode: number | null;
207
+ /** Auto-restart outcome; only `"restarted"` leaves the session usable. */
208
+ restart: AgentRestartOutcome;
209
+ /** Restarts consumed for this session so far. */
210
+ restartCount: number;
211
+ /** Per-session restart budget. */
212
+ maxRestarts: number;
213
+ }
214
+ export type AgentExitHandler = (event: AgentExitEvent) => void;
215
+ /**
216
+ * A near-capacity warning for one bounded limit (a queue/buffer, a saturating
217
+ * resource cap, or a memory envelope) inside the VM runtime. Delivered the moment
218
+ * usage crosses the runtime's warning threshold (~80%), once per crossing — the
219
+ * runtime applies edge-triggering + hysteresis, so this never spams.
220
+ */
221
+ export interface LimitWarning {
222
+ /** Stable limit name, e.g. `"javascript_event_channel"` or `"vm_open_fds"`. */
223
+ limit: string;
224
+ /** Limit class: `"queue"`, `"resource"`, or `"memory"`. */
225
+ category: string;
226
+ /** Current observed usage. */
227
+ observed: number;
228
+ /** Configured capacity. */
229
+ capacity: number;
230
+ /** Observed fill as a percentage of capacity (0–100). */
231
+ fillPercent: number;
232
+ }
233
+ export type LimitWarningHandler = (warning: LimitWarning) => void;
234
+ /**
235
+ * Public core VM options.
236
+ *
237
+ * Keep this interface in sync with
238
+ * `packages/core/src/options-schema.ts::agentOsOptionsSchema`. The Rivet
239
+ * native actor intentionally accepts only a subset via
240
+ * `packages/agentos/src/config.ts::nativeAgentOsOptionsSchema`.
241
+ */
193
242
  export interface AgentOsOptions {
194
243
  /**
195
- * Software to install in the VM. Each entry provides agents, tools,
196
- * or WASM commands. Any object with a `commandDir` property (e.g.,
197
- * registry packages like @agentos-software/coreutils) is treated
198
- * as a WASM command source automatically. Arrays are flattened, so
199
- * meta-packages that export arrays of sub-packages work directly.
244
+ * Software to install in the VM. Each entry is a package-dir ref. Arrays are
245
+ * flattened, so meta-packages that export arrays of sub-packages work directly.
200
246
  */
201
247
  software?: SoftwareInput[];
202
248
  /**
@@ -214,24 +260,26 @@ export interface AgentOsOptions {
214
260
  * Defaults to the hardened builtin set used by the native sidecar bridge.
215
261
  */
216
262
  allowedNodeBuiltins?: string[];
263
+ /**
264
+ * Opt in to a high-resolution monotonic guest clock (microsecond class)
265
+ * for guest Node processes. Default `false` keeps the security-oriented
266
+ * 1ms timer resolution — untrusted guest code should not get a precise
267
+ * timer (timing side channels). Enable only for trusted benchmarking or
268
+ * profiling workloads.
269
+ */
270
+ highResolutionTime?: boolean;
217
271
  /** Root filesystem configuration. Defaults to an overlay with the bundled base snapshot as its deepest lower. */
218
272
  rootFilesystem?: RootFilesystemConfig;
219
273
  /** Filesystems to mount at boot time. */
220
274
  mounts?: MountConfig[];
221
- /**
222
- * @deprecated Use `mounts: [nodeModulesMount(path)]` instead.
223
- * Compatibility alias for mounting `<moduleAccessCwd>/node_modules` at `/root/node_modules`.
224
- */
225
- moduleAccessCwd?: string;
226
275
  /** Additional instructions appended to the base OS system prompt injected at session start. */
227
276
  additionalInstructions?: string;
228
- /** Custom schedule driver for cron jobs. Defaults to TimerScheduleDriver. */
229
- scheduleDriver?: ScheduleDriver;
230
277
  /** Host-side toolkits available to agents inside the VM. */
231
278
  toolKits?: ToolKit[];
232
279
  /**
233
280
  * Custom permission policy for the kernel. Controls access to filesystem,
234
- * network, child process, and environment operations. Defaults to allowAll.
281
+ * network, child process, and environment operations. When omitted, the
282
+ * sidecar defaults every category to allow.
235
283
  */
236
284
  permissions?: Permissions;
237
285
  /**
@@ -244,6 +292,28 @@ export interface AgentOsOptions {
244
292
  * runtime's historical constants, so omitting this leaves behavior unchanged.
245
293
  */
246
294
  limits?: AgentOsLimits;
295
+ /**
296
+ * Called with stderr chunks from the top-level ACP-speaking agent process.
297
+ * The agent process uses stdout for ACP JSON-RPC protocol traffic, so only
298
+ * stderr is forwarded through this hook. Defaults to writing chunks to
299
+ * `process.stderr`.
300
+ */
301
+ onAgentStderr?: AgentStderrHandler;
302
+ /**
303
+ * Called when the ACP adapter process behind a session exits without
304
+ * `closeSession()` — i.e. an adapter crash. The sidecar auto-restarts the
305
+ * adapter (bounded per session, natively re-attaching the same session id)
306
+ * and reports the outcome on the event; only `restart === "restarted"`
307
+ * leaves the session usable. Defaults to writing a warning line to
308
+ * `process.stderr`.
309
+ */
310
+ onAgentExit?: AgentExitHandler;
311
+ /**
312
+ * Called when a bounded limit inside the VM runtime approaches capacity
313
+ * (~80%, edge-triggered with hysteresis so it does not spam). Use it to alert
314
+ * on a slow consumer or a runaway guest before the limit is actually hit.
315
+ */
316
+ onLimitWarning?: LimitWarningHandler;
247
317
  }
248
318
  /** Configuration for a local MCP server (spawned as a child process). */
249
319
  export interface McpServerConfigLocal {
@@ -336,44 +406,37 @@ export declare class AgentOs {
336
406
  #private;
337
407
  readonly sidecar: AgentOsSidecar;
338
408
  private _sessions;
339
- private _closedSessionIds;
340
- private _sessionClosePromises;
341
- private _pendingSessionRequestResolvers;
342
409
  private _processes;
343
410
  private _shells;
344
- private _closedShellIds;
345
411
  private _pendingShellExitPromises;
346
- private _shellCounter;
347
- private _acpTerminals;
348
- private _acpTerminalCounter;
349
- private _softwareRoots;
350
- private _softwareAgentConfigs;
412
+ private _disposed;
413
+ private _disposePromise;
351
414
  private _cronManager;
352
415
  private _toolKits;
353
- private _toolReference;
354
- private _permissions;
355
- private _hostMounts;
356
- private _env;
357
- private _rootFilesystem;
358
416
  private _sidecarLease;
359
417
  private readonly _sidecarClient;
360
418
  private readonly _sidecarSession;
361
419
  private readonly _sidecarVm;
362
420
  private readonly _disposeSidecarEventListener;
421
+ private _disposeSidecarRequestHandler;
422
+ private readonly _agentStderrHandler?;
423
+ private readonly _agentExitHandler?;
424
+ private readonly _limitWarningHandler?;
363
425
  private constructor();
364
426
  static createSidecar(options?: AgentOsCreateSidecarOptions): Promise<AgentOsSidecar>;
365
427
  static getSharedSidecar(options?: AgentOsSharedSidecarOptions): Promise<AgentOsSidecar>;
366
428
  static create(options?: AgentOsOptions): Promise<AgentOs>;
367
429
  exec(command: string, options?: KernelExecOptions): Promise<KernelExecResult>;
368
430
  execArgv(command: string, args?: readonly string[], options?: KernelExecOptions): Promise<KernelExecResult>;
431
+ private _pruneCompletedProcessRoutes;
369
432
  private _trackProcess;
370
- spawn(command: string, args: string[], options?: KernelSpawnOptions): {
433
+ spawn(command: string, args: string[], options?: KernelSpawnOptions): Promise<{
371
434
  pid: number;
372
- };
435
+ }>;
373
436
  /** Write data to a process's stdin. */
374
- writeProcessStdin(pid: number, data: string | Uint8Array): void;
437
+ writeProcessStdin(pid: number, data: string | Uint8Array): Promise<void>;
375
438
  /** Close a process's stdin stream. */
376
- closeProcessStdin(pid: number): void;
439
+ closeProcessStdin(pid: number): Promise<void>;
377
440
  /** Subscribe to stdout data from a process. Returns an unsubscribe function. */
378
441
  onProcessStdout(pid: number, handler: (data: Uint8Array) => void): () => void;
379
442
  /** Subscribe to stderr data from a process. Returns an unsubscribe function. */
@@ -382,16 +445,8 @@ export declare class AgentOs {
382
445
  onProcessExit(pid: number, handler: (exitCode: number) => void): () => void;
383
446
  /** Wait for a process to exit. Returns the exit code. */
384
447
  waitProcess(pid: number): Promise<number>;
385
- private _assertSafeAbsolutePath;
386
- private _assertWritableAbsolutePath;
387
- private _vfs;
388
- private _copyPath;
389
448
  readFile(path: string): Promise<Uint8Array>;
390
449
  writeFile(path: string, content: string | Uint8Array): Promise<void>;
391
- writeFiles(entries: BatchWriteEntry[]): Promise<BatchWriteResult[]>;
392
- readFiles(paths: string[]): Promise<BatchReadResult[]>;
393
- /** Recursively create directories (mkdir -p). */
394
- private _mkdirp;
395
450
  mkdir(path: string, options?: {
396
451
  recursive?: boolean;
397
452
  }): Promise<void>;
@@ -400,66 +455,107 @@ export declare class AgentOs {
400
455
  stat(path: string): Promise<VirtualStat>;
401
456
  exists(path: string): Promise<boolean>;
402
457
  snapshotRootFilesystem(): Promise<RootSnapshotExport>;
458
+ /**
459
+ * Mount a filesystem into the running VM. Resolves once the mount has been
460
+ * delivered to the native sidecar, so guest code can use it immediately
461
+ * after the returned promise settles; a delivery failure rejects instead of
462
+ * leaving the mount silently host-only.
463
+ */
403
464
  mountFs(path: string, driver: VirtualFileSystem, options?: {
404
465
  readOnly?: boolean;
405
- }): void;
406
- unmountFs(path: string): void;
466
+ }): Promise<void>;
467
+ unmountFs(path: string): Promise<void>;
407
468
  move(from: string, to: string): Promise<void>;
408
469
  delete(path: string, options?: {
409
470
  recursive?: boolean;
410
471
  }): Promise<void>;
411
472
  fetch(port: number, request: Request): Promise<Response>;
412
- openShell(options?: OpenShellOptions): {
473
+ openShell(options?: OpenShellOptions): Promise<{
413
474
  shellId: string;
414
- };
415
- connectTerminal(options?: ConnectTerminalOptions): Promise<number>;
475
+ }>;
416
476
  /** Write data to a shell's PTY input. */
417
- writeShell(shellId: string, data: string | Uint8Array): void;
477
+ writeShell(shellId: string, data: string | Uint8Array): Promise<void>;
418
478
  /** Subscribe to data output from a shell. Returns an unsubscribe function. */
419
479
  onShellData(shellId: string, handler: (data: Uint8Array) => void): () => void;
420
- /** Notify a shell of terminal resize. */
421
- resizeShell(shellId: string, cols: number, rows: number): void;
422
- /** Kill a shell process and remove it from tracking. */
423
- closeShell(shellId: string): void;
424
- private _resolveVmPathToHostPath;
425
- /** Returns info about all processes spawned via spawn(). */
426
- listProcesses(): SpawnedProcessInfo[];
480
+ /** Notify a shell of terminal resize and await the sidecar response. */
481
+ resizeShell(shellId: string, cols: number, rows: number): Promise<void>;
482
+ /**
483
+ * Wait for a shell to exit and return its sidecar-authoritative exit code.
484
+ * A late wait reads the retained sidecar process snapshot.
485
+ */
486
+ waitShell(shellId: string): Promise<number>;
487
+ /** Kill a shell process, await the sidecar response, and remove it from tracking. */
488
+ closeShell(shellId: string): Promise<void>;
489
+ /** Returns sidecar-authoritative info for processes spawned via spawn(). */
490
+ listProcesses(): Promise<SpawnedProcessInfo[]>;
427
491
  /** Returns all kernel processes across all active runtimes (WASM and Node). */
428
- allProcesses(): KernelProcessInfo[];
429
- /** Returns processes organized as a tree using ppid relationships. */
430
- processTree(): ProcessTreeNode[];
492
+ allProcesses(): Promise<KernelProcessInfo[]>;
431
493
  /** Returns info about a specific process by PID. Throws if not found. */
432
- getProcess(pid: number): SpawnedProcessInfo;
494
+ getProcess(pid: number): Promise<SpawnedProcessInfo>;
433
495
  /** Send SIGTERM to gracefully stop a process. No-op if already exited. */
434
- stopProcess(pid: number): void;
496
+ stopProcess(pid: number): Promise<void>;
435
497
  /** Send SIGKILL to force-kill a process. No-op if already exited. */
436
- killProcess(pid: number): void;
437
- /** Returns all active sessions with their IDs and agent types. */
438
- listSessions(): SessionInfo[];
498
+ killProcess(pid: number): Promise<void>;
499
+ /** Returns the sidecar's authoritative active-session list. */
500
+ listSessions(): Promise<SessionInfo[]>;
439
501
  /** Internal helper: retrieve a session or throw. */
440
502
  private _requireSession;
441
- /** Returns all registered agents with their installation status. */
442
- listAgents(): AgentRegistryEntry[];
443
- private _syncSessionState;
444
- private _applySessionUpdate;
503
+ /**
504
+ * Dynamically link a software package into the RUNNING VM. The package's
505
+ * `bin/` commands appear under `/opt/agentos/bin` (on `$PATH`) and its `share/man`
506
+ * pages under MANPATH immediately — the `/opt/agentos` mount is host-backed, so
507
+ * writing into its staging dir is reflected live with no reboot. An `agent`
508
+ * block registers the package for `createSession(name)`. Persists for the VM's
509
+ * lifetime (and across a snapshot iff the volume persists).
510
+ */
511
+ linkSoftware(descriptor: PackageRef | SoftwarePackageRef): Promise<void>;
512
+ providedCommands(): Promise<{
513
+ packageName: string;
514
+ commands: string[];
515
+ }[]>;
516
+ /**
517
+ * Returns all registered agents with their installation status. Thin forwarder:
518
+ * sends `AcpListAgentsRequest` and maps the response. The sidecar enumerates the
519
+ * projected `/opt/agentos` packages (the client parses no manifests). Every such
520
+ * agent is a package materialized into the VM, so `installed` is always `true`.
521
+ */
522
+ listAgents(): Promise<AgentRegistryEntry[]>;
445
523
  private _recordSessionNotification;
446
524
  private _dispatchSessionEvent;
447
525
  private _subscribeSessionEvents;
448
- private _applySyntheticConfigOverrides;
526
+ /**
527
+ * Warn once per session (host-visible) that a tool-permission request was
528
+ * auto-denied because no `onPermissionRequest` handler is registered. Shared
529
+ * by both the bare-callback and JSON-RPC permission paths so the message and
530
+ * the once-per-session guard cannot drift between them.
531
+ */
532
+ private _warnNoPermissionHandlerOnce;
533
+ /** Best-effort human label for the tool named in a permission request. */
534
+ private _permissionToolLabel;
535
+ /**
536
+ * Emit a host-visible warning for a session through the same agent-process log
537
+ * channel that surfaces adapter stderr (`onAgentStderr`, default: process
538
+ * stderr). Used for agent-os-owned diagnostics — e.g. a permission request
539
+ * that was auto-denied because no host hook is registered — so they never fire
540
+ * silently inside the sidecar.
541
+ */
542
+ private _emitSessionWarning;
543
+ private _recordAgentStderr;
544
+ private _recordAgentExit;
449
545
  private _handleSidecarEvent;
546
+ private _handleLimitWarning;
450
547
  private _handleAcpExtEvent;
451
- private _unsupportedConfigResponse;
548
+ private _decodeAcpResponseEnvelope;
452
549
  private _sendAcpRequest;
453
550
  private _sendSessionRequest;
551
+ private _sendSessionRequestWithText;
454
552
  private _setSessionConfigByCategory;
455
553
  private _removeSession;
456
- private _abortPendingSessionRequests;
457
- private _cancelPendingPromptRequests;
458
554
  private _rejectPendingPermissionReplies;
459
555
  private _rejectPendingPermissionRepliesFromSession;
460
556
  private _closeSessionInternal;
461
- private _hydrateSessionState;
462
- createSession(agentType: AgentType | string, options?: CreateSessionOptions): Promise<{
557
+ private _getSessionState;
558
+ createSession(agentType: AgentType, options?: CreateSessionOptions): Promise<{
463
559
  sessionId: string;
464
560
  }>;
465
561
  /**
@@ -471,60 +567,16 @@ export declare class AgentOs {
471
567
  * it, else `session/new` + a transcript-continuation preamble). The returned
472
568
  * `sessionId` is the live id in this VM (equal to the requested id for native
473
569
  * loads, freshly assigned for the fallback); the caller remaps `external -> live`.
474
- * The new live session is registered + hydrated locally so subsequent prompts
475
- * route to it.
570
+ * The new live session is registered locally only for host callbacks/events;
571
+ * authoritative state remains in the sidecar.
476
572
  *
477
573
  * Resume depends on a durable root; on a non-durable (default in-memory) root
478
574
  * there is no surviving store and the fallback tier always runs.
479
575
  */
480
- resumeSession(sessionId: string, agentType: AgentType | string, options?: ResumeSessionOptions): Promise<ResumeSessionResult>;
481
- /**
482
- * Resolve the VM bin entry point of an ACP adapter package.
483
- * Reads from the host filesystem since kernel.readFile() resolves through
484
- * mounts; adapter package.json is read directly off the host dir backing
485
- * the relevant mount.
486
- */
487
- private _resolveAdapterBin;
488
- /**
489
- * Parent of the host directory backing the `/root/node_modules` mount, if
490
- * the caller supplied one (e.g. via `nodeModulesMount(...)`). Used as the
491
- * `resolvePackageDir` start dir for adapter/agent package resolution when no
492
- * software root matches. `nodeModulesMount` mounts `<dir>/node_modules`, so
493
- * the start dir is `<dir>` (one level above the node_modules tree).
494
- */
495
- private _nodeModulesHostRoot;
496
- private _resolvePackageBin;
576
+ resumeSession(sessionId: string, agentType: AgentType, options?: ResumeSessionOptions): Promise<ResumeSessionResult>;
497
577
  private _installSidecarRequestHandler;
498
578
  private _handleAcpExtSidecarRequest;
499
- private _dispatchAcpSidecarRequest;
500
- private _handleSupportedAcpSidecarRequest;
501
- private _normalizeAcpPermissionOptionId;
502
- private _buildAcpPermissionResult;
503
- private _handleAcpPermissionRequest;
504
- private _acpParams;
505
- private _requireAcpStringParam;
506
- private _optionalAcpStringParam;
507
- private _optionalAcpNumberParam;
508
- private _optionalAcpStringArrayParam;
509
- private _optionalAcpEnvParam;
510
- private _requireAcpTerminal;
511
- private _appendAcpTerminalOutput;
512
- private _handleAcpReadFile;
513
- private _handleAcpWriteFile;
514
- private _handleAcpReadDir;
515
- private _handleAcpCreateTerminal;
516
- private _handleAcpWriteTerminal;
517
- private _handleAcpReadTerminal;
518
- private _handleAcpWaitForTerminalExit;
519
- private _handleAcpKillTerminal;
520
- private _handleAcpReleaseTerminal;
521
- private _handleAcpResizeTerminal;
522
579
  private _handleAcpPermissionCallback;
523
- /**
524
- * Resolve an agent config by ID. Package-provided configs take
525
- * precedence over the hardcoded AGENT_CONFIGS.
526
- */
527
- private _resolveAgentConfig;
528
580
  /**
529
581
  * Gracefully destroy a session: cancel any pending work, close the client,
530
582
  * and remove from tracking. Unlike close() which is abrupt, this attempts
@@ -534,28 +586,29 @@ export declare class AgentOs {
534
586
  prompt(sessionId: string, text: string): Promise<PromptResult>;
535
587
  /** Cancel ongoing agent work for a session. */
536
588
  cancelSession(sessionId: string): Promise<JsonRpcResponse>;
537
- closeSession(sessionId: string): void;
589
+ closeSession(sessionId: string): Promise<void>;
538
590
  respondPermission(sessionId: string, permissionId: string, reply: PermissionReply): Promise<JsonRpcResponse>;
539
591
  setSessionMode(sessionId: string, modeId: string): Promise<JsonRpcResponse>;
540
- getSessionModes(sessionId: string): SessionModeState | null;
592
+ getSessionModes(sessionId: string): Promise<SessionModeState | null>;
541
593
  setSessionModel(sessionId: string, model: string): Promise<JsonRpcResponse>;
542
594
  setSessionThoughtLevel(sessionId: string, level: string): Promise<JsonRpcResponse>;
543
- getSessionConfigOptions(sessionId: string): SessionConfigOption[];
544
- getSessionCapabilities(sessionId: string): AgentCapabilities | null;
545
- getSessionAgentInfo(sessionId: string): AgentInfo | null;
595
+ getSessionConfigOptions(sessionId: string): Promise<SessionConfigOption[]>;
596
+ getSessionCapabilities(sessionId: string): Promise<AgentCapabilities | null>;
597
+ getSessionAgentInfo(sessionId: string): Promise<AgentInfo | null>;
546
598
  rawSessionSend(sessionId: string, method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>;
547
599
  rawSend(sessionId: string, method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>;
548
600
  onSessionEvent(sessionId: string, handler: SessionEventHandler): () => void;
549
601
  onPermissionRequest(sessionId: string, handler: PermissionRequestHandler): () => void;
550
602
  /** Schedule a cron job. Returns a handle with the job ID and a cancel method. */
551
- scheduleCron(options: CronJobOptions): CronJob;
603
+ scheduleCron(options: CronJobOptions): Promise<CronJob>;
552
604
  /** List all registered cron jobs. */
553
- listCronJobs(): CronJobInfo[];
605
+ listCronJobs(): Promise<CronJobInfo[]>;
554
606
  /** Cancel a cron job by ID. */
555
- cancelCronJob(id: string): void;
607
+ cancelCronJob(id: string): Promise<void>;
556
608
  /** Subscribe to cron lifecycle events (fire, complete, error). */
557
609
  onCronEvent(handler: CronEventHandler): void;
558
610
  dispose(): Promise<void>;
611
+ private _disposeOnce;
559
612
  }
560
613
  export declare function getAgentOsRuntimeAdmin(vm: AgentOs): AgentOsRuntimeAdmin;
561
614
  export declare function getAgentOsKernel(vm: AgentOs): Kernel;
@@ -563,6 +616,7 @@ export declare class AgentOsSidecar {
563
616
  constructor(sidecarId: string, placement: AgentOsSidecarPlacement, sharedPool?: string);
564
617
  describe(): AgentOsSidecarDescription;
565
618
  dispose(): Promise<void>;
619
+ private disposeOnce;
566
620
  }
567
621
  /**
568
622
  * Test-only escape hatch: dispose every cached shared sidecar so vitest