@novu/react 3.19.1-rc.852194fa77 → 3.19.2-rc.dc9caee828

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.
@@ -25,12 +25,13 @@ __export(hooks_exports, {
25
25
  PreferenceLevel: () => import_js.PreferenceLevel,
26
26
  SeverityLevelEnum: () => import_js.SeverityLevelEnum,
27
27
  WorkflowCriticalityEnum: () => import_js.WorkflowCriticalityEnum,
28
+ pendingActionKey: () => import_js.pendingActionKey,
28
29
  useNovu: () => import_NovuProvider.useNovu
29
30
  });
30
31
  module.exports = __toCommonJS(hooks_exports);
31
32
  var import_js = require("@novu/js");
32
33
  var import_NovuProvider = require("./NovuProvider.cjs");
33
- __reExport(hooks_exports, require("./useAgentChat.cjs"), module.exports);
34
+ __reExport(hooks_exports, require("./useWebChat.cjs"), module.exports);
34
35
  __reExport(hooks_exports, require("./useChannelConnection.cjs"), module.exports);
35
36
  __reExport(hooks_exports, require("./useChannelConnections.cjs"), module.exports);
36
37
  __reExport(hooks_exports, require("./useChannelEndpoint.cjs"), module.exports);
@@ -54,8 +55,9 @@ __reExport(hooks_exports, require("./useUpdateSubscription.cjs"), module.exports
54
55
  PreferenceLevel,
55
56
  SeverityLevelEnum,
56
57
  WorkflowCriticalityEnum,
58
+ pendingActionKey,
57
59
  useNovu,
58
- ...require("./useAgentChat.cjs"),
60
+ ...require("./useWebChat.cjs"),
59
61
  ...require("./useChannelConnection.cjs"),
60
62
  ...require("./useChannelConnections.cjs"),
61
63
  ...require("./useChannelEndpoint.cjs"),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useAgentChat';\nexport * from './useChannelConnection';\nexport * from './useChannelConnections';\nexport * from './useChannelEndpoint';\nexport * from './useChannelEndpoints';\nexport * from './useCounts';\nexport * from './useCreateChannelEndpoint';\nexport * from './useCreateSubscription';\nexport * from './useDeleteChannelConnection';\nexport * from './useDeleteChannelEndpoint';\nexport * from './useNotifications';\nexport * from './usePreferences';\nexport * from './useRemoveSubscription';\nexport * from './useSchedule';\nexport * from './useSubscription';\nexport * from './useSubscriptions';\nexport * from './useTelegramSubscriberLink';\nexport * from './useUpdateSubscription';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAA4E;AAC5E,0BAAsC;AACtC,0BAAc,+BAHd;AAIA,0BAAc,uCAJd;AAKA,0BAAc,wCALd;AAMA,0BAAc,qCANd;AAOA,0BAAc,sCAPd;AAQA,0BAAc,4BARd;AASA,0BAAc,2CATd;AAUA,0BAAc,wCAVd;AAWA,0BAAc,6CAXd;AAYA,0BAAc,2CAZd;AAaA,0BAAc,mCAbd;AAcA,0BAAc,iCAdd;AAeA,0BAAc,wCAfd;AAgBA,0BAAc,8BAhBd;AAiBA,0BAAc,kCAjBd;AAkBA,0BAAc,mCAlBd;AAmBA,0BAAc,4CAnBd;AAoBA,0BAAc,wCApBd;","names":[]}
1
+ {"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { pendingActionKey, PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useWebChat';\nexport * from './useChannelConnection';\nexport * from './useChannelConnections';\nexport * from './useChannelEndpoint';\nexport * from './useChannelEndpoints';\nexport * from './useCounts';\nexport * from './useCreateChannelEndpoint';\nexport * from './useCreateSubscription';\nexport * from './useDeleteChannelConnection';\nexport * from './useDeleteChannelEndpoint';\nexport * from './useNotifications';\nexport * from './usePreferences';\nexport * from './useRemoveSubscription';\nexport * from './useSchedule';\nexport * from './useSubscription';\nexport * from './useSubscriptions';\nexport * from './useTelegramSubscriberLink';\nexport * from './useUpdateSubscription';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAA8F;AAC9F,0BAAsC;AACtC,0BAAc,6BAHd;AAIA,0BAAc,uCAJd;AAKA,0BAAc,wCALd;AAMA,0BAAc,qCANd;AAOA,0BAAc,sCAPd;AAQA,0BAAc,4BARd;AASA,0BAAc,2CATd;AAUA,0BAAc,wCAVd;AAWA,0BAAc,6CAXd;AAYA,0BAAc,2CAZd;AAaA,0BAAc,mCAbd;AAcA,0BAAc,iCAdd;AAeA,0BAAc,wCAfd;AAgBA,0BAAc,8BAhBd;AAiBA,0BAAc,kCAjBd;AAkBA,0BAAc,mCAlBd;AAmBA,0BAAc,4CAnBd;AAoBA,0BAAc,wCApBd;","names":[]}
@@ -1,7 +1,7 @@
1
1
  export * from '@novu/js';
2
- export { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';
2
+ export { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum, pendingActionKey } from '@novu/js';
3
3
  export { NovuProvider, useNovu } from './NovuProvider.cjs';
4
- export { UseAgentChatProps, UseAgentChatResult, useAgentChat } from './useAgentChat.cjs';
4
+ export { UseWebChatProps, UseWebChatResult, useWebChat } from './useWebChat.cjs';
5
5
  export { UseChannelConnectionProps, UseChannelConnectionResult, useChannelConnection } from './useChannelConnection.cjs';
6
6
  export { UseChannelConnectionsProps, UseChannelConnectionsResult, useChannelConnections } from './useChannelConnections.cjs';
7
7
  export { UseChannelEndpointProps, UseChannelEndpointResult, useChannelEndpoint } from './useChannelEndpoint.cjs';
@@ -17,18 +17,19 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/hooks/useAgentChat.ts
21
- var useAgentChat_exports = {};
22
- __export(useAgentChat_exports, {
23
- useAgentChat: () => useAgentChat
20
+ // src/hooks/useWebChat.ts
21
+ var useWebChat_exports = {};
22
+ __export(useWebChat_exports, {
23
+ useWebChat: () => useWebChat
24
24
  });
25
- module.exports = __toCommonJS(useAgentChat_exports);
25
+ module.exports = __toCommonJS(useWebChat_exports);
26
+ var import_js = require("@novu/js");
26
27
  var import_react = require("react");
27
28
  var import_useDataRef = require("./internal/useDataRef.cjs");
28
29
  var import_NovuProvider = require("./NovuProvider.cjs");
29
30
  var EMPTY_SERVER_SNAPSHOT = {
30
31
  key: "ssr",
31
- status: "ready",
32
+ status: "loading",
32
33
  run: { isRunning: false },
33
34
  conversationStatus: "active",
34
35
  pagination: { hasMore: false, status: "idle" },
@@ -91,57 +92,92 @@ function handlePublicationCallbacks(args) {
91
92
  function getCreateFlowKey(agentId, agentHash) {
92
93
  return `${agentId}\0${agentHash ?? ""}`;
93
94
  }
94
- function resolveOwnedRuntime(args) {
95
- const key = getCreateFlowKey(args.agentId, args.agentHash);
96
- const current = args.ownedRuntimeRef.current;
97
- if ((current == null ? void 0 : current.key) === key) {
98
- return current.runtime;
95
+ function getManagedRuntimeKey(agentId, agentHash, conversationIdProp, createEpoch) {
96
+ if (conversationIdProp) {
97
+ return `resume:${agentId}\0${agentHash ?? ""}\0${conversationIdProp}`;
99
98
  }
100
- current == null ? void 0 : current.runtime.dispose();
101
- const result = args.novu.agentChat.conversation({ agentId: args.agentId, agentHash: args.agentHash });
102
- if (!result.ok) {
103
- args.ownedRuntimeRef.current = null;
104
- return null;
99
+ return `${getCreateFlowKey(agentId, agentHash)}\0${createEpoch}`;
100
+ }
101
+ function toNovuError(error) {
102
+ if (error instanceof import_js.NovuError) {
103
+ return error;
104
+ }
105
+ if (error instanceof Error) {
106
+ return new import_js.NovuError("Failed to load Web Chat", error);
105
107
  }
106
- args.ownedRuntimeRef.current = { key, runtime: result.data };
107
- return result.data;
108
+ return new import_js.NovuError("Failed to load Web Chat", new Error(String(error)));
108
109
  }
109
- var useAgentChat = (props) => {
110
- var _a;
110
+ var useWebChat = (props) => {
111
111
  const novu = (0, import_NovuProvider.useNovu)();
112
112
  const propsRef = (0, import_useDataRef.useDataRef)(props);
113
+ const [loadState, setLoadState] = (0, import_react.useState)(() => ({
114
+ novu,
115
+ status: "loading"
116
+ }));
117
+ (0, import_react.useEffect)(() => {
118
+ let cancelled = false;
119
+ if (!novu.isWebChatLoaded) {
120
+ setLoadState({ novu, status: "loading" });
121
+ }
122
+ void novu.loadWebChat().then(() => {
123
+ if (!cancelled) {
124
+ setLoadState({ novu, status: "ready" });
125
+ }
126
+ }).catch((error) => {
127
+ var _a, _b;
128
+ if (cancelled) {
129
+ return;
130
+ }
131
+ const novuError = toNovuError(error);
132
+ (_b = (_a = propsRef.current).onError) == null ? void 0 : _b.call(_a, novuError);
133
+ setLoadState({ novu, status: "error", error: novuError });
134
+ });
135
+ return () => {
136
+ cancelled = true;
137
+ };
138
+ }, [novu, propsRef]);
139
+ const webChatReady = loadState.novu === novu && loadState.status === "ready";
140
+ const webChatLoadError = loadState.novu === novu && loadState.status === "error" ? loadState.error : void 0;
141
+ const isWebChatLoading = loadState.novu !== novu || loadState.status === "loading";
113
142
  const sharedRuntime = "conversation" in props ? props.conversation : void 0;
114
143
  const agentId = (sharedRuntime == null ? void 0 : sharedRuntime.agentId) ?? props.agentId;
115
144
  const conversationIdProp = sharedRuntime ? void 0 : props.conversationId;
116
145
  const agentHash = sharedRuntime ? void 0 : props.agentHash;
117
146
  const ownedRuntimeRef = (0, import_react.useRef)(null);
118
- const cachedRuntime = (0, import_react.useMemo)(() => {
147
+ const [managedRuntime, setManagedRuntime] = (0, import_react.useState)(null);
148
+ const [createEpoch, setCreateEpoch] = (0, import_react.useState)(0);
149
+ const managedRuntimeKey = sharedRuntime ? null : getManagedRuntimeKey(agentId, agentHash, conversationIdProp, createEpoch);
150
+ (0, import_react.useEffect)(() => {
151
+ var _a;
119
152
  if (sharedRuntime) {
120
- return sharedRuntime;
153
+ (_a = ownedRuntimeRef.current) == null ? void 0 : _a.runtime.dispose();
154
+ ownedRuntimeRef.current = null;
155
+ setManagedRuntime(null);
156
+ return;
121
157
  }
122
- if (!conversationIdProp) {
123
- return null;
158
+ if (!webChatReady || !managedRuntimeKey) {
159
+ setManagedRuntime(null);
160
+ return;
124
161
  }
125
- const result = novu.agentChat.conversation({
126
- agentId,
127
- conversationId: conversationIdProp,
128
- agentHash
129
- });
130
- return result.ok ? result.data : null;
131
- }, [sharedRuntime, novu, agentId, conversationIdProp, agentHash]);
132
- if (sharedRuntime || conversationIdProp) {
133
- (_a = ownedRuntimeRef.current) == null ? void 0 : _a.runtime.dispose();
134
- ownedRuntimeRef.current = null;
135
- }
136
- const ownedRuntime = sharedRuntime || conversationIdProp ? null : resolveOwnedRuntime({ novu, agentId, agentHash, ownedRuntimeRef });
137
- const runtime = sharedRuntime ?? cachedRuntime ?? ownedRuntime;
138
- (0, import_react.useEffect)(() => {
162
+ const key = managedRuntimeKey;
163
+ const current = ownedRuntimeRef.current;
164
+ let runtime2;
165
+ if ((current == null ? void 0 : current.novu) === novu && current.key === key) {
166
+ runtime2 = current.runtime;
167
+ } else {
168
+ current == null ? void 0 : current.runtime.dispose();
169
+ runtime2 = conversationIdProp ? novu.webChat.conversation({ agentId, conversationId: conversationIdProp, agentHash }) : novu.webChat.conversation({ agentId, agentHash });
170
+ ownedRuntimeRef.current = { key, novu, runtime: runtime2 };
171
+ }
172
+ setManagedRuntime({ key, runtime: runtime2 });
139
173
  return () => {
140
174
  var _a2;
141
175
  (_a2 = ownedRuntimeRef.current) == null ? void 0 : _a2.runtime.dispose();
142
176
  ownedRuntimeRef.current = null;
177
+ setManagedRuntime(null);
143
178
  };
144
- }, []);
179
+ }, [webChatReady, sharedRuntime, novu, agentId, conversationIdProp, agentHash, createEpoch, managedRuntimeKey]);
180
+ const runtime = sharedRuntime ?? ((managedRuntime == null ? void 0 : managedRuntime.key) === managedRuntimeKey ? managedRuntime.runtime : null);
145
181
  const loadNotifiedRef = (0, import_react.useRef)(false);
146
182
  const replayedActionsRef = (0, import_react.useRef)(false);
147
183
  const notifiedCatchUpErrorRef = (0, import_react.useRef)();
@@ -154,7 +190,7 @@ var useAgentChat = (props) => {
154
190
  }, [runtime]);
155
191
  const subscribe = (0, import_react.useCallback)(
156
192
  (onStoreChange) => {
157
- var _a2, _b;
193
+ var _a, _b;
158
194
  if (!runtime) {
159
195
  return () => {
160
196
  };
@@ -162,7 +198,7 @@ var useAgentChat = (props) => {
162
198
  if (!replayedActionsRef.current) {
163
199
  replayedActionsRef.current = true;
164
200
  for (const action of runtime.getSnapshot().pendingActions) {
165
- (_b = (_a2 = propsRef.current).onActionRequested) == null ? void 0 : _b.call(_a2, action);
201
+ (_b = (_a = propsRef.current).onActionRequested) == null ? void 0 : _b.call(_a, action);
166
202
  }
167
203
  }
168
204
  return runtime.subscribe((snapshot2, meta) => {
@@ -189,26 +225,31 @@ var useAgentChat = (props) => {
189
225
  const snapshot = (0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
190
226
  const callRuntime = (0, import_react.useCallback)(
191
227
  async (action) => {
192
- var _a2, _b;
228
+ var _a, _b, _c, _d;
193
229
  if (!runtime) {
194
- return { error: void 0 };
230
+ const error = webChatLoadError ?? new import_js.NovuError(
231
+ isWebChatLoading ? "Web Chat is still loading" : "Web Chat runtime is unavailable",
232
+ new Error("Web Chat runtime is not ready")
233
+ );
234
+ (_b = (_a = propsRef.current).onError) == null ? void 0 : _b.call(_a, error);
235
+ return { error };
195
236
  }
196
237
  const response = await action(runtime);
197
238
  if (response.error) {
198
- (_b = (_a2 = propsRef.current).onError) == null ? void 0 : _b.call(_a2, response.error);
239
+ (_d = (_c = propsRef.current).onError) == null ? void 0 : _d.call(_c, response.error);
199
240
  }
200
241
  return response;
201
242
  },
202
- [runtime, propsRef]
243
+ [runtime, webChatLoadError, isWebChatLoading, propsRef]
203
244
  );
204
245
  const refetch = (0, import_react.useCallback)(async () => {
205
- var _a2, _b;
246
+ var _a, _b;
206
247
  if (!runtime) {
207
248
  return;
208
249
  }
209
250
  const response = await runtime.load();
210
251
  if (response.data) {
211
- (_b = (_a2 = propsRef.current).onSuccess) == null ? void 0 : _b.call(_a2, {
252
+ (_b = (_a = propsRef.current).onSuccess) == null ? void 0 : _b.call(_a, {
212
253
  conversationId: response.data.conversationId,
213
254
  messages: [...response.data.messages],
214
255
  hasMore: response.data.hasMore
@@ -234,7 +275,10 @@ var useAgentChat = (props) => {
234
275
  }),
235
276
  [snapshot.pagination.status, snapshot.pagination.hasMore, fetchMore]
236
277
  );
237
- const sendMessage = (0, import_react.useCallback)((text) => callRuntime((target) => target.sendMessage(text)), [callRuntime]);
278
+ const sendMessage = (0, import_react.useCallback)(
279
+ (input) => callRuntime((target) => target.sendMessage(input)),
280
+ [callRuntime]
281
+ );
238
282
  const respondToAction = (0, import_react.useCallback)(
239
283
  (args) => callRuntime((target) => target.respondToAction(args)),
240
284
  [callRuntime]
@@ -247,15 +291,20 @@ var useAgentChat = (props) => {
247
291
  (messageId) => callRuntime((target) => target.retryMessage(messageId)),
248
292
  [callRuntime]
249
293
  );
294
+ const startNewConversation = (0, import_react.useCallback)(() => {
295
+ if (sharedRuntime || conversationIdProp) {
296
+ return;
297
+ }
298
+ setCreateEpoch((epoch) => epoch + 1);
299
+ }, [sharedRuntime, conversationIdProp]);
250
300
  return {
251
301
  messages: [...snapshot.messages],
252
302
  pendingActions: [...snapshot.pendingActions],
253
303
  conversationId: snapshot.conversationId,
254
- error: snapshot.error,
255
- isLoading: snapshot.status === "loading",
304
+ error: webChatLoadError ?? snapshot.error,
305
+ isLoading: !webChatLoadError && (isWebChatLoading || snapshot.status === "loading"),
256
306
  isRunning: snapshot.run.isRunning,
257
307
  typing: snapshot.run.typing,
258
- status: snapshot.conversationStatus,
259
308
  conversationStatus: snapshot.conversationStatus,
260
309
  run: snapshot.run,
261
310
  pagination: paginationWithFetch,
@@ -265,11 +314,12 @@ var useAgentChat = (props) => {
265
314
  sendMessage,
266
315
  respondToAction,
267
316
  sendAction,
268
- retryMessage
317
+ retryMessage,
318
+ startNewConversation
269
319
  };
270
320
  };
271
321
  // Annotate the CommonJS export names for ESM import in node:
272
322
  0 && (module.exports = {
273
- useAgentChat
323
+ useWebChat
274
324
  });
275
- //# sourceMappingURL=useAgentChat.cjs.map
325
+ //# sourceMappingURL=useWebChat.cjs.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/**\n * State and actions returned by {@link useWebChat}.\n * `sendMessage`, `respondToAction`, `sendAction`, and `retryMessage` resolve `{ data, error }` and never reject.\n * Inspect `error` on the result, or show hook `error`.\n */\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. Mutations also return `{ error }` for that call. */\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 /**\n * Send a user message. `input` is a string, or `{ text, metadata }`. Creates a conversation when `conversationId` is omitted.\n * Does not throw. Resolves `{ data, error }`. Inspect `error` on the result, or show hook `error`.\n */\n sendMessage: (input: SendMessageInput) => Promise<{\n data?: SendMessageResult;\n error?: NovuError | WebChatPlanLimitError;\n }>;\n /**\n * Resolve a pending `approval`. Pass `approvalId` from `pendingActions` or message parts.\n * Does not throw. Resolves `{ data, error }`. Inspect `error` on the result, or show hook `error`.\n */\n respondToAction: (args: { approvalId: string; decision: AgentToolApprovalDecision }) => Promise<{\n data?: RespondToActionResult;\n error?: NovuError | WebChatPlanLimitError;\n }>;\n /**\n * Click a Card button. Do not use this for tool approval.\n * Does not throw. Resolves `{ data, error }`. Inspect `error` on the result, or show hook `error`.\n */\n sendAction: (args: { actionId: string; sourceMessageId: string; value?: string }) => Promise<{\n data?: SendActionResult;\n error?: NovuError | WebChatPlanLimitError;\n }>;\n /**\n * Resend a message whose `status` is `failed`. Reuses the original idempotency key.\n * Does not throw. Resolves `{ data, error }`. Inspect `error` on the result, or show hook `error`.\n */\n retryMessage: (messageId: string) => Promise<{\n data?: SendMessageResult;\n error?: NovuError | WebChatPlanLimitError;\n }>;\n /**\n * Start a new empty chat for the current `agentId`. The next `sendMessage` creates the server conversation.\n * No-op when `conversationId` or `conversation` is provided.\n */\n startNewConversation: () => void;\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 getManagedRuntimeKey(\n agentId: string,\n agentHash: string | undefined,\n conversationIdProp: string | undefined,\n createEpoch: number\n): string {\n if (conversationIdProp) {\n return `resume:${agentId}\\0${agentHash ?? ''}\\0${conversationIdProp}`;\n }\n\n return `${getCreateFlowKey(agentId, agentHash)}\\0${createEpoch}`;\n}\n\ntype ManagedRuntimeEntry = {\n key: string;\n runtime: AgentConversationRuntime;\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 const [managedRuntime, setManagedRuntime] = useState<ManagedRuntimeEntry | null>(null);\n const [createEpoch, setCreateEpoch] = useState(0);\n const managedRuntimeKey = sharedRuntime\n ? null\n : getManagedRuntimeKey(agentId, agentHash, conversationIdProp, createEpoch);\n\n useEffect(() => {\n if (sharedRuntime) {\n ownedRuntimeRef.current?.runtime.dispose();\n ownedRuntimeRef.current = null;\n setManagedRuntime(null);\n\n return;\n }\n\n if (!webChatReady || !managedRuntimeKey) {\n setManagedRuntime(null);\n\n return;\n }\n\n const key = managedRuntimeKey;\n const current = ownedRuntimeRef.current;\n\n let runtime: AgentConversationRuntime;\n if (current?.novu === novu && current.key === key) {\n runtime = current.runtime;\n } else {\n current?.runtime.dispose();\n runtime = conversationIdProp\n ? novu.webChat.conversation({ agentId, conversationId: conversationIdProp, agentHash })\n : novu.webChat.conversation({ agentId, agentHash });\n ownedRuntimeRef.current = { key, novu, runtime };\n }\n\n setManagedRuntime({ key, runtime });\n\n return () => {\n ownedRuntimeRef.current?.runtime.dispose();\n ownedRuntimeRef.current = null;\n setManagedRuntime(null);\n };\n }, [webChatReady, sharedRuntime, novu, agentId, conversationIdProp, agentHash, createEpoch, managedRuntimeKey]);\n\n const runtime =\n sharedRuntime ?? (managedRuntime?.key === managedRuntimeKey ? managedRuntime.runtime : null);\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: { approvalId: 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 const startNewConversation = useCallback(() => {\n if (sharedRuntime || conversationIdProp) {\n return;\n }\n\n setCreateEpoch((epoch) => epoch + 1);\n }, [sharedRuntime, conversationIdProp]);\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 startNewConversation,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBA,gBAA0B;AAC1B,mBAA+G;AAC/G,wBAA2B;AAC3B,0BAAwB;AA2HxB,IAAM,wBAAwB;AAAA,EAC5B,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;AAzKT;AA0KE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;A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A,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["runtime","_a","snapshot"]}
@@ -0,0 +1,138 @@
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
+ /**
42
+ * State and actions returned by {@link useWebChat}.
43
+ * `sendMessage`, `respondToAction`, `sendAction`, and `retryMessage` resolve `{ data, error }` and never reject.
44
+ * Inspect `error` on the result, or show hook `error`.
45
+ */
46
+ type UseWebChatResult = {
47
+ /** Conversation timeline. */
48
+ messages: AgentMessage[];
49
+ /** Tool approvals and MCP connect items that are still pending. */
50
+ pendingActions: AgentPendingAction[];
51
+ /** Server conversation id after create or resume. */
52
+ conversationId?: string;
53
+ /** Last error from load, send, retry, or action. Mutations also return `{ error }` for that call. */
54
+ error?: NovuError | WebChatPlanLimitError;
55
+ /** True while Web Chat loads and, for an existing conversation, until the first history fetch completes. */
56
+ isLoading: boolean;
57
+ /** True while the agent turn is in progress. Same as `run.isRunning`. */
58
+ isRunning: boolean;
59
+ /** Typing indicator. Same as `run.typing`. Absent when the agent is not typing. */
60
+ typing?: AgentConversationRunSnapshot['typing'];
61
+ /** `'active'` or `'resolved'`. The agent sets `resolved` with `ctx.resolve()`. Not a loading flag. */
62
+ conversationStatus: AgentConversationStatus;
63
+ /** Current agent-run snapshot. */
64
+ run: AgentConversationRunSnapshot;
65
+ /** Older-history control. Not a top-level `hasMore` or `fetchMore`. */
66
+ pagination: WebChatPagination & {
67
+ fetchMore: () => Promise<{
68
+ data?: {
69
+ messages: AgentMessage[];
70
+ hasMore: boolean;
71
+ };
72
+ error?: NovuError;
73
+ }>;
74
+ };
75
+ /** True while reconnect recovery is in progress. */
76
+ isRecovering: boolean;
77
+ /** Set when reconnect recovery fails. Separate from send and fetch `error`. */
78
+ catchUpError?: NovuError;
79
+ /** Reload the newest history page. No-op when there is no conversation id. */
80
+ refetch: () => Promise<void>;
81
+ /**
82
+ * Send a user message. `input` is a string, or `{ text, metadata }`. Creates a conversation when `conversationId` is omitted.
83
+ * Does not throw. Resolves `{ data, error }`. Inspect `error` on the result, or show hook `error`.
84
+ */
85
+ sendMessage: (input: SendMessageInput) => Promise<{
86
+ data?: SendMessageResult;
87
+ error?: NovuError | WebChatPlanLimitError;
88
+ }>;
89
+ /**
90
+ * Resolve a pending `approval`. Pass `approvalId` from `pendingActions` or message parts.
91
+ * Does not throw. Resolves `{ data, error }`. Inspect `error` on the result, or show hook `error`.
92
+ */
93
+ respondToAction: (args: {
94
+ approvalId: string;
95
+ decision: AgentToolApprovalDecision;
96
+ }) => Promise<{
97
+ data?: RespondToActionResult;
98
+ error?: NovuError | WebChatPlanLimitError;
99
+ }>;
100
+ /**
101
+ * Click a Card button. Do not use this for tool approval.
102
+ * Does not throw. Resolves `{ data, error }`. Inspect `error` on the result, or show hook `error`.
103
+ */
104
+ sendAction: (args: {
105
+ actionId: string;
106
+ sourceMessageId: string;
107
+ value?: string;
108
+ }) => Promise<{
109
+ data?: SendActionResult;
110
+ error?: NovuError | WebChatPlanLimitError;
111
+ }>;
112
+ /**
113
+ * Resend a message whose `status` is `failed`. Reuses the original idempotency key.
114
+ * Does not throw. Resolves `{ data, error }`. Inspect `error` on the result, or show hook `error`.
115
+ */
116
+ retryMessage: (messageId: string) => Promise<{
117
+ data?: SendMessageResult;
118
+ error?: NovuError | WebChatPlanLimitError;
119
+ }>;
120
+ /**
121
+ * Start a new empty chat for the current `agentId`. The next `sendMessage` creates the server conversation.
122
+ * No-op when `conversationId` or `conversation` is provided.
123
+ */
124
+ startNewConversation: () => void;
125
+ };
126
+ /**
127
+ * Headless Web Chat client. Use it inside `NovuProvider`.
128
+ *
129
+ * @example
130
+ * ```tsx
131
+ * const { messages, sendMessage, isRunning, isLoading, error } = useWebChat({
132
+ * agentId: 'YOUR_AGENT_IDENTIFIER',
133
+ * });
134
+ * ```
135
+ */
136
+ declare const useWebChat: (props: UseWebChatProps) => UseWebChatResult;
137
+
138
+ export { type UseWebChatProps, type UseWebChatResult, useWebChat };
@@ -37,7 +37,7 @@ __export(index_exports, {
37
37
  SubscriptionPreferences: () => import_components.SubscriptionPreferences,
38
38
  TelegramConnectButton: () => import_components.TelegramConnectButton,
39
39
  WorkflowCriticalityEnum: () => import_js.WorkflowCriticalityEnum,
40
- useAgentChat: () => import_hooks.useAgentChat,
40
+ pendingActionKey: () => import_js.pendingActionKey,
41
41
  useChannelConnection: () => import_hooks.useChannelConnection,
42
42
  useChannelConnections: () => import_hooks.useChannelConnections,
43
43
  useChannelEndpoint: () => import_hooks.useChannelEndpoint,
@@ -53,7 +53,8 @@ __export(index_exports, {
53
53
  useSubscription: () => import_hooks.useSubscription,
54
54
  useSubscriptions: () => import_hooks.useSubscriptions,
55
55
  useTelegramSubscriberLink: () => import_hooks.useTelegramSubscriberLink,
56
- useUpdateSubscription: () => import_hooks.useUpdateSubscription
56
+ useUpdateSubscription: () => import_hooks.useUpdateSubscription,
57
+ useWebChat: () => import_hooks.useWebChat
57
58
  });
58
59
  module.exports = __toCommonJS(index_exports);
59
60
  var import_js = require("@novu/js");
@@ -78,7 +79,7 @@ var import_hooks = require("./hooks/index.cjs");
78
79
  SubscriptionPreferences,
79
80
  TelegramConnectButton,
80
81
  WorkflowCriticalityEnum,
81
- useAgentChat,
82
+ pendingActionKey,
82
83
  useChannelConnection,
83
84
  useChannelConnections,
84
85
  useChannelEndpoint,
@@ -94,6 +95,7 @@ var import_hooks = require("./hooks/index.cjs");
94
95
  useSubscription,
95
96
  useSubscriptions,
96
97
  useTelegramSubscriberLink,
97
- useUpdateSubscription
98
+ useUpdateSubscription,
99
+ useWebChat
98
100
  });
99
101
  //# sourceMappingURL=index.cjs.map
@@ -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 UseAgentChatProps,\n UseAgentChatResult,\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 useAgentChat,\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAA4E;AAiD5E,wBAeO;AAuBP,mBAkBO;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { pendingActionKey, 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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAA8F;AAiD9F,wBAeO;AAuBP,mBAkBO;","names":[]}
@@ -1,5 +1,5 @@
1
1
  export * from '@novu/js';
2
- export { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';
2
+ export { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum, pendingActionKey } from '@novu/js';
3
3
  export { AllLocalization, AllLocalizationKey, ChannelConnectButtonIconKey, ElementStyles, InboxAppearance, InboxAppearanceCallback, InboxAppearanceCallbackFunction, InboxAppearanceCallbackKeys, InboxAppearanceKey, InboxElements, InboxLocalization, InboxLocalizationKey, InboxTheme, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, PreferenceGroups, PreferencesFilter, RouterPush, SubscriptionAppearance, SubscriptionAppearanceCallback, SubscriptionAppearanceCallbackFunction, SubscriptionAppearanceCallbackKeys, SubscriptionAppearanceKey, SubscriptionElements, SubscriptionLocalization, SubscriptionLocalizationKey, SubscriptionTheme, Tab, Variables } from '@novu/js/ui';
4
4
  export { NovuProvider, NovuProviderProps, useNovu } from './hooks/NovuProvider.cjs';
5
5
  export { Bell, BellProps } from './components/Bell.cjs';
@@ -15,7 +15,7 @@ export { Subscription, SubscriptionProps } from './components/subscription/Subsc
15
15
  export { SubscriptionButton, SubscriptionButtonProps } from './components/subscription/SubscriptionButton.cjs';
16
16
  export { SubscriptionPreferences, SubscriptionPreferencesProps } from './components/subscription/SubscriptionPreferences.cjs';
17
17
  export { TelegramConnectButton, TelegramConnectButtonProps } from './components/telegram-connect-button/TelegramConnectButton.cjs';
18
- export { UseAgentChatProps, UseAgentChatResult, useAgentChat } from './hooks/useAgentChat.cjs';
18
+ export { UseWebChatProps, UseWebChatResult, useWebChat } from './hooks/useWebChat.cjs';
19
19
  export { UseChannelConnectionProps, UseChannelConnectionResult, useChannelConnection } from './hooks/useChannelConnection.cjs';
20
20
  export { UseChannelConnectionsProps, UseChannelConnectionsResult, useChannelConnections } from './hooks/useChannelConnections.cjs';
21
21
  export { UseChannelEndpointProps, UseChannelEndpointResult, useChannelEndpoint } from './hooks/useChannelEndpoint.cjs';
@@ -37,7 +37,7 @@ __export(server_exports, {
37
37
  SubscriptionPreferences: () => SubscriptionPreferences,
38
38
  TelegramConnectButton: () => TelegramConnectButton,
39
39
  WorkflowCriticalityEnum: () => import_js.WorkflowCriticalityEnum,
40
- useAgentChat: () => useAgentChat,
40
+ pendingActionKey: () => import_js.pendingActionKey,
41
41
  useCounts: () => useCounts,
42
42
  useCreateSubscription: () => useCreateSubscription,
43
43
  useNotifications: () => useNotifications,
@@ -47,7 +47,8 @@ __export(server_exports, {
47
47
  useSchedule: () => useSchedule,
48
48
  useSubscription: () => useSubscription,
49
49
  useSubscriptions: () => useSubscriptions,
50
- useUpdateSubscription: () => useUpdateSubscription
50
+ useUpdateSubscription: () => useUpdateSubscription,
51
+ useWebChat: () => useWebChat
51
52
  });
52
53
  module.exports = __toCommonJS(server_exports);
53
54
  var import_ShadowRootDetector = require("../components/ShadowRootDetector.cjs");
@@ -92,14 +93,13 @@ function TelegramConnectButton() {
92
93
  function useNovu() {
93
94
  return null;
94
95
  }
95
- function useAgentChat(_) {
96
+ function useWebChat(_) {
96
97
  return {
97
98
  messages: [],
98
99
  pendingActions: [],
99
- isLoading: false,
100
+ isLoading: true,
100
101
  isRunning: false,
101
102
  typing: void 0,
102
- status: "active",
103
103
  conversationStatus: "active",
104
104
  run: { isRunning: false },
105
105
  pagination: {
@@ -113,7 +113,9 @@ function useAgentChat(_) {
113
113
  sendMessage: () => Promise.resolve({ data: void 0, error: void 0 }),
114
114
  respondToAction: () => Promise.resolve({ data: void 0, error: void 0 }),
115
115
  sendAction: () => Promise.resolve({ data: void 0, error: void 0 }),
116
- retryMessage: () => Promise.resolve({ data: void 0, error: void 0 })
116
+ retryMessage: () => Promise.resolve({ data: void 0, error: void 0 }),
117
+ startNewConversation: () => {
118
+ }
117
119
  };
118
120
  }
119
121
  function useCounts(_) {
@@ -204,7 +206,7 @@ function useSubscriptions(_) {
204
206
  SubscriptionPreferences,
205
207
  TelegramConnectButton,
206
208
  WorkflowCriticalityEnum,
207
- useAgentChat,
209
+ pendingActionKey,
208
210
  useCounts,
209
211
  useCreateSubscription,
210
212
  useNotifications,
@@ -214,6 +216,7 @@ function useSubscriptions(_) {
214
216
  useSchedule,
215
217
  useSubscription,
216
218
  useSubscriptions,
217
- useUpdateSubscription
219
+ useUpdateSubscription,
220
+ useWebChat
218
221
  });
219
222
  //# sourceMappingURL=index.cjs.map