@wallavi/widget 1.5.3 → 1.6.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
@@ -88,6 +88,24 @@ interface ChatWidgetConfig {
88
88
  mcpIds?: string[];
89
89
  actionIds?: string[];
90
90
  };
91
+ /**
92
+ * Show the microphone button in the input area.
93
+ * The widget records audio, sends it to /api/chat/transcribe (Whisper),
94
+ * and fills the input with the transcript. The Wallavi engine only sees text.
95
+ * Silently hidden when the browser does not support MediaRecorder.
96
+ */
97
+ enableVoice?: boolean;
98
+ /**
99
+ * When true, the transcript is sent immediately without user review.
100
+ * Default false — transcript fills the input for the user to correct if needed.
101
+ */
102
+ voiceAutoSend?: boolean;
103
+ /**
104
+ * Show the paperclip button to attach files (CSV, TXT, images).
105
+ * Text files are extracted and injected as context into the pipeline.
106
+ * Images are accepted and stored; persistent URLs require Phase 2 storage config.
107
+ */
108
+ enableAttachments?: boolean;
91
109
  }
92
110
  interface ChatWidgetProps extends ChatWidgetConfig {
93
111
  className?: string;
@@ -98,6 +116,30 @@ interface ChatWidgetProps extends ChatWidgetConfig {
98
116
  /** Controls which icon the expand button shows (expand vs minimize). */
99
117
  expanded?: boolean;
100
118
  }
119
+ type AttachmentContentType = "text" | "image" | "unsupported";
120
+ /** Wire-format DTO included in /api/chat/stream request when files are attached. */
121
+ interface AttachmentPayload {
122
+ id: string;
123
+ name: string;
124
+ mimeType: string;
125
+ contentType: AttachmentContentType;
126
+ textContent?: string;
127
+ base64?: string;
128
+ rowCount?: number;
129
+ truncated?: boolean;
130
+ sizeBytes: number;
131
+ }
132
+ type AttachmentStatus = "uploading" | "ready" | "error";
133
+ /** Widget-local state for a pending/uploaded attachment. */
134
+ interface Attachment {
135
+ id: string;
136
+ name: string;
137
+ mimeType: string;
138
+ sizeBytes: number;
139
+ status: AttachmentStatus;
140
+ payload?: AttachmentPayload;
141
+ errorMessage?: string;
142
+ }
101
143
  declare function getContrastColor(hex: string): string;
102
144
  declare function formatToolName(name: string): string;
103
145
 
@@ -158,7 +200,7 @@ interface BubbleWidgetProps extends ChatWidgetConfig {
158
200
  }
159
201
  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;
160
202
 
161
- declare function ChatWidget({ agentId, workspaceId, agentName, displayName, profilePicture, userMessageColor, initialMessages, suggestedMessages, messagePlaceholder, watermark, watermarkLogoUrl, footer, theme, showThinking, regenerateMessage, persist, onNavigate, hideCloseButton, source, userContext, playgroundOverrides, className, onClose, onReset, onExpand, expanded, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
203
+ 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;
162
204
 
163
205
  interface UseChatOptions {
164
206
  agentId: string;
@@ -180,10 +222,50 @@ interface UseChatReturn {
180
222
  streaming: boolean;
181
223
  threadId: string;
182
224
  send: (text?: string) => Promise<void>;
225
+ /** Queue attachments to be included in the next send() call. Cleared automatically after send. */
226
+ queueAttachments: (payloads: AttachmentPayload[]) => void;
183
227
  regenerate: () => Promise<void>;
184
228
  reset: () => void;
185
229
  selectPickerOption: (pickerId: string, paramName: string, value: string, label: string) => Promise<void>;
186
230
  }
187
231
  declare function useChat({ agentId, workspaceId, source, userContext, persist, onNavigate, playgroundOverrides, }: UseChatOptions): UseChatReturn;
188
232
 
189
- export { BubbleWidget, type BubbleWidgetProps, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type Message, type MessagePart, type PageContext, type ToolPart, type UserContext, formatToolName, getContrastColor, useChat };
233
+ type VoiceState = "idle" | "recording" | "transcribing" | "error";
234
+ interface UseVoiceOptions {
235
+ agentId: string;
236
+ /** Defaults to NEXT_PUBLIC_API_URL or Wallavi production. */
237
+ apiUrl?: string;
238
+ /** Called with the final transcript text — wire to useChat.send() or setInput(). */
239
+ onTranscript: (text: string) => void;
240
+ onError?: (message: string) => void;
241
+ }
242
+ interface UseVoiceReturn {
243
+ voiceState: VoiceState;
244
+ /** false when browser doesn't support MediaRecorder or mic access is denied */
245
+ isSupported: boolean;
246
+ start: () => Promise<void>;
247
+ stop: () => void;
248
+ }
249
+ declare function useVoice({ agentId, apiUrl, onTranscript, onError }: UseVoiceOptions): UseVoiceReturn;
250
+
251
+ interface UseAttachmentsOptions {
252
+ agentId: string;
253
+ /** Defaults to NEXT_PUBLIC_API_URL or Wallavi production. */
254
+ apiUrl?: string;
255
+ /** Maximum number of concurrent attachments. Default 5. */
256
+ maxFiles?: number;
257
+ }
258
+ interface UseAttachmentsReturn {
259
+ attachments: Attachment[];
260
+ /** Kick off upload for one or more files. Silently skips if maxFiles reached. */
261
+ attach: (files: FileList | File[]) => void;
262
+ remove: (id: string) => void;
263
+ clear: () => void;
264
+ /** true while any attachment is still uploading */
265
+ isUploading: boolean;
266
+ /** Ready attachments with text content (safe to include in chat request) */
267
+ readyPayloads: AttachmentPayload[];
268
+ }
269
+ declare function useAttachments({ agentId, apiUrl, maxFiles, }: UseAttachmentsOptions): UseAttachmentsReturn;
270
+
271
+ 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 };
package/dist/index.d.ts CHANGED
@@ -88,6 +88,24 @@ interface ChatWidgetConfig {
88
88
  mcpIds?: string[];
89
89
  actionIds?: string[];
90
90
  };
91
+ /**
92
+ * Show the microphone button in the input area.
93
+ * The widget records audio, sends it to /api/chat/transcribe (Whisper),
94
+ * and fills the input with the transcript. The Wallavi engine only sees text.
95
+ * Silently hidden when the browser does not support MediaRecorder.
96
+ */
97
+ enableVoice?: boolean;
98
+ /**
99
+ * When true, the transcript is sent immediately without user review.
100
+ * Default false — transcript fills the input for the user to correct if needed.
101
+ */
102
+ voiceAutoSend?: boolean;
103
+ /**
104
+ * Show the paperclip button to attach files (CSV, TXT, images).
105
+ * Text files are extracted and injected as context into the pipeline.
106
+ * Images are accepted and stored; persistent URLs require Phase 2 storage config.
107
+ */
108
+ enableAttachments?: boolean;
91
109
  }
92
110
  interface ChatWidgetProps extends ChatWidgetConfig {
93
111
  className?: string;
@@ -98,6 +116,30 @@ interface ChatWidgetProps extends ChatWidgetConfig {
98
116
  /** Controls which icon the expand button shows (expand vs minimize). */
99
117
  expanded?: boolean;
100
118
  }
119
+ type AttachmentContentType = "text" | "image" | "unsupported";
120
+ /** Wire-format DTO included in /api/chat/stream request when files are attached. */
121
+ interface AttachmentPayload {
122
+ id: string;
123
+ name: string;
124
+ mimeType: string;
125
+ contentType: AttachmentContentType;
126
+ textContent?: string;
127
+ base64?: string;
128
+ rowCount?: number;
129
+ truncated?: boolean;
130
+ sizeBytes: number;
131
+ }
132
+ type AttachmentStatus = "uploading" | "ready" | "error";
133
+ /** Widget-local state for a pending/uploaded attachment. */
134
+ interface Attachment {
135
+ id: string;
136
+ name: string;
137
+ mimeType: string;
138
+ sizeBytes: number;
139
+ status: AttachmentStatus;
140
+ payload?: AttachmentPayload;
141
+ errorMessage?: string;
142
+ }
101
143
  declare function getContrastColor(hex: string): string;
102
144
  declare function formatToolName(name: string): string;
103
145
 
@@ -158,7 +200,7 @@ interface BubbleWidgetProps extends ChatWidgetConfig {
158
200
  }
159
201
  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;
160
202
 
161
- declare function ChatWidget({ agentId, workspaceId, agentName, displayName, profilePicture, userMessageColor, initialMessages, suggestedMessages, messagePlaceholder, watermark, watermarkLogoUrl, footer, theme, showThinking, regenerateMessage, persist, onNavigate, hideCloseButton, source, userContext, playgroundOverrides, className, onClose, onReset, onExpand, expanded, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
203
+ 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;
162
204
 
163
205
  interface UseChatOptions {
164
206
  agentId: string;
@@ -180,10 +222,50 @@ interface UseChatReturn {
180
222
  streaming: boolean;
181
223
  threadId: string;
182
224
  send: (text?: string) => Promise<void>;
225
+ /** Queue attachments to be included in the next send() call. Cleared automatically after send. */
226
+ queueAttachments: (payloads: AttachmentPayload[]) => void;
183
227
  regenerate: () => Promise<void>;
184
228
  reset: () => void;
185
229
  selectPickerOption: (pickerId: string, paramName: string, value: string, label: string) => Promise<void>;
186
230
  }
187
231
  declare function useChat({ agentId, workspaceId, source, userContext, persist, onNavigate, playgroundOverrides, }: UseChatOptions): UseChatReturn;
188
232
 
189
- export { BubbleWidget, type BubbleWidgetProps, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type Message, type MessagePart, type PageContext, type ToolPart, type UserContext, formatToolName, getContrastColor, useChat };
233
+ type VoiceState = "idle" | "recording" | "transcribing" | "error";
234
+ interface UseVoiceOptions {
235
+ agentId: string;
236
+ /** Defaults to NEXT_PUBLIC_API_URL or Wallavi production. */
237
+ apiUrl?: string;
238
+ /** Called with the final transcript text — wire to useChat.send() or setInput(). */
239
+ onTranscript: (text: string) => void;
240
+ onError?: (message: string) => void;
241
+ }
242
+ interface UseVoiceReturn {
243
+ voiceState: VoiceState;
244
+ /** false when browser doesn't support MediaRecorder or mic access is denied */
245
+ isSupported: boolean;
246
+ start: () => Promise<void>;
247
+ stop: () => void;
248
+ }
249
+ declare function useVoice({ agentId, apiUrl, onTranscript, onError }: UseVoiceOptions): UseVoiceReturn;
250
+
251
+ interface UseAttachmentsOptions {
252
+ agentId: string;
253
+ /** Defaults to NEXT_PUBLIC_API_URL or Wallavi production. */
254
+ apiUrl?: string;
255
+ /** Maximum number of concurrent attachments. Default 5. */
256
+ maxFiles?: number;
257
+ }
258
+ interface UseAttachmentsReturn {
259
+ attachments: Attachment[];
260
+ /** Kick off upload for one or more files. Silently skips if maxFiles reached. */
261
+ attach: (files: FileList | File[]) => void;
262
+ remove: (id: string) => void;
263
+ clear: () => void;
264
+ /** true while any attachment is still uploading */
265
+ isUploading: boolean;
266
+ /** Ready attachments with text content (safe to include in chat request) */
267
+ readyPayloads: AttachmentPayload[];
268
+ }
269
+ declare function useAttachments({ agentId, apiUrl, maxFiles, }: UseAttachmentsOptions): UseAttachmentsReturn;
270
+
271
+ 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 };