@lunora/angular 1.0.0-alpha.26 → 1.0.0-alpha.260
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.
- package/README.md +71 -0
- package/dist/index.d.mts +345 -47
- package/dist/index.d.ts +345 -47
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/LUNORA_CLIENT-B0toApHY.mjs +1 -0
- package/dist/packem_shared/agent-DjMQf-yE.mjs +1 -0
- package/dist/packem_shared/agentChat-CQ3TWlc5.mjs +1 -0
- package/dist/packem_shared/agentState-Bjqf9q2f.mjs +1 -0
- package/dist/packem_shared/agentToolEvents-CFnjzw3X.mjs +1 -0
- package/dist/packem_shared/auth-C3dB8sYS.mjs +1 -0
- package/dist/packem_shared/connectionStatus-UhmuwzMa.mjs +1 -0
- package/dist/packem_shared/flag-BDKBQGos.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-QPAo50Am.mjs +1 -0
- package/dist/packem_shared/infiniteQuery-CnLj_eFx.mjs +1 -0
- package/dist/packem_shared/liveQuery-eE9zMaxo.mjs +1 -0
- package/dist/packem_shared/liveTopic-Cz1BDkMP.mjs +1 -0
- package/dist/packem_shared/mutate-Dg5AiM8y.mjs +1 -0
- package/dist/packem_shared/mutator-DjG1yGk8.mjs +1 -0
- package/dist/packem_shared/platform-DGTu4Ucl.mjs +1 -0
- package/dist/packem_shared/presence-NK13Gvdk.mjs +1 -0
- package/dist/packem_shared/rateLimit-B3h9qzh-.mjs +1 -0
- package/dist/packem_shared/runAction-BfiPq4Xz.mjs +1 -0
- package/dist/packem_shared/stream-BuhiwhIH.mjs +1 -0
- package/dist/packem_shared/subscription-zJv48q6C.mjs +1 -0
- package/dist/packem_shared/voiceAgent-DppK8OxH.mjs +1 -0
- package/dist/server.d.mts +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.mjs +1 -0
- package/dist/upload.d.mts +20 -0
- package/dist/upload.d.ts +20 -0
- package/dist/upload.mjs +1 -1
- package/package.json +9 -4
- package/dist/packem_shared/LUNORA_CLIENT-B0pGE0Tv.mjs +0 -1
- package/dist/packem_shared/agent-C-GavfBl.mjs +0 -1
- package/dist/packem_shared/agentChat-DVHf7gsd.mjs +0 -1
- package/dist/packem_shared/agentState-BAfa0QuC.mjs +0 -1
- package/dist/packem_shared/agentToolEvents-CBTZ_DsO.mjs +0 -1
- package/dist/packem_shared/auth-BTEtMnGG.mjs +0 -1
- package/dist/packem_shared/connectionStatus-C53UhkPi.mjs +0 -1
- package/dist/packem_shared/flag-BYFWoQTg.mjs +0 -1
- package/dist/packem_shared/hydratePreloaded-BKHgpXzQ.mjs +0 -1
- package/dist/packem_shared/infiniteQuery-DyWJIpUr.mjs +0 -1
- package/dist/packem_shared/liveQuery-DEIqmTPj.mjs +0 -1
- package/dist/packem_shared/mutate-DR8Uo8Hs.mjs +0 -1
- package/dist/packem_shared/mutator-Cw6jpG06.mjs +0 -1
- package/dist/packem_shared/platform-BGZypnc9.mjs +0 -1
- package/dist/packem_shared/presence-BMrTlOCF.mjs +0 -1
- package/dist/packem_shared/rateLimit-CQazDrPJ.mjs +0 -1
- package/dist/packem_shared/stream-CcvHiJf2.mjs +0 -1
- package/dist/packem_shared/subscription-DJeoGEDR.mjs +0 -1
- package/dist/packem_shared/voiceAgent-DUFVwTWi.mjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { DestroyRef, Signal, InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
2
|
-
import { FunctionReference, LunoraClient, SubscriptionError, User, LunoraClientOptions, ConnectionStatus, Preloaded, ArgsOf, ReturnOf, MutationCallOptions, MutatorHandle } from '@lunora/client';
|
|
1
|
+
import { DestroyRef, Signal, InjectionToken, EnvironmentProviders, Injector } from '@angular/core';
|
|
2
|
+
import { FunctionReference, LunoraClient, SubscriptionErrorCallback, SubscriptionError, User, LunoraClientOptions, ConnectionStatus, Preloaded, ArgsOf, ReturnOf, LiveTopicOptions as LiveTopicOptions$1, LiveTopicRef, LiveStreamSubscribeError, MutationCallOptions, OnlineOnlyOption, MutatorHandle, ActionCallOptions } from '@lunora/client';
|
|
3
3
|
export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, LunoraClientOptions, MutationCallOptions, Preloaded, ReturnOf, SubscriptionError, Unsubscribe } from '@lunora/client';
|
|
4
|
+
import { AuthStatus } from '@lunora/client/auth';
|
|
4
5
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
6
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
6
7
|
export { SKIP } from '@lunora/client/query';
|
|
@@ -22,8 +23,12 @@ type AgentThreadStatus = "awaiting_input" | "cancelled" | "error" | "idle" | "ru
|
|
|
22
23
|
*/
|
|
23
24
|
interface AgentThreadRecord {
|
|
24
25
|
createdAt?: number;
|
|
25
|
-
/**
|
|
26
|
-
|
|
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;
|
|
@@ -51,8 +56,8 @@ interface AgentChatMessage {
|
|
|
51
56
|
optimistic?: boolean;
|
|
52
57
|
role: "assistant" | "system" | "tool" | "user";
|
|
53
58
|
seq: number;
|
|
54
|
-
/** Approval lifecycle marker on a human-in-the-loop tool message. */
|
|
55
|
-
status?: "approved" | "awaiting_approval" | "rejected";
|
|
59
|
+
/** Approval or secret-request lifecycle marker on a human-in-the-loop tool message. */
|
|
60
|
+
status?: "approved" | "awaiting_approval" | "awaiting_secret" | "rejected";
|
|
56
61
|
toolCallId?: string;
|
|
57
62
|
toolCalls?: ReadonlyArray<{
|
|
58
63
|
id: string;
|
|
@@ -136,6 +141,12 @@ interface AgentOptions {
|
|
|
136
141
|
* `inject(DestroyRef)` — the calling component/service.
|
|
137
142
|
*/
|
|
138
143
|
destroyRef?: DestroyRef;
|
|
144
|
+
/**
|
|
145
|
+
* Called when the live thread subscription reports an error (a session
|
|
146
|
+
* expiry, an RLS denial). Without it — and without reading `error` — such a
|
|
147
|
+
* failure is invisible and `thread` / `status` are cleared until a later frame arrives.
|
|
148
|
+
*/
|
|
149
|
+
onError?: SubscriptionErrorCallback;
|
|
139
150
|
/**
|
|
140
151
|
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
141
152
|
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
@@ -157,6 +168,8 @@ interface AgentResult {
|
|
|
157
168
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
158
169
|
*/
|
|
159
170
|
cancel: () => Promise<void>;
|
|
171
|
+
/** The live thread subscription's last error, or `undefined`. */
|
|
172
|
+
error: Signal<SubscriptionError | undefined>;
|
|
160
173
|
/** `true` while a `run` invocation is in flight. */
|
|
161
174
|
pending: Signal<boolean>;
|
|
162
175
|
/** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
|
|
@@ -189,7 +202,7 @@ type AgentMessagesReference$1 = FunctionReference<"query", {
|
|
|
189
202
|
}, ReadonlyArray<Record<string, unknown>>>;
|
|
190
203
|
/** The `agents:agentResolveApproval` reference — resolves a human-in-the-loop tool approval. */
|
|
191
204
|
type AgentApprovalReference = FunctionReference<"mutation", {
|
|
192
|
-
decision: "approve" | "reject";
|
|
205
|
+
decision: "approve" | "approve_for_thread" | "reject";
|
|
193
206
|
instanceId: string;
|
|
194
207
|
note?: string;
|
|
195
208
|
threadKey: string;
|
|
@@ -197,10 +210,41 @@ type AgentApprovalReference = FunctionReference<"mutation", {
|
|
|
197
210
|
}, {
|
|
198
211
|
resolved: boolean;
|
|
199
212
|
}>;
|
|
213
|
+
/** The `agents:agentSupplySecret` reference — stores a person's value for a paused `requestSecretTool` call. */
|
|
214
|
+
type AgentSupplySecretReference = FunctionReference<"mutation", {
|
|
215
|
+
secret: string;
|
|
216
|
+
threadKey: string;
|
|
217
|
+
toolCallId: string;
|
|
218
|
+
}, {
|
|
219
|
+
resolved: boolean;
|
|
220
|
+
}>;
|
|
221
|
+
/** The `agents:agentDeclineSecret` reference — refuses a paused `requestSecretTool` call. */
|
|
222
|
+
type AgentDeclineSecretReference = FunctionReference<"mutation", {
|
|
223
|
+
threadKey: string;
|
|
224
|
+
toolCallId: string;
|
|
225
|
+
}, {
|
|
226
|
+
resolved: boolean;
|
|
227
|
+
}>;
|
|
200
228
|
/** The `agents:agentThread` reference — live thread status + in-flight `instanceId`. */
|
|
201
229
|
type AgentThreadReference = FunctionReference<"query", {
|
|
202
230
|
key: string;
|
|
203
231
|
}, Record<string, unknown> | undefined>;
|
|
232
|
+
/** A tool approved for the rest of a thread, as `agents:agentApprovalGrants` lists it. */
|
|
233
|
+
interface AgentApprovalGrant {
|
|
234
|
+
createdAt: number;
|
|
235
|
+
toolName: string;
|
|
236
|
+
}
|
|
237
|
+
/** The `agents:agentApprovalGrants` reference — live thread-scoped approval grants. */
|
|
238
|
+
type AgentApprovalGrantsReference = FunctionReference<"query", {
|
|
239
|
+
key: string;
|
|
240
|
+
}, ReadonlyArray<AgentApprovalGrant>>;
|
|
241
|
+
/** The `agents:agentRevokeApprovalGrant` reference — removes a thread-scoped approval grant. */
|
|
242
|
+
type AgentRevokeApprovalGrantReference = FunctionReference<"mutation", {
|
|
243
|
+
threadKey: string;
|
|
244
|
+
toolName: string;
|
|
245
|
+
}, {
|
|
246
|
+
revoked: boolean;
|
|
247
|
+
}>;
|
|
204
248
|
/**
|
|
205
249
|
* An app stream reference that tees the agent's in-flight live events, keyed by
|
|
206
250
|
* thread. Carries token deltas and — since `ctx.reportProgress` rides the same
|
|
@@ -218,8 +262,12 @@ type AgentTokenStreamReference = FunctionReference<"stream", {
|
|
|
218
262
|
*/
|
|
219
263
|
interface AgentChatApi {
|
|
220
264
|
agents: {
|
|
265
|
+
agentApprovalGrants: AgentApprovalGrantsReference;
|
|
266
|
+
agentDeclineSecret: AgentDeclineSecretReference;
|
|
221
267
|
agentMessages: AgentMessagesReference$1;
|
|
222
268
|
agentResolveApproval: AgentApprovalReference;
|
|
269
|
+
agentRevokeApprovalGrant: AgentRevokeApprovalGrantReference;
|
|
270
|
+
agentSupplySecret: AgentSupplySecretReference;
|
|
223
271
|
agentThread: AgentThreadReference;
|
|
224
272
|
};
|
|
225
273
|
}
|
|
@@ -246,6 +294,12 @@ interface AgentChatOptions {
|
|
|
246
294
|
destroyRef?: DestroyRef;
|
|
247
295
|
/** History depth forwarded to `agents:agentMessages`. */
|
|
248
296
|
limit?: number;
|
|
297
|
+
/**
|
|
298
|
+
* Called when the live history, thread, or grants subscription reports an error (a
|
|
299
|
+
* session expiry, an RLS denial). Without it — and without reading `error` —
|
|
300
|
+
* such a failure is invisible and `messages` / `status` are cleared until a later frame arrives.
|
|
301
|
+
*/
|
|
302
|
+
onError?: SubscriptionErrorCallback;
|
|
249
303
|
/**
|
|
250
304
|
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
251
305
|
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
@@ -268,27 +322,47 @@ interface AgentChatOptions {
|
|
|
268
322
|
* @experimental
|
|
269
323
|
*/
|
|
270
324
|
interface AgentChatResult {
|
|
325
|
+
/** The tools approved for the rest of this thread, live. Empty until the grants subscription answers. */
|
|
326
|
+
approvalGrants: Signal<ReadonlyArray<AgentApprovalGrant>>;
|
|
271
327
|
/** Approve a paused human-in-the-loop tool call (optionally with a note). */
|
|
272
328
|
approve: (toolCallId: string, note?: string) => Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* Approve a paused tool call and grant that tool for the rest of the thread, so
|
|
331
|
+
* later calls to it run without pausing. Undo with {@link AgentChatResult.revokeGrant}.
|
|
332
|
+
*/
|
|
333
|
+
approveForThread: (toolCallId: string, note?: string) => Promise<void>;
|
|
273
334
|
/**
|
|
274
335
|
* Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
|
|
275
336
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
276
337
|
*/
|
|
277
338
|
cancel: () => Promise<void>;
|
|
339
|
+
/** Refuse a paused `requestSecretTool` call: the run resumes with a "declined" result. */
|
|
340
|
+
declineSecret: (toolCallId: string) => Promise<void>;
|
|
341
|
+
/** The history, thread, or grants subscription's last error, or `undefined`. */
|
|
342
|
+
error: Signal<SubscriptionError | undefined>;
|
|
278
343
|
/** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
|
|
279
344
|
messages: Signal<ReadonlyArray<AgentChatMessage>>;
|
|
280
345
|
/** Reject a paused human-in-the-loop tool call (optionally with a reason). */
|
|
281
346
|
reject: (toolCallId: string, note?: string) => Promise<void>;
|
|
347
|
+
/** Remove a thread-scoped approval grant so the tool's gate applies again to later calls. */
|
|
348
|
+
revokeGrant: (toolName: string) => Promise<void>;
|
|
282
349
|
/** Start (or continue) a run with a user message; extra args merge over `sendArgs`. Appends an optimistic user turn. */
|
|
283
350
|
send: (input: string, args?: Record<string, unknown>) => Promise<void>;
|
|
284
351
|
/** The live thread status, or `undefined` before the thread exists. */
|
|
285
352
|
status: Signal<AgentThreadStatus | undefined>;
|
|
286
353
|
/** The in-flight turn's streamed text — live-only, empty once the turn persists to `messages`. */
|
|
287
354
|
streamingText: Signal<string>;
|
|
355
|
+
/**
|
|
356
|
+
* Give a paused `requestSecretTool` call its value. Always sent online-only: the
|
|
357
|
+
* value is never queued, persisted or replayed, and the call rejects with
|
|
358
|
+
* `OFFLINE_NOT_QUEUED` while the connection is down. The service keeps no copy;
|
|
359
|
+
* a failure rethrows the original error.
|
|
360
|
+
*/
|
|
361
|
+
supplySecret: (toolCallId: string, secret: string) => Promise<void>;
|
|
288
362
|
}
|
|
289
363
|
/**
|
|
290
364
|
* A first-class agent chat surface: live durable history + in-flight token
|
|
291
|
-
* streaming + the send / approve / reject / cancel writes, keyed by `threadKey` —
|
|
365
|
+
* streaming + the send / approve / reject / secret / cancel writes, keyed by `threadKey` —
|
|
292
366
|
* the Angular counterpart to React's `useAgentChat`, re-expressed with signals.
|
|
293
367
|
*
|
|
294
368
|
* It composes the existing primitives rather than adding transport:
|
|
@@ -418,7 +492,7 @@ interface AgentToolEventsOptions {
|
|
|
418
492
|
* Optional live event stream — the same app stream function `agentChat` uses.
|
|
419
493
|
* When supplied, ephemeral `ctx.reportProgress(...)` events for the thread are
|
|
420
494
|
* surfaced as `{ type: "progress" }` entries; when omitted only the durable
|
|
421
|
-
* lifecycle (call / result / awaiting-approval) is returned.
|
|
495
|
+
* lifecycle (call / result / awaiting-approval / awaiting-secret) is returned.
|
|
422
496
|
*/
|
|
423
497
|
stream?: AgentLiveStreamReference;
|
|
424
498
|
/** The thread whose tool activity to observe. */
|
|
@@ -426,7 +500,7 @@ interface AgentToolEventsOptions {
|
|
|
426
500
|
}
|
|
427
501
|
/**
|
|
428
502
|
* A single tool-lifecycle event for a thread. The durable arms
|
|
429
|
-
* (`call`/`result`/`awaiting-approval`) are derived from `agents:agentMessages`
|
|
503
|
+
* (`call`/`result`/`awaiting-approval`/`awaiting-secret`) are derived from `agents:agentMessages`
|
|
430
504
|
* and carry the persisted `seq`; the ephemeral `progress` arm comes live off the
|
|
431
505
|
* stream and has no `seq`. Discriminate on `type`.
|
|
432
506
|
* @experimental
|
|
@@ -453,6 +527,11 @@ type AgentToolEvent = {
|
|
|
453
527
|
toolCallId?: string;
|
|
454
528
|
toolName?: string;
|
|
455
529
|
type: "awaiting-approval";
|
|
530
|
+
} | {
|
|
531
|
+
seq: number;
|
|
532
|
+
toolCallId?: string;
|
|
533
|
+
toolName?: string;
|
|
534
|
+
type: "awaiting-secret";
|
|
456
535
|
};
|
|
457
536
|
/**
|
|
458
537
|
* `AgentToolEventsResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
@@ -502,6 +581,12 @@ interface AuthOptions {
|
|
|
502
581
|
interface AuthResult {
|
|
503
582
|
/** Set the auth token (sign-in / sign-out). */
|
|
504
583
|
setToken: (token: string | null) => void;
|
|
584
|
+
/**
|
|
585
|
+
* The resolved auth state. Branch on this, not on `user() === null` — see the
|
|
586
|
+
* contract in `@lunora/client/auth`; `user` is `null` both when signed out
|
|
587
|
+
* and when a held credential's identity could not be resolved.
|
|
588
|
+
*/
|
|
589
|
+
status: Signal<AuthStatus>;
|
|
505
590
|
/** The current auth token, or `null`. */
|
|
506
591
|
token: Signal<string | null>;
|
|
507
592
|
/** The resolved user from `store.getUser()`, or `null`. */
|
|
@@ -529,18 +614,20 @@ declare const auth: (options?: AuthOptions) => AuthResult;
|
|
|
529
614
|
* @experimental
|
|
530
615
|
*/
|
|
531
616
|
interface AuthGateResult {
|
|
532
|
-
/** `true` once a
|
|
617
|
+
/** `true` once a credential is held and nothing has contradicted it. */
|
|
533
618
|
isAuthenticated: Signal<boolean>;
|
|
534
|
-
/** `true` while a
|
|
619
|
+
/** `true` while a credential's first identity resolve is in flight. */
|
|
535
620
|
isLoading: Signal<boolean>;
|
|
536
621
|
}
|
|
537
622
|
/**
|
|
538
623
|
* Derived auth-gate signals for template gating (Angular's `\@if` control
|
|
539
624
|
* flow), built on {@link auth}. Angular has no JSX-style `Authenticated` slot
|
|
540
625
|
* component the way React/Vue/Solid do, so this exposes the same three-state
|
|
541
|
-
* logic as two booleans instead
|
|
542
|
-
*
|
|
543
|
-
*
|
|
626
|
+
* logic as two booleans instead, mapped from the shared `AuthStatus` contract in
|
|
627
|
+
* `@lunora/client/auth`: a credential whose first identity resolve is in flight
|
|
628
|
+
* is `isLoading`; a credential nothing has contradicted — including one whose
|
|
629
|
+
* identity endpoint is unreachable — is `isAuthenticated`; no session is neither
|
|
630
|
+
* (the signed-out state a template checks for with a plain `\@else`).
|
|
544
631
|
*
|
|
545
632
|
* Call from an injection context (component/service field or constructor):
|
|
546
633
|
* ```ts
|
|
@@ -625,16 +712,15 @@ interface ConnectionStatusOptions {
|
|
|
625
712
|
* @experimental
|
|
626
713
|
*/
|
|
627
714
|
declare const connectionStatus: (options?: ConnectionStatusOptions) => Signal<ConnectionStatus>;
|
|
715
|
+
/** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
|
|
716
|
+
type FlagValue$1 = boolean | number | string | {
|
|
717
|
+
[key: string]: unknown;
|
|
718
|
+
} | unknown[] | null;
|
|
628
719
|
/**
|
|
629
720
|
* The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags.
|
|
630
721
|
* @experimental
|
|
631
722
|
*/
|
|
632
|
-
type FlagValue =
|
|
633
|
-
/**
|
|
634
|
-
* Targeting context bag forwarded to the OpenFeature provider.
|
|
635
|
-
* @experimental
|
|
636
|
-
*/
|
|
637
|
-
type FlagContext = Record<string, unknown>;
|
|
723
|
+
type FlagValue = FlagValue$1;
|
|
638
724
|
/**
|
|
639
725
|
* `FlagOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
640
726
|
* @experimental
|
|
@@ -642,11 +728,6 @@ type FlagContext = Record<string, unknown>;
|
|
|
642
728
|
interface FlagOptions {
|
|
643
729
|
/** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
|
|
644
730
|
client?: LunoraClient;
|
|
645
|
-
/**
|
|
646
|
-
* Per-call targeting context merged on top of the app's default `identify`
|
|
647
|
-
* targeting key.
|
|
648
|
-
*/
|
|
649
|
-
context?: FlagContext;
|
|
650
731
|
/** `DestroyRef` whose `onDestroy` tears down the subscription. Defaults to `inject(DestroyRef)`. */
|
|
651
732
|
destroyRef?: DestroyRef;
|
|
652
733
|
}
|
|
@@ -658,9 +739,16 @@ interface FlagOptions {
|
|
|
658
739
|
* The flag's kind is inferred from `defaultValue`'s runtime type, so
|
|
659
740
|
* `flag("dark", false)` reads a boolean and `flag("hero", "control")` a string.
|
|
660
741
|
*
|
|
742
|
+
* The reactive channel is public, so the server evaluates every flag under the
|
|
743
|
+
* socket's own verified identity — the targeting key your `defineFlags({
|
|
744
|
+
* identify })` derives — and accepts no client-supplied targeting context. For
|
|
745
|
+
* evaluation under a context you compute, call `ctx.flags.*` inside a query,
|
|
746
|
+
* mutation, or action and return the resolved value.
|
|
747
|
+
*
|
|
661
748
|
* Evaluation runs through whatever OpenFeature provider the app wired in
|
|
662
749
|
* `lunora/flags.ts`; the read never throws — a provider error resolves the
|
|
663
|
-
* default (the same fail-open contract as server-side `ctx.flags`).
|
|
750
|
+
* default (the same fail-open contract as server-side `ctx.flags`). No
|
|
751
|
+
* subscription opens during SSR; the signal stays at `defaultValue`.
|
|
664
752
|
*
|
|
665
753
|
* Call from an injection context:
|
|
666
754
|
* ```ts
|
|
@@ -676,11 +764,6 @@ declare const flag: <T extends FlagValue>(key: string, defaultValue: T, options?
|
|
|
676
764
|
interface FlagsOptions {
|
|
677
765
|
/** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
|
|
678
766
|
client?: LunoraClient;
|
|
679
|
-
/**
|
|
680
|
-
* Targeting context shared by every flag in the set, merged on top of the
|
|
681
|
-
* app's default `identify` targeting key.
|
|
682
|
-
*/
|
|
683
|
-
context?: FlagContext;
|
|
684
767
|
/** `DestroyRef` whose `onDestroy` tears down the subscriptions. Defaults to `inject(DestroyRef)`. */
|
|
685
768
|
destroyRef?: DestroyRef;
|
|
686
769
|
}
|
|
@@ -689,7 +772,8 @@ interface FlagsOptions {
|
|
|
689
772
|
*
|
|
690
773
|
* Pass a record of `key → defaultValue`; each flag's kind is inferred from its
|
|
691
774
|
* default, and the returned signal holds the same-shaped record with resolved
|
|
692
|
-
* values (the defaults until each evaluation lands).
|
|
775
|
+
* values (the defaults until each evaluation lands). Like {@link flag} it
|
|
776
|
+
* evaluates under the socket's server-verified identity only.
|
|
693
777
|
*
|
|
694
778
|
* Call from an injection context:
|
|
695
779
|
* ```ts
|
|
@@ -713,7 +797,7 @@ interface HydratePreloadedOptions {
|
|
|
713
797
|
* @experimental
|
|
714
798
|
*/
|
|
715
799
|
interface HydratePreloadedResult<T> {
|
|
716
|
-
/** The latest value pushed by the server. Seeded synchronously from the preloaded value. */
|
|
800
|
+
/** The latest value pushed by the server. Seeded synchronously from the preloaded value until an identity is retired. */
|
|
717
801
|
data: Signal<T | undefined>;
|
|
718
802
|
/** The latest subscription error, or `undefined`. */
|
|
719
803
|
error: Signal<SubscriptionError | undefined>;
|
|
@@ -731,6 +815,12 @@ interface HydratePreloadedResult<T> {
|
|
|
731
815
|
*
|
|
732
816
|
* The subscription tears down when the owning `DestroyRef` fires.
|
|
733
817
|
*
|
|
818
|
+
* The preloaded value was read for whoever was signed in when the page loaded.
|
|
819
|
+
* After a sign-out or user switch retires that identity
|
|
820
|
+
* (`client.identityEpoch() > 0`), every `hydratePreloaded` on the client (created
|
|
821
|
+
* then or later) stops using it and `data` holds `undefined` until the live value
|
|
822
|
+
* arrives — matching `@lunora/react`'s `usePreloadedQuery`.
|
|
823
|
+
*
|
|
734
824
|
* Call from an injection context:
|
|
735
825
|
* ```ts
|
|
736
826
|
* readonly { data, error } = hydratePreloaded(preloadedMessages);
|
|
@@ -754,6 +844,16 @@ interface LiveQueryOptions {
|
|
|
754
844
|
* component is destroyed. Pass one explicitly to control the lifetime yourself.
|
|
755
845
|
*/
|
|
756
846
|
destroyRef?: DestroyRef;
|
|
847
|
+
/**
|
|
848
|
+
* `Injector` to create the reactive-args `effect()` from. Only needed when
|
|
849
|
+
* `args` is a function/`Signal` AND `liveQuery` is called outside an injection
|
|
850
|
+
* context (an explicit `destroyRef` is also being passed — e.g. from
|
|
851
|
+
* `ngOnInit`, or from a test with no `TestBed`) — `effect()` cannot resolve an
|
|
852
|
+
* injector on its own there. Defaults to the ambient injection context, the
|
|
853
|
+
* same source `inject(DestroyRef)` already relies on. Unused for the static
|
|
854
|
+
* `args` form, which never creates an `effect()`.
|
|
855
|
+
*/
|
|
856
|
+
injector?: Injector;
|
|
757
857
|
/**
|
|
758
858
|
* Called when the subscription errors after the initial attach — the async
|
|
759
859
|
* error channel `createQuerySubscription` only wires when a sink is present.
|
|
@@ -787,9 +887,78 @@ interface LiveQueryOptions {
|
|
|
787
887
|
* short-circuit — no network call, no socket; the signal stays `undefined`. To
|
|
788
888
|
* call outside an injection context (e.g. lazily in `ngOnInit`), supply `client`
|
|
789
889
|
* and `destroyRef` via {@link LiveQueryOptions}.
|
|
890
|
+
*
|
|
891
|
+
* `args` also accepts a function/`Signal` — `() => ({ channelId: channelId() })`
|
|
892
|
+
* — to make the subscription reactive: an args change tears the old
|
|
893
|
+
* subscription down, resets the signal to `undefined`, and opens a fresh one
|
|
894
|
+
* for the new args, mirroring
|
|
895
|
+
* `@lunora/solid`'s `createQuery`/`@lunora/vue`'s `useQuery`. A static (plain
|
|
896
|
+
* object) `args` resolves once and never re-runs — no `effect()` is created for
|
|
897
|
+
* it, so it carries none of the reactive form's DI requirement.
|
|
898
|
+
* @experimental
|
|
899
|
+
*/
|
|
900
|
+
declare const liveQuery: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip" | (() => ArgsOf<F> | "skip"), options?: LiveQueryOptions) => Signal<ReturnOf<F> | undefined>;
|
|
901
|
+
/**
|
|
902
|
+
* `LiveTopicOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
903
|
+
* @experimental
|
|
904
|
+
*/
|
|
905
|
+
interface LiveTopicOptions<Payload = unknown> extends Omit<LiveTopicOptions$1<Payload>, "sessionKey" | "shardKey"> {
|
|
906
|
+
/**
|
|
907
|
+
* The client the stream's route is resolved against. Defaults to `LUNORA_CLIENT`, read in the
|
|
908
|
+
* ambient injection context, so pass it when calling outside one (with an explicit `destroyRef`).
|
|
909
|
+
*/
|
|
910
|
+
client?: LunoraClient;
|
|
911
|
+
/**
|
|
912
|
+
* `DestroyRef` whose `onDestroy` tears the subscription down. Defaults to
|
|
913
|
+
* `inject(DestroyRef)` — the calling component/service.
|
|
914
|
+
*/
|
|
915
|
+
destroyRef?: DestroyRef;
|
|
916
|
+
/**
|
|
917
|
+
* `Injector` to create the reactive-args `effect()` from. Only needed when the
|
|
918
|
+
* topic is a function AND `liveTopic` is called outside an injection context
|
|
919
|
+
* with an explicit `destroyRef`. Unused for the static form.
|
|
920
|
+
*/
|
|
921
|
+
injector?: Injector;
|
|
922
|
+
/**
|
|
923
|
+
* Partitions the shared live connection, as `sessionKey` does on `subscribeLiveTopic`: a changed value opens a new
|
|
924
|
+
* connection and closes the old one. Pass a signal (or any function) to make it reactive, e.g. to move to a new
|
|
925
|
+
* key on sign-out.
|
|
926
|
+
*/
|
|
927
|
+
sessionKey?: string | (() => string | undefined);
|
|
928
|
+
/**
|
|
929
|
+
* Follow the topic on this shard, as `shardKey` does on the other adapters. Pass a signal (or any function) when the
|
|
930
|
+
* shard comes from an input or other state that changes: a new value reopens the subscription on the new shard.
|
|
931
|
+
*/
|
|
932
|
+
shardKey?: string | (() => string | undefined);
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Follow one live topic on the connection shared by its stream's route, and mirror its
|
|
936
|
+
* payloads into an Angular `signal`. Pass the reference `_generated/live.ts` hands out
|
|
937
|
+
* (`live.posts.post({ postId })`); the route is resolved against the injected `LunoraClient`,
|
|
938
|
+
* and `lastEvent` and `onEvent` are typed by the payload the topic declares.
|
|
939
|
+
*
|
|
940
|
+
* `lastEvent` reads `undefined` until the first event lands; `error` carries the
|
|
941
|
+
* shard's refusal of the subscription. The subscription is torn down when the
|
|
942
|
+
* owning `DestroyRef` fires, so there is no leaked subscriber.
|
|
943
|
+
*
|
|
944
|
+
* ```ts
|
|
945
|
+
* export class PostComponent {
|
|
946
|
+
* readonly postId = input.required<string>();
|
|
947
|
+
*
|
|
948
|
+
* readonly comments = liveTopic(() => live.posts.post({ postId: this.postId() }));
|
|
949
|
+
* }
|
|
950
|
+
* ```
|
|
951
|
+
*
|
|
952
|
+
* Pass a function when the topic reads a signal, as above: an input is not bound while a field
|
|
953
|
+
* initializer runs, so a plain reference would read `this.postId` too early. A new topic, or a new
|
|
954
|
+
* `sessionKey` or `shardKey` signal value, resubscribes, while a new `onEvent` / `onError` identity is read at
|
|
955
|
+
* call time and does not reopen the subscription.
|
|
790
956
|
* @experimental
|
|
791
957
|
*/
|
|
792
|
-
declare const
|
|
958
|
+
declare const liveTopic: <Payload>(topic: LiveTopicRef<Payload> | (() => LiveTopicRef<Payload>), options?: LiveTopicOptions<Payload>) => {
|
|
959
|
+
error: Signal<LiveStreamSubscribeError | undefined>;
|
|
960
|
+
lastEvent: Signal<Payload | undefined>;
|
|
961
|
+
};
|
|
793
962
|
/**
|
|
794
963
|
* `MutateOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
795
964
|
* @experimental
|
|
@@ -822,7 +991,7 @@ interface MutateOptions<F extends FunctionReference> extends MutationCallOptions
|
|
|
822
991
|
* resolve from the injector.
|
|
823
992
|
* @experimental
|
|
824
993
|
*/
|
|
825
|
-
declare const mutate: <F extends FunctionReference>(reference: F, args: ArgsOf<F>, options?: MutateOptions<F>) => Promise<ReturnOf<F>>;
|
|
994
|
+
declare const mutate: <F extends FunctionReference>(reference: F, args: ArgsOf<F>, options?: MutateOptions<F> & OnlineOnlyOption<F>) => Promise<ReturnOf<F>>;
|
|
826
995
|
/**
|
|
827
996
|
* `MutatorResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
828
997
|
* @experimental
|
|
@@ -877,6 +1046,15 @@ interface PaginatedQueryOptions {
|
|
|
877
1046
|
destroyRef?: DestroyRef;
|
|
878
1047
|
/** Page size for the first page (and the default for `loadMore`). */
|
|
879
1048
|
initialNumItems: number;
|
|
1049
|
+
/**
|
|
1050
|
+
* `Injector` to create the reactive-args `effect()` from. Only needed when
|
|
1051
|
+
* `args` is a function/`Signal` AND the call is outside an injection context
|
|
1052
|
+
* (an explicit `destroyRef` is also being passed). Defaults to the ambient
|
|
1053
|
+
* injection context. Unused for the static `args` form.
|
|
1054
|
+
*/
|
|
1055
|
+
injector?: Injector;
|
|
1056
|
+
/** Called when a page subscription reports an error (also surfaced on the `error` signal). */
|
|
1057
|
+
onError?: SubscriptionErrorCallback;
|
|
880
1058
|
/** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
|
|
881
1059
|
shardKey?: string;
|
|
882
1060
|
}
|
|
@@ -885,6 +1063,13 @@ interface PaginatedQueryOptions {
|
|
|
885
1063
|
* @experimental
|
|
886
1064
|
*/
|
|
887
1065
|
interface PaginatedQueryResult<T> {
|
|
1066
|
+
/**
|
|
1067
|
+
* The last page subscription error, or `undefined`. A tail page that fails
|
|
1068
|
+
* before its first frame is dropped so `status` returns to `"CanLoadMore"`
|
|
1069
|
+
* and `loadMore` can retry it; cleared by the next successful frame,
|
|
1070
|
+
* `loadMore`, or an args change.
|
|
1071
|
+
*/
|
|
1072
|
+
error: Signal<SubscriptionError | undefined>;
|
|
888
1073
|
/** `true` while the first page or a `loadMore` page is in flight. */
|
|
889
1074
|
isLoading: Signal<boolean>;
|
|
890
1075
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
@@ -899,6 +1084,8 @@ interface PaginatedQueryResult<T> {
|
|
|
899
1084
|
* @experimental
|
|
900
1085
|
*/
|
|
901
1086
|
interface InfiniteQueryResult<T> {
|
|
1087
|
+
/** The last page subscription error, or `undefined` — see `PaginatedQueryResult.error`. */
|
|
1088
|
+
error: Signal<SubscriptionError | undefined>;
|
|
902
1089
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
903
1090
|
fetchNextPage: (numberItems?: number) => void;
|
|
904
1091
|
/** `true` when the loaded tail reports it can load another page. */
|
|
@@ -927,9 +1114,13 @@ interface InfiniteQueryResult<T> {
|
|
|
927
1114
|
* ```ts
|
|
928
1115
|
* readonly messages = paginatedQuery(api.messages.list, {}, { initialNumItems: 20 });
|
|
929
1116
|
* ```
|
|
1117
|
+
*
|
|
1118
|
+
* `args` also accepts a function/`Signal` to make the query reactive — an args
|
|
1119
|
+
* change disposes the current pagination engine and builds a fresh one for the
|
|
1120
|
+
* new args. A static (plain object) `args` resolves once and never re-runs.
|
|
930
1121
|
* @experimental
|
|
931
1122
|
*/
|
|
932
|
-
declare const paginatedQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip", options: PaginatedQueryOptions) => PaginatedQueryResult<PageItemOf<F>>;
|
|
1123
|
+
declare const paginatedQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip" | (() => PaginatedArgs<F> | "skip"), options: PaginatedQueryOptions) => PaginatedQueryResult<PageItemOf<F>>;
|
|
933
1124
|
/**
|
|
934
1125
|
* Subscribe to a reactively-paginated query and expose its pages discretely.
|
|
935
1126
|
*
|
|
@@ -941,9 +1132,12 @@ declare const paginatedQuery: <F extends FunctionReference>(reference: F, args:
|
|
|
941
1132
|
* ```ts
|
|
942
1133
|
* readonly feed = infiniteQuery(api.messages.list, {}, { initialNumItems: 20 });
|
|
943
1134
|
* ```
|
|
1135
|
+
*
|
|
1136
|
+
* `args` also accepts a function/`Signal` to make the query reactive — see
|
|
1137
|
+
* `paginatedQuery`'s equivalent note.
|
|
944
1138
|
* @experimental
|
|
945
1139
|
*/
|
|
946
|
-
declare const infiniteQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip", options: PaginatedQueryOptions) => InfiniteQueryResult<PageItemOf<F>>;
|
|
1140
|
+
declare const infiniteQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip" | (() => PaginatedArgs<F> | "skip"), options: PaginatedQueryOptions) => InfiniteQueryResult<PageItemOf<F>>;
|
|
947
1141
|
/**
|
|
948
1142
|
* `HeartbeatReference` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
949
1143
|
* @experimental
|
|
@@ -977,6 +1171,12 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
|
|
|
977
1171
|
intervalMs?: number;
|
|
978
1172
|
/** The `api.*` reference for the presence listPresent query. */
|
|
979
1173
|
listPresent: L;
|
|
1174
|
+
/**
|
|
1175
|
+
* Called when the `listPresent` subscription reports an error (a session
|
|
1176
|
+
* expiry, an RLS denial). Without it — and without reading `error` — such a
|
|
1177
|
+
* failure is invisible and `present` is cleared until a later frame arrives.
|
|
1178
|
+
*/
|
|
1179
|
+
onError?: SubscriptionErrorCallback;
|
|
980
1180
|
/**
|
|
981
1181
|
* Stable id for this presence row. Defaults to a fresh per-call id.
|
|
982
1182
|
* Pass a user/connection id to control deduping across tabs.
|
|
@@ -990,6 +1190,8 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
|
|
|
990
1190
|
* @experimental
|
|
991
1191
|
*/
|
|
992
1192
|
interface PresenceResult<L extends ListPresentReference> {
|
|
1193
|
+
/** The `listPresent` subscription's last error, or `undefined`. */
|
|
1194
|
+
error: Signal<SubscriptionError | undefined>;
|
|
993
1195
|
/** The present members for the room. `undefined` until the first push. */
|
|
994
1196
|
present: Signal<ReturnOf<L> | undefined>;
|
|
995
1197
|
/** This mount's session id (generated when not supplied). */
|
|
@@ -1065,6 +1267,43 @@ interface RateLimitResult {
|
|
|
1065
1267
|
* @experimental
|
|
1066
1268
|
*/
|
|
1067
1269
|
declare const rateLimit: (config: RateLimitConfig, options?: RateLimitOptions) => RateLimitResult;
|
|
1270
|
+
/**
|
|
1271
|
+
* `RunActionOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
1272
|
+
* @experimental
|
|
1273
|
+
*/
|
|
1274
|
+
interface RunActionOptions extends ActionCallOptions {
|
|
1275
|
+
/**
|
|
1276
|
+
* Client to run the action on. Defaults to the injected `LUNORA_CLIENT`.
|
|
1277
|
+
* Because actions usually fire from event handlers — which run *outside* an
|
|
1278
|
+
* injection context — capture the client once (`injectLunoraClient()` in a
|
|
1279
|
+
* field) and pass it here, or call `client.action(...)` directly.
|
|
1280
|
+
*/
|
|
1281
|
+
client?: LunoraClient;
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Run a Lunora action and resolve with the server result (rejects on failure).
|
|
1285
|
+
*
|
|
1286
|
+
* The sibling of `mutate`, and a plain function for the same reason: Angular's
|
|
1287
|
+
* adapter models writes as calls rather than reactive handles, because they fire
|
|
1288
|
+
* from event handlers where a signal-returning primitive has nothing to bind to.
|
|
1289
|
+
* The other adapters return a reactive `{ call, pending, … }` handle because
|
|
1290
|
+
* their idioms make that natural; this one does not.
|
|
1291
|
+
*
|
|
1292
|
+
* Unlike `mutate` there are no `optimistic` / `optimisticUpdate` options. An
|
|
1293
|
+
* optimistic update patches the subscription cache on the assumption a write
|
|
1294
|
+
* will land; an action is not a write — it runs in the Worker, may call a third
|
|
1295
|
+
* party, and has no declared effect on any query.
|
|
1296
|
+
*
|
|
1297
|
+
* ```ts
|
|
1298
|
+
* private readonly client = injectLunoraClient();
|
|
1299
|
+
* verify = () => runAction(api.commands.run, { command: "lunora", args: ["verify"] }, { client: this.client });
|
|
1300
|
+
* ```
|
|
1301
|
+
*
|
|
1302
|
+
* When called from within an injection context you may omit `client` and let it
|
|
1303
|
+
* resolve from the injector.
|
|
1304
|
+
* @experimental
|
|
1305
|
+
*/
|
|
1306
|
+
declare const runAction: <F extends FunctionReference>(reference: F, args: ArgsOf<F>, options?: RunActionOptions) => Promise<ReturnOf<F>>;
|
|
1068
1307
|
/**
|
|
1069
1308
|
* The lifecycle of a stream the primitive is observing.
|
|
1070
1309
|
* @experimental
|
|
@@ -1082,6 +1321,13 @@ interface StreamOptions {
|
|
|
1082
1321
|
* `inject(DestroyRef)` — the calling component/service.
|
|
1083
1322
|
*/
|
|
1084
1323
|
destroyRef?: DestroyRef;
|
|
1324
|
+
/**
|
|
1325
|
+
* Opt into resume-on-reconnect for a stream the server declared `durable`.
|
|
1326
|
+
* The chunks already received are kept and the socket re-attaches to the same
|
|
1327
|
+
* run, so a dropped connection mid-generation continues instead of surfacing
|
|
1328
|
+
* `STREAM_DISCONNECTED`. Has no effect on an ephemeral stream.
|
|
1329
|
+
*/
|
|
1330
|
+
durable?: boolean;
|
|
1085
1331
|
/** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
|
|
1086
1332
|
maxBuffer?: number;
|
|
1087
1333
|
/** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
|
|
@@ -1109,8 +1355,8 @@ interface StreamResult<T> {
|
|
|
1109
1355
|
* chunk the server pushes — use it for token-by-token deltas and other append-only
|
|
1110
1356
|
* feeds. Pass `"skip"` as `args` to keep the primitive mounted without opening a
|
|
1111
1357
|
* stream (mirrors `subscription`); the stream tears down when the owning
|
|
1112
|
-
* `DestroyRef` fires.
|
|
1113
|
-
* with signals.
|
|
1358
|
+
* `DestroyRef` fires. Nothing opens on the Angular server platform (SSR). The
|
|
1359
|
+
* Angular counterpart to React's `useStream`, re-expressed with signals.
|
|
1114
1360
|
*
|
|
1115
1361
|
* Call from an injection context (component/service field or constructor):
|
|
1116
1362
|
* ```ts
|
|
@@ -1131,6 +1377,14 @@ interface SubscriptionOptions {
|
|
|
1131
1377
|
* `inject(DestroyRef)` — the calling component/service.
|
|
1132
1378
|
*/
|
|
1133
1379
|
destroyRef?: DestroyRef;
|
|
1380
|
+
/**
|
|
1381
|
+
* `Injector` to create the reactive-args `effect()` from. Only needed when
|
|
1382
|
+
* `args` is a function/`Signal` AND `subscription` is called outside an
|
|
1383
|
+
* injection context (an explicit `destroyRef` is also being passed).
|
|
1384
|
+
* Defaults to the ambient injection context. Unused for the static `args`
|
|
1385
|
+
* form, which never creates an `effect()`.
|
|
1386
|
+
*/
|
|
1387
|
+
injector?: Injector;
|
|
1134
1388
|
/**
|
|
1135
1389
|
* Called when the subscription errors after the initial attach. Without it,
|
|
1136
1390
|
* a post-attach failure is dropped silently.
|
|
@@ -1164,9 +1418,13 @@ interface SubscriptionResult<T> {
|
|
|
1164
1418
|
* ```ts
|
|
1165
1419
|
* readonly stream = subscription(api.events.stream, { roomId: "general" });
|
|
1166
1420
|
* ```
|
|
1421
|
+
*
|
|
1422
|
+
* `args` also accepts a function/`Signal` to make the subscription reactive —
|
|
1423
|
+
* an args change tears the old subscription down and opens a fresh one for the
|
|
1424
|
+
* new args. A static (plain object) `args` resolves once and never re-runs.
|
|
1167
1425
|
* @experimental
|
|
1168
1426
|
*/
|
|
1169
|
-
declare const subscription: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip", options?: SubscriptionOptions) => SubscriptionResult<ReturnOf<F>>;
|
|
1427
|
+
declare const subscription: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip" | (() => ArgsOf<F> | "skip"), options?: SubscriptionOptions) => SubscriptionResult<ReturnOf<F>>;
|
|
1170
1428
|
/**
|
|
1171
1429
|
* Browser Web Audio subsystems for `voiceAgent` — the default microphone capture
|
|
1172
1430
|
* and speaker playback implementations injected into the primitive via its
|
|
@@ -1205,8 +1463,24 @@ interface MicrophoneConfig {
|
|
|
1205
1463
|
interruptChunks: number;
|
|
1206
1464
|
/** RMS above which the user is considered to be barging in while the agent speaks. */
|
|
1207
1465
|
interruptThreshold: number;
|
|
1208
|
-
/**
|
|
1209
|
-
|
|
1466
|
+
/**
|
|
1467
|
+
* `true` from the moment a turn is committed until it completes — the whole
|
|
1468
|
+
* `thinking` + `speaking` window, not just the audible half.
|
|
1469
|
+
*
|
|
1470
|
+
* It gates BOTH branches below, and the wider span is the point. Gated only
|
|
1471
|
+
* on "audibly speaking", turn detection kept running through the entire
|
|
1472
|
+
* STT+LLM window after a `commit`: room noise at the (deliberately low)
|
|
1473
|
+
* `silenceThreshold` re-armed `sawSpeech`, another quiet gap fired a SECOND
|
|
1474
|
+
* `commit`, and the DO refused it with "a turn is already in progress" —
|
|
1475
|
+
* a refusal that returns before draining the audio buffer, so the PCM
|
|
1476
|
+
* captured since the first commit leaked into the next utterance.
|
|
1477
|
+
*
|
|
1478
|
+
* A genuine barge-in still works in that window: it routes through the
|
|
1479
|
+
* `onInterrupt` branch, which needs `interruptChunks` consecutive chunks at
|
|
1480
|
+
* `interruptThreshold` — an order of magnitude above `silenceThreshold` —
|
|
1481
|
+
* and `interrupt` is exactly what the DO tells the client to send.
|
|
1482
|
+
*/
|
|
1483
|
+
isTurnActive: () => boolean;
|
|
1210
1484
|
/** One 16 kHz mono 16-bit little-endian PCM frame captured from the mic. */
|
|
1211
1485
|
onAudio: (pcm: Uint8Array) => void;
|
|
1212
1486
|
/** A barge-in was detected (RMS spike while the agent is speaking). */
|
|
@@ -1265,7 +1539,11 @@ interface VoiceAgentOptions {
|
|
|
1265
1539
|
* Audio graph stays isolated (and mockable in a non-browser test env).
|
|
1266
1540
|
*/
|
|
1267
1541
|
createMicrophone?: CreateMicrophone;
|
|
1268
|
-
/**
|
|
1542
|
+
/**
|
|
1543
|
+
* Advanced/test seam: open the transport. Defaults to the WebSocket
|
|
1544
|
+
* implementation the client was built with (`client.getWebSocketImpl()`),
|
|
1545
|
+
* NOT a raw `globalThis.WebSocket`.
|
|
1546
|
+
*/
|
|
1269
1547
|
createSocket?: CreateSocket;
|
|
1270
1548
|
/** Advanced/test seam: build the audio playback subsystem. Defaults to a Web Audio implementation. */
|
|
1271
1549
|
createSpeaker?: CreateSpeaker;
|
|
@@ -1282,8 +1560,12 @@ interface VoiceAgentOptions {
|
|
|
1282
1560
|
silenceDurationMs?: number;
|
|
1283
1561
|
/** Input RMS below which audio counts as silence. Default `0.01`. */
|
|
1284
1562
|
silenceThreshold?: number;
|
|
1285
|
-
/**
|
|
1286
|
-
|
|
1563
|
+
/**
|
|
1564
|
+
* The thread to converse on — shared with the agent's text turns. A plain
|
|
1565
|
+
* value, or a `Signal`/getter resolved afresh every time a call opens — the
|
|
1566
|
+
* reactive-args form the package's other primitives take.
|
|
1567
|
+
*/
|
|
1568
|
+
threadKey: (() => string) | string;
|
|
1287
1569
|
/** The generated `api.agents.<name>Voice` reference — identifies the voice DO endpoint. */
|
|
1288
1570
|
voice: VoiceReference;
|
|
1289
1571
|
}
|
|
@@ -1336,4 +1618,20 @@ interface VoiceAgentResult {
|
|
|
1336
1618
|
* @experimental
|
|
1337
1619
|
*/
|
|
1338
1620
|
declare const voiceAgent: (options: VoiceAgentOptions) => VoiceAgentResult;
|
|
1339
|
-
export { type AgentApi, type AgentChatApi, type AgentChatMessage, type AgentChatOptions, type AgentChatResult, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentResult, type AgentStateApi, type AgentStateOptions, type AgentStateResult, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentTokenStreamReference, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsOptions, type AgentToolEventsResult, type AuthGateResult, type AuthOptions, type AuthResult, type ConnectionStatusOptions, type
|
|
1621
|
+
export { type AgentApi, type AgentApprovalGrant, 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 LiveTopicOptions, type MutateOptions, type MutatorResult, type PaginatedQueryOptions, type PaginatedQueryResult, type PresenceOptions, type PresenceResult,
|
|
1622
|
+
/**
|
|
1623
|
+
* The Angular adapter for Lunora.
|
|
1624
|
+
*
|
|
1625
|
+
* Thin, idiomatic glue over the framework-neutral `@lunora/client`. Angular
|
|
1626
|
+
* signals map directly onto Lunora's per-subscription deltas, so a live query is
|
|
1627
|
+
* just a `signal` the WebSocket writes to.
|
|
1628
|
+
*
|
|
1629
|
+
* `provideLunora` / `LUNORA_CLIENT` / `injectLunoraClient` are the injectable
|
|
1630
|
+
* provider carrying one `LunoraClient` (opens its socket lazily), wired once in the
|
|
1631
|
+
* application config. `liveQuery` is a live-query `signal` that opens a
|
|
1632
|
+
* subscription and updates on every delta, torn down automatically on
|
|
1633
|
+
* `DestroyRef.onDestroy`. `mutate` runs a mutation (optimistic updates + offline
|
|
1634
|
+
* queue pass through to the client). `connectionStatus` is a `signal` of the
|
|
1635
|
+
* aggregate live-socket status.
|
|
1636
|
+
*/
|
|
1637
|
+
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, liveTopic, mutate, mutator, paginatedQuery, presence, provideLunora, rateLimit, runAction, stream, subscription, voiceAgent };
|