@rivet-dev/agentos-core 0.0.0-agentos-dylib-plugin.f065be7 → 0.0.0-chdir-fix.3d9feab
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 +8 -11
- package/dist/agent-os.d.ts +185 -43
- package/dist/agent-os.js +834 -536
- package/dist/agentos-package.d.ts +29 -0
- package/dist/agentos-package.js +88 -0
- package/dist/base-filesystem.d.ts +2 -15
- package/dist/base-filesystem.js +23 -171
- package/dist/cron/cron-manager.js +1 -4
- package/dist/cron/types.d.ts +1 -1
- package/dist/default-software.d.ts +8 -0
- package/dist/default-software.js +10 -0
- package/dist/generated/AcpLimitsConfig.d.ts +4 -0
- package/dist/generated/AcpLimitsConfig.js +2 -0
- package/dist/generated/CreateVmConfig.d.ts +26 -0
- package/dist/generated/CreateVmConfig.js +1 -0
- package/dist/generated/FsPermissionRule.d.ts +6 -0
- package/dist/generated/FsPermissionRule.js +1 -0
- package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
- package/dist/generated/FsPermissionRuleSet.js +1 -0
- package/dist/generated/FsPermissionScope.d.ts +3 -0
- package/dist/generated/FsPermissionScope.js +1 -0
- package/dist/generated/HttpLimitsConfig.d.ts +3 -0
- package/dist/generated/HttpLimitsConfig.js +2 -0
- package/dist/generated/JsModuleResolution.d.ts +1 -0
- package/dist/generated/JsModuleResolution.js +2 -0
- package/dist/generated/JsRuntimeConfig.d.ts +31 -0
- package/dist/generated/JsRuntimeConfig.js +1 -0
- package/dist/generated/JsRuntimeLimitsConfig.d.ts +11 -0
- package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
- package/dist/generated/JsRuntimePlatform.d.ts +1 -0
- package/dist/generated/JsRuntimePlatform.js +2 -0
- package/dist/generated/MountPluginDescriptor.d.ts +4 -0
- package/dist/generated/MountPluginDescriptor.js +2 -0
- package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
- package/dist/generated/NativeRootFilesystemConfig.js +1 -0
- package/dist/generated/PatternPermissionRule.d.ts +6 -0
- package/dist/generated/PatternPermissionRule.js +1 -0
- package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
- package/dist/generated/PatternPermissionRuleSet.js +1 -0
- package/dist/generated/PatternPermissionScope.d.ts +3 -0
- package/dist/generated/PatternPermissionScope.js +1 -0
- package/dist/generated/PermissionMode.d.ts +1 -0
- package/dist/generated/PermissionMode.js +2 -0
- package/dist/generated/PermissionsPolicy.d.ts +10 -0
- package/dist/generated/PermissionsPolicy.js +1 -0
- package/dist/generated/PluginLimitsConfig.d.ts +4 -0
- package/dist/generated/PluginLimitsConfig.js +2 -0
- package/dist/generated/PythonLimitsConfig.d.ts +6 -0
- package/dist/generated/PythonLimitsConfig.js +2 -0
- package/dist/generated/ResourceLimitsConfig.d.ts +24 -0
- package/dist/generated/ResourceLimitsConfig.js +2 -0
- package/dist/generated/RootFilesystemConfig.d.ts +9 -0
- package/dist/generated/RootFilesystemConfig.js +1 -0
- package/dist/generated/RootFilesystemEntry.d.ts +13 -0
- package/dist/generated/RootFilesystemEntry.js +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
- package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryKind.js +2 -0
- package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
- package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
- package/dist/generated/RootFilesystemMode.d.ts +1 -0
- package/dist/generated/RootFilesystemMode.js +2 -0
- package/dist/generated/ToolLimitsConfig.d.ts +10 -0
- package/dist/generated/ToolLimitsConfig.js +2 -0
- package/dist/generated/VmDnsConfig.d.ts +6 -0
- package/dist/generated/VmDnsConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +18 -0
- package/dist/generated/VmLimitsConfig.js +1 -0
- package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
- package/dist/generated/VmListenPolicyConfig.js +2 -0
- package/dist/generated/WasmLimitsConfig.d.ts +7 -0
- package/dist/generated/WasmLimitsConfig.js +2 -0
- package/dist/host-dir-mount.d.ts +1 -1
- package/dist/host-tools-zod.js +27 -7
- package/dist/host-tools.js +9 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -2
- package/dist/layers.d.ts +3 -3
- package/dist/layers.js +22 -13
- package/dist/options-schema.d.ts +453 -0
- package/dist/options-schema.js +268 -0
- package/dist/packages.d.ts +17 -116
- package/dist/packages.js +35 -322
- package/dist/runtime-compat.d.ts +27 -7
- package/dist/runtime-compat.js +133 -147
- package/dist/runtime.d.ts +37 -7
- package/dist/sandbox.d.ts +112 -0
- package/dist/sandbox.js +264 -0
- package/dist/sidecar/{agent-os-protocol.d.ts → agentos-protocol.d.ts} +99 -1
- package/dist/sidecar/{agent-os-protocol.js → agentos-protocol.js} +156 -19
- package/dist/sidecar/native-process-client.d.ts +6 -2
- package/dist/sidecar/native-process-client.js +8 -1
- package/dist/sidecar/permissions.d.ts +1 -1
- package/dist/sidecar/permissions.js +4 -4
- package/dist/sidecar/rpc-client.d.ts +87 -6
- package/dist/sidecar/rpc-client.js +433 -93
- package/dist/test/sandbox-agent.js +1 -1
- package/dist/types.d.ts +10 -3
- package/package.json +42 -35
- package/dist/agents.d.ts +0 -63
- package/dist/agents.js +0 -42
- package/fixtures/AGENTOS_SYSTEM_PROMPT.md +0 -21
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @rivet-dev/
|
|
1
|
+
# @rivet-dev/agentos-core
|
|
2
2
|
|
|
3
3
|
A high-level SDK for running coding agents in isolated VMs. agentOS manages the full lifecycle of virtual machines -- from filesystem setup and process management to launching AI agents via the Agent Communication Protocol (ACP).
|
|
4
4
|
|
|
@@ -19,13 +19,13 @@ Agents run inside isolated VMs with their own filesystem, process table, and net
|
|
|
19
19
|
## Quick Start
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npm install @rivet-dev/
|
|
22
|
+
npm install @rivet-dev/agentos-core
|
|
23
23
|
# Install an agent adapter + its underlying agent
|
|
24
|
-
npm install @
|
|
24
|
+
npm install @agentos-software/pi @mariozechner/pi-coding-agent
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import { AgentOs } from "@rivet-dev/
|
|
28
|
+
import { AgentOs } from "@rivet-dev/agentos-core";
|
|
29
29
|
|
|
30
30
|
// 1. Create a VM
|
|
31
31
|
const vm = await AgentOs.create();
|
|
@@ -112,7 +112,7 @@ await vm.dispose();
|
|
|
112
112
|
|
|
113
113
|
| Method | Signature | Description |
|
|
114
114
|
|--------|-----------|-------------|
|
|
115
|
-
| `createSession` | `createSession(agentType: AgentType
|
|
115
|
+
| `createSession` | `createSession(agentType: AgentType, options?: CreateSessionOptions): Promise<{ sessionId: string }>` | Launch an agent and return a session ID |
|
|
116
116
|
| `listSessions` | `listSessions(): SessionInfo[]` | List active sessions |
|
|
117
117
|
| `destroySession` | `destroySession(sessionId: string): Promise<void>` | Gracefully cancel and close a session |
|
|
118
118
|
|
|
@@ -157,10 +157,7 @@ await vm.dispose();
|
|
|
157
157
|
- `MountConfigCustom` — Caller-provided VirtualFileSystem
|
|
158
158
|
- `NativeMountConfig` — Declarative sidecar mount plugin configuration
|
|
159
159
|
- `MountConfigOverlay` — Copy-on-write overlay (lower + upper layers)
|
|
160
|
-
|
|
161
|
-
**Companion Filesystem Packages**
|
|
162
|
-
- `createGoogleDriveBackend()` — Declarative Google Drive native mount helper from `@secure-exec/google-drive`
|
|
163
|
-
- `createS3Backend()` — Declarative S3-compatible native mount helper from `@secure-exec/s3`
|
|
160
|
+
- `chunkedS3MountPlugin()` — Declarative S3-compatible native mount plugin descriptor (from `@rivet-dev/agentos-runtime-core/descriptors`)
|
|
164
161
|
|
|
165
162
|
**MCP Servers**
|
|
166
163
|
- `McpServerConfig` — Union of local and remote MCP configs
|
|
@@ -180,8 +177,8 @@ await vm.dispose();
|
|
|
180
177
|
- `BatchReadResult` — Result of a batch read (path, content, error?)
|
|
181
178
|
|
|
182
179
|
**Agent**
|
|
183
|
-
- `AgentType` — `
|
|
184
|
-
- `AgentConfig` — Agent configuration (
|
|
180
|
+
- `AgentType` — `string` (a package manifest `name`, e.g. `"pi"`, `"claude"`); agents are resolved dynamically from the configured `/opt/agentos` package manifests, so any manifest `name` is valid
|
|
181
|
+
- `AgentConfig` — Agent configuration (adapterEntrypoint, launchArgs, defaultEnv)
|
|
185
182
|
- `AgentRegistryEntry` — Registry entry (id, acpAdapter, agentPackage, installed)
|
|
186
183
|
|
|
187
184
|
**Session**
|
package/dist/agent-os.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { NativeMountPluginDescriptor } from "@
|
|
1
|
+
import type { NativeMountPluginDescriptor } from "@rivet-dev/agentos-runtime-core/descriptors";
|
|
2
2
|
import type { AgentCapabilities, AgentInfo, PermissionReply, PermissionRequestHandler, SessionConfigOption, SessionEventHandler, SessionModeState } from "./agent-session-types.js";
|
|
3
3
|
import { type ToolKit } from "./host-tools.js";
|
|
4
4
|
import type { JsonRpcResponse } from "./json-rpc.js";
|
|
5
5
|
import type { ConnectTerminalOptions, Kernel, KernelExecOptions, KernelExecResult, ProcessInfo as KernelProcessInfo, KernelSpawnOptions, OpenShellOptions, Permissions, VirtualFileSystem, VirtualStat } from "./runtime-compat.js";
|
|
6
|
-
export type { MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, NativeMountPluginDescriptor, } from "@
|
|
6
|
+
export type { MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, NativeMountPluginDescriptor, } from "@rivet-dev/agentos-runtime-core/descriptors";
|
|
7
7
|
export type { AgentCapabilities, AgentInfo, PermissionReply, PermissionRequest, PermissionRequestHandler, SessionConfigOption, SessionEventHandler, SessionInitData, SessionMode, SessionModeState, } from "./agent-session-types.js";
|
|
8
8
|
export type { AcpTimeoutErrorData, JsonRpcError, JsonRpcErrorData, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, } from "./json-rpc.js";
|
|
9
9
|
export { isAcpTimeoutErrorData } from "./json-rpc.js";
|
|
@@ -46,15 +46,16 @@ export interface BatchReadResult {
|
|
|
46
46
|
/** Entry in the agent registry, describing an available agent type. */
|
|
47
47
|
export interface AgentRegistryEntry {
|
|
48
48
|
id: string;
|
|
49
|
-
acpAdapter: string;
|
|
50
|
-
agentPackage: string;
|
|
51
49
|
installed: boolean;
|
|
50
|
+
/** Guest entrypoint the sidecar launches for this agent (`/opt/agentos/bin/<acpEntrypoint>`). */
|
|
51
|
+
adapterEntrypoint: string;
|
|
52
52
|
}
|
|
53
|
-
import {
|
|
53
|
+
import type { AgentType } from "./types.js";
|
|
54
54
|
import type { ScheduleDriver } from "./cron/schedule-driver.js";
|
|
55
55
|
import type { CronEventHandler, CronJob, CronJobInfo, CronJobOptions } from "./cron/types.js";
|
|
56
56
|
import { type LayerStore, type OverlayFilesystemMode, type RootSnapshotExport, type SnapshotLayerHandle } from "./layers.js";
|
|
57
57
|
import { type SoftwareInput } from "./packages.js";
|
|
58
|
+
import { type PackageRef, type SoftwarePackageRef } from "./agentos-package.js";
|
|
58
59
|
import { type AgentOsSidecarPlacement } from "./sidecar/rpc-client.js";
|
|
59
60
|
export interface AgentOsSharedSidecarOptions {
|
|
60
61
|
pool?: string;
|
|
@@ -172,6 +173,10 @@ export interface AgentOsLimits {
|
|
|
172
173
|
/** Guest JavaScript runtime buffering limits. */
|
|
173
174
|
jsRuntime?: {
|
|
174
175
|
v8HeapLimitMb?: number;
|
|
176
|
+
syncRpcWaitTimeoutMs?: number;
|
|
177
|
+
cpuTimeLimitMs?: number;
|
|
178
|
+
wallClockLimitMs?: number;
|
|
179
|
+
importCacheMaterializeTimeoutMs?: number;
|
|
175
180
|
capturedOutputLimitBytes?: number;
|
|
176
181
|
stdinBufferLimitBytes?: number;
|
|
177
182
|
eventPayloadLimitBytes?: number;
|
|
@@ -181,6 +186,7 @@ export interface AgentOsLimits {
|
|
|
181
186
|
python?: {
|
|
182
187
|
outputBufferMaxBytes?: number;
|
|
183
188
|
executionTimeoutMs?: number;
|
|
189
|
+
maxOldSpaceMb?: number;
|
|
184
190
|
vfsRpcTimeoutMs?: number;
|
|
185
191
|
};
|
|
186
192
|
/** Guest WASM runtime limits. */
|
|
@@ -188,17 +194,91 @@ export interface AgentOsLimits {
|
|
|
188
194
|
maxModuleFileBytes?: number;
|
|
189
195
|
capturedOutputLimitBytes?: number;
|
|
190
196
|
syncReadLimitBytes?: number;
|
|
197
|
+
prewarmTimeoutMs?: number;
|
|
198
|
+
runnerHeapLimitMb?: number;
|
|
191
199
|
};
|
|
192
200
|
}
|
|
201
|
+
export interface AgentStderrEvent {
|
|
202
|
+
sessionId: string;
|
|
203
|
+
agentType: string;
|
|
204
|
+
processId: string;
|
|
205
|
+
pid: number | null;
|
|
206
|
+
chunk: Uint8Array;
|
|
207
|
+
}
|
|
208
|
+
export type AgentStderrHandler = (event: AgentStderrEvent) => void;
|
|
209
|
+
/**
|
|
210
|
+
* Auto-restart outcome reported on an {@link AgentExitEvent}. Mirrors the
|
|
211
|
+
* sidecar's `AcpAgentExitedEvent.restart` strings:
|
|
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.
|
|
218
|
+
*/
|
|
219
|
+
export type AgentRestartOutcome = "restarted" | "unsupported" | "failed" | "exhausted";
|
|
220
|
+
/**
|
|
221
|
+
* An unexpected ACP adapter process exit — a crash from the host's
|
|
222
|
+
* perspective (any spontaneous exit without `closeSession()`, including exit
|
|
223
|
+
* code 0) — plus the sidecar's bounded auto-restart outcome.
|
|
224
|
+
*/
|
|
225
|
+
export interface AgentExitEvent {
|
|
226
|
+
sessionId: string;
|
|
227
|
+
agentType: string;
|
|
228
|
+
/** Sidecar process id of the adapter that exited. */
|
|
229
|
+
processId: string;
|
|
230
|
+
pid: number | null;
|
|
231
|
+
/** Adapter exit code; `null` when the exit was observed indirectly. */
|
|
232
|
+
exitCode: number | null;
|
|
233
|
+
/** Auto-restart outcome; only `"restarted"` leaves the session usable. */
|
|
234
|
+
restart: AgentRestartOutcome;
|
|
235
|
+
/** Restarts consumed for this session so far. */
|
|
236
|
+
restartCount: number;
|
|
237
|
+
/** Per-session restart budget. */
|
|
238
|
+
maxRestarts: number;
|
|
239
|
+
}
|
|
240
|
+
export type AgentExitHandler = (event: AgentExitEvent) => void;
|
|
241
|
+
/**
|
|
242
|
+
* A near-capacity warning for one bounded limit (a queue/buffer, a saturating
|
|
243
|
+
* resource cap, or a memory envelope) inside the VM runtime. Delivered the moment
|
|
244
|
+
* usage crosses the runtime's warning threshold (~80%), once per crossing — the
|
|
245
|
+
* runtime applies edge-triggering + hysteresis, so this never spams.
|
|
246
|
+
*/
|
|
247
|
+
export interface LimitWarning {
|
|
248
|
+
/** Stable limit name, e.g. `"javascript_event_channel"` or `"vm_open_fds"`. */
|
|
249
|
+
limit: string;
|
|
250
|
+
/** Limit class: `"queue"`, `"resource"`, or `"memory"`. */
|
|
251
|
+
category: string;
|
|
252
|
+
/** Current observed usage. */
|
|
253
|
+
observed: number;
|
|
254
|
+
/** Configured capacity. */
|
|
255
|
+
capacity: number;
|
|
256
|
+
/** Observed fill as a percentage of capacity (0–100). */
|
|
257
|
+
fillPercent: number;
|
|
258
|
+
}
|
|
259
|
+
export type LimitWarningHandler = (warning: LimitWarning) => void;
|
|
260
|
+
/**
|
|
261
|
+
* Public core VM options.
|
|
262
|
+
*
|
|
263
|
+
* Keep this interface in sync with
|
|
264
|
+
* `packages/core/src/options-schema.ts::agentOsOptionsSchema`. The Rivet
|
|
265
|
+
* native actor intentionally accepts only a subset via
|
|
266
|
+
* `packages/agentos/src/config.ts::nativeAgentOsOptionsSchema`.
|
|
267
|
+
*/
|
|
193
268
|
export interface AgentOsOptions {
|
|
194
269
|
/**
|
|
195
|
-
* Software to install in the VM. Each entry
|
|
196
|
-
*
|
|
197
|
-
* registry packages like @agent-os-pkgs/coreutils) is treated
|
|
198
|
-
* as a WASM command source automatically. Arrays are flattened, so
|
|
199
|
-
* meta-packages that export arrays of sub-packages work directly.
|
|
270
|
+
* Software to install in the VM. Each entry is a package-dir ref. Arrays are
|
|
271
|
+
* flattened, so meta-packages that export arrays of sub-packages work directly.
|
|
200
272
|
*/
|
|
201
273
|
software?: SoftwareInput[];
|
|
274
|
+
/**
|
|
275
|
+
* Whether to auto-include the default software bundle (`@agentos-software/common`
|
|
276
|
+
* — `sh` + coreutils + the standard CLI tools agents rely on) in addition to
|
|
277
|
+
* any `software` you pass. Defaults to `true`; set `false` for a bare VM with
|
|
278
|
+
* only the software you list explicitly. Entries already present in `software`
|
|
279
|
+
* are not duplicated.
|
|
280
|
+
*/
|
|
281
|
+
defaultSoftware?: boolean;
|
|
202
282
|
/** Loopback ports to exempt from SSRF checks (for testing with host-side mock servers). */
|
|
203
283
|
loopbackExemptPorts?: number[];
|
|
204
284
|
/**
|
|
@@ -206,6 +286,14 @@ export interface AgentOsOptions {
|
|
|
206
286
|
* Defaults to the hardened builtin set used by the native sidecar bridge.
|
|
207
287
|
*/
|
|
208
288
|
allowedNodeBuiltins?: string[];
|
|
289
|
+
/**
|
|
290
|
+
* Opt in to a high-resolution monotonic guest clock (microsecond class)
|
|
291
|
+
* for guest Node processes. Default `false` keeps the security-oriented
|
|
292
|
+
* 1ms timer resolution — untrusted guest code should not get a precise
|
|
293
|
+
* timer (timing side channels). Enable only for trusted benchmarking or
|
|
294
|
+
* profiling workloads.
|
|
295
|
+
*/
|
|
296
|
+
highResolutionTime?: boolean;
|
|
209
297
|
/** Root filesystem configuration. Defaults to an overlay with the bundled base snapshot as its deepest lower. */
|
|
210
298
|
rootFilesystem?: RootFilesystemConfig;
|
|
211
299
|
/** Filesystems to mount at boot time. */
|
|
@@ -231,6 +319,28 @@ export interface AgentOsOptions {
|
|
|
231
319
|
* runtime's historical constants, so omitting this leaves behavior unchanged.
|
|
232
320
|
*/
|
|
233
321
|
limits?: AgentOsLimits;
|
|
322
|
+
/**
|
|
323
|
+
* Called with stderr chunks from the top-level ACP-speaking agent process.
|
|
324
|
+
* The agent process uses stdout for ACP JSON-RPC protocol traffic, so only
|
|
325
|
+
* stderr is forwarded through this hook. Defaults to writing chunks to
|
|
326
|
+
* `process.stderr`.
|
|
327
|
+
*/
|
|
328
|
+
onAgentStderr?: AgentStderrHandler;
|
|
329
|
+
/**
|
|
330
|
+
* Called when the ACP adapter process behind a session exits without
|
|
331
|
+
* `closeSession()` — i.e. an adapter crash. The sidecar auto-restarts the
|
|
332
|
+
* adapter (bounded per session, natively re-attaching the same session id)
|
|
333
|
+
* and reports the outcome on the event; only `restart === "restarted"`
|
|
334
|
+
* leaves the session usable. Defaults to writing a warning line to
|
|
335
|
+
* `process.stderr`.
|
|
336
|
+
*/
|
|
337
|
+
onAgentExit?: AgentExitHandler;
|
|
338
|
+
/**
|
|
339
|
+
* Called when a bounded limit inside the VM runtime approaches capacity
|
|
340
|
+
* (~80%, edge-triggered with hysteresis so it does not spam). Use it to alert
|
|
341
|
+
* on a slow consumer or a runaway guest before the limit is actually hit.
|
|
342
|
+
*/
|
|
343
|
+
onLimitWarning?: LimitWarningHandler;
|
|
234
344
|
}
|
|
235
345
|
/** Configuration for a local MCP server (spawned as a child process). */
|
|
236
346
|
export interface McpServerConfigLocal {
|
|
@@ -284,7 +394,7 @@ export interface ResumeSessionOptions {
|
|
|
284
394
|
* fallback tier arms a continuation preamble pointing the agent at it.
|
|
285
395
|
*/
|
|
286
396
|
transcriptPath?: string;
|
|
287
|
-
/** Working directory for the resumed agent session (default `/
|
|
397
|
+
/** Working directory for the resumed agent session (default `/workspace`). */
|
|
288
398
|
cwd?: string;
|
|
289
399
|
/** Environment variables to pass to the resumed agent process. */
|
|
290
400
|
env?: Record<string, string>;
|
|
@@ -334,7 +444,6 @@ export declare class AgentOs {
|
|
|
334
444
|
private _acpTerminals;
|
|
335
445
|
private _acpTerminalCounter;
|
|
336
446
|
private _softwareRoots;
|
|
337
|
-
private _softwareAgentConfigs;
|
|
338
447
|
private _cronManager;
|
|
339
448
|
private _toolKits;
|
|
340
449
|
private _toolReference;
|
|
@@ -342,24 +451,29 @@ export declare class AgentOs {
|
|
|
342
451
|
private _hostMounts;
|
|
343
452
|
private _env;
|
|
344
453
|
private _rootFilesystem;
|
|
454
|
+
private readonly _additionalInstructions;
|
|
345
455
|
private _sidecarLease;
|
|
346
456
|
private readonly _sidecarClient;
|
|
347
457
|
private readonly _sidecarSession;
|
|
348
458
|
private readonly _sidecarVm;
|
|
349
459
|
private readonly _disposeSidecarEventListener;
|
|
460
|
+
private readonly _agentStderrHandler?;
|
|
461
|
+
private readonly _agentExitHandler?;
|
|
462
|
+
private readonly _limitWarningHandler?;
|
|
350
463
|
private constructor();
|
|
351
464
|
static createSidecar(options?: AgentOsCreateSidecarOptions): Promise<AgentOsSidecar>;
|
|
352
465
|
static getSharedSidecar(options?: AgentOsSharedSidecarOptions): Promise<AgentOsSidecar>;
|
|
353
466
|
static create(options?: AgentOsOptions): Promise<AgentOs>;
|
|
354
467
|
exec(command: string, options?: KernelExecOptions): Promise<KernelExecResult>;
|
|
468
|
+
execArgv(command: string, args?: readonly string[], options?: KernelExecOptions): Promise<KernelExecResult>;
|
|
355
469
|
private _trackProcess;
|
|
356
470
|
spawn(command: string, args: string[], options?: KernelSpawnOptions): {
|
|
357
471
|
pid: number;
|
|
358
472
|
};
|
|
359
473
|
/** Write data to a process's stdin. */
|
|
360
|
-
writeProcessStdin(pid: number, data: string | Uint8Array): void
|
|
474
|
+
writeProcessStdin(pid: number, data: string | Uint8Array): Promise<void>;
|
|
361
475
|
/** Close a process's stdin stream. */
|
|
362
|
-
closeProcessStdin(pid: number): void
|
|
476
|
+
closeProcessStdin(pid: number): Promise<void>;
|
|
363
477
|
/** Subscribe to stdout data from a process. Returns an unsubscribe function. */
|
|
364
478
|
onProcessStdout(pid: number, handler: (data: Uint8Array) => void): () => void;
|
|
365
479
|
/** Subscribe to stderr data from a process. Returns an unsubscribe function. */
|
|
@@ -371,7 +485,6 @@ export declare class AgentOs {
|
|
|
371
485
|
private _assertSafeAbsolutePath;
|
|
372
486
|
private _assertWritableAbsolutePath;
|
|
373
487
|
private _vfs;
|
|
374
|
-
private _copyPath;
|
|
375
488
|
readFile(path: string): Promise<Uint8Array>;
|
|
376
489
|
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
377
490
|
writeFiles(entries: BatchWriteEntry[]): Promise<BatchWriteResult[]>;
|
|
@@ -386,10 +499,16 @@ export declare class AgentOs {
|
|
|
386
499
|
stat(path: string): Promise<VirtualStat>;
|
|
387
500
|
exists(path: string): Promise<boolean>;
|
|
388
501
|
snapshotRootFilesystem(): Promise<RootSnapshotExport>;
|
|
502
|
+
/**
|
|
503
|
+
* Mount a filesystem into the running VM. Resolves once the mount has been
|
|
504
|
+
* delivered to the native sidecar, so guest code can use it immediately
|
|
505
|
+
* after the returned promise settles; a delivery failure rejects instead of
|
|
506
|
+
* leaving the mount silently host-only.
|
|
507
|
+
*/
|
|
389
508
|
mountFs(path: string, driver: VirtualFileSystem, options?: {
|
|
390
509
|
readOnly?: boolean;
|
|
391
|
-
}): void
|
|
392
|
-
unmountFs(path: string): void
|
|
510
|
+
}): Promise<void>;
|
|
511
|
+
unmountFs(path: string): Promise<void>;
|
|
393
512
|
move(from: string, to: string): Promise<void>;
|
|
394
513
|
delete(path: string, options?: {
|
|
395
514
|
recursive?: boolean;
|
|
@@ -400,11 +519,17 @@ export declare class AgentOs {
|
|
|
400
519
|
};
|
|
401
520
|
connectTerminal(options?: ConnectTerminalOptions): Promise<number>;
|
|
402
521
|
/** Write data to a shell's PTY input. */
|
|
403
|
-
writeShell(shellId: string, data: string | Uint8Array): void
|
|
522
|
+
writeShell(shellId: string, data: string | Uint8Array): Promise<void>;
|
|
404
523
|
/** Subscribe to data output from a shell. Returns an unsubscribe function. */
|
|
405
524
|
onShellData(shellId: string, handler: (data: Uint8Array) => void): () => void;
|
|
406
525
|
/** Notify a shell of terminal resize. */
|
|
407
526
|
resizeShell(shellId: string, cols: number, rows: number): void;
|
|
527
|
+
/**
|
|
528
|
+
* Wait for a shell to exit and return its process exit code. Resolves
|
|
529
|
+
* immediately for a shell that has already exited (within the closed-shell
|
|
530
|
+
* retention window).
|
|
531
|
+
*/
|
|
532
|
+
waitShell(shellId: string): Promise<number>;
|
|
408
533
|
/** Kill a shell process and remove it from tracking. */
|
|
409
534
|
closeShell(shellId: string): void;
|
|
410
535
|
private _resolveVmPathToHostPath;
|
|
@@ -424,15 +549,53 @@ export declare class AgentOs {
|
|
|
424
549
|
listSessions(): SessionInfo[];
|
|
425
550
|
/** Internal helper: retrieve a session or throw. */
|
|
426
551
|
private _requireSession;
|
|
427
|
-
/**
|
|
428
|
-
|
|
552
|
+
/**
|
|
553
|
+
* Dynamically link a software package into the RUNNING VM. The package's
|
|
554
|
+
* `bin/` commands appear under `/opt/agentos/bin` (on `$PATH`) and its `share/man`
|
|
555
|
+
* pages under MANPATH immediately — the `/opt/agentos` mount is host-backed, so
|
|
556
|
+
* writing into its staging dir is reflected live with no reboot. An `agent`
|
|
557
|
+
* block registers the package for `createSession(name)`. Persists for the VM's
|
|
558
|
+
* lifetime (and across a snapshot iff the volume persists).
|
|
559
|
+
*/
|
|
560
|
+
linkSoftware(descriptor: PackageRef | SoftwarePackageRef): Promise<void>;
|
|
561
|
+
providedCommands(): Promise<{
|
|
562
|
+
packageName: string;
|
|
563
|
+
commands: string[];
|
|
564
|
+
}[]>;
|
|
565
|
+
/**
|
|
566
|
+
* Returns all registered agents with their installation status. Thin forwarder:
|
|
567
|
+
* sends `AcpListAgentsRequest` and maps the response. The sidecar enumerates the
|
|
568
|
+
* projected `/opt/agentos` packages (the client parses no manifests). Every such
|
|
569
|
+
* agent is a package materialized into the VM, so `installed` is always `true`.
|
|
570
|
+
*/
|
|
571
|
+
listAgents(): Promise<AgentRegistryEntry[]>;
|
|
429
572
|
private _syncSessionState;
|
|
430
573
|
private _applySessionUpdate;
|
|
431
574
|
private _recordSessionNotification;
|
|
432
575
|
private _dispatchSessionEvent;
|
|
433
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
|
+
private _recordAgentStderr;
|
|
595
|
+
private _recordAgentExit;
|
|
434
596
|
private _applySyntheticConfigOverrides;
|
|
435
597
|
private _handleSidecarEvent;
|
|
598
|
+
private _handleLimitWarning;
|
|
436
599
|
private _handleAcpExtEvent;
|
|
437
600
|
private _unsupportedConfigResponse;
|
|
438
601
|
private _sendAcpRequest;
|
|
@@ -445,7 +608,7 @@ export declare class AgentOs {
|
|
|
445
608
|
private _rejectPendingPermissionRepliesFromSession;
|
|
446
609
|
private _closeSessionInternal;
|
|
447
610
|
private _hydrateSessionState;
|
|
448
|
-
createSession(agentType: AgentType
|
|
611
|
+
createSession(agentType: AgentType, options?: CreateSessionOptions): Promise<{
|
|
449
612
|
sessionId: string;
|
|
450
613
|
}>;
|
|
451
614
|
/**
|
|
@@ -463,23 +626,7 @@ export declare class AgentOs {
|
|
|
463
626
|
* Resume depends on a durable root; on a non-durable (default in-memory) root
|
|
464
627
|
* there is no surviving store and the fallback tier always runs.
|
|
465
628
|
*/
|
|
466
|
-
resumeSession(sessionId: string, agentType: AgentType
|
|
467
|
-
/**
|
|
468
|
-
* Resolve the VM bin entry point of an ACP adapter package.
|
|
469
|
-
* Reads from the host filesystem since kernel.readFile() resolves through
|
|
470
|
-
* mounts; adapter package.json is read directly off the host dir backing
|
|
471
|
-
* the relevant mount.
|
|
472
|
-
*/
|
|
473
|
-
private _resolveAdapterBin;
|
|
474
|
-
/**
|
|
475
|
-
* Parent of the host directory backing the `/root/node_modules` mount, if
|
|
476
|
-
* the caller supplied one (e.g. via `nodeModulesMount(...)`). Used as the
|
|
477
|
-
* `resolvePackageDir` start dir for adapter/agent package resolution when no
|
|
478
|
-
* software root matches. `nodeModulesMount` mounts `<dir>/node_modules`, so
|
|
479
|
-
* the start dir is `<dir>` (one level above the node_modules tree).
|
|
480
|
-
*/
|
|
481
|
-
private _nodeModulesHostRoot;
|
|
482
|
-
private _resolvePackageBin;
|
|
629
|
+
resumeSession(sessionId: string, agentType: AgentType, options?: ResumeSessionOptions): Promise<ResumeSessionResult>;
|
|
483
630
|
private _installSidecarRequestHandler;
|
|
484
631
|
private _handleAcpExtSidecarRequest;
|
|
485
632
|
private _dispatchAcpSidecarRequest;
|
|
@@ -506,11 +653,6 @@ export declare class AgentOs {
|
|
|
506
653
|
private _handleAcpReleaseTerminal;
|
|
507
654
|
private _handleAcpResizeTerminal;
|
|
508
655
|
private _handleAcpPermissionCallback;
|
|
509
|
-
/**
|
|
510
|
-
* Resolve an agent config by ID. Package-provided configs take
|
|
511
|
-
* precedence over the hardcoded AGENT_CONFIGS.
|
|
512
|
-
*/
|
|
513
|
-
private _resolveAgentConfig;
|
|
514
656
|
/**
|
|
515
657
|
* Gracefully destroy a session: cancel any pending work, close the client,
|
|
516
658
|
* and remove from tracking. Unlike close() which is abrupt, this attempts
|