@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,1555 @@
1
+ import {
2
+ classifyTerminalInput,
3
+ isMultilineEnterSequence,
4
+ normalizeTerminalInput,
5
+ sanitizeTerminalText
6
+ } from "./chunk-JBLVBO3U.js";
7
+ import {
8
+ useAnchoredCursor
9
+ } from "./chunk-GW5YDCRZ.js";
10
+ import {
11
+ SlashSuggestions
12
+ } from "./chunk-HW2TBXVK.js";
13
+ import {
14
+ resolveTerminalInteractionModes
15
+ } from "./chunk-F46N43MG.js";
16
+ import {
17
+ createUndoRing,
18
+ undoRingPop,
19
+ undoRingPush
20
+ } from "./chunk-P4CPRJLI.js";
21
+ import {
22
+ createPromptStash,
23
+ toggleStash
24
+ } from "./chunk-YPQFSFYK.js";
25
+ import {
26
+ computeGhostText
27
+ } from "./chunk-TFZEFIQT.js";
28
+ import {
29
+ createShellTheme
30
+ } from "./chunk-GC55DMZV.js";
31
+ import {
32
+ formatUnknownSlashCommand,
33
+ getCoreSlashCandidates,
34
+ getSlashPrefixCandidates
35
+ } from "./chunk-4K6UB524.js";
36
+ import {
37
+ resolveKeybinding
38
+ } from "./chunk-6SMM5CMP.js";
39
+ import {
40
+ charWidth,
41
+ composerMaxWidth,
42
+ fitText,
43
+ taskComposerMaxWidth
44
+ } from "./chunk-APJIC2O5.js";
45
+
46
+ // src/shell/components/Composer.tsx
47
+ import { Box, Text, useInput } from "@linghun/ink-runtime";
48
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
49
+ import { jsx, jsxs } from "react/jsx-runtime";
50
+ function createEditBuffer(text = "") {
51
+ return { chars: Array.from(text), cursor: Array.from(text).length };
52
+ }
53
+ function bufferToString(buf) {
54
+ return buf.chars.join("");
55
+ }
56
+ function bufferDisplayWidth(buf) {
57
+ let w = 0;
58
+ for (const ch of buf.chars) w += charWidth(ch);
59
+ return w;
60
+ }
61
+ function bufferInsert(buf, text) {
62
+ const insertChars = Array.from(text);
63
+ const chars = [...buf.chars.slice(0, buf.cursor), ...insertChars, ...buf.chars.slice(buf.cursor)];
64
+ return { chars, cursor: buf.cursor + insertChars.length };
65
+ }
66
+ function bufferBackspace(buf) {
67
+ if (buf.cursor === 0) return buf;
68
+ const chars = [...buf.chars.slice(0, buf.cursor - 1), ...buf.chars.slice(buf.cursor)];
69
+ return { chars, cursor: buf.cursor - 1 };
70
+ }
71
+ function bufferDelete(buf) {
72
+ if (buf.cursor >= buf.chars.length) return buf;
73
+ const chars = [...buf.chars.slice(0, buf.cursor), ...buf.chars.slice(buf.cursor + 1)];
74
+ return { chars, cursor: buf.cursor };
75
+ }
76
+ function bufferMoveLeft(buf) {
77
+ if (buf.cursor === 0) return buf;
78
+ return { ...buf, cursor: buf.cursor - 1 };
79
+ }
80
+ function bufferMoveRight(buf) {
81
+ if (buf.cursor >= buf.chars.length) return buf;
82
+ return { ...buf, cursor: buf.cursor + 1 };
83
+ }
84
+ function bufferHome(buf) {
85
+ return { ...buf, cursor: 0 };
86
+ }
87
+ function bufferEnd(buf) {
88
+ return { ...buf, cursor: buf.chars.length };
89
+ }
90
+ function bufferWordLeft(buf) {
91
+ let pos = buf.cursor;
92
+ while (pos > 0 && isWordBoundary(buf.chars[pos - 1] ?? "")) pos--;
93
+ while (pos > 0 && !isWordBoundary(buf.chars[pos - 1] ?? "")) pos--;
94
+ return { ...buf, cursor: pos };
95
+ }
96
+ function bufferWordRight(buf) {
97
+ let pos = buf.cursor;
98
+ const len = buf.chars.length;
99
+ while (pos < len && !isWordBoundary(buf.chars[pos] ?? "")) pos++;
100
+ while (pos < len && isWordBoundary(buf.chars[pos] ?? "")) pos++;
101
+ return { ...buf, cursor: pos };
102
+ }
103
+ function bufferDeleteWordLeft(buf) {
104
+ const target = bufferWordLeft(buf).cursor;
105
+ const chars = [...buf.chars.slice(0, target), ...buf.chars.slice(buf.cursor)];
106
+ return { chars, cursor: target };
107
+ }
108
+ function bufferClearLine(buf) {
109
+ void buf;
110
+ return { chars: [], cursor: 0 };
111
+ }
112
+ function bufferKillToEnd(buf) {
113
+ return { chars: buf.chars.slice(0, buf.cursor), cursor: buf.cursor };
114
+ }
115
+ function bufferMoveUp(buf) {
116
+ const { row, col } = getCursorLinePosition(buf);
117
+ if (row === 0) return buf;
118
+ const lines = bufferToString(buf).split("\n");
119
+ const targetLine = lines[row - 1] ?? "";
120
+ const targetChars = Array.from(targetLine);
121
+ const targetCol = Math.min(col, targetChars.length);
122
+ let newCursor = 0;
123
+ for (let i = 0; i < row - 1; i++) {
124
+ newCursor += Array.from(lines[i] ?? "").length + 1;
125
+ }
126
+ newCursor += targetCol;
127
+ return { ...buf, cursor: newCursor };
128
+ }
129
+ function bufferMoveDown(buf) {
130
+ const { row, col } = getCursorLinePosition(buf);
131
+ const lines = bufferToString(buf).split("\n");
132
+ if (row >= lines.length - 1) return buf;
133
+ const targetLine = lines[row + 1] ?? "";
134
+ const targetChars = Array.from(targetLine);
135
+ const targetCol = Math.min(col, targetChars.length);
136
+ let newCursor = 0;
137
+ for (let i = 0; i <= row; i++) {
138
+ newCursor += Array.from(lines[i] ?? "").length + 1;
139
+ }
140
+ newCursor += targetCol;
141
+ return { ...buf, cursor: newCursor };
142
+ }
143
+ function bufferMoveVisualUp(buf, maxWidth) {
144
+ return bufferMoveVisual(buf, maxWidth, -1);
145
+ }
146
+ function bufferMoveVisualDown(buf, maxWidth) {
147
+ return bufferMoveVisual(buf, maxWidth, 1);
148
+ }
149
+ function bufferMoveVisual(buf, maxWidth, delta) {
150
+ const visual = getVisualLinePosition(buf, maxWidth);
151
+ const target = visual.lines[visual.index + delta];
152
+ if (!target) return buf;
153
+ const cursorCol = Math.max(0, visual.cursorDisplayCol - visual.current.promptWidth);
154
+ const targetText = getRawLineText(buf, target.rawLineIndex);
155
+ const targetChars = Array.from(targetText).slice(target.startChar, target.endChar);
156
+ let used = 0;
157
+ let offset = 0;
158
+ for (; offset < targetChars.length; offset++) {
159
+ const next = charWidth(targetChars[offset] ?? "");
160
+ if (used + next > cursorCol) break;
161
+ used += next;
162
+ }
163
+ return { ...buf, cursor: target.absoluteStart + offset };
164
+ }
165
+ function getVisualLinePosition(buf, maxWidth) {
166
+ const lines = buildVisualLines(buf, maxWidth);
167
+ const fallback = lines[0] ?? {
168
+ rawLineIndex: 0,
169
+ startChar: 0,
170
+ endChar: 0,
171
+ absoluteStart: 0,
172
+ promptWidth: displayWidthOf(PROMPT_MARKER)
173
+ };
174
+ let index = 0;
175
+ for (let i = 0; i < lines.length; i++) {
176
+ const line = lines[i] ?? fallback;
177
+ const lineEnd = line.absoluteStart + line.endChar - line.startChar;
178
+ const nextLine = lines[i + 1];
179
+ const wrapsToNextVisualLine = nextLine?.rawLineIndex === line.rawLineIndex;
180
+ if (buf.cursor >= line.absoluteStart && (wrapsToNextVisualLine ? buf.cursor < lineEnd : buf.cursor <= lineEnd)) {
181
+ index = i;
182
+ break;
183
+ }
184
+ }
185
+ const current = lines[index] ?? fallback;
186
+ let cursorDisplayCol = current.promptWidth;
187
+ const inLineOffset = Math.max(0, buf.cursor - current.absoluteStart);
188
+ const rawLine = getRawLineText(buf, current.rawLineIndex);
189
+ const chars = Array.from(rawLine).slice(current.startChar, current.startChar + inLineOffset);
190
+ for (const ch of chars) cursorDisplayCol += charWidth(ch);
191
+ return { lines, index, current, cursorDisplayCol };
192
+ }
193
+ function buildVisualLines(buf, maxWidth) {
194
+ const rawLines = bufferToString(buf).split("\n");
195
+ const composerWidth = Math.max(8, maxWidth ?? 80);
196
+ const result = [];
197
+ let absoluteLineStart = 0;
198
+ for (let rawIndex = 0; rawIndex < rawLines.length; rawIndex++) {
199
+ const rawLine = rawLines[rawIndex] ?? "";
200
+ const chars = Array.from(rawLine);
201
+ const isFirstRawLine = rawIndex === 0;
202
+ let startChar = 0;
203
+ while (startChar < chars.length || chars.length === 0 && startChar === 0) {
204
+ const prompt = isFirstRawLine && startChar === 0 ? PROMPT_MARKER : PROMPT_MARKER_CONTINUATION;
205
+ const promptWidth = displayWidthOf(prompt);
206
+ const budget = Math.max(4, composerWidth - promptWidth);
207
+ let width = 0;
208
+ let endChar = startChar;
209
+ while (endChar < chars.length) {
210
+ const next = charWidth(chars[endChar] ?? "");
211
+ if (width > 0 && width + next > budget) break;
212
+ width += next;
213
+ endChar++;
214
+ }
215
+ if (endChar === startChar && chars.length > 0) endChar++;
216
+ result.push({
217
+ rawLineIndex: rawIndex,
218
+ startChar,
219
+ endChar,
220
+ absoluteStart: absoluteLineStart + startChar,
221
+ promptWidth
222
+ });
223
+ if (chars.length === 0) break;
224
+ startChar = endChar;
225
+ }
226
+ absoluteLineStart += chars.length + 1;
227
+ }
228
+ return result;
229
+ }
230
+ function getRawLineText(buf, rawLineIndex) {
231
+ return bufferToString(buf).split("\n")[rawLineIndex] ?? "";
232
+ }
233
+ function isWordBoundary(ch) {
234
+ return /[\s\p{P}]/u.test(ch);
235
+ }
236
+ function sanitizeComposerInput(value) {
237
+ return sanitizeTerminalText(value);
238
+ }
239
+ var MAX_HISTORY = 100;
240
+ function createInputHistory() {
241
+ return { entries: [], position: -1, draft: "" };
242
+ }
243
+ function historyAdd(history, text) {
244
+ if (!text.trim()) return { ...history, position: -1, draft: "" };
245
+ const entries = history.entries[0] === text ? history.entries : [text, ...history.entries].slice(0, MAX_HISTORY);
246
+ return { entries, position: -1, draft: "" };
247
+ }
248
+ function historyUp(history, currentText) {
249
+ const nextPos = history.position + 1;
250
+ if (nextPos >= history.entries.length) return void 0;
251
+ const draft = history.position === -1 ? currentText : history.draft;
252
+ return { ...history, position: nextPos, draft };
253
+ }
254
+ function historyDown(history) {
255
+ if (history.position <= -1) return void 0;
256
+ const nextPos = history.position - 1;
257
+ return { ...history, position: nextPos, draft: history.draft };
258
+ }
259
+ function historyCurrentText(history) {
260
+ if (history.position === -1) return void 0;
261
+ return history.entries[history.position];
262
+ }
263
+ function shouldEnterPastePath(input, key, pastePending) {
264
+ if (input.length > PASTE_THRESHOLD) return true;
265
+ if (pastePending && input.length > 0 && !key.ctrl && !key.meta && !key.escape && !key.tab && !key.return) {
266
+ return true;
267
+ }
268
+ return false;
269
+ }
270
+ function selectInputOwner(input, key, ctx) {
271
+ if (ctx.permissionActive) return "permission";
272
+ if (ctx.panelActive === true && isPanelOwnerKey(input, key, ctx)) return "panel";
273
+ if (ctx.pastePending && (key.return || key.escape)) return "paste";
274
+ if (shouldEnterPastePath(input, key, ctx.pastePending)) return "paste";
275
+ if (ctx.slashVisible && isSlashOwnerKey(input, key)) return "slash";
276
+ return "composer";
277
+ }
278
+ function isPanelOwnerKey(input, key, ctx) {
279
+ if (key.escape) return true;
280
+ if (ctx.panelInteractive !== true) return false;
281
+ if (isModifiedEnter(input, key)) return false;
282
+ if (key.return || key.tab || key.upArrow || key.downArrow || key.leftArrow || key.rightArrow) {
283
+ return true;
284
+ }
285
+ if (ctx.panelNumericShortcuts && /^[1-9]$/.test(input) && !key.ctrl && !key.meta) return true;
286
+ if (ctx.panelSpaceAction && input === " " && !key.ctrl && !key.meta) return true;
287
+ return input.toLowerCase() === "x" && !key.ctrl && !key.meta;
288
+ }
289
+ function isSlashOwnerKey(input, key) {
290
+ return Boolean(
291
+ key.return && !isModifiedEnter(input, key) || key.escape || key.tab || key.upArrow || key.downArrow
292
+ );
293
+ }
294
+ function isModifiedEnter(input, key) {
295
+ return Boolean(
296
+ key.return && (key.shift || key.meta) && input.length > 0 && input !== "\r" && input !== "\n"
297
+ );
298
+ }
299
+ function isNavigationKey(key) {
300
+ return Boolean(key.upArrow || key.downArrow || key.leftArrow || key.rightArrow);
301
+ }
302
+ function isVerticalNavigationKey(key) {
303
+ return Boolean(key.upArrow || key.downArrow);
304
+ }
305
+ var OWNER_PRIORITY = [
306
+ "permission",
307
+ "panel",
308
+ "paste",
309
+ "slash",
310
+ "composer"
311
+ ];
312
+ var shouldOwnerBePaste = shouldEnterPastePath;
313
+ function isDoublePressWithin(lastPressAt, now, windowMs = DOUBLE_PRESS_WINDOW_MS) {
314
+ if (lastPressAt <= 0) return false;
315
+ return now - lastPressAt < windowMs;
316
+ }
317
+ function shouldUnstickSlashHidden(prevHead, nextText, nextHead) {
318
+ if (!nextText.startsWith("/")) return true;
319
+ return prevHead !== nextHead;
320
+ }
321
+ function isMultilineEnterSequence2(input) {
322
+ return isMultilineEnterSequence(input);
323
+ }
324
+ var COMPOSER_MAX_VISIBLE_LINES = 5;
325
+ var PROMPT_MARKER = "\u203A ";
326
+ var PROMPT_MARKER_CONTINUATION = " ".repeat(displayWidthOf(PROMPT_MARKER));
327
+ var PERMISSION_ACTION_ORDER = [
328
+ "allow_once",
329
+ "allow_always_tool",
330
+ "deny",
331
+ "details"
332
+ ];
333
+ var PASTE_THRESHOLD = 16;
334
+ var OWNER_PASTE_THRESHOLD = PASTE_THRESHOLD;
335
+ var PASTE_COMPLETION_TIMEOUT_MS = 100;
336
+ var DOUBLE_PRESS_WINDOW_MS = 1e3;
337
+ var HINT_NOTICE_DECAY_MS = 1500;
338
+ function Composer({ view, onInput, capability }) {
339
+ const [buffer, setBuffer] = useState(createEditBuffer());
340
+ const bufferRef = useRef(buffer);
341
+ const [slashSelection, setSlashSelection] = useState(0);
342
+ const [slashHidden, setSlashHidden] = useState(false);
343
+ const [permissionFocus, setPermissionFocus] = useState("allow_once");
344
+ const [hintNotice, setHintNotice] = useState(void 0);
345
+ const historyRef = useRef(createInputHistory());
346
+ const pasteChunksRef = useRef([]);
347
+ const pasteTimerRef = useRef(null);
348
+ const pastePendingRef = useRef(false);
349
+ const focusReportPrefixPendingRef = useRef(false);
350
+ const lastEscAtRef = useRef(0);
351
+ const lastCtrlCAtRef = useRef(0);
352
+ const hintTimerRef = useRef(null);
353
+ const chordBufferRef = useRef([]);
354
+ const undoRingRef = useRef(createUndoRing());
355
+ const stashRef = useRef(createPromptStash());
356
+ const maxWidth = view.viewMode === "task" || view.viewMode === "pending" ? taskComposerMaxWidth(view.width) : composerMaxWidth(view.width);
357
+ const noColor = view.themeMode === "no-color";
358
+ const theme = useMemo(() => createShellTheme(noColor), [noColor]);
359
+ const anchorRef = useRef(null);
360
+ const emitInput = useCallback(
361
+ (event) => {
362
+ Promise.resolve(onInput(event)).catch((error) => {
363
+ const message = error instanceof Error ? error.message : String(error);
364
+ setHintNotice(message);
365
+ });
366
+ },
367
+ [onInput]
368
+ );
369
+ const permissionActive = Boolean(view.permission);
370
+ const permissionActions = useMemo(
371
+ () => buildPermissionActions(view.language, view.permission?.actions),
372
+ [view.language, view.permission]
373
+ );
374
+ const configPanelActive = Boolean(
375
+ view.configPanel || view.helpPanel || view.btwPanel || view.sessionsPanel || view.backgroundTaskOverlay || view.historySearchPanel || view.shortcutPanel
376
+ );
377
+ const terminalInteractionModes = useMemo(
378
+ () => resolveTerminalInteractionModes({ capability, appOwnedScreen: false }),
379
+ [capability]
380
+ );
381
+ const text = bufferToString(buffer);
382
+ const commandPanelActive = Boolean(view.commandPanel);
383
+ const commandPanelConsumesInput = hasSelectableCommandPanelRows(view.commandPanel);
384
+ const slashHeadCurrent = useMemo(() => slashHead(text), [text]);
385
+ const isBareSlash = !permissionActive && text === "/";
386
+ const isSingleLineSlash = !permissionActive && text.startsWith("/") && !text.includes("\n") && text.length >= 2 && text !== "/?";
387
+ const slashCandidates = useMemo(() => {
388
+ if (isBareSlash) return getCoreSlashCandidates();
389
+ if (isSingleLineSlash) return getSlashPrefixCandidates(slashHeadCurrent);
390
+ return [];
391
+ }, [isBareSlash, isSingleLineSlash, slashHeadCurrent]);
392
+ const lastSlashHeadRef = useRef(slashHeadCurrent);
393
+ useEffect(() => {
394
+ if (!text.startsWith("/")) {
395
+ if (slashHidden) setSlashHidden(false);
396
+ lastSlashHeadRef.current = slashHeadCurrent;
397
+ return;
398
+ }
399
+ if (lastSlashHeadRef.current !== slashHeadCurrent) {
400
+ if (slashHidden) setSlashHidden(false);
401
+ lastSlashHeadRef.current = slashHeadCurrent;
402
+ }
403
+ }, [text, slashHeadCurrent, slashHidden]);
404
+ const slashSelectionClamped = slashCandidates.length === 0 ? 0 : Math.max(0, Math.min(slashSelection, slashCandidates.length - 1));
405
+ const resetBuffer = useCallback((nextText = "") => {
406
+ const next = createEditBuffer(nextText);
407
+ bufferRef.current = next;
408
+ setBuffer(next);
409
+ setSlashSelection(0);
410
+ }, []);
411
+ const setBufferAndResetSelection = useCallback((next) => {
412
+ undoRingRef.current = undoRingPush(undoRingRef.current, bufferRef.current);
413
+ bufferRef.current = next;
414
+ setBuffer(next);
415
+ setSlashSelection(0);
416
+ }, []);
417
+ const updateBufferAndResetSelection = useCallback(
418
+ (update) => {
419
+ undoRingRef.current = undoRingPush(undoRingRef.current, bufferRef.current);
420
+ const next = update(bufferRef.current);
421
+ bufferRef.current = next;
422
+ setBuffer(next);
423
+ setSlashSelection(0);
424
+ },
425
+ []
426
+ );
427
+ const submitPermissionAction = useCallback(
428
+ (id) => {
429
+ if (id === "cancel") {
430
+ emitInput({ type: "escape" });
431
+ return;
432
+ }
433
+ emitInput({ type: "permission-action", actionId: id });
434
+ },
435
+ [emitInput]
436
+ );
437
+ const showHintNotice = useCallback((notice) => {
438
+ setHintNotice(notice);
439
+ if (hintTimerRef.current) clearTimeout(hintTimerRef.current);
440
+ hintTimerRef.current = setTimeout(() => {
441
+ setHintNotice(void 0);
442
+ hintTimerRef.current = null;
443
+ }, HINT_NOTICE_DECAY_MS);
444
+ }, []);
445
+ const clearHintNotice = useCallback(() => {
446
+ if (hintTimerRef.current) {
447
+ clearTimeout(hintTimerRef.current);
448
+ hintTimerRef.current = null;
449
+ }
450
+ setHintNotice(void 0);
451
+ }, []);
452
+ const flushPaste = useCallback(() => {
453
+ const chunks = pasteChunksRef.current;
454
+ pasteChunksRef.current = [];
455
+ if (pasteTimerRef.current) {
456
+ clearTimeout(pasteTimerRef.current);
457
+ pasteTimerRef.current = null;
458
+ }
459
+ pastePendingRef.current = false;
460
+ if (chunks.length === 0) return;
461
+ const joined = sanitizeComposerInput(chunks.join(""));
462
+ if (!joined) return;
463
+ const next = bufferInsert(bufferRef.current, joined);
464
+ bufferRef.current = next;
465
+ setBuffer(next);
466
+ setSlashSelection(0);
467
+ }, []);
468
+ const cancelPaste = useCallback(() => {
469
+ pasteChunksRef.current = [];
470
+ if (pasteTimerRef.current) {
471
+ clearTimeout(pasteTimerRef.current);
472
+ pasteTimerRef.current = null;
473
+ }
474
+ pastePendingRef.current = false;
475
+ }, []);
476
+ const enqueuePasteChunk = useCallback(
477
+ (chunk) => {
478
+ pasteChunksRef.current.push(chunk);
479
+ pastePendingRef.current = true;
480
+ if (pasteTimerRef.current) clearTimeout(pasteTimerRef.current);
481
+ pasteTimerRef.current = setTimeout(flushPaste, PASTE_COMPLETION_TIMEOUT_MS);
482
+ },
483
+ [flushPaste]
484
+ );
485
+ useEffect(() => {
486
+ return () => {
487
+ if (pasteTimerRef.current) clearTimeout(pasteTimerRef.current);
488
+ if (hintTimerRef.current) clearTimeout(hintTimerRef.current);
489
+ };
490
+ }, []);
491
+ useInput(
492
+ (input, key) => {
493
+ if (input === "\x1B[I" || input === "\x1B[O" || input === "[I" || input === "[O") {
494
+ focusReportPrefixPendingRef.current = false;
495
+ return;
496
+ }
497
+ if (input === "\x1B[") {
498
+ focusReportPrefixPendingRef.current = true;
499
+ return;
500
+ }
501
+ if (focusReportPrefixPendingRef.current) {
502
+ focusReportPrefixPendingRef.current = false;
503
+ if (input === "I" || input === "O") return;
504
+ }
505
+ if (classifyTerminalInput(input) !== "keyboard") return;
506
+ const buffer2 = bufferRef.current;
507
+ const text2 = bufferToString(buffer2);
508
+ const terminalAction = normalizeTerminalInput(input, key);
509
+ const owner = selectInputOwner(input, key, {
510
+ permissionActive,
511
+ panelActive: configPanelActive || commandPanelActive,
512
+ panelInteractive: Boolean(
513
+ view.configPanel || view.helpPanel || view.btwPanel || view.sessionsPanel || view.backgroundTaskOverlay || view.historySearchPanel || view.shortcutPanel || view.commandPanel || commandPanelConsumesInput
514
+ ),
515
+ panelNumericShortcuts: Boolean(view.helpPanel),
516
+ panelSpaceAction: Boolean(view.btwPanel),
517
+ pastePending: pastePendingRef.current,
518
+ slashVisible: slashCandidates.length > 0 && !slashHidden
519
+ });
520
+ if (!permissionActive) {
521
+ const binding = resolveKeybinding(
522
+ view.keybindings ?? [],
523
+ "chat",
524
+ {
525
+ input,
526
+ ctrl: key.ctrl,
527
+ meta: key.meta,
528
+ shift: key.shift,
529
+ tab: key.tab,
530
+ escape: key.escape,
531
+ return: key.return,
532
+ backspace: key.backspace,
533
+ delete: key.delete
534
+ },
535
+ chordBufferRef.current
536
+ );
537
+ chordBufferRef.current = binding.chordBuffer;
538
+ if (binding.pending) return;
539
+ if (binding.action === "toggle-details") {
540
+ clearHintNotice();
541
+ emitInput({ type: "toggle-details" });
542
+ return;
543
+ }
544
+ if (binding.action === "cycle-permission-mode") {
545
+ emitInput({ type: "cycle-permission-mode" });
546
+ return;
547
+ }
548
+ if (binding.action === "clear-line") {
549
+ setBufferAndResetSelection(bufferClearLine(buffer2));
550
+ return;
551
+ }
552
+ if (binding.action === "delete-word-left") {
553
+ setBufferAndResetSelection(bufferDeleteWordLeft(buffer2));
554
+ return;
555
+ }
556
+ if (binding.action === "history-search") {
557
+ emitInput({ type: "history-search-open" });
558
+ return;
559
+ }
560
+ if (binding.action === "undo") {
561
+ const result = undoRingPop(undoRingRef.current);
562
+ undoRingRef.current = result.ring;
563
+ if (result.buffer) {
564
+ bufferRef.current = result.buffer;
565
+ setBuffer(result.buffer);
566
+ setSlashSelection(0);
567
+ }
568
+ return;
569
+ }
570
+ if (binding.action === "stash") {
571
+ const currentText = bufferToString(bufferRef.current);
572
+ const result = toggleStash(stashRef.current, currentText);
573
+ stashRef.current = result.stash;
574
+ if (result.bufferText !== void 0) {
575
+ resetBuffer(result.bufferText);
576
+ }
577
+ return;
578
+ }
579
+ if (binding.action === "external-editor") {
580
+ emitInput({ type: "external-editor" });
581
+ return;
582
+ }
583
+ if (binding.action === "shortcuts-panel") {
584
+ if (bufferToString(bufferRef.current).length === 0) {
585
+ emitInput({ type: "shortcuts-panel-open" });
586
+ return;
587
+ }
588
+ }
589
+ }
590
+ if (!permissionActive && key.downArrow && key.shift && (view.viewMode === "task" || view.viewMode === "pending")) {
591
+ emitInput({ type: "background-overlay-open" });
592
+ return;
593
+ }
594
+ if (key.ctrl && key.shift && input.toLowerCase() === "c") {
595
+ emitInput({ type: "copy-selection" });
596
+ return;
597
+ }
598
+ if (owner === "permission") {
599
+ if (key.escape) {
600
+ submitPermissionAction("cancel");
601
+ return;
602
+ }
603
+ if (key.return) {
604
+ submitPermissionAction(permissionFocus);
605
+ return;
606
+ }
607
+ if (key.tab && !key.shift) {
608
+ setPermissionFocus(cyclePermissionFocus(permissionActions, permissionFocus, 1));
609
+ return;
610
+ }
611
+ if (key.tab && key.shift) {
612
+ setPermissionFocus(cyclePermissionFocus(permissionActions, permissionFocus, -1));
613
+ return;
614
+ }
615
+ if (key.leftArrow || key.upArrow) {
616
+ setPermissionFocus(cyclePermissionFocus(permissionActions, permissionFocus, -1));
617
+ return;
618
+ }
619
+ if (key.rightArrow || key.downArrow) {
620
+ setPermissionFocus(cyclePermissionFocus(permissionActions, permissionFocus, 1));
621
+ return;
622
+ }
623
+ if (!key.ctrl && !key.meta && input && input.length === 1) {
624
+ const lower = input.toLowerCase();
625
+ if (lower === "y") {
626
+ submitPermissionAction(resolveActionId(permissionActions, "allow_once", "yes"));
627
+ return;
628
+ }
629
+ if (lower === "a") {
630
+ if (permissionActions.some((act) => act.id === "allow_always_tool")) {
631
+ submitPermissionAction("allow_always_tool");
632
+ return;
633
+ }
634
+ }
635
+ if (lower === "n") {
636
+ submitPermissionAction(resolveActionId(permissionActions, "deny", "no"));
637
+ return;
638
+ }
639
+ if (lower === "d") {
640
+ submitPermissionAction("details");
641
+ return;
642
+ }
643
+ }
644
+ return;
645
+ }
646
+ if (owner === "panel") {
647
+ if (key.escape) {
648
+ if (view.helpPanel) emitInput({ type: "help-close" });
649
+ else if (view.btwPanel) emitInput({ type: "btw-close" });
650
+ else if (view.sessionsPanel) emitInput({ type: "sessions-close" });
651
+ else if (view.backgroundTaskOverlay) emitInput({ type: "background-overlay-close" });
652
+ else if (view.historySearchPanel) emitInput({ type: "history-search-close" });
653
+ else if (view.shortcutPanel) emitInput({ type: "shortcuts-panel-close" });
654
+ else if (view.configPanel) emitInput({ type: "config-back" });
655
+ else if (view.commandPanel) emitInput({ type: "command-panel-close" });
656
+ else emitInput({ type: "escape" });
657
+ return;
658
+ }
659
+ if (view.historySearchPanel) {
660
+ if (key.return) emitInput({ type: "history-search-accept" });
661
+ else if (key.upArrow) emitInput({ type: "history-search-move", delta: -1 });
662
+ else if (key.downArrow) emitInput({ type: "history-search-move", delta: 1 });
663
+ else if (!key.ctrl && !key.meta && input.length > 0 && !key.return && !key.tab) {
664
+ const newQuery = (view.historySearchPanel.query ?? "") + input;
665
+ emitInput({ type: "history-search-input", query: newQuery });
666
+ } else if (key.backspace) {
667
+ const currentQuery = view.historySearchPanel.query ?? "";
668
+ emitInput({ type: "history-search-input", query: currentQuery.slice(0, -1) });
669
+ }
670
+ return;
671
+ }
672
+ if (view.shortcutPanel) {
673
+ emitInput({ type: "shortcuts-panel-close" });
674
+ return;
675
+ }
676
+ if (view.helpPanel) {
677
+ if (!key.ctrl && !key.meta && /^[1-9]$/.test(input)) {
678
+ const idx = Number(input) - 1;
679
+ if (idx < view.helpPanel.entries.length) {
680
+ emitInput({ type: "help-select", index: idx });
681
+ }
682
+ } else if (key.return) emitInput({ type: "help-enter" });
683
+ else if (key.upArrow) emitInput({ type: "help-move", delta: -1 });
684
+ else if (key.downArrow) emitInput({ type: "help-move", delta: 1 });
685
+ else if (key.tab || key.rightArrow) emitInput({ type: "help-switch-group", delta: 1 });
686
+ else if (key.leftArrow) emitInput({ type: "help-switch-group", delta: -1 });
687
+ return;
688
+ }
689
+ if (view.btwPanel) {
690
+ if (key.return || input === " ") emitInput({ type: "btw-close" });
691
+ return;
692
+ }
693
+ if (view.configPanel) {
694
+ if (key.return) {
695
+ if (view.configPanel.phase === "panel_list") {
696
+ const selected = view.configPanel.panels[view.configPanel.cursor];
697
+ if (selected) {
698
+ if (selected.id === "language") {
699
+ emitInput({ type: "config-enter" });
700
+ } else {
701
+ emitInput({ type: "config-submit", command: selected.slash });
702
+ }
703
+ }
704
+ } else {
705
+ const action = view.configPanel.actions[view.configPanel.actionCursor];
706
+ if (action) emitInput({ type: "config-submit", command: action.id });
707
+ }
708
+ } else if (key.upArrow) emitInput({ type: "config-move", delta: -1 });
709
+ else if (key.downArrow) emitInput({ type: "config-move", delta: 1 });
710
+ return;
711
+ }
712
+ if (view.sessionsPanel) {
713
+ if (view.sessionsPanel.mode === "search") {
714
+ if (key.escape) emitInput({ type: "sessions-search-close" });
715
+ else if (key.return) emitInput({ type: "sessions-search-close" });
716
+ else if (key.backspace || key.delete) emitInput({ type: "sessions-search-delete" });
717
+ else if (input && !key.ctrl && !key.meta && !key.tab) {
718
+ emitInput({ type: "sessions-search-input", input });
719
+ }
720
+ return;
721
+ }
722
+ if (view.sessionsPanel.mode === "preview") {
723
+ if (key.escape) emitInput({ type: "sessions-preview-close" });
724
+ return;
725
+ }
726
+ if (key.return) emitInput({ type: "sessions-resume" });
727
+ else if (key.upArrow) emitInput({ type: "sessions-move", delta: -1 });
728
+ else if (key.downArrow) emitInput({ type: "sessions-move", delta: 1 });
729
+ else if (input === "/" && !key.ctrl && !key.meta) {
730
+ emitInput({ type: "sessions-search" });
731
+ } else if (input === "v" && key.ctrl) {
732
+ emitInput({ type: "sessions-preview" });
733
+ }
734
+ return;
735
+ }
736
+ if (view.backgroundTaskOverlay) {
737
+ if (key.upArrow) emitInput({ type: "background-overlay-move", delta: -1 });
738
+ else if (key.downArrow) emitInput({ type: "background-overlay-move", delta: 1 });
739
+ else if (key.return) emitInput({ type: "background-overlay-toggle" });
740
+ else if (input.toLowerCase() === "x" && !key.ctrl && !key.meta) {
741
+ emitInput({ type: "background-overlay-stop" });
742
+ }
743
+ return;
744
+ }
745
+ if (commandPanelConsumesInput) {
746
+ if (key.upArrow) {
747
+ emitInput({ type: "command-panel-move", delta: -1 });
748
+ return;
749
+ }
750
+ if (key.downArrow) {
751
+ emitInput({ type: "command-panel-move", delta: 1 });
752
+ return;
753
+ }
754
+ if (key.return) {
755
+ emitInput({ type: "command-panel-toggle" });
756
+ return;
757
+ }
758
+ if (input.toLowerCase() === "x" && !key.ctrl && !key.meta) {
759
+ emitInput({ type: "command-panel-stop" });
760
+ return;
761
+ }
762
+ return;
763
+ }
764
+ if (view.commandPanel) return;
765
+ }
766
+ if (configPanelActive) return;
767
+ if (owner === "paste") {
768
+ if (pastePendingRef.current && key.return) {
769
+ enqueuePasteChunk("");
770
+ return;
771
+ }
772
+ if (pastePendingRef.current && key.escape) {
773
+ cancelPaste();
774
+ return;
775
+ }
776
+ enqueuePasteChunk(input);
777
+ return;
778
+ }
779
+ const slashVisible = slashCandidates.length > 0 && !slashHidden;
780
+ if (owner === "slash") {
781
+ if (terminalAction.type === "newline") {
782
+ updateBufferAndResetSelection((current) => bufferInsert(current, "\n"));
783
+ return;
784
+ }
785
+ if (key.escape) {
786
+ setSlashHidden(true);
787
+ setSlashSelection(-1);
788
+ return;
789
+ }
790
+ if (key.tab && !key.shift) {
791
+ if (slashSelection >= 0) {
792
+ const picked = slashCandidates[slashSelectionClamped];
793
+ if (picked) {
794
+ const spaceIndex = text2.indexOf(" ");
795
+ const args = spaceIndex >= 0 ? text2.slice(spaceIndex) : "";
796
+ const next = args ? `${picked.slash}${args}` : `${picked.slash} `;
797
+ resetBuffer(next);
798
+ setSlashHidden(false);
799
+ return;
800
+ }
801
+ }
802
+ return;
803
+ }
804
+ if (key.upArrow) {
805
+ if (slashSelection >= 0) {
806
+ setSlashSelection((current) => {
807
+ const safe = current < 0 ? 0 : current;
808
+ return safe === 0 ? slashCandidates.length - 1 : safe - 1;
809
+ });
810
+ }
811
+ return;
812
+ }
813
+ if (key.downArrow) {
814
+ if (slashSelection >= 0) {
815
+ setSlashSelection((current) => {
816
+ const safe = current < 0 ? 0 : current;
817
+ return safe >= slashCandidates.length - 1 ? 0 : safe + 1;
818
+ });
819
+ }
820
+ return;
821
+ }
822
+ if (key.return) {
823
+ if (slashSelection >= 0 && !text2.includes(" ")) {
824
+ const picked = slashCandidates[slashSelectionClamped];
825
+ if (picked && picked.slash !== text2) {
826
+ const submitText2 = picked.slash;
827
+ historyRef.current = historyAdd(historyRef.current, submitText2);
828
+ resetBuffer();
829
+ setSlashHidden(false);
830
+ clearHintNotice();
831
+ emitInput({ type: "submit", text: submitText2 });
832
+ return;
833
+ }
834
+ }
835
+ const submitText = text2.trim();
836
+ historyRef.current = historyAdd(historyRef.current, text2);
837
+ resetBuffer();
838
+ setSlashHidden(false);
839
+ clearHintNotice();
840
+ emitInput(submitText ? { type: "submit", text: submitText } : { type: "empty-submit" });
841
+ return;
842
+ }
843
+ return;
844
+ }
845
+ const inTaskMode = view.viewMode === "task" || view.viewMode === "pending";
846
+ const k = key;
847
+ if (inTaskMode && k.pageUp) {
848
+ emitInput({ type: "transcript-scroll", action: "halfPageUp" });
849
+ return;
850
+ }
851
+ if (inTaskMode && k.pageDown) {
852
+ emitInput({ type: "transcript-scroll", action: "halfPageDown" });
853
+ return;
854
+ }
855
+ if (inTaskMode && k.home && text2.length === 0) {
856
+ emitInput({ type: "transcript-scroll", action: "top" });
857
+ return;
858
+ }
859
+ if (inTaskMode && k.end && text2.length === 0) {
860
+ emitInput({ type: "transcript-scroll", action: "bottom" });
861
+ return;
862
+ }
863
+ if (terminalAction.type === "newline") {
864
+ updateBufferAndResetSelection((current) => bufferInsert(current, "\n"));
865
+ return;
866
+ }
867
+ if (key.return && text2.endsWith("\\")) {
868
+ const withoutBackslash = {
869
+ chars: buffer2.chars.slice(0, -1),
870
+ cursor: Math.max(0, buffer2.cursor - 1)
871
+ };
872
+ setBufferAndResetSelection(bufferInsert(withoutBackslash, "\n"));
873
+ return;
874
+ }
875
+ if (key.return) {
876
+ if (text2.length === 0 && view.agentProgressTree && view.agentProgressTree.cursor >= 0) {
877
+ emitInput({ type: "agent-tree-enter" });
878
+ return;
879
+ }
880
+ if (text2.length === 0 && view.taskSuggestions && view.taskSuggestions.length > 0) {
881
+ const index = Math.max(
882
+ 0,
883
+ Math.min(view.taskSuggestionCursor ?? 0, view.taskSuggestions.length - 1)
884
+ );
885
+ const suggestion = view.taskSuggestions[index];
886
+ if (suggestion) {
887
+ emitInput({ type: "task-suggestion-action", suggestionId: suggestion.id });
888
+ return;
889
+ }
890
+ }
891
+ const isSlashSubmit = text2.startsWith("/");
892
+ const setupActive = view.composer.setupActive;
893
+ if (view.composer.busy && !isSlashSubmit && !setupActive) {
894
+ showHintNotice(
895
+ view.composer.busyHint ?? (view.language === "en-US" ? "Still working on the previous request. Press Ctrl+C to interrupt, then send again." : "\u6B63\u5728\u5904\u7406\u4E0A\u4E00\u6761\uFF0C\u6309 Ctrl+C \u53EF\u4E2D\u65AD\uFF0C\u7A0D\u540E\u518D\u53D1\u3002")
896
+ );
897
+ return;
898
+ }
899
+ if (slashVisible && slashSelection >= 0 && !text2.includes(" ")) {
900
+ const picked = slashCandidates[slashSelectionClamped];
901
+ if (picked && picked.slash !== text2) {
902
+ const submitText2 = picked.slash;
903
+ historyRef.current = historyAdd(historyRef.current, submitText2);
904
+ resetBuffer();
905
+ setSlashHidden(false);
906
+ clearHintNotice();
907
+ emitInput({ type: "submit", text: submitText2 });
908
+ return;
909
+ }
910
+ }
911
+ const submitText = text2.trim();
912
+ historyRef.current = historyAdd(historyRef.current, text2);
913
+ resetBuffer();
914
+ setSlashHidden(false);
915
+ clearHintNotice();
916
+ emitInput(submitText ? { type: "submit", text: submitText } : { type: "empty-submit" });
917
+ return;
918
+ }
919
+ if (key.tab && !key.shift) {
920
+ if (slashVisible && slashSelection >= 0) {
921
+ const picked = slashCandidates[slashSelectionClamped];
922
+ if (picked) {
923
+ const spaceIndex = text2.indexOf(" ");
924
+ const args = spaceIndex >= 0 ? text2.slice(spaceIndex) : "";
925
+ const next = args ? `${picked.slash}${args}` : `${picked.slash} `;
926
+ resetBuffer(next);
927
+ setSlashHidden(false);
928
+ return;
929
+ }
930
+ }
931
+ const ghost = computeGhostText(
932
+ text2,
933
+ slashCandidates.map((c) => ({ slash: c.slash, description: c.descriptionZh }))
934
+ );
935
+ if (ghost) {
936
+ resetBuffer(`${text2}${ghost} `);
937
+ return;
938
+ }
939
+ return;
940
+ }
941
+ if (key.tab && key.shift) {
942
+ emitInput({ type: "cycle-permission-mode" });
943
+ return;
944
+ }
945
+ if (key.escape) {
946
+ if (slashVisible && slashSelection >= 0) {
947
+ setSlashHidden(true);
948
+ setSlashSelection(-1);
949
+ return;
950
+ }
951
+ if (text2.length === 0 && view.agentProgressTree && view.agentProgressTree.cursor >= 0) {
952
+ emitInput({ type: "agent-tree-escape" });
953
+ return;
954
+ }
955
+ if (view.composer.busy) {
956
+ clearHintNotice();
957
+ emitInput({ type: "interrupt" });
958
+ return;
959
+ }
960
+ if (text2.length > 0) {
961
+ const now = Date.now();
962
+ if (now - lastEscAtRef.current < DOUBLE_PRESS_WINDOW_MS) {
963
+ lastEscAtRef.current = 0;
964
+ resetBuffer();
965
+ clearHintNotice();
966
+ return;
967
+ }
968
+ lastEscAtRef.current = now;
969
+ showHintNotice(view.language === "en-US" ? "Esc again to clear" : "\u518D\u6309 Esc \u6E05\u7A7A\u8F93\u5165");
970
+ return;
971
+ }
972
+ if (view.commandPanel || view.helpPanel || view.configPanel || view.btwPanel || view.sessionsPanel) {
973
+ clearHintNotice();
974
+ return;
975
+ }
976
+ clearHintNotice();
977
+ emitInput(view.composer.busy ? { type: "interrupt" } : { type: "escape" });
978
+ return;
979
+ }
980
+ if (text2.length === 0 && input.toLowerCase() === "x" && !key.ctrl && !key.meta && view.agentProgressTree && view.agentProgressTree.cursor >= 0) {
981
+ emitInput({ type: "agent-tree-close" });
982
+ return;
983
+ }
984
+ if (key.leftArrow || key.ctrl && input === "b") {
985
+ if (key.ctrl && key.leftArrow || key.meta) {
986
+ setBufferAndResetSelection(bufferWordLeft(buffer2));
987
+ } else {
988
+ setBufferAndResetSelection(bufferMoveLeft(buffer2));
989
+ }
990
+ return;
991
+ }
992
+ if (key.rightArrow || key.ctrl && input === "f") {
993
+ if (key.ctrl && key.rightArrow || key.meta) {
994
+ setBufferAndResetSelection(bufferWordRight(buffer2));
995
+ } else {
996
+ setBufferAndResetSelection(bufferMoveRight(buffer2));
997
+ }
998
+ return;
999
+ }
1000
+ if (key.upArrow) {
1001
+ if (slashVisible && slashSelection >= 0) {
1002
+ setSlashSelection((current) => {
1003
+ const safe = current < 0 ? 0 : current;
1004
+ return safe === 0 ? slashCandidates.length - 1 : safe - 1;
1005
+ });
1006
+ return;
1007
+ }
1008
+ if (text2.length === 0 && view.taskSuggestions && view.taskSuggestions.length > 0) {
1009
+ emitInput({ type: "task-suggestion-move", delta: -1 });
1010
+ return;
1011
+ }
1012
+ if (text2.length === 0 && view.agentProgressTree && view.agentProgressTree.rows.length > 0) {
1013
+ emitInput({ type: "agent-tree-move", delta: -1 });
1014
+ return;
1015
+ }
1016
+ if (text2.length === 0 && inTaskMode) {
1017
+ emitInput({ type: "transcript-scroll", action: "lineUp" });
1018
+ return;
1019
+ }
1020
+ const moved = bufferMoveVisualUp(buffer2, maxWidth);
1021
+ if (moved.cursor !== buffer2.cursor) {
1022
+ setBufferAndResetSelection(moved);
1023
+ } else {
1024
+ const next = historyUp(historyRef.current, text2);
1025
+ if (next) {
1026
+ historyRef.current = next;
1027
+ const histText = historyCurrentText(next);
1028
+ if (histText !== void 0) resetBuffer(histText);
1029
+ }
1030
+ }
1031
+ return;
1032
+ }
1033
+ if (key.downArrow) {
1034
+ if (slashVisible && slashSelection >= 0) {
1035
+ setSlashSelection((current) => {
1036
+ const safe = current < 0 ? 0 : current;
1037
+ return safe >= slashCandidates.length - 1 ? 0 : safe + 1;
1038
+ });
1039
+ return;
1040
+ }
1041
+ if (text2.length === 0 && view.taskSuggestions && view.taskSuggestions.length > 0) {
1042
+ emitInput({ type: "task-suggestion-move", delta: 1 });
1043
+ return;
1044
+ }
1045
+ if (text2.length === 0 && view.agentProgressTree && view.agentProgressTree.rows.length > 0) {
1046
+ emitInput({ type: "agent-tree-move", delta: 1 });
1047
+ return;
1048
+ }
1049
+ if (text2.length === 0 && inTaskMode) {
1050
+ emitInput({ type: "transcript-scroll", action: "lineDown" });
1051
+ return;
1052
+ }
1053
+ const moved = bufferMoveVisualDown(buffer2, maxWidth);
1054
+ if (moved.cursor !== buffer2.cursor) {
1055
+ setBufferAndResetSelection(moved);
1056
+ } else {
1057
+ const next = historyDown(historyRef.current);
1058
+ if (next) {
1059
+ historyRef.current = next;
1060
+ const histText = historyCurrentText(next);
1061
+ resetBuffer(histText ?? next.draft);
1062
+ }
1063
+ }
1064
+ return;
1065
+ }
1066
+ if (key.home) {
1067
+ setBufferAndResetSelection(bufferHome(buffer2));
1068
+ return;
1069
+ }
1070
+ if (key.end) {
1071
+ setBufferAndResetSelection(bufferEnd(buffer2));
1072
+ return;
1073
+ }
1074
+ if (key.ctrl && input === "a") {
1075
+ setBufferAndResetSelection(bufferHome(buffer2));
1076
+ return;
1077
+ }
1078
+ if (key.ctrl && input === "e") {
1079
+ setBufferAndResetSelection(bufferEnd(buffer2));
1080
+ return;
1081
+ }
1082
+ if (key.ctrl && input === "u") {
1083
+ setBufferAndResetSelection(bufferClearLine(buffer2));
1084
+ return;
1085
+ }
1086
+ if (key.ctrl && input === "k") {
1087
+ setBufferAndResetSelection(bufferKillToEnd(buffer2));
1088
+ return;
1089
+ }
1090
+ if (key.ctrl && input === "w") {
1091
+ setBufferAndResetSelection(bufferDeleteWordLeft(buffer2));
1092
+ return;
1093
+ }
1094
+ if (key.ctrl && input === "c") {
1095
+ if (text2.length > 0) {
1096
+ const now = Date.now();
1097
+ if (now - lastCtrlCAtRef.current < DOUBLE_PRESS_WINDOW_MS) {
1098
+ lastCtrlCAtRef.current = 0;
1099
+ resetBuffer();
1100
+ clearHintNotice();
1101
+ return;
1102
+ }
1103
+ lastCtrlCAtRef.current = now;
1104
+ showHintNotice(
1105
+ view.language === "en-US" ? "Ctrl+C again to clear" : "\u518D\u6309 Ctrl+C \u6E05\u7A7A\u8F93\u5165"
1106
+ );
1107
+ return;
1108
+ }
1109
+ clearHintNotice();
1110
+ emitInput({ type: "interrupt" });
1111
+ return;
1112
+ }
1113
+ if (key.ctrl && input === "v") {
1114
+ return;
1115
+ }
1116
+ if (key.ctrl && input === "o") {
1117
+ clearHintNotice();
1118
+ emitInput({ type: "toggle-details" });
1119
+ return;
1120
+ }
1121
+ if (terminalAction.type === "backspace") {
1122
+ setBufferAndResetSelection(bufferBackspace(buffer2));
1123
+ return;
1124
+ }
1125
+ if (terminalAction.type === "delete") {
1126
+ setBufferAndResetSelection(bufferDelete(buffer2));
1127
+ return;
1128
+ }
1129
+ if (terminalAction.type === "delete-word-left") {
1130
+ setBufferAndResetSelection(bufferDeleteWordLeft(buffer2));
1131
+ return;
1132
+ }
1133
+ if (terminalAction.type === "text" && terminalAction.text) {
1134
+ updateBufferAndResetSelection((current) => bufferInsert(current, terminalAction.text));
1135
+ }
1136
+ },
1137
+ { isActive: true }
1138
+ );
1139
+ const placeholderText = view.permission || view.composer.setupActive ? view.composer.placeholder : view.viewMode === "task" || view.viewMode === "pending" ? view.composer.taskPlaceholder : view.composer.placeholder;
1140
+ const composerInnerWidth = Math.max(8, maxWidth - 4);
1141
+ const { lines, truncatedAbove, truncatedBelow, cursorCol, cursorRow } = useMemo(
1142
+ () => formatComposerRenderLines({
1143
+ buffer,
1144
+ placeholder: placeholderText,
1145
+ masking: view.composer.masking,
1146
+ noColor,
1147
+ maxWidth: composerInnerWidth
1148
+ }),
1149
+ [buffer, placeholderText, view.composer.masking, noColor, composerInnerWidth]
1150
+ );
1151
+ void truncatedAbove;
1152
+ void truncatedBelow;
1153
+ const showSuggestions = !permissionActive && slashCandidates.length > 0 && slashSelection >= 0 && !slashHidden;
1154
+ const declaredRow = composerCursorAnchorRowOffset({
1155
+ textAnchorRowBase: view.viewMode === "home" ? 0 : 1,
1156
+ permissionActive,
1157
+ permissionActionCount: permissionActions.length,
1158
+ showSuggestions,
1159
+ slashCandidateCount: slashCandidates.length,
1160
+ cursorRow
1161
+ });
1162
+ useAnchoredCursor(
1163
+ permissionActive ? null : { row: declaredRow, col: cursorCol },
1164
+ anchorRef,
1165
+ capability
1166
+ );
1167
+ const placeholderColor = noColor ? void 0 : "gray";
1168
+ const color = text ? void 0 : placeholderColor;
1169
+ const ghostSuffix = useMemo(() => {
1170
+ if (permissionActive || slashHidden) return void 0;
1171
+ return computeGhostText(
1172
+ text,
1173
+ slashCandidates.map((c) => ({ slash: c.slash, description: c.descriptionZh }))
1174
+ );
1175
+ }, [text, slashCandidates, permissionActive, slashHidden]);
1176
+ const showUnknownHint = false;
1177
+ return /* @__PURE__ */ jsxs(
1178
+ Box,
1179
+ {
1180
+ flexDirection: "column",
1181
+ width: maxWidth,
1182
+ borderStyle: "round",
1183
+ borderColor: theme.border ?? theme.muted,
1184
+ paddingLeft: 2,
1185
+ paddingRight: 1,
1186
+ children: [
1187
+ permissionActive && view.permission ? /* @__PURE__ */ jsx(
1188
+ PermissionControl,
1189
+ {
1190
+ permission: view.permission,
1191
+ actions: permissionActions,
1192
+ focused: permissionFocus,
1193
+ theme,
1194
+ width: composerInnerWidth,
1195
+ language: view.language
1196
+ }
1197
+ ) : null,
1198
+ showSuggestions ? /* @__PURE__ */ jsx(
1199
+ SlashSuggestions,
1200
+ {
1201
+ candidates: slashCandidates,
1202
+ selectedIndex: slashSelectionClamped,
1203
+ theme,
1204
+ language: view.language,
1205
+ width: composerInnerWidth,
1206
+ hint: view.language === "en-US" ? "Tab accept \xB7 \u2191\u2193 pick \xB7 Esc hide \xB7 Enter submit" : "Tab \u9009\u4E2D \xB7 \u2191\u2193 \u5207\u6362 \xB7 Esc \u9690\u85CF \xB7 Enter \u63D0\u4EA4"
1207
+ }
1208
+ ) : null,
1209
+ /* @__PURE__ */ jsxs(Box, { width: "100%", flexDirection: "row", alignItems: "flex-start", children: [
1210
+ /* @__PURE__ */ jsx(Text, { color: theme.muted, dimColor: !text, children: PROMPT_MARKER }),
1211
+ /* @__PURE__ */ jsx(
1212
+ Box,
1213
+ {
1214
+ ref: anchorRef,
1215
+ flexDirection: "column",
1216
+ width: Math.max(4, composerInnerWidth - displayWidthOf(PROMPT_MARKER)),
1217
+ children: lines.map((line, index) => {
1218
+ return /* @__PURE__ */ jsxs(Text, { color, bold: Boolean(text), children: [
1219
+ sliceWidth(line, Math.max(4, composerInnerWidth - displayWidthOf(PROMPT_MARKER))),
1220
+ index === lines.length - 1 && ghostSuffix ? /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: ghostSuffix }) : null
1221
+ ] }, `${index}-${line}`);
1222
+ })
1223
+ }
1224
+ )
1225
+ ] }),
1226
+ showUnknownHint ? /* @__PURE__ */ jsx(Text, { color: theme.muted, children: fitText(formatUnknownSlashCommand(text, view.language), composerInnerWidth) }) : null,
1227
+ hintNotice ? /* @__PURE__ */ jsx(Text, { color: theme.muted, children: fitText(hintNotice, composerInnerWidth) }) : null
1228
+ ]
1229
+ }
1230
+ );
1231
+ }
1232
+ function PermissionControl({
1233
+ permission,
1234
+ actions,
1235
+ focused,
1236
+ theme,
1237
+ width,
1238
+ language
1239
+ }) {
1240
+ const isEn = language === "en-US";
1241
+ const cardWidth = Math.min(width, 76);
1242
+ const innerWidth = Math.max(20, cardWidth - 4);
1243
+ const headline = isEn ? "Permission requested" : "\u9700\u8981\u60A8\u6388\u6743";
1244
+ const summaryLine = permission.actionSummary && permission.actionSummary.length > 0 ? permission.actionSummary : isEn ? `Use tool: ${permission.toolName}` : `\u4F7F\u7528\u5DE5\u5177\uFF1A${permission.toolName}`;
1245
+ return /* @__PURE__ */ jsxs(
1246
+ Box,
1247
+ {
1248
+ flexDirection: "column",
1249
+ borderStyle: "single",
1250
+ borderColor: theme.permission ?? theme.border,
1251
+ paddingX: 1,
1252
+ width: cardWidth,
1253
+ children: [
1254
+ /* @__PURE__ */ jsx(Text, { bold: true, color: theme.permission ?? theme.assistantText ?? theme.brand, children: fitText(headline, innerWidth) }),
1255
+ /* @__PURE__ */ jsx(Text, { color: theme.muted, children: fitText(summaryLine, innerWidth) }),
1256
+ /* @__PURE__ */ jsx(Text, { color: theme.dim ?? theme.muted, dimColor: true, children: "\u2500".repeat(Math.min(innerWidth, 60)) }),
1257
+ /* @__PURE__ */ jsx(PermissionActionRow, { actions, focused, theme, width: innerWidth }),
1258
+ /* @__PURE__ */ jsx(Text, { color: theme.dim ?? theme.muted, dimColor: true, children: fitText(
1259
+ isEn ? "Enter confirm \xB7 Tab switch \xB7 d details \xB7 Esc cancel" : "Enter \u786E\u8BA4 \xB7 Tab \u5207\u6362 \xB7 d \u8BE6\u60C5 \xB7 Esc \u53D6\u6D88",
1260
+ innerWidth
1261
+ ) })
1262
+ ]
1263
+ }
1264
+ );
1265
+ }
1266
+ function PermissionActionRow({
1267
+ actions,
1268
+ focused,
1269
+ theme,
1270
+ width
1271
+ }) {
1272
+ const segments = actions.map((action) => {
1273
+ const isFocused = action.id === focused;
1274
+ const shortcut = action.shortcut ? ` (${action.shortcut})` : "";
1275
+ const text = isFocused ? `[ ${action.label}${shortcut} ]` : ` ${action.label}${shortcut} `;
1276
+ return { text, focused: isFocused, id: action.id };
1277
+ });
1278
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", width, children: segments.map((s) => /* @__PURE__ */ jsx(
1279
+ Text,
1280
+ {
1281
+ color: s.focused ? void 0 : theme.muted,
1282
+ backgroundColor: s.focused && theme.mode !== "no-color" ? theme.permission : void 0,
1283
+ inverse: s.focused,
1284
+ children: fitText(s.text, Math.max(8, width - 2))
1285
+ },
1286
+ s.id
1287
+ )) });
1288
+ }
1289
+ function buildPermissionActions(language, actions) {
1290
+ if (actions && actions.length > 0) {
1291
+ return actions;
1292
+ }
1293
+ const isEn = language === "en-US";
1294
+ return [
1295
+ { id: "allow_once", label: isEn ? "Yes" : "\u662F", shortcut: "y" },
1296
+ {
1297
+ id: "allow_always_tool",
1298
+ label: isEn ? "Allow future similar actions" : "\u5141\u8BB8\u4EE5\u540E\u8FD9\u7C7B\u64CD\u4F5C",
1299
+ shortcut: "a"
1300
+ },
1301
+ { id: "deny", label: isEn ? "No" : "\u5426", shortcut: "n" },
1302
+ { id: "details", label: isEn ? "Details" : "\u8BE6\u60C5", shortcut: "d" }
1303
+ ];
1304
+ }
1305
+ function cyclePermissionFocus(actions, current, delta) {
1306
+ const order = actions.map((a) => a.id);
1307
+ const ids = order.length > 0 ? order : PERMISSION_ACTION_ORDER;
1308
+ const idx = ids.indexOf(current);
1309
+ const safeIdx = idx < 0 ? 0 : idx;
1310
+ const next = (safeIdx + delta + ids.length) % ids.length;
1311
+ return ids[next] ?? ids[0] ?? "allow_once";
1312
+ }
1313
+ function resolveActionId(actions, primary, legacy) {
1314
+ if (actions.some((a) => a.id === primary)) return primary;
1315
+ if (actions.some((a) => a.id === legacy)) return legacy;
1316
+ return primary;
1317
+ }
1318
+ function slashHead(value) {
1319
+ const space = value.indexOf(" ");
1320
+ return space >= 0 ? value.slice(0, space) : value;
1321
+ }
1322
+ function formatComposerRenderLines({
1323
+ buffer,
1324
+ placeholder,
1325
+ masking,
1326
+ noColor,
1327
+ maxWidth
1328
+ }) {
1329
+ void noColor;
1330
+ const text = bufferToString(buffer);
1331
+ const displayText = text ? masking ? "*".repeat(buffer.chars.length) : text : "";
1332
+ if (!displayText) {
1333
+ return {
1334
+ lines: [placeholder],
1335
+ truncatedAbove: 0,
1336
+ truncatedBelow: 0,
1337
+ cursorCol: 0,
1338
+ cursorRow: 0
1339
+ };
1340
+ }
1341
+ const rawLines = displayText.split("\n");
1342
+ const { row: cursorLineIndex, col: cursorCharCol } = getCursorLinePosition(buffer);
1343
+ const composerWidth = Math.max(8, maxWidth ?? 80);
1344
+ const softLines = [];
1345
+ let cursorSoftIndex = 0;
1346
+ let cursorOutCol = 0;
1347
+ for (let rawIndex = 0; rawIndex < rawLines.length; rawIndex++) {
1348
+ const rawLine = rawLines[rawIndex] ?? "";
1349
+ const chars = Array.from(masking ? "*".repeat(Array.from(rawLine).length) : rawLine);
1350
+ let startChar = 0;
1351
+ while (startChar < chars.length || chars.length === 0 && startChar === 0) {
1352
+ const budget = Math.max(4, composerWidth - displayWidthOf(PROMPT_MARKER));
1353
+ let width = 0;
1354
+ let endChar = startChar;
1355
+ while (endChar < chars.length) {
1356
+ const next = charWidth(chars[endChar] ?? "");
1357
+ if (width > 0 && width + next > budget) break;
1358
+ width += next;
1359
+ endChar++;
1360
+ }
1361
+ if (endChar === startChar && chars.length > 0) endChar++;
1362
+ const text2 = chars.slice(startChar, endChar).join("");
1363
+ const softIndex = softLines.length;
1364
+ softLines.push({ text: text2, rawLineIndex: rawIndex, startChar, endChar });
1365
+ if (rawIndex === cursorLineIndex && cursorCharCol >= startChar && cursorCharCol <= endChar) {
1366
+ cursorSoftIndex = softIndex;
1367
+ let cursorWidth = 0;
1368
+ for (let i = startChar; i < cursorCharCol && i < chars.length; i++) {
1369
+ cursorWidth += charWidth(chars[i] ?? "");
1370
+ }
1371
+ cursorOutCol = cursorWidth;
1372
+ }
1373
+ if (chars.length === 0) break;
1374
+ startChar = endChar;
1375
+ }
1376
+ }
1377
+ const totalLines = softLines.length;
1378
+ let startLine = 0;
1379
+ let endLineExclusive = totalLines;
1380
+ if (totalLines > COMPOSER_MAX_VISIBLE_LINES) {
1381
+ const half = Math.floor(COMPOSER_MAX_VISIBLE_LINES / 2);
1382
+ startLine = Math.max(0, cursorSoftIndex - half);
1383
+ endLineExclusive = startLine + COMPOSER_MAX_VISIBLE_LINES;
1384
+ if (endLineExclusive > totalLines) {
1385
+ endLineExclusive = totalLines;
1386
+ startLine = Math.max(0, endLineExclusive - COMPOSER_MAX_VISIBLE_LINES);
1387
+ }
1388
+ }
1389
+ const renderedLines = softLines.slice(startLine, endLineExclusive).map((line) => line.text);
1390
+ const truncatedAbove = startLine;
1391
+ const truncatedBelow = totalLines - endLineExclusive;
1392
+ const cursorVisibleRow = Math.max(
1393
+ 0,
1394
+ Math.min(cursorSoftIndex - startLine, renderedLines.length - 1)
1395
+ );
1396
+ return {
1397
+ lines: renderedLines,
1398
+ truncatedAbove,
1399
+ truncatedBelow,
1400
+ cursorCol: maxWidth && cursorOutCol > maxWidth ? maxWidth : cursorOutCol,
1401
+ cursorRow: cursorVisibleRow
1402
+ };
1403
+ }
1404
+ function sliceWidth(value, max) {
1405
+ let width = 0;
1406
+ let result = "";
1407
+ for (const ch of value) {
1408
+ const next = width + charWidth(ch);
1409
+ if (next > max) break;
1410
+ result += ch;
1411
+ width = next;
1412
+ }
1413
+ return result;
1414
+ }
1415
+ function getCursorLinePosition(buffer) {
1416
+ let row = 0;
1417
+ let col = 0;
1418
+ for (let i = 0; i < buffer.cursor && i < buffer.chars.length; i++) {
1419
+ if (buffer.chars[i] === "\n") {
1420
+ row++;
1421
+ col = 0;
1422
+ } else {
1423
+ col++;
1424
+ }
1425
+ }
1426
+ return { row, col };
1427
+ }
1428
+ function displayWidthOf(value) {
1429
+ let width = 0;
1430
+ for (const char of value) {
1431
+ width += charWidth(char);
1432
+ }
1433
+ return width;
1434
+ }
1435
+ function splitLineAtDisplayCol(line, col) {
1436
+ const chars = Array.from(line);
1437
+ let acc = 0;
1438
+ let i = 0;
1439
+ for (; i < chars.length; i++) {
1440
+ const ch = chars[i] ?? "";
1441
+ const w = charWidth(ch);
1442
+ if (acc + w > col) break;
1443
+ acc += w;
1444
+ }
1445
+ if (i >= chars.length) {
1446
+ return { before: chars.join(""), cursorChar: "", after: "" };
1447
+ }
1448
+ const before = chars.slice(0, i).join("");
1449
+ const cursorChar = chars[i] ?? " ";
1450
+ const after = chars.slice(i + 1).join("");
1451
+ return { before, cursorChar, after };
1452
+ }
1453
+ function composerCursorAnchorRowOffset({
1454
+ textAnchorRowBase = 1,
1455
+ permissionActive,
1456
+ permissionActionCount,
1457
+ showSuggestions,
1458
+ slashCandidateCount,
1459
+ cursorRow
1460
+ }) {
1461
+ let offset = 0;
1462
+ if (permissionActive) {
1463
+ offset += 2 + Math.max(0, permissionActionCount) + 2;
1464
+ }
1465
+ if (showSuggestions) {
1466
+ offset += Math.max(0, slashCandidateCount) + 1;
1467
+ }
1468
+ return offset + Math.max(0, textAnchorRowBase) + Math.max(0, cursorRow);
1469
+ }
1470
+ function hasSelectableCommandPanelRows(panel) {
1471
+ return Boolean(
1472
+ panel?.sections?.some(
1473
+ (section) => section.rows.some(
1474
+ (row) => typeof row !== "string" && row.selectable !== false && Boolean(row.taskRef)
1475
+ )
1476
+ )
1477
+ );
1478
+ }
1479
+ function handleComposerInput(text, input, key) {
1480
+ const normalized = normalizeTerminalInput(input, {
1481
+ backspace: key.backspace === true,
1482
+ delete: key.delete === true,
1483
+ ctrl: key.ctrl === true,
1484
+ meta: key.meta === true,
1485
+ return: key.return === true,
1486
+ shift: key.shift === true
1487
+ });
1488
+ if (key.escape) {
1489
+ return { kind: "emit", event: { type: "escape" }, nextText: "" };
1490
+ }
1491
+ if (normalized.type === "newline") {
1492
+ return { kind: "append", text: "\n" };
1493
+ }
1494
+ if (key.return) {
1495
+ const submitted = text.trim();
1496
+ return {
1497
+ kind: "emit",
1498
+ event: submitted ? { type: "submit", text: submitted } : { type: "empty-submit" },
1499
+ nextText: ""
1500
+ };
1501
+ }
1502
+ if (normalized.type === "backspace" || normalized.type === "delete") {
1503
+ return { kind: "set", text: Array.from(text).slice(0, -1).join("") };
1504
+ }
1505
+ if (normalized.type === "ignore") {
1506
+ return { kind: "ignore" };
1507
+ }
1508
+ if (normalized.type === "text") {
1509
+ return { kind: "append", text: normalized.text };
1510
+ }
1511
+ return { kind: "ignore" };
1512
+ }
1513
+
1514
+ export {
1515
+ createEditBuffer,
1516
+ bufferToString,
1517
+ bufferDisplayWidth,
1518
+ bufferInsert,
1519
+ bufferBackspace,
1520
+ bufferDelete,
1521
+ bufferMoveLeft,
1522
+ bufferMoveRight,
1523
+ bufferHome,
1524
+ bufferEnd,
1525
+ bufferWordLeft,
1526
+ bufferWordRight,
1527
+ bufferDeleteWordLeft,
1528
+ bufferClearLine,
1529
+ bufferKillToEnd,
1530
+ bufferMoveUp,
1531
+ bufferMoveDown,
1532
+ bufferMoveVisualUp,
1533
+ bufferMoveVisualDown,
1534
+ sanitizeComposerInput,
1535
+ createInputHistory,
1536
+ historyAdd,
1537
+ historyUp,
1538
+ historyDown,
1539
+ historyCurrentText,
1540
+ shouldEnterPastePath,
1541
+ selectInputOwner,
1542
+ isNavigationKey,
1543
+ isVerticalNavigationKey,
1544
+ OWNER_PRIORITY,
1545
+ shouldOwnerBePaste,
1546
+ isDoublePressWithin,
1547
+ shouldUnstickSlashHidden,
1548
+ isMultilineEnterSequence2 as isMultilineEnterSequence,
1549
+ OWNER_PASTE_THRESHOLD,
1550
+ Composer,
1551
+ formatComposerRenderLines,
1552
+ splitLineAtDisplayCol,
1553
+ composerCursorAnchorRowOffset,
1554
+ handleComposerInput
1555
+ };