@lunora/vue 1.0.0-alpha.47 → 1.0.0-alpha.49
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 -19
- package/dist/packem_shared/AuthLoading-CST_mkXL.mjs +1 -0
- package/dist/packem_shared/LUNORA_INJECTION_KEY-CswQb5zb.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-D8EcBXmG.mjs +1 -0
- package/dist/packem_shared/stable-key-BSG0zK_E.mjs +1 -0
- package/dist/packem_shared/subscribeToQuery-CGvPMz37.mjs +1 -0
- package/dist/packem_shared/useAgent-DyWC-Sm8.mjs +1 -0
- package/dist/packem_shared/useAgentChat-ScvDvEFO.mjs +1 -0
- package/dist/packem_shared/useAgentState-CUHDV3h7.mjs +1 -0
- package/dist/packem_shared/useAgentToolEvents-DvcPNShc.mjs +1 -0
- package/dist/packem_shared/useAuth-DwDFjvto.mjs +1 -0
- package/dist/packem_shared/useConnectionStatus-BwLyL_L_.mjs +1 -0
- package/dist/packem_shared/useFlag-Bxoq8mH9.mjs +1 -0
- package/dist/packem_shared/useInfiniteQuery-Czncoie-.mjs +1 -0
- package/dist/packem_shared/useMutation-MdgW9pRE.mjs +1 -0
- package/dist/packem_shared/useMutator-DRVDOhcj.mjs +1 -0
- package/dist/packem_shared/usePresence-AiurcGAB.mjs +1 -0
- package/dist/packem_shared/useRateLimit-z8EUFuYJ.mjs +1 -0
- package/dist/packem_shared/useStream-CYkKEcDf.mjs +1 -0
- package/dist/packem_shared/useSubscription-D4Ap-tJr.mjs +1 -0
- package/dist/packem_shared/useVoiceAgent-Ba0SIP06.mjs +1 -0
- package/dist/server.mjs +1 -1
- package/dist/upload.mjs +1 -2
- package/dist/worker.mjs +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/AuthLoading-DKra8yfG.mjs +0 -29
- package/dist/packem_shared/LUNORA_INJECTION_KEY-DQM5MgsC.mjs +0 -26
- package/dist/packem_shared/hydratePreloaded-Cnd2GmG1.mjs +0 -14
- package/dist/packem_shared/stable-key-C8JHuJL7.mjs +0 -40
- package/dist/packem_shared/subscribeToQuery-hVYyvgOD.mjs +0 -51
- package/dist/packem_shared/useAgent-TEp9OWs3.mjs +0 -28
- package/dist/packem_shared/useAgentChat-DQmekE-E.mjs +0 -108
- package/dist/packem_shared/useAgentState-CeDpLTib.mjs +0 -12
- package/dist/packem_shared/useAgentToolEvents-DfCy9INR.mjs +0 -62
- package/dist/packem_shared/useAuth-yXaaF-ro.mjs +0 -28
- package/dist/packem_shared/useConnectionStatus-DM_TOaW5.mjs +0 -20
- package/dist/packem_shared/useFlag-B8Gq7oUu.mjs +0 -70
- package/dist/packem_shared/useInfiniteQuery-CMAUPQyd.mjs +0 -309
- package/dist/packem_shared/useMutation-BKIwT8Jk.mjs +0 -29
- package/dist/packem_shared/useMutator-B_Ahs_ZN.mjs +0 -19
- package/dist/packem_shared/usePresence-Bg671Pt0.mjs +0 -75
- package/dist/packem_shared/useRateLimit-DlPWjcX1.mjs +0 -67
- package/dist/packem_shared/useStream-DK2TNPo4.mjs +0 -65
- package/dist/packem_shared/useSubscription-B2s-lc5e.mjs +0 -48
- package/dist/packem_shared/useVoiceAgent-DuNU5TE_.mjs +0 -388
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { hydratePreloaded } from './packem_shared/hydratePreloaded-Cnd2GmG1.mjs';
|
|
3
|
-
export { LUNORA_INJECTION_KEY, createLunora, provideLunora, useLunora } from './packem_shared/LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
4
|
-
export { useAgent } from './packem_shared/useAgent-TEp9OWs3.mjs';
|
|
5
|
-
export { useAgentChat } from './packem_shared/useAgentChat-DQmekE-E.mjs';
|
|
6
|
-
export { useAgentState } from './packem_shared/useAgentState-CeDpLTib.mjs';
|
|
7
|
-
export { useAgentToolEvents } from './packem_shared/useAgentToolEvents-DfCy9INR.mjs';
|
|
8
|
-
export { useAuth } from './packem_shared/useAuth-yXaaF-ro.mjs';
|
|
9
|
-
export { default as useConnectionStatus } from './packem_shared/useConnectionStatus-DM_TOaW5.mjs';
|
|
10
|
-
export { useFlag, useFlags } from './packem_shared/useFlag-B8Gq7oUu.mjs';
|
|
11
|
-
export { useMutation } from './packem_shared/useMutation-BKIwT8Jk.mjs';
|
|
12
|
-
export { useMutator } from './packem_shared/useMutator-B_Ahs_ZN.mjs';
|
|
13
|
-
export { useInfiniteQuery, usePaginatedQuery } from './packem_shared/useInfiniteQuery-CMAUPQyd.mjs';
|
|
14
|
-
export { usePresence } from './packem_shared/usePresence-Bg671Pt0.mjs';
|
|
15
|
-
export { subscribeToQuery, useQuery } from './packem_shared/subscribeToQuery-hVYyvgOD.mjs';
|
|
16
|
-
export { useRateLimit } from './packem_shared/useRateLimit-DlPWjcX1.mjs';
|
|
17
|
-
export { useStream } from './packem_shared/useStream-DK2TNPo4.mjs';
|
|
18
|
-
export { useSubscription } from './packem_shared/useSubscription-B2s-lc5e.mjs';
|
|
19
|
-
export { useVoiceAgent } from './packem_shared/useVoiceAgent-DuNU5TE_.mjs';
|
|
1
|
+
import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-CST_mkXL.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-D8EcBXmG.mjs";import{LUNORA_INJECTION_KEY as f,createLunora as m,provideLunora as p,useLunora as x}from"./packem_shared/LUNORA_INJECTION_KEY-CswQb5zb.mjs";import{useAgent as d}from"./packem_shared/useAgent-DyWC-Sm8.mjs";import{useAgentChat as A}from"./packem_shared/useAgentChat-ScvDvEFO.mjs";import{useAgentState as h}from"./packem_shared/useAgentState-CUHDV3h7.mjs";import{useAgentToolEvents as l}from"./packem_shared/useAgentToolEvents-DvcPNShc.mjs";import{useAuth as Q}from"./packem_shared/useAuth-DwDFjvto.mjs";import{default as b}from"./packem_shared/useConnectionStatus-BwLyL_L_.mjs";import{useFlag as E,useFlags as I}from"./packem_shared/useFlag-Bxoq8mH9.mjs";import{useMutation as P}from"./packem_shared/useMutation-MdgW9pRE.mjs";import{useMutator as v}from"./packem_shared/useMutator-DRVDOhcj.mjs";import{useInfiniteQuery as M,usePaginatedQuery as O}from"./packem_shared/useInfiniteQuery-Czncoie-.mjs";import{usePresence as U}from"./packem_shared/usePresence-AiurcGAB.mjs";import{subscribeToQuery as J,useQuery as K}from"./packem_shared/subscribeToQuery-CGvPMz37.mjs";import{useRateLimit as Y}from"./packem_shared/useRateLimit-z8EUFuYJ.mjs";import{useStream as k}from"./packem_shared/useStream-CYkKEcDf.mjs";import{useSubscription as w}from"./packem_shared/useSubscription-D4Ap-tJr.mjs";import{useVoiceAgent as B}from"./packem_shared/useVoiceAgent-Ba0SIP06.mjs";export{o as AuthLoading,t as Authenticated,f as LUNORA_INJECTION_KEY,u as Unauthenticated,m as createLunora,a as hydratePreloaded,p as provideLunora,J as subscribeToQuery,d as useAgent,A as useAgentChat,h as useAgentState,l as useAgentToolEvents,Q as useAuth,b as useConnectionStatus,E as useFlag,I as useFlags,M as useInfiniteQuery,x as useLunora,P as useMutation,v as useMutator,O as usePaginatedQuery,U as usePresence,K as useQuery,Y as useRateLimit,k as useStream,w as useSubscription,B as useVoiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineComponent as l,computed as a}from"vue";import{useAuth as s}from"./useAuth-DwDFjvto.mjs";const i=l({name:"Authenticated",setup(o,{slots:t}){const{token:e,user:u}=s(),n=a(()=>e.value!==null&&u.value!==null);return()=>n.value?t.default?.():void 0}}),v=l({name:"Unauthenticated",setup(o,{slots:t}){const{token:e,user:u}=s(),n=a(()=>e.value!==null&&u.value===null);return()=>!n.value&&e.value===null?t.default?.():void 0}}),c=l({name:"AuthLoading",setup(o,{slots:t}){const{token:e,user:u}=s(),n=a(()=>e.value!==null&&u.value===null);return()=>n.value?t.default?.():void 0}});export{c as AuthLoading,i as Authenticated,v as Unauthenticated};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as n}from"@lunora/errors";import{inject as t,provide as a}from"vue";const o=Symbol("lunora.client"),p=r=>({install(e){e.provide(o,r)}}),l=r=>{a(o,r)},L=()=>{const r=t(o,void 0);if(!r)throw new n("INTERNAL","useLunora(): no LunoraClient provided — call app.use(createLunora(client)) or provideLunora(client) in a parent setup().");return r};export{o as LUNORA_INJECTION_KEY,p as createLunora,l as provideLunora,L as useLunora};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useLunora as n}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";import{subscribeToQuery as u}from"./subscribeToQuery-CGvPMz37.mjs";const f=r=>{const e=n(),{args:o,functionPath:t,shardKey:a,value:s}=r;return u(e,{__lunoraRef:t},o,{seed:s,shardKey:a})};export{f as hydratePreloaded};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const y=(e,t)=>e<t?-1:e>t?1:0,s=e=>{if(e===void 0)return"null";if(typeof e=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>s(r)).join(",")}]`;const t=Object.getPrototypeOf(e);if(t!==null&&t!==Object.prototype){const r=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${r} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const n=e,a=Object.keys(n).toSorted(y),i=[];for(const r of a){const o=n[r];o!==void 0&&i.push(`${JSON.stringify(r)}:${s(o)}`)}return`{${i.join(",")}}`};export{s as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createQuerySubscription as m}from"@lunora/client/query";import{shallowRef as c,getCurrentScope as p,onScopeDispose as y,watch as h,toValue as l}from"vue";import{useLunora as b}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const Q=(o,s,t,r={})=>{const e=c(r.seed),u=o.subscribe(s,t,a=>{e.value=a},{shardKey:r.shardKey});return p()&&y(u),e},S=(o,s,t={})=>{const r=b(),e=c(void 0);return h(()=>l(s),(u,a,i)=>{const n=m(r,o,u,{onData:d=>{e.value=d},onReset:()=>{e.value=void 0}},{shardKey:t.shardKey});i(n)},{immediate:!0}),e};export{Q as subscribeToQuery,S as useQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as s,toValue as n}from"vue";import{useMutation as i}from"./useMutation-MdgW9pRE.mjs";import{useSubscription as f}from"./useSubscription-D4Ap-tJr.mjs";const h={__lunoraRef:""},K=o=>{const{api:d,cancel:u,run:c,runArgs:p,threadKey:a}=o,r=i(c),m=i(u??h),{data:g}=f(d.agents.agentThread,()=>({key:n(a)})),e=s(()=>g.value),l=s(()=>e.value?.status),y=async(t,v)=>{await r.mutate({input:t,threadKey:n(a),...p,...v})};return{cancel:async()=>{const t=e.value?.instanceId;u===void 0||t===void 0||await m.mutate({instanceId:t,threadKey:n(a)})},pending:r.pending,run:y,status:l,thread:e}};export{h as NO_MUTATION_REF,K as useAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ref as R,computed as m,toValue as r}from"vue";import{NO_MUTATION_REF as _}from"./useAgent-DyWC-Sm8.mjs";import{useMutation as y}from"./useMutation-MdgW9pRE.mjs";import{useStream as x}from"./useStream-CYkKEcDf.mjs";import{useSubscription as A}from"./useSubscription-D4Ap-tJr.mjs";const O={__lunoraRef:""},k=(g,u)=>{const l=u.filter(s=>s.role==="user"),c=new Set;return g.filter(s=>{for(let o=s.durableUserCountAtSend;o<l.length;o+=1){const d=l[o];if(d!==void 0&&!c.has(o)&&d.content===s.content)return c.add(o),!1}return!0})},B=g=>{const{api:u,cancel:l,limit:c,send:s,sendArgs:o,stream:d,threadKey:a}=g,{data:C}=A(u.agents.agentMessages,()=>{const t=r(a);return c===void 0?{key:t}:{key:t,limit:c}}),{data:K}=A(u.agents.agentThread,()=>({key:r(a)})),S=d===void 0?"skip":()=>({key:r(a)}),{chunks:j}=x(d??O,S),T=y(s),U=y(l??_),I=y(u.agents.agentResolveApproval),v=R([]);let w=0;const f=m(()=>K.value),b=m(()=>f.value?.status),p=m(()=>C.value??[]),q=m(()=>{const t=p.value,n=k(v.value,t);if(n.length===0)return t;let e=-1;for(const i of t)i.seq>e&&(e=i.seq);return[...t,...n.map((i,h)=>({content:i.content,optimistic:!0,role:"user",seq:e+1+h}))]}),E=m(()=>{const t=r(a),n=p.value.filter(e=>e.role==="assistant").length;return j.value.filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=n).map(e=>e.text).join("")});return{approve:async(t,n)=>{const e=f.value?.instanceId;if(e===void 0)throw new Error("useAgentChat: cannot approve — no in-flight run (thread has no instanceId)");await I.mutate({decision:"approve",instanceId:e,threadKey:r(a),toolCallId:t,...n===void 0?{}:{note:n}})},cancel:async()=>{const t=f.value?.instanceId;l===void 0||t===void 0||await U.mutate({instanceId:t,threadKey:r(a)})},messages:q,reject:async(t,n)=>{const e=f.value?.instanceId;if(e===void 0)throw new Error("useAgentChat: cannot reject — no in-flight run (thread has no instanceId)");await I.mutate({decision:"reject",instanceId:e,threadKey:r(a),toolCallId:t,...n===void 0?{}:{note:n}})},send:async(t,n)=>{const e=w;w+=1;const i=p.value.filter(h=>h.role==="user").length;v.value=[...k(v.value,p.value),{content:t,durableUserCountAtSend:i,id:e}];try{await T.mutate({input:t,threadKey:r(a),...o,...n})}catch(h){throw v.value=v.value.filter(M=>M.id!==e),h}},status:b,streamingText:E}};export{B as useAgentChat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as o,toValue as s}from"vue";import{useSubscription as n}from"./useSubscription-D4Ap-tJr.mjs";const p=t=>{const{data:e,error:r}=n(t.api.agents.agentState,()=>({key:s(t.threadKey)})),a=o(()=>e.value);return{error:r,state:a}};export{p as useAgentState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as v,toValue as e}from"vue";import{useStream as c}from"./useStream-CYkKEcDf.mjs";import{useSubscription as C}from"./useSubscription-D4Ap-tJr.mjs";const f={__lunoraRef:""},g=[],y=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(a=>({input:a.input,seq:t.seq,toolCallId:a.id,toolName:a.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]},q=t=>{const{api:a,limit:r,stream:i,threadKey:s}=t,u=()=>{const l=e(s);return r===void 0?{key:l}:{key:l,limit:r}},{data:d}=C(a.agents.agentMessages,u),n=i===void 0?"skip":()=>({key:e(s)}),{chunks:m}=c(i??f,n);return{events:v(()=>{const l=e(s),p=(d.value??g).flatMap(o=>y(o)??[]);for(const o of m.value)o.kind==="progress"&&o.threadKey===l&&p.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return p})}};export{q as useAgentToolEvents};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getIdentityStore as k}from"@lunora/client/auth";import{ref as n,onScopeDispose as m,readonly as s}from"vue";import{useLunora as p}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const f=()=>{const e=p(),t=k(e),o=n(e.getAuthToken()),r=n(t.getUser()),u=()=>{o.value=e.getAuthToken()},g=()=>{r.value=t.getUser()},i=e.onAuthTokenChange(u),a=t.subscribe(g);return m(()=>{i(),a()}),{setToken:h=>{e.setAuthToken(h)},token:s(o),user:s(r)}};export{f as useAuth};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as r,getCurrentScope as s,onScopeDispose as a}from"vue";import{useLunora as u}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const i=()=>{const o=u(),t=r(o.connectionStatus()),e=o.onConnectionStatus(n=>{t.value=n});return s()&&a(e),t};export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as b,watch as p,toValue as a}from"vue";import{e as v}from"./stable-key-BSG0zK_E.mjs";import{useLunora as _}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const g="__lunora_flags__:eval",y=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},d={__lunoraRef:g},h=t=>t===void 0?"":v(t),k=(t,e,u)=>{const o=_(),n=y(e),c=b(e);return p(()=>`${a(t)}\0${h(a(u))}`,(x,m,f)=>{const l=a(t),r=a(u);c.value=e;let s;try{s=o.subscribe(d,{context:r,default:e,key:l,type:n},i=>{c.value=i})}catch{return}f(s)},{immediate:!0}),c},w=(t,e)=>{const u=_(),o=b(t),n=v(t);return p(()=>`${n}\0${h(a(e))}`,(c,x,m)=>{const f=a(e);o.value=t;const l=[];for(const[r,s]of Object.entries(t))try{l.push(u.subscribe(d,{context:f,default:s,key:r,type:y(s)},i=>{o.value={...o.value,[r]:i}}))}catch{}m(()=>{for(const r of l)r()})},{immediate:!0}),o};export{k as useFlag,w as useFlags};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as $,watch as k,toValue as _,onScopeDispose as Q,computed as A}from"vue";import{initialPages as U,derivePaginationStatus as B,applyLoadMore as z,rebalance as q}from"@lunora/client/pagination";import{e as G}from"./stable-key-BSG0zK_E.mjs";import{useLunora as H}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const x=t=>{let n="";for(let u=0;u<t.length;u+=32768)n+=String.fromCharCode(...t.subarray(u,u+32768));return btoa(n)},f="$lunora.wire$",F=64,h=(t,n=0)=>{if(n>F)throw new RangeError(`wire-codec: value nesting exceeds the ${F}-level limit`);if(t===void 0)return[f,"undefined"];if(t===null)return null;const u=typeof t;if(u==="bigint")return[f,"bigint",t.toString()];if(u==="number"){const e=t;return Number.isNaN(e)?[f,"nan"]:e===1/0?[f,"inf"]:e===-1/0?[f,"-inf"]:e}if(u!=="object")return t;if(t instanceof Date)return[f,"date",h(t.getTime(),n+1)];if(t instanceof Error){const e=t,o={};for(const i of Object.keys(e))e[i]!==void 0&&(o[i]=h(e[i],n+1));const l=[f,"error",e.name,e.message,o];return e.cause!==void 0&&l.push(h(e.cause,n+1)),l}if(t instanceof URL)return[f,"url",t.href];if(t instanceof Map)return[f,"map",[...t.entries()].map(([e,o])=>[h(e,n+1),h(o,n+1)])];if(t instanceof Set)return[f,"set",[...t].map(e=>h(e,n+1))];if(t instanceof ArrayBuffer)return[f,"bytes",x(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){const e=t,o=e.constructor.name,l=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return o==="Uint8Array"?[f,"bytes",x(l)]:[f,"bytes",x(l),o]}if(Array.isArray(t)){const e=t.map(o=>h(o,n+1));return e.length>0&&e[0]===f?[f,"arr",e]:e}const L=Object.getPrototypeOf(t);if(L!==null&&L!==Object.prototype){const e=t.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${e} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const b=t,y={};for(const e of Object.keys(b)){const o=b[e];o!==void 0&&(y[e]=h(o,n+1))}return y},D=t=>G(h(t)),P=(t,n)=>`${t}::${D(n)}`,K=(t,n)=>({...n,paginationOpts:{cursor:t.lower,endCursor:t.upper,numItems:t.numItems}}),T=(t,n,u)=>{const L=H(),{initialNumItems:b,shardKey:y}=u,e=$(U(b)),o=$([]);let l;const i=new Map,g=new Map,m=new Set,M=(r,a)=>{o.value=r.map(v=>{const w=P(t.__lunoraRef,K(v,a));return g.get(w)})},V=(r,a,v)=>{const w=s=>P(t.__lunoraRef,K(s,v));for(const s of a){const d=w(s);if(g.has(d))continue;const p=r.find(c=>c.lower===s.lower);if(p){const c=g.get(w(p));c&&g.set(d,c)}}},C=(r,a)=>{const v=new Set;for(const s of r)v.add(P(t.__lunoraRef,K(s,a)));for(const[s,d]of i)v.has(d.currentKey)||(d.unsub(),i.delete(s),g.delete(d.currentKey),m.delete(d.currentKey));const w=new Set([...i.values()].map(s=>s.currentKey));for(const s of r){const d=K(s,a),p=P(t.__lunoraRef,d);if(w.has(p))continue;const c={currentKey:p,unsub:void 0};m.add(p);const R=L.subscribe(t,d,S=>{g.set(c.currentKey,S),m.delete(c.currentKey);const N=_(n);if(M(e.value,N),m.size===0){const I=e.value,O=q(I,o.value);O&&(V(I,O,N),e.value=O)}},{shardKey:y});c.unsub=R,i.set(p,c),w.add(p)}},j=()=>{for(const r of i.values())r.unsub();i.clear(),g.clear(),m.clear()};k(()=>D(_(n)),()=>{const r=_(n);j(),e.value=U(b),o.value=[],l=void 0,r!=="skip"&&(C(e.value,r),M(e.value,r))},{immediate:!0}),k(()=>e.value,r=>{const a=_(n);a!=="skip"&&(C(r,a),M(r,a))}),Q(j);const E=$("LoadingFirstPage");return k([()=>_(n),o],([r,a])=>{E.value=B(r==="skip",a).status},{immediate:!0}),{loadMore:r=>{const a=_(n);if(a==="skip")return;const{nextCursor:v,status:w}=B(!1,o.value);if(w!=="CanLoadMore"||v===l)return;const s=z(e.value,v,r);if(!s)return;l=v;const d=e.value.at(-1),p=s.at(-2);if(d&&p){const c=P(t.__lunoraRef,K(d,a)),R=P(t.__lunoraRef,K(p,a)),S=i.get(c);if(S&&c!==R){S.currentKey=R,i.set(R,S),i.delete(c);const N=g.get(c);N&&(g.set(R,N),g.delete(c))}}e.value=s},pageResults:o,status:E}},Z=(t,n,u)=>{const{loadMore:L,pageResults:b,status:y}=T(t,n,u),e=A(()=>{const o=[];for(const l of b.value)l&&o.push(...l.page);return o});return{isLoading:A(()=>y.value==="LoadingFirstPage"||y.value==="LoadingMore"),loadMore:L,results:e,status:y}},ee=(t,n,u)=>{const{initialNumItems:L}=u,{loadMore:b,pageResults:y,status:e}=T(t,n,u),o=A(()=>{const m=[];for(const M of y.value)M&&m.push(M.page);return m}),l=A(()=>e.value==="LoadingFirstPage"),i=A(()=>e.value==="CanLoadMore"),g=A(()=>e.value==="LoadingMore");return{fetchNextPage:m=>{b(m??L)},hasNextPage:i,isFetchingNextPage:g,isLoading:l,pages:o,status:e}};export{ee as useInfiniteQuery,Z as usePaginatedQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createMutationRunner as v}from"@lunora/client";import{shallowRef as a,ref as l}from"vue";import{useLunora as d}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const c=u=>{const i=d(),t=a(void 0),r=a(void 0),o=l(!1),n=()=>{t.value=void 0,r.value=void 0},s=v(i,u,{setError:e=>{r.value=e},setPending:e=>{o.value=e},setResult:e=>{t.value=e,r.value=void 0}});return{data:t,error:r,mutate:s,pending:o,reset:n}};export{c as useMutation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createMutatorRunner as i}from"@lunora/client";import{shallowRef as o,computed as m}from"vue";const p=u=>{const e=o(void 0),t=o(!1),a=m(()=>e.value!==void 0),{mutate:s,reset:n}=i(u,{setError:r=>{e.value=r},setPending:r=>{t.value=r}});return{error:e,isError:a,mutate:s,pending:t,reset:n}};export{p as useMutator};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as I,getCurrentScope as b,onScopeDispose as g}from"vue";import{useLunora as S}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const w=(e="sess")=>{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`${e}-${Array.from(t,o=>o.toString(16).padStart(2,"0")).join("")}`}}return`${e}-${Date.now().toString(36)}`},D=1e4,K=(e,t)=>{const o=S(),{heartbeat:u,intervalMs:m=D,listPresent:p,shardKey:s}=t,i=t.sessionId??w(),c=I(void 0);let a=t.data;const r=()=>{const n={roomId:e,sessionId:i,...a===void 0?{}:{data:a}};o.mutation(u,n,{shardKey:s}).catch(()=>{})},y=n=>{a=n,r()};if(globalThis.window!==void 0){r();const n=setInterval(r,m),d=()=>{typeof document<"u"&&document.visibilityState==="visible"&&r()};typeof document<"u"&&document.addEventListener("visibilitychange",d);const l=o.acquireConnectionContext({roomId:e,sessionId:i},{shardKey:s}),f=o.subscribe(p,{roomId:e},h=>{c.value=h},{shardKey:s}),v=()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",d),l(),f()};b()&&g(v)}return{present:c,sessionId:i,setData:y}};export{K as usePresence};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{evaluate as u}from"@lunora/ratelimit";import{shallowRef as d,toValue as r,watchEffect as b,onScopeDispose as A,computed as f}from"vue";const L=(s,i={})=>{const a=i.now??Date.now,k=i.tickMs??1e3;let e;const w=d(0),l=()=>{w.value+=1},o=d(u(r(s),e,{consume:!1,count:1,now:a(),reserve:!1}).status),p=b(()=>{o.value=u(r(s),e,{consume:!1,count:1,now:a(),reserve:!1}).status},{flush:"sync"});let t;const n=()=>{t!==void 0&&(clearInterval(t),t=void 0)},m=()=>{o.value.ok||t!==void 0||(t=setInterval(()=>{l(),o.value.ok&&n()},k))};A(()=>{n(),p()}),m();const h=(c=1)=>{const v=u(r(s),e,{consume:!0,count:c,now:a(),reserve:!1});return v.value!==void 0&&(e=v.value),l(),m(),v.status},y=(c=1)=>u(r(s),e,{consume:!1,count:c,now:a(),reserve:!1}).status.ok,R=()=>{e=void 0,n(),l()};return{check:y,consume:h,disabled:f(()=>!o.value.ok),ok:f(()=>o.value.ok),reset:R,retryAfter:f(()=>o.value.retryAfter)}};export{L as useRateLimit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ref as n,watch as h,toValue as y,onScopeDispose as w}from"vue";import{useLunora as x}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const B=(m,v,l={})=>{const d=x(),a=n([]),u=n(void 0),e=n("idle");let t;const c=()=>{t?.()};return h(()=>y(v),(i,S,p)=>{if(a.value=[],u.value=void 0,i==="skip"){e.value="idle";return}e.value="streaming";let o=!0;const f=d.stream(m,i,{maxBuffer:l.maxBuffer,shardKey:l.shardKey}),s=()=>{f.cancel()};t=s,(async()=>{try{for await(const r of f){if(!o)return;a.value=[...a.value,r]}o&&(e.value="complete")}catch(r){if(!o)return;u.value=r instanceof Error?r:new Error(String(r)),e.value="error"}})().catch(()=>{}),p(()=>{o=!1,s(),t===s&&(t=void 0)})},{immediate:!0}),w(()=>{c()}),{cancel:c,chunks:a,error:u,status:e}};export{B as useStream};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createQuerySubscription as n}from"@lunora/client/query";import{LunoraError as c}from"@lunora/errors";import{ref as i,watch as l,toValue as p,onScopeDispose as f}from"vue";import{useLunora as h}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const g=(u,v,t={})=>{const s=h(),o=i(void 0),r=i(void 0);return l(()=>p(v),(a,w,d)=>{if(a==="skip"){o.value=void 0,r.value=void 0;return}const m=n(s,u,a,{onData:e=>{o.value=e,r.value=void 0},onError:e=>{r.value=e.code===void 0?new Error(e.message):new c(e.code,e.message),o.value=void 0},onReset:()=>{o.value=void 0}},{shardKey:t.shardKey});d(m)},{immediate:!0}),f(()=>{o.value=void 0,r.value=void 0}),{data:o,error:r}};export{g as useSubscription};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ref as y,onScopeDispose as F,toValue as L}from"vue";import{useLunora as R}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const W=t=>{if(t.length===0)return 0;let s=0;for(const n of t)s+=n*n;return Math.sqrt(s/t.length)},B=(t,s)=>{const n=s/16e3,o=n>1?Math.floor(t.length/n):t.length,d=new ArrayBuffer(o*2),i=new DataView(d);for(let c=0;c<o;c+=1){const v=t[Math.floor(c*n)]??0,g=Math.max(-1,Math.min(1,v));i.setInt16(c*2,g<0?g*32768:g*32767,!0)}return new Uint8Array(d)},I=async t=>{const s=globalThis,n=s.navigator?.mediaDevices?.getUserMedia.bind(s.navigator.mediaDevices),o=s.AudioContext??s.webkitAudioContext;if(!n||!o)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await n({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),i=new o,c=i.createMediaStreamSource(d),v=i.createScriptProcessor(4096,1,1);let g=!1,m=!1,f=0,a=0;return v.onaudioprocess=u=>{const p=u.inputBuffer.getChannelData(0),h=g?0:W(p);if(t.onLevel(h),g)return;if(t.onAudio(B(p,i.sampleRate)),t.isSpeaking()){a=h>=t.interruptThreshold?a+1:0,a>=t.interruptChunks&&(a=0,t.onInterrupt());return}a=0;const w=p.length/i.sampleRate*1e3;if(h>=t.silenceThreshold){m=!0,f=0;return}m&&(f+=w,f>=t.silenceDurationMs&&(m=!1,f=0,t.onSilence()))},c.connect(v),v.connect(i.destination),{setMuted:u=>{g=u},stop:()=>{v.disconnect(),c.disconnect();for(const u of d.getTracks())u.stop();i.close()}}},J=()=>{const t=globalThis,s=t.AudioContext??t.webkitAudioContext;if(!s)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const n=new s,o=new Set;let d=0,i=Promise.resolve(),c=0;const v=async(f,a)=>{if(a!==c)return;let u;try{u=await n.decodeAudioData(f.buffer)}catch{return}if(a!==c)return;const p=n.createBufferSource();p.buffer=u,p.connect(n.destination);const h=Math.max(n.currentTime,d);p.start(h),d=h+u.duration,o.add(p),p.onended=()=>{o.delete(p)}},g=f=>{const a=Uint8Array.from(f),u=c;i=i.then(()=>v(a,u))},m=()=>{c+=1;for(const f of o)try{f.stop()}catch{}o.clear(),d=n.currentTime};return{enqueue:g,interrupt:m,stop:()=>{m(),n.close()}}},D=1,K=.01,N=1200,P=.15,O=3,j=t=>t.startsWith("https://")?`wss://${t.slice(8)}`:t.startsWith("http://")?`ws://${t.slice(7)}`:t,G=t=>{const s=t.__lunoraRef,n=s.startsWith("agents:")?s.slice(7):s;return n.endsWith("Voice")?n.slice(0,-5):n},H=(t,s,n)=>{const o=j(t),d=o.endsWith("/")?o.slice(0,-1):o,i=new URLSearchParams({threadKey:n});return`${d}/_lunora/voice/${encodeURIComponent(s)}?${i.toString()}`},X=t=>{const{createMicrophone:s=I,createSpeaker:n=J,createSocket:o,interruptChunks:d=O,interruptThreshold:i=P,silenceDurationMs:c=N,silenceThreshold:v=K,threadKey:g,voice:m}=t,f=R(),a=y("idle"),u=y(!1),p=y(""),h=y(""),w=y(0),b=y(!1),A=y(void 0);let l,S=!1;const C=r=>{const e=l?.socket;return e?.readyState===D?(e.send(JSON.stringify(r)),!0):!1},M=()=>{const r=l;if(l=void 0,r){r.microphone?.stop(),r.speaker?.stop();try{r.socket.close()}catch{}}S=!1,u.value=!1,a.value="idle",w.value=0},U=()=>{M()},V=r=>{const e=l;switch(r.type){case"assistant_delta":{e&&(e.speaking=!0),a.value="speaking",h.value+=r.text;break}case"assistant_done":{e&&(e.speaking=!1),h.value=r.text,a.value="listening";break}case"error":{e&&(e.speaking=!1),A.value=new Error(r.message),a.value="listening";break}case"interrupted":{e&&(e.speaking=!1,e.suppressAudio=!1),e?.speaker?.interrupt(),a.value="listening";break}case"ready":{e&&(e.audioFormat=r.audioFormat,e.suppressAudio=!1),u.value=!0,a.value="listening";break}case"user_transcript":{e&&(e.suppressAudio=!1),p.value=r.text,h.value="",a.value="thinking";break}}},$=r=>{const e=l;!e||e.suppressAudio||(e.speaker??=n({audioFormat:e.audioFormat}),e.speaking=!0,a.value="speaking",e.speaker.enqueue(r))},E=async()=>{if(!(l||S)){S=!0,A.value=void 0,p.value="",h.value="";try{const r=H(f.url,G(m),L(g)),e=(o??(k=>new globalThis.WebSocket(k)))(r);e.binaryType="arraybuffer";const x={audioFormat:"mp3",microphone:void 0,socket:e,speaker:void 0,speaking:!1,suppressAudio:!1};l=x,e.onmessage=k=>{if(typeof k.data=="string"){try{V(JSON.parse(k.data))}catch{}return}$(new Uint8Array(k.data))},e.onerror=()=>{A.value=new Error("useVoiceAgent: voice socket error")},e.onclose=()=>{l===x&&M()};const T=await s({interruptChunks:d,interruptThreshold:i,isSpeaking:()=>l?.speaking??!1,onAudio:k=>{e.readyState===D&&e.send(k)},onInterrupt:()=>{C({type:"interrupt"}),l?.speaker?.interrupt(),l&&(l.speaking=!1,l.suppressAudio=!0),a.value="listening"},onLevel:k=>{w.value=k},onSilence:()=>{C({type:"commit"}),a.value="thinking"},silenceDurationMs:c,silenceThreshold:v});l===x?(x.microphone=T,b.value=!1,a.value="listening"):T.stop()}catch(r){A.value=r instanceof Error?r:new Error(String(r)),M()}finally{S=!1}}},_=()=>{const r=!b.value;return l?.microphone?.setMuted(r),b.value=r,r},q=r=>{C({text:r,type:"text"})&&(a.value="thinking")};return F(M),{audioLevel:w,connected:u,endCall:U,error:A,interimTranscript:h,isMuted:b,sendText:q,startCall:E,status:a,toggleMute:_,transcript:p}};export{X as useVoiceAgent};
|
package/dist/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{createServerClient as d,deserializePreloaded as l,getServerSession as a,preloadQuery as o,preloadedQueryResult as i,serializePreloaded as s}from"@lunora/client/ssr";export{d as createServerClient,l as deserializePreloaded,a as getServerSession,o as preloadQuery,i as preloadedQueryResult,s as serializePreloaded};
|
package/dist/upload.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { useChunkedRestUpload, useFileInput, useMultipartUpload, usePasteUpload, useTusUpload, useUpload } from '@visulima/storage-client/vue';
|
|
1
|
+
import{RestrictionError as r,UploadControl as p,UploadError as l}from"@visulima/storage-client";import{useChunkedRestUpload as t,useFileInput as u,useMultipartUpload as a,usePasteUpload as d,useTusUpload as U,useUpload as i}from"@visulima/storage-client/vue";export{r as RestrictionError,p as UploadControl,l as UploadError,t as useChunkedRestUpload,u as useFileInput,a as useMultipartUpload,d as usePasteUpload,U as useTusUpload,i as useUpload};
|
package/dist/worker.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{withFrameworkWorker as a}from"@lunora/runtime";export{a as withLunora};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/vue",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.49",
|
|
4
4
|
"description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@lunora/client": "1.0.0-alpha.
|
|
62
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
63
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
64
|
-
"@lunora/runtime": "1.0.0-alpha.
|
|
61
|
+
"@lunora/client": "1.0.0-alpha.29",
|
|
62
|
+
"@lunora/errors": "1.0.0-alpha.8",
|
|
63
|
+
"@lunora/ratelimit": "1.0.0-alpha.10",
|
|
64
|
+
"@lunora/runtime": "1.0.0-alpha.38",
|
|
65
65
|
"@visulima/storage-client": "1.0.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { defineComponent, computed } from 'vue';
|
|
2
|
-
import { useAuth } from './useAuth-yXaaF-ro.mjs';
|
|
3
|
-
|
|
4
|
-
const Authenticated = defineComponent({
|
|
5
|
-
name: "Authenticated",
|
|
6
|
-
setup(_props, { slots }) {
|
|
7
|
-
const { token, user } = useAuth();
|
|
8
|
-
const isAuthenticated = computed(() => token.value !== null && user.value !== null);
|
|
9
|
-
return () => isAuthenticated.value ? slots.default?.() : void 0;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
const Unauthenticated = defineComponent({
|
|
13
|
-
name: "Unauthenticated",
|
|
14
|
-
setup(_props, { slots }) {
|
|
15
|
-
const { token, user } = useAuth();
|
|
16
|
-
const isLoading = computed(() => token.value !== null && user.value === null);
|
|
17
|
-
return () => !isLoading.value && token.value === null ? slots.default?.() : void 0;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const AuthLoading = defineComponent({
|
|
21
|
-
name: "AuthLoading",
|
|
22
|
-
setup(_props, { slots }) {
|
|
23
|
-
const { token, user } = useAuth();
|
|
24
|
-
const isLoading = computed(() => token.value !== null && user.value === null);
|
|
25
|
-
return () => isLoading.value ? slots.default?.() : void 0;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export { AuthLoading, Authenticated, Unauthenticated };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { LunoraError } from '@lunora/errors';
|
|
2
|
-
import { inject, provide } from 'vue';
|
|
3
|
-
|
|
4
|
-
const LUNORA_INJECTION_KEY = /* @__PURE__ */ Symbol("lunora.client");
|
|
5
|
-
const createLunora = (client) => {
|
|
6
|
-
return {
|
|
7
|
-
install(app) {
|
|
8
|
-
app.provide(LUNORA_INJECTION_KEY, client);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
const provideLunora = (client) => {
|
|
13
|
-
provide(LUNORA_INJECTION_KEY, client);
|
|
14
|
-
};
|
|
15
|
-
const useLunora = () => {
|
|
16
|
-
const client = inject(LUNORA_INJECTION_KEY, void 0);
|
|
17
|
-
if (!client) {
|
|
18
|
-
throw new LunoraError(
|
|
19
|
-
"INTERNAL",
|
|
20
|
-
"useLunora(): no LunoraClient provided — call app.use(createLunora(client)) or provideLunora(client) in a parent setup()."
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return client;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { LUNORA_INJECTION_KEY, createLunora, provideLunora, useLunora };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
2
|
-
import { subscribeToQuery } from './subscribeToQuery-hVYyvgOD.mjs';
|
|
3
|
-
|
|
4
|
-
const hydratePreloaded = (preloaded) => {
|
|
5
|
-
const client = useLunora();
|
|
6
|
-
const { args, functionPath, shardKey, value } = preloaded;
|
|
7
|
-
const functionReference = { __lunoraRef: functionPath };
|
|
8
|
-
return subscribeToQuery(client, functionReference, args, {
|
|
9
|
-
seed: value,
|
|
10
|
-
shardKey
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { hydratePreloaded };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const compareKeys = (a, b) => {
|
|
2
|
-
if (a < b) {
|
|
3
|
-
return -1;
|
|
4
|
-
}
|
|
5
|
-
return a > b ? 1 : 0;
|
|
6
|
-
};
|
|
7
|
-
const stableStringify = (value) => {
|
|
8
|
-
if (value === void 0) {
|
|
9
|
-
return "null";
|
|
10
|
-
}
|
|
11
|
-
if (typeof value === "bigint") {
|
|
12
|
-
throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");
|
|
13
|
-
}
|
|
14
|
-
if (value === null || typeof value !== "object") {
|
|
15
|
-
return JSON.stringify(value);
|
|
16
|
-
}
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
19
|
-
}
|
|
20
|
-
const proto = Object.getPrototypeOf(value);
|
|
21
|
-
if (proto !== null && proto !== Object.prototype) {
|
|
22
|
-
const name = value.constructor?.name ?? "value";
|
|
23
|
-
throw new TypeError(
|
|
24
|
-
`stableStringify: cannot use a ${name} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
const record = value;
|
|
28
|
-
const keys = Object.keys(record).toSorted(compareKeys);
|
|
29
|
-
const parts = [];
|
|
30
|
-
for (const key of keys) {
|
|
31
|
-
const raw = record[key];
|
|
32
|
-
if (raw === void 0) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
parts.push(`${JSON.stringify(key)}:${stableStringify(raw)}`);
|
|
36
|
-
}
|
|
37
|
-
return `{${parts.join(",")}}`;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { stableStringify as s };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { createQuerySubscription } from '@lunora/client/query';
|
|
2
|
-
import { shallowRef, getCurrentScope, onScopeDispose, watch, toValue } from 'vue';
|
|
3
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
4
|
-
|
|
5
|
-
const subscribeToQuery = (client, function_, args, options = {}) => {
|
|
6
|
-
const data = shallowRef(options.seed);
|
|
7
|
-
const unsubscribe = client.subscribe(
|
|
8
|
-
function_,
|
|
9
|
-
args,
|
|
10
|
-
(value) => {
|
|
11
|
-
data.value = value;
|
|
12
|
-
},
|
|
13
|
-
{ shardKey: options.shardKey }
|
|
14
|
-
);
|
|
15
|
-
if (getCurrentScope()) {
|
|
16
|
-
onScopeDispose(unsubscribe);
|
|
17
|
-
} else {
|
|
18
|
-
console.warn(
|
|
19
|
-
"[@lunora/vue] subscribeToQuery called with no active effect scope — its subscription will not be cleaned up automatically. Call it inside setup()/an effect scope, or call the returned teardown yourself."
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
const useQuery = (function_, args, options = {}) => {
|
|
25
|
-
const client = useLunora();
|
|
26
|
-
const data = shallowRef(void 0);
|
|
27
|
-
watch(
|
|
28
|
-
() => toValue(args),
|
|
29
|
-
(current, _previous, onCleanup) => {
|
|
30
|
-
const unsubscribe = createQuerySubscription(
|
|
31
|
-
client,
|
|
32
|
-
function_,
|
|
33
|
-
current,
|
|
34
|
-
{
|
|
35
|
-
onData: (value) => {
|
|
36
|
-
data.value = value;
|
|
37
|
-
},
|
|
38
|
-
onReset: () => {
|
|
39
|
-
data.value = void 0;
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{ shardKey: options.shardKey }
|
|
43
|
-
);
|
|
44
|
-
onCleanup(unsubscribe);
|
|
45
|
-
},
|
|
46
|
-
{ immediate: true }
|
|
47
|
-
);
|
|
48
|
-
return data;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export { subscribeToQuery, useQuery };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { computed, toValue } from 'vue';
|
|
2
|
-
import { useMutation } from './useMutation-BKIwT8Jk.mjs';
|
|
3
|
-
import { useSubscription } from './useSubscription-B2s-lc5e.mjs';
|
|
4
|
-
|
|
5
|
-
const NO_MUTATION_REF = { __lunoraRef: "" };
|
|
6
|
-
const useAgent = (options) => {
|
|
7
|
-
const { api, cancel: cancelReference, run: runReference, runArgs, threadKey } = options;
|
|
8
|
-
const runMutation = useMutation(runReference);
|
|
9
|
-
const cancelMutation = useMutation(cancelReference ?? NO_MUTATION_REF);
|
|
10
|
-
const { data: threadData } = useSubscription(api.agents.agentThread, () => {
|
|
11
|
-
return { key: toValue(threadKey) };
|
|
12
|
-
});
|
|
13
|
-
const thread = computed(() => threadData.value);
|
|
14
|
-
const status = computed(() => thread.value?.status);
|
|
15
|
-
const run = async (input, arguments_) => {
|
|
16
|
-
await runMutation.mutate({ input, threadKey: toValue(threadKey), ...runArgs, ...arguments_ });
|
|
17
|
-
};
|
|
18
|
-
const cancel = async () => {
|
|
19
|
-
const instanceId = thread.value?.instanceId;
|
|
20
|
-
if (cancelReference === void 0 || instanceId === void 0) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
await cancelMutation.mutate({ instanceId, threadKey: toValue(threadKey) });
|
|
24
|
-
};
|
|
25
|
-
return { cancel, pending: runMutation.pending, run, status, thread };
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { NO_MUTATION_REF, useAgent };
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { ref, computed, toValue } from 'vue';
|
|
2
|
-
import { NO_MUTATION_REF } from './useAgent-TEp9OWs3.mjs';
|
|
3
|
-
import { useMutation } from './useMutation-BKIwT8Jk.mjs';
|
|
4
|
-
import { useStream } from './useStream-DK2TNPo4.mjs';
|
|
5
|
-
import { useSubscription } from './useSubscription-B2s-lc5e.mjs';
|
|
6
|
-
|
|
7
|
-
const NO_STREAM_REF = { __lunoraRef: "" };
|
|
8
|
-
const reconcileOptimistic = (optimistic, durable) => {
|
|
9
|
-
const durableUserRows = durable.filter((message) => message.role === "user");
|
|
10
|
-
const consumed = /* @__PURE__ */ new Set();
|
|
11
|
-
return optimistic.filter((pending) => {
|
|
12
|
-
for (let index = pending.durableUserCountAtSend; index < durableUserRows.length; index += 1) {
|
|
13
|
-
const row = durableUserRows[index];
|
|
14
|
-
if (row !== void 0 && !consumed.has(index) && row.content === pending.content) {
|
|
15
|
-
consumed.add(index);
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
const useAgentChat = (options) => {
|
|
23
|
-
const { api, cancel: cancelReference, limit, send: sendReference, sendArgs, stream: streamReference, threadKey } = options;
|
|
24
|
-
const { data: history } = useSubscription(api.agents.agentMessages, () => {
|
|
25
|
-
const key = toValue(threadKey);
|
|
26
|
-
return limit === void 0 ? { key } : { key, limit };
|
|
27
|
-
});
|
|
28
|
-
const { data: threadData } = useSubscription(api.agents.agentThread, () => {
|
|
29
|
-
return { key: toValue(threadKey) };
|
|
30
|
-
});
|
|
31
|
-
const streamArguments = streamReference === void 0 ? "skip" : () => {
|
|
32
|
-
return { key: toValue(threadKey) };
|
|
33
|
-
};
|
|
34
|
-
const { chunks } = useStream(streamReference ?? NO_STREAM_REF, streamArguments);
|
|
35
|
-
const sendMutation = useMutation(sendReference);
|
|
36
|
-
const cancelMutation = useMutation(cancelReference ?? NO_MUTATION_REF);
|
|
37
|
-
const approvalMutation = useMutation(api.agents.agentResolveApproval);
|
|
38
|
-
const optimistic = ref([]);
|
|
39
|
-
let nextId = 0;
|
|
40
|
-
const thread = computed(() => threadData.value);
|
|
41
|
-
const status = computed(() => thread.value?.status);
|
|
42
|
-
const durable = computed(() => history.value ?? []);
|
|
43
|
-
const messages = computed(() => {
|
|
44
|
-
const rows = durable.value;
|
|
45
|
-
const visible = reconcileOptimistic(optimistic.value, rows);
|
|
46
|
-
if (visible.length === 0) {
|
|
47
|
-
return rows;
|
|
48
|
-
}
|
|
49
|
-
let maxDurableSeq = -1;
|
|
50
|
-
for (const message of rows) {
|
|
51
|
-
if (message.seq > maxDurableSeq) {
|
|
52
|
-
maxDurableSeq = message.seq;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return [
|
|
56
|
-
...rows,
|
|
57
|
-
...visible.map((pending, index) => {
|
|
58
|
-
return {
|
|
59
|
-
content: pending.content,
|
|
60
|
-
optimistic: true,
|
|
61
|
-
role: "user",
|
|
62
|
-
seq: maxDurableSeq + 1 + index
|
|
63
|
-
};
|
|
64
|
-
})
|
|
65
|
-
];
|
|
66
|
-
});
|
|
67
|
-
const streamingText = computed(() => {
|
|
68
|
-
const key = toValue(threadKey);
|
|
69
|
-
const assistantCount = durable.value.filter((message) => message.role === "assistant").length;
|
|
70
|
-
return chunks.value.filter((event) => event.kind !== "progress" && event.threadKey === key && event.turn >= assistantCount).map((delta) => delta.text).join("");
|
|
71
|
-
});
|
|
72
|
-
const send = async (input, arguments_) => {
|
|
73
|
-
const id = nextId;
|
|
74
|
-
nextId += 1;
|
|
75
|
-
const durableUserCountAtSend = durable.value.filter((message) => message.role === "user").length;
|
|
76
|
-
optimistic.value = [...reconcileOptimistic(optimistic.value, durable.value), { content: input, durableUserCountAtSend, id }];
|
|
77
|
-
try {
|
|
78
|
-
await sendMutation.mutate({ input, threadKey: toValue(threadKey), ...sendArgs, ...arguments_ });
|
|
79
|
-
} catch (error) {
|
|
80
|
-
optimistic.value = optimistic.value.filter((pending) => pending.id !== id);
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const approve = async (toolCallId, note) => {
|
|
85
|
-
const instanceId = thread.value?.instanceId;
|
|
86
|
-
if (instanceId === void 0) {
|
|
87
|
-
throw new Error("useAgentChat: cannot approve — no in-flight run (thread has no instanceId)");
|
|
88
|
-
}
|
|
89
|
-
await approvalMutation.mutate({ decision: "approve", instanceId, threadKey: toValue(threadKey), toolCallId, ...note === void 0 ? {} : { note } });
|
|
90
|
-
};
|
|
91
|
-
const reject = async (toolCallId, note) => {
|
|
92
|
-
const instanceId = thread.value?.instanceId;
|
|
93
|
-
if (instanceId === void 0) {
|
|
94
|
-
throw new Error("useAgentChat: cannot reject — no in-flight run (thread has no instanceId)");
|
|
95
|
-
}
|
|
96
|
-
await approvalMutation.mutate({ decision: "reject", instanceId, threadKey: toValue(threadKey), toolCallId, ...note === void 0 ? {} : { note } });
|
|
97
|
-
};
|
|
98
|
-
const cancel = async () => {
|
|
99
|
-
const instanceId = thread.value?.instanceId;
|
|
100
|
-
if (cancelReference === void 0 || instanceId === void 0) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
await cancelMutation.mutate({ instanceId, threadKey: toValue(threadKey) });
|
|
104
|
-
};
|
|
105
|
-
return { approve, cancel, messages, reject, send, status, streamingText };
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export { useAgentChat };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { computed, toValue } from 'vue';
|
|
2
|
-
import { useSubscription } from './useSubscription-B2s-lc5e.mjs';
|
|
3
|
-
|
|
4
|
-
const useAgentState = (options) => {
|
|
5
|
-
const { data, error } = useSubscription(options.api.agents.agentState, () => {
|
|
6
|
-
return { key: toValue(options.threadKey) };
|
|
7
|
-
});
|
|
8
|
-
const state = computed(() => data.value);
|
|
9
|
-
return { error, state };
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { useAgentState };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { computed, toValue } from 'vue';
|
|
2
|
-
import { useStream } from './useStream-DK2TNPo4.mjs';
|
|
3
|
-
import { useSubscription } from './useSubscription-B2s-lc5e.mjs';
|
|
4
|
-
|
|
5
|
-
const NO_STREAM_REF = { __lunoraRef: "" };
|
|
6
|
-
const EMPTY_MESSAGES = [];
|
|
7
|
-
const toDurableEvent = (message) => {
|
|
8
|
-
if (message.role === "assistant" && message.toolCalls) {
|
|
9
|
-
return message.toolCalls.map((call) => {
|
|
10
|
-
return { input: call.input, seq: message.seq, toolCallId: call.id, toolName: call.name, type: "call" };
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
if (message.role !== "tool") {
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
if (message.status === "awaiting_approval") {
|
|
17
|
-
return [
|
|
18
|
-
{
|
|
19
|
-
seq: message.seq,
|
|
20
|
-
type: "awaiting-approval",
|
|
21
|
-
...message.toolCallId === void 0 ? {} : { toolCallId: message.toolCallId },
|
|
22
|
-
...message.toolName === void 0 ? {} : { toolName: message.toolName }
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
}
|
|
26
|
-
return [
|
|
27
|
-
{
|
|
28
|
-
output: message.content,
|
|
29
|
-
seq: message.seq,
|
|
30
|
-
type: "result",
|
|
31
|
-
...message.status === "approved" || message.status === "rejected" ? { status: message.status } : {},
|
|
32
|
-
...message.toolCallId === void 0 ? {} : { toolCallId: message.toolCallId },
|
|
33
|
-
...message.toolName === void 0 ? {} : { toolName: message.toolName }
|
|
34
|
-
}
|
|
35
|
-
];
|
|
36
|
-
};
|
|
37
|
-
const useAgentToolEvents = (options) => {
|
|
38
|
-
const { api, limit, stream: streamReference, threadKey } = options;
|
|
39
|
-
const messagesArguments = () => {
|
|
40
|
-
const key = toValue(threadKey);
|
|
41
|
-
return limit === void 0 ? { key } : { key, limit };
|
|
42
|
-
};
|
|
43
|
-
const { data: history } = useSubscription(api.agents.agentMessages, messagesArguments);
|
|
44
|
-
const streamArguments = streamReference === void 0 ? "skip" : () => {
|
|
45
|
-
return { key: toValue(threadKey) };
|
|
46
|
-
};
|
|
47
|
-
const { chunks } = useStream(streamReference ?? NO_STREAM_REF, streamArguments);
|
|
48
|
-
const events = computed(() => {
|
|
49
|
-
const key = toValue(threadKey);
|
|
50
|
-
const durable = history.value ?? EMPTY_MESSAGES;
|
|
51
|
-
const derived = durable.flatMap((message) => toDurableEvent(message) ?? []);
|
|
52
|
-
for (const event of chunks.value) {
|
|
53
|
-
if (event.kind === "progress" && event.threadKey === key) {
|
|
54
|
-
derived.push({ data: event.data, toolCallId: event.toolCallId, type: "progress" });
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return derived;
|
|
58
|
-
});
|
|
59
|
-
return { events };
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export { useAgentToolEvents };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { getIdentityStore } from '@lunora/client/auth';
|
|
2
|
-
import { ref, onScopeDispose, readonly } from 'vue';
|
|
3
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
4
|
-
|
|
5
|
-
const useAuth = () => {
|
|
6
|
-
const client = useLunora();
|
|
7
|
-
const store = getIdentityStore(client);
|
|
8
|
-
const tokenRef = ref(client.getAuthToken());
|
|
9
|
-
const userRef = ref(store.getUser());
|
|
10
|
-
const onTokenChange = () => {
|
|
11
|
-
tokenRef.value = client.getAuthToken();
|
|
12
|
-
};
|
|
13
|
-
const onUserChange = () => {
|
|
14
|
-
userRef.value = store.getUser();
|
|
15
|
-
};
|
|
16
|
-
const unsubToken = client.onAuthTokenChange(onTokenChange);
|
|
17
|
-
const unsubUser = store.subscribe(onUserChange);
|
|
18
|
-
onScopeDispose(() => {
|
|
19
|
-
unsubToken();
|
|
20
|
-
unsubUser();
|
|
21
|
-
});
|
|
22
|
-
const setToken = (next) => {
|
|
23
|
-
client.setAuthToken(next);
|
|
24
|
-
};
|
|
25
|
-
return { setToken, token: readonly(tokenRef), user: readonly(userRef) };
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { useAuth };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { shallowRef, getCurrentScope, onScopeDispose } from 'vue';
|
|
2
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
3
|
-
|
|
4
|
-
const useConnectionStatus = () => {
|
|
5
|
-
const client = useLunora();
|
|
6
|
-
const status = shallowRef(client.connectionStatus());
|
|
7
|
-
const unsubscribe = client.onConnectionStatus((next) => {
|
|
8
|
-
status.value = next;
|
|
9
|
-
});
|
|
10
|
-
if (getCurrentScope()) {
|
|
11
|
-
onScopeDispose(unsubscribe);
|
|
12
|
-
} else {
|
|
13
|
-
console.warn(
|
|
14
|
-
"[@lunora/vue] useConnectionStatus called with no active effect scope — its listener will not be cleaned up automatically. Call it inside setup()/an effect scope."
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
return status;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { useConnectionStatus as default };
|