@runtypelabs/persona 3.24.0 → 3.26.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.ts CHANGED
@@ -6101,148 +6101,6 @@ declare const isDockedMountMode: (config?: AgentWidgetConfig) => boolean;
6101
6101
  */
6102
6102
  declare const resolveDockConfig: (config?: AgentWidgetConfig) => Required<AgentWidgetDockConfig>;
6103
6103
 
6104
- type CodeFormat = "esm" | "script-installer" | "script-manual" | "script-advanced" | "react-component" | "react-advanced";
6105
- /**
6106
- * Hook code templates for code generation.
6107
- * Each hook can be provided as a string (code template) OR as an actual function.
6108
- * Functions are automatically serialized via `.toString()`.
6109
- *
6110
- * IMPORTANT: When providing functions:
6111
- * - Functions must be self-contained (no external variables/closures)
6112
- * - External variables will be undefined when the generated code runs
6113
- * - Use arrow functions or regular function expressions
6114
- *
6115
- * @example
6116
- * ```typescript
6117
- * // Both of these work:
6118
- *
6119
- * // As string:
6120
- * { getHeaders: "async () => ({ 'Authorization': 'Bearer token' })" }
6121
- *
6122
- * // As function (recommended - better IDE support):
6123
- * { getHeaders: async () => ({ 'Authorization': 'Bearer token' }) }
6124
- * ```
6125
- */
6126
- type CodeGeneratorHooks = {
6127
- /**
6128
- * Custom getHeaders function.
6129
- * Should return an object with header key-value pairs.
6130
- *
6131
- * @example
6132
- * ```typescript
6133
- * async () => ({ 'Authorization': `Bearer ${await getAuthToken()}` })
6134
- * ```
6135
- */
6136
- getHeaders?: string | (() => Record<string, string> | Promise<Record<string, string>>);
6137
- /**
6138
- * Custom onFeedback callback for message actions.
6139
- * Receives a feedback object with type, messageId, and message.
6140
- *
6141
- * @example
6142
- * ```typescript
6143
- * (feedback) => { console.log('Feedback:', feedback.type); }
6144
- * ```
6145
- */
6146
- onFeedback?: string | ((feedback: {
6147
- type: string;
6148
- messageId: string;
6149
- message: unknown;
6150
- }) => void);
6151
- /**
6152
- * Custom onCopy callback for message actions.
6153
- * Receives the message that was copied.
6154
- *
6155
- * @example
6156
- * ```typescript
6157
- * (message) => { analytics.track('message_copied', { id: message.id }); }
6158
- * ```
6159
- */
6160
- onCopy?: string | ((message: unknown) => void);
6161
- /**
6162
- * Custom requestMiddleware function.
6163
- * Receives { payload, config } context.
6164
- *
6165
- * @example
6166
- * ```typescript
6167
- * ({ payload }) => ({ ...payload, metadata: { pageUrl: window.location.href } })
6168
- * ```
6169
- */
6170
- requestMiddleware?: string | ((context: {
6171
- payload: unknown;
6172
- config: unknown;
6173
- }) => unknown);
6174
- /**
6175
- * Custom action handlers array.
6176
- * Array of handler functions.
6177
- *
6178
- * @example
6179
- * ```typescript
6180
- * [
6181
- * (action, context) => {
6182
- * if (action.type === 'custom') {
6183
- * return { handled: true };
6184
- * }
6185
- * }
6186
- * ]
6187
- * ```
6188
- */
6189
- actionHandlers?: string | Array<(action: unknown, context: unknown) => unknown>;
6190
- /**
6191
- * Custom action parsers array.
6192
- * Array of parser functions.
6193
- */
6194
- actionParsers?: string | Array<(context: unknown) => unknown>;
6195
- /**
6196
- * Custom postprocessMessage function.
6197
- * Receives { text, message, streaming, raw } context.
6198
- * Will override the default markdownPostprocessor.
6199
- *
6200
- * @example
6201
- * ```typescript
6202
- * ({ text }) => customMarkdownProcessor(text)
6203
- * ```
6204
- */
6205
- postprocessMessage?: string | ((context: {
6206
- text: string;
6207
- message?: unknown;
6208
- streaming?: boolean;
6209
- raw?: string;
6210
- }) => string);
6211
- /**
6212
- * Custom context providers array.
6213
- * Array of provider functions.
6214
- */
6215
- contextProviders?: string | Array<() => unknown>;
6216
- /**
6217
- * Custom stream parser factory.
6218
- * Should be a function that returns a StreamParser.
6219
- */
6220
- streamParser?: string | (() => unknown);
6221
- };
6222
- /**
6223
- * Options for code generation beyond format selection.
6224
- */
6225
- type CodeGeneratorOptions = {
6226
- /**
6227
- * Custom hook code to inject into the generated snippet.
6228
- * Hooks are JavaScript/TypeScript code strings that will be
6229
- * inserted at appropriate locations in the output.
6230
- */
6231
- hooks?: CodeGeneratorHooks;
6232
- /**
6233
- * Whether to include comments explaining each hook.
6234
- * @default true
6235
- */
6236
- includeHookComments?: boolean;
6237
- /**
6238
- * If provided, emits `windowKey` in the generated `initAgentWidget()` call
6239
- * so the widget handle is stored on `window[windowKey]`.
6240
- * Only affects script formats (script-installer, script-manual, script-advanced).
6241
- */
6242
- windowKey?: string;
6243
- };
6244
- declare function generateCodeSnippet(config: any, format?: CodeFormat, options?: CodeGeneratorOptions): string;
6245
-
6246
6104
  /**
6247
6105
  * The current version of the @runtypelabs/persona package.
6248
6106
  * This is automatically derived from package.json.
@@ -6649,54 +6507,6 @@ interface ComboButtonHandle {
6649
6507
  */
