@lunora/solid 1.0.0-alpha.1 → 1.0.0-alpha.100

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 (43) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +25 -15
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/index.d.mts +1028 -187
  5. package/dist/index.d.ts +1028 -187
  6. package/dist/index.mjs +1 -11
  7. package/dist/packem_shared/AuthLoading-6vueEnV0.mjs +1 -0
  8. package/dist/packem_shared/LunoraContext-dPcjtn6R.mjs +1 -0
  9. package/dist/packem_shared/LunoraProvider-BKWckcDR.mjs +1 -0
  10. package/dist/packem_shared/createAction-M4s8XBXV.mjs +1 -0
  11. package/dist/packem_shared/createAgent-DuksX_2d.mjs +1 -0
  12. package/dist/packem_shared/createAgentChat-Ch4Hqox4.mjs +1 -0
  13. package/dist/packem_shared/createAgentState-Catc7Xux.mjs +1 -0
  14. package/dist/packem_shared/createAgentToolEvents-BjdgzYqX.mjs +1 -0
  15. package/dist/packem_shared/createConnectionStatus-BnlXYWeE.mjs +1 -0
  16. package/dist/packem_shared/createFlag-DsxOYsJW.mjs +1 -0
  17. package/dist/packem_shared/createInfiniteQuery-BPyo9Ktw.mjs +1 -0
  18. package/dist/packem_shared/createMutation-DcSsIbGF.mjs +1 -0
  19. package/dist/packem_shared/createMutator-q9cMjGKv.mjs +1 -0
  20. package/dist/packem_shared/createPresence-Bu4loG39.mjs +1 -0
  21. package/dist/packem_shared/createQuery-CdWTlKJM.mjs +1 -0
  22. package/dist/packem_shared/createRateLimit-CIVWrD5H.mjs +1 -0
  23. package/dist/packem_shared/createStream-Dx7SnivS.mjs +1 -0
  24. package/dist/packem_shared/createSubscription-CsrywUOa.mjs +1 -0
  25. package/dist/packem_shared/createVoiceAgent-BiALuzBe.mjs +1 -0
  26. package/dist/packem_shared/hydratePreloaded-Bhxdstm1.mjs +1 -0
  27. package/dist/packem_shared/solid-compat-ByG5HD_F.mjs +1 -0
  28. package/dist/server.mjs +1 -1
  29. package/dist/upload.d.mts +2 -0
  30. package/dist/upload.d.ts +2 -0
  31. package/dist/upload.mjs +1 -0
  32. package/package.json +11 -5
  33. package/dist/packem_shared/Authenticated-RMT5Q_eE.mjs +0 -73
  34. package/dist/packem_shared/LunoraContext-C9SpKj54.mjs +0 -12
  35. package/dist/packem_shared/LunoraProvider-B5BJFk3K.mjs +0 -17
  36. package/dist/packem_shared/createConnectionStatus-D8GPatZX.mjs +0 -14
  37. package/dist/packem_shared/createInfiniteQuery-DyMvQ2Qy.mjs +0 -196
  38. package/dist/packem_shared/createMutationForClient-C7BxzO0y.mjs +0 -36
  39. package/dist/packem_shared/createPresence-DiAak1Jw.mjs +0 -78
  40. package/dist/packem_shared/createQuery-D8mdHfyQ.mjs +0 -28
  41. package/dist/packem_shared/createRateLimit-BA2f8XyF.mjs +0 -76
  42. package/dist/packem_shared/createSubscription-BM2fw8hw.mjs +0 -39
  43. package/dist/packem_shared/hydratePreloaded-CaT1kDBH.mjs +0 -25
package/dist/index.d.ts CHANGED
@@ -1,67 +1,603 @@
1
- import { LunoraClient, User, ConnectionStatus, FunctionReference, ArgsOf, MutationCallOptions, ReturnOf, Preloaded } from '@lunora/client';
2
- export type { ArgsOf, FunctionReference, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe } from '@lunora/client';
3
- import { Context, JSX, Accessor } from 'solid-js';
1
+ import { LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, SubscriptionErrorCallback, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionError, Preloaded } from '@lunora/client';
2
+ export type { ArgsOf, FunctionReference, MutatorHandle, MutatorTransaction, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe } from '@lunora/client';
3
+ import { Context, Accessor } from 'solid-js';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
6
6
  /**
7
- * Solid context carrying the framework-neutral {@link LunoraClient}. Every
8
- * reactive primitive in this adapter (`createQuery`, `createMutation`,
9
- * `hydratePreloaded`) reads the client from here, so a single
10
- * `<LunoraProvider client={…}>` at the root of the tree wires the whole app.
11
- *
12
- * Defaults to `undefined` so {@link useLunora} can throw a helpful error when a
13
- * primitive is used outside a provider rather than dereferencing it.
14
- */
7
+ * Solid context carrying the framework-neutral {@link LunoraClient}. Every
8
+ * reactive primitive in this adapter (`createQuery`, `createMutation`,
9
+ * `hydratePreloaded`) reads the client from here, so a single
10
+ * `<LunoraProvider client={…}>` at the root of the tree wires the whole app.
11
+ *
12
+ * Defaults to `undefined` so {@link useLunora} can throw a helpful error when a
13
+ * primitive is used outside a provider rather than dereferencing it. Solid 2
14
+ * refuses to hand back an `undefined` default at all — see {@link useLunora}.
15
+ */
15
16
  declare const LunoraContext: Context<LunoraClient | undefined>;
16
17
  /**
17
- * Read the {@link LunoraClient} from the nearest `&lt;LunoraProvider>`.
18
- *
19
- * Throws when called outside a provider — the client is required to open the
20
- * HTTP/WS transport, so there is no sensible fallback. The React adapter's
21
- * `useLunora` has the same contract.
22
- */
18
+ * Read the {@link LunoraClient} from the nearest `<LunoraProvider>`.
19
+ *
20
+ * Throws when called outside a provider — the client is required to open the
21
+ * HTTP/WS transport, so there is no sensible fallback. The React adapter's
22
+ * `useLunora` has the same contract.
23
+ */
23
24
  declare const useLunora: () => LunoraClient;
