@rivet-dev/agentos 0.0.0-agentos-dylib-plugin.fc34807 → 0.0.0-agentos-dylib-plugin.bbfdf95

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 (2) hide show
  1. package/dist/actor.js +55 -5
  2. package/package.json +5 -5
package/dist/actor.js CHANGED
@@ -9,6 +9,7 @@
9
9
  * configuration, resolves the plugin + sidecar binaries, and hands the opaque
10
10
  * config envelope across the bridge — it owns no agent-os runtime logic.
11
11
  */
12
+ import { sep } from "node:path";
12
13
  import { getSidecarPath } from "@rivet-dev/agentos-sidecar";
13
14
  import { actor, } from "rivetkit";
14
15
  import { agentOsActorConfigSchema, } from "./config.js";
@@ -35,6 +36,54 @@ export function nodeModulesMount(hostNodeModulesDir, opts) {
35
36
  readOnly,
36
37
  };
37
38
  }
39
+ /**
40
+ * Derive the `node_modules` root that contains an installed package directory.
41
+ * For an agent descriptor whose `packageDir` is `<root>/node_modules/@scope/pkg`,
42
+ * this returns `<root>/node_modules` — the hoist root that also holds the agent's
43
+ * `requires` (the ACP adapter + agent SDK) and their transitive deps under a
44
+ * flat (npm) install. Returns `undefined` when `packageDir` is not inside a
45
+ * `node_modules` tree (e.g. a linked monorepo checkout), where the caller must
46
+ * supply an explicit `nodeModulesMount(...)`.
47
+ */
48
+ function nodeModulesRootOf(packageDir) {
49
+ const parts = packageDir.split(sep);
50
+ const idx = parts.lastIndexOf("node_modules");
51
+ if (idx === -1)
52
+ return undefined;
53
+ return parts.slice(0, idx + 1).join(sep);
54
+ }
55
+ /**
56
+ * Agents run their ACP adapter + SDK inside the VM from `/root/node_modules`.
57
+ * Rather than make the caller hand-write `nodeModulesMount(...)`, auto-derive a
58
+ * read-only `host_dir` mount of the `node_modules` root that holds the agent
59
+ * packages (`requires`) from each agent descriptor's installed `packageDir`.
60
+ *
61
+ * An explicit `/root/node_modules` mount in `options.mounts` always wins. If
62
+ * agents resolve to more than one distinct `node_modules` root the derivation is
63
+ * ambiguous and the caller must mount explicitly.
64
+ */
65
+ function withAutoAgentNodeModulesMount(mounts, descriptors) {
66
+ if (mounts?.some((mount) => mount.path === "/root/node_modules")) {
67
+ return mounts;
68
+ }
69
+ const roots = new Set();
70
+ for (const d of descriptors) {
71
+ if (!d.agent || typeof d.packageDir !== "string")
72
+ continue;
73
+ const root = nodeModulesRootOf(d.packageDir);
74
+ if (root)
75
+ roots.add(root);
76
+ }
77
+ if (roots.size === 0)
78
+ return mounts;
79
+ if (roots.size > 1) {
80
+ throw new Error("agentOs() could not auto-mount agent node_modules: agents resolved to " +
81
+ `multiple node_modules roots (${[...roots].join(", ")}). Pass an ` +
82
+ "explicit nodeModulesMount(...) in options.mounts.");
83
+ }
84
+ const [hostNodeModulesDir] = [...roots];
85
+ return [...(mounts ?? []), nodeModulesMount(hostNodeModulesDir)];
86
+ }
38
87
  function flattenSoftware(input, out) {
39
88
  if (input == null)
40
89
  return;
@@ -65,12 +114,13 @@ export function buildConfigJson(parsed) {
65
114
  });
66
115
  }
67
116
  }
68
- // `/root/node_modules` (agent SDK + transitive dep resolution) is supplied
69
- // explicitly by the client via `options.mounts` (see `nodeModulesMount(...)`),
70
- // not derived from a host cwd. The VM module resolver reads the mounted tree
71
- // through the kernel VFS.
117
+ // `/root/node_modules` (agent ACP adapter + SDK + transitive dep resolution)
118
+ // is auto-derived from the agent descriptors so the standard quickstart needs
119
+ // no manual `nodeModulesMount(...)`: see `withAutoAgentNodeModulesMount`. An
120
+ // explicit `/root/node_modules` mount in `options.mounts` always wins. The VM
121
+ // module resolver reads the mounted tree through the kernel VFS.
72
122
  const options = (parsed.options ?? {});
73
- const mounts = serializeNativeMounts(options.mounts);
123
+ const mounts = withAutoAgentNodeModulesMount(serializeNativeMounts(options.mounts), descriptors);
74
124
  const sidecar = serializeSidecar(options.sidecar);
75
125
  return JSON.stringify({
76
126
  software,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivet-dev/agentos",
3
- "version": "0.0.0-agentos-dylib-plugin.fc34807",
3
+ "version": "0.0.0-agentos-dylib-plugin.bbfdf95",
4
4
  "description": "Agent OS actor for RivetKit — thin TS forwarder that loads the native actor plugin (cdylib) via RivetKit's generic native-plugin ABI.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -28,8 +28,8 @@
28
28
  "test": "vitest run"
29
29
  },
30
30
  "dependencies": {
31
- "@rivet-dev/agentos-core": "0.0.0-agentos-dylib-plugin.fc34807",
32
- "@rivet-dev/agentos-sidecar": "0.0.0-agentos-dylib-plugin.fc34807",
31
+ "@rivet-dev/agentos-core": "0.0.0-agentos-dylib-plugin.bbfdf95",
32
+ "@rivet-dev/agentos-sidecar": "0.0.0-agentos-dylib-plugin.bbfdf95",
33
33
  "zod": "^4.1.11"
34
34
  },
35
35
  "peerDependencies": {
@@ -37,13 +37,13 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^22.19.15",
40
- "rivetkit": "0.0.0-feat-dylib-actor-plugin.5d959bc",
40
+ "rivetkit": "0.0.0-feat-dylib-actor-plugin.c44621f",
41
41
  "vitest": "^2.1.8"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=20"
45
45
  },
46
46
  "optionalDependencies": {
47
- "@rivet-dev/agentos-plugin-linux-x64-gnu": "0.0.0-agentos-dylib-plugin.fc34807"
47
+ "@rivet-dev/agentos-plugin-linux-x64-gnu": "0.0.0-agentos-dylib-plugin.bbfdf95"
48
48
  }
49
49
  }