@lunora/svelte 1.0.0-alpha.9 → 1.0.0-alpha.91

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 (46) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +2 -0
  3. package/dist/index.d.mts +1013 -173
  4. package/dist/index.d.ts +1013 -173
  5. package/dist/index.mjs +1 -10
  6. package/dist/packem_shared/action-SjeZUGhX.mjs +1 -0
  7. package/dist/packem_shared/agent-CFzp-ncV.mjs +1 -0
  8. package/dist/packem_shared/agentChat-BhMVjqq4.mjs +1 -0
  9. package/dist/packem_shared/agentState-at2Rg_Q9.mjs +1 -0
  10. package/dist/packem_shared/agentToolEvents-BrybzNXi.mjs +1 -0
  11. package/dist/packem_shared/auth-Bew4W5n1.mjs +1 -0
  12. package/dist/packem_shared/connectionStatus-D9A79Eqw.mjs +1 -0
  13. package/dist/packem_shared/flag-DmEKEmb9.mjs +1 -0
  14. package/dist/packem_shared/getLunoraClient-DU7BmZy1.mjs +1 -0
  15. package/dist/packem_shared/hydratePreloaded-CW7Ak8zY.mjs +1 -0
  16. package/dist/packem_shared/infiniteQuery-S4ETxAi1.mjs +1 -0
  17. package/dist/packem_shared/is-browser-BEdfLJHK.mjs +1 -0
  18. package/dist/packem_shared/is-function-reference-abFdrAae.mjs +1 -0
  19. package/dist/packem_shared/mutation-DLBr5Op1.mjs +1 -0
  20. package/dist/packem_shared/mutator-DECDuo94.mjs +1 -0
  21. package/dist/packem_shared/presence-I_W9Zbhg.mjs +1 -0
  22. package/dist/packem_shared/query-aWSTFtNz.mjs +1 -0
  23. package/dist/packem_shared/rateLimit-Cli38qWO.mjs +1 -0
  24. package/dist/packem_shared/stream-eY1eAuVw.mjs +1 -0
  25. package/dist/packem_shared/subscribe-reactive-args-DYKqoWhw.mjs +1 -0
  26. package/dist/packem_shared/subscription-3foboeMU.mjs +1 -0
  27. package/dist/packem_shared/voiceAgent-odCezdLl.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 +8 -7
  33. package/dist/packem_shared/auth-DLPf_bK9.mjs +0 -28
  34. package/dist/packem_shared/connectionStatus-CRsOMeYl.mjs +0 -14
  35. package/dist/packem_shared/getLunoraClient--bwSz7F6.mjs +0 -16
  36. package/dist/packem_shared/hydratePreloaded-D5rUJdXy.mjs +0 -21
  37. package/dist/packem_shared/infiniteQuery-jPMQw8Vz.mjs +0 -196
  38. package/dist/packem_shared/is-function-reference-ycLAcI79.mjs +0 -3
  39. package/dist/packem_shared/mutation-CnDkAaLH.mjs +0 -31
  40. package/dist/packem_shared/presence-BQWixJ2T.mjs +0 -66
  41. package/dist/packem_shared/query-D8Pct9Qe.mjs +0 -36
  42. package/dist/packem_shared/rateLimit-Cdw1kp8t.mjs +0 -66
  43. package/dist/packem_shared/subscription-twuBT_Wb.mjs +0 -46
  44. package/dist/worker.d.mts +0 -1
  45. package/dist/worker.d.ts +0 -1
  46. package/dist/worker.mjs +0 -1
package/dist/index.d.ts CHANGED
@@ -1,29 +1,506 @@
1
- import { LunoraClient, User, ConnectionStatus, Preloaded, FunctionReference, ReturnOf, ArgsOf, MutationCallOptions, SubscriptionErrorCallback } from '@lunora/client';
2
- export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, MutationCallOptions, Preloaded, ReturnOf } from '@lunora/client';
1
+ import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, User, ConnectionStatus, Preloaded, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback } from '@lunora/client';
2
+ export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, Preloaded, ReturnOf } from '@lunora/client';
3
3
  import { Readable } from 'svelte/store';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
