@rivet-dev/agentos-runtime-core 0.0.0-glibc.928bc3a → 0.0.0-main.29b0797

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.
Files changed (240) hide show
  1. package/README.md +1 -1
  2. package/commands/[ +0 -0
  3. package/commands/_stubs +0 -0
  4. package/commands/acl_tools +0 -0
  5. package/commands/arch +0 -0
  6. package/commands/attr +0 -0
  7. package/commands/awk +0 -0
  8. package/commands/b2sum +0 -0
  9. package/commands/base32 +0 -0
  10. package/commands/base64 +0 -0
  11. package/commands/basename +0 -0
  12. package/commands/basenc +0 -0
  13. package/commands/bash +0 -0
  14. package/commands/bc +0 -0
  15. package/commands/cat +0 -0
  16. package/commands/chacl +0 -0
  17. package/commands/chcon +0 -0
  18. package/commands/chgrp +0 -0
  19. package/commands/chmod +0 -0
  20. package/commands/chown +0 -0
  21. package/commands/chroot +0 -0
  22. package/commands/cksum +0 -0
  23. package/commands/cmp +0 -0
  24. package/commands/column +0 -0
  25. package/commands/comm +0 -0
  26. package/commands/cp +0 -0
  27. package/commands/curl +0 -0
  28. package/commands/cut +0 -0
  29. package/commands/date +0 -0
  30. package/commands/dd +0 -0
  31. package/commands/df +0 -0
  32. package/commands/diff +0 -0
  33. package/commands/dir +0 -0
  34. package/commands/dircolors +0 -0
  35. package/commands/dirname +0 -0
  36. package/commands/du +0 -0
  37. package/commands/echo +0 -0
  38. package/commands/egrep +0 -0
  39. package/commands/env +0 -0
  40. package/commands/envsubst +0 -0
  41. package/commands/expand +0 -0
  42. package/commands/expr +0 -0
  43. package/commands/factor +0 -0
  44. package/commands/false +0 -0
  45. package/commands/fd +0 -0
  46. package/commands/fgrep +0 -0
  47. package/commands/file +0 -0
  48. package/commands/find +0 -0
  49. package/commands/findmnt +0 -0
  50. package/commands/fmt +0 -0
  51. package/commands/fold +0 -0
  52. package/commands/getent +0 -0
  53. package/commands/getfacl +0 -0
  54. package/commands/getfattr +0 -0
  55. package/commands/git +0 -0
  56. package/commands/git-receive-pack +0 -0
  57. package/commands/git-remote-http +0 -0
  58. package/commands/git-remote-https +0 -0
  59. package/commands/git-upload-archive +0 -0
  60. package/commands/git-upload-pack +0 -0
  61. package/commands/grep +0 -0
  62. package/commands/groups +0 -0
  63. package/commands/gunzip +0 -0
  64. package/commands/gzip +0 -0
  65. package/commands/head +0 -0
  66. package/commands/hostid +0 -0
  67. package/commands/hostname +0 -0
  68. package/commands/http-test +0 -0
  69. package/commands/id +0 -0
  70. package/commands/install +0 -0
  71. package/commands/join +0 -0
  72. package/commands/jq +0 -0
  73. package/commands/kill +0 -0
  74. package/commands/link +0 -0
  75. package/commands/ln +0 -0
  76. package/commands/logname +0 -0
  77. package/commands/ls +0 -0
  78. package/commands/md5sum +0 -0
  79. package/commands/mkdir +0 -0
  80. package/commands/mkfifo +0 -0
  81. package/commands/mknod +0 -0
  82. package/commands/mktemp +0 -0
  83. package/commands/more +0 -0
  84. package/commands/mount +0 -0
  85. package/commands/mv +0 -0
  86. package/commands/nice +0 -0
  87. package/commands/nl +0 -0
  88. package/commands/nohup +0 -0
  89. package/commands/nproc +0 -0
  90. package/commands/numfmt +0 -0
  91. package/commands/od +0 -0
  92. package/commands/paste +0 -0
  93. package/commands/pathchk +0 -0
  94. package/commands/pinky +0 -0
  95. package/commands/printenv +0 -0
  96. package/commands/printf +0 -0
  97. package/commands/ptx +0 -0
  98. package/commands/pwd +0 -0
  99. package/commands/readlink +0 -0
  100. package/commands/realpath +0 -0
  101. package/commands/rev +0 -0
  102. package/commands/rg +0 -0
  103. package/commands/rm +0 -0
  104. package/commands/rmdir +0 -0
  105. package/commands/runas +0 -0
  106. package/commands/runcon +0 -0
  107. package/commands/sed +0 -0
  108. package/commands/seq +0 -0
  109. package/commands/setfacl +0 -0
  110. package/commands/setfattr +0 -0
  111. package/commands/sh +0 -0
  112. package/commands/sha1sum +0 -0
  113. package/commands/sha224sum +0 -0
  114. package/commands/sha256sum +0 -0
  115. package/commands/sha384sum +0 -0
  116. package/commands/sha512sum +0 -0
  117. package/commands/shred +0 -0
  118. package/commands/shuf +0 -0
  119. package/commands/sleep +0 -0
  120. package/commands/sort +0 -0
  121. package/commands/spawn-test-host +0 -0
  122. package/commands/split +0 -0
  123. package/commands/sqlite3 +0 -0
  124. package/commands/ssh +0 -0
  125. package/commands/ssh-keysign +0 -0
  126. package/commands/ssh-sk-helper +0 -0
  127. package/commands/stat +0 -0
  128. package/commands/stdbuf +0 -0
  129. package/commands/strings +0 -0
  130. package/commands/stty +0 -0
  131. package/commands/su +0 -0
  132. package/commands/sum +0 -0
  133. package/commands/sync +0 -0
  134. package/commands/tac +0 -0
  135. package/commands/tail +0 -0
  136. package/commands/tar +0 -0
  137. package/commands/tee +0 -0
  138. package/commands/test +0 -0
  139. package/commands/timeout +0 -0
  140. package/commands/touch +0 -0
  141. package/commands/tr +0 -0
  142. package/commands/tree +0 -0
  143. package/commands/true +0 -0
  144. package/commands/truncate +0 -0
  145. package/commands/tsort +0 -0
  146. package/commands/tty +0 -0
  147. package/commands/uname +0 -0
  148. package/commands/unexpand +0 -0
  149. package/commands/uniq +0 -0
  150. package/commands/unlink +0 -0
  151. package/commands/unzip +0 -0
  152. package/commands/uptime +0 -0
  153. package/commands/users +0 -0
  154. package/commands/vdir +0 -0
  155. package/commands/wc +0 -0
  156. package/commands/wget +0 -0
  157. package/commands/which +0 -0
  158. package/commands/who +0 -0
  159. package/commands/whoami +0 -0
  160. package/commands/xargs +0 -0
  161. package/commands/xattr_tools +0 -0
  162. package/commands/xfs_io +0 -0
  163. package/commands/xu +0 -0
  164. package/commands/yes +0 -0
  165. package/commands/yq +0 -0
  166. package/commands/zcat +0 -0
  167. package/commands/zip +0 -0
  168. package/dist/binary.js +4 -3
  169. package/dist/correlation.d.ts +1 -4
  170. package/dist/correlation.js +7 -10
  171. package/dist/descriptors.d.ts +2 -12
  172. package/dist/descriptors.js +10 -6
  173. package/dist/frame-rpc.d.ts +9 -4
  174. package/dist/frame-rpc.js +19 -2
  175. package/dist/frame-stream.d.ts +33 -0
  176. package/dist/frame-stream.js +113 -0
  177. package/dist/generated/AcpLimitsConfig.d.ts +16 -0
  178. package/dist/generated/BindingLimitsConfig.d.ts +10 -0
  179. package/dist/generated/CreateVmConfig.d.ts +4 -0
  180. package/dist/generated/Http2LimitsConfig.d.ts +12 -0
  181. package/dist/generated/Http2LimitsConfig.js +2 -0
  182. package/dist/generated/JsRuntimeLimitsConfig.d.ts +1 -0
  183. package/dist/generated/MountPluginDescriptor.d.ts +1 -1
  184. package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
  185. package/dist/generated/ProcessLimitsConfig.js +2 -0
  186. package/dist/generated/ReactorLimitsConfig.d.ts +23 -0
  187. package/dist/generated/ReactorLimitsConfig.js +2 -0
  188. package/dist/generated/SqliteLimitsConfig.d.ts +3 -0
  189. package/dist/generated/SqliteLimitsConfig.js +2 -0
  190. package/dist/generated/TlsLimitsConfig.d.ts +3 -0
  191. package/dist/generated/TlsLimitsConfig.js +2 -0
  192. package/dist/generated/UdpLimitsConfig.d.ts +4 -0
  193. package/dist/generated/UdpLimitsConfig.js +2 -0
  194. package/dist/generated/VmGroupConfig.d.ts +5 -0
  195. package/dist/generated/VmGroupConfig.js +2 -0
  196. package/dist/generated/VmLimitsConfig.d.ts +14 -2
  197. package/dist/generated/VmSqliteDescriptor.d.ts +11 -0
  198. package/dist/generated/VmSqliteDescriptor.js +2 -0
  199. package/dist/generated/VmUserAccountConfig.d.ts +9 -0
  200. package/dist/generated/VmUserAccountConfig.js +2 -0
  201. package/dist/generated/VmUserConfig.d.ts +19 -0
  202. package/dist/generated/VmUserConfig.js +1 -0
  203. package/dist/generated/WasmLimitsConfig.d.ts +1 -0
  204. package/dist/generated-protocol.d.ts +60 -2
  205. package/dist/generated-protocol.js +166 -31
  206. package/dist/kernel-proxy.d.ts +5 -1
  207. package/dist/kernel-proxy.js +82 -40
  208. package/dist/native-client.d.ts +9 -5
  209. package/dist/native-client.js +41 -9
  210. package/dist/node-runtime-options-schema.d.ts +1 -1
  211. package/dist/node-runtime-options-schema.js +43 -1
  212. package/dist/node-runtime.d.ts +12 -3
  213. package/dist/node-runtime.js +8 -7
  214. package/dist/process.d.ts +3 -1
  215. package/dist/process.js +27 -8
  216. package/dist/protocol-client.d.ts +26 -4
  217. package/dist/protocol-client.js +164 -12
  218. package/dist/protocol-frames.d.ts +14 -3
  219. package/dist/protocol-frames.js +26 -1
  220. package/dist/protocol-schema.d.ts +1 -1
  221. package/dist/protocol-schema.js +1 -1
  222. package/dist/request-payloads.d.ts +4 -1
  223. package/dist/request-payloads.js +7 -2
  224. package/dist/response-payloads.d.ts +23 -2
  225. package/dist/response-payloads.js +34 -2
  226. package/dist/sidecar-errors.d.ts +37 -0
  227. package/dist/sidecar-errors.js +27 -0
  228. package/dist/sidecar-process.d.ts +20 -6
  229. package/dist/sidecar-process.js +79 -15
  230. package/dist/state.d.ts +6 -6
  231. package/dist/state.js +10 -11
  232. package/dist/test-runtime.d.ts +21 -6
  233. package/dist/test-runtime.js +130 -65
  234. package/dist/vm-config.d.ts +5 -1
  235. package/package.json +9 -6
  236. package/commands/codex +0 -0
  237. package/commands/codex-exec +0 -0
  238. package/commands/http_get +0 -0
  239. package/dist/generated/ToolLimitsConfig.d.ts +0 -10
  240. /package/dist/generated/{ToolLimitsConfig.js → BindingLimitsConfig.js} +0 -0
@@ -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 { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, NativeSidecarKernelProxy, SidecarProcess, serializeMountConfigForSidecar, } from "./kernel-proxy.js";
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 = this.resolveEntry(targetPath);
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
- await fs.chown(this.normalizeTarget(targetPath), uid, gid);
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), "r+");
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
  }
