@lunora/svelte 1.0.0-alpha.76 → 1.0.0-alpha.78
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 +45 -1
- package/dist/index.d.ts +45 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/agent-Dm21Qhs8.mjs +1 -0
- package/dist/packem_shared/agentChat-F7JKdcTl.mjs +1 -0
- package/dist/packem_shared/agentState-BRG5S1NA.mjs +1 -0
- package/dist/packem_shared/agentToolEvents-Csl7lIkN.mjs +1 -0
- package/dist/packem_shared/auth-Bew4W5n1.mjs +1 -0
- package/dist/packem_shared/connectionStatus-D9A79Eqw.mjs +1 -0
- package/dist/packem_shared/flag-DcmqSR3D.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-CW7Ak8zY.mjs +1 -0
- package/dist/packem_shared/infiniteQuery-YtwM_Ac1.mjs +1 -0
- package/dist/packem_shared/is-function-reference-abFdrAae.mjs +1 -0
- package/dist/packem_shared/mutation-YVfTQTn9.mjs +1 -0
- package/dist/packem_shared/mutator-DECDuo94.mjs +1 -0
- package/dist/packem_shared/presence-BaJ2XOzF.mjs +1 -0
- package/dist/packem_shared/query-Bsh9h9vB.mjs +1 -0
- package/dist/packem_shared/rateLimit-Cli38qWO.mjs +1 -0
- package/dist/packem_shared/stream-eY1eAuVw.mjs +1 -0
- package/dist/packem_shared/subscription-MIh5Yd8c.mjs +1 -0
- package/dist/packem_shared/voiceAgent-D2xy_oRK.mjs +1 -0
- package/package.json +4 -8
- package/dist/packem_shared/agent-CddTbgxO.mjs +0 -1
- package/dist/packem_shared/agentChat-BmvA3u8B.mjs +0 -1
- package/dist/packem_shared/agentState-fc7KRCp9.mjs +0 -1
- package/dist/packem_shared/agentToolEvents-sOUvSZsy.mjs +0 -1
- package/dist/packem_shared/auth-BWCPnv0n.mjs +0 -1
- package/dist/packem_shared/connectionStatus-BHVAskxU.mjs +0 -1
- package/dist/packem_shared/flag-5trRaaSv.mjs +0 -1
- package/dist/packem_shared/hydratePreloaded-Bbm6vwbA.mjs +0 -1
- package/dist/packem_shared/infiniteQuery-s_5r8MQZ.mjs +0 -1
- package/dist/packem_shared/is-function-reference-ByqJF30w.mjs +0 -1
- package/dist/packem_shared/mutation-fa0Bj5Bo.mjs +0 -1
- package/dist/packem_shared/mutator-cvH3UrNm.mjs +0 -1
- package/dist/packem_shared/presence-C2YC1KOc.mjs +0 -1
- package/dist/packem_shared/query-BEQBdOJ2.mjs +0 -1
- package/dist/packem_shared/rateLimit-DtykU7F_.mjs +0 -1
- package/dist/packem_shared/stream-DItOnXt6.mjs +0 -1
- package/dist/packem_shared/subscription-Dbz9sy8N.mjs +0 -1
- package/dist/packem_shared/voiceAgent-CPQvbrxT.mjs +0 -1
- package/dist/worker.d.mts +0 -1
- package/dist/worker.d.ts +0 -1
- package/dist/worker.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1061,4 +1061,48 @@ interface VoiceAgentHandle {
|
|
|
1061
1061
|
*/
|
|
1062
1062
|
declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1063
1063
|
declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1064
|
-
export { type AgentApi, 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 FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, 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 StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1064
|
+
export { type AgentApi, 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 FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, 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 StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1065
|
+
/**
|
|
1066
|
+
* Svelte adapter for Lunora (`@lunora/svelte`).
|
|
1067
|
+
*
|
|
1068
|
+
* Thin, idiomatic glue over the framework-neutral `@lunora/client` (no React):
|
|
1069
|
+
* live readable stores you read with `$store`, an optimistic mutation helper,
|
|
1070
|
+
* and the reactive-loader handoff (`hydratePreloaded`). The contract mirrors
|
|
1071
|
+
* `@lunora/react`, re-expressed in Svelte stores: `setLunoraClient` /
|
|
1072
|
+
* `getLunoraClient` are the context provider/consumer; `query` is a live
|
|
1073
|
+
* readable store (React's `useQuery`); `mutation` is an optimistic
|
|
1074
|
+
* `{ data, error, pending, mutate, reset }` (React's `useMutation`); and
|
|
1075
|
+
* `hydratePreloaded` is the SSR-seed-to-live-store handoff (React's
|
|
1076
|
+
* `usePreloadedQuery`).
|
|
1077
|
+
*
|
|
1078
|
+
* The package is plain `.ts` over stores — no `.svelte` component compiler is
|
|
1079
|
+
* required to build or test it.
|
|
1080
|
+
*
|
|
1081
|
+
* Server-side preload helpers (`createServerClient`, `preloadQuery`) live in the
|
|
1082
|
+
* socket-free `@lunora/svelte/server` entry (a re-export of `@lunora/client/ssr`, the
|
|
1083
|
+
* framework-neutral server contract) — import them there in your SvelteKit
|
|
1084
|
+
* `+page.ts` / `+layout.ts` load.
|
|
1085
|
+
*/
|
|
1086
|
+
getLunoraClient, hydratePreloaded, infiniteQuery, mutation, mutator, paginatedQuery, presence, query, rateLimit,
|
|
1087
|
+
/**
|
|
1088
|
+
* Svelte adapter for Lunora (`@lunora/svelte`).
|
|
1089
|
+
*
|
|
1090
|
+
* Thin, idiomatic glue over the framework-neutral `@lunora/client` (no React):
|
|
1091
|
+
* live readable stores you read with `$store`, an optimistic mutation helper,
|
|
1092
|
+
* and the reactive-loader handoff (`hydratePreloaded`). The contract mirrors
|
|
1093
|
+
* `@lunora/react`, re-expressed in Svelte stores: `setLunoraClient` /
|
|
1094
|
+
* `getLunoraClient` are the context provider/consumer; `query` is a live
|
|
1095
|
+
* readable store (React's `useQuery`); `mutation` is an optimistic
|
|
1096
|
+
* `{ data, error, pending, mutate, reset }` (React's `useMutation`); and
|
|
1097
|
+
* `hydratePreloaded` is the SSR-seed-to-live-store handoff (React's
|
|
1098
|
+
* `usePreloadedQuery`).
|
|
1099
|
+
*
|
|
1100
|
+
* The package is plain `.ts` over stores — no `.svelte` component compiler is
|
|
1101
|
+
* required to build or test it.
|
|
1102
|
+
*
|
|
1103
|
+
* Server-side preload helpers (`createServerClient`, `preloadQuery`) live in the
|
|
1104
|
+
* socket-free `@lunora/svelte/server` entry (a re-export of `@lunora/client/ssr`, the
|
|
1105
|
+
* framework-neutral server contract) — import them there in your SvelteKit
|
|
1106
|
+
* `+page.ts` / `+layout.ts` load.
|
|
1107
|
+
*/
|
|
1108
|
+
setLunoraClient, stream, subscription, voiceAgent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1061,4 +1061,48 @@ interface VoiceAgentHandle {
|
|
|
1061
1061
|
*/
|
|
1062
1062
|
declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1063
1063
|
declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1064
|
-
export { type AgentApi, 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 FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, 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 StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1064
|
+
export { type AgentApi, 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 FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, 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 StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1065
|
+
/**
|
|
1066
|
+
* Svelte adapter for Lunora (`@lunora/svelte`).
|
|
1067
|
+
*
|
|
1068
|
+
* Thin, idiomatic glue over the framework-neutral `@lunora/client` (no React):
|
|
1069
|
+
* live readable stores you read with `$store`, an optimistic mutation helper,
|
|
1070
|
+
* and the reactive-loader handoff (`hydratePreloaded`). The contract mirrors
|
|
1071
|
+
* `@lunora/react`, re-expressed in Svelte stores: `setLunoraClient` /
|
|
1072
|
+
* `getLunoraClient` are the context provider/consumer; `query` is a live
|
|
1073
|
+
* readable store (React's `useQuery`); `mutation` is an optimistic
|
|
1074
|
+
* `{ data, error, pending, mutate, reset }` (React's `useMutation`); and
|
|
1075
|
+
* `hydratePreloaded` is the SSR-seed-to-live-store handoff (React's
|
|
1076
|
+
* `usePreloadedQuery`).
|
|
1077
|
+
*
|
|
1078
|
+
* The package is plain `.ts` over stores — no `.svelte` component compiler is
|
|
1079
|
+
* required to build or test it.
|
|
1080
|
+
*
|
|
1081
|
+
* Server-side preload helpers (`createServerClient`, `preloadQuery`) live in the
|
|
1082
|
+
* socket-free `@lunora/svelte/server` entry (a re-export of `@lunora/client/ssr`, the
|
|
1083
|
+
* framework-neutral server contract) — import them there in your SvelteKit
|
|
1084
|
+
* `+page.ts` / `+layout.ts` load.
|
|
1085
|
+
*/
|
|
1086
|
+
getLunoraClient, hydratePreloaded, infiniteQuery, mutation, mutator, paginatedQuery, presence, query, rateLimit,
|
|
1087
|
+
/**
|
|
1088
|
+
* Svelte adapter for Lunora (`@lunora/svelte`).
|
|
1089
|
+
*
|
|
1090
|
+
* Thin, idiomatic glue over the framework-neutral `@lunora/client` (no React):
|
|
1091
|
+
* live readable stores you read with `$store`, an optimistic mutation helper,
|
|
1092
|
+
* and the reactive-loader handoff (`hydratePreloaded`). The contract mirrors
|
|
1093
|
+
* `@lunora/react`, re-expressed in Svelte stores: `setLunoraClient` /
|
|
1094
|
+
* `getLunoraClient` are the context provider/consumer; `query` is a live
|
|
1095
|
+
* readable store (React's `useQuery`); `mutation` is an optimistic
|
|
1096
|
+
* `{ data, error, pending, mutate, reset }` (React's `useMutation`); and
|
|
1097
|
+
* `hydratePreloaded` is the SSR-seed-to-live-store handoff (React's
|
|
1098
|
+
* `usePreloadedQuery`).
|
|
1099
|
+
*
|
|
1100
|
+
* The package is plain `.ts` over stores — no `.svelte` component compiler is
|
|
1101
|
+
* required to build or test it.
|
|
1102
|
+
*
|
|
1103
|
+
* Server-side preload helpers (`createServerClient`, `preloadQuery`) live in the
|
|
1104
|
+
* socket-free `@lunora/svelte/server` entry (a re-export of `@lunora/client/ssr`, the
|
|
1105
|
+
* framework-neutral server contract) — import them there in your SvelteKit
|
|
1106
|
+
* `+page.ts` / `+layout.ts` load.
|
|
1107
|
+
*/
|
|
1108
|
+
setLunoraClient, stream, subscription, voiceAgent };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{agent as o}from"./packem_shared/agent-
|
|
1
|
+
import{agent as o}from"./packem_shared/agent-Dm21Qhs8.mjs";import{agentChat as a}from"./packem_shared/agentChat-F7JKdcTl.mjs";import{agentState as f}from"./packem_shared/agentState-BRG5S1NA.mjs";import{agentToolEvents as n}from"./packem_shared/agentToolEvents-Csl7lIkN.mjs";import{auth as i,authGate as u}from"./packem_shared/auth-Bew4W5n1.mjs";import{connectionStatus as s}from"./packem_shared/connectionStatus-D9A79Eqw.mjs";import{getLunoraClient as c,setLunoraClient as d}from"./packem_shared/getLunoraClient-DU7BmZy1.mjs";import{flag as y,flags as C}from"./packem_shared/flag-DcmqSR3D.mjs";import{hydratePreloaded as v}from"./packem_shared/hydratePreloaded-CW7Ak8zY.mjs";import{mutation as S}from"./packem_shared/mutation-YVfTQTn9.mjs";import{mutator as q}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as E,paginatedQuery as G}from"./packem_shared/infiniteQuery-YtwM_Ac1.mjs";import{presence as T}from"./packem_shared/presence-BaJ2XOzF.mjs";import{query as k}from"./packem_shared/query-Bsh9h9vB.mjs";import{rateLimit as z}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as D}from"./packem_shared/stream-eY1eAuVw.mjs";import{subscription as H}from"./packem_shared/subscription-MIh5Yd8c.mjs";import{voiceAgent as J}from"./packem_shared/voiceAgent-D2xy_oRK.mjs";export{o as agent,a as agentChat,f as agentState,n as agentToolEvents,i as auth,u as authGate,s as connectionStatus,y as flag,C as flags,c as getLunoraClient,v as hydratePreloaded,E as infiniteQuery,S as mutation,q as mutator,G as paginatedQuery,T as presence,k as query,z as rateLimit,d as setLunoraClient,D as stream,H as subscription,J as voiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writable as d}from"svelte/store";import{i as R}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as T}from"./getLunoraClient-DU7BmZy1.mjs";import{mutation as f}from"./mutation-YVfTQTn9.mjs";const _={__lunoraRef:""},A=t=>typeof t=="object"&&t!==null&&typeof t.subscribe=="function",C=(t,r)=>{const{api:e,cancel:s,run:a,runArgs:m,threadKey:c}=r,i=f(t,a),p=f(t,s??_);let o;const u=d(),b=d(),l=R()?t.subscribe(e.agents.agentThread,{key:c},n=>{o=n,u.set(o),b.set(o?.status)}):()=>{},g=async(n,w)=>{await i.mutate({input:n,threadKey:c,...m,...w})},h=async()=>{const n=o?.instanceId;s===void 0||n===void 0||await p.mutate({instanceId:n,threadKey:c})},y=()=>{l()};return{cancel:h,pending:i.pending,run:g,status:{subscribe:b.subscribe},teardown:y,thread:{subscribe:u.subscribe}}};function N(t,r){const e=A(t),s=e?t:T();return C(s,e?r:t)}export{_ as NO_MUTATION_REF,N as agent,A as isClient};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{reconcileOptimistic as R,maxSeq as k}from"@lunora/client";import{writable as g}from"svelte/store";import{i as f}from"./is-browser-BEdfLJHK.mjs";import{isClient as G,NO_MUTATION_REF as J}from"./agent-Dm21Qhs8.mjs";import{getLunoraClient as O}from"./getLunoraClient-DU7BmZy1.mjs";import{mutation as h}from"./mutation-YVfTQTn9.mjs";import{stream as P}from"./stream-eY1eAuVw.mjs";const Q={__lunoraRef:""},V=(n,d)=>{const{api:a,cancel:u,limit:l,send:C,sendArgs:I,stream:v,threadKey:r}=d,E=h(n,C),M=h(n,u??J),_=h(n,a.agents.agentResolveApproval);let m,o=[],i=[],y=[],x=0;const b=g([]),S=g(),w=g(""),p=()=>{const t=R(i,o);if(t.length===0){b.set(o);return}const s=k(o);b.set([...o,...t.map((e,c)=>({content:e.content,optimistic:!0,role:"user",seq:s+1+c}))])},A=()=>{const t=o.filter(e=>e.role==="assistant").length,s=y.filter(e=>e.kind!=="progress"&&e.threadKey===r&&e.turn>=t).map(e=>e.text).join("");w.set(s)},q=v===void 0?"skip":{key:r},j=f()?P(n,v??Q,q).chunks.subscribe(t=>{y=t,A()}):()=>{},N=l===void 0?{key:r}:{key:r,limit:l},D=f()?n.subscribe(a.agents.agentMessages,N,t=>{o=t,p(),A()}):()=>{},F=f()?n.subscribe(a.agents.agentThread,{key:r},t=>{m=t,S.set(m?.status)}):()=>{},H=async(t,s)=>{const e=x;x+=1;const c=k(o);i=[...R(i,o),{content:t,id:e,maxDurableSeqAtSend:c}],p();try{await E.mutate({input:t,threadKey:r,...I,...s})}catch($){throw i=i.filter(z=>z.id!==e),p(),$}},T=async(t,s,e)=>{const c=m?.instanceId;if(c===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await _.mutate({decision:t,instanceId:c,threadKey:r,toolCallId:s,...e===void 0?{}:{note:e}})},K=async(t,s)=>T("approve",t,s),B=async(t,s)=>T("reject",t,s),L=async()=>{const t=m?.instanceId;u===void 0||t===void 0||await M.mutate({instanceId:t,threadKey:r})},U=()=>{D(),F(),j()};return{approve:K,cancel:L,messages:{subscribe:b.subscribe},reject:B,send:H,status:{subscribe:S.subscribe},streamingText:{subscribe:w.subscribe},teardown:U}};function nt(n,d){const a=G(n),u=a?n:O();return V(u,a?d:n)}export{nt as agentChat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{derived as c}from"svelte/store";import{isClient as p}from"./agent-Dm21Qhs8.mjs";import{getLunoraClient as f}from"./getLunoraClient-DU7BmZy1.mjs";import{subscription as d}from"./subscription-MIh5Yd8c.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 m}from"./agent-Dm21Qhs8.mjs";import{getLunoraClient as I}from"./getLunoraClient-DU7BmZy1.mjs";import{stream as N}from"./stream-eY1eAuVw.mjs";import{subscription as h}from"./subscription-MIh5Yd8c.mjs";const k={__lunoraRef:""},q=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(l=>({input:l.input,seq:t.seq,toolCallId:l.id,toolName:l.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]};function K(t,l){const n=m(t),a=n?t:I(),u=n?l:t,{api:p,limit:e,stream:i,threadKey:r}=u,s=e===void 0?{key:r}:{key:r,limit:e},{data:c}=h(a,p.agents.agentMessages,s),v=N(a,i??k,i===void 0?"skip":{key:r});return{events:y([c,v.chunks],([f,C])=>{const d=(f??[]).flatMap(o=>q(o)??[]);for(const o of C)o.kind==="progress"&&o.threadKey===r&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}}export{K as agentToolEvents};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getIdentityStore as a}from"@lunora/client/auth";import{readable as c,derived as i}from"svelte/store";import{getLunoraClient as g}from"./getLunoraClient-DU7BmZy1.mjs";const h=r=>{const e=r??g(),n=a(e),s=c(e.getAuthToken(),t=>(t(e.getAuthToken()),e.onAuthTokenChange(l=>{t(l)}))),u=c(n.getUser(),t=>(t(n.getUser()),n.subscribe(()=>{t(n.getUser())})));return{setToken:t=>{e.setAuthToken(t)},token:s,user:u}},A=r=>{const{token:e,user:n}=h(r),s=i([e,n],([o,t])=>o!==null&&t===null);return{isAuthenticated:i([e,n],([o,t])=>o!==null&&t!==null),isLoading:s}};export{h as auth,A as authGate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readable as r}from"svelte/store";import{getLunoraClient as c}from"./getLunoraClient-DU7BmZy1.mjs";const u=o=>{const t=o??c();return r(t.connectionStatus(),n=>(n(t.connectionStatus()),t.onConnectionStatus(e=>{n(e)})))};export{u as connectionStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readable as l}from"svelte/store";import{isClient as b}from"./agent-Dm21Qhs8.mjs";import{getLunoraClient as p}from"./getLunoraClient-DU7BmZy1.mjs";const g="__lunora_flags__:eval",h=n=>{const t=typeof n;return t==="boolean"||t==="number"||t==="string"?t:"object"},v={__lunoraRef:g},_=(n,t,e,s,o)=>{try{return n.subscribe(v,{context:s,default:e,key:t,type:h(e)},c=>{o(c)})}catch{return()=>{}}};function L(n,t,e,s){const o=b(n),c=o?n:p(),a=o?t:n,i=o?e:t,r=(o?s:e)??void 0;return l(i,u=>_(c,a,i,r,u))}function j(n,t,e){const s=b(n),o=s?n:p(),c=s?t:n,a=(s?e:t)??void 0;return l(c,i=>{let r={...c};const u=[];for(const[f,m]of Object.entries(c))u.push(_(o,f,m,a,d=>{r={...r,[f]:d},i(r)}));return()=>{for(const f of u)f()}})}export{L as flag,j as flags};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readable as u}from"svelte/store";import{getLunoraClient as d}from"./getLunoraClient-DU7BmZy1.mjs";const b=(e,r)=>{const o=r??d(),{args:t,functionPath:n,shardKey:a,value:s}=e,c={__lunoraRef:n};return u(s,i=>o.subscribe(c,t,l=>{i(l)},{shardKey:a}))};export{b as hydratePreloaded};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{initialPages as U,derivePaginationStatus as J,applyLoadMore as G,rebalance as H}from"@lunora/client/pagination";import{derived as j,writable as W,readable as V,get as L}from"svelte/store";import{getLunoraClient as F}from"./getLunoraClient-DU7BmZy1.mjs";import{i as Q}from"./is-function-reference-abFdrAae.mjs";const X=(e,n)=>e<n?-1:e>n?1:0,B=e=>{if(e===void 0)return"null";if(typeof e=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t=>B(t)).join(",")}]`;const n=Object.getPrototypeOf(e);if(n!==null&&n!==Object.prototype){const t=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${t} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const f=e,u=Object.keys(f).toSorted(X),o=[];for(const t of u){const r=f[t];r!==void 0&&o.push(`${JSON.stringify(t)}:${B(r)}`)}return`{${o.join(",")}}`},I=e=>{let n="";for(let u=0;u<e.length;u+=32768)n+=String.fromCharCode(...e.subarray(u,u+32768));return btoa(n)},l="$lunora.wire$",D=64,Y="__proto__",Z=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},R=(e,n=0)=>{if(n>D)throw new RangeError(`wire-codec: value nesting exceeds the ${D}-level limit`);if(e===void 0)return[l,"undefined"];if(e===null)return null;const f=typeof e;if(f==="bigint")return[l,"bigint",e.toString()];if(f==="number"){const t=e;return Number.isNaN(t)?[l,"nan"]:t===1/0?[l,"inf"]:t===-1/0?[l,"-inf"]:t}if(f!=="object")return e;if(e instanceof Date)return[l,"date",R(e.getTime(),n+1)];if(e instanceof Error){const t=e,r={};for(const i of Object.keys(t))t[i]!==void 0&&(r[i]=R(t[i],n+1));const s=[l,"error",t.name,t.message,r];return t.cause!==void 0&&s.push(R(t.cause,n+1)),s}if(e instanceof URL)return[l,"url",e.href];if(e instanceof Map)return[l,"map",[...e.entries()].map(([t,r])=>[R(t,n+1),R(r,n+1)])];if(e instanceof Set)return[l,"set",[...e].map(t=>R(t,n+1))];if(e instanceof ArrayBuffer)return[l,"bytes",I(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,r=t.constructor.name,s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return r==="Uint8Array"?[l,"bytes",I(s)]:[l,"bytes",I(s),r]}if(Array.isArray(e)){const t=e.map(r=>R(r,n+1));return t.length>0&&t[0]===l?[l,"arr",t]:t}if(!Z(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const u=e,o={};for(const t of Object.keys(u)){const r=u[t];if(r===void 0)continue;const s=R(r,n+1);t===Y?Object.defineProperty(o,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):o[t]=s}return o},v=e=>B(R(e)),E=(e,n)=>({...n,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),K=(e,n)=>`${e}::${v(n)}`,q=(e,n,f,u)=>{const{initialNumItems:o,shardKey:t}=u,r=W(U(o)),s=W([]),i=new Map,d=new Map,k=new Set,a=f,p=()=>{if(a==="skip"){s.set([]);return}const y=L(r).map(m=>{const P=K(n.__lunoraRef,E(m,a));return i.get(P)});s.set(y)},$=(y,m)=>{if(a==="skip")return;const P=c=>K(n.__lunoraRef,E(c,a));for(const c of m){const w=P(c);if(i.has(w))continue;const g=y.find(h=>h.lower===c.lower);if(g){const h=i.get(P(g));h&&i.set(w,h)}}},S=()=>{if(a==="skip"){for(const c of d.values())c();d.clear(),s.set([]);return}const y=a,m=L(r),P=new Set;for(const c of m)P.add(K(n.__lunoraRef,E(c,y)));for(const[c,w]of d)P.has(c)||(w(),d.delete(c),k.delete(c),i.delete(c));for(const c of m){const w=E(c,y),g=K(n.__lunoraRef,w);if(d.has(g))continue;k.add(g);const h=e.subscribe(n,w,O=>{if(i.set(g,O),k.delete(g),p(),k.size===0){const M=L(r),N=H(M,L(s));N&&($(M,N),r.set(N),C(),p())}},{shardKey:t});d.set(g,h)}};let A=!1,x=!1;const C=()=>{if(A){x=!0;return}A=!0;try{do x=!1,S();while(x)}finally{A=!1}},b=()=>{for(const y of d.values())y();d.clear(),i.clear(),k.clear()},_=V([],y=>{const m=s.subscribe(y);return a!=="skip"&&(C(),p()),()=>{m(),b(),r.set(U(o)),s.set([])}}),z=j(_,y=>J(a==="skip",y).status);return{loadMore:y=>{if(a==="skip")return;const m=L(s),{nextCursor:P,status:c}=J(!1,m);if(c!=="CanLoadMore")return;const w=L(r),g=G(w,P,y);if(!g)return;const h=w.at(-1),O=g.at(-2);if(h&&O){const M=K(n.__lunoraRef,E(h,a)),N=K(n.__lunoraRef,E(O,a));if(M!==N){const T=i.get(M);T&&(i.set(N,T),i.delete(M))}}r.set(g),C(),p()},pageResults:_,status:z}};function oe(e,n,f,u){const o=!Q(e),t=o?e:F(),r=o?n:e,s=o?f:n,i=o?u:f,{loadMore:d,pageResults:k,status:a}=q(t,r,s,i),p=j(k,S=>S.flatMap(A=>A?.page??[]));return{isLoading:j(a,S=>S==="LoadingFirstPage"||S==="LoadingMore"),loadMore:d,results:p,status:a}}function ie(e,n,f,u){const o=!Q(e),t=o?e:F(),r=o?n:e,s=o?f:n,i=o?u:f,{initialNumItems:d}=i,{loadMore:k,pageResults:a,status:p}=q(t,r,s,i),$=j(a,b=>b.flatMap(_=>_?[_.page]:[])),S=j(p,b=>b==="LoadingFirstPage"),A=j(p,b=>b==="CanLoadMore"),x=j(p,b=>b==="LoadingMore");return{fetchNextPage:b=>{k(b??d)},hasNextPage:A,isFetchingNextPage:x,isLoading:S,pages:$,status:p}}export{ie as infiniteQuery,oe as paginatedQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=e=>typeof e=="object"&&e!==null&&typeof e.__lunoraRef=="string";export{n as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createMutationRunner as m}from"@lunora/client";import{writable as s}from"svelte/store";import{getLunoraClient as u}from"./getLunoraClient-DU7BmZy1.mjs";function R(n,r){const i=r!==void 0,a=i?n:u(),d=i?r:n,o=s(),e=s(),c=s(!1),f=m(a,d,{setError:t=>{e.set(t)},setPending:t=>{c.set(t)},setResult:t=>{o.set(t),e.set(void 0)}});return{data:o,error:e,mutate:f,pending:c,reset:()=>{o.set(void 0),e.set(void 0)}}}export{R as mutation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createMutatorRunner as c}from"@lunora/client";import{writable as o,derived as m}from"svelte/store";const p=n=>{const t=o(),e=o(!1),s=m(t,r=>r!==void 0),{mutate:i,reset:a}=c(n,{setError:r=>{t.set(r)},setPending:r=>{e.set(r)}});return{error:t,isError:s,mutate:i,pending:e,reset:a}};export{p as mutator};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{onDestroy as D}from"svelte";import{readable as C}from"svelte/store";import{i as v}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as S}from"./getLunoraClient-DU7BmZy1.mjs";const U=(t="sess")=>{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`${t}-${Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}`}}return`${t}-${Date.now().toString(36)}`},w=1e4,E=(t,e,n)=>{const{heartbeat:o,intervalMs:a=w,listPresent:u,shardKey:i}=n,c=n.sessionId??U();let d=n.data;const s=()=>{const r={roomId:e,sessionId:c,...d===void 0?{}:{data:d}};t.mutation(o,r,{shardKey:i}).catch(()=>{})},b=r=>{d=r,s()},l=()=>{typeof document<"u"&&document.visibilityState==="visible"&&s()};let f,y;v()&&(s(),f=setInterval(s,a),typeof document<"u"&&document.addEventListener("visibilitychange",l),y=t.acquireConnectionContext({roomId:e,sessionId:c},{shardKey:i}));const g=C(void 0,r=>{if(v())return t.subscribe(u,{roomId:e},h=>{r(h)},{shardKey:i})});let m=!1;const p=()=>{m||(m=!0,f!==void 0&&clearInterval(f),typeof document<"u"&&document.removeEventListener("visibilitychange",l),y?.())};try{D(p)}catch{}return{present:g,sessionId:c,setData:b,teardown:p}};function $(t,e,n){const o=typeof t!="string",a=o?t:S();return E(a,o?e:t,o?n:e)}export{$ as presence};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createQuerySubscription as m}from"@lunora/client/query";import{readable as d}from"svelte/store";import{getLunoraClient as y}from"./getLunoraClient-DU7BmZy1.mjs";import{i as h}from"./is-function-reference-abFdrAae.mjs";function b(r,e,t,a){const o=!h(r),s=o?r:y(),c=o?e:r,f=o?t:e,i=(o?a:t)??{};return d(void 0,n=>m(s,c,f,{onData:p=>{n(p)},onError:i.onError,onReset:()=>{n(void 0)}},{shardKey:i.shardKey}))}export{b as query};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{evaluate as v}from"@lunora/ratelimit";import{writable as y,derived as o}from"svelte/store";import{i as A}from"./is-browser-BEdfLJHK.mjs";const D=(n,f={})=>{const a=f.now??Date.now,k=f.tickMs??1e3;let e;const d=y(0),u=()=>{d.update(t=>t+1)},r=o(d,()=>v(n,e,{consume:!1,count:1,now:a(),reserve:!1}).status);let s;const c=()=>{s!==void 0&&(clearInterval(s),s=void 0)};let l=!0;const w=r.subscribe(t=>{l=t.ok}),m=()=>{l||s!==void 0||(s=setInterval(()=>{u(),l&&c()},k))};A()&&m();const p=(t=1)=>{const i=v(n,e,{consume:!0,count:t,now:a(),reserve:!1});return i.value!==void 0&&(e=i.value),u(),m(),i.status},b=(t=1)=>v(n,e,{consume:!1,count:t,now:a(),reserve:!1}).status.ok,I=()=>{e=void 0,c(),u()},h=()=>{c(),w()};return{check:b,consume:p,disabled:o(r,t=>!t.ok),ok:o(r,t=>t.ok),reset:I,retryAfter:o(r,t=>t.retryAfter),teardown:h}};export{D as rateLimit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writable as p,readable as S}from"svelte/store";import{getLunoraClient as g}from"./getLunoraClient-DU7BmZy1.mjs";import{i as R}from"./is-function-reference-abFdrAae.mjs";function L(c,u,f,h){const r=!R(c),v=r?c:g(),w=r?u:c,l=r?f:u,E=(r?h:f)??{},{maxBuffer:k,shardKey:x}=E,e=p("idle"),n=p();let s;const b=()=>{s?.()},y=S([],m=>{if(m([]),n.set(void 0),l==="skip")return e.set("idle"),()=>{};e.set("streaming");let o=!0,i=[];const d=v.stream(w,l,{maxBuffer:k,shardKey:x}),a=()=>{d.cancel()};return s=a,(async()=>{try{for await(const t of d){if(!o)return;i=[...i,t],m(i)}o&&e.set("complete")}catch(t){if(!o)return;n.set(t instanceof Error?t:new Error(String(t))),e.set("error")}})().catch(()=>{}),()=>{o=!1,a(),s===a&&(s=void 0)}}),C=()=>{b()};return{cancel:b,chunks:y,error:{subscribe:n.subscribe},status:{subscribe:e.subscribe},teardown:C}}export{L as stream};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createQuerySubscription as v}from"@lunora/client/query";import{writable as E,readable as R}from"svelte/store";import{getLunoraClient as h}from"./getLunoraClient-DU7BmZy1.mjs";import{i as w}from"./is-function-reference-abFdrAae.mjs";function D(e,s,n,a){const r=!w(e),b=r?e:h(),u=r?s:e,m=r?n:s,d=(r?a:n)??{},{shardKey:p,onError:f}=d,o=E();return{data:R(void 0,i=>{const l=v(b,u,m,{onData:t=>{i(t),o.set(void 0)},onError:t=>{const c=new Error(t.message);o.set(c),f?.(c)},onReset:()=>{i(void 0)}},{shardKey:p});return()=>{l(),o.set(void 0)}}),error:{subscribe:o.subscribe}}}export{D as subscription};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writable as A,get as I}from"svelte/store";import{isClient as P}from"./agent-Dm21Qhs8.mjs";import{getLunoraClient as W}from"./getLunoraClient-DU7BmZy1.mjs";const H=16e3,V=e=>{if(e.length===0)return 0;let o=0;for(const t of e)o+=t*t;return Math.sqrt(o/e.length)},q=(e,o)=>{const t=o/H,i=t>1?Math.floor(e.length/t):e.length,l=new ArrayBuffer(i*2),c=new DataView(l);for(let d=0;d<i;d+=1){const g=e[Math.floor(d*t)]??0,b=Math.max(-1,Math.min(1,g));c.setInt16(d*2,b<0?b*32768:b*32767,!0)}return new Uint8Array(l)},B=async e=>{const o=globalThis,t=o.navigator?.mediaDevices?.getUserMedia.bind(o.navigator.mediaDevices),i=o.AudioContext??o.webkitAudioContext;if(!t||!i)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const l=await t({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),c=new i,d=c.createMediaStreamSource(l),g=c.createScriptProcessor(4096,1,1);let b=!1,S=!1,h=0,r=0;return g.onaudioprocess=a=>{const p=a.inputBuffer.getChannelData(0),f=b?0:V(p);if(e.onLevel(f),b)return;if(e.onAudio(q(p,c.sampleRate)),e.isSpeaking()){r=f>=e.interruptThreshold?r+1:0,r>=e.interruptChunks&&(r=0,e.onInterrupt());return}r=0;const w=p.length/c.sampleRate*1e3;if(f>=e.silenceThreshold){S=!0,h=0;return}S&&(h+=w,h>=e.silenceDurationMs&&(S=!1,h=0,e.onSilence()))},d.connect(g),g.connect(c.destination),{setMuted:a=>{b=a},stop:()=>{g.disconnect(),d.disconnect();for(const a of l.getTracks())a.stop();c.close()}}},$=()=>{const e=globalThis,o=e.AudioContext??e.webkitAudioContext;if(!o)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const t=new o,i=new Set;let l=0,c=Promise.resolve(),d=0;const g=async(h,r)=>{if(r!==d)return;let a;try{a=await t.decodeAudioData(h.buffer)}catch{return}if(r!==d)return;const p=t.createBufferSource();p.buffer=a,p.connect(t.destination);const f=Math.max(t.currentTime,l);p.start(f),l=f+a.duration,i.add(p),p.onended=()=>{i.delete(p)}},b=h=>{const r=Uint8Array.from(h),a=d;c=c.then(()=>g(r,a))},S=()=>{d+=1;for(const h of i)try{h.stop()}catch{}i.clear(),l=t.currentTime};return{enqueue:b,interrupt:S,stop:()=>{S(),t.close()}}},_=1,J=.01,K=1200,O=.15,G=3,j=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,z=e=>{const o=e.__lunoraRef,t=o.startsWith("agents:")?o.slice(7):o;return t.endsWith("Voice")?t.slice(0,-5):t},Q=(e,o,t)=>{const i=j(e),l=i.endsWith("/")?i.slice(0,-1):i,c=new URLSearchParams({threadKey:t});return`${l}/_lunora/voice/${encodeURIComponent(o)}?${c.toString()}`},X=(e,o)=>{const{createMicrophone:t=B,createSpeaker:i=$,createSocket:l,interruptChunks:c=G,interruptThreshold:d=O,silenceDurationMs:g=K,silenceThreshold:b=J,threadKey:S,voice:h}=o,r=A("idle"),a=A(!1),p=A(""),f=A(""),w=A(0),T=A(!1),y=A();let u,C=!1;const E=s=>{const n=u?.socket;return n?.readyState===_?(n.send(JSON.stringify(s)),!0):!1},M=()=>{const s=u;if(u=void 0,s){s.microphone?.stop(),s.speaker?.stop();try{s.socket.close()}catch{}}C=!1,a.set(!1),r.set("idle"),w.set(0)},U=M,L=s=>{const n=u;switch(s.type){case"assistant_delta":{n&&(n.speaking=!0),r.set("speaking"),f.update(k=>k+s.text);break}case"assistant_done":{n&&(n.speaking=!1),f.set(s.text),r.set("listening");break}case"error":{n&&(n.speaking=!1),y.set(new Error(s.message)),r.set("listening");break}case"interrupted":{n&&(n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),r.set("listening");break}case"ready":{n&&(n.audioFormat=s.audioFormat,n.suppressAudio=!1),a.set(!0),r.set("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),p.set(s.text),f.set(""),r.set("thinking");break}}},R=s=>{const n=u;!n||n.suppressAudio||(n.speaker??=i({audioFormat:n.audioFormat}),n.speaking=!0,r.set("speaking"),n.speaker.enqueue(s))},D=async()=>{if(!(u||C)){C=!0,y.set(void 0),p.set(""),f.set("");try{const s=Q(e.url,z(h),S),k=(l??(m=>new globalThis.WebSocket(m)))(s);k.binaryType="arraybuffer";const v={audioFormat:"mp3",microphone:void 0,socket:k,speaker:void 0,speaking:!1,suppressAudio:!1};u=v,k.onmessage=m=>{if(typeof m.data=="string"){try{L(JSON.parse(m.data))}catch{}return}R(new Uint8Array(m.data))},k.onerror=()=>{y.set(new Error("voiceAgent: voice socket error"))},k.onclose=()=>{u===v&&M()};const x=await t({interruptChunks:c,interruptThreshold:d,isSpeaking:()=>u?.speaking??!1,onAudio:m=>{k.readyState===_&&k.send(m)},onInterrupt:()=>{E({type:"interrupt"}),u?.speaker?.interrupt(),u&&(u.speaking=!1,u.suppressAudio=!0),r.set("listening")},onLevel:m=>{w.set(m)},onSilence:()=>{E({type:"commit"}),r.set("thinking")},silenceDurationMs:g,silenceThreshold:b});u===v?(v.microphone=x,T.set(!1),r.set("listening")):x.stop()}catch(s){y.set(s instanceof Error?s:new Error(String(s))),M()}finally{C=!1}}},F=()=>{const s=!I(T);return u?.microphone?.setMuted(s),T.set(s),s},N=s=>{E({text:s,type:"text"})&&r.set("thinking")};return{audioLevel:{subscribe:w.subscribe},connected:{subscribe:a.subscribe},endCall:U,error:{subscribe:y.subscribe},interimTranscript:{subscribe:f.subscribe},isMuted:{subscribe:T.subscribe},sendText:N,startCall:D,status:{subscribe:r.subscribe},toggleMute:F,transcript:{subscribe:p.subscribe}}};function te(e,o){const t=P(e),i=t?e:W();return X(i,t?o:e)}export{te as voiceAgent};
|
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.78",
|
|
4
4
|
"description": "Svelte adapter for Lunora — live stores, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -44,10 +44,6 @@
|
|
|
44
44
|
"types": "./dist/server.d.ts",
|
|
45
45
|
"import": "./dist/server.mjs"
|
|
46
46
|
},
|
|
47
|
-
"./worker": {
|
|
48
|
-
"types": "./dist/worker.d.ts",
|
|
49
|
-
"import": "./dist/worker.mjs"
|
|
50
|
-
},
|
|
51
47
|
"./upload": {
|
|
52
48
|
"types": "./dist/upload.d.ts",
|
|
53
49
|
"import": "./dist/upload.mjs"
|
|
@@ -58,11 +54,11 @@
|
|
|
58
54
|
"access": "public"
|
|
59
55
|
},
|
|
60
56
|
"dependencies": {
|
|
61
|
-
"@lunora/client": "1.0.0-alpha.
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.50",
|
|
62
58
|
"@lunora/errors": "1.0.0-alpha.21",
|
|
63
59
|
"@lunora/ratelimit": "1.0.0-alpha.22",
|
|
64
|
-
"@lunora/runtime": "1.0.0-alpha.
|
|
65
|
-
"@visulima/storage-client": "1.0.
|
|
60
|
+
"@lunora/runtime": "1.0.0-alpha.62",
|
|
61
|
+
"@visulima/storage-client": "1.0.2"
|
|
66
62
|
},
|
|
67
63
|
"peerDependencies": {
|
|
68
64
|
"svelte": "^5.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{writable as b}from"svelte/store";import{i as T}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as _}from"./getLunoraClient-DU7BmZy1.mjs";import{mutation as d}from"./mutation-fa0Bj5Bo.mjs";const A={__lunoraRef:""},I=t=>typeof t=="object"&&t!==null&&typeof t.subscribe=="function",K=(t,a)=>{const{api:e,cancel:r,run:m,runArgs:p,threadKey:i}=a,o=d(t,m),f=d(t,r??A);let s;const c=b(),u=b(),l=T()?t.subscribe(e.agents.agentThread,{key:i},n=>{s=n,c.set(s),u.set(s?.status)}):()=>{},y=async(n,w)=>{await o.mutate({input:n,threadKey:i,...p,...w})},g=async()=>{const n=s?.instanceId;r===void 0||n===void 0||await f.mutate({instanceId:n,threadKey:i})},h=()=>{l()};return{cancel:g,pending:o.pending,run:y,status:{subscribe:u.subscribe},teardown:h,thread:{subscribe:c.subscribe}}};function N(t,a){const e=I(t),r=e?t:_();return K(r,e?a:t)}export{A as NO_MUTATION_REF,N as agent,I as isClient};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{reconcileOptimistic as K,maxSeq as A}from"@lunora/client";import{writable as b}from"svelte/store";import{i as g}from"./is-browser-BEdfLJHK.mjs";import{isClient as Q,NO_MUTATION_REF as U}from"./agent-CddTbgxO.mjs";import{getLunoraClient as V}from"./getLunoraClient-DU7BmZy1.mjs";import{mutation as h}from"./mutation-fa0Bj5Bo.mjs";import{stream as z}from"./stream-DItOnXt6.mjs";const G={__lunoraRef:""},J=(n,u)=>{const{api:r,cancel:m,limit:y,send:T,sendArgs:_,stream:f,threadKey:a}=u,j=h(n,T),q=h(n,m??U),O=h(n,r.agents.agentResolveApproval);let d,i=[],c=[],v=[],w=0;const l=b([]),k=b(),I=b(""),p=()=>{const t=K(c,i);if(t.length===0){l.set(i);return}const s=A(i);l.set([...i,...t.map((e,o)=>({content:e.content,optimistic:!0,role:"user",seq:s+1+o}))])},x=()=>{const t=i.filter(e=>e.role==="assistant").length,s=v.filter(e=>e.kind!=="progress"&&e.threadKey===a&&e.turn>=t).map(e=>e.text).join("");I.set(s)},R=f===void 0?"skip":{key:a},S=g()?z(n,f??G,R).chunks.subscribe(t=>{v=t,x()}):()=>{},E=y===void 0?{key:a}:{key:a,limit:y},N=g()?n.subscribe(r.agents.agentMessages,E,t=>{i=t,p(),x()}):()=>{},B=g()?n.subscribe(r.agents.agentThread,{key:a},t=>{d=t,k.set(d?.status)}):()=>{},D=async(t,s)=>{const e=w;w+=1;const o=A(i);c=[...K(c,i),{content:t,id:e,maxDurableSeqAtSend:o}],p();try{await j.mutate({input:t,threadKey:a,..._,...s})}catch(H){throw c=c.filter(P=>P.id!==e),p(),H}},C=async(t,s,e)=>{const o=d?.instanceId;if(o===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await O.mutate({decision:t,instanceId:o,threadKey:a,toolCallId:s,...e===void 0?{}:{note:e}})},F=async(t,s)=>C("approve",t,s),L=async(t,s)=>C("reject",t,s),M=async()=>{const t=d?.instanceId;m===void 0||t===void 0||await q.mutate({instanceId:t,threadKey:a})},$=()=>{N(),B(),S()};return{approve:F,cancel:M,messages:{subscribe:l.subscribe},reject:L,send:D,status:{subscribe:k.subscribe},streamingText:{subscribe:I.subscribe},teardown:$}};function nt(n,u){const r=Q(n),m=r?n:V();return J(m,r?u:n)}export{nt as agentChat};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{derived as p}from"svelte/store";import{isClient as f}from"./agent-CddTbgxO.mjs";import{getLunoraClient as d}from"./getLunoraClient-DU7BmZy1.mjs";import{subscription as g}from"./subscription-Dbz9sy8N.mjs";function C(r,o){const t=f(r),a=t?r:d(),e=t?o:r,{data:i,error:n}=g(a,e.api.agents.agentState,{key:e.threadKey}),s=p(i,m=>m);return{error:n,state:s}}export{C as agentState};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{derived as c}from"svelte/store";import{isClient as g}from"./agent-CddTbgxO.mjs";import{getLunoraClient as y}from"./getLunoraClient-DU7BmZy1.mjs";import{stream as I}from"./stream-DItOnXt6.mjs";import{subscription as N}from"./subscription-Dbz9sy8N.mjs";const k={__lunoraRef:""},q=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(t=>({input:t.input,seq:o.seq,toolCallId:t.id,toolName:t.name,type:"call"}));if(o.role==="tool")return o.status==="awaiting_approval"?[{seq:o.seq,type:"awaiting-approval",...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]:[{output:o.content,seq:o.seq,type:"result",...o.status==="approved"||o.status==="rejected"?{status:o.status}:{},...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]};function M(o,t){const l=g(o),s=l?o:y(),p=l?t:o,{api:d,limit:r,stream:i,threadKey:e}=p,m=r===void 0?{key:e}:{key:e,limit:r},{data:u}=N(s,d.agents.agentMessages,m),C=I(s,i??k,i===void 0?"skip":{key:e});return{events:c([u,C.chunks],([f,v])=>{const n=(f??[]).flatMap(a=>q(a)??[]);for(const a of v)a.kind==="progress"&&a.threadKey===e&&n.push({data:a.data,toolCallId:a.toolCallId,type:"progress"});return n})}}export{M as agentToolEvents};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{getIdentityStore as l}from"@lunora/client/auth";import{readable as s,derived as i}from"svelte/store";import{getLunoraClient as g}from"./getLunoraClient-DU7BmZy1.mjs";const h=r=>{const e=r??g(),n=l(e),u=s(e.getAuthToken(),t=>(t(e.getAuthToken()),e.onAuthTokenChange(a=>{t(a)}))),o=s(n.getUser(),t=>(t(n.getUser()),n.subscribe(()=>{t(n.getUser())})));return{setToken:t=>{e.setAuthToken(t)},token:u,user:o}},c=r=>{const{token:e,user:n}=h(r),u=i([e,n],([o,t])=>o!==null&&t===null);return{isAuthenticated:i([e,n],([o,t])=>o!==null&&t!==null),isLoading:u}};export{h as auth,c as authGate};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readable as c}from"svelte/store";import{getLunoraClient as r}from"./getLunoraClient-DU7BmZy1.mjs";const s=o=>{const t=o??r();return c(t.connectionStatus(),n=>(n(t.connectionStatus()),t.onConnectionStatus(e=>{n(e)})))};export{s as connectionStatus};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readable as a}from"svelte/store";import{isClient as p}from"./agent-CddTbgxO.mjs";import{getLunoraClient as b}from"./getLunoraClient-DU7BmZy1.mjs";const g="__lunora_flags__:eval",y=r=>{const t=typeof r;return t==="boolean"||t==="number"||t==="string"?t:"object"},v={__lunoraRef:g},m=(r,t,e,n,o)=>{try{return r.subscribe(v,{context:n,default:e,key:t,type:y(e)},c=>{o(c)})}catch{return()=>{}}};function j(r,t,e,n){const o=p(r),c=o?r:b(),l=o?t:r,u=o?e:t,s=(o?n:e)??void 0;return a(u,f=>m(c,l,u,s,f))}function k(r,t,e){const n=p(r),o=n?r:b(),c=n?t:r,l=(n?e:t)??void 0;return a(c,u=>{let s={...c};const f=[];for(const[i,_]of Object.entries(c))f.push(m(o,i,_,l,d=>{s={...s,[i]:d},u(s)}));return()=>{for(const i of f)i()}})}export{j as flag,k as flags};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readable as u}from"svelte/store";import{getLunoraClient as c}from"./getLunoraClient-DU7BmZy1.mjs";const m=(r,e)=>{const a=e??c(),{args:o,functionPath:t,shardKey:n,value:s}=r,d={__lunoraRef:t};return u(s,i=>a.subscribe(d,o,l=>{i(l)},{shardKey:n}))};export{m as hydratePreloaded};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{initialPages as J,derivePaginationStatus as T,applyLoadMore as V,rebalance as q}from"@lunora/client/pagination";import{derived as S,writable as I,readable as G,get as k}from"svelte/store";import{getLunoraClient as Q}from"./getLunoraClient-DU7BmZy1.mjs";import{i as D}from"./is-function-reference-ByqJF30w.mjs";const H=(e,r)=>e<r?-1:e>r?1:0,F=e=>{if(e===void 0)return"null";if(typeof e=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t=>F(t)).join(",")}]`;const r=Object.getPrototypeOf(e);if(r!==null&&r!==Object.prototype){const t=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${t} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=e,b=Object.keys(s).toSorted(H),i=[];for(const t of b){const n=s[t];n!==void 0&&i.push(`${JSON.stringify(t)}:${F(n)}`)}return`{${i.join(",")}}`},E=e=>{let r="";for(let s=0;s<e.length;s+=32768)r+=String.fromCharCode(...e.subarray(s,s+32768));return btoa(r)},c="$lunora.wire$",K=64,X="__proto__",Y=e=>{if(e===null||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype},M=(e,r=0)=>{if(r>K)throw new RangeError(`wire-codec: value nesting exceeds the ${K}-level limit`);if(e===void 0)return[c,"undefined"];if(e===null)return null;const s=typeof e;if(s==="bigint")return[c,"bigint",e.toString()];if(s==="number"){const t=e;return Number.isNaN(t)?[c,"nan"]:t===1/0?[c,"inf"]:t===-1/0?[c,"-inf"]:t}if(s!=="object")return e;if(e instanceof Date)return[c,"date",M(e.getTime(),r+1)];if(e instanceof Error){const t=e,n={};for(const a of Object.keys(t))t[a]!==void 0&&(n[a]=M(t[a],r+1));const o=[c,"error",t.name,t.message,n];return t.cause!==void 0&&o.push(M(t.cause,r+1)),o}if(e instanceof URL)return[c,"url",e.href];if(e instanceof Map)return[c,"map",[...e.entries()].map(([t,n])=>[M(t,r+1),M(n,r+1)])];if(e instanceof Set)return[c,"set",[...e].map(t=>M(t,r+1))];if(e instanceof ArrayBuffer)return[c,"bytes",E(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,n=t.constructor.name,o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return n==="Uint8Array"?[c,"bytes",E(o)]:[c,"bytes",E(o),n]}if(Array.isArray(e)){const t=e.map(n=>M(n,r+1));return t.length>0&&t[0]===c?[c,"arr",t]:t}if(!Y(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const b=e,i={};for(const t of Object.keys(b)){const n=b[t];if(n===void 0)continue;const o=M(n,r+1);t===X?Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[t]=o}return i},Z=e=>F(M(e)),A=(e,r)=>({...r,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),L=(e,r)=>`${e}::${Z(r)}`,W=(e,r,s,b)=>{const{initialNumItems:i,shardKey:t}=b,n=I(J(i)),o=I([]),a=new Map,d=new Map,w=new Set,f=s,g=()=>{if(f==="skip"){o.set([]);return}const l=k(n).map(m=>{const v=L(r.__lunoraRef,A(m,f));return a.get(v)});o.set(l)},R=(l,m)=>{if(f==="skip")return;const v=u=>L(r.__lunoraRef,A(u,f));for(const u of m){const h=v(u);if(a.has(h))continue;const y=l.find(O=>O.lower===u.lower);if(y){const O=a.get(v(y));O&&a.set(h,O)}}},$=()=>{if(f==="skip"){for(const u of d.values())u();d.clear(),o.set([]);return}const l=f,m=k(n),v=new Set;for(const u of m)v.add(L(r.__lunoraRef,A(u,l)));for(const[u,h]of d)v.has(u)||(h(),d.delete(u),w.delete(u),a.delete(u));for(const u of m){const h=A(u,l),y=L(r.__lunoraRef,h);if(d.has(y))continue;w.add(y);const O=e.subscribe(r,h,x=>{if(a.set(y,x),w.delete(y),g(),w.size===0){const _=k(n),j=q(_,k(o));j&&(R(_,j),n.set(j),p(),g())}},{shardKey:t});d.set(y,O)}};let N=!1,P=!1;const p=()=>{if(N){P=!0;return}N=!0;try{do P=!1,$();while(P)}finally{N=!1}},C=()=>{for(const l of d.values())l();d.clear(),a.clear(),w.clear()},U=G([],l=>{const m=o.subscribe(l);return f!=="skip"&&(p(),g()),()=>{m(),C(),n.set(J(i)),o.set([])}}),z=S(U,l=>T(f==="skip",l).status);return{loadMore:l=>{if(f==="skip")return;const m=k(o),{nextCursor:v,status:u}=T(!1,m);if(u!=="CanLoadMore")return;const h=k(n),y=V(h,v,l);if(!y)return;const O=h.at(-1),x=y.at(-2);if(O&&x){const _=L(r.__lunoraRef,A(O,f)),j=L(r.__lunoraRef,A(x,f));if(_!==j){const B=a.get(_);B&&(a.set(j,B),a.delete(_))}}n.set(y),p(),g()},pageResults:U,status:z}};function oe(e,r,s,b){const i=!D(e),t=i?e:Q(),n=i?r:e,o=i?s:r,a=i?b:s,{loadMore:d,pageResults:w,status:f}=W(t,n,o,a),g=S(w,R=>R.flatMap($=>$?.page??[]));return{isLoading:S(f,R=>R==="LoadingFirstPage"||R==="LoadingMore"),loadMore:d,results:g,status:f}}function se(e,r,s,b){const i=!D(e),t=i?e:Q(),n=i?r:e,o=i?s:r,a=i?b:s,{initialNumItems:d}=a,{loadMore:w,pageResults:f,status:g}=W(t,n,o,a),R=S(f,p=>p.flatMap(C=>C?[C.page]:[])),$=S(g,p=>p==="LoadingFirstPage"),N=S(g,p=>p==="CanLoadMore"),P=S(g,p=>p==="LoadingMore");return{fetchNextPage:p=>{w(p??d)},hasNextPage:N,isFetchingNextPage:P,isLoading:$,pages:R,status:g}}export{se as infiniteQuery,oe as paginatedQuery};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const o=e=>typeof e=="object"&&e!==null&&typeof e.__lunoraRef=="string";export{o as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createMutationRunner as f}from"@lunora/client";import{writable as o}from"svelte/store";import{getLunoraClient as p}from"./getLunoraClient-DU7BmZy1.mjs";function g(n,s){const i=s!==void 0,u=i?n:p(),d=i?s:n,r=o(),e=o(),a=o(!1),m=f(u,d,{setError:t=>{e.set(t)},setPending:t=>{a.set(t)},setResult:t=>{r.set(t),e.set(void 0)}});return{data:r,error:e,mutate:m,pending:a,reset:()=>{r.set(void 0),e.set(void 0)}}}export{g as mutation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createMutatorRunner as m}from"@lunora/client";import{writable as o,derived as d}from"svelte/store";const c=s=>{const e=o(),t=o(!1),n=d(e,r=>r!==void 0),{mutate:a,reset:i}=m(s,{setError:r=>{e.set(r)},setPending:r=>{t.set(r)}});return{error:e,isError:n,mutate:a,pending:t,reset:i}};export{c as mutator};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{onDestroy as b}from"svelte";import{readable as D}from"svelte/store";import{i as l}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as U}from"./getLunoraClient-DU7BmZy1.mjs";const $=(t="sess")=>{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`${t}-${Array.from(e,o=>o.toString(16).padStart(2,"0")).join("")}`}}return`${t}-${Date.now().toString(36)}`},w=1e4,C=(t,e,o)=>{const{heartbeat:r,intervalMs:i=w,listPresent:v,shardKey:a}=o,c=o.sessionId??$();let d=o.data;const s=()=>{const n={roomId:e,sessionId:c,...d===void 0?{}:{data:d}};t.mutation(r,n,{shardKey:a}).catch(()=>{})},I=n=>{d=n,s()},m=()=>{typeof document<"u"&&document.visibilityState==="visible"&&s()};let u,y;l()&&(s(),u=setInterval(s,i),typeof document<"u"&&document.addEventListener("visibilitychange",m),y=t.acquireConnectionContext({roomId:e,sessionId:c},{shardKey:a}));const g=D(void 0,n=>{if(l())return t.subscribe(v,{roomId:e},h=>{n(h)},{shardKey:a})});let f=!1;const p=()=>{f||(f=!0,u!==void 0&&clearInterval(u),typeof document<"u"&&document.removeEventListener("visibilitychange",m),y?.())};try{b(p)}catch{}return{present:g,sessionId:c,setData:I,teardown:p}};function A(t,e,o){const r=typeof t!="string",i=r?t:U();return C(i,r?e:t,r?o:e)}export{A as presence};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createQuerySubscription as s}from"@lunora/client/query";import{readable as c}from"svelte/store";import{getLunoraClient as d}from"./getLunoraClient-DU7BmZy1.mjs";import{i as y}from"./is-function-reference-ByqJF30w.mjs";function E(o,e,t,a){const r=!y(o),m=r?o:d(),u=r?e:o,f=r?t:e,n=(r?a:t)??{};return c(void 0,i=>s(m,u,f,{onData:p=>{i(p)},onError:n.onError,onReset:()=>{i(void 0)}},{shardKey:n.shardKey}))}export{E as query};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{evaluate as v}from"@lunora/ratelimit";import{writable as I,derived as r}from"svelte/store";import{i as L}from"./is-browser-BEdfLJHK.mjs";const D=(n,d={})=>{const a=d.now??Date.now,w=d.tickMs??1e3;let t;const f=I(0),u=()=>{f.update(e=>e+1)},s=r(f,()=>v(n,t,{consume:!1,count:1,now:a(),reserve:!1}).status);let o;const c=()=>{o!==void 0&&(clearInterval(o),o=void 0)};let i=!0;const k=s.subscribe(e=>{i=e.ok}),m=()=>{i||o!==void 0||(o=setInterval(()=>{u(),i&&c()},w))};L()&&m();const p=(e=1)=>{const l=v(n,t,{consume:!0,count:e,now:a(),reserve:!1});return l.value!==void 0&&(t=l.value),u(),m(),l.status},b=(e=1)=>v(n,t,{consume:!1,count:e,now:a(),reserve:!1}).status.ok,y=()=>{t=void 0,c(),u()},A=()=>{c(),k()};return{check:b,consume:p,disabled:r(s,e=>!e.ok),ok:r(s,e=>e.ok),reset:y,retryAfter:r(s,e=>e.retryAfter),teardown:A}};export{D as rateLimit};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{writable as h,readable as E}from"svelte/store";import{getLunoraClient as K}from"./getLunoraClient-DU7BmZy1.mjs";import{i as R}from"./is-function-reference-ByqJF30w.mjs";function L(i,u,f,p){const t=!R(i),w=t?i:K(),y=t?u:i,m=t?f:u,g=(t?p:f)??{},{maxBuffer:k,shardKey:x}=g,r=h("idle"),a=h();let s;const b=()=>{s?.()},v=E([],l=>{if(l([]),a.set(void 0),m==="skip")return r.set("idle"),()=>{};r.set("streaming");let n=!0,c=[];const d=w.stream(y,m,{maxBuffer:k,shardKey:x}),o=()=>{d.cancel()};return s=o,(async()=>{try{for await(const e of d){if(!n)return;c=[...c,e],l(c)}n&&r.set("complete")}catch(e){if(!n)return;a.set(e instanceof Error?e:new Error(String(e))),r.set("error")}})().catch(()=>{}),()=>{n=!1,o(),s===o&&(s=void 0)}}),B=()=>{b()};return{cancel:b,chunks:v,error:{subscribe:a.subscribe},status:{subscribe:r.subscribe},teardown:B}}export{L as stream};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createQuerySubscription as E}from"@lunora/client/query";import{writable as l,readable as y}from"svelte/store";import{getLunoraClient as g}from"./getLunoraClient-DU7BmZy1.mjs";import{i as h}from"./is-function-reference-ByqJF30w.mjs";function S(o,n,s,c){const r=!h(o),u=r?o:g(),b=r?n:o,d=r?s:n,m=(r?c:s)??{},{shardKey:p,onError:f}=m,e=l();return{data:y(void 0,i=>{const v=E(u,b,d,{onData:t=>{i(t),e.set(void 0)},onError:t=>{const a=new Error(t.message);e.set(a),f?.(a)},onReset:()=>{i(void 0)}},{shardKey:p});return()=>{v(),e.set(void 0)}}),error:{subscribe:e.subscribe}}}export{S as subscription};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{writable as w,get as L}from"svelte/store";import{isClient as R}from"./agent-CddTbgxO.mjs";import{getLunoraClient as W}from"./getLunoraClient-DU7BmZy1.mjs";const V=e=>{if(e.length===0)return 0;let o=0;for(const s of e)o+=s*s;return Math.sqrt(o/e.length)},B=(e,o)=>{const s=o/16e3,i=s>1?Math.floor(e.length/s):e.length,d=new ArrayBuffer(i*2),a=new DataView(d);for(let l=0;l<i;l+=1){const g=e[Math.floor(l*s)]??0,b=Math.max(-1,Math.min(1,g));a.setInt16(l*2,b<0?b*32768:b*32767,!0)}return new Uint8Array(d)},I=async e=>{const o=globalThis,s=o.navigator?.mediaDevices?.getUserMedia.bind(o.navigator.mediaDevices),i=o.AudioContext??o.webkitAudioContext;if(!s||!i)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),a=new i,l=a.createMediaStreamSource(d),g=a.createScriptProcessor(4096,1,1);let b=!1,m=!1,f=0,n=0;return g.onaudioprocess=c=>{const p=c.inputBuffer.getChannelData(0),h=b?0:V(p);if(e.onLevel(h),b)return;if(e.onAudio(B(p,a.sampleRate)),e.isSpeaking()){n=h>=e.interruptThreshold?n+1:0,n>=e.interruptChunks&&(n=0,e.onInterrupt());return}n=0;const A=p.length/a.sampleRate*1e3;if(h>=e.silenceThreshold){m=!0,f=0;return}m&&(f+=A,f>=e.silenceDurationMs&&(m=!1,f=0,e.onSilence()))},l.connect(g),g.connect(a.destination),{setMuted:c=>{b=c},stop:()=>{g.disconnect(),l.disconnect();for(const c of d.getTracks())c.stop();a.close()}}},P=()=>{const e=globalThis,o=e.AudioContext??e.webkitAudioContext;if(!o)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new o,i=new Set;let d=0,a=Promise.resolve(),l=0;const g=async(f,n)=>{if(n!==l)return;let c;try{c=await s.decodeAudioData(f.buffer)}catch{return}if(n!==l)return;const p=s.createBufferSource();p.buffer=c,p.connect(s.destination);const h=Math.max(s.currentTime,d);p.start(h),d=h+c.duration,i.add(p),p.onended=()=>{i.delete(p)}},b=f=>{const n=Uint8Array.from(f),c=l;a=a.then(()=>g(n,c))},m=()=>{l+=1;for(const f of i)try{f.stop()}catch{}i.clear(),d=s.currentTime};return{enqueue:b,interrupt:m,stop:()=>{m(),s.close()}}},D=1,J=.01,K=1200,N=.15,O=3,j=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,z=e=>{const o=e.__lunoraRef,s=o.startsWith("agents:")?o.slice(7):o;return s.endsWith("Voice")?s.slice(0,-5):s},H=(e,o,s)=>{const i=j(e),d=i.endsWith("/")?i.slice(0,-1):i,a=new URLSearchParams({threadKey:s});return`${d}/_lunora/voice/${encodeURIComponent(o)}?${a.toString()}`},G=(e,o)=>{const{createMicrophone:s=I,createSpeaker:i=P,createSocket:d,interruptChunks:a=O,interruptThreshold:l=N,silenceDurationMs:g=K,silenceThreshold:b=J,threadKey:m,voice:f}=o,n=w("idle"),c=w(!1),p=w(""),h=w(""),A=w(0),S=w(!1),v=w();let u,C=!1;const M=r=>{const t=u?.socket;return t?.readyState===D?(t.send(JSON.stringify(r)),!0):!1},x=()=>{const r=u;if(u=void 0,r){r.microphone?.stop(),r.speaker?.stop();try{r.socket.close()}catch{}}C=!1,c.set(!1),n.set("idle"),A.set(0)},U=x,$=r=>{const t=u;switch(r.type){case"assistant_delta":{t&&(t.speaking=!0),n.set("speaking"),h.update(y=>y+r.text);break}case"assistant_done":{t&&(t.speaking=!1),h.set(r.text),n.set("listening");break}case"error":{t&&(t.speaking=!1),v.set(new Error(r.message)),n.set("listening");break}case"interrupted":{t&&(t.speaking=!1,t.suppressAudio=!1),t?.speaker?.interrupt(),n.set("listening");break}case"ready":{t&&(t.audioFormat=r.audioFormat,t.suppressAudio=!1),c.set(!0),n.set("listening");break}case"user_transcript":{t&&(t.suppressAudio=!1),p.set(r.text),h.set(""),n.set("thinking");break}}},E=r=>{const t=u;!t||t.suppressAudio||(t.speaker??=i({audioFormat:t.audioFormat}),t.speaking=!0,n.set("speaking"),t.speaker.enqueue(r))},_=async()=>{if(!(u||C)){C=!0,v.set(void 0),p.set(""),h.set("");try{const r=H(e.url,z(f),m),t=(d??(k=>new globalThis.WebSocket(k)))(r);t.binaryType="arraybuffer";const y={audioFormat:"mp3",microphone:void 0,socket:t,speaker:void 0,speaking:!1,suppressAudio:!1};u=y,t.onmessage=k=>{if(typeof k.data=="string"){try{$(JSON.parse(k.data))}catch{}return}E(new Uint8Array(k.data))},t.onerror=()=>{v.set(new Error("voiceAgent: voice socket error"))},t.onclose=()=>{u===y&&x()};const T=await s({interruptChunks:a,interruptThreshold:l,isSpeaking:()=>u?.speaking??!1,onAudio:k=>{t.readyState===D&&t.send(k)},onInterrupt:()=>{M({type:"interrupt"}),u?.speaker?.interrupt(),u&&(u.speaking=!1,u.suppressAudio=!0),n.set("listening")},onLevel:k=>{A.set(k)},onSilence:()=>{M({type:"commit"}),n.set("thinking")},silenceDurationMs:g,silenceThreshold:b});u===y?(y.microphone=T,S.set(!1),n.set("listening")):T.stop()}catch(r){v.set(r instanceof Error?r:new Error(String(r))),x()}finally{C=!1}}},q=()=>{const r=!L(S);return u?.microphone?.setMuted(r),S.set(r),r},F=r=>{M({text:r,type:"text"})&&n.set("thinking")};return{audioLevel:{subscribe:A.subscribe},connected:{subscribe:c.subscribe},endCall:U,error:{subscribe:v.subscribe},interimTranscript:{subscribe:h.subscribe},isMuted:{subscribe:S.subscribe},sendText:F,startCall:_,status:{subscribe:n.subscribe},toggleMute:q,transcript:{subscribe:p.subscribe}}};function Z(e,o){const s=R(e),i=s?e:W();return G(i,s?o:e)}export{Z as voiceAgent};
|
package/dist/worker.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { type ExecutionContextLike, type FrameworkWorkerOptions as LunoraWorkerOptions, type FrameworkWorkerOptionsInput as LunoraWorkerOptionsInput, type FrameworkHostHandler as SvelteKitWorker, withFrameworkWorker as withLunora } from '@lunora/runtime';
|
package/dist/worker.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { type ExecutionContextLike, type FrameworkWorkerOptions as LunoraWorkerOptions, type FrameworkWorkerOptionsInput as LunoraWorkerOptionsInput, type FrameworkHostHandler as SvelteKitWorker, withFrameworkWorker as withLunora } from '@lunora/runtime';
|
package/dist/worker.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{withFrameworkWorker as a}from"@lunora/runtime";export{a as withLunora};
|