6
6
  /**
7
- * Publish a {@link LunoraClient} on the Svelte component context so that
8
- * descendant components can read it with {@link getLunoraClient} (or implicitly,
9
- * via the default-client lookups inside `query`/`mutation`/`hydratePreloaded`).
10
- *
11
- * Call this once, high in the tree (typically your root `+layout.svelte` or
12
- * `App.svelte`), during component initialisation — `setContext` must run while
13
- * the component is being constructed, exactly like React's provider mounts once.
14
- * This is the Svelte analogue of mounting `LunoraProvider`.
15
- */
7
+ * The reactive handle returned by {@link action} — the Svelte counterpart to
8
+ * React's `useAction`, re-expressed as stores you read with `$`. The surface is
9
+ * identical across the Lunora adapters (`@lunora/solid`, `/vue`).
10
+ */
11
+ interface ActionHandle<F extends FunctionReference> {
12
+ /**
13
+ * Run the action. Resolves with the server result and rejects on failure
14
+ * (errors propagate — there is no swallowing).
15
+ */
16
+ call: (args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
17
+ /** The latest invocation's resolved value, or `undefined` before the first success. */
18
+ data: Readable<ReturnOf<F> | undefined>;
19
+ /** The latest invocation's error, or `undefined`. */
20
+ error: Readable<Error | undefined>;
21
+ /**
22
+ * `true` while any invocation from this handle is in flight. Ref-counted, so
23
+ * overlapping calls compose and it only flips back to `false` once the last
24
+ * one settles. Read it with `$pending` in a component to disable a button.
25
+ */
26
+ pending: Readable<boolean>;
27
+ /** Clear `data`/`error` back to idle. */
28
+ reset: () => void;
29
+ }
30
+ /**
31
+ * Create an {@link ActionHandle} for an action reference. The Svelte
32
+ * counterpart to React's `useAction`: returns `{ data, error, pending, call,
33
+ * reset }` of readable stores plus an awaitable `call`.
34
+ *
35
+ * **Narrower than `mutation` on purpose:** no `optimistic` /
36
+ * `optimisticUpdate`. An optimistic update patches the subscription cache on the
37
+ * assumption a write will land; an action is not a write — it runs in the
38
+ * Worker, may call a third party, and has no declared effect on any query.
39
+ *
40
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
41
+ * invocation (an earlier call settling later cannot clobber a newer one), a
42
+ * success clears `error`, and a failure leaves the previous `data` in place.
43
+ * `reset()` clears both; it does not cancel an in-flight call.
44
+ *
45
+ * Pass `client` explicitly, or omit it to resolve the ambient client published
46
+ * by `setLunoraClient`.
47
+ */
48
+ declare function action<F extends FunctionReference>(function_: F): ActionHandle<F>;
49
+ declare function action<F extends FunctionReference>(client: LunoraClient, function_: F): ActionHandle<F>;
50
+ /**
51
+ * The lifecycle status stored on an agent thread. Client-safe mirror of
52
+ * `@lunora/agent`'s `AgentThreadStatus` — re-declared here (rather than imported)
53
+ * so this Svelte entry never pulls in the server-only `@lunora/agent` module graph
54
+ * (the adapter stays Svelte + `@lunora/client` only). Keep in sync with
55
+ * `packages/agent/src/types.ts`.
56
+ */
57
+ type AgentThreadStatus = "awaiting_input" | "cancelled" | "error" | "idle" | "running";
58
+ /**
59
+ * The live thread record surfaced by the `agents:agentThread` query. A structural
60
+ * subset of the persisted thread row — every field beyond `status` is optional so
61
+ * the shape stays forgiving as the server schema grows. Keep in sync with the
62
+ * `agent_threads` table in `packages/agent/src/component.ts`.
63
+ */
64
+ interface AgentThreadRecord {
65
+ createdAt?: number;
66
+ /** The failure message when `status === "error"`. */
67
+ error?: string;
68
+ /** The workflow instance id of the in-flight run — the handle `cancel` targets. */
69
+ instanceId?: string;
70
+ messageCount?: number;
71
+ /** The verified thread owner, when the run was started with one. */
72
+ owner?: string;
73
+ status: AgentThreadStatus;
74
+ title?: string;
75
+ updatedAt?: number;
76
+ }
77
+ /**
78
+ * The `agents.agentThread` reference the handle subscribes to for live thread
79
+ * state (status + the in-flight `instanceId`). A structural subset of the
80
+ * generated `api.agents` surface, so the whole generated `api` object is
81
+ * assignable.
82
+ */
83
+ interface AgentApi {
84
+ agents: {
85
+ agentThread: FunctionReference<"query", {
86
+ key: string;
87
+ }, Record<string, unknown> | undefined>;
88
+ };
89
+ }
90
+ interface AgentOptions {
91
+ /** The generated `api` — its `agents.agentThread` query drives live thread state. */
92
+ api: AgentApi;
93
+ /**
94
+ * Optional app mutation over the agent's cancel path
95
+ * (`ctx.agents[name].cancel(id)`). Called with `{ instanceId, threadKey }`.
96
+ * When omitted (or no run is in flight) {@link AgentHandle.cancel} is a no-op.
97
+ */
98
+ cancel?: FunctionReference<"mutation">;
99
+ /**
100
+ * The app mutation that starts (or continues) a run — a thin wrapper over
101
+ * `ctx.agents[name].run(...)`. Called with `{ threadKey, input }` merged with
102
+ * {@link AgentOptions.runArgs} and the per-call args.
103
+ */
104
+ run: FunctionReference<"mutation">;
105
+ /** Extra args merged into every `run` call (e.g. an `owner` or `title`). */
106
+ runArgs?: Record<string, unknown>;
107
+ /** The thread to observe and drive. */
108
+ threadKey: string;
109
+ }
110
+ interface AgentHandle {
111
+ /**
112
+ * Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
113
+ * no-op when no `cancel` mutation was supplied or no run is in flight.
114
+ */
115
+ cancel: () => Promise<void>;
116
+ /** `true` while a `run` invocation is in flight. Read with `$pending`. */
117
+ pending: Readable<boolean>;
118
+ /** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
119
+ run: (input: string, args?: Record<string, unknown>) => Promise<void>;
120
+ /** The live thread status, or `undefined` before the thread exists. Read with `$status`. */
121
+ status: Readable<AgentThreadStatus | undefined>;
122
+ /**
123
+ * Stop the live thread subscription. Call in `onDestroy`
124
+ * (`onDestroy(handle.teardown)`).
125
+ */
126
+ teardown: () => void;
127
+ /** The live thread record (status, `instanceId`, …), or `undefined` before it exists. Read with `$thread`. */
128
+ thread: Readable<AgentThreadRecord | undefined>;
129
+ }
130
+ /**
131
+ * A thin agent handle: live thread `status` plus `run` / `cancel`, without the
132
+ * chat message surface — the Svelte counterpart to React's `useAgent`,
133
+ * re-expressed as stores you read with `$`. Composes `client.subscribe` for live
134
+ * thread state and {@link mutation} for the run/cancel writes. For the full
135
+ * conversation surface (durable history + approvals) use `agentChat`.
136
+ *
137
+ * `run` and `cancel` stay generic over the app-defined mutations that wrap
138
+ * `ctx.agents[name].run` / `.cancel`, so the handle hard-codes no function names
139
+ * beyond the `agents:*` surface. The subscription opens eagerly on the call and
140
+ * runs until {@link AgentHandle.teardown} — call `onDestroy(handle.teardown)`.
141
+ *
142
+ * Pass `client` explicitly, or omit it to resolve the ambient client published by
143
+ * `setLunoraClient`.
144
+ */
145
+ declare function agent(options: AgentOptions): AgentHandle;
146
+ declare function agent(client: LunoraClient, options: AgentOptions): AgentHandle;
147
+ /**
148
+ * One persisted (or optimistic) thread message, as `agents:agentMessages`
149
+ * surfaces it. Client-safe mirror of `@lunora/agent`'s `AgentMessageRow` —
150
+ * re-declared here (rather than imported) so this Svelte entry never pulls in the
151
+ * server-only `@lunora/agent` module graph. Keep in sync with the
152
+ * `agent_messages` table in `packages/agent/src/component.ts`.
153
+ */
154
+ interface AgentChatMessage {
155
+ content: string;
156
+ createdAt?: number;
157
+ /**
158
+ * `true` for a client-side optimistic user message not yet acknowledged by
159
+ * the server. Cleared once the durable history carries the matching user turn.
160
+ */
161
+ optimistic?: boolean;
162
+ role: "assistant" | "system" | "tool" | "user";
163
+ seq: number;
164
+ /** Approval lifecycle marker on a human-in-the-loop tool message. */
165
+ status?: "approved" | "awaiting_approval" | "rejected";
166
+ toolCallId?: string;
167
+ toolCalls?: ReadonlyArray<{
168
+ id: string;
169
+ input: unknown;
170
+ name: string;
171
+ }>;
172
+ toolName?: string;
173
+ }
174
+ /**
175
+ * A live token delta streamed while a turn is generating. Client-safe mirror of
176
+ * `@lunora/agent`'s `AgentTokenDelta`. Ephemeral — deltas feed
177
+ * {@link AgentChatHandle.streamingText} live and are never replayed; the
178
+ * persisted assistant message stays the single source of truth.
179
+ */
180
+ interface AgentTokenDelta {
181
+ /** Discriminates the token arm of {@link AgentLiveEvent}; unset on the wire (token is the default). */
182
+ kind?: "token";
183
+ /** The incremental text chunk the model just produced. */
184
+ text: string;
185
+ /** The thread this delta belongs to. */
186
+ threadKey: string;
187
+ /** The zero-based index of the turn producing the delta. */
188
+ turn: number;
189
+ }
190
+ /**
191
+ * A live tool-progress event streamed via `ctx.reportProgress(...)`. Client-safe
192
+ * mirror of `@lunora/agent`'s `AgentProgressEvent`. Ephemeral and `toolCallId`-keyed;
193
+ * surfaced by `agentToolEvents`, ignored by {@link AgentChatHandle.streamingText}.
194
+ */
195
+ interface AgentProgressEvent {
196
+ /** The arbitrary, JSON-serializable payload the tool reported. */
197
+ data: unknown;
198
+ /** Discriminates the progress arm of {@link AgentLiveEvent}. */
199
+ kind: "progress";
200
+ /** The thread this event belongs to. */
201
+ threadKey: string;
202
+ /** The tool call this progress belongs to. */
203
+ toolCallId: string;
204
+ }
205
+ /**
206
+ * A single event on the agent's live-only channel — a streamed token delta or a
207
+ * tool progress event. Client-safe mirror of `@lunora/agent`'s `AgentLiveEvent`.
208
+ * Discriminate on `kind` (`"progress"` for the progress arm; token deltas leave
209
+ * it unset).
210
+ */
211
+ type AgentLiveEvent = AgentProgressEvent | AgentTokenDelta;
212
+ /** The `agents:agentMessages` reference — live durable thread history. */
213
+ type AgentMessagesReference$1 = FunctionReference<"query", {
214
+ key: string;
215
+ limit?: number;
216
+ }, ReadonlyArray<Record<string, unknown>>>;
217
+ /** The `agents:agentResolveApproval` reference — resolves a human-in-the-loop tool approval. */
218
+ type AgentApprovalReference = FunctionReference<"mutation", {
219
+ decision: "approve" | "reject";
220
+ instanceId: string;
221
+ note?: string;
222
+ threadKey: string;
223
+ toolCallId: string;
224
+ }, {
225
+ resolved: boolean;
226
+ }>;
227
+ /** The `agents:agentThread` reference — live thread status + in-flight `instanceId`. */
228
+ type AgentThreadReference = FunctionReference<"query", {
229
+ key: string;
230
+ }, Record<string, unknown> | undefined>;
231
+ /**
232
+ * An app stream reference that tees the agent's in-flight live events, keyed by
233
+ * thread. Carries token deltas and — since `ctx.reportProgress` rides the same
234
+ * sink — tool progress events; this handle consumes only the token arm.
235
+ */
236
+ type AgentTokenStreamReference = FunctionReference<"stream", {
237
+ key: string;
238
+ }, AgentLiveEvent>;
239
+ /**
240
+ * The `agents.*` reference surface the chat handle reads. A structural subset of
241
+ * the generated `api.agents`, so the whole generated `api` object is assignable.
242
+ */
243
+ interface AgentChatApi {
244
+ agents: {
245
+ agentMessages: AgentMessagesReference$1;
246
+ agentResolveApproval: AgentApprovalReference;
247
+ agentThread: AgentThreadReference;
248
+ };
249
+ }
250
+ interface AgentChatOptions {
251
+ /** The generated `api` — its `agents.*` surface provides history, thread state, and approval resolution. */
252
+ api: AgentChatApi;
253
+ /**
254
+ * Optional app mutation over the agent's cancel path
255
+ * (`ctx.agents[name].cancel(id)`). Called with `{ instanceId, threadKey }`.
256
+ * When omitted (or no run is in flight) {@link AgentChatHandle.cancel} is a
257
+ * no-op.
258
+ */
259
+ cancel?: FunctionReference<"mutation">;
260
+ /** History depth forwarded to `agents:agentMessages`. */
261
+ limit?: number;
262
+ /**
263
+ * The app mutation that starts (or continues) a run — a thin wrapper over
264
+ * `ctx.agents[name].run(...)`. Called with `{ threadKey, input }` merged with
265
+ * {@link AgentChatOptions.sendArgs} and the per-call args.
266
+ */
267
+ send: FunctionReference<"mutation">;
268
+ /** Extra args merged into every `send` call (e.g. an `owner` or `title`). */
269
+ sendArgs?: Record<string, unknown>;
270
+ /**
271
+ * Optional live token-delta stream — an app stream function that tees the
272
+ * agent's in-flight deltas. When omitted {@link AgentChatHandle.streamingText}
273
+ * stays empty and the UI updates message-by-message from durable history.
274
+ */
275
+ stream?: AgentTokenStreamReference;
276
+ /** The thread to observe and continue. */
277
+ threadKey: string;
278
+ }
279
+ interface AgentChatHandle {
280
+ /** Approve a paused human-in-the-loop tool call (optionally with a note). */
281
+ approve: (toolCallId: string, note?: string) => Promise<void>;
282
+ /**
283
+ * Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
284
+ * no-op when no `cancel` mutation was supplied or no run is in flight.
285
+ */
286
+ cancel: () => Promise<void>;
287
+ /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. Read with `$messages`. */
288
+ messages: Readable<ReadonlyArray<AgentChatMessage>>;
289
+ /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
290
+ reject: (toolCallId: string, note?: string) => Promise<void>;
291
+ /** Start (or continue) a run with a user message; extra args merge over `sendArgs`. Appends an optimistic user turn. */
292
+ send: (input: string, args?: Record<string, unknown>) => Promise<void>;
293
+ /** The live thread status, or `undefined` before the thread exists. Read with `$status`. */
294
+ status: Readable<AgentThreadStatus | undefined>;
295
+ /**
296
+ * The in-flight turn's streamed text — live-only, `""` once the turn persists
297
+ * to `messages`. Populated when a `stream` reference is supplied (via the
298
+ * {@link stream} primitive); with no reference it stays `""` and the UI advances
299
+ * message-by-message from durable history. Read with `$streamingText`.
300
+ */
301
+ streamingText: Readable<string>;
302
+ /**
303
+ * Stop the live history + thread subscriptions (and the token stream, if any).
304
+ * Call in `onDestroy` (`onDestroy(handle.teardown)`).
305
+ */
306
+ teardown: () => void;
307
+ }
308
+ /**
309
+ * A first-class agent chat surface: live durable history + in-flight token
310
+ * streaming + the send / approve / reject / cancel writes, keyed by `threadKey` —
311
+ * the Svelte counterpart to React's `useAgentChat`, re-expressed as stores you
312
+ * read with `$`.
313
+ *
314
+ * It composes the existing primitives rather than adding transport:
315
+ * `client.subscribe(api.agents.agentMessages)` for durable history,
316
+ * `client.subscribe(api.agents.agentThread)` for live status + the in-flight
317
+ * `instanceId`, {@link stream} over an app token stream for in-flight deltas, and
318
+ * {@link mutation} for the writes (`api.agents.agentResolveApproval` for approvals;
319
+ * app-defined wrappers for `send`/`cancel`). Only the `agents:*` surface is
320
+ * hard-coded — `send`/`cancel`/`stream` stay generic references.
321
+ *
322
+ * A `send` optimistically appends the user turn so it renders immediately; the
323
+ * optimistic row clears once the durable history carries the acknowledged turn.
324
+ * `streamingText` is live-only: it holds the current turn's streamed text and
325
+ * empties as soon as that turn's assistant message lands in `messages` (the
326
+ * persisted message is the source of truth); with no `stream` reference it stays
327
+ * `""` and the UI advances message-by-message from durable history. The
328
+ * subscriptions (and the token stream, if any) open eagerly and run until
329
+ * {@link AgentChatHandle.teardown} — call `onDestroy(handle.teardown)`.
330
+ *
331
+ * Pass `client` explicitly, or omit it to resolve the ambient client published by
332
+ * `setLunoraClient`.
333
+ */
334
+ declare function agentChat(options: AgentChatOptions): AgentChatHandle;
335
+ declare function agentChat(client: LunoraClient, options: AgentChatOptions): AgentChatHandle;
336
+ /**
337
+ * The `agents.agentState` reference the handle subscribes to for the thread's live
338
+ * synced state. A structural subset of the generated `api.agents` surface (like
339
+ * `AgentApi` for `agentThread`), so the whole generated `api` object is
340
+ * assignable. Client-safe: no `@lunora/agent` import — the per-agent state type is
341
+ * mirrored by the handle's generic `T`, since codegen pins the reference return as
342
+ * an optional record (it never evaluates agent config).
343
+ */
344
+ interface AgentStateApi {
345
+ agents: {
346
+ agentState: FunctionReference<"query", {
347
+ key: string;
348
+ }, Record<string, unknown> | undefined>;
349
+ };
350
+ }
351
+ interface AgentStateOptions {
352
+ /** The generated `api` — its `agents.agentState` query drives live thread state. */
353
+ api: AgentStateApi;
354
+ /** The thread whose synced state to observe. */
355
+ threadKey: string;
356
+ }
357
+ interface AgentStateHandle<T> {
358
+ /** Svelte readable store of the subscription error, if the live channel reported one. Read with `$error`. */
359
+ error: Readable<Error | undefined>;
360
+ /** Svelte readable store of the live synced state, or `undefined` before it is seeded/first pushed. Read with `$state`. */
361
+ state: Readable<T | undefined>;
362
+ }
363
+ /**
364
+ * Subscribe to an agent thread's synced state — the `setState`-style value a tool
365
+ * writes with `ctx.setState(...)`, seeded by `defineAgent({ initialState })`. A
366
+ * thin wrapper over {@link subscription} against `api.agents.agentState`: the
367
+ * server pushes a fresh frame whenever the state changes (the dedicated query's
368
+ * per-socket JSON memo suppresses no-op pushes on unrelated thread writes), so
369
+ * `state` updates only on a real `setState`. The Svelte counterpart to React's
370
+ * `useAgentState`, re-expressed as stores you read with `$`.
371
+ *
372
+ * Generic over the app's state shape (`agentState<SupportState>(...)`, itself a
373
+ * record) — the reference is typed as an optional record because codegen cannot
374
+ * see the per-agent state type; the generic casts to `T`. The `state`/`error`
375
+ * stores are lazy, so the subscription opens on the first subscriber to `state`
376
+ * and tears down when the last one leaves — there is no `teardown` to call.
377
+ *
378
+ * Pass `client` explicitly, or omit it to resolve the ambient client published by
379
+ * `setLunoraClient`.
380
+ */
381
+ declare function agentState<T extends Record<string, unknown> = Record<string, unknown>>(options: AgentStateOptions): AgentStateHandle<T>;
382
+ declare function agentState<T extends Record<string, unknown> = Record<string, unknown>>(client: LunoraClient, options: AgentStateOptions): AgentStateHandle<T>;
383
+ /** The `agents:agentMessages` reference — live durable thread history. */
384
+ type AgentMessagesReference = FunctionReference<"query", {
385
+ key: string;
386
+ limit?: number;
387
+ }, ReadonlyArray<Record<string, unknown>>>;
388
+ /**
389
+ * An app stream reference that tees the agent's in-flight live events, keyed by
390
+ * thread. Carries token deltas and tool progress events; this handle consumes only
391
+ * the progress arm (`kind === "progress"`).
392
+ */
393
+ type AgentLiveStreamReference = FunctionReference<"stream", {
394
+ key: string;
395
+ }, AgentLiveEvent>;
396
+ /**
397
+ * The `agents.*` reference surface the tool-events handle reads. A structural
398
+ * subset of the generated `api.agents`, so the whole generated `api` object is
399
+ * assignable.
400
+ */
401
+ interface AgentToolEventsApi {
402
+ agents: {
403
+ agentMessages: AgentMessagesReference;
404
+ };
405
+ }
406
+ interface AgentToolEventsOptions {
407
+ /** The generated `api` — its `agents.agentMessages` query provides the durable tool lifecycle. */
408
+ api: AgentToolEventsApi;
409
+ /** History depth forwarded to `agents:agentMessages`. */
410
+ limit?: number;
411
+ /**
412
+ * Optional live event stream — the same app stream function `agentChat` uses.
413
+ * When supplied, ephemeral `ctx.reportProgress(...)` events for the thread are
414
+ * surfaced as `{ type: "progress" }` entries; when omitted only the durable
415
+ * lifecycle (call / result / awaiting-approval) is returned.
416
+ */
417
+ stream?: AgentLiveStreamReference;
418
+ /** The thread whose tool activity to observe. */
419
+ threadKey: string;
420
+ }
421
+ /**
422
+ * A single tool-lifecycle event for a thread. The durable arms
423
+ * (`call`/`result`/`awaiting-approval`) are derived from `agents:agentMessages`
424
+ * and carry the persisted `seq`; the ephemeral `progress` arm comes live off the
425
+ * stream and has no `seq`. Discriminate on `type`.
426
+ */
427
+ type AgentToolEvent = {
428
+ data: unknown;
429
+ toolCallId: string;
430
+ type: "progress";
431
+ } | {
432
+ input: unknown;
433
+ seq: number;
434
+ toolCallId: string;
435
+ toolName: string;
436
+ type: "call";
437
+ } | {
438
+ output: string;
439
+ seq: number;
440
+ status?: "approved" | "rejected";
441
+ toolCallId?: string;
442
+ toolName?: string;
443
+ type: "result";
444
+ } | {
445
+ seq: number;
446
+ toolCallId?: string;
447
+ toolName?: string;
448
+ type: "awaiting-approval";
449
+ };
450
+ interface AgentToolEventsHandle {
451
+ /**
452
+ * The thread's tool events: the durable lifecycle (oldest first, by `seq`)
453
+ * followed by any in-flight ephemeral progress events, recomputed from the live
454
+ * subscription + stream. Read with `$events`. With no `stream` reference only
455
+ * the durable lifecycle is surfaced. Treat as derived, not identity-stable.
456
+ */
457
+ events: Readable<ReadonlyArray<AgentToolEvent>>;
458
+ }
459
+ /**
460
+ * A focused view of a thread's tool activity: tool calls, their results,
461
+ * human-in-the-loop approval pauses, and live `ctx.reportProgress(...)` events —
462
+ * without the full chat message surface. The Svelte counterpart to React's
463
+ * `useAgentToolEvents`, re-expressed as a readable store you read with `$`.
464
+ *
465
+ * It composes the existing primitives rather than adding transport:
466
+ * {@link subscription} over `api.agents.agentMessages` for the durable lifecycle
467
+ * and {@link stream} over the optional app event stream for ephemeral progress,
468
+ * combined through `derived`. Progress events are live-only (the durable path never
469
+ * emits them): they ride the same sink as token deltas and are surfaced here,
470
+ * correlated to their tool call by `toolCallId`. For the conversational surface
471
+ * (messages + streaming text + approvals) use `agentChat`; this handle is the
472
+ * tool-observability slice.
473
+ *
474
+ * The underlying subscription and stream are lazy — they open when `events` gains
475
+ * its first subscriber and tear down when the last one leaves — so there is no
476
+ * `teardown` to call (unlike the write-bearing `agentChat`).
477
+ *
478
+ * Pass `client` explicitly, or omit it to resolve the ambient client published by
479
+ * `setLunoraClient`.
480
+ */
481
+ declare function agentToolEvents(options: AgentToolEventsOptions): AgentToolEventsHandle;
482
+ declare function agentToolEvents(client: LunoraClient, options: AgentToolEventsOptions): AgentToolEventsHandle;
483
+ /**
484
+ * Publish a {@link LunoraClient} on the Svelte component context so that
485
+ * descendant components can read it with {@link getLunoraClient} (or implicitly,
486
+ * via the default-client lookups inside `query`/`mutation`/`hydratePreloaded`).
487
+ *
488
+ * Call this once, high in the tree (typically your root `+layout.svelte` or
489
+ * `App.svelte`), during component initialisation — `setContext` must run while
490
+ * the component is being constructed, exactly like React's provider mounts once.
491
+ * This is the Svelte analogue of mounting `LunoraProvider`.
492
+ */
16
493
  declare const setLunoraClient: (client: LunoraClient) => LunoraClient;
17
494
  /**
18
- * Read the {@link LunoraClient} published by {@link setLunoraClient} from the
19
- * nearest ancestor. Throws if no provider is mounted, mirroring `useLunora`'s
20
- * "must be used inside a LunoraProvider" guard so the failure is loud and
21
- * early rather than a confusing `undefined` deref later.
22
- *
23
- * Must be called during component initialisation (Svelte's `getContext`
24
- * constraint); the live stores returned by `query`/`hydratePreloaded` resolve
25
- * the client eagerly at call time for exactly this reason.
26
- */
495
+ * Read the {@link LunoraClient} published by {@link setLunoraClient} from the
496
+ * nearest ancestor. Throws if no provider is mounted, mirroring `useLunora`'s
497
+ * "must be used inside a LunoraProvider" guard so the failure is loud and
498
+ * early rather than a confusing `undefined` deref later.
499
+ *
500
+ * Must be called during component initialisation (Svelte's `getContext`
501
+ * constraint); the live stores returned by `query`/`hydratePreloaded` resolve
502
+ * the client eagerly at call time for exactly this reason.
503
+ */
27
504
  declare const getLunoraClient: () => LunoraClient;
28
505
  interface AuthStore {
29
506
  /** Set the auth token on the underlying `LunoraClient`. */
@@ -34,95 +511,197 @@ interface AuthStore {
34
511
  user: Readable<User | null>;
35
512
  }
36
513
  /**
37
- * Create a pair of Svelte readable stores tracking the auth token and the
38
- * resolved user identity. The stores are lazy: subscriptions open on the first
39
- * reader and close when the last unsubscribes. Calling `setToken(jwt)` after
40
- * sign-in refreshes both stores.
41
- *
42
- * Pass an explicit client to bypass the ambient context (useful in tests).
43
- */
514
+ * Create a pair of Svelte readable stores tracking the auth token and the
515
+ * resolved user identity. The stores are lazy: subscriptions open on the first
516
+ * reader and close when the last unsubscribes. Calling `setToken(jwt)` after
517
+ * sign-in refreshes both stores.
518
+ *
519
+ * Pass an explicit client to bypass the ambient context (useful in tests).
520
+ */
44
521
  declare const auth: (explicitClient?: ReturnType<typeof getLunoraClient>) => AuthStore;
522
+ /** Derived auth-gate stores for template gating (`{#if $isAuthenticated}`), built on {@link auth}. */
523
+ interface AuthGateStore {
524
+ /** Readable store, `true` once a token is set and the user has resolved. */
525
+ isAuthenticated: Readable<boolean>;
526
+ /** Readable store, `true` while a token is set but the user hasn't resolved yet. */
527
+ isLoading: Readable<boolean>;
528
+ }
529
+ /**
530
+ * Derived auth-gate stores built on {@link auth}. Svelte has no JSX-style
531
+ * `Authenticated` slot component the way React/Vue/Solid do (this package is
532
+ * plain `.ts` over stores — no `.svelte` component compiler required), so this
533
+ * exposes the same three-state logic as two boolean stores instead: a token
534
+ * with no resolved user yet is `isLoading`; a token with a resolved user is
535
+ * `isAuthenticated`; no token is neither (the signed-out state a template
536
+ * checks for with a plain `{:else}`).
537
+ *
538
+ * ```ts
539
+ * import { authGate } from "@lunora/svelte";
540
+ * const { isAuthenticated, isLoading } = authGate();
541
+ * // markup: {#if $isAuthenticated} signed in {:else if $isLoading} loading… {:else} signed out {/if}
542
+ * ```
543
+ *
544
+ * Pass an explicit client to bypass the ambient context (useful in tests).
545
+ */
546
+ declare const authGate: (explicitClient?: ReturnType<typeof getLunoraClient>) => AuthGateStore;
45
547
  /** The shape held by a {@link connectionStatus} store: the latest aggregate live-socket status. */
46
548
  type ConnectionStatusStore = Readable<ConnectionStatus>;
47
549
  /**
48
- * Expose the client's aggregate live-socket status as a Svelte readable store.
49
- * Read it with the `$store` idiom (`{$status}`) and it stays current: the value
50
- * transitions through `idle` → `connecting` → `connected` → `offline` as
51
- * sockets open and drop — the Svelte equivalent of `@lunora/react`'s
52
- * `useConnectionStatus`. Use it to drive a connection indicator.
53
- *
54
- * The status listener attaches inside `readable`'s start callback (on the first
55
- * `$`-read / `.subscribe()`) and is released by the returned stop function when
56
- * the last subscriber goes away, so a store that's never read attaches nothing.
57
- *
58
- * Pass `client` explicitly, or omit it to resolve the ambient client published
59
- * by `setLunoraClient` (which must therefore be called during component init,
60
- * before this runs).
61
- */
550
+ * Expose the client's aggregate live-socket status as a Svelte readable store.
551
+ * Read it with the `$store` idiom (`{$status}`) and it stays current: the value
552
+ * transitions through `idle` → `connecting` → `connected` → `offline` as
553
+ * sockets open and drop — the Svelte equivalent of `@lunora/react`'s
554
+ * `useConnectionStatus`. Use it to drive a connection indicator.
555
+ *
556
+ * The status listener attaches inside `readable`'s start callback (on the first
557
+ * `$`-read / `.subscribe()`) and is released by the returned stop function when
558
+ * the last subscriber goes away, so a store that's never read attaches nothing.
559
+ *
560
+ * Pass `client` explicitly, or omit it to resolve the ambient client published
561
+ * by `setLunoraClient` (which must therefore be called during component init,
562
+ * before this runs).
563
+ */
62
564
  declare const connectionStatus: (client?: LunoraClient) => ConnectionStatusStore;
565
+ /** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
566
+ type FlagContext = Record<string, unknown>;
567
+ /** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
568
+ type FlagValue = boolean | number | string | {
569
+ [key: string]: unknown;
570
+ } | unknown[] | null;
571
+ /**
572
+ * Open a single feature flag as a Svelte readable store, live over Lunora's
573
+ * WebSocket. Read it with the `$store` idiom (`{$darkMode}`).
574
+ *
575
+ * The store holds `defaultValue` until the first evaluation lands, then the
576
+ * server's resolved value — re-emitted whenever the provider re-evaluates (e.g. a
577
+ * flag is toggled in Cloudflare Flagship). The flag's kind is inferred from
578
+ * `defaultValue`'s runtime type, so `flag("dark", false)` reads a boolean and
579
+ * `flag("hero", "control")` a string. `context` supplies a per-call targeting
580
+ * context merged on top of the app's default `identify` targeting key.
581
+ *
582
+ * The subscription opens lazily on the first `$`-read and tears down when the
583
+ * last subscriber detaches. Pass `client` explicitly, or omit it to resolve the
584
+ * ambient client published by `setLunoraClient`. Evaluation never throws — a
585
+ * provider error resolves the default (the same fail-open contract as `ctx.flags`).
586
+ */
587
+ declare function flag<T extends FlagValue>(key: string, defaultValue: T, context?: FlagContext): Readable<T>;
588
+ declare function flag<T extends FlagValue>(client: LunoraClient, key: string, defaultValue: T, context?: FlagContext): Readable<T>;
589
+ /**
590
+ * Open several feature flags at once as a single Svelte readable store of the
591
+ * resolved record, live over Lunora's WebSocket.
592
+ *
593
+ * Pass a record of `key → defaultValue`; each flag's kind is inferred from its
594
+ * default, and the store holds the same-shaped record with resolved values (the
595
+ * defaults until each evaluation lands). A single `context` applies to every
596
+ * flag. This is the batched form of {@link flag} — one store, one subscription
597
+ * per key, torn down together when the last subscriber detaches.
598
+ *
599
+ * Pass `client` explicitly, or omit it to resolve the ambient client published
600
+ * by `setLunoraClient`.
601
+ */
602
+ declare function flags<T extends Record<string, FlagValue>>(flagDefaults: T, context?: FlagContext): Readable<T>;
603
+ declare function flags<T extends Record<string, FlagValue>>(client: LunoraClient, flagDefaults: T, context?: FlagContext): Readable<T>;
63
604
  /**
64
- * Hydrate a query store from a {@link Preloaded} token produced by
65
- * `preloadQuery` during SSR, then keep it live — the reactive-loader handoff.
66
- *
67
- * The store is seeded **synchronously** with `preloaded.value`, so the very
68
- * first read (`$store` during hydration) returns the server value with no
69
- * loading flash and no hydration mismatch — there is no `undefined` window and
70
- * no refetch. When the store gains its first subscriber on the client, a live
71
- * WS subscription attaches and every subsequent delta re-emits, exactly like a
72
- * plain `query` store. This is the Svelte equivalent of React's
73
- * `usePreloadedQuery`.
74
- *
75
- * Pass `client` explicitly, or omit it to resolve the ambient client published
76
- * by `setLunoraClient`.
77
- *
78
- * Note on SSR: `readable`'s start callback only runs when the store is actually
79
- * subscribed (the browser), so on the server the store simply holds the seeded
80
- * value and opens no socket. The token's `value` is the single source of truth
81
- * for the first paint either way.
82
- */
605
+ * Hydrate a query store from a {@link Preloaded} token produced by
606
+ * `preloadQuery` during SSR, then keep it live — the reactive-loader handoff.
607
+ *
608
+ * The store is seeded **synchronously** with `preloaded.value`, so the very
609
+ * first read (`$store` during hydration) returns the server value with no
610
+ * loading flash and no hydration mismatch — there is no `undefined` window and
611
+ * no refetch. When the store gains its first subscriber on the client, a live
612
+ * WS subscription attaches and every subsequent delta re-emits, exactly like a
613
+ * plain `query` store. This is the Svelte equivalent of React's
614
+ * `usePreloadedQuery`.
615
+ *
616
+ * Pass `client` explicitly, or omit it to resolve the ambient client published
617
+ * by `setLunoraClient`.
618
+ *
619
+ * Note on SSR: `readable`'s start callback only runs when the store is actually
620
+ * subscribed (the browser), so on the server the store simply holds the seeded
621
+ * value and opens no socket. The token's `value` is the single source of truth
622
+ * for the first paint either way.
623
+ */
83
624
  declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, client?: LunoraClient) => Readable<T>;
