@lunora/vue 1.0.0-alpha.82 → 1.0.0-alpha.83

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Component, Ref, InjectionKey, App, MaybeRefOrGetter, ComputedRef, DeepReadonly, ShallowRef } from 'vue';
2
- import { Preloaded, LunoraClient, FunctionReference, User, ConnectionStatus, ReturnOf, ArgsOf, MutationCallOptions, MutatorHandle } from '@lunora/client';
2
+ import { Preloaded, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
3
3
  export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
@@ -72,6 +72,52 @@ interface UseQueryOptions {
72
72
  /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
73
73
  shardKey?: string;
74
74
  }
75
+ /**
76
+ * The reactive handle returned by {@link useAction} — the Vue counterpart to
77
+ * React's `useAction`, re-expressed with refs. The surface is identical across
78
+ * the Lunora adapters (`@lunora/solid`, `/svelte`): `data`/`error`/`pending`
79
+ * are refs you read in a template, and `call` is an awaitable that resolves with
80
+ * the server value (or rejects).
81
+ */
82
+ interface ActionHandle<F extends FunctionReference> {
83
+ /** Invoke the action. Resolves with the server value; rejects on failure. */
84
+ call: (args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
85
+ /** The latest invocation's resolved value, or `undefined` before the first success. */
86
+ data: Ref<ReturnOf<F> | undefined>;
87
+ /** The latest invocation's error, or `undefined`. */
88
+ error: Ref<Error | undefined>;
89
+ /** `true` while ANY invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
90
+ pending: Ref<boolean>;
91
+ /** Clear the latest `data`/`error` back to idle. */
92
+ reset: () => void;
93
+ }
94
+ /**
95
+ * Returns a reactive {@link ActionHandle} for the given action reference — the
96
+ * Vue equivalent of React's `useAction`.
97
+ *
98
+ * Actions were the one procedure kind with no adapter hook: `useQuery` and
99
+ * `useMutation` shipped in every adapter and nothing covered actions, so each
100
+ * app re-derived the same pending/error wrapper by hand.
101
+ *
102
+ * **Narrower than `useMutation` on purpose:** there are no `optimistic` /
103
+ * `optimisticUpdate` call options. An optimistic update patches the subscription
104
+ * cache on the assumption a write will land; an action is not a write — it runs
105
+ * in the Worker, may call a third party, and has no declared effect on any
106
+ * query. Offering the option would imply a rollback guarantee nothing can
107
+ * honour.
108
+ *
109
+ * `pending` is ref-counted across overlapping invocations of THIS handle, so it
110
+ * flips back to `false` only once every concurrent call has settled. That
111
+ * orchestration is the shared `createCallRunner` from `@lunora/client`; only the
112
+ * refs are adapter-specific.
113
+ *
114
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
115
+ * invocation (an earlier call settling later cannot clobber a newer one), a
116
+ * success clears `error`, and a failure leaves the previous `data` in place so a
117
+ * transient error does not blank the view. `reset()` clears both; it does not
118
+ * cancel an in-flight call, whose result still lands.
119
+ */
120
+ declare const useAction: <F extends FunctionReference>(function_: F) => ActionHandle<F>;
75
121
  /**
76
122
  * The lifecycle status stored on an agent thread. Client-safe mirror of
77
123
  * `@lunora/agent`'s `AgentThreadStatus` — re-declared here (rather than imported)
@@ -565,8 +611,12 @@ interface MutationHandle<F extends FunctionReference> {
565
611
  * `pending` is ref-counted across overlapping invocations of THIS handle, so it
566
612
  * flips back to `false` only once every concurrent call has settled. The
567
613
  * ref-counted pending + error-normalize orchestration is the shared
568
- * `createMutationRunner` from `@lunora/client`; only the refs are
569
- * adapter-specific.
614
+ * `createCallRunner` from `@lunora/client`; only the refs are adapter-specific.
615
+ *
616
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
617
+ * invocation (an earlier call settling later cannot clobber a newer one), a
618
+ * success clears `error`, and a failure leaves the previous `data` in place.
619
+ * `reset()` clears both; it does not cancel an in-flight call.
570
620
  */
571
621
  declare const useMutation: <F extends FunctionReference>(function_: F) => MutationHandle<F>;
572
622
  /**
@@ -982,7 +1032,7 @@ interface UseVoiceAgentResult {
982
1032
  * `createSocket`) so the composable is drivable outside a browser.
983
1033
  */
984
1034
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
985
- export { type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference,
1035
+ export { type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference,
986
1036
  /**
987
1037
  * `@lunora/vue` — the Vue adapter for Lunora.
988
1038
  *
@@ -1039,7 +1089,7 @@ createLunora, hydratePreloaded,
1039
1089
  * composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
1040
1090
  * package — see [Bring your framework](/docs/frameworks/bring-your-framework).
1041
1091
  */
1042
- provideLunora, subscribeToQuery, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery,
1092
+ provideLunora, subscribeToQuery, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery,
1043
1093
  /**
1044
1094
  * `@lunora/vue` — the Vue adapter for Lunora.
1045
1095
  *
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Component, Ref, InjectionKey, App, MaybeRefOrGetter, ComputedRef, DeepReadonly, ShallowRef } from 'vue';
2
- import { Preloaded, LunoraClient, FunctionReference, User, ConnectionStatus, ReturnOf, ArgsOf, MutationCallOptions, MutatorHandle } from '@lunora/client';
2
+ import { Preloaded, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
3
3
  export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
@@ -72,6 +72,52 @@ interface UseQueryOptions {
72
72
  /** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
73
73
  shardKey?: string;
74
74
  }
75
+ /**
76
+ * The reactive handle returned by {@link useAction} — the Vue counterpart to
77
+ * React's `useAction`, re-expressed with refs. The surface is identical across
78
+ * the Lunora adapters (`@lunora/solid`, `/svelte`): `data`/`error`/`pending`
79
+ * are refs you read in a template, and `call` is an awaitable that resolves with
80
+ * the server value (or rejects).
81
+ */
82
+ interface ActionHandle<F extends FunctionReference> {
83
+ /** Invoke the action. Resolves with the server value; rejects on failure. */
84
+ call: (args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
85
+ /** The latest invocation's resolved value, or `undefined` before the first success. */
86
+ data: Ref<ReturnOf<F> | undefined>;
87
+ /** The latest invocation's error, or `undefined`. */
88
+ error: Ref<Error | undefined>;
89
+ /** `true` while ANY invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
90
+ pending: Ref<boolean>;
91
+ /** Clear the latest `data`/`error` back to idle. */
92
+ reset: () => void;
93
+ }
94
+ /**
95
+ * Returns a reactive {@link ActionHandle} for the given action reference — the
96
+ * Vue equivalent of React's `useAction`.
97
+ *
98
+ * Actions were the one procedure kind with no adapter hook: `useQuery` and
99
+ * `useMutation` shipped in every adapter and nothing covered actions, so each
100
+ * app re-derived the same pending/error wrapper by hand.
101
+ *
102
+ * **Narrower than `useMutation` on purpose:** there are no `optimistic` /
103
+ * `optimisticUpdate` call options. An optimistic update patches the subscription
104
+ * cache on the assumption a write will land; an action is not a write — it runs
105
+ * in the Worker, may call a third party, and has no declared effect on any
106
+ * query. Offering the option would imply a rollback guarantee nothing can
107
+ * honour.
108
+ *
109
+ * `pending` is ref-counted across overlapping invocations of THIS handle, so it
110
+ * flips back to `false` only once every concurrent call has settled. That
111
+ * orchestration is the shared `createCallRunner` from `@lunora/client`; only the
112
+ * refs are adapter-specific.
113
+ *
114
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
115
+ * invocation (an earlier call settling later cannot clobber a newer one), a
116
+ * success clears `error`, and a failure leaves the previous `data` in place so a
117
+ * transient error does not blank the view. `reset()` clears both; it does not
118
+ * cancel an in-flight call, whose result still lands.
119
+ */
120
+ declare const useAction: <F extends FunctionReference>(function_: F) => ActionHandle<F>;
75
121
  /**
76
122
  * The lifecycle status stored on an agent thread. Client-safe mirror of
77
123
  * `@lunora/agent`'s `AgentThreadStatus` — re-declared here (rather than imported)
@@ -565,8 +611,12 @@ interface MutationHandle<F extends FunctionReference> {
565
611
  * `pending` is ref-counted across overlapping invocations of THIS handle, so it
566
612
  * flips back to `false` only once every concurrent call has settled. The
567
613
  * ref-counted pending + error-normalize orchestration is the shared
568
- * `createMutationRunner` from `@lunora/client`; only the refs are
569
- * adapter-specific.
614
+ * `createCallRunner` from `@lunora/client`; only the refs are adapter-specific.
615
+ *
616
+ * `data`/`error` follow the adapter-wide contract: both track the LATEST
617
+ * invocation (an earlier call settling later cannot clobber a newer one), a
618
+ * success clears `error`, and a failure leaves the previous `data` in place.
619
+ * `reset()` clears both; it does not cancel an in-flight call.
570
620
  */
571
621
  declare const useMutation: <F extends FunctionReference>(function_: F) => MutationHandle<F>;
572
622
  /**
@@ -982,7 +1032,7 @@ interface UseVoiceAgentResult {
982
1032
  * `createSocket`) so the composable is drivable outside a browser.
983
1033
  */
984
1034
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
985
- export { type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference,
1035
+ export { type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference,
986
1036
  /**
987
1037
  * `@lunora/vue` — the Vue adapter for Lunora.
988
1038
  *
@@ -1039,7 +1089,7 @@ createLunora, hydratePreloaded,
1039
1089
  * composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
1040
1090
  * package — see [Bring your framework](/docs/frameworks/bring-your-framework).
1041
1091
  */
1042
- provideLunora, subscribeToQuery, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery,
1092
+ provideLunora, subscribeToQuery, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery,
1043
1093
  /**
1044
1094
  * `@lunora/vue` — the Vue adapter for Lunora.
1045
1095
  *
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AuthLoading as o,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{useAgent as d}from"./packem_shared/useAgent-BngqmpN9.mjs";import{useAgentChat as A}from"./packem_shared/useAgentChat-Cx2Q0zEw.mjs";import{useAgentState as h}from"./packem_shared/useAgentState-B_LPf5ZX.mjs";import{useAgentToolEvents as l}from"./packem_shared/useAgentToolEvents-DYYeyrXW.mjs";import{useAuth as Q}from"./packem_shared/useAuth-DJ9902_4.mjs";import{default as b}from"./packem_shared/useConnectionStatus-BSFJBnmi.mjs";import{useFlag as E,useFlags as I}from"./packem_shared/useFlag-D9nbORR8.mjs";import{useMutation as P}from"./packem_shared/useMutation-DBAUj440.mjs";import{useMutator as v}from"./packem_shared/useMutator-CO7nXlRf.mjs";import{useInfiniteQuery as M,usePaginatedQuery as O}from"./packem_shared/useInfiniteQuery-qPTnyRUN.mjs";import{usePresence as U}from"./packem_shared/usePresence-BBMik0HU.mjs";import{subscribeToQuery as J,useQuery as K}from"./packem_shared/subscribeToQuery-DPfbYx11.mjs";import{useRateLimit as Y}from"./packem_shared/useRateLimit-zoPsflSG.mjs";import{useStream as k}from"./packem_shared/useStream-pSLl_8ix.mjs";import{useSubscription as w}from"./packem_shared/useSubscription-uZqOa1Pu.mjs";import{useVoiceAgent as B}from"./packem_shared/useVoiceAgent-CR6Tyf_3.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};
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-D9nbORR8.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-qPTnyRUN.mjs";import{usePresence as J}from"./packem_shared/usePresence-BBMik0HU.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};
@@ -0,0 +1 @@
1
+ import{createCallRunner as i}from"@lunora/client";import{shallowRef as n,ref as u}from"vue";import{useLunora as v}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const R=l=>{const a=v(),t=n(void 0),o=n(void 0),r=u(!1),s=()=>{t.value=void 0,o.value=void 0};return{call:i((e,c)=>a.action(l,e,c),{setError:e=>{o.value=e},setPending:e=>{r.value=e},setResult:e=>{t.value=e,o.value=void 0}}),data:t,error:o,pending:r,reset:s}};export{R as useAction};
@@ -1 +1 @@
1
- import{computed as o,toValue as a}from"vue";import{useMutation as s}from"./useMutation-DBAUj440.mjs";import{useSubscription as y}from"./useSubscription-uZqOa1Pu.mjs";const v={__lunoraRef:""},I=u=>{const{api:i,cancel:c,run:d,runArgs:l,threadKey:e}=u,r=s(d),m=s(c??v),{data:p}=y(i.agents.agentThread,()=>({key:a(e)})),n=o(()=>p.value),f=o(()=>n.value?.status),g=async(t,h)=>{await r.mutate({input:t,threadKey:a(e),...l,...h})};return{cancel:async()=>{const t=n.value?.instanceId;c===void 0||t===void 0||await m.mutate({instanceId:t,threadKey:a(e)})},pending:r.pending,run:g,status:f,thread:n}};export{v as NO_MUTATION_REF,I as useAgent};
1
+ import{computed as o,toValue as a}from"vue";import{useMutation as s}from"./useMutation-D6PkaNaE.mjs";import{useSubscription as y}from"./useSubscription-uZqOa1Pu.mjs";const v={__lunoraRef:""},I=u=>{const{api:i,cancel:c,run:d,runArgs:l,threadKey:e}=u,r=s(d),m=s(c??v),{data:p}=y(i.agents.agentThread,()=>({key:a(e)})),n=o(()=>p.value),f=o(()=>n.value?.status),g=async(t,h)=>{await r.mutate({input:t,threadKey:a(e),...l,...h})};return{cancel:async()=>{const t=n.value?.instanceId;c===void 0||t===void 0||await m.mutate({instanceId:t,threadKey:a(e)})},pending:r.pending,run:g,status:f,thread:n}};export{v as NO_MUTATION_REF,I as useAgent};
@@ -1 +1 @@
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-BngqmpN9.mjs";import{useMutation as m}from"./useMutation-DBAUj440.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
+ 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};
@@ -0,0 +1 @@
1
+ import{createCallRunner as v}from"@lunora/client";import{shallowRef as n,ref as c}from"vue";import{useLunora as d}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const R=a=>{const s=d(),o=n(void 0),t=n(void 0),r=c(!1),u=()=>{o.value=void 0,t.value=void 0},i=v((e,l)=>s.mutation(a,e,l),{setError:e=>{t.value=e},setPending:e=>{r.value=e},setResult:e=>{o.value=e,t.value=void 0}});return{data:o,error:t,mutate:i,pending:r,reset:u}};export{R as useMutation};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vue",
3
- "version": "1.0.0-alpha.82",
3
+ "version": "1.0.0-alpha.83",
4
4
  "description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -54,7 +54,7 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@lunora/client": "1.0.0-alpha.51",
57
+ "@lunora/client": "1.0.0-alpha.52",
58
58
  "@lunora/errors": "1.0.0-alpha.22",
59
59
  "@lunora/ratelimit": "1.0.0-alpha.23",
60
60
  "@lunora/runtime": "1.0.0-alpha.65",
@@ -1 +0,0 @@
1
- import{createMutationRunner as l}from"@lunora/client";import{shallowRef as n,ref as v}from"vue";import{useLunora as c}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const p=s=>{const a=c(),o=n(void 0),t=n(void 0),r=v(!1),u=()=>{o.value=void 0,t.value=void 0},i=l(a,s,{setError:e=>{t.value=e},setPending:e=>{r.value=e},setResult:e=>{o.value=e,t.value=void 0}});return{data:o,error:t,mutate:i,pending:r,reset:u}};export{p as useMutation};