6650
6508
  declare function createComboButton(options: CreateComboButtonOptions): ComboButtonHandle;
6651
6509
 
6652
- interface DemoCarouselItem {
6653
- /** URL to load in the iframe (relative or absolute). */
6654
- url: string;
6655
- /** Display title shown in the toolbar. */
6656
- title: string;
6657
- /** Optional subtitle/description. */
6658
- description?: string;
6659
- }
6660
- interface DemoCarouselOptions {
6661
- /** Demo pages to cycle through. */
6662
- items: DemoCarouselItem[];
6663
- /** Initial item index. Default: 0. */
6664
- initialIndex?: number;
6665
- /** Initial device viewport. Default: 'desktop'. */
6666
- initialDevice?: "desktop" | "mobile";
6667
- /** Initial color scheme for the iframe wrapper. Default: 'light'. */
6668
- initialColorScheme?: "light" | "dark";
6669
- /** Show zoom +/- controls. Default: true. */
6670
- showZoomControls?: boolean;
6671
- /** Show desktop/mobile toggle. Default: true. */
6672
- showDeviceToggle?: boolean;
6673
- /** Show light/dark scheme toggle. Default: true. */
6674
- showColorSchemeToggle?: boolean;
6675
- /** Called when the active demo changes. */
6676
- onChange?: (index: number, item: DemoCarouselItem) => void;
6677
- }
6678
- interface DemoCarouselHandle {
6679
- /** Root element (already appended to the container). */
6680
- element: HTMLElement;
6681
- /** Navigate to a demo by index. */
6682
- goTo(index: number): void;
6683
- /** Go to the next demo. */
6684
- next(): void;
6685
- /** Go to the previous demo. */
6686
- prev(): void;
6687
- /** Current demo index. */
6688
- getIndex(): number;
6689
- /** Change the device viewport. */
6690
- setDevice(device: "desktop" | "mobile"): void;
6691
- /** Change the wrapper color scheme. */
6692
- setColorScheme(scheme: "light" | "dark"): void;
6693
- /** Override zoom level (null = auto-fit). */
6694
- setZoom(zoom: number | null): void;
6695
- /** Tear down listeners, observer, and DOM. */
6696
- destroy(): void;
6697
- }
6698
- declare function createDemoCarousel(container: HTMLElement, options: DemoCarouselOptions): DemoCarouselHandle;
6699
-
6700
6510
  declare const DEFAULT_PALETTE: {
6701
6511
  colors: {
6702
6512
  primary: {
@@ -7263,4 +7073,194 @@ declare function createVoiceProvider(config: VoiceConfig): VoiceProvider;
7263
7073
  declare function createBestAvailableVoiceProvider(config?: Partial<VoiceConfig>): VoiceProvider;
7264
7074
  declare function isVoiceSupported(config?: Partial<VoiceConfig>): boolean;
7265
7075
 
7076
+ type CodeFormat = "esm" | "script-installer" | "script-manual" | "script-advanced" | "react-component" | "react-advanced";
7077
+ /**
7078
+ * Hook code templates for code generation.
7079
+ * Each hook can be provided as a string (code template) OR as an actual function.
7080
+ * Functions are automatically serialized via `.toString()`.
7081
+ *
7082
+ * IMPORTANT: When providing functions:
7083
+ * - Functions must be self-contained (no external variables/closures)
7084
+ * - External variables will be undefined when the generated code runs
7085
+ * - Use arrow functions or regular function expressions
7086
+ *
7087
+ * @example
7088
+ * ```typescript
7089
+ * // Both of these work:
7090
+ *
7091
+ * // As string:
7092
+ * { getHeaders: "async () => ({ 'Authorization': 'Bearer token' })" }
7093
+ *
7094
+ * // As function (recommended - better IDE support):
7095
+ * { getHeaders: async () => ({ 'Authorization': 'Bearer token' }) }
7096
+ * ```
7097
+ */
7098
+ type CodeGeneratorHooks = {
7099
+ /**
7100
+ * Custom getHeaders function.
7101
+ * Should return an object with header key-value pairs.
7102
+ *
7103
+ * @example
7104
+ * ```typescript
7105
+ * async () => ({ 'Authorization': `Bearer ${await getAuthToken()}` })
7106
+ * ```
7107
+ */
7108
+ getHeaders?: string | (() => Record<string, string> | Promise<Record<string, string>>);
7109
+ /**
7110
+ * Custom onFeedback callback for message actions.
7111
+ * Receives a feedback object with type, messageId, and message.
7112
+ *
7113
+ * @example
7114
+ * ```typescript
7115
+ * (feedback) => { console.log('Feedback:', feedback.type); }
7116
+ * ```
7117
+ */
7118
+ onFeedback?: string | ((feedback: {
7119
+ type: string;
7120
+ messageId: string;
7121
+ message: unknown;
7122
+ }) => void);
7123
+ /**
7124
+ * Custom onCopy callback for message actions.
7125
+ * Receives the message that was copied.
7126
+ *
7127
+ * @example
7128
+ * ```typescript
7129
+ * (message) => { analytics.track('message_copied', { id: message.id }); }
7130
+ * ```
7131
+ */
7132
+ onCopy?: string | ((message: unknown) => void);
7133
+ /**
7134
+ * Custom requestMiddleware function.
7135
+ * Receives { payload, config } context.
7136
+ *
7137
+ * @example
7138
+ * ```typescript
7139
+ * ({ payload }) => ({ ...payload, metadata: { pageUrl: window.location.href } })
7140
+ * ```
7141
+ */
7142
+ requestMiddleware?: string | ((context: {
7143
+ payload: unknown;
7144
+ config: unknown;
7145
+ }) => unknown);
7146
+ /**
7147
+ * Custom action handlers array.
7148
+ * Array of handler functions.
7149
+ *
7150
+ * @example
7151
+ * ```typescript
7152
+ * [
7153
+ * (action, context) => {
7154
+ * if (action.type === 'custom') {
7155
+ * return { handled: true };
7156
+ * }
7157
+ * }
7158
+ * ]
7159
+ * ```
7160
+ */
7161
+ actionHandlers?: string | Array<(action: unknown, context: unknown) => unknown>;
7162
+ /**
7163
+ * Custom action parsers array.
7164
+ * Array of parser functions.
7165
+ */
7166
+ actionParsers?: string | Array<(context: unknown) => unknown>;
7167
+ /**
7168
+ * Custom postprocessMessage function.
7169
+ * Receives { text, message, streaming, raw } context.
7170
+ * Will override the default markdownPostprocessor.
7171
+ *
7172
+ * @example
7173
+ * ```typescript
7174
+ * ({ text }) => customMarkdownProcessor(text)
7175
+ * ```
7176
+ */
7177
+ postprocessMessage?: string | ((context: {
7178
+ text: string;
7179
+ message?: unknown;
7180
+ streaming?: boolean;
7181
+ raw?: string;
7182
+ }) => string);
7183
+ /**
7184
+ * Custom context providers array.
7185
+ * Array of provider functions.
7186
+ */
7187
+ contextProviders?: string | Array<() => unknown>;
7188
+ /**
7189
+ * Custom stream parser factory.
7190
+ * Should be a function that returns a StreamParser.
7191
+ */
7192
+ streamParser?: string | (() => unknown);
7193
+ };
7194
+ /**
7195
+ * Options for code generation beyond format selection.
7196
+ */
7197
+ type CodeGeneratorOptions = {
7198
+ /**
7199
+ * Custom hook code to inject into the generated snippet.
7200
+ * Hooks are JavaScript/TypeScript code strings that will be
7201
+ * inserted at appropriate locations in the output.
7202
+ */
7203
+ hooks?: CodeGeneratorHooks;
7204
+ /**
7205
+ * Whether to include comments explaining each hook.
7206
+ * @default true
7207
+ */
7208
+ includeHookComments?: boolean;
7209
+ /**
7210
+ * If provided, emits `windowKey` in the generated `initAgentWidget()` call
7211
+ * so the widget handle is stored on `window[windowKey]`.
7212
+ * Only affects script formats (script-installer, script-manual, script-advanced).
7213
+ */
7214
+ windowKey?: string;
7215
+ };
7216
+ declare function generateCodeSnippet(config: any, format?: CodeFormat, options?: CodeGeneratorOptions): string;
7217
+
7218
+ interface DemoCarouselItem {
7219
+ /** URL to load in the iframe (relative or absolute). */
7220
+ url: string;
7221
+ /** Display title shown in the toolbar. */
7222
+ title: string;
7223
+ /** Optional subtitle/description. */
7224
+ description?: string;
7225
+ }
7226
+ interface DemoCarouselOptions {
7227
+ /** Demo pages to cycle through. */
7228
+ items: DemoCarouselItem[];
7229
+ /** Initial item index. Default: 0. */
7230
+ initialIndex?: number;
7231
+ /** Initial device viewport. Default: 'desktop'. */
7232
+ initialDevice?: "desktop" | "mobile";
7233
+ /** Initial color scheme for the iframe wrapper. Default: 'light'. */
7234
+ initialColorScheme?: "light" | "dark";
7235
+ /** Show zoom +/- controls. Default: true. */
7236
+ showZoomControls?: boolean;
7237
+ /** Show desktop/mobile toggle. Default: true. */
7238
+ showDeviceToggle?: boolean;
7239
+ /** Show light/dark scheme toggle. Default: true. */
7240
+ showColorSchemeToggle?: boolean;
7241
+ /** Called when the active demo changes. */
7242
+ onChange?: (index: number, item: DemoCarouselItem) => void;
7243
+ }
7244
+ interface DemoCarouselHandle {
7245
+ /** Root element (already appended to the container). */
7246
+ element: HTMLElement;
7247
+ /** Navigate to a demo by index. */
7248
+ goTo(index: number): void;
7249
+ /** Go to the next demo. */
7250
+ next(): void;
7251
+ /** Go to the previous demo. */
7252
+ prev(): void;
7253
+ /** Current demo index. */
7254
+ getIndex(): number;
7255
+ /** Change the device viewport. */
7256
+ setDevice(device: "desktop" | "mobile"): void;
7257
+ /** Change the wrapper color scheme. */
7258
+ setColorScheme(scheme: "light" | "dark"): void;
7259
+ /** Override zoom level (null = auto-fit). */
7260
+ setZoom(zoom: number | null): void;
7261
+ /** Tear down listeners, observer, and DOM. */
7262
+ destroy(): void;
7263
+ }
7264
+ declare function createDemoCarousel(container: HTMLElement, options: DemoCarouselOptions): DemoCarouselHandle;
7265
+
7266
7266
  export { ASK_USER_QUESTION_TOOL_NAME, type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentToolsConfig, type AgentWidgetActionContext, type AgentWidgetActionEventPayload, type AgentWidgetActionHandler, type AgentWidgetActionHandlerResult, type AgentWidgetActionParser, type AgentWidgetAgentRequestPayload, type AgentWidgetApproval, type AgentWidgetApprovalConfig, type AgentWidgetArtifactsFeature, type AgentWidgetArtifactsLayoutConfig, type AgentWidgetAskUserQuestionFeature, type AgentWidgetAskUserQuestionStyles, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetComposerConfig, type AgentWidgetConfig, type AgentWidgetContextProvider, type AgentWidgetContextProviderContext, type AgentWidgetController, type AgentWidgetControllerEventMap, type AgentWidgetCustomFetch, type AgentWidgetDockConfig, 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 AgentWidgetParsedAction, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamAnimationBuffer, type AgentWidgetStreamAnimationBuiltinType, type AgentWidgetStreamAnimationFeature, type AgentWidgetStreamAnimationPlaceholder, type AgentWidgetStreamAnimationType, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTimestampConfig, type AgentWidgetWebMcpConfig, type ArtifactConfigPayload, type ArtifactPaneTokens, type ArtifactTabTokens, type ArtifactToolbarTokens, type AskUserQuestionOption, type AskUserQuestionPayload, type AskUserQuestionPrompt, AttachmentManager, type AttachmentManagerConfig, type BorderScale, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type ClientToolDefinition, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ColorPalette, type ColorShade, type ComboButtonHandle, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComponentTokens, type ComposerBuildContext, type ComposerElements, type ContentPart, type CreateComboButtonOptions, type CreateDropdownOptions, type CreateIconButtonOptions, type CreateLabelButtonOptions, type CreateStandardBubbleOptions, type CreateThemeOptions, type CreateToggleGroupOptions, DEFAULT_COMPONENTS, DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH, DEFAULT_FLOATING_LAUNCHER_WIDTH, DEFAULT_PALETTE, DEFAULT_SEMANTIC, DEFAULT_WIDGET_CONFIG, type DeepPartial, type DemoCarouselHandle, type DemoCarouselItem, type DemoCarouselOptions, type DomContextMode, type DomContextOptions, type DropdownMenuHandle, type DropdownMenuItem, type EnrichedPageElement, type EventStreamBadgeColor, type EventStreamConfig, type EventStreamPayloadRenderContext, type EventStreamRowRenderContext, type EventStreamToolbarRenderContext, type EventStreamViewRenderContext, type FormatEnrichedContextOptions, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type IconButtonTokens, type IconName, type IdleIndicatorRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectComponentDirectiveOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type LabelButtonTokens, type LoadingIndicatorRenderContext, type LoadingIndicatorRenderer, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, PRESETS, PRESET_FULLSCREEN, PRESET_MINIMAL, PRESET_SHOP, type ParseOptionsConfig, type ParseRule, type PendingAttachment, type PersonaArtifactKind, type PersonaArtifactManualUpsert, type PersonaArtifactRecord, type PersonaTheme, type PersonaThemePlugin, type RadiusScale, type RuleScoringContext, type SSEEventCallback, type SSEEventRecord, type SanitizeFunction, type SemanticColors, type SemanticSpacing, type SemanticTypography, type ShadowScale, type SlotRenderContext, type SlotRenderer, type SpacingScale, type StreamAnimationContext, type StreamAnimationPlugin, THEME_ZONES, type TextContentPart, type ThemeValidationError, type ThemeValidationResult, type ThemeZone, type ToggleGroupHandle, type ToggleGroupItem, type ToggleGroupTokens, type TokenReference, type TypographyScale, VERSION, type VoiceConfig, type VoiceProvider, type VoiceResult, type VoiceStatus, WEBMCP_TOOL_PREFIX, WebMcpBridge, type WebMcpConfirmHandler, type WebMcpConfirmInfo, type WebMcpToolResult, type WidgetHostLayout, type WidgetHostLayoutMode, type WidgetLayoutSlot, type WidgetPreset, accessibilityPlugin, animationsPlugin, applyThemeVariables, attachHeaderToContainer, brandPlugin, buildComposer, buildDefaultHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, collectEnrichedPageContext, componentRegistry, createActionManager, createAgentExperience, createAskUserQuestionBubble, createBestAvailableVoiceProvider, createBubbleWithLayout, createCSATFeedback, createComboButton, createComponentMiddleware, createComponentStreamParser, createDefaultSanitizer, createDemoCarousel, createDirectivePostprocessor, createDropdownMenu, createFlexibleJsonStreamParser, createIconButton, createImagePart, createJsonStreamParser, createLabelButton, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createPlugin, createRegexJsonParser, createStandardBubble, createTextPart, createTheme, createThemeObserver, createToggleGroup, createTypingIndicator, createVoiceProvider, createWidgetHostLayout, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, defaultParseRules, detectColorScheme, directivePostprocessor, ensureAskUserQuestionSheet, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, formatEnrichedContext, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateStableSelector, generateUserMessageId, getActiveTheme, getColorScheme, getDisplayText, getHeaderLayout, getImageParts, getPreset, hasComponentDirective, hasImages, headerLayouts, highContrastPlugin, initAgentWidget, isAskUserQuestionMessage, isComponentDirectiveType, isDockedMountMode, isVoiceSupported, isWebMcpToolName, listRegisteredStreamAnimations, markdownPostprocessor, mergeWithDefaults, normalizeContent, parseAskUserQuestionPayload, pluginRegistry, reducedMotionPlugin, registerStreamAnimationPlugin, removeAskUserQuestionSheet, renderComponentDirective, renderLoadingIndicatorWithFallback, renderLucideIcon, resolveDockConfig, resolveSanitizer, resolveTokens, stripWebMcpPrefix, themeToCssVariables, unregisterStreamAnimationPlugin, validateImageFile, validateTheme };