@novu/react 3.19.1-rc.852194fa77 → 3.19.1
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/cjs/hooks/index.cjs +2 -2
- package/dist/cjs/hooks/index.cjs.map +1 -1
- package/dist/cjs/hooks/index.d.cts +1 -1
- package/dist/cjs/hooks/{useAgentChat.cjs → useWebChat.cjs} +79 -28
- package/dist/cjs/hooks/useWebChat.cjs.map +1 -0
- package/dist/cjs/hooks/useWebChat.d.cts +117 -0
- package/dist/cjs/index.cjs +4 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/server/index.cjs +6 -7
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/index.d.cts +3 -3
- package/dist/esm/hooks/index.d.ts +1 -1
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useWebChat.d.ts +117 -0
- package/dist/esm/hooks/{useAgentChat.js → useWebChat.js} +73 -23
- package/dist/esm/hooks/useWebChat.js.map +1 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/index.d.ts +3 -3
- package/dist/esm/server/index.js +4 -5
- package/dist/esm/server/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/cjs/hooks/useAgentChat.cjs.map +0 -1
- package/dist/cjs/hooks/useAgentChat.d.cts +0 -98
- package/dist/esm/hooks/useAgentChat.d.ts +0 -98
- package/dist/esm/hooks/useAgentChat.js.map +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { LoadConversationResult, NovuError, WebChatPlanLimitError, AgentMessage, AgentPendingAction, AgentEventEnvelope, AgentHashFields, AgentConversationRuntime, AgentConversationRunSnapshot, AgentConversationStatus, WebChatPagination, SendMessageInput, SendMessageResult, AgentToolApprovalDecision, RespondToActionResult, SendActionResult } from '@novu/js';
|
|
2
|
+
|
|
3
|
+
type UseWebChatCallbacks = {
|
|
4
|
+
onSuccess?: (data: LoadConversationResult) => void;
|
|
5
|
+
onError?: (error: NovuError | WebChatPlanLimitError) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Fires once when a message id first appears. History pages do not fire.
|
|
8
|
+
* The first event of a turn can create an empty assistant message before text arrives.
|
|
9
|
+
* A send that never reaches the server does not fire. The message status becomes `failed` instead.
|
|
10
|
+
*/
|
|
11
|
+
onMessage?: (message: AgentMessage) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Fires once per pending action, including actions still pending on mount.
|
|
14
|
+
* Paging backwards does not fire.
|
|
15
|
+
*/
|
|
16
|
+
onActionRequested?: (action: AgentPendingAction) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Live event envelopes for this conversation.
|
|
19
|
+
* Duplicates that the client drops do not fire.
|
|
20
|
+
* Envelopes that arrive before the conversation id exists do not fire.
|
|
21
|
+
* The message list in this render does not include this envelope yet.
|
|
22
|
+
*/
|
|
23
|
+
onEvent?: (envelope: AgentEventEnvelope) => void;
|
|
24
|
+
};
|
|
25
|
+
/** Arguments for {@link useWebChat}. Pass `agentId`, or pass `conversation`. Do not mix the two. */
|
|
26
|
+
type UseWebChatProps = UseWebChatCallbacks & AgentHashFields & ({
|
|
27
|
+
agentId: string;
|
|
28
|
+
/**
|
|
29
|
+
* Resume this conversation. The hook loads history on mount.
|
|
30
|
+
* Omit this prop to start a new chat. The first send creates a conversation.
|
|
31
|
+
*/
|
|
32
|
+
conversationId?: string;
|
|
33
|
+
conversation?: never;
|
|
34
|
+
} | {
|
|
35
|
+
/** Share an existing conversation runtime across multiple hook instances. */
|
|
36
|
+
conversation: AgentConversationRuntime;
|
|
37
|
+
agentId?: never;
|
|
38
|
+
conversationId?: never;
|
|
39
|
+
agentHash?: never;
|
|
40
|
+
});
|
|
41
|
+
/** State and actions returned by {@link useWebChat}. */
|
|
42
|
+
type UseWebChatResult = {
|
|
43
|
+
/** Conversation timeline. */
|
|
44
|
+
messages: AgentMessage[];
|
|
45
|
+
/** Tool approvals and MCP connect items that are still pending. */
|
|
46
|
+
pendingActions: AgentPendingAction[];
|
|
47
|
+
/** Server conversation id after create or resume. */
|
|
48
|
+
conversationId?: string;
|
|
49
|
+
/** Last error from load, send, retry, or action. */
|
|
50
|
+
error?: NovuError | WebChatPlanLimitError;
|
|
51
|
+
/** True while Web Chat loads and, for an existing conversation, until the first history fetch completes. */
|
|
52
|
+
isLoading: boolean;
|
|
53
|
+
/** True while the agent turn is in progress. Same as `run.isRunning`. */
|
|
54
|
+
isRunning: boolean;
|
|
55
|
+
/** Typing indicator. Same as `run.typing`. Absent when the agent is not typing. */
|
|
56
|
+
typing?: AgentConversationRunSnapshot['typing'];
|
|
57
|
+
/** `'active'` or `'resolved'`. The agent sets `resolved` with `ctx.resolve()`. Not a loading flag. */
|
|
58
|
+
conversationStatus: AgentConversationStatus;
|
|
59
|
+
/** Current agent-run snapshot. */
|
|
60
|
+
run: AgentConversationRunSnapshot;
|
|
61
|
+
/** Older-history control. Not a top-level `hasMore` or `fetchMore`. */
|
|
62
|
+
pagination: WebChatPagination & {
|
|
63
|
+
fetchMore: () => Promise<{
|
|
64
|
+
data?: {
|
|
65
|
+
messages: AgentMessage[];
|
|
66
|
+
hasMore: boolean;
|
|
67
|
+
};
|
|
68
|
+
error?: NovuError;
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
/** True while reconnect recovery is in progress. */
|
|
72
|
+
isRecovering: boolean;
|
|
73
|
+
/** Set when reconnect recovery fails. Separate from send and fetch `error`. */
|
|
74
|
+
catchUpError?: NovuError;
|
|
75
|
+
/** Reload the newest history page. No-op when there is no conversation id. */
|
|
76
|
+
refetch: () => Promise<void>;
|
|
77
|
+
/** Send a user message. `input` is a string, or `{ text, metadata }`. Creates a conversation when `conversationId` is omitted. */
|
|
78
|
+
sendMessage: (input: SendMessageInput) => Promise<{
|
|
79
|
+
data?: SendMessageResult;
|
|
80
|
+
error?: NovuError | WebChatPlanLimitError;
|
|
81
|
+
}>;
|
|
82
|
+
/** Resolve a pending `tool-approval`. Pass `action.id` from `pendingActions`. */
|
|
83
|
+
respondToAction: (args: {
|
|
84
|
+
actionId: string;
|
|
85
|
+
decision: AgentToolApprovalDecision;
|
|
86
|
+
}) => Promise<{
|
|
87
|
+
data?: RespondToActionResult;
|
|
88
|
+
error?: NovuError | WebChatPlanLimitError;
|
|
89
|
+
}>;
|
|
90
|
+
/** Click a Card button. Do not use this for tool approval. */
|
|
91
|
+
sendAction: (args: {
|
|
92
|
+
actionId: string;
|
|
93
|
+
sourceMessageId: string;
|
|
94
|
+
value?: string;
|
|
95
|
+
}) => Promise<{
|
|
96
|
+
data?: SendActionResult;
|
|
97
|
+
error?: NovuError | WebChatPlanLimitError;
|
|
98
|
+
}>;
|
|
99
|
+
/** Resend a message whose `status` is `failed`. Reuses the original idempotency key. */
|
|
100
|
+
retryMessage: (messageId: string) => Promise<{
|
|
101
|
+
data?: SendMessageResult;
|
|
102
|
+
error?: NovuError | WebChatPlanLimitError;
|
|
103
|
+
}>;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Headless Web Chat client. Use it inside `NovuProvider`.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* const { messages, sendMessage, isRunning, isLoading, error } = useWebChat({
|
|
111
|
+
* agentId: 'YOUR_AGENT_IDENTIFIER',
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare const useWebChat: (props: UseWebChatProps) => UseWebChatResult;
|
|
116
|
+
|
|
117
|
+
export { type UseWebChatProps, type UseWebChatResult, useWebChat };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// src/hooks/
|
|
2
|
-
import {
|
|
1
|
+
// src/hooks/useWebChat.ts
|
|
2
|
+
import { NovuError } from "@novu/js";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
4
|
import { useDataRef } from "./internal/useDataRef.js";
|
|
4
5
|
import { useNovu } from "./NovuProvider.js";
|
|
5
6
|
var EMPTY_SERVER_SNAPSHOT = {
|
|
6
7
|
key: "ssr",
|
|
7
|
-
status: "
|
|
8
|
+
status: "loading",
|
|
8
9
|
run: { isRunning: false },
|
|
9
10
|
conversationStatus: "active",
|
|
10
11
|
pagination: { hasMore: false, status: "idle" },
|
|
@@ -69,45 +70,87 @@ function getCreateFlowKey(agentId, agentHash) {
|
|
|
69
70
|
function resolveOwnedRuntime(args) {
|
|
70
71
|
const key = getCreateFlowKey(args.agentId, args.agentHash);
|
|
71
72
|
const current = args.ownedRuntimeRef.current;
|
|
72
|
-
if (current?.key === key) {
|
|
73
|
+
if (current?.novu === args.novu && current.key === key) {
|
|
73
74
|
return current.runtime;
|
|
74
75
|
}
|
|
75
76
|
current?.runtime.dispose();
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
const runtime = args.novu.webChat.conversation({ agentId: args.agentId, agentHash: args.agentHash });
|
|
78
|
+
args.ownedRuntimeRef.current = { key, novu: args.novu, runtime };
|
|
79
|
+
return runtime;
|
|
80
|
+
}
|
|
81
|
+
function toNovuError(error) {
|
|
82
|
+
if (error instanceof NovuError) {
|
|
83
|
+
return error;
|
|
84
|
+
}
|
|
85
|
+
if (error instanceof Error) {
|
|
86
|
+
return new NovuError("Failed to load Web Chat", error);
|
|
80
87
|
}
|
|
81
|
-
|
|
82
|
-
return result.data;
|
|
88
|
+
return new NovuError("Failed to load Web Chat", new Error(String(error)));
|
|
83
89
|
}
|
|
84
|
-
var
|
|
90
|
+
var useWebChat = (props) => {
|
|
85
91
|
const novu = useNovu();
|
|
86
92
|
const propsRef = useDataRef(props);
|
|
93
|
+
const [loadState, setLoadState] = useState(() => ({
|
|
94
|
+
novu,
|
|
95
|
+
status: "loading"
|
|
96
|
+
}));
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
let cancelled = false;
|
|
99
|
+
if (!novu.isWebChatLoaded) {
|
|
100
|
+
setLoadState({ novu, status: "loading" });
|
|
101
|
+
}
|
|
102
|
+
void novu.loadWebChat().then(() => {
|
|
103
|
+
if (!cancelled) {
|
|
104
|
+
setLoadState({ novu, status: "ready" });
|
|
105
|
+
}
|
|
106
|
+
}).catch((error) => {
|
|
107
|
+
if (cancelled) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const novuError = toNovuError(error);
|
|
111
|
+
propsRef.current.onError?.(novuError);
|
|
112
|
+
setLoadState({ novu, status: "error", error: novuError });
|
|
113
|
+
});
|
|
114
|
+
return () => {
|
|
115
|
+
cancelled = true;
|
|
116
|
+
};
|
|
117
|
+
}, [novu, propsRef]);
|
|
118
|
+
const webChatReady = loadState.novu === novu && loadState.status === "ready";
|
|
119
|
+
const webChatLoadError = loadState.novu === novu && loadState.status === "error" ? loadState.error : void 0;
|
|
120
|
+
const isWebChatLoading = loadState.novu !== novu || loadState.status === "loading";
|
|
87
121
|
const sharedRuntime = "conversation" in props ? props.conversation : void 0;
|
|
88
122
|
const agentId = sharedRuntime?.agentId ?? props.agentId;
|
|
89
123
|
const conversationIdProp = sharedRuntime ? void 0 : props.conversationId;
|
|
90
124
|
const agentHash = sharedRuntime ? void 0 : props.agentHash;
|
|
91
125
|
const ownedRuntimeRef = useRef(null);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
const current = ownedRuntimeRef.current;
|
|
128
|
+
if (current && current.novu !== novu) {
|
|
129
|
+
current.runtime.dispose();
|
|
130
|
+
ownedRuntimeRef.current = null;
|
|
131
|
+
}
|
|
132
|
+
}, [novu]);
|
|
92
133
|
const cachedRuntime = useMemo(() => {
|
|
134
|
+
if (!webChatReady) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
93
137
|
if (sharedRuntime) {
|
|
94
138
|
return sharedRuntime;
|
|
95
139
|
}
|
|
96
140
|
if (!conversationIdProp) {
|
|
97
141
|
return null;
|
|
98
142
|
}
|
|
99
|
-
|
|
143
|
+
return novu.webChat.conversation({
|
|
100
144
|
agentId,
|
|
101
145
|
conversationId: conversationIdProp,
|
|
102
146
|
agentHash
|
|
103
147
|
});
|
|
104
|
-
|
|
105
|
-
}, [sharedRuntime, novu, agentId, conversationIdProp, agentHash]);
|
|
148
|
+
}, [webChatReady, sharedRuntime, novu, agentId, conversationIdProp, agentHash]);
|
|
106
149
|
if (sharedRuntime || conversationIdProp) {
|
|
107
150
|
ownedRuntimeRef.current?.runtime.dispose();
|
|
108
151
|
ownedRuntimeRef.current = null;
|
|
109
152
|
}
|
|
110
|
-
const ownedRuntime = sharedRuntime || conversationIdProp ? null : resolveOwnedRuntime({ novu, agentId, agentHash, ownedRuntimeRef });
|
|
153
|
+
const ownedRuntime = !webChatReady || sharedRuntime || conversationIdProp ? null : resolveOwnedRuntime({ novu, agentId, agentHash, ownedRuntimeRef });
|
|
111
154
|
const runtime = sharedRuntime ?? cachedRuntime ?? ownedRuntime;
|
|
112
155
|
useEffect(() => {
|
|
113
156
|
return () => {
|
|
@@ -162,7 +205,12 @@ var useAgentChat = (props) => {
|
|
|
162
205
|
const callRuntime = useCallback(
|
|
163
206
|
async (action) => {
|
|
164
207
|
if (!runtime) {
|
|
165
|
-
|
|
208
|
+
const error = webChatLoadError ?? new NovuError(
|
|
209
|
+
isWebChatLoading ? "Web Chat is still loading" : "Web Chat runtime is unavailable",
|
|
210
|
+
new Error("Web Chat runtime is not ready")
|
|
211
|
+
);
|
|
212
|
+
propsRef.current.onError?.(error);
|
|
213
|
+
return { error };
|
|
166
214
|
}
|
|
167
215
|
const response = await action(runtime);
|
|
168
216
|
if (response.error) {
|
|
@@ -170,7 +218,7 @@ var useAgentChat = (props) => {
|
|
|
170
218
|
}
|
|
171
219
|
return response;
|
|
172
220
|
},
|
|
173
|
-
[runtime, propsRef]
|
|
221
|
+
[runtime, webChatLoadError, isWebChatLoading, propsRef]
|
|
174
222
|
);
|
|
175
223
|
const refetch = useCallback(async () => {
|
|
176
224
|
if (!runtime) {
|
|
@@ -204,7 +252,10 @@ var useAgentChat = (props) => {
|
|
|
204
252
|
}),
|
|
205
253
|
[snapshot.pagination.status, snapshot.pagination.hasMore, fetchMore]
|
|
206
254
|
);
|
|
207
|
-
const sendMessage = useCallback(
|
|
255
|
+
const sendMessage = useCallback(
|
|
256
|
+
(input) => callRuntime((target) => target.sendMessage(input)),
|
|
257
|
+
[callRuntime]
|
|
258
|
+
);
|
|
208
259
|
const respondToAction = useCallback(
|
|
209
260
|
(args) => callRuntime((target) => target.respondToAction(args)),
|
|
210
261
|
[callRuntime]
|
|
@@ -221,11 +272,10 @@ var useAgentChat = (props) => {
|
|
|
221
272
|
messages: [...snapshot.messages],
|
|
222
273
|
pendingActions: [...snapshot.pendingActions],
|
|
223
274
|
conversationId: snapshot.conversationId,
|
|
224
|
-
error: snapshot.error,
|
|
225
|
-
isLoading: snapshot.status === "loading",
|
|
275
|
+
error: webChatLoadError ?? snapshot.error,
|
|
276
|
+
isLoading: !webChatLoadError && (isWebChatLoading || snapshot.status === "loading"),
|
|
226
277
|
isRunning: snapshot.run.isRunning,
|
|
227
278
|
typing: snapshot.run.typing,
|
|
228
|
-
status: snapshot.conversationStatus,
|
|
229
279
|
conversationStatus: snapshot.conversationStatus,
|
|
230
280
|
run: snapshot.run,
|
|
231
281
|
pagination: paginationWithFetch,
|
|
@@ -239,6 +289,6 @@ var useAgentChat = (props) => {
|
|
|
239
289
|
};
|
|
240
290
|
};
|
|
241
291
|
export {
|
|
242
|
-
|
|
292
|
+
useWebChat
|
|
243
293
|
};
|
|
244
|
-
//# sourceMappingURL=
|
|
294
|
+
//# sourceMappingURL=useWebChat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useWebChat.ts"],"sourcesContent":["import type {\n AgentConversationPublicationMeta,\n AgentConversationRunSnapshot,\n AgentConversationRuntime,\n AgentConversationSnapshot,\n AgentConversationStatus,\n AgentEventEnvelope,\n AgentHashFields,\n AgentMessage,\n AgentPendingAction,\n AgentToolApprovalDecision,\n LoadConversationResult,\n RespondToActionResult,\n SendActionResult,\n SendMessageInput,\n SendMessageResult,\n WebChatPagination,\n WebChatPlanLimitError,\n} from '@novu/js';\nimport { NovuError } from '@novu/js';\nimport { type MutableRefObject, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport { useDataRef } from './internal/useDataRef';\nimport { useNovu } from './NovuProvider';\n\ntype UseWebChatCallbacks = {\n onSuccess?: (data: LoadConversationResult) => void;\n onError?: (error: NovuError | WebChatPlanLimitError) => void;\n /**\n * Fires once when a message id first appears. History pages do not fire.\n * The first event of a turn can create an empty assistant message before text arrives.\n * A send that never reaches the server does not fire. The message status becomes `failed` instead.\n */\n onMessage?: (message: AgentMessage) => void;\n /**\n * Fires once per pending action, including actions still pending on mount.\n * Paging backwards does not fire.\n */\n onActionRequested?: (action: AgentPendingAction) => void;\n /**\n * Live event envelopes for this conversation.\n * Duplicates that the client drops do not fire.\n * Envelopes that arrive before the conversation id exists do not fire.\n * The message list in this render does not include this envelope yet.\n */\n onEvent?: (envelope: AgentEventEnvelope) => void;\n};\n\n/** Arguments for {@link useWebChat}. Pass `agentId`, or pass `conversation`. Do not mix the two. */\nexport type UseWebChatProps = UseWebChatCallbacks &\n AgentHashFields &\n (\n | {\n agentId: string;\n /**\n * Resume this conversation. The hook loads history on mount.\n * Omit this prop to start a new chat. The first send creates a conversation.\n */\n conversationId?: string;\n conversation?: never;\n }\n | {\n /** Share an existing conversation runtime across multiple hook instances. */\n conversation: AgentConversationRuntime;\n agentId?: never;\n conversationId?: never;\n agentHash?: never;\n }\n );\n\n/** State and actions returned by {@link useWebChat}. */\nexport type UseWebChatResult = {\n /** Conversation timeline. */\n messages: AgentMessage[];\n /** Tool approvals and MCP connect items that are still pending. */\n pendingActions: AgentPendingAction[];\n /** Server conversation id after create or resume. */\n conversationId?: string;\n /** Last error from load, send, retry, or action. */\n error?: NovuError | WebChatPlanLimitError;\n /** True while Web Chat loads and, for an existing conversation, until the first history fetch completes. */\n isLoading: boolean;\n /** True while the agent turn is in progress. Same as `run.isRunning`. */\n isRunning: boolean;\n /** Typing indicator. Same as `run.typing`. Absent when the agent is not typing. */\n typing?: AgentConversationRunSnapshot['typing'];\n /** `'active'` or `'resolved'`. The agent sets `resolved` with `ctx.resolve()`. Not a loading flag. */\n conversationStatus: AgentConversationStatus;\n /** Current agent-run snapshot. */\n run: AgentConversationRunSnapshot;\n /** Older-history control. Not a top-level `hasMore` or `fetchMore`. */\n pagination: WebChatPagination & {\n fetchMore: () => Promise<{\n data?: { messages: AgentMessage[]; hasMore: boolean };\n error?: NovuError;\n }>;\n };\n /** True while reconnect recovery is in progress. */\n isRecovering: boolean;\n /** Set when reconnect recovery fails. Separate from send and fetch `error`. */\n catchUpError?: NovuError;\n /** Reload the newest history page. No-op when there is no conversation id. */\n refetch: () => Promise<void>;\n /** Send a user message. `input` is a string, or `{ text, metadata }`. Creates a conversation when `conversationId` is omitted. */\n sendMessage: (input: SendMessageInput) => Promise<{\n data?: SendMessageResult;\n error?: NovuError | WebChatPlanLimitError;\n }>;\n /** Resolve a pending `tool-approval`. Pass `action.id` from `pendingActions`. */\n respondToAction: (args: { actionId: string; decision: AgentToolApprovalDecision }) => Promise<{\n data?: RespondToActionResult;\n error?: NovuError | WebChatPlanLimitError;\n }>;\n /** Click a Card button. Do not use this for tool approval. */\n sendAction: (args: { actionId: string; sourceMessageId: string; value?: string }) => Promise<{\n data?: SendActionResult;\n error?: NovuError | WebChatPlanLimitError;\n }>;\n /** Resend a message whose `status` is `failed`. Reuses the original idempotency key. */\n retryMessage: (messageId: string) => Promise<{\n data?: SendMessageResult;\n error?: NovuError | WebChatPlanLimitError;\n }>;\n};\n\nconst EMPTY_SERVER_SNAPSHOT = {\n key: 'ssr',\n status: 'loading',\n run: { isRunning: false },\n conversationStatus: 'active',\n pagination: { hasMore: false, status: 'idle' },\n messages: [],\n pendingActions: [],\n isRecovering: false,\n} as AgentConversationSnapshot;\n\ntype RuntimeActionResult<T> = {\n data?: T;\n error?: NovuError | WebChatPlanLimitError;\n};\n\nfunction handlePublicationCallbacks(args: {\n snapshot: AgentConversationSnapshot;\n meta: AgentConversationPublicationMeta | undefined;\n conversationIdProp: string | undefined;\n propsRef: ReturnType<typeof useDataRef<UseWebChatProps>>;\n loadNotifiedRef: MutableRefObject<boolean>;\n notifiedCatchUpErrorRef: MutableRefObject<NovuError | undefined>;\n lastReportedErrorKeyRef: MutableRefObject<string | undefined>;\n}): void {\n const {\n snapshot,\n meta,\n conversationIdProp,\n propsRef,\n loadNotifiedRef,\n notifiedCatchUpErrorRef,\n lastReportedErrorKeyRef,\n } = args;\n\n if ((meta?.historyLoaded || meta?.change?.kind === 'history') && !loadNotifiedRef.current && conversationIdProp) {\n if (snapshot.conversationId) {\n loadNotifiedRef.current = true;\n propsRef.current.onSuccess?.({\n conversationId: snapshot.conversationId,\n messages: [...snapshot.messages],\n hasMore: snapshot.pagination.hasMore,\n });\n }\n }\n\n if (snapshot.catchUpError && snapshot.catchUpError !== notifiedCatchUpErrorRef.current) {\n notifiedCatchUpErrorRef.current = snapshot.catchUpError;\n propsRef.current.onError?.(snapshot.catchUpError);\n } else if (!snapshot.catchUpError) {\n notifiedCatchUpErrorRef.current = undefined;\n }\n\n if (snapshot.error) {\n const originalMessage = 'originalError' in snapshot.error ? (snapshot.error.originalError?.message ?? '') : '';\n const errorKey = `${snapshot.error.message}:${originalMessage}`;\n if (lastReportedErrorKeyRef.current !== errorKey) {\n lastReportedErrorKeyRef.current = errorKey;\n propsRef.current.onError?.(snapshot.error as NovuError | WebChatPlanLimitError);\n }\n } else {\n lastReportedErrorKeyRef.current = undefined;\n }\n\n const change = meta?.change;\n if (change?.kind === 'live') {\n propsRef.current.onEvent?.(change.envelope);\n }\n\n if (change && change.kind !== 'history') {\n for (const message of change.addedMessages) {\n propsRef.current.onMessage?.(message);\n }\n }\n\n if (change) {\n for (const action of change.newActions) {\n propsRef.current.onActionRequested?.(action);\n }\n }\n}\n\ntype OwnedRuntimeEntry = {\n key: string;\n novu: ReturnType<typeof useNovu>;\n runtime: AgentConversationRuntime;\n};\n\nfunction getCreateFlowKey(agentId: string, agentHash?: string): string {\n return `${agentId}\\0${agentHash ?? ''}`;\n}\n\nfunction resolveOwnedRuntime(args: {\n novu: ReturnType<typeof useNovu>;\n agentId: string;\n agentHash?: string;\n ownedRuntimeRef: MutableRefObject<OwnedRuntimeEntry | null>;\n}): AgentConversationRuntime | null {\n const key = getCreateFlowKey(args.agentId, args.agentHash);\n const current = args.ownedRuntimeRef.current;\n\n if (current?.novu === args.novu && current.key === key) {\n return current.runtime;\n }\n\n current?.runtime.dispose();\n\n const runtime = args.novu.webChat.conversation({ agentId: args.agentId, agentHash: args.agentHash });\n args.ownedRuntimeRef.current = { key, novu: args.novu, runtime };\n return runtime;\n}\n\ntype WebChatLoadState =\n | { novu: ReturnType<typeof useNovu>; status: 'loading' }\n | { novu: ReturnType<typeof useNovu>; status: 'ready' }\n | { novu: ReturnType<typeof useNovu>; status: 'error'; error: NovuError };\n\nfunction toNovuError(error: unknown): NovuError {\n if (error instanceof NovuError) {\n return error;\n }\n\n if (error instanceof Error) {\n return new NovuError('Failed to load Web Chat', error);\n }\n\n return new NovuError('Failed to load Web Chat', new Error(String(error)));\n}\n\n/**\n * Headless Web Chat client. Use it inside `NovuProvider`.\n *\n * @example\n * ```tsx\n * const { messages, sendMessage, isRunning, isLoading, error } = useWebChat({\n * agentId: 'YOUR_AGENT_IDENTIFIER',\n * });\n * ```\n */\nexport const useWebChat = (props: UseWebChatProps): UseWebChatResult => {\n const novu = useNovu();\n const propsRef = useDataRef(props);\n const [loadState, setLoadState] = useState<WebChatLoadState>(() => ({\n novu,\n status: 'loading',\n }));\n\n useEffect(() => {\n let cancelled = false;\n\n if (!novu.isWebChatLoaded) {\n setLoadState({ novu, status: 'loading' });\n }\n\n void novu\n .loadWebChat()\n .then(() => {\n if (!cancelled) {\n setLoadState({ novu, status: 'ready' });\n }\n })\n .catch((error: unknown) => {\n if (cancelled) {\n return;\n }\n\n const novuError = toNovuError(error);\n propsRef.current.onError?.(novuError);\n setLoadState({ novu, status: 'error', error: novuError });\n });\n\n return () => {\n cancelled = true;\n };\n }, [novu, propsRef]);\n\n const webChatReady = loadState.novu === novu && loadState.status === 'ready';\n const webChatLoadError = loadState.novu === novu && loadState.status === 'error' ? loadState.error : undefined;\n const isWebChatLoading = loadState.novu !== novu || loadState.status === 'loading';\n\n const sharedRuntime = 'conversation' in props ? props.conversation : undefined;\n const agentId = sharedRuntime?.agentId ?? props.agentId!;\n const conversationIdProp = sharedRuntime ? undefined : props.conversationId;\n const agentHash = sharedRuntime ? undefined : props.agentHash;\n\n const ownedRuntimeRef = useRef<OwnedRuntimeEntry | null>(null);\n\n useEffect(() => {\n const current = ownedRuntimeRef.current;\n if (current && current.novu !== novu) {\n current.runtime.dispose();\n ownedRuntimeRef.current = null;\n }\n }, [novu]);\n\n const cachedRuntime = useMemo(() => {\n if (!webChatReady) {\n return null;\n }\n\n if (sharedRuntime) {\n return sharedRuntime;\n }\n\n if (!conversationIdProp) {\n return null;\n }\n\n return novu.webChat.conversation({\n agentId,\n conversationId: conversationIdProp,\n agentHash,\n });\n }, [webChatReady, sharedRuntime, novu, agentId, conversationIdProp, agentHash]);\n\n if (sharedRuntime || conversationIdProp) {\n ownedRuntimeRef.current?.runtime.dispose();\n ownedRuntimeRef.current = null;\n }\n\n const ownedRuntime =\n !webChatReady || sharedRuntime || conversationIdProp\n ? null\n : resolveOwnedRuntime({ novu, agentId, agentHash, ownedRuntimeRef });\n\n const runtime = sharedRuntime ?? cachedRuntime ?? ownedRuntime;\n\n useEffect(() => {\n return () => {\n ownedRuntimeRef.current?.runtime.dispose();\n ownedRuntimeRef.current = null;\n };\n }, []);\n\n const loadNotifiedRef = useRef(false);\n const replayedActionsRef = useRef(false);\n const notifiedCatchUpErrorRef = useRef<NovuError | undefined>();\n const lastReportedErrorKeyRef = useRef<string>();\n\n useEffect(() => {\n loadNotifiedRef.current = false;\n replayedActionsRef.current = false;\n notifiedCatchUpErrorRef.current = undefined;\n lastReportedErrorKeyRef.current = undefined;\n }, [runtime]);\n\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n if (!runtime) {\n return () => {};\n }\n\n if (!replayedActionsRef.current) {\n replayedActionsRef.current = true;\n for (const action of runtime.getSnapshot().pendingActions) {\n propsRef.current.onActionRequested?.(action);\n }\n }\n\n return runtime.subscribe((snapshot, meta) => {\n onStoreChange();\n handlePublicationCallbacks({\n snapshot,\n meta,\n conversationIdProp,\n propsRef,\n loadNotifiedRef,\n notifiedCatchUpErrorRef,\n lastReportedErrorKeyRef,\n });\n });\n },\n [runtime, conversationIdProp, propsRef]\n );\n\n const getSnapshot = useCallback(() => {\n return runtime?.getSnapshot() ?? EMPTY_SERVER_SNAPSHOT;\n }, [runtime]);\n\n const getServerSnapshot = useCallback(() => {\n return runtime?.getServerSnapshot() ?? EMPTY_SERVER_SNAPSHOT;\n }, [runtime]);\n\n const snapshot = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n\n const callRuntime = useCallback(\n async <T>(action: (target: AgentConversationRuntime) => Promise<RuntimeActionResult<T>>) => {\n if (!runtime) {\n const error =\n webChatLoadError ??\n new NovuError(\n isWebChatLoading ? 'Web Chat is still loading' : 'Web Chat runtime is unavailable',\n new Error('Web Chat runtime is not ready')\n );\n propsRef.current.onError?.(error);\n\n return { error };\n }\n\n const response = await action(runtime);\n if (response.error) {\n propsRef.current.onError?.(response.error);\n }\n\n return response;\n },\n [runtime, webChatLoadError, isWebChatLoading, propsRef]\n );\n\n const refetch = useCallback(async () => {\n if (!runtime) {\n return;\n }\n\n const response = await runtime.load();\n if (response.data) {\n propsRef.current.onSuccess?.({\n conversationId: response.data.conversationId,\n messages: [...response.data.messages],\n hasMore: response.data.hasMore,\n });\n }\n }, [runtime, propsRef]);\n\n const fetchMore = useCallback(async () => {\n const response = await callRuntime((target) => target.fetchMore());\n\n return {\n ...response,\n error: response.error as NovuError | undefined,\n data: response.data\n ? {\n messages: [...response.data.messages],\n hasMore: response.data.hasMore,\n }\n : undefined,\n };\n }, [callRuntime]);\n\n const paginationWithFetch = useMemo(\n () => ({\n status: snapshot.pagination.status,\n hasMore: snapshot.pagination.hasMore,\n fetchMore,\n }),\n [snapshot.pagination.status, snapshot.pagination.hasMore, fetchMore]\n );\n\n const sendMessage = useCallback(\n (input: SendMessageInput) => callRuntime((target) => target.sendMessage(input)),\n [callRuntime]\n );\n const respondToAction = useCallback(\n (args: { actionId: string; decision: AgentToolApprovalDecision }) =>\n callRuntime((target) => target.respondToAction(args)),\n [callRuntime]\n );\n const sendAction = useCallback(\n (args: { actionId: string; sourceMessageId: string; value?: string }) =>\n callRuntime((target) => target.sendAction(args)),\n [callRuntime]\n );\n const retryMessage = useCallback(\n (messageId: string) => callRuntime((target) => target.retryMessage(messageId)),\n [callRuntime]\n );\n\n return {\n messages: [...snapshot.messages],\n pendingActions: [...snapshot.pendingActions],\n conversationId: snapshot.conversationId,\n error: webChatLoadError ?? (snapshot.error as UseWebChatResult['error']),\n isLoading: !webChatLoadError && (isWebChatLoading || snapshot.status === 'loading'),\n isRunning: snapshot.run.isRunning,\n typing: snapshot.run.typing,\n conversationStatus: snapshot.conversationStatus,\n run: snapshot.run,\n pagination: paginationWithFetch,\n isRecovering: snapshot.isRecovering,\n catchUpError: snapshot.catchUpError,\n refetch,\n sendMessage,\n respondToAction,\n sendAction,\n retryMessage,\n };\n};\n"],"mappings":";AAmBA,SAAS,iBAAiB;AAC1B,SAAgC,aAAa,WAAW,SAAS,QAAQ,UAAU,4BAA4B;AAC/G,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AAsGxB,IAAM,wBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,KAAK,EAAE,WAAW,MAAM;AAAA,EACxB,oBAAoB;AAAA,EACpB,YAAY,EAAE,SAAS,OAA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from './components/subscription/Subsc
|
|
|
15
15
|
export { SubscriptionButton, SubscriptionButtonProps } from './components/subscription/SubscriptionButton.js';
|
|
16
16
|
export { SubscriptionPreferences, SubscriptionPreferencesProps } from './components/subscription/SubscriptionPreferences.js';
|
|
17
17
|
export { TelegramConnectButton, TelegramConnectButtonProps } from './components/telegram-connect-button/TelegramConnectButton.js';
|
|
18
|
-
export {
|
|
18
|
+
export { UseWebChatProps, UseWebChatResult, useWebChat } from './hooks/useWebChat.js';
|
|
19
19
|
export { UseChannelConnectionProps, UseChannelConnectionResult, useChannelConnection } from './hooks/useChannelConnection.js';
|
|
20
20
|
export { UseChannelConnectionsProps, UseChannelConnectionsResult, useChannelConnections } from './hooks/useChannelConnections.js';
|
|
21
21
|
export { UseChannelEndpointProps, UseChannelEndpointResult, useChannelEndpoint } from './hooks/useChannelEndpoint.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
TelegramConnectButton
|
|
18
18
|
} from "./components/index.js";
|
|
19
19
|
import {
|
|
20
|
-
|
|
20
|
+
useWebChat,
|
|
21
21
|
useChannelConnection,
|
|
22
22
|
useChannelConnections,
|
|
23
23
|
useChannelEndpoint,
|
|
@@ -53,7 +53,6 @@ export {
|
|
|
53
53
|
SubscriptionPreferences,
|
|
54
54
|
TelegramConnectButton,
|
|
55
55
|
WorkflowCriticalityEnum,
|
|
56
|
-
useAgentChat,
|
|
57
56
|
useChannelConnection,
|
|
58
57
|
useChannelConnections,
|
|
59
58
|
useChannelEndpoint,
|
|
@@ -69,6 +68,7 @@ export {
|
|
|
69
68
|
useSubscription,
|
|
70
69
|
useSubscriptions,
|
|
71
70
|
useTelegramSubscriberLink,
|
|
72
|
-
useUpdateSubscription
|
|
71
|
+
useUpdateSubscription,
|
|
72
|
+
useWebChat
|
|
73
73
|
};
|
|
74
74
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n AllLocalization,\n AllLocalizationKey,\n ChannelConnectButtonIconKey,\n ElementStyles,\n InboxAppearance,\n InboxAppearanceCallback,\n InboxAppearanceCallbackFunction,\n InboxAppearanceCallbackKeys,\n InboxAppearanceKey,\n InboxElements,\n InboxLocalization,\n InboxLocalizationKey,\n InboxTheme,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n SubscriptionAppearance,\n SubscriptionAppearanceCallback,\n SubscriptionAppearanceCallbackFunction,\n SubscriptionAppearanceCallbackKeys,\n SubscriptionAppearanceKey,\n SubscriptionElements,\n SubscriptionLocalization,\n SubscriptionLocalizationKey,\n SubscriptionTheme,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type {\n BellProps,\n InboxContentProps,\n InboxProps,\n MsTeamsConnectButtonProps,\n MsTeamsLinkUserProps,\n NotificationProps,\n NovuProviderProps,\n SlackConnectButtonProps,\n SlackLinkUserProps,\n SubscriptionButtonProps,\n SubscriptionPreferencesProps,\n SubscriptionProps,\n TelegramConnectButtonProps,\n} from './components';\nexport {\n Bell,\n Inbox,\n InboxContent,\n MsTeamsConnectButton,\n MsTeamsLinkUser,\n Notifications,\n NovuProvider,\n Preferences,\n SlackConnectButton,\n SlackLinkUser,\n Subscription,\n SubscriptionButton,\n SubscriptionPreferences,\n TelegramConnectButton,\n} from './components';\nexport type {\n
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n AllLocalization,\n AllLocalizationKey,\n ChannelConnectButtonIconKey,\n ElementStyles,\n InboxAppearance,\n InboxAppearanceCallback,\n InboxAppearanceCallbackFunction,\n InboxAppearanceCallbackKeys,\n InboxAppearanceKey,\n InboxElements,\n InboxLocalization,\n InboxLocalizationKey,\n InboxTheme,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n SubscriptionAppearance,\n SubscriptionAppearanceCallback,\n SubscriptionAppearanceCallbackFunction,\n SubscriptionAppearanceCallbackKeys,\n SubscriptionAppearanceKey,\n SubscriptionElements,\n SubscriptionLocalization,\n SubscriptionLocalizationKey,\n SubscriptionTheme,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type {\n BellProps,\n InboxContentProps,\n InboxProps,\n MsTeamsConnectButtonProps,\n MsTeamsLinkUserProps,\n NotificationProps,\n NovuProviderProps,\n SlackConnectButtonProps,\n SlackLinkUserProps,\n SubscriptionButtonProps,\n SubscriptionPreferencesProps,\n SubscriptionProps,\n TelegramConnectButtonProps,\n} from './components';\nexport {\n Bell,\n Inbox,\n InboxContent,\n MsTeamsConnectButton,\n MsTeamsLinkUser,\n Notifications,\n NovuProvider,\n Preferences,\n SlackConnectButton,\n SlackLinkUser,\n Subscription,\n SubscriptionButton,\n SubscriptionPreferences,\n TelegramConnectButton,\n} from './components';\nexport type {\n UseWebChatProps,\n UseWebChatResult,\n UseChannelConnectionProps,\n UseChannelConnectionResult,\n UseChannelConnectionsProps,\n UseChannelConnectionsResult,\n UseChannelEndpointProps,\n UseChannelEndpointResult,\n UseCountsProps,\n UseCountsResult,\n UseCreateChannelEndpointProps,\n UseCreateChannelEndpointResult,\n UseDeleteChannelEndpointProps,\n UseDeleteChannelEndpointResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n UseTelegramSubscriberLinkProps,\n UseTelegramSubscriberLinkResult,\n} from './hooks';\nexport {\n useWebChat,\n useChannelConnection,\n useChannelConnections,\n useChannelEndpoint,\n useCounts,\n useCreateChannelEndpoint,\n useCreateSubscription,\n useDeleteChannelEndpoint,\n useNotifications,\n useNovu,\n usePreferences,\n useRemoveSubscription,\n useSchedule,\n useSubscription,\n useSubscriptions,\n useTelegramSubscriberLink,\n useUpdateSubscription,\n} from './hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n ReactAllAppearance,\n ReactInboxAppearance,\n ReactInboxTheme,\n ReactSubscriptionAppearance,\n ReactSubscriptionTheme,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from './utils/types';\n"],"mappings":";AACA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAiD5E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAuBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
|
@@ -3,7 +3,7 @@ import { InboxProps } from '../components/Inbox.js';
|
|
|
3
3
|
export * from '@novu/js';
|
|
4
4
|
export { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';
|
|
5
5
|
import { NovuProviderProps } from '../hooks/NovuProvider.js';
|
|
6
|
-
import {
|
|
6
|
+
import { UseWebChatProps, UseWebChatResult } from '../hooks/useWebChat.js';
|
|
7
7
|
import { UseCountsProps, UseCountsResult } from '../hooks/useCounts.js';
|
|
8
8
|
import { UseCreateSubscriptionProps, UseCreateSubscriptionResult } from '../hooks/useCreateSubscription.js';
|
|
9
9
|
import { UseNotificationsProps, UseNotificationsResult } from '../hooks/useNotifications.js';
|
|
@@ -41,7 +41,7 @@ declare function MsTeamsConnectButton(): react_jsx_runtime.JSX.Element;
|
|
|
41
41
|
declare function MsTeamsLinkUser(): react_jsx_runtime.JSX.Element;
|
|
42
42
|
declare function TelegramConnectButton(): react_jsx_runtime.JSX.Element;
|
|
43
43
|
declare function useNovu(): null;
|
|
44
|
-
declare function
|
|
44
|
+
declare function useWebChat(_: UseWebChatProps): UseWebChatResult;
|
|
45
45
|
declare function useCounts(_: UseCountsProps): UseCountsResult;
|
|
46
46
|
declare function useNotifications(_: UseNotificationsProps): UseNotificationsResult;
|
|
47
47
|
declare function usePreferences(_: UsePreferencesProps): UsePreferencesResult;
|
|
@@ -52,4 +52,4 @@ declare function useUpdateSubscription(_?: UseUpdateSubscriptionProps): UseUpdat
|
|
|
52
52
|
declare function useRemoveSubscription(_?: UseRemoveSubscriptionProps): UseRemoveSubscriptionResult;
|
|
53
53
|
declare function useSubscriptions(_: UseSubscriptionsProps): UseSubscriptionsResult;
|
|
54
54
|
|
|
55
|
-
export { Bell, Inbox, InboxContent, InboxProps, MsTeamsConnectButton, MsTeamsLinkUser, Notifications, NovuProvider, NovuProviderProps, Preferences, SlackConnectButton, SlackLinkUser, Subscription, SubscriptionButton, SubscriptionPreferences, TelegramConnectButton,
|
|
55
|
+
export { Bell, Inbox, InboxContent, InboxProps, MsTeamsConnectButton, MsTeamsLinkUser, Notifications, NovuProvider, NovuProviderProps, Preferences, SlackConnectButton, SlackLinkUser, Subscription, SubscriptionButton, SubscriptionPreferences, TelegramConnectButton, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UseScheduleProps as UsePreferencesProps, UsePreferencesResult, UseWebChatProps, UseWebChatResult, useCounts, useCreateSubscription, useNotifications, useNovu, usePreferences, useRemoveSubscription, useSchedule, useSubscription, useSubscriptions, useUpdateSubscription, useWebChat };
|
package/dist/esm/server/index.js
CHANGED
|
@@ -41,14 +41,13 @@ function TelegramConnectButton() {
|
|
|
41
41
|
function useNovu() {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function useWebChat(_) {
|
|
45
45
|
return {
|
|
46
46
|
messages: [],
|
|
47
47
|
pendingActions: [],
|
|
48
|
-
isLoading:
|
|
48
|
+
isLoading: true,
|
|
49
49
|
isRunning: false,
|
|
50
50
|
typing: void 0,
|
|
51
|
-
status: "active",
|
|
52
51
|
conversationStatus: "active",
|
|
53
52
|
run: { isRunning: false },
|
|
54
53
|
pagination: {
|
|
@@ -152,7 +151,6 @@ export {
|
|
|
152
151
|
SubscriptionPreferences,
|
|
153
152
|
TelegramConnectButton,
|
|
154
153
|
WorkflowCriticalityEnum,
|
|
155
|
-
useAgentChat,
|
|
156
154
|
useCounts,
|
|
157
155
|
useCreateSubscription,
|
|
158
156
|
useNotifications,
|
|
@@ -162,6 +160,7 @@ export {
|
|
|
162
160
|
useSchedule,
|
|
163
161
|
useSubscription,
|
|
164
162
|
useSubscriptions,
|
|
165
|
-
useUpdateSubscription
|
|
163
|
+
useUpdateSubscription,
|
|
164
|
+
useWebChat
|
|
166
165
|
};
|
|
167
166
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type { InboxProps } from '../components/Inbox';\nimport { ShadowRootDetector } from '../components/ShadowRootDetector';\nimport type {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type { InboxProps } from '../components/Inbox';\nimport { ShadowRootDetector } from '../components/ShadowRootDetector';\nimport type {\n UseWebChatProps,\n UseWebChatResult,\n UseCreateSubscriptionProps,\n UseCreateSubscriptionResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n UseRemoveSubscriptionProps,\n UseRemoveSubscriptionResult,\n UseScheduleProps,\n UseScheduleResult,\n UseSubscriptionProps,\n UseSubscriptionResult,\n UseSubscriptionsProps,\n UseSubscriptionsResult,\n UseUpdateSubscriptionProps,\n UseUpdateSubscriptionResult,\n} from '../hooks';\nimport type { NovuProviderProps } from '../hooks/NovuProvider';\nimport type { UseCountsProps, UseCountsResult } from '../hooks/useCounts';\n\n/**\n * Exporting all components from the components folder\n * as empty functions to fix build errors in SSR\n * This will be replaced with actual components\n * when we implement the SSR components in @novu/js/ui\n */\nexport function Inbox(props: InboxProps) {\n return <ShadowRootDetector />;\n}\n\nexport function InboxContent() {}\n\nexport function Notifications() {}\n\nexport function Preferences() {}\n\nexport function Bell() {}\n\nexport function NovuProvider(props: NovuProviderProps) {\n return <>{props.children}</>;\n}\n\nexport function Subscription() {\n return <ShadowRootDetector />;\n}\n\nexport function SubscriptionButton() {}\n\nexport function SubscriptionPreferences() {}\n\nexport function SlackConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function SlackLinkUser() {\n return <ShadowRootDetector />;\n}\n\nexport function MsTeamsConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function MsTeamsLinkUser() {\n return <ShadowRootDetector />;\n}\n\nexport function TelegramConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function useNovu() {\n return null;\n}\n\nexport function useWebChat(_: UseWebChatProps): UseWebChatResult {\n return {\n messages: [],\n pendingActions: [],\n isLoading: true,\n isRunning: false,\n typing: undefined,\n conversationStatus: 'active',\n run: { isRunning: false },\n pagination: {\n status: 'idle',\n hasMore: false,\n fetchMore: () => Promise.resolve({ data: undefined, error: undefined }),\n },\n isRecovering: false,\n catchUpError: undefined,\n refetch: () => Promise.resolve(),\n sendMessage: () => Promise.resolve({ data: undefined, error: undefined }),\n respondToAction: () => Promise.resolve({ data: undefined, error: undefined }),\n sendAction: () => Promise.resolve({ data: undefined, error: undefined }),\n retryMessage: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useCounts(_: UseCountsProps): UseCountsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useNotifications(_: UseNotificationsProps): UseNotificationsResult {\n return {\n isLoading: false,\n isFetching: false,\n hasMore: false,\n readAll: () => Promise.resolve({ data: undefined, error: undefined }),\n seenAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAllRead: () => Promise.resolve({ data: undefined, error: undefined }),\n refetch: () => Promise.resolve(),\n fetchMore: () => Promise.resolve(),\n };\n}\n\nexport function usePreferences(_: UsePreferencesProps): UsePreferencesResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSchedule(_: UseScheduleProps): UseScheduleResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSubscription(_: UseSubscriptionProps): UseSubscriptionResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useCreateSubscription(_: UseCreateSubscriptionProps = {}): UseCreateSubscriptionResult {\n return {\n isCreating: false,\n error: undefined,\n create: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useUpdateSubscription(_: UseUpdateSubscriptionProps = {}): UseUpdateSubscriptionResult {\n return {\n isUpdating: false,\n error: undefined,\n update: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useRemoveSubscription(_: UseRemoveSubscriptionProps = {}): UseRemoveSubscriptionResult {\n return {\n isRemoving: false,\n error: undefined,\n remove: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useSubscriptions(_: UseSubscriptionsProps): UseSubscriptionsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n AllLocalization,\n AllLocalizationKey,\n ElementStyles,\n InboxAppearance,\n InboxAppearanceCallback,\n InboxAppearanceCallbackFunction,\n InboxAppearanceCallbackKeys,\n InboxAppearanceKey,\n InboxElements,\n InboxLocalization,\n InboxLocalizationKey,\n InboxTheme,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n SubscriptionAppearance,\n SubscriptionAppearanceCallback,\n SubscriptionAppearanceCallbackFunction,\n SubscriptionAppearanceCallbackKeys,\n SubscriptionAppearanceKey,\n SubscriptionElements,\n SubscriptionLocalization,\n SubscriptionLocalizationKey,\n SubscriptionTheme,\n Tab,\n Variables,\n} from '@novu/js/ui';\n\nexport type { BellProps, InboxContentProps, InboxProps, NotificationProps, NovuProviderProps } from '../components';\n\nexport type {\n UseWebChatProps,\n UseWebChatResult,\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n} from '../hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from '../utils/types';\n"],"mappings":";AACA,SAAS,0BAA0B;AAqLnC,SAAS,iBAAiB,mBAAmB,+BAA+B;AAtJnE,SAYA,UAZA;AADF,SAAS,MAAM,OAAmB;AACvC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,eAAe;AAAC;AAEzB,SAAS,gBAAgB;AAAC;AAE1B,SAAS,cAAc;AAAC;AAExB,SAAS,OAAO;AAAC;AAEjB,SAAS,aAAa,OAA0B;AACrD,SAAO,gCAAG,gBAAM,UAAS;AAC3B;AAEO,SAAS,eAAe;AAC7B,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,qBAAqB;AAAC;AAE/B,SAAS,0BAA0B;AAAC;AAEpC,SAAS,qBAAqB;AACnC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,gBAAgB;AAC9B,SAAO,oBAAC,sBAAmB;AAC7B;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AEO,SAAS,iBAAiB,GAAkD;AACjF,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novu/react",
|
|
3
|
-
"version": "3.19.1
|
|
3
|
+
"version": "3.19.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/novuhq/novu",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"dependencies": {
|
|
124
|
-
"@novu/js": "3.19.1
|
|
124
|
+
"@novu/js": "3.19.1"
|
|
125
125
|
},
|
|
126
126
|
"nx": {
|
|
127
127
|
"tags": [
|
|
@@ -130,7 +130,8 @@
|
|
|
130
130
|
},
|
|
131
131
|
"scripts": {
|
|
132
132
|
"build:watch": "tsup --watch",
|
|
133
|
-
"build": "tsup && pnpm run check-exports",
|
|
133
|
+
"build": "tsup && node scripts/bundle-graph.mjs && pnpm run check-exports",
|
|
134
|
+
"test:bundle-graph": "node ./scripts/bundle-graph.mjs",
|
|
134
135
|
"check-exports": "attw --pack .",
|
|
135
136
|
"check": "biome check .",
|
|
136
137
|
"check:fix": "biome check --write .",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useAgentChat.ts"],"sourcesContent":["import type {\n AgentChatPagination,\n AgentChatPlanLimitError,\n AgentConversationPublicationMeta,\n AgentConversationRunSnapshot,\n AgentConversationRuntime,\n AgentConversationSnapshot,\n AgentConversationStatus,\n AgentEventEnvelope,\n AgentHashFields,\n AgentMessage,\n AgentPendingAction,\n AgentToolApprovalDecision,\n LoadConversationResult,\n NovuError,\n RespondToActionResult,\n SendActionResult,\n SendMessageResult,\n} from '@novu/js';\nimport { type MutableRefObject, useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport { useDataRef } from './internal/useDataRef';\nimport { useNovu } from './NovuProvider';\n\ntype UseAgentChatCallbacks = {\n onSuccess?: (data: LoadConversationResult) => void;\n onError?: (error: NovuError | AgentChatPlanLimitError) => void;\n /**\n * Fires once per message, when the message id first appears on the conversation.\n * History pages are silent: only new activity fires.\n * An agent message can still be empty at this point, because the first envelope of a\n * turn creates the message before any text is folded into it.\n * A send that never reaches the server does not fire: the message flips to `failed` instead.\n */\n onMessage?: (message: AgentMessage) => void;\n /**\n * Fires once per pending action, including actions still pending on mount, so a\n * resumed conversation reports what it is blocked on. Paging backwards is silent.\n */\n onActionRequested?: (action: AgentPendingAction) => void;\n /**\n * Raw envelopes for this conversation, before the derived callbacks for the same fold.\n * A duplicate envelope that the store drops does not fire. Neither does an envelope that\n * arrives before a newly created conversation claims its id.\n * The store folds the envelope before this callback runs, so `messages` here is one render old.\n */\n onEvent?: (envelope: AgentEventEnvelope) => void;\n};\n\nexport type UseAgentChatProps = UseAgentChatCallbacks &\n AgentHashFields &\n (\n | {\n agentId: string;\n /**\n * Resume this conversation. The hook loads history on mount.\n * Omit this prop to start a new chat. The first send creates a conversation.\n * Later sends pass the returned id. Remount or clear this prop to start another chat.\n */\n conversationId?: string;\n conversation?: never;\n }\n | {\n /** Share an existing conversation runtime across multiple hook instances. */\n conversation: AgentConversationRuntime;\n agentId?: never;\n conversationId?: never;\n agentHash?: never;\n }\n );\n\nexport type UseAgentChatResult = {\n messages: AgentMessage[];\n pendingActions: AgentPendingAction[];\n conversationId?: string;\n error?: NovuError | AgentChatPlanLimitError;\n /** True until the first history fetch completes. False when there is no `conversationId` prop. */\n isLoading: boolean;\n isRunning: boolean;\n typing?: AgentConversationRunSnapshot['typing'];\n /** Conversation lifecycle status (`active`, etc.). */\n status: AgentConversationStatus;\n /** Explicit alias for `status`. */\n conversationStatus: AgentConversationStatus;\n /** Current agent run snapshot. */\n run: AgentConversationRunSnapshot;\n pagination: AgentChatPagination & {\n fetchMore: () => Promise<{\n data?: { messages: AgentMessage[]; hasMore: boolean };\n error?: NovuError;\n }>;\n };\n /** True while reconnect catch-up is in flight for this conversation. */\n isRecovering: boolean;\n /** Set when reconnect catch-up fails. Separate from send/fetch `error`. */\n catchUpError?: NovuError;\n refetch: () => Promise<void>;\n sendMessage: (text: string) => Promise<{\n data?: SendMessageResult;\n error?: NovuError | AgentChatPlanLimitError;\n }>;\n respondToAction: (args: { actionId: string; decision: AgentToolApprovalDecision }) => Promise<{\n data?: RespondToActionResult;\n error?: NovuError | AgentChatPlanLimitError;\n }>;\n sendAction: (args: { actionId: string; sourceMessageId: string; value?: string }) => Promise<{\n data?: SendActionResult;\n error?: NovuError | AgentChatPlanLimitError;\n }>;\n retryMessage: (messageId: string) => Promise<{\n data?: SendMessageResult;\n error?: NovuError | AgentChatPlanLimitError;\n }>;\n};\n\nconst EMPTY_SERVER_SNAPSHOT: AgentConversationSnapshot = {\n key: 'ssr',\n status: 'ready',\n run: { isRunning: false },\n conversationStatus: 'active',\n pagination: { hasMore: false, status: 'idle' },\n messages: [],\n pendingActions: [],\n isRecovering: false,\n};\n\ntype RuntimeActionResult<T> = {\n data?: T;\n error?: NovuError | AgentChatPlanLimitError;\n};\n\nfunction handlePublicationCallbacks(args: {\n snapshot: AgentConversationSnapshot;\n meta: AgentConversationPublicationMeta | undefined;\n conversationIdProp: string | undefined;\n propsRef: ReturnType<typeof useDataRef<UseAgentChatProps>>;\n loadNotifiedRef: MutableRefObject<boolean>;\n notifiedCatchUpErrorRef: MutableRefObject<NovuError | undefined>;\n lastReportedErrorKeyRef: MutableRefObject<string | undefined>;\n}): void {\n const {\n snapshot,\n meta,\n conversationIdProp,\n propsRef,\n loadNotifiedRef,\n notifiedCatchUpErrorRef,\n lastReportedErrorKeyRef,\n } = args;\n\n if ((meta?.historyLoaded || meta?.change?.kind === 'history') && !loadNotifiedRef.current && conversationIdProp) {\n if (snapshot.conversationId) {\n loadNotifiedRef.current = true;\n propsRef.current.onSuccess?.({\n conversationId: snapshot.conversationId,\n messages: [...snapshot.messages],\n hasMore: snapshot.pagination.hasMore,\n });\n }\n }\n\n if (snapshot.catchUpError && snapshot.catchUpError !== notifiedCatchUpErrorRef.current) {\n notifiedCatchUpErrorRef.current = snapshot.catchUpError;\n propsRef.current.onError?.(snapshot.catchUpError);\n } else if (!snapshot.catchUpError) {\n notifiedCatchUpErrorRef.current = undefined;\n }\n\n if (snapshot.error) {\n const originalMessage = 'originalError' in snapshot.error ? (snapshot.error.originalError?.message ?? '') : '';\n const errorKey = `${snapshot.error.message}:${originalMessage}`;\n if (lastReportedErrorKeyRef.current !== errorKey) {\n lastReportedErrorKeyRef.current = errorKey;\n propsRef.current.onError?.(snapshot.error as NovuError | AgentChatPlanLimitError);\n }\n } else {\n lastReportedErrorKeyRef.current = undefined;\n }\n\n const change = meta?.change;\n if (change?.kind === 'live') {\n propsRef.current.onEvent?.(change.envelope);\n }\n\n if (change && change.kind !== 'history') {\n for (const message of change.addedMessages) {\n propsRef.current.onMessage?.(message);\n }\n }\n\n if (change) {\n for (const action of change.newActions) {\n propsRef.current.onActionRequested?.(action);\n }\n }\n}\n\ntype OwnedRuntimeEntry = {\n key: string;\n runtime: AgentConversationRuntime;\n};\n\nfunction getCreateFlowKey(agentId: string, agentHash?: string): string {\n return `${agentId}\\0${agentHash ?? ''}`;\n}\n\nfunction resolveOwnedRuntime(args: {\n novu: ReturnType<typeof useNovu>;\n agentId: string;\n agentHash?: string;\n ownedRuntimeRef: MutableRefObject<OwnedRuntimeEntry | null>;\n}): AgentConversationRuntime | null {\n const key = getCreateFlowKey(args.agentId, args.agentHash);\n const current = args.ownedRuntimeRef.current;\n\n if (current?.key === key) {\n return current.runtime;\n }\n\n current?.runtime.dispose();\n\n const result = args.novu.agentChat.conversation({ agentId: args.agentId, agentHash: args.agentHash });\n if (!result.ok) {\n args.ownedRuntimeRef.current = null;\n return null;\n }\n\n args.ownedRuntimeRef.current = { key, runtime: result.data };\n return result.data;\n}\n\nexport const useAgentChat = (props: UseAgentChatProps): UseAgentChatResult => {\n const novu = useNovu();\n const propsRef = useDataRef(props);\n\n const sharedRuntime = 'conversation' in props ? props.conversation : undefined;\n const agentId = sharedRuntime?.agentId ?? props.agentId!;\n const conversationIdProp = sharedRuntime ? undefined : props.conversationId;\n const agentHash = sharedRuntime ? undefined : props.agentHash;\n\n const ownedRuntimeRef = useRef<OwnedRuntimeEntry | null>(null);\n\n const cachedRuntime = useMemo(() => {\n if (sharedRuntime) {\n return sharedRuntime;\n }\n\n if (!conversationIdProp) {\n return null;\n }\n\n const result = novu.agentChat.conversation({\n agentId,\n conversationId: conversationIdProp,\n agentHash,\n });\n\n return result.ok ? result.data : null;\n }, [sharedRuntime, novu, agentId, conversationIdProp, agentHash]);\n\n if (sharedRuntime || conversationIdProp) {\n ownedRuntimeRef.current?.runtime.dispose();\n ownedRuntimeRef.current = null;\n }\n\n const ownedRuntime =\n sharedRuntime || conversationIdProp ? null : resolveOwnedRuntime({ novu, agentId, agentHash, ownedRuntimeRef });\n\n const runtime = sharedRuntime ?? cachedRuntime ?? ownedRuntime;\n\n useEffect(() => {\n return () => {\n ownedRuntimeRef.current?.runtime.dispose();\n ownedRuntimeRef.current = null;\n };\n }, []);\n\n const loadNotifiedRef = useRef(false);\n const replayedActionsRef = useRef(false);\n const notifiedCatchUpErrorRef = useRef<NovuError | undefined>();\n const lastReportedErrorKeyRef = useRef<string>();\n\n useEffect(() => {\n loadNotifiedRef.current = false;\n replayedActionsRef.current = false;\n notifiedCatchUpErrorRef.current = undefined;\n lastReportedErrorKeyRef.current = undefined;\n }, [runtime]);\n\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n if (!runtime) {\n return () => {};\n }\n\n if (!replayedActionsRef.current) {\n replayedActionsRef.current = true;\n for (const action of runtime.getSnapshot().pendingActions) {\n propsRef.current.onActionRequested?.(action);\n }\n }\n\n return runtime.subscribe((snapshot, meta) => {\n onStoreChange();\n handlePublicationCallbacks({\n snapshot,\n meta,\n conversationIdProp,\n propsRef,\n loadNotifiedRef,\n notifiedCatchUpErrorRef,\n lastReportedErrorKeyRef,\n });\n });\n },\n [runtime, conversationIdProp, propsRef]\n );\n\n const getSnapshot = useCallback(() => {\n return runtime?.getSnapshot() ?? EMPTY_SERVER_SNAPSHOT;\n }, [runtime]);\n\n const getServerSnapshot = useCallback(() => {\n return runtime?.getServerSnapshot() ?? EMPTY_SERVER_SNAPSHOT;\n }, [runtime]);\n\n const snapshot = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n\n const callRuntime = useCallback(\n async <T>(action: (target: AgentConversationRuntime) => Promise<RuntimeActionResult<T>>) => {\n if (!runtime) {\n return { error: undefined };\n }\n\n const response = await action(runtime);\n if (response.error) {\n propsRef.current.onError?.(response.error);\n }\n\n return response;\n },\n [runtime, propsRef]\n );\n\n const refetch = useCallback(async () => {\n if (!runtime) {\n return;\n }\n\n const response = await runtime.load();\n if (response.data) {\n propsRef.current.onSuccess?.({\n conversationId: response.data.conversationId,\n messages: [...response.data.messages],\n hasMore: response.data.hasMore,\n });\n }\n }, [runtime, propsRef]);\n\n const fetchMore = useCallback(async () => {\n const response = await callRuntime((target) => target.fetchMore());\n\n return {\n ...response,\n error: response.error as NovuError | undefined,\n data: response.data\n ? {\n messages: [...response.data.messages],\n hasMore: response.data.hasMore,\n }\n : undefined,\n };\n }, [callRuntime]);\n\n const paginationWithFetch = useMemo(\n () => ({\n status: snapshot.pagination.status,\n hasMore: snapshot.pagination.hasMore,\n fetchMore,\n }),\n [snapshot.pagination.status, snapshot.pagination.hasMore, fetchMore]\n );\n\n const sendMessage = useCallback((text: string) => callRuntime((target) => target.sendMessage(text)), [callRuntime]);\n const respondToAction = useCallback(\n (args: { actionId: string; decision: AgentToolApprovalDecision }) =>\n callRuntime((target) => target.respondToAction(args)),\n [callRuntime]\n );\n const sendAction = useCallback(\n (args: { actionId: string; sourceMessageId: string; value?: string }) =>\n callRuntime((target) => target.sendAction(args)),\n [callRuntime]\n );\n const retryMessage = useCallback(\n (messageId: string) => callRuntime((target) => target.retryMessage(messageId)),\n [callRuntime]\n );\n\n return {\n messages: [...snapshot.messages],\n pendingActions: [...snapshot.pendingActions],\n conversationId: snapshot.conversationId,\n error: snapshot.error as UseAgentChatResult['error'],\n isLoading: snapshot.status === 'loading',\n isRunning: snapshot.run.isRunning,\n typing: snapshot.run.typing,\n status: snapshot.conversationStatus,\n conversationStatus: snapshot.conversationStatus,\n run: snapshot.run,\n pagination: paginationWithFetch,\n isRecovering: snapshot.isRecovering,\n catchUpError: snapshot.catchUpError,\n refetch,\n sendMessage,\n respondToAction,\n sendAction,\n retryMessage,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBA,mBAAqG;AACrG,wBAA2B;AAC3B,0BAAwB;AA6FxB,IAAM,wBAAmD;AAAA,EACvD,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,KAAK,EAAE,WAAW,MAAM;AAAA,EACxB,oBAAoB;AAAA,EACpB,YAAY,EAAE,SAAS,OAAO,QAAQ,OAAO;AAAA,EAC7C,UAAU,CAAC;AAAA,EACX,gBAAgB,CAAC;AAAA,EACjB,cAAc;AAChB;AAOA,SAAS,2BAA2B,MAQ3B;AA1IT;AA2IE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAK,6BAAM,oBAAiB,kCAAM,WAAN,mBAAc,UAAS,cAAc,CAAC,gBAAgB,WAAW,oBAAoB;AAC/G,QAAI,SAAS,gBAAgB;AAC3B,sBAAgB,UAAU;AAC1B,2BAAS,SAAQ,cAAjB,4BAA6B;AAAA,QAC3B,gBAAgB,SAAS;AAAA,QACzB,UAAU,CAAC,GAAG,SAAS,QAAQ;AAAA,QAC/B,SAAS,SAAS,WAAW;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAEA,MAAI,SAAS,gBAAgB,SA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