84
625
  /**
85
- * The reactive handle returned by {@link mutation} — the Svelte counterpart to
86
- * React's `useMutation`, re-expressed as stores you read with `$`. The surface
87
- * is identical across the Lunora adapters (`@lunora/solid`, `/vue`):
88
- * `data`/`error`/`pending` are readable stores and `mutate` is an awaitable.
89
- */
626
+ * The reactive handle returned by {@link mutation} — the Svelte counterpart to
627
+ * React's `useMutation`, re-expressed as stores you read with `$`. The surface
628
+ * is identical across the Lunora adapters (`@lunora/solid`, `/vue`):
629
+ * `data`/`error`/`pending` are readable stores and `mutate` is an awaitable.
630
+ */
90
631
  interface MutationHandle<F extends FunctionReference> {
91
632
  /** The latest invocation's resolved value, or `undefined` before the first success. */
92
633
  data: Readable<ReturnOf<F> | undefined>;
93
634
  /** The latest invocation's error, or `undefined`. */
94
635
  error: Readable<Error | undefined>;
95
636
  /**
96
- * Run the mutation. Resolves with the server result and rejects on failure
97
- * (errors propagate — there is no swallowing). Optimistic updates passed in
98
- * `options` are applied and rolled back by the client against the live query
99
- * subscriptions, exactly as in the React adapter.
100
- */
637
+ * Run the mutation. Resolves with the server result and rejects on failure
638
+ * (errors propagate — there is no swallowing). Optimistic updates passed in
639
+ * `options` are applied and rolled back by the client against the live query
640
+ * subscriptions, exactly as in the React adapter.
641
+ */
101
642
  mutate: (args: ArgsOf<F>, options?: MutationCallOptions<unknown, unknown, ArgsOf<F>>) => Promise<ReturnOf<F>>;
102
643
  /**
103
- * `true` while any invocation from this handle is in flight. Ref-counted, so
104
- * overlapping calls compose and it only flips back to `false` once the last
105
- * one settles. Read it with `$pending` in a component to disable a button.
106
- */
644
+ * `true` while any invocation from this handle is in flight. Ref-counted, so
645
+ * overlapping calls compose and it only flips back to `false` once the last
646
+ * one settles. Read it with `$pending` in a component to disable a button.
647
+ */
107
648
  pending: Readable<boolean>;
108
649
  /** Clear `data`/`error` back to idle. */
109
650
  reset: () => void;
110
651
  }
