@runtypelabs/persona 4.14.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 (81) 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 +241 -16
  14. package/dist/context-mentions.d.ts +241 -16
  15. package/dist/context-mentions.js +11 -8
  16. package/dist/index.cjs +67 -66
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +301 -41
  19. package/dist/index.d.ts +301 -41
  20. package/dist/index.global.js +59 -56
  21. package/dist/index.global.js.map +1 -1
  22. package/dist/index.js +67 -66
  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 +241 -16
  27. package/dist/smart-dom-reader.d.ts +241 -16
  28. package/dist/theme-editor-preview.cjs +66 -66
  29. package/dist/theme-editor-preview.d.cts +255 -17
  30. package/dist/theme-editor-preview.d.ts +255 -17
  31. package/dist/theme-editor-preview.js +56 -56
  32. package/dist/theme-editor.cjs +5 -5
  33. package/dist/theme-editor.d.cts +242 -17
  34. package/dist/theme-editor.d.ts +242 -17
  35. package/dist/theme-editor.js +7 -7
  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/ask-user-question-tool.ts +10 -7
  43. package/src/components/artifact-preview.ts +1 -1
  44. package/src/components/composer-parts.test.ts +103 -4
  45. package/src/components/composer-parts.ts +53 -15
  46. package/src/components/messages.ts +5 -2
  47. package/src/components/panel.ts +31 -5
  48. package/src/components/pill-composer-builder.test.ts +18 -0
  49. package/src/components/suggestions.test.ts +233 -0
  50. package/src/components/suggestions.ts +463 -81
  51. package/src/components/widget-view.ts +4 -0
  52. package/src/defaults.ts +5 -3
  53. package/src/generated/runtype-openapi-contract.ts +17 -0
  54. package/src/index-core.ts +18 -2
  55. package/src/launcher-global.ts +1 -1
  56. package/src/plugins/types.ts +71 -3
  57. package/src/presets.ts +3 -3
  58. package/src/session.ts +10 -8
  59. package/src/styles/widget-styles.test.ts +162 -0
  60. package/src/styles/widget.css +430 -0
  61. package/src/suggest-replies-tool.test.ts +233 -2
  62. package/src/suggest-replies-tool.ts +115 -39
  63. package/src/theme-editor/preview-utils.test.ts +34 -0
  64. package/src/theme-editor/preview-utils.ts +77 -2
  65. package/src/theme-editor/sections.test.ts +33 -0
  66. package/src/theme-editor/sections.ts +53 -5
  67. package/src/theme-reference.ts +9 -2
  68. package/src/types/theme.ts +32 -0
  69. package/src/types.ts +152 -16
  70. package/src/ui.detached-panel.test.ts +1 -1
  71. package/src/ui.suggest-replies.test.ts +1066 -1
  72. package/src/ui.ts +268 -20
  73. package/src/utils/artifact-file.test.ts +1 -1
  74. package/src/utils/code-generators.test.ts +40 -0
  75. package/src/utils/code-generators.ts +22 -0
  76. package/src/utils/config-merge.test.ts +24 -0
  77. package/src/utils/icons.test.ts +26 -0
  78. package/src/utils/icons.ts +8 -0
  79. package/src/utils/theme.test.ts +79 -0
  80. package/src/utils/tokens.ts +64 -0
  81. package/dist/chunk-MMUPR2JW.js +0 -1
package/src/types.ts CHANGED
@@ -2257,10 +2257,13 @@ export type AgentWidgetFeatureFlags = {
2257
2257
  */
2258
2258
  askUserQuestion?: AgentWidgetAskUserQuestionFeature;
2259
2259
  /**
2260
- * Built-in `suggest_replies` quick-reply chips. When the assistant invokes
2261
- * the tool, the widget shows the suggestions as tappable chips above the
2262
- * composer (reusing the suggestion-chips surface) and immediately resumes
2263
- * the execution: fire-and-forget, no user input awaited.
2260
+ * Built-in `suggest_replies` follow-ups. When the assistant invokes the
2261
+ * tool, the widget shows the suggestions using `suggestions.followUps` and
2262
+ * immediately resumes the execution: fire-and-forget, no user input awaited.
2263
+ *
2264
+ * @deprecated Both keys moved to `suggestions.followUps`: use
2265
+ * `suggestions.followUps.enabled` and `suggestions.followUps.expose`. This
2266
+ * alias keeps working per key, with `suggestions.followUps` winning.
2264
2267
  */
2265
2268
  suggestReplies?: AgentWidgetSuggestRepliesFeature;
2266
2269
  };
