@runtypelabs/persona 3.9.2 → 3.10.1

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 (39) hide show
  1. package/dist/index.cjs +45 -42
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +148 -0
  4. package/dist/index.d.ts +148 -0
  5. package/dist/index.global.js +67 -64
  6. package/dist/index.global.js.map +1 -1
  7. package/dist/index.js +45 -42
  8. package/dist/index.js.map +1 -1
  9. package/dist/theme-editor.cjs +959 -214
  10. package/dist/theme-editor.d.cts +157 -3
  11. package/dist/theme-editor.d.ts +157 -3
  12. package/dist/theme-editor.js +955 -214
  13. package/dist/theme-reference.cjs +1 -1
  14. package/dist/theme-reference.d.cts +8 -0
  15. package/dist/theme-reference.d.ts +8 -0
  16. package/dist/theme-reference.js +1 -1
  17. package/dist/widget.css +154 -0
  18. package/package.json +1 -1
  19. package/src/client.test.ts +312 -1
  20. package/src/client.ts +247 -24
  21. package/src/components/messages.ts +1 -1
  22. package/src/components/reasoning-bubble.ts +117 -28
  23. package/src/components/tool-bubble.ts +161 -27
  24. package/src/defaults.ts +12 -0
  25. package/src/styles/widget.css +154 -0
  26. package/src/theme-editor/index.ts +5 -0
  27. package/src/theme-editor/preview-utils.test.ts +58 -0
  28. package/src/theme-editor/preview-utils.ts +220 -4
  29. package/src/theme-editor/sections.test.ts +20 -0
  30. package/src/theme-editor/sections.ts +10 -0
  31. package/src/theme-reference.ts +8 -3
  32. package/src/tool-call-display-defaults.test.ts +23 -0
  33. package/src/types.ts +155 -0
  34. package/src/ui.attachments-drop.test.ts +188 -0
  35. package/src/ui.scroll.test.ts +150 -0
  36. package/src/ui.tool-display.test.ts +204 -0
  37. package/src/ui.ts +275 -7
  38. package/src/utils/message-fingerprint.test.ts +17 -0
  39. package/src/utils/message-fingerprint.ts +13 -1
package/dist/index.d.cts CHANGED
@@ -1176,12 +1176,71 @@ type AgentWidgetScrollToBottomFeature = {
1176
1176
  */
1177
1177
  label?: string;
1178
1178
  };
