@lunora/angular 1.0.0-alpha.9 → 1.0.0-alpha.90

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.
Files changed (50) hide show
  1. package/README.md +42 -0
  2. package/dist/index.d.mts +879 -689
  3. package/dist/index.d.ts +879 -689
  4. package/dist/index.mjs +1 -19
  5. package/dist/packem_shared/LUNORA_CLIENT-B0toApHY.mjs +1 -0
  6. package/dist/packem_shared/agent-BCt1D_wQ.mjs +1 -0
  7. package/dist/packem_shared/agentChat-DMMjTLnF.mjs +1 -0
  8. package/dist/packem_shared/agentState-Cdyss0S4.mjs +1 -0
  9. package/dist/packem_shared/agentToolEvents-BOp6-TK8.mjs +1 -0
  10. package/dist/packem_shared/auth-C3dB8sYS.mjs +1 -0
  11. package/dist/packem_shared/connectionStatus-UhmuwzMa.mjs +1 -0
  12. package/dist/packem_shared/flag-BJxkgJR2.mjs +1 -0
  13. package/dist/packem_shared/hydratePreloaded-gUUl_6tS.mjs +1 -0
  14. package/dist/packem_shared/infiniteQuery-yZS4F7PI.mjs +1 -0
  15. package/dist/packem_shared/liveQuery-ZIgKq4et.mjs +1 -0
  16. package/dist/packem_shared/mutate-BZvLQLyu.mjs +1 -0
  17. package/dist/packem_shared/mutator-DjG1yGk8.mjs +1 -0
  18. package/dist/packem_shared/platform-DNlq-CRU.mjs +1 -0
  19. package/dist/packem_shared/presence-DUkZtSSL.mjs +1 -0
  20. package/dist/packem_shared/rateLimit-B3h9qzh-.mjs +1 -0
  21. package/dist/packem_shared/runAction-BfiPq4Xz.mjs +1 -0
  22. package/dist/packem_shared/stream-CVSnLbC2.mjs +1 -0
  23. package/dist/packem_shared/subscription-B_Xj8Ezd.mjs +1 -0
  24. package/dist/packem_shared/voiceAgent-CyPFWGUt.mjs +1 -0
  25. package/dist/server.d.mts +1 -0
  26. package/dist/server.d.ts +1 -0
  27. package/dist/server.mjs +1 -0
  28. package/dist/upload.d.mts +57 -0
  29. package/dist/upload.d.ts +57 -0
  30. package/dist/upload.mjs +1 -0
  31. package/package.json +12 -3
  32. package/dist/packem_shared/LUNORA_CLIENT-DHUfNu9x.mjs +0 -23
  33. package/dist/packem_shared/agent-DDKvrG4u.mjs +0 -31
  34. package/dist/packem_shared/agentChat-C7kUEwO9.mjs +0 -96
  35. package/dist/packem_shared/agentState-C8GWf3t3.mjs +0 -10
  36. package/dist/packem_shared/agentToolEvents-sXgYggvi.mjs +0 -59
  37. package/dist/packem_shared/auth-Df9N87Z4.mjs +0 -27
  38. package/dist/packem_shared/connectionStatus-BlLodleK.mjs +0 -15
  39. package/dist/packem_shared/flag-CGBo90HJ.mjs +0 -70
  40. package/dist/packem_shared/hydratePreloaded-DIpD1cAM.mjs +0 -33
  41. package/dist/packem_shared/infiniteQuery-nboKfr5E.mjs +0 -221
  42. package/dist/packem_shared/liveQuery-DVxKidjM.mjs +0 -32
  43. package/dist/packem_shared/mutate-D3rEHwbb.mjs +0 -8
  44. package/dist/packem_shared/mutator-BHL8bakL.mjs +0 -19
  45. package/dist/packem_shared/platform-Dg8Bppgq.mjs +0 -14
  46. package/dist/packem_shared/presence-BTuq19dS.mjs +0 -77
  47. package/dist/packem_shared/rateLimit-I4kRT9qV.mjs +0 -58
  48. package/dist/packem_shared/stream-PL64AghO.mjs +0 -47
  49. package/dist/packem_shared/subscription-oZ-WTmpp.mjs +0 -39
  50. package/dist/packem_shared/voiceAgent-DwbrDnB9.mjs +0 -401