@@ -2327,11 +2330,12 @@ export type WidgetPreferenceSlice = {
2327
2330
  };
2328
2331
 
2329
2332
  /**
2330
- * Feature config for the built-in `suggest_replies` quick-reply chips.
2331
- * Chips render in the existing suggestions slot above the composer and are
2332
- * styled by the widget-level `suggestionChipsConfig`. A tapped chip is sent
2333
- * verbatim as the user's next message; chips clear once any user message
2334
- * follows them.
2333
+ * Feature config for the built-in `suggest_replies` follow-ups.
2334
+ *
2335
+ * @deprecated Both keys moved to `suggestions.followUps`
2336
+ * (`suggestions.followUps.enabled` / `suggestions.followUps.expose`), which
2337
+ * also owns presentation, placement, and send/fill behavior. Resolution is
2338
+ * per key with `suggestions.followUps` winning; removal waits for 5.0.
2335
2339
  */
2336
2340
  export type AgentWidgetSuggestRepliesFeature = {
2337
2341
  /**
@@ -2339,14 +2343,18 @@ export type AgentWidgetSuggestRepliesFeature = {
2339
2343
  * renders as a regular tool bubble and is NOT auto-resumed: only set this
2340
2344
  * with no server-side `suggest_replies` declaration, or the execution
2341
2345
  * parks awaiting a resume that never comes.
2346
+ * @deprecated Use `suggestions.followUps.enabled`.
2342
2347
  */
2343
2348
  enabled?: boolean;
2344
2349
  /**
2345
2350
  * Advertise the built-in `suggest_replies` tool to the agent on every
2346
2351
  * dispatch via `clientTools[]`: no server-side `runtimeTools` declaration
2347
- * needed. Defaults to `false`: flows that already declare the tool via
2348
- * `runtimeTools` would otherwise present it to the model twice. Ignored
2349
- * when `enabled` is `false`.
2352
+ * needed. Defaults to `false`. Declare the tool in one place: the API
2353
+ * dedupes a double declaration by name with `clientTools[]` winning, so the
2354
+ * model still sees exactly one tool, but the widget's description and schema
2355
+ * win and the effective tool type becomes `local` (the execution pauses and
2356
+ * the widget auto-resumes it). Ignored when `enabled` is `false`.
2357
+ * @deprecated Use `suggestions.followUps.expose`.
2350
2358
  */
2351
2359
  expose?: boolean;
2352
2360
  };
