@rivet-dev/agentos-core 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-os.d.ts +4 -0
- package/dist/agent-os.js +39 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/options-schema.d.ts +1 -0
- package/dist/options-schema.js +4 -0
- package/dist/sandbox.js +33 -20
- package/dist/types.d.ts +1 -0
- package/package.json +6 -6
package/dist/agent-os.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { VmUserConfig } from "@rivet-dev/agentos-runtime-core/vm-config";
|
|
|
3
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
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
|
+
import { type AgentOsSandboxInput } from "./sandbox.js";
|
|
6
7
|
export type { MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, NativeMountPluginDescriptor, } from "@rivet-dev/agentos-runtime-core/descriptors";
|
|
7
8
|
export type { ConnectTerminalOptions } from "./runtime-compat.js";
|
|
8
9
|
export type * from "./session-api.js";
|
|
@@ -393,6 +394,8 @@ export interface AgentOsOptions {
|
|
|
393
394
|
rootFilesystem?: RootFilesystemConfig;
|
|
394
395
|
/** Filesystems to mount at boot time. */
|
|
395
396
|
mounts?: MountConfig[];
|
|
397
|
+
/** External sandbox mounted into this VM with process bindings. */
|
|
398
|
+
sandbox?: AgentOsSandboxInput;
|
|
396
399
|
/** Custom schedule driver for cron jobs. Defaults to TimerScheduleDriver. */
|
|
397
400
|
scheduleDriver?: ScheduleDriver;
|
|
398
401
|
/** Host-side bindings available to agents inside the VM. */
|
|
@@ -475,6 +478,7 @@ export declare class AgentOs {
|
|
|
475
478
|
private readonly _agentStderrHandler?;
|
|
476
479
|
private readonly _agentExitHandler?;
|
|
477
480
|
private readonly _limitWarningHandler?;
|
|
481
|
+
private readonly _disposeHooks;
|
|
478
482
|
private constructor();
|
|
479
483
|
static createSidecar(options?: AgentOsCreateSidecarOptions): Promise<AgentOsSidecar>;
|
|
480
484
|
static getSharedSidecar(options?: AgentOsSharedSidecarOptions): Promise<AgentOsSidecar>;
|
package/dist/agent-os.js
CHANGED
|
@@ -6,6 +6,7 @@ import { fileURLToPath } from "node:url";
|
|
|
6
6
|
import { validateBindings } from "./bindings.js";
|
|
7
7
|
import { zodToJsonSchema } from "./bindings-zod.js";
|
|
8
8
|
import { parseAgentOsOptions } from "./options-schema.js";
|
|
9
|
+
import { getSandboxDisposeHooks, resolveSandboxOptions, } from "./sandbox.js";
|
|
9
10
|
import { resolvePublishedSidecarBinary } from "./sidecar/binary.js";
|
|
10
11
|
import { findCargoBinary, resolveCargoBinary } from "./sidecar/cargo.js";
|
|
11
12
|
const ACP_PROTOCOL_VERSION = 1;
|
|
@@ -1457,6 +1458,7 @@ export class AgentOs {
|
|
|
1457
1458
|
_agentStderrHandler;
|
|
1458
1459
|
_agentExitHandler;
|
|
1459
1460
|
_limitWarningHandler;
|
|
1461
|
+
_disposeHooks = [];
|
|
1460
1462
|
constructor(kernel, sidecar, softwareRoots, hostMounts, env, rootFilesystem, sidecarClient, sidecarSession, sidecarVm, agentStderrHandler, agentExitHandler, limitWarningHandler) {
|
|
1461
1463
|
this.#kernel = kernel;
|
|
1462
1464
|
this.sidecar = sidecar;
|
|
@@ -1522,13 +1524,15 @@ export class AgentOs {
|
|
|
1522
1524
|
// sidecar owns agent resolution, agent enumeration, and agent snapshot
|
|
1523
1525
|
// bundle loading from the projected package dirs.
|
|
1524
1526
|
const localMounts = await resolveCompatLocalMounts(options?.mounts);
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
validateBindings(bindings);
|
|
1527
|
+
if (options?.bindings && options.bindings.length > 0) {
|
|
1528
|
+
validateBindings(options.bindings);
|
|
1528
1529
|
}
|
|
1529
|
-
// Resolve the sidecar handle
|
|
1530
|
-
//
|
|
1530
|
+
// Resolve the sidecar handle before starting an external sandbox so option
|
|
1531
|
+
// validation failures cannot leak provider resources.
|
|
1531
1532
|
const sidecar = resolveAgentOsSidecar(options?.sidecar);
|
|
1533
|
+
options = await resolveSandboxOptions(options);
|
|
1534
|
+
const sandboxDisposeHooks = getSandboxDisposeHooks(options);
|
|
1535
|
+
const bindings = options.bindings;
|
|
1532
1536
|
const createVmAdmin = async () => {
|
|
1533
1537
|
// The `/opt/agentos` projection is built by the sidecar from the
|
|
1534
1538
|
// forwarded `packages` (it owns the staging dir + read-only mount, and
|
|
@@ -1736,12 +1740,24 @@ export class AgentOs {
|
|
|
1736
1740
|
vm._bindings = vmAdmin.bindings;
|
|
1737
1741
|
vm._bindingReference = vmAdmin.bindingReference;
|
|
1738
1742
|
vm._permissions = vmAdmin.permissions;
|
|
1743
|
+
vm._disposeHooks.push(...sandboxDisposeHooks);
|
|
1739
1744
|
vm._installSidecarRequestHandler();
|
|
1740
1745
|
vm._cronManager = new CronManager(vm, options?.scheduleDriver ?? new TimerScheduleDriver());
|
|
1741
1746
|
return vm;
|
|
1742
1747
|
}
|
|
1743
1748
|
catch (error) {
|
|
1744
|
-
|
|
1749
|
+
const cleanupErrors = [];
|
|
1750
|
+
try {
|
|
1751
|
+
await sidecarLease?.dispose();
|
|
1752
|
+
}
|
|
1753
|
+
catch (disposeError) {
|
|
1754
|
+
cleanupErrors.push(disposeError);
|
|
1755
|
+
}
|
|
1756
|
+
const sandboxCleanupResults = await Promise.allSettled(sandboxDisposeHooks.map((hook) => hook()));
|
|
1757
|
+
cleanupErrors.push(...sandboxCleanupResults.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
|
|
1758
|
+
if (cleanupErrors.length > 0) {
|
|
1759
|
+
throw new AggregateError([error, ...cleanupErrors], "AgentOS VM creation and cleanup failed");
|
|
1760
|
+
}
|
|
1745
1761
|
throw error;
|
|
1746
1762
|
}
|
|
1747
1763
|
}
|
|
@@ -3100,10 +3116,24 @@ export class AgentOs {
|
|
|
3100
3116
|
this._disposeSidecarEventListener();
|
|
3101
3117
|
const sidecarLease = this._sidecarLease;
|
|
3102
3118
|
this._sidecarLease = null;
|
|
3103
|
-
|
|
3104
|
-
|
|
3119
|
+
const disposeVm = sidecarLease
|
|
3120
|
+
? sidecarLease.dispose()
|
|
3121
|
+
: this.#kernel.dispose();
|
|
3122
|
+
const hooks = this._disposeHooks.splice(0);
|
|
3123
|
+
const errors = [];
|
|
3124
|
+
try {
|
|
3125
|
+
await disposeVm;
|
|
3126
|
+
}
|
|
3127
|
+
catch (error) {
|
|
3128
|
+
errors.push(error);
|
|
3129
|
+
}
|
|
3130
|
+
const hookResults = await Promise.allSettled(hooks.map((hook) => hook()));
|
|
3131
|
+
errors.push(...hookResults.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
|
|
3132
|
+
if (errors.length === 1)
|
|
3133
|
+
throw errors[0];
|
|
3134
|
+
if (errors.length > 1) {
|
|
3135
|
+
throw new AggregateError(errors, "AgentOS VM disposal failed");
|
|
3105
3136
|
}
|
|
3106
|
-
return this.#kernel.dispose();
|
|
3107
3137
|
}
|
|
3108
3138
|
}
|
|
3109
3139
|
const agentOsRuntimeAdmins = new WeakMap();
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export { defineSoftware } from "./packages.js";
|
|
|
8
8
|
export { isPackageDescriptor, OPT_AGENTOS_BIN, OPT_AGENTOS_ROOT, tryReadAgentosPackageManifest, } from "./agentos-package.js";
|
|
9
9
|
export { KernelError } from "./runtime-compat.js";
|
|
10
10
|
export type { ExecOptions, ExecResult, ManagedProcess, ProcessInfo, ShellHandle, VirtualDirEntry, VirtualStat, } from "./runtime.js";
|
|
11
|
+
export { createSandboxBindings, createSandboxFs, getSandboxDisposeHooks, resolveSandboxOptions, } from "./sandbox.js";
|
|
11
12
|
export type * from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -8,3 +8,4 @@ export { createSnapshotExport, } from "./layers.js";
|
|
|
8
8
|
export { defineSoftware } from "./packages.js";
|
|
9
9
|
export { isPackageDescriptor, OPT_AGENTOS_BIN, OPT_AGENTOS_ROOT, tryReadAgentosPackageManifest, } from "./agentos-package.js";
|
|
10
10
|
export { KernelError } from "./runtime-compat.js";
|
|
11
|
+
export { createSandboxBindings, createSandboxFs, getSandboxDisposeHooks, resolveSandboxOptions, } from "./sandbox.js";
|
package/dist/options-schema.d.ts
CHANGED
|
@@ -338,6 +338,7 @@ export declare const agentOsOptionFieldSchemas: {
|
|
|
338
338
|
lowers: z.ZodArray<z.ZodUnknown>;
|
|
339
339
|
}, z.core.$strict>;
|
|
340
340
|
}, z.core.$strict>]>>>;
|
|
341
|
+
readonly sandbox: z.ZodOptional<z.ZodCustom<unknown, unknown>>;
|
|
341
342
|
readonly scheduleDriver: z.ZodOptional<z.ZodCustom<unknown, unknown>>;
|
|
342
343
|
readonly bindings: z.ZodOptional<z.ZodArray<z.ZodType<Bindings, unknown, z.core.$ZodTypeInternals<Bindings, unknown>>>>;
|
|
343
344
|
readonly permissions: z.ZodOptional<z.ZodObject<{
|
package/dist/options-schema.js
CHANGED
|
@@ -352,6 +352,10 @@ export const agentOsOptionFieldSchemas = {
|
|
|
352
352
|
.optional(),
|
|
353
353
|
rootFilesystem: rootFilesystemConfigSchema.optional(),
|
|
354
354
|
mounts: z.array(mountConfigSchema).optional(),
|
|
355
|
+
sandbox: z
|
|
356
|
+
.custom((value) => value === undefined ||
|
|
357
|
+
(typeof value === "object" && value !== null && !Array.isArray(value)), { message: "Expected sandbox options object" })
|
|
358
|
+
.optional(),
|
|
355
359
|
scheduleDriver: z
|
|
356
360
|
.custom((value) => typeof value === "object" && value !== null, {
|
|
357
361
|
message: "Expected schedule driver object",
|
package/dist/sandbox.js
CHANGED
|
@@ -241,24 +241,37 @@ export async function resolveSandboxOptions(options) {
|
|
|
241
241
|
return rest;
|
|
242
242
|
}
|
|
243
243
|
const normalizedSandbox = await normalizeSandboxInput(sandbox);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
244
|
+
try {
|
|
245
|
+
const sandboxOptions = normalizedSandbox.options;
|
|
246
|
+
const expanded = rest;
|
|
247
|
+
const mountPath = sandboxOptions.mountPath ?? "/mnt/sandbox";
|
|
248
|
+
const mounts = [
|
|
249
|
+
...(expanded.mounts ?? []),
|
|
250
|
+
{
|
|
251
|
+
path: mountPath,
|
|
252
|
+
plugin: createSandboxFs(sandboxOptions),
|
|
253
|
+
readOnly: sandboxOptions.readOnly,
|
|
254
|
+
},
|
|
255
|
+
];
|
|
256
|
+
const bindings = [
|
|
257
|
+
...(expanded.bindings ?? []),
|
|
258
|
+
createSandboxBindings(sandboxOptions),
|
|
259
|
+
];
|
|
260
|
+
return attachSandboxDisposeHooks({
|
|
261
|
+
...expanded,
|
|
262
|
+
mounts,
|
|
263
|
+
bindings,
|
|
264
|
+
}, normalizedSandbox.dispose ? [normalizedSandbox.dispose] : []);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
if (!normalizedSandbox.dispose)
|
|
268
|
+
throw error;
|
|
269
|
+
try {
|
|
270
|
+
await normalizedSandbox.dispose();
|
|
271
|
+
}
|
|
272
|
+
catch (disposeError) {
|
|
273
|
+
throw new AggregateError([error, disposeError], "Sandbox configuration and cleanup failed");
|
|
274
|
+
}
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
264
277
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export type { FilesystemSnapshotExport, LayerHandle, LayerStore, OverlayFilesyst
|
|
|
14
14
|
export type { SoftwareInput, SoftwareRoot } from "./packages.js";
|
|
15
15
|
export type { AgentBlock, PackageDescriptor, PackageRef, SoftwarePackageRef, } from "./agentos-package.js";
|
|
16
16
|
export type { ChildProcessPermissions, ConnectTerminalOptions, EnvPermissions, ExecOptions, ExecResult, FsPermissionRule, FsPermissions, KernelExecOptions, KernelExecResult, KernelSpawnOptions, NetworkAccessRequest, NetworkPermissions, OpenShellOptions, PatternPermissionRule, PermissionDecision, PermissionMode, Permissions, ProcessInfo, RulePermissions, StdioChannel, TimingMitigation, VirtualDirEntry, VirtualFileSystem, VirtualStat, } from "./runtime.js";
|
|
17
|
+
export type { AgentOsSandboxClient, AgentOsSandboxClientOptions, AgentOsSandboxCommonOptions, AgentOsSandboxInput, AgentOsSandboxOptions, AgentOsSandboxProcessInfo, AgentOsSandboxProcessLogs, AgentOsSandboxProcessResult, AgentOsSandboxProvider, AgentOsSandboxProviderOptions, SandboxMountPluginConfig, } from "./sandbox.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivet-dev/agentos-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"@agentclientprotocol/sdk": "0.16.1",
|
|
60
60
|
"@agentos-software/claude-code": "0.2.7",
|
|
61
61
|
"@agentos-software/codex-cli": "0.3.4",
|
|
62
|
-
"@agentos-software/common": "0.2.
|
|
63
|
-
"@agentos-software/manifest": "0.2.
|
|
62
|
+
"@agentos-software/common": "0.2.10",
|
|
63
|
+
"@agentos-software/manifest": "0.2.10",
|
|
64
64
|
"@agentos-software/opencode": "0.2.7",
|
|
65
65
|
"@agentos-software/pi": "0.2.7",
|
|
66
66
|
"@aws-sdk/client-s3": "^3.1019.0",
|
|
67
|
-
"@rivet-dev/agentos-sidecar": "0.2.
|
|
67
|
+
"@rivet-dev/agentos-sidecar": "0.2.10",
|
|
68
68
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
69
|
-
"@rivet-dev/agentos-runtime-core": "0.2.
|
|
69
|
+
"@rivet-dev/agentos-runtime-core": "0.2.10",
|
|
70
70
|
"@xterm/headless": "^6.0.0",
|
|
71
71
|
"better-sqlite3": "^12.8.0",
|
|
72
72
|
"croner": "^10.0.1",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@agentos-software/vim": "0.3.3",
|
|
102
102
|
"@agentos-software/wget": "0.3.3",
|
|
103
103
|
"@agentos-software/yq": "0.3.3",
|
|
104
|
-
"@rivet-dev/agentos-test-harness": "0.2.
|
|
104
|
+
"@rivet-dev/agentos-test-harness": "0.2.10",
|
|
105
105
|
"@anthropic-ai/claude-agent-sdk": "^0.2.87",
|
|
106
106
|
"@anthropic-ai/claude-code": "^2.1.86",
|
|
107
107
|
"@bare-ts/tools": "0.15.0",
|