devframe 0.0.0 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +62 -0
  3. package/dist/_shared-Bxa2_kq7.mjs +20 -0
  4. package/dist/adapters/build.d.mts +37 -0
  5. package/dist/adapters/build.mjs +68 -0
  6. package/dist/adapters/cli.d.mts +35 -0
  7. package/dist/adapters/cli.mjs +357 -0
  8. package/dist/adapters/embedded.d.mts +19 -0
  9. package/dist/adapters/embedded.mjs +15 -0
  10. package/dist/adapters/kit.d.mts +23 -0
  11. package/dist/adapters/kit.mjs +16 -0
  12. package/dist/adapters/mcp.d.mts +39 -0
  13. package/dist/adapters/mcp.mjs +278 -0
  14. package/dist/adapters/vite.d.mts +32 -0
  15. package/dist/adapters/vite.mjs +31 -0
  16. package/dist/client/index.d.mts +228 -0
  17. package/dist/client/index.mjs +2 -0
  18. package/dist/client-CsR1_h3o.mjs +1569 -0
  19. package/dist/constants.d.mts +20 -0
  20. package/dist/constants.mjs +34 -0
  21. package/dist/context-xQo1FcxX.mjs +6827 -0
  22. package/dist/define-CW9gLnyG.mjs +11 -0
  23. package/dist/devtool-CHT-4_OU.d.mts +1233 -0
  24. package/dist/helpers/nuxt/index.d.mts +46 -0
  25. package/dist/helpers/nuxt/index.mjs +58 -0
  26. package/dist/helpers/nuxt/runtime/plugin.client.d.mts +8 -0
  27. package/dist/helpers/nuxt/runtime/plugin.client.mjs +12 -0
  28. package/dist/human-id-CHS0s28X.mjs +844 -0
  29. package/dist/immer-DEqg5kOd.mjs +894 -0
  30. package/dist/index-Cei8vVcd.d.mts +140 -0
  31. package/dist/index.d.mts +10 -0
  32. package/dist/index.mjs +2 -0
  33. package/dist/main-BJD9t8dk.mjs +601 -0
  34. package/dist/node/index.d.mts +393 -0
  35. package/dist/node/index.mjs +69 -0
  36. package/dist/open-BMO2_-wC.mjs +533 -0
  37. package/dist/recipes/open-helpers.d.mts +108 -0
  38. package/dist/recipes/open-helpers.mjs +69 -0
  39. package/dist/rpc/client.d.mts +9 -0
  40. package/dist/rpc/client.mjs +13 -0
  41. package/dist/rpc/index.d.mts +3 -0
  42. package/dist/rpc/index.mjs +4 -0
  43. package/dist/rpc/server.d.mts +8 -0
  44. package/dist/rpc/server.mjs +10 -0
  45. package/dist/rpc/transports/ws-client.d.mts +2 -0
  46. package/dist/rpc/transports/ws-client.mjs +58 -0
  47. package/dist/rpc/transports/ws-server.d.mts +2 -0
  48. package/dist/rpc/transports/ws-server.mjs +73 -0
  49. package/dist/rpc-hbRk8qtt.mjs +456 -0
  50. package/dist/serialization-CWcWE7x7.mjs +112 -0
  51. package/dist/server-DkJ2-s0Y.mjs +49 -0
  52. package/dist/src-DIKqQIjp.mjs +85 -0
  53. package/dist/static-dump-DwFfj4U_.mjs +97 -0
  54. package/dist/transports-4bqw6Fqg.mjs +15 -0
  55. package/dist/types/index.d.mts +4 -0
  56. package/dist/types/index.mjs +6 -0
  57. package/dist/types-BkyzI9r4.d.mts +273 -0
  58. package/dist/utils/events.d.mts +9 -0
  59. package/dist/utils/events.mjs +40 -0
  60. package/dist/utils/human-id.d.mts +10 -0
  61. package/dist/utils/human-id.mjs +3 -0
  62. package/dist/utils/nanoid.d.mts +4 -0
  63. package/dist/utils/nanoid.mjs +10 -0
  64. package/dist/utils/promise.d.mts +8 -0
  65. package/dist/utils/promise.mjs +15 -0
  66. package/dist/utils/shared-state.d.mts +2 -0
  67. package/dist/utils/shared-state.mjs +36 -0
  68. package/dist/utils/state.d.mts +49 -0
  69. package/dist/utils/state.mjs +26 -0
  70. package/dist/utils/when.d.mts +2 -0
  71. package/dist/utils/when.mjs +424 -0
  72. package/dist/when-aBBXAEh5.d.mts +401 -0
  73. package/dist/ws-client-CDGmViwt.d.mts +26 -0
  74. package/dist/ws-server-Cu8tmZcF.d.mts +49 -0
  75. package/package.json +116 -8
