@lunora/angular 1.0.0-alpha.13 → 1.0.0-alpha.131

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 (50) hide show
  1. package/README.md +42 -0
  2. package/dist/index.d.mts +250 -45
  3. package/dist/index.d.ts +250 -45
  4. package/dist/index.mjs +1 -19
  5. package/dist/packem_shared/LUNORA_CLIENT-B0toApHY.mjs +1 -0
  6. package/dist/packem_shared/agent-BCt1D_wQ.mjs +1 -0
  7. package/dist/packem_shared/agentChat-DMMjTLnF.mjs +1 -0
  8. package/dist/packem_shared/agentState-Cdyss0S4.mjs +1 -0
  9. package/dist/packem_shared/agentToolEvents-BOp6-TK8.mjs +1 -0
  10. package/dist/packem_shared/auth-C3dB8sYS.mjs +1 -0
  11. package/dist/packem_shared/connectionStatus-UhmuwzMa.mjs +1 -0
  12. package/dist/packem_shared/flag-BJxkgJR2.mjs +1 -0
  13. package/dist/packem_shared/hydratePreloaded-Bgt9hkmH.mjs +1 -0
  14. package/dist/packem_shared/infiniteQuery-yZS4F7PI.mjs +1 -0
  15. package/dist/packem_shared/liveQuery-ZIgKq4et.mjs +1 -0
  16. package/dist/packem_shared/mutate-BZvLQLyu.mjs +1 -0
  17. package/dist/packem_shared/mutator-DjG1yGk8.mjs +1 -0
  18. package/dist/packem_shared/platform-DNlq-CRU.mjs +1 -0
  19. package/dist/packem_shared/presence-DUkZtSSL.mjs +1 -0
  20. package/dist/packem_shared/rateLimit-B3h9qzh-.mjs +1 -0
  21. package/dist/packem_shared/runAction-BfiPq4Xz.mjs +1 -0
  22. package/dist/packem_shared/stream-CVSnLbC2.mjs +1 -0
  23. package/dist/packem_shared/subscription-B_Xj8Ezd.mjs +1 -0
  24. package/dist/packem_shared/voiceAgent-CyPFWGUt.mjs +1 -0
  25. package/dist/server.d.mts +1 -0
  26. package/dist/server.d.ts +1 -0
  27. package/dist/server.mjs +1 -0
  28. package/dist/upload.d.mts +57 -0
  29. package/dist/upload.d.ts +57 -0
  30. package/dist/upload.mjs +1 -0
  31. package/package.json +12 -3
  32. package/dist/packem_shared/LUNORA_CLIENT-DHUfNu9x.mjs +0 -23
  33. package/dist/packem_shared/agent-DDKvrG4u.mjs +0 -31
  34. package/dist/packem_shared/agentChat-DDZlxK1v.mjs +0 -111
  35. package/dist/packem_shared/agentState-C8GWf3t3.mjs +0 -10
  36. package/dist/packem_shared/agentToolEvents-sXgYggvi.mjs +0 -59
  37. package/dist/packem_shared/auth-Df9N87Z4.mjs +0 -27
  38. package/dist/packem_shared/connectionStatus-BlLodleK.mjs +0 -15
  39. package/dist/packem_shared/flag-CGBo90HJ.mjs +0 -70
  40. package/dist/packem_shared/hydratePreloaded-DIpD1cAM.mjs +0 -33
  41. package/dist/packem_shared/infiniteQuery-nboKfr5E.mjs +0 -221
  42. package/dist/packem_shared/liveQuery-DVxKidjM.mjs +0 -32
  43. package/dist/packem_shared/mutate-D3rEHwbb.mjs +0 -8
  44. package/dist/packem_shared/mutator-BHL8bakL.mjs +0 -19
  45. package/dist/packem_shared/platform-Dg8Bppgq.mjs +0 -14
  46. package/dist/packem_shared/presence-BTuq19dS.mjs +0 -77
  47. package/dist/packem_shared/rateLimit-I4kRT9qV.mjs +0 -58
  48. package/dist/packem_shared/stream-PL64AghO.mjs +0 -47
  49. package/dist/packem_shared/subscription-oZ-WTmpp.mjs +0 -39
  50. package/dist/packem_shared/voiceAgent-DwbrDnB9.mjs +0 -401
