@lunora/solid 1.0.0-alpha.26 → 1.0.0-alpha.27
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/dist/index.d.mts +420 -431
- package/dist/index.d.ts +420 -431
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -4,37 +4,37 @@ import { Context, Accessor, JSX } from 'solid-js';
|
|
|
4
4
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
5
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
6
6
|
/**
|
|
7
|
-
* Solid context carrying the framework-neutral {@link LunoraClient}. Every
|
|
8
|
-
* reactive primitive in this adapter (`createQuery`, `createMutation`,
|
|
9
|
-
* `hydratePreloaded`) reads the client from here, so a single
|
|
10
|
-
* `<LunoraProvider client={…}>` at the root of the tree wires the whole app.
|
|
11
|
-
*
|
|
12
|
-
* Defaults to `undefined` so {@link useLunora} can throw a helpful error when a
|
|
13
|
-
* primitive is used outside a provider rather than dereferencing it.
|
|
14
|
-
*/
|
|
7
|
+
* Solid context carrying the framework-neutral {@link LunoraClient}. Every
|
|
8
|
+
* reactive primitive in this adapter (`createQuery`, `createMutation`,
|
|
9
|
+
* `hydratePreloaded`) reads the client from here, so a single
|
|
10
|
+
* `<LunoraProvider client={…}>` at the root of the tree wires the whole app.
|
|
11
|
+
*
|
|
12
|
+
* Defaults to `undefined` so {@link useLunora} can throw a helpful error when a
|
|
13
|
+
* primitive is used outside a provider rather than dereferencing it.
|
|
14
|
+
*/
|
|
15
15
|
declare const LunoraContext: Context<LunoraClient | undefined>;
|
|
16
16
|
/**
|
|
17
|
-
* Read the {@link LunoraClient} from the nearest `<LunoraProvider>`.
|
|
18
|
-
*
|
|
19
|
-
* Throws when called outside a provider — the client is required to open the
|
|
20
|
-
* HTTP/WS transport, so there is no sensible fallback. The React adapter's
|
|
21
|
-
* `useLunora` has the same contract.
|
|
22
|
-
*/
|
|
17
|
+
* Read the {@link LunoraClient} from the nearest `<LunoraProvider>`.
|
|
18
|
+
*
|
|
19
|
+
* Throws when called outside a provider — the client is required to open the
|
|
20
|
+
* HTTP/WS transport, so there is no sensible fallback. The React adapter's
|
|
21
|
+
* `useLunora` has the same contract.
|
|
22
|
+
*/
|
|
23
23
|
declare const useLunora: () => LunoraClient;
|
|
24
24
|
/**
|
|
25
|
-
* The lifecycle status stored on an agent thread. Client-safe mirror of
|
|
26
|
-
* `@lunora/agent`'s `AgentThreadStatus` — re-declared here (rather than imported)
|
|
27
|
-
* so this Solid entry never pulls in the server-only `@lunora/agent` module graph
|
|
28
|
-
* (the adapter stays Solid + `@lunora/client` only). Keep in sync with
|
|
29
|
-
* `packages/agent/src/types.ts`.
|
|
30
|
-
*/
|
|
25
|
+
* The lifecycle status stored on an agent thread. Client-safe mirror of
|
|
26
|
+
* `@lunora/agent`'s `AgentThreadStatus` — re-declared here (rather than imported)
|
|
27
|
+
* so this Solid entry never pulls in the server-only `@lunora/agent` module graph
|
|
28
|
+
* (the adapter stays Solid + `@lunora/client` only). Keep in sync with
|
|
29
|
+
* `packages/agent/src/types.ts`.
|
|
30
|
+
*/
|
|
31
31
|
type AgentThreadStatus = "awaiting_input" | "cancelled" | "error" | "idle" | "running";
|
|
32
32
|
/**
|
|
33
|
-
* The live thread record surfaced by the `agents:agentThread` query. A structural
|
|
34
|
-
* subset of the persisted thread row — every field beyond `status` is optional so
|
|
35
|
-
* the shape stays forgiving as the server schema grows. Keep in sync with the
|
|
36
|
-
* `agent_threads` table in `packages/agent/src/component.ts`.
|
|
37
|
-
*/
|
|
33
|
+
* The live thread record surfaced by the `agents:agentThread` query. A structural
|
|
34
|
+
* subset of the persisted thread row — every field beyond `status` is optional so
|
|
35
|
+
* the shape stays forgiving as the server schema grows. Keep in sync with the
|
|
36
|
+
* `agent_threads` table in `packages/agent/src/component.ts`.
|
|
37
|
+
*/
|
|
38
38
|
interface AgentThreadRecord {
|
|
39
39
|
createdAt?: number;
|
|
40
40
|
/** The failure message when `status === "error"`. */
|
|
@@ -51,11 +51,11 @@ interface AgentThreadRecord {
|
|
|
51
51
|
/** A plain value or a Solid accessor of it — matching `createQuery`'s reactive-args contract. */
|
|
52
52
|
type MaybeAccessor$1<T> = Accessor<T> | T;
|
|
53
53
|
/**
|
|
54
|
-
* The `agents.agentThread` reference the primitive subscribes to for live thread
|
|
55
|
-
* state (status + the in-flight `instanceId`). A structural subset of the
|
|
56
|
-
* generated `api.agents` surface, so the whole generated `api` object is
|
|
57
|
-
* assignable.
|
|
58
|
-
*/
|
|
54
|
+
* The `agents.agentThread` reference the primitive subscribes to for live thread
|
|
55
|
+
* state (status + the in-flight `instanceId`). A structural subset of the
|
|
56
|
+
* generated `api.agents` surface, so the whole generated `api` object is
|
|
57
|
+
* assignable.
|
|
58
|
+
*/
|
|
59
59
|
interface CreateAgentApi {
|
|
60
60
|
agents: {
|
|
61
61
|
agentThread: FunctionReference<"query", {
|
|
@@ -67,17 +67,17 @@ interface CreateAgentOptions {
|
|
|
67
67
|
/** The generated `api` — its `agents.agentThread` query drives live thread state. */
|
|
68
68
|
api: CreateAgentApi;
|
|
69
69
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
* Optional app mutation over the agent's cancel path
|
|
71
|
+
* (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
|
|
72
|
+
* When omitted (or no run is in flight) {@link CreateAgentResult.cancel} is a
|
|
73
|
+
* no-op.
|
|
74
|
+
*/
|
|
75
75
|
cancel?: FunctionReference<"mutation">;
|
|
76
76
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
78
|
+
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
79
|
+
* {@link CreateAgentOptions.runArgs} and the per-call args.
|
|
80
|
+
*/
|
|
81
81
|
run: FunctionReference<"mutation">;
|
|
82
82
|
/** Extra args merged into every `run` call (e.g. an `owner` or `title`). */
|
|
83
83
|
runArgs?: Record<string, unknown>;
|
|
@@ -86,9 +86,9 @@ interface CreateAgentOptions {
|
|
|
86
86
|
}
|
|
87
87
|
interface CreateAgentResult {
|
|
88
88
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
* Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
|
|
90
|
+
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
91
|
+
*/
|
|
92
92
|
cancel: () => Promise<void>;
|
|
93
93
|
/** `true` while a `run` invocation is in flight. */
|
|
94
94
|
pending: Accessor<boolean>;
|
|
@@ -100,39 +100,33 @@ interface CreateAgentResult {
|
|
|
100
100
|
thread: Accessor<AgentThreadRecord | undefined>;
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
|
-
* A
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
* `run` and `cancel` stay generic over the app-defined mutations that wrap
|
|
117
|
-
* `ctx.agents.<name>.run` / `.cancel`, so the primitive hard-codes no function
|
|
118
|
-
* names beyond the `agents:*` surface. `threadKey` may be an accessor — a changing
|
|
119
|
-
* key re-subscribes to the new thread.
|
|
120
|
-
*/
|
|
103
|
+
* A thin agent handle: live thread `status` plus `run` / `cancel`, without the
|
|
104
|
+
* chat message surface. Composes `createSubscription(api.agents.agentThread)` for
|
|
105
|
+
* live state and `createMutation` for the run/cancel writes — the Solid
|
|
106
|
+
* counterpart to React's `useAgent`, re-expressed with signals. For the full
|
|
107
|
+
* conversation surface (durable history + streaming + approvals) use
|
|
108
|
+
* `createAgentChat`.
|
|
109
|
+
*
|
|
110
|
+
* `run` and `cancel` stay generic over the app-defined mutations that wrap
|
|
111
|
+
* `ctx.agents.<name>.run` / `.cancel`, so the primitive hard-codes no function
|
|
112
|
+
* names beyond the `agents:*` surface. `threadKey` may be an accessor — a changing
|
|
113
|
+
* key re-subscribes to the new thread.
|
|
114
|
+
*/
|
|
121
115
|
declare const createAgent: (options: CreateAgentOptions) => CreateAgentResult;
|
|
122
116
|
/**
|
|
123
|
-
* One persisted (or optimistic) thread message, as `agents:agentMessages`
|
|
124
|
-
* surfaces it. Client-safe mirror of `@lunora/agent`'s `AgentMessageRow` —
|
|
125
|
-
* re-declared here (rather than imported) so this Solid entry never pulls in the
|
|
126
|
-
* server-only `@lunora/agent` module graph. Keep in sync with the
|
|
127
|
-
* `agent_messages` table in `packages/agent/src/component.ts`.
|
|
128
|
-
*/
|
|
117
|
+
* One persisted (or optimistic) thread message, as `agents:agentMessages`
|
|
118
|
+
* surfaces it. Client-safe mirror of `@lunora/agent`'s `AgentMessageRow` —
|
|
119
|
+
* re-declared here (rather than imported) so this Solid entry never pulls in the
|
|
120
|
+
* server-only `@lunora/agent` module graph. Keep in sync with the
|
|
121
|
+
* `agent_messages` table in `packages/agent/src/component.ts`.
|
|
122
|
+
*/
|
|
129
123
|
interface AgentChatMessage {
|
|
130
124
|
content: string;
|
|
131
125
|
createdAt?: number;
|
|
132
126
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
* `true` for a client-side optimistic user message not yet acknowledged by
|
|
128
|
+
* the server. Cleared once the durable history carries the matching user turn.
|
|
129
|
+
*/
|
|
136
130
|
optimistic?: boolean;
|
|
137
131
|
role: "assistant" | "system" | "tool" | "user";
|
|
138
132
|
seq: number;
|
|
@@ -147,11 +141,11 @@ interface AgentChatMessage {
|
|
|
147
141
|
toolName?: string;
|
|
148
142
|
}
|
|
149
143
|
/**
|
|
150
|
-
* A live token delta streamed while a turn is generating. Client-safe mirror of
|
|
151
|
-
* `@lunora/agent`'s `AgentTokenDelta`. Ephemeral — deltas feed
|
|
152
|
-
* {@link CreateAgentChatResult.streamingText} live and are never replayed; the
|
|
153
|
-
* persisted assistant message stays the single source of truth.
|
|
154
|
-
*/
|
|
144
|
+
* A live token delta streamed while a turn is generating. Client-safe mirror of
|
|
145
|
+
* `@lunora/agent`'s `AgentTokenDelta`. Ephemeral — deltas feed
|
|
146
|
+
* {@link CreateAgentChatResult.streamingText} live and are never replayed; the
|
|
147
|
+
* persisted assistant message stays the single source of truth.
|
|
148
|
+
*/
|
|
155
149
|
interface AgentTokenDelta {
|
|
156
150
|
/** Discriminates the token arm of {@link AgentLiveEvent}; unset on the wire (token is the default). */
|
|
157
151
|
kind?: "token";
|
|
@@ -163,10 +157,10 @@ interface AgentTokenDelta {
|
|
|
163
157
|
turn: number;
|
|
164
158
|
}
|
|
165
159
|
/**
|
|
166
|
-
* A live tool-progress event streamed via `ctx.reportProgress(...)`. Client-safe
|
|
167
|
-
* mirror of `@lunora/agent`'s `AgentProgressEvent`. Ephemeral and `toolCallId`-keyed;
|
|
168
|
-
* surfaced by `createAgentToolEvents`, ignored by {@link CreateAgentChatResult.streamingText}.
|
|
169
|
-
*/
|
|
160
|
+
* A live tool-progress event streamed via `ctx.reportProgress(...)`. Client-safe
|
|
161
|
+
* mirror of `@lunora/agent`'s `AgentProgressEvent`. Ephemeral and `toolCallId`-keyed;
|
|
162
|
+
* surfaced by `createAgentToolEvents`, ignored by {@link CreateAgentChatResult.streamingText}.
|
|
163
|
+
*/
|
|
170
164
|
interface AgentProgressEvent {
|
|
171
165
|
/** The arbitrary, JSON-serializable payload the tool reported. */
|
|
172
166
|
data: unknown;
|
|
@@ -178,11 +172,11 @@ interface AgentProgressEvent {
|
|
|
178
172
|
toolCallId: string;
|
|
179
173
|
}
|
|
180
174
|
/**
|
|
181
|
-
* A single event on the agent's live-only channel — a streamed token delta or a
|
|
182
|
-
* tool progress event. Client-safe mirror of `@lunora/agent`'s `AgentLiveEvent`.
|
|
183
|
-
* Discriminate on `kind` (`"progress"` for the progress arm; token deltas leave
|
|
184
|
-
* it unset).
|
|
185
|
-
*/
|
|
175
|
+
* A single event on the agent's live-only channel — a streamed token delta or a
|
|
176
|
+
* tool progress event. Client-safe mirror of `@lunora/agent`'s `AgentLiveEvent`.
|
|
177
|
+
* Discriminate on `kind` (`"progress"` for the progress arm; token deltas leave
|
|
178
|
+
* it unset).
|
|
179
|
+
*/
|
|
186
180
|
type AgentLiveEvent = AgentProgressEvent | AgentTokenDelta;
|
|
187
181
|
/** The `agents:agentMessages` reference — live durable thread history. */
|
|
188
182
|
type AgentMessagesReference$1 = FunctionReference<"query", {
|
|
@@ -204,18 +198,18 @@ type AgentThreadReference = FunctionReference<"query", {
|
|
|
204
198
|
key: string;
|
|
205
199
|
}, Record<string, unknown> | undefined>;
|
|
206
200
|
/**
|
|
207
|
-
* An app stream reference that tees the agent's in-flight live events, keyed by
|
|
208
|
-
* thread. Carries token deltas and — since `ctx.reportProgress` rides the same
|
|
209
|
-
* sink — tool progress events; this primitive consumes only the token arm.
|
|
210
|
-
*/
|
|
201
|
+
* An app stream reference that tees the agent's in-flight live events, keyed by
|
|
202
|
+
* thread. Carries token deltas and — since `ctx.reportProgress` rides the same
|
|
203
|
+
* sink — tool progress events; this primitive consumes only the token arm.
|
|
204
|
+
*/
|
|
211
205
|
type AgentTokenStreamReference = FunctionReference<"stream", {
|
|
212
206
|
key: string;
|
|
213
207
|
}, AgentLiveEvent>;
|
|
214
208
|
/**
|
|
215
|
-
* The `agents.*` reference surface the chat primitive reads. A structural subset
|
|
216
|
-
* of the generated `api.agents`, so the whole generated `api` object is
|
|
217
|
-
* assignable.
|
|
218
|
-
*/
|
|
209
|
+
* The `agents.*` reference surface the chat primitive reads. A structural subset
|
|
210
|
+
* of the generated `api.agents`, so the whole generated `api` object is
|
|
211
|
+
* assignable.
|
|
212
|
+
*/
|
|
219
213
|
interface CreateAgentChatApi {
|
|
220
214
|
agents: {
|
|
221
215
|
agentMessages: AgentMessagesReference$1;
|
|
@@ -227,27 +221,27 @@ interface CreateAgentChatOptions {
|
|
|
227
221
|
/** The generated `api` — its `agents.*` surface provides history, thread state, and approval resolution. */
|
|
228
222
|
api: CreateAgentChatApi;
|
|
229
223
|
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
224
|
+
* Optional app mutation over the agent's cancel path
|
|
225
|
+
* (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
|
|
226
|
+
* When omitted (or no run is in flight) {@link CreateAgentChatResult.cancel} is
|
|
227
|
+
* a no-op.
|
|
228
|
+
*/
|
|
235
229
|
cancel?: FunctionReference<"mutation">;
|
|
236
230
|
/** History depth forwarded to `agents:agentMessages`. */
|
|
237
231
|
limit?: number;
|
|
238
232
|
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
233
|
+
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
234
|
+
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
235
|
+
* {@link CreateAgentChatOptions.sendArgs} and the per-call args.
|
|
236
|
+
*/
|
|
243
237
|
send: FunctionReference<"mutation">;
|
|
244
238
|
/** Extra args merged into every `send` call (e.g. an `owner` or `title`). */
|
|
245
239
|
sendArgs?: Record<string, unknown>;
|
|
246
240
|
/**
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
241
|
+
* Optional live token-delta stream — an app stream function that tees the
|
|
242
|
+
* agent's in-flight deltas. When omitted {@link CreateAgentChatResult.streamingText}
|
|
243
|
+
* stays empty and the UI updates message-by-message from durable history.
|
|
244
|
+
*/
|
|
251
245
|
stream?: AgentTokenStreamReference;
|
|
252
246
|
/** The thread to observe and continue — a plain value or accessor (an accessor re-subscribes on change). */
|
|
253
247
|
threadKey: MaybeAccessor$1<string>;
|
|
@@ -256,9 +250,9 @@ interface CreateAgentChatResult {
|
|
|
256
250
|
/** Approve a paused human-in-the-loop tool call (optionally with a note). */
|
|
257
251
|
approve: (toolCallId: string, note?: string) => Promise<void>;
|
|
258
252
|
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
253
|
+
* Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
|
|
254
|
+
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
255
|
+
*/
|
|
262
256
|
cancel: () => Promise<void>;
|
|
263
257
|
/** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
|
|
264
258
|
messages: Accessor<ReadonlyArray<AgentChatMessage>>;
|
|
@@ -272,34 +266,34 @@ interface CreateAgentChatResult {
|
|
|
272
266
|
streamingText: Accessor<string>;
|
|
273
267
|
}
|
|
274
268
|
/**
|
|
275
|
-
* A first-class agent chat surface: live durable history + in-flight token
|
|
276
|
-
* streaming + the send / approve / reject / cancel writes, keyed by `threadKey` —
|
|
277
|
-
* the Solid counterpart to React's `useAgentChat`, re-expressed with signals.
|
|
278
|
-
*
|
|
279
|
-
* It composes the existing primitives rather than adding transport:
|
|
280
|
-
* `createSubscription(api.agents.agentMessages)` for durable history,
|
|
281
|
-
* `createSubscription(api.agents.agentThread)` for live status + the in-flight
|
|
282
|
-
* `instanceId`, {@link createStream} over an app token stream for in-flight deltas,
|
|
283
|
-
* and `createMutation` for the writes (`api.agents.agentResolveApproval` for
|
|
284
|
-
* approvals; app-defined wrappers for `send`/`cancel`). Only the `agents:*`
|
|
285
|
-
* surface is hard-coded — `send`/`cancel`/`stream` stay generic references.
|
|
286
|
-
*
|
|
287
|
-
* A `send` optimistically appends the user turn so it renders immediately; the
|
|
288
|
-
* optimistic row clears once the durable history carries the acknowledged turn.
|
|
289
|
-
* `streamingText` is live-only: it holds the current turn's streamed text and
|
|
290
|
-
* empties as soon as that turn's assistant message lands in `messages` (the
|
|
291
|
-
* persisted message is the source of truth), consistent with the loop's
|
|
292
|
-
* replay-safe, live-only delta design.
|
|
293
|
-
*/
|
|
269
|
+
* A first-class agent chat surface: live durable history + in-flight token
|
|
270
|
+
* streaming + the send / approve / reject / cancel writes, keyed by `threadKey` —
|
|
271
|
+
* the Solid counterpart to React's `useAgentChat`, re-expressed with signals.
|
|
272
|
+
*
|
|
273
|
+
* It composes the existing primitives rather than adding transport:
|
|
274
|
+
* `createSubscription(api.agents.agentMessages)` for durable history,
|
|
275
|
+
* `createSubscription(api.agents.agentThread)` for live status + the in-flight
|
|
276
|
+
* `instanceId`, {@link createStream} over an app token stream for in-flight deltas,
|
|
277
|
+
* and `createMutation` for the writes (`api.agents.agentResolveApproval` for
|
|
278
|
+
* approvals; app-defined wrappers for `send`/`cancel`). Only the `agents:*`
|
|
279
|
+
* surface is hard-coded — `send`/`cancel`/`stream` stay generic references.
|
|
280
|
+
*
|
|
281
|
+
* A `send` optimistically appends the user turn so it renders immediately; the
|
|
282
|
+
* optimistic row clears once the durable history carries the acknowledged turn.
|
|
283
|
+
* `streamingText` is live-only: it holds the current turn's streamed text and
|
|
284
|
+
* empties as soon as that turn's assistant message lands in `messages` (the
|
|
285
|
+
* persisted message is the source of truth), consistent with the loop's
|
|
286
|
+
* replay-safe, live-only delta design.
|
|
287
|
+
*/
|
|
294
288
|
declare const createAgentChat: (options: CreateAgentChatOptions) => CreateAgentChatResult;
|
|
295
289
|
/**
|
|
296
|
-
* The `agents.agentState` reference the primitive subscribes to for the thread's
|
|
297
|
-
* live synced state. A structural subset of the generated `api.agents` surface
|
|
298
|
-
* (like `CreateAgentApi` for `agentThread`), so the whole generated `api` object
|
|
299
|
-
* is assignable. Client-safe: no `@lunora/agent` import — the per-agent state type
|
|
300
|
-
* is mirrored by the primitive's generic `T`, since codegen pins the reference
|
|
301
|
-
* return as an optional record (it never evaluates agent config).
|
|
302
|
-
*/
|
|
290
|
+
* The `agents.agentState` reference the primitive subscribes to for the thread's
|
|
291
|
+
* live synced state. A structural subset of the generated `api.agents` surface
|
|
292
|
+
* (like `CreateAgentApi` for `agentThread`), so the whole generated `api` object
|
|
293
|
+
* is assignable. Client-safe: no `@lunora/agent` import — the per-agent state type
|
|
294
|
+
* is mirrored by the primitive's generic `T`, since codegen pins the reference
|
|
295
|
+
* return as an optional record (it never evaluates agent config).
|
|
296
|
+
*/
|
|
303
297
|
interface CreateAgentStateApi {
|
|
304
298
|
agents: {
|
|
305
299
|
agentState: FunctionReference<"query", {
|
|
@@ -320,20 +314,20 @@ interface CreateAgentStateResult<T> {
|
|
|
320
314
|
state: Accessor<T | undefined>;
|
|
321
315
|
}
|
|
322
316
|
/**
|
|
323
|
-
* Subscribe to an agent thread's synced state — the `setState`-style value a tool
|
|
324
|
-
* writes with `ctx.setState(...)`, seeded by `defineAgent({ initialState })`. A
|
|
325
|
-
* thin wrapper over `createSubscription(api.agents.agentState, { key })`: the
|
|
326
|
-
* server pushes a fresh frame whenever the state changes (the dedicated query's
|
|
327
|
-
* per-socket JSON memo suppresses no-op pushes on unrelated thread writes), so
|
|
328
|
-
* `state` updates only on a real `setState`. The Solid counterpart to React's
|
|
329
|
-
* `useAgentState`, re-expressed with signals.
|
|
330
|
-
*
|
|
331
|
-
* Generic over the app's state shape (`createAgentState` with a `SupportState`
|
|
332
|
-
* type argument, itself a record) — the reference is typed as an optional record
|
|
333
|
-
* because codegen cannot see the per-agent state type; the generic casts to `T`.
|
|
334
|
-
* The `extends` bound (not a bare unbounded type parameter) is required so the
|
|
335
|
-
* reference's optional-record return casts cleanly to `T`.
|
|
336
|
-
*/
|
|
317
|
+
* Subscribe to an agent thread's synced state — the `setState`-style value a tool
|
|
318
|
+
* writes with `ctx.setState(...)`, seeded by `defineAgent({ initialState })`. A
|
|
319
|
+
* thin wrapper over `createSubscription(api.agents.agentState, { key })`: the
|
|
320
|
+
* server pushes a fresh frame whenever the state changes (the dedicated query's
|
|
321
|
+
* per-socket JSON memo suppresses no-op pushes on unrelated thread writes), so
|
|
322
|
+
* `state` updates only on a real `setState`. The Solid counterpart to React's
|
|
323
|
+
* `useAgentState`, re-expressed with signals.
|
|
324
|
+
*
|
|
325
|
+
* Generic over the app's state shape (`createAgentState` with a `SupportState`
|
|
326
|
+
* type argument, itself a record) — the reference is typed as an optional record
|
|
327
|
+
* because codegen cannot see the per-agent state type; the generic casts to `T`.
|
|
328
|
+
* The `extends` bound (not a bare unbounded type parameter) is required so the
|
|
329
|
+
* reference's optional-record return casts cleanly to `T`.
|
|
330
|
+
*/
|
|
337
331
|
declare const createAgentState: <T extends Record<string, unknown> = Record<string, unknown>>(options: CreateAgentStateOptions) => CreateAgentStateResult<T>;
|
|
338
332
|
/** The `agents:agentMessages` reference — live durable thread history. */
|
|
339
333
|
type AgentMessagesReference = FunctionReference<"query", {
|
|
@@ -341,18 +335,18 @@ type AgentMessagesReference = FunctionReference<"query", {
|
|
|
341
335
|
limit?: number;
|
|
342
336
|
}, ReadonlyArray<Record<string, unknown>>>;
|
|
343
337
|
/**
|
|
344
|
-
* An app stream reference that tees the agent's in-flight live events, keyed by
|
|
345
|
-
* thread. Carries token deltas and tool progress events; this primitive consumes
|
|
346
|
-
* only the progress arm (`kind === "progress"`).
|
|
347
|
-
*/
|
|
338
|
+
* An app stream reference that tees the agent's in-flight live events, keyed by
|
|
339
|
+
* thread. Carries token deltas and tool progress events; this primitive consumes
|
|
340
|
+
* only the progress arm (`kind === "progress"`).
|
|
341
|
+
*/
|
|
348
342
|
type AgentLiveStreamReference = FunctionReference<"stream", {
|
|
349
343
|
key: string;
|
|
350
344
|
}, AgentLiveEvent>;
|
|
351
345
|
/**
|
|
352
|
-
* The `agents.*` reference surface the tool-events primitive reads. A structural
|
|
353
|
-
* subset of the generated `api.agents`, so the whole generated `api` object is
|
|
354
|
-
* assignable.
|
|
355
|
-
*/
|
|
346
|
+
* The `agents.*` reference surface the tool-events primitive reads. A structural
|
|
347
|
+
* subset of the generated `api.agents`, so the whole generated `api` object is
|
|
348
|
+
* assignable.
|
|
349
|
+
*/
|
|
356
350
|
interface CreateAgentToolEventsApi {
|
|
357
351
|
agents: {
|
|
358
352
|
agentMessages: AgentMessagesReference;
|
|
@@ -364,21 +358,21 @@ interface CreateAgentToolEventsOptions {
|
|
|
364
358
|
/** History depth forwarded to `agents:agentMessages`. */
|
|
365
359
|
limit?: number;
|
|
366
360
|
/**
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
361
|
+
* Optional live event stream — the same app stream function `createAgentChat`
|
|
362
|
+
* uses. When supplied, ephemeral `ctx.reportProgress(...)` events for the
|
|
363
|
+
* thread are surfaced as `{ type: "progress" }` entries; when omitted only the
|
|
364
|
+
* durable lifecycle (call / result / awaiting-approval) is returned.
|
|
365
|
+
*/
|
|
372
366
|
stream?: AgentLiveStreamReference;
|
|
373
367
|
/** The thread whose tool activity to observe — a plain value or accessor (an accessor re-subscribes on change). */
|
|
374
368
|
threadKey: MaybeAccessor$1<string>;
|
|
375
369
|
}
|
|
376
370
|
/**
|
|
377
|
-
* A single tool-lifecycle event for a thread. The durable arms
|
|
378
|
-
* (`call`/`result`/`awaiting-approval`) are derived from `agents:agentMessages`
|
|
379
|
-
* and carry the persisted `seq`; the ephemeral `progress` arm comes live off the
|
|
380
|
-
* stream and has no `seq`. Discriminate on `type`.
|
|
381
|
-
*/
|
|
371
|
+
* A single tool-lifecycle event for a thread. The durable arms
|
|
372
|
+
* (`call`/`result`/`awaiting-approval`) are derived from `agents:agentMessages`
|
|
373
|
+
* and carry the persisted `seq`; the ephemeral `progress` arm comes live off the
|
|
374
|
+
* stream and has no `seq`. Discriminate on `type`.
|
|
375
|
+
*/
|
|
382
376
|
type AgentToolEvent = {
|
|
383
377
|
data: unknown;
|
|
384
378
|
toolCallId: string;
|
|
@@ -404,26 +398,26 @@ type AgentToolEvent = {
|
|
|
404
398
|
};
|
|
405
399
|
interface CreateAgentToolEventsResult {
|
|
406
400
|
/**
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
401
|
+
* The thread's tool events: the durable lifecycle (oldest first, by `seq`)
|
|
402
|
+
* followed by any in-flight ephemeral progress events, recomputed from the live
|
|
403
|
+
* subscription + stream. Treat as derived, not identity-stable.
|
|
404
|
+
*/
|
|
411
405
|
events: Accessor<ReadonlyArray<AgentToolEvent>>;
|
|
412
406
|
}
|
|
413
407
|
/**
|
|
414
|
-
* A focused view of a thread's tool activity: tool calls, their results,
|
|
415
|
-
* human-in-the-loop approval pauses, and live `ctx.reportProgress(...)` events —
|
|
416
|
-
* without the full chat message surface. The Solid counterpart to React's
|
|
417
|
-
* `useAgentToolEvents`, re-expressed as a memo.
|
|
418
|
-
*
|
|
419
|
-
* It composes the existing primitives rather than adding transport:
|
|
420
|
-
* `createSubscription(api.agents.agentMessages)` for the durable lifecycle and
|
|
421
|
-
* {@link createStream} over the optional app event stream for ephemeral progress.
|
|
422
|
-
* Progress events are live-only (the durable path never emits them): they ride
|
|
423
|
-
* the same sink as token deltas and are surfaced here, correlated to their tool
|
|
424
|
-
* call by `toolCallId`. For the conversational surface (messages + streaming text
|
|
425
|
-
* + approvals) use `createAgentChat`; this primitive is the tool-observability slice.
|
|
426
|
-
*/
|
|
408
|
+
* A focused view of a thread's tool activity: tool calls, their results,
|
|
409
|
+
* human-in-the-loop approval pauses, and live `ctx.reportProgress(...)` events —
|
|
410
|
+
* without the full chat message surface. The Solid counterpart to React's
|
|
411
|
+
* `useAgentToolEvents`, re-expressed as a memo.
|
|
412
|
+
*
|
|
413
|
+
* It composes the existing primitives rather than adding transport:
|
|
414
|
+
* `createSubscription(api.agents.agentMessages)` for the durable lifecycle and
|
|
415
|
+
* {@link createStream} over the optional app event stream for ephemeral progress.
|
|
416
|
+
* Progress events are live-only (the durable path never emits them): they ride
|
|
417
|
+
* the same sink as token deltas and are surfaced here, correlated to their tool
|
|
418
|
+
* call by `toolCallId`. For the conversational surface (messages + streaming text
|
|
419
|
+
* + approvals) use `createAgentChat`; this primitive is the tool-observability slice.
|
|
420
|
+
*/
|
|
427
421
|
declare const createAgentToolEvents: (options: CreateAgentToolEventsOptions) => CreateAgentToolEventsResult;
|
|
428
422
|
interface UseAuthResult {
|
|
429
423
|
setToken: (token: string | null) => void;
|
|
@@ -431,40 +425,40 @@ interface UseAuthResult {
|
|
|
431
425
|
user: Accessor<User | null>;
|
|
432
426
|
}
|
|
433
427
|
/**
|
|
434
|
-
* Token + identity plumbing for Solid. Returns `{ token, user, setToken }`
|
|
435
|
-
* where `token` and `user` are fine-grained signals. `setToken(jwt)` after
|
|
436
|
-
* sign-in updates the shared client token; `user` resolves asynchronously via
|
|
437
|
-
* `client.getCurrentUser()` and updates on every token change.
|
|
438
|
-
*/
|
|
428
|
+
* Token + identity plumbing for Solid. Returns `{ token, user, setToken }`
|
|
429
|
+
* where `token` and `user` are fine-grained signals. `setToken(jwt)` after
|
|
430
|
+
* sign-in updates the shared client token; `user` resolves asynchronously via
|
|
431
|
+
* `client.getCurrentUser()` and updates on every token change.
|
|
432
|
+
*/
|
|
439
433
|
declare const createAuth: () => UseAuthResult;
|
|
440
434
|
interface AuthGateProps {
|
|
441
435
|
children: JSX.Element;
|
|
442
436
|
}
|
|
443
437
|
/**
|
|
444
|
-
* Render `children` only after authentication has settled and a token + user
|
|
445
|
-
* are both present.
|
|
446
|
-
*/
|
|
438
|
+
* Render `children` only after authentication has settled and a token + user
|
|
439
|
+
* are both present.
|
|
440
|
+
*/
|
|
447
441
|
declare const Authenticated: (props: AuthGateProps) => JSX.Element;
|
|
448
442
|
/**
|
|
449
|
-
* Render `children` while authentication is still in progress — token is set
|
|
450
|
-
* but the user has not yet resolved.
|
|
451
|
-
*/
|
|
443
|
+
* Render `children` while authentication is still in progress — token is set
|
|
444
|
+
* but the user has not yet resolved.
|
|
445
|
+
*/
|
|
452
446
|
declare const AuthLoading: (props: AuthGateProps) => JSX.Element;
|
|
453
447
|
/**
|
|
454
|
-
* Render `children` only when auth has settled and no token is present (the
|
|
455
|
-
* signed-out state).
|
|
456
|
-
*/
|
|
448
|
+
* Render `children` only when auth has settled and no token is present (the
|
|
449
|
+
* signed-out state).
|
|
450
|
+
*/
|
|
457
451
|
declare const Unauthenticated: (props: AuthGateProps) => JSX.Element;
|
|
458
452
|
/**
|
|
459
|
-
* Reactive accessor of the client's aggregate live-socket status across all
|
|
460
|
-
* shard connections. Reads the current status synchronously and updates on
|
|
461
|
-
* every transition (`idle` → `connecting` → `connected` → `offline`) — Solid's
|
|
462
|
-
* fine-grained signals mean only the components that read the accessor
|
|
463
|
-
* re-render. The Solid equivalent of `@lunora/react`'s `useConnectionStatus`.
|
|
464
|
-
*
|
|
465
|
-
* The status listener is torn down via `onCleanup` when the owning reactive
|
|
466
|
-
* scope disposes (component unmount). Call inside a component / reactive root.
|
|
467
|
-
*/
|
|
453
|
+
* Reactive accessor of the client's aggregate live-socket status across all
|
|
454
|
+
* shard connections. Reads the current status synchronously and updates on
|
|
455
|
+
* every transition (`idle` → `connecting` → `connected` → `offline`) — Solid's
|
|
456
|
+
* fine-grained signals mean only the components that read the accessor
|
|
457
|
+
* re-render. The Solid equivalent of `@lunora/react`'s `useConnectionStatus`.
|
|
458
|
+
*
|
|
459
|
+
* The status listener is torn down via `onCleanup` when the owning reactive
|
|
460
|
+
* scope disposes (component unmount). Call inside a component / reactive root.
|
|
461
|
+
*/
|
|
468
462
|
declare const createConnectionStatus: () => Accessor<ConnectionStatus>;
|
|
469
463
|
/** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
|
|
470
464
|
type FlagContext = Record<string, unknown>;
|
|
@@ -475,33 +469,33 @@ type FlagValue = boolean | number | string | {
|
|
|
475
469
|
/** A plain value or a Solid accessor of it — matching `createQuery`'s reactive-args contract. */
|
|
476
470
|
type MaybeAccessor<T> = Accessor<T> | T;
|
|
477
471
|
/**
|
|
478
|
-
* Subscribe to a single feature flag and return a reactive accessor of its value.
|
|
479
|
-
*
|
|
480
|
-
* The accessor reads `defaultValue` until the first evaluation lands, then the
|
|
481
|
-
* server's resolved value — re-pushed whenever the provider re-evaluates (e.g. a
|
|
482
|
-
* flag is toggled in Cloudflare Flagship). The flag's kind is inferred from
|
|
483
|
-
* `defaultValue`'s runtime type, so `createFlag("dark", false)` reads a boolean
|
|
484
|
-
* and `createFlag("hero", "control")` a string.
|
|
485
|
-
*
|
|
486
|
-
* `key` and `context` may be plain values or accessors; passing an accessor makes
|
|
487
|
-
* the subscription reactive — when it changes the old subscription is torn down
|
|
488
|
-
* (via `onCleanup`) and a fresh one opens. `context` supplies a per-call targeting
|
|
489
|
-
* context merged on top of the app's default `identify` targeting key.
|
|
490
|
-
*
|
|
491
|
-
* Evaluation runs through whatever OpenFeature provider the app wired in
|
|
492
|
-
* `lunora/flags.ts`; the read never throws — a provider error resolves the
|
|
493
|
-
* default (the same fail-open contract as server-side `ctx.flags`).
|
|
494
|
-
*/
|
|
472
|
+
* Subscribe to a single feature flag and return a reactive accessor of its value.
|
|
473
|
+
*
|
|
474
|
+
* The accessor reads `defaultValue` until the first evaluation lands, then the
|
|
475
|
+
* server's resolved value — re-pushed whenever the provider re-evaluates (e.g. a
|
|
476
|
+
* flag is toggled in Cloudflare Flagship). The flag's kind is inferred from
|
|
477
|
+
* `defaultValue`'s runtime type, so `createFlag("dark", false)` reads a boolean
|
|
478
|
+
* and `createFlag("hero", "control")` a string.
|
|
479
|
+
*
|
|
480
|
+
* `key` and `context` may be plain values or accessors; passing an accessor makes
|
|
481
|
+
* the subscription reactive — when it changes the old subscription is torn down
|
|
482
|
+
* (via `onCleanup`) and a fresh one opens. `context` supplies a per-call targeting
|
|
483
|
+
* context merged on top of the app's default `identify` targeting key.
|
|
484
|
+
*
|
|
485
|
+
* Evaluation runs through whatever OpenFeature provider the app wired in
|
|
486
|
+
* `lunora/flags.ts`; the read never throws — a provider error resolves the
|
|
487
|
+
* default (the same fail-open contract as server-side `ctx.flags`).
|
|
488
|
+
*/
|
|
495
489
|
declare const createFlag: <T extends FlagValue>(key: MaybeAccessor<string>, defaultValue: T, context?: MaybeAccessor<FlagContext | undefined>) => Accessor<T>;
|
|
496
490
|
/**
|
|
497
|
-
* Subscribe to several feature flags at once and return a reactive accessor of
|
|
498
|
-
* the resolved record.
|
|
499
|
-
*
|
|
500
|
-
* Pass a record of `key → defaultValue`; each flag's kind is inferred from its
|
|
501
|
-
* default, and the accessor reads the same-shaped record with resolved values
|
|
502
|
-
* (the defaults until each evaluation lands). A single `context` applies to every
|
|
503
|
-
* flag and may be an accessor. This is the batched form of {@link createFlag}.
|
|
504
|
-
*/
|
|
491
|
+
* Subscribe to several feature flags at once and return a reactive accessor of
|
|
492
|
+
* the resolved record.
|
|
493
|
+
*
|
|
494
|
+
* Pass a record of `key → defaultValue`; each flag's kind is inferred from its
|
|
495
|
+
* default, and the accessor reads the same-shaped record with resolved values
|
|
496
|
+
* (the defaults until each evaluation lands). A single `context` applies to every
|
|
497
|
+
* flag and may be an accessor. This is the batched form of {@link createFlag}.
|
|
498
|
+
*/
|
|
505
499
|
declare const createFlags: <T extends Record<string, FlagValue>>(flags: T, context?: MaybeAccessor<FlagContext | undefined>) => Accessor<T>;
|
|
506
500
|
interface MutationHandle<F extends FunctionReference> {
|
|
507
501
|
/** The latest invocation's resolved value, or `undefined` before the first success. */
|
|
@@ -516,44 +510,44 @@ interface MutationHandle<F extends FunctionReference> {
|
|
|
516
510
|
reset: () => void;
|
|
517
511
|
}
|
|
518
512
|
/**
|
|
519
|
-
* The transport surface {@link createMutation} actually needs — just
|
|
520
|
-
* `client.mutation`. Narrowed so the primitive can be exercised against a stub
|
|
521
|
-
* in tests without constructing a full `LunoraClient`.
|
|
522
|
-
*/
|
|
513
|
+
* The transport surface {@link createMutation} actually needs — just
|
|
514
|
+
* `client.mutation`. Narrowed so the primitive can be exercised against a stub
|
|
515
|
+
* in tests without constructing a full `LunoraClient`.
|
|
516
|
+
*/
|
|
523
517
|
interface MutationClient<F extends FunctionReference> {
|
|
524
518
|
mutation: (function_: F, args: ArgsOf<F>, options?: MutationCallOptions<unknown, unknown, ArgsOf<F>>) => Promise<ReturnOf<F>>;
|
|
525
519
|
}
|
|
526
520
|
/**
|
|
527
|
-
* Build a mutation handle bound to an explicit client. Internal seam used by the
|
|
528
|
-
* provider-bound {@link createMutation}; exported for tests that inject a stub.
|
|
529
|
-
* The ref-counted pending + error-normalize orchestration is the shared
|
|
530
|
-
* `createMutationRunner` from `@lunora/client`; only the reactive sinks (Solid
|
|
531
|
-
* signals) are adapter-specific.
|
|
532
|
-
*/
|
|
521
|
+
* Build a mutation handle bound to an explicit client. Internal seam used by the
|
|
522
|
+
* provider-bound {@link createMutation}; exported for tests that inject a stub.
|
|
523
|
+
* The ref-counted pending + error-normalize orchestration is the shared
|
|
524
|
+
* `createMutationRunner` from `@lunora/client`; only the reactive sinks (Solid
|
|
525
|
+
* signals) are adapter-specific.
|
|
526
|
+
*/
|
|
533
527
|
declare const createMutationForClient: <F extends FunctionReference>(client: MutationClient<F>, function_: F) => MutationHandle<F>;
|
|
534
528
|
/**
|
|
535
|
-
* Returns a reactive handle `{ mutate, pending, data, error, reset }` for the
|
|
536
|
-
* given mutation reference, bound to the `LunoraClient` from the nearest
|
|
537
|
-
* `<LunoraProvider>`.
|
|
538
|
-
*
|
|
539
|
-
* Optimistic updates stay client-owned: the `optimistic` / `optimisticUpdate`
|
|
540
|
-
* call options pass straight through to `client.mutation`, which applies and
|
|
541
|
-
* rolls them back against the live Lunora subscription cache — the same
|
|
542
|
-
* machinery `createQuery`/`hydratePreloaded` subscribe to, so an optimistic
|
|
543
|
-
* write reflects in those accessors immediately and reverts on failure.
|
|
544
|
-
*
|
|
545
|
-
* `pending` is ref-counted across overlapping invocations of *this* handle, so
|
|
546
|
-
* it only flips back to `false` once every concurrent call has settled. The
|
|
547
|
-
* mutation also engages `@lunora/client`'s offline queue when the socket is
|
|
548
|
-
* down, so `mutate` stays durable across reconnects.
|
|
549
|
-
*/
|
|
529
|
+
* Returns a reactive handle `{ mutate, pending, data, error, reset }` for the
|
|
530
|
+
* given mutation reference, bound to the `LunoraClient` from the nearest
|
|
531
|
+
* `<LunoraProvider>`.
|
|
532
|
+
*
|
|
533
|
+
* Optimistic updates stay client-owned: the `optimistic` / `optimisticUpdate`
|
|
534
|
+
* call options pass straight through to `client.mutation`, which applies and
|
|
535
|
+
* rolls them back against the live Lunora subscription cache — the same
|
|
536
|
+
* machinery `createQuery`/`hydratePreloaded` subscribe to, so an optimistic
|
|
537
|
+
* write reflects in those accessors immediately and reverts on failure.
|
|
538
|
+
*
|
|
539
|
+
* `pending` is ref-counted across overlapping invocations of *this* handle, so
|
|
540
|
+
* it only flips back to `false` once every concurrent call has settled. The
|
|
541
|
+
* mutation also engages `@lunora/client`'s offline queue when the socket is
|
|
542
|
+
* down, so `mutate` stays durable across reconnects.
|
|
543
|
+
*/
|
|
550
544
|
declare const createMutation: <F extends FunctionReference>(function_: F) => MutationHandle<F>;
|
|
551
545
|
/**
|
|
552
|
-
* The reactive handle returned by {@link createMutator} — the Solid counterpart
|
|
553
|
-
* to `@lunora/react`'s `useMutator`, re-expressed with signals.
|
|
554
|
-
* `error`/`isError`/`pending` are accessors and `mutate` is an awaitable that
|
|
555
|
-
* resolves once the write is persisted (or rejects).
|
|
556
|
-
*/
|
|
546
|
+
* The reactive handle returned by {@link createMutator} — the Solid counterpart
|
|
547
|
+
* to `@lunora/react`'s `useMutator`, re-expressed with signals.
|
|
548
|
+
* `error`/`isError`/`pending` are accessors and `mutate` is an awaitable that
|
|
549
|
+
* resolves once the write is persisted (or rejects).
|
|
550
|
+
*/
|
|
557
551
|
interface MutatorHook<TArgs> {
|
|
558
552
|
/** The latest invocation's error, or `undefined`. */
|
|
559
553
|
error: Accessor<Error | undefined>;
|
|
@@ -567,18 +561,18 @@ interface MutatorHook<TArgs> {
|
|
|
567
561
|
reset: () => void;
|
|
568
562
|
}
|
|
569
563
|
/**
|
|
570
|
-
* Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
|
|
571
|
-
* custom-mutator handle from `@lunora/db`'s `bindMutators` — the Solid
|
|
572
|
-
* equivalent of `@lunora/react`'s `useMutator`. The optimistic overlay and
|
|
573
|
-
* server-authoritative push are owned by the bound handle (and TanStack DB's
|
|
574
|
-
* optimistic-transaction layer rebases pending overlays on every sync tick);
|
|
575
|
-
* this primitive only surfaces signal state for the in-flight/error lifecycle.
|
|
576
|
-
* Reads stay on the existing TanStack `useLiveQuery`; no new query primitive is
|
|
577
|
-
* needed.
|
|
578
|
-
*
|
|
579
|
-
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
580
|
-
* clears only once every concurrent call has settled.
|
|
581
|
-
*/
|
|
564
|
+
* Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
|
|
565
|
+
* custom-mutator handle from `@lunora/db`'s `bindMutators` — the Solid
|
|
566
|
+
* equivalent of `@lunora/react`'s `useMutator`. The optimistic overlay and
|
|
567
|
+
* server-authoritative push are owned by the bound handle (and TanStack DB's
|
|
568
|
+
* optimistic-transaction layer rebases pending overlays on every sync tick);
|
|
569
|
+
* this primitive only surfaces signal state for the in-flight/error lifecycle.
|
|
570
|
+
* Reads stay on the existing TanStack `useLiveQuery`; no new query primitive is
|
|
571
|
+
* needed.
|
|
572
|
+
*
|
|
573
|
+
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
574
|
+
* clears only once every concurrent call has settled.
|
|
575
|
+
*/
|
|
582
576
|
declare const createMutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHook<TArgs>;
|
|
583
577
|
/** The args a paginated query exposes minus the framework-supplied page cursor. */
|
|
584
578
|
type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
|
|
@@ -619,46 +613,46 @@ interface CreateInfiniteQueryResult<T> {
|
|
|
619
613
|
status: Accessor<PaginationStatus>;
|
|
620
614
|
}
|
|
621
615
|
/**
|
|
622
|
-
* Subscribe to a reactively-paginated query and grow the feed page by page.
|
|
623
|
-
*
|
|
624
|
-
* The query function must accept a `paginationOpts: { numItems, cursor,
|
|
625
|
-
* endCursor }` arg and return a `PaginationResult`. `loadMore` appends the next
|
|
626
|
-
* page off the open-ended tail's `continueCursor`; it is a no-op unless
|
|
627
|
-
* `status === "CanLoadMore"`.
|
|
628
|
-
*
|
|
629
|
-
* Call inside a reactive context (component / `createRoot`).
|
|
630
|
-
*/
|
|
616
|
+
* Subscribe to a reactively-paginated query and grow the feed page by page.
|
|
617
|
+
*
|
|
618
|
+
* The query function must accept a `paginationOpts: { numItems, cursor,
|
|
619
|
+
* endCursor }` arg and return a `PaginationResult`. `loadMore` appends the next
|
|
620
|
+
* page off the open-ended tail's `continueCursor`; it is a no-op unless
|
|
621
|
+
* `status === "CanLoadMore"`.
|
|
622
|
+
*
|
|
623
|
+
* Call inside a reactive context (component / `createRoot`).
|
|
624
|
+
*/
|
|
631
625
|
declare const createPaginatedQuery: <F extends FunctionReference>(function_: F, args: "skip" | Accessor<"skip" | PaginatedArgs<F>> | PaginatedArgs<F>, options: CreatePaginatedQueryOptions) => CreatePaginatedQueryResult<PageItemOf<F>>;
|
|
632
626
|
/**
|
|
633
|
-
* Subscribe to a reactively-paginated query and expose its pages discretely.
|
|
634
|
-
*
|
|
635
|
-
* Shares `createPaginatedQuery`'s pagination engine but keeps each page as its
|
|
636
|
-
* own inner array (TanStack-Query-style `fetchNextPage` / `hasNextPage` shape).
|
|
637
|
-
*
|
|
638
|
-
* Call inside a reactive context (component / `createRoot`).
|
|
639
|
-
*/
|
|
627
|
+
* Subscribe to a reactively-paginated query and expose its pages discretely.
|
|
628
|
+
*
|
|
629
|
+
* Shares `createPaginatedQuery`'s pagination engine but keeps each page as its
|
|
630
|
+
* own inner array (TanStack-Query-style `fetchNextPage` / `hasNextPage` shape).
|
|
631
|
+
*
|
|
632
|
+
* Call inside a reactive context (component / `createRoot`).
|
|
633
|
+
*/
|
|
640
634
|
declare const createInfiniteQuery: <F extends FunctionReference>(function_: F, args: "skip" | Accessor<"skip" | PaginatedArgs<F>> | PaginatedArgs<F>, options: CreateInfiniteQueryOptions) => CreateInfiniteQueryResult<PageItemOf<F>>;
|
|
641
635
|
/**
|
|
642
|
-
* `createPresence` — collaborative-awareness primitive, the client half of the
|
|
643
|
-
* `@lunora/server` `definePresence` preset.
|
|
644
|
-
*
|
|
645
|
-
* Drives the heartbeat mutation (on mount, interval, and tab re-focus) and
|
|
646
|
-
* subscribes to the live `listPresent` query for the given room.
|
|
647
|
-
*
|
|
648
|
-
* Call inside a reactive context (component / `createRoot`).
|
|
649
|
-
*/
|
|
650
|
-
/**
|
|
651
|
-
* A heartbeat mutation reference: takes `{ roomId, sessionId, data? }`.
|
|
652
|
-
*/
|
|
636
|
+
* `createPresence` — collaborative-awareness primitive, the client half of the
|
|
637
|
+
* `@lunora/server` `definePresence` preset.
|
|
638
|
+
*
|
|
639
|
+
* Drives the heartbeat mutation (on mount, interval, and tab re-focus) and
|
|
640
|
+
* subscribes to the live `listPresent` query for the given room.
|
|
641
|
+
*
|
|
642
|
+
* Call inside a reactive context (component / `createRoot`).
|
|
643
|
+
*/
|
|
644
|
+
/**
|
|
645
|
+
* A heartbeat mutation reference: takes `{ roomId, sessionId, data? }`.
|
|
646
|
+
*/
|
|
653
647
|
type HeartbeatReference = FunctionReference<"mutation", {
|
|
654
648
|
data?: Record<string, unknown>;
|
|
655
649
|
roomId: string;
|
|
656
650
|
sessionId: string;
|
|
657
651
|
}>;
|
|
658
652
|
/**
|
|
659
|
-
* A listPresent query reference: takes `{ roomId }` and returns the array of
|
|
660
|
-
* present members.
|
|
661
|
-
*/
|
|
653
|
+
* A listPresent query reference: takes `{ roomId }` and returns the array of
|
|
654
|
+
* present members.
|
|
655
|
+
*/
|
|
662
656
|
type ListPresentReference = FunctionReference<"query", {
|
|
663
657
|
roomId: string;
|
|
664
658
|
}>;
|
|
@@ -672,9 +666,9 @@ interface CreatePresenceOptions<H extends HeartbeatReference, L extends ListPres
|
|
|
672
666
|
/** The `api.*` reference for the presence listPresent query. */
|
|
673
667
|
listPresent: L;
|
|
674
668
|
/**
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
669
|
+
* Stable id for this presence row. Defaults to a fresh per-mount id.
|
|
670
|
+
* Pass a user/connection id to control deduping across tabs.
|
|
671
|
+
*/
|
|
678
672
|
sessionId?: string;
|
|
679
673
|
/** Forwarded to the heartbeat mutation / listPresent subscription when sharding by room. */
|
|
680
674
|
shardKey?: string;
|
|
@@ -693,31 +687,31 @@ interface CreateQueryOptions {
|
|
|
693
687
|
shardKey?: string;
|
|
694
688
|
}
|
|
695
689
|
/**
|
|
696
|
-
* Subscribe to a server query and return a reactive accessor of its value.
|
|
697
|
-
*
|
|
698
|
-
* The accessor reads `undefined` until the first server frame lands, then
|
|
699
|
-
* updates on every delta the WebSocket pushes — Solid's fine-grained signals
|
|
700
|
-
* mean only the components that read the accessor re-render, which maps cleanly
|
|
701
|
-
* onto Lunora's per-subscription delta model.
|
|
702
|
-
*
|
|
703
|
-
* `args` may be a plain value or an accessor; passing an accessor makes the
|
|
704
|
-
* subscription reactive — when the args change the old subscription is torn down
|
|
705
|
-
* (via `onCleanup`) and a fresh one opens for the new args. Pass `"skip"` (or an
|
|
706
|
-
* accessor returning `"skip"`) to short-circuit: no network call, no socket.
|
|
707
|
-
*
|
|
708
|
-
* ```tsx
|
|
709
|
-
* const messages = createQuery(api.messages.list, () => ({ channelId: channelId() }));
|
|
710
|
-
* return <For each={messages()?.messages}>{(m) => <li>{m.text}</li>}</For>;
|
|
711
|
-
* ```
|
|
712
|
-
*/
|
|
690
|
+
* Subscribe to a server query and return a reactive accessor of its value.
|
|
691
|
+
*
|
|
692
|
+
* The accessor reads `undefined` until the first server frame lands, then
|
|
693
|
+
* updates on every delta the WebSocket pushes — Solid's fine-grained signals
|
|
694
|
+
* mean only the components that read the accessor re-render, which maps cleanly
|
|
695
|
+
* onto Lunora's per-subscription delta model.
|
|
696
|
+
*
|
|
697
|
+
* `args` may be a plain value or an accessor; passing an accessor makes the
|
|
698
|
+
* subscription reactive — when the args change the old subscription is torn down
|
|
699
|
+
* (via `onCleanup`) and a fresh one opens for the new args. Pass `"skip"` (or an
|
|
700
|
+
* accessor returning `"skip"`) to short-circuit: no network call, no socket.
|
|
701
|
+
*
|
|
702
|
+
* ```tsx
|
|
703
|
+
* const messages = createQuery(api.messages.list, () => ({ channelId: channelId() }));
|
|
704
|
+
* return <For each={messages()?.messages}>{(m) => <li>{m.text}</li>}</For>;
|
|
705
|
+
* ```
|
|
706
|
+
*/
|
|
713
707
|
declare const createQuery: <F extends FunctionReference>(function_: F, args: (ArgsOf<F> | "skip") | Accessor<ArgsOf<F> | "skip">, options?: CreateQueryOptions) => Accessor<ReturnOf<F> | undefined>;
|
|
714
708
|
interface CreateRateLimitOptions {
|
|
715
709
|
/** Clock injection for tests. Defaults to `Date.now`. */
|
|
716
710
|
now?: () => number;
|
|
717
711
|
/**
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
712
|
+
* Re-evaluation cadence in milliseconds while throttled, so `retryAfter`
|
|
713
|
+
* ticks down and `disabled` flips back automatically. Defaults to `1000`.
|
|
714
|
+
*/
|
|
721
715
|
tickMs?: number;
|
|
722
716
|
}
|
|
723
717
|
interface CreateRateLimitResult {
|
|
@@ -735,14 +729,14 @@ interface CreateRateLimitResult {
|
|
|
735
729
|
retryAfter: () => number;
|
|
736
730
|
}
|
|
737
731
|
/**
|
|
738
|
-
* Client-side mirror of a rate limit for instant UX — disable a button or show
|
|
739
|
-
* a countdown without a round-trip. It runs the same token-bucket / fixed-window
|
|
740
|
-
* math as `@lunora/ratelimit` on the server, so the prediction agrees with the
|
|
741
|
-
* authoritative check; the server remains the source of truth.
|
|
742
|
-
*
|
|
743
|
-
* `config` is read on every call; pass a stable reference (module constant) so
|
|
744
|
-
* the derived memos stay settled.
|
|
745
|
-
*/
|
|
732
|
+
* Client-side mirror of a rate limit for instant UX — disable a button or show
|
|
733
|
+
* a countdown without a round-trip. It runs the same token-bucket / fixed-window
|
|
734
|
+
* math as `@lunora/ratelimit` on the server, so the prediction agrees with the
|
|
735
|
+
* authoritative check; the server remains the source of truth.
|
|
736
|
+
*
|
|
737
|
+
* `config` is read on every call; pass a stable reference (module constant) so
|
|
738
|
+
* the derived memos stay settled.
|
|
739
|
+
*/
|
|
746
740
|
declare const createRateLimit: (config: RateLimitConfig, options?: CreateRateLimitOptions) => CreateRateLimitResult;
|
|
747
741
|
/** The lifecycle of a stream the primitive is observing. */
|
|
748
742
|
type CreateStreamStatus = "complete" | "error" | "idle" | "streaming";
|
|
@@ -760,42 +754,42 @@ interface CreateStreamOptions {
|
|
|
760
754
|
shardKey?: string;
|
|
761
755
|
}
|
|
762
756
|
/**
|
|
763
|
-
* Subscribe to a streaming query. Returns the chunks pushed so far plus a
|
|
764
|
-
* lifecycle status and a cancel function, all as accessors. Changing the
|
|
765
|
-
* resolved `args` resets the stream — the previous iterator is cancelled and a
|
|
766
|
-
* fresh one opens with empty `chunks`.
|
|
767
|
-
*
|
|
768
|
-
* `args` may be a plain value or an accessor; resolving it to `"skip"` keeps the
|
|
769
|
-
* primitive mounted without opening a stream (mirrors `createSubscription`). The
|
|
770
|
-
* Solid counterpart to React's `useStream`, re-expressed with signals.
|
|
771
|
-
*/
|
|
757
|
+
* Subscribe to a streaming query. Returns the chunks pushed so far plus a
|
|
758
|
+
* lifecycle status and a cancel function, all as accessors. Changing the
|
|
759
|
+
* resolved `args` resets the stream — the previous iterator is cancelled and a
|
|
760
|
+
* fresh one opens with empty `chunks`.
|
|
761
|
+
*
|
|
762
|
+
* `args` may be a plain value or an accessor; resolving it to `"skip"` keeps the
|
|
763
|
+
* primitive mounted without opening a stream (mirrors `createSubscription`). The
|
|
764
|
+
* Solid counterpart to React's `useStream`, re-expressed with signals.
|
|
765
|
+
*/
|
|
772
766
|
declare const createStream: <F extends FunctionReference<"stream">>(function_: F, args: ArgsOf<F> | "skip" | Accessor<ArgsOf<F> | "skip">, options?: CreateStreamOptions) => CreateStreamResult<ReturnOf<F>>;
|
|
773
767
|
interface CreateSubscriptionResult<T> {
|
|
774
768
|
data: Accessor<T | undefined>;
|
|
775
769
|
error: Accessor<Error | undefined>;
|
|
776
770
|
}
|
|
777
771
|
/**
|
|
778
|
-
* Subscribe to a reactive server push stream. Returns `{ data, error }`
|
|
779
|
-
* accessors that update whenever the server emits. Passing `"skip"` as `args`
|
|
780
|
-
* (or an accessor that resolves to `"skip"`) tears down the subscription.
|
|
781
|
-
*/
|
|
772
|
+
* Subscribe to a reactive server push stream. Returns `{ data, error }`
|
|
773
|
+
* accessors that update whenever the server emits. Passing `"skip"` as `args`
|
|
774
|
+
* (or an accessor that resolves to `"skip"`) tears down the subscription.
|
|
775
|
+
*/
|
|
782
776
|
declare const createSubscription: <F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip" | Accessor<ArgsOf<F> | "skip">, options?: {
|
|
783
777
|
shardKey?: string;
|
|
784
778
|
}) => CreateSubscriptionResult<ReturnOf<F>>;
|
|
785
779
|
/**
|
|
786
|
-
* Browser Web Audio subsystems for `createVoiceAgent` — the default microphone
|
|
787
|
-
* capture and speaker playback implementations injected into the primitive via
|
|
788
|
-
* its `createMicrophone` / `createSpeaker` seams. Kept in a sibling module so the
|
|
789
|
-
* heavy Web Audio graph (and its structural DOM typings) stays isolated from the
|
|
790
|
-
* primitive's transport + reactive-state logic and remains mockable in a
|
|
791
|
-
* non-browser test env.
|
|
792
|
-
*/
|
|
793
|
-
/**
|
|
794
|
-
* The negotiated audio format the voice DO streams back. Mirrors
|
|
795
|
-
* `@lunora/agent`'s `VoiceServerFrame` `ready.audioFormat` — re-declared (not
|
|
796
|
-
* imported) so this Solid package never pulls in the server-only `@lunora/agent`
|
|
797
|
-
* module graph.
|
|
798
|
-
*/
|
|
780
|
+
* Browser Web Audio subsystems for `createVoiceAgent` — the default microphone
|
|
781
|
+
* capture and speaker playback implementations injected into the primitive via
|
|
782
|
+
* its `createMicrophone` / `createSpeaker` seams. Kept in a sibling module so the
|
|
783
|
+
* heavy Web Audio graph (and its structural DOM typings) stays isolated from the
|
|
784
|
+
* primitive's transport + reactive-state logic and remains mockable in a
|
|
785
|
+
* non-browser test env.
|
|
786
|
+
*/
|
|
787
|
+
/**
|
|
788
|
+
* The negotiated audio format the voice DO streams back. Mirrors
|
|
789
|
+
* `@lunora/agent`'s `VoiceServerFrame` `ready.audioFormat` — re-declared (not
|
|
790
|
+
* imported) so this Solid package never pulls in the server-only `@lunora/agent`
|
|
791
|
+
* module graph.
|
|
792
|
+
*/
|
|
799
793
|
type VoiceAudioFormat = "mp3" | "wav";
|
|
800
794
|
/** Captures microphone audio and reports level / turn boundaries back to the primitive. */
|
|
801
795
|
interface VoiceMicrophone {
|
|
@@ -839,15 +833,10 @@ type CreateSpeaker = (config: {
|
|
|
839
833
|
audioFormat: VoiceAudioFormat;
|
|
840
834
|
}) => VoiceSpeaker;
|
|
841
835
|
/**
|
|
842
|
-
* The
|
|
843
|
-
*
|
|
844
|
-
*
|
|
845
|
-
*/
|
|
846
|
-
/**
|
|
847
|
-
* The `agents.<name>Voice` reference codegen emits for a voice-enabled agent — a
|
|
848
|
-
* live, WS-backed session keyed by `threadKey`. A structural subset of the
|
|
849
|
-
* generated member, so passing `api.agents.<name>Voice` type-checks.
|
|
850
|
-
*/
|
|
836
|
+
* The `agents.<name>Voice` reference codegen emits for a voice-enabled agent — a
|
|
837
|
+
* live, WS-backed session keyed by `threadKey`. A structural subset of the
|
|
838
|
+
* generated member, so passing `api.agents.<name>Voice` type-checks.
|
|
839
|
+
*/
|
|
851
840
|
type VoiceReference = FunctionReference<"stream", {
|
|
852
841
|
threadKey: string;
|
|
853
842
|
}, Record<string, unknown>>;
|
|
@@ -869,10 +858,10 @@ interface VoiceSocket {
|
|
|
869
858
|
type CreateSocket = (url: string) => VoiceSocket;
|
|
870
859
|
interface CreateVoiceAgentOptions {
|
|
871
860
|
/**
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
861
|
+
* Advanced/test seam: build the microphone capture subsystem. Defaults to a
|
|
862
|
+
* `getUserMedia` + Web Audio implementation. Injected wholesale so the Web
|
|
863
|
+
* Audio graph stays isolated (and mockable in a non-browser test env).
|
|
864
|
+
*/
|
|
876
865
|
createMicrophone?: CreateMicrophone;
|
|
877
866
|
/** Advanced/test seam: open the transport. Defaults to `new WebSocket(url)`. */
|
|
878
867
|
createSocket?: CreateSocket;
|
|
@@ -916,73 +905,73 @@ interface CreateVoiceAgentResult {
|
|
|
916
905
|
transcript: Accessor<string>;
|
|
917
906
|
}
|
|
918
907
|
/**
|
|
919
|
-
* A first-class voice-call surface for a voice-enabled agent: it opens a
|
|
920
|
-
* WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
|
|
921
|
-
* streams the agent's synthesized speech back through the browser's audio output,
|
|
922
|
-
* and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
|
|
923
|
-
* `audioLevel`) to Solid signals. Pass the generated `api.agents.<name>Voice`
|
|
924
|
-
* reference (never a string), matching `createAgentChat`'s reference-passing style.
|
|
925
|
-
* The Solid counterpart to React's `useVoiceAgent`, re-expressed with signals; the
|
|
926
|
-
* per-call connection lives in a closure variable (a primitive runs once per
|
|
927
|
-
* component, so no signal-of-signal indirection is needed).
|
|
928
|
-
*
|
|
929
|
-
* v1 transport is plain binary WebSocket frames with push-to-talk / silence-timer
|
|
930
|
-
* turn detection and client-side RMS barge-in. The heavy Web Audio capture and
|
|
931
|
-
* playback subsystems are injectable (`createMicrophone` / `createSpeaker` /
|
|
932
|
-
* `createSocket`) so the primitive is drivable outside a browser.
|
|
933
|
-
*/
|
|
908
|
+
* A first-class voice-call surface for a voice-enabled agent: it opens a
|
|
909
|
+
* WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
|
|
910
|
+
* streams the agent's synthesized speech back through the browser's audio output,
|
|
911
|
+
* and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
|
|
912
|
+
* `audioLevel`) to Solid signals. Pass the generated `api.agents.<name>Voice`
|
|
913
|
+
* reference (never a string), matching `createAgentChat`'s reference-passing style.
|
|
914
|
+
* The Solid counterpart to React's `useVoiceAgent`, re-expressed with signals; the
|
|
915
|
+
* per-call connection lives in a closure variable (a primitive runs once per
|
|
916
|
+
* component, so no signal-of-signal indirection is needed).
|
|
917
|
+
*
|
|
918
|
+
* v1 transport is plain binary WebSocket frames with push-to-talk / silence-timer
|
|
919
|
+
* turn detection and client-side RMS barge-in. The heavy Web Audio capture and
|
|
920
|
+
* playback subsystems are injectable (`createMicrophone` / `createSpeaker` /
|
|
921
|
+
* `createSocket`) so the primitive is drivable outside a browser.
|
|
922
|
+
*/
|
|
934
923
|
declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoiceAgentResult;
|
|
935
924
|
/**
|
|
936
|
-
* Hydrate a query from a {@link Preloaded} token produced by `preloadQuery`
|
|
937
|
-
* during SSR, then keep it live.
|
|
938
|
-
*
|
|
939
|
-
* This is the client half of PLAN4's "your loaders are live" handoff. The
|
|
940
|
-
* returned accessor is seeded **synchronously** from `preloaded.value`, so the
|
|
941
|
-
* very first read — during hydration — returns the server-rendered value with
|
|
942
|
-
* no loading flash and no `Suspense` fallback (unlike `createResource`, which
|
|
943
|
-
* always starts pending). After the component mounts, a WebSocket subscription
|
|
944
|
-
* attaches in an effect and every subsequent server delta flows into the same
|
|
945
|
-
* signal, so the UI goes live with zero refetch.
|
|
946
|
-
*
|
|
947
|
-
* ```tsx
|
|
948
|
-
* // route loader (server): const preloaded = await preloadQuery(client, api.messages.list, args);
|
|
949
|
-
* const messages = hydratePreloaded(preloaded); // seeded from SSR, then live
|
|
950
|
-
* return <pre>{JSON.stringify(messages())}</pre>;
|
|
951
|
-
* ```
|
|
952
|
-
*
|
|
953
|
-
* Effects do not run on the server during SSR (Solid only runs them after
|
|
954
|
-
* hydration), so the subscription is strictly client-side — the seed is the
|
|
955
|
-
* only value the server render ever sees.
|
|
956
|
-
*/
|
|
925
|
+
* Hydrate a query from a {@link Preloaded} token produced by `preloadQuery`
|
|
926
|
+
* during SSR, then keep it live.
|
|
927
|
+
*
|
|
928
|
+
* This is the client half of PLAN4's "your loaders are live" handoff. The
|
|
929
|
+
* returned accessor is seeded **synchronously** from `preloaded.value`, so the
|
|
930
|
+
* very first read — during hydration — returns the server-rendered value with
|
|
931
|
+
* no loading flash and no `Suspense` fallback (unlike `createResource`, which
|
|
932
|
+
* always starts pending). After the component mounts, a WebSocket subscription
|
|
933
|
+
* attaches in an effect and every subsequent server delta flows into the same
|
|
934
|
+
* signal, so the UI goes live with zero refetch.
|
|
935
|
+
*
|
|
936
|
+
* ```tsx
|
|
937
|
+
* // route loader (server): const preloaded = await preloadQuery(client, api.messages.list, args);
|
|
938
|
+
* const messages = hydratePreloaded(preloaded); // seeded from SSR, then live
|
|
939
|
+
* return <pre>{JSON.stringify(messages())}</pre>;
|
|
940
|
+
* ```
|
|
941
|
+
*
|
|
942
|
+
* Effects do not run on the server during SSR (Solid only runs them after
|
|
943
|
+
* hydration), so the subscription is strictly client-side — the seed is the
|
|
944
|
+
* only value the server render ever sees.
|
|
945
|
+
*/
|
|
957
946
|
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Accessor<T>;
|
|
958
947
|
interface LunoraProviderProps {
|
|
959
948
|
children: JSX.Element;
|
|
960
949
|
/**
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
950
|
+
* The framework-neutral transport. Build it once at the app root with
|
|
951
|
+
* `new LunoraClient({ url })` (or `createServerClient` during SSR) and pass
|
|
952
|
+
* it here — the provider does not own its lifecycle, so the same instance
|
|
953
|
+
* survives across route navigations.
|
|
954
|
+
*/
|
|
966
955
|
client: LunoraClient;
|
|
967
956
|
}
|
|
968
957
|
/**
|
|
969
|
-
* Provides a {@link LunoraClient} to the Solid tree via {@link LunoraContext}.
|
|
970
|
-
*
|
|
971
|
-
* Solid's context is reactive-graph scoped rather than render scoped, so unlike
|
|
972
|
-
* the React provider there is no QueryClient to detect or lazily create — the
|
|
973
|
-
* adapter's reactive primitives (`createQuery`, `createMutation`,
|
|
974
|
-
* `hydratePreloaded`) own their own signals and read the client straight from
|
|
975
|
-
* context. Drop one of these at the root of your app:
|
|
976
|
-
*
|
|
977
|
-
* ```tsx
|
|
978
|
-
* const client = new LunoraClient({ url: window.location.origin });
|
|
979
|
-
*
|
|
980
|
-
* render(() => (
|
|
981
|
-
* <LunoraProvider client={client}>
|
|
982
|
-
* <App />
|
|
983
|
-
* </LunoraProvider>
|
|
984
|
-
* ), root);
|
|
985
|
-
* ```
|
|
986
|
-
*/
|
|
958
|
+
* Provides a {@link LunoraClient} to the Solid tree via {@link LunoraContext}.
|
|
959
|
+
*
|
|
960
|
+
* Solid's context is reactive-graph scoped rather than render scoped, so unlike
|
|
961
|
+
* the React provider there is no QueryClient to detect or lazily create — the
|
|
962
|
+
* adapter's reactive primitives (`createQuery`, `createMutation`,
|
|
963
|
+
* `hydratePreloaded`) own their own signals and read the client straight from
|
|
964
|
+
* context. Drop one of these at the root of your app:
|
|
965
|
+
*
|
|
966
|
+
* ```tsx
|
|
967
|
+
* const client = new LunoraClient({ url: window.location.origin });
|
|
968
|
+
*
|
|
969
|
+
* render(() => (
|
|
970
|
+
* <LunoraProvider client={client}>
|
|
971
|
+
* <App />
|
|
972
|
+
* </LunoraProvider>
|
|
973
|
+
* ), root);
|
|
974
|
+
* ```
|
|
975
|
+
*/
|
|
987
976
|
declare const LunoraProvider: (props: LunoraProviderProps) => JSX.Element;
|
|
988
977
|
export { type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type CreateAgentApi, type CreateAgentChatApi, type CreateAgentChatOptions, type CreateAgentChatResult, type CreateAgentOptions, type CreateAgentResult, type CreateAgentStateApi, type CreateAgentStateOptions, type CreateAgentStateResult, type CreateAgentToolEventsApi, type CreateAgentToolEventsOptions, type CreateAgentToolEventsResult, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateStreamOptions, type CreateStreamResult, type CreateStreamStatus, type CreateSubscriptionResult, type CreateVoiceAgentOptions, type CreateVoiceAgentResult, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider, type LunoraProviderProps, type MutationClient, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, createAgent, createAgentChat, createAgentState, createAgentToolEvents, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createMutator, createPaginatedQuery, createPresence, createQuery, createRateLimit, createStream, createSubscription, createVoiceAgent, hydratePreloaded, useLunora };
|