@lunora/svelte 1.0.0-alpha.80 → 1.0.0-alpha.82

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 CHANGED
@@ -1,8 +1,52 @@
1
- import { FunctionReference, LunoraClient, User, ConnectionStatus, Preloaded, ReturnOf, ArgsOf, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback } from '@lunora/client';
1
+ import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, User, ConnectionStatus, Preloaded, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback } from '@lunora/client';
2
2
  export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, Preloaded, ReturnOf } from '@lunora/client';
3
3
  import { Readable } from 'svelte/store';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
6
+ /**
7
+ * The reactive handle returned by {@link action} — the Svelte counterpart to
8
+ * React's `useAction`, re-expressed as stores you read with `$`. The surface is
9
+ * identical across the Lunora adapters (`@lunora/solid`, `/vue`).
10
+ */
11
+ interface ActionHandle<F extends FunctionReference> {
12
+ /**
13
+ * Run the action. Resolves with the server result and rejects on failure
14
+ * (errors propagate — there is no swallowing).
15
+ */
16
+ call: (args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
17
+ /** The latest invocation's resolved value, or `undefined` before the first success. */
18
+ data: Readable<ReturnOf<F> | undefined>;
19
+ /** The latest invocation's error, or `undefined`. */
20
+ error: Readable<Error | undefined>;
21
+ /**
22
+ * `true` while any invocation from this handle is in flight. Ref-counted, so
23
+ * overlapping calls compose and it only flips back to `false` once the last
24
+ * one settles. Read it with `$pending` in a component to disable a button.
25
+ */
26
+ pending: Readable<boolean>;
27
+ /** Clear `data`/`error` back to idle. */
28
+ reset: () => void;
29
+ }
30
+ /**
31
+ * Create an {@link ActionHandle} for an action reference. The Svelte
32
+ * counterpart to React's `useAction`: returns `{ data, error, pending, call,
33
+ * reset }` of readable stores plus an awaitable `call`.
34
+ *
35
+ * **Narrower than `mutation` on purpose:** no `optimistic` /
36
+ * `optimisticUpdate`. An optimistic update patches the subscription cache on the
37
+ * assumption a write will land; an action is not a write — it runs in the
38
+ * Worker, may call a third party, and has no declared effect on any query.
39
+ *
40
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
41
+ * invocation (an earlier call settling later cannot clobber a newer one), a
42
+ * success clears `error`, and a failure leaves the previous `data` in place.
43
+ * `reset()` clears both; it does not cancel an in-flight call.
44
+ *
45
+ * Pass `client` explicitly, or omit it to resolve the ambient client published
46
+ * by `setLunoraClient`.
47
+ */
48
+ declare function action<F extends FunctionReference>(function_: F): ActionHandle<F>;
49
+ declare function action<F extends FunctionReference>(client: LunoraClient, function_: F): ActionHandle<F>;
6
50
  /**
7
51
  * The lifecycle status stored on an agent thread. Client-safe mirror of
8
52
  * `@lunora/agent`'s `AgentThreadStatus` — re-declared here (rather than imported)
@@ -610,9 +654,14 @@ interface MutationHandle<F extends FunctionReference> {
610
654
  * Svelte counterpart to React's `useMutation`: returns
611
655
  * `{ data, error, pending, mutate, reset }` of readable stores plus an awaitable
612
656
  * `mutate`. The ref-counted pending + error-normalize orchestration is the
613
- * shared `createMutationRunner` from `@lunora/client`; only the stores are
657
+ * shared `createCallRunner` from `@lunora/client`; only the stores are
614
658
  * adapter-specific.
615
659
  *
660
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
661
+ * invocation (an earlier call settling later cannot clobber a newer one), a
662
+ * success clears `error`, and a failure leaves the previous `data` in place.
663
+ * `reset()` clears both; it does not cancel an in-flight call.
664
+ *
616
665
  * Pass `client` explicitly, or omit it to resolve the ambient client published
617
666
  * by `setLunoraClient`.
618
667
  */
@@ -1061,7 +1110,7 @@ interface VoiceAgentHandle {
1061
1110
  */
1062
1111
  declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
1063
1112
  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,
1113
+ export { type ActionHandle, 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, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
1065
1114
  /**
1066
1115
  * Svelte adapter for Lunora (`@lunora/svelte`).
1067
1116
  *
package/dist/index.d.ts CHANGED
@@ -1,8 +1,52 @@
1
- import { FunctionReference, LunoraClient, User, ConnectionStatus, Preloaded, ReturnOf, ArgsOf, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback } from '@lunora/client';
1
+ import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, User, ConnectionStatus, Preloaded, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback } from '@lunora/client';
2
2
  export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, Preloaded, ReturnOf } from '@lunora/client';
3
3
  import { Readable } from 'svelte/store';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
6
+ /**
7
+ * The reactive handle returned by {@link action} — the Svelte counterpart to
8
+ * React's `useAction`, re-expressed as stores you read with `$`. The surface is
9
+ * identical across the Lunora adapters (`@lunora/solid`, `/vue`).
10
+ */
11
+ interface ActionHandle<F extends FunctionReference> {
12
+ /**
13
+ * Run the action. Resolves with the server result and rejects on failure
14
+ * (errors propagate — there is no swallowing).
15
+ */
16
+ call: (args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
17
+ /** The latest invocation's resolved value, or `undefined` before the first success. */
18
+ data: Readable<ReturnOf<F> | undefined>;
19
+ /** The latest invocation's error, or `undefined`. */
20
+ error: Readable<Error | undefined>;
21
+ /**
22
+ * `true` while any invocation from this handle is in flight. Ref-counted, so
23
+ * overlapping calls compose and it only flips back to `false` once the last
24
+ * one settles. Read it with `$pending` in a component to disable a button.
25
+ */
26
+ pending: Readable<boolean>;
27
+ /** Clear `data`/`error` back to idle. */
28
+ reset: () => void;
29
+ }
30
+ /**
31
+ * Create an {@link ActionHandle} for an action reference. The Svelte
32
+ * counterpart to React's `useAction`: returns `{ data, error, pending, call,
33
+ * reset }` of readable stores plus an awaitable `call`.
34
+ *
35
+ * **Narrower than `mutation` on purpose:** no `optimistic` /
36
+ * `optimisticUpdate`. An optimistic update patches the subscription cache on the
37
+ * assumption a write will land; an action is not a write — it runs in the
38
+ * Worker, may call a third party, and has no declared effect on any query.
39
+ *
40
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
41
+ * invocation (an earlier call settling later cannot clobber a newer one), a
42
+ * success clears `error`, and a failure leaves the previous `data` in place.
43
+ * `reset()` clears both; it does not cancel an in-flight call.
44
+ *
45
+ * Pass `client` explicitly, or omit it to resolve the ambient client published
46
+ * by `setLunoraClient`.
47
+ */
48
+ declare function action<F extends FunctionReference>(function_: F): ActionHandle<F>;
49
+ declare function action<F extends FunctionReference>(client: LunoraClient, function_: F): ActionHandle<F>;
6
50
  /**
7
51
  * The lifecycle status stored on an agent thread. Client-safe mirror of
8
52
  * `@lunora/agent`'s `AgentThreadStatus` — re-declared here (rather than imported)
@@ -610,9 +654,14 @@ interface MutationHandle<F extends FunctionReference> {
610
654
  * Svelte counterpart to React's `useMutation`: returns
611
655
  * `{ data, error, pending, mutate, reset }` of readable stores plus an awaitable
612
656
  * `mutate`. The ref-counted pending + error-normalize orchestration is the
613
- * shared `createMutationRunner` from `@lunora/client`; only the stores are
657
+ * shared `createCallRunner` from `@lunora/client`; only the stores are
614
658
  * adapter-specific.
615
659
  *
660
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
661
+ * invocation (an earlier call settling later cannot clobber a newer one), a
662
+ * success clears `error`, and a failure leaves the previous `data` in place.
663
+ * `reset()` clears both; it does not cancel an in-flight call.
664
+ *
616
665
  * Pass `client` explicitly, or omit it to resolve the ambient client published
617
666
  * by `setLunoraClient`.
618
667
  */
@@ -1061,7 +1110,7 @@ interface VoiceAgentHandle {
1061
1110
  */
1062
1111
  declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
1063
1112
  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,
1113
+ export { type ActionHandle, 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, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
1065
1114
  /**
1066
1115
  * Svelte adapter for Lunora (`@lunora/svelte`).
1067
1116
  *
package/dist/index.mjs CHANGED
@@ -1 +1 @@
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};
1
+ import{action as t}from"./packem_shared/action-SjeZUGhX.mjs";import{agent as a}from"./packem_shared/agent-CFzp-ncV.mjs";import{agentChat as f}from"./packem_shared/agentChat-BhMVjqq4.mjs";import{agentState as n}from"./packem_shared/agentState-DyhOvMaV.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-B5yNPA4v.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-Bew4W5n1.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-D9A79Eqw.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-DU7BmZy1.mjs";import{flag as L,flags as v}from"./packem_shared/flag-DmEKEmb9.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-CW7Ak8zY.mjs";import{mutation as q}from"./packem_shared/mutation-DLBr5Op1.mjs";import{mutator as E}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as P,paginatedQuery as T}from"./packem_shared/infiniteQuery-YtwM_Ac1.mjs";import{presence as k}from"./packem_shared/presence-BaJ2XOzF.mjs";import{query as z}from"./packem_shared/query-Bsh9h9vB.mjs";import{rateLimit as D}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as H}from"./packem_shared/stream-eY1eAuVw.mjs";import{subscription as J}from"./packem_shared/subscription-MIh5Yd8c.mjs";import{voiceAgent as M}from"./packem_shared/voiceAgent-odCezdLl.mjs";export{t as action,a as agent,f as agentChat,n as agentState,i as agentToolEvents,g as auth,s as authGate,l as connectionStatus,L as flag,v as flags,h as getLunoraClient,S as hydratePreloaded,P as infiniteQuery,q as mutation,E as mutator,T as paginatedQuery,k as presence,z as query,D as rateLimit,y as setLunoraClient,H as stream,J as subscription,M as voiceAgent};
@@ -0,0 +1 @@
1
+ import{createCallRunner as f}from"@lunora/client";import{writable as s}from"svelte/store";import{getLunoraClient as p}from"./getLunoraClient-DU7BmZy1.mjs";function R(n,r){const i=r!==void 0,l=i?n:p(),a=i?r:n,o=s(),e=s(),c=s(!1);return{call:f((t,d)=>l.action(a,t,d),{setError:t=>{e.set(t)},setPending:t=>{c.set(t)},setResult:t=>{o.set(t),e.set(void 0)}}),data:o,error:e,pending:c,reset:()=>{o.set(void 0),e.set(void 0)}}}export{R as action};
@@ -1 +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};
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-DLBr5Op1.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};
@@ -1 +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};
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-CFzp-ncV.mjs";import{getLunoraClient as O}from"./getLunoraClient-DU7BmZy1.mjs";import{mutation as h}from"./mutation-DLBr5Op1.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};
@@ -1 +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};
1
+ import{derived as c}from"svelte/store";import{isClient as p}from"./agent-CFzp-ncV.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};
@@ -1 +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};
1
+ import{derived as y}from"svelte/store";import{isClient as m}from"./agent-CFzp-ncV.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};
@@ -1 +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};
1
+ import{readable as l}from"svelte/store";import{isClient as b}from"./agent-CFzp-ncV.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{createCallRunner as f}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,c=i?n:u(),l=i?r:n,o=s(),e=s(),a=s(!1),m=f((t,d)=>c.mutation(l,t,d),{setError:t=>{e.set(t)},setPending:t=>{a.set(t)},setResult:t=>{o.set(t),e.set(void 0)}});return{data:o,error:e,mutate:m,pending:a,reset:()=>{o.set(void 0),e.set(void 0)}}}export{R as mutation};
@@ -1 +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};
1
+ import{writable as A,get as I}from"svelte/store";import{isClient as P}from"./agent-CFzp-ncV.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.80",
3
+ "version": "1.0.0-alpha.82",
4
4
  "description": "Svelte adapter for Lunora — live stores, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -54,10 +54,10 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@lunora/client": "1.0.0-alpha.51",
57
+ "@lunora/client": "1.0.0-alpha.52",
58
58
  "@lunora/errors": "1.0.0-alpha.22",
59
59
  "@lunora/ratelimit": "1.0.0-alpha.23",
60
- "@lunora/runtime": "1.0.0-alpha.64",
60
+ "@lunora/runtime": "1.0.0-alpha.65",
61
61
  "@visulima/storage-client": "1.0.2"
62
62
  },
63
63
  "peerDependencies": {
@@ -1 +0,0 @@
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};