111
652
  /**
112
- * Create an optimistic {@link MutationHandle} for a mutation reference. The
113
- * Svelte counterpart to React's `useMutation`: returns
114
- * `{ data, error, pending, mutate, reset }` of readable stores plus an awaitable
115
- * `mutate`. The ref-counted pending + error-normalize orchestration is the
116
- * shared `createMutationRunner` from `@lunora/client`; only the stores are
117
- * adapter-specific.
118
- *
119
- * Pass `client` explicitly, or omit it to resolve the ambient client published
120
- * by `setLunoraClient`.
121
- */
653
+ * Create an optimistic {@link MutationHandle} for a mutation reference. The
654
+ * Svelte counterpart to React's `useMutation`: returns
655
+ * `{ data, error, pending, mutate, reset }` of readable stores plus an awaitable
656
+ * `mutate`. The ref-counted pending + error-normalize orchestration is the
657
+ * shared `createCallRunner` from `@lunora/client`; only the stores are
658
+ * adapter-specific.
659
+ *
660
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
661
+ * invocation (an earlier call settling later cannot clobber a newer one), a
662
+ * success clears `error`, and a failure leaves the previous `data` in place.
663
+ * `reset()` clears both; it does not cancel an in-flight call.
664
+ *
665
+ * Pass `client` explicitly, or omit it to resolve the ambient client published
666
+ * by `setLunoraClient`.
667
+ */
122
668
  declare function mutation<F extends FunctionReference>(function_: F): MutationHandle<F>;
