@lunora/angular 1.0.0-alpha.58 → 1.0.0-alpha.59
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 +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{agent-ZUHt9ut7.mjs → agent-CsE5xjQK.mjs} +1 -1
- package/dist/packem_shared/{agentChat-CSrFbg5h.mjs → agentChat-kyvh-ktM.mjs} +1 -1
- package/dist/packem_shared/{agentState-DhKNFqhU.mjs → agentState-B4sPm-HF.mjs} +1 -1
- package/dist/packem_shared/{agentToolEvents-DB_9RYy5.mjs → agentToolEvents-CzZN-jQB.mjs} +1 -1
- package/dist/packem_shared/{flag-CeGmnEZN.mjs → flag-CwhMtUIL.mjs} +1 -1
- package/dist/packem_shared/{hydratePreloaded-C8lNoww0.mjs → hydratePreloaded-CduDQN77.mjs} +1 -1
- package/dist/packem_shared/{infiniteQuery-DOlLHKmq.mjs → infiniteQuery-DmFYbw44.mjs} +1 -1
- package/dist/packem_shared/{liveQuery-CqnuEq1l.mjs → liveQuery-BTIv0WUM.mjs} +1 -1
- package/dist/packem_shared/platform-R29Vk-0v.mjs +1 -0
- package/dist/packem_shared/{presence-xJ3m0qXh.mjs → presence-DqzvJjBN.mjs} +1 -1
- package/dist/packem_shared/{subscription-DvndYt66.mjs → subscription-TT5Jlxw0.mjs} +1 -1
- package/dist/packem_shared/voiceAgent-BZZoKTSV.mjs +1 -0
- package/package.json +3 -3
- package/dist/packem_shared/platform-I2VyCEIl.mjs +0 -1
- package/dist/packem_shared/voiceAgent-CzyUcUKj.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1361,7 +1361,11 @@ interface VoiceAgentOptions {
|
|
|
1361
1361
|
* Audio graph stays isolated (and mockable in a non-browser test env).
|
|
1362
1362
|
*/
|
|
1363
1363
|
createMicrophone?: CreateMicrophone;
|
|
1364
|
-
/**
|
|
1364
|
+
/**
|
|
1365
|
+
* Advanced/test seam: open the transport. Defaults to the WebSocket
|
|
1366
|
+
* implementation the client was built with (`client.getWebSocketImpl()`),
|
|
1367
|
+
* NOT a raw `globalThis.WebSocket`.
|
|
1368
|
+
*/
|
|
1365
1369
|
createSocket?: CreateSocket;
|
|
1366
1370
|
/** Advanced/test seam: build the audio playback subsystem. Defaults to a Web Audio implementation. */
|
|
1367
1371
|
createSpeaker?: CreateSpeaker;
|
|
@@ -1378,8 +1382,12 @@ interface VoiceAgentOptions {
|
|
|
1378
1382
|
silenceDurationMs?: number;
|
|
1379
1383
|
/** Input RMS below which audio counts as silence. Default `0.01`. */
|
|
1380
1384
|
silenceThreshold?: number;
|
|
1381
|
-
/**
|
|
1382
|
-
|
|
1385
|
+
/**
|
|
1386
|
+
* The thread to converse on — shared with the agent's text turns. A plain
|
|
1387
|
+
* value, or a `Signal`/getter resolved afresh every time a call opens — the
|
|
1388
|
+
* reactive-args form the package's other primitives take.
|
|
1389
|
+
*/
|
|
1390
|
+
threadKey: (() => string) | string;
|
|
1383
1391
|
/** The generated `api.agents.<name>Voice` reference — identifies the voice DO endpoint. */
|
|
1384
1392
|
voice: VoiceReference;
|
|
1385
1393
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1361,7 +1361,11 @@ interface VoiceAgentOptions {
|
|
|
1361
1361
|
* Audio graph stays isolated (and mockable in a non-browser test env).
|
|
1362
1362
|
*/
|
|
1363
1363
|
createMicrophone?: CreateMicrophone;
|
|
1364
|
-
/**
|
|
1364
|
+
/**
|
|
1365
|
+
* Advanced/test seam: open the transport. Defaults to the WebSocket
|
|
1366
|
+
* implementation the client was built with (`client.getWebSocketImpl()`),
|
|
1367
|
+
* NOT a raw `globalThis.WebSocket`.
|
|
1368
|
+
*/
|
|
1365
1369
|
createSocket?: CreateSocket;
|
|
1366
1370
|
/** Advanced/test seam: build the audio playback subsystem. Defaults to a Web Audio implementation. */
|
|
1367
1371
|
createSpeaker?: CreateSpeaker;
|
|
@@ -1378,8 +1382,12 @@ interface VoiceAgentOptions {
|
|
|
1378
1382
|
silenceDurationMs?: number;
|
|
1379
1383
|
/** Input RMS below which audio counts as silence. Default `0.01`. */
|
|
1380
1384
|
silenceThreshold?: number;
|
|
1381
|
-
/**
|
|
1382
|
-
|
|
1385
|
+
/**
|
|
1386
|
+
* The thread to converse on — shared with the agent's text turns. A plain
|
|
1387
|
+
* value, or a `Signal`/getter resolved afresh every time a call opens — the
|
|
1388
|
+
* reactive-args form the package's other primitives take.
|
|
1389
|
+
*/
|
|
1390
|
+
threadKey: (() => string) | string;
|
|
1383
1391
|
/** The generated `api.agents.<name>Voice` reference — identifies the voice DO endpoint. */
|
|
1384
1392
|
voice: VoiceReference;
|
|
1385
1393
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{agent as t}from"./packem_shared/agent-
|
|
1
|
+
import{agent as t}from"./packem_shared/agent-CsE5xjQK.mjs";import{agentChat as m}from"./packem_shared/agentChat-kyvh-ktM.mjs";import{agentState as f}from"./packem_shared/agentState-B4sPm-HF.mjs";import{agentToolEvents as n}from"./packem_shared/agentToolEvents-CzZN-jQB.mjs";import{auth as i,authGate as u}from"./packem_shared/auth-BgwruT_M.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-CwhMtUIL.mjs";import{hydratePreloaded as C}from"./packem_shared/hydratePreloaded-CduDQN77.mjs";import{liveQuery as S}from"./packem_shared/liveQuery-BTIv0WUM.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-DmFYbw44.mjs";import{presence as K}from"./packem_shared/presence-DqzvJjBN.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-AffQZjVg.mjs";import{subscription as z}from"./packem_shared/subscription-TT5Jlxw0.mjs";import{voiceAgent as D}from"./packem_shared/voiceAgent-BZZoKTSV.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inject as p,DestroyRef as R,computed as o,signal as h}from"@angular/core";import{resolveLunoraClient as v}from"./LUNORA_CLIENT-B0toApHY.mjs";import{subscription as w}from"./subscription-
|
|
1
|
+
import{inject as p,DestroyRef as R,computed as o,signal as h}from"@angular/core";import{resolveLunoraClient as v}from"./LUNORA_CLIENT-B0toApHY.mjs";import{subscription as w}from"./subscription-TT5Jlxw0.mjs";const k=e=>{const{api:i,cancel:r,run:d,runArgs:l,threadKey:n}=e,a=v(e.client),u=e.destroyRef??p(R),{data:f}=w(i.agents.agentThread,{key:n},{client:a,destroyRef:u}),s=o(()=>f()),y=o(()=>s()?.status),c=h(!1),m=async(t,g)=>{c.set(!0);try{await a.mutation(d,{input:t,threadKey:n,...l,...g})}finally{c.set(!1)}};return{cancel:async()=>{const t=s()?.instanceId;r===void 0||t===void 0||await a.mutation(r,{instanceId:t,threadKey:n})},pending:c.asReadonly(),run:m,status:y,thread:s}};export{k as agent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inject as K,DestroyRef as M,signal as O,computed as c}from"@angular/core";import{reconcileOptimistic as R,maxSeq as k}from"@lunora/client";import{resolveLunoraClient as F}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as L}from"./stream-AffQZjVg.mjs";import{subscription as w}from"./subscription-
|
|
1
|
+
import{inject as K,DestroyRef as M,signal as O,computed as c}from"@angular/core";import{reconcileOptimistic as R,maxSeq as k}from"@lunora/client";import{resolveLunoraClient as F}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as L}from"./stream-AffQZjVg.mjs";import{subscription as w}from"./subscription-TT5Jlxw0.mjs";const N={__lunoraRef:""},U=m=>{const{api:d,cancel:g,limit:f,send:x,sendArgs:A,stream:h,threadKey:n}=m,r=F(m.client),l=m.destroyRef??K(M),I=f===void 0?{key:n}:{key:n,limit:f},{data:b}=w(d.agents.agentMessages,I,{client:r,destroyRef:l}),{data:j}=w(d.agents.agentThread,{key:n},{client:r,destroyRef:l}),S=h===void 0?"skip":{key:n},{chunks:q}=L(h??N,S,{client:r,destroyRef:l}),o=O([]);let y=0;const u=c(()=>j()),C=c(()=>u()?.status),i=c(()=>b()??[]),D=c(()=>{const t=i(),e=R(o(),t);if(e.length===0)return t;const s=k(t);return[...t,...e.map((a,p)=>({content:a.content,optimistic:!0,role:"user",seq:s+1+p}))]}),_=c(()=>{const t=i().filter(e=>e.role==="assistant").length;return q().filter(e=>e.kind!=="progress"&&e.threadKey===n&&e.turn>=t).map(e=>e.text).join("")}),E=async(t,e)=>{const s=y;y+=1;const a=k(i());o.set([...R(o(),i()),{content:t,id:s,maxDurableSeqAtSend:a}]);try{await r.mutation(x,{input:t,threadKey:n,...A,...e})}catch(p){throw o.set(o().filter(T=>T.id!==s)),p}},v=async(t,e,s)=>{const a=u()?.instanceId;if(a===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await r.mutation(d.agents.agentResolveApproval,{decision:t,instanceId:a,threadKey:n,toolCallId:e,...s===void 0?{}:{note:s}})};return{approve:async(t,e)=>v("approve",t,e),cancel:async()=>{const t=u()?.instanceId;g===void 0||t===void 0||await r.mutation(g,{instanceId:t,threadKey:n})},messages:D,reject:async(t,e)=>v("reject",t,e),send:E,status:C,streamingText:_}};export{U as agentChat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{computed as c}from"@angular/core";import{subscription as n}from"./subscription-
|
|
1
|
+
import{computed as c}from"@angular/core";import{subscription as n}from"./subscription-TT5Jlxw0.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inject as v,DestroyRef as f,computed as y}from"@angular/core";import{resolveLunoraClient as C}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as I}from"./stream-AffQZjVg.mjs";import{subscription as N}from"./subscription-
|
|
1
|
+
import{inject as v,DestroyRef as f,computed as y}from"@angular/core";import{resolveLunoraClient as C}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as I}from"./stream-AffQZjVg.mjs";import{subscription as N}from"./subscription-TT5Jlxw0.mjs";const m={__lunoraRef:""},E=[],R=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(r=>({input:r.input,seq:t.seq,toolCallId:r.id,toolName:r.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}}]},A=t=>{const{api:r,limit:e,stream:n,threadKey:l}=t,a=C(t.client),i=t.destroyRef??v(f),u=e===void 0?{key:l}:{key:l,limit:e},{data:s}=N(r.agents.agentMessages,u,{client:a,destroyRef:i}),p=n===void 0?"skip":{key:l},{chunks:c}=I(n??m,p,{client:a,destroyRef:i});return{events:y(()=>{const d=(s()??E).flatMap(o=>R(o)??[]);for(const o of c())o.kind==="progress"&&o.threadKey===l&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}};export{A as agentToolEvents};
|
|
@@ -1 +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-
|
|
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-R29Vk-0v.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};
|
|
@@ -1 +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-
|
|
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-R29Vk-0v.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{computed as R,inject as Q,DestroyRef as V,signal as L}from"@angular/core";import{initialPages as Z,derivePaginationStatus as U,applyLoadMore as v,rebalance as tt}from"@lunora/client/pagination";import{resolveLunoraClient as z}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as G,a as et}from"./platform-
|
|
1
|
+
import{computed as R,inject as Q,DestroyRef as V,signal as L}from"@angular/core";import{initialPages as Z,derivePaginationStatus as U,applyLoadMore as v,rebalance as tt}from"@lunora/client/pagination";import{resolveLunoraClient as z}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as G,a as et}from"./platform-R29Vk-0v.mjs";const nt=/["\\\u0000-\u001F\uD800-\uDFFF]/,J=t=>nt.test(t)?JSON.stringify(t):`"${t}"`,$=t=>{if(t===void 0)return"null";if(typeof t=="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 t=="number"){if(Number.isNaN(t))return"nan";if(t===1/0)return"inf";if(t===-1/0)return"-inf";if(Object.is(t,-0))return"-0"}if(typeof t=="string")return J(t);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t)){let r="[";for(let s=0;s<t.length;s++)s>0&&(r+=","),r+=$(t[s]);return r+"]"}const n=Object.getPrototypeOf(t);if(n!==null&&n!==Object.prototype){const r=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${r} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const o=t,i=Object.keys(o).sort();let c="{",e=!0;for(const r of i){const s=o[r];s!==void 0&&(e?e=!1:c+=",",c+=J(r),c+=":",c+=$(s))}return c+"}"},D=t=>{let n="";for(let i=0;i<t.length;i+=32768)n+=String.fromCharCode(...t.subarray(i,i+32768));return btoa(n)},d="$lunora.wire$",W=64,rt="__proto__",ot=t=>{if(t===null||typeof t!="object")return!1;const n=Object.getPrototypeOf(t);return n===null||n===Object.prototype},S=(t,n=0)=>{if(n>W)throw new RangeError(`wire-codec: value nesting exceeds the ${W}-level limit`);if(t===void 0)return[d,"undefined"];if(t===null)return null;const o=typeof t;if(o==="bigint")return[d,"bigint",t.toString()];if(o==="number"){const e=t;return Number.isNaN(e)?[d,"nan"]:e===1/0?[d,"inf"]:e===-1/0?[d,"-inf"]:e}if(o!=="object")return t;if(t instanceof Date)return[d,"date",S(t.getTime(),n+1)];if(t instanceof Error){const e=t,r={};for(const u of Object.keys(e))e[u]!==void 0&&(r[u]=S(e[u],n+1));const s=[d,"error",e.name,e.message,r];return e.cause!==void 0&&s.push(S(e.cause,n+1)),s}if(t instanceof URL)return[d,"url",t.href];if(t instanceof Map)return[d,"map",[...t.entries()].map(([e,r])=>[S(e,n+1),S(r,n+1)])];if(t instanceof Set)return[d,"set",[...t].map(e=>S(e,n+1))];if(t instanceof ArrayBuffer)return[d,"bytes",D(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){const e=t,r=e.constructor.name,s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return r==="Uint8Array"?[d,"bytes",D(s)]:[d,"bytes",D(s),r]}if(Array.isArray(t)){const e=t.map(r=>S(r,n+1));return e.length>0&&e[0]===d?[d,"arr",e]:e}if(!ot(t)){const e=t.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${e} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const i=t,c={};for(const e of Object.keys(i)){const r=i[e];if(r===void 0)continue;const s=S(r,n+1);e===rt?Object.defineProperty(c,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):c[e]=s}return c},st=t=>$(S(t)),K=(t,n)=>`${t}::${st(n)}`,M=(t,n)=>({...n,paginationOpts:{cursor:t.lower,endCursor:t.upper,numItems:t.numItems}}),q=(t,n,o,i)=>{const c=z(o.client),e=o.destroyRef===void 0&&i===void 0,{initialNumItems:r,shardKey:s}=o,u=t.__lunoraRef,p=n==="skip"?{}:n,a=L(Z(r)),E=L([]),B=L("LoadingFirstPage"),A=L(void 0),k=new Map,m=new Map,C=new Set,N=()=>{const b=a().map(f=>{const l=K(u,M(f,p));return m.get(l)});E.set(b);const{status:P}=U(n==="skip",b);B.set(P)},X=(w,b)=>{const P=f=>K(u,M(f,p));for(const f of b){const l=P(f);if(m.has(l))continue;const g=w.find(y=>y.lower===f.lower);if(g){const y=m.get(P(g));y&&m.set(l,y)}}},Y=w=>{const b=new Set;for(const f of w)b.add(K(u,M(f,p)));for(const[f,l]of k)b.has(l.currentKey)||(l.unsub(),k.delete(f),m.delete(l.currentKey));const P=new Set([...k.values()].map(f=>f.currentKey));for(const f of w){const l=M(f,p),g=K(u,l);if(P.has(g))continue;const y={currentKey:g,unsub:void 0};C.add(g);const x=c.subscribe(t,l,O=>{if(m.set(y.currentKey,O),C.delete(y.currentKey),A.set(void 0),N(),C.size===0){const h=a(),j=tt(h,E());j&&(X(h,j),a.set(j),F(j),N())}},{onError:O=>{C.delete(g),A.set(O);const h=a(),j=h.at(-1);h.length>1&&j&&!m.has(g)&&K(u,M(j,p))===g&&(a.set(h.slice(0,-1)),F(a())),N(),o.onError?.(O)},shardKey:s});y.unsub=x,k.set(g,y),P.add(g)}};let I=!1,_=!1;const F=w=>{if(I){_=!0;return}I=!0;try{let b=w;do _=!1,Y(b),b=a();while(_)}finally{I=!1}};n!=="skip"&&G(e)&&F(a()),N();const T=()=>{for(const w of k.values())w.unsub();k.clear(),m.clear()};return i===void 0?(o.destroyRef??Q(V)).onDestroy(T):i(T),{error:A,loadMore:w=>{if(n==="skip")return;const{nextCursor:b,status:P}=U(!1,E());if(P!=="CanLoadMore")return;const f=v(a(),b,w);if(!f)return;const l=a().at(-1),g=f.at(-2);if(l&&g){const y=K(u,M(l,p)),x=K(u,M(g,p)),O=k.get(y);if(O&&y!==x){const h=m.get(y);h&&m.set(x,h),O.unsub(),k.delete(y),m.delete(y)}}A.set(void 0),a.set(f),F(a()),N()},pageResults:E,status:B}},H=(t,n,o)=>{if(typeof n!="function")return q(t,n,o);const i=z(o.client),c=o.destroyRef===void 0,e=o.destroyRef??Q(V),r=L(void 0);return G(c)&&et(n,{destroyRef:e,injector:o.injector},(s,u)=>{const p=[];r.set(q(t,s,{...o,client:i},a=>p.push(a))),u(()=>{for(const a of p)a()})}),{error:R(()=>r()?.error()),loadMore:s=>{r()?.loadMore(s)},pageResults:R(()=>r()?.pageResults()??[]),status:R(()=>r()?.status()??"LoadingFirstPage")}},yt=(t,n,o)=>{const i=H(t,n,o),c=R(()=>i.pageResults().flatMap(r=>r?.page??[])),e=R(()=>{const r=i.status();return r==="LoadingFirstPage"||r==="LoadingMore"});return{error:i.error,isLoading:e,loadMore:i.loadMore,results:c,status:i.status}},dt=(t,n,o)=>{const{initialNumItems:i}=o,c=H(t,n,o),e=R(()=>c.pageResults().flatMap(a=>a?[a.page]:[])),r=R(()=>c.status()==="LoadingFirstPage"),s=R(()=>c.status()==="CanLoadMore"),u=R(()=>c.status()==="LoadingMore"),p=a=>{c.loadMore(a??i)};return{error:c.error,fetchNextPage:p,hasNextPage:s,isFetchingNextPage:u,isLoading:r,pages:e,status:c.status}};export{dt as infiniteQuery,yt as paginatedQuery};
|
|
@@ -1 +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-
|
|
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-R29Vk-0v.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{inject as s,PLATFORM_ID as c,effect as a,untracked as u,NgZone as d}from"@angular/core";const p=r=>r?s(c,{optional:!0})!=="server":!0,l=r=>{const e=r?s(d,{optional:!0}):void 0;return e?t=>e.runOutsideAngular(t):t=>t()},v=(r,e)=>l(r)(e),g=(r,e,t)=>{let n;try{n=a(o=>{const i=r();u(()=>{t(i,o)})},{injector:e.injector,manualCleanup:!0})}catch(o){throw e.injector!==void 0?o:new Error("reactive `args` need an injection context: call this primitive from a component/service field or constructor, or pass `injector` alongside `destroyRef`.",{cause:o})}e.destroyRef.onDestroy(()=>{n.destroy()})};export{g as a,l as o,v as r,p as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inject as I,DestroyRef as h,signal as D}from"@angular/core";import{resolveLunoraClient as S}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as U,r as C}from"./platform-
|
|
1
|
+
import{inject as I,DestroyRef as h,signal as D}from"@angular/core";import{resolveLunoraClient as S}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as U,r as C}from"./platform-R29Vk-0v.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")},E=1e4,x=(n,e)=>{const s=S(e.client),d=e.destroyRef===void 0,f=e.destroyRef??I(h),{heartbeat:y,listPresent:m,shardKey:i}=e,o=e.intervalMs??E,a=e.sessionId??A(),u=D(void 0);if(!Number.isFinite(o)||o<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(o)}`);let c=e.data;const r=()=>{const t={roomId:n,sessionId:a};c!==void 0&&(t.data=c),s.mutation(y,t,{shardKey:i}).catch(()=>{})},p=t=>{c=t,r()};if(U(d)){const t=s.acquireConnectionContext({roomId:n,sessionId:a},{shardKey:i});r();const l=()=>{typeof document<"u"&&document.visibilityState==="visible"&&r()},v=C(d,()=>(typeof document<"u"&&document.addEventListener("visibilitychange",l),setInterval(r,o))),b={roomId:n},g=s.subscribe(m,b,R=>{u.set(R)},{shardKey:i});f.onDestroy(()=>{clearInterval(v),typeof document<"u"&&document.removeEventListener("visibilitychange",l),t(),g()})}return{present:u.asReadonly(),sessionId:a,setData:p}};export{x as presence};
|
|
@@ -1 +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-
|
|
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-R29Vk-0v.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 S}from"@angular/core";import{resolveLunoraClient as q}from"./LUNORA_CLIENT-B0toApHY.mjs";import{o as V}from"./platform-R29Vk-0v.mjs";const L="/_lunora/ws",j="/_lunora/voice/",J=4001,I=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,G=e=>{const s=e.startsWith("agents:")?e.slice(7):e;return s.endsWith("Voice")?s.slice(0,-5):s},X=(e,s)=>{if(s===void 0||s==="")return I(e);if(s.endsWith(L))return s.slice(0,-L.length);try{return new URL(s).origin}catch{return I(e)}},z=e=>{const s=X(e.httpUrl,e.wsUrl),o=s.endsWith("/")?s.slice(0,-1):s,i=new URLSearchParams({threadKey:e.threadKey});return`${o}${j}${encodeURIComponent(e.agent)}?${i.toString()}`},Q=(e,s)=>{if(s?.code===J)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},Y=16e3,Z=e=>{if(e.length===0)return 0;let s=0;for(const o of e)s+=o*o;return Math.sqrt(s/e.length)},ee=(e,s)=>{const o=s/Y,i=o>1?Math.floor(e.length/o):e.length,g=new ArrayBuffer(i*2),u=new DataView(g);for(let c=0;c<i;c+=1){const m=e[Math.floor(c*o)]??0,d=Math.max(-1,Math.min(1,m));u.setInt16(c*2,d<0?d*32768:d*32767,!0)}return new Uint8Array(g)},te=async e=>{const s=globalThis,o=s.navigator?.mediaDevices?.getUserMedia.bind(s.navigator.mediaDevices),i=s.AudioContext??s.webkitAudioContext;if(!o||!i)throw new Error("voiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const g=await o({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),u=new i,c=u.createMediaStreamSource(g),m=u.createScriptProcessor(4096,1,1);let d=!1,y=!1,l=0,f=0;return m.onaudioprocess=p=>{const h=p.inputBuffer.getChannelData(0),r=d?0:Z(h);if(e.onLevel(r),d)return;if(e.onAudio(ee(h,u.sampleRate)),e.isSpeaking()){f=r>=e.interruptThreshold?f+1:0,f>=e.interruptChunks&&(f=0,e.onInterrupt());return}f=0;const v=h.length/u.sampleRate*1e3;if(r>=e.silenceThreshold){y=!0,l=0;return}y&&(l+=v,l>=e.silenceDurationMs&&(y=!1,l=0,e.onSilence()))},c.connect(m),m.connect(u.destination),{setMuted:p=>{d=p},stop:()=>{m.disconnect(),c.disconnect();for(const p of g.getTracks())p.stop();u.close()}}},ne=()=>{const e=globalThis,s=e.AudioContext??e.webkitAudioContext;if(!s)throw new Error("voiceAgent: audio playback requires AudioContext (no browser audio available)");const o=new s,i=new Set;let g=0,u=Promise.resolve(),c=0;const m=async(l,f)=>{if(f!==c)return;let p;try{p=await o.decodeAudioData(l.buffer)}catch{return}if(f!==c)return;const h=o.createBufferSource();h.buffer=p,h.connect(o.destination);const r=Math.max(o.currentTime,g);h.start(r),g=r+p.duration,i.add(h),h.onended=()=>{i.delete(h)}},d=l=>{const f=Uint8Array.from(l),p=c;u=u.then(()=>m(f,p))},y=()=>{c+=1;for(const l of i)try{l.stop()}catch{}i.clear(),g=o.currentTime};return{enqueue:d,interrupt:y,stop:()=>{y(),o.close()}}},F=1,se=.01,oe=1200,re=.15,ae=3,ue=e=>{const{createMicrophone:s=te,createSpeaker:o=ne,createSocket:i,interruptChunks:g=ae,interruptThreshold:u=re,silenceDurationMs:c=oe,silenceThreshold:m=se,threadKey:d,voice:y}=e,l=q(e.client),f=e.destroyRef===void 0,p=e.destroyRef??B(K),h=V(f),r=S("idle"),v=S(!1),_=S(""),E=S(""),x=S(0),R=S(!1),w=S(void 0);let a,T=!1;const M=t=>{const n=a?.socket;return n?.readyState===F?(n.send(JSON.stringify(t)),!0):!1},b=()=>{const t=a;if(a=void 0,t){t.microphone?.stop(),t.speaker?.stop(),t.socket.onmessage=null,t.socket.onerror=null,t.socket.onclose=null;try{t.socket.close()}catch{}}T=!1,v.set(!1),r.set("idle"),x.set(0)},W=b,N=t=>{const n=a;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),r.set("speaking"),E.update(U=>U+t.text);break}case"assistant_done":{n&&(n.speaking=!1),E.set(t.text),r.set("listening");break}case"error":{n&&(n.speaking=!1),w.set(new Error(t.message)),r.set("listening");break}case"interrupted":{n&&(n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),r.set("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),v.set(!0),r.set("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),_.set(t.text),E.set(""),r.set("thinking");break}}},O=t=>{const n=a;!n||n.suppressAudio||(n.speaker??=o({audioFormat:n.audioFormat}),n.speaking=!0,r.set("speaking"),n.speaker.enqueue(t))},P=async()=>{if(a||T)return;T=!0,w.set(void 0),_.set(""),E.set("");let t;try{const n=z({agent:G(y.__lunoraRef),httpUrl:l.url,threadKey:typeof d=="function"?d():d,wsUrl:l.wsUrl}),U=i??(k=>{const C=l.getWebSocketImpl();if(!C)throw new Error("voiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new C(k)}),A=h(()=>U(n));A.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:A,speaker:void 0,speaking:!1,suppressAudio:!1},a=t,A.onmessage=k=>{if(typeof k.data=="string"){try{N(JSON.parse(k.data))}catch{}return}O(new Uint8Array(k.data))},A.onerror=()=>{w.set(new Error("voiceAgent: voice socket error"))},A.onclose=k=>{if(a!==t)return;const C=Q("voiceAgent",k);C&&w.set(C),b()};const D=await h(async()=>s({interruptChunks:g,interruptThreshold:u,isSpeaking:()=>a?.speaking??!1,onAudio:k=>{A.readyState===F&&A.send(k)},onInterrupt:()=>{M({type:"interrupt"}),a?.speaker?.interrupt(),a&&(a.speaking=!1,a.suppressAudio=!0),r.set("listening")},onLevel:k=>{x.set(k)},onSilence:()=>{M({type:"commit"}),r.set("thinking")},silenceDurationMs:c,silenceThreshold:m}));a===t?(t.microphone=D,R.set(!1),t.speaking||r.set("listening")):D.stop()}catch(n){a===t&&(w.set(n instanceof Error?n:new Error(String(n))),b())}finally{T=!1}},H=()=>{const t=!R();return a?.microphone?.setMuted(t),R.set(t),t},$=t=>{M({text:t,type:"text"})&&r.set("thinking")};return p.onDestroy(b),{audioLevel:x.asReadonly(),connected:v.asReadonly(),endCall:W,error:w.asReadonly(),interimTranscript:E.asReadonly(),isMuted:R.asReadonly(),sendText:$,startCall:P,status:r.asReadonly(),toggleMute:H,transcript:_.asReadonly()}};export{ue as voiceAgent};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/angular",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.59",
|
|
4
4
|
"description": "Angular reactive adapter for Lunora — signal-based live queries and mutations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@lunora/client": "1.0.0-alpha.
|
|
57
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
56
|
+
"@lunora/client": "1.0.0-alpha.75",
|
|
57
|
+
"@lunora/ratelimit": "1.0.0-alpha.38",
|
|
58
58
|
"@visulima/storage-client": "1.0.2"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{inject as c,PLATFORM_ID as i,effect as a,untracked as u,NgZone as d}from"@angular/core";const f=t=>t?c(i,{optional:!0})!=="server":!0,p=(t,e)=>{const r=t?c(d,{optional:!0}):void 0;return r?r.runOutsideAngular(e):e()},v=(t,e,r)=>{let n;try{n=a(o=>{const s=t();u(()=>{r(s,o)})},{injector:e.injector,manualCleanup:!0})}catch(o){throw e.injector!==void 0?o:new Error("reactive `args` need an injection context: call this primitive from a component/service field or constructor, or pass `injector` alongside `destroyRef`.",{cause:o})}e.destroyRef.onDestroy(()=>{n.destroy()})};export{v as a,p as r,f as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{inject as P,DestroyRef as W,signal as w}from"@angular/core";import{resolveLunoraClient as H}from"./LUNORA_CLIENT-B0toApHY.mjs";const O=16e3,q=e=>{if(e.length===0)return 0;let r=0;for(const o of e)r+=o*o;return Math.sqrt(r/e.length)},B=(e,r)=>{const o=r/O,a=o>1?Math.floor(e.length/o):e.length,d=new ArrayBuffer(a*2),i=new DataView(d);for(let u=0;u<a;u+=1){const k=e[Math.floor(u*o)]??0,f=Math.max(-1,Math.min(1,k));i.setInt16(u*2,f<0?f*32768:f*32767,!0)}return new Uint8Array(d)},$=async e=>{const r=globalThis,o=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),a=r.AudioContext??r.webkitAudioContext;if(!o||!a)throw new Error("voiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await o({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),i=new a,u=i.createMediaStreamSource(d),k=i.createScriptProcessor(4096,1,1);let f=!1,A=!1,p=0,h=0;return k.onaudioprocess=s=>{const l=s.inputBuffer.getChannelData(0),g=f?0:q(l);if(e.onLevel(g),f)return;if(e.onAudio(B(l,i.sampleRate)),e.isSpeaking()){h=g>=e.interruptThreshold?h+1:0,h>=e.interruptChunks&&(h=0,e.onInterrupt());return}h=0;const S=l.length/i.sampleRate*1e3;if(g>=e.silenceThreshold){A=!0,p=0;return}A&&(p+=S,p>=e.silenceDurationMs&&(A=!1,p=0,e.onSilence()))},u.connect(k),k.connect(i.destination),{setMuted:s=>{f=s},stop:()=>{k.disconnect(),u.disconnect();for(const s of d.getTracks())s.stop();i.close()}}},V=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("voiceAgent: audio playback requires AudioContext (no browser audio available)");const o=new r,a=new Set;let d=0,i=Promise.resolve(),u=0;const k=async(p,h)=>{if(h!==u)return;let s;try{s=await o.decodeAudioData(p.buffer)}catch{return}if(h!==u)return;const l=o.createBufferSource();l.buffer=s,l.connect(o.destination);const g=Math.max(o.currentTime,d);l.start(g),d=g+s.duration,a.add(l),l.onended=()=>{a.delete(l)}},f=p=>{const h=Uint8Array.from(p),s=u;i=i.then(()=>k(h,s))},A=()=>{u+=1;for(const p of a)try{p.stop()}catch{}a.clear(),d=o.currentTime};return{enqueue:f,interrupt:A,stop:()=>{A(),o.close()}}},_=1,J=.01,K=1200,j=.15,G=3,z=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,Q=e=>{const r=e.__lunoraRef,o=r.startsWith("agents:")?r.slice(7):r;return o.endsWith("Voice")?o.slice(0,-5):o},X=(e,r,o)=>{const a=z(e),d=a.endsWith("/")?a.slice(0,-1):a,i=new URLSearchParams({threadKey:o});return`${d}/_lunora/voice/${encodeURIComponent(r)}?${i.toString()}`},ee=e=>{const{createMicrophone:r=$,createSpeaker:o=V,createSocket:a,interruptChunks:d=G,interruptThreshold:i=j,silenceDurationMs:u=K,silenceThreshold:k=J,threadKey:f,voice:A}=e,p=H(e.client),h=e.destroyRef??P(W),s=w("idle"),l=w(!1),g=w(""),S=w(""),E=w(0),T=w(!1),v=w(void 0);let c,b=!1;const M=t=>{const n=c?.socket;return n?.readyState===_?(n.send(JSON.stringify(t)),!0):!1},R=()=>{const t=c;if(c=void 0,t){t.microphone?.stop(),t.speaker?.stop();try{t.socket.close()}catch{}}b=!1,l.set(!1),s.set("idle"),E.set(0)},U=R,D=t=>{const n=c;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),s.set("speaking"),S.update(m=>m+t.text);break}case"assistant_done":{n&&(n.speaking=!1),S.set(t.text),s.set("listening");break}case"error":{n&&(n.speaking=!1),v.set(new Error(t.message)),s.set("listening");break}case"interrupted":{n&&(n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),s.set("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),l.set(!0),s.set("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),g.set(t.text),S.set(""),s.set("thinking");break}}},L=t=>{const n=c;!n||n.suppressAudio||(n.speaker??=o({audioFormat:n.audioFormat}),n.speaking=!0,s.set("speaking"),n.speaker.enqueue(t))},F=async()=>{if(!(c||b)){b=!0,v.set(void 0),g.set(""),S.set("");try{const t=X(p.url,Q(A),f),m=(a??(y=>new globalThis.WebSocket(y)))(t);m.binaryType="arraybuffer";const C={audioFormat:"mp3",microphone:void 0,socket:m,speaker:void 0,speaking:!1,suppressAudio:!1};c=C,m.onmessage=y=>{if(typeof y.data=="string"){try{D(JSON.parse(y.data))}catch{}return}L(new Uint8Array(y.data))},m.onerror=()=>{v.set(new Error("voiceAgent: voice socket error"))},m.onclose=()=>{c===C&&R()};const x=await r({interruptChunks:d,interruptThreshold:i,isSpeaking:()=>c?.speaking??!1,onAudio:y=>{m.readyState===_&&m.send(y)},onInterrupt:()=>{M({type:"interrupt"}),c?.speaker?.interrupt(),c&&(c.speaking=!1,c.suppressAudio=!0),s.set("listening")},onLevel:y=>{E.set(y)},onSilence:()=>{M({type:"commit"}),s.set("thinking")},silenceDurationMs:u,silenceThreshold:k});c===C?(C.microphone=x,T.set(!1),s.set("listening")):x.stop()}catch(t){v.set(t instanceof Error?t:new Error(String(t))),R()}finally{b=!1}}},N=()=>{const t=!T();return c?.microphone?.setMuted(t),T.set(t),t},I=t=>{M({text:t,type:"text"})&&s.set("thinking")};return h.onDestroy(R),{audioLevel:E.asReadonly(),connected:l.asReadonly(),endCall:U,error:v.asReadonly(),interimTranscript:S.asReadonly(),isMuted:T.asReadonly(),sendText:I,startCall:F,status:s.asReadonly(),toggleMute:N,transcript:g.asReadonly()}};export{ee as voiceAgent};
|