@lunora/vue 1.0.0-alpha.100 → 1.0.0-alpha.102

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/README.md CHANGED
@@ -74,22 +74,26 @@ const { mutate, pending } = useMutation(api.messages.send);
74
74
 
75
75
  ## API
76
76
 
77
- | Composable | React equivalent | Description |
78
- | --------------------- | --------------------- | ------------------------------------------------------------------------------- |
79
- | `createLunora` | `LunoraProvider` | Vue plugin — call `app.use(createLunora(client))` at the app root. |
80
- | `useLunora` | `useLunora` | Inject the ambient `LunoraClient` from the nearest provider. |
81
- | `useQuery` | `useQuery` | Live query `ShallowRef` — re-subscribes when reactive args change. |
82
- | `useMutation` | `useMutation` | Optimistic mutation handle (`data`, `error`, `pending`, `mutate`, `reset`). |
83
- | `useSubscription` | `useSubscription` | Raw subscription `ShallowRef` — unbounded live stream. |
84
- | `usePaginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, and `results`. |
85
- | `useInfiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `usePaginatedQuery`. |
86
- | `useAuth` | `useAuth` | Reactive auth: readonly `token`/`user` refs plus `setToken`. |
87
- | `usePresence` | `usePresence` | Collaborative-awareness — heartbeat + live present-members `ShallowRef`. |
88
- | `useFlag` | `useFlag` | Live OpenFeature flag as a readonly `Ref` — holds `default` until resolved. |
89
- | `useFlags` | `useFlags` | Batch variant — a readonly `Ref` of one value per key in the defaults map. |
90
- | `useRateLimit` | `useRateLimit` | Client-side rate-limit mirror — `ok`, `disabled`, `retryAfter` as ComputedRefs. |
91
- | `useConnectionStatus` | `useConnectionStatus` | Reactive connection state (`idle`, `connecting`, `connected`, `offline`). |
92
- | `hydratePreloaded` | `usePreloadedQuery` | Seed a query synchronously from an SSR `Preloaded` token, then go live. |
77
+ | Composable | React equivalent | Description |
78
+ | --------------------- | --------------------- | --------------------------------------------------------------------------------- |
79
+ | `createLunora` | `LunoraProvider` | Vue plugin — call `app.use(createLunora(client))` at the app root. |
80
+ | `useLunora` | `useLunora` | Inject the ambient `LunoraClient` from the nearest provider. |
81
+ | `useQuery` | `useQuery` | Live query `ShallowRef` — re-subscribes when reactive args change. |
82
+ | `useMutation` | `useMutation` | Optimistic mutation handle (`data`, `error`, `pending`, `mutate`, `reset`). |
83
+ | `useSubscription` | `useSubscription` | Raw subscription `ShallowRef` — unbounded live stream. |
84
+ | `usePaginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, and `results`. |
85
+ | `useInfiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `usePaginatedQuery`. |
86
+ | `useAuth` | `useAuth` | Reactive auth: readonly `token`/`user` refs plus `setToken`. |
87
+ | `usePresence` | `usePresence` | Collaborative-awareness — heartbeat + live present-members `ShallowRef`. |
88
+ | `useFlag` | `useFlag` | Live OpenFeature flag as a readonly `Ref` — holds `default` until resolved. |
89
+ | `useFlags` | `useFlags` | Batch variant — a readonly `Ref` of one value per key in the defaults map. |
90
+ | `useRateLimit` | `useRateLimit` | Client-side rate-limit mirror — `ok`, `disabled`, `retryAfter` as ComputedRefs. |
91
+ | `useConnectionStatus` | `useConnectionStatus` | Reactive connection state (`idle`, `connecting`, `connected`, `offline`). |
92
+ | `hydratePreloaded` | `usePreloadedQuery` | Seed a query synchronously from an SSR `Preloaded` token, then go live. |
93
+ | `useAgentToolEvents` | `useAgentToolEvents` | One agent thread's tool lifecycle as a `ComputedRef` of discriminated events. |
94
+ | `useVoiceAgent` | `useVoiceAgent` | Full-duplex voice call — refs for status/transcript/level, `startCall`/`endCall`. |
95
+
96
+ `useVoiceAgent` opens nothing until `startCall()` — that call is what requests the microphone, so it must run from a user gesture. `endCall()` releases the socket, the mic tracks and the Web Audio graph, and `onScopeDispose` runs it for you on unmount.
93
97
 
