@lunora/angular 1.0.0-alpha.2 → 1.0.0-alpha.21

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 (31) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.mts +1305 -112
  3. package/dist/index.d.ts +1305 -112
  4. package/dist/index.mjs +1 -5
  5. package/dist/packem_shared/LUNORA_CLIENT-B0pGE0Tv.mjs +1 -0
  6. package/dist/packem_shared/agent-C-GavfBl.mjs +1 -0
  7. package/dist/packem_shared/agentChat-Bay8gA8i.mjs +1 -0
  8. package/dist/packem_shared/agentState-BAfa0QuC.mjs +1 -0
  9. package/dist/packem_shared/agentToolEvents-CBTZ_DsO.mjs +1 -0
  10. package/dist/packem_shared/auth-BTEtMnGG.mjs +1 -0
  11. package/dist/packem_shared/connectionStatus-C53UhkPi.mjs +1 -0
  12. package/dist/packem_shared/flag-BYFWoQTg.mjs +1 -0
  13. package/dist/packem_shared/hydratePreloaded-BKHgpXzQ.mjs +1 -0
  14. package/dist/packem_shared/infiniteQuery-C-T8hD7-.mjs +1 -0
  15. package/dist/packem_shared/liveQuery-DEIqmTPj.mjs +1 -0
  16. package/dist/packem_shared/mutate-DR8Uo8Hs.mjs +1 -0
  17. package/dist/packem_shared/mutator-Cw6jpG06.mjs +1 -0
  18. package/dist/packem_shared/platform-BGZypnc9.mjs +1 -0
  19. package/dist/packem_shared/presence-BMrTlOCF.mjs +1 -0
  20. package/dist/packem_shared/rateLimit-CQazDrPJ.mjs +1 -0
  21. package/dist/packem_shared/stream-CcvHiJf2.mjs +1 -0
  22. package/dist/packem_shared/subscription-DJeoGEDR.mjs +1 -0
  23. package/dist/packem_shared/voiceAgent-CwlzrEjH.mjs +1 -0
  24. package/dist/upload.d.mts +57 -0
  25. package/dist/upload.d.ts +57 -0
  26. package/dist/upload.mjs +1 -0
  27. package/package.json +9 -3
  28. package/dist/packem_shared/LUNORA_CLIENT-DHUfNu9x.mjs +0 -23
  29. package/dist/packem_shared/connectionStatus-BlLodleK.mjs +0 -15
  30. package/dist/packem_shared/liveQuery-D5VQBOgf.mjs +0 -28
  31. package/dist/packem_shared/mutate-D3rEHwbb.mjs +0 -8
package/dist/index.d.mts CHANGED
@@ -1,57 +1,613 @@
1
- import { InjectionToken, EnvironmentProviders, DestroyRef, Signal } from '@angular/core';
2
- import { LunoraClient, LunoraClientOptions, ConnectionStatus, SubscriptionError, FunctionReference, ArgsOf, ReturnOf, MutationCallOptions } from '@lunora/client';
3
- export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, LunoraClientOptions, MutationCallOptions, ReturnOf, SubscriptionError, Unsubscribe } from '@lunora/client';
1
+ import { DestroyRef, Signal, InjectionToken, EnvironmentProviders } from '@angular/core';
2
+ import { FunctionReference, LunoraClient, SubscriptionError, User, LunoraClientOptions, ConnectionStatus, Preloaded, ArgsOf, ReturnOf, MutationCallOptions, MutatorHandle } from '@lunora/client';
3
+ export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, LunoraClientOptions, MutationCallOptions, Preloaded, ReturnOf, SubscriptionError, Unsubscribe } from '@lunora/client';
4
+ import { PaginationStatus } from '@lunora/client/pagination';
5
+ import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
4
6
  export { SKIP } from '@lunora/client/query';
