@runtypelabs/persona 3.9.2 → 3.10.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 (38) hide show
  1. package/dist/index.cjs +46 -43
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +119 -0
  4. package/dist/index.d.ts +119 -0
  5. package/dist/index.global.js +67 -64
  6. package/dist/index.global.js.map +1 -1
  7. package/dist/index.js +46 -43
  8. package/dist/index.js.map +1 -1
  9. package/dist/theme-editor.cjs +826 -210
  10. package/dist/theme-editor.d.cts +128 -3
  11. package/dist/theme-editor.d.ts +128 -3
  12. package/dist/theme-editor.js +822 -210
  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 +124 -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 +124 -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 +126 -0
  34. package/src/ui.scroll.test.ts +104 -0
  35. package/src/ui.tool-display.test.ts +204 -0
  36. package/src/ui.ts +103 -3
  37. package/src/utils/message-fingerprint.test.ts +17 -0
  38. 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";
@@ -2852,6 +2970,7 @@ type AgentWidgetConfig = {
2852
2970
  */
2853
2971
  textToSpeech?: TextToSpeechConfig;
2854
2972
  toolCall?: AgentWidgetToolCallConfig;
2973
+ reasoning?: AgentWidgetReasoningConfig;
2855
2974
  /**
2856
2975
  * Configuration for tool approval bubbles.
2857
2976
  * 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";
@@ -2852,6 +2970,7 @@ type AgentWidgetConfig = {
2852
2970
  */
2853
2971
  textToSpeech?: TextToSpeechConfig;
2854
2972
  toolCall?: AgentWidgetToolCallConfig;
2973
+ reasoning?: AgentWidgetReasoningConfig;
2855
2974
  /**
2856
2975
  * Configuration for tool approval bubbles.
2857
2976
  * Set to `false` to disable built-in approval handling entirely.