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