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