@wallavi/widget 1.5.3 → 1.6.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/index.d.mts CHANGED
@@ -32,6 +32,8 @@ type Message = {
32
32
  id: string;
33
33
  role: "user" | "assistant";
34
34
  parts: MessagePart[];
35
+ /** Files the user attached to this message — stored for display in the chat thread. */
36
+ attachments?: AttachmentPayload[];
35
37
  };
36
38
  interface PageContext {
37
39
  /** Current URL or path (e.g. "/dashboard/agent/abc/agent-studio") */
@@ -88,6 +90,24 @@ interface ChatWidgetConfig {
88
90
  mcpIds?: string[];
89
91
  actionIds?: string[];
90
92
  };
93
+ /**
94
+ * Show the microphone button in the input area.
95
+ * The widget records audio, sends it to /api/chat/transcribe (Whisper),
96
+ * and fills the input with the transcript. The Wallavi engine only sees text.
97
+ * Silently hidden when the browser does not support MediaRecorder.
98
+ */
99
+ enableVoice?: boolean;
100
+ /**
101
+ * When true, the transcript is sent immediately without user review.
102
+ * Default false — transcript fills the input for the user to correct if needed.
103
+ */
104
+ voiceAutoSend?: boolean;
105
+ /**
106
+ * Show the paperclip button and enable drag-and-drop / clipboard-paste for file attachments.
107
+ * Supported types: CSV, TXT, PDF (text extracted as context), JPG, PNG, WebP, GIF (stored in Vercel Blob).
108
+ * Default: false.
109
+ */
110
+ enableAttachments?: boolean;
91
111
  }
