vanilla-agent 1.23.0 → 1.25.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.cts CHANGED
@@ -146,6 +146,23 @@ type AgentWidgetMessageFeedback = {
146
146
  };
147
147
  /**
148
148
  * Configuration for message action buttons (copy, upvote, downvote)
149
+ *
150
+ * **Client Token Mode**: When using `clientToken`, feedback is automatically
151
+ * sent to your Travrse backend. Just enable the buttons and you're done!
152
+ * The `onFeedback` and `onCopy` callbacks are optional for additional local handling.
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * // With clientToken - feedback is automatic!
157
+ * config: {
158
+ * clientToken: 'ct_live_...',
159
+ * messageActions: {
160
+ * showUpvote: true,
161
+ * showDownvote: true,
162
+ * // No onFeedback needed - sent to backend automatically
163
+ * }
164
+ * }
165
+ * ```
149
166
  */
150
167
  type AgentWidgetMessageActionsConfig = {
151
168
  /**
@@ -159,13 +176,15 @@ type AgentWidgetMessageActionsConfig = {
159
176
  */
160
177
  showCopy?: boolean;
161
178
  /**
162
- * Show upvote button
163
- * @default false (requires backend)
179
+ * Show upvote button.
180
+ * When using `clientToken`, feedback is sent to the backend automatically.
181
+ * @default false
164
182
  */
165
183
  showUpvote?: boolean;
166
184
  /**
167
- * Show downvote button
168
- * @default false (requires backend)
185
+ * Show downvote button.
186
+ * When using `clientToken`, feedback is sent to the backend automatically.
187
+ * @default false
169
188
  */
170
189
  showDownvote?: boolean;
171
190
  /**
@@ -186,11 +205,19 @@ type AgentWidgetMessageActionsConfig = {
186
205
  */
187
206
  layout?: "pill-inside" | "row-inside";
188
207
  /**
189
- * Callback when user submits feedback (upvote/downvote)
208
+ * Callback when user submits feedback (upvote/downvote).
209
+ *
210
+ * **Note**: When using `clientToken`, feedback is AUTOMATICALLY sent to your
211
+ * backend via `/v1/client/feedback`. This callback is called IN ADDITION to
212
+ * the automatic submission, useful for updating local UI or analytics.
190
213
  */
191
214
  onFeedback?: (feedback: AgentWidgetMessageFeedback) => void;
192
215
  /**
193
- * Callback when user copies a message
216
+ * Callback when user copies a message.
217
+ *
218
+ * **Note**: When using `clientToken`, copy events are AUTOMATICALLY tracked
219
+ * via `/v1/client/feedback`. This callback is called IN ADDITION to the
220
+ * automatic tracking.
194
221
  */
195
222
  onCopy?: (message: AgentWidgetMessage) => void;
196
223
  };
@@ -1073,6 +1100,34 @@ type AgentWidgetConfig = {
1073
1100
  sendButtonLabel?: string;
1074
1101
  };
1075
1102
  theme?: AgentWidgetTheme;
1103
+ /**
1104
+ * Theme colors for dark mode. Applied when dark mode is detected
1105
+ * (when colorScheme is 'dark' or 'auto' with dark mode active).
1106
+ * If not provided, falls back to `theme` colors.
1107
+ *
1108
+ * @example
1109
+ * ```typescript
1110
+ * config: {
1111
+ * theme: { primary: '#111827', surface: '#ffffff' },
1112
+ * darkTheme: { primary: '#f9fafb', surface: '#1f2937' },
1113
+ * colorScheme: 'auto'
1114
+ * }
1115
+ * ```
1116
+ */
1117
+ darkTheme?: AgentWidgetTheme;
1118
+ /**
1119
+ * Color scheme mode for the widget.
1120
+ * - 'light': Always use light theme (default)
1121
+ * - 'dark': Always use dark theme
1122
+ * - 'auto': Automatically detect from page (HTML class or prefers-color-scheme)
1123
+ *
1124
+ * When 'auto', detection order:
1125
+ * 1. Check if `<html>` has 'dark' class
1126
+ * 2. Fall back to `prefers-color-scheme: dark` media query
1127
+ *
1128
+ * @default 'light'
1129
+ */
1130
+ colorScheme?: 'auto' | 'light' | 'dark';
1076
1131
  features?: AgentWidgetFeatureFlags;
