@waq666/pneuma 0.0.0-stage → 0.7.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 (687) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +144 -2
  3. package/bin/dsc.js +91 -0
  4. package/bin/headless.cjs +40 -0
  5. package/lib/adapter/core-runtime.d.ts +11 -0
  6. package/lib/adapter/core-runtime.js +259 -0
  7. package/lib/adapter/host.d.ts +18 -0
  8. package/lib/adapter/host.js +14 -0
  9. package/lib/adapter/runtime.d.ts +15 -0
  10. package/lib/adapter/runtime.js +290 -0
  11. package/lib/adapter/transcript.d.ts +184 -0
  12. package/lib/adapter/transcript.js +605 -0
  13. package/lib/app/AgentsOverlay.d.ts +18 -0
  14. package/lib/app/AgentsOverlay.js +63 -0
  15. package/lib/app/App.d.ts +13 -0
  16. package/lib/app/App.js +1498 -0
  17. package/lib/app/ApprovalCard.d.ts +12 -0
  18. package/lib/app/ApprovalCard.js +76 -0
  19. package/lib/app/AskCard.d.ts +20 -0
  20. package/lib/app/AskCard.js +45 -0
  21. package/lib/app/ChatView.d.ts +32 -0
  22. package/lib/app/ChatView.js +198 -0
  23. package/lib/app/Composer.d.ts +50 -0
  24. package/lib/app/Composer.js +282 -0
  25. package/lib/app/DiffBlock.d.ts +6 -0
  26. package/lib/app/DiffBlock.js +37 -0
  27. package/lib/app/MarkdownView.d.ts +6 -0
  28. package/lib/app/MarkdownView.js +99 -0
  29. package/lib/app/ModelPicker.d.ts +7 -0
  30. package/lib/app/ModelPicker.js +18 -0
  31. package/lib/app/PlanReviewCard.d.ts +13 -0
  32. package/lib/app/PlanReviewCard.js +54 -0
  33. package/lib/app/PresetPicker.d.ts +11 -0
  34. package/lib/app/PresetPicker.js +19 -0
  35. package/lib/app/PreviewOverlay.d.ts +14 -0
  36. package/lib/app/PreviewOverlay.js +22 -0
  37. package/lib/app/SessionPicker.d.ts +43 -0
  38. package/lib/app/SessionPicker.js +56 -0
  39. package/lib/app/SettingsOverlay.d.ts +32 -0
  40. package/lib/app/SettingsOverlay.js +157 -0
  41. package/lib/app/SkillsPicker.d.ts +7 -0
  42. package/lib/app/SkillsPicker.js +19 -0
  43. package/lib/app/StatusBar.d.ts +22 -0
  44. package/lib/app/StatusBar.js +272 -0
  45. package/lib/app/TaskStrips.d.ts +13 -0
  46. package/lib/app/TaskStrips.js +40 -0
  47. package/lib/app/ToolCard.d.ts +5 -0
  48. package/lib/app/ToolCard.js +40 -0
  49. package/lib/app/TranscriptOverlay.d.ts +12 -0
  50. package/lib/app/TranscriptOverlay.js +17 -0
  51. package/lib/app/Welcome.d.ts +6 -0
  52. package/lib/app/Welcome.js +66 -0
  53. package/lib/app/attach.d.ts +16 -0
  54. package/lib/app/attach.js +58 -0
  55. package/lib/app/click.d.ts +27 -0
  56. package/lib/app/click.js +89 -0
  57. package/lib/app/clipboard-image.d.ts +11 -0
  58. package/lib/app/clipboard-image.js +66 -0
  59. package/lib/app/cursor.d.ts +4 -0
  60. package/lib/app/cursor.js +24 -0
  61. package/lib/app/hello.d.ts +11 -0
  62. package/lib/app/hello.js +8 -0
  63. package/lib/app/history-store.d.ts +4 -0
  64. package/lib/app/history-store.js +41 -0
  65. package/lib/app/image-blocks.d.ts +12 -0
  66. package/lib/app/image-blocks.js +125 -0
  67. package/lib/app/markdown.d.ts +54 -0
  68. package/lib/app/markdown.js +189 -0
  69. package/lib/app/settings-model.d.ts +69 -0
  70. package/lib/app/settings-model.js +114 -0
  71. package/lib/app/theme.d.ts +166 -0
  72. package/lib/app/theme.js +141 -0
  73. package/lib/boot.d.ts +1 -0
  74. package/lib/boot.js +34 -0
  75. package/lib/commands.d.ts +49 -0
  76. package/lib/commands.js +115 -0
  77. package/lib/contract.d.ts +1973 -0
  78. package/lib/contract.js +36 -0
  79. package/lib/core/agent-roles.d.ts +52 -0
  80. package/lib/core/agent-roles.js +274 -0
  81. package/lib/core/approval-floor.d.ts +183 -0
  82. package/lib/core/approval-floor.js +679 -0
  83. package/lib/core/approval.d.ts +42 -0
  84. package/lib/core/approval.js +8 -0
  85. package/lib/core/audit.d.ts +61 -0
  86. package/lib/core/audit.js +59 -0
  87. package/lib/core/boot-notices.d.ts +6 -0
  88. package/lib/core/boot-notices.js +61 -0
  89. package/lib/core/cdp/actions.d.ts +182 -0
  90. package/lib/core/cdp/actions.js +649 -0
  91. package/lib/core/cdp/launch.d.ts +192 -0
  92. package/lib/core/cdp/launch.js +491 -0
  93. package/lib/core/cdp/snapshot.d.ts +139 -0
  94. package/lib/core/cdp/snapshot.js +316 -0
  95. package/lib/core/cdp/transport.d.ts +160 -0
  96. package/lib/core/cdp/transport.js +359 -0
  97. package/lib/core/command-policy.d.ts +108 -0
  98. package/lib/core/command-policy.js +580 -0
  99. package/lib/core/commands-completion.d.ts +78 -0
  100. package/lib/core/commands-completion.js +167 -0
  101. package/lib/core/compact-anchors.d.ts +76 -0
  102. package/lib/core/compact-anchors.js +284 -0
  103. package/lib/core/compact.d.ts +110 -0
  104. package/lib/core/compact.js +210 -0
  105. package/lib/core/config-store.d.ts +38 -0
  106. package/lib/core/config-store.js +307 -0
  107. package/lib/core/config.d.ts +36 -0
  108. package/lib/core/config.js +124 -0
  109. package/lib/core/connection-test.d.ts +60 -0
  110. package/lib/core/connection-test.js +84 -0
  111. package/lib/core/desktop-control.d.ts +298 -0
  112. package/lib/core/desktop-control.js +1311 -0
  113. package/lib/core/diff-text.d.ts +74 -0
  114. package/lib/core/diff-text.js +257 -0
  115. package/lib/core/dock-browser.d.ts +137 -0
  116. package/lib/core/dock-browser.js +146 -0
  117. package/lib/core/dock-ops.d.ts +59 -0
  118. package/lib/core/dock-ops.js +104 -0
  119. package/lib/core/dock-session.d.ts +39 -0
  120. package/lib/core/dock-session.js +28 -0
  121. package/lib/core/dsh-compat/hook.d.ts +18 -0
  122. package/lib/core/dsh-compat/hook.js +52 -0
  123. package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
  124. package/lib/core/dsh-compat/resolve-hook.js +59 -0
  125. package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
  126. package/lib/core/dsh-compat/tools-facade.js +108 -0
  127. package/lib/core/err-text.d.ts +13 -0
  128. package/lib/core/err-text.js +15 -0
  129. package/lib/core/events.d.ts +149 -0
  130. package/lib/core/events.js +1 -0
  131. package/lib/core/git-exec.d.ts +23 -0
  132. package/lib/core/git-exec.js +72 -0
  133. package/lib/core/git-info.d.ts +47 -0
  134. package/lib/core/git-info.js +157 -0
  135. package/lib/core/goal.d.ts +89 -0
  136. package/lib/core/goal.js +189 -0
  137. package/lib/core/hooks.d.ts +272 -0
  138. package/lib/core/hooks.js +818 -0
  139. package/lib/core/host-browser-link.d.ts +59 -0
  140. package/lib/core/host-browser-link.js +9 -0
  141. package/lib/core/host-methods.d.ts +25 -0
  142. package/lib/core/host-methods.js +103 -0
  143. package/lib/core/image-diet.d.ts +77 -0
  144. package/lib/core/image-diet.js +127 -0
  145. package/lib/core/learnings/ledger.d.ts +73 -0
  146. package/lib/core/learnings/ledger.js +273 -0
  147. package/lib/core/learnings/skill-write.d.ts +250 -0
  148. package/lib/core/learnings/skill-write.js +854 -0
  149. package/lib/core/learnings/store.d.ts +102 -0
  150. package/lib/core/learnings/store.js +266 -0
  151. package/lib/core/lifecycle-hooks.d.ts +189 -0
  152. package/lib/core/lifecycle-hooks.js +576 -0
  153. package/lib/core/llm.d.ts +272 -0
  154. package/lib/core/llm.js +548 -0
  155. package/lib/core/lockfile.d.ts +17 -0
  156. package/lib/core/lockfile.js +110 -0
  157. package/lib/core/loop.d.ts +185 -0
  158. package/lib/core/loop.js +587 -0
  159. package/lib/core/lsp/client.d.ts +189 -0
  160. package/lib/core/lsp/client.js +690 -0
  161. package/lib/core/lsp/framing.d.ts +84 -0
  162. package/lib/core/lsp/framing.js +181 -0
  163. package/lib/core/lsp/line-shift.d.ts +28 -0
  164. package/lib/core/lsp/line-shift.js +127 -0
  165. package/lib/core/lsp/manager.d.ts +93 -0
  166. package/lib/core/lsp/manager.js +418 -0
  167. package/lib/core/lsp/normalize.d.ts +32 -0
  168. package/lib/core/lsp/normalize.js +139 -0
  169. package/lib/core/lsp/servers.d.ts +106 -0
  170. package/lib/core/lsp/servers.js +352 -0
  171. package/lib/core/lsp/uri.d.ts +76 -0
  172. package/lib/core/lsp/uri.js +179 -0
  173. package/lib/core/market.d.ts +51 -0
  174. package/lib/core/market.js +358 -0
  175. package/lib/core/mcp.d.ts +201 -0
  176. package/lib/core/mcp.js +836 -0
  177. package/lib/core/memory-eval.d.ts +158 -0
  178. package/lib/core/memory-eval.js +215 -0
  179. package/lib/core/memory.d.ts +266 -0
  180. package/lib/core/memory.js +703 -0
  181. package/lib/core/mention.d.ts +57 -0
  182. package/lib/core/mention.js +129 -0
  183. package/lib/core/microcompact.d.ts +48 -0
  184. package/lib/core/microcompact.js +79 -0
  185. package/lib/core/migrate.d.ts +56 -0
  186. package/lib/core/migrate.js +134 -0
  187. package/lib/core/model-caps.d.ts +83 -0
  188. package/lib/core/model-caps.js +150 -0
  189. package/lib/core/model-discovery.d.ts +19 -0
  190. package/lib/core/model-discovery.js +69 -0
  191. package/lib/core/modes.d.ts +72 -0
  192. package/lib/core/modes.js +152 -0
  193. package/lib/core/native-bridge.d.ts +135 -0
  194. package/lib/core/native-bridge.js +563 -0
  195. package/lib/core/path-policy.d.ts +32 -0
  196. package/lib/core/path-policy.js +248 -0
  197. package/lib/core/permission-presets.d.ts +67 -0
  198. package/lib/core/permission-presets.js +75 -0
  199. package/lib/core/plugin-loader.d.ts +36 -0
  200. package/lib/core/plugin-loader.js +294 -0
  201. package/lib/core/plugin-registry.d.ts +113 -0
  202. package/lib/core/plugin-registry.js +256 -0
  203. package/lib/core/prefs.d.ts +82 -0
  204. package/lib/core/prefs.js +372 -0
  205. package/lib/core/presets.d.ts +80 -0
  206. package/lib/core/presets.js +373 -0
  207. package/lib/core/pricing.d.ts +90 -0
  208. package/lib/core/pricing.js +126 -0
  209. package/lib/core/prompt.d.ts +92 -0
  210. package/lib/core/prompt.js +339 -0
  211. package/lib/core/ptc.d.ts +66 -0
  212. package/lib/core/ptc.js +70 -0
  213. package/lib/core/remote/frames.d.ts +91 -0
  214. package/lib/core/remote/frames.js +174 -0
  215. package/lib/core/remote/notify.d.ts +54 -0
  216. package/lib/core/remote/notify.js +77 -0
  217. package/lib/core/remote/owner.d.ts +32 -0
  218. package/lib/core/remote/owner.js +75 -0
  219. package/lib/core/remote/pairing.d.ts +104 -0
  220. package/lib/core/remote/pairing.js +261 -0
  221. package/lib/core/remote/push.d.ts +80 -0
  222. package/lib/core/remote/push.js +222 -0
  223. package/lib/core/remote/store.d.ts +18 -0
  224. package/lib/core/remote/store.js +59 -0
  225. package/lib/core/remote/tickets.d.ts +20 -0
  226. package/lib/core/remote/tickets.js +49 -0
  227. package/lib/core/remote/uploads.d.ts +63 -0
  228. package/lib/core/remote/uploads.js +161 -0
  229. package/lib/core/request-attribution.d.ts +26 -0
  230. package/lib/core/request-attribution.js +86 -0
  231. package/lib/core/request-invariant.d.ts +61 -0
  232. package/lib/core/request-invariant.js +199 -0
  233. package/lib/core/sandbox/backends.d.ts +64 -0
  234. package/lib/core/sandbox/backends.js +194 -0
  235. package/lib/core/sandbox/execpolicy.d.ts +93 -0
  236. package/lib/core/sandbox/execpolicy.js +452 -0
  237. package/lib/core/sandbox/net-proxy.d.ts +31 -0
  238. package/lib/core/sandbox/net-proxy.js +162 -0
  239. package/lib/core/sandbox/policy.d.ts +211 -0
  240. package/lib/core/sandbox/policy.js +559 -0
  241. package/lib/core/sandbox/win/abi.d.ts +161 -0
  242. package/lib/core/sandbox/win/abi.js +169 -0
  243. package/lib/core/sandbox/win/account.d.ts +71 -0
  244. package/lib/core/sandbox/win/account.js +206 -0
  245. package/lib/core/sandbox/win/acl.d.ts +54 -0
  246. package/lib/core/sandbox/win/acl.js +339 -0
  247. package/lib/core/sandbox/win/backend.d.ts +61 -0
  248. package/lib/core/sandbox/win/backend.js +249 -0
  249. package/lib/core/sandbox/win/doctor.d.ts +24 -0
  250. package/lib/core/sandbox/win/doctor.js +272 -0
  251. package/lib/core/sandbox/win/ffi.d.ts +107 -0
  252. package/lib/core/sandbox/win/ffi.js +166 -0
  253. package/lib/core/sandbox/win/net-abi.d.ts +154 -0
  254. package/lib/core/sandbox/win/net-abi.js +316 -0
  255. package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
  256. package/lib/core/sandbox/win/runner-entry.js +391 -0
  257. package/lib/core/sandbox/win/setup.d.ts +60 -0
  258. package/lib/core/sandbox/win/setup.js +986 -0
  259. package/lib/core/sandbox/win/token.d.ts +35 -0
  260. package/lib/core/sandbox/win/token.js +238 -0
  261. package/lib/core/sandbox/win/wfp.d.ts +41 -0
  262. package/lib/core/sandbox/win/wfp.js +200 -0
  263. package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
  264. package/lib/core/sandbox/win/workspace-sid.js +45 -0
  265. package/lib/core/schedule/rule.d.ts +184 -0
  266. package/lib/core/schedule/rule.js +745 -0
  267. package/lib/core/schedule/runner.d.ts +185 -0
  268. package/lib/core/schedule/runner.js +678 -0
  269. package/lib/core/schedule/store.d.ts +182 -0
  270. package/lib/core/schedule/store.js +455 -0
  271. package/lib/core/secrets.d.ts +41 -0
  272. package/lib/core/secrets.js +150 -0
  273. package/lib/core/session-export.d.ts +18 -0
  274. package/lib/core/session-export.js +73 -0
  275. package/lib/core/session-index.d.ts +159 -0
  276. package/lib/core/session-index.js +683 -0
  277. package/lib/core/session-meta.d.ts +41 -0
  278. package/lib/core/session-meta.js +97 -0
  279. package/lib/core/session.d.ts +356 -0
  280. package/lib/core/session.js +998 -0
  281. package/lib/core/skills.d.ts +60 -0
  282. package/lib/core/skills.js +171 -0
  283. package/lib/core/spill.d.ts +159 -0
  284. package/lib/core/spill.js +329 -0
  285. package/lib/core/surface-registry.d.ts +45 -0
  286. package/lib/core/surface-registry.js +67 -0
  287. package/lib/core/team-board.d.ts +95 -0
  288. package/lib/core/team-board.js +316 -0
  289. package/lib/core/throughput.d.ts +46 -0
  290. package/lib/core/throughput.js +40 -0
  291. package/lib/core/todo-reminder.d.ts +44 -0
  292. package/lib/core/todo-reminder.js +55 -0
  293. package/lib/core/todo.d.ts +81 -0
  294. package/lib/core/todo.js +222 -0
  295. package/lib/core/token-estimate.d.ts +55 -0
  296. package/lib/core/token-estimate.js +82 -0
  297. package/lib/core/tool-guards.d.ts +103 -0
  298. package/lib/core/tool-guards.js +77 -0
  299. package/lib/core/tool-search.d.ts +152 -0
  300. package/lib/core/tool-search.js +311 -0
  301. package/lib/core/tools/bash.d.ts +281 -0
  302. package/lib/core/tools/bash.js +871 -0
  303. package/lib/core/tools/command-runner.d.ts +84 -0
  304. package/lib/core/tools/command-runner.js +68 -0
  305. package/lib/core/tools/fs-tools.d.ts +23 -0
  306. package/lib/core/tools/fs-tools.js +247 -0
  307. package/lib/core/tools/index.d.ts +8 -0
  308. package/lib/core/tools/index.js +4 -0
  309. package/lib/core/tools/sandbox-args.d.ts +51 -0
  310. package/lib/core/tools/sandbox-args.js +90 -0
  311. package/lib/core/tools/search-tools.d.ts +3 -0
  312. package/lib/core/tools/search-tools.js +153 -0
  313. package/lib/core/tools.d.ts +96 -0
  314. package/lib/core/tools.js +53 -0
  315. package/lib/core/ui-boot-source.d.ts +71 -0
  316. package/lib/core/ui-boot-source.js +121 -0
  317. package/lib/core/ui-bundles.d.ts +249 -0
  318. package/lib/core/ui-bundles.js +830 -0
  319. package/lib/core/ui-combo.d.ts +49 -0
  320. package/lib/core/ui-combo.js +55 -0
  321. package/lib/core/ui-events.d.ts +81 -0
  322. package/lib/core/ui-events.js +364 -0
  323. package/lib/core/ui-hmr.d.ts +36 -0
  324. package/lib/core/ui-hmr.js +128 -0
  325. package/lib/core/ui-methods.d.ts +69 -0
  326. package/lib/core/ui-methods.js +341 -0
  327. package/lib/core/ui-route.d.ts +69 -0
  328. package/lib/core/ui-route.js +122 -0
  329. package/lib/core/ui-server.d.ts +75 -0
  330. package/lib/core/ui-server.js +369 -0
  331. package/lib/core/ui-trust.d.ts +47 -0
  332. package/lib/core/ui-trust.js +164 -0
  333. package/lib/core/untrusted.d.ts +30 -0
  334. package/lib/core/untrusted.js +48 -0
  335. package/lib/core/update-check.d.ts +81 -0
  336. package/lib/core/update-check.js +177 -0
  337. package/lib/core/usage-log.d.ts +82 -0
  338. package/lib/core/usage-log.js +306 -0
  339. package/lib/core/version.d.ts +1 -0
  340. package/lib/core/version.js +37 -0
  341. package/lib/core/web-http.d.ts +57 -0
  342. package/lib/core/web-http.js +137 -0
  343. package/lib/core/web-static.d.ts +31 -0
  344. package/lib/core/web-static.js +75 -0
  345. package/lib/headless.d.ts +1 -0
  346. package/lib/headless.js +31 -0
  347. package/lib/host/kernel.d.ts +33 -0
  348. package/lib/host/kernel.js +451 -0
  349. package/lib/index.d.ts +41 -0
  350. package/lib/index.js +35 -0
  351. package/lib/plugins/agent.d.ts +2 -0
  352. package/lib/plugins/agent.js +274 -0
  353. package/lib/plugins/approval-floor.d.ts +2 -0
  354. package/lib/plugins/approval-floor.js +223 -0
  355. package/lib/plugins/approval.d.ts +16 -0
  356. package/lib/plugins/approval.js +674 -0
  357. package/lib/plugins/ask.d.ts +2 -0
  358. package/lib/plugins/ask.js +245 -0
  359. package/lib/plugins/browser.d.ts +68 -0
  360. package/lib/plugins/browser.js +1341 -0
  361. package/lib/plugins/commands.d.ts +23 -0
  362. package/lib/plugins/commands.js +498 -0
  363. package/lib/plugins/compact.d.ts +21 -0
  364. package/lib/plugins/compact.js +274 -0
  365. package/lib/plugins/computer-use.d.ts +47 -0
  366. package/lib/plugins/computer-use.js +539 -0
  367. package/lib/plugins/desktop-dock.d.ts +2 -0
  368. package/lib/plugins/desktop-dock.js +626 -0
  369. package/lib/plugins/dock-browser.d.ts +34 -0
  370. package/lib/plugins/dock-browser.js +765 -0
  371. package/lib/plugins/dsh-compat.d.ts +25 -0
  372. package/lib/plugins/dsh-compat.js +37 -0
  373. package/lib/plugins/file-review.d.ts +108 -0
  374. package/lib/plugins/file-review.js +393 -0
  375. package/lib/plugins/git.d.ts +26 -0
  376. package/lib/plugins/git.js +132 -0
  377. package/lib/plugins/goal.d.ts +20 -0
  378. package/lib/plugins/goal.js +245 -0
  379. package/lib/plugins/guards.d.ts +14 -0
  380. package/lib/plugins/guards.js +18 -0
  381. package/lib/plugins/hooks.d.ts +19 -0
  382. package/lib/plugins/hooks.js +583 -0
  383. package/lib/plugins/host-stdio.d.ts +88 -0
  384. package/lib/plugins/host-stdio.js +317 -0
  385. package/lib/plugins/image-diet.d.ts +17 -0
  386. package/lib/plugins/image-diet.js +85 -0
  387. package/lib/plugins/lifecycle-hooks.d.ts +26 -0
  388. package/lib/plugins/lifecycle-hooks.js +338 -0
  389. package/lib/plugins/llm.d.ts +13 -0
  390. package/lib/plugins/llm.js +215 -0
  391. package/lib/plugins/lsp.d.ts +54 -0
  392. package/lib/plugins/lsp.js +608 -0
  393. package/lib/plugins/mcp.d.ts +16 -0
  394. package/lib/plugins/mcp.js +673 -0
  395. package/lib/plugins/memory.d.ts +17 -0
  396. package/lib/plugins/memory.js +858 -0
  397. package/lib/plugins/microcompact.d.ts +18 -0
  398. package/lib/plugins/microcompact.js +119 -0
  399. package/lib/plugins/mode.d.ts +18 -0
  400. package/lib/plugins/mode.js +115 -0
  401. package/lib/plugins/permission-presets.d.ts +18 -0
  402. package/lib/plugins/permission-presets.js +135 -0
  403. package/lib/plugins/plan.d.ts +2 -0
  404. package/lib/plugins/plan.js +192 -0
  405. package/lib/plugins/plugin-manager.d.ts +2 -0
  406. package/lib/plugins/plugin-manager.js +165 -0
  407. package/lib/plugins/presets.d.ts +2 -0
  408. package/lib/plugins/presets.js +182 -0
  409. package/lib/plugins/prompt.d.ts +2 -0
  410. package/lib/plugins/prompt.js +264 -0
  411. package/lib/plugins/ptc.d.ts +2 -0
  412. package/lib/plugins/ptc.js +272 -0
  413. package/lib/plugins/remote/http.d.ts +11 -0
  414. package/lib/plugins/remote/http.js +11 -0
  415. package/lib/plugins/remote/routes.d.ts +24 -0
  416. package/lib/plugins/remote/routes.js +384 -0
  417. package/lib/plugins/remote/types.d.ts +135 -0
  418. package/lib/plugins/remote/types.js +87 -0
  419. package/lib/plugins/remote.d.ts +17 -0
  420. package/lib/plugins/remote.js +1028 -0
  421. package/lib/plugins/runtime-api.d.ts +16 -0
  422. package/lib/plugins/runtime-api.js +99 -0
  423. package/lib/plugins/runtime.d.ts +10 -0
  424. package/lib/plugins/runtime.js +451 -0
  425. package/lib/plugins/sandbox.d.ts +2 -0
  426. package/lib/plugins/sandbox.js +761 -0
  427. package/lib/plugins/schedule.d.ts +26 -0
  428. package/lib/plugins/schedule.js +538 -0
  429. package/lib/plugins/self-improve.d.ts +61 -0
  430. package/lib/plugins/self-improve.js +953 -0
  431. package/lib/plugins/session-search.d.ts +16 -0
  432. package/lib/plugins/session-search.js +308 -0
  433. package/lib/plugins/session-title.d.ts +19 -0
  434. package/lib/plugins/session-title.js +109 -0
  435. package/lib/plugins/session.d.ts +7 -0
  436. package/lib/plugins/session.js +296 -0
  437. package/lib/plugins/settings.d.ts +3 -0
  438. package/lib/plugins/settings.js +705 -0
  439. package/lib/plugins/skills.d.ts +2 -0
  440. package/lib/plugins/skills.js +360 -0
  441. package/lib/plugins/spill.d.ts +16 -0
  442. package/lib/plugins/spill.js +200 -0
  443. package/lib/plugins/subagent.d.ts +2 -0
  444. package/lib/plugins/subagent.js +862 -0
  445. package/lib/plugins/surfaces.d.ts +11 -0
  446. package/lib/plugins/surfaces.js +20 -0
  447. package/lib/plugins/team.d.ts +16 -0
  448. package/lib/plugins/team.js +149 -0
  449. package/lib/plugins/todo.d.ts +19 -0
  450. package/lib/plugins/todo.js +188 -0
  451. package/lib/plugins/tool-search.d.ts +2 -0
  452. package/lib/plugins/tool-search.js +425 -0
  453. package/lib/plugins/tools-default.d.ts +12 -0
  454. package/lib/plugins/tools-default.js +275 -0
  455. package/lib/plugins/tools.d.ts +16 -0
  456. package/lib/plugins/tools.js +62 -0
  457. package/lib/plugins/transcript.d.ts +15 -0
  458. package/lib/plugins/transcript.js +311 -0
  459. package/lib/plugins/tui.d.ts +2 -0
  460. package/lib/plugins/tui.js +98 -0
  461. package/lib/plugins/waiting.d.ts +12 -0
  462. package/lib/plugins/waiting.js +34 -0
  463. package/lib/plugins/web-search.d.ts +14 -0
  464. package/lib/plugins/web-search.js +263 -0
  465. package/lib/plugins/webserver.d.ts +48 -0
  466. package/lib/plugins/webserver.js +228 -0
  467. package/lib/remote/assets/app-DAcUCOEn.js +14 -0
  468. package/lib/remote/assets/icon-192.png +0 -0
  469. package/lib/remote/assets/icon-512.png +0 -0
  470. package/lib/remote/assets/index.html +34 -0
  471. package/lib/remote/assets/manifest.json +27 -0
  472. package/lib/remote/assets/style-DIB6729x.css +1 -0
  473. package/lib/remote/assets/sw.js +66 -0
  474. package/lib/services/types.d.ts +1228 -0
  475. package/lib/services/types.js +1 -0
  476. package/lib/tools/config-cli.d.ts +1 -0
  477. package/lib/tools/config-cli.js +89 -0
  478. package/lib/ui/arrival.d.ts +72 -0
  479. package/lib/ui/arrival.js +105 -0
  480. package/lib/ui/assets/app-B70nVIKd.js +69 -0
  481. package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
  482. package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
  483. package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
  484. package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
  485. package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
  486. package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
  487. package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
  488. package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
  489. package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
  490. package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
  491. package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
  492. package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
  493. package/lib/ui/assets/chunk-BajyYBss.js +10 -0
  494. package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
  495. package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
  496. package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
  497. package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
  498. package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
  499. package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
  500. package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
  501. package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
  502. package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
  503. package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
  504. package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
  505. package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
  506. package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
  507. package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
  508. package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
  509. package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
  510. package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
  511. package/lib/ui/assets/chunk-CickPsom.js +1 -0
  512. package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
  513. package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
  514. package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
  515. package/lib/ui/assets/chunk-CqE71os6.js +1 -0
  516. package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
  517. package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
  518. package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
  519. package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
  520. package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
  521. package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
  522. package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
  523. package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
  524. package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
  525. package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
  526. package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
  527. package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
  528. package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
  529. package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
  530. package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
  531. package/lib/ui/assets/chunk-De0Btta0.js +1 -0
  532. package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
  533. package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
  534. package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
  535. package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
  536. package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
  537. package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
  538. package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
  539. package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
  540. package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
  541. package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
  542. package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
  543. package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
  544. package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
  545. package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
  546. package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
  547. package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
  548. package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
  549. package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
  550. package/lib/ui/assets/icon.png +0 -0
  551. package/lib/ui/assets/index.html +14 -0
  552. package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
  553. package/lib/ui/assets/style-Bq01xH_b.css +1 -0
  554. package/lib/ui/frames.d.ts +67 -0
  555. package/lib/ui/frames.js +146 -0
  556. package/lib/ui/index.d.ts +59 -0
  557. package/lib/ui/index.js +50 -0
  558. package/lib/ui/manifest.d.ts +172 -0
  559. package/lib/ui/manifest.js +158 -0
  560. package/lib/ui/plugin.d.ts +161 -0
  561. package/lib/ui/plugin.js +7 -0
  562. package/lib/ui/plugins/browser/client.js +290 -0
  563. package/lib/ui/plugins/browser/icon.png +0 -0
  564. package/lib/ui/plugins/composer/client.js +1843 -0
  565. package/lib/ui/plugins/composer/icon.png +0 -0
  566. package/lib/ui/plugins/files/client.js +646 -0
  567. package/lib/ui/plugins/files/icon.png +0 -0
  568. package/lib/ui/plugins/manifest.json +107 -0
  569. package/lib/ui/plugins/plugins/client.js +682 -0
  570. package/lib/ui/plugins/plugins/icon.png +0 -0
  571. package/lib/ui/plugins/preview/client.js +197 -0
  572. package/lib/ui/plugins/preview/icon.png +0 -0
  573. package/lib/ui/plugins/prompt/client.js +653 -0
  574. package/lib/ui/plugins/prompt/icon.png +0 -0
  575. package/lib/ui/plugins/sessions/client.js +1577 -0
  576. package/lib/ui/plugins/sessions/icon.png +0 -0
  577. package/lib/ui/plugins/settings/client.js +5470 -0
  578. package/lib/ui/plugins/settings/icon.png +0 -0
  579. package/lib/ui/plugins/skills/client.js +485 -0
  580. package/lib/ui/plugins/skills/icon.png +0 -0
  581. package/lib/ui/plugins/status/client.js +1420 -0
  582. package/lib/ui/plugins/status/icon.png +0 -0
  583. package/lib/ui/plugins/statusbar/client.js +504 -0
  584. package/lib/ui/plugins/statusbar/icon.png +0 -0
  585. package/lib/ui/plugins/tasks/client.js +52 -0
  586. package/lib/ui/plugins/tasks/icon.png +0 -0
  587. package/lib/ui/plugins/team/client.js +527 -0
  588. package/lib/ui/plugins/team/icon.png +0 -0
  589. package/lib/ui/plugins/terminal/client.js +232 -0
  590. package/lib/ui/plugins/terminal/icon.png +0 -0
  591. package/lib/ui/plugins/trace/client.js +1376 -0
  592. package/lib/ui/plugins/trace/icon.png +0 -0
  593. package/lib/ui/plugins/transcript/client.js +2661 -0
  594. package/lib/ui/plugins/transcript/icon.png +0 -0
  595. package/lib/ui/scoped-slots.d.ts +20 -0
  596. package/lib/ui/scoped-slots.js +21 -0
  597. package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
  598. package/lib/ui/sdk/@dsc/ui/package.json +16 -0
  599. package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
  600. package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
  601. package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
  602. package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
  603. package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
  604. package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
  605. package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
  606. package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
  607. package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
  608. package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
  609. package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
  610. package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
  611. package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
  612. package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
  613. package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
  614. package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
  615. package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
  616. package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
  617. package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
  618. package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
  619. package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
  620. package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
  621. package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
  622. package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
  623. package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
  624. package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
  625. package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
  626. package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
  627. package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
  628. package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
  629. package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
  630. package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
  631. package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
  632. package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
  633. package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
  634. package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
  635. package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
  636. package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
  637. package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
  638. package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
  639. package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
  640. package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
  641. package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
  642. package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
  643. package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
  644. package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
  645. package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
  646. package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
  647. package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
  648. package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
  649. package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
  650. package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
  651. package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
  652. package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
  653. package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
  654. package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
  655. package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
  656. package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
  657. package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
  658. package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
  659. package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
  660. package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
  661. package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
  662. package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
  663. package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
  664. package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
  665. package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
  666. package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
  667. package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
  668. package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
  669. package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
  670. package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
  671. package/lib/ui/services-react.d.ts +27 -0
  672. package/lib/ui/services-react.js +32 -0
  673. package/lib/ui/services.d.ts +63 -0
  674. package/lib/ui/services.js +121 -0
  675. package/lib/ui/slots-ink.d.ts +26 -0
  676. package/lib/ui/slots-ink.js +78 -0
  677. package/lib/ui/slots-react.d.ts +28 -0
  678. package/lib/ui/slots-react.js +88 -0
  679. package/lib/ui/slots.d.ts +481 -0
  680. package/lib/ui/slots.js +550 -0
  681. package/lib/ui/store.d.ts +89 -0
  682. package/lib/ui/store.js +62 -0
  683. package/lib/ui/tui-plugin-api.d.ts +23 -0
  684. package/lib/ui/tui-plugin-api.js +23 -0
  685. package/lib/ui/tui-plugins.d.ts +47 -0
  686. package/lib/ui/tui-plugins.js +220 -0
  687. package/package.json +58 -6
