@rivet-dev/agentos 0.0.0-glibc.9438c58 → 0.0.0-main.29b0797

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +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 { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport common from \"@agentos-software/common\";\nimport { OPT_AGENTOS_ROOT } from \"@rivet-dev/agentos-core\";\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\tnativeAgentOsOptionsSchema,\n} from \"./config.js\";\nimport { getPluginPath } from \"./plugin-binary.js\";\nimport type { AgentOsActions } from \"./actor-actions.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 ref is flattened (meta packages such as\n * `common` are arrays of refs), normalized to a package dir, and forwarded as\n * `{ dir }` so the sidecar owns the `/opt/agentos` projection. Agent configs\n * are derived from each package's `agentos-package.json`, mirroring\n * `packages/core/src/agent-os.ts`.\n */\ninterface NativeMountLike {\n\tpath: string;\n\tplugin: {\n\t\tid: string;\n\t\tconfig?: unknown;\n\t};\n\treadOnly?: boolean;\n}\n\ninterface NormalizedPackageRef {\n\tpath: string;\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\nfunction toRecord(value: unknown): Record<string, unknown> {\n\treturn value && typeof value === \"object\" && !Array.isArray(value)\n\t\t? (value as Record<string, unknown>)\n\t\t: {};\n}\n\nfunction normalizePackageRef(value: unknown): NormalizedPackageRef | undefined {\n\t// Single package reference: `packagePath` (packed `.aospkg` file, or a\n\t// transition package dir); a raw string is shorthand for the same path.\n\tif (typeof value === \"string\") {\n\t\treturn { path: value };\n\t}\n\tconst record = toRecord(value);\n\tif (typeof record.packagePath === \"string\") {\n\t\treturn { path: record.packagePath };\n\t}\n\t// Recognizably-legacy shapes fail loudly instead of silently dropping the\n\t// package from the VM.\n\tfor (const legacy of [\"packageTar\", \"packageDir\", \"commandDir\", \"dir\"]) {\n\t\tif (typeof record[legacy] === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`agentOS package ref uses removed field \"${legacy}\"; packages are referenced ` +\n\t\t\t\t\t\"by a single `packagePath` — rebuild @agentos-software/* dependencies or pass { packagePath }\",\n\t\t\t);\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction normalizedPackageRefs(software: unknown[]): NormalizedPackageRef[] {\n\tconst refs: NormalizedPackageRef[] = [];\n\tconst seen = new Set<string>();\n\tfor (const entry of software.flat()) {\n\t\tconst ref = normalizePackageRef(entry);\n\t\tif (!ref || seen.has(ref.path)) continue;\n\t\tseen.add(ref.path);\n\t\trefs.push(ref);\n\t}\n\treturn refs;\n}\n\nexport function buildConfigJson<TConnParams>(\n\tparsed: AgentOsActorConfig<TConnParams>,\n): string {\n\tconst options = nativeAgentOsOptionsSchema.parse(\n\t\tparsed.options ?? {},\n\t) as Record<string, unknown>;\n\tconst softwareInput = Array.isArray(options.software) ? options.software : [];\n\tconst defaultSoftwareEnabled = options.defaultSoftware !== false;\n\tconst packageRefs = normalizedPackageRefs(\n\t\tdefaultSoftwareEnabled ? [common, ...softwareInput] : softwareInput,\n\t);\n\tconst packages = packageRefs.map((ref) => ({ packagePath: ref.path }));\n\tconst mounts = serializeNativeMounts(options.mounts);\n\tconst sidecar = serializeSidecar(options.sidecar);\n\treturn JSON.stringify({\n\t\t// The actor forwards ONLY package dirs; the sidecar resolves each agent from\n\t\t// the projected `/opt/agentos/<name>/current/agentos-package.json` (no\n\t\t// client-side adapter-entrypoint resolution — see root CLAUDE.md).\n\t\tpackages,\n\t\tpackagesMountAt: OPT_AGENTOS_ROOT,\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\t// Custom inspector tabs. The native-plugin path bypasses the normal\n\t\t\t// actor-config assembly (`buildActorConfig`/`inspectorTabs`), so the\n\t\t\t// tabs MUST ride on the plugin options: the Rust NAPI binding\n\t\t\t// `from_native_plugin` forwards `inspectorTabs` into the actor config so\n\t\t\t// the dashboard serves `/inspector/custom-tabs/<id>/` and advertises them\n\t\t\t// in `tab-config`. (Setting `actor({ inspector })` alone does nothing for\n\t\t\t// native-plugin actors.)\n\t\t\tinspectorTabs: AGENTOS_INSPECTOR_CONFIG.tabs,\n\t\t} as NapiNativePluginOptions & {\n\t\t\tinspectorTabs: typeof AGENTOS_INSPECTOR_CONFIG.tabs;\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 TS\n * surface because the Rust plugin owns the broadcast set, but the ACTIONS are\n * typed via {@link AgentOsActions} — a TS mirror of the Rust dispatch in\n * `crates/agentos-actor-plugin/src/actions/mod.rs`. That is what gives\n * `createClient<typeof registry>()` a fully-typed handle (e.g. `handle.exec()`\n * returns `ExecResult`, not `unknown`). Keep the two in sync.\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\tAgentOsActions\n>;\n\n// One hour — far past any normal agent turn, connection setup, or idle gap, but\n// still a finite bound (never `0`/Infinity) per the limits-and-observability\n// policy. Agent turns routinely run minutes; the stock RivetKit defaults\n// (actionTimeout 60s, on{Before,}ConnectTimeout 5s, sleepTimeout 30s) cut them\n// off mid-flight and broke live `sessionEvent` streaming with\n// \"actor websocket connection setup timed out after 5000 ms\".\nconst ACTOR_NEVER_HIT_MS = 60 * 60 * 1000;\n// 512 MiB — large prompts/results stream as single actor messages; the stock\n// 64 KiB incoming / 1 MiB outgoing caps truncate real agent payloads.\nconst ACTOR_NEVER_HIT_MESSAGE_BYTES = 512 * 1024 * 1024;\n\n/**\n * Never-hit-by-normal-use defaults for the AgentOS actor. Every value is a high\n * but finite bound so a long multi-step agent turn, a slow connection setup, a\n * large prompt/result, and live `sessionEvent` streaming all complete without\n * tripping a RivetKit actor default. Callers can still override any single knob\n * via `actorOptions` (their value wins over these defaults).\n */\nexport const DEFAULT_AGENTOS_ACTOR_OPTIONS = {\n\t// Connection/setup lifecycle (stock 5s each) — the websocket setup path that\n\t// was timing out at 5000ms and dropping all streamed events.\n\tonBeforeConnectTimeout: ACTOR_NEVER_HIT_MS,\n\tonConnectTimeout: ACTOR_NEVER_HIT_MS,\n\tcreateVarsTimeout: ACTOR_NEVER_HIT_MS,\n\tcreateConnStateTimeout: ACTOR_NEVER_HIT_MS,\n\tonMigrateTimeout: ACTOR_NEVER_HIT_MS,\n\t// Action/RPC lifecycle (stock 60s) — long multi-step prompt turns.\n\tactionTimeout: ACTOR_NEVER_HIT_MS,\n\t// Idle/keepalive — don't reap a live session or sleep mid-turn (stock\n\t// connectionLivenessTimeout 2.5s, sleepTimeout 30s). The liveness *interval*\n\t// (ping cadence) is intentionally left at its small default.\n\tconnectionLivenessTimeout: ACTOR_NEVER_HIT_MS,\n\tsleepTimeout: ACTOR_NEVER_HIT_MS,\n\t// Payload sizes — large prompts/results. `maxQueueMessageSize` is the\n\t// per-actor message cap (stock 64 KiB); the transport-level\n\t// max{Incoming,Outgoing}MessageSize live on the registry/setup config (see\n\t// AGENTOS_REGISTRY_MESSAGE_SIZE_DEFAULTS), not on per-actor options.\n\tmaxQueueSize: 1_000_000,\n\tmaxQueueMessageSize: ACTOR_NEVER_HIT_MESSAGE_BYTES,\n} as const;\n\n// Absolute path to the built inspector-tabs app (the shared Vite bundle). All\n// custom tabs share this one `source` dir; the app routes on the\n// `/inspector/custom-tabs/<id>/` URL segment. Resolves from both `src/` (tsx dev\n// / the demo) and the published `dist/`, since `assets/` sits at the package\n// root in both layouts.\nconst INSPECTOR_TABS_ASSET_DIR = join(\n\tdirname(fileURLToPath(import.meta.url)),\n\t\"..\",\n\t\"assets\",\n\t\"inspector-tabs-app\",\n);\n\n// Custom inspector tabs shipped by agent-os. Ids MUST match the `TABS` registry\n// in `src/inspector-tabs/main.tsx`. The built-in rivetkit tabs are hidden so the\n// dashboard shows only the agent-os tabs.\nconst AGENTOS_INSPECTOR_CONFIG = {\n\ttabs: [\n\t\t{ id: \"transcript\", label: \"Transcript\", source: INSPECTOR_TABS_ASSET_DIR, icon: \"comments\" },\n\t\t{ id: \"filesystem\", label: \"Filesystem\", source: INSPECTOR_TABS_ASSET_DIR, icon: \"folder-tree\" },\n\t\t{ id: \"processes\", label: \"Processes\", source: INSPECTOR_TABS_ASSET_DIR, icon: \"microchip\" },\n\t\t{ id: \"software\", label: \"Software\", source: INSPECTOR_TABS_ASSET_DIR, icon: \"box-archive\" },\n\t\t{ id: \"mounts\", label: \"Mounts\", source: INSPECTOR_TABS_ASSET_DIR, icon: \"hard-drive\" },\n\t\t...([\"workflow\", \"database\", \"state\", \"queue\", \"connections\", \"console\"].map(\n\t\t\t(id) => ({ id, hidden: true as const }),\n\t\t)),\n\t],\n};\n\nexport function createAgentOS<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 userActorOptions = (\n\t\tparsed as { actorOptions?: Record<string, unknown> }\n\t).actorOptions;\n\t// High never-hit defaults, with any caller-supplied option winning.\n\tconst actorOptions = {\n\t\t...DEFAULT_AGENTOS_ACTOR_OPTIONS,\n\t\t...(userActorOptions ?? {}),\n\t};\n\tconst definition = actor({\n\t\tactions: {},\n\t\toptions: actorOptions,\n\t\t// Register the custom agent-os inspector tabs (and hide the built-in\n\t\t// rivetkit tabs) so the dashboard renders the agent-os UI. Without this\n\t\t// the shipped tab assets are never surfaced.\n\t\tinspector: AGENTOS_INSPECTOR_CONFIG,\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\tNativeMountConfig,\n\tPermissionRequest,\n} from \"@rivet-dev/agentos-core\";\nimport {\n\tagentOsOptionFieldSchemas,\n\tnativeMountConfigSchema,\n\tsharedSidecarConfigSchema,\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\nexport const nativeAgentOsOptionsSchema = z\n\t// Native actor options are a JSON-serializable subset of AgentOsOptions.\n\t// Keep this allow-list in sync with buildConfigJson() and\n\t// crates/agentos-actor-plugin/src/config.rs::AgentOsConfigJson.\n\t.object({\n\t\tsoftware: agentOsOptionFieldSchemas.software,\n\t\tdefaultSoftware: agentOsOptionFieldSchemas.defaultSoftware,\n\t\tloopbackExemptPorts: agentOsOptionFieldSchemas.loopbackExemptPorts,\n\t\tallowedNodeBuiltins: agentOsOptionFieldSchemas.allowedNodeBuiltins,\n\t\trootFilesystem: agentOsOptionFieldSchemas.rootFilesystem,\n\t\tmounts: z.array(nativeMountConfigSchema).optional(),\n\t\tadditionalInstructions: agentOsOptionFieldSchemas.additionalInstructions,\n\t\tpermissions: agentOsOptionFieldSchemas.permissions,\n\t\tsidecar: sharedSidecarConfigSchema.optional(),\n\t\tlimits: agentOsOptionFieldSchemas.limits,\n\t})\n\t.strict();\n\n/**\n * RivetKit actor lifecycle/transport options forwarded to `actor({ options })`.\n *\n * Validated downstream by RivetKit's own actor config schema, so this stays a\n * permissive pass-through allow-list. `agentOS()` overlays the never-hit\n * defaults in `DEFAULT_AGENTOS_ACTOR_OPTIONS` (see actor.ts) and lets any value\n * here win, so callers can still tighten a bound when they want one.\n */\nexport const agentOsActorOptionsSchema = z\n\t.record(z.string(), z.unknown())\n\t.optional();\n\nexport const agentOsActorConfigSchema = z\n\t.object({\n\t\toptions: nativeAgentOsOptionsSchema.optional(),\n\t\tactorOptions: agentOsActorOptionsSchema,\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\n/**\n * Type mirror of `nativeAgentOsOptionsSchema`.\n *\n * Keep this in sync with the schema above and the Rust serde mirror at\n * `crates/agentos-actor-plugin/src/config.rs::AgentOsConfigJson`.\n */\nexport type NativeAgentOsOptions = Pick<\n\tAgentOsOptions,\n\t| \"software\"\n\t| \"defaultSoftware\"\n\t| \"loopbackExemptPorts\"\n\t| \"allowedNodeBuiltins\"\n\t| \"rootFilesystem\"\n\t| \"additionalInstructions\"\n\t| \"permissions\"\n\t| \"limits\"\n> & {\n\tmounts?: NativeMountConfig[];\n\tsidecar?: { kind: \"shared\"; pool?: string };\n};\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\"options\" | \"onBeforeConnect\" | \"onSessionEvent\" | \"onPermissionRequest\"\n> &\n\t{ options?: NativeAgentOsOptions } &\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\"options\" | \"onBeforeConnect\" | \"onSessionEvent\" | \"onPermissionRequest\"\n> &\n\t{ options?: NativeAgentOsOptions } &\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 type {\n\tAgentOsOptions,\n\tJsonRpcNotification,\n\tPermissionRequest,\n} from \"@rivet-dev/agentos-core\";\nimport {\n\ttype AgentOsActorDefinition,\n\tcreateAgentOS,\n} from \"./actor.js\";\nimport type {\n\tAgentOsActorConfigInput,\n\tNativeAgentOsOptions,\n} from \"./config.js\";\n\nimport { setup as rivetkitSetup } from \"rivetkit\";\n\n// 512 MiB — large agent prompts/results cross the actor websocket transport as\n// single messages; RivetKit's registry-level defaults (maxIncomingMessageSize\n// 64 KiB, maxOutgoingMessageSize 1 MiB) truncate real payloads. Still a finite\n// bound per the limits-and-observability policy.\nconst AGENTOS_REGISTRY_MESSAGE_SIZE_DEFAULT = 512 * 1024 * 1024;\n\n/**\n * `setup()` wrapper that defaults the registry transport message-size caps to\n * never-hit-by-normal-use values for AgentOS apps, mirroring the per-actor crank\n * in `DEFAULT_AGENTOS_ACTOR_OPTIONS`. Any caller-supplied value wins, so an app\n * can still tighten the bound when it wants one.\n */\nexport const setup: typeof rivetkitSetup = ((\n\tinput: Parameters<typeof rivetkitSetup>[0],\n) =>\n\trivetkitSetup({\n\t\tmaxIncomingMessageSize: AGENTOS_REGISTRY_MESSAGE_SIZE_DEFAULT,\n\t\tmaxOutgoingMessageSize: AGENTOS_REGISTRY_MESSAGE_SIZE_DEFAULT,\n\t\t...input,\n\t})) as typeof rivetkitSetup;\n\nexport {\n\tbuildConfigJson,\n\ttype NodeModulesMountConfig,\n\tnodeModulesMount,\n} from \"./actor.js\";\nexport {\n\ttype AgentOsActorConfig,\n\ttype AgentOsActorConfigInput,\n\ttype NativeAgentOsOptions,\n\tagentOsActorConfigSchema,\n\tnativeAgentOsOptionsSchema,\n} from \"./config.js\";\nexport { getPluginPath } from \"./plugin-binary.js\";\n\n// Re-export the software-definition helper so custom agents/tools/commands can\n// be defined without importing @rivet-dev/agentos-core directly.\nexport { defineSoftware } from \"@rivet-dev/agentos-core\";\n\nexport type {\n\tAgentOsActionContext,\n\tAgentOsActorState,\n\tAgentOsActorVars,\n\tAgentOsEvents,\n\tAgentCrashedPayload,\n\tCronEventPayload,\n\tPermissionRequestPayload,\n\tPersistedSessionEvent,\n\tPersistedSessionRecord,\n\tProcessExitPayload,\n\tProcessOutputPayload,\n\tPromptResult,\n\tSerializableCronAction,\n\tSerializableCronEvent,\n\tSerializableCronJobInfo,\n\tSerializableCronJobOptions,\n\tSessionEventPayload,\n\tSessionRecord,\n\tShellDataPayload,\n\tVmBootedPayload,\n\tVmShutdownPayload,\n} from \"./types.js\";\nexport type {\n\tAgentOsActions,\n\tCreateSessionOptions,\n\tDirEntry,\n\tReadFileResult,\n\tScheduledCronJob,\n\tSignedPreviewUrl,\n\tSpawnedProcess,\n\tVmFetchOptions,\n\tVmFetchResponse,\n\tWriteFileResult,\n} from \"./actor-actions.js\";\n\nexport type AgentOSActorConfigInput<TConnParams = undefined> =\n\tNativeAgentOsOptions &\n\t\tOmit<AgentOsActorConfigInput<TConnParams>, \"options\">;\n\nexport type AgentOSConfigInput<TConnParams = undefined> = AgentOsOptions & {\n\tpreview?: AgentOsActorConfigInput<TConnParams>[\"preview\"];\n\tonBeforeConnect?: AgentOsActorConfigInput<TConnParams>[\"onBeforeConnect\"];\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};\n\nexport function agentOS<TConnParams = undefined>(\n\tconfig: AgentOSConfigInput<TConnParams> = {},\n): AgentOsActorDefinition<TConnParams> {\n\tconst {\n\t\tpreview,\n\t\tonBeforeConnect,\n\t\tonSessionEvent,\n\t\tonPermissionRequest,\n\t\t...options\n\t} = config;\n\n\treturn createAgentOS({\n\t\toptions,\n\t\tpreview,\n\t\tonBeforeConnect,\n\t\tonSessionEvent: onSessionEvent\n\t\t\t? (_ctx, sessionId, event) => onSessionEvent(sessionId, event)\n\t\t\t: undefined,\n\t\tonPermissionRequest: onPermissionRequest\n\t\t\t? (_ctx, sessionId, request) => onPermissionRequest(sessionId, request)\n\t\t\t: undefined,\n\t} as AgentOsActorConfigInput<TConnParams>);\n}\n"],"mappings":";AAYA,SAAS,WAAAA,UAAS,QAAAC,aAAY;AAC9B,SAAS,iBAAAC,sBAAqB;AAC9B,OAAO,YAAY;AACnB,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B;AAAA,EACC;AAAA,OAOM;;;ACnBP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,SAAS;AAGlB,IAAM,YAAY,MAEX,EAAE,OAAU,CAAC,QAAQ,OAAO,QAAQ,UAAU;AAE9C,IAAM,6BAA6B,EAIxC,OAAO;AAAA,EACP,UAAU,0BAA0B;AAAA,EACpC,iBAAiB,0BAA0B;AAAA,EAC3C,qBAAqB,0BAA0B;AAAA,EAC/C,qBAAqB,0BAA0B;AAAA,EAC/C,gBAAgB,0BAA0B;AAAA,EAC1C,QAAQ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,IACA;AAAA,IACA;AAAA,IACA,gBAAgB,iBACb,CAAC,MAAM,WAAW,UAAU,eAAe,WAAW,KAAK,IAC3D;AAAA,IACH,qBAAqB,sBAClB,CAAC,MAAM,WAAW,YAAY,oBAAoB,WAAW,OAAO,IACpE;AAAA,EACJ,CAAyC;AAC1C;","names":["dirname","join","fileURLToPath","require","join","dirname","fileURLToPath"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/actor.ts"],"sourcesContent":["import { setup as rivetkitSetup } from \"rivetkit\";\n\nconst AGENTOS_REGISTRY_MESSAGE_SIZE_DEFAULT = 512 * 1024 * 1024;\n\n/**\n * RivetKit setup with the direct actor SQLite UDS enabled. The UDS is consumed\n * by the AgentOS sidecar; filesystem SQL never crosses the JavaScript layer.\n */\nexport const setup: typeof rivetkitSetup = ((\n\tinput: Parameters<typeof rivetkitSetup>[0],\n) =>\n\trivetkitSetup({\n\t\t...input,\n\t\tmaxIncomingMessageSize: AGENTOS_REGISTRY_MESSAGE_SIZE_DEFAULT,\n\t\tmaxOutgoingMessageSize: AGENTOS_REGISTRY_MESSAGE_SIZE_DEFAULT,\n\t\texperimentalActorUds: true,\n\t} as Parameters<typeof rivetkitSetup>[0])) as typeof rivetkitSetup;\n\nexport type {\n\tAgentOsOptions,\n\tDirEntry,\n\tDynamicMountDescriptor,\n\tExportRootFilesystemOptions,\n\tHttpRequest,\n\tHttpResponse,\n\tMountInfo,\n\tNodeModulesMountConfig,\n\tPackageDescriptor,\n\tProcessExit,\n\tProcessOutput,\n\tPromptResult,\n\tReaddirEntry,\n\tRootSnapshotExport,\n\tSessionInfo,\n\tShellData,\n\tShellExit,\n} from \"@rivet-dev/agentos-core\";\nexport { defineSoftware, nodeModulesMount } from \"@rivet-dev/agentos-core\";\nexport type {\n\tAgentOsActorConfigInput as AgentOSActorConfigInput,\n\tAgentOsActorConfigInput as AgentOSConfigInput,\n} from \"./actor.js\";\nexport {\n\ttype AgentOsActions,\n\ttype AgentOsActorConfigInput,\n\ttype AgentOsActorExtras,\n\ttype AgentOsEventHooks,\n\tcreateAgentOS,\n\tcreateAgentOS as agentOS,\n\tcreateAgentOsActions,\n} from \"./actor.js\";\nexport type {\n\tAgentOsEvents,\n\tProcessExitPayload,\n\tProcessOutputPayload,\n\tSerializableCronAction,\n\tSerializableCronEvent,\n\tSerializableCronJobInfo,\n\tSerializableCronJobOptions,\n\tShellDataPayload,\n\tShellExitPayload,\n\tVmBootedPayload,\n\tVmShutdownPayload,\n} from \"./types.js\";\n","import crypto from \"node:crypto\";\nimport {\n\tAgentOs,\n\ttype AgentExitEvent,\n\ttype AgentOsOptions,\n\ttype CronEvent,\n\ttype DynamicMountDescriptor,\n\ttype OpenSessionInput,\n\ttype PackageDescriptor,\n\ttype PromptInput,\n\ttype SessionStreamEntry,\n} from \"@rivet-dev/agentos-core\";\nimport {\n\ttype Actions,\n\ttype ActorConfigInput,\n\ttype ActorContext,\n\ttype ActorDefinition,\n\tactor,\n\tevent,\n\ttype Type,\n\tUserError,\n} from \"rivetkit\";\nimport { type DatabaseProvider, db, type RawAccess } from \"rivetkit/db\";\nimport type {\n\tAgentOsEvents,\n\tProcessExitPayload,\n\tProcessOutputPayload,\n\tSerializableCronJobOptions,\n\tShellDataPayload,\n\tShellExitPayload,\n\tVmBootedPayload,\n\tVmShutdownPayload,\n} from \"./types.js\";\n\n// Prompts may remain paused at a permission request for a long human review.\n// RivetKit currently exposes only one actor-wide action timeout, so use the\n// largest value Node timers can represent safely (~24.8 days). Callers may\n// still opt into a shorter timeout through actor options.\nconst DEFAULT_ACTION_TIMEOUT_MS = 2_147_483_647;\nconst DEFAULT_SLEEP_GRACE_PERIOD_MS = 15 * 60_000;\nconst DEFAULT_PREVIEW_TTL_SECONDS = 3_600;\nconst MAX_PREVIEW_TTL_SECONDS = 86_400;\nconst DEFAULT_MAX_ACTIVE_PREVIEW_TOKENS = 1_024;\nconst DEFAULT_MAX_SESSION_SUBSCRIPTIONS = 10_000;\nconst DEFAULT_MAX_DYNAMIC_MOUNTS = 10_000;\nconst DEFAULT_MAX_LINKED_SOFTWARE = 10_000;\nconst ACTOR_SQLITE_CHUNK_SIZE = 512 * 1024;\nconst ACTOR_SQLITE_INLINE_THRESHOLD = 64 * 1024;\nconst ROOT_NAMESPACE = \"agentos-root\";\nconst PREVIEW_PATH_PATTERN = /^\\/fetch\\/([a-f0-9]{48})(\\/.*)?$/;\nconst MAX_SQLITE_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;\n\ninterface ActorSqliteMigration {\n\treadonly version: number;\n\treadonly sql: string;\n}\n\nconst ACTOR_SQLITE_MIGRATIONS = [\n\t{\n\t\tversion: 1,\n\t\tsql: `\n\t\t\tCREATE TABLE agentos_actor_preview_tokens (\n\t\t\t\ttoken TEXT PRIMARY KEY CHECK (length(token) = 48 AND token NOT GLOB '*[^0-9a-f]*'),\n\t\t\t\tport INTEGER NOT NULL CHECK (port BETWEEN 1 AND 65535),\n\t\t\t\tcreated_at_ms INTEGER NOT NULL CHECK (created_at_ms BETWEEN 0 AND ${MAX_SQLITE_SAFE_INTEGER}),\n\t\t\t\texpires_at_ms INTEGER NOT NULL CHECK (expires_at_ms > created_at_ms AND expires_at_ms <= ${MAX_SQLITE_SAFE_INTEGER})\n\t\t\t) STRICT;\n\t\t\tCREATE INDEX agentos_actor_preview_tokens_by_expiry\n\t\t\t\tON agentos_actor_preview_tokens(expires_at_ms);\n\t\t\tCREATE TABLE agentos_actor_dynamic_mounts (\n\t\t\t\tpath TEXT PRIMARY KEY CHECK (substr(path, 1, 1) = '/' AND instr(path, char(0)) = 0),\n\t\t\t\tdescriptor_json TEXT NOT NULL CHECK (json_valid(descriptor_json) AND json_type(descriptor_json) = 'object')\n\t\t\t) STRICT;\n\t\t\tCREATE TABLE agentos_actor_linked_software (\n\t\t\t\tpath TEXT PRIMARY KEY CHECK (length(path) > 0 AND instr(path, char(0)) = 0),\n\t\t\t\tdescriptor_json TEXT NOT NULL CHECK (json_valid(descriptor_json) AND json_type(descriptor_json) = 'object')\n\t\t\t) STRICT;\n\t\t`,\n\t},\n] as const satisfies readonly ActorSqliteMigration[];\n\ntype BuiltInEvents = {\n\t[K in keyof AgentOsEvents]: Type<AgentOsEvents[K]>;\n};\n\nconst builtInEvents: BuiltInEvents = {\n\tsessionEvent: event<SessionStreamEntry>(),\n\tvmBooted: event<VmBootedPayload>(),\n\tvmShutdown: event<VmShutdownPayload>(),\n\tprocessOutput: event<ProcessOutputPayload>(),\n\tprocessExit: event<ProcessExitPayload>(),\n\tshellData: event<ShellDataPayload>(),\n\tcronEvent: event<CronEvent>(),\n\tagentExit: event<AgentExitEvent>(),\n\tshellStderr: event<ShellDataPayload>(),\n\tshellExit: event<ShellExitPayload>(),\n};\ntype ActorDb = DatabaseProvider<RawAccess>;\ntype EventSchemaConfig = Record<string, any>;\ntype QueueSchemaConfig = Record<string, any>;\ntype AnyContext = ActorContext<any, any, any, any, any, ActorDb, any, any>;\n\ninterface RuntimeState {\n\tvm: Promise<AgentOs> | null;\n\tsubscribedSessions: Map<string, readonly (() => void)[]>;\n}\n\nconst runtimes = new Map<string, RuntimeState>();\n\nfunction runtimeFor(c: AnyContext): RuntimeState {\n\tlet runtime = runtimes.get(c.actorId);\n\tif (!runtime) {\n\t\truntime = { vm: null, subscribedSessions: new Map() };\n\t\truntimes.set(c.actorId, runtime);\n\t}\n\treturn runtime;\n}\n\nasync function ensureVm(\n\tc: AnyContext,\n\toptions?: AgentOsOptions,\n): Promise<AgentOs> {\n\tconst runtime = runtimeFor(c);\n\tif (runtime.vm !== null) return runtime.vm;\n\n\tconst startedAt = Date.now();\n\truntime.vm = (async () => {\n\t\tconst actorUds = (\n\t\t\tc as AnyContext & {\n\t\t\t\tactorUds(): Promise<{ path: string; token: string }>;\n\t\t\t}\n\t\t).actorUds;\n\t\tif (typeof actorUds !== \"function\") {\n\t\t\tthrow new Error(\n\t\t\t\t\"AgentOS actors require a RivetKit runtime with experimental actor UDS support\",\n\t\t\t);\n\t\t}\n\t\tconst { path, token } = await actorUds.call(c);\n\t\tconst mountRows = await c.db.execute<{ descriptor_json: string }>(\n\t\t\t\"SELECT descriptor_json FROM agentos_actor_dynamic_mounts ORDER BY path\",\n\t\t);\n\t\tconst softwareRows = await c.db.execute<{ descriptor_json: string }>(\n\t\t\t\"SELECT descriptor_json FROM agentos_actor_linked_software ORDER BY path\",\n\t\t);\n\t\tconst vm = await AgentOs.create({\n\t\t\t...options,\n\t\t\tdatabase: { type: \"actor_uds\", path, token },\n\t\t\tonAgentExit: (event) => {\n\t\t\t\tc.log.error({\n\t\t\t\t\tmsg: \"agent-os agent adapter exited unexpectedly\",\n\t\t\t\t\t...event,\n\t\t\t\t});\n\t\t\t\tc.broadcast(\"agentExit\", event);\n\t\t\t\ttry {\n\t\t\t\t\toptions?.onAgentExit?.(event);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tc.log.error({\n\t\t\t\t\t\tmsg: \"agent-os onAgentExit hook failed\",\n\t\t\t\t\t\tsessionId: event.sessionId,\n\t\t\t\t\t\terror,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\trootFilesystem: {\n\t\t\t\ttype: \"native\",\n\t\t\t\tplugin: {\n\t\t\t\t\tid: \"chunked_actor_sqlite\",\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tnamespace: ROOT_NAMESPACE,\n\t\t\t\t\t\tchunkSize: ACTOR_SQLITE_CHUNK_SIZE,\n\t\t\t\t\t\tinlineThreshold: ACTOR_SQLITE_INLINE_THRESHOLD,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\ttry {\n\t\t\tfor (const row of mountRows) {\n\t\t\t\tawait vm.mountFs(\n\t\t\t\t\tJSON.parse(row.descriptor_json) as DynamicMountDescriptor,\n\t\t\t\t);\n\t\t\t}\n\t\t\tfor (const row of softwareRows) {\n\t\t\t\tawait vm.linkSoftware(\n\t\t\t\t\tJSON.parse(row.descriptor_json) as PackageDescriptor,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tawait vm.dispose();\n\t\t\tthrow error;\n\t\t}\n\t\tvm.onCronEvent((cronEvent) => c.broadcast(\"cronEvent\", cronEvent));\n\t\tc.broadcast(\"vmBooted\", {});\n\t\tc.log.info({\n\t\t\tmsg: \"agent-os vm booted\",\n\t\t\tbootDurationMs: Date.now() - startedAt,\n\t\t});\n\t\treturn vm;\n\t})();\n\n\ttry {\n\t\treturn await runtime.vm;\n\t} catch (error) {\n\t\truntime.vm = null;\n\t\tthrow error;\n\t}\n}\n\nasync function disposeVm(c: AnyContext, reason: \"sleep\" | \"destroy\" | \"error\") {\n\tconst runtime = runtimes.get(c.actorId);\n\tif (!runtime) return;\n\tconst vm = runtime.vm;\n\truntimes.delete(c.actorId);\n\tfor (const unsubscribers of runtime.subscribedSessions.values()) {\n\t\tfor (const unsubscribe of unsubscribers) unsubscribe();\n\t}\n\truntime.subscribedSessions.clear();\n\tif (vm) await (await vm).dispose();\n\tc.broadcast(\"vmShutdown\", { reason });\n}\n\nfunction matchPreviewPath(pathname: string): RegExpMatchArray | null {\n\treturn pathname.match(PREVIEW_PATH_PATTERN);\n}\n\n/** @internal Exported only for focused migration-ladder tests. */\nexport function validateAgentOsActorMigrationLadder(\n\tmigrations: readonly ActorSqliteMigration[],\n): void {\n\tif (migrations.length === 0) {\n\t\tthrow new Error(\"AgentOS actor SQLite migration ladder must not be empty\");\n\t}\n\tfor (const [index, migration] of migrations.entries()) {\n\t\tconst expectedVersion = index + 1;\n\t\tif (migration.version !== expectedVersion) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid AgentOS actor SQLite migration ladder: expected version ${expectedVersion}, received ${migration.version}`,\n\t\t\t);\n\t\t}\n\t\tif (migration.sql.trim().length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid AgentOS actor SQLite migration ${migration.version}: SQL is empty`,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t/(?:^|;)\\s*(?:BEGIN|COMMIT|ROLLBACK|SAVEPOINT|RELEASE)\\b/im.test(\n\t\t\t\tmigration.sql,\n\t\t\t)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid AgentOS actor SQLite migration ${migration.version}: transaction control belongs to the migration provider`,\n\t\t\t);\n\t\t}\n\t\tif (/\\b(?:FOREIGN\\s+KEY|REFERENCES)\\b/i.test(migration.sql)) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid AgentOS actor SQLite migration ${migration.version}: foreign keys are not used in the actor-owned schema`,\n\t\t\t);\n\t\t}\n\t\tfor (const statement of migration.sql.split(\";\")) {\n\t\t\tif (\n\t\t\t\t/^\\s*CREATE\\s+TABLE\\b/i.test(statement) &&\n\t\t\t\t!/[)]\\s*STRICT\\s*$/i.test(statement)\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`invalid AgentOS actor SQLite migration ${migration.version}: every actor-owned table must be STRICT`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconst ownedIdentifiers = migration.sql.match(/\\bagentos_[a-z0-9_]+\\b/gi);\n\t\tif (\n\t\t\t!ownedIdentifiers ||\n\t\t\townedIdentifiers.some(\n\t\t\t\t(identifier) => !identifier.startsWith(\"agentos_actor_\"),\n\t\t\t)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid AgentOS actor SQLite migration ${migration.version}: migrations may reference only agentos_actor_* tables and indexes`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** @internal Exported only for focused migration tests. */\nexport async function migrateAgentOsActorTables(\n\tdatabase: RawAccess,\n): Promise<void> {\n\tvalidateAgentOsActorMigrationLadder(ACTOR_SQLITE_MIGRATIONS);\n\tawait database.execute(`\n\t\tCREATE TABLE IF NOT EXISTS agentos_actor_schema_version (\n\t\t\tsingleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n\t\t\tschema_version INTEGER NOT NULL CHECK (schema_version BETWEEN 0 AND ${MAX_SQLITE_SAFE_INTEGER})\n\t\t) STRICT;\n\t`);\n\tconst rows = await database.execute<{ schema_version: unknown }>(\n\t\t\"SELECT schema_version FROM agentos_actor_schema_version WHERE singleton = 1\",\n\t);\n\tif (rows.length > 1) {\n\t\tthrow new Error(\n\t\t\t`invalid AgentOS actor SQLite schema version table: expected at most one row, received ${rows.length}`,\n\t\t);\n\t}\n\tconst rawCurrent = rows[0]?.schema_version;\n\tconst current = rows.length === 0 ? 0 : rawCurrent;\n\tif (\n\t\ttypeof current !== \"number\" ||\n\t\t!Number.isSafeInteger(current) ||\n\t\tcurrent < 0\n\t) {\n\t\tthrow new Error(\n\t\t\t`invalid AgentOS actor SQLite schema version ${String(rawCurrent)}`,\n\t\t);\n\t}\n\tif (current > ACTOR_SQLITE_MIGRATIONS.length) {\n\t\tthrow new Error(\n\t\t\t`AgentOS actor SQLite schema version ${current} is newer than supported version ${ACTOR_SQLITE_MIGRATIONS.length}`,\n\t\t);\n\t}\n\tfor (const migration of ACTOR_SQLITE_MIGRATIONS.slice(current)) {\n\t\tawait database.execute(migration.sql);\n\t\tawait database.execute(\n\t\t\t`INSERT INTO agentos_actor_schema_version (singleton, schema_version)\n\t\t\t VALUES (1, ?)\n\t\t\t ON CONFLICT(singleton) DO UPDATE SET schema_version = excluded.schema_version`,\n\t\t\tmigration.version,\n\t\t);\n\t}\n}\n\nasync function assertActorCollectionCapacity(\n\tc: AnyContext,\n\ttable: \"agentos_actor_dynamic_mounts\" | \"agentos_actor_linked_software\",\n\tkey: string,\n\tlimit: number,\n\tlabel: \"dynamic mounts\" | \"linked software packages\",\n\tconfigKey: \"maxDynamicMounts\" | \"maxLinkedSoftware\",\n): Promise<void> {\n\tconst existing = await c.db.execute<{ present: number }>(\n\t\t`SELECT 1 AS present FROM ${table} WHERE path = ? LIMIT 1`,\n\t\tkey,\n\t);\n\tif (existing.length > 0) return;\n\tconst rows = await c.db.execute<{ count: number }>(\n\t\t`SELECT COUNT(*) AS count FROM ${table}`,\n\t);\n\tconst count = Number(rows[0]?.count ?? 0);\n\tif (count >= limit) {\n\t\tthrow new UserError(\n\t\t\t`${label} limit ${limit} reached; raise ${configKey} to persist more`,\n\t\t\t{\n\t\t\t\tcode: `agentos_${configKey === \"maxDynamicMounts\" ? \"dynamic_mount\" : \"linked_software\"}_limit`,\n\t\t\t\tmetadata: { limit },\n\t\t\t},\n\t\t);\n\t}\n\tif (count + 1 === Math.ceil(limit * 0.8)) {\n\t\tc.log.warn({\n\t\t\tmsg: `${label} are near the limit of ${limit}; raise ${configKey} to persist more`,\n\t\t\tcount: count + 1,\n\t\t\tlimit,\n\t\t});\n\t}\n}\n\nexport interface AgentOsEventHooks<TContext = AnyContext> {\n\tonSessionEvent?: (\n\t\tc: TContext,\n\t\tsessionId: string,\n\t\tevent: SessionStreamEntry,\n\t) => void | Promise<void>;\n}\n\nfunction trackSessionEvents(\n\tc: AnyContext,\n\tvm: AgentOs,\n\tsessionId: string,\n\thooks: AgentOsEventHooks,\n\tmaxSessionSubscriptions: number,\n): void {\n\tconst runtime = runtimeFor(c);\n\tif (runtime.subscribedSessions.has(sessionId)) return;\n\tif (runtime.subscribedSessions.size >= maxSessionSubscriptions) {\n\t\tthrow new UserError(\n\t\t\t`session subscription limit ${maxSessionSubscriptions} reached; raise maxSessionSubscriptions to observe more sessions`,\n\t\t\t{\n\t\t\t\tcode: \"agentos_session_subscription_limit\",\n\t\t\t\tmetadata: { limit: maxSessionSubscriptions },\n\t\t\t},\n\t\t);\n\t}\n\tconst nextCount = runtime.subscribedSessions.size + 1;\n\tif (nextCount === Math.ceil(maxSessionSubscriptions * 0.8)) {\n\t\tc.log.warn({\n\t\t\tmsg: `session subscriptions are near the limit of ${maxSessionSubscriptions}; raise maxSessionSubscriptions to observe more sessions`,\n\t\t\tsubscriptionCount: nextCount,\n\t\t\tlimit: maxSessionSubscriptions,\n\t\t});\n\t}\n\tconst unsubscribeSession = vm.onSessionEvent(\n\t\tsessionId,\n\t\t(notification: SessionStreamEntry) => {\n\t\t\tconst serialized = JSON.parse(\n\t\t\t\tJSON.stringify(notification),\n\t\t\t) as SessionStreamEntry;\n\t\t\tc.broadcast(\"sessionEvent\", serialized);\n\t\t\tif (hooks.onSessionEvent) {\n\t\t\t\tc.waitUntil(\n\t\t\t\t\tPromise.resolve()\n\t\t\t\t\t\t.then(() => hooks.onSessionEvent?.(c, sessionId, serialized))\n\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\tc.log.error({\n\t\t\t\t\t\t\t\tmsg: \"agent-os session event hook failed\",\n\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t);\n\truntime.subscribedSessions.set(sessionId, [unsubscribeSession]);\n}\n\nfunction untrackSessionEvents(c: AnyContext, sessionId: string): void {\n\tconst unsubscribers = runtimeFor(c).subscribedSessions.get(sessionId);\n\tif (!unsubscribers) return;\n\tfor (const unsubscribe of unsubscribers) unsubscribe();\n\truntimeFor(c).subscribedSessions.delete(sessionId);\n}\n\nexport function createAgentOsActions(\n\toptions?: AgentOsOptions,\n\thooks: AgentOsEventHooks = {},\n\tpreview: AgentOsActorExtras[\"preview\"] = {},\n\tmaxSessionSubscriptions = DEFAULT_MAX_SESSION_SUBSCRIPTIONS,\n\tmaxDynamicMounts = DEFAULT_MAX_DYNAMIC_MOUNTS,\n\tmaxLinkedSoftware = DEFAULT_MAX_LINKED_SOFTWARE,\n) {\n\tconst defaultPreviewTtlSeconds =\n\t\tpreview.defaultExpiresInSeconds ?? DEFAULT_PREVIEW_TTL_SECONDS;\n\tconst maxPreviewTtlSeconds =\n\t\tpreview.maxExpiresInSeconds ?? MAX_PREVIEW_TTL_SECONDS;\n\tconst maxActivePreviewTokens =\n\t\tpreview.maxActiveTokens ?? DEFAULT_MAX_ACTIVE_PREVIEW_TOKENS;\n\tif (\n\t\t!Number.isFinite(defaultPreviewTtlSeconds) ||\n\t\tdefaultPreviewTtlSeconds <= 0 ||\n\t\t!Number.isFinite(maxPreviewTtlSeconds) ||\n\t\tmaxPreviewTtlSeconds <= 0 ||\n\t\tdefaultPreviewTtlSeconds > maxPreviewTtlSeconds\n\t) {\n\t\tthrow new UserError(\n\t\t\t\"preview expiry bounds must be positive and the default cannot exceed the maximum\",\n\t\t\t{ code: \"agentos_preview_invalid_config\" },\n\t\t);\n\t}\n\tif (!Number.isInteger(maxActivePreviewTokens) || maxActivePreviewTokens < 1) {\n\t\tthrow new UserError(\"preview.maxActiveTokens must be a positive integer\", {\n\t\t\tcode: \"agentos_preview_invalid_config\",\n\t\t});\n\t}\n\tif (\n\t\t!Number.isInteger(maxSessionSubscriptions) ||\n\t\tmaxSessionSubscriptions < 1\n\t) {\n\t\tthrow new UserError(\"maxSessionSubscriptions must be a positive integer\", {\n\t\t\tcode: \"agentos_session_subscription_invalid_config\",\n\t\t});\n\t}\n\tif (!Number.isInteger(maxDynamicMounts) || maxDynamicMounts < 1) {\n\t\tthrow new UserError(\"maxDynamicMounts must be a positive integer\", {\n\t\t\tcode: \"agentos_dynamic_mount_invalid_config\",\n\t\t});\n\t}\n\tif (!Number.isInteger(maxLinkedSoftware) || maxLinkedSoftware < 1) {\n\t\tthrow new UserError(\"maxLinkedSoftware must be a positive integer\", {\n\t\t\tcode: \"agentos_linked_software_invalid_config\",\n\t\t});\n\t}\n\treturn {\n\t\treadFile: async (c: AnyContext, ...args: Parameters<AgentOs[\"readFile\"]>) =>\n\t\t\t(await ensureVm(c, options)).readFile(...args),\n\t\twriteFile: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"writeFile\"]>\n\t\t) => (await ensureVm(c, options)).writeFile(...args),\n\t\treadFiles: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"readFiles\"]>\n\t\t) => (await ensureVm(c, options)).readFiles(...args),\n\t\twriteFiles: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"writeFiles\"]>\n\t\t) => (await ensureVm(c, options)).writeFiles(...args),\n\t\tstat: async (c: AnyContext, ...args: Parameters<AgentOs[\"stat\"]>) =>\n\t\t\t(await ensureVm(c, options)).stat(...args),\n\t\tmkdir: async (c: AnyContext, ...args: Parameters<AgentOs[\"mkdir\"]>) =>\n\t\t\t(await ensureVm(c, options)).mkdir(...args),\n\t\treaddir: async (c: AnyContext, ...args: Parameters<AgentOs[\"readdir\"]>) =>\n\t\t\t(await ensureVm(c, options)).readdir(...args),\n\t\treaddirEntries: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"readdirEntries\"]>\n\t\t) => (await ensureVm(c, options)).readdirEntries(...args),\n\t\treaddirRecursive: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"readdirRecursive\"]>\n\t\t) => (await ensureVm(c, options)).readdirRecursive(...args),\n\t\texists: async (c: AnyContext, ...args: Parameters<AgentOs[\"exists\"]>) =>\n\t\t\t(await ensureVm(c, options)).exists(...args),\n\t\tmove: async (c: AnyContext, ...args: Parameters<AgentOs[\"move\"]>) =>\n\t\t\t(await ensureVm(c, options)).move(...args),\n\t\tremove: async (c: AnyContext, ...args: Parameters<AgentOs[\"remove\"]>) =>\n\t\t\t(await ensureVm(c, options)).remove(...args),\n\t\texec: async (c: AnyContext, ...args: Parameters<AgentOs[\"exec\"]>) =>\n\t\t\t(await ensureVm(c, options)).exec(...args),\n\t\texecArgv: async (c: AnyContext, ...args: Parameters<AgentOs[\"execArgv\"]>) =>\n\t\t\t(await ensureVm(c, options)).execArgv(...args),\n\t\tspawn: async (c: AnyContext, ...args: Parameters<AgentOs[\"spawn\"]>) => {\n\t\t\tconst vm = await ensureVm(c, options);\n\t\t\tconst process = vm.spawn(...args);\n\t\t\tconst unsubscribeOutput = vm.onProcessOutput(process.pid, (event) =>\n\t\t\t\tc.broadcast(\"processOutput\", event),\n\t\t\t);\n\t\t\tconst unsubscribeExit = vm.onProcessExit(process.pid, (event) =>\n\t\t\t\tc.broadcast(\"processExit\", event),\n\t\t\t);\n\t\t\tvoid c\n\t\t\t\t.keepAwake(\n\t\t\t\t\tvm.waitProcess(process.pid).finally(() => {\n\t\t\t\t\t\tunsubscribeOutput();\n\t\t\t\t\t\tunsubscribeExit();\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.catch((error) =>\n\t\t\t\t\tc.log.error({\n\t\t\t\t\t\tmsg: \"agent-os process wait failed\",\n\t\t\t\t\t\tpid: process.pid,\n\t\t\t\t\t\terror,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\treturn process;\n\t\t},\n\t\twaitProcess: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"waitProcess\"]>\n\t\t) => (await ensureVm(c, options)).waitProcess(...args),\n\t\tkillProcess: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"killProcess\"]>\n\t\t) => (await ensureVm(c, options)).killProcess(...args),\n\t\tstopProcess: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"stopProcess\"]>\n\t\t) => (await ensureVm(c, options)).stopProcess(...args),\n\t\tlistProcesses: async (c: AnyContext) =>\n\t\t\t(await ensureVm(c, options)).listProcesses(),\n\t\tallProcesses: async (c: AnyContext) =>\n\t\t\t(await ensureVm(c, options)).allProcesses(),\n\t\tprocessTree: async (c: AnyContext) =>\n\t\t\t(await ensureVm(c, options)).processTree(),\n\t\tgetProcess: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"getProcess\"]>\n\t\t) => (await ensureVm(c, options)).getProcess(...args),\n\t\twriteProcessStdin: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"writeProcessStdin\"]>\n\t\t) => (await ensureVm(c, options)).writeProcessStdin(...args),\n\t\tcloseProcessStdin: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"closeProcessStdin\"]>\n\t\t) => (await ensureVm(c, options)).closeProcessStdin(...args),\n\t\topenShell: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"openShell\"]>\n\t\t) => {\n\t\t\tconst vm = await ensureVm(c, options);\n\t\t\tconst shell = vm.openShell(...args);\n\t\t\tconst unsubscribeData = vm.onShellData(shell.shellId, (event) =>\n\t\t\t\tc.broadcast(\"shellData\", event),\n\t\t\t);\n\t\t\tconst unsubscribeStderr = vm.onShellStderr(shell.shellId, (event) =>\n\t\t\t\tc.broadcast(\"shellStderr\", event),\n\t\t\t);\n\t\t\tconst unsubscribeExit = vm.onShellExit(shell.shellId, (event) =>\n\t\t\t\tc.broadcast(\"shellExit\", event),\n\t\t\t);\n\t\t\tvoid c\n\t\t\t\t.keepAwake(\n\t\t\t\t\tvm.waitShell(shell.shellId).finally(() => {\n\t\t\t\t\t\tunsubscribeData();\n\t\t\t\t\t\tunsubscribeStderr();\n\t\t\t\t\t\tunsubscribeExit();\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.catch((error) =>\n\t\t\t\t\tc.log.error({\n\t\t\t\t\t\tmsg: \"agent-os shell wait failed\",\n\t\t\t\t\t\tshellId: shell.shellId,\n\t\t\t\t\t\terror,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\treturn shell;\n\t\t},\n\t\twriteShell: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"writeShell\"]>\n\t\t) => (await ensureVm(c, options)).writeShell(...args),\n\t\tresizeShell: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"resizeShell\"]>\n\t\t) => (await ensureVm(c, options)).resizeShell(...args),\n\t\tcloseShell: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"closeShell\"]>\n\t\t) => (await ensureVm(c, options)).closeShell(...args),\n\t\twaitShell: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"waitShell\"]>\n\t\t) => (await ensureVm(c, options)).waitShell(...args),\n\t\thttpRequest: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"httpRequest\"]>\n\t\t) => (await ensureVm(c, options)).httpRequest(...args),\n\t\tscheduleCron: async (\n\t\t\tc: AnyContext,\n\t\t\tcronOptions: SerializableCronJobOptions,\n\t\t) => {\n\t\t\tconst job = (await ensureVm(c, options)).scheduleCron(\n\t\t\t\tcronOptions as Parameters<AgentOs[\"scheduleCron\"]>[0],\n\t\t\t);\n\t\t\treturn { id: job.id };\n\t\t},\n\t\tlistCronJobs: async (c: AnyContext) =>\n\t\t\t(await ensureVm(c, options)).listCronJobs(),\n\t\tcancelCronJob: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"cancelCronJob\"]>\n\t\t) => (await ensureVm(c, options)).cancelCronJob(...args),\n\t\tlistAgents: async (c: AnyContext) =>\n\t\t\t(await ensureVm(c, options)).listAgents(),\n\t\topenSession: async (c: AnyContext, input: OpenSessionInput) => {\n\t\t\tconst vm = await ensureVm(c, options);\n\t\t\tawait vm.openSession(input);\n\t\t\ttrackSessionEvents(\n\t\t\t\tc,\n\t\t\t\tvm,\n\t\t\t\tinput.sessionId ?? \"main\",\n\t\t\t\thooks,\n\t\t\t\tmaxSessionSubscriptions,\n\t\t\t);\n\t\t},\n\t\tgetSession: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"getSession\"]>\n\t\t) => (await ensureVm(c, options)).getSession(...args),\n\t\tlistSessions: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"listSessions\"]>\n\t\t) => (await ensureVm(c, options)).listSessions(...args),\n\t\tdeleteSession: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"deleteSession\"]>\n\t\t) => {\n\t\t\tconst result = await (await ensureVm(c, options)).deleteSession(...args);\n\t\t\tuntrackSessionEvents(c, args[0]?.sessionId ?? \"main\");\n\t\t\treturn result;\n\t\t},\n\t\tunloadSession: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"unloadSession\"]>\n\t\t) => {\n\t\t\tconst result = await (await ensureVm(c, options)).unloadSession(...args);\n\t\t\tuntrackSessionEvents(c, args[0]?.sessionId ?? \"main\");\n\t\t\treturn result;\n\t\t},\n\t\tprompt: async (c: AnyContext, input: PromptInput) => {\n\t\t\tconst vm = await ensureVm(c, options);\n\t\t\tconst sessionId = input.sessionId ?? \"main\";\n\t\t\ttrackSessionEvents(c, vm, sessionId, hooks, maxSessionSubscriptions);\n\t\t\t// The actor is held only through the terminal SQLite commit for this\n\t\t\t// active turn. Merely having an idle durable session holds nothing.\n\t\t\treturn c.keepAwake(vm.prompt(input));\n\t\t},\n\t\tcancelPrompt: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"cancelPrompt\"]>\n\t\t) => (await ensureVm(c, options)).cancelPrompt(...args),\n\t\trespondPermission: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"respondPermission\"]>\n\t\t) => (await ensureVm(c, options)).respondPermission(...args),\n\t\treadHistory: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"readHistory\"]>\n\t\t) => (await ensureVm(c, options)).readHistory(...args),\n\t\tgetSessionConfig: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"getSessionConfig\"]>\n\t\t) => (await ensureVm(c, options)).getSessionConfig(...args),\n\t\tsetSessionConfigOption: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"setSessionConfigOption\"]>\n\t\t) => (await ensureVm(c, options)).setSessionConfigOption(...args),\n\t\tgetSessionCapabilities: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"getSessionCapabilities\"]>\n\t\t) => (await ensureVm(c, options)).getSessionCapabilities(...args),\n\t\tgetSessionAgentInfo: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"getSessionAgentInfo\"]>\n\t\t) => (await ensureVm(c, options)).getSessionAgentInfo(...args),\n\t\tcreatePreviewUrl: async (\n\t\t\tc: AnyContext,\n\t\t\tport: number,\n\t\t\tttlSeconds = defaultPreviewTtlSeconds,\n\t\t) => {\n\t\t\tif (!Number.isInteger(port) || port < 1 || port > 65_535)\n\t\t\t\tthrow new UserError(\n\t\t\t\t\t\"port must be an integer between 1 and 65535; pass a valid VM listener port\",\n\t\t\t\t\t{ code: \"agentos_preview_invalid_port\" },\n\t\t\t\t);\n\t\t\tif (\n\t\t\t\t!Number.isFinite(ttlSeconds) ||\n\t\t\t\tttlSeconds <= 0 ||\n\t\t\t\tttlSeconds > maxPreviewTtlSeconds\n\t\t\t)\n\t\t\t\tthrow new UserError(\n\t\t\t\t\t`ttlSeconds must be greater than 0 and at most ${maxPreviewTtlSeconds}; raise preview.maxExpiresInSeconds to allow a longer lifetime`,\n\t\t\t\t\t{ code: \"agentos_preview_invalid_ttl\" },\n\t\t\t\t);\n\t\t\tconst token = crypto.randomBytes(24).toString(\"hex\");\n\t\t\tconst createdAt = Date.now();\n\t\t\tconst expiresAt = createdAt + ttlSeconds * 1_000;\n\t\t\tawait c.db.execute(\n\t\t\t\t\"DELETE FROM agentos_actor_preview_tokens WHERE expires_at_ms <= ?\",\n\t\t\t\tcreatedAt,\n\t\t\t);\n\t\t\tconst counts = await c.db.execute<{ count: number }>(\n\t\t\t\t\"SELECT COUNT(*) AS count FROM agentos_actor_preview_tokens\",\n\t\t\t);\n\t\t\tconst activeTokenCount = Number(counts[0]?.count ?? 0);\n\t\t\tif (activeTokenCount >= maxActivePreviewTokens) {\n\t\t\t\tthrow new UserError(\n\t\t\t\t\t`preview token limit ${maxActivePreviewTokens} reached; raise preview.maxActiveTokens to allow more`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: \"agentos_preview_token_limit\",\n\t\t\t\t\t\tmetadata: { limit: maxActivePreviewTokens },\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst nextActiveTokenCount = activeTokenCount + 1;\n\t\t\tconst warningThreshold = Math.ceil(maxActivePreviewTokens * 0.8);\n\t\t\tif (nextActiveTokenCount === warningThreshold) {\n\t\t\t\tc.log.warn({\n\t\t\t\t\tmsg: `preview tokens are near the limit of ${maxActivePreviewTokens}; raise preview.maxActiveTokens to allow more`,\n\t\t\t\t\tactiveTokenCount: nextActiveTokenCount,\n\t\t\t\t\tlimit: maxActivePreviewTokens,\n\t\t\t\t});\n\t\t\t}\n\t\t\tawait c.db.execute(\n\t\t\t\t\"INSERT INTO agentos_actor_preview_tokens (token, port, created_at_ms, expires_at_ms) VALUES (?, ?, ?, ?)\",\n\t\t\t\ttoken,\n\t\t\t\tport,\n\t\t\t\tcreatedAt,\n\t\t\t\texpiresAt,\n\t\t\t);\n\t\t\treturn { path: `/fetch/${token}`, token, port, expiresAt };\n\t\t},\n\t\texpirePreviewUrl: async (c: AnyContext, token: string) => {\n\t\t\tawait c.db.execute(\n\t\t\t\t\"DELETE FROM agentos_actor_preview_tokens WHERE token = ?\",\n\t\t\t\ttoken,\n\t\t\t);\n\t\t},\n\t\texportRootFilesystem: async (\n\t\t\tc: AnyContext,\n\t\t\t...args: Parameters<AgentOs[\"exportRootFilesystem\"]>\n\t\t) => (await ensureVm(c, options)).exportRootFilesystem(...args),\n\t\tmountFs: async (c: AnyContext, descriptor: DynamicMountDescriptor) => {\n\t\t\tawait assertActorCollectionCapacity(\n\t\t\t\tc,\n\t\t\t\t\"agentos_actor_dynamic_mounts\",\n\t\t\t\tdescriptor.path,\n\t\t\t\tmaxDynamicMounts,\n\t\t\t\t\"dynamic mounts\",\n\t\t\t\t\"maxDynamicMounts\",\n\t\t\t);\n\t\t\tconst vm = await ensureVm(c, options);\n\t\t\tawait vm.mountFs(descriptor);\n\t\t\ttry {\n\t\t\t\tawait c.db.execute(\n\t\t\t\t\t\"INSERT INTO agentos_actor_dynamic_mounts (path, descriptor_json) VALUES (?, ?) ON CONFLICT(path) DO UPDATE SET descriptor_json = excluded.descriptor_json\",\n\t\t\t\t\tdescriptor.path,\n\t\t\t\t\tJSON.stringify(descriptor),\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tawait vm.unmountFs(descriptor.path);\n\t\t\t\t} catch (rollbackError) {\n\t\t\t\t\tc.log.error({\n\t\t\t\t\t\tmsg: \"agent-os dynamic mount rollback failed\",\n\t\t\t\t\t\tpath: descriptor.path,\n\t\t\t\t\t\terror: rollbackError,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tunmountFs: async (c: AnyContext, path: string) => {\n\t\t\tconst rows = await c.db.execute<{ descriptor_json: string }>(\n\t\t\t\t\"SELECT descriptor_json FROM agentos_actor_dynamic_mounts WHERE path = ?\",\n\t\t\t\tpath,\n\t\t\t);\n\t\t\tconst vm = await ensureVm(c, options);\n\t\t\tawait vm.unmountFs(path);\n\t\t\ttry {\n\t\t\t\tawait c.db.execute(\n\t\t\t\t\t\"DELETE FROM agentos_actor_dynamic_mounts WHERE path = ?\",\n\t\t\t\t\tpath,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (rows[0]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait vm.mountFs(\n\t\t\t\t\t\t\tJSON.parse(rows[0].descriptor_json) as DynamicMountDescriptor,\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (rollbackError) {\n\t\t\t\t\t\tc.log.error({\n\t\t\t\t\t\t\tmsg: \"agent-os dynamic unmount rollback failed\",\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\terror: rollbackError,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tlistMounts: async (c: AnyContext) =>\n\t\t\t(await ensureVm(c, options)).listMounts(),\n\t\tlistSoftware: async (c: AnyContext) =>\n\t\t\t(await ensureVm(c, options)).listSoftware(),\n\t\tlinkSoftware: async (c: AnyContext, descriptor: PackageDescriptor) => {\n\t\t\tawait assertActorCollectionCapacity(\n\t\t\t\tc,\n\t\t\t\t\"agentos_actor_linked_software\",\n\t\t\t\tdescriptor.path,\n\t\t\t\tmaxLinkedSoftware,\n\t\t\t\t\"linked software packages\",\n\t\t\t\t\"maxLinkedSoftware\",\n\t\t\t);\n\t\t\tawait c.db.execute(\n\t\t\t\t\"INSERT INTO agentos_actor_linked_software (path, descriptor_json) VALUES (?, ?) ON CONFLICT(path) DO UPDATE SET descriptor_json = excluded.descriptor_json\",\n\t\t\t\tdescriptor.path,\n\t\t\t\tJSON.stringify(descriptor),\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tawait (await ensureVm(c, options)).linkSoftware(descriptor);\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tawait c.db.execute(\n\t\t\t\t\t\t\"DELETE FROM agentos_actor_linked_software WHERE path = ?\",\n\t\t\t\t\t\tdescriptor.path,\n\t\t\t\t\t);\n\t\t\t\t} catch (rollbackError) {\n\t\t\t\t\tc.log.error({\n\t\t\t\t\t\tmsg: \"agent-os linked software rollback failed\",\n\t\t\t\t\t\tpath: descriptor.path,\n\t\t\t\t\t\terror: rollbackError,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport type AgentOsActions = ReturnType<typeof createAgentOsActions>;\nexport type AgentOsActorDefinition<TConnParams = undefined> = ActorDefinition<\n\tundefined,\n\tTConnParams,\n\tundefined,\n\tundefined,\n\tundefined,\n\tActorDb,\n\tBuiltInEvents,\n\tRecord<never, never>,\n\tAgentOsActions\n>;\n\nexport interface AgentOsActorExtras extends AgentOsOptions {\n\t/** Maximum live session event subscriptions per actor VM. Default: 10,000. */\n\tmaxSessionSubscriptions?: number;\n\t/** Maximum durable dynamic mount descriptors per actor. Default: 10,000. */\n\tmaxDynamicMounts?: number;\n\t/** Maximum durable linked software descriptors per actor. Default: 10,000. */\n\tmaxLinkedSoftware?: number;\n\tpreview?: {\n\t\tdefaultExpiresInSeconds?: number;\n\t\tmaxExpiresInSeconds?: number;\n\t\tmaxActiveTokens?: number;\n\t};\n}\n\nexport type AgentOsActorConfigInput<\n\tTState = undefined,\n\tTConnParams = undefined,\n\tTConnState = undefined,\n\tTVars = undefined,\n\tTInput = undefined,\n\tTEvents extends EventSchemaConfig = Record<never, never>,\n\tTQueues extends QueueSchemaConfig = Record<never, never>,\n\tTUserActions extends Actions<\n\t\tTState,\n\t\tTConnParams,\n\t\tTConnState,\n\t\tTVars,\n\t\tTInput,\n\t\tActorDb,\n\t\tTEvents,\n\t\tTQueues\n\t> = Record<never, never>,\n> = Omit<\n\tActorConfigInput<\n\t\tTState,\n\t\tTConnParams,\n\t\tTConnState,\n\t\tTVars,\n\t\tTInput,\n\t\tActorDb,\n\t\tTEvents,\n\t\tTQueues,\n\t\tTUserActions\n\t>,\n\t\"db\"\n> &\n\tAgentOsActorExtras &\n\tAgentOsEventHooks<\n\t\tActorContext<\n\t\t\tTState,\n\t\t\tTConnParams,\n\t\t\tTConnState,\n\t\t\tTVars,\n\t\t\tTInput,\n\t\t\tActorDb,\n\t\t\tTEvents,\n\t\t\tTQueues\n\t\t>\n\t>;\n\nconst agentOsOptionKeys = [\n\t\"software\",\n\t\"defaultSoftware\",\n\t\"loopbackExemptPorts\",\n\t\"allowedNodeBuiltins\",\n\t\"highResolutionTime\",\n\t\"database\",\n\t\"rootFilesystem\",\n\t\"mounts\",\n\t\"scheduleDriver\",\n\t\"bindings\",\n\t\"permissions\",\n\t\"sidecar\",\n\t\"limits\",\n\t\"onAgentStderr\",\n\t\"onAgentExit\",\n\t\"onLimitWarning\",\n] as const satisfies readonly (keyof AgentOsOptions)[];\n\nfunction splitConfig(\n\tconfig: AgentOsActorConfigInput<any, any, any, any, any, any, any, any>,\n) {\n\tconst actorConfig = { ...config } as Record<string, unknown>;\n\tconst agentOsOptions: AgentOsOptions = {};\n\tfor (const key of agentOsOptionKeys) {\n\t\tif (key in actorConfig) {\n\t\t\t(agentOsOptions as Record<string, unknown>)[key] = actorConfig[key];\n\t\t\tdelete actorConfig[key];\n\t\t}\n\t}\n\tconst onSessionEvent =\n\t\tactorConfig.onSessionEvent as AgentOsEventHooks<AnyContext>[\"onSessionEvent\"];\n\tconst preview = actorConfig.preview as AgentOsActorExtras[\"preview\"];\n\tconst maxSessionSubscriptions = actorConfig.maxSessionSubscriptions as\n\t\t| number\n\t\t| undefined;\n\tconst maxDynamicMounts = actorConfig.maxDynamicMounts as number | undefined;\n\tconst maxLinkedSoftware = actorConfig.maxLinkedSoftware as number | undefined;\n\tdelete actorConfig.onSessionEvent;\n\tdelete actorConfig.preview;\n\tdelete actorConfig.maxSessionSubscriptions;\n\tdelete actorConfig.maxDynamicMounts;\n\tdelete actorConfig.maxLinkedSoftware;\n\treturn {\n\t\tactorConfig,\n\t\tagentOsOptions,\n\t\thooks: { onSessionEvent },\n\t\tpreview,\n\t\tmaxSessionSubscriptions,\n\t\tmaxDynamicMounts,\n\t\tmaxLinkedSoftware,\n\t};\n}\n\nfunction assertNoReservedKeys(\n\tkind: string,\n\tcustom: object | undefined,\n\tbuiltIns: object,\n) {\n\tfor (const key of Object.keys(custom ?? {})) {\n\t\tif (key in builtIns)\n\t\t\tthrow new Error(`agentOS() ${kind} name is reserved: ${key}`);\n\t}\n}\n\nexport function createAgentOS<\n\tTState = undefined,\n\tTConnParams = undefined,\n\tTConnState = undefined,\n\tTVars = undefined,\n\tTInput = undefined,\n\tTEvents extends EventSchemaConfig = Record<never, never>,\n\tTQueues extends QueueSchemaConfig = Record<never, never>,\n\tTUserActions extends Actions<\n\t\tTState,\n\t\tTConnParams,\n\t\tTConnState,\n\t\tTVars,\n\t\tTInput,\n\t\tActorDb,\n\t\tTEvents,\n\t\tTQueues\n\t> = Record<never, never>,\n>(\n\tconfig: AgentOsActorConfigInput<\n\t\tTState,\n\t\tTConnParams,\n\t\tTConnState,\n\t\tTVars,\n\t\tTInput,\n\t\tTEvents,\n\t\tTQueues,\n\t\tTUserActions\n\t> = {} as AgentOsActorConfigInput<\n\t\tTState,\n\t\tTConnParams,\n\t\tTConnState,\n\t\tTVars,\n\t\tTInput,\n\t\tTEvents,\n\t\tTQueues,\n\t\tTUserActions\n\t>,\n): ActorDefinition<\n\tTState,\n\tTConnParams,\n\tTConnState,\n\tTVars,\n\tTInput,\n\tActorDb,\n\tTEvents & BuiltInEvents,\n\tTQueues,\n\tTUserActions & AgentOsActions\n> {\n\tconst split = splitConfig(config);\n\tconst actorConfig = split.actorConfig as Omit<\n\t\ttypeof config,\n\t\tkeyof AgentOsActorExtras\n\t>;\n\tconst {\n\t\tagentOsOptions,\n\t\thooks,\n\t\tpreview,\n\t\tmaxSessionSubscriptions,\n\t\tmaxDynamicMounts,\n\t\tmaxLinkedSoftware,\n\t} = split;\n\tif (agentOsOptions.rootFilesystem) {\n\t\tthrow new Error(\n\t\t\t\"agentOS() owns rootFilesystem so it can persist directly through the actor SQLite UDS; use mounts for additional filesystems\",\n\t\t);\n\t}\n\tif (agentOsOptions.database) {\n\t\tthrow new Error(\n\t\t\t\"agentOS() owns database and injects the actor SQLite UDS descriptor; standalone AgentOs clients may choose a SQLite file\",\n\t\t);\n\t}\n\tconst actions = createAgentOsActions(\n\t\tagentOsOptions,\n\t\thooks,\n\t\tpreview,\n\t\tmaxSessionSubscriptions,\n\t\tmaxDynamicMounts,\n\t\tmaxLinkedSoftware,\n\t);\n\tassertNoReservedKeys(\"action\", actorConfig.actions, actions);\n\tassertNoReservedKeys(\"event\", actorConfig.events, builtInEvents);\n\n\tconst userOnWake = actorConfig.onWake;\n\tconst userOnSleep = actorConfig.onSleep;\n\tconst userOnDestroy = actorConfig.onDestroy;\n\tconst userOnRequest = actorConfig.onRequest;\n\tconst userOnBeforeConnect = actorConfig.onBeforeConnect;\n\n\treturn actor({\n\t\t...actorConfig,\n\t\toptions: {\n\t\t\tactionTimeout: DEFAULT_ACTION_TIMEOUT_MS,\n\t\t\tsleepGracePeriod: DEFAULT_SLEEP_GRACE_PERIOD_MS,\n\t\t\t...actorConfig.options,\n\t\t},\n\t\tdb: db({ onMigrate: migrateAgentOsActorTables }),\n\t\tevents: { ...(actorConfig.events ?? {}), ...builtInEvents },\n\t\tactions: { ...(actorConfig.actions ?? {}), ...actions },\n\t\tonBeforeConnect: async (\n\t\t\tc: Parameters<NonNullable<typeof userOnBeforeConnect>>[0],\n\t\t\tparams: Parameters<NonNullable<typeof userOnBeforeConnect>>[1],\n\t\t) => {\n\t\t\tif (\n\t\t\t\tc.request &&\n\t\t\t\tmatchPreviewPath(new URL(c.request.url).pathname) !== null\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait userOnBeforeConnect?.(c, params);\n\t\t},\n\t\tonWake: async (c: AnyContext) => {\n\t\t\ttry {\n\t\t\t\tawait userOnWake?.(c);\n\t\t\t} catch (error) {\n\t\t\t\tawait disposeVm(c as AnyContext, \"error\");\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tonSleep: async (c: AnyContext) => {\n\t\t\ttry {\n\t\t\t\tawait userOnSleep?.(c);\n\t\t\t} finally {\n\t\t\t\tawait disposeVm(c as AnyContext, \"sleep\");\n\t\t\t}\n\t\t},\n\t\tonDestroy: async (c: AnyContext) => {\n\t\t\ttry {\n\t\t\t\tawait userOnDestroy?.(c);\n\t\t\t} finally {\n\t\t\t\tawait disposeVm(c as AnyContext, \"destroy\");\n\t\t\t}\n\t\t},\n\t\tonRequest: async (c: AnyContext, request: Request) => {\n\t\t\tconst url = new URL(request.url);\n\t\t\tconst match = matchPreviewPath(url.pathname);\n\t\t\tif (!match) {\n\t\t\t\tconst response = await userOnRequest?.(c as never, request);\n\t\t\t\treturn response ?? new Response(\"Not Found\", { status: 404 });\n\t\t\t}\n\t\t\tif (request.method === \"OPTIONS\")\n\t\t\t\treturn new Response(null, {\n\t\t\t\t\tstatus: 204,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"access-control-allow-origin\": \"*\",\n\t\t\t\t\t\t\"access-control-allow-methods\":\n\t\t\t\t\t\t\t\"GET, POST, PUT, PATCH, DELETE, OPTIONS\",\n\t\t\t\t\t\t\"access-control-allow-headers\": \"*\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\tconst now = Date.now();\n\t\t\tawait c.db.execute(\n\t\t\t\t\"DELETE FROM agentos_actor_preview_tokens WHERE expires_at_ms <= ?\",\n\t\t\t\tnow,\n\t\t\t);\n\t\t\tconst rows = await c.db.execute<{ port: number }>(\n\t\t\t\t\"SELECT port FROM agentos_actor_preview_tokens WHERE token = ? AND expires_at_ms > ?\",\n\t\t\t\tmatch[1],\n\t\t\t\tnow,\n\t\t\t);\n\t\t\tif (!rows[0])\n\t\t\t\treturn new Response(\"Preview URL expired or invalid\", { status: 403 });\n\t\t\tconst target = new URL(request.url);\n\t\t\ttarget.pathname = match[2] ?? \"/\";\n\t\t\tconst vm = await ensureVm(c as AnyContext, agentOsOptions);\n\t\t\tconst requestHeaders: Record<string, string> = {};\n\t\t\trequest.headers.forEach((value, key) => {\n\t\t\t\trequestHeaders[key] = value;\n\t\t\t});\n\t\t\tconst response = await vm.httpRequest({\n\t\t\t\tport: rows[0].port,\n\t\t\t\tpath: `${target.pathname}${target.search}`,\n\t\t\t\tmethod: request.method,\n\t\t\t\theaders: requestHeaders,\n\t\t\t\t...(request.method === \"GET\" || request.method === \"HEAD\"\n\t\t\t\t\t? {}\n\t\t\t\t\t: { body: new Uint8Array(await request.arrayBuffer()) }),\n\t\t\t});\n\t\t\tconst headers = new Headers(response.headers);\n\t\t\theaders.set(\"access-control-allow-origin\", \"*\");\n\t\t\treturn new Response(Buffer.from(response.body), {\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders,\n\t\t\t});\n\t\t},\n\t} as any) as ActorDefinition<\n\t\tTState,\n\t\tTConnParams,\n\t\tTConnState,\n\t\tTVars,\n\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AAQ;AAWT;;;ADzrCA,IAAM,wCAAwC,MAAM,OAAO;AAMpD,IAAM,SAA+B,CAC3C,UAEA,cAAc;AAAA,EACb,GAAG;AAAA,EACH,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,sBAAsB;AACvB,CAAwC;","names":["event","response"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rivet-dev/agentos",
3
- "version": "0.0.0-glibc.9438c58",
4
- "description": "Agent OS actor for RivetKit - thin TS forwarder that loads the native actor plugin via RivetKit's native-plugin ABI.",
3
+ "version": "0.0.0-main.29b0797",
4
+ "description": "A native TypeScript RivetKit actor backed by the AgentOS core SDK and sidecar.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
7
7
  "rivetkit",
@@ -51,14 +51,18 @@
51
51
  "build:actor": "tsup src/index.ts src/client.ts src/react.ts",
52
52
  "build:tabs": "vite build --config vite.tabs.config.ts",
53
53
  "check-types": "tsc --noEmit",
54
- "test": "vitest run"
54
+ "test": "vitest run --exclude '**/*.nightly.test.ts'",
55
+ "test:pr": "AGENTOS_ACTOR_E2E=1 vitest run tests/agent-os-conformance.e2e.test.ts --fileParallelism=false",
56
+ "test:nightly": "AGENTOS_ACTOR_E2E=1 vitest run tests/*.nightly.test.ts tests/agent-os-conformance.e2e.test.ts --fileParallelism=false --passWithNoTests",
57
+ "test:e2e": "cargo build --manifest-path ../../Cargo.toml -p agentos-sidecar && pnpm --filter @rivet-dev/agentos-runtime-core build && pnpm --filter @agentos-software/manifest build && pnpm --filter @agentos-software/common... build && pnpm --filter @agentos-software/coreutils build:runtime && pnpm --filter @rivet-dev/agentos-test-harness build && pnpm --filter @rivet-dev/agentos-core build && pnpm build && pnpm test:e2e:run",
58
+ "test:e2e:run": "AGENTOS_ACTOR_E2E=1 vitest run tests/actor-lifecycle.nightly.test.ts tests/agent-os-conformance.e2e.test.ts --fileParallelism=false"
55
59
  },
56
60
  "dependencies": {
57
- "@agentos-software/common": "0.0.0-glibc.9438c58",
58
- "@rivet-dev/agentos-core": "0.0.0-glibc.9438c58",
59
- "@rivet-dev/agentos-sidecar": "0.0.0-glibc.9438c58",
60
- "@rivetkit/react": "0.0.0-stack-feat-rivetkit-forward-inspector-tabs-to-native-plugin-actors-qkwmksyy.d2859b0",
61
- "rivetkit": "0.0.0-stack-feat-rivetkit-forward-inspector-tabs-to-native-plugin-actors-qkwmksyy.d2859b0",
61
+ "@agentclientprotocol/sdk": "0.16.1",
62
+ "@agentos-software/common": "0.0.0-main.29b0797",
63
+ "@rivet-dev/agentos-core": "0.0.0-main.29b0797",
64
+ "@rivetkit/react": "0.0.0-sqlite-uds.4e59a38",
65
+ "rivetkit": "0.0.0-sqlite-uds.4e59a38",
62
66
  "zod": "^4.1.11"
63
67
  },
64
68
  "peerDependencies": {
@@ -74,6 +78,8 @@
74
78
  }
75
79
  },
