@lunora/react 1.0.0-alpha.162 → 1.0.0-alpha.164
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{AuthLoading-DbI2ovRV.mjs → AuthLoading-B4jVX_aA.mjs} +1 -1
- package/dist/packem_shared/LunoraProvider-Ci_P6FY7.mjs +1 -0
- package/dist/packem_shared/{hydratePreloaded-CmtR7jaQ.mjs → hydratePreloaded-CNOIaG0h.mjs} +1 -1
- package/dist/packem_shared/lunora-provider-aorznd0I.mjs +2 -0
- package/dist/packem_shared/{use-paginated-core-ysTYml_x.mjs → use-paginated-core-Dytoa06S.mjs} +1 -1
- package/dist/packem_shared/{useAction-BULAtq6G.mjs → useAction-OoXhANly.mjs} +1 -1
- package/dist/packem_shared/{useAgent-lh7vtWhN.mjs → useAgent-3vl54qli.mjs} +1 -1
- package/dist/packem_shared/{useAgentChat-i1cLTYg-.mjs → useAgentChat-BJS0XeKI.mjs} +1 -1
- package/dist/packem_shared/{useAgentState-ClUrwL_h.mjs → useAgentState-Cal6pSHx.mjs} +1 -1
- package/dist/packem_shared/{useAgentToolEvents-9XJIaMJp.mjs → useAgentToolEvents-BfGsPL2O.mjs} +1 -1
- package/dist/packem_shared/{useAuth-ChPgdlLE.mjs → useAuth-BfihbPPf.mjs} +1 -1
- package/dist/packem_shared/{useAuthSessions-DdVh17uy.mjs → useAuthSessions-DaGcJAED.mjs} +1 -1
- package/dist/packem_shared/{useAuthState-DmLnYLOX.mjs → useAuthState-Fz2ZwPlz.mjs} +1 -1
- package/dist/packem_shared/{useClientQuery-KWIXa1Ug.mjs → useClientQuery-Dse-Rcjt.mjs} +1 -1
- package/dist/packem_shared/{useConnectionStatus-nYMTxult.mjs → useConnectionStatus-CHMUg2j8.mjs} +1 -1
- package/dist/packem_shared/{useFlag-YD7rWpyw.mjs → useFlag-BANpvheX.mjs} +1 -1
- package/dist/packem_shared/{useHttpStream-CNRWf1rj.mjs → useHttpStream-TVol6N-e.mjs} +1 -1
- package/dist/packem_shared/{useInfiniteQuery-CCxQDJfp.mjs → useInfiniteQuery-HgFi_9Rq.mjs} +1 -1
- package/dist/packem_shared/{useMutation-BGafL9Lt.mjs → useMutation-BN3iQJB8.mjs} +1 -1
- package/dist/packem_shared/{usePaginatedQuery-BuGyCMrx.mjs → usePaginatedQuery-zcNSY-31.mjs} +1 -1
- package/dist/packem_shared/{usePresence-BVRKQQhi.mjs → usePresence-77FOv5Gn.mjs} +1 -1
- package/dist/packem_shared/{useQuery-BHAkv-Kd.mjs → useQuery-DwgOK813.mjs} +1 -1
- package/dist/packem_shared/{useStream-CRdt6N67.mjs → useStream-DUOoXrbS.mjs} +1 -1
- package/dist/packem_shared/{useSubscription-DnyZrPty.mjs → useSubscription-BYPfDHYS.mjs} +1 -1
- package/dist/packem_shared/{useVoiceAgent-DSUfJgTi.mjs → useVoiceAgent-CF0Qcu9f.mjs} +1 -1
- package/package.json +4 -4
- package/dist/packem_shared/LunoraProvider-Dek_2gXl.mjs +0 -1
- package/dist/packem_shared/lunora-provider-eFDwhoSo.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-
|
|
2
|
+
import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-B4jVX_aA.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-Fz2ZwPlz.mjs";import{L as n,u as f}from"./packem_shared/lunora-provider-aorznd0I.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-BuCFB9h1.mjs";import{useAction as x}from"./packem_shared/useAction-OoXhANly.mjs";import{useAuthSessions as g,useAuthUsers as A,useImpersonate as h,useOrganizations as U,useSignUpInvitations as c}from"./packem_shared/useAuthSessions-DaGcJAED.mjs";import{useAgent as C}from"./packem_shared/useAgent-3vl54qli.mjs";import{useAgentChat as S}from"./packem_shared/useAgentChat-BJS0XeKI.mjs";import{useAgentState as L}from"./packem_shared/useAgentState-Cal6pSHx.mjs";import{useAgentToolEvents as R}from"./packem_shared/useAgentToolEvents-BfGsPL2O.mjs";import{default as I}from"./packem_shared/useAuth-BfihbPPf.mjs";import{default as v}from"./packem_shared/useClientQuery-Dse-Rcjt.mjs";import{default as z}from"./packem_shared/useConnectionStatus-CHMUg2j8.mjs";import{useFlag as T,useFlags as k}from"./packem_shared/useFlag-BANpvheX.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-TVol6N-e.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-HgFi_9Rq.mjs";import{useMutation as B}from"./packem_shared/useMutation-BN3iQJB8.mjs";import{useMutator as G}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as K}from"./packem_shared/usePaginatedQuery-zcNSY-31.mjs";import{hydratePreloaded as W,default as X}from"./packem_shared/hydratePreloaded-CNOIaG0h.mjs";import{usePresence as Z}from"./packem_shared/usePresence-77FOv5Gn.mjs";import{default as $}from"./packem_shared/useQuery-DwgOK813.mjs";import{useRateLimit as re}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as te}from"./packem_shared/useStream-DUOoXrbS.mjs";import{default as se}from"./packem_shared/useSubscription-BYPfDHYS.mjs";import{useVoiceAgent as pe}from"./packem_shared/useVoiceAgent-CF0Qcu9f.mjs";import{createClientQuery as fe,getErrorCode as ie,getRetryAfterMs as me,isConflictError as de,isForbiddenError as xe,isRateLimitedError as le,isUnauthorizedError as ge}from"@lunora/client";import{RestrictionError as he,UploadControl as Ue,UploadError as ce}from"@visulima/storage-client";import{useChunkedRestUpload as Ce,useFileInput as Ee,useMultipartUpload as Se,usePasteUpload as Qe,useTusUpload as Le,useUpload as Pe}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,n as LunoraProvider,he as RestrictionError,u as Unauthenticated,Ue as UploadControl,ce as UploadError,fe as createClientQuery,ie as getErrorCode,me as getRetryAfterMs,W as hydratePreloaded,de as isConflictError,xe as isForbiddenError,le as isRateLimitedError,ge as isUnauthorizedError,m as lunoraQueryOptions,x as useAction,C as useAgent,S as useAgentChat,L as useAgentState,R as useAgentToolEvents,I as useAuth,g as useAuthSessions,a as useAuthState,A as useAuthUsers,Ce as useChunkedRestUpload,v as useClientQuery,z as useConnectionStatus,Ee as useFileInput,T as useFlag,k as useFlags,V as useHttpStream,h as useImpersonate,q as useInfiniteQuery,f as useLunora,Se as useMultipartUpload,B as useMutation,G as useMutator,U as useOrganizations,K as usePaginatedQuery,Qe as usePasteUpload,X as usePreloadedQuery,Z as usePresence,$ as useQuery,re as useRateLimit,c as useSignUpInvitations,te as useStream,se as useSubscription,Le as useTusUpload,Pe as useUpload,pe as useVoiceAgent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{useAuthState as o}from"./useAuthState-
|
|
2
|
+
import{useAuthState as o}from"./useAuthState-Fz2ZwPlz.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 a,u}from"./lunora-provider-aorznd0I.mjs";export{a as LunoraProvider,u as useLunora};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as R}from"react/compiler-runtime";import{useQueryClient as q,useQuery as K}from"@tanstack/react-query";import{useRef as P,useEffect as S,useSyncExternalStore as C,useState as N}from"react";import{u as T,g as x}from"./lunora-provider-
|
|
2
|
+
import{c as R}from"react/compiler-runtime";import{useQueryClient as q,useQuery as K}from"@tanstack/react-query";import{useRef as P,useEffect as S,useSyncExternalStore as C,useState as N}from"react";import{u as T,g as x}from"./lunora-provider-aorznd0I.mjs";import{l as F,a as O}from"./query-key-QcTqsWNc.mjs";const z=function(o,r){const e=R(9);let n;e[0]!==r?(n=r===void 0?{}:r,e[0]=r,e[1]=n):n=e[1];const s=n,t=T(),i=q(),p=P(s.onError);let u;e[2]!==s.onError?(u=()=>{p.current=s.onError},e[2]=s.onError,e[3]=u):u=e[3],S(u);let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=Q=>{p.current?.(Q)},e[4]=c):c=e[4];const h=c,l=x(t),_=C(l.subscribeIdentityEpoch,l.identityEpoch,D),[g]=N(t),{args:f,functionPath:v,shardKey:y}=o,b=_===0&&t===g?o.value:void 0,m={__lunoraRef:v},E=F(m,f,y),{data:I}=K({initialData:b,queryFn:()=>t.query(m,f,{shardKey:y}),queryKey:E,staleTime:Number.POSITIVE_INFINITY}),d=O(E);let a;return e[5]!==t||e[6]!==i||e[7]!==d?(a=[t,i,d,h],e[5]=t,e[6]=i,e[7]=d,e[8]=a):a=e[8],S(()=>l.attach(i,E,m,f,y,{onError:h}),a),I===void 0?b:I},k=function(o,r={}){return z(o,r)};function D(){return 0}export{z as default,k as hydratePreloaded};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as w}from"react/compiler-runtime";import{LunoraError as L}from"@lunora/errors";import{QueryClientContext as E,QueryClientProvider as O,QueryClient as x}from"@tanstack/react-query";import{use as v,useState as N,useEffect as b,useRef as T,createContext as W}from"react";import{k as g}from"./query-key-QcTqsWNc.mjs";import{jsx as k}from"react/jsx-runtime";const I=n=>{n!==void 0&&(n.cancel({silent:!0}),n.setState({...n.state,data:void 0,dataUpdatedAt:0,error:null,fetchStatus:"idle",status:"pending"}))};class F{constructor(e){this.client=e}client;entries=new Map;pushes=new Map;samples=new Map;epoch=0;identityWatched=new Set;listening=!1;hasConsumers(e){return this.entries.has(g(e))}openSnapshotSample(e){const r=g(e);return this.samples.set(r,(this.samples.get(r)??0)+1),{key:r,pushes:this.pushes.get(r)??0}}closeSnapshotSample(e){const r=(this.samples.get(e.key)??1)-1,t=(this.pushes.get(e.key)??0)===e.pushes;return r>0?(this.samples.set(e.key,r),t):(this.samples.delete(e.key),this.entries.has(e.key)||this.pushes.delete(e.key),t)}clearOnIdentityChange(e){this.listenForIdentityChange(),this.identityWatched.add(e)}stopClearingOnIdentityChange(e){this.identityWatched.delete(e)}identityEpoch=()=>this.epoch;subscribeIdentityEpoch=e=>(this.listenForIdentityChange(),this.client.onIdentityChange(e));listenForIdentityChange(){this.listening||(this.listening=!0,this.client.onIdentityChange(()=>{this.epoch+=1;for(const e of this.identityWatched)this.clearQueries(e)}))}clearQueries(e){const r=e.getQueryCache();for(const t of r.findAll({queryKey:["lunora"]}))I(t),t.getObserversCount()===0&&!this.hasConsumers(t.queryKey)&&r.remove(t)}attach(e,r,t,h,c,d={}){const a=g(r);let s=this.entries.get(a);if(!s){s={errorCallbacks:new Set,refCount:0,unsubscribe:void 0},this.entries.set(a,s);const i=s;try{s.unsubscribe=this.client.subscribe(t,h,o=>{if(this.pushes.set(a,(this.pushes.get(a)??0)+1),o===void 0){I(e.getQueryCache().find({exact:!0,queryKey:r}));return}e.setQueryData(r,o)},{onError:o=>{for(const f of i.errorCallbacks)f(o)},shardKey:c})}catch(o){throw this.entries.delete(a),o}}s.refCount+=1;const{onError:u}=d;u&&s.errorCallbacks.add(u);let l=!1;return()=>{if(l)return;l=!0;const i=this.entries.get(a);i&&(i.refCount-=1,u&&i.errorCallbacks.delete(u),i.refCount<=0&&(i.unsubscribe?.(),this.entries.delete(a)))}}}const Q=new WeakMap,m=n=>{let e=Q.get(n);return e||(e=new F(n),Q.set(n,e)),e},S=W(null),M=()=>new x({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),B=n=>{const e=w(17),{children:r,client:t,queryClient:h}=n,c=v(E);let d;e[0]!==c||e[1]!==h?(d=()=>h??c??M(),e[0]=c,e[1]=h,e[2]=d):d=e[2];const[a]=N(d),s=h??c??a;let u,l;e[3]!==t||e[4]!==s?(u=()=>{m(t).clearOnIdentityChange(s)},l=[t,s],e[3]=t,e[4]=s,e[5]=u,e[6]=l):(u=e[5],l=e[6]),b(u,l);const i=T(t);let o,f;e[7]!==t||e[8]!==s?(o=()=>{i.current!==t&&(m(i.current).stopClearingOnIdentityChange(s),i.current=t,m(t).clearQueries(s),s.invalidateQueries({queryKey:["lunora"]}))},f=[t,s],e[7]=t,e[8]=s,e[9]=o,e[10]=f):(o=e[9],f=e[10]),b(o,f);let y;e[11]!==r||e[12]!==t?(y=k(S,{value:t,children:r}),e[11]=r,e[12]=t,e[13]=y):y=e[13];const p=y;if(c===s)return p;let C;return e[14]!==p||e[15]!==s?(C=k(O,{client:s,children:p}),e[14]=p,e[15]=s,e[16]=C):C=e[16],C},H=()=>{const n=v(S);if(!n)throw new L("INTERNAL","useLunora must be used inside <LunoraProvider />");return n};export{B as L,m as g,H as u};
|
package/dist/packem_shared/{use-paginated-core-ysTYml_x.mjs → use-paginated-core-Dytoa06S.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{initialPages as O,rebalance as Y,derivePaginationStatus as T,applyLoadMore as _}from"@lunora/client/pagination";import{useQueryClient as B,CancelledError as G}from"@tanstack/react-query";import{useRef as p,useReducer as J,useState as z,useEffect as d,useCallback as U}from"react";import{u as W,g as X}from"./lunora-provider-
|
|
2
|
+
import{initialPages as O,rebalance as Y,derivePaginationStatus as T,applyLoadMore as _}from"@lunora/client/pagination";import{useQueryClient as B,CancelledError as G}from"@tanstack/react-query";import{useRef as p,useReducer as J,useState as z,useEffect as d,useCallback as U}from"react";import{u as W,g as X}from"./lunora-provider-aorznd0I.mjs";import{a as u,l as S}from"./query-key-QcTqsWNc.mjs";const Z=function(i){const l=p(void 0);return l.current??=i(),l},oe=function(i,l,R){const y=W(),o=B(),{initialNumItems:Q,shardKey:g}=R,f=l==="skip",k=f?{}:l,[,$]=J(e=>e+1,0),[P,K]=z(()=>O(Q)),[j,C]=z(void 0),A=p(R.onError);d(()=>{A.current=R.onError});const E=`${u(S(i,k,g))}::${String(Q)}`,x=p(E);x.current!==E&&(x.current=E,K(O(Q)),C(void 0));const b=P.map(e=>{const r={...k,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},t=S(i,r,g);return{args:r,key:t}}),D=b.map(({key:e})=>u(e)).join("|"),v=p({baseArgs:k,entries:[],fn:i,shardKey:g});d(()=>{v.current={baseArgs:k,entries:b,fn:i,shardKey:g}});const F=(e,r,t)=>{C(t),K(a=>{const s=v.current,n=a.at(-1);if(a.length<=1||!n||o.getQueryData(r)!==void 0)return a;const m={...s.baseArgs,paginationOpts:{cursor:n.lower,endCursor:n.upper,numItems:n.numItems}};return u(S(s.fn,m,s.shardKey))===e?a.slice(0,-1):a}),A.current?.(t)},q=Z(()=>new Map),L=p(y);d(()=>{const e=q.current;if(L.current!==y){for(const s of e.values())s();e.clear(),L.current=y}if(f){for(const s of e.values())s();e.clear();return}const r=v.current,t=X(y),a=new Set(r.entries.map(({key:s})=>u(s)));for(const[s,n]of e)a.has(s)||(n(),e.delete(s));for(const s of r.entries){const n=u(s.key);if(e.has(n))continue;const m=()=>{o.fetchQuery({gcTime:Number.POSITIVE_INFINITY,queryFn:async()=>{const c=t.openSnapshotSample(s.key),N=await y.query(r.fn,s.args,{shardKey:r.shardKey});return t.closeSnapshotSample(c)?N:o.getQueryData(s.key)??N},queryKey:s.key,staleTime:0}).catch(c=>{if(c instanceof G){t.hasConsumers(s.key)&&m();return}F(n,s.key,c instanceof Error?{code:c.code,message:c.message}:{message:String(c)})})};m();const h=t.attach(o,s.key,r.fn,s.args,r.shardKey,{onError:M=>{F(n,s.key,M)}}),I=s.key;e.set(n,()=>{h(),t.hasConsumers(I)||o.removeQueries({exact:!0,queryKey:I})})}},[y,o,D,f]),d(()=>()=>{for(const e of q.current.values())e();q.current.clear()},[]),d(()=>o.getQueryCache().subscribe(t=>{if(t.type!=="updated")return;const a=u(t.query.queryKey);b.some(({key:s})=>u(s)===a)&&(C(void 0),$())}),[o,D]);const w=f?[]:b.map(({key:e})=>o.getQueryData(e));d(()=>{if(f)return;const e=Y(P,w);e&&K(e)});const{status:H}=T(f,w),V=U(e=>{C(void 0),K(r=>{const t=v.current,a=r.map(h=>{const I={...t.baseArgs,paginationOpts:{cursor:h.lower,endCursor:h.upper,numItems:h.numItems}};return o.getQueryData(S(t.fn,I,t.shardKey))}),{nextCursor:s,status:n}=T(!1,a);return _(r,n==="CanLoadMore"?s:void 0,e)??r})},[o]);return{error:j,loadMore:V,pageResults:w,status:H}};export{oe as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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-
|
|
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-aorznd0I.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 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as N}from"react/compiler-runtime";import{useMutation as R}from"./useMutation-
|
|
2
|
+
import{c as N}from"react/compiler-runtime";import{useMutation as R}from"./useMutation-BN3iQJB8.mjs";import O from"./useSubscription-BYPfDHYS.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{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as Q,useRef as S}from"react";import{useMutation as u}from"./useMutation-
|
|
2
|
+
import{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as Q,useRef as S}from"react";import{useMutation as u}from"./useMutation-BN3iQJB8.mjs";import{useStream as V}from"./useStream-DUOoXrbS.mjs";import A from"./useSubscription-BYPfDHYS.mjs";const W={__lunoraRef:""},X={__lunoraRef:""},Z=[],it=E=>{const{api:a,cancel:m,limit:d,onError:l,send:_,sendArgs:k,stream:p,threadKey:e}=E,x=d===void 0?{key:e}:{key:e,limit:d},{data:w,error:O}=A(a.agents.agentMessages,x,{onError:l}),{data:T,error:b}=A(a.agents.agentThread,{key:e},{onError:l}),I=p===void 0?"skip":{key:e},{chunks:j}=V(p??X,I),q=u(_),C=u(m??W),D=u(a.agents.agentResolveApproval),[K,c]=Q([]),f=S(0),h=S(e);h.current!==e&&(h.current=e,c([]));const g=T,N=g?.status,o=g?.instanceId,s=w??Z,v=M(K,s),F=R(s),G=v.length===0?s:[...s,...v.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:F+1+n}))],P=s.filter(t=>t.role==="assistant").length,U=j.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=P).map(t=>t.text).join(""),{mutate:Y}=q,{mutate:$}=C,{mutate:z}=D,B=async(t,n)=>{const r=f.current;f.current+=1;const H=R(s);c(i=>[...M(i,s),{content:t,id:r,maxDurableSeqAtSend:H}]);try{await Y({input:t,threadKey:e,...k,...n})}catch(i){throw c(J=>J.filter(L=>L.id!==r)),i}},y=async(t,n,r)=>{if(o===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await z({decision:t,instanceId:o,threadKey:e,toolCallId:n,...r===void 0?{}:{note:r}})};return{approve:(t,n)=>y("approve",t,n),cancel:async()=>{m===void 0||o===void 0||await $({instanceId:o,threadKey:e})},error:O??b,messages:G,reject:(t,n)=>y("reject",t,n),send:B,status:N,streamingText:U}};export{it as useAgentChat};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as o}from"react/compiler-runtime";import d from"./useSubscription-
|
|
2
|
+
import{c as o}from"react/compiler-runtime";import d from"./useSubscription-BYPfDHYS.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};
|
package/dist/packem_shared/{useAgentToolEvents-9XJIaMJp.mjs → useAgentToolEvents-BfGsPL2O.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as y}from"react/compiler-runtime";import{useStream as I}from"./useStream-
|
|
2
|
+
import{c as y}from"react/compiler-runtime";import{useStream as I}from"./useStream-DUOoXrbS.mjs";import N from"./useSubscription-BYPfDHYS.mjs";const E={__lunoraRef:""},_=[],k=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(t=>({input:t.input,seq:o.seq,toolCallId:t.id,toolName:t.name,type:"call"}));if(o.role==="tool")return o.status==="awaiting_approval"?[{seq:o.seq,type:"awaiting-approval",...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]:[{output:o.content,seq:o.seq,type:"result",...o.status==="approved"||o.status==="rejected"?{status:o.status}:{},...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]},A=o=>{const t=y(12),{api:c,limit:r,stream:n,threadKey:l}=o;let a;t[0]!==r||t[1]!==l?(a=r===void 0?{key:l}:{key:l,limit:r},t[0]=r,t[1]=l,t[2]=a):a=t[2];const f=a,{data:v}=N(c.agents.agentMessages,f);let i;t[3]!==n||t[4]!==l?(i=n===void 0?"skip":{key:l},t[3]=n,t[4]=l,t[5]=i):i=t[5];const C=i,{chunks:p}=I(n??E,C),s=v??_;let e;if(t[6]!==p||t[7]!==s||t[8]!==l){e=s.flatMap(q);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]=s,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 q(o){return k(o)??[]}export{A 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-
|
|
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-aorznd0I.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as y}from"react/compiler-runtime";import{useMutation as z,useQuery as _,keepPreviousData as b}from"@tanstack/react-query";import{useState as U,useSyncExternalStore as D}from"react";import{u as A}from"./lunora-provider-
|
|
2
|
+
import{c as y}from"react/compiler-runtime";import{useMutation as z,useQuery as _,keepPreviousData as b}from"@tanstack/react-query";import{useState as U,useSyncExternalStore as D}from"react";import{u as A}from"./lunora-provider-aorznd0I.mjs";const E="lunora-react-admin-auth",F=50;function S(t,e,o,u={}){const{enabled:r=!0,pageSize:c=F}=u,[i,s]=U(c),l=D(m=>{const v=t.onAuthTokenChange(m),I=t.onIdentityChange(m);return()=>{v(),I()}},()=>t.currentIdentity(),()=>t.currentIdentity()),n=[E,l??"anon",...e,i],a=_({enabled:r,placeholderData:(m,v)=>v?.queryKey[1]===n[1]?b(m):void 0,queryFn:()=>o(i),queryKey:n,staleTime:0}),d=a.data?.rows,f=a.data?.total,p=f!==void 0&&d!==void 0&&d.length<f,h=()=>{p&&s(m=>m+c)},g=()=>{a.refetch().catch(()=>{})};return{data:d,error:a.error??void 0,hasMore:p,loadMore:h,loading:a.isLoading,refetch:g,total:f}}const q=t=>{const e=y(20);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=A(),{enabled:c,filterField:i,filterValue:s,pageSize:l,search:n,searchField:a,sortBy:d,sortDirection:f}=u;let p;e[2]!==i||e[3]!==s||e[4]!==n||e[5]!==a||e[6]!==d||e[7]!==f?(p=["users",{filterField:i,filterValue:s,search:n,searchField:a,sortBy:d,sortDirection:f}],e[2]=i,e[3]=s,e[4]=n,e[5]=a,e[6]=d,e[7]=f,e[8]=p):p=e[8];let h;e[9]!==r||e[10]!==i||e[11]!==s||e[12]!==n||e[13]!==a||e[14]!==d||e[15]!==f?(h=m=>r.listAuthUsers({filterField:i,filterValue:s,limit:m,search:n,searchField:a,sortBy:d,sortDirection:f}),e[9]=r,e[10]=i,e[11]=s,e[12]=n,e[13]=a,e[14]=d,e[15]=f,e[16]=h):h=e[16];let g;return e[17]!==c||e[18]!==l?(g={enabled:c,pageSize:l},e[17]=c,e[18]=l,e[19]=g):g=e[19],S(r,p,h,g)},M=t=>{const e=y(8);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=A(),{enabled:c,pageSize:i}=u;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=["organizations"],e[2]=s):s=e[2];let l;e[3]!==r?(l=a=>r.listAuthOrganizations({limit:a}),e[3]=r,e[4]=l):l=e[4];let n;return e[5]!==c||e[6]!==i?(n={enabled:c,pageSize:i},e[5]=c,e[6]=i,e[7]=n):n=e[7],S(r,s,l,n)},k=t=>{const e=y(8);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=A(),{enabled:c,pageSize:i}=u;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=["sign-up-invitations"],e[2]=s):s=e[2];let l;e[3]!==r?(l=a=>r.listAuthSignUpInvitations({limit:a}),e[3]=r,e[4]=l):l=e[4];let n;return e[5]!==c||e[6]!==i?(n={enabled:c,pageSize:i},e[5]=c,e[6]=i,e[7]=n):n=e[7],S(r,s,l,n)},K=t=>{const e=y(10);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=A(),{enabled:c,pageSize:i,userId:s}=u;let l;e[2]!==s?(l=["sessions",{userId:s}],e[2]=s,e[3]=l):l=e[3];let n;e[4]!==r||e[5]!==s?(n=d=>r.listAuthSessions({limit:d,userId:s}),e[4]=r,e[5]=s,e[6]=n):n=e[6];let a;return e[7]!==c||e[8]!==i?(a={enabled:c,pageSize:i},e[7]=c,e[8]=i,e[9]=a):a=e[9],S(r,l,n,a)},w=()=>{const t=y(10),e=A();let o;t[0]!==e?(o={mutationFn:a=>e.impersonateAuthUser({userId:a})},t[0]=e,t[1]=o):o=t[1];const u=z(o),{mutateAsync:r,reset:c}=u;let i;t[2]!==r?(i=a=>r(a),t[2]=r,t[3]=i):i=t[3];const s=i,l=u.error??void 0;let n;return t[4]!==s||t[5]!==u.data||t[6]!==u.isPending||t[7]!==c||t[8]!==l?(n={data:u.data,error:l,impersonate:s,pending:u.isPending,reset:c},t[4]=s,t[5]=u.data,t[6]=u.isPending,t[7]=c,t[8]=l,t[9]=n):n=t[9],n};export{K as useAuthSessions,q as useAuthUsers,w as useImpersonate,M as useOrganizations,k 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-
|
|
2
|
+
import{c as u}from"react/compiler-runtime";import{isAuthenticatedStatus as r,isLoadingStatus as a}from"@lunora/client/auth";import n from"./useAuth-BfihbPPf.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-
|
|
2
|
+
import{useCallback as u,useSyncExternalStore as l}from"react";import{u as c}from"./lunora-provider-aorznd0I.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};
|
package/dist/packem_shared/{useConnectionStatus-nYMTxult.mjs → useConnectionStatus-CHMUg2j8.mjs}
RENAMED
|
@@ -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-
|
|
2
|
+
import{c as r}from"react/compiler-runtime";import{useSyncExternalStore as u}from"react";import{u as a}from"./lunora-provider-aorznd0I.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-
|
|
2
|
+
import{useState as _,useRef as i,useEffect as b}from"react";import{u as d}from"./lunora-provider-aorznd0I.mjs";import{b as K}from"./query-key-QcTqsWNc.mjs";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-
|
|
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-aorznd0I.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{s as H}from"./query-key-QcTqsWNc.mjs";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-
|
|
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-Dytoa06S.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{useMutation as y,onlineManager as p}from"@tanstack/react-query";import{useRef as O,useState as h,useCallback as l}from"react";import{u as k}from"./lunora-provider-
|
|
2
|
+
import{useMutation as y,onlineManager as p}from"@tanstack/react-query";import{useRef as O,useState as h,useCallback as l}from"react";import{u as k}from"./lunora-provider-aorznd0I.mjs";const C=async()=>new Promise(r=>{if(p.isOnline()){r();return}const s=p.subscribe(t=>{t&&(s(),r())})}),U=r=>{const s=k(),t=O(0),[u,d]=h(!1),M=y({mutationFn:async({args:n,options:e})=>(s.canQueueOffline(e?.shardKey)||await C(),s.mutation(r,n,e)),networkMode:"always",retry:0,onMutate:()=>{t.current+=1,d(!0)},onSettled:()=>{t.current-=1,d(t.current>0)}}),{data:a,error:i,isError:c,mutateAsync:o,reset:m}=M,b=l((n,e)=>o({args:n,options:e}),[o]),f=l(n=>({data:a,error:i,isError:c,mutate:(g,w)=>o({args:g,options:{optimisticUpdate:n,...w}}),pending:u,reset:m,withOptimisticUpdate:f}),[o,a,i,c,u,m]);return{data:a,error:i,isError:c,mutate:b,pending:u,reset:m,withOptimisticUpdate:f}};export{U as useMutation};
|
package/dist/packem_shared/{usePaginatedQuery-BuGyCMrx.mjs → usePaginatedQuery-zcNSY-31.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c}from"react/compiler-runtime";import{u as f}from"./use-paginated-core-
|
|
2
|
+
import{c}from"react/compiler-runtime";import{u as f}from"./use-paginated-core-Dytoa06S.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 L,useState as _,useRef as p,useEffect as f,useCallback as g}from"react";import{u as D}from"./lunora-provider-
|
|
2
|
+
import{useMemo as L,useState as _,useRef as p,useEffect as f,useCallback as g}from"react";import{u as D}from"./lunora-provider-aorznd0I.mjs";const V=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const t=crypto.getRandomValues(new Uint8Array(16));return Array.from(t,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")},A=1e4,w=(t,r)=>{const e=D(),{heartbeat:v,intervalMs:I=A,listPresent:l,shardKey:s}=r,o=L(()=>r.sessionId??V(),[r.sessionId]),d=JSON.stringify([l.__lunoraRef,t,s??""]),[y,m]=_(),h=y?.client===e&&y.key===d?y:void 0,S=p(r.onError);f(()=>{S.current=r.onError});const b=p(r.data),R=p({client:e,heartbeat:v,roomId:t,sessionId:o,shardKey:s});f(()=>{R.current={client:e,heartbeat:v,roomId:t,sessionId:o,shardKey:s}});const i=g(()=>{const{client:n,heartbeat:a,roomId:c,sessionId:u,shardKey:U}=R.current,k={roomId:c,sessionId:u,...b.current===void 0?{}:{data:b.current}};n.mutation(a,k,{shardKey:U}).catch(()=>{})},[]),E=g(n=>{b.current=n,i()},[i]);return f(()=>{i();const n=setInterval(i,I),a=()=>{typeof document<"u"&&document.visibilityState==="visible"&&i()};return typeof document<"u"&&document.addEventListener("visibilitychange",a),()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",a)}},[i,I,e,t,o,s]),f(()=>e.acquireConnectionContext({roomId:t,sessionId:o},{shardKey:s}),[e,t,o,s]),f(()=>{let n=!1;const a=e.subscribe(l,{roomId:t},c=>{n||m({client:e,error:void 0,key:d,present:c})},{onError:c=>{n||m(u=>({client:e,error:c,key:d,present:u?.client===e&&u.key===d?u.present:void 0})),S.current?.(c)},shardKey:s});return()=>{n=!0,a(),m(void 0)}},[e,l.__lunoraRef,t,d,s]),{error:h?.error,present:h?.present,sessionId:o,setData:E}};export{w as usePresence};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{useQueryClient as E,useQuery as b}from"@tanstack/react-query";import{useRef as I,useEffect as c,useCallback as k,useState as q}from"react";import{u as K,g as f}from"./lunora-provider-
|
|
2
|
+
import{useQueryClient as E,useQuery as b}from"@tanstack/react-query";import{useRef as I,useEffect as c,useCallback as k,useState as q}from"react";import{u as K,g as f}from"./lunora-provider-aorznd0I.mjs";import{l as C,a as D}from"./query-key-QcTqsWNc.mjs";const F=(a,i,h={})=>{const e=K(),u=E(),{onError:l,shardKey:o}=h,d=I(l);c(()=>{d.current=l});const p=k(s=>{d.current?.(s)},[]),r=i==="skip",n=r?{}:i,t=C(a,n,o),[y,Q]=q(e.isReady);c(()=>{y||e.whenReady().then(()=>{Q(!0)})},[e,y]);const g=r?void 0:e.peekHydratedQuery(a.__lunoraRef,n,o),{data:R}=b({enabled:!r&&y,initialData:g,queryFn:async()=>{const s=f(e),S=s.openSnapshotSample(t),m=await e.query(a,n,{shardKey:o});return s.closeSnapshotSample(S)?m:u.getQueryData(t)??m},queryKey:t,staleTime:Number.POSITIVE_INFINITY});return c(()=>r?()=>{}:f(e).attach(u,t,a,n,o,{onError:p}),[e,u,D(t),r,p]),r?void 0:R};export{F 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-
|
|
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-aorznd0I.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{s as E}from"./query-key-QcTqsWNc.mjs";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 L}from"react/compiler-runtime";import{createQuerySubscription as M}from"@lunora/client/query";import{LunoraError as O}from"@lunora/errors";import{useState as j,useRef as R,useEffect as K}from"react";import{u as q}from"./lunora-provider-
|
|
2
|
+
import{c as L}from"react/compiler-runtime";import{createQuerySubscription as M}from"@lunora/client/query";import{LunoraError as O}from"@lunora/errors";import{useState as j,useRef as R,useEffect as K}from"react";import{u as q}from"./lunora-provider-aorznd0I.mjs";import{s as x}from"./query-key-QcTqsWNc.mjs";const A=Object.freeze({data:void 0,error:void 0}),W=(t,s,b)=>{const e=L(20),r=b===void 0?{}:b,o=q(),i=s==="skip",c=i?"skip":x(s),n=JSON.stringify([t.__lunoraRef,c,r.shardKey??""]),[p,y]=j(void 0),h=R(r.onError);let u;e[0]!==r.onError?(u=()=>{h.current=r.onError},e[0]=r.onError,e[1]=u):u=e[1],K(u);let l;e[2]!==s||e[3]!==t?(l={args:s,fn:t},e[2]=s,e[3]=t,e[4]=l):l=e[4];const v=R(l);let d;e[5]!==s||e[6]!==t?(d=()=>{v.current={args:s,fn:t}},e[5]=s,e[6]=t,e[7]=d):d=e[7],K(d);let f;e[8]!==o||e[9]!==n||e[10]!==r.shardKey||e[11]!==i?(f=()=>{if(i)return D;let E=!1;const{args:k,fn:S}=v.current,z=M(o,S,k,{onData:a=>{E||y({client:o,key:n,result:{data:a,error:void 0}})},onError:a=>{const w=a.code===void 0?new Error(a.message):new O(a.code,a.message);h.current?.(a),queueMicrotask(()=>{E||y({client:o,key:n,result:{data:void 0,error:w}})})}},{shardKey:r.shardKey});return()=>{E=!0,z(),y(void 0)}},e[8]=o,e[9]=n,e[10]=r.shardKey,e[11]=i,e[12]=f):f=e[12];let m;return e[13]!==o||e[14]!==t.__lunoraRef||e[15]!==n||e[16]!==r.shardKey||e[17]!==c||e[18]!==i?(m=[o,t.__lunoraRef,n,c,r.shardKey,i],e[13]=o,e[14]=t.__lunoraRef,e[15]=n,e[16]=r.shardKey,e[17]=c,e[18]=i,e[19]=m):m=e[19],K(f,m),p?.client===o&&p.key===n?p.result:A};function D(){}export{W 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-
|
|
2
|
+
import{useState as T,useRef as W,useCallback as y,useEffect as G}from"react";import{u as X}from"./lunora-provider-aorznd0I.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),o=r.endsWith("/")?r.slice(0,-1):r,i=new URLSearchParams({threadKey:e.threadKey});return`${o}${j}${encodeURIComponent(e.agent)}?${i.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,o)=>{const i=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==i&&o(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 o of e)r+=o*o;return Math.sqrt(r/e.length)},oe=(e,r)=>{const o=r/ne,i=o>1?Math.floor(e.length/o):e.length,d=new ArrayBuffer(i*2),l=new DataView(d);for(let u=0;u<i;u+=1){const g=e[Math.floor(u*o)]??0,p=Math.max(-1,Math.min(1,g));l.setInt16(u*2,p<0?p*32768:p*32767,!0)}return new Uint8Array(d)},se=async e=>{const r=globalThis,o=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),i=r.AudioContext??r.webkitAudioContext;if(!o||!i)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await o({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new i,u=l.createMediaStreamSource(d),g=l.createScriptProcessor(4096,1,1);let p=!1,w=!1,a=0,h=0;return g.onaudioprocess=s=>{const f=s.inputBuffer.getChannelData(0),m=p?0:re(f);if(e.onLevel(m),p)return;if(e.onAudio(oe(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:s=>{p=s},stop:()=>{g.disconnect(),u.disconnect();for(const s of d.getTracks())s.stop();l.close()}}},ce=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const o=new r,i=new Set;let d=0,l=Promise.resolve(),u=0;const g=async(a,h)=>{if(h!==u)return;let s;try{s=await o.decodeAudioData(a.buffer)}catch{return}if(h!==u)return;const f=o.createBufferSource();f.buffer=s,f.connect(o.destination);const m=Math.max(o.currentTime,d);f.start(m),d=m+s.duration,i.add(f),f.onended=()=>{i.delete(f)}},p=a=>{const h=Uint8Array.from(a),s=u;l=l.then(()=>g(h,s))},w=()=>{u+=1;for(const a of i)try{a.stop()}catch{}i.clear(),d=o.currentTime};return{enqueue:p,interrupt:w,stop:()=>{w(),o.close()}}},P=1,ie=.01,ae=1200,ue=.15,le=3,he=e=>{const{createMicrophone:r=se,createSpeaker:o=ce,createSocket:i,interruptChunks:d=le,interruptThreshold:l=ue,silenceDurationMs:u=ae,silenceThreshold:g=ie,threadKey:p,voice:w}=e,a=X(),[h,s]=T("idle"),[f,m]=T(!1),[x,M]=T(""),[H,b]=T(""),[$,R]=T(0),[I,U]=T(!1),[B,E]=T(void 0),c=W(void 0),_=W(!1),v=y(t=>{const n=c.current?.socket;return n?.readyState===P?(n.send(JSON.stringify(t)),!0):!1},[]),A=y(()=>{const t=c.current;if(c.current=void 0,t){t.unwatchIdentity?.(),t.microphone?.stop(),t.speaker?.stop(),t.socket.onmessage=null,t.socket.onerror=null,t.socket.onclose=null;try{t.socket.close()}catch{}}_.current=!1,m(!1),s("idle"),R(0)},[]),L=y(t=>{const n=c.current;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),s("speaking"),b(F=>F+t.text);break}case"assistant_done":{n&&(n.awaitingTurn=!1,n.speaking=!1),b(t.text),s("listening");break}case"error":{n&&(n.awaitingTurn=!1,n.speaking=!1),E(new Error(t.message)),s("listening");break}case"interrupted":{n&&(n.awaitingTurn=!1,n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),s("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),m(!0),s("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),M(t.text),b(""),s("thinking");break}}},[]),D=y(t=>{const n=c.current;!n||n.suppressAudio||(n.speaker??=o({audioFormat:n.audioFormat}),n.speaking=!0,s("speaking"),n.speaker.enqueue(t))},[o]),q=y(async()=>{if(c.current||_.current)return;_.current=!0,E(void 0),M(""),b("");let t;try{const n=Z({agent:Q(w.__lunoraRef),httpUrl:a.url,threadKey:p,wsUrl:a.wsUrl}),S=(i??(k=>{const C=a.getWebSocketImpl();if(!C)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new C(k)}))(n);S.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:S,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},c.current=t,t.unwatchIdentity=te(a,"useVoiceAgent",k=>{c.current===t&&(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(c.current!==t)return;const C=ee("useVoiceAgent",k);C&&E(C),A()};const V=await r({interruptChunks:d,interruptThreshold:l,isTurnActive:()=>(c.current?.speaking??!1)||(c.current?.awaitingTurn??!1),onAudio:k=>{S.readyState===P&&S.send(k)},onInterrupt:()=>{v({type:"interrupt"}),c.current?.speaker?.interrupt(),c.current&&(c.current.awaitingTurn=!1,c.current.speaking=!1,c.current.suppressAudio=!0),s("listening")},onLevel:R,onSilence:()=>{v({type:"commit"}),c.current&&(c.current.awaitingTurn=!0),s("thinking")},silenceDurationMs:u,silenceThreshold:g});c.current===t?(t.microphone=V,U(!1),t.speaking||s("listening")):V.stop()}catch(n){c.current===t&&(E(n instanceof Error?n:new Error(String(n))),A())}finally{_.current=!1}},[a,r,i,D,L,d,l,v,u,g,A,p,w]),K=y(()=>{const t=!I;return c.current?.microphone?.setMuted(t),U(t),t},[I]),J=y(t=>{v({text:t,type:"text"})&&(c.current&&(c.current.awaitingTurn=!0),s("thinking"))},[v]);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.
|
|
3
|
+
"version": "1.0.0-alpha.164",
|
|
4
4
|
"description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@lunora/client": "1.0.0-alpha.
|
|
61
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
62
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
60
|
+
"@lunora/client": "1.0.0-alpha.157",
|
|
61
|
+
"@lunora/errors": "1.0.0-alpha.46",
|
|
62
|
+
"@lunora/ratelimit": "1.0.0-alpha.90",
|
|
63
63
|
"@visulima/storage-client": "1.0.3"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{L as a,u}from"./lunora-provider-eFDwhoSo.mjs";export{a as LunoraProvider,u as useLunora};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as w}from"react/compiler-runtime";import{LunoraError as L}from"@lunora/errors";import{QueryClientContext as E,QueryClientProvider as O,QueryClient as x}from"@tanstack/react-query";import{use as v,useState as N,useEffect as b,useRef as T,createContext as W}from"react";import{k as g}from"./query-key-QcTqsWNc.mjs";import{jsx as k}from"react/jsx-runtime";const I=n=>{n!==void 0&&(n.cancel({silent:!0}),n.setState({...n.state,data:void 0,dataUpdatedAt:0,error:null,fetchStatus:"idle",status:"pending"}))};class F{constructor(e){this.client=e}client;entries=new Map;pushes=new Map;samples=new Map;epoch=0;identityWatched=new Set;listening=!1;keyOf(e){return g(e)}hasConsumers(e){return this.entries.has(g(e))}openSnapshotSample(e){const s=g(e);return this.samples.set(s,(this.samples.get(s)??0)+1),{key:s,pushes:this.pushes.get(s)??0}}closeSnapshotSample(e){const s=(this.samples.get(e.key)??1)-1,t=(this.pushes.get(e.key)??0)===e.pushes;return s>0?(this.samples.set(e.key,s),t):(this.samples.delete(e.key),this.entries.has(e.key)||this.pushes.delete(e.key),t)}clearOnIdentityChange(e){this.listenForIdentityChange(),this.identityWatched.add(e)}stopClearingOnIdentityChange(e){this.identityWatched.delete(e)}identityEpoch=()=>this.epoch;subscribeIdentityEpoch=e=>(this.listenForIdentityChange(),this.client.onIdentityChange(e));listenForIdentityChange(){this.listening||(this.listening=!0,this.client.onIdentityChange(()=>{this.epoch+=1;for(const e of this.identityWatched)this.clearQueries(e)}))}clearQueries(e){const s=e.getQueryCache();for(const t of s.findAll({queryKey:["lunora"]}))I(t),t.getObserversCount()===0&&!this.hasConsumers(t.queryKey)&&s.remove(t)}attach(e,s,t,h,c,d={}){const a=g(s);let r=this.entries.get(a);if(!r){r={errorCallbacks:new Set,refCount:0,unsubscribe:void 0},this.entries.set(a,r);const i=r;try{r.unsubscribe=this.client.subscribe(t,h,o=>{if(this.pushes.set(a,(this.pushes.get(a)??0)+1),o===void 0){I(e.getQueryCache().find({exact:!0,queryKey:s}));return}e.setQueryData(s,o)},{onError:o=>{for(const f of i.errorCallbacks)f(o)},shardKey:c})}catch(o){throw this.entries.delete(a),o}}r.refCount+=1;const{onError:u}=d;u&&r.errorCallbacks.add(u);let l=!1;return()=>{if(l)return;l=!0;const i=this.entries.get(a);i&&(i.refCount-=1,u&&i.errorCallbacks.delete(u),i.refCount<=0&&(i.unsubscribe?.(),this.entries.delete(a)))}}}const Q=new WeakMap,m=n=>{let e=Q.get(n);return e||(e=new F(n),Q.set(n,e)),e},S=W(null),M=()=>new x({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),B=n=>{const e=w(17),{children:s,client:t,queryClient:h}=n,c=v(E);let d;e[0]!==c||e[1]!==h?(d=()=>h??c??M(),e[0]=c,e[1]=h,e[2]=d):d=e[2];const[a]=N(d),r=h??c??a;let u,l;e[3]!==t||e[4]!==r?(u=()=>{m(t).clearOnIdentityChange(r)},l=[t,r],e[3]=t,e[4]=r,e[5]=u,e[6]=l):(u=e[5],l=e[6]),b(u,l);const i=T(t);let o,f;e[7]!==t||e[8]!==r?(o=()=>{i.current!==t&&(m(i.current).stopClearingOnIdentityChange(r),i.current=t,m(t).clearQueries(r),r.invalidateQueries({queryKey:["lunora"]}))},f=[t,r],e[7]=t,e[8]=r,e[9]=o,e[10]=f):(o=e[9],f=e[10]),b(o,f);let y;e[11]!==s||e[12]!==t?(y=k(S,{value:t,children:s}),e[11]=s,e[12]=t,e[13]=y):y=e[13];const p=y;if(c===r)return p;let C;return e[14]!==p||e[15]!==r?(C=k(O,{client:r,children:p}),e[14]=p,e[15]=r,e[16]=C):C=e[16],C},H=()=>{const n=v(S);if(!n)throw new L("INTERNAL","useLunora must be used inside <LunoraProvider />");return n};export{B as L,m as g,H as u};
|