@@ -1200,7 +1220,7 @@ function sidecarBinaryNeedsBuild() {
1200
1220
  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
- if (process.env.AGENTOS_SIDECAR_BIN ||
1223
+ if (process.env.AGENTOS_NATIVE_SIDECAR_BIN ||
1204
1224
  process.env.AGENTOS_SIDECAR_BIN ||
1205
1225
  !fsSync.existsSync(path.join(REPO_ROOT, "Cargo.toml"))) {
1206
1226
  return resolvePublishedSidecarBinary();
@@ -1243,7 +1263,7 @@ function createBootstrapEntries(commandNames) {
1243
1263
  ...KERNEL_POSIX_BOOTSTRAP_DIRS.map((entryPath) => ({
1244
1264
  path: entryPath,
1245
1265
  kind: "directory",
1246
- mode: 0o755,
1266
+ mode: entryPath === "/tmp" || entryPath === "/var/tmp" ? 0o1777 : 0o755,
1247
1267
  uid: 0,
1248
1268
  gid: 0,
1249
1269
  })),
@@ -1412,9 +1432,16 @@ function collectGuestCommandPaths(commandDirs, startIndex = 0) {
1412
1432
  async function ensureCommandStubs(proxy, commands) {
1413
1433
  const rootView = proxy.createRootView();
1414
1434
  for (const command of commands) {
1415
- const stubPath = `/bin/${command}`;
1416
- await rootView.writeFile(stubPath, KERNEL_COMMAND_STUB);
1417
- await rootView.chmod(stubPath, 0o755);
1435
+ // `/bin` supports PATH-based test commands. `/opt/agentos/bin` mirrors
1436
+ // the package projection used by production VMs and is required by
1437
+ // upstream tools that exec private helpers via an absolute libexec path.
1438
+ for (const stubPath of [
1439
+ `/bin/${command}`,
1440
+ `/opt/agentos/bin/${command}`,
1441
+ ]) {
1442
+ await rootView.writeFile(stubPath, KERNEL_COMMAND_STUB);
1443
+ await rootView.chmod(stubPath, 0o755);
1444
+ }
1418
1445
  }
1419
1446
  }
1420
1447
  class DeferredFileSystem {
@@ -1483,8 +1510,8 @@ class DeferredFileSystem {
1483
1510
  chmod(path, mode) {
1484
1511
  return this.filesystem().chmod(path, mode);
1485
1512
  }
1486
- chown(path, uid, gid) {
1487
- return this.filesystem().chown(path, uid, gid);
1513
+ chown(path, uid, gid, options) {
1514
+ return this.filesystem().chown(path, uid, gid, options);
1488
1515
  }
1489
1516
  utimes(path, atime, mtime) {
1490
1517
  return this.filesystem().utimes(path, atime, mtime);
@@ -1524,7 +1551,10 @@ const VIRTUAL_FILESYSTEM_METHOD_NAMES = [
1524
1551
  "pread",
1525
1552
  "pwrite",
1526
1553
  ];
1527
- const LIVE_FILESYSTEM_SYNC_CHUNK_SIZE = 512 * 1024;
1554
+ const DEFAULT_LIVE_FILESYSTEM_SYNC_MAX_BYTES = 64 * 1024 * 1024;
1555
+ class LiveFilesystemSyncLimitError extends Error {
1556
+ code = "ERR_AGENTOS_LIVE_FILESYSTEM_SYNC_LIMIT";
1557
+ }
1528
1558
  function topLevelSyncRoot(targetPath) {
1529
1559
  const normalized = normalizePath(targetPath);
1530
1560
  const [first] = normalized.split("/").filter(Boolean);
@@ -1552,48 +1582,75 @@ async function ensureBoundParentDirectory(methods, targetPath) {
1552
1582
  if (parent === targetPath) {
1553
1583
  return;
1554
1584
  }
1555
- await callBoundFilesystemMethod(methods, "mkdir", parent, { recursive: true });
1585
+ await callBoundFilesystemMethod(methods, "mkdir", parent, {
1586
+ recursive: true,
1587
+ });
1556
1588
  }
1557
- async function syncLiveFilesystemToBoundMethods(live, methods, paths) {
1589
+ async function syncLiveFilesystemToBoundMethods(live, methods, paths, maxBytes) {
1590
+ const snapshot = [];
1591
+ const usage = { bytes: 0 };
1558
1592
  for (const targetPath of [...new Set(paths.map(normalizePath))].sort((left, right) => left.localeCompare(right))) {
1559
1593
  if (!(await live.exists(targetPath).catch(() => false))) {
1560
1594
  continue;
1561
1595
  }
1562
- await syncLiveFilesystemPathToBoundMethods(live, methods, targetPath);
1596
+ await snapshotLiveFilesystemPath(live, targetPath, snapshot, usage, maxBytes);
1597
+ }
1598
+ if (usage.bytes >= maxBytes * 0.8) {
1599
+ process.emitWarning(`live filesystem sync retained ${usage.bytes} of ${maxBytes} bytes; ` +
1600
+ "raise createKernel({ maxFilesystemBytes }) before increasing VM filesystem limits", { code: "AGENTOS_LIVE_FILESYSTEM_SYNC_NEAR_LIMIT" });
1601
+ }
1602
+ for (const entry of snapshot) {
1603
+ await applyLiveFilesystemSnapshotEntry(methods, entry);
1563
1604
  }
1564
1605
  }
1565
- async function syncLiveFilesystemPathToBoundMethods(live, methods, targetPath) {
1566
- const stat = targetPath === "/" ? await live.stat(targetPath) : await live.lstat(targetPath);
1606
+ async function snapshotLiveFilesystemPath(live, targetPath, snapshot, usage, maxBytes, knownEntry) {
1607
+ const stat = knownEntry ??
1608
+ (targetPath === "/" ? await live.stat(targetPath) : await live.lstat(targetPath));
1567
1609
  if (stat.isSymbolicLink) {
1568
- await ensureBoundParentDirectory(methods, targetPath);
1569
- await callBoundFilesystemMethod(methods, "removeFile", targetPath).catch(() => { });
1570
- await callBoundFilesystemMethod(methods, "symlink", await live.readlink(targetPath), targetPath);
1610
+ snapshot.push({ kind: "symlink", path: targetPath, target: await live.readlink(targetPath) });
1571
1611
  return;
1572
1612
  }
1573
1613
  if (stat.isDirectory) {
1574
- await callBoundFilesystemMethod(methods, "mkdir", targetPath, {
1575
- recursive: true,
1576
- });
1614
+ snapshot.push({ kind: "directory", path: targetPath });
1577
1615
  const children = (await live.readDirWithTypes(targetPath))
1578
- .map((entry) => entry.name)
1579
- .filter((name) => name !== "." && name !== "..")
1580
- .sort((left, right) => left.localeCompare(right));
1616
+ .filter((entry) => entry.name !== "." && entry.name !== "..")
1617
+ .sort((left, right) => left.name.localeCompare(right.name));
1581
1618
  for (const child of children) {
1582
- await syncLiveFilesystemPathToBoundMethods(live, methods, targetPath === "/" ? posixPath.join("/", child) : posixPath.join(targetPath, child));
1619
+ await snapshotLiveFilesystemPath(live, targetPath === "/"
1620
+ ? posixPath.join("/", child.name)
1621
+ : posixPath.join(targetPath, child.name), snapshot, usage, maxBytes, child);
1583
1622
  }
1584
1623
  return;
1585
1624
  }
1586
- await ensureBoundParentDirectory(methods, targetPath);
1587
- await callBoundFilesystemMethod(methods, "writeFile", targetPath, new Uint8Array(0));
1588
- for (let offset = 0; offset < stat.size; offset += LIVE_FILESYSTEM_SYNC_CHUNK_SIZE) {
1589
- const chunk = await live.pread(targetPath, offset, Math.min(LIVE_FILESYSTEM_SYNC_CHUNK_SIZE, stat.size - offset));
1590
- if (chunk.length === 0) {
1591
- break;
1592
- }
1593
- await callBoundFilesystemMethod(methods, "pwrite", targetPath, offset, chunk);
1625
+ const fileSize = "size" in stat && typeof stat.size === "number"
1626
+ ? stat.size
1627
+ : (await live.lstat(targetPath)).size;
1628
+ if (fileSize > maxBytes - usage.bytes) {
1629
+ throw new LiveFilesystemSyncLimitError(`live filesystem sync for ${targetPath} exceeds ${maxBytes} bytes ` +
1630
+ "(createKernel maxFilesystemBytes); raise createKernel({ maxFilesystemBytes })");
1631
+ }
1632
+ const content = await live.readFile(targetPath);
1633
+ if (content.byteLength > maxBytes - usage.bytes) {
1634
+ throw new LiveFilesystemSyncLimitError(`live filesystem sync for ${targetPath} exceeds ${maxBytes} bytes ` +
1635
+ "(createKernel maxFilesystemBytes); raise createKernel({ maxFilesystemBytes })");
1636
+ }
1637
+ usage.bytes += content.byteLength;
1638
+ snapshot.push({ kind: "file", path: targetPath, content });
1639
+ }
1640
+ async function applyLiveFilesystemSnapshotEntry(methods, entry) {
1641
+ if (entry.kind === "directory") {
1642
+ await callBoundFilesystemMethod(methods, "mkdir", entry.path, { recursive: true });
1643
+ return;
1594
1644
  }
1645
+ await ensureBoundParentDirectory(methods, entry.path);
1646
+ if (entry.kind === "symlink") {
1647
+ await callBoundFilesystemMethod(methods, "removeFile", entry.path).catch(() => { });
1648
+ await callBoundFilesystemMethod(methods, "symlink", entry.target, entry.path);
1649
+ return;
1650
+ }
1651
+ await callBoundFilesystemMethod(methods, "writeFile", entry.path, entry.content);
1595
1652
  }
1596
- function bindLiveFilesystem(target, getFilesystem) {
1653
+ function bindLiveFilesystem(target, getFilesystem, maxBytes) {
1597
1654
  const fallback = {};
1598
1655
  for (const method of VIRTUAL_FILESYSTEM_METHOD_NAMES) {
1599
1656
  const candidate = target[method];
@@ -1619,7 +1676,7 @@ function bindLiveFilesystem(target, getFilesystem) {
1619
1676
  if (!filesystem) {
1620
1677
  return;
1621
1678
  }
1622
- await syncLiveFilesystemToBoundMethods(filesystem, fallback, paths);
1679
+ await syncLiveFilesystemToBoundMethods(filesystem, fallback, paths, maxBytes);
1623
1680
  },
1624
1681
  restore() {
1625
1682
  for (const [method, delegate] of Object.entries(fallback)) {
@@ -1653,9 +1710,9 @@ class NativeKernel {
1653
1710
  loopbackExemptPorts;
1654
1711
  // Bindings registered with the VM, keyed by the callback key the sidecar
1655
1712
  // sends back on a host_callback request (the binding name). Installed lazily
1656
- // on the first registerHostTools call.
1657
- hostToolHandlers = new Map();
1658
- hostToolRequestHandlerInstalled = false;
1713
+ // on the first registerBindings call.
1714
+ bindingHandlers = new Map();
1715
+ bindingRequestHandlerInstalled = false;
1659
1716
  constructor(options) {
1660
1717
  this.options = options;
1661
1718
  this.env = { ...(options.env ?? {}) };
@@ -1685,7 +1742,7 @@ class NativeKernel {
1685
1742
  });
1686
1743
  }
1687
1744
  this.vfs = new DeferredFileSystem(() => this.rootFilesystem);
1688
- this.liveFilesystemBinding = bindLiveFilesystem(this.options.filesystem, () => this.rootFilesystem);
1745
+ this.liveFilesystemBinding = bindLiveFilesystem(this.options.filesystem, () => this.rootFilesystem, options.maxFilesystemBytes ?? DEFAULT_LIVE_FILESYSTEM_SYNC_MAX_BYTES);
1689
1746
  }
1690
1747
  get zombieTimerCount() {
1691
1748
  return this.proxy?.zombieTimerCount ?? 0;
@@ -1880,7 +1937,7 @@ class NativeKernel {
1880
1937
  await this.ensureReady();
1881
1938
  return this.proxy.vmFetch(request);
1882
1939
  }
1883
- async registerHostTools(tools) {
1940
+ async registerBindings(bindings) {
1884
1941
  await this.ensureReady();
1885
1942
  if (!this.client || !this.session || !this.vm) {
1886
1943
  throw new Error("kernel is not ready");
@@ -1888,12 +1945,12 @@ class NativeKernel {
1888
1945
  // Install the dispatcher once. It routes every host_callback request the
1889
1946
  // sidecar emits to the matching registered handler and replies with a
1890
1947
  // host_callback_result frame.
1891
- if (!this.hostToolRequestHandlerInstalled) {
1892
- this.client.setSidecarRequestHandler((request) => this.dispatchHostToolRequest(request));
1893
- this.hostToolRequestHandlerInstalled = true;
1948
+ if (!this.bindingRequestHandlerInstalled) {
1949
+ this.client.setSidecarRequestHandler((request) => this.dispatchBindingRequest(request));
1950
+ this.bindingRequestHandlerInstalled = true;
1894
1951
  }
1895
- for (const [name, binding] of Object.entries(tools)) {
1896
- this.hostToolHandlers.set(name, binding.handler);
1952
+ for (const [name, binding] of Object.entries(bindings)) {
1953
+ this.bindingHandlers.set(name, binding.handler);
1897
1954
  const definition = {
1898
1955
  description: binding.description,
1899
1956
  inputSchema: binding.inputSchema,
@@ -1909,9 +1966,9 @@ class NativeKernel {
1909
1966
  }
1910
1967
  : {}),
1911
1968
  };
1912
- // Register each binding as its own single-callback toolkit so the guest
1969
+ // Register each binding as its own single-callback binding collection so the guest
1913
1970
  // can invoke it directly by name (or by any caller-provided alias). The
1914
- // sidecar exposes the toolkit name as a guest command; the single
1971
+ // sidecar exposes the binding collection name as a guest command; the single
1915
1972
  // callback carries the binding's schema and gates the `binding`
1916
1973
  // permission.
1917
1974
  await this.client.registerHostCallbacks(this.session, this.vm, {
@@ -1926,21 +1983,21 @@ class NativeKernel {
1926
1983
  }
1927
1984
  }
1928
1985
  }
1929
- async dispatchHostToolRequest(request) {
1986
+ async dispatchBindingRequest(request) {
1930
1987
  const { payload } = request;
1931
1988
  if (payload.type !== "host_callback") {
1932
1989
  throw new Error(`unsupported sidecar request for bindings: ${payload.type}`);
1933
1990
  }
1934
- // Callback keys arrive as `${toolkit}:${tool}` for toolkit invocations and
1935
- // as the bare command name otherwise. The toolkit name and tool name are
1936
- // the same here, so the registered tool name is the segment after the last
1991
+ // Callback keys arrive as `${collection}:${binding}` for collection invocations
1992
+ // and as the bare command name otherwise. The collection and binding name are
1993
+ // the same here, so the registered binding name is the segment after the last
1937
1994
  // colon (or the whole key when no colon is present).
1938
1995
  const callbackKey = payload.callback_key;
1939
- const toolName = callbackKey.includes(":")
1996
+ const bindingName = callbackKey.includes(":")
1940
1997
  ? callbackKey.slice(callbackKey.lastIndexOf(":") + 1)
1941
1998
  : callbackKey;
1942
- const handler = this.hostToolHandlers.get(toolName) ??
1943
- this.hostToolHandlers.get(callbackKey);
1999
+ const handler = this.bindingHandlers.get(bindingName) ??
2000
+ this.bindingHandlers.get(callbackKey);
1944
2001
  if (!handler) {
1945
2002
  return {
1946
2003
  type: "host_callback_result",
@@ -1996,6 +2053,10 @@ class NativeKernel {
1996
2053
  await this.ensureReady();
1997
2054
  return this.proxy.rename(oldPath, newPath);
1998
2055
  }
2056
+ async pwrite(targetPath, offset, data) {
2057
+ await this.ensureReady();
2058
+ return this.proxy.vfs.pwrite(targetPath, offset, data);
2059
+ }
1999
2060
  tryResolveMountedCommand(command) {
2000
2061
  const normalized = normalizeCommandLookup(command);
2001
2062
  for (const driver of this.mountedRuntimeDrivers) {
@@ -2062,15 +2123,19 @@ class NativeKernel {
2062
2123
  cwd: REPO_ROOT,
2063
2124
  command: ensureNativeSidecarBinary(),
2064
2125
  args: [],
2065
- frameTimeoutMs: NATIVE_SIDECAR_FRAME_TIMEOUT_MS,
2126
+ gracefulExitMs: 100,
2127
+ forceExitMs: 100,
2066
2128
  }));
2067
2129
  const session = await this.measureBoot("session_open", () => client.authenticateAndOpenSession());
2068
2130
  const vm = await this.measureBoot("vm_create", () => client.createVm(session, {
2069
2131
  runtime: "java_script",
2070
2132
  config: {
2071
2133
  env: createVmEnv,
2134
+ ...(this.options.user ? { user: this.options.user } : {}),
2072
2135
  rootFilesystem,
2073
- ...(bootstrapPermissions ? { permissions: bootstrapPermissions } : {}),
2136
+ ...(bootstrapPermissions
2137
+ ? { permissions: bootstrapPermissions }
2138
+ : {}),
2074
2139
  loopbackExemptPorts: this.loopbackExemptPorts,
2075
2140
  ...(this.options.jsRuntime
2076
2141
  ? { jsRuntime: this.options.jsRuntime }
@@ -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 { ToolLimitsConfig } from "./generated/ToolLimitsConfig.js";
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-glibc.928bc3a",
3
+ "version": "0.0.0-main.29b0797",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -184,15 +184,18 @@
184
184
  },
185
185
  "scripts": {
186
186
  "build:protocol": "pnpm --dir ../build-tools build:protocol",
187
- "build:vm-config": "cargo test -p agentos-vm-config --quiet",
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 && pnpm run build:vm-config && tsc --noEmit",
190
- "build": "pnpm run build:protocol && pnpm run build:vm-config && tsc && pnpm run copy-commands",
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
- "test": "vitest run"
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"
193
196
  },
194
197
  "dependencies": {
195
- "@rivet-dev/agentos-runtime-sidecar": "0.0.0-glibc.928bc3a",
198
+ "@rivet-dev/agentos-runtime-sidecar": "0.0.0-main.29b0797",
196
199
  "@rivetkit/bare-ts": "^0.6.2",
197
200
  "zod": "^4.1.11"
198
201
  },
package/commands/codex DELETED
Binary file
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
- };