5
7
  /**
6
- * DI token carrying the framework-neutral {@link LunoraClient}. Every reactive
7
- * primitive in this adapter (`liveQuery`, `mutate`, `connectionStatus`) reads the
8
- * client from here, so a single {@link provideLunora} in the application config
9
- * wires the whole app.
10
- *
11
- * The token has a root-scoped default factory, so it resolves even without
12
- * {@link provideLunora}: it builds one same-origin browser client (which opens
13
- * its WebSocket lazily on the first subscription). Call {@link provideLunora} to
14
- * point it at a remote URL or hand it a pre-built client.
15
- */
8
+ * The lifecycle status stored on an agent thread. Client-safe mirror of
9
+ * `@lunora/agent`'s `AgentThreadStatus` re-declared here (rather than imported)
10
+ * so this Angular entry never pulls in the server-only `@lunora/agent` module graph
11
+ * (the adapter stays Angular + `@lunora/client` only). Keep in sync with
12
+ * `packages/agent/src/types.ts`.
13
+ * @experimental
14
+ */
15
+ type AgentThreadStatus = "awaiting_input" | "cancelled" | "error" | "idle" | "running";
16
+ /**
17
+ * The live thread record surfaced by the `agents:agentThread` query. A structural
18
+ * subset of the persisted thread row — every field beyond `status` is optional so
19
+ * the shape stays forgiving as the server schema grows. Keep in sync with the
20
+ * `agent_threads` table in `packages/agent/src/component.ts`.
21
+ * @experimental
22
+ */
23
+ interface AgentThreadRecord {
24
+ createdAt?: number;
25
+ /** The failure message when `status === "error"`. */
26
+ error?: string;
27
+ /** The workflow instance id of the in-flight run — the handle `cancel` targets. */
28
+ instanceId?: string;
29
+ messageCount?: number;
30
+ /** The verified thread owner, when the run was started with one. */
31
+ owner?: string;
32
+ status: AgentThreadStatus;
33
+ title?: string;
34
+ updatedAt?: number;
35
+ }
36
+ /**
37
+ * One persisted (or optimistic) thread message, as `agents:agentMessages`
38
+ * surfaces it. Client-safe mirror of `@lunora/agent`'s `AgentMessageRow` —
39
+ * re-declared here (rather than imported) so this Angular entry never pulls in the
40
+ * server-only `@lunora/agent` module graph. Keep in sync with the
41
+ * `agent_messages` table in `packages/agent/src/component.ts`.
42
+ * @experimental
43
+ */
44
+ interface AgentChatMessage {
45
+ content: string;
46
+ createdAt?: number;
47
+ /**
48
+ * `true` for a client-side optimistic user message not yet acknowledged by
49
+ * the server. Cleared once the durable history carries the matching user turn.
50
+ */
51
+ optimistic?: boolean;
52
+ role: "assistant" | "system" | "tool" | "user";
53
+ seq: number;
54
+ /** Approval lifecycle marker on a human-in-the-loop tool message. */
55
+ status?: "approved" | "awaiting_approval" | "rejected";
56
+ toolCallId?: string;
57
+ toolCalls?: ReadonlyArray<{
58
+ id: string;
59
+ input: unknown;
60
+ name: string;
61
+ }>;
62
+ toolName?: string;
63
+ }
64
+ /**
65
+ * A live token delta streamed while a turn is generating. Client-safe mirror of
66
+ * `@lunora/agent`'s `AgentTokenDelta`. Ephemeral — deltas feed the chat surface's
67
+ * streaming text live and are never replayed; the persisted assistant message
68
+ * stays the single source of truth.
69
+ * @experimental
70
+ */
71
+ interface AgentTokenDelta {
72
+ /** Discriminates the token arm of {@link AgentLiveEvent}; unset on the wire (token is the default). */
73
+ kind?: "token";
74
+ /** The incremental text chunk the model just produced. */
75
+ text: string;
76
+ /** The thread this delta belongs to. */
77
+ threadKey: string;
78
+ /** The zero-based index of the turn producing the delta. */
79
+ turn: number;
80
+ }
81
+ /**
82
+ * A live tool-progress event streamed via `ctx.reportProgress(...)`. Client-safe
83
+ * mirror of `@lunora/agent`'s `AgentProgressEvent`. Ephemeral and `toolCallId`-keyed;
84
+ * surfaced by `agentToolEvents`, ignored by the chat surface's streaming text.
85
+ * @experimental
86
+ */
87
+ interface AgentProgressEvent {
88
+ /** The arbitrary, JSON-serializable payload the tool reported. */
89
+ data: unknown;
90
+ /** Discriminates the progress arm of {@link AgentLiveEvent}. */
91
+ kind: "progress";
92
+ /** The thread this event belongs to. */
93
+ threadKey: string;
94
+ /** The tool call this progress belongs to. */
95
+ toolCallId: string;
96
+ }
97
+ /**
98
+ * A single event on the agent's live-only channel — a streamed token delta or a
99
+ * tool progress event. Client-safe mirror of `@lunora/agent`'s `AgentLiveEvent`.
100
+ * Discriminate on `kind` (`"progress"` for the progress arm; token deltas leave
101
+ * it unset).
102
+ * @experimental
103
+ */
104
+ type AgentLiveEvent = AgentProgressEvent | AgentTokenDelta;
105
+ /**
106
+ * The `agents.agentThread` reference the primitive subscribes to for live thread
107
+ * state (status + the in-flight `instanceId`). A structural subset of the
108
+ * generated `api.agents` surface, so the whole generated `api` object is
109
+ * assignable.
110
+ * @experimental
111
+ */
112
+ interface AgentApi {
113
+ agents: {
114
+ agentThread: FunctionReference<"query", {
115
+ key: string;
116
+ }, Record<string, unknown> | undefined>;
117
+ };
118
+ }
119
+ /**
120
+ * `AgentOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
121
+ * @experimental
122
+ */
123
+ interface AgentOptions {
124
+ /** The generated `api` — its `agents.agentThread` query drives live thread state. */
125
+ api: AgentApi;
126
+ /**
127
+ * Optional app mutation over the agent's cancel path
128
+ * (`ctx.agents.&lt;name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
129
+ * When omitted (or no run is in flight) {@link AgentResult.cancel} is a no-op.
130
+ */
131
+ cancel?: FunctionReference<"mutation">;
132
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
133
+ client?: LunoraClient;
134
+ /**
135
+ * `DestroyRef` whose `onDestroy` tears the live subscription down. Defaults to
136
+ * `inject(DestroyRef)` — the calling component/service.
137
+ */
138
+ destroyRef?: DestroyRef;
139
+ /**
140
+ * The app mutation that starts (or continues) a run — a thin wrapper over
141
+ * `ctx.agents.&lt;name>.run(...)`. Called with `{ threadKey, input }` merged with
142
+ * {@link AgentOptions.runArgs} and the per-call args.
143
+ */
144
+ run: FunctionReference<"mutation">;
145
+ /** Extra args merged into every `run` call (e.g. an `owner` or `title`). */
146
+ runArgs?: Record<string, unknown>;
147
+ /** The thread to observe and drive. */
148
+ threadKey: string;
149
+ }
150
+ /**
151
+ * `AgentResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
152
+ * @experimental
153
+ */
154
+ interface AgentResult {
155
+ /**
156
+ * Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
157
+ * no-op when no `cancel` mutation was supplied or no run is in flight.
158
+ */
159
+ cancel: () => Promise<void>;
160
+ /** `true` while a `run` invocation is in flight. */
161
+ pending: Signal<boolean>;
162
+ /** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
163
+ run: (input: string, args?: Record<string, unknown>) => Promise<void>;
164
+ /** The live thread status, or `undefined` before the thread exists. */
165
+ status: Signal<AgentThreadStatus | undefined>;
166
+ /** The live thread record (status, `instanceId`, …), or `undefined` before it exists. */
167
+ thread: Signal<AgentThreadRecord | undefined>;
168
+ }
169
+ /**
170
+ * A thin agent handle: live thread `status` plus `run` / `cancel`, without the
171
+ * chat message surface. Composes `subscription(api.agents.agentThread)` for live
172
+ * state and drives the run/cancel writes straight on the client — the Angular
173
+ * counterpart to React's `useAgent`, re-expressed with signals. For the full
174
+ * conversation surface (durable history + streaming + approvals) use `agentChat`.
175
+ *
176
+ * `run` and `cancel` stay generic over the app-defined mutations that wrap
177
+ * `ctx.agents.&lt;name>.run` / `.cancel`, so the primitive hard-codes no function
178
+ * names beyond the `agents:*` surface.
179
+ *
180
+ * Call from an injection context (component/service field or constructor); pass an
181
+ * explicit `client` / `destroyRef` to drive it outside one (e.g. in a test).
182
+ * @experimental
183
+ */
184
+ declare const agent: (options: AgentOptions) => AgentResult;
185
+ /** The `agents:agentMessages` reference — live durable thread history. */
186
+ type AgentMessagesReference$1 = FunctionReference<"query", {
187
+ key: string;
188
+ limit?: number;
189
+ }, ReadonlyArray<Record<string, unknown>>>;
190
+ /** The `agents:agentResolveApproval` reference — resolves a human-in-the-loop tool approval. */
191
+ type AgentApprovalReference = FunctionReference<"mutation", {
192
+ decision: "approve" | "reject";
193
+ instanceId: string;
194
+ note?: string;
195
+ threadKey: string;
196
+ toolCallId: string;
197
+ }, {
198
+ resolved: boolean;
199
+ }>;
200
+ /** The `agents:agentThread` reference — live thread status + in-flight `instanceId`. */
201
+ type AgentThreadReference = FunctionReference<"query", {
202
+ key: string;
203
+ }, Record<string, unknown> | undefined>;
204
+ /**
205
+ * An app stream reference that tees the agent's in-flight live events, keyed by
206
+ * thread. Carries token deltas and — since `ctx.reportProgress` rides the same
207
+ * sink — tool progress events; this primitive consumes only the token arm.
208
+ * @experimental
209
+ */
210
+ type AgentTokenStreamReference = FunctionReference<"stream", {
211
+ key: string;
212
+ }, AgentLiveEvent>;
213
+ /**
214
+ * The `agents.*` reference surface the chat primitive reads. A structural subset
215
+ * of the generated `api.agents`, so the whole generated `api` object is
216
+ * assignable.
217
+ * @experimental
218
+ */
219
+ interface AgentChatApi {
220
+ agents: {
221
+ agentMessages: AgentMessagesReference$1;
222
+ agentResolveApproval: AgentApprovalReference;
223
+ agentThread: AgentThreadReference;
224
+ };
225
+ }
226
+ /**
227
+ * `AgentChatOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
228
+ * @experimental
229
+ */
230
+ interface AgentChatOptions {
231
+ /** The generated `api` — its `agents.*` surface provides history, thread state, and approval resolution. */
232
+ api: AgentChatApi;
233
+ /**
234
+ * Optional app mutation over the agent's cancel path
235
+ * (`ctx.agents.&lt;name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
236
+ * When omitted (or no run is in flight) {@link AgentChatResult.cancel} is a
237
+ * no-op.
238
+ */
239
+ cancel?: FunctionReference<"mutation">;
240
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
241
+ client?: LunoraClient;
242
+ /**
243
+ * `DestroyRef` whose `onDestroy` tears the subscriptions + stream down. Defaults
244
+ * to `inject(DestroyRef)` — the calling component/service.
245
+ */
246
+ destroyRef?: DestroyRef;
247
+ /** History depth forwarded to `agents:agentMessages`. */
248
+ limit?: number;
249
+ /**
250
+ * The app mutation that starts (or continues) a run — a thin wrapper over
251
+ * `ctx.agents.&lt;name>.run(...)`. Called with `{ threadKey, input }` merged with
252
+ * {@link AgentChatOptions.sendArgs} and the per-call args.
253
+ */
254
+ send: FunctionReference<"mutation">;
255
+ /** Extra args merged into every `send` call (e.g. an `owner` or `title`). */
256
+ sendArgs?: Record<string, unknown>;
257
+ /**
258
+ * Optional live token-delta stream — an app stream function that tees the
259
+ * agent's in-flight deltas. When omitted {@link AgentChatResult.streamingText}
260
+ * stays empty and the UI updates message-by-message from durable history.
261
+ */
262
+ stream?: AgentTokenStreamReference;
263
+ /** The thread to observe and continue. */
264
+ threadKey: string;
265
+ }
266
+ /**
267
+ * `AgentChatResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
268
+ * @experimental
269
+ */
270
+ interface AgentChatResult {
271
+ /** Approve a paused human-in-the-loop tool call (optionally with a note). */
272
+ approve: (toolCallId: string, note?: string) => Promise<void>;
273
+ /**
274
+ * Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
275
+ * no-op when no `cancel` mutation was supplied or no run is in flight.
276
+ */
277
+ cancel: () => Promise<void>;
278
+ /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
279
+ messages: Signal<ReadonlyArray<AgentChatMessage>>;
280
+ /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
281
+ reject: (toolCallId: string, note?: string) => Promise<void>;
282
+ /** Start (or continue) a run with a user message; extra args merge over `sendArgs`. Appends an optimistic user turn. */
283
+ send: (input: string, args?: Record<string, unknown>) => Promise<void>;
284
+ /** The live thread status, or `undefined` before the thread exists. */
285
+ status: Signal<AgentThreadStatus | undefined>;
286
+ /** The in-flight turn's streamed text — live-only, empty once the turn persists to `messages`. */
287
+ streamingText: Signal<string>;
288
+ }
289
+ /**
290
+ * A first-class agent chat surface: live durable history + in-flight token
291
+ * streaming + the send / approve / reject / cancel writes, keyed by `threadKey` —
292
+ * the Angular counterpart to React's `useAgentChat`, re-expressed with signals.
293
+ *
294
+ * It composes the existing primitives rather than adding transport:
295
+ * `subscription(api.agents.agentMessages)` for durable history,
296
+ * `subscription(api.agents.agentThread)` for live status + the in-flight
297
+ * `instanceId`, {@link stream} over an app token stream for in-flight deltas, and
298
+ * the client's own `mutation` for the writes (`api.agents.agentResolveApproval` for
299
+ * approvals; app-defined wrappers for `send`/`cancel`). Only the `agents:*` surface
300
+ * is hard-coded — `send`/`cancel`/`stream` stay generic references.
301
+ *
302
+ * A `send` optimistically appends the user turn so it renders immediately; the
303
+ * optimistic row clears once the durable history carries the acknowledged turn.
304
+ * `streamingText` is live-only: it holds the current turn's streamed text and
305
+ * empties as soon as that turn's assistant message lands in `messages` (the
306
+ * persisted message is the source of truth), consistent with the loop's
307
+ * replay-safe, live-only delta design.
308
+ *
309
+ * Call from an injection context (component/service field or constructor); pass an
310
+ * explicit `client` / `destroyRef` to drive it outside one (e.g. in a test).
311
+ * @experimental
312
+ */
313
+ declare const agentChat: (options: AgentChatOptions) => AgentChatResult;
314
+ /**
315
+ * The `agents.agentState` reference the primitive subscribes to for the thread's
316
+ * live synced state. A structural subset of the generated `api.agents` surface
317
+ * (like `AgentApi` for `agentThread`), so the whole generated `api` object is
318
+ * assignable. Client-safe: no `@lunora/agent` import — the per-agent state type is
319
+ * mirrored by the primitive's generic `T`, since codegen pins the reference return
320
+ * as an optional record (it never evaluates agent config).
321
+ * @experimental
322
+ */
323
+ interface AgentStateApi {
324
+ agents: {
325
+ agentState: FunctionReference<"query", {
326
+ key: string;
327
+ }, Record<string, unknown> | undefined>;
328
+ };
329
+ }
330
+ /**
331
+ * `AgentStateOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
332
+ * @experimental
333
+ */
334
+ interface AgentStateOptions {
335
+ /** The generated `api` — its `agents.agentState` query drives live thread state. */
336
+ api: AgentStateApi;
337
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
338
+ client?: LunoraClient;
339
+ /**
340
+ * `DestroyRef` whose `onDestroy` tears the subscription down. Defaults to
341
+ * `inject(DestroyRef)` — the calling component/service.
342
+ */
343
+ destroyRef?: DestroyRef;
344
+ /** The thread whose synced state to observe. */
345
+ threadKey: string;
346
+ }
347
+ /**
348
+ * `AgentStateResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
349
+ * @experimental
350
+ */
351
+ interface AgentStateResult<T> {
352
+ /** The subscription error, if the live channel reported one. */
353
+ error: Signal<SubscriptionError | undefined>;
354
+ /** The live synced state, or `undefined` before it is seeded/first pushed. */
355
+ state: Signal<T | undefined>;
356
+ }
357
+ /**
358
+ * Subscribe to an agent thread's synced state — the `setState`-style value a tool
359
+ * writes with `ctx.setState(...)`, seeded by `defineAgent({ initialState })`. A
360
+ * thin wrapper over `subscription(api.agents.agentState, { key })`: the server
361
+ * pushes a fresh frame whenever the state changes (the dedicated query's per-socket
362
+ * JSON memo suppresses no-op pushes on unrelated thread writes), so `state` updates
363
+ * only on a real `setState`. The Angular counterpart to React's `useAgentState`,
364
+ * re-expressed with signals.
365
+ *
366
+ * Generic over the app's state shape (`agentState&lt;SupportState>(...)`, itself a
367
+ * record) — the reference is typed as an optional record because codegen cannot see
368
+ * the per-agent state type; the generic casts to `T`. The `extends` bound (not a
369
+ * bare unbounded type parameter) is required: this `.ts` file is parsed JSX-aware by
370
+ * the bundler, where an unbounded type-param arrow is ambiguous with a JSX element.
371
+ *
372
+ * Call from an injection context (component/service field or constructor); pass an
373
+ * explicit `client` / `destroyRef` to drive it outside one (e.g. in a test).
374
+ * @experimental
375
+ */
376
+ declare const agentState: <T extends Record<string, unknown> = Record<string, unknown>>(options: AgentStateOptions) => AgentStateResult<T>;
377
+ /** The `agents:agentMessages` reference — live durable thread history. */
378
+ type AgentMessagesReference = FunctionReference<"query", {
379
+ key: string;
380
+ limit?: number;
381
+ }, ReadonlyArray<Record<string, unknown>>>;
382
+ /**
383
+ * An app stream reference that tees the agent's in-flight live events, keyed by
384
+ * thread. Carries token deltas and tool progress events; this primitive consumes
385
+ * only the progress arm (`kind === "progress"`).
386
+ */
387
+ type AgentLiveStreamReference = FunctionReference<"stream", {
388
+ key: string;
389
+ }, AgentLiveEvent>;
390
+ /**
391
+ * The `agents.*` reference surface the tool-events primitive reads. A structural
392
+ * subset of the generated `api.agents`, so the whole generated `api` object is
393
+ * assignable.
394
+ * @experimental
395
+ */
396
+ interface AgentToolEventsApi {
397
+ agents: {
398
+ agentMessages: AgentMessagesReference;
399
+ };
400
+ }
401
+ /**
402
+ * `AgentToolEventsOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
403
+ * @experimental
404
+ */
405
+ interface AgentToolEventsOptions {
406
+ /** The generated `api` — its `agents.agentMessages` query provides the durable tool lifecycle. */
407
+ api: AgentToolEventsApi;
408
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
409
+ client?: LunoraClient;
410
+ /**
411
+ * `DestroyRef` whose `onDestroy` tears the subscription + stream down. Defaults
412
+ * to `inject(DestroyRef)` — the calling component/service.
413
+ */
414
+ destroyRef?: DestroyRef;
415
+ /** History depth forwarded to `agents:agentMessages`. */
416
+ limit?: number;
417
+ /**
418
+ * Optional live event stream — the same app stream function `agentChat` uses.
419
+ * When supplied, ephemeral `ctx.reportProgress(...)` events for the thread are
420
+ * surfaced as `{ type: "progress" }` entries; when omitted only the durable
421
+ * lifecycle (call / result / awaiting-approval) is returned.
422
+ */
423
+ stream?: AgentLiveStreamReference;
424
+ /** The thread whose tool activity to observe. */
425
+ threadKey: string;
426
+ }
427
+ /**
428
+ * A single tool-lifecycle event for a thread. The durable arms
429
+ * (`call`/`result`/`awaiting-approval`) are derived from `agents:agentMessages`
430
+ * and carry the persisted `seq`; the ephemeral `progress` arm comes live off the
431
+ * stream and has no `seq`. Discriminate on `type`.
432
+ * @experimental
433
+ */
434
+ type AgentToolEvent = {
435
+ data: unknown;
436
+ toolCallId: string;
437
+ type: "progress";
438
+ } | {
439
+ input: unknown;
440
+ seq: number;
441
+ toolCallId: string;
442
+ toolName: string;
443
+ type: "call";
444
+ } | {
445
+ output: string;
446
+ seq: number;
447
+ status?: "approved" | "rejected";
448
+ toolCallId?: string;
449
+ toolName?: string;
450
+ type: "result";
451
+ } | {
452
+ seq: number;
453
+ toolCallId?: string;
454
+ toolName?: string;
455
+ type: "awaiting-approval";
456
+ };
457
+ /**
458
+ * `AgentToolEventsResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
459
+ * @experimental
460
+ */
461
+ interface AgentToolEventsResult {
462
+ /**
463
+ * The thread's tool events: the durable lifecycle (oldest first, by `seq`)
464
+ * followed by any in-flight ephemeral progress events, recomputed from the live
465
+ * subscription + stream. Treat as derived, not identity-stable.
466
+ */
467
+ events: Signal<ReadonlyArray<AgentToolEvent>>;
468
+ }
469
+ /**
470
+ * A focused view of a thread's tool activity: tool calls, their results,
471
+ * human-in-the-loop approval pauses, and live `ctx.reportProgress(...)` events —
472
+ * without the full chat message surface. The Angular counterpart to React's
473
+ * `useAgentToolEvents`, re-expressed as a `computed` signal.
474
+ *
475
+ * It composes the existing primitives rather than adding transport:
476
+ * `subscription(api.agents.agentMessages)` for the durable lifecycle and
477
+ * {@link stream} over the optional app event stream for ephemeral progress.
478
+ * Progress events are live-only (the durable path never emits them): they ride the
479
+ * same sink as token deltas and are surfaced here, correlated to their tool call by
480
+ * `toolCallId`. For the conversational surface (messages + streaming text +
481
+ * approvals) use `agentChat`; this primitive is the tool-observability slice.
482
+ *
483
+ * Call from an injection context (component/service field or constructor); pass an
484
+ * explicit `client` / `destroyRef` to drive it outside one (e.g. in a test).
485
+ * @experimental
486
+ */
487
+ declare const agentToolEvents: (options: AgentToolEventsOptions) => AgentToolEventsResult;
488
+ /**
489
+ * `AuthOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
490
+ * @experimental
491
+ */
492
+ interface AuthOptions {
493
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
494
+ client?: LunoraClient;
495
+ /** `DestroyRef` whose `onDestroy` removes the listeners. Defaults to `inject(DestroyRef)`. */
496
+ destroyRef?: DestroyRef;
497
+ }
498
+ /**
499
+ * `AuthResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
500
+ * @experimental
501
+ */
502
+ interface AuthResult {
503
+ /** Set the auth token (sign-in / sign-out). */
504
+ setToken: (token: string | null) => void;
505
+ /** The current auth token, or `null`. */
506
+ token: Signal<string | null>;
507
+ /** The resolved user from `store.getUser()`, or `null`. */
508
+ user: Signal<User | null>;
509
+ }
510
+ /**
511
+ * Token + identity plumbing for Angular. `token` is a signal tracking the
512
+ * client's auth token; `user` is a signal resolved from `getCurrentUser()`
513
+ * whenever the token changes. `setToken(jwt)` after sign-in makes subsequent
514
+ * RPC calls carry the `Authorization` header.
515
+ *
516
+ * Multiple `auth` instances on the same client share a single per-client
517
+ * identity store (from `@lunora/client/auth`) — a `setToken` from one component
518
+ * re-renders every watcher with the freshly-resolved user.
519
+ *
520
+ * Call from an injection context (component/service field or constructor):
521
+ * ```ts
522
+ * const { token, user, setToken } = auth();
523
+ * ```
524
+ * @experimental
525
+ */
526
+ declare const auth: (options?: AuthOptions) => AuthResult;
527
+ /**
528
+ * `AuthGateResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
529
+ * @experimental
530
+ */
531
+ interface AuthGateResult {
532
+ /** `true` once a token is set and the user has resolved. */
533
+ isAuthenticated: Signal<boolean>;
534
+ /** `true` while a token is set but the user hasn't resolved yet. */
535
+ isLoading: Signal<boolean>;
536
+ }
537
+ /**
538
+ * Derived auth-gate signals for template gating (Angular's `\@if` control
539
+ * flow), built on {@link auth}. Angular has no JSX-style `Authenticated` slot
540
+ * component the way React/Vue/Solid do, so this exposes the same three-state
541
+ * logic as two booleans instead: a token with no resolved user yet is
542
+ * `isLoading`; a token with a resolved user is `isAuthenticated`; no token is
543
+ * neither (the signed-out state a template checks for with a plain `\@else`).
544
+ *
545
+ * Call from an injection context (component/service field or constructor):
546
+ * ```ts
547
+ * protected readonly authState = authGate();
548
+ * // template: \@if (authState.isAuthenticated()) { ... } \@else if (authState.isLoading()) { ... }
549
+ * ```
550
+ * @experimental
551
+ */
552
+ declare const authGate: (options?: AuthOptions) => AuthGateResult;
553
+ /**
554
+ * DI token carrying the framework-neutral {@link LunoraClient}. Every reactive
555
+ * primitive in this adapter (`liveQuery`, `mutate`, `connectionStatus`) reads the
556
+ * client from here, so a single {@link provideLunora} in the application config
557
+ * wires the whole app.
558
+ *
559
+ * The token has a root-scoped default factory, so it resolves even without
560
+ * {@link provideLunora}: it builds one same-origin browser client (which opens
561
+ * its WebSocket lazily on the first subscription). Call {@link provideLunora} to
562
+ * point it at a remote URL or hand it a pre-built client.
563
+ * @experimental
564
+ */
16
565
  declare const LUNORA_CLIENT: InjectionToken<LunoraClient>;
