@lunora/react 1.0.0-alpha.82 → 1.0.0-alpha.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/index.d.mts +33 -3
  2. package/dist/index.d.ts +33 -3
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/cache-BSBhN-M2.mjs +1 -0
  5. package/dist/packem_shared/{hydratePreloaded-CcBW4phD.mjs → hydratePreloaded-C9nnbvjN.mjs} +1 -1
  6. package/dist/packem_shared/{lunoraQueryOptions-B5PEocLy.mjs → lunoraQueryOptions-Celdopal.mjs} +1 -1
  7. package/dist/packem_shared/{query-key-C6iUhRuD.mjs → query-key-BFaqaQy8.mjs} +1 -1
  8. package/dist/packem_shared/use-paginated-core-CZ3gyax5.mjs +2 -0
  9. package/dist/packem_shared/{useAgent-CNDRZNk_.mjs → useAgent-BOOybemP.mjs} +1 -1
  10. package/dist/packem_shared/{useAgentChat-CXJldvLG.mjs → useAgentChat-PB0upmu5.mjs} +1 -1
  11. package/dist/packem_shared/{useAgentState-BOIQjgxe.mjs → useAgentState-DcSalToC.mjs} +1 -1
  12. package/dist/packem_shared/{useAgentToolEvents-B4gy1Q5z.mjs → useAgentToolEvents-Lg1sM60_.mjs} +1 -1
  13. package/dist/packem_shared/useAuthSessions-gBDeNFnd.mjs +2 -0
  14. package/dist/packem_shared/useHttpStream-BzG5kdmo.mjs +2 -0
  15. package/dist/packem_shared/{useInfiniteQuery-C7wp0W2d.mjs → useInfiniteQuery-DFYRAWUe.mjs} +1 -1
  16. package/dist/packem_shared/{usePaginatedQuery-DJNa8KKD.mjs → usePaginatedQuery-BSJBNGSX.mjs} +1 -1
  17. package/dist/packem_shared/{useQuery-BUzNP_Vb.mjs → useQuery-TQiduIxH.mjs} +1 -1
  18. package/dist/packem_shared/{useStream-CmGOT0qj.mjs → useStream-MdOMnlR8.mjs} +1 -1
  19. package/dist/packem_shared/{useSubscription-BHVICtbD.mjs → useSubscription-B9rxVLlG.mjs} +1 -1
  20. package/dist/packem_shared/useVoiceAgent-DHdUlo0G.mjs +2 -0
  21. package/dist/packem_shared/wire-key-DhthMX_1.mjs +1 -0
  22. package/dist/server.mjs +1 -1
  23. package/package.json +4 -4
  24. package/dist/packem_shared/cache-DmbajSjf.mjs +0 -1
  25. package/dist/packem_shared/use-paginated-core-CWfn4qb4.mjs +0 -2
  26. package/dist/packem_shared/useAuthSessions-Bq4-f3g-.mjs +0 -2
  27. package/dist/packem_shared/useHttpStream-D9vum8Qx.mjs +0 -2
  28. package/dist/packem_shared/useVoiceAgent-C9NI6Vzl.mjs +0 -2
  29. package/dist/packem_shared/wire-key-L5JSXhhG.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -270,6 +270,20 @@ type UseOrganizationsOptions = AdminAuthQueryOptions;
270
270
  * invalidation-on-mutate is wired in.
271
271
  */
272
272
  declare const useOrganizations: (options?: UseOrganizationsOptions) => AdminAuthListResult<Record<string, unknown>>;
273
+ /** Options for {@link useSignUpInvitations}. */
274
+ type UseSignUpInvitationsOptions = AdminAuthQueryOptions;
275
+ /**
276
+ * List sign-up invitations (requires the `inviteOnly` plugin). Hits
277
+ * `client.listAuthSignUpInvitations` — an HTTP-only admin-gated read, same
278
+ * transport note as {@link useAuthUsers}.
279
+ *
280
+ * Rows come back unfiltered and newest-first; a row is pending when `acceptedAt`
281
+ * is null and `expiresAt` is in the future. Mutations
282
+ * (`client.createAuthSignUpInvitation`, `client.revokeAuthSignUpInvitation`)
283
+ * stay plain `client.*` calls — call `refetch()` afterward, as the other admin
284
+ * hooks do.
285
+ */
286
+ declare const useSignUpInvitations: (options?: UseSignUpInvitationsOptions) => AdminAuthListResult<Record<string, unknown>>;
273
287
  /** Options for {@link useAuthSessions}. */
