@lunora/react 1.0.0-alpha.50 → 1.0.0-alpha.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{useAgentChat-CJpe5Mg9.mjs → useAgentChat-BoY3nZvn.mjs} +1 -1
- package/dist/packem_shared/{useAgentToolEvents-oXtLad4O.mjs → useAgentToolEvents-D24tT5t_.mjs} +1 -1
- package/dist/packem_shared/useStream-AQlldZGN.mjs +2 -0
- package/package.json +4 -4
- package/dist/packem_shared/useStream-B1USJrJG.mjs +0 -2
package/dist/index.d.mts
CHANGED
|
@@ -1103,6 +1103,13 @@ interface UseStreamResult<T> {
|
|
|
1103
1103
|
status: UseStreamStatus;
|
|
1104
1104
|
}
|
|
1105
1105
|
interface UseStreamOptions {
|
|
1106
|
+
/**
|
|
1107
|
+
* Opt into resume-on-reconnect for a stream the server declared `durable`.
|
|
1108
|
+
* The hook keeps the chunks it already has and the socket re-attaches to the
|
|
1109
|
+
* same run, so a dropped connection mid-generation continues instead of
|
|
1110
|
+
* surfacing `STREAM_DISCONNECTED`. Has no effect on an ephemeral stream.
|
|
1111
|
+
*/
|
|
1112
|
+
durable?: boolean;
|
|
1106
1113
|
/** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
|
|
1107
1114
|
maxBuffer?: number;
|
|
1108
1115
|
shardKey?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1103,6 +1103,13 @@ interface UseStreamResult<T> {
|
|
|
1103
1103
|
status: UseStreamStatus;
|
|
1104
1104
|
}
|
|
1105
1105
|
interface UseStreamOptions {
|
|
1106
|
+
/**
|
|
1107
|
+
* Opt into resume-on-reconnect for a stream the server declared `durable`.
|
|
1108
|
+
* The hook keeps the chunks it already has and the socket re-attaches to the
|
|
1109
|
+
* same run, so a dropped connection mid-generation continues instead of
|
|
1110
|
+
* surfacing `STREAM_DISCONNECTED`. Has no effect on an ephemeral stream.
|
|
1111
|
+
*/
|
|
1112
|
+
durable?: boolean;
|
|
1106
1113
|
/** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
|
|
1107
1114
|
maxBuffer?: number;
|
|
1108
1115
|
shardKey?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{AuthLoading as t,Authenticated as o,Unauthenticated as u}from"./packem_shared/AuthLoading-C5eyDVbk.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-DrW2_avK.mjs";import{LunoraProvider as f,useLunora as n}from"./packem_shared/LunoraProvider-D6ZS72le.mjs";import{CheckoutButton as i,CustomerPortalButton as d,useCheckout as x}from"./packem_shared/CheckoutButton-DS_DKgNf.mjs";import{lunoraQueryOptions as h}from"./packem_shared/lunoraQueryOptions-DWEJoNnh.mjs";import{useAuthSessions as A,useAuthUsers as c,useImpersonate as C,useOrganizations as U}from"./packem_shared/useAuthSessions-DCiiklg1.mjs";import{useAgent as E}from"./packem_shared/useAgent-0Ozf4MwG.mjs";import{useAgentChat as Q}from"./packem_shared/useAgentChat-
|
|
2
|
+
import{AuthLoading as t,Authenticated as o,Unauthenticated as u}from"./packem_shared/AuthLoading-C5eyDVbk.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-DrW2_avK.mjs";import{LunoraProvider as f,useLunora as n}from"./packem_shared/LunoraProvider-D6ZS72le.mjs";import{CheckoutButton as i,CustomerPortalButton as d,useCheckout as x}from"./packem_shared/CheckoutButton-DS_DKgNf.mjs";import{lunoraQueryOptions as h}from"./packem_shared/lunoraQueryOptions-DWEJoNnh.mjs";import{useAuthSessions as A,useAuthUsers as c,useImpersonate as C,useOrganizations as U}from"./packem_shared/useAuthSessions-DCiiklg1.mjs";import{useAgent as E}from"./packem_shared/useAgent-0Ozf4MwG.mjs";import{useAgentChat as Q}from"./packem_shared/useAgentChat-BoY3nZvn.mjs";import{useAgentState as L}from"./packem_shared/useAgentState-CyY_I9m2.mjs";import{useAgentToolEvents as F}from"./packem_shared/useAgentToolEvents-D24tT5t_.mjs";import{default as k}from"./packem_shared/useAuth-BKsFAcDG.mjs";import{default as b}from"./packem_shared/useClientQuery-DFKZurlC.mjs";import{default as z}from"./packem_shared/useConnectionStatus-CiMP3Mmy.mjs";import{useFlag as O,useFlags as T}from"./packem_shared/useFlag-Bj6cjeim.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-6Mx4bTfB.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-CgT2zfA-.mjs";import{useMutation as D}from"./packem_shared/useMutation-C_8Nu0F4.mjs";import{useMutator as J}from"./packem_shared/useMutator-D3CGrk5-.mjs";import{usePaginatedQuery as N}from"./packem_shared/usePaginatedQuery-CSs8g5Z7.mjs";import{hydratePreloaded as X,default as Y}from"./packem_shared/hydratePreloaded-BvPwhOFD.mjs";import{usePresence as _}from"./packem_shared/usePresence-Bfa9ESum.mjs";import{default as ee}from"./packem_shared/useQuery-CDk67eFh.mjs";import{useRateLimit as te}from"./packem_shared/useRateLimit-DqikMrX9.mjs";import{useStream as ue}from"./packem_shared/useStream-AQlldZGN.mjs";import{default as ae}from"./packem_shared/useSubscription-CoFTfvYX.mjs";import{useVoiceAgent as fe}from"./packem_shared/useVoiceAgent-CO0EiOoc.mjs";import{createClientQuery as me,getErrorCode as ie,getRetryAfterMs as de,isConflictError as xe,isForbiddenError as le,isRateLimitedError as he,isUnauthorizedError as ge}from"@lunora/client";import{RestrictionError as ce,UploadControl as Ce,UploadError as Ue}from"@visulima/storage-client";import{useChunkedRestUpload as Ee,useFileInput as Pe,useMultipartUpload as Qe,usePasteUpload as Se,useTusUpload as Le,useUpload as Re}from"@visulima/storage-client/react";export{t as AuthLoading,o as Authenticated,i as CheckoutButton,d as CustomerPortalButton,f as LunoraProvider,ce as RestrictionError,u as Unauthenticated,Ce as UploadControl,Ue as UploadError,me as createClientQuery,ie as getErrorCode,de as getRetryAfterMs,X as hydratePreloaded,xe as isConflictError,le as isForbiddenError,he as isRateLimitedError,ge as isUnauthorizedError,h as lunoraQueryOptions,E as useAgent,Q as useAgentChat,L as useAgentState,F as useAgentToolEvents,k as useAuth,A as useAuthSessions,a as useAuthState,c as useAuthUsers,x as useCheckout,Ee as useChunkedRestUpload,b as useClientQuery,z as useConnectionStatus,Pe as useFileInput,O as useFlag,T as useFlags,V as useHttpStream,C as useImpersonate,q as useInfiniteQuery,n as useLunora,Qe as useMultipartUpload,D as useMutation,J as useMutator,U as useOrganizations,N as usePaginatedQuery,Se as usePasteUpload,Y as usePreloadedQuery,_ as usePresence,ee as useQuery,te as useRateLimit,ue as useStream,ae as useSubscription,Le as useTusUpload,Re as useUpload,fe as useVoiceAgent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as rt}from"react/compiler-runtime";import{reconcileOptimistic as W,maxSeq as X}from"@lunora/client";import{useState as it,useRef as ct}from"react";import{useMutation as Q}from"./useMutation-C_8Nu0F4.mjs";import{useStream as lt}from"./useStream-
|
|
2
|
+
import{c as rt}from"react/compiler-runtime";import{reconcileOptimistic as W,maxSeq as X}from"@lunora/client";import{useState as it,useRef as ct}from"react";import{useMutation as Q}from"./useMutation-C_8Nu0F4.mjs";import{useStream as lt}from"./useStream-AQlldZGN.mjs";import Y from"./useSubscription-CoFTfvYX.mjs";const mt={__lunoraRef:""},ut={__lunoraRef:""},dt=[],St=c=>{const t=rt(47),{api:K,cancel:m,limit:u,send:Z,sendArgs:C,stream:d,threadKey:e}=c;let p;t[0]!==u||t[1]!==e?(p=u===void 0?{key:e}:{key:e,limit:u},t[0]=u,t[1]=e,t[2]=p):p=t[2];const B=p,{data:G}=Y(K.agents.agentMessages,B);let f;t[3]!==e?(f={key:e},t[3]=e,t[4]=f):f=t[4];const{data:H}=Y(K.agents.agentThread,f);let h;t[5]!==d||t[6]!==e?(h=d===void 0?"skip":{key:e},t[5]=d,t[6]=e,t[7]=h):h=t[7];const J=h,{chunks:R}=lt(d??ut,J),tt=Q(Z),et=Q(m??mt),nt=Q(K.agents.agentResolveApproval);let g;t[8]===Symbol.for("react.memo_cache_sentinel")?(g=[],t[8]=g):g=t[8];const[$,U]=it(g),j=ct(0),V=H,q=V?.status,o=V?.instanceId,s=G??dt;let y;if(t[9]!==s||t[10]!==$){const n=W($,s),a=X(s);y=n.length===0?s:[...s,...n.map((r,N)=>({content:r.content,optimistic:!0,role:"user",seq:a+1+N}))],t[9]=s,t[10]=$,t[11]=y}else y=t[11];const b=y;let v;t[12]!==s?(v=s.filter(pt),t[12]=s,t[13]=v):v=t[13];const l=v.length;let k;if(t[14]!==l||t[15]!==R||t[16]!==e){let n;t[18]!==l||t[19]!==e?(n=a=>a.kind!=="progress"&&a.threadKey===e&&a.turn>=l,t[18]=l,t[19]=e,t[20]=n):n=t[20],k=R.filter(n).map(ft).join(""),t[14]=l,t[15]=R,t[16]=e,t[17]=k}else k=t[17];const E=k,{mutate:M}=tt,{mutate:T}=et,{mutate:D}=nt;let w;t[21]!==s||t[22]!==C||t[23]!==M||t[24]!==e?(w=async(n,a)=>{const r=j.current;j.current=j.current+1;const N=X(s);U(P=>[...W(P,s),{content:n,id:r,maxDurableSeqAtSend:N}]);try{await M({input:n,threadKey:e,...C,...a})}catch(P){const st=P;throw U(at=>at.filter(ot=>ot.id!==r)),st}},t[21]=s,t[22]=C,t[23]=M,t[24]=e,t[25]=w):w=t[25];const O=w;let S;t[26]!==o||t[27]!==D||t[28]!==e?(S=async(n,a,r)=>{if(o===void 0)throw new Error(`useAgentChat: cannot ${n} — no in-flight run (thread has no instanceId)`);await D({decision:n,instanceId:o,threadKey:e,toolCallId:a,...r===void 0?{}:{note:r}})},t[26]=o,t[27]=D,t[28]=e,t[29]=S):S=t[29];const i=S;let _;t[30]!==i?(_=(n,a)=>i("approve",n,a),t[30]=i,t[31]=_):_=t[31];const z=_;let x;t[32]!==i?(x=(n,a)=>i("reject",n,a),t[32]=i,t[33]=x):x=t[33];const F=x;let A;t[34]!==T||t[35]!==m||t[36]!==o||t[37]!==e?(A=async()=>{m===void 0||o===void 0||await T({instanceId:o,threadKey:e})},t[34]=T,t[35]=m,t[36]=o,t[37]=e,t[38]=A):A=t[38];const L=A;let I;return t[39]!==z||t[40]!==L||t[41]!==b||t[42]!==F||t[43]!==O||t[44]!==q||t[45]!==E?(I={approve:z,cancel:L,messages:b,reject:F,send:O,status:q,streamingText:E},t[39]=z,t[40]=L,t[41]=b,t[42]=F,t[43]=O,t[44]=q,t[45]=E,t[46]=I):I=t[46],I};function pt(c){return c.role==="assistant"}function ft(c){return c.text}export{St as useAgentChat};
|
package/dist/packem_shared/{useAgentToolEvents-oXtLad4O.mjs → useAgentToolEvents-D24tT5t_.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as v}from"react/compiler-runtime";import{useStream as g}from"./useStream-
|
|
2
|
+
import{c as v}from"react/compiler-runtime";import{useStream as g}from"./useStream-AQlldZGN.mjs";import y from"./useSubscription-CoFTfvYX.mjs";const I={__lunoraRef:""},k=[],N=l=>{if(l.role==="assistant"&&l.toolCalls)return l.toolCalls.map(o=>({input:o.input,seq:l.seq,toolCallId:o.id,toolName:o.name,type:"call"}));if(l.role==="tool")return l.status==="awaiting_approval"?[{seq:l.seq,type:"awaiting-approval",...l.toolCallId===void 0?{}:{toolCallId:l.toolCallId},...l.toolName===void 0?{}:{toolName:l.toolName}}]:[{output:l.content,seq:l.seq,type:"result",...l.status==="approved"||l.status==="rejected"?{status:l.status}:{},...l.toolCallId===void 0?{}:{toolCallId:l.toolCallId},...l.toolName===void 0?{}:{toolName:l.toolName}}]},_=l=>{const o=v(12),{api:m,limit:a,stream:s,threadKey:t}=l;let r;o[0]!==a||o[1]!==t?(r=a===void 0?{key:t}:{key:t,limit:a},o[0]=a,o[1]=t,o[2]=r):r=o[2];const c=r,{data:f}=y(m.agents.agentMessages,c);let i;o[3]!==s||o[4]!==t?(i=s===void 0?"skip":{key:t},o[3]=s,o[4]=t,o[5]=i):i=o[5];const C=i,{chunks:p}=g(s??I,C),u=f??k;let e;if(o[6]!==p||o[7]!==u||o[8]!==t){e=u.flatMap(q);for(const d of p)d.kind==="progress"&&d.threadKey===t&&e.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});o[6]=p,o[7]=u,o[8]=t,o[9]=e}else e=o[9];let n;return o[10]!==e?(n={events:e},o[10]=e,o[11]=n):n=o[11],n};function q(l){return N(l)??[]}export{_ as useAgentToolEvents};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as k}from"react/compiler-runtime";import{useReducer as B,useRef as K,useEffect as R}from"react";import{useLunora as v}from"./LunoraProvider-D6ZS72le.mjs";import{o as S,u as E}from"./stream-state-ksURgmCA.mjs";import{t as L}from"./wire-key-BjAV3_Rq.mjs";const A=(a,u,n)=>{const e=k(27);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,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,l]=B(S,f),s=u==="skip";let m;e[3]!==u||e[4]!==s?(m=s?"skip":L(u),e[3]=u,e[4]=s,e[5]=m):m=e[5];const y=m,b=K(void 0);let d;e[6]!==u||e[7]!==o||e[8]!==a||e[9]!==r.durable||e[10]!==r.maxBuffer||e[11]!==r.shardKey||e[12]!==s?(d=()=>{if(s)return l({type:"reset"}),T;l({type:"reset"}),l({type:"start"});const{cancel:_,cleanup:x}=E(o.stream(a,u,{durable:r.durable,maxBuffer:r.maxBuffer,shardKey:r.shardKey}),l);return b.current=_,()=>{x(),b.current=void 0}},e[6]=u,e[7]=o,e[8]=a,e[9]=r.durable,e[10]=r.maxBuffer,e[11]=r.shardKey,e[12]=s,e[13]=d):d=e[13];let i;e[14]!==o||e[15]!==a.__lunoraRef||e[16]!==r.durable||e[17]!==r.maxBuffer||e[18]!==r.shardKey||e[19]!==y||e[20]!==s?(i=[o,a.__lunoraRef,y,s,r.shardKey,r.maxBuffer,r.durable],e[14]=o,e[15]=a.__lunoraRef,e[16]=r.durable,e[17]=r.maxBuffer,e[18]=r.shardKey,e[19]=y,e[20]=s,e[21]=i):i=e[21],R(d,i);let h;e[22]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{b.current?.()},e[22]=h):h=e[22];let p;return e[23]!==t.chunks||e[24]!==t.error||e[25]!==t.status?(p={cancel:h,chunks:t.chunks,error:t.error,status:t.status},e[23]=t.chunks,e[24]=t.error,e[25]=t.status,e[26]=p):p=e[26],p};function T(){}export{A as useStream};
|
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.52",
|
|
4
4
|
"description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@lunora/client": "1.0.0-alpha.
|
|
57
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
58
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
56
|
+
"@lunora/client": "1.0.0-alpha.48",
|
|
57
|
+
"@lunora/errors": "1.0.0-alpha.21",
|
|
58
|
+
"@lunora/ratelimit": "1.0.0-alpha.22",
|
|
59
59
|
"@visulima/storage-client": "1.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as B}from"react/compiler-runtime";import{useReducer as K,useRef as R,useEffect as v}from"react";import{useLunora as S}from"./LunoraProvider-D6ZS72le.mjs";import{o as b,u as E}from"./stream-state-ksURgmCA.mjs";import{t as L}from"./wire-key-BjAV3_Rq.mjs";const z=(u,o,f)=>{const e=B(25);let a;e[0]!==f?(a=f===void 0?{}:f,e[0]=f,e[1]=a):a=e[1];const r=a,c=S();let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m={chunks:[],error:void 0,status:"idle"},e[2]=m):m=e[2];const[t,n]=K(b,m),s=o==="skip";let l;e[3]!==o||e[4]!==s?(l=s?"skip":L(o),e[3]=o,e[4]=s,e[5]=l):l=e[5];const y=l,_=R(void 0);let i;e[6]!==o||e[7]!==c||e[8]!==u||e[9]!==r.maxBuffer||e[10]!==r.shardKey||e[11]!==s?(i=()=>{if(s)return n({type:"reset"}),T;n({type:"reset"}),n({type:"start"});const{cancel:x,cleanup:k}=E(c.stream(u,o,{maxBuffer:r.maxBuffer,shardKey:r.shardKey}),n);return _.current=x,()=>{k(),_.current=void 0}},e[6]=o,e[7]=c,e[8]=u,e[9]=r.maxBuffer,e[10]=r.shardKey,e[11]=s,e[12]=i):i=e[12];let h;e[13]!==c||e[14]!==u.__lunoraRef||e[15]!==r.maxBuffer||e[16]!==r.shardKey||e[17]!==y||e[18]!==s?(h=[c,u.__lunoraRef,y,s,r.shardKey,r.maxBuffer],e[13]=c,e[14]=u.__lunoraRef,e[15]=r.maxBuffer,e[16]=r.shardKey,e[17]=y,e[18]=s,e[19]=h):h=e[19],v(i,h);let d;e[20]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{_.current?.()},e[20]=d):d=e[20];let p;return e[21]!==t.chunks||e[22]!==t.error||e[23]!==t.status?(p={cancel:d,chunks:t.chunks,error:t.error,status:t.status},e[21]=t.chunks,e[22]=t.error,e[23]=t.status,e[24]=p):p=e[24],p};function T(){}export{z as useStream};
|