17
566
  /**
18
- * Options accepted by {@link provideLunora}. Identical to {@link LunoraClientOptions}
19
- * except `url` is optional — it defaults to the page origin in the browser (and to
20
- * `""` on the server; pass an explicit `url` for SSR data-loading — see
21
- * {@link sameOriginUrl}).
22
- */
567
+ * Options accepted by {@link provideLunora}. Identical to {@link LunoraClientOptions}
568
+ * except `url` is optional — it defaults to the page origin in the browser (and to
569
+ * `""` on the server; pass an explicit `url` for SSR data-loading — see
570
+ * {@link sameOriginUrl}).
571
+ * @experimental
572
+ */
23
573
  type ProvideLunoraOptions = Omit<LunoraClientOptions, "url"> & {
24
574
  url?: string;
25
575
  };
26
576
  /**
27
- * Wire a {@link LunoraClient} into the application injector. Add the result to the
28
- * `providers` array of an Angular application config (or any `EnvironmentProviders`
29
- * consumer):
30
- *
31
- * ```ts
32
- * export const appConfig: ApplicationConfig = {
33
- * providers: [provideLunora({ url: "https://api.example.com" })],
34
- * };
35
- * ```
36
- *
37
- * Pass {@link LunoraClientOptions} to configure a fresh client (URL defaults to
38
- * the page origin), or hand in an already-constructed {@link LunoraClient} to
39
- * share one instance (e.g. a client you also preload against during SSR).
40
- */
577
+ * Wire a {@link LunoraClient} into the application injector. Add the result to the
578
+ * `providers` array of an Angular application config (or any `EnvironmentProviders`
579
+ * consumer):
580
+ *
581
+ * ```ts
582
+ * export const appConfig: ApplicationConfig = {
583
+ * providers: [provideLunora({ url: "https://api.example.com" })],
584
+ * };
585
+ * ```
586
+ *
587
+ * Pass {@link LunoraClientOptions} to configure a fresh client (URL defaults to
588
+ * the page origin), or hand in an already-constructed {@link LunoraClient} to
589
+ * share one instance (e.g. a client you also preload against during SSR).
590
+ * @experimental
591
+ */
41
592
  declare const provideLunora: (optionsOrClient?: LunoraClient | ProvideLunoraOptions) => EnvironmentProviders;