package/README.md CHANGED
@@ -57,6 +57,31 @@ export class MessagesComponent {
57
57
 
58
58
  Pass `"skip"` as the args to short-circuit (no network call, no socket).
59
59
 
60
+ Pass a function/`Signal` instead of a plain object to make the args reactive —
61
+ each change tears the old subscription down, resets the signal to `undefined`,
62
+ and opens a fresh one for the new args:
63
+
64
+ ```ts
65
+ export class MessagesComponent {
66
+ private readonly channelId = input.required<string>();
67
+
68
+ readonly messages = liveQuery(api.messages.list, () => ({ channelId: this.channelId() }));
69
+ }
70
+ ```
71
+
72
+ `subscription` and `paginatedQuery`/`infiniteQuery` accept the same reactive
73
+ args form. Calling from outside an injection context (e.g. `ngOnInit`) needs an
74
+ explicit `injector` alongside `client`/`destroyRef` for the reactive form —
75
+ `effect()` can't resolve one on its own there:
76
+
77
+ ```ts
78
+ liveQuery(api.messages.list, () => ({ channelId: this.channelId() }), {
79
+ client: this.client,
80
+ destroyRef: this.destroyRef,
81
+ injector: this.injector,
82
+ });
83
+ ```
84
+
60
85
  ## Mutations
61
86
 
62
87
  ```ts
@@ -85,4 +110,21 @@ import { connectionStatus } from "@lunora/angular";
85
110
  readonly status = connectionStatus(); // Signal<"idle" | "connecting" | "connected" | "offline">
86
111
  ```
87
112
 
113
+ ## Agents
114
+
115
+ ```ts
116
+ import { agentToolEvents, voiceAgent } from "@lunora/angular";
117
+
118
+ // One thread's tool lifecycle: call / result / awaiting-approval / progress.
119
+ readonly events = agentToolEvents({ api, threadKey: "t1", stream: api.chat.liveEvents }).events;
120
+
121
+ // A full-duplex voice call against api.agents.<name>Voice.
122
+ readonly call = voiceAgent({ threadKey: "t1", voice: api.agents.supportVoice });
123
+ ```
124
+
125
+ `voiceAgent` opens nothing until `call.startCall()` — that call is what requests
126
+ the microphone, so it must run from a user gesture. `call.endCall()` releases the
127
+ socket, the mic tracks and the Web Audio graph, and the owning `DestroyRef` runs
128
+ it on destroy.
129
+
88
130
  Part of the [Lunora](https://github.com/anolilab/lunora) framework.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
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';
1
+ import { DestroyRef, Signal, InjectionToken, EnvironmentProviders, Injector } from '@angular/core';
2
+ import { FunctionReference, LunoraClient, SubscriptionErrorCallback, SubscriptionError, User, LunoraClientOptions, ConnectionStatus, Preloaded, ArgsOf, ReturnOf, MutationCallOptions, MutatorHandle, ActionCallOptions } from '@lunora/client';
3
3
  export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, LunoraClientOptions, MutationCallOptions, Preloaded, ReturnOf, SubscriptionError, Unsubscribe } from '@lunora/client';
4
+ import { AuthStatus } from '@lunora/client/auth';
4
5
  import { PaginationStatus } from '@lunora/client/pagination';
5
6
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
6
7
  export { SKIP } from '@lunora/client/query';
@@ -22,8 +23,12 @@ type AgentThreadStatus = "awaiting_input" | "cancelled" | "error" | "idle" | "ru
22
23
  */
23
24
  interface AgentThreadRecord {
24
25
  createdAt?: number;
25
- /** The failure message when `status === "error"`. */
26
- error?: string;
26
+ /**
27
+ * The failure message when `status === "error"`, `null` once a later run
28
+ * cleared it, absent on a thread that has never failed. Read it for
29
+ * truthiness — `null` and absent both mean "no error".
30
+ */
31
+ error?: null | string;
27
32
  /** The workflow instance id of the in-flight run — the handle `cancel` targets. */
28
33
  instanceId?: string;
29
34
  messageCount?: number;
@@ -125,7 +130,7 @@ interface AgentOptions {
125
130
  api: AgentApi;
126
131
  /**
127
132
  * Optional app mutation over the agent's cancel path
128
- * (`ctx.agents.&lt;name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
133
+ * (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
129
134
  * When omitted (or no run is in flight) {@link AgentResult.cancel} is a no-op.
130
135
  */
131
136
  cancel?: FunctionReference<"mutation">;
@@ -136,9 +141,15 @@ interface AgentOptions {
136
141
  * `inject(DestroyRef)` — the calling component/service.
137
142
  */
138
143
  destroyRef?: DestroyRef;
144
+ /**
145
+ * Called when the live thread subscription reports an error (a session
146
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
147
+ * failure is invisible and `thread` / `status` are cleared until a later frame arrives.
148
+ */
149
+ onError?: SubscriptionErrorCallback;
139
150
  /**
140
151
  * 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
152
+ * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
142
153
  * {@link AgentOptions.runArgs} and the per-call args.
143
154
  */
144
155
  run: FunctionReference<"mutation">;
@@ -157,6 +168,8 @@ interface AgentResult {
157
168
  * no-op when no `cancel` mutation was supplied or no run is in flight.
158
169
  */
159
170
  cancel: () => Promise<void>;
171
+ /** The live thread subscription's last error, or `undefined`. */
172
+ error: Signal<SubscriptionError | undefined>;
160
173
  /** `true` while a `run` invocation is in flight. */
161
174
  pending: Signal<boolean>;
162
175
  /** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
@@ -174,7 +187,7 @@ interface AgentResult {
174
187
  * conversation surface (durable history + streaming + approvals) use `agentChat`.
175
188
  *
176
189
  * `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
190
+ * `ctx.agents.<name>.run` / `.cancel`, so the primitive hard-codes no function
178
191
  * names beyond the `agents:*` surface.
179
192
  *
180
193
  * Call from an injection context (component/service field or constructor); pass an
@@ -232,7 +245,7 @@ interface AgentChatOptions {
232
245
  api: AgentChatApi;
233
246
  /**
234
247
  * Optional app mutation over the agent's cancel path
235
- * (`ctx.agents.&lt;name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
248
+ * (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
236
249
  * When omitted (or no run is in flight) {@link AgentChatResult.cancel} is a
237
250
  * no-op.
238
251
  */
@@ -246,9 +259,15 @@ interface AgentChatOptions {
246
259
  destroyRef?: DestroyRef;
247
260
  /** History depth forwarded to `agents:agentMessages`. */
248
261
  limit?: number;
262
+ /**
263
+ * Called when the live history or thread subscription reports an error (a
264
+ * session expiry, an RLS denial). Without it — and without reading `error` —
265
+ * such a failure is invisible and `messages` / `status` are cleared until a later frame arrives.
266
+ */
267
+ onError?: SubscriptionErrorCallback;
249
268
  /**
250
269
  * 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
270
+ * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
252
271
  * {@link AgentChatOptions.sendArgs} and the per-call args.
253
272
  */
254
273
  send: FunctionReference<"mutation">;
@@ -275,6 +294,8 @@ interface AgentChatResult {
275
294
  * no-op when no `cancel` mutation was supplied or no run is in flight.
276
295
  */
277
296
  cancel: () => Promise<void>;
297
+ /** The history or thread subscription's last error, or `undefined`. */
298
+ error: Signal<SubscriptionError | undefined>;
278
299
  /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
279
300
  messages: Signal<ReadonlyArray<AgentChatMessage>>;
280
301
  /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
@@ -363,7 +384,7 @@ interface AgentStateResult<T> {
363
384
  * only on a real `setState`. The Angular counterpart to React's `useAgentState`,
364
385
  * re-expressed with signals.
365
386
  *
366
- * Generic over the app's state shape (`agentState&lt;SupportState>(...)`, itself a
387
+ * Generic over the app's state shape (`agentState<SupportState>(...)`, itself a
367
388
  * record) — the reference is typed as an optional record because codegen cannot see
368
389
  * the per-agent state type; the generic casts to `T`. The `extends` bound (not a
369
390
  * bare unbounded type parameter) is required: this `.ts` file is parsed JSX-aware by
@@ -502,6 +523,12 @@ interface AuthOptions {
502
523
  interface AuthResult {
503
524
  /** Set the auth token (sign-in / sign-out). */
504
525
  setToken: (token: string | null) => void;
526
+ /**
527
+ * The resolved auth state. Branch on this, not on `user() === null` — see the
528
+ * contract in `@lunora/client/auth`; `user` is `null` both when signed out
529
+ * and when a held credential's identity could not be resolved.
530
+ */
531
+ status: Signal<AuthStatus>;
505
532
  /** The current auth token, or `null`. */
506
533
  token: Signal<string | null>;
507
534
  /** The resolved user from `store.getUser()`, or `null`. */
@@ -524,6 +551,34 @@ interface AuthResult {
524
551
  * @experimental
525
552
  */
526
553
  declare const auth: (options?: AuthOptions) => AuthResult;
554
+ /**
555
+ * `AuthGateResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
556
+ * @experimental
557
+ */
558
+ interface AuthGateResult {
559
+ /** `true` once a credential is held and nothing has contradicted it. */
560
+ isAuthenticated: Signal<boolean>;
561
+ /** `true` while a credential's first identity resolve is in flight. */
562
+ isLoading: Signal<boolean>;
563
+ }
564
+ /**
565
+ * Derived auth-gate signals for template gating (Angular's `\@if` control
566
+ * flow), built on {@link auth}. Angular has no JSX-style `Authenticated` slot
567
+ * component the way React/Vue/Solid do, so this exposes the same three-state
568
+ * logic as two booleans instead, mapped from the shared `AuthStatus` contract in
569
+ * `@lunora/client/auth`: a credential whose first identity resolve is in flight
570
+ * is `isLoading`; a credential nothing has contradicted — including one whose
571
+ * identity endpoint is unreachable — is `isAuthenticated`; no session is neither
572
+ * (the signed-out state a template checks for with a plain `\@else`).
573
+ *
574
+ * Call from an injection context (component/service field or constructor):
575
+ * ```ts
576
+ * protected readonly authState = authGate();
577
+ * // template: \@if (authState.isAuthenticated()) { ... } \@else if (authState.isLoading()) { ... }
578
+ * ```
579
+ * @experimental
580
+ */
581
+ declare const authGate: (options?: AuthOptions) => AuthGateResult;
527
582
  /**
528
583
  * DI token carrying the framework-neutral {@link LunoraClient}. Every reactive
529
584
  * primitive in this adapter (`liveQuery`, `mutate`, `connectionStatus`) reads the
@@ -599,16 +654,15 @@ interface ConnectionStatusOptions {
599
654
  * @experimental
600
655
  */
601
656
  declare const connectionStatus: (options?: ConnectionStatusOptions) => Signal<ConnectionStatus>;
657
+ /** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
658
+ type FlagValue$1 = boolean | number | string | {
659
+ [key: string]: unknown;
660
+ } | unknown[] | null;
602
661
  /**
603
662
  * The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags.
604
663
  * @experimental
605
664
  */
606
- type FlagValue = boolean | number | string | Record<string, unknown> | unknown[] | null;
607
- /**
608
- * Targeting context bag forwarded to the OpenFeature provider.
609
- * @experimental
610
- */
611
- type FlagContext = Record<string, unknown>;
665
+ type FlagValue = FlagValue$1;
612
666
  /**
613
667
  * `FlagOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
614
668
  * @experimental
@@ -616,11 +670,6 @@ type FlagContext = Record<string, unknown>;
616
670
  interface FlagOptions {
617
671
  /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
618
672
  client?: LunoraClient;
619
- /**
620
- * Per-call targeting context merged on top of the app's default `identify`
621
- * targeting key.
622
- */
623
- context?: FlagContext;
624
673
  /** `DestroyRef` whose `onDestroy` tears down the subscription. Defaults to `inject(DestroyRef)`. */
625
674
  destroyRef?: DestroyRef;
626
675
  }
@@ -632,9 +681,16 @@ interface FlagOptions {
632
681
  * The flag's kind is inferred from `defaultValue`'s runtime type, so
633
682
  * `flag("dark", false)` reads a boolean and `flag("hero", "control")` a string.
634
683
  *
684
+ * The reactive channel is public, so the server evaluates every flag under the
685
+ * socket's own verified identity — the targeting key your `defineFlags({
686
+ * identify })` derives — and accepts no client-supplied targeting context. For
687
+ * evaluation under a context you compute, call `ctx.flags.*` inside a query,
688
+ * mutation, or action and return the resolved value.
689
+ *
635
690
  * Evaluation runs through whatever OpenFeature provider the app wired in
636
691
  * `lunora/flags.ts`; the read never throws — a provider error resolves the
637
- * default (the same fail-open contract as server-side `ctx.flags`).
692
+ * default (the same fail-open contract as server-side `ctx.flags`). No
693
+ * subscription opens during SSR; the signal stays at `defaultValue`.
638
694
  *
639
695
  * Call from an injection context:
640
696
  * ```ts
@@ -650,11 +706,6 @@ declare const flag: <T extends FlagValue>(key: string, defaultValue: T, options?
650
706
  interface FlagsOptions {
651
707
  /** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
652
708
  client?: LunoraClient;
653
- /**
654
- * Targeting context shared by every flag in the set, merged on top of the
655
- * app's default `identify` targeting key.
656
- */
657
- context?: FlagContext;
658
709
  /** `DestroyRef` whose `onDestroy` tears down the subscriptions. Defaults to `inject(DestroyRef)`. */
659
710
  destroyRef?: DestroyRef;
660
711
  }
@@ -663,7 +714,8 @@ interface FlagsOptions {
663
714
  *
664
715
  * Pass a record of `key → defaultValue`; each flag's kind is inferred from its
665
716
  * default, and the returned signal holds the same-shaped record with resolved
666
- * values (the defaults until each evaluation lands).
717
+ * values (the defaults until each evaluation lands). Like {@link flag} it
718
+ * evaluates under the socket's server-verified identity only.
667
719
  *
668
720
  * Call from an injection context:
669
721
  * ```ts
@@ -687,7 +739,7 @@ interface HydratePreloadedOptions {
687
739
  * @experimental
688
740
  */
689
741
  interface HydratePreloadedResult<T> {
690
- /** The latest value pushed by the server. Seeded synchronously from the preloaded value. */
742
+ /** The latest value pushed by the server. Seeded synchronously from the preloaded value until an identity is retired. */
691
743
  data: Signal<T | undefined>;
692
744
  /** The latest subscription error, or `undefined`. */
693
745
  error: Signal<SubscriptionError | undefined>;
@@ -705,6 +757,12 @@ interface HydratePreloadedResult<T> {
705
757
  *
706
758
  * The subscription tears down when the owning `DestroyRef` fires.
707
759
  *
760
+ * The preloaded value was read for whoever was signed in when the page loaded.
761
+ * After a sign-out or user switch retires that identity
762
+ * (`client.identityEpoch() > 0`), every `hydratePreloaded` on the client (created
763
+ * then or later) stops using it and `data` holds `undefined` until the live value
764
+ * arrives — matching `@lunora/react`'s `usePreloadedQuery`.
765
+ *
708
766
  * Call from an injection context:
709
767
  * ```ts
710
768
  * readonly { data, error } = hydratePreloaded(preloadedMessages);
@@ -728,6 +786,16 @@ interface LiveQueryOptions {
728
786
  * component is destroyed. Pass one explicitly to control the lifetime yourself.
729
787
  */
730
788
  destroyRef?: DestroyRef;
789
+ /**
790
+ * `Injector` to create the reactive-args `effect()` from. Only needed when
791
+ * `args` is a function/`Signal` AND `liveQuery` is called outside an injection
792
+ * context (an explicit `destroyRef` is also being passed — e.g. from
793
+ * `ngOnInit`, or from a test with no `TestBed`) — `effect()` cannot resolve an
794
+ * injector on its own there. Defaults to the ambient injection context, the
795
+ * same source `inject(DestroyRef)` already relies on. Unused for the static
796
+ * `args` form, which never creates an `effect()`.
797
+ */
798
+ injector?: Injector;
731
799
  /**
732
800
  * Called when the subscription errors after the initial attach — the async
733
801
  * error channel `createQuerySubscription` only wires when a sink is present.
@@ -761,9 +829,17 @@ interface LiveQueryOptions {
761
829
  * short-circuit — no network call, no socket; the signal stays `undefined`. To
762
830
  * call outside an injection context (e.g. lazily in `ngOnInit`), supply `client`
763
831
  * and `destroyRef` via {@link LiveQueryOptions}.
832
+ *
833
+ * `args` also accepts a function/`Signal` — `() => ({ channelId: channelId() })`
834
+ * — to make the subscription reactive: an args change tears the old
835
+ * subscription down, resets the signal to `undefined`, and opens a fresh one
836
+ * for the new args, mirroring
837
+ * `@lunora/solid`'s `createQuery`/`@lunora/vue`'s `useQuery`. A static (plain
838
+ * object) `args` resolves once and never re-runs — no `effect()` is created for
839
+ * it, so it carries none of the reactive form's DI requirement.
764
840
  * @experimental
765
841
  */
766
- declare const liveQuery: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip", options?: LiveQueryOptions) => Signal<ReturnOf<F> | undefined>;
842
+ declare const liveQuery: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip" | (() => ArgsOf<F> | "skip"), options?: LiveQueryOptions) => Signal<ReturnOf<F> | undefined>;
767
843
  /**
768
844
  * `MutateOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
769
845
  * @experimental
@@ -851,6 +927,15 @@ interface PaginatedQueryOptions {
851
927
  destroyRef?: DestroyRef;
852
928
  /** Page size for the first page (and the default for `loadMore`). */
853
929
  initialNumItems: number;
930
+ /**
931
+ * `Injector` to create the reactive-args `effect()` from. Only needed when
932
+ * `args` is a function/`Signal` AND the call is outside an injection context
933
+ * (an explicit `destroyRef` is also being passed). Defaults to the ambient
934
+ * injection context. Unused for the static `args` form.
935
+ */
936
+ injector?: Injector;
937
+ /** Called when a page subscription reports an error (also surfaced on the `error` signal). */
938
+ onError?: SubscriptionErrorCallback;
854
939
  /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
855
940
  shardKey?: string;
856
941
  }
@@ -859,6 +944,13 @@ interface PaginatedQueryOptions {
859
944
  * @experimental
860
945
  */
861
946
  interface PaginatedQueryResult<T> {
947
+ /**
948
+ * The last page subscription error, or `undefined`. A tail page that fails
949
+ * before its first frame is dropped so `status` returns to `"CanLoadMore"`
950
+ * and `loadMore` can retry it; cleared by the next successful frame,
951
+ * `loadMore`, or an args change.
952
+ */
953
+ error: Signal<SubscriptionError | undefined>;
862
954
  /** `true` while the first page or a `loadMore` page is in flight. */
863
955
  isLoading: Signal<boolean>;
864
956
  /** Request the next page. A no-op unless `status === "CanLoadMore"`. */
@@ -873,6 +965,8 @@ interface PaginatedQueryResult<T> {
873
965
  * @experimental
874
966
  */
875
967
  interface InfiniteQueryResult<T> {
968
+ /** The last page subscription error, or `undefined` — see `PaginatedQueryResult.error`. */
969
+ error: Signal<SubscriptionError | undefined>;
876
970
  /** Request the next page. A no-op unless `status === "CanLoadMore"`. */
877
971
  fetchNextPage: (numberItems?: number) => void;
878
972
  /** `true` when the loaded tail reports it can load another page. */
@@ -901,9 +995,13 @@ interface InfiniteQueryResult<T> {
901
995
  * ```ts
902
996
  * readonly messages = paginatedQuery(api.messages.list, {}, { initialNumItems: 20 });
903
997
  * ```
998
+ *
999
+ * `args` also accepts a function/`Signal` to make the query reactive — an args
1000
+ * change disposes the current pagination engine and builds a fresh one for the
1001
+ * new args. A static (plain object) `args` resolves once and never re-runs.
904
1002
  * @experimental
905
1003
  */
906
- declare const paginatedQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip", options: PaginatedQueryOptions) => PaginatedQueryResult<PageItemOf<F>>;
1004
+ declare const paginatedQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip" | (() => PaginatedArgs<F> | "skip"), options: PaginatedQueryOptions) => PaginatedQueryResult<PageItemOf<F>>;
907
1005
  /**
908
1006
  * Subscribe to a reactively-paginated query and expose its pages discretely.
909
1007
  *
@@ -915,9 +1013,12 @@ declare const paginatedQuery: <F extends FunctionReference>(reference: F, args:
915
1013
  * ```ts
916
1014
  * readonly feed = infiniteQuery(api.messages.list, {}, { initialNumItems: 20 });
917
1015
  * ```
1016
+ *
1017
+ * `args` also accepts a function/`Signal` to make the query reactive — see
1018
+ * `paginatedQuery`'s equivalent note.
918
1019
  * @experimental
919
1020
  */
920
- declare const infiniteQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip", options: PaginatedQueryOptions) => InfiniteQueryResult<PageItemOf<F>>;
1021
+ declare const infiniteQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip" | (() => PaginatedArgs<F> | "skip"), options: PaginatedQueryOptions) => InfiniteQueryResult<PageItemOf<F>>;
921
1022
  /**
922
1023
  * `HeartbeatReference` is part of the experimental `@lunora/angular` API and may change without a major version bump.
923
1024
  * @experimental
@@ -951,6 +1052,12 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
951
1052
  intervalMs?: number;
952
1053
  /** The `api.*` reference for the presence listPresent query. */
953
1054
  listPresent: L;
1055
+ /**
1056
+ * Called when the `listPresent` subscription reports an error (a session
1057
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
1058
+ * failure is invisible and `present` is cleared until a later frame arrives.
1059
+ */
1060
+ onError?: SubscriptionErrorCallback;
954
1061
  /**
955
1062
  * Stable id for this presence row. Defaults to a fresh per-call id.
956
1063
  * Pass a user/connection id to control deduping across tabs.
@@ -964,6 +1071,8 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
964
1071
  * @experimental
965
1072
  */
966
1073
  interface PresenceResult<L extends ListPresentReference> {
1074
+ /** The `listPresent` subscription's last error, or `undefined`. */
1075
+ error: Signal<SubscriptionError | undefined>;
967
1076
  /** The present members for the room. `undefined` until the first push. */
968
1077
  present: Signal<ReturnOf<L> | undefined>;
969
1078
  /** This mount's session id (generated when not supplied). */
@@ -1039,6 +1148,43 @@ interface RateLimitResult {
1039
1148
  * @experimental
1040
1149
  */
1041
1150
  declare const rateLimit: (config: RateLimitConfig, options?: RateLimitOptions) => RateLimitResult;
1151
+ /**
1152
+ * `RunActionOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
1153
+ * @experimental
1154
+ */
1155
+ interface RunActionOptions extends ActionCallOptions {
1156
+ /**
1157
+ * Client to run the action on. Defaults to the injected `LUNORA_CLIENT`.
1158
+ * Because actions usually fire from event handlers — which run *outside* an
1159
+ * injection context — capture the client once (`injectLunoraClient()` in a
1160
+ * field) and pass it here, or call `client.action(...)` directly.
1161
+ */
1162
+ client?: LunoraClient;
1163
+ }
1164
+ /**
1165
+ * Run a Lunora action and resolve with the server result (rejects on failure).
1166
+ *
1167
+ * The sibling of `mutate`, and a plain function for the same reason: Angular's
1168
+ * adapter models writes as calls rather than reactive handles, because they fire
1169
+ * from event handlers where a signal-returning primitive has nothing to bind to.
1170
+ * The other adapters return a reactive `{ call, pending, … }` handle because
1171
+ * their idioms make that natural; this one does not.
1172
+ *
1173
+ * Unlike `mutate` there are no `optimistic` / `optimisticUpdate` options. An
1174
+ * optimistic update patches the subscription cache on the assumption a write
1175
+ * will land; an action is not a write — it runs in the Worker, may call a third
1176
+ * party, and has no declared effect on any query.
1177
+ *
1178
+ * ```ts
1179
+ * private readonly client = injectLunoraClient();
1180
+ * verify = () => runAction(api.commands.run, { command: "lunora", args: ["verify"] }, { client: this.client });
1181
+ * ```
1182
+ *
1183
+ * When called from within an injection context you may omit `client` and let it
1184
+ * resolve from the injector.
1185
+ * @experimental
1186
+ */
1187
+ declare const runAction: <F extends FunctionReference>(reference: F, args: ArgsOf<F>, options?: RunActionOptions) => Promise<ReturnOf<F>>;
1042
1188
  /**
1043
1189
  * The lifecycle of a stream the primitive is observing.
1044
1190
  * @experimental
@@ -1056,6 +1202,13 @@ interface StreamOptions {
1056
1202
  * `inject(DestroyRef)` — the calling component/service.
1057
1203
  */
1058
1204
  destroyRef?: DestroyRef;
1205
+ /**
1206
+ * Opt into resume-on-reconnect for a stream the server declared `durable`.
1207
+ * The chunks already received are kept and the socket re-attaches to the same
1208
+ * run, so a dropped connection mid-generation continues instead of surfacing
1209
+ * `STREAM_DISCONNECTED`. Has no effect on an ephemeral stream.
1210
+ */
1211
+ durable?: boolean;
1059
1212
  /** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
1060
1213
  maxBuffer?: number;
1061
1214
  /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
@@ -1083,8 +1236,8 @@ interface StreamResult<T> {
1083
1236
  * chunk the server pushes — use it for token-by-token deltas and other append-only
1084
1237
  * feeds. Pass `"skip"` as `args` to keep the primitive mounted without opening a
1085
1238
  * stream (mirrors `subscription`); the stream tears down when the owning
1086
- * `DestroyRef` fires. The Angular counterpart to React's `useStream`, re-expressed
1087
- * with signals.
1239
+ * `DestroyRef` fires. Nothing opens on the Angular server platform (SSR). The
1240
+ * Angular counterpart to React's `useStream`, re-expressed with signals.
1088
1241
  *
1089
1242
  * Call from an injection context (component/service field or constructor):
1090
1243
  * ```ts
@@ -1105,6 +1258,14 @@ interface SubscriptionOptions {
1105
1258
  * `inject(DestroyRef)` — the calling component/service.
1106
1259
  */
1107
1260
  destroyRef?: DestroyRef;
1261
+ /**
1262
+ * `Injector` to create the reactive-args `effect()` from. Only needed when
1263
+ * `args` is a function/`Signal` AND `subscription` is called outside an
1264
+ * injection context (an explicit `destroyRef` is also being passed).
1265
+ * Defaults to the ambient injection context. Unused for the static `args`
1266
+ * form, which never creates an `effect()`.
1267
+ */
1268
+ injector?: Injector;
1108
1269
  /**
1109
1270
  * Called when the subscription errors after the initial attach. Without it,
1110
1271
  * a post-attach failure is dropped silently.
@@ -1138,9 +1299,13 @@ interface SubscriptionResult<T> {
1138
1299
  * ```ts
1139
1300
  * readonly stream = subscription(api.events.stream, { roomId: "general" });
1140
1301
  * ```
1302
+ *
1303
+ * `args` also accepts a function/`Signal` to make the subscription reactive —
1304
+ * an args change tears the old subscription down and opens a fresh one for the
1305
+ * new args. A static (plain object) `args` resolves once and never re-runs.
1141
1306
  * @experimental
1142
1307
  */
1143
- declare const subscription: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip", options?: SubscriptionOptions) => SubscriptionResult<ReturnOf<F>>;
1308
+ declare const subscription: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip" | (() => ArgsOf<F> | "skip"), options?: SubscriptionOptions) => SubscriptionResult<ReturnOf<F>>;
1144
1309
  /**
1145
1310
  * Browser Web Audio subsystems for `voiceAgent` — the default microphone capture
1146
1311
  * and speaker playback implementations injected into the primitive via its
@@ -1179,8 +1344,24 @@ interface MicrophoneConfig {
1179
1344
  interruptChunks: number;
1180
1345
  /** RMS above which the user is considered to be barging in while the agent speaks. */
1181
1346
  interruptThreshold: number;
1182
- /** `true` while `status === "speaking"` — gates barge-in detection. */
1183
- isSpeaking: () => boolean;
1347
+ /**
1348
+ * `true` from the moment a turn is committed until it completes — the whole
1349
+ * `thinking` + `speaking` window, not just the audible half.
1350
+ *
1351
+ * It gates BOTH branches below, and the wider span is the point. Gated only
1352
+ * on "audibly speaking", turn detection kept running through the entire
1353
+ * STT+LLM window after a `commit`: room noise at the (deliberately low)
1354
+ * `silenceThreshold` re-armed `sawSpeech`, another quiet gap fired a SECOND
1355
+ * `commit`, and the DO refused it with "a turn is already in progress" —
1356
+ * a refusal that returns before draining the audio buffer, so the PCM
1357
+ * captured since the first commit leaked into the next utterance.
1358
+ *
1359
+ * A genuine barge-in still works in that window: it routes through the
1360
+ * `onInterrupt` branch, which needs `interruptChunks` consecutive chunks at
1361
+ * `interruptThreshold` — an order of magnitude above `silenceThreshold` —
1362
+ * and `interrupt` is exactly what the DO tells the client to send.
1363
+ */
1364
+ isTurnActive: () => boolean;
1184
1365
  /** One 16 kHz mono 16-bit little-endian PCM frame captured from the mic. */
1185
1366
  onAudio: (pcm: Uint8Array) => void;
1186
1367
  /** A barge-in was detected (RMS spike while the agent is speaking). */
@@ -1199,9 +1380,9 @@ type CreateSpeaker = (config: {
1199
1380
  audioFormat: VoiceAudioFormat;
1200
1381
  }) => VoiceSpeaker;
1201
1382
  /**
1202
- * The `agents.&lt;name>Voice` reference codegen emits for a voice-enabled agent — a
1383
+ * The `agents.<name>Voice` reference codegen emits for a voice-enabled agent — a
1203
1384
  * live, WS-backed session keyed by `threadKey`. A structural subset of the
1204
- * generated member, so passing `api.agents.&lt;name>Voice` type-checks.
1385
+ * generated member, so passing `api.agents.<name>Voice` type-checks.
1205
1386
  * @experimental
1206
1387
  */
1207
1388
  type VoiceReference = FunctionReference<"stream", {
@@ -1239,7 +1420,11 @@ interface VoiceAgentOptions {
1239
1420
  * Audio graph stays isolated (and mockable in a non-browser test env).
1240
1421
  */
1241
1422
  createMicrophone?: CreateMicrophone;
1242
- /** Advanced/test seam: open the transport. Defaults to `new WebSocket(url)`. */
1423
+ /**
1424
+ * Advanced/test seam: open the transport. Defaults to the WebSocket
1425
+ * implementation the client was built with (`client.getWebSocketImpl()`),
1426
+ * NOT a raw `globalThis.WebSocket`.
1427
+ */
1243
1428
  createSocket?: CreateSocket;
1244
1429
  /** Advanced/test seam: build the audio playback subsystem. Defaults to a Web Audio implementation. */
1245
1430
  createSpeaker?: CreateSpeaker;
@@ -1256,9 +1441,13 @@ interface VoiceAgentOptions {
1256
1441
  silenceDurationMs?: number;
1257
1442
  /** Input RMS below which audio counts as silence. Default `0.01`. */
1258
1443
  silenceThreshold?: number;
1259
- /** The thread to converse on — shared with the agent's text turns. Resolved when the call opens. */
1260
- threadKey: string;
1261
- /** The generated `api.agents.&lt;name>Voice` reference — identifies the voice DO endpoint. */
1444
+ /**
1445
+ * The thread to converse on — shared with the agent's text turns. A plain
1446
+ * value, or a `Signal`/getter resolved afresh every time a call opens — the
1447
+ * reactive-args form the package's other primitives take.
1448
+ */
1449
+ threadKey: (() => string) | string;
1450
+ /** The generated `api.agents.<name>Voice` reference — identifies the voice DO endpoint. */
1262
1451
  voice: VoiceReference;
1263
1452
  }
1264
1453
  /**
@@ -1294,7 +1483,7 @@ interface VoiceAgentResult {
1294
1483
  * WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
1295
1484
  * streams the agent's synthesized speech back through the browser's audio output,
1296
1485
  * and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
1297
- * `audioLevel`) to Angular signals. Pass the generated `api.agents.&lt;name>Voice`
1486
+ * `audioLevel`) to Angular signals. Pass the generated `api.agents.<name>Voice`
1298
1487
  * reference (never a string), matching `agentChat`'s reference-passing style. The
1299
1488
  * Angular counterpart to React's `useVoiceAgent`, re-expressed with signals; the
1300
1489
  * per-call connection lives in a closure variable (the primitive runs once per
@@ -1310,4 +1499,20 @@ interface VoiceAgentResult {
1310
1499
  * @experimental
1311
1500
  */
1312
1501
  declare const voiceAgent: (options: VoiceAgentOptions) => VoiceAgentResult;
1313
- 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 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, connectionStatus, flag, flags, hydratePreloaded, infiniteQuery, injectLunoraClient, liveQuery, mutate, mutator, paginatedQuery, presence, provideLunora, rateLimit, stream, subscription, voiceAgent };
1502
+ 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 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,
1503
+ /**
1504
+ * The Angular adapter for Lunora.
1505
+ *
1506
+ * Thin, idiomatic glue over the framework-neutral `@lunora/client`. Angular
1507
+ * signals map directly onto Lunora's per-subscription deltas, so a live query is
1508
+ * just a `signal` the WebSocket writes to.
1509
+ *
1510
+ * `provideLunora` / `LUNORA_CLIENT` / `injectLunoraClient` are the injectable
1511
+ * provider carrying one `LunoraClient` (opens its socket lazily), wired once in the
1512
+ * application config. `liveQuery` is a live-query `signal` that opens a
1513
+ * subscription and updates on every delta, torn down automatically on
1514
+ * `DestroyRef.onDestroy`. `mutate` runs a mutation (optimistic updates + offline
1515
+ * queue pass through to the client). `connectionStatus` is a `signal` of the
1516
+ * aggregate live-socket status.
1517
+ */
1518
+ type ProvideLunoraOptions, type RateLimitOptions, type RateLimitResult, type RunActionOptions, 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, runAction, stream, subscription, voiceAgent };