package/dist/index.mjs CHANGED
@@ -1,19 +1 @@
1
- export { agent } from './packem_shared/agent-DDKvrG4u.mjs';
2
- export { agentChat } from './packem_shared/agentChat-C7kUEwO9.mjs';
3
- export { agentState } from './packem_shared/agentState-C8GWf3t3.mjs';
4
- export { agentToolEvents } from './packem_shared/agentToolEvents-sXgYggvi.mjs';
5
- export { auth } from './packem_shared/auth-Df9N87Z4.mjs';
6
- export { LUNORA_CLIENT, injectLunoraClient, provideLunora } from './packem_shared/LUNORA_CLIENT-DHUfNu9x.mjs';
7
- export { connectionStatus } from './packem_shared/connectionStatus-BlLodleK.mjs';
8
- export { flag, flags } from './packem_shared/flag-CGBo90HJ.mjs';
9
- export { hydratePreloaded } from './packem_shared/hydratePreloaded-DIpD1cAM.mjs';
10
- export { liveQuery } from './packem_shared/liveQuery-DVxKidjM.mjs';
11
- export { mutate } from './packem_shared/mutate-D3rEHwbb.mjs';
12
- export { mutator } from './packem_shared/mutator-BHL8bakL.mjs';
13
- export { infiniteQuery, paginatedQuery } from './packem_shared/infiniteQuery-nboKfr5E.mjs';
14
- export { presence } from './packem_shared/presence-BTuq19dS.mjs';
15
- export { rateLimit } from './packem_shared/rateLimit-I4kRT9qV.mjs';
16
- export { stream } from './packem_shared/stream-PL64AghO.mjs';
17
- export { subscription } from './packem_shared/subscription-oZ-WTmpp.mjs';
18
- export { voiceAgent } from './packem_shared/voiceAgent-DwbrDnB9.mjs';
19
- export { SKIP } from '@lunora/client/query';
1
+ import{agent as t}from"./packem_shared/agent-BCt1D_wQ.mjs";import{agentChat as m}from"./packem_shared/agentChat-DMMjTLnF.mjs";import{agentState as f}from"./packem_shared/agentState-Cdyss0S4.mjs";import{agentToolEvents as n}from"./packem_shared/agentToolEvents-BOp6-TK8.mjs";import{auth as i,authGate as u}from"./packem_shared/auth-C3dB8sYS.mjs";import{LUNORA_CLIENT as c,injectLunoraClient as s,provideLunora as l}from"./packem_shared/LUNORA_CLIENT-B0toApHY.mjs";import{connectionStatus as L}from"./packem_shared/connectionStatus-UhmuwzMa.mjs";import{flag as v,flags as y}from"./packem_shared/flag-BJxkgJR2.mjs";import{hydratePreloaded as C}from"./packem_shared/hydratePreloaded-gUUl_6tS.mjs";import{liveQuery as S}from"./packem_shared/liveQuery-ZIgKq4et.mjs";import{mutate as I}from"./packem_shared/mutate-BZvLQLyu.mjs";import{mutator as P}from"./packem_shared/mutator-DjG1yGk8.mjs";import{infiniteQuery as b,paginatedQuery as j}from"./packem_shared/infiniteQuery-yZS4F7PI.mjs";import{presence as K}from"./packem_shared/presence-DUkZtSSL.mjs";import{rateLimit as R}from"./packem_shared/rateLimit-B3h9qzh-.mjs";import{runAction as _}from"./packem_shared/runAction-BfiPq4Xz.mjs";import{stream as q}from"./packem_shared/stream-CVSnLbC2.mjs";import{subscription as z}from"./packem_shared/subscription-B_Xj8Ezd.mjs";import{voiceAgent as D}from"./packem_shared/voiceAgent-CyPFWGUt.mjs";import{SKIP as H}from"@lunora/client/query";export{c as LUNORA_CLIENT,H as SKIP,t as agent,m as agentChat,f as agentState,n as agentToolEvents,i as auth,u as authGate,L as connectionStatus,v as flag,y as flags,C as hydratePreloaded,b as infiniteQuery,s as injectLunoraClient,S as liveQuery,I as mutate,P as mutator,j as paginatedQuery,K as presence,l as provideLunora,R as rateLimit,_ as runAction,q as stream,z as subscription,D as voiceAgent};
@@ -0,0 +1 @@
1
+ import{InjectionToken as t,makeEnvironmentProviders as i,inject as c}from"@angular/core";import{LunoraClient as r}from"@lunora/client";const o=()=>globalThis.location?.origin??"",e=new t("lunora.client",{factory:()=>new r({url:o()}),providedIn:"root"}),s=(n={})=>i([{provide:e,useFactory:()=>n instanceof r?n:new r({...n,url:n.url??o()})}]),a=()=>c(e),m=n=>n??a();export{e as LUNORA_CLIENT,a as injectLunoraClient,s as provideLunora,m as resolveLunoraClient};
@@ -0,0 +1 @@
1
+ import{computed as o,signal as R}from"@angular/core";import{resolveLunoraClient as h}from"./LUNORA_CLIENT-B0toApHY.mjs";import{subscription as v}from"./subscription-B_Xj8Ezd.mjs";const x=t=>{const{api:i,cancel:c,onError:d,run:l,runArgs:u,threadKey:n}=t,a=h(t.client),{data:f,error:m}=v(i.agents.agentThread,{key:n},{client:a,destroyRef:t.destroyRef,onError:d}),r=o(()=>f()),y=o(()=>r()?.status),s=R(!1),g=async(e,p)=>{s.set(!0);try{await a.mutation(l,{input:e,threadKey:n,...u,...p})}finally{s.set(!1)}};return{cancel:async()=>{const e=r()?.instanceId;c===void 0||e===void 0||await a.mutation(c,{instanceId:e,threadKey:n})},error:m,pending:s.asReadonly(),run:g,status:y,thread:r}};export{x as agent};
@@ -0,0 +1 @@
1
+ import{computed as a,signal as L}from"@angular/core";import{reconcileOptimistic as k,maxSeq as w}from"@lunora/client";import{resolveLunoraClient as N}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as $}from"./stream-CVSnLbC2.mjs";import{subscription as x}from"./subscription-B_Xj8Ezd.mjs";const z={__lunoraRef:""},W=m=>{const{api:d,cancel:g,limit:h,onError:f,send:A,sendArgs:E,stream:y,threadKey:r}=m,s=N(m.client),{destroyRef:l}=m,b=h===void 0?{key:r}:{key:r,limit:h},{data:I,error:S}=x(d.agents.agentMessages,b,{client:s,destroyRef:l,onError:f}),{data:j,error:q}=x(d.agents.agentThread,{key:r},{client:s,destroyRef:l,onError:f}),C=a(()=>S()??q()),_=y===void 0?"skip":{key:r},{chunks:D}=$(y??z,_,{client:s,destroyRef:l}),c=L([]);let v=0;const u=a(()=>j()),T=a(()=>u()?.status),i=a(()=>I()??[]),K=a(()=>{const t=i(),e=k(c(),t);if(e.length===0)return t;const n=w(t);return[...t,...e.map((o,p)=>({content:o.content,optimistic:!0,role:"user",seq:n+1+p}))]}),M=a(()=>{const t=i().filter(e=>e.role==="assistant").length;return D().filter(e=>e.kind!=="progress"&&e.threadKey===r&&e.turn>=t).map(e=>e.text).join("")}),O=async(t,e)=>{const n=v;v+=1;const o=w(i());c.set([...k(c(),i()),{content:t,id:n,maxDurableSeqAtSend:o}]);try{await s.mutation(A,{input:t,threadKey:r,...E,...e})}catch(p){throw c.set(c().filter(F=>F.id!==n)),p}},R=async(t,e,n)=>{const o=u()?.instanceId;if(o===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await s.mutation(d.agents.agentResolveApproval,{decision:t,instanceId:o,threadKey:r,toolCallId:e,...n===void 0?{}:{note:n}})};return{approve:async(t,e)=>R("approve",t,e),cancel:async()=>{const t=u()?.instanceId;g===void 0||t===void 0||await s.mutation(g,{instanceId:t,threadKey:r})},error:C,messages:K,reject:async(t,e)=>R("reject",t,e),send:O,status:T,streamingText:M}};export{W as agentChat};
@@ -0,0 +1 @@
1
+ import{computed as c}from"@angular/core";import{subscription as n}from"./subscription-B_Xj8Ezd.mjs";const d=t=>{const{data:e,error:r}=n(t.api.agents.agentState,{key:t.threadKey},{client:t.client,destroyRef:t.destroyRef}),a=c(()=>e());return{error:r,state:a}};export{d as agentState};
@@ -0,0 +1 @@
1
+ import{computed as v}from"@angular/core";import{resolveLunoraClient as f}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as C}from"./stream-CVSnLbC2.mjs";import{subscription as y}from"./subscription-B_Xj8Ezd.mjs";const I={__lunoraRef:""},N=[],m=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(l=>({input:l.input,seq:t.seq,toolCallId:l.id,toolName:l.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}}]},R=t=>{const{api:l,limit:n,stream:e,threadKey:r}=t,a=f(t.client),{destroyRef:i}=t,u=n===void 0?{key:r}:{key:r,limit:n},{data:p}=y(l.agents.agentMessages,u,{client:a,destroyRef:i}),s=e===void 0?"skip":{key:r},{chunks:c}=C(e??I,s,{client:a,destroyRef:i});return{events:v(()=>{const d=(p()??N).flatMap(o=>m(o)??[]);for(const o of c())o.kind==="progress"&&o.threadKey===r&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}};export{R as agentToolEvents};
@@ -0,0 +1 @@
1
+ import{inject as h,DestroyRef as k,signal as o,computed as c}from"@angular/core";import{getIdentityStore as l,isLoadingStatus as y,isAuthenticatedStatus as m}from"@lunora/client/auth";import{resolveLunoraClient as A}from"./LUNORA_CLIENT-B0toApHY.mjs";const T=(s={})=>{const t=A(s.client),n=s.destroyRef??h(k),e=l(t),u=o(t.getAuthToken()),r=o(e.getUser()),a=o(e.getStatus()),i=t.onAuthTokenChange(()=>{u.set(t.getAuthToken())}),d=e.subscribe(()=>{r.set(e.getUser()),a.set(e.getStatus())});return n.onDestroy(()=>{i(),d()}),{setToken:g=>{t.setAuthToken(g)},status:a.asReadonly(),token:u.asReadonly(),user:r.asReadonly()}},p=(s={})=>{const{status:t}=T(s),n=c(()=>y(t()));return{isAuthenticated:c(()=>m(t())),isLoading:n}};export{T as auth,p as authGate};
@@ -0,0 +1 @@
1
+ import{inject as r,DestroyRef as i,signal as a}from"@angular/core";import{resolveLunoraClient as u}from"./LUNORA_CLIENT-B0toApHY.mjs";const y=(t={})=>{const n=u(t.client),e=t.destroyRef??r(i),o=a(n.connectionStatus()),s=n.onConnectionStatus(c=>{o.set(c)});return e.onDestroy(s),o.asReadonly()};export{y as connectionStatus};
@@ -0,0 +1 @@
1
+ import{inject as l,DestroyRef as u,signal as a}from"@angular/core";import{resolveLunoraClient as i}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as d}from"./platform-DNlq-CRU.mjs";const m="__lunora_flags__:eval",_=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:m},y=(t,e,n)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:_(e.default)},c=>{n(c)},{onError:()=>{n(e.default)}})}catch{return()=>{}}},k=(t,e,n={})=>{const c=i(n.client),f=n.destroyRef===void 0,o=n.destroyRef??l(u),r=a(e);return d(f)&&o.onDestroy(y(c,{default:e,key:t},s=>{r.set(s)})),r.asReadonly()},h=(t,e={})=>{const n=i(e.client),c=e.destroyRef===void 0,f=e.destroyRef??l(u),o=a({...t});if(!d(c))return o.asReadonly();const r=[];for(const[s,b]of Object.entries(t))r.push(y(n,{default:b,key:s},R=>{o.set({...o(),[s]:R})}));return f.onDestroy(()=>{for(const s of r)s()}),o.asReadonly()};export{k as flag,h as flags};
@@ -0,0 +1 @@
1
+ import{inject as m,DestroyRef as b,signal as n}from"@angular/core";import{resolveLunoraClient as v}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as h}from"./platform-DNlq-CRU.mjs";const x=(s,e={})=>{const c=v(e.client),a=e.destroyRef===void 0,i=e.destroyRef??m(b),{args:d,functionPath:f,shardKey:l,value:u}=s,t=n(u),o=n(void 0),y={__lunoraRef:f};if(h(a)){const R=c.subscribe(y,d,r=>{t.set(r),o.set(void 0)},{onError:r=>{o.set(r)},shardKey:l});i.onDestroy(R)}return{data:t.asReadonly(),error:o.asReadonly()}};export{x as hydratePreloaded};
@@ -0,0 +1 @@
1
+ import{computed as m,inject as q,DestroyRef as z,signal as b}from"@angular/core";import{initialPages as H,derivePaginationStatus as _,applyLoadMore as J,rebalance as T}from"@lunora/client/pagination";import{s as B,a as U,b as X}from"./platform-DNlq-CRU.mjs";import{resolveLunoraClient as E}from"./LUNORA_CLIENT-B0toApHY.mjs";const h=(o,t)=>`${o}::${X(t)}`,L=(o,t)=>({...t,paginationOpts:{cursor:o.lower,endCursor:o.upper,numItems:o.numItems}}),$=(o,t,n,i)=>{const r=E(n.client),K=n.destroyRef===void 0&&i===void 0,{initialNumItems:a,shardKey:w}=n,g=o.__lunoraRef,l=t==="skip"?{}:t,e=b(H(a)),x=b([]),D=b("LoadingFirstPage"),C=b(void 0),R=new Map,y=new Map,F=new Set,S=()=>{const f=e().map(s=>{const u=h(g,L(s,l));return y.get(u)});x.set(f);const{status:P}=_(t==="skip",f);D.set(P)},W=(p,f)=>{const P=s=>h(g,L(s,l));for(const s of f){const u=P(s);if(y.has(u))continue;const d=p.find(c=>c.lower===s.lower);if(d){const c=y.get(P(d));c&&y.set(u,c)}}},G=p=>{const f=new Set;for(const s of p)f.add(h(g,L(s,l)));for(const[s,u]of R)f.has(u.currentKey)||(u.unsub(),R.delete(s),y.delete(u.currentKey));const P=new Set([...R.values()].map(s=>s.currentKey));for(const s of p){const u=L(s,l),d=h(g,u);if(P.has(d))continue;const c={currentKey:d,unsub:void 0};F.add(d);const j=r.subscribe(o,u,M=>{if(y.set(c.currentKey,M),F.delete(c.currentKey),C.set(void 0),S(),F.size===0){const v=e(),k=T(v,x());k&&(W(v,k),e.set(k),I(k),S())}},{onError:M=>{F.delete(d),C.set(M);const v=e(),k=v.at(-1);v.length>1&&k&&!y.has(d)&&h(g,L(k,l))===d&&(e.set(v.slice(0,-1)),I(e())),S(),n.onError?.(M)},shardKey:w});c.unsub=j,R.set(d,c),P.add(d)}};let N=!1,O=!1;const I=p=>{if(N){O=!0;return}N=!0;try{let f=p;do O=!1,G(f),f=e();while(O)}finally{N=!1}};t!=="skip"&&B(K)&&I(e()),S();const Q=()=>{for(const p of R.values())p.unsub();R.clear(),y.clear()};return i===void 0?(n.destroyRef??q(z)).onDestroy(Q):i(Q),{error:C,loadMore:p=>{if(t==="skip")return;const{nextCursor:f,status:P}=_(!1,x());if(P!=="CanLoadMore")return;const s=J(e(),f,p);if(!s)return;const u=e().at(-1),d=s.at(-2);if(u&&d){const c=h(g,L(u,l)),j=h(g,L(d,l)),M=R.get(c);if(M&&c!==j){const v=y.get(c);v&&y.set(j,v),M.unsub(),R.delete(c),y.delete(c)}}C.set(void 0),e.set(s),I(e()),S()},pageResults:x,skipped:m(()=>t==="skip"),status:D}},V=(o,t,n)=>{if(typeof t!="function")return $(o,t,n);const i=E(n.client),r=n.destroyRef===void 0,K=n.destroyRef??q(z),a=b(void 0);return B(r)&&U(t,{destroyRef:K,injector:n.injector},(w,g)=>{const l=[];a.set($(o,w,{...n,client:i},e=>l.push(e))),g(()=>{for(const e of l)e()})}),{error:m(()=>a()?.error()),loadMore:w=>{a()?.loadMore(w)},pageResults:m(()=>a()?.pageResults()??[]),skipped:m(()=>a()?.skipped()??t()==="skip"),status:m(()=>a()?.status()??"LoadingFirstPage")}},se=(o,t,n)=>{const i=V(o,t,n),r=m(()=>i.pageResults().flatMap(a=>a?.page??[])),K=m(()=>{const a=i.status();return!i.skipped()&&(a==="LoadingFirstPage"||a==="LoadingMore")});return{error:i.error,isLoading:K,loadMore:i.loadMore,results:r,status:i.status}},ne=(o,t,n)=>{const{initialNumItems:i}=n,r=V(o,t,n),K=m(()=>r.pageResults().flatMap(e=>e?[e.page]:[])),a=m(()=>!r.skipped()&&r.status()==="LoadingFirstPage"),w=m(()=>r.status()==="CanLoadMore"),g=m(()=>!r.skipped()&&r.status()==="LoadingMore"),l=e=>{r.loadMore(e??i)};return{error:r.error,fetchNextPage:l,hasNextPage:w,isFetchingNextPage:g,isLoading:a,pages:K,status:r.status}};export{ne as infiniteQuery,se as paginatedQuery};
@@ -0,0 +1 @@
1
+ import{inject as u,DestroyRef as y,signal as v}from"@angular/core";import{createQuerySubscription as m}from"@lunora/client/query";import{resolveLunoraClient as R}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as p,a as b}from"./platform-DNlq-CRU.mjs";const g=(c,t,e={})=>{const i=R(e.client),a=e.destroyRef===void 0,s=e.destroyRef??u(y),o=v(void 0),n=(r,f)=>{o.set(void 0);const l=m(i,c,r,{onData:d=>{o.set(d)},onError:e.onError,onReset:()=>{o.set(void 0)}},{shardKey:e.shardKey});f(l)};return p(a)&&(typeof t=="function"?b(t,{destroyRef:s,injector:e.injector},n):n(t,r=>s.onDestroy(r))),o.asReadonly()};export{g as liveQuery};
@@ -0,0 +1 @@
1
+ import{resolveLunoraClient as i}from"./LUNORA_CLIENT-B0toApHY.mjs";const a=(t,o,n={})=>{const{client:e,...r}=n;return i(e).mutation(t,o,r)};export{a as mutate};
@@ -0,0 +1 @@
1
+ import{signal as o,computed as d}from"@angular/core";import{createMutatorRunner as c}from"@lunora/client";const u=n=>{const r=o(void 0),e=o(!1),s=d(()=>r()!==void 0),{mutate:a,reset:i}=c(n,{setError:t=>{r.set(t)},setPending:t=>{e.set(t)}});return{error:r.asReadonly(),isError:s,mutate:a,pending:e.asReadonly(),reset:i}};export{u as mutator};
@@ -0,0 +1 @@
1
+ import{inject as m,PLATFORM_ID as O,computed as j,effect as w,untracked as A,NgZone as S}from"@angular/core";const h=/["\\\u0000-\u001F\uD800-\uDFFF]/,p=r=>h.test(r)?JSON.stringify(r):`"${r}"`,b=r=>{if(r===void 0)return"null";if(typeof r=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof r=="number"){if(Number.isNaN(r))return"nan";if(r===1/0)return"inf";if(r===-1/0)return"-inf";if(Object.is(r,-0))return"-0"}if(typeof r=="string")return p(r);if(r===null||typeof r!="object")return JSON.stringify(r);if(Array.isArray(r)){let n="[";for(let o=0;o<r.length;o++)o>0&&(n+=","),n+=b(r[o]);return n+"]"}const e=Object.getPrototypeOf(r);if(e!==null&&e!==Object.prototype){const n=r.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${n} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=r,c=Object.keys(s).sort();let f="{",t=!0;for(const n of c){const o=s[n];o!==void 0&&(t?t=!1:f+=",",f+=p(n),f+=":",f+=b(o))}return f+"}"},y=r=>{let e="";for(let c=0;c<r.length;c+=32768)e+=String.fromCharCode(...r.subarray(c,c+32768));return btoa(e)},i="$lunora.wire$",g=64,l="__proto__",k=r=>{if(r===null||typeof r!="object")return!1;const e=Object.getPrototypeOf(r);return e===null||e===Object.prototype},a=(r,e=0)=>{if(e>g)throw new RangeError(`wire-codec: value nesting exceeds the ${g}-level limit`);if(r===void 0)return[i,"undefined"];if(r===null)return null;const s=typeof r;if(s==="bigint")return[i,"bigint",r.toString()];if(s==="number"){const t=r;return Number.isNaN(t)?[i,"nan"]:t===1/0?[i,"inf"]:t===-1/0?[i,"-inf"]:t}if(s!=="object")return r;if(r instanceof Date)return[i,"date",a(r.getTime(),e+1)];if(r instanceof Error){const t=r,n={};for(const u of Object.keys(t)){if(t[u]===void 0)continue;const d=a(t[u],e+1);u===l?Object.defineProperty(n,u,{configurable:!0,enumerable:!0,value:d,writable:!0}):n[u]=d}const o=[i,"error",String(t.name),String(t.message),n];return t.cause!==void 0&&o.push(a(t.cause,e+1)),o}if(r instanceof URL)return[i,"url",r.href];if(r instanceof Map)return[i,"map",[...r.entries()].map(([t,n])=>[a(t,e+1),a(n,e+1)])];if(r instanceof Set)return[i,"set",[...r].map(t=>a(t,e+1))];if(r instanceof ArrayBuffer)return[i,"bytes",y(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const t=r,n=t.constructor.name,o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return n==="Uint8Array"?[i,"bytes",y(o)]:[i,"bytes",y(o),n]}if(Array.isArray(r)){const t=r.map(n=>a(n,e+1));return t.length>0&&t[0]===i?[i,"arr",t]:t}if(!k(r)){const t=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} 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 c=r,f={};for(const t of Object.keys(c)){const n=c[t];if(n===void 0)continue;const o=a(n,e+1);t===l?Object.defineProperty(f,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):f[t]=o}return f},E=r=>b(a(r)),D=r=>r?m(O,{optional:!0})!=="server":!0,N=r=>{const e=r?m(S,{optional:!0}):void 0;return e?s=>e.runOutsideAngular(s):s=>s()},P=(r,e)=>N(r)(e),_=(r,e,s)=>{let c;const f=j(()=>E(r()));try{c=w(t=>{f(),A(()=>{s(r(),t)})},{injector:e.injector,manualCleanup:!0})}catch(t){throw e.injector!==void 0?t:new Error("reactive `args` need an injection context: call this primitive from a component/service field or constructor, or pass `injector` alongside `destroyRef`.",{cause:t})}e.destroyRef.onDestroy(()=>{c.destroy()})};export{_ as a,E as b,N as o,P as r,D as s};
@@ -0,0 +1 @@
1
+ import{inject as D,DestroyRef as S,signal as m}from"@angular/core";import{resolveLunoraClient as U}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as C,r as E}from"./platform-DNlq-CRU.mjs";const A=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const n=crypto.getRandomValues(new Uint8Array(16));return Array.from(n,e=>e.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},w=1e4,M=(n,e)=>{const i=U(e.client),u=e.destroyRef===void 0,v=e.destroyRef??D(S),{heartbeat:p,listPresent:b,shardKey:a}=e,o=e.intervalMs??w,c=e.sessionId??A(),f=m(void 0),d=m(void 0);if(!Number.isFinite(o)||o<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(o)}`);let l=e.data;const r=()=>{const t={roomId:n,sessionId:c};l!==void 0&&(t.data=l),i.mutation(p,t,{shardKey:a}).catch(()=>{})},g=t=>{l=t,r()};if(C(u)){const t=i.acquireConnectionContext({roomId:n,sessionId:c},{shardKey:a});r();const y=()=>{typeof document<"u"&&document.visibilityState==="visible"&&r()},R=E(u,()=>(typeof document<"u"&&document.addEventListener("visibilitychange",y),setInterval(r,o))),I={roomId:n},h=i.subscribe(b,I,s=>{f.set(s),d.set(void 0)},{onError:s=>{d.set(s),e.onError?.(s)},shardKey:a});v.onDestroy(()=>{clearInterval(R),typeof document<"u"&&document.removeEventListener("visibilitychange",y),t(),h()})}return{error:d.asReadonly(),present:f.asReadonly(),sessionId:c,setData:g}};export{M as presence};
@@ -0,0 +1 @@
1
+ import{inject as w,DestroyRef as y,signal as p,computed as v}from"@angular/core";import{evaluate as f}from"@lunora/ratelimit";const R=(o,r={})=>{const m=r.destroyRef??w(y),n=r.now??Date.now,k=r.tickMs??1e3;let t;const i=()=>f(o,t,{consume:!1,count:1,now:n(),reserve:!1}).status,e=p(i()),a=()=>{e.set(i())};let s;const l=()=>{s!==void 0&&(clearInterval(s),s=void 0)},d=()=>{e().ok||s!==void 0||(s=setInterval(()=>{a(),e().ok&&l()},k))};return d(),m.onDestroy(()=>{l()}),{check:(u=1)=>f(o,t,{consume:!1,count:u,now:n(),reserve:!1}).status.ok,consume:(u=1)=>{const c=f(o,t,{consume:!0,count:u,now:n(),reserve:!1});return c.value!==void 0&&(t=c.value),a(),d(),c.status},disabled:v(()=>!e().ok),ok:v(()=>e().ok),reset:()=>{t=void 0,l(),a()},retryAfter:v(()=>e().retryAfter)}};export{R as rateLimit};
@@ -0,0 +1 @@
1
+ import{resolveLunoraClient as e}from"./LUNORA_CLIENT-B0toApHY.mjs";const l=(n,o,t={})=>{const{client:r,...c}=t;return e(r).action(n,o,c)};export{l as runAction};
@@ -0,0 +1 @@
1
+ import{inject as R,DestroyRef as b,signal as n}from"@angular/core";import{resolveLunoraClient as k}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as p}from"./platform-DNlq-CRU.mjs";const g=(u,o,e={})=>{const d=k(e.client),m=e.destroyRef??R(b),y=e.destroyRef===void 0,a=n([]),c=n(void 0),t=n("idle");let s=!0,l;const f=()=>{s=!1,l?.()};if(o!=="skip"&&p(y)){t.set("streaming");const i=d.stream(u,o,{durable:e.durable,maxBuffer:e.maxBuffer,shardKey:e.shardKey});l=()=>{i.cancel()},(async()=>{try{for await(const r of i){if(!s)return;a.update(h=>[...h,r])}s&&t.set("complete")}catch(r){if(!s)return;c.set(r instanceof Error?r:new Error(String(r))),t.set("error")}})().catch(()=>{})}return m.onDestroy(f),{cancel:f,chunks:a.asReadonly(),error:c.asReadonly(),status:t.asReadonly()}};export{g as stream};
@@ -0,0 +1 @@
1
+ import{inject as m,DestroyRef as R,signal as a}from"@angular/core";import{createQuerySubscription as p}from"@lunora/client/query";import{resolveLunoraClient as b}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as h,a as j}from"./platform-DNlq-CRU.mjs";const C=(d,n,e={})=>{const f=b(e.client),v=e.destroyRef===void 0,i=e.destroyRef??m(R),l=e.onError,o=a(void 0),r=a(void 0),c=(t,u)=>{if(o.set(void 0),r.set(void 0),t==="skip")return;const y=p(f,d,t,{onData:s=>{o.set(s),r.set(void 0)},onError:s=>{r.set(s),o.set(void 0),l?.(s)},onReset:()=>{o.set(void 0)}},{shardKey:e.shardKey});u(y)};return h(v)&&(typeof n=="function"?j(n,{destroyRef:i,injector:e.injector},c):c(n,t=>i.onDestroy(t))),{data:o.asReadonly(),error:r.asReadonly()}};export{C as subscription};
@@ -0,0 +1 @@
1
+ import{inject as B,DestroyRef as K,signal as T}from"@angular/core";import{resolveLunoraClient as V}from"./LUNORA_CLIENT-B0toApHY.mjs";import{o as q}from"./platform-DNlq-CRU.mjs";const D="/_lunora/ws",j="/_lunora/voice/",J=4001,L=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,G=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},X=(e,r)=>{if(r===void 0||r==="")return L(e);if(r.endsWith(D))return r.slice(0,-D.length);try{return new URL(r).origin}catch{return L(e)}},z=e=>{const r=X(e.httpUrl,e.wsUrl),s=r.endsWith("/")?r.slice(0,-1):r,i=new URLSearchParams({threadKey:e.threadKey});return`${s}${j}${encodeURIComponent(e.agent)}?${i.toString()}`},Q=(e,r)=>{if(r?.code===J)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},Y=(e,r,s)=>{const i=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==i&&s(new Error(`${r}: the signed-in identity changed during the call — the session was ended; start a new call`))})},Z=16e3,ee=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},te=(e,r)=>{const s=r/Z,i=s>1?Math.floor(e.length/s):e.length,k=new ArrayBuffer(i*2),l=new DataView(k);for(let u=0;u<i;u+=1){const y=e[Math.floor(u*s)]??0,d=Math.max(-1,Math.min(1,y));l.setInt16(u*2,d<0?d*32768:d*32767,!0)}return new Uint8Array(k)},ne=async e=>{const r=globalThis,s=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),i=r.AudioContext??r.webkitAudioContext;if(!s||!i)throw new Error("voiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const k=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new i,u=l.createMediaStreamSource(k),y=l.createScriptProcessor(4096,1,1);let d=!1,m=!1,c=0,g=0;return y.onaudioprocess=p=>{const h=p.inputBuffer.getChannelData(0),a=d?0:ee(h);if(e.onLevel(a),d)return;if(e.onAudio(te(h,l.sampleRate)),e.isTurnActive()){g=a>=e.interruptThreshold?g+1:0,g>=e.interruptChunks&&(g=0,e.onInterrupt());return}g=0;const v=h.length/l.sampleRate*1e3;if(a>=e.silenceThreshold){m=!0,c=0;return}m&&(c+=v,c>=e.silenceDurationMs&&(m=!1,c=0,e.onSilence()))},u.connect(y),y.connect(l.destination),{setMuted:p=>{d=p},stop:()=>{y.disconnect(),u.disconnect();for(const p of k.getTracks())p.stop();l.close()}}},re=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("voiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,i=new Set;let k=0,l=Promise.resolve(),u=0;const y=async(c,g)=>{if(g!==u)return;let p;try{p=await s.decodeAudioData(c.buffer)}catch{return}if(g!==u)return;const h=s.createBufferSource();h.buffer=p,h.connect(s.destination);const a=Math.max(s.currentTime,k);h.start(a),k=a+p.duration,i.add(h),h.onended=()=>{i.delete(h)}},d=c=>{const g=Uint8Array.from(c),p=u;l=l.then(()=>y(g,p))},m=()=>{u+=1;for(const c of i)try{c.stop()}catch{}i.clear(),k=s.currentTime};return{enqueue:d,interrupt:m,stop:()=>{m(),s.close()}}},F=1,se=.01,oe=1200,ae=.15,ie=3,de=e=>{const{createMicrophone:r=ne,createSpeaker:s=re,createSocket:i,interruptChunks:k=ie,interruptThreshold:l=ae,silenceDurationMs:u=oe,silenceThreshold:y=se,threadKey:d,voice:m}=e,c=V(e.client),g=e.destroyRef===void 0,p=e.destroyRef??B(K),h=q(g),a=T("idle"),v=T(!1),_=T(""),S=T(""),x=T(0),R=T(!1),w=T(void 0);let o,b=!1;const M=t=>{const n=o?.socket;return n?.readyState===F?(n.send(JSON.stringify(t)),!0):!1},E=()=>{const t=o;if(o=void 0,t){t.unwatchIdentity?.(),t.microphone?.stop(),t.speaker?.stop(),t.socket.onmessage=null,t.socket.onerror=null,t.socket.onclose=null;try{t.socket.close()}catch{}}b=!1,v.set(!1),a.set("idle"),x.set(0)},W=E,N=t=>{const n=o;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),a.set("speaking"),S.update(I=>I+t.text);break}case"assistant_done":{n&&(n.awaitingTurn=!1,n.speaking=!1),S.set(t.text),a.set("listening");break}case"error":{n&&(n.awaitingTurn=!1,n.speaking=!1),w.set(new Error(t.message)),a.set("listening");break}case"interrupted":{n&&(n.awaitingTurn=!1,n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),a.set("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),v.set(!0),a.set("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),_.set(t.text),S.set(""),a.set("thinking");break}}},O=t=>{const n=o;!n||n.suppressAudio||(n.speaker??=s({audioFormat:n.audioFormat}),n.speaking=!0,a.set("speaking"),n.speaker.enqueue(t))},P=async()=>{if(o||b)return;b=!0,w.set(void 0),_.set(""),S.set("");let t;try{const n=z({agent:G(m.__lunoraRef),httpUrl:c.url,threadKey:typeof d=="function"?d():d,wsUrl:c.wsUrl}),I=i??(f=>{const C=c.getWebSocketImpl();if(!C)throw new Error("voiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new C(f)}),A=h(()=>I(n));A.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:A,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},o=t,t.unwatchIdentity=Y(c,"voiceAgent",f=>{o===t&&(w.set(f),E())}),A.onmessage=f=>{if(typeof f.data=="string"){try{N(JSON.parse(f.data))}catch{}return}O(new Uint8Array(f.data))},A.onerror=()=>{w.set(new Error("voiceAgent: voice socket error"))},A.onclose=f=>{if(o!==t)return;const C=Q("voiceAgent",f);C&&w.set(C),E()};const U=await h(async()=>r({interruptChunks:k,interruptThreshold:l,isTurnActive:()=>(o?.speaking??!1)||(o?.awaitingTurn??!1),onAudio:f=>{A.readyState===F&&A.send(f)},onInterrupt:()=>{M({type:"interrupt"}),o?.speaker?.interrupt(),o&&(o.awaitingTurn=!1,o.speaking=!1,o.suppressAudio=!0),a.set("listening")},onLevel:f=>{x.set(f)},onSilence:()=>{M({type:"commit"}),o&&(o.awaitingTurn=!0),a.set("thinking")},silenceDurationMs:u,silenceThreshold:y}));o===t?(t.microphone=U,R.set(!1),t.speaking||a.set("listening")):U.stop()}catch(n){o===t&&(w.set(n instanceof Error?n:new Error(String(n))),E())}finally{b=!1}},H=()=>{const t=!R();return o?.microphone?.setMuted(t),R.set(t),t},$=t=>{M({text:t,type:"text"})&&(o&&(o.awaitingTurn=!0),a.set("thinking"))};return p.onDestroy(E),{audioLevel:x.asReadonly(),connected:v.asReadonly(),endCall:W,error:w.asReadonly(),interimTranscript:S.asReadonly(),isMuted:R.asReadonly(),sendText:$,startCall:P,status:a.asReadonly(),toggleMute:H,transcript:_.asReadonly()}};export{de as voiceAgent};
@@ -0,0 +1 @@
1
+ export { type ArgsOf, type AuthLike, type FunctionReference, type HeadersSource, type Preloaded, type ReturnOf, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, preloadQuery, preloadedQueryResult, serializePreloaded } from '@lunora/client/ssr';
@@ -0,0 +1 @@
1
+ export { type ArgsOf, type AuthLike, type FunctionReference, type HeadersSource, type Preloaded, type ReturnOf, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, preloadQuery, preloadedQueryResult, serializePreloaded } from '@lunora/client/ssr';
@@ -0,0 +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};
@@ -0,0 +1,57 @@
1
+ import { Signal, DestroyRef } from '@angular/core';
2
+ import { UploadResult, CreateUploadOptions, UploadProtocol } from '@lunora/client/upload';
3
+ export { type ChunkedRestAdapter, type ChunkedRestAdapterOptions, type FingerprintFunction, type HeadersResolver, type MultipartAdapter, type MultipartAdapterOptions, type OnBeforeRequest, type RequestOptions, RestrictionError, type TusAdapter, type TusAdapterOptions, type UploadAdapter, UploadError, type UploadRestrictions, type UploadResult, createChunkedRestAdapter, createMultipartAdapter, createTusAdapter, createUpload } from '@lunora/client/upload';
4
+ export { UploadControl } from '@visulima/storage-client';
5
+ /** The lifecycle of an {@link upload} primitive. */
6
+ type UploadStatus = "error" | "idle" | "paused" | "success" | "uploading";
7
+ /**
8
+ * `UploadOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
9
+ * @experimental
10
+ */
11
+ interface UploadOptions extends Omit<CreateUploadOptions, "protocol"> {
12
+ /** `DestroyRef` whose `onDestroy` aborts any upload still in flight. Defaults to `inject(DestroyRef)`. */
13
+ destroyRef?: DestroyRef;
14
+ /** Which resumable protocol to speak. Default `"tus"`. Multipart isn't wrapped here — call `createMultipartAdapter` directly. */
15
+ protocol?: Exclude<UploadProtocol, "multipart">;
16
+ }
17
+ /**
18
+ * `UploadApi` is part of the experimental `@lunora/angular` API and may change without a major version bump.
19
+ * @experimental
20
+ */
21
+ interface UploadApi {
22
+ /** Abort the in-flight upload. Safe to call at any point, including after success. */
23
+ abort: () => void;
24
+ /** The upload error, or `undefined`. */
25
+ error: Signal<Error | undefined>;
26
+ /** Whether the upload is currently paused. */
27
+ isPaused: Signal<boolean>;
28
+ /** Pause the in-flight upload (TUS / chunked-REST only support this mid-upload). A no-op unless `status() === "uploading"`. */
29
+ pause: () => void;
30
+ /** Upload progress, as the adapter reports it (0–100). */
31
+ progress: Signal<number>;
32
+ /** The resolved upload result, or `undefined` before it finishes. */
33
+ result: Signal<UploadResult | undefined>;
34
+ /** Resume a paused upload. A no-op unless `status() === "paused"`. */
35
+ resume: () => void;
36
+ /** Start (or restart) the upload for `file`. Also resolves/rejects with the same result the `result`/`error` signals settle to. */
37
+ start: (file: File) => Promise<UploadResult>;
38
+ /** The upload lifecycle. */
39
+ status: Signal<UploadStatus>;
40
+ }
41
+ /**
42
+ * Drive a resumable (TUS / chunked-REST) upload as Angular signals: `progress`,
43
+ * `status`, `result` and `error`, plus `start` / `pause` / `resume` / `abort`
44
+ * actions. Defaults to TUS — the resumable path that survives pause/resume and
45
+ * a dropped connection.
46
+ *
47
+ * Call from an injection context (component/service field or constructor):
48
+ * ```ts
49
+ * protected readonly upload = upload({ endpoint: "/api/upload" });
50
+ * onFileSelected(file: File) {
51
+ * this.upload.start(file).catch(() => undefined); // errors also land in `error`
52
+ * }
53
+ * ```
54
+ * @experimental
55
+ */
56
+ declare const upload: (options: UploadOptions) => UploadApi;
57
+ export { UploadApi, UploadOptions, UploadStatus, upload };
@@ -0,0 +1,57 @@
1
+ import { Signal, DestroyRef } from '@angular/core';
2
+ import { UploadResult, CreateUploadOptions, UploadProtocol } from '@lunora/client/upload';
3
+ export { type ChunkedRestAdapter, type ChunkedRestAdapterOptions, type FingerprintFunction, type HeadersResolver, type MultipartAdapter, type MultipartAdapterOptions, type OnBeforeRequest, type RequestOptions, RestrictionError, type TusAdapter, type TusAdapterOptions, type UploadAdapter, UploadError, type UploadRestrictions, type UploadResult, createChunkedRestAdapter, createMultipartAdapter, createTusAdapter, createUpload } from '@lunora/client/upload';
4
+ export { UploadControl } from '@visulima/storage-client';
5
+ /** The lifecycle of an {@link upload} primitive. */
6
+ type UploadStatus = "error" | "idle" | "paused" | "success" | "uploading";
7
+ /**
8
+ * `UploadOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
9
+ * @experimental
10
+ */
11
+ interface UploadOptions extends Omit<CreateUploadOptions, "protocol"> {
12
+ /** `DestroyRef` whose `onDestroy` aborts any upload still in flight. Defaults to `inject(DestroyRef)`. */
13
+ destroyRef?: DestroyRef;
14
+ /** Which resumable protocol to speak. Default `"tus"`. Multipart isn't wrapped here — call `createMultipartAdapter` directly. */
15
+ protocol?: Exclude<UploadProtocol, "multipart">;
16
+ }
17
+ /**
18
+ * `UploadApi` is part of the experimental `@lunora/angular` API and may change without a major version bump.
19
+ * @experimental
20
+ */
21
+ interface UploadApi {
22
+ /** Abort the in-flight upload. Safe to call at any point, including after success. */
23
+ abort: () => void;
24
+ /** The upload error, or `undefined`. */
25
+ error: Signal<Error | undefined>;
26
+ /** Whether the upload is currently paused. */
27
+ isPaused: Signal<boolean>;
28
+ /** Pause the in-flight upload (TUS / chunked-REST only support this mid-upload). A no-op unless `status() === "uploading"`. */
29
+ pause: () => void;
30
+ /** Upload progress, as the adapter reports it (0–100). */
31
+ progress: Signal<number>;
32
+ /** The resolved upload result, or `undefined` before it finishes. */
33
+ result: Signal<UploadResult | undefined>;
34
+ /** Resume a paused upload. A no-op unless `status() === "paused"`. */
35
+ resume: () => void;
36
+ /** Start (or restart) the upload for `file`. Also resolves/rejects with the same result the `result`/`error` signals settle to. */
37
+ start: (file: File) => Promise<UploadResult>;
38
+ /** The upload lifecycle. */
39
+ status: Signal<UploadStatus>;
40
+ }
41
+ /**
42
+ * Drive a resumable (TUS / chunked-REST) upload as Angular signals: `progress`,
43
+ * `status`, `result` and `error`, plus `start` / `pause` / `resume` / `abort`
44
+ * actions. Defaults to TUS — the resumable path that survives pause/resume and
45
+ * a dropped connection.
46
+ *
47
+ * Call from an injection context (component/service field or constructor):
48
+ * ```ts
49
+ * protected readonly upload = upload({ endpoint: "/api/upload" });
50
+ * onFileSelected(file: File) {
51
+ * this.upload.start(file).catch(() => undefined); // errors also land in `error`
52
+ * }
53
+ * ```
54
+ * @experimental
55
+ */
56
+ declare const upload: (options: UploadOptions) => UploadApi;
57
+ export { UploadApi, UploadOptions, UploadStatus, upload };
@@ -0,0 +1 @@
1
+ import{inject as g,DestroyRef as m,signal as r}from"@angular/core";import{createUpload as v}from"@lunora/client/upload";import{RestrictionError as D,UploadError as E,createChunkedRestAdapter as P,createMultipartAdapter as b,createTusAdapter as C,createUpload as S}from"@lunora/client/upload";import{UploadControl as k}from"@visulima/storage-client";const x=p=>{const{destroyRef:c,...u}=p,l=c??g(m),s=v(u),n=r(0),t=r("idle"),d=r(void 0),o=r(void 0),a=r(!1);s.setOnStart(()=>{t.set("uploading")}),s.setOnProgress(e=>{n.set(e)}),s.setOnFinish(e=>{d.set(e),t.set("success")}),s.setOnError(e=>{o.set(e),t.set("error")});const f=e=>(o.set(void 0),d.set(void 0),n.set(0),a.set(!1),t.set("uploading"),s.upload(e)),R=()=>{t()==="uploading"&&(s.pause(),a.set(!0),t.set("paused"))},y=()=>{t()==="paused"&&s.resume().then(()=>{a.set(!1),t.set("uploading")}).catch(e=>{o.set(e instanceof Error?e:new Error(String(e))),t.set("error")})},i=()=>{s.abort()};return l.onDestroy(i),{abort:i,error:o.asReadonly(),isPaused:a.asReadonly(),pause:R,progress:n.asReadonly(),result:d.asReadonly(),resume:y,start:f,status:t.asReadonly()}};export{D as RestrictionError,k as UploadControl,E as UploadError,P as createChunkedRestAdapter,b as createMultipartAdapter,C as createTusAdapter,S as createUpload,x as upload};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/angular",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.0.0-alpha.90",
4
4
  "description": "Angular reactive adapter for Lunora — signal-based live queries and mutations",
5
5
  "keywords": [
6
6
  "angular",
@@ -39,14 +39,23 @@
39
39
  "types": "./dist/index.d.ts",
40
40
  "import": "./dist/index.mjs"
41
41
  },
42
+ "./server": {
43
+ "types": "./dist/server.d.ts",
44
+ "import": "./dist/server.mjs"
45
+ },
46
+ "./upload": {
47
+ "types": "./dist/upload.d.ts",
48
+ "import": "./dist/upload.mjs"
49
+ },
42
50
  "./package.json": "./package.json"
43
51
  },
