@drscrewdriver/dsh-better-display 0.3.3-fork.1

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 (390) hide show
  1. package/CHANGELOG.md +259 -0
  2. package/DESIGN.md +72 -0
  3. package/LICENSE +24 -0
  4. package/README.en.md +55 -0
  5. package/README.md +55 -0
  6. package/THIRD_PARTY_NOTICES.md +65 -0
  7. package/compat/harness-rc2.json +99 -0
  8. package/cordis.patch.yml +5 -0
  9. package/cordis.yml +4 -0
  10. package/docs/official-rendering-bridge.md +65 -0
  11. package/dshx.yml +5 -0
  12. package/lib/client.js +49292 -0
  13. package/lib/client.js.map +1 -0
  14. package/lib/dsh-better-display.js +101 -0
  15. package/lib/types/client/Blocks.d.ts +49 -0
  16. package/lib/types/client/Blocks.d.ts.map +1 -0
  17. package/lib/types/client/Blocks.js +143 -0
  18. package/lib/types/client/Blocks.js.map +1 -0
  19. package/lib/types/client/ChoreographedFlow.d.ts +22 -0
  20. package/lib/types/client/ChoreographedFlow.d.ts.map +1 -0
  21. package/lib/types/client/ChoreographedFlow.js +218 -0
  22. package/lib/types/client/ChoreographedFlow.js.map +1 -0
  23. package/lib/types/client/ClosedProcessSummary.d.ts +9 -0
  24. package/lib/types/client/ClosedProcessSummary.d.ts.map +1 -0
  25. package/lib/types/client/ClosedProcessSummary.js +16 -0
  26. package/lib/types/client/ClosedProcessSummary.js.map +1 -0
  27. package/lib/types/client/DiffPanel.d.ts +13 -0
  28. package/lib/types/client/DiffPanel.d.ts.map +1 -0
  29. package/lib/types/client/DiffPanel.js +115 -0
  30. package/lib/types/client/DiffPanel.js.map +1 -0
  31. package/lib/types/client/LiveFold.d.ts +10 -0
  32. package/lib/types/client/LiveFold.d.ts.map +1 -0
  33. package/lib/types/client/LiveFold.js +39 -0
  34. package/lib/types/client/LiveFold.js.map +1 -0
  35. package/lib/types/client/McpAppFrame.d.ts +32 -0
  36. package/lib/types/client/McpAppFrame.d.ts.map +1 -0
  37. package/lib/types/client/McpAppFrame.js +193 -0
  38. package/lib/types/client/McpAppFrame.js.map +1 -0
  39. package/lib/types/client/OfficialContent.d.ts +25 -0
  40. package/lib/types/client/OfficialContent.d.ts.map +1 -0
  41. package/lib/types/client/OfficialContent.js +53 -0
  42. package/lib/types/client/OfficialContent.js.map +1 -0
  43. package/lib/types/client/Reader.d.ts +3 -0
  44. package/lib/types/client/Reader.d.ts.map +1 -0
  45. package/lib/types/client/Reader.js +603 -0
  46. package/lib/types/client/Reader.js.map +1 -0
  47. package/lib/types/client/ReasoningCard.d.ts +11 -0
  48. package/lib/types/client/ReasoningCard.d.ts.map +1 -0
  49. package/lib/types/client/ReasoningCard.js +322 -0
  50. package/lib/types/client/ReasoningCard.js.map +1 -0
  51. package/lib/types/client/SettingsSection.d.ts +37 -0
  52. package/lib/types/client/SettingsSection.d.ts.map +1 -0
  53. package/lib/types/client/SettingsSection.js +63 -0
  54. package/lib/types/client/SettingsSection.js.map +1 -0
  55. package/lib/types/client/StickyLane.d.ts +8 -0
  56. package/lib/types/client/StickyLane.d.ts.map +1 -0
  57. package/lib/types/client/StickyLane.js +39 -0
  58. package/lib/types/client/StickyLane.js.map +1 -0
  59. package/lib/types/client/TimelineRail.d.ts +10 -0
  60. package/lib/types/client/TimelineRail.d.ts.map +1 -0
  61. package/lib/types/client/TimelineRail.js +168 -0
  62. package/lib/types/client/TimelineRail.js.map +1 -0
  63. package/lib/types/client/ToolActivity.d.ts +17 -0
  64. package/lib/types/client/ToolActivity.d.ts.map +1 -0
  65. package/lib/types/client/ToolActivity.js +244 -0
  66. package/lib/types/client/ToolActivity.js.map +1 -0
  67. package/lib/types/client/TurnMetrics.d.ts +11 -0
  68. package/lib/types/client/TurnMetrics.d.ts.map +1 -0
  69. package/lib/types/client/TurnMetrics.js +44 -0
  70. package/lib/types/client/TurnMetrics.js.map +1 -0
  71. package/lib/types/client/WaitClock.d.ts +16 -0
  72. package/lib/types/client/WaitClock.d.ts.map +1 -0
  73. package/lib/types/client/WaitClock.js +29 -0
  74. package/lib/types/client/WaitClock.js.map +1 -0
  75. package/lib/types/client/WaitingClock.d.ts +15 -0
  76. package/lib/types/client/WaitingClock.d.ts.map +1 -0
  77. package/lib/types/client/WaitingClock.js +30 -0
  78. package/lib/types/client/WaitingClock.js.map +1 -0
  79. package/lib/types/client/WaitingStatus.d.ts +6 -0
  80. package/lib/types/client/WaitingStatus.d.ts.map +1 -0
  81. package/lib/types/client/WaitingStatus.js +9 -0
  82. package/lib/types/client/WaitingStatus.js.map +1 -0
  83. package/lib/types/client/conversation-scroll.d.ts +19 -0
  84. package/lib/types/client/conversation-scroll.d.ts.map +1 -0
  85. package/lib/types/client/conversation-scroll.js +25 -0
  86. package/lib/types/client/conversation-scroll.js.map +1 -0
  87. package/lib/types/client/deliverables.d.ts +24 -0
  88. package/lib/types/client/deliverables.d.ts.map +1 -0
  89. package/lib/types/client/deliverables.js +104 -0
  90. package/lib/types/client/deliverables.js.map +1 -0
  91. package/lib/types/client/entry-policy.d.ts +10 -0
  92. package/lib/types/client/entry-policy.d.ts.map +1 -0
  93. package/lib/types/client/entry-policy.js +24 -0
  94. package/lib/types/client/entry-policy.js.map +1 -0
  95. package/lib/types/client/entry.d.ts +4 -0
  96. package/lib/types/client/entry.d.ts.map +1 -0
  97. package/lib/types/client/entry.js +34 -0
  98. package/lib/types/client/entry.js.map +1 -0
  99. package/lib/types/client/fold-choreography.d.ts +40 -0
  100. package/lib/types/client/fold-choreography.d.ts.map +1 -0
  101. package/lib/types/client/fold-choreography.js +48 -0
  102. package/lib/types/client/fold-choreography.js.map +1 -0
  103. package/lib/types/client/fold-intensity.d.ts +11 -0
  104. package/lib/types/client/fold-intensity.d.ts.map +1 -0
  105. package/lib/types/client/fold-intensity.js +32 -0
  106. package/lib/types/client/fold-intensity.js.map +1 -0
  107. package/lib/types/client/index.d.ts +7 -0
  108. package/lib/types/client/index.d.ts.map +1 -0
  109. package/lib/types/client/index.js +195 -0
  110. package/lib/types/client/index.js.map +1 -0
  111. package/lib/types/client/live-turn.d.ts +58 -0
  112. package/lib/types/client/live-turn.d.ts.map +1 -0
  113. package/lib/types/client/live-turn.js +190 -0
  114. package/lib/types/client/live-turn.js.map +1 -0
  115. package/lib/types/client/markdown/MarkdownText.d.ts +41 -0
  116. package/lib/types/client/markdown/MarkdownText.d.ts.map +1 -0
  117. package/lib/types/client/markdown/MarkdownText.js +178 -0
  118. package/lib/types/client/markdown/MarkdownText.js.map +1 -0
  119. package/lib/types/client/markdown/cjkFriendlyStrong.d.ts +9 -0
  120. package/lib/types/client/markdown/cjkFriendlyStrong.d.ts.map +1 -0
  121. package/lib/types/client/markdown/cjkFriendlyStrong.js +73 -0
  122. package/lib/types/client/markdown/cjkFriendlyStrong.js.map +1 -0
  123. package/lib/types/client/markdown/incremental.d.ts +69 -0
  124. package/lib/types/client/markdown/incremental.d.ts.map +1 -0
  125. package/lib/types/client/markdown/incremental.js +108 -0
  126. package/lib/types/client/markdown/incremental.js.map +1 -0
  127. package/lib/types/client/markdown/katex.d.ts +27 -0
  128. package/lib/types/client/markdown/katex.d.ts.map +1 -0
  129. package/lib/types/client/markdown/katex.js +88 -0
  130. package/lib/types/client/markdown/katex.js.map +1 -0
  131. package/lib/types/client/markdown/mathCompatibility.d.ts +11 -0
  132. package/lib/types/client/markdown/mathCompatibility.d.ts.map +1 -0
  133. package/lib/types/client/markdown/mathCompatibility.js +293 -0
  134. package/lib/types/client/markdown/mathCompatibility.js.map +1 -0
  135. package/lib/types/client/markdown/parse.d.ts +25 -0
  136. package/lib/types/client/markdown/parse.d.ts.map +1 -0
  137. package/lib/types/client/markdown/parse.js +42 -0
  138. package/lib/types/client/markdown/parse.js.map +1 -0
  139. package/lib/types/client/markdown/render.d.ts +121 -0
  140. package/lib/types/client/markdown/render.d.ts.map +1 -0
  141. package/lib/types/client/markdown/render.js +452 -0
  142. package/lib/types/client/markdown/render.js.map +1 -0
  143. package/lib/types/client/mcp-app.d.ts +50 -0
  144. package/lib/types/client/mcp-app.d.ts.map +1 -0
  145. package/lib/types/client/mcp-app.js +328 -0
  146. package/lib/types/client/mcp-app.js.map +1 -0
  147. package/lib/types/client/message-chrome.d.ts +19 -0
  148. package/lib/types/client/message-chrome.d.ts.map +1 -0
  149. package/lib/types/client/message-chrome.js +42 -0
  150. package/lib/types/client/message-chrome.js.map +1 -0
  151. package/lib/types/client/motion.d.ts +38 -0
  152. package/lib/types/client/motion.d.ts.map +1 -0
  153. package/lib/types/client/motion.js +453 -0
  154. package/lib/types/client/motion.js.map +1 -0
  155. package/lib/types/client/native/ContextBody.d.ts +130 -0
  156. package/lib/types/client/native/ContextBody.d.ts.map +1 -0
  157. package/lib/types/client/native/ContextBody.js +398 -0
  158. package/lib/types/client/native/ContextBody.js.map +1 -0
  159. package/lib/types/client/native/ContextInjectionRow.d.ts +35 -0
  160. package/lib/types/client/native/ContextInjectionRow.d.ts.map +1 -0
  161. package/lib/types/client/native/ContextInjectionRow.js +42 -0
  162. package/lib/types/client/native/ContextInjectionRow.js.map +1 -0
  163. package/lib/types/client/native/ReferenceIcon.d.ts +16 -0
  164. package/lib/types/client/native/ReferenceIcon.d.ts.map +1 -0
  165. package/lib/types/client/native/ReferenceIcon.js +16 -0
  166. package/lib/types/client/native/ReferenceIcon.js.map +1 -0
  167. package/lib/types/client/native/tool-call-model.d.ts +58 -0
  168. package/lib/types/client/native/tool-call-model.d.ts.map +1 -0
  169. package/lib/types/client/native/tool-call-model.js +219 -0
  170. package/lib/types/client/native/tool-call-model.js.map +1 -0
  171. package/lib/types/client/native/tool-update.d.ts +23 -0
  172. package/lib/types/client/native/tool-update.d.ts.map +1 -0
  173. package/lib/types/client/native/tool-update.js +22 -0
  174. package/lib/types/client/native/tool-update.js.map +1 -0
  175. package/lib/types/client/official-slots.d.ts +71 -0
  176. package/lib/types/client/official-slots.d.ts.map +1 -0
  177. package/lib/types/client/official-slots.js +183 -0
  178. package/lib/types/client/official-slots.js.map +1 -0
  179. package/lib/types/client/open-file.d.ts +29 -0
  180. package/lib/types/client/open-file.d.ts.map +1 -0
  181. package/lib/types/client/open-file.js +71 -0
  182. package/lib/types/client/open-file.js.map +1 -0
  183. package/lib/types/client/pending-submission.d.ts +28 -0
  184. package/lib/types/client/pending-submission.d.ts.map +1 -0
  185. package/lib/types/client/pending-submission.js +28 -0
  186. package/lib/types/client/pending-submission.js.map +1 -0
  187. package/lib/types/client/platform-media.d.ts +6 -0
  188. package/lib/types/client/platform-media.d.ts.map +1 -0
  189. package/lib/types/client/platform-media.js +18 -0
  190. package/lib/types/client/platform-media.js.map +1 -0
  191. package/lib/types/client/primitive-labels.d.ts +10 -0
  192. package/lib/types/client/primitive-labels.d.ts.map +1 -0
  193. package/lib/types/client/primitive-labels.js +38 -0
  194. package/lib/types/client/primitive-labels.js.map +1 -0
  195. package/lib/types/client/projection.d.ts +41 -0
  196. package/lib/types/client/projection.d.ts.map +1 -0
  197. package/lib/types/client/projection.js +112 -0
  198. package/lib/types/client/projection.js.map +1 -0
  199. package/lib/types/client/reasoning-follow.d.ts +10 -0
  200. package/lib/types/client/reasoning-follow.d.ts.map +1 -0
  201. package/lib/types/client/reasoning-follow.js +21 -0
  202. package/lib/types/client/reasoning-follow.js.map +1 -0
  203. package/lib/types/client/resource-address.d.ts +3 -0
  204. package/lib/types/client/resource-address.d.ts.map +1 -0
  205. package/lib/types/client/resource-address.js +33 -0
  206. package/lib/types/client/resource-address.js.map +1 -0
  207. package/lib/types/client/settings-copy.d.ts +7 -0
  208. package/lib/types/client/settings-copy.d.ts.map +1 -0
  209. package/lib/types/client/settings-copy.js +53 -0
  210. package/lib/types/client/settings-copy.js.map +1 -0
  211. package/lib/types/client/settings-slots.d.ts +23 -0
  212. package/lib/types/client/settings-slots.d.ts.map +1 -0
  213. package/lib/types/client/settings-slots.js +2 -0
  214. package/lib/types/client/settings-slots.js.map +1 -0
  215. package/lib/types/client/settings.d.ts +4 -0
  216. package/lib/types/client/settings.d.ts.map +1 -0
  217. package/lib/types/client/settings.js +60 -0
  218. package/lib/types/client/settings.js.map +1 -0
  219. package/lib/types/client/skill-status.d.ts +25 -0
  220. package/lib/types/client/skill-status.d.ts.map +1 -0
  221. package/lib/types/client/skill-status.js +44 -0
  222. package/lib/types/client/skill-status.js.map +1 -0
  223. package/lib/types/client/store.d.ts +35 -0
  224. package/lib/types/client/store.d.ts.map +1 -0
  225. package/lib/types/client/store.js +37 -0
  226. package/lib/types/client/store.js.map +1 -0
  227. package/lib/types/client/stream-buffer.d.ts +37 -0
  228. package/lib/types/client/stream-buffer.d.ts.map +1 -0
  229. package/lib/types/client/stream-buffer.js +150 -0
  230. package/lib/types/client/stream-buffer.js.map +1 -0
  231. package/lib/types/client/streaming.d.ts +18 -0
  232. package/lib/types/client/streaming.d.ts.map +1 -0
  233. package/lib/types/client/streaming.js +84 -0
  234. package/lib/types/client/streaming.js.map +1 -0
  235. package/lib/types/client/timeline.d.ts +26 -0
  236. package/lib/types/client/timeline.d.ts.map +1 -0
  237. package/lib/types/client/timeline.js +48 -0
  238. package/lib/types/client/timeline.js.map +1 -0
  239. package/lib/types/client/tool-activity.d.ts +98 -0
  240. package/lib/types/client/tool-activity.d.ts.map +1 -0
  241. package/lib/types/client/tool-activity.js +301 -0
  242. package/lib/types/client/tool-activity.js.map +1 -0
  243. package/lib/types/client/types.d.ts +91 -0
  244. package/lib/types/client/types.d.ts.map +1 -0
  245. package/lib/types/client/types.js +2 -0
  246. package/lib/types/client/types.js.map +1 -0
  247. package/lib/types/client/waiting-clock.d.ts +49 -0
  248. package/lib/types/client/waiting-clock.d.ts.map +1 -0
  249. package/lib/types/client/waiting-clock.js +80 -0
  250. package/lib/types/client/waiting-clock.js.map +1 -0
  251. package/lib/types/client/word-motion.d.ts +16 -0
  252. package/lib/types/client/word-motion.d.ts.map +1 -0
  253. package/lib/types/client/word-motion.js +90 -0
  254. package/lib/types/client/word-motion.js.map +1 -0
  255. package/lib/types/client/word-timeline.d.ts +32 -0
  256. package/lib/types/client/word-timeline.d.ts.map +1 -0
  257. package/lib/types/client/word-timeline.js +119 -0
  258. package/lib/types/client/word-timeline.js.map +1 -0
  259. package/lib/types/dsh-better-display.d.ts +17 -0
  260. package/lib/types/dsh-better-display.d.ts.map +1 -0
  261. package/lib/types/dsh-better-display.js +93 -0
  262. package/lib/types/dsh-better-display.js.map +1 -0
  263. package/lib/types/skill-roots.d.ts +22 -0
  264. package/lib/types/skill-roots.d.ts.map +1 -0
  265. package/lib/types/skill-roots.js +126 -0
  266. package/lib/types/skill-roots.js.map +1 -0
  267. package/lib/types/skill-status.d.ts +36 -0
  268. package/lib/types/skill-status.d.ts.map +1 -0
  269. package/lib/types/skill-status.js +51 -0
  270. package/lib/types/skill-status.js.map +1 -0
  271. package/package.json +133 -0
  272. package/scripts/build-motion-fixture.mjs +26 -0
  273. package/scripts/check-harness-compat.mjs +71 -0
  274. package/scripts/link-harness-dependencies.mjs +54 -0
  275. package/scripts/verify-auto-fold.mjs +114 -0
  276. package/scripts/verify-official-bridge.mjs +121 -0
  277. package/scripts/verify-tool-shimmer.mjs +62 -0
  278. package/skills/generative-mcpapps/SKILL.md +47 -0
  279. package/skills/generative-mcpapps/examples/interactive_quiz.html +153 -0
  280. package/skills/generative-mcpapps/references/html_boilerplate.md +122 -0
  281. package/skills/generative-mcpapps/references/sep1865_protocol.md +54 -0
  282. package/src/client/Blocks.tsx +213 -0
  283. package/src/client/ChoreographedFlow.tsx +232 -0
  284. package/src/client/ClosedProcessSummary.tsx +23 -0
  285. package/src/client/DiffPanel.tsx +124 -0
  286. package/src/client/LiveFold.tsx +43 -0
  287. package/src/client/McpAppFrame.module.css +210 -0
  288. package/src/client/McpAppFrame.tsx +317 -0
  289. package/src/client/OfficialContent.tsx +69 -0
  290. package/src/client/Reader.module.css +692 -0
  291. package/src/client/Reader.tsx +878 -0
  292. package/src/client/ReasoningCard.tsx +306 -0
  293. package/src/client/SettingsSection.module.css +184 -0
  294. package/src/client/SettingsSection.tsx +194 -0
  295. package/src/client/StickyLane.tsx +34 -0
  296. package/src/client/TimelineRail.module.css +170 -0
  297. package/src/client/TimelineRail.tsx +262 -0
  298. package/src/client/ToolActivity.tsx +274 -0
  299. package/src/client/TurnMetrics.module.css +139 -0
  300. package/src/client/TurnMetrics.tsx +160 -0
  301. package/src/client/WaitClock.tsx +33 -0
  302. package/src/client/WaitingStatus.tsx +13 -0
  303. package/src/client/conversation-scroll.ts +28 -0
  304. package/src/client/deliverables.ts +122 -0
  305. package/src/client/entry-policy.ts +20 -0
  306. package/src/client/entry.tsx +40 -0
  307. package/src/client/fold-choreography.ts +55 -0
  308. package/src/client/fold-intensity.ts +36 -0
  309. package/src/client/index.tsx +222 -0
  310. package/src/client/live-turn.ts +198 -0
  311. package/src/client/markdown/MarkdownText.module.css +304 -0
  312. package/src/client/markdown/MarkdownText.tsx +195 -0
  313. package/src/client/markdown/cjkFriendlyStrong.ts +84 -0
  314. package/src/client/markdown/incremental.ts +131 -0
  315. package/src/client/markdown/katex.tsx +91 -0
  316. package/src/client/markdown/mathCompatibility.ts +350 -0
  317. package/src/client/markdown/parse.ts +45 -0
  318. package/src/client/markdown/render.tsx +647 -0
  319. package/src/client/markdown/upstream.json +14 -0
  320. package/src/client/mcp-app.ts +323 -0
  321. package/src/client/message-chrome.ts +47 -0
  322. package/src/client/motion.tsx +410 -0
  323. package/src/client/native/ContextBody.module.css +161 -0
  324. package/src/client/native/ContextBody.tsx +591 -0
  325. package/src/client/native/ContextInjectionRow.module.css +66 -0
  326. package/src/client/native/ContextInjectionRow.tsx +106 -0
  327. package/src/client/native/ReferenceIcon.tsx +35 -0
  328. package/src/client/native/tool-call-model.ts +248 -0
  329. package/src/client/native/tool-update.ts +32 -0
  330. package/src/client/native/upstream.json +41 -0
  331. package/src/client/official-slots.tsx +211 -0
  332. package/src/client/open-file.ts +94 -0
  333. package/src/client/pending-submission.ts +49 -0
  334. package/src/client/platform-media.ts +17 -0
  335. package/src/client/primitive-labels.ts +54 -0
  336. package/src/client/projection.ts +118 -0
  337. package/src/client/reasoning-follow.ts +28 -0
  338. package/src/client/settings-copy.ts +80 -0
  339. package/src/client/settings-slots.ts +20 -0
  340. package/src/client/settings.tsx +73 -0
  341. package/src/client/skill-status.ts +78 -0
  342. package/src/client/store.ts +75 -0
  343. package/src/client/stream-buffer.ts +136 -0
  344. package/src/client/streaming.tsx +70 -0
  345. package/src/client/style.d.ts +4 -0
  346. package/src/client/timeline.ts +77 -0
  347. package/src/client/tool-activity.ts +298 -0
  348. package/src/client/types.ts +89 -0
  349. package/src/client/waiting-clock.ts +83 -0
  350. package/src/client/word-motion.tsx +92 -0
  351. package/src/client/word-timeline.ts +113 -0
  352. package/src/dsh-better-display.ts +108 -0
  353. package/src/skill-roots.ts +138 -0
  354. package/src/skill-status.ts +81 -0
  355. package/tests/browser-auto-fold.tsx +64 -0
  356. package/tests/browser-closed-gap.tsx +20 -0
  357. package/tests/browser-motion.tsx +65 -0
  358. package/tests/browser-official-bridge.tsx +152 -0
  359. package/tests/browser-sticky-lanes.tsx +22 -0
  360. package/tests/browser-waiting-clock.tsx +14 -0
  361. package/tests/chat-flow-hook.test.ts +66 -0
  362. package/tests/cloud-gate.test.ts +34 -0
  363. package/tests/context-tool-update.test.ts +33 -0
  364. package/tests/conversation-scroll.test.ts +47 -0
  365. package/tests/deliverables.test.ts +128 -0
  366. package/tests/entry.test.ts +42 -0
  367. package/tests/fixtures/maid-composer-hide.html +31 -0
  368. package/tests/fold-choreography.test.ts +54 -0
  369. package/tests/fold-intensity.test.ts +94 -0
  370. package/tests/footer-precedence.test.ts +129 -0
  371. package/tests/history-word-regression.test.ts +16 -0
  372. package/tests/live-turn.test.ts +218 -0
  373. package/tests/mcp-apps.test.ts +157 -0
  374. package/tests/message-chrome.test.ts +29 -0
  375. package/tests/official-slots.test.ts +112 -0
  376. package/tests/open-file.test.ts +114 -0
  377. package/tests/pending-submission.test.ts +45 -0
  378. package/tests/platform-media.test.ts +23 -0
  379. package/tests/projection.test.ts +184 -0
  380. package/tests/reasoning-follow.test.ts +34 -0
  381. package/tests/settings-copy.test.ts +63 -0
  382. package/tests/skill-status.test.ts +137 -0
  383. package/tests/stock-install.test.ts +58 -0
  384. package/tests/stream-buffer.test.ts +102 -0
  385. package/tests/timeline.test.ts +59 -0
  386. package/tests/tool-diff.test.ts +57 -0
  387. package/tests/waiting-clock.test.ts +83 -0
  388. package/tests/word-timeline.test.ts +146 -0
  389. package/tsconfig.json +11 -0
  390. package/tsdown.config.ts +51 -0
