@runtypelabs/persona 4.7.0 → 4.9.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 (185) hide show
  1. package/README.md +1 -0
  2. package/dist/animations/glyph-cycle.cjs +2 -2
  3. package/dist/animations/glyph-cycle.d.cts +1 -1
  4. package/dist/animations/glyph-cycle.d.ts +1 -1
  5. package/dist/animations/glyph-cycle.js +2 -2
  6. package/dist/animations/{types-CSmiKRVa.d.cts → types-4ROVJ1gA.d.cts} +85 -3
  7. package/dist/animations/{types-CSmiKRVa.d.ts → types-4ROVJ1gA.d.ts} +85 -3
  8. package/dist/animations/wipe.cjs +2 -2
  9. package/dist/animations/wipe.d.cts +1 -1
  10. package/dist/animations/wipe.d.ts +1 -1
  11. package/dist/chunk-5EIIHQLQ.js +1 -0
  12. package/dist/chunk-IO5VVUKP.js +3 -0
  13. package/dist/chunk-IPVK3KOM.js +1 -0
  14. package/dist/chunk-UPO4GUFC.js +1 -0
  15. package/dist/codegen.cjs +13 -13
  16. package/dist/codegen.js +14 -14
  17. package/dist/context-mentions-7S5KVUTG.js +169 -0
  18. package/dist/context-mentions-inline-TTCN7ZM2.js +4 -0
  19. package/dist/context-mentions-inline.cjs +4 -0
  20. package/dist/context-mentions-inline.d.cts +203 -0
  21. package/dist/context-mentions-inline.d.ts +203 -0
  22. package/dist/context-mentions-inline.js +4 -0
  23. package/dist/context-mentions.cjs +295 -0
  24. package/dist/context-mentions.d.cts +7025 -0
  25. package/dist/context-mentions.d.ts +7025 -0
  26. package/dist/context-mentions.js +295 -0
  27. package/dist/index.cjs +99 -68
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +1507 -182
  30. package/dist/index.d.ts +1507 -182
  31. package/dist/index.global.js +88 -56
  32. package/dist/index.global.js.map +1 -1
  33. package/dist/index.js +99 -68
  34. package/dist/index.js.map +1 -1
  35. package/dist/install.global.js +1 -1
  36. package/dist/install.global.js.map +1 -1
  37. package/dist/launcher.global.js +3 -2
  38. package/dist/launcher.global.js.map +1 -1
  39. package/dist/markdown-parsers.js +24 -24
  40. package/dist/plugin-kit.cjs +1 -1
  41. package/dist/plugin-kit.d.cts +17 -0
  42. package/dist/plugin-kit.d.ts +17 -0
  43. package/dist/plugin-kit.js +1 -1
  44. package/dist/runtype-tts-entry-UJAEF7NZ.js +1 -0
  45. package/dist/runtype-tts.js +1 -1
  46. package/dist/session-reconnect-JKIJBHS5.js +1 -0
  47. package/dist/smart-dom-reader.cjs +18 -17
  48. package/dist/smart-dom-reader.d.cts +1260 -16
  49. package/dist/smart-dom-reader.d.ts +1260 -16
  50. package/dist/smart-dom-reader.js +18 -17
  51. package/dist/testing.cjs +3 -3
  52. package/dist/testing.js +3 -3
  53. package/dist/theme-editor-preview.cjs +260 -58
  54. package/dist/theme-editor-preview.d.cts +1234 -15
  55. package/dist/theme-editor-preview.d.ts +1234 -15
  56. package/dist/theme-editor-preview.js +87 -58
  57. package/dist/theme-editor.cjs +10 -10
  58. package/dist/theme-editor.d.cts +1226 -15
  59. package/dist/theme-editor.d.ts +1226 -15
  60. package/dist/theme-editor.js +10 -10
  61. package/dist/theme-reference.cjs +1 -1
  62. package/dist/theme-reference.d.cts +76 -0
  63. package/dist/theme-reference.d.ts +76 -0
  64. package/dist/theme-reference.js +1 -1
  65. package/dist/voice-worklet-player.cjs +2 -2
  66. package/dist/voice-worklet-player.js +2 -2
  67. package/dist/webmcp-polyfill.js +2 -2
  68. package/dist/widget.css +1 -1
  69. package/package.json +16 -5
  70. package/src/artifacts-session.test.ts +178 -0
  71. package/src/client.test.ts +255 -1
  72. package/src/client.ts +157 -60
  73. package/src/components/artifact-card.test.ts +333 -0
  74. package/src/components/artifact-card.ts +75 -28
  75. package/src/components/artifact-inline.test.ts +1328 -0
  76. package/src/components/artifact-inline.ts +920 -0
  77. package/src/components/artifact-pane.test.ts +1042 -0
  78. package/src/components/artifact-pane.ts +440 -131
  79. package/src/components/artifact-preview.test.ts +1155 -0
  80. package/src/components/artifact-preview.ts +994 -0
  81. package/src/components/composer-parts.ts +3 -12
  82. package/src/components/context-mention-button.test.ts +70 -0
  83. package/src/components/context-mention-button.ts +82 -0
  84. package/src/components/context-mention-chip.ts +134 -0
  85. package/src/components/context-mention-menu.test.ts +508 -0
  86. package/src/components/context-mention-menu.ts +0 -0
  87. package/src/components/message-bubble.test.ts +175 -0
  88. package/src/components/message-bubble.ts +177 -19
  89. package/src/components/panel.ts +7 -10
  90. package/src/components/pill-composer-builder.test.ts +6 -2
  91. package/src/components/pill-composer-builder.ts +6 -6
  92. package/src/components/reasoning-bubble.ts +1 -13
  93. package/src/components/registry.ts +38 -3
  94. package/src/components/tool-bubble.ts +1 -13
  95. package/src/context-mentions-bundle.test.ts +163 -0
  96. package/src/context-mentions-entry.ts +185 -0
  97. package/src/context-mentions-inline-entry.test.ts +136 -0
  98. package/src/context-mentions-inline-entry.ts +226 -0
  99. package/src/context-mentions-inline-loader.test.ts +30 -0
  100. package/src/context-mentions-inline-loader.ts +36 -0
  101. package/src/context-mentions-inline.ts +15 -0
  102. package/src/context-mentions-loader.ts +32 -0
  103. package/src/context-mentions.ts +16 -0
  104. package/src/defaults.ts +1 -0
  105. package/src/generated/runtype-openapi-contract.ts +55 -3
  106. package/src/index-core.ts +46 -1
  107. package/src/index-global.ts +51 -0
  108. package/src/index.ts +8 -0
  109. package/src/markdown-parsers-loader.test.ts +158 -0
  110. package/src/markdown-parsers-loader.ts +83 -27
  111. package/src/plugin-kit.test.ts +40 -0
  112. package/src/plugin-kit.ts +39 -5
  113. package/src/runtime/host-layout.test.ts +163 -0
  114. package/src/runtime/host-layout.ts +110 -7
  115. package/src/runtime/init.ts +18 -61
  116. package/src/session.mentions.test.ts +175 -0
  117. package/src/session.test.ts +52 -4
  118. package/src/session.ts +197 -27
  119. package/src/smart-dom-reader.test.ts +129 -2
  120. package/src/smart-dom-reader.ts +127 -1
  121. package/src/styles/context-mention-menu-css.ts +176 -0
  122. package/src/styles/widget.css +1002 -152
  123. package/src/theme-editor/preview.ts +2 -0
  124. package/src/theme-editor/sections.test.ts +26 -1
  125. package/src/theme-editor/sections.ts +13 -5
  126. package/src/theme-reference.ts +2 -2
  127. package/src/tool-call-display-defaults.test.ts +1 -0
  128. package/src/types/theme.ts +79 -0
  129. package/src/types.ts +1041 -17
  130. package/src/ui.artifact-pane-gating.test.ts +636 -0
  131. package/src/ui.component-directive.test.ts +104 -0
  132. package/src/ui.composer-bar.test.ts +60 -2
  133. package/src/ui.detached-panel.test.ts +1049 -0
  134. package/src/ui.mention-submit.test.ts +235 -0
  135. package/src/ui.tool-display.test.ts +51 -0
  136. package/src/ui.ts +998 -159
  137. package/src/utils/artifact-custom-actions.ts +128 -0
  138. package/src/utils/artifact-display.test.ts +42 -0
  139. package/src/utils/artifact-display.ts +84 -0
  140. package/src/utils/artifact-file.test.ts +116 -0
  141. package/src/utils/artifact-file.ts +117 -0
  142. package/src/utils/artifact-gate.test.ts +112 -5
  143. package/src/utils/artifact-gate.ts +39 -14
  144. package/src/utils/artifact-loading-status.ts +55 -0
  145. package/src/utils/artifact-status-label.ts +190 -0
  146. package/src/utils/buttons.ts +7 -1
  147. package/src/utils/chunk-loader.test.ts +97 -0
  148. package/src/utils/chunk-loader.ts +88 -0
  149. package/src/utils/code-highlight.test.ts +186 -0
  150. package/src/utils/code-highlight.ts +400 -0
  151. package/src/utils/composer-contenteditable.test.ts +507 -0
  152. package/src/utils/composer-contenteditable.ts +626 -0
  153. package/src/utils/composer-document.test.ts +280 -0
  154. package/src/utils/composer-document.ts +293 -0
  155. package/src/utils/composer-history.test.ts +35 -7
  156. package/src/utils/composer-history.ts +30 -20
  157. package/src/utils/composer-input.ts +159 -0
  158. package/src/utils/context-mention-controller.test.ts +1215 -0
  159. package/src/utils/context-mention-controller.ts +1186 -0
  160. package/src/utils/context-mention-manager.test.ts +422 -0
  161. package/src/utils/context-mention-manager.ts +410 -0
  162. package/src/utils/context-mention-orchestrator.test.ts +538 -0
  163. package/src/utils/context-mention-orchestrator.ts +348 -0
  164. package/src/utils/icons.ts +2 -0
  165. package/src/utils/live-region.test.ts +108 -0
  166. package/src/utils/live-region.ts +94 -0
  167. package/src/utils/mention-channels.ts +63 -0
  168. package/src/utils/mention-llm-format.test.ts +91 -0
  169. package/src/utils/mention-llm-format.ts +79 -0
  170. package/src/utils/mention-matcher.test.ts +86 -0
  171. package/src/utils/mention-matcher.ts +221 -0
  172. package/src/utils/mention-token.ts +72 -0
  173. package/src/utils/mention-trigger.test.ts +155 -0
  174. package/src/utils/mention-trigger.ts +156 -0
  175. package/src/utils/roving-tablist.test.ts +152 -0
  176. package/src/utils/roving-tablist.ts +111 -0
  177. package/src/utils/spinner.ts +45 -0
  178. package/src/utils/theme.test.ts +76 -4
  179. package/src/utils/theme.ts +7 -0
  180. package/src/utils/tokens.ts +118 -11
  181. package/src/utils/tool-loading-animation.test.ts +32 -0
  182. package/src/utils/tool-loading-animation.ts +24 -0
  183. package/dist/chunk-DFBSCFYN.js +0 -1
  184. package/dist/runtype-tts-entry-HFUV2UF7.js +0 -1
  185. package/dist/session-reconnect-U77QFUR7.js +0 -1
