@runtypelabs/persona 1.40.0 → 1.41.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
@@ -65,6 +65,41 @@ interface AgentWidgetPlugin {
65
65
  defaultRenderer: () => HTMLElement;
66
66
  config: AgentWidgetConfig;
67
67
  }) => HTMLElement | null;
68
+ /**
69
+ * Custom renderer for loading indicator
70
+ * Return null to use default renderer (or config-based renderer)
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * renderLoadingIndicator: ({ location, defaultRenderer }) => {
75
+ * if (location === 'standalone') {
76
+ * const el = document.createElement('div');
77
+ * el.textContent = 'Thinking...';
78
+ * return el;
79
+ * }
80
+ * return defaultRenderer();
81
+ * }
82
+ * ```
83
+ */
84
+ renderLoadingIndicator?: (context: LoadingIndicatorRenderContext) => HTMLElement | null;
85
+ /**
86
+ * Custom renderer for idle state indicator.
87
+ * Called when the widget is idle (not streaming) and has at least one message.
88
+ * Return an HTMLElement to display, or null to hide (default).
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * renderIdleIndicator: ({ lastMessage, messageCount }) => {
93
+ * if (messageCount === 0) return null;
94
+ * if (lastMessage?.role !== 'assistant') return null;
95
+ * const el = document.createElement('div');
96
+ * el.className = 'idle-pulse';
97
+ * el.setAttribute('data-preserve-animation', 'true');
98
+ * return el;
99
+ * }
100
+ * ```
101
+ */
102
+ renderIdleIndicator?: (context: IdleIndicatorRenderContext) => HTMLElement | null;
68
103
  /**
69
104
  * Called when plugin is registered
70
105
  */
@@ -1217,6 +1252,137 @@ type AgentWidgetPersistStateConfig = {
1217
1252
  */
1218
1253
  clearOnChatClear?: boolean;
1219
1254
  };
