@runtypelabs/persona 4.13.0 → 4.15.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.
Files changed (106) hide show
  1. package/README.md +4 -4
  2. package/dist/animations/glyph-cycle.d.cts +1 -1
  3. package/dist/animations/glyph-cycle.d.ts +1 -1
  4. package/dist/animations/{types-DveIaNx6.d.cts → types-BpWGm7_6.d.cts} +17 -0
  5. package/dist/animations/{types-DveIaNx6.d.ts → types-BpWGm7_6.d.ts} +17 -0
  6. package/dist/animations/wipe.d.cts +1 -1
  7. package/dist/animations/wipe.d.ts +1 -1
  8. package/dist/chunk-QJ4LV2KW.js +1 -0
  9. package/dist/codegen.cjs +12 -11
  10. package/dist/codegen.js +14 -13
  11. package/dist/{context-mentions-ONG7A7M6.js → context-mentions-BTSTIBFC.js} +1 -1
  12. package/dist/context-mentions.cjs +11 -8
  13. package/dist/context-mentions.d.cts +339 -22
  14. package/dist/context-mentions.d.ts +339 -22
  15. package/dist/context-mentions.js +11 -8
  16. package/dist/index.cjs +68 -67
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +483 -48
  19. package/dist/index.d.ts +483 -48
  20. package/dist/index.global.js +61 -58
  21. package/dist/index.global.js.map +1 -1
  22. package/dist/index.js +70 -69
  23. package/dist/index.js.map +1 -1
  24. package/dist/launcher.global.js +5 -2
  25. package/dist/launcher.global.js.map +1 -1
  26. package/dist/smart-dom-reader.d.cts +339 -22
  27. package/dist/smart-dom-reader.d.ts +339 -22
  28. package/dist/theme-editor-preview.cjs +67 -67
  29. package/dist/theme-editor-preview.d.cts +355 -23
  30. package/dist/theme-editor-preview.d.ts +355 -23
  31. package/dist/theme-editor-preview.js +75 -75
  32. package/dist/theme-editor.cjs +10 -10
  33. package/dist/theme-editor.d.cts +376 -24
  34. package/dist/theme-editor.d.ts +376 -24
  35. package/dist/theme-editor.js +10 -10
  36. package/dist/theme-reference.cjs +1 -1
  37. package/dist/theme-reference.d.cts +38 -0
  38. package/dist/theme-reference.d.ts +38 -0
  39. package/dist/theme-reference.js +1 -1
  40. package/dist/widget.css +1 -1
  41. package/package.json +1 -1
  42. package/src/artifacts-session.test.ts +106 -0
  43. package/src/ask-user-question-tool.ts +10 -7
  44. package/src/client.test.ts +2 -2
  45. package/src/client.ts +4 -1
  46. package/src/components/artifact-card.ts +13 -2
  47. package/src/components/artifact-inline.ts +11 -2
  48. package/src/components/artifact-preview.ts +1 -1
  49. package/src/components/composer-builder.test.ts +2 -0
  50. package/src/components/composer-builder.ts +1 -1
  51. package/src/components/composer-parts.test.ts +105 -4
  52. package/src/components/composer-parts.ts +54 -16
  53. package/src/components/message-bubble.test.ts +7 -1
  54. package/src/components/message-bubble.ts +11 -8
  55. package/src/components/messages.ts +5 -2
  56. package/src/components/panel.ts +31 -5
  57. package/src/components/pill-composer-builder.test.ts +18 -0
  58. package/src/components/suggestions.test.ts +233 -0
  59. package/src/components/suggestions.ts +463 -81
  60. package/src/components/widget-view.ts +4 -0
  61. package/src/defaults.ts +5 -3
  62. package/src/generated/runtype-openapi-contract.ts +17 -0
  63. package/src/index-core.ts +52 -2
  64. package/src/launcher-global.ts +1 -1
  65. package/src/plugins/types.ts +71 -3
  66. package/src/presets.ts +3 -3
  67. package/src/session.ts +55 -12
  68. package/src/styles/widget-styles.test.ts +162 -0
  69. package/src/styles/widget.css +440 -1
  70. package/src/suggest-replies-tool.test.ts +233 -2
  71. package/src/suggest-replies-tool.ts +115 -39
  72. package/src/theme-editor/index.ts +5 -0
  73. package/src/theme-editor/presets.test.ts +43 -0
  74. package/src/theme-editor/presets.ts +101 -87
  75. package/src/theme-editor/preview-utils.test.ts +34 -0
  76. package/src/theme-editor/preview-utils.ts +77 -2
  77. package/src/theme-editor/sections.test.ts +72 -7
  78. package/src/theme-editor/sections.ts +113 -13
  79. package/src/theme-editor/state-preferences.test.ts +15 -0
  80. package/src/theme-editor/state.ts +46 -0
  81. package/src/theme-editor/types.ts +15 -1
  82. package/src/theme-editor/webmcp/tools.test.ts +13 -0
  83. package/src/theme-editor/webmcp/tools.ts +5 -0
  84. package/src/theme-reference.ts +9 -2
  85. package/src/types/theme.ts +32 -0
  86. package/src/types.ts +291 -25
  87. package/src/ui.artifact-pane-gating.test.ts +5 -5
  88. package/src/ui.config-preferences.test.ts +166 -0
  89. package/src/ui.detached-panel.test.ts +1 -1
  90. package/src/ui.suggest-replies.test.ts +1066 -1
  91. package/src/ui.ts +311 -45
  92. package/src/ui.typing-indicator.test.ts +135 -0
  93. package/src/utils/artifact-display.test.ts +180 -16
  94. package/src/utils/artifact-display.ts +155 -14
  95. package/src/utils/artifact-file.test.ts +1 -1
  96. package/src/utils/code-generators.test.ts +40 -0
  97. package/src/utils/code-generators.ts +22 -0
  98. package/src/utils/config-merge.test.ts +84 -0
  99. package/src/utils/config-merge.ts +6 -1
  100. package/src/utils/feature-preferences.test.ts +326 -0
  101. package/src/utils/feature-preferences.ts +498 -0
  102. package/src/utils/icons.test.ts +26 -0
  103. package/src/utils/icons.ts +8 -0
  104. package/src/utils/theme.test.ts +171 -0
  105. package/src/utils/tokens.ts +71 -7
  106. package/dist/chunk-MMUPR2JW.js +0 -1
