@rivet-dev/agentos 0.0.0-nathan-binding-workspace.4640d5c → 0.0.0-nathan-binding-workspace.abc7ec9

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.
@@ -0,0 +1,186 @@
1
+ import { ActionContext, BeforeConnectContext, ActorContext, ActorDefinition, DatabaseProvider, RawAccess } from 'rivetkit';
2
+ export { setup } from 'rivetkit';
3
+ import { AgentOs, JsonRpcNotification, PermissionRequest, CronEvent, AgentCapabilities, AgentInfo, JsonRpcResponse, AgentOsOptions } from '@rivet-dev/agentos-core';
4
+ import { z } from 'zod/v4';
5
+
6
+ type AgentOsActorState = {};
7
+ interface AgentOsActorVars {
8
+ agentOs: AgentOs | null;
9
+ activeSessionIds: Set<string>;
10
+ activeProcesses: Set<number>;
11
+ activeHooks: Set<Promise<void>>;
12
+ activeShells: Set<string>;
13
+ sessions: Set<string>;
14
+ }
15
+ interface SessionEventPayload {
16
+ sessionId: string;
17
+ event: JsonRpcNotification;
18
+ }
19
+ interface PermissionRequestPayload {
20
+ sessionId: string;
21
+ request: PermissionRequest;
22
+ }
23
+ type VmBootedPayload = Record<string, never>;
24
+ interface VmShutdownPayload {
25
+ reason: "sleep" | "destroy" | "error";
26
+ }
27
+ interface ProcessOutputPayload {
28
+ pid: number;
29
+ stream: "stdout" | "stderr";
30
+ data: Uint8Array;
31
+ }
32
+ interface ProcessExitPayload {
33
+ pid: number;
34
+ exitCode: number;
35
+ }
36
+ interface ShellDataPayload {
37
+ shellId: string;
38
+ data: Uint8Array;
39
+ }
40
+ interface CronEventPayload {
41
+ event: CronEvent;
42
+ }
43
+ interface AgentOsEvents {
44
+ sessionEvent: SessionEventPayload;
45
+ permissionRequest: PermissionRequestPayload;
46
+ vmBooted: VmBootedPayload;
47
+ vmShutdown: VmShutdownPayload;
48
+ processOutput: ProcessOutputPayload;
49
+ processExit: ProcessExitPayload;
50
+ shellData: ShellDataPayload;
51
+ cronEvent: CronEventPayload;
52
+ }
53
+ /** Result from sendPrompt. */
54
+ interface PromptResult {
55
+ /** Raw JSON-RPC response from the ACP adapter. */
56
+ response: JsonRpcResponse;
57
+ /** Accumulated agent text output from streamed message chunks. */
58
+ text: string;
59
+ }
60
+ interface SessionRecord {
61
+ sessionId: string;
62
+ agentType: string;
63
+ capabilities: AgentCapabilities;
64
+ agentInfo: AgentInfo | null;
65
+ }
66
+ interface PersistedSessionRecord {
67
+ sessionId: string;
68
+ agentType: string;
69
+ capabilities: AgentCapabilities;
70
+ agentInfo: AgentInfo | null;
71
+ createdAt: number;
72
+ }
73
+ interface PersistedSessionEvent {
74
+ sessionId: string;
75
+ seq: number;
76
+ event: JsonRpcNotification;
77
+ createdAt: number;
78
+ }
79
+ type SerializableCronAction = {
80
+ type: "session";
81
+ agentType: string;
82
+ prompt: string;
83
+ cwd?: string;
84
+ } | {
85
+ type: "exec";
86
+ command: string;
87
+ args?: string[];
88
+ };
89
+ interface SerializableCronJobOptions {
90
+ id?: string;
91
+ schedule: string;
92
+ action: SerializableCronAction;
93
+ overlap?: "allow" | "skip" | "queue";
94
+ }
95
+ interface SerializableCronJobInfo {
96
+ id: string;
97
+ schedule: string;
98
+ action: SerializableCronAction;
99
+ overlap: "allow" | "skip" | "queue";
100
+ lastRun?: string;
101
+ nextRun?: string;
102
+ runCount: number;
103
+ running: boolean;
104
+ }
105
+ type AgentOsActionContext<TConnParams = undefined> = ActionContext<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, any>;
106
+
107
+ declare const agentOsActorConfigSchema: z.ZodObject<{
108
+ options: z.ZodOptional<z.ZodCustom<AgentOsOptions, AgentOsOptions>>;
109
+ preview: z.ZodPrefault<z.ZodObject<{
110
+ defaultExpiresInSeconds: z.ZodDefault<z.ZodNumber>;
111
+ maxExpiresInSeconds: z.ZodDefault<z.ZodNumber>;
112
+ }, z.core.$strict>>;
113
+ onBeforeConnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
114
+ onSessionEvent: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
115
+ onPermissionRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
116
+ }, z.core.$strict>;
117
+ type AgentOsActorContext<TConnParams> = ActorContext<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, any>;
118
+ interface AgentOsActorConfigCallbacks<TConnParams> {
119
+ onBeforeConnect?: (c: BeforeConnectContext<AgentOsActorState, AgentOsActorVars, undefined, any>, params: TConnParams) => void | Promise<void>;
120
+ onSessionEvent?: (c: AgentOsActorContext<TConnParams>, sessionId: string, event: JsonRpcNotification) => void | Promise<void>;
121
+ onPermissionRequest?: (c: AgentOsActorContext<TConnParams>, sessionId: string, request: PermissionRequest) => void | Promise<void>;
122
+ }
123
+ type AgentOsActorConfig<TConnParams = undefined> = Omit<z.infer<typeof agentOsActorConfigSchema>, "onBeforeConnect" | "onSessionEvent" | "onPermissionRequest"> & AgentOsActorConfigCallbacks<TConnParams>;
124
+ type AgentOsActorConfigInput<TConnParams = undefined> = Omit<z.input<typeof agentOsActorConfigSchema>, "onBeforeConnect" | "onSessionEvent" | "onPermissionRequest"> & AgentOsActorConfigCallbacks<TConnParams>;
125
+
126
+ /**
127
+ * Rust-backed `agentOs(...)` definition.
128
+ *
129
+ * Produces an `ActorDefinition` whose `nativeFactoryBuilder` constructs a
130
+ * native-actor-plugin factory through `runtime.createNativePluginFactory(...)`
131
+ * (NAPI → `dlopen` of the agent-os actor plugin cdylib, the inverse of the
132
+ * generic host loader). All lifecycle, state, and action dispatch live in the
133
+ * Rust plugin (`crates/agentos-actor-plugin`). This JS shim only validates
134
+ * configuration, resolves the plugin + sidecar binaries, and hands the opaque
135
+ * config envelope across the bridge — it owns no agent-os runtime logic.
136
+ */
137
+
138
+ /**
139
+ * A native `host_dir` mount of a host `node_modules` directory at
140
+ * `/root/node_modules`, the serializable form `agentOs({ options: { mounts } })`
141
+ * accepts across the NAPI boundary.
142
+ */
143
+ interface NodeModulesMountConfig {
144
+ path: "/root/node_modules";
145
+ plugin: {
146
+ id: "host_dir";
147
+ config: {
148
+ hostPath: string;
149
+ readOnly: boolean;
150
+ };
151
+ };
152
+ readOnly: boolean;
153
+ }
154
+ /**
155
+ * Mount a host `node_modules` directory into the VM at `/root/node_modules`.
156
+ *
157
+ * This is the explicit, mount-based replacement for the removed `moduleAccessCwd`
158
+ * mechanism: the VM module resolver reads the mounted tree through the kernel
159
+ * VFS, so the caller supplies exactly the `node_modules` directory whose
160
+ * packages should resolve in the guest.
161
+ *
162
+ * @param hostNodeModulesDir Absolute host path to a `node_modules` directory.
163
+ * @param opts.readOnly Defaults to `true`; the mount is read-only.
164
+ */
165
+ declare function nodeModulesMount(hostNodeModulesDir: string, opts?: {
166
+ readOnly?: boolean;
167
+ }): NodeModulesMountConfig;
168
+ declare function buildConfigJson<TConnParams>(parsed: AgentOsActorConfig<TConnParams>): string;
169
+ /**
170
+ * Type alias for the `agentOs(...)` return type. Events are not typed at the
171
+ * TS surface because the Rust plugin owns the broadcast set and the
172
+ * test/client surface uses `any` for actions.
173
+ */
174
+ type AgentOsActorDefinition<TConnParams> = ActorDefinition<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<RawAccess>, Record<never, never>, Record<never, never>, any>;
175
+ declare function agentOs<TConnParams = undefined>(config: AgentOsActorConfigInput<TConnParams>): AgentOsActorDefinition<TConnParams>;
176
+
177
+ /**
178
+ * Resolve the absolute path to the agent-os actor plugin cdylib. RivetKit
179
+ * `dlopen`s this path through the generic native-plugin ABI.
180
+ */
181
+ declare function getPluginPath(): string;
182
+
183
+ type AgentOSActorConfigInput<TConnParams = undefined> = AgentOsActorConfigInput<TConnParams>["options"];
184
+ declare function agentOS<TConnParams = undefined>(config?: AgentOSActorConfigInput<TConnParams>): AgentOsActorDefinition<TConnParams>;
185
+
186
+ export { type AgentOSActorConfigInput, type AgentOsActionContext, type AgentOsActorConfig, type AgentOsActorConfigInput, type AgentOsActorState, type AgentOsActorVars, type AgentOsEvents, type CronEventPayload, type NodeModulesMountConfig, type PermissionRequestPayload, type PersistedSessionEvent, type PersistedSessionRecord, type ProcessExitPayload, type ProcessOutputPayload, type PromptResult, type SerializableCronAction, type SerializableCronJobInfo, type SerializableCronJobOptions, type SessionEventPayload, type SessionRecord, type ShellDataPayload, type VmBootedPayload, type VmShutdownPayload, agentOS, agentOs, agentOsActorConfigSchema, buildConfigJson, getPluginPath, nodeModulesMount };
package/dist/index.js ADDED
@@ -0,0 +1,307 @@
1
+ // src/actor.ts
2
+ import { sep } from "path";
3
+ import common from "@agentos-software/common";
4
+ import { getSidecarPath } from "@rivet-dev/agentos-sidecar";
5
+ import {
6
+ actor
7
+ } from "rivetkit";
8
+
9
+ // src/config.ts
10
+ import { z } from "zod/v4";
11
+ var zFunction = () => z.custom((val) => typeof val === "function");
12
+ var AgentOsOptionsSchema = z.custom(
13
+ (val) => typeof val === "object" && val !== null
14
+ );
15
+ var agentOsActorConfigSchema = z.object({
16
+ options: AgentOsOptionsSchema.optional(),
17
+ preview: z.object({
18
+ defaultExpiresInSeconds: z.number().positive().default(3600),
19
+ maxExpiresInSeconds: z.number().positive().default(86400)
20
+ }).strict().prefault(() => ({})),
21
+ onBeforeConnect: zFunction().optional(),
22
+ onSessionEvent: zFunction().optional(),
23
+ onPermissionRequest: zFunction().optional()
24
+ }).strict();
25
+
26
+ // src/plugin-binary.ts
27
+ import { existsSync } from "fs";
28
+ import { createRequire } from "module";
29
+ import { dirname, join } from "path";
30
+ import { fileURLToPath } from "url";
31
+ var PLUGIN_BIN_ENV = "AGENTOS_PLUGIN_BIN";
32
+ function libraryName() {
33
+ switch (process.platform) {
34
+ case "darwin":
35
+ return "libagentos_actor_plugin.dylib";
36
+ case "win32":
37
+ return "agentos_actor_plugin.dll";
38
+ default:
39
+ return "libagentos_actor_plugin.so";
40
+ }
41
+ }
42
+ function getPlatformPackageName() {
43
+ const { platform, arch } = process;
44
+ switch (platform) {
45
+ case "linux":
46
+ if (arch === "x64") return "@rivet-dev/agentos-plugin-linux-x64-gnu";
47
+ if (arch === "arm64") return "@rivet-dev/agentos-plugin-linux-arm64-gnu";
48
+ break;
49
+ case "darwin":
50
+ if (arch === "x64") return "@rivet-dev/agentos-plugin-darwin-x64";
51
+ if (arch === "arm64") return "@rivet-dev/agentos-plugin-darwin-arm64";
52
+ break;
53
+ default:
54
+ break;
55
+ }
56
+ return null;
57
+ }
58
+ function getPluginPath() {
59
+ const override = process.env[PLUGIN_BIN_ENV];
60
+ if (override) {
61
+ if (!existsSync(override)) {
62
+ throw new Error(
63
+ `${PLUGIN_BIN_ENV} is set to ${override} but the file does not exist`
64
+ );
65
+ }
66
+ return override;
67
+ }
68
+ const lib = libraryName();
69
+ const here = dirname(fileURLToPath(import.meta.url));
70
+ for (const profile of ["release", "debug"]) {
71
+ const candidate = join(here, "..", "..", "..", "target", profile, lib);
72
+ if (existsSync(candidate)) {
73
+ return candidate;
74
+ }
75
+ }
76
+ const platformPkg = getPlatformPackageName();
77
+ if (!platformPkg) {
78
+ throw new Error(
79
+ `@rivet-dev/agentos: unsupported platform ${process.platform}/${process.arch}. The Agent OS actor plugin currently supports linux and darwin on x64 and arm64. Set ${PLUGIN_BIN_ENV} to a local cdylib to override.`
80
+ );
81
+ }
82
+ const require2 = createRequire(import.meta.url);
83
+ let pkgJsonPath;
84
+ try {
85
+ pkgJsonPath = require2.resolve(`${platformPkg}/package.json`);
86
+ } catch {
87
+ throw new Error(
88
+ `@rivet-dev/agentos: platform package ${platformPkg} is not installed.
89
+ This usually means the platform is unsupported or optionalDependencies
90
+ were skipped during install. Try: npm install --include=optional ${platformPkg}
91
+ Or set ${PLUGIN_BIN_ENV} to a local cdylib, or build it with
92
+ \`cargo build -p agentos-actor-plugin\`.`
93
+ );
94
+ }
95
+ return join(dirname(pkgJsonPath), lib);
96
+ }
97
+
98
+ // src/actor.ts
99
+ function nodeModulesMount(hostNodeModulesDir, opts) {
100
+ const readOnly = opts?.readOnly ?? true;
101
+ return {
102
+ path: "/root/node_modules",
103
+ plugin: {
104
+ id: "host_dir",
105
+ config: { hostPath: hostNodeModulesDir, readOnly }
106
+ },
107
+ readOnly
108
+ };
109
+ }
110
+ function nodeModulesRootOf(packageDir) {
111
+ const parts = packageDir.split(sep);
112
+ const idx = parts.lastIndexOf("node_modules");
113
+ if (idx === -1) return void 0;
114
+ return parts.slice(0, idx + 1).join(sep);
115
+ }
116
+ function withAutoAgentNodeModulesMount(mounts, descriptors) {
117
+ if (mounts?.some((mount) => mount.path === "/root/node_modules")) {
118
+ return mounts;
119
+ }
120
+ const roots = /* @__PURE__ */ new Set();
121
+ for (const d of descriptors) {
122
+ if (!d.agent || typeof d.packageDir !== "string") continue;
123
+ const root = nodeModulesRootOf(d.packageDir);
124
+ if (root) {
125
+ roots.add(root);
126
+ continue;
127
+ }
128
+ const requires = d.requires?.length ? ` Required packages: ${d.requires.join(", ")}.` : "";
129
+ throw new Error(
130
+ `agentOs() could not auto-mount agent node_modules: agent packageDir ${d.packageDir} is not inside a node_modules install. Run from an npm-installed package tree, or pass an explicit nodeModulesMount(<absolute node_modules path>) in options.mounts.` + requires
131
+ );
132
+ }
133
+ if (roots.size === 0) return mounts;
134
+ if (roots.size > 1) {
135
+ throw new Error(
136
+ `agentOs() could not auto-mount agent node_modules: agents resolved to multiple node_modules roots (${[...roots].join(", ")}). Pass an explicit nodeModulesMount(...) in options.mounts.`
137
+ );
138
+ }
139
+ const [hostNodeModulesDir] = [...roots];
140
+ return [...mounts ?? [], nodeModulesMount(hostNodeModulesDir)];
141
+ }
142
+ function softwareIdentity(d) {
143
+ if (typeof d.commandDir === "string") return `dir:${d.commandDir}`;
144
+ if (typeof d.packageDir === "string") return `dir:${d.packageDir}`;
145
+ const name = d.name;
146
+ if (typeof name === "string") return `name:${name}`;
147
+ return JSON.stringify(d);
148
+ }
149
+ function flattenSoftware(input, out) {
150
+ if (input == null) return;
151
+ if (Array.isArray(input)) {
152
+ for (const item of input) flattenSoftware(item, out);
153
+ return;
154
+ }
155
+ if (typeof input === "object") out.push(input);
156
+ }
157
+ function buildConfigJson(parsed) {
158
+ const descriptors = [];
159
+ flattenSoftware(
160
+ parsed.options?.software,
161
+ descriptors
162
+ );
163
+ const defaultSoftwareEnabled = parsed.options?.defaultSoftware !== false;
164
+ if (defaultSoftwareEnabled) {
165
+ const defaults = [];
166
+ flattenSoftware(common, defaults);
167
+ const seen = new Set(descriptors.map(softwareIdentity));
168
+ const toPrepend = defaults.filter((d) => !seen.has(softwareIdentity(d)));
169
+ descriptors.unshift(...toPrepend);
170
+ }
171
+ const software = [];
172
+ for (const d of descriptors) {
173
+ if (typeof d.commandDir === "string") {
174
+ software.push({ package: d.commandDir });
175
+ } else if (typeof d.packageDir === "string") {
176
+ software.push({
177
+ package: d.packageDir,
178
+ kind: d.hostTool || d.toolkit ? "tool" : "agent"
179
+ });
180
+ }
181
+ }
182
+ const options = parsed.options ?? {};
183
+ const mounts = withAutoAgentNodeModulesMount(
184
+ serializeNativeMounts(options.mounts),
185
+ descriptors
186
+ );
187
+ const sidecar = serializeSidecar(options.sidecar);
188
+ return JSON.stringify({
189
+ software,
190
+ additionalInstructions: options.additionalInstructions,
191
+ loopbackExemptPorts: options.loopbackExemptPorts,
192
+ allowedNodeBuiltins: options.allowedNodeBuiltins,
193
+ permissions: options.permissions,
194
+ rootFilesystem: options.rootFilesystem,
195
+ mounts,
196
+ limits: options.limits,
197
+ sidecar
198
+ });
199
+ }
200
+ function serializeNativeMounts(input) {
201
+ if (input == null) return void 0;
202
+ if (!Array.isArray(input)) {
203
+ throw new Error("agentOs() options.mounts must be an array");
204
+ }
205
+ return input.map((mount, index) => {
206
+ if (!mount || typeof mount !== "object") {
207
+ throw new Error(`agentOs() options.mounts[${index}] must be an object`);
208
+ }
209
+ const record = mount;
210
+ if (record.driver !== void 0) {
211
+ throw new Error(
212
+ "agentOs() only supports Native mounts across the NAPI boundary; Plain mounts with driver callbacks are not serializable"
213
+ );
214
+ }
215
+ if (record.filesystem !== void 0) {
216
+ throw new Error(
217
+ "agentOs() only supports Native mounts across the NAPI boundary; Overlay mounts are not serializable"
218
+ );
219
+ }
220
+ const plugin = record.plugin;
221
+ if (typeof record.path !== "string" || !plugin || typeof plugin !== "object" || typeof plugin.id !== "string") {
222
+ throw new Error(
223
+ `agentOs() options.mounts[${index}] must be a Native mount with { path, plugin: { id, config? } }`
224
+ );
225
+ }
226
+ return {
227
+ path: record.path,
228
+ plugin: {
229
+ id: plugin.id,
230
+ config: plugin.config
231
+ },
232
+ readOnly: typeof record.readOnly === "boolean" ? record.readOnly : void 0
233
+ };
234
+ });
235
+ }
236
+ function serializeSidecar(input) {
237
+ if (input == null) return void 0;
238
+ if (!input || typeof input !== "object") {
239
+ throw new Error("agentOs() options.sidecar must be an object");
240
+ }
241
+ const record = input;
242
+ if (record.kind === "explicit" || record.handle !== void 0) {
243
+ throw new Error(
244
+ "agentOs() only supports sidecar shared pool configuration across the NAPI boundary; explicit sidecar handles are not serializable"
245
+ );
246
+ }
247
+ if (record.kind !== void 0 && record.kind !== "shared") {
248
+ throw new Error('agentOs() options.sidecar.kind must be "shared"');
249
+ }
250
+ return typeof record.pool === "string" ? { pool: record.pool } : {};
251
+ }
252
+ function buildNativeFactoryBuilder(parsed) {
253
+ return (runtime) => {
254
+ if (runtime.kind !== "napi") {
255
+ throw new Error(
256
+ `agentOs() is only supported on the native NAPI runtime (current runtime kind: ${runtime.kind})`
257
+ );
258
+ }
259
+ if (!runtime.createNativePluginFactory) {
260
+ throw new Error(
261
+ "runtime.createNativePluginFactory is not implemented on the active CoreRuntime"
262
+ );
263
+ }
264
+ const options = {
265
+ // Resolve the prebuilt agent-os actor plugin cdylib; RivetKit `dlopen`s
266
+ // it through the generic native-plugin ABI.
267
+ pluginPath: getPluginPath(),
268
+ // Opaque config envelope the plugin parses (config.rs::AgentOsConfigJson).
269
+ configJson: buildConfigJson(parsed),
270
+ // Resolve the prebuilt sidecar binary from the npm package so the plugin
271
+ // spawns the bundled binary rather than relying on `agentos-sidecar`
272
+ // being on PATH.
273
+ sidecarPath: getSidecarPath()
274
+ };
275
+ return runtime.createNativePluginFactory(options);
276
+ };
277
+ }
278
+ function agentOs(config) {
279
+ const parsed = agentOsActorConfigSchema.parse(
280
+ config
281
+ );
282
+ const actorOptions = parsed.actorOptions;
283
+ const definition = actor({
284
+ actions: {},
285
+ ...actorOptions ? { options: actorOptions } : {}
286
+ });
287
+ definition.nativeFactoryBuilder = buildNativeFactoryBuilder(parsed);
288
+ return definition;
289
+ }
290
+
291
+ // src/index.ts
292
+ import { setup } from "rivetkit";
293
+ function agentOS(config = {}) {
294
+ return agentOs({
295
+ options: config
296
+ });
297
+ }
298
+ export {
299
+ agentOS,
300
+ agentOs,
301
+ agentOsActorConfigSchema,
302
+ buildConfigJson,
303
+ getPluginPath,
304
+ nodeModulesMount,
305
+ setup
306
+ };
307
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/actor.ts","../src/config.ts","../src/plugin-binary.ts","../src/index.ts"],"sourcesContent":["/**\n * Rust-backed `agentOs(...)` definition.\n *\n * Produces an `ActorDefinition` whose `nativeFactoryBuilder` constructs a\n * native-actor-plugin factory through `runtime.createNativePluginFactory(...)`\n * (NAPI → `dlopen` of the agent-os actor plugin cdylib, the inverse of the\n * generic host loader). All lifecycle, state, and action dispatch live in the\n * Rust plugin (`crates/agentos-actor-plugin`). This JS shim only validates\n * configuration, resolves the plugin + sidecar binaries, and hands the opaque\n * config envelope across the bridge — it owns no agent-os runtime logic.\n */\n\nimport { sep } from \"node:path\";\nimport common from \"@agentos-software/common\";\nimport { getSidecarPath } from \"@rivet-dev/agentos-sidecar\";\nimport {\n\tactor,\n\ttype ActorDefinition,\n\ttype ActorFactoryHandle,\n\ttype CoreRuntime,\n\ttype DatabaseProvider,\n\ttype NapiNativePluginOptions,\n\ttype RawAccess,\n} from \"rivetkit\";\nimport {\n\ttype AgentOsActorConfig,\n\ttype AgentOsActorConfigInput,\n\tagentOsActorConfigSchema,\n} from \"./config.js\";\nimport { getPluginPath } from \"./plugin-binary.js\";\nimport type { AgentOsActorState, AgentOsActorVars } from \"./types.js\";\n\n/**\n * Build the JSON envelope the Rust plugin consumes. The Rust deserializer\n * uses `deny_unknown_fields`, so the envelope must stay in lock-step with\n * `crates/agentos-actor-plugin/src/config.rs::AgentOsConfigJson`.\n *\n * Software threading: each software descriptor is flattened (meta packages\n * such as `common` are arrays of descriptors) and mapped to the Rust\n * `SoftwareInput { package, kind }`. The agentos-client resolves an\n * ABSOLUTE `package` directly (its `resolve_software` lets an absolute path\n * bypass the `node_modules` prefix), so the descriptor's already-resolved\n * `commandDir` (wasm commands) / `packageDir` (agents/tools) is forwarded as\n * `package`.\n */\ninterface SoftwareDescriptorLike {\n\tcommandDir?: string;\n\tpackageDir?: string;\n\trequires?: string[];\n\tagent?: unknown;\n\thostTool?: unknown;\n\ttoolkit?: unknown;\n}\n\ninterface NativeMountLike {\n\tpath: string;\n\tplugin: {\n\t\tid: string;\n\t\tconfig?: unknown;\n\t};\n\treadOnly?: boolean;\n}\n\n/**\n * A native `host_dir` mount of a host `node_modules` directory at\n * `/root/node_modules`, the serializable form `agentOs({ options: { mounts } })`\n * accepts across the NAPI boundary.\n */\nexport interface NodeModulesMountConfig {\n\tpath: \"/root/node_modules\";\n\tplugin: { id: \"host_dir\"; config: { hostPath: string; readOnly: boolean } };\n\treadOnly: boolean;\n}\n\n/**\n * Mount a host `node_modules` directory into the VM at `/root/node_modules`.\n *\n * This is the explicit, mount-based replacement for the removed `moduleAccessCwd`\n * mechanism: the VM module resolver reads the mounted tree through the kernel\n * VFS, so the caller supplies exactly the `node_modules` directory whose\n * packages should resolve in the guest.\n *\n * @param hostNodeModulesDir Absolute host path to a `node_modules` directory.\n * @param opts.readOnly Defaults to `true`; the mount is read-only.\n */\nexport function nodeModulesMount(\n\thostNodeModulesDir: string,\n\topts?: { readOnly?: boolean },\n): NodeModulesMountConfig {\n\tconst readOnly = opts?.readOnly ?? true;\n\treturn {\n\t\tpath: \"/root/node_modules\",\n\t\tplugin: {\n\t\t\tid: \"host_dir\",\n\t\t\tconfig: { hostPath: hostNodeModulesDir, readOnly },\n\t\t},\n\t\treadOnly,\n\t};\n}\n\n/**\n * Derive the `node_modules` root that contains an installed package directory.\n * For an agent descriptor whose `packageDir` is `<root>/node_modules/@scope/pkg`,\n * this returns `<root>/node_modules` — the hoist root that also holds the agent's\n * `requires` (the ACP adapter + agent SDK) and their transitive deps under a\n * flat (npm) install. Returns `undefined` when `packageDir` is not inside a\n * `node_modules` tree (e.g. a linked monorepo checkout), where the caller must\n * supply an explicit `nodeModulesMount(...)`.\n */\nfunction nodeModulesRootOf(packageDir: string): string | undefined {\n\tconst parts = packageDir.split(sep);\n\tconst idx = parts.lastIndexOf(\"node_modules\");\n\tif (idx === -1) return undefined;\n\treturn parts.slice(0, idx + 1).join(sep);\n}\n\n/**\n * Agents run their ACP adapter + SDK inside the VM from `/root/node_modules`.\n * Rather than make the caller hand-write `nodeModulesMount(...)`, auto-derive a\n * read-only `host_dir` mount of the `node_modules` root that holds the agent\n * packages (`requires`) from each agent descriptor's installed `packageDir`.\n *\n * An explicit `/root/node_modules` mount in `options.mounts` always wins. If\n * agents resolve to more than one distinct `node_modules` root the derivation is\n * ambiguous and the caller must mount explicitly.\n */\nfunction withAutoAgentNodeModulesMount(\n\tmounts: NativeMountLike[] | undefined,\n\tdescriptors: SoftwareDescriptorLike[],\n): NativeMountLike[] | undefined {\n\tif (mounts?.some((mount) => mount.path === \"/root/node_modules\")) {\n\t\treturn mounts;\n\t}\n\n\tconst roots = new Set<string>();\n\tfor (const d of descriptors) {\n\t\tif (!d.agent || typeof d.packageDir !== \"string\") continue;\n\t\tconst root = nodeModulesRootOf(d.packageDir);\n\t\tif (root) {\n\t\t\troots.add(root);\n\t\t\tcontinue;\n\t\t}\n\t\tconst requires = d.requires?.length\n\t\t\t? ` Required packages: ${d.requires.join(\", \")}.`\n\t\t\t: \"\";\n\t\tthrow new Error(\n\t\t\t\"agentOs() could not auto-mount agent node_modules: agent \" +\n\t\t\t\t`packageDir ${d.packageDir} is not inside a node_modules install. ` +\n\t\t\t\t\"Run from an npm-installed package tree, or pass an explicit \" +\n\t\t\t\t\"nodeModulesMount(<absolute node_modules path>) in options.mounts.\" +\n\t\t\t\trequires,\n\t\t);\n\t}\n\n\tif (roots.size === 0) return mounts;\n\tif (roots.size > 1) {\n\t\tthrow new Error(\n\t\t\t\"agentOs() could not auto-mount agent node_modules: agents resolved to \" +\n\t\t\t\t`multiple node_modules roots (${[...roots].join(\", \")}). Pass an ` +\n\t\t\t\t\"explicit nodeModulesMount(...) in options.mounts.\",\n\t\t);\n\t}\n\n\tconst [hostNodeModulesDir] = [...roots];\n\treturn [...(mounts ?? []), nodeModulesMount(hostNodeModulesDir)];\n}\n\n/**\n * Stable identity for a software descriptor, used to de-duplicate the\n * auto-injected default bundle against software the caller passed explicitly.\n * Resolved `commandDir`/`packageDir` paths are the most reliable key; `name`\n * is the fallback for descriptors without a directory.\n */\nfunction softwareIdentity(d: SoftwareDescriptorLike): string {\n\tif (typeof d.commandDir === \"string\") return `dir:${d.commandDir}`;\n\tif (typeof d.packageDir === \"string\") return `dir:${d.packageDir}`;\n\tconst name = (d as { name?: unknown }).name;\n\tif (typeof name === \"string\") return `name:${name}`;\n\treturn JSON.stringify(d);\n}\n\nfunction flattenSoftware(input: unknown, out: SoftwareDescriptorLike[]): void {\n\tif (input == null) return;\n\tif (Array.isArray(input)) {\n\t\tfor (const item of input) flattenSoftware(item, out);\n\t\treturn;\n\t}\n\tif (typeof input === \"object\") out.push(input as SoftwareDescriptorLike);\n}\n\nexport function buildConfigJson<TConnParams>(\n\tparsed: AgentOsActorConfig<TConnParams>,\n): string {\n\tconst descriptors: SoftwareDescriptorLike[] = [];\n\tflattenSoftware(\n\t\t(parsed.options as { software?: unknown })?.software,\n\t\tdescriptors,\n\t);\n\n\t// Auto-include the default software bundle (`@agentos-software/common`: `sh` +\n\t// coreutils + the standard CLI tools agents rely on) unless the caller opted\n\t// out with `defaultSoftware: false`. Anything already listed in `software`\n\t// (e.g. an explicit `common`) is not duplicated. Prepended so the baseline\n\t// tools come first, matching the previous explicit `[common, ...]` ordering.\n\tconst defaultSoftwareEnabled =\n\t\t(parsed.options as { defaultSoftware?: unknown })?.defaultSoftware !== false;\n\tif (defaultSoftwareEnabled) {\n\t\tconst defaults: SoftwareDescriptorLike[] = [];\n\t\tflattenSoftware(common, defaults);\n\t\tconst seen = new Set(descriptors.map(softwareIdentity));\n\t\tconst toPrepend = defaults.filter((d) => !seen.has(softwareIdentity(d)));\n\t\tdescriptors.unshift(...toPrepend);\n\t}\n\n\tconst software: Array<{ package: string; kind?: string }> = [];\n\tfor (const d of descriptors) {\n\t\tif (typeof d.commandDir === \"string\") {\n\t\t\t// Wasm command directory (kind defaults to WasmCommands on the Rust side).\n\t\t\tsoftware.push({ package: d.commandDir });\n\t\t} else if (typeof d.packageDir === \"string\") {\n\t\t\t// Agent SDK / host-tool package: forwarded but not mounted as commands.\n\t\t\t// `kind` matches the kebab-case serde tags of the Rust `SoftwareKind`\n\t\t\t// enum (`wasm-commands` / `agent` / `tool`).\n\t\t\tsoftware.push({\n\t\t\t\tpackage: d.packageDir,\n\t\t\t\tkind: d.hostTool || d.toolkit ? \"tool\" : \"agent\",\n\t\t\t});\n\t\t}\n\t}\n\n\t// `/root/node_modules` (agent ACP adapter + SDK + transitive dep resolution)\n\t// is auto-derived from the agent descriptors so the standard quickstart needs\n\t// no manual `nodeModulesMount(...)`: see `withAutoAgentNodeModulesMount`. An\n\t// explicit `/root/node_modules` mount in `options.mounts` always wins. The VM\n\t// module resolver reads the mounted tree through the kernel VFS.\n\tconst options = (parsed.options ?? {}) as Record<string, unknown>;\n\tconst mounts = withAutoAgentNodeModulesMount(\n\t\tserializeNativeMounts(options.mounts),\n\t\tdescriptors,\n\t);\n\tconst sidecar = serializeSidecar(options.sidecar);\n\treturn JSON.stringify({\n\t\tsoftware,\n\t\tadditionalInstructions: options.additionalInstructions,\n\t\tloopbackExemptPorts: options.loopbackExemptPorts,\n\t\tallowedNodeBuiltins: options.allowedNodeBuiltins,\n\t\tpermissions: options.permissions,\n\t\trootFilesystem: options.rootFilesystem,\n\t\tmounts,\n\t\tlimits: options.limits,\n\t\tsidecar,\n\t});\n}\n\nfunction serializeNativeMounts(input: unknown): NativeMountLike[] | undefined {\n\tif (input == null) return undefined;\n\tif (!Array.isArray(input)) {\n\t\tthrow new Error(\"agentOs() options.mounts must be an array\");\n\t}\n\treturn input.map((mount, index) => {\n\t\tif (!mount || typeof mount !== \"object\") {\n\t\t\tthrow new Error(`agentOs() options.mounts[${index}] must be an object`);\n\t\t}\n\t\tconst record = mount as Record<string, unknown>;\n\t\tif (record.driver !== undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"agentOs() only supports Native mounts across the NAPI boundary; Plain mounts with driver callbacks are not serializable\",\n\t\t\t);\n\t\t}\n\t\tif (record.filesystem !== undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"agentOs() only supports Native mounts across the NAPI boundary; Overlay mounts are not serializable\",\n\t\t\t);\n\t\t}\n\t\tconst plugin = record.plugin;\n\t\tif (\n\t\t\ttypeof record.path !== \"string\" ||\n\t\t\t!plugin ||\n\t\t\ttypeof plugin !== \"object\" ||\n\t\t\ttypeof (plugin as Record<string, unknown>).id !== \"string\"\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`agentOs() options.mounts[${index}] must be a Native mount with { path, plugin: { id, config? } }`,\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tpath: record.path,\n\t\t\tplugin: {\n\t\t\t\tid: (plugin as Record<string, unknown>).id as string,\n\t\t\t\tconfig: (plugin as Record<string, unknown>).config,\n\t\t\t},\n\t\t\treadOnly:\n\t\t\t\ttypeof record.readOnly === \"boolean\" ? record.readOnly : undefined,\n\t\t};\n\t});\n}\n\nfunction serializeSidecar(input: unknown): { pool?: string } | undefined {\n\tif (input == null) return undefined;\n\tif (!input || typeof input !== \"object\") {\n\t\tthrow new Error(\"agentOs() options.sidecar must be an object\");\n\t}\n\tconst record = input as Record<string, unknown>;\n\tif (record.kind === \"explicit\" || record.handle !== undefined) {\n\t\tthrow new Error(\n\t\t\t\"agentOs() only supports sidecar shared pool configuration across the NAPI boundary; explicit sidecar handles are not serializable\",\n\t\t);\n\t}\n\tif (record.kind !== undefined && record.kind !== \"shared\") {\n\t\tthrow new Error('agentOs() options.sidecar.kind must be \"shared\"');\n\t}\n\treturn typeof record.pool === \"string\" ? { pool: record.pool } : {};\n}\n\nfunction buildNativeFactoryBuilder<TConnParams>(\n\tparsed: AgentOsActorConfig<TConnParams>,\n): (runtime: CoreRuntime) => ActorFactoryHandle {\n\treturn (runtime) => {\n\t\tif (runtime.kind !== \"napi\") {\n\t\t\tthrow new Error(\n\t\t\t\t`agentOs() is only supported on the native NAPI runtime (current runtime kind: ${runtime.kind})`,\n\t\t\t);\n\t\t}\n\t\tif (!runtime.createNativePluginFactory) {\n\t\t\tthrow new Error(\n\t\t\t\t\"runtime.createNativePluginFactory is not implemented on the active CoreRuntime\",\n\t\t\t);\n\t\t}\n\t\tconst options: NapiNativePluginOptions = {\n\t\t\t// Resolve the prebuilt agent-os actor plugin cdylib; RivetKit `dlopen`s\n\t\t\t// it through the generic native-plugin ABI.\n\t\t\tpluginPath: getPluginPath(),\n\t\t\t// Opaque config envelope the plugin parses (config.rs::AgentOsConfigJson).\n\t\t\tconfigJson: buildConfigJson(parsed),\n\t\t\t// Resolve the prebuilt sidecar binary from the npm package so the plugin\n\t\t\t// spawns the bundled binary rather than relying on `agentos-sidecar`\n\t\t\t// being on PATH.\n\t\t\tsidecarPath: getSidecarPath(),\n\t\t};\n\t\treturn runtime.createNativePluginFactory(options);\n\t};\n}\n\n/**\n * Type alias for the `agentOs(...)` return type. Events are not typed at the\n * TS surface because the Rust plugin owns the broadcast set and the\n * test/client surface uses `any` for actions.\n */\nexport type AgentOsActorDefinition<TConnParams> = ActorDefinition<\n\tAgentOsActorState,\n\tTConnParams,\n\tundefined,\n\tAgentOsActorVars,\n\tundefined,\n\tDatabaseProvider<RawAccess>,\n\tRecord<never, never>,\n\tRecord<never, never>,\n\tany\n>;\n\nexport function agentOs<TConnParams = undefined>(\n\tconfig: AgentOsActorConfigInput<TConnParams>,\n): AgentOsActorDefinition<TConnParams> {\n\tconst parsed = agentOsActorConfigSchema.parse(\n\t\tconfig,\n\t) as AgentOsActorConfig<TConnParams>;\n\n\t// Construct a minimal definition through the existing actor() helper, then\n\t// attach the Rust factory builder marker. The actions block stays empty\n\t// because no JS-side action ever runs: the engine driver branches on\n\t// `nativeFactoryBuilder` before reaching the JS dispatch path.\n\tconst actorOptions = (parsed as { actorOptions?: Record<string, unknown> })\n\t\t.actorOptions;\n\tconst definition = actor({\n\t\tactions: {},\n\t\t...(actorOptions ? { options: actorOptions } : {}),\n\t} as Parameters<\n\t\ttypeof actor\n\t>[0]) as unknown as AgentOsActorDefinition<TConnParams>;\n\tdefinition.nativeFactoryBuilder = buildNativeFactoryBuilder(parsed);\n\treturn definition;\n}\n","import type {\n\tAgentOsOptions,\n\tJsonRpcNotification,\n\tPermissionRequest,\n} from \"@rivet-dev/agentos-core\";\nimport type { ActorContext, BeforeConnectContext } from \"rivetkit\";\nimport { z } from \"zod/v4\";\nimport type { AgentOsActorState, AgentOsActorVars } from \"./types.js\";\n\nconst zFunction = <\n\tT extends (...args: any[]) => any = (...args: unknown[]) => unknown,\n>() => z.custom<T>((val) => typeof val === \"function\");\n\nconst AgentOsOptionsSchema = z.custom<AgentOsOptions>(\n\t(val) => typeof val === \"object\" && val !== null,\n);\n\nexport const agentOsActorConfigSchema = z\n\t.object({\n\t\toptions: AgentOsOptionsSchema.optional(),\n\t\tpreview: z\n\t\t\t.object({\n\t\t\t\tdefaultExpiresInSeconds: z.number().positive().default(3600),\n\t\t\t\tmaxExpiresInSeconds: z.number().positive().default(86400),\n\t\t\t})\n\t\t\t.strict()\n\t\t\t.prefault(() => ({})),\n\t\tonBeforeConnect: zFunction().optional(),\n\t\tonSessionEvent: zFunction().optional(),\n\t\tonPermissionRequest: zFunction().optional(),\n\t})\n\t.strict();\n\n// --- Typed config types (generic callbacks overlaid on the Zod schema) ---\n\ntype AgentOsActorContext<TConnParams> = ActorContext<\n\tAgentOsActorState,\n\tTConnParams,\n\tundefined,\n\tAgentOsActorVars,\n\tundefined,\n\tany\n>;\n\ninterface AgentOsActorConfigCallbacks<TConnParams> {\n\tonBeforeConnect?: (\n\t\tc: BeforeConnectContext<\n\t\t\tAgentOsActorState,\n\t\t\tAgentOsActorVars,\n\t\t\tundefined,\n\t\t\tany\n\t\t>,\n\t\tparams: TConnParams,\n\t) => void | Promise<void>;\n\tonSessionEvent?: (\n\t\tc: AgentOsActorContext<TConnParams>,\n\t\tsessionId: string,\n\t\tevent: JsonRpcNotification,\n\t) => void | Promise<void>;\n\tonPermissionRequest?: (\n\t\tc: AgentOsActorContext<TConnParams>,\n\t\tsessionId: string,\n\t\trequest: PermissionRequest,\n\t) => void | Promise<void>;\n}\n\n// Parsed config (after Zod defaults/transforms applied).\nexport type AgentOsActorConfig<TConnParams = undefined> = Omit<\n\tz.infer<typeof agentOsActorConfigSchema>,\n\t\"onBeforeConnect\" | \"onSessionEvent\" | \"onPermissionRequest\"\n> &\n\tAgentOsActorConfigCallbacks<TConnParams>;\n\n// Input config (what users pass in before Zod transforms).\nexport type AgentOsActorConfigInput<TConnParams = undefined> = Omit<\n\tz.input<typeof agentOsActorConfigSchema>,\n\t\"onBeforeConnect\" | \"onSessionEvent\" | \"onPermissionRequest\"\n> &\n\tAgentOsActorConfigCallbacks<TConnParams>;\n","// Platform-specific resolver for the prebuilt agent-os actor plugin cdylib\n// (`libagentos_actor_plugin.{so,dylib,dll}`). Mirrors the sidecar-binary\n// resolver (`@rivet-dev/agentos-sidecar`): the library ships inside one of the\n// `@rivet-dev/agentos-plugin-<platform>` packages, declared as\n// optionalDependencies so npm installs only the one matching the current\n// `os`/`cpu`/`libc` at install time (spec phase 6).\n//\n// Resolution priority:\n// 1. `AGENTOS_PLUGIN_BIN` env var (absolute path override).\n// 2. A cargo build output under the repo `target/{release,debug}/` (dev).\n// 3. The platform-specific `@rivet-dev/agentos-plugin-<platform>` package.\n\nimport { existsSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst PLUGIN_BIN_ENV = \"AGENTOS_PLUGIN_BIN\";\n\n/** The cdylib filename for the current platform. */\nfunction libraryName(): string {\n\tswitch (process.platform) {\n\t\tcase \"darwin\":\n\t\t\treturn \"libagentos_actor_plugin.dylib\";\n\t\tcase \"win32\":\n\t\t\treturn \"agentos_actor_plugin.dll\";\n\t\tdefault:\n\t\t\treturn \"libagentos_actor_plugin.so\";\n\t}\n}\n\nfunction getPlatformPackageName(): string | null {\n\tconst { platform, arch } = process;\n\tswitch (platform) {\n\t\tcase \"linux\":\n\t\t\tif (arch === \"x64\") return \"@rivet-dev/agentos-plugin-linux-x64-gnu\";\n\t\t\tif (arch === \"arm64\") return \"@rivet-dev/agentos-plugin-linux-arm64-gnu\";\n\t\t\tbreak;\n\t\tcase \"darwin\":\n\t\t\tif (arch === \"x64\") return \"@rivet-dev/agentos-plugin-darwin-x64\";\n\t\t\tif (arch === \"arm64\") return \"@rivet-dev/agentos-plugin-darwin-arm64\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\treturn null;\n}\n\n/**\n * Resolve the absolute path to the agent-os actor plugin cdylib. RivetKit\n * `dlopen`s this path through the generic native-plugin ABI.\n */\nexport function getPluginPath(): string {\n\tconst override = process.env[PLUGIN_BIN_ENV];\n\tif (override) {\n\t\tif (!existsSync(override)) {\n\t\t\tthrow new Error(\n\t\t\t\t`${PLUGIN_BIN_ENV} is set to ${override} but the file does not exist`,\n\t\t\t);\n\t\t}\n\t\treturn override;\n\t}\n\n\tconst lib = libraryName();\n\n\t// Dev: a cargo build output under the repo `target/`. `import.meta.url` is\n\t// `packages/agentos/dist/plugin-binary.js`, so the repo root is three levels up.\n\tconst here = dirname(fileURLToPath(import.meta.url));\n\tfor (const profile of [\"release\", \"debug\"]) {\n\t\tconst candidate = join(here, \"..\", \"..\", \"..\", \"target\", profile, lib);\n\t\tif (existsSync(candidate)) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\t// Prod: the platform-specific package.\n\tconst platformPkg = getPlatformPackageName();\n\tif (!platformPkg) {\n\t\tthrow new Error(\n\t\t\t`@rivet-dev/agentos: unsupported platform ${process.platform}/${process.arch}. ` +\n\t\t\t\t\"The Agent OS actor plugin currently supports linux and darwin on x64 and arm64. \" +\n\t\t\t\t`Set ${PLUGIN_BIN_ENV} to a local cdylib to override.`,\n\t\t);\n\t}\n\n\tconst require = createRequire(import.meta.url);\n\tlet pkgJsonPath: string;\n\ttry {\n\t\tpkgJsonPath = require.resolve(`${platformPkg}/package.json`);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t`@rivet-dev/agentos: platform package ${platformPkg} is not installed.\\n` +\n\t\t\t\t\"This usually means the platform is unsupported or optionalDependencies\\n\" +\n\t\t\t\t`were skipped during install. Try: npm install --include=optional ${platformPkg}\\n` +\n\t\t\t\t`Or set ${PLUGIN_BIN_ENV} to a local cdylib, or build it with\\n` +\n\t\t\t\t\"`cargo build -p agentos-actor-plugin`.\",\n\t\t);\n\t}\n\n\treturn join(dirname(pkgJsonPath), lib);\n}\n","// Rust-backed agent-os actor surface (native actor plugin / cdylib).\n//\n// Only the `agentOs()` definition function, the config schema, the\n// `nodeModulesMount` helper, the plugin-path resolver, and the public domain\n// types are exported. All actor lifecycle + action dispatch live in the Rust\n// plugin (`crates/agentos-actor-plugin`), loaded by RivetKit via the generic\n// native-plugin ABI.\n\nimport {\n\tagentOs as createAgentOs,\n\ttype AgentOsActorDefinition,\n} from \"./actor.js\";\nimport type { AgentOsActorConfigInput } from \"./config.js\";\n\nexport { setup } from \"rivetkit\";\n\nexport {\n\tbuildConfigJson,\n\tnodeModulesMount,\n\ttype NodeModulesMountConfig,\n} from \"./actor.js\";\nexport { createAgentOs as agentOs };\n\nexport {\n\ttype AgentOsActorConfig,\n\ttype AgentOsActorConfigInput,\n\tagentOsActorConfigSchema,\n} from \"./config.js\";\n\nexport { getPluginPath } from \"./plugin-binary.js\";\n\nexport type {\n\tAgentOsActionContext,\n\tAgentOsActorState,\n\tAgentOsActorVars,\n\tAgentOsEvents,\n\tCronEventPayload,\n\tPermissionRequestPayload,\n\tPersistedSessionEvent,\n\tPersistedSessionRecord,\n\tProcessExitPayload,\n\tProcessOutputPayload,\n\tPromptResult,\n\tSerializableCronAction,\n\tSerializableCronJobInfo,\n\tSerializableCronJobOptions,\n\tSessionEventPayload,\n\tSessionRecord,\n\tShellDataPayload,\n\tVmBootedPayload,\n\tVmShutdownPayload,\n} from \"./types.js\";\n\nexport type AgentOSActorConfigInput<TConnParams = undefined> =\n\tAgentOsActorConfigInput<TConnParams>[\"options\"];\n\nexport function agentOS<TConnParams = undefined>(\n\tconfig: AgentOSActorConfigInput<TConnParams> = {},\n): AgentOsActorDefinition<TConnParams> {\n\treturn createAgentOs({\n\t\toptions: config,\n\t} as AgentOsActorConfigInput<TConnParams>);\n}\n"],"mappings":";AAYA,SAAS,WAAW;AACpB,OAAO,YAAY;AACnB,SAAS,sBAAsB;AAC/B;AAAA,EACC;AAAA,OAOM;;;ACjBP,SAAS,SAAS;AAGlB,IAAM,YAAY,MAEX,EAAE,OAAU,CAAC,QAAQ,OAAO,QAAQ,UAAU;AAErD,IAAM,uBAAuB,EAAE;AAAA,EAC9B,CAAC,QAAQ,OAAO,QAAQ,YAAY,QAAQ;AAC7C;AAEO,IAAM,2BAA2B,EACtC,OAAO;AAAA,EACP,SAAS,qBAAqB,SAAS;AAAA,EACvC,SAAS,EACP,OAAO;AAAA,IACP,yBAAyB,EAAE,OAAO,EA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AAA,MAIlC,aAAa,eAAe;AAAA,IAC7B;AACA,WAAO,QAAQ,0BAA0B,OAAO;AAAA,EACjD;AACD;AAmBO,SAAS,QACf,QACsC;AACtC,QAAM,SAAS,yBAAyB;AAAA,IACvC;AAAA,EACD;AAMA,QAAM,eAAgB,OACpB;AACF,QAAM,aAAa,MAAM;AAAA,IACxB,SAAS,CAAC;AAAA,IACV,GAAI,eAAe,EAAE,SAAS,aAAa,IAAI,CAAC;AAAA,EACjD,CAEI;AACJ,aAAW,uBAAuB,0BAA0B,MAAM;AAClE,SAAO;AACR;;;AG/WA,SAAS,aAAa;AA0Cf,SAAS,QACf,SAA+C,CAAC,GACV;AACtC,SAAO,QAAc;AAAA,IACpB,SAAS;AAAA,EACV,CAAyC;AAC1C;","names":["require"]}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@rivet-dev/agentos",
3
- "version": "0.0.0-nathan-binding-workspace.4640d5c",
4
- "description": "User-facing Agent OS integration for RivetKit actors (interim types-now noop stub)",
3
+ "version": "0.0.0-nathan-binding-workspace.abc7ec9",
4
+ "description": "Agent OS actor for RivetKit - thin TS forwarder that loads the native actor plugin via RivetKit's native-plugin ABI.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
7
7
  "rivetkit",
