@wallavi/widget 1.6.7 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -66,6 +66,27 @@ interface UserContext {
66
66
  pageContext?: PageContext;
67
67
  metadata?: Record<string, unknown>;
68
68
  }
69
+ /**
70
+ * Plug-in backend for non-AI modes (e.g. human support chat).
71
+ * When provided, ChatWidget/useChat skip all Wallavi AI API calls and
72
+ * use these values directly — same UI, different message source.
73
+ */
74
+ interface CustomBackend {
75
+ messages: Message[];
76
+ streaming: boolean;
77
+ send: (text: string, attachments?: AttachmentPayload[]) => Promise<void>;
78
+ reset?: () => void;
79
+ /** Current chat mode — used to display a status indicator in the widget. */
80
+ mode?: "ai" | "human";
81
+ /** Optional action button rendered between messages and input (e.g. "Talk to a human"). */
82
+ footerAction?: {
83
+ label: string;
84
+ sublabel?: string;
85
+ icon?: "human" | "ai";
86
+ onClick: () => Promise<void>;
87
+ loading?: boolean;
88
+ };
89
+ }
69
90
  interface ChatWidgetConfig {
70
91
  agentId: string;
71
92
  workspaceId?: string;
@@ -120,6 +141,8 @@ interface ChatWidgetConfig {
120
141
  * Default: false.
121
142
  */
122
143
  enableAttachments?: boolean;
144
+ /** When set, bypasses Wallavi AI and routes messages through this backend instead. */
145
+ customBackend?: CustomBackend;
123
146
  }
124
147
  interface ChatWidgetProps extends ChatWidgetConfig {
125
148
  className?: string;
@@ -129,6 +152,8 @@ interface ChatWidgetProps extends ChatWidgetConfig {
129
152
  onExpand?: () => void;
130
153
  /** Controls which icon the expand button shows (expand vs minimize). */
131
154
  expanded?: boolean;
155
+ /** When true, removes border-radius, border, and shadow — use when ChatWidget is rendered inside an iframe whose container already provides those styles. */
156
+ embedded?: boolean;
132
157
  }
133
158
  type AttachmentContentType = "text" | "image" | "unsupported";
134
159
  /** Wire-format DTO included in /api/chat/stream request when files are attached. */
@@ -159,7 +184,18 @@ interface Attachment {
159
184
  declare function getContrastColor(hex: string): string;
160
185
  declare function formatToolName(name: string): string;
161
186
 
162
- interface BubbleWidgetProps extends ChatWidgetConfig {
187
+ interface BubbleWidgetProps extends Partial<ChatWidgetConfig> {
188
+ /**
189
+ * Inbox token from Wallavi Support dashboard.
190
+ * When provided, the widget connects to the support inbox (human agents + optional AI)
191
+ * instead of a direct AI agent. Mutually exclusive with agentId.
192
+ */
193
+ inboxToken?: string;
194
+ /**
195
+ * Base URL of the Wallavi app. Only needed when using inboxToken from an external domain.
196
+ * @default "https://app.wallavi.com"
197
+ */
198
+ supportApiBase?: string;
163
199
  /** Where the bubble is anchored. Default: "bottom-right" */
164
200
  position?: "bottom-right" | "bottom-left";
165
201
  /** Chat panel width in px. Default: 360 */
@@ -213,10 +249,21 @@ interface BubbleWidgetProps extends ChatWidgetConfig {
213
249
  * Use together with isOpen to fully control open/close from outside.
214
250
  */
215
251
  onOpenChange?: (open: boolean) => void;
252
+ /**
253
+ * Label for the footer button shown while AI mode is active (prompts user to escalate).
254
+ * @default "Hablar con un agente"
255
+ */
256
+ requestHumanLabel?: string;
257
+ /**
258
+ * Label for the footer button shown while a human agent is handling the chat.
259
+ * When omitted the button is not rendered and the user cannot return to AI.
260
+ * @example "Volver a chatear con la IA"
261
+ */
262
+ returnToAiLabel?: string;
216
263
  }
217
- declare function BubbleWidget({ position: positionProp, width: widthProp, height: heightProp, expandedWidth, expandedHeight, keyboardShortcut: keyboardShortcutProp, shortcutKey, autoOpen: autoOpenProp, bubbleIconUrl: bubbleIconUrlProp, bubbleSize: bubbleSizeProp, panelClassName, autoConfig, hideBubble, isOpen: isOpenProp, onOpenChange, ...chatProps }: BubbleWidgetProps): react_jsx_runtime.JSX.Element;
264
+ declare function BubbleWidget({ inboxToken, supportApiBase, requestHumanLabel, returnToAiLabel, position: positionProp, width: widthProp, height: heightProp, expandedWidth, expandedHeight, keyboardShortcut: keyboardShortcutProp, shortcutKey, autoOpen: autoOpenProp, bubbleIconUrl: bubbleIconUrlProp, bubbleSize: bubbleSizeProp, panelClassName, autoConfig, hideBubble, isOpen: isOpenProp, onOpenChange, ...chatProps }: BubbleWidgetProps): react_jsx_runtime.JSX.Element;
218
265
 
219
- declare function ChatWidget({ agentId, workspaceId, agentName, displayName, profilePicture, userMessageColor, initialMessages, suggestedMessages, messagePlaceholder, watermark, watermarkLogoUrl, footer, theme, showThinking, regenerateMessage, persist, onNavigate, hideCloseButton, source, userContext, playgroundOverrides, enableVoice, voiceAutoSend, enableAttachments, className, onClose, onReset, onExpand, expanded, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
266
+ declare function ChatWidget({ agentId, workspaceId, agentName, displayName, profilePicture, userMessageColor, initialMessages, suggestedMessages, messagePlaceholder, watermark, watermarkLogoUrl, footer, theme, showThinking, regenerateMessage, persist, onNavigate, hideCloseButton, source, userContext, playgroundOverrides, enableVoice, voiceAutoSend, enableAttachments, customBackend, className, onClose, onReset, onExpand, expanded, embedded, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
220
267
 
221
268
  interface UseChatOptions {
222
269
  agentId: string;
@@ -230,6 +277,7 @@ interface UseChatOptions {
230
277
  mcpIds?: string[];
231
278
  actionIds?: string[];
232
279
  };
280
+ customBackend?: CustomBackend;
233
281
  }
234
282
  interface UseChatReturn {
235
283
  messages: Message[];
@@ -244,7 +292,29 @@ interface UseChatReturn {
244
292
  reset: () => void;
245
293
  selectPickerOption: (pickerId: string, paramName: string, value: string, label: string) => Promise<void>;
246
294
  }
247
- declare function useChat({ agentId, workspaceId, source, userContext, persist, onNavigate, playgroundOverrides, }: UseChatOptions): UseChatReturn;
295
+ declare function useChat({ agentId, workspaceId, source, userContext, persist, onNavigate, playgroundOverrides, customBackend, }: UseChatOptions): UseChatReturn;
296
+
297
+ interface UseSupportChatOptions {
298
+ /** Inbox token from Wallavi Support dashboard. */
299
+ inboxToken: string;
300
+ /**
301
+ * Base URL of the Wallavi app that hosts the support-chat API routes.
302
+ * @default "https://app.wallavi.com"
303
+ */
304
+ apiBase?: string;
305
+ /**
306
+ * Label for the footer button shown when AI mode is active.
307
+ * @default "Hablar con un agente"
308
+ */
309
+ requestHumanLabel?: string;
310
+ /**
311
+ * Label for the footer button shown when human agent mode is active.
312
+ * If not set, no "return to AI" button is shown.
313
+ * @example "Volver a chatear con la IA"
314
+ */
315
+ returnToAiLabel?: string;
316
+ }
317
+ declare function useSupportChat({ inboxToken, apiBase, requestHumanLabel, returnToAiLabel, }: UseSupportChatOptions): CustomBackend;
248
318
 
249
319
  type VoiceState = "idle" | "recording" | "transcribing" | "error";
250
320
  interface UseVoiceOptions {
@@ -284,4 +354,4 @@ interface UseAttachmentsReturn {
284
354
  }
285
355
  declare function useAttachments({ agentId, apiUrl, maxFiles, }: UseAttachmentsOptions): UseAttachmentsReturn;
286
356
 
287
- export { type Attachment, type AttachmentContentType, type AttachmentPayload, type AttachmentStatus, BubbleWidget, type BubbleWidgetProps, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type Message, type MessagePart, type PageContext, type ToolPart, type UseAttachmentsOptions, type UseAttachmentsReturn, type UseVoiceOptions, type UseVoiceReturn, type UserContext, type VoiceState, formatToolName, getContrastColor, useAttachments, useChat, useVoice };
357
+ export { type Attachment, type AttachmentContentType, type AttachmentPayload, type AttachmentStatus, BubbleWidget, type BubbleWidgetProps, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type CustomBackend, type Message, type MessagePart, type PageContext, type ToolPart, type UseAttachmentsOptions, type UseAttachmentsReturn, type UseSupportChatOptions, type UseVoiceOptions, type UseVoiceReturn, type UserContext, type VoiceState, formatToolName, getContrastColor, useAttachments, useChat, useSupportChat, useVoice };
package/dist/index.d.ts CHANGED
@@ -66,6 +66,27 @@ interface UserContext {
66
66
  pageContext?: PageContext;
67
67
  metadata?: Record<string, unknown>;
68
68
  }
69
+ /**
70
+ * Plug-in backend for non-AI modes (e.g. human support chat).
71
+ * When provided, ChatWidget/useChat skip all Wallavi AI API calls and
72
+ * use these values directly — same UI, different message source.
73
+ */
74
+ interface CustomBackend {
75
+ messages: Message[];
76
+ streaming: boolean;
77
+ send: (text: string, attachments?: AttachmentPayload[]) => Promise<void>;
78
+ reset?: () => void;
79
+ /** Current chat mode — used to display a status indicator in the widget. */
80
+ mode?: "ai" | "human";
81
+ /** Optional action button rendered between messages and input (e.g. "Talk to a human"). */
82
+ footerAction?: {
83
+ label: string;
84
+ sublabel?: string;
85
+ icon?: "human" | "ai";
86
+ onClick: () => Promise<void>;
87
+ loading?: boolean;
88
+ };
89
+ }
69
90
  interface ChatWidgetConfig {
70
91
  agentId: string;
71
92
  workspaceId?: string;
@@ -120,6 +141,8 @@ interface ChatWidgetConfig {
120
141
  * Default: false.
121
142
  */
122
143
  enableAttachments?: boolean;
144
+ /** When set, bypasses Wallavi AI and routes messages through this backend instead. */
145
+ customBackend?: CustomBackend;
123
146
  }
124
147
  interface ChatWidgetProps extends ChatWidgetConfig {
125
148
  className?: string;
@@ -129,6 +152,8 @@ interface ChatWidgetProps extends ChatWidgetConfig {
129
152
  onExpand?: () => void;
130
153
  /** Controls which icon the expand button shows (expand vs minimize). */
131
154
  expanded?: boolean;
155
+ /** When true, removes border-radius, border, and shadow — use when ChatWidget is rendered inside an iframe whose container already provides those styles. */
156
+ embedded?: boolean;
132
157
  }
133
158
  type AttachmentContentType = "text" | "image" | "unsupported";
134
159
  /** Wire-format DTO included in /api/chat/stream request when files are attached. */
@@ -159,7 +184,18 @@ interface Attachment {
159
184
  declare function getContrastColor(hex: string): string;
160
185
  declare function formatToolName(name: string): string;
161
186
 
162
- interface BubbleWidgetProps extends ChatWidgetConfig {
187
+ interface BubbleWidgetProps extends Partial<ChatWidgetConfig> {
188
+ /**
189
+ * Inbox token from Wallavi Support dashboard.
190
+ * When provided, the widget connects to the support inbox (human agents + optional AI)
191
+ * instead of a direct AI agent. Mutually exclusive with agentId.
192
+ */
193
+ inboxToken?: string;
194
+ /**
195
+ * Base URL of the Wallavi app. Only needed when using inboxToken from an external domain.
196
+ * @default "https://app.wallavi.com"
197
+ */
198
+ supportApiBase?: string;
163
199
  /** Where the bubble is anchored. Default: "bottom-right" */
164
200
  position?: "bottom-right" | "bottom-left";
165
201
  /** Chat panel width in px. Default: 360 */
@@ -213,10 +249,21 @@ interface BubbleWidgetProps extends ChatWidgetConfig {
213
249
  * Use together with isOpen to fully control open/close from outside.
214
250
  */
215
251
  onOpenChange?: (open: boolean) => void;
252
+ /**
253
+ * Label for the footer button shown while AI mode is active (prompts user to escalate).
254
+ * @default "Hablar con un agente"
255
+ */
256
+ requestHumanLabel?: string;
257
+ /**
258
+ * Label for the footer button shown while a human agent is handling the chat.
259
+ * When omitted the button is not rendered and the user cannot return to AI.
260
+ * @example "Volver a chatear con la IA"
261
+ */
262
+ returnToAiLabel?: string;
216
263
  }
217
- declare function BubbleWidget({ position: positionProp, width: widthProp, height: heightProp, expandedWidth, expandedHeight, keyboardShortcut: keyboardShortcutProp, shortcutKey, autoOpen: autoOpenProp, bubbleIconUrl: bubbleIconUrlProp, bubbleSize: bubbleSizeProp, panelClassName, autoConfig, hideBubble, isOpen: isOpenProp, onOpenChange, ...chatProps }: BubbleWidgetProps): react_jsx_runtime.JSX.Element;
264
+ declare function BubbleWidget({ inboxToken, supportApiBase, requestHumanLabel, returnToAiLabel, position: positionProp, width: widthProp, height: heightProp, expandedWidth, expandedHeight, keyboardShortcut: keyboardShortcutProp, shortcutKey, autoOpen: autoOpenProp, bubbleIconUrl: bubbleIconUrlProp, bubbleSize: bubbleSizeProp, panelClassName, autoConfig, hideBubble, isOpen: isOpenProp, onOpenChange, ...chatProps }: BubbleWidgetProps): react_jsx_runtime.JSX.Element;
218
265
 
219
- declare function ChatWidget({ agentId, workspaceId, agentName, displayName, profilePicture, userMessageColor, initialMessages, suggestedMessages, messagePlaceholder, watermark, watermarkLogoUrl, footer, theme, showThinking, regenerateMessage, persist, onNavigate, hideCloseButton, source, userContext, playgroundOverrides, enableVoice, voiceAutoSend, enableAttachments, className, onClose, onReset, onExpand, expanded, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
266
+ declare function ChatWidget({ agentId, workspaceId, agentName, displayName, profilePicture, userMessageColor, initialMessages, suggestedMessages, messagePlaceholder, watermark, watermarkLogoUrl, footer, theme, showThinking, regenerateMessage, persist, onNavigate, hideCloseButton, source, userContext, playgroundOverrides, enableVoice, voiceAutoSend, enableAttachments, customBackend, className, onClose, onReset, onExpand, expanded, embedded, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
220
267
 
221
268
  interface UseChatOptions {
222
269
  agentId: string;
@@ -230,6 +277,7 @@ interface UseChatOptions {
230
277
  mcpIds?: string[];
231
278
  actionIds?: string[];
232
279
  };
280
+ customBackend?: CustomBackend;
233
281
  }
234
282
  interface UseChatReturn {
235
283
  messages: Message[];
@@ -244,7 +292,29 @@ interface UseChatReturn {
244
292
  reset: () => void;
245
293
  selectPickerOption: (pickerId: string, paramName: string, value: string, label: string) => Promise<void>;
246
294
  }
247
- declare function useChat({ agentId, workspaceId, source, userContext, persist, onNavigate, playgroundOverrides, }: UseChatOptions): UseChatReturn;
295
+ declare function useChat({ agentId, workspaceId, source, userContext, persist, onNavigate, playgroundOverrides, customBackend, }: UseChatOptions): UseChatReturn;
296
+
297
+ interface UseSupportChatOptions {
298
+ /** Inbox token from Wallavi Support dashboard. */
299
+ inboxToken: string;
300
+ /**
301
+ * Base URL of the Wallavi app that hosts the support-chat API routes.
302
+ * @default "https://app.wallavi.com"
303
+ */
304
+ apiBase?: string;
305
+ /**
306
+ * Label for the footer button shown when AI mode is active.
307
+ * @default "Hablar con un agente"
308
+ */
309
+ requestHumanLabel?: string;
310
+ /**
311
+ * Label for the footer button shown when human agent mode is active.
312
+ * If not set, no "return to AI" button is shown.
313
+ * @example "Volver a chatear con la IA"
314
+ */
315
+ returnToAiLabel?: string;
316
+ }
317
+ declare function useSupportChat({ inboxToken, apiBase, requestHumanLabel, returnToAiLabel, }: UseSupportChatOptions): CustomBackend;
248
318
 
249
319
  type VoiceState = "idle" | "recording" | "transcribing" | "error";
250
320
  interface UseVoiceOptions {
@@ -284,4 +354,4 @@ interface UseAttachmentsReturn {
284
354
  }
285
355
  declare function useAttachments({ agentId, apiUrl, maxFiles, }: UseAttachmentsOptions): UseAttachmentsReturn;
286
356
 
287
- export { type Attachment, type AttachmentContentType, type AttachmentPayload, type AttachmentStatus, BubbleWidget, type BubbleWidgetProps, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type Message, type MessagePart, type PageContext, type ToolPart, type UseAttachmentsOptions, type UseAttachmentsReturn, type UseVoiceOptions, type UseVoiceReturn, type UserContext, type VoiceState, formatToolName, getContrastColor, useAttachments, useChat, useVoice };
357
+ export { type Attachment, type AttachmentContentType, type AttachmentPayload, type AttachmentStatus, BubbleWidget, type BubbleWidgetProps, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type CustomBackend, type Message, type MessagePart, type PageContext, type ToolPart, type UseAttachmentsOptions, type UseAttachmentsReturn, type UseSupportChatOptions, type UseVoiceOptions, type UseVoiceReturn, type UserContext, type VoiceState, formatToolName, getContrastColor, useAttachments, useChat, useSupportChat, useVoice };