@linghun/tui 0.1.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 (692) hide show
  1. package/LICENSE +190 -0
  2. package/dist/agent-completion-finalizer.d.ts +31 -0
  3. package/dist/agent-completion-finalizer.d.ts.map +1 -0
  4. package/dist/agent-completion-finalizer.js +20 -0
  5. package/dist/agent-handoff-safety.d.ts +13 -0
  6. package/dist/agent-handoff-safety.d.ts.map +1 -0
  7. package/dist/agent-handoff-safety.js +43 -0
  8. package/dist/agent-workflow-registry.d.ts +45 -0
  9. package/dist/agent-workflow-registry.d.ts.map +1 -0
  10. package/dist/agent-workflow-registry.js +12 -0
  11. package/dist/architecture-boundary.d.ts +151 -0
  12. package/dist/architecture-boundary.d.ts.map +1 -0
  13. package/dist/architecture-boundary.js +24 -0
  14. package/dist/architecture-runtime.d.ts +56 -0
  15. package/dist/architecture-runtime.d.ts.map +1 -0
  16. package/dist/architecture-runtime.js +18 -0
  17. package/dist/background-control-runtime.d.ts +29 -0
  18. package/dist/background-control-runtime.d.ts.map +1 -0
  19. package/dist/background-control-runtime.js +148 -0
  20. package/dist/bash-subcommand-parser.d.ts +34 -0
  21. package/dist/bash-subcommand-parser.d.ts.map +1 -0
  22. package/dist/bash-subcommand-parser.js +8 -0
  23. package/dist/batch-tool-confirmation.d.ts +18 -0
  24. package/dist/batch-tool-confirmation.d.ts.map +1 -0
  25. package/dist/batch-tool-confirmation.js +100 -0
  26. package/dist/break-cache-runtime.d.ts +40 -0
  27. package/dist/break-cache-runtime.d.ts.map +1 -0
  28. package/dist/break-cache-runtime.js +17 -0
  29. package/dist/btw-runtime.d.ts +45 -0
  30. package/dist/btw-runtime.d.ts.map +1 -0
  31. package/dist/btw-runtime.js +14 -0
  32. package/dist/cache-command-runtime.d.ts +22 -0
  33. package/dist/cache-command-runtime.d.ts.map +1 -0
  34. package/dist/cache-command-runtime.js +33 -0
  35. package/dist/cache-freshness.d.ts +26 -0
  36. package/dist/cache-freshness.d.ts.map +1 -0
  37. package/dist/cache-freshness.js +14 -0
  38. package/dist/capability-runtime.d.ts +75 -0
  39. package/dist/capability-runtime.d.ts.map +1 -0
  40. package/dist/capability-runtime.js +97 -0
  41. package/dist/chunk-2FVEKTKN.js +86 -0
  42. package/dist/chunk-2YL5VKJ5.js +531 -0
  43. package/dist/chunk-3AKXDMVS.js +85 -0
  44. package/dist/chunk-3GCIXKCI.js +221 -0
  45. package/dist/chunk-3LT6OWQ2.js +258 -0
  46. package/dist/chunk-3XNUDLOM.js +91 -0
  47. package/dist/chunk-4EIC5BCT.js +475 -0
  48. package/dist/chunk-4EP3TUFF.js +238 -0
  49. package/dist/chunk-4I2NWBOM.js +117 -0
  50. package/dist/chunk-4K6UB524.js +443 -0
  51. package/dist/chunk-4T5DJW54.js +88 -0
  52. package/dist/chunk-4WHZ6JKD.js +8105 -0
  53. package/dist/chunk-5H7RRF7C.js +6 -0
  54. package/dist/chunk-64MJP6FK.js +558 -0
  55. package/dist/chunk-66BNE332.js +1617 -0
  56. package/dist/chunk-6CI6TKLN.js +50 -0
  57. package/dist/chunk-6RJVTUWI.js +16 -0
  58. package/dist/chunk-6SMM5CMP.js +100 -0
  59. package/dist/chunk-6USL33ZO.js +289 -0
  60. package/dist/chunk-7ZE5JFAZ.js +760 -0
  61. package/dist/chunk-AKPXMCVF.js +1373 -0
  62. package/dist/chunk-AO4CXI37.js +284 -0
  63. package/dist/chunk-APJIC2O5.js +150 -0
  64. package/dist/chunk-B4GQTZMT.js +607 -0
  65. package/dist/chunk-BFVPLGAC.js +93 -0
  66. package/dist/chunk-BOV4K7FP.js +588 -0
  67. package/dist/chunk-CFMSB6ST.js +59 -0
  68. package/dist/chunk-CFXB5SE5.js +502 -0
  69. package/dist/chunk-CRQORMFF.js +32 -0
  70. package/dist/chunk-CRSLDQOA.js +146 -0
  71. package/dist/chunk-CRW3636S.js +214 -0
  72. package/dist/chunk-D3UTL2QX.js +86 -0
  73. package/dist/chunk-D7TCSOAZ.js +331 -0
  74. package/dist/chunk-DDXS2RDZ.js +228 -0
  75. package/dist/chunk-DICVLZHH.js +144 -0
  76. package/dist/chunk-DNQN74CC.js +1186 -0
  77. package/dist/chunk-DTK5NBTV.js +912 -0
  78. package/dist/chunk-E72U7WW7.js +50 -0
  79. package/dist/chunk-EBACIBJP.js +356 -0
  80. package/dist/chunk-ECFLCY5V.js +530 -0
  81. package/dist/chunk-EORRZP3F.js +109 -0
  82. package/dist/chunk-F43AMWLZ.js +115 -0
  83. package/dist/chunk-F46N43MG.js +56 -0
  84. package/dist/chunk-F6TVBCZV.js +51 -0
  85. package/dist/chunk-FRIMDSRU.js +242 -0
  86. package/dist/chunk-FTAEPAVY.js +314 -0
  87. package/dist/chunk-GC55DMZV.js +156 -0
  88. package/dist/chunk-GCMH5P4W.js +422 -0
  89. package/dist/chunk-GDQQNPBP.js +251 -0
  90. package/dist/chunk-GKZYTPN2.js +279 -0
  91. package/dist/chunk-GLWTWEGX.js +272 -0
  92. package/dist/chunk-GMUCSNUD.js +586 -0
  93. package/dist/chunk-GTP2KPLY.js +167 -0
  94. package/dist/chunk-GW5YDCRZ.js +42 -0
  95. package/dist/chunk-H3T4EF5F.js +87 -0
  96. package/dist/chunk-HAEU6OTS.js +381 -0
  97. package/dist/chunk-HQIJGQYU.js +172 -0
  98. package/dist/chunk-HW2TBXVK.js +34 -0
  99. package/dist/chunk-HWD22O6F.js +94 -0
  100. package/dist/chunk-I3NTAIMF.js +280 -0
  101. package/dist/chunk-IN42UISW.js +372 -0
  102. package/dist/chunk-IWUIOLMF.js +82 -0
  103. package/dist/chunk-J7ZE2JKP.js +283 -0
  104. package/dist/chunk-JBLVBO3U.js +109 -0
  105. package/dist/chunk-JDWXC2OQ.js +800 -0
  106. package/dist/chunk-JGDIO2NF.js +74 -0
  107. package/dist/chunk-JHGWGH2C.js +182 -0
  108. package/dist/chunk-JLCPHVBN.js +42 -0
  109. package/dist/chunk-JO5ANTMR.js +6027 -0
  110. package/dist/chunk-JPXSFZFC.js +100 -0
  111. package/dist/chunk-JQCRCDOC.js +1195 -0
  112. package/dist/chunk-K4FSYBSY.js +41 -0
  113. package/dist/chunk-K56D3X7S.js +1225 -0
  114. package/dist/chunk-KI7C6ZOD.js +92 -0
  115. package/dist/chunk-KO64OFSG.js +58 -0
  116. package/dist/chunk-KQJHVJZB.js +227 -0
  117. package/dist/chunk-KTWV5JC5.js +59 -0
  118. package/dist/chunk-L4XXW6Y5.js +374 -0
  119. package/dist/chunk-L5GOCMZP.js +18 -0
  120. package/dist/chunk-LDABZV5V.js +278 -0
  121. package/dist/chunk-LHHKPGLX.js +903 -0
  122. package/dist/chunk-LL7LBRDL.js +60 -0
  123. package/dist/chunk-LQTVYUT3.js +421 -0
  124. package/dist/chunk-LVIM2PA7.js +663 -0
  125. package/dist/chunk-M4AIK2SP.js +215 -0
  126. package/dist/chunk-MLUIOBKL.js +420 -0
  127. package/dist/chunk-MOJL4X4L.js +47 -0
  128. package/dist/chunk-MVONSJEN.js +300 -0
  129. package/dist/chunk-N7G2X2LK.js +709 -0
  130. package/dist/chunk-NKFKOEYX.js +146 -0
  131. package/dist/chunk-NMNOAFFT.js +167 -0
  132. package/dist/chunk-NSIKYD3X.js +74 -0
  133. package/dist/chunk-O7EFPSMC.js +60 -0
  134. package/dist/chunk-O7S3HYE6.js +210 -0
  135. package/dist/chunk-OEYW3JE3.js +262 -0
  136. package/dist/chunk-OF3K3CU5.js +159 -0
  137. package/dist/chunk-OMZYPQVA.js +298 -0
  138. package/dist/chunk-OZMX3E35.js +248 -0
  139. package/dist/chunk-P277M7Z5.js +303 -0
  140. package/dist/chunk-P4CPRJLI.js +65 -0
  141. package/dist/chunk-PBIPV4LD.js +494 -0
  142. package/dist/chunk-PGNALDEH.js +2003 -0
  143. package/dist/chunk-PGWW3DVE.js +157 -0
  144. package/dist/chunk-QB4VWH7W.js +515 -0
  145. package/dist/chunk-QBCGAIU7.js +120 -0
  146. package/dist/chunk-QIU3FJPC.js +99 -0
  147. package/dist/chunk-QLRTQHTR.js +744 -0
  148. package/dist/chunk-QTDGRZMZ.js +171 -0
  149. package/dist/chunk-RBOQJFIZ.js +183 -0
  150. package/dist/chunk-RDGM4RUE.js +178 -0
  151. package/dist/chunk-RM5JDRCW.js +71 -0
  152. package/dist/chunk-RM5QMOFY.js +189 -0
  153. package/dist/chunk-RMLTVKOY.js +588 -0
  154. package/dist/chunk-RVY34HK4.js +79 -0
  155. package/dist/chunk-S3YWTBXL.js +43 -0
  156. package/dist/chunk-SJOS5PM6.js +64 -0
  157. package/dist/chunk-SOPYWTFV.js +90 -0
  158. package/dist/chunk-SQIBPLLV.js +15 -0
  159. package/dist/chunk-SRZIA6B4.js +136 -0
  160. package/dist/chunk-SYBNJZEL.js +250 -0
  161. package/dist/chunk-TFZEFIQT.js +17 -0
  162. package/dist/chunk-THZBFYAH.js +136 -0
  163. package/dist/chunk-TJLC3QAS.js +83 -0
  164. package/dist/chunk-TYF4GJR3.js +598 -0
  165. package/dist/chunk-UDQT5CWK.js +252 -0
  166. package/dist/chunk-UOHZQIVL.js +168 -0
  167. package/dist/chunk-URNQUECO.js +187 -0
  168. package/dist/chunk-UT2TYK2A.js +148 -0
  169. package/dist/chunk-UT5BOJKU.js +190 -0
  170. package/dist/chunk-V7GDHHBL.js +526 -0
  171. package/dist/chunk-VCSRBS47.js +133 -0
  172. package/dist/chunk-VIBENDE3.js +152 -0
  173. package/dist/chunk-VTQL23UM.js +302 -0
  174. package/dist/chunk-W3KHJNSH.js +281 -0
  175. package/dist/chunk-W6NU7ZAV.js +52 -0
  176. package/dist/chunk-WHFDDZHY.js +407 -0
  177. package/dist/chunk-WJWYRBWH.js +48 -0
  178. package/dist/chunk-WKMBK5UP.js +145 -0
  179. package/dist/chunk-WQMSRO4D.js +489 -0
  180. package/dist/chunk-WV6YJGZR.js +81 -0
  181. package/dist/chunk-WVAQYKGL.js +269 -0
  182. package/dist/chunk-X7A22JHP.js +106 -0
  183. package/dist/chunk-XFPNU42I.js +59 -0
  184. package/dist/chunk-YH6UIHNF.js +161 -0
  185. package/dist/chunk-YPQFSFYK.js +19 -0
  186. package/dist/chunk-YTQFOZRZ.js +110 -0
  187. package/dist/chunk-ZJK25VFP.js +506 -0
  188. package/dist/chunk-ZOSK2UEU.js +1555 -0
  189. package/dist/chunk-ZYSN7AWW.js +336 -0
  190. package/dist/chunk-ZZ2CNCXJ.js +282 -0
  191. package/dist/command-panel-runtime.d.ts +33 -0
  192. package/dist/command-panel-runtime.d.ts.map +1 -0
  193. package/dist/command-panel-runtime.js +80 -0
  194. package/dist/compact-cache-command-runtime.d.ts +38 -0
  195. package/dist/compact-cache-command-runtime.d.ts.map +1 -0
  196. package/dist/compact-cache-command-runtime.js +146 -0
  197. package/dist/compact-context.d.ts +35 -0
  198. package/dist/compact-context.d.ts.map +1 -0
  199. package/dist/compact-context.js +16 -0
  200. package/dist/compact-preflight-runtime.d.ts +46 -0
  201. package/dist/compact-preflight-runtime.d.ts.map +1 -0
  202. package/dist/compact-preflight-runtime.js +62 -0
  203. package/dist/connector-runtime.d.ts +72 -0
  204. package/dist/connector-runtime.d.ts.map +1 -0
  205. package/dist/connector-runtime.js +88 -0
  206. package/dist/context-estimator.d.ts +20 -0
  207. package/dist/context-estimator.d.ts.map +1 -0
  208. package/dist/context-estimator.js +18 -0
  209. package/dist/context-window-runtime.d.ts +12 -0
  210. package/dist/context-window-runtime.d.ts.map +1 -0
  211. package/dist/context-window-runtime.js +10 -0
  212. package/dist/deep-compact-runtime.d.ts +53 -0
  213. package/dist/deep-compact-runtime.d.ts.map +1 -0
  214. package/dist/deep-compact-runtime.js +35 -0
  215. package/dist/deferred-tools-catalog.d.ts +52 -0
  216. package/dist/deferred-tools-catalog.d.ts.map +1 -0
  217. package/dist/deferred-tools-catalog.js +42 -0
  218. package/dist/details-status-runtime.d.ts +48 -0
  219. package/dist/details-status-runtime.d.ts.map +1 -0
  220. package/dist/details-status-runtime.js +102 -0
  221. package/dist/evidence-runtime.d.ts +48 -0
  222. package/dist/evidence-runtime.d.ts.map +1 -0
  223. package/dist/evidence-runtime.js +92 -0
  224. package/dist/extension-command-runtime.d.ts +63 -0
  225. package/dist/extension-command-runtime.d.ts.map +1 -0
  226. package/dist/extension-command-runtime.js +67 -0
  227. package/dist/extension-slash-runtime.d.ts +11 -0
  228. package/dist/extension-slash-runtime.d.ts.map +1 -0
  229. package/dist/extension-slash-runtime.js +79 -0
  230. package/dist/external-editor-runtime.d.ts +32 -0
  231. package/dist/external-editor-runtime.d.ts.map +1 -0
  232. package/dist/external-editor-runtime.js +71 -0
  233. package/dist/failure-learning-command-runtime.d.ts +10 -0
  234. package/dist/failure-learning-command-runtime.d.ts.map +1 -0
  235. package/dist/failure-learning-command-runtime.js +78 -0
  236. package/dist/failure-learning-presenter.d.ts +6 -0
  237. package/dist/failure-learning-presenter.d.ts.map +1 -0
  238. package/dist/failure-learning-presenter.js +12 -0
  239. package/dist/failure-learning-runtime.d.ts +39 -0
  240. package/dist/failure-learning-runtime.d.ts.map +1 -0
  241. package/dist/failure-learning-runtime.js +39 -0
  242. package/dist/feature-flag-runtime.d.ts +8 -0
  243. package/dist/feature-flag-runtime.d.ts.map +1 -0
  244. package/dist/feature-flag-runtime.js +12 -0
  245. package/dist/feishu-long-connection-runtime.d.ts +12 -0
  246. package/dist/feishu-long-connection-runtime.d.ts.map +1 -0
  247. package/dist/feishu-long-connection-runtime.js +7 -0
  248. package/dist/final-answer-gate.d.ts +24 -0
  249. package/dist/final-answer-gate.d.ts.map +1 -0
  250. package/dist/final-answer-gate.js +26 -0
  251. package/dist/ghost-text.d.ts +16 -0
  252. package/dist/ghost-text.d.ts.map +1 -0
  253. package/dist/ghost-text.js +8 -0
  254. package/dist/git-branch-runtime.d.ts +14 -0
  255. package/dist/git-branch-runtime.d.ts.map +1 -0
  256. package/dist/git-branch-runtime.js +68 -0
  257. package/dist/git-command-runtime.d.ts +22 -0
  258. package/dist/git-command-runtime.d.ts.map +1 -0
  259. package/dist/git-command-runtime.js +89 -0
  260. package/dist/git-operation-runtime.d.ts +188 -0
  261. package/dist/git-operation-runtime.d.ts.map +1 -0
  262. package/dist/git-operation-runtime.js +45 -0
  263. package/dist/git-runtime.d.ts +113 -0
  264. package/dist/git-runtime.d.ts.map +1 -0
  265. package/dist/git-runtime.js +16 -0
  266. package/dist/git-slash-runtime.d.ts +38 -0
  267. package/dist/git-slash-runtime.d.ts.map +1 -0
  268. package/dist/git-slash-runtime.js +18 -0
  269. package/dist/git-tool-dispatch-runtime.d.ts +108 -0
  270. package/dist/git-tool-dispatch-runtime.d.ts.map +1 -0
  271. package/dist/git-tool-dispatch-runtime.js +25 -0
  272. package/dist/git-tool-runtime.d.ts +64 -0
  273. package/dist/git-tool-runtime.d.ts.map +1 -0
  274. package/dist/git-tool-runtime.js +36 -0
  275. package/dist/guard-wiring.d.ts +67 -0
  276. package/dist/guard-wiring.d.ts.map +1 -0
  277. package/dist/guard-wiring.js +21 -0
  278. package/dist/handoff-session-runtime.d.ts +11 -0
  279. package/dist/handoff-session-runtime.d.ts.map +1 -0
  280. package/dist/handoff-session-runtime.js +36 -0
  281. package/dist/index-result-presenter.d.ts +14 -0
  282. package/dist/index-result-presenter.d.ts.map +1 -0
  283. package/dist/index-result-presenter.js +28 -0
  284. package/dist/index-runtime.d.ts +64 -0
  285. package/dist/index-runtime.d.ts.map +1 -0
  286. package/dist/index-runtime.js +28 -0
  287. package/dist/index-tool-runtime.d.ts +44 -0
  288. package/dist/index-tool-runtime.d.ts.map +1 -0
  289. package/dist/index-tool-runtime.js +24 -0
  290. package/dist/index.d.ts +57 -0
  291. package/dist/index.d.ts.map +1 -0
  292. package/dist/index.js +2346 -0
  293. package/dist/job-agent-command-runtime.d.ts +127 -0
  294. package/dist/job-agent-command-runtime.d.ts.map +1 -0
  295. package/dist/job-agent-command-runtime.js +138 -0
  296. package/dist/job-runner-presenter.d.ts +32 -0
  297. package/dist/job-runner-presenter.d.ts.map +1 -0
  298. package/dist/job-runner-presenter.js +30 -0
  299. package/dist/job-runtime.d.ts +65 -0
  300. package/dist/job-runtime.d.ts.map +1 -0
  301. package/dist/job-runtime.js +88 -0
  302. package/dist/keybinding-runtime.d.ts +29 -0
  303. package/dist/keybinding-runtime.d.ts.map +1 -0
  304. package/dist/keybinding-runtime.js +14 -0
  305. package/dist/log-artifact.d.ts +55 -0
  306. package/dist/log-artifact.d.ts.map +1 -0
  307. package/dist/log-artifact.js +10 -0
  308. package/dist/mcp-index-command-runtime.d.ts +21 -0
  309. package/dist/mcp-index-command-runtime.d.ts.map +1 -0
  310. package/dist/mcp-index-command-runtime.js +18 -0
  311. package/dist/mcp-index-runtime.d.ts +106 -0
  312. package/dist/mcp-index-runtime.d.ts.map +1 -0
  313. package/dist/mcp-index-runtime.js +142 -0
  314. package/dist/mcp-sse-runtime.d.ts +13 -0
  315. package/dist/mcp-sse-runtime.d.ts.map +1 -0
  316. package/dist/mcp-sse-runtime.js +8 -0
  317. package/dist/mcp-stdio-runtime.d.ts +37 -0
  318. package/dist/mcp-stdio-runtime.d.ts.map +1 -0
  319. package/dist/mcp-stdio-runtime.js +15 -0
  320. package/dist/memory-command-runtime.d.ts +37 -0
  321. package/dist/memory-command-runtime.d.ts.map +1 -0
  322. package/dist/memory-command-runtime.js +88 -0
  323. package/dist/memory-eviction-runtime.d.ts +7 -0
  324. package/dist/memory-eviction-runtime.d.ts.map +1 -0
  325. package/dist/memory-eviction-runtime.js +12 -0
  326. package/dist/memory-extraction-runtime.d.ts +40 -0
  327. package/dist/memory-extraction-runtime.d.ts.map +1 -0
  328. package/dist/memory-extraction-runtime.js +20 -0
  329. package/dist/memory-rules-runtime.d.ts +15 -0
  330. package/dist/memory-rules-runtime.d.ts.map +1 -0
  331. package/dist/memory-rules-runtime.js +14 -0
  332. package/dist/meta-scheduler-complexity.d.ts +16 -0
  333. package/dist/meta-scheduler-complexity.d.ts.map +1 -0
  334. package/dist/meta-scheduler-complexity.js +37 -0
  335. package/dist/meta-scheduler-runtime.d.ts +288 -0
  336. package/dist/meta-scheduler-runtime.d.ts.map +1 -0
  337. package/dist/meta-scheduler-runtime.js +17 -0
  338. package/dist/model-command-runtime.d.ts +12 -0
  339. package/dist/model-command-runtime.d.ts.map +1 -0
  340. package/dist/model-command-runtime.js +84 -0
  341. package/dist/model-doctor-runtime.d.ts +81 -0
  342. package/dist/model-doctor-runtime.d.ts.map +1 -0
  343. package/dist/model-doctor-runtime.js +46 -0
  344. package/dist/model-loop-runtime.d.ts +189 -0
  345. package/dist/model-loop-runtime.d.ts.map +1 -0
  346. package/dist/model-loop-runtime.js +141 -0
  347. package/dist/model-prompt-runtime.d.ts +25 -0
  348. package/dist/model-prompt-runtime.d.ts.map +1 -0
  349. package/dist/model-prompt-runtime.js +33 -0
  350. package/dist/model-setup-runtime.d.ts +28 -0
  351. package/dist/model-setup-runtime.d.ts.map +1 -0
  352. package/dist/model-setup-runtime.js +26 -0
  353. package/dist/model-stream-runtime.d.ts +47 -0
  354. package/dist/model-stream-runtime.d.ts.map +1 -0
  355. package/dist/model-stream-runtime.js +136 -0
  356. package/dist/model-tool-runtime.d.ts +114 -0
  357. package/dist/model-tool-runtime.d.ts.map +1 -0
  358. package/dist/model-tool-runtime.js +144 -0
  359. package/dist/natural-command-bridge.d.ts +158 -0
  360. package/dist/natural-command-bridge.d.ts.map +1 -0
  361. package/dist/natural-command-bridge.js +36 -0
  362. package/dist/pending-details-presenter.d.ts +8 -0
  363. package/dist/pending-details-presenter.d.ts.map +1 -0
  364. package/dist/pending-details-presenter.js +12 -0
  365. package/dist/permission-approval-runtime.d.ts +28 -0
  366. package/dist/permission-approval-runtime.d.ts.map +1 -0
  367. package/dist/permission-approval-runtime.js +136 -0
  368. package/dist/permission-continuation-runtime.d.ts +90 -0
  369. package/dist/permission-continuation-runtime.d.ts.map +1 -0
  370. package/dist/permission-continuation-runtime.js +68 -0
  371. package/dist/permission-policy-engine.d.ts +51 -0
  372. package/dist/permission-policy-engine.d.ts.map +1 -0
  373. package/dist/permission-policy-engine.js +12 -0
  374. package/dist/permission-presenter.d.ts +13 -0
  375. package/dist/permission-presenter.d.ts.map +1 -0
  376. package/dist/permission-presenter.js +8 -0
  377. package/dist/persistent-history.d.ts +18 -0
  378. package/dist/persistent-history.d.ts.map +1 -0
  379. package/dist/persistent-history.js +126 -0
  380. package/dist/platform-security.d.ts +4 -0
  381. package/dist/platform-security.d.ts.map +1 -0
  382. package/dist/platform-security.js +10 -0
  383. package/dist/process-command-runtime.d.ts +9 -0
  384. package/dist/process-command-runtime.d.ts.map +1 -0
  385. package/dist/process-command-runtime.js +11 -0
  386. package/dist/process-guard.d.ts +56 -0
  387. package/dist/process-guard.d.ts.map +1 -0
  388. package/dist/process-guard.js +22 -0
  389. package/dist/prompt-command-runtime.d.ts +12 -0
  390. package/dist/prompt-command-runtime.d.ts.map +1 -0
  391. package/dist/prompt-command-runtime.js +10 -0
  392. package/dist/prompt-stash.d.ts +15 -0
  393. package/dist/prompt-stash.d.ts.map +1 -0
  394. package/dist/prompt-stash.js +8 -0
  395. package/dist/provider-circuit-breaker.d.ts +132 -0
  396. package/dist/provider-circuit-breaker.d.ts.map +1 -0
  397. package/dist/provider-circuit-breaker.js +31 -0
  398. package/dist/provider-loop-runtime.d.ts +18 -0
  399. package/dist/provider-loop-runtime.d.ts.map +1 -0
  400. package/dist/provider-loop-runtime.js +16 -0
  401. package/dist/remote-command-runtime.d.ts +47 -0
  402. package/dist/remote-command-runtime.d.ts.map +1 -0
  403. package/dist/remote-command-runtime.js +125 -0
  404. package/dist/remote-inbound-bridge-runtime.d.ts +152 -0
  405. package/dist/remote-inbound-bridge-runtime.d.ts.map +1 -0
  406. package/dist/remote-inbound-bridge-runtime.js +44 -0
  407. package/dist/remote-mcp-presenter.d.ts +5 -0
  408. package/dist/remote-mcp-presenter.d.ts.map +1 -0
  409. package/dist/remote-mcp-presenter.js +10 -0
  410. package/dist/remote-repl-bridge-runtime.d.ts +134 -0
  411. package/dist/remote-repl-bridge-runtime.d.ts.map +1 -0
  412. package/dist/remote-repl-bridge-runtime.js +20 -0
  413. package/dist/remote-transport.d.ts +50 -0
  414. package/dist/remote-transport.d.ts.map +1 -0
  415. package/dist/remote-transport.js +14 -0
  416. package/dist/request-lifecycle-presenter.d.ts +25 -0
  417. package/dist/request-lifecycle-presenter.d.ts.map +1 -0
  418. package/dist/request-lifecycle-presenter.js +22 -0
  419. package/dist/runner-runtime.d.ts +41 -0
  420. package/dist/runner-runtime.d.ts.map +1 -0
  421. package/dist/runner-runtime.js +35 -0
  422. package/dist/runtime-budget.d.ts +38 -0
  423. package/dist/runtime-budget.d.ts.map +1 -0
  424. package/dist/runtime-budget.js +78 -0
  425. package/dist/runtime-path-marker.d.ts +112 -0
  426. package/dist/runtime-path-marker.d.ts.map +1 -0
  427. package/dist/runtime-path-marker.js +18 -0
  428. package/dist/runtime-status-presenter.d.ts +22 -0
  429. package/dist/runtime-status-presenter.d.ts.map +1 -0
  430. package/dist/runtime-status-presenter.js +15 -0
  431. package/dist/runtime-status-snapshot.d.ts +52 -0
  432. package/dist/runtime-status-snapshot.d.ts.map +1 -0
  433. package/dist/runtime-status-snapshot.js +11 -0
  434. package/dist/runtime-utils.d.ts +2 -0
  435. package/dist/runtime-utils.d.ts.map +1 -0
  436. package/dist/runtime-utils.js +6 -0
  437. package/dist/shell/clipboard.d.ts +23 -0
  438. package/dist/shell/clipboard.d.ts.map +1 -0
  439. package/dist/shell/clipboard.js +8 -0
  440. package/dist/shell/components/AgentProgressTree.d.ts +9 -0
  441. package/dist/shell/components/AgentProgressTree.d.ts.map +1 -0
  442. package/dist/shell/components/AgentProgressTree.js +9 -0
  443. package/dist/shell/components/BackgroundTaskOverlay.d.ts +8 -0
  444. package/dist/shell/components/BackgroundTaskOverlay.d.ts.map +1 -0
  445. package/dist/shell/components/BackgroundTaskOverlay.js +8 -0
  446. package/dist/shell/components/BtwPanel.d.ts +16 -0
  447. package/dist/shell/components/BtwPanel.d.ts.map +1 -0
  448. package/dist/shell/components/BtwPanel.js +8 -0
  449. package/dist/shell/components/CommandPanel.d.ts +11 -0
  450. package/dist/shell/components/CommandPanel.d.ts.map +1 -0
  451. package/dist/shell/components/CommandPanel.js +8 -0
  452. package/dist/shell/components/Composer.d.ts +187 -0
  453. package/dist/shell/components/Composer.d.ts.map +1 -0
  454. package/dist/shell/components/Composer.js +99 -0
  455. package/dist/shell/components/ConfigPanel.d.ts +11 -0
  456. package/dist/shell/components/ConfigPanel.d.ts.map +1 -0
  457. package/dist/shell/components/ConfigPanel.js +8 -0
  458. package/dist/shell/components/CtrlOToExpand.d.ts +30 -0
  459. package/dist/shell/components/CtrlOToExpand.d.ts.map +1 -0
  460. package/dist/shell/components/CtrlOToExpand.js +16 -0
  461. package/dist/shell/components/HelpPanel.d.ts +19 -0
  462. package/dist/shell/components/HelpPanel.d.ts.map +1 -0
  463. package/dist/shell/components/HelpPanel.js +8 -0
  464. package/dist/shell/components/HistorySearchPanel.d.ts +14 -0
  465. package/dist/shell/components/HistorySearchPanel.d.ts.map +1 -0
  466. package/dist/shell/components/HistorySearchPanel.js +104 -0
  467. package/dist/shell/components/MessageMarkdown.d.ts +34 -0
  468. package/dist/shell/components/MessageMarkdown.d.ts.map +1 -0
  469. package/dist/shell/components/MessageMarkdown.js +18 -0
  470. package/dist/shell/components/MessageResponse.d.ts +14 -0
  471. package/dist/shell/components/MessageResponse.d.ts.map +1 -0
  472. package/dist/shell/components/MessageResponse.js +6 -0
  473. package/dist/shell/components/MouseInputRouter.d.ts +28 -0
  474. package/dist/shell/components/MouseInputRouter.d.ts.map +1 -0
  475. package/dist/shell/components/MouseInputRouter.js +84 -0
  476. package/dist/shell/components/NotificationStack.d.ts +19 -0
  477. package/dist/shell/components/NotificationStack.d.ts.map +1 -0
  478. package/dist/shell/components/NotificationStack.js +6 -0
  479. package/dist/shell/components/OutputLine.d.ts +19 -0
  480. package/dist/shell/components/OutputLine.d.ts.map +1 -0
  481. package/dist/shell/components/OutputLine.js +38 -0
  482. package/dist/shell/components/ProductBlock.d.ts +10 -0
  483. package/dist/shell/components/ProductBlock.d.ts.map +1 -0
  484. package/dist/shell/components/ProductBlock.js +12 -0
  485. package/dist/shell/components/ScrollViewport.d.ts +43 -0
  486. package/dist/shell/components/ScrollViewport.d.ts.map +1 -0
  487. package/dist/shell/components/ScrollViewport.js +86 -0
  488. package/dist/shell/components/SessionsPanel.d.ts +24 -0
  489. package/dist/shell/components/SessionsPanel.d.ts.map +1 -0
  490. package/dist/shell/components/SessionsPanel.js +8 -0
  491. package/dist/shell/components/ShellApp.d.ts +8 -0
  492. package/dist/shell/components/ShellApp.d.ts.map +1 -0
  493. package/dist/shell/components/ShellApp.js +45 -0
  494. package/dist/shell/components/ShortcutPanel.d.ts +14 -0
  495. package/dist/shell/components/ShortcutPanel.d.ts.map +1 -0
  496. package/dist/shell/components/ShortcutPanel.js +59 -0
  497. package/dist/shell/components/SlashSuggestions.d.ts +24 -0
  498. package/dist/shell/components/SlashSuggestions.d.ts.map +1 -0
  499. package/dist/shell/components/SlashSuggestions.js +7 -0
  500. package/dist/shell/components/StatusFooter.d.ts +30 -0
  501. package/dist/shell/components/StatusFooter.d.ts.map +1 -0
  502. package/dist/shell/components/StatusFooter.js +7 -0
  503. package/dist/shell/components/StatusTray.d.ts +9 -0
  504. package/dist/shell/components/StatusTray.d.ts.map +1 -0
  505. package/dist/shell/components/StatusTray.js +6 -0
  506. package/dist/shell/components/StructuredDiff.d.ts +9 -0
  507. package/dist/shell/components/StructuredDiff.d.ts.map +1 -0
  508. package/dist/shell/components/StructuredDiff.js +7 -0
  509. package/dist/shell/components/TaskListView.d.ts +9 -0
  510. package/dist/shell/components/TaskListView.d.ts.map +1 -0
  511. package/dist/shell/components/TaskListView.js +9 -0
  512. package/dist/shell/components/TaskSuggestionBar.d.ts +15 -0
  513. package/dist/shell/components/TaskSuggestionBar.d.ts.map +1 -0
  514. package/dist/shell/components/TaskSuggestionBar.js +8 -0
  515. package/dist/shell/components/UnseenMessagePill.d.ts +12 -0
  516. package/dist/shell/components/UnseenMessagePill.d.ts.map +1 -0
  517. package/dist/shell/components/UnseenMessagePill.js +6 -0
  518. package/dist/shell/components/WorkflowProgressView.d.ts +9 -0
  519. package/dist/shell/components/WorkflowProgressView.d.ts.map +1 -0
  520. package/dist/shell/components/WorkflowProgressView.js +9 -0
  521. package/dist/shell/components/useAnchoredCursor.d.ts +32 -0
  522. package/dist/shell/components/useAnchoredCursor.d.ts.map +1 -0
  523. package/dist/shell/components/useAnchoredCursor.js +6 -0
  524. package/dist/shell/hooks/useRenderThrottle.d.ts +2 -0
  525. package/dist/shell/hooks/useRenderThrottle.d.ts.map +1 -0
  526. package/dist/shell/hooks/useRenderThrottle.js +35 -0
  527. package/dist/shell/hooks/useScrollBatcher.d.ts +10 -0
  528. package/dist/shell/hooks/useScrollBatcher.d.ts.map +1 -0
  529. package/dist/shell/hooks/useScrollBatcher.js +23 -0
  530. package/dist/shell/hooks/useScrollRuntime.d.ts +2 -0
  531. package/dist/shell/hooks/useScrollRuntime.d.ts.map +1 -0
  532. package/dist/shell/hooks/useScrollRuntime.js +6 -0
  533. package/dist/shell/hyperlink-utils.d.ts +18 -0
  534. package/dist/shell/hyperlink-utils.d.ts.map +1 -0
  535. package/dist/shell/hyperlink-utils.js +8 -0
  536. package/dist/shell/ink-renderer.d.ts +18 -0
  537. package/dist/shell/ink-renderer.d.ts.map +1 -0
  538. package/dist/shell/ink-renderer.js +54 -0
  539. package/dist/shell/models/command-transcript-presenter.d.ts +73 -0
  540. package/dist/shell/models/command-transcript-presenter.d.ts.map +1 -0
  541. package/dist/shell/models/command-transcript-presenter.js +26 -0
  542. package/dist/shell/models/help-panel.d.ts +37 -0
  543. package/dist/shell/models/help-panel.d.ts.map +1 -0
  544. package/dist/shell/models/help-panel.js +10 -0
  545. package/dist/shell/models/permission-elevation.d.ts +65 -0
  546. package/dist/shell/models/permission-elevation.d.ts.map +1 -0
  547. package/dist/shell/models/permission-elevation.js +10 -0
  548. package/dist/shell/models/permission-explanation.d.ts +45 -0
  549. package/dist/shell/models/permission-explanation.d.ts.map +1 -0
  550. package/dist/shell/models/permission-explanation.js +14 -0
  551. package/dist/shell/models/session-panel.d.ts +22 -0
  552. package/dist/shell/models/session-panel.d.ts.map +1 -0
  553. package/dist/shell/models/session-panel.js +18 -0
  554. package/dist/shell/models/task-scroll-state.d.ts +24 -0
  555. package/dist/shell/models/task-scroll-state.d.ts.map +1 -0
  556. package/dist/shell/models/task-scroll-state.js +26 -0
  557. package/dist/shell/models/terminal-input-runtime.d.ts +37 -0
  558. package/dist/shell/models/terminal-input-runtime.d.ts.map +1 -0
  559. package/dist/shell/models/terminal-input-runtime.js +18 -0
  560. package/dist/shell/models/transcript-scroll-state.d.ts +57 -0
  561. package/dist/shell/models/transcript-scroll-state.d.ts.map +1 -0
  562. package/dist/shell/models/transcript-scroll-state.js +12 -0
  563. package/dist/shell/models/transcript-selection-state.d.ts +39 -0
  564. package/dist/shell/models/transcript-selection-state.d.ts.map +1 -0
  565. package/dist/shell/models/transcript-selection-state.js +25 -0
  566. package/dist/shell/models/wheel-acceleration.d.ts +52 -0
  567. package/dist/shell/models/wheel-acceleration.d.ts.map +1 -0
  568. package/dist/shell/models/wheel-acceleration.js +6 -0
  569. package/dist/shell/output-utils.d.ts +22 -0
  570. package/dist/shell/output-utils.d.ts.map +1 -0
  571. package/dist/shell/output-utils.js +12 -0
  572. package/dist/shell/plain-renderer.d.ts +12 -0
  573. package/dist/shell/plain-renderer.d.ts.map +1 -0
  574. package/dist/shell/plain-renderer.js +13 -0
  575. package/dist/shell/progress-views.d.ts +10 -0
  576. package/dist/shell/progress-views.d.ts.map +1 -0
  577. package/dist/shell/progress-views.js +17 -0
  578. package/dist/shell/stdout-flush-barrier.d.ts +39 -0
  579. package/dist/shell/stdout-flush-barrier.d.ts.map +1 -0
  580. package/dist/shell/stdout-flush-barrier.js +10 -0
  581. package/dist/shell/terminal-capability.d.ts +54 -0
  582. package/dist/shell/terminal-capability.d.ts.map +1 -0
  583. package/dist/shell/terminal-capability.js +10 -0
  584. package/dist/shell/terminal-interaction-runtime.d.ts +11 -0
  585. package/dist/shell/terminal-interaction-runtime.d.ts.map +1 -0
  586. package/dist/shell/terminal-interaction-runtime.js +38 -0
  587. package/dist/shell/terminal-state-recovery.d.ts +52 -0
  588. package/dist/shell/terminal-state-recovery.d.ts.map +1 -0
  589. package/dist/shell/terminal-state-recovery.js +11 -0
  590. package/dist/shell/text-utils.d.ts +40 -0
  591. package/dist/shell/text-utils.d.ts.map +1 -0
  592. package/dist/shell/text-utils.js +26 -0
  593. package/dist/shell/theme.d.ts +41 -0
  594. package/dist/shell/theme.d.ts.map +1 -0
  595. package/dist/shell/theme.js +8 -0
  596. package/dist/shell/types.d.ts +784 -0
  597. package/dist/shell/types.d.ts.map +1 -0
  598. package/dist/shell/types.js +0 -0
  599. package/dist/shell/view-model.d.ts +82 -0
  600. package/dist/shell/view-model.d.ts.map +1 -0
  601. package/dist/shell/view-model.js +48 -0
  602. package/dist/slash-command-runtime.d.ts +64 -0
  603. package/dist/slash-command-runtime.d.ts.map +1 -0
  604. package/dist/slash-command-runtime.js +186 -0
  605. package/dist/slash-dispatch.d.ts +48 -0
  606. package/dist/slash-dispatch.d.ts.map +1 -0
  607. package/dist/slash-dispatch.js +53 -0
  608. package/dist/startup-runtime.d.ts +48 -0
  609. package/dist/startup-runtime.d.ts.map +1 -0
  610. package/dist/startup-runtime.js +43 -0
  611. package/dist/terminal-readiness-presenter.d.ts +131 -0
  612. package/dist/terminal-readiness-presenter.d.ts.map +1 -0
  613. package/dist/terminal-readiness-presenter.js +16 -0
  614. package/dist/terminal-readiness-runtime.d.ts +5 -0
  615. package/dist/terminal-readiness-runtime.d.ts.map +1 -0
  616. package/dist/terminal-readiness-runtime.js +15 -0
  617. package/dist/terminal-setup-runtime.d.ts +34 -0
  618. package/dist/terminal-setup-runtime.d.ts.map +1 -0
  619. package/dist/terminal-setup-runtime.js +257 -0
  620. package/dist/tool-output-presenter.d.ts +38 -0
  621. package/dist/tool-output-presenter.d.ts.map +1 -0
  622. package/dist/tool-output-presenter.js +16 -0
  623. package/dist/tool-result-budget.d.ts +42 -0
  624. package/dist/tool-result-budget.d.ts.map +1 -0
  625. package/dist/tool-result-budget.js +11 -0
  626. package/dist/tui-agent-job-runtime.d.ts +38 -0
  627. package/dist/tui-agent-job-runtime.d.ts.map +1 -0
  628. package/dist/tui-agent-job-runtime.js +86 -0
  629. package/dist/tui-context-runtime.d.ts +426 -0
  630. package/dist/tui-context-runtime.d.ts.map +1 -0
  631. package/dist/tui-context-runtime.js +65 -0
  632. package/dist/tui-data-types.d.ts +923 -0
  633. package/dist/tui-data-types.d.ts.map +1 -0
  634. package/dist/tui-data-types.js +0 -0
  635. package/dist/tui-details-runtime.d.ts +25 -0
  636. package/dist/tui-details-runtime.d.ts.map +1 -0
  637. package/dist/tui-details-runtime.js +29 -0
  638. package/dist/tui-memory-runtime.d.ts +33 -0
  639. package/dist/tui-memory-runtime.d.ts.map +1 -0
  640. package/dist/tui-memory-runtime.js +58 -0
  641. package/dist/tui-messages.d.ts +4 -0
  642. package/dist/tui-messages.d.ts.map +1 -0
  643. package/dist/tui-messages.js +6 -0
  644. package/dist/tui-model-runtime.d.ts +30 -0
  645. package/dist/tui-model-runtime.d.ts.map +1 -0
  646. package/dist/tui-model-runtime.js +39 -0
  647. package/dist/tui-output-surface.d.ts +141 -0
  648. package/dist/tui-output-surface.d.ts.map +1 -0
  649. package/dist/tui-output-surface.js +55 -0
  650. package/dist/tui-permission-runtime.d.ts +62 -0
  651. package/dist/tui-permission-runtime.d.ts.map +1 -0
  652. package/dist/tui-permission-runtime.js +24 -0
  653. package/dist/tui-state-runtime.d.ts +21 -0
  654. package/dist/tui-state-runtime.d.ts.map +1 -0
  655. package/dist/tui-state-runtime.js +47 -0
  656. package/dist/turn-continuity-runtime.d.ts +30 -0
  657. package/dist/turn-continuity-runtime.d.ts.map +1 -0
  658. package/dist/turn-continuity-runtime.js +8 -0
  659. package/dist/undo-ring.d.ts +16 -0
  660. package/dist/undo-ring.d.ts.map +1 -0
  661. package/dist/undo-ring.js +12 -0
  662. package/dist/usage-stats-presenter.d.ts +17 -0
  663. package/dist/usage-stats-presenter.d.ts.map +1 -0
  664. package/dist/usage-stats-presenter.js +22 -0
  665. package/dist/user-state-signal-runtime.d.ts +33 -0
  666. package/dist/user-state-signal-runtime.d.ts.map +1 -0
  667. package/dist/user-state-signal-runtime.js +8 -0
  668. package/dist/verification-command-runtime.d.ts +25 -0
  669. package/dist/verification-command-runtime.d.ts.map +1 -0
  670. package/dist/verification-command-runtime.js +51 -0
  671. package/dist/verification-level.d.ts +93 -0
  672. package/dist/verification-level.d.ts.map +1 -0
  673. package/dist/verification-level.js +18 -0
  674. package/dist/workflow-agent-runtime-bridge.d.ts +169 -0
  675. package/dist/workflow-agent-runtime-bridge.d.ts.map +1 -0
  676. package/dist/workflow-agent-runtime-bridge.js +9 -0
  677. package/dist/workflow-command-runtime.d.ts +94 -0
  678. package/dist/workflow-command-runtime.d.ts.map +1 -0
  679. package/dist/workflow-command-runtime.js +114 -0
  680. package/dist/workflow-plan-schema.d.ts +161 -0
  681. package/dist/workflow-plan-schema.d.ts.map +1 -0
  682. package/dist/workflow-plan-schema.js +12 -0
  683. package/dist/workflow-planner-entry.d.ts +52 -0
  684. package/dist/workflow-planner-entry.d.ts.map +1 -0
  685. package/dist/workflow-planner-entry.js +328 -0
  686. package/dist/workflow-task-surface.d.ts +39 -0
  687. package/dist/workflow-task-surface.d.ts.map +1 -0
  688. package/dist/workflow-task-surface.js +7 -0
  689. package/dist/workspace-reference-cache.d.ts +110 -0
  690. package/dist/workspace-reference-cache.d.ts.map +1 -0
  691. package/dist/workspace-reference-cache.js +12 -0
  692. package/package.json +41 -0