42
593
  /**
43
- * Read the {@link LunoraClient} from the current injector. Call inside an
44
- * injection context (a component/service field initializer or constructor, or a
45
- * `runInInjectionContext` callback). Use it to hold the client for imperative
46
- * calls — e.g. `mutation`/`action` from event handlers, which run outside an
47
- * injection context:
48
- *
49
- * ```ts
50
- * private readonly client = injectLunoraClient();
51
- * send = (text: string) => this.client.mutation(api.messages.send, { text });
52
- * ```
53
- */
594
+ * Read the {@link LunoraClient} from the current injector. Call inside an
595
+ * injection context (a component/service field initializer or constructor, or a
596
+ * `runInInjectionContext` callback). Use it to hold the client for imperative
597
+ * calls — e.g. `mutation`/`action` from event handlers, which run outside an
598
+ * injection context:
599
+ *
600
+ * ```ts
601
+ * private readonly client = injectLunoraClient();
602
+ * send = (text: string) => this.client.mutation(api.messages.send, { text });
603
+ * ```
604
+ * @experimental
605
+ */
54
606
  declare const injectLunoraClient: () => LunoraClient;
607
+ /**
608
+ * `ConnectionStatusOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
609
+ * @experimental
610
+ */
55
611
  interface ConnectionStatusOptions {
56
612
  /** Client to observe. Defaults to the injected `LUNORA_CLIENT`. */
57
613
  client?: LunoraClient;
@@ -59,88 +615,725 @@ interface ConnectionStatusOptions {
59
615
  destroyRef?: DestroyRef;
60
616
  }
61
617
  /**
62
- * A `signal` of the client's aggregate live-socket status across all shard
63
- * connections. Reads the current status synchronously and updates on every
64
- * transition (`idle` → `connecting` → `connected` → `offline`). The Angular
65
- * equivalent of `@lunora/react`'s `useConnectionStatus`.
66
- *
67
- * The listener is removed when the owning `DestroyRef` fires. Call from an
68
- * injection context (component/service field or constructor).
69
- */
618
+ * A `signal` of the client's aggregate live-socket status across all shard
619
+ * connections. Reads the current status synchronously and updates on every
620
+ * transition (`idle` → `connecting` → `connected` → `offline`). The Angular
621
+ * equivalent of `@lunora/react`'s `useConnectionStatus`.
622
+ *
623
+ * The listener is removed when the owning `DestroyRef` fires. Call from an
624
+ * injection context (component/service field or constructor).
625
+ * @experimental
626
+ */
70
627
  declare const connectionStatus: (options?: ConnectionStatusOptions) => Signal<ConnectionStatus>;
628
+ /**
629
+ * The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags.
630
+ * @experimental
631
+ */
632
+ type FlagValue = boolean | number | string | Record<string, unknown> | unknown[] | null;
633
+ /**
634
+ * Targeting context bag forwarded to the OpenFeature provider.
635
+ * @experimental
636
+ */
637
+ type FlagContext = Record<string, unknown>;
638
+ /**
639
+ * `FlagOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
640
+ * @experimental
641
+ */
642
+ interface FlagOptions {
643
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
644
+ client?: LunoraClient;
645
+ /**
646
+ * Per-call targeting context merged on top of the app's default `identify`
647
+ * targeting key.
648
+ */
649
+ context?: FlagContext;
650
+ /** `DestroyRef` whose `onDestroy` tears down the subscription. Defaults to `inject(DestroyRef)`. */
651
+ destroyRef?: DestroyRef;
652
+ }
653
+ /**
654
+ * Subscribe to a single feature flag, live over Lunora's WebSocket.
655
+ *
656
+ * The returned signal holds `defaultValue` until the first evaluation lands, then
657
+ * the server's resolved value — re-pushed whenever the provider re-evaluates.
658
+ * The flag's kind is inferred from `defaultValue`'s runtime type, so
659
+ * `flag("dark", false)` reads a boolean and `flag("hero", "control")` a string.
660
+ *
661
+ * Evaluation runs through whatever OpenFeature provider the app wired in
662
+ * `lunora/flags.ts`; the read never throws — a provider error resolves the
663
+ * default (the same fail-open contract as server-side `ctx.flags`).
664
+ *
665
+ * Call from an injection context:
666
+ * ```ts
667
+ * readonly darkMode = flag("dark-mode", false);
668
+ * ```
669
+ * @experimental
670
+ */
671
+ declare const flag: <T extends FlagValue>(key: string, defaultValue: T, options?: FlagOptions) => Signal<T>;
672
+ /**
673
+ * `FlagsOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
674
+ * @experimental
675
+ */
676
+ interface FlagsOptions {
677
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
678
+ client?: LunoraClient;
679
+ /**
680
+ * Targeting context shared by every flag in the set, merged on top of the
681
+ * app's default `identify` targeting key.
682
+ */
683
+ context?: FlagContext;
684
+ /** `DestroyRef` whose `onDestroy` tears down the subscriptions. Defaults to `inject(DestroyRef)`. */
685
+ destroyRef?: DestroyRef;
686
+ }
687
+ /**
688
+ * Subscribe to several feature flags at once, live over Lunora's WebSocket.
689
+ *
690
+ * Pass a record of `key → defaultValue`; each flag's kind is inferred from its
691
+ * default, and the returned signal holds the same-shaped record with resolved
692
+ * values (the defaults until each evaluation lands).
693
+ *
694
+ * Call from an injection context:
695
+ * ```ts
696
+ * readonly features = flags({ "dark-mode": false, "new-editor": false });
697
+ * ```
698
+ * @experimental
699
+ */
700
+ declare const flags: <T extends Record<string, FlagValue>>(flagDefaults: T, options?: FlagsOptions) => Signal<T>;
701
+ /**
702
+ * `HydratePreloadedOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
703
+ * @experimental
704
+ */
705
+ interface HydratePreloadedOptions {
706
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
707
+ client?: LunoraClient;
708
+ /** `DestroyRef` whose `onDestroy` tears the subscription down. Defaults to `inject(DestroyRef)`. */
709
+ destroyRef?: DestroyRef;
710
+ }
711
+ /**
712
+ * `HydratePreloadedResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
713
+ * @experimental
714
+ */
715
+ interface HydratePreloadedResult<T> {
716
+ /** The latest value pushed by the server. Seeded synchronously from the preloaded value. */
717
+ data: Signal<T | undefined>;
718
+ /** The latest subscription error, or `undefined`. */
719
+ error: Signal<SubscriptionError | undefined>;
720
+ }
721
+ /**
722
+ * Hydrate a query from a {@link Preloaded} token produced by `preloadQuery`
723
+ * during SSR, then keep it live — the Angular half of the reactive-loader
724
+ * handoff.
725
+ *
726
+ * The returned signal is seeded **synchronously** from `preloaded.value`, so the
727
+ * very first read (during hydration) shows the server value: no loading flash,
728
+ * no hydration mismatch. After seeding it opens a WebSocket subscription on the
729
+ * same `(functionPath, args, shardKey)` the SSR loader used, so every later
730
+ * server delta updates the signal exactly like `liveQuery`.
731
+ *
732
+ * The subscription tears down when the owning `DestroyRef` fires.
733
+ *
734
+ * Call from an injection context:
735
+ * ```ts
736
+ * readonly { data, error } = hydratePreloaded(preloadedMessages);
737
+ * ```
738
+ * @experimental
739
+ */
740
+ declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, options?: HydratePreloadedOptions) => HydratePreloadedResult<T>;
741
+ /**
742
+ * `LiveQueryOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
743
+ * @experimental
744
+ */
71
745
  interface LiveQueryOptions {
72
746
  /**
73
- * Client to bind to. Defaults to the injected `LUNORA_CLIENT`; pass one
74
- * explicitly to use `liveQuery` outside an injection context (or in a test).
75
- */
747
+ * Client to bind to. Defaults to the injected `LUNORA_CLIENT`; pass one
748
+ * explicitly to use `liveQuery` outside an injection context (or in a test).
749
+ */
76
750
  client?: LunoraClient;
77
751
  /**
78
- * `DestroyRef` whose `onDestroy` tears the subscription down. Defaults to
79
- * `inject(DestroyRef)` — the calling component/service — so it closes when that
80
- * component is destroyed. Pass one explicitly to control the lifetime yourself.
81
- */
752
+ * `DestroyRef` whose `onDestroy` tears the subscription down. Defaults to
753
+ * `inject(DestroyRef)` — the calling component/service — so it closes when that
754
+ * component is destroyed. Pass one explicitly to control the lifetime yourself.
755
+ */
82
756
  destroyRef?: DestroyRef;
83
757
  /**
84
- * Called when the subscription errors after the initial attach — the async
85
- * error channel `createQuerySubscription` only wires when a sink is present.
86
- * Without it, a post-attach failure is dropped silently: the signal simply
87
- * stops updating with no error state exposed. Pass a handler to surface it
88
- * (log, toast, set an error signal of your own).
89
- */
758
+ * Called when the subscription errors after the initial attach — the async
759
+ * error channel `createQuerySubscription` only wires when a sink is present.
760
+ * Without it, a post-attach failure is dropped silently: the signal simply
761
+ * stops updating with no error state exposed. Pass a handler to surface it
762
+ * (log, toast, set an error signal of your own).
763
+ */
90
764
  onError?: (error: SubscriptionError) => void;
91
765
  /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
92
766
  shardKey?: string;
93
767
  }
