@runtypelabs/persona 4.23.1 → 4.24.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 (158) hide show
  1. package/dist/animations/glyph-cycle.d.cts +1 -1
  2. package/dist/animations/glyph-cycle.d.ts +1 -1
  3. package/dist/animations/{types-9Vxm-PPz.d.cts → types-Db61aI9J.d.cts} +25 -2
  4. package/dist/animations/{types-9Vxm-PPz.d.ts → types-Db61aI9J.d.ts} +25 -2
  5. package/dist/animations/wipe.d.cts +1 -1
  6. package/dist/animations/wipe.d.ts +1 -1
  7. package/dist/animations-extra.d.cts +25 -2
  8. package/dist/animations-extra.d.ts +25 -2
  9. package/dist/approval-ui-3NMYNXBD.js +1 -0
  10. package/dist/approval-ui.cjs +2 -2
  11. package/dist/approval-ui.d.cts +261 -40
  12. package/dist/approval-ui.d.ts +261 -40
  13. package/dist/approval-ui.js +2 -2
  14. package/dist/{artifacts-ui-F4N6VMKF.js → artifacts-ui-IGB5YKLO.js} +4 -4
  15. package/dist/artifacts-ui.d.cts +256 -28
  16. package/dist/artifacts-ui.d.ts +256 -28
  17. package/dist/{chunk-NIKYKSNZ.js → chunk-7CO4T5KB.js} +1 -1
  18. package/dist/codegen.cjs +11 -11
  19. package/dist/codegen.js +13 -13
  20. package/dist/context-mentions.d.cts +256 -28
  21. package/dist/context-mentions.d.ts +256 -28
  22. package/dist/event-stream-view.d.cts +256 -28
  23. package/dist/event-stream-view.d.ts +256 -28
  24. package/dist/forms-ui.d.cts +291 -30
  25. package/dist/forms-ui.d.ts +291 -30
  26. package/dist/history-view.d.cts +25 -2
  27. package/dist/history-view.d.ts +25 -2
  28. package/dist/index.cjs +70 -69
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +337 -51
  31. package/dist/index.d.ts +337 -51
  32. package/dist/index.global.js +57 -54
  33. package/dist/index.global.js.map +1 -1
  34. package/dist/index.js +70 -69
  35. package/dist/index.js.map +1 -1
  36. package/dist/install.global.js +1 -1
  37. package/dist/install.global.js.map +1 -1
  38. package/dist/launcher.global.js +2 -2
  39. package/dist/launcher.global.js.map +1 -1
  40. package/dist/session-reconnect.d.cts +256 -28
  41. package/dist/session-reconnect.d.ts +256 -28
  42. package/dist/smart-dom-reader.d.cts +256 -28
  43. package/dist/smart-dom-reader.d.ts +256 -28
  44. package/dist/theme-editor-preview.cjs +74 -73
  45. package/dist/theme-editor-preview.d.cts +263 -28
  46. package/dist/theme-editor-preview.d.ts +263 -28
  47. package/dist/theme-editor-preview.js +51 -50
  48. package/dist/theme-editor.cjs +10 -10
  49. package/dist/theme-editor.d.cts +276 -30
  50. package/dist/theme-editor.d.ts +276 -30
  51. package/dist/theme-editor.js +10 -10
  52. package/dist/theme-reference.cjs +1 -1
  53. package/dist/theme-reference.d.cts +1522 -11
  54. package/dist/theme-reference.d.ts +1522 -11
  55. package/dist/theme-reference.js +1 -1
  56. package/dist/widget.css +1 -1
  57. package/package.json +3 -2
  58. package/src/__fixtures__/defaults-parity.v4.json +776 -0
  59. package/src/approval-ui-entry.ts +0 -1
  60. package/src/approval-ui-loader.ts +5 -4
  61. package/src/approval-ui.ts +0 -1
  62. package/src/client-identity-proof.test.ts +193 -0
  63. package/src/client-session-warm.test.ts +216 -0
  64. package/src/client-visitor-history.test.ts +6 -0
  65. package/src/client.tool-pair-replay.test.ts +325 -0
  66. package/src/client.ts +154 -61
  67. package/src/codegen.test.ts +24 -0
  68. package/src/components/activity-row.test.ts +100 -0
  69. package/src/components/activity-row.ts +136 -0
  70. package/src/components/approval-actions.test.ts +8 -5
  71. package/src/components/approval-actions.ts +19 -6
  72. package/src/components/approval-bubble.test.ts +56 -9
  73. package/src/components/approval-bubble.ts +36 -41
  74. package/src/components/composer-builder.ts +5 -2
  75. package/src/components/composer-parts.ts +10 -2
  76. package/src/components/header-builder.test.ts +32 -0
  77. package/src/components/header-builder.ts +7 -4
  78. package/src/components/header-layouts.test.ts +12 -0
  79. package/src/components/header-layouts.ts +3 -2
  80. package/src/components/launcher.ts +11 -2
  81. package/src/components/message-bubble.test.ts +22 -0
  82. package/src/components/message-bubble.ts +7 -3
  83. package/src/components/panel.test.ts +52 -1
  84. package/src/components/panel.ts +47 -8
  85. package/src/components/pill-composer-builder.test.ts +2 -0
  86. package/src/components/pill-composer-builder.ts +0 -1
  87. package/src/components/reasoning-bubble.ts +29 -17
  88. package/src/components/suggestions.test.ts +1 -0
  89. package/src/components/suggestions.ts +0 -16
  90. package/src/components/tool-bubble.ts +131 -114
  91. package/src/components/tool-details.test.ts +87 -0
  92. package/src/components/tool-details.ts +102 -0
  93. package/src/components/welcome.test.ts +8 -0
  94. package/src/components/welcome.ts +4 -2
  95. package/src/defaults-parity.test.ts +158 -0
  96. package/src/defaults.test.ts +69 -0
  97. package/src/defaults.ts +128 -49
  98. package/src/generated/runtype-openapi-contract.ts +28 -13
  99. package/src/index-core.ts +2 -0
  100. package/src/install.test.ts +24 -0
  101. package/src/install.ts +3 -1
  102. package/src/launcher-global.ts +2 -1
  103. package/src/launcher-variants.test.ts +52 -0
  104. package/src/runtime/init-update-reset.test.ts +21 -0
  105. package/src/session.ts +61 -9
  106. package/src/styles/widget-styles.test.ts +19 -0
  107. package/src/styles/widget.css +295 -23
  108. package/src/theme-editor/index.ts +2 -0
  109. package/src/theme-editor/preview-utils.test.ts +8 -0
  110. package/src/theme-editor/preview-utils.ts +7 -3
  111. package/src/theme-editor/sections.test.ts +31 -0
  112. package/src/theme-editor/sections.ts +55 -1
  113. package/src/theme-editor/state-preferences.test.ts +49 -0
  114. package/src/theme-editor/state.ts +73 -15
  115. package/src/theme-reference.test.ts +20 -0
  116. package/src/theme-reference.ts +11 -5
  117. package/src/tool-call-display-defaults.test.ts +33 -1
  118. package/src/types/theme.ts +80 -3
  119. package/src/types.ts +179 -23
  120. package/src/ui.activity-row.test.ts +91 -0
  121. package/src/ui.approval-plugin.test.ts +63 -0
  122. package/src/ui.composer-compact.test.ts +24 -2
  123. package/src/ui.composer-placement.test.ts +23 -0
  124. package/src/ui.detached-panel.test.ts +33 -6
  125. package/src/ui.docked.test.ts +19 -0
  126. package/src/ui.header-update-stability.test.ts +25 -0
  127. package/src/ui.identity-proof.test.ts +58 -0
  128. package/src/ui.launcher-teaser.test.ts +25 -0
  129. package/src/ui.message-width.test.ts +17 -2
  130. package/src/ui.reasoning-display.test.ts +92 -0
  131. package/src/ui.rebuild-composer.test.ts +20 -3
  132. package/src/ui.scroll.test.ts +32 -0
  133. package/src/ui.session-init.test.ts +312 -0
  134. package/src/ui.status-indicator.test.ts +82 -0
  135. package/src/ui.suggest-replies.test.ts +11 -0
  136. package/src/ui.ts +363 -74
  137. package/src/ui.v5-defaults.test.ts +144 -0
  138. package/src/ui.welcome.test.ts +92 -3
  139. package/src/utils/__snapshots__/tokens-parity.test.ts.snap +811 -140
  140. package/src/utils/code-generators.ts +14 -0
  141. package/src/utils/composer-compact.test.ts +0 -2
  142. package/src/utils/composer-compact.ts +2 -4
  143. package/src/utils/composer-placement.ts +2 -3
  144. package/src/utils/config-merge.test.ts +81 -5
  145. package/src/utils/config-merge.ts +13 -3
  146. package/src/utils/defaults-provenance.ts +67 -0
  147. package/src/utils/dock.ts +7 -1
  148. package/src/utils/launcher-variant.ts +16 -0
  149. package/src/utils/panel-config.ts +97 -0
  150. package/src/utils/status-indicator.ts +39 -0
  151. package/src/utils/theme.test.ts +182 -0
  152. package/src/utils/theme.ts +131 -18
  153. package/src/utils/tokens.test.ts +122 -1
  154. package/src/utils/tokens.ts +177 -17
  155. package/src/utils/tool-pair-replay.ts +100 -0
  156. package/src/welcome.test.ts +23 -0
  157. package/src/welcome.ts +16 -9
  158. package/dist/approval-ui-K7R5Q5OC.js +0 -1