@@ -0,0 +1,178 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Adapted from DeepSeek Harness b150a551b8d465e31e418e1b2eaf5e79bbb7d28e (MIT). See THIRD_PARTY_NOTICES.md.
3
+ /**
4
+ * Untrusted assistant-Markdown renderer over the direct mdast pipeline:
5
+ * `parse.ts` grammars, the incremental streaming parser, and `render.tsx`.
6
+ * While a message streams, all but the trailing two blocks freeze as cached
7
+ * React elements and only the source tail behind them re-parses per chunk,
8
+ * so per-chunk work tracks the tail size instead of the whole reply. Frozen
9
+ * blocks keep their source-offset keys when they cross the freeze boundary,
10
+ * so React reconciles instead of remounting. Known deviation while
11
+ * streaming: a reference-style link or footnote whose definition sits on the
12
+ * other side of the freeze boundary renders literally until the settled
13
+ * full parse self-heals it.
14
+ */
15
+ import { memo, useMemo, useRef } from 'react';
16
+ import { IncrementalMarkdownParser } from './incremental.js';
17
+ import { parseGfm, parseGfmWithMath } from './parse.js';
18
+ import { collectReferenceTargets, createReferenceTargets, renderBlocks, renderFootnoteSection, wrapBlockChildren, } from './render.js';
19
+ // KaTeX CSS is supplied once by the shared DSH UI-primitives client bundle.
20
+ import css from './MarkdownText.module.css';
21
+ /** One settled full render: parse with math, resolve references, append the footnote section. */
22
+ function renderSettled(text, codeLabels, fileMentions, pathImages, renderText, renderAtom) {
23
+ const root = parseGfmWithMath(text);
24
+ const targets = createReferenceTargets();
25
+ collectReferenceTargets(root.children, targets);
26
+ const context = {
27
+ renderText,
28
+ renderAtom,
29
+ streaming: false,
30
+ codeLabels,
31
+ fileMentions,
32
+ pathImages,
33
+ targets,
34
+ footnoteOrder: [],
35
+ footnoteCounts: new Map(),
36
+ };
37
+ const blocks = wrapBlockChildren(renderBlocks(root.children.map((node, index) => ({ node, key: node.position?.start.offset ?? -(index + 1) })), context), false);
38
+ const section = renderFootnoteSection(context);
39
+ return section === null ? blocks : [...blocks, '\n', section];
40
+ }
41
+ /**
42
+ * Streaming render state for one growing message: the incremental parser,
43
+ * the frozen blocks' cached elements, and the reference/footnote state their
44
+ * rendering consumed (footnote numbering assigned to frozen references is
45
+ * final, so the tail continues from a copy of it each frame).
46
+ */
47
+ class StreamingRenderer {
48
+ codeLabels;
49
+ renderText;
50
+ renderAtom;
51
+ pathImages;
52
+ parser = new IncrementalMarkdownParser(parseGfm);
53
+ generation = -1;
54
+ frozenCount = 0;
55
+ frozenElements = [];
56
+ frozenTargets = createReferenceTargets();
57
+ frozenFootnoteOrder = [];
58
+ frozenFootnoteCounts = new Map();
59
+ lastText = null;
60
+ lastRendered = [];
61
+ /** @param codeLabels - Fence copy labels baked into cached elements; the owner replaces the renderer when they change. */
62
+ constructor(codeLabels, renderText, renderAtom, pathImages) {
63
+ this.codeLabels = codeLabels;
64
+ this.renderText = renderText;
65
+ this.renderAtom = renderAtom;
66
+ this.pathImages = pathImages;
67
+ }
68
+ /**
69
+ * Render the current accumulated text. Idempotent per text value, so React
70
+ * may re-execute the calling render freely.
71
+ * @param text - The full accumulated markdown source.
72
+ * @returns Frozen elements, re-rendered tail, and the footnote section.
73
+ */
74
+ render(text) {
75
+ if (text === this.lastText)
76
+ return this.lastRendered;
77
+ const { frozen, tail, generation } = this.parser.update(text);
78
+ if (generation !== this.generation) {
79
+ this.generation = generation;
80
+ this.frozenCount = 0;
81
+ this.frozenElements = [];
82
+ this.frozenTargets = createReferenceTargets();
83
+ this.frozenFootnoteOrder = [];
84
+ this.frozenFootnoteCounts = new Map();
85
+ }
86
+ const newlyFrozen = frozen.slice(this.frozenCount);
87
+ collectReferenceTargets(newlyFrozen.map(block => block.node), this.frozenTargets);
88
+ // Targets visible this frame: everything frozen so far plus the current
89
+ // tail parse — a newly frozen block's references resolved against the
90
+ // same parse tree its definitions came from.
91
+ const frameTargets = {
92
+ definitions: new Map(this.frozenTargets.definitions),
93
+ footnotes: new Map(this.frozenTargets.footnotes),
94
+ };
95
+ collectReferenceTargets(tail.map(block => block.node), frameTargets);
96
+ if (newlyFrozen.length > 0) {
97
+ const frozenContext = {
98
+ renderText: this.renderText,
99
+ renderAtom: this.renderAtom,
100
+ streaming: true,
101
+ codeLabels: this.codeLabels,
102
+ fileMentions: undefined,
103
+ pathImages: this.pathImages,
104
+ targets: frameTargets,
105
+ footnoteOrder: this.frozenFootnoteOrder,
106
+ footnoteCounts: this.frozenFootnoteCounts,
107
+ };
108
+ // Separator newlines are cached alongside the elements so the
109
+ // assembled children match the settled pipeline's block wrapping.
110
+ const batch = [...this.frozenElements];
111
+ for (const element of renderBlocks(newlyFrozen, frozenContext)) {
112
+ if (batch.length > 0)
113
+ batch.push('\n');
114
+ batch.push(element);
115
+ }
116
+ this.frozenElements = batch;
117
+ this.frozenCount = frozen.length;
118
+ }
119
+ const tailContext = {
120
+ renderText: this.renderText,
121
+ renderAtom: this.renderAtom,
122
+ streaming: true,
123
+ codeLabels: this.codeLabels,
124
+ fileMentions: undefined,
125
+ pathImages: this.pathImages,
126
+ targets: frameTargets,
127
+ footnoteOrder: [...this.frozenFootnoteOrder],
128
+ footnoteCounts: new Map(this.frozenFootnoteCounts),
129
+ };
130
+ const children = [...this.frozenElements];
131
+ for (const element of renderBlocks(tail, tailContext)) {
132
+ if (children.length > 0)
133
+ children.push('\n');
134
+ children.push(element);
135
+ }
136
+ const section = renderFootnoteSection(tailContext);
137
+ if (section !== null)
138
+ children.push('\n', section);
139
+ this.lastText = text;
140
+ this.lastRendered = children;
141
+ return this.lastRendered;
142
+ }
143
+ }
144
+ /**
145
+ * Render untrusted assistant-authored Markdown as semantic React elements.
146
+ * @param props - Markdown source text preserved by the session projection;
147
+ * `streaming` renders fences and TeX plain (highlighting and KaTeX land on
148
+ * the finalize swap) and parses incrementally across chunks; `codeLabels`
149
+ * forwards localized copy-button labels to fence CodeBlocks — pass a
150
+ * reference-stable object (memoized per locale revision), because a new
151
+ * identity discards the streaming render cache mid-message. `fileMentions`
152
+ * links inline-code tokens its resolver recognizes as real files; this is
153
+ * the single streaming gate — it applies to settled renders only, because a
154
+ * streaming message's vocabulary is not final and frozen cached elements
155
+ * must not bake in handlers that could go stale.
156
+ * @returns A GFM document with TeX math rendered through KaTeX; raw HTML,
157
+ * relative links, and unsafe protocols are disabled, while absolute HTTP(S)
158
+ * images render directly.
159
+ */
160
+ export const MarkdownText = memo(function MarkdownText({ text, streaming = false, codeLabels, fileMentions, pathImages, renderText, renderAtom }) {
161
+ const streamRef = useRef(null);
162
+ const streamImagesRef = useRef(pathImages);
163
+ const streamLabelsRef = useRef(codeLabels);
164
+ const children = useMemo(() => {
165
+ if (!streaming) {
166
+ streamRef.current = null;
167
+ return renderSettled(text, codeLabels, fileMentions, pathImages, renderText, renderAtom);
168
+ }
169
+ if (streamRef.current === null || streamLabelsRef.current !== codeLabels || streamImagesRef.current !== pathImages) {
170
+ streamRef.current = new StreamingRenderer(codeLabels, renderText, renderAtom, pathImages);
171
+ streamLabelsRef.current = codeLabels;
172
+ streamImagesRef.current = pathImages;
173
+ }
174
+ return streamRef.current.render(text);
175
+ }, [text, streaming, codeLabels, fileMentions, pathImages, renderText, renderAtom]);
176
+ return _jsx("div", { className: css.markdown, children: children });
177
+ });
178
+ //# sourceMappingURL=MarkdownText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownText.js","sourceRoot":"","sources":["../../../../src/client/markdown/MarkdownText.tsx"],"names":[],"mappings":";AAAA,4GAA4G;AAC5G;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAG7C,OAAO,EAAE,y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,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAQ7I;IACC,MAAM,SAAS,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAA;IACxD,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;IAC1C,MAAM,eAAe,GAAG,MAAM,CAAiC,UAAU,CAAC,CAAA;IAC1E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS,CAAC,OAAO,GAAG,IAAI,CAAA;YACxB,OAAO,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;QAC1F,CAAC;QACD,IAAI,SAAS,CAAC,OAAO,KAAK,IAAI,IAAI,eAAe,CAAC,OAAO,KAAK,UAAU,IAAI,eAAe,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACnH,SAAS,CAAC,OAAO,GAAG,IAAI,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;YACzF,eAAe,CAAC,OAAO,GAAG,UAAU,CAAA;YACpC,eAAe,CAAC,OAAO,GAAG,UAAU,CAAA;QACtC,CAAC;QACD,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAA;IACnF,OAAO,cAAK,SAAS,EAAE,GAAG,CAAC,QAAQ,YAAG,QAAQ,GAAO,CAAA;AACvD,CAAC,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ /** Let asterisk strong emphasis close after punctuation when CJK prose continues without whitespace. */
2
+ import type { Extension } from 'micromark-util-types';
3
+ /**
4
+ * Extend CommonMark asterisk strong emphasis for punctuation-delimited CJK
5
+ * prose, as a micromark syntax extension for `fromMarkdown`.
6
+ * @returns The micromark syntax extension.
7
+ */
8
+ export declare function cjkFriendlyStrong(): Extension;
9
+ //# sourceMappingURL=cjkFriendlyStrong.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cjkFriendlyStrong.d.ts","sourceRoot":"","sources":["../../../../src/client/markdown/cjkFriendlyStrong.ts"],"names":[],"mappings":"AACA,wGAAwG;AAMxG,OAAO,KAAK,EAAa,SAAS,EAAoB,MAAM,sBAAsB,CAAA;AAqElF;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,SAAS,CAE7C"}
@@ -0,0 +1,73 @@
1
+ // Adapted from DeepSeek Harness b150a551b8d465e31e418e1b2eaf5e79bbb7d28e (MIT). See THIRD_PARTY_NOTICES.md.
2
+ /** Let asterisk strong emphasis close after punctuation when CJK prose continues without whitespace. */
3
+ import { attention } from 'micromark-core-commonmark';
4
+ import { unicodePunctuation } from 'micromark-util-character';
5
+ import { classifyCharacter } from 'micromark-util-classify-character';
6
+ import { codes, constants } from 'micromark-util-symbol';
7
+ const cjkCharacter = new RegExp([
8
+ '\\p{Script_Extensions=Han}',
9
+ '\\p{Script_Extensions=Hiragana}',
10
+ '\\p{Script_Extensions=Katakana}',
11
+ '\\p{Script_Extensions=Hangul}',
12
+ '\\p{Script_Extensions=Bopomofo}',
13
+ ].join('|'), 'u');
14
+ function isCjkCharacter(code) {
15
+ return code !== null && code >= 0 && cjkCharacter.test(String.fromCodePoint(code));
16
+ }
17
+ const tokenizeCjkFriendlyAttention = function (effects, ok, nok) {
18
+ const configuredAttentionMarkers = this.parser.constructs.attentionMarkers.null;
19
+ if (configuredAttentionMarkers === undefined) {
20
+ throw new Error('micromark CommonMark attention markers are unavailable');
21
+ }
22
+ const attentionMarkers = configuredAttentionMarkers;
23
+ const previous = this.previous;
24
+ const before = classifyCharacter(previous);
25
+ let marker = codes.eof;
26
+ return start;
27
+ function start(code) {
28
+ /* v8 ignore next -- this text construct is dispatched only for an asterisk. */
29
+ if (code !== codes.asterisk)
30
+ return nok(code);
31
+ marker = code;
32
+ effects.enter('attentionSequence');
33
+ return inside(code);
34
+ }
35
+ function inside(code) {
36
+ if (code === marker) {
37
+ effects.consume(code);
38
+ return inside;
39
+ }
40
+ const token = effects.exit('attentionSequence');
41
+ const after = classifyCharacter(code);
42
+ const open = !after || (after === constants.characterGroupPunctuation && Boolean(before))
43
+ || attentionMarkers.includes(code);
44
+ const commonMarkClose = !before
45
+ || (before === constants.characterGroupPunctuation && Boolean(after))
46
+ || attentionMarkers.includes(previous);
47
+ const markerCount = token.end.offset - token.start.offset;
48
+ const cjkStrongClose = markerCount >= 2
49
+ && unicodePunctuation(previous)
50
+ && isCjkCharacter(code);
51
+ const close = commonMarkClose || cjkStrongClose;
52
+ token._open = open;
53
+ token._close = close;
54
+ return ok(code);
55
+ }
56
+ };
57
+ const cjkFriendlyAttention = {
58
+ name: 'cjkFriendlyAttention',
59
+ resolveAll: attention.resolveAll,
60
+ tokenize: tokenizeCjkFriendlyAttention,
61
+ };
62
+ const cjkFriendlyStrongExtension = {
63
+ text: { [codes.asterisk]: cjkFriendlyAttention },
64
+ };
65
+ /**
66
+ * Extend CommonMark asterisk strong emphasis for punctuation-delimited CJK
67
+ * prose, as a micromark syntax extension for `fromMarkdown`.
68
+ * @returns The micromark syntax extension.
69
+ */
70
+ export function cjkFriendlyStrong() {
71
+ return cjkFriendlyStrongExtension;
72
+ }
73
+ //# sourceMappingURL=cjkFriendlyStrong.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cjkFriendlyStrong.js","sourceRoot":"","sources":["../../../../src/client/markdown/cjkFriendlyStrong.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,wGAAwG;AAExG,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCA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;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,0BAA0B,CAAA;AACnC,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Incremental block-level markdown parsing for an append-only text stream.
3
+ *
4
+ * Re-parsing the whole accumulated document on every streaming chunk is
5
+ * quadratic in the final reply length. CommonMark block parsing is line-based
6
+ * and appended text can only reshape the parse frontier — the last top-level
7
+ * block (a paragraph becoming a setext heading or a table, a list continuing
8
+ * after a blank line, an unclosed fence swallowing lines) — so earlier blocks
9
+ * are final. This parser therefore freezes all but the trailing
10
+ * {@link UNSTABLE_TAIL_BLOCKS} blocks and re-parses only the source tail
11
+ * behind them: each source region is parsed O(1) times over the stream
12
+ * instead of once per chunk.
13
+ *
14
+ * The freeze boundary comes from the parser's own `position` offsets, never
15
+ * from custom source scanning. The cut sits at the *end offset* of the last
16
+ * frozen block (not the next block's start): a following block's start offset
17
+ * excludes up to three spaces of insignificant leading indentation, which is
18
+ * harmless to drop, but cutting at the previous end also keeps the
19
+ * inter-block blank lines in the tail so the sliced source stays verbatim.
20
+ *
21
+ * Known deviation, shared with any prefix-freeze scheme: micromark resolves
22
+ * reference-style links and footnotes document-wide at parse time, so a
23
+ * reference whose definition lands on the other side of the freeze boundary
24
+ * renders literally until the settled full parse self-heals it.
25
+ */
26
+ import type { Root, RootContent } from 'mdast';
27
+ /** A top-level mdast block plus a render key that is stable across chunks. */
28
+ export interface PositionedBlock {
29
+ /** The parsed block. Positions inside it are relative to its parse slice. */
30
+ readonly node: RootContent;
31
+ /**
32
+ * The block's start offset in the full source text. Stable from the frame
33
+ * a block first appears through freezing, so React reconciles rather than
34
+ * remounts when a block crosses the freeze boundary.
35
+ */
36
+ readonly key: number;
37
+ }
38
+ /** One {@link IncrementalMarkdownParser.update} result. */
39
+ export interface IncrementalBlocks {
40
+ /** Blocks that can no longer change; grows monotonically per generation. */
41
+ readonly frozen: readonly PositionedBlock[];
42
+ /** The re-parsed unstable tail (at most {@link UNSTABLE_TAIL_BLOCKS} blocks plus growth). */
43
+ readonly tail: readonly PositionedBlock[];
44
+ /** Bumped whenever non-append input discards the frozen prefix; callers drop caches keyed on it. */
45
+ readonly generation: number;
46
+ }
47
+ /**
48
+ * Append-only incremental parser over a caller-supplied grammar. One instance
49
+ * accumulates one streaming document; non-append input resets it.
50
+ */
51
+ export declare class IncrementalMarkdownParser {
52
+ private readonly parse;
53
+ private prevText;
54
+ private tailStart;
55
+ private frozen;
56
+ private generation;
57
+ private cached;
58
+ /** @param parse - Grammar shared with whatever renders the blocks, so boundaries agree. */
59
+ constructor(parse: (text: string) => Root);
60
+ /**
61
+ * Fold the current accumulated text and return the frozen/tail split.
62
+ * Idempotent for identical input (the previous result is returned as-is),
63
+ * so callers may invoke it from render paths that re-execute.
64
+ * @param text - The full accumulated markdown source.
65
+ * @returns Frozen and tail blocks with stream-stable render keys.
66
+ */
67
+ update(text: string): IncrementalBlocks;
68
+ }
69
+ //# sourceMappingURL=incremental.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incremental.d.ts","sourceRoot":"","sources":["../../../../src/client/markdown/incremental.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAS9C,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED,2DAA2D;AAC3D,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;IAC3C,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,EAAE,SAAS,eAAe,EAAE,CAAA;IACzC,oGAAoG;IACpG,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAeD;;;GAGG;AACH,qBAAa,yBAAyB;IAQxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAPlC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,SAAS,CAAI;IACrB,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,UAAU,CAAI;IACtB,OAAO,CAAC,MAAM,CAAiC;IAE/C,2FAA2F;gBAC9D,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI;IAE1D;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB;CAsCxC"}
@@ -0,0 +1,108 @@
1
+ // Adapted from DeepSeek Harness b150a551b8d465e31e418e1b2eaf5e79bbb7d28e (MIT). See THIRD_PARTY_NOTICES.md.
2
+ /**
3
+ * Incremental block-level markdown parsing for an append-only text stream.
4
+ *
5
+ * Re-parsing the whole accumulated document on every streaming chunk is
6
+ * quadratic in the final reply length. CommonMark block parsing is line-based
7
+ * and appended text can only reshape the parse frontier — the last top-level
8
+ * block (a paragraph becoming a setext heading or a table, a list continuing
9
+ * after a blank line, an unclosed fence swallowing lines) — so earlier blocks
10
+ * are final. This parser therefore freezes all but the trailing
11
+ * {@link UNSTABLE_TAIL_BLOCKS} blocks and re-parses only the source tail
12
+ * behind them: each source region is parsed O(1) times over the stream
13
+ * instead of once per chunk.
14
+ *
15
+ * The freeze boundary comes from the parser's own `position` offsets, never
16
+ * from custom source scanning. The cut sits at the *end offset* of the last
17
+ * frozen block (not the next block's start): a following block's start offset
18
+ * excludes up to three spaces of insignificant leading indentation, which is
19
+ * harmless to drop, but cutting at the previous end also keeps the
20
+ * inter-block blank lines in the tail so the sliced source stays verbatim.
21
+ *
22
+ * Known deviation, shared with any prefix-freeze scheme: micromark resolves
23
+ * reference-style links and footnotes document-wide at parse time, so a
24
+ * reference whose definition lands on the other side of the freeze boundary
25
+ * renders literally until the settled full parse self-heals it.
26
+ */
27
+ /**
28
+ * Trailing blocks kept unstable. Appended text reshapes at most the last
29
+ * block; the second-to-last is retained as safety margin so a freeze decision
30
+ * never has to reason about the parse frontier.
31
+ */
32
+ const UNSTABLE_TAIL_BLOCKS = 2;
33
+ /**
34
+ * A block's render key: its absolute source start offset. A position-less
35
+ * node (a grammar is free to omit positions) falls back to a negative
36
+ * list-index key — unique within one update's tail, which is the only place
37
+ * the fallback can occur: freezing requires the cut block's position, so a
38
+ * position-less parse keeps every block in the tail (real grammars always
39
+ * stamp positions and never take this path).
40
+ */
41
+ function blockKey(node, base, index) {
42
+ const offset = node.position?.start.offset;
43
+ return offset === undefined ? -(index + 1) : base + offset;
44
+ }
45
+ /**
46
+ * Append-only incremental parser over a caller-supplied grammar. One instance
47
+ * accumulates one streaming document; non-append input resets it.
48
+ */
49
+ export class IncrementalMarkdownParser {
50
+ parse;
51
+ prevText = '';
52
+ tailStart = 0;
53
+ frozen = [];
54
+ generation = 0;
55
+ cached = null;
56
+ /** @param parse - Grammar shared with whatever renders the blocks, so boundaries agree. */
57
+ constructor(parse) {
58
+ this.parse = parse;
59
+ }
60
+ /**
61
+ * Fold the current accumulated text and return the frozen/tail split.
62
+ * Idempotent for identical input (the previous result is returned as-is),
63
+ * so callers may invoke it from render paths that re-execute.
64
+ * @param text - The full accumulated markdown source.
65
+ * @returns Frozen and tail blocks with stream-stable render keys.
66
+ */
67
+ update(text) {
68
+ if (this.cached !== null && text === this.prevText)
69
+ return this.cached;
70
+ // Deliberate O(prefix) memcmp per update: sound divergence detection has
71
+ // to verify the whole retained prefix, and startsWith compares bytes two
72
+ // orders of magnitude faster than parsing them — the cost this class
73
+ // exists to remove. Passing append/reset deltas instead would push
74
+ // append bookkeeping across the session-projection update boundary for a check
75
+ // that stays sub-millisecond at realistic reply sizes.
76
+ if (!text.startsWith(this.prevText)) {
77
+ this.prevText = '';
78
+ this.tailStart = 0;
79
+ this.frozen = [];
80
+ this.generation += 1;
81
+ }
82
+ this.prevText = text;
83
+ const base = this.tailStart;
84
+ const blocks = this.parse(text.slice(base)).children;
85
+ let firstUnstable = Math.max(0, blocks.length - UNSTABLE_TAIL_BLOCKS);
86
+ if (firstUnstable > 0) {
87
+ const cutEnd = blocks[firstUnstable - 1]?.position?.end.offset;
88
+ if (cutEnd === undefined) {
89
+ // A grammar that omits positions leaves nothing to cut at; keep the
90
+ // whole parse in the tail rather than guessing a boundary.
91
+ firstUnstable = 0;
92
+ }
93
+ else {
94
+ for (const node of blocks.slice(0, firstUnstable)) {
95
+ this.frozen.push({ node, key: blockKey(node, base, this.frozen.length) });
96
+ }
97
+ this.tailStart = base + cutEnd;
98
+ }
99
+ }
100
+ const tail = blocks.slice(firstUnstable).map((node, index) => ({
101
+ node,
102
+ key: blockKey(node, base, index),
103
+ }));
104
+ this.cached = { frozen: [...this.frozen], tail, generation: this.generation };
105
+ return this.cached;
106
+ }
107
+ }
108
+ //# sourceMappingURL=incremental.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incremental.js","sourceRoot":"","sources":["../../../../src/client/markdown/incremental.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAA;AAwB9B;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,IAAiB,EAAE,IAAY,EAAE,KAAa;IAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAA;IAC1C,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,MAAM,CAAA;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAQP;IAPrB,QAAQ,GAAG,EAAE,CAAA;IACb,SAAS,GAAG,CAAC,CAAA;IACb,MAAM,GAAsB,EAAE,CAAA;IAC9B,UAAU,GAAG,CAAC,CAAA;IACd,MAAM,GAA6B,IAAI,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CAAC,EAAE,aAAa,CAAC,EAAE,CAAC;oBAClD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;gBAC3E,CAAC;gBACD,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,MAAM,CAAA;YAChC,CAAC;QACH,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7D,IAAI;YACJ,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC;SACjC,CAAC,CAAC,CAAA;QACH,IAAI,CAAC,MAAM,GAAG,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAA;QAC7E,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * TeX-to-React via KaTeX, replicating the rehype-katex pipeline this renderer
3
+ * replaced: the same three-arm error chain (strict render, `strict: 'ignore'`
4
+ * retry, error span) and a DOM-identical element tree, so settled math keeps
5
+ * its exact markup. KaTeX emits an HTML string; the browser's own HTML parser
6
+ * (`DOMParser`, applying the spec's SVG/MathML foreign-content attribute
7
+ * adjustments KaTeX output relies on) turns it into a tree this module maps
8
+ * onto React elements — KaTeX output is a static span/MathML/SVG vocabulary
9
+ * with no raw user HTML, the same trust shiki's tree gets in CodeBlock.
10
+ *
11
+ * React 18 has no MathML support, so the `.katex-mathml` subtree's elements
12
+ * land in the HTML namespace — exactly as they did under the replaced
13
+ * hast-util-to-jsx-runtime pipeline. The visual arm is the `.katex-html`
14
+ * span tree; the MathML arm serves assistive technology, which reads it by
15
+ * tag name regardless of namespace.
16
+ */
17
+ import type { ReactNode } from 'react';
18
+ /**
19
+ * Render TeX source to React elements through KaTeX.
20
+ * @param value - The TeX source (math node value; fenced `math` blocks append
21
+ * their trailing newline to match the replaced pipeline's text extraction).
22
+ * @param displayMode - Display (block) versus inline rendering.
23
+ * @returns KaTeX's element tree, or the error span when the source does not
24
+ * parse (colored with KaTeX's stock `errorColor`, matching rehype-katex).
25
+ */
26
+ export declare function renderTexToReact(value: string, displayMode: boolean): ReactNode;
27
+ //# sourceMappingURL=katex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"katex.d.ts","sourceRoot":"","sources":["../../../../src/client/markdown/katex.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAuCrD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,SAAS,CAwB/E"}
@@ -0,0 +1,88 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Adapted from DeepSeek Harness b150a551b8d465e31e418e1b2eaf5e79bbb7d28e (MIT). See THIRD_PARTY_NOTICES.md.
3
+ /**
4
+ * TeX-to-React via KaTeX, replicating the rehype-katex pipeline this renderer
5
+ * replaced: the same three-arm error chain (strict render, `strict: 'ignore'`
6
+ * retry, error span) and a DOM-identical element tree, so settled math keeps
7
+ * its exact markup. KaTeX emits an HTML string; the browser's own HTML parser
8
+ * (`DOMParser`, applying the spec's SVG/MathML foreign-content attribute
9
+ * adjustments KaTeX output relies on) turns it into a tree this module maps
10
+ * onto React elements — KaTeX output is a static span/MathML/SVG vocabulary
11
+ * with no raw user HTML, the same trust shiki's tree gets in CodeBlock.
12
+ *
13
+ * React 18 has no MathML support, so the `.katex-mathml` subtree's elements
14
+ * land in the HTML namespace — exactly as they did under the replaced
15
+ * hast-util-to-jsx-runtime pipeline. The visual arm is the `.katex-html`
16
+ * span tree; the MathML arm serves assistive technology, which reads it by
17
+ * tag name regardless of namespace.
18
+ */
19
+ import { createElement } from 'react';
20
+ import katex from 'katex';
21
+ /**
22
+ * Convert one inline `style` attribute string into React's style object.
23
+ * KaTeX emits only plain kebab-case declarations (no custom properties and no
24
+ * nameless declarations), so camel-casing the property is the whole mapping.
25
+ */
26
+ function styleObject(css) {
27
+ const style = {};
28
+ for (const declaration of css.split(';')) {
29
+ const colon = declaration.indexOf(':');
30
+ if (colon === -1)
31
+ continue;
32
+ const name = declaration.slice(0, colon).trim();
33
+ const key = name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
34
+ style[key] = declaration.slice(colon + 1).trim();
35
+ }
36
+ return style;
37
+ }
38
+ /** Map one parsed DOM node onto a React element (text nodes pass through). */
39
+ function domToReact(node, key) {
40
+ if (node.nodeType === Node.TEXT_NODE)
41
+ return node.textContent;
42
+ /* v8 ignore next 2 -- KaTeX output holds only elements and text; other
43
+ node kinds cannot appear in its serialized vocabulary. */
44
+ if (node.nodeType !== Node.ELEMENT_NODE)
45
+ return null;
46
+ const element = node;
47
+ const props = { key };
48
+ for (const attribute of element.attributes) {
49
+ if (attribute.name === 'class')
50
+ props['className'] = attribute.value;
51
+ else if (attribute.name === 'style')
52
+ props['style'] = styleObject(attribute.value);
53
+ else
54
+ props[attribute.name] = attribute.value;
55
+ }
56
+ const children = [...element.childNodes].map(domToReact);
57
+ return children.length === 0
58
+ ? createElement(element.localName, props)
59
+ : createElement(element.localName, props, ...children);
60
+ }
61
+ /**
62
+ * Render TeX source to React elements through KaTeX.
63
+ * @param value - The TeX source (math node value; fenced `math` blocks append
64
+ * their trailing newline to match the replaced pipeline's text extraction).
65
+ * @param displayMode - Display (block) versus inline rendering.
66
+ * @returns KaTeX's element tree, or the error span when the source does not
67
+ * parse (colored with KaTeX's stock `errorColor`, matching rehype-katex).
68
+ */
69
+ export function renderTexToReact(value, displayMode) {
70
+ let html;
71
+ try {
72
+ html = katex.renderToString(value, { displayMode, throwOnError: true });
73
+ }
74
+ catch (error) {
75
+ try {
76
+ html = katex.renderToString(value, { displayMode, strict: 'ignore', throwOnError: false });
77
+ }
78
+ catch {
79
+ // KaTeX renders ParseErrors itself under throwOnError: false; only its
80
+ // internal errors reach here, so mirror rehype-katex's manual span.
81
+ /* v8 ignore next 8 */
82
+ return (_jsx("span", { className: "katex-error", style: { color: '#cc0000' }, title: String(error), children: value }));
83
+ }
84
+ }
85
+ const parsed = new DOMParser().parseFromString(html, 'text/html');
86
+ return [...parsed.body.childNodes].map(domToReact);
87
+ }
88
+ //# sourceMappingURL=katex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"katex.js","sourceRoot":"","sources":["../../../../src/client/markdown/katex.tsx"],"names":[],"mappings":";AAAA,4GAA4G;AAC5G;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;;;GAIG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,KAAK,GAA2B,EAAE,CAAA;IACxC,KAAK,MAAM,WAAW,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACtC,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,SAAQ;QAC1B,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,CAAA;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;QAClF,KAAK,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAA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AC,KAAK,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAA;IACzE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC;YACH,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAA;QAC5F,CAAC;QAAC,MAAM,CAAC;YACP,uEAAuE;YACvE,oEAAoE;YACpE,sBAAsB;YACtB,OAAO,CACL,eACE,SAAS,EAAC,aAAa,EACvB,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAC3B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,YAEnB,KAAK,GACD,CACR,CAAA;QACH,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IACjE,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;AACpD,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** Extend upstream dollar-only math syntax with TeX delimiters while reusing its token vocabulary. */
2
+ import type { Extension } from 'micromark-util-types';
3
+ /**
4
+ * TeX backslash delimiters and same-line display-dollar blocks as a micromark
5
+ * syntax extension reusing `micromark-extension-math`'s token vocabulary; the
6
+ * caller must also register `math()` on the same parse so the emitted tokens
7
+ * compile to standard math nodes.
8
+ * @returns The micromark syntax extension.
9
+ */
10
+ export declare function mathCompatibility(): Extension;
11
+ //# sourceMappingURL=mathCompatibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mathCompatibility.d.ts","sourceRoot":"","sources":["../../../../src/client/markdown/mathCompatibility.ts"],"names":[],"mappings":"AACA,sGAAsG;AAMtG,OAAO,KAAK,EAAa,SAAS,EAA8B,MAAM,sBAAsB,CAAA;AA6U5F;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,SAAS,CAE7C"}