@@ -2421,10 +2429,13 @@ export type AgentWidgetAskUserQuestionFeature = {
2421
2429
  * matching {@link AskUserQuestionPayload}; when the model calls it, the
2422
2430
  * existing answer-pill sheet renders and the answer resumes the execution.
2423
2431
  *
2424
- * Defaults to `false`: flows that already declare `ask_user_question` via
2425
- * `runtimeTools` would otherwise present the tool to the model twice.
2426
- * Ignored when `enabled` is `false`: never offer the agent a question
2427
- * tool the widget can't render an answer UI for.
2432
+ * Defaults to `false`. Declare the tool in one place: the API dedupes a
2433
+ * double declaration by name with `clientTools[]` winning, so the model
2434
+ * still sees exactly one tool, but the widget's description and schema win
2435
+ * and the effective tool type becomes `local` (the execution pauses and the
2436
+ * widget resumes it with the user's answer). Ignored when `enabled` is
2437
+ * `false`: never offer the agent a question tool the widget can't render an
2438
+ * answer UI for.
2428
2439
  */
2429
2440
  expose?: boolean;
2430
2441
  /** Slide-in animation duration in ms. Defaults to 180. */
@@ -2913,6 +2924,10 @@ export type AgentWidgetSendButtonConfig = {
2913
2924
  paddingY?: string;
2914
2925
  iconText?: string;
2915
2926
  iconName?: string;
2927
+ /** Icon glyph box in icon mode, e.g. "20px". Defaults to half of `size`. */
2928
+ iconSize?: string;
2929
+ /** Stroke width for the icon glyph, in viewBox units. Default 2. */
2930
+ iconStrokeWidth?: number;
2916
2931
  useIcon?: boolean;
2917
2932
  tooltipText?: string;
2918
2933
  showTooltip?: boolean;
@@ -3728,6 +3743,123 @@ export type AgentWidgetSuggestionChipsConfig = {
3728
3743
  paddingY?: string;
3729
3744
  };
3730
3745
 
3746
+ /** A suggested next action shown to the user. Strings remain supported as shorthand. */
3747
+ export type AgentWidgetSuggestion =
3748
+ | string
3749
+ | {
3750
+ /** Stable analytics / DOM identity. Falls back to the prompt or label. */
3751
+ id?: string;
3752
+ /** Concise visible action label. */
3753
+ label: string;
3754
+ /** Text placed in the composer or sent. Defaults to `label`. */
3755
+ prompt?: string;
3756
+ /** Optional supporting copy, most useful with the `card` variant. */
3757
+ description?: string;
3758
+ /** Optional icon from Persona's bundled Lucide registry. */
3759
+ icon?: IconName;
3760
+ /**
3761
+ * CSS color for this item's glyph. Tints the icon only: label, border,
3762
+ * and background stay neutral. Ignored without an `icon`.
3763
+ */
3764
+ iconColor?: string;
3765
+ /** Override the surface's click behavior for this item. */
3766
+ behavior?: AgentWidgetSuggestionBehavior;
3767
+ /** Visually promote one high-confidence action. */
3768
+ emphasis?: "default" | "primary";
3769
+ };
3770
+
3771
+ export type AgentWidgetSuggestionBehavior = "send" | "fill";
3772
+ export type AgentWidgetSuggestionVariant = "chip" | "card" | "list";
3773
+ export type AgentWidgetSuggestionSurface = "starter" | "followUp";
3774
+ /**
3775
+ * Who produced the rendered suggestions: static config, the agent's
3776
+ * `suggest_replies` tool, or `controller.setFollowUpSuggestions`.
3777
+ */
3778
+ export type AgentWidgetSuggestionSource = "config" | "agent" | "host";
3779
+
3780
+ /**
3781
+ * A suggestion after Persona has normalized shorthand strings and resolved the
3782
+ * effective click behavior. Plugin hooks receive this stable shape.
3783
+ */
3784
+ export type AgentWidgetResolvedSuggestion = {
3785
+ id: string;
3786
+ label: string;
3787
+ prompt: string;
3788
+ description?: string;
3789
+ icon?: IconName;
3790
+ /** CSS color for the glyph only; never the label, border, or background. */
3791
+ iconColor?: string;
3792
+ behavior: AgentWidgetSuggestionBehavior;
3793
+ emphasis: "default" | "primary";
3794
+ };
3795
+
3796
+ /** Presentation keys shared by every suggestion surface. */
3797
+ export type AgentWidgetSuggestionSurfaceConfig = {
3798
+ /** Item density. Defaults to `card` for starters and `chip` for follow-ups. */
3799
+ variant?: AgentWidgetSuggestionVariant;
3800
+ /** Default click behavior, overridable per item. Defaults to `send`. */
3801
+ behavior?: AgentWidgetSuggestionBehavior;
3802
+ /**
3803
+ * Layout for items past the surface width. Defaults to `wrap` for starters
3804
+ * and `scroll` for follow-ups. Applies to the `chip` variant only; the
3805
+ * `card` and `list` layouts manage their own stacking.
3806
+ */
3807
+ overflow?: "scroll" | "wrap";
3808
+ /** Maximum visible items. Defaults to 4. */
3809
+ maxItems?: number;
3810
+ };
3811
+
3812
+ export type AgentWidgetStarterSuggestionsConfig =
3813
+ AgentWidgetSuggestionSurfaceConfig & {
3814
+ /** Suggestions shown before the first user message. */
3815
+ items?: AgentWidgetSuggestion[];
3816
+ /**
3817
+ * `auto` uses the welcome surface when the welcome card renders and the
3818
+ * composer otherwise. Explicit values are literal: `welcome` renders
3819
+ * nothing when the welcome card is hidden. Defaults to `auto`.
3820
+ */
3821
+ placement?: "auto" | "welcome" | "composer";
3822
+ };
3823
+
3824
+ export type AgentWidgetFollowUpSuggestionsConfig =
3825
+ AgentWidgetSuggestionSurfaceConfig & {
3826
+ /**
3827
+ * Enable the built-in `suggest_replies` follow-ups. Defaults to true. When
3828
+ * false, `suggest_replies` renders as a regular tool bubble and is NOT
3829
+ * auto-resumed: only set this with no server-side `suggest_replies`
3830
+ * declaration, or the execution parks awaiting a resume that never comes.
3831
+ */
3832
+ enabled?: boolean;
3833
+ /**
3834
+ * Advertise the built-in `suggest_replies` tool to the agent on every
3835
+ * dispatch via `clientTools[]`: no server-side `runtimeTools` declaration
3836
+ * needed. Defaults to `false`. Declare the tool in one place: the API
3837
+ * dedupes a double declaration by name with `clientTools[]` winning, so
3838
+ * the model still sees exactly one tool, but the widget's description and
3839
+ * schema win and the effective tool type becomes `local` (the execution
3840
+ * pauses and the widget auto-resumes it). Ignored when `enabled` is
3841
+ * `false`.
3842
+ */
3843
+ expose?: boolean;
3844
+ /**
3845
+ * `auto` places follow-ups after the transcript in regular panels and above
3846
+ * the composer in composer-bar mode. Defaults to `auto`.
3847
+ */
3848
+ placement?: "auto" | "after-message" | "composer";
3849
+ // No `items`: follow-up items are contextual and come from the agent's
3850
+ // `suggest_replies` tool or `controller.setFollowUpSuggestions`, not static
3851
+ // config. Static lists are `starters`.
3852
+ };
3853
+
3854
+ /**
3855
+ * Structured suggestions configuration. The legacy `suggestionChips` and
3856
+ * `suggestionChipsConfig` fields remain supported for backwards compatibility.
3857
+ */
3858
+ export type AgentWidgetSuggestionsConfig = {
3859
+ starters?: AgentWidgetStarterSuggestionsConfig;
3860
+ followUps?: AgentWidgetFollowUpSuggestionsConfig;
3861
+ };
3862
+
3731
3863
  /**
3732
3864
  * Interface for pluggable stream parsers that extract text from streaming responses.
3733
3865
  * Parsers handle incremental parsing to extract text values from structured formats (JSON, XML, etc.).
@@ -5048,7 +5180,11 @@ export type AgentWidgetConfig = {
5048
5180
  * with `initialArtifacts`.
5049
5181
  */
5050
5182
  initialSelectedArtifactId?: string | null;
5183
+ /** Rich starter and follow-up suggestion surfaces. */
5184
+ suggestions?: AgentWidgetSuggestionsConfig;
5185
+ /** @deprecated Prefer `suggestions.starters.items`. */
5051
5186
  suggestionChips?: string[];
5187
+ /** @deprecated Prefer semantic tokens under `theme.components.suggestion`. */
5052
5188
  suggestionChipsConfig?: AgentWidgetSuggestionChipsConfig;
5053
5189
  debug?: boolean;
5054
5190
  formEndpoint?: string;
@@ -907,7 +907,7 @@ describe("createAgentExperience welded artifact split chrome", () => {
907
907
 
908
908
  controller.hideArtifacts();
909
909
 
910
- // Byte-identical to pane-closed: container carries the border, panel does not.
910
+ // Same as pane-closed: container carries the border, panel does not.
911
911
  expect(mount.classList.contains("persona-artifact-welded-split")).toBe(false);
912
912
  expect(container?.style.border).toContain("--persona-panel-border");
913
913
  expect(panel?.style.border).toBe("");