@rivet-dev/agentos-core 0.0.0-codex-actor-plugin-contract-coverage.c7d8f87 → 0.0.0-fix-main-wasm-ownership.150c49a
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 +39 -36
- package/dist/agent-os.d.ts +197 -232
- package/dist/agent-os.js +769 -1162
- package/dist/agentos-package.d.ts +4 -2
- package/dist/agentos-package.js +4 -1
- 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 +134 -31
- package/dist/options-schema.js +144 -26
- package/dist/runtime-compat.d.ts +11 -37
- package/dist/runtime-compat.js +74 -374
- package/dist/runtime.d.ts +10 -3
- 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 +420 -29
- package/dist/sidecar/agentos-protocol.js +683 -93
- package/dist/sidecar/native-process-client.d.ts +1 -1
- package/dist/sidecar/native-process-client.js +1 -1
- package/dist/sidecar/rpc-client.d.ts +39 -6
- package/dist/sidecar/rpc-client.js +111 -30
- 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 +19 -17
- 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 = Omit<KernelSpawnOptions, "onStdout" | "onStderr">;
|
|
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,28 @@ 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
|
+
token: string;
|
|
153
|
+
} | {
|
|
154
|
+
type: "sqlite_file";
|
|
155
|
+
path: string;
|
|
156
|
+
};
|
|
88
157
|
/**
|
|
89
158
|
* Compatibility path for arbitrary caller-supplied filesystems.
|
|
90
159
|
* This maps to the sidecar `js_bridge` plugin during the migration.
|
|
@@ -94,6 +163,10 @@ export interface PlainMountConfig {
|
|
|
94
163
|
path: string;
|
|
95
164
|
/** The filesystem driver to mount. */
|
|
96
165
|
driver: VirtualFileSystem;
|
|
166
|
+
/** Filesystem type exposed through guest mount discovery. */
|
|
167
|
+
guestFstype?: string;
|
|
168
|
+
/** Source name exposed through guest mount discovery. */
|
|
169
|
+
guestSource?: string;
|
|
97
170
|
/** If true, write operations throw EROFS. */
|
|
98
171
|
readOnly?: boolean;
|
|
99
172
|
}
|
|
@@ -101,6 +174,10 @@ export interface PlainMountConfig {
|
|
|
101
174
|
export interface NativeMountConfig {
|
|
102
175
|
path: string;
|
|
103
176
|
plugin: NativeMountPluginDescriptor;
|
|
177
|
+
/** Filesystem type exposed through guest mount discovery. */
|
|
178
|
+
guestFstype?: string;
|
|
179
|
+
/** Source name exposed through guest mount discovery. */
|
|
180
|
+
guestSource?: string;
|
|
104
181
|
readOnly?: boolean;
|
|
105
182
|
}
|
|
106
183
|
export interface OverlayMountConfig {
|
|
@@ -146,29 +223,42 @@ export interface AgentOsLimits {
|
|
|
146
223
|
};
|
|
147
224
|
/** HTTP body buffering limits. */
|
|
148
225
|
http?: {
|
|
149
|
-
/** Cap on `vm.
|
|
226
|
+
/** Cap on `vm.httpRequest()` buffered response bodies. Must be <= the sidecar wire frame cap. */
|
|
150
227
|
maxFetchResponseBytes?: number;
|
|
151
228
|
};
|
|
152
|
-
/** Host
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
229
|
+
/** Host binding registration and invocation limits. */
|
|
230
|
+
bindings?: {
|
|
231
|
+
defaultBindingTimeoutMs?: number;
|
|
232
|
+
maxBindingTimeoutMs?: number;
|
|
233
|
+
maxRegisteredCollections?: number;
|
|
234
|
+
maxRegisteredCollectionsPerVm?: number;
|
|
235
|
+
maxBindingsPerCollection?: number;
|
|
236
|
+
maxBindingSchemaBytes?: number;
|
|
237
|
+
maxExamplesPerBinding?: number;
|
|
238
|
+
maxBindingExampleInputBytes?: number;
|
|
162
239
|
};
|
|
163
240
|
/** Mount plugin manifest size limits. */
|
|
164
241
|
plugins?: {
|
|
165
242
|
maxPersistedManifestBytes?: number;
|
|
166
243
|
maxPersistedManifestFileBytes?: number;
|
|
167
244
|
};
|
|
168
|
-
/** ACP adapter
|
|
245
|
+
/** ACP adapter, active-turn, history-retention, and page limits. */
|
|
169
246
|
acp?: {
|
|
170
247
|
maxReadLineBytes?: number;
|
|
171
248
|
stdoutBufferByteLimit?: number;
|
|
249
|
+
maxCompletedMessageBytes?: number;
|
|
250
|
+
maxTurnOutputBytes?: number;
|
|
251
|
+
maxPromptBytes?: number;
|
|
252
|
+
maxPromptBlocks?: number;
|
|
253
|
+
maxFallbackContinuationBytes?: number;
|
|
254
|
+
maxSessionHistoryBytes?: number;
|
|
255
|
+
maxSessionHistoryEvents?: number;
|
|
256
|
+
maxHistoryPageEntries?: number;
|
|
257
|
+
maxSessionListEntries?: number;
|
|
258
|
+
};
|
|
259
|
+
/** Shared local-file/actor-UDS SQLite result materialization limit. */
|
|
260
|
+
sqlite?: {
|
|
261
|
+
maxResultBytes?: number;
|
|
172
262
|
};
|
|
173
263
|
/** Guest JavaScript runtime buffering limits. */
|
|
174
264
|
jsRuntime?: {
|
|
@@ -196,6 +286,15 @@ export interface AgentOsLimits {
|
|
|
196
286
|
syncReadLimitBytes?: number;
|
|
197
287
|
prewarmTimeoutMs?: number;
|
|
198
288
|
runnerHeapLimitMb?: number;
|
|
289
|
+
runnerCpuTimeLimitMs?: number;
|
|
290
|
+
};
|
|
291
|
+
/** Process spawn, I/O, and lifecycle-event backlog limits. */
|
|
292
|
+
process?: {
|
|
293
|
+
maxSpawnFileActions?: number;
|
|
294
|
+
maxSpawnFileActionBytes?: number;
|
|
295
|
+
pendingStdinBytes?: number;
|
|
296
|
+
pendingEventCount?: number;
|
|
297
|
+
pendingEventBytes?: number;
|
|
199
298
|
};
|
|
200
299
|
}
|
|
201
300
|
export interface AgentStderrEvent {
|
|
@@ -207,20 +306,14 @@ export interface AgentStderrEvent {
|
|
|
207
306
|
}
|
|
208
307
|
export type AgentStderrHandler = (event: AgentStderrEvent) => void;
|
|
209
308
|
/**
|
|
210
|
-
*
|
|
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.
|
|
309
|
+
* Restart disposition reported on an {@link AgentExitEvent}. AgentOS never
|
|
310
|
+
* respawns an adapter or replays an interrupted request implicitly.
|
|
218
311
|
*/
|
|
219
|
-
export type AgentRestartOutcome = "
|
|
312
|
+
export type AgentRestartOutcome = "not_attempted";
|
|
220
313
|
/**
|
|
221
314
|
* An unexpected ACP adapter process exit — a crash from the host's
|
|
222
|
-
* perspective (any spontaneous exit
|
|
223
|
-
* code 0)
|
|
315
|
+
* perspective (any spontaneous exit before `unloadSession()`, including exit
|
|
316
|
+
* code 0). The live route is evicted and must be restored explicitly.
|
|
224
317
|
*/
|
|
225
318
|
export interface AgentExitEvent {
|
|
226
319
|
sessionId: string;
|
|
@@ -230,11 +323,11 @@ export interface AgentExitEvent {
|
|
|
230
323
|
pid: number | null;
|
|
231
324
|
/** Adapter exit code; `null` when the exit was observed indirectly. */
|
|
232
325
|
exitCode: number | null;
|
|
233
|
-
/**
|
|
326
|
+
/** Always `"not_attempted"`; AgentOS does not restart adapters implicitly. */
|
|
234
327
|
restart: AgentRestartOutcome;
|
|
235
|
-
/**
|
|
328
|
+
/** Always zero. */
|
|
236
329
|
restartCount: number;
|
|
237
|
-
/**
|
|
330
|
+
/** Always zero. */
|
|
238
331
|
maxRestarts: number;
|
|
239
332
|
}
|
|
240
333
|
export type AgentExitHandler = (event: AgentExitEvent) => void;
|
|
@@ -261,11 +354,12 @@ export type LimitWarningHandler = (warning: LimitWarning) => void;
|
|
|
261
354
|
* Public core VM options.
|
|
262
355
|
*
|
|
263
356
|
* Keep this interface in sync with
|
|
264
|
-
* `packages/core/src/options-schema.ts::agentOsOptionsSchema`. The
|
|
265
|
-
*
|
|
266
|
-
* `packages/agentos/src/config.ts::nativeAgentOsOptionsSchema`.
|
|
357
|
+
* `packages/core/src/options-schema.ts::agentOsOptionsSchema`. The TypeScript
|
|
358
|
+
* Rivet actor accepts this surface directly alongside ordinary actor options.
|
|
267
359
|
*/
|
|
268
360
|
export interface AgentOsOptions {
|
|
361
|
+
/** Initial virtual Linux credentials and account record. Defaults to `1000:1000` (`agentos`). */
|
|
362
|
+
user?: VmUserConfig;
|
|
269
363
|
/**
|
|
270
364
|
* Software to install in the VM. Each entry is a package-dir ref. Arrays are
|
|
271
365
|
* flattened, so meta-packages that export arrays of sub-packages work directly.
|
|
@@ -294,16 +388,16 @@ export interface AgentOsOptions {
|
|
|
294
388
|
* profiling workloads.
|
|
295
389
|
*/
|
|
296
390
|
highResolutionTime?: boolean;
|
|
391
|
+
/** Durable SQLite storage for VM-owned filesystem and session state. */
|
|
392
|
+
database?: VmSqliteConfig;
|
|
297
393
|
/** Root filesystem configuration. Defaults to an overlay with the bundled base snapshot as its deepest lower. */
|
|
298
394
|
rootFilesystem?: RootFilesystemConfig;
|
|
299
395
|
/** Filesystems to mount at boot time. */
|
|
300
396
|
mounts?: MountConfig[];
|
|
301
|
-
/** Additional instructions appended to the base OS system prompt injected at session start. */
|
|
302
|
-
additionalInstructions?: string;
|
|
303
397
|
/** Custom schedule driver for cron jobs. Defaults to TimerScheduleDriver. */
|
|
304
398
|
scheduleDriver?: ScheduleDriver;
|
|
305
|
-
/** Host-side
|
|
306
|
-
|
|
399
|
+
/** Host-side bindings available to agents inside the VM. */
|
|
400
|
+
bindings?: Bindings[];
|
|
307
401
|
/**
|
|
308
402
|
* Custom permission policy for the kernel. Controls access to filesystem,
|
|
309
403
|
* network, child process, and environment operations. Defaults to allowAll.
|
|
@@ -327,12 +421,10 @@ export interface AgentOsOptions {
|
|
|
327
421
|
*/
|
|
328
422
|
onAgentStderr?: AgentStderrHandler;
|
|
329
423
|
/**
|
|
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`.
|
|
424
|
+
* Called when the ACP adapter process behind a session exits unexpectedly.
|
|
425
|
+
* The sidecar evicts the live
|
|
426
|
+
* route and never retries the adapter or interrupted request implicitly.
|
|
427
|
+
* Defaults to writing a warning line to `process.stderr`.
|
|
336
428
|
*/
|
|
337
429
|
onAgentExit?: AgentExitHandler;
|
|
338
430
|
/**
|
|
@@ -342,85 +434,12 @@ export interface AgentOsOptions {
|
|
|
342
434
|
*/
|
|
343
435
|
onLimitWarning?: LimitWarningHandler;
|
|
344
436
|
}
|
|
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
437
|
export interface AgentOsRuntimeAdmin {
|
|
365
438
|
kernel: Kernel;
|
|
366
439
|
rootView: VirtualFileSystem;
|
|
367
440
|
env: Record<string, string>;
|
|
368
441
|
sidecar: AgentOsSidecar;
|
|
369
442
|
}
|
|
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
443
|
/** Information about a process spawned via AgentOs.spawn(). */
|
|
425
444
|
export interface SpawnedProcessInfo {
|
|
426
445
|
pid: number;
|
|
@@ -432,10 +451,8 @@ export interface SpawnedProcessInfo {
|
|
|
432
451
|
export declare class AgentOs {
|
|
433
452
|
#private;
|
|
434
453
|
readonly sidecar: AgentOsSidecar;
|
|
435
|
-
private
|
|
436
|
-
private
|
|
437
|
-
private _sessionClosePromises;
|
|
438
|
-
private _pendingSessionRequestResolvers;
|
|
454
|
+
private _durableSessionEventHandlers;
|
|
455
|
+
private _agentExitHandlers;
|
|
439
456
|
private _processes;
|
|
440
457
|
private _shells;
|
|
441
458
|
private _closedShellIds;
|
|
@@ -445,13 +462,12 @@ export declare class AgentOs {
|
|
|
445
462
|
private _acpTerminalCounter;
|
|
446
463
|
private _softwareRoots;
|
|
447
464
|
private _cronManager;
|
|
448
|
-
private
|
|
449
|
-
private
|
|
465
|
+
private _bindings;
|
|
466
|
+
private _bindingReference;
|
|
450
467
|
private _permissions;
|
|
451
468
|
private _hostMounts;
|
|
452
469
|
private _env;
|
|
453
470
|
private _rootFilesystem;
|
|
454
|
-
private readonly _additionalInstructions;
|
|
455
471
|
private _sidecarLease;
|
|
456
472
|
private readonly _sidecarClient;
|
|
457
473
|
private readonly _sidecarSession;
|
|
@@ -467,19 +483,17 @@ export declare class AgentOs {
|
|
|
467
483
|
exec(command: string, options?: KernelExecOptions): Promise<KernelExecResult>;
|
|
468
484
|
execArgv(command: string, args?: readonly string[], options?: KernelExecOptions): Promise<KernelExecResult>;
|
|
469
485
|
private _trackProcess;
|
|
470
|
-
spawn(command: string, args: string[], options?:
|
|
486
|
+
spawn(command: string, args: string[], options?: SpawnOptions): {
|
|
471
487
|
pid: number;
|
|
472
488
|
};
|
|
473
489
|
/** Write data to a process's stdin. */
|
|
474
490
|
writeProcessStdin(pid: number, data: string | Uint8Array): Promise<void>;
|
|
475
491
|
/** Close a process's stdin stream. */
|
|
476
492
|
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;
|
|
493
|
+
/** Subscribe to stdout and stderr from a process. */
|
|
494
|
+
onProcessOutput(pid: number, handler: (event: ProcessOutput) => void): () => void;
|
|
481
495
|
/** Subscribe to process exit. Returns an unsubscribe function. */
|
|
482
|
-
onProcessExit(pid: number, handler: (
|
|
496
|
+
onProcessExit(pid: number, handler: (event: ProcessExit) => void): () => void;
|
|
483
497
|
/** Wait for a process to exit. Returns the exit code. */
|
|
484
498
|
waitProcess(pid: number): Promise<number>;
|
|
485
499
|
private _assertSafeAbsolutePath;
|
|
@@ -495,27 +509,41 @@ export declare class AgentOs {
|
|
|
495
509
|
recursive?: boolean;
|
|
496
510
|
}): Promise<void>;
|
|
497
511
|
readdir(path: string): Promise<string[]>;
|
|
512
|
+
readdirEntries(path: string): Promise<ReaddirEntry[]>;
|
|
498
513
|
readdirRecursive(path: string, options?: ReaddirRecursiveOptions): Promise<DirEntry[]>;
|
|
499
514
|
stat(path: string): Promise<VirtualStat>;
|
|
500
515
|
exists(path: string): Promise<boolean>;
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
516
|
+
exportRootFilesystem(options: ExportRootFilesystemOptions): Promise<RootSnapshotExport>;
|
|
517
|
+
/**
|
|
518
|
+
* Mount a filesystem into the running VM. Resolves once the mount has been
|
|
519
|
+
* delivered to the native sidecar, so guest code can use it immediately
|
|
520
|
+
* after the returned promise settles; a delivery failure rejects instead of
|
|
521
|
+
* leaving the mount silently host-only.
|
|
522
|
+
*/
|
|
523
|
+
mountFs(descriptor: DynamicMountDescriptor): Promise<void>;
|
|
524
|
+
unmountFs(path: string): Promise<void>;
|
|
525
|
+
listMounts(): Promise<MountInfo[]>;
|
|
506
526
|
move(from: string, to: string): Promise<void>;
|
|
507
|
-
|
|
527
|
+
remove(path: string, options?: {
|
|
508
528
|
recursive?: boolean;
|
|
509
529
|
}): Promise<void>;
|
|
510
|
-
|
|
511
|
-
openShell(options?:
|
|
530
|
+
httpRequest(request: HttpRequest): Promise<HttpResponse>;
|
|
531
|
+
openShell(options?: ShellOptions): {
|
|
512
532
|
shellId: string;
|
|
513
533
|
};
|
|
514
534
|
connectTerminal(options?: ConnectTerminalOptions): Promise<number>;
|
|
515
535
|
/** Write data to a shell's PTY input. */
|
|
516
536
|
writeShell(shellId: string, data: string | Uint8Array): Promise<void>;
|
|
517
|
-
/**
|
|
518
|
-
|
|
537
|
+
/**
|
|
538
|
+
* Subscribe to ordered PTY output (stdout and stderr). Returns an unsubscribe
|
|
539
|
+
* function. `OpenShellOptions.onStderr` is a diagnostic tap for callers that
|
|
540
|
+
* need channel identity; do not render both surfaces.
|
|
541
|
+
*/
|
|
542
|
+
onShellData(shellId: string, handler: (event: ShellData) => void): () => void;
|
|
543
|
+
/** Subscribe to the stderr-only diagnostic stream for a shell. */
|
|
544
|
+
onShellStderr(shellId: string, handler: (event: ShellData) => void): () => void;
|
|
545
|
+
/** Subscribe to shell exit. */
|
|
546
|
+
onShellExit(shellId: string, handler: (event: ShellExit) => void): () => void;
|
|
519
547
|
/** Notify a shell of terminal resize. */
|
|
520
548
|
resizeShell(shellId: string, cols: number, rows: number): void;
|
|
521
549
|
/**
|
|
@@ -539,20 +567,29 @@ export declare class AgentOs {
|
|
|
539
567
|
stopProcess(pid: number): void;
|
|
540
568
|
/** Send SIGKILL to force-kill a process. No-op if already exited. */
|
|
541
569
|
killProcess(pid: number): void;
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
570
|
+
openSession(input: OpenSessionInput): Promise<void>;
|
|
571
|
+
getSession(input?: SessionTarget): Promise<DurableSessionInfo>;
|
|
572
|
+
listSessions(input?: ListSessionsInput): Promise<SessionPage>;
|
|
573
|
+
deleteSession(input?: SessionTarget): Promise<void>;
|
|
574
|
+
unloadSession(input?: SessionTarget): Promise<void>;
|
|
575
|
+
prompt(input: PromptInput): Promise<DurablePromptResult>;
|
|
576
|
+
cancelPrompt(input?: SessionTarget): Promise<CancelPromptResult>;
|
|
577
|
+
respondPermission(input: PermissionResponse): Promise<PermissionResponseResult>;
|
|
578
|
+
readHistory(input?: ReadHistoryInput): Promise<HistoryPage>;
|
|
579
|
+
getSessionConfig(input?: SessionTarget): Promise<SessionConfig>;
|
|
580
|
+
setSessionConfigOption(input: SetSessionConfigOptionInput): Promise<SessionConfig>;
|
|
581
|
+
getSessionCapabilities(input?: SessionTarget): Promise<SessionCapabilities | null>;
|
|
582
|
+
getSessionAgentInfo(input?: SessionTarget): Promise<SessionAgentInfo | null>;
|
|
546
583
|
/**
|
|
547
584
|
* Dynamically link a software package into the RUNNING VM. The package's
|
|
548
585
|
* `bin/` commands appear under `/opt/agentos/bin` (on `$PATH`) and its `share/man`
|
|
549
586
|
* pages under MANPATH immediately — the `/opt/agentos` mount is host-backed, so
|
|
550
587
|
* writing into its staging dir is reflected live with no reboot. An `agent`
|
|
551
|
-
* block registers the package for `
|
|
588
|
+
* block registers the package for `openSession({ agent: name })`. Persists for the VM's
|
|
552
589
|
* lifetime (and across a snapshot iff the volume persists).
|
|
553
590
|
*/
|
|
554
|
-
linkSoftware(descriptor:
|
|
555
|
-
|
|
591
|
+
linkSoftware(descriptor: PackageDescriptor): Promise<void>;
|
|
592
|
+
listSoftware(): Promise<{
|
|
556
593
|
packageName: string;
|
|
557
594
|
commands: string[];
|
|
558
595
|
}[]>;
|
|
@@ -563,71 +600,17 @@ export declare class AgentOs {
|
|
|
563
600
|
* agent is a package materialized into the VM, so `installed` is always `true`.
|
|
564
601
|
*/
|
|
565
602
|
listAgents(): Promise<AgentRegistryEntry[]>;
|
|
566
|
-
private _syncSessionState;
|
|
567
|
-
private _applySessionUpdate;
|
|
568
|
-
private _recordSessionNotification;
|
|
569
|
-
private _dispatchSessionEvent;
|
|
570
|
-
private _subscribeSessionEvents;
|
|
571
|
-
/**
|
|
572
|
-
* Warn once per session (host-visible) that a tool-permission request was
|
|
573
|
-
* auto-denied because no `onPermissionRequest` handler is registered. Shared
|
|
574
|
-
* by both the bare-callback and JSON-RPC permission paths so the message and
|
|
575
|
-
* the once-per-session guard cannot drift between them.
|
|
576
|
-
*/
|
|
577
|
-
private _warnNoPermissionHandlerOnce;
|
|
578
|
-
/** Best-effort human label for the tool named in a permission request. */
|
|
579
|
-
private _permissionToolLabel;
|
|
580
|
-
/**
|
|
581
|
-
* Emit a host-visible warning for a session through the same agent-process log
|
|
582
|
-
* channel that surfaces adapter stderr (`onAgentStderr`, default: process
|
|
583
|
-
* stderr). Used for agent-os-owned diagnostics — e.g. a permission request
|
|
584
|
-
* that was auto-denied because no host hook is registered — so they never fire
|
|
585
|
-
* silently inside the sidecar.
|
|
586
|
-
*/
|
|
587
|
-
private _emitSessionWarning;
|
|
588
603
|
private _recordAgentStderr;
|
|
589
604
|
private _recordAgentExit;
|
|
590
|
-
private _applySyntheticConfigOverrides;
|
|
591
605
|
private _handleSidecarEvent;
|
|
592
606
|
private _handleLimitWarning;
|
|
593
607
|
private _handleAcpExtEvent;
|
|
594
|
-
private
|
|
608
|
+
private _emitDurableSessionEvent;
|
|
595
609
|
private _sendAcpRequest;
|
|
596
|
-
private _sendSessionRequest;
|
|
597
|
-
private _setSessionConfigByCategory;
|
|
598
|
-
private _removeSession;
|
|
599
|
-
private _abortPendingSessionRequests;
|
|
600
|
-
private _cancelPendingPromptRequests;
|
|
601
|
-
private _rejectPendingPermissionReplies;
|
|
602
|
-
private _rejectPendingPermissionRepliesFromSession;
|
|
603
|
-
private _closeSessionInternal;
|
|
604
|
-
private _hydrateSessionState;
|
|
605
|
-
createSession(agentType: AgentType, options?: CreateSessionOptions): Promise<{
|
|
606
|
-
sessionId: string;
|
|
607
|
-
}>;
|
|
608
|
-
/**
|
|
609
|
-
* Resume a session that exists in durable storage but is not live in this VM
|
|
610
|
-
* (e.g. after a Rivet actor slept and woke with a fresh VM). Thin forwarder:
|
|
611
|
-
* resolves the agent config + adapter entrypoint exactly as {@link createSession}
|
|
612
|
-
* does, then forwards a single `AcpResumeSessionRequest` to the sidecar, which
|
|
613
|
-
* owns the resume state machine (native `session/load` when the agent supports
|
|
614
|
-
* it, else `session/new` + a transcript-continuation preamble). The returned
|
|
615
|
-
* `sessionId` is the live id in this VM (equal to the requested id for native
|
|
616
|
-
* loads, freshly assigned for the fallback); the caller remaps `external -> live`.
|
|
617
|
-
* The new live session is registered + hydrated locally so subsequent prompts
|
|
618
|
-
* route to it.
|
|
619
|
-
*
|
|
620
|
-
* Resume depends on a durable root; on a non-durable (default in-memory) root
|
|
621
|
-
* there is no surviving store and the fallback tier always runs.
|
|
622
|
-
*/
|
|
623
|
-
resumeSession(sessionId: string, agentType: AgentType, options?: ResumeSessionOptions): Promise<ResumeSessionResult>;
|
|
624
610
|
private _installSidecarRequestHandler;
|
|
625
611
|
private _handleAcpExtSidecarRequest;
|
|
626
612
|
private _dispatchAcpSidecarRequest;
|
|
627
613
|
private _handleSupportedAcpSidecarRequest;
|
|
628
|
-
private _normalizeAcpPermissionOptionId;
|
|
629
|
-
private _buildAcpPermissionResult;
|
|
630
|
-
private _handleAcpPermissionRequest;
|
|
631
614
|
private _acpParams;
|
|
632
615
|
private _requireAcpStringParam;
|
|
633
616
|
private _optionalAcpStringParam;
|
|
@@ -646,29 +629,11 @@ export declare class AgentOs {
|
|
|
646
629
|
private _handleAcpKillTerminal;
|
|
647
630
|
private _handleAcpReleaseTerminal;
|
|
648
631
|
private _handleAcpResizeTerminal;
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
*/
|
|
655
|
-
destroySession(sessionId: string): Promise<void>;
|
|
656
|
-
prompt(sessionId: string, text: string): Promise<PromptResult>;
|
|
657
|
-
/** Cancel ongoing agent work for a session. */
|
|
658
|
-
cancelSession(sessionId: string): Promise<JsonRpcResponse>;
|
|
659
|
-
closeSession(sessionId: string): void;
|
|
660
|
-
respondPermission(sessionId: string, permissionId: string, reply: PermissionReply): Promise<JsonRpcResponse>;
|
|
661
|
-
setSessionMode(sessionId: string, modeId: string): Promise<JsonRpcResponse>;
|
|
662
|
-
getSessionModes(sessionId: string): SessionModeState | null;
|
|
663
|
-
setSessionModel(sessionId: string, model: string): Promise<JsonRpcResponse>;
|
|
664
|
-
setSessionThoughtLevel(sessionId: string, level: string): Promise<JsonRpcResponse>;
|
|
665
|
-
getSessionConfigOptions(sessionId: string): SessionConfigOption[];
|
|
666
|
-
getSessionCapabilities(sessionId: string): AgentCapabilities | null;
|
|
667
|
-
getSessionAgentInfo(sessionId: string): AgentInfo | null;
|
|
668
|
-
rawSessionSend(sessionId: string, method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>;
|
|
669
|
-
rawSend(sessionId: string, method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>;
|
|
670
|
-
onSessionEvent(sessionId: string, handler: SessionEventHandler): () => void;
|
|
671
|
-
onPermissionRequest(sessionId: string, handler: PermissionRequestHandler): () => void;
|
|
632
|
+
onSessionEvent(handler: (entry: SessionStreamEntry) => void): () => void;
|
|
633
|
+
onSessionEvent(sessionId: string | undefined, handler: (entry: SessionStreamEntry) => void): () => void;
|
|
634
|
+
/** Subscribe to unexpected adapter exits without changing session liveness. */
|
|
635
|
+
onAgentExit(handler: AgentExitHandler): () => void;
|
|
636
|
+
onAgentExit(sessionId: string | undefined, handler: AgentExitHandler): () => void;
|
|
672
637
|
/** Schedule a cron job. Returns a handle with the job ID and a cancel method. */
|
|
673
638
|
scheduleCron(options: CronJobOptions): CronJob;
|
|
674
639
|
/** List all registered cron jobs. */
|