1255
+ /**
1256
+ * Context provided to loading indicator render functions.
1257
+ * Used for customizing the loading indicator appearance.
1258
+ */
1259
+ type LoadingIndicatorRenderContext = {
1260
+ /**
1261
+ * Full widget configuration for accessing theme, etc.
1262
+ */
1263
+ config: AgentWidgetConfig;
1264
+ /**
1265
+ * Current streaming state (always true when indicator is shown)
1266
+ */
1267
+ streaming: boolean;
1268
+ /**
1269
+ * Location where the indicator is rendered:
1270
+ * - 'inline': Inside a streaming assistant message bubble (when content is empty)
1271
+ * - 'standalone': Separate bubble while waiting for stream to start
1272
+ */
1273
+ location: 'inline' | 'standalone';
1274
+ /**
1275
+ * Function to render the default 3-dot bouncing indicator.
1276
+ * Call this if you want to use the default for certain cases.
1277
+ */
1278
+ defaultRenderer: () => HTMLElement;
1279
+ };
1280
+ /**
1281
+ * Context provided to idle indicator render functions.
1282
+ * Used for customizing the idle state indicator appearance.
1283
+ */
1284
+ type IdleIndicatorRenderContext = {
1285
+ /**
1286
+ * Full widget configuration for accessing theme, etc.
1287
+ */
1288
+ config: AgentWidgetConfig;
1289
+ /**
1290
+ * The last message in the conversation (if any).
1291
+ * Useful for conditional rendering based on who spoke last.
1292
+ */
1293
+ lastMessage: AgentWidgetMessage | undefined;
1294
+ /**
1295
+ * Total number of messages in the conversation.
1296
+ */
1297
+ messageCount: number;
1298
+ };
1299
+ /**
1300
+ * Configuration for customizing the loading indicator.
1301
+ * The loading indicator is shown while waiting for a response or
1302
+ * when an assistant message is streaming but has no content yet.
1303
+ *
1304
+ * @example
1305
+ * ```typescript
1306
+ * // Custom animated spinner
1307
+ * config: {
1308
+ * loadingIndicator: {
1309
+ * render: ({ location }) => {
1310
+ * const el = document.createElement('div');
1311
+ * el.innerHTML = '<svg class="spinner">...</svg>';
1312
+ * el.setAttribute('data-preserve-animation', 'true');
1313
+ * return el;
1314
+ * }
1315
+ * }
1316
+ * }
1317
+ * ```
1318
+ *
1319
+ * @example
1320
+ * ```typescript
1321
+ * // Different indicators by location
1322
+ * config: {
1323
+ * loadingIndicator: {
1324
+ * render: ({ location, defaultRenderer }) => {
1325
+ * if (location === 'inline') {
1326
+ * return defaultRenderer(); // Use default for inline
1327
+ * }
1328
+ * // Custom for standalone
1329
+ * const el = document.createElement('div');
1330
+ * el.textContent = 'Thinking...';
1331
+ * return el;
1332
+ * }
1333
+ * }
1334
+ * }
1335
+ * ```
1336
+ *
1337
+ * @example
1338
+ * ```typescript
1339
+ * // Hide loading indicator entirely
1340
+ * config: {
1341
+ * loadingIndicator: {
1342
+ * render: () => null
1343
+ * }
1344
+ * }
1345
+ * ```
1346
+ */
1347
+ type AgentWidgetLoadingIndicatorConfig = {
1348
+ /**
1349
+ * Whether to show the bubble background and border around the standalone loading indicator.
1350
+ * Set to false to render the loading indicator without any bubble styling.
1351
+ * @default true
1352
+ */
1353
+ showBubble?: boolean;
1354
+ /**
1355
+ * Custom render function for the loading indicator.
1356
+ * Return an HTMLElement to display, or null to hide the indicator.
1357
+ *
1358
+ * For custom animations, add `data-preserve-animation="true"` attribute
1359
+ * to prevent the DOM morpher from interrupting the animation.
1360
+ */
1361
+ render?: (context: LoadingIndicatorRenderContext) => HTMLElement | null;
1362
+ /**
1363
+ * Render function for the idle state indicator.
1364
+ * Called when the widget is idle (not streaming) and has at least one message.
1365
+ * Return an HTMLElement to display, or null to hide (default).
1366
+ *
1367
+ * For animations, add `data-preserve-animation="true"` attribute
1368
+ * to prevent the DOM morpher from interrupting the animation.
1369
+ *
1370
+ * @example
1371
+ * ```typescript
1372
+ * loadingIndicator: {
1373
+ * renderIdle: ({ lastMessage }) => {
1374
+ * // Only show idle indicator after assistant messages
1375
+ * if (lastMessage?.role !== 'assistant') return null;
1376
+ * const el = document.createElement('div');
1377
+ * el.className = 'pulse-dot';
1378
+ * el.setAttribute('data-preserve-animation', 'true');
1379
+ * return el;
1380
+ * }
1381
+ * }
1382
+ * ```
1383
+ */
1384
+ renderIdle?: (context: IdleIndicatorRenderContext) => HTMLElement | null;
1385
+ };
1220
1386
  type AgentWidgetConfig = {
1221
1387
  apiUrl?: string;
1222
1388
  flowId?: string;
@@ -1650,6 +1816,28 @@ type AgentWidgetConfig = {
1650
1816
  * ```
1651
1817
  */
1652
1818
  persistState?: boolean | AgentWidgetPersistStateConfig;
1819
+ /**
1820
+ * Configuration for customizing the loading indicator.
1821
+ * The loading indicator is shown while waiting for a response or
1822
+ * when an assistant message is streaming but has no content yet.
1823
+ *
1824
+ * @example
1825
+ * ```typescript
1826
+ * config: {
1827
+ * loadingIndicator: {
1828
+ * render: ({ location, defaultRenderer }) => {
1829
+ * if (location === 'standalone') {
1830
+ * const el = document.createElement('div');
1831
+ * el.textContent = 'Thinking...';
1832
+ * return el;
1833
+ * }
1834
+ * return defaultRenderer();
1835
+ * }
1836
+ * }
1837
+ * }
1838
+ * ```
1839
+ */
1840
+ loadingIndicator?: AgentWidgetLoadingIndicatorConfig;
1653
1841
  };
1654
1842
  type AgentWidgetMessageRole = "user" | "assistant" | "system";
1655
1843
  type AgentWidgetReasoning = {
@@ -2795,6 +2983,7 @@ declare function createComponentStreamParser(): {
2795
2983
  */
2796
2984
  declare function isComponentDirectiveType(obj: unknown): obj is ComponentDirective;
2797
2985
 
2986
+ type LoadingIndicatorRenderer = (context: LoadingIndicatorRenderContext) => HTMLElement | null;
2798
2987
  type MessageTransform = (context: {
2799
2988
  text: string;
2800
2989
  message: AgentWidgetMessage;
@@ -2806,20 +2995,39 @@ type MessageActionCallbacks = {
2806
2995
  onFeedback?: (feedback: AgentWidgetMessageFeedback) => void;
2807
2996
  };
2808
2997
  declare const createTypingIndicator: () => HTMLElement;
2998
+ /**
2999
+ * Render loading indicator with fallback chain:
3000
+ * 1. Custom renderer (if provided and returns non-null)
3001
+ * 2. Default typing indicator
3002
+ */
3003
+ declare const renderLoadingIndicatorWithFallback: (location: "inline" | "standalone", customRenderer?: LoadingIndicatorRenderer, widgetConfig?: AgentWidgetConfig) => HTMLElement | null;
2809
3004
  /**
2810
3005
  * Create message action buttons (copy, upvote, downvote)
2811
3006
  */
2812
3007
  declare const createMessageActions: (message: AgentWidgetMessage, actionsConfig: AgentWidgetMessageActionsConfig, callbacks?: MessageActionCallbacks) => HTMLElement;
3008
+ /**
3009
+ * Options for creating a standard message bubble
3010
+ */
3011
+ type CreateStandardBubbleOptions = {
3012
+ /**
3013
+ * Custom loading indicator renderer for inline location
3014
+ */
3015
+ loadingIndicatorRenderer?: LoadingIndicatorRenderer;
3016
+ /**
3017
+ * Full widget config (needed for loading indicator context)
3018
+ */
3019
+ widgetConfig?: AgentWidgetConfig;
3020
+ };
2813
3021
  /**
2814
3022
  * Create standard message bubble
2815
3023
  * Supports layout configuration for avatars, timestamps, and visual presets
2816
3024
  */
2817
- declare const createStandardBubble: (message: AgentWidgetMessage, transform: MessageTransform, layoutConfig?: AgentWidgetMessageLayoutConfig, actionsConfig?: AgentWidgetMessageActionsConfig, actionCallbacks?: MessageActionCallbacks) => HTMLElement;
3025
+ declare const createStandardBubble: (message: AgentWidgetMessage, transform: MessageTransform, layoutConfig?: AgentWidgetMessageLayoutConfig, actionsConfig?: AgentWidgetMessageActionsConfig, actionCallbacks?: MessageActionCallbacks, options?: CreateStandardBubbleOptions) => HTMLElement;
2818
3026
  /**
2819
3027
  * Create bubble with custom renderer support
2820
3028
  * Uses custom renderer if provided in layout config, otherwise falls back to standard bubble
2821
3029
  */
2822
- declare const createBubbleWithLayout: (message: AgentWidgetMessage, transform: MessageTransform, layoutConfig?: AgentWidgetMessageLayoutConfig, actionsConfig?: AgentWidgetMessageActionsConfig, actionCallbacks?: MessageActionCallbacks) => HTMLElement;
3030
+ declare const createBubbleWithLayout: (message: AgentWidgetMessage, transform: MessageTransform, layoutConfig?: AgentWidgetMessageLayoutConfig, actionsConfig?: AgentWidgetMessageActionsConfig, actionCallbacks?: MessageActionCallbacks, options?: CreateStandardBubbleOptions) => HTMLElement;
2823
3031
 
2824
3032
  /**
2825
3033
  * Options for component middleware
@@ -2971,4 +3179,4 @@ declare const getHeaderLayout: (layoutName: string) => HeaderLayoutRenderer;
2971
3179
  */
2972
3180
  declare const buildHeaderWithLayout: (config: AgentWidgetConfig, layoutConfig?: AgentWidgetHeaderLayoutConfig, context?: Partial<HeaderLayoutContext>) => HeaderElements;
2973
3181
 
2974
- export { type AgentWidgetAttachmentsConfig, 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, AttachmentManager, type AttachmentManagerConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, type ContentPart, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type PendingAttachment, type SlotRenderContext, type SlotRenderer, type TextContentPart, VERSION, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createImagePart, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTextPart, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getDisplayText, getHeaderLayout, getImageParts, hasComponentDirective, hasImages, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, normalizeContent, pluginRegistry, renderComponentDirective, validateImageFile };
3182
+ export { type AgentWidgetAttachmentsConfig, 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 AgentWidgetLoadingIndicatorConfig, 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, AttachmentManager, type AttachmentManagerConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, type ContentPart, type CreateStandardBubbleOptions, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type IdleIndicatorRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type LoadingIndicatorRenderContext, type LoadingIndicatorRenderer, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type PendingAttachment, type SlotRenderContext, type SlotRenderer, type TextContentPart, VERSION, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createImagePart, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTextPart, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getDisplayText, getHeaderLayout, getImageParts, hasComponentDirective, hasImages, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, normalizeContent, pluginRegistry, renderComponentDirective, renderLoadingIndicatorWithFallback, validateImageFile };
package/dist/index.d.ts CHANGED
@@ -65,6 +65,41 @@ interface AgentWidgetPlugin {
65
65
  defaultRenderer: () => HTMLElement;
66
66
  config: AgentWidgetConfig;
67
67
  }) => HTMLElement | null;
68
+ /**
69
+ * Custom renderer for loading indicator
70
+ * Return null to use default renderer (or config-based renderer)
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * renderLoadingIndicator: ({ location, defaultRenderer }) => {
75
+ * if (location === 'standalone') {
76
+ * const el = document.createElement('div');
77
+ * el.textContent = 'Thinking...';
78
+ * return el;
79
+ * }
80
+ * return defaultRenderer();
81
+ * }
82
+ * ```
83
+ */
84
+ renderLoadingIndicator?: (context: LoadingIndicatorRenderContext) => HTMLElement | null;
85
+ /**
86
+ * Custom renderer for idle state indicator.
87
+ * Called when the widget is idle (not streaming) and has at least one message.
88
+ * Return an HTMLElement to display, or null to hide (default).
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * renderIdleIndicator: ({ lastMessage, messageCount }) => {
93
+ * if (messageCount === 0) return null;
94
+ * if (lastMessage?.role !== 'assistant') return null;
95
+ * const el = document.createElement('div');
96
+ * el.className = 'idle-pulse';
97
+ * el.setAttribute('data-preserve-animation', 'true');
98
+ * return el;
99
+ * }
100
+ * ```
101
+ */
102
+ renderIdleIndicator?: (context: IdleIndicatorRenderContext) => HTMLElement | null;
68
103
  /**
69
104
  * Called when plugin is registered
70
105
  */
@@ -1217,6 +1252,137 @@ type AgentWidgetPersistStateConfig = {
1217
1252
  */
1218
1253
  clearOnChatClear?: boolean;
1219
1254
  };
1255
+ /**
1256
+ * Context provided to loading indicator render functions.
1257
+ * Used for customizing the loading indicator appearance.
1258
+ */
1259
+ type LoadingIndicatorRenderContext = {
1260
+ /**
1261
+ * Full widget configuration for accessing theme, etc.
1262
+ */
1263
+ config: AgentWidgetConfig;
1264
+ /**
1265
+ * Current streaming state (always true when indicator is shown)
1266
+ */
1267
+ streaming: boolean;
1268
+ /**
1269
+ * Location where the indicator is rendered:
1270
+ * - 'inline': Inside a streaming assistant message bubble (when content is empty)
1271
+ * - 'standalone': Separate bubble while waiting for stream to start
1272
+ */
1273
+ location: 'inline' | 'standalone';
1274
+ /**
1275
+ * Function to render the default 3-dot bouncing indicator.
1276
+ * Call this if you want to use the default for certain cases.
1277
+ */
1278
+ defaultRenderer: () => HTMLElement;
1279
+ };
1280
+ /**
1281
+ * Context provided to idle indicator render functions.
1282
+ * Used for customizing the idle state indicator appearance.
1283
+ */
1284
+ type IdleIndicatorRenderContext = {
1285
+ /**
1286
+ * Full widget configuration for accessing theme, etc.
1287
+ */
1288
+ config: AgentWidgetConfig;
1289
+ /**
1290
+ * The last message in the conversation (if any).
1291
+ * Useful for conditional rendering based on who spoke last.
1292
+ */
1293
+ lastMessage: AgentWidgetMessage | undefined;
1294
+ /**
1295
+ * Total number of messages in the conversation.
1296
+ */
1297
+ messageCount: number;
1298
+ };
1299
+ /**
1300
+ * Configuration for customizing the loading indicator.
1301
+ * The loading indicator is shown while waiting for a response or
1302
+ * when an assistant message is streaming but has no content yet.
1303
+ *
1304
+ * @example
1305
+ * ```typescript
1306
+ * // Custom animated spinner
1307
+ * config: {
1308
+ * loadingIndicator: {
1309
+ * render: ({ location }) => {
1310
+ * const el = document.createElement('div');
1311
+ * el.innerHTML = '<svg class="spinner">...</svg>';
1312
+ * el.setAttribute('data-preserve-animation', 'true');
1313
+ * return el;
1314
+ * }
1315
+ * }
1316
+ * }
1317
+ * ```
1318
+ *
1319
+ * @example
1320
+ * ```typescript
1321
+ * // Different indicators by location
1322
+ * config: {
1323
+ * loadingIndicator: {
1324
+ * render: ({ location, defaultRenderer }) => {
1325
+ * if (location === 'inline') {
1326
+ * return defaultRenderer(); // Use default for inline
1327
+ * }
1328
+ * // Custom for standalone
1329
+ * const el = document.createElement('div');
1330
+ * el.textContent = 'Thinking...';
1331
+ * return el;
1332
+ * }
1333
+ * }
1334
+ * }
1335
+ * ```
1336
+ *
1337
+ * @example
1338
+ * ```typescript
1339
+ * // Hide loading indicator entirely
1340
+ * config: {
1341
+ * loadingIndicator: {
1342
+ * render: () => null
1343
+ * }
1344
+ * }
1345
+ * ```
1346
+ */
1347
+ type AgentWidgetLoadingIndicatorConfig = {
1348
+ /**
1349
+ * Whether to show the bubble background and border around the standalone loading indicator.
1350
+ * Set to false to render the loading indicator without any bubble styling.
1351
+ * @default true
1352
+ */
1353
+ showBubble?: boolean;
1354
+ /**
1355
+ * Custom render function for the loading indicator.
1356
+ * Return an HTMLElement to display, or null to hide the indicator.
1357
+ *
1358
+ * For custom animations, add `data-preserve-animation="true"` attribute
1359
+ * to prevent the DOM morpher from interrupting the animation.
1360
+ */
1361
+ render?: (context: LoadingIndicatorRenderContext) => HTMLElement | null;
1362
+ /**
1363
+ * Render function for the idle state indicator.
1364
+ * Called when the widget is idle (not streaming) and has at least one message.
1365
+ * Return an HTMLElement to display, or null to hide (default).
1366
+ *
1367
+ * For animations, add `data-preserve-animation="true"` attribute
1368
+ * to prevent the DOM morpher from interrupting the animation.
1369
+ *
1370
+ * @example
1371
+ * ```typescript
1372
+ * loadingIndicator: {
1373
+ * renderIdle: ({ lastMessage }) => {
1374
+ * // Only show idle indicator after assistant messages
1375
+ * if (lastMessage?.role !== 'assistant') return null;
1376
+ * const el = document.createElement('div');
1377
+ * el.className = 'pulse-dot';
1378
+ * el.setAttribute('data-preserve-animation', 'true');
1379
+ * return el;
1380
+ * }
1381
+ * }
1382
+ * ```
1383
+ */
1384
+ renderIdle?: (context: IdleIndicatorRenderContext) => HTMLElement | null;
1385
+ };
1220
1386
  type AgentWidgetConfig = {
1221
1387
  apiUrl?: string;
1222
1388
  flowId?: string;
@@ -1650,6 +1816,28 @@ type AgentWidgetConfig = {
1650
1816
  * ```
1651
1817
  */
1652
1818
  persistState?: boolean | AgentWidgetPersistStateConfig;
1819
+ /**
1820
+ * Configuration for customizing the loading indicator.
1821
+ * The loading indicator is shown while waiting for a response or
1822
+ * when an assistant message is streaming but has no content yet.
1823
+ *
1824
+ * @example
1825
+ * ```typescript
1826
+ * config: {
1827
+ * loadingIndicator: {
1828
+ * render: ({ location, defaultRenderer }) => {
1829
+ * if (location === 'standalone') {
1830
+ * const el = document.createElement('div');
1831
+ * el.textContent = 'Thinking...';
1832
+ * return el;
1833
+ * }
1834
+ * return defaultRenderer();
1835
+ * }
1836
+ * }
1837
+ * }
1838
+ * ```
1839
+ */
1840
+ loadingIndicator?: AgentWidgetLoadingIndicatorConfig;
1653
1841
  };
1654
1842
  type AgentWidgetMessageRole = "user" | "assistant" | "system";
1655
1843
  type AgentWidgetReasoning = {
@@ -2795,6 +2983,7 @@ declare function createComponentStreamParser(): {
2795
2983
  */
2796
2984
  declare function isComponentDirectiveType(obj: unknown): obj is ComponentDirective;
2797
2985
 
2986
+ type LoadingIndicatorRenderer = (context: LoadingIndicatorRenderContext) => HTMLElement | null;
2798
2987
  type MessageTransform = (context: {
2799
2988
  text: string;
2800
2989
  message: AgentWidgetMessage;
@@ -2806,20 +2995,39 @@ type MessageActionCallbacks = {
2806
2995
  onFeedback?: (feedback: AgentWidgetMessageFeedback) => void;
2807
2996
  };
2808
2997
  declare const createTypingIndicator: () => HTMLElement;
2998
+ /**
2999
+ * Render loading indicator with fallback chain:
3000
+ * 1. Custom renderer (if provided and returns non-null)
3001
+ * 2. Default typing indicator
3002
+ */
3003
+ declare const renderLoadingIndicatorWithFallback: (location: "inline" | "standalone", customRenderer?: LoadingIndicatorRenderer, widgetConfig?: AgentWidgetConfig) => HTMLElement | null;
2809
3004
  /**
2810
3005
  * Create message action buttons (copy, upvote, downvote)
2811
3006
  */
2812
3007
  declare const createMessageActions: (message: AgentWidgetMessage, actionsConfig: AgentWidgetMessageActionsConfig, callbacks?: MessageActionCallbacks) => HTMLElement;
3008
+ /**
3009
+ * Options for creating a standard message bubble
3010
+ */
3011
+ type CreateStandardBubbleOptions = {
3012
+ /**
3013
+ * Custom loading indicator renderer for inline location
3014
+ */
3015
+ loadingIndicatorRenderer?: LoadingIndicatorRenderer;
3016
+ /**
3017
+ * Full widget config (needed for loading indicator context)
3018
+ */
3019
+ widgetConfig?: AgentWidgetConfig;
3020
+ };
2813
3021
  /**
2814
3022
  * Create standard message bubble
2815
3023
  * Supports layout configuration for avatars, timestamps, and visual presets
2816
3024
  */
2817
- declare const createStandardBubble: (message: AgentWidgetMessage, transform: MessageTransform, layoutConfig?: AgentWidgetMessageLayoutConfig, actionsConfig?: AgentWidgetMessageActionsConfig, actionCallbacks?: MessageActionCallbacks) => HTMLElement;
3025
+ declare const createStandardBubble: (message: AgentWidgetMessage, transform: MessageTransform, layoutConfig?: AgentWidgetMessageLayoutConfig, actionsConfig?: AgentWidgetMessageActionsConfig, actionCallbacks?: MessageActionCallbacks, options?: CreateStandardBubbleOptions) => HTMLElement;
2818
3026
  /**
2819
3027
  * Create bubble with custom renderer support
2820
3028
  * Uses custom renderer if provided in layout config, otherwise falls back to standard bubble
2821
3029
  */
2822
- declare const createBubbleWithLayout: (message: AgentWidgetMessage, transform: MessageTransform, layoutConfig?: AgentWidgetMessageLayoutConfig, actionsConfig?: AgentWidgetMessageActionsConfig, actionCallbacks?: MessageActionCallbacks) => HTMLElement;
3030
+ declare const createBubbleWithLayout: (message: AgentWidgetMessage, transform: MessageTransform, layoutConfig?: AgentWidgetMessageLayoutConfig, actionsConfig?: AgentWidgetMessageActionsConfig, actionCallbacks?: MessageActionCallbacks, options?: CreateStandardBubbleOptions) => HTMLElement;
2823
3031
 
2824
3032
  /**
2825
3033
  * Options for component middleware
@@ -2971,4 +3179,4 @@ declare const getHeaderLayout: (layoutName: string) => HeaderLayoutRenderer;
2971
3179
  */
2972
3180
  declare const buildHeaderWithLayout: (config: AgentWidgetConfig, layoutConfig?: AgentWidgetHeaderLayoutConfig, context?: Partial<HeaderLayoutContext>) => HeaderElements;
2973
3181
 
2974
- export { type AgentWidgetAttachmentsConfig, 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, AttachmentManager, type AttachmentManagerConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, type ContentPart, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type PendingAttachment, type SlotRenderContext, type SlotRenderer, type TextContentPart, VERSION, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createImagePart, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTextPart, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getDisplayText, getHeaderLayout, getImageParts, hasComponentDirective, hasImages, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, normalizeContent, pluginRegistry, renderComponentDirective, validateImageFile };
3182
+ export { type AgentWidgetAttachmentsConfig, 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 AgentWidgetLoadingIndicatorConfig, 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, AttachmentManager, type AttachmentManagerConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, type ContentPart, type CreateStandardBubbleOptions, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type IdleIndicatorRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type LoadingIndicatorRenderContext, type LoadingIndicatorRenderer, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type PendingAttachment, type SlotRenderContext, type SlotRenderer, type TextContentPart, VERSION, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createImagePart, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTextPart, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getDisplayText, getHeaderLayout, getImageParts, hasComponentDirective, hasImages, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, normalizeContent, pluginRegistry, renderComponentDirective, renderLoadingIndicatorWithFallback, validateImageFile };