@ai-matrx/rich-content 0.2.4 → 0.2.7

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 (381) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/code-block/CodeBlock.d.ts +44 -0
  3. package/dist/code-block/CodeBlock.js +449 -0
  4. package/dist/code-block/CodeBlockHeader.d.ts +63 -0
  5. package/dist/code-block/CodeBlockHeader.js +472 -0
  6. package/dist/code-block/CodeEditorLoading.d.ts +3 -0
  7. package/dist/code-block/CodeEditorLoading.js +34 -0
  8. package/dist/code-block/LanguageDisplay.d.ts +28 -0
  9. package/dist/code-block/LanguageDisplay.js +279 -0
  10. package/dist/code-block/SmallCodeEditor.d.ts +30 -0
  11. package/dist/code-block/SmallCodeEditor.js +22 -0
  12. package/dist/code-block/StickyButtons.d.ts +35 -0
  13. package/dist/code-block/StickyButtons.js +88 -0
  14. package/dist/code-block/highlight/ShikiCodeView.d.ts +26 -0
  15. package/dist/code-block/highlight/ShikiCodeView.js +134 -0
  16. package/dist/code-block/highlight/shiki-highlighter.d.ts +14 -0
  17. package/dist/code-block/highlight/shiki-highlighter.js +126 -0
  18. package/dist/code-block/highlight/useHighlightedLines.d.ts +18 -0
  19. package/dist/code-block/highlight/useHighlightedLines.js +142 -0
  20. package/dist/code-block/sticky-inset.d.ts +6 -0
  21. package/dist/code-block/sticky-inset.js +10 -0
  22. package/dist/display/block-interaction.d.ts +33 -0
  23. package/dist/display/block-interaction.js +13 -0
  24. package/dist/display/blocks/ChatCollapsibleWrapper.d.ts +13 -0
  25. package/dist/display/blocks/ChatCollapsibleWrapper.js +56 -0
  26. package/dist/display/blocks/buildMediaSource.d.ts +25 -0
  27. package/dist/display/blocks/buildMediaSource.js +43 -0
  28. package/dist/display/blocks/canvas-adaptive.d.ts +118 -0
  29. package/dist/display/blocks/canvas-adaptive.js +127 -0
  30. package/dist/display/blocks/canvas-fit.d.ts +24 -0
  31. package/dist/display/blocks/canvas-fit.js +19 -0
  32. package/dist/display/blocks/chart/ChartBlock.d.ts +8 -0
  33. package/dist/display/blocks/chart/ChartBlock.js +125 -0
  34. package/dist/display/blocks/chart/ChartCanvas.d.ts +18 -0
  35. package/dist/display/blocks/chart/ChartCanvas.js +159 -0
  36. package/dist/display/blocks/chart/TableChart.d.ts +25 -0
  37. package/dist/display/blocks/chart/TableChart.js +97 -0
  38. package/dist/display/blocks/chart/chart-spec.d.ts +39 -0
  39. package/dist/display/blocks/chart/chart-spec.js +128 -0
  40. package/dist/display/blocks/chart/labels.d.ts +20 -0
  41. package/dist/display/blocks/chart/labels.js +7 -0
  42. package/dist/display/blocks/chart/table-chart.d.ts +37 -0
  43. package/dist/display/blocks/chart/table-chart.js +231 -0
  44. package/dist/display/blocks/common/BlockHeaderWrapper.d.ts +56 -0
  45. package/dist/display/blocks/common/BlockHeaderWrapper.js +310 -0
  46. package/dist/display/blocks/common/ContentBlockWrapper.d.ts +40 -0
  47. package/dist/display/blocks/common/ContentBlockWrapper.js +214 -0
  48. package/dist/display/blocks/common/SandboxedHtml.d.ts +27 -0
  49. package/dist/display/blocks/common/SandboxedHtml.js +26 -0
  50. package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
  51. package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
  52. package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
  53. package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
  54. package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
  55. package/dist/display/blocks/diagram/diagram-printer.js +294 -0
  56. package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
  57. package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
  58. package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
  59. package/dist/display/blocks/diagram/layout-utils.js +347 -0
  60. package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
  61. package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
  62. package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
  63. package/dist/display/blocks/diagram/presentation-direction.js +19 -0
  64. package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
  65. package/dist/display/blocks/diagram/ui-utils.js +18 -0
  66. package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
  67. package/dist/display/blocks/diff/DiffBlock.js +119 -0
  68. package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
  69. package/dist/display/blocks/diff/DiffCanvas.js +20 -0
  70. package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
  71. package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
  72. package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
  73. package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
  74. package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
  75. package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
  76. package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
  77. package/dist/display/blocks/images/ImageBlock.js +265 -0
  78. package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
  79. package/dist/display/blocks/json/JsonBlock.js +562 -0
  80. package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
  81. package/dist/display/blocks/json/JsonTableView.js +173 -0
  82. package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
  83. package/dist/display/blocks/json/json-compact-stringify.js +52 -0
  84. package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
  85. package/dist/display/blocks/json/json-tabular-utils.js +121 -0
  86. package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
  87. package/dist/display/blocks/links/LinkComponent.js +373 -0
  88. package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
  89. package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
  90. package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
  91. package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
  92. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
  93. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
  94. package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
  95. package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
  96. package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
  97. package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
  98. package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
  99. package/dist/display/blocks/svg/SvgBlock.js +126 -0
  100. package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
  101. package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
  102. package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
  103. package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
  104. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
  105. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
  106. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
  107. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
  108. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
  109. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
  110. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
  111. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
  112. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
  113. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
  114. package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
  115. package/dist/display/blocks/toml/TomlBlock.js +167 -0
  116. package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
  117. package/dist/display/blocks/tree/TreeBlock.js +163 -0
  118. package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
  119. package/dist/display/blocks/xml/XmlBlock.js +197 -0
  120. package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
  121. package/dist/display/blocks/xml/readXmlTag.js +1 -0
  122. package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
  123. package/dist/display/blocks/xml/xml-tokenize.js +169 -0
  124. package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
  125. package/dist/display/blocks/yaml/YamlBlock.js +191 -0
  126. package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
  127. package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
  128. package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
  129. package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
  130. package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
  131. package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
  132. package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
  133. package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
  134. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
  135. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
  136. package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
  137. package/dist/display/chat-markdown/KindTextGate.js +60 -0
  138. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
  139. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
  140. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
  141. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
  142. package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
  143. package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
  144. package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
  145. package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
  146. package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
  147. package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
  148. package/dist/display/chat-markdown/constants.d.ts +14 -0
  149. package/dist/display/chat-markdown/constants.js +317 -0
  150. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
  151. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
  152. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
  153. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
  154. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
  155. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
  156. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
  157. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
  158. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
  159. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
  160. package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
  161. package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
  162. package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
  163. package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
  164. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
  165. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
  166. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
  167. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
  168. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
  169. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
  170. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
  171. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
  172. package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
  173. package/dist/display/chat-markdown/kind-source-view.js +14 -0
  174. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
  175. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
  176. package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
  177. package/dist/display/chat-markdown/progressive-mount.js +90 -0
  178. package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
  179. package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
  180. package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
  181. package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
  182. package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
  183. package/dist/display/chat-markdown/stable-blocks.js +54 -0
  184. package/dist/display/chat-markdown/types.d.ts +11 -0
  185. package/dist/display/chat-markdown/types.js +26 -0
  186. package/dist/display/specimen/SpecimenContext.d.ts +26 -0
  187. package/dist/display/specimen/SpecimenContext.js +64 -0
  188. package/dist/display/tables/MarkdownTable.d.ts +23 -0
  189. package/dist/display/tables/MarkdownTable.js +769 -0
  190. package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
  191. package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
  192. package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
  193. package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
  194. package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
  195. package/dist/display/tables/SendToWorkbookButton.js +93 -0
  196. package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
  197. package/dist/display/tables/TableSaveToMenu.js +98 -0
  198. package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
  199. package/dist/display/tables/TableWithSeparatedControls.js +574 -0
  200. package/dist/display/tables/ViewTableModal.d.ts +14 -0
  201. package/dist/display/tables/ViewTableModal.js +67 -0
  202. package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
  203. package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
  204. package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
  205. package/dist/display/tables/editing/RowActionsMenu.js +80 -0
  206. package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
  207. package/dist/display/tables/editing/TableEditToolbar.js +63 -0
  208. package/dist/display/tables/editing/tableMutations.d.ts +50 -0
  209. package/dist/display/tables/editing/tableMutations.js +148 -0
  210. package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
  211. package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
  212. package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
  213. package/dist/display/tables/editing/useTableUndo.js +17 -0
  214. package/dist/display/tables/table-action-row.d.ts +8 -0
  215. package/dist/display/tables/table-action-row.js +31 -0
  216. package/dist/display/tables/table-viewer.d.ts +13 -0
  217. package/dist/display/tables/table-viewer.js +18 -0
  218. package/dist/host/ErrorActions.d.ts +1 -1
  219. package/dist/host/ErrorNotice.d.ts +10 -0
  220. package/dist/host/ErrorNotice.js +19 -0
  221. package/dist/host/app-bindings.d.ts +155 -0
  222. package/dist/host/app-bindings.js +160 -0
  223. package/dist/host/diagnostics.d.ts +2 -2
  224. package/dist/host/diagnostics.js +2 -1
  225. package/dist/host/tables.d.ts +1 -6
  226. package/dist/host/types.d.ts +14 -7
  227. package/dist/levels/RichContent.d.ts +3 -0
  228. package/dist/levels/RichContent.js +102 -0
  229. package/dist/levels/RichContentInline.d.ts +28 -0
  230. package/dist/levels/RichContentInline.js +61 -0
  231. package/dist/levels/RichContentPreview.d.ts +12 -0
  232. package/dist/levels/RichContentPreview.js +39 -0
  233. package/dist/levels/RichContentStandardImpl.d.ts +12 -0
  234. package/dist/levels/RichContentStandardImpl.js +27 -0
  235. package/dist/levels/RichContentStaticProse.d.ts +46 -0
  236. package/dist/levels/RichContentStaticProse.js +100 -0
  237. package/dist/levels/depth.d.ts +18 -0
  238. package/dist/levels/depth.js +32 -0
  239. package/dist/levels/prose/inline-level-elements.d.ts +19 -0
  240. package/dist/levels/prose/inline-level-elements.js +103 -0
  241. package/dist/levels/prose/prose-block-elements.d.ts +25 -0
  242. package/dist/levels/prose/prose-block-elements.js +313 -0
  243. package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
  244. package/dist/levels/prose/prose-inline-elements.js +143 -0
  245. package/dist/levels/prose/prose-prepare.d.ts +50 -0
  246. package/dist/levels/prose/prose-prepare.js +246 -0
  247. package/dist/levels/prose/remote-image-policy.d.ts +34 -0
  248. package/dist/levels/prose/remote-image-policy.js +153 -0
  249. package/dist/levels/prose/variant-root.d.ts +9 -0
  250. package/dist/levels/prose/variant-root.js +34 -0
  251. package/dist/levels/rich-content-types.d.ts +93 -0
  252. package/dist/levels/rich-content-types.js +4 -0
  253. package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
  254. package/dist/levels/server/DelimiterViolationReport.js +24 -0
  255. package/dist/levels/server/RichContentServer.d.ts +27 -0
  256. package/dist/levels/server/RichContentServer.js +97 -0
  257. package/dist/levels/standard/NestedRichContent.d.ts +7 -0
  258. package/dist/levels/standard/NestedRichContent.js +70 -0
  259. package/dist/levels/standard/StandardBlocks.d.ts +13 -0
  260. package/dist/levels/standard/StandardBlocks.js +239 -0
  261. package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
  262. package/dist/levels/standard/StandardKindRegion.js +69 -0
  263. package/dist/levels/standard/standard-kind-region.d.ts +19 -0
  264. package/dist/levels/standard/standard-kind-region.js +21 -0
  265. package/dist/levels/standard/static-standard.d.ts +23 -0
  266. package/dist/levels/standard/static-standard.js +187 -0
  267. package/dist/levels/standard/stream-holdback.d.ts +2 -0
  268. package/dist/levels/standard/stream-holdback.js +77 -0
  269. package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
  270. package/dist/mermaid/MermaidFullscreen.js +71 -0
  271. package/dist/mermaid/MermaidRenderer.d.ts +20 -0
  272. package/dist/mermaid/MermaidRenderer.js +267 -0
  273. package/dist/mermaid/MermaidView.d.ts +27 -0
  274. package/dist/mermaid/MermaidView.js +68 -0
  275. package/dist/mermaid/MermaidViewport.d.ts +75 -0
  276. package/dist/mermaid/MermaidViewport.js +286 -0
  277. package/dist/mermaid/adapters/er.d.ts +10 -0
  278. package/dist/mermaid/adapters/er.js +205 -0
  279. package/dist/mermaid/adapters/flowchart.d.ts +17 -0
  280. package/dist/mermaid/adapters/flowchart.js +634 -0
  281. package/dist/mermaid/adapters/journey.d.ts +9 -0
  282. package/dist/mermaid/adapters/journey.js +207 -0
  283. package/dist/mermaid/adapters/mindmap.d.ts +12 -0
  284. package/dist/mermaid/adapters/mindmap.js +252 -0
  285. package/dist/mermaid/adapters/pie.d.ts +7 -0
  286. package/dist/mermaid/adapters/pie.js +172 -0
  287. package/dist/mermaid/adapters/quadrant.d.ts +8 -0
  288. package/dist/mermaid/adapters/quadrant.js +231 -0
  289. package/dist/mermaid/adapters/register.d.ts +7 -0
  290. package/dist/mermaid/adapters/register.js +19 -0
  291. package/dist/mermaid/adapters/sequence.d.ts +8 -0
  292. package/dist/mermaid/adapters/sequence.js +251 -0
  293. package/dist/mermaid/adapters/state.d.ts +12 -0
  294. package/dist/mermaid/adapters/state.js +245 -0
  295. package/dist/mermaid/adapters/timeline.d.ts +8 -0
  296. package/dist/mermaid/adapters/timeline.js +245 -0
  297. package/dist/mermaid/catalog.d.ts +33 -0
  298. package/dist/mermaid/catalog.js +202 -0
  299. package/dist/mermaid/diagram-type.d.ts +39 -0
  300. package/dist/mermaid/diagram-type.js +89 -0
  301. package/dist/mermaid/export.d.ts +21 -0
  302. package/dist/mermaid/export.js +112 -0
  303. package/dist/mermaid/extract-fence.d.ts +15 -0
  304. package/dist/mermaid/extract-fence.js +22 -0
  305. package/dist/mermaid/lazy-draw.d.ts +40 -0
  306. package/dist/mermaid/lazy-draw.js +168 -0
  307. package/dist/mermaid/model/adapter.d.ts +28 -0
  308. package/dist/mermaid/model/adapter.js +16 -0
  309. package/dist/mermaid/model/ops.d.ts +282 -0
  310. package/dist/mermaid/model/ops.js +9 -0
  311. package/dist/mermaid/model/round-trip.d.ts +22 -0
  312. package/dist/mermaid/model/round-trip.js +45 -0
  313. package/dist/mermaid/model/types.d.ts +271 -0
  314. package/dist/mermaid/model/types.js +0 -0
  315. package/dist/mermaid/print-render.d.ts +9 -0
  316. package/dist/mermaid/print-render.js +39 -0
  317. package/dist/mermaid/runtime.d.ts +25 -0
  318. package/dist/mermaid/runtime.js +183 -0
  319. package/dist/mermaid/sanitize.d.ts +46 -0
  320. package/dist/mermaid/sanitize.js +234 -0
  321. package/dist/mermaid/types.d.ts +43 -0
  322. package/dist/mermaid/types.js +21 -0
  323. package/dist/mermaid/view/ViewModePane.d.ts +24 -0
  324. package/dist/mermaid/view/ViewModePane.js +9 -0
  325. package/dist/utils/client-lazy.d.ts +1 -1
  326. package/dist/utils/client-lazy.js +4 -1
  327. package/dist/utils/lifted/DiffView.d.ts +10 -0
  328. package/dist/utils/lifted/DiffView.js +26 -0
  329. package/dist/utils/lifted/IconButton.d.ts +24 -0
  330. package/dist/utils/lifted/IconButton.js +43 -0
  331. package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
  332. package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
  333. package/dist/utils/lifted/ShimmerText.d.ts +5 -0
  334. package/dist/utils/lifted/ShimmerText.js +21 -0
  335. package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
  336. package/dist/utils/lifted/SuspenseLoader.js +42 -0
  337. package/dist/utils/lifted/Tooltip.d.ts +20 -0
  338. package/dist/utils/lifted/Tooltip.js +52 -0
  339. package/dist/utils/lifted/artifactId.d.ts +34 -0
  340. package/dist/utils/lifted/artifactId.js +15 -0
  341. package/dist/utils/lifted/canvasContent.d.ts +63 -0
  342. package/dist/utils/lifted/canvasContent.js +98 -0
  343. package/dist/utils/lifted/captureReactError.d.ts +24 -0
  344. package/dist/utils/lifted/captureReactError.js +28 -0
  345. package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
  346. package/dist/utils/lifted/chunk-load-recovery.js +36 -0
  347. package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
  348. package/dist/utils/lifted/code-editor-agent-types.js +0 -0
  349. package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
  350. package/dist/utils/lifted/code-editor-agents.js +52 -0
  351. package/dist/utils/lifted/code-language-extension.d.ts +1 -0
  352. package/dist/utils/lifted/code-language-extension.js +60 -0
  353. package/dist/utils/lifted/custom-icons.d.ts +16 -0
  354. package/dist/utils/lifted/custom-icons.js +47 -0
  355. package/dist/utils/lifted/durability.d.ts +16 -0
  356. package/dist/utils/lifted/durability.js +45 -0
  357. package/dist/utils/lifted/errors.d.ts +30 -0
  358. package/dist/utils/lifted/errors.js +29 -0
  359. package/dist/utils/lifted/html-document.d.ts +1 -0
  360. package/dist/utils/lifted/html-document.js +12 -0
  361. package/dist/utils/lifted/languageOptions.d.ts +9 -0
  362. package/dist/utils/lifted/languageOptions.js +52 -0
  363. package/dist/utils/lifted/languages.d.ts +34 -0
  364. package/dist/utils/lifted/languages.js +175 -0
  365. package/dist/utils/lifted/loading-spinner.d.ts +18 -0
  366. package/dist/utils/lifted/loading-spinner.js +200 -0
  367. package/dist/utils/lifted/media-refs.d.ts +13 -0
  368. package/dist/utils/lifted/media-refs.js +27 -0
  369. package/dist/utils/lifted/scroll-root.d.ts +1 -0
  370. package/dist/utils/lifted/scroll-root.js +25 -0
  371. package/dist/utils/lifted/syntax-themes.d.ts +32 -0
  372. package/dist/utils/lifted/syntax-themes.js +100 -0
  373. package/dist/utils/lifted/url-utm.d.ts +24 -0
  374. package/dist/utils/lifted/url-utm.js +66 -0
  375. package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
  376. package/dist/utils/lifted/use-is-mounted.js +21 -0
  377. package/dist/utils/lifted/useToastManager.d.ts +1 -0
  378. package/dist/utils/lifted/useToastManager.js +7 -0
  379. package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
  380. package/dist/utils/report-kind-at-raw-renderer.js +32 -0
  381. package/package.json +48 -10
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import { captureReactRenderError } from "../../../utils/lifted/captureReactError.js";
3
+ import {
4
+ isChunkLoadError,
5
+ notifyChunkLoadError
6
+ } from "../../../utils/lifted/chunk-load-recovery.js";
7
+ class MarkdownErrorBoundary extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.state = { hasError: false };
11
+ }
12
+ static getDerivedStateFromError(_) {
13
+ return { hasError: true };
14
+ }
15
+ componentDidCatch(error, errorInfo) {
16
+ console.error(
17
+ "[MarkdownStream] Error caught by boundary:",
18
+ error,
19
+ errorInfo
20
+ );
21
+ if (isChunkLoadError(error)) {
22
+ notifyChunkLoadError(error);
23
+ } else {
24
+ captureReactRenderError(error, {
25
+ boundary: "MarkdownErrorBoundary",
26
+ componentStack: errorInfo.componentStack ?? null
27
+ });
28
+ }
29
+ this.props.onError?.(error, errorInfo);
30
+ }
31
+ render() {
32
+ if (this.state.hasError) {
33
+ return this.props.fallback;
34
+ }
35
+ return this.props.children;
36
+ }
37
+ }
38
+ export {
39
+ MarkdownErrorBoundary
40
+ };
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ interface PlainTextFallbackProps {
3
+ requestId?: string;
4
+ content: string;
5
+ className?: string;
6
+ }
7
+ export declare const PlainTextFallback: React.FC<PlainTextFallbackProps>;
8
+ export {};
@@ -0,0 +1,91 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Suspense, lazy } from "react";
3
+ import { cn } from "@ai-matrx/design-system";
4
+ import { MarkdownErrorBoundary } from "./MarkdownErrorBoundary.js";
5
+ import { findEmbeddedKindJsonRegions } from "@ai-matrx/content-ir/surfaces";
6
+ import {
7
+ firstKindSlug,
8
+ hasKindKey,
9
+ hasKindKeyAnySpelling,
10
+ kindObjectProseBreak,
11
+ normalizeKindSpellings
12
+ } from "@ai-matrx/content-ir/surfaces";
13
+ import { kindTextToMarkdown } from "@ai-matrx/content-ir/surfaces";
14
+ import { humanizeKind } from "@ai-matrx/content-ir/surfaces";
15
+ const KindInstanceRender = lazy(
16
+ () => import("../../../host/app-bindings.js").then((m) => ({ default: m.KindInstanceRender }))
17
+ );
18
+ const FENCE_LINE = /^[ \t]*(`{3,}|~{3,})[^\n`]*$/gm;
19
+ function isKindObject(value) {
20
+ return typeof value === "object" && value !== null && !Array.isArray(value) && typeof value.__kind === "string";
21
+ }
22
+ function textPieces(text) {
23
+ const cleaned = text.replace(FENCE_LINE, "");
24
+ if (!hasKindKey(cleaned)) return cleaned.trim() ? [{ type: "text", text: cleaned }] : [];
25
+ const keyAt = cleaned.search(/"__kind"\s*:/);
26
+ const objectAt = cleaned.lastIndexOf("{", keyAt);
27
+ const before = cleaned.slice(0, objectAt < 0 ? keyAt : objectAt);
28
+ const out = [];
29
+ if (before.trim()) out.push({ type: "text", text: before });
30
+ out.push({ type: "broken", kind: firstKindSlug(cleaned) });
31
+ const proseBreak = objectAt < 0 ? null : kindObjectProseBreak(cleaned.slice(objectAt));
32
+ if (proseBreak !== null) out.push(...textPieces(cleaned.slice(objectAt + proseBreak)));
33
+ return out;
34
+ }
35
+ function piecesOf(content) {
36
+ const pieces = [];
37
+ let cursor = 0;
38
+ for (const region of findEmbeddedKindJsonRegions(content)) {
39
+ let value = null;
40
+ try {
41
+ value = JSON.parse(region.content);
42
+ } catch {
43
+ value = null;
44
+ }
45
+ if (!isKindObject(value)) continue;
46
+ pieces.push(...textPieces(content.slice(cursor, region.start)));
47
+ pieces.push({ type: "kind", kind: value.__kind, value, source: region.content });
48
+ cursor = region.end;
49
+ }
50
+ pieces.push(...textPieces(content.slice(cursor)));
51
+ return pieces;
52
+ }
53
+ function ReadableText({ text }) {
54
+ return /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap break-words", children: text });
55
+ }
56
+ const PlainTextFallback = ({
57
+ requestId,
58
+ content,
59
+ className
60
+ }) => {
61
+ const containerStyles = cn(
62
+ "py-3 px-4 space-y-2 font-sans text-md antialiased leading-relaxed tracking-wide whitespace-pre-wrap break-words overflow-x-hidden min-w-0",
63
+ "block rounded-lg w-full bg-textured",
64
+ className
65
+ );
66
+ if (!content || !hasKindKeyAnySpelling(content)) {
67
+ return /* @__PURE__ */ jsx("div", { className: "mb-3 w-full min-w-0 text-left overflow-x-hidden", children: /* @__PURE__ */ jsx("div", { className: containerStyles, children: content || "No content available" }) });
68
+ }
69
+ return /* @__PURE__ */ jsx("div", { className: "mb-3 w-full min-w-0 text-left overflow-x-hidden", children: /* @__PURE__ */ jsx("div", { className: cn(containerStyles, "whitespace-normal"), children: piecesOf(normalizeKindSpellings(content)).map((piece, i) => {
70
+ if (piece.type === "text") return /* @__PURE__ */ jsx(ReadableText, { text: piece.text }, i);
71
+ if (piece.type === "broken") {
72
+ return /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", "data-kind-fallback": "broken", children: [
73
+ piece.kind ? humanizeKind(piece.kind) : "This content",
74
+ " could not be read"
75
+ ] }, i);
76
+ }
77
+ const readable = /* @__PURE__ */ jsx(ReadableText, { text: kindTextToMarkdown(piece.source) });
78
+ return /* @__PURE__ */ jsx(MarkdownErrorBoundary, { fallback: readable, children: /* @__PURE__ */ jsx(Suspense, { fallback: readable, children: /* @__PURE__ */ jsx(
79
+ KindInstanceRender,
80
+ {
81
+ kind: piece.kind,
82
+ value: piece.value,
83
+ showRoutingNote: false,
84
+ variant: "bare"
85
+ }
86
+ ) }) }, i);
87
+ }) }) });
88
+ };
89
+ export {
90
+ PlainTextFallback
91
+ };
@@ -0,0 +1,20 @@
1
+ import type { AnswerEditRemarkMeta } from "../../block-interaction.js";
2
+ import React from "react";
3
+ import { RenderBlock } from "../block-registry/BlockRenderer.js";
4
+ interface SafeBlockRendererProps {
5
+ requestId?: string;
6
+ block: RenderBlock;
7
+ index: number;
8
+ isStreamActive?: boolean;
9
+ onContentChange?: (newContent: string) => void;
10
+ /** Owning message context forwarded to canonical artifact renderers. */
11
+ conversationId?: string;
12
+ messageId?: string;
13
+ taskId?: string;
14
+ isLastReasoningBlock?: boolean;
15
+ replaceBlockContent: (original: string, replacement: string, remark?: AnswerEditRemarkMeta) => void;
16
+ handleOpenEditor: () => void;
17
+ outputSchema?: unknown | null;
18
+ }
19
+ export declare const SafeBlockRenderer: React.FC<SafeBlockRendererProps>;
20
+ export {};
@@ -0,0 +1,72 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { MarkdownErrorBoundary } from "./MarkdownErrorBoundary.js";
3
+ import { BlockFallback } from "./BlockFallback.js";
4
+ import { clientLazy } from "../../../utils/client-lazy.js";
5
+ import SuspenseLoader from "../../../utils/lifted/SuspenseLoader.js";
6
+ const BlockRenderer = clientLazy(
7
+ () => import("../block-registry/BlockRenderer.js").then((m) => m.BlockRenderer),
8
+ {
9
+ loading: () => /* @__PURE__ */ jsx("div", { className: "py-2 px-1 text-sm text-neutral-400", children: /* @__PURE__ */ jsx(SuspenseLoader, { centered: false, message: "Loading content\u2026" }) })
10
+ }
11
+ );
12
+ function blockContextTags(block, index) {
13
+ const sd = block.serverData ?? {};
14
+ const md = block.metadata ?? {};
15
+ const str = (v) => typeof v === "string" && v.length > 0 ? v : void 0;
16
+ const artifactType = str(sd.artifact_type) ?? str(md.artifactType);
17
+ return {
18
+ "data-mtx-ctx": "block",
19
+ "data-block-type": block.type,
20
+ "data-block-id": str(sd.id) ?? str(md.blockId) ?? str(md.id) ?? String(index),
21
+ "data-tool-name": str(sd.tool_name) ?? str(sd.toolName) ?? str(md.toolName),
22
+ "data-language": str(block.language),
23
+ // Artifact identity for materialized refs (mermaid, etc.).
24
+ "data-artifact-type": artifactType,
25
+ "data-artifact-id": str(sd.artifact_id) ?? str(md.artifactId),
26
+ // Mermaid's rendered SVG text is node LABELS, not the diagram DSL — so the
27
+ // raw source must be tagged explicitly for the context menu to pass the
28
+ // real diagram to an agent. Bounded to mermaid; DSL is small (<2KB typical).
29
+ "data-block-source": block.type === "mermaid" || artifactType === "mermaid" ? str(block.content) : void 0
30
+ };
31
+ }
32
+ const SafeBlockRenderer = ({
33
+ requestId,
34
+ block,
35
+ index,
36
+ isStreamActive,
37
+ onContentChange,
38
+ conversationId,
39
+ messageId,
40
+ taskId,
41
+ isLastReasoningBlock,
42
+ replaceBlockContent,
43
+ handleOpenEditor,
44
+ outputSchema
45
+ }) => {
46
+ return /* @__PURE__ */ jsx("div", { className: "contents", ...blockContextTags(block, index), children: /* @__PURE__ */ jsx(
47
+ MarkdownErrorBoundary,
48
+ {
49
+ fallback: /* @__PURE__ */ jsx(BlockFallback, { block, isStreamActive }),
50
+ children: /* @__PURE__ */ jsx(
51
+ BlockRenderer,
52
+ {
53
+ requestId,
54
+ block,
55
+ index,
56
+ isStreamActive,
57
+ onContentChange,
58
+ conversationId,
59
+ messageId,
60
+ taskId,
61
+ isLastReasoningBlock,
62
+ replaceBlockContent,
63
+ handleOpenEditor,
64
+ outputSchema
65
+ }
66
+ )
67
+ }
68
+ ) });
69
+ };
70
+ export {
71
+ SafeBlockRenderer
72
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The SOURCE VIEW context — a subtree that shows what the author wrote (a
3
+ * ```xml fence's card, ruling (a)): a kind-looking region there is code being
4
+ * shown and stays as written. Its own module so the leaves that honour it
5
+ * (`KindTextGate`, `StandardBlock`, `InlineCodeSnippet`) read it without
6
+ * importing the pipeline.
7
+ */
8
+ import React from "react";
9
+ /** Declares a subtree a source view — kind regions in it stay as written. */
10
+ export declare function KindSourceView({ children }: {
11
+ children: React.ReactNode;
12
+ }): React.JSX.Element;
13
+ /** Whether this subtree is a source view (see `KindSourceView`). */
14
+ export declare function useKindSourceView(): boolean;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext } from "react";
4
+ const KindSourceViewContext = createContext(false);
5
+ function KindSourceView({ children }) {
6
+ return /* @__PURE__ */ jsx(KindSourceViewContext.Provider, { value: true, children: /* @__PURE__ */ jsx("div", { "data-kind-source": "explicit", className: "contents", children }) });
7
+ }
8
+ function useKindSourceView() {
9
+ return useContext(KindSourceViewContext);
10
+ }
11
+ export {
12
+ KindSourceView,
13
+ useKindSourceView
14
+ };
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+ /**
3
+ * Inline renderer for `{{variable_name}}` tokens.
4
+ *
5
+ * Spacing invariants (MUST preserve):
6
+ * - Root element is a `<span>` with `display: inline` (not inline-block)
7
+ * so it never breaks line flow or grows its parent line box.
8
+ * - `font-size`, `font-weight`, and `line-height` inherit from the parent
9
+ * (paragraph, heading, list item, blockquote, table cell, etc.). No
10
+ * text-sizing classes are applied.
11
+ * - Visual distinction comes from background + inset ring only
12
+ * (`ring-inset` uses box-shadow → does not expand layout box).
13
+ * - Horizontal padding (`px-1`) + tiny margin (`mx-0.5`) add breathing
14
+ * room without affecting vertical rhythm.
15
+ *
16
+ * Data invariants:
17
+ * - The raw snake_case name lives on the DOM as `data-name` (set by the
18
+ * remark plugin) and is preserved on every re-render.
19
+ * - The pretty-cased label shown to the user is derived at render time
20
+ * and is never persisted anywhere.
21
+ */
22
+ interface MatrxVariableInlineProps {
23
+ "data-name"?: string;
24
+ name?: string;
25
+ children?: React.ReactNode;
26
+ }
27
+ export declare const MatrxVariableInline: React.FC<MatrxVariableInlineProps>;
28
+ export default MatrxVariableInline;
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ HoverCard,
5
+ HoverCardContent,
6
+ HoverCardTrigger
7
+ } from "@ai-matrx/design-system";
8
+ import { cn } from "@ai-matrx/design-system";
9
+ import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
10
+ const MatrxVariableInline = (props) => {
11
+ const rawName = props["data-name"] ?? props.name ?? "";
12
+ if (!rawName) {
13
+ return null;
14
+ }
15
+ const prettyLabel = humanizeIdentifier(rawName) || rawName;
16
+ const tokenString = `{{${rawName}}}`;
17
+ return /* @__PURE__ */ jsxs(HoverCard, { openDelay: 120, closeDelay: 80, children: [
18
+ /* @__PURE__ */ jsx(HoverCardTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
19
+ "span",
20
+ {
21
+ className: cn(
22
+ "inline rounded px-1 mx-0.5",
23
+ "bg-primary/50 text-foreground",
24
+ "ring-1 ring-inset ring-primary/20",
25
+ "hover:bg-primary/75 hover:ring-primary/85",
26
+ "cursor-help transition-colors",
27
+ "border border-dashed border-primary"
28
+ ),
29
+ "data-name": rawName,
30
+ "data-matrx-variable": "",
31
+ children: prettyLabel
32
+ }
33
+ ) }),
34
+ /* @__PURE__ */ jsx(
35
+ HoverCardContent,
36
+ {
37
+ align: "start",
38
+ side: "top",
39
+ sideOffset: 6,
40
+ className: "w-64 p-3 border border-border rounded-xl",
41
+ children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
42
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
43
+ /* @__PURE__ */ jsx("span", { className: "inline-block h-1.5 w-1.5 rounded-full bg-primary" }),
44
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wider font-semibold text-muted-foreground", children: "Variable" })
45
+ ] }),
46
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-semibold text-foreground leading-tight", children: prettyLabel }),
47
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
48
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Token" }),
49
+ /* @__PURE__ */ jsx("code", { className: "font-mono text-[11px] bg-muted text-foreground px-1.5 py-0.5 rounded self-start break-all", children: tokenString })
50
+ ] }),
51
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
52
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Raw Name" }),
53
+ /* @__PURE__ */ jsx("code", { className: "font-mono text-[11px] text-muted-foreground self-start break-all", children: rawName })
54
+ ] }),
55
+ /* @__PURE__ */ jsx("div", { className: "text-[11px] text-muted-foreground pt-1.5 border-t border-border", children: "More details coming soon." })
56
+ ] })
57
+ }
58
+ )
59
+ ] });
60
+ };
61
+ var MatrxVariableInline_default = MatrxVariableInline;
62
+ export {
63
+ MatrxVariableInline,
64
+ MatrxVariableInline_default as default
65
+ };
@@ -0,0 +1,18 @@
1
+ import { type ReactNode } from "react";
2
+ /** Blocks mounted in the first commit — above any real chat answer. */
3
+ export declare const PROGRESSIVE_FIRST_SLICE = 200;
4
+ /** Blocks added per follow-up slice. */
5
+ export declare const PROGRESSIVE_SLICE = 150;
6
+ /** Blocks mounted without the reader scrolling; the rest follow the scroll. */
7
+ export declare const PROGRESSIVE_AUTO_LIMIT = 600;
8
+ /** Next count after one slice; pure so it is testable. */
9
+ export declare function nextProgressiveCount(current: number, total: number): number;
10
+ export interface ProgressiveMount {
11
+ /** How many blocks to render now. */
12
+ shown: number;
13
+ /** Render after the mounted blocks: null once everything is mounted. */
14
+ sentinel: ReactNode;
15
+ }
16
+ export declare function useProgressiveMount(total: number): ProgressiveMount;
17
+ /** Back-compat shape for callers that only need the count. */
18
+ export declare function useProgressiveCount(total: number): number;
@@ -0,0 +1,90 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { nearestScrollRoot } from "../../utils/lifted/scroll-root.js";
4
+ import { useRenderAllRequested } from "../../mermaid/lazy-draw.js";
5
+ import { startTransition, useEffect, useRef, useState } from "react";
6
+ import { formatCount } from "@ai-matrx/kit/format";
7
+ import { Button } from "@ai-matrx/design-system/controls";
8
+ const PROGRESSIVE_FIRST_SLICE = 200;
9
+ const PROGRESSIVE_SLICE = 150;
10
+ const PROGRESSIVE_AUTO_LIMIT = 600;
11
+ function nextProgressiveCount(current, total) {
12
+ return Math.min(total, current + PROGRESSIVE_SLICE);
13
+ }
14
+ function useProgressiveMount(total) {
15
+ const [mounted, setMounted] = useState(() => Math.min(total, PROGRESSIVE_FIRST_SLICE));
16
+ if (total <= PROGRESSIVE_FIRST_SLICE && mounted > PROGRESSIVE_FIRST_SLICE) {
17
+ setMounted(PROGRESSIVE_FIRST_SLICE);
18
+ }
19
+ const renderAll = useRenderAllRequested();
20
+ const shown = renderAll ? total : Math.max(Math.min(total, PROGRESSIVE_FIRST_SLICE), Math.min(mounted, total));
21
+ const auto = shown < Math.min(total, PROGRESSIVE_AUTO_LIMIT);
22
+ useEffect(() => {
23
+ if (!auto) return void 0;
24
+ const timer = setTimeout(() => {
25
+ startTransition(
26
+ () => setMounted(
27
+ (m) => Math.min(PROGRESSIVE_AUTO_LIMIT, nextProgressiveCount(Math.max(m, shown), total))
28
+ )
29
+ );
30
+ }, 0);
31
+ return () => clearTimeout(timer);
32
+ }, [auto, shown, total]);
33
+ const more = () => startTransition(() => setMounted((m) => nextProgressiveCount(Math.max(m, shown), total)));
34
+ const sentinel = shown >= total ? null : /* @__PURE__ */ jsx(ScrollSentinel, { active: !auto, onVisible: more, shown, total }, shown);
35
+ return { shown, sentinel };
36
+ }
37
+ function useProgressiveCount(total) {
38
+ return useProgressiveMount(total).shown;
39
+ }
40
+ function ScrollSentinel({
41
+ active,
42
+ onVisible,
43
+ shown,
44
+ total
45
+ }) {
46
+ const ref = useRef(null);
47
+ useEffect(() => {
48
+ const el = ref.current;
49
+ if (!active || !el || typeof IntersectionObserver === "undefined") return void 0;
50
+ const io = new IntersectionObserver(
51
+ (entries) => {
52
+ if (entries.some((e) => e.isIntersecting)) onVisible();
53
+ },
54
+ // Its own scroller, so the margin holds inside a panel or drawer too.
55
+ { root: nearestScrollRoot(el), rootMargin: "1500px 0px" }
56
+ );
57
+ io.observe(el);
58
+ return () => io.disconnect();
59
+ }, [active, onVisible]);
60
+ return /* @__PURE__ */ jsx(
61
+ "div",
62
+ {
63
+ ref,
64
+ "data-progressive-sentinel": "",
65
+ role: "status",
66
+ className: "py-3 text-center text-xs text-muted-foreground",
67
+ children: active ? /* @__PURE__ */ jsxs(Button, { variant: "link", onClick: onVisible, children: [
68
+ "Showing ",
69
+ formatCount(shown),
70
+ " of ",
71
+ formatCount(total),
72
+ " blocks \u2014 more load as you scroll (or click)"
73
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
74
+ "Loading ",
75
+ shown.toLocaleString(),
76
+ " of ",
77
+ total.toLocaleString(),
78
+ " blocks\u2026"
79
+ ] })
80
+ }
81
+ );
82
+ }
83
+ export {
84
+ PROGRESSIVE_AUTO_LIMIT,
85
+ PROGRESSIVE_FIRST_SLICE,
86
+ PROGRESSIVE_SLICE,
87
+ nextProgressiveCount,
88
+ useProgressiveCount,
89
+ useProgressiveMount
90
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The live-stream hop: a Redux `RenderBlockPayload` (StreamBlockAccumulator
3
+ * output, `state.activeRequests[requestId].renderBlocks`) becomes the flat
4
+ * `RenderBlock` shape BlockRenderer consumes.
5
+ *
6
+ * LOAD-BEARING MAPPING: `rb.data` → `block.serverData`. For untyped code
7
+ * blocks (fenced ```json / bare JSON) the accumulator emits
8
+ * `data: { language: "json" }` — that annotation object arrives here as a
9
+ * TRUTHY `serverData`. Downstream consumers must therefore never treat "has
10
+ * serverData" as "has kind/typed data" for a block that still needs routing
11
+ * (see `applyIrKindRoute`, which derives routed serverData from the
12
+ * `metadata.__ir` envelope and discards this annotation).
13
+ *
14
+ * Extracted from EnhancedChatMarkdown so tests can drive the REAL hop —
15
+ * the 2026-07-04 "No flashcards available yet" bug lived exactly on this
16
+ * seam and was invisible to tests that built blocks by hand.
17
+ */
18
+ import type { RenderBlockPayload } from "@ai-matrx/agents/generated/stream-events";
19
+ import type { RenderBlock } from "./block-registry/BlockRenderer.js";
20
+ /**
21
+ * THE ARTIFACT BODY. The accumulator keeps an `<artifact …>` block's tag lines
22
+ * in `content` (its `metadata.rawXml` must round-trip the source verbatim);
23
+ * the reload splitter hands the renderer only the body between the tags.
24
+ * ArtifactBlock parses `content` AS the payload, so the live block drew
25
+ * "No flashcards available yet" settled and the raw `__kind` JSON mid-stream
26
+ * while a reload drew the cards. Same body on both paths, by construction:
27
+ * the opening tag, the closing tag (or the closer's partial tail mid-stream)
28
+ * and the blank edges go; the body is untouched.
29
+ */
30
+ export declare function artifactBodyOf(content: string): string;
31
+ export declare function renderBlockToContentBlock(rb: RenderBlockPayload): RenderBlock;
@@ -0,0 +1,32 @@
1
+ function artifactBodyOf(content) {
2
+ let body = content;
3
+ const open = /^\s*<artifact\b[^>]*>/i.exec(body);
4
+ if (open) body = body.slice(open[0].length);
5
+ else if (/^\s*<artifact\b/i.test(body)) return "";
6
+ const close = body.lastIndexOf("</artifact>");
7
+ if (close !== -1) {
8
+ body = body.slice(0, close);
9
+ } else {
10
+ const tail = /<\/?[a-z]*$/i.exec(body);
11
+ if (tail && "</artifact>".startsWith(tail[0].toLowerCase())) {
12
+ body = body.slice(0, tail.index);
13
+ }
14
+ }
15
+ return body.replace(/^\s*\n/, "").trimEnd();
16
+ }
17
+ function renderBlockToContentBlock(rb) {
18
+ return {
19
+ type: rb.type,
20
+ content: rb.type === "artifact" ? artifactBodyOf(rb.content ?? "") : rb.content ?? "",
21
+ serverData: rb.data ?? void 0,
22
+ metadata: rb.metadata,
23
+ language: rb.data?.language,
24
+ src: rb.data?.src,
25
+ alt: rb.data?.alt,
26
+ isStreamingBlock: rb.status === "streaming"
27
+ };
28
+ }
29
+ export {
30
+ artifactBodyOf,
31
+ renderBlockToContentBlock
32
+ };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * THE FINAL PASS: when a stream completes, the screen must equal the one-shot
3
+ * reading of the finished text — the same blocks a reload renders.
4
+ *
5
+ * Why this exists (chair ruling, 2026-09-26 — common-docs
6
+ * projects/rich-content-unification/REGISTER.md, RC-B3 rulings): while a
7
+ * message streams, "a settled block never changes" holds with ONE documented
8
+ * exception — an orphan `</thinking>` / `</think>` / `</reasoning>` closer
9
+ * that arrives late. Models do emit closer-only reasoning (the opener lost
10
+ * upstream); the one-shot splitter then folds everything before the closer
11
+ * into a thinking region (`metadata.continuation`), which no streaming reader
12
+ * can know in advance. The live StreamBlockAccumulator strips such a closer
13
+ * (and reports it) instead, so its final blocks differ from a reload's.
14
+ *
15
+ * So after completion, when the one-shot reading contains an orphan rescue,
16
+ * the renderer shows the one-shot blocks. Only client-produced accumulator
17
+ * blocks (`client_…`) are replaced: their reload path IS the one-shot split of
18
+ * the stored text; server-produced blocks carry server envelopes and stay.
19
+ */
20
+ import { type SplitterBlock } from "../markdown-classification/processors/utils/content-splitter-v2.js";
21
+ export interface SettleStreamInput {
22
+ /** The stream is still arriving (never settled). */
23
+ isStreamActive: boolean;
24
+ /** Ids of the accumulator's render blocks for this message. */
25
+ blockIds: readonly string[];
26
+ /** The finished text. */
27
+ content: string;
28
+ }
29
+ /**
30
+ * The one-shot blocks to show instead of the accumulator's, or null when the
31
+ * accumulator's final blocks already are the one-shot reading.
32
+ */
33
+ export declare function settledOneShotBlocks({ isStreamActive, blockIds, content, }: SettleStreamInput): SplitterBlock[] | null;
34
+ export interface SettledFromRecordInput {
35
+ /** The stream is still arriving. */
36
+ isStreamActive: boolean;
37
+ /** The committed message this turn renders, when there is one. */
38
+ messageId: string | null | undefined;
39
+ /** How many display segments the committed record holds (0 = not in the store yet). */
40
+ recordSegmentCount: number;
41
+ }
42
+ /**
43
+ * THE FINAL SCREEN IS THE RELOAD. A turn whose stream has ended and whose
44
+ * committed record is in the store renders from that record — the same parts,
45
+ * split the same one-shot way, that a reload renders — never from the live
46
+ * render blocks (server- or client-built), which are an incremental reading
47
+ * of a text still arriving (verify-RC-B3 F1/F2). A turn with no committed
48
+ * record yet keeps its live blocks (and the orphan-rescue pass above).
49
+ */
50
+ export declare function renderSettledFromRecord({ isStreamActive, messageId, recordSegmentCount, }: SettledFromRecordInput): boolean;
@@ -0,0 +1,26 @@
1
+ import {
2
+ splitContentIntoBlocksV2
3
+ } from "../markdown-classification/processors/utils/content-splitter-v2.js";
4
+ const REASONING_CLOSER = /<\/(?:thinking|think|reasoning)\s*>/i;
5
+ function settledOneShotBlocks({
6
+ isStreamActive,
7
+ blockIds,
8
+ content
9
+ }) {
10
+ if (isStreamActive || blockIds.length === 0) return null;
11
+ if (!blockIds.every((id) => id.startsWith("client_"))) return null;
12
+ if (!REASONING_CLOSER.test(content)) return null;
13
+ const oneShot = splitContentIntoBlocksV2(content);
14
+ return oneShot.some((block) => block.metadata?.continuation === true) ? oneShot : null;
15
+ }
16
+ function renderSettledFromRecord({
17
+ isStreamActive,
18
+ messageId,
19
+ recordSegmentCount
20
+ }) {
21
+ return !isStreamActive && !!messageId && recordSegmentCount > 0;
22
+ }
23
+ export {
24
+ renderSettledFromRecord,
25
+ settledOneShotBlocks
26
+ };
@@ -0,0 +1,15 @@
1
+ /** Anything a splitter hands a renderer: a typed chunk of the document. */
2
+ interface BlockLike {
3
+ type: string;
4
+ content: string;
5
+ }
6
+ /** Same block data, field by field (content strings compare by value). */
7
+ export declare function sameBlock<T extends BlockLike>(a: T, b: T): boolean;
8
+ /**
9
+ * Returns `next` with every block that equals a block of `prev` replaced by
10
+ * that previous object. Matching is by (type, content) in order of
11
+ * occurrence, so identity survives blocks shifting position. Returns `prev`
12
+ * itself when nothing changed at all.
13
+ */
14
+ export declare function reuseUnchangedBlocks<T extends BlockLike>(prev: readonly T[], next: readonly T[]): T[];
15
+ export {};