@rivet-dev/agentos-core 0.0.0-nathan-agentos-package-resolution.3785b9a → 0.0.0-provided-commands.1847f3b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -112,7 +112,7 @@ await vm.dispose();
112
112
 
113
113
  | Method | Signature | Description |
114
114
  |--------|-----------|-------------|
115
- | `createSession` | `createSession(agentType: AgentType \| string, options?: CreateSessionOptions): Promise<{ sessionId: string }>` | Launch an agent and return a session ID |
115
+ | `createSession` | `createSession(agentType: AgentType, options?: CreateSessionOptions): Promise<{ sessionId: string }>` | Launch an agent and return a session ID |
116
116
  | `listSessions` | `listSessions(): SessionInfo[]` | List active sessions |
117
117
  | `destroySession` | `destroySession(sessionId: string): Promise<void>` | Gracefully cancel and close a session |
118
118
 
@@ -177,8 +177,8 @@ await vm.dispose();
177
177
  - `BatchReadResult` — Result of a batch read (path, content, error?)
178
178
 
179
179
  **Agent**
180
- - `AgentType` — `"pi" | "pi-cli" | "opencode" | "claude"`
181
- - `AgentConfig` — Agent configuration (acpAdapter, agentPackage, prepareInstructions)
180
+ - `AgentType` — `string` (a package manifest `name`, e.g. `"pi"`, `"claude"`); agents are resolved dynamically from the configured `/opt/agentos` package manifests, so any manifest `name` is valid
181
+ - `AgentConfig` — Agent configuration (adapterEntrypoint, launchArgs, defaultEnv)
182
182
  - `AgentRegistryEntry` — Registry entry (id, acpAdapter, agentPackage, installed)
183
183
 
184
184
  **Session**