@@ -1,3 +1,5 @@
1
+ import { IconNode } from 'lucide';
2
+
1
3
  type TokenType = 'color' | 'spacing' | 'typography' | 'shadow' | 'border' | 'radius';
2
4
  type TokenReference<_T extends TokenType = TokenType> = string;
3
5
  interface ColorShade {
@@ -153,6 +155,8 @@ interface ComponentTokenSet {
153
155
  margin?: TokenReference<'spacing'>;
154
156
  shadow?: TokenReference<'shadow'>;
155
157
  opacity?: number;
158
+ /** Hover background — used by transparent variants like `button.ghost`. */
159
+ hoverBackground?: TokenReference<'color'>;
156
160
  }
157
161
  interface ButtonTokens extends ComponentTokenSet {
158
162
  primary: ComponentTokenSet;
@@ -177,6 +181,10 @@ interface PanelTokens extends ComponentTokenSet {
177
181
  maxWidth: string;
178
182
  height: string;
179
183
  maxHeight: string;
184
+ /** Gap between the detached panel and its region edges. Only used when detached. */
185
+ inset?: string;
186
+ /** Background of the region revealed behind a detached panel. */
187
+ canvasBackground?: string;
180
188
  }
181
189
  interface HeaderTokens extends ComponentTokenSet {
182
190
  background: TokenReference<'color'>;
@@ -341,6 +349,14 @@ interface ArtifactToolbarTokens {
341
349
  iconBorder?: string;
342
350
  toggleGroupGap?: string;
343
351
  toggleBorderRadius?: string;
352
+ /** Inner padding of the segmented view/source toggle pill. */
353
+ toggleGroupPadding?: string;
354
+ /** Border of the segmented view/source toggle pill (e.g., `none`). */
355
+ toggleGroupBorder?: string;
356
+ /** Corner radius of the segmented view/source toggle pill. */
357
+ toggleGroupBorderRadius?: string;
358
+ /** Background of the segmented view/source toggle pill. */
359
+ toggleGroupBackground?: string;
344
360
  copyBackground?: string;
345
361
  copyBorder?: string;
346
362
  copyColor?: string;
@@ -372,6 +388,16 @@ interface ArtifactTabTokens {
372
388
  /** Tab list container padding (CSS shorthand). */
373
389
  listPadding?: string;
374
390
  }
391
+ /** Artifact reference card (chat thread) chrome. */
392
+ interface ArtifactCardTokens {
393
+ background?: string;
394
+ /** Full border shorthand (e.g. `1px solid #e5e7eb`). */
395
+ border?: string;
396
+ borderRadius?: string;
397
+ hoverBackground?: string;
398
+ /** Border color on hover. */
399
+ hoverBorderColor?: string;
400
+ }
375
401
  /** Artifact pane chrome. */
376
402
  interface ArtifactPaneTokens {
377
403
  /**
@@ -382,6 +408,54 @@ interface ArtifactPaneTokens {
382
408
  background?: string;
383
409
  toolbarBackground?: string;
384
410
  }
411
+ /** Inline artifact block chrome (`display: "inline"` file preview). */
412
+ interface ArtifactInlineTokens {
413
+ /** Background of the inline preview frame. */
414
+ background?: string;
415
+ /** Full border shorthand for the frame (e.g. `1px solid #e5e7eb`). */
416
+ border?: string;
417
+ /** Border radius of the inline preview frame. */
418
+ borderRadius?: string;
419
+ /** Background of the title/toolbar chrome bar. */
420
+ chromeBackground?: string;
421
+ /** Bottom border of the title bar. */
422
+ chromeBorder?: string;
423
+ /** Title text color in the chrome bar (artifact basename). */
424
+ titleColor?: string;
425
+ /** Muted text color for the type label / streaming status. */
426
+ mutedColor?: string;
427
+ /** Preview iframe height inside the inline body. */
428
+ frameHeight?: string;
429
+ }
430
+ /**
431
+ * Syntax-highlighted artifact source view (pane + inline), rendered by
432
+ * `utils/code-highlight.ts`. One Light defaults ship in `widget.css`, with a
433
+ * One Dark override keyed off the widget's resolved color scheme (the
434
+ * `data-persona-color-scheme` root attribute, not the OS preference); set any
435
+ * of these to retheme the tokenizer palette and the line-number gutter.
436
+ */
437
+ interface CodeTokens {
438
+ /** Keywords, booleans, null (e.g. `const`, `true`). */
439
+ keywordColor?: string;
440
+ /** String and template literals; HTML attribute values. */
441
+ stringColor?: string;
442
+ /** Line and block comments. */
443
+ commentColor?: string;
444
+ /** Numeric literals; CSS hex colors / units. */
445
+ numberColor?: string;
446
+ /** HTML tag brackets + names; doctype. */
447
+ tagColor?: string;
448
+ /** HTML attribute names. */
449
+ attrColor?: string;
450
+ /** CSS property names; JSON object keys. */
451
+ propertyColor?: string;
452
+ /** Line-number gutter digits. */
453
+ lineNumberColor?: string;
454
+ /** Right border of the line-number gutter. */
455
+ gutterBorderColor?: string;
456
+ /** Background of the source-view code sheet (defaults to One Light/Dark editor background). */
457
+ background?: string;
458
+ }
385
459
  /** Icon button chrome (used by createIconButton). */
386
460
  interface IconButtonTokens {
387
461
  background?: string;
@@ -451,9 +525,13 @@ interface ComponentTokens {
451
525
  toolbar?: ArtifactToolbarTokens;
452
526
  tab?: ArtifactTabTokens;
453
527
  pane?: ArtifactPaneTokens;
528
+ card?: ArtifactCardTokens;
529
+ inline?: ArtifactInlineTokens;
454
530
  };
455
531
  /** Collapsible widget chrome (tool/reasoning/approval bubbles). */
456
532
  collapsibleWidget?: CollapsibleWidgetTokens;
533
+ /** Syntax-highlighted artifact source view (tokenizer palette + gutter). */
534
+ code?: CodeTokens;
457
535
  }
458
536
  interface PaletteExtras {
459
537
  transitions?: Record<string, string>;
@@ -764,6 +842,7 @@ type RuntypeExecutionStreamEvent = ({
764
842
  totalSteps?: number;
765
843
  type: "execution_start";
766
844
  }) | ({
845
+ claudeManagedAgentId?: string;
767
846
  completedAt?: string;
768
847
  durationMs?: number;
769
848
  executionId: string;
@@ -808,6 +887,15 @@ type RuntypeExecutionStreamEvent = ({
808
887
  completedAt?: string;
809
888
  content?: string;
810
889
  cost?: number;
890
+ estimatedContextBreakdown?: {
891
+ categories: Record<string, {
892
+ chars: number;
893
+ estimatedTokens: number;
894
+ }>;
895
+ contextWindowSize?: number;
896
+ estimatedTotalTokens: number;
897
+ estimatedUtilizationPercent?: number;
898
+ };
811
899
  executionId: string;
812
900
  fallback?: {
813
901
  attempts: Array<{
@@ -845,6 +933,7 @@ type RuntypeExecutionStreamEvent = ({
845
933
  type: "step_start";
846
934
  } | ({
847
935
  completedAt?: string;
936
+ cost?: number;
848
937
  durationMs?: number;
849
938
  error?: string;
850
939
  executionId: string;
@@ -950,6 +1039,11 @@ type RuntypeExecutionStreamEvent = ({
950
1039
  artifactType: "markdown" | "component";
951
1040
  component?: string;
952
1041
  executionId?: string;
1042
+ file?: {
1043
+ language?: string;
1044
+ mimeType: string;
1045
+ path: string;
1046
+ };
953
1047
  id: string;
954
1048
  seq?: number;
955
1049
  title?: string;
@@ -1058,6 +1152,14 @@ type RuntypeExecutionStreamEvent = ({
1058
1152
  awaitReason?: string;
1059
1153
  awaitedAt?: string;
1060
1154
  crawlId?: string;
1155
+ elicitation?: {
1156
+ message: string;
1157
+ mode: "form" | "url";
1158
+ pauseCount?: number;
1159
+ requestedSchema?: Record<string, unknown>;
1160
+ serverName?: string;
1161
+ url?: string;
1162
+ };
1061
1163
  executionId: string;
1062
1164
  origin?: "webmcp" | "sdk";
1063
1165
  pageOrigin?: string;
@@ -1157,6 +1259,14 @@ type RuntypeFlowSSEEvent = {
1157
1259
  awaitReason?: string;
1158
1260
  awaitedAt: string;
1159
1261
  crawlId?: string;
1262
+ elicitation?: {
1263
+ message: string;
1264
+ mode: "form" | "url";
1265
+ pauseCount?: number;
1266
+ requestedSchema?: Record<string, unknown>;
1267
+ serverName?: string;
1268
+ url?: string;
1269
+ };
1160
1270
  executionId?: string;
1161
1271
  flowId: string;
1162
1272
  origin?: "webmcp" | "sdk";
@@ -1207,7 +1317,7 @@ type RuntypeFlowSSEEvent = {
1207
1317
  completedAt?: string;
1208
1318
  duration?: number;
1209
1319
  durationMs?: number;
1210
- error?: string;
1320
+ error?: string | null;
1211
1321
  executionId?: string;
1212
1322
  executionTime?: number;
1213
1323
  id?: string;
@@ -1251,13 +1361,21 @@ type RuntypeFlowSSEEvent = {
1251
1361
  totalSteps: number;
1252
1362
  type: "step_skip";
1253
1363
  when: string;
1254
- } | {
1364
+ } | ({
1365
+ elicitation?: {
1366
+ message: string;
1367
+ mode: "form" | "url";
1368
+ pauseCount?: number;
1369
+ requestedSchema?: Record<string, unknown>;
1370
+ serverName?: string;
1371
+ url?: string;
1372
+ };
1255
1373
  executionId?: string;
1256
1374
  reason?: string;
1257
1375
  seq?: number;
1258
1376
  type: "step_await";
1259
1377
  [key: string]: unknown;
1260
- } | ({
1378
+ }) | ({
1261
1379
  agentContext?: {
1262
1380
  executionId: string;
1263
1381
  iteration: number;
@@ -1422,6 +1540,149 @@ type TargetResolver = (id: string) => {
1422
1540
  payload: Record<string, unknown>;
1423
1541
  };
1424
1542
 
1543
+ /**
1544
+ * Curated registry of lucide icons available to `renderLucideIcon`.
1545
+ *
1546
+ * The widget used to do `import * as icons from "lucide"` and look up
1547
+ * icons dynamically by string. That defeated tree-shaking, so the IIFE
1548
+ * (CDN/script-tag) bundle shipped all 1640 lucide icons (~400KB of icon
1549
+ * data) regardless of which we actually used. This explicit registry
1550
+ * lets the bundler drop any icon not listed here.
1551
+ *
1552
+ * Trade-off: `renderLucideIcon(name)` is now a *closed set*. Names not
1553
+ * in this map return `null` and log a warning, exactly as a typo did
1554
+ * before. The registry is intentionally generous (~110 icons) so that
1555
+ * custom `ComponentRenderer` authors rarely hit a missing-icon dead end.
1556
+ *
1557
+ * To add icons: add a named import above and a row in `LUCIDE_ICONS`,
1558
+ * keyed by the lucide kebab-case name (matches their filename and
1559
+ * https://lucide.dev/icons).
1560
+ *
1561
+ * See `packages/widget/docs/icon-registry-shortlist.md` for the full
1562
+ * curation rationale and which icons were considered but excluded.
1563
+ */
1564
+ declare const LUCIDE_ICONS: {
1565
+ readonly activity: IconNode;
1566
+ readonly "arrow-down": IconNode;
1567
+ readonly "arrow-up": IconNode;
1568
+ readonly "arrow-up-right": IconNode;
1569
+ readonly bot: IconNode;
1570
+ readonly "chevron-down": IconNode;
1571
+ readonly "chevron-up": IconNode;
1572
+ readonly "chevron-right": IconNode;
1573
+ readonly "chevron-left": IconNode;
1574
+ readonly check: IconNode;
1575
+ readonly clipboard: IconNode;
1576
+ readonly "clipboard-copy": IconNode;
1577
+ readonly "code-xml": IconNode;
1578
+ readonly copy: IconNode;
1579
+ readonly file: IconNode;
1580
+ readonly "file-code": IconNode;
1581
+ readonly "file-spreadsheet": IconNode;
1582
+ readonly "file-text": IconNode;
1583
+ readonly "image-plus": IconNode;
1584
+ readonly loader: IconNode;
1585
+ readonly "loader-circle": IconNode;
1586
+ readonly mic: IconNode;
1587
+ readonly paperclip: IconNode;
1588
+ readonly "refresh-cw": IconNode;
1589
+ readonly search: IconNode;
1590
+ readonly send: IconNode;
1591
+ readonly "shield-alert": IconNode;
1592
+ readonly "shield-check": IconNode;
1593
+ readonly "shield-x": IconNode;
1594
+ readonly square: IconNode;
1595
+ readonly "thumbs-down": IconNode;
1596
+ readonly "thumbs-up": IconNode;
1597
+ readonly upload: IconNode;
1598
+ readonly "volume-2": IconNode;
1599
+ readonly x: IconNode;
1600
+ readonly user: IconNode;
1601
+ readonly mail: IconNode;
1602
+ readonly phone: IconNode;
1603
+ readonly calendar: IconNode;
1604
+ readonly clock: IconNode;
1605
+ readonly building: IconNode;
1606
+ readonly "map-pin": IconNode;
1607
+ readonly lock: IconNode;
1608
+ readonly key: IconNode;
1609
+ readonly "credit-card": IconNode;
1610
+ readonly "at-sign": IconNode;
1611
+ readonly hash: IconNode;
1612
+ readonly globe: IconNode;
1613
+ readonly link: IconNode;
1614
+ readonly "circle-check": IconNode;
1615
+ readonly "circle-x": IconNode;
1616
+ readonly "triangle-alert": IconNode;
1617
+ readonly info: IconNode;
1618
+ readonly ban: IconNode;
1619
+ readonly shield: IconNode;
1620
+ readonly "arrow-left": IconNode;
1621
+ readonly "arrow-right": IconNode;
1622
+ readonly "external-link": IconNode;
1623
+ readonly ellipsis: IconNode;
1624
+ readonly "ellipsis-vertical": IconNode;
1625
+ readonly menu: IconNode;
1626
+ readonly house: IconNode;
1627
+ readonly plus: IconNode;
1628
+ readonly minus: IconNode;
1629
+ readonly pencil: IconNode;
1630
+ readonly trash: IconNode;
1631
+ readonly "trash-2": IconNode;
1632
+ readonly save: IconNode;
1633
+ readonly download: IconNode;
1634
+ readonly share: IconNode;
1635
+ readonly funnel: IconNode;
1636
+ readonly settings: IconNode;
1637
+ readonly "rotate-cw": IconNode;
1638
+ readonly maximize: IconNode;
1639
+ readonly minimize: IconNode;
1640
+ readonly "shopping-cart": IconNode;
1641
+ readonly "shopping-bag": IconNode;
1642
+ readonly package: IconNode;
1643
+ readonly truck: IconNode;
1644
+ readonly tag: IconNode;
1645
+ readonly gift: IconNode;
1646
+ readonly receipt: IconNode;
1647
+ readonly wallet: IconNode;
1648
+ readonly store: IconNode;
1649
+ readonly "dollar-sign": IconNode;
1650
+ readonly percent: IconNode;
1651
+ readonly play: IconNode;
1652
+ readonly pause: IconNode;
1653
+ readonly "volume-x": IconNode;
1654
+ readonly camera: IconNode;
1655
+ readonly image: IconNode;
1656
+ readonly film: IconNode;
1657
+ readonly headphones: IconNode;
1658
+ readonly "message-circle": IconNode;
1659
+ readonly "message-square": IconNode;
1660
+ readonly bell: IconNode;
1661
+ readonly heart: IconNode;
1662
+ readonly star: IconNode;
1663
+ readonly eye: IconNode;
1664
+ readonly "eye-off": IconNode;
1665
+ readonly bookmark: IconNode;
1666
+ readonly "calendar-days": IconNode;
1667
+ readonly history: IconNode;
1668
+ readonly timer: IconNode;
1669
+ readonly folder: IconNode;
1670
+ readonly "folder-open": IconNode;
1671
+ readonly files: IconNode;
1672
+ readonly sparkles: IconNode;
1673
+ readonly zap: IconNode;
1674
+ readonly sun: IconNode;
1675
+ readonly moon: IconNode;
1676
+ readonly flag: IconNode;
1677
+ readonly monitor: IconNode;
1678
+ readonly smartphone: IconNode;
1679
+ };
1680
+ /**
1681
+ * Names of lucide icons that ship with the widget. Names not in this
1682
+ * union return `null` from `renderLucideIcon` (with a console warning).
1683
+ */
1684
+ type IconName = keyof typeof LUCIDE_ICONS;
1685
+
1425
1686
  /**
1426
1687
  * Text content part for multi-modal messages
1427
1688
  */
@@ -1480,6 +1741,446 @@ type AgentWidgetContextProviderContext = {
1480
1741
  config: AgentWidgetConfig;
1481
1742
  };
1482
1743
  type AgentWidgetContextProvider = (context: AgentWidgetContextProviderContext) => Record<string, unknown> | void | Promise<Record<string, unknown> | void>;
1744
+ /** A single selectable item in the mention menu (host-provided). */
1745
+ type AgentWidgetContextMentionItem = {
1746
+ /** Stable key within its source. */
1747
+ id: string;
1748
+ /** Shown in the menu and on the chip (e.g. "App.tsx"). */
1749
+ label: string;
1750
+ /** Subtitle line in the menu. */
1751
+ description?: string;
1752
+ /** Lucide icon name. */
1753
+ iconName?: string;
1754
+ /**
1755
+ * Accent color for this item's inline token (`display: "inline"`), any CSS
1756
+ * color. Sets `--persona-mention-token-accent` on the token, tinting its pill
1757
+ * background + icon/label — the per-item/per-type color knob (Slack/Linear
1758
+ * style). Prefer setting the same color across a source's items for a "color
1759
+ * per type" look, or theme by `[data-mention-source]` in CSS instead. Ignored
1760
+ * in chip mode.
1761
+ */
1762
+ color?: string;
1763
+ /** Group header override; defaults to the source's `label`. */
1764
+ group?: string;
1765
+ /** Optional recency/popularity hint the default matcher boosts on. */
1766
+ recencyScore?: number;
1767
+ /**
1768
+ * SKILLS / SLASH-COMMANDS. When set, this item is a COMMAND (a verb) rather
1769
+ * than a context mention (a noun), so selecting it dispatches a behavior
1770
+ * instead of adding a context chip. Absent for ordinary mentions.
1771
+ *
1772
+ * - `"prompt"`: a prompt macro. `resolve()` returns `insertText` (or
1773
+ * `llmAppend`) which is written into the composer (see `insertMode`);
1774
+ * `submitOnSelect` optionally sends it immediately. No chip.
1775
+ * - `"action"`: a client action. `action()` runs in the browser; no resolve,
1776
+ * no chip, no message sent (e.g. `/clear`, `/theme dark`).
1777
+ * - `"server"`: a server-invoked skill. Routed like a `resolveOn:"submit"`
1778
+ * mention whose `resolve().context` reaches the backend via request
1779
+ * `context.mentions.<sourceId>.<itemId>` (a flow/agent reads it).
1780
+ */
1781
+ command?: "prompt" | "action" | "server";
1782
+ /**
1783
+ * `command:"action"` handler. Receives the parsed `args` (text after the
1784
+ * command name), plus a small `composer` capability + `config`/`messages`.
1785
+ * Short-circuits the mention flow (no chip, no send). Ignored otherwise.
1786
+ */
1787
+ action?: (ctx: AgentWidgetContextMentionCommandContext) => void | Promise<void>;
1788
+ /**
1789
+ * `command:"prompt"` insertion mode. `"replace"` (default) swaps the whole
1790
+ * composer value for the resolved text; `"insert-at-caret"` replaces only the
1791
+ * `/token` span, keeping surrounding prose. Ignored otherwise.
1792
+ */
1793
+ insertMode?: "replace" | "insert-at-caret";
1794
+ /**
1795
+ * When true, a `command:"prompt"` submits the composer immediately after
1796
+ * inserting its text (a one-shot macro). Ignored for other kinds.
1797
+ */
1798
+ submitOnSelect?: boolean;
1799
+ /**
1800
+ * COMMANDS only. Ghost hint for a free-text argument (e.g. "order id" →
1801
+ * `/lookup ‹order id›` in the menu). Its presence switches the command to
1802
+ * INLINE COMPLETION (Slack-style): selecting it fills `/name ` into the
1803
+ * composer for inline arg entry instead of dispatching on select, and the
1804
+ * command is executed at SUBMIT with the typed args. `command:"server"` items
1805
+ * always use inline completion (their chip had no way to add an argument);
1806
+ * for `"prompt"`/`"action"` items this is opt-in. Ignored for non-commands.
1807
+ */
1808
+ commandArgsPlaceholder?: string;
1809
+ };
1810
+ /**
1811
+ * Capability object handed to a `command:"action"` handler. The widget exposes
1812
+ * only composer-local operations; broader actions (clear the transcript, change
1813
+ * theme) are wired by the host via closures over its own controller.
1814
+ */
1815
+ type AgentWidgetContextMentionComposerCapability = {
1816
+ /** Current composer text. */
1817
+ getValue: () => string;
1818
+ /** Replace composer text (fires `input`, moves caret to end, refocuses). */
1819
+ setValue: (value: string) => void;
1820
+ /** Submit the composer (same path as pressing send). */
1821
+ submit: () => void;
1822
+ };
1823
+ /** Context passed to a `command:"action"` handler. */
1824
+ type AgentWidgetContextMentionCommandContext = {
1825
+ /** Text typed after the command name (e.g. `staging` for `/deploy staging`). */
1826
+ args: string;
1827
+ config: AgentWidgetConfig;
1828
+ messages: AgentWidgetMessage[];
1829
+ composer: AgentWidgetContextMentionComposerCapability;
1830
+ };
1831
+ /** Reference stored on a sent message for transcript fidelity + chip rendering. */
1832
+ type AgentWidgetContextMentionRef = {
1833
+ sourceId: string;
1834
+ itemId: string;
1835
+ label: string;
1836
+ iconName?: string;
1837
+ /** Accent color for the inline token (see `AgentWidgetContextMentionItem.color`). */
1838
+ color?: string;
1839
+ };
1840
+ /**
1841
+ * One ordered segment of a sent message's prose, for inline mention rendering
1842
+ * (`contextMentions.display: "inline"`). Text runs and atomic mention tokens
1843
+ * interleave in document order so the sent bubble re-renders `@tokens` in place
1844
+ * and composer history can round-trip them. Display/transcript concern only —
1845
+ * the model still sees resolved bodies via `llmContent`/`contentParts`.
1846
+ */
1847
+ type AgentWidgetContentSegment = {
1848
+ kind: "text";
1849
+ text: string;
1850
+ } | {
1851
+ kind: "mention";
1852
+ ref: AgentWidgetContextMentionRef;
1853
+ };
1854
+ /**
1855
+ * The payload a source returns from `resolve()` for one selected item.
1856
+ * Lead with `llmAppend` — it is the only channel guaranteed to reach the model
1857
+ * with no backend changes.
1858
+ */
1859
+ type AgentWidgetContextMentionPayload = {
1860
+ /**
1861
+ * PRIMARY, model-visible channel. Appended to this user message's LLM content
1862
+ * so the model actually sees the context with no backend changes.
1863
+ */
1864
+ llmAppend?: string;
1865
+ /**
1866
+ * `command:"prompt"` macros only. Text written into the COMPOSER on select
1867
+ * (see `AgentWidgetContextMentionItem.insertMode`) — distinct from the hidden
1868
+ * `llmAppend` context channel. Falls back to `llmAppend` when omitted.
1869
+ */
1870
+ insertText?: string;
1871
+ /** Extra content parts (e.g. file text / image) via the multi-modal path. */
1872
+ contentParts?: ContentPart[];
1873
+ /**
1874
+ * OPT-IN structured channel. Merged into request `context` under
1875
+ * `mentions.<sourceId>.<itemId>` for flows/agents that read it. NOTE: ambient
1876
+ * `context` is NOT guaranteed to reach the model — use `llmAppend` if you need
1877
+ * the model to see it.
1878
+ */
1879
+ context?: Record<string, unknown>;
1880
+ };
1881
+ /**
1882
+ * One resolved mention, handed to `contextMentions.llmFormat` to build the
1883
+ * model-visible block. `text` is the source's `llmAppend`; `ref`/`item` carry
1884
+ * the selection identity/metadata for a custom formatter (e.g. a source-specific
1885
+ * wrapper or a path from `item`).
1886
+ */
1887
+ type AgentWidgetMentionLlmEntry = {
1888
+ /** The mention's display label (from `ref.label`). */
1889
+ label: string;
1890
+ /** The resolved model-visible body (the source's `llmAppend`). */
1891
+ text: string;
1892
+ ref: AgentWidgetContextMentionRef;
1893
+ item: AgentWidgetContextMentionItem;
1894
+ };
1895
+ type AgentWidgetContextMentionSearchContext = {
1896
+ messages: AgentWidgetMessage[];
1897
+ config: AgentWidgetConfig;
1898
+ /** Aborts when the next keystroke supersedes this in-flight search. */
1899
+ signal: AbortSignal;
1900
+ };
1901
+ type AgentWidgetContextMentionResolveContext = AgentWidgetContextMentionSearchContext & {
1902
+ /** Plain-text composer value at resolve time. */
1903
+ composerText: string;
1904
+ /**
1905
+ * For `command` items: the text typed after the command name (e.g.
1906
+ * `"123"` for `/lookup 123`). Empty string for ordinary mentions.
1907
+ */
1908
+ args: string;
1909
+ };
1910
+ type AgentWidgetContextMentionSource = {
1911
+ id: string;
1912
+ /** Group header shown in the menu. */
1913
+ label: string;
1914
+ /**
1915
+ * Filter items for the current `@query` (empty query → recent/popular).
1916
+ * Implement server-side search for large/remote sets, or return all items and
1917
+ * let the widget rank them with `defaultMentionFilter`
1918
+ * (see `createStaticMentionSource` for the common case).
1919
+ */
1920
+ search: (query: string, ctx: AgentWidgetContextMentionSearchContext) => AgentWidgetContextMentionItem[] | Promise<AgentWidgetContextMentionItem[]>;
1921
+ /**
1922
+ * Fetch the payload for dispatch. Called once when the user SELECTS the item
1923
+ * (eagerly, cached on the chip, abortable on removal) unless `resolveOn` is
1924
+ * `"submit"`. A throw/abort drops the mention via `onMentionResolveError`.
1925
+ */
1926
+ resolve: (item: AgentWidgetContextMentionItem, ctx: AgentWidgetContextMentionResolveContext) => AgentWidgetContextMentionPayload | Promise<AgentWidgetContextMentionPayload>;
1927
+ /**
1928
+ * When to call `resolve()`:
1929
+ * - `"select"` (default): eager on pick; parallelizes the fetch with the user
1930
+ * finishing their sentence so submit stays instant.
1931
+ * - `"submit"`: defer to send time, for time-sensitive sources (e.g. current
1932
+ * page state that may change between select and send).
1933
+ * @default "select"
1934
+ */
1935
+ resolveOn?: "select" | "submit";
1936
+ /**
1937
+ * COMMAND sources only. Resolve a `/name` (the first token of a command line)
1938
+ * to its menu item, for submit-time inline-command dispatch and the menu's
1939
+ * "typing args now" suppression. `createSlashCommandsSource` sets this; plain
1940
+ * `@`-mention sources leave it undefined.
1941
+ */
1942
+ matchCommand?: (name: string) => AgentWidgetContextMentionItem | undefined;
1943
+ };
1944
+ /** Context passed to the optional `renderMentionMenu` override. */
1945
+ type AgentWidgetContextMentionMenuRenderContext = {
1946
+ /** Current trigger query ("" when freshly opened). */
1947
+ query: string;
1948
+ /** Grouped, ranked, capped results ready to paint. */
1949
+ groups: {
1950
+ source: AgentWidgetContextMentionSource;
1951
+ items: AgentWidgetContextMentionItem[];
1952
+ }[];
1953
+ /** Per-source async state for loading/empty/error rendering, keyed by source id. */
1954
+ status: Record<string, "loading" | "ready" | "empty" | "error">;
1955
+ /** Index into the flat keyboard-traversal order. */
1956
+ activeIndex: number;
1957
+ /** Commit a selection (strips `@query`, adds chip, resolves on select). */
1958
+ select: (item: AgentWidgetContextMentionItem) => void;
1959
+ /** Close the menu, keeping a literal `@`. */
1960
+ close: () => void;
1961
+ };
1962
+ /** Context passed to the optional `renderMentionItem` per-row override. */
1963
+ type AgentWidgetContextMentionItemRenderContext = {
1964
+ /** The item to render. */
1965
+ item: AgentWidgetContextMentionItem;
1966
+ /** The source this item came from (its group). */
1967
+ source: AgentWidgetContextMentionSource;
1968
+ /** Current trigger query, for highlighting matches. */
1969
+ query: string;
1970
+ /** True when this row is the keyboard-highlighted one at render time. */
1971
+ active: boolean;
1972
+ /** Position in the flat keyboard-traversal order. */
1973
+ index: number;
1974
+ };
1975
+ /** Context passed to the optional `renderMentionChip` override. */
1976
+ type AgentWidgetContextMentionChipRenderContext = {
1977
+ ref: AgentWidgetContextMentionRef;
1978
+ /** Resolve-on-select lifecycle for spinner→ready→error UI. */
1979
+ status: "resolving" | "ready" | "error";
1980
+ /**
1981
+ * The resolved payload, once available (select-resolved sources only). Use it
1982
+ * to preview already-fetched content on hover. Undefined while `status` is
1983
+ * `"resolving"`, on `"error"`, and for `resolveOn:"submit"` sources (which
1984
+ * resolve at send time, not while the chip sits in the composer — for those,
1985
+ * `ref.itemId` carries the source key you can re-read on demand, e.g. a CSS
1986
+ * selector for the smart-dom source).
1987
+ */
1988
+ payload?: AgentWidgetContextMentionPayload;
1989
+ /** Remove the chip; aborts any in-flight resolve. */
1990
+ remove: () => void;
1991
+ };
1992
+ /**
1993
+ * Where a trigger char is allowed to open the menu:
1994
+ * - `"anywhere"` (default): after any whitespace or start (the `@` rule).
1995
+ * - `"line-start"`: only when the char before the trigger is a newline or the
1996
+ * start of input — the natural rule for `/` slash-commands.
1997
+ * - `"input-start"`: only at index 0 of the composer.
1998
+ */
1999
+ type AgentWidgetMentionTriggerPosition = "anywhere" | "line-start" | "input-start";
2000
+ /**
2001
+ * A SECOND (or Nth) trigger channel sharing the same menu engine — e.g. `/` for
2002
+ * slash-commands alongside `@` for context. The legacy `trigger`/`sources`
2003
+ * fields form the implicit first channel; `triggers[]` adds more. At any caret
2004
+ * at most one channel is active, so all channels drive one menu/controller.
2005
+ */
2006
+ type AgentWidgetMentionTriggerChannel = {
2007
+ /** Trigger character (e.g. "/"). */
2008
+ trigger: string;
2009
+ /** Sources for this channel (searched only when this trigger is active). */
2010
+ sources: AgentWidgetContextMentionSource[];
2011
+ /** Where the trigger may open. @default "anywhere" */
2012
+ triggerPosition?: AgentWidgetMentionTriggerPosition;
2013
+ /**
2014
+ * Let the query span spaces so a command can take ARGS (`/deploy staging`).
2015
+ * A newline still ends it. Pair with `triggerPosition: "line-start"` for
2016
+ * slash-commands. @default false
2017
+ */
2018
+ allowSpaces?: boolean;
2019
+ /** Show a composer affordance button for this channel. @default false */
2020
+ showButton?: boolean;
2021
+ /** Icon for this channel's affordance button. */
2022
+ buttonIconName?: string;
2023
+ /** Tooltip / aria-label for this channel's affordance button. */
2024
+ buttonTooltipText?: string;
2025
+ /** Placeholder for this channel's picker search field. */
2026
+ searchPlaceholder?: string;
2027
+ };
2028
+ type AgentWidgetContextMentionConfig = {
2029
+ /** @default false */
2030
+ enabled?: boolean;
2031
+ /**
2032
+ * Show the visible composer affordance button (the discoverable entry point).
2033
+ * Strongly recommended; the bare `@` trigger alone is hard to discover for
2034
+ * non-technical users. @default true
2035
+ */
2036
+ showButton?: boolean;
2037
+ /**
2038
+ * Icon for the affordance button (any registered Lucide name). Defaults to a
2039
+ * "+" signifier — the consumer-recognized "add context" affordance — rather
2040
+ * than an "@" glyph, which reads as power-user. Use `"at-sign"` on a
2041
+ * developer/power-user surface. @default "plus"
2042
+ */
2043
+ buttonIconName?: string;
2044
+ /** Tooltip / aria-label for the affordance button. @default "Add context" */
2045
+ buttonTooltipText?: string;
2046
+ /**
2047
+ * Placeholder for the picker's search field, shown when the menu is opened
2048
+ * from the affordance button (a Cursor/Copilot-style picker that inserts no
2049
+ * trigger character). The typed-trigger path keeps its query in the textarea
2050
+ * and never shows this field. @default "Search context…"
2051
+ */
2052
+ searchPlaceholder?: string;
2053
+ /** Trigger character. @default "@" */
2054
+ trigger?: string;
2055
+ /**
2056
+ * Where the primary `trigger` may open the menu. @default "anywhere"
2057
+ */
2058
+ triggerPosition?: AgentWidgetMentionTriggerPosition;
2059
+ /**
2060
+ * ADDITIONAL trigger channels sharing this engine — e.g. a `/` slash-command
2061
+ * channel next to `@` context. Each channel has its own trigger char,
2062
+ * sources, and position rule. See `AgentWidgetMentionTriggerChannel`.
2063
+ */
2064
+ triggers?: AgentWidgetMentionTriggerChannel[];
2065
+ /** Max mentions per message. @default 8 */
2066
+ maxMentions?: number;
2067
+ /** Max items shown per source group before "keep typing to narrow". @default 6 */
2068
+ maxItemsPerGroup?: number;
2069
+ /**
2070
+ * Debounce for ASYNC source search only (ms). Synchronous sources and the
2071
+ * menu's first paint are never debounced. @default 150
2072
+ */
2073
+ searchDebounceMs?: number;
2074
+ /** Registered mention sources (search + resolve). */
2075
+ sources: AgentWidgetContextMentionSource[];
2076
+ /** Chip icon fallback when a source/item omits one. @default "at-sign" */
2077
+ chipIconName?: string;
2078
+ /**
2079
+ * How each resolved mention's `llmAppend` text is wrapped into a delimited
2080
+ * block before it is prepended to the model-visible message content. Blocks
2081
+ * are joined with a blank line and the typed prose follows last.
2082
+ *
2083
+ * - `"fenced"` (default): a fenced code block with the label in the info
2084
+ * string, e.g. selecting `App.tsx` emits:
2085
+ * ```text
2086
+ * ```App.tsx
2087
+ * <file body>
2088
+ * ```
2089
+ * ```
2090
+ * The fence auto-escalates (four+ backticks) when the body itself contains a
2091
+ * fence, so a body can never terminate its own wrapper.
2092
+ * - `"document"`: Anthropic's long-context document shape, e.g.:
2093
+ * ```text
2094
+ * <document index="1">
2095
+ * <source>App.tsx</source>
2096
+ * <document_content>
2097
+ * <file body>
2098
+ * </document_content>
2099
+ * </document>
2100
+ * ```
2101
+ * Prefer this for prose/document-shaped sources per Anthropic's long-context
2102
+ * guidance (indexed `<document>` blocks improve grounding and citation). A
2103
+ * body containing the literal `</document_content>` closing tag falls back to
2104
+ * the fenced block for that entry to avoid a broken XML boundary.
2105
+ * - function form: fully owns the block for one mention — its return string is
2106
+ * used verbatim (no extra wrapping), joined with the other blocks. `index` is
2107
+ * the 0-based position among the message's mention blocks.
2108
+ *
2109
+ * @default "fenced"
2110
+ */
2111
+ llmFormat?: "fenced" | "document" | ((entry: AgentWidgetMentionLlmEntry, index: number) => string);
2112
+ /**
2113
+ * How `@` selections appear in the composer and sent user bubble.
2114
+ *
2115
+ * - `"chip"` (default): strip `@query` on select; show a compact pill in the
2116
+ * composer context row; `content` is prose-only.
2117
+ * - `"inline"`: insert an atomic styled token in the sentence (Slack/Linear/
2118
+ * Cursor style), backed by a contenteditable composer. Slash-command channels
2119
+ * (`triggers[]` with `/`) stay inline-text regardless — they already use the
2120
+ * `/name args` model, not chips. `renderMentionChip` is ignored for `@`
2121
+ * mentions in this mode.
2122
+ *
2123
+ * The resolved-context channel (`llmContent`/`contentParts`) is unchanged
2124
+ * across both modes — inline tokens are a display concern.
2125
+ *
2126
+ * @default "chip"
2127
+ */
2128
+ display?: "chip" | "inline";
2129
+ /**
2130
+ * Fired when a pick is rejected: it duplicates an existing chip in chip display
2131
+ * (`"duplicate"` — inline display allows the same item as multiple tokens, so it
2132
+ * never rejects for this reason), hits `maxMentions` (`"limit"`), or (inline
2133
+ * display) the composer text changed between parse and commit so the token could
2134
+ * not be inserted (`"stale"`).
2135
+ */
2136
+ onMentionRejected?: (item: AgentWidgetContextMentionItem, reason: "duplicate" | "limit" | "stale") => void;
2137
+ /**
2138
+ * A `resolve()` that throws/aborts: the mention is dropped and the message
2139
+ * still sends. Surface a non-blocking notice here if desired.
2140
+ */
2141
+ onMentionResolveError?: (item: AgentWidgetContextMentionItem, error: unknown) => void;
2142
+ /**
2143
+ * MID-LEVEL render override for the autocomplete menu. The widget still owns
2144
+ * trigger detection, search, debounce/abort, keyboard nav, and positioning;
2145
+ * you only supply the menu markup and drive selection through `ctx`. Omit to
2146
+ * use the built-in grouped menu. @default built-in
2147
+ */
2148
+ renderMentionMenu?: (ctx: AgentWidgetContextMentionMenuRenderContext) => HTMLElement;
2149
+ /**
2150
+ * NARROW render override for a single result row's INNER content, keeping the
2151
+ * built-in menu chrome (group headers, loading/empty/error, keyboard nav, the
2152
+ * "keep typing" hint). The widget keeps the `role="option"` wrapper and its
2153
+ * click/hover wiring; you return only the row's contents. For full menu
2154
+ * control use `renderMentionMenu` instead. Highlight is CSS-driven via the
2155
+ * wrapper's `[data-active]` attribute, so this is called once per render, not
2156
+ * on every arrow key. Ignored when `renderMentionMenu` is set. @default built-in
2157
+ */
2158
+ renderMentionItem?: (ctx: AgentWidgetContextMentionItemRenderContext) => HTMLElement;
2159
+ /**
2160
+ * MID-LEVEL render override for a single context chip. Return your own pill
2161
+ * (must include an accessible remove control wired to `ctx.remove`); reflect
2162
+ * `ctx.status` for resolve-on-select. Omit to use the built-in compact pill.
2163
+ * @default built-in
2164
+ */
2165
+ renderMentionChip?: (ctx: AgentWidgetContextMentionChipRenderContext) => HTMLElement;
2166
+ /**
2167
+ * INLINE display only (`display: "inline"`). Render override for a single inline
2168
+ * mention TOKEN — the atomic styled node that sits in the sentence, in both the
2169
+ * contenteditable composer and the read-only sent bubble. Return your own
2170
+ * element (e.g. a fully custom colored pill); the composer marks it
2171
+ * `contenteditable="false"` and stamps `data-mention-id` so it stays atomic.
2172
+ * Omit to use the built-in pill (icon + `@label`, tinted by
2173
+ * `--persona-mention-token-accent` / `ref.color`, themeable per source via the
2174
+ * `[data-mention-source]` attribute). Ignored in chip mode.
2175
+ * @default built-in
2176
+ */
2177
+ renderMentionToken?: (ctx: AgentWidgetContextMentionTokenRenderContext) => HTMLElement;
2178
+ };
2179
+ /** Render context for `renderMentionToken`. `readonly` is true in the sent bubble. */
2180
+ type AgentWidgetContextMentionTokenRenderContext = {
2181
+ ref: AgentWidgetContextMentionRef;
2182
+ readonly: boolean;
2183
+ };
1483
2184
  type AgentWidgetRequestPayloadMessage = {
1484
2185
  role: AgentWidgetMessageRole;
1485
2186
  content: MessageContent;
@@ -1942,7 +2643,13 @@ type AgentWidgetMessageActionsConfig = {
1942
2643
  * new artifact content arrives or the host calls `showArtifacts()` on the widget handle.
1943
2644
  */
1944
2645
  type AgentWidgetArtifactsLayoutConfig = {
1945
- /** Flex gap between chat column and artifact pane. @default 0.5rem */
2646
+ /**
2647
+ * Flex gap between chat column and artifact pane.
2648
+ * @default 0 (welded); detached uses the panel inset
2649
+ * @remarks In welded appearances (`panel` / `seamless`) a nonzero gap opens a
2650
+ * visible seam in the single card. It is honored geometrically (resize clamps
2651
+ * and the seam handle account for it) but is usually undesired.
2652
+ */
1946
2653
  splitGap?: string;
1947
2654
  /** Artifact column width in split mode. @default 40% */
1948
2655
  paneWidth?: string;
@@ -1973,16 +2680,39 @@ type AgentWidgetArtifactsLayoutConfig = {
1973
2680
  /** Optional max artifact width cap while resizing (`px` only). Layout still bounds by chat min width. */
1974
2681
  resizableMaxWidth?: string;
1975
2682
  /**
1976
- * Visual treatment for the artifact column in split mode.
1977
- * - `'panel'`: bordered sidebar with left border, gap, and shadow (default).
1978
- * - `'seamless'`: flush with chat: no border or shadow, container background, zero gap.
2683
+ * Visual treatment for the artifact column in a desktop split.
2684
+ * - `'panel'`: one welded card (border + radius wrap chat + pane) with a hairline
2685
+ * divider on the pane's chat-facing edge, zero gap (default).
2686
+ * - `'seamless'`: the same welded card with no internal divider or chrome, zero gap.
2687
+ * - `'detached'`: two separate elevated cards: gap from `--persona-panel-inset`,
2688
+ * all-side border and radius on each, and canvas background behind the split.
2689
+ * In an inline embed this also insets the split from the container edges on all
2690
+ * sides (the page canvas shows through), so the all-side margin no longer requires
2691
+ * `launcher.detachedPanel`.
2692
+ *
2693
+ * Default is `'panel'` unless `launcher.detachedPanel` is true, in which case an unset
2694
+ * `paneAppearance` resolves to `'detached'`. An explicit value always wins.
1979
2695
  * @default 'panel'
1980
2696
  */
1981
- paneAppearance?: "panel" | "seamless";
2697
+ paneAppearance?: "panel" | "seamless" | "detached";
1982
2698
  /** Border radius on the artifact pane (CSS length). Works with any `paneAppearance`. */
1983
2699
  paneBorderRadius?: string;
1984
2700
  /** CSS `box-shadow` on the artifact pane. Set `"none"` to suppress the default shadow. */
1985
2701
  paneShadow?: string;
2702
+ /**
2703
+ * CSS `box-shadow` for the chat column card in a detached split. Defaults to the same
2704
+ * elevation as the artifact pane; set to `"none"` to keep the chat flat while the pane stays raised.
2705
+ */
2706
+ chatShadow?: string;
2707
+ /**
2708
+ * Chat column surface in a detached split. `"card"` (default) renders the chat as an inset card
2709
+ * matching the artifact pane; `"flush"` renders the chat flush with the container (no border, radius,
2710
+ * or shadow) and insets only the artifact pane, so the chat is flat background and the pane floats.
2711
+ * Only affects an inline-embedded detached split (the container-filling case); in floating, docked,
2712
+ * or sidebar modes it falls back to the card look.
2713
+ * @default 'card'
2714
+ */
2715
+ chatSurface?: "card" | "flush";
1986
2716
  /**
1987
2717
  * Full `border` shorthand for the artifact `<aside>` (all sides). Overrides default pane borders.
1988
2718
  * Example: `"1px solid #cccccc"`.
@@ -1994,14 +2724,12 @@ type AgentWidgetArtifactsLayoutConfig = {
1994
2724
  */
1995
2725
  paneBorderLeft?: string;
1996
2726
  /**
1997
- * Desktop split only (not narrow-host drawer / not ≤640px): square the **main chat card’s**
1998
- * top-right and bottom-right radii, and round the **artifact pane’s** top-right and bottom-right
1999
- * to match `persona-rounded-2xl` (`--persona-radius-lg`) so the two columns read as one shell.
2727
+ * @deprecated No-op. Panel and seamless splits now weld into one card by default.
2000
2728
  */
2001
2729
  unifiedSplitChrome?: boolean;
2002
2730
  /**
2003
- * When `unifiedSplitChrome` is true, outer-right corner radius on the artifact column (CSS length).
2004
- * @default matches theme large radius (`--persona-radius-lg`)
2731
+ * Desktop welded split only: override the artifact pane's outer-right corner radius (CSS length).
2732
+ * @default matches the panel radius (`--persona-panel-radius`)
2005
2733
  */
2006
2734
  unifiedSplitOuterRadius?: string;
2007
2735
  /**
@@ -2021,6 +2749,10 @@ type AgentWidgetArtifactsLayoutConfig = {
2021
2749
  * @default 'default'
2022
2750
  */
2023
2751
  toolbarPreset?: "default" | "document";
2752
+ /** Visible title in the artifact toolbar. @default "Artifacts" */
2753
+ toolbarTitle?: string;
2754
+ /** Label for the artifact dismiss control. @default "Close" */
2755
+ closeButtonLabel?: string;
2024
2756
  /**
2025
2757
  * When `toolbarPreset` is `document`, show a visible "Copy" label next to the copy icon.
2026
2758
  */
@@ -2035,6 +2767,17 @@ type AgentWidgetArtifactsLayoutConfig = {
2035
2767
  documentToolbarToggleActiveBackground?: string;
2036
2768
  /** Active view/source toggle border color. Sets `--persona-artifact-doc-toggle-active-border`. */
2037
2769
  documentToolbarToggleActiveBorderColor?: string;
2770
+ /** 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. */
2771
+ showExpandToggle?: boolean;
2772
+ /** Show the copy control in the `default` toolbar preset (the `document` preset always shows it). Default: false. */
2773
+ showCopyButton?: boolean;
2774
+ /** Edge fade on the scrollable tab strip. true = both ends (dynamic). @default true */
2775
+ tabFade?: boolean | {
2776
+ start?: boolean;
2777
+ end?: boolean;
2778
+ };
2779
+ /** Tab fade width (CSS length). @default 24px */
2780
+ tabFadeSize?: string;
2038
2781
  /**
2039
2782
  * Invoked when the document toolbar Refresh control is used (before the pane re-renders).
2040
2783
  * Use to replay `connectStream`, refetch, etc.
@@ -2058,20 +2801,349 @@ type AgentWidgetArtifactsLayoutConfig = {
2058
2801
  jsonPayload: string;
2059
2802
  }) => void | Promise<void>;
2060
2803
  };
2804
+ type PersonaArtifactDisplayMode = "card" | "panel" | "inline";
2805
+ /** Context handed to custom artifact actions. Content fields are best-effort: resolved from live session state or, after a refresh, from the persisted reference-card payload. */
2806
+ type PersonaArtifactActionContext = {
2807
+ artifactId: string | null;
2808
+ title: string;
2809
+ artifactType: string;
2810
+ markdown?: string;
2811
+ file?: PersonaArtifactFileMeta;
2812
+ /** Component artifacts: pretty-printed { component, props } JSON. */
2813
+ jsonPayload?: string;
2814
+ };
2815
+ /**
2816
+ * Context passed to a `features.artifacts.statusLabel` function on every
2817
+ * artifact streaming update, once per visible surface. Treat it as read-only:
2818
+ * the function should be pure and fast (it runs per streaming delta, per
2819
+ * surface).
2820
+ */
2821
+ type PersonaArtifactStatusLabelContext = {
2822
+ artifactId: string;
2823
+ artifactType: "markdown" | "component";
2824
+ title?: string;
2825
+ /** The default subject, e.g. "document", "component", or a file type label like "HTML file". */
2826
+ typeLabel: string;
2827
+ file?: PersonaArtifactFileMeta;
2828
+ /** Accumulated streamed content length so far (0 for component artifacts). */
2829
+ chars: number;
2830
+ /** Accumulated line count so far (0 for component artifacts). */
2831
+ lines: number;
2832
+ /** Milliseconds since this artifact's first streaming update was seen. */
2833
+ elapsedMs: number;
2834
+ /** Lazy accessor for the accumulated markdown source (empty string for component artifacts). Call only if needed; parsing cost is opt-in. */
2835
+ content: () => string;
2836
+ /** Which surface is asking, so hosts can shorten for cramped spots. */
2837
+ surface: "card" | "inline-chrome" | "status-body";
2838
+ };
2839
+ /** A custom action button rendered in an artifact toolbar/card slot. */
2840
+ type PersonaArtifactCustomAction = {
2841
+ /** Stable id, used for DOM wiring and keyed re-renders. */
2842
+ id: string;
2843
+ /** Accessible label; also the visible text when showLabel is true. */
2844
+ label: string;
2845
+ /** Registry icon name, or a factory returning your own element (e.g. a brand SVG). The factory result is author-owned code, not sanitized wire data. */
2846
+ icon?: IconName | (() => HTMLElement | SVGElement);
2847
+ /** Render icon + text instead of icon-only. Default: false. */
2848
+ showLabel?: boolean;
2849
+ /** Per-artifact gate, evaluated on each render. Omitted = always visible. */
2850
+ visible?: (ctx: PersonaArtifactActionContext) => boolean;
2851
+ /** May be async; rejections are swallowed like built-in action errors. */
2852
+ onClick: (ctx: PersonaArtifactActionContext) => void | Promise<void>;
2853
+ };
2061
2854
  type AgentWidgetArtifactsFeature = {
2062
2855
  /** When true, Persona shows the artifact pane and handles artifact_* SSE events */
2063
2856
  enabled?: boolean;
2064
2857
  /** If set, artifact events for other types are ignored */
2065
2858
  allowedTypes?: PersonaArtifactKind[];
2859
+ /**
2860
+ * Where artifact bodies render. A single mode applies to all artifacts;
2861
+ * the object form sets a default plus per-type overrides.
2862
+ * Defaults to "panel" (current behavior).
2863
+ */
2864
+ display?: PersonaArtifactDisplayMode | {
2865
+ default?: PersonaArtifactDisplayMode;
2866
+ byType?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayMode>>;
2867
+ };
2066
2868
  /** Split / drawer dimensions and launcher widen behavior */
2067
2869
  layout?: AgentWidgetArtifactsLayoutConfig;
2068
2870
  /**
2069
- * Called when an artifact card action is triggered (open, download).
2070
- * Return `true` to prevent the default behavior.
2871
+ * Controls inline preview of previewable file artifacts (HTML/SVG written by
2872
+ * a Claude Managed agent). When a markdown artifact carries `file` metadata,
2873
+ * the pane can render an isolated `<iframe srcdoc>` sandbox instead of a code
2874
+ * block.
2875
+ */
2876
+ filePreview?: {
2877
+ /** Enable rendered preview for html/svg files. Defaults to enabled. Set false to force source view. */
2878
+ enabled?: boolean;
2879
+ /**
2880
+ * `sandbox` attribute for the preview iframe. Defaults to `"allow-scripts"`.
2881
+ * `allow-same-origin` is stripped (with a console warning) unless
2882
+ * `dangerouslyAllowSameOrigin` is set: the opaque origin is what isolates
2883
+ * the preview from the host page. Embedder-trusted config.
2884
+ */
2885
+ iframeSandbox?: string;
2886
+ /**
2887
+ * Allows `allow-same-origin` to pass through `iframeSandbox`. Off by
2888
+ * default because it lets agent-written file content run with the host
2889
+ * page's origin (DOM, storage, credentialed requests). Only set this when
2890
+ * every previewed file source is fully trusted.
2891
+ */
2892
+ dangerouslyAllowSameOrigin?: boolean;
2893
+ /**
2894
+ * Loading treatment for the preview iframe. Default on.
2895
+ *
2896
+ * A sandboxed `iframe srcdoc` (opaque origin, `allow-scripts` only) paints
2897
+ * blank until its content renders — seconds for artifacts that pull CDN
2898
+ * scripts (React/Babel). The default shows a themed "Loading preview…"
2899
+ * overlay over the iframe, dismissed the instant the content signals it has
2900
+ * painted (an injected `postMessage` reporter) or a hard timeout elapses.
2901
+ *
2902
+ * `false` disables the overlay and the injected ready signal entirely (the
2903
+ * srcdoc becomes the raw file source, the prior behavior). An object tunes
2904
+ * the timing; omitted / `true` uses all defaults.
2905
+ */
2906
+ loading?: boolean | {
2907
+ /** Show the overlay only if the preview is not ready after this many ms. Default 200. */
2908
+ delayMs?: number;
2909
+ /** Once shown, keep the overlay visible at least this long (anti-flicker). Default 300. */
2910
+ minVisibleMs?: number;
2911
+ /** Give up waiting and reveal the iframe regardless after this many ms. Default 8000. */
2912
+ timeoutMs?: number;
2913
+ /**
2914
+ * Append the `postMessage` ready reporter to the srcdoc so the overlay
2915
+ * dismisses on first paint rather than the iframe `load` event (which
2916
+ * fires before post-DOMContentLoaded rendering like Babel compilation).
2917
+ * Default true. When false, the overlay dismisses on `load` + a double
2918
+ * `requestAnimationFrame`, or the timeout.
2919
+ */
2920
+ injectReadySignal?: boolean;
2921
+ /**
2922
+ * Escalation text shown beside the spinner after `labelDelayMs`.
2923
+ * Default `"Starting preview..."`. `false` renders an icon-only
2924
+ * indicator forever (no text ever). A short work-naming label is
2925
+ * added only after a delay by design — icon-first, with text reserved
2926
+ * for genuinely slow loads (per Geist/Sandpack guidance; HIG warns
2927
+ * against the vague word "loading").
2928
+ */
2929
+ label?: string | false;
2930
+ /**
2931
+ * Delay before the escalation label fades in, measured from when the
2932
+ * overlay actually becomes visible (i.e. after `delayMs`), not from
2933
+ * iframe creation. Default 2000.
2934
+ */
2935
+ labelDelayMs?: number;
2936
+ /**
2937
+ * Full replacement for the default indicator (spinner + escalation
2938
+ * label). Called once when the overlay is built; return any element
2939
+ * (a brand mark, skeleton, custom animation) to own the indicator
2940
+ * content entirely (the escalation-label logic is then skipped), or
2941
+ * return `null` to fall back to the default. A thrown error also falls
2942
+ * back. Mirrors `renderInline` / `renderCard`'s null-falls-back
2943
+ * contract. The overlay backdrop, timing, and dismissal stay
2944
+ * widget-owned either way.
2945
+ */
2946
+ renderIndicator?: (ctx: {
2947
+ artifactId: string;
2948
+ config: AgentWidgetConfig;
2949
+ }) => HTMLElement | null;
2950
+ };
2951
+ };
2952
+ /**
2953
+ * Custom action buttons for the artifact pane toolbar, rendered between the
2954
+ * refresh and expand/close controls in both toolbar presets. Re-read on live
2955
+ * config updates.
2956
+ */
2957
+ toolbarActions?: PersonaArtifactCustomAction[];
2958
+ /**
2959
+ * Custom action buttons for the artifact reference card, rendered before the
2960
+ * Download button on complete artifacts. Clicks are delegated, so they
2961
+ * survive re-renders and page refresh.
2962
+ */
2963
+ cardActions?: PersonaArtifactCustomAction[];
2964
+ /**
2965
+ * File chrome (title bar + toolbar) around inline preview blocks
2966
+ * (`display: "inline"`). Default when undefined: chrome on, with the built-in
2967
+ * Copy and Expand controls. Pass `false` to render the bare preview body
2968
+ * (frame → padded body, no chrome bar), or an object to toggle the built-in
2969
+ * controls individually.
2970
+ *
2971
+ * Note: default-on chrome adds a title bar and buttons to every existing
2972
+ * inline host on upgrade; set `inlineChrome: false` to opt out.
2973
+ */
2974
+ inlineChrome?: boolean | {
2975
+ /** Show the built-in Copy button (complete artifacts only). Default true. */
2976
+ showCopy?: boolean;
2977
+ /** Show the built-in Expand button (opens the pane for this artifact). Default true. */
2978
+ showExpand?: boolean;
2979
+ /**
2980
+ * Show the built-in rendered/source view toggle (complete artifacts
2981
+ * only). Default true. The toggle is availability-gated: it appears only
2982
+ * for file-backed markdown artifacts that have a rendered alternative to
2983
+ * their source (previewable HTML/SVG, or markdown-kind files), and never
2984
+ * when `inlineBody.viewMode: "source"` forces a source-only body. Plain
2985
+ * markdown and component artifacts don't get it (the pane toggle covers
2986
+ * those).
2987
+ */
2988
+ showViewToggle?: boolean;
2989
+ };
2990
+ /**
2991
+ * Custom action buttons for the inline chrome toolbar, rendered before the
2992
+ * built-in Copy/Expand controls on complete artifacts. Same shape as
2993
+ * `cardActions`; each action's `visible` gate is respected and clicks are
2994
+ * delegated, so they survive re-renders and page refresh.
2995
+ */
2996
+ inlineActions?: PersonaArtifactCustomAction[];
2997
+ /**
2998
+ * Replace the artifact tab strip entirely (Seam A). Return an element mounted in
2999
+ * place of the built-in `.persona-artifact-list`; the pane still owns the toolbar,
3000
+ * preview body, iframe reuse, and lazy-render gate. Re-invoked when the records or
3001
+ * selection change. Custom bars own their own accessibility; use `createRovingTablist`
3002
+ * to keep keyboard/tablist behavior. When set, the built-in strip (scroll, fade,
3003
+ * tablist) is not rendered.
3004
+ *
3005
+ * Return either a fresh element per call, or the SAME element updated in place.
3006
+ * Returning a stable element preserves internal state across selection changes:
3007
+ * the pane skips remounting an unchanged node, so a roving tablist keeps keyboard
3008
+ * focus on the selected tab (a fresh element per call drops focus and breaks
3009
+ * Arrow-key nav). See the reference bars in `apps/web/src/artifact-demo.ts`.
3010
+ */
3011
+ renderTabBar?: (ctx: {
3012
+ records: PersonaArtifactRecord[];
3013
+ selectedId: string | null;
3014
+ onSelect: (id: string) => void;
3015
+ }) => HTMLElement;
3016
+ /**
3017
+ * Body layout for inline artifact blocks (`display: "inline"`). Controls how
3018
+ * the block reserves height and behaves while a file/document artifact
3019
+ * streams, so the streaming source no longer grows an unbounded `<pre>` and
3020
+ * then snaps to the completed preview. Affects only the inline block; the
3021
+ * artifact pane is unchanged.
3022
+ *
3023
+ * Defaults (a behavior change from prior versions, which grew with content
3024
+ * during streaming): a fixed 320px streaming source window with tail-follow,
3025
+ * a top edge fade, and an animated streaming→complete swap. Pass
3026
+ * `height: "auto"` to restore the old grow-with-content streaming behavior.
3027
+ */
3028
+ inlineBody?: {
3029
+ /** What the body shows while streaming. Default `"source"`. */
3030
+ streamingView?: "source" | "status";
3031
+ /**
3032
+ * How the completed body renders. `"rendered"` (default) keeps the current
3033
+ * behavior: file previews in a sandboxed iframe, markdown through the
3034
+ * markdown pipeline. `"source"` always shows the raw syntax-highlighted
3035
+ * source instead — for hosts where the artifact is input to the host system
3036
+ * (a code editor, a query runner) rather than something to preview. Unlike
3037
+ * `filePreview.enabled: false`, this also covers markdown-kind files and
3038
+ * plain markdown artifacts. Component artifacts always render through the
3039
+ * registry.
3040
+ */
3041
+ viewMode?: "rendered" | "source";
3042
+ /**
3043
+ * Body height per state. A number reserves that many px for the whole body
3044
+ * region (border-box, padding included) with internal scroll — the
3045
+ * zero-layout-shift path; `"auto"` means content-sized. A
3046
+ * scalar applies to both the streaming and complete states; the object form
3047
+ * sets them independently. Default `320` for both states.
3048
+ *
3049
+ * Note: with `"auto"` on the complete state, non-iframe bodies (rendered
3050
+ * markdown, source view, component) are content-sized, but a file-preview
3051
+ * iframe cannot be content-sized without postMessage plumbing, so it falls
3052
+ * back to the CSS-var default (`--persona-artifact-inline-frame-height`,
3053
+ * 320px).
3054
+ *
3055
+ * Numeric heights are applied via the CSS var
3056
+ * `--persona-artifact-inline-body-height` on the block root. The older
3057
+ * `--persona-artifact-inline-frame-height` var still overrides the iframe
3058
+ * height when this one is unset, so themes pinned to it keep working.
3059
+ */
3060
+ height?: number | "auto" | {
3061
+ streaming?: number | "auto";
3062
+ complete?: number | "auto";
3063
+ };
3064
+ /**
3065
+ * Tail-follow the newest streamed lines in a fixed-height source window: if
3066
+ * the viewport is already at the bottom, keep it pinned as content arrives;
3067
+ * if the reader scrolled up, don't fight them. Only meaningful for a numeric
3068
+ * streaming height. Default `true`.
3069
+ *
3070
+ * Precedence: ignored when `overflow: "clip"` (a clipped window shows the
3071
+ * top of the document and never scrolls, so there is no tail to follow).
3072
+ */
3073
+ followOutput?: boolean;
3074
+ /**
3075
+ * How a fixed-height source window handles content taller than the window.
3076
+ *
3077
+ * - `"scroll"` (default) — the current behavior: an internally scrollable
3078
+ * window that tail-follows the newest streamed lines (see `followOutput`),
3079
+ * so the reader sees the growing tail of the document.
3080
+ * - `"clip"` — a fixed-height window that shows the TOP of the document,
3081
+ * `overflow: hidden` with no internal scroll and no tail-follow
3082
+ * (`followOutput` is ignored in this mode). When content overflows the
3083
+ * window a bottom edge fade signals there is more below (the top is always
3084
+ * visible, so a top fade never applies); an explicit `fadeMask` still wins
3085
+ * over this clip-mode default. When the inline chrome's Expand control is
3086
+ * enabled the whole body doubles as an expand hitbox (click / Enter / Space
3087
+ * opens the artifact in the pane), matching the industry inline-card
3088
+ * pattern; otherwise the clip is purely visual.
3089
+ *
3090
+ * Only meaningful for a numeric streaming/complete height. Default
3091
+ * `"scroll"`.
3092
+ */
3093
+ overflow?: "scroll" | "clip";
3094
+ /**
3095
+ * Edge fade masks on the fixed-height streaming window (a top fade signals
3096
+ * clipped content above, a bottom fade signals clipped content below). Each
3097
+ * fade renders only when content is actually clipped on that edge, so with
3098
+ * tail-follow pinned at the bottom the bottom fade stays inert until the
3099
+ * reader scrolls up mid-stream. `true` = `{ top: true, bottom: true }`,
3100
+ * `false` = none. Default `{ top: true, bottom: true }`.
3101
+ */
3102
+ fadeMask?: boolean | {
3103
+ top?: boolean;
3104
+ bottom?: boolean;
3105
+ };
3106
+ /**
3107
+ * Animate the streaming→complete body swap. `"auto"` uses the View
3108
+ * Transitions API when supported and `prefers-reduced-motion` is off;
3109
+ * `"none"` swaps instantly. Default `"auto"`.
3110
+ */
3111
+ transition?: "auto" | "none";
3112
+ /**
3113
+ * What the block becomes once the artifact completes.
3114
+ *
3115
+ * - `"inline"` (default) — the streamed body stays inline forever, as
3116
+ * configured by the other `inlineBody` options.
3117
+ * - `"card"` — the block streams inline as configured, then collapses to the
3118
+ * compact artifact reference card once the artifact completes (the Copilot
3119
+ * "chiclet" / Claude side-panel handoff pattern), keeping the thread
3120
+ * scannable. The collapse plays as a short CSS height transition (skipped
3121
+ * under `prefers-reduced-motion`); it does not use the View Transitions
3122
+ * API, so `transition` does not affect it. After the collapse the card's
3123
+ * normal actions apply (click opens the artifact pane). `viewMode`, the
3124
+ * inline rendered/source view toggle, `inlineActions`, and inline copy are
3125
+ * streaming-phase-only in this mode and inert once the block is a card
3126
+ * (there is nothing to toggle or copy on a collapsed card). Blocks that are
3127
+ * already complete when they first render (page-refresh hydration) render
3128
+ * the card directly, with no flash of the inline body and no animation.
3129
+ *
3130
+ * Default `"inline"`.
3131
+ */
3132
+ completeDisplay?: "inline" | "card";
3133
+ };
3134
+ /**
3135
+ * Called when an artifact action is triggered (open, download, expand).
3136
+ * Return `true` to intercept: the widget then does not change state.
3137
+ * For `expand`, `expanded` is the state the toggle is about to enter and
3138
+ * `artifactId` is the currently selected artifact (or `null` when none).
2071
3139
  */
2072
3140
  onArtifactAction?: (action: {
2073
3141
  type: 'open' | 'download';
2074
3142
  artifactId: string;
3143
+ } | {
3144
+ type: 'expand';
3145
+ artifactId: string | null;
3146
+ expanded: boolean;
2075
3147
  }) => boolean | void;
2076
3148
  /**
2077
3149
  * Custom renderer for artifact reference cards shown in the message thread.
@@ -2087,6 +3159,72 @@ type AgentWidgetArtifactsFeature = {
2087
3159
  config: AgentWidgetConfig;
2088
3160
  defaultRenderer: () => HTMLElement;
2089
3161
  }) => HTMLElement | null;
3162
+ /**
3163
+ * Custom renderer for inline artifact blocks (display: "inline"), mirroring
3164
+ * `renderCard`. Return an element to replace the default inline preview,
3165
+ * or null to use the default.
3166
+ */
3167
+ renderInline?: (context: {
3168
+ artifact: {
3169
+ artifactId: string;
3170
+ title: string;
3171
+ artifactType: string;
3172
+ status: string;
3173
+ };
3174
+ config: AgentWidgetConfig;
3175
+ defaultRenderer: () => HTMLElement;
3176
+ }) => HTMLElement | null;
3177
+ /**
3178
+ * Text shown while an artifact streams, in place of the default
3179
+ * `Generating <type>...` status. Applies to every streaming surface: the
3180
+ * reference card status line, the inline chrome meta label, and the inline
3181
+ * streaming status body (`inlineBody.streamingView: "status"`).
3182
+ *
3183
+ * - A plain string replaces the default label everywhere (localization or
3184
+ * brand voice).
3185
+ * - A function is called on every artifact update for each visible surface;
3186
+ * it must be pure and fast. Returning a string sets the animated label
3187
+ * only. Returning `{ label, detail }` splits the status into an animated
3188
+ * label (re-applied only when its text changes, so the loading animation
3189
+ * stays stable) and a plain un-animated detail span that may update freely
3190
+ * per delta (live counters).
3191
+ *
3192
+ * Default when unset: the current behavior, `Generating <type>...` with no
3193
+ * detail. If the function throws, the default label is used for that update
3194
+ * (a bad host callback must never break rendering). There is deliberately no
3195
+ * percent progress: streams do not announce total length, so counts and
3196
+ * elapsed time are the only truthful signals.
3197
+ */
3198
+ statusLabel?: string | ((ctx: PersonaArtifactStatusLabelContext) => string | {
3199
+ label: string;
3200
+ detail?: string;
3201
+ });
3202
+ /**
3203
+ * Animation applied to the artifact card's "Generating …" status text while
3204
+ * the artifact streams. Character-by-character modes (`shimmer`,
3205
+ * `shimmer-color`, `rainbow`) wrap each character in a span with a staggered
3206
+ * `animation-delay`; `pulse` fades the whole status text; `none` disables the
3207
+ * animation. Honors `prefers-reduced-motion`.
3208
+ * @default "shimmer"
3209
+ */
3210
+ loadingAnimation?: AgentWidgetToolCallLoadingAnimation;
3211
+ /**
3212
+ * Duration of one full animation cycle in milliseconds.
3213
+ * Applies to pulse, shimmer, shimmer-color, and rainbow modes.
3214
+ * @default 2000
3215
+ */
3216
+ loadingAnimationDuration?: number;
3217
+ /**
3218
+ * Primary color for shimmer-color animation mode.
3219
+ * Defaults to the current text color.
3220
+ */
3221
+ loadingAnimationColor?: string;
3222
+ /**
3223
+ * Secondary/end color for shimmer-color animation mode.
3224
+ * Creates a gradient sweep between `loadingAnimationColor` and this color.
3225
+ * @default "#3b82f6"
3226
+ */
3227
+ loadingAnimationSecondaryColor?: string;
2090
3228
  };
2091
3229
  /**
2092
3230
  * How the transcript scrolls while an assistant response streams in.
@@ -2214,6 +3352,13 @@ type AgentWidgetToolCallDisplayFeature = {
2214
3352
  * @default false
2215
3353
  */
2216
3354
  grouped?: boolean;
3355
+ /**
3356
+ * Controls how a grouped tool sequence is rendered.
3357
+ * - `"stack"`: show the group summary and each child tool row.
3358
+ * - `"summary"`: show one consolidated summary row only.
3359
+ * @default "stack"
3360
+ */
3361
+ groupedMode?: "stack" | "summary";
2217
3362
  /**
2218
3363
  * When false, tool call bubbles show only the collapsed summary with no
2219
3364
  * expand/collapse toggle. Users see tool awareness without full details.
@@ -2903,6 +4048,24 @@ type AgentWidgetLauncherConfig = {
2903
4048
  * @default false
2904
4049
  */
2905
4050
  sidebarMode?: boolean;
4051
+ /**
4052
+ * When true, the widget panel renders as a detached card inset within its region,
4053
+ * with rounded corners on all sides and elevation (shadow plus hairline border),
4054
+ * instead of sitting flush against the region edges.
4055
+ *
4056
+ * The gap around the card is themed via `theme.components.panel.inset`. The
4057
+ * background revealed behind it is themed via `theme.components.panel.canvasBackground`
4058
+ * in docked and inline embed modes. In sidebar mode the gap stays click-through, so the
4059
+ * host page shows through it the same way it does in floating mode, and canvasBackground
4060
+ * is a no-op there.
4061
+ *
4062
+ * Applies to sidebar, docked, and inline embed modes. Ignored in mobile fullscreen,
4063
+ * where chrome is already suppressed. Floating mode is unchanged, since it already
4064
+ * renders as a detached card.
4065
+ *
4066
+ * @default false
4067
+ */
4068
+ detachedPanel?: boolean;
2906
4069
  /**
2907
4070
  * Width of the sidebar panel when sidebarMode is true.
2908
4071
  * @default "420px"
@@ -4937,6 +6100,18 @@ type AgentWidgetConfig = {
4937
6100
  }) => string;
4938
6101
  plugins?: AgentWidgetPlugin[];
4939
6102
  contextProviders?: AgentWidgetContextProvider[];
6103
+ /**
6104
+ * Context mentions: let users explicitly pull external context into a turn by
6105
+ * typing `@` or clicking a visible composer button, both opening one shared
6106
+ * searchable menu of host-provided sources. Selecting a mention adds a
6107
+ * removable pill chip; resolved content reaches the model via `llmAppend`
6108
+ * (default) or the opt-in structured `context` channel.
6109
+ *
6110
+ * Disabled by default. When enabled, the mention runtime is lazy-loaded from a
6111
+ * sibling chunk on first use, so sites that leave it off pay no bundle cost.
6112
+ * See `docs/context-mentions-plan.md`.
6113
+ */
6114
+ contextMentions?: AgentWidgetContextMentionConfig;
4940
6115
  requestMiddleware?: AgentWidgetRequestMiddleware;
4941
6116
  actionParsers?: AgentWidgetActionParser[];
4942
6117
  actionHandlers?: AgentWidgetActionHandler[];
@@ -5479,6 +6654,25 @@ type AgentWidgetMessage = {
5479
6654
  * The `content` field contains the text-only representation for display.
5480
6655
  */
5481
6656
  contentParts?: ContentPart[];
6657
+ /**
6658
+ * Context mentions attached to this (user) message, for transcript fidelity +
6659
+ * chip rendering in the sent bubble. Refs only — the resolved payloads are
6660
+ * merged into `llmContent`/`contentParts` (model-visible) at send time.
6661
+ */
6662
+ contextMentions?: AgentWidgetContextMentionRef[];
6663
+ /**
6664
+ * Ordered prose + mention blocks for inline-mode rendering and composer history
6665
+ * recall (`contextMentions.display: "inline"`). Present only on inline-mode user
6666
+ * messages; when omitted the sent bubble falls back to the chip row derived from
6667
+ * `contextMentions`. Display/transcript concern only — not the model channel.
6668
+ */
6669
+ contentSegments?: AgentWidgetContentSegment[];
6670
+ /**
6671
+ * Resolved opt-in structured mention context for this (user) message, merged
6672
+ * into the request `context` under `mentions.<sourceId>.<itemId>` by the
6673
+ * client. Internal: set at send time from each source's `resolve().context`.
6674
+ */
6675
+ mentionContext?: Record<string, unknown>;
5482
6676
  streaming?: boolean;
5483
6677
  variant?: AgentWidgetMessageVariant;
5484
6678
  sequence?: number;
@@ -5549,6 +6743,21 @@ type AgentWidgetMessage = {
5549
6743
  */
5550
6744
  stopReason?: StopReasonKind;
5551
6745
  };
6746
+ /**
6747
+ * Optional file metadata attached to a markdown artifact that represents a
6748
+ * concrete file written by a Claude Managed agent (e.g. `/mnt/session/outputs/cat.html`).
6749
+ * Additive: the artifact content stays a fenced code block on the wire for
6750
+ * backward compatibility; new widgets use this to recover the raw source and
6751
+ * offer a preview. Mirrors the `file` field on the core `artifact_start` event.
6752
+ */
6753
+ type PersonaArtifactFileMeta = {
6754
+ /** Full path of the written file (also used as the artifact title). */
6755
+ path: string;
6756
+ /** MIME type of the file (used for download and preview decisions). */
6757
+ mimeType: string;
6758
+ /** Fence language the content was encoded with (html/xml/md/text). */
6759
+ language?: string;
6760
+ };
5552
6761
  type PersonaArtifactRecord = {
5553
6762
  id: string;
5554
6763
  artifactType: PersonaArtifactKind;
@@ -5557,6 +6766,8 @@ type PersonaArtifactRecord = {
5557
6766
  markdown?: string;
5558
6767
  component?: string;
5559
6768
  props?: Record<string, unknown>;
6769
+ /** Present when this markdown artifact is a previewable file (see PersonaArtifactFileMeta). */
6770
+ file?: PersonaArtifactFileMeta;
5560
6771
  };
5561
6772
 
5562
6773
  /** Field definition types for the declarative configurator system (headless: no DOM) */