44
52
  "publishConfig": {
45
53
  "access": "public"
46
54
  },
47
55
  "dependencies": {
48
- "@lunora/client": "1.0.0-alpha.23",
49
- "@lunora/ratelimit": "1.0.0-alpha.8"
56
+ "@lunora/client": "1.0.0-alpha.108",
57
+ "@lunora/ratelimit": "1.0.0-alpha.62",
58
+ "@visulima/storage-client": "1.0.3"
50
59
  },
51
60
  "peerDependencies": {
52
61
  "@angular/core": "^19.2.0 || ^20.0.0 || ^21.0.0 || ^22.0.0"
@@ -1,23 +0,0 @@
1
- import { InjectionToken, makeEnvironmentProviders, inject } from '@angular/core';
2
- import { LunoraClient } from '@lunora/client';
3
-
4
- const sameOriginUrl = () => globalThis.location?.origin ?? "";
5
- const LUNORA_CLIENT = new InjectionToken("lunora.client", {
6
- factory: () => new LunoraClient({ url: sameOriginUrl() }),
7
- providedIn: "root"
8
- });
9
- const provideLunora = (optionsOrClient = {}) => makeEnvironmentProviders([
10
- {
11
- provide: LUNORA_CLIENT,
12
- useFactory: () => {
13
- if (optionsOrClient instanceof LunoraClient) {
14
- return optionsOrClient;
15
- }
16
- return new LunoraClient({ ...optionsOrClient, url: optionsOrClient.url ?? sameOriginUrl() });
17
- }
18
- }
19
- ]);
20
- const injectLunoraClient = () => inject(LUNORA_CLIENT);
21
- const resolveLunoraClient = (client) => client ?? injectLunoraClient();
22
-
23
- export { LUNORA_CLIENT, injectLunoraClient, provideLunora, resolveLunoraClient };
@@ -1,31 +0,0 @@
1
- import { inject, DestroyRef, computed, signal } from '@angular/core';
2
- import { resolveLunoraClient } from './LUNORA_CLIENT-DHUfNu9x.mjs';
3
- import { subscription } from './subscription-oZ-WTmpp.mjs';
4
-
5
- const agent = (options) => {
6
- const { api, cancel: cancelReference, run: runReference, runArgs, threadKey } = options;
7
- const client = resolveLunoraClient(options.client);
8
- const destroyRef = options.destroyRef ?? inject(DestroyRef);
9
- const { data: threadData } = subscription(api.agents.agentThread, { key: threadKey }, { client, destroyRef });
10
- const thread = computed(() => threadData());
11
- const status = computed(() => thread()?.status);
12
- const pending = signal(false);
13
- const run = async (input, arguments_) => {
14
- pending.set(true);
15
- try {
16
- await client.mutation(runReference, { input, threadKey, ...runArgs, ...arguments_ });
17
- } finally {
18
- pending.set(false);
19
- }
20
- };
21
- const cancel = async () => {
22
- const instanceId = thread()?.instanceId;
23
- if (cancelReference === void 0 || instanceId === void 0) {
24
- return;
25
- }
26
- await client.mutation(cancelReference, { instanceId, threadKey });
27
- };
28
- return { cancel, pending: pending.asReadonly(), run, status, thread };
29
- };
30
-
31
- export { agent };
@@ -1,96 +0,0 @@
1
- import { inject, DestroyRef, signal, computed } from '@angular/core';
2
- import { resolveLunoraClient } from './LUNORA_CLIENT-DHUfNu9x.mjs';
3
- import { stream } from './stream-PL64AghO.mjs';
4
- import { subscription } from './subscription-oZ-WTmpp.mjs';
5
-
6
- const NO_STREAM_REF = { __lunoraRef: "" };
7
- const reconcileOptimistic = (optimistic, durable) => {
8
- const pool = durable.filter((message) => message.role === "user").map((message) => message.content);
9
- return optimistic.filter((pending) => {
10
- const index = pool.indexOf(pending.content);
11
- if (index !== -1) {
12
- pool.splice(index, 1);
13
- return false;
14
- }
15
- return true;
16
- });
17
- };
18
- const agentChat = (options) => {
19
- const { api, cancel: cancelReference, limit, send: sendReference, sendArgs, stream: streamReference, threadKey } = options;
20
- const client = resolveLunoraClient(options.client);
21
- const destroyRef = options.destroyRef ?? inject(DestroyRef);
22
- const messagesArguments = limit === void 0 ? { key: threadKey } : { key: threadKey, limit };
23
- const { data: history } = subscription(api.agents.agentMessages, messagesArguments, { client, destroyRef });
24
- const { data: threadData } = subscription(api.agents.agentThread, { key: threadKey }, { client, destroyRef });
25
- const streamArguments = streamReference === void 0 ? "skip" : { key: threadKey };
26
- const { chunks } = stream(streamReference ?? NO_STREAM_REF, streamArguments, { client, destroyRef });
27
- const optimistic = signal([]);
28
- let nextId = 0;
29
- const thread = computed(() => threadData());
30
- const status = computed(() => thread()?.status);
31
- const durable = computed(() => history() ?? []);
32
- const messages = computed(() => {
33
- const rows = durable();
34
- const visible = reconcileOptimistic(optimistic(), rows);
35
- if (visible.length === 0) {
36
- return rows;
37
- }
38
- return [
39
- ...rows,
40
- ...visible.map((pending, index) => {
41
- return {
42
- content: pending.content,
43
- optimistic: true,
44
- role: "user",
45
- seq: rows.length + index
46
- };
47
- })
48
- ];
49
- });
50
- const streamingText = computed(() => {
51
- const assistantCount = durable().filter((message) => message.role === "assistant").length;
52
- return chunks().filter((event) => event.kind !== "progress" && event.threadKey === threadKey && event.turn >= assistantCount).map((delta) => delta.text).join("");
53
- });
54
- const send = async (input, arguments_) => {
55
- const id = nextId;
56
- nextId += 1;
57
- optimistic.set([...reconcileOptimistic(optimistic(), durable()), { content: input, id }]);
58
- await client.mutation(sendReference, { input, threadKey, ...sendArgs, ...arguments_ });
59
- };
60
- const approve = async (toolCallId, note) => {
61
- const instanceId = thread()?.instanceId;
62
- if (instanceId === void 0) {
63
- throw new Error("agentChat: cannot approve — no in-flight run (thread has no instanceId)");
64
- }
65
- await client.mutation(api.agents.agentResolveApproval, {
66
- decision: "approve",
67
- instanceId,
68
- threadKey,
69
- toolCallId,
70
- ...note === void 0 ? {} : { note }
71
- });
72
- };
73
- const reject = async (toolCallId, note) => {
74
- const instanceId = thread()?.instanceId;
75
- if (instanceId === void 0) {
76
- throw new Error("agentChat: cannot reject — no in-flight run (thread has no instanceId)");
77
- }
78
- await client.mutation(api.agents.agentResolveApproval, {
79
- decision: "reject",
80
- instanceId,
81
- threadKey,
82
- toolCallId,
83
- ...note === void 0 ? {} : { note }
84
- });
85
- };
86
- const cancel = async () => {
87
- const instanceId = thread()?.instanceId;
88
- if (cancelReference === void 0 || instanceId === void 0) {
89
- return;
90
- }
91
- await client.mutation(cancelReference, { instanceId, threadKey });
92
- };
93
- return { approve, cancel, messages, reject, send, status, streamingText };
94
- };
95
-
96
- export { agentChat };
@@ -1,10 +0,0 @@
1
- import { computed } from '@angular/core';
2
- import { subscription } from './subscription-oZ-WTmpp.mjs';
3
-
4
- const agentState = (options) => {
5
- const { data, error } = subscription(options.api.agents.agentState, { key: options.threadKey }, { client: options.client, destroyRef: options.destroyRef });
6
- const state = computed(() => data());
7
- return { error, state };
8
- };
9
-
10
- export { agentState };
@@ -1,59 +0,0 @@
1
- import { inject, DestroyRef, computed } from '@angular/core';
2
- import { resolveLunoraClient } from './LUNORA_CLIENT-DHUfNu9x.mjs';
3
- import { stream } from './stream-PL64AghO.mjs';
4
- import { subscription } from './subscription-oZ-WTmpp.mjs';
5
-
6
- const NO_STREAM_REF = { __lunoraRef: "" };
7
- const EMPTY_MESSAGES = [];
8
- const toDurableEvent = (message) => {
9
- if (message.role === "assistant" && message.toolCalls) {
10
- return message.toolCalls.map((call) => {
11
- return { input: call.input, seq: message.seq, toolCallId: call.id, toolName: call.name, type: "call" };
12
- });
13
- }
14
- if (message.role !== "tool") {
15
- return void 0;
16
- }
17
- if (message.status === "awaiting_approval") {
18
- return [
19
- {
20
- seq: message.seq,
21
- type: "awaiting-approval",
22
- ...message.toolCallId === void 0 ? {} : { toolCallId: message.toolCallId },
23
- ...message.toolName === void 0 ? {} : { toolName: message.toolName }
24
- }
25
- ];
26
- }
27
- return [
28
- {
29
- output: message.content,
30
- seq: message.seq,
31
- type: "result",
32
- ...message.status === "approved" || message.status === "rejected" ? { status: message.status } : {},
33
- ...message.toolCallId === void 0 ? {} : { toolCallId: message.toolCallId },
34
- ...message.toolName === void 0 ? {} : { toolName: message.toolName }
35
- }
36
- ];
37
- };
38
- const agentToolEvents = (options) => {
39
- const { api, limit, stream: streamReference, threadKey } = options;
40
- const client = resolveLunoraClient(options.client);
41
- const destroyRef = options.destroyRef ?? inject(DestroyRef);
42
- const messagesArguments = limit === void 0 ? { key: threadKey } : { key: threadKey, limit };
43
- const { data: history } = subscription(api.agents.agentMessages, messagesArguments, { client, destroyRef });
44
- const streamArguments = streamReference === void 0 ? "skip" : { key: threadKey };
45
- const { chunks } = stream(streamReference ?? NO_STREAM_REF, streamArguments, { client, destroyRef });
46
- const events = computed(() => {
47
- const durable = history() ?? EMPTY_MESSAGES;
48
- const derived = durable.flatMap((message) => toDurableEvent(message) ?? []);
49
- for (const event of chunks()) {
50
- if (event.kind === "progress" && event.threadKey === threadKey) {
51
- derived.push({ data: event.data, toolCallId: event.toolCallId, type: "progress" });
52
- }
53
- }
54
- return derived;
55
- });
56
- return { events };
57
- };
58
-
59
- export { agentToolEvents };
@@ -1,27 +0,0 @@
1
- import { inject, DestroyRef, signal } from '@angular/core';
2
- import { getIdentityStore } from '@lunora/client/auth';
3
- import { resolveLunoraClient } from './LUNORA_CLIENT-DHUfNu9x.mjs';
4
-
5
- const auth = (options = {}) => {
6
- const client = resolveLunoraClient(options.client);
7
- const destroyRef = options.destroyRef ?? inject(DestroyRef);
8
- const store = getIdentityStore(client);
9
- const token = signal(client.getAuthToken());
10
- const user = signal(store.getUser());
11
- const unsubToken = client.onAuthTokenChange(() => {
12
- token.set(client.getAuthToken());
13
- });
14
- const unsubUser = store.subscribe(() => {
15
- user.set(store.getUser());
16
- });
17
- destroyRef.onDestroy(() => {
18
- unsubToken();
19
- unsubUser();
20
- });
21
- const setToken = (next) => {
22
- client.setAuthToken(next);
23
- };
24
- return { setToken, token: token.asReadonly(), user: user.asReadonly() };
25
- };
26
-
27
- export { auth };
@@ -1,15 +0,0 @@
1
- import { inject, DestroyRef, signal } from '@angular/core';
2
- import { resolveLunoraClient } from './LUNORA_CLIENT-DHUfNu9x.mjs';
3
-
4
- const connectionStatus = (options = {}) => {
5
- const client = resolveLunoraClient(options.client);
6
- const destroyRef = options.destroyRef ?? inject(DestroyRef);
7
- const status = signal(client.connectionStatus());
8
- const unsubscribe = client.onConnectionStatus((next) => {
9
- status.set(next);
10
- });
11
- destroyRef.onDestroy(unsubscribe);
12
- return status.asReadonly();
13
- };
14
-
15
- export { connectionStatus };