@rivet-dev/agentos-runtime-core 0.0.0-codex-actor-plugin-contract-coverage.115ca8a → 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/commands/[ +0 -0
- package/commands/_stubs +0 -0
- package/commands/acl_tools +0 -0
- package/commands/arch +0 -0
- package/commands/attr +0 -0
- package/commands/awk +0 -0
- package/commands/b2sum +0 -0
- package/commands/base32 +0 -0
- package/commands/base64 +0 -0
- package/commands/basename +0 -0
- package/commands/basenc +0 -0
- package/commands/bash +0 -0
- package/commands/bc +0 -0
- package/commands/cat +0 -0
- package/commands/chacl +0 -0
- package/commands/chcon +0 -0
- package/commands/chgrp +0 -0
- package/commands/chmod +0 -0
- package/commands/chown +0 -0
- package/commands/chroot +0 -0
- package/commands/cksum +0 -0
- package/commands/cmp +0 -0
- package/commands/column +0 -0
- package/commands/comm +0 -0
- package/commands/cp +0 -0
- package/commands/curl +0 -0
- package/commands/cut +0 -0
- package/commands/date +0 -0
- package/commands/dd +0 -0
- package/commands/df +0 -0
- package/commands/diff +0 -0
- package/commands/dir +0 -0
- package/commands/dircolors +0 -0
- package/commands/dirname +0 -0
- package/commands/du +0 -0
- package/commands/echo +0 -0
- package/commands/egrep +0 -0
- package/commands/env +0 -0
- package/commands/envsubst +0 -0
- package/commands/expand +0 -0
- package/commands/expr +0 -0
- package/commands/factor +0 -0
- package/commands/false +0 -0
- package/commands/fd +0 -0
- package/commands/fgrep +0 -0
- package/commands/file +0 -0
- package/commands/find +0 -0
- package/commands/findmnt +0 -0
- package/commands/fmt +0 -0
- package/commands/fold +0 -0
- package/commands/getent +0 -0
- package/commands/getfacl +0 -0
- package/commands/getfattr +0 -0
- package/commands/git +0 -0
- package/commands/git-receive-pack +0 -0
- package/commands/git-remote-http +0 -0
- package/commands/git-remote-https +0 -0
- package/commands/git-upload-archive +0 -0
- package/commands/git-upload-pack +0 -0
- package/commands/grep +0 -0
- package/commands/groups +0 -0
- package/commands/gunzip +0 -0
- package/commands/gzip +0 -0
- package/commands/head +0 -0
- package/commands/hostid +0 -0
- package/commands/hostname +0 -0
- package/commands/http-test +0 -0
- package/commands/id +0 -0
- package/commands/install +0 -0
- package/commands/join +0 -0
- package/commands/jq +0 -0
- package/commands/kill +0 -0
- package/commands/link +0 -0
- package/commands/ln +0 -0
- package/commands/logname +0 -0
- package/commands/ls +0 -0
- package/commands/md5sum +0 -0
- package/commands/mkdir +0 -0
- package/commands/mkfifo +0 -0
- package/commands/mknod +0 -0
- package/commands/mktemp +0 -0
- package/commands/more +0 -0
- package/commands/mount +0 -0
- package/commands/mv +0 -0
- package/commands/nice +0 -0
- package/commands/nl +0 -0
- package/commands/nohup +0 -0
- package/commands/nproc +0 -0
- package/commands/numfmt +0 -0
- package/commands/od +0 -0
- package/commands/paste +0 -0
- package/commands/pathchk +0 -0
- package/commands/pinky +0 -0
- package/commands/printenv +0 -0
- package/commands/printf +0 -0
- package/commands/ptx +0 -0
- package/commands/pwd +0 -0
- package/commands/readlink +0 -0
- package/commands/realpath +0 -0
- package/commands/rev +0 -0
- package/commands/rg +0 -0
- package/commands/rm +0 -0
- package/commands/rmdir +0 -0
- package/commands/runas +0 -0
- package/commands/runcon +0 -0
- package/commands/sed +0 -0
- package/commands/seq +0 -0
- package/commands/setfacl +0 -0
- package/commands/setfattr +0 -0
- package/commands/sh +0 -0
- package/commands/sha1sum +0 -0
- package/commands/sha224sum +0 -0
- package/commands/sha256sum +0 -0
- package/commands/sha384sum +0 -0
- package/commands/sha512sum +0 -0
- package/commands/shred +0 -0
- package/commands/shuf +0 -0
- package/commands/sleep +0 -0
- package/commands/sort +0 -0
- package/commands/spawn-test-host +0 -0
- package/commands/split +0 -0
- package/commands/sqlite3 +0 -0
- package/commands/ssh +0 -0
- package/commands/ssh-keysign +0 -0
- package/commands/ssh-sk-helper +0 -0
- package/commands/stat +0 -0
- package/commands/stdbuf +0 -0
- package/commands/strings +0 -0
- package/commands/stty +0 -0
- package/commands/su +0 -0
- package/commands/sum +0 -0
- package/commands/sync +0 -0
- package/commands/tac +0 -0
- package/commands/tail +0 -0
- package/commands/tar +0 -0
- package/commands/tee +0 -0
- package/commands/test +0 -0
- package/commands/timeout +0 -0
- package/commands/touch +0 -0
- package/commands/tr +0 -0
- package/commands/tree +0 -0
- package/commands/true +0 -0
- package/commands/truncate +0 -0
- package/commands/tsort +0 -0
- package/commands/tty +0 -0
- package/commands/uname +0 -0
- package/commands/unexpand +0 -0
- package/commands/uniq +0 -0
- package/commands/unlink +0 -0
- package/commands/unzip +0 -0
- package/commands/uptime +0 -0
- package/commands/users +0 -0
- package/commands/vdir +0 -0
- package/commands/wc +0 -0
- package/commands/wget +0 -0
- package/commands/which +0 -0
- package/commands/who +0 -0
- package/commands/whoami +0 -0
- package/commands/xargs +0 -0
- package/commands/xattr_tools +0 -0
- package/commands/xfs_io +0 -0
- package/commands/xu +0 -0
- package/commands/yes +0 -0
- package/commands/yq +0 -0
- package/commands/zcat +0 -0
- package/commands/zip +0 -0
- package/dist/correlation.d.ts +1 -4
- package/dist/correlation.js +7 -10
- package/dist/descriptors.d.ts +2 -12
- package/dist/descriptors.js +10 -6
- package/dist/frame-rpc.d.ts +9 -4
- package/dist/frame-rpc.js +19 -2
- package/dist/frame-stream.d.ts +33 -0
- package/dist/frame-stream.js +113 -0
- package/dist/generated/AcpLimitsConfig.d.ts +16 -0
- package/dist/generated/BindingLimitsConfig.d.ts +10 -0
- package/dist/generated/CreateVmConfig.d.ts +4 -0
- package/dist/generated/Http2LimitsConfig.d.ts +12 -0
- package/dist/generated/Http2LimitsConfig.js +2 -0
- package/dist/generated/JsRuntimeLimitsConfig.d.ts +1 -0
- package/dist/generated/MountPluginDescriptor.d.ts +1 -1
- package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
- package/dist/generated/ProcessLimitsConfig.js +2 -0
- package/dist/generated/ReactorLimitsConfig.d.ts +23 -0
- package/dist/generated/ReactorLimitsConfig.js +2 -0
- package/dist/generated/SqliteLimitsConfig.d.ts +3 -0
- package/dist/generated/SqliteLimitsConfig.js +2 -0
- package/dist/generated/TlsLimitsConfig.d.ts +3 -0
- package/dist/generated/TlsLimitsConfig.js +2 -0
- package/dist/generated/UdpLimitsConfig.d.ts +4 -0
- package/dist/generated/UdpLimitsConfig.js +2 -0
- package/dist/generated/VmGroupConfig.d.ts +5 -0
- package/dist/generated/VmGroupConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +14 -2
- package/dist/generated/VmSqliteDescriptor.d.ts +11 -0
- package/dist/generated/VmSqliteDescriptor.js +2 -0
- 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/VmUserConfig.js +1 -0
- package/dist/generated/WasmLimitsConfig.d.ts +1 -0
- package/dist/generated-protocol.d.ts +60 -2
- package/dist/generated-protocol.js +166 -31
- package/dist/kernel-proxy.d.ts +5 -1
- package/dist/kernel-proxy.js +77 -39
- package/dist/native-client.d.ts +9 -5
- package/dist/native-client.js +41 -9
- package/dist/node-runtime-options-schema.d.ts +1 -1
- package/dist/node-runtime-options-schema.js +43 -1
- package/dist/node-runtime.d.ts +12 -3
- package/dist/node-runtime.js +8 -7
- package/dist/process.d.ts +3 -1
- package/dist/process.js +27 -8
- package/dist/protocol-client.d.ts +26 -4
- package/dist/protocol-client.js +164 -12
- package/dist/protocol-frames.d.ts +14 -3
- package/dist/protocol-frames.js +26 -1
- package/dist/protocol-schema.d.ts +1 -1
- package/dist/protocol-schema.js +1 -1
- package/dist/request-payloads.d.ts +4 -1
- package/dist/request-payloads.js +7 -2
- package/dist/response-payloads.d.ts +23 -2
- package/dist/response-payloads.js +34 -2
- package/dist/sidecar-errors.d.ts +37 -0
- package/dist/sidecar-errors.js +27 -0
- package/dist/sidecar-process.d.ts +20 -6
- package/dist/sidecar-process.js +79 -15
- package/dist/state.d.ts +6 -6
- package/dist/state.js +10 -11
- package/dist/test-runtime.d.ts +21 -6
- package/dist/test-runtime.js +129 -65
- package/dist/vm-config.d.ts +5 -1
- package/package.json +5 -3
- package/commands/codex +0 -0
- package/commands/codex-exec +0 -0
- package/commands/http_get +0 -0
- package/dist/generated/ToolLimitsConfig.d.ts +0 -10
- /package/dist/generated/{ToolLimitsConfig.js → BindingLimitsConfig.js} +0 -0
package/dist/test-runtime.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as path from "node:path";
|
|
|
5
5
|
import * as posixPath from "node:path/posix";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import "./native-client.js";
|
|
8
|
-
import {
|
|
8
|
+
import { NativeSidecarKernelProxy, SidecarProcess, serializeMountConfigForSidecar, } from "./kernel-proxy.js";
|
|
9
9
|
import { resolvePublishedSidecarBinary } from "./binary.js";
|
|
10
10
|
import { findCargoBinary, resolveCargoBinary } from "./cargo.js";
|
|
11
11
|
export const AF_INET = 2;
|
|
@@ -33,6 +33,8 @@ const KERNEL_POSIX_BOOTSTRAP_DIRS = [
|
|
|
33
33
|
"/srv",
|
|
34
34
|
"/sys",
|
|
35
35
|
"/opt",
|
|
36
|
+
"/opt/agentos",
|
|
37
|
+
"/opt/agentos/bin",
|
|
36
38
|
"/mnt",
|
|
37
39
|
"/media",
|
|
38
40
|
"/home",
|
|
@@ -66,9 +68,21 @@ const SIDECAR_BUILD_INPUTS = [
|
|
|
66
68
|
path.join(REPO_ROOT, "Cargo.toml"),
|
|
67
69
|
path.join(REPO_ROOT, "Cargo.lock"),
|
|
68
70
|
path.join(REPO_ROOT, "crates/bridge"),
|
|
71
|
+
path.join(REPO_ROOT, "crates/build-support"),
|
|
69
72
|
path.join(REPO_ROOT, "crates/execution"),
|
|
70
73
|
path.join(REPO_ROOT, "crates/kernel"),
|
|
71
|
-
path.join(REPO_ROOT, "crates/sidecar"),
|
|
74
|
+
path.join(REPO_ROOT, "crates/native-sidecar"),
|
|
75
|
+
path.join(REPO_ROOT, "crates/native-sidecar-core"),
|
|
76
|
+
path.join(REPO_ROOT, "crates/sidecar-protocol"),
|
|
77
|
+
path.join(REPO_ROOT, "crates/v8-runtime"),
|
|
78
|
+
path.join(REPO_ROOT, "crates/vfs"),
|
|
79
|
+
path.join(REPO_ROOT, "crates/vm-config"),
|
|
80
|
+
path.join(REPO_ROOT, "packages/build-tools/bridge-src"),
|
|
81
|
+
path.join(REPO_ROOT, "packages/build-tools/package.json"),
|
|
82
|
+
path.join(REPO_ROOT, "packages/build-tools/scripts/build-v8-bridge.mjs"),
|
|
83
|
+
path.join(REPO_ROOT, "packages/core/fixtures/base-filesystem.json"),
|
|
84
|
+
path.join(REPO_ROOT, "packages/runtime-core/fixtures/base-filesystem.json"),
|
|
85
|
+
path.join(REPO_ROOT, "pnpm-lock.yaml"),
|
|
72
86
|
];
|
|
73
87
|
let ensuredSidecarBinary = null;
|
|
74
88
|
export class KernelError extends Error {
|
|
@@ -325,8 +339,10 @@ export class InMemoryFileSystem {
|
|
|
325
339
|
typeBits === 0 ? (entry.mode & 0o170000) | (mode & 0o7777) : mode;
|
|
326
340
|
entry.ctimeMs = Date.now();
|
|
327
341
|
}
|
|
328
|
-
async chown(targetPath, uid, gid) {
|
|
329
|
-
const entry =
|
|
342
|
+
async chown(targetPath, uid, gid, options) {
|
|
343
|
+
const entry = options?.followSymlinks === false
|
|
344
|
+
? this.entries.get(normalizePath(targetPath))
|
|
345
|
+
: this.resolveEntry(targetPath);
|
|
330
346
|
if (!entry)
|
|
331
347
|
throw errnoError("ENOENT", `chown '${targetPath}'`);
|
|
332
348
|
entry.uid = uid;
|
|
@@ -548,8 +564,14 @@ export class NodeFileSystem {
|
|
|
548
564
|
async chmod(targetPath, mode) {
|
|
549
565
|
await fs.chmod(this.normalizeTarget(targetPath), mode);
|
|
550
566
|
}
|
|
551
|
-
async chown(targetPath, uid, gid) {
|
|
552
|
-
|
|
567
|
+
async chown(targetPath, uid, gid, options) {
|
|
568
|
+
const normalized = this.normalizeTarget(targetPath);
|
|
569
|
+
if (options?.followSymlinks === false) {
|
|
570
|
+
await fs.lchown(normalized, uid, gid);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
await fs.chown(normalized, uid, gid);
|
|
574
|
+
}
|
|
553
575
|
}
|
|
554
576
|
async utimes(targetPath, atime, mtime) {
|
|
555
577
|
await fs.utimes(this.normalizeTarget(targetPath), atime / 1000, mtime / 1000);
|
|
@@ -569,7 +591,7 @@ export class NodeFileSystem {
|
|
|
569
591
|
}
|
|
570
592
|
}
|
|
571
593
|
async pwrite(targetPath, offset, data) {
|
|
572
|
-
const handle = await fs.open(this.normalizeTarget(targetPath),
|
|
594
|
+
const handle = await fs.open(this.normalizeTarget(targetPath), fsSync.constants.O_WRONLY);
|
|
573
595
|
try {
|
|
574
596
|
await handle.write(data, 0, data.length, offset);
|
|
575
597
|
}
|
|
@@ -857,7 +879,6 @@ export const WASMVM_COMMANDS = Object.freeze([
|
|
|
857
879
|
"unzip",
|
|
858
880
|
"sqlite3",
|
|
859
881
|
"curl",
|
|
860
|
-
"wget",
|
|
861
882
|
"git",
|
|
862
883
|
"git-remote-http",
|
|
863
884
|
"git-remote-https",
|
|
@@ -1021,7 +1042,6 @@ export const DEFAULT_FIRST_PARTY_TIERS = Object.freeze({
|
|
|
1021
1042
|
tac: "read-only",
|
|
1022
1043
|
tsort: "read-only",
|
|
1023
1044
|
curl: "full",
|
|
1024
|
-
wget: "full",
|
|
1025
1045
|
sqlite3: "read-write",
|
|
1026
1046
|
});
|
|
1027
1047
|
class NativeRuntimeDescriptor {
|
|
@@ -1148,8 +1168,8 @@ class WasmVmRuntimeDescriptor {
|
|
|
1148
1168
|
recordModuleExecution(command) {
|
|
1149
1169
|
const normalized = normalizeCommandLookup(command);
|
|
1150
1170
|
if (this._commandPaths.has(normalized) ||
|
|
1151
|
-
(!this.commandDirs || this.commandDirs.length === 0) &&
|
|
1152
|
-
this.commands.includes(normalized)) {
|
|
1171
|
+
((!this.commandDirs || this.commandDirs.length === 0) &&
|
|
1172
|
+
this.commands.includes(normalized))) {
|
|
1153
1173
|
this._moduleCache.set(normalized, true);
|
|
1154
1174
|
}
|
|
1155
1175
|
}
|
|
@@ -1201,7 +1221,6 @@ function ensureNativeSidecarBinary() {
|
|
|
1201
1221
|
// A published install has no in-repo Cargo workspace to build from: resolve
|
|
1202
1222
|
// the prebuilt platform binary (or an explicit sidecar override).
|
|
1203
1223
|
if (process.env.AGENTOS_SIDECAR_BIN ||
|
|
1204
|
-
process.env.AGENTOS_SIDECAR_BIN ||
|
|
1205
1224
|
!fsSync.existsSync(path.join(REPO_ROOT, "Cargo.toml"))) {
|
|
1206
1225
|
return resolvePublishedSidecarBinary();
|
|
1207
1226
|
}
|
|
@@ -1243,7 +1262,7 @@ function createBootstrapEntries(commandNames) {
|
|
|
1243
1262
|
...KERNEL_POSIX_BOOTSTRAP_DIRS.map((entryPath) => ({
|
|
1244
1263
|
path: entryPath,
|
|
1245
1264
|
kind: "directory",
|
|
1246
|
-
mode: 0o755,
|
|
1265
|
+
mode: entryPath === "/tmp" || entryPath === "/var/tmp" ? 0o1777 : 0o755,
|
|
1247
1266
|
uid: 0,
|
|
1248
1267
|
gid: 0,
|
|
1249
1268
|
})),
|
|
@@ -1412,9 +1431,16 @@ function collectGuestCommandPaths(commandDirs, startIndex = 0) {
|
|
|
1412
1431
|
async function ensureCommandStubs(proxy, commands) {
|
|
1413
1432
|
const rootView = proxy.createRootView();
|
|
1414
1433
|
for (const command of commands) {
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1434
|
+
// `/bin` supports PATH-based test commands. `/opt/agentos/bin` mirrors
|
|
1435
|
+
// the package projection used by production VMs and is required by
|
|
1436
|
+
// upstream tools that exec private helpers via an absolute libexec path.
|
|
1437
|
+
for (const stubPath of [
|
|
1438
|
+
`/bin/${command}`,
|
|
1439
|
+
`/opt/agentos/bin/${command}`,
|
|
1440
|
+
]) {
|
|
1441
|
+
await rootView.writeFile(stubPath, KERNEL_COMMAND_STUB);
|
|
1442
|
+
await rootView.chmod(stubPath, 0o755);
|
|
1443
|
+
}
|
|
1418
1444
|
}
|
|
1419
1445
|
}
|
|
1420
1446
|
class DeferredFileSystem {
|
|
@@ -1483,8 +1509,8 @@ class DeferredFileSystem {
|
|
|
1483
1509
|
chmod(path, mode) {
|
|
1484
1510
|
return this.filesystem().chmod(path, mode);
|
|
1485
1511
|
}
|
|
1486
|
-
chown(path, uid, gid) {
|
|
1487
|
-
return this.filesystem().chown(path, uid, gid);
|
|
1512
|
+
chown(path, uid, gid, options) {
|
|
1513
|
+
return this.filesystem().chown(path, uid, gid, options);
|
|
1488
1514
|
}
|
|
1489
1515
|
utimes(path, atime, mtime) {
|
|
1490
1516
|
return this.filesystem().utimes(path, atime, mtime);
|
|
@@ -1524,7 +1550,10 @@ const VIRTUAL_FILESYSTEM_METHOD_NAMES = [
|
|
|
1524
1550
|
"pread",
|
|
1525
1551
|
"pwrite",
|
|
1526
1552
|
];
|
|
1527
|
-
const
|
|
1553
|
+
const DEFAULT_LIVE_FILESYSTEM_SYNC_MAX_BYTES = 64 * 1024 * 1024;
|
|
1554
|
+
class LiveFilesystemSyncLimitError extends Error {
|
|
1555
|
+
code = "ERR_AGENTOS_LIVE_FILESYSTEM_SYNC_LIMIT";
|
|
1556
|
+
}
|
|
1528
1557
|
function topLevelSyncRoot(targetPath) {
|
|
1529
1558
|
const normalized = normalizePath(targetPath);
|
|
1530
1559
|
const [first] = normalized.split("/").filter(Boolean);
|
|
@@ -1552,48 +1581,75 @@ async function ensureBoundParentDirectory(methods, targetPath) {
|
|
|
1552
1581
|
if (parent === targetPath) {
|
|
1553
1582
|
return;
|
|
1554
1583
|
}
|
|
1555
|
-
await callBoundFilesystemMethod(methods, "mkdir", parent, {
|
|
1584
|
+
await callBoundFilesystemMethod(methods, "mkdir", parent, {
|
|
1585
|
+
recursive: true,
|
|
1586
|
+
});
|
|
1556
1587
|
}
|
|
1557
|
-
async function syncLiveFilesystemToBoundMethods(live, methods, paths) {
|
|
1588
|
+
async function syncLiveFilesystemToBoundMethods(live, methods, paths, maxBytes) {
|
|
1589
|
+
const snapshot = [];
|
|
1590
|
+
const usage = { bytes: 0 };
|
|
1558
1591
|
for (const targetPath of [...new Set(paths.map(normalizePath))].sort((left, right) => left.localeCompare(right))) {
|
|
1559
1592
|
if (!(await live.exists(targetPath).catch(() => false))) {
|
|
1560
1593
|
continue;
|
|
1561
1594
|
}
|
|
1562
|
-
await
|
|
1595
|
+
await snapshotLiveFilesystemPath(live, targetPath, snapshot, usage, maxBytes);
|
|
1596
|
+
}
|
|
1597
|
+
if (usage.bytes >= maxBytes * 0.8) {
|
|
1598
|
+
process.emitWarning(`live filesystem sync retained ${usage.bytes} of ${maxBytes} bytes; ` +
|
|
1599
|
+
"raise createKernel({ maxFilesystemBytes }) before increasing VM filesystem limits", { code: "AGENTOS_LIVE_FILESYSTEM_SYNC_NEAR_LIMIT" });
|
|
1600
|
+
}
|
|
1601
|
+
for (const entry of snapshot) {
|
|
1602
|
+
await applyLiveFilesystemSnapshotEntry(methods, entry);
|
|
1563
1603
|
}
|
|
1564
1604
|
}
|
|
1565
|
-
async function
|
|
1566
|
-
const stat =
|
|
1605
|
+
async function snapshotLiveFilesystemPath(live, targetPath, snapshot, usage, maxBytes, knownEntry) {
|
|
1606
|
+
const stat = knownEntry ??
|
|
1607
|
+
(targetPath === "/" ? await live.stat(targetPath) : await live.lstat(targetPath));
|
|
1567
1608
|
if (stat.isSymbolicLink) {
|
|
1568
|
-
|
|
1569
|
-
await callBoundFilesystemMethod(methods, "removeFile", targetPath).catch(() => { });
|
|
1570
|
-
await callBoundFilesystemMethod(methods, "symlink", await live.readlink(targetPath), targetPath);
|
|
1609
|
+
snapshot.push({ kind: "symlink", path: targetPath, target: await live.readlink(targetPath) });
|
|
1571
1610
|
return;
|
|
1572
1611
|
}
|
|
1573
1612
|
if (stat.isDirectory) {
|
|
1574
|
-
|
|
1575
|
-
recursive: true,
|
|
1576
|
-
});
|
|
1613
|
+
snapshot.push({ kind: "directory", path: targetPath });
|
|
1577
1614
|
const children = (await live.readDirWithTypes(targetPath))
|
|
1578
|
-
.
|
|
1579
|
-
.
|
|
1580
|
-
.sort((left, right) => left.localeCompare(right));
|
|
1615
|
+
.filter((entry) => entry.name !== "." && entry.name !== "..")
|
|
1616
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
1581
1617
|
for (const child of children) {
|
|
1582
|
-
await
|
|
1618
|
+
await snapshotLiveFilesystemPath(live, targetPath === "/"
|
|
1619
|
+
? posixPath.join("/", child.name)
|
|
1620
|
+
: posixPath.join(targetPath, child.name), snapshot, usage, maxBytes, child);
|
|
1583
1621
|
}
|
|
1584
1622
|
return;
|
|
1585
1623
|
}
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1624
|
+
const fileSize = "size" in stat && typeof stat.size === "number"
|
|
1625
|
+
? stat.size
|
|
1626
|
+
: (await live.lstat(targetPath)).size;
|
|
1627
|
+
if (fileSize > maxBytes - usage.bytes) {
|
|
1628
|
+
throw new LiveFilesystemSyncLimitError(`live filesystem sync for ${targetPath} exceeds ${maxBytes} bytes ` +
|
|
1629
|
+
"(createKernel maxFilesystemBytes); raise createKernel({ maxFilesystemBytes })");
|
|
1630
|
+
}
|
|
1631
|
+
const content = await live.readFile(targetPath);
|
|
1632
|
+
if (content.byteLength > maxBytes - usage.bytes) {
|
|
1633
|
+
throw new LiveFilesystemSyncLimitError(`live filesystem sync for ${targetPath} exceeds ${maxBytes} bytes ` +
|
|
1634
|
+
"(createKernel maxFilesystemBytes); raise createKernel({ maxFilesystemBytes })");
|
|
1635
|
+
}
|
|
1636
|
+
usage.bytes += content.byteLength;
|
|
1637
|
+
snapshot.push({ kind: "file", path: targetPath, content });
|
|
1638
|
+
}
|
|
1639
|
+
async function applyLiveFilesystemSnapshotEntry(methods, entry) {
|
|
1640
|
+
if (entry.kind === "directory") {
|
|
1641
|
+
await callBoundFilesystemMethod(methods, "mkdir", entry.path, { recursive: true });
|
|
1642
|
+
return;
|
|
1594
1643
|
}
|
|
1644
|
+
await ensureBoundParentDirectory(methods, entry.path);
|
|
1645
|
+
if (entry.kind === "symlink") {
|
|
1646
|
+
await callBoundFilesystemMethod(methods, "removeFile", entry.path).catch(() => { });
|
|
1647
|
+
await callBoundFilesystemMethod(methods, "symlink", entry.target, entry.path);
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
await callBoundFilesystemMethod(methods, "writeFile", entry.path, entry.content);
|
|
1595
1651
|
}
|
|
1596
|
-
function bindLiveFilesystem(target, getFilesystem) {
|
|
1652
|
+
function bindLiveFilesystem(target, getFilesystem, maxBytes) {
|
|
1597
1653
|
const fallback = {};
|
|
1598
1654
|
for (const method of VIRTUAL_FILESYSTEM_METHOD_NAMES) {
|
|
1599
1655
|
const candidate = target[method];
|
|
@@ -1619,7 +1675,7 @@ function bindLiveFilesystem(target, getFilesystem) {
|
|
|
1619
1675
|
if (!filesystem) {
|
|
1620
1676
|
return;
|
|
1621
1677
|
}
|
|
1622
|
-
await syncLiveFilesystemToBoundMethods(filesystem, fallback, paths);
|
|
1678
|
+
await syncLiveFilesystemToBoundMethods(filesystem, fallback, paths, maxBytes);
|
|
1623
1679
|
},
|
|
1624
1680
|
restore() {
|
|
1625
1681
|
for (const [method, delegate] of Object.entries(fallback)) {
|
|
@@ -1653,9 +1709,9 @@ class NativeKernel {
|
|
|
1653
1709
|
loopbackExemptPorts;
|
|
1654
1710
|
// Bindings registered with the VM, keyed by the callback key the sidecar
|
|
1655
1711
|
// sends back on a host_callback request (the binding name). Installed lazily
|
|
1656
|
-
// on the first
|
|
1657
|
-
|
|
1658
|
-
|
|
1712
|
+
// on the first registerBindings call.
|
|
1713
|
+
bindingHandlers = new Map();
|
|
1714
|
+
bindingRequestHandlerInstalled = false;
|
|
1659
1715
|
constructor(options) {
|
|
1660
1716
|
this.options = options;
|
|
1661
1717
|
this.env = { ...(options.env ?? {}) };
|
|
@@ -1685,7 +1741,7 @@ class NativeKernel {
|
|
|
1685
1741
|
});
|
|
1686
1742
|
}
|
|
1687
1743
|
this.vfs = new DeferredFileSystem(() => this.rootFilesystem);
|
|
1688
|
-
this.liveFilesystemBinding = bindLiveFilesystem(this.options.filesystem, () => this.rootFilesystem);
|
|
1744
|
+
this.liveFilesystemBinding = bindLiveFilesystem(this.options.filesystem, () => this.rootFilesystem, options.maxFilesystemBytes ?? DEFAULT_LIVE_FILESYSTEM_SYNC_MAX_BYTES);
|
|
1689
1745
|
}
|
|
1690
1746
|
get zombieTimerCount() {
|
|
1691
1747
|
return this.proxy?.zombieTimerCount ?? 0;
|
|
@@ -1880,7 +1936,7 @@ class NativeKernel {
|
|
|
1880
1936
|
await this.ensureReady();
|
|
1881
1937
|
return this.proxy.vmFetch(request);
|
|
1882
1938
|
}
|
|
1883
|
-
async
|
|
1939
|
+
async registerBindings(bindings) {
|
|
1884
1940
|
await this.ensureReady();
|
|
1885
1941
|
if (!this.client || !this.session || !this.vm) {
|
|
1886
1942
|
throw new Error("kernel is not ready");
|
|
@@ -1888,12 +1944,12 @@ class NativeKernel {
|
|
|
1888
1944
|
// Install the dispatcher once. It routes every host_callback request the
|
|
1889
1945
|
// sidecar emits to the matching registered handler and replies with a
|
|
1890
1946
|
// host_callback_result frame.
|
|
1891
|
-
if (!this.
|
|
1892
|
-
this.client.setSidecarRequestHandler((request) => this.
|
|
1893
|
-
this.
|
|
1947
|
+
if (!this.bindingRequestHandlerInstalled) {
|
|
1948
|
+
this.client.setSidecarRequestHandler((request) => this.dispatchBindingRequest(request));
|
|
1949
|
+
this.bindingRequestHandlerInstalled = true;
|
|
1894
1950
|
}
|
|
1895
|
-
for (const [name, binding] of Object.entries(
|
|
1896
|
-
this.
|
|
1951
|
+
for (const [name, binding] of Object.entries(bindings)) {
|
|
1952
|
+
this.bindingHandlers.set(name, binding.handler);
|
|
1897
1953
|
const definition = {
|
|
1898
1954
|
description: binding.description,
|
|
1899
1955
|
inputSchema: binding.inputSchema,
|
|
@@ -1909,9 +1965,9 @@ class NativeKernel {
|
|
|
1909
1965
|
}
|
|
1910
1966
|
: {}),
|
|
1911
1967
|
};
|
|
1912
|
-
// Register each binding as its own single-callback
|
|
1968
|
+
// Register each binding as its own single-callback binding collection so the guest
|
|
1913
1969
|
// can invoke it directly by name (or by any caller-provided alias). The
|
|
1914
|
-
// sidecar exposes the
|
|
1970
|
+
// sidecar exposes the binding collection name as a guest command; the single
|
|
1915
1971
|
// callback carries the binding's schema and gates the `binding`
|
|
1916
1972
|
// permission.
|
|
1917
1973
|
await this.client.registerHostCallbacks(this.session, this.vm, {
|
|
@@ -1926,21 +1982,21 @@ class NativeKernel {
|
|
|
1926
1982
|
}
|
|
1927
1983
|
}
|
|
1928
1984
|
}
|
|
1929
|
-
async
|
|
1985
|
+
async dispatchBindingRequest(request) {
|
|
1930
1986
|
const { payload } = request;
|
|
1931
1987
|
if (payload.type !== "host_callback") {
|
|
1932
1988
|
throw new Error(`unsupported sidecar request for bindings: ${payload.type}`);
|
|
1933
1989
|
}
|
|
1934
|
-
// Callback keys arrive as `${
|
|
1935
|
-
// as the bare command name otherwise. The
|
|
1936
|
-
// the same here, so the registered
|
|
1990
|
+
// Callback keys arrive as `${collection}:${binding}` for collection invocations
|
|
1991
|
+
// and as the bare command name otherwise. The collection and binding name are
|
|
1992
|
+
// the same here, so the registered binding name is the segment after the last
|
|
1937
1993
|
// colon (or the whole key when no colon is present).
|
|
1938
1994
|
const callbackKey = payload.callback_key;
|
|
1939
|
-
const
|
|
1995
|
+
const bindingName = callbackKey.includes(":")
|
|
1940
1996
|
? callbackKey.slice(callbackKey.lastIndexOf(":") + 1)
|
|
1941
1997
|
: callbackKey;
|
|
1942
|
-
const handler = this.
|
|
1943
|
-
this.
|
|
1998
|
+
const handler = this.bindingHandlers.get(bindingName) ??
|
|
1999
|
+
this.bindingHandlers.get(callbackKey);
|
|
1944
2000
|
if (!handler) {
|
|
1945
2001
|
return {
|
|
1946
2002
|
type: "host_callback_result",
|
|
@@ -1996,6 +2052,10 @@ class NativeKernel {
|
|
|
1996
2052
|
await this.ensureReady();
|
|
1997
2053
|
return this.proxy.rename(oldPath, newPath);
|
|
1998
2054
|
}
|
|
2055
|
+
async pwrite(targetPath, offset, data) {
|
|
2056
|
+
await this.ensureReady();
|
|
2057
|
+
return this.proxy.vfs.pwrite(targetPath, offset, data);
|
|
2058
|
+
}
|
|
1999
2059
|
tryResolveMountedCommand(command) {
|
|
2000
2060
|
const normalized = normalizeCommandLookup(command);
|
|
2001
2061
|
for (const driver of this.mountedRuntimeDrivers) {
|
|
@@ -2062,15 +2122,19 @@ class NativeKernel {
|
|
|
2062
2122
|
cwd: REPO_ROOT,
|
|
2063
2123
|
command: ensureNativeSidecarBinary(),
|
|
2064
2124
|
args: [],
|
|
2065
|
-
|
|
2125
|
+
gracefulExitMs: 100,
|
|
2126
|
+
forceExitMs: 100,
|
|
2066
2127
|
}));
|
|
2067
2128
|
const session = await this.measureBoot("session_open", () => client.authenticateAndOpenSession());
|
|
2068
2129
|
const vm = await this.measureBoot("vm_create", () => client.createVm(session, {
|
|
2069
2130
|
runtime: "java_script",
|
|
2070
2131
|
config: {
|
|
2071
2132
|
env: createVmEnv,
|
|
2133
|
+
...(this.options.user ? { user: this.options.user } : {}),
|
|
2072
2134
|
rootFilesystem,
|
|
2073
|
-
...(bootstrapPermissions
|
|
2135
|
+
...(bootstrapPermissions
|
|
2136
|
+
? { permissions: bootstrapPermissions }
|
|
2137
|
+
: {}),
|
|
2074
2138
|
loopbackExemptPorts: this.loopbackExemptPorts,
|
|
2075
2139
|
...(this.options.jsRuntime
|
|
2076
2140
|
? { jsRuntime: this.options.jsRuntime }
|
package/dist/vm-config.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export type { AcpLimitsConfig } from "./generated/AcpLimitsConfig.js";
|
|
2
2
|
export type { CreateVmConfig } from "./generated/CreateVmConfig.js";
|
|
3
|
+
export type { VmUserConfig } from "./generated/VmUserConfig.js";
|
|
4
|
+
export type { VmUserAccountConfig } from "./generated/VmUserAccountConfig.js";
|
|
5
|
+
export type { VmGroupConfig } from "./generated/VmGroupConfig.js";
|
|
3
6
|
export type { FsPermissionRule } from "./generated/FsPermissionRule.js";
|
|
4
7
|
export type { FsPermissionRuleSet } from "./generated/FsPermissionRuleSet.js";
|
|
5
8
|
export type { FsPermissionScope } from "./generated/FsPermissionScope.js";
|
|
@@ -16,6 +19,7 @@ export type { PatternPermissionScope } from "./generated/PatternPermissionScope.
|
|
|
16
19
|
export type { PermissionMode } from "./generated/PermissionMode.js";
|
|
17
20
|
export type { PermissionsPolicy } from "./generated/PermissionsPolicy.js";
|
|
18
21
|
export type { PluginLimitsConfig } from "./generated/PluginLimitsConfig.js";
|
|
22
|
+
export type { ProcessLimitsConfig } from "./generated/ProcessLimitsConfig.js";
|
|
19
23
|
export type { PythonLimitsConfig } from "./generated/PythonLimitsConfig.js";
|
|
20
24
|
export type { ResourceLimitsConfig } from "./generated/ResourceLimitsConfig.js";
|
|
21
25
|
export type { RootFilesystemConfig } from "./generated/RootFilesystemConfig.js";
|
|
@@ -24,7 +28,7 @@ export type { RootFilesystemEntryEncoding } from "./generated/RootFilesystemEntr
|
|
|
24
28
|
export type { RootFilesystemEntryKind } from "./generated/RootFilesystemEntryKind.js";
|
|
25
29
|
export type { RootFilesystemLowerDescriptor } from "./generated/RootFilesystemLowerDescriptor.js";
|
|
26
30
|
export type { RootFilesystemMode } from "./generated/RootFilesystemMode.js";
|
|
27
|
-
export type {
|
|
31
|
+
export type { BindingLimitsConfig } from "./generated/BindingLimitsConfig.js";
|
|
28
32
|
export type { VmDnsConfig } from "./generated/VmDnsConfig.js";
|
|
29
33
|
export type { VmLimitsConfig } from "./generated/VmLimitsConfig.js";
|
|
30
34
|
export type { VmListenPolicyConfig } from "./generated/VmListenPolicyConfig.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivet-dev/agentos-runtime-core",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-fix-main-wasm-ownership.150c49a",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -189,10 +189,12 @@
|
|
|
189
189
|
"check-types": "pnpm run build:protocol && pnpm run build:vm-config && tsc --noEmit",
|
|
190
190
|
"build": "pnpm run build:protocol && pnpm run build:vm-config && tsc && pnpm run copy-commands",
|
|
191
191
|
"prepack": "node scripts/copy-wasm-commands.mjs --require",
|
|
192
|
-
"
|
|
192
|
+
"pretest": "cargo build -q -p agentos-native-sidecar",
|
|
193
|
+
"test": "vitest run",
|
|
194
|
+
"test:ecosystem": "AGENTOS_ECOSYSTEM_E2E=1 vitest run tests/integration/e2e-project-matrix.test.ts -t 'required Node ecosystem reactor matrix' --reporter=verbose"
|
|
193
195
|
},
|
|
194
196
|
"dependencies": {
|
|
195
|
-
"@rivet-dev/agentos-runtime-sidecar": "0.0.0-
|
|
197
|
+
"@rivet-dev/agentos-runtime-sidecar": "0.0.0-fix-main-wasm-ownership.150c49a",
|
|
196
198
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
197
199
|
"zod": "^4.1.11"
|
|
198
200
|
},
|
package/commands/codex
DELETED
|
Binary file
|
package/commands/codex-exec
DELETED
|
Binary file
|
package/commands/http_get
DELETED
|
Binary file
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type ToolLimitsConfig = {
|
|
2
|
-
defaultToolTimeoutMs?: number;
|
|
3
|
-
maxToolTimeoutMs?: number;
|
|
4
|
-
maxRegisteredToolkits?: number;
|
|
5
|
-
maxRegisteredToolsPerVm?: number;
|
|
6
|
-
maxToolsPerToolkit?: number;
|
|
7
|
-
maxToolSchemaBytes?: number;
|
|
8
|
-
maxToolExamplesPerTool?: number;
|
|
9
|
-
maxToolExampleInputBytes?: number;
|
|
10
|
-
};
|
|
File without changes
|