@lunora/vue 1.0.0-alpha.13 → 1.0.0-alpha.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +6 -0
- package/README.md +20 -16
- package/dist/index.d.mts +1047 -240
- package/dist/index.d.ts +1047 -240
- package/dist/index.mjs +1 -13
- package/dist/packem_shared/AuthLoading-Dp-20UXt.mjs +1 -0
- package/dist/packem_shared/LUNORA_INJECTION_KEY-Bct9tKCj.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-BpzZkPH4.mjs +1 -0
- package/dist/packem_shared/is-browser-BEdfLJHK.mjs +1 -0
- package/dist/packem_shared/scope-dispose-Mq3k4nvP.mjs +1 -0
- package/dist/packem_shared/subscribeToQuery-G5w094pU.mjs +1 -0
- package/dist/packem_shared/useAction-C4VLsh4M.mjs +1 -0
- package/dist/packem_shared/useAgent-BLhUb7TW.mjs +1 -0
- package/dist/packem_shared/useAgentChat-D9dYI4Pq.mjs +1 -0
- package/dist/packem_shared/useAgentState-eXsZU41P.mjs +1 -0
- package/dist/packem_shared/useAgentToolEvents-CXb7Vtcn.mjs +1 -0
- package/dist/packem_shared/useAuth-axmO2A7B.mjs +1 -0
- package/dist/packem_shared/useConnectionStatus-CCUbKnj2.mjs +1 -0
- package/dist/packem_shared/useFlag-xVfWC_c6.mjs +1 -0
- package/dist/packem_shared/useInfiniteQuery-T4qCkGfy.mjs +1 -0
- package/dist/packem_shared/useMutation-D6PkaNaE.mjs +1 -0
- package/dist/packem_shared/useMutator-CO7nXlRf.mjs +1 -0
- package/dist/packem_shared/usePresence-CQ8zOCOI.mjs +1 -0
- package/dist/packem_shared/useRateLimit-zoPsflSG.mjs +1 -0
- package/dist/packem_shared/useStream-COVzNdKq.mjs +1 -0
- package/dist/packem_shared/useSubscription-ImlDfQGg.mjs +1 -0
- package/dist/packem_shared/useVoiceAgent-BEGHhbmX.mjs +1 -0
- package/dist/server.mjs +1 -1
- package/dist/upload.d.mts +2 -0
- package/dist/upload.d.ts +2 -0
- package/dist/upload.mjs +1 -0
- package/package.json +8 -7
- package/dist/packem_shared/AuthLoading-_6-uOycE.mjs +0 -29
- package/dist/packem_shared/LUNORA_INJECTION_KEY-DtFXLDQ_.mjs +0 -22
- package/dist/packem_shared/hydratePreloaded-rVY68iFv.mjs +0 -14
- package/dist/packem_shared/subscribeToQuery-Cv5YL-SI.mjs +0 -51
- package/dist/packem_shared/useAuth-C2aEzXXH.mjs +0 -28
- package/dist/packem_shared/useConnectionStatus-CDgduQYe.mjs +0 -20
- package/dist/packem_shared/useFlag-yTJu5_q7.mjs +0 -98
- package/dist/packem_shared/useInfiniteQuery-CEfbw7Nw.mjs +0 -199
- package/dist/packem_shared/useMutation-DWubV5pv.mjs +0 -29
- package/dist/packem_shared/useMutator-B_Ahs_ZN.mjs +0 -19
- package/dist/packem_shared/usePresence-BeN5xaZM.mjs +0 -59
- package/dist/packem_shared/useRateLimit-DlPWjcX1.mjs +0 -67
- package/dist/packem_shared/useSubscription-Ol0AZFUv.mjs +0 -47
- package/dist/worker.d.mts +0 -1
- package/dist/worker.d.ts +0 -1
- package/dist/worker.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,150 +1,650 @@
|
|
|
1
|
-
import { Component, Ref, InjectionKey, App,
|
|
2
|
-
import { Preloaded, LunoraClient,
|
|
3
|
-
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
|
|
1
|
+
import { Component, Ref, InjectionKey, App, MaybeRefOrGetter, ComputedRef, DeepReadonly, ShallowRef } from 'vue';
|
|
2
|
+
import { Preloaded, SubscriptionErrorCallback, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionError } from '@lunora/client';
|
|
3
|
+
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe, User } from '@lunora/client';
|
|
4
4
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
5
|
export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
|
|
6
6
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
7
7
|
/**
|
|
8
|
-
* Render the default slot only after auth has settled and a token + user are
|
|
9
|
-
* both present. Hides the slot on first render and when signed out.
|
|
10
|
-
*/
|
|
8
|
+
* Render the default slot only after auth has settled and a token + user are
|
|
9
|
+
* both present. Hides the slot on first render and when signed out.
|
|
10
|
+
*/
|
|
11
11
|
declare const Authenticated: Component;
|
|
12
12
|
/**
|
|
13
|
-
* Render the default slot only when auth has settled and no token is present
|
|
14
|
-
* (the signed-out state). Hidden while the user is still loading.
|
|
15
|
-
*/
|
|
13
|
+
* Render the default slot only when auth has settled and no token is present
|
|
14
|
+
* (the signed-out state). Hidden while the user is still loading.
|
|
15
|
+
*/
|
|
16
16
|
declare const Unauthenticated: Component;
|
|
17
17
|
/**
|
|
18
|
-
* Render the default slot while authentication is still in progress — token is
|
|
19
|
-
* set but `getCurrentUser()` has not yet resolved.
|
|
20
|
-
*/
|
|
18
|
+
* Render the default slot while authentication is still in progress — token is
|
|
19
|
+
* set but `getCurrentUser()` has not yet resolved.
|
|
20
|
+
*/
|
|
21
21
|
declare const AuthLoading: Component;
|
|
22
22
|
/**
|
|
23
|
-
* Hydrate a query from a {@link Preloaded} token produced by `preloadQuery`
|
|
24
|
-
* during SSR, then keep it live — the Vue half of PLAN4's reactive-loader
|
|
25
|
-
* handoff.
|
|
26
|
-
*
|
|
27
|
-
* The returned `ref` is seeded **synchronously** from `preloaded.value`, so the
|
|
28
|
-
* very first read (during hydration) shows the server value: no loading flash,
|
|
29
|
-
* no hydration mismatch. After seeding it opens a WebSocket subscription on the
|
|
30
|
-
* same `(functionPath, args, shardKey)` the SSR loader used, so every later
|
|
31
|
-
* server delta updates the ref exactly like `useQuery`.
|
|
32
|
-
*
|
|
33
|
-
* The subscription tears down with the surrounding effect scope (component
|
|
34
|
-
* unmount or `effectScope().stop()`), inherited from `subscribeToQuery`.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
23
|
+
* Hydrate a query from a {@link Preloaded} token produced by `preloadQuery`
|
|
24
|
+
* during SSR, then keep it live — the Vue half of PLAN4's reactive-loader
|
|
25
|
+
* handoff.
|
|
26
|
+
*
|
|
27
|
+
* The returned `ref` is seeded **synchronously** from `preloaded.value`, so the
|
|
28
|
+
* very first read (during hydration) shows the server value: no loading flash,
|
|
29
|
+
* no hydration mismatch. After seeding it opens a WebSocket subscription on the
|
|
30
|
+
* same `(functionPath, args, shardKey)` the SSR loader used, so every later
|
|
31
|
+
* server delta updates the ref exactly like `useQuery`.
|
|
32
|
+
*
|
|
33
|
+
* The subscription tears down with the surrounding effect scope (component
|
|
34
|
+
* unmount or `effectScope().stop()`), inherited from `subscribeToQuery`.
|
|
35
|
+
*
|
|
36
|
+
* Pass `onError` to surface a subscription-scoped error the server pushes (a
|
|
37
|
+
* session expiry, an RLS denial). Without it such an error is dropped and the
|
|
38
|
+
* ref keeps rendering the SSR snapshot as if it were live.
|
|
39
|
+
*
|
|
40
|
+
* The ref is `Ref<T>`, not `Ref<T | undefined>`: `subscribeToQuery`'s ref widens
|
|
41
|
+
* to `undefined` because it also serves the unseeded `useQuery` case, but this
|
|
42
|
+
* entry point always passes `seed: preloaded.value`, so the "seeded
|
|
43
|
+
* synchronously, no loading flash" contract means it is never undefined. Every
|
|
44
|
+
* other adapter's `hydratePreloaded` returns `T`; narrowing here stops Vue
|
|
45
|
+
* consumers guarding a state that cannot occur.
|
|
46
|
+
*/
|
|
47
|
+
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, options?: {
|
|
48
|
+
onError?: SubscriptionErrorCallback;
|
|
49
|
+
}) => Ref<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Injection key carrying the {@link LunoraClient} down the component tree.
|
|
52
|
+
* Exported so advanced consumers can inject it by hand; most apps use
|
|
53
|
+
* {@link createLunora} or {@link provideLunora}.
|
|
54
|
+
*/
|
|
42
55
|
declare const LUNORA_INJECTION_KEY: InjectionKey<LunoraClient>;
|
|
43
56
|
/**
|
|
44
|
-
* Vue plugin form: `app.use(createLunora(client))`. Mirrors the React
|
|
45
|
-
* `LunoraProvider` — establishes the single app-wide client every composable
|
|
46
|
-
* resolves through {@link useLunora}.
|
|
47
|
-
*
|
|
48
|
-
* The client is framework-neutral (`@lunora/client`): it owns the WebSocket
|
|
49
|
-
* transport, subscription registry, offline queue, and delta-merge. This plugin
|
|
50
|
-
* only wires it into Vue's `provide`/`inject` graph (read it with
|
|
51
|
-
* {@link useLunora}); it adds no React, no store, and no extra reactivity layer.
|
|
52
|
-
*/
|
|
57
|
+
* Vue plugin form: `app.use(createLunora(client))`. Mirrors the React
|
|
58
|
+
* `LunoraProvider` — establishes the single app-wide client every composable
|
|
59
|
+
* resolves through {@link useLunora}.
|
|
60
|
+
*
|
|
61
|
+
* The client is framework-neutral (`@lunora/client`): it owns the WebSocket
|
|
62
|
+
* transport, subscription registry, offline queue, and delta-merge. This plugin
|
|
63
|
+
* only wires it into Vue's `provide`/`inject` graph (read it with
|
|
64
|
+
* {@link useLunora}); it adds no React, no store, and no extra reactivity layer.
|
|
65
|
+
*/
|
|
53
66
|
declare const createLunora: (client: LunoraClient) => {
|
|
54
67
|
install: (app: App) => void;
|
|
55
68
|
};
|
|
56
69
|
/**
|
|
57
|
-
* Composition-API form: call inside a parent component's `setup()` to provide
|
|
58
|
-
* the client to its subtree. The counterpart to `app.use(createLunora(client))`
|
|
59
|
-
* when you'd rather scope the client to a subtree than the whole app. Must run
|
|
60
|
-
* synchronously inside `setup()` (Vue's `provide` constraint).
|
|
61
|
-
*/
|
|
70
|
+
* Composition-API form: call inside a parent component's `setup()` to provide
|
|
71
|
+
* the client to its subtree. The counterpart to `app.use(createLunora(client))`
|
|
72
|
+
* when you'd rather scope the client to a subtree than the whole app. Must run
|
|
73
|
+
* synchronously inside `setup()` (Vue's `provide` constraint).
|
|
74
|
+
*/
|
|
62
75
|
declare const provideLunora: (client: LunoraClient) => void;
|
|
63
76
|
/**
|
|
64
|
-
* Read the {@link LunoraClient} from the nearest provider — the Vue counterpart
|
|
65
|
-
* to `@lunora/react`/`@lunora/solid`'s `useLunora`. Throws with a clear message
|
|
66
|
-
* when called outside a `createLunora`/`provideLunora` scope so the failure
|
|
67
|
-
* points at the missing provider rather than a later `undefined` deref.
|
|
68
|
-
*/
|
|
77
|
+
* Read the {@link LunoraClient} from the nearest provider — the Vue counterpart
|
|
78
|
+
* to `@lunora/react`/`@lunora/solid`'s `useLunora`. Throws with a clear message
|
|
79
|
+
* when called outside a `createLunora`/`provideLunora` scope so the failure
|
|
80
|
+
* points at the missing provider rather than a later `undefined` deref.
|
|
81
|
+
*/
|
|
69
82
|
declare const useLunora: () => LunoraClient;
|
|
70
83
|
/** Options shared by the live-query composables. */
|
|
71
84
|
interface UseQueryOptions {
|
|
85
|
+
/**
|
|
86
|
+
* Called when the server pushes a subscription-scoped error (an RLS denial, a
|
|
87
|
+
* query that starts failing server-side). Without a handler such an error has
|
|
88
|
+
* nowhere to go and the ref simply freezes at its last good value.
|
|
89
|
+
*/
|
|
90
|
+
onError?: SubscriptionErrorCallback;
|
|
72
91
|
/** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
|
|
73
92
|
shardKey?: string;
|
|
74
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* The reactive handle returned by {@link useAction} — the Vue counterpart to
|
|
96
|
+
* React's `useAction`, re-expressed with refs. The surface is identical across
|
|
97
|
+
* the Lunora adapters (`@lunora/solid`, `/svelte`): `data`/`error`/`pending`
|
|
98
|
+
* are refs you read in a template, and `call` is an awaitable that resolves with
|
|
99
|
+
* the server value (or rejects).
|
|
100
|
+
*/
|
|
101
|
+
interface ActionHandle<F extends FunctionReference> {
|
|
102
|
+
/** Invoke the action. Resolves with the server value; rejects on failure. */
|
|
103
|
+
call: (args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
|
|
104
|
+
/** The latest invocation's resolved value, or `undefined` before the first success. */
|
|
105
|
+
data: Ref<ReturnOf<F> | undefined>;
|
|
106
|
+
/** The latest invocation's error, or `undefined`. */
|
|
107
|
+
error: Ref<Error | undefined>;
|
|
108
|
+
/** `true` while ANY invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
|
|
109
|
+
pending: Ref<boolean>;
|
|
110
|
+
/** Clear the latest `data`/`error` back to idle. */
|
|
111
|
+
reset: () => void;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Returns a reactive {@link ActionHandle} for the given action reference — the
|
|
115
|
+
* Vue equivalent of React's `useAction`.
|
|
116
|
+
*
|
|
117
|
+
* Actions were the one procedure kind with no adapter hook: `useQuery` and
|
|
118
|
+
* `useMutation` shipped in every adapter and nothing covered actions, so each
|
|
119
|
+
* app re-derived the same pending/error wrapper by hand.
|
|
120
|
+
*
|
|
121
|
+
* **Narrower than `useMutation` on purpose:** there are no `optimistic` /
|
|
122
|
+
* `optimisticUpdate` call options. An optimistic update patches the subscription
|
|
123
|
+
* cache on the assumption a write will land; an action is not a write — it runs
|
|
124
|
+
* in the Worker, may call a third party, and has no declared effect on any
|
|
125
|
+
* query. Offering the option would imply a rollback guarantee nothing can
|
|
126
|
+
* honour.
|
|
127
|
+
*
|
|
128
|
+
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
129
|
+
* flips back to `false` only once every concurrent call has settled. That
|
|
130
|
+
* orchestration is the shared `createCallRunner` from `@lunora/client`; only the
|
|
131
|
+
* refs are adapter-specific.
|
|
132
|
+
*
|
|
133
|
+
* `data`/`error` follow the adapter-wide contract: both track the LATEST
|
|
134
|
+
* invocation (an earlier call settling later cannot clobber a newer one), a
|
|
135
|
+
* success clears `error`, and a failure leaves the previous `data` in place so a
|
|
136
|
+
* transient error does not blank the view. `reset()` clears both; it does not
|
|
137
|
+
* cancel an in-flight call, whose result still lands.
|
|
138
|
+
*/
|
|
139
|
+
declare const useAction: <F extends FunctionReference>(function_: F) => ActionHandle<F>;
|
|
140
|
+
/**
|
|
141
|
+
* The lifecycle status stored on an agent thread. Client-safe mirror of
|
|
142
|
+
* `@lunora/agent`'s `AgentThreadStatus` — re-declared here (rather than imported)
|
|
143
|
+
* so this Vue entry never pulls in the server-only `@lunora/agent` module graph
|
|
144
|
+
* (the adapter stays Vue + `@lunora/client` only). Keep in sync with
|
|
145
|
+
* `packages/agent/src/types.ts`.
|
|
146
|
+
*/
|
|
147
|
+
type AgentThreadStatus = "awaiting_input" | "cancelled" | "error" | "idle" | "running";
|
|
148
|
+
/**
|
|
149
|
+
* The live thread record surfaced by the `agents:agentThread` query. A structural
|
|
150
|
+
* subset of the persisted thread row — every field beyond `status` is optional so
|
|
151
|
+
* the shape stays forgiving as the server schema grows. Keep in sync with the
|
|
152
|
+
* `agent_threads` table in `packages/agent/src/component.ts`.
|
|
153
|
+
*/
|
|
154
|
+
interface AgentThreadRecord {
|
|
155
|
+
createdAt?: number;
|
|
156
|
+
/** The failure message when `status === "error"`. */
|
|
157
|
+
error?: string;
|
|
158
|
+
/** The workflow instance id of the in-flight run — the handle `cancel` targets. */
|
|
159
|
+
instanceId?: string;
|
|
160
|
+
messageCount?: number;
|
|
161
|
+
/** The verified thread owner, when the run was started with one. */
|
|
162
|
+
owner?: string;
|
|
163
|
+
status: AgentThreadStatus;
|
|
164
|
+
title?: string;
|
|
165
|
+
updatedAt?: number;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The `agents.agentThread` reference the composable subscribes to for live thread
|
|
169
|
+
* state (status + the in-flight `instanceId`). A structural subset of the
|
|
170
|
+
* generated `api.agents` surface, so the whole generated `api` object is
|
|
171
|
+
* assignable.
|
|
172
|
+
*/
|
|
173
|
+
interface UseAgentApi {
|
|
174
|
+
agents: {
|
|
175
|
+
agentThread: FunctionReference<"query", {
|
|
176
|
+
key: string;
|
|
177
|
+
}, Record<string, unknown> | undefined>;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
interface UseAgentOptions {
|
|
181
|
+
/** The generated `api` — its `agents.agentThread` query drives live thread state. */
|
|
182
|
+
api: UseAgentApi;
|
|
183
|
+
/**
|
|
184
|
+
* Optional app mutation over the agent's cancel path
|
|
185
|
+
* (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
|
|
186
|
+
* When omitted (or no run is in flight) {@link UseAgentResult.cancel} is a
|
|
187
|
+
* no-op.
|
|
188
|
+
*/
|
|
189
|
+
cancel?: FunctionReference<"mutation">;
|
|
190
|
+
/**
|
|
191
|
+
* Called when the live thread subscription reports an error (a session
|
|
192
|
+
* expiry, an RLS denial). Without it — and without reading `error` — such a
|
|
193
|
+
* failure is invisible and `thread` / `status` are cleared until a later frame arrives.
|
|
194
|
+
*/
|
|
195
|
+
onError?: SubscriptionErrorCallback;
|
|
196
|
+
/**
|
|
197
|
+
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
198
|
+
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
199
|
+
* {@link UseAgentOptions.runArgs} and the per-call args.
|
|
200
|
+
*/
|
|
201
|
+
run: FunctionReference<"mutation">;
|
|
202
|
+
/** Extra args merged into every `run` call (e.g. an `owner` or `title`). */
|
|
203
|
+
runArgs?: Record<string, unknown>;
|
|
204
|
+
/** The thread to observe and drive — may be a plain value, `ref`, or getter (a reactive source re-subscribes). */
|
|
205
|
+
threadKey: MaybeRefOrGetter<string>;
|
|
206
|
+
}
|
|
207
|
+
interface UseAgentResult {
|
|
208
|
+
/**
|
|
209
|
+
* Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
|
|
210
|
+
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
211
|
+
*/
|
|
212
|
+
cancel: () => Promise<void>;
|
|
213
|
+
/** The live thread subscription's last error, or `undefined`. */
|
|
214
|
+
error: Ref<Error | undefined>;
|
|
215
|
+
/** `true` while a `run` invocation is in flight. */
|
|
216
|
+
pending: Readonly<Ref<boolean>>;
|
|
217
|
+
/** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
|
|
218
|
+
run: (input: string, args?: Record<string, unknown>) => Promise<void>;
|
|
219
|
+
/** The live thread status, or `undefined` before the thread exists. */
|
|
220
|
+
status: ComputedRef<AgentThreadStatus | undefined>;
|
|
221
|
+
/** The live thread record (status, `instanceId`, …), or `undefined` before it exists. */
|
|
222
|
+
thread: ComputedRef<AgentThreadRecord | undefined>;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* A thin agent handle: live thread `status` plus `run` / `cancel`, without the
|
|
226
|
+
* chat message surface. Composes `useSubscription(api.agents.agentThread)` for
|
|
227
|
+
* live state and `useMutation` for the run/cancel writes — the Vue counterpart to
|
|
228
|
+
* React's `useAgent`, re-expressed with refs. For the full conversation surface
|
|
229
|
+
* (durable history + streaming + approvals) use `useAgentChat`.
|
|
230
|
+
*
|
|
231
|
+
* `run` and `cancel` stay generic over the app-defined mutations that wrap
|
|
232
|
+
* `ctx.agents.<name>.run` / `.cancel`, so the composable hard-codes no function
|
|
233
|
+
* names beyond the `agents:*` surface. `threadKey` may be reactive — a changing
|
|
234
|
+
* key re-subscribes to the new thread.
|
|
235
|
+
*/
|
|
236
|
+
declare const useAgent: (options: UseAgentOptions) => UseAgentResult;
|
|
237
|
+
/**
|
|
238
|
+
* One persisted (or optimistic) thread message, as `agents:agentMessages`
|
|
239
|
+
* surfaces it. Client-safe mirror of `@lunora/agent`'s `AgentMessageRow` —
|
|
240
|
+
* re-declared here (rather than imported) so this Vue entry never pulls in the
|
|
241
|
+
* server-only `@lunora/agent` module graph. Keep in sync with the
|
|
242
|
+
* `agent_messages` table in `packages/agent/src/component.ts`.
|
|
243
|
+
*/
|
|
244
|
+
interface AgentChatMessage {
|
|
245
|
+
content: string;
|
|
246
|
+
createdAt?: number;
|
|
247
|
+
/**
|
|
248
|
+
* `true` for a client-side optimistic user message not yet acknowledged by
|
|
249
|
+
* the server. Cleared once the durable history carries the matching user turn.
|
|
250
|
+
*/
|
|
251
|
+
optimistic?: boolean;
|
|
252
|
+
role: "assistant" | "system" | "tool" | "user";
|
|
253
|
+
seq: number;
|
|
254
|
+
/** Approval lifecycle marker on a human-in-the-loop tool message. */
|
|
255
|
+
status?: "approved" | "awaiting_approval" | "rejected";
|
|
256
|
+
toolCallId?: string;
|
|
257
|
+
toolCalls?: ReadonlyArray<{
|
|
258
|
+
id: string;
|
|
259
|
+
input: unknown;
|
|
260
|
+
name: string;
|
|
261
|
+
}>;
|
|
262
|
+
toolName?: string;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* A live token delta streamed while a turn is generating. Client-safe mirror of
|
|
266
|
+
* `@lunora/agent`'s `AgentTokenDelta`. Ephemeral — deltas feed
|
|
267
|
+
* {@link UseAgentChatResult.streamingText} live and are never replayed; the
|
|
268
|
+
* persisted assistant message stays the single source of truth.
|
|
269
|
+
*/
|
|
270
|
+
interface AgentTokenDelta {
|
|
271
|
+
/** Discriminates the token arm of {@link AgentLiveEvent}; unset on the wire (token is the default). */
|
|
272
|
+
kind?: "token";
|
|
273
|
+
/** The incremental text chunk the model just produced. */
|
|
274
|
+
text: string;
|
|
275
|
+
/** The thread this delta belongs to. */
|
|
276
|
+
threadKey: string;
|
|
277
|
+
/** The zero-based index of the turn producing the delta. */
|
|
278
|
+
turn: number;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* A live tool-progress event streamed via `ctx.reportProgress(...)`. Client-safe
|
|
282
|
+
* mirror of `@lunora/agent`'s `AgentProgressEvent`. Ephemeral and `toolCallId`-keyed;
|
|
283
|
+
* surfaced by `useAgentToolEvents`, ignored by {@link UseAgentChatResult.streamingText}.
|
|
284
|
+
*/
|
|
285
|
+
interface AgentProgressEvent {
|
|
286
|
+
/** The arbitrary, JSON-serializable payload the tool reported. */
|
|
287
|
+
data: unknown;
|
|
288
|
+
/** Discriminates the progress arm of {@link AgentLiveEvent}. */
|
|
289
|
+
kind: "progress";
|
|
290
|
+
/** The thread this event belongs to. */
|
|
291
|
+
threadKey: string;
|
|
292
|
+
/** The tool call this progress belongs to. */
|
|
293
|
+
toolCallId: string;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* A single event on the agent's live-only channel — a streamed token delta or a
|
|
297
|
+
* tool progress event. Client-safe mirror of `@lunora/agent`'s `AgentLiveEvent`.
|
|
298
|
+
* Discriminate on `kind` (`"progress"` for the progress arm; token deltas leave
|
|
299
|
+
* it unset).
|
|
300
|
+
*/
|
|
301
|
+
type AgentLiveEvent = AgentProgressEvent | AgentTokenDelta;
|
|
302
|
+
/** The `agents:agentMessages` reference — live durable thread history. */
|
|
303
|
+
type AgentMessagesReference$1 = FunctionReference<"query", {
|
|
304
|
+
key: string;
|
|
305
|
+
limit?: number;
|
|
306
|
+
}, ReadonlyArray<Record<string, unknown>>>;
|
|
307
|
+
/** The `agents:agentResolveApproval` reference — resolves a human-in-the-loop tool approval. */
|
|
308
|
+
type AgentApprovalReference = FunctionReference<"mutation", {
|
|
309
|
+
decision: "approve" | "reject";
|
|
310
|
+
instanceId: string;
|
|
311
|
+
note?: string;
|
|
312
|
+
threadKey: string;
|
|
313
|
+
toolCallId: string;
|
|
314
|
+
}, {
|
|
315
|
+
resolved: boolean;
|
|
316
|
+
}>;
|
|
317
|
+
/** The `agents:agentThread` reference — live thread status + in-flight `instanceId`. */
|
|
318
|
+
type AgentThreadReference = FunctionReference<"query", {
|
|
319
|
+
key: string;
|
|
320
|
+
}, Record<string, unknown> | undefined>;
|
|
321
|
+
/**
|
|
322
|
+
* An app stream reference that tees the agent's in-flight live events, keyed by
|
|
323
|
+
* thread. Carries token deltas and — since `ctx.reportProgress` rides the same
|
|
324
|
+
* sink — tool progress events; this composable consumes only the token arm.
|
|
325
|
+
*/
|
|
326
|
+
type AgentTokenStreamReference = FunctionReference<"stream", {
|
|
327
|
+
key: string;
|
|
328
|
+
}, AgentLiveEvent>;
|
|
329
|
+
/**
|
|
330
|
+
* The `agents.*` reference surface the chat composable reads. A structural subset
|
|
331
|
+
* of the generated `api.agents`, so the whole generated `api` object is
|
|
332
|
+
* assignable.
|
|
333
|
+
*/
|
|
334
|
+
interface UseAgentChatApi {
|
|
335
|
+
agents: {
|
|
336
|
+
agentMessages: AgentMessagesReference$1;
|
|
337
|
+
agentResolveApproval: AgentApprovalReference;
|
|
338
|
+
agentThread: AgentThreadReference;
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
interface UseAgentChatOptions {
|
|
342
|
+
/** The generated `api` — its `agents.*` surface provides history, thread state, and approval resolution. */
|
|
343
|
+
api: UseAgentChatApi;
|
|
344
|
+
/**
|
|
345
|
+
* Optional app mutation over the agent's cancel path
|
|
346
|
+
* (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
|
|
347
|
+
* When omitted (or no run is in flight) {@link UseAgentChatResult.cancel} is a
|
|
348
|
+
* no-op.
|
|
349
|
+
*/
|
|
350
|
+
cancel?: FunctionReference<"mutation">;
|
|
351
|
+
/** History depth forwarded to `agents:agentMessages`. */
|
|
352
|
+
limit?: number;
|
|
353
|
+
/**
|
|
354
|
+
* Called when the live history or thread subscription reports an error (a
|
|
355
|
+
* session expiry, an RLS denial). Without it — and without reading `error` —
|
|
356
|
+
* such a failure is invisible and `messages` / `status` are cleared until a later frame arrives.
|
|
357
|
+
*/
|
|
358
|
+
onError?: SubscriptionErrorCallback;
|
|
359
|
+
/**
|
|
360
|
+
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
361
|
+
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
362
|
+
* {@link UseAgentChatOptions.sendArgs} and the per-call args.
|
|
363
|
+
*/
|
|
364
|
+
send: FunctionReference<"mutation">;
|
|
365
|
+
/** Extra args merged into every `send` call (e.g. an `owner` or `title`). */
|
|
366
|
+
sendArgs?: Record<string, unknown>;
|
|
367
|
+
/**
|
|
368
|
+
* Optional live token-delta stream — an app stream function that tees the
|
|
369
|
+
* agent's in-flight deltas. When omitted {@link UseAgentChatResult.streamingText}
|
|
370
|
+
* stays empty and the UI updates message-by-message from durable history.
|
|
371
|
+
*/
|
|
372
|
+
stream?: AgentTokenStreamReference;
|
|
373
|
+
/** The thread to observe and continue — may be a plain value, `ref`, or getter (a reactive source re-subscribes). */
|
|
374
|
+
threadKey: MaybeRefOrGetter<string>;
|
|
375
|
+
}
|
|
376
|
+
interface UseAgentChatResult {
|
|
377
|
+
/** Approve a paused human-in-the-loop tool call (optionally with a note). */
|
|
378
|
+
approve: (toolCallId: string, note?: string) => Promise<void>;
|
|
379
|
+
/**
|
|
380
|
+
* Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
|
|
381
|
+
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
382
|
+
*/
|
|
383
|
+
cancel: () => Promise<void>;
|
|
384
|
+
/** The history or thread subscription's last error, or `undefined`. */
|
|
385
|
+
error: ComputedRef<Error | undefined>;
|
|
386
|
+
/** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
|
|
387
|
+
messages: ComputedRef<ReadonlyArray<AgentChatMessage>>;
|
|
388
|
+
/** Reject a paused human-in-the-loop tool call (optionally with a reason). */
|
|
389
|
+
reject: (toolCallId: string, note?: string) => Promise<void>;
|
|
390
|
+
/** Start (or continue) a run with a user message; extra args merge over `sendArgs`. Appends an optimistic user turn. */
|
|
391
|
+
send: (input: string, args?: Record<string, unknown>) => Promise<void>;
|
|
392
|
+
/** The live thread status, or `undefined` before the thread exists. */
|
|
393
|
+
status: ComputedRef<AgentThreadStatus | undefined>;
|
|
394
|
+
/** The in-flight turn's streamed text — live-only, empty once the turn persists to `messages`. */
|
|
395
|
+
streamingText: ComputedRef<string>;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* A first-class agent chat surface: live durable history + in-flight token
|
|
399
|
+
* streaming + the send / approve / reject / cancel writes, keyed by `threadKey` —
|
|
400
|
+
* the Vue counterpart to React's `useAgentChat`, re-expressed with refs.
|
|
401
|
+
*
|
|
402
|
+
* It composes the existing primitives rather than adding transport:
|
|
403
|
+
* `useSubscription(api.agents.agentMessages)` for durable history,
|
|
404
|
+
* `useSubscription(api.agents.agentThread)` for live status + the in-flight
|
|
405
|
+
* `instanceId`, {@link useStream} over an app token stream for in-flight deltas,
|
|
406
|
+
* and `useMutation` for the writes (`api.agents.agentResolveApproval` for
|
|
407
|
+
* approvals; app-defined wrappers for `send`/`cancel`). Only the `agents:*`
|
|
408
|
+
* surface is hard-coded — `send`/`cancel`/`stream` stay generic references.
|
|
409
|
+
*
|
|
410
|
+
* A `send` optimistically appends the user turn so it renders immediately; the
|
|
411
|
+
* optimistic row clears once the durable history carries the acknowledged turn.
|
|
412
|
+
* `streamingText` is live-only: it holds the current turn's streamed text and
|
|
413
|
+
* empties as soon as that turn's assistant message lands in `messages` (the
|
|
414
|
+
* persisted message is the source of truth), consistent with the loop's
|
|
415
|
+
* replay-safe, live-only delta design.
|
|
416
|
+
*/
|
|
417
|
+
declare const useAgentChat: (options: UseAgentChatOptions) => UseAgentChatResult;
|
|
418
|
+
/**
|
|
419
|
+
* The `agents.agentState` reference the composable subscribes to for the thread's
|
|
420
|
+
* live synced state. A structural subset of the generated `api.agents` surface
|
|
421
|
+
* (like `UseAgentApi` for `agentThread`), so the whole generated `api` object is
|
|
422
|
+
* assignable. Client-safe: no `@lunora/agent` import — the per-agent state type is
|
|
423
|
+
* mirrored by the composable's generic `T`, since codegen pins the reference
|
|
424
|
+
* return as an optional record (it never evaluates agent config).
|
|
425
|
+
*/
|
|
426
|
+
interface UseAgentStateApi {
|
|
427
|
+
agents: {
|
|
428
|
+
agentState: FunctionReference<"query", {
|
|
429
|
+
key: string;
|
|
430
|
+
}, Record<string, unknown> | undefined>;
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
interface UseAgentStateOptions {
|
|
434
|
+
/** The generated `api` — its `agents.agentState` query drives live thread state. */
|
|
435
|
+
api: UseAgentStateApi;
|
|
436
|
+
/** The thread whose synced state to observe — may be a plain value, `ref`, or getter (a reactive source re-subscribes). */
|
|
437
|
+
threadKey: MaybeRefOrGetter<string>;
|
|
438
|
+
}
|
|
439
|
+
interface UseAgentStateResult<T> {
|
|
440
|
+
/** The subscription error, if the live channel reported one. */
|
|
441
|
+
error: Ref<Error | undefined>;
|
|
442
|
+
/** The live synced state, or `undefined` before it is seeded/first pushed. */
|
|
443
|
+
state: ComputedRef<T | undefined>;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Subscribe to an agent thread's synced state — the `setState`-style value a tool
|
|
447
|
+
* writes with `ctx.setState(...)`, seeded by `defineAgent({ initialState })`. A
|
|
448
|
+
* thin wrapper over `useSubscription(api.agents.agentState, { key })`: the server
|
|
449
|
+
* pushes a fresh frame whenever the state changes (the dedicated query's
|
|
450
|
+
* per-socket JSON memo suppresses no-op pushes on unrelated thread writes), so
|
|
451
|
+
* `state` updates only on a real `setState`. The Vue counterpart to React's
|
|
452
|
+
* `useAgentState`, re-expressed with refs.
|
|
453
|
+
*
|
|
454
|
+
* Generic over the app's state shape (`useAgentState` with a `SupportState` type
|
|
455
|
+
* argument, itself a record) — the reference is typed as an optional record
|
|
456
|
+
* because codegen cannot see the per-agent state type; the generic casts to `T`.
|
|
457
|
+
* The `extends` bound (not
|
|
458
|
+
* a bare unbounded type parameter) is required: this `.ts` file is parsed
|
|
459
|
+
* JSX-aware by the bundler, where an unbounded type-param arrow is ambiguous with
|
|
460
|
+
* a JSX element.
|
|
461
|
+
*/
|
|
462
|
+
declare const useAgentState: <T extends Record<string, unknown> = Record<string, unknown>>(options: UseAgentStateOptions) => UseAgentStateResult<T>;
|
|
463
|
+
/** The `agents:agentMessages` reference — live durable thread history. */
|
|
464
|
+
type AgentMessagesReference = FunctionReference<"query", {
|
|
465
|
+
key: string;
|
|
466
|
+
limit?: number;
|
|
467
|
+
}, ReadonlyArray<Record<string, unknown>>>;
|
|
468
|
+
/**
|
|
469
|
+
* An app stream reference that tees the agent's in-flight live events, keyed by
|
|
470
|
+
* thread. Carries token deltas and tool progress events; this composable consumes
|
|
471
|
+
* only the progress arm (`kind === "progress"`).
|
|
472
|
+
*/
|
|
473
|
+
type AgentLiveStreamReference = FunctionReference<"stream", {
|
|
474
|
+
key: string;
|
|
475
|
+
}, AgentLiveEvent>;
|
|
476
|
+
/**
|
|
477
|
+
* The `agents.*` reference surface the tool-events composable reads. A structural
|
|
478
|
+
* subset of the generated `api.agents`, so the whole generated `api` object is
|
|
479
|
+
* assignable.
|
|
480
|
+
*/
|
|
481
|
+
interface UseAgentToolEventsApi {
|
|
482
|
+
agents: {
|
|
483
|
+
agentMessages: AgentMessagesReference;
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
interface UseAgentToolEventsOptions {
|
|
487
|
+
/** The generated `api` — its `agents.agentMessages` query provides the durable tool lifecycle. */
|
|
488
|
+
api: UseAgentToolEventsApi;
|
|
489
|
+
/** History depth forwarded to `agents:agentMessages`. */
|
|
490
|
+
limit?: number;
|
|
491
|
+
/**
|
|
492
|
+
* Optional live event stream — the same app stream function `useAgentChat`
|
|
493
|
+
* uses. When supplied, ephemeral `ctx.reportProgress(...)` events for the
|
|
494
|
+
* thread are surfaced as `{ type: "progress" }` entries; when omitted only the
|
|
495
|
+
* durable lifecycle (call / result / awaiting-approval) is returned.
|
|
496
|
+
*/
|
|
497
|
+
stream?: AgentLiveStreamReference;
|
|
498
|
+
/** The thread whose tool activity to observe — may be a plain value, `ref`, or getter (a reactive source re-subscribes). */
|
|
499
|
+
threadKey: MaybeRefOrGetter<string>;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* A single tool-lifecycle event for a thread. The durable arms
|
|
503
|
+
* (`call`/`result`/`awaiting-approval`) are derived from `agents:agentMessages`
|
|
504
|
+
* and carry the persisted `seq`; the ephemeral `progress` arm comes live off the
|
|
505
|
+
* stream and has no `seq`. Discriminate on `type`.
|
|
506
|
+
*/
|
|
507
|
+
type AgentToolEvent = {
|
|
508
|
+
data: unknown;
|
|
509
|
+
toolCallId: string;
|
|
510
|
+
type: "progress";
|
|
511
|
+
} | {
|
|
512
|
+
input: unknown;
|
|
513
|
+
seq: number;
|
|
514
|
+
toolCallId: string;
|
|
515
|
+
toolName: string;
|
|
516
|
+
type: "call";
|
|
517
|
+
} | {
|
|
518
|
+
output: string;
|
|
519
|
+
seq: number;
|
|
520
|
+
status?: "approved" | "rejected";
|
|
521
|
+
toolCallId?: string;
|
|
522
|
+
toolName?: string;
|
|
523
|
+
type: "result";
|
|
524
|
+
} | {
|
|
525
|
+
seq: number;
|
|
526
|
+
toolCallId?: string;
|
|
527
|
+
toolName?: string;
|
|
528
|
+
type: "awaiting-approval";
|
|
529
|
+
};
|
|
530
|
+
interface UseAgentToolEventsResult {
|
|
531
|
+
/**
|
|
532
|
+
* The thread's tool events: the durable lifecycle (oldest first, by `seq`)
|
|
533
|
+
* followed by any in-flight ephemeral progress events, recomputed from the live
|
|
534
|
+
* subscription + stream. Treat as derived, not identity-stable.
|
|
535
|
+
*/
|
|
536
|
+
events: ComputedRef<ReadonlyArray<AgentToolEvent>>;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* A focused view of a thread's tool activity: tool calls, their results,
|
|
540
|
+
* human-in-the-loop approval pauses, and live `ctx.reportProgress(...)` events —
|
|
541
|
+
* without the full chat message surface. The Vue counterpart to React's
|
|
542
|
+
* `useAgentToolEvents`, re-expressed as a `computed`.
|
|
543
|
+
*
|
|
544
|
+
* It composes the existing primitives rather than adding transport:
|
|
545
|
+
* `useSubscription(api.agents.agentMessages)` for the durable lifecycle and
|
|
546
|
+
* {@link useStream} over the optional app event stream for ephemeral progress.
|
|
547
|
+
* Progress events are live-only (the durable path never emits them): they ride
|
|
548
|
+
* the same sink as token deltas and are surfaced here, correlated to their tool
|
|
549
|
+
* call by `toolCallId`. For the conversational surface (messages + streaming text
|
|
550
|
+
* + approvals) use `useAgentChat`; this composable is the tool-observability slice.
|
|
551
|
+
*/
|
|
552
|
+
declare const useAgentToolEvents: (options: UseAgentToolEventsOptions) => UseAgentToolEventsResult;
|
|
75
553
|
interface UseAuthResult {
|
|
76
554
|
setToken: (token: string | null) => void;
|
|
77
555
|
token: DeepReadonly<Ref<string | null>>;
|
|
78
556
|
user: DeepReadonly<Ref<User | null>>;
|
|
79
557
|
}
|
|
80
558
|
/**
|
|
81
|
-
* Token + identity plumbing for Vue. `token` is a readonly ref tracking the
|
|
82
|
-
* client's auth token; `user` is a readonly ref resolved from `getCurrentUser()`
|
|
83
|
-
* whenever the token changes. `setToken(jwt)` after sign-in makes subsequent
|
|
84
|
-
* RPC calls carry the `Authorization` header.
|
|
85
|
-
*
|
|
86
|
-
* Multiple `useAuth` instances within the same effect scope share a single
|
|
87
|
-
* per-client identity store (from `@lunora/client/auth`) — a `setToken` from
|
|
88
|
-
* one component re-renders every watcher with the freshly-resolved user.
|
|
89
|
-
|
|
559
|
+
* Token + identity plumbing for Vue. `token` is a readonly ref tracking the
|
|
560
|
+
* client's auth token; `user` is a readonly ref resolved from `getCurrentUser()`
|
|
561
|
+
* whenever the token changes. `setToken(jwt)` after sign-in makes subsequent
|
|
562
|
+
* RPC calls carry the `Authorization` header.
|
|
563
|
+
*
|
|
564
|
+
* Multiple `useAuth` instances within the same effect scope share a single
|
|
565
|
+
* per-client identity store (from `@lunora/client/auth`) — a `setToken` from
|
|
566
|
+
* one component re-renders every watcher with the freshly-resolved user.
|
|
567
|
+
*
|
|
568
|
+
* Both subscribes are client-only, for the same reason as `useFlags`: this
|
|
569
|
+
* runs synchronously inside `setup()` during `renderToString`, and that render
|
|
570
|
+
* scope is never stopped, so `onScopeDispose` never fires. For the identity
|
|
571
|
+
* subscribe that is not just a stray listener — the store kicks off
|
|
572
|
+
* `getCurrentUser()` on its first subscriber, so an unguarded server render
|
|
573
|
+
* issues a round-trip against a client whose URL does not resolve there. Both
|
|
574
|
+
* refs still hold the client's current values; live updates start at hydration.
|
|
575
|
+
*/
|
|
90
576
|
declare const useAuth: () => UseAuthResult;
|
|
91
577
|
/**
|
|
92
|
-
* Reactive view of the client's aggregate live-socket status across all shard
|
|
93
|
-
* connections, exposed as a read-only `ref`. The value transitions through
|
|
94
|
-
* `idle` → `connecting` → `connected` → `offline` as sockets open and drop —
|
|
95
|
-
* use it to drive a connection indicator so an operator can tell a healthy live
|
|
96
|
-
* channel from a silently-dropped one. The Vue-idiomatic equivalent of
|
|
97
|
-
* `@lunora/react`'s `useConnectionStatus`.
|
|
98
|
-
*
|
|
99
|
-
* Teardown is wired to the active effect scope (`onScopeDispose`), so the
|
|
100
|
-
* status listener is released on component unmount (or `effectScope().stop()`).
|
|
101
|
-
* Call inside `setup()` / an active effect scope.
|
|
102
|
-
|
|
578
|
+
* Reactive view of the client's aggregate live-socket status across all shard
|
|
579
|
+
* connections, exposed as a read-only `ref`. The value transitions through
|
|
580
|
+
* `idle` → `connecting` → `connected` → `offline` as sockets open and drop —
|
|
581
|
+
* use it to drive a connection indicator so an operator can tell a healthy live
|
|
582
|
+
* channel from a silently-dropped one. The Vue-idiomatic equivalent of
|
|
583
|
+
* `@lunora/react`'s `useConnectionStatus`.
|
|
584
|
+
*
|
|
585
|
+
* Teardown is wired to the active effect scope (`onScopeDispose`), so the
|
|
586
|
+
* status listener is released on component unmount (or `effectScope().stop()`).
|
|
587
|
+
* Call inside `setup()` / an active effect scope.
|
|
588
|
+
*
|
|
589
|
+
* Client-only, for the same reason as `useFlags`: this runs synchronously
|
|
590
|
+
* inside `setup()` during `renderToString`, and that render scope is never
|
|
591
|
+
* stopped — `onScopeDispose` therefore never fires and an unguarded listener
|
|
592
|
+
* would stay registered on the client for the lifetime of the server process,
|
|
593
|
+
* one per rendered request. The ref still holds the client's current status,
|
|
594
|
+
* which is what the SSR HTML should show; live updates start at hydration.
|
|
595
|
+
*/
|
|
103
596
|
declare const useConnectionStatus: () => Readonly<Ref<ConnectionStatus>>;
|
|
104
|
-
/** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
|
|
105
|
-
type FlagContext = Record<string, unknown>;
|
|
106
597
|
/** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
|
|
107
598
|
type FlagValue = boolean | number | string | {
|
|
108
599
|
[key: string]: unknown;
|
|
109
600
|
} | unknown[] | null;
|
|
110
601
|
/**
|
|
111
|
-
* Subscribe to a single feature flag, live over Lunora's WebSocket.
|
|
112
|
-
*
|
|
113
|
-
* The returned `ref` holds `defaultValue` until the first evaluation lands, then
|
|
114
|
-
* the server's resolved value — re-pushed whenever the provider re-evaluates
|
|
115
|
-
* (e.g. a flag is toggled in Cloudflare Flagship). The flag's kind is inferred
|
|
116
|
-
* from `defaultValue`'s runtime type, so `useFlag("dark", false)` reads a boolean
|
|
117
|
-
* and `useFlag("hero", "control")` a string.
|
|
118
|
-
*
|
|
119
|
-
* `key`
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* `
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* server
|
|
146
|
-
*
|
|
147
|
-
*/
|
|
602
|
+
* Subscribe to a single feature flag, live over Lunora's WebSocket.
|
|
603
|
+
*
|
|
604
|
+
* The returned `ref` holds `defaultValue` until the first evaluation lands, then
|
|
605
|
+
* the server's resolved value — re-pushed whenever the provider re-evaluates
|
|
606
|
+
* (e.g. a flag is toggled in Cloudflare Flagship). The flag's kind is inferred
|
|
607
|
+
* from `defaultValue`'s runtime type, so `useFlag("dark", false)` reads a boolean
|
|
608
|
+
* and `useFlag("hero", "control")` a string.
|
|
609
|
+
*
|
|
610
|
+
* `key` may be a plain value, a `ref`, or a getter: passing a reactive source
|
|
611
|
+
* makes the subscription reactive — when it changes the old subscription is torn
|
|
612
|
+
* down and a fresh one opens.
|
|
613
|
+
*
|
|
614
|
+
* The reactive channel is public, so the server evaluates every flag under the
|
|
615
|
+
* socket's own verified identity — the targeting key your `defineFlags({
|
|
616
|
+
* identify })` derives — and accepts no client-supplied targeting context. For
|
|
617
|
+
* evaluation under a context you compute, call `ctx.flags.*` inside a query,
|
|
618
|
+
* mutation, or action and return the resolved value.
|
|
619
|
+
*
|
|
620
|
+
* Evaluation runs through whatever OpenFeature provider the app wired in
|
|
621
|
+
* `lunora/flags.ts`; the read never throws — a provider error resolves the
|
|
622
|
+
* default (the same fail-open contract as server-side `ctx.flags`) — both an
|
|
623
|
+
* attach throw and a provider error pushed mid-session. Call inside `setup()`
|
|
624
|
+
* (or any active effect scope); the subscription tears down on unmount. During
|
|
625
|
+
* SSR no subscription opens at all and the ref stays at `defaultValue`.
|
|
626
|
+
*/
|
|
627
|
+
declare const useFlag: <T extends FlagValue>(key: MaybeRefOrGetter<string>, defaultValue: T) => Readonly<Ref<T>>;
|
|
628
|
+
/**
|
|
629
|
+
* Subscribe to several feature flags at once, live over Lunora's WebSocket.
|
|
630
|
+
*
|
|
631
|
+
* Pass a record of `key → defaultValue`; each flag's kind is inferred from its
|
|
632
|
+
* default, and the returned `ref` holds the same-shaped record with resolved
|
|
633
|
+
* values (the defaults until each evaluation lands). This is the batched form of
|
|
634
|
+
* {@link useFlag} — one subscription per key, torn down together when the
|
|
635
|
+
* enclosing effect scope stops. Like {@link useFlag} it evaluates under the
|
|
636
|
+
* socket's server-verified identity only. The flag set is fixed for the
|
|
637
|
+
* composable's lifetime, so nothing here is reactive.
|
|
638
|
+
*/
|
|
639
|
+
declare const useFlags: <T extends Record<string, FlagValue>>(flags: T) => Readonly<Ref<T>>;
|
|
640
|
+
/**
|
|
641
|
+
* The reactive handle returned by {@link useMutation} — the Vue counterpart to
|
|
642
|
+
* React's `useMutation`, re-expressed with refs. The surface is identical across
|
|
643
|
+
* the Lunora adapters (`@lunora/solid`, `/svelte`): `data`/`error`/`pending` are
|
|
644
|
+
* refs you read in a template, `mutate` is an awaitable that resolves with the
|
|
645
|
+
* server value (or rejects). Per-call `optimistic` / `optimisticUpdate` options
|
|
646
|
+
* pass straight through to `client.mutation`.
|
|
647
|
+
*/
|
|
148
648
|
interface MutationHandle<F extends FunctionReference> {
|
|
149
649
|
/** The latest invocation's resolved value, or `undefined` before the first success. */
|
|
150
650
|
data: Ref<ReturnOf<F> | undefined>;
|
|
@@ -158,27 +658,31 @@ interface MutationHandle<F extends FunctionReference> {
|
|
|
158
658
|
reset: () => void;
|
|
159
659
|
}
|
|
160
660
|
/**
|
|
161
|
-
* Returns a reactive {@link MutationHandle} for the given mutation reference —
|
|
162
|
-
* the Vue equivalent of React's `useMutation`.
|
|
163
|
-
*
|
|
164
|
-
* Optimistic updates stay client-owned: the `optimistic` / `optimisticUpdate`
|
|
165
|
-
* call options pass straight through to `client.mutation`, which applies and
|
|
166
|
-
* rolls them back against the Lunora subscription cache (Convex parity).
|
|
167
|
-
*
|
|
168
|
-
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
169
|
-
* flips back to `false` only once every concurrent call has settled. The
|
|
170
|
-
* ref-counted pending + error-normalize orchestration is the shared
|
|
171
|
-
* `
|
|
172
|
-
*
|
|
173
|
-
|
|
661
|
+
* Returns a reactive {@link MutationHandle} for the given mutation reference —
|
|
662
|
+
* the Vue equivalent of React's `useMutation`.
|
|
663
|
+
*
|
|
664
|
+
* Optimistic updates stay client-owned: the `optimistic` / `optimisticUpdate`
|
|
665
|
+
* call options pass straight through to `client.mutation`, which applies and
|
|
666
|
+
* rolls them back against the Lunora subscription cache (Convex parity).
|
|
667
|
+
*
|
|
668
|
+
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
669
|
+
* flips back to `false` only once every concurrent call has settled. The
|
|
670
|
+
* ref-counted pending + error-normalize orchestration is the shared
|
|
671
|
+
* `createCallRunner` from `@lunora/client`; only the refs are adapter-specific.
|
|
672
|
+
*
|
|
673
|
+
* `data`/`error` follow the adapter-wide contract: both track the LATEST
|
|
674
|
+
* invocation (an earlier call settling later cannot clobber a newer one), a
|
|
675
|
+
* success clears `error`, and a failure leaves the previous `data` in place.
|
|
676
|
+
* `reset()` clears both; it does not cancel an in-flight call.
|
|
677
|
+
*/
|
|
174
678
|
declare const useMutation: <F extends FunctionReference>(function_: F) => MutationHandle<F>;
|
|
175
679
|
/**
|
|
176
|
-
* The reactive handle returned by {@link useMutator} — the Vue counterpart to
|
|
177
|
-
* `@lunora/react`'s `useMutator`, re-expressed with refs. The surface is
|
|
178
|
-
* identical across the Lunora adapters (`@lunora/solid`, `/svelte`):
|
|
179
|
-
* `error`/`isError`/`pending` are refs you read in a template and `mutate` is an
|
|
180
|
-
* awaitable that resolves once the write is persisted (or rejects).
|
|
181
|
-
*/
|
|
680
|
+
* The reactive handle returned by {@link useMutator} — the Vue counterpart to
|
|
681
|
+
* `@lunora/react`'s `useMutator`, re-expressed with refs. The surface is
|
|
682
|
+
* identical across the Lunora adapters (`@lunora/solid`, `/svelte`):
|
|
683
|
+
* `error`/`isError`/`pending` are refs you read in a template and `mutate` is an
|
|
684
|
+
* awaitable that resolves once the write is persisted (or rejects).
|
|
685
|
+
*/
|
|
182
686
|
interface MutatorHook<TArgs> {
|
|
183
687
|
/** The latest invocation's error, or `undefined`. */
|
|
184
688
|
error: Ref<Error | undefined>;
|
|
@@ -192,18 +696,18 @@ interface MutatorHook<TArgs> {
|
|
|
192
696
|
reset: () => void;
|
|
193
697
|
}
|
|
194
698
|
/**
|
|
195
|
-
* Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
|
|
196
|
-
* custom-mutator handle from `@lunora/db`'s `bindMutators` — the Vue equivalent
|
|
197
|
-
* of `@lunora/react`'s `useMutator`. The optimistic overlay and
|
|
198
|
-
* server-authoritative push are owned by the bound handle (and TanStack DB's
|
|
199
|
-
* optimistic-transaction layer rebases pending overlays on every sync tick);
|
|
200
|
-
* this composable only surfaces reactive state for the in-flight/error
|
|
201
|
-
* lifecycle. Reads stay on the existing TanStack `useLiveQuery`; no new query
|
|
202
|
-
* composable is needed.
|
|
203
|
-
*
|
|
204
|
-
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
205
|
-
* clears only once every concurrent call has settled.
|
|
206
|
-
*/
|
|
699
|
+
* Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
|
|
700
|
+
* custom-mutator handle from `@lunora/db`'s `bindMutators` — the Vue equivalent
|
|
701
|
+
* of `@lunora/react`'s `useMutator`. The optimistic overlay and
|
|
702
|
+
* server-authoritative push are owned by the bound handle (and TanStack DB's
|
|
703
|
+
* optimistic-transaction layer rebases pending overlays on every sync tick);
|
|
704
|
+
* this composable only surfaces reactive state for the in-flight/error
|
|
705
|
+
* lifecycle. Reads stay on the existing TanStack `useLiveQuery`; no new query
|
|
706
|
+
* composable is needed.
|
|
707
|
+
*
|
|
708
|
+
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
709
|
+
* clears only once every concurrent call has settled.
|
|
710
|
+
*/
|
|
207
711
|
declare const useMutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHook<TArgs>;
|
|
208
712
|
/** The args a paginated query exposes minus the framework-supplied page cursor. */
|
|
209
713
|
type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
|
|
@@ -214,9 +718,18 @@ type PageItemOf<F extends FunctionReference> = ReturnOf<F> extends {
|
|
|
214
718
|
interface UsePaginatedQueryOptions {
|
|
215
719
|
/** Page size for the first page (and the default for `loadMore`). */
|
|
216
720
|
initialNumItems: number;
|
|
721
|
+
/** Called when a page subscription reports an error (also surfaced on the `error` ref). */
|
|
722
|
+
onError?: SubscriptionErrorCallback;
|
|
217
723
|
shardKey?: string;
|
|
218
724
|
}
|
|
219
725
|
interface UsePaginatedQueryResult<T> {
|
|
726
|
+
/**
|
|
727
|
+
* The last page subscription error, or `undefined`. A tail page that fails
|
|
728
|
+
* before its first frame is dropped so `status` returns to `"CanLoadMore"`
|
|
729
|
+
* and `loadMore` can retry it; cleared by the next successful frame,
|
|
730
|
+
* `loadMore`, or an args change.
|
|
731
|
+
*/
|
|
732
|
+
error: Ref<SubscriptionError | undefined>;
|
|
220
733
|
/** `true` while the first page or a `loadMore` page is in flight. */
|
|
221
734
|
isLoading: Ref<boolean>;
|
|
222
735
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
@@ -226,31 +739,35 @@ interface UsePaginatedQueryResult<T> {
|
|
|
226
739
|
status: Ref<PaginationStatus>;
|
|
227
740
|
}
|
|
228
741
|
/**
|
|
229
|
-
* Subscribe to a reactively-paginated query and grow the feed page by page.
|
|
230
|
-
*
|
|
231
|
-
* The query function must accept a `paginationOpts: { numItems, cursor,
|
|
232
|
-
* endCursor }` arg and return a `PaginationResult`. Pages are tracked as an
|
|
233
|
-
* ordered list of stable boundary cursors; each loaded page is a live
|
|
234
|
-
* subscription over a FIXED `(lower, upper]` range. Inserting or deleting a row
|
|
235
|
-
* grows/shrinks the affected page without duplicating or skipping rows across
|
|
236
|
-
* boundaries.
|
|
237
|
-
*
|
|
238
|
-
* `loadMore` appends the next page off the open-ended tail's `continueCursor`;
|
|
239
|
-
* it is a no-op unless `status === "CanLoadMore"`. Background split/join
|
|
240
|
-
* maintenance keeps page sizes near `initialNumItems` as edits accumulate.
|
|
241
|
-
*
|
|
242
|
-
* Changing `fn`, the base `args`, `initialNumItems`, or `shardKey` resets the
|
|
243
|
-
* feed to its first page.
|
|
244
|
-
*
|
|
245
|
-
* Call inside `setup()` (or any active effect scope).
|
|
246
|
-
*/
|
|
742
|
+
* Subscribe to a reactively-paginated query and grow the feed page by page.
|
|
743
|
+
*
|
|
744
|
+
* The query function must accept a `paginationOpts: { numItems, cursor,
|
|
745
|
+
* endCursor }` arg and return a `PaginationResult`. Pages are tracked as an
|
|
746
|
+
* ordered list of stable boundary cursors; each loaded page is a live
|
|
747
|
+
* subscription over a FIXED `(lower, upper]` range. Inserting or deleting a row
|
|
748
|
+
* grows/shrinks the affected page without duplicating or skipping rows across
|
|
749
|
+
* boundaries.
|
|
750
|
+
*
|
|
751
|
+
* `loadMore` appends the next page off the open-ended tail's `continueCursor`;
|
|
752
|
+
* it is a no-op unless `status === "CanLoadMore"`. Background split/join
|
|
753
|
+
* maintenance keeps page sizes near `initialNumItems` as edits accumulate.
|
|
754
|
+
*
|
|
755
|
+
* Changing `fn`, the base `args`, `initialNumItems`, or `shardKey` resets the
|
|
756
|
+
* feed to its first page.
|
|
757
|
+
*
|
|
758
|
+
* Call inside `setup()` (or any active effect scope).
|
|
759
|
+
*/
|
|
247
760
|
declare const usePaginatedQuery: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<"skip" | PaginatedArgs<F>>, options: UsePaginatedQueryOptions) => UsePaginatedQueryResult<PageItemOf<F>>;
|
|
248
761
|
interface UseInfiniteQueryOptions {
|
|
249
762
|
/** Page size for the first page (and the default for `fetchNextPage`). */
|
|
250
763
|
initialNumItems: number;
|
|
764
|
+
/** Called when a page subscription reports an error (also surfaced on the `error` ref). */
|
|
765
|
+
onError?: SubscriptionErrorCallback;
|
|
251
766
|
shardKey?: string;
|
|
252
767
|
}
|
|
253
768
|
interface UseInfiniteQueryResult<T> {
|
|
769
|
+
/** The last page subscription error, or `undefined` — see `UsePaginatedQueryResult.error`. */
|
|
770
|
+
error: Ref<SubscriptionError | undefined>;
|
|
254
771
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
255
772
|
fetchNextPage: (numberItems?: number) => void;
|
|
256
773
|
/** `true` when the loaded tail reports it can load another page. */
|
|
@@ -264,37 +781,37 @@ interface UseInfiniteQueryResult<T> {
|
|
|
264
781
|
status: Ref<PaginationStatus>;
|
|
265
782
|
}
|
|
266
783
|
/**
|
|
267
|
-
* Subscribe to a reactively-paginated query and expose its pages discretely.
|
|
268
|
-
*
|
|
269
|
-
* Shares `usePaginatedQuery`'s reactive-pagination engine but keeps each page
|
|
270
|
-
* as its own inner array rather than flattening them, and adds the
|
|
271
|
-
* TanStack-Query-style `fetchNextPage` / `hasNextPage` / `isFetchingNextPage`
|
|
272
|
-
* shape.
|
|
273
|
-
*
|
|
274
|
-
* Call inside `setup()` (or any active effect scope).
|
|
275
|
-
*/
|
|
784
|
+
* Subscribe to a reactively-paginated query and expose its pages discretely.
|
|
785
|
+
*
|
|
786
|
+
* Shares `usePaginatedQuery`'s reactive-pagination engine but keeps each page
|
|
787
|
+
* as its own inner array rather than flattening them, and adds the
|
|
788
|
+
* TanStack-Query-style `fetchNextPage` / `hasNextPage` / `isFetchingNextPage`
|
|
789
|
+
* shape.
|
|
790
|
+
*
|
|
791
|
+
* Call inside `setup()` (or any active effect scope).
|
|
792
|
+
*/
|
|
276
793
|
declare const useInfiniteQuery: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<"skip" | PaginatedArgs<F>>, options: UseInfiniteQueryOptions) => UseInfiniteQueryResult<PageItemOf<F>>;
|
|
277
794
|
/**
|
|
278
|
-
* `usePresence` — collaborative-awareness composable, the client half of the
|
|
279
|
-
* `@lunora/server` `definePresence` preset.
|
|
280
|
-
*
|
|
281
|
-
* Drives the heartbeat mutation (on mount, interval, and tab re-focus) and
|
|
282
|
-
* subscribes to the live `listPresent` query for the given room.
|
|
283
|
-
*
|
|
284
|
-
* Call inside `setup()` (or any active effect scope).
|
|
285
|
-
*/
|
|
286
|
-
/**
|
|
287
|
-
* A heartbeat mutation reference: takes `{ roomId, sessionId, data? }`.
|
|
288
|
-
*/
|
|
795
|
+
* `usePresence` — collaborative-awareness composable, the client half of the
|
|
796
|
+
* `@lunora/server` `definePresence` preset.
|
|
797
|
+
*
|
|
798
|
+
* Drives the heartbeat mutation (on mount, interval, and tab re-focus) and
|
|
799
|
+
* subscribes to the live `listPresent` query for the given room.
|
|
800
|
+
*
|
|
801
|
+
* Call inside `setup()` (or any active effect scope).
|
|
802
|
+
*/
|
|
803
|
+
/**
|
|
804
|
+
* A heartbeat mutation reference: takes `{ roomId, sessionId, data? }`.
|
|
805
|
+
*/
|
|
289
806
|
type HeartbeatReference = FunctionReference<"mutation", {
|
|
290
807
|
data?: Record<string, unknown>;
|
|
291
808
|
roomId: string;
|
|
292
809
|
sessionId: string;
|
|
293
810
|
}>;
|
|
294
811
|
/**
|
|
295
|
-
* A listPresent query reference: takes `{ roomId }` and returns the array of
|
|
296
|
-
* present members.
|
|
297
|
-
*/
|
|
812
|
+
* A listPresent query reference: takes `{ roomId }` and returns the array of
|
|
813
|
+
* present members.
|
|
814
|
+
*/
|
|
298
815
|
type ListPresentReference = FunctionReference<"query", {
|
|
299
816
|
roomId: string;
|
|
300
817
|
}>;
|
|
@@ -308,14 +825,22 @@ interface UsePresenceOptions<H extends HeartbeatReference, L extends ListPresent
|
|
|
308
825
|
/** The `api.*` reference for the presence listPresent query. */
|
|
309
826
|
listPresent: L;
|
|
310
827
|
/**
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
828
|
+
* Called when the `listPresent` subscription reports an error (a session
|
|
829
|
+
* expiry, an RLS denial). Without it — and without reading `error` — such a
|
|
830
|
+
* failure is invisible and `present` is cleared until a later frame arrives.
|
|
831
|
+
*/
|
|
832
|
+
onError?: SubscriptionErrorCallback;
|
|
833
|
+
/**
|
|
834
|
+
* Stable id for this presence row. Defaults to a fresh per-mount id.
|
|
835
|
+
* Pass a user/connection id to control deduping across tabs.
|
|
836
|
+
*/
|
|
314
837
|
sessionId?: string;
|
|
315
838
|
/** Forwarded to the heartbeat mutation / listPresent subscription when sharding by room. */
|
|
316
839
|
shardKey?: string;
|
|
317
840
|
}
|
|
318
841
|
interface UsePresenceResult<L extends ListPresentReference> {
|
|
842
|
+
/** The `listPresent` subscription's last error, or `undefined`. */
|
|
843
|
+
error: ShallowRef<SubscriptionError | undefined>;
|
|
319
844
|
/** The present members for the room. `undefined` until the first push. */
|
|
320
845
|
present: ShallowRef<ReturnOf<L> | undefined>;
|
|
321
846
|
/** This mount's session id (generated when not supplied). */
|
|
@@ -325,51 +850,58 @@ interface UsePresenceResult<L extends ListPresentReference> {
|
|
|
325
850
|
}
|
|
326
851
|
declare const usePresence: <H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: UsePresenceOptions<H, L>) => UsePresenceResult<L>;
|
|
327
852
|
/**
|
|
328
|
-
* Open a live subscription against `client` for FIXED args and stream its values
|
|
329
|
-
* into a `ref`. The low-level primitive behind `hydratePreloaded` (whose args
|
|
330
|
-
* come from an immutable `Preloaded` token and never change); {@link useQuery}
|
|
331
|
-
* handles the reactive-args case separately.
|
|
332
|
-
*
|
|
333
|
-
* `client.subscribe` already dedupes by `(functionPath, args, shardKey)` and
|
|
334
|
-
* replays the last value synchronously, so multiple consumers of the same query
|
|
335
|
-
* ride one server-side registration. `seed` sets the ref's value synchronously
|
|
336
|
-
* before the subscription attaches, so the first read shows the SSR value with
|
|
337
|
-
* no loading flash.
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
* effect scope (
|
|
342
|
-
*
|
|
343
|
-
* `
|
|
344
|
-
|
|
853
|
+
* Open a live subscription against `client` for FIXED args and stream its values
|
|
854
|
+
* into a `ref`. The low-level primitive behind `hydratePreloaded` (whose args
|
|
855
|
+
* come from an immutable `Preloaded` token and never change); {@link useQuery}
|
|
856
|
+
* handles the reactive-args case separately.
|
|
857
|
+
*
|
|
858
|
+
* `client.subscribe` already dedupes by `(functionPath, args, shardKey)` and
|
|
859
|
+
* replays the last value synchronously, so multiple consumers of the same query
|
|
860
|
+
* ride one server-side registration. `seed` sets the ref's value synchronously
|
|
861
|
+
* before the subscription attaches, so the first read shows the SSR value with
|
|
862
|
+
* no loading flash. `onError` receives a subscription-scoped error the server
|
|
863
|
+
* pushes (a session expiry, an RLS denial); without it the ref keeps rendering
|
|
864
|
+
* the seed as if it were live.
|
|
865
|
+
*
|
|
866
|
+
* Teardown is wired to the active effect scope (`onScopeDispose`), so it fires
|
|
867
|
+
* on component unmount or `effectScope().stop()`. Call it inside `setup()` / an
|
|
868
|
+
* effect scope (as `hydratePreloaded` does); outside any scope there is nothing
|
|
869
|
+
* to own the subscription, so it would leak until the process exits — the
|
|
870
|
+
* `getCurrentScope` guard only avoids throwing, it does not auto-clean.
|
|
871
|
+
*/
|
|
345
872
|
declare const subscribeToQuery: <F extends FunctionReference, T = ReturnOf<F>>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
|
|
873
|
+
onError?: SubscriptionErrorCallback;
|
|
346
874
|
seed?: T;
|
|
347
875
|
shardKey?: string;
|
|
348
876
|
}) => Ref<T | undefined>;
|
|
349
877
|
/**
|
|
350
|
-
* Subscribe to a server query and expose its latest value as a `ref`.
|
|
351
|
-
*
|
|
352
|
-
* The returned ref is `undefined` until the first server response lands, then
|
|
353
|
-
* updates on every delta the server pushes — the Vue-idiomatic equivalent of
|
|
354
|
-
* React's `useQuery`. `args` may be a plain value, a `ref`, or a getter: passing
|
|
355
|
-
* a reactive source makes the subscription reactive — when the args change the
|
|
356
|
-
* old subscription is torn down
|
|
357
|
-
* `@lunora/react`/`@lunora/solid`). Pass `"skip"` (or a source resolving to
|
|
358
|
-
* `"skip"`) to short-circuit: no network call, no socket. The subscription tears
|
|
359
|
-
* down automatically when the owning component unmounts (or the effect scope
|
|
360
|
-
* stops).
|
|
361
|
-
*
|
|
362
|
-
* Call inside `setup()` (or any active effect scope). For SSR seeding with no
|
|
363
|
-
* loading flash, use `hydratePreloaded` instead.
|
|
364
|
-
|
|
878
|
+
* Subscribe to a server query and expose its latest value as a `ref`.
|
|
879
|
+
*
|
|
880
|
+
* The returned ref is `undefined` until the first server response lands, then
|
|
881
|
+
* updates on every delta the server pushes — the Vue-idiomatic equivalent of
|
|
882
|
+
* React's `useQuery`. `args` may be a plain value, a `ref`, or a getter: passing
|
|
883
|
+
* a reactive source makes the subscription reactive — when the args change the
|
|
884
|
+
* old subscription is torn down, the ref resets to `undefined`, and a fresh one
|
|
885
|
+
* opens for the new args (matching `@lunora/react`/`@lunora/solid`). Pass `"skip"` (or a source resolving to
|
|
886
|
+
* `"skip"`) to short-circuit: no network call, no socket. The subscription tears
|
|
887
|
+
* down automatically when the owning component unmounts (or the effect scope
|
|
888
|
+
* stops).
|
|
889
|
+
*
|
|
890
|
+
* Call inside `setup()` (or any active effect scope). For SSR seeding with no
|
|
891
|
+
* loading flash, use `hydratePreloaded` instead.
|
|
892
|
+
*
|
|
893
|
+
* Pass `onError` to surface a subscription-scoped error the server pushes (an RLS
|
|
894
|
+
* denial, a query that starts failing server-side). Without it such an error is
|
|
895
|
+
* dropped and the ref just freezes at its last good value.
|
|
896
|
+
*/
|
|
365
897
|
declare const useQuery: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<ArgsOf<F> | "skip">, options?: UseQueryOptions) => Ref<ReturnOf<F> | undefined>;
|
|
366
898
|
interface UseRateLimitOptions {
|
|
367
899
|
/** Clock injection for tests. Defaults to `Date.now`. */
|
|
368
900
|
now?: () => number;
|
|
369
901
|
/**
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
902
|
+
* Re-render cadence in milliseconds while throttled, so `retryAfter` ticks
|
|
903
|
+
* down and `disabled` flips back automatically. Defaults to `1000`.
|
|
904
|
+
*/
|
|
373
905
|
tickMs?: number;
|
|
374
906
|
}
|
|
375
907
|
interface UseRateLimitResult {
|
|
@@ -387,31 +919,306 @@ interface UseRateLimitResult {
|
|
|
387
919
|
retryAfter: ComputedRef<number>;
|
|
388
920
|
}
|
|
389
921
|
/**
|
|
390
|
-
* Client-side mirror of a rate limit for instant UX — disable a button or show
|
|
391
|
-
* a countdown without a round-trip. It runs the same token-bucket / fixed-window
|
|
392
|
-
* math as `@lunora/ratelimit` on the server, so the prediction agrees with the
|
|
393
|
-
* authoritative check; the server remains the source of truth.
|
|
394
|
-
*
|
|
395
|
-
* `config` accepts a plain object, a `ref`, or a getter (`MaybeRefOrGetter`).
|
|
396
|
-
* When you pass a ref/getter it is tracked reactively — changing the config
|
|
397
|
-
* re-derives `status` (and the `ok` / `disabled` / `retryAfter` views) on the
|
|
398
|
-
* fly. A plain object keeps working unchanged; pass a stable reference (module
|
|
399
|
-
* constant) so the reactive derived values stay settled.
|
|
400
|
-
*/
|
|
922
|
+
* Client-side mirror of a rate limit for instant UX — disable a button or show
|
|
923
|
+
* a countdown without a round-trip. It runs the same token-bucket / fixed-window
|
|
924
|
+
* math as `@lunora/ratelimit` on the server, so the prediction agrees with the
|
|
925
|
+
* authoritative check; the server remains the source of truth.
|
|
926
|
+
*
|
|
927
|
+
* `config` accepts a plain object, a `ref`, or a getter (`MaybeRefOrGetter`).
|
|
928
|
+
* When you pass a ref/getter it is tracked reactively — changing the config
|
|
929
|
+
* re-derives `status` (and the `ok` / `disabled` / `retryAfter` views) on the
|
|
930
|
+
* fly. A plain object keeps working unchanged; pass a stable reference (module
|
|
931
|
+
* constant) so the reactive derived values stay settled.
|
|
932
|
+
*/
|
|
401
933
|
declare const useRateLimit: (config: MaybeRefOrGetter<RateLimitConfig>, options?: UseRateLimitOptions) => UseRateLimitResult;
|
|
934
|
+
/** The lifecycle of a stream the composable is observing. */
|
|
935
|
+
type UseStreamStatus = "complete" | "error" | "idle" | "streaming";
|
|
936
|
+
interface UseStreamResult<T> {
|
|
937
|
+
/** Force-cancel the stream and resolve the iterator. Safe to call multiple times. */
|
|
938
|
+
cancel: () => void;
|
|
939
|
+
/** Chunks the server has pushed so far, in arrival order. */
|
|
940
|
+
chunks: Ref<ReadonlyArray<T>>;
|
|
941
|
+
error: Ref<Error | undefined>;
|
|
942
|
+
status: Ref<UseStreamStatus>;
|
|
943
|
+
}
|
|
944
|
+
interface UseStreamOptions {
|
|
945
|
+
/**
|
|
946
|
+
* Opt into resume-on-reconnect for a stream the server declared `durable`.
|
|
947
|
+
* The chunks already received are kept and the socket re-attaches to the same
|
|
948
|
+
* run, so a dropped connection mid-generation continues instead of surfacing
|
|
949
|
+
* `STREAM_DISCONNECTED`. Has no effect on an ephemeral stream.
|
|
950
|
+
*/
|
|
951
|
+
durable?: boolean;
|
|
952
|
+
/** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
|
|
953
|
+
maxBuffer?: number;
|
|
954
|
+
shardKey?: string;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Subscribe to a streaming query. Returns the chunks pushed so far plus a
|
|
958
|
+
* lifecycle status and a cancel function, all as refs. Changing the resolved
|
|
959
|
+
* `args` resets the stream — the previous iterator is cancelled and a fresh one
|
|
960
|
+
* opens with empty `chunks`.
|
|
961
|
+
*
|
|
962
|
+
* `args` may be a plain value, `ref`, or getter; resolving it to `"skip"` keeps
|
|
963
|
+
* the composable mounted without opening a stream (mirrors `useSubscription`).
|
|
964
|
+
* Nothing opens during SSR either — the stream attaches after hydration.
|
|
965
|
+
* The Vue counterpart to React's `useStream`, re-expressed with refs.
|
|
966
|
+
*/
|
|
967
|
+
declare const useStream: <F extends FunctionReference<"stream">>(function_: F, args: MaybeRefOrGetter<"skip" | ArgsOf<F>>, options?: UseStreamOptions) => UseStreamResult<ReturnOf<F>>;
|
|
402
968
|
interface UseSubscriptionResult<T> {
|
|
403
969
|
data: Ref<T | undefined>;
|
|
404
970
|
error: Ref<Error | undefined>;
|
|
405
971
|
}
|
|
406
972
|
/**
|
|
407
|
-
* Subscribe to a reactive server push stream. Returns `{ data, error }` refs
|
|
408
|
-
* that update whenever the server emits a new value. Passing `"skip"` as `args`
|
|
409
|
-
* (or a ref/getter that resolves to `"skip"`) tears down the subscription
|
|
410
|
-
* without unmounting.
|
|
411
|
-
*
|
|
412
|
-
* Unlike `useQuery`, which tracks the full reactive cache, `useSubscription`
|
|
413
|
-
* owns a single lightweight subscription and is suitable for ephemeral,
|
|
414
|
-
* high-frequency streams.
|
|
415
|
-
*/
|
|
973
|
+
* Subscribe to a reactive server push stream. Returns `{ data, error }` refs
|
|
974
|
+
* that update whenever the server emits a new value. Passing `"skip"` as `args`
|
|
975
|
+
* (or a ref/getter that resolves to `"skip"`) tears down the subscription
|
|
976
|
+
* without unmounting.
|
|
977
|
+
*
|
|
978
|
+
* Unlike `useQuery`, which tracks the full reactive cache, `useSubscription`
|
|
979
|
+
* owns a single lightweight subscription and is suitable for ephemeral,
|
|
980
|
+
* high-frequency streams.
|
|
981
|
+
*/
|
|
416
982
|
declare const useSubscription: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<ArgsOf<F> | "skip">, options?: UseQueryOptions) => UseSubscriptionResult<ReturnOf<F>>;
|
|
417
|
-
|
|
983
|
+
/**
|
|
984
|
+
* Browser Web Audio subsystems for `useVoiceAgent` — the default microphone
|
|
985
|
+
* capture and speaker playback implementations injected into the composable via
|
|
986
|
+
* its `createMicrophone` / `createSpeaker` seams. Kept in a sibling module so the
|
|
987
|
+
* heavy Web Audio graph (and its structural DOM typings) stays isolated from the
|
|
988
|
+
* composable's transport + reactive-state logic and remains mockable in a
|
|
989
|
+
* non-browser test env.
|
|
990
|
+
*/
|
|
991
|
+
/**
|
|
992
|
+
* The negotiated audio format the voice DO streams back. Mirrors
|
|
993
|
+
* `@lunora/agent`'s `VoiceServerFrame` `ready.audioFormat` — re-declared (not
|
|
994
|
+
* imported) so this Vue package never pulls in the server-only `@lunora/agent`
|
|
995
|
+
* module graph.
|
|
996
|
+
*/
|
|
997
|
+
type VoiceAudioFormat = "mp3" | "wav";
|
|
998
|
+
/** Captures microphone audio and reports level / turn boundaries back to the composable. */
|
|
999
|
+
interface VoiceMicrophone {
|
|
1000
|
+
/** Mute/unmute the mic without tearing down the capture graph. */
|
|
1001
|
+
setMuted: (muted: boolean) => void;
|
|
1002
|
+
/** Stop capture and release the media stream + audio graph. */
|
|
1003
|
+
stop: () => void;
|
|
1004
|
+
}
|
|
1005
|
+
/** Plays the server's streamed audio chunks and supports a mid-utterance barge-in. */
|
|
1006
|
+
interface VoiceSpeaker {
|
|
1007
|
+
/** Queue a decoded audio chunk for gap-minimized playback. */
|
|
1008
|
+
enqueue: (audio: Uint8Array) => void;
|
|
1009
|
+
/** Drop everything queued and stop the current chunk (barge-in). */
|
|
1010
|
+
interrupt: () => void;
|
|
1011
|
+
/** Release the playback audio context. */
|
|
1012
|
+
stop: () => void;
|
|
1013
|
+
}
|
|
1014
|
+
/** Config passed to a {@link CreateMicrophone} factory. */
|
|
1015
|
+
interface MicrophoneConfig {
|
|
1016
|
+
/** The consecutive above-threshold chunk count that counts as a barge-in. */
|
|
1017
|
+
interruptChunks: number;
|
|
1018
|
+
/** RMS above which the user is considered to be barging in while the agent speaks. */
|
|
1019
|
+
interruptThreshold: number;
|
|
1020
|
+
/**
|
|
1021
|
+
* `true` from the moment a turn is committed until it completes — the whole
|
|
1022
|
+
* `thinking` + `speaking` window, not just the audible half.
|
|
1023
|
+
*
|
|
1024
|
+
* It gates BOTH branches below, and the wider span is the point. Gated only
|
|
1025
|
+
* on "audibly speaking", turn detection kept running through the entire
|
|
1026
|
+
* STT+LLM window after a `commit`: room noise at the (deliberately low)
|
|
1027
|
+
* `silenceThreshold` re-armed `sawSpeech`, another quiet gap fired a SECOND
|
|
1028
|
+
* `commit`, and the DO refused it with "a turn is already in progress" —
|
|
1029
|
+
* a refusal that returns before draining the audio buffer, so the PCM
|
|
1030
|
+
* captured since the first commit leaked into the next utterance.
|
|
1031
|
+
*
|
|
1032
|
+
* A genuine barge-in still works in that window: it routes through the
|
|
1033
|
+
* `onInterrupt` branch, which needs `interruptChunks` consecutive chunks at
|
|
1034
|
+
* `interruptThreshold` — an order of magnitude above `silenceThreshold` —
|
|
1035
|
+
* and `interrupt` is exactly what the DO tells the client to send.
|
|
1036
|
+
*/
|
|
1037
|
+
isTurnActive: () => boolean;
|
|
1038
|
+
/** One 16 kHz mono 16-bit little-endian PCM frame captured from the mic. */
|
|
1039
|
+
onAudio: (pcm: Uint8Array) => void;
|
|
1040
|
+
/** A barge-in was detected (RMS spike while the agent is speaking). */
|
|
1041
|
+
onInterrupt: () => void;
|
|
1042
|
+
/** The current input RMS (0–1), for a level meter. */
|
|
1043
|
+
onLevel: (rms: number) => void;
|
|
1044
|
+
/** A spoken utterance ended (speech followed by `silenceDurationMs` of silence). */
|
|
1045
|
+
onSilence: () => void;
|
|
1046
|
+
/** Milliseconds of sub-threshold audio (after speech) that closes an utterance. */
|
|
1047
|
+
silenceDurationMs: number;
|
|
1048
|
+
/** RMS below which audio counts as silence. */
|
|
1049
|
+
silenceThreshold: number;
|
|
1050
|
+
}
|
|
1051
|
+
type CreateMicrophone = (config: MicrophoneConfig) => Promise<VoiceMicrophone>;
|
|
1052
|
+
type CreateSpeaker = (config: {
|
|
1053
|
+
audioFormat: VoiceAudioFormat;
|
|
1054
|
+
}) => VoiceSpeaker;
|
|
1055
|
+
/**
|
|
1056
|
+
* The `agents.<name>Voice` reference codegen emits for a voice-enabled agent — a
|
|
1057
|
+
* live, WS-backed session keyed by `threadKey`. A structural subset of the
|
|
1058
|
+
* generated member, so passing `api.agents.<name>Voice` type-checks.
|
|
1059
|
+
*/
|
|
1060
|
+
type VoiceReference = FunctionReference<"stream", {
|
|
1061
|
+
threadKey: string;
|
|
1062
|
+
}, Record<string, unknown>>;
|
|
1063
|
+
/** The lifecycle of a voice call, mirrored to the UI. */
|
|
1064
|
+
type VoiceStatus = "idle" | "listening" | "speaking" | "thinking";
|
|
1065
|
+
/** A minimal structural subset of the DOM `WebSocket` the composable drives. */
|
|
1066
|
+
interface VoiceSocket {
|
|
1067
|
+
binaryType: string;
|
|
1068
|
+
close: () => void;
|
|
1069
|
+
onclose: ((event: unknown) => void) | null;
|
|
1070
|
+
onerror: ((event: unknown) => void) | null;
|
|
1071
|
+
onmessage: ((event: {
|
|
1072
|
+
data: unknown;
|
|
1073
|
+
}) => void) | null;
|
|
1074
|
+
onopen: ((event: unknown) => void) | null;
|
|
1075
|
+
readonly readyState: number;
|
|
1076
|
+
send: (data: ArrayBufferView | ArrayBufferLike | string) => void;
|
|
1077
|
+
}
|
|
1078
|
+
type CreateSocket = (url: string) => VoiceSocket;
|
|
1079
|
+
interface UseVoiceAgentOptions {
|
|
1080
|
+
/**
|
|
1081
|
+
* Advanced/test seam: build the microphone capture subsystem. Defaults to a
|
|
1082
|
+
* `getUserMedia` + Web Audio implementation. Injected wholesale so the Web
|
|
1083
|
+
* Audio graph stays isolated (and mockable in a non-browser test env).
|
|
1084
|
+
*/
|
|
1085
|
+
createMicrophone?: CreateMicrophone;
|
|
1086
|
+
/**
|
|
1087
|
+
* Advanced/test seam: open the transport. Defaults to the WebSocket
|
|
1088
|
+
* implementation the client was built with (`client.getWebSocketImpl()`),
|
|
1089
|
+
* NOT a raw `globalThis.WebSocket`.
|
|
1090
|
+
*/
|
|
1091
|
+
createSocket?: CreateSocket;
|
|
1092
|
+
/** Advanced/test seam: build the audio playback subsystem. Defaults to a Web Audio implementation. */
|
|
1093
|
+
createSpeaker?: CreateSpeaker;
|
|
1094
|
+
/** Consecutive above-`interruptThreshold` chunks that trigger a barge-in. Default `3`. */
|
|
1095
|
+
interruptChunks?: number;
|
|
1096
|
+
/** Input RMS above which the user is treated as barging in while the agent speaks. Default `0.15`. */
|
|
1097
|
+
interruptThreshold?: number;
|
|
1098
|
+
/** Milliseconds of silence (after speech) that auto-commits an utterance. Default `1200`. */
|
|
1099
|
+
silenceDurationMs?: number;
|
|
1100
|
+
/** Input RMS below which audio counts as silence. Default `0.01`. */
|
|
1101
|
+
silenceThreshold?: number;
|
|
1102
|
+
/** The thread to converse on — shared with the agent's text turns. May be a plain value, `ref`, or getter (resolved when the call opens). */
|
|
1103
|
+
threadKey: MaybeRefOrGetter<string>;
|
|
1104
|
+
/** The generated `api.agents.<name>Voice` reference — identifies the voice DO endpoint. */
|
|
1105
|
+
voice: VoiceReference;
|
|
1106
|
+
}
|
|
1107
|
+
interface UseVoiceAgentResult {
|
|
1108
|
+
/** The current input RMS (0–1) — drive a mic level meter. */
|
|
1109
|
+
audioLevel: Readonly<Ref<number>>;
|
|
1110
|
+
/** `true` once the WS `ready` handshake completed. */
|
|
1111
|
+
connected: Readonly<Ref<boolean>>;
|
|
1112
|
+
/** Tear down the call: close the socket, stop the mic, release audio. Idempotent. */
|
|
1113
|
+
endCall: () => void;
|
|
1114
|
+
/** The last transport/pipeline error, or `undefined`. */
|
|
1115
|
+
error: Readonly<Ref<Error | undefined>>;
|
|
1116
|
+
/** The live assistant text for the in-flight turn (grows via deltas; finalized on done). */
|
|
1117
|
+
interimTranscript: Readonly<Ref<string>>;
|
|
1118
|
+
/** `true` while the mic is muted. */
|
|
1119
|
+
isMuted: Readonly<Ref<boolean>>;
|
|
1120
|
+
/** Send a typed turn (no audio) — a text message spoken back by the agent. */
|
|
1121
|
+
sendText: (text: string) => void;
|
|
1122
|
+
/** Open the mic, connect the socket, and start the conversation. Idempotent while active. */
|
|
1123
|
+
startCall: () => Promise<void>;
|
|
1124
|
+
/** The current call lifecycle. */
|
|
1125
|
+
status: Readonly<Ref<VoiceStatus>>;
|
|
1126
|
+
/** Mute/unmute the microphone. Returns the new muted state. */
|
|
1127
|
+
toggleMute: () => boolean;
|
|
1128
|
+
/** The last finalized user utterance (STT result). */
|
|
1129
|
+
transcript: Readonly<Ref<string>>;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* A first-class voice-call surface for a voice-enabled agent: it opens a
|
|
1133
|
+
* WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
|
|
1134
|
+
* streams the agent's synthesized speech back through the browser's audio output,
|
|
1135
|
+
* and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
|
|
1136
|
+
* `audioLevel`) to Vue refs. Pass the generated `api.agents.<name>Voice`
|
|
1137
|
+
* reference (never a string), matching `useAgentChat`'s reference-passing style.
|
|
1138
|
+
* The Vue counterpart to React's `useVoiceAgent`, re-expressed with refs; the
|
|
1139
|
+
* per-call connection lives in a closure variable (a composable runs once per
|
|
1140
|
+
* component, so no `ref`-of-ref indirection is needed).
|
|
1141
|
+
*
|
|
1142
|
+
* v1 transport is plain binary WebSocket frames with push-to-talk / silence-timer
|
|
1143
|
+
* turn detection and client-side RMS barge-in. The heavy Web Audio capture and
|
|
1144
|
+
* playback subsystems are injectable (`createMicrophone` / `createSpeaker` /
|
|
1145
|
+
* `createSocket`) so the composable is drivable outside a browser.
|
|
1146
|
+
*/
|
|
1147
|
+
declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
|
|
1148
|
+
export { type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type FlagValue, type HeartbeatReference,
|
|
1149
|
+
/**
|
|
1150
|
+
* `@lunora/vue` — the Vue adapter for Lunora.
|
|
1151
|
+
*
|
|
1152
|
+
* Thin, idiomatic glue over the framework-neutral `@lunora/client` (which owns
|
|
1153
|
+
* the WebSocket transport, subscription registry, offline queue, and
|
|
1154
|
+
* delta-merge — zero React, zero Vue). This package re-expresses that contract
|
|
1155
|
+
* as Vue composables:
|
|
1156
|
+
*
|
|
1157
|
+
* - `createLunora` / `provideLunora` / `useLunora` — provide/inject the client.
|
|
1158
|
+
* - `useQuery` — a live `ref` that opens a WS subscription and updates on deltas (reactive args re-subscribe).
|
|
1159
|
+
* - `useMutation` — an optimistic mutation handle (refs + awaitable `mutate`).
|
|
1160
|
+
* - `hydratePreloaded` — seed a `ref` synchronously from an SSR `Preloaded` token (no loading flash), then attach the live subscription.
|
|
1161
|
+
*
|
|
1162
|
+
* Server-side preload helpers live in the socket-free `@lunora/vue/server`
|
|
1163
|
+
* entry (`createServerClient`, `preloadQuery`). Nuxt's single-worker
|
|
1164
|
+
* composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
|
|
1165
|
+
* package — see [Bring your framework](/docs/frameworks/bring-your-framework).
|
|
1166
|
+
*/
|
|
1167
|
+
LUNORA_INJECTION_KEY, type ListPresentReference, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus,
|
|
1168
|
+
/**
|
|
1169
|
+
* `@lunora/vue` — the Vue adapter for Lunora.
|
|
1170
|
+
*
|
|
1171
|
+
* Thin, idiomatic glue over the framework-neutral `@lunora/client` (which owns
|
|
1172
|
+
* the WebSocket transport, subscription registry, offline queue, and
|
|
1173
|
+
* delta-merge — zero React, zero Vue). This package re-expresses that contract
|
|
1174
|
+
* as Vue composables:
|
|
1175
|
+
*
|
|
1176
|
+
* - `createLunora` / `provideLunora` / `useLunora` — provide/inject the client.
|
|
1177
|
+
* - `useQuery` — a live `ref` that opens a WS subscription and updates on deltas (reactive args re-subscribe).
|
|
1178
|
+
* - `useMutation` — an optimistic mutation handle (refs + awaitable `mutate`).
|
|
1179
|
+
* - `hydratePreloaded` — seed a `ref` synchronously from an SSR `Preloaded` token (no loading flash), then attach the live subscription.
|
|
1180
|
+
*
|
|
1181
|
+
* Server-side preload helpers live in the socket-free `@lunora/vue/server`
|
|
1182
|
+
* entry (`createServerClient`, `preloadQuery`). Nuxt's single-worker
|
|
1183
|
+
* composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
|
|
1184
|
+
* package — see [Bring your framework](/docs/frameworks/bring-your-framework).
|
|
1185
|
+
*/
|
|
1186
|
+
createLunora, hydratePreloaded,
|
|
1187
|
+
/**
|
|
1188
|
+
* `@lunora/vue` — the Vue adapter for Lunora.
|
|
1189
|
+
*
|
|
1190
|
+
* Thin, idiomatic glue over the framework-neutral `@lunora/client` (which owns
|
|
1191
|
+
* the WebSocket transport, subscription registry, offline queue, and
|
|
1192
|
+
* delta-merge — zero React, zero Vue). This package re-expresses that contract
|
|
1193
|
+
* as Vue composables:
|
|
1194
|
+
*
|
|
1195
|
+
* - `createLunora` / `provideLunora` / `useLunora` — provide/inject the client.
|
|
1196
|
+
* - `useQuery` — a live `ref` that opens a WS subscription and updates on deltas (reactive args re-subscribe).
|
|
1197
|
+
* - `useMutation` — an optimistic mutation handle (refs + awaitable `mutate`).
|
|
1198
|
+
* - `hydratePreloaded` — seed a `ref` synchronously from an SSR `Preloaded` token (no loading flash), then attach the live subscription.
|
|
1199
|
+
*
|
|
1200
|
+
* Server-side preload helpers live in the socket-free `@lunora/vue/server`
|
|
1201
|
+
* entry (`createServerClient`, `preloadQuery`). Nuxt's single-worker
|
|
1202
|
+
* composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
|
|
1203
|
+
* package — see [Bring your framework](/docs/frameworks/bring-your-framework).
|
|
1204
|
+
*/
|
|
1205
|
+
provideLunora, subscribeToQuery, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery,
|
|
1206
|
+
/**
|
|
1207
|
+
* `@lunora/vue` — the Vue adapter for Lunora.
|
|
1208
|
+
*
|
|
1209
|
+
* Thin, idiomatic glue over the framework-neutral `@lunora/client` (which owns
|
|
1210
|
+
* the WebSocket transport, subscription registry, offline queue, and
|
|
1211
|
+
* delta-merge — zero React, zero Vue). This package re-expresses that contract
|
|
1212
|
+
* as Vue composables:
|
|
1213
|
+
*
|
|
1214
|
+
* - `createLunora` / `provideLunora` / `useLunora` — provide/inject the client.
|
|
1215
|
+
* - `useQuery` — a live `ref` that opens a WS subscription and updates on deltas (reactive args re-subscribe).
|
|
1216
|
+
* - `useMutation` — an optimistic mutation handle (refs + awaitable `mutate`).
|
|
1217
|
+
* - `hydratePreloaded` — seed a `ref` synchronously from an SSR `Preloaded` token (no loading flash), then attach the live subscription.
|
|
1218
|
+
*
|
|
1219
|
+
* Server-side preload helpers live in the socket-free `@lunora/vue/server`
|
|
1220
|
+
* entry (`createServerClient`, `preloadQuery`). Nuxt's single-worker
|
|
1221
|
+
* composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
|
|
1222
|
+
* package — see [Bring your framework](/docs/frameworks/bring-your-framework).
|
|
1223
|
+
*/
|
|
1224
|
+
useLunora, useMutation, useMutator, usePaginatedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
|