@di-code/coding-agent 0.1.6 → 0.1.8

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 (338) hide show
  1. package/README.md +112 -68
  2. package/compositions/base.yml +54 -0
  3. package/compositions/interactive.yml +14 -0
  4. package/compositions/json.yml +6 -0
  5. package/compositions/print.yml +5 -0
  6. package/compositions/rpc.yml +12 -0
  7. package/compositions/webui.yml +9 -0
  8. package/dist/cli.d.ts +22 -1
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +97 -3
  11. package/dist/cli.js.map +1 -1
  12. package/dist/composition-loader-entry.d.ts +11 -0
  13. package/dist/composition-loader-entry.d.ts.map +1 -0
  14. package/dist/composition-loader-entry.js +12 -0
  15. package/dist/composition-loader-entry.js.map +1 -0
  16. package/dist/compositions.d.ts +32 -0
  17. package/dist/compositions.d.ts.map +1 -0
  18. package/dist/compositions.js +173 -0
  19. package/dist/compositions.js.map +1 -0
  20. package/dist/core/session/session-manager.d.ts +9 -2
  21. package/dist/core/session/session-manager.d.ts.map +1 -1
  22. package/dist/core/session/session-manager.js +28 -0
  23. package/dist/core/session/session-manager.js.map +1 -1
  24. package/dist/core/session/session-storage.d.ts.map +1 -1
  25. package/dist/core/session/session-storage.js +20 -3
  26. package/dist/core/session/session-storage.js.map +1 -1
  27. package/dist/core/session/types.d.ts +11 -2
  28. package/dist/core/session/types.d.ts.map +1 -1
  29. package/dist/core/session/types.js.map +1 -1
  30. package/dist/core/session-tools.d.ts +5 -0
  31. package/dist/core/session-tools.d.ts.map +1 -0
  32. package/dist/core/session-tools.js +17 -0
  33. package/dist/core/session-tools.js.map +1 -0
  34. package/dist/core/session.d.ts +21 -7
  35. package/dist/core/session.d.ts.map +1 -1
  36. package/dist/core/session.js +77 -41
  37. package/dist/core/session.js.map +1 -1
  38. package/dist/core/tools/bash.d.ts +1 -38
  39. package/dist/core/tools/bash.d.ts.map +1 -1
  40. package/dist/core/tools/bash.js +1 -207
  41. package/dist/core/tools/bash.js.map +1 -1
  42. package/dist/core/tools/edit-diff.d.ts +1 -24
  43. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  44. package/dist/core/tools/edit-diff.js +1 -135
  45. package/dist/core/tools/edit-diff.js.map +1 -1
  46. package/dist/core/tools/edit.d.ts +1 -26
  47. package/dist/core/tools/edit.d.ts.map +1 -1
  48. package/dist/core/tools/edit.js +1 -140
  49. package/dist/core/tools/edit.js.map +1 -1
  50. package/dist/core/tools/file-mutation-queue.d.ts +1 -1
  51. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  52. package/dist/core/tools/file-mutation-queue.js +1 -23
  53. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  54. package/dist/core/tools/file-search.d.ts +1 -13
  55. package/dist/core/tools/file-search.d.ts.map +1 -1
  56. package/dist/core/tools/file-search.js +1 -98
  57. package/dist/core/tools/file-search.js.map +1 -1
  58. package/dist/core/tools/glob.d.ts +1 -10
  59. package/dist/core/tools/glob.d.ts.map +1 -1
  60. package/dist/core/tools/glob.js +1 -43
  61. package/dist/core/tools/glob.js.map +1 -1
  62. package/dist/core/tools/grep.d.ts +1 -12
  63. package/dist/core/tools/grep.d.ts.map +1 -1
  64. package/dist/core/tools/grep.js +1 -66
  65. package/dist/core/tools/grep.js.map +1 -1
  66. package/dist/core/tools/load-skill.d.ts +1 -9
  67. package/dist/core/tools/load-skill.d.ts.map +1 -1
  68. package/dist/core/tools/load-skill.js +1 -21
  69. package/dist/core/tools/load-skill.js.map +1 -1
  70. package/dist/core/tools/path-boundary.d.ts +1 -4
  71. package/dist/core/tools/path-boundary.d.ts.map +1 -1
  72. package/dist/core/tools/path-boundary.js +1 -65
  73. package/dist/core/tools/path-boundary.js.map +1 -1
  74. package/dist/core/tools/read.d.ts +1 -16
  75. package/dist/core/tools/read.d.ts.map +1 -1
  76. package/dist/core/tools/read.js +1 -131
  77. package/dist/core/tools/read.js.map +1 -1
  78. package/dist/core/tools/write.d.ts +1 -16
  79. package/dist/core/tools/write.d.ts.map +1 -1
  80. package/dist/core/tools/write.js +1 -44
  81. package/dist/core/tools/write.js.map +1 -1
  82. package/dist/entry.js +30 -28
  83. package/dist/entry.js.map +1 -1
  84. package/dist/i18n.d.ts.map +1 -1
  85. package/dist/i18n.js +2 -0
  86. package/dist/i18n.js.map +1 -1
  87. package/dist/index.d.ts +6 -3
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +6 -3
  90. package/dist/index.js.map +1 -1
  91. package/dist/interactive/builtin.d.ts +17 -0
  92. package/dist/interactive/builtin.d.ts.map +1 -0
  93. package/dist/interactive/builtin.js +47 -0
  94. package/dist/interactive/builtin.js.map +1 -0
  95. package/dist/interactive/controller.d.ts +85 -0
  96. package/dist/interactive/controller.d.ts.map +1 -0
  97. package/dist/interactive/controller.js +211 -0
  98. package/dist/interactive/controller.js.map +1 -0
  99. package/dist/interactive/index.d.ts +3 -0
  100. package/dist/interactive/index.d.ts.map +1 -0
  101. package/dist/interactive/index.js +3 -0
  102. package/dist/interactive/index.js.map +1 -0
  103. package/dist/interactive-host-entry.d.ts +7 -0
  104. package/dist/interactive-host-entry.d.ts.map +1 -0
  105. package/dist/interactive-host-entry.js +123 -0
  106. package/dist/interactive-host-entry.js.map +1 -0
  107. package/dist/interactive-profile.d.ts +18 -0
  108. package/dist/interactive-profile.d.ts.map +1 -0
  109. package/dist/interactive-profile.js +290 -0
  110. package/dist/interactive-profile.js.map +1 -0
  111. package/dist/interactive-resources-entry.d.ts +7 -0
  112. package/dist/interactive-resources-entry.d.ts.map +1 -0
  113. package/dist/interactive-resources-entry.js +42 -0
  114. package/dist/interactive-resources-entry.js.map +1 -0
  115. package/dist/legacy-main.d.ts +39 -0
  116. package/dist/legacy-main.d.ts.map +1 -0
  117. package/dist/legacy-main.js +611 -0
  118. package/dist/legacy-main.js.map +1 -0
  119. package/dist/main.d.ts +15 -34
  120. package/dist/main.d.ts.map +1 -1
  121. package/dist/main.js +130 -513
  122. package/dist/main.js.map +1 -1
  123. package/dist/mcp/entries.d.ts +42 -0
  124. package/dist/mcp/entries.d.ts.map +1 -0
  125. package/dist/mcp/entries.js +98 -0
  126. package/dist/mcp/entries.js.map +1 -0
  127. package/dist/mcp-client-entry.d.ts +5 -0
  128. package/dist/mcp-client-entry.d.ts.map +1 -0
  129. package/dist/mcp-client-entry.js +6 -0
  130. package/dist/mcp-client-entry.js.map +1 -0
  131. package/dist/mcp-config-entry.d.ts +5 -0
  132. package/dist/mcp-config-entry.d.ts.map +1 -0
  133. package/dist/mcp-config-entry.js +6 -0
  134. package/dist/mcp-config-entry.js.map +1 -0
  135. package/dist/mcp-tools-entry.d.ts +5 -0
  136. package/dist/mcp-tools-entry.d.ts.map +1 -0
  137. package/dist/mcp-tools-entry.js +6 -0
  138. package/dist/mcp-tools-entry.js.map +1 -0
  139. package/dist/mcp-transport-entry.d.ts +5 -0
  140. package/dist/mcp-transport-entry.d.ts.map +1 -0
  141. package/dist/mcp-transport-entry.js +6 -0
  142. package/dist/mcp-transport-entry.js.map +1 -0
  143. package/dist/modes/interactive-entry.d.ts +18 -0
  144. package/dist/modes/interactive-entry.d.ts.map +1 -0
  145. package/dist/modes/interactive-entry.js +21 -0
  146. package/dist/modes/interactive-entry.js.map +1 -0
  147. package/dist/modes/interactive-state.js +1 -1
  148. package/dist/modes/interactive-state.js.map +1 -1
  149. package/dist/modes/interactive.d.ts +16 -6
  150. package/dist/modes/interactive.d.ts.map +1 -1
  151. package/dist/modes/interactive.js +99 -33
  152. package/dist/modes/interactive.js.map +1 -1
  153. package/dist/modes/json-entry.d.ts +13 -0
  154. package/dist/modes/json-entry.d.ts.map +1 -0
  155. package/dist/modes/json-entry.js +14 -0
  156. package/dist/modes/json-entry.js.map +1 -0
  157. package/dist/modes/json.d.ts +4 -1
  158. package/dist/modes/json.d.ts.map +1 -1
  159. package/dist/modes/json.js +3 -3
  160. package/dist/modes/json.js.map +1 -1
  161. package/dist/modes/print-entry.d.ts +10 -0
  162. package/dist/modes/print-entry.d.ts.map +1 -0
  163. package/dist/modes/print-entry.js +11 -0
  164. package/dist/modes/print-entry.js.map +1 -0
  165. package/dist/modes/tree-selector.d.ts.map +1 -1
  166. package/dist/modes/tree-selector.js +4 -0
  167. package/dist/modes/tree-selector.js.map +1 -1
  168. package/dist/plugin-dump-composition.d.ts +6 -0
  169. package/dist/plugin-dump-composition.d.ts.map +1 -0
  170. package/dist/plugin-dump-composition.js +7 -0
  171. package/dist/plugin-dump-composition.js.map +1 -0
  172. package/dist/plugin-inventory.d.ts +7 -0
  173. package/dist/plugin-inventory.d.ts.map +1 -0
  174. package/dist/plugin-inventory.js +8 -0
  175. package/dist/plugin-inventory.js.map +1 -0
  176. package/dist/plugin-manager.d.ts +6 -0
  177. package/dist/plugin-manager.d.ts.map +1 -0
  178. package/dist/plugin-manager.js +7 -0
  179. package/dist/plugin-manager.js.map +1 -0
  180. package/dist/plugin-trace.d.ts +6 -0
  181. package/dist/plugin-trace.d.ts.map +1 -0
  182. package/dist/plugin-trace.js +7 -0
  183. package/dist/plugin-trace.js.map +1 -0
  184. package/dist/plugins/dynamic-broker.d.ts +76 -0
  185. package/dist/plugins/dynamic-broker.d.ts.map +1 -0
  186. package/dist/plugins/dynamic-broker.js +852 -0
  187. package/dist/plugins/dynamic-broker.js.map +1 -0
  188. package/dist/plugins/profile.d.ts +15 -0
  189. package/dist/plugins/profile.d.ts.map +1 -0
  190. package/dist/plugins/profile.js +34 -0
  191. package/dist/plugins/profile.js.map +1 -0
  192. package/dist/plugins/runtime-host.d.ts +37 -0
  193. package/dist/plugins/runtime-host.d.ts.map +1 -0
  194. package/dist/plugins/runtime-host.js +95 -0
  195. package/dist/plugins/runtime-host.js.map +1 -0
  196. package/dist/plugins/trust.d.ts +8 -0
  197. package/dist/plugins/trust.d.ts.map +1 -0
  198. package/dist/plugins/trust.js +59 -0
  199. package/dist/plugins/trust.js.map +1 -0
  200. package/dist/project-trust-entry.d.ts +15 -0
  201. package/dist/project-trust-entry.d.ts.map +1 -0
  202. package/dist/project-trust-entry.js +15 -0
  203. package/dist/project-trust-entry.js.map +1 -0
  204. package/dist/rpc/client.d.ts +78 -6
  205. package/dist/rpc/client.d.ts.map +1 -1
  206. package/dist/rpc/client.js +172 -4
  207. package/dist/rpc/client.js.map +1 -1
  208. package/dist/rpc/dispatcher.d.ts +121 -0
  209. package/dist/rpc/dispatcher.d.ts.map +1 -0
  210. package/dist/rpc/dispatcher.js +994 -0
  211. package/dist/rpc/dispatcher.js.map +1 -0
  212. package/dist/rpc/index.d.ts +2 -0
  213. package/dist/rpc/index.d.ts.map +1 -1
  214. package/dist/rpc/index.js +2 -0
  215. package/dist/rpc/index.js.map +1 -1
  216. package/dist/rpc/lifecycle.d.ts +6 -0
  217. package/dist/rpc/lifecycle.d.ts.map +1 -0
  218. package/dist/rpc/lifecycle.js +24 -0
  219. package/dist/rpc/lifecycle.js.map +1 -0
  220. package/dist/rpc/protocol.d.ts +112 -31
  221. package/dist/rpc/protocol.d.ts.map +1 -1
  222. package/dist/rpc/protocol.js +569 -117
  223. package/dist/rpc/protocol.js.map +1 -1
  224. package/dist/rpc/server-service.d.ts +7 -0
  225. package/dist/rpc/server-service.d.ts.map +1 -0
  226. package/dist/rpc/server-service.js +3 -0
  227. package/dist/rpc/server-service.js.map +1 -0
  228. package/dist/rpc/server.d.ts +16 -19
  229. package/dist/rpc/server.d.ts.map +1 -1
  230. package/dist/rpc/server.js +59 -115
  231. package/dist/rpc/server.js.map +1 -1
  232. package/dist/rpc-client-sdk-entry.d.ts +12 -0
  233. package/dist/rpc-client-sdk-entry.d.ts.map +1 -0
  234. package/dist/rpc-client-sdk-entry.js +11 -0
  235. package/dist/rpc-client-sdk-entry.js.map +1 -0
  236. package/dist/rpc-entry.js +50 -18
  237. package/dist/rpc-entry.js.map +1 -1
  238. package/dist/rpc-server-entry.d.ts +8 -0
  239. package/dist/rpc-server-entry.d.ts.map +1 -0
  240. package/dist/rpc-server-entry.js +67 -0
  241. package/dist/rpc-server-entry.js.map +1 -0
  242. package/dist/runtime/attachment-store.d.ts +13 -0
  243. package/dist/runtime/attachment-store.d.ts.map +1 -0
  244. package/dist/runtime/attachment-store.js +93 -0
  245. package/dist/runtime/attachment-store.js.map +1 -0
  246. package/dist/runtime/bootstrap.d.ts +14 -0
  247. package/dist/runtime/bootstrap.d.ts.map +1 -0
  248. package/dist/runtime/bootstrap.js +29 -0
  249. package/dist/runtime/bootstrap.js.map +1 -0
  250. package/dist/runtime/interactive-host-service.d.ts +22 -0
  251. package/dist/runtime/interactive-host-service.d.ts.map +1 -0
  252. package/dist/runtime/interactive-host-service.js +2 -0
  253. package/dist/runtime/interactive-host-service.js.map +1 -0
  254. package/dist/runtime/interactive-resource-service.d.ts +11 -0
  255. package/dist/runtime/interactive-resource-service.d.ts.map +1 -0
  256. package/dist/runtime/interactive-resource-service.js +3 -0
  257. package/dist/runtime/interactive-resource-service.js.map +1 -0
  258. package/dist/runtime/plugin-inventory-entry.d.ts +5 -0
  259. package/dist/runtime/plugin-inventory-entry.d.ts.map +1 -0
  260. package/dist/runtime/plugin-inventory-entry.js +18 -0
  261. package/dist/runtime/plugin-inventory-entry.js.map +1 -0
  262. package/dist/runtime/plugin-inventory-service.d.ts +8 -0
  263. package/dist/runtime/plugin-inventory-service.d.ts.map +1 -0
  264. package/dist/runtime/plugin-inventory-service.js +3 -0
  265. package/dist/runtime/plugin-inventory-service.js.map +1 -0
  266. package/dist/runtime/plugin-manager-entry.d.ts +20 -0
  267. package/dist/runtime/plugin-manager-entry.d.ts.map +1 -0
  268. package/dist/runtime/plugin-manager-entry.js +96 -0
  269. package/dist/runtime/plugin-manager-entry.js.map +1 -0
  270. package/dist/runtime/plugin-observability-entry.d.ts +12 -0
  271. package/dist/runtime/plugin-observability-entry.d.ts.map +1 -0
  272. package/dist/runtime/plugin-observability-entry.js +73 -0
  273. package/dist/runtime/plugin-observability-entry.js.map +1 -0
  274. package/dist/runtime/product-host.d.ts +91 -0
  275. package/dist/runtime/product-host.d.ts.map +1 -0
  276. package/dist/runtime/product-host.js +529 -0
  277. package/dist/runtime/product-host.js.map +1 -0
  278. package/dist/runtime/session-factory.d.ts +17 -0
  279. package/dist/runtime/session-factory.d.ts.map +1 -0
  280. package/dist/runtime/session-factory.js +75 -0
  281. package/dist/runtime/session-factory.js.map +1 -0
  282. package/dist/runtime/session-host.d.ts +152 -0
  283. package/dist/runtime/session-host.d.ts.map +1 -0
  284. package/dist/runtime/session-host.js +895 -0
  285. package/dist/runtime/session-host.js.map +1 -0
  286. package/dist/runtime-core-entry.d.ts +11 -0
  287. package/dist/runtime-core-entry.d.ts.map +1 -0
  288. package/dist/runtime-core-entry.js +9 -0
  289. package/dist/runtime-core-entry.js.map +1 -0
  290. package/dist/session-factory-entry.d.ts +7 -0
  291. package/dist/session-factory-entry.d.ts.map +1 -0
  292. package/dist/session-factory-entry.js +9 -0
  293. package/dist/session-factory-entry.js.map +1 -0
  294. package/dist/session-store-jsonl-entry.d.ts +7 -0
  295. package/dist/session-store-jsonl-entry.d.ts.map +1 -0
  296. package/dist/session-store-jsonl-entry.js +33 -0
  297. package/dist/session-store-jsonl-entry.js.map +1 -0
  298. package/dist/startup.d.ts +21 -1
  299. package/dist/startup.d.ts.map +1 -1
  300. package/dist/startup.js +179 -10
  301. package/dist/startup.js.map +1 -1
  302. package/dist/subagents/index.d.ts +2 -0
  303. package/dist/subagents/index.d.ts.map +1 -0
  304. package/dist/subagents/index.js +2 -0
  305. package/dist/subagents/index.js.map +1 -0
  306. package/dist/subagents/service.d.ts +50 -0
  307. package/dist/subagents/service.d.ts.map +1 -0
  308. package/dist/subagents/service.js +521 -0
  309. package/dist/subagents/service.js.map +1 -0
  310. package/dist/ui-host.d.ts +125 -0
  311. package/dist/ui-host.d.ts.map +1 -0
  312. package/dist/ui-host.js +275 -0
  313. package/dist/ui-host.js.map +1 -0
  314. package/dist/web/assets/index-BwfuGMvv.css +1 -0
  315. package/dist/web/assets/index-DPUaJqFJ.js +41 -0
  316. package/dist/web/assets/index-DPUaJqFJ.js.map +1 -0
  317. package/dist/web/index.html +14 -0
  318. package/dist/web-command.d.ts +11 -0
  319. package/dist/web-command.d.ts.map +1 -0
  320. package/dist/web-command.js +114 -0
  321. package/dist/web-command.js.map +1 -0
  322. package/dist/web-frontend.d.ts +73 -0
  323. package/dist/web-frontend.d.ts.map +1 -0
  324. package/dist/web-frontend.js +249 -0
  325. package/dist/web-frontend.js.map +1 -0
  326. package/dist/web.d.ts +254 -0
  327. package/dist/web.d.ts.map +1 -0
  328. package/dist/web.js +740 -0
  329. package/dist/web.js.map +1 -0
  330. package/dist/webui-entry.d.ts +3 -0
  331. package/dist/webui-entry.d.ts.map +1 -0
  332. package/dist/webui-entry.js +73 -0
  333. package/dist/webui-entry.js.map +1 -0
  334. package/dist/webui.d.ts +91 -0
  335. package/dist/webui.d.ts.map +1 -0
  336. package/dist/webui.js +882 -0
  337. package/dist/webui.js.map +1 -0
  338. package/package.json +89 -8