94
768
  /**
95
- * Subscribe to a server query and mirror its value into an Angular `signal`.
96
- *
97
- * Reads `undefined` until the first server frame lands, then updates on every
98
- * delta the WebSocket pushes. The underlying subscription is torn down
99
- * automatically when the owning `DestroyRef` fires (the component/service is
100
- * destroyed), so there is no leaked socket subscription.
101
- *
102
- * Call it from an injection context (a component/service field initializer or
103
- * constructor) so the default `inject(DestroyRef)` resolves the caller's
104
- * lifetime:
105
- *
106
- * ```ts
107
- * export class MessagesComponent {
108
- * readonly messages = liveQuery(api.messages.list, { channelId: "general" });
109
- * }
110
- * ```
111
- *
112
- * Pass `"skip"` (the `SKIP` sentinel from `@lunora/client/query`) as `args` to
113
- * short-circuit — no network call, no socket; the signal stays `undefined`. To
114
- * call outside an injection context (e.g. lazily in `ngOnInit`), supply `client`
115
- * and `destroyRef` via {@link LiveQueryOptions}.
116
- */
769
+ * Subscribe to a server query and mirror its value into an Angular `signal`.
770
+ *
771
+ * Reads `undefined` until the first server frame lands, then updates on every
772
+ * delta the WebSocket pushes. The underlying subscription is torn down
773
+ * automatically when the owning `DestroyRef` fires (the component/service is
774
+ * destroyed), so there is no leaked socket subscription.
775
+ *
776
+ * Call it from an injection context (a component/service field initializer or
777
+ * constructor) so the default `inject(DestroyRef)` resolves the caller's
778
+ * lifetime:
779
+ *
780
+ * ```ts
781
+ * export class MessagesComponent {
782
+ * readonly messages = liveQuery(api.messages.list, { channelId: "general" });
783
+ * }
784
+ * ```
785
+ *
786
+ * Pass `"skip"` (the `SKIP` sentinel from `@lunora/client/query`) as `args` to
787
+ * short-circuit — no network call, no socket; the signal stays `undefined`. To
788
+ * call outside an injection context (e.g. lazily in `ngOnInit`), supply `client`
789
+ * and `destroyRef` via {@link LiveQueryOptions}.
790
+ * @experimental
791
+ */
117
792
  declare const liveQuery: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip", options?: LiveQueryOptions) => Signal<ReturnOf<F> | undefined>;
793
+ /**
794
+ * `MutateOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
795
+ * @experimental
796
+ */
118
797
  interface MutateOptions<F extends FunctionReference> extends MutationCallOptions<unknown, unknown, ArgsOf<F>> {
119
798
  /**
120
- * Client to run the mutation on. Defaults to the injected `LUNORA_CLIENT`.
121
- * Because mutations usually fire from event handlers — which run *outside* an
122
- * injection context — capture the client once (`injectLunoraClient()` in a
123
- * field) and pass it here, or call `client.mutation(...)` directly.
124
- */
125
- client?: LunoraClient;
126
- }
127
- /**
128
- * Run a Lunora mutation and resolve with the server result (rejects on failure).
129
- *
130
- * Optimistic updates stay client-owned: the `optimistic` / `optimisticUpdate`
131
- * call options pass straight through to `client.mutation`, which applies and
132
- * rolls them back against the live subscription cache — the same cache
133
- * `liveQuery` reads, so an optimistic write reflects immediately and
134
- * reverts on failure. The client's offline queue also engages when the socket is
135
- * down, so the write stays durable across reconnects.
136
- *
137
- * ```ts
138
- * private readonly client = injectLunoraClient();
139
- * send = (text: string) => mutate(api.messages.send, { text }, { client: this.client });
140
- * ```
141
- *
142
- * When called from within an injection context you may omit `client` and let it
143
- * resolve from the injector.
144
- */
799
+ * Client to run the mutation on. Defaults to the injected `LUNORA_CLIENT`.
800
+ * Because mutations usually fire from event handlers — which run *outside* an
801
+ * injection context — capture the client once (`injectLunoraClient()` in a
802
+ * field) and pass it here, or call `client.mutation(...)` directly.
803
+ */
804
+ client?: LunoraClient;
805
+ }
806
+ /**
807
+ * Run a Lunora mutation and resolve with the server result (rejects on failure).
808
+ *
809
+ * Optimistic updates stay client-owned: the `optimistic` / `optimisticUpdate`
810
+ * call options pass straight through to `client.mutation`, which applies and
811
+ * rolls them back against the live subscription cache — the same cache
812
+ * `liveQuery` reads, so an optimistic write reflects immediately and
813
+ * reverts on failure. The client's offline queue also engages when the socket is
814
+ * down, so the write stays durable across reconnects.
815
+ *
816
+ * ```ts
817
+ * private readonly client = injectLunoraClient();
818
+ * send = (text: string) => mutate(api.messages.send, { text }, { client: this.client });
819
+ * ```
820
+ *
821
+ * When called from within an injection context you may omit `client` and let it
822
+ * resolve from the injector.
823
+ * @experimental
824
+ */
145
825
  declare const mutate: <F extends FunctionReference>(reference: F, args: ArgsOf<F>, options?: MutateOptions<F>) => Promise<ReturnOf<F>>;
