@lunora/angular 1.0.0-alpha.10 → 1.0.0-alpha.101

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