@deepseek-harness-tui/dsh-tui 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (531) hide show
  1. package/README.md +70 -24
  2. package/assets/whale-girl/whale-girl-dark.png +0 -0
  3. package/assets/whale-girl/whale-girl-happy.png +0 -0
  4. package/assets/whale-girl/whale-girl.png +0 -0
  5. package/bin/dsh-tui.js +93 -6
  6. package/cordis.patch.yml +63 -22
  7. package/cordis.yml +3 -2
  8. package/guide/dsh-tui-guide/SKILL.md +37 -0
  9. package/guide/dsh-tui-guide/configuration.en.md +410 -0
  10. package/guide/dsh-tui-guide/configuration.md +349 -0
  11. package/guide/dsh-tui-guide/getting-started.en.md +398 -0
  12. package/guide/dsh-tui-guide/getting-started.md +397 -0
  13. package/guide/dsh-tui-guide/interaction.en.md +674 -0
  14. package/guide/dsh-tui-guide/interaction.md +747 -0
  15. package/guide/dsh-tui-guide/migrate.en.md +166 -0
  16. package/guide/dsh-tui-guide/migrate.md +132 -0
  17. package/guide/dsh-tui-guide/plugins.en.md +68 -0
  18. package/guide/dsh-tui-guide/plugins.md +56 -0
  19. package/guide/dsh-tui-guide/themes.en.md +192 -0
  20. package/guide/dsh-tui-guide/themes.md +185 -0
  21. package/guide/dsh-tui-guide/user-guide.en.md +608 -0
  22. package/guide/dsh-tui-guide/user-guide.md +586 -0
  23. package/guide/dsh-tui-guide/vscode.en.md +301 -0
  24. package/guide/dsh-tui-guide/vscode.md +272 -0
  25. package/lib/settings.json +1272 -0
  26. package/lib/types/adapter/channel/ui-policy.d.ts +10 -2
  27. package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
  28. package/lib/types/adapter/channel/ui-policy.js +17 -0
  29. package/lib/types/adapter/kernel/replay.d.ts.map +1 -1
  30. package/lib/types/adapter/kernel/replay.js +2 -0
  31. package/lib/types/adapter/ports/channel-display.d.ts +12 -0
  32. package/lib/types/adapter/ports/channel-display.d.ts.map +1 -1
  33. package/lib/types/adapter/ports/channel-session.d.ts +38 -0
  34. package/lib/types/adapter/ports/channel-session.d.ts.map +1 -1
  35. package/lib/types/adapter/ports/channel-settings.d.ts +14 -1
  36. package/lib/types/adapter/ports/channel-settings.d.ts.map +1 -1
  37. package/lib/types/adapter/ports/channel-ui.d.ts +75 -6
  38. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  39. package/lib/types/adapter/ports/channel-view.d.ts +86 -9
  40. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  41. package/lib/types/commands.d.ts.map +1 -1
  42. package/lib/types/commands.js +2 -0
  43. package/lib/types/components/BalanceReportRow.d.ts +10 -2
  44. package/lib/types/components/BalanceReportRow.d.ts.map +1 -1
  45. package/lib/types/components/BalanceReportRow.js +18 -4
  46. package/lib/types/components/Chat/JobCard.d.ts +9 -0
  47. package/lib/types/components/Chat/JobCard.d.ts.map +1 -1
  48. package/lib/types/components/Chat/JobCard.js +42 -15
  49. package/lib/types/components/Chat/SubagentMessage.js +6 -6
  50. package/lib/types/components/CompactionStatusRow.d.ts +24 -0
  51. package/lib/types/components/CompactionStatusRow.d.ts.map +1 -0
  52. package/lib/types/components/CompactionStatusRow.js +72 -0
  53. package/lib/types/components/GoalTodoPanel.js +2 -2
  54. package/lib/types/components/HelpMenu.d.ts +2 -2
  55. package/lib/types/components/HelpMenu.d.ts.map +1 -1
  56. package/lib/types/components/HelpMenu.js +5 -4
  57. package/lib/types/components/InlineMathParagraph.d.ts +22 -0
  58. package/lib/types/components/InlineMathParagraph.d.ts.map +1 -0
  59. package/lib/types/components/InlineMathParagraph.js +178 -0
  60. package/lib/types/components/JobsPanel.d.ts.map +1 -1
  61. package/lib/types/components/JobsPanel.js +80 -33
  62. package/lib/types/components/LogoV2.d.ts +41 -3
  63. package/lib/types/components/LogoV2.d.ts.map +1 -1
  64. package/lib/types/components/LogoV2.js +148 -24
  65. package/lib/types/components/Markdown.d.ts +10 -3
  66. package/lib/types/components/Markdown.d.ts.map +1 -1
  67. package/lib/types/components/Markdown.js +47 -14
  68. package/lib/types/components/MathBlock.d.ts +13 -0
  69. package/lib/types/components/MathBlock.d.ts.map +1 -0
  70. package/lib/types/components/MathBlock.js +136 -0
  71. package/lib/types/components/MessageList.d.ts +10 -1
  72. package/lib/types/components/MessageList.d.ts.map +1 -1
  73. package/lib/types/components/MessageList.js +16 -7
  74. package/lib/types/components/MigratePicker.d.ts +30 -0
  75. package/lib/types/components/MigratePicker.d.ts.map +1 -0
  76. package/lib/types/components/MigratePicker.js +38 -0
  77. package/lib/types/components/PresetPicker.d.ts +4 -0
  78. package/lib/types/components/PresetPicker.d.ts.map +1 -1
  79. package/lib/types/components/PresetPicker.js +5 -1
  80. package/lib/types/components/PromptInput.d.ts +17 -0
  81. package/lib/types/components/PromptInput.d.ts.map +1 -1
  82. package/lib/types/components/PromptInput.js +60 -8
  83. package/lib/types/components/SplitDiffView.d.ts.map +1 -1
  84. package/lib/types/components/SplitDiffView.js +2 -1
  85. package/lib/types/components/StarPrompt.d.ts +59 -0
  86. package/lib/types/components/StarPrompt.d.ts.map +1 -0
  87. package/lib/types/components/StarPrompt.js +326 -0
  88. package/lib/types/components/StreamingMarkdown.d.ts.map +1 -1
  89. package/lib/types/components/StreamingMarkdown.js +20 -3
  90. package/lib/types/components/SubagentCard.d.ts.map +1 -1
  91. package/lib/types/components/SubagentCard.js +8 -8
  92. package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
  93. package/lib/types/components/SubagentDetailScene.js +108 -10
  94. package/lib/types/components/TimelineRail.d.ts.map +1 -1
  95. package/lib/types/components/TimelineRail.js +9 -1
  96. package/lib/types/components/Whale.d.ts +17 -8
  97. package/lib/types/components/Whale.d.ts.map +1 -1
  98. package/lib/types/components/Whale.js +25 -15
  99. package/lib/types/components/WhaleGirl.d.ts +35 -0
  100. package/lib/types/components/WhaleGirl.d.ts.map +1 -0
  101. package/lib/types/components/WhaleGirl.js +50 -0
  102. package/lib/types/components/WorkingSpinner.d.ts +4 -1
  103. package/lib/types/components/WorkingSpinner.d.ts.map +1 -1
  104. package/lib/types/components/WorkingSpinner.js +2 -2
  105. package/lib/types/components/bigfont.d.ts +47 -18
  106. package/lib/types/components/bigfont.d.ts.map +1 -1
  107. package/lib/types/components/bigfont.js +55 -40
  108. package/lib/types/components/design-system/ThemeProvider.d.ts +6 -0
  109. package/lib/types/components/design-system/ThemeProvider.d.ts.map +1 -1
  110. package/lib/types/components/design-system/ThemeProvider.js +40 -1
  111. package/lib/types/components/maidPortrait.d.ts +44 -0
  112. package/lib/types/components/maidPortrait.d.ts.map +1 -0
  113. package/lib/types/components/maidPortrait.js +178 -0
  114. package/lib/types/components/mathPreview.d.ts +25 -0
  115. package/lib/types/components/mathPreview.d.ts.map +1 -0
  116. package/lib/types/components/mathPreview.js +48 -0
  117. package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
  118. package/lib/types/components/messages/AssistantThinkingMessage.js +6 -5
  119. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  120. package/lib/types/components/messages/AssistantToolUseMessage.js +3 -2
  121. package/lib/types/components/messages/TranscriptImages.d.ts.map +1 -1
  122. package/lib/types/components/messages/TranscriptImages.js +11 -1
  123. package/lib/types/components/questions/AskUserQuestionPanel.d.ts +14 -2
  124. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
  125. package/lib/types/components/questions/AskUserQuestionPanel.js +80 -38
  126. package/lib/types/components/questions/PlanReviewPanel.d.ts.map +1 -1
  127. package/lib/types/components/questions/PlanReviewPanel.js +3 -3
  128. package/lib/types/components/sessions/ForeignSessionRow.d.ts +34 -0
  129. package/lib/types/components/sessions/ForeignSessionRow.d.ts.map +1 -0
  130. package/lib/types/components/sessions/ForeignSessionRow.js +43 -0
  131. package/lib/types/components/sessions/SourceTabs.d.ts +52 -0
  132. package/lib/types/components/sessions/SourceTabs.d.ts.map +1 -0
  133. package/lib/types/components/sessions/SourceTabs.js +70 -0
  134. package/lib/types/components/splashEggs.d.ts +56 -0
  135. package/lib/types/components/splashEggs.d.ts.map +1 -0
  136. package/lib/types/components/splashEggs.js +67 -0
  137. package/lib/types/components/splashFonts.d.ts +119 -0
  138. package/lib/types/components/splashFonts.d.ts.map +1 -0
  139. package/lib/types/components/splashFonts.js +267 -0
  140. package/lib/types/components/splashLayout.d.ts +41 -0
  141. package/lib/types/components/splashLayout.d.ts.map +1 -0
  142. package/lib/types/components/splashLayout.js +40 -0
  143. package/lib/types/components/trajectory/MiniWake.d.ts +11 -1
  144. package/lib/types/components/trajectory/MiniWake.d.ts.map +1 -1
  145. package/lib/types/components/trajectory/MiniWake.js +9 -3
  146. package/lib/types/components/whaleGirlSprite.d.ts +17 -0
  147. package/lib/types/components/whaleGirlSprite.d.ts.map +1 -0
  148. package/lib/types/components/whaleGirlSprite.js +47 -0
  149. package/lib/types/deepseekPricing.d.ts +74 -0
  150. package/lib/types/deepseekPricing.d.ts.map +1 -1
  151. package/lib/types/deepseekPricing.js +110 -11
  152. package/lib/types/dsh-adapter/channel/action-readiness.d.ts +1 -1
  153. package/lib/types/dsh-adapter/channel/action-readiness.d.ts.map +1 -1
  154. package/lib/types/dsh-adapter/channel/action-readiness.js +6 -1
  155. package/lib/types/dsh-adapter/channel/background-action.d.ts +1 -0
  156. package/lib/types/dsh-adapter/channel/background-action.d.ts.map +1 -1
  157. package/lib/types/dsh-adapter/channel/background-action.js +1 -0
  158. package/lib/types/dsh-adapter/channel/binding-events.d.ts +8 -9
  159. package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
  160. package/lib/types/dsh-adapter/channel/binding-events.js +69 -21
  161. package/lib/types/dsh-adapter/channel/compaction.d.ts +2 -1
  162. package/lib/types/dsh-adapter/channel/compaction.d.ts.map +1 -1
  163. package/lib/types/dsh-adapter/channel/compaction.js +35 -2
  164. package/lib/types/dsh-adapter/channel/external-commands.d.ts.map +1 -1
  165. package/lib/types/dsh-adapter/channel/external-commands.js +8 -2
  166. package/lib/types/dsh-adapter/channel/job-projection.d.ts +1 -0
  167. package/lib/types/dsh-adapter/channel/job-projection.d.ts.map +1 -1
  168. package/lib/types/dsh-adapter/channel/job-projection.js +88 -3
  169. package/lib/types/dsh-adapter/channel/local-actions.d.ts.map +1 -1
  170. package/lib/types/dsh-adapter/channel/local-actions.js +6 -1
  171. package/lib/types/dsh-adapter/channel/mode-actions.d.ts +13 -0
  172. package/lib/types/dsh-adapter/channel/mode-actions.d.ts.map +1 -1
  173. package/lib/types/dsh-adapter/channel/mode-actions.js +48 -7
  174. package/lib/types/dsh-adapter/channel/mode-permission-actions.d.ts.map +1 -1
  175. package/lib/types/dsh-adapter/channel/mode-permission-actions.js +25 -9
  176. package/lib/types/dsh-adapter/channel/model-switch.d.ts.map +1 -1
  177. package/lib/types/dsh-adapter/channel/model-switch.js +5 -1
  178. package/lib/types/dsh-adapter/channel/paths.d.ts.map +1 -1
  179. package/lib/types/dsh-adapter/channel/paths.js +7 -1
  180. package/lib/types/dsh-adapter/channel/preferences.d.ts +1 -1
  181. package/lib/types/dsh-adapter/channel/preferences.d.ts.map +1 -1
  182. package/lib/types/dsh-adapter/channel/preferences.js +31 -5
  183. package/lib/types/dsh-adapter/channel/projection.d.ts +1 -2
  184. package/lib/types/dsh-adapter/channel/projection.d.ts.map +1 -1
  185. package/lib/types/dsh-adapter/channel/projection.js +127 -17
  186. package/lib/types/dsh-adapter/channel/question-record.d.ts +76 -0
  187. package/lib/types/dsh-adapter/channel/question-record.d.ts.map +1 -0
  188. package/lib/types/dsh-adapter/channel/question-record.js +107 -0
  189. package/lib/types/dsh-adapter/channel/session-lineage.d.ts +42 -0
  190. package/lib/types/dsh-adapter/channel/session-lineage.d.ts.map +1 -0
  191. package/lib/types/dsh-adapter/channel/session-lineage.js +51 -0
  192. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts +2 -0
  193. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts.map +1 -1
  194. package/lib/types/dsh-adapter/channel/session-live-adoption.js +9 -3
  195. package/lib/types/dsh-adapter/channel/session-metadata.d.ts +2 -1
  196. package/lib/types/dsh-adapter/channel/session-metadata.d.ts.map +1 -1
  197. package/lib/types/dsh-adapter/channel/session-metadata.js +39 -7
  198. package/lib/types/dsh-adapter/channel/session-reset.d.ts +1 -1
  199. package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
  200. package/lib/types/dsh-adapter/channel/session-reset.js +7 -0
  201. package/lib/types/dsh-adapter/channel/session-resume.d.ts +1 -0
  202. package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
  203. package/lib/types/dsh-adapter/channel/session-resume.js +4 -2
  204. package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
  205. package/lib/types/dsh-adapter/channel/settings-host.js +8 -0
  206. package/lib/types/dsh-adapter/channel/state.d.ts +17 -2
  207. package/lib/types/dsh-adapter/channel/state.d.ts.map +1 -1
  208. package/lib/types/dsh-adapter/channel/state.js +6 -1
  209. package/lib/types/dsh-adapter/channel/subagent-projection.d.ts +30 -35
  210. package/lib/types/dsh-adapter/channel/subagent-projection.d.ts.map +1 -1
  211. package/lib/types/dsh-adapter/channel/subagent-projection.js +143 -4
  212. package/lib/types/dsh-adapter/channel/types.d.ts +1 -1
  213. package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
  214. package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
  215. package/lib/types/dsh-adapter/channel.js +35 -5
  216. package/lib/types/dsh-adapter/compat/messages.d.ts +6 -0
  217. package/lib/types/dsh-adapter/compat/messages.d.ts.map +1 -1
  218. package/lib/types/dsh-adapter/compat/messages.js +9 -0
  219. package/lib/types/dsh-adapter/contract.d.ts +6 -5
  220. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  221. package/lib/types/dsh-adapter/contract.js +14 -6
  222. package/lib/types/dsh-adapter/index.d.ts +36 -1
  223. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  224. package/lib/types/dsh-adapter/index.js +22 -6
  225. package/lib/types/dsh-adapter/jobs.d.ts +82 -16
  226. package/lib/types/dsh-adapter/jobs.d.ts.map +1 -1
  227. package/lib/types/dsh-adapter/jobs.js +104 -9
  228. package/lib/types/dsh-adapter/migrate/adapters/claude-code.d.ts +3 -0
  229. package/lib/types/dsh-adapter/migrate/adapters/claude-code.d.ts.map +1 -0
  230. package/lib/types/dsh-adapter/migrate/adapters/claude-code.js +131 -0
  231. package/lib/types/dsh-adapter/migrate/adapters/claude-code.parse.d.ts +17 -0
  232. package/lib/types/dsh-adapter/migrate/adapters/claude-code.parse.d.ts.map +1 -0
  233. package/lib/types/dsh-adapter/migrate/adapters/claude-code.parse.js +329 -0
  234. package/lib/types/dsh-adapter/migrate/adapters/codex.d.ts +3 -0
  235. package/lib/types/dsh-adapter/migrate/adapters/codex.d.ts.map +1 -0
  236. package/lib/types/dsh-adapter/migrate/adapters/codex.js +102 -0
  237. package/lib/types/dsh-adapter/migrate/adapters/codex.parse.d.ts +16 -0
  238. package/lib/types/dsh-adapter/migrate/adapters/codex.parse.d.ts.map +1 -0
  239. package/lib/types/dsh-adapter/migrate/adapters/codex.parse.js +289 -0
  240. package/lib/types/dsh-adapter/migrate/adapters/grok-build.d.ts +3 -0
  241. package/lib/types/dsh-adapter/migrate/adapters/grok-build.d.ts.map +1 -0
  242. package/lib/types/dsh-adapter/migrate/adapters/grok-build.js +117 -0
  243. package/lib/types/dsh-adapter/migrate/adapters/grok-build.parse.d.ts +13 -0
  244. package/lib/types/dsh-adapter/migrate/adapters/grok-build.parse.d.ts.map +1 -0
  245. package/lib/types/dsh-adapter/migrate/adapters/grok-build.parse.js +178 -0
  246. package/lib/types/dsh-adapter/migrate/adapters/omp.d.ts +3 -0
  247. package/lib/types/dsh-adapter/migrate/adapters/omp.d.ts.map +1 -0
  248. package/lib/types/dsh-adapter/migrate/adapters/omp.js +133 -0
  249. package/lib/types/dsh-adapter/migrate/adapters/scan-fs.d.ts +60 -0
  250. package/lib/types/dsh-adapter/migrate/adapters/scan-fs.d.ts.map +1 -0
  251. package/lib/types/dsh-adapter/migrate/adapters/scan-fs.js +178 -0
  252. package/lib/types/dsh-adapter/migrate/adapters/scan.d.ts +8 -0
  253. package/lib/types/dsh-adapter/migrate/adapters/scan.d.ts.map +1 -0
  254. package/lib/types/dsh-adapter/migrate/adapters/scan.js +40 -0
  255. package/lib/types/dsh-adapter/migrate/adapters/zcode.d.ts +3 -0
  256. package/lib/types/dsh-adapter/migrate/adapters/zcode.d.ts.map +1 -0
  257. package/lib/types/dsh-adapter/migrate/adapters/zcode.js +93 -0
  258. package/lib/types/dsh-adapter/migrate/adapters/zcode.parse.d.ts +9 -0
  259. package/lib/types/dsh-adapter/migrate/adapters/zcode.parse.d.ts.map +1 -0
  260. package/lib/types/dsh-adapter/migrate/adapters/zcode.parse.js +89 -0
  261. package/lib/types/dsh-adapter/migrate/bin-path.d.ts +6 -0
  262. package/lib/types/dsh-adapter/migrate/bin-path.d.ts.map +1 -0
  263. package/lib/types/dsh-adapter/migrate/bin-path.js +30 -0
  264. package/lib/types/dsh-adapter/migrate/browse.d.ts +42 -0
  265. package/lib/types/dsh-adapter/migrate/browse.d.ts.map +1 -0
  266. package/lib/types/dsh-adapter/migrate/browse.js +90 -0
  267. package/lib/types/dsh-adapter/migrate/cli.d.ts +9 -0
  268. package/lib/types/dsh-adapter/migrate/cli.d.ts.map +1 -0
  269. package/lib/types/dsh-adapter/migrate/cli.js +106 -0
  270. package/lib/types/dsh-adapter/migrate/import-one.d.ts +89 -0
  271. package/lib/types/dsh-adapter/migrate/import-one.d.ts.map +1 -0
  272. package/lib/types/dsh-adapter/migrate/import-one.js +133 -0
  273. package/lib/types/dsh-adapter/migrate/index.d.ts +35 -0
  274. package/lib/types/dsh-adapter/migrate/index.d.ts.map +1 -0
  275. package/lib/types/dsh-adapter/migrate/index.js +107 -0
  276. package/lib/types/dsh-adapter/migrate/parse/injection.d.ts +40 -0
  277. package/lib/types/dsh-adapter/migrate/parse/injection.d.ts.map +1 -0
  278. package/lib/types/dsh-adapter/migrate/parse/injection.js +127 -0
  279. package/lib/types/dsh-adapter/migrate/parse/jsonl.d.ts +28 -0
  280. package/lib/types/dsh-adapter/migrate/parse/jsonl.d.ts.map +1 -0
  281. package/lib/types/dsh-adapter/migrate/parse/jsonl.js +40 -0
  282. package/lib/types/dsh-adapter/migrate/parse/role-turns.d.ts +28 -0
  283. package/lib/types/dsh-adapter/migrate/parse/role-turns.d.ts.map +1 -0
  284. package/lib/types/dsh-adapter/migrate/parse/role-turns.js +50 -0
  285. package/lib/types/dsh-adapter/migrate/parse/title.d.ts +18 -0
  286. package/lib/types/dsh-adapter/migrate/parse/title.d.ts.map +1 -0
  287. package/lib/types/dsh-adapter/migrate/parse/title.js +29 -0
  288. package/lib/types/dsh-adapter/migrate/parse/tools.d.ts +62 -0
  289. package/lib/types/dsh-adapter/migrate/parse/tools.d.ts.map +1 -0
  290. package/lib/types/dsh-adapter/migrate/parse/tools.js +110 -0
  291. package/lib/types/dsh-adapter/migrate/picker.d.ts +64 -0
  292. package/lib/types/dsh-adapter/migrate/picker.d.ts.map +1 -0
  293. package/lib/types/dsh-adapter/migrate/picker.js +86 -0
  294. package/lib/types/dsh-adapter/migrate/recent-agents.d.ts +40 -0
  295. package/lib/types/dsh-adapter/migrate/recent-agents.d.ts.map +1 -0
  296. package/lib/types/dsh-adapter/migrate/recent-agents.js +100 -0
  297. package/lib/types/dsh-adapter/migrate/sessionize.d.ts +39 -0
  298. package/lib/types/dsh-adapter/migrate/sessionize.d.ts.map +1 -0
  299. package/lib/types/dsh-adapter/migrate/sessionize.js +271 -0
  300. package/lib/types/dsh-adapter/migrate/types.d.ts +176 -0
  301. package/lib/types/dsh-adapter/migrate/types.d.ts.map +1 -0
  302. package/lib/types/dsh-adapter/migrate/types.js +11 -0
  303. package/lib/types/dsh-adapter/migrate/uuid.d.ts +7 -0
  304. package/lib/types/dsh-adapter/migrate/uuid.d.ts.map +1 -0
  305. package/lib/types/dsh-adapter/migrate/uuid.js +25 -0
  306. package/lib/types/dsh-adapter/oauth/bonus.d.ts +27 -0
  307. package/lib/types/dsh-adapter/oauth/bonus.d.ts.map +1 -0
  308. package/lib/types/dsh-adapter/oauth/bonus.js +69 -0
  309. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/command.d.ts +2 -1
  310. package/lib/types/dsh-adapter/oauth/command.d.ts.map +1 -0
  311. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/command.js +7 -4
  312. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/credentials.d.ts +13 -10
  313. package/lib/types/dsh-adapter/oauth/credentials.d.ts.map +1 -0
  314. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/credentials.js +61 -23
  315. package/lib/types/dsh-adapter/oauth/deepseek.d.ts +39 -0
  316. package/lib/types/dsh-adapter/oauth/deepseek.d.ts.map +1 -0
  317. package/lib/types/dsh-adapter/oauth/deepseek.js +189 -0
  318. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/index.d.ts +24 -16
  319. package/lib/types/dsh-adapter/oauth/index.d.ts.map +1 -0
  320. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/index.js +34 -20
  321. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/interaction.d.ts +14 -12
  322. package/lib/types/dsh-adapter/oauth/interaction.d.ts.map +1 -0
  323. package/lib/types/dsh-adapter/oauth/interaction.js +283 -0
  324. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/opener.d.ts +2 -1
  325. package/lib/types/dsh-adapter/oauth/opener.d.ts.map +1 -0
  326. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/opener.js +1 -1
  327. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/pi-ai.d.ts +10 -3
  328. package/lib/types/dsh-adapter/oauth/pi-ai.d.ts.map +1 -0
  329. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/pi-ai.js +8 -3
  330. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/profiles.d.ts +6 -3
  331. package/lib/types/dsh-adapter/oauth/profiles.d.ts.map +1 -0
  332. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/profiles.js +11 -3
  333. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/service.d.ts +14 -7
  334. package/lib/types/dsh-adapter/oauth/service.d.ts.map +1 -0
  335. package/{node_modules/@deepseek-harness-tui/dsh-auth/lib → lib/types/dsh-adapter/oauth}/service.js +82 -17
  336. package/lib/types/dsh-adapter/plugin.d.ts +12 -3
  337. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  338. package/lib/types/dsh-adapter/plugin.js +215 -376
  339. package/lib/types/dsh-adapter/presets.d.ts +6 -4
  340. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  341. package/lib/types/dsh-adapter/presets.js +6 -4
  342. package/lib/types/dsh-adapter/providerWizard.d.ts +17 -0
  343. package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -1
  344. package/lib/types/dsh-adapter/providerWizard.js +260 -68
  345. package/lib/types/dsh-adapter/questions.d.ts +22 -15
  346. package/lib/types/dsh-adapter/questions.d.ts.map +1 -1
  347. package/lib/types/dsh-adapter/questions.js +47 -45
  348. package/lib/types/dsh-adapter/sessions/digest.d.ts +11 -6
  349. package/lib/types/dsh-adapter/sessions/digest.d.ts.map +1 -1
  350. package/lib/types/dsh-adapter/sessions/digest.js +20 -13
  351. package/lib/types/dsh-adapter/sessions/frames.d.ts +3 -1
  352. package/lib/types/dsh-adapter/sessions/frames.d.ts.map +1 -1
  353. package/lib/types/dsh-adapter/sessions/frames.js +5 -4
  354. package/lib/types/dsh-adapter/sessions/list.d.ts +6 -1
  355. package/lib/types/dsh-adapter/sessions/list.d.ts.map +1 -1
  356. package/lib/types/dsh-adapter/sessions/list.js +188 -164
  357. package/lib/types/dsh-adapter/sessions/recovery.d.ts +16 -0
  358. package/lib/types/dsh-adapter/sessions/recovery.d.ts.map +1 -0
  359. package/lib/types/dsh-adapter/sessions/recovery.js +108 -0
  360. package/lib/types/dsh-adapter/sessions/snapshot.d.ts +7 -0
  361. package/lib/types/dsh-adapter/sessions/snapshot.d.ts.map +1 -0
  362. package/lib/types/dsh-adapter/sessions/snapshot.js +90 -0
  363. package/lib/types/dsh-adapter/sessions/store.d.ts +10 -4
  364. package/lib/types/dsh-adapter/sessions/store.d.ts.map +1 -1
  365. package/lib/types/dsh-adapter/sessions/store.js +62 -25
  366. package/lib/types/dsh-adapter/sideQuestion.d.ts +41 -2
  367. package/lib/types/dsh-adapter/sideQuestion.d.ts.map +1 -1
  368. package/lib/types/dsh-adapter/sideQuestion.js +98 -2
  369. package/lib/types/dsh-adapter/subagents.d.ts +29 -3
  370. package/lib/types/dsh-adapter/subagents.d.ts.map +1 -1
  371. package/lib/types/dsh-adapter/subagents.js +87 -3
  372. package/lib/types/herdr.d.ts +2 -0
  373. package/lib/types/herdr.d.ts.map +1 -1
  374. package/lib/types/herdr.js +9 -3
  375. package/lib/types/i18n.d.ts +598 -60
  376. package/lib/types/i18n.d.ts.map +1 -1
  377. package/lib/types/i18n.js +198 -31
  378. package/lib/types/ink/components/App.d.ts +2 -2
  379. package/lib/types/ink/components/App.d.ts.map +1 -1
  380. package/lib/types/ink/components/App.js +15 -2
  381. package/lib/types/ink/components/Image.d.ts +14 -1
  382. package/lib/types/ink/components/Image.d.ts.map +1 -1
  383. package/lib/types/ink/components/Image.js +2 -2
  384. package/lib/types/ink/events/input-event.js +3 -3
  385. package/lib/types/ink/hooks/use-terminal-images.d.ts +12 -0
  386. package/lib/types/ink/hooks/use-terminal-images.d.ts.map +1 -1
  387. package/lib/types/ink/hooks/use-terminal-images.js +13 -0
  388. package/lib/types/ink/ink.d.ts +6 -0
  389. package/lib/types/ink/ink.d.ts.map +1 -1
  390. package/lib/types/ink/ink.js +16 -1
  391. package/lib/types/ink/kitty-graphics.d.ts +44 -3
  392. package/lib/types/ink/kitty-graphics.d.ts.map +1 -1
  393. package/lib/types/ink/kitty-graphics.js +184 -23
  394. package/lib/types/ink/output.d.ts +24 -2
  395. package/lib/types/ink/output.d.ts.map +1 -1
  396. package/lib/types/ink/output.js +83 -5
  397. package/lib/types/ink/parse-keypress.d.ts +61 -1
  398. package/lib/types/ink/parse-keypress.d.ts.map +1 -1
  399. package/lib/types/ink/parse-keypress.js +764 -93
  400. package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
  401. package/lib/types/ink/render-node-to-output.js +8 -1
  402. package/lib/types/ink/screen.d.ts +24 -0
  403. package/lib/types/ink/screen.d.ts.map +1 -1
  404. package/lib/types/ink/screen.js +89 -0
  405. package/lib/types/ink/selection.d.ts +40 -18
  406. package/lib/types/ink/selection.d.ts.map +1 -1
  407. package/lib/types/ink/selection.js +142 -30
  408. package/lib/types/ink/sixel-codec.d.ts +12 -1
  409. package/lib/types/ink/sixel-codec.d.ts.map +1 -1
  410. package/lib/types/ink/sixel-codec.js +29 -5
  411. package/lib/types/ink/sixel-graphics.d.ts.map +1 -1
  412. package/lib/types/ink/sixel-graphics.js +5 -3
  413. package/lib/types/ink/styles.d.ts +9 -0
  414. package/lib/types/ink/styles.d.ts.map +1 -1
  415. package/lib/types/ink/terminal-image.d.ts +8 -0
  416. package/lib/types/ink/terminal-image.d.ts.map +1 -1
  417. package/lib/types/ink/terminal-querier.d.ts +32 -1
  418. package/lib/types/ink/terminal-querier.d.ts.map +1 -1
  419. package/lib/types/ink/terminal-querier.js +54 -2
  420. package/lib/types/ink/timeline-rail.d.ts +5 -0
  421. package/lib/types/ink/timeline-rail.d.ts.map +1 -1
  422. package/lib/types/ink/update-overflow-guard.d.ts +24 -0
  423. package/lib/types/ink/update-overflow-guard.d.ts.map +1 -1
  424. package/lib/types/ink/update-overflow-guard.js +25 -3
  425. package/lib/types/math/inline-layout.d.ts +29 -0
  426. package/lib/types/math/inline-layout.d.ts.map +1 -0
  427. package/lib/types/math/inline-layout.js +106 -0
  428. package/lib/types/math/layout.d.ts +58 -0
  429. package/lib/types/math/layout.d.ts.map +1 -0
  430. package/lib/types/math/layout.js +59 -0
  431. package/lib/types/math/renderer.d.ts +64 -0
  432. package/lib/types/math/renderer.d.ts.map +1 -0
  433. package/lib/types/math/renderer.js +256 -0
  434. package/lib/types/minimalUiMode.d.ts +19 -0
  435. package/lib/types/minimalUiMode.d.ts.map +1 -0
  436. package/lib/types/minimalUiMode.js +23 -0
  437. package/lib/types/oauth.d.ts +5 -10
  438. package/lib/types/oauth.d.ts.map +1 -1
  439. package/lib/types/oauth.js +5 -10
  440. package/lib/types/screens/Chat.d.ts +17 -1
  441. package/lib/types/screens/Chat.d.ts.map +1 -1
  442. package/lib/types/screens/Chat.js +627 -54
  443. package/lib/types/screens/SessionSupervisor.d.ts +2 -1
  444. package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
  445. package/lib/types/screens/SessionSupervisor.js +156 -19
  446. package/lib/types/screens/Settings.d.ts.map +1 -1
  447. package/lib/types/screens/Settings.js +49 -11
  448. package/lib/types/screens/StatusLine.d.ts +4 -0
  449. package/lib/types/screens/StatusLine.d.ts.map +1 -1
  450. package/lib/types/screens/StatusLine.js +57 -27
  451. package/lib/types/screens/chatOverlay.d.ts +5 -0
  452. package/lib/types/screens/chatOverlay.d.ts.map +1 -1
  453. package/lib/types/screens/chatOverlay.js +1 -0
  454. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts +47 -0
  455. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -0
  456. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +65 -0
  457. package/lib/types/screens/sessionSupervisor/model.d.ts +12 -0
  458. package/lib/types/screens/sessionSupervisor/model.d.ts.map +1 -1
  459. package/lib/types/screens/sessionSupervisor/model.js +26 -0
  460. package/lib/types/screens/sessionSupervisor/useForeignSessions.d.ts +107 -0
  461. package/lib/types/screens/sessionSupervisor/useForeignSessions.d.ts.map +1 -0
  462. package/lib/types/screens/sessionSupervisor/useForeignSessions.js +312 -0
  463. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts +4 -1
  464. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts.map +1 -1
  465. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.js +97 -14
  466. package/lib/types/sessionHistory.d.ts +2 -2
  467. package/lib/types/sessionHistory.d.ts.map +1 -1
  468. package/lib/types/sessionHistory.js +31 -5
  469. package/lib/types/settings/definitions.d.ts +681 -0
  470. package/lib/types/settings/definitions.d.ts.map +1 -0
  471. package/lib/types/settings/definitions.js +511 -0
  472. package/lib/types/starAction.d.ts +44 -0
  473. package/lib/types/starAction.d.ts.map +1 -0
  474. package/lib/types/starAction.js +52 -0
  475. package/lib/types/terminal-utils/latex.d.ts +10 -0
  476. package/lib/types/terminal-utils/latex.d.ts.map +1 -0
  477. package/lib/types/terminal-utils/latex.js +1417 -0
  478. package/lib/types/terminal-utils/markdown.d.ts +3 -1
  479. package/lib/types/terminal-utils/markdown.d.ts.map +1 -1
  480. package/lib/types/terminal-utils/markdown.js +26 -1
  481. package/lib/types/terminal-utils/math.d.ts +66 -0
  482. package/lib/types/terminal-utils/math.d.ts.map +1 -0
  483. package/lib/types/terminal-utils/math.js +337 -0
  484. package/lib/types/tips.d.ts.map +1 -1
  485. package/lib/types/tips.js +16 -4
  486. package/lib/types/tuiDisplayPrefs.d.ts +67 -0
  487. package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
  488. package/lib/types/tuiDisplayPrefs.js +59 -0
  489. package/lib/types/ui.d.ts +1 -1
  490. package/lib/types/ui.d.ts.map +1 -1
  491. package/lib/types/ui.js +1 -1
  492. package/lib/types/update.js +2 -2
  493. package/lib/types/usageStats.d.ts +98 -0
  494. package/lib/types/usageStats.d.ts.map +1 -0
  495. package/lib/types/usageStats.js +169 -0
  496. package/lib/types/utils/bmp.d.ts +17 -0
  497. package/lib/types/utils/bmp.d.ts.map +1 -0
  498. package/lib/types/utils/bmp.js +154 -0
  499. package/lib/types/utils/clipboard.d.ts +14 -2
  500. package/lib/types/utils/clipboard.d.ts.map +1 -1
  501. package/lib/types/utils/clipboard.js +143 -8
  502. package/lib/types/utils/fold-long-lines.d.ts.map +1 -1
  503. package/lib/types/utils/fold-long-lines.js +2 -1
  504. package/lib/types/utils/keymap.d.ts +4 -1
  505. package/lib/types/utils/keymap.d.ts.map +1 -1
  506. package/lib/types/utils/keymap.js +8 -0
  507. package/lib/types/utils/modifiers.d.ts +4 -3
  508. package/lib/types/utils/modifiers.d.ts.map +1 -1
  509. package/lib/types/utils/modifiers.js +4 -3
  510. package/lib/types/utils/pastedImagePath.d.ts +8 -0
  511. package/lib/types/utils/pastedImagePath.d.ts.map +1 -1
  512. package/lib/types/utils/pastedImagePath.js +29 -5
  513. package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/LICENSE +202 -0
  514. package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/NOTICE +20 -0
  515. package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/index.d.ts +16 -0
  516. package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/lib/bundled-packages.json +4 -0
  517. package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/lib/index.mjs +20 -0
  518. package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/lib/index.mjs.LEGAL.txt +35 -0
  519. package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/package.json +29 -0
  520. package/package.json +127 -102
  521. package/presets/liangshen/agent.cordis.yml +4 -1
  522. package/presets/liangshen/preset.yml +1 -1
  523. package/lib/types/minimalMode.d.ts +0 -13
  524. package/lib/types/minimalMode.d.ts.map +0 -1
  525. package/lib/types/minimalMode.js +0 -17
  526. package/node_modules/@deepseek-harness-tui/dsh-auth/LICENSE +0 -21
  527. package/node_modules/@deepseek-harness-tui/dsh-auth/README.md +0 -143
  528. package/node_modules/@deepseek-harness-tui/dsh-auth/cordis.patch.yml +0 -11
  529. package/node_modules/@deepseek-harness-tui/dsh-auth/dsh-plugin.json +0 -44
  530. package/node_modules/@deepseek-harness-tui/dsh-auth/lib/interaction.js +0 -193
  531. package/node_modules/@deepseek-harness-tui/dsh-auth/package.json +0 -69
