@runtypelabs/persona 4.17.1 → 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 (158) hide show
  1. package/dist/chunk-3I2S3I5P.js +1 -0
  2. package/dist/chunk-76IELU7F.js +1 -0
  3. package/dist/chunk-EFJBUH5F.js +1 -0
  4. package/dist/chunk-PDPVORUF.js +1 -0
  5. package/dist/chunk-Q735PSZL.js +1 -0
  6. package/dist/chunk-VK6JOIYJ.js +1 -0
  7. package/dist/codegen.cjs +4 -4
  8. package/dist/codegen.js +4 -4
  9. package/dist/{context-mentions-BTSTIBFC.js → context-mentions-MJL6S6P2.js} +1 -1
  10. package/dist/context-mentions.cjs +9 -8
  11. package/dist/context-mentions.d.cts +1212 -14
  12. package/dist/context-mentions.d.ts +1212 -14
  13. package/dist/context-mentions.js +9 -8
  14. package/dist/event-stream-view-4EZ7BGFK.js +1 -0
  15. package/dist/event-stream-view.cjs +129 -0
  16. package/dist/event-stream-view.d.cts +8384 -0
  17. package/dist/event-stream-view.d.ts +8384 -0
  18. package/dist/event-stream-view.js +129 -0
  19. package/dist/history-view-BD6OXLNA.js +898 -0
  20. package/dist/history-view.cjs +898 -0
  21. package/dist/history-view.d.cts +1461 -0
  22. package/dist/history-view.d.ts +1461 -0
  23. package/dist/history-view.js +898 -0
  24. package/dist/index.cjs +77 -77
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +1987 -17
  27. package/dist/index.d.ts +1987 -17
  28. package/dist/index.global.js +67 -66
  29. package/dist/index.global.js.map +1 -1
  30. package/dist/index.js +77 -77
  31. package/dist/index.js.map +1 -1
  32. package/dist/launcher.global.js +5 -4
  33. package/dist/launcher.global.js.map +1 -1
  34. package/dist/plugin-kit.cjs +1 -1
  35. package/dist/plugin-kit.d.cts +0 -8
  36. package/dist/plugin-kit.d.ts +0 -8
  37. package/dist/plugin-kit.js +1 -1
  38. package/dist/smart-dom-reader.d.cts +1212 -14
  39. package/dist/smart-dom-reader.d.ts +1212 -14
  40. package/dist/theme-editor-preview.cjs +970 -73
  41. package/dist/theme-editor-preview.d.cts +1331 -15
  42. package/dist/theme-editor-preview.d.ts +1331 -15
  43. package/dist/theme-editor-preview.js +81 -81
  44. package/dist/theme-editor.cjs +7 -7
  45. package/dist/theme-editor.d.cts +1215 -15
  46. package/dist/theme-editor.d.ts +1215 -15
  47. package/dist/theme-editor.js +9 -9
  48. package/dist/theme-reference.cjs +1 -1
  49. package/dist/theme-reference.d.cts +226 -7
  50. package/dist/theme-reference.d.ts +226 -7
  51. package/dist/theme-reference.js +1 -1
  52. package/dist/widget.css +1 -1
  53. package/package.json +16 -4
  54. package/src/client-history-rest.test.ts +1034 -0
  55. package/src/client-visitor-history.test.ts +596 -0
  56. package/src/client.ts +1040 -24
  57. package/src/components/artifact-inline.ts +8 -1
  58. package/src/components/artifact-pane.test.ts +278 -1
  59. package/src/components/artifact-pane.ts +135 -67
  60. package/src/components/artifact-preview.test.ts +14 -1
  61. package/src/components/artifact-preview.ts +9 -0
  62. package/src/components/header-builder.ts +3 -0
  63. package/src/components/header-layouts.test.ts +171 -7
  64. package/src/components/header-layouts.ts +83 -53
  65. package/src/components/header-parts.test.ts +154 -1
  66. package/src/components/header-parts.ts +266 -138
  67. package/src/components/history-confirm-dialog.ts +177 -0
  68. package/src/components/history-shell-copy.ts +99 -0
  69. package/src/components/history-view/announcer.ts +40 -0
  70. package/src/components/history-view/copy.ts +105 -0
  71. package/src/components/history-view/css.ts +1078 -0
  72. package/src/components/history-view/grouping.test.ts +142 -0
  73. package/src/components/history-view/grouping.ts +142 -0
  74. package/src/components/history-view/icons.ts +73 -0
  75. package/src/components/history-view/rows.ts +341 -0
  76. package/src/components/history-view/state.ts +309 -0
  77. package/src/components/history-view.test.ts +2660 -0
  78. package/src/components/history-view.ts +1891 -0
  79. package/src/components/launcher-surface.test.ts +133 -0
  80. package/src/components/launcher.test.ts +18 -0
  81. package/src/components/launcher.ts +7 -7
  82. package/src/components/panel.ts +17 -7
  83. package/src/components/welcome.ts +72 -2
  84. package/src/defaults.ts +36 -3
  85. package/src/event-stream-view-bundle.test.ts +69 -0
  86. package/src/event-stream-view-entry.ts +19 -0
  87. package/src/event-stream-view-loader.ts +31 -0
  88. package/src/event-stream-view.ts +19 -0
  89. package/src/generated/runtype-openapi-contract.ts +1 -0
  90. package/src/history-render.ts +325 -0
  91. package/src/history-view-bundle.test.ts +78 -0
  92. package/src/history-view-entry.ts +41 -0
  93. package/src/history-view-loader.test.ts +30 -0
  94. package/src/history-view-loader.ts +32 -0
  95. package/src/history-view.ts +28 -0
  96. package/src/index-core.ts +50 -2
  97. package/src/index-global.ts +55 -0
  98. package/src/internal/demo-history-provider.test.ts +402 -0
  99. package/src/internal/demo-history-provider.ts +689 -0
  100. package/src/internal/history-provider-registry.ts +25 -0
  101. package/src/internal/history-provider.ts +150 -0
  102. package/src/internal/runtype-history-provider.test.ts +313 -0
  103. package/src/internal/runtype-history-provider.ts +240 -0
  104. package/src/plugin-kit.test.ts +16 -0
  105. package/src/plugin-kit.ts +13 -5
  106. package/src/plugins/types.ts +177 -1
  107. package/src/session-history.test.ts +1397 -0
  108. package/src/session.ts +1200 -26
  109. package/src/styles/widget-styles.test.ts +133 -0
  110. package/src/styles/widget.css +227 -8
  111. package/src/theme-editor/preview-utils.test.ts +19 -0
  112. package/src/theme-editor/preview-utils.ts +15 -1
  113. package/src/theme-editor/preview.ts +7 -1
  114. package/src/theme-editor/role-mappings.ts +4 -1
  115. package/src/theme-editor/sections.test.ts +168 -1
  116. package/src/theme-editor/sections.ts +136 -7
  117. package/src/theme-editor/webmcp/summary.ts +16 -2
  118. package/src/theme-reference.ts +20 -6
  119. package/src/types/theme.ts +213 -7
  120. package/src/types.ts +927 -7
  121. package/src/ui.artifact-rail-resize.test.ts +235 -0
  122. package/src/ui.attachments-drop.test.ts +1 -0
  123. package/src/ui.header-update-stability.test.ts +2 -2
  124. package/src/ui.history-chunk.test.ts +72 -0
  125. package/src/ui.history-config-provider.test.ts +318 -0
  126. package/src/ui.history-controller.test.ts +711 -0
  127. package/src/ui.history-lifecycle.test.ts +456 -0
  128. package/src/ui.history-render-hooks.test.ts +904 -0
  129. package/src/ui.history-shell.test.ts +1887 -0
  130. package/src/ui.rail-overlay.test.ts +573 -0
  131. package/src/ui.rail-resize.test.ts +284 -0
  132. package/src/ui.rebuild-composer.test.ts +21 -0
  133. package/src/ui.render-welcome.test.ts +42 -0
  134. package/src/ui.shortcuts.test.ts +166 -0
  135. package/src/ui.ts +3071 -240
  136. package/src/utils/__fixtures__/client-conversation-history-wire.json +108 -0
  137. package/src/utils/artifact-file.ts +15 -0
  138. package/src/utils/artifact-gate.test.ts +4 -0
  139. package/src/utils/artifact-gate.ts +13 -17
  140. package/src/utils/artifact-resize.test.ts +28 -0
  141. package/src/utils/artifact-resize.ts +9 -2
  142. package/src/utils/buttons.ts +188 -1
  143. package/src/utils/config-merge.test.ts +91 -0
  144. package/src/utils/dropdown.ts +10 -1
  145. package/src/utils/history-messages.test.ts +284 -0
  146. package/src/utils/history-messages.ts +284 -0
  147. package/src/utils/icons.ts +3 -0
  148. package/src/utils/shortcuts.test.ts +288 -0
  149. package/src/utils/shortcuts.ts +221 -0
  150. package/src/utils/theme.test.ts +501 -4
  151. package/src/utils/theme.ts +42 -3
  152. package/src/utils/tokens.ts +153 -15
  153. package/src/utils/tooltip-timing.ts +4 -0
  154. package/src/utils/tooltip.test.ts +249 -7
  155. package/src/utils/tooltip.ts +146 -4
  156. package/src/utils/visitor-store.test.ts +425 -0
  157. package/src/utils/visitor-store.ts +337 -0
  158. package/dist/chunk-QJ4LV2KW.js +0 -1
@@ -21,6 +21,8 @@ interface AgentWidgetPluginStorage {
21
21
  remove: (key: string) => void;
22
22
  }
23
23
 
