@lunora/react 1.0.0-alpha.298 → 1.0.0-alpha.299

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.
Files changed (40) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/packem_shared/{AuthLoading-cCcnpzS8.mjs → AuthLoading-DgQHaQD5.mjs} +1 -1
  3. package/dist/packem_shared/LunoraProvider-0PzN8244.mjs +1 -0
  4. package/dist/packem_shared/hydratePreloaded-DLUC_u80.mjs +2 -0
  5. package/dist/packem_shared/lunora-provider-BMJTPKMP.mjs +2 -0
  6. package/dist/packem_shared/{query-core-C6u-yRAv.mjs → query-core-C9_ReCKt.mjs} +1 -1
  7. package/dist/packem_shared/use-paginated-core-BjpWBr46.mjs +2 -0
  8. package/dist/packem_shared/useAction-BGTQyx5l.mjs +2 -0
  9. package/dist/packem_shared/{useAgent-B9xIcys5.mjs → useAgent-BW4uKe79.mjs} +1 -1
  10. package/dist/packem_shared/{useAgentApprovals-BNLOv-N3.mjs → useAgentApprovals-VbOnL2Lx.mjs} +1 -1
  11. package/dist/packem_shared/{useAgentChat-CAj633xe.mjs → useAgentChat-DjLC2W3L.mjs} +1 -1
  12. package/dist/packem_shared/{useAgentState-DV_QtMaZ.mjs → useAgentState-CNZ5F4mc.mjs} +1 -1
  13. package/dist/packem_shared/{useAgentToolEvents-BUj4J1Tk.mjs → useAgentToolEvents-dndcx99y.mjs} +1 -1
  14. package/dist/packem_shared/{useAuth-D-BORwSq.mjs → useAuth-C1_ruDmE.mjs} +1 -1
  15. package/dist/packem_shared/useAuthSessions-CFVMrk0L.mjs +2 -0
  16. package/dist/packem_shared/{useAuthState-Bn59SpsP.mjs → useAuthState-DZhCIjSA.mjs} +1 -1
  17. package/dist/packem_shared/{useClientQuery-DsNsWwjz.mjs → useClientQuery-D-c8YM6Q.mjs} +1 -1
  18. package/dist/packem_shared/{useConnectionStatus-DbnZFUh4.mjs → useConnectionStatus-CAmQqRpD.mjs} +1 -1
  19. package/dist/packem_shared/{useFlag-BwwyJsI4.mjs → useFlag-CWjaNeAp.mjs} +1 -1
  20. package/dist/packem_shared/{useHttpStream-BWjb3Bwp.mjs → useHttpStream-C-VR6P1E.mjs} +1 -1
  21. package/dist/packem_shared/{useInfiniteQuery-BdNoCySX.mjs → useInfiniteQuery-BIkpHK0e.mjs} +1 -1
  22. package/dist/packem_shared/{useLiveTopic-BNT52TSr.mjs → useLiveTopic-Cp5b1ncm.mjs} +1 -1
  23. package/dist/packem_shared/useMutation-D6p61C2U.mjs +2 -0
  24. package/dist/packem_shared/{usePaginatedQuery-CLrDYofT.mjs → usePaginatedQuery-B7tBY2XC.mjs} +1 -1
  25. package/dist/packem_shared/{usePresence-8uaHuPpB.mjs → usePresence-dgOxESVW.mjs} +1 -1
  26. package/dist/packem_shared/useQuery-DMSZbdFz.mjs +2 -0
  27. package/dist/packem_shared/{useStream-Coolvm1E.mjs → useStream-B_XzhM-6.mjs} +1 -1
  28. package/dist/packem_shared/{useSubscription-D-q34veC.mjs → useSubscription-CRqptgB_.mjs} +1 -1
  29. package/dist/packem_shared/useSuspenseQuery-B9DrM8Kw.mjs +2 -0
  30. package/dist/packem_shared/{useVoiceAgent-C6guyO_8.mjs → useVoiceAgent-BHkPJWuv.mjs} +1 -1
  31. package/package.json +1 -1
  32. package/dist/packem_shared/LunoraProvider-BBGmLjtV.mjs +0 -1
  33. package/dist/packem_shared/hydratePreloaded-BTfZ3Y-k.mjs +0 -2
  34. package/dist/packem_shared/lunora-provider-BLU6gzBE.mjs +0 -2
  35. package/dist/packem_shared/use-paginated-core-DBWKHrw9.mjs +0 -2
  36. package/dist/packem_shared/useAction-CfyA8IBO.mjs +0 -2
  37. package/dist/packem_shared/useAuthSessions-DbhLMygw.mjs +0 -2
  38. package/dist/packem_shared/useMutation-BHdcAbSI.mjs +0 -2
  39. package/dist/packem_shared/useQuery-CgQLnrl2.mjs +0 -2
  40. package/dist/packem_shared/useSuspenseQuery-YoTulk0E.mjs +0 -2
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-cCcnpzS8.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-Bn59SpsP.mjs";import{L as f,u as n}from"./packem_shared/lunora-provider-BLU6gzBE.mjs";import{useAction as m}from"./packem_shared/useAction-CfyA8IBO.mjs";import{useAuthSessions as d,useAuthUsers as l,useImpersonate as A,useOrganizations as g,useSignUpInvitations as c}from"./packem_shared/useAuthSessions-DbhLMygw.mjs";import{useAgent as U}from"./packem_shared/useAgent-B9xIcys5.mjs";import{useAgentApprovals as S}from"./packem_shared/useAgentApprovals-BNLOv-N3.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-CAj633xe.mjs";import{useAgentState as L}from"./packem_shared/useAgentState-DV_QtMaZ.mjs";import{useAgentToolEvents as v}from"./packem_shared/useAgentToolEvents-BUj4J1Tk.mjs";import{default as F}from"./packem_shared/useAuth-D-BORwSq.mjs";import{default as M}from"./packem_shared/useClientQuery-DsNsWwjz.mjs";import{default as b}from"./packem_shared/useConnectionStatus-DbnZFUh4.mjs";import{useFlag as O,useFlags as k}from"./packem_shared/useFlag-BwwyJsI4.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-BWjb3Bwp.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-BdNoCySX.mjs";import{useLiveTopic as B}from"./packem_shared/useLiveTopic-BNT52TSr.mjs";import{useMutation as G}from"./packem_shared/useMutation-BHdcAbSI.mjs";import{useMutator as K}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as W}from"./packem_shared/usePaginatedQuery-CLrDYofT.mjs";import{hydratePreloaded as Y,default as Z}from"./packem_shared/hydratePreloaded-BTfZ3Y-k.mjs";import{usePresence as $}from"./packem_shared/usePresence-8uaHuPpB.mjs";import{default as re}from"./packem_shared/useQuery-CgQLnrl2.mjs";import{useRateLimit as te}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as se}from"./packem_shared/useStream-Coolvm1E.mjs";import{default as pe}from"./packem_shared/useSubscription-D-q34veC.mjs";import{default as ne}from"./packem_shared/useSuspenseQuery-YoTulk0E.mjs";import{useVoiceAgent as me}from"./packem_shared/useVoiceAgent-C6guyO_8.mjs";import{createClientQuery as de,getErrorCode as le,getRetryAfterMs as Ae,isConflictError as ge,isForbiddenError as ce,isRateLimitedError as he,isUnauthorizedError as Ue}from"@lunora/client";import{lunoraQueryOptions as Se}from"@lunora/client/query";import{RestrictionError as Ee,UploadControl as Qe,UploadError as Le}from"@visulima/storage-client";import{useChunkedRestUpload as ve,useFileInput as Re,useMultipartUpload as Fe,usePasteUpload as Ie,useTusUpload as Me,useUpload as Te}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,Ee as RestrictionError,u as Unauthenticated,Qe as UploadControl,Le as UploadError,de as createClientQuery,le as getErrorCode,Ae as getRetryAfterMs,Y as hydratePreloaded,ge as isConflictError,ce as isForbiddenError,he as isRateLimitedError,Ue as isUnauthorizedError,Se as lunoraQueryOptions,m as useAction,U as useAgent,S as useAgentApprovals,E as useAgentChat,L as useAgentState,v as useAgentToolEvents,F as useAuth,d as useAuthSessions,a as useAuthState,l as useAuthUsers,ve as useChunkedRestUpload,M as useClientQuery,b as useConnectionStatus,Re as useFileInput,O as useFlag,k as useFlags,V as useHttpStream,A as useImpersonate,q as useInfiniteQuery,B as useLiveTopic,n as useLunora,Fe as useMultipartUpload,G as useMutation,K as useMutator,g as useOrganizations,W as usePaginatedQuery,Ie as usePasteUpload,Z as usePreloadedQuery,$ as usePresence,re as useQuery,te as useRateLimit,c as useSignUpInvitations,se as useStream,pe as useSubscription,ne as useSuspenseQuery,Me as useTusUpload,Te as useUpload,me as useVoiceAgent};
2
+ import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-DgQHaQD5.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-DZhCIjSA.mjs";import{L as f,u as n}from"./packem_shared/lunora-provider-BMJTPKMP.mjs";import{useAction as m}from"./packem_shared/useAction-BGTQyx5l.mjs";import{useAuthSessions as d,useAuthUsers as l,useImpersonate as A,useOrganizations as g,useSignUpInvitations as c}from"./packem_shared/useAuthSessions-CFVMrk0L.mjs";import{useAgent as U}from"./packem_shared/useAgent-BW4uKe79.mjs";import{useAgentApprovals as S}from"./packem_shared/useAgentApprovals-VbOnL2Lx.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-DjLC2W3L.mjs";import{useAgentState as L}from"./packem_shared/useAgentState-CNZ5F4mc.mjs";import{useAgentToolEvents as v}from"./packem_shared/useAgentToolEvents-dndcx99y.mjs";import{default as F}from"./packem_shared/useAuth-C1_ruDmE.mjs";import{default as M}from"./packem_shared/useClientQuery-D-c8YM6Q.mjs";import{default as b}from"./packem_shared/useConnectionStatus-CAmQqRpD.mjs";import{useFlag as O,useFlags as k}from"./packem_shared/useFlag-CWjaNeAp.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-C-VR6P1E.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-BIkpHK0e.mjs";import{useLiveTopic as B}from"./packem_shared/useLiveTopic-Cp5b1ncm.mjs";import{useMutation as G}from"./packem_shared/useMutation-D6p61C2U.mjs";import{useMutator as K}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as W}from"./packem_shared/usePaginatedQuery-B7tBY2XC.mjs";import{hydratePreloaded as Y,default as Z}from"./packem_shared/hydratePreloaded-DLUC_u80.mjs";import{usePresence as $}from"./packem_shared/usePresence-dgOxESVW.mjs";import{default as re}from"./packem_shared/useQuery-DMSZbdFz.mjs";import{useRateLimit as te}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as se}from"./packem_shared/useStream-B_XzhM-6.mjs";import{default as pe}from"./packem_shared/useSubscription-CRqptgB_.mjs";import{default as ne}from"./packem_shared/useSuspenseQuery-B9DrM8Kw.mjs";import{useVoiceAgent as me}from"./packem_shared/useVoiceAgent-BHkPJWuv.mjs";import{createClientQuery as de,getErrorCode as le,getRetryAfterMs as Ae,isConflictError as ge,isForbiddenError as ce,isRateLimitedError as he,isUnauthorizedError as Ue}from"@lunora/client";import{lunoraQueryOptions as Se}from"@lunora/client/query";import{RestrictionError as Ee,UploadControl as Qe,UploadError as Le}from"@visulima/storage-client";import{useChunkedRestUpload as ve,useFileInput as Re,useMultipartUpload as Fe,usePasteUpload as Ie,useTusUpload as Me,useUpload as Te}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,Ee as RestrictionError,u as Unauthenticated,Qe as UploadControl,Le as UploadError,de as createClientQuery,le as getErrorCode,Ae as getRetryAfterMs,Y as hydratePreloaded,ge as isConflictError,ce as isForbiddenError,he as isRateLimitedError,Ue as isUnauthorizedError,Se as lunoraQueryOptions,m as useAction,U as useAgent,S as useAgentApprovals,E as useAgentChat,L as useAgentState,v as useAgentToolEvents,F as useAuth,d as useAuthSessions,a as useAuthState,l as useAuthUsers,ve as useChunkedRestUpload,M as useClientQuery,b as useConnectionStatus,Re as useFileInput,O as useFlag,k as useFlags,V as useHttpStream,A as useImpersonate,q as useInfiniteQuery,B as useLiveTopic,n as useLunora,Fe as useMultipartUpload,G as useMutation,K as useMutator,g as useOrganizations,W as usePaginatedQuery,Ie as usePasteUpload,Z as usePreloadedQuery,$ as usePresence,re as useQuery,te as useRateLimit,c as useSignUpInvitations,se as useStream,pe as useSubscription,ne as useSuspenseQuery,Me as useTusUpload,Te as useUpload,me as useVoiceAgent};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useAuthState as o}from"./useAuthState-Bn59SpsP.mjs";const s=t=>{const{children:n}=t,{isAuthenticated:i}=o();return i?n:void 0},d=t=>{const{children:n}=t,{isAuthenticated:i,isLoading:e}=o();return!e&&!i?n:void 0},r=t=>{const{children:n}=t,{isLoading:i}=o();return i?n:void 0};export{r as AuthLoading,s as Authenticated,d as Unauthenticated};
2
+ import{useAuthState as o}from"./useAuthState-DZhCIjSA.mjs";const s=t=>{const{children:n}=t,{isAuthenticated:i}=o();return i?n:void 0},d=t=>{const{children:n}=t,{isAuthenticated:i,isLoading:e}=o();return!e&&!i?n:void 0},r=t=>{const{children:n}=t,{isLoading:i}=o();return i?n:void 0};export{r as AuthLoading,s as Authenticated,d as Unauthenticated};
@@ -0,0 +1 @@
1
+ import{L as r,u,b as o,a as s}from"./lunora-provider-BMJTPKMP.mjs";export{r as LunoraProvider,u as useLunora,o as useLunoraClientSwapped,s as useLunoraQueryClient};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as K}from"react/compiler-runtime";import{useQuery as P}from"@tanstack/react-query";import{useRef as L,useEffect as I,useSyncExternalStore as N,useState as T}from"react";import{u as w,a as x,g as F,b as O,s as V}from"./lunora-provider-BMJTPKMP.mjs";import{lunoraQueryKey as z}from"@lunora/client/query";const D=function(o,r){const e=K(11);let s;e[0]!==r?(s=r===void 0?{}:r,e[0]=r,e[1]=s):s=e[1];const i=s,t=w(),n=x(),S=L(i.onError);let c;e[2]!==i.onError?(c=()=>{S.current=i.onError},e[2]=i.onError,e[3]=c):c=e[3],I(c);let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=h=>{S.current?.(h)},e[4]=u):u=e[4];const b=u,m=F(t);let a;e[5]!==t?(a=()=>t.identityEpoch(),e[5]=t,e[6]=a):a=e[6];const _=N(m.subscribeIdentityEpoch,a,Y),[Q]=T(t),R=O(),{args:p,functionPath:q,shardKey:l}=o,g=_===0&&!R&&t===Q?o.value:void 0,d={__lunoraRef:q},f=z(d,p,l),{data:v}=P({initialData:g,queryFn:async h=>{const{signal:C}=h;return m.liveValue(n,f,C,{fetch:async()=>t.query(d,p,{shardKey:l}),shardKey:l})},queryKey:f,staleTime:Number.POSITIVE_INFINITY},n),E=V(f);let y;return e[7]!==t||e[8]!==n||e[9]!==E?(y=[t,n,E,b],e[7]=t,e[8]=n,e[9]=E,e[10]=y):y=e[10],I(()=>m.attach(n,f,d,p,l,{onError:b}),y),v===void 0?g:v},G=function(o,r={}){return D(o,r)};function Y(){return 0}export{D as default,G as hydratePreloaded};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as z}from"react/compiler-runtime";import{LunoraError as W}from"@lunora/errors";import{QueryClientContext as x,QueryClientProvider as _,QueryClient as $}from"@tanstack/react-query";import{createContext as U,use as y,useState as T,useEffect as E,useRef as B}from"react";import{stableWireKey as H}from"@lunora/wire";import{jsx as C}from"react/jsx-runtime";const b=e=>H(e),nt=e=>b(e),F=e=>{e!==void 0&&(e.cancel({silent:!0}),e.setState({...e.state,data:void 0,dataUpdatedAt:0,error:null,fetchStatus:"idle",status:"pending"}))},Q={status:"idle"},P=(e,t)=>{for(const s of e.waiters)s(t);e.waiters.clear()},V=1e4,Y=async(e,t,s)=>new Promise((n,a)=>{if(t.aborted){a(t.reason);return}let u,h;const c=()=>{clearTimeout(u),h?.(),e.waiters.delete(r),t.removeEventListener("abort",i)},i=()=>{c(),a(t.reason)},r=d=>{c(),n(d)};u=setTimeout(()=>{r(!1)},V),e.waiters.add(r),t.addEventListener("abort",i,{once:!0}),h=s(()=>{r(!1)}),e.waiters.has(r)||h()});class j{constructor(t){this.client=t}client;entries=new Map;live=new Map;identityWatched=new Set;listening=!1;hasConsumers(t){return this.entries.has(b(t))}async liveValue(t,s,n,a){const{fetch:u,shardKey:h,waitForPush:c=!0}=a;if(!("window"in globalThis)||this.client.getWebSocketImpl()===void 0)return u();const i=b(s),r=this.liveFor(i),d=r.state.status==="pushed"?t.getQueryData(s)??r.state.value:void 0;if(d!==void 0)return d;if(c&&r.state.status!=="errored"&&!this.client.isCrossTabFollower()&&this.client.expectsPush({shardKey:h})){let o;try{o=await Y(r,n,f=>this.client.onConnectionStatus(()=>{this.client.expectsPush({shardKey:h})||f()}))}finally{this.forgetIdleLive(i)}if(o)return this.liveValue(t,s,n,a)}const p=r.state;let l;try{l=await u()}finally{this.forgetIdleLive(i)}if(r.state!==p&&r.state.status==="pushed"){const o=t.getQueryData(s);return o!==void 0?o:r.state.value}return l}clearOnIdentityChange(t){this.listenForIdentityChange(),this.identityWatched.add(t)}stopClearingOnIdentityChange(t){this.identityWatched.delete(t)}subscribeIdentityEpoch=t=>(this.listenForIdentityChange(),this.client.onIdentityChange(t));listenForIdentityChange(){this.listening||(this.listening=!0,this.client.onIdentityChange(()=>{for(const t of this.identityWatched)this.clearQueries(t)}))}clearQueries(t){const s=t.getQueryCache();for(const n of s.findAll({queryKey:["lunora"]}))F(n),n.getObserversCount()===0&&!this.hasConsumers(n.queryKey)&&s.remove(n)}attach(t,s,n,a,u,h={}){const c=b(s);let i=this.entries.get(c);if(!i){i={clients:new Map([[t,0]]),errorCallbacks:new Set,unsubscribe:void 0},this.entries.set(c,i);const l=i;try{i.unsubscribe=this.client.subscribe(n,a,o=>{const f=this.liveFor(c);if(o===void 0){f.state=Q;for(const v of l.clients.keys())F(v.getQueryCache().find({exact:!0,queryKey:s}));return}for(const v of l.clients.keys())v.setQueryData(s,o);f.state={status:"pushed",value:o},P(f,!0)},{onError:o=>{const f=this.liveFor(c);f.state.status!=="pushed"&&(f.state={status:"errored"},P(f,!1));for(const v of l.errorCallbacks)v(o)},shardKey:u})}catch(o){throw this.entries.delete(c),this.dropLive(c),o}}i.clients.set(t,(i.clients.get(t)??0)+1);const r=this.live.get(c);r?.state.status==="pushed"&&t.setQueryData(s,r.state.value);const{onError:d}=h;d&&i.errorCallbacks.add(d);let p=!1;return()=>{if(p)return;p=!0;const l=this.entries.get(c);if(!l)return;const o=(l.clients.get(t)??1)-1;o>0?l.clients.set(t,o):l.clients.delete(t),d&&l.errorCallbacks.delete(d),l.clients.size===0&&(l.unsubscribe?.(),this.entries.delete(c),this.dropLive(c))}}awaitFreshPush(t){const s=this.live.get(b(t));s?.state.status==="pushed"&&(s.state=Q)}liveFor(t){let s=this.live.get(t);return s||(s={state:Q,waiters:new Set},this.live.set(t,s)),s}forgetIdleLive(t){!this.entries.has(t)&&this.live.get(t)?.waiters.size===0&&this.live.delete(t)}dropLive(t){const s=this.live.get(t);s!==void 0&&(s.waiters.size===0?this.live.delete(t):s.state=Q)}}const O=new WeakMap,k=e=>{let t=O.get(e);return t||(t=new j(e),O.set(e,t)),t},N=Symbol.for("@lunora/react/contexts"),G=()=>{const e=globalThis;return e[N]??=new Map,e[N]},J=e=>e===null?"null":typeof e,S=function(e,t){const s=G(),n=J(t),a=s.get(e);if(a!==void 0){if(a.kind!==n)throw new Error(`Context "${e}" was registered with a ${a.kind} default; a copy asked for a ${n} default.`);return a.context}const u=U(t);return s.set(e,{context:u,kind:n}),u},M=S("lunora-client",null),R=S("lunora-query-client",null),A=S("lunora-tanstack-owner",null),D=S("lunora-client-swapped",!1),K=()=>new $({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),it=e=>{const t=z(23),{children:s,client:n,queryClient:a}=e,u=y(x);let h;t[0]!==u||t[1]!==a?(h=()=>a??u??K(),t[0]=u,t[1]=a,t[2]=h):h=t[2];const[c]=T(h),i=a??u??c;let r,d;t[3]!==n||t[4]!==i?(r=()=>{k(n).clearOnIdentityChange(i)},d=[n,i],t[3]=n,t[4]=i,t[5]=r,t[6]=d):(r=t[5],d=t[6]),E(r,d);const p=B(n);let l,o;t[7]!==n||t[8]!==i?(l=()=>{p.current!==n&&(k(p.current).stopClearingOnIdentityChange(i),p.current=n,k(n).clearQueries(i),i.invalidateQueries({queryKey:["lunora"]}))},o=[n,i],t[7]=n,t[8]=i,t[9]=l,t[10]=o):(l=t[9],o=t[10]),E(l,o);const[f]=T(n),v=n!==f;let w;t[11]!==s||t[12]!==v?(w=C(D,{value:v,children:s}),t[11]=s,t[12]=v,t[13]=w):w=t[13];let g;t[14]!==n||t[15]!==w?(g=C(M,{value:n,children:w}),t[14]=n,t[15]=w,t[16]=g):g=t[16];let m;t[17]!==i||t[18]!==g?(m=C(A,{value:x,children:C(R,{value:i,children:g})}),t[17]=i,t[18]=g,t[19]=m):m=t[19];const L=m;if(u===i)return L;let I;return t[20]!==L||t[21]!==i?(I=C(_,{client:i,children:L}),t[20]=L,t[21]=i,t[22]=I):I=t[22],I},rt=()=>{const e=y(A),t=y(x),s=y(R),a=(e===x?t:void 0)??s??t;if(!a)throw new W("INTERNAL","useLunoraQueryClient must be used inside <LunoraProvider />");return a},ot=()=>y(D),at=()=>{const e=y(M);if(!e)throw new W("INTERNAL","useLunora must be used inside <LunoraProvider />");return e};export{it as L,rt as a,ot as b,k as g,nt as s,at as u};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as R}from"react/compiler-runtime";import{useRef as $,useEffect as b}from"react";import{g as h}from"./lunora-provider-BLU6gzBE.mjs";const x=g=>{const e=R(16),{args:a,argsKey:E,client:r,function_:n,onError:s,queryClient:t,queryKey:m,shardKey:i,skipped:o}=g,p=`${n.__lunoraRef}\0${E}\0${i??""}`,y=$(s);let c;e[0]!==s?(c=()=>{y.current=s},e[0]=s,e[1]=c):c=e[1],b(c);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=K=>{y.current?.(K)},e[2]=u):u=e[2];const _=u;let f;e[3]!==a||e[4]!==r||e[5]!==n||e[6]!==t||e[7]!==m||e[8]!==i||e[9]!==o?(f=()=>o?S:h(r).attach(t,m,n,a,i,{onError:_}),e[3]=a,e[4]=r,e[5]=n,e[6]=t,e[7]=m,e[8]=i,e[9]=o,e[10]=f):f=e[10];let l;e[11]!==r||e[12]!==t||e[13]!==o||e[14]!==p?(l=[r,t,p,o,_],e[11]=r,e[12]=t,e[13]=o,e[14]=p,e[15]=l):l=e[15],b(f,l)};function S(){}export{x as u};
2
+ import{c as R}from"react/compiler-runtime";import{useRef as $,useEffect as b}from"react";import{g as h}from"./lunora-provider-BMJTPKMP.mjs";const x=g=>{const e=R(16),{args:a,argsKey:E,client:r,function_:n,onError:s,queryClient:t,queryKey:m,shardKey:i,skipped:o}=g,p=`${n.__lunoraRef}\0${E}\0${i??""}`,y=$(s);let c;e[0]!==s?(c=()=>{y.current=s},e[0]=s,e[1]=c):c=e[1],b(c);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=K=>{y.current?.(K)},e[2]=u):u=e[2];const _=u;let f;e[3]!==a||e[4]!==r||e[5]!==n||e[6]!==t||e[7]!==m||e[8]!==i||e[9]!==o?(f=()=>o?S:h(r).attach(t,m,n,a,i,{onError:_}),e[3]=a,e[4]=r,e[5]=n,e[6]=t,e[7]=m,e[8]=i,e[9]=o,e[10]=f):f=e[10];let l;e[11]!==r||e[12]!==t||e[13]!==o||e[14]!==p?(l=[r,t,p,o,_],e[11]=r,e[12]=t,e[13]=o,e[14]=p,e[15]=l):l=e[15],b(f,l)};function S(){}export{x as u};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{initialPages as z,isHeadPage as G,rebalance as J,derivePaginationStatus as V,applyLoadMore as U,classifyPageFailure as X,headPage as Z}from"@lunora/client/pagination";import{useRef as y,useReducer as ee,useState as _,useEffect as p,useMemo as se,useCallback as te}from"react";import{u as re,a as ne,s as I,g as $}from"./lunora-provider-BMJTPKMP.mjs";import{CancelledError as ae}from"@tanstack/react-query";import{lunoraQueryKey as S}from"@lunora/client/query";const oe=c=>c instanceof ae?!0:c instanceof Error&&c.message==="CancelledError"&&"revert"in c&&"silent"in c,ce=function(c){const v=y(void 0);return v.current??=c(),v},ye=function(c,v,F){const d=re(),u=ne(),{initialNumItems:w,shardKey:E}=F,l=v==="skip",P=l?{}:v,[,j]=ee(e=>e+1,0),[m,K]=_(()=>z(w)),[W,C]=_(void 0),O=y(F.onError);p(()=>{O.current=F.onError});const R=`${I(S(c,P,E))}::${String(w)}`,H=y(R),Q=y(!1),g=y(void 0);H.current!==R&&(H.current=R,Q.current=!1,g.current=void 0,K(z(w)),C(void 0));const x=se(()=>new WeakMap,[R]),q=m.map(e=>{let r=x.get(e);if(r===void 0){const a={...P,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},o=S(c,a,E);r={args:a,hash:I(o),key:o},x.set(e,r)}return r}),A=q.map(({hash:e})=>e).join("|"),k=y({baseArgs:P,entries:[],fn:c,pages:m,shardKey:E});p(()=>{k.current={baseArgs:P,entries:q,fn:c,pages:m,shardKey:E}});const N=(e,r,a)=>{if(H.current!==R)return;const o=k.current,t=s=>({...o.baseArgs,paginationOpts:{cursor:s.lower,endCursor:s.upper,numItems:s.numItems}}),n=s=>I(S(o.fn,t(s),o.shardKey)),i=X(o.pages,s=>n(s)===e,a,Q.current);if(i==="restart"){const s=Z(w),f=[s];d.resnapshot(o.fn,t(s),{shardKey:o.shardKey}),$(d).awaitFreshPush(S(o.fn,t(s),o.shardKey)),g.current=n(s),k.current={...o,pages:f},Q.current=!0,K(f),C(void 0)}i==="surface"&&(C(a),K(s=>{const f=s.at(-1);return s.length<=1||!f||u.getQueryData(r)!==void 0?s:n(f)===e?s.slice(0,-1):s}),O.current?.(a))},L=ce(()=>new Map),T=y(d);p(()=>{const e=L.current;if(T.current!==d){for(const t of e.values())t();e.clear(),T.current=d}if(l){for(const t of e.values())t();e.clear();return}const r=k.current,a=$(d),o=new Set(r.entries.map(({hash:t})=>t));for(const[t,n]of e)o.has(t)||(n(),e.delete(t));for(const t of r.entries){const{hash:n}=t;if(e.has(n))continue;const i=async()=>d.query(r.fn,t.args,{shardKey:r.shardKey}),s=()=>{u.fetchQuery({gcTime:Number.POSITIVE_INFINITY,queryFn:async({signal:h})=>a.liveValue(u,t.key,h,{fetch:i,shardKey:r.shardKey}),queryKey:t.key,staleTime:0}).catch(h=>{if(oe(h)){a.hasConsumers(t.key)&&s();return}N(n,t.key,h instanceof Error?{code:h.code,message:h.message}:{message:String(h)})})};s();const f=a.attach(u,t.key,r.fn,t.args,r.shardKey,{onError:D=>{N(n,t.key,D)}}),b=t.key;e.set(n,()=>{f(),a.hasConsumers(b)||u.removeQueries({exact:!0,queryKey:b})})}},[d,u,A,l]),p(()=>()=>{for(const e of L.current.values())e();L.current.clear()},[]),p(()=>{const e=u.getQueryCache(),r=new Set,a=new Set;for(const[n,{hash:i}]of q.entries())r.add(i),m[n]!==void 0&&!G(m[n])&&a.add(i);const o=c.__lunoraRef;return e.subscribe(n=>{if(n.type!=="updated")return;const i=n.query.queryKey;if(i[1]!==o)return;const s=I(i);r.has(s)&&(n.action.type==="success"&&(a.has(s)&&(Q.current=!1),g.current===s&&(g.current=void 0),C(void 0)),j())})},[u,A]);const M=l?[]:q.map(({hash:e,key:r})=>g.current===e?void 0:u.getQueryData(r));p(()=>{if(l)return;const e=J(m,M);e&&K(e)});const{status:Y}=V(l,M),B=te(e=>{C(void 0),K(r=>{const a=k.current,o=r.map(s=>{const f={...a.baseArgs,paginationOpts:{cursor:s.lower,endCursor:s.upper,numItems:s.numItems}},b=S(a.fn,f,a.shardKey);return g.current===I(b)?void 0:u.getQueryData(b)}),{nextCursor:t,status:n}=V(!1,o);return U(r,n==="CanLoadMore"?t:void 0,e)??r})},[u]);return{error:W,loadMore:B,pageResults:M,status:Y}};export{ye as u};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as L}from"react/compiler-runtime";import{createCallRunner as R}from"@lunora/client";import{useMutation as k}from"@tanstack/react-query";import{useState as n}from"react";import{u as q,a as x}from"./lunora-provider-BMJTPKMP.mjs";const S=a=>{const t=L(12),i=q(),C=x(),[c,g]=n(void 0),[l,u]=n(void 0),[m,M]=n(!1);let o;t[0]!==i||t[1]!==a?(o={mutationFn:async e=>{const{args:v,options:A}=e;return i.action(a,v,A)},networkMode:"always",retry:0},t[0]=i,t[1]=a,t[2]=o):o=t[2];const{mutateAsync:d,reset:p}=k(o,C);let s;t[3]!==d||t[4]!==p?(s=()=>({call:R(async(e,v)=>d({args:e,options:v}),{setError:u,setPending:M,setResult:e=>{g(()=>e),u(void 0)}}),reset:()=>{g(void 0),u(void 0),p()}}),t[3]=d,t[4]=p,t[5]=s):s=t[5];const[w]=n(s),{call:f,reset:y}=w;let r;return t[6]!==f||t[7]!==c||t[8]!==l||t[9]!==m||t[10]!==y?(r={call:f,data:c,error:l,pending:m,reset:y},t[6]=f,t[7]=c,t[8]=l,t[9]=m,t[10]=y,t[11]=r):r=t[11],r};export{S as useAction};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as N}from"react/compiler-runtime";import{useMutation as R}from"./useMutation-BHdcAbSI.mjs";import O from"./useSubscription-D-q34veC.mjs";const b={__lunoraRef:""},F=_=>{const t=N(20),{api:A,cancel:a,onError:d,run:I,runArgs:f,threadKey:e}=_,s=R(I),T=R(a??b);let c;t[0]!==e?(c={key:e},t[0]=e,t[1]=c):c=t[1];let r;t[2]!==d?(r={onError:d},t[2]=d,t[3]=r):r=t[3];const{data:v,error:p}=O(A.agents.agentThread,c,r),n=v,g=n?.status,o=n?.instanceId,{mutate:m}=s,{mutate:M}=T;let i;t[4]!==f||t[5]!==m||t[6]!==e?(i=async(w,E)=>{await m({input:w,threadKey:e,...f,...E})},t[4]=f,t[5]=m,t[6]=e,t[7]=i):i=t[7];const h=i;let u;t[8]!==M||t[9]!==a||t[10]!==o||t[11]!==e?(u=async()=>{a===void 0||o===void 0||await M({instanceId:o,threadKey:e})},t[8]=M,t[9]=a,t[10]=o,t[11]=e,t[12]=u):u=t[12];const y=u;let l;return t[13]!==y||t[14]!==p||t[15]!==h||t[16]!==s.pending||t[17]!==g||t[18]!==n?(l={cancel:y,error:p,pending:s.pending,run:h,status:g,thread:n},t[13]=y,t[14]=p,t[15]=h,t[16]=s.pending,t[17]=g,t[18]=n,t[19]=l):l=t[19],l};export{F as useAgent};
2
+ import{c as N}from"react/compiler-runtime";import{useMutation as R}from"./useMutation-D6p61C2U.mjs";import O from"./useSubscription-CRqptgB_.mjs";const b={__lunoraRef:""},F=_=>{const t=N(20),{api:A,cancel:a,onError:d,run:I,runArgs:f,threadKey:e}=_,s=R(I),T=R(a??b);let c;t[0]!==e?(c={key:e},t[0]=e,t[1]=c):c=t[1];let r;t[2]!==d?(r={onError:d},t[2]=d,t[3]=r):r=t[3];const{data:v,error:p}=O(A.agents.agentThread,c,r),n=v,g=n?.status,o=n?.instanceId,{mutate:m}=s,{mutate:M}=T;let i;t[4]!==f||t[5]!==m||t[6]!==e?(i=async(w,E)=>{await m({input:w,threadKey:e,...f,...E})},t[4]=f,t[5]=m,t[6]=e,t[7]=i):i=t[7];const h=i;let u;t[8]!==M||t[9]!==a||t[10]!==o||t[11]!==e?(u=async()=>{a===void 0||o===void 0||await M({instanceId:o,threadKey:e})},t[8]=M,t[9]=a,t[10]=o,t[11]=e,t[12]=u):u=t[12];const y=u;let l;return t[13]!==y||t[14]!==p||t[15]!==h||t[16]!==s.pending||t[17]!==g||t[18]!==n?(l={cancel:y,error:p,pending:s.pending,run:h,status:g,thread:n},t[13]=y,t[14]=p,t[15]=h,t[16]=s.pending,t[17]=g,t[18]=n,t[19]=l):l=t[19],l};export{F as useAgent};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as p}from"react/compiler-runtime";import c from"./useSubscription-D-q34veC.mjs";const m=n=>{const e=p(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:a,error:r}=c(n.api.agents.agentPendingApprovals,t),s=a;let o;return e[1]!==r||e[2]!==s?(o={approvals:s,error:r},e[1]=r,e[2]=s,e[3]=o):o=e[3],o};export{m as useAgentApprovals};
2
+ import{c as p}from"react/compiler-runtime";import c from"./useSubscription-CRqptgB_.mjs";const m=n=>{const e=p(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:a,error:r}=c(n.api.agents.agentPendingApprovals,t),s=a;let o;return e[1]!==r||e[2]!==s?(o={approvals:s,error:r},e[1]=r,e[2]=s,e[3]=o):o=e[3],o};export{m as useAgentApprovals};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as nt,useRef as k}from"react";import{u as rt}from"./lunora-provider-BLU6gzBE.mjs";import{useMutation as s}from"./useMutation-BHdcAbSI.mjs";import{useStream as at}from"./useStream-Coolvm1E.mjs";import d from"./useSubscription-D-q34veC.mjs";const ot={__lunoraRef:""},st={__lunoraRef:""},ct=[],it=[],kt=A=>{const{api:r,cancel:m,limit:g,onError:i,send:E,sendArgs:_,stream:v,threadKey:e}=A,T=g===void 0?{key:e}:{key:e,limit:g},{data:w,error:x}=d(r.agents.agentMessages,T,{onError:i}),{data:G,error:I}=d(r.agents.agentThread,{key:e},{onError:i}),{data:O,error:b}=d(r.agents.agentApprovalGrants,{key:e},{onError:i}),C=v===void 0?"skip":{key:e},{chunks:D}=at(v??st,C),j=s(E),q=s(m??ot),F=s(r.agents.agentResolveApproval),N=s(r.agents.agentRevokeApprovalGrant),K=s(r.agents.agentDeclineSecret),P=rt(),[Y,u]=nt([]),h=k(0),f=k(e);f.current!==e&&(f.current=e,u([]));const y=G,L=y?.status,c=y?.instanceId,a=w??ct,S=M(Y,a),U=R(a),$=S.length===0?a:[...a,...S.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:U+1+n}))],z=a.filter(t=>t.role==="assistant").length,B=D.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=z).map(t=>t.text).join(""),{mutate:H}=j,{mutate:J}=q,{mutate:Q}=F,{mutate:V}=N,{mutate:W}=K,X=async(t,n)=>{const o=h.current;h.current+=1;const Z=R(a);u(p=>[...M(p,a),{content:t,id:o,maxDurableSeqAtSend:Z}]);try{await H({input:t,threadKey:e,..._,...n})}catch(p){throw u(tt=>tt.filter(et=>et.id!==o)),p}},l=async(t,n,o)=>{if(c===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await Q({decision:t,instanceId:c,threadKey:e,toolCallId:n,...o===void 0?{}:{note:o}})};return{approvalGrants:O??it,approve:(t,n)=>l("approve",t,n),approveForThread:(t,n)=>l("approve_for_thread",t,n),cancel:async()=>{m===void 0||c===void 0||await J({instanceId:c,threadKey:e})},declineSecret:async t=>{await W({threadKey:e,toolCallId:t})},error:x??I??b,messages:$,reject:(t,n)=>l("reject",t,n),revokeGrant:async t=>{await V({threadKey:e,toolName:t})},send:X,status:L,streamingText:B,supplySecret:async(t,n)=>{await P.mutation(r.agents.agentSupplySecret,{secret:n,threadKey:e,toolCallId:t},{onlineOnly:!0})}}};export{kt as useAgentChat};
2
+ import{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as nt,useRef as k}from"react";import{u as rt}from"./lunora-provider-BMJTPKMP.mjs";import{useMutation as s}from"./useMutation-D6p61C2U.mjs";import{useStream as at}from"./useStream-B_XzhM-6.mjs";import d from"./useSubscription-CRqptgB_.mjs";const ot={__lunoraRef:""},st={__lunoraRef:""},ct=[],it=[],kt=A=>{const{api:r,cancel:m,limit:g,onError:i,send:E,sendArgs:_,stream:v,threadKey:e}=A,T=g===void 0?{key:e}:{key:e,limit:g},{data:w,error:x}=d(r.agents.agentMessages,T,{onError:i}),{data:G,error:I}=d(r.agents.agentThread,{key:e},{onError:i}),{data:O,error:b}=d(r.agents.agentApprovalGrants,{key:e},{onError:i}),C=v===void 0?"skip":{key:e},{chunks:D}=at(v??st,C),j=s(E),q=s(m??ot),F=s(r.agents.agentResolveApproval),N=s(r.agents.agentRevokeApprovalGrant),K=s(r.agents.agentDeclineSecret),P=rt(),[Y,u]=nt([]),h=k(0),f=k(e);f.current!==e&&(f.current=e,u([]));const y=G,L=y?.status,c=y?.instanceId,a=w??ct,S=M(Y,a),U=R(a),$=S.length===0?a:[...a,...S.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:U+1+n}))],z=a.filter(t=>t.role==="assistant").length,B=D.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=z).map(t=>t.text).join(""),{mutate:H}=j,{mutate:J}=q,{mutate:Q}=F,{mutate:V}=N,{mutate:W}=K,X=async(t,n)=>{const o=h.current;h.current+=1;const Z=R(a);u(p=>[...M(p,a),{content:t,id:o,maxDurableSeqAtSend:Z}]);try{await H({input:t,threadKey:e,..._,...n})}catch(p){throw u(tt=>tt.filter(et=>et.id!==o)),p}},l=async(t,n,o)=>{if(c===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await Q({decision:t,instanceId:c,threadKey:e,toolCallId:n,...o===void 0?{}:{note:o}})};return{approvalGrants:O??it,approve:(t,n)=>l("approve",t,n),approveForThread:(t,n)=>l("approve_for_thread",t,n),cancel:async()=>{m===void 0||c===void 0||await J({instanceId:c,threadKey:e})},declineSecret:async t=>{await W({threadKey:e,toolCallId:t})},error:x??I??b,messages:$,reject:(t,n)=>l("reject",t,n),revokeGrant:async t=>{await V({threadKey:e,toolName:t})},send:X,status:L,streamingText:B,supplySecret:async(t,n)=>{await P.mutation(r.agents.agentSupplySecret,{secret:n,threadKey:e,toolCallId:t},{onlineOnly:!0})}}};export{kt as useAgentChat};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as o}from"react/compiler-runtime";import d from"./useSubscription-D-q34veC.mjs";const l=t=>{const e=o(5);let r;e[0]!==t.threadKey?(r={key:t.threadKey},e[0]=t.threadKey,e[1]=r):r=e[1];const{data:n,error:s}=d(t.api.agents.agentState,r),c=n;let a;return e[2]!==s||e[3]!==c?(a={error:s,state:c},e[2]=s,e[3]=c,e[4]=a):a=e[4],a};export{l as useAgentState};
2
+ import{c as o}from"react/compiler-runtime";import d from"./useSubscription-CRqptgB_.mjs";const l=t=>{const e=o(5);let r;e[0]!==t.threadKey?(r={key:t.threadKey},e[0]=t.threadKey,e[1]=r):r=e[1];const{data:n,error:s}=d(t.api.agents.agentState,r),c=n;let a;return e[2]!==s||e[3]!==c?(a={error:s,state:c},e[2]=s,e[3]=c,e[4]=a):a=e[4],a};export{l as useAgentState};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as C}from"react/compiler-runtime";import{useStream as y}from"./useStream-Coolvm1E.mjs";import _ from"./useSubscription-D-q34veC.mjs";const I={__lunoraRef:""},N=[],S={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},k=o=>{const t=o.status===void 0?void 0:S[o.status];if(t!==void 0)return{seq:o.seq,type:t,...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}},q=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(r=>({input:r.input,seq:o.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(o.role!=="tool")return;const t=k(o);return t!==void 0?[t]:[{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}}]},m=o=>{const t=C(12),{api:r,limit:n,stream:i,threadKey:l}=o;let a;t[0]!==n||t[1]!==l?(a=n===void 0?{key:l}:{key:l,limit:n},t[0]=n,t[1]=l,t[2]=a):a=t[2];const v=a,{data:f}=_(r.agents.agentMessages,v);let s;t[3]!==i||t[4]!==l?(s=i===void 0?"skip":{key:l},t[3]=i,t[4]=l,t[5]=s):s=t[5];const E=s,{chunks:p}=y(i??I,E),c=f??N;let e;if(t[6]!==p||t[7]!==c||t[8]!==l){e=c.flatMap(A);for(const d of p)d.kind==="progress"&&d.threadKey===l&&e.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});t[6]=p,t[7]=c,t[8]=l,t[9]=e}else e=t[9];let u;return t[10]!==e?(u={events:e},t[10]=e,t[11]=u):u=t[11],u};function A(o){return q(o)??[]}export{m as useAgentToolEvents};
2
+ import{c as C}from"react/compiler-runtime";import{useStream as y}from"./useStream-B_XzhM-6.mjs";import _ from"./useSubscription-CRqptgB_.mjs";const I={__lunoraRef:""},N=[],S={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},k=o=>{const t=o.status===void 0?void 0:S[o.status];if(t!==void 0)return{seq:o.seq,type:t,...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}},q=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(r=>({input:r.input,seq:o.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(o.role!=="tool")return;const t=k(o);return t!==void 0?[t]:[{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}}]},m=o=>{const t=C(12),{api:r,limit:n,stream:i,threadKey:l}=o;let a;t[0]!==n||t[1]!==l?(a=n===void 0?{key:l}:{key:l,limit:n},t[0]=n,t[1]=l,t[2]=a):a=t[2];const v=a,{data:f}=_(r.agents.agentMessages,v);let s;t[3]!==i||t[4]!==l?(s=i===void 0?"skip":{key:l},t[3]=i,t[4]=l,t[5]=s):s=t[5];const E=s,{chunks:p}=y(i??I,E),c=f??N;let e;if(t[6]!==p||t[7]!==c||t[8]!==l){e=c.flatMap(A);for(const d of p)d.kind==="progress"&&d.threadKey===l&&e.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});t[6]=p,t[7]=c,t[8]=l,t[9]=e}else e=t[9];let u;return t[10]!==e?(u={events:e},t[10]=e,t[11]=u):u=t[11],u};function A(o){return q(o)??[]}export{m as useAgentToolEvents};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as h}from"react/compiler-runtime";import{getIdentityStore as k}from"@lunora/client/auth";import{useSyncExternalStore as p}from"react";import{u as A}from"./lunora-provider-BLU6gzBE.mjs";const _=()=>{const t=h(13),e=A();let o;t[0]!==e?(o=k(e),t[0]=e,t[1]=o):o=t[1];const n=o;let s,r,u;t[2]!==e?(s=g=>e.onAuthTokenChange(g),r=()=>e.getAuthToken(),u=()=>e.getAuthToken(),t[2]=e,t[3]=s,t[4]=r,t[5]=u):(s=t[3],r=t[4],u=t[5]);const i=p(s,r,u),f=p(n.subscribe,n.getUser,T),m=p(n.subscribe,n.getStatus,b);let l;t[6]!==e?(l=g=>{e.setAuthToken(g)},t[6]=e,t[7]=l):l=t[7];const a=l;let c;return t[8]!==a||t[9]!==m||t[10]!==i||t[11]!==f?(c={setToken:a,status:m,token:i,user:f},t[8]=a,t[9]=m,t[10]=i,t[11]=f,t[12]=c):c=t[12],c};function T(){return null}function b(){return"loading"}export{_ as default};
2
+ import{c as h}from"react/compiler-runtime";import{getIdentityStore as k}from"@lunora/client/auth";import{useSyncExternalStore as p}from"react";import{u as A}from"./lunora-provider-BMJTPKMP.mjs";const _=()=>{const t=h(13),e=A();let o;t[0]!==e?(o=k(e),t[0]=e,t[1]=o):o=t[1];const n=o;let s,r,u;t[2]!==e?(s=g=>e.onAuthTokenChange(g),r=()=>e.getAuthToken(),u=()=>e.getAuthToken(),t[2]=e,t[3]=s,t[4]=r,t[5]=u):(s=t[3],r=t[4],u=t[5]);const i=p(s,r,u),f=p(n.subscribe,n.getUser,T),m=p(n.subscribe,n.getStatus,b);let l;t[6]!==e?(l=g=>{e.setAuthToken(g)},t[6]=e,t[7]=l):l=t[7];const a=l;let c;return t[8]!==a||t[9]!==m||t[10]!==i||t[11]!==f?(c={setToken:a,status:m,token:i,user:f},t[8]=a,t[9]=m,t[10]=i,t[11]=f,t[12]=c):c=t[12],c};function T(){return null}function b(){return"loading"}export{_ as default};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as f}from"react/compiler-runtime";import{isLunoraAdminClient as I}from"@lunora/client/admin";import{authSessionsList as b,authUsersList as z,authOrganizationsList as C,authSignUpInvitationsList as U,ADMIN_AUTH_DEFAULT_PAGE_SIZE as q,subscribeAdminAuthIdentity as w,adminAuthListQueryKey as E,adminAuthListHasMore as P}from"@lunora/client/auth";import{LunoraError as M}from"@lunora/errors";import{useMutation as T,useQuery as $,keepPreviousData as D}from"@tanstack/react-query";import{useState as _,useSyncExternalStore as F}from"react";import{a as y,u as K}from"./lunora-provider-BMJTPKMP.mjs";const p=()=>{const e=K();if(!I(e))throw new M("INTERNAL","The admin auth hooks need a LunoraAdminClient: construct the provider's client with `new LunoraAdminClient(...)` from `@lunora/client/admin`.");return e};function h(e,t,i={}){const{enabled:a=!0,pageSize:n=q}=i,[s,r]=_(n),o=y(),c=F(m=>w(e,m),()=>e.currentIdentity(),()=>e.currentIdentity()),l=E(c,t,s),u=$({enabled:a,placeholderData:(m,v)=>v?.queryKey[1]===l[1]?D(m):void 0,queryFn:()=>t.fetchPage(s),queryKey:l,staleTime:0},o),d=u.data?.rows,L=u.data?.total,A=P(u.data),g=()=>{A&&r(m=>m+n)},S=()=>{u.refetch().catch(()=>{})};return{data:d,error:u.error??void 0,hasMore:A,loadMore:g,loading:u.isLoading,refetch:S,total:L}}const R=e=>{const t=f(3),i=e===void 0?{}:e,a=p(),{enabled:n,pageSize:s,...r}=i;let o;return t[0]!==n||t[1]!==s?(o={enabled:n,pageSize:s},t[0]=n,t[1]=s,t[2]=o):o=t[2],h(a,z(a,r),o)},Z=e=>{const t=f(7);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const a=i,n=p(),{enabled:s,pageSize:r}=a;let o;t[2]!==n?(o=C(n),t[2]=n,t[3]=o):o=t[3];let c;return t[4]!==s||t[5]!==r?(c={enabled:s,pageSize:r},t[4]=s,t[5]=r,t[6]=c):c=t[6],h(n,o,c)},j=e=>{const t=f(7);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const a=i,n=p(),{enabled:s,pageSize:r}=a;let o;t[2]!==n?(o=U(n),t[2]=n,t[3]=o):o=t[3];let c;return t[4]!==s||t[5]!==r?(c={enabled:s,pageSize:r},t[4]=s,t[5]=r,t[6]=c):c=t[6],h(n,o,c)},B=e=>{const t=f(3),i=e===void 0?{}:e,a=p(),{enabled:n,pageSize:s,userId:r}=i;let o;return t[0]!==n||t[1]!==s?(o={enabled:n,pageSize:s},t[0]=n,t[1]=s,t[2]=o):o=t[2],h(a,b(a,{userId:r}),o)},J=()=>{const e=f(10),t=p(),i=y();let a;e[0]!==t?(a={mutationFn:d=>t.impersonateAuthUser({userId:d})},e[0]=t,e[1]=a):a=e[1];const n=T(a,i),{mutateAsync:s,reset:r}=n;let o;e[2]!==s?(o=d=>s(d),e[2]=s,e[3]=o):o=e[3];const c=o,l=n.error??void 0;let u;return e[4]!==c||e[5]!==n.data||e[6]!==n.isPending||e[7]!==r||e[8]!==l?(u={data:n.data,error:l,impersonate:c,pending:n.isPending,reset:r},e[4]=c,e[5]=n.data,e[6]=n.isPending,e[7]=r,e[8]=l,e[9]=u):u=e[9],u};export{B as useAuthSessions,R as useAuthUsers,J as useImpersonate,Z as useOrganizations,j as useSignUpInvitations};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as u}from"react/compiler-runtime";import{isAuthenticatedStatus as r,isLoadingStatus as a}from"@lunora/client/auth";import n from"./useAuth-D-BORwSq.mjs";const m=()=>{const t=u(7),{status:e}=n();let s;t[0]!==e?(s=r(e),t[0]=e,t[1]=s):s=t[1];let i;t[2]!==e?(i=a(e),t[2]=e,t[3]=i):i=t[3];let o;return t[4]!==s||t[5]!==i?(o={isAuthenticated:s,isLoading:i},t[4]=s,t[5]=i,t[6]=o):o=t[6],o};export{m as useAuthState};
2
+ import{c as u}from"react/compiler-runtime";import{isAuthenticatedStatus as r,isLoadingStatus as a}from"@lunora/client/auth";import n from"./useAuth-C1_ruDmE.mjs";const m=()=>{const t=u(7),{status:e}=n();let s;t[0]!==e?(s=r(e),t[0]=e,t[1]=s):s=t[1];let i;t[2]!==e?(i=a(e),t[2]=e,t[3]=i):i=t[3];let o;return t[4]!==s||t[5]!==i?(o={isAuthenticated:s,isLoading:i},t[4]=s,t[5]=i,t[6]=o):o=t[6],o};export{m as useAuthState};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useCallback as u,useSyncExternalStore as l}from"react";import{u as c}from"./lunora-provider-BLU6gzBE.mjs";const y=e=>{const t=c(),n=u(s=>t.subscribeClientQuery(e,()=>{s()}),[t,e.key]),r=l(n,()=>t.getClientQuery(e),()=>t.getClientQuery(e)),o=u(s=>{t.setClientQuery(e,s)},[t,e]);return[r,o]};export{y as default};
2
+ import{useCallback as u,useSyncExternalStore as l}from"react";import{u as c}from"./lunora-provider-BMJTPKMP.mjs";const y=e=>{const t=c(),n=u(s=>t.subscribeClientQuery(e,()=>{s()}),[t,e.key]),r=l(n,()=>t.getClientQuery(e),()=>t.getClientQuery(e)),o=u(s=>{t.setClientQuery(e,s)},[t,e]);return[r,o]};export{y as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as r}from"react/compiler-runtime";import{useSyncExternalStore as u}from"react";import{u as a}from"./lunora-provider-BLU6gzBE.mjs";const S=()=>{const t=r(4),n=a();let o,e,s;return t[0]!==n?(o=c=>n.onConnectionStatus(()=>{c()}),e=()=>n.connectionStatus(),s=()=>n.connectionStatus(),t[0]=n,t[1]=o,t[2]=e,t[3]=s):(o=t[1],e=t[2],s=t[3]),u(o,e,s)};export{S as default};
2
+ import{c as r}from"react/compiler-runtime";import{useSyncExternalStore as u}from"react";import{u as a}from"./lunora-provider-BMJTPKMP.mjs";const S=()=>{const t=r(4),n=a();let o,e,s;return t[0]!==n?(o=c=>n.onConnectionStatus(()=>{c()}),e=()=>n.connectionStatus(),s=()=>n.connectionStatus(),t[0]=n,t[1]=o,t[2]=e,t[3]=s):(o=t[1],e=t[2],s=t[3]),u(o,e,s)};export{S as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useState as _,useRef as i,useEffect as b}from"react";import{u as d}from"./lunora-provider-BLU6gzBE.mjs";import{stableStringify as K}from"@lunora/wire";const g="__lunora_flags__:eval",m=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:g},F=(t,e,n)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:m(e.default)},s=>{n(s)},{onError:()=>{n(e.default)}})}catch{return()=>{}}},S=(t,e)=>{const n=d(),[s,r]=_(e),o=m(e),u=`${t}::${o}`,f=i(u);f.current!==u&&(f.current=u,r(e));const l=i(e);return b(()=>{l.current=e}),b(()=>{let a=!1;const c=l.current;r(c);const p=F(n,{default:c,key:t},y=>{a||r(y)});return()=>{a=!0,p()}},[n,t,o]),s},h=t=>{const e=d(),[n,s]=_(t),r=K(t),o=i(r);o.current!==r&&(o.current=r,s(t));const u=i(t);return b(()=>{u.current=t}),b(()=>{let f=!1;const l=u.current;s(l);const a=[];for(const[c,p]of Object.entries(l))a.push(F(e,{default:p,key:c},y=>{f||s(R=>({...R,[c]:y}))}));return()=>{f=!0;for(const c of a)c()}},[e,r]),n};export{S as useFlag,h as useFlags};
2
+ import{useState as _,useRef as i,useEffect as b}from"react";import{u as d}from"./lunora-provider-BMJTPKMP.mjs";import{stableStringify as K}from"@lunora/wire";const g="__lunora_flags__:eval",m=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:g},F=(t,e,n)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:m(e.default)},s=>{n(s)},{onError:()=>{n(e.default)}})}catch{return()=>{}}},S=(t,e)=>{const n=d(),[s,r]=_(e),o=m(e),u=`${t}::${o}`,f=i(u);f.current!==u&&(f.current=u,r(e));const l=i(e);return b(()=>{l.current=e}),b(()=>{let a=!1;const c=l.current;r(c);const p=F(n,{default:c,key:t},y=>{a||r(y)});return()=>{a=!0,p()}},[n,t,o]),s},h=t=>{const e=d(),[n,s]=_(t),r=K(t),o=i(r);o.current!==r&&(o.current=r,s(t));const u=i(t);return b(()=>{u.current=t}),b(()=>{let f=!1;const l=u.current;s(l);const a=[];for(const[c,p]of Object.entries(l))a.push(F(e,{default:p,key:c},y=>{f||s(R=>({...R,[c]:y}))}));return()=>{f=!0;for(const c of a)c()}},[e,r]),n};export{S as useFlag,h as useFlags};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as S}from"react/compiler-runtime";import{useReducer as _,useRef as v,useEffect as R}from"react";import{u as b}from"./lunora-provider-BLU6gzBE.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{stableWireKey as H}from"@lunora/wire";const w=(t,c,n)=>{const e=S(24);let m;e[0]!==n?(m=n===void 0?{}:n,e[0]=n,e[1]=m):m=e[1];const o=m,f=b();let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={chunks:[],error:void 0,status:"idle"},e[2]=a):a=e[2];const[s,i]=_(z,a),r=c==="skip";let u;e[3]!==c||e[4]!==r?(u=r?"skip":H(c),e[3]=c,e[4]=r,e[5]=u):u=e[5];const k=u,x=v(void 0);let l;e[6]!==c||e[7]!==f||e[8]!==o.maxBuffer||e[9]!==t||e[10]!==r?(l=()=>{if(r)return i({type:"reset"}),K;i({type:"reset"}),i({type:"start"});const{cancel:B,cleanup:y}=E(f.httpStream(t,c,{maxBuffer:o.maxBuffer}),i);return x.current=B,()=>{y(),x.current=void 0}},e[6]=c,e[7]=f,e[8]=o.maxBuffer,e[9]=t,e[10]=r,e[11]=l):l=e[11];let p;e[12]!==f||e[13]!==o.maxBuffer||e[14]!==t.method||e[15]!==t.path||e[16]!==k||e[17]!==r?(p=[f,t.method,t.path,k,r,o.maxBuffer],e[12]=f,e[13]=o.maxBuffer,e[14]=t.method,e[15]=t.path,e[16]=k,e[17]=r,e[18]=p):p=e[18],R(l,p);let h;e[19]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{x.current?.()},e[19]=h):h=e[19];let d;return e[20]!==s.chunks||e[21]!==s.error||e[22]!==s.status?(d={cancel:h,chunks:s.chunks,error:s.error,status:s.status},e[20]=s.chunks,e[21]=s.error,e[22]=s.status,e[23]=d):d=e[23],d};function K(){}export{w as useHttpStream};
2
+ import{c as S}from"react/compiler-runtime";import{useReducer as _,useRef as v,useEffect as R}from"react";import{u as b}from"./lunora-provider-BMJTPKMP.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{stableWireKey as H}from"@lunora/wire";const w=(t,c,n)=>{const e=S(24);let m;e[0]!==n?(m=n===void 0?{}:n,e[0]=n,e[1]=m):m=e[1];const o=m,f=b();let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={chunks:[],error:void 0,status:"idle"},e[2]=a):a=e[2];const[s,i]=_(z,a),r=c==="skip";let u;e[3]!==c||e[4]!==r?(u=r?"skip":H(c),e[3]=c,e[4]=r,e[5]=u):u=e[5];const k=u,x=v(void 0);let l;e[6]!==c||e[7]!==f||e[8]!==o.maxBuffer||e[9]!==t||e[10]!==r?(l=()=>{if(r)return i({type:"reset"}),K;i({type:"reset"}),i({type:"start"});const{cancel:B,cleanup:y}=E(f.httpStream(t,c,{maxBuffer:o.maxBuffer}),i);return x.current=B,()=>{y(),x.current=void 0}},e[6]=c,e[7]=f,e[8]=o.maxBuffer,e[9]=t,e[10]=r,e[11]=l):l=e[11];let p;e[12]!==f||e[13]!==o.maxBuffer||e[14]!==t.method||e[15]!==t.path||e[16]!==k||e[17]!==r?(p=[f,t.method,t.path,k,r,o.maxBuffer],e[12]=f,e[13]=o.maxBuffer,e[14]=t.method,e[15]=t.path,e[16]=k,e[17]=r,e[18]=p):p=e[18],R(l,p);let h;e[19]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{x.current?.()},e[19]=h):h=e[19];let d;return e[20]!==s.chunks||e[21]!==s.error||e[22]!==s.status?(d={cancel:h,chunks:s.chunks,error:s.error,status:s.status},e[20]=s.chunks,e[21]=s.error,e[22]=s.status,e[23]=d):d=e[23],d};function K(){}export{w as useHttpStream};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as M}from"react/compiler-runtime";import{useRef as R,useEffect as y}from"react";import{u as C}from"./use-paginated-core-DBWKHrw9.mjs";const v=(x,c,N)=>{const e=M(16),{initialNumItems:s}=N,{error:u,loadMore:o,pageResults:m,status:a}=C(x,c==="skip"?"skip":c,N),P=c==="skip";let t;if(e[0]!==m){t=[];for(const f of m)f&&t.push(f.page);e[0]=m,e[1]=t}else t=e[1];let i;e[2]!==s||e[3]!==o?(i={defaultNumItems:s,loadMore:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const h=R(i);let n;e[5]!==s||e[6]!==o?(n=()=>{h.current={defaultNumItems:s,loadMore:o}},e[5]=s,e[6]=o,e[7]=n):n=e[7],y(n);let r;e[8]===Symbol.for("react.memo_cache_sentinel")?(r=f=>{const{defaultNumItems:k,loadMore:L}=h.current;L(f??k)},e[8]=r):r=e[8];const I=r,d=a==="CanLoadMore",p=!P&&a==="LoadingMore",g=!P&&a==="LoadingFirstPage";let l;return e[9]!==u||e[10]!==t||e[11]!==a||e[12]!==d||e[13]!==p||e[14]!==g?(l={error:u,fetchNextPage:I,hasNextPage:d,isFetchingNextPage:p,isLoading:g,pages:t,status:a},e[9]=u,e[10]=t,e[11]=a,e[12]=d,e[13]=p,e[14]=g,e[15]=l):l=e[15],l};export{v as default};
2
+ import{c as M}from"react/compiler-runtime";import{useRef as R,useEffect as y}from"react";import{u as C}from"./use-paginated-core-BjpWBr46.mjs";const v=(x,c,N)=>{const e=M(16),{initialNumItems:s}=N,{error:u,loadMore:o,pageResults:m,status:a}=C(x,c==="skip"?"skip":c,N),P=c==="skip";let t;if(e[0]!==m){t=[];for(const f of m)f&&t.push(f.page);e[0]=m,e[1]=t}else t=e[1];let i;e[2]!==s||e[3]!==o?(i={defaultNumItems:s,loadMore:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const h=R(i);let n;e[5]!==s||e[6]!==o?(n=()=>{h.current={defaultNumItems:s,loadMore:o}},e[5]=s,e[6]=o,e[7]=n):n=e[7],y(n);let r;e[8]===Symbol.for("react.memo_cache_sentinel")?(r=f=>{const{defaultNumItems:k,loadMore:L}=h.current;L(f??k)},e[8]=r):r=e[8];const I=r,d=a==="CanLoadMore",p=!P&&a==="LoadingMore",g=!P&&a==="LoadingFirstPage";let l;return e[9]!==u||e[10]!==t||e[11]!==a||e[12]!==d||e[13]!==p||e[14]!==g?(l={error:u,fetchNextPage:I,hasNextPage:d,isFetchingNextPage:p,isLoading:g,pages:t,status:a},e[9]=u,e[10]=t,e[11]=a,e[12]=d,e[13]=p,e[14]=g,e[15]=l):l=e[15],l};export{v as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as D}from"react/compiler-runtime";import{liveTopicSubscription as R,subscribeLiveTopic as C}from"@lunora/client";import{stableWireKey as M}from"@lunora/wire";import{useState as W,useRef as $,useEffect as y}from"react";import{u as g}from"./lunora-provider-BLU6gzBE.mjs";function F(b,f){const t=D(8),d=f===void 0?{}:f,o=R(g(),b,d),{headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}=o,e=M({headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}),[p,l]=W(),m=p?.key===e?p:void 0,s=$(o);let n;t[0]!==o?(n=()=>{s.current=o},t[0]=o,t[1]=n):n=t[1],y(n);let i,c;t[2]!==e?(i=()=>{const x=C({...s.current,onError:r=>{l(E=>({error:r,key:e,lastEvent:E?.key===e?E.lastEvent:void 0})),s.current.onError?.(r)},onEvent:r=>{l({error:void 0,key:e,lastEvent:r}),s.current.onEvent?.(r)}});return()=>{x(),l(void 0)}},c=[e],t[2]=e,t[3]=i,t[4]=c):(i=t[3],c=t[4]),y(i,c);const a=m?.error,v=m?.lastEvent;let u;return t[5]!==a||t[6]!==v?(u={error:a,lastEvent:v},t[5]=a,t[6]=v,t[7]=u):u=t[7],u}export{F as useLiveTopic};
2
+ import{c as D}from"react/compiler-runtime";import{liveTopicSubscription as R,subscribeLiveTopic as C}from"@lunora/client";import{stableWireKey as M}from"@lunora/wire";import{useState as W,useRef as $,useEffect as y}from"react";import{u as g}from"./lunora-provider-BMJTPKMP.mjs";function F(b,f){const t=D(8),d=f===void 0?{}:f,o=R(g(),b,d),{headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}=o,e=M({headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}),[p,l]=W(),m=p?.key===e?p:void 0,s=$(o);let n;t[0]!==o?(n=()=>{s.current=o},t[0]=o,t[1]=n):n=t[1],y(n);let i,c;t[2]!==e?(i=()=>{const x=C({...s.current,onError:r=>{l(E=>({error:r,key:e,lastEvent:E?.key===e?E.lastEvent:void 0})),s.current.onError?.(r)},onEvent:r=>{l({error:void 0,key:e,lastEvent:r}),s.current.onEvent?.(r)}});return()=>{x(),l(void 0)}},c=[e],t[2]=e,t[3]=i,t[4]=c):(i=t[3],c=t[4]),y(i,c);const a=m?.error,v=m?.lastEvent;let u;return t[5]!==a||t[6]!==v?(u={error:a,lastEvent:v},t[5]=a,t[6]=v,t[7]=u):u=t[7],u}export{F as useLiveTopic};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{useMutation as k,onlineManager as g}from"@tanstack/react-query";import{useRef as v,useState as A,useCallback as O}from"react";import{u as L,a as P}from"./lunora-provider-BMJTPKMP.mjs";const Q=async()=>new Promise(n=>{if(g.isOnline()){n();return}const r=g.subscribe(s=>{s&&(r(),n())})}),q=n=>{const r=L(),s=P(),u=n.sensitive===!0,c=v(0),[l,p]=A(!1),b=k({mutationFn:async({args:e,options:t})=>(!(u||t?.onlineOnly===!0)&&!r.canQueueOffline(t?.shardKey)&&await Q(),r.mutation(n,e,t)),networkMode:"always",...u?{gcTime:0}:{},retry:0,onMutate:()=>{c.current+=1,p(!0)},onSettled:(e,t,o)=>{if(c.current-=1,p(c.current>0),u||o.options?.onlineOnly===!0){const a=s.getMutationCache();for(const h of a.findAll({predicate:C=>C.state.variables===o}))a.remove(h)}}},s),{data:m,error:d,isError:f,mutateAsync:i,reset:y}=b,w=O((e,t)=>i({args:e,options:t}),[i]),M=O(e=>({data:m,error:d,isError:f,mutate:(o,a)=>i({args:o,options:{optimisticUpdate:e,...a}}),pending:l,reset:y,withOptimisticUpdate:M}),[i,m,d,f,l,y]);return{data:m,error:d,isError:f,mutate:w,pending:l,reset:y,withOptimisticUpdate:M}};export{q as useMutation};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c}from"react/compiler-runtime";import{u as f}from"./use-paginated-core-DBWKHrw9.mjs";const L=(d,i,l)=>{const e=c(8),{error:r,loadMore:p,pageResults:n,status:t}=f(d,i==="skip"?"skip":i,l);let s;if(e[0]!==n){s=[];for(const u of n)u&&s.push(...u.page);e[0]=n,e[1]=s}else s=e[1];const a=!(i==="skip")&&(t==="LoadingFirstPage"||t==="LoadingMore");let o;return e[2]!==r||e[3]!==p||e[4]!==s||e[5]!==t||e[6]!==a?(o={error:r,isLoading:a,loadMore:p,results:s,status:t},e[2]=r,e[3]=p,e[4]=s,e[5]=t,e[6]=a,e[7]=o):o=e[7],o};export{L as usePaginatedQuery};
2
+ import{c}from"react/compiler-runtime";import{u as f}from"./use-paginated-core-BjpWBr46.mjs";const L=(d,i,l)=>{const e=c(8),{error:r,loadMore:p,pageResults:n,status:t}=f(d,i==="skip"?"skip":i,l);let s;if(e[0]!==n){s=[];for(const u of n)u&&s.push(...u.page);e[0]=n,e[1]=s}else s=e[1];const a=!(i==="skip")&&(t==="LoadingFirstPage"||t==="LoadingMore");let o;return e[2]!==r||e[3]!==p||e[4]!==s||e[5]!==t||e[6]!==a?(o={error:r,isLoading:a,loadMore:p,results:s,status:t},e[2]=r,e[3]=p,e[4]=s,e[5]=t,e[6]=a,e[7]=o):o=e[7],o};export{L as usePaginatedQuery};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useMemo as _,useState as w,useRef as l,useEffect as u,useCallback as E}from"react";import{u as D}from"./lunora-provider-BLU6gzBE.mjs";const V=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(e)}`)},A=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},C=1e4,P=(e,r)=>{const t=D(),{heartbeat:g,intervalMs:y=C,listPresent:m,shardKey:s}=r;V(y);const o=_(()=>r.sessionId??A(),[r.sessionId]),d=JSON.stringify([m.__lunoraRef,e,s??""]),[b,p]=w(),h=b?.client===t&&b.key===d?b:void 0,R=l(r.onError);u(()=>{R.current=r.onError});const v=l(r.data),I=l(!1),S=l({client:t,heartbeat:g,roomId:e,sessionId:o,shardKey:s});u(()=>{S.current={client:t,heartbeat:g,roomId:e,sessionId:o,shardKey:s}});const i=E(()=>{const{client:n,heartbeat:c,roomId:a,sessionId:f,shardKey:k}=S.current,L={roomId:a,sessionId:f,...v.current===void 0?{}:{data:v.current}};n.mutation(c,L,{shardKey:k}).catch(()=>{})},[]),U=E(n=>{v.current=n,I.current&&i()},[i]);return u(()=>(I.current=!0,()=>{I.current=!1}),[]),u(()=>{i();const n=setInterval(i,y),c=()=>{typeof document<"u"&&document.visibilityState==="visible"&&i()};return typeof document<"u"&&document.addEventListener("visibilitychange",c),()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",c)}},[i,y,t,e,o,s]),u(()=>t.acquireConnectionContext({roomId:e,sessionId:o},{shardKey:s}),[t,e,o,s]),u(()=>{let n=!1;const c=t.subscribe(m,{roomId:e},a=>{n||p({client:t,error:void 0,key:d,present:a})},{onError:a=>{n||p(f=>({client:t,error:a,key:d,present:f?.client===t&&f.key===d?f.present:void 0})),R.current?.(a)},shardKey:s});return()=>{n=!0,c(),p(void 0)}},[t,m.__lunoraRef,e,d,s]),{error:h?.error,present:h?.present,sessionId:o,setData:U}};export{P as usePresence};
2
+ import{useMemo as _,useState as w,useRef as l,useEffect as u,useCallback as E}from"react";import{u as D}from"./lunora-provider-BMJTPKMP.mjs";const V=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(e)}`)},A=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},C=1e4,P=(e,r)=>{const t=D(),{heartbeat:g,intervalMs:y=C,listPresent:m,shardKey:s}=r;V(y);const o=_(()=>r.sessionId??A(),[r.sessionId]),d=JSON.stringify([m.__lunoraRef,e,s??""]),[b,p]=w(),h=b?.client===t&&b.key===d?b:void 0,R=l(r.onError);u(()=>{R.current=r.onError});const v=l(r.data),I=l(!1),S=l({client:t,heartbeat:g,roomId:e,sessionId:o,shardKey:s});u(()=>{S.current={client:t,heartbeat:g,roomId:e,sessionId:o,shardKey:s}});const i=E(()=>{const{client:n,heartbeat:c,roomId:a,sessionId:f,shardKey:k}=S.current,L={roomId:a,sessionId:f,...v.current===void 0?{}:{data:v.current}};n.mutation(c,L,{shardKey:k}).catch(()=>{})},[]),U=E(n=>{v.current=n,I.current&&i()},[i]);return u(()=>(I.current=!0,()=>{I.current=!1}),[]),u(()=>{i();const n=setInterval(i,y),c=()=>{typeof document<"u"&&document.visibilityState==="visible"&&i()};return typeof document<"u"&&document.addEventListener("visibilitychange",c),()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",c)}},[i,y,t,e,o,s]),u(()=>t.acquireConnectionContext({roomId:e,sessionId:o},{shardKey:s}),[t,e,o,s]),u(()=>{let n=!1;const c=t.subscribe(m,{roomId:e},a=>{n||p({client:t,error:void 0,key:d,present:a})},{onError:a=>{n||p(f=>({client:t,error:a,key:d,present:f?.client===t&&f.key===d?f.present:void 0})),R.current?.(a)},shardKey:s});return()=>{n=!0,c(),p(void 0)}},[t,m.__lunoraRef,e,d,s]),{error:h?.error,present:h?.present,sessionId:o,setData:U}};export{P as usePresence};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as k}from"react/compiler-runtime";import{useQuery as q}from"@tanstack/react-query";import{useState as E,useEffect as F}from"react";import{u as N,a as T,g as V}from"./lunora-provider-BMJTPKMP.mjs";import{u as A}from"./query-core-C9_ReCKt.mjs";import{stableWireKey as C}from"@lunora/wire";import{lunoraQueryKeyFromArgsKey as D}from"@lunora/client/query";const P=(s,K,R)=>{const e=k(26),v=R===void 0?{}:R,r=N(),u=T(),{onError:Q,shardKey:t}=v,y=K==="skip",o=y?{}:K,l=C(o),a=D(s.__lunoraRef,l,t),[n,b]=E(r.isReady);let d,c;e[0]!==r||e[1]!==n?(d=()=>{n||r.whenReady().then(()=>{b(!0)})},c=[r,n],e[0]=r,e[1]=n,e[2]=d,e[3]=c):(d=e[2],c=e[3]),F(d,c);let m;if(!y){const h=r.peekHydratedQueryByKey(s.__lunoraRef,l,t);m=h===void 0?r.peekActiveQuerySnapshot(s.__lunoraRef,o,t).value:h}const g=!y&&n;let i;e[4]!==o||e[5]!==r||e[6]!==s||e[7]!==u||e[8]!==a||e[9]!==t?(i=async h=>{const{signal:S}=h;return V(r).liveValue(u,a,S,{fetch:async()=>r.query(s,o,{shardKey:t}),shardKey:t})},e[4]=o,e[5]=r,e[6]=s,e[7]=u,e[8]=a,e[9]=t,e[10]=i):i=e[10];let p;e[11]!==m||e[12]!==a||e[13]!==g||e[14]!==i?(p={enabled:g,initialData:m,queryFn:i,queryKey:a,staleTime:Number.POSITIVE_INFINITY},e[11]=m,e[12]=a,e[13]=g,e[14]=i,e[15]=p):p=e[15];const{data:I}=q(p,u);let f;return e[16]!==l||e[17]!==o||e[18]!==r||e[19]!==s||e[20]!==Q||e[21]!==u||e[22]!==a||e[23]!==t||e[24]!==y?(f={args:o,argsKey:l,client:r,function_:s,onError:Q,queryClient:u,queryKey:a,shardKey:t,skipped:y},e[16]=l,e[17]=o,e[18]=r,e[19]=s,e[20]=Q,e[21]=u,e[22]=a,e[23]=t,e[24]=y,e[25]=f):f=e[25],A(f),y?void 0:I};export{P as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as K}from"react/compiler-runtime";import{useReducer as B,useRef as R,useEffect as _}from"react";import{u as v}from"./lunora-provider-BLU6gzBE.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{stableWireKey as E}from"@lunora/wire";const A=(u,a,l)=>{const e=K(27);let c;e[0]!==l?(c=l===void 0?{}:l,e[0]=l,e[1]=c):c=e[1];const r=c,o=v();let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={chunks:[],error:void 0,status:"idle"},e[2]=f):f=e[2];const[t,m]=B(S,f),s=a==="skip";let n;e[3]!==a||e[4]!==s?(n=s?"skip":E(a),e[3]=a,e[4]=s,e[5]=n):n=e[5];const y=n,b=R(void 0);let i;e[6]!==a||e[7]!==o||e[8]!==u||e[9]!==r.durable||e[10]!==r.maxBuffer||e[11]!==r.shardKey||e[12]!==s?(i=()=>{if(s)return m({type:"reset"}),L;m({type:"reset"}),m({type:"start"});const{cancel:k,cleanup:x}=z(o.stream(u,a,{durable:r.durable,maxBuffer:r.maxBuffer,shardKey:r.shardKey}),m);return b.current=k,()=>{x(),b.current=void 0}},e[6]=a,e[7]=o,e[8]=u,e[9]=r.durable,e[10]=r.maxBuffer,e[11]=r.shardKey,e[12]=s,e[13]=i):i=e[13];let d;e[14]!==o||e[15]!==u.__lunoraRef||e[16]!==r.durable||e[17]!==r.maxBuffer||e[18]!==r.shardKey||e[19]!==y||e[20]!==s?(d=[o,u.__lunoraRef,y,s,r.shardKey,r.maxBuffer,r.durable],e[14]=o,e[15]=u.__lunoraRef,e[16]=r.durable,e[17]=r.maxBuffer,e[18]=r.shardKey,e[19]=y,e[20]=s,e[21]=d):d=e[21],_(i,d);let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{b.current?.()},e[22]=p):p=e[22];let h;return e[23]!==t.chunks||e[24]!==t.error||e[25]!==t.status?(h={cancel:p,chunks:t.chunks,error:t.error,status:t.status},e[23]=t.chunks,e[24]=t.error,e[25]=t.status,e[26]=h):h=e[26],h};function L(){}export{A as useStream};
2
+ import{c as K}from"react/compiler-runtime";import{useReducer as B,useRef as R,useEffect as _}from"react";import{u as v}from"./lunora-provider-BMJTPKMP.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{stableWireKey as E}from"@lunora/wire";const A=(u,a,l)=>{const e=K(27);let c;e[0]!==l?(c=l===void 0?{}:l,e[0]=l,e[1]=c):c=e[1];const r=c,o=v();let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={chunks:[],error:void 0,status:"idle"},e[2]=f):f=e[2];const[t,m]=B(S,f),s=a==="skip";let n;e[3]!==a||e[4]!==s?(n=s?"skip":E(a),e[3]=a,e[4]=s,e[5]=n):n=e[5];const y=n,b=R(void 0);let i;e[6]!==a||e[7]!==o||e[8]!==u||e[9]!==r.durable||e[10]!==r.maxBuffer||e[11]!==r.shardKey||e[12]!==s?(i=()=>{if(s)return m({type:"reset"}),L;m({type:"reset"}),m({type:"start"});const{cancel:k,cleanup:x}=z(o.stream(u,a,{durable:r.durable,maxBuffer:r.maxBuffer,shardKey:r.shardKey}),m);return b.current=k,()=>{x(),b.current=void 0}},e[6]=a,e[7]=o,e[8]=u,e[9]=r.durable,e[10]=r.maxBuffer,e[11]=r.shardKey,e[12]=s,e[13]=i):i=e[13];let d;e[14]!==o||e[15]!==u.__lunoraRef||e[16]!==r.durable||e[17]!==r.maxBuffer||e[18]!==r.shardKey||e[19]!==y||e[20]!==s?(d=[o,u.__lunoraRef,y,s,r.shardKey,r.maxBuffer,r.durable],e[14]=o,e[15]=u.__lunoraRef,e[16]=r.durable,e[17]=r.maxBuffer,e[18]=r.shardKey,e[19]=y,e[20]=s,e[21]=d):d=e[21],_(i,d);let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{b.current?.()},e[22]=p):p=e[22];let h;return e[23]!==t.chunks||e[24]!==t.error||e[25]!==t.status?(h={cancel:p,chunks:t.chunks,error:t.error,status:t.status},e[23]=t.chunks,e[24]=t.error,e[25]=t.status,e[26]=h):h=e[26],h};function L(){}export{A as useStream};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as O}from"react/compiler-runtime";import{createQuerySubscription as j}from"@lunora/client/query";import{LunoraError as L}from"@lunora/errors";import{useState as M,useRef as R,useEffect as E}from"react";import{u as q}from"./lunora-provider-BLU6gzBE.mjs";import{stableWireKey as x}from"@lunora/wire";const A=Object.freeze({data:void 0,error:void 0}),W=(t,n,b)=>{const e=O(20),r=b===void 0?{}:b,o=q(),a=n==="skip",c=a?"skip":x(n),i=JSON.stringify([t.__lunoraRef,c,r.shardKey??""]),[y,p]=M(void 0),v=R(r.onError);let u;e[0]!==r.onError?(u=()=>{v.current=r.onError},e[0]=r.onError,e[1]=u):u=e[1],E(u);let d;e[2]!==n||e[3]!==t?(d={args:n,fn:t},e[2]=n,e[3]=t,e[4]=d):d=e[4];const K=R(d);let l;e[5]!==n||e[6]!==t?(l=()=>{K.current={args:n,fn:t}},e[5]=n,e[6]=t,e[7]=l):l=e[7],E(l);let f;e[8]!==o||e[9]!==i||e[10]!==r.shardKey||e[11]!==a?(f=()=>{if(a)return D;let h=!1;const{args:k,fn:w}=K.current,S=j(o,w,k,{onData:s=>{h||p({client:o,key:i,result:{data:s,error:void 0}})},onError:s=>{const z=Object.assign(s.code===void 0?new Error(s.message):new L(s.code,s.message),s.why===void 0?{}:{why:s.why});v.current?.(s),queueMicrotask(()=>{h||p({client:o,key:i,result:{data:void 0,error:z}})})}},{shardKey:r.shardKey});return()=>{h=!0,S(),p(void 0)}},e[8]=o,e[9]=i,e[10]=r.shardKey,e[11]=a,e[12]=f):f=e[12];let m;return e[13]!==o||e[14]!==t.__lunoraRef||e[15]!==i||e[16]!==r.shardKey||e[17]!==c||e[18]!==a?(m=[o,t.__lunoraRef,i,c,r.shardKey,a],e[13]=o,e[14]=t.__lunoraRef,e[15]=i,e[16]=r.shardKey,e[17]=c,e[18]=a,e[19]=m):m=e[19],E(f,m),y?.client===o&&y.key===i?y.result:A};function D(){}export{W as default};
2
+ import{c as O}from"react/compiler-runtime";import{createQuerySubscription as j}from"@lunora/client/query";import{LunoraError as L}from"@lunora/errors";import{useState as M,useRef as R,useEffect as E}from"react";import{u as q}from"./lunora-provider-BMJTPKMP.mjs";import{stableWireKey as x}from"@lunora/wire";const A=Object.freeze({data:void 0,error:void 0}),W=(t,n,b)=>{const e=O(20),r=b===void 0?{}:b,o=q(),a=n==="skip",c=a?"skip":x(n),i=JSON.stringify([t.__lunoraRef,c,r.shardKey??""]),[y,p]=M(void 0),v=R(r.onError);let u;e[0]!==r.onError?(u=()=>{v.current=r.onError},e[0]=r.onError,e[1]=u):u=e[1],E(u);let d;e[2]!==n||e[3]!==t?(d={args:n,fn:t},e[2]=n,e[3]=t,e[4]=d):d=e[4];const K=R(d);let l;e[5]!==n||e[6]!==t?(l=()=>{K.current={args:n,fn:t}},e[5]=n,e[6]=t,e[7]=l):l=e[7],E(l);let f;e[8]!==o||e[9]!==i||e[10]!==r.shardKey||e[11]!==a?(f=()=>{if(a)return D;let h=!1;const{args:k,fn:w}=K.current,S=j(o,w,k,{onData:s=>{h||p({client:o,key:i,result:{data:s,error:void 0}})},onError:s=>{const z=Object.assign(s.code===void 0?new Error(s.message):new L(s.code,s.message),s.why===void 0?{}:{why:s.why});v.current?.(s),queueMicrotask(()=>{h||p({client:o,key:i,result:{data:void 0,error:z}})})}},{shardKey:r.shardKey});return()=>{h=!0,S(),p(void 0)}},e[8]=o,e[9]=i,e[10]=r.shardKey,e[11]=a,e[12]=f):f=e[12];let m;return e[13]!==o||e[14]!==t.__lunoraRef||e[15]!==i||e[16]!==r.shardKey||e[17]!==c||e[18]!==a?(m=[o,t.__lunoraRef,i,c,r.shardKey,a],e[13]=o,e[14]=t.__lunoraRef,e[15]=i,e[16]=r.shardKey,e[17]=c,e[18]=a,e[19]=m):m=e[19],E(f,m),y?.client===o&&y.key===i?y.result:A};function D(){}export{W as default};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as h}from"react/compiler-runtime";import{useSuspenseQuery as R}from"@tanstack/react-query";import{u as S,a as I,g as b}from"./lunora-provider-BMJTPKMP.mjs";import{u as q}from"./query-core-C9_ReCKt.mjs";import{stableWireKey as F}from"@lunora/wire";import{lunoraQueryKeyFromArgsKey as k}from"@lunora/client/query";const E=(s,m,c)=>{const e=h(21),f=c===void 0?{}:c,r=S(),y=I(),{onError:d,shardKey:a}=f,u=m,o=F(u),t=k(s.__lunoraRef,o,a),p=r.isReady?r.peekHydratedQueryByKey(s.__lunoraRef,o,a):void 0;let i;e[0]!==o||e[1]!==u||e[2]!==r||e[3]!==s||e[4]!==y||e[5]!==t||e[6]!==a?(i=async K=>{const{signal:Q}=K;return await r.whenReady(),r.peekHydratedQueryByKey(s.__lunoraRef,o,a)??b(r).liveValue(y,t,Q,{fetch:async()=>r.query(s,u,{shardKey:a}),waitForPush:!1})},e[0]=o,e[1]=u,e[2]=r,e[3]=s,e[4]=y,e[5]=t,e[6]=a,e[7]=i):i=e[7];let l;e[8]!==p||e[9]!==t||e[10]!==i?(l={initialData:p,queryFn:i,queryKey:t,staleTime:Number.POSITIVE_INFINITY},e[8]=p,e[9]=t,e[10]=i,e[11]=l):l=e[11];const{data:g}=R(l,y);let n;return e[12]!==o||e[13]!==u||e[14]!==r||e[15]!==s||e[16]!==d||e[17]!==y||e[18]!==t||e[19]!==a?(n={args:u,argsKey:o,client:r,function_:s,onError:d,queryClient:y,queryKey:t,shardKey:a,skipped:!1},e[12]=o,e[13]=u,e[14]=r,e[15]=s,e[16]=d,e[17]=y,e[18]=t,e[19]=a,e[20]=n):n=e[20],q(n),g};export{E as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useState as T,useRef as W,useCallback as y,useEffect as G}from"react";import{u as X}from"./lunora-provider-BLU6gzBE.mjs";const N="/_lunora/ws",j="/_lunora/voice/",z=4001,O=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,Q=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},Y=(e,r)=>{if(r===void 0||r==="")return O(e);if(r.endsWith(N))return r.slice(0,-N.length);try{return new URL(r).origin}catch{return O(e)}},Z=e=>{const r=Y(e.httpUrl,e.wsUrl),s=r.endsWith("/")?r.slice(0,-1):r,c=new URLSearchParams({threadKey:e.threadKey});return`${s}${j}${encodeURIComponent(e.agent)}?${c.toString()}`},ee=(e,r)=>{if(r?.code===z)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},te=(e,r,s)=>{const c=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==c&&s(new Error(`${r}: the signed-in identity changed during the call — the session was ended; start a new call`))})},ne=16e3,re=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},se=(e,r)=>{const s=r/ne,c=s>1?Math.floor(e.length/s):e.length,d=new ArrayBuffer(c*2),l=new DataView(d);for(let u=0;u<c;u+=1){const g=e[Math.floor(u*s)]??0,p=Math.max(-1,Math.min(1,g));l.setInt16(u*2,p<0?p*32768:p*32767,!0)}return new Uint8Array(d)},oe=async e=>{const r=globalThis,s=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),c=r.AudioContext??r.webkitAudioContext;if(!s||!c)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new c,u=l.createMediaStreamSource(d),g=l.createScriptProcessor(4096,1,1);let p=!1,w=!1,a=0,h=0;return g.onaudioprocess=o=>{const f=o.inputBuffer.getChannelData(0),m=p?0:re(f);if(e.onLevel(m),p)return;if(e.onAudio(se(f,l.sampleRate)),e.isTurnActive()){h=m>=e.interruptThreshold?h+1:0,h>=e.interruptChunks&&(h=0,e.onInterrupt());return}h=0;const x=f.length/l.sampleRate*1e3;if(m>=e.silenceThreshold){w=!0,a=0;return}w&&(a+=x,a>=e.silenceDurationMs&&(w=!1,a=0,e.onSilence()))},u.connect(g),g.connect(l.destination),{setMuted:o=>{p=o},stop:()=>{g.disconnect(),u.disconnect();for(const o of d.getTracks())o.stop();l.close()}}},ie=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,c=new Set;let d=0,l=Promise.resolve(),u=0;const g=async(a,h)=>{if(h!==u)return;let o;try{o=await s.decodeAudioData(a.buffer)}catch{return}if(h!==u)return;const f=s.createBufferSource();f.buffer=o,f.connect(s.destination);const m=Math.max(s.currentTime,d);f.start(m),d=m+o.duration,c.add(f),f.onended=()=>{c.delete(f)}},p=a=>{const h=Uint8Array.from(a),o=u;l=l.then(()=>g(h,o))},w=()=>{u+=1;for(const a of c)try{a.stop()}catch{}c.clear(),d=s.currentTime};return{enqueue:p,interrupt:w,stop:()=>{w(),s.close()}}},P=1,ce=.01,ae=1200,ue=.15,le=3,he=e=>{const{createMicrophone:r=oe,createSpeaker:s=ie,createSocket:c,interruptChunks:d=le,interruptThreshold:l=ue,silenceDurationMs:u=ae,silenceThreshold:g=ce,threadKey:p,voice:w}=e,a=X(),[h,o]=T("idle"),[f,m]=T(!1),[x,M]=T(""),[H,v]=T(""),[$,R]=T(0),[I,U]=T(!1),[B,E]=T(void 0),i=W(void 0),_=W(!1),C=y(n=>{const t=i.current?.socket;return t?.readyState===P?(t.send(JSON.stringify(n)),!0):!1},[]),A=y(()=>{const n=i.current;if(i.current=void 0,n){n.unwatchIdentity?.(),n.microphone?.stop(),n.speaker?.stop(),n.socket.onmessage=null,n.socket.onerror=null,n.socket.onclose=null;try{n.socket.close()}catch{}}_.current=!1,m(!1),o("idle"),R(0)},[]),L=y(n=>{const t=i.current;switch(n.type){case"assistant_delta":{t&&(t.speaking=!0),o("speaking"),v(F=>F+n.text);break}case"assistant_discarded":{t&&(t.suppressAudio=!0),t?.speaker?.interrupt(),v("");break}case"assistant_done":{t&&(t.awaitingTurn=!1,t.speaking=!1),v(n.text),o("listening");break}case"error":{t&&(t.awaitingTurn=!1,t.speaking=!1),E(new Error(n.message)),o("listening");break}case"interrupted":{t&&(t.awaitingTurn=!1,t.speaking=!1,t.suppressAudio=!1),t?.speaker?.interrupt(),o("listening");break}case"ready":{t&&(t.audioFormat=n.audioFormat,t.suppressAudio=!1),m(!0),o("listening");break}case"user_transcript":{t&&(t.suppressAudio=!1),M(n.text),v(""),o("thinking");break}}},[]),D=y(n=>{const t=i.current;!t||t.suppressAudio||(t.speaker??=s({audioFormat:t.audioFormat}),t.speaking=!0,o("speaking"),t.speaker.enqueue(n))},[s]),q=y(async()=>{if(i.current||_.current)return;_.current=!0,E(void 0),M(""),v("");let n;try{const t=Z({agent:Q(w.__lunoraRef),httpUrl:a.url,threadKey:p,wsUrl:a.wsUrl}),S=(c??(k=>{const b=a.getWebSocketImpl();if(!b)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new b(k)}))(t);S.binaryType="arraybuffer",n={audioFormat:"mp3",microphone:void 0,socket:S,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},i.current=n,n.unwatchIdentity=te(a,"useVoiceAgent",k=>{i.current===n&&(E(k),A())}),S.onmessage=k=>{if(typeof k.data=="string"){try{L(JSON.parse(k.data))}catch{}return}D(new Uint8Array(k.data))},S.onerror=()=>{E(new Error("useVoiceAgent: voice socket error"))},S.onclose=k=>{if(i.current!==n)return;const b=ee("useVoiceAgent",k);b&&E(b),A()};const V=await r({interruptChunks:d,interruptThreshold:l,isTurnActive:()=>(i.current?.speaking??!1)||(i.current?.awaitingTurn??!1),onAudio:k=>{S.readyState===P&&S.send(k)},onInterrupt:()=>{C({type:"interrupt"}),i.current?.speaker?.interrupt(),i.current&&(i.current.awaitingTurn=!1,i.current.speaking=!1,i.current.suppressAudio=!0),o("listening")},onLevel:R,onSilence:()=>{C({type:"commit"}),i.current&&(i.current.awaitingTurn=!0),o("thinking")},silenceDurationMs:u,silenceThreshold:g});i.current===n?(n.microphone=V,U(!1),n.speaking||o("listening")):V.stop()}catch(t){i.current===n&&(E(t instanceof Error?t:new Error(String(t))),A())}finally{_.current=!1}},[a,r,c,D,L,d,l,C,u,g,A,p,w]),K=y(()=>{const n=!I;return i.current?.microphone?.setMuted(n),U(n),n},[I]),J=y(n=>{C({text:n,type:"text"})&&(i.current&&(i.current.awaitingTurn=!0),o("thinking"))},[C]);return G(()=>A,[A]),{audioLevel:$,connected:f,endCall:A,error:B,interimTranscript:H,isMuted:I,sendText:J,startCall:q,status:h,toggleMute:K,transcript:x}};export{he as useVoiceAgent};
2
+ import{useState as T,useRef as W,useCallback as y,useEffect as G}from"react";import{u as X}from"./lunora-provider-BMJTPKMP.mjs";const N="/_lunora/ws",j="/_lunora/voice/",z=4001,O=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,Q=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},Y=(e,r)=>{if(r===void 0||r==="")return O(e);if(r.endsWith(N))return r.slice(0,-N.length);try{return new URL(r).origin}catch{return O(e)}},Z=e=>{const r=Y(e.httpUrl,e.wsUrl),s=r.endsWith("/")?r.slice(0,-1):r,c=new URLSearchParams({threadKey:e.threadKey});return`${s}${j}${encodeURIComponent(e.agent)}?${c.toString()}`},ee=(e,r)=>{if(r?.code===z)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},te=(e,r,s)=>{const c=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==c&&s(new Error(`${r}: the signed-in identity changed during the call — the session was ended; start a new call`))})},ne=16e3,re=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},se=(e,r)=>{const s=r/ne,c=s>1?Math.floor(e.length/s):e.length,d=new ArrayBuffer(c*2),l=new DataView(d);for(let u=0;u<c;u+=1){const g=e[Math.floor(u*s)]??0,p=Math.max(-1,Math.min(1,g));l.setInt16(u*2,p<0?p*32768:p*32767,!0)}return new Uint8Array(d)},oe=async e=>{const r=globalThis,s=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),c=r.AudioContext??r.webkitAudioContext;if(!s||!c)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new c,u=l.createMediaStreamSource(d),g=l.createScriptProcessor(4096,1,1);let p=!1,w=!1,a=0,h=0;return g.onaudioprocess=o=>{const f=o.inputBuffer.getChannelData(0),m=p?0:re(f);if(e.onLevel(m),p)return;if(e.onAudio(se(f,l.sampleRate)),e.isTurnActive()){h=m>=e.interruptThreshold?h+1:0,h>=e.interruptChunks&&(h=0,e.onInterrupt());return}h=0;const x=f.length/l.sampleRate*1e3;if(m>=e.silenceThreshold){w=!0,a=0;return}w&&(a+=x,a>=e.silenceDurationMs&&(w=!1,a=0,e.onSilence()))},u.connect(g),g.connect(l.destination),{setMuted:o=>{p=o},stop:()=>{g.disconnect(),u.disconnect();for(const o of d.getTracks())o.stop();l.close()}}},ie=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,c=new Set;let d=0,l=Promise.resolve(),u=0;const g=async(a,h)=>{if(h!==u)return;let o;try{o=await s.decodeAudioData(a.buffer)}catch{return}if(h!==u)return;const f=s.createBufferSource();f.buffer=o,f.connect(s.destination);const m=Math.max(s.currentTime,d);f.start(m),d=m+o.duration,c.add(f),f.onended=()=>{c.delete(f)}},p=a=>{const h=Uint8Array.from(a),o=u;l=l.then(()=>g(h,o))},w=()=>{u+=1;for(const a of c)try{a.stop()}catch{}c.clear(),d=s.currentTime};return{enqueue:p,interrupt:w,stop:()=>{w(),s.close()}}},P=1,ce=.01,ae=1200,ue=.15,le=3,he=e=>{const{createMicrophone:r=oe,createSpeaker:s=ie,createSocket:c,interruptChunks:d=le,interruptThreshold:l=ue,silenceDurationMs:u=ae,silenceThreshold:g=ce,threadKey:p,voice:w}=e,a=X(),[h,o]=T("idle"),[f,m]=T(!1),[x,M]=T(""),[H,v]=T(""),[$,R]=T(0),[I,U]=T(!1),[B,E]=T(void 0),i=W(void 0),_=W(!1),C=y(n=>{const t=i.current?.socket;return t?.readyState===P?(t.send(JSON.stringify(n)),!0):!1},[]),A=y(()=>{const n=i.current;if(i.current=void 0,n){n.unwatchIdentity?.(),n.microphone?.stop(),n.speaker?.stop(),n.socket.onmessage=null,n.socket.onerror=null,n.socket.onclose=null;try{n.socket.close()}catch{}}_.current=!1,m(!1),o("idle"),R(0)},[]),L=y(n=>{const t=i.current;switch(n.type){case"assistant_delta":{t&&(t.speaking=!0),o("speaking"),v(F=>F+n.text);break}case"assistant_discarded":{t&&(t.suppressAudio=!0),t?.speaker?.interrupt(),v("");break}case"assistant_done":{t&&(t.awaitingTurn=!1,t.speaking=!1),v(n.text),o("listening");break}case"error":{t&&(t.awaitingTurn=!1,t.speaking=!1),E(new Error(n.message)),o("listening");break}case"interrupted":{t&&(t.awaitingTurn=!1,t.speaking=!1,t.suppressAudio=!1),t?.speaker?.interrupt(),o("listening");break}case"ready":{t&&(t.audioFormat=n.audioFormat,t.suppressAudio=!1),m(!0),o("listening");break}case"user_transcript":{t&&(t.suppressAudio=!1),M(n.text),v(""),o("thinking");break}}},[]),D=y(n=>{const t=i.current;!t||t.suppressAudio||(t.speaker??=s({audioFormat:t.audioFormat}),t.speaking=!0,o("speaking"),t.speaker.enqueue(n))},[s]),q=y(async()=>{if(i.current||_.current)return;_.current=!0,E(void 0),M(""),v("");let n;try{const t=Z({agent:Q(w.__lunoraRef),httpUrl:a.url,threadKey:p,wsUrl:a.wsUrl}),S=(c??(k=>{const b=a.getWebSocketImpl();if(!b)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new b(k)}))(t);S.binaryType="arraybuffer",n={audioFormat:"mp3",microphone:void 0,socket:S,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},i.current=n,n.unwatchIdentity=te(a,"useVoiceAgent",k=>{i.current===n&&(E(k),A())}),S.onmessage=k=>{if(typeof k.data=="string"){try{L(JSON.parse(k.data))}catch{}return}D(new Uint8Array(k.data))},S.onerror=()=>{E(new Error("useVoiceAgent: voice socket error"))},S.onclose=k=>{if(i.current!==n)return;const b=ee("useVoiceAgent",k);b&&E(b),A()};const V=await r({interruptChunks:d,interruptThreshold:l,isTurnActive:()=>(i.current?.speaking??!1)||(i.current?.awaitingTurn??!1),onAudio:k=>{S.readyState===P&&S.send(k)},onInterrupt:()=>{C({type:"interrupt"}),i.current?.speaker?.interrupt(),i.current&&(i.current.awaitingTurn=!1,i.current.speaking=!1,i.current.suppressAudio=!0),o("listening")},onLevel:R,onSilence:()=>{C({type:"commit"}),i.current&&(i.current.awaitingTurn=!0),o("thinking")},silenceDurationMs:u,silenceThreshold:g});i.current===n?(n.microphone=V,U(!1),n.speaking||o("listening")):V.stop()}catch(t){i.current===n&&(E(t instanceof Error?t:new Error(String(t))),A())}finally{_.current=!1}},[a,r,c,D,L,d,l,C,u,g,A,p,w]),K=y(()=>{const n=!I;return i.current?.microphone?.setMuted(n),U(n),n},[I]),J=y(n=>{C({text:n,type:"text"})&&(i.current&&(i.current.awaitingTurn=!0),o("thinking"))},[C]);return G(()=>A,[A]),{audioLevel:$,connected:f,endCall:A,error:B,interimTranscript:H,isMuted:I,sendText:J,startCall:q,status:h,toggleMute:K,transcript:x}};export{he as useVoiceAgent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/react",
3
- "version": "1.0.0-alpha.298",
3
+ "version": "1.0.0-alpha.299",
4
4
  "description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -1 +0,0 @@
1
- import{L as e,u as o,a as u}from"./lunora-provider-BLU6gzBE.mjs";export{e as LunoraProvider,o as useLunora,u as useLunoraClientSwapped};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as K}from"react/compiler-runtime";import{useQueryClient as P,useQuery as N}from"@tanstack/react-query";import{useRef as T,useEffect as I,useSyncExternalStore as w,useState as x}from"react";import{u as F,g as L,a as O,s as V}from"./lunora-provider-BLU6gzBE.mjs";import{lunoraQueryKey as z}from"@lunora/client/query";const D=function(o,r){const e=K(11);let s;e[0]!==r?(s=r===void 0?{}:r,e[0]=r,e[1]=s):s=e[1];const i=s,t=F(),n=P(),S=T(i.onError);let c;e[2]!==i.onError?(c=()=>{S.current=i.onError},e[2]=i.onError,e[3]=c):c=e[3],I(c);let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=h=>{S.current?.(h)},e[4]=u):u=e[4];const b=u,m=L(t);let a;e[5]!==t?(a=()=>t.identityEpoch(),e[5]=t,e[6]=a):a=e[6];const _=w(m.subscribeIdentityEpoch,a,Y),[Q]=x(t),R=O(),{args:p,functionPath:q,shardKey:l}=o,g=_===0&&!R&&t===Q?o.value:void 0,d={__lunoraRef:q},f=z(d,p,l),{data:v}=N({initialData:g,queryFn:async h=>{const{signal:C}=h;return m.liveValue(n,f,C,{fetch:async()=>t.query(d,p,{shardKey:l}),shardKey:l})},queryKey:f,staleTime:Number.POSITIVE_INFINITY}),E=V(f);let y;return e[7]!==t||e[8]!==n||e[9]!==E?(y=[t,n,E,b],e[7]=t,e[8]=n,e[9]=E,e[10]=y):y=e[10],I(()=>m.attach(n,f,d,p,l,{onError:b}),y),v===void 0?g:v},G=function(o,r={}){return D(o,r)};function Y(){return 0}export{D as default,G as hydratePreloaded};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as M}from"react/compiler-runtime";import{LunoraError as D}from"@lunora/errors";import{QueryClientContext as R,QueryClientProvider as A,QueryClient as N}from"@tanstack/react-query";import{createContext as z,use as Q,useState as S,useEffect as x,useRef as _}from"react";import{stableWireKey as $}from"@lunora/wire";import{jsx as I}from"react/jsx-runtime";const w=e=>$(e),tt=e=>w(e),k=e=>{e!==void 0&&(e.cancel({silent:!0}),e.setState({...e.state,data:void 0,dataUpdatedAt:0,error:null,fetchStatus:"idle",status:"pending"}))},m={status:"idle"},T=(e,t)=>{for(const s of e.waiters)s(t);e.waiters.clear()},U=1e4,B=async(e,t,s)=>new Promise((i,c)=>{if(t.aborted){c(t.reason);return}let u,d;const l=()=>{clearTimeout(u),d?.(),e.waiters.delete(r),t.removeEventListener("abort",n)},n=()=>{l(),c(t.reason)},r=h=>{l(),i(h)};u=setTimeout(()=>{r(!1)},U),e.waiters.add(r),t.addEventListener("abort",n,{once:!0}),d=s(()=>{r(!1)}),e.waiters.has(r)||d()});class H{constructor(t){this.client=t}client;entries=new Map;live=new Map;identityWatched=new Set;listening=!1;hasConsumers(t){return this.entries.has(w(t))}async liveValue(t,s,i,c){const{fetch:u,shardKey:d,waitForPush:l=!0}=c;if(!("window"in globalThis)||this.client.getWebSocketImpl()===void 0)return u();const n=w(s),r=this.liveFor(n),h=r.state.status==="pushed"?t.getQueryData(s)??r.state.value:void 0;if(h!==void 0)return h;if(l&&r.state.status!=="errored"&&!this.client.isCrossTabFollower()&&this.client.expectsPush({shardKey:d})){let o;try{o=await B(r,i,f=>this.client.onConnectionStatus(()=>{this.client.expectsPush({shardKey:d})||f()}))}finally{this.forgetIdleLive(n)}if(o)return this.liveValue(t,s,i,c)}const p=r.state;let a;try{a=await u()}finally{this.forgetIdleLive(n)}if(r.state!==p&&r.state.status==="pushed"){const o=t.getQueryData(s);return o!==void 0?o:r.state.value}return a}clearOnIdentityChange(t){this.listenForIdentityChange(),this.identityWatched.add(t)}stopClearingOnIdentityChange(t){this.identityWatched.delete(t)}subscribeIdentityEpoch=t=>(this.listenForIdentityChange(),this.client.onIdentityChange(t));listenForIdentityChange(){this.listening||(this.listening=!0,this.client.onIdentityChange(()=>{for(const t of this.identityWatched)this.clearQueries(t)}))}clearQueries(t){const s=t.getQueryCache();for(const i of s.findAll({queryKey:["lunora"]}))k(i),i.getObserversCount()===0&&!this.hasConsumers(i.queryKey)&&s.remove(i)}attach(t,s,i,c,u,d={}){const l=w(s);let n=this.entries.get(l);if(!n){n={clients:new Map([[t,0]]),errorCallbacks:new Set,unsubscribe:void 0},this.entries.set(l,n);const a=n;try{n.unsubscribe=this.client.subscribe(i,c,o=>{const f=this.liveFor(l);if(o===void 0){f.state=m;for(const v of a.clients.keys())k(v.getQueryCache().find({exact:!0,queryKey:s}));return}for(const v of a.clients.keys())v.setQueryData(s,o);f.state={status:"pushed",value:o},T(f,!0)},{onError:o=>{const f=this.liveFor(l);f.state.status!=="pushed"&&(f.state={status:"errored"},T(f,!1));for(const v of a.errorCallbacks)v(o)},shardKey:u})}catch(o){throw this.entries.delete(l),this.dropLive(l),o}}n.clients.set(t,(n.clients.get(t)??0)+1);const r=this.live.get(l);r?.state.status==="pushed"&&t.setQueryData(s,r.state.value);const{onError:h}=d;h&&n.errorCallbacks.add(h);let p=!1;return()=>{if(p)return;p=!0;const a=this.entries.get(l);if(!a)return;const o=(a.clients.get(t)??1)-1;o>0?a.clients.set(t,o):a.clients.delete(t),h&&a.errorCallbacks.delete(h),a.clients.size===0&&(a.unsubscribe?.(),this.entries.delete(l),this.dropLive(l))}}awaitFreshPush(t){const s=this.live.get(w(t));s?.state.status==="pushed"&&(s.state=m)}liveFor(t){let s=this.live.get(t);return s||(s={state:m,waiters:new Set},this.live.set(t,s)),s}forgetIdleLive(t){!this.entries.has(t)&&this.live.get(t)?.waiters.size===0&&this.live.delete(t)}dropLive(t){const s=this.live.get(t);s!==void 0&&(s.waiters.size===0?this.live.delete(t):s.state=m)}}const E=new WeakMap,L=e=>{let t=E.get(e);return t||(t=new H(e),E.set(e,t)),t},F=Symbol.for("@lunora/react/contexts"),V=()=>{const e=globalThis;return e[F]??=new Map,e[F]},Y=e=>e===null?"null":typeof e,P=function(e,t){const s=V(),i=Y(t),c=s.get(e);if(c!==void 0){if(c.kind!==i)throw new Error(`Context "${e}" was registered with a ${c.kind} default; a copy asked for a ${i} default.`);return c.context}const u=z(t);return s.set(e,{context:u,kind:i}),u},O=P("lunora-client",null),W=P("lunora-client-swapped",!1),j=()=>new N({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),et=e=>{const t=M(20),{children:s,client:i,queryClient:c}=e,u=Q(R);let d;t[0]!==u||t[1]!==c?(d=()=>c??u??j(),t[0]=u,t[1]=c,t[2]=d):d=t[2];const[l]=S(d),n=c??u??l;let r,h;t[3]!==i||t[4]!==n?(r=()=>{L(i).clearOnIdentityChange(n)},h=[i,n],t[3]=i,t[4]=n,t[5]=r,t[6]=h):(r=t[5],h=t[6]),x(r,h);const p=_(i);let a,o;t[7]!==i||t[8]!==n?(a=()=>{p.current!==i&&(L(p.current).stopClearingOnIdentityChange(n),p.current=i,L(i).clearQueries(n),n.invalidateQueries({queryKey:["lunora"]}))},o=[i,n],t[7]=i,t[8]=n,t[9]=a,t[10]=o):(a=t[9],o=t[10]),x(a,o);const[f]=S(i),v=i!==f;let g;t[11]!==s||t[12]!==v?(g=I(W,{value:v,children:s}),t[11]=s,t[12]=v,t[13]=g):g=t[13];let y;t[14]!==i||t[15]!==g?(y=I(O,{value:i,children:g}),t[14]=i,t[15]=g,t[16]=y):y=t[16];const C=y;if(u===n)return C;let b;return t[17]!==C||t[18]!==n?(b=I(A,{client:n,children:C}),t[17]=C,t[18]=n,t[19]=b):b=t[19],b},st=()=>Q(W),it=()=>{const e=Q(O);if(!e)throw new D("INTERNAL","useLunora must be used inside <LunoraProvider />");return e};export{et as L,st as a,L as g,tt as s,it as u};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{initialPages as z,isHeadPage as G,rebalance as J,derivePaginationStatus as V,applyLoadMore as U,classifyPageFailure as X,headPage as Z}from"@lunora/client/pagination";import{useQueryClient as ee,CancelledError as se}from"@tanstack/react-query";import{useRef as y,useReducer as te,useState as _,useEffect as p,useMemo as re,useCallback as ne}from"react";import{u as ae,s as I,g as $}from"./lunora-provider-BLU6gzBE.mjs";import{lunoraQueryKey as S}from"@lunora/client/query";const oe=function(d){const v=y(void 0);return v.current??=d(),v},he=function(d,v,F){const f=ae(),c=ee(),{initialNumItems:w,shardKey:P}=F,l=v==="skip",E=l?{}:v,[,j]=te(e=>e+1,0),[m,K]=_(()=>z(w)),[W,C]=_(void 0),x=y(F.onError);p(()=>{x.current=F.onError});const R=`${I(S(d,E,P))}::${String(w)}`,H=y(R),Q=y(!1),g=y(void 0);H.current!==R&&(H.current=R,Q.current=!1,g.current=void 0,K(z(w)),C(void 0));const A=re(()=>new WeakMap,[R]),q=m.map(e=>{let r=A.get(e);if(r===void 0){const a={...E,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},o=S(d,a,P);r={args:a,hash:I(o),key:o},A.set(e,r)}return r}),L=q.map(({hash:e})=>e).join("|"),k=y({baseArgs:E,entries:[],fn:d,pages:m,shardKey:P});p(()=>{k.current={baseArgs:E,entries:q,fn:d,pages:m,shardKey:P}});const N=(e,r,a)=>{if(H.current!==R)return;const o=k.current,t=s=>({...o.baseArgs,paginationOpts:{cursor:s.lower,endCursor:s.upper,numItems:s.numItems}}),n=s=>I(S(o.fn,t(s),o.shardKey)),u=X(o.pages,s=>n(s)===e,a,Q.current);if(u==="restart"){const s=Z(w),i=[s];f.resnapshot(o.fn,t(s),{shardKey:o.shardKey}),$(f).awaitFreshPush(S(o.fn,t(s),o.shardKey)),g.current=n(s),k.current={...o,pages:i},Q.current=!0,K(i),C(void 0)}u==="surface"&&(C(a),K(s=>{const i=s.at(-1);return s.length<=1||!i||c.getQueryData(r)!==void 0?s:n(i)===e?s.slice(0,-1):s}),x.current?.(a))},M=oe(()=>new Map),T=y(f);p(()=>{const e=M.current;if(T.current!==f){for(const t of e.values())t();e.clear(),T.current=f}if(l){for(const t of e.values())t();e.clear();return}const r=k.current,a=$(f),o=new Set(r.entries.map(({hash:t})=>t));for(const[t,n]of e)o.has(t)||(n(),e.delete(t));for(const t of r.entries){const{hash:n}=t;if(e.has(n))continue;const u=async()=>f.query(r.fn,t.args,{shardKey:r.shardKey}),s=()=>{c.fetchQuery({gcTime:Number.POSITIVE_INFINITY,queryFn:async({signal:h})=>a.liveValue(c,t.key,h,{fetch:u,shardKey:r.shardKey}),queryKey:t.key,staleTime:0}).catch(h=>{if(h instanceof se){a.hasConsumers(t.key)&&s();return}N(n,t.key,h instanceof Error?{code:h.code,message:h.message}:{message:String(h)})})};s();const i=a.attach(c,t.key,r.fn,t.args,r.shardKey,{onError:D=>{N(n,t.key,D)}}),b=t.key;e.set(n,()=>{i(),a.hasConsumers(b)||c.removeQueries({exact:!0,queryKey:b})})}},[f,c,L,l]),p(()=>()=>{for(const e of M.current.values())e();M.current.clear()},[]),p(()=>{const e=c.getQueryCache(),r=new Set,a=new Set;for(const[n,{hash:u}]of q.entries())r.add(u),m[n]!==void 0&&!G(m[n])&&a.add(u);const o=d.__lunoraRef;return e.subscribe(n=>{if(n.type!=="updated")return;const u=n.query.queryKey;if(u[1]!==o)return;const s=I(u);r.has(s)&&(n.action.type==="success"&&(a.has(s)&&(Q.current=!1),g.current===s&&(g.current=void 0),C(void 0)),j())})},[c,L]);const O=l?[]:q.map(({hash:e,key:r})=>g.current===e?void 0:c.getQueryData(r));p(()=>{if(l)return;const e=J(m,O);e&&K(e)});const{status:Y}=V(l,O),B=ne(e=>{C(void 0),K(r=>{const a=k.current,o=r.map(s=>{const i={...a.baseArgs,paginationOpts:{cursor:s.lower,endCursor:s.upper,numItems:s.numItems}},b=S(a.fn,i,a.shardKey);return g.current===I(b)?void 0:c.getQueryData(b)}),{nextCursor:t,status:n}=V(!1,o);return U(r,n==="CanLoadMore"?t:void 0,e)??r})},[c]);return{error:W,loadMore:B,pageResults:O,status:Y}};export{he as u};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as R}from"react/compiler-runtime";import{createCallRunner as k}from"@lunora/client";import{useMutation as x}from"@tanstack/react-query";import{useState as n}from"react";import{u as C}from"./lunora-provider-BLU6gzBE.mjs";const S=a=>{const t=R(12),i=C(),[c,g]=n(void 0),[l,m]=n(void 0),[u,M]=n(!1);let o;t[0]!==i||t[1]!==a?(o={mutationFn:async e=>{const{args:y,options:A}=e;return i.action(a,y,A)},networkMode:"always",retry:0},t[0]=i,t[1]=a,t[2]=o):o=t[2];const{mutateAsync:d,reset:p}=x(o);let s;t[3]!==d||t[4]!==p?(s=()=>({call:k(async(e,y)=>d({args:e,options:y}),{setError:m,setPending:M,setResult:e=>{g(()=>e),m(void 0)}}),reset:()=>{g(void 0),m(void 0),p()}}),t[3]=d,t[4]=p,t[5]=s):s=t[5];const[w]=n(s),{call:f,reset:v}=w;let r;return t[6]!==f||t[7]!==c||t[8]!==l||t[9]!==u||t[10]!==v?(r={call:f,data:c,error:l,pending:u,reset:v},t[6]=f,t[7]=c,t[8]=l,t[9]=u,t[10]=v,t[11]=r):r=t[11],r};export{S as useAction};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as m}from"react/compiler-runtime";import{isLunoraAdminClient as S}from"@lunora/client/admin";import{authSessionsList as v,authUsersList as I,authOrganizationsList as b,authSignUpInvitationsList as z,ADMIN_AUTH_DEFAULT_PAGE_SIZE as U,subscribeAdminAuthIdentity as w,adminAuthListQueryKey as E,adminAuthListHasMore as P}from"@lunora/client/auth";import{LunoraError as M}from"@lunora/errors";import{useMutation as T,useQuery as $,keepPreviousData as q}from"@tanstack/react-query";import{useState as C,useSyncExternalStore as D}from"react";import{u as _}from"./lunora-provider-BLU6gzBE.mjs";const f=()=>{const e=_();if(!S(e))throw new M("INTERNAL","The admin auth hooks need a LunoraAdminClient: construct the provider's client with `new LunoraAdminClient(...)` from `@lunora/client/admin`.");return e};function p(e,t,i={}){const{enabled:r=!0,pageSize:o=U}=i,[s,a]=C(o),n=D(d=>w(e,d),()=>e.currentIdentity(),()=>e.currentIdentity()),c=E(n,t,s),u=$({enabled:r,placeholderData:(d,y)=>y?.queryKey[1]===c[1]?q(d):void 0,queryFn:()=>t.fetchPage(s),queryKey:c,staleTime:0}),l=u.data?.rows,A=u.data?.total,h=P(u.data),g=()=>{h&&a(d=>d+o)},L=()=>{u.refetch().catch(()=>{})};return{data:l,error:u.error??void 0,hasMore:h,loadMore:g,loading:u.isLoading,refetch:L,total:A}}const Q=e=>{const t=m(3),i=e===void 0?{}:e,r=f(),{enabled:o,pageSize:s,...a}=i;let n;return t[0]!==o||t[1]!==s?(n={enabled:o,pageSize:s},t[0]=o,t[1]=s,t[2]=n):n=t[2],p(r,I(r,a),n)},G=e=>{const t=m(7);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const r=i,o=f(),{enabled:s,pageSize:a}=r;let n;t[2]!==o?(n=b(o),t[2]=o,t[3]=n):n=t[3];let c;return t[4]!==s||t[5]!==a?(c={enabled:s,pageSize:a},t[4]=s,t[5]=a,t[6]=c):c=t[6],p(o,n,c)},R=e=>{const t=m(7);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const r=i,o=f(),{enabled:s,pageSize:a}=r;let n;t[2]!==o?(n=z(o),t[2]=o,t[3]=n):n=t[3];let c;return t[4]!==s||t[5]!==a?(c={enabled:s,pageSize:a},t[4]=s,t[5]=a,t[6]=c):c=t[6],p(o,n,c)},Z=e=>{const t=m(3),i=e===void 0?{}:e,r=f(),{enabled:o,pageSize:s,userId:a}=i;let n;return t[0]!==o||t[1]!==s?(n={enabled:o,pageSize:s},t[0]=o,t[1]=s,t[2]=n):n=t[2],p(r,v(r,{userId:a}),n)},j=()=>{const e=m(10),t=f();let i;e[0]!==t?(i={mutationFn:l=>t.impersonateAuthUser({userId:l})},e[0]=t,e[1]=i):i=e[1];const r=T(i),{mutateAsync:o,reset:s}=r;let a;e[2]!==o?(a=l=>o(l),e[2]=o,e[3]=a):a=e[3];const n=a,c=r.error??void 0;let u;return e[4]!==n||e[5]!==r.data||e[6]!==r.isPending||e[7]!==s||e[8]!==c?(u={data:r.data,error:c,impersonate:n,pending:r.isPending,reset:s},e[4]=n,e[5]=r.data,e[6]=r.isPending,e[7]=s,e[8]=c,e[9]=u):u=e[9],u};export{Z as useAuthSessions,Q as useAuthUsers,j as useImpersonate,G as useOrganizations,R as useSignUpInvitations};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{useQueryClient as k,useMutation as v,onlineManager as g}from"@tanstack/react-query";import{useRef as A,useState as P,useCallback as O}from"react";import{u as Q}from"./lunora-provider-BLU6gzBE.mjs";const R=async()=>new Promise(n=>{if(g.isOnline()){n();return}const r=g.subscribe(u=>{u&&(r(),n())})}),x=n=>{const r=Q(),u=k(),a=n.sensitive===!0,c=A(0),[l,p]=P(!1),b=v({mutationFn:async({args:e,options:t})=>(!(a||t?.onlineOnly===!0)&&!r.canQueueOffline(t?.shardKey)&&await R(),r.mutation(n,e,t)),networkMode:"always",...a?{gcTime:0}:{},retry:0,onMutate:()=>{c.current+=1,p(!0)},onSettled:(e,t,o)=>{if(c.current-=1,p(c.current>0),a||o.options?.onlineOnly===!0){const i=u.getMutationCache();for(const h of i.findAll({predicate:C=>C.state.variables===o}))i.remove(h)}}}),{data:m,error:d,isError:f,mutateAsync:s,reset:y}=b,w=O((e,t)=>s({args:e,options:t}),[s]),M=O(e=>({data:m,error:d,isError:f,mutate:(o,i)=>s({args:o,options:{optimisticUpdate:e,...i}}),pending:l,reset:y,withOptimisticUpdate:M}),[s,m,d,f,l,y]);return{data:m,error:d,isError:f,mutate:w,pending:l,reset:y,withOptimisticUpdate:M}};export{x as useMutation};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as k}from"react/compiler-runtime";import{useQueryClient as q,useQuery as E}from"@tanstack/react-query";import{useState as F,useEffect as N}from"react";import{u as T,g as V}from"./lunora-provider-BLU6gzBE.mjs";import{u as A}from"./query-core-C6u-yRAv.mjs";import{stableWireKey as C}from"@lunora/wire";import{lunoraQueryKeyFromArgsKey as D}from"@lunora/client/query";const P=(s,K,R)=>{const e=k(26),v=R===void 0?{}:R,t=T(),y=q(),{onError:Q,shardKey:r}=v,u=K==="skip",o=u?{}:K,l=C(o),a=D(s.__lunoraRef,l,r),[n,b]=F(t.isReady);let d,c;e[0]!==t||e[1]!==n?(d=()=>{n||t.whenReady().then(()=>{b(!0)})},c=[t,n],e[0]=t,e[1]=n,e[2]=d,e[3]=c):(d=e[2],c=e[3]),N(d,c);let m;if(!u){const h=t.peekHydratedQueryByKey(s.__lunoraRef,l,r);m=h===void 0?t.peekActiveQuerySnapshot(s.__lunoraRef,o,r).value:h}const g=!u&&n;let i;e[4]!==o||e[5]!==t||e[6]!==s||e[7]!==y||e[8]!==a||e[9]!==r?(i=async h=>{const{signal:S}=h;return V(t).liveValue(y,a,S,{fetch:async()=>t.query(s,o,{shardKey:r}),shardKey:r})},e[4]=o,e[5]=t,e[6]=s,e[7]=y,e[8]=a,e[9]=r,e[10]=i):i=e[10];let p;e[11]!==m||e[12]!==a||e[13]!==g||e[14]!==i?(p={enabled:g,initialData:m,queryFn:i,queryKey:a,staleTime:Number.POSITIVE_INFINITY},e[11]=m,e[12]=a,e[13]=g,e[14]=i,e[15]=p):p=e[15];const{data:I}=E(p);let f;return e[16]!==l||e[17]!==o||e[18]!==t||e[19]!==s||e[20]!==Q||e[21]!==y||e[22]!==a||e[23]!==r||e[24]!==u?(f={args:o,argsKey:l,client:t,function_:s,onError:Q,queryClient:y,queryKey:a,shardKey:r,skipped:u},e[16]=l,e[17]=o,e[18]=t,e[19]=s,e[20]=Q,e[21]=y,e[22]=a,e[23]=r,e[24]=u,e[25]=f):f=e[25],A(f),u?void 0:I};export{P as default};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as h}from"react/compiler-runtime";import{useQueryClient as R,useSuspenseQuery as S}from"@tanstack/react-query";import{u as I,g as b}from"./lunora-provider-BLU6gzBE.mjs";import{u as q}from"./query-core-C6u-yRAv.mjs";import{stableWireKey as F}from"@lunora/wire";import{lunoraQueryKeyFromArgsKey as k}from"@lunora/client/query";const E=(s,m,c)=>{const e=h(21),f=c===void 0?{}:c,r=I(),u=R(),{onError:d,shardKey:t}=f,y=m,o=F(y),a=k(s.__lunoraRef,o,t),p=r.isReady?r.peekHydratedQueryByKey(s.__lunoraRef,o,t):void 0;let i;e[0]!==o||e[1]!==y||e[2]!==r||e[3]!==s||e[4]!==u||e[5]!==a||e[6]!==t?(i=async K=>{const{signal:Q}=K;return await r.whenReady(),r.peekHydratedQueryByKey(s.__lunoraRef,o,t)??b(r).liveValue(u,a,Q,{fetch:async()=>r.query(s,y,{shardKey:t}),waitForPush:!1})},e[0]=o,e[1]=y,e[2]=r,e[3]=s,e[4]=u,e[5]=a,e[6]=t,e[7]=i):i=e[7];let l;e[8]!==p||e[9]!==a||e[10]!==i?(l={initialData:p,queryFn:i,queryKey:a,staleTime:Number.POSITIVE_INFINITY},e[8]=p,e[9]=a,e[10]=i,e[11]=l):l=e[11];const{data:g}=S(l);let n;return e[12]!==o||e[13]!==y||e[14]!==r||e[15]!==s||e[16]!==d||e[17]!==u||e[18]!==a||e[19]!==t?(n={args:y,argsKey:o,client:r,function_:s,onError:d,queryClient:u,queryKey:a,shardKey:t,skipped:!1},e[12]=o,e[13]=y,e[14]=r,e[15]=s,e[16]=d,e[17]=u,e[18]=a,e[19]=t,e[20]=n):n=e[20],q(n),g};export{E as default};