274
288
  interface UseAuthSessionsOptions extends AdminAuthQueryOptions {
275
289
  /** Scope the list to one user's sessions; omit for the global cross-user browser. */
@@ -1216,8 +1230,24 @@ interface MicrophoneConfig {
1216
1230
  interruptChunks: number;
1217
1231
  /** RMS above which the user is considered to be barging in while the agent speaks. */
1218
1232
  interruptThreshold: number;
1219
- /** `true` while `status === "speaking"` — gates barge-in detection. */
1220
- isSpeaking: () => boolean;
1233
+ /**
1234
+ * `true` from the moment a turn is committed until it completes — the whole
1235
+ * `thinking` + `speaking` window, not just the audible half.
1236
+ *
1237
+ * It gates BOTH branches below, and the wider span is the point. Gated only
1238
+ * on "audibly speaking", turn detection kept running through the entire
1239
+ * STT+LLM window after a `commit`: room noise at the (deliberately low)
1240
+ * `silenceThreshold` re-armed `sawSpeech`, another quiet gap fired a SECOND
1241
+ * `commit`, and the DO refused it with "a turn is already in progress" —
1242
+ * a refusal that returns before draining the audio buffer, so the PCM
1243
+ * captured since the first commit leaked into the next utterance.
1244
+ *
1245
+ * A genuine barge-in still works in that window: it routes through the
1246
+ * `onInterrupt` branch, which needs `interruptChunks` consecutive chunks at
1247
+ * `interruptThreshold` — an order of magnitude above `silenceThreshold` —
1248
+ * and `interrupt` is exactly what the DO tells the client to send.
1249
+ */
1250
+ isTurnActive: () => boolean;
1221
1251
  /** One 16 kHz mono 16-bit little-endian PCM frame captured from the mic. */
1222
1252
  onAudio: (pcm: Uint8Array) => void;
1223
1253
  /** A barge-in was detected (RMS spike while the agent is speaking). */
@@ -1325,4 +1355,4 @@ interface UseVoiceAgentResult {
1325
1355
  * `createSocket`) so the hook is drivable outside a browser.
1326
1356
  */
1327
1357
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
1328
- export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
1358
+ export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSignUpInvitationsOptions, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useVoiceAgent };
package/dist/index.d.ts CHANGED
@@ -270,6 +270,20 @@ type UseOrganizationsOptions = AdminAuthQueryOptions;
270
270
  * invalidation-on-mutate is wired in.
271
271
  */
272
272
  declare const useOrganizations: (options?: UseOrganizationsOptions) => AdminAuthListResult<Record<string, unknown>>;
273
+ /** Options for {@link useSignUpInvitations}. */
274
+ type UseSignUpInvitationsOptions = AdminAuthQueryOptions;
275
+ /**
276
+ * List sign-up invitations (requires the `inviteOnly` plugin). Hits
277
+ * `client.listAuthSignUpInvitations` — an HTTP-only admin-gated read, same
278
+ * transport note as {@link useAuthUsers}.
279
+ *
280
+ * Rows come back unfiltered and newest-first; a row is pending when `acceptedAt`
281
+ * is null and `expiresAt` is in the future. Mutations
282
+ * (`client.createAuthSignUpInvitation`, `client.revokeAuthSignUpInvitation`)
283
+ * stay plain `client.*` calls — call `refetch()` afterward, as the other admin
284
+ * hooks do.
285
+ */
286
+ declare const useSignUpInvitations: (options?: UseSignUpInvitationsOptions) => AdminAuthListResult<Record<string, unknown>>;
273
287
  /** Options for {@link useAuthSessions}. */
274
288
  interface UseAuthSessionsOptions extends AdminAuthQueryOptions {
275
289
  /** Scope the list to one user's sessions; omit for the global cross-user browser. */
@@ -1216,8 +1230,24 @@ interface MicrophoneConfig {
1216
1230
  interruptChunks: number;
1217
1231
  /** RMS above which the user is considered to be barging in while the agent speaks. */
1218
1232
  interruptThreshold: number;
1219
- /** `true` while `status === "speaking"` — gates barge-in detection. */
1220
- isSpeaking: () => boolean;
1233
+ /**
1234
+ * `true` from the moment a turn is committed until it completes — the whole
1235
+ * `thinking` + `speaking` window, not just the audible half.
1236
+ *
1237
+ * It gates BOTH branches below, and the wider span is the point. Gated only
1238
+ * on "audibly speaking", turn detection kept running through the entire
1239
+ * STT+LLM window after a `commit`: room noise at the (deliberately low)
1240
+ * `silenceThreshold` re-armed `sawSpeech`, another quiet gap fired a SECOND
1241
+ * `commit`, and the DO refused it with "a turn is already in progress" —
1242
+ * a refusal that returns before draining the audio buffer, so the PCM
1243
+ * captured since the first commit leaked into the next utterance.
1244
+ *
1245
+ * A genuine barge-in still works in that window: it routes through the
1246
+ * `onInterrupt` branch, which needs `interruptChunks` consecutive chunks at
1247
+ * `interruptThreshold` — an order of magnitude above `silenceThreshold` —
1248
+ * and `interrupt` is exactly what the DO tells the client to send.
1249
+ */
1250
+ isTurnActive: () => boolean;
1221
1251
  /** One 16 kHz mono 16-bit little-endian PCM frame captured from the mic. */
1222
1252
  onAudio: (pcm: Uint8Array) => void;
1223
1253
  /** A barge-in was detected (RMS spike while the agent is speaking). */
@@ -1325,4 +1355,4 @@ interface UseVoiceAgentResult {
1325
1355
  * `createSocket`) so the hook is drivable outside a browser.
1326
1356
  */
1327
1357
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
1328
- export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
1358
+ export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSignUpInvitationsOptions, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useVoiceAgent };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-dC08yqew.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CoOG9XdT.mjs";import{LunoraProvider as f,useLunora as n}from"./packem_shared/LunoraProvider-DC06S-p1.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-B5PEocLy.mjs";import{useAction as x}from"./packem_shared/useAction-CUSJu4yq.mjs";import{useAuthSessions as A,useAuthUsers as g,useImpersonate as h,useOrganizations as c}from"./packem_shared/useAuthSessions-Bq4-f3g-.mjs";import{useAgent as y}from"./packem_shared/useAgent-CNDRZNk_.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-CXJldvLG.mjs";import{useAgentState as S}from"./packem_shared/useAgentState-BOIQjgxe.mjs";import{useAgentToolEvents as L}from"./packem_shared/useAgentToolEvents-B4gy1Q5z.mjs";import{default as F}from"./packem_shared/useAuth-x4boOoAR.mjs";import{default as I}from"./packem_shared/useClientQuery-DFs7trEf.mjs";import{default as v}from"./packem_shared/useConnectionStatus-XYsYGiT6.mjs";import{useFlag as O,useFlags as T}from"./packem_shared/useFlag-BDM923ke.mjs";import{useHttpStream as H}from"./packem_shared/useHttpStream-D9vum8Qx.mjs";import{default as j}from"./packem_shared/useInfiniteQuery-C7wp0W2d.mjs";import{useMutation as w}from"./packem_shared/useMutation-BnKec7bE.mjs";import{useMutator as D}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as J}from"./packem_shared/usePaginatedQuery-DJNa8KKD.mjs";import{hydratePreloaded as N,default as W}from"./packem_shared/hydratePreloaded-CcBW4phD.mjs";import{usePresence as Y}from"./packem_shared/usePresence-BVjZyltT.mjs";import{default as _}from"./packem_shared/useQuery-BUzNP_Vb.mjs";import{useRateLimit as ee}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as oe}from"./packem_shared/useStream-CmGOT0qj.mjs";import{default as ue}from"./packem_shared/useSubscription-BHVICtbD.mjs";import{useVoiceAgent as ae}from"./packem_shared/useVoiceAgent-C9NI6Vzl.mjs";import{createClientQuery as fe,getErrorCode as ne,getRetryAfterMs as ie,isConflictError as me,isForbiddenError as de,isRateLimitedError as xe,isUnauthorizedError as le}from"@lunora/client";import{RestrictionError as ge,UploadControl as he,UploadError as ce}from"@visulima/storage-client";import{useChunkedRestUpload as ye,useFileInput as Ce,useMultipartUpload as Ee,usePasteUpload as Qe,useTusUpload as Se,useUpload as Pe}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,ge as RestrictionError,u as Unauthenticated,he as UploadControl,ce as UploadError,fe as createClientQuery,ne as getErrorCode,ie as getRetryAfterMs,N as hydratePreloaded,me as isConflictError,de as isForbiddenError,xe as isRateLimitedError,le as isUnauthorizedError,m as lunoraQueryOptions,x as useAction,y as useAgent,E as useAgentChat,S as useAgentState,L as useAgentToolEvents,F as useAuth,A as useAuthSessions,a as useAuthState,g as useAuthUsers,ye as useChunkedRestUpload,I as useClientQuery,v as useConnectionStatus,Ce as useFileInput,O as useFlag,T as useFlags,H as useHttpStream,h as useImpersonate,j as useInfiniteQuery,n as useLunora,Ee as useMultipartUpload,w as useMutation,D as useMutator,c as useOrganizations,J as usePaginatedQuery,Qe as usePasteUpload,W as usePreloadedQuery,Y as usePresence,_ as useQuery,ee as useRateLimit,oe as useStream,ue as useSubscription,Se as useTusUpload,Pe as useUpload,ae as useVoiceAgent};
2
+ import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-dC08yqew.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CoOG9XdT.mjs";import{LunoraProvider as n,useLunora as f}from"./packem_shared/LunoraProvider-DC06S-p1.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-Celdopal.mjs";import{useAction as x}from"./packem_shared/useAction-CUSJu4yq.mjs";import{useAuthSessions as g,useAuthUsers as A,useImpersonate as h,useOrganizations as U,useSignUpInvitations as c}from"./packem_shared/useAuthSessions-gBDeNFnd.mjs";import{useAgent as C}from"./packem_shared/useAgent-BOOybemP.mjs";import{useAgentChat as S}from"./packem_shared/useAgentChat-PB0upmu5.mjs";import{useAgentState as P}from"./packem_shared/useAgentState-DcSalToC.mjs";import{useAgentToolEvents as R}from"./packem_shared/useAgentToolEvents-Lg1sM60_.mjs";import{default as I}from"./packem_shared/useAuth-x4boOoAR.mjs";import{default as v}from"./packem_shared/useClientQuery-DFs7trEf.mjs";import{default as z}from"./packem_shared/useConnectionStatus-XYsYGiT6.mjs";import{useFlag as T,useFlags as k}from"./packem_shared/useFlag-BDM923ke.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-BzG5kdmo.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-DFYRAWUe.mjs";import{useMutation as B}from"./packem_shared/useMutation-BnKec7bE.mjs";import{useMutator as G}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as K}from"./packem_shared/usePaginatedQuery-BSJBNGSX.mjs";import{hydratePreloaded as W,default as X}from"./packem_shared/hydratePreloaded-C9nnbvjN.mjs";import{usePresence as Z}from"./packem_shared/usePresence-BVjZyltT.mjs";import{default as $}from"./packem_shared/useQuery-TQiduIxH.mjs";import{useRateLimit as re}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as te}from"./packem_shared/useStream-MdOMnlR8.mjs";import{default as se}from"./packem_shared/useSubscription-B9rxVLlG.mjs";import{useVoiceAgent as pe}from"./packem_shared/useVoiceAgent-DHdUlo0G.mjs";import{createClientQuery as fe,getErrorCode as ie,getRetryAfterMs as me,isConflictError as de,isForbiddenError as xe,isRateLimitedError as le,isUnauthorizedError as ge}from"@lunora/client";import{RestrictionError as he,UploadControl as Ue,UploadError as ce}from"@visulima/storage-client";import{useChunkedRestUpload as Ce,useFileInput as Ee,useMultipartUpload as Se,usePasteUpload as Qe,useTusUpload as Pe,useUpload as Le}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,n as LunoraProvider,he as RestrictionError,u as Unauthenticated,Ue as UploadControl,ce as UploadError,fe as createClientQuery,ie as getErrorCode,me as getRetryAfterMs,W as hydratePreloaded,de as isConflictError,xe as isForbiddenError,le as isRateLimitedError,ge as isUnauthorizedError,m as lunoraQueryOptions,x as useAction,C as useAgent,S as useAgentChat,P as useAgentState,R as useAgentToolEvents,I as useAuth,g as useAuthSessions,a as useAuthState,A as useAuthUsers,Ce as useChunkedRestUpload,v as useClientQuery,z as useConnectionStatus,Ee as useFileInput,T as useFlag,k as useFlags,V as useHttpStream,h as useImpersonate,q as useInfiniteQuery,f as useLunora,Se as useMultipartUpload,B as useMutation,G as useMutator,U as useOrganizations,K as usePaginatedQuery,Qe as usePasteUpload,X as usePreloadedQuery,Z as usePresence,$ as useQuery,re as useRateLimit,c as useSignUpInvitations,te as useStream,se as useSubscription,Pe as useTusUpload,Le as useUpload,pe as useVoiceAgent};
@@ -0,0 +1 @@
1
+ import{k as a}from"./query-key-BFaqaQy8.mjs";class d{constructor(e){this.client=e}client;entries=new Map;keyOf(e){return a(e)}hasConsumers(e){return this.entries.has(a(e))}attach(e,c,f,b,h,k={}){const s=a(c);let r=this.entries.get(s);if(!r){r={errorCallbacks:new Set,refCount:0,unsubscribe:void 0},this.entries.set(s,r);const t=r;try{r.unsubscribe=this.client.subscribe(f,b,n=>{e.setQueryData(c,n)},{onError:n=>{for(const C of t.errorCallbacks)C(n)},shardKey:h})}catch(n){throw this.entries.delete(s),n}}r.refCount+=1;const{onError:o}=k;o&&r.errorCallbacks.add(o);let u=!1;return()=>{if(u)return;u=!0;const t=this.entries.get(s);t&&(t.refCount-=1,o&&t.errorCallbacks.delete(o),t.refCount<=0&&(t.unsubscribe?.(),this.entries.delete(s)))}}}const l=new WeakMap,y=i=>{let e=l.get(i);return e||(e=new d(i),l.set(i,e)),e};export{y as g};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as _}from"react/compiler-runtime";import{useQueryClient as b,useQuery as q}from"@tanstack/react-query";import{useRef as K,useEffect as Q}from"react";import{g as P}from"./cache-DmbajSjf.mjs";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{l as N,s as S}from"./query-key-C6iUhRuD.mjs";const T=function(a,e){const r=_(9);let o;r[0]!==e?(o=e===void 0?{}:e,r[0]=e,r[1]=o):o=r[1];const n=o,t=v(),s=b(),p=K(n.onError);let i;r[2]!==n.onError?(i=()=>{p.current=n.onError},r[2]=n.onError,r[3]=i):i=r[3],Q(i);let u;r[4]===Symbol.for("react.memo_cache_sentinel")?(u=I=>{p.current?.(I)},r[4]=u):u=r[4];const E=u,{args:l,functionPath:R,shardKey:f,value:g}=a,y={__lunoraRef:R},m=N(y,l,f),{data:h}=q({initialData:g,queryFn:()=>t.query(y,l,{shardKey:f}),queryKey:m,staleTime:Number.POSITIVE_INFINITY}),d=S(m);let c;return r[5]!==t||r[6]!==s||r[7]!==d?(c=[t,s,d,E],r[5]=t,r[6]=s,r[7]=d,r[8]=c):c=r[8],Q(()=>P(t).attach(s,m,y,l,f,{onError:E}),c),h===void 0?g:h},L=function(a,e={}){return T(a,e)};export{T as default,L as hydratePreloaded};
2
+ import{c as _}from"react/compiler-runtime";import{useQueryClient as b,useQuery as q}from"@tanstack/react-query";import{useRef as K,useEffect as Q}from"react";import{g as P}from"./cache-BSBhN-M2.mjs";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{l as N,s as S}from"./query-key-BFaqaQy8.mjs";const T=function(a,e){const r=_(9);let o;r[0]!==e?(o=e===void 0?{}:e,r[0]=e,r[1]=o):o=r[1];const n=o,t=v(),s=b(),p=K(n.onError);let i;r[2]!==n.onError?(i=()=>{p.current=n.onError},r[2]=n.onError,r[3]=i):i=r[3],Q(i);let u;r[4]===Symbol.for("react.memo_cache_sentinel")?(u=I=>{p.current?.(I)},r[4]=u):u=r[4];const E=u,{args:l,functionPath:R,shardKey:f,value:g}=a,y={__lunoraRef:R},m=N(y,l,f),{data:h}=q({initialData:g,queryFn:()=>t.query(y,l,{shardKey:f}),queryKey:m,staleTime:Number.POSITIVE_INFINITY}),d=S(m);let c;return r[5]!==t||r[6]!==s||r[7]!==d?(c=[t,s,d,E],r[5]=t,r[6]=s,r[7]=d,r[8]=c):c=r[8],Q(()=>P(t).attach(s,m,y,l,f,{onError:E}),c),h===void 0?g:h},L=function(a,e={}){return T(a,e)};export{T as default,L as hydratePreloaded};
@@ -1 +1 @@
1
- import{l as u}from"./query-key-C6iUhRuD.mjs";const t=(a,r,s,e={})=>{const y=s??{};return{queryFn:()=>a.query(r,y,{shardKey:e.shardKey}),queryKey:u(r,y,e.shardKey),staleTime:Number.POSITIVE_INFINITY}};export{t as lunoraQueryOptions};
1
+ import{l as u}from"./query-key-BFaqaQy8.mjs";const t=(a,r,s,e={})=>{const y=s??{};return{queryFn:()=>a.query(r,y,{shardKey:e.shardKey}),queryKey:u(r,y,e.shardKey),staleTime:Number.POSITIVE_INFINITY}};export{t as lunoraQueryOptions};
@@ -1 +1 @@
1
- import{s as r}from"./wire-key-L5JSXhhG.mjs";const o=e=>r(e),n=(e,s,a)=>["lunora",e.__lunoraRef,s,a??null],t=e=>o(e);export{o as k,n as l,t as s};
1
+ import{s as r}from"./wire-key-DhthMX_1.mjs";const o=e=>r(e),n=(e,s,a)=>["lunora",e.__lunoraRef,s,a??null],t=e=>o(e);export{o as k,n as l,t as s};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{initialPages as N,rebalance as j,derivePaginationStatus as O,applyLoadMore as H}from"@lunora/client/pagination";import{useQueryClient as V}from"@tanstack/react-query";import{useRef as h,useReducer as Y,useState as T,useEffect as d,useCallback as B}from"react";import{g as G}from"./cache-BSBhN-M2.mjs";import{useLunora as J}from"./LunoraProvider-DC06S-p1.mjs";import{s as c,l as I}from"./query-key-BFaqaQy8.mjs";const U=function(u){const m=h(void 0);return m.current??=u(),m},te=function(u,m,R){const i=J(),a=V(),{initialNumItems:Q,shardKey:g}=R,y=m==="skip",p=y?{}:m,[,D]=Y(e=>e+1,0),[A,K]=T(()=>N(Q)),[z,k]=T(void 0),P=h(R.onError);d(()=>{P.current=R.onError});const q=`${c(I(u,p,g))}::${String(Q)}`,x=h(q);x.current!==q&&(x.current=q,K(N(Q)),k(void 0));const b=A.map(e=>{const r={...p,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},t=I(u,r,g);return{args:r,key:t}}),F=b.map(({key:e})=>c(e)).join("|"),v=h({baseArgs:p,entries:[],fn:u,shardKey:g});d(()=>{v.current={baseArgs:p,entries:b,fn:u,shardKey:g}});const L=(e,r,t)=>{k(t),K(o=>{const s=v.current,n=o.at(-1);if(o.length<=1||!n||a.getQueryData(r)!==void 0)return o;const w={...s.baseArgs,paginationOpts:{cursor:n.lower,endCursor:n.upper,numItems:n.numItems}};return c(I(s.fn,w,s.shardKey))===e?o.slice(0,-1):o}),P.current?.(t)},E=U(()=>new Map),M=h(i);d(()=>{const e=E.current;if(M.current!==i){for(const s of e.values())s();e.clear(),M.current=i}if(y){for(const s of e.values())s();e.clear();return}const r=v.current,t=G(i),o=new Set(r.entries.map(({key:s})=>c(s)));for(const[s,n]of e)o.has(s)||(n(),e.delete(s));for(const s of r.entries){const n=c(s.key);if(e.has(n))continue;a.fetchQuery({gcTime:Number.POSITIVE_INFINITY,queryFn:()=>i.query(r.fn,s.args,{shardKey:r.shardKey}),queryKey:s.key,staleTime:0}).catch(f=>{L(n,s.key,f instanceof Error?{code:f.code,message:f.message}:{message:String(f)})});const l=t.attach(a,s.key,r.fn,s.args,r.shardKey,{onError:f=>{L(n,s.key,f)}}),C=s.key;e.set(n,()=>{l(),t.hasConsumers(C)||a.removeQueries({exact:!0,queryKey:C})})}},[i,a,F,y]),d(()=>()=>{for(const e of E.current.values())e();E.current.clear()},[]),d(()=>a.getQueryCache().subscribe(t=>{if(t.type!=="updated")return;const o=c(t.query.queryKey);b.some(({key:s})=>c(s)===o)&&(k(void 0),D())}),[a,F]);const S=y?[]:b.map(({key:e})=>a.getQueryData(e));d(()=>{if(y)return;const e=j(A,S);e&&K(e)});const{status:_}=O(y,S),$=B(e=>{k(void 0),K(r=>{const t=v.current,o=r.map(l=>{const C={...t.baseArgs,paginationOpts:{cursor:l.lower,endCursor:l.upper,numItems:l.numItems}};return a.getQueryData(I(t.fn,C,t.shardKey))}),{nextCursor:s,status:n}=O(!1,o);return H(r,n==="CanLoadMore"?s:void 0,e)??r})},[a]);return{error:z,loadMore:$,pageResults:S,status:_}};export{te as u};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as N}from"react/compiler-runtime";import{useMutation as R}from"./useMutation-BnKec7bE.mjs";import O from"./useSubscription-BHVICtbD.mjs";const b={__lunoraRef:""},F=_=>{const t=N(20),{api:A,cancel:a,onError:d,run:I,runArgs:f,threadKey:e}=_,s=R(I),T=R(a??b);let c;t[0]!==e?(c={key:e},t[0]=e,t[1]=c):c=t[1];let r;t[2]!==d?(r={onError:d},t[2]=d,t[3]=r):r=t[3];const{data:v,error:p}=O(A.agents.agentThread,c,r),n=v,g=n?.status,o=n?.instanceId,{mutate:m}=s,{mutate:M}=T;let i;t[4]!==f||t[5]!==m||t[6]!==e?(i=async(w,E)=>{await m({input:w,threadKey:e,...f,...E})},t[4]=f,t[5]=m,t[6]=e,t[7]=i):i=t[7];const h=i;let u;t[8]!==M||t[9]!==a||t[10]!==o||t[11]!==e?(u=async()=>{a===void 0||o===void 0||await M({instanceId:o,threadKey:e})},t[8]=M,t[9]=a,t[10]=o,t[11]=e,t[12]=u):u=t[12];const y=u;let l;return t[13]!==y||t[14]!==p||t[15]!==h||t[16]!==s.pending||t[17]!==g||t[18]!==n?(l={cancel:y,error:p,pending:s.pending,run:h,status:g,thread:n},t[13]=y,t[14]=p,t[15]=h,t[16]=s.pending,t[17]=g,t[18]=n,t[19]=l):l=t[19],l};export{F as useAgent};
2
+ import{c as N}from"react/compiler-runtime";import{useMutation as R}from"./useMutation-BnKec7bE.mjs";import O from"./useSubscription-B9rxVLlG.mjs";const b={__lunoraRef:""},F=_=>{const t=N(20),{api:A,cancel:a,onError:d,run:I,runArgs:f,threadKey:e}=_,s=R(I),T=R(a??b);let c;t[0]!==e?(c={key:e},t[0]=e,t[1]=c):c=t[1];let r;t[2]!==d?(r={onError:d},t[2]=d,t[3]=r):r=t[3];const{data:v,error:p}=O(A.agents.agentThread,c,r),n=v,g=n?.status,o=n?.instanceId,{mutate:m}=s,{mutate:M}=T;let i;t[4]!==f||t[5]!==m||t[6]!==e?(i=async(w,E)=>{await m({input:w,threadKey:e,...f,...E})},t[4]=f,t[5]=m,t[6]=e,t[7]=i):i=t[7];const h=i;let u;t[8]!==M||t[9]!==a||t[10]!==o||t[11]!==e?(u=async()=>{a===void 0||o===void 0||await M({instanceId:o,threadKey:e})},t[8]=M,t[9]=a,t[10]=o,t[11]=e,t[12]=u):u=t[12];const y=u;let l;return t[13]!==y||t[14]!==p||t[15]!==h||t[16]!==s.pending||t[17]!==g||t[18]!==n?(l={cancel:y,error:p,pending:s.pending,run:h,status:g,thread:n},t[13]=y,t[14]=p,t[15]=h,t[16]=s.pending,t[17]=g,t[18]=n,t[19]=l):l=t[19],l};export{F as useAgent};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as Q,useRef as S}from"react";import{useMutation as u}from"./useMutation-BnKec7bE.mjs";import{useStream as V}from"./useStream-CmGOT0qj.mjs";import A from"./useSubscription-BHVICtbD.mjs";const W={__lunoraRef:""},X={__lunoraRef:""},Z=[],it=E=>{const{api:a,cancel:m,limit:d,onError:l,send:_,sendArgs:k,stream:p,threadKey:e}=E,x=d===void 0?{key:e}:{key:e,limit:d},{data:w,error:O}=A(a.agents.agentMessages,x,{onError:l}),{data:T,error:b}=A(a.agents.agentThread,{key:e},{onError:l}),I=p===void 0?"skip":{key:e},{chunks:j}=V(p??X,I),q=u(_),C=u(m??W),D=u(a.agents.agentResolveApproval),[K,c]=Q([]),f=S(0),h=S(e);h.current!==e&&(h.current=e,c([]));const g=T,N=g?.status,o=g?.instanceId,s=w??Z,v=M(K,s),F=R(s),G=v.length===0?s:[...s,...v.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:F+1+n}))],P=s.filter(t=>t.role==="assistant").length,U=j.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=P).map(t=>t.text).join(""),{mutate:Y}=q,{mutate:$}=C,{mutate:z}=D,B=async(t,n)=>{const r=f.current;f.current+=1;const H=R(s);c(i=>[...M(i,s),{content:t,id:r,maxDurableSeqAtSend:H}]);try{await Y({input:t,threadKey:e,...k,...n})}catch(i){throw c(J=>J.filter(L=>L.id!==r)),i}},y=async(t,n,r)=>{if(o===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await z({decision:t,instanceId:o,threadKey:e,toolCallId:n,...r===void 0?{}:{note:r}})};return{approve:(t,n)=>y("approve",t,n),cancel:async()=>{m===void 0||o===void 0||await $({instanceId:o,threadKey:e})},error:O??b,messages:G,reject:(t,n)=>y("reject",t,n),send:B,status:N,streamingText:U}};export{it as useAgentChat};
2
+ import{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as Q,useRef as S}from"react";import{useMutation as u}from"./useMutation-BnKec7bE.mjs";import{useStream as V}from"./useStream-MdOMnlR8.mjs";import A from"./useSubscription-B9rxVLlG.mjs";const W={__lunoraRef:""},X={__lunoraRef:""},Z=[],it=E=>{const{api:a,cancel:m,limit:d,onError:l,send:_,sendArgs:k,stream:p,threadKey:e}=E,x=d===void 0?{key:e}:{key:e,limit:d},{data:w,error:O}=A(a.agents.agentMessages,x,{onError:l}),{data:T,error:b}=A(a.agents.agentThread,{key:e},{onError:l}),I=p===void 0?"skip":{key:e},{chunks:j}=V(p??X,I),q=u(_),C=u(m??W),D=u(a.agents.agentResolveApproval),[K,c]=Q([]),f=S(0),h=S(e);h.current!==e&&(h.current=e,c([]));const g=T,N=g?.status,o=g?.instanceId,s=w??Z,v=M(K,s),F=R(s),G=v.length===0?s:[...s,...v.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:F+1+n}))],P=s.filter(t=>t.role==="assistant").length,U=j.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=P).map(t=>t.text).join(""),{mutate:Y}=q,{mutate:$}=C,{mutate:z}=D,B=async(t,n)=>{const r=f.current;f.current+=1;const H=R(s);c(i=>[...M(i,s),{content:t,id:r,maxDurableSeqAtSend:H}]);try{await Y({input:t,threadKey:e,...k,...n})}catch(i){throw c(J=>J.filter(L=>L.id!==r)),i}},y=async(t,n,r)=>{if(o===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await z({decision:t,instanceId:o,threadKey:e,toolCallId:n,...r===void 0?{}:{note:r}})};return{approve:(t,n)=>y("approve",t,n),cancel:async()=>{m===void 0||o===void 0||await $({instanceId:o,threadKey:e})},error:O??b,messages:G,reject:(t,n)=>y("reject",t,n),send:B,status:N,streamingText:U}};export{it as useAgentChat};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as o}from"react/compiler-runtime";import d from"./useSubscription-BHVICtbD.mjs";const l=t=>{const e=o(5);let r;e[0]!==t.threadKey?(r={key:t.threadKey},e[0]=t.threadKey,e[1]=r):r=e[1];const{data:n,error:s}=d(t.api.agents.agentState,r),c=n;let a;return e[2]!==s||e[3]!==c?(a={error:s,state:c},e[2]=s,e[3]=c,e[4]=a):a=e[4],a};export{l as useAgentState};
2
+ import{c as o}from"react/compiler-runtime";import d from"./useSubscription-B9rxVLlG.mjs";const l=t=>{const e=o(5);let r;e[0]!==t.threadKey?(r={key:t.threadKey},e[0]=t.threadKey,e[1]=r):r=e[1];const{data:n,error:s}=d(t.api.agents.agentState,r),c=n;let a;return e[2]!==s||e[3]!==c?(a={error:s,state:c},e[2]=s,e[3]=c,e[4]=a):a=e[4],a};export{l as useAgentState};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as y}from"react/compiler-runtime";import{useStream as I}from"./useStream-CmGOT0qj.mjs";import N from"./useSubscription-BHVICtbD.mjs";const E={__lunoraRef:""},_=[],k=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(t=>({input:t.input,seq:o.seq,toolCallId:t.id,toolName:t.name,type:"call"}));if(o.role==="tool")return o.status==="awaiting_approval"?[{seq:o.seq,type:"awaiting-approval",...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]:[{output:o.content,seq:o.seq,type:"result",...o.status==="approved"||o.status==="rejected"?{status:o.status}:{},...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]},A=o=>{const t=y(12),{api:c,limit:r,stream:n,threadKey:l}=o;let a;t[0]!==r||t[1]!==l?(a=r===void 0?{key:l}:{key:l,limit:r},t[0]=r,t[1]=l,t[2]=a):a=t[2];const f=a,{data:v}=N(c.agents.agentMessages,f);let i;t[3]!==n||t[4]!==l?(i=n===void 0?"skip":{key:l},t[3]=n,t[4]=l,t[5]=i):i=t[5];const C=i,{chunks:p}=I(n??E,C),s=v??_;let e;if(t[6]!==p||t[7]!==s||t[8]!==l){e=s.flatMap(q);for(const d of p)d.kind==="progress"&&d.threadKey===l&&e.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});t[6]=p,t[7]=s,t[8]=l,t[9]=e}else e=t[9];let u;return t[10]!==e?(u={events:e},t[10]=e,t[11]=u):u=t[11],u};function q(o){return k(o)??[]}export{A as useAgentToolEvents};
2
+ import{c as y}from"react/compiler-runtime";import{useStream as I}from"./useStream-MdOMnlR8.mjs";import N from"./useSubscription-B9rxVLlG.mjs";const E={__lunoraRef:""},_=[],k=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(t=>({input:t.input,seq:o.seq,toolCallId:t.id,toolName:t.name,type:"call"}));if(o.role==="tool")return o.status==="awaiting_approval"?[{seq:o.seq,type:"awaiting-approval",...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]:[{output:o.content,seq:o.seq,type:"result",...o.status==="approved"||o.status==="rejected"?{status:o.status}:{},...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]},A=o=>{const t=y(12),{api:c,limit:r,stream:n,threadKey:l}=o;let a;t[0]!==r||t[1]!==l?(a=r===void 0?{key:l}:{key:l,limit:r},t[0]=r,t[1]=l,t[2]=a):a=t[2];const f=a,{data:v}=N(c.agents.agentMessages,f);let i;t[3]!==n||t[4]!==l?(i=n===void 0?"skip":{key:l},t[3]=n,t[4]=l,t[5]=i):i=t[5];const C=i,{chunks:p}=I(n??E,C),s=v??_;let e;if(t[6]!==p||t[7]!==s||t[8]!==l){e=s.flatMap(q);for(const d of p)d.kind==="progress"&&d.threadKey===l&&e.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});t[6]=p,t[7]=s,t[8]=l,t[9]=e}else e=t[9];let u;return t[10]!==e?(u={events:e},t[10]=e,t[11]=u):u=t[11],u};function q(o){return k(o)??[]}export{A as useAgentToolEvents};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as A}from"react/compiler-runtime";import{useMutation as y,useQuery as z,keepPreviousData as I}from"@tanstack/react-query";import{useState as _,useSyncExternalStore as b}from"react";import{useLunora as S}from"./LunoraProvider-DC06S-p1.mjs";const U="lunora-react-admin-auth",D=50;function v(t,e,o,u={}){const{enabled:r=!0,pageSize:c=D}=u,[i,s]=_(c),a=b(g=>t.onAuthTokenChange(g),()=>t.currentIdentity(),()=>t.currentIdentity()),n=[U,a??"anon",...e,i],l=z({enabled:r,placeholderData:I,queryFn:()=>o(i),queryKey:n,staleTime:0}),d=l.data?.rows,f=l.data?.total,m=f!==void 0&&d!==void 0&&d.length<f,p=()=>{m&&s(g=>g+c)},h=()=>{l.refetch().catch(()=>{})};return{data:d,error:l.error??void 0,hasMore:m,loadMore:p,loading:l.isLoading,refetch:h,total:f}}const $=t=>{const e=A(20);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=S(),{enabled:c,filterField:i,filterValue:s,pageSize:a,search:n,searchField:l,sortBy:d,sortDirection:f}=u;let m;e[2]!==i||e[3]!==s||e[4]!==n||e[5]!==l||e[6]!==d||e[7]!==f?(m=["users",{filterField:i,filterValue:s,search:n,searchField:l,sortBy:d,sortDirection:f}],e[2]=i,e[3]=s,e[4]=n,e[5]=l,e[6]=d,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==r||e[10]!==i||e[11]!==s||e[12]!==n||e[13]!==l||e[14]!==d||e[15]!==f?(p=g=>r.listAuthUsers({filterField:i,filterValue:s,limit:g,search:n,searchField:l,sortBy:d,sortDirection:f}),e[9]=r,e[10]=i,e[11]=s,e[12]=n,e[13]=l,e[14]=d,e[15]=f,e[16]=p):p=e[16];let h;return e[17]!==c||e[18]!==a?(h={enabled:c,pageSize:a},e[17]=c,e[18]=a,e[19]=h):h=e[19],v(r,m,p,h)},M=t=>{const e=A(8);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=S(),{enabled:c,pageSize:i}=u;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=["organizations"],e[2]=s):s=e[2];let a;e[3]!==r?(a=l=>r.listAuthOrganizations({limit:l}),e[3]=r,e[4]=a):a=e[4];let n;return e[5]!==c||e[6]!==i?(n={enabled:c,pageSize:i},e[5]=c,e[6]=i,e[7]=n):n=e[7],v(r,s,a,n)},T=t=>{const e=A(8);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=S(),{enabled:c,pageSize:i}=u;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=["sign-up-invitations"],e[2]=s):s=e[2];let a;e[3]!==r?(a=l=>r.listAuthSignUpInvitations({limit:l}),e[3]=r,e[4]=a):a=e[4];let n;return e[5]!==c||e[6]!==i?(n={enabled:c,pageSize:i},e[5]=c,e[6]=i,e[7]=n):n=e[7],v(r,s,a,n)},q=t=>{const e=A(10);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=S(),{enabled:c,pageSize:i,userId:s}=u;let a;e[2]!==s?(a=["sessions",{userId:s}],e[2]=s,e[3]=a):a=e[3];let n;e[4]!==r||e[5]!==s?(n=d=>r.listAuthSessions({limit:d,userId:s}),e[4]=r,e[5]=s,e[6]=n):n=e[6];let l;return e[7]!==c||e[8]!==i?(l={enabled:c,pageSize:i},e[7]=c,e[8]=i,e[9]=l):l=e[9],v(r,a,n,l)},k=()=>{const t=A(10),e=S();let o;t[0]!==e?(o={mutationFn:l=>e.impersonateAuthUser({userId:l})},t[0]=e,t[1]=o):o=t[1];const u=y(o),{mutateAsync:r,reset:c}=u;let i;t[2]!==r?(i=l=>r(l),t[2]=r,t[3]=i):i=t[3];const s=i,a=u.error??void 0;let n;return t[4]!==s||t[5]!==u.data||t[6]!==u.isPending||t[7]!==c||t[8]!==a?(n={data:u.data,error:a,impersonate:s,pending:u.isPending,reset:c},t[4]=s,t[5]=u.data,t[6]=u.isPending,t[7]=c,t[8]=a,t[9]=n):n=t[9],n};export{q as useAuthSessions,$ as useAuthUsers,k as useImpersonate,M as useOrganizations,T as useSignUpInvitations};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as S}from"react/compiler-runtime";import{useReducer as _,useRef as v,useEffect as R}from"react";import{useLunora as b}from"./LunoraProvider-DC06S-p1.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{s as H}from"./wire-key-DhthMX_1.mjs";const w=(t,c,n)=>{const e=S(24);let m;e[0]!==n?(m=n===void 0?{}:n,e[0]=n,e[1]=m):m=e[1];const o=m,f=b();let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={chunks:[],error:void 0,status:"idle"},e[2]=a):a=e[2];const[s,i]=_(z,a),r=c==="skip";let l;e[3]!==c||e[4]!==r?(l=r?"skip":H(c),e[3]=c,e[4]=r,e[5]=l):l=e[5];const k=l,x=v(void 0);let u;e[6]!==c||e[7]!==f||e[8]!==o.maxBuffer||e[9]!==t||e[10]!==r?(u=()=>{if(r)return i({type:"reset"}),K;i({type:"reset"}),i({type:"start"});const{cancel:B,cleanup:y}=E(f.httpStream(t,c,{maxBuffer:o.maxBuffer}),i);return x.current=B,()=>{y(),x.current=void 0}},e[6]=c,e[7]=f,e[8]=o.maxBuffer,e[9]=t,e[10]=r,e[11]=u):u=e[11];let p;e[12]!==f||e[13]!==o.maxBuffer||e[14]!==t.method||e[15]!==t.path||e[16]!==k||e[17]!==r?(p=[f,t.method,t.path,k,r,o.maxBuffer],e[12]=f,e[13]=o.maxBuffer,e[14]=t.method,e[15]=t.path,e[16]=k,e[17]=r,e[18]=p):p=e[18],R(u,p);let h;e[19]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{x.current?.()},e[19]=h):h=e[19];let d;return e[20]!==s.chunks||e[21]!==s.error||e[22]!==s.status?(d={cancel:h,chunks:s.chunks,error:s.error,status:s.status},e[20]=s.chunks,e[21]=s.error,e[22]=s.status,e[23]=d):d=e[23],d};function K(){}export{w as useHttpStream};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as M}from"react/compiler-runtime";import{useRef as R,useEffect as y}from"react";import{u as C}from"./use-paginated-core-CWfn4qb4.mjs";const v=(x,c,N)=>{const e=M(16),{initialNumItems:s}=N,{error:u,loadMore:o,pageResults:m,status:a}=C(x,c==="skip"?"skip":c,N),P=c==="skip";let t;if(e[0]!==m){t=[];for(const f of m)f&&t.push(f.page);e[0]=m,e[1]=t}else t=e[1];let i;e[2]!==s||e[3]!==o?(i={defaultNumItems:s,loadMore:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const h=R(i);let n;e[5]!==s||e[6]!==o?(n=()=>{h.current={defaultNumItems:s,loadMore:o}},e[5]=s,e[6]=o,e[7]=n):n=e[7],y(n);let r;e[8]===Symbol.for("react.memo_cache_sentinel")?(r=f=>{const{defaultNumItems:k,loadMore:L}=h.current;L(f??k)},e[8]=r):r=e[8];const I=r,d=a==="CanLoadMore",p=!P&&a==="LoadingMore",g=!P&&a==="LoadingFirstPage";let l;return e[9]!==u||e[10]!==t||e[11]!==a||e[12]!==d||e[13]!==p||e[14]!==g?(l={error:u,fetchNextPage:I,hasNextPage:d,isFetchingNextPage:p,isLoading:g,pages:t,status:a},e[9]=u,e[10]=t,e[11]=a,e[12]=d,e[13]=p,e[14]=g,e[15]=l):l=e[15],l};export{v as default};
2
+ import{c as M}from"react/compiler-runtime";import{useRef as R,useEffect as y}from"react";import{u as C}from"./use-paginated-core-CZ3gyax5.mjs";const v=(x,c,N)=>{const e=M(16),{initialNumItems:s}=N,{error:u,loadMore:o,pageResults:m,status:a}=C(x,c==="skip"?"skip":c,N),P=c==="skip";let t;if(e[0]!==m){t=[];for(const f of m)f&&t.push(f.page);e[0]=m,e[1]=t}else t=e[1];let i;e[2]!==s||e[3]!==o?(i={defaultNumItems:s,loadMore:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const h=R(i);let n;e[5]!==s||e[6]!==o?(n=()=>{h.current={defaultNumItems:s,loadMore:o}},e[5]=s,e[6]=o,e[7]=n):n=e[7],y(n);let r;e[8]===Symbol.for("react.memo_cache_sentinel")?(r=f=>{const{defaultNumItems:k,loadMore:L}=h.current;L(f??k)},e[8]=r):r=e[8];const I=r,d=a==="CanLoadMore",p=!P&&a==="LoadingMore",g=!P&&a==="LoadingFirstPage";let l;return e[9]!==u||e[10]!==t||e[11]!==a||e[12]!==d||e[13]!==p||e[14]!==g?(l={error:u,fetchNextPage:I,hasNextPage:d,isFetchingNextPage:p,isLoading:g,pages:t,status:a},e[9]=u,e[10]=t,e[11]=a,e[12]=d,e[13]=p,e[14]=g,e[15]=l):l=e[15],l};export{v as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c}from"react/compiler-runtime";import{u as f}from"./use-paginated-core-CWfn4qb4.mjs";const L=(d,i,l)=>{const e=c(8),{error:r,loadMore:p,pageResults:n,status:t}=f(d,i==="skip"?"skip":i,l);let s;if(e[0]!==n){s=[];for(const u of n)u&&s.push(...u.page);e[0]=n,e[1]=s}else s=e[1];const a=!(i==="skip")&&(t==="LoadingFirstPage"||t==="LoadingMore");let o;return e[2]!==r||e[3]!==p||e[4]!==s||e[5]!==t||e[6]!==a?(o={error:r,isLoading:a,loadMore:p,results:s,status:t},e[2]=r,e[3]=p,e[4]=s,e[5]=t,e[6]=a,e[7]=o):o=e[7],o};export{L as usePaginatedQuery};
2
+ import{c}from"react/compiler-runtime";import{u as f}from"./use-paginated-core-CZ3gyax5.mjs";const L=(d,i,l)=>{const e=c(8),{error:r,loadMore:p,pageResults:n,status:t}=f(d,i==="skip"?"skip":i,l);let s;if(e[0]!==n){s=[];for(const u of n)u&&s.push(...u.page);e[0]=n,e[1]=s}else s=e[1];const a=!(i==="skip")&&(t==="LoadingFirstPage"||t==="LoadingMore");let o;return e[2]!==r||e[3]!==p||e[4]!==s||e[5]!==t||e[6]!==a?(o={error:r,isLoading:a,loadMore:p,results:s,status:t},e[2]=r,e[3]=p,e[4]=s,e[5]=t,e[6]=a,e[7]=o):o=e[7],o};export{L as usePaginatedQuery};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useQueryClient as h,useQuery as E}from"@tanstack/react-query";import{useRef as b,useEffect as n,useCallback as g,useState as I}from"react";import{g as k}from"./cache-DmbajSjf.mjs";import{useLunora as q}from"./LunoraProvider-DC06S-p1.mjs";import{l as K,s as C}from"./query-key-C6iUhRuD.mjs";const F=(t,i,p={})=>{const e=q(),y=h(),{onError:c,shardKey:s}=p,d=b(c);n(()=>{d.current=c});const l=g(m=>{d.current?.(m)},[]),r=i==="skip",o=r?{}:i,a=K(t,o,s),[u,f]=I(e.isReady);n(()=>{u||e.whenReady().then(()=>{f(!0)})},[e,u]);const Q=r?void 0:e.peekHydratedQuery(t.__lunoraRef,o,s),{data:R}=E({enabled:!r&&u,initialData:Q,queryFn:()=>e.query(t,o,{shardKey:s}),queryKey:a,staleTime:Number.POSITIVE_INFINITY});return n(()=>r?()=>{}:k(e).attach(y,a,t,o,s,{onError:l}),[e,y,C(a),r,l]),r?void 0:R};export{F as default};
2
+ import{useQueryClient as h,useQuery as E}from"@tanstack/react-query";import{useRef as b,useEffect as n,useCallback as g,useState as I}from"react";import{g as k}from"./cache-BSBhN-M2.mjs";import{useLunora as q}from"./LunoraProvider-DC06S-p1.mjs";import{l as K,s as C}from"./query-key-BFaqaQy8.mjs";const F=(t,i,p={})=>{const e=q(),y=h(),{onError:c,shardKey:s}=p,d=b(c);n(()=>{d.current=c});const l=g(m=>{d.current?.(m)},[]),r=i==="skip",o=r?{}:i,a=K(t,o,s),[u,f]=I(e.isReady);n(()=>{u||e.whenReady().then(()=>{f(!0)})},[e,u]);const Q=r?void 0:e.peekHydratedQuery(t.__lunoraRef,o,s),{data:R}=E({enabled:!r&&u,initialData:Q,queryFn:()=>e.query(t,o,{shardKey:s}),queryKey:a,staleTime:Number.POSITIVE_INFINITY});return n(()=>r?()=>{}:k(e).attach(y,a,t,o,s,{onError:l}),[e,y,C(a),r,l]),r?void 0:R};export{F as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as K}from"react/compiler-runtime";import{useReducer as B,useRef as R,useEffect as _}from"react";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{s as E}from"./wire-key-L5JSXhhG.mjs";const A=(u,a,l)=>{const e=K(27);let c;e[0]!==l?(c=l===void 0?{}:l,e[0]=l,e[1]=c):c=e[1];const r=c,o=v();let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={chunks:[],error:void 0,status:"idle"},e[2]=f):f=e[2];const[t,m]=B(S,f),s=a==="skip";let n;e[3]!==a||e[4]!==s?(n=s?"skip":E(a),e[3]=a,e[4]=s,e[5]=n):n=e[5];const y=n,b=R(void 0);let i;e[6]!==a||e[7]!==o||e[8]!==u||e[9]!==r.durable||e[10]!==r.maxBuffer||e[11]!==r.shardKey||e[12]!==s?(i=()=>{if(s)return m({type:"reset"}),L;m({type:"reset"}),m({type:"start"});const{cancel:k,cleanup:x}=z(o.stream(u,a,{durable:r.durable,maxBuffer:r.maxBuffer,shardKey:r.shardKey}),m);return b.current=k,()=>{x(),b.current=void 0}},e[6]=a,e[7]=o,e[8]=u,e[9]=r.durable,e[10]=r.maxBuffer,e[11]=r.shardKey,e[12]=s,e[13]=i):i=e[13];let d;e[14]!==o||e[15]!==u.__lunoraRef||e[16]!==r.durable||e[17]!==r.maxBuffer||e[18]!==r.shardKey||e[19]!==y||e[20]!==s?(d=[o,u.__lunoraRef,y,s,r.shardKey,r.maxBuffer,r.durable],e[14]=o,e[15]=u.__lunoraRef,e[16]=r.durable,e[17]=r.maxBuffer,e[18]=r.shardKey,e[19]=y,e[20]=s,e[21]=d):d=e[21],_(i,d);let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{b.current?.()},e[22]=p):p=e[22];let h;return e[23]!==t.chunks||e[24]!==t.error||e[25]!==t.status?(h={cancel:p,chunks:t.chunks,error:t.error,status:t.status},e[23]=t.chunks,e[24]=t.error,e[25]=t.status,e[26]=h):h=e[26],h};function L(){}export{A as useStream};
2
+ import{c as K}from"react/compiler-runtime";import{useReducer as B,useRef as R,useEffect as _}from"react";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{s as E}from"./wire-key-DhthMX_1.mjs";const A=(u,a,l)=>{const e=K(27);let c;e[0]!==l?(c=l===void 0?{}:l,e[0]=l,e[1]=c):c=e[1];const r=c,o=v();let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={chunks:[],error:void 0,status:"idle"},e[2]=f):f=e[2];const[t,m]=B(S,f),s=a==="skip";let n;e[3]!==a||e[4]!==s?(n=s?"skip":E(a),e[3]=a,e[4]=s,e[5]=n):n=e[5];const y=n,b=R(void 0);let i;e[6]!==a||e[7]!==o||e[8]!==u||e[9]!==r.durable||e[10]!==r.maxBuffer||e[11]!==r.shardKey||e[12]!==s?(i=()=>{if(s)return m({type:"reset"}),L;m({type:"reset"}),m({type:"start"});const{cancel:k,cleanup:x}=z(o.stream(u,a,{durable:r.durable,maxBuffer:r.maxBuffer,shardKey:r.shardKey}),m);return b.current=k,()=>{x(),b.current=void 0}},e[6]=a,e[7]=o,e[8]=u,e[9]=r.durable,e[10]=r.maxBuffer,e[11]=r.shardKey,e[12]=s,e[13]=i):i=e[13];let d;e[14]!==o||e[15]!==u.__lunoraRef||e[16]!==r.durable||e[17]!==r.maxBuffer||e[18]!==r.shardKey||e[19]!==y||e[20]!==s?(d=[o,u.__lunoraRef,y,s,r.shardKey,r.maxBuffer,r.durable],e[14]=o,e[15]=u.__lunoraRef,e[16]=r.durable,e[17]=r.maxBuffer,e[18]=r.shardKey,e[19]=y,e[20]=s,e[21]=d):d=e[21],_(i,d);let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{b.current?.()},e[22]=p):p=e[22];let h;return e[23]!==t.chunks||e[24]!==t.error||e[25]!==t.status?(h={cancel:p,chunks:t.chunks,error:t.error,status:t.status},e[23]=t.chunks,e[24]=t.error,e[25]=t.status,e[26]=h):h=e[26],h};function L(){}export{A as useStream};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as x}from"react/compiler-runtime";import{createQuerySubscription as A}from"@lunora/client/query";import{LunoraError as D}from"@lunora/errors";import{useState as F,useRef as S,useEffect as v}from"react";import{useLunora as M}from"./LunoraProvider-DC06S-p1.mjs";import{s as Q}from"./wire-key-L5JSXhhG.mjs";const H=(o,r,a)=>{const e=x(24);let l;e[0]!==a?(l=a===void 0?{}:a,e[0]=a,e[1]=l):l=e[1];const t=l,n=M();let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={data:void 0,error:void 0},e[2]=c):c=e[2];const[k,E]=F(c),s=r==="skip";let d;e[3]!==r||e[4]!==s?(d=s?"skip":Q(r),e[3]=r,e[4]=s,e[5]=d):d=e[5];const b=d,K=S(t.onError);let f;e[6]!==t.onError?(f=()=>{K.current=t.onError},e[6]=t.onError,e[7]=f):f=e[7],v(f);let u;e[8]!==r||e[9]!==o?(u={args:r,fn:o},e[8]=r,e[9]=o,e[10]=u):u=e[10];const R=S(u);let m;e[11]!==r||e[12]!==o?(m=()=>{R.current={args:r,fn:o}},e[11]=r,e[12]=o,e[13]=m):m=e[13],v(m);let p;e[14]!==n||e[15]!==t.shardKey||e[16]!==s?(p=()=>{if(s)return E({data:void 0,error:void 0}),W;let h=!1;const{args:w,fn:z}=R.current,L=A(n,z,w,{onData:i=>{h||E({data:i,error:void 0})},onError:i=>{const q=i.code===void 0?new Error(i.message):new D(i.code,i.message);K.current?.(i),queueMicrotask(()=>{h||E({data:void 0,error:q})})}},{shardKey:t.shardKey});return()=>{h=!0,L()}},e[14]=n,e[15]=t.shardKey,e[16]=s,e[17]=p):p=e[17];let y;return e[18]!==n||e[19]!==o.__lunoraRef||e[20]!==t.shardKey||e[21]!==b||e[22]!==s?(y=[n,o.__lunoraRef,b,t.shardKey,s],e[18]=n,e[19]=o.__lunoraRef,e[20]=t.shardKey,e[21]=b,e[22]=s,e[23]=y):y=e[23],v(p,y),k};function W(){}export{H as default};
2
+ import{c as x}from"react/compiler-runtime";import{createQuerySubscription as A}from"@lunora/client/query";import{LunoraError as D}from"@lunora/errors";import{useState as F,useRef as S,useEffect as v}from"react";import{useLunora as M}from"./LunoraProvider-DC06S-p1.mjs";import{s as Q}from"./wire-key-DhthMX_1.mjs";const H=(o,r,a)=>{const e=x(24);let l;e[0]!==a?(l=a===void 0?{}:a,e[0]=a,e[1]=l):l=e[1];const t=l,n=M();let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={data:void 0,error:void 0},e[2]=c):c=e[2];const[k,E]=F(c),s=r==="skip";let d;e[3]!==r||e[4]!==s?(d=s?"skip":Q(r),e[3]=r,e[4]=s,e[5]=d):d=e[5];const b=d,K=S(t.onError);let f;e[6]!==t.onError?(f=()=>{K.current=t.onError},e[6]=t.onError,e[7]=f):f=e[7],v(f);let u;e[8]!==r||e[9]!==o?(u={args:r,fn:o},e[8]=r,e[9]=o,e[10]=u):u=e[10];const R=S(u);let m;e[11]!==r||e[12]!==o?(m=()=>{R.current={args:r,fn:o}},e[11]=r,e[12]=o,e[13]=m):m=e[13],v(m);let p;e[14]!==n||e[15]!==t.shardKey||e[16]!==s?(p=()=>{if(s)return E({data:void 0,error:void 0}),W;let h=!1;const{args:w,fn:z}=R.current,L=A(n,z,w,{onData:i=>{h||E({data:i,error:void 0})},onError:i=>{const q=i.code===void 0?new Error(i.message):new D(i.code,i.message);K.current?.(i),queueMicrotask(()=>{h||E({data:void 0,error:q})})}},{shardKey:t.shardKey});return()=>{h=!0,L()}},e[14]=n,e[15]=t.shardKey,e[16]=s,e[17]=p):p=e[17];let y;return e[18]!==n||e[19]!==o.__lunoraRef||e[20]!==t.shardKey||e[21]!==b||e[22]!==s?(y=[n,o.__lunoraRef,b,t.shardKey,s],e[18]=n,e[19]=o.__lunoraRef,e[20]=t.shardKey,e[21]=b,e[22]=s,e[23]=y):y=e[23],v(p,y),k};function W(){}export{H as default};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{useState as T,useRef as W,useCallback as y,useEffect as G}from"react";import{useLunora as X}from"./LunoraProvider-DC06S-p1.mjs";const N="/_lunora/ws",j="/_lunora/voice/",z=4001,O=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 O(e);if(r.endsWith(N))return r.slice(0,-N.length);try{return new URL(r).origin}catch{return O(e)}},Z=e=>{const r=Y(e.httpUrl,e.wsUrl),o=r.endsWith("/")?r.slice(0,-1):r,i=new URLSearchParams({threadKey:e.threadKey});return`${o}${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,o)=>{const i=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==i&&o(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 o of e)r+=o*o;return Math.sqrt(r/e.length)},oe=(e,r)=>{const o=r/ne,i=o>1?Math.floor(e.length/o):e.length,d=new ArrayBuffer(i*2),l=new DataView(d);for(let u=0;u<i;u+=1){const g=e[Math.floor(u*o)]??0,p=Math.max(-1,Math.min(1,g));l.setInt16(u*2,p<0?p*32768:p*32767,!0)}return new Uint8Array(d)},se=async e=>{const r=globalThis,o=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),i=r.AudioContext??r.webkitAudioContext;if(!o||!i)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await o({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new i,u=l.createMediaStreamSource(d),g=l.createScriptProcessor(4096,1,1);let p=!1,w=!1,a=0,h=0;return g.onaudioprocess=s=>{const f=s.inputBuffer.getChannelData(0),m=p?0:re(f);if(e.onLevel(m),p)return;if(e.onAudio(oe(f,l.sampleRate)),e.isTurnActive()){h=m>=e.interruptThreshold?h+1:0,h>=e.interruptChunks&&(h=0,e.onInterrupt());return}h=0;const x=f.length/l.sampleRate*1e3;if(m>=e.silenceThreshold){w=!0,a=0;return}w&&(a+=x,a>=e.silenceDurationMs&&(w=!1,a=0,e.onSilence()))},u.connect(g),g.connect(l.destination),{setMuted:s=>{p=s},stop:()=>{g.disconnect(),u.disconnect();for(const s of d.getTracks())s.stop();l.close()}}},ce=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const o=new r,i=new Set;let d=0,l=Promise.resolve(),u=0;const g=async(a,h)=>{if(h!==u)return;let s;try{s=await o.decodeAudioData(a.buffer)}catch{return}if(h!==u)return;const f=o.createBufferSource();f.buffer=s,f.connect(o.destination);const m=Math.max(o.currentTime,d);f.start(m),d=m+s.duration,i.add(f),f.onended=()=>{i.delete(f)}},p=a=>{const h=Uint8Array.from(a),s=u;l=l.then(()=>g(h,s))},w=()=>{u+=1;for(const a of i)try{a.stop()}catch{}i.clear(),d=o.currentTime};return{enqueue:p,interrupt:w,stop:()=>{w(),o.close()}}},P=1,ie=.01,ae=1200,ue=.15,le=3,he=e=>{const{createMicrophone:r=se,createSpeaker:o=ce,createSocket:i,interruptChunks:d=le,interruptThreshold:l=ue,silenceDurationMs:u=ae,silenceThreshold:g=ie,threadKey:p,voice:w}=e,a=X(),[h,s]=T("idle"),[f,m]=T(!1),[x,M]=T(""),[H,b]=T(""),[$,R]=T(0),[I,U]=T(!1),[B,E]=T(void 0),c=W(void 0),_=W(!1),v=y(t=>{const n=c.current?.socket;return n?.readyState===P?(n.send(JSON.stringify(t)),!0):!1},[]),A=y(()=>{const t=c.current;if(c.current=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{}}_.current=!1,m(!1),s("idle"),R(0)},[]),L=y(t=>{const n=c.current;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),s("speaking"),b(F=>F+t.text);break}case"assistant_done":{n&&(n.awaitingTurn=!1,n.speaking=!1),b(t.text),s("listening");break}case"error":{n&&(n.awaitingTurn=!1,n.speaking=!1),E(new Error(t.message)),s("listening");break}case"interrupted":{n&&(n.awaitingTurn=!1,n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),s("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),m(!0),s("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),M(t.text),b(""),s("thinking");break}}},[]),D=y(t=>{const n=c.current;!n||n.suppressAudio||(n.speaker??=o({audioFormat:n.audioFormat}),n.speaking=!0,s("speaking"),n.speaker.enqueue(t))},[o]),q=y(async()=>{if(c.current||_.current)return;_.current=!0,E(void 0),M(""),b("");let t;try{const n=Z({agent:Q(w.__lunoraRef),httpUrl:a.url,threadKey:p,wsUrl:a.wsUrl}),S=(i??(k=>{const C=a.getWebSocketImpl();if(!C)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new C(k)}))(n);S.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:S,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},c.current=t,t.unwatchIdentity=te(a,"useVoiceAgent",k=>{c.current===t&&(E(k),A())}),S.onmessage=k=>{if(typeof k.data=="string"){try{L(JSON.parse(k.data))}catch{}return}D(new Uint8Array(k.data))},S.onerror=()=>{E(new Error("useVoiceAgent: voice socket error"))},S.onclose=k=>{if(c.current!==t)return;const C=ee("useVoiceAgent",k);C&&E(C),A()};const V=await r({interruptChunks:d,interruptThreshold:l,isTurnActive:()=>(c.current?.speaking??!1)||(c.current?.awaitingTurn??!1),onAudio:k=>{S.readyState===P&&S.send(k)},onInterrupt:()=>{v({type:"interrupt"}),c.current?.speaker?.interrupt(),c.current&&(c.current.awaitingTurn=!1,c.current.speaking=!1,c.current.suppressAudio=!0),s("listening")},onLevel:R,onSilence:()=>{v({type:"commit"}),c.current&&(c.current.awaitingTurn=!0),s("thinking")},silenceDurationMs:u,silenceThreshold:g});c.current===t?(t.microphone=V,U(!1),t.speaking||s("listening")):V.stop()}catch(n){c.current===t&&(E(n instanceof Error?n:new Error(String(n))),A())}finally{_.current=!1}},[a,r,i,D,L,d,l,v,u,g,A,p,w]),K=y(()=>{const t=!I;return c.current?.microphone?.setMuted(t),U(t),t},[I]),J=y(t=>{v({text:t,type:"text"})&&(c.current&&(c.current.awaitingTurn=!0),s("thinking"))},[v]);return G(()=>A,[A]),{audioLevel:$,connected:f,endCall:A,error:B,interimTranscript:H,isMuted:I,sendText:J,startCall:q,status:h,toggleMute:K,transcript:x}};export{he as useVoiceAgent};
@@ -0,0 +1 @@
1
+ import{s as p}from"./stable-key-B_BlboiY.mjs";const y=r=>{let n="";for(let c=0;c<r.length;c+=32768)n+=String.fromCharCode(...r.subarray(c,c+32768));return btoa(n)},t="$lunora.wire$",d=64,m="__proto__",g=r=>{if(r===null||typeof r!="object")return!1;const n=Object.getPrototypeOf(r);return n===null||n===Object.prototype},i=(r,n=0)=>{if(n>d)throw new RangeError(`wire-codec: value nesting exceeds the ${d}-level limit`);if(r===void 0)return[t,"undefined"];if(r===null)return null;const a=typeof r;if(a==="bigint")return[t,"bigint",r.toString()];if(a==="number"){const e=r;return Number.isNaN(e)?[t,"nan"]:e===1/0?[t,"inf"]:e===-1/0?[t,"-inf"]:e}if(a!=="object")return r;if(r instanceof Date)return[t,"date",i(r.getTime(),n+1)];if(r instanceof Error){const e=r,o={};for(const f of Object.keys(e)){if(e[f]===void 0)continue;const b=i(e[f],n+1);f===m?Object.defineProperty(o,f,{configurable:!0,enumerable:!0,value:b,writable:!0}):o[f]=b}const s=[t,"error",e.name,e.message,o];return e.cause!==void 0&&s.push(i(e.cause,n+1)),s}if(r instanceof URL)return[t,"url",r.href];if(r instanceof Map)return[t,"map",[...r.entries()].map(([e,o])=>[i(e,n+1),i(o,n+1)])];if(r instanceof Set)return[t,"set",[...r].map(e=>i(e,n+1))];if(r instanceof ArrayBuffer)return[t,"bytes",y(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const e=r,o=e.constructor.name,s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return o==="Uint8Array"?[t,"bytes",y(s)]:[t,"bytes",y(s),o]}if(Array.isArray(r)){const e=r.map(o=>i(o,n+1));return e.length>0&&e[0]===t?[t,"arr",e]:e}if(!g(r)){const e=r.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 c=r,u={};for(const e of Object.keys(c)){const o=c[e];if(o===void 0)continue;const s=i(o,n+1);e===m?Object.defineProperty(u,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):u[e]=s}return u},l=r=>p(i(r));export{l as s};
package/dist/server.mjs CHANGED
@@ -1 +1 @@
1
- import{createServerClient as o}from"@lunora/client/ssr";import{createServerClient as K,deserializePreloaded as f,getServerSession as Q,serializePreloaded as x}from"@lunora/client/ssr";import{l as d}from"./packem_shared/query-key-C6iUhRuD.mjs";import{lunoraQueryOptions as S}from"./packem_shared/lunoraQueryOptions-B5PEocLy.mjs";import{preloadQuery as v,preloadedQueryResult as N}from"@lunora/client";import{HydrationBoundary as T,dehydrate as g}from"@tanstack/react-query";const u=async(r,a,e,t,y={})=>{const s=t??{};await r.prefetchQuery({queryFn:()=>a.query(e,s,{shardKey:y.shardKey}),queryKey:d(e,s,y.shardKey),staleTime:Number.POSITIVE_INFINITY})},h=async(r,a,e,t={})=>o(r).query(a,e,{shardKey:t.shardKey}),i=async(r,a,e,t={})=>o(r).mutation(a,e,{shardKey:t.shardKey}),l=async(r,a,e,t={})=>o(r).action(a,e,{shardKey:t.shardKey});export{T as HydrationBoundary,K as createServerClient,g as dehydrate,f as deserializePreloaded,l as fetchAction,i as fetchMutation,h as fetchQuery,Q as getServerSession,S as lunoraQueryOptions,u as prefetchQuery,v as preloadQuery,N as preloadedQueryResult,x as serializePreloaded};
1
+ import{createServerClient as o}from"@lunora/client/ssr";import{createServerClient as K,deserializePreloaded as f,getServerSession as Q,serializePreloaded as x}from"@lunora/client/ssr";import{l as d}from"./packem_shared/query-key-BFaqaQy8.mjs";import{lunoraQueryOptions as S}from"./packem_shared/lunoraQueryOptions-Celdopal.mjs";import{preloadQuery as v,preloadedQueryResult as N}from"@lunora/client";import{HydrationBoundary as T,dehydrate as g}from"@tanstack/react-query";const u=async(r,a,e,t,y={})=>{const s=t??{};await r.prefetchQuery({queryFn:()=>a.query(e,s,{shardKey:y.shardKey}),queryKey:d(e,s,y.shardKey),staleTime:Number.POSITIVE_INFINITY})},h=async(r,a,e,t={})=>o(r).query(a,e,{shardKey:t.shardKey}),i=async(r,a,e,t={})=>o(r).mutation(a,e,{shardKey:t.shardKey}),l=async(r,a,e,t={})=>o(r).action(a,e,{shardKey:t.shardKey});export{T as HydrationBoundary,K as createServerClient,g as dehydrate,f as deserializePreloaded,l as fetchAction,i as fetchMutation,h as fetchQuery,Q as getServerSession,S as lunoraQueryOptions,u as prefetchQuery,v as preloadQuery,N as preloadedQueryResult,x as serializePreloaded};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/react",
3
- "version": "1.0.0-alpha.82",
3
+ "version": "1.0.0-alpha.84",
4
4
  "description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -57,9 +57,9 @@
57
57
  "access": "public"
58
58
  },
59
59
  "dependencies": {
60
- "@lunora/client": "1.0.0-alpha.76",
61
- "@lunora/errors": "1.0.0-alpha.31",
62
- "@lunora/ratelimit": "1.0.0-alpha.38",
60
+ "@lunora/client": "1.0.0-alpha.79",
61
+ "@lunora/errors": "1.0.0-alpha.32",
62
+ "@lunora/ratelimit": "1.0.0-alpha.39",
63
63
  "@visulima/storage-client": "1.0.2"
64
64
  },
65
65
  "peerDependencies": {
@@ -1 +0,0 @@
1
- import{k as u}from"./query-key-C6iUhRuD.mjs";class g{constructor(e){this.client=e}client;entries=new Map;keyOf(e){return u(e)}attach(e,c,f,b,h,k={}){const s=u(c);let r=this.entries.get(s);if(!r){r={errorCallbacks:new Set,refCount:0,unsubscribe:void 0},this.entries.set(s,r);const t=r;try{r.unsubscribe=this.client.subscribe(f,b,n=>{e.setQueryData(c,n)},{onError:n=>{for(const d of t.errorCallbacks)d(n)},shardKey:h})}catch(n){throw this.entries.delete(s),n}}r.refCount+=1;const{onError:o}=k;o&&r.errorCallbacks.add(o);let a=!1;return()=>{if(a)return;a=!0;const t=this.entries.get(s);t&&(t.refCount-=1,o&&t.errorCallbacks.delete(o),t.refCount<=0&&(t.unsubscribe?.(),this.entries.delete(s)))}}}const l=new WeakMap,C=i=>{let e=l.get(i);return e||(e=new g(i),l.set(i,e)),e};export{C as g};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{initialPages as x,rebalance as N,derivePaginationStatus as D,applyLoadMore as T}from"@lunora/client/pagination";import{useQueryClient as B}from"@tanstack/react-query";import{useRef as m,useReducer as G,useState as F,useEffect as y,useCallback as J}from"react";import{g as U}from"./cache-DmbajSjf.mjs";import{useLunora as V}from"./LunoraProvider-DC06S-p1.mjs";import{s as u,l as v}from"./query-key-C6iUhRuD.mjs";const W=function(i){const l=m(void 0);return l.current??=i(),l},te=function(i,l,C){const f=V(),c=B(),{initialNumItems:R,shardKey:p}=C,d=l==="skip",g=d?{}:l,[,O]=G(e=>e+1,0),[q,h]=F(()=>x(R)),[z,k]=F(void 0),w=m(C.onError);y(()=>{w.current=C.onError});const Q=`${u(v(i,g,p))}::${String(R)}`,A=m(Q);A.current!==Q&&(A.current=Q,h(x(R)),k(void 0));const K=q.map(e=>{const t={...g,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},r=v(i,t,p);return{args:t,key:r}}),P=K.map(({key:e})=>u(e)).join("|"),b=m({baseArgs:g,entries:[],fn:i,shardKey:p});y(()=>{b.current={baseArgs:g,entries:K,fn:i,shardKey:p}});const L=(e,t,r)=>{k(r),h(o=>{const s=b.current,n=o.at(-1);if(o.length<=1||!n||c.getQueryData(t)!==void 0)return o;const S={...s.baseArgs,paginationOpts:{cursor:n.lower,endCursor:n.upper,numItems:n.numItems}};return u(v(s.fn,S,s.shardKey))===e?o.slice(0,-1):o}),w.current?.(r)},E=W(()=>new Map),M=m(f);y(()=>{const e=E.current;if(M.current!==f){for(const s of e.values())s();e.clear(),M.current=f}if(d){for(const s of e.values())s();e.clear();return}const t=b.current,r=U(f),o=new Set(t.entries.map(({key:s})=>u(s)));for(const[s,n]of e)o.has(s)||(n(),e.delete(s));for(const s of t.entries){const n=u(s.key);if(e.has(n))continue;c.fetchQuery({queryFn:()=>f.query(t.fn,s.args,{shardKey:t.shardKey}),queryKey:s.key,staleTime:0}).catch(a=>{L(n,s.key,a instanceof Error?{code:a.code,message:a.message}:{message:String(a)})}),e.set(n,r.attach(c,s.key,t.fn,s.args,t.shardKey,{onError:a=>{L(n,s.key,a)}}))}},[f,c,P,d]),y(()=>()=>{for(const e of E.current.values())e();E.current.clear()},[]),y(()=>c.getQueryCache().subscribe(r=>{if(r.type!=="updated")return;const o=u(r.query.queryKey);K.some(({key:s})=>u(s)===o)&&(k(void 0),O())}),[c,P]);const I=d?[]:K.map(({key:e})=>c.getQueryData(e));y(()=>{if(d)return;const e=N(q,I);e&&h(e)});const{status:$}=D(d,I),j=J(e=>{k(void 0),h(t=>{const r=b.current,o=t.map(a=>{const H={...r.baseArgs,paginationOpts:{cursor:a.lower,endCursor:a.upper,numItems:a.numItems}};return c.getQueryData(v(r.fn,H,r.shardKey))}),{nextCursor:s,status:n}=D(!1,o);return T(t,n==="CanLoadMore"?s:void 0,e)??t})},[c]);return{error:z,loadMore:j,pageResults:I,status:$}};export{te as u};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as A}from"react/compiler-runtime";import{useMutation as v,useQuery as z,keepPreviousData as I}from"@tanstack/react-query";import{useState as _,useSyncExternalStore as b}from"react";import{useLunora as y}from"./LunoraProvider-DC06S-p1.mjs";const D="lunora-react-admin-auth",E=50;function S(t,e,r,u={}){const{enabled:a=!0,pageSize:c=E}=u,[i,s]=_(c),l=b(g=>t.onAuthTokenChange(g),()=>t.currentIdentity(),()=>t.currentIdentity()),n=[D,l??"anon",...e,i],o=z({enabled:a,placeholderData:I,queryFn:()=>r(i),queryKey:n,staleTime:0}),d=o.data?.rows,f=o.data?.total,m=f!==void 0&&d!==void 0&&d.length<f,h=()=>{m&&s(g=>g+c)},p=()=>{o.refetch().catch(()=>{})};return{data:d,error:o.error??void 0,hasMore:m,loadMore:h,loading:o.isLoading,refetch:p,total:f}}const M=t=>{const e=A(20);let r;e[0]!==t?(r=t===void 0?{}:t,e[0]=t,e[1]=r):r=e[1];const u=r,a=y(),{enabled:c,filterField:i,filterValue:s,pageSize:l,search:n,searchField:o,sortBy:d,sortDirection:f}=u;let m;e[2]!==i||e[3]!==s||e[4]!==n||e[5]!==o||e[6]!==d||e[7]!==f?(m=["users",{filterField:i,filterValue:s,search:n,searchField:o,sortBy:d,sortDirection:f}],e[2]=i,e[3]=s,e[4]=n,e[5]=o,e[6]=d,e[7]=f,e[8]=m):m=e[8];let h;e[9]!==a||e[10]!==i||e[11]!==s||e[12]!==n||e[13]!==o||e[14]!==d||e[15]!==f?(h=g=>a.listAuthUsers({filterField:i,filterValue:s,limit:g,search:n,searchField:o,sortBy:d,sortDirection:f}),e[9]=a,e[10]=i,e[11]=s,e[12]=n,e[13]=o,e[14]=d,e[15]=f,e[16]=h):h=e[16];let p;return e[17]!==c||e[18]!==l?(p={enabled:c,pageSize:l},e[17]=c,e[18]=l,e[19]=p):p=e[19],S(a,m,h,p)},T=t=>{const e=A(8);let r;e[0]!==t?(r=t===void 0?{}:t,e[0]=t,e[1]=r):r=e[1];const u=r,a=y(),{enabled:c,pageSize:i}=u;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=["organizations"],e[2]=s):s=e[2];let l;e[3]!==a?(l=o=>a.listAuthOrganizations({limit:o}),e[3]=a,e[4]=l):l=e[4];let n;return e[5]!==c||e[6]!==i?(n={enabled:c,pageSize:i},e[5]=c,e[6]=i,e[7]=n):n=e[7],S(a,s,l,n)},$=t=>{const e=A(10);let r;e[0]!==t?(r=t===void 0?{}:t,e[0]=t,e[1]=r):r=e[1];const u=r,a=y(),{enabled:c,pageSize:i,userId:s}=u;let l;e[2]!==s?(l=["sessions",{userId:s}],e[2]=s,e[3]=l):l=e[3];let n;e[4]!==a||e[5]!==s?(n=d=>a.listAuthSessions({limit:d,userId:s}),e[4]=a,e[5]=s,e[6]=n):n=e[6];let o;return e[7]!==c||e[8]!==i?(o={enabled:c,pageSize:i},e[7]=c,e[8]=i,e[9]=o):o=e[9],S(a,l,n,o)},q=()=>{const t=A(10),e=y();let r;t[0]!==e?(r={mutationFn:o=>e.impersonateAuthUser({userId:o})},t[0]=e,t[1]=r):r=t[1];const u=v(r),{mutateAsync:a,reset:c}=u;let i;t[2]!==a?(i=o=>a(o),t[2]=a,t[3]=i):i=t[3];const s=i,l=u.error??void 0;let n;return t[4]!==s||t[5]!==u.data||t[6]!==u.isPending||t[7]!==c||t[8]!==l?(n={data:u.data,error:l,impersonate:s,pending:u.isPending,reset:c},t[4]=s,t[5]=u.data,t[6]=u.isPending,t[7]=c,t[8]=l,t[9]=n):n=t[9],n};export{$ as useAuthSessions,M as useAuthUsers,q as useImpersonate,T as useOrganizations};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as S}from"react/compiler-runtime";import{useReducer as _,useRef as v,useEffect as R}from"react";import{useLunora as b}from"./LunoraProvider-DC06S-p1.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{s as H}from"./stable-key-B_BlboiY.mjs";const C=(t,c,o)=>{const e=S(24);let m;e[0]!==o?(m=o===void 0?{}:o,e[0]=o,e[1]=m):m=e[1];const f=m,n=b();let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={chunks:[],error:void 0,status:"idle"},e[2]=i):i=e[2];const[s,a]=_(z,i),r=c==="skip";let l;e[3]!==c||e[4]!==r?(l=r?"skip":H(c),e[3]=c,e[4]=r,e[5]=l):l=e[5];const k=l,x=v(void 0);let u;e[6]!==c||e[7]!==n||e[8]!==f.maxBuffer||e[9]!==t||e[10]!==r?(u=()=>{if(r)return a({type:"reset"}),L;a({type:"reset"}),a({type:"start"});const{cancel:B,cleanup:y}=E(n.httpStream(t,c,{maxBuffer:f.maxBuffer}),a);return x.current=B,()=>{y(),x.current=void 0}},e[6]=c,e[7]=n,e[8]=f.maxBuffer,e[9]=t,e[10]=r,e[11]=u):u=e[11];let p;e[12]!==n||e[13]!==f.maxBuffer||e[14]!==t.method||e[15]!==t.path||e[16]!==k||e[17]!==r?(p=[n,t.method,t.path,k,r,f.maxBuffer],e[12]=n,e[13]=f.maxBuffer,e[14]=t.method,e[15]=t.path,e[16]=k,e[17]=r,e[18]=p):p=e[18],R(u,p);let h;e[19]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{x.current?.()},e[19]=h):h=e[19];let d;return e[20]!==s.chunks||e[21]!==s.error||e[22]!==s.status?(d={cancel:h,chunks:s.chunks,error:s.error,status:s.status},e[20]=s.chunks,e[21]=s.error,e[22]=s.status,e[23]=d):d=e[23],d};function L(){}export{C as useHttpStream};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{useState as w,useRef as N,useCallback as E,useEffect as G}from"react";import{useLunora as X}from"./LunoraProvider-DC06S-p1.mjs";const O="/_lunora/ws",j="/_lunora/voice/",z=4001,P=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,Q=e=>{const n=e.startsWith("agents:")?e.slice(7):e;return n.endsWith("Voice")?n.slice(0,-5):n},Y=(e,n)=>{if(n===void 0||n==="")return P(e);if(n.endsWith(O))return n.slice(0,-O.length);try{return new URL(n).origin}catch{return P(e)}},Z=e=>{const n=Y(e.httpUrl,e.wsUrl),s=n.endsWith("/")?n.slice(0,-1):n,i=new URLSearchParams({threadKey:e.threadKey});return`${s}${j}${encodeURIComponent(e.agent)}?${i.toString()}`},ee=(e,n)=>{if(n?.code===z)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},te=16e3,ne=e=>{if(e.length===0)return 0;let n=0;for(const s of e)n+=s*s;return Math.sqrt(n/e.length)},re=(e,n)=>{const s=n/te,i=s>1?Math.floor(e.length/s):e.length,d=new ArrayBuffer(i*2),l=new DataView(d);for(let a=0;a<i;a+=1){const k=e[Math.floor(a*s)]??0,p=Math.max(-1,Math.min(1,k));l.setInt16(a*2,p<0?p*32768:p*32767,!0)}return new Uint8Array(d)},oe=async e=>{const n=globalThis,s=n.navigator?.mediaDevices?.getUserMedia.bind(n.navigator.mediaDevices),i=n.AudioContext??n.webkitAudioContext;if(!s||!i)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new i,a=l.createMediaStreamSource(d),k=l.createScriptProcessor(4096,1,1);let p=!1,g=!1,u=0,h=0;return k.onaudioprocess=o=>{const f=o.inputBuffer.getChannelData(0),m=p?0:ne(f);if(e.onLevel(m),p)return;if(e.onAudio(re(f,l.sampleRate)),e.isSpeaking()){h=m>=e.interruptThreshold?h+1:0,h>=e.interruptChunks&&(h=0,e.onInterrupt());return}h=0;const x=f.length/l.sampleRate*1e3;if(m>=e.silenceThreshold){g=!0,u=0;return}g&&(u+=x,u>=e.silenceDurationMs&&(g=!1,u=0,e.onSilence()))},a.connect(k),k.connect(l.destination),{setMuted:o=>{p=o},stop:()=>{k.disconnect(),a.disconnect();for(const o of d.getTracks())o.stop();l.close()}}},se=()=>{const e=globalThis,n=e.AudioContext??e.webkitAudioContext;if(!n)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new n,i=new Set;let d=0,l=Promise.resolve(),a=0;const k=async(u,h)=>{if(h!==a)return;let o;try{o=await s.decodeAudioData(u.buffer)}catch{return}if(h!==a)return;const f=s.createBufferSource();f.buffer=o,f.connect(s.destination);const m=Math.max(s.currentTime,d);f.start(m),d=m+o.duration,i.add(f),f.onended=()=>{i.delete(f)}},p=u=>{const h=Uint8Array.from(u),o=a;l=l.then(()=>k(h,o))},g=()=>{a+=1;for(const u of i)try{u.stop()}catch{}i.clear(),d=s.currentTime};return{enqueue:p,interrupt:g,stop:()=>{g(),s.close()}}},V=1,ce=.01,ie=1200,ae=.15,ue=3,pe=e=>{const{createMicrophone:n=oe,createSpeaker:s=se,createSocket:i,interruptChunks:d=ue,interruptThreshold:l=ae,silenceDurationMs:a=ie,silenceThreshold:k=ce,threadKey:p,voice:g}=e,u=X(),[h,o]=w("idle"),[f,m]=w(!1),[x,R]=w(""),[H,v]=w(""),[$,U]=w(0),[M,L]=w(!1),[B,C]=w(void 0),c=N(void 0),_=N(!1),T=E(t=>{const r=c.current?.socket;return r?.readyState===V?(r.send(JSON.stringify(t)),!0):!1},[]),y=E(()=>{const t=c.current;if(c.current=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{}}_.current=!1,m(!1),o("idle"),U(0)},[]),D=E(t=>{const r=c.current;switch(t.type){case"assistant_delta":{r&&(r.speaking=!0),o("speaking"),v(F=>F+t.text);break}case"assistant_done":{r&&(r.speaking=!1),v(t.text),o("listening");break}case"error":{r&&(r.speaking=!1),C(new Error(t.message)),o("listening");break}case"interrupted":{r&&(r.speaking=!1,r.suppressAudio=!1),r?.speaker?.interrupt(),o("listening");break}case"ready":{r&&(r.audioFormat=t.audioFormat,r.suppressAudio=!1),m(!0),o("listening");break}case"user_transcript":{r&&(r.suppressAudio=!1),R(t.text),v(""),o("thinking");break}}},[]),I=E(t=>{const r=c.current;!r||r.suppressAudio||(r.speaker??=s({audioFormat:r.audioFormat}),r.speaking=!0,o("speaking"),r.speaker.enqueue(t))},[s]),q=E(async()=>{if(c.current||_.current)return;_.current=!0,C(void 0),R(""),v("");let t;try{const r=Z({agent:Q(g.__lunoraRef),httpUrl:u.url,threadKey:p,wsUrl:u.wsUrl}),A=(i??(S=>{const b=u.getWebSocketImpl();if(!b)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new b(S)}))(r);A.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:A,speaker:void 0,speaking:!1,suppressAudio:!1},c.current=t,A.onmessage=S=>{if(typeof S.data=="string"){try{D(JSON.parse(S.data))}catch{}return}I(new Uint8Array(S.data))},A.onerror=()=>{C(new Error("useVoiceAgent: voice socket error"))},A.onclose=S=>{if(c.current!==t)return;const b=ee("useVoiceAgent",S);b&&C(b),y()};const W=await n({interruptChunks:d,interruptThreshold:l,isSpeaking:()=>c.current?.speaking??!1,onAudio:S=>{A.readyState===V&&A.send(S)},onInterrupt:()=>{T({type:"interrupt"}),c.current?.speaker?.interrupt(),c.current&&(c.current.speaking=!1,c.current.suppressAudio=!0),o("listening")},onLevel:U,onSilence:()=>{T({type:"commit"}),o("thinking")},silenceDurationMs:a,silenceThreshold:k});c.current===t?(t.microphone=W,L(!1),t.speaking||o("listening")):W.stop()}catch(r){c.current===t&&(C(r instanceof Error?r:new Error(String(r))),y())}finally{_.current=!1}},[u,n,i,I,D,d,l,T,a,k,y,p,g]),K=E(()=>{const t=!M;return c.current?.microphone?.setMuted(t),L(t),t},[M]),J=E(t=>{T({text:t,type:"text"})&&o("thinking")},[T]);return G(()=>y,[y]),{audioLevel:$,connected:f,endCall:y,error:B,interimTranscript:H,isMuted:M,sendText:J,startCall:q,status:h,toggleMute:K,transcript:x}};export{pe as useVoiceAgent};
@@ -1 +0,0 @@
1
- import{s as d}from"./stable-key-B_BlboiY.mjs";const u=r=>{let t="";for(let c=0;c<r.length;c+=32768)t+=String.fromCharCode(...r.subarray(c,c+32768));return btoa(t)},e="$lunora.wire$",b=64,m="__proto__",p=r=>{if(r===null||typeof r!="object")return!1;const t=Object.getPrototypeOf(r);return t===null||t===Object.prototype},i=(r,t=0)=>{if(t>b)throw new RangeError(`wire-codec: value nesting exceeds the ${b}-level limit`);if(r===void 0)return[e,"undefined"];if(r===null)return null;const f=typeof r;if(f==="bigint")return[e,"bigint",r.toString()];if(f==="number"){const n=r;return Number.isNaN(n)?[e,"nan"]:n===1/0?[e,"inf"]:n===-1/0?[e,"-inf"]:n}if(f!=="object")return r;if(r instanceof Date)return[e,"date",i(r.getTime(),t+1)];if(r instanceof Error){const n=r,o={};for(const y of Object.keys(n))n[y]!==void 0&&(o[y]=i(n[y],t+1));const s=[e,"error",n.name,n.message,o];return n.cause!==void 0&&s.push(i(n.cause,t+1)),s}if(r instanceof URL)return[e,"url",r.href];if(r instanceof Map)return[e,"map",[...r.entries()].map(([n,o])=>[i(n,t+1),i(o,t+1)])];if(r instanceof Set)return[e,"set",[...r].map(n=>i(n,t+1))];if(r instanceof ArrayBuffer)return[e,"bytes",u(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const n=r,o=n.constructor.name,s=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);return o==="Uint8Array"?[e,"bytes",u(s)]:[e,"bytes",u(s),o]}if(Array.isArray(r)){const n=r.map(o=>i(o,t+1));return n.length>0&&n[0]===e?[e,"arr",n]:n}if(!p(r)){const n=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${n} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const c=r,a={};for(const n of Object.keys(c)){const o=c[n];if(o===void 0)continue;const s=i(o,t+1);n===m?Object.defineProperty(a,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):a[n]=s}return a},w=r=>d(i(r));export{w as s};