94
98
  ## Related
95
99
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Component, Ref, InjectionKey, App, MaybeRefOrGetter, ComputedRef, DeepReadonly, ShallowRef } from 'vue';
2
- import { Preloaded, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
3
- export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
2
+ import { Preloaded, LunoraClient, SubscriptionErrorCallback, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
3
+ export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe, User } from '@lunora/client';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
6
6
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
@@ -32,8 +32,15 @@ declare const AuthLoading: Component;
32
32
  *
33
33
  * The subscription tears down with the surrounding effect scope (component
34
34
  * unmount or `effectScope().stop()`), inherited from `subscribeToQuery`.
35
+ *
36
+ * The ref is `Ref<T>`, not `Ref<T | undefined>`: `subscribeToQuery`'s ref widens
37
+ * to `undefined` because it also serves the unseeded `useQuery` case, but this
38
+ * entry point always passes `seed: preloaded.value`, so the "seeded
39
+ * synchronously, no loading flash" contract means it is never undefined. Every
40
+ * other adapter's `hydratePreloaded` returns `T`; narrowing here stops Vue
41
+ * consumers guarding a state that cannot occur.
35
42
  */
36
- declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Ref<T | undefined>;
43
+ declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Ref<T>;
37
44
  /**
38
45
  * Injection key carrying the {@link LunoraClient} down the component tree.
39
46
  * Exported so advanced consumers can inject it by hand; most apps use
@@ -69,6 +76,12 @@ declare const provideLunora: (client: LunoraClient) => void;
69
76
  declare const useLunora: () => LunoraClient;
70
77
  /** Options shared by the live-query composables. */
71
78
  interface UseQueryOptions {
79
+ /**
80
+ * Called when the server pushes a subscription-scoped error (an RLS denial, a
81
+ * query that starts failing server-side). Without a handler such an error has
82
+ * nowhere to go and the ref simply freezes at its last good value.
83
+ */
84
+ onError?: SubscriptionErrorCallback;
72
85
  /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
73
86
  shardKey?: string;
74
87
  }
@@ -566,8 +579,10 @@ type FlagValue = boolean | number | string | {
566
579
  *
567
580
  * Evaluation runs through whatever OpenFeature provider the app wired in
568
581
  * `lunora/flags.ts`; the read never throws — a provider error resolves the
569
- * default (the same fail-open contract as server-side `ctx.flags`). Call inside
570
- * `setup()` (or any active effect scope); the subscription tears down on unmount.
582
+ * default (the same fail-open contract as server-side `ctx.flags`) both an
583
+ * attach throw and a provider error pushed mid-session. Call inside `setup()`
584
+ * (or any active effect scope); the subscription tears down on unmount. During
585
+ * SSR no subscription opens at all and the ref stays at `defaultValue`.
571
586
  */
572
587
  declare const useFlag: <T extends FlagValue>(key: MaybeRefOrGetter<string>, defaultValue: T, context?: MaybeRefOrGetter<FlagContext | undefined>) => Readonly<Ref<T>>;
573
588
  /**
@@ -808,6 +823,10 @@ declare const subscribeToQuery: <F extends FunctionReference, T = ReturnOf<F>>(c
808
823
  *
809
824
  * Call inside `setup()` (or any active effect scope). For SSR seeding with no
810
825
  * loading flash, use `hydratePreloaded` instead.
826
+ *
827
+ * Pass `onError` to surface a subscription-scoped error the server pushes (an RLS
828
+ * denial, a query that starts failing server-side). Without it such an error is
829
+ * dropped and the ref just freezes at its last good value.
811
830
  */
812
831
  declare const useQuery: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<ArgsOf<F> | "skip">, options?: UseQueryOptions) => Ref<ReturnOf<F> | undefined>;
813
832
  interface UseRateLimitOptions {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Component, Ref, InjectionKey, App, MaybeRefOrGetter, ComputedRef, DeepReadonly, ShallowRef } from 'vue';
2
- import { Preloaded, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
3
- export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
2
+ import { Preloaded, LunoraClient, SubscriptionErrorCallback, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
3
+ export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe, User } from '@lunora/client';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
6
6
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
@@ -32,8 +32,15 @@ declare const AuthLoading: Component;
32
32
  *
33
33
  * The subscription tears down with the surrounding effect scope (component
34
34
  * unmount or `effectScope().stop()`), inherited from `subscribeToQuery`.
35
+ *
36
+ * The ref is `Ref<T>`, not `Ref<T | undefined>`: `subscribeToQuery`'s ref widens
37
+ * to `undefined` because it also serves the unseeded `useQuery` case, but this
38
+ * entry point always passes `seed: preloaded.value`, so the "seeded
39
+ * synchronously, no loading flash" contract means it is never undefined. Every
40
+ * other adapter's `hydratePreloaded` returns `T`; narrowing here stops Vue
41
+ * consumers guarding a state that cannot occur.
35
42
  */
36
- declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Ref<T | undefined>;
43
+ declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Ref<T>;
37
44
  /**
38
45
  * Injection key carrying the {@link LunoraClient} down the component tree.
39
46
  * Exported so advanced consumers can inject it by hand; most apps use
@@ -69,6 +76,12 @@ declare const provideLunora: (client: LunoraClient) => void;
69
76
  declare const useLunora: () => LunoraClient;
70
77
  /** Options shared by the live-query composables. */
71
78
  interface UseQueryOptions {
79
+ /**
80
+ * Called when the server pushes a subscription-scoped error (an RLS denial, a
81
+ * query that starts failing server-side). Without a handler such an error has
82
+ * nowhere to go and the ref simply freezes at its last good value.
83
+ */
84
+ onError?: SubscriptionErrorCallback;
72
85
  /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
73
86
  shardKey?: string;
74
87
  }
@@ -566,8 +579,10 @@ type FlagValue = boolean | number | string | {
566
579
  *
567
580
  * Evaluation runs through whatever OpenFeature provider the app wired in
568
581
  * `lunora/flags.ts`; the read never throws — a provider error resolves the
569
- * default (the same fail-open contract as server-side `ctx.flags`). Call inside
570
- * `setup()` (or any active effect scope); the subscription tears down on unmount.
582
+ * default (the same fail-open contract as server-side `ctx.flags`) both an
583
+ * attach throw and a provider error pushed mid-session. Call inside `setup()`
584
+ * (or any active effect scope); the subscription tears down on unmount. During
585
+ * SSR no subscription opens at all and the ref stays at `defaultValue`.
571
586
  */
572
587
  declare const useFlag: <T extends FlagValue>(key: MaybeRefOrGetter<string>, defaultValue: T, context?: MaybeRefOrGetter<FlagContext | undefined>) => Readonly<Ref<T>>;
573
588
  /**
@@ -808,6 +823,10 @@ declare const subscribeToQuery: <F extends FunctionReference, T = ReturnOf<F>>(c
808
823
  *
809
824
  * Call inside `setup()` (or any active effect scope). For SSR seeding with no
810
825
  * loading flash, use `hydratePreloaded` instead.
826
+ *
827
+ * Pass `onError` to surface a subscription-scoped error the server pushes (an RLS
828
+ * denial, a query that starts failing server-side). Without it such an error is
829
+ * dropped and the ref just freezes at its last good value.
811
830
  */
812
831
  declare const useQuery: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<ArgsOf<F> | "skip">, options?: UseQueryOptions) => Ref<ReturnOf<F> | undefined>;
813
832
  interface UseRateLimitOptions {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AuthLoading as r,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-nfI43dvD.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-kyzbcRHO.mjs";import{LUNORA_INJECTION_KEY as f,createLunora as m,provideLunora as p,useLunora as x}from"./packem_shared/LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{useAction as A}from"./packem_shared/useAction-C4VLsh4M.mjs";import{useAgent as d}from"./packem_shared/useAgent-Bji8ptsw.mjs";import{useAgentChat as h}from"./packem_shared/useAgentChat-C3Q3Wf5w.mjs";import{useAgentState as l}from"./packem_shared/useAgentState-B_LPf5ZX.mjs";import{useAgentToolEvents as Q}from"./packem_shared/useAgentToolEvents-DYYeyrXW.mjs";import{useAuth as b}from"./packem_shared/useAuth-DJ9902_4.mjs";import{default as E}from"./packem_shared/useConnectionStatus-BSFJBnmi.mjs";import{useFlag as N,useFlags as P}from"./packem_shared/useFlag-_IYnlB1G.mjs";import{useMutation as v}from"./packem_shared/useMutation-D6PkaNaE.mjs";import{useMutator as M}from"./packem_shared/useMutator-CO7nXlRf.mjs";import{useInfiniteQuery as R,usePaginatedQuery as U}from"./packem_shared/useInfiniteQuery-BRhjOdWk.mjs";import{usePresence as J}from"./packem_shared/usePresence-D5H9k1UX.mjs";import{subscribeToQuery as V,useQuery as Y}from"./packem_shared/subscribeToQuery-DPfbYx11.mjs";import{useRateLimit as k}from"./packem_shared/useRateLimit-zoPsflSG.mjs";import{useStream as w}from"./packem_shared/useStream-pSLl_8ix.mjs";import{useSubscription as B}from"./packem_shared/useSubscription-uZqOa1Pu.mjs";import{useVoiceAgent as G}from"./packem_shared/useVoiceAgent-CR6Tyf_3.mjs";export{r as AuthLoading,t as Authenticated,f as LUNORA_INJECTION_KEY,u as Unauthenticated,m as createLunora,a as hydratePreloaded,p as provideLunora,V as subscribeToQuery,A as useAction,d as useAgent,h as useAgentChat,l as useAgentState,Q as useAgentToolEvents,b as useAuth,E as useConnectionStatus,N as useFlag,P as useFlags,R as useInfiniteQuery,x as useLunora,v as useMutation,M as useMutator,U as usePaginatedQuery,J as usePresence,Y as useQuery,k as useRateLimit,w as useStream,B as useSubscription,G as useVoiceAgent};
1
+ import{AuthLoading as r,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-nfI43dvD.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-BtfKkWB8.mjs";import{LUNORA_INJECTION_KEY as f,createLunora as m,provideLunora as p,useLunora as x}from"./packem_shared/LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{useAction as A}from"./packem_shared/useAction-C4VLsh4M.mjs";import{useAgent as d}from"./packem_shared/useAgent-Bji8ptsw.mjs";import{useAgentChat as h}from"./packem_shared/useAgentChat-BZBKErKQ.mjs";import{useAgentState as l}from"./packem_shared/useAgentState-B_LPf5ZX.mjs";import{useAgentToolEvents as Q}from"./packem_shared/useAgentToolEvents-DYYeyrXW.mjs";import{useAuth as b}from"./packem_shared/useAuth-DJ9902_4.mjs";import{default as E}from"./packem_shared/useConnectionStatus-BSFJBnmi.mjs";import{useFlag as N,useFlags as P}from"./packem_shared/useFlag-CCgWKa-m.mjs";import{useMutation as v}from"./packem_shared/useMutation-D6PkaNaE.mjs";import{useMutator as M}from"./packem_shared/useMutator-CO7nXlRf.mjs";import{useInfiniteQuery as R,usePaginatedQuery as U}from"./packem_shared/useInfiniteQuery-BRhjOdWk.mjs";import{usePresence as J}from"./packem_shared/usePresence-D5H9k1UX.mjs";import{subscribeToQuery as V,useQuery as Y}from"./packem_shared/subscribeToQuery-CHbbz_3v.mjs";import{useRateLimit as k}from"./packem_shared/useRateLimit-zoPsflSG.mjs";import{useStream as w}from"./packem_shared/useStream-pSLl_8ix.mjs";import{useSubscription as B}from"./packem_shared/useSubscription-uZqOa1Pu.mjs";import{useVoiceAgent as G}from"./packem_shared/useVoiceAgent-CR6Tyf_3.mjs";export{r as AuthLoading,t as Authenticated,f as LUNORA_INJECTION_KEY,u as Unauthenticated,m as createLunora,a as hydratePreloaded,p as provideLunora,V as subscribeToQuery,A as useAction,d as useAgent,h as useAgentChat,l as useAgentState,Q as useAgentToolEvents,b as useAuth,E as useConnectionStatus,N as useFlag,P as useFlags,R as useInfiniteQuery,x as useLunora,v as useMutation,M as useMutator,U as usePaginatedQuery,J as usePresence,Y as useQuery,k as useRateLimit,w as useStream,B as useSubscription,G as useVoiceAgent};
@@ -1 +1 @@
1
- import{useLunora as s}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{subscribeToQuery as u}from"./subscribeToQuery-DPfbYx11.mjs";const d=e=>{const r=s(),{args:n,functionPath:o,shardKey:t,value:c}=e;return u(r,{__lunoraRef:o},n,{seed:c,shardKey:t})};export{d as hydratePreloaded};
1
+ import{useLunora as s}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{subscribeToQuery as u}from"./subscribeToQuery-CHbbz_3v.mjs";const d=e=>{const r=s(),{args:n,functionPath:o,shardKey:t,value:c}=e;return u(r,{__lunoraRef:o},n,{seed:c,shardKey:t})};export{d as hydratePreloaded};
@@ -0,0 +1 @@
1
+ import{createQuerySubscription as b}from"@lunora/client/query";import{shallowRef as i,watch as f,toValue as p}from"vue";import{i as n}from"./is-browser-BEdfLJHK.mjs";import{useLunora as l}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as y}from"./scope-dispose-Mq3k4nvP.mjs";const D=(s,t,e,o={})=>{const r=i(o.seed);if(n()){const a=s.subscribe(t,e,u=>{r.value=u},{shardKey:o.shardKey});y(a)}return r},E=(s,t,e={})=>{const o=l(),r=i(void 0);return f(()=>p(t),(a,u,c)=>{if(!n())return;const m=b(o,s,a,{onData:d=>{r.value=d},onError:e.onError,onReset:()=>{r.value=void 0}},{shardKey:e.shardKey});c(m)},{immediate:!0}),r};export{D as subscribeToQuery,E as useQuery};
@@ -0,0 +1 @@
1
+ import{reconcileOptimistic as y,maxSeq as A}from"@lunora/client";import{ref as D,watch as N,toValue as s,computed as c}from"vue";import{NO_MUTATION_REF as F}from"./useAgent-Bji8ptsw.mjs";import{useMutation as m}from"./useMutation-D6PkaNaE.mjs";import{useStream as U}from"./useStream-pSLl_8ix.mjs";import{useSubscription as w}from"./useSubscription-uZqOa1Pu.mjs";const V={__lunoraRef:""},W=R=>{const{api:u,cancel:v,limit:p,send:k,sendArgs:x,stream:h,threadKey:a}=R,{data:I}=w(u.agents.agentMessages,()=>{const t=s(a);return p===void 0?{key:t}:{key:t,limit:p}}),{data:M}=w(u.agents.agentThread,()=>({key:s(a)})),S=h===void 0?"skip":()=>({key:s(a)}),{chunks:_}=U(h??V,S),b=m(k),K=m(v??F),T=m(u.agents.agentResolveApproval),r=D([]);let f=0;N(()=>s(a),()=>{r.value=[]});const l=c(()=>M.value),j=c(()=>l.value?.status),i=c(()=>I.value??[]),q=c(()=>{const t=i.value,n=y(r.value,t);if(n.length===0)return t;const e=A(t);return[...t,...n.map((o,d)=>({content:o.content,optimistic:!0,role:"user",seq:e+1+d}))]}),E=c(()=>{const t=s(a),n=i.value.filter(e=>e.role==="assistant").length;return _.value.filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=n).map(e=>e.text).join("")}),O=async(t,n)=>{const e=f;f+=1;const o=A(i.value);r.value=[...y(r.value,i.value),{content:t,id:e,maxDurableSeqAtSend:o}];try{await b.mutate({input:t,threadKey:s(a),...x,...n})}catch(d){throw r.value=r.value.filter(C=>C.id!==e),d}},g=async(t,n,e)=>{const o=l.value?.instanceId;if(o===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await T.mutate({decision:t,instanceId:o,threadKey:s(a),toolCallId:n,...e===void 0?{}:{note:e}})};return{approve:async(t,n)=>g("approve",t,n),cancel:async()=>{const t=l.value?.instanceId;v===void 0||t===void 0||await K.mutate({instanceId:t,threadKey:s(a)})},messages:q,reject:async(t,n)=>g("reject",t,n),send:O,status:j,streamingText:E}};export{W as useAgentChat};
@@ -0,0 +1 @@
1
+ import{shallowRef as l,watch as f,toValue as s}from"vue";import{i as b}from"./is-browser-BEdfLJHK.mjs";import{s as m}from"./stable-key-B_BlboiY.mjs";import{useLunora as _}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const k="__lunora_flags__:eval",F=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},$={__lunoraRef:k},d=(t,e,o)=>{try{return t.subscribe($,{context:e.context,default:e.default,key:e.key,type:F(e.default)},r=>{o(r)},{onError:()=>{o(e.default)}})}catch{return()=>{}}},p=t=>t===void 0?"":m(t),L=(t,e,o)=>{const r=_(),u=l(e);return f(()=>`${s(t)}\0${p(s(o))}`,(v,y,i)=>{const a=s(t),c=s(o);u.value=e,b()&&i(d(r,{context:c,default:e,key:a},n=>{u.value=n}))},{immediate:!0}),u},R=(t,e)=>{const o=_(),r=l(t),u=m(t);return f(()=>`${u}\0${p(s(e))}`,(v,y,i)=>{const a=s(e);if(r.value=t,!b())return;const c=[];for(const[n,x]of Object.entries(t))c.push(d(o,{context:a,default:x,key:n},h=>{r.value={...r.value,[n]:h}}));i(()=>{for(const n of c)n()})},{immediate:!0}),r};export{L as useFlag,R as useFlags};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vue",
3
- "version": "1.0.0-alpha.100",
3
+ "version": "1.0.0-alpha.102",
4
4
  "description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -54,9 +54,9 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@lunora/client": "1.0.0-alpha.65",
57
+ "@lunora/client": "1.0.0-alpha.67",
58
58
  "@lunora/errors": "1.0.0-alpha.26",
59
- "@lunora/ratelimit": "1.0.0-alpha.30",
59
+ "@lunora/ratelimit": "1.0.0-alpha.31",
60
60
  "@visulima/storage-client": "1.0.2"
61
61
  },
62
62
  "peerDependencies": {
@@ -1 +0,0 @@
1
- import{createQuerySubscription as b}from"@lunora/client/query";import{shallowRef as i,watch as p,toValue as f}from"vue";import{i as n}from"./is-browser-BEdfLJHK.mjs";import{useLunora as l}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as y}from"./scope-dispose-Mq3k4nvP.mjs";const D=(o,s,t,e={})=>{const r=i(e.seed);if(n()){const a=o.subscribe(s,t,u=>{r.value=u},{shardKey:e.shardKey});y(a)}return r},R=(o,s,t={})=>{const e=l(),r=i(void 0);return p(()=>f(s),(a,u,c)=>{if(!n())return;const m=b(e,o,a,{onData:d=>{r.value=d},onReset:()=>{r.value=void 0}},{shardKey:t.shardKey});c(m)},{immediate:!0}),r};export{D as subscribeToQuery,R as useQuery};
@@ -1 +0,0 @@
1
- import{reconcileOptimistic as y,maxSeq as A}from"@lunora/client";import{ref as D,computed as c,toValue as s}from"vue";import{NO_MUTATION_REF as N}from"./useAgent-Bji8ptsw.mjs";import{useMutation as m}from"./useMutation-D6PkaNaE.mjs";import{useStream as F}from"./useStream-pSLl_8ix.mjs";import{useSubscription as R}from"./useSubscription-uZqOa1Pu.mjs";const U={__lunoraRef:""},Q=k=>{const{api:u,cancel:p,limit:v,send:w,sendArgs:x,stream:h,threadKey:a}=k,{data:I}=R(u.agents.agentMessages,()=>{const t=s(a);return v===void 0?{key:t}:{key:t,limit:v}}),{data:M}=R(u.agents.agentThread,()=>({key:s(a)})),S=h===void 0?"skip":()=>({key:s(a)}),{chunks:_}=F(h??U,S),b=m(w),K=m(p??N),T=m(u.agents.agentResolveApproval),o=D([]);let f=0;const l=c(()=>M.value),j=c(()=>l.value?.status),i=c(()=>I.value??[]),q=c(()=>{const t=i.value,n=y(o.value,t);if(n.length===0)return t;const e=A(t);return[...t,...n.map((r,d)=>({content:r.content,optimistic:!0,role:"user",seq:e+1+d}))]}),E=c(()=>{const t=s(a),n=i.value.filter(e=>e.role==="assistant").length;return _.value.filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=n).map(e=>e.text).join("")}),O=async(t,n)=>{const e=f;f+=1;const r=A(i.value);o.value=[...y(o.value,i.value),{content:t,id:e,maxDurableSeqAtSend:r}];try{await b.mutate({input:t,threadKey:s(a),...x,...n})}catch(d){throw o.value=o.value.filter(C=>C.id!==e),d}},g=async(t,n,e)=>{const r=l.value?.instanceId;if(r===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await T.mutate({decision:t,instanceId:r,threadKey:s(a),toolCallId:n,...e===void 0?{}:{note:e}})};return{approve:async(t,n)=>g("approve",t,n),cancel:async()=>{const t=l.value?.instanceId;p===void 0||t===void 0||await K.mutate({instanceId:t,threadKey:s(a)})},messages:q,reject:async(t,n)=>g("reject",t,n),send:O,status:j,streamingText:E}};export{Q as useAgentChat};
@@ -1 +0,0 @@
1
- import{shallowRef as _,watch as m,toValue as n}from"vue";import{s as p}from"./stable-key-B_BlboiY.mjs";import{useLunora as v}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const $="__lunora_flags__:eval",y=e=>{const t=typeof e;return t==="boolean"||t==="number"||t==="string"?t:"object"},d={__lunoraRef:$},h=e=>e===void 0?"":p(e),C=(e,t,c)=>{const r=v(),a=y(t),u=_(t);return m(()=>`${n(e)}\0${h(n(c))}`,(g,f,l)=>{const i=n(e),s=n(c);u.value=t;let o;try{o=r.subscribe(d,{context:s,default:t,key:i,type:a},b=>{u.value=b})}catch{return}l(o)},{immediate:!0}),u},F=(e,t)=>{const c=v(),r=_(e),a=p(e);return m(()=>`${a}\0${h(n(t))}`,(u,g,f)=>{const l=n(t);r.value=e;const i=[];for(const[s,o]of Object.entries(e))try{i.push(c.subscribe(d,{context:l,default:o,key:s,type:y(o)},b=>{r.value={...r.value,[s]:b}}))}catch{}f(()=>{for(const s of i)s()})},{immediate:!0}),r};export{C as useFlag,F as useFlags};