@runtypelabs/persona 4.17.0 → 4.18.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 (165) 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-BpWGm7_6.d.cts → types-DsmTD8TO.d.cts} +12 -0
  4. package/dist/animations/{types-BpWGm7_6.d.ts → types-DsmTD8TO.d.ts} +12 -0
  5. package/dist/animations/wipe.d.cts +1 -1
  6. package/dist/animations/wipe.d.ts +1 -1
  7. package/dist/chunk-3I2S3I5P.js +1 -0
  8. package/dist/chunk-76IELU7F.js +1 -0
  9. package/dist/chunk-EFJBUH5F.js +1 -0
  10. package/dist/chunk-PDPVORUF.js +1 -0
  11. package/dist/chunk-Q735PSZL.js +1 -0
  12. package/dist/chunk-VK6JOIYJ.js +1 -0
  13. package/dist/codegen.cjs +4 -4
  14. package/dist/codegen.js +4 -4
  15. package/dist/{context-mentions-BTSTIBFC.js → context-mentions-MJL6S6P2.js} +1 -1
  16. package/dist/context-mentions.cjs +9 -8
  17. package/dist/context-mentions.d.cts +1224 -14
  18. package/dist/context-mentions.d.ts +1224 -14
  19. package/dist/context-mentions.js +9 -8
  20. package/dist/event-stream-view-4EZ7BGFK.js +1 -0
  21. package/dist/event-stream-view.cjs +129 -0
  22. package/dist/event-stream-view.d.cts +8384 -0
  23. package/dist/event-stream-view.d.ts +8384 -0
  24. package/dist/event-stream-view.js +129 -0
  25. package/dist/history-view-BD6OXLNA.js +898 -0
  26. package/dist/history-view.cjs +898 -0
  27. package/dist/history-view.d.cts +1461 -0
  28. package/dist/history-view.d.ts +1461 -0
  29. package/dist/history-view.js +898 -0
  30. package/dist/index.cjs +77 -77
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +2040 -21
  33. package/dist/index.d.ts +2040 -21
  34. package/dist/index.global.js +67 -66
  35. package/dist/index.global.js.map +1 -1
  36. package/dist/index.js +77 -77
  37. package/dist/index.js.map +1 -1
  38. package/dist/launcher.global.js +5 -4
  39. package/dist/launcher.global.js.map +1 -1
  40. package/dist/plugin-kit.cjs +1 -1
  41. package/dist/plugin-kit.d.cts +0 -8
  42. package/dist/plugin-kit.d.ts +0 -8
  43. package/dist/plugin-kit.js +1 -1
  44. package/dist/smart-dom-reader.d.cts +1224 -14
  45. package/dist/smart-dom-reader.d.ts +1224 -14
  46. package/dist/theme-editor-preview.cjs +970 -73
  47. package/dist/theme-editor-preview.d.cts +1343 -15
  48. package/dist/theme-editor-preview.d.ts +1343 -15
  49. package/dist/theme-editor-preview.js +81 -81
  50. package/dist/theme-editor.cjs +7 -7
  51. package/dist/theme-editor.d.cts +1227 -15
  52. package/dist/theme-editor.d.ts +1227 -15
  53. package/dist/theme-editor.js +9 -9
  54. package/dist/theme-reference.cjs +1 -1
  55. package/dist/theme-reference.d.cts +226 -7
  56. package/dist/theme-reference.d.ts +226 -7
  57. package/dist/theme-reference.js +1 -1
  58. package/dist/webmcp-polyfill.js +2 -2
  59. package/dist/widget.css +1 -1
  60. package/package.json +18 -6
  61. package/src/client-history-rest.test.ts +1034 -0
  62. package/src/client-visitor-history.test.ts +596 -0
  63. package/src/client.ts +1040 -24
  64. package/src/components/artifact-inline.ts +8 -1
  65. package/src/components/artifact-pane.test.ts +278 -1
  66. package/src/components/artifact-pane.ts +135 -67
  67. package/src/components/artifact-preview.test.ts +14 -1
  68. package/src/components/artifact-preview.ts +9 -0
  69. package/src/components/header-builder.ts +3 -0
  70. package/src/components/header-layouts.test.ts +171 -7
  71. package/src/components/header-layouts.ts +83 -53
  72. package/src/components/header-parts.test.ts +154 -1
  73. package/src/components/header-parts.ts +266 -138
  74. package/src/components/history-confirm-dialog.ts +177 -0
  75. package/src/components/history-shell-copy.ts +99 -0
  76. package/src/components/history-view/announcer.ts +40 -0
  77. package/src/components/history-view/copy.ts +105 -0
  78. package/src/components/history-view/css.ts +1078 -0
  79. package/src/components/history-view/grouping.test.ts +142 -0
  80. package/src/components/history-view/grouping.ts +142 -0
  81. package/src/components/history-view/icons.ts +73 -0
  82. package/src/components/history-view/rows.ts +341 -0
  83. package/src/components/history-view/state.ts +309 -0
  84. package/src/components/history-view.test.ts +2660 -0
  85. package/src/components/history-view.ts +1891 -0
  86. package/src/components/launcher-surface.test.ts +133 -0
  87. package/src/components/launcher.test.ts +18 -0
  88. package/src/components/launcher.ts +7 -7
  89. package/src/components/panel.ts +17 -7
  90. package/src/components/welcome.ts +72 -2
  91. package/src/defaults.ts +36 -3
  92. package/src/event-stream-view-bundle.test.ts +69 -0
  93. package/src/event-stream-view-entry.ts +19 -0
  94. package/src/event-stream-view-loader.ts +31 -0
  95. package/src/event-stream-view.ts +19 -0
  96. package/src/generated/runtype-openapi-contract.ts +54 -4
  97. package/src/history-render.ts +325 -0
  98. package/src/history-view-bundle.test.ts +78 -0
  99. package/src/history-view-entry.ts +41 -0
  100. package/src/history-view-loader.test.ts +30 -0
  101. package/src/history-view-loader.ts +32 -0
  102. package/src/history-view.ts +28 -0
  103. package/src/index-core.ts +50 -2
  104. package/src/index-global.ts +55 -0
  105. package/src/internal/demo-history-provider.test.ts +402 -0
  106. package/src/internal/demo-history-provider.ts +689 -0
  107. package/src/internal/history-provider-registry.ts +25 -0
  108. package/src/internal/history-provider.ts +150 -0
  109. package/src/internal/runtype-history-provider.test.ts +313 -0
  110. package/src/internal/runtype-history-provider.ts +240 -0
  111. package/src/plugin-kit.test.ts +16 -0
  112. package/src/plugin-kit.ts +13 -5
  113. package/src/plugins/types.ts +177 -1
  114. package/src/session-history.test.ts +1397 -0
  115. package/src/session.ts +1200 -26
  116. package/src/styles/widget-styles.test.ts +133 -0
  117. package/src/styles/widget.css +227 -8
  118. package/src/theme-editor/preview-utils.test.ts +19 -0
  119. package/src/theme-editor/preview-utils.ts +15 -1
  120. package/src/theme-editor/preview.ts +7 -1
  121. package/src/theme-editor/role-mappings.ts +4 -1
  122. package/src/theme-editor/sections.test.ts +168 -1
  123. package/src/theme-editor/sections.ts +136 -7
  124. package/src/theme-editor/webmcp/summary.ts +16 -2
  125. package/src/theme-reference.ts +20 -6
  126. package/src/types/theme.ts +213 -7
  127. package/src/types.ts +927 -7
  128. package/src/ui.artifact-rail-resize.test.ts +235 -0
  129. package/src/ui.attachments-drop.test.ts +1 -0
  130. package/src/ui.header-update-stability.test.ts +2 -2
  131. package/src/ui.history-chunk.test.ts +72 -0
  132. package/src/ui.history-config-provider.test.ts +318 -0
  133. package/src/ui.history-controller.test.ts +711 -0
  134. package/src/ui.history-lifecycle.test.ts +456 -0
  135. package/src/ui.history-render-hooks.test.ts +904 -0
  136. package/src/ui.history-shell.test.ts +1887 -0
  137. package/src/ui.rail-overlay.test.ts +573 -0
  138. package/src/ui.rail-resize.test.ts +284 -0
  139. package/src/ui.rebuild-composer.test.ts +21 -0
  140. package/src/ui.render-welcome.test.ts +42 -0
  141. package/src/ui.shortcuts.test.ts +166 -0
  142. package/src/ui.ts +3071 -240
  143. package/src/utils/__fixtures__/client-conversation-history-wire.json +108 -0
  144. package/src/utils/artifact-file.ts +15 -0
  145. package/src/utils/artifact-gate.test.ts +4 -0
  146. package/src/utils/artifact-gate.ts +13 -17
  147. package/src/utils/artifact-resize.test.ts +28 -0
  148. package/src/utils/artifact-resize.ts +9 -2
  149. package/src/utils/buttons.ts +188 -1
  150. package/src/utils/config-merge.test.ts +91 -0
  151. package/src/utils/dropdown.ts +10 -1
  152. package/src/utils/history-messages.test.ts +284 -0
  153. package/src/utils/history-messages.ts +284 -0
  154. package/src/utils/icons.ts +3 -0
  155. package/src/utils/shortcuts.test.ts +288 -0
  156. package/src/utils/shortcuts.ts +221 -0
  157. package/src/utils/theme.test.ts +501 -4
  158. package/src/utils/theme.ts +42 -3
  159. package/src/utils/tokens.ts +153 -15
  160. package/src/utils/tooltip-timing.ts +4 -0
  161. package/src/utils/tooltip.test.ts +249 -7
  162. package/src/utils/tooltip.ts +146 -4
  163. package/src/utils/visitor-store.test.ts +425 -0
  164. package/src/utils/visitor-store.ts +337 -0
  165. package/dist/chunk-QJ4LV2KW.js +0 -1
@@ -148,6 +148,10 @@ interface SemanticTokens {
148
148
  }