123
669
  declare function mutation<F extends FunctionReference>(client: LunoraClient, function_: F): MutationHandle<F>;
670
+ /**
671
+ * The reactive handle returned by {@link mutator} — the Svelte counterpart to
672
+ * `@lunora/react`'s `useMutator`, re-expressed as stores you read with `$`.
673
+ * `error`/`isError`/`pending` are readable stores and `mutate` is an awaitable
674
+ * that resolves once the write is persisted (or rejects).
675
+ */
676
+ interface MutatorHandleStore<TArgs> {
677
+ /** The latest invocation's error, or `undefined`. */
678
+ error: Readable<Error | undefined>;
679
+ /** `true` when the latest invocation rejected. */
680
+ isError: Readable<boolean>;
681
+ /** Run the mutator; resolves once the write is persisted, rejects on failure. */
682
+ mutate: (args: TArgs) => Promise<void>;
683
+ /** `true` while ANY invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
684
+ pending: Readable<boolean>;
685
+ /** Clear the latest `error` back to idle. */
686
+ reset: () => void;
687
+ }
688
+ /**
689
+ * Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
690
+ * custom-mutator handle from `@lunora/db`'s `bindMutators` — the Svelte
691
+ * equivalent of `@lunora/react`'s `useMutator`. The optimistic overlay and
692
+ * server-authoritative push are owned by the bound handle (and TanStack DB's
693
+ * optimistic-transaction layer rebases pending overlays on every sync tick);
694
+ * this helper only surfaces store state for the in-flight/error lifecycle. Reads
695
+ * stay on the existing TanStack `useLiveQuery`; no new query store is needed.
696
+ *
697
+ * `pending` is ref-counted across overlapping invocations of THIS handle, so it
698
+ * clears only once every concurrent call has settled.
699
+ */
700
+ declare const mutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHandleStore<TArgs>;
124
701
  /** The args a paginated query exposes minus the framework-supplied page cursor. */
125
702
  type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
703
+ /** Paginated args, the skip sentinel, or a reactive (`Readable`) source of either. */
704
+ type ReactivePaginatedArgs<F extends FunctionReference> = "skip" | PaginatedArgs<F> | Readable<"skip" | PaginatedArgs<F>>;
126
705
  /** The element type of the `page` array a paginated query returns. */