1077
1132
  launcher?: AgentWidgetLauncherConfig;
1078
1133
  initialMessages?: AgentWidgetMessage[];
@@ -2027,6 +2082,14 @@ declare function hasComponentDirective(message: AgentWidgetMessage): boolean;
2027
2082
  */
2028
2083
  declare function extractComponentDirectiveFromMessage(message: AgentWidgetMessage): ComponentDirective | null;
2029
2084
 
2085
+ /**
2086
+ * Default light theme colors
2087
+ */
2088
+ declare const DEFAULT_LIGHT_THEME: AgentWidgetTheme;
2089
+ /**
2090
+ * Default dark theme colors
2091
+ */
2092
+ declare const DEFAULT_DARK_THEME: AgentWidgetTheme;
2030
2093
  /**
2031
2094
  * Default widget configuration
2032
2095
  * Single source of truth for all default values
@@ -2123,4 +2186,4 @@ declare const getHeaderLayout: (layoutName: string) => HeaderLayoutRenderer;
2123
2186
  */
2124
2187
  declare const buildHeaderWithLayout: (config: AgentWidgetConfig, layoutConfig?: AgentWidgetHeaderLayoutConfig, context?: Partial<HeaderLayoutContext>) => HeaderElements;
2125
2188
 
2126
- export { type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type SlotRenderContext, type SlotRenderer, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getHeaderLayout, hasComponentDirective, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, pluginRegistry, renderComponentDirective };
2189
+ export { type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type SlotRenderContext, type SlotRenderer, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getHeaderLayout, hasComponentDirective, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, pluginRegistry, renderComponentDirective };
package/dist/index.d.ts CHANGED
@@ -146,6 +146,23 @@ type AgentWidgetMessageFeedback = {
146
146
  };
147
147
  /**
148
148
  * Configuration for message action buttons (copy, upvote, downvote)
149
+ *
150
+ * **Client Token Mode**: When using `clientToken`, feedback is automatically
151
+ * sent to your Travrse backend. Just enable the buttons and you're done!
152
+ * The `onFeedback` and `onCopy` callbacks are optional for additional local handling.
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * // With clientToken - feedback is automatic!
157
+ * config: {
158
+ * clientToken: 'ct_live_...',
159
+ * messageActions: {
160
+ * showUpvote: true,
161
+ * showDownvote: true,
162
+ * // No onFeedback needed - sent to backend automatically
163
+ * }
164
+ * }
165
+ * ```
149
166
  */
150
167
  type AgentWidgetMessageActionsConfig = {
151
168
  /**
@@ -159,13 +176,15 @@ type AgentWidgetMessageActionsConfig = {
159
176
  */
160
177
  showCopy?: boolean;
161
178
  /**
162
- * Show upvote button
163
- * @default false (requires backend)
179
+ * Show upvote button.
180
+ * When using `clientToken`, feedback is sent to the backend automatically.
181
+ * @default false
164
182
  */
165
183
  showUpvote?: boolean;
166
184
  /**
167
- * Show downvote button
168
- * @default false (requires backend)
185
+ * Show downvote button.
186
+ * When using `clientToken`, feedback is sent to the backend automatically.
187
+ * @default false
169
188
  */
170
189
  showDownvote?: boolean;
171
190
  /**
@@ -186,11 +205,19 @@ type AgentWidgetMessageActionsConfig = {
186
205
  */
187
206
  layout?: "pill-inside" | "row-inside";
188
207
  /**
189
- * Callback when user submits feedback (upvote/downvote)
208
+ * Callback when user submits feedback (upvote/downvote).
209
+ *
210
+ * **Note**: When using `clientToken`, feedback is AUTOMATICALLY sent to your
211
+ * backend via `/v1/client/feedback`. This callback is called IN ADDITION to
212
+ * the automatic submission, useful for updating local UI or analytics.
190
213
  */
191
214
  onFeedback?: (feedback: AgentWidgetMessageFeedback) => void;
192
215
  /**
193
- * Callback when user copies a message
216
+ * Callback when user copies a message.
217
+ *
218
+ * **Note**: When using `clientToken`, copy events are AUTOMATICALLY tracked
219
+ * via `/v1/client/feedback`. This callback is called IN ADDITION to the
220
+ * automatic tracking.
194
221
  */
195
222
  onCopy?: (message: AgentWidgetMessage) => void;
196
223
  };
