@runtypelabs/persona 3.19.0 → 3.20.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
@@ -4266,6 +4266,22 @@ type InjectMessageOptions = {
4266
4266
  * Consumers can detect this in `messageTransform` to render custom UI.
4267
4267
  */
4268
4268
  voiceProcessing?: boolean;
4269
+ /**
4270
+ * Raw structured payload (typically a JSON string) representing the
4271
+ * full directive that produced this message — e.g. `{ "text": "...",
4272
+ * "component": "Foo", "props": {...} }`.
4273
+ *
4274
+ * Mirrors the field populated by stream parsers during normal LLM
4275
+ * responses. Set this when injecting a message that should render as a
4276
+ * component directive (`hasComponentDirective` /
4277
+ * `extractComponentDirectiveFromMessage` look at `rawContent` first).
4278
+ *
4279
+ * Priority for the API payload remains:
4280
+ * `contentParts > llmContent > rawContent > content`. Pass `llmContent`
4281
+ * alongside `rawContent` if the LLM should see something other than the
4282
+ * raw directive.
4283
+ */
4284
+ rawContent?: string;
4269
4285
  };
4270
4286
  /**
4271
4287
  * Options for injecting assistant messages (most common case).
@@ -4282,6 +4298,57 @@ type InjectUserMessageOptions = Omit<InjectMessageOptions, "role">;
4282
4298
  * Role defaults to 'system'.
4283
4299
  */
4284
4300
  type InjectSystemMessageOptions = Omit<InjectMessageOptions, "role">;