@@ -32,6 +32,7 @@ export function decrqm(mode) {
32
32
  return {
33
33
  request: csi(`?${mode}$p`),
34
34
  match: (r) => r.type === 'decrpm' && r.mode === mode,
35
+ responseType: 'decrpm',
35
36
  };
36
37
  }
37
38
  /**
@@ -44,6 +45,7 @@ export function da1() {
44
45
  return {
45
46
  request: csi('c'),
46
47
  match: (r) => r.type === 'da1',
48
+ responseType: 'da1',
47
49
  };
48
50
  }
49
51
  /**
@@ -54,6 +56,7 @@ export function da2() {
54
56
  return {
55
57
  request: csi('>c'),
56
58
  match: (r) => r.type === 'da2',
59
+ responseType: 'da2',
57
60
  };
58
61
  }
59
62
  /**
@@ -65,6 +68,7 @@ export function kittyKeyboard() {
65
68
  return {
66
69
  request: csi('?u'),
67
70
  match: (r) => r.type === 'kittyKeyboard',
71
+ responseType: 'kittyKeyboard',
68
72
  };
69
73
  }
70
74
  /**
@@ -78,6 +82,7 @@ export function kittyGraphics(imageId) {
78
82
  // same direct-data + compression path used by real renderer uploads.
79
83
  request: `\u001b_Gi=${id},s=1,v=1,a=q,t=d,f=32,o=z;eAFjYGBgAAAABAAB\u001b\\`,
80
84
  match: (r) => r.type === 'kittyGraphics' && r.imageId === id,
85
+ responseType: 'kittyGraphics',
81
86
  };
82
87
  }
83
88
  /** XTWINOPS: query the physical pixel dimensions of one terminal cell. */