127
706
  type PageItemOf<F extends FunctionReference> = ReturnOf<F> extends {
128
707
  page: (infer T)[];
@@ -160,46 +739,50 @@ interface InfiniteQueryHandle<T> {
160
739
  status: Readable<PaginationStatus>;
161
740
  }
162
741
  /**
163
- * Open a live paginated query as Svelte stores. The first page opens when
164
- * called; call `loadMore(n)` to append the next page. Results are flattened
165
- * across all loaded pages.
166
- *
167
- * Pass `client` explicitly, or omit it to resolve the ambient client from the
168
- * Svelte context.
169
- */
170
- declare function paginatedQuery<F extends FunctionReference>(function_: F, args: "skip" | PaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
171
- declare function paginatedQuery<F extends FunctionReference>(client: LunoraClient, function_: F, args: "skip" | PaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
172
- /**
173
- * Open a live paginated query as Svelte stores, keeping each page as its own
174
- * inner array (TanStack-Query-style `fetchNextPage` / `hasNextPage` shape).
175
- *
176
- * Pass `client` explicitly, or omit it to resolve the ambient client from the
177
- * Svelte context.
178
- */
742
+ * Open a live paginated query as Svelte stores. The first page opens when
743
+ * called; call `loadMore(n)` to append the next page. Results are flattened
744
+ * across all loaded pages.
745
+ *
746
+ * Pass `client` explicitly, or omit it to resolve the ambient client from the
747
+ * Svelte context.
748
+ *
749
+ * `args` may also be a `Readable` store: each emission tears the engine down
750
+ * and rebuilds it against the new args (pagination resets to the first page);
751
+ * a `"skip"` emission tears down without re-opening.
752
+ */
753
+ declare function paginatedQuery<F extends FunctionReference>(function_: F, args: ReactivePaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
754
+ declare function paginatedQuery<F extends FunctionReference>(client: LunoraClient, function_: F, args: ReactivePaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
755
+ /**
756
+ * Open a live paginated query as Svelte stores, keeping each page as its own
757
+ * inner array (TanStack-Query-style `fetchNextPage` / `hasNextPage` shape).
758
+ *
759
+ * Pass `client` explicitly, or omit it to resolve the ambient client from the
760
+ * Svelte context.
761
+ */
179
762
  declare function infiniteQuery<F extends FunctionReference>(function_: F, args: "skip" | PaginatedArgs<F>, options: InfiniteQueryOptions): InfiniteQueryHandle<PageItemOf<F>>;
180
763
  declare function infiniteQuery<F extends FunctionReference>(client: LunoraClient, function_: F, args: "skip" | PaginatedArgs<F>, options: InfiniteQueryOptions): InfiniteQueryHandle<PageItemOf<F>>;
181
764
  /**
182
- * `presence` — collaborative-awareness stores, the client half of the
183
- * `@lunora/server` `definePresence` preset.
184
- *
185
- * Drives the heartbeat mutation (on call, interval, and tab re-focus) and
186
- * subscribes to the live `listPresent` query for the given room.
187
- *
188
- * Pass `client` explicitly, or omit it to resolve the ambient client from the
189
- * Svelte context.
190
- */
191
- /**
192
- * A heartbeat mutation reference: takes `{ roomId, sessionId, data? }`.
193
- */
765
+ * `presence` — collaborative-awareness stores, the client half of the
766
+ * `@lunora/server` `definePresence` preset.
767
+ *
768
+ * Drives the heartbeat mutation (on call, interval, and tab re-focus) and
769
+ * subscribes to the live `listPresent` query for the given room.
770
+ *
771
+ * Pass `client` explicitly, or omit it to resolve the ambient client from the
772
+ * Svelte context.
773
+ */
774
+ /**
775
+ * A heartbeat mutation reference: takes `{ roomId, sessionId, data? }`.
776
+ */
194
777
  type HeartbeatReference = FunctionReference<"mutation", {
195
778
  data?: Record<string, unknown>;
196
779
  roomId: string;
197
780
  sessionId: string;
198
781
  }>;
199
782
  /**
200
- * A listPresent query reference: takes `{ roomId }` and returns the array of
201
- * present members.
202
- */
783
+ * A listPresent query reference: takes `{ roomId }` and returns the array of
784
+ * present members.
785
+ */
203
786
  type ListPresentReference = FunctionReference<"query", {
204
787
  roomId: string;
205
788
  }>;
@@ -213,9 +796,9 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
213
796
  /** The `api.*` reference for the presence listPresent query. */
214
797
  listPresent: L;
215
798
  /**
216
- * Stable id for this presence row. Defaults to a fresh per-mount id.
217
- * Pass a user/connection id to control deduping across tabs.
218
- */
799
+ * Stable id for this presence row. Defaults to a fresh per-mount id.
800
+ * Pass a user/connection id to control deduping across tabs.
801
+ */
219
802
  sessionId?: string;
220
803
  /** Forwarded to the heartbeat mutation / listPresent subscription when sharding by room. */
221
804
  shardKey?: string;
@@ -231,17 +814,22 @@ interface PresenceHandle<L extends ListPresentReference> {
231
814
  teardown: () => void;
232
815
  }
233
816
  /**
234
- * Open a live presence handle.
235
- *
236
- * Pass `client` explicitly, or omit it to resolve the ambient client from the
237
- * Svelte context (requires calling inside a component's `&lt;script>` block or
238
- * inside a function called during component initialisation).
239
- *
240
- * Call `teardown()` when the component is destroyed to stop heartbeats and
241
- * remove the visibility listener (`onDestroy(handle.teardown)`).
242
- */
817
+ * Open a live presence handle.
818
+ *
819
+ * Pass `client` explicitly, or omit it to resolve the ambient client from the
820
+ * Svelte context (requires calling inside a component's `<script>` block or
821
+ * inside a function called during component initialisation).
822
+ *
823
+ * Teardown (stop heartbeats, remove the visibility listener, release the
824
+ * connection context) is wired automatically to the component's `onDestroy`
825
+ * when called during component initialisation. Outside a component call
826
+ * `handle.teardown()` yourself. `teardown()` is idempotent, so an explicit
827
+ * `onDestroy(handle.teardown)` on top of the auto-wiring is safe.
828
+ */
243
829
  declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
244
830
  declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
831
+ /** Query args, the skip sentinel, or a reactive (`Readable`) source of either. */
832
+ type ReactiveArgs<F extends FunctionReference> = ArgsOf<F> | "skip" | Readable<ArgsOf<F> | "skip">;
245
833
  /** Options accepted by {@link query}. */
246
834
  interface QueryStoreOptions {
247
835
  /** Called when the underlying subscription reports an error. */
@@ -250,36 +838,46 @@ interface QueryStoreOptions {
250
838
  shardKey?: string;
251
839
  }
252
840
  /**
253
- * The shape held by a {@link query} store: the latest server value (`undefined`
254
- * until the first response lands, mirroring React's `useQuery`).
255
- */
841
+ * The shape held by a {@link query} store: the latest server value (`undefined`
842
+ * until the first response lands, mirroring React's `useQuery`).
843
+ */
256
844
  type QueryStore<F extends FunctionReference> = Readable<ReturnOf<F> | undefined>;
257
845
  /**
258
- * Open a live query as a Svelte readable store. Read it with the `$store`
259
- * idiom in a component (`{$messages}`) and it stays current: a WS subscription
260
- * attaches the moment the store gains its first subscriber and the value
261
- * re-emits on every server delta — the Svelte equivalent of React's `useQuery`.
262
- *
263
- * The subscription is opened lazily (inside `readable`'s start callback, on the
264
- * first `$`-read / `.subscribe()`) and torn down by the returned stop function
265
- * when the last subscriber goes away — so a store that's never read opens no
266
- * socket, and a component that unmounts releases its subscription. Sharing one
267
- * store across several components shares a single underlying subscription
268
- * (the `LunoraClient` de-dupes by `(fn, args, shardKey)`).
269
- *
270
- * Pass `client` explicitly, or omit it to resolve the ambient client published
271
- * by `setLunoraClient` (which must therefore be called during component init,
272
- * before this runs).
273
- */
274
- declare function query<F extends FunctionReference>(function_: F, args: ArgsOf<F>, options?: QueryStoreOptions): QueryStore<F>;
275
- declare function query<F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: QueryStoreOptions): QueryStore<F>;
846
+ * Open a live query as a Svelte readable store. Read it with the `$store`
847
+ * idiom in a component (`{$messages}`) and it stays current: a WS subscription
848
+ * attaches the moment the store gains its first subscriber and the value
849
+ * re-emits on every server delta — the Svelte equivalent of React's `useQuery`.
850
+ *
851
+ * The subscription is opened lazily (inside `readable`'s start callback, on the
852
+ * first `$`-read / `.subscribe()`) and torn down by the returned stop function
853
+ * when the last subscriber goes away — so a store that's never read opens no
854
+ * socket, and a component that unmounts releases its subscription. Sharing one
855
+ * store across several components shares a single underlying subscription
856
+ * (the `LunoraClient` de-dupes by `(fn, args, shardKey)`).
857
+ *
858
+ * Pass `"skip"` as `args` to keep the store connected but the subscription
859
+ * dormant (the value stays `undefined`, no socket opens) — useful for a query
860
+ * gated on auth or a route param, matching React/Vue/Solid's `useQuery`.
861
+ *
862
+ * Pass `client` explicitly, or omit it to resolve the ambient client published
863
+ * by `setLunoraClient` (which must therefore be called during component init,
864
+ * before this runs).
865
+ *
866
+ * `args` may also be a `Readable` store (wrap runes state with `toStore` or
867
+ * `derived`): each emission tears down the previous subscription and opens a
868
+ * fresh one against the new args — the Svelte counterpart of Vue's
869
+ * `MaybeRefOrGetter` args. An emission of `"skip"` tears down without
870
+ * re-opening and resets the value to `undefined`.
871
+ */
872
+ declare function query<F extends FunctionReference>(function_: F, args: ReactiveArgs<F>, options?: QueryStoreOptions): QueryStore<F>;
873
+ declare function query<F extends FunctionReference>(client: LunoraClient, function_: F, args: ReactiveArgs<F>, options?: QueryStoreOptions): QueryStore<F>;
276
874
  interface RateLimitOptions {
277
875
  /** Clock injection for tests. Defaults to `Date.now`. */
278
876
  now?: () => number;
279
877
  /**
280
- * Re-evaluation cadence in milliseconds while throttled, so `retryAfter`
281
- * ticks down and `disabled` flips back automatically. Defaults to `1000`.
282
- */
878
+ * Re-evaluation cadence in milliseconds while throttled, so `retryAfter`
879
+ * ticks down and `disabled` flips back automatically. Defaults to `1000`.
880
+ */
283
881
  tickMs?: number;
284
882
  }
285
883
  interface RateLimitHandle {
@@ -299,17 +897,57 @@ interface RateLimitHandle {
299
897
  teardown: () => void;
300
898
  }
301
899
  /**
302
- * Client-side mirror of a rate limit for instant UX — disable a button or show
303
- * a countdown without a round-trip. It runs the same token-bucket / fixed-window
304
- * math as `@lunora/ratelimit` on the server, so the prediction agrees with the
305
- * authoritative check; the server remains the source of truth.
306
- *
307
- * `config` is read on every call; pass a stable reference (module constant).
308
- *
309
- * Call `teardown()` when the component is destroyed to stop the auto-tick
310
- * interval (`onDestroy(handle.teardown)`).
311
- */
900
+ * Client-side mirror of a rate limit for instant UX — disable a button or show
901
+ * a countdown without a round-trip. It runs the same token-bucket / fixed-window
902
+ * math as `@lunora/ratelimit` on the server, so the prediction agrees with the
903
+ * authoritative check; the server remains the source of truth.
904
+ *
905
+ * `config` is read on every call; pass a stable reference (module constant).
906
+ *
907
+ * Call `teardown()` when the component is destroyed to stop the auto-tick
908
+ * interval (`onDestroy(handle.teardown)`).
909
+ */
312
910
  declare const rateLimit: (config: RateLimitConfig, options?: RateLimitOptions) => RateLimitHandle;
911
+ /** The lifecycle of a stream the store is observing. */
912
+ type StreamStatus = "complete" | "error" | "idle" | "streaming";
913
+ interface StreamStoreOptions {
914
+ /** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
915
+ maxBuffer?: number;
916
+ shardKey?: string;
917
+ }
918
+ interface StreamHandle<T> {
919
+ /** Force-cancel the stream and resolve the iterator. Safe to call multiple times. */
920
+ cancel: () => void;
921
+ /** Svelte readable store of the chunks the server has pushed so far, in arrival order. */
922
+ chunks: Readable<ReadonlyArray<T>>;
923
+ /** Svelte readable store of the last stream error (`undefined` when healthy). */
924
+ error: Readable<Error | undefined>;
925
+ /** Svelte readable store of the stream lifecycle status. */
926
+ status: Readable<StreamStatus>;
927
+ /**
928
+ * Stop the stream and release the iterator. Call in `onDestroy`
929
+ * (`onDestroy(handle.teardown)`) when you consume `chunks` eagerly; when you
930
+ * read `chunks` with `$` the store tears itself down as the last subscriber
931
+ * leaves.
932
+ */
933
+ teardown: () => void;
934
+ }
935
+ /**
936
+ * Open a streaming query and expose its chunks, lifecycle status, and last error
937
+ * as Svelte readable stores. The `chunks` store is lazy: the stream opens on the
938
+ * first subscriber to `chunks` and is cancelled when the last one leaves (its
939
+ * chunks reset on the next open). `status` and `error` mirror that same stream.
940
+ *
941
+ * Passing `"skip"` as `args` keeps the stores connected but the stream dormant
942
+ * (`chunks` stays empty, `status` stays `"idle"`). The Svelte counterpart to
943
+ * React's `useStream`, re-expressed as stores you read with `$`.
944
+ *
945
+ * Pass an explicit `client` as the first argument to bypass the ambient context
946
+ * (useful in tests), or omit it to resolve the client published by
947
+ * `setLunoraClient`.
948
+ */
949
+ declare function stream<F extends FunctionReference<"stream">>(function_: F, args: ArgsOf<F> | "skip", options?: StreamStoreOptions): StreamHandle<ReturnOf<F>>;
950
+ declare function stream<F extends FunctionReference<"stream">>(client: LunoraClient, function_: F, args: ArgsOf<F> | "skip", options?: StreamStoreOptions): StreamHandle<ReturnOf<F>>;
313
951
  interface SubscriptionStoreOptions {
314
952
  onError?: (error: Error) => void;
315
953
  shardKey?: string;
@@ -321,15 +959,217 @@ interface SubscriptionHandle<T> {
321
959
  error: Readable<Error | undefined>;
322
960
  }
323
961
  /**
324
- * Create a pair of Svelte readable stores that open a live subscription
325
- * against the Lunora backend. `data` updates on every server push; `error`
326
- * captures the last subscription error. Both stores are lazy: the subscription
327
- * opens on the first subscriber to `data` and tears down when it stops.
328
- *
329
- * Passing `"skip"` as `args` keeps the stores connected but the subscription
330
- * dormant (`data` stays `undefined`). Pass an explicit `client` as the first
331
- * argument to bypass the ambient context (useful in tests).
332
- */
333
- declare function subscription<F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip", options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
334
- declare function subscription<F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F> | "skip", options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
335
- export { type AuthStore, type ConnectionStatusStore, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type MutationHandle, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type SubscriptionHandle, type SubscriptionStoreOptions, auth, connectionStatus, getLunoraClient, hydratePreloaded, infiniteQuery, mutation, paginatedQuery, presence, query, rateLimit, setLunoraClient, subscription };
962
+ * Create a pair of Svelte readable stores that open a live subscription
963
+ * against the Lunora backend. `data` updates on every server push; `error`
964
+ * captures the last subscription error. Both stores are lazy: the subscription
965
+ * opens on the first subscriber to `data` and tears down when it stops.
966
+ *
967
+ * Passing `"skip"` as `args` keeps the stores connected but the subscription
968
+ * dormant (`data` stays `undefined`). Pass an explicit `client` as the first
969
+ * argument to bypass the ambient context (useful in tests).
970
+ *
971
+ * `args` may also be a `Readable` store: each emission tears down the previous
972
+ * subscription and opens a fresh one; a `"skip"` emission tears down without
973
+ * re-opening and resets `data` to `undefined`.
974
+ */
975
+ declare function subscription<F extends FunctionReference>(function_: F, args: ReactiveArgs<F>, options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
976
+ declare function subscription<F extends FunctionReference>(client: LunoraClient, function_: F, args: ReactiveArgs<F>, options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
977
+ /**
978
+ * Browser Web Audio subsystems for `useVoiceAgent` — the default microphone
979
+ * capture and speaker playback implementations injected into the composable via
980
+ * its `createMicrophone` / `createSpeaker` seams. Kept in a sibling module so the
981
+ * heavy Web Audio graph (and its structural DOM typings) stays isolated from the
982
+ * composable's transport + reactive-state logic and remains mockable in a
983
+ * non-browser test env.
984
+ */
985
+ /**
986
+ * The negotiated audio format the voice DO streams back. Mirrors
987
+ * `@lunora/agent`'s `VoiceServerFrame` `ready.audioFormat` — re-declared (not
988
+ * imported) so this Svelte package never pulls in the server-only `@lunora/agent`
989
+ * module graph.
990
+ */
991
+ type VoiceAudioFormat = "mp3" | "wav";
992
+ /** Captures microphone audio and reports level / turn boundaries back to the composable. */
993
+ interface VoiceMicrophone {
994
+ /** Mute/unmute the mic without tearing down the capture graph. */
995
+ setMuted: (muted: boolean) => void;
996
+ /** Stop capture and release the media stream + audio graph. */
997
+ stop: () => void;
998
+ }
999
+ /** Plays the server's streamed audio chunks and supports a mid-utterance barge-in. */
1000
+ interface VoiceSpeaker {
1001
+ /** Queue a decoded audio chunk for gap-minimized playback. */
1002
+ enqueue: (audio: Uint8Array) => void;
1003
+ /** Drop everything queued and stop the current chunk (barge-in). */
1004
+ interrupt: () => void;
1005
+ /** Release the playback audio context. */
1006
+ stop: () => void;
1007
+ }
1008
+ /** Config passed to a {@link CreateMicrophone} factory. */
1009
+ interface MicrophoneConfig {
1010
+ /** The consecutive above-threshold chunk count that counts as a barge-in. */
1011
+ interruptChunks: number;
1012
+ /** RMS above which the user is considered to be barging in while the agent speaks. */
1013
+ interruptThreshold: number;
1014
+ /** `true` while `status === "speaking"` — gates barge-in detection. */
1015
+ isSpeaking: () => boolean;
1016
+ /** One 16 kHz mono 16-bit little-endian PCM frame captured from the mic. */
1017
+ onAudio: (pcm: Uint8Array) => void;
1018
+ /** A barge-in was detected (RMS spike while the agent is speaking). */
1019
+ onInterrupt: () => void;
1020
+ /** The current input RMS (0–1), for a level meter. */
1021
+ onLevel: (rms: number) => void;
1022
+ /** A spoken utterance ended (speech followed by `silenceDurationMs` of silence). */
1023
+ onSilence: () => void;
1024
+ /** Milliseconds of sub-threshold audio (after speech) that closes an utterance. */
1025
+ silenceDurationMs: number;
1026
+ /** RMS below which audio counts as silence. */
1027
+ silenceThreshold: number;
1028
+ }
1029
+ type CreateMicrophone = (config: MicrophoneConfig) => Promise<VoiceMicrophone>;
1030
+ type CreateSpeaker = (config: {
1031
+ audioFormat: VoiceAudioFormat;
1032
+ }) => VoiceSpeaker;
1033
+ /**
1034
+ * The `agents.<name>Voice` reference codegen emits for a voice-enabled agent — a
1035
+ * live, WS-backed session keyed by `threadKey`. A structural subset of the
1036
+ * generated member, so passing `api.agents.<name>Voice` type-checks.
1037
+ */
1038
+ type VoiceReference = FunctionReference<"stream", {
1039
+ threadKey: string;
1040
+ }, Record<string, unknown>>;
1041
+ /** The lifecycle of a voice call, mirrored to the UI. */
1042
+ type VoiceStatus = "idle" | "listening" | "speaking" | "thinking";
1043
+ /** A minimal structural subset of the DOM `WebSocket` the handle drives. */
1044
+ interface VoiceSocket {
1045
+ binaryType: string;
1046
+ close: () => void;
1047
+ onclose: ((event: unknown) => void) | null;
1048
+ onerror: ((event: unknown) => void) | null;
1049
+ onmessage: ((event: {
1050
+ data: unknown;
1051
+ }) => void) | null;
1052
+ onopen: ((event: unknown) => void) | null;
1053
+ readonly readyState: number;
1054
+ send: (data: ArrayBufferView | ArrayBufferLike | string) => void;
1055
+ }
1056
+ type CreateSocket = (url: string) => VoiceSocket;
1057
+ interface VoiceAgentOptions {
1058
+ /**
1059
+ * Advanced/test seam: build the microphone capture subsystem. Defaults to a
1060
+ * `getUserMedia` + Web Audio implementation. Injected wholesale so the Web
1061
+ * Audio graph stays isolated (and mockable in a non-browser test env).
1062
+ */
1063
+ createMicrophone?: CreateMicrophone;
1064
+ /** Advanced/test seam: open the transport. Defaults to `new WebSocket(url)`. */
1065
+ createSocket?: CreateSocket;
1066
+ /** Advanced/test seam: build the audio playback subsystem. Defaults to a Web Audio implementation. */
1067
+ createSpeaker?: CreateSpeaker;
1068
+ /** Consecutive above-`interruptThreshold` chunks that trigger a barge-in. Default `3`. */
1069
+ interruptChunks?: number;
1070
+ /** Input RMS above which the user is treated as barging in while the agent speaks. Default `0.15`. */
1071
+ interruptThreshold?: number;
1072
+ /** Milliseconds of silence (after speech) that auto-commits an utterance. Default `1200`. */
1073
+ silenceDurationMs?: number;
1074
+ /** Input RMS below which audio counts as silence. Default `0.01`. */
1075
+ silenceThreshold?: number;
1076
+ /** The thread to converse on — shared with the agent's text turns. */
1077
+ threadKey: string;
1078
+ /** The generated `api.agents.<name>Voice` reference — identifies the voice DO endpoint. */
1079
+ voice: VoiceReference;
1080
+ }
1081
+ interface VoiceAgentHandle {
1082
+ /** Svelte readable store of the current input RMS (0–1) — drive a mic level meter. Read with `$audioLevel`. */
1083
+ audioLevel: Readable<number>;
1084
+ /** Svelte readable store: `true` once the WS `ready` handshake completed. Read with `$connected`. */
1085
+ connected: Readable<boolean>;
1086
+ /** Tear down the call: close the socket, stop the mic, release audio. Idempotent. Call in `onDestroy`. */
1087
+ endCall: () => void;
1088
+ /** Svelte readable store of the last transport/pipeline error, or `undefined`. Read with `$error`. */
1089
+ error: Readable<Error | undefined>;
1090
+ /** Svelte readable store of the live assistant text for the in-flight turn (grows via deltas; finalized on done). Read with `$interimTranscript`. */
1091
+ interimTranscript: Readable<string>;
1092
+ /** Svelte readable store: `true` while the mic is muted. Read with `$isMuted`. */
1093
+ isMuted: Readable<boolean>;
1094
+ /** Send a typed turn (no audio) — a text message spoken back by the agent. */
1095
+ sendText: (text: string) => void;
1096
+ /** Open the mic, connect the socket, and start the conversation. Idempotent while active. */
1097
+ startCall: () => Promise<void>;
1098
+ /** Svelte readable store of the current call lifecycle. Read with `$status`. */
1099
+ status: Readable<VoiceStatus>;
1100
+ /** Mute/unmute the microphone. Returns the new muted state. */
1101
+ toggleMute: () => boolean;
1102
+ /** Svelte readable store of the last finalized user utterance (STT result). Read with `$transcript`. */
1103
+ transcript: Readable<string>;
1104
+ }
1105
+ /**
1106
+ * A first-class voice-call surface for a voice-enabled agent: it opens a
1107
+ * WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
1108
+ * streams the agent's synthesized speech back through the browser's audio output,
1109
+ * and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
1110
+ * `audioLevel`) to Svelte readable stores you read with `$`. Pass the generated
1111
+ * `api.agents.<name>Voice` reference (never a string), matching `agentChat`'s
1112
+ * reference-passing style. The Svelte counterpart to React's `useVoiceAgent`,
1113
+ * re-expressed as stores; the per-call connection lives in a closure variable (a
1114
+ * handle is created once per component, so no store-of-store indirection is
1115
+ * needed).
1116
+ *
1117
+ * v1 transport is plain binary WebSocket frames with push-to-talk / silence-timer
1118
+ * turn detection and client-side RMS barge-in. The heavy Web Audio capture and
1119
+ * playback subsystems are injectable (`createMicrophone` / `createSpeaker` /
1120
+ * `createSocket`) so the handle is drivable outside a browser.
1121
+ *
1122
+ * There is no auto-dispose in Svelte — call `endCall` in `onDestroy`
1123
+ * (`onDestroy(handle.endCall)`) to tear the call down if the component unmounts
1124
+ * mid-call.
1125
+ *
1126
+ * Pass `client` explicitly, or omit it to resolve the ambient client published by
1127
+ * `setLunoraClient`.
1128
+ */
1129
+ declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
1130
+ declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
1131
+ export { type ActionHandle, type AgentApi, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
1132
+ /**
1133
+ * Svelte adapter for Lunora (`@lunora/svelte`).
1134
+ *
1135
+ * Thin, idiomatic glue over the framework-neutral `@lunora/client` (no React):
1136
+ * live readable stores you read with `$store`, an optimistic mutation helper,
1137
+ * and the reactive-loader handoff (`hydratePreloaded`). The contract mirrors
1138
+ * `@lunora/react`, re-expressed in Svelte stores: `setLunoraClient` /
1139
+ * `getLunoraClient` are the context provider/consumer; `query` is a live
1140
+ * readable store (React's `useQuery`); `mutation` is an optimistic
1141
+ * `{ data, error, pending, mutate, reset }` (React's `useMutation`); and
1142
+ * `hydratePreloaded` is the SSR-seed-to-live-store handoff (React's
1143
+ * `usePreloadedQuery`).
1144
+ *
1145
+ * The package is plain `.ts` over stores — no `.svelte` component compiler is
1146
+ * required to build or test it.
1147
+ *
1148
+ * Server-side preload helpers (`createServerClient`, `preloadQuery`) live in the
1149
+ * socket-free `@lunora/svelte/server` entry (a re-export of `@lunora/client/ssr`, the
1150
+ * framework-neutral server contract) — import them there in your SvelteKit
1151
+ * `+page.ts` / `+layout.ts` load.
1152
+ */
1153
+ getLunoraClient, hydratePreloaded, infiniteQuery, mutation, mutator, paginatedQuery, presence, query, rateLimit,
1154
+ /**
1155
+ * Svelte adapter for Lunora (`@lunora/svelte`).
1156
+ *
1157
+ * Thin, idiomatic glue over the framework-neutral `@lunora/client` (no React):
1158
+ * live readable stores you read with `$store`, an optimistic mutation helper,
1159
+ * and the reactive-loader handoff (`hydratePreloaded`). The contract mirrors
1160
+ * `@lunora/react`, re-expressed in Svelte stores: `setLunoraClient` /
1161
+ * `getLunoraClient` are the context provider/consumer; `query` is a live
1162
+ * readable store (React's `useQuery`); `mutation` is an optimistic
1163
+ * `{ data, error, pending, mutate, reset }` (React's `useMutation`); and
1164
+ * `hydratePreloaded` is the SSR-seed-to-live-store handoff (React's
1165
+ * `usePreloadedQuery`).
1166
+ *
1167
+ * The package is plain `.ts` over stores — no `.svelte` component compiler is
1168
+ * required to build or test it.
1169
+ *
1170
+ * Server-side preload helpers (`createServerClient`, `preloadQuery`) live in the
1171
+ * socket-free `@lunora/svelte/server` entry (a re-export of `@lunora/client/ssr`, the
1172
+ * framework-neutral server contract) — import them there in your SvelteKit
1173
+ * `+page.ts` / `+layout.ts` load.
1174
+ */
1175
+ setLunoraClient, stream, subscription, voiceAgent };