@@ -290,6 +290,7 @@ interface ResolvedWelcomeConfig {
290
290
  * Optional on the interface, always populated by `resolveWelcomeConfig`:
291
291
  * a plugin literal built against an older minor must still type-check.
292
292
  */
293
+ layout?: "top" | "centered";
293
294
  anchor?: AgentWidgetWelcomeAnchor;
294
295
  /** Percentage string; validated, falls back to "44%". */
295
296
  anchorComposerTop?: string;
@@ -1061,6 +1062,8 @@ interface InputTokens extends ComponentTokenSet {
1061
1062
  backdropFilter?: string;
1062
1063
  }
1063
1064
  interface LauncherTokens extends ComponentTokenSet {
1065
+ /** Distance from the viewport edges. Circle default: 20px; pill: 24px. */
1066
+ offset?: string;
1064
1067
  size: string;
1065
1068
  iconSize: string;
1066
1069
  shadow: TokenReference<'shadow'>;
@@ -1083,6 +1086,15 @@ interface PanelTokens extends ComponentTokenSet {
1083
1086
  inset?: string;
1084
1087
  /** Background of the region revealed behind a detached panel. */
1085
1088
  canvasBackground?: string;
1089
+ /** Chrome defaults by rendered panel mode. */
1090
+ modes?: Partial<Record<'floating' | 'inline' | 'sidebar' | 'docked' | 'mobile', {
1091
+ /** Full border shorthand (for example, `"1px solid var(--persona-border)"`). */
1092
+ border?: string;
1093
+ /** Box-shadow token reference or raw CSS shadow. */
1094
+ shadow?: string;
1095
+ /** Corner radius token reference or raw CSS radius. */
1096
+ borderRadius?: TokenReference<'radius'>;
1097
+ }>>;
1086
1098
  }
1087
1099
  /** Per-element text styling shared by themable text surfaces. */
1088
1100
  interface TextStyleTokens {
@@ -1109,10 +1121,16 @@ interface HeaderTokens extends ComponentTokenSet {
1109
1121
  */
1110
1122
  border?: TokenReference<'color'>;
1111
1123
  borderRadius: TokenReference<'radius'>;
1124
+ /** Standard-header padding. @default "20px 24px" */
1125
+ padding?: string;
1126
+ /** Minimal-header padding. Explicitly wins over `padding`. @default "16px 24px" */
1127
+ minimalPadding?: string;
1112
1128
  /** Background of the rounded avatar tile next to the title (Lucide / emoji / image). */
1113
1129
  iconBackground: TokenReference<'color'>;
1114
1130
  /** Foreground (glyph stroke or emoji text) on the header avatar tile. */
1115
1131
  iconForeground: TokenReference<'color'>;
1132
+ /** Header identity glyph size as a fraction of its icon box. @default "0.6" */
1133
+ iconScale?: string;
1116
1134
  /**
1117
1135
  * Legacy alias of `title.color`; `title.color` wins when both are set.
1118
1136
  * Unset, the title takes `foreground`, then the primary color.
@@ -1151,6 +1169,14 @@ interface HeaderTokens extends ComponentTokenSet {
1151
1169
  * sibling. @default "1.5"
1152
1170
  */
1153
1171
  controlStrokeWidth?: string;
1172
+ /** Header control corner radius. Per-control radius overrides win. */
1173
+ controlBorderRadius?: string;
1174
+ /** Default control hover/focus fill. Explicit button backgrounds win. */
1175
+ controlHoverBackground?: TokenReference<'color'>;
1176
+ /** Default control hover/focus icon color. Explicit button colors win. */
1177
+ controlHoverForeground?: TokenReference<'color'>;
1178
+ /** Keyboard focus outline; unset preserves the browser default. */
1179
+ controlFocusOutline?: string;
1154
1180
  /** Box-shadow on the header (e.g., a fade shadow to replace the default border). */
1155
1181
  shadow?: string;
1156
1182
  /** Override the header bottom border (e.g., `none`). */
@@ -1325,6 +1351,12 @@ interface MessageGeometryTokens {
1325
1351
  lineHeight?: string;
1326
1352
  }
1327
1353
  interface MessageTokens {
1354
+ /** Height of the optional transcript top fade. Default 18px. */
1355
+ topFadeHeight?: string;
1356
+ /** Vertical gap between transcript turns. @default "12px" */
1357
+ gap?: string;
1358
+ /** Gap between turns in fullscreen mode; falls back to `gap`. */
1359
+ fullscreenGap?: string;
1328
1360
  user: MessageGeometryTokens & {
1329
1361
  background: TokenReference<'color'>;
1330
1362
  text: TokenReference<'color'>;
@@ -1338,6 +1370,8 @@ interface MessageTokens {
1338
1370
  borderRadius: TokenReference<'radius'>;
1339
1371
  /** Assistant bubble border color (CSS color). */
1340
1372
  border?: TokenReference<'color'>;
1373
+ /** Border width; set to 0px for a flat assistant response. @default "1px" */
1374
+ borderWidth?: string;
1341
1375
  /** Assistant bubble box-shadow (token ref or raw CSS, e.g. `none`). */
1342
1376
  shadow?: string;
1343
1377
  };
@@ -1456,12 +1490,40 @@ interface AttachmentTokens {
1456
1490
  };
1457
1491
  }
1458
1492
  /** Tool-call row chrome (collapsible tool bubbles). */
1459
- interface ToolBubbleTokens {
1493
+ interface ActivityTokens {
1494
+ /** Minimum activity row height. */
1495
+ rowHeight?: string;
1496
+ /** Group child indentation; falls back to indent when unset. V5: 0px. */
1497
+ groupIndent?: string;
1498
+ /** Extra vertical gap between grouped rows. V5: 0px. */
1499
+ groupGap?: string;
1500
+ /** Padding around expanded group children. V5: 0px. */
1501
+ groupPadding?: string;
1502
+ /** Gap between consecutive activity entries. V5: 0px. */
1503
+ transcriptGap?: string;
1504
+ /** Gap from activity to an assistant response. V5: 12px. */
1505
+ responseGap?: string;
1506
+ /** Expanded body padding. V5: 4px 0. */
1507
+ bodyPadding?: string;
1508
+ /** Expanded reasoning text size. V5: 13px. */
1509
+ bodySize?: string;
1510
+ /** Expanded reasoning line height. V5: 1.5. */
1511
+ bodyLineHeight?: string;
1512
+ /** Expanded reasoning font weight. V5: 400. */
1513
+ bodyFontWeight?: string;
1514
+ /** Gap between expanded detail sections. V5: 8px. */
1515
+ sectionGap?: string;
1516
+ labelSize?: string;
1517
+ iconSize?: string;
1518
+ indent?: string;
1519
+ bodySurface?: TokenReference<'color'>;
1520
+ }
1521
+ interface ToolBubbleTokens extends ActivityTokens {
1460
1522
  /** Box-shadow for tool bubbles (token ref or raw CSS, e.g. `none`). */
1461
1523
  shadow: string;
1462
1524
  }
1463
1525
  /** Reasoning / “thinking” row chrome. */
1464
- interface ReasoningBubbleTokens {
1526
+ interface ReasoningBubbleTokens extends ActivityTokens {
1465
1527
  shadow: string;
1466
1528
  }
1467
1529
  /** One event-stream badge chip: fill + text pair. The chip border derives
@@ -1595,6 +1657,10 @@ interface ComposerChromeTokens {
1595
1657
  shadow: string;
1596
1658
  /** Border color of the composer form. @default semantic.colors.border */
1597
1659
  borderColor?: TokenReference<'color'>;
1660
+ /** Focused form border color; falls back to borderColor. V5: a stronger neutral border. */
1661
+ focusBorderColor?: TokenReference<'color'>;
1662
+ /** Outer focus ring (CSS outline shorthand). V4: none; V5: a thin neutral ring. */
1663
+ focusRing?: string;
1598
1664
  /** Inner padding of the composer form (raw CSS shorthand). @default "0.75rem 1rem" */
1599
1665
  padding?: string;
1600
1666
  /** Gap between the textarea row and the actions row. @default "0.5rem" */
@@ -1613,12 +1679,18 @@ interface ComposerChromeTokens {
1613
1679
  controlSize?: string;
1614
1680
  /** Glyph box inside those controls. @default "24px" */
1615
1681
  controlIconSize?: string;
1682
+ /** Send/stop glyph size. Explicit sendButton.iconSize wins. V5: 18px. */
1683
+ sendIconSize?: string;
1684
+ /** Icon-mode submit button radius. V4 inherits the primary button; V5: 9999px. */
1685
+ sendButtonRadius?: string;
1686
+ /** Footer top border (CSS shorthand). V4: 1px solid divider; V5: none. */
1687
+ footerBorder?: string;
1616
1688
  /**
1617
1689
  * Background painted behind an overlaid composer footer
1618
1690
  * (`composer.placement: "overlay"`). Any CSS `background` value, gradients
1619
1691
  * included — same convention as the shadow tokens. Inert under
1620
1692
  * `placement: "block"`.
1621
- * @default "transparent"
1693
+ * @default "transparent" (V4); a theme-aware 24px fade (V5)
1622
1694
  */
1623
1695
  overlayBand?: string;
1624
1696
  /** Segmented mode-group track. */
@@ -1794,6 +1866,8 @@ interface ScrollToBottomTokens extends ComponentTokenSet {
1794
1866
  }
1795
1867
  /** Visual tokens shared by one suggestion presentation variant. */
1796
1868
  interface SuggestionVariantTokens extends ComponentTokenSet {
1869
+ /** Label weight. V4: 500; V5: 400. */
1870
+ fontWeight?: string;
1797
1871
  /** Space inside one item, between its icon and its copy. */
1798
1872
  gap?: string;
1799
1873
  /** Space between suggestion items in the container. */
@@ -1842,6 +1916,7 @@ interface ComponentTokens {
1842
1916
  voice: VoiceTokens;
1843
1917
  approval: ApprovalTokens;
1844
1918
  attachment: AttachmentTokens;
1919
+ activity?: ActivityTokens;
1845
1920
  toolBubble: ToolBubbleTokens;
1846
1921
  reasoningBubble: ReasoningBubbleTokens;
1847
1922
  /** Event-stream inspector badge chips. */
@@ -1971,6 +2046,7 @@ type RuntypeExecutionStreamEvent = ({
1971
2046
  turnIndex?: number;
1972
2047
  type: "turn_start";
1973
2048
  }) | ({
2049
+ attributes?: Record<string, string | number | boolean>;
1974
2050
  completedAt?: string;
1975
2051
  content?: string;
1976
2052
  cost?: number;
@@ -2029,7 +2105,8 @@ type RuntypeExecutionStreamEvent = ({
2029
2105
  };
2030
2106
  turnId?: string;
2031
2107
  type: "model_call_start";
2032
- } | {
2108
+ } | ({
2109
+ attributes?: Record<string, string | number | boolean>;
2033
2110
  completedAt?: string;
2034
2111
  cost?: number;
2035
2112
  durationMs?: number;
@@ -2053,10 +2130,11 @@ type RuntypeExecutionStreamEvent = ({
2053
2130
  cacheWrite?: number;
2054
2131
  input: number;
2055
2132
  output: number;
2133
+ reasoning?: number;
2056
2134
  };
2057
2135
  turnId?: string;
2058
2136
  type: "model_call_complete";
2059
- } | {
2137
+ }) | {
2060
2138
  executionId: string;
2061
2139
  id: string;
2062
2140
  index?: number;
@@ -3156,10 +3234,32 @@ type AgentWidgetContextMentionTokenRenderContext = {
3156
3234
  ref: AgentWidgetContextMentionRef;
3157
3235
  readonly: boolean;
3158
3236
  };
3237
+ /** One earlier client-tool call replayed to the model, in `/v1/dispatch` shape. */
3238
+ type AgentWidgetReplayedToolCall = {
3239
+ toolCallId: string;
3240
+ /** Model-facing (sanitized) name, e.g. `webmcp_search`. */
3241
+ toolName: string;
3242
+ args: Record<string, unknown>;
3243
+ };
3244
+ /** The browser's answer to an {@link AgentWidgetReplayedToolCall}. */
3245
+ type AgentWidgetReplayedToolResult = {
3246
+ toolCallId: string;
3247
+ toolName: string;
3248
+ result: unknown;
3249
+ };
3250
+ /**
3251
+ * A message in the proxy/agent request payload. Earlier client-tool calls the
3252
+ * browser answered replay as an assistant message carrying `toolCalls`,
3253
+ * followed by a `tool` message carrying the matching `toolResults`; both have
3254
+ * empty `content`. Client-token mode never sends them: the server replays
3255
+ * from its own stored transcript there.
3256
+ */
3159
3257
  type AgentWidgetRequestPayloadMessage = {
3160
- role: AgentWidgetMessageRole;
3258
+ role: AgentWidgetMessageRole | "tool";
3161
3259
  content: MessageContent;
3162
3260
  createdAt: string;
3261
+ toolCalls?: AgentWidgetReplayedToolCall[];
3262
+ toolResults?: AgentWidgetReplayedToolResult[];
3163
3263
  };
3164
3264
  type AgentWidgetRequestPayload = {
3165
3265
  messages: AgentWidgetRequestPayloadMessage[];
@@ -3522,6 +3622,24 @@ type AgentMessageMetadata = {
3522
3622
  * never re-resume the call.
3523
3623
  */
3524
3624
  suggestRepliesResolved?: boolean;
3625
+ /**
3626
+ * The client-tool answer the server accepted through `/resume`, kept so
3627
+ * later proxy/agent turns can replay the call and its result to the model.
3628
+ * `toolName` is the widget's internal name (`webmcp:<name>` or a bare
3629
+ * built-in). Set only after the resume succeeds; preserved across
3630
+ * re-emissions of the tool message.
3631
+ */
3632
+ clientToolAnswer?: {
3633
+ toolCallId: string;
3634
+ toolName: string;
3635
+ args: unknown;
3636
+ result: unknown;
3637
+ /**
3638
+ * Shared by the answers posted in one `/resume`, i.e. one assistant
3639
+ * turn's parallel calls; a chained call gets a new batch.
3640
+ */
3641
+ batch?: string;
3642
+ };
3525
3643
  };
3526
3644
  type AgentWidgetRequestMiddlewareContext = {
3527
3645
  payload: AgentWidgetRequestPayload;
@@ -4519,6 +4637,14 @@ type AgentWidgetToolCallCollapsedMode = "tool-call" | "tool-name" | "tool-previe
4519
4637
  */
4520
4638
  type AgentWidgetToolCallLoadingAnimation = "none" | "pulse" | "shimmer" | "shimmer-color" | "rainbow";
4521
4639
  type AgentWidgetToolCallDisplayFeature = {
4640
+ /** Activity chrome. Defaults to card in V4 and row with future.v5Defaults. */
4641
+ variant?: "card" | "row";
4642
+ /** Row status icons: always, active/attention-needed only, or never. V5 defaults to active; V4 to always. */
4643
+ iconVisibility?: "always" | "active" | "never";
4644
+ /** Row variant: open when the first content chunk arrives. Default false in V5; true in V4. */
4645
+ autoExpand?: boolean;
4646
+ /** Row variant: collapse once after completion, in ms; false disables. Default 1000. */
4647
+ autoCollapseDelay?: number | false;
4522
4648
  /**
4523
4649
  * Controls what collapsed tool call rows show in their header/summary area.
4524
4650
  * @default "tool-call"
@@ -4549,9 +4675,10 @@ type AgentWidgetToolCallDisplayFeature = {
4549
4675
  * Controls how a grouped tool sequence is rendered.
4550
4676
  * - `"stack"`: show the group summary and each child tool row.
4551
4677
  * - `"summary"`: show one consolidated summary row only.
4678
+ * - `"collapsible"`: expandable activity group (V5 default).
4552
4679
  * @default "stack"
4553
4680
  */
4554
- groupedMode?: "stack" | "summary";
4681
+ groupedMode?: "stack" | "summary" | "collapsible";
4555
4682
  /**
4556
4683
  * What happens to a tool call row once it completes.
4557
4684
  *
@@ -4582,6 +4709,14 @@ type AgentWidgetToolCallDisplayFeature = {
4582
4709
  /** See `features.toolCallDisplay.completedVisibility`. */
4583
4710
  type AgentWidgetToolCallCompletedVisibility = "kept" | "removed";
4584
4711
  type AgentWidgetReasoningDisplayFeature = {
4712
+ /** Activity chrome. Defaults to card in V4 and row with future.v5Defaults. */
4713
+ variant?: "card" | "row";
4714
+ /** Row status icons: always, active/attention-needed only, or never. V5 defaults to active; V4 to always. */
4715
+ iconVisibility?: "always" | "active" | "never";
4716
+ /** Row variant: open when the first content chunk arrives. Default false in V5; true in V4. */
4717
+ autoExpand?: boolean;
4718
+ /** Row variant: collapse once after completion, in ms; false disables. Default 1000. */
4719
+ autoCollapseDelay?: number | false;
4585
4720
  /**
4586
4721
  * When true, active collapsed reasoning rows can render a lightweight preview block.
4587
4722
  * @default false
@@ -5277,8 +5412,8 @@ interface AgentWidgetHistoryFeature {
5277
5412
  * otherwise `"browser"`) and narrows it to what the provider advertises, so a
5278
5413
  * browser-only provider is never asked for a scope it cannot serve. An
5279
5414
  * explicit `features.history.scope` is a hard request and still fails closed
5280
- * with `unsupported_scope`. `getIdentityProof` is never called for a supplied
5281
- * provider, and `HistoryOperationContext` carries only the resolved scope;
5415
+ * with `unsupported_scope`. History operations on a supplied provider never
5416
+ * call `getIdentityProof`, and `HistoryOperationContext` carries only the resolved scope;
5282
5417
  * report your own identity through `getIdentityStatus()` /
5283
5418
  * `subscribeIdentityStatus()`, which is what the scope banner and its retry
5284
5419
  * affordance read.
@@ -5662,7 +5797,7 @@ type EventStreamConfig = {
5662
5797
  /**
5663
5798
  * Fields to extract from event payloads for description text.
5664
5799
  * The first matching field value is displayed after the badge.
5665
- * @default ["flowName", "stepName", "name", "tool", "toolName"]
5800
+ * @default ["flowName", "stepName", "reasoningText", "text", "name", "tool", "toolName"]
5666
5801
  */
5667
5802
  descriptionFields?: string[];
5668
5803
  /**
@@ -5873,6 +6008,8 @@ type AgentWidgetComposerBarPeekConfig = {
5873
6008
  streamAnimation?: AgentWidgetStreamAnimationFeature;
5874
6009
  };
5875
6010
  type AgentWidgetLauncherConfig = {
6011
+ /** Collapsed launcher shape. V4 defaults to pill; V5 defaults to circle. */
6012
+ variant?: "pill" | "circle";
5876
6013
  enabled?: boolean;
5877
6014
  title?: string;
5878
6015
  subtitle?: string;
@@ -6616,9 +6753,9 @@ type AgentWidgetComposerConfig = {
6616
6753
  /**
6617
6754
  * Where the composer footer sits relative to the transcript.
6618
6755
  *
6619
- * - `"block"` (default): the footer is a flex sibling below the scroll body.
6756
+ * - `"block"` (V4 default): the footer is a flex sibling below the scroll body.
6620
6757
  * Nothing scrolls behind it.
6621
- * - `"overlay"`: the footer is absolutely overlaid on the scroll body, so the
6758
+ * - `"overlay"` (V5 default): the footer is absolutely overlaid on the scroll body, so the
6622
6759
  * transcript scrolls behind it (the chatgpt.com / claude.ai model, where the
6623
6760
  * composer is sticky inside the scroller). The widget reserves the footer's
6624
6761
  * live height as bottom padding on the scroll body and on a plugin welcome
@@ -6630,7 +6767,7 @@ type AgentWidgetComposerConfig = {
6630
6767
  * included) and `theme.components.input.backdropFilter`.
6631
6768
  *
6632
6769
  * Ignored in composer-bar mount mode, which owns its own geometry.
6633
- * @default "block"
6770
+ * @default "block" (V4), "overlay" (V5)
6634
6771
  */
6635
6772
  placement?: ComposerPlacement;
6636
6773
  /**
@@ -6644,8 +6781,9 @@ type AgentWidgetComposerConfig = {
6644
6781
  *
6645
6782
  * `"single-row"` describes the IDLE composer only. It composes with the
6646
6783
  * compact state, so a wrapped draft, chips, attachment previews, a quote, a
6647
- * pending card, or live dictation all fall back to the stacked card, exactly
6648
- * as `data-persona-composer-compact` does today.
6784
+ * pending card all fall back to the stacked card, exactly
6785
+ * as `data-persona-composer-compact` does today. Recording alone does not
6786
+ * expand the composer; dictated text expands it when it wraps.
6649
6787
  *
6650
6788
  * Ignored in composer-bar mount mode, whose pill is already one row.
6651
6789
  * @default "stacked"
@@ -6687,7 +6825,14 @@ type AgentWidgetClearChatConfig = {
6687
6825
  showTooltip?: boolean;
6688
6826
  };
6689
6827
  type AgentWidgetStatusIndicatorConfig = {
6828
+ /** Show the indicator. Explicit false also hides transient connection states. */
6690
6829
  visible?: boolean;
6830
+ /**
6831
+ * "always" shows status beneath the composer; "transient" shows connecting,
6832
+ * reconnecting, and error status above it, hiding normal idle/streaming status.
6833
+ * Available in both defaults states. Default: "always" in v4, "transient" in v5.
6834
+ */
6835
+ mode?: "always" | "transient";
6691
6836
  /** Text alignment. Default: 'right'. */
6692
6837
  align?: 'left' | 'center' | 'right';
6693
6838
  idleText?: string;
@@ -7462,7 +7607,8 @@ type AgentWidgetResolvedSuggestion = {
7462
7607
  };
7463
7608
  /** Presentation keys shared by every suggestion surface. */
7464
7609
  type AgentWidgetSuggestionSurfaceConfig = {
7465
- /** Item density. Defaults to `card` for starters and `chip` for follow-ups. */
7610
+ /** Item density. V4 starters: card. V5 starters: chip, or card in fullscreen.
7611
+ * Follow-ups default to chip. */
7466
7612
  variant?: AgentWidgetSuggestionVariant;
7467
7613
  /** Default click behavior, overridable per item. Defaults to `send`. */
7468
7614
  behavior?: AgentWidgetSuggestionBehavior;
@@ -7473,7 +7619,7 @@ type AgentWidgetSuggestionSurfaceConfig = {
7473
7619
  * own stacking.
7474
7620
  */
7475
7621
  overflow?: "scroll" | "wrap";
7476
- /** Maximum visible items. Defaults to 4. */
7622
+ /** Maximum visible items. Defaults to 4, or 3 for V5 non-fullscreen starters. */
7477
7623
  maxItems?: number;
7478
7624
  };
7479
7625
  type AgentWidgetStarterSuggestionsConfig = AgentWidgetSuggestionSurfaceConfig & {
@@ -7527,8 +7673,8 @@ type AgentWidgetSuggestionsConfig = {
7527
7673
  type AgentWidgetWelcomeVariant = "card" | "hero" | "none";
7528
7674
  /**
7529
7675
  * When the welcome surface goes away. `"never"` is the default for `"card"`;
7530
- * `"on-first-message"` is the default for `"hero"` and cannot be overridden
7531
- * there.
7676
+ * `"on-first-message"` is forced for legacy V4 `"hero"`. V5 defaults every
7677
+ * variant to `"on-first-message"`. Explicit layout opts into overridable dismissal.
7532
7678
  */
7533
7679
  type AgentWidgetWelcomeDismiss = "never" | "on-first-message";
7534
7680
  /**
@@ -7582,7 +7728,10 @@ type AgentWidgetWelcomeAlign = "start" | "center";
7582
7728
  * host-set value from a filled-in default.
7583
7729
  */
7584
7730
  interface AgentWidgetWelcomeConfig {
7585
- /** Card or hero title. Defaults to "Hello 👋". */
7731
+ /** Vertical placement: V4 defaults to top; V5 to centered. Fullscreen centered
7732
+ * welcomes also raise the empty composer unless `anchor` is explicitly set. */
7733
+ layout?: "top" | "centered";
7734
+ /** Card or hero title. V4: "Hello 👋". V5: "What can I help with?". */
7586
7735
  title?: string;
7587
7736
  /**
7588
7737
  * Small muted line above the title, e.g. a section name. Omitted when unset
@@ -7595,19 +7744,22 @@ interface AgentWidgetWelcomeConfig {
7595
7744
  icon?: AgentWidgetWelcomeIcon;
7596
7745
  /**
7597
7746
  * Horizontal alignment of the kicker, title, subtitle, and starter
7598
- * suggestions. Unset follows the variant: `card` starts, `hero` centers.
7747
+ * suggestions. Centered layouts default to center. Otherwise unset follows
7748
+ * the variant: `card` starts, `hero` centers.
7599
7749
  */
7600
7750
  align?: AgentWidgetWelcomeAlign;
7601
7751
  /** @default "card" */
7602
7752
  variant?: AgentWidgetWelcomeVariant;
7603
- /** @default "never" for `card`, always `"on-first-message"` for `hero`. */
7753
+ /** V4: never for card, forced on-first-message for hero. V5: on-first-message
7754
+ * for all variants; explicit values win. Explicit layout also allows overriding
7755
+ * the legacy hero dismissal in V4. */
7604
7756
  dismiss?: AgentWidgetWelcomeDismiss;
7605
7757
  /**
7606
7758
  * Vertical anchoring of the greeting-plus-composer pair in the EMPTY
7607
7759
  * conversation only. On the first message the pair drops to the bottom
7608
7760
  * (animated; see `data-persona-conversation-state`).
7609
7761
  *
7610
- * - `"bottom"` (default): the composer stays pinned at the bottom.
7762
+ * - `"bottom"`: the composer stays pinned at the bottom.
7611
7763
  * - `"center"`: greeting and composer float together so the composer's top
7612
7764
  * edge lands at `anchorComposerTop` of the panel column, and the welcome
7613
7765
  * surface is end-anchored `composerGap` above it.
@@ -7615,7 +7767,8 @@ interface AgentWidgetWelcomeConfig {
7615
7767
  * Composes with either `composer.placement`. Ignored in composer-bar mount
7616
7768
  * mode. `renderWelcome` plugin content inherits the anchor: the widget
7617
7769
  * positions the overlay host and reserves the composer zone.
7618
- * @default "bottom"
7770
+ * Defaults to bottom, except centered fullscreen layouts, which center the
7771
+ * measured greeting/composer group when no anchor override is supplied.
7619
7772
  */
7620
7773
  anchor?: AgentWidgetWelcomeAnchor;
7621
7774
  /**
@@ -8107,6 +8260,9 @@ type AgentWidgetLayoutConfig = {
8107
8260
  * `launcher.composerBar.contentMaxWidth`)
8108
8261
  */
8109
8262
  contentMaxWidth?: string;
8263
+ /** Fade the transcript's top edge when content is scrolled above it.
8264
+ * Defaults to false in V4 and true with future.v5Defaults. */
8265
+ topFade?: boolean;
8110
8266
  };
8111
8267
  /**
8112
8268
  * Token types for marked renderer methods
@@ -8720,7 +8876,30 @@ type AgentWidgetLoadingIndicatorConfig = {
8720
8876
  */
8721
8877
  renderIdle?: (context: IdleIndicatorRenderContext) => HTMLElement | null;
8722
8878
  };
8879
+ /** Built-in `sessionInit` triggers. See {@link AgentWidgetConfig.sessionInit}. */
8880
+ type AgentWidgetSessionInitTrigger = 'input' | 'focus' | 'mount' | 'send';
8881
+ /**
8882
+ * Custom `sessionInit` trigger. Runs when the widget mounts in client token mode,
8883
+ * and again if `update()` swaps in a different function. Call `warm()` whenever
8884
+ * the visitor shows intent (it is safe to call repeatedly). Return a cleanup to
8885
+ * run when the widget is destroyed or the hook is replaced.
8886
+ */
8887
+ type AgentWidgetSessionInitHook = (context: {
8888
+ /** Fire-and-forget early session init; latched and error-swallowing. */
8889
+ warm: () => void;
8890
+ /** The widget's mount element. */
8891
+ mount: HTMLElement;
8892
+ }) => void | (() => void);
8723
8893
  type AgentWidgetConfig = {
8894
+ /** Opt in to upcoming major-version defaults without changing explicit settings. */
8895
+ future?: {
8896
+ /**
8897
+ * Use the v5 default styling as it rolls out in 4.x. Every affected setting
8898
+ * remains independently configurable. Explicit options and theme tokens win.
8899
+ * @default false
8900
+ */
8901
+ v5Defaults?: boolean;
8902
+ };
8724
8903
  apiUrl?: string;
8725
8904
  flowId?: string;
8726
8905
  /**
@@ -8875,6 +9054,46 @@ type AgentWidgetConfig = {
8875
9054
  * ```
8876
9055
  */
8877
9056
  onSessionExpired?: () => void;
9057
+ /**
9058
+ * When the widget calls `/v1/client/init` in client token mode, ahead of the
9059
+ * first send. Ignored outside client token mode.
9060
+ *
9061
+ * - `'input'` (default): on the composer's first user keystroke that leaves
9062
+ * non-empty text. Programmatic value changes (restored drafts,
9063
+ * `setMessage()`, history recall) do not count.
9064
+ * - `'focus'`: when the visitor focuses the composer by pointer or Tab (and
9065
+ * on first input, as a fallback). Programmatic focus, such as
9066
+ * `autoFocusInput` on open or mount, does not count.
9067
+ * - `'mount'`: as soon as the widget mounts (the behavior before this option
9068
+ * existed). Use it when a server-configured welcome message, which arrives
9069
+ * with the init response, must show before the visitor types.
9070
+ * - `'send'`: no early init; the first send initializes the session.
9071
+ * - A function: custom trigger. Called on mount (and when `update()` swaps
9072
+ * in a different function) with a `warm` callback to call whenever you
9073
+ * decide (e.g. on hover); may return a cleanup that runs on destroy or
9074
+ * replacement. Replaces the built-in triggers.
9075
+ *
9076
+ * The early init is fire-and-forget: it runs at most once per session
9077
+ * lifetime (re-armed after expiry or a new conversation), sends exactly the
9078
+ * same request the send would, and swallows errors. A failure resurfaces
9079
+ * when the send retries init. A send during an in-flight early init reuses
9080
+ * it, so only one `/v1/client/init` is issued. When visitor history is
9081
+ * enabled the widget still initializes on mount to restore the conversation.
9082
+ * Hosts can also trigger it imperatively with `controller.warmSession()`.
9083
+ *
9084
+ * @default 'input'
9085
+ *
9086
+ * @example
9087
+ * ```typescript
9088
+ * config: {
9089
+ * clientToken: 'ct_live_...',
9090
+ * sessionInit: ({ warm, mount }) => {
9091
+ * mount.addEventListener('pointerenter', warm, { once: true });
9092
+ * }
9093
+ * }
9094
+ * ```
9095
+ */
9096
+ sessionInit?: AgentWidgetSessionInitTrigger | AgentWidgetSessionInitHook;
8878
9097
  /**
8879
9098
  * Get stored session ID for session resumption (client token mode only).
8880
9099
  * Called when initializing a new session to check if there's a previous session_id
@@ -8907,13 +9126,20 @@ type AgentWidgetConfig = {
8907
9126
  */
8908
9127
  setStoredSessionId?: (sessionId: string) => void;
8909
9128
  /**
8910
- * Called immediately before any cross-device history request and before a
9129
+ * With identityProvider, called before every client-token chat POST, including retries, independently of history.
9130
+ * Also called immediately before any cross-device history request and before a
8911
9131
  * conversationId resume of a conversation discovered on another device.
8912
- * Return a fresh end-user access token (rt_eu_… / JWT). Null uses exact-browser
8913
- * scope only for a never-bound visitor; a previously bound visitor fails closed
8914
- * until resetHistoryIdentity() runs. Never cached by the widget.
9132
+ * Return a fresh end-user access token (rt_eu_… / JWT). Null stops identity-enabled chat.
9133
+ * For history only, null uses exact-browser scope for a never-bound visitor;
9134
+ * a bound visitor fails closed until resetHistoryIdentity(). Never cached.
8915
9135
  */
8916
9136
  getIdentityProof?: () => string | null | Promise<string | null>;
9137
+ /**
9138
+ * Provider name registered with Runtype, for example "clerk". Enables per-request
9139
+ * chat identity through getIdentityProof without enabling history. A missing or
9140
+ * failed proof stops the turn; omitting this preserves history-only callbacks.
9141
+ */
9142
+ identityProvider?: string;
8917
9143
  /**
8918
9144
  * Read the persisted active conversation id (client token mode only).
8919
9145
  * Called only after the internal stored-state bootstrap gate resolves.
@@ -9587,6 +9813,8 @@ type AgentWidgetReasoning = {
9587
9813
  durationMs?: number;
9588
9814
  };
9589
9815
  type AgentWidgetToolCall = {
9816
+ /** Optional approval state for activity-row status chrome. */
9817
+ approvalStatus?: "pending" | "approved" | "denied" | "timeout";
9590
9818
  id: string;
9591
9819
  name?: string;
9592
9820
  status: "pending" | "running" | "complete";