@@ -339,6 +339,14 @@ interface ReasoningBubbleTokens {
339
339
  interface ComposerChromeTokens {
340
340
  /** Box-shadow on the composer form (raw CSS, e.g. `none`). */
341
341
  shadow: string;
342
+ /** Inner padding of the composer form (raw CSS shorthand). @default "0.75rem 1rem" */
343
+ padding?: string;
344
+ /** Gap between the textarea row and the actions row. @default "0.5rem" */
345
+ gap?: string;
346
+ /** Composer textarea font-size. @default "0.875rem" */
347
+ fontSize?: string;
348
+ /** Composer textarea line-height. @default "1.25rem" */
349
+ lineHeight?: string;
342
350
  }
343
351
  /** Artifact toolbar chrome. */
344
352
  interface ArtifactToolbarTokens {
@@ -488,6 +496,26 @@ interface ScrollToBottomTokens extends ComponentTokenSet {
488
496
  fontSize?: string;
489
497
  iconSize?: string;
490
498
  }
499
+ /** Visual tokens shared by one suggestion presentation variant. */
500
+ interface SuggestionVariantTokens extends ComponentTokenSet {
501
+ gap?: string;
502
+ minHeight?: string;
503
+ fontSize?: string;
504
+ lineHeight?: string;
505
+ iconSize?: string;
506
+ hoverBackground?: TokenReference<'color'>;
507
+ hoverForeground?: TokenReference<'color'>;
508
+ hoverBorder?: TokenReference<'color'>;
509
+ pressedBackground?: TokenReference<'color'>;
510
+ focusRing?: TokenReference<'color'>;
511
+ disabledOpacity?: string;
512
+ }
513
+ /** Starter and follow-up suggestion chrome. */
514
+ interface SuggestionTokens {
515
+ chip: SuggestionVariantTokens;
516
+ card: SuggestionVariantTokens;
517
+ list: SuggestionVariantTokens;
518
+ }
491
519
  /** Toggle group chrome (used by createToggleGroup). */
492
520
  interface ToggleGroupTokens {
493
521
  /** Gap between toggle buttons. Default: 0 (connected). */
@@ -518,6 +546,8 @@ interface ComponentTokens {
518
546
  labelButton?: LabelButtonTokens;
519
547
  /** Scroll-to-bottom indicator styling tokens. */
520
548
  scrollToBottom?: ScrollToBottomTokens;
549
+ /** Starter prompt and follow-up suggestion styling tokens. */
550
+ suggestion?: SuggestionTokens;
521
551
  /** Toggle group styling tokens. */
522
552
  toggleGroup?: ToggleGroupTokens;
523
553
  /** Artifact toolbar, tab strip, and pane chrome. */
@@ -559,6 +589,40 @@ type DeepPartial<T> = T extends object ? {
559
589
  [P in keyof T]?: DeepPartial<T[P]>;
560
590
  } : T;
561
591
 
592
+ type AgentWidgetTransformSuggestionsContext = {
593
+ /**
594
+ * Fresh copy of the suggestions entering this plugin, already normalized:
595
+ * shorthand strings expanded and the effective send/fill behavior resolved.
596
+ */
597
+ suggestions: AgentWidgetResolvedSuggestion[];
598
+ surface: AgentWidgetSuggestionSurface;
599
+ source: AgentWidgetSuggestionSource;
600
+ config: AgentWidgetConfig;
601
+ };
602
+ type AgentWidgetRenderSuggestionContext = {
603
+ /** Fully normalized suggestion, including the effective send/fill behavior. */
604
+ suggestion: AgentWidgetResolvedSuggestion;
605
+ index: number;
606
+ surface: AgentWidgetSuggestionSurface;
607
+ source: AgentWidgetSuggestionSource;
608
+ variant: AgentWidgetSuggestionVariant;
609
+ streaming: boolean;
610
+ config: AgentWidgetConfig;
611
+ /** Build Persona's standard chip, card, or list item. */
612
+ defaultRenderer: () => HTMLElement;
613
+ /**
614
+ * Run the normal selection pipeline: DOM event, plugin selection hooks, then
615
+ * send or fill. Custom renderers should call this instead of sending directly.
616
+ */
617
+ select: () => void;
618
+ };
619
+ type AgentWidgetSuggestionSelectContext = {
620
+ suggestion: AgentWidgetResolvedSuggestion;
621
+ surface: AgentWidgetSuggestionSurface;
622
+ source: AgentWidgetSuggestionSource;
623
+ variant: AgentWidgetSuggestionVariant;
624
+ config: AgentWidgetConfig;
625
+ };
562
626
  /**
563
627
  * Plugin interface for customizing widget components
564
628
  */
@@ -571,6 +635,25 @@ interface AgentWidgetPlugin {
571
635
  * Optional priority (higher = runs first). Default: 0
572
636
  */
573
637
  priority?: number;
638
+ /**
639
+ * Transform, filter, enrich, or reorder suggestions. Hooks receive normalized
640
+ * items and compose in plugin priority order; the return value may use the
641
+ * loose shape (string shorthand included) and is re-normalized before the next
642
+ * hook. A per-item `behavior` set here survives. `maxItems` caps the list
643
+ * after the full chain. Return an empty array to hide the surface.
644
+ */
645
+ transformSuggestions?: (context: AgentWidgetTransformSuggestionsContext) => AgentWidgetSuggestion[];
646
+ /**
647
+ * Render one starter or follow-up suggestion. Return null to use Persona's
648
+ * default chip/card/list renderer. Call `select()` from custom interaction
649
+ * controls to preserve events, selection hooks, and send/fill behavior.
650
+ */
651
+ renderSuggestion?: (context: AgentWidgetRenderSuggestionContext) => HTMLElement | null;
652
+ /**
653
+ * Observe or intercept a suggestion selection. Return false to cancel the
654
+ * built-in send/fill action. Hooks run in plugin priority order.
655
+ */
656
+ onSuggestionSelect?: (context: AgentWidgetSuggestionSelectContext) => void | boolean;
574
657
  /**
575
658
  * Custom renderer for message bubbles
576
659
  * Return null to use default renderer
@@ -1080,7 +1163,24 @@ type RuntypeExecutionStreamEvent = ({
1080
1163
  type: "source";
1081
1164
  url?: string;
1082
1165
  [key: string]: unknown;
1166
+ } | {
1167
+ executionId: string;
1168
+ iteration?: number;
1169
+ seq: number;
1170
+ state: Record<string, unknown>;
1171
+ type: "state_snapshot";
1083
1172
  } | ({
1173
+ executionId: string;
1174
+ iteration?: number;
1175
+ patch: Array<{
1176
+ from?: string;
1177
+ op: "add" | "remove" | "replace" | "move" | "copy" | "test";
1178
+ path: string;
1179
+ value?: unknown;
1180
+ }>;
1181
+ seq: number;
1182
+ type: "state_delta";
1183
+ }) | ({
1084
1184
  executionId: string;
1085
1185
  hiddenParameterNames?: Array<string>;
1086
1186
  iteration?: number;
@@ -1322,6 +1422,7 @@ declare const LUCIDE_ICONS: {
1322
1422
  readonly plus: IconNode;
1323
1423
  readonly minus: IconNode;
1324
1424
  readonly pencil: IconNode;
1425
+ readonly "pen-line": IconNode;
1325
1426
  readonly trash: IconNode;
1326
1427
  readonly "trash-2": IconNode;
1327
1428
  readonly save: IconNode;
@@ -1364,11 +1465,13 @@ declare const LUCIDE_ICONS: {
1364
1465
  readonly folder: IconNode;
1365
1466
  readonly "folder-open": IconNode;
1366
1467
  readonly files: IconNode;
1468
+ readonly "chart-column": IconNode;
1367
1469
  readonly sparkles: IconNode;
1368
1470
  readonly zap: IconNode;
1369
1471
  readonly sun: IconNode;
1370
1472
  readonly moon: IconNode;
1371
1473
  readonly flag: IconNode;
1474
+ readonly lightbulb: IconNode;
1372
1475
  readonly monitor: IconNode;
1373
1476
  readonly smartphone: IconNode;
1374
1477
  };
@@ -1968,6 +2071,14 @@ type AgentToolsConfig = {
1968
2071
  };
1969
2072
  /** Artifact kinds for the Persona sidebar and dispatch payload */
1970
2073
  type PersonaArtifactKind = "markdown" | "component";
2074
+ type PersonaArtifactPresentation = {
2075
+ /**
2076
+ * Producer hint for where this artifact renders (content-disposition
2077
+ * model). Beats configured defaults; loses to explicit `files`/`byKind`
2078
+ * rules. Persona never infers it; the producer or host supplies it.
2079
+ */
2080
+ preferredMode?: PersonaArtifactDisplayModeInput;
2081
+ };
1971
2082
  /**
1972
2083
  * Agent configuration for agent execution mode.
1973
2084
  * When provided in the widget config, enables agent loop execution instead of flow dispatch.
@@ -2496,7 +2607,48 @@ type AgentWidgetArtifactsLayoutConfig = {
2496
2607
  jsonPayload: string;
2497
2608
  }) => void | Promise<void>;
2498
2609
  };
2499
- type PersonaArtifactDisplayMode = "card" | "panel" | "inline";
2610
+ /**
2611
+ * Where the artifact body renders by default. Every mode shows the compact
2612
+ * reference in the transcript; the mode names where the body goes:
2613
+ * nowhere yet (`collapsed`), the side panel (`panel`), or the conversation
2614
+ * itself (`inline`).
2615
+ */
2616
+ type PersonaArtifactDisplayMode = "collapsed" | "panel" | "inline";
2617
+ /**
2618
+ * Accepted wherever a display mode is written. `"card"` is a deprecated
2619
+ * alias of `"collapsed"` (the old name described the reference card, which
2620
+ * every mode shows, instead of where the body renders). Resolution and
2621
+ * parsing always canonicalize to `"collapsed"`.
2622
+ */
2623
+ type PersonaArtifactDisplayModeInput = PersonaArtifactDisplayMode | "card";
2624
+ /**
2625
+ * Display rules for file-backed artifacts. `byMediaType` keys are exact MIME
2626
+ * types (`"text/html"`) or major-type wildcards (`"image/*"`), matched
2627
+ * case-insensitively without parameters; exact beats wildcard.
2628
+ */
2629
+ type PersonaArtifactFilesDisplayRules = {
2630
+ default?: PersonaArtifactDisplayModeInput;
2631
+ byMediaType?: Record<string, PersonaArtifactDisplayModeInput>;
2632
+ };
2633
+ /**
2634
+ * Scoped artifact display rules. Matching resolves from the most specific
2635
+ * selector to `default`; see `resolveArtifactDisplay`.
2636
+ *
2637
+ * Across preference layers, one merge rule applies everywhere: a string value
2638
+ * replaces the whole subtree it names; an object refines it per key. So
2639
+ * `files: "inline"` overrides every lower-layer file rule, while
2640
+ * `files: { default: "inline" }` keeps lower-layer MIME exceptions.
2641
+ */
2642
+ type PersonaArtifactDisplayRules = {
2643
+ default?: PersonaArtifactDisplayModeInput;
2644
+ byKind?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayModeInput>>;
2645
+ /**
2646
+ * @deprecated Use `byKind`. When both are present, `byKind` wins.
2647
+ */
2648
+ byType?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayModeInput>>;
2649
+ /** Rules for any artifact carrying file metadata. */
2650
+ files?: PersonaArtifactDisplayModeInput | PersonaArtifactFilesDisplayRules;
2651
+ };
2500
2652
  /** Context handed to custom artifact actions. Content fields are best-effort: resolved from live session state or, after a refresh, from the persisted reference-card payload. */
2501
2653
  type PersonaArtifactActionContext = {
2502
2654
  artifactId: string | null;
@@ -2553,13 +2705,10 @@ type AgentWidgetArtifactsFeature = {
2553
2705
  allowedTypes?: PersonaArtifactKind[];
2554
2706
  /**
2555
2707
  * Where artifact bodies render. A single mode applies to all artifacts;
2556
- * the object form sets a default plus per-type overrides.
2708
+ * the object form sets a default plus scoped overrides.
2557
2709
  * Defaults to "panel" (current behavior).
2558
2710
  */
2559
- display?: PersonaArtifactDisplayMode | {
2560
- default?: PersonaArtifactDisplayMode;
2561
- byType?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayMode>>;
2562
- };
2711
+ display?: PersonaArtifactDisplayModeInput | PersonaArtifactDisplayRules;
2563
2712
  /** Split / drawer dimensions and launcher widen behavior */
2564
2713
  layout?: AgentWidgetArtifactsLayoutConfig;
2565
2714
  /**
@@ -3281,19 +3430,63 @@ type AgentWidgetFeatureFlags = {
3281
3430
  */
3282
3431
  askUserQuestion?: AgentWidgetAskUserQuestionFeature;
3283
3432
  /**
3284
- * Built-in `suggest_replies` quick-reply chips. When the assistant invokes
3285
- * the tool, the widget shows the suggestions as tappable chips above the
3286
- * composer (reusing the suggestion-chips surface) and immediately resumes
3287
- * the execution: fire-and-forget, no user input awaited.
3433
+ * Built-in `suggest_replies` follow-ups. When the assistant invokes the
3434
+ * tool, the widget shows the suggestions using `suggestions.followUps` and
3435
+ * immediately resumes the execution: fire-and-forget, no user input awaited.
3436
+ *
3437
+ * @deprecated Both keys moved to `suggestions.followUps`: use
3438
+ * `suggestions.followUps.enabled` and `suggestions.followUps.expose`. This
3439
+ * alias keeps working per key, with `suggestions.followUps` winning.
3288
3440
  */
3289
3441
  suggestReplies?: AgentWidgetSuggestRepliesFeature;
3290
3442
  };
3443
+ type WidgetPreferenceCapabilities = {
3444
+ artifacts?: boolean;
3445
+ tools?: boolean;
3446
+ reasoning?: boolean;
3447
+ };
3291
3448
  /**
3292
- * Feature config for the built-in `suggest_replies` quick-reply chips.
3293
- * Chips render in the existing suggestions slot above the composer and are
3294
- * styled by the widget-level `suggestionChipsConfig`. A tapped chip is sent
3295
- * verbatim as the user's next message; chips clear once any user message
3296
- * follows them.
3449
+ * Persistable artifact-layout choices. The full layout config deliberately is
3450
+ * not exposed because it also contains callbacks and embedder-owned chrome.
3451
+ */
3452
+ type WidgetArtifactLayoutPreference = Pick<AgentWidgetArtifactsLayoutConfig, "paneWidth" | "paneMaxWidth" | "paneMinWidth" | "expandLauncherPanelWhenOpen" | "expandedPanelWidth" | "resizable" | "resizableMinWidth" | "resizableMaxWidth">;
3453
+ /**
3454
+ * Curated, JSON-serializable display preferences in native `features` shape.
3455
+ *
3456
+ * Absence means inherit the next preference layer and ultimately Persona's
3457
+ * current default. Persist only explicit choices; resetting a choice deletes
3458
+ * its key.
3459
+ *
3460
+ * Capability facts (`artifacts.enabled`, `allowedTypes`), trusted iframe
3461
+ * security, callbacks, actions, renderers, labels, and theme styling are
3462
+ * intentionally excluded because they remain embedder/code-owned.
3463
+ */
3464
+ type WidgetPreferenceSlice = {
3465
+ showToolCalls?: boolean;
3466
+ showReasoning?: boolean;
3467
+ toolCallDisplay?: Pick<AgentWidgetToolCallDisplayFeature, "collapsedMode" | "expandable" | "grouped" | "groupedMode" | "loadingAnimation">;
3468
+ reasoningDisplay?: Pick<AgentWidgetReasoningDisplayFeature, "expandable" | "activePreview">;
3469
+ artifacts?: {
3470
+ /**
3471
+ * String and object forms are both persistable and mean different things
3472
+ * when layers merge: a string replaces every lower-layer display rule; an
3473
+ * object refines lower layers per selector key (same rule applies to
3474
+ * `display.files`).
3475
+ */
3476
+ display?: PersonaArtifactDisplayModeInput | PersonaArtifactDisplayRules;
3477
+ filePreview?: {
3478
+ enabled?: boolean;
3479
+ };
3480
+ layout?: WidgetArtifactLayoutPreference;
3481
+ };
3482
+ };
3483
+ /**
3484
+ * Feature config for the built-in `suggest_replies` follow-ups.
3485
+ *
3486
+ * @deprecated Both keys moved to `suggestions.followUps`
3487
+ * (`suggestions.followUps.enabled` / `suggestions.followUps.expose`), which
3488
+ * also owns presentation, placement, and send/fill behavior. Resolution is
3489
+ * per key with `suggestions.followUps` winning; removal waits for 5.0.
3297
3490
  */
3298
3491
  type AgentWidgetSuggestRepliesFeature = {
3299
3492
  /**
@@ -3301,14 +3494,18 @@ type AgentWidgetSuggestRepliesFeature = {
3301
3494
  * renders as a regular tool bubble and is NOT auto-resumed: only set this
3302
3495
  * with no server-side `suggest_replies` declaration, or the execution
3303
3496
  * parks awaiting a resume that never comes.
3497
+ * @deprecated Use `suggestions.followUps.enabled`.
3304
3498
  */
3305
3499
  enabled?: boolean;
3306
3500
  /**
3307
3501
  * Advertise the built-in `suggest_replies` tool to the agent on every
3308
3502
  * dispatch via `clientTools[]`: no server-side `runtimeTools` declaration
3309
- * needed. Defaults to `false`: flows that already declare the tool via
3310
- * `runtimeTools` would otherwise present it to the model twice. Ignored
3311
- * when `enabled` is `false`.
3503
+ * needed. Defaults to `false`. Declare the tool in one place: the API
3504
+ * dedupes a double declaration by name with `clientTools[]` winning, so the
3505
+ * model still sees exactly one tool, but the widget's description and schema
3506
+ * win and the effective tool type becomes `local` (the execution pauses and
3507
+ * the widget auto-resumes it). Ignored when `enabled` is `false`.
3508
+ * @deprecated Use `suggestions.followUps.expose`.
3312
3509
  */
3313
3510
  expose?: boolean;
3314
3511
  };
@@ -3378,10 +3575,13 @@ type AgentWidgetAskUserQuestionFeature = {
3378
3575
  * matching {@link AskUserQuestionPayload}; when the model calls it, the
3379
3576
  * existing answer-pill sheet renders and the answer resumes the execution.
3380
3577
  *
3381
- * Defaults to `false`: flows that already declare `ask_user_question` via
3382
- * `runtimeTools` would otherwise present the tool to the model twice.
3383
- * Ignored when `enabled` is `false`: never offer the agent a question
3384
- * tool the widget can't render an answer UI for.
3578
+ * Defaults to `false`. Declare the tool in one place: the API dedupes a
3579
+ * double declaration by name with `clientTools[]` winning, so the model
3580
+ * still sees exactly one tool, but the widget's description and schema win
3581
+ * and the effective tool type becomes `local` (the execution pauses and the
3582
+ * widget resumes it with the user's answer). Ignored when `enabled` is
3583
+ * `false`: never offer the agent a question tool the widget can't render an
3584
+ * answer UI for.
3385
3585
  */
3386
3586
  expose?: boolean;
3387
3587
  /** Slide-in animation duration in ms. Defaults to 180. */
@@ -3854,6 +4054,10 @@ type AgentWidgetSendButtonConfig = {
3854
4054
  paddingY?: string;
3855
4055
  iconText?: string;
3856
4056
  iconName?: string;
4057
+ /** Icon glyph box in icon mode, e.g. "20px". Defaults to half of `size`. */
4058
+ iconSize?: string;
4059
+ /** Stroke width for the icon glyph, in viewBox units. Default 2. */
4060
+ iconStrokeWidth?: number;
3857
4061
  useIcon?: boolean;
3858
4062
  tooltipText?: string;
3859
4063
  showTooltip?: boolean;
@@ -4577,6 +4781,109 @@ type AgentWidgetSuggestionChipsConfig = {
4577
4781
  paddingX?: string;
4578
4782
  paddingY?: string;
4579
4783
  };
4784
+ /** A suggested next action shown to the user. Strings remain supported as shorthand. */
4785
+ type AgentWidgetSuggestion = string | {
4786
+ /** Stable analytics / DOM identity. Falls back to the prompt or label. */
4787
+ id?: string;
4788
+ /** Concise visible action label. */
4789
+ label: string;
4790
+ /** Text placed in the composer or sent. Defaults to `label`. */
4791
+ prompt?: string;
4792
+ /** Optional supporting copy, most useful with the `card` variant. */
4793
+ description?: string;
4794
+ /** Optional icon from Persona's bundled Lucide registry. */
4795
+ icon?: IconName;
4796
+ /**
4797
+ * CSS color for this item's glyph. Tints the icon only: label, border,
4798
+ * and background stay neutral. Ignored without an `icon`.
4799
+ */
4800
+ iconColor?: string;
4801
+ /** Override the surface's click behavior for this item. */
4802
+ behavior?: AgentWidgetSuggestionBehavior;
4803
+ /** Visually promote one high-confidence action. */
4804
+ emphasis?: "default" | "primary";
4805
+ };
4806
+ type AgentWidgetSuggestionBehavior = "send" | "fill";
4807
+ type AgentWidgetSuggestionVariant = "chip" | "card" | "list";
4808
+ type AgentWidgetSuggestionSurface = "starter" | "followUp";
4809
+ /**
4810
+ * Who produced the rendered suggestions: static config, the agent's
4811
+ * `suggest_replies` tool, or `controller.setFollowUpSuggestions`.
4812
+ */
4813
+ type AgentWidgetSuggestionSource = "config" | "agent" | "host";
4814
+ /**
4815
+ * A suggestion after Persona has normalized shorthand strings and resolved the
4816
+ * effective click behavior. Plugin hooks receive this stable shape.
4817
+ */
4818
+ type AgentWidgetResolvedSuggestion = {
4819
+ id: string;
4820
+ label: string;
4821
+ prompt: string;
4822
+ description?: string;
4823
+ icon?: IconName;
4824
+ /** CSS color for the glyph only; never the label, border, or background. */
4825
+ iconColor?: string;
4826
+ behavior: AgentWidgetSuggestionBehavior;
4827
+ emphasis: "default" | "primary";
4828
+ };
4829
+ /** Presentation keys shared by every suggestion surface. */
4830
+ type AgentWidgetSuggestionSurfaceConfig = {
4831
+ /** Item density. Defaults to `card` for starters and `chip` for follow-ups. */
4832
+ variant?: AgentWidgetSuggestionVariant;
4833
+ /** Default click behavior, overridable per item. Defaults to `send`. */
4834
+ behavior?: AgentWidgetSuggestionBehavior;
4835
+ /**
4836
+ * Layout for items past the surface width. Defaults to `wrap` for starters
4837
+ * and `scroll` for follow-ups. Applies to the `chip` variant only; the
4838
+ * `card` and `list` layouts manage their own stacking.
4839
+ */
4840
+ overflow?: "scroll" | "wrap";
4841
+ /** Maximum visible items. Defaults to 4. */
4842
+ maxItems?: number;
4843
+ };
4844
+ type AgentWidgetStarterSuggestionsConfig = AgentWidgetSuggestionSurfaceConfig & {
4845
+ /** Suggestions shown before the first user message. */
4846
+ items?: AgentWidgetSuggestion[];
4847
+ /**
4848
+ * `auto` uses the welcome surface when the welcome card renders and the
4849
+ * composer otherwise. Explicit values are literal: `welcome` renders
4850
+ * nothing when the welcome card is hidden. Defaults to `auto`.
4851
+ */
4852
+ placement?: "auto" | "welcome" | "composer";
4853
+ };
4854
+ type AgentWidgetFollowUpSuggestionsConfig = AgentWidgetSuggestionSurfaceConfig & {
4855
+ /**
4856
+ * Enable the built-in `suggest_replies` follow-ups. Defaults to true. When
4857
+ * false, `suggest_replies` renders as a regular tool bubble and is NOT
4858
+ * auto-resumed: only set this with no server-side `suggest_replies`
4859
+ * declaration, or the execution parks awaiting a resume that never comes.
4860
+ */
4861
+ enabled?: boolean;
4862
+ /**
4863
+ * Advertise the built-in `suggest_replies` tool to the agent on every
4864
+ * dispatch via `clientTools[]`: no server-side `runtimeTools` declaration
4865
+ * needed. Defaults to `false`. Declare the tool in one place: the API
4866
+ * dedupes a double declaration by name with `clientTools[]` winning, so
4867
+ * the model still sees exactly one tool, but the widget's description and
4868
+ * schema win and the effective tool type becomes `local` (the execution
4869
+ * pauses and the widget auto-resumes it). Ignored when `enabled` is
4870
+ * `false`.
4871
+ */
4872
+ expose?: boolean;
4873
+ /**
4874
+ * `auto` places follow-ups after the transcript in regular panels and above
4875
+ * the composer in composer-bar mode. Defaults to `auto`.
4876
+ */
4877
+ placement?: "auto" | "after-message" | "composer";
4878
+ };
4879
+ /**
4880
+ * Structured suggestions configuration. The legacy `suggestionChips` and
4881
+ * `suggestionChipsConfig` fields remain supported for backwards compatibility.
4882
+ */
4883
+ type AgentWidgetSuggestionsConfig = {
4884
+ starters?: AgentWidgetStarterSuggestionsConfig;
4885
+ followUps?: AgentWidgetFollowUpSuggestionsConfig;
4886
+ };
4580
4887
  /**
4581
4888
  * Interface for pluggable stream parsers that extract text from streaming responses.
4582
4889
  * Parsers handle incremental parsing to extract text values from structured formats (JSON, XML, etc.).
@@ -5729,6 +6036,15 @@ type AgentWidgetConfig = {
5729
6036
  */
5730
6037
  colorScheme?: 'auto' | 'light' | 'dark';
5731
6038
  features?: AgentWidgetFeatureFlags;
6039
+ /**
6040
+ * Per-instance display overrides, applied over `features` through the
6041
+ * preference allowlist (security/capability keys cannot pass). String
6042
+ * `display` values replace the base rule subtree; objects refine it per
6043
+ * key. Each `controller.update({ preferences })` replaces the previous
6044
+ * slice wholesale (dropped keys revert to the base `features`); an
6045
+ * explicit-undefined patch clears it entirely.
6046
+ */
6047
+ preferences?: WidgetPreferenceSlice;
5732
6048
  /**
5733
6049
  * When true, focus the chat input after the panel opens and the open animation completes.
5734
6050
  * Applies to launcher mode (user click, controller.open(), autoExpand) and inline mode (on init).
@@ -5749,7 +6065,11 @@ type AgentWidgetConfig = {
5749
6065
  * with `initialArtifacts`.
5750
6066
  */
5751
6067
  initialSelectedArtifactId?: string | null;
6068
+ /** Rich starter and follow-up suggestion surfaces. */
6069
+ suggestions?: AgentWidgetSuggestionsConfig;
6070
+ /** @deprecated Prefer `suggestions.starters.items`. */
5752
6071
  suggestionChips?: string[];
6072
+ /** @deprecated Prefer semantic tokens under `theme.components.suggestion`. */
5753
6073
  suggestionChipsConfig?: AgentWidgetSuggestionChipsConfig;
5754
6074
  debug?: boolean;
5755
6075
  formEndpoint?: string;
@@ -6489,6 +6809,8 @@ type PersonaArtifactRecord = {
6489
6809
  props?: Record<string, unknown>;
6490
6810
  /** Present when this markdown artifact is a previewable file (see PersonaArtifactFileMeta). */
6491
6811
  file?: PersonaArtifactFileMeta;
6812
+ /** Optional presentation metadata such as the producer's display-mode hint. */
6813
+ presentation?: PersonaArtifactPresentation;
6492
6814
  };
6493
6815
 
6494
6816
  /** Field definition types for the declarative configurator system (headless: no DOM) */
@@ -6569,6 +6891,12 @@ interface FieldDef {
6569
6891
  formatValue?: (value: unknown) => unknown;
6570
6892
  /** Convert control input back into the stored value shape */
6571
6893
  parseValue?: (value: unknown) => unknown;
6894
+ /** Capability required for hosts to render this field. */
6895
+ requiresCapability?: keyof WidgetPreferenceCapabilities;
6896
+ /** The host may offer an inherit/reset action which deletes this path. */
6897
+ unsettable?: boolean;
6898
+ /** Label for the inherit/reset action. Default: "Use default". */
6899
+ unsetLabel?: string;
6572
6900
  }
6573
6901
  interface SectionDef {
6574
6902
  id: string;
@@ -6579,6 +6907,8 @@ interface SectionDef {
6579
6907
  collapsed?: boolean;
6580
6908
  /** Preset buttons for this section */
6581
6909
  presets?: SectionPreset[];
6910
+ /** Capability required for hosts to render this section. */
6911
+ requiresCapability?: keyof WidgetPreferenceCapabilities;
6582
6912
  }
6583
6913
  interface SectionPreset {
6584
6914
  id: string;
@@ -6609,6 +6939,8 @@ interface ThemeEditorPreset {
6609
6939
  toolCall?: AgentWidgetToolCallConfig;
6610
6940
  /** Tool call styling for dark mode (falls back to toolCall if not set) */
6611
6941
  darkToolCall?: AgentWidgetToolCallConfig;
6942
+ /** Sparse, persistable widget behavior layered separately from theme tokens. */
6943
+ behavior?: WidgetPreferenceSlice;
6612
6944
  preview: {
6613
6945
  primary: string;
6614
6946
  surface: string;
@@ -6659,6 +6991,8 @@ declare class ThemeEditorState {
6659
6991
  * - everything else → writes into AgentWidgetConfig
6660
6992
  */
6661
6993
  set(path: string, value: unknown): void;
6994
+ /** Delete a dot-path and prune empty parents so sparse preferences inherit. */
6995
+ unset(path: string): void;
6662
6996
  /** Batch-set multiple paths at once */
6663
6997
  setBatch(updates: Record<string, unknown>): void;
6664
6998
  /** Replace the entire theme */
@@ -6695,6 +7029,8 @@ declare const COMPONENT_SHAPE_SECTIONS: SectionDef[];
6695
7029
  /** Component color sections (can be scoped for light/dark) */
6696
7030
  declare const COMPONENT_COLOR_SECTIONS: SectionDef[];
6697
7031
  declare const COMPONENTS_SECTIONS: SectionDef[];
7032
+ declare const ARTIFACT_DISPLAY_PREFERENCE_SECTION: SectionDef;
7033
+ declare const STREAM_AND_ARTIFACTS_SUB_GROUP: SubGroupDef;
6698
7034
  declare const CONFIGURE_SUB_GROUPS: SubGroupDef[];
6699
7035
  declare const CONFIGURE_SECTIONS: SectionDef[];
6700
7036
  /** Section 1: Theme: color mode selection */
@@ -6769,7 +7105,7 @@ declare const MOCK_WORKSPACE_CONTENT = "\n <div class=\"preview-workspace-con
6769
7105
  * using the exported templates and shell CSS utilities.
6770
7106
  */
6771
7107
  declare function buildSrcdoc(mountId: string, shellMode: 'light' | 'dark', docked: boolean, widgetCssPath: string): string;
6772
- type PreviewScene = 'home' | 'conversation' | 'minimized' | 'artifact';
7108
+ type PreviewScene = 'home' | 'conversation' | 'follow-ups' | 'minimized' | 'artifact';
6773
7109
  type PreviewTranscriptEntryPreset = 'user-message' | 'assistant-message' | 'assistant-code-block' | 'assistant-markdown-table' | 'assistant-image' | 'reasoning-streaming' | 'reasoning-complete' | 'tool-running' | 'tool-complete' | 'approval-request';
6774
7110
  declare function getPreviewTranscriptPresetLabel(preset: PreviewTranscriptEntryPreset): string;
6775
7111
  declare function createPreviewTranscriptEntry(preset: PreviewTranscriptEntryPreset, index?: number): AgentWidgetMessage;
@@ -6812,6 +7148,22 @@ interface PreviewConfigOptions {
6812
7148
  declare function buildPreviewConfig(options: PreviewConfigOptions, shellModeOverride?: 'light' | 'dark'): AgentWidgetConfig;
6813
7149
  declare function buildPreviewConfigWithMessages(options: PreviewConfigOptions, messages: AgentWidgetMessage[], shellModeOverride?: 'light' | 'dark'): AgentWidgetConfig;
6814
7150
 
7151
+ /**
7152
+ * Imperative preview renderer for the theme editor.
7153
+ * Import from `@runtypelabs/persona/theme-editor/preview` (not the headless
7154
+ * `@runtypelabs/persona/theme-editor` subpath, which omits the widget runtime).
7155
+ *
7156
+ * Manages iframe-based widget previews with device frames, zoom, scenes, and compare mode.
7157
+ * No external DOM dependencies: only needs a container element to mount into.
7158
+ *
7159
+ * For advanced preview needs (background URLs, inline editing, contrast checking),
7160
+ * use the lifecycle hooks in `ThemePreviewOptions` and import shared building blocks
7161
+ * from `./preview-utils` directly.
7162
+ */
7163
+
7164
+ type PreviewShellMode = 'light' | 'dark';
7165
+ type CompareMode = 'off' | 'baseline' | 'themes';
7166
+
6815
7167
  /**
6816
7168
  * Interface Role → Token mapping layer.
6817
7169
  *
@@ -7104,4 +7456,4 @@ declare function runContrastChecks(state: ThemeEditorLike, level?: ContrastLevel
7104
7456
  /** Compact contrast warnings for the regions a mutation touched. */
7105
7457
  declare function quickContrastWarnings(state: ThemeEditorLike, pairKeys: string[], variant?: 'light' | 'dark' | 'both', level?: ContrastLevel): ContrastWarning[];
7106
7458
 
7107
- export { ADVANCED_TOKENS_SECTION, ALL_ROLES, ALL_TABS, BRAND_PALETTE_SECTION, BUILT_IN_PRESETS, type BuildTranscriptStreamFramesOptions, COLORS_SECTIONS, COLOR_FAMILIES, COMPONENTS_SECTIONS, COMPONENT_COLOR_SECTIONS, COMPONENT_SHAPE_SECTIONS, CONFIGURE_SECTIONS, CONFIGURE_SUB_GROUPS, CONTRAST_PAIRS, CSS_NAMED_COLORS, type ColorScaleOptions, type ConfigChangeListener, type ConfiguratorSnapshot, type ContrastCheck, type ContrastLevel, type ContrastReport, type ContrastWarning, type CreateThemeEditorToolsOptions, DEVICE_DIMENSIONS, type DetectedRoleAssignment, type EditTarget, type FieldDef, type FieldType, HOME_SUGGESTION_CHIPS, INTERFACE_ROLES_SECTION, MOCK_BROWSER_CONTENT, MOCK_WORKSPACE_CONTENT, type OnChangeCallback, PALETTE_SECTION, PREVIEW_STORAGE_ADAPTER, type PreviewConfigOptions, type PreviewScene, type PreviewShellPalette, type PreviewTranscriptEntryPreset, RADIUS_PRESETS, ROLE_ASSISTANT_MESSAGES, ROLE_BORDERS, ROLE_FAMILIES, ROLE_FAMILY_LABELS, ROLE_HEADER, ROLE_INPUT, ROLE_INTENSITIES, ROLE_LINKS_FOCUS, ROLE_PRIMARY_ACTIONS, ROLE_SCROLL_TO_BOTTOM, ROLE_SURFACES, ROLE_USER_MESSAGES, type RoleAssignmentOptions, type RoleFamily, type RoleIntensity, type RoleState, type RoleTarget, type RoleTargetKind, SEMANTIC_COLORS_SECTION, SHADE_KEYS, SHELL_STYLE_ID, STATUS_COLORS_SECTION, STATUS_PALETTE_SECTION, STYLE_SECTIONS, STYLE_SECTIONS_V2, type SectionDef, type SectionPreset, type SelectOption, type SliderOptions, type SubGroupDef, THEME_EDITOR_PRESETS, THEME_SECTION, type TabDef, type ThemeEditorLike, type ThemeEditorPreset, ThemeEditorState, type ThemeSummary, type TokenRefOptions, type ToolAnnotations, type ToolContent, type ToolExecute, type ToolImageContent, type ToolResult, type ToolTextContent, type TranscriptStreamFrame, type WebMcpTool, ZOOM_MAX, ZOOM_MIN, appendPreviewTranscriptEntry, applySceneConfig, applyShellTheme, buildPreviewConfig, buildPreviewConfigWithMessages, buildShellCss, buildSrcdoc, buildSummary, buildTranscriptStreamFrames, coerceColor, coerceFamily, coerceIntensity, coerceRadius, coerceRoundnessStyle, coerceScheme, convertFromPx, convertToPx, createPreviewMessages, createPreviewTranscriptEntry, createThemeEditorTools, detectRoleAssignment, escapeHtml, findSection, formatCssValue, generateColorScale, getPreviewTranscriptPresetLabel, getShellPalette, getThemeEditorPreset, hexToHsl, hslToHex, isValidHex, normalizeColorValue, paletteColorPath, parseCssValue, presetStreamsText, quickContrastWarnings, resolveRoleAssignment, resolveThemeColorPath, rgbToHex, runContrastChecks, scopeSection, tokenRefDisplayName, toolResult, wcagContrastRatio };
7459
+ export { ADVANCED_TOKENS_SECTION, ALL_ROLES, ALL_TABS, ARTIFACT_DISPLAY_PREFERENCE_SECTION, BRAND_PALETTE_SECTION, BUILT_IN_PRESETS, type BuildTranscriptStreamFramesOptions, COLORS_SECTIONS, COLOR_FAMILIES, COMPONENTS_SECTIONS, COMPONENT_COLOR_SECTIONS, COMPONENT_SHAPE_SECTIONS, CONFIGURE_SECTIONS, CONFIGURE_SUB_GROUPS, CONTRAST_PAIRS, CSS_NAMED_COLORS, type ColorScaleOptions, type CompareMode, type ConfigChangeListener, type ConfiguratorSnapshot, type ContrastCheck, type ContrastLevel, type ContrastReport, type ContrastWarning, type CreateThemeEditorToolsOptions, DEVICE_DIMENSIONS, type DetectedRoleAssignment, type EditTarget, type FieldDef, type FieldType, HOME_SUGGESTION_CHIPS, INTERFACE_ROLES_SECTION, MOCK_BROWSER_CONTENT, MOCK_WORKSPACE_CONTENT, type OnChangeCallback, PALETTE_SECTION, PREVIEW_STORAGE_ADAPTER, type PreviewConfigOptions, type PreviewScene, type PreviewShellMode, type PreviewShellPalette, type PreviewTranscriptEntryPreset, RADIUS_PRESETS, ROLE_ASSISTANT_MESSAGES, ROLE_BORDERS, ROLE_FAMILIES, ROLE_FAMILY_LABELS, ROLE_HEADER, ROLE_INPUT, ROLE_INTENSITIES, ROLE_LINKS_FOCUS, ROLE_PRIMARY_ACTIONS, ROLE_SCROLL_TO_BOTTOM, ROLE_SURFACES, ROLE_USER_MESSAGES, type RoleAssignmentOptions, type RoleFamily, type RoleIntensity, type RoleState, type RoleTarget, type RoleTargetKind, SEMANTIC_COLORS_SECTION, SHADE_KEYS, SHELL_STYLE_ID, STATUS_COLORS_SECTION, STATUS_PALETTE_SECTION, STREAM_AND_ARTIFACTS_SUB_GROUP, STYLE_SECTIONS, STYLE_SECTIONS_V2, type SectionDef, type SectionPreset, type SelectOption, type SliderOptions, type SubGroupDef, THEME_EDITOR_PRESETS, THEME_SECTION, type TabDef, type ThemeEditorLike, type ThemeEditorPreset, ThemeEditorState, type ThemeSummary, type TokenRefOptions, type ToolAnnotations, type ToolContent, type ToolExecute, type ToolImageContent, type ToolResult, type ToolTextContent, type TranscriptStreamFrame, type WebMcpTool, ZOOM_MAX, ZOOM_MIN, appendPreviewTranscriptEntry, applySceneConfig, applyShellTheme, buildPreviewConfig, buildPreviewConfigWithMessages, buildShellCss, buildSrcdoc, buildSummary, buildTranscriptStreamFrames, coerceColor, coerceFamily, coerceIntensity, coerceRadius, coerceRoundnessStyle, coerceScheme, convertFromPx, convertToPx, createPreviewMessages, createPreviewTranscriptEntry, createThemeEditorTools, detectRoleAssignment, escapeHtml, findSection, formatCssValue, generateColorScale, getPreviewTranscriptPresetLabel, getShellPalette, getThemeEditorPreset, hexToHsl, hslToHex, isValidHex, normalizeColorValue, paletteColorPath, parseCssValue, presetStreamsText, quickContrastWarnings, resolveRoleAssignment, resolveThemeColorPath, rgbToHex, runContrastChecks, scopeSection, tokenRefDisplayName, toolResult, wcagContrastRatio };