@rivet-dev/agentos 0.0.0-integrate-dylib-into-main.815fcda → 0.0.0-nathan-binding-workspace.4640d5c

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/dist/mod.d.ts ADDED
@@ -0,0 +1,594 @@
1
+ import { ActorDefinition, Type } from 'rivetkit';
2
+ export { setup } from 'rivetkit';
3
+
4
+ /**
5
+ * `@rivet-dev/agentos` — the user-facing Agent OS integration for RivetKit.
6
+ *
7
+ * INTERIM "types-now, noop-the-runtime" STUB.
8
+ *
9
+ * This package owns the Agent OS-specific TypeScript surface (config schema
10
+ * type, events, the actor-definition type, the `vm.*` action interface, and
11
+ * the `nodeModulesMount` helper) and imports only GENERIC primitives (the
12
+ * actor definition / registry / action context) from `rivetkit`.
13
+ *
14
+ * The runtime is intentionally NOT wired: `agentOS()` returns a correctly
15
+ * typed RivetKit actor definition whose action handler bodies THROW. This
16
+ * lets consumers (examples, downstream packages) type-check against the real
17
+ * shape before the native runtime (dylib) lands, without pulling in any napi
18
+ * / native module. When the dylib is ready, swap the throwing handlers for
19
+ * the native factory builder — the public types do not change.
20
+ */
21
+
22
+ /** A JSON-RPC notification frame emitted by the ACP adapter. */
23
+ interface JsonRpcNotification {
24
+ jsonrpc: "2.0";
25
+ method: string;
26
+ params?: unknown;
27
+ }
28
+ /** A JSON-RPC response frame returned by the ACP adapter. */
29
+ interface JsonRpcResponse {
30
+ jsonrpc: "2.0";
31
+ id: number | string;
32
+ result?: unknown;
33
+ error?: {
34
+ code: number;
35
+ message: string;
36
+ data?: unknown;
37
+ };
38
+ }
39
+ /** A permission request surfaced by the agent to the host. */
40
+ interface PermissionRequest {
41
+ /** Stable id used to reply to this specific request via `respondPermission`. */
42
+ permissionId: string;
43
+ /** Optional human-readable description of what is being requested. */
44
+ description?: string;
45
+ /** Raw ACP permission params (tool name, input, options, etc.). */
46
+ params?: Record<string, unknown>;
47
+ /** @deprecated legacy alias retained for older docs snippets. */
48
+ toolName?: string;
49
+ /** @deprecated legacy alias retained for older docs snippets. */
50
+ rationale?: string;
51
+ /** @deprecated legacy alias retained for older docs snippets. */
52
+ input?: unknown;
53
+ }
54
+ /** Reply to a permission request: allow once, allow always, or reject. */
55
+ type PermissionReply = "once" | "always" | "reject";
56
+ /** One selectable agent mode (e.g. "plan", "auto"). */
57
+ interface SessionMode {
58
+ id: string;
59
+ name?: string;
60
+ label?: string;
61
+ description?: string;
62
+ [key: string]: unknown;
63
+ }
64
+ /** The set of modes available to a session plus the current selection. */
65
+ interface SessionModeState {
66
+ currentModeId: string;
67
+ availableModes: SessionMode[];
68
+ }
69
+ /** A configurable session option (model, thought level, etc.). */
70
+ interface SessionConfigOption {
71
+ id: string;
72
+ category?: string;
73
+ label?: string;
74
+ description?: string;
75
+ currentValue?: string;
76
+ allowedValues?: Array<{
77
+ id: string;
78
+ label?: string;
79
+ }>;
80
+ readOnly?: boolean;
81
+ }
82
+ /** Capabilities advertised by an ACP agent during initialization. */
83
+ interface AgentCapabilities {
84
+ loadSession?: boolean;
85
+ promptCapabilities?: Record<string, unknown>;
86
+ [key: string]: unknown;
87
+ }
88
+ /** Identity metadata advertised by an ACP agent. */
89
+ interface AgentInfo {
90
+ name: string;
91
+ version?: string;
92
+ [key: string]: unknown;
93
+ }
94
+ /** A cron tick delivered to the actor. */
95
+ interface CronEvent {
96
+ id: string;
97
+ schedule: string;
98
+ firedAt: number;
99
+ }
100
+ /** POSIX-style stat record returned by `stat`. */
101
+ interface VirtualStat {
102
+ mode: number;
103
+ size: number;
104
+ blocks: number;
105
+ dev: number;
106
+ rdev: number;
107
+ isDirectory: boolean;
108
+ isSymbolicLink: boolean;
109
+ atimeMs: number;
110
+ mtimeMs: number;
111
+ ctimeMs: number;
112
+ birthtimeMs: number;
113
+ ino: number;
114
+ nlink: number;
115
+ uid: number;
116
+ gid: number;
117
+ }
118
+ /** A directory entry with metadata (returned by `readdirRecursive`). */
119
+ interface DirEntry {
120
+ /** Absolute path to the entry. */
121
+ path: string;
122
+ type: "file" | "directory" | "symlink";
123
+ size: number;
124
+ }
125
+ /** Options for `readdirRecursive`. */
126
+ interface ReaddirRecursiveOptions {
127
+ /** Maximum depth to recurse (0 = only immediate children). */
128
+ maxDepth?: number;
129
+ /** Directory names to skip. */
130
+ exclude?: string[];
131
+ }
132
+ /** A single file in a batch write (`writeFiles`). */
133
+ interface BatchWriteEntry {
134
+ path: string;
135
+ content: string | Uint8Array;
136
+ }
137
+ /** Result of a single file in a batch write. */
138
+ interface BatchWriteResult {
139
+ path: string;
140
+ success: boolean;
141
+ error?: string;
142
+ }
143
+ /** Result of a single file in a batch read (`readFiles`). */
144
+ interface BatchReadResult {
145
+ path: string;
146
+ content: Uint8Array | null;
147
+ error?: string;
148
+ }
149
+ /** A single entry in an exported root filesystem snapshot. */
150
+ interface FilesystemEntry {
151
+ path: string;
152
+ type: "file" | "directory" | "symlink";
153
+ mode: string;
154
+ uid: number;
155
+ gid: number;
156
+ content?: string;
157
+ encoding?: "utf8" | "base64";
158
+ target?: string;
159
+ }
160
+ /** A serializable export of the VM root filesystem. */
161
+ interface RootSnapshotExport {
162
+ kind: "snapshot-export";
163
+ source: {
164
+ format: "agentos-filesystem-snapshot-v1";
165
+ filesystem: {
166
+ entries: FilesystemEntry[];
167
+ };
168
+ };
169
+ }
170
+ /** Options for `exec` / `execArgv`. */
171
+ interface ExecOptions {
172
+ env?: Record<string, string>;
173
+ cwd?: string;
174
+ stdin?: string | Uint8Array;
175
+ timeout?: number;
176
+ captureStdio?: boolean;
177
+ }
178
+ /** Result of a synchronous `exec` / `execArgv`. */
179
+ interface ExecResult {
180
+ exitCode: number;
181
+ stdout: string;
182
+ stderr: string;
183
+ }
184
+ /** Options for `spawn`. */
185
+ interface SpawnOptions {
186
+ env?: Record<string, string>;
187
+ cwd?: string;
188
+ stdin?: string | Uint8Array;
189
+ }
190
+ /** Info about a process spawned via `spawn`. */
191
+ interface SpawnedProcessInfo {
192
+ pid: number;
193
+ command: string;
194
+ args: string[];
195
+ running: boolean;
196
+ exitCode: number | null;
197
+ }
198
+ /** Options for `openShell` / `connectTerminal`. */
199
+ interface OpenShellOptions {
200
+ command?: string;
201
+ args?: string[];
202
+ env?: Record<string, string>;
203
+ cwd?: string;
204
+ cols?: number;
205
+ rows?: number;
206
+ }
207
+ /** Options for `connectTerminal` (a shell plus a streaming data callback). */
208
+ interface ConnectTerminalOptions extends OpenShellOptions {
209
+ onData?: (data: Uint8Array) => void;
210
+ }
211
+ /** Options for `vmFetch` (method/headers/body for the proxied request). */
212
+ interface VmFetchOptions {
213
+ method?: string;
214
+ headers?: Record<string, string>;
215
+ body?: string | Uint8Array;
216
+ }
217
+ /** Response returned by `vmFetch`. */
218
+ interface VmFetchResponse {
219
+ status: number;
220
+ statusText?: string;
221
+ headers?: Array<[string, string]>;
222
+ body: Uint8Array;
223
+ }
224
+ /** A time-limited, token-based preview URL for a VM port. */
225
+ interface PreviewUrl {
226
+ /** Signed path (including token query) to proxy to the VM port. */
227
+ path: string;
228
+ /** Opaque signed token authorizing the proxy. */
229
+ token: string;
230
+ /** Epoch millis at which the token expires. */
231
+ expiresAt: number;
232
+ }
233
+ /** An in-memory session event with its monotonic sequence number. */
234
+ interface SequencedSessionEvent {
235
+ sequenceNumber: number;
236
+ notification: JsonRpcNotification;
237
+ }
238
+ /** Options for `getSequencedEvents` (replay in-memory events after `since`). */
239
+ interface GetSequencedEventsOptions {
240
+ /** Return only events with a sequence number greater than this value. */
241
+ since?: number;
242
+ }
243
+ /**
244
+ * Serializable Agent OS VM options. These fields are accepted at the top level
245
+ * of `agentOS({ ... })` (see `AgentOSActorConfigInput`); this type collects
246
+ * them for callers that want to build the option set as a standalone value.
247
+ *
248
+ * Kept structurally open: the full option set is owned by the sidecar/native
249
+ * layer and forwarded across the boundary, so consumers configure it as data.
250
+ */
251
+ interface AgentOSOptions {
252
+ software?: unknown;
253
+ additionalInstructions?: string;
254
+ loopbackExemptPorts?: number[];
255
+ allowedNodeBuiltins?: string[];
256
+ permissions?: unknown;
257
+ rootFilesystem?: unknown;
258
+ mounts?: unknown[];
259
+ limits?: unknown;
260
+ sidecar?: unknown;
261
+ [key: string]: unknown;
262
+ }
263
+ /**
264
+ * A native `host_dir` mount of a host `node_modules` directory at
265
+ * `/root/node_modules`.
266
+ */
267
+ interface NodeModulesMountConfig {
268
+ path: "/root/node_modules";
269
+ plugin: {
270
+ id: "host_dir";
271
+ config: {
272
+ hostPath: string;
273
+ readOnly: boolean;
274
+ };
275
+ };
276
+ readOnly: boolean;
277
+ }
278
+ /**
279
+ * Mount a host `node_modules` directory into the VM at `/root/node_modules`.
280
+ *
281
+ * @param hostNodeModulesDir Absolute host path to a `node_modules` directory.
282
+ * @param opts.readOnly Defaults to `true`; the mount is read-only.
283
+ */
284
+ declare function nodeModulesMount(hostNodeModulesDir: string, opts?: {
285
+ readOnly?: boolean;
286
+ }): NodeModulesMountConfig;
287
+ type AgentOSActorState = {};
288
+ interface AgentOSActorVars {
289
+ activeSessionIds: Set<string>;
290
+ activeProcesses: Set<number>;
291
+ activeShells: Set<string>;
292
+ sessions: Set<string>;
293
+ }
294
+ interface SessionEventPayload {
295
+ sessionId: string;
296
+ event: JsonRpcNotification;
297
+ }
298
+ interface PermissionRequestPayload {
299
+ sessionId: string;
300
+ request: PermissionRequest;
301
+ }
302
+ type VmBootedPayload = Record<string, never>;
303
+ interface VmShutdownPayload {
304
+ reason: "sleep" | "destroy" | "error";
305
+ }
306
+ interface ProcessOutputPayload {
307
+ pid: number;
308
+ stream: "stdout" | "stderr";
309
+ data: Uint8Array;
310
+ }
311
+ interface ProcessExitPayload {
312
+ pid: number;
313
+ exitCode: number;
314
+ }
315
+ interface ShellDataPayload {
316
+ shellId: string;
317
+ data: Uint8Array;
318
+ }
319
+ interface CronEventPayload {
320
+ event: CronEvent;
321
+ }
322
+ declare const agentOSEvents: {
323
+ sessionEvent: Type<SessionEventPayload>;
324
+ permissionRequest: Type<PermissionRequestPayload>;
325
+ vmBooted: Type<VmBootedPayload>;
326
+ vmShutdown: Type<VmShutdownPayload>;
327
+ processOutput: Type<ProcessOutputPayload>;
328
+ processExit: Type<ProcessExitPayload>;
329
+ shellData: Type<ShellDataPayload>;
330
+ cronEvent: Type<CronEventPayload>;
331
+ };
332
+ /** Event schema map type for the actor `events` config (payload-inferring). */
333
+ type AgentOSEvents = typeof agentOSEvents;
334
+ interface PromptResult {
335
+ response: JsonRpcResponse;
336
+ text: string;
337
+ }
338
+ interface SessionRecord {
339
+ sessionId: string;
340
+ agentType: string;
341
+ capabilities: AgentCapabilities;
342
+ agentInfo: AgentInfo | null;
343
+ }
344
+ interface PersistedSessionRecord extends SessionRecord {
345
+ createdAt: number;
346
+ }
347
+ interface PersistedSessionEvent {
348
+ sessionId: string;
349
+ seq: number;
350
+ event: JsonRpcNotification;
351
+ createdAt: number;
352
+ }
353
+ type SerializableCronAction = {
354
+ type: "session";
355
+ agentType: string;
356
+ prompt: string;
357
+ /** Session options applied when the cron fires (cwd, env, etc.). */
358
+ options?: CreateSessionOptions;
359
+ } | {
360
+ type: "exec";
361
+ command: string;
362
+ args?: string[];
363
+ };
364
+ interface SerializableCronJobOptions {
365
+ id?: string;
366
+ schedule: string;
367
+ action: SerializableCronAction;
368
+ overlap?: "allow" | "skip" | "queue";
369
+ }
370
+ /** Result of scheduling a cron job. */
371
+ interface ScheduledCronJob {
372
+ id: string;
373
+ }
374
+ /** Info about a registered cron job (returned by `listCronJobs`). */
375
+ interface CronJobInfo {
376
+ id: string;
377
+ schedule: string;
378
+ action: SerializableCronAction;
379
+ overlap: "allow" | "skip" | "queue";
380
+ }
381
+ /**
382
+ * Input config passed to `agentOS(...)`.
383
+ *
384
+ * The VM option fields live at the TOP LEVEL (no nested `options` key), so
385
+ * callers write `agentOS({ software: [...], additionalInstructions: "..." })`.
386
+ */
387
+ interface AgentOSActorConfigInput<TConnParams = undefined> {
388
+ /**
389
+ * Software packages to install in the VM. Pass the imported packages
390
+ * directly (e.g. `software: [common, pi]`); kept loosely typed so any
391
+ * software package import type-checks.
392
+ */
393
+ software?: unknown[];
394
+ /** Additional instructions appended to the base OS instructions. */
395
+ additionalInstructions?: string;
396
+ /** Ports exempt from the loopback-only network restriction. */
397
+ loopbackExemptPorts?: number[];
398
+ /** Node.js builtins the guest is allowed to import. */
399
+ allowedNodeBuiltins?: string[];
400
+ /** Permission policy applied to the VM. */
401
+ permissions?: unknown;
402
+ /** Root filesystem configuration / snapshot. */
403
+ rootFilesystem?: unknown;
404
+ /** Host-backed mounts exposed inside the VM. */
405
+ mounts?: unknown[];
406
+ /** Bindings exposed to agents as CLI commands inside the VM. */
407
+ bindings?: unknown[];
408
+ /** Per-VM resource limits. */
409
+ limits?: unknown;
410
+ /** Low-level runtime configuration. */
411
+ sidecar?: unknown;
412
+ preview?: {
413
+ defaultExpiresInSeconds?: number;
414
+ maxExpiresInSeconds?: number;
415
+ };
416
+ onSessionEvent?: (sessionId: string, event: JsonRpcNotification) => void | Promise<void>;
417
+ onPermissionRequest?: (sessionId: string, request: PermissionRequest) => void | Promise<void>;
418
+ __connParams?: TConnParams;
419
+ }
420
+ /** Parsed config (after defaults applied). */
421
+ interface AgentOSActorConfig<TConnParams = undefined> extends AgentOSActorConfigInput<TConnParams> {
422
+ preview: {
423
+ defaultExpiresInSeconds: number;
424
+ maxExpiresInSeconds: number;
425
+ };
426
+ }
427
+ /** A local MCP server launched as a child process inside the VM. */
428
+ interface McpServerConfigLocal {
429
+ type: "local";
430
+ /** Command to launch the MCP server. */
431
+ command: string;
432
+ /** Arguments for the command. */
433
+ args?: string[];
434
+ /** Environment variables for the server process. */
435
+ env?: Record<string, string>;
436
+ }
437
+ /** A remote MCP server reachable over HTTP. */
438
+ interface McpServerConfigRemote {
439
+ type: "remote";
440
+ /** URL of the remote MCP server. */
441
+ url: string;
442
+ /** HTTP headers to include in requests to the server. */
443
+ headers?: Record<string, string>;
444
+ }
445
+ type McpServerConfig = McpServerConfigLocal | McpServerConfigRemote;
446
+ /** Options accepted by `createSession(agentType, options?)`. */
447
+ interface CreateSessionOptions {
448
+ /** Working directory for the agent session inside the VM. Defaults to /workspace. */
449
+ cwd?: string;
450
+ /** Environment variables passed to the agent process (e.g. API keys). */
451
+ env?: Record<string, string>;
452
+ /** MCP servers made available to the agent during the session. */
453
+ mcpServers?: McpServerConfig[];
454
+ /** Skip OS instructions injection entirely (default false). */
455
+ skipOsInstructions?: boolean;
456
+ /** Additional instructions appended to the base OS instructions. */
457
+ additionalInstructions?: string;
458
+ }
459
+ /**
460
+ * The `vm.*` action surface as the SERVER defines it. Each handler receives
461
+ * the RivetKit action context (`c`) as its first argument; RivetKit strips
462
+ * that context when projecting these onto the client handle, so callers invoke
463
+ * e.g. `handle.createSession("claude", { env: { ANTHROPIC_API_KEY } })`.
464
+ *
465
+ * The string index signature satisfies RivetKit's `Actions` constraint.
466
+ */
467
+ interface VmActions {
468
+ /** Create an ACP session against a registered agent and return its record. */
469
+ createSession(c: any, agentType: string, options?: CreateSessionOptions): Promise<SessionRecord>;
470
+ /** Send a prompt to an existing session and accumulate the agent's reply. */
471
+ sendPrompt(c: any, sessionId: string, prompt: string): Promise<PromptResult>;
472
+ /** Alias of `sendPrompt`: send a prompt and accumulate the agent's reply. */
473
+ prompt(c: any, sessionId: string, text: string): Promise<PromptResult>;
474
+ /** Cancel the in-flight prompt for a session (leaves the session open). */
475
+ cancelPrompt(c: any, sessionId: string): Promise<JsonRpcResponse>;
476
+ /** Cancel ongoing agent work for a session. */
477
+ cancelSession(c: any, sessionId: string): Promise<JsonRpcResponse>;
478
+ /** List the sessions currently tracked by this VM. */
479
+ listSessions(c: any): Promise<SessionRecord[]>;
480
+ /** Tear down an ACP session abruptly. */
481
+ closeSession(c: any, sessionId: string): Promise<void>;
482
+ /** Gracefully destroy a session (cancel pending work, then close). */
483
+ destroySession(c: any, sessionId: string): Promise<void>;
484
+ /** Reply to a pending permission request raised by the agent. */
485
+ respondPermission(c: any, sessionId: string, permissionId: string, reply: PermissionReply): Promise<JsonRpcResponse>;
486
+ /** Switch the active mode (e.g. "plan", "auto") for a session. */
487
+ setMode(c: any, sessionId: string, modeId: string): Promise<JsonRpcResponse>;
488
+ /** Switch the active model for a session. */
489
+ setModel(c: any, sessionId: string, model: string): Promise<JsonRpcResponse>;
490
+ /** Switch the thought/reasoning level for a session. */
491
+ setThoughtLevel(c: any, sessionId: string, level: string): Promise<JsonRpcResponse>;
492
+ /** Get the available + current modes for a session. */
493
+ getModes(c: any, sessionId: string): Promise<SessionModeState | null>;
494
+ /** Get the configurable options (model, thought level, ...) for a session. */
495
+ getConfigOptions(c: any, sessionId: string): Promise<SessionConfigOption[]>;
496
+ /** Replay in-memory session events (live reconnection); newer than `since`. */
497
+ getSequencedEvents(c: any, sessionId: string, options?: GetSequencedEventsOptions): Promise<SequencedSessionEvent[]>;
498
+ /** Replay persisted session events from durable storage (transcript history). */
499
+ getSessionEvents(c: any, sessionId: string): Promise<PersistedSessionEvent[]>;
500
+ /** List persisted session records (including for VMs not currently running). */
501
+ listPersistedSessions(c: any): Promise<PersistedSessionRecord[]>;
502
+ /** Run a command line to completion and capture its output. */
503
+ exec(c: any, command: string, options?: ExecOptions): Promise<ExecResult>;
504
+ /** Run a command (argv form, no shell) to completion and capture output. */
505
+ execArgv(c: any, command: string, args?: readonly string[], options?: ExecOptions): Promise<ExecResult>;
506
+ /** Spawn a long-running process and return its pid. */
507
+ spawn(c: any, command: string, args?: string[], options?: SpawnOptions): Promise<{
508
+ pid: number;
509
+ }>;
510
+ /** Spawn a process inside the VM and return its pid. */
511
+ spawnProcess(c: any, command: string, args?: string[]): Promise<number>;
512
+ /** List processes spawned via `spawn`. */
513
+ listProcesses(c: any): Promise<SpawnedProcessInfo[]>;
514
+ /** Get info about a single spawned process. */
515
+ getProcess(c: any, pid: number): Promise<SpawnedProcessInfo>;
516
+ /** Write data to a spawned process's stdin. */
517
+ writeProcessStdin(c: any, pid: number, data: string | Uint8Array): Promise<void>;
518
+ /** Close a spawned process's stdin stream. */
519
+ closeProcessStdin(c: any, pid: number): Promise<void>;
520
+ /** Wait for a process to exit and return its exit code. */
521
+ waitProcess(c: any, pid: number): Promise<number>;
522
+ /** Gracefully stop a process (SIGTERM). */
523
+ stopProcess(c: any, pid: number): Promise<void>;
524
+ /** Force-kill a running process by pid (SIGKILL). */
525
+ killProcess(c: any, pid: number): Promise<void>;
526
+ /** Open an interactive shell (PTY) and return its id. */
527
+ openShell(c: any, options?: OpenShellOptions): Promise<{
528
+ shellId: string;
529
+ }>;
530
+ /** Connect a terminal (PTY) to the VM and return its pid. */
531
+ connectTerminal(c: any, options?: ConnectTerminalOptions): Promise<number>;
532
+ /** Write input to a shell's PTY. */
533
+ writeShell(c: any, shellId: string, data: string | Uint8Array): Promise<void>;
534
+ /** Resize a shell's PTY. */
535
+ resizeShell(c: any, shellId: string, cols: number, rows: number): Promise<void>;
536
+ /** Close a shell and free its PTY. */
537
+ closeShell(c: any, shellId: string): Promise<void>;
538
+ /** Read a file from the VM filesystem. */
539
+ readFile(c: any, path: string): Promise<Uint8Array>;
540
+ /** Write a file into the VM filesystem. */
541
+ writeFile(c: any, path: string, content: Uint8Array | string): Promise<void>;
542
+ /** Write several files in one call, reporting per-file success. */
543
+ writeFiles(c: any, entries: BatchWriteEntry[]): Promise<BatchWriteResult[]>;
544
+ /** Read several files in one call, reporting per-file content/errors. */
545
+ readFiles(c: any, paths: string[]): Promise<BatchReadResult[]>;
546
+ /** Create a directory (optionally recursive). */
547
+ mkdir(c: any, path: string, options?: {
548
+ recursive?: boolean;
549
+ }): Promise<void>;
550
+ /** List the immediate entries of a directory. */
551
+ readdir(c: any, path: string): Promise<string[]>;
552
+ /** Recursively list directory entries with metadata. */
553
+ readdirRecursive(c: any, path: string, options?: ReaddirRecursiveOptions): Promise<DirEntry[]>;
554
+ /** Stat a path. */
555
+ stat(c: any, path: string): Promise<VirtualStat>;
556
+ /** Check whether a path exists. */
557
+ exists(c: any, path: string): Promise<boolean>;
558
+ /** Move/rename a path. */
559
+ move(c: any, from: string, to: string): Promise<void>;
560
+ /** Delete a path (optionally recursive). */
561
+ delete(c: any, path: string, options?: {
562
+ recursive?: boolean;
563
+ }): Promise<void>;
564
+ /** Export a serializable snapshot of the VM root filesystem. */
565
+ snapshotRootFilesystem(c: any): Promise<RootSnapshotExport>;
566
+ /** Proxy an HTTP request to a port inside the VM and return the response. */
567
+ vmFetch(c: any, port: number, path: string, options?: VmFetchOptions): Promise<VmFetchResponse>;
568
+ /** Create a time-limited, token-based preview URL for a VM port. */
569
+ createSignedPreviewUrl(c: any, port: number, expiresInSeconds?: number): Promise<PreviewUrl>;
570
+ /** Schedule a serializable cron job inside the VM. */
571
+ scheduleCron(c: any, options: SerializableCronJobOptions): Promise<ScheduledCronJob>;
572
+ /** List the cron jobs registered on this VM. */
573
+ listCronJobs(c: any): Promise<CronJobInfo[]>;
574
+ /** Cancel a registered cron job by id. */
575
+ cancelCronJob(c: any, id: string): Promise<void>;
576
+ /** Index signature required by RivetKit's `Actions` constraint. */
577
+ [action: string]: (c: any, ...args: any[]) => any;
578
+ }
579
+ /**
580
+ * The `agentOS(...)` actor definition type. Mirrors RivetKit's generic
581
+ * `ActorDefinition` with the Agent OS state/vars/events/actions bound in.
582
+ */
583
+ type AgentOSActorDefinition<TConnParams = undefined> = ActorDefinition<AgentOSActorState, TConnParams, undefined, AgentOSActorVars, undefined, any, AgentOSEvents, Record<never, never>, VmActions>;
584
+ /**
585
+ * Build the Agent OS actor definition.
586
+ *
587
+ * STUB: returns a correctly typed RivetKit actor definition whose action
588
+ * handlers throw. No native/napi module is imported. Replace the throwing
589
+ * handlers with the native factory builder once the runtime ships; the public
590
+ * type surface is stable.
591
+ */
592
+ declare function agentOS<TConnParams = undefined>(_config: AgentOSActorConfigInput<TConnParams>): AgentOSActorDefinition<TConnParams>;
593
+
594
+ export { type AgentCapabilities, type AgentInfo, type AgentOSActorConfig, type AgentOSActorConfigInput, type AgentOSActorDefinition, type AgentOSActorState, type AgentOSActorVars, type AgentOSEvents, type AgentOSOptions, type BatchReadResult, type BatchWriteEntry, type BatchWriteResult, type ConnectTerminalOptions, type CreateSessionOptions, type CronEvent, type CronEventPayload, type CronJobInfo, type DirEntry, type ExecOptions, type ExecResult, type FilesystemEntry, type GetSequencedEventsOptions, type JsonRpcNotification, type JsonRpcResponse, type McpServerConfig, type McpServerConfigLocal, type McpServerConfigRemote, type NodeModulesMountConfig, type OpenShellOptions, type PermissionReply, type PermissionRequest, type PermissionRequestPayload, type PersistedSessionEvent, type PersistedSessionRecord, type PreviewUrl, type ProcessExitPayload, type ProcessOutputPayload, type PromptResult, type ReaddirRecursiveOptions, type RootSnapshotExport, type ScheduledCronJob, type SequencedSessionEvent, type SerializableCronAction, type SerializableCronJobOptions, type SessionConfigOption, type SessionEventPayload, type SessionMode, type SessionModeState, type SessionRecord, type ShellDataPayload, type SpawnOptions, type SpawnedProcessInfo, type VirtualStat, type VmActions, type VmBootedPayload, type VmFetchOptions, type VmFetchResponse, type VmShutdownPayload, agentOS, nodeModulesMount };
package/dist/mod.js ADDED
@@ -0,0 +1,107 @@
1
+ // src/mod.ts
2
+ import { actor, event } from "rivetkit";
3
+ import { setup } from "rivetkit";
4
+ function nodeModulesMount(hostNodeModulesDir, opts) {
5
+ const readOnly = opts?.readOnly ?? true;
6
+ return {
7
+ path: "/root/node_modules",
8
+ plugin: {
9
+ id: "host_dir",
10
+ config: { hostPath: hostNodeModulesDir, readOnly }
11
+ },
12
+ readOnly
13
+ };
14
+ }
15
+ var typedEvent = () => event();
16
+ var agentOSEvents = {
17
+ sessionEvent: typedEvent(),
18
+ permissionRequest: typedEvent(),
19
+ vmBooted: typedEvent(),
20
+ vmShutdown: typedEvent(),
21
+ processOutput: typedEvent(),
22
+ processExit: typedEvent(),
23
+ shellData: typedEvent(),
24
+ cronEvent: typedEvent()
25
+ };
26
+ var RUNTIME_NOT_WIRED = "agentos runtime not yet wired \u2014 dylib pending";
27
+ function agentOS(_config) {
28
+ const notWired = () => {
29
+ throw new Error(RUNTIME_NOT_WIRED);
30
+ };
31
+ const definition = actor({
32
+ state: {},
33
+ createVars: () => ({
34
+ activeSessionIds: /* @__PURE__ */ new Set(),
35
+ activeProcesses: /* @__PURE__ */ new Set(),
36
+ activeShells: /* @__PURE__ */ new Set(),
37
+ sessions: /* @__PURE__ */ new Set()
38
+ }),
39
+ events: agentOSEvents,
40
+ actions: {
41
+ // Sessions
42
+ createSession: notWired,
43
+ sendPrompt: notWired,
44
+ prompt: notWired,
45
+ cancelPrompt: notWired,
46
+ cancelSession: notWired,
47
+ listSessions: notWired,
48
+ closeSession: notWired,
49
+ destroySession: notWired,
50
+ respondPermission: notWired,
51
+ setMode: notWired,
52
+ setModel: notWired,
53
+ setThoughtLevel: notWired,
54
+ getModes: notWired,
55
+ getConfigOptions: notWired,
56
+ // Session event replay
57
+ getSequencedEvents: notWired,
58
+ getSessionEvents: notWired,
59
+ listPersistedSessions: notWired,
60
+ // Processes
61
+ exec: notWired,
62
+ execArgv: notWired,
63
+ spawn: notWired,
64
+ spawnProcess: notWired,
65
+ listProcesses: notWired,
66
+ getProcess: notWired,
67
+ writeProcessStdin: notWired,
68
+ closeProcessStdin: notWired,
69
+ waitProcess: notWired,
70
+ stopProcess: notWired,
71
+ killProcess: notWired,
72
+ // Shells
73
+ openShell: notWired,
74
+ connectTerminal: notWired,
75
+ writeShell: notWired,
76
+ resizeShell: notWired,
77
+ closeShell: notWired,
78
+ // Filesystem
79
+ readFile: notWired,
80
+ writeFile: notWired,
81
+ writeFiles: notWired,
82
+ readFiles: notWired,
83
+ mkdir: notWired,
84
+ readdir: notWired,
85
+ readdirRecursive: notWired,
86
+ stat: notWired,
87
+ exists: notWired,
88
+ move: notWired,
89
+ delete: notWired,
90
+ snapshotRootFilesystem: notWired,
91
+ // Networking + preview URLs
92
+ vmFetch: notWired,
93
+ createSignedPreviewUrl: notWired,
94
+ // Cron
95
+ scheduleCron: notWired,
96
+ listCronJobs: notWired,
97
+ cancelCronJob: notWired
98
+ }
99
+ });
100
+ return definition;
101
+ }
102
+ export {
103
+ agentOS,
104
+ nodeModulesMount,
105
+ setup
106
+ };
107
+ //# sourceMappingURL=mod.js.map