@@ -1 +1 @@
1
- {"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAEN,4BAA4B,EAE5B,MAAM,EACN,GAAG,EACH,UAAU,EAEV,UAAU,EACV,YAAY,GAGZ,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAe,SAAS,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAEN,iCAAiC,GACjC,MAAM,2BAA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,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAClF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;CACD","sourcesContent":["import { statSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { extname, join, resolve } from \"node:path\";\nimport {\n\ttype AutocompleteProvider,\n\tCombinedAutocompleteProvider,\n\ttype Component,\n\tEditor,\n\tKey,\n\tmatchesKey,\n\ttype OverlayHandle,\n\tSelectList,\n\tSettingsList,\n\ttype SlashCommand,\n\ttype TUI,\n} from \"@di-code/tui\";\nimport {\n\tcleanupStaleClipboardImages,\n\tclipboardImageDirectory,\n\tisClipboardImagePath,\n\treadClipboardImagePath,\n\tremoveClipboardImage,\n} from \"../core/clipboard-image.ts\";\nimport { extractImageAttachments } from \"../core/image-input.ts\";\nimport type { AgentSession, AgentSessionEvent } from \"../core/session.ts\";\nimport type { ExtensionHost } from \"../extensions/runtime.ts\";\nimport { DEFAULT_LOCALE, type Locale, translate } from \"../i18n.ts\";\nimport {\n\ttype InteractiveProviderOnboardingOptions,\n\tshowInteractiveProviderOnboarding,\n} from \"../provider-onboarding.ts\";\nimport { removeGlobalProviderApiKey, saveGlobalLocale } from \"../startup.ts\";\nimport {\n\tAutocompleteMenu,\n\tInteractiveChat,\n\tInteractiveComposer,\n\tInteractiveFooter,\n\tInteractiveHeader,\n\ttype InteractiveViewState,\n} from \"./interactive-components.ts\";\nimport { InteractiveLayout } from \"./interactive-layout.ts\";\nimport { InteractiveProjection } from \"./interactive-state.ts\";\nimport { TreeSelector } from \"./tree-selector.ts\";\n\nexport type { AgentSessionEvent };\nexport type { InteractiveMessage, InteractiveProcessItem, InteractiveState } from \"./interactive-state.ts\";\nexport { InteractiveProjection } from \"./interactive-state.ts\";\n\nconst IMAGE_EXTENSIONS = new Set([\".gif\", \".jpeg\", \".jpg\", \".png\", \".webp\"]);\nconst PASTE_IMAGE_KEY = process.platform === \"win32\" ? Key.alt(\"v\") : Key.ctrl(\"v\");\nconst PASTE_IMAGE_SHORTCUT = process.platform === \"win32\" ? \"Alt+V\" : \"Ctrl+V\";\n\nfunction builtinSlashCommands(locale: Locale): readonly SlashCommand[] {\n\tconst t = (key: string) => translate(locale, key);\n\treturn [\n\t\t{ name: \"help\", description: t(\"showInteractiveCommands\") },\n\t\t{ name: \"clear\", description: t(\"clearVisibleMessages\") },\n\t\t{ name: \"model\", description: t(\"openModelSelector\") },\n\t\t{ name: \"session\", description: t(\"openSessionSelector\") },\n\t\t{ name: \"tree\", description: t(\"openTreeSelector\") },\n\t\t{ name: \"theme\", description: t(\"openThemeSelector\") },\n\t\t{ name: \"settings\", description: t(\"openSettingsSelector\") },\n\t\t{ name: \"login\", description: t(\"chooseProvider\") },\n\t\t{ name: \"logout\", description: t(\"removeProviderKey\") },\n\t\t{ name: \"compact\", description: t(\"compactContext\") },\n\t\t{ name: \"usage\", description: t(\"showUsage\") },\n\t\t{ name: \"retry\", description: t(\"retryPrompt\") },\n\t\t{ name: \"steer\", description: t(\"steerAgent\") },\n\t];\n}\n\nfunction asImageAttachmentReference(pasted: string, cwd: string): string {\n\tif (pasted.includes(\"\\n\")) return pasted;\n\tconst candidate = pasted.trim().replace(/^(?:\"([\\s\\S]*)\"|'([\\s\\S]*)')$/, \"$1$2\");\n\tif (!candidate || !IMAGE_EXTENSIONS.has(extname(candidate).toLowerCase())) return pasted;\n\ttry {\n\t\tif (!statSync(resolve(cwd, candidate)).isFile()) return pasted;\n\t} catch {\n\t\treturn pasted;\n\t}\n\treturn `@\"${candidate.replaceAll('\"', '\\\\\"')}\" `;\n}\n\nfunction normalizeDroppedImagePrompt(prompt: string, cwd: string): string {\n\tconst normalized = asImageAttachmentReference(prompt, cwd);\n\tif (normalized !== prompt) return normalized;\n\tconst prefix = /^((?:(?:[A-Za-z]:[\\\\/])|(?:\\.\\.?[\\\\/])|\\/)[\\s\\S]*?\\.(?:gif|jpe?g|png|webp))([\\s\\S]*)$/i.exec(prompt);\n\tif (!prefix) return prompt;\n\tconst imageReference = asImageAttachmentReference(prefix[1] ?? \"\", cwd);\n\treturn imageReference === prefix[1]\n\t\t? prompt\n\t\t: `${imageReference}${normalizeDroppedImagePrompt(prefix[2] ?? \"\", cwd)}`;\n}\n\nfunction steeringCommandArgument(prompt: string): string | undefined {\n\tconst match = /^\\/steer(?:\\s+([\\s\\S]*))?$/i.exec(prompt);\n\treturn match ? (match[1] ?? \"\").trim() : undefined;\n}\n\nexport interface InteractiveModeOptions {\n\treadonly session: AgentSession;\n\treadonly tui: TUI;\n\treadonly onExit?: () => void;\n\treadonly sessions?: readonly InteractiveSessionChoice[];\n\treadonly extensionHost?: ExtensionHost;\n\treadonly providerOnboarding?: Omit<InteractiveProviderOnboardingOptions, \"tui\">;\n\t/** User data directory that owns clipboard image temporaries. */\n\treadonly agentDir?: string;\n\treadonly readClipboardImagePath?: (directory?: string) => Promise<string | null>;\n\treadonly locale?: Locale;\n}\n\nexport interface InteractiveSessionChoice {\n\treadonly id: string;\n\treadonly label: string;\n\treadonly description?: string;\n\topen(): AgentSession | Promise<AgentSession>;\n}\n\nexport class InteractiveMode {\n\tprivate readonly projection = new InteractiveProjection();\n\tprivate readonly root: InteractiveLayout;\n\tprivate readonly editor: Editor;\n\tprivate session: AgentSession;\n\tprivate readonly tui: TUI;\n\tprivate readonly sessionChoices: readonly InteractiveSessionChoice[];\n\tprivate readonly extensionHost?: ExtensionHost;\n\tprivate readonly providerOnboarding?: Omit<InteractiveProviderOnboardingOptions, \"tui\">;\n\tprivate readonly agentDir: string;\n\tprivate readonly readClipboardImagePath: (directory?: string) => Promise<string | null>;\n\tprivate clipboardDirectory: string;\n\tprivate readonly clipboardFiles = new Set<string>();\n\tprivate unsubscribeSession?: () => void;\n\tprivate sessionSwitching = false;\n\tprivate promptInFlight = false;\n\tprivate compactionInFlight = false;\n\tprivate activeAbort?: AbortController;\n\tprivate started = false;\n\tprivate lastFailedPrompt?: string;\n\tprivate queuedPrompts: string[] = [];\n\tprivate steeringPrompts: string[] = [];\n\tprivate readonly onExit?: () => void;\n\tprivate theme: \"dark\" | \"light\" = \"dark\";\n\tprivate overlay?: OverlayHandle;\n\tprivate autocompleteOverlay?: OverlayHandle;\n\tprivate spinnerTimer?: ReturnType<typeof setInterval>;\n\tprivate shutdownEmitted = false;\n\tprivate preserveClipboardFiles = false;\n\tprivate locale: Locale;\n\n\tconstructor(options: InteractiveModeOptions) {\n\t\tthis.session = options.session;\n\t\tthis.projection.configureFilePreview(this.session.allowedRoot, () => this.refresh());\n\t\tthis.tui = options.tui;\n\t\tthis.onExit = options.onExit;\n\t\tthis.sessionChoices = [...(options.sessions ?? [])];\n\t\tthis.extensionHost = options.extensionHost;\n\t\tthis.providerOnboarding = options.providerOnboarding;\n\t\tthis.agentDir = resolve(options.agentDir ?? join(homedir(), \".di-code\"));\n\t\tthis.locale = options.locale ?? DEFAULT_LOCALE;\n\t\tthis.readClipboardImagePath = options.readClipboardImagePath ?? readClipboardImagePath;\n\t\tthis.clipboardDirectory = clipboardImageDirectory(this.agentDir, this.session.allowedRoot);\n\t\tconst autocomplete: AutocompleteProvider = {\n\t\t\tgetSuggestions: (context, autocompleteOptions) =>\n\t\t\t\tnew CombinedAutocompleteProvider(this.listSlashCommands(), this.session.allowedRoot).getSuggestions(\n\t\t\t\t\tcontext,\n\t\t\t\t\tautocompleteOptions,\n\t\t\t\t),\n\t\t\tapplyCompletion: (context, item, prefix) =>\n\t\t\t\tnew CombinedAutocompleteProvider(this.listSlashCommands(), this.session.allowedRoot).applyCompletion(\n\t\t\t\t\tcontext,\n\t\t\t\t\titem,\n\t\t\t\t\tprefix,\n\t\t\t\t),\n\t\t};\n\t\tthis.editor = new Editor({\n\t\t\tmaxHeight: 3,\n\t\t\tautocomplete,\n\t\t});\n\t\tthis.editor.onSubmit = (text) => void this.submit(text);\n\t\tthis.editor.onEscape = () => this.activeAbort?.abort();\n\t\tthis.editor.onCommand = (data) => this.handleCommand(data);\n\t\tthis.editor.onInterrupt = () => this.exit();\n\t\tthis.editor.onChange = () => {\n\t\t\tif (!this.preserveClipboardFiles) {\n\t\t\t\tvoid this.cleanupUnreferencedClipboardFiles().catch((cause) => {\n\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\tthis.refresh();\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t\tthis.editor.onAutocompleteChange = () => this.updateAutocompleteOverlay();\n\t\tconst readViewState = (): InteractiveViewState => ({\n\t\t\t...this.projection.state,\n\t\t\tmodel: `${this.session.modelId}${this.session.thinkingLevel ? `(${this.session.thinkingLevel})` : \"\"}`,\n\t\t\ttheme: this.theme,\n\t\t\tlocale: this.locale,\n\t\t\tpasteImageShortcut: PASTE_IMAGE_SHORTCUT,\n\t\t});\n\t\tthis.root = new InteractiveLayout({\n\t\t\theader: new InteractiveHeader(readViewState),\n\t\t\tchat: new InteractiveChat(readViewState),\n\t\t\tcomposer: new InteractiveComposer(readViewState),\n\t\t\teditor: this.editor,\n\t\t\tfooter: new InteractiveFooter(readViewState),\n\t\t});\n\t\tthis.tui.addChild(this.root);\n\t\tthis.tui.setFocus(this.editor);\n\t}\n\n\tstart(initialPrompt?: string): void {\n\t\tif (this.started) throw new Error(\"Interactive mode is already started\");\n\t\tthis.started = true;\n\t\tthis.shutdownEmitted = false;\n\t\tvoid this.extensionHost?.emit({ type: \"session_start\", cwd: this.session.allowedRoot });\n\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\tthis.projection.setUsage(this.session.usage);\n\t\tthis.subscribeToSession();\n\t\tvoid cleanupStaleClipboardImages(this.agentDir, this.session.allowedRoot).catch((cause) => {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\tthis.refresh();\n\t\t});\n\t\ttry {\n\t\t\tthis.tui.start();\n\t\t} catch (cause) {\n\t\t\tthis.started = false;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.unsubscribeSession = undefined;\n\t\t\tthrow cause;\n\t\t}\n\t\tthis.startSpinnerTimer();\n\t\tif (initialPrompt?.trim()) void this.submit(initialPrompt);\n\t}\n\n\tstop(): void {\n\t\tif (!this.started && !this.unsubscribeSession) return;\n\t\tthis.started = false;\n\t\tthis.activeAbort?.abort();\n\t\tthis.activeAbort = undefined;\n\t\tthis.stopSpinnerTimer();\n\t\tthis.projection.clearTransientProcess();\n\t\tthis.closeOverlay();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = undefined;\n\t\tvoid this.cleanupClipboardFiles();\n\t\tthis.tui.stop({ finalLines: this.root.renderTranscript(this.tui.columns) });\n\t\tif (!this.shutdownEmitted) {\n\t\t\tthis.shutdownEmitted = true;\n\t\t\tvoid this.extensionHost?.emit({ type: \"session_shutdown\", reason: \"user\" });\n\t\t}\n\t}\n\n\tprivate exit(): void {\n\t\tthis.stop();\n\t\tthis.onExit?.();\n\t}\n\n\tprivate handleCommand(data: string): boolean {\n\t\tif (matchesKey(data, Key.alt(\"s\"))) {\n\t\t\tvoid this.submitSteering(this.editor.getValue());\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x1b[Z\") {\n\t\t\ttry {\n\t\t\t\tconst level = this.session.cycleThinkingLevel();\n\t\t\t\tthis.projection.setStatus(level ? `thinking=${level}` : \"Current model does not support thinking levels.\");\n\t\t\t} catch (cause) {\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t}\n\t\t\tthis.refresh();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x14\") {\n\t\t\tthis.openThemeSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x13\") {\n\t\t\tthis.openSettingsSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0f\") {\n\t\t\tthis.openModelSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0c\") {\n\t\t\tthis.openSessionSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x12\" && this.lastFailedPrompt && !this.promptInFlight) {\n\t\t\tvoid this.submit(this.lastFailedPrompt, true);\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, PASTE_IMAGE_KEY)) {\n\t\t\tvoid this.attachClipboardImage();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate async attachClipboardImage(): Promise<void> {\n\t\ttry {\n\t\t\tconst path = await this.readClipboardImagePath(this.clipboardDirectory);\n\t\t\tif (!path) {\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\tthis.locale === \"zh-CN\" ? \"剪贴板中没有受支持的图片。\" : \"Clipboard has no supported image.\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.editor.insertTextAtCursor(path);\n\t\t\t\tif (isClipboardImagePath(path, this.clipboardDirectory)) this.clipboardFiles.add(path);\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate openThemeSelector(): void {\n\t\tconst t = (key: string) => translate(this.locale, key);\n\t\tconst list = new SelectList([\n\t\t\t{ value: \"dark\", label: t(\"dark\"), description: t(\"darkTheme\") },\n\t\t\t{ value: \"light\", label: t(\"light\"), description: t(\"lightTheme\") },\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tthis.theme = item.value === \"light\" ? \"light\" : \"dark\";\n\t\t\tthis.projection.setStatus(`theme=${this.theme}`);\n\t\t\tthis.closeOverlay();\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openModelSelector(): void {\n\t\tconst list = new SelectList(\n\t\t\tthis.session.availableModels.map((model) => ({\n\t\t\t\tvalue: model.id,\n\t\t\t\tlabel: model.name,\n\t\t\t\tdescription: `${model.provider} / ${model.id} / context ${model.contextWindow}`,\n\t\t\t})),\n\t\t);\n\t\tlist.onSelect = (item) => {\n\t\t\ttry {\n\t\t\t\tthis.session.setModel(item.value);\n\t\t\t\tthis.projection.setStatus(`model=${item.value}`);\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t} catch (cause) {\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t}\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSessionSelector(): void {\n\t\tconst t = (key: string) => translate(this.locale, key);\n\t\tconst list = new SelectList([\n\t\t\t{\n\t\t\t\tvalue: \"__current__\",\n\t\t\t\tlabel: t(\"currentSession\"),\n\t\t\t\tdescription: this.session.sessionFile ?? t(\"inMemorySession\"),\n\t\t\t},\n\t\t\t...this.sessionChoices.map((choice) => ({\n\t\t\t\tvalue: choice.id,\n\t\t\t\tlabel: choice.label,\n\t\t\t\t...(choice.description ? { description: choice.description } : {}),\n\t\t\t})),\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tif (item.value === \"__current__\") {\n\t\t\t\tthis.projection.setStatus(\"session=current\");\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst choice = this.sessionChoices.find((candidate) => candidate.id === item.value);\n\t\t\tif (!choice) return;\n\t\t\tthis.closeOverlay();\n\t\t\tvoid this.switchSession(choice);\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openTreeSelector(): void {\n\t\tif (this.promptInFlight || this.compactionInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"提示词运行时不能浏览会话树。\"\n\t\t\t\t\t: \"Cannot browse the session tree while a prompt is running.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.session.sessionTree.length === 0) {\n\t\t\tthis.projection.setStatus(\n\t\t\t\tthis.locale === \"zh-CN\" ? \"当前会话还没有历史节点。\" : \"The current session has no history nodes.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst selector = new TreeSelector({\n\t\t\tnodes: this.session.sessionTree,\n\t\t\tleafId: this.session.sessionLeafId,\n\t\t\tlocale: this.locale,\n\t\t\tonContinue: (entry) => {\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tvoid this.navigateTreeEntry(entry.id);\n\t\t\t},\n\t\t\tonEdit: (entry) => {\n\t\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"user\") {\n\t\t\t\t\tthis.projection.setError(\n\t\t\t\t\t\tthis.locale === \"zh-CN\" ? \"只能编辑历史用户消息。\" : \"Only historical user messages can be edited.\",\n\t\t\t\t\t);\n\t\t\t\t\tthis.refresh();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tvoid this.navigateTreeEntry(entry.id);\n\t\t\t},\n\t\t\tonSummarize: (entry) => {\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tvoid this.summarizeTreeBranch(entry.id);\n\t\t\t},\n\t\t\tonCancel: () => this.closeOverlay(),\n\t\t});\n\t\tthis.showOverlay(selector, true, \"80%\");\n\t}\n\n\tprivate async navigateTreeEntry(entryId: string): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.session.navigateTree(entryId);\n\t\t\tif (!this.started) return false;\n\t\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\t\tthis.editor.setValue(result.editorText ?? \"\");\n\t\t\tthis.projection.setStatus(\n\t\t\t\tresult.imagesOmitted\n\t\t\t\t\t? this.locale === \"zh-CN\"\n\t\t\t\t\t\t? \"已恢复文本;请重新附加图片。\"\n\t\t\t\t\t\t: \"Text restored; reattach images before sending.\"\n\t\t\t\t\t: `tree=${result.selectedEntryId}`,\n\t\t\t);\n\t\t\treturn true;\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\treturn false;\n\t\t} finally {\n\t\t\tthis.refresh();\n\t\t}\n\t}\n\n\tprivate async summarizeTreeBranch(entryId: string): Promise<void> {\n\t\tif (this.compactionInFlight || this.promptInFlight) return;\n\t\tthis.compactionInFlight = true;\n\t\tthis.projection.setStatus(this.locale === \"zh-CN\" ? \"正在为分支生成摘要。\" : \"Summarizing selected branch.\");\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tif (!(await this.navigateTreeEntry(entryId))) return;\n\t\t\tawait this.session.compact();\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\t\tthis.projection.setStatus(this.locale === \"zh-CN\" ? \"摘要分支已创建。\" : \"Summary branch created.\");\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.compactionInFlight = false;\n\t\t\tthis.refresh();\n\t\t}\n\t}\n\n\tprivate openSettingsSelector(): void {\n\t\tconst t = (key: string) => translate(this.locale, key);\n\t\tconst list = new SettingsList(\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tid: \"compaction\",\n\t\t\t\t\tlabel: t(\"contextCompaction\"),\n\t\t\t\t\tcurrentValue: this.session.compactionEnabled ? t(\"on\") : t(\"off\"),\n\t\t\t\t\tvalues: [t(\"on\"), t(\"off\")],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"locale\",\n\t\t\t\t\tlabel: t(\"language\"),\n\t\t\t\t\tcurrentValue: this.locale,\n\t\t\t\t\tvalues: [\"en\", \"zh-CN\"],\n\t\t\t\t},\n\t\t\t],\n\t\t\t{ title: t(\"settings\") },\n\t\t);\n\t\tlist.onChange = (id, value) => {\n\t\t\tif (id === \"locale\") {\n\t\t\t\tthis.locale = value === \"zh-CN\" ? \"zh-CN\" : \"en\";\n\t\t\t\tvoid saveGlobalLocale(this.agentDir, this.locale).catch((cause) => {\n\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\tthis.refresh();\n\t\t\t\t});\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.openSettingsSelector();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (id !== \"compaction\") return;\n\t\t\ttry {\n\t\t\t\tconst enabled = this.session.setCompactionEnabled(value === t(\"on\"));\n\t\t\t\tlist.updateValue(id, enabled ? t(\"on\") : t(\"off\"));\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\tenabled === (value === t(\"on\")) ? `compaction=${enabled ? t(\"on\") : t(\"off\")}` : t(\"compactionUnavailable\"),\n\t\t\t\t);\n\t\t\t} catch (cause) {\n\t\t\t\tlist.updateValue(id, this.session.compactionEnabled ? t(\"on\") : t(\"off\"));\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\tthis.closeOverlay();\n\t\t\t}\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate showOverlay(component: Component, preserveLastLine = false, maxHeight: \"60%\" | \"80%\" = \"60%\"): void {\n\t\tthis.editor.cancelAutocomplete();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.closeOverlay();\n\t\tthis.overlay = this.tui.showOverlay(component, {\n\t\t\twidth: \"70%\",\n\t\t\tmaxHeight,\n\t\t\tanchor: \"center\",\n\t\t\tmargin: 1,\n\t\t\tpreserveLastLine,\n\t\t});\n\t}\n\n\tprivate closeOverlay(): void {\n\t\tthis.overlay?.hide();\n\t\tthis.overlay = undefined;\n\t}\n\n\tprivate updateAutocompleteOverlay(): void {\n\t\tthis.closeAutocompleteOverlay();\n\t\tif (!this.editor.isShowingAutocomplete()) {\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst menu = new AutocompleteMenu(() => ({\n\t\t\titems: this.editor.getAutocompleteItems(),\n\t\t\tindex: this.editor.getAutocompleteIndex(),\n\t\t}));\n\t\tconst editorBounds = this.root.getEditorBounds(this.tui.columns);\n\t\tthis.autocompleteOverlay = this.tui.showOverlay(menu, {\n\t\t\twidth: \"55%\",\n\t\t\tmaxHeight: 9,\n\t\t\tanchor: \"bottom-left\",\n\t\t\tplacement: {\n\t\t\t\tanchorRow: editorBounds.end - 1,\n\t\t\t\tavoidStartRow: editorBounds.start,\n\t\t\t\tpreferred: \"below\",\n\t\t\t},\n\t\t\tmargin: 1,\n\t\t\tpreserveLastLine: true,\n\t\t\tnonCapturing: true,\n\t\t});\n\t\tthis.refresh();\n\t}\n\n\tprivate closeAutocompleteOverlay(): void {\n\t\tthis.autocompleteOverlay?.hide();\n\t\tthis.autocompleteOverlay = undefined;\n\t}\n\n\tprivate refresh(): void {\n\t\tthis.root.invalidate();\n\t\tthis.tui.requestRender();\n\t}\n\n\tprivate startSpinnerTimer(): void {\n\t\tthis.stopSpinnerTimer();\n\t\tthis.spinnerTimer = setInterval(() => {\n\t\t\tif (this.projection.advanceSpinner()) this.refresh();\n\t\t}, 120);\n\t\tthis.spinnerTimer.unref?.();\n\t}\n\n\tprivate stopSpinnerTimer(): void {\n\t\tif (this.spinnerTimer) clearInterval(this.spinnerTimer);\n\t\tthis.spinnerTimer = undefined;\n\t}\n\n\tprivate subscribeToSession(): void {\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = this.session.subscribeSession((event) => {\n\t\t\tif (!this.started) return;\n\t\t\tif (event.type === \"tree_navigated\") {\n\t\t\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"queue_update\") {\n\t\t\t\tthis.steeringPrompts = [...event.steering];\n\t\t\t\tthis.refreshQueue();\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.projection.apply(event);\n\t\t\tthis.refresh();\n\t\t});\n\t}\n\n\tprivate async switchSession(choice: InteractiveSessionChoice): Promise<void> {\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\" ? \"提示词运行时不能切换会话。\" : \"Cannot switch sessions while a prompt is running.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.sessionSwitching = true;\n\t\tthis.projection.setStatus(`opening session=${choice.id}`);\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tconst next = await choice.open();\n\t\t\tif (!this.started) return;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.session = next;\n\t\t\tthis.projection.configureFilePreview(next.allowedRoot, () => this.refresh());\n\t\t\tthis.clipboardDirectory = clipboardImageDirectory(this.agentDir, next.allowedRoot);\n\t\t\tvoid cleanupStaleClipboardImages(this.agentDir, next.allowedRoot);\n\t\t\tthis.queuedPrompts = [];\n\t\t\tthis.steeringPrompts = [];\n\t\t\tthis.refreshQueue();\n\t\t\tthis.projection.replaceTranscript(next.transcript);\n\t\t\tthis.projection.setUsage(next.usage);\n\t\t\tthis.projection.setStatus(`session=${choice.id}`);\n\t\t\tthis.subscribeToSession();\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.sessionSwitching = false;\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate async submit(text: string, retry = false): Promise<void> {\n\t\tconst prompt = text.trim();\n\t\tif (prompt.length === 0 || !this.started) return;\n\t\tconst steeringArgument = steeringCommandArgument(prompt);\n\t\tif (steeringArgument !== undefined) {\n\t\t\tawait this.submitSteering(steeringArgument);\n\t\t\treturn;\n\t\t}\n\t\tif (prompt.startsWith(\"/\") && !this.isLoadedSkillCommand(prompt)) {\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tthis.handleSlashCommand(prompt);\n\t\t\treturn;\n\t\t}\n\t\tif (this.sessionSwitching) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"会话正在打开,请等待后再提交提示词。\"\n\t\t\t\t\t: \"A session is opening; wait before submitting a prompt.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.compactionInFlight) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"正在压缩上下文,请等待后再提交提示词。\"\n\t\t\t\t\t: \"A compaction is running; wait before submitting a prompt.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight) {\n\t\t\tthis.queuedPrompts.push(prompt);\n\t\t\tthis.refreshQueue();\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.promptInFlight = true;\n\t\tthis.activeAbort = new AbortController();\n\t\tthis.projection.setRetrying(retry);\n\t\ttry {\n\t\t\tconst input = await extractImageAttachments(\n\t\t\t\tnormalizeDroppedImagePrompt(prompt, this.session.allowedRoot),\n\t\t\t\tthis.session.allowedRoot,\n\t\t\t);\n\t\t\tthis.preserveClipboardFiles = true;\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tconst result = await this.session.promptWithImages(input.text, input.images, this.activeAbort.signal);\n\t\t\tif (result.stopReason === \"error\" || result.stopReason === \"aborted\") this.lastFailedPrompt = prompt;\n\t\t\telse {\n\t\t\t\tthis.lastFailedPrompt = undefined;\n\t\t\t\tawait this.cleanupClipboardFiles();\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tthis.lastFailedPrompt = prompt;\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.preserveClipboardFiles = false;\n\t\t\tthis.promptInFlight = false;\n\t\t\tthis.activeAbort = undefined;\n\t\t\tthis.projection.setRetrying(false);\n\t\t\tconst next = this.queuedPrompts.shift();\n\t\t\tthis.refreshQueue();\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\tif (next && this.started) void this.submit(next);\n\t\t}\n\t}\n\n\tprivate async submitSteering(text: string): Promise<void> {\n\t\tconst prompt = text.trim();\n\t\tif (prompt.length === 0) {\n\t\t\tthis.projection.setError(this.locale === \"zh-CN\" ? \"引导内容不能为空。\" : \"Steering content must not be empty.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.sessionSwitching) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"会话正在打开,请等待后再引导 Agent。\"\n\t\t\t\t\t: \"A session is opening; wait before steering the agent.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.compactionInFlight) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"正在压缩上下文,请等待后再引导 Agent。\"\n\t\t\t\t\t: \"A compaction is running; wait before steering the agent.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (!this.promptInFlight) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"只能在提示词运行时引导 Agent。\"\n\t\t\t\t\t: \"Steering is only available while a prompt is running.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst input = await extractImageAttachments(\n\t\t\t\tnormalizeDroppedImagePrompt(prompt, this.session.allowedRoot),\n\t\t\t\tthis.session.allowedRoot,\n\t\t\t);\n\t\t\tawait this.session.steerWithImages(input.text, input.images);\n\t\t\tthis.editor.setValue(\"\");\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate refreshQueue(): void {\n\t\tthis.projection.setQueue([\n\t\t\t...this.steeringPrompts.map((prompt) => `steer: ${prompt}`),\n\t\t\t...this.queuedPrompts.map((prompt) => `queued: ${prompt}`),\n\t\t]);\n\t}\n\n\tprivate async cleanupUnreferencedClipboardFiles(): Promise<void> {\n\t\tconst text = this.editor.getValue();\n\t\tconst files = [...this.clipboardFiles].filter((path) => !text.includes(path));\n\t\tawait Promise.all(files.map((path) => removeClipboardImage(path, this.clipboardDirectory)));\n\t\tfor (const path of files) this.clipboardFiles.delete(path);\n\t}\n\n\tprivate async cleanupClipboardFiles(): Promise<void> {\n\t\tconst files = [...this.clipboardFiles];\n\t\tawait Promise.all(files.map((path) => removeClipboardImage(path, this.clipboardDirectory)));\n\t\tfor (const path of files) this.clipboardFiles.delete(path);\n\t}\n\n\tprivate handleSlashCommand(input: string): void {\n\t\tconst trimmed = input.slice(1).trim();\n\t\tconst [rawCommand = \"\", ...argParts] = trimmed.split(/\\s+/);\n\t\tconst command = rawCommand.toLowerCase();\n\t\tconst args = argParts.join(\" \");\n\t\tswitch (command) {\n\t\t\tcase \"help\":\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\t`commands: ${this.listSlashCommands()\n\t\t\t\t\t\t.map((item) => `/${item.name}`)\n\t\t\t\t\t\t.join(\" \")}`,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"clear\":\n\t\t\t\tthis.projection.clearVisibleMessages();\n\t\t\t\tthis.projection.setStatus(translate(this.locale, \"visibleMessagesCleared\"));\n\t\t\t\tbreak;\n\t\t\tcase \"model\":\n\t\t\t\tthis.openModelSelector();\n\t\t\t\treturn;\n\t\t\tcase \"session\":\n\t\t\t\tthis.openSessionSelector();\n\t\t\t\treturn;\n\t\t\tcase \"tree\":\n\t\t\t\tthis.openTreeSelector();\n\t\t\t\treturn;\n\t\t\tcase \"theme\":\n\t\t\t\tthis.openThemeSelector();\n\t\t\t\treturn;\n\t\t\tcase \"settings\":\n\t\t\t\tthis.openSettingsSelector();\n\t\t\t\treturn;\n\t\t\tcase \"login\":\n\t\t\t\tthis.openProviderLogin();\n\t\t\t\treturn;\n\t\t\tcase \"logout\":\n\t\t\t\tvoid this.logoutProvider();\n\t\t\t\treturn;\n\t\t\tcase \"compact\":\n\t\t\t\tvoid this.runManualCompaction();\n\t\t\t\treturn;\n\t\t\tcase \"usage\":\n\t\t\t\tthis.projection.setStatus(this.formatUsage());\n\t\t\t\tbreak;\n\t\t\tcase \"retry\":\n\t\t\t\tif (this.lastFailedPrompt && !this.promptInFlight) void this.submit(this.lastFailedPrompt, true);\n\t\t\t\telse this.projection.setStatus(translate(this.locale, \"nothingToRetry\"));\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tif (this.extensionHost?.listCommands().some((entry) => entry.name === command)) {\n\t\t\t\t\tvoid this.extensionHost.runCommand(command, args).catch((cause) => {\n\t\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\t\tthis.refresh();\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.projection.setError(`Unknown command: /${command}`);\n\t\t\t}\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate openProviderLogin(): void {\n\t\tif (!this.providerOnboarding) {\n\t\t\tthis.projection.setError(\"Provider login is unavailable in this session.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot change Provider while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.editor.cancelAutocomplete();\n\t\tthis.closeAutocompleteOverlay();\n\t\tvoid showInteractiveProviderOnboarding({\n\t\t\t...this.providerOnboarding,\n\t\t\tconfiguration: { ...this.providerOnboarding.configuration, locale: this.locale },\n\t\t\ttui: this.tui,\n\t\t})\n\t\t\t.then((runtime) => {\n\t\t\t\tif (!this.started) return;\n\t\t\t\tthis.tui.setFocus(this.editor);\n\t\t\t\tif (!runtime) {\n\t\t\t\t\tthis.refresh();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.session.setRuntime(runtime.provider, runtime.model);\n\t\t\t\tthis.projection.setStatus(`provider=${runtime.provider.id} model=${runtime.model.id}`);\n\t\t\t\tthis.refresh();\n\t\t\t})\n\t\t\t.catch((cause) => {\n\t\t\t\tif (this.started) this.tui.setFocus(this.editor);\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\tthis.refresh();\n\t\t\t});\n\t}\n\n\tprivate async logoutProvider(): Promise<void> {\n\t\tif (!this.providerOnboarding) {\n\t\t\tthis.projection.setError(\"Provider logout is unavailable in this session.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot change Provider while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst providerId = this.session.providerId;\n\t\ttry {\n\t\t\tconst removed = await removeGlobalProviderApiKey(this.providerOnboarding.agentDir, providerId);\n\t\t\tif (!removed) {\n\t\t\t\tthis.projection.setStatus(`no global API key stored for provider=${providerId}`);\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.projection.setStatus(\n\t\t\t\t`global API key removed for provider=${providerId}; it remains active until this session ends`,\n\t\t\t);\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate listSlashCommands(): readonly SlashCommand[] {\n\t\tconst skills = this.session.availableSkills.map((skill) => ({\n\t\t\tname: `skill:${skill.name}`,\n\t\t\tdescription: skill.description,\n\t\t}));\n\t\treturn [...builtinSlashCommands(this.locale), ...(this.extensionHost?.listCommands() ?? []), ...skills];\n\t}\n\n\tprivate isLoadedSkillCommand(input: string): boolean {\n\t\tconst name = /^\\/skill:([a-z0-9]+(?:-[a-z0-9]+)*)(?:\\s|$)/.exec(input)?.[1];\n\t\treturn name !== undefined && this.session.availableSkills.some((skill) => skill.name === name);\n\t}\n\n\tprivate formatUsage(): string {\n\t\tconst usage = this.session.usage;\n\t\tif (this.locale === \"zh-CN\") {\n\t\t\treturn `用量:请求=${usage.requestCount} 输入=${usage.inputTokens} 输出=${usage.outputTokens} 总计=${usage.totalTokens} 费用=$${usage.cost.total.toFixed(4)} 上下文=${usage.estimatedContextTokens}/${usage.contextWindow}`;\n\t\t}\n\t\treturn `usage: requests=${usage.requestCount} input=${usage.inputTokens} output=${usage.outputTokens} total=${usage.totalTokens} cost=$${usage.cost.total.toFixed(4)} context=${usage.estimatedContextTokens}/${usage.contextWindow}`;\n\t}\n\n\tprivate async runManualCompaction(): Promise<void> {\n\t\tif (this.promptInFlight || this.compactionInFlight) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\" ? \"提示词运行时不能压缩上下文。\" : \"Cannot compact while a prompt is running.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.compactionInFlight = true;\n\t\tthis.projection.setStatus(translate(this.locale, \"manualCompactionStarting\"));\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tawait this.session.compact();\n\t\t\tthis.projection.setStatus(translate(this.locale, \"manualCompactionComplete\"));\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.compactionInFlight = false;\n\t\t\tthis.refresh();\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EA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I,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;CACD","sourcesContent":["import { statSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { extname, join, resolve } from \"node:path\";\nimport type { CommandRegistry, InteractiveContextService } from \"@di-code/builtins\";\nimport {\n\ttype AutocompleteProvider,\n\tCombinedAutocompleteProvider,\n\ttype Component,\n\tEditor,\n\tKey,\n\tmatchesKey,\n\ttype OverlayHandle,\n\tSelectList,\n\tSettingsList,\n\ttype SlashCommand,\n\ttype TUI,\n} from \"@di-code/tui\";\nimport {\n\tcleanupStaleClipboardImages,\n\tclipboardImageDirectory,\n\tisClipboardImagePath,\n\treadClipboardImagePath,\n\tremoveClipboardImage,\n} from \"../core/clipboard-image.ts\";\nimport { extractImageAttachments } from \"../core/image-input.ts\";\nimport type { AgentSession, AgentSessionEvent } from \"../core/session.ts\";\nimport { DEFAULT_LOCALE, type Locale, translate } from \"../i18n.ts\";\nimport {\n\ttype InteractiveProviderOnboardingOptions,\n\tshowInteractiveProviderOnboarding,\n} from \"../provider-onboarding.ts\";\nimport type { SessionHostUi } from \"../runtime/session-host.ts\";\nimport {\n\tremoveGlobalProviderApiKey,\n\tsaveGlobalLocale,\n\tsaveGlobalModelSelection,\n\tsaveGlobalThinkingLevel,\n} from \"../startup.ts\";\nimport {\n\tAutocompleteMenu,\n\tInteractiveChat,\n\tInteractiveComposer,\n\tInteractiveFooter,\n\tInteractiveHeader,\n\ttype InteractiveViewState,\n} from \"./interactive-components.ts\";\nimport { InteractiveLayout } from \"./interactive-layout.ts\";\nimport { InteractiveProjection } from \"./interactive-state.ts\";\nimport { TreeSelector } from \"./tree-selector.ts\";\n\nexport type { AgentSessionEvent };\nexport type { InteractiveMessage, InteractiveProcessItem, InteractiveState } from \"./interactive-state.ts\";\nexport { InteractiveProjection } from \"./interactive-state.ts\";\n\nconst IMAGE_EXTENSIONS = new Set([\".gif\", \".jpeg\", \".jpg\", \".png\", \".webp\"]);\nconst PASTE_IMAGE_KEY = process.platform === \"win32\" ? Key.alt(\"v\") : Key.ctrl(\"v\");\nconst PASTE_IMAGE_SHORTCUT = process.platform === \"win32\" ? \"Alt+V\" : \"Ctrl+V\";\n\nfunction builtinSlashCommands(locale: Locale): readonly SlashCommand[] {\n\tconst t = (key: string) => translate(locale, key);\n\treturn [\n\t\t{ name: \"help\", description: t(\"showInteractiveCommands\") },\n\t\t{ name: \"clear\", description: t(\"clearVisibleMessages\") },\n\t\t{ name: \"model\", description: t(\"openModelSelector\") },\n\t\t{ name: \"session\", description: t(\"openSessionSelector\") },\n\t\t{ name: \"tree\", description: t(\"openTreeSelector\") },\n\t\t{ name: \"theme\", description: t(\"openThemeSelector\") },\n\t\t{ name: \"settings\", description: t(\"openSettingsSelector\") },\n\t\t{ name: \"login\", description: t(\"chooseProvider\") },\n\t\t{ name: \"logout\", description: t(\"removeProviderKey\") },\n\t\t{ name: \"compact\", description: t(\"compactContext\") },\n\t\t{ name: \"usage\", description: t(\"showUsage\") },\n\t\t{ name: \"retry\", description: t(\"retryPrompt\") },\n\t\t{ name: \"steer\", description: t(\"steerAgent\") },\n\t];\n}\n\nfunction asImageAttachmentReference(pasted: string, cwd: string): string {\n\tif (pasted.includes(\"\\n\")) return pasted;\n\tconst candidate = pasted.trim().replace(/^(?:\"([\\s\\S]*)\"|'([\\s\\S]*)')$/, \"$1$2\");\n\tif (!candidate || !IMAGE_EXTENSIONS.has(extname(candidate).toLowerCase())) return pasted;\n\ttry {\n\t\tif (!statSync(resolve(cwd, candidate)).isFile()) return pasted;\n\t} catch {\n\t\treturn pasted;\n\t}\n\treturn `@\"${candidate.replaceAll('\"', '\\\\\"')}\" `;\n}\n\nfunction normalizeDroppedImagePrompt(prompt: string, cwd: string): string {\n\tconst normalized = asImageAttachmentReference(prompt, cwd);\n\tif (normalized !== prompt) return normalized;\n\tconst prefix = /^((?:(?:[A-Za-z]:[\\\\/])|(?:\\.\\.?[\\\\/])|\\/)[\\s\\S]*?\\.(?:gif|jpe?g|png|webp))([\\s\\S]*)$/i.exec(prompt);\n\tif (!prefix) return prompt;\n\tconst imageReference = asImageAttachmentReference(prefix[1] ?? \"\", cwd);\n\treturn imageReference === prefix[1]\n\t\t? prompt\n\t\t: `${imageReference}${normalizeDroppedImagePrompt(prefix[2] ?? \"\", cwd)}`;\n}\n\nfunction steeringCommandArgument(prompt: string): string | undefined {\n\tconst match = /^\\/steer(?:\\s+([\\s\\S]*))?$/i.exec(prompt);\n\treturn match ? (match[1] ?? \"\").trim() : undefined;\n}\n\nexport interface InteractiveModeOptions {\n\treadonly session: InteractiveSessionHandle;\n\treadonly tui: TUI;\n\treadonly onExit?: () => void;\n\treadonly sessions?: readonly InteractiveSessionChoice[];\n\treadonly providerOnboarding?: Omit<InteractiveProviderOnboardingOptions, \"tui\">;\n\t/** User data directory that owns clipboard image temporaries. */\n\treadonly agentDir?: string;\n\treadonly readClipboardImagePath?: (directory?: string) => Promise<string | null>;\n\treadonly locale?: Locale;\n\t/** Command contributions are resolved through the composition registry. */\n\treadonly commandRegistry?: CommandRegistry;\n\t/** Session controls and preferences are supplied by the active Context. */\n\treadonly context?: InteractiveContextService;\n}\n\nexport interface InteractiveSessionChoice {\n\treadonly id: string;\n\treadonly label: string;\n\treadonly description?: string;\n\topen(): InteractiveSessionHandle | Promise<InteractiveSessionHandle>;\n}\n\nexport type InteractiveSessionHandle = AgentSession | SessionHostUi;\n\ninterface ContextSessionChoice {\n\treadonly id: string;\n\treadonly label: string;\n\treadonly description?: string;\n\treadonly open: () => unknown | Promise<unknown>;\n}\n\nfunction isContextSessionChoice(value: unknown): value is ContextSessionChoice {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\ttypeof value.id === \"string\" &&\n\t\t\"label\" in value &&\n\t\ttypeof value.label === \"string\" &&\n\t\t\"open\" in value &&\n\t\ttypeof value.open === \"function\"\n\t);\n}\n\nexport class InteractiveMode {\n\tprivate readonly projection = new InteractiveProjection();\n\tprivate readonly root: InteractiveLayout;\n\tprivate readonly editor: Editor;\n\tprivate session: InteractiveSessionHandle;\n\tprivate readonly tui: TUI;\n\tprivate readonly sessionChoices: readonly InteractiveSessionChoice[];\n\tprivate readonly providerOnboarding?: Omit<InteractiveProviderOnboardingOptions, \"tui\">;\n\tprivate readonly agentDir: string;\n\tprivate readonly readClipboardImagePath: (directory?: string) => Promise<string | null>;\n\tprivate clipboardDirectory: string;\n\tprivate readonly clipboardFiles = new Set<string>();\n\tprivate unsubscribeSession?: () => void;\n\tprivate sessionSwitching = false;\n\tprivate promptInFlight = false;\n\tprivate compactionInFlight = false;\n\tprivate activeAbort?: AbortController;\n\tprivate started = false;\n\tprivate lastFailedPrompt?: string;\n\tprivate queuedPrompts: string[] = [];\n\tprivate steeringPrompts: string[] = [];\n\tprivate readonly onExit?: () => void;\n\tprivate theme: \"dark\" | \"light\" = \"dark\";\n\tprivate overlay?: OverlayHandle;\n\tprivate autocompleteOverlay?: OverlayHandle;\n\tprivate spinnerTimer?: ReturnType<typeof setInterval>;\n\tprivate preserveClipboardFiles = false;\n\tprivate locale: Locale;\n\tprivate readonly commandRegistry?: CommandRegistry;\n\tprivate readonly context?: InteractiveContextService;\n\n\tconstructor(options: InteractiveModeOptions) {\n\t\tthis.session = options.session;\n\t\tthis.projection.configureFilePreview(this.session.allowedRoot, () => this.refresh());\n\t\tthis.tui = options.tui;\n\t\tthis.onExit = options.onExit;\n\t\tconst contextChoices = (options.context?.sessionChoices() ?? []).filter(isContextSessionChoice).map((choice) => ({\n\t\t\t...choice,\n\t\t\topen: async () => {\n\t\t\t\tconst session = await choice.open();\n\t\t\t\tif (typeof session !== \"object\" || session === null) throw new Error(`Session choice ${choice.id} is invalid`);\n\t\t\t\treturn session as InteractiveSessionHandle;\n\t\t\t},\n\t\t}));\n\t\tthis.sessionChoices = [...(options.sessions ?? contextChoices)];\n\t\tthis.providerOnboarding = options.providerOnboarding;\n\t\tthis.agentDir = resolve(options.agentDir ?? join(homedir(), \".di-code\"));\n\t\tthis.locale = options.locale ?? DEFAULT_LOCALE;\n\t\tthis.commandRegistry = options.commandRegistry;\n\t\tthis.context = options.context;\n\t\tif (this.context?.theme() === \"light\") this.theme = \"light\";\n\t\tthis.readClipboardImagePath = options.readClipboardImagePath ?? readClipboardImagePath;\n\t\tthis.clipboardDirectory = clipboardImageDirectory(this.agentDir, this.session.allowedRoot);\n\t\tconst autocomplete: AutocompleteProvider = {\n\t\t\tgetSuggestions: (context, autocompleteOptions) =>\n\t\t\t\tnew CombinedAutocompleteProvider(this.listSlashCommands(), this.session.allowedRoot).getSuggestions(\n\t\t\t\t\tcontext,\n\t\t\t\t\tautocompleteOptions,\n\t\t\t\t),\n\t\t\tapplyCompletion: (context, item, prefix) =>\n\t\t\t\tnew CombinedAutocompleteProvider(this.listSlashCommands(), this.session.allowedRoot).applyCompletion(\n\t\t\t\t\tcontext,\n\t\t\t\t\titem,\n\t\t\t\t\tprefix,\n\t\t\t\t),\n\t\t};\n\t\tthis.editor = new Editor({\n\t\t\tmaxHeight: 3,\n\t\t\tautocomplete,\n\t\t\tsubmitAutocomplete: (context) => /^\\/[^\\s/]*$/.test(context.text.slice(0, context.cursor)),\n\t\t});\n\t\tthis.editor.onSubmit = (text) => void this.submit(text);\n\t\tthis.editor.onEscape = () => {\n\t\t\tif (!this.activeAbort) {\n\t\t\t\tthis.context?.cancel();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.projection.setStatus(translate(this.locale, \"cancelled\"));\n\t\t\tthis.context?.cancel();\n\t\t\tthis.activeAbort.abort();\n\t\t\tthis.refresh();\n\t\t};\n\t\tthis.editor.onCommand = (data) => this.handleCommand(data);\n\t\tthis.editor.onInterrupt = () => this.exit();\n\t\tthis.editor.onChange = () => {\n\t\t\tif (!this.preserveClipboardFiles) {\n\t\t\t\tvoid this.cleanupUnreferencedClipboardFiles().catch((cause) => {\n\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\tthis.refresh();\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t\tthis.editor.onAutocompleteChange = () => this.updateAutocompleteOverlay();\n\t\tconst readViewState = (): InteractiveViewState => ({\n\t\t\t...this.projection.state,\n\t\t\tmodel: `${this.session.modelId}${this.session.thinkingLevel ? `(${this.session.thinkingLevel})` : \"\"}`,\n\t\t\ttheme: this.theme,\n\t\t\tlocale: this.locale,\n\t\t\tpasteImageShortcut: PASTE_IMAGE_SHORTCUT,\n\t\t});\n\t\tthis.root = new InteractiveLayout({\n\t\t\theader: new InteractiveHeader(readViewState),\n\t\t\tchat: new InteractiveChat(readViewState),\n\t\t\tcomposer: new InteractiveComposer(readViewState),\n\t\t\teditor: this.editor,\n\t\t\tfooter: new InteractiveFooter(readViewState),\n\t\t});\n\t\tthis.tui.addChild(this.root);\n\t\tthis.tui.setFocus(this.editor);\n\t}\n\n\tstart(initialPrompt?: string): void {\n\t\tif (this.started) throw new Error(\"Interactive mode is already started\");\n\t\tthis.started = true;\n\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\tthis.projection.setUsage(this.session.usage);\n\t\tthis.subscribeToSession();\n\t\tvoid cleanupStaleClipboardImages(this.agentDir, this.session.allowedRoot).catch((cause) => {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\tthis.refresh();\n\t\t});\n\t\ttry {\n\t\t\tthis.tui.start();\n\t\t} catch (cause) {\n\t\t\tthis.started = false;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.unsubscribeSession = undefined;\n\t\t\tthrow cause;\n\t\t}\n\t\tthis.startSpinnerTimer();\n\t\tif (initialPrompt?.trim()) void this.submit(initialPrompt);\n\t}\n\n\tstop(): void {\n\t\tif (!this.started && !this.unsubscribeSession) return;\n\t\tthis.started = false;\n\t\tthis.activeAbort?.abort();\n\t\tthis.activeAbort = undefined;\n\t\tthis.stopSpinnerTimer();\n\t\tthis.projection.clearTransientProcess();\n\t\tthis.closeOverlay();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = undefined;\n\t\tvoid this.cleanupClipboardFiles();\n\t\tthis.tui.stop({ finalLines: this.root.renderTranscript(this.tui.columns) });\n\t}\n\n\t/** Cancels the active prompt without changing Session history. */\n\tcancelActivePrompt(): void {\n\t\tthis.activeAbort?.abort();\n\t}\n\n\t/** Re-submits the last failed prompt when the mode is idle. */\n\tretryLastPrompt(): void {\n\t\tif (this.lastFailedPrompt && !this.promptInFlight) void this.submit(this.lastFailedPrompt, true);\n\t}\n\n\tprivate exit(): void {\n\t\tthis.stop();\n\t\tthis.onExit?.();\n\t}\n\n\tprivate handleCommand(data: string): boolean {\n\t\tthis.context?.keybindings();\n\t\tif (matchesKey(data, Key.alt(\"s\"))) {\n\t\t\tvoid this.submitSteering(this.editor.getValue());\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x1b[Z\") {\n\t\t\ttry {\n\t\t\t\tconst level = this.session.cycleThinkingLevel();\n\t\t\t\tthis.projection.setStatus(level ? `thinking=${level}` : \"Current model does not support thinking levels.\");\n\t\t\t\tif (level) {\n\t\t\t\t\tvoid saveGlobalThinkingLevel(this.agentDir, this.session.providerId, this.session.modelId, level).catch(\n\t\t\t\t\t\t(cause) => {\n\t\t\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\t\t\tthis.refresh();\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (cause) {\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t}\n\t\t\tthis.refresh();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x14\") {\n\t\t\tthis.openThemeSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x13\") {\n\t\t\tthis.openSettingsSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0f\") {\n\t\t\tthis.openModelSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0c\") {\n\t\t\tthis.openSessionSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x12\" && this.lastFailedPrompt && !this.promptInFlight) {\n\t\t\tvoid this.submit(this.lastFailedPrompt, true);\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, PASTE_IMAGE_KEY)) {\n\t\t\tvoid this.attachClipboardImage();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate async attachClipboardImage(): Promise<void> {\n\t\ttry {\n\t\t\tconst path = await this.readClipboardImagePath(this.clipboardDirectory);\n\t\t\tif (!path) {\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\tthis.locale === \"zh-CN\" ? \"剪贴板中没有受支持的图片。\" : \"Clipboard has no supported image.\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.editor.insertTextAtCursor(path);\n\t\t\t\tif (isClipboardImagePath(path, this.clipboardDirectory)) this.clipboardFiles.add(path);\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate openThemeSelector(): void {\n\t\tconst t = (key: string) => translate(this.locale, key);\n\t\tconst list = new SelectList([\n\t\t\t{ value: \"dark\", label: t(\"dark\"), description: t(\"darkTheme\") },\n\t\t\t{ value: \"light\", label: t(\"light\"), description: t(\"lightTheme\") },\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tthis.theme = item.value === \"light\" ? \"light\" : \"dark\";\n\t\t\tthis.context?.setTheme(this.theme);\n\t\t\tthis.projection.setStatus(`theme=${this.theme}`);\n\t\t\tthis.closeOverlay();\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openModelSelector(): void {\n\t\tconst list = new SelectList(\n\t\t\tthis.session.availableModels.map((model) => ({\n\t\t\t\tvalue: model.id,\n\t\t\t\tlabel: model.name,\n\t\t\t\tdescription: `${model.provider} / ${model.id} / context ${model.contextWindow}`,\n\t\t\t})),\n\t\t);\n\t\tlist.onSelect = (item) => {\n\t\t\ttry {\n\t\t\t\tthis.session.setModel(item.value);\n\t\t\t\tthis.projection.setStatus(`model=${item.value}`);\n\t\t\t\tvoid saveGlobalModelSelection(this.agentDir, this.session.providerId, this.session.modelId).catch((cause) => {\n\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\tthis.refresh();\n\t\t\t\t});\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t} catch (cause) {\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t}\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSessionSelector(): void {\n\t\tconst t = (key: string) => translate(this.locale, key);\n\t\tconst list = new SelectList([\n\t\t\t{\n\t\t\t\tvalue: \"__current__\",\n\t\t\t\tlabel: t(\"currentSession\"),\n\t\t\t\tdescription: this.session.sessionFile ?? t(\"inMemorySession\"),\n\t\t\t},\n\t\t\t...this.sessionChoices.map((choice) => ({\n\t\t\t\tvalue: choice.id,\n\t\t\t\tlabel: choice.label,\n\t\t\t\t...(choice.description ? { description: choice.description } : {}),\n\t\t\t})),\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tif (item.value === \"__current__\") {\n\t\t\t\tthis.projection.setStatus(\"session=current\");\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst choice = this.sessionChoices.find((candidate) => candidate.id === item.value);\n\t\t\tif (!choice) return;\n\t\t\tthis.closeOverlay();\n\t\t\tvoid this.switchSession(choice);\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openTreeSelector(): void {\n\t\tif (this.promptInFlight || this.compactionInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"提示词运行时不能浏览会话树。\"\n\t\t\t\t\t: \"Cannot browse the session tree while a prompt is running.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.session.sessionTree.length === 0) {\n\t\t\tthis.projection.setStatus(\n\t\t\t\tthis.locale === \"zh-CN\" ? \"当前会话还没有历史节点。\" : \"The current session has no history nodes.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst selector = new TreeSelector({\n\t\t\tnodes: this.session.sessionTree,\n\t\t\tleafId: this.session.sessionLeafId,\n\t\t\tlocale: this.locale,\n\t\t\tonContinue: (entry) => {\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tvoid this.navigateTreeEntry(entry.id);\n\t\t\t},\n\t\t\tonEdit: (entry) => {\n\t\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"user\") {\n\t\t\t\t\tthis.projection.setError(\n\t\t\t\t\t\tthis.locale === \"zh-CN\" ? \"只能编辑历史用户消息。\" : \"Only historical user messages can be edited.\",\n\t\t\t\t\t);\n\t\t\t\t\tthis.refresh();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tvoid this.navigateTreeEntry(entry.id);\n\t\t\t},\n\t\t\tonSummarize: (entry) => {\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tvoid this.summarizeTreeBranch(entry.id);\n\t\t\t},\n\t\t\tonCancel: () => this.closeOverlay(),\n\t\t});\n\t\tthis.showOverlay(selector, true, \"80%\");\n\t}\n\n\tprivate async navigateTreeEntry(entryId: string): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.session.navigateTree(entryId);\n\t\t\tif (!this.started) return false;\n\t\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\t\tthis.editor.setValue(result.editorText ?? \"\");\n\t\t\tthis.projection.setStatus(\n\t\t\t\tresult.imagesOmitted\n\t\t\t\t\t? this.locale === \"zh-CN\"\n\t\t\t\t\t\t? \"已恢复文本;请重新附加图片。\"\n\t\t\t\t\t\t: \"Text restored; reattach images before sending.\"\n\t\t\t\t\t: `tree=${result.selectedEntryId}`,\n\t\t\t);\n\t\t\treturn true;\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\treturn false;\n\t\t} finally {\n\t\t\tthis.refresh();\n\t\t}\n\t}\n\n\tprivate async summarizeTreeBranch(entryId: string): Promise<void> {\n\t\tif (this.compactionInFlight || this.promptInFlight) return;\n\t\tthis.compactionInFlight = true;\n\t\tthis.projection.setStatus(this.locale === \"zh-CN\" ? \"正在为分支生成摘要。\" : \"Summarizing selected branch.\");\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tif (!(await this.navigateTreeEntry(entryId))) return;\n\t\t\tawait this.session.compact();\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\t\tthis.projection.setStatus(this.locale === \"zh-CN\" ? \"摘要分支已创建。\" : \"Summary branch created.\");\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.compactionInFlight = false;\n\t\t\tthis.refresh();\n\t\t}\n\t}\n\n\tprivate openSettingsSelector(): void {\n\t\tconst t = (key: string) => translate(this.locale, key);\n\t\tconst list = new SettingsList(\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tid: \"compaction\",\n\t\t\t\t\tlabel: t(\"contextCompaction\"),\n\t\t\t\t\tcurrentValue: this.session.compactionEnabled ? t(\"on\") : t(\"off\"),\n\t\t\t\t\tvalues: [t(\"on\"), t(\"off\")],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"locale\",\n\t\t\t\t\tlabel: t(\"language\"),\n\t\t\t\t\tcurrentValue: this.locale,\n\t\t\t\t\tvalues: [\"en\", \"zh-CN\"],\n\t\t\t\t},\n\t\t\t],\n\t\t\t{ title: t(\"settings\") },\n\t\t);\n\t\tlist.onChange = (id, value) => {\n\t\t\tif (id === \"locale\") {\n\t\t\t\tthis.locale = value === \"zh-CN\" ? \"zh-CN\" : \"en\";\n\t\t\t\tvoid saveGlobalLocale(this.agentDir, this.locale).catch((cause) => {\n\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\tthis.refresh();\n\t\t\t\t});\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.openSettingsSelector();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (id !== \"compaction\") return;\n\t\t\ttry {\n\t\t\t\tconst enabled = this.session.setCompactionEnabled(value === t(\"on\"));\n\t\t\t\tlist.updateValue(id, enabled ? t(\"on\") : t(\"off\"));\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\tenabled === (value === t(\"on\")) ? `compaction=${enabled ? t(\"on\") : t(\"off\")}` : t(\"compactionUnavailable\"),\n\t\t\t\t);\n\t\t\t} catch (cause) {\n\t\t\t\tlist.updateValue(id, this.session.compactionEnabled ? t(\"on\") : t(\"off\"));\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\tthis.closeOverlay();\n\t\t\t}\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate showOverlay(component: Component, preserveLastLine = false, maxHeight: \"60%\" | \"80%\" = \"60%\"): void {\n\t\tthis.editor.cancelAutocomplete();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.closeOverlay();\n\t\tthis.overlay = this.tui.showOverlay(component, {\n\t\t\twidth: \"70%\",\n\t\t\tmaxHeight,\n\t\t\tanchor: \"center\",\n\t\t\tmargin: 1,\n\t\t\tpreserveLastLine,\n\t\t});\n\t}\n\n\tprivate closeOverlay(): void {\n\t\tthis.overlay?.hide();\n\t\tthis.overlay = undefined;\n\t}\n\n\tprivate updateAutocompleteOverlay(): void {\n\t\tthis.closeAutocompleteOverlay();\n\t\tif (!this.editor.isShowingAutocomplete()) {\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst menu = new AutocompleteMenu(() => ({\n\t\t\titems: this.editor.getAutocompleteItems(),\n\t\t\tindex: this.editor.getAutocompleteIndex(),\n\t\t}));\n\t\tconst editorBounds = this.root.getEditorBounds(this.tui.columns);\n\t\tthis.autocompleteOverlay = this.tui.showOverlay(menu, {\n\t\t\twidth: \"55%\",\n\t\t\tmaxHeight: 9,\n\t\t\tanchor: \"bottom-left\",\n\t\t\tplacement: {\n\t\t\t\tanchorRow: editorBounds.end - 1,\n\t\t\t\tavoidStartRow: editorBounds.start,\n\t\t\t\tpreferred: \"below\",\n\t\t\t},\n\t\t\tmargin: 1,\n\t\t\tpreserveLastLine: true,\n\t\t\tnonCapturing: true,\n\t\t});\n\t\tthis.refresh();\n\t}\n\n\tprivate closeAutocompleteOverlay(): void {\n\t\tthis.autocompleteOverlay?.hide();\n\t\tthis.autocompleteOverlay = undefined;\n\t}\n\n\tprivate refresh(): void {\n\t\tthis.root.invalidate();\n\t\tthis.tui.requestRender();\n\t}\n\n\tprivate startSpinnerTimer(): void {\n\t\tthis.stopSpinnerTimer();\n\t\tthis.spinnerTimer = setInterval(() => {\n\t\t\tif (this.projection.advanceSpinner()) this.refresh();\n\t\t}, 120);\n\t\tthis.spinnerTimer.unref?.();\n\t}\n\n\tprivate stopSpinnerTimer(): void {\n\t\tif (this.spinnerTimer) clearInterval(this.spinnerTimer);\n\t\tthis.spinnerTimer = undefined;\n\t}\n\n\tprivate subscribeToSession(): void {\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = this.session.subscribeSession((event) => {\n\t\t\tif (!this.started) return;\n\t\t\tif (event.type === \"tree_navigated\") {\n\t\t\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"queue_update\") {\n\t\t\t\tthis.steeringPrompts = [...event.steering];\n\t\t\t\tthis.refreshQueue();\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.projection.apply(event);\n\t\t\tthis.refresh();\n\t\t});\n\t}\n\n\tprivate async switchSession(choice: InteractiveSessionChoice): Promise<void> {\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\" ? \"提示词运行时不能切换会话。\" : \"Cannot switch sessions while a prompt is running.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.sessionSwitching = true;\n\t\tthis.projection.setStatus(`opening session=${choice.id}`);\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tconst next = await choice.open();\n\t\t\tif (!this.started) return;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.session = next;\n\t\t\tthis.projection.configureFilePreview(next.allowedRoot, () => this.refresh());\n\t\t\tthis.clipboardDirectory = clipboardImageDirectory(this.agentDir, next.allowedRoot);\n\t\t\tvoid cleanupStaleClipboardImages(this.agentDir, next.allowedRoot);\n\t\t\tthis.queuedPrompts = [];\n\t\t\tthis.steeringPrompts = [];\n\t\t\tthis.refreshQueue();\n\t\t\tthis.projection.replaceTranscript(next.transcript);\n\t\t\tthis.projection.setUsage(next.usage);\n\t\t\tthis.projection.setStatus(`session=${choice.id}`);\n\t\t\tthis.subscribeToSession();\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.sessionSwitching = false;\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate async submit(text: string, retry = false): Promise<void> {\n\t\tconst prompt = text.trim();\n\t\tif (prompt.length === 0 || !this.started) return;\n\t\tconst steeringArgument = steeringCommandArgument(prompt);\n\t\tif (steeringArgument !== undefined) {\n\t\t\tawait this.submitSteering(steeringArgument);\n\t\t\treturn;\n\t\t}\n\t\tif (prompt.startsWith(\"/\") && !this.isLoadedSkillCommand(prompt)) {\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tthis.handleSlashCommand(prompt);\n\t\t\treturn;\n\t\t}\n\t\tif (this.sessionSwitching) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"会话正在打开,请等待后再提交提示词。\"\n\t\t\t\t\t: \"A session is opening; wait before submitting a prompt.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.compactionInFlight) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"正在压缩上下文,请等待后再提交提示词。\"\n\t\t\t\t\t: \"A compaction is running; wait before submitting a prompt.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight) {\n\t\t\tthis.queuedPrompts.push(prompt);\n\t\t\tthis.refreshQueue();\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.promptInFlight = true;\n\t\tthis.activeAbort = new AbortController();\n\t\tthis.projection.setRetrying(retry);\n\t\ttry {\n\t\t\tconst input = await extractImageAttachments(\n\t\t\t\tnormalizeDroppedImagePrompt(prompt, this.session.allowedRoot),\n\t\t\t\tthis.session.allowedRoot,\n\t\t\t);\n\t\t\tthis.preserveClipboardFiles = true;\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tconst result =\n\t\t\t\tretry && \"retry\" in this.session\n\t\t\t\t\t? await this.session.retry(this.activeAbort.signal)\n\t\t\t\t\t: await this.session.promptWithImages(input.text, input.images, this.activeAbort.signal);\n\t\t\tif (result.stopReason === \"error\" || result.stopReason === \"aborted\") this.lastFailedPrompt = prompt;\n\t\t\telse {\n\t\t\t\tthis.lastFailedPrompt = undefined;\n\t\t\t\tawait this.cleanupClipboardFiles();\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tthis.lastFailedPrompt = prompt;\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.preserveClipboardFiles = false;\n\t\t\tthis.promptInFlight = false;\n\t\t\tthis.activeAbort = undefined;\n\t\t\tthis.projection.setRetrying(false);\n\t\t\tconst next = this.queuedPrompts.shift();\n\t\t\tthis.refreshQueue();\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\tif (next && this.started) void this.submit(next);\n\t\t}\n\t}\n\n\tprivate async submitSteering(text: string): Promise<void> {\n\t\tconst prompt = text.trim();\n\t\tif (prompt.length === 0) {\n\t\t\tthis.projection.setError(this.locale === \"zh-CN\" ? \"引导内容不能为空。\" : \"Steering content must not be empty.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.sessionSwitching) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"会话正在打开,请等待后再引导 Agent。\"\n\t\t\t\t\t: \"A session is opening; wait before steering the agent.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.compactionInFlight) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"正在压缩上下文,请等待后再引导 Agent。\"\n\t\t\t\t\t: \"A compaction is running; wait before steering the agent.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (!this.promptInFlight) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\"\n\t\t\t\t\t? \"只能在提示词运行时引导 Agent。\"\n\t\t\t\t\t: \"Steering is only available while a prompt is running.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst input = await extractImageAttachments(\n\t\t\t\tnormalizeDroppedImagePrompt(prompt, this.session.allowedRoot),\n\t\t\t\tthis.session.allowedRoot,\n\t\t\t);\n\t\t\tawait this.session.steerWithImages(input.text, input.images);\n\t\t\tthis.editor.setValue(\"\");\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate refreshQueue(): void {\n\t\tthis.projection.setQueue([\n\t\t\t...this.steeringPrompts.map((prompt) => `steer: ${prompt}`),\n\t\t\t...this.queuedPrompts.map((prompt) => `queued: ${prompt}`),\n\t\t]);\n\t}\n\n\tprivate async cleanupUnreferencedClipboardFiles(): Promise<void> {\n\t\tconst text = this.editor.getValue();\n\t\tconst files = [...this.clipboardFiles].filter((path) => !text.includes(path));\n\t\tawait Promise.all(files.map((path) => removeClipboardImage(path, this.clipboardDirectory)));\n\t\tfor (const path of files) this.clipboardFiles.delete(path);\n\t}\n\n\tprivate async cleanupClipboardFiles(): Promise<void> {\n\t\tconst files = [...this.clipboardFiles];\n\t\tawait Promise.all(files.map((path) => removeClipboardImage(path, this.clipboardDirectory)));\n\t\tfor (const path of files) this.clipboardFiles.delete(path);\n\t}\n\n\tprivate handleSlashCommand(input: string): void {\n\t\tconst trimmed = input.slice(1).trim();\n\t\tconst [rawCommand = \"\", ...argParts] = trimmed.split(/\\s+/);\n\t\tconst command = rawCommand.toLowerCase();\n\t\tconst args = argParts.join(\" \");\n\t\tif (this.commandRegistry?.list().some((entry) => entry.name === command)) {\n\t\t\tvoid this.commandRegistry\n\t\t\t\t.execute(command, {\n\t\t\t\t\thost: { runCommand: (name: string, value: string) => this.runRegisteredCommand(name, value) },\n\t\t\t\t\targs,\n\t\t\t\t})\n\t\t\t\t.catch((cause) => {\n\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\tthis.refresh();\n\t\t\t\t});\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.runRegisteredCommand(command, args);\n\t}\n\n\tprivate runRegisteredCommand(command: string, _args: string): number {\n\t\tswitch (command) {\n\t\t\tcase \"help\":\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\t`commands: ${this.listSlashCommands()\n\t\t\t\t\t\t.map((item) => `/${item.name}`)\n\t\t\t\t\t\t.join(\" \")}`,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"clear\":\n\t\t\t\tthis.projection.clearVisibleMessages();\n\t\t\t\tthis.projection.setStatus(translate(this.locale, \"visibleMessagesCleared\"));\n\t\t\t\tbreak;\n\t\t\tcase \"model\":\n\t\t\t\tthis.openModelSelector();\n\t\t\t\treturn 0;\n\t\t\tcase \"session\":\n\t\t\t\tthis.openSessionSelector();\n\t\t\t\treturn 0;\n\t\t\tcase \"tree\":\n\t\t\t\tthis.openTreeSelector();\n\t\t\t\treturn 0;\n\t\t\tcase \"theme\":\n\t\t\t\tthis.openThemeSelector();\n\t\t\t\treturn 0;\n\t\t\tcase \"settings\":\n\t\t\t\tthis.openSettingsSelector();\n\t\t\t\treturn 0;\n\t\t\tcase \"login\":\n\t\t\t\tthis.openProviderLogin();\n\t\t\t\treturn 0;\n\t\t\tcase \"logout\":\n\t\t\t\tvoid this.logoutProvider();\n\t\t\t\treturn 0;\n\t\t\tcase \"compact\":\n\t\t\t\tvoid this.runManualCompaction();\n\t\t\t\treturn 0;\n\t\t\tcase \"usage\":\n\t\t\t\tthis.projection.setStatus(this.formatUsage());\n\t\t\t\tbreak;\n\t\t\tcase \"retry\":\n\t\t\t\tif (this.lastFailedPrompt && !this.promptInFlight) {\n\t\t\t\t\tif (this.context) void this.context.retry();\n\t\t\t\t\telse void this.submit(this.lastFailedPrompt, true);\n\t\t\t\t} else this.projection.setStatus(translate(this.locale, \"nothingToRetry\"));\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthis.projection.setError(`Unknown command: /${command}`);\n\t\t}\n\t\tthis.refresh();\n\t\treturn 0;\n\t}\n\n\tprivate openProviderLogin(): void {\n\t\tif (!this.providerOnboarding) {\n\t\t\tthis.projection.setError(\"Provider login is unavailable in this session.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot change Provider while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.editor.cancelAutocomplete();\n\t\tthis.closeAutocompleteOverlay();\n\t\tvoid showInteractiveProviderOnboarding({\n\t\t\t...this.providerOnboarding,\n\t\t\tconfiguration: { ...this.providerOnboarding.configuration, locale: this.locale },\n\t\t\ttui: this.tui,\n\t\t})\n\t\t\t.then((runtime) => {\n\t\t\t\tif (!this.started) return;\n\t\t\t\tthis.tui.setFocus(this.editor);\n\t\t\t\tif (!runtime) {\n\t\t\t\t\tthis.refresh();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.session.setRuntime(runtime.provider, runtime.model);\n\t\t\t\tthis.projection.setStatus(`provider=${runtime.provider.id} model=${runtime.model.id}`);\n\t\t\t\tthis.refresh();\n\t\t\t})\n\t\t\t.catch((cause) => {\n\t\t\t\tif (this.started) this.tui.setFocus(this.editor);\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\tthis.refresh();\n\t\t\t});\n\t}\n\n\tprivate async logoutProvider(): Promise<void> {\n\t\tif (!this.providerOnboarding) {\n\t\t\tthis.projection.setError(\"Provider logout is unavailable in this session.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot change Provider while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst providerId = this.session.providerId;\n\t\ttry {\n\t\t\tconst removed = await removeGlobalProviderApiKey(this.providerOnboarding.agentDir, providerId);\n\t\t\tif (!removed) {\n\t\t\t\tthis.projection.setStatus(`no global API key stored for provider=${providerId}`);\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.projection.setStatus(\n\t\t\t\t`global API key removed for provider=${providerId}; it remains active until this session ends`,\n\t\t\t);\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate listSlashCommands(): readonly SlashCommand[] {\n\t\tconst skills = this.session.availableSkills.map((skill) => ({\n\t\t\tname: `skill:${skill.name}`,\n\t\t\tdescription: skill.description,\n\t\t}));\n\t\tconst registryCommands = this.commandRegistry?.list().map((command) => ({\n\t\t\tname: command.name,\n\t\t\tdescription: typeof command.description === \"function\" ? command.description(this.locale) : command.description,\n\t\t}));\n\t\treturn [...(registryCommands ?? builtinSlashCommands(this.locale)), ...skills];\n\t}\n\n\tprivate isLoadedSkillCommand(input: string): boolean {\n\t\tconst name = /^\\/skill:([a-z0-9]+(?:-[a-z0-9]+)*)(?:\\s|$)/.exec(input)?.[1];\n\t\treturn name !== undefined && this.session.availableSkills.some((skill) => skill.name === name);\n\t}\n\n\tprivate formatUsage(): string {\n\t\tconst usage = this.session.usage;\n\t\tif (this.locale === \"zh-CN\") {\n\t\t\treturn `用量:请求=${usage.requestCount} 输入=${usage.inputTokens} 输出=${usage.outputTokens} 总计=${usage.totalTokens} 费用=$${usage.cost.total.toFixed(4)} 上下文=${usage.estimatedContextTokens}/${usage.contextWindow}`;\n\t\t}\n\t\treturn `usage: requests=${usage.requestCount} input=${usage.inputTokens} output=${usage.outputTokens} total=${usage.totalTokens} cost=$${usage.cost.total.toFixed(4)} context=${usage.estimatedContextTokens}/${usage.contextWindow}`;\n\t}\n\n\tprivate async runManualCompaction(): Promise<void> {\n\t\tif (this.promptInFlight || this.compactionInFlight) {\n\t\t\tthis.projection.setError(\n\t\t\t\tthis.locale === \"zh-CN\" ? \"提示词运行时不能压缩上下文。\" : \"Cannot compact while a prompt is running.\",\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.compactionInFlight = true;\n\t\tthis.projection.setStatus(translate(this.locale, \"manualCompactionStarting\"));\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tawait this.session.compact();\n\t\t\tthis.projection.setStatus(translate(this.locale, \"manualCompactionComplete\"));\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.compactionInFlight = false;\n\t\t\tthis.refresh();\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { RendererDefinition } from "@di-code/builtins";
2
+ import { type JsonRunner } from "./json.ts";
3
+ import type { PrintIo } from "./print.ts";
4
+ export interface JsonModeEntryOptions {
5
+ readonly prompt: string;
6
+ readonly runner: JsonRunner;
7
+ readonly io: PrintIo;
8
+ readonly renderer?: RendererDefinition;
9
+ readonly onStart: () => void | Promise<void>;
10
+ readonly onStop: () => void | Promise<void>;
11
+ }
12
+ export declare function runJsonModeEntry(options: JsonModeEntryOptions): Promise<number>;
13
+ //# sourceMappingURL=json-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-entry.d.ts","sourceRoot":"","sources":["../../src/modes/json-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAqB,KAAK,UAAU,EAAe,MAAM,WAAW,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAUrF"}
@@ -0,0 +1,14 @@
1
+ import { runJsonMode } from "./json.js";
2
+ export async function runJsonModeEntry(options) {
3
+ await options.onStart();
4
+ try {
5
+ const renderer = options.renderer
6
+ ? { render: (event) => options.renderer?.render(event) }
7
+ : undefined;
8
+ return await runJsonMode(options.prompt, options.runner, options.io, renderer);
9
+ }
10
+ finally {
11
+ await options.onStop();
12
+ }
13
+ }
14
+ //# sourceMappingURL=json-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-entry.js","sourceRoot":"","sources":["../../src/modes/json-entry.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,WAAW,EAAE,MAAM,WAAW,CAAC;AAY5E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA6B;IACnE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IACxB,IAAI,CAAC;QACJ,MAAM,QAAQ,GAA6B,OAAO,CAAC,QAAQ;YAC1D,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;YACxD,CAAC,CAAC,SAAS,CAAC;QACb,OAAO,MAAM,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChF,CAAC;YAAS,CAAC;QACV,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;AACF,CAAC","sourcesContent":["import type { RendererDefinition } from \"@di-code/builtins\";\nimport { type JsonRenderer, type JsonRunner, runJsonMode } from \"./json.ts\";\nimport type { PrintIo } from \"./print.ts\";\n\nexport interface JsonModeEntryOptions {\n\treadonly prompt: string;\n\treadonly runner: JsonRunner;\n\treadonly io: PrintIo;\n\treadonly renderer?: RendererDefinition;\n\treadonly onStart: () => void | Promise<void>;\n\treadonly onStop: () => void | Promise<void>;\n}\n\nexport async function runJsonModeEntry(options: JsonModeEntryOptions): Promise<number> {\n\tawait options.onStart();\n\ttry {\n\t\tconst renderer: JsonRenderer | undefined = options.renderer\n\t\t\t? { render: (event) => options.renderer?.render(event) }\n\t\t\t: undefined;\n\t\treturn await runJsonMode(options.prompt, options.runner, options.io, renderer);\n\t} finally {\n\t\tawait options.onStop();\n\t}\n}\n"]}
@@ -10,5 +10,8 @@ export interface JsonRunner {
10
10
  prompt(text: string): Promise<AssistantMessage>;
11
11
  subscribe(listener: AgentListener): () => void;
12
12
  }
13
- export declare function runJsonMode(prompt: string, runner: JsonRunner, io: PrintIo): Promise<number>;
13
+ export interface JsonRenderer {
14
+ render(event: AgentEvent): string | undefined;
15
+ }
16
+ export declare function runJsonMode(prompt: string, runner: JsonRunner, io: PrintIo, renderer?: JsonRenderer): Promise<number>;
14
17
  //# sourceMappingURL=json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/modes/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,eAAO,MAAM,kBAAkB,EAAG,CAAU,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,kBAAkB,CAAC;IAC5C,QAAQ,CAA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2
  function toError(cause) {
3
3
  return cause instanceof Error ? cause : new Error(String(cause));
4
4
  }
5
- export async function runJsonMode(prompt, runner, io) {
5
+ export async function runJsonMode(prompt, runner, io, renderer) {
6
6
  const unsubscribe = runner.subscribe((event) => {
7
- const record = { version: JSON_EVENT_VERSION, event };
8
- io.stdout(`${JSON.stringify(record)}\n`);
7
+ const rendered = renderer?.render(event) ?? JSON.stringify({ version: JSON_EVENT_VERSION, event });
8
+ io.stdout(`${rendered}\n`);
9
9
  });
10
10
  try {
11
11
  const assistant = await runner.prompt(prompt);
@@ -1 +1 @@
1
- {"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/modes/json.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAU,CAAC;AAY7C,SAAS,OAAO,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAc,EAAE,MAAkB,EAAE,EAAW;IAChF,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAoB,EAAE,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;QACvE,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACJ,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,SAAS,CAAC,UAAU,KAAK,OAAO,IAAI,SAAS,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAC5E,EAAE,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,YAAY,IAAI,CAAC,CAAC;YACzC,OAAO,CAAC,CAAC;QACV,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,EAAE,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC;QACzC,OAAO,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACV,WAAW,EAAE,CAAC;IACf,CAAC;AACF,CAAC","sourcesContent":["import type { AgentEvent, AgentListener } from \"@di-code/agent\";\nimport type { AssistantMessage } from \"@di-code/ai\";\nimport type { PrintIo } from \"./print.ts\";\n\nexport const JSON_EVENT_VERSION = 2 as const;\n\nexport interface JsonEventRecord {\n\treadonly version: typeof JSON_EVENT_VERSION;\n\treadonly event: AgentEvent;\n}\n\nexport interface JsonRunner {\n\tprompt(text: string): Promise<AssistantMessage>;\n\tsubscribe(listener: AgentListener): () => void;\n}\n\nfunction toError(cause: unknown): Error {\n\treturn cause instanceof Error ? cause : new Error(String(cause));\n}\n\nexport async function runJsonMode(prompt: string, runner: JsonRunner, io: PrintIo): Promise<number> {\n\tconst unsubscribe = runner.subscribe((event) => {\n\t\tconst record: JsonEventRecord = { version: JSON_EVENT_VERSION, event };\n\t\tio.stdout(`${JSON.stringify(record)}\\n`);\n\t});\n\n\ttry {\n\t\tconst assistant = await runner.prompt(prompt);\n\t\tif (assistant.stopReason === \"error\" || assistant.stopReason === \"aborted\") {\n\t\t\tio.stderr(`${assistant.errorMessage}\\n`);\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t} catch (cause) {\n\t\tio.stderr(`${toError(cause).message}\\n`);\n\t\treturn 1;\n\t} finally {\n\t\tunsubscribe();\n\t}\n}\n"]}
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/modes/json.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAU,CAAC;AAgB7C,SAAS,OAAO,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,MAAc,EACd,MAAkB,EAClB,EAAW,EACX,QAAuB;IAEvB,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QAC9C,MAAM,QAAQ,GAAG,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAC;QACnG,EAAE,CAAC,MAAM,CAAC,GAAG,QAAQ,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACJ,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,SAAS,CAAC,UAAU,KAAK,OAAO,IAAI,SAAS,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAC5E,EAAE,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,YAAY,IAAI,CAAC,CAAC;YACzC,OAAO,CAAC,CAAC;QACV,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,EAAE,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC;QACzC,OAAO,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACV,WAAW,EAAE,CAAC;IACf,CAAC;AACF,CAAC","sourcesContent":["import type { AgentEvent, AgentListener } from \"@di-code/agent\";\nimport type { AssistantMessage } from \"@di-code/ai\";\nimport type { PrintIo } from \"./print.ts\";\n\nexport const JSON_EVENT_VERSION = 2 as const;\n\nexport interface JsonEventRecord {\n\treadonly version: typeof JSON_EVENT_VERSION;\n\treadonly event: AgentEvent;\n}\n\nexport interface JsonRunner {\n\tprompt(text: string): Promise<AssistantMessage>;\n\tsubscribe(listener: AgentListener): () => void;\n}\n\nexport interface JsonRenderer {\n\trender(event: AgentEvent): string | undefined;\n}\n\nfunction toError(cause: unknown): Error {\n\treturn cause instanceof Error ? cause : new Error(String(cause));\n}\n\nexport async function runJsonMode(\n\tprompt: string,\n\trunner: JsonRunner,\n\tio: PrintIo,\n\trenderer?: JsonRenderer,\n): Promise<number> {\n\tconst unsubscribe = runner.subscribe((event) => {\n\t\tconst rendered = renderer?.render(event) ?? JSON.stringify({ version: JSON_EVENT_VERSION, event });\n\t\tio.stdout(`${rendered}\\n`);\n\t});\n\n\ttry {\n\t\tconst assistant = await runner.prompt(prompt);\n\t\tif (assistant.stopReason === \"error\" || assistant.stopReason === \"aborted\") {\n\t\t\tio.stderr(`${assistant.errorMessage}\\n`);\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t} catch (cause) {\n\t\tio.stderr(`${toError(cause).message}\\n`);\n\t\treturn 1;\n\t} finally {\n\t\tunsubscribe();\n\t}\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { PrintIo, PromptRunner } from "./print.ts";
2
+ export interface PrintModeEntryOptions {
3
+ readonly prompt: string;
4
+ readonly runner: PromptRunner;
5
+ readonly io: PrintIo;
6
+ readonly onStart: () => void | Promise<void>;
7
+ readonly onStop: () => void | Promise<void>;
8
+ }
9
+ export declare function runPrintModeEntry(options: PrintModeEntryOptions): Promise<number>;
10
+ //# sourceMappingURL=print-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-entry.d.ts","sourceRoot":"","sources":["../../src/modes/print-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGxD,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAOvF"}
@@ -0,0 +1,11 @@
1
+ import { runPrintMode } from "./print.js";
2
+ export async function runPrintModeEntry(options) {
3
+ await options.onStart();
4
+ try {
5
+ return await runPrintMode(options.prompt, options.runner, options.io);
6
+ }
7
+ finally {
8
+ await options.onStop();
9
+ }
10
+ }
11
+ //# sourceMappingURL=print-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-entry.js","sourceRoot":"","sources":["../../src/modes/print-entry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAU1C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAA8B;IACrE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IACxB,IAAI,CAAC;QACJ,OAAO,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;YAAS,CAAC;QACV,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;AACF,CAAC","sourcesContent":["import type { PrintIo, PromptRunner } from \"./print.ts\";\nimport { runPrintMode } from \"./print.ts\";\n\nexport interface PrintModeEntryOptions {\n\treadonly prompt: string;\n\treadonly runner: PromptRunner;\n\treadonly io: PrintIo;\n\treadonly onStart: () => void | Promise<void>;\n\treadonly onStop: () => void | Promise<void>;\n}\n\nexport async function runPrintModeEntry(options: PrintModeEntryOptions): Promise<number> {\n\tawait options.onStart();\n\ttry {\n\t\treturn await runPrintMode(options.prompt, options.runner, options.io);\n\t} finally {\n\t\tawait options.onStop();\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tree-selector.d.ts","sourceRoot":"","sources":["../../src/modes/tree-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAmC,MAAM,cAAc,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,YAAY,CAAC;AAyBpD,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACvC,MAAM,CAAC,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,WAAW,CAAC,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,IAAI,IAAI,CAAC;CAClB;AA4FD,oHAAoH;AACpH,qBAAa,YAAa,YAAW,SAAS,EAAE,SAAS;IACxD,OAAO,UAAS;IAChB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA0B;IAChD,OAAO,CAAC,aAAa,CAAK;gBAEd,OAAO,EAAE,mBAAmB;IAOxC,UAAU,IAAI,IAAI;IAElB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAwB/B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAwB/B,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,YAAY;IAapB,OAA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I;IAKZ,OAAO,CAAC,MAAM;CAOd"}
@@ -20,6 +20,8 @@ function singleLine(value) {
20
20
  function textContent(entry) {
21
21
  if (entry.type === "summary")
22
22
  return singleLine(entry.summary);
23
+ if (entry.type === "plugin")
24
+ return singleLine(`plugin:${entry.pluginId}`);
23
25
  return singleLine(entry.message.content
24
26
  .filter((content) => content.type === "text")
25
27
  .map((content) => content.text)
@@ -169,6 +171,8 @@ export class TreeSelector {
169
171
  const text = textContent(entry);
170
172
  if (entry.type === "summary")
171
173
  return `${paint(YELLOW, "summary: ")}${text || paint(DIM, "(empty)")}`;
174
+ if (entry.type === "plugin")
175
+ return `${paint(DIM, "plugin: ")}${text || paint(DIM, "(empty)")}`;
172
176
  if (entry.message.role === "user")
173
177
  return `${paint(CYAN, "user: ")}${text || paint(DIM, "(empty)")}`;
174
178
  if (entry.message.role === "assistant") {
@@ -1 +1 @@
1
- {"version":3,"file":"tree-selector.js","sourceRoot":"","sources":["../../src/modes/tree-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,GAAG,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/F,OAAO,EAAe,SAAS,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,gBAAgB,GAAG,UAAU,CAAC;AACpC,MAAM,IAAI,GAAG,eAAe,CAAC;AAC7B,MAAM,KAAK,GAAG,gBAAgB,CAAC;AAC/B,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAChC,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAC7B,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAC7B,MAAM,iBAAiB,GAAG,EAAE,CAAC;AA2B7B,SAAS,KAAK,CAAC,KAAa,EAAE,IAAY;IACzC,8FAA8F;IAC9F,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,gBAAgB,EAAE,CAAC;AAC7C,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAChC,OAAO,KAAK;SACV,OAAO,CAAC,YAAY,EAA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,CAAC,MAAM,EAAE,eAAe,CAAC,YAAY,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;IACvO,CAAC;IAEO,IAAI,CAAC,SAAiB;QAC7B,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACpC,IAAI,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC/F,CAAC;IAEO,MAAM,CAAC,MAAyC;QACvD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC;QACpD,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,IAAI,MAAM,KAAK,UAAU;YAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC;aACvD,IAAI,MAAM,KAAK,MAAM;YAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;;YACpD,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACD","sourcesContent":["import { type Component, type Focusable, Key, matchesKey, SelectionPanel } from \"@di-code/tui\";\nimport type { SessionEntry, SessionTreeNode } from \"../core/session/types.ts\";\nimport { type Locale, translate } from \"../i18n.ts\";\n\nconst RESET_FOREGROUND = \"\\x1b[39m\";\nconst CYAN = \"\\x1b[38;5;45m\";\nconst GREEN = \"\\x1b[38;5;114m\";\nconst YELLOW = \"\\x1b[38;5;222m\";\nconst RED = \"\\x1b[38;5;210m\";\nconst DIM = \"\\x1b[38;5;245m\";\nconst MAX_VISIBLE_NODES = 12;\n\ninterface FlatTreeNode {\n\treadonly entry: SessionEntry;\n\t/** Visual indentation only grows where the session graph actually branches. */\n\treadonly indent: number;\n\treadonly showConnector: boolean;\n\treadonly isLast: boolean;\n\treadonly gutters: readonly TreeGutter[];\n\treadonly isCurrentPath: boolean;\n}\n\ninterface TreeGutter {\n\treadonly level: number;\n\treadonly continues: boolean;\n}\n\nexport interface TreeSelectorOptions {\n\treadonly nodes: readonly SessionTreeNode[];\n\treadonly leafId?: string;\n\treadonly locale: Locale;\n\tonContinue?(entry: SessionEntry): void;\n\tonEdit?(entry: SessionEntry): void;\n\tonSummarize?(entry: SessionEntry): void;\n\tonCancel?(): void;\n}\n\nfunction paint(color: string, text: string): string {\n\t// Reset only the foreground so a selected row keeps its background across coloured fragments.\n\treturn `${color}${text}${RESET_FOREGROUND}`;\n}\n\nfunction singleLine(value: string): string {\n\treturn value\n\t\t.replace(/[\\r\\n\\t]+/g, \" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n}\n\nfunction textContent(entry: SessionEntry): string {\n\tif (entry.type === \"summary\") return singleLine(entry.summary);\n\treturn singleLine(\n\t\tentry.message.content\n\t\t\t.filter((content) => content.type === \"text\")\n\t\t\t.map((content) => content.text)\n\t\t\t.join(\" \"),\n\t);\n}\n\nfunction flattenTree(nodes: readonly SessionTreeNode[], leafId: string | undefined): FlatTreeNode[] {\n\tconst parents = new Map<string, string>();\n\tconst raw: Array<Omit<FlatTreeNode, \"isCurrentPath\">> = [];\n\ttype PendingNode = {\n\t\treadonly node: SessionTreeNode;\n\t\treadonly indent: number;\n\t\treadonly justBranched: boolean;\n\t\treadonly showConnector: boolean;\n\t\treadonly isLast: boolean;\n\t\treadonly gutters: readonly TreeGutter[];\n\t};\n\tconst stack: PendingNode[] = [];\n\tconst multipleRoots = nodes.length > 1;\n\n\tfor (let index = nodes.length - 1; index >= 0; index -= 1) {\n\t\tconst node = nodes[index];\n\t\tif (!node) continue;\n\t\tstack.push({\n\t\t\tnode,\n\t\t\tindent: multipleRoots ? 1 : 0,\n\t\t\tjustBranched: multipleRoots,\n\t\t\tshowConnector: multipleRoots,\n\t\t\tisLast: index === nodes.length - 1,\n\t\t\tgutters: [],\n\t\t});\n\t}\n\n\twhile (stack.length > 0) {\n\t\tconst current = stack.pop();\n\t\tif (!current) continue;\n\t\traw.push({\n\t\t\tentry: current.node.entry,\n\t\t\tindent: current.indent,\n\t\t\tshowConnector: current.showConnector,\n\t\t\tisLast: current.isLast,\n\t\t\tgutters: current.gutters,\n\t\t});\n\t\tconst children = current.node.children;\n\t\tconst multipleChildren = children.length > 1;\n\t\tconst childIndent = multipleChildren\n\t\t\t? current.indent + 1\n\t\t\t: current.justBranched && current.indent > 0\n\t\t\t\t? current.indent + 1\n\t\t\t\t: current.indent;\n\t\tconst childGutters =\n\t\t\tcurrent.showConnector && current.indent > 0\n\t\t\t\t? [...current.gutters, { level: current.indent - 1, continues: !current.isLast }]\n\t\t\t\t: current.gutters;\n\t\tfor (let index = children.length - 1; index >= 0; index -= 1) {\n\t\t\tconst child = children[index];\n\t\t\tif (!child) continue;\n\t\t\tparents.set(child.entry.id, current.node.entry.id);\n\t\t\tstack.push({\n\t\t\t\tnode: child,\n\t\t\t\tindent: childIndent,\n\t\t\t\tjustBranched: multipleChildren,\n\t\t\t\tshowConnector: multipleChildren,\n\t\t\t\tisLast: index === children.length - 1,\n\t\t\t\tgutters: childGutters,\n\t\t\t});\n\t\t}\n\t}\n\n\tconst currentPath = new Set<string>();\n\tfor (let current = leafId; current; current = parents.get(current)) currentPath.add(current);\n\treturn raw.map((node) => ({ ...node, isCurrentPath: currentPath.has(node.entry.id) }));\n}\n\n/** Compact, keyboard-driven session tree browser. It only renders and delegates all state changes to its caller. */\nexport class TreeSelector implements Component, Focusable {\n\tfocused = false;\n\tprivate readonly options: TreeSelectorOptions;\n\tprivate readonly nodes: readonly FlatTreeNode[];\n\tprivate selectedIndex = 0;\n\n\tconstructor(options: TreeSelectorOptions) {\n\t\tthis.options = options;\n\t\tthis.nodes = flattenTree(options.nodes, options.leafId);\n\t\tconst selected = this.nodes.findIndex((node) => node.entry.id === options.leafId);\n\t\tif (selected >= 0) this.selectedIndex = selected;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tif (this.nodes.length === 0)\n\t\t\treturn new SelectionPanel({ emptyText: translate(this.options.locale, \"treeEmpty\"), total: 0 }).render(width);\n\n\t\tconst start = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.selectedIndex - Math.floor(MAX_VISIBLE_NODES / 2), this.nodes.length - MAX_VISIBLE_NODES),\n\t\t);\n\t\tconst end = Math.min(this.nodes.length, start + MAX_VISIBLE_NODES);\n\t\tconst rows: string[] = [];\n\t\tfor (let index = start; index < end; index += 1) {\n\t\t\tconst node = this.nodes[index];\n\t\t\tif (node) rows.push(this.renderNode(node));\n\t\t}\n\t\treturn new SelectionPanel({\n\t\t\trows,\n\t\t\tselectedIndex: this.selectedIndex - start,\n\t\t\tposition: this.selectedIndex + 1,\n\t\t\ttotal: this.nodes.length,\n\t\t\thint: this.actionHint(),\n\t\t}).render(width);\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (matchesKey(data, Key.up)) {\n\t\t\tthis.move(-1);\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, Key.down)) {\n\t\t\tthis.move(1);\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, Key.enter)) {\n\t\t\tthis.select(\"continue\");\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, Key.escape) || matchesKey(data, Key.ctrl(\"c\"))) {\n\t\t\tthis.options.onCancel?.();\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, \"e\")) {\n\t\t\tthis.select(\"edit\");\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, \"s\")) this.select(\"summarize\");\n\t}\n\n\tprivate renderNode(node: FlatTreeNode): string {\n\t\tconst prefix = this.renderPrefix(node);\n\t\tconst currentPath = node.isCurrentPath ? paint(CYAN, \"• \") : \" \";\n\t\tconst content = this.entryDisplay(node.entry);\n\t\treturn `${prefix}${currentPath}${content}`;\n\t}\n\n\tprivate renderPrefix(node: FlatTreeNode): string {\n\t\tconst levels: string[] = [];\n\t\tfor (let level = 0; level < node.indent; level += 1) {\n\t\t\tconst gutter = node.gutters.find((candidate) => candidate.level === level);\n\t\t\tif (gutter) {\n\t\t\t\tlevels.push(paint(DIM, gutter.continues ? \"│ \" : \" \"));\n\t\t\t} else if (node.showConnector && level === node.indent - 1) {\n\t\t\t\tlevels.push(paint(DIM, node.isLast ? \"└─ \" : \"├─ \"));\n\t\t\t} else {\n\t\t\t\tlevels.push(\" \");\n\t\t\t}\n\t\t}\n\t\treturn levels.join(\"\");\n\t}\n\n\tprivate entryDisplay(entry: SessionEntry): string {\n\t\tconst text = textContent(entry);\n\t\tif (entry.type === \"summary\") return `${paint(YELLOW, \"summary: \")}${text || paint(DIM, \"(empty)\")}`;\n\t\tif (entry.message.role === \"user\") return `${paint(CYAN, \"user: \")}${text || paint(DIM, \"(empty)\")}`;\n\t\tif (entry.message.role === \"assistant\") {\n\t\t\tif (text) return `${paint(GREEN, \"assistant: \")}${text}`;\n\t\t\tif (entry.message.stopReason === \"aborted\") return `${paint(GREEN, \"assistant: \")}${paint(DIM, \"(aborted)\")}`;\n\t\t\tif (entry.message.stopReason === \"error\") return `${paint(GREEN, \"assistant: \")}${paint(RED, \"(error)\")}`;\n\t\t\treturn `${paint(GREEN, \"assistant: \")}${paint(DIM, \"(no text)\")}`;\n\t\t}\n\t\treturn `${paint(DIM, `${entry.message.toolName}: `)}${text || paint(DIM, \"(no text)\")}`;\n\t}\n\n\tprivate actionHint(): string {\n\t\treturn `Enter ${translate(this.options.locale, \"treeContinue\")} · e ${translate(this.options.locale, \"treeEdit\")} · s ${translate(this.options.locale, \"treeSummarize\")} · Esc ${translate(this.options.locale, \"treeCancel\")}`;\n\t}\n\n\tprivate move(direction: -1 | 1): void {\n\t\tif (this.nodes.length === 0) return;\n\t\tthis.selectedIndex = (this.selectedIndex + direction + this.nodes.length) % this.nodes.length;\n\t}\n\n\tprivate select(action: \"continue\" | \"edit\" | \"summarize\"): void {\n\t\tconst entry = this.nodes[this.selectedIndex]?.entry;\n\t\tif (!entry) return;\n\t\tif (action === \"continue\") this.options.onContinue?.(entry);\n\t\telse if (action === \"edit\") this.options.onEdit?.(entry);\n\t\telse this.options.onSummarize?.(entry);\n\t}\n}\n"]}
1
+ {"version":3,"file":"tree-selector.js","sourceRoot":"","sources":["../../src/modes/tree-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,GAAG,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/F,OAAO,EAAe,SAAS,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,gBAAgB,GAAG,UAAU,CAAC;AACpC,MAAM,IAAI,GAAG,eAAe,CAAC;AAC7B,MAAM,KAAK,GAAG,gBAAgB,CAAC;AAC/B,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAChC,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAC7B,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAC7B,MAAM,iBAAiB,GAAG,EAAE,CAAC;AA2B7B,SAAS,KAAK,CAAC,KAAa,EAAE,IAAY;IACzC,8FAA8F;IAC9F,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,gBAAgB,EAAE,CAAC;AAC7C,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAChC,OAAO,KAAK;SACV,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC;SAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;AACV,CAAC;AAED,SAAS,WAAW,CAAC,KAAmB;IACvC,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/D,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,UAAU,CAAC,UAAU,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IA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AC,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;IACvO,CAAC;IAEO,IAAI,CAAC,SAAiB;QAC7B,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACpC,IAAI,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC/F,CAAC;IAEO,MAAM,CAAC,MAAyC;QACvD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC;QACpD,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,IAAI,MAAM,KAAK,UAAU;YAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC;aACvD,IAAI,MAAM,KAAK,MAAM;YAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;;YACpD,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACD","sourcesContent":["import { type Component, type Focusable, Key, matchesKey, SelectionPanel } from \"@di-code/tui\";\nimport type { SessionEntry, SessionTreeNode } from \"../core/session/types.ts\";\nimport { type Locale, translate } from \"../i18n.ts\";\n\nconst RESET_FOREGROUND = \"\\x1b[39m\";\nconst CYAN = \"\\x1b[38;5;45m\";\nconst GREEN = \"\\x1b[38;5;114m\";\nconst YELLOW = \"\\x1b[38;5;222m\";\nconst RED = \"\\x1b[38;5;210m\";\nconst DIM = \"\\x1b[38;5;245m\";\nconst MAX_VISIBLE_NODES = 12;\n\ninterface FlatTreeNode {\n\treadonly entry: SessionEntry;\n\t/** Visual indentation only grows where the session graph actually branches. */\n\treadonly indent: number;\n\treadonly showConnector: boolean;\n\treadonly isLast: boolean;\n\treadonly gutters: readonly TreeGutter[];\n\treadonly isCurrentPath: boolean;\n}\n\ninterface TreeGutter {\n\treadonly level: number;\n\treadonly continues: boolean;\n}\n\nexport interface TreeSelectorOptions {\n\treadonly nodes: readonly SessionTreeNode[];\n\treadonly leafId?: string;\n\treadonly locale: Locale;\n\tonContinue?(entry: SessionEntry): void;\n\tonEdit?(entry: SessionEntry): void;\n\tonSummarize?(entry: SessionEntry): void;\n\tonCancel?(): void;\n}\n\nfunction paint(color: string, text: string): string {\n\t// Reset only the foreground so a selected row keeps its background across coloured fragments.\n\treturn `${color}${text}${RESET_FOREGROUND}`;\n}\n\nfunction singleLine(value: string): string {\n\treturn value\n\t\t.replace(/[\\r\\n\\t]+/g, \" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n}\n\nfunction textContent(entry: SessionEntry): string {\n\tif (entry.type === \"summary\") return singleLine(entry.summary);\n\tif (entry.type === \"plugin\") return singleLine(`plugin:${entry.pluginId}`);\n\treturn singleLine(\n\t\tentry.message.content\n\t\t\t.filter((content) => content.type === \"text\")\n\t\t\t.map((content) => content.text)\n\t\t\t.join(\" \"),\n\t);\n}\n\nfunction flattenTree(nodes: readonly SessionTreeNode[], leafId: string | undefined): FlatTreeNode[] {\n\tconst parents = new Map<string, string>();\n\tconst raw: Array<Omit<FlatTreeNode, \"isCurrentPath\">> = [];\n\ttype PendingNode = {\n\t\treadonly node: SessionTreeNode;\n\t\treadonly indent: number;\n\t\treadonly justBranched: boolean;\n\t\treadonly showConnector: boolean;\n\t\treadonly isLast: boolean;\n\t\treadonly gutters: readonly TreeGutter[];\n\t};\n\tconst stack: PendingNode[] = [];\n\tconst multipleRoots = nodes.length > 1;\n\n\tfor (let index = nodes.length - 1; index >= 0; index -= 1) {\n\t\tconst node = nodes[index];\n\t\tif (!node) continue;\n\t\tstack.push({\n\t\t\tnode,\n\t\t\tindent: multipleRoots ? 1 : 0,\n\t\t\tjustBranched: multipleRoots,\n\t\t\tshowConnector: multipleRoots,\n\t\t\tisLast: index === nodes.length - 1,\n\t\t\tgutters: [],\n\t\t});\n\t}\n\n\twhile (stack.length > 0) {\n\t\tconst current = stack.pop();\n\t\tif (!current) continue;\n\t\traw.push({\n\t\t\tentry: current.node.entry,\n\t\t\tindent: current.indent,\n\t\t\tshowConnector: current.showConnector,\n\t\t\tisLast: current.isLast,\n\t\t\tgutters: current.gutters,\n\t\t});\n\t\tconst children = current.node.children;\n\t\tconst multipleChildren = children.length > 1;\n\t\tconst childIndent = multipleChildren\n\t\t\t? current.indent + 1\n\t\t\t: current.justBranched && current.indent > 0\n\t\t\t\t? current.indent + 1\n\t\t\t\t: current.indent;\n\t\tconst childGutters =\n\t\t\tcurrent.showConnector && current.indent > 0\n\t\t\t\t? [...current.gutters, { level: current.indent - 1, continues: !current.isLast }]\n\t\t\t\t: current.gutters;\n\t\tfor (let index = children.length - 1; index >= 0; index -= 1) {\n\t\t\tconst child = children[index];\n\t\t\tif (!child) continue;\n\t\t\tparents.set(child.entry.id, current.node.entry.id);\n\t\t\tstack.push({\n\t\t\t\tnode: child,\n\t\t\t\tindent: childIndent,\n\t\t\t\tjustBranched: multipleChildren,\n\t\t\t\tshowConnector: multipleChildren,\n\t\t\t\tisLast: index === children.length - 1,\n\t\t\t\tgutters: childGutters,\n\t\t\t});\n\t\t}\n\t}\n\n\tconst currentPath = new Set<string>();\n\tfor (let current = leafId; current; current = parents.get(current)) currentPath.add(current);\n\treturn raw.map((node) => ({ ...node, isCurrentPath: currentPath.has(node.entry.id) }));\n}\n\n/** Compact, keyboard-driven session tree browser. It only renders and delegates all state changes to its caller. */\nexport class TreeSelector implements Component, Focusable {\n\tfocused = false;\n\tprivate readonly options: TreeSelectorOptions;\n\tprivate readonly nodes: readonly FlatTreeNode[];\n\tprivate selectedIndex = 0;\n\n\tconstructor(options: TreeSelectorOptions) {\n\t\tthis.options = options;\n\t\tthis.nodes = flattenTree(options.nodes, options.leafId);\n\t\tconst selected = this.nodes.findIndex((node) => node.entry.id === options.leafId);\n\t\tif (selected >= 0) this.selectedIndex = selected;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tif (this.nodes.length === 0)\n\t\t\treturn new SelectionPanel({ emptyText: translate(this.options.locale, \"treeEmpty\"), total: 0 }).render(width);\n\n\t\tconst start = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.selectedIndex - Math.floor(MAX_VISIBLE_NODES / 2), this.nodes.length - MAX_VISIBLE_NODES),\n\t\t);\n\t\tconst end = Math.min(this.nodes.length, start + MAX_VISIBLE_NODES);\n\t\tconst rows: string[] = [];\n\t\tfor (let index = start; index < end; index += 1) {\n\t\t\tconst node = this.nodes[index];\n\t\t\tif (node) rows.push(this.renderNode(node));\n\t\t}\n\t\treturn new SelectionPanel({\n\t\t\trows,\n\t\t\tselectedIndex: this.selectedIndex - start,\n\t\t\tposition: this.selectedIndex + 1,\n\t\t\ttotal: this.nodes.length,\n\t\t\thint: this.actionHint(),\n\t\t}).render(width);\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (matchesKey(data, Key.up)) {\n\t\t\tthis.move(-1);\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, Key.down)) {\n\t\t\tthis.move(1);\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, Key.enter)) {\n\t\t\tthis.select(\"continue\");\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, Key.escape) || matchesKey(data, Key.ctrl(\"c\"))) {\n\t\t\tthis.options.onCancel?.();\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, \"e\")) {\n\t\t\tthis.select(\"edit\");\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, \"s\")) this.select(\"summarize\");\n\t}\n\n\tprivate renderNode(node: FlatTreeNode): string {\n\t\tconst prefix = this.renderPrefix(node);\n\t\tconst currentPath = node.isCurrentPath ? paint(CYAN, \"• \") : \" \";\n\t\tconst content = this.entryDisplay(node.entry);\n\t\treturn `${prefix}${currentPath}${content}`;\n\t}\n\n\tprivate renderPrefix(node: FlatTreeNode): string {\n\t\tconst levels: string[] = [];\n\t\tfor (let level = 0; level < node.indent; level += 1) {\n\t\t\tconst gutter = node.gutters.find((candidate) => candidate.level === level);\n\t\t\tif (gutter) {\n\t\t\t\tlevels.push(paint(DIM, gutter.continues ? \"│ \" : \" \"));\n\t\t\t} else if (node.showConnector && level === node.indent - 1) {\n\t\t\t\tlevels.push(paint(DIM, node.isLast ? \"└─ \" : \"├─ \"));\n\t\t\t} else {\n\t\t\t\tlevels.push(\" \");\n\t\t\t}\n\t\t}\n\t\treturn levels.join(\"\");\n\t}\n\n\tprivate entryDisplay(entry: SessionEntry): string {\n\t\tconst text = textContent(entry);\n\t\tif (entry.type === \"summary\") return `${paint(YELLOW, \"summary: \")}${text || paint(DIM, \"(empty)\")}`;\n\t\tif (entry.type === \"plugin\") return `${paint(DIM, \"plugin: \")}${text || paint(DIM, \"(empty)\")}`;\n\t\tif (entry.message.role === \"user\") return `${paint(CYAN, \"user: \")}${text || paint(DIM, \"(empty)\")}`;\n\t\tif (entry.message.role === \"assistant\") {\n\t\t\tif (text) return `${paint(GREEN, \"assistant: \")}${text}`;\n\t\t\tif (entry.message.stopReason === \"aborted\") return `${paint(GREEN, \"assistant: \")}${paint(DIM, \"(aborted)\")}`;\n\t\t\tif (entry.message.stopReason === \"error\") return `${paint(GREEN, \"assistant: \")}${paint(RED, \"(error)\")}`;\n\t\t\treturn `${paint(GREEN, \"assistant: \")}${paint(DIM, \"(no text)\")}`;\n\t\t}\n\t\treturn `${paint(DIM, `${entry.message.toolName}: `)}${text || paint(DIM, \"(no text)\")}`;\n\t}\n\n\tprivate actionHint(): string {\n\t\treturn `Enter ${translate(this.options.locale, \"treeContinue\")} · e ${translate(this.options.locale, \"treeEdit\")} · s ${translate(this.options.locale, \"treeSummarize\")} · Esc ${translate(this.options.locale, \"treeCancel\")}`;\n\t}\n\n\tprivate move(direction: -1 | 1): void {\n\t\tif (this.nodes.length === 0) return;\n\t\tthis.selectedIndex = (this.selectedIndex + direction + this.nodes.length) % this.nodes.length;\n\t}\n\n\tprivate select(action: \"continue\" | \"edit\" | \"summarize\"): void {\n\t\tconst entry = this.nodes[this.selectedIndex]?.entry;\n\t\tif (!entry) return;\n\t\tif (action === \"continue\") this.options.onContinue?.(entry);\n\t\telse if (action === \"edit\") this.options.onEdit?.(entry);\n\t\telse this.options.onSummarize?.(entry);\n\t}\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export { type PluginObservationService, pluginDumpComposition, pluginDumpCompositionKey, } from "./runtime/plugin-observability-entry.ts";
2
+ export declare const apiVersion: number | undefined;
3
+ export declare const name: string;
4
+ export declare const version: string | undefined;
5
+ export declare const apply: import("@di-code/plugin-runtime").PluginApply<unknown>;
6
+ //# sourceMappingURL=plugin-dump-composition.d.ts.map