4301
+ /**
4302
+ * Options for injecting an assistant message that renders as a component
4303
+ * directive — sugar over `injectAssistantMessage` for the common case of
4304
+ * "render this registered component, same as if the LLM had emitted it".
4305
+ *
4306
+ * Equivalent to calling `injectAssistantMessage({ content: text, rawContent:
4307
+ * JSON.stringify({ text, component, props }), llmContent })`.
4308
+ *
4309
+ * @example
4310
+ * widget.injectComponentDirective({
4311
+ * component: "DynamicForm",
4312
+ * props: { title: "Book a demo", fields: [...] },
4313
+ * text: "Share your details to book a demo.",
4314
+ * llmContent: "[Showed booking form]"
4315
+ * });
4316
+ */
4317
+ type InjectComponentDirectiveOptions = {
4318
+ /**
4319
+ * Name of a renderer registered via `componentRegistry.register(...)`.
4320
+ */
4321
+ component: string;
4322
+ /**
4323
+ * Props passed to the component renderer.
4324
+ */
4325
+ props?: Record<string, unknown>;
4326
+ /**
4327
+ * Bubble copy displayed above (or with) the rendered component.
4328
+ * Mirrors the `text` field in a streamed JSON directive.
4329
+ * @default ""
4330
+ */
4331
+ text?: string;
4332
+ /**
4333
+ * Content sent to the LLM in API requests. When omitted, the raw
4334
+ * directive JSON is what the LLM would see (per the standard
4335
+ * priority chain). Provide a redacted/short version to avoid sending
4336
+ * the full directive in subsequent turns.
4337
+ */
4338
+ llmContent?: string;
4339
+ /**
4340
+ * Optional message ID. If omitted, an assistant id is auto-generated.
4341
+ */
4342
+ id?: string;
4343
+ /**
4344
+ * Optional creation timestamp (ISO string). If omitted, uses current time.
4345
+ */
4346
+ createdAt?: string;
4347
+ /**
4348
+ * Optional sequence number for ordering.
4349
+ */
4350
+ sequence?: number;
4351
+ };
4285
4352
  type PersonaArtifactRecord = {
4286
4353
  id: string;
4287
4354
  artifactType: PersonaArtifactKind;
@@ -4738,6 +4805,24 @@ declare class AgentWidgetSession {
4738
4805
  * Inject multiple messages in a single batch with one sort and one render pass.
4739
4806
  */
4740
4807
  injectMessageBatch(optionsList: InjectMessageOptions[]): AgentWidgetMessage[];
4808
+ /**
4809
+ * Convenience method for injecting a registered component directive as
4810
+ * an assistant message — the same shape Persona produces from a streamed
4811
+ * `{ "text": "...", "component": "...", "props": {...} }` payload.
4812
+ *
4813
+ * Sets `content` to `text`, `rawContent` to the JSON directive (so
4814
+ * `extractComponentDirectiveFromMessage` can find it), and forwards
4815
+ * `llmContent` / `id` / `createdAt` / `sequence`.
4816
+ *
4817
+ * @example
4818
+ * session.injectComponentDirective({
4819
+ * component: "DynamicForm",
4820
+ * props: { title: "Book a demo", fields: [...] },
4821
+ * text: "Share your details to book a demo.",
4822
+ * llmContent: "[Showed booking form]"
4823
+ * });
4824
+ */
4825
+ injectComponentDirective(options: InjectComponentDirectiveOptions): AgentWidgetMessage;
4741
4826
  sendMessage(rawInput: string, options?: {
4742
4827
  viaVoice?: boolean;
4743
4828
  /** Multi-modal content parts (e.g., images) to include with the message */
@@ -4931,6 +5016,12 @@ type Controller = {
4931
5016
  * Inject multiple messages in a single batch with one sort and one render pass.
4932
5017
  */
4933
5018
  injectMessageBatch: (optionsList: InjectMessageOptions[]) => AgentWidgetMessage[];
5019
+ /**
5020
+ * Convenience method for injecting an assistant message that renders as a
5021
+ * registered component — same shape Persona produces from a streamed
5022
+ * `{ "text": "...", "component": "...", "props": {...} }` payload.
5023
+ */
5024
+ injectComponentDirective: (options: InjectComponentDirectiveOptions) => AgentWidgetMessage;
4934
5025
  /**
4935
5026
  * @deprecated Use injectMessage() instead.
4936
5027
  */
@@ -6504,11 +6595,20 @@ declare function createComponentMiddleware(): {
6504
6595
  reset: () => void;
6505
6596
  };
6506
6597
  /**
6507
- * Checks if a message contains a component directive in its raw content
6598
+ * Checks if a message contains a component directive.
6599
+ *
6600
+ * Looks at `rawContent` first (the field set by stream parsers); falls back
6601
+ * to `content` when it looks like JSON, so injected messages that pass the
6602
+ * directive via `content` (or have no `rawContent`) are still recognized.
6508
6603
  */
6509
6604
  declare function hasComponentDirective(message: AgentWidgetMessage): boolean;
6510
6605
  /**
6511
- * Extracts component directive from a complete message
6606
+ * Extracts component directive from a complete message.
6607
+ *
6608
+ * Looks at `rawContent` first (the field set by stream parsers); falls back
6609
+ * to `content` when it looks like JSON, so injected messages that pass the
6610
+ * directive via `content` (or have no `rawContent`) render the same as
6611
+ * streamed ones.
6512
6612
  */
6513
6613
  declare function extractComponentDirectiveFromMessage(message: AgentWidgetMessage): ComponentDirective | null;
6514
6614
 
@@ -6660,4 +6760,4 @@ declare function createVoiceProvider(config: VoiceConfig): VoiceProvider;
6660
6760
  declare function createBestAvailableVoiceProvider(config?: Partial<VoiceConfig>): VoiceProvider;
6661
6761
  declare function isVoiceSupported(config?: Partial<VoiceConfig>): boolean;
6662
6762
 
6663
- export { ASK_USER_QUESTION_TOOL_NAME, type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentToolsConfig, type AgentWidgetAgentRequestPayload, type AgentWidgetApproval, type AgentWidgetApprovalConfig, type AgentWidgetArtifactsFeature, type AgentWidgetArtifactsLayoutConfig, type AgentWidgetAskUserQuestionFeature, type AgentWidgetAskUserQuestionStyles, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetComposerConfig, type AgentWidgetConfig, 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 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 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 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 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, 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, listRegisteredStreamAnimations, markdownPostprocessor, mergeWithDefaults, normalizeContent, parseAskUserQuestionPayload, pluginRegistry, reducedMotionPlugin, registerStreamAnimationPlugin, removeAskUserQuestionSheet, renderComponentDirective, renderLoadingIndicatorWithFallback, renderLucideIcon, resolveDockConfig, resolveSanitizer, resolveTokens, themeToCssVariables, unregisterStreamAnimationPlugin, validateImageFile, validateTheme };
6763
+ export { ASK_USER_QUESTION_TOOL_NAME, type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentToolsConfig, type AgentWidgetAgentRequestPayload, type AgentWidgetApproval, type AgentWidgetApprovalConfig, type AgentWidgetArtifactsFeature, type AgentWidgetArtifactsLayoutConfig, type AgentWidgetAskUserQuestionFeature, type AgentWidgetAskUserQuestionStyles, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetComposerConfig, type AgentWidgetConfig, 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 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 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 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, 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, listRegisteredStreamAnimations, markdownPostprocessor, mergeWithDefaults, normalizeContent, parseAskUserQuestionPayload, pluginRegistry, reducedMotionPlugin, registerStreamAnimationPlugin, removeAskUserQuestionSheet, renderComponentDirective, renderLoadingIndicatorWithFallback, renderLucideIcon, resolveDockConfig, resolveSanitizer, resolveTokens, themeToCssVariables, unregisterStreamAnimationPlugin, validateImageFile, validateTheme };
package/dist/index.d.ts CHANGED
@@ -4266,6 +4266,22 @@ type InjectMessageOptions = {
4266
4266
  * Consumers can detect this in `messageTransform` to render custom UI.
4267
4267
  */
4268
4268
  voiceProcessing?: boolean;
4269
+ /**
4270
+ * Raw structured payload (typically a JSON string) representing the
4271
+ * full directive that produced this message — e.g. `{ "text": "...",
4272
+ * "component": "Foo", "props": {...} }`.
4273
+ *
4274
+ * Mirrors the field populated by stream parsers during normal LLM
4275
+ * responses. Set this when injecting a message that should render as a
4276
+ * component directive (`hasComponentDirective` /
4277
+ * `extractComponentDirectiveFromMessage` look at `rawContent` first).
4278
+ *
4279
+ * Priority for the API payload remains:
4280
+ * `contentParts > llmContent > rawContent > content`. Pass `llmContent`
4281
+ * alongside `rawContent` if the LLM should see something other than the
4282
+ * raw directive.
4283
+ */
4284
+ rawContent?: string;
4269
4285
  };
4270
4286
  /**
4271
4287
  * Options for injecting assistant messages (most common case).
@@ -4282,6 +4298,57 @@ type InjectUserMessageOptions = Omit<InjectMessageOptions, "role">;
4282
4298
  * Role defaults to 'system'.
4283
4299
  */
4284
4300
  type InjectSystemMessageOptions = Omit<InjectMessageOptions, "role">;
4301
+ /**
4302
+ * Options for injecting an assistant message that renders as a component
4303
+ * directive — sugar over `injectAssistantMessage` for the common case of
4304
+ * "render this registered component, same as if the LLM had emitted it".
4305
+ *
4306
+ * Equivalent to calling `injectAssistantMessage({ content: text, rawContent:
4307
+ * JSON.stringify({ text, component, props }), llmContent })`.
4308
+ *
4309
+ * @example
4310
+ * widget.injectComponentDirective({
4311
+ * component: "DynamicForm",
4312
+ * props: { title: "Book a demo", fields: [...] },
4313
+ * text: "Share your details to book a demo.",
4314
+ * llmContent: "[Showed booking form]"
4315
+ * });
4316
+ */
4317
+ type InjectComponentDirectiveOptions = {
4318
+ /**
4319
+ * Name of a renderer registered via `componentRegistry.register(...)`.
4320
+ */
4321
+ component: string;
4322
+ /**
4323
+ * Props passed to the component renderer.
4324
+ */
4325
+ props?: Record<string, unknown>;
4326
+ /**
4327
+ * Bubble copy displayed above (or with) the rendered component.
4328
+ * Mirrors the `text` field in a streamed JSON directive.
4329
+ * @default ""
4330
+ */
4331
+ text?: string;
4332
+ /**
4333
+ * Content sent to the LLM in API requests. When omitted, the raw
4334
+ * directive JSON is what the LLM would see (per the standard
4335
+ * priority chain). Provide a redacted/short version to avoid sending
4336
+ * the full directive in subsequent turns.
4337
+ */
4338
+ llmContent?: string;
4339
+ /**
4340
+ * Optional message ID. If omitted, an assistant id is auto-generated.
4341
+ */
4342
+ id?: string;
4343
+ /**
4344
+ * Optional creation timestamp (ISO string). If omitted, uses current time.
4345
+ */
4346
+ createdAt?: string;
4347
+ /**
4348
+ * Optional sequence number for ordering.
4349
+ */
4350
+ sequence?: number;
4351
+ };
4285
4352
  type PersonaArtifactRecord = {
4286
4353
  id: string;
4287
4354
  artifactType: PersonaArtifactKind;
@@ -4738,6 +4805,24 @@ declare class AgentWidgetSession {
4738
4805
  * Inject multiple messages in a single batch with one sort and one render pass.
4739
4806
  */
4740
4807
  injectMessageBatch(optionsList: InjectMessageOptions[]): AgentWidgetMessage[];
4808
+ /**
4809
+ * Convenience method for injecting a registered component directive as
4810
+ * an assistant message — the same shape Persona produces from a streamed
4811
+ * `{ "text": "...", "component": "...", "props": {...} }` payload.
4812
+ *
4813
+ * Sets `content` to `text`, `rawContent` to the JSON directive (so
4814
+ * `extractComponentDirectiveFromMessage` can find it), and forwards
4815
+ * `llmContent` / `id` / `createdAt` / `sequence`.
4816
+ *
4817
+ * @example
4818
+ * session.injectComponentDirective({
4819
+ * component: "DynamicForm",
4820
+ * props: { title: "Book a demo", fields: [...] },
4821
+ * text: "Share your details to book a demo.",
4822
+ * llmContent: "[Showed booking form]"
4823
+ * });
4824
+ */
4825
+ injectComponentDirective(options: InjectComponentDirectiveOptions): AgentWidgetMessage;
4741
4826
  sendMessage(rawInput: string, options?: {
4742
4827
  viaVoice?: boolean;
4743
4828
  /** Multi-modal content parts (e.g., images) to include with the message */
@@ -4931,6 +5016,12 @@ type Controller = {
4931
5016
  * Inject multiple messages in a single batch with one sort and one render pass.
4932
5017
  */
4933
5018
  injectMessageBatch: (optionsList: InjectMessageOptions[]) => AgentWidgetMessage[];
5019
+ /**
5020
+ * Convenience method for injecting an assistant message that renders as a
5021
+ * registered component — same shape Persona produces from a streamed
5022
+ * `{ "text": "...", "component": "...", "props": {...} }` payload.
5023
+ */
5024
+ injectComponentDirective: (options: InjectComponentDirectiveOptions) => AgentWidgetMessage;
4934
5025
  /**
4935
5026
  * @deprecated Use injectMessage() instead.
4936
5027
  */
@@ -6504,11 +6595,20 @@ declare function createComponentMiddleware(): {
6504
6595
  reset: () => void;
6505
6596
  };
6506
6597
  /**
6507
- * Checks if a message contains a component directive in its raw content
6598
+ * Checks if a message contains a component directive.
6599
+ *
6600
+ * Looks at `rawContent` first (the field set by stream parsers); falls back
6601
+ * to `content` when it looks like JSON, so injected messages that pass the
6602
+ * directive via `content` (or have no `rawContent`) are still recognized.
6508
6603
  */
6509
6604
  declare function hasComponentDirective(message: AgentWidgetMessage): boolean;
6510
6605
  /**
6511
- * Extracts component directive from a complete message
6606
+ * Extracts component directive from a complete message.
6607
+ *
6608
+ * Looks at `rawContent` first (the field set by stream parsers); falls back
6609
+ * to `content` when it looks like JSON, so injected messages that pass the
6610
+ * directive via `content` (or have no `rawContent`) render the same as
6611
+ * streamed ones.
6512
6612
  */
6513
6613
  declare function extractComponentDirectiveFromMessage(message: AgentWidgetMessage): ComponentDirective | null;
6514
6614
 
@@ -6660,4 +6760,4 @@ declare function createVoiceProvider(config: VoiceConfig): VoiceProvider;
6660
6760
  declare function createBestAvailableVoiceProvider(config?: Partial<VoiceConfig>): VoiceProvider;
6661
6761
  declare function isVoiceSupported(config?: Partial<VoiceConfig>): boolean;
6662
6762
 
6663
- export { ASK_USER_QUESTION_TOOL_NAME, type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentToolsConfig, type AgentWidgetAgentRequestPayload, type AgentWidgetApproval, type AgentWidgetApprovalConfig, type AgentWidgetArtifactsFeature, type AgentWidgetArtifactsLayoutConfig, type AgentWidgetAskUserQuestionFeature, type AgentWidgetAskUserQuestionStyles, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetComposerConfig, type AgentWidgetConfig, 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 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 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 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 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, 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, listRegisteredStreamAnimations, markdownPostprocessor, mergeWithDefaults, normalizeContent, parseAskUserQuestionPayload, pluginRegistry, reducedMotionPlugin, registerStreamAnimationPlugin, removeAskUserQuestionSheet, renderComponentDirective, renderLoadingIndicatorWithFallback, renderLucideIcon, resolveDockConfig, resolveSanitizer, resolveTokens, themeToCssVariables, unregisterStreamAnimationPlugin, validateImageFile, validateTheme };
6763
+ export { ASK_USER_QUESTION_TOOL_NAME, type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentToolsConfig, type AgentWidgetAgentRequestPayload, type AgentWidgetApproval, type AgentWidgetApprovalConfig, type AgentWidgetArtifactsFeature, type AgentWidgetArtifactsLayoutConfig, type AgentWidgetAskUserQuestionFeature, type AgentWidgetAskUserQuestionStyles, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetComposerConfig, type AgentWidgetConfig, 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 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 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 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, 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, listRegisteredStreamAnimations, markdownPostprocessor, mergeWithDefaults, normalizeContent, parseAskUserQuestionPayload, pluginRegistry, reducedMotionPlugin, registerStreamAnimationPlugin, removeAskUserQuestionSheet, renderComponentDirective, renderLoadingIndicatorWithFallback, renderLucideIcon, resolveDockConfig, resolveSanitizer, resolveTokens, themeToCssVariables, unregisterStreamAnimationPlugin, validateImageFile, validateTheme };