@@ -85,6 +90,7 @@ export function terminalCellSizePixels() {
85
90
  return {
86
91
  request: csi('16t'),
87
92
  match: (r) => r.type === 'terminalPixelSize' && r.scope === 'cell',
93
+ responseType: 'terminalPixelSize',
88
94
  };
89
95
  }
90
96
  /** XTWINOPS: query the terminal text area's physical pixel dimensions. */
@@ -92,6 +98,7 @@ export function terminalWindowSizePixels() {
92
98
  return {
93
99
  request: csi('14t'),
94
100
  match: (r) => r.type === 'terminalPixelSize' && r.scope === 'window',
101
+ responseType: 'terminalPixelSize',
95
102
  };
96
103
  }
97
104
  /**
@@ -105,6 +112,7 @@ export function cursorPosition() {
105
112
  return {
106
113
  request: csi('?6n'),
107
114
  match: (r) => r.type === 'cursorPosition',
115
+ responseType: 'cursorPosition',
108
116
  };
109
117
  }
110
118
  /**
@@ -117,6 +125,7 @@ export function oscColor(code) {
117
125
  return {
118
126
  request: osc(code, '?'),
119
127
  match: (r) => r.type === 'osc' && r.code === code,
128
+ responseType: 'osc',
120
129
  };
121
130
  }
122
131
  /**
@@ -131,6 +140,7 @@ export function xtversion() {
131
140
  return {
132
141
  request: csi('>0q'),
133
142
  match: (r) => r.type === 'xtversion',
143
+ responseType: 'xtversion',
134
144
  };
135
145
  }
136
146
  // -- Querier --
@@ -166,6 +176,37 @@ export class TerminalQuerier {
166
176
  get isSuspended() {
167
177
  return this.suspended;
168
178
  }
179
+ /**
180
+ * In-flight evidence for the input parser (read-only observation): true
181
+ * while at least one query or flush sentinel is still waiting for its
182
+ * reply. Purely observational — queue semantics are untouched.
183
+ */
184
+ get hasPending() {
185
+ return this.queue.length > 0;
186
+ }
187
+ /**
188
+ * In-flight evidence for the input parser (read-only observation): the
189
+ * response types of the queries still awaiting a reply, plus `da1` when a
190
+ * flush() sentinel is still open (DA1 is the reply that resolves it).
191
+ *
192
+ * This is bound to the query lifecycle on purpose. A boolean "something
193
+ * was sent recently" lets any recent query authorize a claim for bytes
194
+ * that may belong to no query at all, so the parser receives the expected
195
+ * types instead: a reply tail is only claimed when its shape can complete
196
+ * into one of them, and a query resolved by a sentinel stops counting the
197
+ * moment its promise settles. Purely observational — queue semantics are
198
+ * untouched.
199
+ */
200
+ get pendingResponseTypes() {
201
+ const types = new Set();
202
+ for (const pending of this.queue) {
203
+ if (pending.kind === 'query')
204
+ types.add(pending.responseType);
205
+ else
206
+ types.add('da1');
207
+ }
208
+ return types;
209
+ }
169
210
  holdRawMode() {
170
211
  this.setRawMode?.(true);
171
212
  return () => this.setRawMode?.(false);
@@ -190,6 +231,7 @@ export class TerminalQuerier {
190
231
  this.queue.push({
191
232
  kind: 'query',
192
233
  match: query.match,
234
+ responseType: query.responseType,
193
235
  resolve: r => resolve(r),
194
236
  releaseRawMode: this.holdRawMode(),
195
237
  });
@@ -214,6 +256,11 @@ export class TerminalQuerier {
214
256
  this.suspended = true;
215
257
  this.drainPending();
216
258
  }
259
+ /**
260
+ * Receives responses that answer no pending query — e.g. a Kitty graphics
261
+ * error for a placement command sent without suppressing failures.
262
+ */
263
+ onUnsolicited = undefined;
217
264
  /**
218
265
  * Dispatch a response parsed from stdin. Called by App.tsx's
219
266
  * processKeysInBatch for every `kind: 'response'` item.
@@ -230,7 +277,8 @@ export class TerminalQuerier {
230
277
  * and signal its flush() completion. Only draining up to the first
231
278
  * sentinel keeps later batches intact when multiple callers have
232
279
  * concurrent queries in flight.
233
- * - Unsolicited responses (no match, no sentinel) are silently dropped.
280
+ * - Unsolicited responses (no match, no sentinel) go to
281
+ * {@link onUnsolicited} when set, and are dropped otherwise.
234
282
  * @param r - the response parsed from stdin.
235
283
  */
236
284
  onResponse(r) {
@@ -247,8 +295,10 @@ export class TerminalQuerier {
247
295
  }
248
296
  if (r.type === 'da1') {
249
297
  const s = this.queue.findIndex(p => p.kind === 'sentinel');
250
- if (s === -1)
298
+ if (s === -1) {
299
+ this.onUnsolicited?.(r);
251
300
  return;
301
+ }
252
302
  for (const p of this.queue.splice(0, s + 1)) {
253
303
  if (p.kind === 'query')
254
304
  p.resolve(undefined);
@@ -256,7 +306,9 @@ export class TerminalQuerier {
256
306
  p.resolve(r);
257
307
  p.releaseRawMode();
258
308
  }
309
+ return;
259
310
  }
311
+ this.onUnsolicited?.(r);
260
312
  }
261
313
  /**
262
314
  * Resolve outstanding queries before stdin is handed to another process.
@@ -63,6 +63,11 @@ export interface TimelineSnapshot {
63
63
  /** Turn owning the viewport top row; first turn while pre-turn content
64
64
  * owns the top; null only when there are no turns. */
65
65
  activeId: number | null;
66
+ /** Turn the sticky header names: the active turn once its prompt has
67
+ * scrolled out above the viewport top (or is folded away); null while
68
+ * that prompt, or pre-turn content such as the logo, is still on the
69
+ * top row, where naming it would repeat text already on screen. */
70
+ pinnedId: number | null;
66
71
  /** ▲ target (strictly above the top), null at the first turn. */
67
72
  upId: number | null;
68
73
  /** ▼ target (below the top and reachable), null at the end. */
@@ -1 +1 @@
1
- {"version":3,"file":"timeline-rail.d.ts","sourceRoot":"","sources":["../../../src/ink/timeline-rail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,qDAAqD;AACrD,eAAO,MAAM,UAAU,IAAI,CAAA;AAE3B,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,KAAK,CAAA;AAEzC,mDAAmD;AACnD,eAAO,MAAM,cAAc,IAAI,CAAA;AAE/B,0EAA0E;AAC1E,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC;uEACuE;AACvE,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAA;IACV;6BACyB;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAA;IACf;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;iEACiE;AACjE,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,KAAK,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IAClC;2DACuD;IACvD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,iEAAiE;IACjE,IAAI,EAAE,MAAM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GACf;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GACd;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnC;0CAC0C;AAC1C,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB;;qBAEiB;IACjB,UAAU,EAAE,OAAO,CAAA;CACpB,GAAG,OAAO,CAOV;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,QAAQ,EAAE,OAAO,GAChB,YAAY,GAAG,IAAI,CAuBrB;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAUtE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAoB,GAAG,MAAM,CAkB9E;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CA+B5E"}
@@ -58,5 +58,29 @@ export declare function swallowNestedUpdateOverflow(error: unknown, source: stri
58
58
  * @param onChange - The subscriber callback about to run.
59
59
  */
60
60
  export declare function callWithUpdateOverflowGuard(source: string, onChange: () => void): void;
61
+ /**
62
+ * Origin of a process-level fatal error, as reported to the sink.
63
+ */
64
+ export type ProcessGuardOrigin = 'uncaughtException' | 'unhandledRejection';
65
+ /**
66
+ * Fatal-error sink installed by the process owner (the dsh-tui runtime, which
67
+ * routes it into the TUI's single exit funnel). Returning true means the sink
68
+ * took ownership of the process — it runs the teardown (resume marker,
69
+ * terminal restore, `dsh-tui crashed: …`) and exits non-zero. Returning false
70
+ * leaves the error to Node's default crash, which keeps "fail loud, non-zero"
71
+ * true when no sink is registered or the tree is being torn down.
72
+ */
73
+ export type ProcessGuardFatalSink = (error: unknown, origin: ProcessGuardOrigin) => boolean;
74
+ /** Register (or clear, with undefined) the fatal-error sink. */
75
+ export declare function registerProcessGuardFatalSink(sink: ProcessGuardFatalSink | undefined): void;
76
+ /**
77
+ * Normalize the reason handed to a fatal sink so the exit funnel can never
78
+ * mistake a fatal error for a clean user exit. `Promise.reject()` and
79
+ * `throw undefined` deliver `undefined`, and the funnel selects its crash path
80
+ * with `error !== undefined` — passing the raw reason through would run the
81
+ * zero-exit path while the sink reported that it owned the process. Defined
82
+ * reasons (including non-Error values) are returned unchanged.
83
+ */
84
+ export declare function fatalReasonForExit(error: unknown, origin: ProcessGuardOrigin): unknown;
61
85
  export declare function installNestedUpdateOverflowProcessGuard(): void;
62
86
  //# sourceMappingURL=update-overflow-guard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-overflow-guard.d.ts","sourceRoot":"","sources":["../../../src/ink/update-overflow-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAoBH,2EAA2E;AAC3E,MAAM,MAAM,cAAc,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;AAOjD,+CAA+C;AAC/C,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAEnF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAmDnF;AAED;;;;;;GA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,wBAAgB,uCAAuC,IAAI,IAAI,CAgB9D"}
@@ -130,6 +130,22 @@ export function callWithUpdateOverflowGuard(source, onChange) {
130
130
  throw error;
131
131
  }
132
132
  }
133
+ let fatalSink;
134
+ /** Register (or clear, with undefined) the fatal-error sink. */
135
+ export function registerProcessGuardFatalSink(sink) {
136
+ fatalSink = sink;
137
+ }
138
+ /**
139
+ * Normalize the reason handed to a fatal sink so the exit funnel can never
140
+ * mistake a fatal error for a clean user exit. `Promise.reject()` and
141
+ * `throw undefined` deliver `undefined`, and the funnel selects its crash path
142
+ * with `error !== undefined` — passing the raw reason through would run the
143
+ * zero-exit path while the sink reported that it owned the process. Defined
144
+ * reasons (including non-Error values) are returned unchanged.
145
+ */
146
+ export function fatalReasonForExit(error, origin) {
147
+ return error === undefined ? new Error(`${origin} with undefined reason`) : error;
148
+ }
133
149
  /**
134
150
  * Process-level backstop for the overflow error. The hotspot guards above
135
151
  * cover the known enqueue sites (clock tick, reveal tick, channel emit,
@@ -138,9 +154,11 @@ export function callWithUpdateOverflowGuard(source, onChange) {
138
154
  * feeder, a future timer, a plugin's store) would still kill the process.
139
155
  * This installs uncaughtException/unhandledRejection handlers that absorb
140
156
  * exactly the overflow error class (same self-healing contract: React
141
- * already reset the counter before throwing) and rethrow everything else
142
- * unchanged. Idempotent; opt out with DSH_TUI_NO_185_PROCESS_GUARD=1 when a
143
- * host owns process error policy.
157
+ * already reset the counter before throwing) and hand everything else to the
158
+ * registered fatal sink — or rethrow it unchanged when there is none, so the
159
+ * process still fails loud with a non-zero exit rather than continuing in an
160
+ * unknown state. Idempotent; opt out with DSH_TUI_NO_185_PROCESS_GUARD=1 when
161
+ * a host owns process error policy.
144
162
  */
145
163
  let processGuardInstalled = false;
146
164
  export function installNestedUpdateOverflowProcessGuard() {
@@ -152,6 +170,8 @@ export function installNestedUpdateOverflowProcessGuard() {
152
170
  process.on('uncaughtException', error => {
153
171
  if (swallowNestedUpdateOverflow(error, 'process.uncaught'))
154
172
  return;
173
+ if (fatalSink?.(error, 'uncaughtException') === true)
174
+ return;
155
175
  // Unknown errors keep Node's default semantics: rethrowing from a
156
176
  // listener crashes the process with the original error.
157
177
  throw error;
@@ -159,6 +179,8 @@ export function installNestedUpdateOverflowProcessGuard() {
159
179
  process.on('unhandledRejection', error => {
160
180
  if (swallowNestedUpdateOverflow(error, 'process.rejection'))
161
181
  return;
182
+ if (fatalSink?.(error, 'unhandledRejection') === true)
183
+ return;
162
184
  throw error;
163
185
  });
164
186
  }
@@ -0,0 +1,29 @@
1
+ /** Formulas one paragraph may lay out as images; the rest keep Unicode. */
2
+ export declare const INLINE_MEDIA_MAX = 4096;
3
+ export type InlinePiece = {
4
+ readonly kind: 'text';
5
+ readonly text: string;
6
+ readonly width: number;
7
+ } | {
8
+ readonly kind: 'media';
9
+ readonly index: number;
10
+ readonly columns: number;
11
+ };
12
+ export type InlineRow = {
13
+ readonly pieces: readonly InlinePiece[];
14
+ /** Columns the row's content spans. */
15
+ readonly width: number;
16
+ /** The row continues the previous one (a wrap, not a source newline). */
17
+ readonly continuation: boolean;
18
+ };
19
+ /** The placeholder run standing in for formula `index`, `columns` cells wide. */
20
+ export declare function inlineMediaPlaceholder(index: number, columns: number): string;
21
+ /**
22
+ * Wrap `formatted` (ANSI text containing placeholder runs for `columns.length`
23
+ * formulas) to `width` and split every row into text and media pieces.
24
+ * Returns undefined when a formula could not be kept whole on one row — its
25
+ * run was split by a hard wrap (wider than the row) or appears more than once
26
+ * — so the caller keeps the plain text rendering instead.
27
+ */
28
+ export declare function layoutInlineMedia(formatted: string, width: number, columns: readonly number[]): InlineRow[] | undefined;
29
+ //# sourceMappingURL=inline-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-layout.d.ts","sourceRoot":"","sources":["../../../src/math/inline-layout.ts"],"names":[],"mappings":"AAoBA,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,OAAS,CAAA;AAItC,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAA;IACvC,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,yEAAyE;IACzE,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;CAC/B,CAAA;AAED,iFAAiF;AACjF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAK7E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,SAAS,EAAE,GAAG,SAAS,CA2CzB"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Line layout for a paragraph whose inline formulas are terminal images.
3
+ *
4
+ * Each formula is stood in for by a run of placeholder characters as wide as
5
+ * its image (one private-use code point per formula, so neighbouring
6
+ * formulas stay distinguishable), and the formatted paragraph is wrapped by
7
+ * the same `wrapText` that <Text> uses. A run holds no spaces, so it wraps
8
+ * as one unbreakable word: a formula never splits across rows, and a
9
+ * paragraph with no formulas lays out exactly as it does in <Text>. Each
10
+ * wrapped row is then cut into ANSI-balanced text pieces (sliceAnsi re-opens
11
+ * the styles and links a cut crosses) and the image slots between them.
12
+ * Pure: no React, no terminal.
13
+ */
14
+ import stripAnsi from 'strip-ansi';
15
+ import { stringWidth } from '../ink/stringWidth.js';
16
+ import wrapText from '../ink/wrap-text.js';
17
+ import sliceAnsi from '../utils/sliceAnsi.js';
18
+ /** First placeholder code point (Private Use Area, width 1). */
19
+ const PLACEHOLDER_BASE = 0xe000;
20
+ /** Formulas one paragraph may lay out as images; the rest keep Unicode. */
21
+ export const INLINE_MEDIA_MAX = 0x1000;
22
+ const graphemes = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
23
+ /** The placeholder run standing in for formula `index`, `columns` cells wide. */
24
+ export function inlineMediaPlaceholder(index, columns) {
25
+ if (!Number.isInteger(index) || index < 0 || index >= INLINE_MEDIA_MAX) {
26
+ throw new RangeError(`inline media index out of range: ${index}`);
27
+ }
28
+ return String.fromCodePoint(PLACEHOLDER_BASE + index).repeat(Math.max(1, columns));
29
+ }
30
+ /**
31
+ * Wrap `formatted` (ANSI text containing placeholder runs for `columns.length`
32
+ * formulas) to `width` and split every row into text and media pieces.
33
+ * Returns undefined when a formula could not be kept whole on one row — its
34
+ * run was split by a hard wrap (wider than the row) or appears more than once
35
+ * — so the caller keeps the plain text rendering instead.
36
+ */
37
+ export function layoutInlineMedia(formatted, width, columns) {
38
+ if (width < 1)
39
+ return undefined;
40
+ const seen = new Set();
41
+ const rows = [];
42
+ const wrapped = wrapText(formatted, width, 'wrap');
43
+ const continuations = wrapContinuations(stripAnsi(formatted), stripAnsi(wrapped));
44
+ for (const [lineIndex, line] of wrapped.split('\n').entries()) {
45
+ const pieces = [];
46
+ const plain = stripAnsi(line);
47
+ let column = 0;
48
+ let textStart = 0;
49
+ let run;
50
+ const flushText = (end) => {
51
+ if (end <= textStart)
52
+ return;
53
+ const text = sliceAnsi(line, textStart, end);
54
+ pieces.push({ kind: 'text', text, width: end - textStart });
55
+ };
56
+ const closeRun = () => {
57
+ if (run === undefined)
58
+ return true;
59
+ const length = column - run.start;
60
+ if (seen.has(run.index) || length !== columns[run.index])
61
+ return false;
62
+ seen.add(run.index);
63
+ pieces.push({ kind: 'media', index: run.index, columns: length });
64
+ textStart = column;
65
+ run = undefined;
66
+ return true;
67
+ };
68
+ for (const { segment: char } of graphemes.segment(plain)) {
69
+ const code = char.codePointAt(0);
70
+ const index = code - PLACEHOLDER_BASE;
71
+ const isMedia = index >= 0 && index < columns.length;
72
+ if (run !== undefined && (!isMedia || index !== run.index) && !closeRun())
73
+ return undefined;
74
+ if (isMedia && run === undefined) {
75
+ flushText(column);
76
+ run = { index, start: column };
77
+ }
78
+ column += isMedia ? 1 : stringWidth(char);
79
+ }
80
+ if (!closeRun())
81
+ return undefined;
82
+ flushText(column);
83
+ rows.push({ pieces, width: column, continuation: continuations[lineIndex] === true });
84
+ }
85
+ return seen.size === columns.length ? rows : undefined;
86
+ }
87
+ /**
88
+ * For each line of `wrapped`, whether the newline before it was inserted by
89
+ * wrapping (true) or was in `source` (false). wrapAnsi (trim off) only
90
+ * inserts newlines, so walking both plain strings in step finds them.
91
+ */
92
+ function wrapContinuations(source, wrapped) {
93
+ const result = [false];
94
+ let at = 0;
95
+ for (const char of wrapped) {
96
+ if (char === '\n') {
97
+ const inSource = source[at] === '\n';
98
+ result.push(!inSource);
99
+ if (inSource)
100
+ at += 1;
101
+ continue;
102
+ }
103
+ at += char.length;
104
+ }
105
+ return result;
106
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Terminal-cell geometry for a typeset formula. Pure: no rasterization.
3
+ *
4
+ * MathJax reports a formula's size in ex. A formula starts at one base scale
5
+ * tied to the terminal's physical cell height (so every formula reads at the
6
+ * same size, like text), shrinks uniformly only when it would exceed the
7
+ * width or height it may occupy, and is never enlarged. The canvas is padded,
8
+ * never stretched, to a whole number of cells.
9
+ */
10
+ import type { TerminalCellSize } from '../ink/terminal-image.js';
11
+ /** Pixels per ex at the base scale, as a fraction of the cell height. */
12
+ export declare const BASE_EX_TO_CELL_HEIGHT = 0.5;
13
+ /**
14
+ * Display formulas set larger than the body text, like LaTeX (settings
15
+ * `mathImageScale`): at one ex per 0.72 cell heights the glyph strokes get
16
+ * roughly 45% more device pixels, which is what a terminal-drawn ink mask
17
+ * needs to read as clean rather than thin. Inline formulas keep the base
18
+ * scale — their single row of cells clamps the resolution anyway.
19
+ */
20
+ export declare const LARGE_DISPLAY_EX_TO_CELL_HEIGHT = 0.72;
21
+ /** The next step up: about 80% more pixels than the base scale. */
22
+ export declare const XLARGE_DISPLAY_EX_TO_CELL_HEIGHT = 0.9;
23
+ /**
24
+ * Below this fraction of the base scale the formula is unreadable as an
25
+ * image; the caller keeps the Unicode rendering instead of shrinking further.
26
+ */
27
+ export declare const MIN_SCALE_FRACTION = 0.5;
28
+ export interface FormulaSize {
29
+ readonly widthEx: number;
30
+ readonly heightEx: number;
31
+ }
32
+ export interface FormulaConstraints {
33
+ readonly cellSize: TerminalCellSize;
34
+ /** Pixels per ex as a fraction of the cell height; defaults to the base scale. */
35
+ readonly baseExToCellHeight?: number;
36
+ readonly maxColumns: number;
37
+ readonly maxRows: number;
38
+ /** Transparent margin around the ink, in device-independent pixels. */
39
+ readonly bleed: number;
40
+ /** Largest canvas edge and RGBA byte size the raster may use. */
41
+ readonly maxEdge: number;
42
+ readonly maxBytes: number;
43
+ }
44
+ export interface FormulaLayoutPlan {
45
+ readonly columns: number;
46
+ readonly rows: number;
47
+ /** Canvas size in device pixels (cells × cell size × deviceScale). */
48
+ readonly canvasWidth: number;
49
+ readonly canvasHeight: number;
50
+ /** Ink box size in device pixels, centered in the canvas. */
51
+ readonly contentWidth: number;
52
+ readonly contentHeight: number;
53
+ readonly pixelsPerEx: number;
54
+ readonly deviceScale: 1 | 2;
55
+ }
56
+ export type FormulaLayoutFailure = 'invalid-dimensions' | 'too-small' | 'raster-limit';
57
+ export declare function planFormulaLayout(size: FormulaSize, constraints: FormulaConstraints): FormulaLayoutPlan | FormulaLayoutFailure;
58
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/math/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,gBAAgB,E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GAAG,cAAc,CAAA;AAEtF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,WAAW,EACjB,WAAW,EAAE,kBAAkB,GAC9B,iBAAiB,GAAG,oBAAoB,CA6C1C"}
@@ -0,0 +1,59 @@
1
+ /** Pixels per ex at the base scale, as a fraction of the cell height. */
2
+ export const BASE_EX_TO_CELL_HEIGHT = 0.5;
3
+ /**
4
+ * Display formulas set larger than the body text, like LaTeX (settings
5
+ * `mathImageScale`): at one ex per 0.72 cell heights the glyph strokes get
6
+ * roughly 45% more device pixels, which is what a terminal-drawn ink mask
7
+ * needs to read as clean rather than thin. Inline formulas keep the base
8
+ * scale — their single row of cells clamps the resolution anyway.
9
+ */
10
+ export const LARGE_DISPLAY_EX_TO_CELL_HEIGHT = 0.72;
11
+ /** The next step up: about 80% more pixels than the base scale. */
12
+ export const XLARGE_DISPLAY_EX_TO_CELL_HEIGHT = 0.9;
13
+ /**
14
+ * Below this fraction of the base scale the formula is unreadable as an
15
+ * image; the caller keeps the Unicode rendering instead of shrinking further.
16
+ */
17
+ export const MIN_SCALE_FRACTION = 0.5;
18
+ export function planFormulaLayout(size, constraints) {
19
+ const { cellSize, maxColumns, maxRows, bleed } = constraints;
20
+ if (!(size.widthEx > 0) || !(size.heightEx > 0) ||
21
+ !Number.isFinite(size.widthEx) || !Number.isFinite(size.heightEx) ||
22
+ maxColumns < 1 || maxRows < 1) {
23
+ return 'invalid-dimensions';
24
+ }
25
+ const basePixelsPerEx = cellSize.height * (constraints.baseExToCellHeight ?? BASE_EX_TO_CELL_HEIGHT);
26
+ const availableWidth = maxColumns * cellSize.width - bleed * 2;
27
+ const availableHeight = maxRows * cellSize.height - bleed * 2;
28
+ if (availableWidth <= 0 || availableHeight <= 0)
29
+ return 'too-small';
30
+ const pixelsPerEx = Math.min(basePixelsPerEx, availableWidth / size.widthEx, availableHeight / size.heightEx);
31
+ // Legibility is absolute, not relative to what the caller asked for: the
32
+ // floor stays on the base scale so a larger display request shrinks back to
33
+ // a readable size instead of flipping formulas to the Unicode fallback.
34
+ if (pixelsPerEx < cellSize.height * BASE_EX_TO_CELL_HEIGHT * MIN_SCALE_FRACTION)
35
+ return 'too-small';
36
+ const contentWidth = size.widthEx * pixelsPerEx;
37
+ const contentHeight = size.heightEx * pixelsPerEx;
38
+ const columns = Math.min(maxColumns, Math.ceil((contentWidth + bleed * 2) / cellSize.width));
39
+ const rows = Math.min(maxRows, Math.ceil((contentHeight + bleed * 2) / cellSize.height));
40
+ const fits = (scale) => {
41
+ const width = columns * cellSize.width * scale;
42
+ const height = rows * cellSize.height * scale;
43
+ return width <= constraints.maxEdge && height <= constraints.maxEdge &&
44
+ width * height * 4 <= constraints.maxBytes;
45
+ };
46
+ const deviceScale = fits(2) ? 2 : fits(1) ? 1 : undefined;
47
+ if (deviceScale === undefined)
48
+ return 'raster-limit';
49
+ return {
50
+ columns,
51
+ rows,
52
+ canvasWidth: columns * cellSize.width * deviceScale,
53
+ canvasHeight: rows * cellSize.height * deviceScale,
54
+ contentWidth: contentWidth * deviceScale,
55
+ contentHeight: contentHeight * deviceScale,
56
+ pixelsPerEx: pixelsPerEx * deviceScale,
57
+ deviceScale,
58
+ };
59
+ }
@@ -0,0 +1,64 @@
1
+ import { type TerminalCellSize, type TerminalImageSource } from '../ink/terminal-image.js';
2
+ /** Same budget as the Unicode renderer: longer input is a paste, not math. */
3
+ export declare const MATH_SOURCE_LIMIT = 4096;
4
+ export type MathFailureCode = 'empty' | 'input-too-long' | 'tex-error' | 'invalid-dimensions' | 'too-small' | 'raster-limit' | 'empty-raster' | 'clipped-raster' | 'backend-unavailable';
5
+ export interface MathRenderRequest {
6
+ /** TeX without delimiters. */
7
+ readonly tex: string;
8
+ readonly display: boolean;
9
+ /** Ink color as `#rrggbb` (the theme's text color). */
10
+ readonly color: string;
11
+ readonly cellSize: TerminalCellSize;
12
+ /** Largest cell box the formula may occupy; it shrinks to fit, never grows. */
13
+ readonly maxColumns: number;
14
+ readonly maxRows: number;
15
+ /**
16
+ * Pixels per ex as a fraction of the cell height. Display formulas pass
17
+ * {@link DISPLAY_EX_TO_CELL_HEIGHT} so they are set larger than the body
18
+ * text; inline formulas keep the base scale.
19
+ */
20
+ readonly baseExToCellHeight?: number;
21
+ }
22
+ export interface MathRaster {
23
+ /** Stable identity of this raster (formula, color, geometry). */
24
+ readonly key: string;
25
+ readonly source: TerminalImageSource;
26
+ readonly columns: number;
27
+ readonly rows: number;
28
+ /** Half-open pixel box of visible ink inside the canvas. */
29
+ readonly inkBounds: {
30
+ readonly left: number;
31
+ readonly top: number;
32
+ readonly right: number;
33
+ readonly bottom: number;
34
+ };
35
+ }
36
+ export type MathRenderResult = {
37
+ readonly ok: true;
38
+ readonly raster: MathRaster;
39
+ } | {
40
+ readonly ok: false;
41
+ readonly failure: MathFailureCode;
42
+ };
43
+ /** Cache counters, for tests and debug output. */
44
+ export declare const mathRenderStats: {
45
+ vectorHits: number;
46
+ vectorMisses: number;
47
+ rasterHits: number;
48
+ rasterMisses: number;
49
+ };
50
+ /**
51
+ * The settled result for this request if one is cached, without rendering.
52
+ * Lets a remounted view (scrolled back into the viewport) paint its image on
53
+ * the first frame instead of flashing the Unicode fallback.
54
+ */
55
+ export declare function peekMathRaster(request: MathRenderRequest): MathRenderResult | undefined;
56
+ /**
57
+ * Typeset and rasterize one formula. Results (including failures) are cached
58
+ * by formula, color and geometry; concurrent requests for the same key share
59
+ * one render.
60
+ */
61
+ export declare function renderMathRaster(request: MathRenderRequest): Promise<MathRenderResult>;
62
+ /** Drop every cached vector and raster (tests; a future debug command). */
63
+ export declare function clearMathRenderCaches(): void;
64
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/math/renderer.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAA;AAGjC,8EAA8E;AAC9E,eAAO,MAAM,iBA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