package/lib/app/App.js ADDED
@@ -0,0 +1,1498 @@
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * 顶层界面:快照订阅(useSyncExternalStore)+ 键盘路由 + 鼠标层 + 恒定帧布局。
4
+ *
5
+ * 布局(0.6.56):根盒高度恒为「终端行数 − 1」并 overflow hidden——ink 的帧写带尾随
6
+ * 换行,帧高一旦随内容变化终端就会滚动(「↑↓ 跳回底部」的根源);固定帧之后任何
7
+ * 状态下重绘都从屏顶原位擦写、零滚动。聊天区是 flexGrow 的滚动视口:底对齐、老的
8
+ * 条目从顶上裁掉(只丢历史不丢最新),滚轮 / PgUp·PgDn 以条为单位回看,滚动时在
9
+ * 输入框上方挂一条可点击的「回到底部」提示;选择器与模型浮层独占整屏、列表行与
10
+ * 屏幕行一一对应,点击即命中。
11
+ *
12
+ * 键盘优先级:Ctrl+C(打断/退出)→ 审批卡(四档)→ 提问卡(模态作答)→ 计划反馈
13
+ * 输入 → 计划评审卡(批准/拒绝/带反馈)→ 图片预览浮层 → 子代理浮层 → 回看浮层
14
+ * (Ctrl+O)→ 会话选择器 → 模型/模式/技能浮层 → Esc(打断 / 双击撤回上一轮)→ PgUp/PgDn
15
+ * 滚动 → Ctrl+O/Ctrl+T → 其余交给 Composer(↑↓ 在输入框里仍是历史回忆,对齐
16
+ * dsh-TUI)。
17
+ *
18
+ * 鼠标(0.6.56):进程存活期间开启 SGR 跟踪(DECSET 1000+1006),卸载时关闭。
19
+ * ink 的按键解析不认识 SGR 序列,剥掉 ESC 头后以 `'[<b;x;yM|m'` 原样进 useInput——
20
+ * 在最顶层拦截:滚轮按状态路由(浮层/聊天/两个选择器);左键点击派发给命中区注册表
21
+ * (卡片页脚按钮、提问选项、回底提示条、附件芯片、后台芯片、图片行——组件用 yoga
22
+ * 绝对行自报几何,见 click.ts),列表则用构造行号直接映射。跟踪开着时终端原生选区
23
+ * 要走 Shift+拖拽,全终端 TUI 通例。
24
+ *
25
+ * 光标停靠(0.6.57):App 包一层 stdout.write,帧(含 `\x1b[2K`)写完追加一条
26
+ * CUP 把物理光标送回 Composer 声明的 caret(cursor.ts)——Windows Terminal 的
27
+ * IME 拼音预览因此画在输入框里;无声明时隐藏光标。
28
+ *
29
+ * @module dsc-tui/app/App
30
+ */
31
+ import { spawn } from 'node:child_process';
32
+ import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
33
+ import { Box, Text, useInput, useStdout } from 'ink';
34
+ import { DEFAULT_STATUS_BAR_PREFS, normalizeStatusBarPrefs } from '../contract.js';
35
+ import { runCommand } from '../plugins/commands.js';
36
+ import { AgentsOverlay, buildAgentRows } from './AgentsOverlay.js';
37
+ import { absoluteTop, measuredHeight, useClickRegion } from './click.js';
38
+ import { ApprovalCard } from './ApprovalCard.js';
39
+ import { AskCard, SKIPPED_ANSWER } from './AskCard.js';
40
+ import { readClipboardImage } from './clipboard-image.js';
41
+ import { ChatView } from './ChatView.js';
42
+ import { Composer } from './Composer.js';
43
+ import { renderImageBlock } from './image-blocks.js';
44
+ import { ModelPicker } from './ModelPicker.js';
45
+ import { PlanReviewCard } from './PlanReviewCard.js';
46
+ import { PresetPicker } from './PresetPicker.js';
47
+ import { PreviewOverlay } from './PreviewOverlay.js';
48
+ import { SessionPicker } from './SessionPicker.js';
49
+ import { SETTINGS_CHROME, SETTINGS_LIST_TOP, SettingsOverlay } from './SettingsOverlay.js';
50
+ import { SkillsPicker } from './SkillsPicker.js';
51
+ import { buildSettingsRows, focusableRows, isFocusableRow, settingsWindowStart, } from './settings-model.js';
52
+ import { shortId, StatusBar } from './StatusBar.js';
53
+ import { TaskStrips } from './TaskStrips.js';
54
+ import { TranscriptOverlay } from './TranscriptOverlay.js';
55
+ import { Welcome } from './Welcome.js';
56
+ import { extractImages, readImageAsDataUrl } from './attach.js';
57
+ import { BORDER, GAP, PAD, PALETTE, STATUS_COLOR, TEXT } from './theme.js';
58
+ /** 双击 Ctrl+C 的判定窗口。 */
59
+ const EXIT_WINDOW_MS = 2000;
60
+ /** 双击 Esc 撤回上一轮的判定窗口(对齐 dsh 的 3 秒)。 */
61
+ const REWIND_WINDOW_MS = 3000;
62
+ /** 聊天视口一次渲染的条目窗口(帧内放不下会被裁掉,窗口只约束 reconcile 量)。 */
63
+ const CHAT_WINDOW = 80;
64
+ /** 回看浮层的条目窗口(全量 transcript,窗口随滚动偏移滑动)。 */
65
+ const OVERLAY_WINDOW = 200;
66
+ /** 欢迎页只挂在短会话顶上(resume 长会话再画只是把历史往下顶,dsh skipIntro 同款)。 */
67
+ const WELCOME_MAX_ENTRIES = 30;
68
+ /** 选择器框的固定行数:上下边框 2 + 标题 1 + 筛选行 1 + 提示行 1(改名行与提示行 1:1 互换)。 */
69
+ const PICKER_CHROME = 5;
70
+ /** 工作区显示名:最后一段路径(dsh 会话总管的 rail 同款;盘根/空目录给兜底文案)。 */
71
+ const workspaceLabel = (cwd) => {
72
+ if (cwd === '')
73
+ return '(无目录)';
74
+ const base = cwd.replace(/[\\/]+$/, '').split(/[\\/]/).pop() ?? cwd;
75
+ return base === '' ? cwd : base;
76
+ };
77
+ /** 「已离开最新」提示条(0.6.59 对齐 dsh 的 pill):蓝底深字,整枚可点回底。 */
78
+ function TailIndicator({ hidden, onJump, registerClick, }) {
79
+ const ref = useRef(null);
80
+ useClickRegion(ref, registerClick, (col, row, top, height) => {
81
+ if (row < top || row >= top + height)
82
+ return false;
83
+ onJump();
84
+ return true;
85
+ });
86
+ return (_jsx(Box, { ref: ref, marginTop: GAP.tight, children: _jsxs(Text, { backgroundColor: PALETTE.pillBg, color: PALETTE.pillText, bold: true, children: [' ↓ 回到底部(Enter/End)', hidden > 99 ? ` · ${hidden} 条新` : '', ' '] }) }));
87
+ }
88
+ export function App({ runtime, clipboardReader, imageRenderer, tuiNoticeExtras, }) {
89
+ const snapshot = useSyncExternalStore(runtime.subscribe, runtime.getSnapshot);
90
+ const approval = snapshot.surfaces.pendingApproval;
91
+ const question = snapshot.surfaces.pendingQuestion;
92
+ const plan = snapshot.surfaces.pendingPlan;
93
+ const { stdout } = useStdout();
94
+ const [picker, setPicker] = useState(false);
95
+ const [pickerIndex, setPickerIndex] = useState(0);
96
+ const [expandThinking, setExpandThinking] = useState(false);
97
+ const [notice, setNotice] = useState(null);
98
+ /** 审批卡内嵌 diff 的展开态(v 切换;换卡即复位)。 */
99
+ const [approvalExpanded, setApprovalExpanded] = useState(false);
100
+ /** 计划全文的展开态。 */
101
+ const [planExpanded, setPlanExpanded] = useState(false);
102
+ /** 计划卡的「带反馈退回」输入模式:Composer 临时改成反馈输入框。 */
103
+ const [planFeedback, setPlanFeedback] = useState(false);
104
+ /** 提问卡的作答进度(一批多题逐题作答;换卡即复位)。 */
105
+ const [askIndex, setAskIndex] = useState(0);
106
+ const [askChecked, setAskChecked] = useState([]);
107
+ const [askHighlight, setAskHighlight] = useState(0);
108
+ const [askText, setAskText] = useState('');
109
+ /** 回看浮层(Ctrl+O):offset 是「从尾部往回滚的条数」。 */
110
+ const [transcriptOpen, setTranscriptOpen] = useState(false);
111
+ const [scrollOffset, setScrollOffset] = useState(0);
112
+ /** 聊天滚动锚点:窗口末端的条目下标;null = 跟随最新(直播态)。 */
113
+ const [chatAnchor, setChatAnchor] = useState(null);
114
+ /** Composer 补全面板开合(Esc 打断与「关面板」的分流依据)。 */
115
+ const [panelOpen, setPanelOpen] = useState(false);
116
+ /** ---- 0.6.57:双击 Esc 撤回 / 剪贴板贴图 / 子代理浮层 / 图片预览 ---- */
117
+ /** 上一次 Esc 的时刻(撤回的 prime 判定;任何非 Esc 按键清零)。 */
118
+ const lastEsc = useRef(0);
119
+ /** Composer 草稿镜像(撤回要判断输入框是否为空;不进状态避免多余重渲染)。 */
120
+ const draftRef = useRef('');
121
+ /** 外部灌入 Composer 的草稿(token 变化即生效)。 */
122
+ const [composerPreset, setComposerPreset] = useState({ text: '', token: 0 });
123
+ /** 剪贴板贴图暂存的附件芯片。 */
124
+ const [attachments, setAttachments] = useState([]);
125
+ const attachmentSeq = useRef(0);
126
+ /** 子代理浮层:名单 / 某个代理的只读转录(null = 关闭)。 */
127
+ const [agentView, setAgentView] = useState(null);
128
+ const [agentEntries, setAgentEntries] = useState(null);
129
+ const [agentIndex, setAgentIndex] = useState(0);
130
+ /** 图片预览浮层(半块真彩;block 由 effect 现算)。 */
131
+ const [preview, setPreview] = useState(null);
132
+ const [previewBlock, setPreviewBlock] = useState(null);
133
+ const [previewLoading, setPreviewLoading] = useState(false);
134
+ const [previewError, setPreviewError] = useState(null);
135
+ // ---- 会话选择器:页 / 筛选 / 改名 / 删除确认 ----
136
+ const [pickerPage, setPickerPage] = useState('active');
137
+ const [archivedList, setArchivedList] = useState([]);
138
+ const [pickerQuery, setPickerQuery] = useState('');
139
+ const [pickerBuffer, setPickerBuffer] = useState(null);
140
+ const [pickerArmed, setPickerArmed] = useState(false);
141
+ /**
142
+ * 两级导航(0.6.63 对齐 dsh 的会话总管):已钻取的工作区 cwd;null = 工作区层。
143
+ * 工作区只有一个时派生为「直落会话层」(pickerWorkspace 保持 null,Esc 直接关)。
144
+ */
145
+ const [pickerWorkspace, setPickerWorkspace] = useState(null);
146
+ /** 模型选择浮层(/model 无参数打开;输入即筛选)。 */
147
+ const [modelPicker, setModelPicker] = useState(false);
148
+ const [modelIndex, setModelIndex] = useState(0);
149
+ const [modelQuery, setModelQuery] = useState('');
150
+ /** 模式选择浮层(/preset 无参数打开,对齐 dsh 裸命令开 picker)。 */
151
+ const [presetPicker, setPresetPicker] = useState(false);
152
+ const [presetIndex, setPresetIndex] = useState(0);
153
+ const [presetQuery, setPresetQuery] = useState('');
154
+ /** 技能选择浮层(/skills 无参数打开;Enter 回填 /技能名 到输入行)。 */
155
+ const [skillsPicker, setSkillsPicker] = useState(false);
156
+ const [skillsIndex, setSkillsIndex] = useState(0);
157
+ const [skillsQuery, setSkillsQuery] = useState('');
158
+ /** ---- 0.6.61:设置页(/settings)---- 焦点/草稿/回执/滚动全在这组状态里。 */
159
+ const [settingsOpen, setSettingsOpen] = useState(false);
160
+ const [settingsSections, setSettingsSections] = useState([]);
161
+ const [settingsValues, setSettingsValues] = useState({});
162
+ /** 焦点在 focusables(可聚焦行号表)里的位置。 */
163
+ const [settingsIndex, setSettingsIndex] = useState(0);
164
+ const [settingsEdit, setSettingsEdit] = useState(null);
165
+ const [settingsNotice, setSettingsNotice] = useState(null);
166
+ /** 当前展开的设置子页(null = 根页;dsh 式一层分组,Esc 先退子页再关页)。 */
167
+ const [settingsGroup, setSettingsGroup] = useState(null);
168
+ /** 当前展开的分区页(0.6.64 两级导航:null = 根页只列分区名;组子页在分区页之下)。 */
169
+ const [settingsSection, setSettingsSection] = useState(null);
170
+ /** 状态栏段显隐(0.6.62):启动读一次 prefs,设置页改动后就地更新。 */
171
+ const [statusBarPrefs, setStatusBarPrefs] = useState(DEFAULT_STATUS_BAR_PREFS);
172
+ const lastCtrlC = useRef(0);
173
+ /** 可切换模型列表:进程内静态,取一次即可。 */
174
+ const models = useMemo(() => runtime.listModels(), [runtime]);
175
+ /** @ 提及补全的文件清单来源(dock 的 fs-list;不可用时补全退化为空)。 */
176
+ const dockLister = useCallback((dir) => runtime.dock('fs-list', { dir: dir === '' ? '.' : dir }), [runtime]);
177
+ /** 卡片/提示条的点击命中注册表(组件登记判定函数,几何在点击时现量,见 click.ts)。 */
178
+ const clickRegions = useRef(new Set());
179
+ const registerClick = useCallback((region) => {
180
+ clickRegions.current.add(region);
181
+ return () => {
182
+ clickRegions.current.delete(region);
183
+ };
184
+ }, []);
185
+ const askQuestions = question?.questions ?? (question !== null ? [question] : []);
186
+ const currentQuestion = askQuestions[askIndex];
187
+ /** 模型浮层的筛选结果(value/description 子串匹配)。 */
188
+ const modelList = useMemo(() => {
189
+ const q = modelQuery.trim().toLowerCase();
190
+ if (q === '')
191
+ return models;
192
+ return models.filter((choice) => choice.value.toLowerCase().includes(q) || choice.description.toLowerCase().includes(q));
193
+ }, [models, modelQuery]);
194
+ /** 模式投影(浮层开着才算:listPresets 是同步读盘)。 */
195
+ const presetSurface = useMemo(() => (presetPicker ? runtime.listPresets() : null), [runtime, presetPicker]);
196
+ /** 模式浮层的筛选结果(显示名/名字/说明子串匹配)。 */
197
+ const presetList = useMemo(() => {
198
+ if (presetSurface === null)
199
+ return [];
200
+ const q = presetQuery.trim().toLowerCase();
201
+ if (q === '')
202
+ return presetSurface.options;
203
+ return presetSurface.options.filter((preset) => preset.label.toLowerCase().includes(q) ||
204
+ preset.name.toLowerCase().includes(q) ||
205
+ preset.description.toLowerCase().includes(q));
206
+ }, [presetSurface, presetQuery]);
207
+ /** 技能投影(浮层开着才算)。 */
208
+ const skillsSurface = useMemo(() => (skillsPicker ? runtime.listSkills() : []), [runtime, skillsPicker]);
209
+ /** 技能浮层的筛选结果(名字/描述/来源子串匹配)。 */
210
+ const skillsList = useMemo(() => {
211
+ const q = skillsQuery.trim().toLowerCase();
212
+ if (q === '')
213
+ return skillsSurface;
214
+ return skillsSurface.filter((skill) => skill.name.toLowerCase().includes(q) ||
215
+ skill.description.toLowerCase().includes(q) ||
216
+ skill.source.toLowerCase().includes(q));
217
+ }, [skillsSurface, skillsQuery]);
218
+ /** 回合跑动 → 空闲时响一声 BEL:长任务跑完人不在终端前也能听见。 */
219
+ const previousTurn = useRef(snapshot.status.turnState);
220
+ useEffect(() => {
221
+ const current = snapshot.status.turnState;
222
+ const wasActive = previousTurn.current !== 'idle';
223
+ previousTurn.current = current;
224
+ if (wasActive && current === 'idle') {
225
+ try {
226
+ stdout?.write('\x07');
227
+ }
228
+ catch {
229
+ // 管道里写不进去就算了,提示音是锦上添花
230
+ }
231
+ }
232
+ }, [snapshot.status.turnState, stdout]);
233
+ // 设置里的「思考块默认展开」是初值(0.6.61):启动读一次,Ctrl+T 仍是会话内
234
+ // 的临时开关。旧测试的 runtime mock 没有这个方法——缺了就静默跳过。
235
+ useEffect(() => {
236
+ if (typeof runtime.getUiPrefs !== 'function')
237
+ return;
238
+ const prefs = runtime.getUiPrefs();
239
+ if (prefs.reasoningDefaultOpen === true)
240
+ setExpandThinking(true);
241
+ // 状态栏段显隐(0.6.62):缺键归一(老 mock / 老宿主)后装填。
242
+ setStatusBarPrefs(normalizeStatusBarPrefs(prefs.statusBar));
243
+ }, [runtime]);
244
+ // 鼠标跟踪全时开启(SGR 点击/滚轮;不启用 1002/1003——拖拽选区留给终端原生行为)。
245
+ useEffect(() => {
246
+ stdout?.write('\x1b[?1000;1006h');
247
+ return () => {
248
+ try {
249
+ stdout?.write('\x1b[?1000;1006l');
250
+ }
251
+ catch {
252
+ // 卸载收尾时写不进就放弃,别让退出路径再抛错
253
+ }
254
+ };
255
+ }, [stdout]);
256
+ /** Composer 草稿镜像(双击 Esc 撤回判断输入框是否为空)。 */
257
+ const handleDraftChange = useCallback((text) => {
258
+ draftRef.current = text;
259
+ }, []);
260
+ // notice 8 秒自动过期:提示盒常驻会挡住后续操作语义(用户反馈:命令提示
261
+ // 一直展示);有新 notice 就重置计时。不做「打字即清」——双击 Esc 撤回会把
262
+ // 文本灌回输入框(非空草稿事件),当场抹掉刚设置的撤回提示(电池实锤)。
263
+ useEffect(() => {
264
+ if (notice === null)
265
+ return;
266
+ const timer = setTimeout(() => setNotice(null), 8_000);
267
+ return () => clearTimeout(timer);
268
+ }, [notice]);
269
+ // 图片预览的字符画现算:preview(含 index)一变就重渲染当前那张。
270
+ useEffect(() => {
271
+ if (preview === null) {
272
+ setPreviewBlock(null);
273
+ setPreviewError(null);
274
+ setPreviewLoading(false);
275
+ return;
276
+ }
277
+ const source = preview.sources[preview.index];
278
+ if (source === undefined)
279
+ return;
280
+ let cancelled = false;
281
+ setPreviewLoading(true);
282
+ setPreviewError(null);
283
+ const render = imageRenderer ?? renderImageBlock;
284
+ render(source, Math.max(10, (stdout?.columns ?? 80) - 4), Math.max(4, (stdout?.rows ?? 24) - 10))
285
+ .then((block) => {
286
+ if (cancelled)
287
+ return;
288
+ setPreviewBlock(block);
289
+ setPreviewLoading(false);
290
+ })
291
+ .catch((cause) => {
292
+ if (cancelled)
293
+ return;
294
+ setPreviewBlock(null);
295
+ setPreviewLoading(false);
296
+ setPreviewError(cause instanceof Error ? cause.message : String(cause));
297
+ });
298
+ return () => {
299
+ cancelled = true;
300
+ };
301
+ }, [preview, imageRenderer, stdout]);
302
+ // 卡片换人(或消失)时复位对应的本地状态。
303
+ useEffect(() => setApprovalExpanded(false), [approval?.id]);
304
+ useEffect(() => {
305
+ setPlanExpanded(false);
306
+ setPlanFeedback(false);
307
+ }, [plan?.file, plan?.title]);
308
+ useEffect(() => {
309
+ setAskIndex(0);
310
+ setAskChecked([]);
311
+ setAskHighlight(0);
312
+ setAskText('');
313
+ }, [question?.id]);
314
+ /** 提问卡推进到下一题(最后一题交出后服务收卡,本地进度直接归零)。 */
315
+ const advanceAsk = () => {
316
+ setAskChecked([]);
317
+ setAskHighlight(0);
318
+ setAskText('');
319
+ setAskIndex((current) => (current + 1 < askQuestions.length ? current + 1 : 0));
320
+ };
321
+ /** 交出当前题的答案:有自由文本用文本,否则按勾选(多选)或高亮(单选)。 */
322
+ const submitAsk = (raw) => {
323
+ if (question === null || currentQuestion === undefined)
324
+ return;
325
+ let answer = raw.trim();
326
+ if (answer === '') {
327
+ if (currentQuestion.multiSelect) {
328
+ const labels = askChecked
329
+ .map((position) => currentQuestion.options[position]?.label)
330
+ .filter((label) => label !== undefined);
331
+ if (labels.length === 0)
332
+ return;
333
+ answer = labels.join('、');
334
+ }
335
+ else {
336
+ const option = currentQuestion.options[askHighlight];
337
+ if (option === undefined)
338
+ return;
339
+ answer = option.label;
340
+ }
341
+ }
342
+ runtime.answerQuestion(answer);
343
+ advanceAsk();
344
+ };
345
+ // ---- 会话选择器的数据整形:置顶优先、最近更新在前,输入即筛选 ----
346
+ const pickerSource = useMemo(() => {
347
+ const source = pickerPage === 'active'
348
+ ? [...snapshot.sessions]
349
+ : archivedList.map((item) => ({
350
+ id: item.path,
351
+ cwd: item.cwd,
352
+ createdAt: item.createdAt,
353
+ updatedAt: item.updatedAt,
354
+ ...(item.title !== undefined ? { title: item.title } : {}),
355
+ }));
356
+ source.sort((a, b) => (b.pinnedAt ?? 0) - (a.pinnedAt ?? 0) || b.updatedAt - a.updatedAt);
357
+ return source;
358
+ }, [pickerPage, snapshot.sessions, archivedList]);
359
+ /** 工作区分桶(当前页数据源按 cwd 归堆):当前会话所在工作区置顶,其余按最新会话时间降序。 */
360
+ const workspaceEntries = useMemo(() => {
361
+ const buckets = new Map();
362
+ for (const session of pickerSource) {
363
+ const bucket = buckets.get(session.cwd);
364
+ if (bucket === undefined) {
365
+ buckets.set(session.cwd, { cwd: session.cwd, count: 1, latest: session.updatedAt });
366
+ }
367
+ else {
368
+ bucket.count += 1;
369
+ bucket.latest = Math.max(bucket.latest, session.updatedAt);
370
+ }
371
+ }
372
+ const currentCwd = snapshot.status.cwd ?? null;
373
+ return [...buckets.values()].sort((a, b) => (a.cwd === currentCwd ? 0 : 1) - (b.cwd === currentCwd ? 0 : 1) || b.latest - a.latest);
374
+ }, [pickerSource, snapshot.status.cwd]);
375
+ /** 工作区层 = 未钻取且工作区不止一个(单工作区直落会话层,省一次回车)。 */
376
+ const activeWorkspace = pickerWorkspace ?? (workspaceEntries.length === 1 ? (workspaceEntries[0]?.cwd ?? null) : null);
377
+ const isWorkspaceLevel = activeWorkspace === null;
378
+ /** 工作区层的筛选(名称/路径子串)。 */
379
+ const workspaceList = useMemo(() => {
380
+ const q = pickerQuery.trim().toLowerCase();
381
+ if (q === '')
382
+ return workspaceEntries;
383
+ return workspaceEntries.filter((entry) => workspaceLabel(entry.cwd).toLowerCase().includes(q) || entry.cwd.toLowerCase().includes(q));
384
+ }, [workspaceEntries, pickerQuery]);
385
+ /** 会话层 = 已选工作区(或单工作区直落)的会话,再过筛选词。 */
386
+ const pickerList = useMemo(() => {
387
+ const scoped = activeWorkspace === null
388
+ ? pickerSource
389
+ : pickerSource.filter((session) => session.cwd === activeWorkspace);
390
+ const q = pickerQuery.trim().toLowerCase();
391
+ if (q === '')
392
+ return scoped;
393
+ return scoped.filter((session) => (session.title ?? '').toLowerCase().includes(q) ||
394
+ session.cwd.toLowerCase().includes(q) ||
395
+ session.id.toLowerCase().includes(q));
396
+ }, [pickerSource, activeWorkspace, pickerQuery]);
397
+ // ---- 恒定帧与各视口的窗口切片 ----
398
+ const termRows = stdout?.rows ?? 24;
399
+ /** 帧内容行数:终端行数 − 1(ink 帧自带尾随换行,末行留给光标落点)。 */
400
+ const frameRows = Math.max(1, termRows - 1);
401
+ /** 状态栏行数(0.6.57 去掉描边框后固定两行)。 */
402
+ const statusbarLines = 2;
403
+ /** 当前层的行数(工作区层 = 工作区数,会话层 = 会话数);窗口切片与点击映射都按它算。 */
404
+ const pickerRowCount = isWorkspaceLevel ? workspaceList.length : pickerList.length;
405
+ /** 选择器列表窗口:框内除固定框架外全部让给列表(点击行号映射按它 1:1 对齐)。 */
406
+ const pickerListRows = Math.min(Math.max(pickerRowCount, 0), Math.max(1, frameRows - statusbarLines - PICKER_CHROME));
407
+ /** 窗口起点:选中项尽量居中(fzf 式),两端夹住;列表放得下时等于 0。 */
408
+ const pickerStart = Math.min(Math.max(0, pickerIndex - Math.floor((pickerListRows - 1) / 2)), Math.max(0, pickerRowCount - pickerListRows));
409
+ const visibleSessions = pickerList.slice(pickerStart, pickerStart + pickerListRows);
410
+ const visibleWorkspaces = workspaceList
411
+ .slice(pickerStart, pickerStart + pickerListRows)
412
+ .map((entry) => ({
413
+ cwd: entry.cwd,
414
+ name: workspaceLabel(entry.cwd),
415
+ count: entry.count,
416
+ latest: entry.latest,
417
+ current: entry.cwd !== '' && entry.cwd === snapshot.status.cwd,
418
+ }));
419
+ /** 聊天窗口:末端锚在 chatAnchor(null = 跟最新),窗口向历史方向展开。 */
420
+ const chatEnd = Math.min(chatAnchor ?? snapshot.entries.length, snapshot.entries.length);
421
+ const chatWindow = snapshot.entries.slice(Math.max(0, chatEnd - CHAT_WINDOW), chatEnd);
422
+ // ---- 设置页(/settings)的行模型与窗口切片(几何与 SettingsOverlay 共表)----
423
+ const settingsRows = useMemo(() => buildSettingsRows(settingsSections, settingsSection, settingsGroup), [settingsSections, settingsSection, settingsGroup]);
424
+ const settingsFocusables = useMemo(() => focusableRows(settingsRows, settingsSections), [settingsRows, settingsSections]);
425
+ /** 焦点行 = focusables 里的第 index 个;列表变短时夹住(分区装载前后都安全)。 */
426
+ const settingsFocusRow = settingsFocusables[Math.min(settingsIndex, Math.max(0, settingsFocusables.length - 1))] ?? 0;
427
+ /** 设置页视口:帧内扣除固定框架(上下边框 2 + 标题 1 + notice 1 + 提示条 1)。 */
428
+ const settingsViewport = Math.max(1, frameRows - statusbarLines - SETTINGS_CHROME);
429
+ const settingsWindow = settingsWindowStart(settingsFocusRow, settingsViewport, settingsRows.length);
430
+ /** 回看浮层的窗口(offset 是从尾部往回的条数)。 */
431
+ const overlayTotal = snapshot.entries.length;
432
+ const overlayEnd = Math.max(1, overlayTotal - Math.min(scrollOffset, Math.max(0, overlayTotal - 1)));
433
+ const overlayStart = Math.max(0, overlayEnd - OVERLAY_WINDOW);
434
+ const overlayWindow = snapshot.entries.slice(overlayStart, overlayEnd);
435
+ /** 聊天回看滚动:delta 负数往历史翻,翻到最底(end=len)就回到直播态。 */
436
+ const scrollChat = (delta) => {
437
+ setChatAnchor((current) => {
438
+ const length = snapshot.entries.length;
439
+ const end = Math.min(current ?? length, length);
440
+ const next = end + delta;
441
+ return next >= length ? null : Math.max(0, next);
442
+ });
443
+ };
444
+ /** 归档页的数据加载(Tab 切页时拉一次;动作之后刷新也走这里)。 */
445
+ const reloadArchived = useCallback(() => {
446
+ void runtime
447
+ .listArchivedSessions()
448
+ .then((page) => setArchivedList(page.items))
449
+ .catch(() => setArchivedList([]));
450
+ }, [runtime]);
451
+ const togglePickerPage = () => {
452
+ setPickerArmed(false);
453
+ setPickerBuffer(null);
454
+ setPickerIndex(0);
455
+ setPickerQuery('');
456
+ // 两页的工作区集合不同:切页回工作区层重新选(dsh 总管同语义)。
457
+ setPickerWorkspace(null);
458
+ if (pickerPage === 'active') {
459
+ setPickerPage('archived');
460
+ reloadArchived();
461
+ }
462
+ else {
463
+ setPickerPage('active');
464
+ void runtime.refreshSessions();
465
+ }
466
+ };
467
+ /** 选择器里的会话动作(改名/置顶/归档/恢复/删除/分叉)统一收口:跑完刷新 + 错误上屏。 */
468
+ const pickerAction = (work) => {
469
+ void work()
470
+ .then((result) => {
471
+ if (result !== undefined && result.ok === false)
472
+ setNotice(result.error ?? '操作失败');
473
+ if (pickerPage === 'active')
474
+ void runtime.refreshSessions();
475
+ else
476
+ reloadArchived();
477
+ })
478
+ .catch((cause) => setNotice(cause instanceof Error ? cause.message : String(cause)));
479
+ };
480
+ /** 打开当前选中会话(Enter 与「点击已选中行」共用):归档页先恢复回活动区再打开。 */
481
+ const openSelectedSession = () => {
482
+ const selected = pickerList[pickerIndex];
483
+ if (selected === undefined)
484
+ return;
485
+ setPicker(false);
486
+ setChatAnchor(null);
487
+ if (pickerPage === 'archived') {
488
+ pickerAction(() => runtime.restoreSessions([selected.id]));
489
+ void runtime.openSession(selected.id);
490
+ }
491
+ else {
492
+ void runtime.openSession(selected.id);
493
+ }
494
+ };
495
+ /** 应用当前选中的模型(Enter 与「点击已选中项」共用)。 */
496
+ const applyModel = () => {
497
+ const choice = modelList[modelIndex];
498
+ if (choice === undefined)
499
+ return;
500
+ setModelPicker(false);
501
+ void runtime.setModel(choice.value);
502
+ };
503
+ /** 应用当前选中的模式(Enter 与「点击已选中项」共用):回执走 notice。 */
504
+ const applyPreset = () => {
505
+ const preset = presetList[presetIndex];
506
+ if (preset === undefined)
507
+ return;
508
+ setPresetPicker(false);
509
+ const mutation = runtime.usePreset(preset.name);
510
+ setNotice(mutation.ok ? mutation.notice ?? `已切换到模式「${preset.label}」` : mutation.error);
511
+ };
512
+ /** 应用当前选中的技能(Enter 与「点击已选中项」共用):把 /技能名 灌回输入行。 */
513
+ const applySkill = () => {
514
+ const skill = skillsList[skillsIndex];
515
+ if (skill === undefined)
516
+ return;
517
+ if (!skill.userInvocable) {
518
+ setNotice(`技能 ${skill.name} 没注册成命令(不进模型目录),不能这样调用`);
519
+ return;
520
+ }
521
+ setSkillsPicker(false);
522
+ setNotice(null);
523
+ setComposerPreset({ text: `/${skill.name} `, token: Date.now() });
524
+ };
525
+ // ---- 0.6.61:设置页的动作(Enter 与鼠标点击共用的唯一真源)----
526
+ /** 写一个设置项:回执进设置页底部 notice 行;成功后就地刷新值表(改动即保存)。 */
527
+ const applySetting = (sectionId, key, value) => {
528
+ void runtime
529
+ .setSettingValue(sectionId, key, value)
530
+ .then((mutation) => {
531
+ if (!mutation.ok) {
532
+ setSettingsNotice({ ok: false, text: mutation.error });
533
+ return;
534
+ }
535
+ setSettingsValues((current) => ({
536
+ ...current,
537
+ [sectionId]: { ...current[sectionId], [key]: value },
538
+ }));
539
+ setSettingsNotice({ ok: true, text: mutation.notice ?? '已保存' });
540
+ // 思考块默认展开除了新会话语义,当前会话也当场跟着切
541
+ if (sectionId === 'tui' && key === 'reasoningDefaultOpen')
542
+ setExpandThinking(value === true);
543
+ // 状态栏段开关(0.6.62):就地改 state,关页即见(静默保存,无回执)
544
+ if (sectionId === 'tui' && key.startsWith('statusBar.')) {
545
+ setStatusBarPrefs((current) => ({ ...current, [key.slice('statusBar.'.length)]: value === true }));
546
+ }
547
+ })
548
+ .catch((cause) => setSettingsNotice({ ok: false, text: cause instanceof Error ? cause.message : String(cause) }));
549
+ };
550
+ /** 执行分区动作(button 字段):回执可能带结构化载荷(发布页链接等),TUI 只显示文案。 */
551
+ const runSettingsAction = (sectionId, action) => {
552
+ void runtime
553
+ .runSettingAction(sectionId, action)
554
+ .then((mutation) => {
555
+ if (!mutation.ok) {
556
+ setSettingsNotice({ ok: false, text: mutation.error });
557
+ return;
558
+ }
559
+ const fallback = mutation.data?.kind === 'url' ? mutation.data.url : '已完成';
560
+ setSettingsNotice({ ok: true, text: mutation.notice ?? fallback });
561
+ })
562
+ .catch((cause) => setSettingsNotice({ ok: false, text: cause instanceof Error ? cause.message : String(cause) }));
563
+ };
564
+ /** info.copyable 行的复制:/copy 同款(win32 clip / darwin pbcopy / linux wl-copy)。 */
565
+ const copyInfoText = (text) => {
566
+ const command = process.platform === 'darwin' ? 'pbcopy' : process.platform === 'win32' ? 'clip' : 'wl-copy';
567
+ try {
568
+ const child = spawn(command, [], { stdio: ['pipe', 'ignore', 'ignore'] });
569
+ child.on('error', () => setSettingsNotice({ ok: false, text: `复制失败:找不到 ${command} 命令` }));
570
+ child.stdin?.end(text);
571
+ setSettingsNotice({ ok: true, text: `已复制:${text}` });
572
+ }
573
+ catch (error) {
574
+ setSettingsNotice({
575
+ ok: false,
576
+ text: `复制失败:${error instanceof Error ? error.message : String(error)}`,
577
+ });
578
+ }
579
+ };
580
+ /** 行 → 字段解析(结构行或下标越界返回 null)。 */
581
+ const settingsFieldAt = (row) => {
582
+ if (row === undefined || row.kind !== 'field')
583
+ return null;
584
+ const section = settingsSections.find((entry) => entry.id === row.sectionId);
585
+ const field = section?.fields[row.fieldIndex];
586
+ return field !== undefined ? { sectionId: row.sectionId, field } : null;
587
+ };
588
+ /** 行的主动作(Enter 与「点击该行」共用):switch/select 改值即存,text/number 进编辑。 */
589
+ const activateSettingsRow = (row, direction) => {
590
+ if (row?.kind === 'section') {
591
+ // 进分区页(0.6.64 两级导航):焦点与草稿归零;Esc 由键盘分支逐级退栈
592
+ setSettingsSection(row.sectionId);
593
+ setSettingsIndex(0);
594
+ setSettingsEdit(null);
595
+ return;
596
+ }
597
+ if (row?.kind === 'group') {
598
+ // 进组子页(dsh 同款):焦点与草稿归零;Esc 由键盘分支先退子页再关页
599
+ setSettingsGroup({ sectionId: row.sectionId, groupId: row.groupId });
600
+ setSettingsIndex(0);
601
+ setSettingsEdit(null);
602
+ return;
603
+ }
604
+ if (row?.kind === 'hint') {
605
+ if (row.jump === 'model-picker') {
606
+ setSettingsOpen(false);
607
+ setModelPicker(true);
608
+ setModelIndex(0);
609
+ setModelQuery('');
610
+ }
611
+ else if (row.jump === 'usage') {
612
+ setSettingsOpen(false);
613
+ runCommand('/usage', runtime, {
614
+ openPicker: openSessionPicker,
615
+ openModels: () => { },
616
+ openAgents,
617
+ notice: setNotice,
618
+ });
619
+ }
620
+ return;
621
+ }
622
+ const hit = settingsFieldAt(row);
623
+ if (hit === null)
624
+ return;
625
+ const { sectionId, field } = hit;
626
+ if (field.type === 'switch') {
627
+ applySetting(sectionId, field.key, settingsValues[sectionId]?.[field.key] === true ? false : true);
628
+ return;
629
+ }
630
+ if (field.type === 'select') {
631
+ const options = field.options;
632
+ if (options.length === 0)
633
+ return;
634
+ const current = String(settingsValues[sectionId]?.[field.key] ?? '');
635
+ const at = options.findIndex((option) => option.value === current);
636
+ const next = options[(((at + direction) % options.length) + options.length) % options.length] ?? options[0];
637
+ if (next !== undefined)
638
+ applySetting(sectionId, field.key, next.value);
639
+ return;
640
+ }
641
+ if (field.type === 'text' || field.type === 'number') {
642
+ const current = settingsValues[sectionId]?.[field.key];
643
+ setSettingsEdit({ sectionId, key: field.key, draft: current === undefined ? '' : String(current) });
644
+ return;
645
+ }
646
+ if (field.type === 'button') {
647
+ runSettingsAction(sectionId, field.action);
648
+ return;
649
+ }
650
+ if (field.type === 'info' && field.copyable === true)
651
+ copyInfoText(field.text);
652
+ };
653
+ /** 编辑态 Enter:number 先校验(非法留编辑态弹红,对齐 dsh),text 直接入库。 */
654
+ const commitSettingsEdit = () => {
655
+ if (settingsEdit === null)
656
+ return;
657
+ const hit = settingsFieldAt(settingsRows[settingsFocusRow]);
658
+ if (hit === null || !('key' in hit.field) || hit.field.key !== settingsEdit.key) {
659
+ setSettingsEdit(null);
660
+ return;
661
+ }
662
+ if (hit.field.type === 'number') {
663
+ const parsed = Number(settingsEdit.draft);
664
+ const invalid = settingsEdit.draft.trim() === '' ||
665
+ Number.isNaN(parsed) ||
666
+ (hit.field.min !== undefined && parsed < hit.field.min) ||
667
+ (hit.field.max !== undefined && parsed > hit.field.max);
668
+ if (invalid) {
669
+ const range = `${hit.field.min ?? '-∞'}–${hit.field.max ?? '∞'}`;
670
+ setSettingsNotice({ ok: false, text: `无效输入:需要 ${range} 之间的数字` });
671
+ return;
672
+ }
673
+ setSettingsEdit(null);
674
+ applySetting(hit.sectionId, hit.field.key, parsed);
675
+ return;
676
+ }
677
+ setSettingsEdit(null);
678
+ if (hit.field.type === 'text')
679
+ applySetting(hit.sectionId, hit.field.key, settingsEdit.draft);
680
+ };
681
+ // ---- 0.6.57:双击 Esc 撤回上一轮 ----
682
+ /**
683
+ * 撤回上一轮(对齐 codex 的 backtrack 语义、dsh 的 fork 实现):fork 出
684
+ * 「最后一条用户消息之前」的新会话并切换过去,原话放回输入框改完重发;
685
+ * 原会话原样保留(不删任何条目,/resume 里随时找回)。
686
+ */
687
+ const rewindLastTurn = () => {
688
+ const path = snapshot.status.sessionId;
689
+ if (path === null || path === '') {
690
+ setNotice('还没有对话可撤回');
691
+ return;
692
+ }
693
+ void runtime
694
+ .listUserMessages(path)
695
+ .then(async (messages) => {
696
+ const last = messages[messages.length - 1];
697
+ if (last === undefined)
698
+ return '这个会话还没有用户消息,没得撤';
699
+ const fork = await runtime.forkSession(path, messages.length - 1);
700
+ if (!fork.ok)
701
+ return fork.error === '' ? '撤回失败' : fork.error;
702
+ await runtime.openSession(fork.path);
703
+ setComposerPreset((current) => ({ text: last, token: current.token + 1 }));
704
+ setChatAnchor(null);
705
+ setAttachments([]);
706
+ return '已撤回上一轮,原话已放回输入框(原会话保留在 /resume)';
707
+ })
708
+ .then((message) => {
709
+ if (typeof message === 'string')
710
+ setNotice(message);
711
+ })
712
+ .catch((cause) => setNotice(cause instanceof Error ? cause.message : String(cause)));
713
+ };
714
+ // ---- 0.6.57:剪贴板贴图与附件芯片 ----
715
+ /** Ctrl+V:剪贴板里是图就挂芯片(提交时读成 data URL),是文本就并入草稿。 */
716
+ const handlePaste = () => {
717
+ const read = clipboardReader ?? readClipboardImage;
718
+ void read()
719
+ .then((result) => {
720
+ if (result.kind === 'image') {
721
+ attachmentSeq.current += 1;
722
+ const id = attachmentSeq.current;
723
+ setAttachments((current) => [
724
+ ...current,
725
+ {
726
+ id,
727
+ path: result.path,
728
+ name: result.path.split(/[\\/]/).pop() ?? result.path,
729
+ },
730
+ ]);
731
+ setNotice(`已附加图片 #${id}(点击芯片预览,Enter 随消息发送)`);
732
+ return;
733
+ }
734
+ if (result.kind === 'text' && result.text.trim() !== '') {
735
+ setComposerPreset((current) => ({
736
+ text: draftRef.current + result.text,
737
+ token: current.token + 1,
738
+ }));
739
+ return;
740
+ }
741
+ setNotice('剪贴板里没有图片(文字粘贴交给终端,Ctrl+V 只接图)');
742
+ })
743
+ .catch(() => setNotice('剪贴板读取失败'));
744
+ };
745
+ /** 摘下一枚附件芯片。 */
746
+ const removeAttachment = (id) => {
747
+ setAttachments((current) => current.filter((att) => att.id !== id));
748
+ };
749
+ /** 点附件芯片:开这张图的预览。 */
750
+ const previewAttachment = (id) => {
751
+ const att = attachments.find((item) => item.id === id);
752
+ if (att === undefined)
753
+ return;
754
+ setPreview({ title: att.name, sources: [{ path: att.path }], index: 0 });
755
+ };
756
+ /** 点会话流里的图片行:预览历史消息带的图(data URL 现场落临时文件解码)。 */
757
+ const handlePreviewImages = useCallback((images) => {
758
+ setPreview({
759
+ title: `图片(${images.length} 张)`,
760
+ sources: images.map((dataUrl) => ({ dataUrl })),
761
+ index: 0,
762
+ });
763
+ }, []);
764
+ // ---- 0.6.57:子代理查看 ----
765
+ /** 打开某个代理/后台会话的只读转录(peek 不改文件)。 */
766
+ const openAgentTranscript = useCallback((file, title) => {
767
+ setAgentView({ mode: 'transcript', file, title });
768
+ setAgentEntries(null);
769
+ setScrollOffset(0);
770
+ void runtime
771
+ .peekTranscript(file)
772
+ .then((entries) => setAgentEntries(entries))
773
+ .catch(() => setAgentEntries([]));
774
+ }, [runtime]);
775
+ /** /agents 打开名单浮层(命令 ui 回调)。 */
776
+ const openAgents = useCallback(() => {
777
+ setAgentView({ mode: 'list' });
778
+ setAgentIndex(0);
779
+ }, []);
780
+ /** 打开设置页(/settings 命令入口):同步拿分区表,值表逐分区异步装填。 */
781
+ const openSettings = useCallback(() => {
782
+ const sections = runtime.getSettingsSections();
783
+ setSettingsSections(sections);
784
+ setSettingsValues({});
785
+ setSettingsIndex(0);
786
+ setSettingsEdit(null);
787
+ setSettingsNotice(null);
788
+ setSettingsGroup(null);
789
+ setSettingsSection(null);
790
+ setSettingsOpen(true);
791
+ for (const section of sections) {
792
+ void runtime
793
+ .getSectionValues(section.id)
794
+ .then((sectionValues) => {
795
+ setSettingsValues((current) => ({ ...current, [section.id]: sectionValues }));
796
+ })
797
+ .catch(() => {
798
+ // 单个分区取值失败不拖垮整页:空表 = 控件显示占位,保存时由后端报错
799
+ setSettingsValues((current) => ({ ...current, [section.id]: {} }));
800
+ });
801
+ }
802
+ }, [runtime]);
803
+ /** 打开会话选择器(/resume 命令、输入框 ⌸ 按钮、点击入口共用一条通道)。 */
804
+ const openSessionPicker = useCallback(() => {
805
+ setPicker(true);
806
+ setPickerIndex(0);
807
+ setPickerQuery('');
808
+ setPickerPage('active');
809
+ setPickerWorkspace(null);
810
+ void runtime.refreshSessions();
811
+ }, [runtime]);
812
+ /** 工作区层的 Enter/再点:钻进该工作区的会话列表(清筛选,焦点回顶)。 */
813
+ const enterWorkspace = (index) => {
814
+ const entry = workspaceList[index];
815
+ if (entry === undefined)
816
+ return;
817
+ setPickerWorkspace(entry.cwd);
818
+ setPickerIndex(0);
819
+ setPickerQuery('');
820
+ setPickerArmed(false);
821
+ };
822
+ /** 名单浮层的行(队友在前、后台会话在后;与渲染同一条装配规则)。 */
823
+ const agentRows = agentView !== null && agentView.mode === 'list'
824
+ ? buildAgentRows(runtime.listTeammates(), snapshot.sessionStates)
825
+ : [];
826
+ // ---- 卡片鼠标动作(与按键一一等价;键盘路由仍是唯一真源,这里只是映射)----
827
+ const handleApprovalAction = (action) => {
828
+ if (approval === null)
829
+ return;
830
+ if (action === 'allow-once')
831
+ runtime.answerApproval('allow-once');
832
+ else if (action === 'allow-session') {
833
+ if (approval.scopes.includes('session'))
834
+ runtime.answerApproval('allow-session');
835
+ }
836
+ else if (action === 'allow-always') {
837
+ if (approval.scopes.includes('always'))
838
+ runtime.answerApproval('allow-always');
839
+ }
840
+ else if (action === 'reject')
841
+ runtime.answerApproval('reject');
842
+ else if (action === 'toggle-diff')
843
+ setApprovalExpanded((current) => !current);
844
+ };
845
+ const handlePlanAction = (action) => {
846
+ if (action === 'approve')
847
+ runtime.answerPlan('approved');
848
+ else if (action === 'reject')
849
+ runtime.answerPlan('rejected');
850
+ else if (action === 'feedback')
851
+ setPlanFeedback(true);
852
+ else if (action === 'toggle')
853
+ setPlanExpanded((current) => !current);
854
+ };
855
+ const handleAskOption = (option) => {
856
+ if (question === null || currentQuestion === undefined)
857
+ return;
858
+ if (currentQuestion.multiSelect) {
859
+ setAskChecked((current) => current.includes(option)
860
+ ? current.filter((position) => position !== option)
861
+ : [...current, option]);
862
+ return;
863
+ }
864
+ const chosen = currentQuestion.options[option];
865
+ if (chosen === undefined)
866
+ return;
867
+ runtime.answerQuestion(chosen.label);
868
+ advanceAsk();
869
+ };
870
+ useInput((input, key) => {
871
+ // SGR 鼠标事件最顶层拦截:滚轮按状态路由,左键点击派发给命中区。
872
+ const mouse = /^\[<(\d+);(\d+);(\d+)([Mm])$/.exec(input);
873
+ if (mouse !== null) {
874
+ const [, button, colText, rowText, phase] = mouse;
875
+ const col = Number(colText);
876
+ const row = Number(rowText);
877
+ if (button === '64' || button === '65') {
878
+ // 滚轮:64 上 / 65 下,一步一条(浮层/聊天同款颗粒度)。
879
+ const step = button === '64' ? -1 : 1;
880
+ if (picker) {
881
+ setPickerIndex((current) => Math.max(0, Math.min(current + step, pickerRowCount - 1)));
882
+ }
883
+ else if (modelPicker) {
884
+ setModelIndex((current) => Math.max(0, Math.min(current + step, modelList.length - 1)));
885
+ }
886
+ else if (presetPicker) {
887
+ setPresetIndex((current) => Math.max(0, Math.min(current + step, presetList.length - 1)));
888
+ }
889
+ else if (skillsPicker) {
890
+ setSkillsIndex((current) => Math.max(0, Math.min(current + step, skillsList.length - 1)));
891
+ }
892
+ else if (agentView !== null) {
893
+ if (agentView.mode === 'list') {
894
+ setAgentIndex((current) => Math.max(0, Math.min(current + step, agentRows.length - 1)));
895
+ }
896
+ else {
897
+ const maxOffset = Math.max(0, (agentEntries?.length ?? 0) - 1);
898
+ setScrollOffset((current) => Math.max(0, Math.min(current - step, maxOffset)));
899
+ }
900
+ }
901
+ else if (transcriptOpen) {
902
+ const maxOffset = Math.max(0, snapshot.entries.length - 1);
903
+ setScrollOffset((current) => Math.max(0, Math.min(current - step, maxOffset)));
904
+ }
905
+ else if (settingsOpen) {
906
+ // 设置页滚轮 = 移动焦点(dsh 同语义),窗口随焦点跟随
907
+ setSettingsIndex((current) => Math.max(0, Math.min(current + step, Math.max(0, settingsFocusables.length - 1))));
908
+ }
909
+ else {
910
+ scrollChat(step);
911
+ }
912
+ return;
913
+ }
914
+ if (button !== '0' || phase !== 'M')
915
+ return; // 只认左键按下;释放与右/中键忽略
916
+ if (picker) {
917
+ if (pickerBuffer !== null)
918
+ return; // 改名输入态不响应鼠标
919
+ // 列表行从「顶边框+标题+筛选行」之后起排(改名行再往下顺延一行)。
920
+ const listTop = 3 + (pickerBuffer !== null ? 1 : 0);
921
+ const row0 = row - 1 - listTop;
922
+ if (row0 < 0 || row0 >= pickerListRows)
923
+ return;
924
+ const hit = pickerStart + row0;
925
+ // 两级行结构相同(listTop/切片一致):工作区层再点 = 钻入,会话层再点 = 打开。
926
+ if (hit !== pickerIndex) {
927
+ setPickerIndex(hit);
928
+ return;
929
+ }
930
+ if (isWorkspaceLevel)
931
+ enterWorkspace(hit);
932
+ else
933
+ openSelectedSession();
934
+ return;
935
+ }
936
+ if (modelPicker) {
937
+ const row0 = row - 1 - 3;
938
+ if (row0 < 0 || row0 >= modelList.length)
939
+ return;
940
+ if (row0 === modelIndex)
941
+ applyModel();
942
+ else
943
+ setModelIndex(row0);
944
+ return;
945
+ }
946
+ if (presetPicker) {
947
+ const row0 = row - 1 - 3;
948
+ if (row0 < 0 || row0 >= presetList.length)
949
+ return;
950
+ if (row0 === presetIndex)
951
+ applyPreset();
952
+ else
953
+ setPresetIndex(row0);
954
+ return;
955
+ }
956
+ if (skillsPicker) {
957
+ const row0 = row - 1 - 3;
958
+ if (row0 < 0 || row0 >= skillsList.length)
959
+ return;
960
+ if (row0 === skillsIndex)
961
+ applySkill();
962
+ else
963
+ setSkillsIndex(row0);
964
+ return;
965
+ }
966
+ if (settingsOpen) {
967
+ if (settingsEdit !== null)
968
+ return; // 草稿由键盘独占(对齐 dsh 的编辑态)
969
+ // 列表行从「外框顶边 + 标题行」之后起排,滚动窗口与组件共用同一份行模型
970
+ const slice = row - 1 - SETTINGS_LIST_TOP;
971
+ if (slice < 0 || slice >= settingsViewport)
972
+ return;
973
+ const target = settingsRows[settingsWindow + slice];
974
+ if (target === undefined || (target.kind !== 'field' && target.kind !== 'hint' && target.kind !== 'group' && target.kind !== 'section'))
975
+ return;
976
+ const fields = settingsSections.find((section) => section.id === target.sectionId)?.fields ?? [];
977
+ if (!isFocusableRow(target, fields))
978
+ return;
979
+ activateSettingsRow(target, 1);
980
+ return;
981
+ }
982
+ // 卡片页脚按钮 / 提问选项 / 回底提示条 / 附件与后台芯片 / 图片行:点击时现量
983
+ // 几何(避免节流渲染导致的滞后),再询问判定函数;谁命中谁消费。
984
+ for (const entry of clickRegions.current) {
985
+ const top = absoluteTop(entry.node.current);
986
+ const height = measuredHeight(entry.node.current);
987
+ if (top === null || height === null)
988
+ continue;
989
+ if (entry.hit(col - 1, row - 1, top, height))
990
+ return;
991
+ }
992
+ return;
993
+ }
994
+ // 任何非 Esc 按键都取消「再按一次 Esc」的 prime 态(对齐 codex 的 backtrack)。
995
+ if (!key.escape)
996
+ lastEsc.current = 0;
997
+ // Ctrl+V 贴图:终端把粘贴限定成文本,纯图片剪贴板不发任何字节——按键层自己接。
998
+ if (key.ctrl && input === 'v' && !modal) {
999
+ handlePaste();
1000
+ return;
1001
+ }
1002
+ if (key.ctrl && input === 'c') {
1003
+ const now = Date.now();
1004
+ if (now - lastCtrlC.current < EXIT_WINDOW_MS) {
1005
+ runtime.exit();
1006
+ return;
1007
+ }
1008
+ lastCtrlC.current = now;
1009
+ if (snapshot.status.turnState !== 'idle')
1010
+ runtime.interrupt();
1011
+ else
1012
+ setNotice('再按一次 Ctrl+C 退出');
1013
+ return;
1014
+ }
1015
+ if (approval !== null) {
1016
+ if (input === 'y' || input === 'Y')
1017
+ runtime.answerApproval('allow-once');
1018
+ else if (input === 'a' || input === 'A') {
1019
+ if (approval.scopes.includes('session'))
1020
+ runtime.answerApproval('allow-session');
1021
+ }
1022
+ else if (input === 'p' || input === 'P') {
1023
+ if (approval.scopes.includes('always'))
1024
+ runtime.answerApproval('allow-always');
1025
+ }
1026
+ else if (input === 'n' || input === 'N' || key.escape)
1027
+ runtime.answerApproval('reject');
1028
+ else if ((input === 'v' || input === 'V') && approval.diff !== undefined)
1029
+ setApprovalExpanded((current) => !current);
1030
+ return;
1031
+ }
1032
+ if (question !== null) {
1033
+ const optionCount = currentQuestion?.options.length ?? 0;
1034
+ if (key.upArrow) {
1035
+ setAskHighlight((current) => Math.max(0, current - 1));
1036
+ }
1037
+ else if (key.downArrow) {
1038
+ setAskHighlight((current) => Math.min(optionCount - 1, current + 1));
1039
+ }
1040
+ else if (key.escape) {
1041
+ runtime.answerQuestion(SKIPPED_ANSWER);
1042
+ advanceAsk();
1043
+ }
1044
+ else if (key.return) {
1045
+ submitAsk(askText);
1046
+ }
1047
+ else if (key.backspace || key.delete) {
1048
+ setAskText((current) => current.slice(0, -1));
1049
+ }
1050
+ else if (input === ' ' && optionCount > 0 && currentQuestion !== undefined) {
1051
+ // 空格在选择题里是「选定/勾选」;有自由文本需求时打字即可(数字不占用)。
1052
+ if (currentQuestion.multiSelect) {
1053
+ setAskChecked((current) => current.includes(askHighlight)
1054
+ ? current.filter((position) => position !== askHighlight)
1055
+ : [...current, askHighlight]);
1056
+ }
1057
+ else {
1058
+ const option = currentQuestion.options[askHighlight];
1059
+ if (option !== undefined) {
1060
+ runtime.answerQuestion(option.label);
1061
+ advanceAsk();
1062
+ }
1063
+ }
1064
+ }
1065
+ else if (!key.ctrl && !key.meta && !key.tab) {
1066
+ const printable = input.replace(/[\r\n]+/g, '');
1067
+ if (printable !== '')
1068
+ setAskText((current) => current + printable);
1069
+ }
1070
+ return;
1071
+ }
1072
+ if (planFeedback) {
1073
+ // 反馈文本由 Composer 承接(Enter 走 handleSubmit),这里只管 Esc 收摊。
1074
+ if (key.escape)
1075
+ setPlanFeedback(false);
1076
+ return;
1077
+ }
1078
+ if (plan !== null) {
1079
+ if (input === 'y' || input === 'Y')
1080
+ runtime.answerPlan('approved');
1081
+ else if (input === 'n' || input === 'N' || key.escape)
1082
+ runtime.answerPlan('rejected');
1083
+ else if (input === 'e' || input === 'E')
1084
+ setPlanFeedback(true);
1085
+ else if (input === 'v' || input === 'V')
1086
+ setPlanExpanded((current) => !current);
1087
+ return;
1088
+ }
1089
+ // 图片预览浮层:Esc / 点击关闭,←→ 在同一批图里切换。
1090
+ if (preview !== null) {
1091
+ if (key.escape)
1092
+ setPreview(null);
1093
+ else if (key.leftArrow)
1094
+ setPreview((current) => current === null ? current : { ...current, index: Math.max(0, current.index - 1) });
1095
+ else if (key.rightArrow)
1096
+ setPreview((current) => current === null
1097
+ ? current
1098
+ : { ...current, index: Math.min(current.sources.length - 1, current.index + 1) });
1099
+ return;
1100
+ }
1101
+ // 子代理浮层:名单(Enter/点击看转录)与转录(回看浮层同款滚动)两种形态。
1102
+ if (agentView !== null) {
1103
+ if (agentView.mode === 'list') {
1104
+ if (key.escape)
1105
+ setAgentView(null);
1106
+ else if (key.return) {
1107
+ const row = agentRows[agentIndex];
1108
+ if (row !== undefined)
1109
+ openAgentTranscript(row.file, row.title);
1110
+ }
1111
+ else if (key.upArrow)
1112
+ setAgentIndex((current) => Math.max(0, current - 1));
1113
+ else if (key.downArrow)
1114
+ setAgentIndex((current) => Math.min(agentRows.length - 1, current + 1));
1115
+ return;
1116
+ }
1117
+ const agentTotal = agentEntries?.length ?? 0;
1118
+ const maxOffset = Math.max(0, agentTotal - 1);
1119
+ if (key.escape || input === 'q')
1120
+ setAgentView(null);
1121
+ else if (key.upArrow || input === 'k')
1122
+ setScrollOffset((current) => Math.min(maxOffset, current + 1));
1123
+ else if (key.downArrow || input === 'j')
1124
+ setScrollOffset((current) => Math.max(0, current - 1));
1125
+ else if (key.pageUp)
1126
+ setScrollOffset((current) => Math.min(maxOffset, current + 10));
1127
+ else if (key.pageDown)
1128
+ setScrollOffset((current) => Math.max(0, current - 10));
1129
+ return;
1130
+ }
1131
+ if (transcriptOpen) {
1132
+ const maxOffset = Math.max(0, snapshot.entries.length - 1);
1133
+ if (key.escape || input === 'q' || (key.ctrl && input === 'o'))
1134
+ setTranscriptOpen(false);
1135
+ else if (key.upArrow || input === 'k')
1136
+ setScrollOffset((current) => Math.min(maxOffset, current + 1));
1137
+ else if (key.downArrow || input === 'j')
1138
+ setScrollOffset((current) => Math.max(0, current - 1));
1139
+ else if (key.pageUp)
1140
+ setScrollOffset((current) => Math.min(maxOffset, current + 10));
1141
+ else if (key.pageDown)
1142
+ setScrollOffset((current) => Math.max(0, current - 10));
1143
+ return;
1144
+ }
1145
+ if (picker) {
1146
+ const selected = pickerList[pickerIndex];
1147
+ // 改名态:输入行归改名缓冲
1148
+ if (pickerBuffer !== null) {
1149
+ if (key.escape)
1150
+ setPickerBuffer(null);
1151
+ else if (key.return) {
1152
+ if (selected !== undefined && pickerBuffer.trim() !== '') {
1153
+ const title = pickerBuffer.trim();
1154
+ pickerAction(() => runtime.renameSession(selected.id, title));
1155
+ }
1156
+ setPickerBuffer(null);
1157
+ }
1158
+ else if (key.backspace || key.delete)
1159
+ setPickerBuffer((current) => (current ?? '').slice(0, -1));
1160
+ else if (!key.ctrl && !key.meta) {
1161
+ const printable = input.replace(/[\r\n]+/g, '');
1162
+ if (printable !== '')
1163
+ setPickerBuffer((current) => (current ?? '') + printable);
1164
+ }
1165
+ return;
1166
+ }
1167
+ if (key.escape) {
1168
+ if (pickerArmed)
1169
+ setPickerArmed(false);
1170
+ else if (pickerWorkspace !== null) {
1171
+ // 会话层 Esc 先回工作区层(dsh 子页惯例);单工作区直落时没有上层,直接关。
1172
+ setPickerWorkspace(null);
1173
+ setPickerIndex(0);
1174
+ }
1175
+ else
1176
+ setPicker(false);
1177
+ return;
1178
+ }
1179
+ if (key.tab) {
1180
+ togglePickerPage();
1181
+ return;
1182
+ }
1183
+ if (key.return) {
1184
+ if (isWorkspaceLevel)
1185
+ enterWorkspace(pickerIndex);
1186
+ else
1187
+ openSelectedSession();
1188
+ return;
1189
+ }
1190
+ if (key.upArrow) {
1191
+ setPickerIndex((current) => Math.max(0, current - 1));
1192
+ return;
1193
+ }
1194
+ if (key.downArrow) {
1195
+ setPickerIndex((current) => Math.min(pickerRowCount - 1, current + 1));
1196
+ return;
1197
+ }
1198
+ if (key.ctrl) {
1199
+ // 动作键全走 Ctrl 组合——普通字符留给筛选输入;工作区层没有会话动作。
1200
+ if (isWorkspaceLevel)
1201
+ return;
1202
+ if (input === 'r' && selected !== undefined) {
1203
+ setPickerBuffer(selected.title ?? '');
1204
+ }
1205
+ else if (input === 'p' && selected !== undefined) {
1206
+ const pinned = selected.pinnedAt !== undefined;
1207
+ pickerAction(() => runtime.setSessionPinned(selected.id, !pinned));
1208
+ }
1209
+ else if (input === 'a' && pickerPage === 'active' && selected !== undefined) {
1210
+ pickerAction(() => runtime.archiveSessions([selected.id]));
1211
+ }
1212
+ else if (input === 'u' && pickerPage === 'archived' && selected !== undefined) {
1213
+ pickerAction(() => runtime.restoreSessions([selected.id]));
1214
+ }
1215
+ else if (input === 'x' && selected !== undefined) {
1216
+ if (pickerArmed) {
1217
+ setPickerArmed(false);
1218
+ pickerAction(() => runtime.purgeSessions([selected.id]));
1219
+ }
1220
+ else {
1221
+ setPickerArmed(true);
1222
+ }
1223
+ }
1224
+ else if (input === 'f' && selected !== undefined) {
1225
+ pickerAction(() => runtime
1226
+ .listUserMessages(selected.id)
1227
+ .then((messages) => runtime.forkSession(selected.id, messages.length))
1228
+ .then((result) => {
1229
+ if (result.ok) {
1230
+ setPicker(false);
1231
+ void runtime.openSession(result.path);
1232
+ }
1233
+ return result.ok ? { ok: true } : { ok: false, error: '分叉失败' };
1234
+ }));
1235
+ }
1236
+ return;
1237
+ }
1238
+ // 普通字符:筛选输入
1239
+ if (key.backspace || key.delete) {
1240
+ setPickerQuery((current) => current.slice(0, -1));
1241
+ setPickerIndex(0);
1242
+ return;
1243
+ }
1244
+ if (!key.meta) {
1245
+ const printable = input.replace(/[\r\n\t]+/g, '');
1246
+ if (printable !== '') {
1247
+ setPickerQuery((current) => current + printable);
1248
+ setPickerIndex(0);
1249
+ setPickerArmed(false);
1250
+ }
1251
+ }
1252
+ return;
1253
+ }
1254
+ if (modelPicker) {
1255
+ if (key.escape)
1256
+ setModelPicker(false);
1257
+ else if (key.return) {
1258
+ applyModel();
1259
+ }
1260
+ else if (key.upArrow)
1261
+ setModelIndex((current) => Math.max(0, current - 1));
1262
+ else if (key.downArrow)
1263
+ setModelIndex((current) => Math.min(modelList.length - 1, current + 1));
1264
+ else if (key.backspace || key.delete) {
1265
+ setModelQuery((current) => current.slice(0, -1));
1266
+ setModelIndex(0);
1267
+ }
1268
+ else if (!key.ctrl && !key.meta) {
1269
+ const printable = input.replace(/[\r\n\t]+/g, '');
1270
+ if (printable !== '') {
1271
+ setModelQuery((current) => current + printable);
1272
+ setModelIndex(0);
1273
+ }
1274
+ }
1275
+ return;
1276
+ }
1277
+ // 模式浮层:与模型浮层同款(输入即筛选、Enter 切换、Esc 关)。
1278
+ if (presetPicker) {
1279
+ if (key.escape)
1280
+ setPresetPicker(false);
1281
+ else if (key.return)
1282
+ applyPreset();
1283
+ else if (key.upArrow)
1284
+ setPresetIndex((current) => Math.max(0, current - 1));
1285
+ else if (key.downArrow)
1286
+ setPresetIndex((current) => Math.min(presetList.length - 1, current + 1));
1287
+ else if (key.backspace || key.delete) {
1288
+ setPresetQuery((current) => current.slice(0, -1));
1289
+ setPresetIndex(0);
1290
+ }
1291
+ else if (!key.ctrl && !key.meta) {
1292
+ const printable = input.replace(/[\r\n\t]+/g, '');
1293
+ if (printable !== '') {
1294
+ setPresetQuery((current) => current + printable);
1295
+ setPresetIndex(0);
1296
+ }
1297
+ }
1298
+ return;
1299
+ }
1300
+ // 技能浮层:同款;Enter 对不可回填的技能只提示不关页。
1301
+ if (skillsPicker) {
1302
+ if (key.escape)
1303
+ setSkillsPicker(false);
1304
+ else if (key.return)
1305
+ applySkill();
1306
+ else if (key.upArrow)
1307
+ setSkillsIndex((current) => Math.max(0, current - 1));
1308
+ else if (key.downArrow)
1309
+ setSkillsIndex((current) => Math.min(skillsList.length - 1, current + 1));
1310
+ else if (key.backspace || key.delete) {
1311
+ setSkillsQuery((current) => current.slice(0, -1));
1312
+ setSkillsIndex(0);
1313
+ }
1314
+ else if (!key.ctrl && !key.meta) {
1315
+ const printable = input.replace(/[\r\n\t]+/g, '');
1316
+ if (printable !== '') {
1317
+ setSkillsQuery((current) => current + printable);
1318
+ setSkillsIndex(0);
1319
+ }
1320
+ }
1321
+ return;
1322
+ }
1323
+ // 设置页:编辑态独占键盘(对齐 dsh,草稿之外的一切都不响应);其余 ↑↓ 焦点、
1324
+ // ←→ 循环 select、Enter 主动作(切换/编辑/执行/复制/跳转)、Esc 关页。
1325
+ if (settingsOpen) {
1326
+ const at = Math.min(settingsIndex, Math.max(0, settingsFocusables.length - 1));
1327
+ const focusRow = settingsFocusables[at] ?? 0;
1328
+ if (settingsEdit !== null) {
1329
+ if (key.escape) {
1330
+ setSettingsEdit(null);
1331
+ }
1332
+ else if (key.return) {
1333
+ commitSettingsEdit();
1334
+ }
1335
+ else if (key.backspace || key.delete) {
1336
+ setSettingsEdit({ ...settingsEdit, draft: settingsEdit.draft.slice(0, -1) });
1337
+ }
1338
+ else if (!key.ctrl && !key.meta) {
1339
+ const printable = input.replace(/[\r\n\t]+/g, '');
1340
+ if (printable !== '') {
1341
+ setSettingsEdit({ ...settingsEdit, draft: settingsEdit.draft + printable });
1342
+ }
1343
+ }
1344
+ return;
1345
+ }
1346
+ if (key.escape) {
1347
+ // 逐级退栈(dsh 同款:子页里 Esc 是「返回上级」):组子页 → 分区页 → 根页 → 关页
1348
+ if (settingsGroup !== null) {
1349
+ setSettingsGroup(null);
1350
+ setSettingsIndex(0);
1351
+ }
1352
+ else if (settingsSection !== null) {
1353
+ setSettingsSection(null);
1354
+ setSettingsIndex(0);
1355
+ }
1356
+ else {
1357
+ setSettingsOpen(false);
1358
+ }
1359
+ return;
1360
+ }
1361
+ if (key.upArrow) {
1362
+ setSettingsIndex(Math.max(0, at - 1));
1363
+ return;
1364
+ }
1365
+ if (key.downArrow) {
1366
+ setSettingsIndex(Math.min(settingsFocusables.length - 1, at + 1));
1367
+ return;
1368
+ }
1369
+ if (key.return || key.rightArrow)
1370
+ activateSettingsRow(settingsRows[focusRow], 1);
1371
+ else if (key.leftArrow)
1372
+ activateSettingsRow(settingsRows[focusRow], -1);
1373
+ return;
1374
+ }
1375
+ // 回到底部 pill 可见且输入为空时:Enter/End 跳回最新(codex/dsh 同语义;
1376
+ // 输入非空时 End 仍归 Composer 的光标移动)。
1377
+ if (chatAnchor !== null && !modal && !panelOpen && draftRef.current === '') {
1378
+ if (key.end || key.return) {
1379
+ setChatAnchor(null);
1380
+ return;
1381
+ }
1382
+ }
1383
+ // Esc(对齐 codex):回合跑着 = 打断;空闲且输入框为空 = prime 撤回——双击
1384
+ // Esc 把上一轮撤掉、原话放回输入框(dsh 同款 3 秒窗口)。补全面板开着时
1385
+ // Esc 只关面板。
1386
+ if (key.escape && !panelOpen) {
1387
+ if (snapshot.status.turnState !== 'idle') {
1388
+ runtime.interrupt();
1389
+ return;
1390
+ }
1391
+ if (draftRef.current === '') {
1392
+ const now = Date.now();
1393
+ if (now - lastEsc.current < REWIND_WINDOW_MS) {
1394
+ lastEsc.current = 0;
1395
+ rewindLastTurn();
1396
+ }
1397
+ else {
1398
+ lastEsc.current = now;
1399
+ setNotice('再按一次 Esc:撤回上一轮对话');
1400
+ }
1401
+ }
1402
+ return;
1403
+ }
1404
+ // 聊天回看(对齐 codex 的 PgUp/PgDn;滚轮同义,↑↓ 留给输入框历史)。
1405
+ if (key.pageUp) {
1406
+ scrollChat(-10);
1407
+ return;
1408
+ }
1409
+ if (key.pageDown) {
1410
+ scrollChat(10);
1411
+ return;
1412
+ }
1413
+ if (key.ctrl && input === 't') {
1414
+ setExpandThinking((current) => !current);
1415
+ return;
1416
+ }
1417
+ if (key.ctrl && input === 'o') {
1418
+ setScrollOffset(0);
1419
+ setTranscriptOpen(true);
1420
+ return;
1421
+ }
1422
+ });
1423
+ const handleSubmit = (text) => {
1424
+ setNotice(null);
1425
+ setChatAnchor(null);
1426
+ if (planFeedback) {
1427
+ setPlanFeedback(false);
1428
+ if (text !== '')
1429
+ runtime.answerPlan('rejected', text);
1430
+ return;
1431
+ }
1432
+ if (text.startsWith('/')) {
1433
+ runCommand(text, runtime, {
1434
+ openPicker: openSessionPicker,
1435
+ openModels: () => {
1436
+ setModelPicker(true);
1437
+ setModelIndex(0);
1438
+ setModelQuery('');
1439
+ },
1440
+ openPresets: () => {
1441
+ setPresetPicker(true);
1442
+ setPresetIndex(0);
1443
+ setPresetQuery('');
1444
+ },
1445
+ openSkills: () => {
1446
+ setSkillsPicker(true);
1447
+ setSkillsIndex(0);
1448
+ setSkillsQuery('');
1449
+ },
1450
+ toggleThinking: (visible) => {
1451
+ const next = visible ?? !expandThinking;
1452
+ setExpandThinking(next);
1453
+ setNotice(next ? '思考块已展开(Ctrl+T 随时切换)' : '思考块已折叠(Ctrl+T 随时切换)');
1454
+ },
1455
+ openAgents,
1456
+ openSettings,
1457
+ notice: setNotice,
1458
+ });
1459
+ return;
1460
+ }
1461
+ // 图片合流:附件芯片(剪贴板贴图)先读成 data URL,正文里的图片路径交给
1462
+ // extractImages;两类失败一起提示。发完即清空芯片。
1463
+ const fromChips = [];
1464
+ const failedChips = [];
1465
+ for (const att of attachments) {
1466
+ try {
1467
+ fromChips.push(readImageAsDataUrl(att.path));
1468
+ }
1469
+ catch {
1470
+ failedChips.push(att.name);
1471
+ }
1472
+ }
1473
+ setAttachments([]);
1474
+ const attached = extractImages(text);
1475
+ const failed = [...failedChips, ...attached.failed];
1476
+ if (failed.length > 0) {
1477
+ setNotice(`图片读取失败(太大或 IO 错误):${failed.join('、')}`);
1478
+ }
1479
+ const images = [...fromChips, ...attached.images];
1480
+ runtime.submit(attached.text, images.length > 0 ? images : undefined);
1481
+ };
1482
+ const modal = approval !== null ||
1483
+ question !== null ||
1484
+ picker ||
1485
+ transcriptOpen ||
1486
+ modelPicker ||
1487
+ presetPicker ||
1488
+ skillsPicker ||
1489
+ settingsOpen ||
1490
+ preview !== null ||
1491
+ agentView !== null ||
1492
+ (plan !== null && !planFeedback);
1493
+ /** 子代理转录的窗口切片(与回看浮层同一套「条」滚动)。 */
1494
+ const agentTotal = agentEntries?.length ?? 0;
1495
+ const agentEnd = Math.max(1, agentTotal - Math.min(scrollOffset, Math.max(0, agentTotal - 1)));
1496
+ const agentWindow = (agentEntries ?? []).slice(Math.max(0, agentEnd - OVERLAY_WINDOW), agentEnd);
1497
+ return (_jsxs(Box, { height: frameRows, width: "100%", flexDirection: "column", overflow: "hidden", paddingX: PAD.page, children: [preview !== null ? (_jsx(PreviewOverlay, { title: preview.title, index: preview.index, total: preview.sources.length, block: previewBlock, loading: previewLoading, error: previewError, registerClick: registerClick, onClose: () => setPreview(null) })) : agentView !== null && agentView.mode === 'list' ? (_jsx(AgentsOverlay, { rows: agentRows, index: agentIndex })) : agentView !== null && agentView.mode === 'transcript' ? (_jsx(TranscriptOverlay, { entries: agentWindow, start: Math.max(0, agentEnd - agentWindow.length), total: agentTotal, title: agentView.title })) : picker ? (_jsx(SessionPicker, { level: isWorkspaceLevel ? 'workspaces' : 'sessions', workspaces: visibleWorkspaces, workspaceTitle: pickerWorkspace === null ? null : workspaceLabel(pickerWorkspace), sessions: visibleSessions, total: isWorkspaceLevel ? workspaceList.length : pickerList.length, start: pickerStart, index: pickerIndex, page: pickerPage, query: pickerQuery, buffer: pickerBuffer, armed: pickerArmed, loading: snapshot.sessionsLoading, sessionStates: snapshot.sessionStates })) : transcriptOpen ? (_jsx(TranscriptOverlay, { entries: overlayWindow, start: overlayStart, total: overlayTotal })) : modelPicker ? (_jsx(ModelPicker, { models: modelList, index: modelIndex, query: modelQuery })) : presetPicker && presetSurface !== null ? (_jsx(PresetPicker, { presets: presetList, current: presetSurface.current, defaultName: presetSurface.defaultName, index: presetIndex, query: presetQuery })) : skillsPicker ? (_jsx(SkillsPicker, { skills: skillsList, index: skillsIndex, query: skillsQuery })) : settingsOpen ? (_jsx(SettingsOverlay, { sections: settingsSections, rows: settingsRows, values: settingsValues, focusRow: settingsFocusRow, windowStart: settingsWindow, viewport: settingsViewport, editing: settingsEdit, notice: settingsNotice, section: settingsSection, group: settingsGroup })) : (_jsxs(_Fragment, { children: [_jsx(Box, { flexDirection: "column", flexGrow: 1, overflowY: "hidden", justifyContent: "flex-end", children: _jsx(ChatView, { entries: chatWindow, turnState: snapshot.status.turnState, expandThinking: expandThinking, empty: snapshot.entries.length === 0, header: snapshot.entries.length < WELCOME_MAX_ENTRIES ? (_jsx(Welcome, { model: snapshot.status.model, effort: snapshot.status.effort ?? '-', cwd: snapshot.status.cwd })) : undefined, onPreviewImages: handlePreviewImages, onOpenAgent: (file) => openAgentTranscript(file, shortId(file)), registerClick: registerClick }) }), _jsxs(Box, { flexShrink: 0, flexDirection: "column", children: [_jsx(TaskStrips, { goal: snapshot.surfaces.goal, todos: snapshot.surfaces.todos }), approval !== null ? (_jsx(ApprovalCard, { request: approval, expanded: approvalExpanded, onAction: handleApprovalAction, registerClick: registerClick })) : null, approval === null && question !== null ? (_jsx(AskCard, { ask: question, index: askIndex, checked: askChecked, highlight: askHighlight, text: askText, onOptionClick: handleAskOption, registerClick: registerClick })) : null, approval === null && question === null && plan !== null ? (_jsx(PlanReviewCard, { plan: plan, expanded: planExpanded, feedbacking: planFeedback, onAction: handlePlanAction, registerClick: registerClick })) : null, notice !== null ? (_jsx(Box, { borderStyle: "single", borderColor: BORDER.frame, paddingX: PAD.inline, marginTop: GAP.tight, children: _jsx(Text, { ...TEXT.label, color: STATUS_COLOR.waiting, children: notice }) })) : null, tuiNoticeExtras, chatAnchor !== null ? (_jsx(TailIndicator, { hidden: snapshot.entries.length - chatEnd, onJump: () => setChatAnchor(null), registerClick: registerClick })) : null, _jsx(Composer, { disabled: modal, models: models, placeholder: planFeedback ? '反馈原话(Enter 退回计划,Esc 取消)' : undefined, completionsEnabled: !planFeedback, lister: dockLister, onPanelOpenChange: setPanelOpen, onDraftChange: handleDraftChange, preset: composerPreset, attachments: attachments, onRemoveAttachment: removeAttachment, onPreviewAttachment: previewAttachment, onOpenSessions: openSessionPicker, working: snapshot.status.turnState !== 'idle', registerClick: registerClick, onSubmit: handleSubmit })] })] })), _jsx(Box, { flexShrink: 0, children: _jsx(StatusBar, { status: snapshot.status, surfaces: snapshot.surfaces, subagents: snapshot.subagents ?? [], queued: (snapshot.queued ?? []).length + (snapshot.notices ?? []).length, config: statusBarPrefs, onOpenAgent: (sessionPath) => openAgentTranscript(sessionPath, shortId(sessionPath)), registerClick: registerClick }) })] }));
1498
+ }