@@ -0,0 +1,97 @@
1
+ import { n as dumpFunctions, s as getRpcHandler } from "./rpc-hbRk8qtt.mjs";
2
+ import { DEVTOOLS_RPC_DUMP_DIRNAME } from "./constants.mjs";
3
+ //#region src/node/host-h3.ts
4
+ /**
5
+ * h3-backed {@link DevToolsHost} — used by the standalone CLI adapter.
6
+ * This commit adds the shell; the CLI adapter in commit 5 wires it up
7
+ * with a real h3 app and sirv handler.
8
+ */
9
+ function createH3DevToolsHost(options) {
10
+ return {
11
+ mountStatic(base, distDir) {
12
+ return options.mount?.(base, distDir);
13
+ },
14
+ resolveOrigin() {
15
+ return options.origin;
16
+ }
17
+ };
18
+ }
19
+ //#endregion
20
+ //#region src/node/static-dump.ts
21
+ function makeDumpKey(name) {
22
+ return encodeURIComponent(name.replaceAll(":", "~"));
23
+ }
24
+ function makeStaticPath(name) {
25
+ return `${DEVTOOLS_RPC_DUMP_DIRNAME}/${makeDumpKey(name)}.static.json`;
26
+ }
27
+ function makeQueryRecordPath(name, hash) {
28
+ return `${DEVTOOLS_RPC_DUMP_DIRNAME}/${makeDumpKey(name)}.record.${hash}.json`;
29
+ }
30
+ function makeQueryFallbackPath(name) {
31
+ return `${DEVTOOLS_RPC_DUMP_DIRNAME}/${makeDumpKey(name)}.fallback.json`;
32
+ }
33
+ async function resolveRecord(record) {
34
+ return typeof record === "function" ? await record() : record;
35
+ }
36
+ async function collectStaticRpcDump(definitions, context) {
37
+ const manifest = {};
38
+ const files = {};
39
+ for (const definition of definitions) {
40
+ const type = definition.type ?? "query";
41
+ const serialization = definition.jsonSerializable === true ? "json" : "structured-clone";
42
+ if (type === "static") {
43
+ const handler = await getRpcHandler(definition, context);
44
+ const path = makeStaticPath(definition.name);
45
+ files[path] = {
46
+ serialization,
47
+ fnName: definition.name,
48
+ data: { output: await Promise.resolve(handler()) }
49
+ };
50
+ manifest[definition.name] = {
51
+ type: "static",
52
+ path,
53
+ serialization
54
+ };
55
+ continue;
56
+ }
57
+ if (type !== "query") continue;
58
+ const store = await dumpFunctions([definition], context);
59
+ if (!(definition.name in store.definitions)) continue;
60
+ const queryEntry = {
61
+ type: "query",
62
+ records: {},
63
+ serialization
64
+ };
65
+ const prefix = `${definition.name}---`;
66
+ for (const [recordKey, recordOrGetter] of Object.entries(store.records)) {
67
+ if (!recordKey.startsWith(prefix)) continue;
68
+ const key = recordKey.slice(prefix.length);
69
+ const record = await resolveRecord(recordOrGetter);
70
+ if (key === "fallback") {
71
+ const path = makeQueryFallbackPath(definition.name);
72
+ files[path] = {
73
+ serialization,
74
+ fnName: definition.name,
75
+ data: record
76
+ };
77
+ queryEntry.fallback = path;
78
+ } else {
79
+ const path = makeQueryRecordPath(definition.name, key);
80
+ files[path] = {
81
+ serialization,
82
+ fnName: definition.name,
83
+ data: record
84
+ };
85
+ queryEntry.records[key] = path;
86
+ }
87
+ }
88
+ if (!Object.keys(queryEntry.records).length && !queryEntry.fallback) continue;
89
+ manifest[definition.name] = queryEntry;
90
+ }
91
+ return {
92
+ manifest,
93
+ files
94
+ };
95
+ }
96
+ //#endregion
97
+ export { createH3DevToolsHost as n, collectStaticRpcDump as t };
@@ -0,0 +1,15 @@
1
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
2
+ //#region src/node/mcp/transports.ts
3
+ /**
4
+ * Start the MCP server on stdio. Returns a stop function.
5
+ * @internal
6
+ */
7
+ async function startStdioTransport(server) {
8
+ const transport = new StdioServerTransport();
9
+ await server.connect(transport);
10
+ return async () => {
11
+ await server.close();
12
+ };
13
+ }
14
+ //#endregion
15
+ export { startStdioTransport };
@@ -0,0 +1,4 @@
1
+ import { $ as DevToolsLogsHost, $t as EventsMap, A as DevToolsViewHost, At as DevToolsDiagnosticsHost, B as DevToolsTerminalStatus, Bt as DevToolsServerCommandEntry, Ct as DevToolsViewLauncher, Dt as JsonRenderer, Et as JsonRenderSpec, F as DevToolsChildProcessTerminalSession, Ft as DevToolsCommandHandle, G as DevToolsLogElementPosition, Gt as AgentResourceContent, H as DevToolsRpcClientFunctions, Ht as AgentHandle, I as DevToolsTerminalHost, It as DevToolsCommandKeybinding, J as DevToolsLogEntryInput, Jt as AgentToolInput, K as DevToolsLogEntry, Kt as AgentResourceInput, L as DevToolsTerminalSession, Lt as DevToolsCommandShortcutOverrides, M as PartialWithoutId, Mt as DevToolsClientCommand, N as Thenable, Nt as DevToolsCommandBase, Ot as RemoteDockOptions, P as DevToolsChildProcessExecuteOptions, Pt as DevToolsCommandEntry, Q as DevToolsLogsClient, Qt as EventUnsubscribe, R as DevToolsTerminalSessionBase, Rt as DevToolsCommandsHost, St as DevToolsViewJsonRender, Tt as JsonRenderElement, U as DevToolsRpcServerFunctions, Ut as AgentManifest, V as DevToolsDocksUserSettings, Vt as DevToolsServerCommandInput, W as DevToolsRpcSharedStates, Wt as AgentResource, X as DevToolsLogHandle, Xt as DevToolsAgentHostEvents, Y as DevToolsLogFilePosition, Yt as DevToolsAgentHost, Z as DevToolsLogLevel, Zt as EventEmitter, _ as RpcSharedStateGetOptions, _t as DevToolsDockUserEntry, a as DevtoolRuntime, at as DevToolsMessageHandle, bt as DevToolsViewCustomRender, c as defineDevtool, ct as DevToolsMessagesHost, d as DevToolsNodeContext, dt as DevToolsDockEntriesGrouped, et as DevToolsMessageElementPosition, f as DevToolsNodeUtils, ft as DevToolsDockEntry, g as RpcFunctionsHost, gt as DevToolsDockHost, h as RpcBroadcastOptions, ht as DevToolsDockEntryIcon, i as DevtoolDeploymentKind, it as DevToolsMessageFilePosition, j as EntriesToObject, jt as DevToolsDiagnosticsLogger, kt as DevToolsDiagnosticsDefinition, l as ConnectionMeta, lt as DevToolsHost, m as DevToolsNodeRpcSession, mt as DevToolsDockEntryCategory, n as DevtoolCliOptions, nt as DevToolsMessageEntryFrom, o as DevtoolSetupInfo, ot as DevToolsMessageLevel, p as RemoteConnectionInfo, pt as DevToolsDockEntryBase, q as DevToolsLogEntryFrom, qt as AgentTool, r as DevtoolDefinition, rt as DevToolsMessageEntryInput, s as DevtoolSpaOptions, st as DevToolsMessagesClient, t as DevtoolBrowserContext, tt as DevToolsMessageEntry, u as DevToolsCapabilities, ut as ClientScriptEntry, v as RpcSharedStateHost, vt as DevToolsViewAction, wt as DevToolsViewLauncherStatus, xt as DevToolsViewIframe, yt as DevToolsViewBuiltin, z as DevToolsTerminalSessionStreamChunkEvent, zt as DevToolsCommandsHostEvents } from "../devtool-CHT-4_OU.mjs";
2
+ import { m as RpcFunctionAgentOptions } from "../types-BkyzI9r4.mjs";
3
+ import { t as DevToolsNodeRpcSessionMeta } from "../ws-server-Cu8tmZcF.mjs";
4
+ export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, ClientScriptEntry, ConnectionMeta, DevToolsAgentHost, DevToolsAgentHostEvents, DevToolsCapabilities, DevToolsChildProcessExecuteOptions, DevToolsChildProcessTerminalSession, DevToolsClientCommand, DevToolsCommandBase, DevToolsCommandEntry, DevToolsCommandHandle, DevToolsCommandKeybinding, DevToolsCommandShortcutOverrides, DevToolsCommandsHost, DevToolsCommandsHostEvents, DevToolsDiagnosticsDefinition, DevToolsDiagnosticsHost, DevToolsDiagnosticsLogger, DevToolsDockEntriesGrouped, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsDockUserEntry, DevToolsDocksUserSettings, DevToolsHost, DevToolsLogElementPosition, DevToolsLogEntry, DevToolsLogEntryFrom, DevToolsLogEntryInput, DevToolsLogFilePosition, DevToolsLogHandle, DevToolsLogLevel, DevToolsLogsClient, DevToolsLogsHost, DevToolsMessageElementPosition, DevToolsMessageEntry, DevToolsMessageEntryFrom, DevToolsMessageEntryInput, DevToolsMessageFilePosition, DevToolsMessageHandle, DevToolsMessageLevel, DevToolsMessagesClient, DevToolsMessagesHost, DevToolsNodeContext, DevToolsNodeRpcSession, DevToolsNodeRpcSessionMeta, DevToolsNodeUtils, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsRpcSharedStates, DevToolsServerCommandEntry, DevToolsServerCommandInput, DevToolsTerminalHost, DevToolsTerminalSession, DevToolsTerminalSessionBase, DevToolsTerminalSessionStreamChunkEvent, DevToolsTerminalStatus, DevToolsViewAction, DevToolsViewBuiltin, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, DevToolsViewJsonRender, DevToolsViewLauncher, DevToolsViewLauncherStatus, DevtoolBrowserContext, DevtoolCliOptions, DevtoolDefinition, DevtoolDeploymentKind, DevtoolRuntime, DevtoolSetupInfo, DevtoolSpaOptions, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, JsonRenderElement, JsonRenderSpec, JsonRenderer, PartialWithoutId, RemoteConnectionInfo, RemoteDockOptions, RpcBroadcastOptions, RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, Thenable, defineDevtool };
@@ -0,0 +1,6 @@
1
+ //#region src/types/devtool.ts
2
+ function defineDevtool(d) {
3
+ return d;
4
+ }
5
+ //#endregion
6
+ export { defineDevtool };
@@ -0,0 +1,273 @@
1
+ import { GenericSchema, InferInput } from "valibot";
2
+ import { BirpcFn, BirpcReturn as BirpcReturn$1 } from "birpc";
3
+
4
+ //#region src/rpc/utils.d.ts
5
+ /** Infers TypeScript tuple type from Valibot schema array */
6
+ type InferArgsType<S extends RpcArgsSchema | undefined> = S extends readonly [] ? [] : S extends readonly [infer H, ...infer T] ? H extends GenericSchema ? T extends readonly GenericSchema[] ? [InferInput<H>, ...InferArgsType<T>] : never : never : never;
7
+ /** Infers TypeScript return type from Valibot return schema */
8
+ type InferReturnType<S extends RpcReturnSchema | undefined> = S extends RpcReturnSchema ? InferInput<S> : void;
9
+ //#endregion
10
+ //#region src/rpc/types.d.ts
11
+ type Thenable<T> = T | Promise<T>;
12
+ type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as K[0]]: K[1] };
13
+ /**
14
+ * Type of the RPC function,
15
+ * - static: A function that returns a static data, no arguments (can be cached and dumped)
16
+ * - action: A function that performs an action (no data returned)
17
+ * - event: A function that emits an event (no data returned), and does not wait for a response
18
+ * - query: A function that queries a resource
19
+ *
20
+ * By default, the function is a query function.
21
+ */
22
+ type RpcFunctionType = 'static' | 'action' | 'event' | 'query';
23
+ /**
24
+ * Agent exposure settings for an RPC function. When this field is set,
25
+ * the function is surfaced to agents (e.g. via the devframe MCP adapter)
26
+ * as a callable tool. Functions without an `agent` field are not exposed —
27
+ * default-deny.
28
+ *
29
+ * @experimental The agent-native surface is experimental and may change
30
+ * without a major version bump until it stabilizes.
31
+ */
32
+ interface RpcFunctionAgentOptions {
33
+ /**
34
+ * Human-readable description shown to the agent. Required — agents
35
+ * rely on this to decide when to invoke the tool. Keep it to ~1–3
36
+ * sentences explaining what the tool does and when to use it.
37
+ */
38
+ description: string;
39
+ /**
40
+ * Optional human-friendly display title. Maps to the MCP tool `title`
41
+ * annotation. Falls back to the RPC function `name` when omitted.
42
+ */
43
+ title?: string;
44
+ /**
45
+ * Safety classification. Drives MCP annotations (`readOnlyHint`,
46
+ * `destructiveHint`) downstream.
47
+ * - `'read'` — no side effects; safe to call freely.
48
+ * - `'action'` — mutates state but not destructive.
49
+ * - `'destructive'` — may perform destructive updates.
50
+ *
51
+ * When omitted it is inferred from the function `type`:
52
+ * - `'static'` / `'query'` → `'read'`
53
+ * - `'action'` / `'event'` → `'action'`
54
+ */
55
+ safety?: 'read' | 'action' | 'destructive';
56
+ /** Free-form tags for grouping or filtering. */
57
+ tags?: readonly string[];
58
+ /**
59
+ * Optional example invocations shown to agents. Returned verbatim in
60
+ * the agent manifest.
61
+ */
62
+ examples?: readonly {
63
+ args: unknown[];
64
+ description?: string;
65
+ }[];
66
+ }
67
+ /**
68
+ * Manages dynamic function registration and provides a type-safe proxy for accessing functions.
69
+ */
70
+ interface RpcFunctionsCollector<LocalFunctions, SetupContext = undefined> {
71
+ /** User-provided context passed to setup functions */
72
+ context: SetupContext;
73
+ /** Type-safe proxy for calling registered functions */
74
+ readonly functions: LocalFunctions;
75
+ /** Map of registered function definitions keyed by function name */
76
+ readonly definitions: Map<string, RpcFunctionDefinitionAnyWithContext<SetupContext>>;
77
+ /** Register a new function definition */
78
+ register: (fn: RpcFunctionDefinitionAnyWithContext<SetupContext>) => void;
79
+ /** Update an existing function definition */
80
+ update: (fn: RpcFunctionDefinitionAnyWithContext<SetupContext>) => void;
81
+ /** Subscribe to function changes, returns unsubscribe function */
82
+ onChanged: (fn: (id?: string) => void) => (() => void);
83
+ }
84
+ /**
85
+ * Result returned by a function's setup method.
86
+ */
87
+ interface RpcFunctionSetupResult<ARGS extends any[], RETURN = void> {
88
+ /** Function handler */
89
+ handler?: (...args: ARGS) => RETURN;
90
+ /** Optional dump definition (overrides definition-level dump) */
91
+ dump?: RpcDumpDefinition<ARGS, RETURN>;
92
+ }
93
+ /** Valibot schema array for validating function arguments */
94
+ type RpcArgsSchema = readonly GenericSchema[];
95
+ /** Valibot schema for validating function return value */
96
+ type RpcReturnSchema = GenericSchema;
97
+ /**
98
+ * Single record in a dump store with pre-computed results.
99
+ */
100
+ interface RpcDumpRecord<ARGS extends any[] = any[], RETURN = any> {
101
+ /** Function arguments */
102
+ inputs: ARGS;
103
+ /** Result (value or lazy function) */
104
+ output?: RETURN;
105
+ /** Error if execution failed */
106
+ error?: {
107
+ /** Error message */message: string; /** Error type name (e.g., "Error", "TypeError") */
108
+ name: string;
109
+ };
110
+ }
111
+ /**
112
+ * Defines argument combinations to pre-compute for a function.
113
+ */
114
+ interface RpcDumpDefinition<ARGS extends any[] = any[], RETURN = any> {
115
+ /** Argument combinations to pre-compute by executing handler */
116
+ inputs?: ARGS[];
117
+ /** Pre-computed records to use directly (bypasses handler execution) */
118
+ records?: RpcDumpRecord<ARGS, RETURN>[];
119
+ /** Fallback value when no match found */
120
+ fallback?: RETURN;
121
+ }
122
+ /**
123
+ * Dynamically generates dump definitions based on context.
124
+ */
125
+ type RpcDumpGetter<ARGS extends any[] = any[], RETURN = any, CONTEXT = any> = (context: CONTEXT, handler: (...args: ARGS) => RETURN) => Thenable<RpcDumpDefinition<ARGS, RETURN>>;
126
+ /**
127
+ * Dump configuration (static object or dynamic function).
128
+ */
129
+ type RpcDump<ARGS extends any[] = any[], RETURN = any, CONTEXT = any> = RpcDumpDefinition<ARGS, RETURN> | RpcDumpGetter<ARGS, RETURN, CONTEXT>;
130
+ /**
131
+ * Base function definition metadata.
132
+ */
133
+ interface RpcFunctionDefinitionBase {
134
+ /** Function name (unique identifier) */
135
+ name: string;
136
+ /** Function type (static, action, event, or query) */
137
+ type?: RpcFunctionType;
138
+ /**
139
+ * Declares whether this function's args/return are JSON-serializable
140
+ * — i.e. no `Map`, `Set`, `Date`, `BigInt`, class instances, circular
141
+ * references, `undefined` leaves, `Symbol`, or `Function` values.
142
+ *
143
+ * - `true` — args and return are encoded with strict `JSON.stringify`
144
+ * on the wire and on disk. Misshapen values throw `DF0019` at the
145
+ * sender, surfacing the bug *during the offending call* rather than
146
+ * silently coercing to `{}` later. Required for `agent` exposure.
147
+ * - `false` (default) — payloads use `structured-clone-es`, which
148
+ * round-trips Maps/Sets/cycles. Functions in this mode cannot be
149
+ * exposed via the `agent` field — registration throws `DF0018`.
150
+ */
151
+ jsonSerializable?: boolean;
152
+ }
153
+ /**
154
+ * Dump store containing pre-computed results.
155
+ * Flat structure for serialization and efficient lookups.
156
+ */
157
+ interface RpcDumpStore<T = any> {
158
+ /** Function definitions keyed by name */
159
+ definitions: Record<string, RpcFunctionDefinitionBase>;
160
+ /** Records keyed by '<function-name>---<hash>' or '<function-name>---fallback' */
161
+ records: Record<string, RpcDumpRecord | (() => Promise<RpcDumpRecord>)>;
162
+ /** @internal */
163
+ _functions?: T;
164
+ }
165
+ /**
166
+ * Dump client options.
167
+ */
168
+ interface RpcDumpClientOptions {
169
+ /** Called when arguments don't match any pre-computed entry */
170
+ onMiss?: (functionName: string, args: any[]) => void;
171
+ }
172
+ /**
173
+ * Options for collecting dumps.
174
+ */
175
+ interface RpcDumpCollectionOptions {
176
+ /**
177
+ * Concurrency control for parallel execution.
178
+ * - `false` or `undefined`: sequential execution (default)
179
+ * - `true`: parallel execution with concurrency limit of 5
180
+ * - `number`: parallel execution with specified concurrency limit
181
+ */
182
+ concurrency?: boolean | number | null;
183
+ }
184
+ /**
185
+ * RPC function definition with optional dump support.
186
+ */
187
+ type RpcFunctionDefinition<NAME extends string, TYPE extends RpcFunctionType = 'query', ARGS extends any[] = [], RETURN = void, AS extends RpcArgsSchema | undefined = undefined, RS extends RpcReturnSchema | undefined = undefined, CONTEXT = undefined> = [AS, RS] extends [undefined, undefined] ? {
188
+ /** Function name (unique identifier) */name: NAME; /** Function type (static, action, event, or query) */
189
+ type?: TYPE; /** Whether the function results should be cached */
190
+ cacheable?: boolean; /** Valibot schema array for validating function arguments */
191
+ args?: AS; /** Valibot schema for validating function return value */
192
+ returns?: RS;
193
+ /**
194
+ * Declares whether this function's args/return are JSON-serializable
195
+ * (no Map/Set/Date/BigInt/cycles/class instances/undefined/Symbol/Function).
196
+ *
197
+ * - `true` — wire and dump use strict `JSON.stringify`; misshapen
198
+ * values throw `DF0019` at the call site. Required for `agent`.
199
+ * - `false` (default) — `structured-clone-es` round-trips fancy
200
+ * types. Cannot be `agent`-exposed (registration throws `DF0018`).
201
+ */
202
+ jsonSerializable?: boolean;
203
+ /**
204
+ * Expose this function to agents (e.g. via the MCP adapter).
205
+ * When omitted, the function is not agent-exposed (default-deny).
206
+ *
207
+ * @experimental
208
+ */
209
+ agent?: RpcFunctionAgentOptions; /** Setup function called with context to initialize handler and dump */
210
+ setup?: (context: CONTEXT) => Thenable<RpcFunctionSetupResult<ARGS, RETURN>>; /** Function implementation (required if setup doesn't provide one) */
211
+ handler?: (...args: ARGS) => RETURN; /** Dump definition (setup dump takes priority) */
212
+ dump?: RpcDump<ARGS, RETURN, CONTEXT>;
213
+ /**
214
+ * Sugar for "query in dev, single baked snapshot in build": when
215
+ * `true` and no `dump` is provided, the build adapter runs the
216
+ * handler once with no arguments and stores the result as both a
217
+ * no-args record and the fallback so any call variant resolves
218
+ * to the same snapshot. Only valid on `query` (or untyped)
219
+ * functions — `static` already has equivalent default behavior.
220
+ */
221
+ snapshot?: boolean;
222
+ __resolved?: RpcFunctionSetupResult<ARGS, RETURN>;
223
+ __promise?: Thenable<RpcFunctionSetupResult<ARGS, RETURN>>;
224
+ } : {
225
+ /** Function name (unique identifier) */name: NAME; /** Function type (static, action, event, or query) */
226
+ type?: TYPE; /** Whether the function results should be cached */
227
+ cacheable?: boolean; /** Valibot schema array for validating function arguments */
228
+ args: AS; /** Valibot schema for validating function return value */
229
+ returns: RS;
230
+ /**
231
+ * Declares whether this function's args/return are JSON-serializable
232
+ * (no Map/Set/Date/BigInt/cycles/class instances/undefined/Symbol/Function).
233
+ *
234
+ * - `true` — wire and dump use strict `JSON.stringify`; misshapen
235
+ * values throw `DF0019` at the call site. Required for `agent`.
236
+ * - `false` (default) — `structured-clone-es` round-trips fancy
237
+ * types. Cannot be `agent`-exposed (registration throws `DF0018`).
238
+ */
239
+ jsonSerializable?: boolean;
240
+ /**
241
+ * Expose this function to agents (e.g. via the MCP adapter).
242
+ * When omitted, the function is not agent-exposed (default-deny).
243
+ *
244
+ * @experimental
245
+ */
246
+ agent?: RpcFunctionAgentOptions; /** Setup function called with context to initialize handler and dump */
247
+ setup?: (context: CONTEXT) => Thenable<RpcFunctionSetupResult<InferArgsType<AS>, InferReturnType<RS>>>; /** Function implementation (required if setup doesn't provide one) */
248
+ handler?: (...args: InferArgsType<AS>) => InferReturnType<RS>; /** Dump definition (setup dump takes priority) */
249
+ dump?: RpcDump<InferArgsType<AS>, InferReturnType<RS>, CONTEXT>;
250
+ /**
251
+ * Sugar for "query in dev, single baked snapshot in build": when
252
+ * `true` and no `dump` is provided, the build adapter runs the
253
+ * handler once with no arguments and stores the result as both a
254
+ * no-args record and the fallback so any call variant resolves
255
+ * to the same snapshot. Only valid on `query` (or untyped)
256
+ * functions — `static` already has equivalent default behavior.
257
+ */
258
+ snapshot?: boolean;
259
+ __resolved?: RpcFunctionSetupResult<InferArgsType<AS>, InferReturnType<RS>>;
260
+ __promise?: Thenable<RpcFunctionSetupResult<InferArgsType<AS>, InferReturnType<RS>>>;
261
+ };
262
+ type RpcFunctionDefinitionToFunction<T extends RpcFunctionDefinitionAny> = T extends {
263
+ args: infer AS;
264
+ returns: infer RS;
265
+ } ? AS extends RpcArgsSchema ? RS extends RpcReturnSchema ? (...args: InferArgsType<AS>) => InferReturnType<RS> : never : never : T extends RpcFunctionDefinition<string, any, infer ARGS, infer RETURN, any, any, any> ? (...args: ARGS) => RETURN : never;
266
+ type RpcFunctionDefinitionAny = RpcFunctionDefinition<string, any, any, any, any, any, any>;
267
+ type RpcFunctionDefinitionAnyWithContext<CONTEXT = undefined> = RpcFunctionDefinition<string, any, any, any, any, any, CONTEXT>;
268
+ type RpcDefinitionsToFunctions<T extends readonly RpcFunctionDefinitionAny[]> = EntriesToObject<{ [K in keyof T]: [T[K]['name'], RpcFunctionDefinitionToFunction<T[K]>] }>;
269
+ type RpcDefinitionsFilter<T extends readonly RpcFunctionDefinitionAny[], Type extends RpcFunctionType> = { [K in keyof T]: T[K] extends {
270
+ type: Type;
271
+ } ? T[K] : never };
272
+ //#endregion
273
+ export { RpcReturnSchema as C, RpcFunctionsCollector as S, RpcFunctionDefinitionAnyWithContext as _, RpcDefinitionsFilter as a, RpcFunctionSetupResult as b, RpcDumpClientOptions as c, RpcDumpGetter as d, RpcDumpRecord as f, RpcFunctionDefinitionAny as g, RpcFunctionDefinition as h, RpcArgsSchema as i, RpcDumpCollectionOptions as l, RpcFunctionAgentOptions as m, BirpcReturn$1 as n, RpcDefinitionsToFunctions as o, RpcDumpStore as p, EntriesToObject as r, RpcDump as s, BirpcFn as t, RpcDumpDefinition as u, RpcFunctionDefinitionBase as v, Thenable as w, RpcFunctionType as x, RpcFunctionDefinitionToFunction as y };
@@ -0,0 +1,9 @@
1
+ import { $t as EventsMap, Zt as EventEmitter } from "../devtool-CHT-4_OU.mjs";
2
+
3
+ //#region src/utils/events.d.ts
4
+ /**
5
+ * Create event emitter.
6
+ */
7
+ declare function createEventEmitter<Events extends EventsMap>(): EventEmitter<Events>;
8
+ //#endregion
9
+ export { createEventEmitter };
@@ -0,0 +1,40 @@
1
+ //#region src/utils/events.ts
2
+ /**
3
+ * Create event emitter.
4
+ */
5
+ function createEventEmitter() {
6
+ const _listeners = {};
7
+ function emit(event, ...args) {
8
+ const callbacks = _listeners[event] || [];
9
+ for (let i = 0, length = callbacks.length; i < length; i++) {
10
+ const callback = callbacks[i];
11
+ if (callback) callback(...args);
12
+ }
13
+ }
14
+ function emitOnce(event, ...args) {
15
+ emit(event, ...args);
16
+ delete _listeners[event];
17
+ }
18
+ function on(event, cb) {
19
+ (_listeners[event] ||= []).push(cb);
20
+ return () => {
21
+ _listeners[event] = _listeners[event]?.filter((i) => cb !== i);
22
+ };
23
+ }
24
+ function once(event, cb) {
25
+ const unsubscribe = on(event, ((...args) => {
26
+ unsubscribe();
27
+ return cb(...args);
28
+ }));
29
+ return unsubscribe;
30
+ }
31
+ return {
32
+ _listeners,
33
+ emit,
34
+ emitOnce,
35
+ on,
36
+ once
37
+ };
38
+ }
39
+ //#endregion
40
+ export { createEventEmitter };
@@ -0,0 +1,10 @@
1
+ //#region ../../../node_modules/.pnpm/human-id@4.1.3/node_modules/human-id/dist/index.d.ts
2
+ interface Options {
3
+ separator?: string;
4
+ capitalize?: boolean;
5
+ adjectiveCount?: number;
6
+ addAdverb?: boolean;
7
+ }
8
+ declare function humanId(options?: Options | string | boolean): string;
9
+ //#endregion
10
+ export { humanId };
@@ -0,0 +1,3 @@
1
+ import { t as import_dist } from "../human-id-CHS0s28X.mjs";
2
+ var humanId = import_dist.humanId;
3
+ export { humanId };
@@ -0,0 +1,4 @@
1
+ //#region src/utils/nanoid.d.ts
2
+ declare function nanoid(size?: number): string;
3
+ //#endregion
4
+ export { nanoid };
@@ -0,0 +1,10 @@
1
+ //#region src/utils/nanoid.ts
2
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
3
+ function nanoid(size = 21) {
4
+ let id = "";
5
+ let i = size;
6
+ while (i--) id += urlAlphabet[Math.random() * 64 | 0];
7
+ return id;
8
+ }
9
+ //#endregion
10
+ export { nanoid };
@@ -0,0 +1,8 @@
1
+ //#region src/utils/promise.d.ts
2
+ declare function promiseWithResolver<T>(): {
3
+ promise: Promise<T>;
4
+ resolve: (value: T) => void;
5
+ reject: (error: Error) => void;
6
+ };
7
+ //#endregion
8
+ export { promiseWithResolver };
@@ -0,0 +1,15 @@
1
+ //#region src/utils/promise.ts
2
+ function promiseWithResolver() {
3
+ let resolve;
4
+ let reject;
5
+ return {
6
+ promise: new Promise((_resolve, _reject) => {
7
+ resolve = _resolve;
8
+ reject = _reject;
9
+ }),
10
+ resolve,
11
+ reject
12
+ };
13
+ }
14
+ //#endregion
15
+ export { promiseWithResolver };
@@ -0,0 +1,2 @@
1
+ import { C as ImmutableSet, D as createSharedState, E as SharedStateOptions, S as ImmutableObject, T as SharedStateEvents, b as ImmutableArray, k as Patch, w as SharedState, x as ImmutableMap, y as Immutable } from "../devtool-CHT-4_OU.mjs";
2
+ export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, Patch as SharedStatePatch, createSharedState };
@@ -0,0 +1,36 @@
1
+ import { createEventEmitter } from "./events.mjs";
2
+ import { i as produceWithPatches, n as enablePatches, r as produce, t as applyPatches } from "../immer-DEqg5kOd.mjs";
3
+ import { nanoid } from "./nanoid.mjs";
4
+ //#region src/utils/shared-state.ts
5
+ function createSharedState(options) {
6
+ const { enablePatches: enablePatches$1 = false } = options;
7
+ const events = createEventEmitter();
8
+ let state = options.initialValue;
9
+ const syncIds = /* @__PURE__ */ new Set();
10
+ return {
11
+ on: events.on,
12
+ value: () => state,
13
+ patch: (patches, syncId = nanoid()) => {
14
+ if (syncIds.has(syncId)) return;
15
+ enablePatches();
16
+ state = applyPatches(state, patches);
17
+ syncIds.add(syncId);
18
+ events.emit("updated", state, void 0, syncId);
19
+ },
20
+ mutate: (fn, syncId = nanoid()) => {
21
+ if (syncIds.has(syncId)) return;
22
+ syncIds.add(syncId);
23
+ if (enablePatches$1) {
24
+ const [newState, patches] = produceWithPatches(state, fn);
25
+ state = newState;
26
+ events.emit("updated", state, patches, syncId);
27
+ } else {
28
+ state = produce(state, fn);
29
+ events.emit("updated", state, void 0, syncId);
30
+ }
31
+ },
32
+ syncIds
33
+ };
34
+ }
35
+ //#endregion
36
+ export { createSharedState };
@@ -0,0 +1,49 @@
1
+ import { O as Objectish, Zt as EventEmitter, k as Patch } from "../devtool-CHT-4_OU.mjs";
2
+
3
+ //#region src/utils/state.d.ts
4
+ type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
5
+ type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
6
+ type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
7
+ type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
8
+ type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
9
+ type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
10
+ /**
11
+ * State host that is immutable by default with explicit mutate.
12
+ */
13
+ interface SharedState<T> {
14
+ /**
15
+ * Get the current state. Immutable.
16
+ */
17
+ get: () => Immutable<T>;
18
+ /**
19
+ * Subscribe to state changes.
20
+ */
21
+ on: EventEmitter<SharedStateEvents<T>>['on'];
22
+ /**
23
+ * Mutate the state.
24
+ */
25
+ mutate: (fn: (state: T) => void) => void;
26
+ /**
27
+ * Apply patches to the state.
28
+ */
29
+ patch: (patches: Patch[]) => void;
30
+ }
31
+ interface SharedStateEvents<T> {
32
+ updated: (state: T) => void;
33
+ patches: (patches: Patch[]) => void;
34
+ }
35
+ interface SharedStateOptions<T> {
36
+ /**
37
+ * Initial state.
38
+ */
39
+ initialState: T;
40
+ /**
41
+ * Enable patches.
42
+ *
43
+ * @default false
44
+ */
45
+ enablePatches?: boolean;
46
+ }
47
+ declare function createSharedState<T extends Objectish>(options: SharedStateOptions<T>): SharedState<T>;
48
+ //#endregion
49
+ export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, createSharedState };
@@ -0,0 +1,26 @@
1
+ import { createEventEmitter } from "./events.mjs";
2
+ import { i as produceWithPatches, r as produce, t as applyPatches } from "../immer-DEqg5kOd.mjs";
3
+ //#region src/utils/state.ts
4
+ function createSharedState(options) {
5
+ const { enablePatches = false } = options;
6
+ const events = createEventEmitter();
7
+ let state = options.initialState;
8
+ return {
9
+ on: events.on,
10
+ get: () => state,
11
+ patch: (patches) => {
12
+ state = applyPatches(state, patches);
13
+ events.emit("updated", state);
14
+ },
15
+ mutate: (fn) => {
16
+ if (enablePatches) {
17
+ const [newState, patches] = produceWithPatches(state, fn);
18
+ state = newState;
19
+ events.emit("patches", patches);
20
+ } else state = produce(state, fn);
21
+ events.emit("updated", state);
22
+ }
23
+ };
24
+ }
25
+ //#endregion
26
+ export { createSharedState };
@@ -0,0 +1,2 @@
1
+ import { i as resolveContextValue, n as WhenExpression, r as evaluateWhen, t as WhenContext } from "../when-aBBXAEh5.mjs";
2
+ export { WhenContext, WhenExpression, evaluateWhen, resolveContextValue };