@rivet-dev/agentos 0.0.0-integrate-dylib-into-main.815fcda → 0.0.0-nathan-binding-workspace.4640d5c
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/dist/client.cjs +25 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +2 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -0
- package/dist/mod.cjs +134 -0
- package/dist/mod.cjs.map +1 -0
- package/dist/mod.d.cts +594 -0
- package/dist/mod.d.ts +594 -0
- package/dist/mod.js +107 -0
- package/dist/mod.js.map +1 -0
- package/dist/react.cjs +25 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +3 -0
- package/dist/react.js.map +1 -0
- package/package.json +64 -31
- package/dist/actor.d.ts +0 -52
- package/dist/actor.js +0 -252
- package/dist/config.d.ts +0 -23
- package/dist/config.js +0 -18
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -10
- package/dist/plugin-binary.d.ts +0 -5
- package/dist/plugin-binary.js +0 -84
- package/dist/types.d.ts +0 -102
- package/dist/types.js +0 -1
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mod.ts"],"sourcesContent":["/**\n * `@rivet-dev/agentos` — the user-facing Agent OS integration for RivetKit.\n *\n * INTERIM \"types-now, noop-the-runtime\" STUB.\n *\n * This package owns the Agent OS-specific TypeScript surface (config schema\n * type, events, the actor-definition type, the `vm.*` action interface, and\n * the `nodeModulesMount` helper) and imports only GENERIC primitives (the\n * actor definition / registry / action context) from `rivetkit`.\n *\n * The runtime is intentionally NOT wired: `agentOS()` returns a correctly\n * typed RivetKit actor definition whose action handler bodies THROW. This\n * lets consumers (examples, downstream packages) type-check against the real\n * shape before the native runtime (dylib) lands, without pulling in any napi\n * / native module. When the dylib is ready, swap the throwing handlers for\n * the native factory builder — the public types do not change.\n */\n\nimport { actor, type ActorDefinition, event, type Type } from \"rivetkit\";\n\n// Re-export the RivetKit registry builder so consumers import everything they\n// need from `@rivet-dev/agentos` and never reach for `rivetkit` directly.\nexport { setup } from \"rivetkit\";\n\n// ---------------------------------------------------------------------------\n// Owned ACP / Agent OS primitive shapes\n//\n// These mirror the structural shape of the types that the real integration\n// imports from `@rivet-dev/agentos-core`. They are deliberately owned here\n// (rather than imported) so this package stays self-contained on `rivetkit`\n// + `@rivetkit/react` until the runtime is wired. Swap them for the core\n// package's canonical types when the dylib lands.\n// ---------------------------------------------------------------------------\n\n/** A JSON-RPC notification frame emitted by the ACP adapter. */\nexport interface JsonRpcNotification {\n\tjsonrpc: \"2.0\";\n\tmethod: string;\n\tparams?: unknown;\n}\n\n/** A JSON-RPC response frame returned by the ACP adapter. */\nexport interface JsonRpcResponse {\n\tjsonrpc: \"2.0\";\n\tid: number | string;\n\tresult?: unknown;\n\terror?: { code: number; message: string; data?: unknown };\n}\n\n/** A permission request surfaced by the agent to the host. */\nexport interface PermissionRequest {\n\t/** Stable id used to reply to this specific request via `respondPermission`. */\n\tpermissionId: string;\n\t/** Optional human-readable description of what is being requested. */\n\tdescription?: string;\n\t/** Raw ACP permission params (tool name, input, options, etc.). */\n\tparams?: Record<string, unknown>;\n\t/** @deprecated legacy alias retained for older docs snippets. */\n\ttoolName?: string;\n\t/** @deprecated legacy alias retained for older docs snippets. */\n\trationale?: string;\n\t/** @deprecated legacy alias retained for older docs snippets. */\n\tinput?: unknown;\n}\n\n/** Reply to a permission request: allow once, allow always, or reject. */\nexport type PermissionReply = \"once\" | \"always\" | \"reject\";\n\n/** One selectable agent mode (e.g. \"plan\", \"auto\"). */\nexport interface SessionMode {\n\tid: string;\n\tname?: string;\n\tlabel?: string;\n\tdescription?: string;\n\t[key: string]: unknown;\n}\n\n/** The set of modes available to a session plus the current selection. */\nexport interface SessionModeState {\n\tcurrentModeId: string;\n\tavailableModes: SessionMode[];\n}\n\n/** A configurable session option (model, thought level, etc.). */\nexport interface SessionConfigOption {\n\tid: string;\n\tcategory?: string;\n\tlabel?: string;\n\tdescription?: string;\n\tcurrentValue?: string;\n\tallowedValues?: Array<{ id: string; label?: string }>;\n\treadOnly?: boolean;\n}\n\n/** Capabilities advertised by an ACP agent during initialization. */\nexport interface AgentCapabilities {\n\tloadSession?: boolean;\n\tpromptCapabilities?: Record<string, unknown>;\n\t[key: string]: unknown;\n}\n\n/** Identity metadata advertised by an ACP agent. */\nexport interface AgentInfo {\n\tname: string;\n\tversion?: string;\n\t[key: string]: unknown;\n}\n\n/** A cron tick delivered to the actor. */\nexport interface CronEvent {\n\tid: string;\n\tschedule: string;\n\tfiredAt: number;\n}\n\n// ---------------------------------------------------------------------------\n// Filesystem primitives (mirror core's runtime-compat / agentos shapes)\n// ---------------------------------------------------------------------------\n\n/** POSIX-style stat record returned by `stat`. */\nexport interface VirtualStat {\n\tmode: number;\n\tsize: number;\n\tblocks: number;\n\tdev: number;\n\trdev: number;\n\tisDirectory: boolean;\n\tisSymbolicLink: boolean;\n\tatimeMs: number;\n\tmtimeMs: number;\n\tctimeMs: number;\n\tbirthtimeMs: number;\n\tino: number;\n\tnlink: number;\n\tuid: number;\n\tgid: number;\n}\n\n/** A directory entry with metadata (returned by `readdirRecursive`). */\nexport interface DirEntry {\n\t/** Absolute path to the entry. */\n\tpath: string;\n\ttype: \"file\" | \"directory\" | \"symlink\";\n\tsize: number;\n}\n\n/** Options for `readdirRecursive`. */\nexport interface ReaddirRecursiveOptions {\n\t/** Maximum depth to recurse (0 = only immediate children). */\n\tmaxDepth?: number;\n\t/** Directory names to skip. */\n\texclude?: string[];\n}\n\n/** A single file in a batch write (`writeFiles`). */\nexport interface BatchWriteEntry {\n\tpath: string;\n\tcontent: string | Uint8Array;\n}\n\n/** Result of a single file in a batch write. */\nexport interface BatchWriteResult {\n\tpath: string;\n\tsuccess: boolean;\n\terror?: string;\n}\n\n/** Result of a single file in a batch read (`readFiles`). */\nexport interface BatchReadResult {\n\tpath: string;\n\tcontent: Uint8Array | null;\n\terror?: string;\n}\n\n/** A single entry in an exported root filesystem snapshot. */\nexport interface FilesystemEntry {\n\tpath: string;\n\ttype: \"file\" | \"directory\" | \"symlink\";\n\tmode: string;\n\tuid: number;\n\tgid: number;\n\tcontent?: string;\n\tencoding?: \"utf8\" | \"base64\";\n\ttarget?: string;\n}\n\n/** A serializable export of the VM root filesystem. */\nexport interface RootSnapshotExport {\n\tkind: \"snapshot-export\";\n\tsource: {\n\t\tformat: \"agentos-filesystem-snapshot-v1\";\n\t\tfilesystem: { entries: FilesystemEntry[] };\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Process + shell primitives\n// ---------------------------------------------------------------------------\n\n/** Options for `exec` / `execArgv`. */\nexport interface ExecOptions {\n\tenv?: Record<string, string>;\n\tcwd?: string;\n\tstdin?: string | Uint8Array;\n\ttimeout?: number;\n\tcaptureStdio?: boolean;\n}\n\n/** Result of a synchronous `exec` / `execArgv`. */\nexport interface ExecResult {\n\texitCode: number;\n\tstdout: string;\n\tstderr: string;\n}\n\n/** Options for `spawn`. */\nexport interface SpawnOptions {\n\tenv?: Record<string, string>;\n\tcwd?: string;\n\tstdin?: string | Uint8Array;\n}\n\n/** Info about a process spawned via `spawn`. */\nexport interface SpawnedProcessInfo {\n\tpid: number;\n\tcommand: string;\n\targs: string[];\n\trunning: boolean;\n\texitCode: number | null;\n}\n\n/** Options for `openShell` / `connectTerminal`. */\nexport interface OpenShellOptions {\n\tcommand?: string;\n\targs?: string[];\n\tenv?: Record<string, string>;\n\tcwd?: string;\n\tcols?: number;\n\trows?: number;\n}\n\n/** Options for `connectTerminal` (a shell plus a streaming data callback). */\nexport interface ConnectTerminalOptions extends OpenShellOptions {\n\tonData?: (data: Uint8Array) => void;\n}\n\n// ---------------------------------------------------------------------------\n// Networking + preview URLs\n// ---------------------------------------------------------------------------\n\n/** Options for `vmFetch` (method/headers/body for the proxied request). */\nexport interface VmFetchOptions {\n\tmethod?: string;\n\theaders?: Record<string, string>;\n\tbody?: string | Uint8Array;\n}\n\n/** Response returned by `vmFetch`. */\nexport interface VmFetchResponse {\n\tstatus: number;\n\tstatusText?: string;\n\theaders?: Array<[string, string]>;\n\tbody: Uint8Array;\n}\n\n/** A time-limited, token-based preview URL for a VM port. */\nexport interface PreviewUrl {\n\t/** Signed path (including token query) to proxy to the VM port. */\n\tpath: string;\n\t/** Opaque signed token authorizing the proxy. */\n\ttoken: string;\n\t/** Epoch millis at which the token expires. */\n\texpiresAt: number;\n}\n\n// ---------------------------------------------------------------------------\n// Session event replay\n// ---------------------------------------------------------------------------\n\n/** An in-memory session event with its monotonic sequence number. */\nexport interface SequencedSessionEvent {\n\tsequenceNumber: number;\n\tnotification: JsonRpcNotification;\n}\n\n/** Options for `getSequencedEvents` (replay in-memory events after `since`). */\nexport interface GetSequencedEventsOptions {\n\t/** Return only events with a sequence number greater than this value. */\n\tsince?: number;\n}\n\n/**\n * Serializable Agent OS VM options. These fields are accepted at the top level\n * of `agentOS({ ... })` (see `AgentOSActorConfigInput`); this type collects\n * them for callers that want to build the option set as a standalone value.\n *\n * Kept structurally open: the full option set is owned by the sidecar/native\n * layer and forwarded across the boundary, so consumers configure it as data.\n */\nexport interface AgentOSOptions {\n\tsoftware?: unknown;\n\tadditionalInstructions?: string;\n\tloopbackExemptPorts?: number[];\n\tallowedNodeBuiltins?: string[];\n\tpermissions?: unknown;\n\trootFilesystem?: unknown;\n\tmounts?: unknown[];\n\tlimits?: unknown;\n\tsidecar?: unknown;\n\t[key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Mounts\n// ---------------------------------------------------------------------------\n\n/**\n * A native `host_dir` mount of a host `node_modules` directory at\n * `/root/node_modules`.\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 * @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// Actor state / vars\n// ---------------------------------------------------------------------------\n\n// biome-ignore lint/complexity/noBannedTypes: empty state placeholder\nexport type AgentOSActorState = {};\n\nexport interface AgentOSActorVars {\n\tactiveSessionIds: Set<string>;\n\tactiveProcesses: Set<number>;\n\tactiveShells: Set<string>;\n\tsessions: Set<string>;\n}\n\n// ---------------------------------------------------------------------------\n// Event payloads + schema map\n// ---------------------------------------------------------------------------\n\nexport interface SessionEventPayload {\n\tsessionId: string;\n\tevent: JsonRpcNotification;\n}\n\nexport interface PermissionRequestPayload {\n\tsessionId: string;\n\trequest: PermissionRequest;\n}\n\nexport type VmBootedPayload = Record<string, never>;\n\nexport interface VmShutdownPayload {\n\treason: \"sleep\" | \"destroy\" | \"error\";\n}\n\nexport interface ProcessOutputPayload {\n\tpid: number;\n\tstream: \"stdout\" | \"stderr\";\n\tdata: Uint8Array;\n}\n\nexport interface ProcessExitPayload {\n\tpid: number;\n\texitCode: number;\n}\n\nexport interface ShellDataPayload {\n\tshellId: string;\n\tdata: Uint8Array;\n}\n\nexport interface CronEventPayload {\n\tevent: CronEvent;\n}\n\n/**\n * Event schema map consumed by the actor `events` config.\n *\n * Built with RivetKit's `event<T>()` helper so each entry is a valid\n * `EventSchema` (an `EventTypeToken` carrying the payload type). This lets the\n * actor definition satisfy RivetKit's `EventSchemaConfig` while\n * `conn.on(name, cb)` infers the payload for each event with no casts.\n */\n// `event<T>()` returns RivetKit's internal `EventTypeToken<T>`, which is not\n// part of the public type surface and therefore \"cannot be named\" in the\n// generated `.d.ts` (tsup dts rollup → TS4023). `Type<T>` is the exported\n// public alias for that same token, so annotating through it keeps per-event\n// payload inference while emitting a nameable type.\nconst typedEvent = <T>(): Type<T> => event<T>();\n\nconst agentOSEvents = {\n\tsessionEvent: typedEvent<SessionEventPayload>(),\n\tpermissionRequest: typedEvent<PermissionRequestPayload>(),\n\tvmBooted: typedEvent<VmBootedPayload>(),\n\tvmShutdown: typedEvent<VmShutdownPayload>(),\n\tprocessOutput: typedEvent<ProcessOutputPayload>(),\n\tprocessExit: typedEvent<ProcessExitPayload>(),\n\tshellData: typedEvent<ShellDataPayload>(),\n\tcronEvent: typedEvent<CronEventPayload>(),\n};\n\n/** Event schema map type for the actor `events` config (payload-inferring). */\nexport type AgentOSEvents = typeof agentOSEvents;\n\n// ---------------------------------------------------------------------------\n// Session + prompt records\n// ---------------------------------------------------------------------------\n\nexport interface PromptResult {\n\tresponse: JsonRpcResponse;\n\ttext: string;\n}\n\nexport interface SessionRecord {\n\tsessionId: string;\n\tagentType: string;\n\tcapabilities: AgentCapabilities;\n\tagentInfo: AgentInfo | null;\n}\n\nexport interface PersistedSessionRecord extends SessionRecord {\n\tcreatedAt: number;\n}\n\nexport interface PersistedSessionEvent {\n\tsessionId: string;\n\tseq: number;\n\tevent: JsonRpcNotification;\n\tcreatedAt: number;\n}\n\n// ---------------------------------------------------------------------------\n// Cron\n// ---------------------------------------------------------------------------\n\nexport type SerializableCronAction =\n\t| {\n\t\t\ttype: \"session\";\n\t\t\tagentType: string;\n\t\t\tprompt: string;\n\t\t\t/** Session options applied when the cron fires (cwd, env, etc.). */\n\t\t\toptions?: CreateSessionOptions;\n\t }\n\t| { type: \"exec\"; command: string; args?: string[] };\n\nexport interface SerializableCronJobOptions {\n\tid?: string;\n\tschedule: string;\n\taction: SerializableCronAction;\n\toverlap?: \"allow\" | \"skip\" | \"queue\";\n}\n\n/** Result of scheduling a cron job. */\nexport interface ScheduledCronJob {\n\tid: string;\n}\n\n/** Info about a registered cron job (returned by `listCronJobs`). */\nexport interface CronJobInfo {\n\tid: string;\n\tschedule: string;\n\taction: SerializableCronAction;\n\toverlap: \"allow\" | \"skip\" | \"queue\";\n}\n\n// ---------------------------------------------------------------------------\n// Config\n// ---------------------------------------------------------------------------\n\n/**\n * Input config passed to `agentOS(...)`.\n *\n * The VM option fields live at the TOP LEVEL (no nested `options` key), so\n * callers write `agentOS({ software: [...], additionalInstructions: \"...\" })`.\n */\nexport interface AgentOSActorConfigInput<TConnParams = undefined> {\n\t/**\n\t * Software packages to install in the VM. Pass the imported packages\n\t * directly (e.g. `software: [common, pi]`); kept loosely typed so any\n\t * software package import type-checks.\n\t */\n\tsoftware?: unknown[];\n\t/** Additional instructions appended to the base OS instructions. */\n\tadditionalInstructions?: string;\n\t/** Ports exempt from the loopback-only network restriction. */\n\tloopbackExemptPorts?: number[];\n\t/** Node.js builtins the guest is allowed to import. */\n\tallowedNodeBuiltins?: string[];\n\t/** Permission policy applied to the VM. */\n\tpermissions?: unknown;\n\t/** Root filesystem configuration / snapshot. */\n\trootFilesystem?: unknown;\n\t/** Host-backed mounts exposed inside the VM. */\n\tmounts?: unknown[];\n\t/** Bindings exposed to agents as CLI commands inside the VM. */\n\tbindings?: unknown[];\n\t/** Per-VM resource limits. */\n\tlimits?: unknown;\n\t/** Low-level runtime configuration. */\n\tsidecar?: unknown;\n\tpreview?: {\n\t\tdefaultExpiresInSeconds?: number;\n\t\tmaxExpiresInSeconds?: number;\n\t};\n\tonSessionEvent?: (\n\t\tsessionId: string,\n\t\tevent: JsonRpcNotification,\n\t) => void | Promise<void>;\n\tonPermissionRequest?: (\n\t\tsessionId: string,\n\t\trequest: PermissionRequest,\n\t) => void | Promise<void>;\n\t// Reserved for parity with the native config's typed connection params.\n\t__connParams?: TConnParams;\n}\n\n/** Parsed config (after defaults applied). */\nexport interface AgentOSActorConfig<TConnParams = undefined>\n\textends AgentOSActorConfigInput<TConnParams> {\n\tpreview: { defaultExpiresInSeconds: number; maxExpiresInSeconds: number };\n}\n\n// ---------------------------------------------------------------------------\n// MCP servers + session options (mirrors @rivet-dev/agentos-core's\n// CreateSessionOptions / McpServerConfig)\n// ---------------------------------------------------------------------------\n\n/** A local MCP server launched as a child process inside the VM. */\nexport interface McpServerConfigLocal {\n\ttype: \"local\";\n\t/** Command to launch the MCP server. */\n\tcommand: string;\n\t/** Arguments for the command. */\n\targs?: string[];\n\t/** Environment variables for the server process. */\n\tenv?: Record<string, string>;\n}\n\n/** A remote MCP server reachable over HTTP. */\nexport interface McpServerConfigRemote {\n\ttype: \"remote\";\n\t/** URL of the remote MCP server. */\n\turl: string;\n\t/** HTTP headers to include in requests to the server. */\n\theaders?: Record<string, string>;\n}\n\nexport type McpServerConfig = McpServerConfigLocal | McpServerConfigRemote;\n\n/** Options accepted by `createSession(agentType, options?)`. */\nexport interface CreateSessionOptions {\n\t/** Working directory for the agent session inside the VM. Defaults to /workspace. */\n\tcwd?: string;\n\t/** Environment variables passed to the agent process (e.g. API keys). */\n\tenv?: Record<string, string>;\n\t/** MCP servers made available to the agent during the session. */\n\tmcpServers?: McpServerConfig[];\n\t/** Skip OS instructions injection entirely (default false). */\n\tskipOsInstructions?: boolean;\n\t/** Additional instructions appended to the base OS instructions. */\n\tadditionalInstructions?: string;\n}\n\n// ---------------------------------------------------------------------------\n// vm.* action surface\n//\n// The real native factory exposes these as `any`; this stub gives them real\n// types so consumers (and tsc) exercise the intended shape.\n// ---------------------------------------------------------------------------\n\n/**\n * The `vm.*` action surface as the SERVER defines it. Each handler receives\n * the RivetKit action context (`c`) as its first argument; RivetKit strips\n * that context when projecting these onto the client handle, so callers invoke\n * e.g. `handle.createSession(\"claude\", { env: { ANTHROPIC_API_KEY } })`.\n *\n * The string index signature satisfies RivetKit's `Actions` constraint.\n */\nexport interface VmActions {\n\t// ── Sessions ────────────────────────────────────────────────────\n\t/** Create an ACP session against a registered agent and return its record. */\n\tcreateSession(\n\t\tc: any,\n\t\tagentType: string,\n\t\toptions?: CreateSessionOptions,\n\t): Promise<SessionRecord>;\n\t/** Send a prompt to an existing session and accumulate the agent's reply. */\n\tsendPrompt(c: any, sessionId: string, prompt: string): Promise<PromptResult>;\n\t/** Alias of `sendPrompt`: send a prompt and accumulate the agent's reply. */\n\tprompt(c: any, sessionId: string, text: string): Promise<PromptResult>;\n\t/** Cancel the in-flight prompt for a session (leaves the session open). */\n\tcancelPrompt(c: any, sessionId: string): Promise<JsonRpcResponse>;\n\t/** Cancel ongoing agent work for a session. */\n\tcancelSession(c: any, sessionId: string): Promise<JsonRpcResponse>;\n\t/** List the sessions currently tracked by this VM. */\n\tlistSessions(c: any): Promise<SessionRecord[]>;\n\t/** Tear down an ACP session abruptly. */\n\tcloseSession(c: any, sessionId: string): Promise<void>;\n\t/** Gracefully destroy a session (cancel pending work, then close). */\n\tdestroySession(c: any, sessionId: string): Promise<void>;\n\t/** Reply to a pending permission request raised by the agent. */\n\trespondPermission(\n\t\tc: any,\n\t\tsessionId: string,\n\t\tpermissionId: string,\n\t\treply: PermissionReply,\n\t): Promise<JsonRpcResponse>;\n\t/** Switch the active mode (e.g. \"plan\", \"auto\") for a session. */\n\tsetMode(c: any, sessionId: string, modeId: string): Promise<JsonRpcResponse>;\n\t/** Switch the active model for a session. */\n\tsetModel(c: any, sessionId: string, model: string): Promise<JsonRpcResponse>;\n\t/** Switch the thought/reasoning level for a session. */\n\tsetThoughtLevel(\n\t\tc: any,\n\t\tsessionId: string,\n\t\tlevel: string,\n\t): Promise<JsonRpcResponse>;\n\t/** Get the available + current modes for a session. */\n\tgetModes(c: any, sessionId: string): Promise<SessionModeState | null>;\n\t/** Get the configurable options (model, thought level, ...) for a session. */\n\tgetConfigOptions(c: any, sessionId: string): Promise<SessionConfigOption[]>;\n\n\t// ── Session event replay ────────────────────────────────────────\n\t/** Replay in-memory session events (live reconnection); newer than `since`. */\n\tgetSequencedEvents(\n\t\tc: any,\n\t\tsessionId: string,\n\t\toptions?: GetSequencedEventsOptions,\n\t): Promise<SequencedSessionEvent[]>;\n\t/** Replay persisted session events from durable storage (transcript history). */\n\tgetSessionEvents(\n\t\tc: any,\n\t\tsessionId: string,\n\t): Promise<PersistedSessionEvent[]>;\n\t/** List persisted session records (including for VMs not currently running). */\n\tlistPersistedSessions(c: any): Promise<PersistedSessionRecord[]>;\n\n\t// ── Processes ───────────────────────────────────────────────────\n\t/** Run a command line to completion and capture its output. */\n\texec(c: any, command: string, options?: ExecOptions): Promise<ExecResult>;\n\t/** Run a command (argv form, no shell) to completion and capture output. */\n\texecArgv(\n\t\tc: any,\n\t\tcommand: string,\n\t\targs?: readonly string[],\n\t\toptions?: ExecOptions,\n\t): Promise<ExecResult>;\n\t/** Spawn a long-running process and return its pid. */\n\tspawn(\n\t\tc: any,\n\t\tcommand: string,\n\t\targs?: string[],\n\t\toptions?: SpawnOptions,\n\t): Promise<{ pid: number }>;\n\t/** Spawn a process inside the VM and return its pid. */\n\tspawnProcess(c: any, command: string, args?: string[]): Promise<number>;\n\t/** List processes spawned via `spawn`. */\n\tlistProcesses(c: any): Promise<SpawnedProcessInfo[]>;\n\t/** Get info about a single spawned process. */\n\tgetProcess(c: any, pid: number): Promise<SpawnedProcessInfo>;\n\t/** Write data to a spawned process's stdin. */\n\twriteProcessStdin(\n\t\tc: any,\n\t\tpid: number,\n\t\tdata: string | Uint8Array,\n\t): Promise<void>;\n\t/** Close a spawned process's stdin stream. */\n\tcloseProcessStdin(c: any, pid: number): Promise<void>;\n\t/** Wait for a process to exit and return its exit code. */\n\twaitProcess(c: any, pid: number): Promise<number>;\n\t/** Gracefully stop a process (SIGTERM). */\n\tstopProcess(c: any, pid: number): Promise<void>;\n\t/** Force-kill a running process by pid (SIGKILL). */\n\tkillProcess(c: any, pid: number): Promise<void>;\n\n\t// ── Shells / PTYs ───────────────────────────────────────────────\n\t/** Open an interactive shell (PTY) and return its id. */\n\topenShell(c: any, options?: OpenShellOptions): Promise<{ shellId: string }>;\n\t/** Connect a terminal (PTY) to the VM and return its pid. */\n\tconnectTerminal(c: any, options?: ConnectTerminalOptions): Promise<number>;\n\t/** Write input to a shell's PTY. */\n\twriteShell(c: any, shellId: string, data: string | Uint8Array): Promise<void>;\n\t/** Resize a shell's PTY. */\n\tresizeShell(\n\t\tc: any,\n\t\tshellId: string,\n\t\tcols: number,\n\t\trows: number,\n\t): Promise<void>;\n\t/** Close a shell and free its PTY. */\n\tcloseShell(c: any, shellId: string): Promise<void>;\n\n\t// ── Filesystem ──────────────────────────────────────────────────\n\t/** Read a file from the VM filesystem. */\n\treadFile(c: any, path: string): Promise<Uint8Array>;\n\t/** Write a file into the VM filesystem. */\n\twriteFile(c: any, path: string, content: Uint8Array | string): Promise<void>;\n\t/** Write several files in one call, reporting per-file success. */\n\twriteFiles(c: any, entries: BatchWriteEntry[]): Promise<BatchWriteResult[]>;\n\t/** Read several files in one call, reporting per-file content/errors. */\n\treadFiles(c: any, paths: string[]): Promise<BatchReadResult[]>;\n\t/** Create a directory (optionally recursive). */\n\tmkdir(\n\t\tc: any,\n\t\tpath: string,\n\t\toptions?: { recursive?: boolean },\n\t): Promise<void>;\n\t/** List the immediate entries of a directory. */\n\treaddir(c: any, path: string): Promise<string[]>;\n\t/** Recursively list directory entries with metadata. */\n\treaddirRecursive(\n\t\tc: any,\n\t\tpath: string,\n\t\toptions?: ReaddirRecursiveOptions,\n\t): Promise<DirEntry[]>;\n\t/** Stat a path. */\n\tstat(c: any, path: string): Promise<VirtualStat>;\n\t/** Check whether a path exists. */\n\texists(c: any, path: string): Promise<boolean>;\n\t/** Move/rename a path. */\n\tmove(c: any, from: string, to: string): Promise<void>;\n\t/** Delete a path (optionally recursive). */\n\tdelete(\n\t\tc: any,\n\t\tpath: string,\n\t\toptions?: { recursive?: boolean },\n\t): Promise<void>;\n\t/** Export a serializable snapshot of the VM root filesystem. */\n\tsnapshotRootFilesystem(c: any): Promise<RootSnapshotExport>;\n\n\t// ── Networking + preview URLs ───────────────────────────────────\n\t/** Proxy an HTTP request to a port inside the VM and return the response. */\n\tvmFetch(\n\t\tc: any,\n\t\tport: number,\n\t\tpath: string,\n\t\toptions?: VmFetchOptions,\n\t): Promise<VmFetchResponse>;\n\t/** Create a time-limited, token-based preview URL for a VM port. */\n\tcreateSignedPreviewUrl(\n\t\tc: any,\n\t\tport: number,\n\t\texpiresInSeconds?: number,\n\t): Promise<PreviewUrl>;\n\n\t// ── Cron ────────────────────────────────────────────────────────\n\t/** Schedule a serializable cron job inside the VM. */\n\tscheduleCron(\n\t\tc: any,\n\t\toptions: SerializableCronJobOptions,\n\t): Promise<ScheduledCronJob>;\n\t/** List the cron jobs registered on this VM. */\n\tlistCronJobs(c: any): Promise<CronJobInfo[]>;\n\t/** Cancel a registered cron job by id. */\n\tcancelCronJob(c: any, id: string): Promise<void>;\n\n\t/** Index signature required by RivetKit's `Actions` constraint. */\n\t[action: string]: (c: any, ...args: any[]) => any;\n}\n\n// ---------------------------------------------------------------------------\n// Actor definition\n// ---------------------------------------------------------------------------\n\n/**\n * The `agentOS(...)` actor definition type. Mirrors RivetKit's generic\n * `ActorDefinition` with the Agent OS state/vars/events/actions bound in.\n */\nexport type AgentOSActorDefinition<TConnParams = undefined> = ActorDefinition<\n\tAgentOSActorState,\n\tTConnParams,\n\tundefined,\n\tAgentOSActorVars,\n\tundefined,\n\tany,\n\tAgentOSEvents,\n\tRecord<never, never>,\n\tVmActions\n>;\n\nconst RUNTIME_NOT_WIRED =\n\t\"agentos runtime not yet wired — dylib pending\";\n\n/**\n * Build the Agent OS actor definition.\n *\n * STUB: returns a correctly typed RivetKit actor definition whose action\n * handlers throw. No native/napi module is imported. Replace the throwing\n * handlers with the native factory builder once the runtime ships; the public\n * type surface is stable.\n */\nexport function agentOS<TConnParams = undefined>(\n\t// Accepted for type-surface parity; ignored by the stub.\n\t_config: AgentOSActorConfigInput<TConnParams>,\n): AgentOSActorDefinition<TConnParams> {\n\tconst notWired = () => {\n\t\tthrow new Error(RUNTIME_NOT_WIRED);\n\t};\n\n\tconst definition = actor({\n\t\tstate: {} as AgentOSActorState,\n\t\tcreateVars: (): AgentOSActorVars => ({\n\t\t\tactiveSessionIds: new Set<string>(),\n\t\t\tactiveProcesses: new Set<number>(),\n\t\t\tactiveShells: new Set<string>(),\n\t\t\tsessions: new Set<string>(),\n\t\t}),\n\t\tevents: agentOSEvents,\n\t\tactions: {\n\t\t\t// Sessions\n\t\t\tcreateSession: notWired,\n\t\t\tsendPrompt: notWired,\n\t\t\tprompt: notWired,\n\t\t\tcancelPrompt: notWired,\n\t\t\tcancelSession: notWired,\n\t\t\tlistSessions: notWired,\n\t\t\tcloseSession: notWired,\n\t\t\tdestroySession: notWired,\n\t\t\trespondPermission: notWired,\n\t\t\tsetMode: notWired,\n\t\t\tsetModel: notWired,\n\t\t\tsetThoughtLevel: notWired,\n\t\t\tgetModes: notWired,\n\t\t\tgetConfigOptions: notWired,\n\t\t\t// Session event replay\n\t\t\tgetSequencedEvents: notWired,\n\t\t\tgetSessionEvents: notWired,\n\t\t\tlistPersistedSessions: notWired,\n\t\t\t// Processes\n\t\t\texec: notWired,\n\t\t\texecArgv: notWired,\n\t\t\tspawn: notWired,\n\t\t\tspawnProcess: notWired,\n\t\t\tlistProcesses: notWired,\n\t\t\tgetProcess: notWired,\n\t\t\twriteProcessStdin: notWired,\n\t\t\tcloseProcessStdin: notWired,\n\t\t\twaitProcess: notWired,\n\t\t\tstopProcess: notWired,\n\t\t\tkillProcess: notWired,\n\t\t\t// Shells\n\t\t\topenShell: notWired,\n\t\t\tconnectTerminal: notWired,\n\t\t\twriteShell: notWired,\n\t\t\tresizeShell: notWired,\n\t\t\tcloseShell: notWired,\n\t\t\t// Filesystem\n\t\t\treadFile: notWired,\n\t\t\twriteFile: notWired,\n\t\t\twriteFiles: notWired,\n\t\t\treadFiles: notWired,\n\t\t\tmkdir: notWired,\n\t\t\treaddir: notWired,\n\t\t\treaddirRecursive: notWired,\n\t\t\tstat: notWired,\n\t\t\texists: notWired,\n\t\t\tmove: notWired,\n\t\t\tdelete: notWired,\n\t\t\tsnapshotRootFilesystem: notWired,\n\t\t\t// Networking + preview URLs\n\t\t\tvmFetch: notWired,\n\t\t\tcreateSignedPreviewUrl: notWired,\n\t\t\t// Cron\n\t\t\tscheduleCron: notWired,\n\t\t\tlistCronJobs: notWired,\n\t\t\tcancelCronJob: notWired,\n\t\t},\n\t});\n\n\treturn definition as unknown as AgentOSActorDefinition<TConnParams>;\n}\n"],"mappings":";AAkBA,SAAS,OAA6B,aAAwB;AAI9D,SAAS,aAAa;AAsTf,SAAS,iBACf,oBACA,MACyB;AACzB,QAAM,WAAW,MAAM,YAAY;AACnC,SAAO;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,MACP,IAAI;AAAA,MACJ,QAAQ,EAAE,UAAU,oBAAoB,SAAS;AAAA,IAClD;AAAA,IACA;AAAA,EACD;AACD;AAqEA,IAAM,aAAa,MAAkB,MAAS;AAE9C,IAAM,gBAAgB;AAAA,EACrB,cAAc,WAAgC;AAAA,EAC9C,mBAAmB,WAAqC;AAAA,EACxD,UAAU,WAA4B;AAAA,EACtC,YAAY,WAA8B;AAAA,EAC1C,eAAe,WAAiC;AAAA,EAChD,aAAa,WAA+B;AAAA,EAC5C,WAAW,WAA6B;AAAA,EACxC,WAAW,WAA6B;AACzC;AA6XA,IAAM,oBACL;AAUM,SAAS,QAEf,SACsC;AACtC,QAAM,WAAW,MAAM;AACtB,UAAM,IAAI,MAAM,iBAAiB;AAAA,EAClC;AAEA,QAAM,aAAa,MAAM;AAAA,IACxB,OAAO,CAAC;AAAA,IACR,YAAY,OAAyB;AAAA,MACpC,kBAAkB,oBAAI,IAAY;AAAA,MAClC,iBAAiB,oBAAI,IAAY;AAAA,MACjC,cAAc,oBAAI,IAAY;AAAA,MAC9B,UAAU,oBAAI,IAAY;AAAA,IAC3B;AAAA,IACA,QAAQ;AAAA,IACR,SAAS;AAAA;AAAA,MAER,eAAe;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cAAc;AAAA,MACd,gBAAgB;AAAA,MAChB,mBAAmB;AAAA,MACnB,SAAS;AAAA,MACT,UAAU;AAAA,MACV,iBAAiB;AAAA,MACjB,UAAU;AAAA,MACV,kBAAkB;AAAA;AAAA,MAElB,oBAAoB;AAAA,MACpB,kBAAkB;AAAA,MAClB,uBAAuB;AAAA;AAAA,MAEvB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,MACP,cAAc;AAAA,MACd,eAAe;AAAA,MACf,YAAY;AAAA,MACZ,mBAAmB;AAAA,MACnB,mBAAmB;AAAA,MACnB,aAAa;AAAA,MACb,aAAa;AAAA,MACb,aAAa;AAAA;AAAA,MAEb,WAAW;AAAA,MACX,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,YAAY;AAAA;AAAA,MAEZ,UAAU;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,OAAO;AAAA,MACP,SAAS;AAAA,MACT,kBAAkB;AAAA,MAClB,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,wBAAwB;AAAA;AAAA,MAExB,SAAS;AAAA,MACT,wBAAwB;AAAA;AAAA,MAExB,cAAc;AAAA,MACd,cAAc;AAAA,MACd,eAAe;AAAA,IAChB;AAAA,EACD,CAAC;AAED,SAAO;AACR;","names":[]}
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/react.ts
|
|
18
|
+
var react_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(react_exports);
|
|
20
|
+
__reExport(react_exports, require("@rivetkit/react"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@rivetkit/react")
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["/**\n * `@rivet-dev/agentos/react` — Agent OS React bindings.\n *\n * Re-exports `@rivetkit/react` (`createRivetKit`, `createRivetKitWithClient`,\n * and the hooks). Kept on its own subpath so neither React nor the client\n * bundle is pulled into server code that imports the root module.\n */\n\nexport * from \"@rivetkit/react\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAQA,0BAAc,4BARd;","names":[]}
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@rivetkit/react';
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@rivetkit/react';
|
package/dist/react.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["/**\n * `@rivet-dev/agentos/react` — Agent OS React bindings.\n *\n * Re-exports `@rivetkit/react` (`createRivetKit`, `createRivetKitWithClient`,\n * and the hooks). Kept on its own subpath so neither React nor the client\n * bundle is pulled into server code that imports the root module.\n */\n\nexport * from \"@rivetkit/react\";\n"],"mappings":";AAQA,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,50 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivet-dev/agentos",
|
|
3
|
-
"version": "0.0.0-
|
|
4
|
-
"description": "Agent OS
|
|
3
|
+
"version": "0.0.0-nathan-binding-workspace.4640d5c",
|
|
4
|
+
"description": "User-facing Agent OS integration for RivetKit actors (interim types-now noop stub)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
"keywords": [
|
|
7
|
+
"rivetkit",
|
|
8
|
+
"agentos",
|
|
9
|
+
"agentos",
|
|
10
|
+
"agents",
|
|
11
|
+
"actors",
|
|
12
|
+
"ai"
|
|
13
|
+
],
|
|
14
|
+
"sideEffects": false,
|
|
14
15
|
"files": [
|
|
15
16
|
"dist",
|
|
16
|
-
"
|
|
17
|
+
"package.json"
|
|
17
18
|
],
|
|
19
|
+
"type": "module",
|
|
18
20
|
"exports": {
|
|
19
21
|
".": {
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
"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"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"./client": {
|
|
32
|
+
"import": {
|
|
33
|
+
"browser": {
|
|
34
|
+
"types": "./dist/client.d.ts",
|
|
35
|
+
"default": "./dist/client.js"
|
|
36
|
+
},
|
|
37
|
+
"types": "./dist/client.d.ts",
|
|
38
|
+
"default": "./dist/client.js"
|
|
39
|
+
},
|
|
40
|
+
"require": {
|
|
41
|
+
"types": "./dist/client.d.cts",
|
|
42
|
+
"default": "./dist/client.cjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"./react": {
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./dist/react.d.ts",
|
|
48
|
+
"default": "./dist/react.js"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./dist/react.d.cts",
|
|
52
|
+
"default": "./dist/react.cjs"
|
|
53
|
+
}
|
|
23
54
|
}
|
|
24
55
|
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=22.0.0"
|
|
58
|
+
},
|
|
25
59
|
"scripts": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"test": "vitest run"
|
|
60
|
+
"build": "tsup src/mod.ts src/client.ts src/react.ts",
|
|
61
|
+
"check-types": "tsc --noEmit"
|
|
29
62
|
},
|
|
30
63
|
"dependencies": {
|
|
31
|
-
"
|
|
32
|
-
"@
|
|
33
|
-
"@rivet-dev/agentos-sidecar": "0.0.0-integrate-dylib-into-main.815fcda",
|
|
34
|
-
"zod": "^4.1.11"
|
|
64
|
+
"rivetkit": "2.3.0-rc.12",
|
|
65
|
+
"@rivetkit/react": "2.3.0-rc.12"
|
|
35
66
|
},
|
|
36
67
|
"peerDependencies": {
|
|
37
|
-
"
|
|
68
|
+
"react": "^18 || ^19",
|
|
69
|
+
"react-dom": "^18 || ^19"
|
|
38
70
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"react": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"react-dom": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
46
78
|
},
|
|
47
|
-
"
|
|
48
|
-
"
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"tsup": "^8.4.0",
|
|
81
|
+
"typescript": "^5.7.3"
|
|
49
82
|
}
|
|
50
83
|
}
|
package/dist/actor.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rust-backed `agentOs(...)` definition.
|
|
3
|
-
*
|
|
4
|
-
* Produces an `ActorDefinition` whose `nativeFactoryBuilder` constructs a
|
|
5
|
-
* native-actor-plugin factory through `runtime.createNativePluginFactory(...)`
|
|
6
|
-
* (NAPI → `dlopen` of the agent-os actor plugin cdylib, the inverse of the
|
|
7
|
-
* generic host loader). All lifecycle, state, and action dispatch live in the
|
|
8
|
-
* Rust plugin (`crates/agentos-actor-plugin`). This JS shim only validates
|
|
9
|
-
* configuration, resolves the plugin + sidecar binaries, and hands the opaque
|
|
10
|
-
* config envelope across the bridge — it owns no agent-os runtime logic.
|
|
11
|
-
*/
|
|
12
|
-
import { type ActorDefinition, type DatabaseProvider, type RawAccess } from "rivetkit";
|
|
13
|
-
import { type AgentOsActorConfig, type AgentOsActorConfigInput } from "./config.js";
|
|
14
|
-
import type { AgentOsActorState, AgentOsActorVars } from "./types.js";
|
|
15
|
-
/**
|
|
16
|
-
* A native `host_dir` mount of a host `node_modules` directory at
|
|
17
|
-
* `/root/node_modules`, the serializable form `agentOs({ options: { mounts } })`
|
|
18
|
-
* accepts across the NAPI boundary.
|
|
19
|
-
*/
|
|
20
|
-
export interface NodeModulesMountConfig {
|
|
21
|
-
path: "/root/node_modules";
|
|
22
|
-
plugin: {
|
|
23
|
-
id: "host_dir";
|
|
24
|
-
config: {
|
|
25
|
-
hostPath: string;
|
|
26
|
-
readOnly: boolean;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
readOnly: boolean;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Mount a host `node_modules` directory into the VM at `/root/node_modules`.
|
|
33
|
-
*
|
|
34
|
-
* This is the explicit, mount-based replacement for the removed `moduleAccessCwd`
|
|
35
|
-
* mechanism: the VM module resolver reads the mounted tree through the kernel
|
|
36
|
-
* VFS, so the caller supplies exactly the `node_modules` directory whose
|
|
37
|
-
* packages should resolve in the guest.
|
|
38
|
-
*
|
|
39
|
-
* @param hostNodeModulesDir Absolute host path to a `node_modules` directory.
|
|
40
|
-
* @param opts.readOnly Defaults to `true`; the mount is read-only.
|
|
41
|
-
*/
|
|
42
|
-
export declare function nodeModulesMount(hostNodeModulesDir: string, opts?: {
|
|
43
|
-
readOnly?: boolean;
|
|
44
|
-
}): NodeModulesMountConfig;
|
|
45
|
-
export declare function buildConfigJson<TConnParams>(parsed: AgentOsActorConfig<TConnParams>): string;
|
|
46
|
-
/**
|
|
47
|
-
* Type alias for the `agentOs(...)` return type. Events are not typed at the
|
|
48
|
-
* TS surface because the Rust plugin owns the broadcast set and the
|
|
49
|
-
* test/client surface uses `any` for actions.
|
|
50
|
-
*/
|
|
51
|
-
export type AgentOsActorDefinition<TConnParams> = ActorDefinition<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<RawAccess>, Record<never, never>, Record<never, never>, any>;
|
|
52
|
-
export declare function agentOs<TConnParams = undefined>(config: AgentOsActorConfigInput<TConnParams>): AgentOsActorDefinition<TConnParams>;
|
package/dist/actor.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rust-backed `agentOs(...)` definition.
|
|
3
|
-
*
|
|
4
|
-
* Produces an `ActorDefinition` whose `nativeFactoryBuilder` constructs a
|
|
5
|
-
* native-actor-plugin factory through `runtime.createNativePluginFactory(...)`
|
|
6
|
-
* (NAPI → `dlopen` of the agent-os actor plugin cdylib, the inverse of the
|
|
7
|
-
* generic host loader). All lifecycle, state, and action dispatch live in the
|
|
8
|
-
* Rust plugin (`crates/agentos-actor-plugin`). This JS shim only validates
|
|
9
|
-
* configuration, resolves the plugin + sidecar binaries, and hands the opaque
|
|
10
|
-
* config envelope across the bridge — it owns no agent-os runtime logic.
|
|
11
|
-
*/
|
|
12
|
-
import { sep } from "node:path";
|
|
13
|
-
import common from "@agentos-software/common";
|
|
14
|
-
import { getSidecarPath } from "@rivet-dev/agentos-sidecar";
|
|
15
|
-
import { actor, } from "rivetkit";
|
|
16
|
-
import { agentOsActorConfigSchema, } from "./config.js";
|
|
17
|
-
import { getPluginPath } from "./plugin-binary.js";
|
|
18
|
-
/**
|
|
19
|
-
* Mount a host `node_modules` directory into the VM at `/root/node_modules`.
|
|
20
|
-
*
|
|
21
|
-
* This is the explicit, mount-based replacement for the removed `moduleAccessCwd`
|
|
22
|
-
* mechanism: the VM module resolver reads the mounted tree through the kernel
|
|
23
|
-
* VFS, so the caller supplies exactly the `node_modules` directory whose
|
|
24
|
-
* packages should resolve in the guest.
|
|
25
|
-
*
|
|
26
|
-
* @param hostNodeModulesDir Absolute host path to a `node_modules` directory.
|
|
27
|
-
* @param opts.readOnly Defaults to `true`; the mount is read-only.
|
|
28
|
-
*/
|
|
29
|
-
export function nodeModulesMount(hostNodeModulesDir, opts) {
|
|
30
|
-
const readOnly = opts?.readOnly ?? true;
|
|
31
|
-
return {
|
|
32
|
-
path: "/root/node_modules",
|
|
33
|
-
plugin: {
|
|
34
|
-
id: "host_dir",
|
|
35
|
-
config: { hostPath: hostNodeModulesDir, readOnly },
|
|
36
|
-
},
|
|
37
|
-
readOnly,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Derive the `node_modules` root that contains an installed package directory.
|
|
42
|
-
* For an agent descriptor whose `packageDir` is `<root>/node_modules/@scope/pkg`,
|
|
43
|
-
* this returns `<root>/node_modules` — the hoist root that also holds the agent's
|
|
44
|
-
* `requires` (the ACP adapter + agent SDK) and their transitive deps under a
|
|
45
|
-
* flat (npm) install. Returns `undefined` when `packageDir` is not inside a
|
|
46
|
-
* `node_modules` tree (e.g. a linked monorepo checkout), where the caller must
|
|
47
|
-
* supply an explicit `nodeModulesMount(...)`.
|
|
48
|
-
*/
|
|
49
|
-
function nodeModulesRootOf(packageDir) {
|
|
50
|
-
const parts = packageDir.split(sep);
|
|
51
|
-
const idx = parts.lastIndexOf("node_modules");
|
|
52
|
-
if (idx === -1)
|
|
53
|
-
return undefined;
|
|
54
|
-
return parts.slice(0, idx + 1).join(sep);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Agents run their ACP adapter + SDK inside the VM from `/root/node_modules`.
|
|
58
|
-
* Rather than make the caller hand-write `nodeModulesMount(...)`, auto-derive a
|
|
59
|
-
* read-only `host_dir` mount of the `node_modules` root that holds the agent
|
|
60
|
-
* packages (`requires`) from each agent descriptor's installed `packageDir`.
|
|
61
|
-
*
|
|
62
|
-
* An explicit `/root/node_modules` mount in `options.mounts` always wins. If
|
|
63
|
-
* agents resolve to more than one distinct `node_modules` root the derivation is
|
|
64
|
-
* ambiguous and the caller must mount explicitly.
|
|
65
|
-
*/
|
|
66
|
-
function withAutoAgentNodeModulesMount(mounts, descriptors) {
|
|
67
|
-
if (mounts?.some((mount) => mount.path === "/root/node_modules")) {
|
|
68
|
-
return mounts;
|
|
69
|
-
}
|
|
70
|
-
const roots = new Set();
|
|
71
|
-
for (const d of descriptors) {
|
|
72
|
-
if (!d.agent || typeof d.packageDir !== "string")
|
|
73
|
-
continue;
|
|
74
|
-
const root = nodeModulesRootOf(d.packageDir);
|
|
75
|
-
if (root)
|
|
76
|
-
roots.add(root);
|
|
77
|
-
}
|
|
78
|
-
if (roots.size === 0)
|
|
79
|
-
return mounts;
|
|
80
|
-
if (roots.size > 1) {
|
|
81
|
-
throw new Error("agentOs() could not auto-mount agent node_modules: agents resolved to " +
|
|
82
|
-
`multiple node_modules roots (${[...roots].join(", ")}). Pass an ` +
|
|
83
|
-
"explicit nodeModulesMount(...) in options.mounts.");
|
|
84
|
-
}
|
|
85
|
-
const [hostNodeModulesDir] = [...roots];
|
|
86
|
-
return [...(mounts ?? []), nodeModulesMount(hostNodeModulesDir)];
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Stable identity for a software descriptor, used to de-duplicate the
|
|
90
|
-
* auto-injected default bundle against software the caller passed explicitly.
|
|
91
|
-
* Resolved `commandDir`/`packageDir` paths are the most reliable key; `name`
|
|
92
|
-
* is the fallback for descriptors without a directory.
|
|
93
|
-
*/
|
|
94
|
-
function softwareIdentity(d) {
|
|
95
|
-
if (typeof d.commandDir === "string")
|
|
96
|
-
return `dir:${d.commandDir}`;
|
|
97
|
-
if (typeof d.packageDir === "string")
|
|
98
|
-
return `dir:${d.packageDir}`;
|
|
99
|
-
const name = d.name;
|
|
100
|
-
if (typeof name === "string")
|
|
101
|
-
return `name:${name}`;
|
|
102
|
-
return JSON.stringify(d);
|
|
103
|
-
}
|
|
104
|
-
function flattenSoftware(input, out) {
|
|
105
|
-
if (input == null)
|
|
106
|
-
return;
|
|
107
|
-
if (Array.isArray(input)) {
|
|
108
|
-
for (const item of input)
|
|
109
|
-
flattenSoftware(item, out);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (typeof input === "object")
|
|
113
|
-
out.push(input);
|
|
114
|
-
}
|
|
115
|
-
export function buildConfigJson(parsed) {
|
|
116
|
-
const descriptors = [];
|
|
117
|
-
flattenSoftware(parsed.options?.software, descriptors);
|
|
118
|
-
// Auto-include the default software bundle (`@agentos-software/common`: `sh` +
|
|
119
|
-
// coreutils + the standard CLI tools agents rely on) unless the caller opted
|
|
120
|
-
// out with `defaultSoftware: false`. Anything already listed in `software`
|
|
121
|
-
// (e.g. an explicit `common`) is not duplicated. Prepended so the baseline
|
|
122
|
-
// tools come first, matching the previous explicit `[common, ...]` ordering.
|
|
123
|
-
const defaultSoftwareEnabled = parsed.options?.defaultSoftware !== false;
|
|
124
|
-
if (defaultSoftwareEnabled) {
|
|
125
|
-
const defaults = [];
|
|
126
|
-
flattenSoftware(common, defaults);
|
|
127
|
-
const seen = new Set(descriptors.map(softwareIdentity));
|
|
128
|
-
const toPrepend = defaults.filter((d) => !seen.has(softwareIdentity(d)));
|
|
129
|
-
descriptors.unshift(...toPrepend);
|
|
130
|
-
}
|
|
131
|
-
const software = [];
|
|
132
|
-
for (const d of descriptors) {
|
|
133
|
-
if (typeof d.commandDir === "string") {
|
|
134
|
-
// Wasm command directory (kind defaults to WasmCommands on the Rust side).
|
|
135
|
-
software.push({ package: d.commandDir });
|
|
136
|
-
}
|
|
137
|
-
else if (typeof d.packageDir === "string") {
|
|
138
|
-
// Agent SDK / host-tool package: forwarded but not mounted as commands.
|
|
139
|
-
// `kind` matches the kebab-case serde tags of the Rust `SoftwareKind`
|
|
140
|
-
// enum (`wasm-commands` / `agent` / `tool`).
|
|
141
|
-
software.push({
|
|
142
|
-
package: d.packageDir,
|
|
143
|
-
kind: d.hostTool || d.toolkit ? "tool" : "agent",
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
// `/root/node_modules` (agent ACP adapter + SDK + transitive dep resolution)
|
|
148
|
-
// is auto-derived from the agent descriptors so the standard quickstart needs
|
|
149
|
-
// no manual `nodeModulesMount(...)`: see `withAutoAgentNodeModulesMount`. An
|
|
150
|
-
// explicit `/root/node_modules` mount in `options.mounts` always wins. The VM
|
|
151
|
-
// module resolver reads the mounted tree through the kernel VFS.
|
|
152
|
-
const options = (parsed.options ?? {});
|
|
153
|
-
const mounts = withAutoAgentNodeModulesMount(serializeNativeMounts(options.mounts), descriptors);
|
|
154
|
-
const sidecar = serializeSidecar(options.sidecar);
|
|
155
|
-
return JSON.stringify({
|
|
156
|
-
software,
|
|
157
|
-
additionalInstructions: options.additionalInstructions,
|
|
158
|
-
loopbackExemptPorts: options.loopbackExemptPorts,
|
|
159
|
-
allowedNodeBuiltins: options.allowedNodeBuiltins,
|
|
160
|
-
permissions: options.permissions,
|
|
161
|
-
rootFilesystem: options.rootFilesystem,
|
|
162
|
-
mounts,
|
|
163
|
-
limits: options.limits,
|
|
164
|
-
sidecar,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
function serializeNativeMounts(input) {
|
|
168
|
-
if (input == null)
|
|
169
|
-
return undefined;
|
|
170
|
-
if (!Array.isArray(input)) {
|
|
171
|
-
throw new Error("agentOs() options.mounts must be an array");
|
|
172
|
-
}
|
|
173
|
-
return input.map((mount, index) => {
|
|
174
|
-
if (!mount || typeof mount !== "object") {
|
|
175
|
-
throw new Error(`agentOs() options.mounts[${index}] must be an object`);
|
|
176
|
-
}
|
|
177
|
-
const record = mount;
|
|
178
|
-
if (record.driver !== undefined) {
|
|
179
|
-
throw new Error("agentOs() only supports Native mounts across the NAPI boundary; Plain mounts with driver callbacks are not serializable");
|
|
180
|
-
}
|
|
181
|
-
if (record.filesystem !== undefined) {
|
|
182
|
-
throw new Error("agentOs() only supports Native mounts across the NAPI boundary; Overlay mounts are not serializable");
|
|
183
|
-
}
|
|
184
|
-
const plugin = record.plugin;
|
|
185
|
-
if (typeof record.path !== "string" ||
|
|
186
|
-
!plugin ||
|
|
187
|
-
typeof plugin !== "object" ||
|
|
188
|
-
typeof plugin.id !== "string") {
|
|
189
|
-
throw new Error(`agentOs() options.mounts[${index}] must be a Native mount with { path, plugin: { id, config? } }`);
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
path: record.path,
|
|
193
|
-
plugin: {
|
|
194
|
-
id: plugin.id,
|
|
195
|
-
config: plugin.config,
|
|
196
|
-
},
|
|
197
|
-
readOnly: typeof record.readOnly === "boolean" ? record.readOnly : undefined,
|
|
198
|
-
};
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
function serializeSidecar(input) {
|
|
202
|
-
if (input == null)
|
|
203
|
-
return undefined;
|
|
204
|
-
if (!input || typeof input !== "object") {
|
|
205
|
-
throw new Error("agentOs() options.sidecar must be an object");
|
|
206
|
-
}
|
|
207
|
-
const record = input;
|
|
208
|
-
if (record.kind === "explicit" || record.handle !== undefined) {
|
|
209
|
-
throw new Error("agentOs() only supports sidecar shared pool configuration across the NAPI boundary; explicit sidecar handles are not serializable");
|
|
210
|
-
}
|
|
211
|
-
if (record.kind !== undefined && record.kind !== "shared") {
|
|
212
|
-
throw new Error('agentOs() options.sidecar.kind must be "shared"');
|
|
213
|
-
}
|
|
214
|
-
return typeof record.pool === "string" ? { pool: record.pool } : {};
|
|
215
|
-
}
|
|
216
|
-
function buildNativeFactoryBuilder(parsed) {
|
|
217
|
-
return (runtime) => {
|
|
218
|
-
if (runtime.kind !== "napi") {
|
|
219
|
-
throw new Error(`agentOs() is only supported on the native NAPI runtime (current runtime kind: ${runtime.kind})`);
|
|
220
|
-
}
|
|
221
|
-
if (!runtime.createNativePluginFactory) {
|
|
222
|
-
throw new Error("runtime.createNativePluginFactory is not implemented on the active CoreRuntime");
|
|
223
|
-
}
|
|
224
|
-
const options = {
|
|
225
|
-
// Resolve the prebuilt agent-os actor plugin cdylib; RivetKit `dlopen`s
|
|
226
|
-
// it through the generic native-plugin ABI.
|
|
227
|
-
pluginPath: getPluginPath(),
|
|
228
|
-
// Opaque config envelope the plugin parses (config.rs::AgentOsConfigJson).
|
|
229
|
-
configJson: buildConfigJson(parsed),
|
|
230
|
-
// Resolve the prebuilt sidecar binary from the npm package so the plugin
|
|
231
|
-
// spawns the bundled binary rather than relying on `agentos-sidecar`
|
|
232
|
-
// being on PATH.
|
|
233
|
-
sidecarPath: getSidecarPath(),
|
|
234
|
-
};
|
|
235
|
-
return runtime.createNativePluginFactory(options);
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
export function agentOs(config) {
|
|
239
|
-
const parsed = agentOsActorConfigSchema.parse(config);
|
|
240
|
-
// Construct a minimal definition through the existing actor() helper, then
|
|
241
|
-
// attach the Rust factory builder marker. The actions block stays empty
|
|
242
|
-
// because no JS-side action ever runs: the engine driver branches on
|
|
243
|
-
// `nativeFactoryBuilder` before reaching the JS dispatch path.
|
|
244
|
-
const actorOptions = parsed
|
|
245
|
-
.actorOptions;
|
|
246
|
-
const definition = actor({
|
|
247
|
-
actions: {},
|
|
248
|
-
...(actorOptions ? { options: actorOptions } : {}),
|
|
249
|
-
});
|
|
250
|
-
definition.nativeFactoryBuilder = buildNativeFactoryBuilder(parsed);
|
|
251
|
-
return definition;
|
|
252
|
-
}
|
package/dist/config.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { AgentOsOptions, JsonRpcNotification, PermissionRequest } from "@rivet-dev/agentos-core";
|
|
2
|
-
import type { ActorContext, BeforeConnectContext } from "rivetkit";
|
|
3
|
-
import { z } from "zod/v4";
|
|
4
|
-
import type { AgentOsActorState, AgentOsActorVars } from "./types.js";
|
|
5
|
-
export declare const agentOsActorConfigSchema: z.ZodObject<{
|
|
6
|
-
options: z.ZodOptional<z.ZodCustom<AgentOsOptions, AgentOsOptions>>;
|
|
7
|
-
preview: z.ZodPrefault<z.ZodObject<{
|
|
8
|
-
defaultExpiresInSeconds: z.ZodDefault<z.ZodNumber>;
|
|
9
|
-
maxExpiresInSeconds: z.ZodDefault<z.ZodNumber>;
|
|
10
|
-
}, z.core.$strict>>;
|
|
11
|
-
onBeforeConnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
12
|
-
onSessionEvent: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
13
|
-
onPermissionRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
14
|
-
}, z.core.$strict>;
|
|
15
|
-
type AgentOsActorContext<TConnParams> = ActorContext<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, any>;
|
|
16
|
-
interface AgentOsActorConfigCallbacks<TConnParams> {
|
|
17
|
-
onBeforeConnect?: (c: BeforeConnectContext<AgentOsActorState, AgentOsActorVars, undefined, any>, params: TConnParams) => void | Promise<void>;
|
|
18
|
-
onSessionEvent?: (c: AgentOsActorContext<TConnParams>, sessionId: string, event: JsonRpcNotification) => void | Promise<void>;
|
|
19
|
-
onPermissionRequest?: (c: AgentOsActorContext<TConnParams>, sessionId: string, request: PermissionRequest) => void | Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
export type AgentOsActorConfig<TConnParams = undefined> = Omit<z.infer<typeof agentOsActorConfigSchema>, "onBeforeConnect" | "onSessionEvent" | "onPermissionRequest"> & AgentOsActorConfigCallbacks<TConnParams>;
|
|
22
|
-
export type AgentOsActorConfigInput<TConnParams = undefined> = Omit<z.input<typeof agentOsActorConfigSchema>, "onBeforeConnect" | "onSessionEvent" | "onPermissionRequest"> & AgentOsActorConfigCallbacks<TConnParams>;
|
|
23
|
-
export {};
|
package/dist/config.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
const zFunction = () => z.custom((val) => typeof val === "function");
|
|
3
|
-
const AgentOsOptionsSchema = z.custom((val) => typeof val === "object" && val !== null);
|
|
4
|
-
export const agentOsActorConfigSchema = z
|
|
5
|
-
.object({
|
|
6
|
-
options: AgentOsOptionsSchema.optional(),
|
|
7
|
-
preview: z
|
|
8
|
-
.object({
|
|
9
|
-
defaultExpiresInSeconds: z.number().positive().default(3600),
|
|
10
|
-
maxExpiresInSeconds: z.number().positive().default(86400),
|
|
11
|
-
})
|
|
12
|
-
.strict()
|
|
13
|
-
.prefault(() => ({})),
|
|
14
|
-
onBeforeConnect: zFunction().optional(),
|
|
15
|
-
onSessionEvent: zFunction().optional(),
|
|
16
|
-
onPermissionRequest: zFunction().optional(),
|
|
17
|
-
})
|
|
18
|
-
.strict();
|
package/dist/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { agentOs, type AgentOsActorDefinition, buildConfigJson, nodeModulesMount, type NodeModulesMountConfig, } from "./actor.js";
|
|
2
|
-
export { type AgentOsActorConfig, type AgentOsActorConfigInput, agentOsActorConfigSchema, } from "./config.js";
|
|
3
|
-
export { getPluginPath } from "./plugin-binary.js";
|
|
4
|
-
export type { AgentOsActionContext, AgentOsActorState, AgentOsActorVars, AgentOsEvents, CronEventPayload, PermissionRequestPayload, PersistedSessionEvent, PersistedSessionRecord, ProcessExitPayload, ProcessOutputPayload, PromptResult, SerializableCronAction, SerializableCronJobInfo, SerializableCronJobOptions, SessionEventPayload, SessionRecord, ShellDataPayload, VmBootedPayload, VmShutdownPayload, } from "./types.js";
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Rust-backed agent-os actor surface (native actor plugin / cdylib).
|
|
2
|
-
//
|
|
3
|
-
// Only the `agentOs()` definition function, the config schema, the
|
|
4
|
-
// `nodeModulesMount` helper, the plugin-path resolver, and the public domain
|
|
5
|
-
// types are exported. All actor lifecycle + action dispatch live in the Rust
|
|
6
|
-
// plugin (`crates/agentos-actor-plugin`), loaded by RivetKit via the generic
|
|
7
|
-
// native-plugin ABI.
|
|
8
|
-
export { agentOs, buildConfigJson, nodeModulesMount, } from "./actor.js";
|
|
9
|
-
export { agentOsActorConfigSchema, } from "./config.js";
|
|
10
|
-
export { getPluginPath } from "./plugin-binary.js";
|