24
+ type ShortcutScope = "widget" | "page";
25
+
24
26
  type AgentWidgetTransformSuggestionsContext = {
25
27
  /**
26
28
  * Fresh copy of the suggestions entering this plugin, already normalized:
@@ -69,6 +71,37 @@ type AgentWidgetRenderWelcomeContext = {
69
71
  /** Teardown for this render; runs before the next one and on destroy. */
70
72
  onCleanup: (fn: () => void) => void;
71
73
  };
74
+ /** Context for one `railSections` entry. Frozen per invocation. */
75
+ type AgentWidgetRailSectionContext = {
76
+ /** Current rail width state. The section re-renders whenever this flips. */
77
+ collapsed: boolean;
78
+ presentation: ResolvedHistoryPresentation;
79
+ /** The same frozen action path the default rows and `renderHistoryView` use. */
80
+ actions: AgentWidgetHistoryRenderActions;
81
+ };
82
+ /** A plugin-contributed navigation section in the history rail. */
83
+ type AgentWidgetRailSection = {
84
+ /** Stable identity, stamped as `data-persona-rail-section`. */
85
+ id: string;
86
+ /** Default `"above-conversations"`. */
87
+ placement?: AgentWidgetHistoryRailSection["placement"];
88
+ /** Optional heading, styled like a conversation date-group heading. */
89
+ title?: string;
90
+ /** Section body. Null renders nothing for the current state. */
91
+ render: (context: AgentWidgetRailSectionContext) => Element | null;
92
+ };
93
+ /** A plugin-contributed keyboard shortcut, bound per widget instance. */
94
+ type AgentWidgetPluginShortcut = {
95
+ /** Stable identity, used in duplicate/throw warnings. */
96
+ id: string;
97
+ /** e.g. `"mod+b"`. "mod" is Command on Apple platforms, Control elsewhere. */
98
+ combo: string;
99
+ /** Default `"widget"`: fires only from inside the widget mount. */
100
+ scope?: ShortcutScope;
101
+ /** Returning false skips the binding for this keypress. */
102
+ when?: () => boolean;
103
+ run: () => void;
104
+ };
72
105
  type AgentWidgetSuggestionSelectContext = {
73
106
  suggestion: AgentWidgetResolvedSuggestion;
74
107
  surface: AgentWidgetSuggestionSurface;
@@ -339,6 +372,10 @@ interface AgentWidgetPlugin {
339
372
  * Custom renderer for loading indicator
340
373
  * Return null to use default renderer (or config-based renderer)
341
374
  *
375
+ * Covers the streaming indicator ('inline', 'standalone') and the transcript
376
+ * skeleton shown while a conversation opened from the Messages list loads
377
+ * ('conversation-open').
378
+ *
342
379
  * @example
343
380
  * ```typescript
344
381
  * renderLoadingIndicator: ({ location, defaultRenderer }) => {
@@ -390,6 +427,118 @@ interface AgentWidgetPlugin {
390
427
  * Return null to use default renderer.
391
428
  */
392
429
  renderEventStreamPayload?: (context: EventStreamPayloadRenderContext) => HTMLElement | null;
430
+ /**
431
+ * Replace the complete history ("Messages") navigation contents in either
432
+ * host. Plugins run by priority and the first non-null element wins; null
433
+ * falls through to the default full view, which then applies the first
434
+ * non-null header/row/state hook at each slot.
435
+ *
436
+ * Calling `defaultRenderer()` bypasses this hook only: the default view is
437
+ * built and its lower-level slots still arbitrate, including this plugin's.
438
+ * Return it (or an element containing it) to compose rather than replace.
439
+ *
440
+ * The hook replaces contents, not orchestration. Persona keeps placement,
441
+ * open/close, responsive rail <-> panel movement, inertness, Escape, the
442
+ * confirmation dialogs, live announcements, and focus fallback. Fetch nothing
443
+ * directly: `actions.refresh()` is the only way to reload the list.
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * renderHistoryView: ({ conversations, actions, presentation, onCleanup }) => {
448
+ * const rail = document.createElement("nav");
449
+ * rail.dataset.presentation = presentation;
450
+ * for (const conversation of conversations) {
451
+ * const row = document.createElement("button");
452
+ * row.textContent = conversation.title;
453
+ * row.addEventListener("click", () => void actions.openConversation(conversation.id));
454
+ * rail.appendChild(row);
455
+ * }
456
+ * const timer = setInterval(() => void actions.refresh(), 60_000);
457
+ * onCleanup(() => clearInterval(timer));
458
+ * return rail;
459
+ * }
460
+ * ```
461
+ */
462
+ renderHistoryView?: (context: AgentWidgetRenderHistoryViewContext) => HTMLElement | null;
463
+ /**
464
+ * Replace the standard Messages header while retaining its list/state UI.
465
+ * Return null to use the default top bar. A custom header may not remove the
466
+ * keyboard close path or falsify the resolved open state.
467
+ */
468
+ renderHistoryHeader?: (context: AgentWidgetRenderHistoryHeaderContext) => HTMLElement | null;
469
+ /**
470
+ * Replace one conversation row while retaining standard paging/grouping.
471
+ * Return null to use the default row.
472
+ */
473
+ renderHistoryConversation?: (context: AgentWidgetRenderHistoryConversationContext) => HTMLElement | null;
474
+ /**
475
+ * Replace loading, empty, error, authentication, rate-limit, or recovery
476
+ * content in the list region. Return null to use the default block.
477
+ */
478
+ renderHistoryState?: (context: AgentWidgetRenderHistoryStateContext) => HTMLElement | null;
479
+ /**
480
+ * Replace the transcript-level error surface shown when opening a
481
+ * conversation from the Messages list fails. Plugins run by priority and
482
+ * the first non-null element wins; null falls through to the default block.
483
+ *
484
+ * Persona keeps the centered transcript column, the alert role, and the
485
+ * composer gate around the returned element. `retry`/`back` are the only
486
+ * exits: both route through the token-guarded open flow, so do not fetch
487
+ * directly. `back` is absent when there is no Messages surface to return
488
+ * to; do not render a back affordance without it.
489
+ */
490
+ renderHistoryOpenError?: (context: AgentWidgetRenderHistoryOpenErrorContext) => HTMLElement | null;
491
+ /**
492
+ * Contribute navigation sections to the history rail, stacked around the
493
+ * conversation list in `placement` order. Rail only: the panel presentation
494
+ * renders none of them, and `features.history.rail.sections` (config) comes
495
+ * first inside each bucket, then plugins in plugin order.
496
+ *
497
+ * `render` is re-invoked with the new `collapsed` value whenever the rail
498
+ * collapses or expands, and its return replaces the previous content;
499
+ * returning null renders nothing for that state. A throwing `render` warns
500
+ * once and drops that section only, leaving the rest of the rail alone. An id
501
+ * a config section already owns is dropped with a warning.
502
+ *
503
+ * Keep heavy UI in the host bundle: `render` may return a skeleton and
504
+ * hydrate it after the host's own dynamic import resolves.
505
+ *
506
+ * @example
507
+ * ```typescript
508
+ * railSections: [
509
+ * {
510
+ * id: "pinned",
511
+ * title: "Pinned",
512
+ * render: ({ collapsed, actions }) => {
513
+ * if (collapsed) return null;
514
+ * const list = document.createElement("div");
515
+ * const row = document.createElement("button");
516
+ * row.textContent = "Weekly report";
517
+ * row.addEventListener("click", () => void actions.openConversation("c1"));
518
+ * list.appendChild(row);
519
+ * return list;
520
+ * }
521
+ * }
522
+ * ]
523
+ * ```
524
+ */
525
+ railSections?: AgentWidgetRailSection[];
526
+ /**
527
+ * Keyboard shortcuts registered for the lifetime of each widget instance the
528
+ * plugin is active in, and unregistered on its teardown. `combo` is written
529
+ * as `"mod+b"` / `"mod+shift+k"`, where "mod" is Command on Apple platforms
530
+ * and Control elsewhere. `scope` defaults to `"widget"` (only while focus is
531
+ * inside the mount); `when` returning false skips the keypress. A combo
532
+ * another binding already owns warns and is ignored, first registration wins.
533
+ *
534
+ * @example
535
+ * ```typescript
536
+ * shortcuts: [
537
+ * { id: "open-inbox", combo: "mod+shift+i", run: () => openInbox() }
538
+ * ]
539
+ * ```
540
+ */
541
+ shortcuts?: AgentWidgetPluginShortcut[];
393
542
  /**
394
543
  * Called when plugin is registered
395
544
  */
@@ -548,6 +697,10 @@ interface SemanticTokens {
548
697
  }
549
698
  interface ComponentTokenSet {
550
699
  background?: TokenReference<'color'>;
700
+ /**
701
+ * Text and glyph color on `background`. `HeaderTokens` also derives its
702
+ * unset text, icon, and border colors from this pair.
703
+ */
551
704
  foreground?: TokenReference<'color'>;
552
705
  border?: TokenReference<'color'>;
553
706
  borderRadius?: TokenReference<'radius'>;
@@ -575,6 +728,15 @@ interface LauncherTokens extends ComponentTokenSet {
575
728
  size: string;
576
729
  iconSize: string;
577
730
  shadow: TokenReference<'shadow'>;
731
+ /**
732
+ * Stroke weight of the launcher glyphs, the agent icon and the
733
+ * call-to-action arrow alike. Unitless, and must be a STRING (`"1.75"`,
734
+ * never `1.75`: the token resolver silently skips numbers). Applied as CSS,
735
+ * so it beats the attribute the icons render with. Inert for emoji / image
736
+ * launchers, which have no svg.
737
+ * @default "1.5", matching the header's controlStrokeWidth
738
+ */
739
+ iconStrokeWidth?: string;
578
740
  }
579
741
  interface PanelTokens extends ComponentTokenSet {
580
742
  width: string;
@@ -595,28 +757,212 @@ interface TextStyleTokens {
595
757
  letterSpacing?: string;
596
758
  color?: TokenReference<'color'>;
597
759
  }
760
+ /**
761
+ * Header band tokens. `background` plus `foreground` (inherited from
762
+ * `ComponentTokenSet`) is the pair that colors the band: `foreground` anchors
763
+ * the header text, and every text, action-icon, and border color the theme
764
+ * leaves unset derives from the pair. Derivation only fills unset keys, so an
765
+ * explicit key always wins, and `iconBackground` / `iconForeground` (the avatar
766
+ * tile) keep their own defaults rather than deriving.
767
+ */
598
768
  interface HeaderTokens extends ComponentTokenSet {
599
769
  background: TokenReference<'color'>;
600
- border: TokenReference<'color'>;
770
+ /**
771
+ * Hairline under the header. Unset, it derives as
772
+ * `color-mix(in srgb, foreground 14%, background)`, then the divider color.
773
+ */
774
+ border?: TokenReference<'color'>;
601
775
  borderRadius: TokenReference<'radius'>;
602
776
  /** Background of the rounded avatar tile next to the title (Lucide / emoji / image). */
603
777
  iconBackground: TokenReference<'color'>;
604
778
  /** Foreground (glyph stroke or emoji text) on the header avatar tile. */
605
779
  iconForeground: TokenReference<'color'>;
606
- /** Legacy alias of `title.color`; `title.color` wins when both are set. */
607
- titleForeground: TokenReference<'color'>;
608
- /** Legacy alias of `subtitle.color`; `subtitle.color` wins when both are set. */
609
- subtitleForeground: TokenReference<'color'>;
780
+ /**
781
+ * Legacy alias of `title.color`; `title.color` wins when both are set.
782
+ * Unset, the title takes `foreground`, then the primary color.
783
+ */
784
+ titleForeground?: TokenReference<'color'>;
785
+ /**
786
+ * Legacy alias of `subtitle.color`; `subtitle.color` wins when both are set.
787
+ * Unset, the subtitle takes `color-mix(in srgb, foreground 72%, background)`,
788
+ * then the muted text color.
789
+ */
790
+ subtitleForeground?: TokenReference<'color'>;
610
791
  /** Header title typography (next to the icon, or minimal layout title). */
611
792
  title?: TextStyleTokens;
612
793
  /** Header subtitle typography, for the line under the title. */
613
794
  subtitle?: TextStyleTokens;
614
- /** Default color for clear / close icon buttons when launcher overrides are unset. */
615
- actionIconForeground: TokenReference<'color'>;
795
+ /**
796
+ * Default color for clear / close icon buttons when launcher overrides are
797
+ * unset. Itself unset, it takes the same
798
+ * `color-mix(in srgb, foreground 72%, background)` as the subtitle, then the
799
+ * muted text color.
800
+ */
801
+ actionIconForeground?: TokenReference<'color'>;
802
+ /**
803
+ * Edge of every header icon button: close, clear chat, `trailingActions`, and
804
+ * the Messages toggle. Per-control config keys (`launcher.closeButtonSize`,
805
+ * `launcher.clearChat.size`) still win. Coarse pointers floor the hit area at
806
+ * 40px regardless. @default "32px"
807
+ */
808
+ controlSize?: string;
809
+ /** Glyph box inside a header control. @default "20px" */
810
+ controlIconSize?: string;
811
+ /**
812
+ * Stroke weight of the glyph inside a header control. Unitless, as an SVG
813
+ * stroke-width (e.g. `"1.75"`). Sparse-viewBox glyphs (the close X) render
814
+ * at 0.7 of it so their heavier visible weight still matches a dense
815
+ * sibling. @default "1.5"
816
+ */
817
+ controlStrokeWidth?: string;
616
818
  /** Box-shadow on the header (e.g., a fade shadow to replace the default border). */
617
819
  shadow?: string;
618
820
  /** Override the header bottom border (e.g., `none`). */
619
821
  borderBottom?: string;
822
+ /**
823
+ * Floor for the header strip's height (e.g. `"56px"`). Pin it together with
824
+ * `components.history.railHeader.minHeight` so the Messages rail header and
825
+ * the conversation header read as one continuous band.
826
+ */
827
+ minHeight?: string;
828
+ }
829
+ /** Messages (conversation history) surfaces. */
830
+ interface HistoryTokens {
831
+ /**
832
+ * The Messages rail's own top strip, which runs beside the widget header
833
+ * when `features.history.presentation` resolves to `rail`.
834
+ */
835
+ railHeader?: {
836
+ /** Strip background. Defaults to the rail's surface color. */
837
+ background?: TokenReference<'color'>;
838
+ /** Full border-bottom shorthand (raw CSS, e.g. `"1px solid #e5e7eb"`). @default "0" */
839
+ border?: string;
840
+ /** Strip height floor. Defaults to `components.header.minHeight`, then 56px. */
841
+ minHeight?: string;
842
+ /**
843
+ * The strip's view title ("Messages"). 14px/600 in the text color by
844
+ * default; set the type keys to restyle it.
845
+ */
846
+ title?: TextStyleTokens;
847
+ };
848
+ /**
849
+ * The "Conversations" heading over the list block. Visible in rail
850
+ * presentation only (the panel keeps it screen-reader-only). 14px/600 in
851
+ * the text color by default. Every key is pinned in the widget CSS, so
852
+ * host-page heading rules never restyle it.
853
+ */
854
+ listHeading?: TextStyleTokens;
855
+ /**
856
+ * The muted sub-headers inside the Messages surface: date groups ("Today",
857
+ * "Yesterday") and rail nav section titles (`features.history.rail.sections`
858
+ * `title`, e.g. "Workspace"). 13px/500 in the muted text color in the rail
859
+ * (the panel keeps date groups screen-reader-only). Every key is pinned in
860
+ * the widget CSS, so host-page heading rules never restyle them.
861
+ */
862
+ groupHeading?: TextStyleTokens;
863
+ /**
864
+ * The floating rail that a collapsed
865
+ * `features.history.rail.collapsedBehavior: "overlay"` opens on hover. It
866
+ * hangs below the trigger in the conversation header; its width and edge
867
+ * stay `features.history.rail` geometry, not tokens.
868
+ */
869
+ overlay?: {
870
+ /** Gap from the trigger, the docked edge, and the bottom. @default "8px" */
871
+ margin?: string;
872
+ /** Corner radius, on all four corners. @default "16px" */
873
+ borderRadius?: string;
874
+ /** Elevation over the conversation. @default "0 12px 40px rgba(0, 0, 0, 0.25)" */
875
+ shadow?: string;
876
+ /** Surface behind the rail. Defaults to the rail's own surface color. */
877
+ background?: TokenReference<'color'>;
878
+ };
879
+ /**
880
+ * Destructive action text (row Delete, "Delete all conversations").
881
+ * Defaults to `palette.colors.error.600` in light schemes and a lighter
882
+ * red in the built-in dark theme so the 14px labels keep AA contrast.
883
+ */
884
+ dangerForeground?: TokenReference<'color'>;
885
+ /**
886
+ * The delete/forget confirmation dialog the shell shows for destructive
887
+ * history actions. The danger pair is always emitted (`--persona-danger`
888
+ * / `--persona-danger-fg`); scrim and shadow keep the built-in look when
889
+ * unset.
890
+ */
891
+ confirm?: {
892
+ /**
893
+ * Destructive button fill. Defaults to `palette.colors.error.700` in
894
+ * light schemes and `error.600` in the built-in dark theme.
895
+ */
896
+ dangerBackground?: TokenReference<'color'>;
897
+ /** Destructive button label. @default "#ffffff" */
898
+ dangerForeground?: TokenReference<'color'>;
899
+ /** Overlay behind the dialog. @default "rgba(15, 23, 42, 0.45)" */
900
+ scrim?: TokenReference<'color'>;
901
+ /** Card elevation (raw CSS shadow). */
902
+ shadow?: string;
903
+ };
904
+ /** The per-row overflow menu in the Messages list (rail and panel). */
905
+ menu?: {
906
+ /**
907
+ * Menu surface. Defaults to the list surface lifted 8% toward white so
908
+ * the menu reads as elevated in dark schemes.
909
+ */
910
+ background?: TokenReference<'color'>;
911
+ /** Corner radius. @default "12px" */
912
+ borderRadius?: string;
913
+ };
914
+ /**
915
+ * Enter/exit motion of the Messages surface. Only the body slides; the bar
916
+ * is persistent chrome and never animates. Durations are milliseconds and 0
917
+ * disables that leg; `prefers-reduced-motion` always wins over these.
918
+ */
919
+ motion?: {
920
+ /** Entrance slide-and-fade duration: bare ms number, or a CSS time string. @default 180 */
921
+ enterDurationMs?: number | string;
922
+ /** Entrance easing. @default "cubic-bezier(0, 0, 0.2, 1)" */
923
+ enterEasing?: string;
924
+ /** Exit slide-and-fade duration: bare ms number, or a CSS time string. @default 160 */
925
+ exitDurationMs?: number | string;
926
+ /** Exit easing. @default "cubic-bezier(0.4, 0, 1, 1)" */
927
+ exitEasing?: string;
928
+ };
929
+ }
930
+ /**
931
+ * The portaled icon-control tooltip (header controls, composer buttons) and
932
+ * its trailing shortcut hint chip. Unset keys keep the built-in dark look.
933
+ */
934
+ interface TooltipTokens {
935
+ /** Bubble and arrow fill. @default "#111827" */
936
+ background?: TokenReference<'color'>;
937
+ /** Label color. @default "#ffffff" */
938
+ foreground?: TokenReference<'color'>;
939
+ /** Trailing shortcut hint color. @default "rgba(255, 255, 255, 0.55)" */
940
+ hintForeground?: TokenReference<'color'>;
941
+ /** Bubble corner radius. Defaults to `palette.radius.sm`. */
942
+ borderRadius?: TokenReference<'radius'>;
943
+ /** Label type size. @default "12px" */
944
+ fontSize?: string;
945
+ /** Bubble inset, full CSS shorthand. @default "6px 12px" */
946
+ padding?: TokenReference<'spacing'>;
947
+ /** Bubble box-shadow (token ref or raw CSS, e.g. `none`). */
948
+ shadow?: string;
949
+ /** Render the caret pointing at the control. @default true */
950
+ arrow?: boolean;
951
+ /** Wrap width. @default "min(320px, calc(100vw - 16px))" */
952
+ maxWidth?: string;
953
+ }
954
+ /**
955
+ * The hover-revealed action row under a message (copy, vote, read aloud).
956
+ * Unset keys inherit the shared ghost icon-button wash, which is already
957
+ * scheme-aware, so most themes never need this group.
958
+ */
959
+ interface MessageActionsTokens {
960
+ /** Hover fill. Defaults to `components.button.ghost.hoverBackground`. */
961
+ hoverBackground?: TokenReference<'color'>;
962
+ /** Hover icon color. Defaults to `semantic.colors.text`. */
963
+ hoverForeground?: TokenReference<'color'>;
964
+ /** Button corner radius. Defaults to `palette.radius.md`. */
965
+ borderRadius?: TokenReference<'radius'>;
620
966
  }
621
967
  interface MessageTokens {
622
968
  user: {
@@ -962,7 +1308,13 @@ interface ComponentTokens {
962
1308
  launcher: LauncherTokens;
963
1309
  panel: PanelTokens;
964
1310
  header: HeaderTokens;
1311
+ /** Messages rail chrome. */
1312
+ history?: HistoryTokens;
1313
+ /** Portaled icon-control tooltip and its shortcut hint chip. */
1314
+ tooltip?: TooltipTokens;
965
1315
  message: MessageTokens;
1316
+ /** Hover-revealed per-message action row (copy, vote, read aloud). */
1317
+ messageActions?: MessageActionsTokens;
966
1318
  /** Welcome / intro card shown above the message list. */
967
1319
  introCard?: IntroCardTokens;
968
1320
  /** Markdown surfaces (chat + artifact pane). */
@@ -1461,6 +1813,101 @@ type TargetResolver = (id: string) => {
1461
1813
  payload: Record<string, unknown>;
1462
1814
  };
1463
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
+
1464
1911
  /**
1465
1912
  * Curated registry of lucide icons available to `renderLucideIcon`.
1466
1913
  *
@@ -1545,6 +1992,7 @@ declare const LUCIDE_ICONS: {
1545
1992
  readonly "ellipsis-vertical": IconNode;
1546
1993
  readonly menu: IconNode;
1547
1994
  readonly house: IconNode;
1995
+ readonly "panel-left": IconNode;
1548
1996
  readonly plus: IconNode;
1549
1997
  readonly minus: IconNode;
1550
1998
  readonly pencil: IconNode;
@@ -2706,6 +3154,8 @@ type AgentWidgetArtifactsLayoutConfig = {
2706
3154
  documentToolbarToggleActiveBackground?: string;
2707
3155
  /** Active view/source toggle border color. Sets `--persona-artifact-doc-toggle-active-border`. */
2708
3156
  documentToolbarToggleActiveBorderColor?: string;
3157
+ /** Active view/source toggle icon color (defaults to `documentToolbarIconColor`). Sets `--persona-artifact-doc-toggle-active-color`. */
3158
+ documentToolbarToggleActiveColor?: string;
2709
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. */
2710
3160
  showExpandToggle?: boolean;
2711
3161
  /** Show the copy control in the `default` toolbar preset (the `document` preset always shows it). Default: false. */
@@ -2718,13 +3168,20 @@ type AgentWidgetArtifactsLayoutConfig = {
2718
3168
  /** Tab fade width (CSS length). @default 24px */
2719
3169
  tabFadeSize?: string;
2720
3170
  /**
2721
- * Invoked when the document toolbar Refresh control is used (before the pane re-renders).
2722
- * 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.
2723
3177
  */
2724
3178
  onDocumentToolbarRefresh?: () => void | Promise<void>;
2725
3179
  /**
2726
3180
  * Optional copy dropdown entries (shown when `documentToolbarShowCopyChevron` is true and this array is non-empty).
2727
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.
2728
3185
  */
2729
3186
  documentToolbarCopyMenuItems?: Array<{
2730
3187
  id: string;
@@ -2732,13 +3189,24 @@ type AgentWidgetArtifactsLayoutConfig = {
2732
3189
  }>;
2733
3190
  /**
2734
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.
2735
3195
  */
2736
3196
  onDocumentToolbarCopyMenuSelect?: (payload: {
2737
3197
  actionId: string;
2738
3198
  artifactId: string | null;
2739
3199
  markdown: string;
2740
3200
  jsonPayload: string;
2741
- }) => 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>;
2742
3210
  };
2743
3211
  /**
2744
3212
  * Where the artifact body renders by default. Every mode shows the compact
@@ -3581,6 +4049,11 @@ type AgentWidgetFeatureFlags = {
3581
4049
  * pills + optional free-text input.
3582
4050
  */
3583
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;
3584
4057
  /**
3585
4058
  * Built-in `suggest_replies` follow-ups. When the assistant invokes the
3586
4059
  * tool, the widget shows the suggestions using `suggestions.followUps` and
@@ -3773,6 +4246,604 @@ type AgentWidgetAskUserQuestionFeature = {
3773
4246
  /** Style overrides for the sheet and pills. */
3774
4247
  styles?: AgentWidgetAskUserQuestionStyles;
3775
4248
  };
4249
+ /**
4250
+ * Copy overrides for the visitor-facing conversation history surface. These are
4251
+ * the widget's only localization mechanism for history, so every user-visible
4252
+ * history string is listed here.
4253
+ */
4254
+ interface AgentWidgetHistoryCopy {
4255
+ /** Title of the history view. Defaults to "Messages". */
4256
+ viewTitle?: string;
4257
+ /** Heading shown when the visitor has no stored conversations. */
4258
+ emptyTitle?: string;
4259
+ /** Body text shown when the visitor has no stored conversations. */
4260
+ emptyDescription?: string;
4261
+ /** Heading shown when a history request fails. */
4262
+ errorTitle?: string;
4263
+ /** Body text shown when a history request fails. */
4264
+ errorDescription?: string;
4265
+ /** Label for the retry action on the error state. */
4266
+ retryLabel?: string;
4267
+ /** Heading shown after a 429 rate-limited history response. */
4268
+ rateLimitedTitle?: string;
4269
+ /** Body text shown after a 429 rate-limited history response. */
4270
+ rateLimitedDescription?: string;
4271
+ /** Confirmation prompt before deleting a single conversation. */
4272
+ deleteConversationConfirm?: string;
4273
+ /** Confirmation prompt before deleting every conversation in the active scope. */
4274
+ clearHistoryConfirm?: string;
4275
+ /** Confirmation prompt before detaching this browser from its history identity. */
4276
+ resetIdentityConfirm?: string;
4277
+ /** Label for the action that starts a new server conversation. */
4278
+ newConversationLabel?: string;
4279
+ /** Label for the action that prepends the previous transcript page. */
4280
+ showEarlierMessagesLabel?: string;
4281
+ /** Accessible label for the transcript skeleton while a conversation loads. */
4282
+ openConversationLoadingLabel?: string;
4283
+ /** Body text when a selected conversation failed to load. */
4284
+ openConversationErrorTitle?: string;
4285
+ /** Label for the retry action after a conversation failed to load. */
4286
+ openConversationRetryLabel?: string;
4287
+ /** Label for the return-to-messages action after a conversation failed to load. */
4288
+ openConversationBackLabel?: string;
4289
+ /** Status notice after a deleted conversation was recovered into a fresh one. */
4290
+ conversationDeletedNotice?: string;
4291
+ /** Status notice after this browser was detached from its history identity. */
4292
+ identityResetNotice?: string;
4293
+ /** Status notice when a local reset succeeded but server revocation was unconfirmed. */
4294
+ identityResetUnconfirmedNotice?: string;
4295
+ /** Pinned group heading for starred conversations. */
4296
+ groupStarred?: string;
4297
+ /** Time-group heading for conversations updated today. */
4298
+ groupToday?: string;
4299
+ /** Time-group heading for conversations updated yesterday. */
4300
+ groupYesterday?: string;
4301
+ /** Time-group heading for the trailing 7-day window. */
4302
+ groupPrevious7Days?: string;
4303
+ /** Time-group heading for the trailing 30-day window. */
4304
+ groupPrevious30Days?: string;
4305
+ /** Time-group heading for older conversations, grouped by month and year. */
4306
+ groupMonthYear?: string;
4307
+ /** Scope title when history is limited to this browser. */
4308
+ browserOnlyTitle?: string;
4309
+ /** Scope description when history is limited to this browser. */
4310
+ browserOnlyDescription?: string;
4311
+ /** Scope title while an identity proof is being resolved. */
4312
+ verifyingTitle?: string;
4313
+ /** Scope description while an identity proof is being resolved. */
4314
+ verifyingDescription?: string;
4315
+ /** Scope title when history is available across signed-in devices. */
4316
+ verifiedTitle?: string;
4317
+ /** Scope description when history is available across signed-in devices. */
4318
+ verifiedDescription?: string;
4319
+ /** Scope title when the visitor must sign in again to view account history. */
4320
+ authenticationRequiredTitle?: string;
4321
+ /** Scope description when the visitor must sign in again to view account history. */
4322
+ authenticationRequiredDescription?: string;
4323
+ /** Scope title when the host identity provider threw or rejected. */
4324
+ identityProviderFailedTitle?: string;
4325
+ /** Scope description when the host identity provider threw or rejected. */
4326
+ identityProviderFailedDescription?: string;
4327
+ /** Scope title when the server did not admit a supplied identity proof. */
4328
+ proofNotAdmittedTitle?: string;
4329
+ /** Scope description when the server did not admit a supplied identity proof. */
4330
+ proofNotAdmittedDescription?: string;
4331
+ /** Label for the action that retries identity resolution. */
4332
+ retryIdentityLabel?: string;
4333
+ /** Accessible name of the header control that opens history. */
4334
+ openHistoryLabel?: string;
4335
+ /** Accessible name of that control while a turn is streaming or resuming. */
4336
+ openHistoryBusyLabel?: string;
4337
+ /** Least-destructive action in every history confirmation dialog. */
4338
+ confirmCancelLabel?: string;
4339
+ /** Heading of the delete-one confirmation. */
4340
+ deleteConversationConfirmTitle?: string;
4341
+ /** Confirming action of the delete-one confirmation. */
4342
+ deleteConversationConfirmLabel?: string;
4343
+ /** Heading of the delete-all confirmation. */
4344
+ clearHistoryConfirmTitle?: string;
4345
+ /** Confirming action of the delete-all confirmation. */
4346
+ clearHistoryConfirmLabel?: string;
4347
+ /** Delete-all body used when the resolved scope is the signed-in user. */
4348
+ clearHistoryVerifiedConfirm?: string;
4349
+ /** Heading of the forget-this-device confirmation. */
4350
+ resetIdentityConfirmTitle?: string;
4351
+ /** Confirming action of the forget-this-device confirmation. */
4352
+ resetIdentityConfirmLabel?: string;
4353
+ /** Panel back control; returns to the surface that opened Messages. */
4354
+ backLabel?: string;
4355
+ /** Rail close control, shown only when the rail is not collapsible. */
4356
+ closeLabel?: string;
4357
+ /** Rail collapse toggle while the rail is expanded. */
4358
+ collapseLabel?: string;
4359
+ /** Rail collapse toggle while the rail is collapsed to icons. */
4360
+ expandLabel?: string;
4361
+ /** Accessible name of the docked rail's drag-resize handle. */
4362
+ resizeLabel?: string;
4363
+ /** Accessible status while the first page loads. */
4364
+ loadingLabel?: string;
4365
+ /** Label of the paging action below the last group. */
4366
+ loadMoreLabel?: string;
4367
+ /** Label of that action while its page is in flight. */
4368
+ loadingMoreLabel?: string;
4369
+ /**
4370
+ * Heading over the conversation list. Visible in rail presentation, where it
4371
+ * carries the list overflow trigger; sr-only in panel presentation.
4372
+ */
4373
+ conversationsTitle?: string;
4374
+ /** Accessible name of the per-row overflow trigger and its menu. */
4375
+ rowActionsLabel?: string;
4376
+ /** Accessible name of the list-level overflow trigger and its menu. */
4377
+ listOptionsLabel?: string;
4378
+ /** Delete item inside the per-row overflow menu. */
4379
+ deleteConversationLabel?: string;
4380
+ /** Delete-all item inside the list overflow menu. */
4381
+ clearHistoryLabel?: string;
4382
+ /** Forget-this-device item inside the list overflow menu. */
4383
+ resetIdentityLabel?: string;
4384
+ /** Row message count. `{count}` placeholder. */
4385
+ messageCountLabel?: string;
4386
+ /** Row message count for exactly one message. */
4387
+ messageCountLabelOne?: string;
4388
+ /** Announced after a single conversation was deleted. */
4389
+ conversationRemovedNotice?: string;
4390
+ /** Announced after every conversation in scope was deleted. */
4391
+ historyClearedNotice?: string;
4392
+ /** Heading shown when history is unavailable for this surface. */
4393
+ unavailableTitle?: string;
4394
+ /** Body text shown when history is unavailable for this surface. */
4395
+ unavailableDescription?: string;
4396
+ /** Heading of the post-deletion replacement-init recovery state. */
4397
+ newConversationRequiredTitle?: string;
4398
+ /** Body text of the post-deletion replacement-init recovery state. */
4399
+ newConversationRequiredDescription?: string;
4400
+ /** Rate-limited wait guidance. `{seconds}` placeholder. */
4401
+ rateLimitedWaitDescription?: string;
4402
+ /** Row-adjacent error after a failed open. */
4403
+ openFailedLabel?: string;
4404
+ /** Row-adjacent error after a failed delete. */
4405
+ deleteFailedLabel?: string;
4406
+ /** Relative time for the most recent bucket. */
4407
+ relativeNow?: string;
4408
+ /** Relative time in minutes. `{value}` placeholder. */
4409
+ relativeMinutes?: string;
4410
+ /** Relative time in hours. `{value}` placeholder. */
4411
+ relativeHours?: string;
4412
+ /** Relative time in days. `{value}` placeholder. */
4413
+ relativeDays?: string;
4414
+ /** Relative time in weeks. `{value}` placeholder. */
4415
+ relativeWeeks?: string;
4416
+ /** Relative time in years. `{value}` placeholder. */
4417
+ relativeYears?: string;
4418
+ }
4419
+ /**
4420
+ * One row in a `features.history.rail.sections` navigation section. Icon
4421
+ * precedence, highest first: `renderIcon`, then `iconUrl`, then `icon`.
4422
+ * Whichever resolves first is built once and reused for the item's lifetime.
4423
+ */
4424
+ interface AgentWidgetHistoryRailSectionItem {
4425
+ /** Stable identity, stamped as `data-persona-rail-item`. */
4426
+ id: string;
4427
+ /** Visible text, and the default `aria-label` of the button. */
4428
+ label: string;
4429
+ /**
4430
+ * Lucide name from the widget's built-in icon registry (see `IconName`). A
4431
+ * name outside the registry warns once and the row renders label-only.
4432
+ */
4433
+ icon?: IconName | (string & {});
4434
+ /** Image URL or data URI, rendered as a decorative `img` in the icon slot. */
4435
+ iconUrl?: string;
4436
+ /** Full custom icon node. Returning null renders the row label-only. */
4437
+ renderIcon?: () => Element | null;
4438
+ /** Small trailing text chip, for a count or a short status word. */
4439
+ badge?: string;
4440
+ /** Invoked on click. A throw is caught and warned once per section. */
4441
+ onSelect: () => void;
4442
+ }
4443
+ /** One navigation section in the history rail, above or below the list. */
4444
+ interface AgentWidgetHistoryRailSection {
4445
+ /** Stable identity, stamped as `data-persona-rail-section`. */
4446
+ id: string;
4447
+ /** Optional heading, styled like a conversation date-group heading. */
4448
+ title?: string;
4449
+ /** Default `"above-conversations"`. */
4450
+ placement?: "above-conversations" | "below-conversations" | "footer";
4451
+ items: AgentWidgetHistoryRailSectionItem[];
4452
+ }
4453
+ /**
4454
+ * Host-defined item in the list overflow menu (the `…` beside the
4455
+ * conversation-list heading). Rendered above the built-in destructive items.
4456
+ */
4457
+ interface AgentWidgetHistoryListAction {
4458
+ /** Stable identity; keeps menu focus keys stable across re-renders. */
4459
+ id: string;
4460
+ label: string;
4461
+ /** Destructive (red) styling like the built-in delete-all. Default false. */
4462
+ danger?: boolean;
4463
+ /** Receives the conversation summaries loaded at selection time. */
4464
+ onSelect: (context: {
4465
+ conversations: HistoryConversationSummary[];
4466
+ }) => void | Promise<void>;
4467
+ }
4468
+ /**
4469
+ * Feature config for per-visitor conversation history. Without a `provider`,
4470
+ * client token mode only: the built-in Runtype backend needs one, so the UI
4471
+ * never renders for proxy/agent sessions. A `provider` lifts that restriction.
4472
+ */
4473
+ interface AgentWidgetHistoryFeature {
4474
+ /** Master switch. Default false: no capability flag on init, no UI. */
4475
+ enabled?: boolean;
4476
+ /**
4477
+ * Custom conversation-history backend. Supply one to run the history UX
4478
+ * (list, open, delete, delete-all, header title binding) against your own
4479
+ * storage in ANY session mode, including a custom `apiUrl` backend with no
4480
+ * client token. Omitted, history falls back to the built-in Runtype backend,
4481
+ * which requires client token mode.
4482
+ *
4483
+ * Pass either an instance or a factory. The factory form is called once per
4484
+ * widget instance, so a single script-tag config object (assembled before
4485
+ * install) can back several widgets without sharing provider state. Passing a
4486
+ * new factory identity through `update()` rebuilds the provider.
4487
+ *
4488
+ * Failures are signalled by throwing `HistoryProviderError` with a `code` from
4489
+ * `HistoryProviderErrorCode`. The view branches on that code alone: it never
4490
+ * reads message text, and an untyped throw degrades to a generic error state.
4491
+ *
4492
+ * `prepareOpen`/`prepareStartNew` resolve BEFORE anything visible changes:
4493
+ * they return a `PreparedHistoryActivation` whose `commit()` applies the
4494
+ * already-authorized binding and whose `discard()` idempotently abandons a
4495
+ * superseded activation, leaving the active chat untouched. The widget calls
4496
+ * exactly one of the two per prepared activation.
4497
+ *
4498
+ * Optional capabilities hide their affordances when absent: no `update`
4499
+ * removes the rename/star actions (including the built-in title-menu `star`),
4500
+ * and no `resetDevice` removes "forget this device".
4501
+ *
4502
+ * The provider's `capabilities.scopes` is authoritative: the widget derives a
4503
+ * default scope (`"verified-user"` when `getIdentityProof` is configured,
4504
+ * otherwise `"browser"`) and narrows it to what the provider advertises, so a
4505
+ * browser-only provider is never asked for a scope it cannot serve. An
4506
+ * explicit `features.history.scope` is a hard request and still fails closed
4507
+ * with `unsupported_scope`. `getIdentityProof` is never called for a supplied
4508
+ * provider, and `HistoryOperationContext` carries only the resolved scope;
4509
+ * report your own identity through `getIdentityStatus()` /
4510
+ * `subscribeIdentityStatus()`, which is what the scope banner and its retry
4511
+ * affordance read.
4512
+ *
4513
+ * Reopening the last conversation after a page reload is the host's job: the
4514
+ * widget's boot resume runs only on the built-in Runtype path, so with a
4515
+ * supplied provider the transcript is restored by the storage adapter while
4516
+ * `getActiveConversationId()` starts null (no active row, no
4517
+ * conversation-bound header title) until something opens a conversation.
4518
+ * Persist the id yourself and call `controller.openConversation(id)` on ready
4519
+ * if you want the last conversation to come back automatically.
4520
+ *
4521
+ * @example
4522
+ * ```js
4523
+ * features: { history: { enabled: true, provider: () => myProvider } }
4524
+ * ```
4525
+ */
4526
+ provider?: HistoryProvider | (() => HistoryProvider);
4527
+ /** Page size for the conversation list (default 25, server max 100). */
4528
+ pageSize?: number;
4529
+ /**
4530
+ * Default history placement. "panel" replaces the conversation surface;
4531
+ * "rail" requests a side navigation host whenever it is at least 720px wide
4532
+ * and collapses to panel below that; "auto" uses rail only for a wide inline
4533
+ * or docked shell and keeps floating launchers panel-based at every width.
4534
+ * Default "panel".
4535
+ */
4536
+ presentation?: "panel" | "rail" | "auto";
4537
+ /**
4538
+ * Geometry of the rail navigation column. `side` picks the edge it docks to
4539
+ * (default "left", beside the conversation); `width` is its fixed width in
4540
+ * px, clamped to 200-400 (default 260). `collapsible` (default true) puts a
4541
+ * collapse toggle in the rail header that shrinks it to a 52px icon rail, and
4542
+ * `defaultCollapsed` (default false) picks the state a visitor who has never
4543
+ * toggled it starts in. The chosen state is remembered per visitor alongside
4544
+ * the other `persistState` keys. Ignored in panel presentation.
4545
+ */
4546
+ rail?: {
4547
+ side?: "left" | "right";
4548
+ width?: number;
4549
+ collapsible?: boolean;
4550
+ defaultCollapsed?: boolean;
4551
+ /**
4552
+ * Drag handle on the docked rail's divider edge, resizing it live within
4553
+ * the same 200 to 400 clamp `width` takes. Default false. The chosen width
4554
+ * is remembered per visitor alongside the other `persistState` keys and
4555
+ * outranks a later `width` update, the way the collapsed state does; the
4556
+ * floating overlay rail inherits it but is never itself resizable, and a
4557
+ * collapsed icon column ignores it until it expands again.
4558
+ */
4559
+ resizable?: boolean;
4560
+ /**
4561
+ * Shape of the COLLAPSED rail. `"icon-rail"` (default) keeps the 52px icon
4562
+ * column beside the conversation. `"overlay"` removes the column entirely:
4563
+ * a trigger takes the leading edge of the conversation header, hovering or
4564
+ * tapping it floats the expanded rail over the conversation, and clicking
4565
+ * it pins the rail back open. The floating rail is transient, so leaving
4566
+ * it, Escape, a click outside, or selecting a conversation all dismiss it;
4567
+ * its own header toggle docks it instead, being the control the pointer
4568
+ * finds there. Geometry follows `width` and `side`; the collapsed rail's
4569
+ * chunk is not loaded until the first hover. Ignored when `collapsible` is
4570
+ * false or in panel presentation.
4571
+ */
4572
+ collapsedBehavior?: "icon-rail" | "overlay";
4573
+ /**
4574
+ * One brand declaration, placed in both of the rail's identity spots: the
4575
+ * header's heading area when expanded (the mark leading, `copy.viewTitle`
4576
+ * beside it as the wordmark), and the collapse toggle's rest face when the
4577
+ * rail is collapsed, where hover and keyboard focus reveal the panel glyph
4578
+ * under it. A coarse pointer keeps the glyph, having no hover to reveal it
4579
+ * with. Icon precedence, highest first: `render`, then `iconUrl`, then
4580
+ * `icon`. `render` receives the placement through `ctx.collapsed` (`true`
4581
+ * is the collapsed toggle face) and may return null to skip that spot.
4582
+ * `renderHeader` outranks this for the heading area; the collapsed face is
4583
+ * this slot's alone. Decorative either way: the view's accessible name
4584
+ * still comes from `copy.viewTitle`, and the toggle keeps its own label.
4585
+ * Ignored in panel presentation.
4586
+ */
4587
+ brand?: {
4588
+ /** Lucide name from the built-in registry; an unknown one warns once. */
4589
+ icon?: IconName | (string & {});
4590
+ /** Image URL or data URI, rendered as a decorative `img`. */
4591
+ iconUrl?: string;
4592
+ /** Full custom node. A throw warns once and drops the brand. */
4593
+ render?: (context: {
4594
+ collapsed: boolean;
4595
+ }) => Element | null;
4596
+ };
4597
+ /**
4598
+ * Full override of the rail header's identity area, outranking `brand`
4599
+ * there, re-invoked whenever the collapsed state changes. Return null to
4600
+ * leave the area empty, which leaves the collapse toggle standing alone.
4601
+ * The accessible name of the
4602
+ * view comes from `copy.viewTitle` either way: the heading stays in the
4603
+ * DOM, visually hidden, whenever this renders. Ignored in panel
4604
+ * presentation.
4605
+ */
4606
+ renderHeader?: (context: {
4607
+ collapsed: boolean;
4608
+ defaultTitle: string;
4609
+ }) => Element | null;
4610
+ /**
4611
+ * Extra navigation sections stacked around the conversation list, in array
4612
+ * order within each `placement` bucket. Rail-only in this release: a move
4613
+ * into panel presentation removes them and a move back re-renders them.
4614
+ */
4615
+ sections?: AgentWidgetHistoryRailSection[];
4616
+ /**
4617
+ * Keyboard shortcut for the collapse toggle, e.g. `"mod+b"` ("mod" is
4618
+ * Command on Apple platforms, Control elsewhere). Undefined by default, so
4619
+ * an embedded widget never claims a host page's keys. The same declaration
4620
+ * drives the binding, the toggle's tooltip hint chip, and its
4621
+ * `aria-keyshortcuts`.
4622
+ */
4623
+ collapseShortcut?: string | false;
4624
+ /**
4625
+ * Where `collapseShortcut` listens. Default `"widget"`: only while focus is
4626
+ * inside the widget. `"page"` claims the combo document-wide, which suits a
4627
+ * fullscreen widget that IS the app.
4628
+ */
4629
+ collapseShortcutScope?: "widget" | "page";
4630
+ };
4631
+ /**
4632
+ * History scope. Defaults to "verified-user" when getIdentityProof exists,
4633
+ * otherwise "browser". Before this browser has been identity-bound, a null
4634
+ * proof falls back to browser scope for that operation. Once visitor.endUserId
4635
+ * is non-null, a null proof fails closed until the host resets history identity.
4636
+ *
4637
+ * With a `provider`, this is a hard request: the provider must advertise it
4638
+ * in `capabilities.scopes` or every history operation fails with
4639
+ * `unsupported_scope`. Leave it unset to let the provider's advertised scope
4640
+ * win.
4641
+ */
4642
+ scope?: HistoryScope;
4643
+ /** Copy overrides. Every user-visible history string must be here. */
4644
+ copy?: AgentWidgetHistoryCopy;
4645
+ /**
4646
+ * Date bucketing of the conversation list. `"time"` (default) groups rows
4647
+ * under Today, Yesterday, Previous 7 days, Previous 30 days, and month
4648
+ * headings. `"none"` renders one flat list in server order instead, the
4649
+ * recents-style sidebar. Starred conversations keep their pinned group
4650
+ * either way.
4651
+ */
4652
+ grouping?: "time" | "none";
4653
+ /**
4654
+ * Leading avatar on each conversation row. Unset, rows show the launcher's
4655
+ * image mark (`launcher.iconUrl`) when one exists and are text-only
4656
+ * otherwise, the assistant-list default. Pass an image URL or a glyph to
4657
+ * always show a mark, or false to force text-only rows.
4658
+ */
4659
+ rowAvatar?: boolean | string;
4660
+ /** Show the evidence-based history scope/status beneath the Messages heading. Default true. */
4661
+ showScopeStatus?: boolean;
4662
+ /**
4663
+ * Visitor-facing delete of a single conversation via each row's overflow
4664
+ * menu. Default true. False hides the control only: it changes nothing about
4665
+ * what is stored or for how long, and custom row slots still receive
4666
+ * `requestDelete`. Turn off for deployments that treat conversations as
4667
+ * business records.
4668
+ */
4669
+ showDelete?: boolean;
4670
+ /**
4671
+ * The "Delete all conversations" item in the Messages overflow menu. Default
4672
+ * true. False hides the control only; storage and retention are unchanged.
4673
+ * The identity reset item is separate and unaffected.
4674
+ */
4675
+ showDeleteAll?: boolean;
4676
+ /**
4677
+ * Host items appended to the list overflow menu, above the built-in
4678
+ * destructive actions. The trigger renders whenever any item exists, so
4679
+ * these keep the menu alive even with `showDeleteAll: false`.
4680
+ */
4681
+ listActions?: AgentWidgetHistoryListAction[];
4682
+ }
4683
+ /** Resolved scope for a logical history operation. */
4684
+ type HistoryScope = "browser" | "verified-user";
4685
+ /** `presentation` after it has been resolved against the host container width. */
4686
+ type ResolvedHistoryPresentation = "panel" | "rail";
4687
+ /**
4688
+ * The surface Messages returns to on back/Escape. `"home"` only when a Home
4689
+ * Screen composition opened it; the core header button always records
4690
+ * `"conversation"`.
4691
+ */
4692
+ type HistoryReturnSurface = "home" | "conversation";
4693
+ /**
4694
+ * Evidence-based history identity state. Never inferred from the mere presence
4695
+ * of `getIdentityProof`, and never carries token, visitor, or end-user values.
4696
+ */
4697
+ type HistoryIdentityStatus = {
4698
+ state: "browser_only";
4699
+ reason: "configured_browser_scope" | "no_identity_provider" | "proof_unavailable_before_binding";
4700
+ } | {
4701
+ state: "verifying";
4702
+ } | {
4703
+ state: "verified";
4704
+ } | {
4705
+ state: "authentication_required";
4706
+ reason: "proof_unavailable_after_binding" | "invalid_identity_proof";
4707
+ } | {
4708
+ state: "identity_provider_failed";
4709
+ } | {
4710
+ state: "configuration_error";
4711
+ reason: "proof_not_admitted";
4712
+ } | {
4713
+ state: "resetting";
4714
+ } | {
4715
+ state: "unavailable";
4716
+ reason: "history_disabled" | "ineligible_mode";
4717
+ };
4718
+ /** Fully defaulted history copy. Every user-visible history string. */
4719
+ type ResolvedHistoryCopy = Required<AgentWidgetHistoryCopy>;
4720
+ /** List-region state handed to render hooks. */
4721
+ type HistoryViewState = {
4722
+ kind: "loading";
4723
+ phase: "initial" | "refresh" | "load-more";
4724
+ } | {
4725
+ kind: "ready";
4726
+ } | {
4727
+ kind: "empty";
4728
+ } | {
4729
+ kind: "error";
4730
+ reason: "unavailable" | "authentication_failed" | "authentication_required" | "identity_provider_failed" | "proof_not_admitted" | "unsupported_scope" | "unknown";
4731
+ retryable: boolean;
4732
+ } | {
4733
+ kind: "rate_limited";
4734
+ retryAfterSeconds: number;
4735
+ } | {
4736
+ kind: "new_conversation_required";
4737
+ };
4738
+ /** The single in-flight history operation, or `null` when idle. */
4739
+ type HistoryPendingAction = {
4740
+ kind: "refresh" | "load-more" | "start-new" | "clear" | "reset";
4741
+ } | {
4742
+ kind: "open" | "delete";
4743
+ conversationId: string;
4744
+ } | null;
4745
+ /**
4746
+ * Every history operation a render hook may invoke. Each routes through the
4747
+ * same controller/session path as the default renderer, so busy gating,
4748
+ * selection epochs, and confirmations behave identically.
4749
+ */
4750
+ type AgentWidgetHistoryRenderActions = {
4751
+ refresh(): Promise<void>;
4752
+ loadMore(): Promise<void>;
4753
+ openConversation(conversationId: string): Promise<void>;
4754
+ startNewConversation(): Promise<void>;
4755
+ /** Each request method opens Persona's accessible confirmation first. */
4756
+ requestDeleteConversation(conversationId: string): Promise<"deleted" | "cancelled">;
4757
+ requestClearConversationHistory(): Promise<"cleared" | "cancelled">;
4758
+ requestResetHistoryIdentity(): Promise<{
4759
+ outcome: "cancelled";
4760
+ } | {
4761
+ outcome: "reset";
4762
+ remoteRevocationConfirmed: boolean;
4763
+ }>;
4764
+ close(): void;
4765
+ };
4766
+ /** Context for `renderHistoryView`. Frozen snapshot; no provider or credentials. */
4767
+ type AgentWidgetRenderHistoryViewContext = {
4768
+ conversations: readonly HistoryConversationSummary[];
4769
+ activeConversationId: string | null;
4770
+ state: HistoryViewState;
4771
+ pendingAction: HistoryPendingAction;
4772
+ identityStatus: HistoryIdentityStatus;
4773
+ nextCursor: string | null;
4774
+ presentation: ResolvedHistoryPresentation;
4775
+ returnSurface: HistoryReturnSurface;
4776
+ config: AgentWidgetConfig;
4777
+ copy: ResolvedHistoryCopy;
4778
+ actions: AgentWidgetHistoryRenderActions;
4779
+ /** The default full view. Bypasses this hook only; lower slots still apply. */
4780
+ defaultRenderer(): HTMLElement;
4781
+ /** Re-run arbitration with the current snapshot. Inert after close/destroy. */
4782
+ requestRender(): void;
4783
+ /** Teardown for this render; runs before the next one and on close. */
4784
+ onCleanup(callback: () => void): void;
4785
+ };
4786
+ /** Context for `renderHistoryConversation` (one list row). */
4787
+ type AgentWidgetRenderHistoryConversationContext = {
4788
+ conversation: HistoryConversationSummary;
4789
+ active: boolean;
4790
+ pending: "opening" | "deleting" | null;
4791
+ presentation: ResolvedHistoryPresentation;
4792
+ config: AgentWidgetConfig;
4793
+ open(): Promise<void>;
4794
+ requestDelete(): Promise<"deleted" | "cancelled">;
4795
+ defaultRenderer(): HTMLElement;
4796
+ };
4797
+ /** Context for `renderHistoryHeader` (the Messages top bar). */
4798
+ type AgentWidgetRenderHistoryHeaderContext = {
4799
+ presentation: ResolvedHistoryPresentation;
4800
+ returnSurface: HistoryReturnSurface;
4801
+ identityStatus: HistoryIdentityStatus;
4802
+ pendingAction: HistoryPendingAction;
4803
+ config: AgentWidgetConfig;
4804
+ copy: ResolvedHistoryCopy;
4805
+ actions: Pick<AgentWidgetHistoryRenderActions, "close" | "startNewConversation">;
4806
+ defaultRenderer(): HTMLElement;
4807
+ };
4808
+ /**
4809
+ * Context for `renderHistoryState`. Invoked only for non-ready list states;
4810
+ * `retry`/`startNewConversation` are present only where they are safe, so
4811
+ * custom DOM never infers recovery behavior.
4812
+ */
4813
+ type AgentWidgetRenderHistoryStateContext = {
4814
+ state: Exclude<HistoryViewState, {
4815
+ kind: "ready";
4816
+ }>;
4817
+ identityStatus: HistoryIdentityStatus;
4818
+ presentation: ResolvedHistoryPresentation;
4819
+ config: AgentWidgetConfig;
4820
+ copy: ResolvedHistoryCopy;
4821
+ retry?: () => Promise<void>;
4822
+ startNewConversation?: () => Promise<void>;
4823
+ defaultRenderer(): HTMLElement;
4824
+ };
4825
+ /**
4826
+ * Context for `renderHistoryOpenError` (the transcript-level surface shown
4827
+ * when opening a conversation from the Messages list fails). `retry` and
4828
+ * `back` are the only exits: both route through the token-guarded open flow,
4829
+ * so custom DOM must not fetch on its own. `back` is present only when the
4830
+ * Messages surface is available to return to.
4831
+ */
4832
+ type AgentWidgetRenderHistoryOpenErrorContext = {
4833
+ conversationId: string;
4834
+ config: AgentWidgetConfig;
4835
+ /** Resolved shell copy the default surface renders. */
4836
+ copy: {
4837
+ title: string;
4838
+ retryLabel: string;
4839
+ backLabel: string;
4840
+ };
4841
+ /** Re-runs the open through Persona's token-guarded flow. */
4842
+ retry: () => void;
4843
+ /** Returns to the Messages list. Absent when history is unavailable. */
4844
+ back?: () => void;
4845
+ defaultRenderer(): HTMLElement;
4846
+ };
3776
4847
  type SSEEventRecord = {
3777
4848
  id: string;
3778
4849
  type: string;
@@ -4245,6 +5316,24 @@ type AgentWidgetLauncherTeaserConfig = {
4245
5316
  */
4246
5317
  dismissLabel?: string;
4247
5318
  };
5319
+ /**
5320
+ * Timing for the portaled icon-control tooltip (header, composer, rail).
5321
+ * Keyboard focus always opens immediately. Hover waits `delayMs` unless
5322
+ * another tooltip closed within `skipDelayMs` (toolbar scan).
5323
+ */
5324
+ type AgentWidgetTooltipConfig = {
5325
+ /**
5326
+ * Milliseconds to wait on hover before the first tooltip appears.
5327
+ * `0` restores the previous instant-open behavior.
5328
+ * @default 200
5329
+ */
5330
+ delayMs?: number;
5331
+ /**
5332
+ * After a tooltip closes, later hovers in this window skip `delayMs`.
5333
+ * @default 300
5334
+ */
5335
+ skipDelayMs?: number;
5336
+ };
4248
5337
  type AgentWidgetSendButtonConfig = {
4249
5338
  borderWidth?: string;
4250
5339
  borderColor?: string;
@@ -5251,6 +6340,21 @@ type ClientSession = {
5251
6340
  name: string;
5252
6341
  description: string | null;
5253
6342
  };
6343
+ /**
6344
+ * Active conversation record for this session. Optional only for rolling-deploy
6345
+ * compatibility with servers that predate the visitor history contract.
6346
+ */
6347
+ conversationId?: string;
6348
+ /**
6349
+ * Canonical resolved chat target (flow or agent). Normalized from the response
6350
+ * `targetId`, falling back to `flow.id` during rolling deployment. History code
6351
+ * reads this, never widget config.
6352
+ */
6353
+ targetId?: string;
6354
+ /** Opaque change token; differs whenever the conversation transcript mutated. */
6355
+ conversationRevision?: string;
6356
+ /** Visitor grant backing history. `token` appears only at mint. */
6357
+ visitor?: ClientVisitorGrant;
5254
6358
  /** Configuration from the server */
5255
6359
  config: {
5256
6360
  welcomeMessage: string | null;
@@ -5258,6 +6362,43 @@ type ClientSession = {
5258
6362
  theme: Record<string, unknown> | null;
5259
6363
  };
5260
6364
  };
6365
+ /**
6366
+ * Visitor credential and identity acknowledgement returned by /v1/client/init.
6367
+ * `expiresAt` stays the wire string: it is a server-slid idle window the widget
6368
+ * never evaluates locally.
6369
+ */
6370
+ type ClientVisitorGrant = {
6371
+ id: string;
6372
+ /** Replacement secret. Present only at mint; persist it before anything else. */
6373
+ token?: string;
6374
+ expiresAt: string;
6375
+ endUserId: string | null;
6376
+ /** Server acknowledgement of the supplied identity proof. Status metadata only. */
6377
+ identityStatus?: "not_provided" | "admitted" | "ignored";
6378
+ };
6379
+ /**
6380
+ * One conversation row, normalized at the Runtype boundary. The deprecated wire
6381
+ * `flowId` alias never escapes that boundary: history code reads `targetId`.
6382
+ */
6383
+ type HistoryConversationSummary = {
6384
+ id: string;
6385
+ /** Server-generated; rendered verbatim, never derived locally. */
6386
+ title: string;
6387
+ /** Resolved chat target (flow or agent); `null` when the server omits it. */
6388
+ targetId: string | null;
6389
+ /** Server-produced plain-text preview; `null` when unavailable. */
6390
+ preview: string | null;
6391
+ messageCount: number;
6392
+ createdAt: string;
6393
+ updatedAt: string;
6394
+ /** Visitor-pinned flag. Absent when the provider has no update capability. */
6395
+ starred?: boolean;
6396
+ };
6397
+ /** Visitor-editable conversation metadata. Absent fields are left unchanged. */
6398
+ type HistoryConversationPatch = {
6399
+ title?: string;
6400
+ starred?: boolean;
6401
+ };
5261
6402
  /** Icon button in the header title row (minimal layout). */
5262
6403
  type AgentWidgetHeaderTrailingAction = {
5263
6404
  id: string;
@@ -5276,6 +6417,13 @@ type AgentWidgetHeaderTrailingAction = {
5276
6417
  destructive?: boolean;
5277
6418
  dividerBefore?: boolean;
5278
6419
  }>;
6420
+ /**
6421
+ * Keyboard shortcut that activates this action, e.g. `"mod+shift+h"` ("mod"
6422
+ * is Command on Apple platforms, Control elsewhere). Fires only while focus
6423
+ * is inside the widget, and also drives the button's tooltip hint chip and
6424
+ * its `aria-keyshortcuts`.
6425
+ */
6426
+ shortcut?: string;
5279
6427
  };
5280
6428
  /**
5281
6429
  * Context provided to header render functions
@@ -5319,6 +6467,15 @@ type AgentWidgetHeaderLayoutConfig = {
5319
6467
  showIcon?: boolean;
5320
6468
  /** Show/hide the title */
5321
6469
  showTitle?: boolean;
6470
+ /**
6471
+ * What the header title (or `titleMenu` label) displays. `"static"`
6472
+ * (default) always shows `launcher.title`. `"conversation"` shows the active
6473
+ * conversation's title — the Claude-style pairing for a `titleMenu` holding
6474
+ * conversation actions — falling back to `launcher.title` while no titled
6475
+ * conversation is open (fresh chat, cleared history, or before the history
6476
+ * view has loaded titles). Requires `features.history` for titles to exist.
6477
+ */
6478
+ titleSource?: "static" | "conversation";
5322
6479
  /** Show/hide the subtitle */
5323
6480
  showSubtitle?: boolean;
5324
6481
  /** Show/hide the close button */
@@ -5369,8 +6526,16 @@ type AgentWidgetHeaderLayoutConfig = {
5369
6526
  destructive?: boolean;
5370
6527
  dividerBefore?: boolean;
5371
6528
  }>;
5372
- /** Called when a menu item is selected. */
5373
- onSelect: (id: string) => void;
6529
+ /**
6530
+ * Called when a menu item is selected. Returning `false` (sync or via
6531
+ * promise) falls through to the widget built-ins, mirroring the artifact
6532
+ * copy-menu contract: id `star` toggles the active conversation's star and
6533
+ * id `delete` runs the shell's confirm-then-delete on it (both require
6534
+ * `features.history` and, for star, a provider with the update
6535
+ * capability). `rename` has no built-in: hosts own the rename UI and call
6536
+ * `renameConversation()`.
6537
+ */
6538
+ onSelect: (id: string) => void | boolean | Promise<void | boolean>;
5374
6539
  /** Hover pill style. */
5375
6540
  hover?: {
5376
6541
  background?: string;
@@ -5941,15 +7106,20 @@ type LoadingIndicatorRenderContext = {
5941
7106
  */
5942
7107
  config: AgentWidgetConfig;
5943
7108
  /**
5944
- * Current streaming state (always true when indicator is shown)
7109
+ * Current streaming state. Always true for 'inline' and 'standalone';
7110
+ * false for 'conversation-open' (a history fetch, not a stream).
5945
7111
  */
5946
7112
  streaming: boolean;
5947
7113
  /**
5948
7114
  * Location where the indicator is rendered:
5949
7115
  * - 'inline': Inside a streaming assistant message bubble (when content is empty)
5950
7116
  * - 'standalone': Separate bubble while waiting for stream to start
7117
+ * - 'conversation-open': Transcript stand-in while a conversation opened
7118
+ * from the Messages list is being fetched. The returned element is mounted
7119
+ * inside Persona's centered transcript column, which keeps the status
7120
+ * role, announcement label, and composer gating.
5951
7121
  */
5952
- location: 'inline' | 'standalone';
7122
+ location: 'inline' | 'standalone' | 'conversation-open';
5953
7123
  /**
5954
7124
  * Function to render the default 3-dot bouncing indicator.
5955
7125
  * Call this if you want to use the default for certain cases.
@@ -6248,6 +7418,28 @@ type AgentWidgetConfig = {
6248
7418
  * ```
6249
7419
  */
6250
7420
  setStoredSessionId?: (sessionId: string) => void;
7421
+ /**
7422
+ * Called immediately before any cross-device history request and before a
7423
+ * conversationId resume of a conversation discovered on another device.
7424
+ * Return a fresh end-user access token (rt_eu_… / JWT). Null uses exact-browser
7425
+ * scope only for a never-bound visitor; a previously bound visitor fails closed
7426
+ * until resetHistoryIdentity() runs. Never cached by the widget.
7427
+ */
7428
+ getIdentityProof?: () => string | null | Promise<string | null>;
7429
+ /**
7430
+ * Read the persisted active conversation id (client token mode only).
7431
+ * Called only after the internal stored-state bootstrap gate resolves.
7432
+ */
7433
+ getStoredConversationId?: () => string | null;
7434
+ /** Persist the active conversation id so a later boot reopens the same record. */
7435
+ setStoredConversationId?: (conversationId: string) => void;
7436
+ /** Drop the persisted active conversation id (new conversation, deletion, reset). */
7437
+ clearStoredConversationId?: () => void;
7438
+ /**
7439
+ * Drop the persisted session id. Dedicated clear seam: it avoids widening
7440
+ * `setStoredSessionId` and its existing host call sites.
7441
+ */
7442
+ clearStoredSessionId?: () => void;
6251
7443
  /**
6252
7444
  * Static headers to include with each request.
6253
7445
  * For dynamic headers (e.g., auth tokens), use `getHeaders` instead.
@@ -6327,6 +7519,12 @@ type AgentWidgetConfig = {
6327
7519
  * @default false
6328
7520
  */
6329
7521
  autoFocusInput?: boolean;
7522
+ /**
7523
+ * Hover timing for the portaled control tooltip. Keyboard focus is
7524
+ * always immediate. Unset keys keep the ChatGPT/Claude defaults
7525
+ * (`delayMs: 200`, `skipDelayMs: 300`).
7526
+ */
7527
+ tooltip?: AgentWidgetTooltipConfig;
6330
7528
  launcher?: AgentWidgetLauncherConfig;
6331
7529
  initialMessages?: AgentWidgetMessage[];
6332
7530
  /**