146
- export { type ConnectionStatusOptions, LUNORA_CLIENT, type LiveQueryOptions, type MutateOptions, type ProvideLunoraOptions, connectionStatus, injectLunoraClient, liveQuery, mutate, provideLunora };
826
+ /**
827
+ * `MutatorResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
828
+ * @experimental
829
+ */
830
+ interface MutatorResult<TArgs> {
831
+ /** The latest invocation's error, or `undefined`. */
832
+ error: Signal<Error | undefined>;
833
+ /** `true` when the latest invocation rejected. */
834
+ isError: Signal<boolean>;
835
+ /** Run the mutator; resolves once the write is persisted, rejects on failure. */
836
+ mutate: (args: TArgs) => Promise<void>;
837
+ /** `true` while ANY invocation from this handle is in flight. */
838
+ pending: Signal<boolean>;
839
+ /** Clear the latest `error` back to idle. */
840
+ reset: () => void;
841
+ }
842
+ /**
843
+ * Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
844
+ * custom-mutator handle from `` `@lunora/db` ``'s `bindMutators` — the Angular
845
+ * equivalent of `` `@lunora/react` ``'s `useMutator`. The optimistic overlay and
846
+ * server-authoritative push are owned by the bound handle; this function only
847
+ * surfaces reactive state for the in-flight/error lifecycle.
848
+ *
849
+ * `pending` is ref-counted across overlapping invocations of THIS handle, so it
850
+ * clears only once every concurrent call has settled.
851
+ *
852
+ * Does NOT require an injection context — it works with plain signals.
853
+ *
854
+ * ```ts
855
+ * private readonly collection = bindMutators(collections);
856
+ * readonly mutator = mutator(this.collection.insert);
857
+ * ```
858
+ * @experimental
859
+ */
860
+ declare const mutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorResult<TArgs>;
861
+ /** The args a paginated query exposes minus the framework-supplied page cursor. */
862
+ type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOfRaw<F>, "paginationOpts">;
863
+ /** The element type of the `page` array a paginated query returns. */
864
+ type PageItemOf<F extends FunctionReference> = ReturnTypeOf<F> extends {
865
+ page: (infer T)[];
866
+ } ? T : unknown;
867
+ type ArgsOfRaw<F extends FunctionReference> = F extends FunctionReference<"query", infer A> ? A : never;
868
+ type ReturnTypeOf<F extends FunctionReference> = F extends FunctionReference<"query", unknown, infer R> ? R : never;
869
+ /**
870
+ * Options for the paginated query — part of the experimental `@lunora/angular` API and may change without a major version bump.
871
+ * @experimental
872
+ */
873
+ interface PaginatedQueryOptions {
874
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
875
+ client?: LunoraClient;
876
+ /** `DestroyRef` whose `onDestroy` tears down the subscriptions. Defaults to `inject(DestroyRef)`. */
877
+ destroyRef?: DestroyRef;
878
+ /** Page size for the first page (and the default for `loadMore`). */
879
+ initialNumItems: number;
880
+ /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
881
+ shardKey?: string;
882
+ }
883
+ /**
884
+ * `PaginatedQueryResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
885
+ * @experimental
886
+ */
887
+ interface PaginatedQueryResult<T> {
888
+ /** `true` while the first page or a `loadMore` page is in flight. */
889
+ isLoading: Signal<boolean>;
890
+ /** Request the next page. A no-op unless `status === "CanLoadMore"`. */
891
+ loadMore: (numberItems: number) => void;
892
+ /** Flattened items across every loaded page, in order. */
893
+ results: Signal<T[]>;
894
+ /** The pagination status. */
895
+ status: Signal<PaginationStatus>;
896
+ }
897
+ /**
898
+ * `InfiniteQueryResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
899
+ * @experimental
900
+ */
901
+ interface InfiniteQueryResult<T> {
902
+ /** Request the next page. A no-op unless `status === "CanLoadMore"`. */
903
+ fetchNextPage: (numberItems?: number) => void;
904
+ /** `true` when the loaded tail reports it can load another page. */
905
+ hasNextPage: Signal<boolean>;
906
+ /** `true` while a `fetchNextPage` page (beyond the first) is in flight. */
907
+ isFetchingNextPage: Signal<boolean>;
908
+ /** `true` while the first page is in flight. */
909
+ isLoading: Signal<boolean>;
910
+ /** One inner array per loaded page, in order; unresolved pages are omitted. */
911
+ pages: Signal<T[][]>;
912
+ /** The pagination status. */
913
+ status: Signal<PaginationStatus>;
914
+ }
915
+ /**
916
+ * Subscribe to a reactively-paginated query and grow the feed page by page.
917
+ *
918
+ * The query function must accept a `paginationOpts: { numItems, cursor,
919
+ * endCursor }` arg and return a `PaginationResult`. Pages are tracked as an
920
+ * ordered list of stable boundary cursors; each loaded page is a live
921
+ * subscription over a FIXED `(lower, upper]` range.
922
+ *
923
+ * `loadMore` appends the next page off the open-ended tail's `continueCursor`;
924
+ * it is a no-op unless `status === "CanLoadMore"`.
925
+ *
926
+ * Call from an injection context:
927
+ * ```ts
928
+ * readonly messages = paginatedQuery(api.messages.list, {}, { initialNumItems: 20 });
929
+ * ```
930
+ * @experimental
931
+ */
932
+ declare const paginatedQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip", options: PaginatedQueryOptions) => PaginatedQueryResult<PageItemOf<F>>;
933
+ /**
934
+ * Subscribe to a reactively-paginated query and expose its pages discretely.
935
+ *
936
+ * Shares `paginatedQuery`'s reactive-pagination engine but keeps each page as
937
+ * its own inner array rather than flattening them, and adds the TanStack-Query-
938
+ * style `fetchNextPage` / `hasNextPage` / `isFetchingNextPage` shape.
939
+ *
940
+ * Call from an injection context:
941
+ * ```ts
942
+ * readonly feed = infiniteQuery(api.messages.list, {}, { initialNumItems: 20 });
943
+ * ```
944
+ * @experimental
945
+ */
946
+ declare const infiniteQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip", options: PaginatedQueryOptions) => InfiniteQueryResult<PageItemOf<F>>;
947
+ /**
948
+ * `HeartbeatReference` is part of the experimental `@lunora/angular` API and may change without a major version bump.
949
+ * @experimental
950
+ */
951
+ type HeartbeatReference = FunctionReference<"mutation", {
952
+ data?: Record<string, unknown>;
953
+ roomId: string;
954
+ sessionId: string;
955
+ }>;
956
+ /**
957
+ * `ListPresentReference` is part of the experimental `@lunora/angular` API and may change without a major version bump.
958
+ * @experimental
959
+ */
960
+ type ListPresentReference = FunctionReference<"query", {
961
+ roomId: string;
962
+ }>;
963
+ /**
964
+ * `PresenceOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
965
+ * @experimental
966
+ */
967
+ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentReference> {
968
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
969
+ client?: LunoraClient;
970
+ /** Awareness blob for the first heartbeat (selection, cursor, name, color…). */
971
+ data?: Record<string, unknown>;
972
+ /** `DestroyRef` whose `onDestroy` cleans up. Defaults to `inject(DestroyRef)`. */
973
+ destroyRef?: DestroyRef;
974
+ /** The `api.*` reference for the presence heartbeat mutation. */
975
+ heartbeat: H;
976
+ /** Heartbeat cadence in ms. Defaults to 10s (10000). */
977
+ intervalMs?: number;
978
+ /** The `api.*` reference for the presence listPresent query. */
979
+ listPresent: L;
980
+ /**
981
+ * Stable id for this presence row. Defaults to a fresh per-call id.
982
+ * Pass a user/connection id to control deduping across tabs.
983
+ */
984
+ sessionId?: string;
985
+ /** Forwarded to the heartbeat mutation / listPresent subscription when sharding by room. */
986
+ shardKey?: string;
987
+ }
988
+ /**
989
+ * `PresenceResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
990
+ * @experimental
991
+ */
992
+ interface PresenceResult<L extends ListPresentReference> {
993
+ /** The present members for the room. `undefined` until the first push. */
994
+ present: Signal<ReturnOf<L> | undefined>;
995
+ /** This mount's session id (generated when not supplied). */
996
+ sessionId: string;
997
+ /** Replace the awareness `data` sent with subsequent heartbeats, and heartbeat immediately. */
998
+ setData: (data: Record<string, unknown> | undefined) => void;
999
+ }
1000
+ /**
1001
+ * `presence` — collaborative-awareness primitive, the client half of the
1002
+ * `@lunora/server` `definePresence` preset.
1003
+ *
1004
+ * Drives the heartbeat mutation (on mount, interval, and tab re-focus) and
1005
+ * subscribes to the live `listPresent` query for the given room.
1006
+ *
1007
+ * Call from an injection context (component/service field or constructor):
1008
+ * ```ts
1009
+ * readonly roomPresence = presence("room:general", {
1010
+ * heartbeat: api.presence.heartbeat,
1011
+ * listPresent: api.presence.listPresent,
1012
+ * });
1013
+ * ```
1014
+ * @experimental
1015
+ */
1016
+ declare const presence: <H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: PresenceOptions<H, L>) => PresenceResult<L>;
1017
+ /**
1018
+ * `RateLimitOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
1019
+ * @experimental
1020
+ */
1021
+ interface RateLimitOptions {
1022
+ /**
1023
+ * `DestroyRef` whose `onDestroy` clears the interval. Defaults to
1024
+ * `inject(DestroyRef)` — the calling component/service.
1025
+ */
1026
+ destroyRef?: DestroyRef;
1027
+ /** Clock injection for tests. Defaults to `Date.now`. */
1028
+ now?: () => number;
1029
+ /**
1030
+ * Re-render cadence in milliseconds while throttled, so `retryAfter` ticks
1031
+ * down and `disabled` flips back automatically. Defaults to `1000`.
1032
+ */
1033
+ tickMs?: number;
1034
+ }
1035
+ /**
1036
+ * `RateLimitResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
1037
+ * @experimental
1038
+ */
1039
+ interface RateLimitResult {
1040
+ /** Would consuming `count` (default 1) succeed right now? Does not consume. */
1041
+ check: (count?: number) => boolean;
1042
+ /** Optimistically consume `count` (default 1) locally; mirrors the server algorithm. */
1043
+ consume: (count?: number) => RateLimitStatus;
1044
+ /** `true` while a single unit cannot be consumed — convenient for disabling a control. */
1045
+ disabled: Signal<boolean>;
1046
+ /** `true` while a single unit can be consumed. */
1047
+ ok: Signal<boolean>;
1048
+ /** Clear local accounting (e.g. after the server confirms a reset). */
1049
+ reset: () => void;
1050
+ /** Milliseconds until the next unit is available. `0` when `ok`. */
1051
+ retryAfter: Signal<number>;
1052
+ }
1053
+ /**
1054
+ * Client-side mirror of a rate limit for instant UX — disable a button or show
1055
+ * a countdown without a round-trip. It runs the same token-bucket / fixed-window
1056
+ * math as `@lunora/ratelimit` on the server, so the prediction agrees with the
1057
+ * authoritative check; the server remains the source of truth.
1058
+ *
1059
+ * Requires an Angular injection context unless a `DestroyRef` is passed
1060
+ * explicitly via `options.destroyRef`.
1061
+ *
1062
+ * ```ts
1063
+ * readonly sendLimit = rateLimit({ kind: "token bucket", period: 1000, rate: 10 });
1064
+ * ```
1065
+ * @experimental
1066
+ */
1067
+ declare const rateLimit: (config: RateLimitConfig, options?: RateLimitOptions) => RateLimitResult;
1068
+ /**
1069
+ * The lifecycle of a stream the primitive is observing.
1070
+ * @experimental
1071
+ */
1072
+ type StreamStatus = "complete" | "error" | "idle" | "streaming";
1073
+ /**
1074
+ * `StreamOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
1075
+ * @experimental
1076
+ */
1077
+ interface StreamOptions {
1078
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
1079
+ client?: LunoraClient;
1080
+ /**
1081
+ * `DestroyRef` whose `onDestroy` cancels the stream. Defaults to
1082
+ * `inject(DestroyRef)` — the calling component/service.
1083
+ */
1084
+ destroyRef?: DestroyRef;
1085
+ /** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
1086
+ maxBuffer?: number;
1087
+ /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
1088
+ shardKey?: string;
1089
+ }
1090
+ /**
1091
+ * `StreamResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
1092
+ * @experimental
1093
+ */
1094
+ interface StreamResult<T> {
1095
+ /** Force-cancel the stream and resolve the iterator. Safe to call multiple times. */
1096
+ cancel: () => void;
1097
+ /** Chunks the server has pushed so far, in arrival order. */
1098
+ chunks: Signal<ReadonlyArray<T>>;
1099
+ /** The stream error, or `undefined`. */
1100
+ error: Signal<Error | undefined>;
1101
+ /** The stream lifecycle. */
1102
+ status: Signal<StreamStatus>;
1103
+ }
1104
+ /**
1105
+ * Subscribe to a streaming query. Returns the chunks pushed so far plus a
1106
+ * lifecycle status and a `cancel` function, all as signals.
1107
+ *
1108
+ * Unlike `subscription`, which tracks the latest value, `stream` accumulates every
1109
+ * chunk the server pushes — use it for token-by-token deltas and other append-only
1110
+ * feeds. Pass `"skip"` as `args` to keep the primitive mounted without opening a
1111
+ * stream (mirrors `subscription`); the stream tears down when the owning
1112
+ * `DestroyRef` fires. The Angular counterpart to React's `useStream`, re-expressed
1113
+ * with signals.
1114
+ *
1115
+ * Call from an injection context (component/service field or constructor):
1116
+ * ```ts
1117
+ * readonly tokens = stream(api.chat.liveEvents, { key: "thread-1" });
1118
+ * ```
1119
+ * @experimental
1120
+ */
1121
+ declare const stream: <F extends FunctionReference<"stream">>(reference: F, args: ArgsOf<F> | "skip", options?: StreamOptions) => StreamResult<ReturnOf<F>>;
1122
+ /**
1123
+ * `SubscriptionOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
1124
+ * @experimental
1125
+ */
1126
+ interface SubscriptionOptions {
1127
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
1128
+ client?: LunoraClient;
1129
+ /**
1130
+ * `DestroyRef` whose `onDestroy` tears the subscription down. Defaults to
1131
+ * `inject(DestroyRef)` — the calling component/service.
1132
+ */
1133
+ destroyRef?: DestroyRef;
1134
+ /**
1135
+ * Called when the subscription errors after the initial attach. Without it,
1136
+ * a post-attach failure is dropped silently.
1137
+ */
1138
+ onError?: (error: SubscriptionError) => void;
1139
+ /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
1140
+ shardKey?: string;
1141
+ }
1142
+ /**
1143
+ * `SubscriptionResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
1144
+ * @experimental
1145
+ */
1146
+ interface SubscriptionResult<T> {
1147
+ /** The latest value pushed by the server. `undefined` before the first frame. */
1148
+ data: Signal<T | undefined>;
1149
+ /** The latest error, or `undefined`. */
1150
+ error: Signal<SubscriptionError | undefined>;
1151
+ }
1152
+ /**
1153
+ * Subscribe to a reactive server push stream. Returns `{ data, error }` signals
1154
+ * that update whenever the server emits a new value.
1155
+ *
1156
+ * Unlike `liveQuery`, which tracks a single value, `subscription` also
1157
+ * exposes an `error` signal for the async error channel. Use it for ephemeral,
1158
+ * high-frequency streams where you need error visibility.
1159
+ *
1160
+ * Pass `"skip"` as `args` to short-circuit — no network call, no socket.
1161
+ * The subscription tears down when the owning `DestroyRef` fires.
1162
+ *
1163
+ * Call from an injection context (component/service field or constructor):
1164
+ * ```ts
1165
+ * readonly stream = subscription(api.events.stream, { roomId: "general" });
1166
+ * ```
1167
+ * @experimental
1168
+ */
1169
+ declare const subscription: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip", options?: SubscriptionOptions) => SubscriptionResult<ReturnOf<F>>;
1170
+ /**
1171
+ * Browser Web Audio subsystems for `voiceAgent` — the default microphone capture
1172
+ * and speaker playback implementations injected into the primitive via its
1173
+ * `createMicrophone` / `createSpeaker` seams. Kept in a sibling module so the
1174
+ * heavy Web Audio graph (and its structural DOM typings) stays isolated from the
1175
+ * primitive's transport + signal-state logic and remains mockable in a
1176
+ * non-browser test env.
1177
+ */
1178
+ /**
1179
+ * The negotiated audio format the voice DO streams back. Mirrors
1180
+ * `@lunora/agent`'s `VoiceServerFrame` `ready.audioFormat` — re-declared (not
1181
+ * imported) so this Angular package never pulls in the server-only `@lunora/agent`
1182
+ * module graph.
1183
+ * @experimental
1184
+ */
1185
+ type VoiceAudioFormat = "mp3" | "wav";
1186
+ /** Captures microphone audio and reports level / turn boundaries back to the primitive. */
1187
+ interface VoiceMicrophone {
1188
+ /** Mute/unmute the mic without tearing down the capture graph. */
1189
+ setMuted: (muted: boolean) => void;
1190
+ /** Stop capture and release the media stream + audio graph. */
1191
+ stop: () => void;
1192
+ }
1193
+ /** Plays the server's streamed audio chunks and supports a mid-utterance barge-in. */
1194
+ interface VoiceSpeaker {
1195
+ /** Queue a decoded audio chunk for gap-minimized playback. */
1196
+ enqueue: (audio: Uint8Array) => void;
1197
+ /** Drop everything queued and stop the current chunk (barge-in). */
1198
+ interrupt: () => void;
1199
+ /** Release the playback audio context. */
1200
+ stop: () => void;
1201
+ }
1202
+ /** Config passed to a {@link CreateMicrophone} factory. */
1203
+ interface MicrophoneConfig {
1204
+ /** The consecutive above-threshold chunk count that counts as a barge-in. */
1205
+ interruptChunks: number;
1206
+ /** RMS above which the user is considered to be barging in while the agent speaks. */
1207
+ interruptThreshold: number;
1208
+ /** `true` while `status === "speaking"` — gates barge-in detection. */
1209
+ isSpeaking: () => boolean;
1210
+ /** One 16 kHz mono 16-bit little-endian PCM frame captured from the mic. */
1211
+ onAudio: (pcm: Uint8Array) => void;
1212
+ /** A barge-in was detected (RMS spike while the agent is speaking). */
1213
+ onInterrupt: () => void;
1214
+ /** The current input RMS (0–1), for a level meter. */
1215
+ onLevel: (rms: number) => void;
1216
+ /** A spoken utterance ended (speech followed by `silenceDurationMs` of silence). */
1217
+ onSilence: () => void;
1218
+ /** Milliseconds of sub-threshold audio (after speech) that closes an utterance. */
1219
+ silenceDurationMs: number;
1220
+ /** RMS below which audio counts as silence. */
1221
+ silenceThreshold: number;
1222
+ }
1223
+ type CreateMicrophone = (config: MicrophoneConfig) => Promise<VoiceMicrophone>;
1224
+ type CreateSpeaker = (config: {
1225
+ audioFormat: VoiceAudioFormat;
1226
+ }) => VoiceSpeaker;
1227
+ /**
1228
+ * The `agents.&lt;name>Voice` reference codegen emits for a voice-enabled agent — a
1229
+ * live, WS-backed session keyed by `threadKey`. A structural subset of the
1230
+ * generated member, so passing `api.agents.&lt;name>Voice` type-checks.
1231
+ * @experimental
1232
+ */
1233
+ type VoiceReference = FunctionReference<"stream", {
1234
+ threadKey: string;
1235
+ }, Record<string, unknown>>;
1236
+ /**
1237
+ * The lifecycle of a voice call, mirrored to the UI.
1238
+ * @experimental
1239
+ */
1240
+ type VoiceStatus = "idle" | "listening" | "speaking" | "thinking";
1241
+ /** A minimal structural subset of the DOM `WebSocket` the primitive drives. */
1242
+ interface VoiceSocket {
1243
+ binaryType: string;
1244
+ close: () => void;
1245
+ onclose: ((event: unknown) => void) | null;
1246
+ onerror: ((event: unknown) => void) | null;
1247
+ onmessage: ((event: {
1248
+ data: unknown;
1249
+ }) => void) | null;
1250
+ onopen: ((event: unknown) => void) | null;
1251
+ readonly readyState: number;
1252
+ send: (data: ArrayBufferView | ArrayBufferLike | string) => void;
1253
+ }
1254
+ type CreateSocket = (url: string) => VoiceSocket;
1255
+ /**
1256
+ * `VoiceAgentOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
1257
+ * @experimental
1258
+ */
1259
+ interface VoiceAgentOptions {
1260
+ /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
1261
+ client?: LunoraClient;
1262
+ /**
1263
+ * Advanced/test seam: build the microphone capture subsystem. Defaults to a
1264
+ * `getUserMedia` + Web Audio implementation. Injected wholesale so the Web
1265
+ * Audio graph stays isolated (and mockable in a non-browser test env).
1266
+ */
1267
+ createMicrophone?: CreateMicrophone;
1268
+ /** Advanced/test seam: open the transport. Defaults to `new WebSocket(url)`. */
1269
+ createSocket?: CreateSocket;
1270
+ /** Advanced/test seam: build the audio playback subsystem. Defaults to a Web Audio implementation. */
1271
+ createSpeaker?: CreateSpeaker;
1272
+ /**
1273
+ * `DestroyRef` whose `onDestroy` tears the call down. Defaults to
1274
+ * `inject(DestroyRef)` — the calling component/service.
1275
+ */
1276
+ destroyRef?: DestroyRef;
1277
+ /** Consecutive above-`interruptThreshold` chunks that trigger a barge-in. Default `3`. */
1278
+ interruptChunks?: number;
1279
+ /** Input RMS above which the user is treated as barging in while the agent speaks. Default `0.15`. */
1280
+ interruptThreshold?: number;
1281
+ /** Milliseconds of silence (after speech) that auto-commits an utterance. Default `1200`. */
1282
+ silenceDurationMs?: number;
1283
+ /** Input RMS below which audio counts as silence. Default `0.01`. */
1284
+ silenceThreshold?: number;
1285
+ /** The thread to converse on — shared with the agent's text turns. Resolved when the call opens. */
1286
+ threadKey: string;
1287
+ /** The generated `api.agents.&lt;name>Voice` reference — identifies the voice DO endpoint. */
1288
+ voice: VoiceReference;
1289
+ }
1290
+ /**
1291
+ * `VoiceAgentResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
1292
+ * @experimental
1293
+ */
1294
+ interface VoiceAgentResult {
1295
+ /** The current input RMS (0–1) — drive a mic level meter. */
1296
+ audioLevel: Signal<number>;
1297
+ /** `true` once the WS `ready` handshake completed. */
1298
+ connected: Signal<boolean>;
1299
+ /** Tear down the call: close the socket, stop the mic, release audio. Idempotent. */
1300
+ endCall: () => void;
1301
+ /** The last transport/pipeline error, or `undefined`. */
1302
+ error: Signal<Error | undefined>;
1303
+ /** The live assistant text for the in-flight turn (grows via deltas; finalized on done). */
1304
+ interimTranscript: Signal<string>;
1305
+ /** `true` while the mic is muted. */
1306
+ isMuted: Signal<boolean>;
1307
+ /** Send a typed turn (no audio) — a text message spoken back by the agent. */
1308
+ sendText: (text: string) => void;
1309
+ /** Open the mic, connect the socket, and start the conversation. Idempotent while active. */
1310
+ startCall: () => Promise<void>;
1311
+ /** The current call lifecycle. */
1312
+ status: Signal<VoiceStatus>;
1313
+ /** Mute/unmute the microphone. Returns the new muted state. */
1314
+ toggleMute: () => boolean;
1315
+ /** The last finalized user utterance (STT result). */
1316
+ transcript: Signal<string>;
1317
+ }
1318
+ /**
1319
+ * A first-class voice-call surface for a voice-enabled agent: it opens a
1320
+ * WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
1321
+ * streams the agent's synthesized speech back through the browser's audio output,
1322
+ * and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
1323
+ * `audioLevel`) to Angular signals. Pass the generated `api.agents.&lt;name>Voice`
1324
+ * reference (never a string), matching `agentChat`'s reference-passing style. The
1325
+ * Angular counterpart to React's `useVoiceAgent`, re-expressed with signals; the
1326
+ * per-call connection lives in a closure variable (the primitive runs once per
1327
+ * component, so no signal-of-connection indirection is needed).
1328
+ *
1329
+ * v1 transport is plain binary WebSocket frames with push-to-talk / silence-timer
1330
+ * turn detection and client-side RMS barge-in. The heavy Web Audio capture and
1331
+ * playback subsystems are injectable (`createMicrophone` / `createSpeaker` /
1332
+ * `createSocket`) so the primitive is drivable outside a browser.
1333
+ *
1334
+ * Call from an injection context (component/service field or constructor); pass an
1335
+ * explicit `client` / `destroyRef` to drive it outside one (e.g. in a test).
1336
+ * @experimental
1337
+ */
1338
+ declare const voiceAgent: (options: VoiceAgentOptions) => VoiceAgentResult;
1339
+ export { type AgentApi, type AgentChatApi, type AgentChatMessage, type AgentChatOptions, type AgentChatResult, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentResult, type AgentStateApi, type AgentStateOptions, type AgentStateResult, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentTokenStreamReference, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsOptions, type AgentToolEventsResult, type AuthGateResult, type AuthOptions, type AuthResult, type ConnectionStatusOptions, type FlagContext, type FlagOptions, type FlagValue, type FlagsOptions, type HeartbeatReference, type HydratePreloadedOptions, type HydratePreloadedResult, type InfiniteQueryResult, LUNORA_CLIENT, type ListPresentReference, type LiveQueryOptions, type MutateOptions, type MutatorResult, type PaginatedQueryOptions, type PaginatedQueryResult, type PresenceOptions, type PresenceResult, type ProvideLunoraOptions, type RateLimitOptions, type RateLimitResult, type StreamOptions, type StreamResult, type StreamStatus, type SubscriptionOptions, type SubscriptionResult, type VoiceAgentOptions, type VoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags, hydratePreloaded, infiniteQuery, injectLunoraClient, liveQuery, mutate, mutator, paginatedQuery, presence, provideLunora, rateLimit, stream, subscription, voiceAgent };