@lunora/angular 1.0.0-alpha.12 → 1.0.0-alpha.120
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 +42 -0
- package/dist/index.d.mts +243 -44
- package/dist/index.d.ts +243 -44
- package/dist/index.mjs +1 -19
- package/dist/packem_shared/LUNORA_CLIENT-B0toApHY.mjs +1 -0
- package/dist/packem_shared/agent-BCt1D_wQ.mjs +1 -0
- package/dist/packem_shared/agentChat-DMMjTLnF.mjs +1 -0
- package/dist/packem_shared/agentState-Cdyss0S4.mjs +1 -0
- package/dist/packem_shared/agentToolEvents-BOp6-TK8.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-BJxkgJR2.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-gUUl_6tS.mjs +1 -0
- package/dist/packem_shared/infiniteQuery-yZS4F7PI.mjs +1 -0
- package/dist/packem_shared/liveQuery-ZIgKq4et.mjs +1 -0
- package/dist/packem_shared/mutate-BZvLQLyu.mjs +1 -0
- package/dist/packem_shared/mutator-DjG1yGk8.mjs +1 -0
- package/dist/packem_shared/platform-DNlq-CRU.mjs +1 -0
- package/dist/packem_shared/presence-DUkZtSSL.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-CVSnLbC2.mjs +1 -0
- package/dist/packem_shared/subscription-B_Xj8Ezd.mjs +1 -0
- package/dist/packem_shared/voiceAgent-CyPFWGUt.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 +57 -0
- package/dist/upload.d.ts +57 -0
- package/dist/upload.mjs +1 -0
- package/package.json +12 -3
- package/dist/packem_shared/LUNORA_CLIENT-DHUfNu9x.mjs +0 -23
- package/dist/packem_shared/agent-DDKvrG4u.mjs +0 -31
- package/dist/packem_shared/agentChat-DDZlxK1v.mjs +0 -111
- package/dist/packem_shared/agentState-C8GWf3t3.mjs +0 -10
- package/dist/packem_shared/agentToolEvents-sXgYggvi.mjs +0 -59
- package/dist/packem_shared/auth-Df9N87Z4.mjs +0 -27
- package/dist/packem_shared/connectionStatus-BlLodleK.mjs +0 -15
- package/dist/packem_shared/flag-CGBo90HJ.mjs +0 -70
- package/dist/packem_shared/hydratePreloaded-DIpD1cAM.mjs +0 -33
- package/dist/packem_shared/infiniteQuery-nboKfr5E.mjs +0 -221
- package/dist/packem_shared/liveQuery-DVxKidjM.mjs +0 -32
- package/dist/packem_shared/mutate-D3rEHwbb.mjs +0 -8
- package/dist/packem_shared/mutator-BHL8bakL.mjs +0 -19
- package/dist/packem_shared/platform-Dg8Bppgq.mjs +0 -14
- package/dist/packem_shared/presence-BTuq19dS.mjs +0 -77
- package/dist/packem_shared/rateLimit-I4kRT9qV.mjs +0 -58
- package/dist/packem_shared/stream-PL64AghO.mjs +0 -47
- package/dist/packem_shared/subscription-oZ-WTmpp.mjs +0 -39
- package/dist/packem_shared/voiceAgent-DwbrDnB9.mjs +0 -401
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, MutationCallOptions, MutatorHandle, ActionCallOptions } from '@lunora/client';
|
|
3
3
|
export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, LunoraClientOptions, MutationCallOptions, Preloaded, ReturnOf, SubscriptionError, Unsubscribe } from '@lunora/client';
|
|
4
|
+
import { AuthStatus } from '@lunora/client/auth';
|
|
4
5
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
6
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
6
7
|
export { SKIP } from '@lunora/client/query';
|
|
@@ -22,8 +23,12 @@ type AgentThreadStatus = "awaiting_input" | "cancelled" | "error" | "idle" | "ru
|
|
|
22
23
|
*/
|
|
23
24
|
interface AgentThreadRecord {
|
|
24
25
|
createdAt?: number;
|
|
25
|
-
/**
|
|
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;
|
|
@@ -125,7 +130,7 @@ interface AgentOptions {
|
|
|
125
130
|
api: AgentApi;
|
|
126
131
|
/**
|
|
127
132
|
* Optional app mutation over the agent's cancel path
|
|
128
|
-
* (`ctx.agents
|
|
133
|
+
* (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
|
|
129
134
|
* When omitted (or no run is in flight) {@link AgentResult.cancel} is a no-op.
|
|
130
135
|
*/
|
|
131
136
|
cancel?: FunctionReference<"mutation">;
|
|
@@ -136,9 +141,15 @@ interface AgentOptions {
|
|
|
136
141
|
* `inject(DestroyRef)` — the calling component/service.
|
|
137
142
|
*/
|
|
138
143
|
destroyRef?: DestroyRef;
|
|
144
|
+
/**
|
|
145
|
+
* Called when the live thread subscription reports an error (a session
|
|
146
|
+
* expiry, an RLS denial). Without it — and without reading `error` — such a
|
|
147
|
+
* failure is invisible and `thread` / `status` are cleared until a later frame arrives.
|
|
148
|
+
*/
|
|
149
|
+
onError?: SubscriptionErrorCallback;
|
|
139
150
|
/**
|
|
140
151
|
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
141
|
-
* `ctx.agents
|
|
152
|
+
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
142
153
|
* {@link AgentOptions.runArgs} and the per-call args.
|
|
143
154
|
*/
|
|
144
155
|
run: FunctionReference<"mutation">;
|
|
@@ -157,6 +168,8 @@ interface AgentResult {
|
|
|
157
168
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
158
169
|
*/
|
|
159
170
|
cancel: () => Promise<void>;
|
|
171
|
+
/** The live thread subscription's last error, or `undefined`. */
|
|
172
|
+
error: Signal<SubscriptionError | undefined>;
|
|
160
173
|
/** `true` while a `run` invocation is in flight. */
|
|
161
174
|
pending: Signal<boolean>;
|
|
162
175
|
/** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
|
|
@@ -174,7 +187,7 @@ interface AgentResult {
|
|
|
174
187
|
* conversation surface (durable history + streaming + approvals) use `agentChat`.
|
|
175
188
|
*
|
|
176
189
|
* `run` and `cancel` stay generic over the app-defined mutations that wrap
|
|
177
|
-
* `ctx.agents
|
|
190
|
+
* `ctx.agents.<name>.run` / `.cancel`, so the primitive hard-codes no function
|
|
178
191
|
* names beyond the `agents:*` surface.
|
|
179
192
|
*
|
|
180
193
|
* Call from an injection context (component/service field or constructor); pass an
|
|
@@ -232,7 +245,7 @@ interface AgentChatOptions {
|
|
|
232
245
|
api: AgentChatApi;
|
|
233
246
|
/**
|
|
234
247
|
* Optional app mutation over the agent's cancel path
|
|
235
|
-
* (`ctx.agents
|
|
248
|
+
* (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
|
|
236
249
|
* When omitted (or no run is in flight) {@link AgentChatResult.cancel} is a
|
|
237
250
|
* no-op.
|
|
238
251
|
*/
|
|
@@ -246,9 +259,15 @@ interface AgentChatOptions {
|
|
|
246
259
|
destroyRef?: DestroyRef;
|
|
247
260
|
/** History depth forwarded to `agents:agentMessages`. */
|
|
248
261
|
limit?: number;
|
|
262
|
+
/**
|
|
263
|
+
* Called when the live history or thread subscription reports an error (a
|
|
264
|
+
* session expiry, an RLS denial). Without it — and without reading `error` —
|
|
265
|
+
* such a failure is invisible and `messages` / `status` are cleared until a later frame arrives.
|
|
266
|
+
*/
|
|
267
|
+
onError?: SubscriptionErrorCallback;
|
|
249
268
|
/**
|
|
250
269
|
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
251
|
-
* `ctx.agents
|
|
270
|
+
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
252
271
|
* {@link AgentChatOptions.sendArgs} and the per-call args.
|
|
253
272
|
*/
|
|
254
273
|
send: FunctionReference<"mutation">;
|
|
@@ -275,6 +294,8 @@ interface AgentChatResult {
|
|
|
275
294
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
276
295
|
*/
|
|
277
296
|
cancel: () => Promise<void>;
|
|
297
|
+
/** The history or thread subscription's last error, or `undefined`. */
|
|
298
|
+
error: Signal<SubscriptionError | undefined>;
|
|
278
299
|
/** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
|
|
279
300
|
messages: Signal<ReadonlyArray<AgentChatMessage>>;
|
|
280
301
|
/** Reject a paused human-in-the-loop tool call (optionally with a reason). */
|
|
@@ -363,7 +384,7 @@ interface AgentStateResult<T> {
|
|
|
363
384
|
* only on a real `setState`. The Angular counterpart to React's `useAgentState`,
|
|
364
385
|
* re-expressed with signals.
|
|
365
386
|
*
|
|
366
|
-
* Generic over the app's state shape (`agentState
|
|
387
|
+
* Generic over the app's state shape (`agentState<SupportState>(...)`, itself a
|
|
367
388
|
* record) — the reference is typed as an optional record because codegen cannot see
|
|
368
389
|
* the per-agent state type; the generic casts to `T`. The `extends` bound (not a
|
|
369
390
|
* bare unbounded type parameter) is required: this `.ts` file is parsed JSX-aware by
|
|
@@ -502,6 +523,12 @@ interface AuthOptions {
|
|
|
502
523
|
interface AuthResult {
|
|
503
524
|
/** Set the auth token (sign-in / sign-out). */
|
|
504
525
|
setToken: (token: string | null) => void;
|
|
526
|
+
/**
|
|
527
|
+
* The resolved auth state. Branch on this, not on `user() === null` — see the
|
|
528
|
+
* contract in `@lunora/client/auth`; `user` is `null` both when signed out
|
|
529
|
+
* and when a held credential's identity could not be resolved.
|
|
530
|
+
*/
|
|
531
|
+
status: Signal<AuthStatus>;
|
|
505
532
|
/** The current auth token, or `null`. */
|
|
506
533
|
token: Signal<string | null>;
|
|
507
534
|
/** The resolved user from `store.getUser()`, or `null`. */
|
|
@@ -524,6 +551,34 @@ interface AuthResult {
|
|
|
524
551
|
* @experimental
|
|
525
552
|
*/
|
|
526
553
|
declare const auth: (options?: AuthOptions) => AuthResult;
|
|
554
|
+
/**
|
|
555
|
+
* `AuthGateResult` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
556
|
+
* @experimental
|
|
557
|
+
*/
|
|
558
|
+
interface AuthGateResult {
|
|
559
|
+
/** `true` once a credential is held and nothing has contradicted it. */
|
|
560
|
+
isAuthenticated: Signal<boolean>;
|
|
561
|
+
/** `true` while a credential's first identity resolve is in flight. */
|
|
562
|
+
isLoading: Signal<boolean>;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Derived auth-gate signals for template gating (Angular's `\@if` control
|
|
566
|
+
* flow), built on {@link auth}. Angular has no JSX-style `Authenticated` slot
|
|
567
|
+
* component the way React/Vue/Solid do, so this exposes the same three-state
|
|
568
|
+
* logic as two booleans instead, mapped from the shared `AuthStatus` contract in
|
|
569
|
+
* `@lunora/client/auth`: a credential whose first identity resolve is in flight
|
|
570
|
+
* is `isLoading`; a credential nothing has contradicted — including one whose
|
|
571
|
+
* identity endpoint is unreachable — is `isAuthenticated`; no session is neither
|
|
572
|
+
* (the signed-out state a template checks for with a plain `\@else`).
|
|
573
|
+
*
|
|
574
|
+
* Call from an injection context (component/service field or constructor):
|
|
575
|
+
* ```ts
|
|
576
|
+
* protected readonly authState = authGate();
|
|
577
|
+
* // template: \@if (authState.isAuthenticated()) { ... } \@else if (authState.isLoading()) { ... }
|
|
578
|
+
* ```
|
|
579
|
+
* @experimental
|
|
580
|
+
*/
|
|
581
|
+
declare const authGate: (options?: AuthOptions) => AuthGateResult;
|
|
527
582
|
/**
|
|
528
583
|
* DI token carrying the framework-neutral {@link LunoraClient}. Every reactive
|
|
529
584
|
* primitive in this adapter (`liveQuery`, `mutate`, `connectionStatus`) reads the
|
|
@@ -599,16 +654,15 @@ interface ConnectionStatusOptions {
|
|
|
599
654
|
* @experimental
|
|
600
655
|
*/
|
|
601
656
|
declare const connectionStatus: (options?: ConnectionStatusOptions) => Signal<ConnectionStatus>;
|
|
657
|
+
/** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
|
|
658
|
+
type FlagValue$1 = boolean | number | string | {
|
|
659
|
+
[key: string]: unknown;
|
|
660
|
+
} | unknown[] | null;
|
|
602
661
|
/**
|
|
603
662
|
* The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags.
|
|
604
663
|
* @experimental
|
|
605
664
|
*/
|
|
606
|
-
type FlagValue =
|
|
607
|
-
/**
|
|
608
|
-
* Targeting context bag forwarded to the OpenFeature provider.
|
|
609
|
-
* @experimental
|
|
610
|
-
*/
|
|
611
|
-
type FlagContext = Record<string, unknown>;
|
|
665
|
+
type FlagValue = FlagValue$1;
|
|
612
666
|
/**
|
|
613
667
|
* `FlagOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
614
668
|
* @experimental
|
|
@@ -616,11 +670,6 @@ type FlagContext = Record<string, unknown>;
|
|
|
616
670
|
interface FlagOptions {
|
|
617
671
|
/** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
|
|
618
672
|
client?: LunoraClient;
|
|
619
|
-
/**
|
|
620
|
-
* Per-call targeting context merged on top of the app's default `identify`
|
|
621
|
-
* targeting key.
|
|
622
|
-
*/
|
|
623
|
-
context?: FlagContext;
|
|
624
673
|
/** `DestroyRef` whose `onDestroy` tears down the subscription. Defaults to `inject(DestroyRef)`. */
|
|
625
674
|
destroyRef?: DestroyRef;
|
|
626
675
|
}
|
|
@@ -632,9 +681,16 @@ interface FlagOptions {
|
|
|
632
681
|
* The flag's kind is inferred from `defaultValue`'s runtime type, so
|
|
633
682
|
* `flag("dark", false)` reads a boolean and `flag("hero", "control")` a string.
|
|
634
683
|
*
|
|
684
|
+
* The reactive channel is public, so the server evaluates every flag under the
|
|
685
|
+
* socket's own verified identity — the targeting key your `defineFlags({
|
|
686
|
+
* identify })` derives — and accepts no client-supplied targeting context. For
|
|
687
|
+
* evaluation under a context you compute, call `ctx.flags.*` inside a query,
|
|
688
|
+
* mutation, or action and return the resolved value.
|
|
689
|
+
*
|
|
635
690
|
* Evaluation runs through whatever OpenFeature provider the app wired in
|
|
636
691
|
* `lunora/flags.ts`; the read never throws — a provider error resolves the
|
|
637
|
-
* default (the same fail-open contract as server-side `ctx.flags`).
|
|
692
|
+
* default (the same fail-open contract as server-side `ctx.flags`). No
|
|
693
|
+
* subscription opens during SSR; the signal stays at `defaultValue`.
|
|
638
694
|
*
|
|
639
695
|
* Call from an injection context:
|
|
640
696
|
* ```ts
|
|
@@ -650,11 +706,6 @@ declare const flag: <T extends FlagValue>(key: string, defaultValue: T, options?
|
|
|
650
706
|
interface FlagsOptions {
|
|
651
707
|
/** Client to bind to. Defaults to the injected `LUNORA_CLIENT`. */
|
|
652
708
|
client?: LunoraClient;
|
|
653
|
-
/**
|
|
654
|
-
* Targeting context shared by every flag in the set, merged on top of the
|
|
655
|
-
* app's default `identify` targeting key.
|
|
656
|
-
*/
|
|
657
|
-
context?: FlagContext;
|
|
658
709
|
/** `DestroyRef` whose `onDestroy` tears down the subscriptions. Defaults to `inject(DestroyRef)`. */
|
|
659
710
|
destroyRef?: DestroyRef;
|
|
660
711
|
}
|
|
@@ -663,7 +714,8 @@ interface FlagsOptions {
|
|
|
663
714
|
*
|
|
664
715
|
* Pass a record of `key → defaultValue`; each flag's kind is inferred from its
|
|
665
716
|
* default, and the returned signal holds the same-shaped record with resolved
|
|
666
|
-
* values (the defaults until each evaluation lands).
|
|
717
|
+
* values (the defaults until each evaluation lands). Like {@link flag} it
|
|
718
|
+
* evaluates under the socket's server-verified identity only.
|
|
667
719
|
*
|
|
668
720
|
* Call from an injection context:
|
|
669
721
|
* ```ts
|
|
@@ -728,6 +780,16 @@ interface LiveQueryOptions {
|
|
|
728
780
|
* component is destroyed. Pass one explicitly to control the lifetime yourself.
|
|
729
781
|
*/
|
|
730
782
|
destroyRef?: DestroyRef;
|
|
783
|
+
/**
|
|
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;
|
|
731
793
|
/**
|
|
732
794
|
* Called when the subscription errors after the initial attach — the async
|
|
733
795
|
* error channel `createQuerySubscription` only wires when a sink is present.
|
|
@@ -761,9 +823,17 @@ interface LiveQueryOptions {
|
|
|
761
823
|
* short-circuit — no network call, no socket; the signal stays `undefined`. To
|
|
762
824
|
* call outside an injection context (e.g. lazily in `ngOnInit`), supply `client`
|
|
763
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.
|
|
764
834
|
* @experimental
|
|
765
835
|
*/
|
|
766
|
-
declare const liveQuery: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip", options?: LiveQueryOptions) => Signal<ReturnOf<F> | undefined>;
|
|
836
|
+
declare const liveQuery: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip" | (() => ArgsOf<F> | "skip"), options?: LiveQueryOptions) => Signal<ReturnOf<F> | undefined>;
|
|
767
837
|
/**
|
|
768
838
|
* `MutateOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
769
839
|
* @experimental
|
|
@@ -851,6 +921,15 @@ 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
|
}
|
|
@@ -859,6 +938,13 @@ interface PaginatedQueryOptions {
|
|
|
859
938
|
* @experimental
|
|
860
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"`. */
|
|
@@ -873,6 +959,8 @@ interface PaginatedQueryResult<T> {
|
|
|
873
959
|
* @experimental
|
|
874
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. */
|
|
@@ -901,9 +989,13 @@ interface InfiniteQueryResult<T> {
|
|
|
901
989
|
* ```ts
|
|
902
990
|
* readonly messages = paginatedQuery(api.messages.list, {}, { initialNumItems: 20 });
|
|
903
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.
|
|
904
996
|
* @experimental
|
|
905
997
|
*/
|
|
906
|
-
declare const paginatedQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip", options: PaginatedQueryOptions) => PaginatedQueryResult<PageItemOf<F>>;
|
|
998
|
+
declare const paginatedQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip" | (() => PaginatedArgs<F> | "skip"), options: PaginatedQueryOptions) => PaginatedQueryResult<PageItemOf<F>>;
|
|
907
999
|
/**
|
|
908
1000
|
* Subscribe to a reactively-paginated query and expose its pages discretely.
|
|
909
1001
|
*
|
|
@@ -915,9 +1007,12 @@ declare const paginatedQuery: <F extends FunctionReference>(reference: F, args:
|
|
|
915
1007
|
* ```ts
|
|
916
1008
|
* readonly feed = infiniteQuery(api.messages.list, {}, { initialNumItems: 20 });
|
|
917
1009
|
* ```
|
|
1010
|
+
*
|
|
1011
|
+
* `args` also accepts a function/`Signal` to make the query reactive — see
|
|
1012
|
+
* `paginatedQuery`'s equivalent note.
|
|
918
1013
|
* @experimental
|
|
919
1014
|
*/
|
|
920
|
-
declare const infiniteQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip", options: PaginatedQueryOptions) => InfiniteQueryResult<PageItemOf<F>>;
|
|
1015
|
+
declare const infiniteQuery: <F extends FunctionReference>(reference: F, args: PaginatedArgs<F> | "skip" | (() => PaginatedArgs<F> | "skip"), options: PaginatedQueryOptions) => InfiniteQueryResult<PageItemOf<F>>;
|
|
921
1016
|
/**
|
|
922
1017
|
* `HeartbeatReference` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
923
1018
|
* @experimental
|
|
@@ -951,6 +1046,12 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
|
|
|
951
1046
|
intervalMs?: number;
|
|
952
1047
|
/** The `api.*` reference for the presence listPresent query. */
|
|
953
1048
|
listPresent: L;
|
|
1049
|
+
/**
|
|
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;
|
|
954
1055
|
/**
|
|
955
1056
|
* Stable id for this presence row. Defaults to a fresh per-call id.
|
|
956
1057
|
* Pass a user/connection id to control deduping across tabs.
|
|
@@ -964,6 +1065,8 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
|
|
|
964
1065
|
* @experimental
|
|
965
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). */
|
|
@@ -1039,6 +1142,43 @@ interface RateLimitResult {
|
|
|
1039
1142
|
* @experimental
|
|
1040
1143
|
*/
|
|
1041
1144
|
declare const rateLimit: (config: RateLimitConfig, options?: RateLimitOptions) => RateLimitResult;
|
|
1145
|
+
/**
|
|
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>>;
|
|
1042
1182
|
/**
|
|
1043
1183
|
* The lifecycle of a stream the primitive is observing.
|
|
1044
1184
|
* @experimental
|
|
@@ -1056,6 +1196,13 @@ interface StreamOptions {
|
|
|
1056
1196
|
* `inject(DestroyRef)` — the calling component/service.
|
|
1057
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. */
|
|
@@ -1083,8 +1230,8 @@ interface StreamResult<T> {
|
|
|
1083
1230
|
* chunk the server pushes — use it for token-by-token deltas and other append-only
|
|
1084
1231
|
* feeds. Pass `"skip"` as `args` to keep the primitive mounted without opening a
|
|
1085
1232
|
* stream (mirrors `subscription`); the stream tears down when the owning
|
|
1086
|
-
* `DestroyRef` fires.
|
|
1087
|
-
* with signals.
|
|
1233
|
+
* `DestroyRef` fires. Nothing opens on the Angular server platform (SSR). The
|
|
1234
|
+
* Angular counterpart to React's `useStream`, re-expressed with signals.
|
|
1088
1235
|
*
|
|
1089
1236
|
* Call from an injection context (component/service field or constructor):
|
|
1090
1237
|
* ```ts
|
|
@@ -1105,6 +1252,14 @@ interface SubscriptionOptions {
|
|
|
1105
1252
|
* `inject(DestroyRef)` — the calling component/service.
|
|
1106
1253
|
*/
|
|
1107
1254
|
destroyRef?: DestroyRef;
|
|
1255
|
+
/**
|
|
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;
|
|
1108
1263
|
/**
|
|
1109
1264
|
* Called when the subscription errors after the initial attach. Without it,
|
|
1110
1265
|
* a post-attach failure is dropped silently.
|
|
@@ -1138,9 +1293,13 @@ interface SubscriptionResult<T> {
|
|
|
1138
1293
|
* ```ts
|
|
1139
1294
|
* readonly stream = subscription(api.events.stream, { roomId: "general" });
|
|
1140
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.
|
|
1141
1300
|
* @experimental
|
|
1142
1301
|
*/
|
|
1143
|
-
declare const subscription: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip", options?: SubscriptionOptions) => SubscriptionResult<ReturnOf<F>>;
|
|
1302
|
+
declare const subscription: <F extends FunctionReference>(reference: F, args: ArgsOf<F> | "skip" | (() => ArgsOf<F> | "skip"), options?: SubscriptionOptions) => SubscriptionResult<ReturnOf<F>>;
|
|
1144
1303
|
/**
|
|
1145
1304
|
* Browser Web Audio subsystems for `voiceAgent` — the default microphone capture
|
|
1146
1305
|
* and speaker playback implementations injected into the primitive via its
|
|
@@ -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
|
-
/**
|
|
1183
|
-
|
|
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,9 +1374,9 @@ type CreateSpeaker = (config: {
|
|
|
1199
1374
|
audioFormat: VoiceAudioFormat;
|
|
1200
1375
|
}) => VoiceSpeaker;
|
|
1201
1376
|
/**
|
|
1202
|
-
* The `agents
|
|
1377
|
+
* The `agents.<name>Voice` reference codegen emits for a voice-enabled agent — a
|
|
1203
1378
|
* live, WS-backed session keyed by `threadKey`. A structural subset of the
|
|
1204
|
-
* generated member, so passing `api.agents
|
|
1379
|
+
* generated member, so passing `api.agents.<name>Voice` type-checks.
|
|
1205
1380
|
* @experimental
|
|
1206
1381
|
*/
|
|
1207
1382
|
type VoiceReference = FunctionReference<"stream", {
|
|
@@ -1239,7 +1414,11 @@ interface VoiceAgentOptions {
|
|
|
1239
1414
|
* Audio graph stays isolated (and mockable in a non-browser test env).
|
|
1240
1415
|
*/
|
|
1241
1416
|
createMicrophone?: CreateMicrophone;
|
|
1242
|
-
/**
|
|
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
|
+
*/
|
|
1243
1422
|
createSocket?: CreateSocket;
|
|
1244
1423
|
/** Advanced/test seam: build the audio playback subsystem. Defaults to a Web Audio implementation. */
|
|
1245
1424
|
createSpeaker?: CreateSpeaker;
|
|
@@ -1256,9 +1435,13 @@ interface VoiceAgentOptions {
|
|
|
1256
1435
|
silenceDurationMs?: number;
|
|
1257
1436
|
/** Input RMS below which audio counts as silence. Default `0.01`. */
|
|
1258
1437
|
silenceThreshold?: number;
|
|
1259
|
-
/**
|
|
1260
|
-
|
|
1261
|
-
|
|
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. */
|
|
1262
1445
|
voice: VoiceReference;
|
|
1263
1446
|
}
|
|
1264
1447
|
/**
|
|
@@ -1294,7 +1477,7 @@ interface VoiceAgentResult {
|
|
|
1294
1477
|
* WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
|
|
1295
1478
|
* streams the agent's synthesized speech back through the browser's audio output,
|
|
1296
1479
|
* and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
|
|
1297
|
-
* `audioLevel`) to Angular signals. Pass the generated `api.agents
|
|
1480
|
+
* `audioLevel`) to Angular signals. Pass the generated `api.agents.<name>Voice`
|
|
1298
1481
|
* reference (never a string), matching `agentChat`'s reference-passing style. The
|
|
1299
1482
|
* Angular counterpart to React's `useVoiceAgent`, re-expressed with signals; the
|
|
1300
1483
|
* per-call connection lives in a closure variable (the primitive runs once per
|
|
@@ -1310,4 +1493,20 @@ interface VoiceAgentResult {
|
|
|
1310
1493
|
* @experimental
|
|
1311
1494
|
*/
|
|
1312
1495
|
declare const voiceAgent: (options: VoiceAgentOptions) => VoiceAgentResult;
|
|
1313
|
-
export { type AgentApi, type AgentChatApi, type AgentChatMessage, type AgentChatOptions, type AgentChatResult, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentResult, type AgentStateApi, type AgentStateOptions, type AgentStateResult, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentTokenStreamReference, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsOptions, type AgentToolEventsResult, type
|
|
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { agentChat } from './packem_shared/agentChat-DDZlxK1v.mjs';
|
|
3
|
-
export { agentState } from './packem_shared/agentState-C8GWf3t3.mjs';
|
|
4
|
-
export { agentToolEvents } from './packem_shared/agentToolEvents-sXgYggvi.mjs';
|
|
5
|
-
export { auth } from './packem_shared/auth-Df9N87Z4.mjs';
|
|
6
|
-
export { LUNORA_CLIENT, injectLunoraClient, provideLunora } from './packem_shared/LUNORA_CLIENT-DHUfNu9x.mjs';
|
|
7
|
-
export { connectionStatus } from './packem_shared/connectionStatus-BlLodleK.mjs';
|
|
8
|
-
export { flag, flags } from './packem_shared/flag-CGBo90HJ.mjs';
|
|
9
|
-
export { hydratePreloaded } from './packem_shared/hydratePreloaded-DIpD1cAM.mjs';
|
|
10
|
-
export { liveQuery } from './packem_shared/liveQuery-DVxKidjM.mjs';
|
|
11
|
-
export { mutate } from './packem_shared/mutate-D3rEHwbb.mjs';
|
|
12
|
-
export { mutator } from './packem_shared/mutator-BHL8bakL.mjs';
|
|
13
|
-
export { infiniteQuery, paginatedQuery } from './packem_shared/infiniteQuery-nboKfr5E.mjs';
|
|
14
|
-
export { presence } from './packem_shared/presence-BTuq19dS.mjs';
|
|
15
|
-
export { rateLimit } from './packem_shared/rateLimit-I4kRT9qV.mjs';
|
|
16
|
-
export { stream } from './packem_shared/stream-PL64AghO.mjs';
|
|
17
|
-
export { subscription } from './packem_shared/subscription-oZ-WTmpp.mjs';
|
|
18
|
-
export { voiceAgent } from './packem_shared/voiceAgent-DwbrDnB9.mjs';
|
|
19
|
-
export { SKIP } from '@lunora/client/query';
|
|
1
|
+
import{agent as t}from"./packem_shared/agent-BCt1D_wQ.mjs";import{agentChat as m}from"./packem_shared/agentChat-DMMjTLnF.mjs";import{agentState as f}from"./packem_shared/agentState-Cdyss0S4.mjs";import{agentToolEvents as n}from"./packem_shared/agentToolEvents-BOp6-TK8.mjs";import{auth as i,authGate as u}from"./packem_shared/auth-C3dB8sYS.mjs";import{LUNORA_CLIENT as c,injectLunoraClient as s,provideLunora as l}from"./packem_shared/LUNORA_CLIENT-B0toApHY.mjs";import{connectionStatus as L}from"./packem_shared/connectionStatus-UhmuwzMa.mjs";import{flag as v,flags as y}from"./packem_shared/flag-BJxkgJR2.mjs";import{hydratePreloaded as C}from"./packem_shared/hydratePreloaded-gUUl_6tS.mjs";import{liveQuery as S}from"./packem_shared/liveQuery-ZIgKq4et.mjs";import{mutate as I}from"./packem_shared/mutate-BZvLQLyu.mjs";import{mutator as P}from"./packem_shared/mutator-DjG1yGk8.mjs";import{infiniteQuery as b,paginatedQuery as j}from"./packem_shared/infiniteQuery-yZS4F7PI.mjs";import{presence as K}from"./packem_shared/presence-DUkZtSSL.mjs";import{rateLimit as R}from"./packem_shared/rateLimit-B3h9qzh-.mjs";import{runAction as _}from"./packem_shared/runAction-BfiPq4Xz.mjs";import{stream as q}from"./packem_shared/stream-CVSnLbC2.mjs";import{subscription as z}from"./packem_shared/subscription-B_Xj8Ezd.mjs";import{voiceAgent as D}from"./packem_shared/voiceAgent-CyPFWGUt.mjs";import{SKIP as H}from"@lunora/client/query";export{c as LUNORA_CLIENT,H as SKIP,t as agent,m as agentChat,f as agentState,n as agentToolEvents,i as auth,u as authGate,L as connectionStatus,v as flag,y as flags,C as hydratePreloaded,b as infiniteQuery,s as injectLunoraClient,S as liveQuery,I as mutate,P as mutator,j as paginatedQuery,K as presence,l as provideLunora,R as rateLimit,_ as runAction,q as stream,z as subscription,D as voiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InjectionToken as t,makeEnvironmentProviders as i,inject as c}from"@angular/core";import{LunoraClient as r}from"@lunora/client";const o=()=>globalThis.location?.origin??"",e=new t("lunora.client",{factory:()=>new r({url:o()}),providedIn:"root"}),s=(n={})=>i([{provide:e,useFactory:()=>n instanceof r?n:new r({...n,url:n.url??o()})}]),a=()=>c(e),m=n=>n??a();export{e as LUNORA_CLIENT,a as injectLunoraClient,s as provideLunora,m as resolveLunoraClient};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as o,signal as R}from"@angular/core";import{resolveLunoraClient as h}from"./LUNORA_CLIENT-B0toApHY.mjs";import{subscription as v}from"./subscription-B_Xj8Ezd.mjs";const x=t=>{const{api:i,cancel:c,onError:d,run:l,runArgs:u,threadKey:n}=t,a=h(t.client),{data:f,error:m}=v(i.agents.agentThread,{key:n},{client:a,destroyRef:t.destroyRef,onError:d}),r=o(()=>f()),y=o(()=>r()?.status),s=R(!1),g=async(e,p)=>{s.set(!0);try{await a.mutation(l,{input:e,threadKey:n,...u,...p})}finally{s.set(!1)}};return{cancel:async()=>{const e=r()?.instanceId;c===void 0||e===void 0||await a.mutation(c,{instanceId:e,threadKey:n})},error:m,pending:s.asReadonly(),run:g,status:y,thread:r}};export{x as agent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as a,signal as L}from"@angular/core";import{reconcileOptimistic as k,maxSeq as w}from"@lunora/client";import{resolveLunoraClient as N}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as $}from"./stream-CVSnLbC2.mjs";import{subscription as x}from"./subscription-B_Xj8Ezd.mjs";const z={__lunoraRef:""},W=m=>{const{api:d,cancel:g,limit:h,onError:f,send:A,sendArgs:E,stream:y,threadKey:r}=m,s=N(m.client),{destroyRef:l}=m,b=h===void 0?{key:r}:{key:r,limit:h},{data:I,error:S}=x(d.agents.agentMessages,b,{client:s,destroyRef:l,onError:f}),{data:j,error:q}=x(d.agents.agentThread,{key:r},{client:s,destroyRef:l,onError:f}),C=a(()=>S()??q()),_=y===void 0?"skip":{key:r},{chunks:D}=$(y??z,_,{client:s,destroyRef:l}),c=L([]);let v=0;const u=a(()=>j()),T=a(()=>u()?.status),i=a(()=>I()??[]),K=a(()=>{const t=i(),e=k(c(),t);if(e.length===0)return t;const n=w(t);return[...t,...e.map((o,p)=>({content:o.content,optimistic:!0,role:"user",seq:n+1+p}))]}),M=a(()=>{const t=i().filter(e=>e.role==="assistant").length;return D().filter(e=>e.kind!=="progress"&&e.threadKey===r&&e.turn>=t).map(e=>e.text).join("")}),O=async(t,e)=>{const n=v;v+=1;const o=w(i());c.set([...k(c(),i()),{content:t,id:n,maxDurableSeqAtSend:o}]);try{await s.mutation(A,{input:t,threadKey:r,...E,...e})}catch(p){throw c.set(c().filter(F=>F.id!==n)),p}},R=async(t,e,n)=>{const o=u()?.instanceId;if(o===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await s.mutation(d.agents.agentResolveApproval,{decision:t,instanceId:o,threadKey:r,toolCallId:e,...n===void 0?{}:{note:n}})};return{approve:async(t,e)=>R("approve",t,e),cancel:async()=>{const t=u()?.instanceId;g===void 0||t===void 0||await s.mutation(g,{instanceId:t,threadKey:r})},error:C,messages:K,reject:async(t,e)=>R("reject",t,e),send:O,status:T,streamingText:M}};export{W as agentChat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as c}from"@angular/core";import{subscription as n}from"./subscription-B_Xj8Ezd.mjs";const d=t=>{const{data:e,error:r}=n(t.api.agents.agentState,{key:t.threadKey},{client:t.client,destroyRef:t.destroyRef}),a=c(()=>e());return{error:r,state:a}};export{d as agentState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as v}from"@angular/core";import{resolveLunoraClient as f}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as C}from"./stream-CVSnLbC2.mjs";import{subscription as y}from"./subscription-B_Xj8Ezd.mjs";const I={__lunoraRef:""},N=[],m=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(l=>({input:l.input,seq:t.seq,toolCallId:l.id,toolName:l.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]},R=t=>{const{api:l,limit:n,stream:e,threadKey:r}=t,a=f(t.client),{destroyRef:i}=t,u=n===void 0?{key:r}:{key:r,limit:n},{data:p}=y(l.agents.agentMessages,u,{client:a,destroyRef:i}),s=e===void 0?"skip":{key:r},{chunks:c}=C(e??I,s,{client:a,destroyRef:i});return{events:v(()=>{const d=(p()??N).flatMap(o=>m(o)??[]);for(const o of c())o.kind==="progress"&&o.threadKey===r&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}};export{R as agentToolEvents};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as h,DestroyRef as k,signal as o,computed as c}from"@angular/core";import{getIdentityStore as l,isLoadingStatus as y,isAuthenticatedStatus as m}from"@lunora/client/auth";import{resolveLunoraClient as A}from"./LUNORA_CLIENT-B0toApHY.mjs";const T=(s={})=>{const t=A(s.client),n=s.destroyRef??h(k),e=l(t),u=o(t.getAuthToken()),r=o(e.getUser()),a=o(e.getStatus()),i=t.onAuthTokenChange(()=>{u.set(t.getAuthToken())}),d=e.subscribe(()=>{r.set(e.getUser()),a.set(e.getStatus())});return n.onDestroy(()=>{i(),d()}),{setToken:g=>{t.setAuthToken(g)},status:a.asReadonly(),token:u.asReadonly(),user:r.asReadonly()}},p=(s={})=>{const{status:t}=T(s),n=c(()=>y(t()));return{isAuthenticated:c(()=>m(t())),isLoading:n}};export{T as auth,p as authGate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as r,DestroyRef as i,signal as a}from"@angular/core";import{resolveLunoraClient as u}from"./LUNORA_CLIENT-B0toApHY.mjs";const y=(t={})=>{const n=u(t.client),e=t.destroyRef??r(i),o=a(n.connectionStatus()),s=n.onConnectionStatus(c=>{o.set(c)});return e.onDestroy(s),o.asReadonly()};export{y as connectionStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as l,DestroyRef as u,signal as a}from"@angular/core";import{resolveLunoraClient as i}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as d}from"./platform-DNlq-CRU.mjs";const m="__lunora_flags__:eval",_=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:m},y=(t,e,n)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:_(e.default)},c=>{n(c)},{onError:()=>{n(e.default)}})}catch{return()=>{}}},k=(t,e,n={})=>{const c=i(n.client),f=n.destroyRef===void 0,o=n.destroyRef??l(u),r=a(e);return d(f)&&o.onDestroy(y(c,{default:e,key:t},s=>{r.set(s)})),r.asReadonly()},h=(t,e={})=>{const n=i(e.client),c=e.destroyRef===void 0,f=e.destroyRef??l(u),o=a({...t});if(!d(c))return o.asReadonly();const r=[];for(const[s,b]of Object.entries(t))r.push(y(n,{default:b,key:s},R=>{o.set({...o(),[s]:R})}));return f.onDestroy(()=>{for(const s of r)s()}),o.asReadonly()};export{k as flag,h as flags};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as m,DestroyRef as b,signal as n}from"@angular/core";import{resolveLunoraClient as v}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as h}from"./platform-DNlq-CRU.mjs";const x=(s,e={})=>{const c=v(e.client),a=e.destroyRef===void 0,i=e.destroyRef??m(b),{args:d,functionPath:f,shardKey:l,value:u}=s,t=n(u),o=n(void 0),y={__lunoraRef:f};if(h(a)){const R=c.subscribe(y,d,r=>{t.set(r),o.set(void 0)},{onError:r=>{o.set(r)},shardKey:l});i.onDestroy(R)}return{data:t.asReadonly(),error:o.asReadonly()}};export{x as hydratePreloaded};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as m,inject as q,DestroyRef as z,signal as b}from"@angular/core";import{initialPages as H,derivePaginationStatus as _,applyLoadMore as J,rebalance as T}from"@lunora/client/pagination";import{s as B,a as U,b as X}from"./platform-DNlq-CRU.mjs";import{resolveLunoraClient as E}from"./LUNORA_CLIENT-B0toApHY.mjs";const h=(o,t)=>`${o}::${X(t)}`,L=(o,t)=>({...t,paginationOpts:{cursor:o.lower,endCursor:o.upper,numItems:o.numItems}}),$=(o,t,n,i)=>{const r=E(n.client),K=n.destroyRef===void 0&&i===void 0,{initialNumItems:a,shardKey:w}=n,g=o.__lunoraRef,l=t==="skip"?{}:t,e=b(H(a)),x=b([]),D=b("LoadingFirstPage"),C=b(void 0),R=new Map,y=new Map,F=new Set,S=()=>{const f=e().map(s=>{const u=h(g,L(s,l));return y.get(u)});x.set(f);const{status:P}=_(t==="skip",f);D.set(P)},W=(p,f)=>{const P=s=>h(g,L(s,l));for(const s of f){const u=P(s);if(y.has(u))continue;const d=p.find(c=>c.lower===s.lower);if(d){const c=y.get(P(d));c&&y.set(u,c)}}},G=p=>{const f=new Set;for(const s of p)f.add(h(g,L(s,l)));for(const[s,u]of R)f.has(u.currentKey)||(u.unsub(),R.delete(s),y.delete(u.currentKey));const P=new Set([...R.values()].map(s=>s.currentKey));for(const s of p){const u=L(s,l),d=h(g,u);if(P.has(d))continue;const c={currentKey:d,unsub:void 0};F.add(d);const j=r.subscribe(o,u,M=>{if(y.set(c.currentKey,M),F.delete(c.currentKey),C.set(void 0),S(),F.size===0){const v=e(),k=T(v,x());k&&(W(v,k),e.set(k),I(k),S())}},{onError:M=>{F.delete(d),C.set(M);const v=e(),k=v.at(-1);v.length>1&&k&&!y.has(d)&&h(g,L(k,l))===d&&(e.set(v.slice(0,-1)),I(e())),S(),n.onError?.(M)},shardKey:w});c.unsub=j,R.set(d,c),P.add(d)}};let N=!1,O=!1;const I=p=>{if(N){O=!0;return}N=!0;try{let f=p;do O=!1,G(f),f=e();while(O)}finally{N=!1}};t!=="skip"&&B(K)&&I(e()),S();const Q=()=>{for(const p of R.values())p.unsub();R.clear(),y.clear()};return i===void 0?(n.destroyRef??q(z)).onDestroy(Q):i(Q),{error:C,loadMore:p=>{if(t==="skip")return;const{nextCursor:f,status:P}=_(!1,x());if(P!=="CanLoadMore")return;const s=J(e(),f,p);if(!s)return;const u=e().at(-1),d=s.at(-2);if(u&&d){const c=h(g,L(u,l)),j=h(g,L(d,l)),M=R.get(c);if(M&&c!==j){const v=y.get(c);v&&y.set(j,v),M.unsub(),R.delete(c),y.delete(c)}}C.set(void 0),e.set(s),I(e()),S()},pageResults:x,skipped:m(()=>t==="skip"),status:D}},V=(o,t,n)=>{if(typeof t!="function")return $(o,t,n);const i=E(n.client),r=n.destroyRef===void 0,K=n.destroyRef??q(z),a=b(void 0);return B(r)&&U(t,{destroyRef:K,injector:n.injector},(w,g)=>{const l=[];a.set($(o,w,{...n,client:i},e=>l.push(e))),g(()=>{for(const e of l)e()})}),{error:m(()=>a()?.error()),loadMore:w=>{a()?.loadMore(w)},pageResults:m(()=>a()?.pageResults()??[]),skipped:m(()=>a()?.skipped()??t()==="skip"),status:m(()=>a()?.status()??"LoadingFirstPage")}},se=(o,t,n)=>{const i=V(o,t,n),r=m(()=>i.pageResults().flatMap(a=>a?.page??[])),K=m(()=>{const a=i.status();return!i.skipped()&&(a==="LoadingFirstPage"||a==="LoadingMore")});return{error:i.error,isLoading:K,loadMore:i.loadMore,results:r,status:i.status}},ne=(o,t,n)=>{const{initialNumItems:i}=n,r=V(o,t,n),K=m(()=>r.pageResults().flatMap(e=>e?[e.page]:[])),a=m(()=>!r.skipped()&&r.status()==="LoadingFirstPage"),w=m(()=>r.status()==="CanLoadMore"),g=m(()=>!r.skipped()&&r.status()==="LoadingMore"),l=e=>{r.loadMore(e??i)};return{error:r.error,fetchNextPage:l,hasNextPage:w,isFetchingNextPage:g,isLoading:a,pages:K,status:r.status}};export{ne as infiniteQuery,se as paginatedQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as u,DestroyRef as y,signal as v}from"@angular/core";import{createQuerySubscription as m}from"@lunora/client/query";import{resolveLunoraClient as R}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as p,a as b}from"./platform-DNlq-CRU.mjs";const g=(c,t,e={})=>{const i=R(e.client),a=e.destroyRef===void 0,s=e.destroyRef??u(y),o=v(void 0),n=(r,f)=>{o.set(void 0);const l=m(i,c,r,{onData:d=>{o.set(d)},onError:e.onError,onReset:()=>{o.set(void 0)}},{shardKey:e.shardKey});f(l)};return p(a)&&(typeof t=="function"?b(t,{destroyRef:s,injector:e.injector},n):n(t,r=>s.onDestroy(r))),o.asReadonly()};export{g as liveQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveLunoraClient as i}from"./LUNORA_CLIENT-B0toApHY.mjs";const a=(t,o,n={})=>{const{client:e,...r}=n;return i(e).mutation(t,o,r)};export{a as mutate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{signal as o,computed as d}from"@angular/core";import{createMutatorRunner as c}from"@lunora/client";const u=n=>{const r=o(void 0),e=o(!1),s=d(()=>r()!==void 0),{mutate:a,reset:i}=c(n,{setError:t=>{r.set(t)},setPending:t=>{e.set(t)}});return{error:r.asReadonly(),isError:s,mutate:a,pending:e.asReadonly(),reset:i}};export{u as mutator};
|