149
149
  interface ComponentTokenSet {
150
150
  background?: TokenReference<'color'>;
151
+ /**
152
+ * Text and glyph color on `background`. `HeaderTokens` also derives its
153
+ * unset text, icon, and border colors from this pair.
154
+ */
151
155
  foreground?: TokenReference<'color'>;
152
156
  border?: TokenReference<'color'>;
153
157
  borderRadius?: TokenReference<'radius'>;
@@ -175,6 +179,15 @@ interface LauncherTokens extends ComponentTokenSet {
175
179
  size: string;
176
180
  iconSize: string;
177
181
  shadow: TokenReference<'shadow'>;
182
+ /**
183
+ * Stroke weight of the launcher glyphs, the agent icon and the
184
+ * call-to-action arrow alike. Unitless, and must be a STRING (`"1.75"`,
185
+ * never `1.75`: the token resolver silently skips numbers). Applied as CSS,
186
+ * so it beats the attribute the icons render with. Inert for emoji / image
187
+ * launchers, which have no svg.
188
+ * @default "1.5", matching the header's controlStrokeWidth
189
+ */
190
+ iconStrokeWidth?: string;
178
191
  }
179
192
  interface PanelTokens extends ComponentTokenSet {
180
193
  width: string;
@@ -195,28 +208,212 @@ interface TextStyleTokens {
195
208
  letterSpacing?: string;
196
209
  color?: TokenReference<'color'>;
197
210
  }
211
+ /**
212
+ * Header band tokens. `background` plus `foreground` (inherited from
213
+ * `ComponentTokenSet`) is the pair that colors the band: `foreground` anchors
214
+ * the header text, and every text, action-icon, and border color the theme
215
+ * leaves unset derives from the pair. Derivation only fills unset keys, so an
216
+ * explicit key always wins, and `iconBackground` / `iconForeground` (the avatar
217
+ * tile) keep their own defaults rather than deriving.
218
+ */
198
219
  interface HeaderTokens extends ComponentTokenSet {
199
220
  background: TokenReference<'color'>;
200
- border: TokenReference<'color'>;
221
+ /**
222
+ * Hairline under the header. Unset, it derives as
223
+ * `color-mix(in srgb, foreground 14%, background)`, then the divider color.
224
+ */
225
+ border?: TokenReference<'color'>;
201
226
  borderRadius: TokenReference<'radius'>;
202
227
  /** Background of the rounded avatar tile next to the title (Lucide / emoji / image). */
203
228
  iconBackground: TokenReference<'color'>;
204
229
  /** Foreground (glyph stroke or emoji text) on the header avatar tile. */
205
230
  iconForeground: TokenReference<'color'>;
206
- /** Legacy alias of `title.color`; `title.color` wins when both are set. */
207
- titleForeground: TokenReference<'color'>;
208
- /** Legacy alias of `subtitle.color`; `subtitle.color` wins when both are set. */
209
- subtitleForeground: TokenReference<'color'>;
231
+ /**
232
+ * Legacy alias of `title.color`; `title.color` wins when both are set.
233
+ * Unset, the title takes `foreground`, then the primary color.
234
+ */
235
+ titleForeground?: TokenReference<'color'>;
236
+ /**
237
+ * Legacy alias of `subtitle.color`; `subtitle.color` wins when both are set.
238
+ * Unset, the subtitle takes `color-mix(in srgb, foreground 72%, background)`,
239
+ * then the muted text color.
240
+ */
241
+ subtitleForeground?: TokenReference<'color'>;
210
242
  /** Header title typography (next to the icon, or minimal layout title). */
211
243
  title?: TextStyleTokens;
212
244
  /** Header subtitle typography, for the line under the title. */
213
245
  subtitle?: TextStyleTokens;
214
- /** Default color for clear / close icon buttons when launcher overrides are unset. */
215
- actionIconForeground: TokenReference<'color'>;
246
+ /**
247
+ * Default color for clear / close icon buttons when launcher overrides are
248
+ * unset. Itself unset, it takes the same
249
+ * `color-mix(in srgb, foreground 72%, background)` as the subtitle, then the
250
+ * muted text color.
251
+ */
252
+ actionIconForeground?: TokenReference<'color'>;
253
+ /**
254
+ * Edge of every header icon button: close, clear chat, `trailingActions`, and
255
+ * the Messages toggle. Per-control config keys (`launcher.closeButtonSize`,
256
+ * `launcher.clearChat.size`) still win. Coarse pointers floor the hit area at
257
+ * 40px regardless. @default "32px"
258
+ */
259
+ controlSize?: string;
260
+ /** Glyph box inside a header control. @default "20px" */
261
+ controlIconSize?: string;
262
+ /**
263
+ * Stroke weight of the glyph inside a header control. Unitless, as an SVG
264
+ * stroke-width (e.g. `"1.75"`). Sparse-viewBox glyphs (the close X) render
265
+ * at 0.7 of it so their heavier visible weight still matches a dense
266
+ * sibling. @default "1.5"
267
+ */
268
+ controlStrokeWidth?: string;
216
269
  /** Box-shadow on the header (e.g., a fade shadow to replace the default border). */
217
270
  shadow?: string;
218
271
  /** Override the header bottom border (e.g., `none`). */
219
272
  borderBottom?: string;
273
+ /**
274
+ * Floor for the header strip's height (e.g. `"56px"`). Pin it together with
275
+ * `components.history.railHeader.minHeight` so the Messages rail header and
276
+ * the conversation header read as one continuous band.
277
+ */
278
+ minHeight?: string;
279
+ }
280
+ /** Messages (conversation history) surfaces. */
281
+ interface HistoryTokens {
282
+ /**
283
+ * The Messages rail's own top strip, which runs beside the widget header
284
+ * when `features.history.presentation` resolves to `rail`.
285
+ */
286
+ railHeader?: {
287
+ /** Strip background. Defaults to the rail's surface color. */
288
+ background?: TokenReference<'color'>;
289
+ /** Full border-bottom shorthand (raw CSS, e.g. `"1px solid #e5e7eb"`). @default "0" */
290
+ border?: string;
291
+ /** Strip height floor. Defaults to `components.header.minHeight`, then 56px. */
292
+ minHeight?: string;
293
+ /**
294
+ * The strip's view title ("Messages"). 14px/600 in the text color by
295
+ * default; set the type keys to restyle it.
296
+ */
297
+ title?: TextStyleTokens;
298
+ };
299
+ /**
300
+ * The "Conversations" heading over the list block. Visible in rail
301
+ * presentation only (the panel keeps it screen-reader-only). 14px/600 in
302
+ * the text color by default. Every key is pinned in the widget CSS, so
303
+ * host-page heading rules never restyle it.
304
+ */
305
+ listHeading?: TextStyleTokens;
306
+ /**
307
+ * The muted sub-headers inside the Messages surface: date groups ("Today",
308
+ * "Yesterday") and rail nav section titles (`features.history.rail.sections`
309
+ * `title`, e.g. "Workspace"). 13px/500 in the muted text color in the rail
310
+ * (the panel keeps date groups screen-reader-only). Every key is pinned in
311
+ * the widget CSS, so host-page heading rules never restyle them.
312
+ */
313
+ groupHeading?: TextStyleTokens;
314
+ /**
315
+ * The floating rail that a collapsed
316
+ * `features.history.rail.collapsedBehavior: "overlay"` opens on hover. It
317
+ * hangs below the trigger in the conversation header; its width and edge
318
+ * stay `features.history.rail` geometry, not tokens.
319
+ */
320
+ overlay?: {
321
+ /** Gap from the trigger, the docked edge, and the bottom. @default "8px" */
322
+ margin?: string;
323
+ /** Corner radius, on all four corners. @default "16px" */
324
+ borderRadius?: string;
325
+ /** Elevation over the conversation. @default "0 12px 40px rgba(0, 0, 0, 0.25)" */
326
+ shadow?: string;
327
+ /** Surface behind the rail. Defaults to the rail's own surface color. */
328
+ background?: TokenReference<'color'>;
329
+ };
330
+ /**
331
+ * Destructive action text (row Delete, "Delete all conversations").
332
+ * Defaults to `palette.colors.error.600` in light schemes and a lighter
333
+ * red in the built-in dark theme so the 14px labels keep AA contrast.
334
+ */
335
+ dangerForeground?: TokenReference<'color'>;
336
+ /**
337
+ * The delete/forget confirmation dialog the shell shows for destructive
338
+ * history actions. The danger pair is always emitted (`--persona-danger`
339
+ * / `--persona-danger-fg`); scrim and shadow keep the built-in look when
340
+ * unset.
341
+ */
342
+ confirm?: {
343
+ /**
344
+ * Destructive button fill. Defaults to `palette.colors.error.700` in
345
+ * light schemes and `error.600` in the built-in dark theme.
346
+ */
347
+ dangerBackground?: TokenReference<'color'>;
348
+ /** Destructive button label. @default "#ffffff" */
349
+ dangerForeground?: TokenReference<'color'>;
350
+ /** Overlay behind the dialog. @default "rgba(15, 23, 42, 0.45)" */
351
+ scrim?: TokenReference<'color'>;
352
+ /** Card elevation (raw CSS shadow). */
353
+ shadow?: string;
354
+ };
355
+ /** The per-row overflow menu in the Messages list (rail and panel). */
356
+ menu?: {
357
+ /**
358
+ * Menu surface. Defaults to the list surface lifted 8% toward white so
359
+ * the menu reads as elevated in dark schemes.
360
+ */
361
+ background?: TokenReference<'color'>;
362
+ /** Corner radius. @default "12px" */
363
+ borderRadius?: string;
364
+ };
365
+ /**
366
+ * Enter/exit motion of the Messages surface. Only the body slides; the bar
367
+ * is persistent chrome and never animates. Durations are milliseconds and 0
368
+ * disables that leg; `prefers-reduced-motion` always wins over these.
369
+ */
370
+ motion?: {
371
+ /** Entrance slide-and-fade duration: bare ms number, or a CSS time string. @default 180 */
372
+ enterDurationMs?: number | string;
373
+ /** Entrance easing. @default "cubic-bezier(0, 0, 0.2, 1)" */
374
+ enterEasing?: string;
375
+ /** Exit slide-and-fade duration: bare ms number, or a CSS time string. @default 160 */
376
+ exitDurationMs?: number | string;
377
+ /** Exit easing. @default "cubic-bezier(0.4, 0, 1, 1)" */
378
+ exitEasing?: string;
379
+ };
380
+ }
381
+ /**
382
+ * The portaled icon-control tooltip (header controls, composer buttons) and
383
+ * its trailing shortcut hint chip. Unset keys keep the built-in dark look.
384
+ */
385
+ interface TooltipTokens {
386
+ /** Bubble and arrow fill. @default "#111827" */
387
+ background?: TokenReference<'color'>;
388
+ /** Label color. @default "#ffffff" */
389
+ foreground?: TokenReference<'color'>;
390
+ /** Trailing shortcut hint color. @default "rgba(255, 255, 255, 0.55)" */
391
+ hintForeground?: TokenReference<'color'>;
392
+ /** Bubble corner radius. Defaults to `palette.radius.sm`. */
393
+ borderRadius?: TokenReference<'radius'>;
394
+ /** Label type size. @default "12px" */
395
+ fontSize?: string;
396
+ /** Bubble inset, full CSS shorthand. @default "6px 12px" */
397
+ padding?: TokenReference<'spacing'>;
398
+ /** Bubble box-shadow (token ref or raw CSS, e.g. `none`). */
399
+ shadow?: string;
400
+ /** Render the caret pointing at the control. @default true */
401
+ arrow?: boolean;
402
+ /** Wrap width. @default "min(320px, calc(100vw - 16px))" */
403
+ maxWidth?: string;
404
+ }
405
+ /**
406
+ * The hover-revealed action row under a message (copy, vote, read aloud).
407
+ * Unset keys inherit the shared ghost icon-button wash, which is already
408
+ * scheme-aware, so most themes never need this group.
409
+ */
410
+ interface MessageActionsTokens {
411
+ /** Hover fill. Defaults to `components.button.ghost.hoverBackground`. */
412
+ hoverBackground?: TokenReference<'color'>;
413
+ /** Hover icon color. Defaults to `semantic.colors.text`. */
414
+ hoverForeground?: TokenReference<'color'>;
415
+ /** Button corner radius. Defaults to `palette.radius.md`. */
416
+ borderRadius?: TokenReference<'radius'>;
220
417
  }
221
418
  interface MessageTokens {
222
419
  user: {
@@ -562,7 +759,13 @@ interface ComponentTokens {
562
759
  launcher: LauncherTokens;
563
760
  panel: PanelTokens;
564
761
  header: HeaderTokens;
762
+ /** Messages rail chrome. */
763
+ history?: HistoryTokens;
764
+ /** Portaled icon-control tooltip and its shortcut hint chip. */
765
+ tooltip?: TooltipTokens;
565
766
  message: MessageTokens;
767
+ /** Hover-revealed per-message action row (copy, vote, read aloud). */
768
+ messageActions?: MessageActionsTokens;
566
769
  /** Welcome / intro card shown above the message list. */
567
770
  introCard?: IntroCardTokens;
568
771
  /** Markdown surfaces (chat + artifact pane). */
@@ -645,6 +848,8 @@ interface AgentWidgetPluginStorage {
645
848
  remove: (key: string) => void;
646
849
  }
647
850
 
851
+ type ShortcutScope = "widget" | "page";
852
+
648
853
  type AgentWidgetTransformSuggestionsContext = {
649
854
  /**
650
855
  * Fresh copy of the suggestions entering this plugin, already normalized:
@@ -693,6 +898,37 @@ type AgentWidgetRenderWelcomeContext = {
693
898
  /** Teardown for this render; runs before the next one and on destroy. */
694
899
  onCleanup: (fn: () => void) => void;
695
900
  };
901
+ /** Context for one `railSections` entry. Frozen per invocation. */
902
+ type AgentWidgetRailSectionContext = {
903
+ /** Current rail width state. The section re-renders whenever this flips. */
904
+ collapsed: boolean;
905
+ presentation: ResolvedHistoryPresentation;
906
+ /** The same frozen action path the default rows and `renderHistoryView` use. */
907
+ actions: AgentWidgetHistoryRenderActions;
908
+ };
909
+ /** A plugin-contributed navigation section in the history rail. */
910
+ type AgentWidgetRailSection = {
911
+ /** Stable identity, stamped as `data-persona-rail-section`. */
912
+ id: string;
913
+ /** Default `"above-conversations"`. */
914
+ placement?: AgentWidgetHistoryRailSection["placement"];
915
+ /** Optional heading, styled like a conversation date-group heading. */
916
+ title?: string;
917
+ /** Section body. Null renders nothing for the current state. */
918
+ render: (context: AgentWidgetRailSectionContext) => Element | null;
919
+ };
920
+ /** A plugin-contributed keyboard shortcut, bound per widget instance. */
921
+ type AgentWidgetPluginShortcut = {
922
+ /** Stable identity, used in duplicate/throw warnings. */
923
+ id: string;
924
+ /** e.g. `"mod+b"`. "mod" is Command on Apple platforms, Control elsewhere. */
925
+ combo: string;
926
+ /** Default `"widget"`: fires only from inside the widget mount. */
927
+ scope?: ShortcutScope;
928
+ /** Returning false skips the binding for this keypress. */
929
+ when?: () => boolean;
930
+ run: () => void;
931
+ };
696
932
  type AgentWidgetSuggestionSelectContext = {
697
933
  suggestion: AgentWidgetResolvedSuggestion;
698
934
  surface: AgentWidgetSuggestionSurface;
@@ -963,6 +1199,10 @@ interface AgentWidgetPlugin {
963
1199
  * Custom renderer for loading indicator
964
1200
  * Return null to use default renderer (or config-based renderer)
965
1201
  *
1202
+ * Covers the streaming indicator ('inline', 'standalone') and the transcript
1203
+ * skeleton shown while a conversation opened from the Messages list loads
1204
+ * ('conversation-open').
1205
+ *
966
1206
  * @example
967
1207
  * ```typescript
968
1208
  * renderLoadingIndicator: ({ location, defaultRenderer }) => {
@@ -1014,6 +1254,118 @@ interface AgentWidgetPlugin {
1014
1254
  * Return null to use default renderer.
1015
1255
  */
1016
1256
  renderEventStreamPayload?: (context: EventStreamPayloadRenderContext) => HTMLElement | null;
1257
+ /**
1258
+ * Replace the complete history ("Messages") navigation contents in either
1259
+ * host. Plugins run by priority and the first non-null element wins; null
1260
+ * falls through to the default full view, which then applies the first
1261
+ * non-null header/row/state hook at each slot.
1262
+ *
1263
+ * Calling `defaultRenderer()` bypasses this hook only: the default view is
1264
+ * built and its lower-level slots still arbitrate, including this plugin's.
1265
+ * Return it (or an element containing it) to compose rather than replace.
1266
+ *
1267
+ * The hook replaces contents, not orchestration. Persona keeps placement,
1268
+ * open/close, responsive rail <-> panel movement, inertness, Escape, the
1269
+ * confirmation dialogs, live announcements, and focus fallback. Fetch nothing
1270
+ * directly: `actions.refresh()` is the only way to reload the list.
1271
+ *
1272
+ * @example
1273
+ * ```typescript
1274
+ * renderHistoryView: ({ conversations, actions, presentation, onCleanup }) => {
1275
+ * const rail = document.createElement("nav");
1276
+ * rail.dataset.presentation = presentation;
1277
+ * for (const conversation of conversations) {
1278
+ * const row = document.createElement("button");
1279
+ * row.textContent = conversation.title;
1280
+ * row.addEventListener("click", () => void actions.openConversation(conversation.id));
1281
+ * rail.appendChild(row);
1282
+ * }
1283
+ * const timer = setInterval(() => void actions.refresh(), 60_000);
1284
+ * onCleanup(() => clearInterval(timer));
1285
+ * return rail;
1286
+ * }
1287
+ * ```
1288
+ */
1289
+ renderHistoryView?: (context: AgentWidgetRenderHistoryViewContext) => HTMLElement | null;
1290
+ /**
1291
+ * Replace the standard Messages header while retaining its list/state UI.
1292
+ * Return null to use the default top bar. A custom header may not remove the
1293
+ * keyboard close path or falsify the resolved open state.
1294
+ */
1295
+ renderHistoryHeader?: (context: AgentWidgetRenderHistoryHeaderContext) => HTMLElement | null;
1296
+ /**
1297
+ * Replace one conversation row while retaining standard paging/grouping.
1298
+ * Return null to use the default row.
1299
+ */
1300
+ renderHistoryConversation?: (context: AgentWidgetRenderHistoryConversationContext) => HTMLElement | null;
1301
+ /**
1302
+ * Replace loading, empty, error, authentication, rate-limit, or recovery
1303
+ * content in the list region. Return null to use the default block.
1304
+ */
1305
+ renderHistoryState?: (context: AgentWidgetRenderHistoryStateContext) => HTMLElement | null;
1306
+ /**
1307
+ * Replace the transcript-level error surface shown when opening a
1308
+ * conversation from the Messages list fails. Plugins run by priority and
1309
+ * the first non-null element wins; null falls through to the default block.
1310
+ *
1311
+ * Persona keeps the centered transcript column, the alert role, and the
1312
+ * composer gate around the returned element. `retry`/`back` are the only
1313
+ * exits: both route through the token-guarded open flow, so do not fetch
1314
+ * directly. `back` is absent when there is no Messages surface to return
1315
+ * to; do not render a back affordance without it.
1316
+ */
1317
+ renderHistoryOpenError?: (context: AgentWidgetRenderHistoryOpenErrorContext) => HTMLElement | null;
1318
+ /**
1319
+ * Contribute navigation sections to the history rail, stacked around the
1320
+ * conversation list in `placement` order. Rail only: the panel presentation
1321
+ * renders none of them, and `features.history.rail.sections` (config) comes
1322
+ * first inside each bucket, then plugins in plugin order.
1323
+ *
1324
+ * `render` is re-invoked with the new `collapsed` value whenever the rail
1325
+ * collapses or expands, and its return replaces the previous content;
1326
+ * returning null renders nothing for that state. A throwing `render` warns
1327
+ * once and drops that section only, leaving the rest of the rail alone. An id
1328
+ * a config section already owns is dropped with a warning.
1329
+ *
1330
+ * Keep heavy UI in the host bundle: `render` may return a skeleton and
1331
+ * hydrate it after the host's own dynamic import resolves.
1332
+ *
1333
+ * @example
1334
+ * ```typescript
1335
+ * railSections: [
1336
+ * {
1337
+ * id: "pinned",
1338
+ * title: "Pinned",
1339
+ * render: ({ collapsed, actions }) => {
1340
+ * if (collapsed) return null;
1341
+ * const list = document.createElement("div");
1342
+ * const row = document.createElement("button");
1343
+ * row.textContent = "Weekly report";
1344
+ * row.addEventListener("click", () => void actions.openConversation("c1"));
1345
+ * list.appendChild(row);
1346
+ * return list;
1347
+ * }
1348
+ * }
1349
+ * ]
1350
+ * ```
1351
+ */
1352
+ railSections?: AgentWidgetRailSection[];
1353
+ /**
1354
+ * Keyboard shortcuts registered for the lifetime of each widget instance the
1355
+ * plugin is active in, and unregistered on its teardown. `combo` is written
1356
+ * as `"mod+b"` / `"mod+shift+k"`, where "mod" is Command on Apple platforms
1357
+ * and Control elsewhere. `scope` defaults to `"widget"` (only while focus is
1358
+ * inside the mount); `when` returning false skips the keypress. A combo
1359
+ * another binding already owns warns and is ignored, first registration wins.
1360
+ *
1361
+ * @example
1362
+ * ```typescript
1363
+ * shortcuts: [
1364
+ * { id: "open-inbox", combo: "mod+shift+i", run: () => openInbox() }
1365
+ * ]
1366
+ * ```
1367
+ */
1368
+ shortcuts?: AgentWidgetPluginShortcut[];
1017
1369
  /**
1018
1370
  * Called when plugin is registered
1019
1371
  */
@@ -1052,6 +1404,7 @@ type RuntypeExecutionStreamEvent = ({
1052
1404
  iterations?: number;
1053
1405
  kind: "agent" | "flow";
1054
1406
  seq: number;
1407
+ stepErrorCount?: number;
1055
1408
  stopReason?: string;
1056
1409
  success: boolean;
1057
1410
  successfulSteps?: number;
@@ -1381,10 +1734,21 @@ type RuntypeExecutionStreamEvent = ({
1381
1734
  mode: "form" | "url";
1382
1735
  pauseCount?: number;
1383
1736
  requestedSchema?: Record<string, unknown>;
1737
+ requests?: Array<{
1738
+ message: string;
1739
+ mode: "form" | "url";
1740
+ name: string;
1741
+ requestedSchema?: Record<string, unknown>;
1742
+ url?: string;
1743
+ }>;
1384
1744
  serverName?: string;
1385
1745
  url?: string;
1386
1746
  };
1387
1747
  executionId: string;
1748
+ externalAgent?: {
1749
+ contextId?: string;
1750
+ taskId?: string;
1751
+ };
1388
1752
  origin?: "webmcp" | "sdk";
1389
1753
  pageOrigin?: string;
1390
1754
  parameters?: Record<string, unknown>;
@@ -1449,6 +1813,101 @@ type TargetResolver = (id: string) => {
1449
1813
  payload: Record<string, unknown>;
1450
1814
  };
1451
1815
 
1816
+ /**
1817
+ * History provider seam (`docs/visitor-history-implementation-plan.md` D9).
1818
+ * Session/UI history code depends on this interface, never on
1819
+ * `AgentWidgetClient`.
1820
+ *
1821
+ * The module stays under `internal/` but its contract is public: `index-core.ts`
1822
+ * re-exports these declarations so integrators can implement
1823
+ * `features.history.provider`. The provider REGISTRY beside it stays private.
1824
+ */
1825
+
1826
+ /** Fixed for the lifetime of one opened history view/action chain. */
1827
+ interface HistoryOperationContext {
1828
+ scope: HistoryScope;
1829
+ }
1830
+ /**
1831
+ * An authorized-but-not-yet-applied conversation activation. The provider must
1832
+ * not mutate the active chat until `commit()`.
1833
+ */
1834
+ interface PreparedHistoryActivation {
1835
+ conversationId: string;
1836
+ conversationRevision: string;
1837
+ /** Apply the already-authorized provider-specific transport/session binding. */
1838
+ commit(): void | Promise<void>;
1839
+ /** Idempotently abandon a stale/superseded activation without changing chat. */
1840
+ discard(): void;
1841
+ }
1842
+ interface HistoryListOptions {
1843
+ cursor?: string;
1844
+ limit?: number;
1845
+ targetId?: string;
1846
+ context: HistoryOperationContext;
1847
+ }
1848
+ interface HistoryListResult {
1849
+ items: HistoryConversationSummary[];
1850
+ nextCursor: string | null;
1851
+ }
1852
+ interface HistoryPageOptions {
1853
+ cursor?: string;
1854
+ /** Lets the provider synthesize stable timestamps across page boundaries. */
1855
+ beforeCreatedAt?: string;
1856
+ context: HistoryOperationContext;
1857
+ }
1858
+ interface HistoryPageResult {
1859
+ summary: HistoryConversationSummary;
1860
+ /** Already mapped; the visitor-visible projection lives in `content`. */
1861
+ messages: AgentWidgetMessage[];
1862
+ conversationRevision: string;
1863
+ /** Follow for the next older page. `null` at the start of the transcript. */
1864
+ nextCursor: string | null;
1865
+ }
1866
+ interface HistoryDeleteAllOptions {
1867
+ /** Absent means the whole authorized scope, never the UI default. */
1868
+ targetId?: string;
1869
+ context: HistoryOperationContext;
1870
+ }
1871
+ /** The contract a `features.history.provider` implementation satisfies. */
1872
+ interface HistoryProvider {
1873
+ readonly capabilities: {
1874
+ scopes: readonly HistoryScope[];
1875
+ };
1876
+ getIdentityStatus(): HistoryIdentityStatus;
1877
+ subscribeIdentityStatus(callback: (status: HistoryIdentityStatus) => void): () => void;
1878
+ list(opts: HistoryListOptions): Promise<HistoryListResult>;
1879
+ getPage(id: string, opts: HistoryPageOptions): Promise<HistoryPageResult>;
1880
+ prepareOpen(id: string, opts: {
1881
+ context: HistoryOperationContext;
1882
+ }): Promise<PreparedHistoryActivation>;
1883
+ prepareStartNew(opts: {
1884
+ context: HistoryOperationContext;
1885
+ }): Promise<PreparedHistoryActivation>;
1886
+ delete(id: string, opts: {
1887
+ context: HistoryOperationContext;
1888
+ }): Promise<void>;
1889
+ deleteAll(opts: HistoryDeleteAllOptions): Promise<{
1890
+ deleted: number;
1891
+ }>;
1892
+ /**
1893
+ * Optional capability: visitor-scoped rename/star. Absence hides every
1894
+ * update affordance (star glyphs, built-in title-menu actions). A user-set
1895
+ * title pins: the provider must never let a later auto-generated title
1896
+ * overwrite one set through this call.
1897
+ */
1898
+ update?(id: string, patch: HistoryConversationPatch, opts: {
1899
+ context: HistoryOperationContext;
1900
+ }): Promise<HistoryConversationSummary>;
1901
+ /**
1902
+ * Optional capability. Absence hides "forget this device". Resolves (never
1903
+ * rejects) on remote failure; credentials are cleared in `finally` either way.
1904
+ */
1905
+ resetDevice?(): Promise<{
1906
+ remoteRevocationConfirmed: boolean;
1907
+ }>;
1908
+ subscribeAvailability?(callback: (available: boolean) => void): () => void;
1909
+ }
1910
+
1452
1911
  /**
1453
1912
  * Curated registry of lucide icons available to `renderLucideIcon`.
1454
1913
  *
@@ -1533,6 +1992,7 @@ declare const LUCIDE_ICONS: {
1533
1992
  readonly "ellipsis-vertical": IconNode;
1534
1993
  readonly menu: IconNode;
1535
1994
  readonly house: IconNode;
1995
+ readonly "panel-left": IconNode;
1536
1996
  readonly plus: IconNode;
1537
1997
  readonly minus: IconNode;
1538
1998
  readonly pencil: IconNode;
@@ -2694,6 +3154,8 @@ type AgentWidgetArtifactsLayoutConfig = {
2694
3154
  documentToolbarToggleActiveBackground?: string;
2695
3155
  /** Active view/source toggle border color. Sets `--persona-artifact-doc-toggle-active-border`. */
2696
3156
  documentToolbarToggleActiveBorderColor?: string;
3157
+ /** Active view/source toggle icon color (defaults to `documentToolbarIconColor`). Sets `--persona-artifact-doc-toggle-active-color`. */
3158
+ documentToolbarToggleActiveColor?: string;
2697
3159
  /** Show an expand/collapse toggle in the artifact toolbar (both presets). Expanded fills the widget with the pane and hides the chat column. Default: false. */
2698
3160
  showExpandToggle?: boolean;
2699
3161
  /** Show the copy control in the `default` toolbar preset (the `document` preset always shows it). Default: false. */
@@ -2706,13 +3168,20 @@ type AgentWidgetArtifactsLayoutConfig = {
2706
3168
  /** Tab fade width (CSS length). @default 24px */
2707
3169
  tabFadeSize?: string;
2708
3170
  /**
2709
- * Invoked when the document toolbar Refresh control is used (before the pane re-renders).
2710
- * Use to replay `connectStream`, refetch, etc.
3171
+ * Invoked when the document toolbar Refresh control is used (before the pane
3172
+ * re-renders). The button renders only while this handler is set: the refresh
3173
+ * glyph universally reads "reload this preview" (Claude artifacts, v0), so
3174
+ * keep the handler scoped to refreshing the rendered artifact — regenerating
3175
+ * content or resetting the conversation belongs to message-level or
3176
+ * conversation-level controls, not artifact chrome.
2711
3177
  */
2712
3178
  onDocumentToolbarRefresh?: () => void | Promise<void>;
2713
3179
  /**
2714
3180
  * Optional copy dropdown entries (shown when `documentToolbarShowCopyChevron` is true and this array is non-empty).
2715
3181
  * The main Copy control still performs default copy unless `onDocumentToolbarCopyMenuSelect` handles everything.
3182
+ * Without a handler, built-in ids work out of the box: `download` saves the
3183
+ * artifact (real filename/MIME for file artifacts, `<title>.md` otherwise);
3184
+ * `markdown`/`md` and `json`/`source` copy that form to the clipboard.
2716
3185
  */
2717
3186
  documentToolbarCopyMenuItems?: Array<{
2718
3187
  id: string;
@@ -2720,13 +3189,24 @@ type AgentWidgetArtifactsLayoutConfig = {
2720
3189
  }>;
2721
3190
  /**
2722
3191
  * When set, invoked for the chevron menu (and can override default copy per `actionId`).
3192
+ * Return `false` to fall through to the widget's built-in behavior for that
3193
+ * action id (`download` saves the artifact; copy ids copy); any other return
3194
+ * value keeps the handler's outcome as final.
2723
3195
  */
2724
3196
  onDocumentToolbarCopyMenuSelect?: (payload: {
2725
3197
  actionId: string;
2726
3198
  artifactId: string | null;
2727
3199
  markdown: string;
2728
3200
  jsonPayload: string;
2729
- }) => void | Promise<void>;
3201
+ /** File metadata when the selected artifact is a previewable file. */
3202
+ file?: PersonaArtifactFileMeta;
3203
+ /** Filename the built-in download would use (file basename, or `<title>.md`). */
3204
+ suggestedFilename: string;
3205
+ /** MIME type paired with `suggestedFilename`. */
3206
+ mime: string;
3207
+ /** Raw content the built-in download would write (unfenced source for file artifacts). */
3208
+ content: string;
3209
+ }) => void | boolean | Promise<void | boolean>;
2730
3210
  };
2731
3211
  /**
2732
3212
  * Where the artifact body renders by default. Every mode shows the compact
@@ -3569,6 +4049,11 @@ type AgentWidgetFeatureFlags = {
3569
4049
  * pills + optional free-text input.
3570
4050
  */
3571
4051
  askUserQuestion?: AgentWidgetAskUserQuestionFeature;
4052
+ /**
4053
+ * Per-visitor conversation history. Client token mode only; disabled by
4054
+ * default so no capability flag is sent on init and no UI mounts.
4055
+ */
4056
+ history?: AgentWidgetHistoryFeature;
3572
4057
  /**
3573
4058
  * Built-in `suggest_replies` follow-ups. When the assistant invokes the
3574
4059
  * tool, the widget shows the suggestions using `suggestions.followUps` and
@@ -3766,6 +4251,604 @@ type AgentWidgetAskUserQuestionFeature = {
3766
4251
  /** Style overrides for the sheet and pills. */
3767
4252
  styles?: AgentWidgetAskUserQuestionStyles;
3768
4253
  };
4254
+ /**
4255
+ * Copy overrides for the visitor-facing conversation history surface. These are
4256
+ * the widget's only localization mechanism for history, so every user-visible
4257
+ * history string is listed here.
4258
+ */
4259
+ interface AgentWidgetHistoryCopy {
4260
+ /** Title of the history view. Defaults to "Messages". */
4261
+ viewTitle?: string;
4262
+ /** Heading shown when the visitor has no stored conversations. */
4263
+ emptyTitle?: string;
4264
+ /** Body text shown when the visitor has no stored conversations. */
4265
+ emptyDescription?: string;
4266
+ /** Heading shown when a history request fails. */
4267
+ errorTitle?: string;
4268
+ /** Body text shown when a history request fails. */
4269
+ errorDescription?: string;
4270
+ /** Label for the retry action on the error state. */
4271
+ retryLabel?: string;
4272
+ /** Heading shown after a 429 rate-limited history response. */
4273
+ rateLimitedTitle?: string;
4274
+ /** Body text shown after a 429 rate-limited history response. */
4275
+ rateLimitedDescription?: string;
4276
+ /** Confirmation prompt before deleting a single conversation. */
4277
+ deleteConversationConfirm?: string;
4278
+ /** Confirmation prompt before deleting every conversation in the active scope. */
4279
+ clearHistoryConfirm?: string;
4280
+ /** Confirmation prompt before detaching this browser from its history identity. */
4281
+ resetIdentityConfirm?: string;
4282
+ /** Label for the action that starts a new server conversation. */
4283
+ newConversationLabel?: string;
4284
+ /** Label for the action that prepends the previous transcript page. */
4285
+ showEarlierMessagesLabel?: string;
4286
+ /** Accessible label for the transcript skeleton while a conversation loads. */
4287
+ openConversationLoadingLabel?: string;
4288
+ /** Body text when a selected conversation failed to load. */
4289
+ openConversationErrorTitle?: string;
4290
+ /** Label for the retry action after a conversation failed to load. */
4291
+ openConversationRetryLabel?: string;
4292
+ /** Label for the return-to-messages action after a conversation failed to load. */
4293
+ openConversationBackLabel?: string;
4294
+ /** Status notice after a deleted conversation was recovered into a fresh one. */
4295
+ conversationDeletedNotice?: string;
4296
+ /** Status notice after this browser was detached from its history identity. */
4297
+ identityResetNotice?: string;
4298
+ /** Status notice when a local reset succeeded but server revocation was unconfirmed. */
4299
+ identityResetUnconfirmedNotice?: string;
4300
+ /** Pinned group heading for starred conversations. */
4301
+ groupStarred?: string;
4302
+ /** Time-group heading for conversations updated today. */
4303
+ groupToday?: string;
4304
+ /** Time-group heading for conversations updated yesterday. */
4305
+ groupYesterday?: string;
4306
+ /** Time-group heading for the trailing 7-day window. */
4307
+ groupPrevious7Days?: string;
4308
+ /** Time-group heading for the trailing 30-day window. */
4309
+ groupPrevious30Days?: string;
4310
+ /** Time-group heading for older conversations, grouped by month and year. */
4311
+ groupMonthYear?: string;
4312
+ /** Scope title when history is limited to this browser. */
4313
+ browserOnlyTitle?: string;
4314
+ /** Scope description when history is limited to this browser. */
4315
+ browserOnlyDescription?: string;
4316
+ /** Scope title while an identity proof is being resolved. */
4317
+ verifyingTitle?: string;
4318
+ /** Scope description while an identity proof is being resolved. */
4319
+ verifyingDescription?: string;
4320
+ /** Scope title when history is available across signed-in devices. */
4321
+ verifiedTitle?: string;
4322
+ /** Scope description when history is available across signed-in devices. */
4323
+ verifiedDescription?: string;
4324
+ /** Scope title when the visitor must sign in again to view account history. */
4325
+ authenticationRequiredTitle?: string;
4326
+ /** Scope description when the visitor must sign in again to view account history. */
4327
+ authenticationRequiredDescription?: string;
4328
+ /** Scope title when the host identity provider threw or rejected. */
4329
+ identityProviderFailedTitle?: string;
4330
+ /** Scope description when the host identity provider threw or rejected. */
4331
+ identityProviderFailedDescription?: string;
4332
+ /** Scope title when the server did not admit a supplied identity proof. */
4333
+ proofNotAdmittedTitle?: string;
4334
+ /** Scope description when the server did not admit a supplied identity proof. */
4335
+ proofNotAdmittedDescription?: string;
4336
+ /** Label for the action that retries identity resolution. */
4337
+ retryIdentityLabel?: string;
4338
+ /** Accessible name of the header control that opens history. */
4339
+ openHistoryLabel?: string;
4340
+ /** Accessible name of that control while a turn is streaming or resuming. */
4341
+ openHistoryBusyLabel?: string;
4342
+ /** Least-destructive action in every history confirmation dialog. */
4343
+ confirmCancelLabel?: string;
4344
+ /** Heading of the delete-one confirmation. */
4345
+ deleteConversationConfirmTitle?: string;
4346
+ /** Confirming action of the delete-one confirmation. */
4347
+ deleteConversationConfirmLabel?: string;
4348
+ /** Heading of the delete-all confirmation. */
4349
+ clearHistoryConfirmTitle?: string;
4350
+ /** Confirming action of the delete-all confirmation. */
4351
+ clearHistoryConfirmLabel?: string;
4352
+ /** Delete-all body used when the resolved scope is the signed-in user. */
4353
+ clearHistoryVerifiedConfirm?: string;
4354
+ /** Heading of the forget-this-device confirmation. */
4355
+ resetIdentityConfirmTitle?: string;
4356
+ /** Confirming action of the forget-this-device confirmation. */
4357
+ resetIdentityConfirmLabel?: string;
4358
+ /** Panel back control; returns to the surface that opened Messages. */
4359
+ backLabel?: string;
4360
+ /** Rail close control, shown only when the rail is not collapsible. */
4361
+ closeLabel?: string;
4362
+ /** Rail collapse toggle while the rail is expanded. */
4363
+ collapseLabel?: string;
4364
+ /** Rail collapse toggle while the rail is collapsed to icons. */
4365
+ expandLabel?: string;
4366
+ /** Accessible name of the docked rail's drag-resize handle. */
4367
+ resizeLabel?: string;
4368
+ /** Accessible status while the first page loads. */
4369
+ loadingLabel?: string;
4370
+ /** Label of the paging action below the last group. */
4371
+ loadMoreLabel?: string;
4372
+ /** Label of that action while its page is in flight. */
4373
+ loadingMoreLabel?: string;
4374
+ /**
4375
+ * Heading over the conversation list. Visible in rail presentation, where it
4376
+ * carries the list overflow trigger; sr-only in panel presentation.
4377
+ */
4378
+ conversationsTitle?: string;
4379
+ /** Accessible name of the per-row overflow trigger and its menu. */
4380
+ rowActionsLabel?: string;
4381
+ /** Accessible name of the list-level overflow trigger and its menu. */
4382
+ listOptionsLabel?: string;
4383
+ /** Delete item inside the per-row overflow menu. */
4384
+ deleteConversationLabel?: string;
4385
+ /** Delete-all item inside the list overflow menu. */
4386
+ clearHistoryLabel?: string;
4387
+ /** Forget-this-device item inside the list overflow menu. */
4388
+ resetIdentityLabel?: string;
4389
+ /** Row message count. `{count}` placeholder. */
4390
+ messageCountLabel?: string;
4391
+ /** Row message count for exactly one message. */
4392
+ messageCountLabelOne?: string;
4393
+ /** Announced after a single conversation was deleted. */
4394
+ conversationRemovedNotice?: string;
4395
+ /** Announced after every conversation in scope was deleted. */
4396
+ historyClearedNotice?: string;
4397
+ /** Heading shown when history is unavailable for this surface. */
4398
+ unavailableTitle?: string;
4399
+ /** Body text shown when history is unavailable for this surface. */
4400
+ unavailableDescription?: string;
4401
+ /** Heading of the post-deletion replacement-init recovery state. */
4402
+ newConversationRequiredTitle?: string;
4403
+ /** Body text of the post-deletion replacement-init recovery state. */
4404
+ newConversationRequiredDescription?: string;
4405
+ /** Rate-limited wait guidance. `{seconds}` placeholder. */
4406
+ rateLimitedWaitDescription?: string;
4407
+ /** Row-adjacent error after a failed open. */
4408
+ openFailedLabel?: string;
4409
+ /** Row-adjacent error after a failed delete. */
4410
+ deleteFailedLabel?: string;
4411
+ /** Relative time for the most recent bucket. */
4412
+ relativeNow?: string;
4413
+ /** Relative time in minutes. `{value}` placeholder. */
4414
+ relativeMinutes?: string;
4415
+ /** Relative time in hours. `{value}` placeholder. */
4416
+ relativeHours?: string;
4417
+ /** Relative time in days. `{value}` placeholder. */
4418
+ relativeDays?: string;
4419
+ /** Relative time in weeks. `{value}` placeholder. */
4420
+ relativeWeeks?: string;
4421
+ /** Relative time in years. `{value}` placeholder. */
4422
+ relativeYears?: string;
4423
+ }
4424
+ /**
4425
+ * One row in a `features.history.rail.sections` navigation section. Icon
4426
+ * precedence, highest first: `renderIcon`, then `iconUrl`, then `icon`.
4427
+ * Whichever resolves first is built once and reused for the item's lifetime.
4428
+ */
4429
+ interface AgentWidgetHistoryRailSectionItem {
4430
+ /** Stable identity, stamped as `data-persona-rail-item`. */
4431
+ id: string;
4432
+ /** Visible text, and the default `aria-label` of the button. */
4433
+ label: string;
4434
+ /**
4435
+ * Lucide name from the widget's built-in icon registry (see `IconName`). A
4436
+ * name outside the registry warns once and the row renders label-only.
4437
+ */
4438
+ icon?: IconName | (string & {});
4439
+ /** Image URL or data URI, rendered as a decorative `img` in the icon slot. */
4440
+ iconUrl?: string;
4441
+ /** Full custom icon node. Returning null renders the row label-only. */
4442
+ renderIcon?: () => Element | null;
4443
+ /** Small trailing text chip, for a count or a short status word. */
4444
+ badge?: string;
4445
+ /** Invoked on click. A throw is caught and warned once per section. */
4446
+ onSelect: () => void;
4447
+ }
4448
+ /** One navigation section in the history rail, above or below the list. */
4449
+ interface AgentWidgetHistoryRailSection {
4450
+ /** Stable identity, stamped as `data-persona-rail-section`. */
4451
+ id: string;
4452
+ /** Optional heading, styled like a conversation date-group heading. */
4453
+ title?: string;
4454
+ /** Default `"above-conversations"`. */
4455
+ placement?: "above-conversations" | "below-conversations" | "footer";
4456
+ items: AgentWidgetHistoryRailSectionItem[];
4457
+ }
4458
+ /**
4459
+ * Host-defined item in the list overflow menu (the `…` beside the
4460
+ * conversation-list heading). Rendered above the built-in destructive items.
4461
+ */
4462
+ interface AgentWidgetHistoryListAction {
4463
+ /** Stable identity; keeps menu focus keys stable across re-renders. */
4464
+ id: string;
4465
+ label: string;
4466
+ /** Destructive (red) styling like the built-in delete-all. Default false. */
4467
+ danger?: boolean;
4468
+ /** Receives the conversation summaries loaded at selection time. */
4469
+ onSelect: (context: {
4470
+ conversations: HistoryConversationSummary[];
4471
+ }) => void | Promise<void>;
4472
+ }
4473
+ /**
4474
+ * Feature config for per-visitor conversation history. Without a `provider`,
4475
+ * client token mode only: the built-in Runtype backend needs one, so the UI
4476
+ * never renders for proxy/agent sessions. A `provider` lifts that restriction.
4477
+ */
4478
+ interface AgentWidgetHistoryFeature {
4479
+ /** Master switch. Default false: no capability flag on init, no UI. */
4480
+ enabled?: boolean;
4481
+ /**
4482
+ * Custom conversation-history backend. Supply one to run the history UX
4483
+ * (list, open, delete, delete-all, header title binding) against your own
4484
+ * storage in ANY session mode, including a custom `apiUrl` backend with no
4485
+ * client token. Omitted, history falls back to the built-in Runtype backend,
4486
+ * which requires client token mode.
4487
+ *
4488
+ * Pass either an instance or a factory. The factory form is called once per
4489
+ * widget instance, so a single script-tag config object (assembled before
4490
+ * install) can back several widgets without sharing provider state. Passing a
4491
+ * new factory identity through `update()` rebuilds the provider.
4492
+ *
4493
+ * Failures are signalled by throwing `HistoryProviderError` with a `code` from
4494
+ * `HistoryProviderErrorCode`. The view branches on that code alone: it never
4495
+ * reads message text, and an untyped throw degrades to a generic error state.
4496
+ *
4497
+ * `prepareOpen`/`prepareStartNew` resolve BEFORE anything visible changes:
4498
+ * they return a `PreparedHistoryActivation` whose `commit()` applies the
4499
+ * already-authorized binding and whose `discard()` idempotently abandons a
4500
+ * superseded activation, leaving the active chat untouched. The widget calls
4501
+ * exactly one of the two per prepared activation.
4502
+ *
4503
+ * Optional capabilities hide their affordances when absent: no `update`
4504
+ * removes the rename/star actions (including the built-in title-menu `star`),
4505
+ * and no `resetDevice` removes "forget this device".
4506
+ *
4507
+ * The provider's `capabilities.scopes` is authoritative: the widget derives a
4508
+ * default scope (`"verified-user"` when `getIdentityProof` is configured,
4509
+ * otherwise `"browser"`) and narrows it to what the provider advertises, so a
4510
+ * browser-only provider is never asked for a scope it cannot serve. An
4511
+ * explicit `features.history.scope` is a hard request and still fails closed
4512
+ * with `unsupported_scope`. `getIdentityProof` is never called for a supplied
4513
+ * provider, and `HistoryOperationContext` carries only the resolved scope;
4514
+ * report your own identity through `getIdentityStatus()` /
4515
+ * `subscribeIdentityStatus()`, which is what the scope banner and its retry
4516
+ * affordance read.
4517
+ *
4518
+ * Reopening the last conversation after a page reload is the host's job: the
4519
+ * widget's boot resume runs only on the built-in Runtype path, so with a
4520
+ * supplied provider the transcript is restored by the storage adapter while
4521
+ * `getActiveConversationId()` starts null (no active row, no
4522
+ * conversation-bound header title) until something opens a conversation.
4523
+ * Persist the id yourself and call `controller.openConversation(id)` on ready
4524
+ * if you want the last conversation to come back automatically.
4525
+ *
4526
+ * @example
4527
+ * ```js
4528
+ * features: { history: { enabled: true, provider: () => myProvider } }
4529
+ * ```
4530
+ */
4531
+ provider?: HistoryProvider | (() => HistoryProvider);
4532
+ /** Page size for the conversation list (default 25, server max 100). */
4533
+ pageSize?: number;
4534
+ /**
4535
+ * Default history placement. "panel" replaces the conversation surface;
4536
+ * "rail" requests a side navigation host whenever it is at least 720px wide
4537
+ * and collapses to panel below that; "auto" uses rail only for a wide inline
4538
+ * or docked shell and keeps floating launchers panel-based at every width.
4539
+ * Default "panel".
4540
+ */
4541
+ presentation?: "panel" | "rail" | "auto";
4542
+ /**
4543
+ * Geometry of the rail navigation column. `side` picks the edge it docks to
4544
+ * (default "left", beside the conversation); `width` is its fixed width in
4545
+ * px, clamped to 200-400 (default 260). `collapsible` (default true) puts a
4546
+ * collapse toggle in the rail header that shrinks it to a 52px icon rail, and
4547
+ * `defaultCollapsed` (default false) picks the state a visitor who has never
4548
+ * toggled it starts in. The chosen state is remembered per visitor alongside
4549
+ * the other `persistState` keys. Ignored in panel presentation.
4550
+ */
4551
+ rail?: {
4552
+ side?: "left" | "right";
4553
+ width?: number;
4554
+ collapsible?: boolean;
4555
+ defaultCollapsed?: boolean;
4556
+ /**
4557
+ * Drag handle on the docked rail's divider edge, resizing it live within
4558
+ * the same 200 to 400 clamp `width` takes. Default false. The chosen width
4559
+ * is remembered per visitor alongside the other `persistState` keys and
4560
+ * outranks a later `width` update, the way the collapsed state does; the
4561
+ * floating overlay rail inherits it but is never itself resizable, and a
4562
+ * collapsed icon column ignores it until it expands again.
4563
+ */
4564
+ resizable?: boolean;
4565
+ /**
4566
+ * Shape of the COLLAPSED rail. `"icon-rail"` (default) keeps the 52px icon
4567
+ * column beside the conversation. `"overlay"` removes the column entirely:
4568
+ * a trigger takes the leading edge of the conversation header, hovering or
4569
+ * tapping it floats the expanded rail over the conversation, and clicking
4570
+ * it pins the rail back open. The floating rail is transient, so leaving
4571
+ * it, Escape, a click outside, or selecting a conversation all dismiss it;
4572
+ * its own header toggle docks it instead, being the control the pointer
4573
+ * finds there. Geometry follows `width` and `side`; the collapsed rail's
4574
+ * chunk is not loaded until the first hover. Ignored when `collapsible` is
4575
+ * false or in panel presentation.
4576
+ */
4577
+ collapsedBehavior?: "icon-rail" | "overlay";
4578
+ /**
4579
+ * One brand declaration, placed in both of the rail's identity spots: the
4580
+ * header's heading area when expanded (the mark leading, `copy.viewTitle`
4581
+ * beside it as the wordmark), and the collapse toggle's rest face when the
4582
+ * rail is collapsed, where hover and keyboard focus reveal the panel glyph
4583
+ * under it. A coarse pointer keeps the glyph, having no hover to reveal it
4584
+ * with. Icon precedence, highest first: `render`, then `iconUrl`, then
4585
+ * `icon`. `render` receives the placement through `ctx.collapsed` (`true`
4586
+ * is the collapsed toggle face) and may return null to skip that spot.
4587
+ * `renderHeader` outranks this for the heading area; the collapsed face is
4588
+ * this slot's alone. Decorative either way: the view's accessible name
4589
+ * still comes from `copy.viewTitle`, and the toggle keeps its own label.
4590
+ * Ignored in panel presentation.
4591
+ */
4592
+ brand?: {
4593
+ /** Lucide name from the built-in registry; an unknown one warns once. */
4594
+ icon?: IconName | (string & {});
4595
+ /** Image URL or data URI, rendered as a decorative `img`. */
4596
+ iconUrl?: string;
4597
+ /** Full custom node. A throw warns once and drops the brand. */
4598
+ render?: (context: {
4599
+ collapsed: boolean;
4600
+ }) => Element | null;
4601
+ };
4602
+ /**
4603
+ * Full override of the rail header's identity area, outranking `brand`
4604
+ * there, re-invoked whenever the collapsed state changes. Return null to
4605
+ * leave the area empty, which leaves the collapse toggle standing alone.
4606
+ * The accessible name of the
4607
+ * view comes from `copy.viewTitle` either way: the heading stays in the
4608
+ * DOM, visually hidden, whenever this renders. Ignored in panel
4609
+ * presentation.
4610
+ */
4611
+ renderHeader?: (context: {
4612
+ collapsed: boolean;
4613
+ defaultTitle: string;
4614
+ }) => Element | null;
4615
+ /**
4616
+ * Extra navigation sections stacked around the conversation list, in array
4617
+ * order within each `placement` bucket. Rail-only in this release: a move
4618
+ * into panel presentation removes them and a move back re-renders them.
4619
+ */
4620
+ sections?: AgentWidgetHistoryRailSection[];
4621
+ /**
4622
+ * Keyboard shortcut for the collapse toggle, e.g. `"mod+b"` ("mod" is
4623
+ * Command on Apple platforms, Control elsewhere). Undefined by default, so
4624
+ * an embedded widget never claims a host page's keys. The same declaration
4625
+ * drives the binding, the toggle's tooltip hint chip, and its
4626
+ * `aria-keyshortcuts`.
4627
+ */
4628
+ collapseShortcut?: string | false;
4629
+ /**
4630
+ * Where `collapseShortcut` listens. Default `"widget"`: only while focus is
4631
+ * inside the widget. `"page"` claims the combo document-wide, which suits a
4632
+ * fullscreen widget that IS the app.
4633
+ */
4634
+ collapseShortcutScope?: "widget" | "page";
4635
+ };
4636
+ /**
4637
+ * History scope. Defaults to "verified-user" when getIdentityProof exists,
4638
+ * otherwise "browser". Before this browser has been identity-bound, a null
4639
+ * proof falls back to browser scope for that operation. Once visitor.endUserId
4640
+ * is non-null, a null proof fails closed until the host resets history identity.
4641
+ *
4642
+ * With a `provider`, this is a hard request: the provider must advertise it
4643
+ * in `capabilities.scopes` or every history operation fails with
4644
+ * `unsupported_scope`. Leave it unset to let the provider's advertised scope
4645
+ * win.
4646
+ */
4647
+ scope?: HistoryScope;
4648
+ /** Copy overrides. Every user-visible history string must be here. */
4649
+ copy?: AgentWidgetHistoryCopy;
4650
+ /**
4651
+ * Date bucketing of the conversation list. `"time"` (default) groups rows
4652
+ * under Today, Yesterday, Previous 7 days, Previous 30 days, and month
4653
+ * headings. `"none"` renders one flat list in server order instead, the
4654
+ * recents-style sidebar. Starred conversations keep their pinned group
4655
+ * either way.
4656
+ */
4657
+ grouping?: "time" | "none";
4658
+ /**
4659
+ * Leading avatar on each conversation row. Unset, rows show the launcher's
4660
+ * image mark (`launcher.iconUrl`) when one exists and are text-only
4661
+ * otherwise, the assistant-list default. Pass an image URL or a glyph to
4662
+ * always show a mark, or false to force text-only rows.
4663
+ */
4664
+ rowAvatar?: boolean | string;
4665
+ /** Show the evidence-based history scope/status beneath the Messages heading. Default true. */
4666
+ showScopeStatus?: boolean;
4667
+ /**
4668
+ * Visitor-facing delete of a single conversation via each row's overflow
4669
+ * menu. Default true. False hides the control only: it changes nothing about
4670
+ * what is stored or for how long, and custom row slots still receive
4671
+ * `requestDelete`. Turn off for deployments that treat conversations as
4672
+ * business records.
4673
+ */
4674
+ showDelete?: boolean;
4675
+ /**
4676
+ * The "Delete all conversations" item in the Messages overflow menu. Default
4677
+ * true. False hides the control only; storage and retention are unchanged.
4678
+ * The identity reset item is separate and unaffected.
4679
+ */
4680
+ showDeleteAll?: boolean;
4681
+ /**
4682
+ * Host items appended to the list overflow menu, above the built-in
4683
+ * destructive actions. The trigger renders whenever any item exists, so
4684
+ * these keep the menu alive even with `showDeleteAll: false`.
4685
+ */
4686
+ listActions?: AgentWidgetHistoryListAction[];
4687
+ }
4688
+ /** Resolved scope for a logical history operation. */
4689
+ type HistoryScope = "browser" | "verified-user";
4690
+ /** `presentation` after it has been resolved against the host container width. */
4691
+ type ResolvedHistoryPresentation = "panel" | "rail";
4692
+ /**
4693
+ * The surface Messages returns to on back/Escape. `"home"` only when a Home
4694
+ * Screen composition opened it; the core header button always records
4695
+ * `"conversation"`.
4696
+ */
4697
+ type HistoryReturnSurface = "home" | "conversation";
4698
+ /**
4699
+ * Evidence-based history identity state. Never inferred from the mere presence
4700
+ * of `getIdentityProof`, and never carries token, visitor, or end-user values.
4701
+ */
4702
+ type HistoryIdentityStatus = {
4703
+ state: "browser_only";
4704
+ reason: "configured_browser_scope" | "no_identity_provider" | "proof_unavailable_before_binding";
4705
+ } | {
4706
+ state: "verifying";
4707
+ } | {
4708
+ state: "verified";
4709
+ } | {
4710
+ state: "authentication_required";
4711
+ reason: "proof_unavailable_after_binding" | "invalid_identity_proof";
4712
+ } | {
4713
+ state: "identity_provider_failed";
4714
+ } | {
4715
+ state: "configuration_error";
4716
+ reason: "proof_not_admitted";
4717
+ } | {
4718
+ state: "resetting";
4719
+ } | {
4720
+ state: "unavailable";
4721
+ reason: "history_disabled" | "ineligible_mode";
4722
+ };
4723
+ /** Fully defaulted history copy. Every user-visible history string. */
4724
+ type ResolvedHistoryCopy = Required<AgentWidgetHistoryCopy>;
4725
+ /** List-region state handed to render hooks. */
4726
+ type HistoryViewState = {
4727
+ kind: "loading";
4728
+ phase: "initial" | "refresh" | "load-more";
4729
+ } | {
4730
+ kind: "ready";
4731
+ } | {
4732
+ kind: "empty";
4733
+ } | {
4734
+ kind: "error";
4735
+ reason: "unavailable" | "authentication_failed" | "authentication_required" | "identity_provider_failed" | "proof_not_admitted" | "unsupported_scope" | "unknown";
4736
+ retryable: boolean;
4737
+ } | {
4738
+ kind: "rate_limited";
4739
+ retryAfterSeconds: number;
4740
+ } | {
4741
+ kind: "new_conversation_required";
4742
+ };
4743
+ /** The single in-flight history operation, or `null` when idle. */
4744
+ type HistoryPendingAction = {
4745
+ kind: "refresh" | "load-more" | "start-new" | "clear" | "reset";
4746
+ } | {
4747
+ kind: "open" | "delete";
4748
+ conversationId: string;
4749
+ } | null;
4750
+ /**
4751
+ * Every history operation a render hook may invoke. Each routes through the
4752
+ * same controller/session path as the default renderer, so busy gating,
4753
+ * selection epochs, and confirmations behave identically.
4754
+ */
4755
+ type AgentWidgetHistoryRenderActions = {
4756
+ refresh(): Promise<void>;
4757
+ loadMore(): Promise<void>;
4758
+ openConversation(conversationId: string): Promise<void>;
4759
+ startNewConversation(): Promise<void>;
4760
+ /** Each request method opens Persona's accessible confirmation first. */
4761
+ requestDeleteConversation(conversationId: string): Promise<"deleted" | "cancelled">;
4762
+ requestClearConversationHistory(): Promise<"cleared" | "cancelled">;
4763
+ requestResetHistoryIdentity(): Promise<{
4764
+ outcome: "cancelled";
4765
+ } | {
4766
+ outcome: "reset";
4767
+ remoteRevocationConfirmed: boolean;
4768
+ }>;
4769
+ close(): void;
4770
+ };
4771
+ /** Context for `renderHistoryView`. Frozen snapshot; no provider or credentials. */
4772
+ type AgentWidgetRenderHistoryViewContext = {
4773
+ conversations: readonly HistoryConversationSummary[];
4774
+ activeConversationId: string | null;
4775
+ state: HistoryViewState;
4776
+ pendingAction: HistoryPendingAction;
4777
+ identityStatus: HistoryIdentityStatus;
4778
+ nextCursor: string | null;
4779
+ presentation: ResolvedHistoryPresentation;
4780
+ returnSurface: HistoryReturnSurface;
4781
+ config: AgentWidgetConfig;
4782
+ copy: ResolvedHistoryCopy;
4783
+ actions: AgentWidgetHistoryRenderActions;
4784
+ /** The default full view. Bypasses this hook only; lower slots still apply. */
4785
+ defaultRenderer(): HTMLElement;
4786
+ /** Re-run arbitration with the current snapshot. Inert after close/destroy. */
4787
+ requestRender(): void;
4788
+ /** Teardown for this render; runs before the next one and on close. */
4789
+ onCleanup(callback: () => void): void;
4790
+ };
4791
+ /** Context for `renderHistoryConversation` (one list row). */
4792
+ type AgentWidgetRenderHistoryConversationContext = {
4793
+ conversation: HistoryConversationSummary;
4794
+ active: boolean;
4795
+ pending: "opening" | "deleting" | null;
4796
+ presentation: ResolvedHistoryPresentation;
4797
+ config: AgentWidgetConfig;
4798
+ open(): Promise<void>;
4799
+ requestDelete(): Promise<"deleted" | "cancelled">;
4800
+ defaultRenderer(): HTMLElement;
4801
+ };
4802
+ /** Context for `renderHistoryHeader` (the Messages top bar). */
4803
+ type AgentWidgetRenderHistoryHeaderContext = {
4804
+ presentation: ResolvedHistoryPresentation;
4805
+ returnSurface: HistoryReturnSurface;
4806
+ identityStatus: HistoryIdentityStatus;
4807
+ pendingAction: HistoryPendingAction;
4808
+ config: AgentWidgetConfig;
4809
+ copy: ResolvedHistoryCopy;
4810
+ actions: Pick<AgentWidgetHistoryRenderActions, "close" | "startNewConversation">;
4811
+ defaultRenderer(): HTMLElement;
4812
+ };
4813
+ /**
4814
+ * Context for `renderHistoryState`. Invoked only for non-ready list states;
4815
+ * `retry`/`startNewConversation` are present only where they are safe, so
4816
+ * custom DOM never infers recovery behavior.
4817
+ */
4818
+ type AgentWidgetRenderHistoryStateContext = {
4819
+ state: Exclude<HistoryViewState, {
4820
+ kind: "ready";
4821
+ }>;
4822
+ identityStatus: HistoryIdentityStatus;
4823
+ presentation: ResolvedHistoryPresentation;
4824
+ config: AgentWidgetConfig;
4825
+ copy: ResolvedHistoryCopy;
4826
+ retry?: () => Promise<void>;
4827
+ startNewConversation?: () => Promise<void>;
4828
+ defaultRenderer(): HTMLElement;
4829
+ };
4830
+ /**
4831
+ * Context for `renderHistoryOpenError` (the transcript-level surface shown
4832
+ * when opening a conversation from the Messages list fails). `retry` and
4833
+ * `back` are the only exits: both route through the token-guarded open flow,
4834
+ * so custom DOM must not fetch on its own. `back` is present only when the
4835
+ * Messages surface is available to return to.
4836
+ */
4837
+ type AgentWidgetRenderHistoryOpenErrorContext = {
4838
+ conversationId: string;
4839
+ config: AgentWidgetConfig;
4840
+ /** Resolved shell copy the default surface renders. */
4841
+ copy: {
4842
+ title: string;
4843
+ retryLabel: string;
4844
+ backLabel: string;
4845
+ };
4846
+ /** Re-runs the open through Persona's token-guarded flow. */
4847
+ retry: () => void;
4848
+ /** Returns to the Messages list. Absent when history is unavailable. */
4849
+ back?: () => void;
4850
+ defaultRenderer(): HTMLElement;
4851
+ };
3769
4852
  type SSEEventRecord = {
3770
4853
  id: string;
3771
4854
  type: string;
@@ -4238,6 +5321,24 @@ type AgentWidgetLauncherTeaserConfig = {
4238
5321
  */
4239
5322
  dismissLabel?: string;
4240
5323
  };
5324
+ /**
5325
+ * Timing for the portaled icon-control tooltip (header, composer, rail).
5326
+ * Keyboard focus always opens immediately. Hover waits `delayMs` unless
5327
+ * another tooltip closed within `skipDelayMs` (toolbar scan).
5328
+ */
5329
+ type AgentWidgetTooltipConfig = {
5330
+ /**
5331
+ * Milliseconds to wait on hover before the first tooltip appears.
5332
+ * `0` restores the previous instant-open behavior.
5333
+ * @default 200
5334
+ */
5335
+ delayMs?: number;
5336
+ /**
5337
+ * After a tooltip closes, later hovers in this window skip `delayMs`.
5338
+ * @default 300
5339
+ */
5340
+ skipDelayMs?: number;
5341
+ };
4241
5342
  type AgentWidgetSendButtonConfig = {
4242
5343
  borderWidth?: string;
4243
5344
  borderColor?: string;
@@ -5244,6 +6345,21 @@ type ClientSession = {
5244
6345
  name: string;
5245
6346
  description: string | null;
5246
6347
  };
6348
+ /**
6349
+ * Active conversation record for this session. Optional only for rolling-deploy
6350
+ * compatibility with servers that predate the visitor history contract.
6351
+ */
6352
+ conversationId?: string;
6353
+ /**
6354
+ * Canonical resolved chat target (flow or agent). Normalized from the response
6355
+ * `targetId`, falling back to `flow.id` during rolling deployment. History code
6356
+ * reads this, never widget config.
6357
+ */
6358
+ targetId?: string;
6359
+ /** Opaque change token; differs whenever the conversation transcript mutated. */
6360
+ conversationRevision?: string;
6361
+ /** Visitor grant backing history. `token` appears only at mint. */
6362
+ visitor?: ClientVisitorGrant;
5247
6363
  /** Configuration from the server */
5248
6364
  config: {
5249
6365
  welcomeMessage: string | null;
@@ -5251,6 +6367,43 @@ type ClientSession = {
5251
6367
  theme: Record<string, unknown> | null;
5252
6368
  };
5253
6369
  };
6370
+ /**
6371
+ * Visitor credential and identity acknowledgement returned by /v1/client/init.
6372
+ * `expiresAt` stays the wire string: it is a server-slid idle window the widget
6373
+ * never evaluates locally.
6374
+ */
6375
+ type ClientVisitorGrant = {
6376
+ id: string;
6377
+ /** Replacement secret. Present only at mint; persist it before anything else. */
6378
+ token?: string;
6379
+ expiresAt: string;
6380
+ endUserId: string | null;
6381
+ /** Server acknowledgement of the supplied identity proof. Status metadata only. */
6382
+ identityStatus?: "not_provided" | "admitted" | "ignored";
6383
+ };
6384
+ /**
6385
+ * One conversation row, normalized at the Runtype boundary. The deprecated wire
6386
+ * `flowId` alias never escapes that boundary: history code reads `targetId`.
6387
+ */
6388
+ type HistoryConversationSummary = {
6389
+ id: string;
6390
+ /** Server-generated; rendered verbatim, never derived locally. */
6391
+ title: string;
6392
+ /** Resolved chat target (flow or agent); `null` when the server omits it. */
6393
+ targetId: string | null;
6394
+ /** Server-produced plain-text preview; `null` when unavailable. */
6395
+ preview: string | null;
6396
+ messageCount: number;
6397
+ createdAt: string;
6398
+ updatedAt: string;
6399
+ /** Visitor-pinned flag. Absent when the provider has no update capability. */
6400
+ starred?: boolean;
6401
+ };
6402
+ /** Visitor-editable conversation metadata. Absent fields are left unchanged. */
6403
+ type HistoryConversationPatch = {
6404
+ title?: string;
6405
+ starred?: boolean;
6406
+ };
5254
6407
  /** Icon button in the header title row (minimal layout). */
5255
6408
  type AgentWidgetHeaderTrailingAction = {
5256
6409
  id: string;
@@ -5269,6 +6422,13 @@ type AgentWidgetHeaderTrailingAction = {
5269
6422
  destructive?: boolean;
5270
6423
  dividerBefore?: boolean;
5271
6424
  }>;
6425
+ /**
6426
+ * Keyboard shortcut that activates this action, e.g. `"mod+shift+h"` ("mod"
6427
+ * is Command on Apple platforms, Control elsewhere). Fires only while focus
6428
+ * is inside the widget, and also drives the button's tooltip hint chip and
6429
+ * its `aria-keyshortcuts`.
6430
+ */
6431
+ shortcut?: string;
5272
6432
  };
5273
6433
  /**
5274
6434
  * Context provided to header render functions
@@ -5312,6 +6472,15 @@ type AgentWidgetHeaderLayoutConfig = {
5312
6472
  showIcon?: boolean;
5313
6473
  /** Show/hide the title */
5314
6474
  showTitle?: boolean;
6475
+ /**
6476
+ * What the header title (or `titleMenu` label) displays. `"static"`
6477
+ * (default) always shows `launcher.title`. `"conversation"` shows the active
6478
+ * conversation's title — the Claude-style pairing for a `titleMenu` holding
6479
+ * conversation actions — falling back to `launcher.title` while no titled
6480
+ * conversation is open (fresh chat, cleared history, or before the history
6481
+ * view has loaded titles). Requires `features.history` for titles to exist.
6482
+ */
6483
+ titleSource?: "static" | "conversation";
5315
6484
  /** Show/hide the subtitle */
5316
6485
  showSubtitle?: boolean;
5317
6486
  /** Show/hide the close button */
@@ -5362,8 +6531,16 @@ type AgentWidgetHeaderLayoutConfig = {
5362
6531
  destructive?: boolean;
5363
6532
  dividerBefore?: boolean;
5364
6533
  }>;
5365
- /** Called when a menu item is selected. */
5366
- onSelect: (id: string) => void;
6534
+ /**
6535
+ * Called when a menu item is selected. Returning `false` (sync or via
6536
+ * promise) falls through to the widget built-ins, mirroring the artifact
6537
+ * copy-menu contract: id `star` toggles the active conversation's star and
6538
+ * id `delete` runs the shell's confirm-then-delete on it (both require
6539
+ * `features.history` and, for star, a provider with the update
6540
+ * capability). `rename` has no built-in: hosts own the rename UI and call
6541
+ * `renameConversation()`.
6542
+ */
6543
+ onSelect: (id: string) => void | boolean | Promise<void | boolean>;
5367
6544
  /** Hover pill style. */
5368
6545
  hover?: {
5369
6546
  background?: string;
@@ -5934,15 +7111,20 @@ type LoadingIndicatorRenderContext = {
5934
7111
  */
5935
7112
  config: AgentWidgetConfig;
5936
7113
  /**
5937
- * Current streaming state (always true when indicator is shown)
7114
+ * Current streaming state. Always true for 'inline' and 'standalone';
7115
+ * false for 'conversation-open' (a history fetch, not a stream).
5938
7116
  */
5939
7117
  streaming: boolean;
5940
7118
  /**
5941
7119
  * Location where the indicator is rendered:
5942
7120
  * - 'inline': Inside a streaming assistant message bubble (when content is empty)
5943
7121
  * - 'standalone': Separate bubble while waiting for stream to start
7122
+ * - 'conversation-open': Transcript stand-in while a conversation opened
7123
+ * from the Messages list is being fetched. The returned element is mounted
7124
+ * inside Persona's centered transcript column, which keeps the status
7125
+ * role, announcement label, and composer gating.
5944
7126
  */
5945
- location: 'inline' | 'standalone';
7127
+ location: 'inline' | 'standalone' | 'conversation-open';
5946
7128
  /**
5947
7129
  * Function to render the default 3-dot bouncing indicator.
5948
7130
  * Call this if you want to use the default for certain cases.
@@ -6241,6 +7423,28 @@ type AgentWidgetConfig = {
6241
7423
  * ```
6242
7424
  */
6243
7425
  setStoredSessionId?: (sessionId: string) => void;
7426
+ /**
7427
+ * Called immediately before any cross-device history request and before a
7428
+ * conversationId resume of a conversation discovered on another device.
7429
+ * Return a fresh end-user access token (rt_eu_… / JWT). Null uses exact-browser
7430
+ * scope only for a never-bound visitor; a previously bound visitor fails closed
7431
+ * until resetHistoryIdentity() runs. Never cached by the widget.
7432
+ */
7433
+ getIdentityProof?: () => string | null | Promise<string | null>;
7434
+ /**
7435
+ * Read the persisted active conversation id (client token mode only).
7436
+ * Called only after the internal stored-state bootstrap gate resolves.
7437
+ */
7438
+ getStoredConversationId?: () => string | null;
7439
+ /** Persist the active conversation id so a later boot reopens the same record. */
7440
+ setStoredConversationId?: (conversationId: string) => void;
7441
+ /** Drop the persisted active conversation id (new conversation, deletion, reset). */
7442
+ clearStoredConversationId?: () => void;
7443
+ /**
7444
+ * Drop the persisted session id. Dedicated clear seam: it avoids widening
7445
+ * `setStoredSessionId` and its existing host call sites.
7446
+ */
7447
+ clearStoredSessionId?: () => void;
6244
7448
  /**
6245
7449
  * Static headers to include with each request.
6246
7450
  * For dynamic headers (e.g., auth tokens), use `getHeaders` instead.
@@ -6320,6 +7524,12 @@ type AgentWidgetConfig = {
6320
7524
  * @default false
6321
7525
  */
6322
7526
  autoFocusInput?: boolean;
7527
+ /**
7528
+ * Hover timing for the portaled control tooltip. Keyboard focus is
7529
+ * always immediate. Unset keys keep the ChatGPT/Claude defaults
7530
+ * (`delayMs: 200`, `skipDelayMs: 300`).
7531
+ */
7532
+ tooltip?: AgentWidgetTooltipConfig;
6323
7533
  launcher?: AgentWidgetLauncherConfig;
6324
7534
  initialMessages?: AgentWidgetMessage[];
6325
7535
  /**
@@ -7378,7 +8588,7 @@ declare const MOCK_WORKSPACE_CONTENT = "\n <div class=\"preview-workspace-con
7378
8588
  * using the exported templates and shell CSS utilities.
7379
8589
  */
7380
8590
  declare function buildSrcdoc(mountId: string, shellMode: 'light' | 'dark', docked: boolean, widgetCssPath: string): string;
7381
- type PreviewScene = 'home' | 'conversation' | 'follow-ups' | 'minimized' | 'artifact';
8591
+ type PreviewScene = 'home' | 'conversation' | 'follow-ups' | 'minimized' | 'artifact' | 'messages';
7382
8592
  type PreviewTranscriptEntryPreset = 'user-message' | 'assistant-message' | 'assistant-code-block' | 'assistant-markdown-table' | 'assistant-image' | 'reasoning-streaming' | 'reasoning-complete' | 'tool-running' | 'tool-complete' | 'approval-request';
7383
8593
  declare function getPreviewTranscriptPresetLabel(preset: PreviewTranscriptEntryPreset): string;
7384
8594
  declare function createPreviewTranscriptEntry(preset: PreviewTranscriptEntryPreset, index?: number): AgentWidgetMessage;
@@ -7692,6 +8902,8 @@ interface ContrastPair {
7692
8902
  key: string;
7693
8903
  label: string;
7694
8904
  fg: string;
8905
+ /** Tried in order when `fg` is unset; suggestions still write to `fg`. */
8906
+ fgFallbacks?: string[];
7695
8907
  bg: string;
7696
8908
  }
7697
8909
  declare const CONTRAST_PAIRS: ContrastPair[];