8
- "agentos",
8
+ "agent-os",
9
9
  "agentos",
10
10
  "agents",
11
11
  "actors",
@@ -14,18 +14,15 @@
14
14
  "sideEffects": false,
15
15
  "files": [
16
16
  "dist",
17
- "package.json"
17
+ "package.json",
18
+ "README.md"
18
19
  ],
19
20
  "type": "module",
20
21
  "exports": {
21
22
  ".": {
22
23
  "import": {
23
- "types": "./dist/mod.d.ts",
24
- "default": "./dist/mod.js"
25
- },
26
- "require": {
27
- "types": "./dist/mod.d.cts",
28
- "default": "./dist/mod.cjs"
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
29
26
  }
30
27
  },
31
28
  "./client": {
@@ -36,20 +33,12 @@
36
33
  },
37
34
  "types": "./dist/client.d.ts",
38
35
  "default": "./dist/client.js"
39
- },
40
- "require": {
41
- "types": "./dist/client.d.cts",
42
- "default": "./dist/client.cjs"
43
36
  }
44
37
  },
45
38
  "./react": {
46
39
  "import": {
47
40
  "types": "./dist/react.d.ts",
48
41
  "default": "./dist/react.js"
49
- },
50
- "require": {
51
- "types": "./dist/react.d.cts",
52
- "default": "./dist/react.cjs"
53
42
  }
54
43
  }