@@ -1073,6 +1100,34 @@ type AgentWidgetConfig = {
1073
1100
  sendButtonLabel?: string;
1074
1101
  };
1075
1102
  theme?: AgentWidgetTheme;
1103
+ /**
1104
+ * Theme colors for dark mode. Applied when dark mode is detected
1105
+ * (when colorScheme is 'dark' or 'auto' with dark mode active).
1106
+ * If not provided, falls back to `theme` colors.
1107
+ *
1108
+ * @example
1109
+ * ```typescript
1110
+ * config: {
1111
+ * theme: { primary: '#111827', surface: '#ffffff' },
1112
+ * darkTheme: { primary: '#f9fafb', surface: '#1f2937' },
1113
+ * colorScheme: 'auto'
1114
+ * }
1115
+ * ```
1116
+ */
1117
+ darkTheme?: AgentWidgetTheme;
1118
+ /**
1119
+ * Color scheme mode for the widget.
1120
+ * - 'light': Always use light theme (default)
1121
+ * - 'dark': Always use dark theme
1122
+ * - 'auto': Automatically detect from page (HTML class or prefers-color-scheme)
1123
+ *
1124
+ * When 'auto', detection order:
1125
+ * 1. Check if `<html>` has 'dark' class
1126
+ * 2. Fall back to `prefers-color-scheme: dark` media query
1127
+ *
1128
+ * @default 'light'
1129
+ */
1130
+ colorScheme?: 'auto' | 'light' | 'dark';
1076
1131
  features?: AgentWidgetFeatureFlags;
1077
1132
  launcher?: AgentWidgetLauncherConfig;
1078
1133
  initialMessages?: AgentWidgetMessage[];
@@ -2027,6 +2082,14 @@ declare function hasComponentDirective(message: AgentWidgetMessage): boolean;
2027
2082
  */
2028
2083
  declare function extractComponentDirectiveFromMessage(message: AgentWidgetMessage): ComponentDirective | null;
2029
2084
 
2085
+ /**
2086
+ * Default light theme colors
2087
+ */
2088
+ declare const DEFAULT_LIGHT_THEME: AgentWidgetTheme;
2089
+ /**
2090
+ * Default dark theme colors
2091
+ */
2092
+ declare const DEFAULT_DARK_THEME: AgentWidgetTheme;
2030
2093
  /**
2031
2094
  * Default widget configuration
2032
2095
  * Single source of truth for all default values
@@ -2123,4 +2186,4 @@ declare const getHeaderLayout: (layoutName: string) => HeaderLayoutRenderer;
2123
2186
  */
2124
2187
  declare const buildHeaderWithLayout: (config: AgentWidgetConfig, layoutConfig?: AgentWidgetHeaderLayoutConfig, context?: Partial<HeaderLayoutContext>) => HeaderElements;
2125
2188
 
2126
- export { type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type SlotRenderContext, type SlotRenderer, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getHeaderLayout, hasComponentDirective, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, pluginRegistry, renderComponentDirective };
2189
+ export { type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type SlotRenderContext, type SlotRenderer, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getHeaderLayout, hasComponentDirective, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, pluginRegistry, renderComponentDirective };