92
112
  interface ChatWidgetProps extends ChatWidgetConfig {
93
113
  className?: string;
@@ -98,6 +118,32 @@ interface ChatWidgetProps extends ChatWidgetConfig {
98
118
  /** Controls which icon the expand button shows (expand vs minimize). */
99
119
  expanded?: boolean;
100
120
  }
121
+ type AttachmentContentType = "text" | "image" | "unsupported";
122
+ /** Wire-format DTO included in /api/chat/stream request when files are attached. */
123
+ interface AttachmentPayload {
124
+ id: string;
125
+ name: string;
126
+ mimeType: string;
127
+ contentType: AttachmentContentType;
128
+ textContent?: string;
129
+ base64?: string;
130
+ /** Persistent public URL — set by upload.ts when Vercel Blob is configured. */
131
+ url?: string;
132
+ rowCount?: number;
133
+ truncated?: boolean;
134
+ sizeBytes: number;
135
+ }
136
+ type AttachmentStatus = "uploading" | "ready" | "error";
137
+ /** Widget-local state for a pending/uploaded attachment. */
138
+ interface Attachment {
139
+ id: string;
140
+ name: string;
141
+ mimeType: string;
142
+ sizeBytes: number;
143
+ status: AttachmentStatus;
144
+ payload?: AttachmentPayload;
145
+ errorMessage?: string;
146
+ }
101
147
  declare function getContrastColor(hex: string): string;
102
148
  declare function formatToolName(name: string): string;
103
149
 
@@ -158,7 +204,7 @@ interface BubbleWidgetProps extends ChatWidgetConfig {
158
204
  }
159
205
  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
206
 
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;
207
+ 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
208
 
163
209
  interface UseChatOptions {
164
210
  agentId: string;
@@ -180,10 +226,50 @@ interface UseChatReturn {
180
226
  streaming: boolean;
181
227
  threadId: string;
182
228
  send: (text?: string) => Promise<void>;
229
+ /** Queue attachments to be included in the next send() call. Cleared automatically after send. */
230
+ queueAttachments: (payloads: AttachmentPayload[]) => void;
183
231
  regenerate: () => Promise<void>;
184
232
  reset: () => void;
185
233
  selectPickerOption: (pickerId: string, paramName: string, value: string, label: string) => Promise<void>;
186
234
  }
187
235
  declare function useChat({ agentId, workspaceId, source, userContext, persist, onNavigate, playgroundOverrides, }: UseChatOptions): UseChatReturn;
188
236
 
189
- export { BubbleWidget, type BubbleWidgetProps, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type Message, type MessagePart, type PageContext, type ToolPart, type UserContext, formatToolName, getContrastColor, useChat };
237
+ type VoiceState = "idle" | "recording" | "transcribing" | "error";
238
+ interface UseVoiceOptions {
239
+ agentId: string;
240
+ /** Defaults to NEXT_PUBLIC_API_URL or Wallavi production. */
241
+ apiUrl?: string;
242
+ /** Called with the final transcript text — wire to useChat.send() or setInput(). */
243
+ onTranscript: (text: string) => void;
244
+ onError?: (message: string) => void;
245
+ }
246
+ interface UseVoiceReturn {
247
+ voiceState: VoiceState;
248
+ /** false when browser doesn't support MediaRecorder or mic access is denied */
249
+ isSupported: boolean;
250
+ start: () => Promise<void>;
251
+ stop: () => void;
252
+ }
253
+ declare function useVoice({ agentId, apiUrl, onTranscript, onError }: UseVoiceOptions): UseVoiceReturn;
254
+
255
+ interface UseAttachmentsOptions {
256
+ agentId: string;
257
+ /** Defaults to NEXT_PUBLIC_API_URL or Wallavi production. */
258
+ apiUrl?: string;
259
+ /** Maximum number of concurrent attachments. Default 5. */
260
+ maxFiles?: number;
261
+ }
262
+ interface UseAttachmentsReturn {
263
+ attachments: Attachment[];
264
+ /** Kick off upload for one or more files. Silently skips if maxFiles reached. */
265
+ attach: (files: FileList | File[]) => void;
266
+ remove: (id: string) => void;
267
+ clear: () => void;
268
+ /** true while any attachment is still uploading */
269
+ isUploading: boolean;
270
+ /** Ready attachments with text content (safe to include in chat request) */
271
+ readyPayloads: AttachmentPayload[];
272
+ }
273
+ declare function useAttachments({ agentId, apiUrl, maxFiles, }: UseAttachmentsOptions): UseAttachmentsReturn;
274
+
275
+ 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
@@ -32,6 +32,8 @@ type Message = {
32
32
  id: string;
33
33
  role: "user" | "assistant";
34
34
  parts: MessagePart[];
35
+ /** Files the user attached to this message — stored for display in the chat thread. */
36
+ attachments?: AttachmentPayload[];
35
37
  };
36
38
  interface PageContext {
37
39
  /** Current URL or path (e.g. "/dashboard/agent/abc/agent-studio") */
@@ -88,6 +90,24 @@ interface ChatWidgetConfig {
88
90
  mcpIds?: string[];
89
91
  actionIds?: string[];
90
92
  };
93
+ /**
94
+ * Show the microphone button in the input area.
95
+ * The widget records audio, sends it to /api/chat/transcribe (Whisper),
96
+ * and fills the input with the transcript. The Wallavi engine only sees text.
97
+ * Silently hidden when the browser does not support MediaRecorder.
98
+ */
99
+ enableVoice?: boolean;
100
+ /**
101
+ * When true, the transcript is sent immediately without user review.
102
+ * Default false — transcript fills the input for the user to correct if needed.
103
+ */
104
+ voiceAutoSend?: boolean;
105
+ /**
106
+ * Show the paperclip button and enable drag-and-drop / clipboard-paste for file attachments.
107
+ * Supported types: CSV, TXT, PDF (text extracted as context), JPG, PNG, WebP, GIF (stored in Vercel Blob).
108
+ * Default: false.
109
+ */
110
+ enableAttachments?: boolean;
91
111
  }
92
112
  interface ChatWidgetProps extends ChatWidgetConfig {
93
113
  className?: string;
@@ -98,6 +118,32 @@ interface ChatWidgetProps extends ChatWidgetConfig {
98
118
  /** Controls which icon the expand button shows (expand vs minimize). */
99
119
  expanded?: boolean;
100
120
  }
121
+ type AttachmentContentType = "text" | "image" | "unsupported";
122
+ /** Wire-format DTO included in /api/chat/stream request when files are attached. */
123
+ interface AttachmentPayload {
124
+ id: string;
125
+ name: string;
126
+ mimeType: string;
127
+ contentType: AttachmentContentType;
128
+ textContent?: string;
129
+ base64?: string;
130
+ /** Persistent public URL — set by upload.ts when Vercel Blob is configured. */
131
+ url?: string;
132
+ rowCount?: number;
133
+ truncated?: boolean;
134
+ sizeBytes: number;
135
+ }
136
+ type AttachmentStatus = "uploading" | "ready" | "error";
137
+ /** Widget-local state for a pending/uploaded attachment. */
138
+ interface Attachment {
139
+ id: string;
140
+ name: string;
141
+ mimeType: string;
142
+ sizeBytes: number;
143
+ status: AttachmentStatus;
144
+ payload?: AttachmentPayload;
145
+ errorMessage?: string;
146
+ }
101
147
  declare function getContrastColor(hex: string): string;
102
148
  declare function formatToolName(name: string): string;
103
149
 
@@ -158,7 +204,7 @@ interface BubbleWidgetProps extends ChatWidgetConfig {
158
204
  }
159
205
  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
206
 
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;
207
+ 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
208
 
163
209
  interface UseChatOptions {
164
210
  agentId: string;
@@ -180,10 +226,50 @@ interface UseChatReturn {
180
226
  streaming: boolean;
181
227
  threadId: string;
182
228
  send: (text?: string) => Promise<void>;
229
+ /** Queue attachments to be included in the next send() call. Cleared automatically after send. */
230
+ queueAttachments: (payloads: AttachmentPayload[]) => void;
183
231
  regenerate: () => Promise<void>;
184
232
  reset: () => void;
185
233
  selectPickerOption: (pickerId: string, paramName: string, value: string, label: string) => Promise<void>;
186
234
  }
187
235
  declare function useChat({ agentId, workspaceId, source, userContext, persist, onNavigate, playgroundOverrides, }: UseChatOptions): UseChatReturn;
188
236
 
189
- export { BubbleWidget, type BubbleWidgetProps, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type Message, type MessagePart, type PageContext, type ToolPart, type UserContext, formatToolName, getContrastColor, useChat };
237
+ type VoiceState = "idle" | "recording" | "transcribing" | "error";
238
+ interface UseVoiceOptions {
239
+ agentId: string;
240
+ /** Defaults to NEXT_PUBLIC_API_URL or Wallavi production. */
241
+ apiUrl?: string;
242
+ /** Called with the final transcript text — wire to useChat.send() or setInput(). */
243
+ onTranscript: (text: string) => void;
244
+ onError?: (message: string) => void;
245
+ }
246
+ interface UseVoiceReturn {
247
+ voiceState: VoiceState;
248
+ /** false when browser doesn't support MediaRecorder or mic access is denied */
249
+ isSupported: boolean;
250
+ start: () => Promise<void>;
251
+ stop: () => void;
252
+ }
253
+ declare function useVoice({ agentId, apiUrl, onTranscript, onError }: UseVoiceOptions): UseVoiceReturn;
254
+
255
+ interface UseAttachmentsOptions {
256
+ agentId: string;
257
+ /** Defaults to NEXT_PUBLIC_API_URL or Wallavi production. */
258
+ apiUrl?: string;
259
+ /** Maximum number of concurrent attachments. Default 5. */
260
+ maxFiles?: number;
261
+ }
262
+ interface UseAttachmentsReturn {
263
+ attachments: Attachment[];
264
+ /** Kick off upload for one or more files. Silently skips if maxFiles reached. */
265
+ attach: (files: FileList | File[]) => void;
266
+ remove: (id: string) => void;
267
+ clear: () => void;
268
+ /** true while any attachment is still uploading */
269
+ isUploading: boolean;
270
+ /** Ready attachments with text content (safe to include in chat request) */
271
+ readyPayloads: AttachmentPayload[];
272
+ }
273
+ declare function useAttachments({ agentId, apiUrl, maxFiles, }: UseAttachmentsOptions): UseAttachmentsReturn;
274
+
275
+ 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 };