@lunora/solid 1.0.0-alpha.74 → 1.0.0-alpha.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -19
- package/dist/index.d.mts +30 -3
- package/dist/index.d.ts +30 -3
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{createAgent-DTUKko5X.mjs → createAgent-hhL-sw_X.mjs} +1 -1
- package/dist/packem_shared/{createAgentChat-Bo021xHU.mjs → createAgentChat-CK0_VzMa.mjs} +1 -1
- package/dist/packem_shared/{createAgentState-DIknFZyn.mjs → createAgentState-D3UsBxBI.mjs} +1 -1
- package/dist/packem_shared/{createAgentToolEvents-BZDqkzK6.mjs → createAgentToolEvents-BoC23C-n.mjs} +1 -1
- package/dist/packem_shared/{createFlag-CkY9V_ou.mjs → createFlag-BmHiFrD-.mjs} +1 -1
- package/dist/packem_shared/createInfiniteQuery-i8Rv0Rl2.mjs +1 -0
- package/dist/packem_shared/createPresence-eSor6sjx.mjs +1 -0
- package/dist/packem_shared/{createQuery-DMcnUyOD.mjs → createQuery-CdWTlKJM.mjs} +1 -1
- package/dist/packem_shared/createStream-Dx7SnivS.mjs +1 -0
- package/dist/packem_shared/createSubscription-1glD6fxF.mjs +1 -0
- package/dist/packem_shared/{createVoiceAgent-BjL6DH05.mjs → createVoiceAgent-iW_a_E7h.mjs} +1 -1
- package/dist/packem_shared/hydratePreloaded-Bhxdstm1.mjs +1 -0
- package/package.json +4 -4
- package/dist/packem_shared/createInfiniteQuery-DLpKN_aQ.mjs +0 -1
- package/dist/packem_shared/createPresence-Da_DdL7L.mjs +0 -1
- package/dist/packem_shared/createStream-B10b3ijV.mjs +0 -1
- package/dist/packem_shared/createSubscription-D9e8lT1C.mjs +0 -1
- package/dist/packem_shared/hydratePreloaded-CnJNitir.mjs +0 -1
package/README.md
CHANGED
|
@@ -95,25 +95,25 @@ render(
|
|
|
95
95
|
|
|
96
96
|
## API
|
|
97
97
|
|
|
98
|
-
| Primitive | React equivalent | Description
|
|
99
|
-
| --------------------------------------------------- | --------------------- |
|
|
100
|
-
| `LunoraProvider` | `LunoraProvider` | Context component — wraps your app tree with the `LunoraClient`.
|
|
101
|
-
| `useLunora` | `useLunora` | Read the ambient `LunoraClient` from the nearest `LunoraProvider`.
|
|
102
|
-
| `createQuery` | `useQuery` | Live query signal — returns `() => T \| undefined`, re-subscribes on arg change.
|
|
103
|
-
| `createMutation` | `useMutation` | Optimistic mutation handle (`data`, `error`, `pending`, `mutate`, `reset`).
|
|
104
|
-
| `createSubscription` | `useSubscription` | Raw subscription signal — unbounded live stream.
|
|
105
|
-
| `createPaginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, and `
|
|
106
|
-
| `createInfiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `createPaginatedQuery`.
|
|
107
|
-
| `createAuth` | `useAuth` | Reactive auth state (`token`, `user` signals + `setToken`).
|
|
108
|
-
| `Authenticated` / `AuthLoading` / `Unauthenticated` | — | Auth-gate components rendering `children` per identity state.
|
|
109
|
-
| `createPresence` | `usePresence` | Collaborative-awareness — heartbeat + live present-members signal.
|
|
110
|
-
| `createFlag` | `useFlag` | Live OpenFeature flag accessor — returns `default` until the server answers.
|
|
111
|
-
| `createFlags` | `useFlags` | Batch variant — an accessor of one value per key in the defaults map.
|
|
112
|
-
| `createRateLimit` | `useRateLimit` | Client-side rate-limit mirror — `ok`, `disabled`, `retryAfter` as signals.
|
|
113
|
-
| `createConnectionStatus` | `useConnectionStatus` | Reactive connection state signal.
|
|
114
|
-
| `hydratePreloaded` | `usePreloadedQuery` | Seed a query synchronously from an SSR `Preloaded` token, then go live.
|
|
115
|
-
| `createAgentToolEvents` | `useAgentToolEvents` | One agent thread's tool lifecycle as an `Accessor` of discriminated events.
|
|
116
|
-
| `createVoiceAgent` | `useVoiceAgent` | Full-duplex voice call — accessors for status/transcript/level + call controls.
|
|
98
|
+
| Primitive | React equivalent | Description |
|
|
99
|
+
| --------------------------------------------------- | --------------------- | --------------------------------------------------------------------------------- |
|
|
100
|
+
| `LunoraProvider` | `LunoraProvider` | Context component — wraps your app tree with the `LunoraClient`. |
|
|
101
|
+
| `useLunora` | `useLunora` | Read the ambient `LunoraClient` from the nearest `LunoraProvider`. |
|
|
102
|
+
| `createQuery` | `useQuery` | Live query signal — returns `() => T \| undefined`, re-subscribes on arg change. |
|
|
103
|
+
| `createMutation` | `useMutation` | Optimistic mutation handle (`data`, `error`, `pending`, `mutate`, `reset`). |
|
|
104
|
+
| `createSubscription` | `useSubscription` | Raw subscription signal — unbounded live stream. |
|
|
105
|
+
| `createPaginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, `results`, and `error` signals. |
|
|
106
|
+
| `createInfiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `createPaginatedQuery`. |
|
|
107
|
+
| `createAuth` | `useAuth` | Reactive auth state (`token`, `user` signals + `setToken`). |
|
|
108
|
+
| `Authenticated` / `AuthLoading` / `Unauthenticated` | — | Auth-gate components rendering `children` per identity state. |
|
|
109
|
+
| `createPresence` | `usePresence` | Collaborative-awareness — heartbeat + live present-members signal. |
|
|
110
|
+
| `createFlag` | `useFlag` | Live OpenFeature flag accessor — returns `default` until the server answers. |
|
|
111
|
+
| `createFlags` | `useFlags` | Batch variant — an accessor of one value per key in the defaults map. |
|
|
112
|
+
| `createRateLimit` | `useRateLimit` | Client-side rate-limit mirror — `ok`, `disabled`, `retryAfter` as signals. |
|
|
113
|
+
| `createConnectionStatus` | `useConnectionStatus` | Reactive connection state signal. |
|
|
114
|
+
| `hydratePreloaded` | `usePreloadedQuery` | Seed a query synchronously from an SSR `Preloaded` token, then go live. |
|
|
115
|
+
| `createAgentToolEvents` | `useAgentToolEvents` | One agent thread's tool lifecycle as an `Accessor` of discriminated events. |
|
|
116
|
+
| `createVoiceAgent` | `useVoiceAgent` | Full-duplex voice call — accessors for status/transcript/level + call controls. |
|
|
117
117
|
|
|
118
118
|
`createVoiceAgent` opens nothing until `startCall()` — that call is what requests the microphone, so it must run from a user gesture. `endCall()` releases the socket, the mic tracks and the Web Audio graph, and `onCleanup` runs it for you when the owning root is disposed.
|
|
119
119
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback, Preloaded } from '@lunora/client';
|
|
1
|
+
import { LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback, SubscriptionError, Preloaded } from '@lunora/client';
|
|
2
2
|
export type { ArgsOf, FunctionReference, MutatorHandle, MutatorTransaction, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe } from '@lunora/client';
|
|
3
3
|
import { Context, Accessor } from 'solid-js';
|
|
4
4
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
@@ -673,9 +673,18 @@ type PageItemOf<F extends FunctionReference> = ReturnOf<F> extends {
|
|
|
673
673
|
interface CreatePaginatedQueryOptions {
|
|
674
674
|
/** Page size for the first page (and the default for `loadMore`). */
|
|
675
675
|
initialNumItems: number;
|
|
676
|
+
/** Called when a page subscription reports an error (also surfaced on the `error` accessor). */
|
|
677
|
+
onError?: SubscriptionErrorCallback;
|
|
676
678
|
shardKey?: string;
|
|
677
679
|
}
|
|
678
680
|
interface CreatePaginatedQueryResult<T> {
|
|
681
|
+
/**
|
|
682
|
+
* The last page subscription error, or `undefined`. A tail page that fails
|
|
683
|
+
* before its first frame is dropped so `status` returns to `"CanLoadMore"`
|
|
684
|
+
* and `loadMore` can retry it; cleared by the next successful frame,
|
|
685
|
+
* `loadMore`, or an args change.
|
|
686
|
+
*/
|
|
687
|
+
error: Accessor<SubscriptionError | undefined>;
|
|
679
688
|
/** `true` while the first page or a `loadMore` page is in flight. */
|
|
680
689
|
isLoading: Accessor<boolean>;
|
|
681
690
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
@@ -687,9 +696,13 @@ interface CreatePaginatedQueryResult<T> {
|
|
|
687
696
|
interface CreateInfiniteQueryOptions {
|
|
688
697
|
/** Page size for the first page (and the default for `fetchNextPage`). */
|
|
689
698
|
initialNumItems: number;
|
|
699
|
+
/** Called when a page subscription reports an error (also surfaced on the `error` accessor). */
|
|
700
|
+
onError?: SubscriptionErrorCallback;
|
|
690
701
|
shardKey?: string;
|
|
691
702
|
}
|
|
692
703
|
interface CreateInfiniteQueryResult<T> {
|
|
704
|
+
/** The last page subscription error, or `undefined` — see `CreatePaginatedQueryResult.error`. */
|
|
705
|
+
error: Accessor<SubscriptionError | undefined>;
|
|
693
706
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
694
707
|
fetchNextPage: (numberItems?: number) => void;
|
|
695
708
|
/** `true` when the loaded tail reports it can load another page. */
|
|
@@ -792,7 +805,8 @@ interface CreateQueryOptions {
|
|
|
792
805
|
*
|
|
793
806
|
* `args` may be a plain value or an accessor; passing an accessor makes the
|
|
794
807
|
* subscription reactive — when the args change the old subscription is torn down
|
|
795
|
-
* (via `onCleanup`) and a fresh one opens for
|
|
808
|
+
* (via `onCleanup`), the accessor resets to `undefined`, and a fresh one opens for
|
|
809
|
+
* the new args. Pass `"skip"` (or an
|
|
796
810
|
* accessor returning `"skip"`) to short-circuit: no network call, no socket.
|
|
797
811
|
*
|
|
798
812
|
* ```tsx
|
|
@@ -849,6 +863,13 @@ interface CreateStreamResult<T> {
|
|
|
849
863
|
status: Accessor<CreateStreamStatus>;
|
|
850
864
|
}
|
|
851
865
|
interface CreateStreamOptions {
|
|
866
|
+
/**
|
|
867
|
+
* Opt into resume-on-reconnect for a stream the server declared `durable`.
|
|
868
|
+
* The chunks already received are kept and the socket re-attaches to the same
|
|
869
|
+
* run, so a dropped connection mid-generation continues instead of surfacing
|
|
870
|
+
* `STREAM_DISCONNECTED`. Has no effect on an ephemeral stream.
|
|
871
|
+
*/
|
|
872
|
+
durable?: boolean;
|
|
852
873
|
/** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
|
|
853
874
|
maxBuffer?: number;
|
|
854
875
|
shardKey?: string;
|
|
@@ -1042,8 +1063,14 @@ declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoic
|
|
|
1042
1063
|
* Mount callbacks do not run on the server during SSR (both Solid majors defer
|
|
1043
1064
|
* them until after hydration), so the subscription is strictly client-side —
|
|
1044
1065
|
* the seed is the only value the server render ever sees.
|
|
1066
|
+
*
|
|
1067
|
+
* Pass `onError` to surface a subscription-scoped error the server pushes (a
|
|
1068
|
+
* session expiry, an RLS denial). Without it such an error is dropped and the
|
|
1069
|
+
* accessor keeps rendering the SSR snapshot as if it were live.
|
|
1045
1070
|
*/
|
|
1046
|
-
declare const hydratePreloaded: <T>(preloaded: Preloaded<T
|
|
1071
|
+
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, options?: {
|
|
1072
|
+
onError?: SubscriptionErrorCallback;
|
|
1073
|
+
}) => Accessor<T>;
|
|
1047
1074
|
interface LunoraProviderProps {
|
|
1048
1075
|
children: SolidChildren;
|
|
1049
1076
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback, Preloaded } from '@lunora/client';
|
|
1
|
+
import { LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback, SubscriptionError, Preloaded } from '@lunora/client';
|
|
2
2
|
export type { ArgsOf, FunctionReference, MutatorHandle, MutatorTransaction, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe } from '@lunora/client';
|
|
3
3
|
import { Context, Accessor } from 'solid-js';
|
|
4
4
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
@@ -673,9 +673,18 @@ type PageItemOf<F extends FunctionReference> = ReturnOf<F> extends {
|
|
|
673
673
|
interface CreatePaginatedQueryOptions {
|
|
674
674
|
/** Page size for the first page (and the default for `loadMore`). */
|
|
675
675
|
initialNumItems: number;
|
|
676
|
+
/** Called when a page subscription reports an error (also surfaced on the `error` accessor). */
|
|
677
|
+
onError?: SubscriptionErrorCallback;
|
|
676
678
|
shardKey?: string;
|
|
677
679
|
}
|
|
678
680
|
interface CreatePaginatedQueryResult<T> {
|
|
681
|
+
/**
|
|
682
|
+
* The last page subscription error, or `undefined`. A tail page that fails
|
|
683
|
+
* before its first frame is dropped so `status` returns to `"CanLoadMore"`
|
|
684
|
+
* and `loadMore` can retry it; cleared by the next successful frame,
|
|
685
|
+
* `loadMore`, or an args change.
|
|
686
|
+
*/
|
|
687
|
+
error: Accessor<SubscriptionError | undefined>;
|
|
679
688
|
/** `true` while the first page or a `loadMore` page is in flight. */
|
|
680
689
|
isLoading: Accessor<boolean>;
|
|
681
690
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
@@ -687,9 +696,13 @@ interface CreatePaginatedQueryResult<T> {
|
|
|
687
696
|
interface CreateInfiniteQueryOptions {
|
|
688
697
|
/** Page size for the first page (and the default for `fetchNextPage`). */
|
|
689
698
|
initialNumItems: number;
|
|
699
|
+
/** Called when a page subscription reports an error (also surfaced on the `error` accessor). */
|
|
700
|
+
onError?: SubscriptionErrorCallback;
|
|
690
701
|
shardKey?: string;
|
|
691
702
|
}
|
|
692
703
|
interface CreateInfiniteQueryResult<T> {
|
|
704
|
+
/** The last page subscription error, or `undefined` — see `CreatePaginatedQueryResult.error`. */
|
|
705
|
+
error: Accessor<SubscriptionError | undefined>;
|
|
693
706
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
694
707
|
fetchNextPage: (numberItems?: number) => void;
|
|
695
708
|
/** `true` when the loaded tail reports it can load another page. */
|
|
@@ -792,7 +805,8 @@ interface CreateQueryOptions {
|
|
|
792
805
|
*
|
|
793
806
|
* `args` may be a plain value or an accessor; passing an accessor makes the
|
|
794
807
|
* subscription reactive — when the args change the old subscription is torn down
|
|
795
|
-
* (via `onCleanup`) and a fresh one opens for
|
|
808
|
+
* (via `onCleanup`), the accessor resets to `undefined`, and a fresh one opens for
|
|
809
|
+
* the new args. Pass `"skip"` (or an
|
|
796
810
|
* accessor returning `"skip"`) to short-circuit: no network call, no socket.
|
|
797
811
|
*
|
|
798
812
|
* ```tsx
|
|
@@ -849,6 +863,13 @@ interface CreateStreamResult<T> {
|
|
|
849
863
|
status: Accessor<CreateStreamStatus>;
|
|
850
864
|
}
|
|
851
865
|
interface CreateStreamOptions {
|
|
866
|
+
/**
|
|
867
|
+
* Opt into resume-on-reconnect for a stream the server declared `durable`.
|
|
868
|
+
* The chunks already received are kept and the socket re-attaches to the same
|
|
869
|
+
* run, so a dropped connection mid-generation continues instead of surfacing
|
|
870
|
+
* `STREAM_DISCONNECTED`. Has no effect on an ephemeral stream.
|
|
871
|
+
*/
|
|
872
|
+
durable?: boolean;
|
|
852
873
|
/** Forwarded to `client.stream()` — caps the in-flight chunk buffer. */
|
|
853
874
|
maxBuffer?: number;
|
|
854
875
|
shardKey?: string;
|
|
@@ -1042,8 +1063,14 @@ declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoic
|
|
|
1042
1063
|
* Mount callbacks do not run on the server during SSR (both Solid majors defer
|
|
1043
1064
|
* them until after hydration), so the subscription is strictly client-side —
|
|
1044
1065
|
* the seed is the only value the server render ever sees.
|
|
1066
|
+
*
|
|
1067
|
+
* Pass `onError` to surface a subscription-scoped error the server pushes (a
|
|
1068
|
+
* session expiry, an RLS denial). Without it such an error is dropped and the
|
|
1069
|
+
* accessor keeps rendering the SSR snapshot as if it were live.
|
|
1045
1070
|
*/
|
|
1046
|
-
declare const hydratePreloaded: <T>(preloaded: Preloaded<T
|
|
1071
|
+
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, options?: {
|
|
1072
|
+
onError?: SubscriptionErrorCallback;
|
|
1073
|
+
}) => Accessor<T>;
|
|
1047
1074
|
interface LunoraProviderProps {
|
|
1048
1075
|
children: SolidChildren;
|
|
1049
1076
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraContext as r,useLunora as o}from"./packem_shared/LunoraContext-dPcjtn6R.mjs";import{createAction as c,createActionForClient as n}from"./packem_shared/createAction-M4s8XBXV.mjs";import{createAgent as m}from"./packem_shared/createAgent-
|
|
1
|
+
import{LunoraContext as r,useLunora as o}from"./packem_shared/LunoraContext-dPcjtn6R.mjs";import{createAction as c,createActionForClient as n}from"./packem_shared/createAction-M4s8XBXV.mjs";import{createAgent as m}from"./packem_shared/createAgent-hhL-sw_X.mjs";import{createAgentChat as x}from"./packem_shared/createAgentChat-CK0_VzMa.mjs";import{createAgentState as u}from"./packem_shared/createAgentState-D3UsBxBI.mjs";import{createAgentToolEvents as A}from"./packem_shared/createAgentToolEvents-BoC23C-n.mjs";import{AuthLoading as l,Authenticated as s,Unauthenticated as h,createAuth as C}from"./packem_shared/AuthLoading-6vueEnV0.mjs";import{default as y}from"./packem_shared/createConnectionStatus-BnlXYWeE.mjs";import{createFlag as P,createFlags as S}from"./packem_shared/createFlag-BmHiFrD-.mjs";import{createMutation as Q,createMutationForClient as v}from"./packem_shared/createMutation-DcSsIbGF.mjs";import{createMutator as E}from"./packem_shared/createMutator-q9cMjGKv.mjs";import{createInfiniteQuery as R,createPaginatedQuery as T}from"./packem_shared/createInfiniteQuery-i8Rv0Rl2.mjs";import{createPresence as V}from"./packem_shared/createPresence-eSor6sjx.mjs";import{createQuery as k}from"./packem_shared/createQuery-CdWTlKJM.mjs";import{createRateLimit as w}from"./packem_shared/createRateLimit-CIVWrD5H.mjs";import{createStream as B}from"./packem_shared/createStream-Dx7SnivS.mjs";import{createSubscription as G}from"./packem_shared/createSubscription-1glD6fxF.mjs";import{createVoiceAgent as J}from"./packem_shared/createVoiceAgent-iW_a_E7h.mjs";import{default as N}from"./packem_shared/hydratePreloaded-Bhxdstm1.mjs";import{LunoraProvider as W}from"./packem_shared/LunoraProvider-BKWckcDR.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{createMemo as s}from"solid-js";import{createMutation as i}from"./createMutation-DcSsIbGF.mjs";import{createSubscription as M}from"./createSubscription-
|
|
1
|
+
import{createMemo as s}from"solid-js";import{createMutation as i}from"./createMutation-DcSsIbGF.mjs";import{createSubscription as M}from"./createSubscription-1glD6fxF.mjs";const l={__lunoraRef:""},c=t=>typeof t=="function"?t():t,K=t=>{const{api:u,cancel:r,run:d,runArgs:f,threadKey:n}=t,o=i(d),m=i(r??l),{data:p}=M(u.agents.agentThread,()=>({key:c(n)})),a=s(()=>p()),y=s(()=>a()?.status),g=async(e,h)=>{await o.mutate({input:e,threadKey:c(n),...f,...h})};return{cancel:async()=>{const e=a()?.instanceId;r===void 0||e===void 0||await m.mutate({instanceId:e,threadKey:c(n)})},pending:o.pending,run:g,status:y,thread:a}};export{l as NO_MUTATION_REF,K as createAgent,c as resolveMaybe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reconcileOptimistic as A,maxSeq as M}from"@lunora/client";import{createSignal as F,createMemo as c}from"solid-js";import{resolveMaybe as a,NO_MUTATION_REF as U}from"./createAgent-
|
|
1
|
+
import{reconcileOptimistic as A,maxSeq as M}from"@lunora/client";import{createSignal as F,createMemo as c}from"solid-js";import{resolveMaybe as a,NO_MUTATION_REF as U}from"./createAgent-hhL-sw_X.mjs";import{createMutation as p}from"./createMutation-DcSsIbGF.mjs";import{createStream as $}from"./createStream-Dx7SnivS.mjs";import{createSubscription as k}from"./createSubscription-1glD6fxF.mjs";import{t as z}from"./solid-compat-ByG5HD_F.mjs";const B={__lunoraRef:""},Z=R=>{const{api:m,cancel:u,limit:f,send:S,sendArgs:w,stream:h,threadKey:r}=R,{data:x}=k(m.agents.agentMessages,()=>{const t=a(r);return f===void 0?{key:t}:{key:t,limit:f}}),{data:I}=k(m.agents.agentThread,()=>({key:a(r)})),b=h===void 0?"skip":()=>({key:a(r)}),{chunks:_}=$(h??B,b),E=p(S),K=p(u??U),O=p(m.agents.agentResolveApproval),[g,d]=F([]);let y=0;z(()=>a(r),()=>{g().length>0&&d([])});const l=c(()=>I()),T=c(()=>l()?.status),i=c(()=>x()??[]),j=c(()=>{const t=i(),n=A(g(),t);if(n.length===0)return t;const e=M(t);return[...t,...n.map((s,o)=>({content:s.content,optimistic:!0,role:"user",seq:e+1+o}))]}),q=c(()=>{const t=a(r),n=i().filter(e=>e.role==="assistant").length;return _().filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=n).map(e=>e.text).join("")}),C=async(t,n)=>{const e=y;y+=1;const s=M(i());d(o=>[...A(o,i()),{content:t,id:e,maxDurableSeqAtSend:s}]);try{await E.mutate({input:t,threadKey:a(r),...w,...n})}catch(o){throw d(D=>D.filter(N=>N.id!==e)),o}},v=async(t,n,e)=>{const s=l()?.instanceId;if(s===void 0)throw new Error(`createAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await O.mutate({decision:t,instanceId:s,threadKey:a(r),toolCallId:n,...e===void 0?{}:{note:e}})};return{approve:async(t,n)=>v("approve",t,n),cancel:async()=>{const t=l()?.instanceId;u===void 0||t===void 0||await K.mutate({instanceId:t,threadKey:a(r)})},messages:j,reject:async(t,n)=>v("reject",t,n),send:C,status:T,streamingText:q}};export{Z 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-hhL-sw_X.mjs";import{createSubscription as c}from"./createSubscription-1glD6fxF.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-BZDqkzK6.mjs → createAgentToolEvents-BoC23C-n.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-hhL-sw_X.mjs";import{createStream as f}from"./createStream-Dx7SnivS.mjs";import{createSubscription as y}from"./createSubscription-1glD6fxF.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 u}from"solid-js";import{useLunora as a}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as b}from"./createAgent-
|
|
1
|
+
import{createSignal as u}from"solid-js";import{useLunora as a}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as b}from"./createAgent-hhL-sw_X.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{initialPages as U,derivePaginationStatus as J,applyLoadMore as X,rebalance as Y}from"@lunora/client/pagination";import{createMemo as A,createSignal as T}from"solid-js";import{useLunora as Z}from"./LunoraContext-dPcjtn6R.mjs";import{t as W}from"./solid-compat-ByG5HD_F.mjs";const v=/["\\\u0000-\u001F\uD800-\uDFFF]/,q=e=>v.test(e)?JSON.stringify(e):`"${e}"`,$=e=>{if(e===void 0)return"null";if(typeof e=="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 e=="number"){if(Number.isNaN(e))return"nan";if(e===1/0)return"inf";if(e===-1/0)return"-inf";if(Object.is(e,-0))return"-0"}if(typeof e=="string")return q(e);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e)){let o="[";for(let n=0;n<e.length;n++)n>0&&(o+=","),o+=$(e[n]);return o+"]"}const r=Object.getPrototypeOf(e);if(r!==null&&r!==Object.prototype){const o=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${o} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const d=e,y=Object.keys(d).sort();let u="{",t=!0;for(const o of y){const n=d[o];n!==void 0&&(t?t=!1:u+=",",u+=q(o),u+=":",u+=$(n))}return u+"}"},C=e=>{let r="";for(let y=0;y<e.length;y+=32768)r+=String.fromCharCode(...e.subarray(y,y+32768));return btoa(r)},l="$lunora.wire$",Q=64,ee="__proto__",te=e=>{if(e===null||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype},k=(e,r=0)=>{if(r>Q)throw new RangeError(`wire-codec: value nesting exceeds the ${Q}-level limit`);if(e===void 0)return[l,"undefined"];if(e===null)return null;const d=typeof e;if(d==="bigint")return[l,"bigint",e.toString()];if(d==="number"){const t=e;return Number.isNaN(t)?[l,"nan"]:t===1/0?[l,"inf"]:t===-1/0?[l,"-inf"]:t}if(d!=="object")return e;if(e instanceof Date)return[l,"date",k(e.getTime(),r+1)];if(e instanceof Error){const t=e,o={};for(const a of Object.keys(t))t[a]!==void 0&&(o[a]=k(t[a],r+1));const n=[l,"error",t.name,t.message,o];return t.cause!==void 0&&n.push(k(t.cause,r+1)),n}if(e instanceof URL)return[l,"url",e.href];if(e instanceof Map)return[l,"map",[...e.entries()].map(([t,o])=>[k(t,r+1),k(o,r+1)])];if(e instanceof Set)return[l,"set",[...e].map(t=>k(t,r+1))];if(e instanceof ArrayBuffer)return[l,"bytes",C(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,o=t.constructor.name,n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return o==="Uint8Array"?[l,"bytes",C(n)]:[l,"bytes",C(n),o]}if(Array.isArray(e)){const t=e.map(o=>k(o,r+1));return t.length>0&&t[0]===l?[l,"arr",t]:t}if(!te(e)){const t=e.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 y=e,u={};for(const t of Object.keys(y)){const o=y[t];if(o===void 0)continue;const n=k(o,r+1);t===ee?Object.defineProperty(u,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):u[t]=n}return u},re=e=>$(k(e)),N=(e,r)=>({...r,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),O=(e,r)=>`${e}::${re(r)}`,z=(e,r,d)=>{const y=Z(),{initialNumItems:u,onError:t,shardKey:o}=d,n=()=>typeof r=="function"?r():r,[a,P]=T(U(u)),p=new Map,[R,_]=T([]),[E,L]=T(void 0),M=new Map,j=new Set,K=(s,f)=>{const m=s.map(i=>{const c=O(e.__lunoraRef,N(i,f));return p.get(c)});_(m)},G=(s,f,m)=>{const i=c=>O(e.__lunoraRef,N(c,m));for(const c of f){const g=i(c);if(p.has(g))continue;const h=s.find(b=>b.lower===c.lower);if(h){const b=p.get(i(h));b&&p.set(g,b)}}},H=(s,f)=>{const m=new Set;for(const i of s)m.add(O(e.__lunoraRef,N(i,f)));for(const[i,c]of M)m.has(i)||(c(),M.delete(i),j.delete(i),p.delete(i));for(const i of s){const c=N(i,f),g=O(e.__lunoraRef,c);if(M.has(g))continue;j.add(g);const h=y.subscribe(e,c,b=>{p.set(g,b),j.delete(g),L(void 0);const w=n();if(w!=="skip"&&(K(a(),w),j.size===0)){const S=a(),I=Y(S,R());I&&(G(S,I,w),P(I))}},{onError:b=>{j.delete(g),L(b);const w=a(),S=w.at(-1);w.length>1&&S&&!p.has(g)&&O(e.__lunoraRef,N(S,f))===g&&P(w.slice(0,-1)),t?.(b)},shardKey:o});M.set(g,h)}};let x=!1,F=!1;const B=(s,f)=>{if(x){F=!0;return}x=!0;try{let m=s,i=f;do{F=!1,H(m,i);const c=n();if(c==="skip")break;m=a(),i=c}while(F)}finally{x=!1}},D=()=>{for(const s of M.values())s();M.clear(),p.clear(),j.clear()};W(n,s=>(D(),P(U(u)),_([]),L(void 0),s!=="skip"&&(B(a(),s),K(a(),s)),D)),W(a,s=>{const f=n();f!=="skip"&&(B(s,f),K(s,f))});const V=A(()=>{const s=n()==="skip";return J(s,R()).status});return{error:E,loadMore:s=>{const f=n();if(f==="skip")return;const{nextCursor:m,status:i}=J(!1,R());if(i!=="CanLoadMore")return;const c=X(a(),m,s);if(!c)return;const g=a().at(-1),h=c.at(-2);if(g&&h){const b=O(e.__lunoraRef,N(g,f)),w=O(e.__lunoraRef,N(h,f));if(b!==w){const S=p.get(b);S&&p.set(w,S)}}L(void 0),P(c)},pageResults:R,status:V}},ae=(e,r,d)=>{const{error:y,loadMore:u,pageResults:t,status:o}=z(e,r,d),n=A(()=>t().flatMap(P=>P?.page??[])),a=A(()=>o()==="LoadingFirstPage"||o()==="LoadingMore");return{error:y,isLoading:a,loadMore:u,results:n,status:o}},fe=(e,r,d)=>{const{initialNumItems:y}=d,{error:u,loadMore:t,pageResults:o,status:n}=z(e,r,d),a=A(()=>o().flatMap(E=>E?[E.page]:[])),P=A(()=>n()==="LoadingFirstPage"),p=A(()=>n()==="CanLoadMore"),R=A(()=>n()==="LoadingMore");return{error:u,fetchNextPage:E=>{t(E??y)},hasNextPage:p,isFetchingNextPage:R,isLoading:P,pages:a,status:n}};export{fe as createInfiniteQuery,ae as createPaginatedQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSignal as g}from"solid-js";import{useLunora as I}from"./LunoraContext-dPcjtn6R.mjs";import{o as U}from"./solid-compat-ByG5HD_F.mjs";const S=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},h=1e4,L=(e,t)=>{const r=I(),{heartbeat:d,intervalMs:u=h,listPresent:f,shardKey:s}=t,i=t.sessionId??S(),[l,m]=g(void 0);let a=t.data;const o=()=>{const n={roomId:e,sessionId:i,...a===void 0?{}:{data:a}};r.mutation(d,n,{shardKey:s}).catch(()=>{})},y=n=>{a=n,o()};return U(()=>{o();const n=setInterval(o,u),c=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};typeof document<"u"&&document.addEventListener("visibilitychange",c);const p=r.acquireConnectionContext({roomId:e,sessionId:i},{shardKey:s}),v=r.subscribe(f,{roomId:e},b=>{m(()=>b)},{shardKey:s});return()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",c),p(),v()}}),{present:l,sessionId:i,setData:y}};export{L 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-dPcjtn6R.mjs";import{t as l}from"./solid-compat-ByG5HD_F.mjs";const Q=(o,r,t={})=>{const n=p(),{onError:s,shardKey:c}=t,[
|
|
1
|
+
import{createQuerySubscription as f}from"@lunora/client/query";import{createSignal as m}from"solid-js";import{useLunora as p}from"./LunoraContext-dPcjtn6R.mjs";import{t as l}from"./solid-compat-ByG5HD_F.mjs";const Q=(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{Q as createQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSignal as s,onCleanup as b}from"solid-js";import{useLunora as S}from"./LunoraContext-dPcjtn6R.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createQuerySubscription as v}from"@lunora/client/query";import{LunoraError as p}from"@lunora/errors";import{createSignal as a}from"solid-js";import{useLunora as u}from"./LunoraContext-dPcjtn6R.mjs";import{t as l}from"./solid-compat-ByG5HD_F.mjs";const D=(i,r,d={})=>{const s=u(),[c,e]=a(void 0),[m,t]=a(void 0);return l(typeof r=="function"?r:()=>r,n=>{if(e(()=>{}),t(()=>{}),n!=="skip")return v(s,i,n,{onData:o=>{e(()=>o),t(()=>{})},onError:o=>{const f=o.code?new p(o.code,o.message):new Error(o.message);t(()=>f),e(()=>{})},onReset:()=>{e(()=>{})}},{shardKey:d.shardKey})}),{data:c,error:m}};export{D as createSubscription};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSignal as w,onCleanup as B}from"solid-js";import{useLunora as $}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as J}from"./createAgent-
|
|
1
|
+
import{createSignal as w,onCleanup as B}from"solid-js";import{useLunora as $}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as J}from"./createAgent-hhL-sw_X.mjs";const K=16e3,G=e=>{if(e.length===0)return 0;let s=0;for(const o of e)s+=o*o;return Math.sqrt(s/e.length)},j=(e,s)=>{const o=s/K,a=o>1?Math.floor(e.length/o):e.length,l=new ArrayBuffer(a*2),i=new DataView(l);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(l)},z=async e=>{const s=globalThis,o=s.navigator?.mediaDevices?.getUserMedia.bind(s.navigator.mediaDevices),a=s.AudioContext??s.webkitAudioContext;if(!o||!a)throw new Error("createVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const l=await o({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),i=new a,u=i.createMediaStreamSource(l),k=i.createScriptProcessor(4096,1,1);let f=!1,A=!1,d=0,p=0;return k.onaudioprocess=r=>{const h=r.inputBuffer.getChannelData(0),g=f?0:G(h);if(e.onLevel(g),f)return;if(e.onAudio(j(h,i.sampleRate)),e.isSpeaking()){p=g>=e.interruptThreshold?p+1:0,p>=e.interruptChunks&&(p=0,e.onInterrupt());return}p=0;const E=h.length/i.sampleRate*1e3;if(g>=e.silenceThreshold){A=!0,d=0;return}A&&(d+=E,d>=e.silenceDurationMs&&(A=!1,d=0,e.onSilence()))},u.connect(k),k.connect(i.destination),{setMuted:r=>{f=r},stop:()=>{k.disconnect(),u.disconnect();for(const r of l.getTracks())r.stop();i.close()}}},Q=()=>{const e=globalThis,s=e.AudioContext??e.webkitAudioContext;if(!s)throw new Error("createVoiceAgent: audio playback requires AudioContext (no browser audio available)");const o=new s,a=new Set;let l=0,i=Promise.resolve(),u=0;const k=async(d,p)=>{if(p!==u)return;let r;try{r=await o.decodeAudioData(d.buffer)}catch{return}if(p!==u)return;const h=o.createBufferSource();h.buffer=r,h.connect(o.destination);const g=Math.max(o.currentTime,l);h.start(g),l=g+r.duration,a.add(h),h.onended=()=>{a.delete(h)}},f=d=>{const p=Uint8Array.from(d),r=u;i=i.then(()=>k(p,r))},A=()=>{u+=1;for(const d of a)try{d.stop()}catch{}a.clear(),l=o.currentTime};return{enqueue:f,interrupt:A,stop:()=>{A(),o.close()}}},D=1,X=.01,Y=1200,Z=.15,ee=3,te=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,ne=e=>{const s=e.__lunoraRef,o=s.startsWith("agents:")?s.slice(7):s;return o.endsWith("Voice")?o.slice(0,-5):o},oe=(e,s,o)=>{const a=te(e),l=a.endsWith("/")?a.slice(0,-1):a,i=new URLSearchParams({threadKey:o});return`${l}/_lunora/voice/${encodeURIComponent(s)}?${i.toString()}`},ie=e=>{const{createMicrophone:s=z,createSpeaker:o=Q,createSocket:a,interruptChunks:l=ee,interruptThreshold:i=Z,silenceDurationMs:u=Y,silenceThreshold:k=X,threadKey:f,voice:A}=e,d=$(),[p,r]=w("idle"),[h,g]=w(!1),[E,x]=w(""),[F,y]=w(""),[I,_]=w(0),[U,L]=w(!1),[N,T]=w(void 0);let c,b=!1;const M=t=>{const n=c?.socket;return n?.readyState===D?(n.send(JSON.stringify(t)),!0):!1},C=()=>{const t=c;if(c=void 0,t){t.microphone?.stop(),t.speaker?.stop();try{t.socket.close()}catch{}}b=!1,g(!1),r("idle"),_(0)},P=C,W=t=>{const n=c;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),r("speaking"),y(m=>m+t.text);break}case"assistant_done":{n&&(n.speaking=!1),y(t.text),r("listening");break}case"error":{n&&(n.speaking=!1),T(new Error(t.message)),r("listening");break}case"interrupted":{n&&(n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),r("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),g(!0),r("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),x(t.text),y(""),r("thinking");break}}},V=t=>{const n=c;!n||n.suppressAudio||(n.speaker??=o({audioFormat:n.audioFormat}),n.speaking=!0,r("speaking"),n.speaker.enqueue(t))},H=async()=>{if(!(c||b)){b=!0,T(void 0),x(""),y("");try{const t=oe(d.url,ne(A),J(f)),m=(a??(S=>new globalThis.WebSocket(S)))(t);m.binaryType="arraybuffer";const v={audioFormat:"mp3",microphone:void 0,socket:m,speaker:void 0,speaking:!1,suppressAudio:!1};c=v,m.onmessage=S=>{if(typeof S.data=="string"){try{W(JSON.parse(S.data))}catch{}return}V(new Uint8Array(S.data))},m.onerror=()=>{T(new Error("createVoiceAgent: voice socket error"))},m.onclose=()=>{c===v&&C()};const R=await s({interruptChunks:l,interruptThreshold:i,isSpeaking:()=>c?.speaking??!1,onAudio:S=>{m.readyState===D&&m.send(S)},onInterrupt:()=>{M({type:"interrupt"}),c?.speaker?.interrupt(),c&&(c.speaking=!1,c.suppressAudio=!0),r("listening")},onLevel:S=>{_(S)},onSilence:()=>{M({type:"commit"}),r("thinking")},silenceDurationMs:u,silenceThreshold:k});c===v?(v.microphone=R,L(!1),r("listening")):R.stop()}catch(t){T(t instanceof Error?t:new Error(String(t))),C()}finally{b=!1}}},O=()=>{const t=!U();return c?.microphone?.setMuted(t),L(t),t},q=t=>{M({text:t,type:"text"})&&r("thinking")};return B(C),{audioLevel:I,connected:h,endCall:P,error:N,interimTranscript:F,isMuted:U,sendText:q,startCall:H,status:p,toggleMute:O,transcript:E}};export{ie as createVoiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSignal as d}from"solid-js";import{useLunora as l}from"./LunoraContext-dPcjtn6R.mjs";import{o as m}from"./solid-compat-ByG5HD_F.mjs";const g=(o,r={})=>{const t=l(),{args:n,functionPath:a,shardKey:e,value:s}=o,[c,u]=d(s),f={__lunoraRef:a};return m(()=>t.subscribe(f,n,i=>u(()=>i),{onError:r.onError,shardKey:e})),c};export{g as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/solid",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.76",
|
|
4
4
|
"description": "SolidJS adapter for Lunora — live queries, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/client": "1.0.0-alpha.
|
|
58
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
59
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.73",
|
|
58
|
+
"@lunora/errors": "1.0.0-alpha.30",
|
|
59
|
+
"@lunora/ratelimit": "1.0.0-alpha.37",
|
|
60
60
|
"@visulima/storage-client": "1.0.2"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{initialPages as C,derivePaginationStatus as $,applyLoadMore as G,rebalance as H}from"@lunora/client/pagination";import{createMemo as S,createSignal as B}from"solid-js";import{useLunora as V}from"./LunoraContext-dPcjtn6R.mjs";import{t as D}from"./solid-compat-ByG5HD_F.mjs";const X=/["\\\u0000-\u001F\uD800-\uDFFF]/,U=e=>X.test(e)?JSON.stringify(e):`"${e}"`,F=e=>{if(e===void 0)return"null";if(typeof e=="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 e=="number"){if(Number.isNaN(e))return"nan";if(e===1/0)return"inf";if(e===-1/0)return"-inf";if(Object.is(e,-0))return"-0"}if(typeof e=="string")return U(e);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e)){let n="[";for(let s=0;s<e.length;s++)s>0&&(n+=","),n+=F(e[s]);return n+"]"}const r=Object.getPrototypeOf(e);if(r!==null&&r!==Object.prototype){const n=e.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 l=e,u=Object.keys(l).sort();let a="{",t=!0;for(const n of u){const s=l[n];s!==void 0&&(t?t=!1:a+=",",a+=U(n),a+=":",a+=F(s))}return a+"}"},x=e=>{let r="";for(let u=0;u<e.length;u+=32768)r+=String.fromCharCode(...e.subarray(u,u+32768));return btoa(r)},y="$lunora.wire$",J=64,Y="__proto__",Z=e=>{if(e===null||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype},k=(e,r=0)=>{if(r>J)throw new RangeError(`wire-codec: value nesting exceeds the ${J}-level limit`);if(e===void 0)return[y,"undefined"];if(e===null)return null;const l=typeof e;if(l==="bigint")return[y,"bigint",e.toString()];if(l==="number"){const t=e;return Number.isNaN(t)?[y,"nan"]:t===1/0?[y,"inf"]:t===-1/0?[y,"-inf"]:t}if(l!=="object")return e;if(e instanceof Date)return[y,"date",k(e.getTime(),r+1)];if(e instanceof Error){const t=e,n={};for(const d of Object.keys(t))t[d]!==void 0&&(n[d]=k(t[d],r+1));const s=[y,"error",t.name,t.message,n];return t.cause!==void 0&&s.push(k(t.cause,r+1)),s}if(e instanceof URL)return[y,"url",e.href];if(e instanceof Map)return[y,"map",[...e.entries()].map(([t,n])=>[k(t,r+1),k(n,r+1)])];if(e instanceof Set)return[y,"set",[...e].map(t=>k(t,r+1))];if(e instanceof ArrayBuffer)return[y,"bytes",x(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,n=t.constructor.name,s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return n==="Uint8Array"?[y,"bytes",x(s)]:[y,"bytes",x(s),n]}if(Array.isArray(e)){const t=e.map(n=>k(n,r+1));return t.length>0&&t[0]===y?[y,"arr",t]:t}if(!Z(e)){const t=e.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 u=e,a={};for(const t of Object.keys(u)){const n=u[t];if(n===void 0)continue;const s=k(n,r+1);t===Y?Object.defineProperty(a,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):a[t]=s}return a},v=e=>F(k(e)),N=(e,r)=>({...r,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),O=(e,r)=>`${e}::${v(r)}`,W=(e,r,l)=>{const u=V(),{initialNumItems:a,shardKey:t}=l,n=()=>typeof r=="function"?r():r,[s,d]=B(C(a)),g=new Map,[h,j]=B([]),p=new Map,M=new Set,E=(o,f)=>{const b=o.map(i=>{const c=O(e.__lunoraRef,N(i,f));return g.get(c)});j(b)},q=(o,f,b)=>{const i=c=>O(e.__lunoraRef,N(c,b));for(const c of f){const m=i(c);if(g.has(m))continue;const P=o.find(w=>w.lower===c.lower);if(P){const w=g.get(i(P));w&&g.set(m,w)}}},Q=(o,f)=>{const b=new Set;for(const i of o)b.add(O(e.__lunoraRef,N(i,f)));for(const[i,c]of p)b.has(i)||(c(),p.delete(i),M.delete(i),g.delete(i));for(const i of o){const c=N(i,f),m=O(e.__lunoraRef,c);if(p.has(m))continue;M.add(m);const P=u.subscribe(e,c,w=>{g.set(m,w),M.delete(m);const A=n();if(A!=="skip"&&(E(s(),A),M.size===0)){const R=s(),K=H(R,h());K&&(q(R,K,A),d(K))}},{shardKey:t});p.set(m,P)}};let L=!1,_=!1;const I=(o,f)=>{if(L){_=!0;return}L=!0;try{let b=o,i=f;do{_=!1,Q(b,i);const c=n();if(c==="skip")break;b=s(),i=c}while(_)}finally{L=!1}},T=()=>{for(const o of p.values())o();p.clear(),g.clear(),M.clear()};D(n,o=>(T(),d(C(a)),j([]),o!=="skip"&&(I(s(),o),E(s(),o)),T)),D(s,o=>{const f=n();f!=="skip"&&(I(o,f),E(o,f))});const z=S(()=>{const o=n()==="skip";return $(o,h()).status});return{loadMore:o=>{const f=n();if(f==="skip")return;const{nextCursor:b,status:i}=$(!1,h());if(i!=="CanLoadMore")return;const c=G(s(),b,o);if(!c)return;const m=s().at(-1),P=c.at(-2);if(m&&P){const w=O(e.__lunoraRef,N(m,f)),A=O(e.__lunoraRef,N(P,f));if(w!==A){const R=g.get(w);R&&g.set(A,R)}}d(c)},pageResults:h,status:z}},oe=(e,r,l)=>{const{loadMore:u,pageResults:a,status:t}=W(e,r,l),n=S(()=>a().flatMap(d=>d?.page??[]));return{isLoading:S(()=>t()==="LoadingFirstPage"||t()==="LoadingMore"),loadMore:u,results:n,status:t}},ie=(e,r,l)=>{const{initialNumItems:u}=l,{loadMore:a,pageResults:t,status:n}=W(e,r,l),s=S(()=>t().flatMap(p=>p?[p.page]:[])),d=S(()=>n()==="LoadingFirstPage"),g=S(()=>n()==="CanLoadMore"),h=S(()=>n()==="LoadingMore");return{fetchNextPage:p=>{a(p??u)},hasNextPage:g,isFetchingNextPage:h,isLoading:d,pages:s,status:n}};export{ie as createInfiniteQuery,oe as createPaginatedQuery};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createSignal as g}from"solid-js";import{useLunora as S}from"./LunoraContext-dPcjtn6R.mjs";import{o as D}from"./solid-compat-ByG5HD_F.mjs";const I=()=>{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("")}}return Date.now().toString(36)},U=1e4,C=(t,e)=>{const r=S(),{heartbeat:d,intervalMs:u=U,listPresent:f,shardKey:i}=e,s=e.sessionId??I(),[l,m]=g(void 0);let a=e.data;const o=()=>{const n={roomId:t,sessionId:s,...a===void 0?{}:{data:a}};r.mutation(d,n,{shardKey:i}).catch(()=>{})},y=n=>{a=n,o()};return D(()=>{o();const n=setInterval(o,u),c=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};typeof document<"u"&&document.addEventListener("visibilitychange",c);const p=r.acquireConnectionContext({roomId:t,sessionId:s},{shardKey:i}),v=r.subscribe(f,{roomId:t},b=>{m(()=>b)},{shardKey:i});return()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",c),p(),v()}}),{present:l,sessionId:s,setData:y}};export{C as createPresence};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createSignal as a,onCleanup as S}from"solid-js";import{useLunora as x}from"./LunoraContext-dPcjtn6R.mjs";import{t as C}from"./solid-compat-ByG5HD_F.mjs";const K=(d,o,s={})=>{const h=x(),[p,i]=a([]),[v,f]=a(void 0),[k,e]=a("idle"),y=typeof o=="function"?o:()=>o;let t;const u=()=>{t?.()};return C(y,l=>{if(i(()=>[]),f(()=>{}),l==="skip"){e("idle");return}e("streaming");let n=!0;const m=h.stream(d,l,{maxBuffer:s.maxBuffer,shardKey:s.shardKey}),c=()=>{m.cancel()};return t=c,(async()=>{try{for await(const r of m){if(!n)return;i(E=>[...E,r])}n&&e("complete")}catch(r){if(!n)return;f(()=>r instanceof Error?r:new Error(String(r))),e("error")}})().catch(()=>{}),()=>{n=!1,c(),t===c&&(t=void 0)}}),S(()=>{u()}),{cancel:u,chunks:p,error:v,status:k}};export{K as createStream};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createQuerySubscription as v}from"@lunora/client/query";import{LunoraError as p}from"@lunora/errors";import{createSignal as a}from"solid-js";import{useLunora as u}from"./LunoraContext-dPcjtn6R.mjs";import{t as l}from"./solid-compat-ByG5HD_F.mjs";const D=(i,r,d={})=>{const s=u(),[c,e]=a(void 0),[m,t]=a(void 0);return l(typeof r=="function"?r:()=>r,n=>{if(n==="skip"){e(()=>{}),t(()=>{});return}return v(s,i,n,{onData:o=>{e(()=>o),t(()=>{})},onError:o=>{const f=o.code?new p(o.code,o.message):new Error(o.message);t(()=>f),e(()=>{})},onReset:()=>{e(()=>{})}},{shardKey:d.shardKey})}),{data:c,error:m}};export{D as createSubscription};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createSignal as i}from"solid-js";import{useLunora as d}from"./LunoraContext-dPcjtn6R.mjs";import{o as l}from"./solid-compat-ByG5HD_F.mjs";const b=t=>{const o=d(),{args:a,functionPath:e,shardKey:r,value:n}=t,[s,c]=i(n),u={__lunoraRef:e};return l(()=>o.subscribe(u,a,f=>c(()=>f),{shardKey:r})),s};export{b as default};
|