@lunora/solid 1.0.0-alpha.162 → 1.0.0-alpha.163
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 +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{AuthLoading-DKoQs-9J.mjs → AuthLoading-DjUnIaP5.mjs} +1 -1
- package/dist/packem_shared/LunoraContext-BWsj_3CK.mjs +1 -0
- package/dist/packem_shared/LunoraProvider-DMhpuxvx.mjs +1 -0
- package/dist/packem_shared/{createAction-M4s8XBXV.mjs → createAction-BZkayM2R.mjs} +1 -1
- package/dist/packem_shared/{createAgent-4wFKlDvV.mjs → createAgent-ClUHcuLQ.mjs} +1 -1
- package/dist/packem_shared/{createAgentChat-BcOUF-3C.mjs → createAgentChat-CcXKtq6E.mjs} +1 -1
- package/dist/packem_shared/{createAgentState-KojjkWsi.mjs → createAgentState-DiO83WZD.mjs} +1 -1
- package/dist/packem_shared/{createAgentToolEvents-DUAkn3eP.mjs → createAgentToolEvents-qnjy40Nf.mjs} +1 -1
- package/dist/packem_shared/{createConnectionStatus-BnlXYWeE.mjs → createConnectionStatus-D8bC05Jn.mjs} +1 -1
- package/dist/packem_shared/{createFlag-JN9dYhDQ.mjs → createFlag-C2_nVE8X.mjs} +1 -1
- package/dist/packem_shared/{createInfiniteQuery-BuxNVHct.mjs → createInfiniteQuery-U-hmiGPH.mjs} +1 -1
- package/dist/packem_shared/{createMutation-DcSsIbGF.mjs → createMutation-DM2mXpq3.mjs} +1 -1
- package/dist/packem_shared/{createPresence-Bu4loG39.mjs → createPresence-QYsDYovA.mjs} +1 -1
- package/dist/packem_shared/{createQuery-aadhebsp.mjs → createQuery-BLBqpxzz.mjs} +1 -1
- package/dist/packem_shared/{createStream-Dx7SnivS.mjs → createStream-CCAOb9q1.mjs} +1 -1
- package/dist/packem_shared/{createSubscription-DK6JFpEA.mjs → createSubscription-BNX2MuML.mjs} +1 -1
- package/dist/packem_shared/{createVoiceAgent-C4uRX2Ca.mjs → createVoiceAgent-C7uDA2VU.mjs} +1 -1
- package/dist/packem_shared/hydratePreloaded-DCi296oW.mjs +1 -0
- package/package.json +1 -1
- package/dist/packem_shared/LunoraContext-dPcjtn6R.mjs +0 -1
- package/dist/packem_shared/LunoraProvider-BKWckcDR.mjs +0 -1
- package/dist/packem_shared/hydratePreloaded-Dkt8F6wg.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1137,7 +1137,8 @@ declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoic
|
|
|
1137
1137
|
* (`client.identityEpoch() > 0`), every `hydratePreloaded` on the client (mounted
|
|
1138
1138
|
* then or later) stops using it and returns `undefined` until the live value
|
|
1139
1139
|
* arrives — matching `@lunora/react`'s `usePreloadedQuery`, hence the
|
|
1140
|
-
* `Accessor<T | undefined>` type.
|
|
1140
|
+
* `Accessor<T | undefined>` type. The same holds under a `LunoraProvider` whose
|
|
1141
|
+
* `client` was swapped: the value was preloaded for the first client.
|
|
1141
1142
|
*/
|
|
1142
1143
|
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, options?: {
|
|
1143
1144
|
onError?: SubscriptionErrorCallback;
|
|
@@ -1171,13 +1172,21 @@ interface LunoraProviderProps {
|
|
|
1171
1172
|
* ), root);
|
|
1172
1173
|
* ```
|
|
1173
1174
|
*
|
|
1175
|
+
* Swapping the `client` prop for a different instance **remounts the subtree**
|
|
1176
|
+
* under the provider. Solid's providers read their value once, so the swap
|
|
1177
|
+
* cannot be pushed into primitives that already resolved the client; instead
|
|
1178
|
+
* every primitive below is disposed (its subscriptions on the old client torn
|
|
1179
|
+
* down) and recreated against the new client, starting from `undefined` — no
|
|
1180
|
+
* rows from the old client survive, and `hydratePreloaded` does not seed a value
|
|
1181
|
+
* preloaded for the client the provider first rendered with (not even after
|
|
1182
|
+
* swapping back to it). Local component state under the provider resets with
|
|
1183
|
+
* it. Re-reading the same instance is a no-op.
|
|
1184
|
+
*
|
|
1174
1185
|
* Written with `createComponent` rather than JSX on purpose. Solid 1.x and 2.0
|
|
1175
1186
|
* compile JSX against different runtimes (`solid-js/web` vs `@solidjs/web`), so
|
|
1176
1187
|
* a JSX source file would force this package to ship two builds; `createComponent`
|
|
1177
1188
|
* is exported from the `solid-js` root in both majors, and the provider component
|
|
1178
|
-
* itself is resolved per-major by {@link providerOf}.
|
|
1179
|
-
* both props lazy, so swapping the `client` prop re-provides the new value to
|
|
1180
|
-
* descendants exactly as the JSX form did.
|
|
1189
|
+
* itself is resolved per-major by {@link providerOf}.
|
|
1181
1190
|
*/
|
|
1182
1191
|
declare const LunoraProvider: (props: LunoraProviderProps) => SolidElement;
|
|
1183
1192
|
export { type ActionClient, type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type CreateAgentApi, type CreateAgentChatApi, type CreateAgentChatOptions, type CreateAgentChatResult, type CreateAgentOptions, type CreateAgentResult, type CreateAgentStateApi, type CreateAgentStateOptions, type CreateAgentStateResult, type CreateAgentToolEventsApi, type CreateAgentToolEventsOptions, type CreateAgentToolEventsResult, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateStreamOptions, type CreateStreamResult, type CreateStreamStatus, type CreateSubscriptionResult, type CreateVoiceAgentOptions, type CreateVoiceAgentResult, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider,
|
package/dist/index.d.ts
CHANGED
|
@@ -1137,7 +1137,8 @@ declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoic
|
|
|
1137
1137
|
* (`client.identityEpoch() > 0`), every `hydratePreloaded` on the client (mounted
|
|
1138
1138
|
* then or later) stops using it and returns `undefined` until the live value
|
|
1139
1139
|
* arrives — matching `@lunora/react`'s `usePreloadedQuery`, hence the
|
|
1140
|
-
* `Accessor<T | undefined>` type.
|
|
1140
|
+
* `Accessor<T | undefined>` type. The same holds under a `LunoraProvider` whose
|
|
1141
|
+
* `client` was swapped: the value was preloaded for the first client.
|
|
1141
1142
|
*/
|
|
1142
1143
|
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, options?: {
|
|
1143
1144
|
onError?: SubscriptionErrorCallback;
|
|
@@ -1171,13 +1172,21 @@ interface LunoraProviderProps {
|
|
|
1171
1172
|
* ), root);
|
|
1172
1173
|
* ```
|
|
1173
1174
|
*
|
|
1175
|
+
* Swapping the `client` prop for a different instance **remounts the subtree**
|
|
1176
|
+
* under the provider. Solid's providers read their value once, so the swap
|
|
1177
|
+
* cannot be pushed into primitives that already resolved the client; instead
|
|
1178
|
+
* every primitive below is disposed (its subscriptions on the old client torn
|
|
1179
|
+
* down) and recreated against the new client, starting from `undefined` — no
|
|
1180
|
+
* rows from the old client survive, and `hydratePreloaded` does not seed a value
|
|
1181
|
+
* preloaded for the client the provider first rendered with (not even after
|
|
1182
|
+
* swapping back to it). Local component state under the provider resets with
|
|
1183
|
+
* it. Re-reading the same instance is a no-op.
|
|
1184
|
+
*
|
|
1174
1185
|
* Written with `createComponent` rather than JSX on purpose. Solid 1.x and 2.0
|
|
1175
1186
|
* compile JSX against different runtimes (`solid-js/web` vs `@solidjs/web`), so
|
|
1176
1187
|
* a JSX source file would force this package to ship two builds; `createComponent`
|
|
1177
1188
|
* is exported from the `solid-js` root in both majors, and the provider component
|
|
1178
|
-
* itself is resolved per-major by {@link providerOf}.
|
|
1179
|
-
* both props lazy, so swapping the `client` prop re-provides the new value to
|
|
1180
|
-
* descendants exactly as the JSX form did.
|
|
1189
|
+
* itself is resolved per-major by {@link providerOf}.
|
|
1181
1190
|
*/
|
|
1182
1191
|
declare const LunoraProvider: (props: LunoraProviderProps) => SolidElement;
|
|
1183
1192
|
export { type ActionClient, type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type CreateAgentApi, type CreateAgentChatApi, type CreateAgentChatOptions, type CreateAgentChatResult, type CreateAgentOptions, type CreateAgentResult, type CreateAgentStateApi, type CreateAgentStateOptions, type CreateAgentStateResult, type CreateAgentToolEventsApi, type CreateAgentToolEventsOptions, type CreateAgentToolEventsResult, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateStreamOptions, type CreateStreamResult, type CreateStreamStatus, type CreateSubscriptionResult, type CreateVoiceAgentOptions, type CreateVoiceAgentResult, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider,
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraContext as r,useLunora as o}from"./packem_shared/LunoraContext-
|
|
1
|
+
import{LunoraContext as r,useLunora as o}from"./packem_shared/LunoraContext-BWsj_3CK.mjs";import{createAction as c,createActionForClient as n}from"./packem_shared/createAction-BZkayM2R.mjs";import{createAgent as m}from"./packem_shared/createAgent-ClUHcuLQ.mjs";import{createAgentChat as x}from"./packem_shared/createAgentChat-CcXKtq6E.mjs";import{createAgentState as u}from"./packem_shared/createAgentState-DiO83WZD.mjs";import{createAgentToolEvents as A}from"./packem_shared/createAgentToolEvents-qnjy40Nf.mjs";import{AuthLoading as l,Authenticated as s,Unauthenticated as h,createAuth as C}from"./packem_shared/AuthLoading-DjUnIaP5.mjs";import{default as y}from"./packem_shared/createConnectionStatus-D8bC05Jn.mjs";import{createFlag as P,createFlags as S}from"./packem_shared/createFlag-C2_nVE8X.mjs";import{createMutation as Q,createMutationForClient as v}from"./packem_shared/createMutation-DM2mXpq3.mjs";import{createMutator as E}from"./packem_shared/createMutator-q9cMjGKv.mjs";import{createInfiniteQuery as R,createPaginatedQuery as T}from"./packem_shared/createInfiniteQuery-U-hmiGPH.mjs";import{createPresence as V}from"./packem_shared/createPresence-QYsDYovA.mjs";import{createQuery as k}from"./packem_shared/createQuery-BLBqpxzz.mjs";import{createRateLimit as w}from"./packem_shared/createRateLimit-CIVWrD5H.mjs";import{createStream as B}from"./packem_shared/createStream-CCAOb9q1.mjs";import{createSubscription as G}from"./packem_shared/createSubscription-BNX2MuML.mjs";import{createVoiceAgent as J}from"./packem_shared/createVoiceAgent-C7uDA2VU.mjs";import{default as N}from"./packem_shared/hydratePreloaded-DCi296oW.mjs";import{LunoraProvider as W}from"./packem_shared/LunoraProvider-DMhpuxvx.mjs";export{l as AuthLoading,s as Authenticated,r as LunoraContext,W as LunoraProvider,h as Unauthenticated,c as createAction,n as createActionForClient,m as createAgent,x as createAgentChat,u as createAgentState,A as createAgentToolEvents,C as createAuth,y as createConnectionStatus,P as createFlag,S as createFlags,R as createInfiniteQuery,Q as createMutation,v as createMutationForClient,E as createMutator,T as createPaginatedQuery,V as createPresence,k as createQuery,w as createRateLimit,B as createStream,G as createSubscription,J as createVoiceAgent,N as hydratePreloaded,o as useLunora};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getIdentityStore as d,isAuthenticatedStatus as k,isLoadingStatus as l}from"@lunora/client/auth";import{createSignal as s,onCleanup as m,createComponent as A,Show as T}from"solid-js";import{useLunora as p}from"./LunoraContext-
|
|
1
|
+
import{getIdentityStore as d,isAuthenticatedStatus as k,isLoadingStatus as l}from"@lunora/client/auth";import{createSignal as s,onCleanup as m,createComponent as A,Show as T}from"solid-js";import{useLunora as p}from"./LunoraContext-BWsj_3CK.mjs";const U=()=>{const t=p(),e=d(t),[n,r]=s(t.getAuthToken()),[a,c]=s(e.getUser()),[i,h]=s(e.getStatus()),g=t.onAuthTokenChange(o=>{r(()=>o)}),S=e.subscribe(()=>{c(()=>e.getUser()),h(()=>e.getStatus())});return m(()=>{g(),S()}),{setToken:o=>{t.setAuthToken(o)},status:i,token:n,user:a}},b=T,u=t=>e=>{const n=U();return A(b,{get children(){return e.children},get when(){return t(n)}})},x=u(({status:t})=>k(t())),y=u(({status:t})=>l(t())),G=u(({status:t})=>t()==="unauthenticated");export{y as AuthLoading,x as Authenticated,G as Unauthenticated,U as createAuth};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as o}from"@lunora/errors";import{createContext as e,useContext as r}from"solid-js";const n=e(),u=e(!1),c=()=>{try{return r(u)}catch{return!1}},i=()=>{let t;try{t=r(n)}catch{t=void 0}if(!t)throw new o("INTERNAL","useLunora must be used inside <LunoraProvider />");return t};export{u as LunoraClientSwappedContext,n as LunoraContext,i as useLunora,c as useLunoraClientSwapped};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createMemo as o,untrack as p,createComponent as c}from"solid-js";import{LunoraContext as l,LunoraClientSwappedContext as d}from"./LunoraContext-BWsj_3CK.mjs";import{p as i}from"./solid-compat-ByG5HD_F.mjs";const f=t=>{const a=o(()=>t.client),u=(e,r)=>c(i(l),{get children(){return c(i(d),{get children(){return t.children},value:r})},value:e});let n=0;return o(()=>{const e=a(),r=n>0;return n+=1,p(()=>u(e,r))})};export{f as LunoraProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCallRunner as m}from"@lunora/client";import{createSignal as r}from"solid-js";import{useLunora as p}from"./LunoraContext-
|
|
1
|
+
import{createCallRunner as m}from"@lunora/client";import{createSignal as r}from"solid-js";import{useLunora as p}from"./LunoraContext-BWsj_3CK.mjs";const u=(t,c)=>{const[s,n]=r(void 0),[a,e]=r(void 0),[i,l]=r(!1);return{call:m((o,d)=>t.action(c,o,d),{setError:e,setPending:l,setResult:o=>{n(()=>o),e(void 0)}}),data:s,error:a,pending:i,reset:()=>{n(()=>{}),e(void 0)}}},R=t=>u(p(),t);export{R as createAction,u as createActionForClient};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as s}from"solid-js";import{createMutation as i}from"./createMutation-
|
|
1
|
+
import{createMemo as s}from"solid-js";import{createMutation as i}from"./createMutation-DM2mXpq3.mjs";import{createSubscription as R}from"./createSubscription-BNX2MuML.mjs";const _={__lunoraRef:""},a=t=>typeof t=="function"?t():t,b=t=>{const{api:u,cancel:c,onError:d,run:f,runArgs:m,threadKey:n}=t,o=i(f),p=i(c??_),{data:y,error:g}=R(u.agents.agentThread,()=>({key:a(n)}),{onError:d}),r=s(()=>y()),h=s(()=>r()?.status),M=async(e,l)=>{await o.mutate({input:e,threadKey:a(n),...m,...l})};return{cancel:async()=>{const e=r()?.instanceId;c===void 0||e===void 0||await p.mutate({instanceId:e,threadKey:a(n)})},error:g,pending:o.pending,run:M,status:h,thread:r}};export{_ as NO_MUTATION_REF,b as createAgent,a as resolveMaybe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reconcileOptimistic as E,maxSeq as M}from"@lunora/client";import{createMemo as s,createSignal as B}from"solid-js";import{resolveMaybe as o,NO_MUTATION_REF as G}from"./createAgent-
|
|
1
|
+
import{reconcileOptimistic as E,maxSeq as M}from"@lunora/client";import{createMemo as s,createSignal as B}from"solid-js";import{resolveMaybe as o,NO_MUTATION_REF as G}from"./createAgent-ClUHcuLQ.mjs";import{createMutation as u}from"./createMutation-DM2mXpq3.mjs";import{createStream as H}from"./createStream-CCAOb9q1.mjs";import{createSubscription as k}from"./createSubscription-BNX2MuML.mjs";import{t as J}from"./solid-compat-ByG5HD_F.mjs";const L={__lunoraRef:""},nt=R=>{const{api:m,cancel:l,limit:h,onError:f,send:S,sendArgs:b,stream:g,threadKey:n}=R,{data:w,error:x}=k(m.agents.agentMessages,()=>{const t=o(n);return h===void 0?{key:t}:{key:t,limit:h}},{onError:f}),{data:I,error:_}=k(m.agents.agentThread,()=>({key:o(n)}),{onError:f}),K=s(()=>x()??_()),O=g===void 0?"skip":()=>({key:o(n)}),{chunks:T}=H(g??L,O),j=u(S),q=u(l??G),C=u(m.agents.agentResolveApproval),[y,d]=B([]);let v=0;J(()=>o(n),()=>{y().length>0&&d([])});const p=s(()=>I()),D=s(()=>p()?.status),i=s(()=>w()??[]),N=s(()=>{const t=i(),r=E(y(),t);if(r.length===0)return t;const e=M(t);return[...t,...r.map((a,c)=>({content:a.content,optimistic:!0,role:"user",seq:e+1+c}))]}),F=s(()=>{const t=o(n),r=i().filter(e=>e.role==="assistant").length;return T().filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=r).map(e=>e.text).join("")}),U=async(t,r)=>{const e=v;v+=1;const a=M(i());d(c=>[...E(c,i()),{content:t,id:e,maxDurableSeqAtSend:a}]);try{await j.mutate({input:t,threadKey:o(n),...b,...r})}catch(c){throw d($=>$.filter(z=>z.id!==e)),c}},A=async(t,r,e)=>{const a=p()?.instanceId;if(a===void 0)throw new Error(`createAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await C.mutate({decision:t,instanceId:a,threadKey:o(n),toolCallId:r,...e===void 0?{}:{note:e}})};return{approve:async(t,r)=>A("approve",t,r),cancel:async()=>{const t=p()?.instanceId;l===void 0||t===void 0||await q.mutate({instanceId:t,threadKey:o(n)})},error:K,messages:N,reject:async(t,r)=>A("reject",t,r),send:U,status:D,streamingText:F}};export{nt as createAgentChat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as o}from"solid-js";import{resolveMaybe as n}from"./createAgent-
|
|
1
|
+
import{createMemo as o}from"solid-js";import{resolveMaybe as n}from"./createAgent-ClUHcuLQ.mjs";import{createSubscription as c}from"./createSubscription-BNX2MuML.mjs";const p=e=>{const{data:t,error:r}=c(e.api.agents.agentState,()=>({key:n(e.threadKey)})),a=o(()=>t());return{error:r,state:a}};export{p as createAgentState};
|
package/dist/packem_shared/{createAgentToolEvents-DUAkn3eP.mjs → createAgentToolEvents-qnjy40Nf.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as v}from"solid-js";import{resolveMaybe as n}from"./createAgent-
|
|
1
|
+
import{createMemo as v}from"solid-js";import{resolveMaybe as n}from"./createAgent-ClUHcuLQ.mjs";import{createStream as f}from"./createStream-CCAOb9q1.mjs";import{createSubscription as y}from"./createSubscription-BNX2MuML.mjs";const C={__lunoraRef:""},I=[],N=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}}]},_=t=>{const{api:r,limit:a,stream:i,threadKey:e}=t,u=()=>{const l=n(e);return a===void 0?{key:l}:{key:l,limit:a}},{data:p}=y(r.agents.agentMessages,u),s=i===void 0?"skip":()=>({key:n(e)}),{chunks:c}=f(i??C,s);return{events:v(()=>{const l=n(e),d=(p()??I).flatMap(o=>N(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{_ as createAgentToolEvents};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSignal as s}from"solid-js";import{useLunora as a}from"./LunoraContext-
|
|
1
|
+
import{createSignal as s}from"solid-js";import{useLunora as a}from"./LunoraContext-BWsj_3CK.mjs";import{o as r}from"./solid-compat-ByG5HD_F.mjs";const m=()=>{const t=a(),[o,n]=s(t.connectionStatus());return r(()=>t.onConnectionStatus(e=>{n(e)})),o};export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSignal as u}from"solid-js";import{useLunora as a}from"./LunoraContext-
|
|
1
|
+
import{createSignal as u}from"solid-js";import{useLunora as a}from"./LunoraContext-BWsj_3CK.mjs";import{resolveMaybe as b}from"./createAgent-ClUHcuLQ.mjs";import{t as d,o as m}from"./solid-compat-ByG5HD_F.mjs";const _="__lunora_flags__:eval",p=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},y={__lunoraRef:_},f=(t,e,r)=>{try{return t.subscribe(y,{default:e.default,key:e.key,type:p(e.default)},o=>{r(o)},{onError:()=>{r(e.default)}})}catch{return()=>{}}},A=(t,e)=>{const r=a(),[o,s]=u(e);return d(()=>b(t),n=>(s(()=>e),f(r,{default:e,key:n},c=>{s(()=>c)}))),o},E=t=>{const e=a(),[r,o]=u(t);return m(()=>{const s=[];for(const[n,c]of Object.entries(t))s.push(f(e,{default:c,key:n},l=>{o(i=>({...i,[n]:l}))}));return()=>{for(const n of s)n()}}),r};export{A as createFlag,E as createFlags};
|
package/dist/packem_shared/{createInfiniteQuery-BuxNVHct.mjs → createInfiniteQuery-U-hmiGPH.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initialPages as O,derivePaginationStatus as Q,applyLoadMore as W,rebalance as j}from"@lunora/client/pagination";import{createMemo as y,createSignal as I}from"solid-js";import{t as D,s as G}from"./reactive-args-DwYuo-jL.mjs";import{useLunora as H}from"./LunoraContext-
|
|
1
|
+
import{initialPages as O,derivePaginationStatus as Q,applyLoadMore as W,rebalance as j}from"@lunora/client/pagination";import{createMemo as y,createSignal as I}from"solid-js";import{t as D,s as G}from"./reactive-args-DwYuo-jL.mjs";import{useLunora as H}from"./LunoraContext-BWsj_3CK.mjs";import{t as J}from"./solid-compat-ByG5HD_F.mjs";const R=(t,n)=>({...n,paginationOpts:{cursor:t.lower,endCursor:t.upper,numItems:t.numItems}}),w=(t,n)=>`${t}::${G(n)}`,$=(t,n,M)=>{const S=H(),{initialNumItems:b,onError:v,shardKey:P}=M,i=()=>typeof n=="function"?n():n,[l,p]=I(O(b)),a=new Map,[h,x]=I([]),[E,g]=I(void 0),L=new Map,K=new Set,_=(e,r)=>{const f=e.map(s=>{const o=w(t.__lunoraRef,R(s,r));return a.get(o)});x(f)},q=(e,r,f)=>{const s=o=>w(t.__lunoraRef,R(o,f));for(const o of r){const c=s(o);if(a.has(c))continue;const k=e.find(u=>u.lower===o.lower);if(k){const u=a.get(s(k));u&&a.set(c,u)}}},z=(e,r)=>{const f=new Set;for(const s of e)f.add(w(t.__lunoraRef,R(s,r)));for(const[s,o]of L)f.has(s)||(o(),L.delete(s),K.delete(s),a.delete(s));for(const s of e){const o=R(s,r),c=w(t.__lunoraRef,o);if(L.has(c))continue;K.add(c);const k=S.subscribe(t,o,u=>{a.set(c,u),K.delete(c),g(void 0);const d=i();if(d!=="skip"&&(_(l(),d),K.size===0)){const m=l(),C=j(m,h());C&&(q(m,C,d),p(C))}},{onError:u=>{K.delete(c),g(u);const d=l(),m=d.at(-1);d.length>1&&m&&!a.has(c)&&w(t.__lunoraRef,R(m,r))===c&&p(d.slice(0,-1)),v?.(u)},shardKey:P});L.set(c,k)}};let N=!1,A=!1;const F=(e,r)=>{if(N){A=!0;return}N=!0;try{let f=e,s=r;do{A=!1,z(f,s);const o=i();if(o==="skip")break;f=l(),s=o}while(A)}finally{N=!1}},T=()=>{for(const e of L.values())e();L.clear(),a.clear(),K.clear()};D(i,e=>(T(),p(O(b)),x([]),g(void 0),e!=="skip"&&(F(l(),e),_(l(),e)),T)),J(l,e=>{const r=i();r!=="skip"&&(F(e,r),_(e,r))});const B=y(()=>{const e=i()==="skip";return Q(e,h()).status});return{error:E,loadMore:e=>{const r=i();if(r==="skip")return;const{nextCursor:f,status:s}=Q(!1,h());if(s!=="CanLoadMore")return;const o=W(l(),f,e);if(!o)return;const c=l().at(-1),k=o.at(-2);if(c&&k){const u=w(t.__lunoraRef,R(c,r)),d=w(t.__lunoraRef,R(k,r));if(u!==d){const m=a.get(u);m&&a.set(d,m)}}g(void 0),p(o)},pageResults:h,status:B}},te=(t,n,M)=>{const{error:S,loadMore:b,pageResults:v,status:P}=$(t,n,M),i=y(()=>v().flatMap(a=>a?.page??[])),l=y(()=>(typeof n=="function"?n():n)==="skip"),p=y(()=>!l()&&(P()==="LoadingFirstPage"||P()==="LoadingMore"));return{error:S,isLoading:p,loadMore:b,results:i,status:P}},se=(t,n,M)=>{const{initialNumItems:S}=M,{error:b,loadMore:v,pageResults:P,status:i}=$(t,n,M),l=y(()=>P().flatMap(g=>g?[g.page]:[])),p=y(()=>(typeof n=="function"?n():n)==="skip"),a=y(()=>!p()&&i()==="LoadingFirstPage"),h=y(()=>i()==="CanLoadMore"),x=y(()=>!p()&&i()==="LoadingMore");return{error:b,fetchNextPage:g=>{v(g??S)},hasNextPage:h,isFetchingNextPage:x,isLoading:a,pages:l,status:i}};export{se as createInfiniteQuery,te as createPaginatedQuery};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCallRunner as l}from"@lunora/client";import{createSignal as s}from"solid-js";import{useLunora as p}from"./LunoraContext-
|
|
1
|
+
import{createCallRunner as l}from"@lunora/client";import{createSignal as s}from"solid-js";import{useLunora as p}from"./LunoraContext-BWsj_3CK.mjs";const v=(e,o)=>{const[r,t]=s(void 0),[n,a]=s(void 0),[c,u]=s(!1),m=l((i,d)=>e.mutation(o,i,d),{setError:a,setPending:u,setResult:i=>{t(()=>i),a(void 0)}});return{data:r,error:n,mutate:m,pending:c,reset:()=>{t(()=>{}),a(void 0)}}},R=e=>{const o=p();return v({mutation:(r,t,n)=>o.mutation(r,t,n)},e)};export{R as createMutation,v as createMutationForClient};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSignal as f}from"solid-js";import{useLunora as E}from"./LunoraContext-
|
|
1
|
+
import{createSignal as f}from"solid-js";import{useLunora as E}from"./LunoraContext-BWsj_3CK.mjs";import{o as S}from"./solid-compat-ByG5HD_F.mjs";const h=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const t=crypto.getRandomValues(new Uint8Array(16));return Array.from(t,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")},D=1e4,A=(t,e)=>{const s=E(),{heartbeat:l,intervalMs:m=D,listPresent:y,shardKey:i}=e,a=e.sessionId??h(),[v,p]=f(void 0),[b,d]=f(void 0);let c=e.data;const o=()=>{const n={roomId:t,sessionId:a,...c===void 0?{}:{data:c}};s.mutation(l,n,{shardKey:i}).catch(()=>{})},g=n=>{c=n,o()};return S(()=>{o();const n=setInterval(o,m),u=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};typeof document<"u"&&document.addEventListener("visibilitychange",u);const I=s.acquireConnectionContext({roomId:t,sessionId:a},{shardKey:i}),U=s.subscribe(y,{roomId:t},r=>{p(()=>r),d(void 0)},{onError:r=>{d(r),e.onError?.(r)},shardKey:i});return()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",u),I(),U()}}),{error:b,present:v,sessionId:a,setData:g}};export{A as createPresence};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createQuerySubscription as f}from"@lunora/client/query";import{createSignal as m}from"solid-js";import{useLunora as p}from"./LunoraContext-
|
|
1
|
+
import{createQuerySubscription as f}from"@lunora/client/query";import{createSignal as m}from"solid-js";import{useLunora as p}from"./LunoraContext-BWsj_3CK.mjs";import{t as l}from"./reactive-args-DwYuo-jL.mjs";const E=(o,r,t={})=>{const n=p(),{onError:s,shardKey:c}=t,[i,e]=m(void 0);return l(()=>typeof r=="function"?r():r,u=>(e(()=>{}),f(n,o,u,{onData:a=>{e(()=>a)},onError:s,onReset:()=>{e(()=>{})}},{shardKey:c}))),i};export{E as createQuery};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSignal as s,onCleanup as b}from"solid-js";import{useLunora as S}from"./LunoraContext-
|
|
1
|
+
import{createSignal as s,onCleanup as b}from"solid-js";import{useLunora as S}from"./LunoraContext-BWsj_3CK.mjs";import{t as x}from"./solid-compat-ByG5HD_F.mjs";const K=(d,n,o={})=>{const h=S(),[p,i]=s([]),[v,f]=s(void 0),[k,e]=s("idle"),y=typeof n=="function"?n:()=>n;let t;const u=()=>{t?.()};return x(y,l=>{if(i(()=>[]),f(()=>{}),l==="skip"){e("idle");return}e("streaming");let c=!0;const m=h.stream(d,l,{durable:o.durable,maxBuffer:o.maxBuffer,shardKey:o.shardKey}),a=()=>{m.cancel()};return t=a,(async()=>{try{for await(const r of m){if(!c)return;i(E=>[...E,r])}c&&e("complete")}catch(r){if(!c)return;f(()=>r instanceof Error?r:new Error(String(r))),e("error")}})().catch(()=>{}),()=>{c=!1,a(),t===a&&(t=void 0)}}),b(()=>{u()}),{cancel:u,chunks:p,error:v,status:k}};export{K as createStream};
|
package/dist/packem_shared/{createSubscription-DK6JFpEA.mjs → createSubscription-BNX2MuML.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createQuerySubscription as v}from"@lunora/client/query";import{LunoraError as l}from"@lunora/errors";import{createSignal as d}from"solid-js";import{useLunora as p}from"./LunoraContext-
|
|
1
|
+
import{createQuerySubscription as v}from"@lunora/client/query";import{LunoraError as l}from"@lunora/errors";import{createSignal as d}from"solid-js";import{useLunora as p}from"./LunoraContext-BWsj_3CK.mjs";import{t as u}from"./reactive-args-DwYuo-jL.mjs";const A=(i,r,n={})=>{const m=p(),[s,e]=d(void 0),[c,t]=d(void 0);return u(typeof r=="function"?r:()=>r,a=>{if(e(()=>{}),t(()=>{}),a!=="skip")return v(m,i,a,{onData:o=>{e(()=>o),t(()=>{})},onError:o=>{const f=o.code?new l(o.code,o.message):new Error(o.message);t(()=>f),e(()=>{}),n.onError?.(o)},onReset:()=>{e(()=>{})}},{shardKey:n.shardKey})}),{data:s,error:c}};export{A as createSubscription};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSignal as y,onCleanup as J}from"solid-js";import{useLunora as G}from"./LunoraContext-
|
|
1
|
+
import{createSignal as y,onCleanup as J}from"solid-js";import{useLunora as G}from"./LunoraContext-BWsj_3CK.mjs";import{resolveMaybe as X}from"./createAgent-ClUHcuLQ.mjs";const D="/_lunora/ws",j="/_lunora/voice/",z=4001,F=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,Q=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},Y=(e,r)=>{if(r===void 0||r==="")return F(e);if(r.endsWith(D))return r.slice(0,-D.length);try{return new URL(r).origin}catch{return F(e)}},Z=e=>{const r=Y(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()}`},ee=(e,r)=>{if(r?.code===z)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},te=(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`))})},ne=16e3,re=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},oe=(e,r)=>{const s=r/ne,i=s>1?Math.floor(e.length/s):e.length,f=new ArrayBuffer(i*2),l=new DataView(f);for(let u=0;u<i;u+=1){const k=e[Math.floor(u*s)]??0,g=Math.max(-1,Math.min(1,k));l.setInt16(u*2,g<0?g*32768:g*32767,!0)}return new Uint8Array(f)},se=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("createVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const f=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new i,u=l.createMediaStreamSource(f),k=l.createScriptProcessor(4096,1,1);let g=!1,w=!1,c=0,p=0;return k.onaudioprocess=o=>{const h=o.inputBuffer.getChannelData(0),m=g?0:re(h);if(e.onLevel(m),g)return;if(e.onAudio(oe(h,l.sampleRate)),e.isTurnActive()){p=m>=e.interruptThreshold?p+1:0,p>=e.interruptChunks&&(p=0,e.onInterrupt());return}p=0;const b=h.length/l.sampleRate*1e3;if(m>=e.silenceThreshold){w=!0,c=0;return}w&&(c+=b,c>=e.silenceDurationMs&&(w=!1,c=0,e.onSilence()))},u.connect(k),k.connect(l.destination),{setMuted:o=>{g=o},stop:()=>{k.disconnect(),u.disconnect();for(const o of f.getTracks())o.stop();l.close()}}},ae=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("createVoiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,i=new Set;let f=0,l=Promise.resolve(),u=0;const k=async(c,p)=>{if(p!==u)return;let o;try{o=await s.decodeAudioData(c.buffer)}catch{return}if(p!==u)return;const h=s.createBufferSource();h.buffer=o,h.connect(s.destination);const m=Math.max(s.currentTime,f);h.start(m),f=m+o.duration,i.add(h),h.onended=()=>{i.delete(h)}},g=c=>{const p=Uint8Array.from(c),o=u;l=l.then(()=>k(p,o))},w=()=>{u+=1;for(const c of i)try{c.stop()}catch{}i.clear(),f=s.currentTime};return{enqueue:g,interrupt:w,stop:()=>{w(),s.close()}}},V=1,ie=.01,ce=1200,ue=.15,le=3,fe=e=>{const{createMicrophone:r=se,createSpeaker:s=ae,createSocket:i,interruptChunks:f=le,interruptThreshold:l=ue,silenceDurationMs:u=ce,silenceThreshold:k=ie,threadKey:g,voice:w}=e,c=G(),[p,o]=y("idle"),[h,m]=y(!1),[b,M]=y(""),[W,v]=y(""),[N,x]=y(0),[I,U]=y(!1),[O,S]=y(void 0);let a,C=!1;const _=t=>{const n=a?.socket;return n?.readyState===V?(n.send(JSON.stringify(t)),!0):!1},T=()=>{const t=a;if(a=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{}}C=!1,m(!1),o("idle"),x(0)},P=T,H=t=>{const n=a;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),o("speaking"),v(R=>R+t.text);break}case"assistant_done":{n&&(n.awaitingTurn=!1,n.speaking=!1),v(t.text),o("listening");break}case"error":{n&&(n.awaitingTurn=!1,n.speaking=!1),S(new Error(t.message)),o("listening");break}case"interrupted":{n&&(n.awaitingTurn=!1,n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),o("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),m(!0),o("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),M(t.text),v(""),o("thinking");break}}},$=t=>{const n=a;!n||n.suppressAudio||(n.speaker??=s({audioFormat:n.audioFormat}),n.speaking=!0,o("speaking"),n.speaker.enqueue(t))},B=async()=>{if(a||C)return;C=!0,S(void 0),M(""),v("");let t;try{const n=Z({agent:Q(w.__lunoraRef),httpUrl:c.url,threadKey:X(g),wsUrl:c.wsUrl}),A=(i??(d=>{const E=c.getWebSocketImpl();if(!E)throw new Error("createVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new E(d)}))(n);A.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:A,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},a=t,t.unwatchIdentity=te(c,"createVoiceAgent",d=>{a===t&&(S(d),T())}),A.onmessage=d=>{if(typeof d.data=="string"){try{H(JSON.parse(d.data))}catch{}return}$(new Uint8Array(d.data))},A.onerror=()=>{S(new Error("createVoiceAgent: voice socket error"))},A.onclose=d=>{if(a!==t)return;const E=ee("createVoiceAgent",d);E&&S(E),T()};const L=await r({interruptChunks:f,interruptThreshold:l,isTurnActive:()=>(a?.speaking??!1)||(a?.awaitingTurn??!1),onAudio:d=>{A.readyState===V&&A.send(d)},onInterrupt:()=>{_({type:"interrupt"}),a?.speaker?.interrupt(),a&&(a.awaitingTurn=!1,a.speaking=!1,a.suppressAudio=!0),o("listening")},onLevel:d=>{x(d)},onSilence:()=>{_({type:"commit"}),a&&(a.awaitingTurn=!0),o("thinking")},silenceDurationMs:u,silenceThreshold:k});a===t?(t.microphone=L,U(!1),t.speaking||o("listening")):L.stop()}catch(n){a===t&&(S(n instanceof Error?n:new Error(String(n))),T())}finally{C=!1}},K=()=>{const t=!I();return a?.microphone?.setMuted(t),U(t),t},q=t=>{_({text:t,type:"text"})&&(a&&(a.awaitingTurn=!0),o("thinking"))};return J(T),{audioLevel:N,connected:h,endCall:P,error:O,interimTranscript:W,isMuted:I,sendText:q,startCall:B,status:p,toggleMute:K,transcript:b}};export{fe as createVoiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSignal as l}from"solid-js";import{useLunora as h,useLunoraClientSwapped as m}from"./LunoraContext-BWsj_3CK.mjs";import{o as y}from"./solid-compat-ByG5HD_F.mjs";const g=(n,e={})=>{const o=h(),{args:r,functionPath:a,shardKey:i,value:s}=n,[c,t]=l(o.identityEpoch()===0&&!m()?s:void 0),d={__lunoraRef:a};return y(()=>{const u=o.onIdentityChange(()=>{t(()=>{})});o.identityEpoch()!==0&&t(()=>{});const f=o.subscribe(d,r,p=>t(()=>p),{onError:e.onError,shardKey:i});return()=>{u(),f()}}),c};export{g as default};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as o}from"@lunora/errors";import{createContext as t,useContext as e}from"solid-js";const n=t(),s=()=>{let r;try{r=e(n)}catch{r=void 0}if(!r)throw new o("INTERNAL","useLunora must be used inside <LunoraProvider />");return r};export{n as LunoraContext,s as useLunora};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createComponent as e}from"solid-js";import{LunoraContext as o}from"./LunoraContext-dPcjtn6R.mjs";import{p as t}from"./solid-compat-ByG5HD_F.mjs";const a=r=>e(t(o),{get children(){return r.children},get value(){return r.client}});export{a as LunoraProvider};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createSignal as l}from"solid-js";import{useLunora as m}from"./LunoraContext-dPcjtn6R.mjs";import{o as p}from"./solid-compat-ByG5HD_F.mjs";const E=(n,r={})=>{const o=m(),{args:e,functionPath:i,shardKey:a,value:s}=n,[c,t]=l(o.identityEpoch()===0?s:void 0),d={__lunoraRef:i};return p(()=>{const u=o.onIdentityChange(()=>{t(()=>{})});o.identityEpoch()!==0&&t(()=>{});const f=o.subscribe(d,e,h=>t(()=>h),{onError:r.onError,shardKey:a});return()=>{u(),f()}}),c};export{E as default};
|