1179
+ type AgentWidgetToolCallCollapsedMode = "tool-call" | "tool-name" | "tool-preview";
1180
+ type AgentWidgetToolCallDisplayFeature = {
1181
+ /**
1182
+ * Controls what collapsed tool call rows show in their header/summary area.
1183
+ * @default "tool-call"
1184
+ */
1185
+ collapsedMode?: AgentWidgetToolCallCollapsedMode;
1186
+ /**
1187
+ * When true, active collapsed tool calls can render a lightweight preview block.
1188
+ * @default false
1189
+ */
1190
+ activePreview?: boolean;
1191
+ /**
1192
+ * Optional CSS min-height applied to active collapsed tool call rows.
1193
+ */
1194
+ activeMinHeight?: string;
1195
+ /**
1196
+ * Maximum preview lines shown for collapsed active tool calls.
1197
+ * @default 3
1198
+ */
1199
+ previewMaxLines?: number;
1200
+ /**
1201
+ * When true, consecutive tool call rows can be visually grouped.
1202
+ * @default false
1203
+ */
1204
+ grouped?: boolean;
1205
+ /**
1206
+ * When false, tool call bubbles show only the collapsed summary with no
1207
+ * expand/collapse toggle. Users see tool awareness without full details.
1208
+ * @default true
1209
+ */
1210
+ expandable?: boolean;
1211
+ };
1212
+ type AgentWidgetReasoningDisplayFeature = {
1213
+ /**
1214
+ * When true, active collapsed reasoning rows can render a lightweight preview block.
1215
+ * @default false
1216
+ */
1217
+ activePreview?: boolean;
1218
+ /**
1219
+ * Optional CSS min-height applied to active collapsed reasoning rows.
1220
+ */
1221
+ activeMinHeight?: string;
1222
+ /**
1223
+ * Maximum preview lines shown for collapsed active reasoning rows.
1224
+ * @default 3
1225
+ */
1226
+ previewMaxLines?: number;
1227
+ /**
1228
+ * When false, reasoning bubbles show only the collapsed summary with no
1229
+ * expand/collapse toggle. Users see reasoning awareness without full details.
1230
+ * @default true
1231
+ */
1232
+ expandable?: boolean;
1233
+ };
1179
1234
  type AgentWidgetFeatureFlags = {
1180
1235
  showReasoning?: boolean;
1181
1236
  showToolCalls?: boolean;
1182
1237
  showEventStreamToggle?: boolean;
1183
1238
  /** Shared transcript + event stream scroll-to-bottom affordance. */
1184
1239
  scrollToBottom?: AgentWidgetScrollToBottomFeature;
1240
+ /** Collapsed transcript behavior for tool call rows. */
1241
+ toolCallDisplay?: AgentWidgetToolCallDisplayFeature;
1242
+ /** Collapsed transcript behavior for reasoning rows. */
1243
+ reasoningDisplay?: AgentWidgetReasoningDisplayFeature;
1185
1244
  /** Configuration for the Event Stream inspector view */
1186
1245
  eventStream?: EventStreamConfig;
1187
1246
  /** Optional artifact sidebar (split pane / mobile drawer) */
@@ -1746,6 +1805,65 @@ type AgentWidgetToolCallConfig = {
1746
1805
  codeBlockTextColor?: string;
1747
1806
  toggleTextColor?: string;
1748
1807
  labelTextColor?: string;
1808
+ /**
1809
+ * Override the collapsed summary row content for a tool call bubble.
1810
+ * Return `null` to fall back to the built-in summary for the active display mode.
1811
+ */
1812
+ renderCollapsedSummary?: (context: {
1813
+ message: AgentWidgetMessage;
1814
+ toolCall: AgentWidgetToolCall;
1815
+ defaultSummary: string;
1816
+ previewText: string;
1817
+ collapsedMode: AgentWidgetToolCallCollapsedMode;
1818
+ isActive: boolean;
1819
+ config: AgentWidgetConfig;
1820
+ }) => HTMLElement | string | null;
1821
+ /**
1822
+ * Override the lightweight collapsed preview content shown for active tool rows.
1823
+ * Return `null` to fall back to the built-in preview text.
1824
+ */
1825
+ renderCollapsedPreview?: (context: {
1826
+ message: AgentWidgetMessage;
1827
+ toolCall: AgentWidgetToolCall;
1828
+ defaultPreview: string;
1829
+ isActive: boolean;
1830
+ config: AgentWidgetConfig;
1831
+ }) => HTMLElement | string | null;
1832
+ /**
1833
+ * Override the summary content for grouped consecutive tool-call containers.
1834
+ * Return `null` to fall back to the built-in `Called [x] tools` summary.
1835
+ */
1836
+ renderGroupedSummary?: (context: {
1837
+ messages: AgentWidgetMessage[];
1838
+ toolCalls: AgentWidgetToolCall[];
1839
+ defaultSummary: string;
1840
+ config: AgentWidgetConfig;
1841
+ }) => HTMLElement | string | null;
1842
+ };
1843
+ type AgentWidgetReasoningConfig = {
1844
+ /**
1845
+ * Override the collapsed summary row content for a reasoning bubble.
1846
+ * Return `null` to fall back to the built-in summary.
1847
+ */
1848
+ renderCollapsedSummary?: (context: {
1849
+ message: AgentWidgetMessage;
1850
+ reasoning: AgentWidgetReasoning;
1851
+ defaultSummary: string;
1852
+ previewText: string;
1853
+ isActive: boolean;
1854
+ config: AgentWidgetConfig;
1855
+ }) => HTMLElement | string | null;
1856
+ /**
1857
+ * Override the lightweight collapsed preview content shown for active reasoning rows.
1858
+ * Return `null` to fall back to the built-in preview text.
1859
+ */
1860
+ renderCollapsedPreview?: (context: {
1861
+ message: AgentWidgetMessage;
1862
+ reasoning: AgentWidgetReasoning;
1863
+ defaultPreview: string;
1864
+ isActive: boolean;
1865
+ config: AgentWidgetConfig;
1866
+ }) => HTMLElement | string | null;
1749
1867
  };
1750
1868
  type AgentWidgetSuggestionChipsConfig = {
1751
1869
  fontFamily?: "sans-serif" | "serif" | "mono";
@@ -2461,6 +2579,35 @@ type AgentWidgetAttachmentsConfig = {
2461
2579
  * Callback when a file is rejected (wrong type or too large).
2462
2580
  */
2463
2581
  onFileRejected?: (file: File, reason: 'type' | 'size' | 'count') => void;
2582
+ /**
2583
+ * Customize the drag-and-drop overlay that appears when files are dragged over the widget.
2584
+ */
2585
+ dropOverlay?: {
2586
+ /** Background color/value of the overlay. @default 'rgba(59, 130, 246, 0.08)' */
2587
+ background?: string;
2588
+ /** Backdrop blur applied behind the overlay (CSS value). @default '8px' */
2589
+ backdropBlur?: string;
2590
+ /** Border style shown during drag. @default '2px dashed rgba(59, 130, 246, 0.4)' */
2591
+ border?: string;
2592
+ /** Border radius of the overlay. @default 'inherit' */
2593
+ borderRadius?: string;
2594
+ /** Inset/margin pulling the overlay away from the container edges (CSS value). @default '0' */
2595
+ inset?: string;
2596
+ /** Lucide icon name displayed in the center. @default 'upload' */
2597
+ iconName?: string;
2598
+ /** Icon size (CSS value). @default '48px' */
2599
+ iconSize?: string;
2600
+ /** Icon stroke color. @default 'rgba(59, 130, 246, 0.6)' */
2601
+ iconColor?: string;
2602
+ /** Icon stroke width. @default 0.5 */
2603
+ iconStrokeWidth?: number;
2604
+ /** Optional label text shown below the icon. */
2605
+ label?: string;
2606
+ /** Label font size. @default '0.875rem' */
2607
+ labelSize?: string;
2608
+ /** Label color. @default 'rgba(59, 130, 246, 0.8)' */
2609
+ labelColor?: string;
2610
+ };
2464
2611
  };
2465
2612
  /**
2466
2613
  * Configuration for persisting widget state across page navigations.
@@ -2852,6 +2999,7 @@ type AgentWidgetConfig = {
2852
2999
  */
2853
3000
  textToSpeech?: TextToSpeechConfig;
2854
3001
  toolCall?: AgentWidgetToolCallConfig;
3002
+ reasoning?: AgentWidgetReasoningConfig;
2855
3003
  /**
2856
3004
  * Configuration for tool approval bubbles.
2857
3005
  * Set to `false` to disable built-in approval handling entirely.
package/dist/index.d.ts CHANGED
@@ -1176,12 +1176,71 @@ type AgentWidgetScrollToBottomFeature = {
1176
1176
  */
1177
1177
  label?: string;
1178
1178
  };
1179
+ type AgentWidgetToolCallCollapsedMode = "tool-call" | "tool-name" | "tool-preview";
1180
+ type AgentWidgetToolCallDisplayFeature = {
1181
+ /**
1182
+ * Controls what collapsed tool call rows show in their header/summary area.
1183
+ * @default "tool-call"
1184
+ */
1185
+ collapsedMode?: AgentWidgetToolCallCollapsedMode;
1186
+ /**
1187
+ * When true, active collapsed tool calls can render a lightweight preview block.
1188
+ * @default false
1189
+ */
1190
+ activePreview?: boolean;
1191
+ /**
1192
+ * Optional CSS min-height applied to active collapsed tool call rows.
1193
+ */
1194
+ activeMinHeight?: string;
1195
+ /**
1196
+ * Maximum preview lines shown for collapsed active tool calls.
1197
+ * @default 3
1198
+ */
1199
+ previewMaxLines?: number;
1200
+ /**
1201
+ * When true, consecutive tool call rows can be visually grouped.
1202
+ * @default false
1203
+ */
1204
+ grouped?: boolean;
1205
+ /**
1206
+ * When false, tool call bubbles show only the collapsed summary with no
1207
+ * expand/collapse toggle. Users see tool awareness without full details.
1208
+ * @default true
1209
+ */
1210
+ expandable?: boolean;
1211
+ };
1212
+ type AgentWidgetReasoningDisplayFeature = {
1213
+ /**
1214
+ * When true, active collapsed reasoning rows can render a lightweight preview block.
1215
+ * @default false
1216
+ */
1217
+ activePreview?: boolean;
1218
+ /**
1219
+ * Optional CSS min-height applied to active collapsed reasoning rows.
1220
+ */
1221
+ activeMinHeight?: string;
1222
+ /**
1223
+ * Maximum preview lines shown for collapsed active reasoning rows.
1224
+ * @default 3
1225
+ */
1226
+ previewMaxLines?: number;
1227
+ /**
1228
+ * When false, reasoning bubbles show only the collapsed summary with no
1229
+ * expand/collapse toggle. Users see reasoning awareness without full details.
1230
+ * @default true
1231
+ */
1232
+ expandable?: boolean;
1233
+ };
1179
1234
  type AgentWidgetFeatureFlags = {
1180
1235
  showReasoning?: boolean;
1181
1236
  showToolCalls?: boolean;
1182
1237
  showEventStreamToggle?: boolean;
1183
1238
  /** Shared transcript + event stream scroll-to-bottom affordance. */
1184
1239
  scrollToBottom?: AgentWidgetScrollToBottomFeature;
1240
+ /** Collapsed transcript behavior for tool call rows. */
1241
+ toolCallDisplay?: AgentWidgetToolCallDisplayFeature;
1242
+ /** Collapsed transcript behavior for reasoning rows. */
1243
+ reasoningDisplay?: AgentWidgetReasoningDisplayFeature;
1185
1244
  /** Configuration for the Event Stream inspector view */
1186
1245
  eventStream?: EventStreamConfig;
1187
1246
  /** Optional artifact sidebar (split pane / mobile drawer) */
@@ -1746,6 +1805,65 @@ type AgentWidgetToolCallConfig = {
1746
1805
  codeBlockTextColor?: string;
1747
1806
  toggleTextColor?: string;
1748
1807
  labelTextColor?: string;
1808
+ /**
1809
+ * Override the collapsed summary row content for a tool call bubble.
1810
+ * Return `null` to fall back to the built-in summary for the active display mode.
1811
+ */
1812
+ renderCollapsedSummary?: (context: {
1813
+ message: AgentWidgetMessage;
1814
+ toolCall: AgentWidgetToolCall;
1815
+ defaultSummary: string;
1816
+ previewText: string;
1817
+ collapsedMode: AgentWidgetToolCallCollapsedMode;
1818
+ isActive: boolean;
1819
+ config: AgentWidgetConfig;
1820
+ }) => HTMLElement | string | null;
1821
+ /**
1822
+ * Override the lightweight collapsed preview content shown for active tool rows.
1823
+ * Return `null` to fall back to the built-in preview text.
1824
+ */
1825
+ renderCollapsedPreview?: (context: {
1826
+ message: AgentWidgetMessage;
1827
+ toolCall: AgentWidgetToolCall;
1828
+ defaultPreview: string;
1829
+ isActive: boolean;
1830
+ config: AgentWidgetConfig;
1831
+ }) => HTMLElement | string | null;
1832
+ /**
1833
+ * Override the summary content for grouped consecutive tool-call containers.
1834
+ * Return `null` to fall back to the built-in `Called [x] tools` summary.
1835
+ */
1836
+ renderGroupedSummary?: (context: {
1837
+ messages: AgentWidgetMessage[];
1838
+ toolCalls: AgentWidgetToolCall[];
1839
+ defaultSummary: string;
1840
+ config: AgentWidgetConfig;
1841
+ }) => HTMLElement | string | null;
1842
+ };
1843
+ type AgentWidgetReasoningConfig = {
1844
+ /**
1845
+ * Override the collapsed summary row content for a reasoning bubble.
1846
+ * Return `null` to fall back to the built-in summary.
1847
+ */
1848
+ renderCollapsedSummary?: (context: {
1849
+ message: AgentWidgetMessage;
1850
+ reasoning: AgentWidgetReasoning;
1851
+ defaultSummary: string;
1852
+ previewText: string;
1853
+ isActive: boolean;
1854
+ config: AgentWidgetConfig;
1855
+ }) => HTMLElement | string | null;
1856
+ /**
1857
+ * Override the lightweight collapsed preview content shown for active reasoning rows.
1858
+ * Return `null` to fall back to the built-in preview text.
1859
+ */
1860
+ renderCollapsedPreview?: (context: {
1861
+ message: AgentWidgetMessage;
1862
+ reasoning: AgentWidgetReasoning;
1863
+ defaultPreview: string;
1864
+ isActive: boolean;
1865
+ config: AgentWidgetConfig;
1866
+ }) => HTMLElement | string | null;
1749
1867
  };
1750
1868
  type AgentWidgetSuggestionChipsConfig = {
1751
1869
  fontFamily?: "sans-serif" | "serif" | "mono";
@@ -2461,6 +2579,35 @@ type AgentWidgetAttachmentsConfig = {
2461
2579
  * Callback when a file is rejected (wrong type or too large).
2462
2580
  */
2463
2581
  onFileRejected?: (file: File, reason: 'type' | 'size' | 'count') => void;
2582
+ /**
2583
+ * Customize the drag-and-drop overlay that appears when files are dragged over the widget.
2584
+ */
2585
+ dropOverlay?: {
2586
+ /** Background color/value of the overlay. @default 'rgba(59, 130, 246, 0.08)' */
2587
+ background?: string;
2588
+ /** Backdrop blur applied behind the overlay (CSS value). @default '8px' */
2589
+ backdropBlur?: string;
2590
+ /** Border style shown during drag. @default '2px dashed rgba(59, 130, 246, 0.4)' */
2591
+ border?: string;
2592
+ /** Border radius of the overlay. @default 'inherit' */
2593
+ borderRadius?: string;
2594
+ /** Inset/margin pulling the overlay away from the container edges (CSS value). @default '0' */
2595
+ inset?: string;
2596
+ /** Lucide icon name displayed in the center. @default 'upload' */
2597
+ iconName?: string;
2598
+ /** Icon size (CSS value). @default '48px' */
2599
+ iconSize?: string;
2600
+ /** Icon stroke color. @default 'rgba(59, 130, 246, 0.6)' */
2601
+ iconColor?: string;
2602
+ /** Icon stroke width. @default 0.5 */
2603
+ iconStrokeWidth?: number;
2604
+ /** Optional label text shown below the icon. */
2605
+ label?: string;
2606
+ /** Label font size. @default '0.875rem' */
2607
+ labelSize?: string;
2608
+ /** Label color. @default 'rgba(59, 130, 246, 0.8)' */
2609
+ labelColor?: string;
2610
+ };
2464
2611
  };
2465
2612
  /**
2466
2613
  * Configuration for persisting widget state across page navigations.
@@ -2852,6 +2999,7 @@ type AgentWidgetConfig = {
2852
2999
  */
2853
3000
  textToSpeech?: TextToSpeechConfig;
2854
3001
  toolCall?: AgentWidgetToolCallConfig;
3002
+ reasoning?: AgentWidgetReasoningConfig;
2855
3003
  /**
2856
3004
  * Configuration for tool approval bubbles.
2857
3005
  * Set to `false` to disable built-in approval handling entirely.