@@ -46,20 +46,14 @@ export interface BatchReadResult {
46
46
  /** Entry in the agent registry, describing an available agent type. */
47
47
  export interface AgentRegistryEntry {
48
48
  id: string;
49
- /** npm adapter package (legacy agents) — absent for `/opt/agentos` packages. */
50
- acpAdapter?: string;
51
- /** npm agent package (legacy agents) — absent for `/opt/agentos` packages. */
52
- agentPackage?: string;
53
- /** Pre-resolved adapter command path for an `/opt/agentos` agent package. */
54
- adapterEntrypoint?: string;
55
49
  installed: boolean;
56
50
  }
57
- import { type AgentType } from "./agents.js";
51
+ import type { AgentType } from "./types.js";
58
52
  import type { ScheduleDriver } from "./cron/schedule-driver.js";
59
53
  import type { CronEventHandler, CronJob, CronJobInfo, CronJobOptions } from "./cron/types.js";
60
54
  import { type LayerStore, type OverlayFilesystemMode, type RootSnapshotExport, type SnapshotLayerHandle } from "./layers.js";
61
55
  import { type SoftwareInput } from "./packages.js";
62
- import { type PackageDescriptor } from "./agentos-package.js";
56
+ import { type PackageRef, type SoftwarePackageRef } from "./agentos-package.js";
63
57
  import { type AgentOsSidecarPlacement } from "./sidecar/rpc-client.js";
64
58
  export interface AgentOsSharedSidecarOptions {
65
59
  pool?: string;
@@ -177,6 +171,10 @@ export interface AgentOsLimits {
177
171
  /** Guest JavaScript runtime buffering limits. */
178
172
  jsRuntime?: {
179
173
  v8HeapLimitMb?: number;
174
+ syncRpcWaitTimeoutMs?: number;
175
+ cpuTimeLimitMs?: number;
176
+ wallClockLimitMs?: number;
177
+ importCacheMaterializeTimeoutMs?: number;
180
178
  capturedOutputLimitBytes?: number;
181
179
  stdinBufferLimitBytes?: number;
182
180
  eventPayloadLimitBytes?: number;
@@ -186,6 +184,7 @@ export interface AgentOsLimits {
186
184
  python?: {
187
185
  outputBufferMaxBytes?: number;
188
186
  executionTimeoutMs?: number;
187
+ maxOldSpaceMb?: number;
189
188
  vfsRpcTimeoutMs?: number;
190
189
  };
191
190
  /** Guest WASM runtime limits. */
@@ -193,6 +192,8 @@ export interface AgentOsLimits {
193
192
  maxModuleFileBytes?: number;
194
193
  capturedOutputLimitBytes?: number;
195
194
  syncReadLimitBytes?: number;
195
+ prewarmTimeoutMs?: number;
196
+ runnerHeapLimitMb?: number;
196
197
  };
197
198
  }
198
199
  export interface AgentStderrEvent {
@@ -203,6 +204,38 @@ export interface AgentStderrEvent {
203
204
  chunk: Uint8Array;
204
205
  }
205
206
  export type AgentStderrHandler = (event: AgentStderrEvent) => void;
207
+ /**
208
+ * Auto-restart outcome reported on an {@link AgentExitEvent}. Mirrors the
209
+ * sidecar's `AcpAgentExitedEvent.restart` strings:
210
+ * - `"restarted"` — the adapter was respawned and the session was natively
211
+ * re-attached under the same session id; the session stays usable.
212
+ * - `"unsupported"` — the adapter does not advertise a native resume
213
+ * capability (`loadSession`/`resume`); the session was evicted.
214
+ * - `"failed"` — the respawn or re-attach errored; the session was evicted.
215
+ * - `"exhausted"` — the per-session restart budget was already spent; evicted.
216
+ */
217
+ export type AgentRestartOutcome = "restarted" | "unsupported" | "failed" | "exhausted";
218
+ /**
219
+ * An unexpected ACP adapter process exit — a crash from the host's
220
+ * perspective (any spontaneous exit without `closeSession()`, including exit
221
+ * code 0) — plus the sidecar's bounded auto-restart outcome.
222
+ */
223
+ export interface AgentExitEvent {
224
+ sessionId: string;
225
+ agentType: string;
226
+ /** Sidecar process id of the adapter that exited. */
227
+ processId: string;
228
+ pid: number | null;
229
+ /** Adapter exit code; `null` when the exit was observed indirectly. */
230
+ exitCode: number | null;
231
+ /** Auto-restart outcome; only `"restarted"` leaves the session usable. */
232
+ restart: AgentRestartOutcome;
233
+ /** Restarts consumed for this session so far. */
234
+ restartCount: number;
235
+ /** Per-session restart budget. */
236
+ maxRestarts: number;
237
+ }
238
+ export type AgentExitHandler = (event: AgentExitEvent) => void;
206
239
  /**
207
240
  * A near-capacity warning for one bounded limit (a queue/buffer, a saturating
208
241
  * resource cap, or a memory envelope) inside the VM runtime. Delivered the moment
@@ -232,11 +265,8 @@ export type LimitWarningHandler = (warning: LimitWarning) => void;
232
265
  */
233
266
  export interface AgentOsOptions {
234
267
  /**
235
- * Software to install in the VM. Each entry provides agents, tools,
236
- * or WASM commands. Any object with a `commandDir` property (e.g.,
237
- * registry packages like @agentos-software/coreutils) is treated
238
- * as a WASM command source automatically. Arrays are flattened, so
239
- * meta-packages that export arrays of sub-packages work directly.
268
+ * Software to install in the VM. Each entry is a package-dir ref. Arrays are
269
+ * flattened, so meta-packages that export arrays of sub-packages work directly.
240
270
  */
241
271
  software?: SoftwareInput[];
242
272
  /**
@@ -254,15 +284,18 @@ export interface AgentOsOptions {
254
284
  * Defaults to the hardened builtin set used by the native sidecar bridge.
255
285
  */
256
286
  allowedNodeBuiltins?: string[];
287
+ /**
288
+ * Opt in to a high-resolution monotonic guest clock (microsecond class)
289
+ * for guest Node processes. Default `false` keeps the security-oriented
290
+ * 1ms timer resolution — untrusted guest code should not get a precise
291
+ * timer (timing side channels). Enable only for trusted benchmarking or
292
+ * profiling workloads.
293
+ */
294
+ highResolutionTime?: boolean;
257
295
  /** Root filesystem configuration. Defaults to an overlay with the bundled base snapshot as its deepest lower. */
258
296
  rootFilesystem?: RootFilesystemConfig;
259
297
  /** Filesystems to mount at boot time. */
260
298
  mounts?: MountConfig[];
261
- /**
262
- * @deprecated Use `mounts: [nodeModulesMount(path)]` instead.
263
- * Compatibility alias for mounting `<moduleAccessCwd>/node_modules` at `/root/node_modules`.
264
- */
265
- moduleAccessCwd?: string;
266
299
  /** Additional instructions appended to the base OS system prompt injected at session start. */
267
300
  additionalInstructions?: string;
268
301
  /** Custom schedule driver for cron jobs. Defaults to TimerScheduleDriver. */
@@ -291,6 +324,15 @@ export interface AgentOsOptions {
291
324
  * `process.stderr`.
292
325
  */
293
326
  onAgentStderr?: AgentStderrHandler;
327
+ /**
328
+ * Called when the ACP adapter process behind a session exits without
329
+ * `closeSession()` — i.e. an adapter crash. The sidecar auto-restarts the
330
+ * adapter (bounded per session, natively re-attaching the same session id)
331
+ * and reports the outcome on the event; only `restart === "restarted"`
332
+ * leaves the session usable. Defaults to writing a warning line to
333
+ * `process.stderr`.
334
+ */
335
+ onAgentExit?: AgentExitHandler;
294
336
  /**
295
337
  * Called when a bounded limit inside the VM runtime approaches capacity
296
338
  * (~80%, edge-triggered with hysteresis so it does not spam). Use it to alert
@@ -397,12 +439,9 @@ export declare class AgentOs {
397
439
  private _closedShellIds;
398
440
  private _pendingShellExitPromises;
399
441
  private _shellCounter;
400
- /** Command names linked into `/opt/agentos/bin` at runtime (via the sidecar). */
401
- private _linkedCommands;
402
442
  private _acpTerminals;
403
443
  private _acpTerminalCounter;
404
444
  private _softwareRoots;
405
- private _softwareAgentConfigs;
406
445
  private _cronManager;
407
446
  private _toolKits;
408
447
  private _toolReference;
@@ -417,6 +456,7 @@ export declare class AgentOs {
417
456
  private readonly _sidecarVm;
418
457
  private readonly _disposeSidecarEventListener;
419
458
  private readonly _agentStderrHandler?;
459
+ private readonly _agentExitHandler?;
420
460
  private readonly _limitWarningHandler?;
421
461
  private constructor();
422
462
  static createSidecar(options?: AgentOsCreateSidecarOptions): Promise<AgentOsSidecar>;
@@ -443,7 +483,6 @@ export declare class AgentOs {
443
483
  private _assertSafeAbsolutePath;
444
484
  private _assertWritableAbsolutePath;
445
485
  private _vfs;
446
- private _copyPath;
447
486
  readFile(path: string): Promise<Uint8Array>;
448
487
  writeFile(path: string, content: string | Uint8Array): Promise<void>;
449
488
  writeFiles(entries: BatchWriteEntry[]): Promise<BatchWriteResult[]>;
@@ -477,7 +516,11 @@ export declare class AgentOs {
477
516
  onShellData(shellId: string, handler: (data: Uint8Array) => void): () => void;
478
517
  /** Notify a shell of terminal resize. */
479
518
  resizeShell(shellId: string, cols: number, rows: number): void;
480
- /** Wait for a shell to exit and return its process exit code. */
519
+ /**
520
+ * Wait for a shell to exit and return its process exit code. Resolves
521
+ * immediately for a shell that has already exited (within the closed-shell
522
+ * retention window).
523
+ */
481
524
  waitShell(shellId: string): Promise<number>;
482
525
  /** Kill a shell process and remove it from tracking. */
483
526
  closeShell(shellId: string): void;
@@ -506,9 +549,18 @@ export declare class AgentOs {
506
549
  * block registers the package for `createSession(name)`. Persists for the VM's
507
550
  * lifetime (and across a snapshot iff the volume persists).
508
551
  */
509
- linkSoftware(descriptor: PackageDescriptor): Promise<void>;
510
- /** Returns all registered agents with their installation status. */
511
- listAgents(): AgentRegistryEntry[];
552
+ linkSoftware(descriptor: PackageRef | SoftwarePackageRef): Promise<void>;
553
+ providedCommands(): Promise<{
554
+ packageName: string;
555
+ commands: string[];
556
+ }[]>;
557
+ /**
558
+ * Returns all registered agents with their installation status. Thin forwarder:
559
+ * sends `AcpListAgentsRequest` and maps the response. The sidecar enumerates the
560
+ * projected `/opt/agentos` packages (the client parses no manifests). Every such
561
+ * agent is a package materialized into the VM, so `installed` is always `true`.
562
+ */
563
+ listAgents(): Promise<AgentRegistryEntry[]>;
512
564
  private _syncSessionState;
513
565
  private _applySessionUpdate;
514
566
  private _recordSessionNotification;
@@ -532,6 +584,7 @@ export declare class AgentOs {
532
584
  */
533
585
  private _emitSessionWarning;
534
586
  private _recordAgentStderr;
587
+ private _recordAgentExit;
535
588
  private _applySyntheticConfigOverrides;
536
589
  private _handleSidecarEvent;
537
590
  private _handleLimitWarning;
@@ -547,7 +600,7 @@ export declare class AgentOs {
547
600
  private _rejectPendingPermissionRepliesFromSession;
548
601
  private _closeSessionInternal;
549
602
  private _hydrateSessionState;
550
- createSession(agentType: AgentType | string, options?: CreateSessionOptions): Promise<{
603
+ createSession(agentType: AgentType, options?: CreateSessionOptions): Promise<{
551
604
  sessionId: string;
552
605
  }>;
553
606
  /**
@@ -565,7 +618,7 @@ export declare class AgentOs {
565
618
  * Resume depends on a durable root; on a non-durable (default in-memory) root
566
619
  * there is no surviving store and the fallback tier always runs.
567
620
  */
568
- resumeSession(sessionId: string, agentType: AgentType | string, options?: ResumeSessionOptions): Promise<ResumeSessionResult>;
621
+ resumeSession(sessionId: string, agentType: AgentType, options?: ResumeSessionOptions): Promise<ResumeSessionResult>;
569
622
  private _installSidecarRequestHandler;
570
623
  private _handleAcpExtSidecarRequest;
571
624
  private _dispatchAcpSidecarRequest;
@@ -592,11 +645,6 @@ export declare class AgentOs {
592
645
  private _handleAcpReleaseTerminal;
593
646
  private _handleAcpResizeTerminal;
594
647
  private _handleAcpPermissionCallback;
595
- /**
596
- * Resolve an agent config by ID. Package-provided configs take
597
- * precedence over the hardcoded AGENT_CONFIGS.
598
- */
599
- private _resolveAgentConfig;
600
648
  /**
601
649
  * Gracefully destroy a session: cancel any pending work, close the client,
602
650
  * and remove from tracking. Unlike close() which is abrupt, this attempts