55
44
  },
@@ -57,12 +46,17 @@
57
46
  "node": ">=22.0.0"
58
47
  },
59
48
  "scripts": {
60
- "build": "tsup src/mod.ts src/client.ts src/react.ts",
61
- "check-types": "tsc --noEmit"
49
+ "build": "tsup src/index.ts src/client.ts src/react.ts",
50
+ "check-types": "tsc --noEmit",
51
+ "test": "vitest run"
62
52
  },
63
53
  "dependencies": {
64
- "rivetkit": "2.3.0-rc.12",
65
- "@rivetkit/react": "2.3.0-rc.12"
54
+ "@agentos-software/common": "0.3.0-rc.2",
55
+ "@rivet-dev/agentos-core": "0.0.0-nathan-binding-workspace.abc7ec9",
56
+ "@rivet-dev/agentos-sidecar": "0.0.0-nathan-binding-workspace.abc7ec9",
57
+ "@rivetkit/react": "0.0.0-feat-dylib-actor-plugin.c44621f",
58
+ "rivetkit": "0.0.0-feat-dylib-actor-plugin.c44621f",
59
+ "zod": "^4.1.11"
66
60
  },
67
61
  "peerDependencies": {
68
62
  "react": "^18 || ^19",
@@ -77,7 +71,15 @@
77
71
  }
78
72
  },
79
73
  "devDependencies": {
74
+ "@types/node": "^22.19.15",
80
75
  "tsup": "^8.4.0",
81
- "typescript": "^5.7.3"
76
+ "typescript": "^5.7.3",
77
+ "vitest": "^2.1.8"
78
+ },
79
+ "optionalDependencies": {
80
+ "@rivet-dev/agentos-plugin-darwin-arm64": "0.0.0-nathan-binding-workspace.abc7ec9",
81
+ "@rivet-dev/agentos-plugin-darwin-x64": "0.0.0-nathan-binding-workspace.abc7ec9",
82
+ "@rivet-dev/agentos-plugin-linux-arm64-gnu": "0.0.0-nathan-binding-workspace.abc7ec9",
83
+ "@rivet-dev/agentos-plugin-linux-x64-gnu": "0.0.0-nathan-binding-workspace.abc7ec9"
82
84
  }
83
85
  }