@@ -0,0 +1,912 @@
1
+ import {
2
+ StructuredDiff
3
+ } from "./chunk-F43AMWLZ.js";
4
+ import {
5
+ charWidth,
6
+ displayWidth,
7
+ wrapText
8
+ } from "./chunk-APJIC2O5.js";
9
+
10
+ // src/shell/components/MessageMarkdown.tsx
11
+ import { Box, Text } from "@linghun/ink-runtime";
12
+ import { highlight } from "cli-highlight";
13
+ import { lexer } from "marked";
14
+ import { createContext, useContext } from "react";
15
+ import { memo, useRef } from "react";
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ var MessageResponseContext = createContext(false);
18
+ function useInMessageResponse() {
19
+ return useContext(MessageResponseContext);
20
+ }
21
+ function MessageResponseProvider({
22
+ children
23
+ }) {
24
+ return /* @__PURE__ */ jsx(MessageResponseContext.Provider, { value: true, children });
25
+ }
26
+ var INLINE_TOKEN_RE = /(`[^`\n]+`|\*\*[^*\n][^\n]*?\*\*|\*[^*\n][^\n]*?\*|\[[^\]\n]+\]\([^\s)\n]+\))/u;
27
+ var ANSI_REGEX = /\x1B\[[0-9;]*m/gu;
28
+ var TABLE_VERTICAL_FALLBACK_WIDTH = 48;
29
+ var TABLE_MAX_COLUMN_WIDTH = 48;
30
+ var TABLE_MIN_COLUMN_WIDTH = 6;
31
+ var TABLE_MIN_ACCEPTABLE_COLUMN = 8;
32
+ var MARKDOWN_TOKEN_CACHE_LIMIT = 128;
33
+ var markdownTokenCache = /* @__PURE__ */ new Map();
34
+ var codeHighlightCache = /* @__PURE__ */ new Map();
35
+ var GIT_CRLF_WARNING_RE = /^\[stderr\]\s*warning:\s+in the working copy of .+ LF will be replaced by CRLF\b.*$/iu;
36
+ function getCachedMarkdownTokens(text) {
37
+ const cached = markdownTokenCache.get(text);
38
+ if (cached) {
39
+ markdownTokenCache.delete(text);
40
+ markdownTokenCache.set(text, cached);
41
+ return cached;
42
+ }
43
+ const tokens = lexer(text);
44
+ markdownTokenCache.set(text, tokens);
45
+ trimCache(markdownTokenCache);
46
+ return tokens;
47
+ }
48
+ function getCachedHighlightedCodeLines(code, lang) {
49
+ const key = `${lang ?? ""}::${code}`;
50
+ const cached = codeHighlightCache.get(key);
51
+ if (cached) {
52
+ codeHighlightCache.delete(key);
53
+ codeHighlightCache.set(key, cached);
54
+ return cached;
55
+ }
56
+ const lines = highlightedCodeLines(code, lang);
57
+ codeHighlightCache.set(key, lines);
58
+ trimCache(codeHighlightCache);
59
+ return lines;
60
+ }
61
+ function trimCache(cache) {
62
+ while (cache.size > MARKDOWN_TOKEN_CACHE_LIMIT) {
63
+ const first = cache.keys().next().value;
64
+ if (!first) return;
65
+ cache.delete(first);
66
+ }
67
+ }
68
+ function stripLowValueDiagnosticNoise(text) {
69
+ return text.split("\n").filter((line) => !GIT_CRLF_WARNING_RE.test(line.trim())).join("\n");
70
+ }
71
+ function isRawDiffStart(lines, index) {
72
+ const line = lines[index] ?? "";
73
+ const nextLines = lines.slice(index + 1, index + 5);
74
+ if (/^diff --git\s+/u.test(line)) return true;
75
+ if (/^@@\s+-\d/u.test(line)) return true;
76
+ if (/^---\s+\S/u.test(line)) {
77
+ return nextLines.some((next) => /^\+\+\+\s+\S/u.test(next));
78
+ }
79
+ if (/^(?:new file mode|deleted file mode)\s+\d+/u.test(line)) {
80
+ return nextLines.some((next) => /^---\s+\S/u.test(next) || /^\+\+\+\s+\S/u.test(next));
81
+ }
82
+ return false;
83
+ }
84
+ function isRawDiffLine(line) {
85
+ return /^diff --git\s+/u.test(line) || /^(?:index|new file mode|deleted file mode|old mode|new mode)\b/u.test(line) || /^(?:copy from|copy to|rename from|rename to|similarity index|dissimilarity index)\b/u.test(
86
+ line
87
+ ) || /^---\s+\S/u.test(line) || /^\+\+\+\s+\S/u.test(line) || /^@@\s+-\d/u.test(line) || /^[+-]/u.test(line) || /^ /u.test(line) || /^\/u.test(line);
88
+ }
89
+ function isRawDiffBlock(lines) {
90
+ const hasHeaderPair = lines.some((line) => /^---\s+\S/u.test(line)) && lines.some((line) => /^\+\+\+\s+\S/u.test(line));
91
+ const hasHunk = lines.some((line) => /^@@\s+-\d/u.test(line));
92
+ const hasAdd = lines.some((line) => /^\+(?!\+\+)/u.test(line));
93
+ const hasRemove = lines.some((line) => /^-(?!--)/u.test(line));
94
+ return hasHeaderPair || hasHunk || hasAdd && hasRemove;
95
+ }
96
+ function splitRawDiffSections(text) {
97
+ const lines = text.split("\n");
98
+ const segments = [];
99
+ let markdownLines = [];
100
+ let inFence = false;
101
+ let index = 0;
102
+ const flushMarkdown = () => {
103
+ if (markdownLines.length === 0) return;
104
+ segments.push({ kind: "markdown", text: markdownLines.join("\n") });
105
+ markdownLines = [];
106
+ };
107
+ while (index < lines.length) {
108
+ const line = lines[index] ?? "";
109
+ if (/^\s*```\s*[A-Za-z0-9_+-]*\s*$/u.test(line)) {
110
+ inFence = !inFence;
111
+ markdownLines.push(line);
112
+ index += 1;
113
+ continue;
114
+ }
115
+ if (!inFence && isRawDiffStart(lines, index)) {
116
+ const diffLines = [];
117
+ let cursor = index;
118
+ while (cursor < lines.length) {
119
+ const current = lines[cursor] ?? "";
120
+ if (current.trim().length === 0) {
121
+ const next = lines[cursor + 1] ?? "";
122
+ if (isRawDiffLine(next)) {
123
+ diffLines.push(current);
124
+ cursor += 1;
125
+ continue;
126
+ }
127
+ break;
128
+ }
129
+ if (!isRawDiffLine(current)) break;
130
+ diffLines.push(current);
131
+ cursor += 1;
132
+ }
133
+ if (isRawDiffBlock(diffLines)) {
134
+ flushMarkdown();
135
+ segments.push({ kind: "diff", text: diffLines.join("\n") });
136
+ index = cursor;
137
+ continue;
138
+ }
139
+ }
140
+ markdownLines.push(line);
141
+ index += 1;
142
+ }
143
+ flushMarkdown();
144
+ return segments;
145
+ }
146
+ function __testSplitRawDiffSections(text) {
147
+ const normalized = stripLowValueDiagnosticNoise(text.replace(/\r/g, ""));
148
+ return splitRawDiffSections(normalized);
149
+ }
150
+ function tokenizeInline(value) {
151
+ const tokens = [];
152
+ let remaining = value;
153
+ while (remaining.length > 0) {
154
+ const match = remaining.match(INLINE_TOKEN_RE);
155
+ if (!match || match.index === void 0) {
156
+ tokens.push({ kind: "text", value: remaining });
157
+ break;
158
+ }
159
+ if (match.index > 0) {
160
+ tokens.push({ kind: "text", value: remaining.slice(0, match.index) });
161
+ }
162
+ const matched = match[0];
163
+ if (matched.startsWith("`")) {
164
+ tokens.push({ kind: "code", value: matched.slice(1, -1) });
165
+ } else if (matched.startsWith("**")) {
166
+ tokens.push({ kind: "bold", value: matched.slice(2, -2) });
167
+ } else if (matched.startsWith("[")) {
168
+ const link = matched.match(/^\[([^\]\n]+)\]\(([^\s)\n]+)\)$/u);
169
+ if (link) tokens.push({ kind: "link", value: link[1] ?? "", href: link[2] ?? "" });
170
+ else tokens.push({ kind: "text", value: matched });
171
+ } else {
172
+ tokens.push({ kind: "italic", value: matched.slice(1, -1) });
173
+ }
174
+ remaining = remaining.slice(match.index + matched.length);
175
+ }
176
+ return tokens;
177
+ }
178
+ function baseColor(theme, dim, tone) {
179
+ if (dim) return theme.dim;
180
+ if (tone === "error") return theme.error;
181
+ if (tone === "diagnostic") return theme.diagnostic;
182
+ return theme.assistantText;
183
+ }
184
+ function InlineText({
185
+ value,
186
+ theme,
187
+ dim,
188
+ tone,
189
+ selected
190
+ }) {
191
+ const color = baseColor(theme, dim, tone);
192
+ const codeColor = theme.inlineCode ?? theme.dim ?? theme.muted;
193
+ const tokens = tokenizeInline(value);
194
+ return /* @__PURE__ */ jsx(
195
+ Text,
196
+ {
197
+ color: selected ? "white" : color,
198
+ backgroundColor: selected && theme.mode !== "no-color" ? "blue" : void 0,
199
+ dimColor: selected ? false : dim,
200
+ children: tokens.map((token, tokenIndex) => {
201
+ const key = `${tokenIndex}-${token.kind}-${token.value}`;
202
+ if (token.kind === "code") {
203
+ return /* @__PURE__ */ jsx(
204
+ Text,
205
+ {
206
+ color: selected ? "white" : codeColor,
207
+ dimColor: selected ? false : dim,
208
+ children: token.value
209
+ },
210
+ key
211
+ );
212
+ }
213
+ if (token.kind === "bold") {
214
+ return /* @__PURE__ */ jsx(
215
+ Text,
216
+ {
217
+ bold: true,
218
+ color: selected ? "white" : color,
219
+ dimColor: selected ? false : dim,
220
+ children: token.value
221
+ },
222
+ key
223
+ );
224
+ }
225
+ if (token.kind === "italic") {
226
+ return /* @__PURE__ */ jsx(
227
+ Text,
228
+ {
229
+ italic: true,
230
+ color: selected ? "white" : color,
231
+ dimColor: selected ? false : dim,
232
+ children: token.value
233
+ },
234
+ key
235
+ );
236
+ }
237
+ if (token.kind === "link") {
238
+ return /* @__PURE__ */ jsx(
239
+ Text,
240
+ {
241
+ color: selected ? "white" : theme.diagnostic ?? theme.accent,
242
+ underline: true,
243
+ children: token.value
244
+ },
245
+ key
246
+ );
247
+ }
248
+ return /* @__PURE__ */ jsx(Text, { children: token.value }, key);
249
+ })
250
+ }
251
+ );
252
+ }
253
+ function InlineRow({
254
+ value,
255
+ theme,
256
+ dim,
257
+ tone,
258
+ wrapWidth,
259
+ selected
260
+ }) {
261
+ const rows = wrapWidth ? wrapText(value, wrapWidth) : [value];
262
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: rows.map((row, rowIndex) => /* @__PURE__ */ jsx(
263
+ InlineText,
264
+ {
265
+ value: row,
266
+ theme,
267
+ dim,
268
+ tone,
269
+ selected
270
+ },
271
+ `${rowIndex}-${row}`
272
+ )) });
273
+ }
274
+ function InlineCellRangeRow({
275
+ value,
276
+ ranges,
277
+ theme,
278
+ dim,
279
+ tone
280
+ }) {
281
+ const segments = splitLineBySelectionRanges(value, ranges);
282
+ return /* @__PURE__ */ jsx(Text, { children: segments.map((segment, index) => /* @__PURE__ */ jsx(
283
+ InlineText,
284
+ {
285
+ value: segment.text,
286
+ theme,
287
+ dim,
288
+ tone,
289
+ selected: segment.selected
290
+ },
291
+ `${index}-${segment.selected ? "selected" : "plain"}-${segment.text}`
292
+ )) });
293
+ }
294
+ function splitLineBySelectionRanges(value, ranges) {
295
+ const chars = Array.from(value);
296
+ const totalWidth = chars.reduce((width, char) => width + Math.max(1, charWidth(char)), 0);
297
+ const normalized = ranges.map((range) => ({
298
+ start: Math.max(0, Math.min(totalWidth, range.startColumn)),
299
+ end: Math.max(0, Math.min(totalWidth, range.endColumn))
300
+ })).filter((range) => range.end > range.start).sort((a, b) => a.start - b.start || a.end - b.end);
301
+ if (normalized.length === 0) return [{ text: value, selected: false }];
302
+ const merged = [];
303
+ for (const range of normalized) {
304
+ const previous = merged.at(-1);
305
+ if (previous && range.start <= previous.end) previous.end = Math.max(previous.end, range.end);
306
+ else merged.push({ ...range });
307
+ }
308
+ const segments = [];
309
+ let current = "";
310
+ let currentSelected;
311
+ let column = 0;
312
+ const pushCurrent = () => {
313
+ if (currentSelected === void 0 || current.length === 0) return;
314
+ segments.push({ text: current, selected: currentSelected });
315
+ current = "";
316
+ };
317
+ for (const char of chars) {
318
+ const width = Math.max(1, charWidth(char));
319
+ const selected = merged.some((range) => range.start < column + width && range.end > column);
320
+ if (currentSelected !== selected) {
321
+ pushCurrent();
322
+ currentSelected = selected;
323
+ }
324
+ current += char;
325
+ column += width;
326
+ }
327
+ pushCurrent();
328
+ return segments;
329
+ }
330
+ function stripAnsi(value) {
331
+ return value.replace(ANSI_REGEX, "");
332
+ }
333
+ function highlightedCodeLines(code, lang) {
334
+ if (!lang) return code.split("\n");
335
+ if (lang === "diff" || lang === "patch") return code.split("\n");
336
+ try {
337
+ return highlight(code, { language: lang, ignoreIllegals: true }).split("\n");
338
+ } catch {
339
+ return code.split("\n");
340
+ }
341
+ }
342
+ function CodeLine({
343
+ line,
344
+ highlightedLine,
345
+ lang,
346
+ theme,
347
+ dim,
348
+ selected,
349
+ ranges,
350
+ wrapWidth
351
+ }) {
352
+ const isDiff = lang === "diff" || lang === "patch";
353
+ const color = isDiff && line.startsWith("+") && !line.startsWith("+++") ? theme.success ?? theme.status.pass : isDiff && line.startsWith("-") && !line.startsWith("---") ? theme.error ?? theme.status.fail : theme.diagnostic ?? theme.accent;
354
+ const dimLine = dim || isDiff && !line.startsWith("+") && !line.startsWith("-");
355
+ if (ranges && ranges.length > 0) {
356
+ const segments = splitLineBySelectionRanges(line.length === 0 ? " " : line, ranges);
357
+ return /* @__PURE__ */ jsx(Text, { wrap: "wrap", children: segments.map((segment, index) => /* @__PURE__ */ jsx(
358
+ Text,
359
+ {
360
+ color: segment.selected ? "white" : color,
361
+ backgroundColor: segment.selected && theme.mode !== "no-color" ? "blue" : void 0,
362
+ dimColor: segment.selected ? false : dimLine,
363
+ children: segment.text
364
+ },
365
+ `${index}-${segment.selected ? "selected" : "plain"}-${segment.text}`
366
+ )) });
367
+ }
368
+ const rawWrapped = wrapText(line.length === 0 ? " " : line, wrapWidth);
369
+ const highlightedFits = highlightedLine && rawWrapped.length === 1 && displayWidth(stripAnsi(highlightedLine)) <= wrapWidth;
370
+ const rows = highlightedFits ? [highlightedLine] : rawWrapped;
371
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: rows.map((wrapped, index) => {
372
+ const padded = padDisplay(wrapped, wrapWidth);
373
+ return /* @__PURE__ */ jsx(
374
+ Text,
375
+ {
376
+ color: selected ? "white" : highlightedFits && !isDiff ? void 0 : color,
377
+ backgroundColor: selected && theme.mode !== "no-color" ? "blue" : void 0,
378
+ dimColor: selected ? false : dimLine,
379
+ children: padded
380
+ },
381
+ `${index}-${stripAnsi(wrapped)}`
382
+ );
383
+ }) });
384
+ }
385
+ function renderCodeBlock({
386
+ code,
387
+ lang,
388
+ theme,
389
+ dim,
390
+ wrapWidth,
391
+ blockKey
392
+ }) {
393
+ if (lang === "diff" || lang === "patch") {
394
+ return /* @__PURE__ */ jsx(StructuredDiff, { code, theme, wrapWidth, dim }, blockKey);
395
+ }
396
+ const rawLines = code.split("\n");
397
+ const highlighted = getCachedHighlightedCodeLines(code, lang);
398
+ const lineCount = rawLines.length;
399
+ const gutterWidth = String(lineCount).length;
400
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginLeft: 1, children: [
401
+ lang ? /* @__PURE__ */ jsx(Text, { color: theme.dim ?? theme.muted, dimColor: dim, children: ` ${lang}` }) : null,
402
+ rawLines.map((line, lineIndex) => {
403
+ const num = String(lineIndex + 1).padStart(gutterWidth, " ");
404
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
405
+ /* @__PURE__ */ jsx(Text, { color: theme.dim ?? theme.muted, dimColor: true, children: `${num} \u2502 ` }),
406
+ /* @__PURE__ */ jsx(
407
+ CodeLine,
408
+ {
409
+ line,
410
+ highlightedLine: highlighted[lineIndex],
411
+ lang,
412
+ theme,
413
+ dim,
414
+ wrapWidth: Math.max(8, wrapWidth - gutterWidth - 4)
415
+ }
416
+ )
417
+ ] }, `${blockKey}-line-${lineIndex}-${line}`);
418
+ })
419
+ ] }, blockKey);
420
+ }
421
+ function tokenPlainText(token) {
422
+ const maybeText = token;
423
+ return typeof maybeText.text === "string" ? maybeText.text : typeof maybeText.raw === "string" ? maybeText.raw : "";
424
+ }
425
+ function renderToken({
426
+ token,
427
+ theme,
428
+ dim,
429
+ tone,
430
+ wrapWidth,
431
+ keyPrefix
432
+ }) {
433
+ switch (token.type) {
434
+ case "space":
435
+ return /* @__PURE__ */ jsx(Box, { height: 1 }, keyPrefix);
436
+ case "heading": {
437
+ const heading = token;
438
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginTop: heading.depth <= 2 ? 1 : 0, children: wrapText(`${"#".repeat(heading.depth)} ${heading.text}`, wrapWidth).map(
439
+ (line, index) => /* @__PURE__ */ jsx(
440
+ Text,
441
+ {
442
+ bold: true,
443
+ color: dim ? theme.dim : theme.accent ?? theme.brand,
444
+ dimColor: dim,
445
+ children: line
446
+ },
447
+ `${keyPrefix}-heading-${index}-${line}`
448
+ )
449
+ ) }, keyPrefix);
450
+ }
451
+ case "paragraph":
452
+ case "text":
453
+ return /* @__PURE__ */ jsx(
454
+ InlineRow,
455
+ {
456
+ value: tokenPlainText(token),
457
+ theme,
458
+ dim,
459
+ tone,
460
+ wrapWidth
461
+ },
462
+ keyPrefix
463
+ );
464
+ case "blockquote": {
465
+ const quote = token;
466
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
467
+ /* @__PURE__ */ jsx(Text, { color: theme.dim ?? theme.muted, dimColor: dim, children: "\u258C " }),
468
+ /* @__PURE__ */ jsx(
469
+ MessageMarkdown,
470
+ {
471
+ text: quote.text,
472
+ theme,
473
+ dim,
474
+ tone,
475
+ wrapWidth: wrapWidth - 2
476
+ }
477
+ )
478
+ ] }, keyPrefix);
479
+ }
480
+ case "list": {
481
+ const list = token;
482
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: list.items.map((item, index) => {
483
+ const marker = list.ordered ? `${Number(list.start || 1) + index}.` : item.task ? item.checked ? "\u2611" : "\u2610" : "-";
484
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
485
+ /* @__PURE__ */ jsxs(Text, { color: dim ? theme.dim : theme.muted, dimColor: dim, children: [
486
+ marker,
487
+ " "
488
+ ] }),
489
+ /* @__PURE__ */ jsx(
490
+ InlineRow,
491
+ {
492
+ value: item.text.replace(/\n+/gu, " "),
493
+ theme,
494
+ dim,
495
+ tone,
496
+ wrapWidth: Math.max(8, wrapWidth - marker.length - 1)
497
+ }
498
+ )
499
+ ] }, `${keyPrefix}-item-${index}`);
500
+ }) }, keyPrefix);
501
+ }
502
+ case "code": {
503
+ const code = token;
504
+ return renderCodeBlock({
505
+ code: code.text,
506
+ lang: code.lang,
507
+ theme,
508
+ dim,
509
+ wrapWidth,
510
+ blockKey: keyPrefix
511
+ });
512
+ }
513
+ case "table":
514
+ return renderTable(token, theme, dim, tone, wrapWidth, keyPrefix);
515
+ case "hr":
516
+ return /* @__PURE__ */ jsx(Text, { color: theme.dim ?? theme.muted, dimColor: dim, children: "\u2500".repeat(Math.min(wrapWidth, 40)) }, keyPrefix);
517
+ default:
518
+ return /* @__PURE__ */ jsx(
519
+ InlineRow,
520
+ {
521
+ value: tokenPlainText(token),
522
+ theme,
523
+ dim,
524
+ tone,
525
+ wrapWidth
526
+ },
527
+ keyPrefix
528
+ );
529
+ }
530
+ }
531
+ function renderMarkdownTokens({
532
+ text,
533
+ theme,
534
+ dim,
535
+ tone,
536
+ wrapWidth,
537
+ keyPrefix
538
+ }) {
539
+ const tokens = getCachedMarkdownTokens(text);
540
+ return tokens.map(
541
+ (token, index) => renderToken({
542
+ token,
543
+ theme,
544
+ dim,
545
+ tone,
546
+ wrapWidth,
547
+ keyPrefix: `${keyPrefix}-${index}-${token.type}-${token.raw.slice(0, 16)}`
548
+ })
549
+ );
550
+ }
551
+ function buildTableCell(text, width) {
552
+ const lines = wrapText(text, Math.max(4, width));
553
+ return { text, lines, width };
554
+ }
555
+ function padDisplay(value, width) {
556
+ const visible = displayWidth(stripAnsi(value));
557
+ return `${value}${" ".repeat(Math.max(0, width - visible))}`;
558
+ }
559
+ function tableWidths(table, wrapWidth) {
560
+ const columnCount = table.header.length;
561
+ const maxPerCol = Math.max(
562
+ TABLE_MIN_COLUMN_WIDTH,
563
+ Math.min(TABLE_MAX_COLUMN_WIDTH, Math.floor(wrapWidth * 0.45))
564
+ );
565
+ const rawWidths = Array.from({ length: columnCount }, (_, index) => {
566
+ const values = [
567
+ table.header[index]?.text ?? "",
568
+ ...table.rows.map((row) => row[index]?.text ?? "")
569
+ ];
570
+ return Math.min(
571
+ maxPerCol,
572
+ Math.max(TABLE_MIN_COLUMN_WIDTH, ...values.map((value) => displayWidth(value)))
573
+ );
574
+ });
575
+ const borderWidth = columnCount + 1;
576
+ const paddingWidth = columnCount * 2;
577
+ const available = Math.max(
578
+ columnCount * TABLE_MIN_COLUMN_WIDTH,
579
+ wrapWidth - borderWidth - paddingWidth
580
+ );
581
+ const total = rawWidths.reduce((sum, width) => sum + width, 0);
582
+ if (total <= available) return rawWidths;
583
+ const scale = available / total;
584
+ const proportional = rawWidths.map(
585
+ (w) => Math.max(TABLE_MIN_COLUMN_WIDTH, Math.floor(w * scale))
586
+ );
587
+ if (proportional.some((w) => w < TABLE_MIN_ACCEPTABLE_COLUMN)) {
588
+ return rawWidths;
589
+ }
590
+ return proportional;
591
+ }
592
+ function renderTable(table, theme, dim, tone, wrapWidth, keyPrefix) {
593
+ const columnCount = table.header.length;
594
+ if (columnCount === 0) return null;
595
+ const widths = tableWidths(table, wrapWidth);
596
+ const tableWidth = widths.reduce((sum, width) => sum + width + 2, 1);
597
+ if (wrapWidth < TABLE_VERTICAL_FALLBACK_WIDTH || tableWidth > wrapWidth) {
598
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: table.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginBottom: 1, children: row.map((cell, cellIndex) => /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
599
+ /* @__PURE__ */ jsxs(Text, { color: theme.muted, dimColor: dim, children: [
600
+ table.header[cellIndex]?.text ?? `#${cellIndex + 1}`,
601
+ ":",
602
+ " "
603
+ ] }),
604
+ /* @__PURE__ */ jsx(
605
+ InlineRow,
606
+ {
607
+ value: cell.text,
608
+ theme,
609
+ dim,
610
+ tone,
611
+ wrapWidth: Math.max(
612
+ 8,
613
+ wrapWidth - displayWidth(table.header[cellIndex]?.text ?? `#${cellIndex + 1}`) - 2
614
+ )
615
+ }
616
+ )
617
+ ] }, `${keyPrefix}-vertical-${rowIndex}-${cellIndex}`)) }, `${keyPrefix}-vertical-${rowIndex}`)) }, keyPrefix);
618
+ }
619
+ const borderColor = theme.dim ?? theme.muted;
620
+ const border = (left, mid, right) => `${left}${widths.map((width) => "\u2500".repeat(width + 2)).join(mid)}${right}`;
621
+ const renderRow = (cells, rowKey, boldHeader = false) => {
622
+ const height = Math.max(...cells.map((cell) => cell.lines.length));
623
+ return Array.from({ length: height }, (_, lineIndex) => /* @__PURE__ */ jsxs(Text, { children: [
624
+ /* @__PURE__ */ jsx(Text, { color: borderColor, dimColor: dim, children: "\u2502" }),
625
+ cells.map((cell, cellIndex) => /* @__PURE__ */ jsxs(Text, { children: [
626
+ " ",
627
+ /* @__PURE__ */ jsx(Text, { bold: boldHeader, color: boldHeader && !dim ? theme.accent : void 0, children: padDisplay(cell.lines[lineIndex] ?? "", cell.width) }),
628
+ " ",
629
+ /* @__PURE__ */ jsx(Text, { color: borderColor, dimColor: dim, children: "\u2502" })
630
+ ] }, `${rowKey}-${lineIndex}-${cellIndex}`))
631
+ ] }, `${rowKey}-${lineIndex}`));
632
+ };
633
+ const header = table.header.map((cell, index) => buildTableCell(cell.text, widths[index] ?? 4));
634
+ const rows = table.rows.map(
635
+ (row) => row.map((cell, index) => buildTableCell(cell.text, widths[index] ?? 4))
636
+ );
637
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
638
+ /* @__PURE__ */ jsx(Text, { color: borderColor, dimColor: dim, children: border("\u250C", "\u252C", "\u2510") }),
639
+ renderRow(header, `${keyPrefix}-header`, true),
640
+ /* @__PURE__ */ jsx(Text, { color: borderColor, dimColor: dim, children: border("\u251C", "\u253C", "\u2524") }),
641
+ rows.flatMap((row, index) => [
642
+ ...renderRow(row, `${keyPrefix}-row-${index}`),
643
+ ...index < rows.length - 1 ? [
644
+ /* @__PURE__ */ jsx(Text, { color: borderColor, dimColor: dim, children: border("\u251C", "\u253C", "\u2524") }, `${keyPrefix}-sep-${index}`)
645
+ ] : []
646
+ ]),
647
+ /* @__PURE__ */ jsx(Text, { color: borderColor, dimColor: dim, children: border("\u2514", "\u2534", "\u2518") })
648
+ ] }, keyPrefix);
649
+ }
650
+ function MessageMarkdown({
651
+ text,
652
+ theme,
653
+ dim = false,
654
+ tone = "default",
655
+ wrapWidth,
656
+ selectionLineIndexes,
657
+ selectionLineRanges,
658
+ isStreaming
659
+ }) {
660
+ if (!text || text.length === 0) return null;
661
+ if ((selectionLineIndexes?.length ?? 0) > 0 || (selectionLineRanges?.length ?? 0) > 0) {
662
+ return renderSelectablePlainMarkdown({
663
+ text,
664
+ theme,
665
+ dim,
666
+ tone,
667
+ wrapWidth,
668
+ selectionLineIndexes,
669
+ selectionLineRanges
670
+ });
671
+ }
672
+ if (isStreaming) {
673
+ const lines = text.replace(/\r/g, "").split("\n");
674
+ const color = baseColor(theme, dim, tone);
675
+ const effectiveWrapWidth2 = wrapWidth ?? 80;
676
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: lines.flatMap(
677
+ (line, i) => wrapText(line, effectiveWrapWidth2).map((wrapped, wrappedIndex) => /* @__PURE__ */ jsx(Text, { color, dimColor: dim, children: wrapped }, `s${i}-${wrappedIndex}-${wrapped}`))
678
+ ) });
679
+ }
680
+ const effectiveWrapWidth = wrapWidth ?? 80;
681
+ const normalized = stripLowValueDiagnosticNoise(text.replace(/\r/g, ""));
682
+ const segments = splitRawDiffSections(normalized);
683
+ if (segments.some((segment) => segment.kind === "diff")) {
684
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: segments.map(
685
+ (segment, index) => segment.kind === "diff" ? /* @__PURE__ */ jsx(
686
+ StructuredDiff,
687
+ {
688
+ code: segment.text,
689
+ theme,
690
+ wrapWidth: effectiveWrapWidth,
691
+ dim
692
+ },
693
+ `raw-diff-${index}`
694
+ ) : /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: renderMarkdownTokens({
695
+ text: segment.text,
696
+ theme,
697
+ dim,
698
+ tone,
699
+ wrapWidth: effectiveWrapWidth,
700
+ keyPrefix: `markdown-${index}`
701
+ }) }, `markdown-${index}`)
702
+ ) });
703
+ }
704
+ const tokens = getCachedMarkdownTokens(normalized);
705
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: tokens.map(
706
+ (token, index) => renderToken({
707
+ token,
708
+ theme,
709
+ dim,
710
+ tone,
711
+ wrapWidth: effectiveWrapWidth,
712
+ keyPrefix: `${index}-${token.type}-${token.raw.slice(0, 16)}`
713
+ })
714
+ ) });
715
+ }
716
+ function renderSelectablePlainMarkdown({
717
+ text,
718
+ theme,
719
+ dim,
720
+ tone,
721
+ wrapWidth,
722
+ selectionLineIndexes,
723
+ selectionLineRanges
724
+ }) {
725
+ const lines = text.replace(/\r/g, "").split("\n");
726
+ const selectedLines = new Set(selectionLineIndexes ?? []);
727
+ const selectedRangesByLine = /* @__PURE__ */ new Map();
728
+ for (const range of selectionLineRanges ?? []) {
729
+ const existing = selectedRangesByLine.get(range.lineIndex) ?? [];
730
+ existing.push(range);
731
+ selectedRangesByLine.set(range.lineIndex, existing);
732
+ }
733
+ const effectiveWrapWidth = wrapWidth ?? 80;
734
+ let inCode = false;
735
+ let codeLang;
736
+ let codeLineNum = 0;
737
+ const rendered = [];
738
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
739
+ const raw = lines[lineIndex] ?? "";
740
+ const fence = raw.match(/^\s*```\s*([A-Za-z0-9_+-]*)\s*$/u);
741
+ if (fence) {
742
+ inCode = !inCode;
743
+ codeLang = inCode ? fence[1] || void 0 : void 0;
744
+ codeLineNum = 0;
745
+ continue;
746
+ }
747
+ const ranges = selectedRangesByLine.get(lineIndex) ?? [];
748
+ if (inCode) {
749
+ codeLineNum++;
750
+ const gutter = String(codeLineNum).padStart(2, " ");
751
+ rendered.push(
752
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
753
+ /* @__PURE__ */ jsx(Text, { color: theme.dim ?? theme.muted, dimColor: true, children: `${gutter} \u2502 ` }),
754
+ /* @__PURE__ */ jsx(
755
+ CodeLine,
756
+ {
757
+ line: raw,
758
+ lang: codeLang,
759
+ theme,
760
+ dim,
761
+ selected: selectedLines.has(lineIndex),
762
+ ranges,
763
+ wrapWidth: Math.max(8, effectiveWrapWidth - 5)
764
+ }
765
+ )
766
+ ] }, `code-line-${lineIndex}-${raw}`)
767
+ );
768
+ continue;
769
+ }
770
+ if (raw.trim().length === 0) {
771
+ rendered.push(/* @__PURE__ */ jsx(Box, { height: 1 }, `blank-${lineIndex}`));
772
+ continue;
773
+ }
774
+ if (ranges.length > 0) {
775
+ rendered.push(
776
+ /* @__PURE__ */ jsx(
777
+ InlineCellRangeRow,
778
+ {
779
+ value: raw,
780
+ ranges,
781
+ theme,
782
+ dim,
783
+ tone
784
+ },
785
+ `range-${lineIndex}`
786
+ )
787
+ );
788
+ continue;
789
+ }
790
+ rendered.push(
791
+ /* @__PURE__ */ jsx(
792
+ InlineRow,
793
+ {
794
+ value: raw,
795
+ theme,
796
+ dim,
797
+ tone,
798
+ wrapWidth,
799
+ selected: selectedLines.has(lineIndex)
800
+ },
801
+ `line-${lineIndex}-${raw}`
802
+ )
803
+ );
804
+ }
805
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: rendered });
806
+ }
807
+ var MemoMessageMarkdown = memo(MessageMarkdown);
808
+ function splitStreamingMarkdownForRender(text, state) {
809
+ const normalized = text.replace(/\r/g, "");
810
+ if (!normalized.startsWith(state.stablePrefix)) {
811
+ state.stablePrefix = "";
812
+ }
813
+ const boundary = state.stablePrefix.length;
814
+ const suffixInput = normalized.slice(boundary);
815
+ const advance = findStablePrefixAdvance(suffixInput);
816
+ if (advance > 0) {
817
+ state.stablePrefix = normalized.slice(0, boundary + advance);
818
+ }
819
+ return {
820
+ stablePrefix: state.stablePrefix,
821
+ unstableSuffix: normalized.slice(state.stablePrefix.length),
822
+ parsedSuffixInput: suffixInput
823
+ };
824
+ }
825
+ function findStablePrefixAdvance(text) {
826
+ let offset = 0;
827
+ let boundary = 0;
828
+ let inCode = false;
829
+ for (const match of text.matchAll(/[^\n]*(?:\n|$)/gu)) {
830
+ const segment = match[0];
831
+ if (!segment) break;
832
+ if (!segment.endsWith("\n")) break;
833
+ const line = segment.slice(0, -1);
834
+ const fence = /^\s*```\s*[A-Za-z0-9_+-]*\s*$/u.test(line);
835
+ if (fence) {
836
+ inCode = !inCode;
837
+ offset += segment.length;
838
+ if (!inCode) boundary = offset;
839
+ continue;
840
+ }
841
+ offset += segment.length;
842
+ if (!inCode && line.trim().length === 0) boundary = offset;
843
+ }
844
+ if (!inCode && text.endsWith("\n") && hasBalancedInlineMarkdown(text)) return text.length;
845
+ return boundary;
846
+ }
847
+ function hasBalancedInlineMarkdown(text) {
848
+ let inInlineCode = false;
849
+ let boldOpen = false;
850
+ let italicOpen = false;
851
+ for (let index = 0; index < text.length; index += 1) {
852
+ const char = text[index];
853
+ if (char === "`") {
854
+ inInlineCode = !inInlineCode;
855
+ continue;
856
+ }
857
+ if (!inInlineCode && char === "*" && text[index + 1] === "*") {
858
+ boldOpen = !boldOpen;
859
+ index += 1;
860
+ continue;
861
+ }
862
+ if (!inInlineCode && char === "*") {
863
+ italicOpen = !italicOpen;
864
+ }
865
+ }
866
+ return !inInlineCode && !boldOpen && !italicOpen;
867
+ }
868
+ function StreamingMarkdown({
869
+ text,
870
+ theme,
871
+ dim = false,
872
+ tone = "default",
873
+ wrapWidth
874
+ }) {
875
+ const stateRef = useRef({ stablePrefix: "" });
876
+ const { stablePrefix, unstableSuffix } = splitStreamingMarkdownForRender(text, stateRef.current);
877
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
878
+ stablePrefix ? /* @__PURE__ */ jsx(
879
+ MemoMessageMarkdown,
880
+ {
881
+ text: stablePrefix,
882
+ theme,
883
+ dim,
884
+ tone,
885
+ wrapWidth
886
+ }
887
+ ) : null,
888
+ unstableSuffix ? /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
889
+ /* @__PURE__ */ jsx(
890
+ MessageMarkdown,
891
+ {
892
+ text: unstableSuffix,
893
+ theme,
894
+ dim,
895
+ tone,
896
+ wrapWidth,
897
+ isStreaming: true
898
+ }
899
+ ),
900
+ /* @__PURE__ */ jsx(Text, { color: theme.accent, children: "\u258C" })
901
+ ] }) : /* @__PURE__ */ jsx(Text, { color: theme.accent, children: "\u258C" })
902
+ ] });
903
+ }
904
+
905
+ export {
906
+ useInMessageResponse,
907
+ MessageResponseProvider,
908
+ __testSplitRawDiffSections,
909
+ MessageMarkdown,
910
+ splitStreamingMarkdownForRender,
911
+ StreamingMarkdown
912
+ };