@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
@@ -290,6 +290,8 @@ interface AgentWidgetPluginStorage {
290
290
  remove: (key: string) => void;
291
291
  }
292
292
 
293
+ type ShortcutScope = "widget" | "page";
294
+
293
295
  type AgentWidgetTransformSuggestionsContext = {
294
296
  /**
295
297
  * Fresh copy of the suggestions entering this plugin, already normalized:
@@ -338,6 +340,37 @@ type AgentWidgetRenderWelcomeContext = {
338
340
  /** Teardown for this render; runs before the next one and on destroy. */
339
341
  onCleanup: (fn: () => void) => void;
340
342
  };
343
+ /** Context for one `railSections` entry. Frozen per invocation. */
344
+ type AgentWidgetRailSectionContext = {
345
+ /** Current rail width state. The section re-renders whenever this flips. */
346
+ collapsed: boolean;
347
+ presentation: ResolvedHistoryPresentation;
348
+ /** The same frozen action path the default rows and `renderHistoryView` use. */
349
+ actions: AgentWidgetHistoryRenderActions;
350
+ };
351
+ /** A plugin-contributed navigation section in the history rail. */
352
+ type AgentWidgetRailSection = {
353
+ /** Stable identity, stamped as `data-persona-rail-section`. */
354
+ id: string;
355
+ /** Default `"above-conversations"`. */
356
+ placement?: AgentWidgetHistoryRailSection["placement"];
357
+ /** Optional heading, styled like a conversation date-group heading. */
358
+ title?: string;
359
+ /** Section body. Null renders nothing for the current state. */
360
+ render: (context: AgentWidgetRailSectionContext) => Element | null;
361
+ };
362
+ /** A plugin-contributed keyboard shortcut, bound per widget instance. */
363
+ type AgentWidgetPluginShortcut = {
364
+ /** Stable identity, used in duplicate/throw warnings. */
365
+ id: string;
366
+ /** e.g. `"mod+b"`. "mod" is Command on Apple platforms, Control elsewhere. */
367
+ combo: string;
368
+ /** Default `"widget"`: fires only from inside the widget mount. */
369
+ scope?: ShortcutScope;
370
+ /** Returning false skips the binding for this keypress. */
371
+ when?: () => boolean;
372
+ run: () => void;
373
+ };
341
374
  type AgentWidgetSuggestionSelectContext = {
342
375
  suggestion: AgentWidgetResolvedSuggestion;
343
376
  surface: AgentWidgetSuggestionSurface;
@@ -608,6 +641,10 @@ interface AgentWidgetPlugin {
608
641
  * Custom renderer for loading indicator
609
642
  * Return null to use default renderer (or config-based renderer)
610
643
  *
644
+ * Covers the streaming indicator ('inline', 'standalone') and the transcript
645
+ * skeleton shown while a conversation opened from the Messages list loads
646
+ * ('conversation-open').
647
+ *
611
648
  * @example
612
649
  * ```typescript
613
650
  * renderLoadingIndicator: ({ location, defaultRenderer }) => {
@@ -659,6 +696,118 @@ interface AgentWidgetPlugin {
659
696
  * Return null to use default renderer.
660
697
  */
661
698
  renderEventStreamPayload?: (context: EventStreamPayloadRenderContext) => HTMLElement | null;
699
+ /**
700
+ * Replace the complete history ("Messages") navigation contents in either
701
+ * host. Plugins run by priority and the first non-null element wins; null
702
+ * falls through to the default full view, which then applies the first
703
+ * non-null header/row/state hook at each slot.
704
+ *
705
+ * Calling `defaultRenderer()` bypasses this hook only: the default view is
706
+ * built and its lower-level slots still arbitrate, including this plugin's.
707
+ * Return it (or an element containing it) to compose rather than replace.
708
+ *
709
+ * The hook replaces contents, not orchestration. Persona keeps placement,
710
+ * open/close, responsive rail <-> panel movement, inertness, Escape, the
711
+ * confirmation dialogs, live announcements, and focus fallback. Fetch nothing
712
+ * directly: `actions.refresh()` is the only way to reload the list.
713
+ *
714
+ * @example
715
+ * ```typescript
716
+ * renderHistoryView: ({ conversations, actions, presentation, onCleanup }) => {
717
+ * const rail = document.createElement("nav");
718
+ * rail.dataset.presentation = presentation;
719
+ * for (const conversation of conversations) {
720
+ * const row = document.createElement("button");
721
+ * row.textContent = conversation.title;
722
+ * row.addEventListener("click", () => void actions.openConversation(conversation.id));
723
+ * rail.appendChild(row);
724
+ * }
725
+ * const timer = setInterval(() => void actions.refresh(), 60_000);
726
+ * onCleanup(() => clearInterval(timer));
727
+ * return rail;
728
+ * }
729
+ * ```
730
+ */
731
+ renderHistoryView?: (context: AgentWidgetRenderHistoryViewContext) => HTMLElement | null;
732
+ /**
733
+ * Replace the standard Messages header while retaining its list/state UI.
734
+ * Return null to use the default top bar. A custom header may not remove the
735
+ * keyboard close path or falsify the resolved open state.
736
+ */
737
+ renderHistoryHeader?: (context: AgentWidgetRenderHistoryHeaderContext) => HTMLElement | null;
738
+ /**
739
+ * Replace one conversation row while retaining standard paging/grouping.
740
+ * Return null to use the default row.
741
+ */
742
+ renderHistoryConversation?: (context: AgentWidgetRenderHistoryConversationContext) => HTMLElement | null;
743
+ /**
744
+ * Replace loading, empty, error, authentication, rate-limit, or recovery
745
+ * content in the list region. Return null to use the default block.
746
+ */
747
+ renderHistoryState?: (context: AgentWidgetRenderHistoryStateContext) => HTMLElement | null;
748
+ /**
749
+ * Replace the transcript-level error surface shown when opening a
750
+ * conversation from the Messages list fails. Plugins run by priority and
751
+ * the first non-null element wins; null falls through to the default block.
752
+ *
753
+ * Persona keeps the centered transcript column, the alert role, and the
754
+ * composer gate around the returned element. `retry`/`back` are the only
755
+ * exits: both route through the token-guarded open flow, so do not fetch
756
+ * directly. `back` is absent when there is no Messages surface to return
757
+ * to; do not render a back affordance without it.
758
+ */
759
+ renderHistoryOpenError?: (context: AgentWidgetRenderHistoryOpenErrorContext) => HTMLElement | null;
760
+ /**
761
+ * Contribute navigation sections to the history rail, stacked around the
762
+ * conversation list in `placement` order. Rail only: the panel presentation
763
+ * renders none of them, and `features.history.rail.sections` (config) comes
764
+ * first inside each bucket, then plugins in plugin order.
765
+ *
766
+ * `render` is re-invoked with the new `collapsed` value whenever the rail
767
+ * collapses or expands, and its return replaces the previous content;
768
+ * returning null renders nothing for that state. A throwing `render` warns
769
+ * once and drops that section only, leaving the rest of the rail alone. An id
770
+ * a config section already owns is dropped with a warning.
771
+ *
772
+ * Keep heavy UI in the host bundle: `render` may return a skeleton and
773
+ * hydrate it after the host's own dynamic import resolves.
774
+ *
775
+ * @example
776
+ * ```typescript
777
+ * railSections: [
778
+ * {
779
+ * id: "pinned",
780
+ * title: "Pinned",
781
+ * render: ({ collapsed, actions }) => {
782
+ * if (collapsed) return null;
783
+ * const list = document.createElement("div");
784
+ * const row = document.createElement("button");
785
+ * row.textContent = "Weekly report";
786
+ * row.addEventListener("click", () => void actions.openConversation("c1"));
787
+ * list.appendChild(row);
788
+ * return list;
789
+ * }
790
+ * }
791
+ * ]
792
+ * ```
793
+ */
794
+ railSections?: AgentWidgetRailSection[];
795
+ /**
796
+ * Keyboard shortcuts registered for the lifetime of each widget instance the
797
+ * plugin is active in, and unregistered on its teardown. `combo` is written
798
+ * as `"mod+b"` / `"mod+shift+k"`, where "mod" is Command on Apple platforms
799
+ * and Control elsewhere. `scope` defaults to `"widget"` (only while focus is
800
+ * inside the mount); `when` returning false skips the keypress. A combo
801
+ * another binding already owns warns and is ignored, first registration wins.
802
+ *
803
+ * @example
804
+ * ```typescript
805
+ * shortcuts: [
806
+ * { id: "open-inbox", combo: "mod+shift+i", run: () => openInbox() }
807
+ * ]
808
+ * ```
809
+ */
810
+ shortcuts?: AgentWidgetPluginShortcut[];
662
811
  /**
663
812
  * Called when plugin is registered
664
813
  */
@@ -817,6 +966,10 @@ interface SemanticTokens {
817
966
  }
818
967
  interface ComponentTokenSet {
819
968
  background?: TokenReference<'color'>;
969
+ /**
970
+ * Text and glyph color on `background`. `HeaderTokens` also derives its
971
+ * unset text, icon, and border colors from this pair.
972
+ */
820
973
  foreground?: TokenReference<'color'>;
821
974
  border?: TokenReference<'color'>;
822
975
  borderRadius?: TokenReference<'radius'>;
@@ -844,6 +997,15 @@ interface LauncherTokens extends ComponentTokenSet {
844
997
  size: string;
845
998
  iconSize: string;
846
999
  shadow: TokenReference<'shadow'>;
1000
+ /**
1001
+ * Stroke weight of the launcher glyphs, the agent icon and the
1002
+ * call-to-action arrow alike. Unitless, and must be a STRING (`"1.75"`,
1003
+ * never `1.75`: the token resolver silently skips numbers). Applied as CSS,
1004
+ * so it beats the attribute the icons render with. Inert for emoji / image
1005
+ * launchers, which have no svg.
1006
+ * @default "1.5", matching the header's controlStrokeWidth
1007
+ */
1008
+ iconStrokeWidth?: string;
847
1009
  }
848
1010
  interface PanelTokens extends ComponentTokenSet {
849
1011
  width: string;
@@ -864,28 +1026,212 @@ interface TextStyleTokens {
864
1026
  letterSpacing?: string;
865
1027
  color?: TokenReference<'color'>;
866
1028
  }
1029
+ /**
1030
+ * Header band tokens. `background` plus `foreground` (inherited from
1031
+ * `ComponentTokenSet`) is the pair that colors the band: `foreground` anchors
1032
+ * the header text, and every text, action-icon, and border color the theme
1033
+ * leaves unset derives from the pair. Derivation only fills unset keys, so an
1034
+ * explicit key always wins, and `iconBackground` / `iconForeground` (the avatar
1035
+ * tile) keep their own defaults rather than deriving.
1036
+ */
867
1037
  interface HeaderTokens extends ComponentTokenSet {
868
1038
  background: TokenReference<'color'>;
869
- border: TokenReference<'color'>;
1039
+ /**
1040
+ * Hairline under the header. Unset, it derives as
1041
+ * `color-mix(in srgb, foreground 14%, background)`, then the divider color.
1042
+ */
1043
+ border?: TokenReference<'color'>;
870
1044
  borderRadius: TokenReference<'radius'>;
871
1045
  /** Background of the rounded avatar tile next to the title (Lucide / emoji / image). */
872
1046
  iconBackground: TokenReference<'color'>;
873
1047
  /** Foreground (glyph stroke or emoji text) on the header avatar tile. */
874
1048
  iconForeground: TokenReference<'color'>;
875
- /** Legacy alias of `title.color`; `title.color` wins when both are set. */
876
- titleForeground: TokenReference<'color'>;
877
- /** Legacy alias of `subtitle.color`; `subtitle.color` wins when both are set. */
878
- subtitleForeground: TokenReference<'color'>;
1049
+ /**
1050
+ * Legacy alias of `title.color`; `title.color` wins when both are set.
1051
+ * Unset, the title takes `foreground`, then the primary color.
1052
+ */
1053
+ titleForeground?: TokenReference<'color'>;
1054
+ /**
1055
+ * Legacy alias of `subtitle.color`; `subtitle.color` wins when both are set.
1056
+ * Unset, the subtitle takes `color-mix(in srgb, foreground 72%, background)`,
1057
+ * then the muted text color.
1058
+ */
1059
+ subtitleForeground?: TokenReference<'color'>;
879
1060
  /** Header title typography (next to the icon, or minimal layout title). */
880
1061
  title?: TextStyleTokens;
881
1062
  /** Header subtitle typography, for the line under the title. */
882
1063
  subtitle?: TextStyleTokens;
883
- /** Default color for clear / close icon buttons when launcher overrides are unset. */
884
- actionIconForeground: TokenReference<'color'>;
1064
+ /**
1065
+ * Default color for clear / close icon buttons when launcher overrides are
1066
+ * unset. Itself unset, it takes the same
1067
+ * `color-mix(in srgb, foreground 72%, background)` as the subtitle, then the
1068
+ * muted text color.
1069
+ */
1070
+ actionIconForeground?: TokenReference<'color'>;
1071
+ /**
1072
+ * Edge of every header icon button: close, clear chat, `trailingActions`, and
1073
+ * the Messages toggle. Per-control config keys (`launcher.closeButtonSize`,
1074
+ * `launcher.clearChat.size`) still win. Coarse pointers floor the hit area at
1075
+ * 40px regardless. @default "32px"
1076
+ */
1077
+ controlSize?: string;
1078
+ /** Glyph box inside a header control. @default "20px" */
1079
+ controlIconSize?: string;
1080
+ /**
1081
+ * Stroke weight of the glyph inside a header control. Unitless, as an SVG
1082
+ * stroke-width (e.g. `"1.75"`). Sparse-viewBox glyphs (the close X) render
1083
+ * at 0.7 of it so their heavier visible weight still matches a dense
1084
+ * sibling. @default "1.5"
1085
+ */
1086
+ controlStrokeWidth?: string;
885
1087
  /** Box-shadow on the header (e.g., a fade shadow to replace the default border). */
886
1088
  shadow?: string;
887
1089
  /** Override the header bottom border (e.g., `none`). */
888
1090
  borderBottom?: string;
1091
+ /**
1092
+ * Floor for the header strip's height (e.g. `"56px"`). Pin it together with
1093
+ * `components.history.railHeader.minHeight` so the Messages rail header and
1094
+ * the conversation header read as one continuous band.
1095
+ */
1096
+ minHeight?: string;
1097
+ }
1098
+ /** Messages (conversation history) surfaces. */
1099
+ interface HistoryTokens {
1100
+ /**
1101
+ * The Messages rail's own top strip, which runs beside the widget header
1102
+ * when `features.history.presentation` resolves to `rail`.
1103
+ */
1104
+ railHeader?: {
1105
+ /** Strip background. Defaults to the rail's surface color. */
1106
+ background?: TokenReference<'color'>;
1107
+ /** Full border-bottom shorthand (raw CSS, e.g. `"1px solid #e5e7eb"`). @default "0" */
1108
+ border?: string;
1109
+ /** Strip height floor. Defaults to `components.header.minHeight`, then 56px. */
1110
+ minHeight?: string;
1111
+ /**
1112
+ * The strip's view title ("Messages"). 14px/600 in the text color by
1113
+ * default; set the type keys to restyle it.
1114
+ */
1115
+ title?: TextStyleTokens;
1116
+ };
1117
+ /**
1118
+ * The "Conversations" heading over the list block. Visible in rail
1119
+ * presentation only (the panel keeps it screen-reader-only). 14px/600 in
1120
+ * the text color by default. Every key is pinned in the widget CSS, so
1121
+ * host-page heading rules never restyle it.
1122
+ */
1123
+ listHeading?: TextStyleTokens;
1124
+ /**
1125
+ * The muted sub-headers inside the Messages surface: date groups ("Today",
1126
+ * "Yesterday") and rail nav section titles (`features.history.rail.sections`
1127
+ * `title`, e.g. "Workspace"). 13px/500 in the muted text color in the rail
1128
+ * (the panel keeps date groups screen-reader-only). Every key is pinned in
1129
+ * the widget CSS, so host-page heading rules never restyle them.
1130
+ */
1131
+ groupHeading?: TextStyleTokens;
1132
+ /**
1133
+ * The floating rail that a collapsed
1134
+ * `features.history.rail.collapsedBehavior: "overlay"` opens on hover. It
1135
+ * hangs below the trigger in the conversation header; its width and edge
1136
+ * stay `features.history.rail` geometry, not tokens.
1137
+ */
1138
+ overlay?: {
1139
+ /** Gap from the trigger, the docked edge, and the bottom. @default "8px" */
1140
+ margin?: string;
1141
+ /** Corner radius, on all four corners. @default "16px" */
1142
+ borderRadius?: string;
1143
+ /** Elevation over the conversation. @default "0 12px 40px rgba(0, 0, 0, 0.25)" */
1144
+ shadow?: string;
1145
+ /** Surface behind the rail. Defaults to the rail's own surface color. */
1146
+ background?: TokenReference<'color'>;
1147
+ };
1148
+ /**
1149
+ * Destructive action text (row Delete, "Delete all conversations").
1150
+ * Defaults to `palette.colors.error.600` in light schemes and a lighter
1151
+ * red in the built-in dark theme so the 14px labels keep AA contrast.
1152
+ */
1153
+ dangerForeground?: TokenReference<'color'>;
1154
+ /**
1155
+ * The delete/forget confirmation dialog the shell shows for destructive
1156
+ * history actions. The danger pair is always emitted (`--persona-danger`
1157
+ * / `--persona-danger-fg`); scrim and shadow keep the built-in look when
1158
+ * unset.
1159
+ */
1160
+ confirm?: {
1161
+ /**
1162
+ * Destructive button fill. Defaults to `palette.colors.error.700` in
1163
+ * light schemes and `error.600` in the built-in dark theme.
1164
+ */
1165
+ dangerBackground?: TokenReference<'color'>;
1166
+ /** Destructive button label. @default "#ffffff" */
1167
+ dangerForeground?: TokenReference<'color'>;
1168
+ /** Overlay behind the dialog. @default "rgba(15, 23, 42, 0.45)" */
1169
+ scrim?: TokenReference<'color'>;
1170
+ /** Card elevation (raw CSS shadow). */
1171
+ shadow?: string;
1172
+ };
1173
+ /** The per-row overflow menu in the Messages list (rail and panel). */
1174
+ menu?: {
1175
+ /**
1176
+ * Menu surface. Defaults to the list surface lifted 8% toward white so
1177
+ * the menu reads as elevated in dark schemes.
1178
+ */
1179
+ background?: TokenReference<'color'>;
1180
+ /** Corner radius. @default "12px" */
1181
+ borderRadius?: string;
1182
+ };
1183
+ /**
1184
+ * Enter/exit motion of the Messages surface. Only the body slides; the bar
1185
+ * is persistent chrome and never animates. Durations are milliseconds and 0
1186
+ * disables that leg; `prefers-reduced-motion` always wins over these.
1187
+ */
1188
+ motion?: {
1189
+ /** Entrance slide-and-fade duration: bare ms number, or a CSS time string. @default 180 */
1190
+ enterDurationMs?: number | string;
1191
+ /** Entrance easing. @default "cubic-bezier(0, 0, 0.2, 1)" */
1192
+ enterEasing?: string;
1193
+ /** Exit slide-and-fade duration: bare ms number, or a CSS time string. @default 160 */
1194
+ exitDurationMs?: number | string;
1195
+ /** Exit easing. @default "cubic-bezier(0.4, 0, 1, 1)" */
1196
+ exitEasing?: string;
1197
+ };
1198
+ }
1199
+ /**
1200
+ * The portaled icon-control tooltip (header controls, composer buttons) and
1201
+ * its trailing shortcut hint chip. Unset keys keep the built-in dark look.
1202
+ */
1203
+ interface TooltipTokens {
1204
+ /** Bubble and arrow fill. @default "#111827" */
1205
+ background?: TokenReference<'color'>;
1206
+ /** Label color. @default "#ffffff" */
1207
+ foreground?: TokenReference<'color'>;
1208
+ /** Trailing shortcut hint color. @default "rgba(255, 255, 255, 0.55)" */
1209
+ hintForeground?: TokenReference<'color'>;
1210
+ /** Bubble corner radius. Defaults to `palette.radius.sm`. */
1211
+ borderRadius?: TokenReference<'radius'>;
1212
+ /** Label type size. @default "12px" */
1213
+ fontSize?: string;
1214
+ /** Bubble inset, full CSS shorthand. @default "6px 12px" */
1215
+ padding?: TokenReference<'spacing'>;
1216
+ /** Bubble box-shadow (token ref or raw CSS, e.g. `none`). */
1217
+ shadow?: string;
1218
+ /** Render the caret pointing at the control. @default true */
1219
+ arrow?: boolean;
1220
+ /** Wrap width. @default "min(320px, calc(100vw - 16px))" */
1221
+ maxWidth?: string;
1222
+ }
1223
+ /**
1224
+ * The hover-revealed action row under a message (copy, vote, read aloud).
1225
+ * Unset keys inherit the shared ghost icon-button wash, which is already
1226
+ * scheme-aware, so most themes never need this group.
1227
+ */
1228
+ interface MessageActionsTokens {
1229
+ /** Hover fill. Defaults to `components.button.ghost.hoverBackground`. */
1230
+ hoverBackground?: TokenReference<'color'>;
1231
+ /** Hover icon color. Defaults to `semantic.colors.text`. */
1232
+ hoverForeground?: TokenReference<'color'>;
1233
+ /** Button corner radius. Defaults to `palette.radius.md`. */
1234
+ borderRadius?: TokenReference<'radius'>;
889
1235
  }
890
1236
  interface MessageTokens {
891
1237
  user: {
@@ -1231,7 +1577,13 @@ interface ComponentTokens {
1231
1577
  launcher: LauncherTokens;
1232
1578
  panel: PanelTokens;
1233
1579
  header: HeaderTokens;
1580
+ /** Messages rail chrome. */
1581
+ history?: HistoryTokens;
1582
+ /** Portaled icon-control tooltip and its shortcut hint chip. */
1583
+ tooltip?: TooltipTokens;
1234
1584
  message: MessageTokens;
1585
+ /** Hover-revealed per-message action row (copy, vote, read aloud). */
1586
+ messageActions?: MessageActionsTokens;
1235
1587
  /** Welcome / intro card shown above the message list. */
1236
1588
  introCard?: IntroCardTokens;
1237
1589
  /** Markdown surfaces (chat + artifact pane). */
@@ -1730,6 +2082,101 @@ type TargetResolver = (id: string) => {
1730
2082
  payload: Record<string, unknown>;
1731
2083
  };
1732
2084
 
2085
+ /**
2086
+ * History provider seam (`docs/visitor-history-implementation-plan.md` D9).
2087
+ * Session/UI history code depends on this interface, never on
2088
+ * `AgentWidgetClient`.
2089
+ *
2090
+ * The module stays under `internal/` but its contract is public: `index-core.ts`
2091
+ * re-exports these declarations so integrators can implement
2092
+ * `features.history.provider`. The provider REGISTRY beside it stays private.
2093
+ */
2094
+
2095
+ /** Fixed for the lifetime of one opened history view/action chain. */
2096
+ interface HistoryOperationContext {
2097
+ scope: HistoryScope;
2098
+ }
2099
+ /**
2100
+ * An authorized-but-not-yet-applied conversation activation. The provider must
2101
+ * not mutate the active chat until `commit()`.
2102
+ */
2103
+ interface PreparedHistoryActivation {
2104
+ conversationId: string;
2105
+ conversationRevision: string;
2106
+ /** Apply the already-authorized provider-specific transport/session binding. */
2107
+ commit(): void | Promise<void>;
2108
+ /** Idempotently abandon a stale/superseded activation without changing chat. */
2109
+ discard(): void;
2110
+ }
2111
+ interface HistoryListOptions {
2112
+ cursor?: string;
2113
+ limit?: number;
2114
+ targetId?: string;
2115
+ context: HistoryOperationContext;
2116
+ }
2117
+ interface HistoryListResult {
2118
+ items: HistoryConversationSummary[];
2119
+ nextCursor: string | null;
2120
+ }
2121
+ interface HistoryPageOptions {
2122
+ cursor?: string;
2123
+ /** Lets the provider synthesize stable timestamps across page boundaries. */
2124
+ beforeCreatedAt?: string;
2125
+ context: HistoryOperationContext;
2126
+ }
2127
+ interface HistoryPageResult {
2128
+ summary: HistoryConversationSummary;
2129
+ /** Already mapped; the visitor-visible projection lives in `content`. */
2130
+ messages: AgentWidgetMessage[];
2131
+ conversationRevision: string;
2132
+ /** Follow for the next older page. `null` at the start of the transcript. */
2133
+ nextCursor: string | null;
2134
+ }
2135
+ interface HistoryDeleteAllOptions {
2136
+ /** Absent means the whole authorized scope, never the UI default. */
2137
+ targetId?: string;
2138
+ context: HistoryOperationContext;
2139
+ }
2140
+ /** The contract a `features.history.provider` implementation satisfies. */
2141
+ interface HistoryProvider {
2142
+ readonly capabilities: {
2143
+ scopes: readonly HistoryScope[];
2144
+ };
2145
+ getIdentityStatus(): HistoryIdentityStatus;
2146
+ subscribeIdentityStatus(callback: (status: HistoryIdentityStatus) => void): () => void;
2147
+ list(opts: HistoryListOptions): Promise<HistoryListResult>;
2148
+ getPage(id: string, opts: HistoryPageOptions): Promise<HistoryPageResult>;
2149
+ prepareOpen(id: string, opts: {
2150
+ context: HistoryOperationContext;
2151
+ }): Promise<PreparedHistoryActivation>;
2152
+ prepareStartNew(opts: {
2153
+ context: HistoryOperationContext;
2154
+ }): Promise<PreparedHistoryActivation>;
2155
+ delete(id: string, opts: {
2156
+ context: HistoryOperationContext;
2157
+ }): Promise<void>;
2158
+ deleteAll(opts: HistoryDeleteAllOptions): Promise<{
2159
+ deleted: number;
2160
+ }>;
2161
+ /**
2162
+ * Optional capability: visitor-scoped rename/star. Absence hides every
2163
+ * update affordance (star glyphs, built-in title-menu actions). A user-set
2164
+ * title pins: the provider must never let a later auto-generated title
2165
+ * overwrite one set through this call.
2166
+ */
2167
+ update?(id: string, patch: HistoryConversationPatch, opts: {
2168
+ context: HistoryOperationContext;
2169
+ }): Promise<HistoryConversationSummary>;
2170
+ /**
2171
+ * Optional capability. Absence hides "forget this device". Resolves (never
2172
+ * rejects) on remote failure; credentials are cleared in `finally` either way.
2173
+ */
2174
+ resetDevice?(): Promise<{
2175
+ remoteRevocationConfirmed: boolean;
2176
+ }>;
2177
+ subscribeAvailability?(callback: (available: boolean) => void): () => void;
2178
+ }
2179
+
1733
2180
  /**
1734
2181
  * Curated registry of lucide icons available to `renderLucideIcon`.
1735
2182
  *
@@ -1814,6 +2261,7 @@ declare const LUCIDE_ICONS: {
1814
2261
  readonly "ellipsis-vertical": IconNode;
1815
2262
  readonly menu: IconNode;
1816
2263
  readonly house: IconNode;
2264
+ readonly "panel-left": IconNode;
1817
2265
  readonly plus: IconNode;
1818
2266
  readonly minus: IconNode;
1819
2267
  readonly pencil: IconNode;
@@ -2975,6 +3423,8 @@ type AgentWidgetArtifactsLayoutConfig = {
2975
3423
  documentToolbarToggleActiveBackground?: string;
2976
3424
  /** Active view/source toggle border color. Sets `--persona-artifact-doc-toggle-active-border`. */
2977
3425
  documentToolbarToggleActiveBorderColor?: string;
3426
+ /** Active view/source toggle icon color (defaults to `documentToolbarIconColor`). Sets `--persona-artifact-doc-toggle-active-color`. */
3427
+ documentToolbarToggleActiveColor?: string;
2978
3428
  /** 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. */
2979
3429
  showExpandToggle?: boolean;
2980
3430
  /** Show the copy control in the `default` toolbar preset (the `document` preset always shows it). Default: false. */
@@ -2987,13 +3437,20 @@ type AgentWidgetArtifactsLayoutConfig = {
2987
3437
  /** Tab fade width (CSS length). @default 24px */
2988
3438
  tabFadeSize?: string;
2989
3439
  /**
2990
- * Invoked when the document toolbar Refresh control is used (before the pane re-renders).
2991
- * Use to replay `connectStream`, refetch, etc.
3440
+ * Invoked when the document toolbar Refresh control is used (before the pane
3441
+ * re-renders). The button renders only while this handler is set: the refresh
3442
+ * glyph universally reads "reload this preview" (Claude artifacts, v0), so
3443
+ * keep the handler scoped to refreshing the rendered artifact — regenerating
3444
+ * content or resetting the conversation belongs to message-level or
3445
+ * conversation-level controls, not artifact chrome.
2992
3446
  */
2993
3447
  onDocumentToolbarRefresh?: () => void | Promise<void>;
2994
3448
  /**
2995
3449
  * Optional copy dropdown entries (shown when `documentToolbarShowCopyChevron` is true and this array is non-empty).
2996
3450
  * The main Copy control still performs default copy unless `onDocumentToolbarCopyMenuSelect` handles everything.
3451
+ * Without a handler, built-in ids work out of the box: `download` saves the
3452
+ * artifact (real filename/MIME for file artifacts, `<title>.md` otherwise);
3453
+ * `markdown`/`md` and `json`/`source` copy that form to the clipboard.
2997
3454
  */
2998
3455
  documentToolbarCopyMenuItems?: Array<{
2999
3456
  id: string;
@@ -3001,13 +3458,24 @@ type AgentWidgetArtifactsLayoutConfig = {
3001
3458
  }>;
3002
3459
  /**
3003
3460
  * When set, invoked for the chevron menu (and can override default copy per `actionId`).
3461
+ * Return `false` to fall through to the widget's built-in behavior for that
3462
+ * action id (`download` saves the artifact; copy ids copy); any other return
3463
+ * value keeps the handler's outcome as final.
3004
3464
  */
3005
3465
  onDocumentToolbarCopyMenuSelect?: (payload: {
3006
3466
  actionId: string;
3007
3467
  artifactId: string | null;
3008
3468
  markdown: string;
3009
3469
  jsonPayload: string;
3010
- }) => void | Promise<void>;
3470
+ /** File metadata when the selected artifact is a previewable file. */
3471
+ file?: PersonaArtifactFileMeta;
3472
+ /** Filename the built-in download would use (file basename, or `<title>.md`). */
3473
+ suggestedFilename: string;
3474
+ /** MIME type paired with `suggestedFilename`. */
3475
+ mime: string;
3476
+ /** Raw content the built-in download would write (unfenced source for file artifacts). */
3477
+ content: string;
3478
+ }) => void | boolean | Promise<void | boolean>;
3011
3479
  };
3012
3480
  /**
3013
3481
  * Where the artifact body renders by default. Every mode shows the compact
@@ -3850,6 +4318,11 @@ type AgentWidgetFeatureFlags = {
3850
4318
  * pills + optional free-text input.
3851
4319
  */
3852
4320
  askUserQuestion?: AgentWidgetAskUserQuestionFeature;
4321
+ /**
4322
+ * Per-visitor conversation history. Client token mode only; disabled by
4323
+ * default so no capability flag is sent on init and no UI mounts.
4324
+ */
4325
+ history?: AgentWidgetHistoryFeature;
3853
4326
  /**
3854
4327
  * Built-in `suggest_replies` follow-ups. When the assistant invokes the
3855
4328
  * tool, the widget shows the suggestions using `suggestions.followUps` and
@@ -4042,6 +4515,604 @@ type AgentWidgetAskUserQuestionFeature = {
4042
4515
  /** Style overrides for the sheet and pills. */
4043
4516
  styles?: AgentWidgetAskUserQuestionStyles;
4044
4517
  };
4518
+ /**
4519
+ * Copy overrides for the visitor-facing conversation history surface. These are
4520
+ * the widget's only localization mechanism for history, so every user-visible
4521
+ * history string is listed here.
4522
+ */
4523
+ interface AgentWidgetHistoryCopy {
4524
+ /** Title of the history view. Defaults to "Messages". */
4525
+ viewTitle?: string;
4526
+ /** Heading shown when the visitor has no stored conversations. */
4527
+ emptyTitle?: string;
4528
+ /** Body text shown when the visitor has no stored conversations. */
4529
+ emptyDescription?: string;
4530
+ /** Heading shown when a history request fails. */
4531
+ errorTitle?: string;
4532
+ /** Body text shown when a history request fails. */
4533
+ errorDescription?: string;
4534
+ /** Label for the retry action on the error state. */
4535
+ retryLabel?: string;
4536
+ /** Heading shown after a 429 rate-limited history response. */
4537
+ rateLimitedTitle?: string;
4538
+ /** Body text shown after a 429 rate-limited history response. */
4539
+ rateLimitedDescription?: string;
4540
+ /** Confirmation prompt before deleting a single conversation. */
4541
+ deleteConversationConfirm?: string;
4542
+ /** Confirmation prompt before deleting every conversation in the active scope. */
4543
+ clearHistoryConfirm?: string;
4544
+ /** Confirmation prompt before detaching this browser from its history identity. */
4545
+ resetIdentityConfirm?: string;
4546
+ /** Label for the action that starts a new server conversation. */
4547
+ newConversationLabel?: string;
4548
+ /** Label for the action that prepends the previous transcript page. */
4549
+ showEarlierMessagesLabel?: string;
4550
+ /** Accessible label for the transcript skeleton while a conversation loads. */
4551
+ openConversationLoadingLabel?: string;
4552
+ /** Body text when a selected conversation failed to load. */
4553
+ openConversationErrorTitle?: string;
4554
+ /** Label for the retry action after a conversation failed to load. */
4555
+ openConversationRetryLabel?: string;
4556
+ /** Label for the return-to-messages action after a conversation failed to load. */
4557
+ openConversationBackLabel?: string;
4558
+ /** Status notice after a deleted conversation was recovered into a fresh one. */
4559
+ conversationDeletedNotice?: string;
4560
+ /** Status notice after this browser was detached from its history identity. */
4561
+ identityResetNotice?: string;
4562
+ /** Status notice when a local reset succeeded but server revocation was unconfirmed. */
4563
+ identityResetUnconfirmedNotice?: string;
4564
+ /** Pinned group heading for starred conversations. */
4565
+ groupStarred?: string;
4566
+ /** Time-group heading for conversations updated today. */
4567
+ groupToday?: string;
4568
+ /** Time-group heading for conversations updated yesterday. */
4569
+ groupYesterday?: string;
4570
+ /** Time-group heading for the trailing 7-day window. */
4571
+ groupPrevious7Days?: string;
4572
+ /** Time-group heading for the trailing 30-day window. */
4573
+ groupPrevious30Days?: string;
4574
+ /** Time-group heading for older conversations, grouped by month and year. */
4575
+ groupMonthYear?: string;
4576
+ /** Scope title when history is limited to this browser. */
4577
+ browserOnlyTitle?: string;
4578
+ /** Scope description when history is limited to this browser. */
4579
+ browserOnlyDescription?: string;
4580
+ /** Scope title while an identity proof is being resolved. */
4581
+ verifyingTitle?: string;
4582
+ /** Scope description while an identity proof is being resolved. */
4583
+ verifyingDescription?: string;
4584
+ /** Scope title when history is available across signed-in devices. */
4585
+ verifiedTitle?: string;
4586
+ /** Scope description when history is available across signed-in devices. */
4587
+ verifiedDescription?: string;
4588
+ /** Scope title when the visitor must sign in again to view account history. */
4589
+ authenticationRequiredTitle?: string;
4590
+ /** Scope description when the visitor must sign in again to view account history. */
4591
+ authenticationRequiredDescription?: string;
4592
+ /** Scope title when the host identity provider threw or rejected. */
4593
+ identityProviderFailedTitle?: string;
4594
+ /** Scope description when the host identity provider threw or rejected. */
4595
+ identityProviderFailedDescription?: string;
4596
+ /** Scope title when the server did not admit a supplied identity proof. */
4597
+ proofNotAdmittedTitle?: string;
4598
+ /** Scope description when the server did not admit a supplied identity proof. */
4599
+ proofNotAdmittedDescription?: string;
4600
+ /** Label for the action that retries identity resolution. */
4601
+ retryIdentityLabel?: string;
4602
+ /** Accessible name of the header control that opens history. */
4603
+ openHistoryLabel?: string;
4604
+ /** Accessible name of that control while a turn is streaming or resuming. */
4605
+ openHistoryBusyLabel?: string;
4606
+ /** Least-destructive action in every history confirmation dialog. */
4607
+ confirmCancelLabel?: string;
4608
+ /** Heading of the delete-one confirmation. */
4609
+ deleteConversationConfirmTitle?: string;
4610
+ /** Confirming action of the delete-one confirmation. */
4611
+ deleteConversationConfirmLabel?: string;
4612
+ /** Heading of the delete-all confirmation. */
4613
+ clearHistoryConfirmTitle?: string;
4614
+ /** Confirming action of the delete-all confirmation. */
4615
+ clearHistoryConfirmLabel?: string;
4616
+ /** Delete-all body used when the resolved scope is the signed-in user. */
4617
+ clearHistoryVerifiedConfirm?: string;
4618
+ /** Heading of the forget-this-device confirmation. */
4619
+ resetIdentityConfirmTitle?: string;
4620
+ /** Confirming action of the forget-this-device confirmation. */
4621
+ resetIdentityConfirmLabel?: string;
4622
+ /** Panel back control; returns to the surface that opened Messages. */
4623
+ backLabel?: string;
4624
+ /** Rail close control, shown only when the rail is not collapsible. */
4625
+ closeLabel?: string;
4626
+ /** Rail collapse toggle while the rail is expanded. */
4627
+ collapseLabel?: string;
4628
+ /** Rail collapse toggle while the rail is collapsed to icons. */
4629
+ expandLabel?: string;
4630
+ /** Accessible name of the docked rail's drag-resize handle. */
4631
+ resizeLabel?: string;
4632
+ /** Accessible status while the first page loads. */
4633
+ loadingLabel?: string;
4634
+ /** Label of the paging action below the last group. */
4635
+ loadMoreLabel?: string;
4636
+ /** Label of that action while its page is in flight. */
4637
+ loadingMoreLabel?: string;
4638
+ /**
4639
+ * Heading over the conversation list. Visible in rail presentation, where it
4640
+ * carries the list overflow trigger; sr-only in panel presentation.
4641
+ */
4642
+ conversationsTitle?: string;
4643
+ /** Accessible name of the per-row overflow trigger and its menu. */
4644
+ rowActionsLabel?: string;
4645
+ /** Accessible name of the list-level overflow trigger and its menu. */
4646
+ listOptionsLabel?: string;
4647
+ /** Delete item inside the per-row overflow menu. */
4648
+ deleteConversationLabel?: string;
4649
+ /** Delete-all item inside the list overflow menu. */
4650
+ clearHistoryLabel?: string;
4651
+ /** Forget-this-device item inside the list overflow menu. */
4652
+ resetIdentityLabel?: string;
4653
+ /** Row message count. `{count}` placeholder. */
4654
+ messageCountLabel?: string;
4655
+ /** Row message count for exactly one message. */
4656
+ messageCountLabelOne?: string;
4657
+ /** Announced after a single conversation was deleted. */
4658
+ conversationRemovedNotice?: string;
4659
+ /** Announced after every conversation in scope was deleted. */
4660
+ historyClearedNotice?: string;
4661
+ /** Heading shown when history is unavailable for this surface. */
4662
+ unavailableTitle?: string;
4663
+ /** Body text shown when history is unavailable for this surface. */
4664
+ unavailableDescription?: string;
4665
+ /** Heading of the post-deletion replacement-init recovery state. */
4666
+ newConversationRequiredTitle?: string;
4667
+ /** Body text of the post-deletion replacement-init recovery state. */
4668
+ newConversationRequiredDescription?: string;
4669
+ /** Rate-limited wait guidance. `{seconds}` placeholder. */
4670
+ rateLimitedWaitDescription?: string;
4671
+ /** Row-adjacent error after a failed open. */
4672
+ openFailedLabel?: string;
4673
+ /** Row-adjacent error after a failed delete. */
4674
+ deleteFailedLabel?: string;
4675
+ /** Relative time for the most recent bucket. */
4676
+ relativeNow?: string;
4677
+ /** Relative time in minutes. `{value}` placeholder. */
4678
+ relativeMinutes?: string;
4679
+ /** Relative time in hours. `{value}` placeholder. */
4680
+ relativeHours?: string;
4681
+ /** Relative time in days. `{value}` placeholder. */
4682
+ relativeDays?: string;
4683
+ /** Relative time in weeks. `{value}` placeholder. */
4684
+ relativeWeeks?: string;
4685
+ /** Relative time in years. `{value}` placeholder. */
4686
+ relativeYears?: string;
4687
+ }
4688
+ /**
4689
+ * One row in a `features.history.rail.sections` navigation section. Icon
4690
+ * precedence, highest first: `renderIcon`, then `iconUrl`, then `icon`.
4691
+ * Whichever resolves first is built once and reused for the item's lifetime.
4692
+ */
4693
+ interface AgentWidgetHistoryRailSectionItem {
4694
+ /** Stable identity, stamped as `data-persona-rail-item`. */
4695
+ id: string;
4696
+ /** Visible text, and the default `aria-label` of the button. */
4697
+ label: string;
4698
+ /**
4699
+ * Lucide name from the widget's built-in icon registry (see `IconName`). A
4700
+ * name outside the registry warns once and the row renders label-only.
4701
+ */
4702
+ icon?: IconName | (string & {});
4703
+ /** Image URL or data URI, rendered as a decorative `img` in the icon slot. */
4704
+ iconUrl?: string;
4705
+ /** Full custom icon node. Returning null renders the row label-only. */
4706
+ renderIcon?: () => Element | null;
4707
+ /** Small trailing text chip, for a count or a short status word. */
4708
+ badge?: string;
4709
+ /** Invoked on click. A throw is caught and warned once per section. */
4710
+ onSelect: () => void;
4711
+ }
4712
+ /** One navigation section in the history rail, above or below the list. */
4713
+ interface AgentWidgetHistoryRailSection {
4714
+ /** Stable identity, stamped as `data-persona-rail-section`. */
4715
+ id: string;
4716
+ /** Optional heading, styled like a conversation date-group heading. */
4717
+ title?: string;
4718
+ /** Default `"above-conversations"`. */
4719
+ placement?: "above-conversations" | "below-conversations" | "footer";
4720
+ items: AgentWidgetHistoryRailSectionItem[];
4721
+ }
4722
+ /**
4723
+ * Host-defined item in the list overflow menu (the `…` beside the
4724
+ * conversation-list heading). Rendered above the built-in destructive items.
4725
+ */
4726
+ interface AgentWidgetHistoryListAction {
4727
+ /** Stable identity; keeps menu focus keys stable across re-renders. */
4728
+ id: string;
4729
+ label: string;
4730
+ /** Destructive (red) styling like the built-in delete-all. Default false. */
4731
+ danger?: boolean;
4732
+ /** Receives the conversation summaries loaded at selection time. */
4733
+ onSelect: (context: {
4734
+ conversations: HistoryConversationSummary[];
4735
+ }) => void | Promise<void>;
4736
+ }
4737
+ /**
4738
+ * Feature config for per-visitor conversation history. Without a `provider`,
4739
+ * client token mode only: the built-in Runtype backend needs one, so the UI
4740
+ * never renders for proxy/agent sessions. A `provider` lifts that restriction.
4741
+ */
4742
+ interface AgentWidgetHistoryFeature {
4743
+ /** Master switch. Default false: no capability flag on init, no UI. */
4744
+ enabled?: boolean;
4745
+ /**
4746
+ * Custom conversation-history backend. Supply one to run the history UX
4747
+ * (list, open, delete, delete-all, header title binding) against your own
4748
+ * storage in ANY session mode, including a custom `apiUrl` backend with no
4749
+ * client token. Omitted, history falls back to the built-in Runtype backend,
4750
+ * which requires client token mode.
4751
+ *
4752
+ * Pass either an instance or a factory. The factory form is called once per
4753
+ * widget instance, so a single script-tag config object (assembled before
4754
+ * install) can back several widgets without sharing provider state. Passing a
4755
+ * new factory identity through `update()` rebuilds the provider.
4756
+ *
4757
+ * Failures are signalled by throwing `HistoryProviderError` with a `code` from
4758
+ * `HistoryProviderErrorCode`. The view branches on that code alone: it never
4759
+ * reads message text, and an untyped throw degrades to a generic error state.
4760
+ *
4761
+ * `prepareOpen`/`prepareStartNew` resolve BEFORE anything visible changes:
4762
+ * they return a `PreparedHistoryActivation` whose `commit()` applies the
4763
+ * already-authorized binding and whose `discard()` idempotently abandons a
4764
+ * superseded activation, leaving the active chat untouched. The widget calls
4765
+ * exactly one of the two per prepared activation.
4766
+ *
4767
+ * Optional capabilities hide their affordances when absent: no `update`
4768
+ * removes the rename/star actions (including the built-in title-menu `star`),
4769
+ * and no `resetDevice` removes "forget this device".
4770
+ *
4771
+ * The provider's `capabilities.scopes` is authoritative: the widget derives a
4772
+ * default scope (`"verified-user"` when `getIdentityProof` is configured,
4773
+ * otherwise `"browser"`) and narrows it to what the provider advertises, so a
4774
+ * browser-only provider is never asked for a scope it cannot serve. An
4775
+ * explicit `features.history.scope` is a hard request and still fails closed
4776
+ * with `unsupported_scope`. `getIdentityProof` is never called for a supplied
4777
+ * provider, and `HistoryOperationContext` carries only the resolved scope;
4778
+ * report your own identity through `getIdentityStatus()` /
4779
+ * `subscribeIdentityStatus()`, which is what the scope banner and its retry
4780
+ * affordance read.
4781
+ *
4782
+ * Reopening the last conversation after a page reload is the host's job: the
4783
+ * widget's boot resume runs only on the built-in Runtype path, so with a
4784
+ * supplied provider the transcript is restored by the storage adapter while
4785
+ * `getActiveConversationId()` starts null (no active row, no
4786
+ * conversation-bound header title) until something opens a conversation.
4787
+ * Persist the id yourself and call `controller.openConversation(id)` on ready
4788
+ * if you want the last conversation to come back automatically.
4789
+ *
4790
+ * @example
4791
+ * ```js
4792
+ * features: { history: { enabled: true, provider: () => myProvider } }
4793
+ * ```
4794
+ */
4795
+ provider?: HistoryProvider | (() => HistoryProvider);
4796
+ /** Page size for the conversation list (default 25, server max 100). */
4797
+ pageSize?: number;
4798
+ /**
4799
+ * Default history placement. "panel" replaces the conversation surface;
4800
+ * "rail" requests a side navigation host whenever it is at least 720px wide
4801
+ * and collapses to panel below that; "auto" uses rail only for a wide inline
4802
+ * or docked shell and keeps floating launchers panel-based at every width.
4803
+ * Default "panel".
4804
+ */
4805
+ presentation?: "panel" | "rail" | "auto";
4806
+ /**
4807
+ * Geometry of the rail navigation column. `side` picks the edge it docks to
4808
+ * (default "left", beside the conversation); `width` is its fixed width in
4809
+ * px, clamped to 200-400 (default 260). `collapsible` (default true) puts a
4810
+ * collapse toggle in the rail header that shrinks it to a 52px icon rail, and
4811
+ * `defaultCollapsed` (default false) picks the state a visitor who has never
4812
+ * toggled it starts in. The chosen state is remembered per visitor alongside
4813
+ * the other `persistState` keys. Ignored in panel presentation.
4814
+ */
4815
+ rail?: {
4816
+ side?: "left" | "right";
4817
+ width?: number;
4818
+ collapsible?: boolean;
4819
+ defaultCollapsed?: boolean;
4820
+ /**
4821
+ * Drag handle on the docked rail's divider edge, resizing it live within
4822
+ * the same 200 to 400 clamp `width` takes. Default false. The chosen width
4823
+ * is remembered per visitor alongside the other `persistState` keys and
4824
+ * outranks a later `width` update, the way the collapsed state does; the
4825
+ * floating overlay rail inherits it but is never itself resizable, and a
4826
+ * collapsed icon column ignores it until it expands again.
4827
+ */
4828
+ resizable?: boolean;
4829
+ /**
4830
+ * Shape of the COLLAPSED rail. `"icon-rail"` (default) keeps the 52px icon
4831
+ * column beside the conversation. `"overlay"` removes the column entirely:
4832
+ * a trigger takes the leading edge of the conversation header, hovering or
4833
+ * tapping it floats the expanded rail over the conversation, and clicking
4834
+ * it pins the rail back open. The floating rail is transient, so leaving
4835
+ * it, Escape, a click outside, or selecting a conversation all dismiss it;
4836
+ * its own header toggle docks it instead, being the control the pointer
4837
+ * finds there. Geometry follows `width` and `side`; the collapsed rail's
4838
+ * chunk is not loaded until the first hover. Ignored when `collapsible` is
4839
+ * false or in panel presentation.
4840
+ */
4841
+ collapsedBehavior?: "icon-rail" | "overlay";
4842
+ /**
4843
+ * One brand declaration, placed in both of the rail's identity spots: the
4844
+ * header's heading area when expanded (the mark leading, `copy.viewTitle`
4845
+ * beside it as the wordmark), and the collapse toggle's rest face when the
4846
+ * rail is collapsed, where hover and keyboard focus reveal the panel glyph
4847
+ * under it. A coarse pointer keeps the glyph, having no hover to reveal it
4848
+ * with. Icon precedence, highest first: `render`, then `iconUrl`, then
4849
+ * `icon`. `render` receives the placement through `ctx.collapsed` (`true`
4850
+ * is the collapsed toggle face) and may return null to skip that spot.
4851
+ * `renderHeader` outranks this for the heading area; the collapsed face is
4852
+ * this slot's alone. Decorative either way: the view's accessible name
4853
+ * still comes from `copy.viewTitle`, and the toggle keeps its own label.
4854
+ * Ignored in panel presentation.
4855
+ */
4856
+ brand?: {
4857
+ /** Lucide name from the built-in registry; an unknown one warns once. */
4858
+ icon?: IconName | (string & {});
4859
+ /** Image URL or data URI, rendered as a decorative `img`. */
4860
+ iconUrl?: string;
4861
+ /** Full custom node. A throw warns once and drops the brand. */
4862
+ render?: (context: {
4863
+ collapsed: boolean;
4864
+ }) => Element | null;
4865
+ };
4866
+ /**
4867
+ * Full override of the rail header's identity area, outranking `brand`
4868
+ * there, re-invoked whenever the collapsed state changes. Return null to
4869
+ * leave the area empty, which leaves the collapse toggle standing alone.
4870
+ * The accessible name of the
4871
+ * view comes from `copy.viewTitle` either way: the heading stays in the
4872
+ * DOM, visually hidden, whenever this renders. Ignored in panel
4873
+ * presentation.
4874
+ */
4875
+ renderHeader?: (context: {
4876
+ collapsed: boolean;
4877
+ defaultTitle: string;
4878
+ }) => Element | null;
4879
+ /**
4880
+ * Extra navigation sections stacked around the conversation list, in array
4881
+ * order within each `placement` bucket. Rail-only in this release: a move
4882
+ * into panel presentation removes them and a move back re-renders them.
4883
+ */
4884
+ sections?: AgentWidgetHistoryRailSection[];
4885
+ /**
4886
+ * Keyboard shortcut for the collapse toggle, e.g. `"mod+b"` ("mod" is
4887
+ * Command on Apple platforms, Control elsewhere). Undefined by default, so
4888
+ * an embedded widget never claims a host page's keys. The same declaration
4889
+ * drives the binding, the toggle's tooltip hint chip, and its
4890
+ * `aria-keyshortcuts`.
4891
+ */
4892
+ collapseShortcut?: string | false;
4893
+ /**
4894
+ * Where `collapseShortcut` listens. Default `"widget"`: only while focus is
4895
+ * inside the widget. `"page"` claims the combo document-wide, which suits a
4896
+ * fullscreen widget that IS the app.
4897
+ */
4898
+ collapseShortcutScope?: "widget" | "page";
4899
+ };
4900
+ /**
4901
+ * History scope. Defaults to "verified-user" when getIdentityProof exists,
4902
+ * otherwise "browser". Before this browser has been identity-bound, a null
4903
+ * proof falls back to browser scope for that operation. Once visitor.endUserId
4904
+ * is non-null, a null proof fails closed until the host resets history identity.
4905
+ *
4906
+ * With a `provider`, this is a hard request: the provider must advertise it
4907
+ * in `capabilities.scopes` or every history operation fails with
4908
+ * `unsupported_scope`. Leave it unset to let the provider's advertised scope
4909
+ * win.
4910
+ */
4911
+ scope?: HistoryScope;
4912
+ /** Copy overrides. Every user-visible history string must be here. */
4913
+ copy?: AgentWidgetHistoryCopy;
4914
+ /**
4915
+ * Date bucketing of the conversation list. `"time"` (default) groups rows
4916
+ * under Today, Yesterday, Previous 7 days, Previous 30 days, and month
4917
+ * headings. `"none"` renders one flat list in server order instead, the
4918
+ * recents-style sidebar. Starred conversations keep their pinned group
4919
+ * either way.
4920
+ */
4921
+ grouping?: "time" | "none";
4922
+ /**
4923
+ * Leading avatar on each conversation row. Unset, rows show the launcher's
4924
+ * image mark (`launcher.iconUrl`) when one exists and are text-only
4925
+ * otherwise, the assistant-list default. Pass an image URL or a glyph to
4926
+ * always show a mark, or false to force text-only rows.
4927
+ */
4928
+ rowAvatar?: boolean | string;
4929
+ /** Show the evidence-based history scope/status beneath the Messages heading. Default true. */
4930
+ showScopeStatus?: boolean;
4931
+ /**
4932
+ * Visitor-facing delete of a single conversation via each row's overflow
4933
+ * menu. Default true. False hides the control only: it changes nothing about
4934
+ * what is stored or for how long, and custom row slots still receive
4935
+ * `requestDelete`. Turn off for deployments that treat conversations as
4936
+ * business records.
4937
+ */
4938
+ showDelete?: boolean;
4939
+ /**
4940
+ * The "Delete all conversations" item in the Messages overflow menu. Default
4941
+ * true. False hides the control only; storage and retention are unchanged.
4942
+ * The identity reset item is separate and unaffected.
4943
+ */
4944
+ showDeleteAll?: boolean;
4945
+ /**
4946
+ * Host items appended to the list overflow menu, above the built-in
4947
+ * destructive actions. The trigger renders whenever any item exists, so
4948
+ * these keep the menu alive even with `showDeleteAll: false`.
4949
+ */
4950
+ listActions?: AgentWidgetHistoryListAction[];
4951
+ }
4952
+ /** Resolved scope for a logical history operation. */
4953
+ type HistoryScope = "browser" | "verified-user";
4954
+ /** `presentation` after it has been resolved against the host container width. */
4955
+ type ResolvedHistoryPresentation = "panel" | "rail";
4956
+ /**
4957
+ * The surface Messages returns to on back/Escape. `"home"` only when a Home
4958
+ * Screen composition opened it; the core header button always records
4959
+ * `"conversation"`.
4960
+ */
4961
+ type HistoryReturnSurface = "home" | "conversation";
4962
+ /**
4963
+ * Evidence-based history identity state. Never inferred from the mere presence
4964
+ * of `getIdentityProof`, and never carries token, visitor, or end-user values.
4965
+ */
4966
+ type HistoryIdentityStatus = {
4967
+ state: "browser_only";
4968
+ reason: "configured_browser_scope" | "no_identity_provider" | "proof_unavailable_before_binding";
4969
+ } | {
4970
+ state: "verifying";
4971
+ } | {
4972
+ state: "verified";
4973
+ } | {
4974
+ state: "authentication_required";
4975
+ reason: "proof_unavailable_after_binding" | "invalid_identity_proof";
4976
+ } | {
4977
+ state: "identity_provider_failed";
4978
+ } | {
4979
+ state: "configuration_error";
4980
+ reason: "proof_not_admitted";
4981
+ } | {
4982
+ state: "resetting";
4983
+ } | {
4984
+ state: "unavailable";
4985
+ reason: "history_disabled" | "ineligible_mode";
4986
+ };
4987
+ /** Fully defaulted history copy. Every user-visible history string. */
4988
+ type ResolvedHistoryCopy = Required<AgentWidgetHistoryCopy>;
4989
+ /** List-region state handed to render hooks. */
4990
+ type HistoryViewState = {
4991
+ kind: "loading";
4992
+ phase: "initial" | "refresh" | "load-more";
4993
+ } | {
4994
+ kind: "ready";
4995
+ } | {
4996
+ kind: "empty";
4997
+ } | {
4998
+ kind: "error";
4999
+ reason: "unavailable" | "authentication_failed" | "authentication_required" | "identity_provider_failed" | "proof_not_admitted" | "unsupported_scope" | "unknown";
5000
+ retryable: boolean;
5001
+ } | {
5002
+ kind: "rate_limited";
5003
+ retryAfterSeconds: number;
5004
+ } | {
5005
+ kind: "new_conversation_required";
5006
+ };
5007
+ /** The single in-flight history operation, or `null` when idle. */
5008
+ type HistoryPendingAction = {
5009
+ kind: "refresh" | "load-more" | "start-new" | "clear" | "reset";
5010
+ } | {
5011
+ kind: "open" | "delete";
5012
+ conversationId: string;
5013
+ } | null;
5014
+ /**
5015
+ * Every history operation a render hook may invoke. Each routes through the
5016
+ * same controller/session path as the default renderer, so busy gating,
5017
+ * selection epochs, and confirmations behave identically.
5018
+ */
5019
+ type AgentWidgetHistoryRenderActions = {
5020
+ refresh(): Promise<void>;
5021
+ loadMore(): Promise<void>;
5022
+ openConversation(conversationId: string): Promise<void>;
5023
+ startNewConversation(): Promise<void>;
5024
+ /** Each request method opens Persona's accessible confirmation first. */
5025
+ requestDeleteConversation(conversationId: string): Promise<"deleted" | "cancelled">;
5026
+ requestClearConversationHistory(): Promise<"cleared" | "cancelled">;
5027
+ requestResetHistoryIdentity(): Promise<{
5028
+ outcome: "cancelled";
5029
+ } | {
5030
+ outcome: "reset";
5031
+ remoteRevocationConfirmed: boolean;
5032
+ }>;
5033
+ close(): void;
5034
+ };
5035
+ /** Context for `renderHistoryView`. Frozen snapshot; no provider or credentials. */
5036
+ type AgentWidgetRenderHistoryViewContext = {
5037
+ conversations: readonly HistoryConversationSummary[];
5038
+ activeConversationId: string | null;
5039
+ state: HistoryViewState;
5040
+ pendingAction: HistoryPendingAction;
5041
+ identityStatus: HistoryIdentityStatus;
5042
+ nextCursor: string | null;
5043
+ presentation: ResolvedHistoryPresentation;
5044
+ returnSurface: HistoryReturnSurface;
5045
+ config: AgentWidgetConfig;
5046
+ copy: ResolvedHistoryCopy;
5047
+ actions: AgentWidgetHistoryRenderActions;
5048
+ /** The default full view. Bypasses this hook only; lower slots still apply. */
5049
+ defaultRenderer(): HTMLElement;
5050
+ /** Re-run arbitration with the current snapshot. Inert after close/destroy. */
5051
+ requestRender(): void;
5052
+ /** Teardown for this render; runs before the next one and on close. */
5053
+ onCleanup(callback: () => void): void;
5054
+ };
5055
+ /** Context for `renderHistoryConversation` (one list row). */
5056
+ type AgentWidgetRenderHistoryConversationContext = {
5057
+ conversation: HistoryConversationSummary;
5058
+ active: boolean;
5059
+ pending: "opening" | "deleting" | null;
5060
+ presentation: ResolvedHistoryPresentation;
5061
+ config: AgentWidgetConfig;
5062
+ open(): Promise<void>;
5063
+ requestDelete(): Promise<"deleted" | "cancelled">;
5064
+ defaultRenderer(): HTMLElement;
5065
+ };
5066
+ /** Context for `renderHistoryHeader` (the Messages top bar). */
5067
+ type AgentWidgetRenderHistoryHeaderContext = {
5068
+ presentation: ResolvedHistoryPresentation;
5069
+ returnSurface: HistoryReturnSurface;
5070
+ identityStatus: HistoryIdentityStatus;
5071
+ pendingAction: HistoryPendingAction;
5072
+ config: AgentWidgetConfig;
5073
+ copy: ResolvedHistoryCopy;
5074
+ actions: Pick<AgentWidgetHistoryRenderActions, "close" | "startNewConversation">;
5075
+ defaultRenderer(): HTMLElement;
5076
+ };
5077
+ /**
5078
+ * Context for `renderHistoryState`. Invoked only for non-ready list states;
5079
+ * `retry`/`startNewConversation` are present only where they are safe, so
5080
+ * custom DOM never infers recovery behavior.
5081
+ */
5082
+ type AgentWidgetRenderHistoryStateContext = {
5083
+ state: Exclude<HistoryViewState, {
5084
+ kind: "ready";
5085
+ }>;
5086
+ identityStatus: HistoryIdentityStatus;
5087
+ presentation: ResolvedHistoryPresentation;
5088
+ config: AgentWidgetConfig;
5089
+ copy: ResolvedHistoryCopy;
5090
+ retry?: () => Promise<void>;
5091
+ startNewConversation?: () => Promise<void>;
5092
+ defaultRenderer(): HTMLElement;
5093
+ };
5094
+ /**
5095
+ * Context for `renderHistoryOpenError` (the transcript-level surface shown
5096
+ * when opening a conversation from the Messages list fails). `retry` and
5097
+ * `back` are the only exits: both route through the token-guarded open flow,
5098
+ * so custom DOM must not fetch on its own. `back` is present only when the
5099
+ * Messages surface is available to return to.
5100
+ */
5101
+ type AgentWidgetRenderHistoryOpenErrorContext = {
5102
+ conversationId: string;
5103
+ config: AgentWidgetConfig;
5104
+ /** Resolved shell copy the default surface renders. */
5105
+ copy: {
5106
+ title: string;
5107
+ retryLabel: string;
5108
+ backLabel: string;
5109
+ };
5110
+ /** Re-runs the open through Persona's token-guarded flow. */
5111
+ retry: () => void;
5112
+ /** Returns to the Messages list. Absent when history is unavailable. */
5113
+ back?: () => void;
5114
+ defaultRenderer(): HTMLElement;
5115
+ };
4045
5116
  type SSEEventRecord = {
4046
5117
  id: string;
4047
5118
  type: string;
@@ -4514,6 +5585,24 @@ type AgentWidgetLauncherTeaserConfig = {
4514
5585
  */
4515
5586
  dismissLabel?: string;
4516
5587
  };
5588
+ /**
5589
+ * Timing for the portaled icon-control tooltip (header, composer, rail).
5590
+ * Keyboard focus always opens immediately. Hover waits `delayMs` unless
5591
+ * another tooltip closed within `skipDelayMs` (toolbar scan).
5592
+ */
5593
+ type AgentWidgetTooltipConfig = {
5594
+ /**
5595
+ * Milliseconds to wait on hover before the first tooltip appears.
5596
+ * `0` restores the previous instant-open behavior.
5597
+ * @default 200
5598
+ */
5599
+ delayMs?: number;
5600
+ /**
5601
+ * After a tooltip closes, later hovers in this window skip `delayMs`.
5602
+ * @default 300
5603
+ */
5604
+ skipDelayMs?: number;
5605
+ };
4517
5606
  type AgentWidgetSendButtonConfig = {
4518
5607
  borderWidth?: string;
4519
5608
  borderColor?: string;
@@ -5520,6 +6609,21 @@ type ClientSession = {
5520
6609
  name: string;
5521
6610
  description: string | null;
5522
6611
  };
6612
+ /**
6613
+ * Active conversation record for this session. Optional only for rolling-deploy
6614
+ * compatibility with servers that predate the visitor history contract.
6615
+ */
6616
+ conversationId?: string;
6617
+ /**
6618
+ * Canonical resolved chat target (flow or agent). Normalized from the response
6619
+ * `targetId`, falling back to `flow.id` during rolling deployment. History code
6620
+ * reads this, never widget config.
6621
+ */
6622
+ targetId?: string;
6623
+ /** Opaque change token; differs whenever the conversation transcript mutated. */
6624
+ conversationRevision?: string;
6625
+ /** Visitor grant backing history. `token` appears only at mint. */
6626
+ visitor?: ClientVisitorGrant;
5523
6627
  /** Configuration from the server */
5524
6628
  config: {
5525
6629
  welcomeMessage: string | null;
@@ -5527,6 +6631,43 @@ type ClientSession = {
5527
6631
  theme: Record<string, unknown> | null;
5528
6632
  };
5529
6633
  };
6634
+ /**
6635
+ * Visitor credential and identity acknowledgement returned by /v1/client/init.
6636
+ * `expiresAt` stays the wire string: it is a server-slid idle window the widget
6637
+ * never evaluates locally.
6638
+ */
6639
+ type ClientVisitorGrant = {
6640
+ id: string;
6641
+ /** Replacement secret. Present only at mint; persist it before anything else. */
6642
+ token?: string;
6643
+ expiresAt: string;
6644
+ endUserId: string | null;
6645
+ /** Server acknowledgement of the supplied identity proof. Status metadata only. */
6646
+ identityStatus?: "not_provided" | "admitted" | "ignored";
6647
+ };
6648
+ /**
6649
+ * One conversation row, normalized at the Runtype boundary. The deprecated wire
6650
+ * `flowId` alias never escapes that boundary: history code reads `targetId`.
6651
+ */
6652
+ type HistoryConversationSummary = {
6653
+ id: string;
6654
+ /** Server-generated; rendered verbatim, never derived locally. */
6655
+ title: string;
6656
+ /** Resolved chat target (flow or agent); `null` when the server omits it. */
6657
+ targetId: string | null;
6658
+ /** Server-produced plain-text preview; `null` when unavailable. */
6659
+ preview: string | null;
6660
+ messageCount: number;
6661
+ createdAt: string;
6662
+ updatedAt: string;
6663
+ /** Visitor-pinned flag. Absent when the provider has no update capability. */
6664
+ starred?: boolean;
6665
+ };
6666
+ /** Visitor-editable conversation metadata. Absent fields are left unchanged. */
6667
+ type HistoryConversationPatch = {
6668
+ title?: string;
6669
+ starred?: boolean;
6670
+ };
5530
6671
  /** Icon button in the header title row (minimal layout). */
5531
6672
  type AgentWidgetHeaderTrailingAction = {
5532
6673
  id: string;
@@ -5545,6 +6686,13 @@ type AgentWidgetHeaderTrailingAction = {
5545
6686
  destructive?: boolean;
5546
6687
  dividerBefore?: boolean;
5547
6688
  }>;
6689
+ /**
6690
+ * Keyboard shortcut that activates this action, e.g. `"mod+shift+h"` ("mod"
6691
+ * is Command on Apple platforms, Control elsewhere). Fires only while focus
6692
+ * is inside the widget, and also drives the button's tooltip hint chip and
6693
+ * its `aria-keyshortcuts`.
6694
+ */
6695
+ shortcut?: string;
5548
6696
  };
5549
6697
  /**
5550
6698
  * Context provided to header render functions
@@ -5588,6 +6736,15 @@ type AgentWidgetHeaderLayoutConfig = {
5588
6736
  showIcon?: boolean;
5589
6737
  /** Show/hide the title */
5590
6738
  showTitle?: boolean;
6739
+ /**
6740
+ * What the header title (or `titleMenu` label) displays. `"static"`
6741
+ * (default) always shows `launcher.title`. `"conversation"` shows the active
6742
+ * conversation's title — the Claude-style pairing for a `titleMenu` holding
6743
+ * conversation actions — falling back to `launcher.title` while no titled
6744
+ * conversation is open (fresh chat, cleared history, or before the history
6745
+ * view has loaded titles). Requires `features.history` for titles to exist.
6746
+ */
6747
+ titleSource?: "static" | "conversation";
5591
6748
  /** Show/hide the subtitle */
5592
6749
  showSubtitle?: boolean;
5593
6750
  /** Show/hide the close button */
@@ -5638,8 +6795,16 @@ type AgentWidgetHeaderLayoutConfig = {
5638
6795
  destructive?: boolean;
5639
6796
  dividerBefore?: boolean;
5640
6797
  }>;
5641
- /** Called when a menu item is selected. */
5642
- onSelect: (id: string) => void;
6798
+ /**
6799
+ * Called when a menu item is selected. Returning `false` (sync or via
6800
+ * promise) falls through to the widget built-ins, mirroring the artifact
6801
+ * copy-menu contract: id `star` toggles the active conversation's star and
6802
+ * id `delete` runs the shell's confirm-then-delete on it (both require
6803
+ * `features.history` and, for star, a provider with the update
6804
+ * capability). `rename` has no built-in: hosts own the rename UI and call
6805
+ * `renameConversation()`.
6806
+ */
6807
+ onSelect: (id: string) => void | boolean | Promise<void | boolean>;
5643
6808
  /** Hover pill style. */
5644
6809
  hover?: {
5645
6810
  background?: string;
@@ -6210,15 +7375,20 @@ type LoadingIndicatorRenderContext = {
6210
7375
  */
6211
7376
  config: AgentWidgetConfig;
6212
7377
  /**
6213
- * Current streaming state (always true when indicator is shown)
7378
+ * Current streaming state. Always true for 'inline' and 'standalone';
7379
+ * false for 'conversation-open' (a history fetch, not a stream).
6214
7380
  */
6215
7381
  streaming: boolean;
6216
7382
  /**
6217
7383
  * Location where the indicator is rendered:
6218
7384
  * - 'inline': Inside a streaming assistant message bubble (when content is empty)
6219
7385
  * - 'standalone': Separate bubble while waiting for stream to start
7386
+ * - 'conversation-open': Transcript stand-in while a conversation opened
7387
+ * from the Messages list is being fetched. The returned element is mounted
7388
+ * inside Persona's centered transcript column, which keeps the status
7389
+ * role, announcement label, and composer gating.
6220
7390
  */
6221
- location: 'inline' | 'standalone';
7391
+ location: 'inline' | 'standalone' | 'conversation-open';
6222
7392
  /**
6223
7393
  * Function to render the default 3-dot bouncing indicator.
6224
7394
  * Call this if you want to use the default for certain cases.
@@ -6517,6 +7687,28 @@ type AgentWidgetConfig = {
6517
7687
  * ```
6518
7688
  */
6519
7689
  setStoredSessionId?: (sessionId: string) => void;
7690
+ /**
7691
+ * Called immediately before any cross-device history request and before a
7692
+ * conversationId resume of a conversation discovered on another device.
7693
+ * Return a fresh end-user access token (rt_eu_… / JWT). Null uses exact-browser
7694
+ * scope only for a never-bound visitor; a previously bound visitor fails closed
7695
+ * until resetHistoryIdentity() runs. Never cached by the widget.
7696
+ */
7697
+ getIdentityProof?: () => string | null | Promise<string | null>;
7698
+ /**
7699
+ * Read the persisted active conversation id (client token mode only).
7700
+ * Called only after the internal stored-state bootstrap gate resolves.
7701
+ */
7702
+ getStoredConversationId?: () => string | null;
7703
+ /** Persist the active conversation id so a later boot reopens the same record. */
7704
+ setStoredConversationId?: (conversationId: string) => void;
7705
+ /** Drop the persisted active conversation id (new conversation, deletion, reset). */
7706
+ clearStoredConversationId?: () => void;
7707
+ /**
7708
+ * Drop the persisted session id. Dedicated clear seam: it avoids widening
7709
+ * `setStoredSessionId` and its existing host call sites.
7710
+ */
7711
+ clearStoredSessionId?: () => void;
6520
7712
  /**
6521
7713
  * Static headers to include with each request.
6522
7714
  * For dynamic headers (e.g., auth tokens), use `getHeaders` instead.
@@ -6596,6 +7788,12 @@ type AgentWidgetConfig = {
6596
7788
  * @default false
6597
7789
  */
6598
7790
  autoFocusInput?: boolean;
7791
+ /**
7792
+ * Hover timing for the portaled control tooltip. Keyboard focus is
7793
+ * always immediate. Unset keys keep the ChatGPT/Claude defaults
7794
+ * (`delayMs: 200`, `skipDelayMs: 300`).
7795
+ */
7796
+ tooltip?: AgentWidgetTooltipConfig;
6599
7797
  launcher?: AgentWidgetLauncherConfig;
6600
7798
  initialMessages?: AgentWidgetMessage[];
6601
7799
  /**