@lunora/react 1.0.0-alpha.303 → 1.0.0-alpha.304

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -470,11 +470,12 @@ interface UseAgentResult {
470
470
  declare const useAgent: (options: UseAgentOptions) => UseAgentResult;
471
471
  /**
472
472
  * One human-in-the-loop approval a run is paused on, on a thread the caller
473
- * owns. Carries the triple `agents.agentResolveApproval` takes, so a UI can
474
- * approve or reject straight from the list.
473
+ * owns. Carries the ids `agents.agentResolveApproval` takes, `approvalSlot`
474
+ * included, so a UI can hand an item straight to `useAgentChat`'s `approve` or `reject`.
475
475
  */
476
476
  interface PendingApproval {
477
477
  agent: string;
478
+ approvalSlot: string;
478
479
  content: string;
479
480
  instanceId: string;
480
481
  requestedAt: number;
@@ -524,6 +525,8 @@ declare const useAgentApprovals: (options: UseAgentApprovalsOptions) => UseAgent
524
525
  * table in `packages/agent/src/component.ts`.
525
526
  */
526
527
  interface AgentChatMessage {
528
+ /** On an `awaiting_approval` message: the slot its run waits under, which a decision must name. */
529
+ approvalSlot?: string;
527
530
  content: string;
528
531
  createdAt?: number;
529
532
  /**
@@ -588,6 +591,7 @@ type AgentMessagesReference$1 = FunctionReference<"query", {
588
591
  }, ReadonlyArray<Record<string, unknown>>>;
589
592
  /** The `agents:agentResolveApproval` reference — resolves a human-in-the-loop tool approval. */
590
593
  type AgentApprovalReference = FunctionReference<"mutation", {
594
+ approvalSlot: string;
591
595
  decision: "approve" | "approve_for_thread" | "reject";
592
596
  instanceId: string;
593
597
  note?: string;
@@ -596,6 +600,11 @@ type AgentApprovalReference = FunctionReference<"mutation", {
596
600
  }, {
597
601
  resolved: boolean;
598
602
  }>;
603
+ /**
604
+ * The pending approval a decision answers: its `awaiting_approval` message, its `awaiting-approval` tool event or its
605
+ * inbox item. A provider can reuse a tool-call id in a later turn, so a decision names the approval's slot as well.
606
+ */
607
+ type AgentApprovalTarget = Pick<AgentChatMessage, "approvalSlot" | "toolCallId">;
599
608
  /** The `agents:agentSupplySecret` reference — stores a person's value for a paused `requestSecretTool` call. */
600
609
  type AgentSupplySecretReference = FunctionReference<"mutation", {
601
610
  secret: string;
@@ -694,12 +703,12 @@ interface UseAgentChatResult {
694
703
  /** The tools approved for the rest of this thread, live. Empty until the grants subscription answers. */
695
704
  approvalGrants: ReadonlyArray<AgentApprovalGrant>;
696
705
  /** Approve a paused human-in-the-loop tool call (optionally with a note). */
697
- approve: (toolCallId: string, note?: string) => Promise<void>;
706
+ approve: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
698
707
  /**
699
708
  * Approve a paused tool call and grant that tool for the rest of the thread, so
700
709
  * later calls to it run without pausing. Undo with {@link UseAgentChatResult.revokeGrant}.
701
710
  */
702
- approveForThread: (toolCallId: string, note?: string) => Promise<void>;
711
+ approveForThread: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
703
712
  /**
704
713
  * Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
705
714
  * no-op when no `cancel` mutation was supplied or no run is in flight.
@@ -712,7 +721,7 @@ interface UseAgentChatResult {
712
721
  /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
713
722
  messages: ReadonlyArray<AgentChatMessage>;
714
723
  /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
715
- reject: (toolCallId: string, note?: string) => Promise<void>;
724
+ reject: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
716
725
  /** Remove a thread-scoped approval grant so the tool's gate applies again to later calls. */
717
726
  revokeGrant: (toolName: string) => Promise<void>;
718
727
  /** Start (or continue) a run with a user message; extra args merge over `sendArgs`. Appends an optimistic user turn. */
@@ -854,6 +863,7 @@ type AgentToolEvent = {
854
863
  toolName?: string;
855
864
  type: "result";
856
865
  } | {
866
+ approvalSlot?: string;
857
867
  seq: number;
858
868
  toolCallId?: string;
859
869
  toolName?: string;
@@ -1566,4 +1576,4 @@ interface UseVoiceAgentResult {
1566
1576
  * `createSocket`) so the hook is drivable outside a browser.
1567
1577
  */
1568
1578
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
1569
- export { type ActionHook, type AdminAuthListResult, type AgentApprovalGrant, 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, type PendingApproval, Unauthenticated, type UseAgentApi, type UseAgentApprovalsApi, type UseAgentApprovalsOptions, type UseAgentApprovalsResult, 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 UseLiveTopicOptions, type UseLiveTopicResult, 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, useAgentApprovals, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLiveTopic, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useSuspenseQuery, useVoiceAgent };
1579
+ export { type ActionHook, type AdminAuthListResult, type AgentApprovalGrant, type AgentApprovalTarget, 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, type PendingApproval, Unauthenticated, type UseAgentApi, type UseAgentApprovalsApi, type UseAgentApprovalsOptions, type UseAgentApprovalsResult, 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 UseLiveTopicOptions, type UseLiveTopicResult, 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, useAgentApprovals, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLiveTopic, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useSuspenseQuery, useVoiceAgent };
package/dist/index.d.ts CHANGED
@@ -470,11 +470,12 @@ interface UseAgentResult {
470
470
  declare const useAgent: (options: UseAgentOptions) => UseAgentResult;
471
471
  /**
472
472
  * One human-in-the-loop approval a run is paused on, on a thread the caller
473
- * owns. Carries the triple `agents.agentResolveApproval` takes, so a UI can
474
- * approve or reject straight from the list.
473
+ * owns. Carries the ids `agents.agentResolveApproval` takes, `approvalSlot`
474
+ * included, so a UI can hand an item straight to `useAgentChat`'s `approve` or `reject`.
475
475
  */
476
476
  interface PendingApproval {
477
477
  agent: string;
478
+ approvalSlot: string;
478
479
  content: string;
479
480
  instanceId: string;
480
481
  requestedAt: number;
@@ -524,6 +525,8 @@ declare const useAgentApprovals: (options: UseAgentApprovalsOptions) => UseAgent
524
525
  * table in `packages/agent/src/component.ts`.
525
526
  */
526
527
  interface AgentChatMessage {
528
+ /** On an `awaiting_approval` message: the slot its run waits under, which a decision must name. */
529
+ approvalSlot?: string;
527
530
  content: string;
528
531
  createdAt?: number;
529
532
  /**
@@ -588,6 +591,7 @@ type AgentMessagesReference$1 = FunctionReference<"query", {
588
591
  }, ReadonlyArray<Record<string, unknown>>>;
589
592
  /** The `agents:agentResolveApproval` reference — resolves a human-in-the-loop tool approval. */
590
593
  type AgentApprovalReference = FunctionReference<"mutation", {
594
+ approvalSlot: string;
591
595
  decision: "approve" | "approve_for_thread" | "reject";
592
596
  instanceId: string;
593
597
  note?: string;
@@ -596,6 +600,11 @@ type AgentApprovalReference = FunctionReference<"mutation", {
596
600
  }, {
597
601
  resolved: boolean;
598
602
  }>;
603
+ /**
604
+ * The pending approval a decision answers: its `awaiting_approval` message, its `awaiting-approval` tool event or its
605
+ * inbox item. A provider can reuse a tool-call id in a later turn, so a decision names the approval's slot as well.
606
+ */
607
+ type AgentApprovalTarget = Pick<AgentChatMessage, "approvalSlot" | "toolCallId">;
599
608
  /** The `agents:agentSupplySecret` reference — stores a person's value for a paused `requestSecretTool` call. */
600
609
  type AgentSupplySecretReference = FunctionReference<"mutation", {
601
610
  secret: string;
@@ -694,12 +703,12 @@ interface UseAgentChatResult {
694
703
  /** The tools approved for the rest of this thread, live. Empty until the grants subscription answers. */
695
704
  approvalGrants: ReadonlyArray<AgentApprovalGrant>;
696
705
  /** Approve a paused human-in-the-loop tool call (optionally with a note). */
697
- approve: (toolCallId: string, note?: string) => Promise<void>;
706
+ approve: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
698
707
  /**
699
708
  * Approve a paused tool call and grant that tool for the rest of the thread, so
700
709
  * later calls to it run without pausing. Undo with {@link UseAgentChatResult.revokeGrant}.
701
710
  */
702
- approveForThread: (toolCallId: string, note?: string) => Promise<void>;
711
+ approveForThread: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
703
712
  /**
704
713
  * Terminate the in-flight run and mark its thread `"cancelled"`. Resolves as a
705
714
  * no-op when no `cancel` mutation was supplied or no run is in flight.
@@ -712,7 +721,7 @@ interface UseAgentChatResult {
712
721
  /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
713
722
  messages: ReadonlyArray<AgentChatMessage>;
714
723
  /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
715
- reject: (toolCallId: string, note?: string) => Promise<void>;
724
+ reject: (approval: AgentApprovalTarget, note?: string) => Promise<void>;
716
725
  /** Remove a thread-scoped approval grant so the tool's gate applies again to later calls. */
717
726
  revokeGrant: (toolName: string) => Promise<void>;
718
727
  /** Start (or continue) a run with a user message; extra args merge over `sendArgs`. Appends an optimistic user turn. */
@@ -854,6 +863,7 @@ type AgentToolEvent = {
854
863
  toolName?: string;
855
864
  type: "result";
856
865
  } | {
866
+ approvalSlot?: string;
857
867
  seq: number;
858
868
  toolCallId?: string;
859
869
  toolName?: string;
@@ -1566,4 +1576,4 @@ interface UseVoiceAgentResult {
1566
1576
  * `createSocket`) so the hook is drivable outside a browser.
1567
1577
  */
1568
1578
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
1569
- export { type ActionHook, type AdminAuthListResult, type AgentApprovalGrant, 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, type PendingApproval, Unauthenticated, type UseAgentApi, type UseAgentApprovalsApi, type UseAgentApprovalsOptions, type UseAgentApprovalsResult, 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 UseLiveTopicOptions, type UseLiveTopicResult, 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, useAgentApprovals, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLiveTopic, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useSuspenseQuery, useVoiceAgent };
1579
+ export { type ActionHook, type AdminAuthListResult, type AgentApprovalGrant, type AgentApprovalTarget, 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, type PendingApproval, Unauthenticated, type UseAgentApi, type UseAgentApprovalsApi, type UseAgentApprovalsOptions, type UseAgentApprovalsResult, 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 UseLiveTopicOptions, type UseLiveTopicResult, 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, useAgentApprovals, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLiveTopic, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useSuspenseQuery, 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-DgQHaQD5.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-DZhCIjSA.mjs";import{L as f,u as n}from"./packem_shared/lunora-provider-BMJTPKMP.mjs";import{useAction as m}from"./packem_shared/useAction-BGTQyx5l.mjs";import{useAuthSessions as d,useAuthUsers as l,useImpersonate as A,useOrganizations as g,useSignUpInvitations as c}from"./packem_shared/useAuthSessions-Cv3RRW_S.mjs";import{useAgent as U}from"./packem_shared/useAgent-BW4uKe79.mjs";import{useAgentApprovals as S}from"./packem_shared/useAgentApprovals-VbOnL2Lx.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-DjLC2W3L.mjs";import{useAgentState as L}from"./packem_shared/useAgentState-CNZ5F4mc.mjs";import{useAgentToolEvents as v}from"./packem_shared/useAgentToolEvents-dndcx99y.mjs";import{default as F}from"./packem_shared/useAuth-C1_ruDmE.mjs";import{default as M}from"./packem_shared/useClientQuery-D-c8YM6Q.mjs";import{default as b}from"./packem_shared/useConnectionStatus-CAmQqRpD.mjs";import{useFlag as O,useFlags as k}from"./packem_shared/useFlag-CWjaNeAp.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-C-VR6P1E.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-BIkpHK0e.mjs";import{useLiveTopic as B}from"./packem_shared/useLiveTopic-Cp5b1ncm.mjs";import{useMutation as G}from"./packem_shared/useMutation-D6p61C2U.mjs";import{useMutator as K}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as W}from"./packem_shared/usePaginatedQuery-B7tBY2XC.mjs";import{hydratePreloaded as Y,usePreloadedQuery as Z}from"./packem_shared/hydratePreloaded-DbwkdExV.mjs";import{usePresence as $}from"./packem_shared/usePresence-dgOxESVW.mjs";import{default as re}from"./packem_shared/useQuery-DMSZbdFz.mjs";import{useRateLimit as te}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as se}from"./packem_shared/useStream-B_XzhM-6.mjs";import{default as pe}from"./packem_shared/useSubscription-CRqptgB_.mjs";import{default as ne}from"./packem_shared/useSuspenseQuery-B9DrM8Kw.mjs";import{useVoiceAgent as me}from"./packem_shared/useVoiceAgent-BHkPJWuv.mjs";import{createClientQuery as de,getErrorCode as le,getRetryAfterMs as Ae,isConflictError as ge,isForbiddenError as ce,isRateLimitedError as he,isUnauthorizedError as Ue}from"@lunora/client";import{lunoraQueryOptions as Se}from"@lunora/client/query";import{RestrictionError as Ee,UploadControl as Qe,UploadError as Le}from"@visulima/storage-client";import{useChunkedRestUpload as ve,useFileInput as Re,useMultipartUpload as Fe,usePasteUpload as Ie,useTusUpload as Me,useUpload as Te}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,Ee as RestrictionError,u as Unauthenticated,Qe as UploadControl,Le as UploadError,de as createClientQuery,le as getErrorCode,Ae as getRetryAfterMs,Y as hydratePreloaded,ge as isConflictError,ce as isForbiddenError,he as isRateLimitedError,Ue as isUnauthorizedError,Se as lunoraQueryOptions,m as useAction,U as useAgent,S as useAgentApprovals,E as useAgentChat,L as useAgentState,v as useAgentToolEvents,F as useAuth,d as useAuthSessions,a as useAuthState,l as useAuthUsers,ve as useChunkedRestUpload,M as useClientQuery,b as useConnectionStatus,Re as useFileInput,O as useFlag,k as useFlags,V as useHttpStream,A as useImpersonate,q as useInfiniteQuery,B as useLiveTopic,n as useLunora,Fe as useMultipartUpload,G as useMutation,K as useMutator,g as useOrganizations,W as usePaginatedQuery,Ie as usePasteUpload,Z as usePreloadedQuery,$ as usePresence,re as useQuery,te as useRateLimit,c as useSignUpInvitations,se as useStream,pe as useSubscription,ne as useSuspenseQuery,Me as useTusUpload,Te as useUpload,me as useVoiceAgent};
2
+ import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-DgQHaQD5.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-DZhCIjSA.mjs";import{L as f,u as n}from"./packem_shared/lunora-provider-BMJTPKMP.mjs";import{useAction as m}from"./packem_shared/useAction-BGTQyx5l.mjs";import{useAuthSessions as d,useAuthUsers as l,useImpersonate as A,useOrganizations as g,useSignUpInvitations as c}from"./packem_shared/useAuthSessions-Cv3RRW_S.mjs";import{useAgent as U}from"./packem_shared/useAgent-BW4uKe79.mjs";import{useAgentApprovals as S}from"./packem_shared/useAgentApprovals-VbOnL2Lx.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-Civzre-d.mjs";import{useAgentState as L}from"./packem_shared/useAgentState-CNZ5F4mc.mjs";import{useAgentToolEvents as v}from"./packem_shared/useAgentToolEvents-Bv7qTf29.mjs";import{default as F}from"./packem_shared/useAuth-C1_ruDmE.mjs";import{default as M}from"./packem_shared/useClientQuery-D-c8YM6Q.mjs";import{default as b}from"./packem_shared/useConnectionStatus-CAmQqRpD.mjs";import{useFlag as O,useFlags as k}from"./packem_shared/useFlag-CWjaNeAp.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-C-VR6P1E.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-BIkpHK0e.mjs";import{useLiveTopic as B}from"./packem_shared/useLiveTopic-Cp5b1ncm.mjs";import{useMutation as G}from"./packem_shared/useMutation-D6p61C2U.mjs";import{useMutator as K}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as W}from"./packem_shared/usePaginatedQuery-B7tBY2XC.mjs";import{hydratePreloaded as Y,usePreloadedQuery as Z}from"./packem_shared/hydratePreloaded-DbwkdExV.mjs";import{usePresence as $}from"./packem_shared/usePresence-dgOxESVW.mjs";import{default as re}from"./packem_shared/useQuery-DMSZbdFz.mjs";import{useRateLimit as te}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as se}from"./packem_shared/useStream-B_XzhM-6.mjs";import{default as pe}from"./packem_shared/useSubscription-CRqptgB_.mjs";import{default as ne}from"./packem_shared/useSuspenseQuery-B9DrM8Kw.mjs";import{useVoiceAgent as me}from"./packem_shared/useVoiceAgent-BHkPJWuv.mjs";import{createClientQuery as de,getErrorCode as le,getRetryAfterMs as Ae,isConflictError as ge,isForbiddenError as ce,isRateLimitedError as he,isUnauthorizedError as Ue}from"@lunora/client";import{lunoraQueryOptions as Se}from"@lunora/client/query";import{RestrictionError as Ee,UploadControl as Qe,UploadError as Le}from"@visulima/storage-client";import{useChunkedRestUpload as ve,useFileInput as Re,useMultipartUpload as Fe,usePasteUpload as Ie,useTusUpload as Me,useUpload as Te}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,Ee as RestrictionError,u as Unauthenticated,Qe as UploadControl,Le as UploadError,de as createClientQuery,le as getErrorCode,Ae as getRetryAfterMs,Y as hydratePreloaded,ge as isConflictError,ce as isForbiddenError,he as isRateLimitedError,Ue as isUnauthorizedError,Se as lunoraQueryOptions,m as useAction,U as useAgent,S as useAgentApprovals,E as useAgentChat,L as useAgentState,v as useAgentToolEvents,F as useAuth,d as useAuthSessions,a as useAuthState,l as useAuthUsers,ve as useChunkedRestUpload,M as useClientQuery,b as useConnectionStatus,Re as useFileInput,O as useFlag,k as useFlags,V as useHttpStream,A as useImpersonate,q as useInfiniteQuery,B as useLiveTopic,n as useLunora,Fe as useMultipartUpload,G as useMutation,K as useMutator,g as useOrganizations,W as usePaginatedQuery,Ie as usePasteUpload,Z as usePreloadedQuery,$ as usePresence,re as useQuery,te as useRateLimit,c as useSignUpInvitations,se as useStream,pe as useSubscription,ne as useSuspenseQuery,Me as useTusUpload,Te as useUpload,me as useVoiceAgent};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{reconcileOptimistic as A,maxSeq as R}from"@lunora/client";import{useState as nt,useRef as k}from"react";import{u as rt}from"./lunora-provider-BMJTPKMP.mjs";import{useMutation as c}from"./useMutation-D6p61C2U.mjs";import{useStream as at}from"./useStream-B_XzhM-6.mjs";import m from"./useSubscription-CRqptgB_.mjs";const ot={__lunoraRef:""},st={__lunoraRef:""},ct=[],it=[],Rt=E=>{const{api:r,cancel:g,limit:v,onError:u,send:w,sendArgs:_,stream:h,threadKey:e}=E,T=v===void 0?{key:e}:{key:e,limit:v},{data:I,error:C}=m(r.agents.agentMessages,T,{onError:u}),{data:x,error:G}=m(r.agents.agentThread,{key:e},{onError:u}),{data:O,error:b}=m(r.agents.agentApprovalGrants,{key:e},{onError:u}),D=h===void 0?"skip":{key:e},{chunks:j}=at(h??st,D),q=c(w),F=c(g??ot),N=c(r.agents.agentResolveApproval),K=c(r.agents.agentRevokeApprovalGrant),P=c(r.agents.agentDeclineSecret),Y=rt(),[$,p]=nt([]),f=k(0),y=k(e);y.current!==e&&(y.current=e,p([]));const S=x,L=S?.status,i=S?.instanceId,a=I??ct,M=A($,a),U=R(a),z=M.length===0?a:[...a,...M.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:U+1+n}))],B=a.filter(t=>t.role==="assistant").length,H=j.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=B).map(t=>t.text).join(""),{mutate:J}=q,{mutate:Q}=F,{mutate:V}=N,{mutate:W}=K,{mutate:X}=P,Z=async(t,n)=>{const s=f.current;f.current+=1;const l=R(a);p(o=>[...A(o,a),{content:t,id:s,maxDurableSeqAtSend:l}]);try{await J({input:t,threadKey:e,..._,...n})}catch(o){throw p(tt=>tt.filter(et=>et.id!==s)),o}},d=async(t,n,s)=>{if(i===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);const{approvalSlot:l,toolCallId:o}=n;if(l===void 0||o===void 0)throw new Error(`useAgentChat: cannot ${t} — pass the pending approval, which carries its toolCallId and approvalSlot`);await V({approvalSlot:l,decision:t,instanceId:i,threadKey:e,toolCallId:o,...s===void 0?{}:{note:s}})};return{approvalGrants:O??it,approve:(t,n)=>d("approve",t,n),approveForThread:(t,n)=>d("approve_for_thread",t,n),cancel:async()=>{g===void 0||i===void 0||await Q({instanceId:i,threadKey:e})},declineSecret:async t=>{await X({threadKey:e,toolCallId:t})},error:C??G??b,messages:z,reject:(t,n)=>d("reject",t,n),revokeGrant:async t=>{await W({threadKey:e,toolName:t})},send:Z,status:L,streamingText:H,supplySecret:async(t,n)=>{await Y.mutation(r.agents.agentSupplySecret,{secret:n,threadKey:e,toolCallId:t},{onlineOnly:!0})}}};export{Rt as useAgentChat};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as C}from"react/compiler-runtime";import{useStream as S}from"./useStream-B_XzhM-6.mjs";import y from"./useSubscription-CRqptgB_.mjs";const _={__lunoraRef:""},I=[],N={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},k=o=>{const t=o.status===void 0?void 0:N[o.status];if(t!==void 0)return{seq:o.seq,type:t,...o.approvalSlot===void 0?{}:{approvalSlot:o.approvalSlot},...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}},q=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(n=>({input:n.input,seq:o.seq,toolCallId:n.id,toolName:n.name,type:"call"}));if(o.role!=="tool")return;const t=k(o);return t!==void 0?[t]:[{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}}]},w=o=>{const t=C(12),{api:n,limit:e,stream:a,threadKey:l}=o;let i;t[0]!==e||t[1]!==l?(i=e===void 0?{key:l}:{key:l,limit:e},t[0]=e,t[1]=l,t[2]=i):i=t[2];const v=i,{data:f}=y(n.agents.agentMessages,v);let u;t[3]!==a||t[4]!==l?(u=a===void 0?"skip":{key:l},t[3]=a,t[4]=l,t[5]=u):u=t[5];const E=u,{chunks:s}=S(a??_,E),c=f??I;let r;if(t[6]!==s||t[7]!==c||t[8]!==l){r=c.flatMap(A);for(const d of s)d.kind==="progress"&&d.threadKey===l&&r.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});t[6]=s,t[7]=c,t[8]=l,t[9]=r}else r=t[9];let p;return t[10]!==r?(p={events:r},t[10]=r,t[11]=p):p=t[11],p};function A(o){return q(o)??[]}export{w as useAgentToolEvents};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/react",
3
- "version": "1.0.0-alpha.303",
3
+ "version": "1.0.0-alpha.304",
4
4
  "description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as nt,useRef as k}from"react";import{u as rt}from"./lunora-provider-BMJTPKMP.mjs";import{useMutation as s}from"./useMutation-D6p61C2U.mjs";import{useStream as at}from"./useStream-B_XzhM-6.mjs";import d from"./useSubscription-CRqptgB_.mjs";const ot={__lunoraRef:""},st={__lunoraRef:""},ct=[],it=[],kt=A=>{const{api:r,cancel:m,limit:g,onError:i,send:E,sendArgs:_,stream:v,threadKey:e}=A,T=g===void 0?{key:e}:{key:e,limit:g},{data:w,error:x}=d(r.agents.agentMessages,T,{onError:i}),{data:G,error:I}=d(r.agents.agentThread,{key:e},{onError:i}),{data:O,error:b}=d(r.agents.agentApprovalGrants,{key:e},{onError:i}),C=v===void 0?"skip":{key:e},{chunks:D}=at(v??st,C),j=s(E),q=s(m??ot),F=s(r.agents.agentResolveApproval),N=s(r.agents.agentRevokeApprovalGrant),K=s(r.agents.agentDeclineSecret),P=rt(),[Y,u]=nt([]),h=k(0),f=k(e);f.current!==e&&(f.current=e,u([]));const y=G,L=y?.status,c=y?.instanceId,a=w??ct,S=M(Y,a),U=R(a),$=S.length===0?a:[...a,...S.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:U+1+n}))],z=a.filter(t=>t.role==="assistant").length,B=D.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=z).map(t=>t.text).join(""),{mutate:H}=j,{mutate:J}=q,{mutate:Q}=F,{mutate:V}=N,{mutate:W}=K,X=async(t,n)=>{const o=h.current;h.current+=1;const Z=R(a);u(p=>[...M(p,a),{content:t,id:o,maxDurableSeqAtSend:Z}]);try{await H({input:t,threadKey:e,..._,...n})}catch(p){throw u(tt=>tt.filter(et=>et.id!==o)),p}},l=async(t,n,o)=>{if(c===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await Q({decision:t,instanceId:c,threadKey:e,toolCallId:n,...o===void 0?{}:{note:o}})};return{approvalGrants:O??it,approve:(t,n)=>l("approve",t,n),approveForThread:(t,n)=>l("approve_for_thread",t,n),cancel:async()=>{m===void 0||c===void 0||await J({instanceId:c,threadKey:e})},declineSecret:async t=>{await W({threadKey:e,toolCallId:t})},error:x??I??b,messages:$,reject:(t,n)=>l("reject",t,n),revokeGrant:async t=>{await V({threadKey:e,toolName:t})},send:X,status:L,streamingText:B,supplySecret:async(t,n)=>{await P.mutation(r.agents.agentSupplySecret,{secret:n,threadKey:e,toolCallId:t},{onlineOnly:!0})}}};export{kt as useAgentChat};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as C}from"react/compiler-runtime";import{useStream as y}from"./useStream-B_XzhM-6.mjs";import _ from"./useSubscription-CRqptgB_.mjs";const I={__lunoraRef:""},N=[],S={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},k=o=>{const t=o.status===void 0?void 0:S[o.status];if(t!==void 0)return{seq:o.seq,type:t,...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}},q=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(r=>({input:r.input,seq:o.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(o.role!=="tool")return;const t=k(o);return t!==void 0?[t]:[{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}}]},m=o=>{const t=C(12),{api:r,limit:n,stream:i,threadKey:l}=o;let a;t[0]!==n||t[1]!==l?(a=n===void 0?{key:l}:{key:l,limit:n},t[0]=n,t[1]=l,t[2]=a):a=t[2];const v=a,{data:f}=_(r.agents.agentMessages,v);let s;t[3]!==i||t[4]!==l?(s=i===void 0?"skip":{key:l},t[3]=i,t[4]=l,t[5]=s):s=t[5];const E=s,{chunks:p}=y(i??I,E),c=f??N;let e;if(t[6]!==p||t[7]!==c||t[8]!==l){e=c.flatMap(A);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]=c,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 A(o){return q(o)??[]}export{m as useAgentToolEvents};