25
+ interface ActionHandle<F extends FunctionReference> {
26
+ /** Invoke the action. Resolves with the server result; rejects on failure. */
27
+ call: (args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
28
+ /** The latest invocation's resolved value, or `undefined` before the first success. */
29
+ data: Accessor<ReturnOf<F> | undefined>;
30
+ /** The latest invocation's error, or `undefined`. */
31
+ error: Accessor<Error | undefined>;
32
+ /** `true` while any invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
33
+ pending: Accessor<boolean>;
34
+ /** Clear `data`/`error` back to idle. */
35
+ reset: () => void;
36
+ }
37
+ /**
38
+ * The transport surface {@link createAction} actually needs — just
39
+ * `client.action`. Narrowed so the primitive can be exercised against a stub in
40
+ * tests without constructing a full `LunoraClient`.
41
+ */
42
+ interface ActionClient<F extends FunctionReference> {
43
+ action: (function_: F, args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
44
+ }
45
+ /**
46
+ * Build an action handle bound to an explicit client. Internal seam used by the
47
+ * provider-bound {@link createAction}; exported for tests that inject a stub.
48
+ * The ref-counted pending + error-normalize orchestration is the shared
49
+ * `createCallRunner` from `@lunora/client`; only the reactive sinks (Solid
50
+ * signals) are adapter-specific.
51
+ *
52
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
53
+ * invocation (an earlier call settling later cannot clobber a newer one), a
54
+ * success clears `error`, and a failure leaves the previous `data` in place.
55
+ * `reset()` clears both; it does not cancel an in-flight call.
56
+ */
57
+ declare const createActionForClient: <F extends FunctionReference>(client: ActionClient<F>, function_: F) => ActionHandle<F>;
58
+ /**
59
+ * Returns a reactive handle `{ call, pending, data, error, reset }` for the
60
+ * given action reference, bound to the `LunoraClient` from the nearest
61
+ * `<LunoraProvider>`.
62
+ *
63
+ * **Narrower than `createMutation` on purpose:** no `optimistic` /
64
+ * `optimisticUpdate` call options. An optimistic update patches the subscription
65
+ * cache on the assumption a write will land; an action is not a write — it runs
66
+ * in the Worker, may call a third party, and has no declared effect on any
67
+ * query. Offering the option would imply a rollback guarantee nothing can
68
+ * honour.
69
+ */
70
+ declare const createAction: <F extends FunctionReference>(function_: F) => ActionHandle<F>;
71
+ /**
72
+ * The lifecycle status stored on an agent thread. Client-safe mirror of
73
+ * `@lunora/agent`'s `AgentThreadStatus` — re-declared here (rather than imported)
74
+ * so this Solid entry never pulls in the server-only `@lunora/agent` module graph
75
+ * (the adapter stays Solid + `@lunora/client` only). Keep in sync with
76
+ * `packages/agent/src/types.ts`.
77
+ */
78
+ type AgentThreadStatus = "awaiting_input" | "cancelled" | "error" | "idle" | "running";
79
+ /**
80
+ * The live thread record surfaced by the `agents:agentThread` query. A structural
81
+ * subset of the persisted thread row — every field beyond `status` is optional so
82
+ * the shape stays forgiving as the server schema grows. Keep in sync with the
83
+ * `agent_threads` table in `packages/agent/src/component.ts`.
84
+ */
85
+ interface AgentThreadRecord {
86
+ createdAt?: number;
87
+ /** The failure message when `status === "error"`. */
88
+ error?: string;
89
+ /** The workflow instance id of the in-flight run — the handle `cancel` targets. */
90
+ instanceId?: string;
91
+ messageCount?: number;
92
+ /** The verified thread owner, when the run was started with one. */
93
+ owner?: string;
94
+ status: AgentThreadStatus;
95
+ title?: string;
96
+ updatedAt?: number;
97
+ }
98
+ /** A plain value or a Solid accessor of it — matching `createQuery`'s reactive-args contract. */
99
+ type MaybeAccessor<T> = Accessor<T> | T;
100
+ /**
101
+ * The `agents.agentThread` reference the primitive subscribes to for live thread
102
+ * state (status + the in-flight `instanceId`). A structural subset of the
103
+ * generated `api.agents` surface, so the whole generated `api` object is
104
+ * assignable.
105
+ */
106
+ interface CreateAgentApi {
107
+ agents: {
108
+ agentThread: FunctionReference<"query", {
109
+ key: string;
110
+ }, Record<string, unknown> | undefined>;
111
+ };
112
+ }
113
+ interface CreateAgentOptions {
114
+ /** The generated `api` — its `agents.agentThread` query drives live thread state. */
115
+ api: CreateAgentApi;
116
+ /**
117
+ * Optional app mutation over the agent's cancel path
118
+ * (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
119
+ * When omitted (or no run is in flight) {@link CreateAgentResult.cancel} is a
120
+ * no-op.
121
+ */
122
+ cancel?: FunctionReference<"mutation">;
123
+ /**
124
+ * Called when the live thread subscription reports an error (a session
125
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
126
+ * failure is invisible and `thread` / `status` are cleared until a later frame arrives.
127
+ */
128
+ onError?: SubscriptionErrorCallback;
129
+ /**
130
+ * The app mutation that starts (or continues) a run — a thin wrapper over
131
+ * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
132
+ * {@link CreateAgentOptions.runArgs} and the per-call args.
133
+ */
134
+ run: FunctionReference<"mutation">;
135
+ /** Extra args merged into every `run` call (e.g. an `owner` or `title`). */
136
+ runArgs?: Record<string, unknown>;
137
+ /** The thread to observe and drive — a plain value or accessor (an accessor re-subscribes on change). */
138
+ threadKey: MaybeAccessor<string>;
139
+ }
140
+ interface CreateAgentResult {
141
+ /**
142
+ * Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
143
+ * no-op when no `cancel` mutation was supplied or no run is in flight.
144
+ */
145
+ cancel: () => Promise<void>;
146
+ /** The live thread subscription's last error, or `undefined`. */
147
+ error: Accessor<Error | undefined>;
148
+ /** `true` while a `run` invocation is in flight. */
149
+ pending: Accessor<boolean>;
150
+ /** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
151
+ run: (input: string, args?: Record<string, unknown>) => Promise<void>;
152
+ /** The live thread status, or `undefined` before the thread exists. */
153
+ status: Accessor<AgentThreadStatus | undefined>;
154
+ /** The live thread record (status, `instanceId`, …), or `undefined` before it exists. */
155
+ thread: Accessor<AgentThreadRecord | undefined>;
156
+ }
157
+ /**
158
+ * A thin agent handle: live thread `status` plus `run` / `cancel`, without the
159
+ * chat message surface. Composes `createSubscription(api.agents.agentThread)` for
160
+ * live state and `createMutation` for the run/cancel writes — the Solid
161
+ * counterpart to React's `useAgent`, re-expressed with signals. For the full
162
+ * conversation surface (durable history + streaming + approvals) use
163
+ * `createAgentChat`.
164
+ *
165
+ * `run` and `cancel` stay generic over the app-defined mutations that wrap
166
+ * `ctx.agents.<name>.run` / `.cancel`, so the primitive hard-codes no function
167
+ * names beyond the `agents:*` surface. `threadKey` may be an accessor — a changing
168
+ * key re-subscribes to the new thread.
169
+ */
170
+ declare const createAgent: (options: CreateAgentOptions) => CreateAgentResult;
171
+ /**
172
+ * One persisted (or optimistic) thread message, as `agents:agentMessages`
173
+ * surfaces it. Client-safe mirror of `@lunora/agent`'s `AgentMessageRow` —
174
+ * re-declared here (rather than imported) so this Solid entry never pulls in the
175
+ * server-only `@lunora/agent` module graph. Keep in sync with the
176
+ * `agent_messages` table in `packages/agent/src/component.ts`.
177
+ */
178
+ interface AgentChatMessage {
179
+ content: string;
180
+ createdAt?: number;
181
+ /**
182
+ * `true` for a client-side optimistic user message not yet acknowledged by
183
+ * the server. Cleared once the durable history carries the matching user turn.
184
+ */
185
+ optimistic?: boolean;
186
+ role: "assistant" | "system" | "tool" | "user";
187
+ seq: number;
188
+ /** Approval lifecycle marker on a human-in-the-loop tool message. */
189
+ status?: "approved" | "awaiting_approval" | "rejected";
190
+ toolCallId?: string;
191
+ toolCalls?: ReadonlyArray<{
192
+ id: string;
193
+ input: unknown;
194
+ name: string;
195
+ }>;
196
+ toolName?: string;
197
+ }
198
+ /**
199
+ * A live token delta streamed while a turn is generating. Client-safe mirror of
200
+ * `@lunora/agent`'s `AgentTokenDelta`. Ephemeral — deltas feed
201
+ * {@link CreateAgentChatResult.streamingText} live and are never replayed; the
202
+ * persisted assistant message stays the single source of truth.
203
+ */
204
+ interface AgentTokenDelta {
205
+ /** Discriminates the token arm of {@link AgentLiveEvent}; unset on the wire (token is the default). */
206
+ kind?: "token";
207
+ /** The incremental text chunk the model just produced. */
208
+ text: string;
209
+ /** The thread this delta belongs to. */
210
+ threadKey: string;
211
+ /** The zero-based index of the turn producing the delta. */
212
+ turn: number;
213
+ }
214
+ /**
215
+ * A live tool-progress event streamed via `ctx.reportProgress(...)`. Client-safe
216
+ * mirror of `@lunora/agent`'s `AgentProgressEvent`. Ephemeral and `toolCallId`-keyed;
217
+ * surfaced by `createAgentToolEvents`, ignored by {@link CreateAgentChatResult.streamingText}.
218
+ */
219
+ interface AgentProgressEvent {
220
+ /** The arbitrary, JSON-serializable payload the tool reported. */
221
+ data: unknown;
222
+ /** Discriminates the progress arm of {@link AgentLiveEvent}. */
223
+ kind: "progress";
224
+ /** The thread this event belongs to. */
225
+ threadKey: string;
226
+ /** The tool call this progress belongs to. */
227
+ toolCallId: string;
228
+ }
229
+ /**
230
+ * A single event on the agent's live-only channel — a streamed token delta or a
231
+ * tool progress event. Client-safe mirror of `@lunora/agent`'s `AgentLiveEvent`.
232
+ * Discriminate on `kind` (`"progress"` for the progress arm; token deltas leave
233
+ * it unset).
234
+ */
235
+ type AgentLiveEvent = AgentProgressEvent | AgentTokenDelta;
236
+ /** The `agents:agentMessages` reference — live durable thread history. */
237
+ type AgentMessagesReference$1 = FunctionReference<"query", {
238
+ key: string;
239
+ limit?: number;
240
+ }, ReadonlyArray<Record<string, unknown>>>;
241
+ /** The `agents:agentResolveApproval` reference — resolves a human-in-the-loop tool approval. */
242
+ type AgentApprovalReference = FunctionReference<"mutation", {
243
+ decision: "approve" | "reject";
244
+ instanceId: string;
245
+ note?: string;
246
+ threadKey: string;
247
+ toolCallId: string;
248
+ }, {
249
+ resolved: boolean;
250
+ }>;
251
+ /** The `agents:agentThread` reference — live thread status + in-flight `instanceId`. */
252
+ type AgentThreadReference = FunctionReference<"query", {
253
+ key: string;
254
+ }, Record<string, unknown> | undefined>;
255
+ /**
256
+ * An app stream reference that tees the agent's in-flight live events, keyed by
257
+ * thread. Carries token deltas and — since `ctx.reportProgress` rides the same
258
+ * sink — tool progress events; this primitive consumes only the token arm.
259
+ */
260
+ type AgentTokenStreamReference = FunctionReference<"stream", {
261
+ key: string;
262
+ }, AgentLiveEvent>;
263
+ /**
264
+ * The `agents.*` reference surface the chat primitive reads. A structural subset
265
+ * of the generated `api.agents`, so the whole generated `api` object is
266
+ * assignable.
267
+ */
268
+ interface CreateAgentChatApi {
269
+ agents: {
270
+ agentMessages: AgentMessagesReference$1;
271
+ agentResolveApproval: AgentApprovalReference;
272
+ agentThread: AgentThreadReference;
273
+ };
274
+ }
275
+ interface CreateAgentChatOptions {
276
+ /** The generated `api` — its `agents.*` surface provides history, thread state, and approval resolution. */
277
+ api: CreateAgentChatApi;
278
+ /**
279
+ * Optional app mutation over the agent's cancel path
280
+ * (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
281
+ * When omitted (or no run is in flight) {@link CreateAgentChatResult.cancel} is
282
+ * a no-op.
283
+ */
284
+ cancel?: FunctionReference<"mutation">;
285
+ /** History depth forwarded to `agents:agentMessages`. */
286
+ limit?: number;
287
+ /**
288
+ * Called when the live history or thread subscription reports an error (a
289
+ * session expiry, an RLS denial). Without it — and without reading `error` —
290
+ * such a failure is invisible and `messages` / `status` are cleared until a later frame arrives.
291
+ */
292
+ onError?: SubscriptionErrorCallback;
293
+ /**
294
+ * The app mutation that starts (or continues) a run — a thin wrapper over
295
+ * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
296
+ * {@link CreateAgentChatOptions.sendArgs} and the per-call args.
297
+ */
298
+ send: FunctionReference<"mutation">;
299
+ /** Extra args merged into every `send` call (e.g. an `owner` or `title`). */
300
+ sendArgs?: Record<string, unknown>;
301
+ /**
302
+ * Optional live token-delta stream — an app stream function that tees the
303
+ * agent's in-flight deltas. When omitted {@link CreateAgentChatResult.streamingText}
304
+ * stays empty and the UI updates message-by-message from durable history.
305
+ */
306
+ stream?: AgentTokenStreamReference;
307
+ /** The thread to observe and continue — a plain value or accessor (an accessor re-subscribes on change). */
308
+ threadKey: MaybeAccessor<string>;
309
+ }
310
+ interface CreateAgentChatResult {
311
+ /** Approve a paused human-in-the-loop tool call (optionally with a note). */
312
+ approve: (toolCallId: string, note?: string) => Promise<void>;
313
+ /**
314
+ * Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
315
+ * no-op when no `cancel` mutation was supplied or no run is in flight.
316
+ */
317
+ cancel: () => Promise<void>;
318
+ /** The history or thread subscription's last error, or `undefined`. */
319
+ error: Accessor<Error | undefined>;
320
+ /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
321
+ messages: Accessor<ReadonlyArray<AgentChatMessage>>;
322
+ /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
323
+ reject: (toolCallId: string, note?: string) => Promise<void>;
324
+ /** Start (or continue) a run with a user message; extra args merge over `sendArgs`. Appends an optimistic user turn. */
325
+ send: (input: string, args?: Record<string, unknown>) => Promise<void>;
326
+ /** The live thread status, or `undefined` before the thread exists. */
327
+ status: Accessor<AgentThreadStatus | undefined>;
328
+ /** The in-flight turn's streamed text — live-only, empty once the turn persists to `messages`. */
329
+ streamingText: Accessor<string>;
330
+ }
331
+ /**
332
+ * A first-class agent chat surface: live durable history + in-flight token
333
+ * streaming + the send / approve / reject / cancel writes, keyed by `threadKey` —
334
+ * the Solid counterpart to React's `useAgentChat`, re-expressed with signals.
335
+ *
336
+ * It composes the existing primitives rather than adding transport:
337
+ * `createSubscription(api.agents.agentMessages)` for durable history,
338
+ * `createSubscription(api.agents.agentThread)` for live status + the in-flight
339
+ * `instanceId`, {@link createStream} over an app token stream for in-flight deltas,
340
+ * and `createMutation` for the writes (`api.agents.agentResolveApproval` for
341
+ * approvals; app-defined wrappers for `send`/`cancel`). Only the `agents:*`
342
+ * surface is hard-coded — `send`/`cancel`/`stream` stay generic references.
343
+ *
344
+ * A `send` optimistically appends the user turn so it renders immediately; the
345
+ * optimistic row clears once the durable history carries the acknowledged turn.
346
+ * `streamingText` is live-only: it holds the current turn's streamed text and
347
+ * empties as soon as that turn's assistant message lands in `messages` (the
348
+ * persisted message is the source of truth), consistent with the loop's
349
+ * replay-safe, live-only delta design.
350
+ */
351
+ declare const createAgentChat: (options: CreateAgentChatOptions) => CreateAgentChatResult;
352
+ /**
353
+ * The `agents.agentState` reference the primitive subscribes to for the thread's
354
+ * live synced state. A structural subset of the generated `api.agents` surface
355
+ * (like `CreateAgentApi` for `agentThread`), so the whole generated `api` object
356
+ * is assignable. Client-safe: no `@lunora/agent` import — the per-agent state type
357
+ * is mirrored by the primitive's generic `T`, since codegen pins the reference
358
+ * return as an optional record (it never evaluates agent config).
359
+ */
360
+ interface CreateAgentStateApi {
361
+ agents: {
362
+ agentState: FunctionReference<"query", {
363
+ key: string;
364
+ }, Record<string, unknown> | undefined>;
365
+ };
366
+ }
367
+ interface CreateAgentStateOptions {
368
+ /** The generated `api` — its `agents.agentState` query drives live thread state. */
369
+ api: CreateAgentStateApi;
370
+ /** The thread whose synced state to observe — a plain value or accessor (an accessor re-subscribes on change). */
371
+ threadKey: MaybeAccessor<string>;
372
+ }
373
+ interface CreateAgentStateResult<T> {
374
+ /** The subscription error, if the live channel reported one. */
375
+ error: Accessor<Error | undefined>;
376
+ /** The live synced state, or `undefined` before it is seeded/first pushed. */
377
+ state: Accessor<T | undefined>;
378
+ }
379
+ /**
380
+ * Subscribe to an agent thread's synced state — the `setState`-style value a tool
381
+ * writes with `ctx.setState(...)`, seeded by `defineAgent({ initialState })`. A
382
+ * thin wrapper over `createSubscription(api.agents.agentState, { key })`: the
383
+ * server pushes a fresh frame whenever the state changes (the dedicated query's
384
+ * per-socket JSON memo suppresses no-op pushes on unrelated thread writes), so
385
+ * `state` updates only on a real `setState`. The Solid counterpart to React's
386
+ * `useAgentState`, re-expressed with signals.
387
+ *
388
+ * Generic over the app's state shape (`createAgentState` with a `SupportState`
389
+ * type argument, itself a record) — the reference is typed as an optional record
390
+ * because codegen cannot see the per-agent state type; the generic casts to `T`.
391
+ * The `extends` bound (not a bare unbounded type parameter) is required so the
392
+ * reference's optional-record return casts cleanly to `T`.
393
+ */
394
+ declare const createAgentState: <T extends Record<string, unknown> = Record<string, unknown>>(options: CreateAgentStateOptions) => CreateAgentStateResult<T>;
395
+ /** The `agents:agentMessages` reference — live durable thread history. */
396
+ type AgentMessagesReference = FunctionReference<"query", {
397
+ key: string;
398
+ limit?: number;
399
+ }, ReadonlyArray<Record<string, unknown>>>;
400
+ /**
401
+ * An app stream reference that tees the agent's in-flight live events, keyed by
402
+ * thread. Carries token deltas and tool progress events; this primitive consumes
403
+ * only the progress arm (`kind === "progress"`).
404
+ */
405
+ type AgentLiveStreamReference = FunctionReference<"stream", {
406
+ key: string;
407
+ }, AgentLiveEvent>;
408
+ /**
409
+ * The `agents.*` reference surface the tool-events primitive reads. A structural
410
+ * subset of the generated `api.agents`, so the whole generated `api` object is
411
+ * assignable.
412
+ */
413
+ interface CreateAgentToolEventsApi {
414
+ agents: {
415
+ agentMessages: AgentMessagesReference;
416
+ };
417
+ }
418
+ interface CreateAgentToolEventsOptions {
419
+ /** The generated `api` — its `agents.agentMessages` query provides the durable tool lifecycle. */
420
+ api: CreateAgentToolEventsApi;
421
+ /** History depth forwarded to `agents:agentMessages`. */
422
+ limit?: number;
423
+ /**
424
+ * Optional live event stream — the same app stream function `createAgentChat`
425
+ * uses. When supplied, ephemeral `ctx.reportProgress(...)` events for the
426
+ * thread are surfaced as `{ type: "progress" }` entries; when omitted only the
427
+ * durable lifecycle (call / result / awaiting-approval) is returned.
428
+ */
429
+ stream?: AgentLiveStreamReference;
430
+ /** The thread whose tool activity to observe — a plain value or accessor (an accessor re-subscribes on change). */
431
+ threadKey: MaybeAccessor<string>;
432
+ }
433
+ /**
434
+ * A single tool-lifecycle event for a thread. The durable arms
435
+ * (`call`/`result`/`awaiting-approval`) are derived from `agents:agentMessages`
436
+ * and carry the persisted `seq`; the ephemeral `progress` arm comes live off the
437
+ * stream and has no `seq`. Discriminate on `type`.
438
+ */
439
+ type AgentToolEvent = {
440
+ data: unknown;
441
+ toolCallId: string;
442
+ type: "progress";
443
+ } | {
444
+ input: unknown;
445
+ seq: number;
446
+ toolCallId: string;
447
+ toolName: string;
448
+ type: "call";
449
+ } | {
450
+ output: string;
451
+ seq: number;
452
+ status?: "approved" | "rejected";
453
+ toolCallId?: string;
454
+ toolName?: string;
455
+ type: "result";
456
+ } | {
457
+ seq: number;
458
+ toolCallId?: string;
459
+ toolName?: string;
460
+ type: "awaiting-approval";
461
+ };
462
+ interface CreateAgentToolEventsResult {
463
+ /**
464
+ * The thread's tool events: the durable lifecycle (oldest first, by `seq`)
465
+ * followed by any in-flight ephemeral progress events, recomputed from the live
466
+ * subscription + stream. Treat as derived, not identity-stable.
467
+ */
468
+ events: Accessor<ReadonlyArray<AgentToolEvent>>;
469
+ }
470
+ /**
471
+ * A focused view of a thread's tool activity: tool calls, their results,
472
+ * human-in-the-loop approval pauses, and live `ctx.reportProgress(...)` events —
473
+ * without the full chat message surface. The Solid counterpart to React's
474
+ * `useAgentToolEvents`, re-expressed as a memo.
475
+ *
476
+ * It composes the existing primitives rather than adding transport:
477
+ * `createSubscription(api.agents.agentMessages)` for the durable lifecycle and
478
+ * {@link createStream} over the optional app event stream for ephemeral progress.
479
+ * Progress events are live-only (the durable path never emits them): they ride
480
+ * the same sink as token deltas and are surfaced here, correlated to their tool
481
+ * call by `toolCallId`. For the conversational surface (messages + streaming text
482
+ * + approvals) use `createAgentChat`; this primitive is the tool-observability slice.
483
+ */
484
+ declare const createAgentToolEvents: (options: CreateAgentToolEventsOptions) => CreateAgentToolEventsResult;
485
+ /**
486
+ * Children accepted by this adapter's components.
487
+ *
488
+ * Structurally identical to Solid 2.0's `Element`, which is in turn a widening
489
+ * of 1.x's `JSX.Element` (a DOM `Node` satisfies `object` with no
490
+ * `call`/`apply`/`bind`). Children are contravariant, so one union that accepts
491
+ * both majors' element types is enough — no `any` required here.
492
+ */
493
+ type SolidChildren = SolidChildrenArray | boolean | null | number | (object & {
494
+ readonly apply?: never;
495
+ readonly bind?: never;
496
+ readonly call?: never;
497
+ }) | (string & {}) | undefined;
498
+ interface SolidChildrenArray extends Array<SolidChildren> {}
499
+ /**
500
+ * The return type of this adapter's components.
501
+ *
502
+ * Deliberately `any`, and the one place in the package where that is the right
503
+ * answer. TypeScript checks a component's return type against the *renderer's*
504
+ * `JSX.Element`, and the two majors define that incompatibly — 1.x's is rooted
505
+ * in the DOM `Node` interface, 2.0's in an opaque `RenderedElement`. Neither is
506
+ * assignable to the other, so no concrete type satisfies both, and a structural
507
+ * union (as used for {@link SolidChildren}) fails in the return position. `any`
508
+ * is what lets one set of `.d.ts` files type-check inside a 1.x app and a 2.x
509
+ * app alike.
510
+ */
511
+ type SolidElement = any;
24
512
  interface UseAuthResult {
25
513
  setToken: (token: string | null) => void;
26
514
  token: Accessor<string | null>;
27
515
  user: Accessor<User | null>;
28
516
  }
29
517
  /**
30
- * Token + identity plumbing for Solid. Returns `{ token, user, setToken }`
31
- * where `token` and `user` are fine-grained signals. `setToken(jwt)` after
32
- * sign-in updates the shared client token; `user` resolves asynchronously via
33
- * `client.getCurrentUser()` and updates on every token change.
34
- */
518
+ * Token + identity plumbing for Solid. Returns `{ token, user, setToken }`
519
+ * where `token` and `user` are fine-grained signals. `setToken(jwt)` after
520
+ * sign-in updates the shared client token; `user` resolves asynchronously via
521
+ * `client.getCurrentUser()` and updates on every token change.
522
+ */
35
523
  declare const createAuth: () => UseAuthResult;
36
524
  interface AuthGateProps {
37
- children: JSX.Element;
38
- }
39
- /**
40
- * Render `children` only after authentication has settled and a token + user
41
- * are both present.
42
- */
43
- declare const Authenticated: (props: AuthGateProps) => JSX.Element;
44
- /**
45
- * Render `children` while authentication is still in progress — token is set
46
- * but the user has not yet resolved.
47
- */
48
- declare const AuthLoading: (props: AuthGateProps) => JSX.Element;
49
- /**
50
- * Render `children` only when auth has settled and no token is present (the
51
- * signed-out state).
52
- */
53
- declare const Unauthenticated: (props: AuthGateProps) => JSX.Element;
54
- /**
55
- * Reactive accessor of the client's aggregate live-socket status across all
56
- * shard connections. Reads the current status synchronously and updates on
57
- * every transition (`idle` → `connecting` → `connected` → `offline`) — Solid's
58
- * fine-grained signals mean only the components that read the accessor
59
- * re-render. The Solid equivalent of `@lunora/react`'s `useConnectionStatus`.
60
- *
61
- * The status listener is torn down via `onCleanup` when the owning reactive
62
- * scope disposes (component unmount). Call inside a component / reactive root.
63
- */
525
+ children: SolidChildren;
526
+ }
527
+ /** An auth-gate component: renders its children only while the gate's condition holds. */
528
+ type AuthGate = (props: AuthGateProps) => SolidElement;
529
+ /**
530
+ * Render `children` only after authentication has settled and a token + user
531
+ * are both present.
532
+ */
533
+ declare const Authenticated: AuthGate;
534
+ /**
535
+ * Render `children` while authentication is still in progress — token is set
536
+ * but the user has not yet resolved.
537
+ */
538
+ declare const AuthLoading: AuthGate;
539
+ /**
540
+ * Render `children` only when auth has settled and no token is present (the
541
+ * signed-out state).
542
+ */
543
+ declare const Unauthenticated: AuthGate;
544
+ /**
545
+ * Reactive accessor of the client's aggregate live-socket status across all
546
+ * shard connections. Reads the current status synchronously and updates on
547
+ * every transition (`idle` → `connecting` → `connected` → `offline`) — Solid's
548
+ * fine-grained signals mean only the components that read the accessor
549
+ * re-render. The Solid equivalent of `@lunora/react`'s `useConnectionStatus`.
550
+ *
551
+ * The listener is registered at **mount**, not in the component body, because
552
+ * `onConnectionStatus` invokes it synchronously on subscribe: Solid 2 rejects a
553
+ * signal write inside an owned scope (`REACTIVE_WRITE_IN_OWNED_SCOPE`) and — since
554
+ * the throw escapes render — halts the reactive system for the whole page, not
555
+ * just this component. Nothing is missed by waiting: the initial value comes
556
+ * from `client.connectionStatus()`, and the immediate callback re-syncs at
557
+ * mount. Torn down when the owning scope disposes. Call inside a component /
558
+ * reactive root.
559
+ */
64
560
  declare const createConnectionStatus: () => Accessor<ConnectionStatus>;
561
+ /** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
562
+ type FlagValue = boolean | number | string | {
563
+ [key: string]: unknown;
564
+ } | unknown[] | null;
565
+ /**
566
+ * Subscribe to a single feature flag and return a reactive accessor of its value.
567
+ *
568
+ * The accessor reads `defaultValue` until the first evaluation lands, then the
569
+ * server's resolved value — re-pushed whenever the provider re-evaluates (e.g. a
570
+ * flag is toggled in Cloudflare Flagship). The flag's kind is inferred from
571
+ * `defaultValue`'s runtime type, so `createFlag("dark", false)` reads a boolean
572
+ * and `createFlag("hero", "control")` a string.
573
+ *
574
+ * `key` may be a plain value or an accessor; passing an accessor makes the
575
+ * subscription reactive — when it changes the old subscription is torn down (via
576
+ * `onCleanup`) and a fresh one opens.
577
+ *
578
+ * The reactive channel is public, so the server evaluates every flag under the
579
+ * socket's own verified identity — the targeting key your `defineFlags({
580
+ * identify })` derives — and accepts no client-supplied targeting context. For
581
+ * evaluation under a context you compute, call `ctx.flags.*` inside a query,
582
+ * mutation, or action and return the resolved value.
583
+ *
584
+ * Evaluation runs through whatever OpenFeature provider the app wired in
585
+ * `lunora/flags.ts`; the read never throws — a provider error resolves the
586
+ * default (the same fail-open contract as server-side `ctx.flags`).
587
+ */
588
+ declare const createFlag: <T extends FlagValue>(key: MaybeAccessor<string>, defaultValue: T) => Accessor<T>;
589
+ /**
590
+ * Subscribe to several feature flags at once and return a reactive accessor of
591
+ * the resolved record.
592
+ *
593
+ * Pass a record of `key → defaultValue`; each flag's kind is inferred from its
594
+ * default, and the accessor reads the same-shaped record with resolved values
595
+ * (the defaults until each evaluation lands). This is the batched form of
596
+ * {@link createFlag}, and evaluates under the socket's server-verified identity
597
+ * only. The flag set is fixed for the primitive's lifetime, so nothing here is
598
+ * reactive — the subscriptions open on mount and tear down on cleanup.
599
+ */
600
+ declare const createFlags: <T extends Record<string, FlagValue>>(flags: T) => Accessor<T>;
65
601
  interface MutationHandle<F extends FunctionReference> {
66
602
  /** The latest invocation's resolved value, or `undefined` before the first success. */
67
603
  data: Accessor<ReturnOf<F> | undefined>;
@@ -75,38 +611,75 @@ interface MutationHandle<F extends FunctionReference> {
75
611
  reset: () => void;
76
612
  }
77
613
  /**
78
- * The transport surface {@link createMutation} actually needs — just
79
- * `client.mutation`. Narrowed so the primitive can be exercised against a stub
80
- * in tests without constructing a full `LunoraClient`.
81
- */
614
+ * The transport surface {@link createMutation} actually needs — just
615
+ * `client.mutation`. Narrowed so the primitive can be exercised against a stub
616
+ * in tests without constructing a full `LunoraClient`.
617
+ */
82
618
  interface MutationClient<F extends FunctionReference> {
83
619
  mutation: (function_: F, args: ArgsOf<F>, options?: MutationCallOptions<unknown, unknown, ArgsOf<F>>) => Promise<ReturnOf<F>>;
84
620
  }
85
621
  /**
86
- * Build a mutation handle bound to an explicit client. Internal seam used by the
87
- * provider-bound {@link createMutation}; exported for tests that inject a stub.
88
- * The ref-counted pending + error-normalize orchestration is the shared
89
- * `createMutationRunner` from `@lunora/client`; only the reactive sinks (Solid
90
- * signals) are adapter-specific.
91
- */
622
+ * Build a mutation handle bound to an explicit client. Internal seam used by the
623
+ * provider-bound {@link createMutation}; exported for tests that inject a stub.
624
+ * The ref-counted pending + error-normalize orchestration is the shared
625
+ * `createCallRunner` from `@lunora/client`; only the reactive sinks (Solid
626
+ * signals) are adapter-specific.
627
+ *
628
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
629
+ * invocation (an earlier call settling later cannot clobber a newer one), a
630
+ * success clears `error`, and a failure leaves the previous `data` in place.
631
+ * `reset()` clears both; it does not cancel an in-flight call.
632
+ */
92
633
  declare const createMutationForClient: <F extends FunctionReference>(client: MutationClient<F>, function_: F) => MutationHandle<F>;
93
634
  /**
94
- * Returns a reactive handle `{ mutate, pending, data, error, reset }` for the
95
- * given mutation reference, bound to the `LunoraClient` from the nearest
96
- * `&lt;LunoraProvider>`.
97
- *
98
- * Optimistic updates stay client-owned: the `optimistic` / `optimisticUpdate`
99
- * call options pass straight through to `client.mutation`, which applies and
100
- * rolls them back against the live Lunora subscription cache — the same
101
- * machinery `createQuery`/`hydratePreloaded` subscribe to, so an optimistic
102
- * write reflects in those accessors immediately and reverts on failure.
103
- *
104
- * `pending` is ref-counted across overlapping invocations of *this* handle, so
105
- * it only flips back to `false` once every concurrent call has settled. The
106
- * mutation also engages `@lunora/client`'s offline queue when the socket is
107
- * down, so `mutate` stays durable across reconnects.
108
- */
635
+ * Returns a reactive handle `{ mutate, pending, data, error, reset }` for the
636
+ * given mutation reference, bound to the `LunoraClient` from the nearest
637
+ * `<LunoraProvider>`.
638
+ *
639
+ * Optimistic updates stay client-owned: the `optimistic` / `optimisticUpdate`
640
+ * call options pass straight through to `client.mutation`, which applies and
641
+ * rolls them back against the live Lunora subscription cache — the same
642
+ * machinery `createQuery`/`hydratePreloaded` subscribe to, so an optimistic
643
+ * write reflects in those accessors immediately and reverts on failure.
644
+ *
645
+ * `pending` is ref-counted across overlapping invocations of *this* handle, so
646
+ * it only flips back to `false` once every concurrent call has settled. The
647
+ * mutation also engages `@lunora/client`'s offline queue when the socket is
648
+ * down, so `mutate` stays durable across reconnects.
649
+ */
109
650
  declare const createMutation: <F extends FunctionReference>(function_: F) => MutationHandle<F>;
651
+ /**
652
+ * The reactive handle returned by {@link createMutator} — the Solid counterpart
653
+ * to `@lunora/react`'s `useMutator`, re-expressed with signals.
654
+ * `error`/`isError`/`pending` are accessors and `mutate` is an awaitable that
655
+ * resolves once the write is persisted (or rejects).
656
+ */
657
+ interface MutatorHook<TArgs> {
658
+ /** The latest invocation's error, or `undefined`. */
659
+ error: Accessor<Error | undefined>;
660
+ /** `true` when the latest invocation rejected. */
661
+ isError: Accessor<boolean>;
662
+ /** Run the mutator; resolves once the write is persisted, rejects on failure. */
663
+ mutate: (args: TArgs) => Promise<void>;
664
+ /** `true` while ANY invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
665
+ pending: Accessor<boolean>;
666
+ /** Clear the latest `error` back to idle. */
667
+ reset: () => void;
668
+ }
669
+ /**
670
+ * Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
671
+ * custom-mutator handle from `@lunora/db`'s `bindMutators` — the Solid
672
+ * equivalent of `@lunora/react`'s `useMutator`. The optimistic overlay and
673
+ * server-authoritative push are owned by the bound handle (and TanStack DB's
674
+ * optimistic-transaction layer rebases pending overlays on every sync tick);
675
+ * this primitive only surfaces signal state for the in-flight/error lifecycle.
676
+ * Reads stay on the existing TanStack `useLiveQuery`; no new query primitive is
677
+ * needed.
678
+ *
679
+ * `pending` is ref-counted across overlapping invocations of THIS handle, so it
680
+ * clears only once every concurrent call has settled.
681
+ */
682
+ declare const createMutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHook<TArgs>;
110
683
  /** The args a paginated query exposes minus the framework-supplied page cursor. */
111
684
  type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
112
685
  /** The element type of the `page` array a paginated query returns. */
@@ -116,9 +689,18 @@ type PageItemOf<F extends FunctionReference> = ReturnOf<F> extends {
116
689
  interface CreatePaginatedQueryOptions {
117
690
  /** Page size for the first page (and the default for `loadMore`). */
118
691
  initialNumItems: number;
692
+ /** Called when a page subscription reports an error (also surfaced on the `error` accessor). */
693
+ onError?: SubscriptionErrorCallback;
119
694
  shardKey?: string;
120
695
  }
121
696
  interface CreatePaginatedQueryResult<T> {
697
+ /**
698
+ * The last page subscription error, or `undefined`. A tail page that fails
699
+ * before its first frame is dropped so `status` returns to `"CanLoadMore"`
700
+ * and `loadMore` can retry it; cleared by the next successful frame,
701
+ * `loadMore`, or an args change.
702
+ */
703
+ error: Accessor<SubscriptionError | undefined>;
122
704
  /** `true` while the first page or a `loadMore` page is in flight. */
123
705
  isLoading: Accessor<boolean>;
124
706
  /** Request the next page. A no-op unless `status === "CanLoadMore"`. */
@@ -130,9 +712,13 @@ interface CreatePaginatedQueryResult<T> {
130
712
  interface CreateInfiniteQueryOptions {
131
713
  /** Page size for the first page (and the default for `fetchNextPage`). */
132
714
  initialNumItems: number;
715
+ /** Called when a page subscription reports an error (also surfaced on the `error` accessor). */
716
+ onError?: SubscriptionErrorCallback;
133
717
  shardKey?: string;
134
718
  }
135
719
  interface CreateInfiniteQueryResult<T> {
720
+ /** The last page subscription error, or `undefined` — see `CreatePaginatedQueryResult.error`. */
721
+ error: Accessor<SubscriptionError | undefined>;
136
722
  /** Request the next page. A no-op unless `status === "CanLoadMore"`. */
137
723
  fetchNextPage: (numberItems?: number) => void;
138
724
  /** `true` when the loaded tail reports it can load another page. */
@@ -146,46 +732,46 @@ interface CreateInfiniteQueryResult<T> {
146
732
  status: Accessor<PaginationStatus>;
147
733
  }
148
734
  /**
149
- * Subscribe to a reactively-paginated query and grow the feed page by page.
150
- *
151
- * The query function must accept a `paginationOpts: { numItems, cursor,
152
- * endCursor }` arg and return a `PaginationResult`. `loadMore` appends the next
153
- * page off the open-ended tail's `continueCursor`; it is a no-op unless
154
- * `status === "CanLoadMore"`.
155
- *
156
- * Call inside a reactive context (component / `createRoot`).
157
- */
735
+ * Subscribe to a reactively-paginated query and grow the feed page by page.
736
+ *
737
+ * The query function must accept a `paginationOpts: { numItems, cursor,
738
+ * endCursor }` arg and return a `PaginationResult`. `loadMore` appends the next
739
+ * page off the open-ended tail's `continueCursor`; it is a no-op unless
740
+ * `status === "CanLoadMore"`.
741
+ *
742
+ * Call inside a reactive context (component / `createRoot`).
743
+ */
158
744
  declare const createPaginatedQuery: <F extends FunctionReference>(function_: F, args: "skip" | Accessor<"skip" | PaginatedArgs<F>> | PaginatedArgs<F>, options: CreatePaginatedQueryOptions) => CreatePaginatedQueryResult<PageItemOf<F>>;
159
745
  /**
160
- * Subscribe to a reactively-paginated query and expose its pages discretely.
161
- *
162
- * Shares `createPaginatedQuery`'s pagination engine but keeps each page as its
163
- * own inner array (TanStack-Query-style `fetchNextPage` / `hasNextPage` shape).
164
- *
165
- * Call inside a reactive context (component / `createRoot`).
166
- */
746
+ * Subscribe to a reactively-paginated query and expose its pages discretely.
747
+ *
748
+ * Shares `createPaginatedQuery`'s pagination engine but keeps each page as its
749
+ * own inner array (TanStack-Query-style `fetchNextPage` / `hasNextPage` shape).
750
+ *
751
+ * Call inside a reactive context (component / `createRoot`).
752
+ */
167
753
  declare const createInfiniteQuery: <F extends FunctionReference>(function_: F, args: "skip" | Accessor<"skip" | PaginatedArgs<F>> | PaginatedArgs<F>, options: CreateInfiniteQueryOptions) => CreateInfiniteQueryResult<PageItemOf<F>>;
168
754
  /**
169
- * `createPresence` — collaborative-awareness primitive, the client half of the
170
- * `@lunora/server` `definePresence` preset.
171
- *
172
- * Drives the heartbeat mutation (on mount, interval, and tab re-focus) and
173
- * subscribes to the live `listPresent` query for the given room.
174
- *
175
- * Call inside a reactive context (component / `createRoot`).
176
- */
177
- /**
178
- * A heartbeat mutation reference: takes `{ roomId, sessionId, data? }`.
179
- */
755
+ * `createPresence` — collaborative-awareness primitive, the client half of the
756
+ * `@lunora/server` `definePresence` preset.
757
+ *
758
+ * Drives the heartbeat mutation (on mount, interval, and tab re-focus) and
759
+ * subscribes to the live `listPresent` query for the given room.
760
+ *
761
+ * Call inside a reactive context (component / `createRoot`).
762
+ */
763
+ /**
764
+ * A heartbeat mutation reference: takes `{ roomId, sessionId, data? }`.
765
+ */
180
766
  type HeartbeatReference = FunctionReference<"mutation", {
181
767
  data?: Record<string, unknown>;
182
768
  roomId: string;
183
769
  sessionId: string;
184
770
  }>;
185
771
  /**
186
- * A listPresent query reference: takes `{ roomId }` and returns the array of
187
- * present members.
188
- */
772
+ * A listPresent query reference: takes `{ roomId }` and returns the array of
773
+ * present members.
774
+ */
189
775
  type ListPresentReference = FunctionReference<"query", {
190
776
  roomId: string;
191
777
  }>;
@@ -199,14 +785,22 @@ interface CreatePresenceOptions<H extends HeartbeatReference, L extends ListPres
199
785
  /** The `api.*` reference for the presence listPresent query. */
200
786
  listPresent: L;
201
787
  /**
202
- * Stable id for this presence row. Defaults to a fresh per-mount id.
203
- * Pass a user/connection id to control deduping across tabs.
204
- */
788
+ * Called when the `listPresent` subscription reports an error (a session
789
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
790
+ * failure is invisible and `present` is cleared until a later frame arrives.
791
+ */
792
+ onError?: SubscriptionErrorCallback;
793
+ /**
794
+ * Stable id for this presence row. Defaults to a fresh per-mount id.
795
+ * Pass a user/connection id to control deduping across tabs.
796
+ */
205
797
  sessionId?: string;
206
798
  /** Forwarded to the heartbeat mutation / listPresent subscription when sharding by room. */
207
799
  shardKey?: string;
208
800
  }
209
801
  interface CreatePresenceResult<L extends ListPresentReference> {
802
+ /** The `listPresent` subscription's last error, or `undefined`. */
803
+ error: () => SubscriptionError | undefined;
210
804
  /** The present members for the room. `undefined` until the first push. */
211
805
  present: () => ReturnOf<L> | undefined;
212
806
  /** This mount's session id (generated when not supplied). */
@@ -216,35 +810,46 @@ interface CreatePresenceResult<L extends ListPresentReference> {
216
810
  }
217
811
  declare const createPresence: <H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: CreatePresenceOptions<H, L>) => CreatePresenceResult<L>;
218
812
  interface CreateQueryOptions {
813
+ /**
814
+ * Called when the server pushes a subscription-scoped error (an RLS denial, a
815
+ * query that starts failing server-side). Without a handler such an error has
816
+ * nowhere to go and the accessor simply freezes at its last good value.
817
+ */
818
+ onError?: SubscriptionErrorCallback;
219
819
  /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
220
820
  shardKey?: string;
221
821
  }
222
822
  /**
223
- * Subscribe to a server query and return a reactive accessor of its value.
224
- *
225
- * The accessor reads `undefined` until the first server frame lands, then
226
- * updates on every delta the WebSocket pushes — Solid's fine-grained signals
227
- * mean only the components that read the accessor re-render, which maps cleanly
228
- * onto Lunora's per-subscription delta model.
229
- *
230
- * `args` may be a plain value or an accessor; passing an accessor makes the
231
- * subscription reactive — when the args change the old subscription is torn down
232
- * (via `onCleanup`) and a fresh one opens for the new args. Pass `"skip"` (or an
233
- * accessor returning `"skip"`) to short-circuit: no network call, no socket.
234
- *
235
- * ```tsx
236
- * const messages = createQuery(api.messages.list, () => ({ channelId: channelId() }));
237
- * return &lt;For each={messages()?.messages}>{(m) => &lt;li>{m.text}&lt;/li>}&lt;/For>;
238
- * ```
239
- */
823
+ * Subscribe to a server query and return a reactive accessor of its value.
824
+ *
825
+ * The accessor reads `undefined` until the first server frame lands, then
826
+ * updates on every delta the WebSocket pushes — Solid's fine-grained signals
827
+ * mean only the components that read the accessor re-render, which maps cleanly
828
+ * onto Lunora's per-subscription delta model.
829
+ *
830
+ * `args` may be a plain value or an accessor; passing an accessor makes the
831
+ * subscription reactive — when the args change the old subscription is torn down
832
+ * (via `onCleanup`), the accessor resets to `undefined`, and a fresh one opens for
833
+ * the new args. Pass `"skip"` (or an
834
+ * accessor returning `"skip"`) to short-circuit: no network call, no socket.
835
+ *
836
+ * ```tsx
837
+ * const messages = createQuery(api.messages.list, () => ({ channelId: channelId() }));
838
+ * return <For each={messages()?.messages}>{(m) => <li>{m.text}</li>}</For>;
839
+ * ```
840
+ *
841
+ * Pass `onError` to surface a subscription-scoped error the server pushes (an RLS
842
+ * denial, a query that starts failing server-side). Without it such an error is
843
+ * dropped and the accessor just freezes at its last good value.
844
+ */
240
845
  declare const createQuery: <F extends FunctionReference>(function_: F, args: (ArgsOf<F> | "skip") | Accessor<ArgsOf<F> | "skip">, options?: CreateQueryOptions) => Accessor<ReturnOf<F> | undefined>;
241
846
  interface CreateRateLimitOptions {
242
847
  /** Clock injection for tests. Defaults to `Date.now`. */
243
848
  now?: () => number;
244
849
  /**
245
- * Re-evaluation cadence in milliseconds while throttled, so `retryAfter`
246
- * ticks down and `disabled` flips back automatically. Defaults to `1000`.
247
- */
850
+ * Re-evaluation cadence in milliseconds while throttled, so `retryAfter`
851
+ * ticks down and `disabled` flips back automatically. Defaults to `1000`.
852
+ */
248
853
  tickMs?: number;
249
854
  }
250
855
  interface CreateRateLimitResult {
@@ -262,78 +867,314 @@ interface CreateRateLimitResult {
262
867
  retryAfter: () => number;
263
868
  }
264
869
  /**
265
- * Client-side mirror of a rate limit for instant UX — disable a button or show
266
- * a countdown without a round-trip. It runs the same token-bucket / fixed-window
267
- * math as `@lunora/ratelimit` on the server, so the prediction agrees with the
268
- * authoritative check; the server remains the source of truth.
269
- *
270
- * `config` is read on every call; pass a stable reference (module constant) so
271
- * the derived memos stay settled.
272
- */
870
+ * Client-side mirror of a rate limit for instant UX — disable a button or show
871
+ * a countdown without a round-trip. It runs the same token-bucket / fixed-window
872
+ * math as `@lunora/ratelimit` on the server, so the prediction agrees with the
873
+ * authoritative check; the server remains the source of truth.
874
+ *
875
+ * `config` is read on every call; pass a stable reference (module constant) so
876
+ * the derived memos stay settled.
877
+ */
273
878
  declare const createRateLimit: (config: RateLimitConfig, options?: CreateRateLimitOptions) => CreateRateLimitResult;
879
+ /** The lifecycle of a stream the primitive is observing. */
880
+ type CreateStreamStatus = "complete" | "error" | "idle" | "streaming";
881
+ interface CreateStreamResult<T> {
882
+ /** Force-cancel the stream and resolve the iterator. Safe to call multiple times. */
883
+ cancel: () => void;
884
+ /** Chunks the server has pushed so far, in arrival order. */
885
+ chunks: Accessor<ReadonlyArray<T>>;
886
+ error: Accessor<Error | undefined>;
887
+ status: Accessor<CreateStreamStatus>;
888
+ }
889
+ interface CreateStreamOptions {
890
+ /**
891
+ * Opt into resume-on-reconnect for a stream the server declared `durable`.
892
+ * The chunks already received are kept and the socket re-attaches to the same
893
+ * run, so a dropped connection mid-generation continues instead of surfacing
894
+ * `STREAM_DISCONNECTED`. Has no effect on an ephemeral stream.
895
+ */
896
+ durable?: boolean;
897
+ /** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
898
+ maxBuffer?: number;
899
+ shardKey?: string;
900
+ }
901
+ /**
902
+ * Subscribe to a streaming query. Returns the chunks pushed so far plus a
903
+ * lifecycle status and a cancel function, all as accessors. Changing the
904
+ * resolved `args` resets the stream — the previous iterator is cancelled and a
905
+ * fresh one opens with empty `chunks`.
906
+ *
907
+ * `args` may be a plain value or an accessor; resolving it to `"skip"` keeps the
908
+ * primitive mounted without opening a stream (mirrors `createSubscription`). The
909
+ * Solid counterpart to React's `useStream`, re-expressed with signals.
910
+ */
911
+ declare const createStream: <F extends FunctionReference<"stream">>(function_: F, args: ArgsOf<F> | "skip" | Accessor<ArgsOf<F> | "skip">, options?: CreateStreamOptions) => CreateStreamResult<ReturnOf<F>>;
274
912
  interface CreateSubscriptionResult<T> {
275
913
  data: Accessor<T | undefined>;
276
914
  error: Accessor<Error | undefined>;
277
915
  }
278
916
  /**
279
- * Subscribe to a reactive server push stream. Returns `{ data, error }`
280
- * accessors that update whenever the server emits. Passing `"skip"` as `args`
281
- * (or an accessor that resolves to `"skip"`) tears down the subscription.
282
- */
917
+ * Subscribe to a reactive server push stream. Returns `{ data, error }`
918
+ * accessors that update whenever the server emits. Passing `"skip"` as `args`
919
+ * (or an accessor that resolves to `"skip"`) tears down the subscription.
920
+ *
921
+ * `onError` mirrors the other adapters' subscription primitives: it receives the
922
+ * raw wire-level subscription error (code included) alongside the normalised
923
+ * `error` accessor.
924
+ */
283
925
  declare const createSubscription: <F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip" | Accessor<ArgsOf<F> | "skip">, options?: {
926
+ onError?: SubscriptionErrorCallback;
284
927
  shardKey?: string;
285
928
  }) => CreateSubscriptionResult<ReturnOf<F>>;
286
929
  /**
287
- * Hydrate a query from a {@link Preloaded} token produced by `preloadQuery`
288
- * during SSR, then keep it live.
289
- *
290
- * This is the client half of PLAN4's "your loaders are live" handoff. The
291
- * returned accessor is seeded **synchronously** from `preloaded.value`, so the
292
- * very first read — during hydration — returns the server-rendered value with
293
- * no loading flash and no `Suspense` fallback (unlike `createResource`, which
294
- * always starts pending). After the component mounts, a WebSocket subscription
295
- * attaches in an effect and every subsequent server delta flows into the same
296
- * signal, so the UI goes live with zero refetch.
297
- *
298
- * ```tsx
299
- * // route loader (server): const preloaded = await preloadQuery(client, api.messages.list, args);
300
- * const messages = hydratePreloaded(preloaded); // seeded from SSR, then live
301
- * return &lt;pre>{JSON.stringify(messages())}&lt;/pre>;
302
- * ```
303
- *
304
- * Effects do not run on the server during SSR (Solid only runs them after
305
- * hydration), so the subscription is strictly client-side — the seed is the
306
- * only value the server render ever sees.
307
- */
308
- declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Accessor<T>;
930
+ * Browser Web Audio subsystems for `createVoiceAgent` — the default microphone
931
+ * capture and speaker playback implementations injected into the primitive via
932
+ * its `createMicrophone` / `createSpeaker` seams. Kept in a sibling module so the
933
+ * heavy Web Audio graph (and its structural DOM typings) stays isolated from the
934
+ * primitive's transport + reactive-state logic and remains mockable in a
935
+ * non-browser test env.
936
+ */
937
+ /**
938
+ * The negotiated audio format the voice DO streams back. Mirrors
939
+ * `@lunora/agent`'s `VoiceServerFrame` `ready.audioFormat` — re-declared (not
940
+ * imported) so this Solid package never pulls in the server-only `@lunora/agent`
941
+ * module graph.
942
+ */
943
+ type VoiceAudioFormat = "mp3" | "wav";
944
+ /** Captures microphone audio and reports level / turn boundaries back to the primitive. */
945
+ interface VoiceMicrophone {
946
+ /** Mute/unmute the mic without tearing down the capture graph. */
947
+ setMuted: (muted: boolean) => void;
948
+ /** Stop capture and release the media stream + audio graph. */
949
+ stop: () => void;
950
+ }
951
+ /** Plays the server's streamed audio chunks and supports a mid-utterance barge-in. */
952
+ interface VoiceSpeaker {
953
+ /** Queue a decoded audio chunk for gap-minimized playback. */
954
+ enqueue: (audio: Uint8Array) => void;
955
+ /** Drop everything queued and stop the current chunk (barge-in). */
956
+ interrupt: () => void;
957
+ /** Release the playback audio context. */
958
+ stop: () => void;
959
+ }
960
+ /** Config passed to a {@link CreateMicrophone} factory. */
961
+ interface MicrophoneConfig {
962
+ /** The consecutive above-threshold chunk count that counts as a barge-in. */
963
+ interruptChunks: number;
964
+ /** RMS above which the user is considered to be barging in while the agent speaks. */
965
+ interruptThreshold: number;
966
+ /**
967
+ * `true` from the moment a turn is committed until it completes — the whole
968
+ * `thinking` + `speaking` window, not just the audible half.
969
+ *
970
+ * It gates BOTH branches below, and the wider span is the point. Gated only
971
+ * on "audibly speaking", turn detection kept running through the entire
972
+ * STT+LLM window after a `commit`: room noise at the (deliberately low)
973
+ * `silenceThreshold` re-armed `sawSpeech`, another quiet gap fired a SECOND
974
+ * `commit`, and the DO refused it with "a turn is already in progress" —
975
+ * a refusal that returns before draining the audio buffer, so the PCM
976
+ * captured since the first commit leaked into the next utterance.
977
+ *
978
+ * A genuine barge-in still works in that window: it routes through the
979
+ * `onInterrupt` branch, which needs `interruptChunks` consecutive chunks at
980
+ * `interruptThreshold` — an order of magnitude above `silenceThreshold` —
981
+ * and `interrupt` is exactly what the DO tells the client to send.
982
+ */
983
+ isTurnActive: () => boolean;
984
+ /** One 16 kHz mono 16-bit little-endian PCM frame captured from the mic. */
985
+ onAudio: (pcm: Uint8Array) => void;
986
+ /** A barge-in was detected (RMS spike while the agent is speaking). */
987
+ onInterrupt: () => void;
988
+ /** The current input RMS (0–1), for a level meter. */
989
+ onLevel: (rms: number) => void;
990
+ /** A spoken utterance ended (speech followed by `silenceDurationMs` of silence). */
991
+ onSilence: () => void;
992
+ /** Milliseconds of sub-threshold audio (after speech) that closes an utterance. */
993
+ silenceDurationMs: number;
994
+ /** RMS below which audio counts as silence. */
995
+ silenceThreshold: number;
996
+ }
997
+ type CreateMicrophone = (config: MicrophoneConfig) => Promise<VoiceMicrophone>;
998
+ type CreateSpeaker = (config: {
999
+ audioFormat: VoiceAudioFormat;
1000
+ }) => VoiceSpeaker;
1001
+ /**
1002
+ * The `agents.<name>Voice` reference codegen emits for a voice-enabled agent — a
1003
+ * live, WS-backed session keyed by `threadKey`. A structural subset of the
1004
+ * generated member, so passing `api.agents.<name>Voice` type-checks.
1005
+ */
1006
+ type VoiceReference = FunctionReference<"stream", {
1007
+ threadKey: string;
1008
+ }, Record<string, unknown>>;
1009
+ /** The lifecycle of a voice call, mirrored to the UI. */
1010
+ type VoiceStatus = "idle" | "listening" | "speaking" | "thinking";
1011
+ /** A minimal structural subset of the DOM `WebSocket` the primitive drives. */
1012
+ interface VoiceSocket {
1013
+ binaryType: string;
1014
+ close: () => void;
1015
+ onclose: ((event: unknown) => void) | null;
1016
+ onerror: ((event: unknown) => void) | null;
1017
+ onmessage: ((event: {
1018
+ data: unknown;
1019
+ }) => void) | null;
1020
+ onopen: ((event: unknown) => void) | null;
1021
+ readonly readyState: number;
1022
+ send: (data: ArrayBufferView | ArrayBufferLike | string) => void;
1023
+ }
1024
+ type CreateSocket = (url: string) => VoiceSocket;
1025
+ interface CreateVoiceAgentOptions {
1026
+ /**
1027
+ * Advanced/test seam: build the microphone capture subsystem. Defaults to a
1028
+ * `getUserMedia` + Web Audio implementation. Injected wholesale so the Web
1029
+ * Audio graph stays isolated (and mockable in a non-browser test env).
1030
+ */
1031
+ createMicrophone?: CreateMicrophone;
1032
+ /**
1033
+ * Advanced/test seam: open the transport. Defaults to the WebSocket
1034
+ * implementation the client was built with (`client.getWebSocketImpl()`),
1035
+ * NOT a raw `globalThis.WebSocket`.
1036
+ */
1037
+ createSocket?: CreateSocket;
1038
+ /** Advanced/test seam: build the audio playback subsystem. Defaults to a Web Audio implementation. */
1039
+ createSpeaker?: CreateSpeaker;
1040
+ /** Consecutive above-`interruptThreshold` chunks that trigger a barge-in. Default `3`. */
1041
+ interruptChunks?: number;
1042
+ /** Input RMS above which the user is treated as barging in while the agent speaks. Default `0.15`. */
1043
+ interruptThreshold?: number;
1044
+ /** Milliseconds of silence (after speech) that auto-commits an utterance. Default `1200`. */
1045
+ silenceDurationMs?: number;
1046
+ /** Input RMS below which audio counts as silence. Default `0.01`. */
1047
+ silenceThreshold?: number;
1048
+ /** The thread to converse on — shared with the agent's text turns. May be a plain value or accessor (resolved when the call opens). */
1049
+ threadKey: MaybeAccessor<string>;
1050
+ /** The generated `api.agents.<name>Voice` reference — identifies the voice DO endpoint. */
1051
+ voice: VoiceReference;
1052
+ }
1053
+ interface CreateVoiceAgentResult {
1054
+ /** The current input RMS (0–1) — drive a mic level meter. */
1055
+ audioLevel: Accessor<number>;
1056
+ /** `true` once the WS `ready` handshake completed. */
1057
+ connected: Accessor<boolean>;
1058
+ /** Tear down the call: close the socket, stop the mic, release audio. Idempotent. */
1059
+ endCall: () => void;
1060
+ /** The last transport/pipeline error, or `undefined`. */
1061
+ error: Accessor<Error | undefined>;
1062
+ /** The live assistant text for the in-flight turn (grows via deltas; finalized on done). */
1063
+ interimTranscript: Accessor<string>;
1064
+ /** `true` while the mic is muted. */
1065
+ isMuted: Accessor<boolean>;
1066
+ /** Send a typed turn (no audio) — a text message spoken back by the agent. */
1067
+ sendText: (text: string) => void;
1068
+ /** Open the mic, connect the socket, and start the conversation. Idempotent while active. */
1069
+ startCall: () => Promise<void>;
1070
+ /** The current call lifecycle. */
1071
+ status: Accessor<VoiceStatus>;
1072
+ /** Mute/unmute the microphone. Returns the new muted state. */
1073
+ toggleMute: () => boolean;
1074
+ /** The last finalized user utterance (STT result). */
1075
+ transcript: Accessor<string>;
1076
+ }
1077
+ /**
1078
+ * A first-class voice-call surface for a voice-enabled agent: it opens a
1079
+ * WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
1080
+ * streams the agent's synthesized speech back through the browser's audio output,
1081
+ * and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
1082
+ * `audioLevel`) to Solid signals. Pass the generated `api.agents.<name>Voice`
1083
+ * reference (never a string), matching `createAgentChat`'s reference-passing style.
1084
+ * The Solid counterpart to React's `useVoiceAgent`, re-expressed with signals; the
1085
+ * per-call connection lives in a closure variable (a primitive runs once per
1086
+ * component, so no signal-of-signal indirection is needed).
1087
+ *
1088
+ * v1 transport is plain binary WebSocket frames with push-to-talk / silence-timer
1089
+ * turn detection and client-side RMS barge-in. The heavy Web Audio capture and
1090
+ * playback subsystems are injectable (`createMicrophone` / `createSpeaker` /
1091
+ * `createSocket`) so the primitive is drivable outside a browser.
1092
+ */
1093
+ declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoiceAgentResult;
1094
+ /**
1095
+ * Hydrate a query from a {@link Preloaded} token produced by `preloadQuery`
1096
+ * during SSR, then keep it live.
1097
+ *
1098
+ * This is the client half of PLAN4's "your loaders are live" handoff. The
1099
+ * returned accessor is seeded **synchronously** from `preloaded.value`, so the
1100
+ * very first read — during hydration — returns the server-rendered value with
1101
+ * no loading flash and no `Suspense` fallback (unlike `createResource`, which
1102
+ * always starts pending). Once the component mounts, a WebSocket subscription
1103
+ * attaches and every subsequent server delta flows into the same signal, so the
1104
+ * UI goes live with zero refetch.
1105
+ *
1106
+ * ```tsx
1107
+ * // route loader (server): const preloaded = await preloadQuery(client, api.messages.list, args);
1108
+ * const messages = hydratePreloaded(preloaded); // seeded from SSR, then live
1109
+ * return <pre>{JSON.stringify(messages())}</pre>;
1110
+ * ```
1111
+ *
1112
+ * Mount callbacks do not run on the server during SSR (both Solid majors defer
1113
+ * them until after hydration), so the subscription is strictly client-side —
1114
+ * the seed is the only value the server render ever sees.
1115
+ *
1116
+ * Pass `onError` to surface a subscription-scoped error the server pushes (a
1117
+ * session expiry, an RLS denial). Without it such an error is dropped and the
1118
+ * accessor keeps rendering the SSR snapshot as if it were live.
1119
+ */
1120
+ declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, options?: {
1121
+ onError?: SubscriptionErrorCallback;
1122
+ }) => Accessor<T>;
309
1123
  interface LunoraProviderProps {
310
- children: JSX.Element;
1124
+ children: SolidChildren;
311
1125
  /**
312
- * The framework-neutral transport. Build it once at the app root with
313
- * `new LunoraClient({ url })` (or `createServerClient` during SSR) and pass
314
- * it here — the provider does not own its lifecycle, so the same instance
315
- * survives across route navigations.
316
- */
1126
+ * The framework-neutral transport. Build it once at the app root with
1127
+ * `new LunoraClient({ url })` (or `createServerClient` during SSR) and pass
1128
+ * it here — the provider does not own its lifecycle, so the same instance
1129
+ * survives across route navigations.
1130
+ */
317
1131
  client: LunoraClient;
318
1132
  }
319
1133
  /**
320
- * Provides a {@link LunoraClient} to the Solid tree via {@link LunoraContext}.
321
- *
322
- * Solid's context is reactive-graph scoped rather than render scoped, so unlike
323
- * the React provider there is no QueryClient to detect or lazily create — the
324
- * adapter's reactive primitives (`createQuery`, `createMutation`,
325
- * `hydratePreloaded`) own their own signals and read the client straight from
326
- * context. Drop one of these at the root of your app:
327
- *
328
- * ```tsx
329
- * const client = new LunoraClient({ url: window.location.origin });
330
- *
331
- * render(() => (
332
- * &lt;LunoraProvider client={client}>
333
- * &lt;App />
334
- * &lt;/LunoraProvider>
335
- * ), root);
336
- * ```
337
- */
338
- declare const LunoraProvider: (props: LunoraProviderProps) => JSX.Element;
339
- export { AuthLoading, Authenticated, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateSubscriptionResult, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider, type LunoraProviderProps, type MutationClient, type MutationHandle, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, createAuth, createConnectionStatus, createInfiniteQuery, createMutation, createMutationForClient, createPaginatedQuery, createPresence, createQuery, createRateLimit, createSubscription, hydratePreloaded, useLunora };
1134
+ * Provides a {@link LunoraClient} to the Solid tree via {@link LunoraContext}.
1135
+ *
1136
+ * Solid's context is reactive-graph scoped rather than render scoped, so unlike
1137
+ * the React provider there is no QueryClient to detect or lazily create — the
1138
+ * adapter's reactive primitives (`createQuery`, `createMutation`,
1139
+ * `hydratePreloaded`) own their own signals and read the client straight from
1140
+ * context. Drop one of these at the root of your app:
1141
+ *
1142
+ * ```tsx
1143
+ * const client = new LunoraClient({ url: window.location.origin });
1144
+ *
1145
+ * render(() => (
1146
+ * <LunoraProvider client={client}>
1147
+ * <App />
1148
+ * </LunoraProvider>
1149
+ * ), root);
1150
+ * ```
1151
+ *
1152
+ * Written with `createComponent` rather than JSX on purpose. Solid 1.x and 2.0
1153
+ * compile JSX against different runtimes (`solid-js/web` vs `@solidjs/web`), so
1154
+ * a JSX source file would force this package to ship two builds; `createComponent`
1155
+ * is exported from the `solid-js` root in both majors, and the provider component
1156
+ * itself is resolved per-major by {@link providerOf}. The `get` accessors keep
1157
+ * both props lazy, so swapping the `client` prop re-provides the new value to
1158
+ * descendants exactly as the JSX form did.
1159
+ */
1160
+ declare const LunoraProvider: (props: LunoraProviderProps) => SolidElement;
1161
+ export { type ActionClient, type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type CreateAgentApi, type CreateAgentChatApi, type CreateAgentChatOptions, type CreateAgentChatResult, type CreateAgentOptions, type CreateAgentResult, type CreateAgentStateApi, type CreateAgentStateOptions, type CreateAgentStateResult, type CreateAgentToolEventsApi, type CreateAgentToolEventsOptions, type CreateAgentToolEventsResult, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateStreamOptions, type CreateStreamResult, type CreateStreamStatus, type CreateSubscriptionResult, type CreateVoiceAgentOptions, type CreateVoiceAgentResult, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider,
1162
+ /**
1163
+ * SolidJS adapter for Lunora.
1164
+ *
1165
+ * Thin, idiomatic glue over the framework-neutral `@lunora/client`. Solid's
1166
+ * fine-grained signals map directly onto Lunora's per-subscription deltas, so a
1167
+ * live query is just a signal the WebSocket writes to. The adapter exposes
1168
+ * `LunoraProvider` / `useLunora` (context carrying the `LunoraClient`),
1169
+ * `createQuery` (a live query accessor that opens a subscription and updates on
1170
+ * every delta), `createMutation` (an optimistic mutation handle), and
1171
+ * `hydratePreloaded` (seed a query from an SSR `Preloaded` token synchronously —
1172
+ * no loading flash — then attach the live subscription; the client half of
1173
+ * PLAN4's "your loaders are live" reactive-loader handoff).
1174
+ *
1175
+ * Server-side preloading (`createServerClient`, `preloadQuery`) lives in the
1176
+ * socket-free `@lunora/solid/server` entry (a re-export of `@lunora/client/ssr`, the
1177
+ * framework-neutral server contract) — call it from your SolidStart route loader
1178
+ * and hand the resulting `Preloaded` token to `hydratePreloaded`.
1179
+ */
1180
+ type LunoraProviderProps, type MutationClient, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, type SolidChildren, Unauthenticated, type UseAuthResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, createAction, createActionForClient, createAgent, createAgentChat, createAgentState, createAgentToolEvents, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createMutator, createPaginatedQuery, createPresence, createQuery, createRateLimit, createStream, createSubscription, createVoiceAgent, hydratePreloaded, useLunora };