76
80
  "devDependencies": {
81
+ "@agentos-software/coreutils": "0.3.3",
82
+ "@rivet-dev/agentos-test-harness": "0.0.0-main.29b0797",
77
83
  "@radix-ui/react-collapsible": "^1.1.2",
78
84
  "@radix-ui/react-scroll-area": "^1.2.2",
79
85
  "@tanstack/react-query": "^5.87.1",
@@ -93,11 +99,5 @@
93
99
  "typescript": "^5.7.3",
94
100
  "vite": "^5.4.20",
95
101
  "vitest": "^2.1.8"
96
- },
97
- "optionalDependencies": {
98
- "@rivet-dev/agentos-plugin-darwin-arm64": "0.0.0-glibc.9438c58",
99
- "@rivet-dev/agentos-plugin-darwin-x64": "0.0.0-glibc.9438c58",
100
- "@rivet-dev/agentos-plugin-linux-arm64-gnu": "0.0.0-glibc.9438c58",
101
- "@rivet-dev/agentos-plugin-linux-x64-gnu": "0.0.0-glibc.9438c58"
102
102
  }
103
103
  }
@@ -1 +0,0 @@
1
- import{j}from"./index-C50G2vhD.js";import{j as N,f as C}from"./scroll-area-DzL-iGyn.js";const m=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,f=N,g=(e,a)=>n=>{var s;if((a==null?void 0:a.variants)==null)return f(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:u,defaultVariants:i}=a,y=Object.keys(u).map(t=>{const r=n==null?void 0:n[t],o=i==null?void 0:i[t];if(r===null)return null;const l=m(r)||m(o);return u[t][l]}),c=n&&Object.entries(n).reduce((t,r)=>{let[o,l]=r;return l===void 0||(t[o]=l),t},{}),x=a==null||(s=a.compoundVariants)===null||s===void 0?void 0:s.reduce((t,r)=>{let{class:o,className:l,...V}=r;return Object.entries(V).every(b=>{let[v,d]=b;return Array.isArray(d)?d.includes({...i,...c}[v]):{...i,...c}[v]===d})?[...t,o,l]:t},[]);return f(e,y,x,n==null?void 0:n.class,n==null?void 0:n.className)},k=g("inline-flex items-center tracking-normal rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors whitespace-nowrap max-w-full overflow-hidden truncate",{variants:{variant:{secondary:"border-transparent bg-secondary text-secondary-foreground",outline:"text-foreground"}},defaultVariants:{variant:"secondary"}});function h({className:e,variant:a,...n}){return j.jsx("div",{className:C(k({variant:a}),e),...n})}export{h as B};
@@ -1 +0,0 @@
1
- import{r as f,j as t}from"./index-C50G2vhD.js";import{u as j}from"./useQuery-RSkOi56s.js";import{e as N,S as b,A as c,C as w,f as p,F as S,h as g,r as k}from"./scroll-area-DzL-iGyn.js";function y({actorId:n,entry:e,depth:r,selectedPath:i,onSelect:o}){const[x,h]=f.useState(!1),d=e.path===i,a=e.dir&&!e.virtual,u=j(N.listDirQueryOptions(n,e.path,a&&x));return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1",style:{paddingLeft:`${r*12}px`},children:[t.jsx("button",{type:"button",onClick:()=>a&&h(s=>!s),className:p("flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-muted/50",!a&&"pointer-events-none opacity-0"),disabled:!a,children:t.jsx(w,{className:p("size-3 transition-transform",x&&"rotate-90")})}),t.jsxs("button",{type:"button",onClick:()=>a?h(s=>!s):e.dir?void 0:o(e),className:p("flex min-w-0 flex-1 items-center gap-2 rounded px-2 py-1 text-left text-sm",d?"bg-muted text-foreground":"hover:bg-muted/50"),children:[t.jsx(S,{dir:e.dir,className:"size-3.5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"flex-1 truncate",children:e.name}),!e.dir&&e.size!=null?t.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/60",children:g(e.size)}):null]})]}),a&&x?u.isLoading?t.jsx("div",{className:"py-1 text-xs text-muted-foreground",style:{paddingLeft:`${(r+1)*12+28}px`},children:"loading…"}):(u.data??[]).map(s=>t.jsx(y,{actorId:n,entry:s,depth:r+1,selectedPath:i,onSelect:o},s.path)):null]})}function C({actorId:n,path:e}){const{data:r,error:i,isFetching:o}=j(N.fileContentQueryOptions(n,e));return e?i?t.jsxs(c,{children:["Failed to read ",e,": ",i.message]}):!r||o?t.jsxs(c,{children:["Loading ",e,"…"]}):t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3",children:[t.jsx("span",{className:"truncate font-mono text-sm",children:r.path}),t.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:g(r.sizeBytes)}),t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:k(r.mtimeMs)})]}),t.jsx(b,{className:"min-h-0 flex-1",children:r.text===null?t.jsxs("div",{className:"flex h-full items-center justify-center p-8 text-center text-sm text-muted-foreground",children:["Binary file (",g(r.sizeBytes),") — preview unavailable."]}):t.jsx("pre",{className:"whitespace-pre-wrap break-words p-4 font-mono text-xs leading-relaxed",children:r.text})})]}):t.jsx(c,{children:"Select a file to view its contents."})}function v(n){let e=n.trim();return e===""?"/":(e.startsWith("/")||(e=`/${e}`),e=e.replace(/\/+/g,"/"),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e)}function L({actorId:n}){const[e,r]=f.useState("/"),[i,o]=f.useState("/"),[x,h]=f.useState(null),d=j(N.listDirQueryOptions(n,e)),a=d.data===null,u=d.data??[];return f.useEffect(()=>{const s=setTimeout(()=>{const l=v(i);r(m=>l!==m?l:m)},500);return()=>clearTimeout(s)},[i]),t.jsxs("div",{className:"flex h-full min-h-0",children:[t.jsxs("div",{className:"flex h-full w-2/5 flex-col border-r",children:[t.jsx("div",{className:"border-b px-3 py-1.5",children:t.jsx("input",{value:i,onChange:s=>o(s.target.value),onKeyDown:s=>{if(s.key==="Enter"){const l=v(i);o(l),r(m=>l!==m?l:m)}},spellCheck:!1,autoComplete:"off","aria-label":"Root directory",placeholder:"/",className:"w-full bg-transparent font-mono text-xs text-muted-foreground outline-none placeholder:text-muted-foreground/40 focus:text-foreground"})}),t.jsx(b,{className:"min-h-0 flex-1 p-2",children:d.isLoading?t.jsxs(c,{children:["Loading ",e,"…"]}):d.error?t.jsxs(c,{children:["Failed to list ",e,": ",d.error.message]}):a?t.jsxs(c,{children:["Not a directory, or does not exist: ",e]}):u.length===0?t.jsx(c,{children:"Empty directory."}):u.map(s=>t.jsx(y,{actorId:n,entry:s,depth:0,selectedPath:x,onSelect:l=>h(l.path)},s.path))})]}),t.jsx("div",{className:"min-h-0 w-3/5",children:t.jsx(C,{actorId:n,path:x})})]})}export{L as FilesystemTabConnected};
@@ -1 +0,0 @@
1
- var rt=e=>{throw TypeError(e)};var Ne=(e,t,r)=>t.has(e)||rt("Cannot "+r);var h=(e,t,r)=>(Ne(e,t,"read from private field"),r?r.call(e):t.get(e)),_=(e,t,r)=>t.has(e)?rt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),k=(e,t,r,o)=>(Ne(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r),M=(e,t,r)=>(Ne(e,t,"access private method"),r);import{S as Wt,p as ot,a as W,s as Ie,b as ye,n as Le,e as ze,i as nt,t as Ut,c as Ee,f as Ft,d as Bt,g as st,h as mt,r as l,k as gt,l as $t,j as m,m as Y,R as Vt}from"./index-C50G2vhD.js";var L,S,we,I,re,le,G,Z,xe,ce,ue,oe,ne,q,de,R,ve,De,We,Ue,Fe,Be,$e,Ve,vt,bt,_o=(bt=class extends Wt{constructor(t,r){super();_(this,R);_(this,L);_(this,S);_(this,we);_(this,I);_(this,re);_(this,le);_(this,G);_(this,Z);_(this,xe);_(this,ce);_(this,ue);_(this,oe);_(this,ne);_(this,q);_(this,de,new Set);this.options=r,k(this,L,t),k(this,Z,null),k(this,G,ot()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(h(this,S).addObserver(this),it(h(this,S),this.options)?M(this,R,ve).call(this):this.updateResult(),M(this,R,Fe).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qe(h(this,S),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qe(h(this,S),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,M(this,R,Be).call(this),M(this,R,$e).call(this),h(this,S).removeObserver(this)}setOptions(t){const r=this.options,o=h(this,S);if(this.options=h(this,L).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof W(this.options.enabled,h(this,S))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");M(this,R,Ve).call(this),h(this,S).setOptions(this.options),r._defaulted&&!Ie(this.options,r)&&h(this,L).getQueryCache().notify({type:"observerOptionsUpdated",query:h(this,S),observer:this});const n=this.hasListeners();n&&at(h(this,S),o,this.options,r)&&M(this,R,ve).call(this),this.updateResult(),n&&(h(this,S)!==o||W(this.options.enabled,h(this,S))!==W(r.enabled,h(this,S))||ye(this.options.staleTime,h(this,S))!==ye(r.staleTime,h(this,S)))&&M(this,R,De).call(this);const s=M(this,R,We).call(this);n&&(h(this,S)!==o||W(this.options.enabled,h(this,S))!==W(r.enabled,h(this,S))||s!==h(this,q))&&M(this,R,Ue).call(this,s)}getOptimisticResult(t){const r=h(this,L).getQueryCache().build(h(this,L),t),o=this.createResult(r,t);return Gt(this,o)&&(k(this,I,o),k(this,le,this.options),k(this,re,h(this,S).state)),o}getCurrentResult(){return h(this,I)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r==null||r(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&h(this,G).status==="pending"&&h(this,G).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){h(this,de).add(t)}getCurrentQuery(){return h(this,S)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=h(this,L).defaultQueryOptions(t),o=h(this,L).getQueryCache().build(h(this,L),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return M(this,R,ve).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),h(this,I)))}createResult(t,r){var P;const o=h(this,S),n=this.options,s=h(this,I),i=h(this,re),a=h(this,le),f=t!==o?t.state:h(this,we),{state:u}=t;let d={...u},p=!1,b;if(r._optimisticResults){const E=this.hasListeners(),j=!E&&it(t,r),C=E&&at(t,o,r,n);(j||C)&&(d={...d,...Bt(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:v,errorUpdatedAt:g,status:w}=d;b=d.data;let x=!1;if(r.placeholderData!==void 0&&b===void 0&&w==="pending"){let E;s!=null&&s.isPlaceholderData&&r.placeholderData===(a==null?void 0:a.placeholderData)?(E=s.data,x=!0):E=typeof r.placeholderData=="function"?r.placeholderData((P=h(this,ue))==null?void 0:P.state.data,h(this,ue)):r.placeholderData,E!==void 0&&(w="success",b=st(s==null?void 0:s.data,E,r),p=!0)}if(r.select&&b!==void 0&&!x)if(s&&b===(i==null?void 0:i.data)&&r.select===h(this,xe))b=h(this,ce);else try{k(this,xe,r.select),b=r.select(b),b=st(s==null?void 0:s.data,b,r),k(this,ce,b),k(this,Z,null)}catch(E){k(this,Z,E)}h(this,Z)&&(v=h(this,Z),b=h(this,ce),g=Date.now(),w="error");const T=d.fetchStatus==="fetching",z=w==="pending",O=w==="error",D=z&&T,F=b!==void 0,N={status:w,fetchStatus:d.fetchStatus,isPending:z,isSuccess:w==="success",isError:O,isInitialLoading:D,isLoading:D,data:b,dataUpdatedAt:d.dataUpdatedAt,error:v,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>f.dataUpdateCount||d.errorUpdateCount>f.errorUpdateCount,isFetching:T,isRefetching:T&&!z,isLoadingError:O&&!F,isPaused:d.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:O&&F,isStale:Ye(t,r),refetch:this.refetch,promise:h(this,G),isEnabled:W(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const E=N.data!==void 0,j=N.status==="error"&&!E,C=J=>{j?J.reject(N.error):E&&J.resolve(N.data)},pe=()=>{const J=k(this,G,N.promise=ot());C(J)},$=h(this,G);switch($.status){case"pending":t.queryHash===o.queryHash&&C($);break;case"fulfilled":(j||N.data!==$.value)&&pe();break;case"rejected":(!j||N.error!==$.reason)&&pe();break}}return N}updateResult(){const t=h(this,I),r=this.createResult(h(this,S),this.options);if(k(this,re,h(this,S).state),k(this,le,this.options),h(this,re).data!==void 0&&k(this,ue,h(this,S)),Ie(r,t))return;k(this,I,r);const o=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,s=typeof n=="function"?n():n;if(s==="all"||!s&&!h(this,de).size)return!0;const i=new Set(s??h(this,de));return this.options.throwOnError&&i.add("error"),Object.keys(h(this,I)).some(a=>{const c=a;return h(this,I)[c]!==t[c]&&i.has(c)})};M(this,R,vt).call(this,{listeners:o()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&M(this,R,Fe).call(this)}},L=new WeakMap,S=new WeakMap,we=new WeakMap,I=new WeakMap,re=new WeakMap,le=new WeakMap,G=new WeakMap,Z=new WeakMap,xe=new WeakMap,ce=new WeakMap,ue=new WeakMap,oe=new WeakMap,ne=new WeakMap,q=new WeakMap,de=new WeakMap,R=new WeakSet,ve=function(t){M(this,R,Ve).call(this);let r=h(this,S).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(Le)),r},De=function(){M(this,R,Be).call(this);const t=ye(this.options.staleTime,h(this,S));if(ze.isServer()||h(this,I).isStale||!nt(t))return;const o=Ut(h(this,I).dataUpdatedAt,t)+1;k(this,oe,Ee.setTimeout(()=>{h(this,I).isStale||this.updateResult()},o))},We=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(h(this,S)):this.options.refetchInterval)??!1},Ue=function(t){M(this,R,$e).call(this),k(this,q,t),!(ze.isServer()||W(this.options.enabled,h(this,S))===!1||!nt(h(this,q))||h(this,q)===0)&&k(this,ne,Ee.setInterval(()=>{(this.options.refetchIntervalInBackground||Ft.isFocused())&&M(this,R,ve).call(this)},h(this,q)))},Fe=function(){M(this,R,De).call(this),M(this,R,Ue).call(this,M(this,R,We).call(this))},Be=function(){h(this,oe)!==void 0&&(Ee.clearTimeout(h(this,oe)),k(this,oe,void 0))},$e=function(){h(this,ne)!==void 0&&(Ee.clearInterval(h(this,ne)),k(this,ne,void 0))},Ve=function(){const t=h(this,L).getQueryCache().build(h(this,L),this.options);if(t===h(this,S))return;const r=h(this,S);k(this,S,t),k(this,we,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},vt=function(t){mt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(h(this,I))}),h(this,L).getQueryCache().notify({query:h(this,S),type:"observerResultsUpdated"})})},bt);function Qt(e,t){return W(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&W(t.retryOnMount,e)===!1)}function it(e,t){return Qt(e,t)||e.state.data!==void 0&&Qe(e,t,t.refetchOnMount)}function Qe(e,t,r){if(W(t.enabled,e)!==!1&&ye(t.staleTime,e)!=="static"){const o=typeof r=="function"?r(e):r;return o==="always"||o!==!1&&Ye(e,t)}return!1}function at(e,t,r,o){return(e!==t||W(o.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Ye(e,r)}function Ye(e,t){return W(t.enabled,e)!==!1&&e.isStaleByTime(ye(t.staleTime,e))}function Gt(e,t){return!Ie(e.getCurrentResult(),t)}var yt=l.createContext(!1),Ht=()=>l.useContext(yt);yt.Provider;function Yt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Xt=l.createContext(Yt()),Kt=()=>l.useContext(Xt),Zt=(e,t,r)=>{const o=r!=null&&r.state.error&&typeof e.throwOnError=="function"?gt(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},qt=e=>{l.useEffect(()=>{e.clearReset()},[e])},Jt=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||gt(r,[e.error,o])),Oo=(e,t)=>t.state.data===void 0,er=e=>{if(e.suspense){const r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},tr=(e,t)=>e.isLoading&&e.isFetching&&!t,rr=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,lt=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function No(e,t,r){var b,v,g,w;const o=Ht(),n=Kt(),s=$t(),i=s.defaultQueryOptions(e);(v=(b=s.getDefaultOptions().queries)==null?void 0:b._experimental_beforeQuery)==null||v.call(b,i);const a=s.getQueryCache().get(i.queryHash),c=e.subscribed!==!1;i._optimisticResults=o?"isRestoring":c?"optimistic":void 0,er(i),Zt(i,n,a),qt(n);const f=!s.getQueryCache().get(i.queryHash),[u]=l.useState(()=>new t(s,i)),d=u.getOptimisticResult(i),p=!o&&c;if(l.useSyncExternalStore(l.useCallback(x=>{const T=p?u.subscribe(mt.batchCalls(x)):Le;return u.updateResult(),T},[u,p]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),l.useEffect(()=>{u.setOptions(i)},[i,u]),rr(i,d))throw lt(i,u,n);if(Jt({result:d,errorResetBoundary:n,throwOnError:i.throwOnError,query:a,suspense:i.suspense}))throw d.error;if((w=(g=s.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||w.call(g,i,d),i.experimental_prefetchInRender&&!ze.isServer()&&tr(d,o)){const x=f?lt(i,u,n):a==null?void 0:a.promise;x==null||x.catch(Le).finally(()=>{u.updateResult()})}return i.notifyOnChangeProps?d:u.trackResult(d)}function wt(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(r=wt(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function or(){for(var e,t,r=0,o="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=wt(e))&&(o&&(o+=" "),o+=t);return o}const Xe="-",nr=e=>{const t=ir(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(Xe);return a[0]===""&&a.length!==1&&a.shift(),xt(a,t)||sr(i)},getConflictingClassGroupIds:(i,a)=>{const c=r[i]||[];return a&&o[i]?[...c,...o[i]]:c}}},xt=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const r=e[0],o=t.nextPart.get(r),n=o?xt(e.slice(1),o):void 0;if(n)return n;if(t.validators.length===0)return;const s=e.join(Xe);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},ct=/^\[(.+)\]$/,sr=e=>{if(ct.test(e)){const t=ct.exec(e)[1],r=t==null?void 0:t.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},ir=e=>{const{theme:t,prefix:r}=e,o={nextPart:new Map,validators:[]};return lr(Object.entries(e.classGroups),r).forEach(([s,i])=>{Ge(i,o,s,t)}),o},Ge=(e,t,r,o)=>{e.forEach(n=>{if(typeof n=="string"){const s=n===""?t:ut(t,n);s.classGroupId=r;return}if(typeof n=="function"){if(ar(n)){Ge(n(o),t,r,o);return}t.validators.push({validator:n,classGroupId:r});return}Object.entries(n).forEach(([s,i])=>{Ge(i,ut(t,s),r,o)})})},ut=(e,t)=>{let r=e;return t.split(Xe).forEach(o=>{r.nextPart.has(o)||r.nextPart.set(o,{nextPart:new Map,validators:[]}),r=r.nextPart.get(o)}),r},ar=e=>e.isThemeGetter,lr=(e,t)=>t?e.map(([r,o])=>{const n=o.map(s=>typeof s=="string"?t+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([i,a])=>[t+i,a])):s);return[r,n]}):e,cr=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,o=new Map;const n=(s,i)=>{r.set(s,i),t++,t>e&&(t=0,o=r,r=new Map)};return{get(s){let i=r.get(s);if(i!==void 0)return i;if((i=o.get(s))!==void 0)return n(s,i),i},set(s,i){r.has(s)?r.set(s,i):n(s,i)}}},St="!",ur=e=>{const{separator:t,experimentalParseClassName:r}=e,o=t.length===1,n=t[0],s=t.length,i=a=>{const c=[];let f=0,u=0,d;for(let w=0;w<a.length;w++){let x=a[w];if(f===0){if(x===n&&(o||a.slice(w,w+s)===t)){c.push(a.slice(u,w)),u=w+s;continue}if(x==="/"){d=w;continue}}x==="["?f++:x==="]"&&f--}const p=c.length===0?a:a.substring(u),b=p.startsWith(St),v=b?p.substring(1):p,g=d&&d>u?d-u:void 0;return{modifiers:c,hasImportantModifier:b,baseClassName:v,maybePostfixModifierPosition:g}};return r?a=>r({className:a,parseClassName:i}):i},dr=e=>{if(e.length<=1)return e;const t=[];let r=[];return e.forEach(o=>{o[0]==="["?(t.push(...r.sort(),o),r=[]):r.push(o)}),t.push(...r.sort()),t},fr=e=>({cache:cr(e.cacheSize),parseClassName:ur(e),...nr(e)}),hr=/\s+/,pr=(e,t)=>{const{parseClassName:r,getClassGroupId:o,getConflictingClassGroupIds:n}=t,s=[],i=e.trim().split(hr);let a="";for(let c=i.length-1;c>=0;c-=1){const f=i[c],{modifiers:u,hasImportantModifier:d,baseClassName:p,maybePostfixModifierPosition:b}=r(f);let v=!!b,g=o(v?p.substring(0,b):p);if(!g){if(!v){a=f+(a.length>0?" "+a:a);continue}if(g=o(p),!g){a=f+(a.length>0?" "+a:a);continue}v=!1}const w=dr(u).join(":"),x=d?w+St:w,T=x+g;if(s.includes(T))continue;s.push(T);const z=n(g,v);for(let O=0;O<z.length;++O){const D=z[O];s.push(x+D)}a=f+(a.length>0?" "+a:a)}return a};function br(){let e=0,t,r,o="";for(;e<arguments.length;)(t=arguments[e++])&&(r=Ct(t))&&(o&&(o+=" "),o+=r);return o}const Ct=e=>{if(typeof e=="string")return e;let t,r="";for(let o=0;o<e.length;o++)e[o]&&(t=Ct(e[o]))&&(r&&(r+=" "),r+=t);return r};function mr(e,...t){let r,o,n,s=i;function i(c){const f=t.reduce((u,d)=>d(u),e());return r=fr(f),o=r.cache.get,n=r.cache.set,s=a,a(c)}function a(c){const f=o(c);if(f)return f;const u=pr(c,r);return n(c,u),u}return function(){return s(br.apply(null,arguments))}}const A=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},Rt=/^\[(?:([a-z-]+):)?(.+)\]$/i,gr=/^\d+\/\d+$/,vr=new Set(["px","full","screen"]),yr=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,wr=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,xr=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Sr=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Cr=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Q=e=>ae(e)||vr.has(e)||gr.test(e),X=e=>he(e,"length",_r),ae=e=>!!e&&!Number.isNaN(Number(e)),je=e=>he(e,"number",ae),me=e=>!!e&&Number.isInteger(Number(e)),Rr=e=>e.endsWith("%")&&ae(e.slice(0,-1)),y=e=>Rt.test(e),K=e=>yr.test(e),Er=new Set(["length","size","percentage"]),Pr=e=>he(e,Er,Et),Ar=e=>he(e,"position",Et),Tr=new Set(["image","url"]),kr=e=>he(e,Tr,Nr),Mr=e=>he(e,"",Or),ge=()=>!0,he=(e,t,r)=>{const o=Rt.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):r(o[2]):!1},_r=e=>wr.test(e)&&!xr.test(e),Et=()=>!1,Or=e=>Sr.test(e),Nr=e=>Cr.test(e),jr=()=>{const e=A("colors"),t=A("spacing"),r=A("blur"),o=A("brightness"),n=A("borderColor"),s=A("borderRadius"),i=A("borderSpacing"),a=A("borderWidth"),c=A("contrast"),f=A("grayscale"),u=A("hueRotate"),d=A("invert"),p=A("gap"),b=A("gradientColorStops"),v=A("gradientColorStopPositions"),g=A("inset"),w=A("margin"),x=A("opacity"),T=A("padding"),z=A("saturate"),O=A("scale"),D=A("sepia"),F=A("skew"),H=A("space"),N=A("translate"),P=()=>["auto","contain","none"],E=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto",y,t],C=()=>[y,t],pe=()=>["",Q,X],$=()=>["auto",ae,y],J=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Re=()=>["solid","dashed","dotted","double","none"],et=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Oe=()=>["start","end","center","between","around","evenly","stretch"],be=()=>["","0",y],tt=()=>["auto","avoid","all","avoid-page","page","left","right","column"],V=()=>[ae,y];return{cacheSize:500,separator:":",theme:{colors:[ge],spacing:[Q,X],blur:["none","",K,y],brightness:V(),borderColor:[e],borderRadius:["none","","full",K,y],borderSpacing:C(),borderWidth:pe(),contrast:V(),grayscale:be(),hueRotate:V(),invert:be(),gap:C(),gradientColorStops:[e],gradientColorStopPositions:[Rr,X],inset:j(),margin:j(),opacity:V(),padding:C(),saturate:V(),scale:V(),sepia:be(),skew:V(),space:C(),translate:C()},classGroups:{aspect:[{aspect:["auto","square","video",y]}],container:["container"],columns:[{columns:[K]}],"break-after":[{"break-after":tt()}],"break-before":[{"break-before":tt()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...J(),y]}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",me,y]}],basis:[{basis:j()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",y]}],grow:[{grow:be()}],shrink:[{shrink:be()}],order:[{order:["first","last","none",me,y]}],"grid-cols":[{"grid-cols":[ge]}],"col-start-end":[{col:["auto",{span:["full",me,y]},y]}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":[ge]}],"row-start-end":[{row:["auto",{span:[me,y]},y]}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",y]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",y]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...Oe()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Oe(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Oe(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[T]}],px:[{px:[T]}],py:[{py:[T]}],ps:[{ps:[T]}],pe:[{pe:[T]}],pt:[{pt:[T]}],pr:[{pr:[T]}],pb:[{pb:[T]}],pl:[{pl:[T]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[H]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[H]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",y,t]}],"min-w":[{"min-w":[y,t,"min","max","fit"]}],"max-w":[{"max-w":[y,t,"none","full","min","max","fit","prose",{screen:[K]},K]}],h:[{h:[y,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[y,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[y,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[y,t,"auto","min","max","fit"]}],"font-size":[{text:["base",K,X]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",je]}],"font-family":[{font:[ge]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",y]}],"line-clamp":[{"line-clamp":["none",ae,je]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Q,y]}],"list-image":[{"list-image":["none",y]}],"list-style-type":[{list:["none","disc","decimal",y]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[x]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[x]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Re(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Q,X]}],"underline-offset":[{"underline-offset":["auto",Q,y]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[x]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...J(),Ar]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Pr]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},kr]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[b]}],"gradient-via":[{via:[b]}],"gradient-to":[{to:[b]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[x]}],"border-style":[{border:[...Re(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[x]}],"divide-style":[{divide:Re()}],"border-color":[{border:[n]}],"border-color-x":[{"border-x":[n]}],"border-color-y":[{"border-y":[n]}],"border-color-s":[{"border-s":[n]}],"border-color-e":[{"border-e":[n]}],"border-color-t":[{"border-t":[n]}],"border-color-r":[{"border-r":[n]}],"border-color-b":[{"border-b":[n]}],"border-color-l":[{"border-l":[n]}],"divide-color":[{divide:[n]}],"outline-style":[{outline:["",...Re()]}],"outline-offset":[{"outline-offset":[Q,y]}],"outline-w":[{outline:[Q,X]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:pe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[x]}],"ring-offset-w":[{"ring-offset":[Q,X]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",K,Mr]}],"shadow-color":[{shadow:[ge]}],opacity:[{opacity:[x]}],"mix-blend":[{"mix-blend":[...et(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":et()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[o]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",K,y]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[z]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[x]}],"backdrop-saturate":[{"backdrop-saturate":[z]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",y]}],duration:[{duration:V()}],ease:[{ease:["linear","in","out","in-out",y]}],delay:[{delay:V()}],animate:[{animate:["none","spin","ping","pulse","bounce",y]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[O]}],"scale-x":[{"scale-x":[O]}],"scale-y":[{"scale-y":[O]}],rotate:[{rotate:[me,y]}],"translate-x":[{"translate-x":[N]}],"translate-y":[{"translate-y":[N]}],"skew-x":[{"skew-x":[F]}],"skew-y":[{"skew-y":[F]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",y]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",y]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",y]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Q,X,je]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Ir=mr(jr);function Ke(...e){return Ir(or(e))}function jo({children:e}){return m.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-8 text-center text-sm text-muted-foreground",children:e})}const Lr={green:"text-green-500",amber:"text-amber-500",red:"text-red-500",muted:"text-muted-foreground/50"};function Io({color:e,className:t}){return m.jsx("svg",{viewBox:"0 0 8 8",className:Ke("size-2 shrink-0 fill-current",Lr[e],t),"aria-hidden":"true",children:m.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function Lo({className:e}){return m.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:m.jsx("path",{d:"M6 4l4 4-4 4"})})}function zr({className:e}){return m.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[m.jsx("rect",{x:"5.5",y:"5.5",width:"8",height:"8",rx:"1.5"}),m.jsx("path",{d:"M10.5 5.5V4A1.5 1.5 0 0 0 9 2.5H4A1.5 1.5 0 0 0 2.5 4v5A1.5 1.5 0 0 0 4 10.5h1.5"})]})}function Dr({className:e}){return m.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:m.jsx("path",{d:"M3 8.5l3.5 3.5L13 4.5"})})}function zo({value:e,className:t}){const[r,o]=l.useState(!1);return m.jsx("button",{type:"button","aria-label":r?"Copied":"Copy",title:r?"Copied":"Copy",onClick:n=>{var s;n.stopPropagation(),(s=navigator.clipboard)==null||s.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1200)}).catch(()=>{})},className:Ke("inline-flex size-5 items-center justify-center rounded text-muted-foreground/40 transition-colors hover:bg-muted hover:text-foreground",r&&"text-green-500",t),children:r?m.jsx(Dr,{className:"size-3"}):m.jsx(zr,{className:"size-3.5"})})}function Do({dir:e,className:t}){return m.jsx("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e?m.jsx("path",{d:"M1.5 4.5A1 1 0 0 1 2.5 3.5h3l1.5 1.5h5.5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-10a1 1 0 0 1-1-1z"}):m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M4 1.5h5l3 3v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-11a1 1 0 0 1 1-1z"}),m.jsx("path",{d:"M9 1.5v3h3"})]})})}function Wo(e){if(e==null)return"—";if(e<1024)return`${e} B`;const t=["KiB","MiB","GiB","TiB"];let r=e/1024,o=0;for(;r>=1024&&o<t.length-1;)r/=1024,o+=1;return`${(r>=100?r.toFixed(0):r.toFixed(1)).replace(/\.0$/,"")} ${t[o]}`}function Uo(e){if(e==null)return"—";const t=Date.now()-e;if(t<0)return"just now";const r=Math.floor(t/1e3);if(r<60)return`${r}s ago`;const o=Math.floor(r/60);if(o<60)return`${o}m ago`;const n=Math.floor(o/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}const ee=(e,...t)=>["agent-os",e,...t];function Wr(e){const t=e.package,r=t.lastIndexOf("@");let o;r>0?o=t.slice(r).split("/").slice(0,2).join("/"):o=t.split("/").filter(Boolean).pop()??t;const n=t.startsWith("@rivet-dev/")||t.startsWith("@agentos-software/")?"rivet-dev":"user";return{name:`${o} · ${e.kind}`,version:e.version??"—",source:n,binaries:e.commands??[]}}function Ur(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function Fr(e){if(e instanceof Uint8Array)return e;if(Array.isArray(e)&&e[0]==="$Uint8Array"&&typeof e[1]=="string"){const t=atob(e[1]),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}if(Array.isArray(e))return Uint8Array.from(e);if(typeof e=="string")try{const t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}catch{return new TextEncoder().encode(e)}return new Uint8Array}function Br(e){return e.subarray(0,8192).includes(0)?null:new TextDecoder("utf-8",{fatal:!1}).decode(e)}function $r(e,t){var n;const o=((e==null?void 0:e.params)??{}).update;if((e==null?void 0:e.method)==="session/update"&&o&&typeof o=="object"){const s=o.sessionUpdate,i=((n=o.content)==null?void 0:n.text)??"";switch(s){case"user_message_chunk":return{kind:"user",seq:t,text:i};case"agent_message_chunk":return{kind:"assistant",seq:t,text:i};case"agent_thought_chunk":return{kind:"thinking",seq:t,text:i};case"tool_call":case"tool_call_update":return{kind:"tool",seq:t,tool:o.title??o.toolCallId??"tool",status:o.status};default:return{kind:"raw",seq:t,label:s??e.method,json:o}}}return{kind:"raw",seq:t,label:(e==null?void 0:e.method)??"event",json:e==null?void 0:e.params}}function Vr(e){return $r(e.event,e.seq)}const Fo={softwareQueryOptions:e=>({queryKey:ee(e,"software"),queryFn:async()=>(await Y("listSoftware",[])).map(Wr)}),processesQueryOptions:e=>({queryKey:ee(e,"processes"),queryFn:()=>Y("listProcesses",[])}),listDirQueryOptions:(e,t,r=!0)=>({queryKey:ee(e,"dir",t),enabled:r,queryFn:async()=>{const o=await Y("readdirEntries",[t],{timeoutMs:1e4});return o===null?null:o.filter(s=>s.name!=="."&&s.name!=="..").map(s=>{const i=Ur(t,s.name);return{name:s.name,path:i,dir:s.isDirectory}}).sort((s,i)=>Number(i.dir)-Number(s.dir)||s.name.localeCompare(i.name))}}),fileContentQueryOptions:(e,t)=>({queryKey:ee(e,"file",t??""),enabled:!!t,queryFn:async()=>{const r=t,[o,n]=await Promise.all([Y("readFile",[r]).then(Fr),Y("stat",[r])]);return{path:r,sizeBytes:n.size,mtimeMs:n.mtimeMs,text:Br(o)}}}),mountsQueryOptions:e=>({queryKey:ee(e,"mounts"),queryFn:()=>Y("listMounts",[])}),sessionsQueryOptions:e=>({queryKey:ee(e,"sessions"),queryFn:()=>Y("listPersistedSessions",[]),refetchInterval:1e4}),transcriptQueryOptions:(e,t)=>({queryKey:ee(e,"transcript",t??""),enabled:!!t,queryFn:async()=>(await Y("getSessionEvents",[t])).map(Vr)})};function se(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e==null||e(n),r===!1||!n.defaultPrevented)return t==null?void 0:t(n)}}function Qr(e,t=[]){let r=[];function o(s,i){const a=l.createContext(i);a.displayName=s+"Context";const c=r.length;r=[...r,i];const f=d=>{var x;const{scope:p,children:b,...v}=d,g=((x=p==null?void 0:p[e])==null?void 0:x[c])||a,w=l.useMemo(()=>v,Object.values(v));return m.jsx(g.Provider,{value:w,children:b})};f.displayName=s+"Provider";function u(d,p){var g;const b=((g=p==null?void 0:p[e])==null?void 0:g[c])||a,v=l.useContext(b);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[f,u]}const n=()=>{const s=r.map(i=>l.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return l.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return n.scopeName=e,[o,Gr(n,...t)]}function Gr(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(s){const i=o.reduce((a,{useScope:c,scopeName:f})=>{const d=c(s)[`__scope${f}`];return{...a,...d}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}var He=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{};function dt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hr(...e){return t=>{let r=!1;const o=e.map(n=>{const s=dt(n,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let n=0;n<o.length;n++){const s=o[n];typeof s=="function"?s():dt(e[n],null)}}}}function ie(...e){return l.useCallback(Hr(...e),e)}function Yr(e){const t=l.forwardRef((r,o)=>{let{children:n,...s}=r,i=null,a=!1;const c=[];ft(n)&&typeof Pe=="function"&&(n=Pe(n._payload)),l.Children.forEach(n,p=>{var b;if(Jr(p)){a=!0;const v=p;let g="child"in v.props?v.props.child:v.props.children;ft(g)&&typeof Pe=="function"&&(g=Pe(g._payload)),i=Kr(v,g),c.push((b=i==null?void 0:i.props)==null?void 0:b.children)}else c.push(p)}),i?i=l.cloneElement(i,void 0,c):!a&&l.Children.count(n)===1&&l.isValidElement(n)&&(i=n);const f=i?qr(i):void 0,u=ie(o,f);if(!i){if(n||n===0)throw new Error(a?oo(e):ro(e));return n}const d=Zr(s,i.props??{});return i.type!==l.Fragment&&(d.ref=o?u:f),l.cloneElement(i,d)});return t.displayName=`${e}.Slot`,t}var Xr=Symbol.for("radix.slottable"),Kr=(e,t)=>{if("child"in e.props){const r=e.props.child;return l.isValidElement(r)?l.cloneElement(r,void 0,e.props.children(r.props.children)):null}return l.isValidElement(t)?t:null};function Zr(e,t){const r={...t};for(const o in t){const n=e[o],s=t[o];/^on[A-Z]/.test(o)?n&&s?r[o]=(...a)=>{const c=s(...a);return n(...a),c}:n&&(r[o]=n):o==="style"?r[o]={...n,...s}:o==="className"&&(r[o]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}function qr(e){var o,n;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(n=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Jr(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Xr}var eo=Symbol.for("react.lazy");function ft(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===eo&&"_payload"in e&&to(e._payload)}function to(e){return typeof e=="object"&&e!==null&&"then"in e}var ro=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,oo=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Pe=Vt[" use ".trim().toString()],no=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Se=no.reduce((e,t)=>{const r=Yr(`Primitive.${t}`),o=l.forwardRef((n,s)=>{const{asChild:i,...a}=n,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(c,{...a,ref:s})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function so(e,t){return l.useReducer((r,o)=>t[r][o]??r,e)}var Ce=e=>{const{present:t,children:r}=e,o=io(t),n=typeof r=="function"?r({present:o.isPresent}):l.Children.only(r),s=ao(o.ref,lo(n));return typeof r=="function"||o.isPresent?l.cloneElement(n,{ref:s}):null};Ce.displayName="Presence";function io(e){const[t,r]=l.useState(),o=l.useRef(null),n=l.useRef(e),s=l.useRef("none"),i=e?"mounted":"unmounted",[a,c]=so(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const f=Ae(o.current);s.current=a==="mounted"?f:"none"},[a]),He(()=>{const f=o.current,u=n.current;if(u!==e){const p=s.current,b=Ae(f);e?c("MOUNT"):b==="none"||(f==null?void 0:f.display)==="none"?c("UNMOUNT"):c(u&&p!==b?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,c]),He(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,d=b=>{const g=Ae(o.current).includes(CSS.escape(b.animationName));if(b.target===t&&g&&(c("ANIMATION_END"),!n.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},p=b=>{b.target===t&&(s.current=Ae(o.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(f),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:l.useCallback(f=>{o.current=f?getComputedStyle(f):null,r(f)},[])}}function ht(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ao(...e){const t=l.useRef(e);return t.current=e,l.useCallback(r=>{const o=t.current;let n=!1;const s=o.map(i=>{const a=ht(i,r);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<s.length;i++){const a=s[i];typeof a=="function"?a():ht(o[i],null)}}},[])}function Ae(e){return(e==null?void 0:e.animationName)||"none"}function lo(e){var o,n;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(n=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function te(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...r)=>{var o;return(o=t.current)==null?void 0:o.call(t,...r)},[])}var co=l.createContext(void 0);function uo(e){const t=l.useContext(co);return e||t||"ltr"}function fo(e,[t,r]){return Math.min(r,Math.max(t,e))}function ho(e,t){return l.useReducer((r,o)=>t[r][o]??r,e)}var Ze="ScrollArea",[Pt]=Qr(Ze),[po,U]=Pt(Ze),At=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:o="hover",dir:n,scrollHideDelay:s=600,...i}=e,[a,c]=l.useState(null),[f,u]=l.useState(null),[d,p]=l.useState(null),[b,v]=l.useState(null),[g,w]=l.useState(null),[x,T]=l.useState(0),[z,O]=l.useState(0),[D,F]=l.useState(!1),[H,N]=l.useState(!1),P=ie(t,j=>c(j)),E=uo(n);return m.jsx(po,{scope:r,type:o,dir:E,scrollHideDelay:s,scrollArea:a,viewport:f,onViewportChange:u,content:d,onContentChange:p,scrollbarX:b,onScrollbarXChange:v,scrollbarXEnabled:D,onScrollbarXEnabledChange:F,scrollbarY:g,onScrollbarYChange:w,scrollbarYEnabled:H,onScrollbarYEnabledChange:N,onCornerWidthChange:T,onCornerHeightChange:O,children:m.jsx(Se.div,{dir:E,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":z+"px",...e.style}})})});At.displayName=Ze;var Tt="ScrollAreaViewport",kt=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:o,nonce:n,...s}=e,i=U(Tt,r),a=l.useRef(null),c=ie(t,a,i.onViewportChange);return m.jsxs(m.Fragment,{children:[m.jsx(bo,{nonce:n}),m.jsx(Se.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:m.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});kt.displayName=Tt;var bo=l.memo(({nonce:e})=>m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:e}),(e,t)=>e.nonce===t.nonce),B="ScrollAreaScrollbar",Mt=l.forwardRef((e,t)=>{const{forceMount:r,...o}=e,n=U(B,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=n,a=e.orientation==="horizontal";return l.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),n.type==="hover"?m.jsx(mo,{...o,ref:t,forceMount:r}):n.type==="scroll"?m.jsx(go,{...o,ref:t,forceMount:r}):n.type==="auto"?m.jsx(_t,{...o,ref:t,forceMount:r}):n.type==="always"?m.jsx(qe,{...o,ref:t,"data-state":"visible"}):null});Mt.displayName=B;var mo=l.forwardRef((e,t)=>{const{forceMount:r,...o}=e,n=U(B,e.__scopeScrollArea),[s,i]=l.useState(!1);return l.useEffect(()=>{const a=n.scrollArea;let c=0;if(a){const f=()=>{window.clearTimeout(c),i(!0)},u=()=>{c=window.setTimeout(()=>i(!1),n.scrollHideDelay)};return a.addEventListener("pointerenter",f),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",f),a.removeEventListener("pointerleave",u)}}},[n.scrollArea,n.scrollHideDelay]),m.jsx(Ce,{present:r||s,children:m.jsx(_t,{"data-state":s?"visible":"hidden",...o,ref:t})})}),go=l.forwardRef((e,t)=>{const{forceMount:r,...o}=e,n=U(B,e.__scopeScrollArea),s=e.orientation==="horizontal",i=_e(()=>c("SCROLL_END"),100),[a,c]=ho("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(a==="idle"){const f=window.setTimeout(()=>c("HIDE"),n.scrollHideDelay);return()=>window.clearTimeout(f)}},[a,n.scrollHideDelay,c]),l.useEffect(()=>{const f=n.viewport,u=s?"scrollLeft":"scrollTop";if(f){let d=f[u];const p=()=>{const b=f[u];d!==b&&(c("SCROLL"),i()),d=b};return f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[n.viewport,s,c,i]),m.jsx(Ce,{present:r||a!=="hidden",children:m.jsx(qe,{"data-state":a==="hidden"?"hidden":"visible",...o,ref:t,onPointerEnter:se(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:se(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),_t=l.forwardRef((e,t)=>{const r=U(B,e.__scopeScrollArea),{forceMount:o,...n}=e,[s,i]=l.useState(!1),a=e.orientation==="horizontal",c=_e(()=>{if(r.viewport){const f=r.viewport.offsetWidth<r.viewport.scrollWidth,u=r.viewport.offsetHeight<r.viewport.scrollHeight;i(a?f:u)}},10);return fe(r.viewport,c),fe(r.content,c),m.jsx(Ce,{present:o||s,children:m.jsx(qe,{"data-state":s?"visible":"hidden",...n,ref:t})})}),qe=l.forwardRef((e,t)=>{const{orientation:r="vertical",...o}=e,n=U(B,e.__scopeScrollArea),s=l.useRef(null),i=l.useRef(0),[a,c]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=Lt(a.viewport,a.content),u={...o,sizes:a,onSizesChange:c,hasThumb:f>0&&f<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function d(p,b){return Co(p,i.current,a,b)}return r==="horizontal"?m.jsx(vo,{...u,ref:t,onThumbPositionChange:()=>{if(n.viewport&&s.current){const p=n.viewport.scrollLeft,b=pt(p,a,n.dir);s.current.style.transform=`translate3d(${b}px, 0, 0)`}},onWheelScroll:p=>{n.viewport&&(n.viewport.scrollLeft=p)},onDragScroll:p=>{n.viewport&&(n.viewport.scrollLeft=d(p,n.dir))}}):r==="vertical"?m.jsx(yo,{...u,ref:t,onThumbPositionChange:()=>{if(n.viewport&&s.current){const p=n.viewport.scrollTop,b=pt(p,a);s.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:p=>{n.viewport&&(n.viewport.scrollTop=p)},onDragScroll:p=>{n.viewport&&(n.viewport.scrollTop=d(p))}}):null}),vo=l.forwardRef((e,t)=>{const{sizes:r,onSizesChange:o,...n}=e,s=U(B,e.__scopeScrollArea),[i,a]=l.useState(),c=l.useRef(null),f=ie(t,c,s.onScrollbarXChange);return l.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),m.jsx(Nt,{"data-orientation":"horizontal",...n,ref:f,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Me(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(s.viewport){const p=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(p),Dt(p,d)&&u.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&o({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ke(i.paddingLeft),paddingEnd:ke(i.paddingRight)}})}})}),yo=l.forwardRef((e,t)=>{const{sizes:r,onSizesChange:o,...n}=e,s=U(B,e.__scopeScrollArea),[i,a]=l.useState(),c=l.useRef(null),f=ie(t,c,s.onScrollbarYChange);return l.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),m.jsx(Nt,{"data-orientation":"vertical",...n,ref:f,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Me(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(s.viewport){const p=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(p),Dt(p,d)&&u.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&o({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ke(i.paddingTop),paddingEnd:ke(i.paddingBottom)}})}})}),[wo,Ot]=Pt(B),Nt=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:o,hasThumb:n,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:f,onWheelScroll:u,onResize:d,...p}=e,b=U(B,r),[v,g]=l.useState(null),w=ie(t,P=>g(P)),x=l.useRef(null),T=l.useRef(""),z=b.viewport,O=o.content-o.viewport,D=te(u),F=te(c),H=_e(d,10);function N(P){if(x.current){const E=P.clientX-x.current.left,j=P.clientY-x.current.top;f({x:E,y:j})}}return l.useEffect(()=>{const P=E=>{const j=E.target;(v==null?void 0:v.contains(j))&&D(E,O)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[z,v,O,D]),l.useEffect(F,[o,F]),fe(v,H),fe(b.content,H),m.jsx(wo,{scope:r,scrollbar:v,hasThumb:n,onThumbChange:te(s),onThumbPointerUp:te(i),onThumbPositionChange:F,onThumbPointerDown:te(a),children:m.jsx(Se.div,{...p,ref:w,style:{position:"absolute",...p.style},onPointerDown:se(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),x.current=v.getBoundingClientRect(),T.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),N(P))}),onPointerMove:se(e.onPointerMove,N),onPointerUp:se(e.onPointerUp,P=>{const E=P.target;E.hasPointerCapture(P.pointerId)&&E.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=T.current,b.viewport&&(b.viewport.style.scrollBehavior=""),x.current=null})})})}),Te="ScrollAreaThumb",jt=l.forwardRef((e,t)=>{const{forceMount:r,...o}=e,n=Ot(Te,e.__scopeScrollArea);return m.jsx(Ce,{present:r||n.hasThumb,children:m.jsx(xo,{ref:t,...o})})}),xo=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:o,...n}=e,s=U(Te,r),i=Ot(Te,r),{onThumbPositionChange:a}=i,c=ie(t,d=>i.onThumbChange(d)),f=l.useRef(void 0),u=_e(()=>{f.current&&(f.current(),f.current=void 0)},100);return l.useEffect(()=>{const d=s.viewport;if(d){const p=()=>{if(u(),!f.current){const b=Ro(d,a);f.current=b,a()}};return a(),d.addEventListener("scroll",p),()=>d.removeEventListener("scroll",p)}},[s.viewport,u,a]),m.jsx(Se.div,{"data-state":i.hasThumb?"visible":"hidden",...n,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:se(e.onPointerDownCapture,d=>{const b=d.target.getBoundingClientRect(),v=d.clientX-b.left,g=d.clientY-b.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:se(e.onPointerUp,i.onThumbPointerUp)})});jt.displayName=Te;var Je="ScrollAreaCorner",It=l.forwardRef((e,t)=>{const r=U(Je,e.__scopeScrollArea),o=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&o?m.jsx(So,{...e,ref:t}):null});It.displayName=Je;var So=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,...o}=e,n=U(Je,r),[s,i]=l.useState(0),[a,c]=l.useState(0),f=!!(s&&a);return fe(n.scrollbarX,()=>{var d;const u=((d=n.scrollbarX)==null?void 0:d.offsetHeight)||0;n.onCornerHeightChange(u),c(u)}),fe(n.scrollbarY,()=>{var d;const u=((d=n.scrollbarY)==null?void 0:d.offsetWidth)||0;n.onCornerWidthChange(u),i(u)}),f?m.jsx(Se.div,{...o,ref:t,style:{width:s,height:a,position:"absolute",right:n.dir==="ltr"?0:void 0,left:n.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ke(e){return e?parseInt(e,10):0}function Lt(e,t){const r=e/t;return isNaN(r)?0:r}function Me(e){const t=Lt(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-r)*t;return Math.max(o,18)}function Co(e,t,r,o="ltr"){const n=Me(r),s=n/2,i=t||s,a=n-i,c=r.scrollbar.paddingStart+i,f=r.scrollbar.size-r.scrollbar.paddingEnd-a,u=r.content-r.viewport,d=o==="ltr"?[0,u]:[u*-1,0];return zt([c,f],d)(e)}function pt(e,t,r="ltr"){const o=Me(t),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-n,i=t.content-t.viewport,a=s-o,c=r==="ltr"?[0,i]:[i*-1,0],f=fo(e,c);return zt([0,i],[0,a])(f)}function zt(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(r-e[0])}}function Dt(e,t){return e>0&&e<t}var Ro=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},o=0;return function n(){const s={left:e.scrollLeft,top:e.scrollTop},i=r.left!==s.left,a=r.top!==s.top;(i||a)&&t(),r=s,o=window.requestAnimationFrame(n)}(),()=>window.cancelAnimationFrame(o)};function _e(e,t){const r=te(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,t)},[r,t])}function fe(e,t){const r=te(t);He(()=>{let o=0;if(e){const n=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(r)});return n.observe(e),()=>{window.cancelAnimationFrame(o),n.unobserve(e)}}},[e,r])}var Eo=At,Po=kt,Ao=It;const To=l.forwardRef(({className:e,children:t,...r},o)=>m.jsxs(Eo,{ref:o,className:Ke("relative overflow-hidden",e),...r,children:[m.jsx(Po,{className:"h-full w-full rounded-[inherit] [&>div]:!block",children:t}),m.jsx(Mt,{orientation:"vertical",className:"flex h-full w-2.5 touch-none select-none border-l border-l-transparent p-[1px] transition-colors",children:m.jsx(jt,{className:"relative flex-1 rounded-full bg-border"})}),m.jsx(Ao,{})]}));To.displayName="ScrollArea";export{jo as A,Lo as C,Do as F,Se as P,_o as Q,To as S,Ce as a,ie as b,se as c,Qr as d,Fo as e,Ke as f,Io as g,Wo as h,zo as i,or as j,No as k,Oo as l,$r as m,Uo as r,He as u};
@@ -1 +0,0 @@
1
- import{r as i,u as S,j as e}from"./index-C50G2vhD.js";import{u as k}from"./useQuery-RSkOi56s.js";import{u as E}from"./useSuspenseQuery-CpwiXRj_.js";import{e as j,m as I,S as g,A as d,g as A,r as O,f as T}from"./scroll-area-DzL-iGyn.js";function a({label:t,meta:n,children:o}){return e.jsxs("div",{className:"border-b px-4 py-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:t}),n?e.jsx("span",{className:"ml-auto font-mono text-xs text-muted-foreground",children:n}):null]}),o]})}function N({event:t}){switch(t.kind){case"user":case"assistant":return e.jsx(a,{label:t.kind,children:e.jsx("p",{className:"whitespace-pre-wrap text-sm",children:t.text||"—"})});case"thinking":return e.jsx(a,{label:"thinking",children:e.jsx("p",{className:"whitespace-pre-wrap text-sm italic text-muted-foreground",children:t.text||"—"})});case"tool":return e.jsx(a,{label:`tool · ${t.tool}`,meta:t.status,children:e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:t.status??""})});default:return e.jsx(a,{label:t.label,children:e.jsx("pre",{className:"whitespace-pre-wrap break-words rounded bg-muted/50 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground",children:JSON.stringify(t.json,null,2)})})}}function $({actorId:t}){var h;const{data:n}=E(j.sessionsQueryOptions(t)),[o,b]=i.useState(null),r=o??((h=n[0])==null?void 0:h.sessionId)??null,{data:c=[]}=k(j.transcriptQueryOptions(t,r)),v=S().useEvent,[l,x]=i.useState([]),u=i.useRef(0),m=i.useRef(r);return m.current=r,i.useEffect(()=>{x([]),u.current=0},[r]),v("sessionEvent",s=>{const f=m.current;if(!f||s!=null&&s.sessionId&&s.sessionId!==f)return;const p=(s==null?void 0:s.event)??s;p&&x(w=>[...w,I(p,u.current++)])}),e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{className:"flex h-full w-64 shrink-0 flex-col border-r",children:[e.jsxs("div",{className:"border-b px-3 py-2.5",children:[e.jsx("div",{className:"text-sm font-semibold",children:"Sessions"}),e.jsxs("div",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:[n.length," session",n.length===1?"":"s"]})]}),e.jsx(g,{className:"min-h-0 flex-1",children:n.length===0?e.jsx(d,{children:"No sessions yet."}):e.jsx("div",{className:"p-1.5",children:n.map(s=>e.jsxs("button",{type:"button",onClick:()=>b(s.sessionId),className:T("flex w-full items-center gap-2 rounded px-2 py-2 text-left",s.sessionId===r?"bg-muted":"hover:bg-muted/50"),children:[e.jsx(A,{color:s.status==="running"?"green":"muted"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-mono text-xs",children:s.sessionId}),e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[s.agentType," · ",O(s.createdAt)]})]})]},s.sessionId))})})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-b px-4 py-3",children:[e.jsx("div",{className:"font-mono text-sm",children:r}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[c.length+l.length," event",c.length+l.length===1?"":"s"]})]}),e.jsx(g,{className:"min-h-0 flex-1",children:c.length+l.length===0?e.jsx(d,{children:"This session has no events yet."}):e.jsxs(e.Fragment,{children:[c.map(s=>e.jsx(N,{event:s},`b-${s.seq}`)),l.map(s=>e.jsx(N,{event:s},`l-${s.seq}`))]})})]}):e.jsx(d,{children:"Select a session to view its transcript."})})]})}export{$ as TranscriptTabConnected};
@@ -1 +0,0 @@
1
- import{k as r,Q as u}from"./scroll-area-DzL-iGyn.js";function a(e,s){return r(e,u)}export{a as u};