@lunora/svelte 1.0.0-alpha.321 → 1.0.0-alpha.323
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 +33 -7
- package/dist/index.d.ts +33 -7
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/agentChat-B85Roxj3.mjs +1 -0
- package/dist/packem_shared/{agentState-DUcWVYXr.mjs → agentState-CWX44Gk9.mjs} +1 -1
- package/dist/packem_shared/agentToolEvents-CdJUiim7.mjs +1 -0
- package/dist/packem_shared/{infiniteQuery-D91H-yvI.mjs → infiniteQuery-DOD9tEYH.mjs} +1 -1
- package/dist/packem_shared/{liveTopic-zWCoweI3.mjs → liveTopic-By3-Qi68.mjs} +1 -1
- package/dist/packem_shared/presence-C_vLicqT.mjs +1 -0
- package/dist/packem_shared/{query-DpzFJQyT.mjs → query-CxjOg_wv.mjs} +1 -1
- package/dist/packem_shared/subscribe-reactive-args-ClWd3Rut.mjs +1 -0
- package/dist/packem_shared/{subscription-DSyycrP7.mjs → subscription-DFD5oYmP.mjs} +1 -1
- package/package.json +2 -2
- package/dist/packem_shared/agentChat-DDtm3-N1.mjs +0 -1
- package/dist/packem_shared/agentToolEvents-D2DqjZ9V.mjs +0 -1
- package/dist/packem_shared/presence-DYgABtvC.mjs +0 -1
- package/dist/packem_shared/subscribe-reactive-args-D0fSbP1k.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -164,6 +164,8 @@ declare function agent(client: LunoraClient, options: AgentOptions): AgentHandle
|
|
|
164
164
|
* `agent_messages` table in `packages/agent/src/component.ts`.
|
|
165
165
|
*/
|
|
166
166
|
interface AgentChatMessage {
|
|
167
|
+
/** On an `awaiting_approval` message: the slot its run waits under, which a decision must name. */
|
|
168
|
+
approvalSlot?: string;
|
|
167
169
|
content: string;
|
|
168
170
|
createdAt?: number;
|
|
169
171
|
/**
|
|
@@ -228,6 +230,7 @@ type AgentMessagesReference$1 = FunctionReference<"query", {
|
|
|
228
230
|
}, ReadonlyArray<Record<string, unknown>>>;
|
|
229
231
|
/** The `agents:agentResolveApproval` reference — resolves a human-in-the-loop tool approval. */
|
|
230
232
|
type AgentApprovalReference = FunctionReference<"mutation", {
|
|
233
|
+
approvalSlot: string;
|
|
231
234
|
decision: "approve" | "approve_for_thread" | "reject";
|
|
232
235
|
instanceId: string;
|
|
233
236
|
note?: string;
|
|
@@ -236,6 +239,11 @@ type AgentApprovalReference = FunctionReference<"mutation", {
|
|
|
236
239
|
}, {
|
|
237
240
|
resolved: boolean;
|
|
238
241
|
}>;
|
|
242
|
+
/**
|
|
243
|
+
* The pending approval a decision answers: its `awaiting_approval` message, its `awaiting-approval` tool event or its
|
|
244
|
+
* inbox item. A provider can reuse a tool-call id in a later turn, so a decision names the approval's slot as well.
|
|
245
|
+
*/
|
|
246
|
+
type AgentApprovalTarget = Pick<AgentChatMessage, "approvalSlot" | "toolCallId">;
|
|
239
247
|
/** The `agents:agentSupplySecret` reference — stores a person's value for a paused `requestSecretTool` call. */
|
|
240
248
|
type AgentSupplySecretReference = FunctionReference<"mutation", {
|
|
241
249
|
secret: string;
|
|
@@ -334,12 +342,12 @@ interface AgentChatHandle {
|
|
|
334
342
|
/** The tools approved for the rest of this thread, live. Read with `$approvalGrants`. */
|
|
335
343
|
approvalGrants: Readable<ReadonlyArray<AgentApprovalGrant>>;
|
|
336
344
|
/** Approve a paused human-in-the-loop tool call (optionally with a note). */
|
|
337
|
-
approve: (
|
|
345
|
+
approve: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
|
|
338
346
|
/**
|
|
339
347
|
* Approve a paused tool call and grant that tool for the rest of the thread, so
|
|
340
348
|
* later calls to it run without pausing. Undo with {@link AgentChatHandle.revokeGrant}.
|
|
341
349
|
*/
|
|
342
|
-
approveForThread: (
|
|
350
|
+
approveForThread: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
|
|
343
351
|
/**
|
|
344
352
|
* Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
|
|
345
353
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
@@ -350,7 +358,7 @@ interface AgentChatHandle {
|
|
|
350
358
|
/** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. Read with `$messages`. */
|
|
351
359
|
messages: Readable<ReadonlyArray<AgentChatMessage>>;
|
|
352
360
|
/** Reject a paused human-in-the-loop tool call (optionally with a reason). */
|
|
353
|
-
reject: (
|
|
361
|
+
reject: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
|
|
354
362
|
/** Remove a thread-scoped approval grant so the tool's gate applies again to later calls. */
|
|
355
363
|
revokeGrant: (toolName: string) => Promise<void>;
|
|
356
364
|
/** Start (or continue) a run with a user message; extra args merge over `sendArgs`. Appends an optimistic user turn. */
|
|
@@ -514,6 +522,7 @@ type AgentToolEvent = {
|
|
|
514
522
|
toolName?: string;
|
|
515
523
|
type: "result";
|
|
516
524
|
} | {
|
|
525
|
+
approvalSlot?: string;
|
|
517
526
|
seq: number;
|
|
518
527
|
toolCallId?: string;
|
|
519
528
|
toolName?: string;
|
|
@@ -923,7 +932,10 @@ declare function infiniteQuery<F extends FunctionReference>(client: LunoraClient
|
|
|
923
932
|
* `@lunora/server` `definePresence` preset.
|
|
924
933
|
*
|
|
925
934
|
* Drives the heartbeat mutation (on call, interval, and tab re-focus) and
|
|
926
|
-
* subscribes to the live `listPresent` query for the given room.
|
|
935
|
+
* subscribes to the live `listPresent` query for the given room. `roomId` may
|
|
936
|
+
* be a `Readable<string>`; a change stops the old room's heartbeats and
|
|
937
|
+
* subscription and joins the new one. Pass `leave` to drop the old room's row
|
|
938
|
+
* at once; without it the server keeps that row until it ages out (`ttlMs`).
|
|
927
939
|
*
|
|
928
940
|
* Pass `client` explicitly, or omit it to resolve the ambient client from the
|
|
929
941
|
* Svelte context.
|
|
@@ -943,6 +955,13 @@ type HeartbeatReference = FunctionReference<"mutation", {
|
|
|
943
955
|
type ListPresentReference = FunctionReference<"query", {
|
|
944
956
|
roomId: string;
|
|
945
957
|
}>;
|
|
958
|
+
/**
|
|
959
|
+
* The presence `leave` mutation: `definePresence(...).functions.leave`.
|
|
960
|
+
*/
|
|
961
|
+
type LeaveReference = FunctionReference<"mutation", {
|
|
962
|
+
roomId: string;
|
|
963
|
+
sessionId: string;
|
|
964
|
+
}>;
|
|
946
965
|
interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentReference> {
|
|
947
966
|
/** Awareness blob for the first heartbeat (selection, cursor, name, color…). */
|
|
948
967
|
data?: Record<string, unknown>;
|
|
@@ -950,6 +969,13 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
|
|
|
950
969
|
heartbeat: H;
|
|
951
970
|
/** Heartbeat cadence in ms. Defaults to 10s. */
|
|
952
971
|
intervalMs?: number;
|
|
972
|
+
/**
|
|
973
|
+
* The `api.*` reference for the presence `leave` mutation. When given, leaving a room (a room
|
|
974
|
+
* change, or teardown) removes this session's row there at once, unless another view on the same
|
|
975
|
+
* client still shows that session in that room; without it the old room lists the session until
|
|
976
|
+
* its last heartbeat ages out (`ttlMs`).
|
|
977
|
+
*/
|
|
978
|
+
leave?: LeaveReference;
|
|
953
979
|
/** The `api.*` reference for the presence listPresent query. */
|
|
954
980
|
listPresent: L;
|
|
955
981
|
/**
|
|
@@ -991,8 +1017,8 @@ interface PresenceHandle<L extends ListPresentReference> {
|
|
|
991
1017
|
* `handle.teardown()` yourself. `teardown()` is idempotent, so an explicit
|
|
992
1018
|
* `onDestroy(handle.teardown)` on top of the auto-wiring is safe.
|
|
993
1019
|
*/
|
|
994
|
-
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
995
|
-
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1020
|
+
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: Readable<string> | string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1021
|
+
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: Readable<string> | string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
996
1022
|
/** Query args, the skip sentinel, or a reactive (`Readable`) source of either. */
|
|
997
1023
|
type ReactiveArgs<F extends FunctionReference> = ArgsOf<F> | "skip" | Readable<ArgsOf<F> | "skip">;
|
|
998
1024
|
/** Options accepted by {@link query}. */
|
|
@@ -1325,7 +1351,7 @@ interface VoiceAgentHandle {
|
|
|
1325
1351
|
*/
|
|
1326
1352
|
declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1327
1353
|
declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1328
|
-
export { type ActionHandle, type AgentApi, type AgentApprovalGrant, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type LiveTopicState, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1354
|
+
export { type ActionHandle, type AgentApi, type AgentApprovalGrant, type AgentApprovalTarget, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type LeaveReference, type ListPresentReference, type LiveTopicState, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1329
1355
|
/**
|
|
1330
1356
|
* Svelte adapter for Lunora (`@lunora/svelte`).
|
|
1331
1357
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -164,6 +164,8 @@ declare function agent(client: LunoraClient, options: AgentOptions): AgentHandle
|
|
|
164
164
|
* `agent_messages` table in `packages/agent/src/component.ts`.
|
|
165
165
|
*/
|
|
166
166
|
interface AgentChatMessage {
|
|
167
|
+
/** On an `awaiting_approval` message: the slot its run waits under, which a decision must name. */
|
|
168
|
+
approvalSlot?: string;
|
|
167
169
|
content: string;
|
|
168
170
|
createdAt?: number;
|
|
169
171
|
/**
|
|
@@ -228,6 +230,7 @@ type AgentMessagesReference$1 = FunctionReference<"query", {
|
|
|
228
230
|
}, ReadonlyArray<Record<string, unknown>>>;
|
|
229
231
|
/** The `agents:agentResolveApproval` reference — resolves a human-in-the-loop tool approval. */
|
|
230
232
|
type AgentApprovalReference = FunctionReference<"mutation", {
|
|
233
|
+
approvalSlot: string;
|
|
231
234
|
decision: "approve" | "approve_for_thread" | "reject";
|
|
232
235
|
instanceId: string;
|
|
233
236
|
note?: string;
|
|
@@ -236,6 +239,11 @@ type AgentApprovalReference = FunctionReference<"mutation", {
|
|
|
236
239
|
}, {
|
|
237
240
|
resolved: boolean;
|
|
238
241
|
}>;
|
|
242
|
+
/**
|
|
243
|
+
* The pending approval a decision answers: its `awaiting_approval` message, its `awaiting-approval` tool event or its
|
|
244
|
+
* inbox item. A provider can reuse a tool-call id in a later turn, so a decision names the approval's slot as well.
|
|
245
|
+
*/
|
|
246
|
+
type AgentApprovalTarget = Pick<AgentChatMessage, "approvalSlot" | "toolCallId">;
|
|
239
247
|
/** The `agents:agentSupplySecret` reference — stores a person's value for a paused `requestSecretTool` call. */
|
|
240
248
|
type AgentSupplySecretReference = FunctionReference<"mutation", {
|
|
241
249
|
secret: string;
|
|
@@ -334,12 +342,12 @@ interface AgentChatHandle {
|
|
|
334
342
|
/** The tools approved for the rest of this thread, live. Read with `$approvalGrants`. */
|
|
335
343
|
approvalGrants: Readable<ReadonlyArray<AgentApprovalGrant>>;
|
|
336
344
|
/** Approve a paused human-in-the-loop tool call (optionally with a note). */
|
|
337
|
-
approve: (
|
|
345
|
+
approve: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
|
|
338
346
|
/**
|
|
339
347
|
* Approve a paused tool call and grant that tool for the rest of the thread, so
|
|
340
348
|
* later calls to it run without pausing. Undo with {@link AgentChatHandle.revokeGrant}.
|
|
341
349
|
*/
|
|
342
|
-
approveForThread: (
|
|
350
|
+
approveForThread: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
|
|
343
351
|
/**
|
|
344
352
|
* Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
|
|
345
353
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
@@ -350,7 +358,7 @@ interface AgentChatHandle {
|
|
|
350
358
|
/** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. Read with `$messages`. */
|
|
351
359
|
messages: Readable<ReadonlyArray<AgentChatMessage>>;
|
|
352
360
|
/** Reject a paused human-in-the-loop tool call (optionally with a reason). */
|
|
353
|
-
reject: (
|
|
361
|
+
reject: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
|
|
354
362
|
/** Remove a thread-scoped approval grant so the tool's gate applies again to later calls. */
|
|
355
363
|
revokeGrant: (toolName: string) => Promise<void>;
|
|
356
364
|
/** Start (or continue) a run with a user message; extra args merge over `sendArgs`. Appends an optimistic user turn. */
|
|
@@ -514,6 +522,7 @@ type AgentToolEvent = {
|
|
|
514
522
|
toolName?: string;
|
|
515
523
|
type: "result";
|
|
516
524
|
} | {
|
|
525
|
+
approvalSlot?: string;
|
|
517
526
|
seq: number;
|
|
518
527
|
toolCallId?: string;
|
|
519
528
|
toolName?: string;
|
|
@@ -923,7 +932,10 @@ declare function infiniteQuery<F extends FunctionReference>(client: LunoraClient
|
|
|
923
932
|
* `@lunora/server` `definePresence` preset.
|
|
924
933
|
*
|
|
925
934
|
* Drives the heartbeat mutation (on call, interval, and tab re-focus) and
|
|
926
|
-
* subscribes to the live `listPresent` query for the given room.
|
|
935
|
+
* subscribes to the live `listPresent` query for the given room. `roomId` may
|
|
936
|
+
* be a `Readable<string>`; a change stops the old room's heartbeats and
|
|
937
|
+
* subscription and joins the new one. Pass `leave` to drop the old room's row
|
|
938
|
+
* at once; without it the server keeps that row until it ages out (`ttlMs`).
|
|
927
939
|
*
|
|
928
940
|
* Pass `client` explicitly, or omit it to resolve the ambient client from the
|
|
929
941
|
* Svelte context.
|
|
@@ -943,6 +955,13 @@ type HeartbeatReference = FunctionReference<"mutation", {
|
|
|
943
955
|
type ListPresentReference = FunctionReference<"query", {
|
|
944
956
|
roomId: string;
|
|
945
957
|
}>;
|
|
958
|
+
/**
|
|
959
|
+
* The presence `leave` mutation: `definePresence(...).functions.leave`.
|
|
960
|
+
*/
|
|
961
|
+
type LeaveReference = FunctionReference<"mutation", {
|
|
962
|
+
roomId: string;
|
|
963
|
+
sessionId: string;
|
|
964
|
+
}>;
|
|
946
965
|
interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentReference> {
|
|
947
966
|
/** Awareness blob for the first heartbeat (selection, cursor, name, color…). */
|
|
948
967
|
data?: Record<string, unknown>;
|
|
@@ -950,6 +969,13 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
|
|
|
950
969
|
heartbeat: H;
|
|
951
970
|
/** Heartbeat cadence in ms. Defaults to 10s. */
|
|
952
971
|
intervalMs?: number;
|
|
972
|
+
/**
|
|
973
|
+
* The `api.*` reference for the presence `leave` mutation. When given, leaving a room (a room
|
|
974
|
+
* change, or teardown) removes this session's row there at once, unless another view on the same
|
|
975
|
+
* client still shows that session in that room; without it the old room lists the session until
|
|
976
|
+
* its last heartbeat ages out (`ttlMs`).
|
|
977
|
+
*/
|
|
978
|
+
leave?: LeaveReference;
|
|
953
979
|
/** The `api.*` reference for the presence listPresent query. */
|
|
954
980
|
listPresent: L;
|
|
955
981
|
/**
|
|
@@ -991,8 +1017,8 @@ interface PresenceHandle<L extends ListPresentReference> {
|
|
|
991
1017
|
* `handle.teardown()` yourself. `teardown()` is idempotent, so an explicit
|
|
992
1018
|
* `onDestroy(handle.teardown)` on top of the auto-wiring is safe.
|
|
993
1019
|
*/
|
|
994
|
-
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
995
|
-
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1020
|
+
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: Readable<string> | string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1021
|
+
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: Readable<string> | string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
996
1022
|
/** Query args, the skip sentinel, or a reactive (`Readable`) source of either. */
|
|
997
1023
|
type ReactiveArgs<F extends FunctionReference> = ArgsOf<F> | "skip" | Readable<ArgsOf<F> | "skip">;
|
|
998
1024
|
/** Options accepted by {@link query}. */
|
|
@@ -1325,7 +1351,7 @@ interface VoiceAgentHandle {
|
|
|
1325
1351
|
*/
|
|
1326
1352
|
declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1327
1353
|
declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1328
|
-
export { type ActionHandle, type AgentApi, type AgentApprovalGrant, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type LiveTopicState, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1354
|
+
export { type ActionHandle, type AgentApi, type AgentApprovalGrant, type AgentApprovalTarget, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type LeaveReference, type ListPresentReference, type LiveTopicState, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1329
1355
|
/**
|
|
1330
1356
|
* Svelte adapter for Lunora (`@lunora/svelte`).
|
|
1331
1357
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{action as t}from"./packem_shared/action-BwzMXvK2.mjs";import{agent as m}from"./packem_shared/agent-CYV_xWD9.mjs";import{agentChat as a}from"./packem_shared/agentChat-
|
|
1
|
+
import{action as t}from"./packem_shared/action-BwzMXvK2.mjs";import{agent as m}from"./packem_shared/agent-CYV_xWD9.mjs";import{agentChat as a}from"./packem_shared/agentChat-B85Roxj3.mjs";import{agentState as n}from"./packem_shared/agentState-CWX44Gk9.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-CdJUiim7.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-DLryMKMY.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-Ba3Y_I18.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-CIfxHhDm.mjs";import{flag as C,flags as L}from"./packem_shared/flag-CvPhqFko.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-GIJIIvjB.mjs";import{liveTopic as b}from"./packem_shared/liveTopic-By3-Qi68.mjs";import{mutation as A}from"./packem_shared/mutation-Cvnei0Ke.mjs";import{mutator as G}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as j,paginatedQuery as k}from"./packem_shared/infiniteQuery-DOD9tEYH.mjs";import{presence as z}from"./packem_shared/presence-C_vLicqT.mjs";import{query as D}from"./packem_shared/query-CxjOg_wv.mjs";import{rateLimit as H}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as J}from"./packem_shared/stream-CMEivEKF.mjs";import{subscription as M}from"./packem_shared/subscription-DFD5oYmP.mjs";import{voiceAgent as O}from"./packem_shared/voiceAgent-qByP7VDj.mjs";export{t as action,m as agent,a as agentChat,n as agentState,i as agentToolEvents,g as auth,s as authGate,l as connectionStatus,C as flag,L as flags,h as getLunoraClient,S as hydratePreloaded,j as infiniteQuery,b as liveTopic,A as mutation,G as mutator,k as paginatedQuery,z as presence,D as query,H as rateLimit,y as setLunoraClient,J as stream,M as subscription,O as voiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{reconcileOptimistic as R,maxSeq as E}from"@lunora/client";import{writable as b}from"svelte/store";import{i as g}from"./is-browser-BEdfLJHK.mjs";import{isClient as tt,NO_MUTATION_REF as et}from"./agent-CYV_xWD9.mjs";import{getLunoraClient as st}from"./getLunoraClient-CIfxHhDm.mjs";import{mutation as i}from"./mutation-Cvnei0Ke.mjs";import{stream as nt}from"./stream-CMEivEKF.mjs";const at={__lunoraRef:""},rt=(n,v)=>{const{api:r,cancel:p,limit:h,onError:y,send:_,sendArgs:G,stream:k,threadKey:a}=v,q=i(n,_),j=i(n,p??et),D=i(n,r.agents.agentResolveApproval),F=i(n,r.agents.agentRevokeApprovalGrant),N=i(n,r.agents.agentSupplySecret),H=i(n,r.agents.agentDeclineSecret);let l,o=[],u=[],x=[],A=0;const f=b([]),C=b(),T=b([]),I=b(""),S=()=>{const t=R(u,o);if(t.length===0){f.set(o);return}const e=E(o);f.set([...o,...t.map((s,c)=>({content:s.content,optimistic:!0,role:"user",seq:e+1+c}))])},M=()=>{const t=o.filter(s=>s.role==="assistant").length,e=x.filter(s=>s.kind!=="progress"&&s.threadKey===a&&s.turn>=t).map(s=>s.text).join("");I.set(e)},K=k===void 0?"skip":{key:a},$=g()?nt(n,k??at,K).chunks.subscribe(t=>{x=t,M()}):()=>{},B=h===void 0?{key:a}:{key:a,limit:h},L=g()?n.subscribe(r.agents.agentMessages,B,t=>{o=t,S(),M()},{onError:y}):()=>{},O=g()?n.subscribe(r.agents.agentThread,{key:a},t=>{l=t,C.set(l?.status)},{onError:y}):()=>{},U=g()?n.subscribe(r.agents.agentApprovalGrants,{key:a},t=>{T.set(t)},{onError:y}):()=>{},z=async(t,e)=>{const s=A;A+=1;const c=E(o);u=[...R(u,o),{content:t,id:s,maxDurableSeqAtSend:c}],S();try{await q.mutate({input:t,threadKey:a,...G,...e})}catch(m){throw u=u.filter(d=>d.id!==s),S(),m}},w=async(t,e,s)=>{const c=l?.instanceId;if(c===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);const{approvalSlot:m,toolCallId:d}=e;if(m===void 0||d===void 0)throw new Error(`agentChat: cannot ${t} — pass the pending approval, which carries its toolCallId and approvalSlot`);await D.mutate({approvalSlot:m,decision:t,instanceId:c,threadKey:a,toolCallId:d,...s===void 0?{}:{note:s}})},J=async(t,e)=>w("approve",t,e),P=async(t,e)=>w("approve_for_thread",t,e),Q=async(t,e)=>w("reject",t,e),V=async t=>{await F.mutate({threadKey:a,toolName:t})},W=async(t,e)=>{await N.mutate({secret:e,threadKey:a,toolCallId:t},{onlineOnly:!0})},X=async t=>{await H.mutate({threadKey:a,toolCallId:t})},Y=async()=>{const t=l?.instanceId;p===void 0||t===void 0||await j.mutate({instanceId:t,threadKey:a})},Z=()=>{L(),O(),U(),$()};return{approvalGrants:{subscribe:T.subscribe},approve:J,approveForThread:P,cancel:Y,declineSecret:X,messages:{subscribe:f.subscribe},reject:Q,revokeGrant:V,send:z,status:{subscribe:C.subscribe},streamingText:{subscribe:I.subscribe},supplySecret:W,teardown:Z}};function dt(n,v){const r=tt(n),p=r?n:st();return rt(p,r?v:n)}export{dt as agentChat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{derived as c}from"svelte/store";import{isClient as p}from"./agent-CYV_xWD9.mjs";import{getLunoraClient as f}from"./getLunoraClient-CIfxHhDm.mjs";import{subscription as d}from"./subscription-
|
|
1
|
+
import{derived as c}from"svelte/store";import{isClient as p}from"./agent-CYV_xWD9.mjs";import{getLunoraClient as f}from"./getLunoraClient-CIfxHhDm.mjs";import{subscription as d}from"./subscription-DFD5oYmP.mjs";function h(t,r){const o=p(t),n=o?t:f(),e=o?r:t,{data:i,error:a}=d(n,e.api.agents.agentState,{key:e.threadKey}),s=c(i,m=>m);return{error:a,state:s}}export{h as agentState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{derived as y}from"svelte/store";import{isClient as E}from"./agent-CYV_xWD9.mjs";import{getLunoraClient as I}from"./getLunoraClient-CIfxHhDm.mjs";import{stream as N}from"./stream-CMEivEKF.mjs";import{subscription as _}from"./subscription-DFD5oYmP.mjs";const h={__lunoraRef:""},k={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},m=t=>{const o=t.status===void 0?void 0:k[t.status];if(o!==void 0)return{seq:t.seq,type:o,...t.approvalSlot===void 0?{}:{approvalSlot:t.approvalSlot},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}},q=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(r=>({input:r.input,seq:t.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(t.role!=="tool")return;const o=m(t);return o!==void 0?[o]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]};function x(t,o){const r=E(t),a=r?t:I(),p=r?o:t,{api:u,limit:i,stream:e,threadKey:n}=p,s=i===void 0?{key:n}:{key:n,limit:i},{data:c}=_(a,u.agents.agentMessages,s),v=N(a,e??h,e===void 0?"skip":{key:n});return{events:y([c,v.chunks],([f,C])=>{const d=(f??[]).flatMap(l=>q(l)??[]);for(const l of C)l.kind==="progress"&&l.threadKey===n&&d.push({data:l.data,toolCallId:l.toolCallId,type:"progress"});return d})}}export{x as agentToolEvents};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initialPages as F,derivePaginationStatus as H,applyLoadMore as Y,isHeadPage as Z,rebalance as _,classifyPageFailure as O,headPage as ee}from"@lunora/client/pagination";import{stableWireKey as se}from"@lunora/wire";import{derived as L,writable as Q,readable as te,get as K}from"svelte/store";import{i as oe}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as T}from"./getLunoraClient-CIfxHhDm.mjs";import{i as j}from"./is-function-reference-abFdrAae.mjs";import{i as ne,s as re}from"./subscribe-reactive-args-
|
|
1
|
+
import{initialPages as F,derivePaginationStatus as H,applyLoadMore as Y,isHeadPage as Z,rebalance as _,classifyPageFailure as O,headPage as ee}from"@lunora/client/pagination";import{stableWireKey as se}from"@lunora/wire";import{derived as L,writable as Q,readable as te,get as K}from"svelte/store";import{i as oe}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as T}from"./getLunoraClient-CIfxHhDm.mjs";import{i as j}from"./is-function-reference-abFdrAae.mjs";import{i as ne,s as re}from"./subscribe-reactive-args-ClWd3Rut.mjs";const $=(n,u)=>({...u,paginationOpts:{cursor:n.lower,endCursor:n.upper,numItems:n.numItems}}),ae=(n,u)=>`${n}::${se(u)}`,D=(n,u,M,I)=>{const{initialNumItems:l,onError:N,shardKey:C}=I,r=Q(F(l)),m=Q();let v=!1;const w=Q([]),i=new Map,g=new Map,p=new Set;let t=ne(M)?"skip":M,x=new WeakMap;const a=(e,b)=>{let c=x.get(e);return c===void 0&&(c=ae(u.__lunoraRef,$(e,b)),x.set(e,c)),c},y=()=>{if(t==="skip"){w.set([]);return}const e=t,b=K(r).map(c=>{const s=a(c,e);return i.get(s)});w.set(b)},E=(e,b)=>{if(t==="skip")return;const c=t,s=R=>a(R,c);for(const R of b){const o=s(R);if(i.has(o))continue;const S=e.find(d=>d.lower===R.lower);if(S){const d=i.get(s(S));d&&i.set(o,d)}}},q=()=>{if(t==="skip"){for(const s of g.values())s();g.clear(),w.set([]);return}const e=t,b=K(r),c=new Set;for(const s of b)c.add(a(s,e));for(const[s,R]of g)c.has(s)||(R(),g.delete(s),p.delete(s),i.delete(s));for(const s of b){const R=$(s,e),o=a(s,e);if(g.has(o))continue;p.add(o);const S=n.subscribe(u,R,d=>{if(i.set(o,d),v&&K(r).some(P=>!Z(P)&&a(P,e)===o)&&(v=!1),p.delete(o),m.set(void 0),y(),p.size===0){const P=K(r),h=_(P,K(w));h&&(E(P,h),r.set(h),A(),y())}},{onError:d=>{p.delete(o);const P=O(K(r),X=>a(X,e)===o,d,v);if(P==="restart"&&(n.resnapshot(u,$(ee(l),e),{shardKey:C}),G(),v=!0),P!=="surface")return;m.set(d);const h=K(r),B=h.at(-1);h.length>1&&B&&!i.has(o)&&a(B,e)===o&&(r.set(h.slice(0,-1)),A(),y()),N?.(d)},shardKey:C});g.set(o,S)}};let f=!1,k=!1;const A=()=>{if(f){k=!0;return}f=!0;try{do k=!1,q();while(k)}finally{f=!1}},z=()=>{for(const e of g.values())e();g.clear(),i.clear(),p.clear(),x=new WeakMap},G=()=>{z(),r.set(F(l)),m.set(void 0),A(),y()},W=te([],e=>{if(!oe())return()=>{};const b=w.subscribe(e),c=re(M,s=>(t=s,A(),y(),()=>{z(),r.set(F(l)),m.set(void 0),v=!1}));return()=>{c(),b(),w.set([])}}),J=L(W,e=>H(t==="skip",e).status),U=L(W,()=>t==="skip"),V=e=>{if(t==="skip")return;const b=K(w),{nextCursor:c,status:s}=H(!1,b);if(s!=="CanLoadMore")return;const R=K(r),o=Y(R,c,e);if(!o)return;const S=R.at(-1),d=o.at(-2);if(S&&d){const P=a(S,t),h=a(d,t);if(P!==h){const B=i.get(P);B&&(i.set(h,B),i.delete(P))}}m.set(void 0),r.set(o),A(),y()};return{error:{subscribe:m.subscribe},loadMore:V,pageResults:W,skipped:U,status:J}};function pe(n,u,M,I){const l=!j(n),N=l?n:T(),C=l?u:n,r=l?M:u,m=l?I:M,{error:v,loadMore:w,pageResults:i,skipped:g,status:p}=D(N,C,r,m),t=L(i,a=>a.flatMap(y=>y?.page??[])),x=L([p,g],([a,y])=>!y&&(a==="LoadingFirstPage"||a==="LoadingMore"));return{error:v,isLoading:x,loadMore:w,results:t,status:p}}function ye(n,u,M,I){const l=!j(n),N=l?n:T(),C=l?u:n,r=l?M:u,m=l?I:M,{initialNumItems:v}=m,{error:w,loadMore:i,pageResults:g,skipped:p,status:t}=D(N,C,r,m),x=L(g,f=>f.flatMap(k=>k?[k.page]:[])),a=L([t,p],([f,k])=>!k&&f==="LoadingFirstPage"),y=L(t,f=>f==="CanLoadMore"),E=L([t,p],([f,k])=>!k&&f==="LoadingMore");return{error:w,fetchNextPage:f=>{i(f??v)},hasNextPage:y,isFetchingNextPage:E,isLoading:a,pages:x,status:t}}export{ye as infiniteQuery,pe as paginatedQuery};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{liveTopicSubscription as p,subscribeLiveTopic as y}from"@lunora/client";import{readable as c,derived as f}from"svelte/store";import{i as E}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as h}from"./getLunoraClient-CIfxHhDm.mjs";import{i as l,s as D}from"./subscribe-reactive-args-
|
|
1
|
+
import{liveTopicSubscription as p,subscribeLiveTopic as y}from"@lunora/client";import{readable as c,derived as f}from"svelte/store";import{i as E}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as h}from"./getLunoraClient-CIfxHhDm.mjs";import{i as l,s as D}from"./subscribe-reactive-args-ClWd3Rut.mjs";const S=r=>({headers:r.headers,maxDelayMs:r.maxDelayMs,retryDelay:r.retryDelay,sessionKey:r.sessionKey,topic:r.topic,url:r.url,withCredentials:r.withCredentials}),g=(r,i={})=>{const v=h();return c({error:void 0,lastEvent:void 0},s=>{if(!E())return;const u=l(r)?r:c(r),a=l(i)?i:c(i);let n={};const d=a.subscribe(t=>{n=t}),m=t=>{let e;return s({error:void 0,lastEvent:e}),y({...t,onError:o=>{s({error:o,lastEvent:e}),n.onError?.(o)},onEvent:o=>{e=o,s({error:void 0,lastEvent:e}),n.onEvent?.(o)}})},b=D(f([u,a],([t,e])=>S(p(v,t,e))),m);return()=>{b(),d()}})};export{g as liveTopic};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{onDestroy as F}from"svelte";import{writable as K,readable as N}from"svelte/store";import{i as L}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as T}from"./getLunoraClient-CIfxHhDm.mjs";import{s as M}from"./subscribe-reactive-args-ClWd3Rut.mjs";const j=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(e)}`)},h=async e=>{try{await e()}catch{}},D=e=>JSON.stringify([e.shardKey??"",e.roomId,e.sessionId]),W=new WeakMap,A=e=>{let o=W.get(e);return o===void 0&&(o={heartbeats:new Map,leaves:new Map},W.set(e,o)),o},_=(e,o,t)=>{const{heartbeats:n,leaves:r}=A(e),s=D(o),d=r.get(s),i=d===void 0?h(t):d.then(async()=>h(t)),a=n.get(s)??new Set;a.add(i),n.set(s,a),i.then(()=>{a.delete(i),a.size===0&&n.get(s)===a&&n.delete(s)})},q=(e,o,t)=>{const{heartbeats:n,leaves:r}=A(e),s=D(o),d=[...n.get(s)??[]],i=d.length===0?h(t):Promise.all(d).then(async()=>h(t));r.set(s,i),i.then(()=>{r.get(s)===i&&r.delete(s)})},k=new WeakMap,z=(e,o)=>{const t=k.get(e)??new Map,n=D(o);k.set(e,t),t.set(n,(t.get(n)??0)+1);let r=!0;return()=>{if(!r)return!1;r=!1;const s=(t.get(n)??1)-1;return s>0?(t.set(n,s),!1):(t.delete(n),!0)}},B=(e,o)=>{let t;return e.onConnectionStatus(n=>{const r=t!==void 0&&t!=="connected";t=n,r&&n==="connected"&&o()})},J=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,o=>o.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},O=1e4,$=(e,o,t)=>{const{heartbeat:n,intervalMs:r=O,leave:s,listPresent:d,shardKey:i}=t;j(r);const a=t.sessionId??J();let w=t.data,m=!1,I="";const l=()=>{const c={roomId:I,sessionId:a,...w===void 0?{}:{data:w}};_(e,{roomId:I,sessionId:a,shardKey:i},async()=>e.mutation(n,c,{onlineOnly:!0,shardKey:i}))},V=c=>{w=c,m&&l()},C=()=>{typeof document<"u"&&document.visibilityState==="visible"&&l()};let E;L()&&(E=M(o,c=>{I=c,m=!0,l();const y=setInterval(l,r);typeof document<"u"&&document.addEventListener("visibilitychange",C);const v=e.acquireConnectionContext({roomId:c,sessionId:a},{shardKey:i}),g=z(e,{roomId:c,sessionId:a,shardKey:i}),S=B(e,l);return()=>{m=!1,clearInterval(y),typeof document<"u"&&document.removeEventListener("visibilitychange",C),S(),v(),g()&&s!==void 0&&q(e,{roomId:c,sessionId:a,shardKey:i},async()=>e.mutation(s,{roomId:c,sessionId:a},{onlineOnly:!0,shardKey:i}))}}));const p=K();let u=!1;const x=()=>u;let R;const H=N(void 0,c=>{if(!L()||u)return;const y=M(o,S=>{if(u)return()=>{};c(void 0),p.set(void 0);let f=!0;const U=e.subscribe(d,{roomId:S},b=>{f&&(c(b),p.set(void 0))},{onError:b=>{f&&(p.set(b),t.onError?.(b))},shardKey:i});return x()?(f=!1,U(),()=>{}):()=>{f=!1,U()}});let v=!1;const g=()=>{v||(v=!0,R=void 0,y())};return R=g,g}),P=()=>{u||(u=!0,m=!1,E?.(),R?.())};try{F(P)}catch{}return{error:{subscribe:p.subscribe},present:H,sessionId:a,setData:V,teardown:P}};function ee(e,o,t){const n=t!==void 0,r=n?e:T();return $(r,n?o:e,n?t:o)}export{ee as presence};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createQuerySubscription as u}from"@lunora/client/query";import{readable as d}from"svelte/store";import{i as b}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as v}from"./getLunoraClient-CIfxHhDm.mjs";import{i as y}from"./is-function-reference-abFdrAae.mjs";import{s as R}from"./subscribe-reactive-args-
|
|
1
|
+
import{createQuerySubscription as u}from"@lunora/client/query";import{readable as d}from"svelte/store";import{i as b}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as v}from"./getLunoraClient-CIfxHhDm.mjs";import{i as y}from"./is-function-reference-abFdrAae.mjs";import{s as R}from"./subscribe-reactive-args-ClWd3Rut.mjs";function q(o,i,t,s){const r=!y(o),a=r?o:v(),c=r?i:o,p=r?t:i,n=(r?s:t)??{};return d(void 0,e=>b()?R(p,f=>(e(void 0),u(a,c,f,{onData:m=>{e(m)},onError:n.onError,onReset:()=>{e(void 0)}},{shardKey:n.shardKey}))):()=>{})}export{q as query};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{stableWireKey as a}from"@lunora/wire";const y=t=>typeof t?.subscribe=="function",h=(t,o)=>{if(!y(t))return o(t);let r=()=>{},i=!1,s,l,u=!0,n;const c=t.subscribe(b=>{if(i){s=[b];return}i=!0;try{let e=[b];for(;e;){const f=a(e[0]);f!==l&&(l=f,r(),r=o(e[0])),e=s,s=void 0}}catch(e){if(!u)throw e;n=[e]}finally{i=!1}});if(u=!1,n!==void 0)throw c(),r(),n[0];return()=>{c(),r()}};export{y as i,h as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createQuerySubscription as g}from"@lunora/client/query";import{LunoraError as h}from"@lunora/errors";import{writable as y,readable as l}from"svelte/store";import{i as R}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as x}from"./getLunoraClient-CIfxHhDm.mjs";import{i as C}from"./is-function-reference-abFdrAae.mjs";import{s as L}from"./subscribe-reactive-args-
|
|
1
|
+
import{createQuerySubscription as g}from"@lunora/client/query";import{LunoraError as h}from"@lunora/errors";import{writable as y,readable as l}from"svelte/store";import{i as R}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as x}from"./getLunoraClient-CIfxHhDm.mjs";import{i as C}from"./is-function-reference-abFdrAae.mjs";import{s as L}from"./subscribe-reactive-args-ClWd3Rut.mjs";function z(r,n,a,i){const t=!C(r),c=t?r:x(),m=t?n:r,d=t?a:n,f=(t?i:a)??{},{shardKey:v,onError:p}=f,e=y();return{data:l(void 0,s=>{if(!R())return()=>{};const w=L(d,u=>(s(void 0),e.set(void 0),g(c,m,u,{onData:o=>{s(o),e.set(void 0)},onError:o=>{const b=Object.assign(o.code===void 0?new Error(o.message):new h(o.code,o.message),o.why===void 0?{}:{why:o.why});e.set(b),p?.(o)},onReset:()=>{s(void 0)}},{shardKey:v})));return()=>{w(),e.set(void 0)}}),error:{subscribe:e.subscribe}}}export{z as subscription};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/svelte",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.323",
|
|
4
4
|
"description": "Svelte adapter for Lunora — live stores, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/client": "^1.0.0-alpha.
|
|
57
|
+
"@lunora/client": "^1.0.0-alpha.303",
|
|
58
58
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
59
59
|
"@lunora/ratelimit": "^1.0.0-alpha.197",
|
|
60
60
|
"@lunora/wire": "1.0.0-alpha.6",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{reconcileOptimistic as R,maxSeq as _}from"@lunora/client";import{writable as l}from"svelte/store";import{i as b}from"./is-browser-BEdfLJHK.mjs";import{isClient as tt,NO_MUTATION_REF as et}from"./agent-CYV_xWD9.mjs";import{getLunoraClient as st}from"./getLunoraClient-CIfxHhDm.mjs";import{mutation as i}from"./mutation-Cvnei0Ke.mjs";import{stream as nt}from"./stream-CMEivEKF.mjs";const rt={__lunoraRef:""},at=(n,d)=>{const{api:a,cancel:p,limit:g,onError:v,send:C,sendArgs:E,stream:S,threadKey:r}=d,I=i(n,C),G=i(n,p??et),q=i(n,a.agents.agentResolveApproval),j=i(n,a.agents.agentRevokeApprovalGrant),D=i(n,a.agents.agentSupplySecret),F=i(n,a.agents.agentDeclineSecret);let m,o=[],u=[],w=[],k=0;const y=l([]),x=l(),A=l([]),T=l(""),h=()=>{const t=R(u,o);if(t.length===0){y.set(o);return}const e=_(o);y.set([...o,...t.map((s,c)=>({content:s.content,optimistic:!0,role:"user",seq:e+1+c}))])},M=()=>{const t=o.filter(s=>s.role==="assistant").length,e=w.filter(s=>s.kind!=="progress"&&s.threadKey===r&&s.turn>=t).map(s=>s.text).join("");T.set(e)},N=S===void 0?"skip":{key:r},H=b()?nt(n,S??rt,N).chunks.subscribe(t=>{w=t,M()}):()=>{},K=g===void 0?{key:r}:{key:r,limit:g},B=b()?n.subscribe(a.agents.agentMessages,K,t=>{o=t,h(),M()},{onError:v}):()=>{},L=b()?n.subscribe(a.agents.agentThread,{key:r},t=>{m=t,x.set(m?.status)},{onError:v}):()=>{},O=b()?n.subscribe(a.agents.agentApprovalGrants,{key:r},t=>{A.set(t)},{onError:v}):()=>{},U=async(t,e)=>{const s=k;k+=1;const c=_(o);u=[...R(u,o),{content:t,id:s,maxDurableSeqAtSend:c}],h();try{await I.mutate({input:t,threadKey:r,...E,...e})}catch(Y){throw u=u.filter(Z=>Z.id!==s),h(),Y}},f=async(t,e,s)=>{const c=m?.instanceId;if(c===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await q.mutate({decision:t,instanceId:c,threadKey:r,toolCallId:e,...s===void 0?{}:{note:s}})},$=async(t,e)=>f("approve",t,e),z=async(t,e)=>f("approve_for_thread",t,e),J=async(t,e)=>f("reject",t,e),P=async t=>{await j.mutate({threadKey:r,toolName:t})},Q=async(t,e)=>{await D.mutate({secret:e,threadKey:r,toolCallId:t},{onlineOnly:!0})},V=async t=>{await F.mutate({threadKey:r,toolCallId:t})},W=async()=>{const t=m?.instanceId;p===void 0||t===void 0||await G.mutate({instanceId:t,threadKey:r})},X=()=>{B(),L(),O(),H()};return{approvalGrants:{subscribe:A.subscribe},approve:$,approveForThread:z,cancel:W,declineSecret:V,messages:{subscribe:y.subscribe},reject:J,revokeGrant:P,send:U,status:{subscribe:x.subscribe},streamingText:{subscribe:T.subscribe},supplySecret:Q,teardown:X}};function bt(n,d){const a=tt(n),p=a?n:st();return at(p,a?d:n)}export{bt as agentChat};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{derived as y}from"svelte/store";import{isClient as E}from"./agent-CYV_xWD9.mjs";import{getLunoraClient as I}from"./getLunoraClient-CIfxHhDm.mjs";import{stream as N}from"./stream-CMEivEKF.mjs";import{subscription as m}from"./subscription-DSyycrP7.mjs";const _={__lunoraRef:""},h={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},k=t=>{const o=t.status===void 0?void 0:h[t.status];if(o!==void 0)return{seq:t.seq,type:o,...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}},q=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(r=>({input:r.input,seq:t.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(t.role!=="tool")return;const o=k(t);return o!==void 0?[o]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]};function x(t,o){const r=E(t),a=r?t:I(),s=r?o:t,{api:u,limit:e,stream:i,threadKey:l}=s,p=e===void 0?{key:l}:{key:l,limit:e},{data:c}=m(a,u.agents.agentMessages,p),v=N(a,i??_,i===void 0?"skip":{key:l});return{events:y([c,v.chunks],([f,C])=>{const d=(f??[]).flatMap(n=>q(n)??[]);for(const n of C)n.kind==="progress"&&n.threadKey===l&&d.push({data:n.data,toolCallId:n.toolCallId,type:"progress"});return d})}}export{x as agentToolEvents};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{onDestroy as I}from"svelte";import{writable as S,readable as U}from"svelte/store";import{i as h}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as C}from"./getLunoraClient-CIfxHhDm.mjs";const D=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(e)}`)},L=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},V=1e4,x=(e,t,n)=>{const{heartbeat:r,intervalMs:s=V,listPresent:y,shardKey:i}=n;D(s);const d=n.sessionId??L();let f=n.data,u=!1;const a=()=>{const o={roomId:t,sessionId:d,...f===void 0?{}:{data:f}};e.mutation(r,o,{shardKey:i}).catch(()=>{})},w=o=>{f=o,u&&a()},p=()=>{typeof document<"u"&&document.visibilityState==="visible"&&a()};let l,b;h()&&(u=!0,a(),l=setInterval(a,s),typeof document<"u"&&document.addEventListener("visibilitychange",p),b=e.acquireConnectionContext({roomId:t,sessionId:d},{shardKey:i}));const m=S(),E=U(void 0,o=>{if(h())return e.subscribe(y,{roomId:t},c=>{o(c),m.set(void 0)},{onError:c=>{m.set(c),n.onError?.(c)},shardKey:i})});let v=!1;const g=()=>{v||(v=!0,u=!1,l!==void 0&&clearInterval(l),typeof document<"u"&&document.removeEventListener("visibilitychange",p),b?.())};try{I(g)}catch{}return{error:{subscribe:m.subscribe},present:E,sessionId:d,setData:w,teardown:g}};function F(e,t,n){const r=typeof e!="string",s=r?e:C();return x(s,r?t:e,r?n:t)}export{F as presence};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{stableWireKey as c}from"@lunora/wire";const f=e=>typeof e?.subscribe=="function",y=(e,n)=>{if(!f(e))return n(e);let s=()=>{},i=!1,r,o;const b=e.subscribe(u=>{if(i){r=[u];return}i=!0;try{let t=[u];for(;t;){const l=c(t[0]);l!==o&&(o=l,s(),s=n(t[0])),t=r,r=void 0}}finally{i=!1}});return()=>{b(),s()}};export{f as i,y as s};
|