@rivet-dev/agentos-runtime-core 0.0.0-fix-main-wasm-ownership.8ca391b → 0.0.0-fix-core-spawn-keep-stdin-open.242e11c
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 +2 -2
- package/commands/[ +0 -0
- package/commands/_stubs +0 -0
- package/commands/awk +0 -0
- package/commands/bash +0 -0
- package/commands/chcon +0 -0
- package/commands/chroot +0 -0
- package/commands/column +0 -0
- package/commands/diff +0 -0
- package/commands/du +0 -0
- package/commands/egrep +0 -0
- package/commands/env +0 -0
- package/commands/expr +0 -0
- package/commands/fgrep +0 -0
- package/commands/file +0 -0
- package/commands/groups +0 -0
- package/commands/gunzip +0 -0
- package/commands/gzip +0 -0
- package/commands/hostid +0 -0
- package/commands/http-test +0 -0
- package/commands/install +0 -0
- package/commands/jq +0 -0
- package/commands/nice +0 -0
- package/commands/nohup +0 -0
- package/commands/pinky +0 -0
- package/commands/rev +0 -0
- package/commands/rg +0 -0
- package/commands/runcon +0 -0
- package/commands/sh +0 -0
- package/commands/sleep +0 -0
- package/commands/spawn-test-host +0 -0
- package/commands/sqlite3 +0 -0
- package/commands/ssh +0 -0
- package/commands/stdbuf +0 -0
- package/commands/strings +0 -0
- package/commands/stty +0 -0
- package/commands/sync +0 -0
- package/commands/tar +0 -0
- package/commands/test +0 -0
- package/commands/timeout +0 -0
- package/commands/tree +0 -0
- package/commands/tty +0 -0
- package/commands/unzip +0 -0
- package/commands/uptime +0 -0
- package/commands/users +0 -0
- package/commands/wget +0 -0
- package/commands/which +0 -0
- package/commands/who +0 -0
- package/commands/whoami +0 -0
- package/commands/yq +0 -0
- package/commands/zcat +0 -0
- package/commands/zip +0 -0
- package/dist/binary.js +4 -3
- package/dist/event-buffer.d.ts +14 -0
- package/dist/event-buffer.js +30 -1
- package/dist/frame-stream.d.ts +1 -0
- package/dist/frame-stream.js +8 -0
- package/dist/generated/ExecutionLimitsConfig.d.ts +5 -0
- package/dist/generated/ExecutionLimitsConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +2 -0
- package/dist/generated/VmSqliteDescriptor.d.ts +0 -1
- package/dist/generated-protocol.d.ts +550 -0
- package/dist/generated-protocol.js +1446 -122
- package/dist/kernel-proxy.js +1 -1
- package/dist/native-client.js +22 -9
- package/dist/node-runtime.js +5 -5
- package/dist/process.d.ts +4 -2
- package/dist/process.js +11 -3
- package/dist/protocol-client.d.ts +2 -0
- package/dist/protocol-client.js +29 -0
- package/dist/request-payloads.d.ts +96 -0
- package/dist/request-payloads.js +66 -0
- package/dist/response-payloads.d.ts +27 -0
- package/dist/response-payloads.js +18 -0
- package/dist/sidecar-process.d.ts +8 -1
- package/dist/sidecar-process.js +27 -2
- package/dist/test-runtime.d.ts +7 -1
- package/dist/test-runtime.js +97 -15
- package/package.json +11 -8
package/dist/test-runtime.js
CHANGED
|
@@ -5,9 +5,9 @@ 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 { NativeSidecarKernelProxy, SidecarProcess, serializeMountConfigForSidecar, } from "./kernel-proxy.js";
|
|
9
8
|
import { resolvePublishedSidecarBinary } from "./binary.js";
|
|
10
9
|
import { findCargoBinary, resolveCargoBinary } from "./cargo.js";
|
|
10
|
+
import { NativeSidecarKernelProxy, SidecarProcess, serializeMountConfigForSidecar, } from "./kernel-proxy.js";
|
|
11
11
|
export const AF_INET = 2;
|
|
12
12
|
export const AF_UNIX = 1;
|
|
13
13
|
export const SOCK_STREAM = 1;
|
|
@@ -1161,7 +1161,7 @@ class WasmVmRuntimeDescriptor {
|
|
|
1161
1161
|
if (dirOffset === undefined) {
|
|
1162
1162
|
continue;
|
|
1163
1163
|
}
|
|
1164
|
-
guestPaths.set(name, `/
|
|
1164
|
+
guestPaths.set(name, `/__agentos/commands/${startIndex + dirOffset}/${name}`);
|
|
1165
1165
|
}
|
|
1166
1166
|
return guestPaths;
|
|
1167
1167
|
}
|
|
@@ -1220,7 +1220,8 @@ function sidecarBinaryNeedsBuild() {
|
|
|
1220
1220
|
function ensureNativeSidecarBinary() {
|
|
1221
1221
|
// A published install has no in-repo Cargo workspace to build from: resolve
|
|
1222
1222
|
// the prebuilt platform binary (or an explicit sidecar override).
|
|
1223
|
-
if (process.env.
|
|
1223
|
+
if (process.env.AGENTOS_NATIVE_SIDECAR_BIN ||
|
|
1224
|
+
process.env.AGENTOS_SIDECAR_BIN ||
|
|
1224
1225
|
!fsSync.existsSync(path.join(REPO_ROOT, "Cargo.toml"))) {
|
|
1225
1226
|
return resolvePublishedSidecarBinary();
|
|
1226
1227
|
}
|
|
@@ -1262,9 +1263,13 @@ function createBootstrapEntries(commandNames) {
|
|
|
1262
1263
|
...KERNEL_POSIX_BOOTSTRAP_DIRS.map((entryPath) => ({
|
|
1263
1264
|
path: entryPath,
|
|
1264
1265
|
kind: "directory",
|
|
1265
|
-
mode: entryPath === "/tmp" || entryPath === "/var/tmp"
|
|
1266
|
-
|
|
1267
|
-
|
|
1266
|
+
mode: entryPath === "/tmp" || entryPath === "/var/tmp"
|
|
1267
|
+
? 0o1777
|
|
1268
|
+
: entryPath === "/home/agentos"
|
|
1269
|
+
? 0o2755
|
|
1270
|
+
: 0o755,
|
|
1271
|
+
uid: entryPath === "/home/agentos" || entryPath === "/workspace" ? 1000 : 0,
|
|
1272
|
+
gid: entryPath === "/home/agentos" || entryPath === "/workspace" ? 1000 : 0,
|
|
1268
1273
|
})),
|
|
1269
1274
|
{
|
|
1270
1275
|
path: "/usr/bin/env",
|
|
@@ -1413,17 +1418,88 @@ function planNodeFilesystemPassthroughMounts(filesystem, existingMounts) {
|
|
|
1413
1418
|
fs: new NodeFileSystem({ root: hostPath }),
|
|
1414
1419
|
readOnly: true,
|
|
1415
1420
|
});
|
|
1421
|
+
if (directoryName === "node_modules") {
|
|
1422
|
+
appendNodeModulesSymlinkTargetMounts(mounts, existingGuestPaths, guestPath, hostPath);
|
|
1423
|
+
}
|
|
1416
1424
|
}
|
|
1417
1425
|
return {
|
|
1418
1426
|
mounts,
|
|
1419
1427
|
passthroughDirectories,
|
|
1420
1428
|
};
|
|
1421
1429
|
}
|
|
1430
|
+
function appendNodeModulesSymlinkTargetMounts(mounts, existingGuestPaths, guestRoot, hostRoot) {
|
|
1431
|
+
let canonicalHostRoot;
|
|
1432
|
+
try {
|
|
1433
|
+
canonicalHostRoot = fsSync.realpathSync(hostRoot);
|
|
1434
|
+
}
|
|
1435
|
+
catch {
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1438
|
+
const appendTarget = (guestPath, symlinkPath) => {
|
|
1439
|
+
if (existingGuestPaths.has(guestPath))
|
|
1440
|
+
return;
|
|
1441
|
+
try {
|
|
1442
|
+
const target = fsSync.realpathSync(symlinkPath);
|
|
1443
|
+
if (!fsSync.statSync(target).isDirectory())
|
|
1444
|
+
return;
|
|
1445
|
+
const relativeTarget = path.relative(canonicalHostRoot, target);
|
|
1446
|
+
if (relativeTarget === "" ||
|
|
1447
|
+
(!relativeTarget.startsWith(`..${path.sep}`) &&
|
|
1448
|
+
relativeTarget !== ".." &&
|
|
1449
|
+
!path.isAbsolute(relativeTarget))) {
|
|
1450
|
+
// pnpm and similar stores deliberately use links that remain inside
|
|
1451
|
+
// node_modules. Keeping those on the root mount preserves the realpath
|
|
1452
|
+
// ancestry needed to resolve their nested dependency links.
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
mounts.push({
|
|
1456
|
+
path: guestPath,
|
|
1457
|
+
fs: new NodeFileSystem({ root: target }),
|
|
1458
|
+
readOnly: true,
|
|
1459
|
+
});
|
|
1460
|
+
existingGuestPaths.add(guestPath);
|
|
1461
|
+
}
|
|
1462
|
+
catch {
|
|
1463
|
+
// Broken or concurrently-removed links remain unavailable, matching Node.
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
let entries;
|
|
1467
|
+
try {
|
|
1468
|
+
entries = fsSync.readdirSync(hostRoot, { withFileTypes: true });
|
|
1469
|
+
}
|
|
1470
|
+
catch {
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
for (const entry of entries) {
|
|
1474
|
+
if (entry.name.startsWith("."))
|
|
1475
|
+
continue;
|
|
1476
|
+
const entryPath = path.join(hostRoot, entry.name);
|
|
1477
|
+
if (entry.isSymbolicLink()) {
|
|
1478
|
+
appendTarget(`${guestRoot}/${entry.name}`, entryPath);
|
|
1479
|
+
continue;
|
|
1480
|
+
}
|
|
1481
|
+
if (!entry.isDirectory() || !entry.name.startsWith("@"))
|
|
1482
|
+
continue;
|
|
1483
|
+
let scopedEntries;
|
|
1484
|
+
try {
|
|
1485
|
+
scopedEntries = fsSync.readdirSync(entryPath, { withFileTypes: true });
|
|
1486
|
+
}
|
|
1487
|
+
catch {
|
|
1488
|
+
continue;
|
|
1489
|
+
}
|
|
1490
|
+
for (const scopedEntry of scopedEntries) {
|
|
1491
|
+
if (scopedEntry.name.startsWith(".") || !scopedEntry.isSymbolicLink()) {
|
|
1492
|
+
continue;
|
|
1493
|
+
}
|
|
1494
|
+
appendTarget(`${guestRoot}/${entry.name}/${scopedEntry.name}`, path.join(entryPath, scopedEntry.name));
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1422
1498
|
function collectGuestCommandPaths(commandDirs, startIndex = 0) {
|
|
1423
1499
|
const guestPaths = new Map();
|
|
1424
1500
|
for (const entry of discoverWasmCommandEntries(commandDirs)) {
|
|
1425
1501
|
if (!guestPaths.has(entry.name)) {
|
|
1426
|
-
guestPaths.set(entry.name, `/
|
|
1502
|
+
guestPaths.set(entry.name, `/__agentos/commands/${startIndex + entry.dirOffset}/${entry.name}`);
|
|
1427
1503
|
}
|
|
1428
1504
|
}
|
|
1429
1505
|
return guestPaths;
|
|
@@ -1434,10 +1510,7 @@ async function ensureCommandStubs(proxy, commands) {
|
|
|
1434
1510
|
// `/bin` supports PATH-based test commands. `/opt/agentos/bin` mirrors
|
|
1435
1511
|
// the package projection used by production VMs and is required by
|
|
1436
1512
|
// 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
|
-
]) {
|
|
1513
|
+
for (const stubPath of [`/bin/${command}`, `/opt/agentos/bin/${command}`]) {
|
|
1441
1514
|
await rootView.writeFile(stubPath, KERNEL_COMMAND_STUB);
|
|
1442
1515
|
await rootView.chmod(stubPath, 0o755);
|
|
1443
1516
|
}
|
|
@@ -1604,9 +1677,15 @@ async function syncLiveFilesystemToBoundMethods(live, methods, paths, maxBytes)
|
|
|
1604
1677
|
}
|
|
1605
1678
|
async function snapshotLiveFilesystemPath(live, targetPath, snapshot, usage, maxBytes, knownEntry) {
|
|
1606
1679
|
const stat = knownEntry ??
|
|
1607
|
-
(targetPath === "/"
|
|
1680
|
+
(targetPath === "/"
|
|
1681
|
+
? await live.stat(targetPath)
|
|
1682
|
+
: await live.lstat(targetPath));
|
|
1608
1683
|
if (stat.isSymbolicLink) {
|
|
1609
|
-
snapshot.push({
|
|
1684
|
+
snapshot.push({
|
|
1685
|
+
kind: "symlink",
|
|
1686
|
+
path: targetPath,
|
|
1687
|
+
target: await live.readlink(targetPath),
|
|
1688
|
+
});
|
|
1610
1689
|
return;
|
|
1611
1690
|
}
|
|
1612
1691
|
if (stat.isDirectory) {
|
|
@@ -1638,7 +1717,9 @@ async function snapshotLiveFilesystemPath(live, targetPath, snapshot, usage, max
|
|
|
1638
1717
|
}
|
|
1639
1718
|
async function applyLiveFilesystemSnapshotEntry(methods, entry) {
|
|
1640
1719
|
if (entry.kind === "directory") {
|
|
1641
|
-
await callBoundFilesystemMethod(methods, "mkdir", entry.path, {
|
|
1720
|
+
await callBoundFilesystemMethod(methods, "mkdir", entry.path, {
|
|
1721
|
+
recursive: true,
|
|
1722
|
+
});
|
|
1642
1723
|
return;
|
|
1643
1724
|
}
|
|
1644
1725
|
await ensureBoundParentDirectory(methods, entry.path);
|
|
@@ -1783,7 +1864,7 @@ class NativeKernel {
|
|
|
1783
1864
|
collectGuestCommandPaths(commandDirs, startIndex);
|
|
1784
1865
|
const allCommandDirs = [...this.mountedCommandDirs, ...commandDirs];
|
|
1785
1866
|
const sidecarMounts = allCommandDirs.map((commandDir, index) => serializeMountConfigForSidecar({
|
|
1786
|
-
path: `/
|
|
1867
|
+
path: `/__agentos/commands/${index}`,
|
|
1787
1868
|
readOnly: true,
|
|
1788
1869
|
plugin: {
|
|
1789
1870
|
id: "host_dir",
|
|
@@ -2136,6 +2217,7 @@ class NativeKernel {
|
|
|
2136
2217
|
? { permissions: bootstrapPermissions }
|
|
2137
2218
|
: {}),
|
|
2138
2219
|
loopbackExemptPorts: this.loopbackExemptPorts,
|
|
2220
|
+
...(this.options.limits ? { limits: this.options.limits } : {}),
|
|
2139
2221
|
...(this.options.jsRuntime
|
|
2140
2222
|
? { jsRuntime: this.options.jsRuntime }
|
|
2141
2223
|
: {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivet-dev/agentos-runtime-core",
|
|
3
|
-
"version": "0.0.0-fix-
|
|
3
|
+
"version": "0.0.0-fix-core-spawn-keep-stdin-open.242e11c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -184,17 +184,20 @@
|
|
|
184
184
|
},
|
|
185
185
|
"scripts": {
|
|
186
186
|
"build:protocol": "pnpm --dir ../build-tools build:protocol",
|
|
187
|
-
"
|
|
187
|
+
"generate:vm-config": "cargo test -p agentos-vm-config --quiet",
|
|
188
188
|
"copy-commands": "node scripts/copy-wasm-commands.mjs",
|
|
189
|
-
"check-types": "pnpm run build:protocol &&
|
|
190
|
-
"build": "pnpm run build:protocol &&
|
|
189
|
+
"check-types": "pnpm run build:protocol && tsc --noEmit",
|
|
190
|
+
"build": "pnpm run build:protocol && tsc && pnpm run copy-commands",
|
|
191
191
|
"prepack": "node scripts/copy-wasm-commands.mjs --require",
|
|
192
|
-
"
|
|
193
|
-
"test": "vitest run",
|
|
194
|
-
"test:
|
|
192
|
+
"test": "vitest run --exclude '**/*.nightly.test.ts'",
|
|
193
|
+
"test:pr": "vitest run --exclude '**/*.nightly.test.ts' --fileParallelism=false",
|
|
194
|
+
"test:nightly": "vitest run tests/integration/*.nightly.test.ts --passWithNoTests",
|
|
195
|
+
"test:ecosystem": "AGENTOS_ECOSYSTEM_E2E=1 vitest run tests/integration/e2e-project-matrix.nightly.test.ts -t 'required Node ecosystem reactor matrix' --reporter=verbose",
|
|
196
|
+
"test:ecosystem:full": "AGENTOS_ECOSYSTEM_FULL_E2E=1 vitest run tests/integration/e2e-project-matrix.nightly.test.ts -t 'full Node ecosystem matrix through kernel' --reporter=verbose",
|
|
197
|
+
"test:npm-workflows": "AGENTOS_NPM_WORKFLOWS_E2E=1 vitest run tests/integration/e2e-npm-*.nightly.test.ts tests/integration/e2e-npx-and-pipes.nightly.test.ts tests/integration/e2e-concurrently.nightly.test.ts tests/integration/e2e-nextjs-build.nightly.test.ts --reporter=verbose"
|
|
195
198
|
},
|
|
196
199
|
"dependencies": {
|
|
197
|
-
"@rivet-dev/agentos-runtime-sidecar": "0.0.0-fix-
|
|
200
|
+
"@rivet-dev/agentos-runtime-sidecar": "0.0.0-fix-core-spawn-keep-stdin-open.242e11c",
|
|
198
201
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
199
202
|
"zod": "^4.1.11"
|
|
200
203
|
},
|