open-multi-agent-kit 0.80.2 → 0.80.4

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 (2330) hide show
  1. package/CHANGELOG.md +4219 -431
  2. package/README.md +603 -101
  3. package/dist/bun/cli.d.ts +3 -0
  4. package/dist/bun/cli.d.ts.map +1 -0
  5. package/dist/bun/cli.js +9 -0
  6. package/dist/bun/cli.js.map +1 -0
  7. package/dist/bun/register-bedrock.d.ts +2 -0
  8. package/dist/bun/register-bedrock.d.ts.map +1 -0
  9. package/dist/bun/register-bedrock.js +4 -0
  10. package/dist/bun/register-bedrock.js.map +1 -0
  11. package/dist/bun/restore-sandbox-env.d.ts +13 -0
  12. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  13. package/dist/bun/restore-sandbox-env.js +32 -0
  14. package/dist/bun/restore-sandbox-env.js.map +1 -0
  15. package/dist/cli/args.d.ts +56 -0
  16. package/dist/cli/args.d.ts.map +1 -0
  17. package/dist/cli/args.js +371 -0
  18. package/dist/cli/args.js.map +1 -0
  19. package/dist/cli/config-selector.d.ts +14 -0
  20. package/dist/cli/config-selector.d.ts.map +1 -0
  21. package/dist/cli/config-selector.js +31 -0
  22. package/dist/cli/config-selector.js.map +1 -0
  23. package/dist/cli/file-processor.d.ts +15 -0
  24. package/dist/cli/file-processor.d.ts.map +1 -0
  25. package/dist/cli/file-processor.js +82 -0
  26. package/dist/cli/file-processor.js.map +1 -0
  27. package/dist/cli/initial-message.d.ts +18 -0
  28. package/dist/cli/initial-message.d.ts.map +1 -0
  29. package/dist/cli/initial-message.js +22 -0
  30. package/dist/cli/initial-message.js.map +1 -0
  31. package/dist/cli/list-models.d.ts +9 -0
  32. package/dist/cli/list-models.d.ts.map +1 -0
  33. package/dist/cli/list-models.js +98 -0
  34. package/dist/cli/list-models.js.map +1 -0
  35. package/dist/cli/session-picker.d.ts +9 -0
  36. package/dist/cli/session-picker.d.ts.map +1 -0
  37. package/dist/cli/session-picker.js +35 -0
  38. package/dist/cli/session-picker.js.map +1 -0
  39. package/dist/cli.d.ts +1 -0
  40. package/dist/cli.d.ts.map +1 -0
  41. package/dist/cli.js +17 -16
  42. package/dist/cli.js.map +1 -0
  43. package/dist/config.d.ts +92 -0
  44. package/dist/config.d.ts.map +1 -0
  45. package/dist/config.js +437 -0
  46. package/dist/config.js.map +1 -0
  47. package/dist/core/agent-session-runtime.d.ts +117 -0
  48. package/dist/core/agent-session-runtime.d.ts.map +1 -0
  49. package/dist/core/agent-session-runtime.js +300 -0
  50. package/dist/core/agent-session-runtime.js.map +1 -0
  51. package/dist/core/agent-session-services.d.ts +87 -0
  52. package/dist/core/agent-session-services.d.ts.map +1 -0
  53. package/dist/core/agent-session-services.js +119 -0
  54. package/dist/core/agent-session-services.js.map +1 -0
  55. package/dist/core/agent-session.d.ts +605 -0
  56. package/dist/core/agent-session.d.ts.map +1 -0
  57. package/dist/core/agent-session.js +2551 -0
  58. package/dist/core/agent-session.js.map +1 -0
  59. package/dist/core/auth-guidance.d.ts +5 -0
  60. package/dist/core/auth-guidance.d.ts.map +1 -0
  61. package/dist/core/auth-guidance.js +21 -0
  62. package/dist/core/auth-guidance.js.map +1 -0
  63. package/dist/core/auth-storage.d.ts +141 -0
  64. package/dist/core/auth-storage.d.ts.map +1 -0
  65. package/dist/core/auth-storage.js +443 -0
  66. package/dist/core/auth-storage.js.map +1 -0
  67. package/dist/core/bash-executor.d.ts +32 -0
  68. package/dist/core/bash-executor.d.ts.map +1 -0
  69. package/dist/core/bash-executor.js +141 -0
  70. package/dist/core/bash-executor.js.map +1 -0
  71. package/dist/core/compaction/branch-summarization.d.ts +90 -0
  72. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  73. package/dist/core/compaction/branch-summarization.js +249 -0
  74. package/dist/core/compaction/branch-summarization.js.map +1 -0
  75. package/dist/core/compaction/compaction.d.ts +136 -0
  76. package/dist/core/compaction/compaction.d.ts.map +1 -0
  77. package/dist/core/compaction/compaction.js +646 -0
  78. package/dist/core/compaction/compaction.js.map +1 -0
  79. package/dist/core/compaction/index.d.ts +7 -0
  80. package/dist/core/compaction/index.d.ts.map +1 -0
  81. package/dist/core/compaction/index.js +7 -0
  82. package/dist/core/compaction/index.js.map +1 -0
  83. package/dist/core/compaction/utils.d.ts +38 -0
  84. package/dist/core/compaction/utils.d.ts.map +1 -0
  85. package/dist/core/compaction/utils.js +153 -0
  86. package/dist/core/compaction/utils.js.map +1 -0
  87. package/dist/core/defaults.d.ts +3 -0
  88. package/dist/core/defaults.d.ts.map +1 -0
  89. package/dist/core/defaults.js +2 -0
  90. package/dist/core/defaults.js.map +1 -0
  91. package/dist/core/diagnostics.d.ts +15 -0
  92. package/dist/core/diagnostics.d.ts.map +1 -0
  93. package/dist/core/diagnostics.js +2 -0
  94. package/dist/core/diagnostics.js.map +1 -0
  95. package/dist/core/event-bus.d.ts +9 -0
  96. package/dist/core/event-bus.d.ts.map +1 -0
  97. package/dist/core/event-bus.js +25 -0
  98. package/dist/core/event-bus.js.map +1 -0
  99. package/dist/core/exec.d.ts +29 -0
  100. package/dist/core/exec.d.ts.map +1 -0
  101. package/dist/core/exec.js +79 -0
  102. package/dist/core/exec.js.map +1 -0
  103. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  104. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  105. package/dist/core/export-html/ansi-to-html.js +249 -0
  106. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  107. package/dist/core/export-html/index.d.ts +37 -0
  108. package/dist/core/export-html/index.d.ts.map +1 -0
  109. package/dist/core/export-html/index.js +226 -0
  110. package/dist/core/export-html/index.js.map +1 -0
  111. package/dist/core/export-html/template.css +1066 -0
  112. package/dist/core/export-html/template.html +55 -0
  113. package/dist/core/export-html/template.js +1866 -0
  114. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  115. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  116. package/dist/core/export-html/tool-renderer.js +108 -0
  117. package/dist/core/export-html/tool-renderer.js.map +1 -0
  118. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  119. package/dist/core/export-html/vendor/marked.min.js +6 -0
  120. package/dist/core/extensions/index.d.ts +12 -0
  121. package/dist/core/extensions/index.d.ts.map +1 -0
  122. package/dist/core/extensions/index.js +9 -0
  123. package/dist/core/extensions/index.js.map +1 -0
  124. package/dist/core/extensions/loader.d.ts +24 -0
  125. package/dist/core/extensions/loader.d.ts.map +1 -0
  126. package/dist/core/extensions/loader.js +502 -0
  127. package/dist/core/extensions/loader.js.map +1 -0
  128. package/dist/core/extensions/runner.d.ts +161 -0
  129. package/dist/core/extensions/runner.d.ts.map +1 -0
  130. package/dist/core/extensions/runner.js +842 -0
  131. package/dist/core/extensions/runner.js.map +1 -0
  132. package/dist/core/extensions/types.d.ts +1183 -0
  133. package/dist/core/extensions/types.d.ts.map +1 -0
  134. package/dist/core/extensions/types.js +45 -0
  135. package/dist/core/extensions/types.js.map +1 -0
  136. package/dist/core/extensions/wrapper.d.ts +20 -0
  137. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  138. package/dist/core/extensions/wrapper.js +22 -0
  139. package/dist/core/extensions/wrapper.js.map +1 -0
  140. package/dist/core/footer-data-provider.d.ts +59 -0
  141. package/dist/core/footer-data-provider.d.ts.map +1 -0
  142. package/dist/core/footer-data-provider.js +351 -0
  143. package/dist/core/footer-data-provider.js.map +1 -0
  144. package/dist/core/hooks/fail-closed.d.ts +7 -0
  145. package/dist/core/hooks/fail-closed.d.ts.map +1 -0
  146. package/dist/core/hooks/fail-closed.js +58 -0
  147. package/dist/core/hooks/fail-closed.js.map +1 -0
  148. package/dist/core/hooks/index.d.ts +3 -0
  149. package/dist/core/hooks/index.d.ts.map +1 -0
  150. package/dist/core/hooks/index.js +2 -0
  151. package/dist/core/hooks/index.js.map +1 -0
  152. package/dist/core/hooks/types.d.ts +28 -0
  153. package/dist/core/hooks/types.d.ts.map +1 -0
  154. package/dist/core/hooks/types.js +2 -0
  155. package/dist/core/hooks/types.js.map +1 -0
  156. package/dist/core/http-dispatcher.d.ts +21 -0
  157. package/dist/core/http-dispatcher.d.ts.map +1 -0
  158. package/dist/core/http-dispatcher.js +48 -0
  159. package/dist/core/http-dispatcher.js.map +1 -0
  160. package/dist/core/index.d.ts +12 -0
  161. package/dist/core/index.d.ts.map +1 -0
  162. package/dist/core/index.js +12 -0
  163. package/dist/core/index.js.map +1 -0
  164. package/dist/core/keybindings.d.ts +353 -0
  165. package/dist/core/keybindings.d.ts.map +1 -0
  166. package/dist/core/keybindings.js +295 -0
  167. package/dist/core/keybindings.js.map +1 -0
  168. package/dist/core/messages.d.ts +77 -0
  169. package/dist/core/messages.d.ts.map +1 -0
  170. package/dist/core/messages.js +123 -0
  171. package/dist/core/messages.js.map +1 -0
  172. package/dist/core/metrics-sampler.d.ts +57 -0
  173. package/dist/core/metrics-sampler.d.ts.map +1 -0
  174. package/dist/core/metrics-sampler.js +135 -0
  175. package/dist/core/metrics-sampler.js.map +1 -0
  176. package/dist/core/model-registry.d.ts +150 -0
  177. package/dist/core/model-registry.d.ts.map +1 -0
  178. package/dist/core/model-registry.js +784 -0
  179. package/dist/core/model-registry.js.map +1 -0
  180. package/dist/core/model-resolver.d.ts +110 -0
  181. package/dist/core/model-resolver.d.ts.map +1 -0
  182. package/dist/core/model-resolver.js +498 -0
  183. package/dist/core/model-resolver.js.map +1 -0
  184. package/dist/core/output-guard.d.ts +7 -0
  185. package/dist/core/output-guard.d.ts.map +1 -0
  186. package/dist/core/output-guard.js +89 -0
  187. package/dist/core/output-guard.js.map +1 -0
  188. package/dist/core/package-manager.d.ts +211 -0
  189. package/dist/core/package-manager.d.ts.map +1 -0
  190. package/dist/core/package-manager.js +2088 -0
  191. package/dist/core/package-manager.js.map +1 -0
  192. package/dist/core/prompt-templates.d.ts +52 -0
  193. package/dist/core/prompt-templates.d.ts.map +1 -0
  194. package/dist/core/prompt-templates.js +238 -0
  195. package/dist/core/prompt-templates.js.map +1 -0
  196. package/dist/core/provider-attribution.d.ts +4 -0
  197. package/dist/core/provider-attribution.d.ts.map +1 -0
  198. package/dist/core/provider-attribution.js +72 -0
  199. package/dist/core/provider-attribution.js.map +1 -0
  200. package/dist/core/provider-display-names.d.ts +2 -0
  201. package/dist/core/provider-display-names.d.ts.map +1 -0
  202. package/dist/core/provider-display-names.js +36 -0
  203. package/dist/core/provider-display-names.js.map +1 -0
  204. package/dist/core/resolve-config-value.d.ts +31 -0
  205. package/dist/core/resolve-config-value.d.ts.map +1 -0
  206. package/dist/core/resolve-config-value.js +249 -0
  207. package/dist/core/resolve-config-value.js.map +1 -0
  208. package/dist/core/resource-loader.d.ts +202 -0
  209. package/dist/core/resource-loader.d.ts.map +1 -0
  210. package/dist/core/resource-loader.js +759 -0
  211. package/dist/core/resource-loader.js.map +1 -0
  212. package/dist/core/sdk.d.ts +109 -0
  213. package/dist/core/sdk.d.ts.map +1 -0
  214. package/dist/core/sdk.js +265 -0
  215. package/dist/core/sdk.js.map +1 -0
  216. package/dist/core/session-cwd.d.ts +19 -0
  217. package/dist/core/session-cwd.d.ts.map +1 -0
  218. package/dist/core/session-cwd.js +38 -0
  219. package/dist/core/session-cwd.js.map +1 -0
  220. package/dist/core/session-manager.d.ts +332 -0
  221. package/dist/core/session-manager.d.ts.map +1 -0
  222. package/dist/core/session-manager.js +1246 -0
  223. package/dist/core/session-manager.js.map +1 -0
  224. package/dist/core/settings-manager.d.ts +269 -0
  225. package/dist/core/settings-manager.d.ts.map +1 -0
  226. package/dist/core/settings-manager.js +805 -0
  227. package/dist/core/settings-manager.js.map +1 -0
  228. package/dist/core/skills.d.ts +60 -0
  229. package/dist/core/skills.d.ts.map +1 -0
  230. package/dist/core/skills.js +387 -0
  231. package/dist/core/skills.js.map +1 -0
  232. package/dist/core/slash-commands.d.ts +14 -0
  233. package/dist/core/slash-commands.d.ts.map +1 -0
  234. package/dist/core/slash-commands.js +25 -0
  235. package/dist/core/slash-commands.js.map +1 -0
  236. package/dist/core/source-info.d.ts +18 -0
  237. package/dist/core/source-info.d.ts.map +1 -0
  238. package/dist/core/source-info.js +19 -0
  239. package/dist/core/source-info.js.map +1 -0
  240. package/dist/core/system-prompt.d.ts +28 -0
  241. package/dist/core/system-prompt.d.ts.map +1 -0
  242. package/dist/core/system-prompt.js +120 -0
  243. package/dist/core/system-prompt.js.map +1 -0
  244. package/dist/core/telemetry.d.ts +3 -0
  245. package/dist/core/telemetry.d.ts.map +1 -0
  246. package/dist/core/telemetry.js +9 -0
  247. package/dist/core/telemetry.js.map +1 -0
  248. package/dist/core/timings.d.ts +8 -0
  249. package/dist/core/timings.d.ts.map +1 -0
  250. package/dist/core/timings.js +31 -0
  251. package/dist/core/timings.js.map +1 -0
  252. package/dist/core/tools/bash.d.ts +68 -0
  253. package/dist/core/tools/bash.d.ts.map +1 -0
  254. package/dist/core/tools/bash.js +337 -0
  255. package/dist/core/tools/bash.js.map +1 -0
  256. package/dist/core/tools/edit-diff.d.ts +122 -0
  257. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  258. package/dist/core/tools/edit-diff.js +459 -0
  259. package/dist/core/tools/edit-diff.js.map +1 -0
  260. package/dist/core/tools/edit.d.ts +51 -0
  261. package/dist/core/tools/edit.d.ts.map +1 -0
  262. package/dist/core/tools/edit.js +284 -0
  263. package/dist/core/tools/edit.js.map +1 -0
  264. package/dist/core/tools/file-mutation-queue.d.ts +6 -0
  265. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  266. package/dist/core/tools/file-mutation-queue.js +52 -0
  267. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  268. package/dist/core/tools/find.d.ts +35 -0
  269. package/dist/core/tools/find.d.ts.map +1 -0
  270. package/dist/core/tools/find.js +297 -0
  271. package/dist/core/tools/find.js.map +1 -0
  272. package/dist/core/tools/grep.d.ts +37 -0
  273. package/dist/core/tools/grep.d.ts.map +1 -0
  274. package/dist/core/tools/grep.js +304 -0
  275. package/dist/core/tools/grep.js.map +1 -0
  276. package/dist/core/tools/index.d.ts +40 -0
  277. package/dist/core/tools/index.d.ts.map +1 -0
  278. package/dist/core/tools/index.js +112 -0
  279. package/dist/core/tools/index.js.map +1 -0
  280. package/dist/core/tools/ls.d.ts +37 -0
  281. package/dist/core/tools/ls.d.ts.map +1 -0
  282. package/dist/core/tools/ls.js +167 -0
  283. package/dist/core/tools/ls.js.map +1 -0
  284. package/dist/core/tools/output-accumulator.d.ts +52 -0
  285. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  286. package/dist/core/tools/output-accumulator.js +185 -0
  287. package/dist/core/tools/output-accumulator.js.map +1 -0
  288. package/dist/core/tools/path-utils.d.ts +10 -0
  289. package/dist/core/tools/path-utils.d.ts.map +1 -0
  290. package/dist/core/tools/path-utils.js +99 -0
  291. package/dist/core/tools/path-utils.js.map +1 -0
  292. package/dist/core/tools/read.d.ts +35 -0
  293. package/dist/core/tools/read.d.ts.map +1 -0
  294. package/dist/core/tools/read.js +289 -0
  295. package/dist/core/tools/read.js.map +1 -0
  296. package/dist/core/tools/render-utils.d.ts +24 -0
  297. package/dist/core/tools/render-utils.d.ts.map +1 -0
  298. package/dist/core/tools/render-utils.js +65 -0
  299. package/dist/core/tools/render-utils.js.map +1 -0
  300. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
  301. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  302. package/dist/core/tools/tool-definition-wrapper.js +34 -0
  303. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  304. package/dist/core/tools/truncate.d.ts +70 -0
  305. package/dist/core/tools/truncate.d.ts.map +1 -0
  306. package/dist/core/tools/truncate.js +215 -0
  307. package/dist/core/tools/truncate.js.map +1 -0
  308. package/dist/core/tools/write.d.ts +26 -0
  309. package/dist/core/tools/write.d.ts.map +1 -0
  310. package/dist/core/tools/write.js +197 -0
  311. package/dist/core/tools/write.js.map +1 -0
  312. package/dist/index.d.ts +31 -0
  313. package/dist/index.d.ts.map +1 -0
  314. package/dist/index.js +44 -0
  315. package/dist/index.js.map +1 -0
  316. package/dist/main.d.ts +12 -0
  317. package/dist/main.d.ts.map +1 -0
  318. package/dist/main.js +633 -0
  319. package/dist/main.js.map +1 -0
  320. package/dist/migrations.d.ts +33 -0
  321. package/dist/migrations.d.ts.map +1 -0
  322. package/dist/migrations.js +398 -0
  323. package/dist/migrations.js.map +1 -0
  324. package/dist/modes/index.d.ts +9 -0
  325. package/dist/modes/index.d.ts.map +1 -0
  326. package/dist/modes/index.js +8 -0
  327. package/dist/modes/index.js.map +1 -0
  328. package/dist/modes/interactive/assets/clankolas.png +0 -0
  329. package/dist/modes/interactive/components/armin.d.ts +34 -0
  330. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  331. package/dist/modes/interactive/components/armin.js +333 -0
  332. package/dist/modes/interactive/components/armin.js.map +1 -0
  333. package/dist/modes/interactive/components/assistant-message.d.ts +20 -0
  334. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  335. package/dist/modes/interactive/components/assistant-message.js +121 -0
  336. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  337. package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
  338. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  339. package/dist/modes/interactive/components/bash-execution.js +175 -0
  340. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  341. package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  342. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  343. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  344. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  345. package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  346. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  347. package/dist/modes/interactive/components/branch-summary-message.js +44 -0
  348. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  349. package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  350. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  351. package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
  352. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  353. package/dist/modes/interactive/components/config-selector.d.ts +71 -0
  354. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  355. package/dist/modes/interactive/components/config-selector.js +506 -0
  356. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  357. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  358. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  359. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  360. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  361. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  362. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  363. package/dist/modes/interactive/components/custom-editor.js +70 -0
  364. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  365. package/dist/modes/interactive/components/custom-message.d.ts +20 -0
  366. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  367. package/dist/modes/interactive/components/custom-message.js +79 -0
  368. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  369. package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
  370. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
  371. package/dist/modes/interactive/components/daxnuts.js +140 -0
  372. package/dist/modes/interactive/components/daxnuts.js.map +1 -0
  373. package/dist/modes/interactive/components/diff.d.ts +12 -0
  374. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  375. package/dist/modes/interactive/components/diff.js +133 -0
  376. package/dist/modes/interactive/components/diff.js.map +1 -0
  377. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  378. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  379. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  380. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  381. package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
  382. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
  383. package/dist/modes/interactive/components/earendil-announcement.js +40 -0
  384. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
  385. package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
  386. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  387. package/dist/modes/interactive/components/extension-editor.js +119 -0
  388. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  389. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  390. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  391. package/dist/modes/interactive/components/extension-input.js +61 -0
  392. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  393. package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
  394. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  395. package/dist/modes/interactive/components/extension-selector.js +83 -0
  396. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  397. package/dist/modes/interactive/components/footer.d.ts +34 -0
  398. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  399. package/dist/modes/interactive/components/footer.js +254 -0
  400. package/dist/modes/interactive/components/footer.js.map +1 -0
  401. package/dist/modes/interactive/components/index.d.ts +32 -0
  402. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  403. package/dist/modes/interactive/components/index.js +33 -0
  404. package/dist/modes/interactive/components/index.js.map +1 -0
  405. package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
  406. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  407. package/dist/modes/interactive/components/keybinding-hints.js +36 -0
  408. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  409. package/dist/modes/interactive/components/login-dialog.d.ts +51 -0
  410. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  411. package/dist/modes/interactive/components/login-dialog.js +174 -0
  412. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  413. package/dist/modes/interactive/components/model-selector.d.ts +47 -0
  414. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  415. package/dist/modes/interactive/components/model-selector.js +278 -0
  416. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  417. package/dist/modes/interactive/components/oauth-selector.d.ts +31 -0
  418. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  419. package/dist/modes/interactive/components/oauth-selector.js +165 -0
  420. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  421. package/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
  422. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  423. package/dist/modes/interactive/components/scoped-models-selector.js +290 -0
  424. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  425. package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  426. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  427. package/dist/modes/interactive/components/session-selector-search.js +155 -0
  428. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  429. package/dist/modes/interactive/components/session-selector.d.ts +96 -0
  430. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  431. package/dist/modes/interactive/components/session-selector.js +861 -0
  432. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  433. package/dist/modes/interactive/components/settings-selector.d.ts +69 -0
  434. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  435. package/dist/modes/interactive/components/settings-selector.js +390 -0
  436. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  437. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  438. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  439. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  440. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  441. package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  442. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  443. package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
  444. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  445. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  446. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  447. package/dist/modes/interactive/components/theme-selector.js +50 -0
  448. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  449. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  450. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  451. package/dist/modes/interactive/components/thinking-selector.js +51 -0
  452. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  453. package/dist/modes/interactive/components/tool-execution.d.ts +63 -0
  454. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  455. package/dist/modes/interactive/components/tool-execution.js +317 -0
  456. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  457. package/dist/modes/interactive/components/tree-selector.d.ts +89 -0
  458. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  459. package/dist/modes/interactive/components/tree-selector.js +1093 -0
  460. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  461. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  462. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  463. package/dist/modes/interactive/components/user-message-selector.js +114 -0
  464. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  465. package/dist/modes/interactive/components/user-message.d.ts +10 -0
  466. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  467. package/dist/modes/interactive/components/user-message.js +29 -0
  468. package/dist/modes/interactive/components/user-message.js.map +1 -0
  469. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  470. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  471. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  472. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  473. package/dist/modes/interactive/interactive-mode.d.ts +375 -0
  474. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  475. package/dist/modes/interactive/interactive-mode.js +4722 -0
  476. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  477. package/dist/modes/interactive/theme/dark.json +86 -0
  478. package/dist/modes/interactive/theme/light.json +85 -0
  479. package/dist/modes/interactive/theme/omk-control-grid-dark.json +93 -0
  480. package/dist/modes/interactive/theme/omk-control-light.json +87 -0
  481. package/dist/modes/interactive/theme/omk-control.json +87 -0
  482. package/dist/modes/interactive/theme/rust-forge.json +91 -0
  483. package/dist/modes/interactive/theme/theme-schema.json +335 -0
  484. package/dist/modes/interactive/theme/theme.d.ts +103 -0
  485. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  486. package/dist/modes/interactive/theme/theme.js +1070 -0
  487. package/dist/modes/interactive/theme/theme.js.map +1 -0
  488. package/dist/modes/print-mode.d.ts +28 -0
  489. package/dist/modes/print-mode.d.ts.map +1 -0
  490. package/dist/modes/print-mode.js +132 -0
  491. package/dist/modes/print-mode.js.map +1 -0
  492. package/dist/modes/rpc/jsonl.d.ts +17 -0
  493. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  494. package/dist/modes/rpc/jsonl.js +49 -0
  495. package/dist/modes/rpc/jsonl.js.map +1 -0
  496. package/dist/modes/rpc/rpc-client.d.ts +227 -0
  497. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  498. package/dist/modes/rpc/rpc-client.js +467 -0
  499. package/dist/modes/rpc/rpc-client.js.map +1 -0
  500. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  501. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  502. package/dist/modes/rpc/rpc-mode.js +616 -0
  503. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  504. package/dist/modes/rpc/rpc-types.d.ts +420 -0
  505. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  506. package/dist/modes/rpc/rpc-types.js +8 -0
  507. package/dist/modes/rpc/rpc-types.js.map +1 -0
  508. package/dist/package-manager-cli.d.ts +4 -0
  509. package/dist/package-manager-cli.d.ts.map +1 -0
  510. package/dist/package-manager-cli.js +515 -0
  511. package/dist/package-manager-cli.js.map +1 -0
  512. package/dist/utils/ansi.d.ts +2 -0
  513. package/dist/utils/ansi.d.ts.map +1 -0
  514. package/dist/utils/ansi.js +52 -0
  515. package/dist/utils/ansi.js.map +1 -0
  516. package/dist/utils/changelog.d.ts +21 -0
  517. package/dist/utils/changelog.d.ts.map +1 -0
  518. package/dist/utils/changelog.js +87 -0
  519. package/dist/utils/changelog.js.map +1 -0
  520. package/dist/utils/child-process.d.ts +15 -0
  521. package/dist/utils/child-process.d.ts.map +1 -0
  522. package/dist/utils/child-process.js +88 -0
  523. package/dist/utils/child-process.js.map +1 -0
  524. package/dist/utils/clipboard-image.d.ts +11 -0
  525. package/dist/utils/clipboard-image.d.ts.map +1 -0
  526. package/dist/utils/clipboard-image.js +249 -0
  527. package/dist/utils/clipboard-image.js.map +1 -0
  528. package/dist/utils/clipboard-native.d.ts +10 -0
  529. package/dist/utils/clipboard-native.d.ts.map +1 -0
  530. package/dist/utils/clipboard-native.js +20 -0
  531. package/dist/utils/clipboard-native.js.map +1 -0
  532. package/dist/utils/clipboard.d.ts +2 -0
  533. package/dist/utils/clipboard.d.ts.map +1 -0
  534. package/dist/utils/clipboard.js +117 -0
  535. package/dist/utils/clipboard.js.map +1 -0
  536. package/dist/utils/deprecation.d.ts +4 -0
  537. package/dist/utils/deprecation.d.ts.map +1 -0
  538. package/dist/utils/deprecation.js +13 -0
  539. package/dist/utils/deprecation.js.map +1 -0
  540. package/dist/utils/exif-orientation.d.ts +5 -0
  541. package/dist/utils/exif-orientation.d.ts.map +1 -0
  542. package/dist/utils/exif-orientation.js +158 -0
  543. package/dist/utils/exif-orientation.js.map +1 -0
  544. package/dist/utils/frontmatter.d.ts +8 -0
  545. package/dist/utils/frontmatter.d.ts.map +1 -0
  546. package/dist/utils/frontmatter.js +26 -0
  547. package/dist/utils/frontmatter.js.map +1 -0
  548. package/dist/utils/fs-watch.d.ts +5 -0
  549. package/dist/utils/fs-watch.d.ts.map +1 -0
  550. package/dist/utils/fs-watch.js +25 -0
  551. package/dist/utils/fs-watch.js.map +1 -0
  552. package/dist/utils/git.d.ts +26 -0
  553. package/dist/utils/git.d.ts.map +1 -0
  554. package/dist/utils/git.js +195 -0
  555. package/dist/utils/git.js.map +1 -0
  556. package/dist/utils/html.d.ts +7 -0
  557. package/dist/utils/html.d.ts.map +1 -0
  558. package/dist/utils/html.js +40 -0
  559. package/dist/utils/html.js.map +1 -0
  560. package/dist/utils/image-convert.d.ts +9 -0
  561. package/dist/utils/image-convert.d.ts.map +1 -0
  562. package/dist/utils/image-convert.js +39 -0
  563. package/dist/utils/image-convert.js.map +1 -0
  564. package/dist/utils/image-resize-core.d.ts +30 -0
  565. package/dist/utils/image-resize-core.d.ts.map +1 -0
  566. package/dist/utils/image-resize-core.js +124 -0
  567. package/dist/utils/image-resize-core.js.map +1 -0
  568. package/dist/utils/image-resize-worker.d.ts +2 -0
  569. package/dist/utils/image-resize-worker.d.ts.map +1 -0
  570. package/dist/utils/image-resize-worker.js +31 -0
  571. package/dist/utils/image-resize-worker.js.map +1 -0
  572. package/dist/utils/image-resize.d.ts +16 -0
  573. package/dist/utils/image-resize.d.ts.map +1 -0
  574. package/dist/utils/image-resize.js +97 -0
  575. package/dist/utils/image-resize.js.map +1 -0
  576. package/dist/utils/json.d.ts +3 -0
  577. package/dist/utils/json.d.ts.map +1 -0
  578. package/dist/utils/json.js +7 -0
  579. package/dist/utils/json.js.map +1 -0
  580. package/dist/utils/mime.d.ts +3 -0
  581. package/dist/utils/mime.d.ts.map +1 -0
  582. package/dist/utils/mime.js +69 -0
  583. package/dist/utils/mime.js.map +1 -0
  584. package/dist/utils/open-browser.d.ts +9 -0
  585. package/dist/utils/open-browser.d.ts.map +1 -0
  586. package/dist/utils/open-browser.js +22 -0
  587. package/dist/utils/open-browser.js.map +1 -0
  588. package/dist/utils/paths.d.ts +31 -0
  589. package/dist/utils/paths.d.ts.map +1 -0
  590. package/dist/utils/paths.js +92 -0
  591. package/dist/utils/paths.js.map +1 -0
  592. package/dist/utils/photon.d.ts +21 -0
  593. package/dist/utils/photon.d.ts.map +1 -0
  594. package/dist/utils/photon.js +121 -0
  595. package/dist/utils/photon.js.map +1 -0
  596. package/dist/utils/pi-user-agent.d.ts +2 -0
  597. package/dist/utils/pi-user-agent.d.ts.map +1 -0
  598. package/dist/utils/pi-user-agent.js +5 -0
  599. package/dist/utils/pi-user-agent.js.map +1 -0
  600. package/dist/utils/shell.d.ts +30 -0
  601. package/dist/utils/shell.d.ts.map +1 -0
  602. package/dist/utils/shell.js +195 -0
  603. package/dist/utils/shell.js.map +1 -0
  604. package/dist/utils/sleep.d.ts +5 -0
  605. package/dist/utils/sleep.d.ts.map +1 -0
  606. package/dist/utils/sleep.js +17 -0
  607. package/dist/utils/sleep.js.map +1 -0
  608. package/dist/utils/syntax-highlight.d.ts +12 -0
  609. package/dist/utils/syntax-highlight.d.ts.map +1 -0
  610. package/dist/utils/syntax-highlight.js +118 -0
  611. package/dist/utils/syntax-highlight.js.map +1 -0
  612. package/dist/utils/tools-manager.d.ts +3 -0
  613. package/dist/utils/tools-manager.d.ts.map +1 -0
  614. package/dist/utils/tools-manager.js +328 -0
  615. package/dist/utils/tools-manager.js.map +1 -0
  616. package/dist/utils/version-check.d.ts +15 -0
  617. package/dist/utils/version-check.d.ts.map +1 -0
  618. package/dist/utils/version-check.js +86 -0
  619. package/dist/utils/version-check.js.map +1 -0
  620. package/dist/utils/windows-self-update.d.ts +3 -0
  621. package/dist/utils/windows-self-update.d.ts.map +1 -0
  622. package/dist/utils/windows-self-update.js +77 -0
  623. package/dist/utils/windows-self-update.js.map +1 -0
  624. package/docs/compaction.md +394 -0
  625. package/docs/containerization.md +111 -0
  626. package/docs/custom-provider.md +736 -0
  627. package/docs/development.md +71 -0
  628. package/docs/docs.json +152 -0
  629. package/docs/extensions.md +2627 -0
  630. package/docs/images/doom-extension.png +0 -0
  631. package/docs/images/exy.png +0 -0
  632. package/docs/images/interactive-mode.png +0 -0
  633. package/docs/images/tree-view.png +0 -0
  634. package/docs/index.md +75 -0
  635. package/docs/json.md +82 -0
  636. package/docs/keybindings.md +197 -0
  637. package/docs/models.md +493 -0
  638. package/docs/packages.md +226 -0
  639. package/docs/prompt-templates.md +88 -0
  640. package/docs/providers.md +256 -0
  641. package/docs/quickstart.md +165 -0
  642. package/docs/rpc.md +1408 -0
  643. package/docs/sdk.md +1137 -0
  644. package/docs/session-format.md +412 -0
  645. package/docs/sessions.md +145 -0
  646. package/docs/settings.md +281 -0
  647. package/docs/shell-aliases.md +13 -0
  648. package/docs/skills.md +231 -0
  649. package/docs/terminal-setup.md +114 -0
  650. package/docs/termux.md +127 -0
  651. package/docs/themes.md +297 -0
  652. package/docs/tmux.md +61 -0
  653. package/docs/tui.md +927 -0
  654. package/docs/usage.md +288 -0
  655. package/docs/windows.md +17 -0
  656. package/examples/README.md +25 -0
  657. package/examples/extensions/README.md +210 -0
  658. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  659. package/examples/extensions/bash-spawn-hook.ts +30 -0
  660. package/examples/extensions/bookmark.ts +50 -0
  661. package/examples/extensions/border-status-editor.ts +145 -0
  662. package/examples/extensions/built-in-tool-renderer.ts +249 -0
  663. package/examples/extensions/claude-rules.ts +86 -0
  664. package/examples/extensions/commands.ts +72 -0
  665. package/examples/extensions/confirm-destructive.ts +59 -0
  666. package/examples/extensions/custom-compaction.ts +127 -0
  667. package/examples/extensions/custom-footer.ts +64 -0
  668. package/examples/extensions/custom-header.ts +73 -0
  669. package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
  670. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  671. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  672. package/examples/extensions/custom-provider-gitlab-duo/index.ts +400 -0
  673. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  674. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  675. package/examples/extensions/dirty-repo-guard.ts +56 -0
  676. package/examples/extensions/doom-overlay/README.md +46 -0
  677. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  678. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  679. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  680. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  681. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  682. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  683. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  684. package/examples/extensions/doom-overlay/index.ts +74 -0
  685. package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  686. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  687. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  688. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  689. package/examples/extensions/dynamic-resources/index.ts +15 -0
  690. package/examples/extensions/dynamic-tools.ts +74 -0
  691. package/examples/extensions/event-bus.ts +43 -0
  692. package/examples/extensions/file-trigger.ts +41 -0
  693. package/examples/extensions/git-checkpoint.ts +53 -0
  694. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  695. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  696. package/examples/extensions/gondolin/index.ts +531 -0
  697. package/examples/extensions/gondolin/package-lock.json +185 -0
  698. package/examples/extensions/gondolin/package.json +19 -0
  699. package/examples/extensions/handoff.ts +191 -0
  700. package/examples/extensions/hello.ts +26 -0
  701. package/examples/extensions/hidden-thinking-label.ts +53 -0
  702. package/examples/extensions/inline-bash.ts +94 -0
  703. package/examples/extensions/input-transform-streaming.ts +39 -0
  704. package/examples/extensions/input-transform.ts +43 -0
  705. package/examples/extensions/interactive-shell.ts +196 -0
  706. package/examples/extensions/mac-system-theme.ts +47 -0
  707. package/examples/extensions/message-renderer.ts +59 -0
  708. package/examples/extensions/minimal-mode.ts +426 -0
  709. package/examples/extensions/modal-editor.ts +85 -0
  710. package/examples/extensions/model-status.ts +31 -0
  711. package/examples/extensions/notify.ts +55 -0
  712. package/examples/extensions/overlay-qa-tests.ts +1450 -0
  713. package/examples/extensions/overlay-test.ts +153 -0
  714. package/examples/extensions/permission-gate.ts +34 -0
  715. package/examples/extensions/pirate.ts +47 -0
  716. package/examples/extensions/plan-mode/README.md +65 -0
  717. package/examples/extensions/plan-mode/index.ts +340 -0
  718. package/examples/extensions/plan-mode/utils.ts +168 -0
  719. package/examples/extensions/preset.ts +430 -0
  720. package/examples/extensions/prompt-customizer.ts +97 -0
  721. package/examples/extensions/protected-paths.ts +30 -0
  722. package/examples/extensions/provider-payload.ts +18 -0
  723. package/examples/extensions/qna.ts +122 -0
  724. package/examples/extensions/question.ts +264 -0
  725. package/examples/extensions/questionnaire.ts +427 -0
  726. package/examples/extensions/rainbow-editor.ts +88 -0
  727. package/examples/extensions/reload-runtime.ts +37 -0
  728. package/examples/extensions/rpc-demo.ts +118 -0
  729. package/examples/extensions/sandbox/index.ts +321 -0
  730. package/examples/extensions/sandbox/package-lock.json +92 -0
  731. package/examples/extensions/sandbox/package.json +19 -0
  732. package/examples/extensions/send-user-message.ts +97 -0
  733. package/examples/extensions/session-name.ts +27 -0
  734. package/examples/extensions/shutdown-command.ts +63 -0
  735. package/examples/extensions/snake.ts +343 -0
  736. package/examples/extensions/space-invaders.ts +560 -0
  737. package/examples/extensions/ssh.ts +220 -0
  738. package/examples/extensions/status-line.ts +32 -0
  739. package/examples/extensions/structured-output.ts +65 -0
  740. package/examples/extensions/subagent/README.md +175 -0
  741. package/examples/extensions/subagent/agents/planner.md +37 -0
  742. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  743. package/examples/extensions/subagent/agents/scout.md +50 -0
  744. package/examples/extensions/subagent/agents/worker.md +24 -0
  745. package/examples/extensions/subagent/agents.ts +126 -0
  746. package/examples/extensions/subagent/index.ts +1009 -0
  747. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  748. package/examples/extensions/subagent/prompts/implement.md +10 -0
  749. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  750. package/examples/extensions/summarize.ts +206 -0
  751. package/examples/extensions/system-prompt-header.ts +17 -0
  752. package/examples/extensions/tic-tac-toe.ts +1008 -0
  753. package/examples/extensions/timed-confirm.ts +70 -0
  754. package/examples/extensions/titlebar-spinner.ts +58 -0
  755. package/examples/extensions/todo.ts +297 -0
  756. package/examples/extensions/tool-override.ts +144 -0
  757. package/examples/extensions/tools.ts +146 -0
  758. package/examples/extensions/trigger-compact.ts +50 -0
  759. package/examples/extensions/truncated-tool.ts +195 -0
  760. package/examples/extensions/widget-placement.ts +9 -0
  761. package/examples/extensions/with-deps/index.ts +32 -0
  762. package/examples/extensions/with-deps/package-lock.json +31 -0
  763. package/examples/extensions/with-deps/package.json +22 -0
  764. package/examples/extensions/working-indicator.ts +123 -0
  765. package/examples/extensions/working-message-test.ts +25 -0
  766. package/examples/rpc-extension-ui.ts +640 -0
  767. package/examples/sdk/01-minimal.ts +26 -0
  768. package/examples/sdk/02-custom-model.ts +53 -0
  769. package/examples/sdk/03-custom-prompt.ts +70 -0
  770. package/examples/sdk/04-skills.ts +55 -0
  771. package/examples/sdk/05-tools.ts +48 -0
  772. package/examples/sdk/06-extensions.ts +94 -0
  773. package/examples/sdk/07-context-files.ts +42 -0
  774. package/examples/sdk/08-prompt-templates.ts +51 -0
  775. package/examples/sdk/09-api-keys-and-oauth.ts +52 -0
  776. package/examples/sdk/10-settings.ts +53 -0
  777. package/examples/sdk/11-sessions.ts +52 -0
  778. package/examples/sdk/12-full-control.ts +77 -0
  779. package/examples/sdk/13-session-runtime.ts +67 -0
  780. package/examples/sdk/README.md +144 -0
  781. package/package.json +104 -200
  782. package/AGENTS.md +0 -679
  783. package/CLAUDE.md +0 -110
  784. package/DESIGN.md +0 -358
  785. package/GEMINI.md +0 -8
  786. package/LICENSE +0 -21
  787. package/MATURITY.md +0 -76
  788. package/ROADMAP.md +0 -127
  789. package/SECURITY.md +0 -83
  790. package/WORKER_MANIFEST.md +0 -35
  791. package/dist/adapters/commandcode/commandcode-cli-adapter.d.ts +0 -10
  792. package/dist/adapters/commandcode/commandcode-cli-adapter.js +0 -57
  793. package/dist/adapters/kimi/ascii-art.d.ts +0 -1
  794. package/dist/adapters/kimi/ascii-art.js +0 -23
  795. package/dist/adapters/kimi/banner.d.ts +0 -53
  796. package/dist/adapters/kimi/banner.js +0 -284
  797. package/dist/adapters/kimi/bug-filter.d.ts +0 -15
  798. package/dist/adapters/kimi/bug-filter.js +0 -150
  799. package/dist/adapters/kimi/capability.d.ts +0 -25
  800. package/dist/adapters/kimi/capability.js +0 -68
  801. package/dist/adapters/kimi/continue-prompt-guard.d.ts +0 -20
  802. package/dist/adapters/kimi/continue-prompt-guard.js +0 -70
  803. package/dist/adapters/kimi/isolated-home.d.ts +0 -21
  804. package/dist/adapters/kimi/isolated-home.js +0 -270
  805. package/dist/adapters/kimi/runner.d.ts +0 -71
  806. package/dist/adapters/kimi/runner.js +0 -1084
  807. package/dist/adapters/kimi/simple-art.d.ts +0 -1
  808. package/dist/adapters/kimi/simple-art.js +0 -1
  809. package/dist/adapters/kimi/statusline.d.ts +0 -26
  810. package/dist/adapters/kimi/statusline.js +0 -142
  811. package/dist/adapters/kimi/usage.d.ts +0 -52
  812. package/dist/adapters/kimi/usage.js +0 -481
  813. package/dist/adapters/kimi/wire-client.d.ts +0 -142
  814. package/dist/adapters/kimi/wire-client.js +0 -725
  815. package/dist/adapters/kimi/wire-protocol-types.d.ts +0 -549
  816. package/dist/adapters/kimi/wire-protocol-types.js +0 -59
  817. package/dist/adapters/opencode/opencode-cli-adapter.d.ts +0 -9
  818. package/dist/adapters/opencode/opencode-cli-adapter.js +0 -43
  819. package/dist/awareness/classifiers/browser-console-classifier.d.ts +0 -3
  820. package/dist/awareness/classifiers/browser-console-classifier.js +0 -47
  821. package/dist/awareness/classifiers/evidence-gap-classifier.d.ts +0 -3
  822. package/dist/awareness/classifiers/evidence-gap-classifier.js +0 -31
  823. package/dist/awareness/classifiers/stalled-run-classifier.d.ts +0 -2
  824. package/dist/awareness/classifiers/stalled-run-classifier.js +0 -24
  825. package/dist/awareness/notice-store.d.ts +0 -6
  826. package/dist/awareness/notice-store.js +0 -91
  827. package/dist/awareness/notice.d.ts +0 -17
  828. package/dist/awareness/notice.js +0 -1
  829. package/dist/awareness/noticer-engine.d.ts +0 -42
  830. package/dist/awareness/noticer-engine.js +0 -63
  831. package/dist/awareness/router.d.ts +0 -6
  832. package/dist/awareness/router.js +0 -46
  833. package/dist/benchmark/contracts.d.ts +0 -116
  834. package/dist/benchmark/contracts.js +0 -6
  835. package/dist/benchmark/fixtures.d.ts +0 -11
  836. package/dist/benchmark/fixtures.js +0 -124
  837. package/dist/benchmark/harness.d.ts +0 -13
  838. package/dist/benchmark/harness.js +0 -191
  839. package/dist/benchmark/shadow-mode.d.ts +0 -17
  840. package/dist/benchmark/shadow-mode.js +0 -95
  841. package/dist/brand/matrix-rain.d.ts +0 -15
  842. package/dist/brand/matrix-rain.js +0 -132
  843. package/dist/brand/night-city.theme.json +0 -178
  844. package/dist/brand/omk-matrix-art.d.ts +0 -1
  845. package/dist/brand/omk-matrix-art.js +0 -10
  846. package/dist/brand/omk-simple-art.d.ts +0 -7
  847. package/dist/brand/omk-simple-art.js +0 -13
  848. package/dist/brand/palette.d.ts +0 -90
  849. package/dist/brand/palette.js +0 -129
  850. package/dist/brand/rust-forge.theme.json +0 -216
  851. package/dist/brand/theme-compiled.d.ts +0 -61
  852. package/dist/brand/theme-compiled.js +0 -241
  853. package/dist/brand/theme.d.ts +0 -41
  854. package/dist/brand/theme.js +0 -275
  855. package/dist/browser/browser-feedback.d.ts +0 -10
  856. package/dist/browser/browser-feedback.js +0 -84
  857. package/dist/browser/browser-observer.d.ts +0 -21
  858. package/dist/browser/browser-observer.js +0 -159
  859. package/dist/browser/browser-session.d.ts +0 -26
  860. package/dist/browser/browser-session.js +0 -63
  861. package/dist/cli/command-registry.d.ts +0 -2
  862. package/dist/cli/command-registry.js +0 -20
  863. package/dist/cli/input/argv-parser.d.ts +0 -16
  864. package/dist/cli/input/argv-parser.js +0 -50
  865. package/dist/cli/input/command-envelope.d.ts +0 -16
  866. package/dist/cli/input/command-envelope.js +0 -64
  867. package/dist/cli/input/config-loader.d.ts +0 -16
  868. package/dist/cli/input/config-loader.js +0 -48
  869. package/dist/cli/input/index.d.ts +0 -8
  870. package/dist/cli/input/index.js +0 -8
  871. package/dist/cli/input/input-resolver.d.ts +0 -13
  872. package/dist/cli/input/input-resolver.js +0 -50
  873. package/dist/cli/input/validator.d.ts +0 -10
  874. package/dist/cli/input/validator.js +0 -37
  875. package/dist/cli/main.d.ts +0 -4
  876. package/dist/cli/main.js +0 -34
  877. package/dist/cli/output/error-renderer.d.ts +0 -10
  878. package/dist/cli/output/error-renderer.js +0 -68
  879. package/dist/cli/output/hash.d.ts +0 -1
  880. package/dist/cli/output/hash.js +0 -10
  881. package/dist/cli/output/index.d.ts +0 -9
  882. package/dist/cli/output/index.js +0 -9
  883. package/dist/cli/output/json-renderer.d.ts +0 -7
  884. package/dist/cli/output/json-renderer.js +0 -35
  885. package/dist/cli/output/markdown-renderer.d.ts +0 -5
  886. package/dist/cli/output/markdown-renderer.js +0 -86
  887. package/dist/cli/output/nlp-renderer.d.ts +0 -7
  888. package/dist/cli/output/nlp-renderer.js +0 -96
  889. package/dist/cli/output/output-router.d.ts +0 -5
  890. package/dist/cli/output/output-router.js +0 -33
  891. package/dist/cli/register-awareness-commands.d.ts +0 -2
  892. package/dist/cli/register-awareness-commands.js +0 -133
  893. package/dist/cli/register-basic-commands.d.ts +0 -2
  894. package/dist/cli/register-basic-commands.js +0 -489
  895. package/dist/cli/register-integration-commands.d.ts +0 -2
  896. package/dist/cli/register-integration-commands.js +0 -59
  897. package/dist/cli/register-mcp-dag-cron-screenshot-commands.d.ts +0 -2
  898. package/dist/cli/register-mcp-dag-cron-screenshot-commands.js +0 -275
  899. package/dist/cli/register-openai-codex-commands.d.ts +0 -2
  900. package/dist/cli/register-openai-codex-commands.js +0 -55
  901. package/dist/cli/register-provider-commands.d.ts +0 -2
  902. package/dist/cli/register-provider-commands.js +0 -244
  903. package/dist/cli/register-spec-agent-goal-commands.d.ts +0 -2
  904. package/dist/cli/register-spec-agent-goal-commands.js +0 -486
  905. package/dist/cli/register-tool-commands.d.ts +0 -2
  906. package/dist/cli/register-tool-commands.js +0 -202
  907. package/dist/cli/register-workflow-commands.d.ts +0 -2
  908. package/dist/cli/register-workflow-commands.js +0 -158
  909. package/dist/cli/registry/core.d.ts +0 -2
  910. package/dist/cli/registry/core.js +0 -27
  911. package/dist/cli/registry/session.d.ts +0 -2
  912. package/dist/cli/registry/session.js +0 -137
  913. package/dist/cli/registry/system.d.ts +0 -2
  914. package/dist/cli/registry/system.js +0 -95
  915. package/dist/cli/registry/tooling.d.ts +0 -2
  916. package/dist/cli/registry/tooling.js +0 -112
  917. package/dist/cli/registry/visual.d.ts +0 -2
  918. package/dist/cli/registry/visual.js +0 -91
  919. package/dist/cli/release-promotion-gate.d.ts +0 -21
  920. package/dist/cli/release-promotion-gate.js +0 -93
  921. package/dist/cli/root.d.ts +0 -12
  922. package/dist/cli/root.js +0 -121
  923. package/dist/cli/runtime/capability-selector.d.ts +0 -18
  924. package/dist/cli/runtime/capability-selector.js +0 -208
  925. package/dist/cli/runtime/cli-runtime.d.ts +0 -10
  926. package/dist/cli/runtime/cli-runtime.js +0 -35
  927. package/dist/cli/runtime/cli-writer.d.ts +0 -18
  928. package/dist/cli/runtime/cli-writer.js +0 -87
  929. package/dist/cli/runtime/command-bus.d.ts +0 -45
  930. package/dist/cli/runtime/command-bus.js +0 -145
  931. package/dist/cli/runtime/event-bus.d.ts +0 -12
  932. package/dist/cli/runtime/event-bus.js +0 -31
  933. package/dist/cli/runtime/generic-provider-adapter.d.ts +0 -24
  934. package/dist/cli/runtime/generic-provider-adapter.js +0 -38
  935. package/dist/cli/runtime/index.d.ts +0 -17
  936. package/dist/cli/runtime/index.js +0 -18
  937. package/dist/cli/runtime/intent-classifier.d.ts +0 -16
  938. package/dist/cli/runtime/intent-classifier.js +0 -113
  939. package/dist/cli/runtime/plan-controller.d.ts +0 -7
  940. package/dist/cli/runtime/plan-controller.js +0 -29
  941. package/dist/cli/runtime/provider-adapter-registry.d.ts +0 -32
  942. package/dist/cli/runtime/provider-adapter-registry.js +0 -60
  943. package/dist/cli/runtime/provider-event-normalizer.d.ts +0 -19
  944. package/dist/cli/runtime/provider-event-normalizer.js +0 -150
  945. package/dist/cli/runtime/run-controller.d.ts +0 -7
  946. package/dist/cli/runtime/run-controller.js +0 -30
  947. package/dist/cli/runtime/runtime-sidecar.d.ts +0 -17
  948. package/dist/cli/runtime/runtime-sidecar.js +0 -138
  949. package/dist/cli/runtime/task-controller.d.ts +0 -7
  950. package/dist/cli/runtime/task-controller.js +0 -29
  951. package/dist/cli/runtime/types.d.ts +0 -312
  952. package/dist/cli/runtime/types.js +0 -6
  953. package/dist/cli/theme/index.d.ts +0 -18
  954. package/dist/cli/theme/index.js +0 -11
  955. package/dist/cli/theme/oklab-quantize.d.ts +0 -29
  956. package/dist/cli/theme/oklab-quantize.js +0 -105
  957. package/dist/cli/theme/render-table.d.ts +0 -59
  958. package/dist/cli/theme/render-table.js +0 -112
  959. package/dist/cli/theme/status-frame.d.ts +0 -10
  960. package/dist/cli/theme/status-frame.js +0 -22
  961. package/dist/cli/theme/terminal-capability.d.ts +0 -23
  962. package/dist/cli/theme/terminal-capability.js +0 -104
  963. package/dist/cli/theme/theme-doc.d.ts +0 -22
  964. package/dist/cli/theme/theme-doc.js +0 -97
  965. package/dist/cli/theme/theme-registry.d.ts +0 -25
  966. package/dist/cli/theme/theme-registry.js +0 -445
  967. package/dist/cli/theme/theme-resolver.d.ts +0 -12
  968. package/dist/cli/theme/theme-resolver.js +0 -38
  969. package/dist/cli/theme/tier-explain.d.ts +0 -21
  970. package/dist/cli/theme/tier-explain.js +0 -60
  971. package/dist/cli/ui/event.d.ts +0 -66
  972. package/dist/cli/ui/event.js +0 -1
  973. package/dist/cli/ui/green-rain-renderer.d.ts +0 -17
  974. package/dist/cli/ui/green-rain-renderer.js +0 -97
  975. package/dist/cli/ui/neon-grid-renderer.d.ts +0 -25
  976. package/dist/cli/ui/neon-grid-renderer.js +0 -170
  977. package/dist/cli/ui/plain-renderer.d.ts +0 -37
  978. package/dist/cli/ui/plain-renderer.js +0 -162
  979. package/dist/cli/ui/renderer.d.ts +0 -7
  980. package/dist/cli/ui/renderer.js +0 -1
  981. package/dist/cli/ui/rich-renderer.d.ts +0 -32
  982. package/dist/cli/ui/rich-renderer.js +0 -234
  983. package/dist/cli/ui/route-blocked-panel.d.ts +0 -5
  984. package/dist/cli/ui/route-blocked-panel.js +0 -67
  985. package/dist/cli/ui/rust-forge-renderer.d.ts +0 -19
  986. package/dist/cli/ui/rust-forge-renderer.js +0 -143
  987. package/dist/cli/ui/system24-renderer.d.ts +0 -96
  988. package/dist/cli/ui/system24-renderer.js +0 -533
  989. package/dist/cli/v2/chat-repl.d.ts +0 -38
  990. package/dist/cli/v2/chat-repl.js +0 -338
  991. package/dist/cli/v2/cli-v2-skeleton.d.ts +0 -105
  992. package/dist/cli/v2/cli-v2-skeleton.js +0 -465
  993. package/dist/cli/v2/interactive-prompt.d.ts +0 -52
  994. package/dist/cli/v2/interactive-prompt.js +0 -192
  995. package/dist/cli/v2/persistent-memory.d.ts +0 -70
  996. package/dist/cli/v2/persistent-memory.js +0 -229
  997. package/dist/cli/v2/provider-commands.d.ts +0 -120
  998. package/dist/cli/v2/provider-commands.js +0 -244
  999. package/dist/cli/v2/release-commands.d.ts +0 -29
  1000. package/dist/cli/v2/release-commands.js +0 -95
  1001. package/dist/cli/v2/workflow-commands.d.ts +0 -72
  1002. package/dist/cli/v2/workflow-commands.js +0 -198
  1003. package/dist/cockpit/git-numstat.d.ts +0 -10
  1004. package/dist/cockpit/git-numstat.js +0 -97
  1005. package/dist/cockpit/lsp-status.d.ts +0 -5
  1006. package/dist/cockpit/lsp-status.js +0 -51
  1007. package/dist/cockpit/types.d.ts +0 -66
  1008. package/dist/cockpit/types.js +0 -4
  1009. package/dist/cockpit/views/rail-view.d.ts +0 -9
  1010. package/dist/cockpit/views/rail-view.js +0 -160
  1011. package/dist/commands/agent.d.ts +0 -6
  1012. package/dist/commands/agent.js +0 -263
  1013. package/dist/commands/appshot.d.ts +0 -15
  1014. package/dist/commands/appshot.js +0 -122
  1015. package/dist/commands/auth.d.ts +0 -43
  1016. package/dist/commands/auth.js +0 -169
  1017. package/dist/commands/browser.d.ts +0 -18
  1018. package/dist/commands/browser.js +0 -110
  1019. package/dist/commands/chat/chat-turn-dag.d.ts +0 -21
  1020. package/dist/commands/chat/chat-turn-dag.js +0 -72
  1021. package/dist/commands/chat/core.d.ts +0 -27
  1022. package/dist/commands/chat/core.js +0 -423
  1023. package/dist/commands/chat/index.d.ts +0 -5
  1024. package/dist/commands/chat/index.js +0 -5
  1025. package/dist/commands/chat/native-root-loop.d.ts +0 -82
  1026. package/dist/commands/chat/native-root-loop.js +0 -1584
  1027. package/dist/commands/chat/runtime.d.ts +0 -46
  1028. package/dist/commands/chat/runtime.js +0 -406
  1029. package/dist/commands/chat/slash/commands/control.d.ts +0 -2
  1030. package/dist/commands/chat/slash/commands/control.js +0 -196
  1031. package/dist/commands/chat/slash/commands/diagnostics.d.ts +0 -2
  1032. package/dist/commands/chat/slash/commands/diagnostics.js +0 -64
  1033. package/dist/commands/chat/slash/commands/harness.d.ts +0 -2
  1034. package/dist/commands/chat/slash/commands/harness.js +0 -21
  1035. package/dist/commands/chat/slash/commands/index.d.ts +0 -2
  1036. package/dist/commands/chat/slash/commands/index.js +0 -18
  1037. package/dist/commands/chat/slash/commands/routing.d.ts +0 -2
  1038. package/dist/commands/chat/slash/commands/routing.js +0 -385
  1039. package/dist/commands/chat/slash/commands/session.d.ts +0 -2
  1040. package/dist/commands/chat/slash/commands/session.js +0 -104
  1041. package/dist/commands/chat/slash/commands/tool-plane.d.ts +0 -2
  1042. package/dist/commands/chat/slash/commands/tool-plane.js +0 -64
  1043. package/dist/commands/chat/slash/commands/ui.d.ts +0 -2
  1044. package/dist/commands/chat/slash/commands/ui.js +0 -108
  1045. package/dist/commands/chat/slash/context.d.ts +0 -3
  1046. package/dist/commands/chat/slash/context.js +0 -9
  1047. package/dist/commands/chat/slash/format.d.ts +0 -3
  1048. package/dist/commands/chat/slash/format.js +0 -19
  1049. package/dist/commands/chat/slash/parser.d.ts +0 -15
  1050. package/dist/commands/chat/slash/parser.js +0 -97
  1051. package/dist/commands/chat/slash/registry.d.ts +0 -13
  1052. package/dist/commands/chat/slash/registry.js +0 -38
  1053. package/dist/commands/chat/slash/result.d.ts +0 -7
  1054. package/dist/commands/chat/slash/result.js +0 -35
  1055. package/dist/commands/chat/slash/types.d.ts +0 -32
  1056. package/dist/commands/chat/slash/types.js +0 -1
  1057. package/dist/commands/chat/startup.d.ts +0 -68
  1058. package/dist/commands/chat/startup.js +0 -150
  1059. package/dist/commands/chat/state.d.ts +0 -3
  1060. package/dist/commands/chat/state.js +0 -100
  1061. package/dist/commands/chat/utils.d.ts +0 -25
  1062. package/dist/commands/chat/utils.js +0 -218
  1063. package/dist/commands/chat.d.ts +0 -2
  1064. package/dist/commands/chat.js +0 -2
  1065. package/dist/commands/cockpit/core.d.ts +0 -5
  1066. package/dist/commands/cockpit/core.js +0 -91
  1067. package/dist/commands/cockpit/render.d.ts +0 -5
  1068. package/dist/commands/cockpit/render.js +0 -970
  1069. package/dist/commands/cockpit/scroll.d.ts +0 -39
  1070. package/dist/commands/cockpit/scroll.js +0 -87
  1071. package/dist/commands/cockpit/telemetry.d.ts +0 -30
  1072. package/dist/commands/cockpit/telemetry.js +0 -361
  1073. package/dist/commands/cockpit/update-loop.d.ts +0 -54
  1074. package/dist/commands/cockpit/update-loop.js +0 -285
  1075. package/dist/commands/cockpit/utils.d.ts +0 -233
  1076. package/dist/commands/cockpit/utils.js +0 -388
  1077. package/dist/commands/cockpit.d.ts +0 -8
  1078. package/dist/commands/cockpit.js +0 -7
  1079. package/dist/commands/codex.d.ts +0 -70
  1080. package/dist/commands/codex.js +0 -597
  1081. package/dist/commands/consent.d.ts +0 -24
  1082. package/dist/commands/consent.js +0 -255
  1083. package/dist/commands/cron.d.ts +0 -16
  1084. package/dist/commands/cron.js +0 -187
  1085. package/dist/commands/dag-from-spec.d.ts +0 -31
  1086. package/dist/commands/dag-from-spec.js +0 -344
  1087. package/dist/commands/dag.d.ts +0 -10
  1088. package/dist/commands/dag.js +0 -512
  1089. package/dist/commands/design.d.ts +0 -73
  1090. package/dist/commands/design.js +0 -1253
  1091. package/dist/commands/diff-runs.d.ts +0 -3
  1092. package/dist/commands/diff-runs.js +0 -36
  1093. package/dist/commands/do.d.ts +0 -29
  1094. package/dist/commands/do.js +0 -196
  1095. package/dist/commands/doctor/checks.d.ts +0 -19
  1096. package/dist/commands/doctor/checks.js +0 -861
  1097. package/dist/commands/doctor/core.d.ts +0 -2
  1098. package/dist/commands/doctor/core.js +0 -53
  1099. package/dist/commands/doctor/fix-plan.d.ts +0 -69
  1100. package/dist/commands/doctor/fix-plan.js +0 -78
  1101. package/dist/commands/doctor/fix.d.ts +0 -5
  1102. package/dist/commands/doctor/fix.js +0 -1002
  1103. package/dist/commands/doctor/report.d.ts +0 -7
  1104. package/dist/commands/doctor/report.js +0 -140
  1105. package/dist/commands/doctor/utils.d.ts +0 -52
  1106. package/dist/commands/doctor/utils.js +0 -124
  1107. package/dist/commands/doctor.d.ts +0 -2
  1108. package/dist/commands/doctor.js +0 -1
  1109. package/dist/commands/goal-interview.d.ts +0 -18
  1110. package/dist/commands/goal-interview.js +0 -396
  1111. package/dist/commands/goal.d.ts +0 -46
  1112. package/dist/commands/goal.js +0 -492
  1113. package/dist/commands/google.d.ts +0 -1
  1114. package/dist/commands/google.js +0 -27
  1115. package/dist/commands/graph.d.ts +0 -71
  1116. package/dist/commands/graph.js +0 -208
  1117. package/dist/commands/hud.d.ts +0 -57
  1118. package/dist/commands/hud.js +0 -1031
  1119. package/dist/commands/image.d.ts +0 -16
  1120. package/dist/commands/image.js +0 -102
  1121. package/dist/commands/init/config.d.ts +0 -8
  1122. package/dist/commands/init/config.js +0 -97
  1123. package/dist/commands/init/constants.d.ts +0 -7
  1124. package/dist/commands/init/constants.js +0 -49
  1125. package/dist/commands/init/content.d.ts +0 -12
  1126. package/dist/commands/init/content.js +0 -1775
  1127. package/dist/commands/init/core.d.ts +0 -2
  1128. package/dist/commands/init/core.js +0 -298
  1129. package/dist/commands/init/interactive.d.ts +0 -9
  1130. package/dist/commands/init/interactive.js +0 -170
  1131. package/dist/commands/init/scaffold.d.ts +0 -17
  1132. package/dist/commands/init/scaffold.js +0 -146
  1133. package/dist/commands/init/types.d.ts +0 -35
  1134. package/dist/commands/init/types.js +0 -1
  1135. package/dist/commands/init/utils.d.ts +0 -13
  1136. package/dist/commands/init/utils.js +0 -107
  1137. package/dist/commands/init.d.ts +0 -32
  1138. package/dist/commands/init.js +0 -2581
  1139. package/dist/commands/inspect.d.ts +0 -9
  1140. package/dist/commands/inspect.js +0 -12
  1141. package/dist/commands/lsp.d.ts +0 -8
  1142. package/dist/commands/lsp.js +0 -60
  1143. package/dist/commands/mcp/config.d.ts +0 -32
  1144. package/dist/commands/mcp/config.js +0 -286
  1145. package/dist/commands/mcp/doctor-fix.d.ts +0 -12
  1146. package/dist/commands/mcp/doctor-fix.js +0 -261
  1147. package/dist/commands/mcp/doctor.d.ts +0 -55
  1148. package/dist/commands/mcp/doctor.js +0 -400
  1149. package/dist/commands/mcp/list.d.ts +0 -1
  1150. package/dist/commands/mcp/list.js +0 -57
  1151. package/dist/commands/mcp/shared.d.ts +0 -50
  1152. package/dist/commands/mcp/shared.js +0 -210
  1153. package/dist/commands/mcp/test.d.ts +0 -5
  1154. package/dist/commands/mcp/test.js +0 -458
  1155. package/dist/commands/mcp.d.ts +0 -8
  1156. package/dist/commands/mcp.js +0 -5
  1157. package/dist/commands/menu.d.ts +0 -4
  1158. package/dist/commands/menu.js +0 -213
  1159. package/dist/commands/merge.d.ts +0 -9
  1160. package/dist/commands/merge.js +0 -363
  1161. package/dist/commands/mode.d.ts +0 -3
  1162. package/dist/commands/mode.js +0 -60
  1163. package/dist/commands/model.d.ts +0 -15
  1164. package/dist/commands/model.js +0 -219
  1165. package/dist/commands/notice.d.ts +0 -7
  1166. package/dist/commands/notice.js +0 -76
  1167. package/dist/commands/open-design-agent.d.ts +0 -46
  1168. package/dist/commands/open-design-agent.js +0 -569
  1169. package/dist/commands/orchestrate.d.ts +0 -18
  1170. package/dist/commands/orchestrate.js +0 -284
  1171. package/dist/commands/parallel/core.d.ts +0 -34
  1172. package/dist/commands/parallel/core.js +0 -296
  1173. package/dist/commands/parallel/index.d.ts +0 -5
  1174. package/dist/commands/parallel/index.js +0 -5
  1175. package/dist/commands/parallel/interactive.d.ts +0 -27
  1176. package/dist/commands/parallel/interactive.js +0 -172
  1177. package/dist/commands/parallel/orchestrator.d.ts +0 -40
  1178. package/dist/commands/parallel/orchestrator.js +0 -564
  1179. package/dist/commands/parallel/utils.d.ts +0 -12
  1180. package/dist/commands/parallel/utils.js +0 -114
  1181. package/dist/commands/parallel/worker.d.ts +0 -43
  1182. package/dist/commands/parallel/worker.js +0 -276
  1183. package/dist/commands/parallel.d.ts +0 -4
  1184. package/dist/commands/parallel.js +0 -3
  1185. package/dist/commands/plan.d.ts +0 -6
  1186. package/dist/commands/plan.js +0 -113
  1187. package/dist/commands/project-index.d.ts +0 -18
  1188. package/dist/commands/project-index.js +0 -312
  1189. package/dist/commands/provider.d.ts +0 -65
  1190. package/dist/commands/provider.js +0 -625
  1191. package/dist/commands/rail.d.ts +0 -6
  1192. package/dist/commands/rail.js +0 -7
  1193. package/dist/commands/replay.d.ts +0 -7
  1194. package/dist/commands/replay.js +0 -10
  1195. package/dist/commands/research.d.ts +0 -5
  1196. package/dist/commands/research.js +0 -48
  1197. package/dist/commands/run.d.ts +0 -15
  1198. package/dist/commands/run.js +0 -312
  1199. package/dist/commands/runs.d.ts +0 -36
  1200. package/dist/commands/runs.js +0 -504
  1201. package/dist/commands/screenshot.d.ts +0 -10
  1202. package/dist/commands/screenshot.js +0 -72
  1203. package/dist/commands/skill.d.ts +0 -28
  1204. package/dist/commands/skill.js +0 -382
  1205. package/dist/commands/snip.d.ts +0 -8
  1206. package/dist/commands/snip.js +0 -77
  1207. package/dist/commands/spec.d.ts +0 -17
  1208. package/dist/commands/spec.js +0 -262
  1209. package/dist/commands/specify.d.ts +0 -18
  1210. package/dist/commands/specify.js +0 -111
  1211. package/dist/commands/star.d.ts +0 -3
  1212. package/dist/commands/star.js +0 -35
  1213. package/dist/commands/summary.d.ts +0 -5
  1214. package/dist/commands/summary.js +0 -445
  1215. package/dist/commands/sync.d.ts +0 -6
  1216. package/dist/commands/sync.js +0 -129
  1217. package/dist/commands/team.d.ts +0 -8
  1218. package/dist/commands/team.js +0 -302
  1219. package/dist/commands/verify.d.ts +0 -4
  1220. package/dist/commands/verify.js +0 -378
  1221. package/dist/commands/version.d.ts +0 -7
  1222. package/dist/commands/version.js +0 -101
  1223. package/dist/commands/web-bridge.d.ts +0 -12
  1224. package/dist/commands/web-bridge.js +0 -75
  1225. package/dist/commands/why.d.ts +0 -14
  1226. package/dist/commands/why.js +0 -46
  1227. package/dist/commands/workflow.d.ts +0 -13
  1228. package/dist/commands/workflow.js +0 -385
  1229. package/dist/contracts/command.d.ts +0 -25
  1230. package/dist/contracts/command.js +0 -1
  1231. package/dist/contracts/dag.d.ts +0 -142
  1232. package/dist/contracts/dag.js +0 -4
  1233. package/dist/contracts/decision.d.ts +0 -23
  1234. package/dist/contracts/decision.js +0 -1
  1235. package/dist/contracts/envelope.d.ts +0 -29
  1236. package/dist/contracts/envelope.js +0 -1
  1237. package/dist/contracts/errors.d.ts +0 -13
  1238. package/dist/contracts/errors.js +0 -15
  1239. package/dist/contracts/evidence-bundle.d.ts +0 -52
  1240. package/dist/contracts/evidence-bundle.js +0 -1
  1241. package/dist/contracts/evidence.d.ts +0 -23
  1242. package/dist/contracts/evidence.js +0 -1
  1243. package/dist/contracts/goal.d.ts +0 -169
  1244. package/dist/contracts/goal.js +0 -4
  1245. package/dist/contracts/hud.d.ts +0 -17
  1246. package/dist/contracts/hud.js +0 -4
  1247. package/dist/contracts/index.d.ts +0 -10
  1248. package/dist/contracts/index.js +0 -10
  1249. package/dist/contracts/interview.d.ts +0 -106
  1250. package/dist/contracts/interview.js +0 -9
  1251. package/dist/contracts/orchestration.d.ts +0 -215
  1252. package/dist/contracts/orchestration.js +0 -4
  1253. package/dist/contracts/proof.d.ts +0 -32
  1254. package/dist/contracts/proof.js +0 -1
  1255. package/dist/contracts/provider-health.d.ts +0 -79
  1256. package/dist/contracts/provider-health.js +0 -57
  1257. package/dist/contracts/provider.d.ts +0 -35
  1258. package/dist/contracts/provider.js +0 -1
  1259. package/dist/contracts/replay.d.ts +0 -95
  1260. package/dist/contracts/replay.js +0 -7
  1261. package/dist/contracts/run.d.ts +0 -34
  1262. package/dist/contracts/run.js +0 -1
  1263. package/dist/contracts/safety.d.ts +0 -10
  1264. package/dist/contracts/safety.js +0 -4
  1265. package/dist/contracts/version.d.ts +0 -21
  1266. package/dist/contracts/version.js +0 -1
  1267. package/dist/contracts/web-bridge.d.ts +0 -95
  1268. package/dist/contracts/web-bridge.js +0 -168
  1269. package/dist/contracts/worker-context.d.ts +0 -70
  1270. package/dist/contracts/worker-context.js +0 -1
  1271. package/dist/evidence/attempt-record.d.ts +0 -78
  1272. package/dist/evidence/attempt-record.js +0 -16
  1273. package/dist/evidence/bundle-validator.d.ts +0 -7
  1274. package/dist/evidence/bundle-validator.js +0 -103
  1275. package/dist/evidence/context-snapshot.d.ts +0 -20
  1276. package/dist/evidence/context-snapshot.js +0 -81
  1277. package/dist/evidence/decision-trace.d.ts +0 -14
  1278. package/dist/evidence/decision-trace.js +0 -54
  1279. package/dist/evidence/diagnosis.d.ts +0 -15
  1280. package/dist/evidence/diagnosis.js +0 -279
  1281. package/dist/evidence/evidence-recorder.d.ts +0 -19
  1282. package/dist/evidence/evidence-recorder.js +0 -55
  1283. package/dist/evidence/evidence-trust-score.d.ts +0 -101
  1284. package/dist/evidence/evidence-trust-score.js +0 -408
  1285. package/dist/evidence/graph-ontology-relation-gate.d.ts +0 -10
  1286. package/dist/evidence/graph-ontology-relation-gate.js +0 -46
  1287. package/dist/evidence/headroom-replay-verifier.d.ts +0 -19
  1288. package/dist/evidence/headroom-replay-verifier.js +0 -86
  1289. package/dist/evidence/index.d.ts +0 -26
  1290. package/dist/evidence/index.js +0 -12
  1291. package/dist/evidence/proof-trust-cli.d.ts +0 -8
  1292. package/dist/evidence/proof-trust-cli.js +0 -27
  1293. package/dist/evidence/proof-trust.d.ts +0 -14
  1294. package/dist/evidence/proof-trust.js +0 -373
  1295. package/dist/evidence/regression-proof-matrix.d.ts +0 -42
  1296. package/dist/evidence/regression-proof-matrix.js +0 -72
  1297. package/dist/evidence/run-trace.d.ts +0 -103
  1298. package/dist/evidence/run-trace.js +0 -191
  1299. package/dist/evidence/trust-calibration.d.ts +0 -25
  1300. package/dist/evidence/trust-calibration.js +0 -151
  1301. package/dist/goal/compiler.d.ts +0 -5
  1302. package/dist/goal/compiler.js +0 -350
  1303. package/dist/goal/control-loop.d.ts +0 -124
  1304. package/dist/goal/control-loop.js +0 -1123
  1305. package/dist/goal/ensemble-memory.d.ts +0 -26
  1306. package/dist/goal/ensemble-memory.js +0 -55
  1307. package/dist/goal/eval-criteria.d.ts +0 -3
  1308. package/dist/goal/eval-criteria.js +0 -72
  1309. package/dist/goal/evidence.d.ts +0 -20
  1310. package/dist/goal/evidence.js +0 -321
  1311. package/dist/goal/goal-daemon.d.ts +0 -40
  1312. package/dist/goal/goal-daemon.js +0 -318
  1313. package/dist/goal/intake.d.ts +0 -48
  1314. package/dist/goal/intake.js +0 -561
  1315. package/dist/goal/intent-analyzer.d.ts +0 -9
  1316. package/dist/goal/intent-analyzer.js +0 -322
  1317. package/dist/goal/intent-frame.d.ts +0 -65
  1318. package/dist/goal/intent-frame.js +0 -596
  1319. package/dist/goal/interview-assimilation.d.ts +0 -13
  1320. package/dist/goal/interview-assimilation.js +0 -383
  1321. package/dist/goal/interview-question-bank.d.ts +0 -11
  1322. package/dist/goal/interview-question-bank.js +0 -225
  1323. package/dist/goal/interview-scoring.d.ts +0 -31
  1324. package/dist/goal/interview-scoring.js +0 -187
  1325. package/dist/goal/interview-session.d.ts +0 -25
  1326. package/dist/goal/interview-session.js +0 -116
  1327. package/dist/goal/persistence.d.ts +0 -11
  1328. package/dist/goal/persistence.js +0 -134
  1329. package/dist/goal/prompt-digest.d.ts +0 -13
  1330. package/dist/goal/prompt-digest.js +0 -111
  1331. package/dist/goal/scoring.d.ts +0 -2
  1332. package/dist/goal/scoring.js +0 -69
  1333. package/dist/goal/wake-policy.d.ts +0 -26
  1334. package/dist/goal/wake-policy.js +0 -58
  1335. package/dist/harness/create-harness-task-runner.d.ts +0 -43
  1336. package/dist/harness/create-harness-task-runner.js +0 -56
  1337. package/dist/harness/execute-harness-run.d.ts +0 -34
  1338. package/dist/harness/execute-harness-run.js +0 -109
  1339. package/dist/hooks/events.d.ts +0 -71
  1340. package/dist/hooks/events.js +0 -1
  1341. package/dist/hooks/hook-bus.d.ts +0 -13
  1342. package/dist/hooks/hook-bus.js +0 -59
  1343. package/dist/hooks/hook-registry.d.ts +0 -6
  1344. package/dist/hooks/hook-registry.js +0 -64
  1345. package/dist/hooks/index.d.ts +0 -3
  1346. package/dist/hooks/index.js +0 -2
  1347. package/dist/hud/index.d.ts +0 -9
  1348. package/dist/hud/index.js +0 -11
  1349. package/dist/hud/live-renderer.d.ts +0 -17
  1350. package/dist/hud/live-renderer.js +0 -52
  1351. package/dist/hud/render.d.ts +0 -64
  1352. package/dist/hud/render.js +0 -960
  1353. package/dist/hud/types.d.ts +0 -58
  1354. package/dist/hud/types.js +0 -7
  1355. package/dist/input/input-artifacts.d.ts +0 -10
  1356. package/dist/input/input-artifacts.js +0 -19
  1357. package/dist/input/input-envelope.d.ts +0 -86
  1358. package/dist/input/input-envelope.js +0 -87
  1359. package/dist/integrations/servarr/adapter.d.ts +0 -29
  1360. package/dist/integrations/servarr/adapter.js +0 -156
  1361. package/dist/integrations/servarr/commands.d.ts +0 -15
  1362. package/dist/integrations/servarr/commands.js +0 -119
  1363. package/dist/integrations/servarr/schema.d.ts +0 -34
  1364. package/dist/integrations/servarr/schema.js +0 -149
  1365. package/dist/kimi/ascii-art.d.ts +0 -1
  1366. package/dist/kimi/ascii-art.js +0 -23
  1367. package/dist/kimi/banner.d.ts +0 -53
  1368. package/dist/kimi/banner.js +0 -284
  1369. package/dist/kimi/bug-filter.d.ts +0 -15
  1370. package/dist/kimi/bug-filter.js +0 -150
  1371. package/dist/kimi/capability.d.ts +0 -25
  1372. package/dist/kimi/capability.js +0 -68
  1373. package/dist/kimi/isolated-home.d.ts +0 -21
  1374. package/dist/kimi/isolated-home.js +0 -270
  1375. package/dist/kimi/runner.d.ts +0 -74
  1376. package/dist/kimi/runner.js +0 -1052
  1377. package/dist/kimi/simple-art.d.ts +0 -1
  1378. package/dist/kimi/simple-art.js +0 -1
  1379. package/dist/kimi/statusline.d.ts +0 -26
  1380. package/dist/kimi/statusline.js +0 -142
  1381. package/dist/kimi/usage.d.ts +0 -52
  1382. package/dist/kimi/usage.js +0 -481
  1383. package/dist/kimi/wire-client.d.ts +0 -95
  1384. package/dist/kimi/wire-client.js +0 -338
  1385. package/dist/lsp/default-config.d.ts +0 -16
  1386. package/dist/lsp/default-config.js +0 -26
  1387. package/dist/mcp/acp-server.d.ts +0 -2
  1388. package/dist/mcp/acp-server.js +0 -357
  1389. package/dist/mcp/autoconnect.d.ts +0 -60
  1390. package/dist/mcp/autoconnect.js +0 -192
  1391. package/dist/mcp/client.d.ts +0 -112
  1392. package/dist/mcp/client.js +0 -276
  1393. package/dist/mcp/config-permissions.d.ts +0 -23
  1394. package/dist/mcp/config-permissions.js +0 -66
  1395. package/dist/mcp/consent-flow.d.ts +0 -152
  1396. package/dist/mcp/consent-flow.js +0 -329
  1397. package/dist/mcp/filesystem-readonly-server.d.ts +0 -2
  1398. package/dist/mcp/filesystem-readonly-server.js +0 -320
  1399. package/dist/mcp/governance.d.ts +0 -292
  1400. package/dist/mcp/governance.js +0 -602
  1401. package/dist/mcp/host.d.ts +0 -154
  1402. package/dist/mcp/host.js +0 -792
  1403. package/dist/mcp/omk-project-server.d.ts +0 -2
  1404. package/dist/mcp/omk-project-server.js +0 -1632
  1405. package/dist/mcp/omk-web-bridge-server.d.ts +0 -14
  1406. package/dist/mcp/omk-web-bridge-server.js +0 -154
  1407. package/dist/mcp/permission-resolver.d.ts +0 -67
  1408. package/dist/mcp/permission-resolver.js +0 -124
  1409. package/dist/mcp/quality-gate.d.ts +0 -36
  1410. package/dist/mcp/quality-gate.js +0 -247
  1411. package/dist/mcp/quarantine.d.ts +0 -11
  1412. package/dist/mcp/quarantine.js +0 -79
  1413. package/dist/mcp/secret-scanner.d.ts +0 -195
  1414. package/dist/mcp/secret-scanner.js +0 -742
  1415. package/dist/mcp/server-catalog.d.ts +0 -36
  1416. package/dist/mcp/server-catalog.js +0 -168
  1417. package/dist/mcp/shared-secret-registry.d.ts +0 -61
  1418. package/dist/mcp/shared-secret-registry.js +0 -171
  1419. package/dist/mcp/transports/stdio.d.ts +0 -22
  1420. package/dist/mcp/transports/stdio.js +0 -165
  1421. package/dist/mcp/transports/streamable-http.d.ts +0 -31
  1422. package/dist/mcp/transports/streamable-http.js +0 -289
  1423. package/dist/mcp/transports/transport.d.ts +0 -20
  1424. package/dist/mcp/transports/transport.js +0 -3
  1425. package/dist/memory/embedding.d.ts +0 -11
  1426. package/dist/memory/embedding.js +0 -24
  1427. package/dist/memory/graph-delta-log.d.ts +0 -137
  1428. package/dist/memory/graph-delta-log.js +0 -650
  1429. package/dist/memory/graph-viewer.d.ts +0 -72
  1430. package/dist/memory/graph-viewer.js +0 -383
  1431. package/dist/memory/kuzu-memory-store.d.ts +0 -37
  1432. package/dist/memory/kuzu-memory-store.js +0 -453
  1433. package/dist/memory/local-graph-memory-store.d.ts +0 -264
  1434. package/dist/memory/local-graph-memory-store.js +0 -1875
  1435. package/dist/memory/memory-config.d.ts +0 -51
  1436. package/dist/memory/memory-config.js +0 -187
  1437. package/dist/memory/memory-store.d.ts +0 -66
  1438. package/dist/memory/memory-store.js +0 -228
  1439. package/dist/memory/ontology-model.d.ts +0 -175
  1440. package/dist/memory/ontology-model.js +0 -131
  1441. package/dist/metrics/provenance-ratio.d.ts +0 -16
  1442. package/dist/metrics/provenance-ratio.js +0 -33
  1443. package/dist/openai/image-client.d.ts +0 -103
  1444. package/dist/openai/image-client.js +0 -380
  1445. package/dist/orchestration/adaptorch-topology.d.ts +0 -59
  1446. package/dist/orchestration/adaptorch-topology.js +0 -194
  1447. package/dist/orchestration/agent-worker.d.ts +0 -72
  1448. package/dist/orchestration/agent-worker.js +0 -278
  1449. package/dist/orchestration/capability-agents.d.ts +0 -14
  1450. package/dist/orchestration/capability-agents.js +0 -180
  1451. package/dist/orchestration/capability-routing.d.ts +0 -65
  1452. package/dist/orchestration/capability-routing.js +0 -121
  1453. package/dist/orchestration/compiled-dag-executor.d.ts +0 -56
  1454. package/dist/orchestration/compiled-dag-executor.js +0 -88
  1455. package/dist/orchestration/completion-artifacts.d.ts +0 -37
  1456. package/dist/orchestration/completion-artifacts.js +0 -84
  1457. package/dist/orchestration/completion-sentinel.d.ts +0 -37
  1458. package/dist/orchestration/completion-sentinel.js +0 -66
  1459. package/dist/orchestration/contracts/index.d.ts +0 -45
  1460. package/dist/orchestration/contracts/index.js +0 -6
  1461. package/dist/orchestration/dag-artifacts.d.ts +0 -11
  1462. package/dist/orchestration/dag-artifacts.js +0 -42
  1463. package/dist/orchestration/dag-compiler-presets.d.ts +0 -20
  1464. package/dist/orchestration/dag-compiler-presets.js +0 -476
  1465. package/dist/orchestration/dag-compiler-types.d.ts +0 -43
  1466. package/dist/orchestration/dag-compiler-types.js +0 -1
  1467. package/dist/orchestration/dag-compiler.d.ts +0 -3
  1468. package/dist/orchestration/dag-compiler.js +0 -135
  1469. package/dist/orchestration/dag.d.ts +0 -196
  1470. package/dist/orchestration/dag.js +0 -310
  1471. package/dist/orchestration/diagnostics.d.ts +0 -27
  1472. package/dist/orchestration/diagnostics.js +0 -262
  1473. package/dist/orchestration/enhanced-modes.d.ts +0 -116
  1474. package/dist/orchestration/enhanced-modes.js +0 -231
  1475. package/dist/orchestration/enhanced-parallel-orchestrator.d.ts +0 -127
  1476. package/dist/orchestration/enhanced-parallel-orchestrator.js +0 -734
  1477. package/dist/orchestration/ensemble-decision.d.ts +0 -42
  1478. package/dist/orchestration/ensemble-decision.js +0 -301
  1479. package/dist/orchestration/ensemble.d.ts +0 -22
  1480. package/dist/orchestration/ensemble.js +0 -558
  1481. package/dist/orchestration/eta.d.ts +0 -10
  1482. package/dist/orchestration/eta.js +0 -75
  1483. package/dist/orchestration/evidence-check.d.ts +0 -36
  1484. package/dist/orchestration/evidence-check.js +0 -257
  1485. package/dist/orchestration/evidence-gate.d.ts +0 -34
  1486. package/dist/orchestration/evidence-gate.js +0 -513
  1487. package/dist/orchestration/execution-planner.d.ts +0 -40
  1488. package/dist/orchestration/execution-planner.js +0 -252
  1489. package/dist/orchestration/executor.d.ts +0 -11
  1490. package/dist/orchestration/executor.js +0 -1075
  1491. package/dist/orchestration/hedge-persona-weights.d.ts +0 -25
  1492. package/dist/orchestration/hedge-persona-weights.js +0 -43
  1493. package/dist/orchestration/interactive-orchestrator.d.ts +0 -134
  1494. package/dist/orchestration/interactive-orchestrator.js +0 -450
  1495. package/dist/orchestration/log-streamer.d.ts +0 -104
  1496. package/dist/orchestration/log-streamer.js +0 -293
  1497. package/dist/orchestration/loop-artifacts.d.ts +0 -14
  1498. package/dist/orchestration/loop-artifacts.js +0 -20
  1499. package/dist/orchestration/loop-controller-headroom.d.ts +0 -6
  1500. package/dist/orchestration/loop-controller-headroom.js +0 -33
  1501. package/dist/orchestration/loop-controller.d.ts +0 -14
  1502. package/dist/orchestration/loop-controller.js +0 -311
  1503. package/dist/orchestration/loop-guard.d.ts +0 -28
  1504. package/dist/orchestration/loop-guard.js +0 -104
  1505. package/dist/orchestration/loop-state.d.ts +0 -86
  1506. package/dist/orchestration/loop-state.js +0 -1
  1507. package/dist/orchestration/merge-arbiter.d.ts +0 -91
  1508. package/dist/orchestration/merge-arbiter.js +0 -376
  1509. package/dist/orchestration/node-monitor.d.ts +0 -18
  1510. package/dist/orchestration/node-monitor.js +0 -98
  1511. package/dist/orchestration/orchestrate-prompt.d.ts +0 -43
  1512. package/dist/orchestration/orchestrate-prompt.js +0 -533
  1513. package/dist/orchestration/orchestration-state.d.ts +0 -3
  1514. package/dist/orchestration/orchestration-state.js +0 -2
  1515. package/dist/orchestration/parallel-orchestrator.d.ts +0 -165
  1516. package/dist/orchestration/parallel-orchestrator.js +0 -607
  1517. package/dist/orchestration/parallel-ui.d.ts +0 -52
  1518. package/dist/orchestration/parallel-ui.js +0 -479
  1519. package/dist/orchestration/repair-policy.d.ts +0 -20
  1520. package/dist/orchestration/repair-policy.js +0 -221
  1521. package/dist/orchestration/route-calibration.d.ts +0 -27
  1522. package/dist/orchestration/route-calibration.js +0 -123
  1523. package/dist/orchestration/routing/inventory.d.ts +0 -9
  1524. package/dist/orchestration/routing/inventory.js +0 -273
  1525. package/dist/orchestration/routing/mcp-config.d.ts +0 -17
  1526. package/dist/orchestration/routing/mcp-config.js +0 -158
  1527. package/dist/orchestration/routing/types.d.ts +0 -59
  1528. package/dist/orchestration/routing/types.js +0 -4
  1529. package/dist/orchestration/routing.d.ts +0 -45
  1530. package/dist/orchestration/routing.js +0 -1072
  1531. package/dist/orchestration/run-state.d.ts +0 -36
  1532. package/dist/orchestration/run-state.js +0 -176
  1533. package/dist/orchestration/scheduler.d.ts +0 -11
  1534. package/dist/orchestration/scheduler.js +0 -88
  1535. package/dist/orchestration/skill-assigner.d.ts +0 -22
  1536. package/dist/orchestration/skill-assigner.js +0 -345
  1537. package/dist/orchestration/state-machine/index.d.ts +0 -3
  1538. package/dist/orchestration/state-machine/index.js +0 -3
  1539. package/dist/orchestration/state-machine/node-state-machine.d.ts +0 -24
  1540. package/dist/orchestration/state-machine/node-state-machine.js +0 -35
  1541. package/dist/orchestration/state-machine/run-state-machine.d.ts +0 -38
  1542. package/dist/orchestration/state-machine/run-state-machine.js +0 -161
  1543. package/dist/orchestration/state-machine/run-state-manager.d.ts +0 -108
  1544. package/dist/orchestration/state-machine/run-state-manager.js +0 -314
  1545. package/dist/orchestration/state-persister.d.ts +0 -7
  1546. package/dist/orchestration/state-persister.js +0 -84
  1547. package/dist/orchestration/task-graph.d.ts +0 -46
  1548. package/dist/orchestration/task-graph.js +0 -299
  1549. package/dist/orchestration/verification-only.d.ts +0 -28
  1550. package/dist/orchestration/verification-only.js +0 -94
  1551. package/dist/providers/anthropic-messages-runner.d.ts +0 -17
  1552. package/dist/providers/anthropic-messages-runner.js +0 -197
  1553. package/dist/providers/attempt-recorder.d.ts +0 -10
  1554. package/dist/providers/attempt-recorder.js +0 -38
  1555. package/dist/providers/codex-cli-runner.d.ts +0 -11
  1556. package/dist/providers/codex-cli-runner.js +0 -144
  1557. package/dist/providers/context-preflight.d.ts +0 -47
  1558. package/dist/providers/context-preflight.js +0 -134
  1559. package/dist/providers/deepseek/deepseek-balance.d.ts +0 -29
  1560. package/dist/providers/deepseek/deepseek-balance.js +0 -80
  1561. package/dist/providers/deepseek/deepseek-client.d.ts +0 -53
  1562. package/dist/providers/deepseek/deepseek-client.js +0 -164
  1563. package/dist/providers/deepseek/deepseek-config.d.ts +0 -89
  1564. package/dist/providers/deepseek/deepseek-config.js +0 -272
  1565. package/dist/providers/deepseek/deepseek-errors.d.ts +0 -5
  1566. package/dist/providers/deepseek/deepseek-errors.js +0 -48
  1567. package/dist/providers/deepseek/deepseek-provider.d.ts +0 -10
  1568. package/dist/providers/deepseek/deepseek-provider.js +0 -162
  1569. package/dist/providers/deepseek/deepseek-super-config.d.ts +0 -31
  1570. package/dist/providers/deepseek/deepseek-super-config.js +0 -136
  1571. package/dist/providers/deepseek-provider.d.ts +0 -8
  1572. package/dist/providers/deepseek-provider.js +0 -78
  1573. package/dist/providers/health.d.ts +0 -16
  1574. package/dist/providers/health.js +0 -101
  1575. package/dist/providers/index.d.ts +0 -23
  1576. package/dist/providers/index.js +0 -23
  1577. package/dist/providers/kimi-provider-failure.d.ts +0 -8
  1578. package/dist/providers/kimi-provider-failure.js +0 -56
  1579. package/dist/providers/kimi-provider.d.ts +0 -7
  1580. package/dist/providers/kimi-provider.js +0 -27
  1581. package/dist/providers/model-registry.d.ts +0 -104
  1582. package/dist/providers/model-registry.js +0 -677
  1583. package/dist/providers/model-table.d.ts +0 -24
  1584. package/dist/providers/model-table.js +0 -140
  1585. package/dist/providers/model-tabs.d.ts +0 -33
  1586. package/dist/providers/model-tabs.js +0 -98
  1587. package/dist/providers/openai-compatible-runner.d.ts +0 -17
  1588. package/dist/providers/openai-compatible-runner.js +0 -180
  1589. package/dist/providers/provider-health.d.ts +0 -46
  1590. package/dist/providers/provider-health.js +0 -200
  1591. package/dist/providers/provider-router.d.ts +0 -8
  1592. package/dist/providers/provider-router.js +0 -174
  1593. package/dist/providers/provider-runtime.d.ts +0 -17
  1594. package/dist/providers/provider-runtime.js +0 -270
  1595. package/dist/providers/provider-stats.d.ts +0 -56
  1596. package/dist/providers/provider-stats.js +0 -303
  1597. package/dist/providers/provider-task-runner.d.ts +0 -23
  1598. package/dist/providers/provider-task-runner.js +0 -1202
  1599. package/dist/providers/provider.d.ts +0 -76
  1600. package/dist/providers/provider.js +0 -9
  1601. package/dist/providers/router.d.ts +0 -14
  1602. package/dist/providers/router.js +0 -563
  1603. package/dist/providers/runner/deepseek-helpers.d.ts +0 -38
  1604. package/dist/providers/runner/deepseek-helpers.js +0 -150
  1605. package/dist/providers/runner/env.d.ts +0 -12
  1606. package/dist/providers/runner/env.js +0 -98
  1607. package/dist/providers/runner/execution.d.ts +0 -26
  1608. package/dist/providers/runner/execution.js +0 -42
  1609. package/dist/providers/runner/helpers.d.ts +0 -9
  1610. package/dist/providers/runner/helpers.js +0 -38
  1611. package/dist/providers/runner/results.d.ts +0 -26
  1612. package/dist/providers/runner/results.js +0 -104
  1613. package/dist/providers/thinking-levels.d.ts +0 -7
  1614. package/dist/providers/thinking-levels.js +0 -72
  1615. package/dist/providers/types.d.ts +0 -143
  1616. package/dist/providers/types.js +0 -60
  1617. package/dist/replay/differ.d.ts +0 -5
  1618. package/dist/replay/differ.js +0 -314
  1619. package/dist/replay/index.d.ts +0 -6
  1620. package/dist/replay/index.js +0 -4
  1621. package/dist/replay/inspector.d.ts +0 -14
  1622. package/dist/replay/inspector.js +0 -264
  1623. package/dist/replay/manifest-builder.d.ts +0 -11
  1624. package/dist/replay/manifest-builder.js +0 -184
  1625. package/dist/replay/replay-engine.d.ts +0 -18
  1626. package/dist/replay/replay-engine.js +0 -265
  1627. package/dist/runtime/adapter.d.ts +0 -77
  1628. package/dist/runtime/adapter.js +0 -28
  1629. package/dist/runtime/advanced-control-loop.d.ts +0 -60
  1630. package/dist/runtime/advanced-control-loop.js +0 -136
  1631. package/dist/runtime/agent-runtime.d.ts +0 -162
  1632. package/dist/runtime/agent-runtime.js +0 -31
  1633. package/dist/runtime/authority-matrix.d.ts +0 -23
  1634. package/dist/runtime/authority-matrix.js +0 -171
  1635. package/dist/runtime/blast-radius.d.ts +0 -10
  1636. package/dist/runtime/blast-radius.js +0 -14
  1637. package/dist/runtime/cache-stable-session.d.ts +0 -55
  1638. package/dist/runtime/cache-stable-session.js +0 -108
  1639. package/dist/runtime/capability-injection.d.ts +0 -39
  1640. package/dist/runtime/capability-injection.js +0 -93
  1641. package/dist/runtime/chat-advisory-runtime.d.ts +0 -2
  1642. package/dist/runtime/chat-advisory-runtime.js +0 -74
  1643. package/dist/runtime/child-env.d.ts +0 -31
  1644. package/dist/runtime/child-env.js +0 -131
  1645. package/dist/runtime/codex-cli-runtime.d.ts +0 -10
  1646. package/dist/runtime/codex-cli-runtime.js +0 -80
  1647. package/dist/runtime/codex-runtime.d.ts +0 -38
  1648. package/dist/runtime/codex-runtime.js +0 -286
  1649. package/dist/runtime/command-bus.d.ts +0 -13
  1650. package/dist/runtime/command-bus.js +0 -57
  1651. package/dist/runtime/context-broker-converter.d.ts +0 -9
  1652. package/dist/runtime/context-broker-converter.js +0 -126
  1653. package/dist/runtime/context-broker.d.ts +0 -34
  1654. package/dist/runtime/context-broker.js +0 -339
  1655. package/dist/runtime/context-budget-optimizer.d.ts +0 -73
  1656. package/dist/runtime/context-budget-optimizer.js +0 -300
  1657. package/dist/runtime/context-capsule.d.ts +0 -81
  1658. package/dist/runtime/context-capsule.js +0 -46
  1659. package/dist/runtime/contracts/command-envelope.d.ts +0 -99
  1660. package/dist/runtime/contracts/command-envelope.js +0 -5
  1661. package/dist/runtime/contracts/evidence.d.ts +0 -139
  1662. package/dist/runtime/contracts/evidence.js +0 -144
  1663. package/dist/runtime/contracts/reasoning-trace.d.ts +0 -120
  1664. package/dist/runtime/contracts/reasoning-trace.js +0 -10
  1665. package/dist/runtime/contracts/router-v2.d.ts +0 -44
  1666. package/dist/runtime/contracts/router-v2.js +0 -4
  1667. package/dist/runtime/contracts/shared.d.ts +0 -61
  1668. package/dist/runtime/contracts/shared.js +0 -12
  1669. package/dist/runtime/contracts/weakness-remediation.d.ts +0 -83
  1670. package/dist/runtime/contracts/weakness-remediation.js +0 -44
  1671. package/dist/runtime/core-verified-preset.d.ts +0 -37
  1672. package/dist/runtime/core-verified-preset.js +0 -205
  1673. package/dist/runtime/data-retention-gate.d.ts +0 -42
  1674. package/dist/runtime/data-retention-gate.js +0 -123
  1675. package/dist/runtime/debloat-nlp.d.ts +0 -140
  1676. package/dist/runtime/debloat-nlp.js +0 -398
  1677. package/dist/runtime/deepseek-runtime.d.ts +0 -32
  1678. package/dist/runtime/deepseek-runtime.js +0 -276
  1679. package/dist/runtime/external-cli-adapter.d.ts +0 -29
  1680. package/dist/runtime/external-cli-adapter.js +0 -296
  1681. package/dist/runtime/freedomd-evidence-envelope.d.ts +0 -57
  1682. package/dist/runtime/freedomd-evidence-envelope.js +0 -110
  1683. package/dist/runtime/freedomd-exception.d.ts +0 -32
  1684. package/dist/runtime/freedomd-exception.js +0 -95
  1685. package/dist/runtime/freedomd-incidents.d.ts +0 -23
  1686. package/dist/runtime/freedomd-incidents.js +0 -103
  1687. package/dist/runtime/freedomd-policy.d.ts +0 -35
  1688. package/dist/runtime/freedomd-policy.js +0 -114
  1689. package/dist/runtime/freedomd-router.d.ts +0 -66
  1690. package/dist/runtime/freedomd-router.js +0 -433
  1691. package/dist/runtime/glm-api-runtime.d.ts +0 -4
  1692. package/dist/runtime/glm-api-runtime.js +0 -15
  1693. package/dist/runtime/headroom-aware-loop-decision.d.ts +0 -21
  1694. package/dist/runtime/headroom-aware-loop-decision.js +0 -67
  1695. package/dist/runtime/headroom-loop-risk.d.ts +0 -19
  1696. package/dist/runtime/headroom-loop-risk.js +0 -43
  1697. package/dist/runtime/headroom-policy.d.ts +0 -50
  1698. package/dist/runtime/headroom-policy.js +0 -184
  1699. package/dist/runtime/index.d.ts +0 -9
  1700. package/dist/runtime/index.js +0 -9
  1701. package/dist/runtime/kimi-api-runtime.d.ts +0 -60
  1702. package/dist/runtime/kimi-api-runtime.js +0 -455
  1703. package/dist/runtime/kimi-print-runtime.d.ts +0 -10
  1704. package/dist/runtime/kimi-print-runtime.js +0 -108
  1705. package/dist/runtime/kimi-wire-protocol-runtime.d.ts +0 -44
  1706. package/dist/runtime/kimi-wire-protocol-runtime.js +0 -452
  1707. package/dist/runtime/kimi-wire-runtime.d.ts +0 -17
  1708. package/dist/runtime/kimi-wire-runtime.js +0 -112
  1709. package/dist/runtime/legacy-bridge.d.ts +0 -14
  1710. package/dist/runtime/legacy-bridge.js +0 -27
  1711. package/dist/runtime/local-llm-runtime.d.ts +0 -33
  1712. package/dist/runtime/local-llm-runtime.js +0 -222
  1713. package/dist/runtime/mimo-api-runtime.d.ts +0 -13
  1714. package/dist/runtime/mimo-api-runtime.js +0 -24
  1715. package/dist/runtime/nlg-renderer.d.ts +0 -38
  1716. package/dist/runtime/nlg-renderer.js +0 -132
  1717. package/dist/runtime/ouroboros-policy.d.ts +0 -57
  1718. package/dist/runtime/ouroboros-policy.js +0 -134
  1719. package/dist/runtime/output-router.d.ts +0 -20
  1720. package/dist/runtime/output-router.js +0 -171
  1721. package/dist/runtime/private-stderr.d.ts +0 -13
  1722. package/dist/runtime/private-stderr.js +0 -69
  1723. package/dist/runtime/process-session.d.ts +0 -27
  1724. package/dist/runtime/process-session.js +0 -35
  1725. package/dist/runtime/prompt-envelope.d.ts +0 -28
  1726. package/dist/runtime/prompt-envelope.js +0 -78
  1727. package/dist/runtime/proof-bundle-trust.d.ts +0 -74
  1728. package/dist/runtime/proof-bundle-trust.js +0 -100
  1729. package/dist/runtime/provider-event-normalizer.d.ts +0 -117
  1730. package/dist/runtime/provider-event-normalizer.js +0 -454
  1731. package/dist/runtime/provider-maturity-gate.d.ts +0 -43
  1732. package/dist/runtime/provider-maturity-gate.js +0 -127
  1733. package/dist/runtime/provider-sovereignty.d.ts +0 -81
  1734. package/dist/runtime/provider-sovereignty.js +0 -285
  1735. package/dist/runtime/provider-tool-contracts.d.ts +0 -24
  1736. package/dist/runtime/provider-tool-contracts.js +0 -56
  1737. package/dist/runtime/public-surface.d.ts +0 -93
  1738. package/dist/runtime/public-surface.js +0 -146
  1739. package/dist/runtime/reasoning-trace.d.ts +0 -46
  1740. package/dist/runtime/reasoning-trace.js +0 -289
  1741. package/dist/runtime/recovery-artifact-store.d.ts +0 -39
  1742. package/dist/runtime/recovery-artifact-store.js +0 -111
  1743. package/dist/runtime/renderers.d.ts +0 -33
  1744. package/dist/runtime/renderers.js +0 -221
  1745. package/dist/runtime/router-v2-scoring.d.ts +0 -16
  1746. package/dist/runtime/router-v2-scoring.js +0 -156
  1747. package/dist/runtime/runtime-backed-task-runner.d.ts +0 -21
  1748. package/dist/runtime/runtime-backed-task-runner.js +0 -456
  1749. package/dist/runtime/runtime-bootstrap.d.ts +0 -33
  1750. package/dist/runtime/runtime-bootstrap.js +0 -267
  1751. package/dist/runtime/runtime-failure-classifier.d.ts +0 -15
  1752. package/dist/runtime/runtime-failure-classifier.js +0 -107
  1753. package/dist/runtime/runtime-health-probes.d.ts +0 -30
  1754. package/dist/runtime/runtime-health-probes.js +0 -102
  1755. package/dist/runtime/runtime-registry.d.ts +0 -23
  1756. package/dist/runtime/runtime-registry.js +0 -95
  1757. package/dist/runtime/runtime-router.d.ts +0 -60
  1758. package/dist/runtime/runtime-router.js +0 -1174
  1759. package/dist/runtime/sandbox-profile.d.ts +0 -54
  1760. package/dist/runtime/sandbox-profile.js +0 -136
  1761. package/dist/runtime/slash-commands.d.ts +0 -46
  1762. package/dist/runtime/slash-commands.js +0 -652
  1763. package/dist/runtime/stable-json.d.ts +0 -9
  1764. package/dist/runtime/stable-json.js +0 -45
  1765. package/dist/runtime/structured-compaction.d.ts +0 -107
  1766. package/dist/runtime/structured-compaction.js +0 -414
  1767. package/dist/runtime/tool-call-repair.d.ts +0 -35
  1768. package/dist/runtime/tool-call-repair.js +0 -181
  1769. package/dist/runtime/tool-dispatch-contracts.d.ts +0 -102
  1770. package/dist/runtime/tool-dispatch-contracts.js +0 -171
  1771. package/dist/runtime/tool-plane.d.ts +0 -31
  1772. package/dist/runtime/tool-plane.js +0 -160
  1773. package/dist/runtime/tool-proxy.d.ts +0 -20
  1774. package/dist/runtime/tool-proxy.js +0 -109
  1775. package/dist/runtime/tool-registry-contract.d.ts +0 -40
  1776. package/dist/runtime/tool-registry-contract.js +0 -52
  1777. package/dist/runtime/ui-components.d.ts +0 -64
  1778. package/dist/runtime/ui-components.js +0 -232
  1779. package/dist/runtime/weakness-remediation-index.d.ts +0 -27
  1780. package/dist/runtime/weakness-remediation-index.js +0 -37
  1781. package/dist/runtime/weights-config.d.ts +0 -90
  1782. package/dist/runtime/weights-config.js +0 -249
  1783. package/dist/runtime/worker-manifest.d.ts +0 -34
  1784. package/dist/runtime/worker-manifest.js +0 -204
  1785. package/dist/safety/approval-policy.d.ts +0 -4
  1786. package/dist/safety/approval-policy.js +0 -33
  1787. package/dist/safety/enforcement-engine.d.ts +0 -89
  1788. package/dist/safety/enforcement-engine.js +0 -279
  1789. package/dist/safety/guard-hooks.d.ts +0 -3
  1790. package/dist/safety/guard-hooks.js +0 -64
  1791. package/dist/safety/tool-authority-gate.d.ts +0 -102
  1792. package/dist/safety/tool-authority-gate.js +0 -200
  1793. package/dist/schema/command.schema.d.ts +0 -121
  1794. package/dist/schema/command.schema.js +0 -25
  1795. package/dist/schema/decision.schema.d.ts +0 -57
  1796. package/dist/schema/decision.schema.js +0 -32
  1797. package/dist/schema/envelope.schema.d.ts +0 -216
  1798. package/dist/schema/envelope.schema.js +0 -38
  1799. package/dist/schema/error.schema.d.ts +0 -51
  1800. package/dist/schema/error.schema.js +0 -12
  1801. package/dist/schema/evidence-bundle.schema.d.ts +0 -196
  1802. package/dist/schema/evidence-bundle.schema.js +0 -38
  1803. package/dist/schema/evidence.schema.d.ts +0 -58
  1804. package/dist/schema/evidence.schema.js +0 -31
  1805. package/dist/schema/index.d.ts +0 -10
  1806. package/dist/schema/index.js +0 -10
  1807. package/dist/schema/proof-bundle.schema.d.ts +0 -150
  1808. package/dist/schema/proof-bundle.schema.js +0 -41
  1809. package/dist/schema/provider.schema.d.ts +0 -138
  1810. package/dist/schema/provider.schema.js +0 -35
  1811. package/dist/schema/run-manifest.schema.d.ts +0 -168
  1812. package/dist/schema/run-manifest.schema.js +0 -35
  1813. package/dist/schema/version.schema.d.ts +0 -64
  1814. package/dist/schema/version.schema.js +0 -21
  1815. package/dist/theme/ansi.d.ts +0 -15
  1816. package/dist/theme/ansi.js +0 -48
  1817. package/dist/theme/colors.d.ts +0 -87
  1818. package/dist/theme/colors.js +0 -105
  1819. package/dist/theme/extended-palette.d.ts +0 -85
  1820. package/dist/theme/extended-palette.js +0 -108
  1821. package/dist/theme/external-theme-adapters.d.ts +0 -27
  1822. package/dist/theme/external-theme-adapters.js +0 -52
  1823. package/dist/theme/hud-theme.d.ts +0 -6
  1824. package/dist/theme/hud-theme.js +0 -41
  1825. package/dist/theme/index.d.ts +0 -12
  1826. package/dist/theme/index.js +0 -20
  1827. package/dist/theme/layout.d.ts +0 -24
  1828. package/dist/theme/layout.js +0 -160
  1829. package/dist/theme/library-effects.d.ts +0 -12
  1830. package/dist/theme/library-effects.js +0 -47
  1831. package/dist/theme/metrics.d.ts +0 -23
  1832. package/dist/theme/metrics.js +0 -93
  1833. package/dist/theme/parallel.d.ts +0 -68
  1834. package/dist/theme/parallel.js +0 -356
  1835. package/dist/theme/working-indicator.d.ts +0 -38
  1836. package/dist/theme/working-indicator.js +0 -149
  1837. package/dist/tui/model.d.ts +0 -28
  1838. package/dist/tui/model.js +0 -1
  1839. package/dist/tui/terminal-frame-renderer.d.ts +0 -27
  1840. package/dist/tui/terminal-frame-renderer.js +0 -130
  1841. package/dist/tui/views/capabilities-view.d.ts +0 -3
  1842. package/dist/tui/views/capabilities-view.js +0 -13
  1843. package/dist/tui/views/common.d.ts +0 -11
  1844. package/dist/tui/views/common.js +0 -35
  1845. package/dist/tui/views/dag-view.d.ts +0 -3
  1846. package/dist/tui/views/dag-view.js +0 -12
  1847. package/dist/tui/views/evidence-view.d.ts +0 -3
  1848. package/dist/tui/views/evidence-view.js +0 -18
  1849. package/dist/tui/views/index.d.ts +0 -4
  1850. package/dist/tui/views/index.js +0 -3
  1851. package/dist/ui/omk-sigil.d.ts +0 -13
  1852. package/dist/ui/omk-sigil.js +0 -268
  1853. package/dist/ui/omk-working-sweep.d.ts +0 -61
  1854. package/dist/ui/omk-working-sweep.js +0 -406
  1855. package/dist/util/agent-schema.d.ts +0 -24
  1856. package/dist/util/agent-schema.js +0 -293
  1857. package/dist/util/appshot-store.d.ts +0 -68
  1858. package/dist/util/appshot-store.js +0 -506
  1859. package/dist/util/chat-agent-mode.d.ts +0 -184
  1860. package/dist/util/chat-agent-mode.js +0 -938
  1861. package/dist/util/chat-cockpit.d.ts +0 -56
  1862. package/dist/util/chat-cockpit.js +0 -389
  1863. package/dist/util/chat-startup.d.ts +0 -35
  1864. package/dist/util/chat-startup.js +0 -330
  1865. package/dist/util/chat-state.d.ts +0 -27
  1866. package/dist/util/chat-state.js +0 -105
  1867. package/dist/util/checkpoint.d.ts +0 -21
  1868. package/dist/util/checkpoint.js +0 -238
  1869. package/dist/util/cli-contract.d.ts +0 -46
  1870. package/dist/util/cli-contract.js +0 -72
  1871. package/dist/util/clipboard-image.d.ts +0 -49
  1872. package/dist/util/clipboard-image.js +0 -263
  1873. package/dist/util/command-envelope.d.ts +0 -19
  1874. package/dist/util/command-envelope.js +0 -31
  1875. package/dist/util/cron-engine.d.ts +0 -24
  1876. package/dist/util/cron-engine.js +0 -227
  1877. package/dist/util/events-logger.d.ts +0 -30
  1878. package/dist/util/events-logger.js +0 -142
  1879. package/dist/util/execution-selection.d.ts +0 -13
  1880. package/dist/util/execution-selection.js +0 -82
  1881. package/dist/util/first-run-star.d.ts +0 -58
  1882. package/dist/util/first-run-star.js +0 -264
  1883. package/dist/util/fs/core.d.ts +0 -5
  1884. package/dist/util/fs/core.js +0 -35
  1885. package/dist/util/fs/internal.d.ts +0 -14
  1886. package/dist/util/fs/internal.js +0 -169
  1887. package/dist/util/fs/kimi-sync.d.ts +0 -41
  1888. package/dist/util/fs/kimi-sync.js +0 -495
  1889. package/dist/util/fs/logo.d.ts +0 -2
  1890. package/dist/util/fs/logo.js +0 -78
  1891. package/dist/util/fs/manifest.d.ts +0 -6
  1892. package/dist/util/fs/manifest.js +0 -40
  1893. package/dist/util/fs/mcp-diagnose.d.ts +0 -15
  1894. package/dist/util/fs/mcp-diagnose.js +0 -205
  1895. package/dist/util/fs/mcp-runtime-config.d.ts +0 -23
  1896. package/dist/util/fs/mcp-runtime-config.js +0 -424
  1897. package/dist/util/fs/paths.d.ts +0 -13
  1898. package/dist/util/fs/paths.js +0 -82
  1899. package/dist/util/fs/preflight.d.ts +0 -27
  1900. package/dist/util/fs/preflight.js +0 -271
  1901. package/dist/util/fs.d.ts +0 -8
  1902. package/dist/util/fs.js +0 -8
  1903. package/dist/util/git.d.ts +0 -11
  1904. package/dist/util/git.js +0 -39
  1905. package/dist/util/hash.d.ts +0 -2
  1906. package/dist/util/hash.js +0 -13
  1907. package/dist/util/help-text.d.ts +0 -1
  1908. package/dist/util/help-text.js +0 -60
  1909. package/dist/util/i18n.d.ts +0 -10
  1910. package/dist/util/i18n.js +0 -848
  1911. package/dist/util/json-envelope.d.ts +0 -15
  1912. package/dist/util/json-envelope.js +0 -28
  1913. package/dist/util/mcp-preflight.d.ts +0 -26
  1914. package/dist/util/mcp-preflight.js +0 -29
  1915. package/dist/util/mode-preset.d.ts +0 -29
  1916. package/dist/util/mode-preset.js +0 -222
  1917. package/dist/util/mode-selector.d.ts +0 -6
  1918. package/dist/util/mode-selector.js +0 -74
  1919. package/dist/util/output-buffer.d.ts +0 -12
  1920. package/dist/util/output-buffer.js +0 -59
  1921. package/dist/util/process-tree.d.ts +0 -18
  1922. package/dist/util/process-tree.js +0 -102
  1923. package/dist/util/project-root.d.ts +0 -27
  1924. package/dist/util/project-root.js +0 -382
  1925. package/dist/util/provider-usage.d.ts +0 -2
  1926. package/dist/util/provider-usage.js +0 -1
  1927. package/dist/util/reasoning-nlp.d.ts +0 -84
  1928. package/dist/util/reasoning-nlp.js +0 -325
  1929. package/dist/util/resource-profile.d.ts +0 -32
  1930. package/dist/util/resource-profile.js +0 -219
  1931. package/dist/util/run-store.d.ts +0 -38
  1932. package/dist/util/run-store.js +0 -151
  1933. package/dist/util/run-view-model.d.ts +0 -111
  1934. package/dist/util/run-view-model.js +0 -333
  1935. package/dist/util/runtime-profile.d.ts +0 -34
  1936. package/dist/util/runtime-profile.js +0 -149
  1937. package/dist/util/runtime-scope.d.ts +0 -2
  1938. package/dist/util/runtime-scope.js +0 -19
  1939. package/dist/util/scoped-agent-file.d.ts +0 -47
  1940. package/dist/util/scoped-agent-file.js +0 -121
  1941. package/dist/util/screenshot-store.d.ts +0 -42
  1942. package/dist/util/screenshot-store.js +0 -340
  1943. package/dist/util/secret-mask.d.ts +0 -5
  1944. package/dist/util/secret-mask.js +0 -41
  1945. package/dist/util/session.d.ts +0 -19
  1946. package/dist/util/session.js +0 -81
  1947. package/dist/util/shell.d.ts +0 -30
  1948. package/dist/util/shell.js +0 -350
  1949. package/dist/util/snippet.d.ts +0 -17
  1950. package/dist/util/snippet.js +0 -110
  1951. package/dist/util/sync-manifest.d.ts +0 -13
  1952. package/dist/util/sync-manifest.js +0 -22
  1953. package/dist/util/terminal-input.d.ts +0 -45
  1954. package/dist/util/terminal-input.js +0 -67
  1955. package/dist/util/terminal-kit-bridge.d.ts +0 -24
  1956. package/dist/util/terminal-kit-bridge.js +0 -60
  1957. package/dist/util/terminal-layout.d.ts +0 -18
  1958. package/dist/util/terminal-layout.js +0 -112
  1959. package/dist/util/terminal-owner.d.ts +0 -20
  1960. package/dist/util/terminal-owner.js +0 -95
  1961. package/dist/util/theme.d.ts +0 -9
  1962. package/dist/util/theme.js +0 -9
  1963. package/dist/util/timeout-config.d.ts +0 -18
  1964. package/dist/util/timeout-config.js +0 -101
  1965. package/dist/util/todo-sync.d.ts +0 -58
  1966. package/dist/util/todo-sync.js +0 -473
  1967. package/dist/util/update-check.d.ts +0 -94
  1968. package/dist/util/update-check.js +0 -355
  1969. package/dist/util/usage-view-model.d.ts +0 -22
  1970. package/dist/util/usage-view-model.js +0 -57
  1971. package/dist/util/user-visible-output.d.ts +0 -19
  1972. package/dist/util/user-visible-output.js +0 -48
  1973. package/dist/util/version.d.ts +0 -4
  1974. package/dist/util/version.js +0 -52
  1975. package/dist/util/worktree.d.ts +0 -10
  1976. package/dist/util/worktree.js +0 -165
  1977. package/dist/ux/explain-loop-decision.d.ts +0 -4
  1978. package/dist/ux/explain-loop-decision.js +0 -55
  1979. package/dist/ux/intent-router.d.ts +0 -15
  1980. package/dist/ux/intent-router.js +0 -64
  1981. package/dist/ux/natural-entrypoint.d.ts +0 -21
  1982. package/dist/ux/natural-entrypoint.js +0 -122
  1983. package/dist/version.d.ts +0 -13
  1984. package/dist/version.js +0 -22
  1985. package/dist/web-bridge/host.d.ts +0 -8
  1986. package/dist/web-bridge/host.js +0 -109
  1987. package/dist/web-bridge/native-host.d.ts +0 -6
  1988. package/dist/web-bridge/native-host.js +0 -40
  1989. package/dist/web-bridge/status.d.ts +0 -84
  1990. package/dist/web-bridge/status.js +0 -201
  1991. package/docs/2026-05-01-16gb-lite-mode.md +0 -37
  1992. package/docs/2026-05-01-critical-issues-and-improvements.md +0 -361
  1993. package/docs/2026-05-01-dag-ensemble-runtime.md +0 -74
  1994. package/docs/2026-05-02-p1-p2-hardening-handoff.md +0 -139
  1995. package/docs/2026-05-05-adjustable-timeouts-and-cron-jobs.md +0 -252
  1996. package/docs/2026-05-08-omk-hardening-plan.md +0 -62
  1997. package/docs/2026-05-14/critical-issues.md +0 -20
  1998. package/docs/2026-05-14/improvements.md +0 -14
  1999. package/docs/2026-05-14/init-checklist.md +0 -25
  2000. package/docs/2026-05-14/plan.md +0 -20
  2001. package/docs/2026-05-15/critical-issues.md +0 -20
  2002. package/docs/2026-05-15/improvements.md +0 -14
  2003. package/docs/2026-05-15/init-checklist.md +0 -25
  2004. package/docs/2026-05-15/plan.md +0 -20
  2005. package/docs/2026-05-16/critical-issues.md +0 -20
  2006. package/docs/2026-05-16/improvements.md +0 -14
  2007. package/docs/2026-05-16/init-checklist.md +0 -25
  2008. package/docs/2026-05-16/plan.md +0 -20
  2009. package/docs/2026-05-17/critical-issues.md +0 -20
  2010. package/docs/2026-05-17/improvements.md +0 -14
  2011. package/docs/2026-05-17/init-checklist.md +0 -25
  2012. package/docs/2026-05-17/plan.md +0 -20
  2013. package/docs/2026-05-18/improvements.md +0 -14
  2014. package/docs/2026-05-18/init-checklist.md +0 -25
  2015. package/docs/2026-05-18/plan.md +0 -20
  2016. package/docs/2026-05-18-critical-issues-and-improvements.md +0 -441
  2017. package/docs/2026-05-18-project-direction.md +0 -223
  2018. package/docs/2026-05-19/critical-issues.md +0 -20
  2019. package/docs/2026-05-19/improvements.md +0 -14
  2020. package/docs/2026-05-19/init-checklist.md +0 -25
  2021. package/docs/2026-05-19/plan.md +0 -20
  2022. package/docs/2026-05-20/critical-issues.md +0 -20
  2023. package/docs/2026-05-20/improvements.md +0 -14
  2024. package/docs/2026-05-20/init-checklist.md +0 -25
  2025. package/docs/2026-05-20/plan.md +0 -20
  2026. package/docs/2026-05-21/critical-issues.md +0 -20
  2027. package/docs/2026-05-21/improvements.md +0 -14
  2028. package/docs/2026-05-21/init-checklist.md +0 -25
  2029. package/docs/2026-05-21/plan.md +0 -20
  2030. package/docs/2026-05-22/critical-issues.md +0 -20
  2031. package/docs/2026-05-22/improvements.md +0 -14
  2032. package/docs/2026-05-22/init-checklist.md +0 -25
  2033. package/docs/2026-05-22/plan.md +0 -20
  2034. package/docs/2026-05-23/critical-issues.md +0 -20
  2035. package/docs/2026-05-23/improvements.md +0 -14
  2036. package/docs/2026-05-23/init-checklist.md +0 -25
  2037. package/docs/2026-05-23/plan.md +0 -20
  2038. package/docs/2026-05-24/critical-issues.md +0 -30
  2039. package/docs/2026-05-24/improvements.md +0 -23
  2040. package/docs/2026-05-24/init-checklist.md +0 -25
  2041. package/docs/2026-05-24/plan.md +0 -22
  2042. package/docs/2026-05-25/critical-issues.md +0 -20
  2043. package/docs/2026-05-25/improvements.md +0 -14
  2044. package/docs/2026-05-25/init-checklist.md +0 -25
  2045. package/docs/2026-05-25/plan.md +0 -20
  2046. package/docs/2026-05-26/critical-issues.md +0 -20
  2047. package/docs/2026-05-26/improvements.md +0 -14
  2048. package/docs/2026-05-26/init-checklist.md +0 -25
  2049. package/docs/2026-05-26/plan.md +0 -20
  2050. package/docs/2026-05-27/critical-issues.md +0 -20
  2051. package/docs/2026-05-27/improvements.md +0 -14
  2052. package/docs/2026-05-27/init-checklist.md +0 -25
  2053. package/docs/2026-05-27/plan.md +0 -20
  2054. package/docs/2026-05-28/critical-issues.md +0 -20
  2055. package/docs/2026-05-28/improvements.md +0 -14
  2056. package/docs/2026-05-28/init-checklist.md +0 -25
  2057. package/docs/2026-05-28/plan.md +0 -20
  2058. package/docs/2026-05-29/critical-issues.md +0 -20
  2059. package/docs/2026-05-29/improvements.md +0 -14
  2060. package/docs/2026-05-29/init-checklist.md +0 -25
  2061. package/docs/2026-05-29/plan.md +0 -20
  2062. package/docs/2026-05-30/critical-issues.md +0 -20
  2063. package/docs/2026-05-30/improvements.md +0 -14
  2064. package/docs/2026-05-30/init-checklist.md +0 -25
  2065. package/docs/2026-05-30/plan.md +0 -20
  2066. package/docs/2026-05-31/critical-issues.md +0 -20
  2067. package/docs/2026-05-31/improvements.md +0 -14
  2068. package/docs/2026-05-31/init-checklist.md +0 -25
  2069. package/docs/2026-05-31/plan.md +0 -20
  2070. package/docs/2026-06-01/critical-issues.md +0 -20
  2071. package/docs/2026-06-01/improvements.md +0 -14
  2072. package/docs/2026-06-01/init-checklist.md +0 -25
  2073. package/docs/2026-06-01/plan.md +0 -20
  2074. package/docs/2026-06-02/critical-issues.md +0 -20
  2075. package/docs/2026-06-02/improvements.md +0 -14
  2076. package/docs/2026-06-02/init-checklist.md +0 -25
  2077. package/docs/2026-06-02/plan.md +0 -20
  2078. package/docs/2026-06-03/critical-issues.md +0 -20
  2079. package/docs/2026-06-03/improvements.md +0 -14
  2080. package/docs/2026-06-03/init-checklist.md +0 -25
  2081. package/docs/2026-06-03/plan.md +0 -20
  2082. package/docs/2026-06-04/critical-issues.md +0 -20
  2083. package/docs/2026-06-04/improvements.md +0 -14
  2084. package/docs/2026-06-04/init-checklist.md +0 -25
  2085. package/docs/2026-06-04/plan.md +0 -20
  2086. package/docs/2026-06-05/critical-issues.md +0 -20
  2087. package/docs/2026-06-05/improvements.md +0 -14
  2088. package/docs/2026-06-05/init-checklist.md +0 -25
  2089. package/docs/2026-06-05/plan.md +0 -20
  2090. package/docs/2026-06-06/critical-issues.md +0 -20
  2091. package/docs/2026-06-06/improvements.md +0 -14
  2092. package/docs/2026-06-06/init-checklist.md +0 -25
  2093. package/docs/2026-06-06/plan.md +0 -20
  2094. package/docs/2026-06-07/critical-issues.md +0 -20
  2095. package/docs/2026-06-07/improvements.md +0 -14
  2096. package/docs/2026-06-07/init-checklist.md +0 -25
  2097. package/docs/2026-06-07/plan.md +0 -20
  2098. package/docs/2026-06-08/critical-issues.md +0 -20
  2099. package/docs/2026-06-08/improvements.md +0 -14
  2100. package/docs/2026-06-08/init-checklist.md +0 -25
  2101. package/docs/2026-06-08/plan.md +0 -20
  2102. package/docs/2026-06-09/critical-issues.md +0 -20
  2103. package/docs/2026-06-09/improvements.md +0 -14
  2104. package/docs/2026-06-09/init-checklist.md +0 -25
  2105. package/docs/2026-06-09/plan.md +0 -20
  2106. package/docs/2026-06-10/critical-issues.md +0 -20
  2107. package/docs/2026-06-10/improvements.md +0 -14
  2108. package/docs/2026-06-10/init-checklist.md +0 -25
  2109. package/docs/2026-06-10/plan.md +0 -20
  2110. package/docs/2026-06-11/critical-issues.md +0 -20
  2111. package/docs/2026-06-11/improvements.md +0 -14
  2112. package/docs/2026-06-11/init-checklist.md +0 -25
  2113. package/docs/2026-06-11/plan.md +0 -20
  2114. package/docs/2026-06-14/critical-issues.md +0 -19
  2115. package/docs/2026-06-14/improvements.md +0 -15
  2116. package/docs/2026-06-14/init-checklist.md +0 -25
  2117. package/docs/2026-06-14/plan.md +0 -20
  2118. package/docs/2026-06-15/critical-issues.md +0 -19
  2119. package/docs/2026-06-15/improvements.md +0 -15
  2120. package/docs/2026-06-15/init-checklist.md +0 -25
  2121. package/docs/2026-06-15/plan.md +0 -20
  2122. package/docs/2026-06-16/critical-issues.md +0 -19
  2123. package/docs/2026-06-16/improvements.md +0 -15
  2124. package/docs/2026-06-16/init-checklist.md +0 -25
  2125. package/docs/2026-06-16/plan.md +0 -20
  2126. package/docs/2026-06-17/critical-issues.md +0 -19
  2127. package/docs/2026-06-17/improvements.md +0 -15
  2128. package/docs/2026-06-17/init-checklist.md +0 -25
  2129. package/docs/2026-06-17/plan.md +0 -20
  2130. package/docs/ARCHITECTURE_ANALYSIS_CODEGRAPH.md +0 -224
  2131. package/docs/GSTACK_MIGRATION.md +0 -169
  2132. package/docs/OMK_CLI_V2_RUNTIME_ARCHITECTURE.md +0 -2058
  2133. package/docs/adr/0001-no-native-rust-lane.md +0 -52
  2134. package/docs/algorithm-hardening-playbook.md +0 -219
  2135. package/docs/benchmark-design.md +0 -122
  2136. package/docs/claims.md +0 -85
  2137. package/docs/cli-v2-migration.md +0 -87
  2138. package/docs/codex-oauth-setup.md +0 -62
  2139. package/docs/comparisons/omk-vs-claude-code.md +0 -31
  2140. package/docs/comparisons/omk-vs-codex.md +0 -33
  2141. package/docs/comparisons/omk-vs-mcp-agent.md +0 -33
  2142. package/docs/comparisons/omk-vs-opencode.md +0 -32
  2143. package/docs/decision-layer-calibration.md +0 -20
  2144. package/docs/decisions/2026-06-10-git-history-bloat.md +0 -61
  2145. package/docs/decisions/ADR-theme-dark-only-assets.md +0 -43
  2146. package/docs/demo/verified-run/README.md +0 -32
  2147. package/docs/demo/verified-run/artifacts/README.md +0 -18
  2148. package/docs/demo/verified-run/capture-plan.md +0 -51
  2149. package/docs/demo/verified-run/generated-diff.md +0 -27
  2150. package/docs/demo/verified-run/raw-prompt.md +0 -21
  2151. package/docs/demo/verified-run/video-shot-list.md +0 -14
  2152. package/docs/design-md.md +0 -35
  2153. package/docs/geo-eval-prompts.md +0 -53
  2154. package/docs/getting-started.md +0 -37
  2155. package/docs/github-organic-promotion.md +0 -127
  2156. package/docs/headroom-omk-final-summary.md +0 -188
  2157. package/docs/headroom-omk-integration.md +0 -394
  2158. package/docs/headroom-omk-setup-guide.md +0 -422
  2159. package/docs/headroom-omk-usage-examples.md +0 -371
  2160. package/docs/hud-and-parallel-ux.md +0 -155
  2161. package/docs/integrations/adaptorch.md +0 -46
  2162. package/docs/integrations/ouroboros.md +0 -96
  2163. package/docs/kimi-oauth-usage-status.md +0 -33
  2164. package/docs/kimi-okabe-dmail.md +0 -44
  2165. package/docs/local-graph-memory.md +0 -102
  2166. package/docs/lsp.md +0 -48
  2167. package/docs/mcp-ontology-proposal.md +0 -12
  2168. package/docs/native-root-runtime-algorithms.md +0 -402
  2169. package/docs/native-root-runtime-hardening.md +0 -141
  2170. package/docs/neo4j-memory.md +0 -5
  2171. package/docs/openai-platform-image-keys.md +0 -23
  2172. package/docs/phase1-final-report.md +0 -154
  2173. package/docs/post-0793-hardening-roadmap.md +0 -123
  2174. package/docs/provider-maturity.md +0 -46
  2175. package/docs/runtime-architecture.md +0 -89
  2176. package/docs/use-cases/evidence-gated-coding-agents.md +0 -52
  2177. package/docs/use-cases/no-kimi-mode.md +0 -38
  2178. package/docs/use-cases/provider-routing-for-ai-coding.md +0 -36
  2179. package/docs/use-cases/replayable-agent-runs.md +0 -40
  2180. package/docs/use-cases/scoped-mcp-for-coding-agents.md +0 -34
  2181. package/docs/versioning.md +0 -55
  2182. package/docs/what-is-omk.md +0 -64
  2183. package/llms.txt +0 -48
  2184. package/readmeasset/.npmignore +0 -27
  2185. package/readmeasset/ASSET_INDEX.md +0 -44
  2186. package/readmeasset/ASSET_PROVENANCE.md +0 -136
  2187. package/readmeasset/omk-adaptorch-ouroboros-supermemory.svg +0 -95
  2188. package/readmeasset/omk-control-surfaces.svg +0 -55
  2189. package/readmeasset/omk-control.webp +0 -0
  2190. package/readmeasset/omk-core-loop.svg +0 -26
  2191. package/readmeasset/omk-evidence-gate-card.png +0 -0
  2192. package/readmeasset/omk-freedomd-control-plane.svg +0 -59
  2193. package/readmeasset/omk-freedomd-control-plane.webp +0 -0
  2194. package/readmeasset/omk-github-banner.webp +0 -0
  2195. package/readmeasset/omk-github-header.webp +0 -0
  2196. package/readmeasset/omk-init-control-loop.svg +0 -118
  2197. package/readmeasset/omk-install-card.png +0 -0
  2198. package/readmeasset/omk-logo-512.png +0 -0
  2199. package/readmeasset/omk-logo-mark.svg +0 -8
  2200. package/readmeasset/omk-parallel-subagents.svg +0 -97
  2201. package/readmeasset/omk-provider-router-card.png +0 -0
  2202. package/readmeasset/omk-release-assertions.svg +0 -51
  2203. package/readmeasset/omk-runtime-flow-0.78.0.webp +0 -0
  2204. package/readmeasset/omk-social-preview.png +0 -0
  2205. package/readmeasset/omk-tui-0.78.0.webp +0 -0
  2206. package/readmeasset/omk_tui.png +0 -0
  2207. package/templates/.kimi/AGENTS.md +0 -93
  2208. package/templates/.omk/agents/okabe.yaml +0 -30
  2209. package/templates/.omk/agents/roles/aggregator.yaml +0 -13
  2210. package/templates/.omk/agents/roles/architect.yaml +0 -13
  2211. package/templates/.omk/agents/roles/coder.yaml +0 -9
  2212. package/templates/.omk/agents/roles/explorer.yaml +0 -13
  2213. package/templates/.omk/agents/roles/integrator.yaml +0 -13
  2214. package/templates/.omk/agents/roles/interviewer.yaml +0 -13
  2215. package/templates/.omk/agents/roles/ontology.yaml +0 -18
  2216. package/templates/.omk/agents/roles/planner.yaml +0 -13
  2217. package/templates/.omk/agents/roles/qa.yaml +0 -12
  2218. package/templates/.omk/agents/roles/researcher.yaml +0 -13
  2219. package/templates/.omk/agents/roles/reviewer.yaml +0 -13
  2220. package/templates/.omk/agents/roles/router.yaml +0 -13
  2221. package/templates/.omk/agents/roles/security.yaml +0 -12
  2222. package/templates/.omk/agents/roles/tester.yaml +0 -12
  2223. package/templates/.omk/agents/roles/vision-debugger.yaml +0 -12
  2224. package/templates/.omk/agents/root.yaml +0 -62
  2225. package/templates/.omk/lsp.json +0 -27
  2226. package/templates/.omk/prompts/root.md +0 -74
  2227. package/templates/AGENTS.md +0 -510
  2228. package/templates/skills/agents/agentmemory/SKILL.md +0 -40
  2229. package/templates/skills/agents/andrej-karpathy-skills/SKILL.md +0 -41
  2230. package/templates/skills/agents/claude-for-legal/SKILL.md +0 -63
  2231. package/templates/skills/agents/claude-for-legal/references/workflow-catalog.md +0 -38
  2232. package/templates/skills/agents/matt-pocock-skills/SKILL.md +0 -40
  2233. package/templates/skills/agents/multica/SKILL.md +0 -40
  2234. package/templates/skills/agents/omk-agent-reach-websearch/SKILL.md +0 -55
  2235. package/templates/skills/agents/omk-backend-api-review/SKILL.md +0 -30
  2236. package/templates/skills/agents/omk-code-review/SKILL.md +0 -40
  2237. package/templates/skills/agents/omk-context-broker/SKILL.md +0 -57
  2238. package/templates/skills/agents/omk-control-loop-debugger/SKILL.md +0 -49
  2239. package/templates/skills/agents/omk-design-system/SKILL.md +0 -22
  2240. package/templates/skills/agents/omk-docs-release/SKILL.md +0 -42
  2241. package/templates/skills/agents/omk-evidence-contract/SKILL.md +0 -52
  2242. package/templates/skills/agents/omk-frontend-implementation/SKILL.md +0 -13
  2243. package/templates/skills/agents/omk-frontend-ui-review/SKILL.md +0 -29
  2244. package/templates/skills/agents/omk-git-commit-pr/SKILL.md +0 -45
  2245. package/templates/skills/agents/omk-industrial-control-loop/SKILL.md +0 -33
  2246. package/templates/skills/agents/omk-plan-first/SKILL.md +0 -39
  2247. package/templates/skills/agents/omk-project-rules/SKILL.md +0 -46
  2248. package/templates/skills/agents/omk-python-typing/SKILL.md +0 -33
  2249. package/templates/skills/agents/omk-quality-gate/SKILL.md +0 -54
  2250. package/templates/skills/agents/omk-repo-explorer/SKILL.md +0 -33
  2251. package/templates/skills/agents/omk-research-verify/SKILL.md +0 -30
  2252. package/templates/skills/agents/omk-secret-guard/SKILL.md +0 -23
  2253. package/templates/skills/agents/omk-security-review/SKILL.md +0 -49
  2254. package/templates/skills/agents/omk-test-debug-loop/SKILL.md +0 -43
  2255. package/templates/skills/agents/omk-troubleshooting/SKILL.md +0 -14
  2256. package/templates/skills/agents/omk-typescript-strict/SKILL.md +0 -38
  2257. package/templates/skills/agents/omk-worktree-team/SKILL.md +0 -44
  2258. package/templates/skills/agents/react-doctor/SKILL.md +0 -46
  2259. package/templates/skills/kimi/agentmemory/SKILL.md +0 -40
  2260. package/templates/skills/kimi/andrej-karpathy-skills/SKILL.md +0 -41
  2261. package/templates/skills/kimi/awesome-design-md/SKILL.md +0 -54
  2262. package/templates/skills/kimi/claude-for-legal/SKILL.md +0 -63
  2263. package/templates/skills/kimi/claude-for-legal/references/workflow-catalog.md +0 -38
  2264. package/templates/skills/kimi/deepseek-api/SKILL.md +0 -27
  2265. package/templates/skills/kimi/deepseek-disable/SKILL.md +0 -20
  2266. package/templates/skills/kimi/deepseek-enable/SKILL.md +0 -20
  2267. package/templates/skills/kimi/deepseekset/SKILL.md +0 -27
  2268. package/templates/skills/kimi/graph-view/SKILL.md +0 -29
  2269. package/templates/skills/kimi/matt-pocock-skills/SKILL.md +0 -40
  2270. package/templates/skills/kimi/multica/SKILL.md +0 -40
  2271. package/templates/skills/kimi/omk-agent-reach-websearch/SKILL.md +0 -55
  2272. package/templates/skills/kimi/omk-backend-api-review/SKILL.md +0 -30
  2273. package/templates/skills/kimi/omk-code-review/SKILL.md +0 -34
  2274. package/templates/skills/kimi/omk-context-broker/SKILL.md +0 -57
  2275. package/templates/skills/kimi/omk-control-loop-debugger/SKILL.md +0 -49
  2276. package/templates/skills/kimi/omk-design-md/SKILL.md +0 -55
  2277. package/templates/skills/kimi/omk-design-system/SKILL.md +0 -22
  2278. package/templates/skills/kimi/omk-docs-release/SKILL.md +0 -42
  2279. package/templates/skills/kimi/omk-evidence-contract/SKILL.md +0 -52
  2280. package/templates/skills/kimi/omk-flow-bugfix/SKILL.md +0 -20
  2281. package/templates/skills/kimi/omk-flow-design-to-code/SKILL.md +0 -23
  2282. package/templates/skills/kimi/omk-flow-feature-dev/SKILL.md +0 -24
  2283. package/templates/skills/kimi/omk-flow-pr-review/SKILL.md +0 -17
  2284. package/templates/skills/kimi/omk-flow-refactor/SKILL.md +0 -21
  2285. package/templates/skills/kimi/omk-flow-release/SKILL.md +0 -20
  2286. package/templates/skills/kimi/omk-flow-team-run/SKILL.md +0 -24
  2287. package/templates/skills/kimi/omk-frontend-implementation/SKILL.md +0 -13
  2288. package/templates/skills/kimi/omk-frontend-ui-review/SKILL.md +0 -29
  2289. package/templates/skills/kimi/omk-git-commit-pr/SKILL.md +0 -45
  2290. package/templates/skills/kimi/omk-global-rules/SKILL.md +0 -31
  2291. package/templates/skills/kimi/omk-industrial-control-loop/SKILL.md +0 -33
  2292. package/templates/skills/kimi/omk-kimi-runtime/SKILL.md +0 -46
  2293. package/templates/skills/kimi/omk-multimodal-ui-review/SKILL.md +0 -26
  2294. package/templates/skills/kimi/omk-plan-first/SKILL.md +0 -39
  2295. package/templates/skills/kimi/omk-project-rules/SKILL.md +0 -21
  2296. package/templates/skills/kimi/omk-python-typing/SKILL.md +0 -33
  2297. package/templates/skills/kimi/omk-quality-gate/SKILL.md +0 -36
  2298. package/templates/skills/kimi/omk-repo-explorer/SKILL.md +0 -33
  2299. package/templates/skills/kimi/omk-research-verify/SKILL.md +0 -30
  2300. package/templates/skills/kimi/omk-secret-guard/SKILL.md +0 -23
  2301. package/templates/skills/kimi/omk-security-review/SKILL.md +0 -49
  2302. package/templates/skills/kimi/omk-task-router/SKILL.md +0 -27
  2303. package/templates/skills/kimi/omk-test-debug-loop/SKILL.md +0 -43
  2304. package/templates/skills/kimi/omk-typescript-strict/SKILL.md +0 -38
  2305. package/templates/skills/kimi/omk-worktree-team/SKILL.md +0 -44
  2306. package/templates/skills/kimi/open-design/SKILL.md +0 -56
  2307. package/templates/skills/kimi/provider/SKILL.md +0 -47
  2308. package/templates/skills/kimi/react-doctor/SKILL.md +0 -46
  2309. package/templates/skills/kimi/speckit-analyze/SKILL.md +0 -255
  2310. package/templates/skills/kimi/speckit-checklist/SKILL.md +0 -367
  2311. package/templates/skills/kimi/speckit-clarify/SKILL.md +0 -249
  2312. package/templates/skills/kimi/speckit-constitution/SKILL.md +0 -152
  2313. package/templates/skills/kimi/speckit-implement/SKILL.md +0 -204
  2314. package/templates/skills/kimi/speckit-plan/SKILL.md +0 -147
  2315. package/templates/skills/kimi/speckit-specify/SKILL.md +0 -325
  2316. package/templates/skills/kimi/speckit-tasks/SKILL.md +0 -197
  2317. package/templates/skills/kimi/speckit-taskstoissues/SKILL.md +0 -101
  2318. package/templates/skills/kimi/think/SKILL.md +0 -41
  2319. package/templates/spec-kit-omk-preset/commands/plan.md +0 -21
  2320. package/templates/spec-kit-omk-preset/commands/tasks.md +0 -21
  2321. package/templates/spec-kit-omk-preset/preset.yml +0 -12
  2322. package/templates/spec-kit-omk-preset/templates/plan-template.md +0 -75
  2323. package/templates/spec-kit-omk-preset/templates/spec-template.md +0 -80
  2324. package/templates/spec-kit-omk-preset/templates/tasks-template.md +0 -160
  2325. package/templates/web-bridge/chrome-extension/README.md +0 -18
  2326. package/templates/web-bridge/chrome-extension/background.js +0 -57
  2327. package/templates/web-bridge/chrome-extension/content-script.js +0 -46
  2328. package/templates/web-bridge/chrome-extension/manifest.json +0 -16
  2329. package/templates/web-bridge/chrome-extension/popup.html +0 -21
  2330. package/templates/web-bridge/chrome-extension/popup.js +0 -9
@@ -0,0 +1,4722 @@
1
+ /**
2
+ * Interactive mode for the coding agent.
3
+ * Handles TUI rendering and user interaction, delegating business logic to AgentSession.
4
+ */
5
+ import * as crypto from "node:crypto";
6
+ import * as fs from "node:fs";
7
+ import * as os from "node:os";
8
+ import * as path from "node:path";
9
+ import { getProviders, } from "@earendil-works/omk-ai";
10
+ import { CombinedAutocompleteProvider, Container, fuzzyFilter, getCapabilities, hyperlink, Loader, Markdown, matchesKey, ProcessTerminal, Spacer, setKeybindings, Text, TruncatedText, TUI, visibleWidth, } from "@earendil-works/omk-tui";
11
+ import chalk from "chalk";
12
+ import { spawn, spawnSync } from "child_process";
13
+ import { APP_NAME, APP_TITLE, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, getShareViewerUrl, VERSION, } from "../../config.js";
14
+ import { parseSkillBlock } from "../../core/agent-session.js";
15
+ import { SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
16
+ import { FooterDataProvider } from "../../core/footer-data-provider.js";
17
+ import { configureHttpDispatcher, formatHttpIdleTimeoutMs } from "../../core/http-dispatcher.js";
18
+ import { KeybindingsManager } from "../../core/keybindings.js";
19
+ import { createCompactionSummaryMessage } from "../../core/messages.js";
20
+ import { defaultModelPerProvider, findExactModelReferenceMatch, resolveModelScope } from "../../core/model-resolver.js";
21
+ import { DefaultPackageManager } from "../../core/package-manager.js";
22
+ import { BUILT_IN_PROVIDER_DISPLAY_NAMES } from "../../core/provider-display-names.js";
23
+ import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
24
+ import { SessionManager } from "../../core/session-manager.js";
25
+ import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
26
+ import { isInstallTelemetryEnabled } from "../../core/telemetry.js";
27
+ import { getChangelogPath, getNewEntries, parseChangelog } from "../../utils/changelog.js";
28
+ import { copyToClipboard } from "../../utils/clipboard.js";
29
+ import { extensionForImageMimeType, readClipboardImage } from "../../utils/clipboard-image.js";
30
+ import { parseGitUrl } from "../../utils/git.js";
31
+ import { getCwdRelativePath } from "../../utils/paths.js";
32
+ import { killTrackedDetachedChildren } from "../../utils/shell.js";
33
+ import { ensureTool } from "../../utils/tools-manager.js";
34
+ import { checkForNewPiVersion } from "../../utils/version-check.js";
35
+ import { ArminComponent } from "./components/armin.js";
36
+ import { AssistantMessageComponent } from "./components/assistant-message.js";
37
+ import { BashExecutionComponent } from "./components/bash-execution.js";
38
+ import { BorderedLoader } from "./components/bordered-loader.js";
39
+ import { BranchSummaryMessageComponent } from "./components/branch-summary-message.js";
40
+ import { CompactionSummaryMessageComponent } from "./components/compaction-summary-message.js";
41
+ import { CountdownTimer } from "./components/countdown-timer.js";
42
+ import { CustomEditor } from "./components/custom-editor.js";
43
+ import { CustomMessageComponent } from "./components/custom-message.js";
44
+ import { DaxnutsComponent } from "./components/daxnuts.js";
45
+ import { DynamicBorder } from "./components/dynamic-border.js";
46
+ import { EarendilAnnouncementComponent } from "./components/earendil-announcement.js";
47
+ import { ExtensionEditorComponent } from "./components/extension-editor.js";
48
+ import { ExtensionInputComponent } from "./components/extension-input.js";
49
+ import { ExtensionSelectorComponent } from "./components/extension-selector.js";
50
+ import { FooterComponent } from "./components/footer.js";
51
+ import { formatKeyText, keyDisplayText, keyHint, keyText, rawKeyHint } from "./components/keybinding-hints.js";
52
+ import { LoginDialogComponent } from "./components/login-dialog.js";
53
+ import { ModelSelectorComponent } from "./components/model-selector.js";
54
+ import { OAuthSelectorComponent } from "./components/oauth-selector.js";
55
+ import { ScopedModelsSelectorComponent } from "./components/scoped-models-selector.js";
56
+ import { SessionSelectorComponent } from "./components/session-selector.js";
57
+ import { SettingsSelectorComponent } from "./components/settings-selector.js";
58
+ import { SkillInvocationMessageComponent } from "./components/skill-invocation-message.js";
59
+ import { ToolExecutionComponent } from "./components/tool-execution.js";
60
+ import { TreeSelectorComponent } from "./components/tree-selector.js";
61
+ import { UserMessageComponent } from "./components/user-message.js";
62
+ import { UserMessageSelectorComponent } from "./components/user-message-selector.js";
63
+ import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, initTheme, onThemeChange, setRegisteredThemes, setTheme, setThemeInstance, stopThemeWatcher, Theme, theme, } from "./theme/theme.js";
64
+ function isExpandable(obj) {
65
+ return typeof obj === "object" && obj !== null && "setExpanded" in obj && typeof obj.setExpanded === "function";
66
+ }
67
+ class ExpandableText extends Text {
68
+ getCollapsedText;
69
+ getExpandedText;
70
+ constructor(getCollapsedText, getExpandedText, expanded = false, paddingX = 0, paddingY = 0) {
71
+ super(expanded ? getExpandedText() : getCollapsedText(), paddingX, paddingY);
72
+ this.getCollapsedText = getCollapsedText;
73
+ this.getExpandedText = getExpandedText;
74
+ }
75
+ setExpanded(expanded) {
76
+ this.setText(expanded ? this.getExpandedText() : this.getCollapsedText());
77
+ }
78
+ }
79
+ const DEAD_TERMINAL_ERROR_CODES = new Set(["EIO", "EPIPE", "ENOTCONN"]);
80
+ function isDeadTerminalError(error) {
81
+ if (!error || typeof error !== "object" || !("code" in error)) {
82
+ return false;
83
+ }
84
+ const code = error.code;
85
+ return code !== undefined && DEAD_TERMINAL_ERROR_CODES.has(code);
86
+ }
87
+ const ANTHROPIC_SUBSCRIPTION_AUTH_WARNING = "Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage.";
88
+ function isAnthropicSubscriptionAuthKey(apiKey) {
89
+ return typeof apiKey === "string" && apiKey.startsWith("sk-ant-oat");
90
+ }
91
+ function isUnknownModel(model) {
92
+ return !!model && model.provider === "unknown" && model.id === "unknown" && model.api === "unknown";
93
+ }
94
+ function quoteIfNeeded(value) {
95
+ if (value.length > 0 && !/[^a-zA-Z0-9_\-./~:@]/.test(value)) {
96
+ return value;
97
+ }
98
+ return `'${value.replace(/'/g, `'\\''`)}'`;
99
+ }
100
+ export function formatResumeCommand(sessionManager) {
101
+ if (!process.stdout.isTTY)
102
+ return undefined;
103
+ if (!sessionManager.isPersisted())
104
+ return undefined;
105
+ const sessionFile = sessionManager.getSessionFile();
106
+ if (!sessionFile || !fs.existsSync(sessionFile))
107
+ return undefined;
108
+ const args = [APP_NAME];
109
+ if (!sessionManager.usesDefaultSessionDir()) {
110
+ args.push("--session-dir", quoteIfNeeded(sessionManager.getSessionDir()));
111
+ }
112
+ args.push("--session", sessionManager.getSessionId());
113
+ return args.join(" ");
114
+ }
115
+ function hasDefaultModelProvider(providerId) {
116
+ return providerId in defaultModelPerProvider;
117
+ }
118
+ const BEDROCK_PROVIDER_ID = "amazon-bedrock";
119
+ const BUILT_IN_MODEL_PROVIDERS = new Set(getProviders());
120
+ export function isApiKeyLoginProvider(providerId, oauthProviderIds, builtInProviderIds = BUILT_IN_MODEL_PROVIDERS) {
121
+ if (BUILT_IN_PROVIDER_DISPLAY_NAMES[providerId]) {
122
+ return true;
123
+ }
124
+ if (builtInProviderIds.has(providerId)) {
125
+ return false;
126
+ }
127
+ return !oauthProviderIds.has(providerId);
128
+ }
129
+ export function buildWorkingLoaderMessage(base, reasoning, level) {
130
+ if (!reasoning || level === undefined || level === "off") {
131
+ return base;
132
+ }
133
+ return `${base} · thinking: ${level}`;
134
+ }
135
+ export class InteractiveMode {
136
+ runtimeHost;
137
+ ui;
138
+ chatContainer;
139
+ pendingMessagesContainer;
140
+ statusContainer;
141
+ defaultEditor;
142
+ editor;
143
+ editorComponentFactory;
144
+ autocompleteProvider;
145
+ autocompleteProviderWrappers = [];
146
+ fdPath;
147
+ editorContainer;
148
+ footer;
149
+ footerDataProvider;
150
+ metricsTimer = null;
151
+ // Stored so the same manager can be injected into custom editors, selectors, and extension UI.
152
+ keybindings;
153
+ version;
154
+ isInitialized = false;
155
+ onInputCallback;
156
+ pendingUserInputs = [];
157
+ loadingAnimation = undefined;
158
+ workingMessage = undefined;
159
+ workingVisible = true;
160
+ workingIndicatorOptions = undefined;
161
+ defaultWorkingMessage = "Working...";
162
+ defaultHiddenThinkingLabel = "Thinking...";
163
+ hiddenThinkingLabel = this.defaultHiddenThinkingLabel;
164
+ lastSigintTime = 0;
165
+ lastEscapeTime = 0;
166
+ changelogMarkdown = undefined;
167
+ startupNoticesShown = false;
168
+ anthropicSubscriptionWarningShown = false;
169
+ // Status line tracking (for mutating immediately-sequential status updates)
170
+ lastStatusSpacer = undefined;
171
+ lastStatusText = undefined;
172
+ // Streaming message tracking
173
+ streamingComponent = undefined;
174
+ streamingMessage = undefined;
175
+ // Tool execution tracking: toolCallId -> component
176
+ pendingTools = new Map();
177
+ // Tool output expansion state
178
+ toolOutputExpanded = false;
179
+ // Thinking block visibility state
180
+ hideThinkingBlock = false;
181
+ // Skill commands: command name -> skill file path
182
+ skillCommands = new Map();
183
+ // Agent subscription unsubscribe function
184
+ unsubscribe;
185
+ signalCleanupHandlers = [];
186
+ // Track if editor is in bash mode (text starts with !)
187
+ isBashMode = false;
188
+ // Track current bash execution component
189
+ bashComponent = undefined;
190
+ // Track pending bash components (shown in pending area, moved to chat on submit)
191
+ pendingBashComponents = [];
192
+ // Auto-compaction state
193
+ autoCompactionLoader = undefined;
194
+ autoCompactionEscapeHandler;
195
+ // Auto-retry state
196
+ retryLoader = undefined;
197
+ retryCountdown = undefined;
198
+ retryEscapeHandler;
199
+ // Messages queued while compaction is running
200
+ compactionQueuedMessages = [];
201
+ // Shutdown state
202
+ shutdownRequested = false;
203
+ // Extension UI state
204
+ extensionSelector = undefined;
205
+ extensionInput = undefined;
206
+ extensionEditor = undefined;
207
+ extensionTerminalInputUnsubscribers = new Set();
208
+ // Extension widgets (components rendered above/below the editor)
209
+ extensionWidgetsAbove = new Map();
210
+ extensionWidgetsBelow = new Map();
211
+ widgetContainerAbove;
212
+ widgetContainerBelow;
213
+ // Custom footer from extension (undefined = use built-in footer)
214
+ customFooter = undefined;
215
+ // Header container that holds the built-in or custom header
216
+ headerContainer;
217
+ // Built-in header (logo + keybinding hints + changelog)
218
+ builtInHeader = undefined;
219
+ // Custom header from extension (undefined = use built-in header)
220
+ customHeader = undefined;
221
+ options;
222
+ // Convenience accessors
223
+ get session() {
224
+ return this.runtimeHost.session;
225
+ }
226
+ get agent() {
227
+ return this.session.agent;
228
+ }
229
+ get sessionManager() {
230
+ return this.session.sessionManager;
231
+ }
232
+ get settingsManager() {
233
+ return this.session.settingsManager;
234
+ }
235
+ constructor(runtimeHost, options = {}) {
236
+ this.runtimeHost = runtimeHost;
237
+ this.options = options;
238
+ this.runtimeHost.setBeforeSessionInvalidate(() => {
239
+ this.resetExtensionUI();
240
+ });
241
+ this.runtimeHost.setRebindSession(async () => {
242
+ await this.rebindCurrentSession();
243
+ });
244
+ this.version = VERSION;
245
+ this.ui = new TUI(new ProcessTerminal(), this.settingsManager.getShowHardwareCursor());
246
+ this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
247
+ this.headerContainer = new Container();
248
+ this.chatContainer = new Container();
249
+ this.pendingMessagesContainer = new Container();
250
+ this.statusContainer = new Container();
251
+ this.widgetContainerAbove = new Container();
252
+ this.widgetContainerBelow = new Container();
253
+ this.keybindings = KeybindingsManager.create();
254
+ setKeybindings(this.keybindings);
255
+ const editorPaddingX = this.settingsManager.getEditorPaddingX();
256
+ const autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();
257
+ this.defaultEditor = new CustomEditor(this.ui, getEditorTheme(), this.keybindings, {
258
+ paddingX: editorPaddingX,
259
+ autocompleteMaxVisible,
260
+ });
261
+ this.editor = this.defaultEditor;
262
+ this.editorContainer = new Container();
263
+ this.editorContainer.addChild(this.editor);
264
+ this.footerDataProvider = new FooterDataProvider(this.sessionManager.getCwd());
265
+ this.footer = new FooterComponent(this.session, this.footerDataProvider);
266
+ this.footer.setAutoCompactEnabled(this.session.autoCompactionEnabled);
267
+ // Load hide thinking block setting
268
+ this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
269
+ // Register themes from resource loader and initialize
270
+ setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
271
+ initTheme(this.settingsManager.getTheme(), true);
272
+ }
273
+ getAutocompleteSourceTag(sourceInfo) {
274
+ if (!sourceInfo) {
275
+ return undefined;
276
+ }
277
+ const scopePrefix = sourceInfo.scope === "user" ? "u" : sourceInfo.scope === "project" ? "p" : "t";
278
+ const source = sourceInfo.source.trim();
279
+ if (source === "auto" || source === "local" || source === "cli") {
280
+ return scopePrefix;
281
+ }
282
+ if (source.startsWith("npm:")) {
283
+ return `${scopePrefix}:${source}`;
284
+ }
285
+ const gitSource = parseGitUrl(source);
286
+ if (gitSource) {
287
+ const ref = gitSource.ref ? `@${gitSource.ref}` : "";
288
+ return `${scopePrefix}:git:${gitSource.host}/${gitSource.path}${ref}`;
289
+ }
290
+ return scopePrefix;
291
+ }
292
+ prefixAutocompleteDescription(description, sourceInfo) {
293
+ const sourceTag = this.getAutocompleteSourceTag(sourceInfo);
294
+ if (!sourceTag) {
295
+ return description;
296
+ }
297
+ return description ? `[${sourceTag}] ${description}` : `[${sourceTag}]`;
298
+ }
299
+ getBuiltInCommandConflictDiagnostics(extensionRunner) {
300
+ const builtinNames = new Set(BUILTIN_SLASH_COMMANDS.map((command) => command.name));
301
+ return extensionRunner
302
+ .getRegisteredCommands()
303
+ .filter((command) => builtinNames.has(command.name))
304
+ .map((command) => ({
305
+ type: "warning",
306
+ message: command.invocationName === command.name
307
+ ? `Extension command '/${command.name}' conflicts with built-in interactive command. Skipping in autocomplete.`
308
+ : `Extension command '/${command.name}' conflicts with built-in interactive command. Available as '/${command.invocationName}'.`,
309
+ path: command.sourceInfo.path,
310
+ }));
311
+ }
312
+ createBaseAutocompleteProvider() {
313
+ // Define commands for autocomplete
314
+ const slashCommands = BUILTIN_SLASH_COMMANDS.map((command) => ({
315
+ name: command.name,
316
+ description: command.description,
317
+ }));
318
+ const modelCommand = slashCommands.find((command) => command.name === "model");
319
+ if (modelCommand) {
320
+ modelCommand.getArgumentCompletions = (prefix) => {
321
+ // Get available models (scoped or from registry)
322
+ const models = this.session.scopedModels.length > 0
323
+ ? this.session.scopedModels.map((s) => s.model)
324
+ : this.session.modelRegistry.getAvailable();
325
+ if (models.length === 0)
326
+ return null;
327
+ // Create items with provider/id format
328
+ const items = models.map((m) => ({
329
+ id: m.id,
330
+ provider: m.provider,
331
+ label: `${m.provider}/${m.id}`,
332
+ }));
333
+ // Fuzzy filter by model ID + provider (allows "opus anthropic" to match)
334
+ const filtered = fuzzyFilter(items, prefix, (item) => `${item.id} ${item.provider}`);
335
+ if (filtered.length === 0)
336
+ return null;
337
+ return filtered.map((item) => ({
338
+ value: item.label,
339
+ label: item.id,
340
+ description: item.provider,
341
+ }));
342
+ };
343
+ }
344
+ // Convert prompt templates to SlashCommand format for autocomplete
345
+ const templateCommands = this.session.promptTemplates.map((cmd) => ({
346
+ name: cmd.name,
347
+ description: this.prefixAutocompleteDescription(cmd.description, cmd.sourceInfo),
348
+ ...(cmd.argumentHint && { argumentHint: cmd.argumentHint }),
349
+ }));
350
+ // Convert extension commands to SlashCommand format
351
+ const builtinCommandNames = new Set(slashCommands.map((c) => c.name));
352
+ const extensionCommands = this.session.extensionRunner
353
+ .getRegisteredCommands()
354
+ .filter((cmd) => !builtinCommandNames.has(cmd.name))
355
+ .map((cmd) => ({
356
+ name: cmd.invocationName,
357
+ description: this.prefixAutocompleteDescription(cmd.description, cmd.sourceInfo),
358
+ getArgumentCompletions: cmd.getArgumentCompletions,
359
+ }));
360
+ // Build skill commands from session.skills (if enabled)
361
+ this.skillCommands.clear();
362
+ const skillCommandList = [];
363
+ if (this.settingsManager.getEnableSkillCommands()) {
364
+ for (const skill of this.session.resourceLoader.getSkills().skills) {
365
+ const commandName = `skill:${skill.name}`;
366
+ this.skillCommands.set(commandName, skill.filePath);
367
+ skillCommandList.push({
368
+ name: commandName,
369
+ description: this.prefixAutocompleteDescription(skill.description, skill.sourceInfo),
370
+ });
371
+ }
372
+ }
373
+ return new CombinedAutocompleteProvider([...slashCommands, ...templateCommands, ...extensionCommands, ...skillCommandList], this.sessionManager.getCwd(), this.fdPath);
374
+ }
375
+ setupAutocompleteProvider() {
376
+ let provider = this.createBaseAutocompleteProvider();
377
+ for (const wrapProvider of this.autocompleteProviderWrappers) {
378
+ provider = wrapProvider(provider);
379
+ }
380
+ this.autocompleteProvider = provider;
381
+ this.defaultEditor.setAutocompleteProvider(provider);
382
+ if (this.editor !== this.defaultEditor) {
383
+ this.editor.setAutocompleteProvider?.(provider);
384
+ }
385
+ }
386
+ showStartupNoticesIfNeeded() {
387
+ if (this.startupNoticesShown) {
388
+ return;
389
+ }
390
+ this.startupNoticesShown = true;
391
+ if (!this.changelogMarkdown) {
392
+ return;
393
+ }
394
+ if (this.chatContainer.children.length > 0) {
395
+ this.chatContainer.addChild(new Spacer(1));
396
+ }
397
+ this.chatContainer.addChild(new DynamicBorder());
398
+ if (this.settingsManager.getCollapseChangelog()) {
399
+ const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
400
+ const latestVersion = versionMatch ? versionMatch[1] : this.version;
401
+ const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
402
+ this.chatContainer.addChild(new Text(condensedText, 1, 0));
403
+ }
404
+ else {
405
+ this.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
406
+ this.chatContainer.addChild(new Spacer(1));
407
+ this.chatContainer.addChild(new Markdown(this.changelogMarkdown.trim(), 1, 0, this.getMarkdownThemeWithSettings()));
408
+ this.chatContainer.addChild(new Spacer(1));
409
+ }
410
+ this.chatContainer.addChild(new DynamicBorder());
411
+ }
412
+ async init() {
413
+ if (this.isInitialized)
414
+ return;
415
+ this.registerSignalHandlers();
416
+ // Load changelog (only show new entries, skip for resumed sessions)
417
+ this.changelogMarkdown = this.getChangelogForDisplay();
418
+ // Ensure fd and rg are available (downloads if missing, adds to PATH via getBinDir)
419
+ // Both are needed: fd for autocomplete, rg for grep tool and bash commands
420
+ const [fdPath] = await Promise.all([ensureTool("fd"), ensureTool("rg")]);
421
+ this.fdPath = fdPath;
422
+ if (this.session.scopedModels.length > 0 && (this.options.verbose || !this.settingsManager.getQuietStartup())) {
423
+ const modelList = this.session.scopedModels
424
+ .map((sm) => {
425
+ const thinkingStr = sm.thinkingLevel ? `:${sm.thinkingLevel}` : "";
426
+ return `${sm.model.id}${thinkingStr}`;
427
+ })
428
+ .join(", ");
429
+ const cycleKeys = this.keybindings.getKeys("app.model.cycleForward");
430
+ const cycleHint = cycleKeys.length > 0
431
+ ? theme.fg("muted", ` (${formatKeyText(cycleKeys.join("/"), { capitalize: true })} to cycle)`)
432
+ : "";
433
+ console.log(theme.fg("dim", `Model scope: ${modelList}${cycleHint}`));
434
+ }
435
+ // Add header container as first child
436
+ this.ui.addChild(this.headerContainer);
437
+ // Add header with keybindings from config (unless silenced)
438
+ if (this.options.verbose || !this.settingsManager.getQuietStartup()) {
439
+ const logo = theme.bold(theme.fg("accent", APP_NAME)) + theme.fg("dim", ` v${this.version}`);
440
+ // Build startup instructions using keybinding hint helpers
441
+ const hint = (keybinding, description) => keyHint(keybinding, description);
442
+ const expandedInstructions = [
443
+ hint("app.interrupt", "to interrupt"),
444
+ hint("app.clear", "to clear"),
445
+ rawKeyHint(`${keyText("app.clear")} twice`, "to exit"),
446
+ hint("app.exit", "to exit (empty)"),
447
+ hint("app.suspend", "to suspend"),
448
+ keyHint("tui.editor.deleteToLineEnd", "to delete to end"),
449
+ hint("app.thinking.cycle", "to cycle thinking level"),
450
+ rawKeyHint(`${keyText("app.model.cycleForward")}/${keyText("app.model.cycleBackward")}`, "to cycle models"),
451
+ hint("app.model.select", "to select model"),
452
+ hint("app.tools.expand", "to expand tools"),
453
+ hint("app.thinking.toggle", "to expand thinking"),
454
+ hint("app.editor.external", "for external editor"),
455
+ rawKeyHint("/", "for commands"),
456
+ rawKeyHint("!", "to run bash"),
457
+ rawKeyHint("!!", "to run bash (no context)"),
458
+ hint("app.message.followUp", "to queue follow-up"),
459
+ hint("app.message.dequeue", "to edit all queued messages"),
460
+ hint("app.clipboard.pasteImage", "to paste image"),
461
+ rawKeyHint("drop files", "to attach"),
462
+ ].join("\n");
463
+ const compactInstructions = [
464
+ hint("app.interrupt", "interrupt"),
465
+ rawKeyHint(`${keyText("app.clear")}/${keyText("app.exit")}`, "clear/exit"),
466
+ rawKeyHint("/", "commands"),
467
+ rawKeyHint("!", "bash"),
468
+ hint("app.tools.expand", "more"),
469
+ ].join(theme.fg("muted", " · "));
470
+ const compactOnboarding = theme.fg("dim", `Press ${keyText("app.tools.expand")} to show full startup help and loaded resources.`);
471
+ const onboarding = theme.fg("dim", `OMK can explain its own features and look up its docs. Ask it how to use or extend OMK.`);
472
+ this.builtInHeader = new ExpandableText(() => `${logo}\n${compactInstructions}\n${compactOnboarding}\n\n${onboarding}`, () => `${logo}\n${expandedInstructions}\n\n${onboarding}`, this.getStartupExpansionState(), 1, 0);
473
+ // Setup UI layout
474
+ this.headerContainer.addChild(new Spacer(1));
475
+ this.headerContainer.addChild(this.builtInHeader);
476
+ this.headerContainer.addChild(new Spacer(1));
477
+ }
478
+ else {
479
+ // Minimal header when silenced
480
+ this.builtInHeader = new Text("", 0, 0);
481
+ this.headerContainer.addChild(this.builtInHeader);
482
+ }
483
+ this.ui.addChild(this.chatContainer);
484
+ this.ui.addChild(this.pendingMessagesContainer);
485
+ this.ui.addChild(this.statusContainer);
486
+ this.renderWidgets(); // Initialize with default spacer
487
+ this.ui.addChild(this.widgetContainerAbove);
488
+ this.ui.addChild(this.editorContainer);
489
+ this.ui.addChild(this.widgetContainerBelow);
490
+ this.ui.addChild(this.footer);
491
+ this.ui.setFocus(this.editor);
492
+ this.setupKeyHandlers();
493
+ this.setupEditorSubmitHandler();
494
+ // Start the UI before initializing extensions so session_start handlers can use interactive dialogs
495
+ this.ui.start();
496
+ this.isInitialized = true;
497
+ // Initialize extensions first so resources are shown before messages
498
+ await this.rebindCurrentSession();
499
+ // Render initial messages AFTER showing loaded resources
500
+ this.renderInitialMessages();
501
+ // Set up theme file watcher
502
+ onThemeChange(() => {
503
+ this.ui.invalidate();
504
+ this.updateEditorBorderColor();
505
+ this.ui.requestRender();
506
+ });
507
+ // Set up git branch watcher (uses provider instead of footer)
508
+ this.footerDataProvider.onBranchChange(() => {
509
+ this.ui.requestRender();
510
+ });
511
+ // Periodically refresh footer metrics (CPU / memory).
512
+ this.metricsTimer = setInterval(() => {
513
+ this.footer.invalidate();
514
+ this.ui.requestRender();
515
+ }, 2000);
516
+ this.metricsTimer.unref();
517
+ // Initialize available provider count for footer display
518
+ await this.updateAvailableProviderCount();
519
+ }
520
+ /**
521
+ * Update terminal title with session name and cwd.
522
+ */
523
+ updateTerminalTitle() {
524
+ const cwdBasename = path.basename(this.sessionManager.getCwd());
525
+ const sessionName = this.sessionManager.getSessionName();
526
+ if (sessionName) {
527
+ this.ui.terminal.setTitle(`${APP_TITLE} - ${sessionName} - ${cwdBasename}`);
528
+ }
529
+ else {
530
+ this.ui.terminal.setTitle(`${APP_TITLE} - ${cwdBasename}`);
531
+ }
532
+ }
533
+ /**
534
+ * Run the interactive mode. This is the main entry point.
535
+ * Initializes the UI, shows warnings, processes initial messages, and starts the interactive loop.
536
+ */
537
+ async run() {
538
+ await this.init();
539
+ // Start version check asynchronously
540
+ checkForNewPiVersion(this.version).then((newRelease) => {
541
+ if (newRelease) {
542
+ this.showNewVersionNotification(newRelease);
543
+ }
544
+ });
545
+ // Start package update check asynchronously
546
+ this.checkForPackageUpdates().then((updates) => {
547
+ if (updates.length > 0) {
548
+ this.showPackageUpdateNotification(updates);
549
+ }
550
+ });
551
+ // Check tmux keyboard setup asynchronously
552
+ this.checkTmuxKeyboardSetup().then((warning) => {
553
+ if (warning) {
554
+ this.showWarning(warning);
555
+ }
556
+ });
557
+ // Show startup warnings
558
+ const { migratedProviders, modelFallbackMessage, initialMessage, initialImages, initialMessages } = this.options;
559
+ if (migratedProviders && migratedProviders.length > 0) {
560
+ this.showWarning(`Migrated credentials to auth.json: ${migratedProviders.join(", ")}`);
561
+ }
562
+ const modelsJsonError = this.session.modelRegistry.getError();
563
+ if (modelsJsonError) {
564
+ this.showError(`models.json error: ${modelsJsonError}`);
565
+ }
566
+ if (modelFallbackMessage) {
567
+ this.showWarning(modelFallbackMessage);
568
+ }
569
+ void this.maybeWarnAboutAnthropicSubscriptionAuth();
570
+ // Process initial messages
571
+ if (initialMessage) {
572
+ try {
573
+ await this.session.prompt(initialMessage, { images: initialImages });
574
+ }
575
+ catch (error) {
576
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
577
+ this.showError(errorMessage);
578
+ }
579
+ }
580
+ if (initialMessages) {
581
+ for (const message of initialMessages) {
582
+ try {
583
+ await this.session.prompt(message);
584
+ }
585
+ catch (error) {
586
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
587
+ this.showError(errorMessage);
588
+ }
589
+ }
590
+ }
591
+ // Main interactive loop
592
+ while (true) {
593
+ const userInput = await this.getUserInput();
594
+ try {
595
+ await this.session.prompt(userInput);
596
+ }
597
+ catch (error) {
598
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
599
+ this.showError(errorMessage);
600
+ }
601
+ }
602
+ }
603
+ async checkForPackageUpdates() {
604
+ if (process.env.OMK_OFFLINE || process.env.PI_OFFLINE) {
605
+ return [];
606
+ }
607
+ try {
608
+ const packageManager = new DefaultPackageManager({
609
+ cwd: this.sessionManager.getCwd(),
610
+ agentDir: getAgentDir(),
611
+ settingsManager: this.settingsManager,
612
+ });
613
+ const updates = await packageManager.checkForAvailableUpdates();
614
+ return updates.map((update) => update.displayName);
615
+ }
616
+ catch {
617
+ return [];
618
+ }
619
+ }
620
+ async checkTmuxKeyboardSetup() {
621
+ if (!process.env.TMUX)
622
+ return undefined;
623
+ const runTmuxShow = (option) => {
624
+ return new Promise((resolve) => {
625
+ const proc = spawn("tmux", ["show", "-gv", option], {
626
+ stdio: ["ignore", "pipe", "ignore"],
627
+ });
628
+ let stdout = "";
629
+ const timer = setTimeout(() => {
630
+ proc.kill();
631
+ resolve(undefined);
632
+ }, 2000);
633
+ proc.stdout?.on("data", (data) => {
634
+ stdout += data.toString();
635
+ });
636
+ proc.on("error", () => {
637
+ clearTimeout(timer);
638
+ resolve(undefined);
639
+ });
640
+ proc.on("close", (code) => {
641
+ clearTimeout(timer);
642
+ resolve(code === 0 ? stdout.trim() : undefined);
643
+ });
644
+ });
645
+ };
646
+ const [extendedKeys, extendedKeysFormat] = await Promise.all([
647
+ runTmuxShow("extended-keys"),
648
+ runTmuxShow("extended-keys-format"),
649
+ ]);
650
+ // If we couldn't query tmux (timeout, sandbox, etc.), don't warn
651
+ if (extendedKeys === undefined)
652
+ return undefined;
653
+ if (extendedKeys !== "on" && extendedKeys !== "always") {
654
+ return "tmux extended-keys is off. Modified Enter keys may not work. Add `set -g extended-keys on` to ~/.tmux.conf and restart tmux.";
655
+ }
656
+ if (extendedKeysFormat === "xterm") {
657
+ return "tmux extended-keys-format is xterm. OMK works best with csi-u. Add `set -g extended-keys-format csi-u` to ~/.tmux.conf and restart tmux.";
658
+ }
659
+ return undefined;
660
+ }
661
+ /**
662
+ * Get changelog entries to display on startup.
663
+ * Only shows new entries since last seen version, skips for resumed sessions.
664
+ */
665
+ getChangelogForDisplay() {
666
+ // Skip changelog for resumed/continued sessions (already have messages)
667
+ if (this.session.state.messages.length > 0) {
668
+ return undefined;
669
+ }
670
+ const lastVersion = this.settingsManager.getLastChangelogVersion();
671
+ const changelogPath = getChangelogPath();
672
+ const entries = parseChangelog(changelogPath);
673
+ if (!lastVersion) {
674
+ // Fresh install - record the version, send telemetry, don't show changelog
675
+ this.settingsManager.setLastChangelogVersion(VERSION);
676
+ this.reportInstallTelemetry(VERSION);
677
+ return undefined;
678
+ }
679
+ const newEntries = getNewEntries(entries, lastVersion);
680
+ if (newEntries.length > 0) {
681
+ this.settingsManager.setLastChangelogVersion(VERSION);
682
+ this.reportInstallTelemetry(VERSION);
683
+ return newEntries.map((e) => e.content).join("\n\n");
684
+ }
685
+ return undefined;
686
+ }
687
+ reportInstallTelemetry(version) {
688
+ if (process.env.OMK_OFFLINE || process.env.PI_OFFLINE) {
689
+ return;
690
+ }
691
+ if (!isInstallTelemetryEnabled(this.settingsManager)) {
692
+ return;
693
+ }
694
+ void version;
695
+ // Install telemetry is intentionally disabled for OMK npm builds until an OMK-owned endpoint exists.
696
+ }
697
+ getMarkdownThemeWithSettings() {
698
+ return {
699
+ ...getMarkdownTheme(),
700
+ codeBlockIndent: this.settingsManager.getCodeBlockIndent(),
701
+ };
702
+ }
703
+ // =========================================================================
704
+ // Extension System
705
+ // =========================================================================
706
+ formatDisplayPath(p) {
707
+ const home = os.homedir();
708
+ let result = p;
709
+ // Replace home directory with ~
710
+ if (result.startsWith(home)) {
711
+ result = `~${result.slice(home.length)}`;
712
+ }
713
+ return result;
714
+ }
715
+ formatExtensionDisplayPath(path) {
716
+ let result = this.formatDisplayPath(path);
717
+ result = result.replace(/\/index\.ts$/, "").replace(/\/index\.js$/, "");
718
+ return result;
719
+ }
720
+ formatContextPath(p) {
721
+ const cwd = path.resolve(this.sessionManager.getCwd());
722
+ const absolutePath = path.isAbsolute(p) ? path.resolve(p) : path.resolve(cwd, p);
723
+ const relativePath = getCwdRelativePath(absolutePath, cwd);
724
+ if (relativePath !== undefined) {
725
+ return relativePath;
726
+ }
727
+ return this.formatDisplayPath(absolutePath);
728
+ }
729
+ getStartupExpansionState() {
730
+ return this.options.verbose || this.toolOutputExpanded;
731
+ }
732
+ /**
733
+ * Get a short path relative to the package root for display.
734
+ */
735
+ getShortPath(fullPath, sourceInfo) {
736
+ const baseDir = sourceInfo?.baseDir;
737
+ if (baseDir && this.isPackageSource(sourceInfo)) {
738
+ const relativePath = path.relative(path.resolve(baseDir), path.resolve(fullPath));
739
+ if (relativePath &&
740
+ relativePath !== "." &&
741
+ !relativePath.startsWith("..") &&
742
+ !relativePath.startsWith(`..${path.sep}`) &&
743
+ !path.isAbsolute(relativePath)) {
744
+ return relativePath.replace(/\\/g, "/");
745
+ }
746
+ }
747
+ const source = sourceInfo?.source ?? "";
748
+ const npmMatch = fullPath.match(/node_modules\/(@?[^/]+(?:\/[^/]+)?)\/(.*)/);
749
+ if (npmMatch && source.startsWith("npm:")) {
750
+ return npmMatch[2];
751
+ }
752
+ const gitMatch = fullPath.match(/git\/[^/]+\/[^/]+\/(.*)/);
753
+ if (gitMatch && source.startsWith("git:")) {
754
+ return gitMatch[1];
755
+ }
756
+ return this.formatDisplayPath(fullPath);
757
+ }
758
+ getCompactPathLabel(resourcePath, sourceInfo) {
759
+ const shortPath = this.getShortPath(resourcePath, sourceInfo);
760
+ const normalizedPath = shortPath.replace(/\\/g, "/");
761
+ const segments = normalizedPath.split("/").filter((segment) => segment.length > 0 && segment !== "~");
762
+ if (segments.length > 0) {
763
+ return segments[segments.length - 1];
764
+ }
765
+ return shortPath;
766
+ }
767
+ getCompactPackageSourceLabel(sourceInfo) {
768
+ const source = sourceInfo?.source ?? "";
769
+ if (source.startsWith("npm:")) {
770
+ return source.slice("npm:".length) || source;
771
+ }
772
+ const gitSource = parseGitUrl(source);
773
+ if (gitSource) {
774
+ return gitSource.path || source;
775
+ }
776
+ return source;
777
+ }
778
+ getCompactExtensionLabel(resourcePath, sourceInfo) {
779
+ if (!this.isPackageSource(sourceInfo)) {
780
+ return this.getCompactPathLabel(resourcePath, sourceInfo);
781
+ }
782
+ const sourceLabel = this.getCompactPackageSourceLabel(sourceInfo);
783
+ if (!sourceLabel) {
784
+ return this.getCompactPathLabel(resourcePath, sourceInfo);
785
+ }
786
+ const shortPath = this.getShortPath(resourcePath, sourceInfo).replace(/\\/g, "/");
787
+ const packagePath = shortPath.startsWith("extensions/") ? shortPath.slice("extensions/".length) : shortPath;
788
+ const parsedPath = path.posix.parse(packagePath);
789
+ if (parsedPath.name === "index") {
790
+ return !parsedPath.dir || parsedPath.dir === "." ? sourceLabel : `${sourceLabel}:${parsedPath.dir}`;
791
+ }
792
+ return `${sourceLabel}:${packagePath}`;
793
+ }
794
+ getCompactDisplayPathSegments(resourcePath) {
795
+ return this.formatDisplayPath(resourcePath)
796
+ .replace(/\\/g, "/")
797
+ .split("/")
798
+ .filter((segment) => segment.length > 0 && segment !== "~");
799
+ }
800
+ getCompactNonPackageExtensionLabel(resourcePath, index, allPaths) {
801
+ const segments = allPaths[index]?.segments;
802
+ if (!segments || segments.length === 0) {
803
+ return this.getCompactPathLabel(resourcePath);
804
+ }
805
+ for (let segmentCount = 1; segmentCount <= segments.length; segmentCount += 1) {
806
+ const candidate = segments.slice(-segmentCount).join("/");
807
+ const isUnique = allPaths.every((item, itemIndex) => {
808
+ if (itemIndex === index) {
809
+ return true;
810
+ }
811
+ return item.segments.slice(-segmentCount).join("/") !== candidate;
812
+ });
813
+ if (isUnique) {
814
+ return candidate;
815
+ }
816
+ }
817
+ return segments.join("/");
818
+ }
819
+ getCompactExtensionLabels(extensions) {
820
+ const nonPackageExtensions = extensions
821
+ .map((extension) => {
822
+ const segments = this.getCompactDisplayPathSegments(extension.path);
823
+ const lastSegment = segments[segments.length - 1];
824
+ if (segments.length > 1 && (lastSegment === "index.ts" || lastSegment === "index.js")) {
825
+ segments.pop();
826
+ }
827
+ return {
828
+ path: extension.path,
829
+ sourceInfo: extension.sourceInfo,
830
+ segments,
831
+ };
832
+ })
833
+ .filter((extension) => !this.isPackageSource(extension.sourceInfo));
834
+ return extensions.map((extension) => {
835
+ if (this.isPackageSource(extension.sourceInfo)) {
836
+ return this.getCompactExtensionLabel(extension.path, extension.sourceInfo);
837
+ }
838
+ const nonPackageIndex = nonPackageExtensions.findIndex((item) => item.path === extension.path);
839
+ if (nonPackageIndex === -1) {
840
+ return this.getCompactPathLabel(extension.path, extension.sourceInfo);
841
+ }
842
+ return this.getCompactNonPackageExtensionLabel(extension.path, nonPackageIndex, nonPackageExtensions);
843
+ });
844
+ }
845
+ getDisplaySourceInfo(sourceInfo) {
846
+ const source = sourceInfo?.source ?? "local";
847
+ const scope = sourceInfo?.scope ?? "project";
848
+ if (source === "local") {
849
+ if (scope === "user") {
850
+ return { label: "user", color: "muted" };
851
+ }
852
+ if (scope === "project") {
853
+ return { label: "project", color: "muted" };
854
+ }
855
+ if (scope === "temporary") {
856
+ return { label: "path", scopeLabel: "temp", color: "muted" };
857
+ }
858
+ return { label: "path", color: "muted" };
859
+ }
860
+ if (source === "cli") {
861
+ return { label: "path", scopeLabel: scope === "temporary" ? "temp" : undefined, color: "muted" };
862
+ }
863
+ const scopeLabel = scope === "user" ? "user" : scope === "project" ? "project" : scope === "temporary" ? "temp" : undefined;
864
+ return { label: source, scopeLabel, color: "accent" };
865
+ }
866
+ getScopeGroup(sourceInfo) {
867
+ const source = sourceInfo?.source ?? "local";
868
+ const scope = sourceInfo?.scope ?? "project";
869
+ if (source === "cli" || scope === "temporary")
870
+ return "path";
871
+ if (scope === "user")
872
+ return "user";
873
+ if (scope === "project")
874
+ return "project";
875
+ return "path";
876
+ }
877
+ isPackageSource(sourceInfo) {
878
+ const source = sourceInfo?.source ?? "";
879
+ return source.startsWith("npm:") || source.startsWith("git:");
880
+ }
881
+ buildScopeGroups(items) {
882
+ const groups = {
883
+ user: { scope: "user", paths: [], packages: new Map() },
884
+ project: { scope: "project", paths: [], packages: new Map() },
885
+ path: { scope: "path", paths: [], packages: new Map() },
886
+ };
887
+ for (const item of items) {
888
+ const groupKey = this.getScopeGroup(item.sourceInfo);
889
+ const group = groups[groupKey];
890
+ const source = item.sourceInfo?.source ?? "local";
891
+ if (this.isPackageSource(item.sourceInfo)) {
892
+ const list = group.packages.get(source) ?? [];
893
+ list.push(item);
894
+ group.packages.set(source, list);
895
+ }
896
+ else {
897
+ group.paths.push(item);
898
+ }
899
+ }
900
+ return [groups.project, groups.user, groups.path].filter((group) => group.paths.length > 0 || group.packages.size > 0);
901
+ }
902
+ formatScopeGroups(groups, options) {
903
+ const lines = [];
904
+ for (const group of groups) {
905
+ lines.push(` ${theme.fg("accent", group.scope)}`);
906
+ const sortedPaths = [...group.paths].sort((a, b) => a.path.localeCompare(b.path));
907
+ for (const item of sortedPaths) {
908
+ lines.push(theme.fg("dim", ` ${options.formatPath(item)}`));
909
+ }
910
+ const sortedPackages = Array.from(group.packages.entries()).sort(([a], [b]) => a.localeCompare(b));
911
+ for (const [source, items] of sortedPackages) {
912
+ lines.push(` ${theme.fg("mdLink", source)}`);
913
+ const sortedPackagePaths = [...items].sort((a, b) => a.path.localeCompare(b.path));
914
+ for (const item of sortedPackagePaths) {
915
+ lines.push(theme.fg("dim", ` ${options.formatPackagePath(item, source)}`));
916
+ }
917
+ }
918
+ }
919
+ return lines.join("\n");
920
+ }
921
+ findSourceInfoForPath(p, sourceInfos) {
922
+ const exact = sourceInfos.get(p);
923
+ if (exact)
924
+ return exact;
925
+ let current = p;
926
+ while (current.includes("/")) {
927
+ current = current.substring(0, current.lastIndexOf("/"));
928
+ const parent = sourceInfos.get(current);
929
+ if (parent)
930
+ return parent;
931
+ }
932
+ return undefined;
933
+ }
934
+ formatPathWithSource(p, sourceInfo) {
935
+ if (sourceInfo) {
936
+ const shortPath = this.getShortPath(p, sourceInfo);
937
+ const { label, scopeLabel } = this.getDisplaySourceInfo(sourceInfo);
938
+ const labelText = scopeLabel ? `${label} (${scopeLabel})` : label;
939
+ return `${labelText} ${shortPath}`;
940
+ }
941
+ return this.formatDisplayPath(p);
942
+ }
943
+ formatDiagnostics(diagnostics, sourceInfos) {
944
+ const lines = [];
945
+ // Group collision diagnostics by name
946
+ const collisions = new Map();
947
+ const otherDiagnostics = [];
948
+ for (const d of diagnostics) {
949
+ if (d.type === "collision" && d.collision) {
950
+ const list = collisions.get(d.collision.name) ?? [];
951
+ list.push(d);
952
+ collisions.set(d.collision.name, list);
953
+ }
954
+ else {
955
+ otherDiagnostics.push(d);
956
+ }
957
+ }
958
+ // Format collision diagnostics grouped by name
959
+ for (const [name, collisionList] of collisions) {
960
+ const first = collisionList[0]?.collision;
961
+ if (!first)
962
+ continue;
963
+ lines.push(theme.fg("warning", ` "${name}" collision:`));
964
+ lines.push(theme.fg("dim", ` ${theme.fg("success", "✓")} ${this.formatPathWithSource(first.winnerPath, this.findSourceInfoForPath(first.winnerPath, sourceInfos))}`));
965
+ for (const d of collisionList) {
966
+ if (d.collision) {
967
+ lines.push(theme.fg("dim", ` ${theme.fg("warning", "✗")} ${this.formatPathWithSource(d.collision.loserPath, this.findSourceInfoForPath(d.collision.loserPath, sourceInfos))} (skipped)`));
968
+ }
969
+ }
970
+ }
971
+ for (const d of otherDiagnostics) {
972
+ if (d.path) {
973
+ const formattedPath = this.formatPathWithSource(d.path, this.findSourceInfoForPath(d.path, sourceInfos));
974
+ lines.push(theme.fg(d.type === "error" ? "error" : "warning", ` ${formattedPath}`));
975
+ lines.push(theme.fg(d.type === "error" ? "error" : "warning", ` ${d.message}`));
976
+ }
977
+ else {
978
+ lines.push(theme.fg(d.type === "error" ? "error" : "warning", ` ${d.message}`));
979
+ }
980
+ }
981
+ return lines.join("\n");
982
+ }
983
+ showLoadedResources(options) {
984
+ const showListing = options?.force || this.options.verbose || !this.settingsManager.getQuietStartup();
985
+ const showDiagnostics = showListing || options?.showDiagnosticsWhenQuiet === true;
986
+ if (!showListing && !showDiagnostics) {
987
+ return;
988
+ }
989
+ const sectionHeader = (name, color = "mdHeading") => theme.fg(color, `[${name}]`);
990
+ const formatCompactList = (items, options) => {
991
+ const labels = items.map((item) => item.trim()).filter((item) => item.length > 0);
992
+ if (options?.sort !== false) {
993
+ labels.sort((a, b) => a.localeCompare(b));
994
+ }
995
+ return theme.fg("dim", ` ${labels.join(", ")}`);
996
+ };
997
+ const addLoadedSection = (name, collapsedBody, expandedBody = collapsedBody, color = "mdHeading") => {
998
+ const section = new ExpandableText(() => `${sectionHeader(name, color)}\n${collapsedBody}`, () => `${sectionHeader(name, color)}\n${expandedBody}`, this.getStartupExpansionState(), 0, 0);
999
+ this.chatContainer.addChild(section);
1000
+ this.chatContainer.addChild(new Spacer(1));
1001
+ };
1002
+ const skillsResult = this.session.resourceLoader.getSkills();
1003
+ const promptsResult = this.session.resourceLoader.getPrompts();
1004
+ const themesResult = this.session.resourceLoader.getThemes();
1005
+ const extensions = options?.extensions ??
1006
+ this.session.resourceLoader.getExtensions().extensions.map((extension) => ({
1007
+ path: extension.path,
1008
+ sourceInfo: extension.sourceInfo,
1009
+ }));
1010
+ const sourceInfos = new Map();
1011
+ for (const extension of extensions) {
1012
+ if (extension.sourceInfo) {
1013
+ sourceInfos.set(extension.path, extension.sourceInfo);
1014
+ }
1015
+ }
1016
+ for (const skill of skillsResult.skills) {
1017
+ if (skill.sourceInfo) {
1018
+ sourceInfos.set(skill.filePath, skill.sourceInfo);
1019
+ }
1020
+ }
1021
+ for (const prompt of promptsResult.prompts) {
1022
+ if (prompt.sourceInfo) {
1023
+ sourceInfos.set(prompt.filePath, prompt.sourceInfo);
1024
+ }
1025
+ }
1026
+ for (const loadedTheme of themesResult.themes) {
1027
+ if (loadedTheme.sourcePath && loadedTheme.sourceInfo) {
1028
+ sourceInfos.set(loadedTheme.sourcePath, loadedTheme.sourceInfo);
1029
+ }
1030
+ }
1031
+ if (showListing) {
1032
+ const contextFiles = this.session.resourceLoader.getAgentsFiles().agentsFiles;
1033
+ if (contextFiles.length > 0) {
1034
+ this.chatContainer.addChild(new Spacer(1));
1035
+ const contextList = contextFiles
1036
+ .map((f) => theme.fg("dim", ` ${this.formatDisplayPath(f.path)}`))
1037
+ .join("\n");
1038
+ const contextCompactList = formatCompactList(contextFiles.map((contextFile) => this.formatContextPath(contextFile.path)), { sort: false });
1039
+ addLoadedSection("Context", contextCompactList, contextList);
1040
+ }
1041
+ const skills = skillsResult.skills;
1042
+ if (skills.length > 0) {
1043
+ const groups = this.buildScopeGroups(skills.map((skill) => ({ path: skill.filePath, sourceInfo: skill.sourceInfo })));
1044
+ const skillList = this.formatScopeGroups(groups, {
1045
+ formatPath: (item) => this.formatDisplayPath(item.path),
1046
+ formatPackagePath: (item) => this.getShortPath(item.path, item.sourceInfo),
1047
+ });
1048
+ const skillCompactList = formatCompactList(skills.map((skill) => skill.name));
1049
+ addLoadedSection("Skills", skillCompactList, skillList);
1050
+ }
1051
+ const templates = this.session.promptTemplates;
1052
+ if (templates.length > 0) {
1053
+ const groups = this.buildScopeGroups(templates.map((template) => ({ path: template.filePath, sourceInfo: template.sourceInfo })));
1054
+ const templateByPath = new Map(templates.map((t) => [t.filePath, t]));
1055
+ const templateList = this.formatScopeGroups(groups, {
1056
+ formatPath: (item) => {
1057
+ const template = templateByPath.get(item.path);
1058
+ return template ? `/${template.name}` : this.formatDisplayPath(item.path);
1059
+ },
1060
+ formatPackagePath: (item) => {
1061
+ const template = templateByPath.get(item.path);
1062
+ return template ? `/${template.name}` : this.formatDisplayPath(item.path);
1063
+ },
1064
+ });
1065
+ const promptCompactList = formatCompactList(templates.map((template) => `/${template.name}`));
1066
+ addLoadedSection("Prompts", promptCompactList, templateList);
1067
+ }
1068
+ if (extensions.length > 0) {
1069
+ const groups = this.buildScopeGroups(extensions);
1070
+ const extList = this.formatScopeGroups(groups, {
1071
+ formatPath: (item) => this.formatExtensionDisplayPath(item.path),
1072
+ formatPackagePath: (item) => this.formatExtensionDisplayPath(this.getShortPath(item.path, item.sourceInfo)),
1073
+ });
1074
+ const extensionCompactList = formatCompactList(this.getCompactExtensionLabels(extensions));
1075
+ addLoadedSection("Extensions", extensionCompactList, extList, "mdHeading");
1076
+ }
1077
+ // Show loaded themes (excluding built-in)
1078
+ const loadedThemes = themesResult.themes;
1079
+ const customThemes = loadedThemes.filter((t) => t.sourcePath);
1080
+ if (customThemes.length > 0) {
1081
+ const groups = this.buildScopeGroups(customThemes.map((loadedTheme) => ({
1082
+ path: loadedTheme.sourcePath,
1083
+ sourceInfo: loadedTheme.sourceInfo,
1084
+ })));
1085
+ const themeList = this.formatScopeGroups(groups, {
1086
+ formatPath: (item) => this.formatDisplayPath(item.path),
1087
+ formatPackagePath: (item) => this.getShortPath(item.path, item.sourceInfo),
1088
+ });
1089
+ const themeCompactList = formatCompactList(customThemes.map((loadedTheme) => loadedTheme.name ?? this.getCompactPathLabel(loadedTheme.sourcePath, loadedTheme.sourceInfo)));
1090
+ addLoadedSection("Themes", themeCompactList, themeList);
1091
+ }
1092
+ }
1093
+ if (showDiagnostics) {
1094
+ const skillDiagnostics = skillsResult.diagnostics;
1095
+ if (skillDiagnostics.length > 0) {
1096
+ const warningLines = this.formatDiagnostics(skillDiagnostics, sourceInfos);
1097
+ this.chatContainer.addChild(new Text(`${theme.fg("warning", "[Skill conflicts]")}\n${warningLines}`, 0, 0));
1098
+ this.chatContainer.addChild(new Spacer(1));
1099
+ }
1100
+ const promptDiagnostics = promptsResult.diagnostics;
1101
+ if (promptDiagnostics.length > 0) {
1102
+ const warningLines = this.formatDiagnostics(promptDiagnostics, sourceInfos);
1103
+ this.chatContainer.addChild(new Text(`${theme.fg("warning", "[Prompt conflicts]")}\n${warningLines}`, 0, 0));
1104
+ this.chatContainer.addChild(new Spacer(1));
1105
+ }
1106
+ const extensionDiagnostics = [];
1107
+ const extensionErrors = this.session.resourceLoader.getExtensions().errors;
1108
+ if (extensionErrors.length > 0) {
1109
+ for (const error of extensionErrors) {
1110
+ extensionDiagnostics.push({ type: "error", message: error.error, path: error.path });
1111
+ }
1112
+ }
1113
+ const commandDiagnostics = this.session.extensionRunner.getCommandDiagnostics();
1114
+ extensionDiagnostics.push(...commandDiagnostics);
1115
+ extensionDiagnostics.push(...this.getBuiltInCommandConflictDiagnostics(this.session.extensionRunner));
1116
+ const shortcutDiagnostics = this.session.extensionRunner.getShortcutDiagnostics();
1117
+ extensionDiagnostics.push(...shortcutDiagnostics);
1118
+ if (extensionDiagnostics.length > 0) {
1119
+ const warningLines = this.formatDiagnostics(extensionDiagnostics, sourceInfos);
1120
+ this.chatContainer.addChild(new Text(`${theme.fg("warning", "[Extension issues]")}\n${warningLines}`, 0, 0));
1121
+ this.chatContainer.addChild(new Spacer(1));
1122
+ }
1123
+ const themeDiagnostics = themesResult.diagnostics;
1124
+ if (themeDiagnostics.length > 0) {
1125
+ const warningLines = this.formatDiagnostics(themeDiagnostics, sourceInfos);
1126
+ this.chatContainer.addChild(new Text(`${theme.fg("warning", "[Theme conflicts]")}\n${warningLines}`, 0, 0));
1127
+ this.chatContainer.addChild(new Spacer(1));
1128
+ }
1129
+ }
1130
+ }
1131
+ /**
1132
+ * Initialize the extension system with TUI-based UI context.
1133
+ */
1134
+ async bindCurrentSessionExtensions() {
1135
+ const uiContext = this.createExtensionUIContext();
1136
+ await this.session.bindExtensions({
1137
+ uiContext,
1138
+ mode: "tui",
1139
+ abortHandler: () => {
1140
+ this.restoreQueuedMessagesToEditor({ abort: true });
1141
+ },
1142
+ commandContextActions: {
1143
+ waitForIdle: () => this.session.agent.waitForIdle(),
1144
+ newSession: async (options) => {
1145
+ if (this.loadingAnimation) {
1146
+ this.loadingAnimation.stop();
1147
+ this.loadingAnimation = undefined;
1148
+ }
1149
+ this.statusContainer.clear();
1150
+ try {
1151
+ const result = await this.runtimeHost.newSession(options);
1152
+ if (!result.cancelled) {
1153
+ this.renderCurrentSessionState();
1154
+ this.ui.requestRender();
1155
+ }
1156
+ return result;
1157
+ }
1158
+ catch (error) {
1159
+ return this.handleFatalRuntimeError("Failed to create session", error);
1160
+ }
1161
+ },
1162
+ fork: async (entryId, options) => {
1163
+ try {
1164
+ const result = await this.runtimeHost.fork(entryId, options);
1165
+ if (!result.cancelled) {
1166
+ this.renderCurrentSessionState();
1167
+ this.editor.setText(result.selectedText ?? "");
1168
+ this.showStatus("Forked to new session");
1169
+ }
1170
+ return { cancelled: result.cancelled };
1171
+ }
1172
+ catch (error) {
1173
+ return this.handleFatalRuntimeError("Failed to fork session", error);
1174
+ }
1175
+ },
1176
+ navigateTree: async (targetId, options) => {
1177
+ const result = await this.session.navigateTree(targetId, {
1178
+ summarize: options?.summarize,
1179
+ customInstructions: options?.customInstructions,
1180
+ replaceInstructions: options?.replaceInstructions,
1181
+ label: options?.label,
1182
+ });
1183
+ if (result.cancelled) {
1184
+ return { cancelled: true };
1185
+ }
1186
+ this.chatContainer.clear();
1187
+ this.renderInitialMessages();
1188
+ if (result.editorText && !this.editor.getText().trim()) {
1189
+ this.editor.setText(result.editorText);
1190
+ }
1191
+ this.showStatus("Navigated to selected point");
1192
+ void this.flushCompactionQueue({ willRetry: false });
1193
+ return { cancelled: false };
1194
+ },
1195
+ switchSession: async (sessionPath, options) => {
1196
+ return this.handleResumeSession(sessionPath, options);
1197
+ },
1198
+ reload: async () => {
1199
+ await this.handleReloadCommand();
1200
+ },
1201
+ },
1202
+ shutdownHandler: () => {
1203
+ this.shutdownRequested = true;
1204
+ if (!this.session.isStreaming) {
1205
+ void this.shutdown();
1206
+ }
1207
+ },
1208
+ onError: (error) => {
1209
+ this.showExtensionError(error.extensionPath, error.error, error.stack);
1210
+ },
1211
+ });
1212
+ setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
1213
+ this.setupAutocompleteProvider();
1214
+ const extensionRunner = this.session.extensionRunner;
1215
+ this.setupExtensionShortcuts(extensionRunner);
1216
+ this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });
1217
+ this.showStartupNoticesIfNeeded();
1218
+ }
1219
+ applyRuntimeSettings() {
1220
+ configureHttpDispatcher(this.settingsManager.getHttpIdleTimeoutMs());
1221
+ this.footer.setSession(this.session);
1222
+ this.footer.setAutoCompactEnabled(this.session.autoCompactionEnabled);
1223
+ this.footerDataProvider.setCwd(this.sessionManager.getCwd());
1224
+ this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
1225
+ this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());
1226
+ this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
1227
+ const editorPaddingX = this.settingsManager.getEditorPaddingX();
1228
+ const autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();
1229
+ this.defaultEditor.setPaddingX(editorPaddingX);
1230
+ this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);
1231
+ if (this.editor !== this.defaultEditor) {
1232
+ this.editor.setPaddingX?.(editorPaddingX);
1233
+ this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);
1234
+ }
1235
+ }
1236
+ async rebindCurrentSession() {
1237
+ this.unsubscribe?.();
1238
+ this.unsubscribe = undefined;
1239
+ this.applyRuntimeSettings();
1240
+ await this.bindCurrentSessionExtensions();
1241
+ this.subscribeToAgent();
1242
+ await this.updateAvailableProviderCount();
1243
+ this.updateEditorBorderColor();
1244
+ this.updateTerminalTitle();
1245
+ }
1246
+ async handleFatalRuntimeError(prefix, error) {
1247
+ const message = error instanceof Error ? error.message : String(error);
1248
+ this.showError(`${prefix}: ${message}`);
1249
+ stopThemeWatcher();
1250
+ this.stop();
1251
+ process.exit(1);
1252
+ }
1253
+ renderCurrentSessionState() {
1254
+ this.chatContainer.clear();
1255
+ this.pendingMessagesContainer.clear();
1256
+ this.compactionQueuedMessages = [];
1257
+ this.streamingComponent = undefined;
1258
+ this.streamingMessage = undefined;
1259
+ this.pendingTools.clear();
1260
+ this.renderInitialMessages();
1261
+ }
1262
+ /**
1263
+ * Get a registered tool definition by name (for custom rendering).
1264
+ */
1265
+ getRegisteredToolDefinition(toolName) {
1266
+ return this.session.getToolDefinition(toolName);
1267
+ }
1268
+ /**
1269
+ * Set up keyboard shortcuts registered by extensions.
1270
+ */
1271
+ setupExtensionShortcuts(extensionRunner) {
1272
+ const shortcuts = extensionRunner.getShortcuts(this.keybindings.getEffectiveConfig());
1273
+ if (shortcuts.size === 0)
1274
+ return;
1275
+ // Create a context for shortcut handlers
1276
+ const createContext = () => ({
1277
+ ui: this.createExtensionUIContext(),
1278
+ mode: "tui",
1279
+ hasUI: true,
1280
+ cwd: this.sessionManager.getCwd(),
1281
+ sessionManager: this.sessionManager,
1282
+ modelRegistry: this.session.modelRegistry,
1283
+ model: this.session.model,
1284
+ isIdle: () => !this.session.isStreaming,
1285
+ signal: this.session.agent.signal,
1286
+ abort: () => {
1287
+ this.restoreQueuedMessagesToEditor({ abort: true });
1288
+ },
1289
+ hasPendingMessages: () => this.session.pendingMessageCount > 0,
1290
+ shutdown: () => {
1291
+ this.shutdownRequested = true;
1292
+ },
1293
+ getContextUsage: () => this.session.getContextUsage(),
1294
+ compact: (options) => {
1295
+ void (async () => {
1296
+ try {
1297
+ const result = await this.session.compact(options?.customInstructions);
1298
+ options?.onComplete?.(result);
1299
+ }
1300
+ catch (error) {
1301
+ const err = error instanceof Error ? error : new Error(String(error));
1302
+ options?.onError?.(err);
1303
+ }
1304
+ })();
1305
+ },
1306
+ getSystemPrompt: () => this.session.systemPrompt,
1307
+ });
1308
+ // Set up the extension shortcut handler on the default editor
1309
+ this.defaultEditor.onExtensionShortcut = (data) => {
1310
+ for (const [shortcutStr, shortcut] of shortcuts) {
1311
+ // Cast to KeyId - extension shortcuts use the same format
1312
+ if (matchesKey(data, shortcutStr)) {
1313
+ // Run handler async, don't block input
1314
+ Promise.resolve(shortcut.handler(createContext())).catch((err) => {
1315
+ this.showError(`Shortcut handler error: ${err instanceof Error ? err.message : String(err)}`);
1316
+ });
1317
+ return true;
1318
+ }
1319
+ }
1320
+ return false;
1321
+ };
1322
+ }
1323
+ /**
1324
+ * Set extension status text in the footer.
1325
+ */
1326
+ setExtensionStatus(key, text) {
1327
+ this.footerDataProvider.setExtensionStatus(key, text);
1328
+ this.ui.requestRender();
1329
+ }
1330
+ getWorkingLoaderMessage() {
1331
+ return buildWorkingLoaderMessage(this.workingMessage ?? this.defaultWorkingMessage, !!this.session.model?.reasoning, this.session.thinkingLevel);
1332
+ }
1333
+ createWorkingLoader() {
1334
+ return new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), this.getWorkingLoaderMessage(), this.workingIndicatorOptions);
1335
+ }
1336
+ stopWorkingLoader() {
1337
+ if (this.loadingAnimation) {
1338
+ this.loadingAnimation.stop();
1339
+ this.loadingAnimation = undefined;
1340
+ }
1341
+ this.statusContainer.clear();
1342
+ }
1343
+ setWorkingVisible(visible) {
1344
+ this.workingVisible = visible;
1345
+ if (!visible) {
1346
+ this.stopWorkingLoader();
1347
+ this.ui.requestRender();
1348
+ return;
1349
+ }
1350
+ if (this.session.isStreaming && !this.loadingAnimation) {
1351
+ this.statusContainer.clear();
1352
+ this.loadingAnimation = this.createWorkingLoader();
1353
+ this.statusContainer.addChild(this.loadingAnimation);
1354
+ }
1355
+ this.ui.requestRender();
1356
+ }
1357
+ setWorkingIndicator(options) {
1358
+ this.workingIndicatorOptions = options;
1359
+ this.loadingAnimation?.setIndicator(options);
1360
+ this.ui.requestRender();
1361
+ }
1362
+ setHiddenThinkingLabel(label) {
1363
+ this.hiddenThinkingLabel = label ?? this.defaultHiddenThinkingLabel;
1364
+ for (const child of this.chatContainer.children) {
1365
+ if (child instanceof AssistantMessageComponent) {
1366
+ child.setHiddenThinkingLabel(this.hiddenThinkingLabel);
1367
+ }
1368
+ }
1369
+ if (this.streamingComponent) {
1370
+ this.streamingComponent.setHiddenThinkingLabel(this.hiddenThinkingLabel);
1371
+ }
1372
+ this.ui.requestRender();
1373
+ }
1374
+ /**
1375
+ * Set an extension widget (string array or custom component).
1376
+ */
1377
+ setExtensionWidget(key, content, options) {
1378
+ const placement = options?.placement ?? "aboveEditor";
1379
+ const removeExisting = (map) => {
1380
+ const existing = map.get(key);
1381
+ if (existing?.dispose)
1382
+ existing.dispose();
1383
+ map.delete(key);
1384
+ };
1385
+ removeExisting(this.extensionWidgetsAbove);
1386
+ removeExisting(this.extensionWidgetsBelow);
1387
+ if (content === undefined) {
1388
+ this.renderWidgets();
1389
+ return;
1390
+ }
1391
+ let component;
1392
+ if (Array.isArray(content)) {
1393
+ // Wrap string array in a Container with Text components
1394
+ const container = new Container();
1395
+ for (const line of content.slice(0, InteractiveMode.MAX_WIDGET_LINES)) {
1396
+ container.addChild(new Text(line, 1, 0));
1397
+ }
1398
+ if (content.length > InteractiveMode.MAX_WIDGET_LINES) {
1399
+ container.addChild(new Text(theme.fg("muted", "... (widget truncated)"), 1, 0));
1400
+ }
1401
+ component = container;
1402
+ }
1403
+ else {
1404
+ // Factory function - create component
1405
+ component = content(this.ui, theme);
1406
+ }
1407
+ const targetMap = placement === "belowEditor" ? this.extensionWidgetsBelow : this.extensionWidgetsAbove;
1408
+ targetMap.set(key, component);
1409
+ this.renderWidgets();
1410
+ }
1411
+ clearExtensionWidgets() {
1412
+ for (const widget of this.extensionWidgetsAbove.values()) {
1413
+ widget.dispose?.();
1414
+ }
1415
+ for (const widget of this.extensionWidgetsBelow.values()) {
1416
+ widget.dispose?.();
1417
+ }
1418
+ this.extensionWidgetsAbove.clear();
1419
+ this.extensionWidgetsBelow.clear();
1420
+ this.renderWidgets();
1421
+ }
1422
+ resetExtensionUI() {
1423
+ if (this.extensionSelector) {
1424
+ this.hideExtensionSelector();
1425
+ }
1426
+ if (this.extensionInput) {
1427
+ this.hideExtensionInput();
1428
+ }
1429
+ if (this.extensionEditor) {
1430
+ this.hideExtensionEditor();
1431
+ }
1432
+ this.ui.hideOverlay();
1433
+ this.clearExtensionTerminalInputListeners();
1434
+ this.setExtensionFooter(undefined);
1435
+ this.setExtensionHeader(undefined);
1436
+ this.clearExtensionWidgets();
1437
+ this.footerDataProvider.clearExtensionStatuses();
1438
+ this.footer.invalidate();
1439
+ this.autocompleteProviderWrappers = [];
1440
+ this.setCustomEditorComponent(undefined);
1441
+ this.setupAutocompleteProvider();
1442
+ this.defaultEditor.onExtensionShortcut = undefined;
1443
+ this.updateTerminalTitle();
1444
+ this.workingMessage = undefined;
1445
+ this.workingVisible = true;
1446
+ this.setWorkingIndicator();
1447
+ if (this.loadingAnimation) {
1448
+ this.loadingAnimation.setMessage(`${this.defaultWorkingMessage} (${keyText("app.interrupt")} to interrupt)`);
1449
+ }
1450
+ this.setHiddenThinkingLabel();
1451
+ }
1452
+ // Maximum total widget lines to prevent viewport overflow
1453
+ static MAX_WIDGET_LINES = 10;
1454
+ /**
1455
+ * Render all extension widgets to the widget container.
1456
+ */
1457
+ renderWidgets() {
1458
+ if (!this.widgetContainerAbove || !this.widgetContainerBelow)
1459
+ return;
1460
+ this.renderWidgetContainer(this.widgetContainerAbove, this.extensionWidgetsAbove, true, true);
1461
+ this.renderWidgetContainer(this.widgetContainerBelow, this.extensionWidgetsBelow, false, false);
1462
+ this.ui.requestRender();
1463
+ }
1464
+ renderWidgetContainer(container, widgets, spacerWhenEmpty, leadingSpacer) {
1465
+ container.clear();
1466
+ if (widgets.size === 0) {
1467
+ if (spacerWhenEmpty) {
1468
+ container.addChild(new Spacer(1));
1469
+ }
1470
+ return;
1471
+ }
1472
+ if (leadingSpacer) {
1473
+ container.addChild(new Spacer(1));
1474
+ }
1475
+ for (const component of widgets.values()) {
1476
+ container.addChild(component);
1477
+ }
1478
+ }
1479
+ /**
1480
+ * Set a custom footer component, or restore the built-in footer.
1481
+ */
1482
+ setExtensionFooter(factory) {
1483
+ // Dispose existing custom footer
1484
+ if (this.customFooter?.dispose) {
1485
+ this.customFooter.dispose();
1486
+ }
1487
+ // Remove current footer from UI
1488
+ if (this.customFooter) {
1489
+ this.ui.removeChild(this.customFooter);
1490
+ }
1491
+ else {
1492
+ this.ui.removeChild(this.footer);
1493
+ }
1494
+ if (factory) {
1495
+ // Create and add custom footer, passing the data provider
1496
+ this.customFooter = factory(this.ui, theme, this.footerDataProvider);
1497
+ this.ui.addChild(this.customFooter);
1498
+ }
1499
+ else {
1500
+ // Restore built-in footer
1501
+ this.customFooter = undefined;
1502
+ this.ui.addChild(this.footer);
1503
+ }
1504
+ this.ui.requestRender();
1505
+ }
1506
+ /**
1507
+ * Set a custom header component, or restore the built-in header.
1508
+ */
1509
+ setExtensionHeader(factory) {
1510
+ // Header may not be initialized yet if called during early initialization
1511
+ if (!this.builtInHeader) {
1512
+ return;
1513
+ }
1514
+ // Dispose existing custom header
1515
+ if (this.customHeader?.dispose) {
1516
+ this.customHeader.dispose();
1517
+ }
1518
+ // Find the index of the current header in the header container
1519
+ const currentHeader = this.customHeader || this.builtInHeader;
1520
+ const index = this.headerContainer.children.indexOf(currentHeader);
1521
+ if (factory) {
1522
+ // Create and add custom header
1523
+ this.customHeader = factory(this.ui, theme);
1524
+ if (isExpandable(this.customHeader)) {
1525
+ this.customHeader.setExpanded(this.toolOutputExpanded);
1526
+ }
1527
+ if (index !== -1) {
1528
+ this.headerContainer.children[index] = this.customHeader;
1529
+ }
1530
+ else {
1531
+ // If not found (e.g. builtInHeader was never added), add at the top
1532
+ this.headerContainer.children.unshift(this.customHeader);
1533
+ }
1534
+ }
1535
+ else {
1536
+ // Restore built-in header
1537
+ this.customHeader = undefined;
1538
+ if (isExpandable(this.builtInHeader)) {
1539
+ this.builtInHeader.setExpanded(this.toolOutputExpanded);
1540
+ }
1541
+ if (index !== -1) {
1542
+ this.headerContainer.children[index] = this.builtInHeader;
1543
+ }
1544
+ }
1545
+ this.ui.requestRender();
1546
+ }
1547
+ addExtensionTerminalInputListener(handler) {
1548
+ const unsubscribe = this.ui.addInputListener(handler);
1549
+ this.extensionTerminalInputUnsubscribers.add(unsubscribe);
1550
+ return () => {
1551
+ unsubscribe();
1552
+ this.extensionTerminalInputUnsubscribers.delete(unsubscribe);
1553
+ };
1554
+ }
1555
+ clearExtensionTerminalInputListeners() {
1556
+ for (const unsubscribe of this.extensionTerminalInputUnsubscribers) {
1557
+ unsubscribe();
1558
+ }
1559
+ this.extensionTerminalInputUnsubscribers.clear();
1560
+ }
1561
+ /**
1562
+ * Create the ExtensionUIContext for extensions.
1563
+ */
1564
+ createExtensionUIContext() {
1565
+ return {
1566
+ select: (title, options, opts) => this.showExtensionSelector(title, options, opts),
1567
+ confirm: (title, message, opts) => this.showExtensionConfirm(title, message, opts),
1568
+ input: (title, placeholder, opts) => this.showExtensionInput(title, placeholder, opts),
1569
+ notify: (message, type) => this.showExtensionNotify(message, type),
1570
+ onTerminalInput: (handler) => this.addExtensionTerminalInputListener(handler),
1571
+ setStatus: (key, text) => this.setExtensionStatus(key, text),
1572
+ setWorkingMessage: (message) => {
1573
+ this.workingMessage = message;
1574
+ if (this.loadingAnimation) {
1575
+ this.loadingAnimation.setMessage(message ?? this.defaultWorkingMessage);
1576
+ }
1577
+ },
1578
+ setWorkingVisible: (visible) => this.setWorkingVisible(visible),
1579
+ setWorkingIndicator: (options) => this.setWorkingIndicator(options),
1580
+ setHiddenThinkingLabel: (label) => this.setHiddenThinkingLabel(label),
1581
+ setWidget: (key, content, options) => this.setExtensionWidget(key, content, options),
1582
+ setFooter: (factory) => this.setExtensionFooter(factory),
1583
+ setHeader: (factory) => this.setExtensionHeader(factory),
1584
+ setTitle: (title) => this.ui.terminal.setTitle(title),
1585
+ custom: (factory, options) => this.showExtensionCustom(factory, options),
1586
+ pasteToEditor: (text) => this.editor.handleInput(`\x1b[200~${text}\x1b[201~`),
1587
+ setEditorText: (text) => this.editor.setText(text),
1588
+ getEditorText: () => this.editor.getExpandedText?.() ?? this.editor.getText(),
1589
+ editor: (title, prefill) => this.showExtensionEditor(title, prefill),
1590
+ addAutocompleteProvider: (factory) => {
1591
+ this.autocompleteProviderWrappers.push(factory);
1592
+ this.setupAutocompleteProvider();
1593
+ },
1594
+ setEditorComponent: (factory) => this.setCustomEditorComponent(factory),
1595
+ getEditorComponent: () => this.editorComponentFactory,
1596
+ get theme() {
1597
+ return theme;
1598
+ },
1599
+ getAllThemes: () => getAvailableThemesWithPaths(),
1600
+ getTheme: (name) => getThemeByName(name),
1601
+ setTheme: (themeOrName) => {
1602
+ if (themeOrName instanceof Theme) {
1603
+ setThemeInstance(themeOrName);
1604
+ this.ui.requestRender();
1605
+ return { success: true };
1606
+ }
1607
+ const result = setTheme(themeOrName, true);
1608
+ if (result.success) {
1609
+ if (this.settingsManager.getTheme() !== themeOrName) {
1610
+ this.settingsManager.setTheme(themeOrName);
1611
+ }
1612
+ this.ui.requestRender();
1613
+ }
1614
+ return result;
1615
+ },
1616
+ getToolsExpanded: () => this.toolOutputExpanded,
1617
+ setToolsExpanded: (expanded) => this.setToolsExpanded(expanded),
1618
+ };
1619
+ }
1620
+ /**
1621
+ * Show a selector for extensions.
1622
+ */
1623
+ showExtensionSelector(title, options, opts) {
1624
+ return new Promise((resolve) => {
1625
+ if (opts?.signal?.aborted) {
1626
+ resolve(undefined);
1627
+ return;
1628
+ }
1629
+ const onAbort = () => {
1630
+ this.hideExtensionSelector();
1631
+ resolve(undefined);
1632
+ };
1633
+ opts?.signal?.addEventListener("abort", onAbort, { once: true });
1634
+ this.extensionSelector = new ExtensionSelectorComponent(title, options, (option) => {
1635
+ opts?.signal?.removeEventListener("abort", onAbort);
1636
+ this.hideExtensionSelector();
1637
+ resolve(option);
1638
+ }, () => {
1639
+ opts?.signal?.removeEventListener("abort", onAbort);
1640
+ this.hideExtensionSelector();
1641
+ resolve(undefined);
1642
+ }, { tui: this.ui, timeout: opts?.timeout, onToggleToolsExpanded: () => this.toggleToolOutputExpansion() });
1643
+ this.editorContainer.clear();
1644
+ this.editorContainer.addChild(this.extensionSelector);
1645
+ this.ui.setFocus(this.extensionSelector);
1646
+ this.ui.requestRender();
1647
+ });
1648
+ }
1649
+ /**
1650
+ * Hide the extension selector.
1651
+ */
1652
+ hideExtensionSelector() {
1653
+ this.extensionSelector?.dispose();
1654
+ this.editorContainer.clear();
1655
+ this.editorContainer.addChild(this.editor);
1656
+ this.extensionSelector = undefined;
1657
+ this.ui.setFocus(this.editor);
1658
+ this.ui.requestRender();
1659
+ }
1660
+ /**
1661
+ * Show a confirmation dialog for extensions.
1662
+ */
1663
+ async showExtensionConfirm(title, message, opts) {
1664
+ const result = await this.showExtensionSelector(`${title}\n${message}`, ["Yes", "No"], opts);
1665
+ return result === "Yes";
1666
+ }
1667
+ async promptForMissingSessionCwd(error) {
1668
+ const confirmed = await this.showExtensionConfirm("Session cwd not found", formatMissingSessionCwdPrompt(error.issue));
1669
+ return confirmed ? error.issue.fallbackCwd : undefined;
1670
+ }
1671
+ /**
1672
+ * Show a text input for extensions.
1673
+ */
1674
+ showExtensionInput(title, placeholder, opts) {
1675
+ return new Promise((resolve) => {
1676
+ if (opts?.signal?.aborted) {
1677
+ resolve(undefined);
1678
+ return;
1679
+ }
1680
+ const onAbort = () => {
1681
+ this.hideExtensionInput();
1682
+ resolve(undefined);
1683
+ };
1684
+ opts?.signal?.addEventListener("abort", onAbort, { once: true });
1685
+ this.extensionInput = new ExtensionInputComponent(title, placeholder, (value) => {
1686
+ opts?.signal?.removeEventListener("abort", onAbort);
1687
+ this.hideExtensionInput();
1688
+ resolve(value);
1689
+ }, () => {
1690
+ opts?.signal?.removeEventListener("abort", onAbort);
1691
+ this.hideExtensionInput();
1692
+ resolve(undefined);
1693
+ }, { tui: this.ui, timeout: opts?.timeout });
1694
+ this.editorContainer.clear();
1695
+ this.editorContainer.addChild(this.extensionInput);
1696
+ this.ui.setFocus(this.extensionInput);
1697
+ this.ui.requestRender();
1698
+ });
1699
+ }
1700
+ /**
1701
+ * Hide the extension input.
1702
+ */
1703
+ hideExtensionInput() {
1704
+ this.extensionInput?.dispose();
1705
+ this.editorContainer.clear();
1706
+ this.editorContainer.addChild(this.editor);
1707
+ this.extensionInput = undefined;
1708
+ this.ui.setFocus(this.editor);
1709
+ this.ui.requestRender();
1710
+ }
1711
+ /**
1712
+ * Show a multi-line editor for extensions (with Ctrl+G support).
1713
+ */
1714
+ showExtensionEditor(title, prefill) {
1715
+ return new Promise((resolve) => {
1716
+ this.extensionEditor = new ExtensionEditorComponent(this.ui, this.keybindings, title, prefill, (value) => {
1717
+ this.hideExtensionEditor();
1718
+ resolve(value);
1719
+ }, () => {
1720
+ this.hideExtensionEditor();
1721
+ resolve(undefined);
1722
+ });
1723
+ this.editorContainer.clear();
1724
+ this.editorContainer.addChild(this.extensionEditor);
1725
+ this.ui.setFocus(this.extensionEditor);
1726
+ this.ui.requestRender();
1727
+ });
1728
+ }
1729
+ /**
1730
+ * Hide the extension editor.
1731
+ */
1732
+ hideExtensionEditor() {
1733
+ this.editorContainer.clear();
1734
+ this.editorContainer.addChild(this.editor);
1735
+ this.extensionEditor = undefined;
1736
+ this.ui.setFocus(this.editor);
1737
+ this.ui.requestRender();
1738
+ }
1739
+ /**
1740
+ * Set a custom editor component from an extension.
1741
+ * Pass undefined to restore the default editor.
1742
+ */
1743
+ setCustomEditorComponent(factory) {
1744
+ this.editorComponentFactory = factory;
1745
+ // Save text from current editor before switching
1746
+ const currentText = this.editor.getText();
1747
+ this.editorContainer.clear();
1748
+ if (factory) {
1749
+ // Create the custom editor with tui, theme, and keybindings
1750
+ const newEditor = factory(this.ui, getEditorTheme(), this.keybindings);
1751
+ // Wire up callbacks from the default editor
1752
+ newEditor.onSubmit = this.defaultEditor.onSubmit;
1753
+ newEditor.onChange = this.defaultEditor.onChange;
1754
+ // Copy text from previous editor
1755
+ newEditor.setText(currentText);
1756
+ // Copy appearance settings if supported
1757
+ if (newEditor.borderColor !== undefined) {
1758
+ newEditor.borderColor = this.defaultEditor.borderColor;
1759
+ }
1760
+ if (newEditor.setPaddingX !== undefined) {
1761
+ newEditor.setPaddingX(this.defaultEditor.getPaddingX());
1762
+ }
1763
+ // Set autocomplete if supported
1764
+ if (newEditor.setAutocompleteProvider && this.autocompleteProvider) {
1765
+ newEditor.setAutocompleteProvider(this.autocompleteProvider);
1766
+ }
1767
+ // If extending CustomEditor, copy app-level handlers
1768
+ // Use duck typing since instanceof fails across jiti module boundaries
1769
+ const customEditor = newEditor;
1770
+ if ("actionHandlers" in customEditor && customEditor.actionHandlers instanceof Map) {
1771
+ if (!customEditor.onEscape) {
1772
+ customEditor.onEscape = () => this.defaultEditor.onEscape?.();
1773
+ }
1774
+ if (!customEditor.onCtrlD) {
1775
+ customEditor.onCtrlD = () => this.defaultEditor.onCtrlD?.();
1776
+ }
1777
+ if (!customEditor.onPasteImage) {
1778
+ customEditor.onPasteImage = () => this.defaultEditor.onPasteImage?.();
1779
+ }
1780
+ if (!customEditor.onExtensionShortcut) {
1781
+ customEditor.onExtensionShortcut = (data) => this.defaultEditor.onExtensionShortcut?.(data);
1782
+ }
1783
+ // Copy action handlers (clear, suspend, model switching, etc.)
1784
+ for (const [action, handler] of this.defaultEditor.actionHandlers) {
1785
+ customEditor.actionHandlers.set(action, handler);
1786
+ }
1787
+ }
1788
+ this.editor = newEditor;
1789
+ }
1790
+ else {
1791
+ // Restore default editor with text from custom editor
1792
+ this.defaultEditor.setText(currentText);
1793
+ this.editor = this.defaultEditor;
1794
+ }
1795
+ this.editorContainer.addChild(this.editor);
1796
+ this.ui.setFocus(this.editor);
1797
+ this.ui.requestRender();
1798
+ }
1799
+ /**
1800
+ * Show a notification for extensions.
1801
+ */
1802
+ showExtensionNotify(message, type) {
1803
+ if (type === "error") {
1804
+ this.showError(message);
1805
+ }
1806
+ else if (type === "warning") {
1807
+ this.showWarning(message);
1808
+ }
1809
+ else {
1810
+ this.showStatus(message);
1811
+ }
1812
+ }
1813
+ /** Show a custom component with keyboard focus. Overlay mode renders on top of existing content. */
1814
+ async showExtensionCustom(factory, options) {
1815
+ const savedText = this.editor.getText();
1816
+ const isOverlay = options?.overlay ?? false;
1817
+ const restoreEditor = () => {
1818
+ this.editorContainer.clear();
1819
+ this.editorContainer.addChild(this.editor);
1820
+ this.editor.setText(savedText);
1821
+ this.ui.setFocus(this.editor);
1822
+ this.ui.requestRender();
1823
+ };
1824
+ return new Promise((resolve, reject) => {
1825
+ let component;
1826
+ let closed = false;
1827
+ const close = (result) => {
1828
+ if (closed)
1829
+ return;
1830
+ closed = true;
1831
+ if (isOverlay)
1832
+ this.ui.hideOverlay();
1833
+ else
1834
+ restoreEditor();
1835
+ // Note: both branches above already call requestRender
1836
+ resolve(result);
1837
+ try {
1838
+ component?.dispose?.();
1839
+ }
1840
+ catch {
1841
+ /* ignore dispose errors */
1842
+ }
1843
+ };
1844
+ Promise.resolve(factory(this.ui, theme, this.keybindings, close))
1845
+ .then((c) => {
1846
+ if (closed)
1847
+ return;
1848
+ component = c;
1849
+ if (isOverlay) {
1850
+ // Resolve overlay options - can be static or dynamic function
1851
+ const resolveOptions = () => {
1852
+ if (options?.overlayOptions) {
1853
+ const opts = typeof options.overlayOptions === "function"
1854
+ ? options.overlayOptions()
1855
+ : options.overlayOptions;
1856
+ return opts;
1857
+ }
1858
+ // Fallback: use component's width property if available
1859
+ const w = component.width;
1860
+ return w ? { width: w } : undefined;
1861
+ };
1862
+ const handle = this.ui.showOverlay(component, resolveOptions());
1863
+ // Expose handle to caller for visibility control
1864
+ options?.onHandle?.(handle);
1865
+ }
1866
+ else {
1867
+ this.editorContainer.clear();
1868
+ this.editorContainer.addChild(component);
1869
+ this.ui.setFocus(component);
1870
+ this.ui.requestRender();
1871
+ }
1872
+ })
1873
+ .catch((err) => {
1874
+ if (closed)
1875
+ return;
1876
+ if (!isOverlay)
1877
+ restoreEditor();
1878
+ reject(err);
1879
+ });
1880
+ });
1881
+ }
1882
+ /**
1883
+ * Show an extension error in the UI.
1884
+ */
1885
+ showExtensionError(extensionPath, error, stack) {
1886
+ const errorMsg = `Extension "${extensionPath}" error: ${error}`;
1887
+ const errorText = new Text(theme.fg("error", errorMsg), 1, 0);
1888
+ this.chatContainer.addChild(errorText);
1889
+ if (stack) {
1890
+ // Show stack trace in dim color, indented
1891
+ const stackLines = stack
1892
+ .split("\n")
1893
+ .slice(1) // Skip first line (duplicates error message)
1894
+ .map((line) => theme.fg("dim", ` ${line.trim()}`))
1895
+ .join("\n");
1896
+ if (stackLines) {
1897
+ this.chatContainer.addChild(new Text(stackLines, 1, 0));
1898
+ }
1899
+ }
1900
+ this.ui.requestRender();
1901
+ }
1902
+ // =========================================================================
1903
+ // Key Handlers
1904
+ // =========================================================================
1905
+ setupKeyHandlers() {
1906
+ // Set up handlers on defaultEditor - they use this.editor for text access
1907
+ // so they work correctly regardless of which editor is active
1908
+ this.defaultEditor.onEscape = () => {
1909
+ if (this.session.isStreaming) {
1910
+ this.restoreQueuedMessagesToEditor({ abort: true });
1911
+ }
1912
+ else if (this.session.isBashRunning) {
1913
+ this.session.abortBash();
1914
+ }
1915
+ else if (this.isBashMode) {
1916
+ this.editor.setText("");
1917
+ this.isBashMode = false;
1918
+ this.updateEditorBorderColor();
1919
+ }
1920
+ else if (!this.editor.getText().trim()) {
1921
+ // Double-escape with empty editor triggers /tree, /fork, or nothing based on setting
1922
+ const action = this.settingsManager.getDoubleEscapeAction();
1923
+ if (action !== "none") {
1924
+ const now = Date.now();
1925
+ if (now - this.lastEscapeTime < 500) {
1926
+ if (action === "tree") {
1927
+ this.showTreeSelector();
1928
+ }
1929
+ else {
1930
+ this.showUserMessageSelector();
1931
+ }
1932
+ this.lastEscapeTime = 0;
1933
+ }
1934
+ else {
1935
+ this.lastEscapeTime = now;
1936
+ }
1937
+ }
1938
+ }
1939
+ };
1940
+ // Register app action handlers
1941
+ this.defaultEditor.onAction("app.clear", () => this.handleCtrlC());
1942
+ this.defaultEditor.onCtrlD = () => this.handleCtrlD();
1943
+ this.defaultEditor.onAction("app.suspend", () => this.handleCtrlZ());
1944
+ this.defaultEditor.onAction("app.thinking.cycle", () => this.cycleThinkingLevel());
1945
+ this.defaultEditor.onAction("app.model.cycleForward", () => this.cycleModel("forward"));
1946
+ this.defaultEditor.onAction("app.model.cycleBackward", () => this.cycleModel("backward"));
1947
+ // Global debug handler on TUI (works regardless of focus)
1948
+ this.ui.onDebug = () => this.handleDebugCommand();
1949
+ this.defaultEditor.onAction("app.model.select", () => this.showModelSelector());
1950
+ this.defaultEditor.onAction("app.tools.expand", () => this.toggleToolOutputExpansion());
1951
+ this.defaultEditor.onAction("app.thinking.toggle", () => this.toggleThinkingBlockVisibility());
1952
+ this.defaultEditor.onAction("app.editor.external", () => this.openExternalEditor());
1953
+ this.defaultEditor.onAction("app.message.followUp", () => this.handleFollowUp());
1954
+ this.defaultEditor.onAction("app.message.dequeue", () => this.handleDequeue());
1955
+ this.defaultEditor.onAction("app.session.new", () => this.handleClearCommand());
1956
+ this.defaultEditor.onAction("app.session.tree", () => this.showTreeSelector());
1957
+ this.defaultEditor.onAction("app.session.fork", () => this.showUserMessageSelector());
1958
+ this.defaultEditor.onAction("app.session.resume", () => this.showSessionSelector());
1959
+ this.defaultEditor.onChange = (text) => {
1960
+ const wasBashMode = this.isBashMode;
1961
+ this.isBashMode = text.trimStart().startsWith("!");
1962
+ if (wasBashMode !== this.isBashMode) {
1963
+ this.updateEditorBorderColor();
1964
+ }
1965
+ };
1966
+ // Handle clipboard image paste (triggered on Ctrl+V)
1967
+ this.defaultEditor.onPasteImage = () => {
1968
+ this.handleClipboardImagePaste();
1969
+ };
1970
+ }
1971
+ async handleClipboardImagePaste() {
1972
+ try {
1973
+ const image = await readClipboardImage();
1974
+ if (!image) {
1975
+ return;
1976
+ }
1977
+ // Write to temp file
1978
+ const tmpDir = os.tmpdir();
1979
+ const ext = extensionForImageMimeType(image.mimeType) ?? "png";
1980
+ const fileName = `pi-clipboard-${crypto.randomUUID()}.${ext}`;
1981
+ const filePath = path.join(tmpDir, fileName);
1982
+ fs.writeFileSync(filePath, Buffer.from(image.bytes));
1983
+ // Insert file path directly
1984
+ this.editor.insertTextAtCursor?.(filePath);
1985
+ this.ui.requestRender();
1986
+ }
1987
+ catch {
1988
+ // Silently ignore clipboard errors (may not have permission, etc.)
1989
+ }
1990
+ }
1991
+ setupEditorSubmitHandler() {
1992
+ this.defaultEditor.onSubmit = async (text) => {
1993
+ text = text.trim();
1994
+ if (!text)
1995
+ return;
1996
+ // Handle commands
1997
+ if (text === "/settings") {
1998
+ this.showSettingsSelector();
1999
+ this.editor.setText("");
2000
+ return;
2001
+ }
2002
+ if (text === "/scoped-models") {
2003
+ this.editor.setText("");
2004
+ await this.showModelsSelector();
2005
+ return;
2006
+ }
2007
+ if (text === "/model" || text.startsWith("/model ")) {
2008
+ const searchTerm = text.startsWith("/model ") ? text.slice(7).trim() : undefined;
2009
+ this.editor.setText("");
2010
+ await this.handleModelCommand(searchTerm);
2011
+ return;
2012
+ }
2013
+ if (text === "/export" || text.startsWith("/export ")) {
2014
+ await this.handleExportCommand(text);
2015
+ this.editor.setText("");
2016
+ return;
2017
+ }
2018
+ if (text === "/import" || text.startsWith("/import ")) {
2019
+ await this.handleImportCommand(text);
2020
+ this.editor.setText("");
2021
+ return;
2022
+ }
2023
+ if (text === "/share") {
2024
+ await this.handleShareCommand();
2025
+ this.editor.setText("");
2026
+ return;
2027
+ }
2028
+ if (text === "/copy") {
2029
+ await this.handleCopyCommand();
2030
+ this.editor.setText("");
2031
+ return;
2032
+ }
2033
+ if (text === "/name" || text.startsWith("/name ")) {
2034
+ this.handleNameCommand(text);
2035
+ this.editor.setText("");
2036
+ return;
2037
+ }
2038
+ if (text === "/session") {
2039
+ this.handleSessionCommand();
2040
+ this.editor.setText("");
2041
+ return;
2042
+ }
2043
+ if (text === "/changelog") {
2044
+ this.handleChangelogCommand();
2045
+ this.editor.setText("");
2046
+ return;
2047
+ }
2048
+ if (text === "/hotkeys") {
2049
+ this.handleHotkeysCommand();
2050
+ this.editor.setText("");
2051
+ return;
2052
+ }
2053
+ if (text === "/fork") {
2054
+ this.showUserMessageSelector();
2055
+ this.editor.setText("");
2056
+ return;
2057
+ }
2058
+ if (text === "/clone") {
2059
+ this.editor.setText("");
2060
+ await this.handleCloneCommand();
2061
+ return;
2062
+ }
2063
+ if (text === "/tree") {
2064
+ this.showTreeSelector();
2065
+ this.editor.setText("");
2066
+ return;
2067
+ }
2068
+ if (text === "/login") {
2069
+ this.showOAuthSelector("login");
2070
+ this.editor.setText("");
2071
+ return;
2072
+ }
2073
+ if (text === "/logout") {
2074
+ this.showOAuthSelector("logout");
2075
+ this.editor.setText("");
2076
+ return;
2077
+ }
2078
+ if (text === "/new") {
2079
+ this.editor.setText("");
2080
+ await this.handleClearCommand();
2081
+ return;
2082
+ }
2083
+ if (text === "/compact" || text.startsWith("/compact ")) {
2084
+ const customInstructions = text.startsWith("/compact ") ? text.slice(9).trim() : undefined;
2085
+ this.editor.setText("");
2086
+ await this.handleCompactCommand(customInstructions);
2087
+ return;
2088
+ }
2089
+ if (text === "/reload") {
2090
+ this.editor.setText("");
2091
+ await this.handleReloadCommand();
2092
+ return;
2093
+ }
2094
+ if (text === "/debug") {
2095
+ this.handleDebugCommand();
2096
+ this.editor.setText("");
2097
+ return;
2098
+ }
2099
+ if (text === "/arminsayshi") {
2100
+ this.handleArminSaysHi();
2101
+ this.editor.setText("");
2102
+ return;
2103
+ }
2104
+ if (text === "/dementedelves") {
2105
+ this.handleDementedDelves();
2106
+ this.editor.setText("");
2107
+ return;
2108
+ }
2109
+ if (text === "/resume") {
2110
+ this.showSessionSelector();
2111
+ this.editor.setText("");
2112
+ return;
2113
+ }
2114
+ if (text === "/quit") {
2115
+ this.editor.setText("");
2116
+ await this.shutdown();
2117
+ return;
2118
+ }
2119
+ // Handle bash command (! for normal, !! for excluded from context)
2120
+ if (text.startsWith("!")) {
2121
+ const isExcluded = text.startsWith("!!");
2122
+ const command = isExcluded ? text.slice(2).trim() : text.slice(1).trim();
2123
+ if (command) {
2124
+ if (this.session.isBashRunning) {
2125
+ this.showWarning("A bash command is already running. Press Esc to cancel it first.");
2126
+ this.editor.setText(text);
2127
+ return;
2128
+ }
2129
+ this.editor.addToHistory?.(text);
2130
+ await this.handleBashCommand(command, isExcluded);
2131
+ this.isBashMode = false;
2132
+ this.updateEditorBorderColor();
2133
+ return;
2134
+ }
2135
+ }
2136
+ // Queue input during compaction (extension commands execute immediately)
2137
+ if (this.session.isCompacting) {
2138
+ if (this.isExtensionCommand(text)) {
2139
+ this.editor.addToHistory?.(text);
2140
+ this.editor.setText("");
2141
+ await this.session.prompt(text);
2142
+ }
2143
+ else {
2144
+ this.queueCompactionMessage(text, "steer");
2145
+ }
2146
+ return;
2147
+ }
2148
+ // If streaming, use prompt() with steer behavior
2149
+ // This handles extension commands (execute immediately), prompt template expansion, and queueing
2150
+ if (this.session.isStreaming) {
2151
+ this.editor.addToHistory?.(text);
2152
+ this.editor.setText("");
2153
+ await this.session.prompt(text, { streamingBehavior: "steer" });
2154
+ this.updatePendingMessagesDisplay();
2155
+ this.ui.requestRender();
2156
+ return;
2157
+ }
2158
+ // Normal message submission
2159
+ // First, move any pending bash components to chat
2160
+ this.flushPendingBashComponents();
2161
+ if (this.onInputCallback) {
2162
+ this.onInputCallback(text);
2163
+ }
2164
+ else {
2165
+ this.pendingUserInputs.push(text);
2166
+ }
2167
+ this.editor.addToHistory?.(text);
2168
+ };
2169
+ }
2170
+ subscribeToAgent() {
2171
+ this.unsubscribe = this.session.subscribe(async (event) => {
2172
+ await this.handleEvent(event);
2173
+ });
2174
+ }
2175
+ async handleEvent(event) {
2176
+ if (!this.isInitialized) {
2177
+ await this.init();
2178
+ }
2179
+ this.footer.invalidate();
2180
+ switch (event.type) {
2181
+ case "agent_start":
2182
+ this.pendingTools.clear();
2183
+ if (this.settingsManager.getShowTerminalProgress()) {
2184
+ this.ui.terminal.setProgress(true);
2185
+ }
2186
+ // Restore main escape handler if retry handler is still active
2187
+ // (retry success event fires later, but we need main handler now)
2188
+ if (this.retryEscapeHandler) {
2189
+ this.defaultEditor.onEscape = this.retryEscapeHandler;
2190
+ this.retryEscapeHandler = undefined;
2191
+ }
2192
+ if (this.retryCountdown) {
2193
+ this.retryCountdown.dispose();
2194
+ this.retryCountdown = undefined;
2195
+ }
2196
+ if (this.retryLoader) {
2197
+ this.retryLoader.stop();
2198
+ this.retryLoader = undefined;
2199
+ }
2200
+ this.stopWorkingLoader();
2201
+ if (this.workingVisible) {
2202
+ this.loadingAnimation = this.createWorkingLoader();
2203
+ this.statusContainer.addChild(this.loadingAnimation);
2204
+ }
2205
+ this.ui.requestRender();
2206
+ break;
2207
+ case "queue_update":
2208
+ this.updatePendingMessagesDisplay();
2209
+ this.ui.requestRender();
2210
+ break;
2211
+ case "session_info_changed":
2212
+ this.updateTerminalTitle();
2213
+ this.footer.invalidate();
2214
+ this.ui.requestRender();
2215
+ break;
2216
+ case "thinking_level_changed":
2217
+ this.footer.invalidate();
2218
+ this.updateEditorBorderColor();
2219
+ this.loadingAnimation?.setMessage(this.getWorkingLoaderMessage());
2220
+ this.ui.requestRender();
2221
+ break;
2222
+ case "message_start":
2223
+ if (event.message.role === "custom") {
2224
+ this.addMessageToChat(event.message);
2225
+ this.ui.requestRender();
2226
+ }
2227
+ else if (event.message.role === "user") {
2228
+ this.addMessageToChat(event.message);
2229
+ this.updatePendingMessagesDisplay();
2230
+ this.ui.requestRender();
2231
+ }
2232
+ else if (event.message.role === "assistant") {
2233
+ this.streamingComponent = new AssistantMessageComponent(undefined, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel);
2234
+ this.streamingMessage = event.message;
2235
+ this.chatContainer.addChild(this.streamingComponent);
2236
+ this.streamingComponent.updateContent(this.streamingMessage);
2237
+ this.ui.requestRender();
2238
+ }
2239
+ break;
2240
+ case "message_update":
2241
+ if (this.streamingComponent && event.message.role === "assistant") {
2242
+ this.streamingMessage = event.message;
2243
+ this.streamingComponent.updateContent(this.streamingMessage);
2244
+ for (const content of this.streamingMessage.content) {
2245
+ if (content.type === "toolCall") {
2246
+ if (!this.pendingTools.has(content.id)) {
2247
+ const component = new ToolExecutionComponent(content.name, content.id, content.arguments, {
2248
+ showImages: this.settingsManager.getShowImages(),
2249
+ imageWidthCells: this.settingsManager.getImageWidthCells(),
2250
+ }, this.getRegisteredToolDefinition(content.name), this.ui, this.sessionManager.getCwd());
2251
+ component.setExpanded(this.toolOutputExpanded);
2252
+ this.chatContainer.addChild(component);
2253
+ this.pendingTools.set(content.id, component);
2254
+ }
2255
+ else {
2256
+ const component = this.pendingTools.get(content.id);
2257
+ if (component) {
2258
+ component.updateArgs(content.arguments);
2259
+ }
2260
+ }
2261
+ }
2262
+ }
2263
+ this.ui.requestRender();
2264
+ }
2265
+ break;
2266
+ case "message_end":
2267
+ if (event.message.role === "user")
2268
+ break;
2269
+ if (this.streamingComponent && event.message.role === "assistant") {
2270
+ this.streamingMessage = event.message;
2271
+ let errorMessage;
2272
+ if (this.streamingMessage.stopReason === "aborted") {
2273
+ const retryAttempt = this.session.retryAttempt;
2274
+ errorMessage =
2275
+ retryAttempt > 0
2276
+ ? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? "s" : ""}`
2277
+ : "Operation aborted";
2278
+ this.streamingMessage.errorMessage = errorMessage;
2279
+ }
2280
+ this.streamingComponent.updateContent(this.streamingMessage);
2281
+ if (this.streamingMessage.stopReason === "aborted" || this.streamingMessage.stopReason === "error") {
2282
+ if (!errorMessage) {
2283
+ errorMessage = this.streamingMessage.errorMessage || "Error";
2284
+ }
2285
+ for (const [, component] of this.pendingTools.entries()) {
2286
+ component.updateResult({
2287
+ content: [{ type: "text", text: errorMessage }],
2288
+ isError: true,
2289
+ });
2290
+ }
2291
+ this.pendingTools.clear();
2292
+ }
2293
+ else {
2294
+ // Args are now complete - trigger diff computation for edit tools
2295
+ for (const [, component] of this.pendingTools.entries()) {
2296
+ component.setArgsComplete();
2297
+ }
2298
+ }
2299
+ this.streamingComponent = undefined;
2300
+ this.streamingMessage = undefined;
2301
+ this.footer.invalidate();
2302
+ }
2303
+ this.ui.requestRender();
2304
+ break;
2305
+ case "tool_execution_start": {
2306
+ let component = this.pendingTools.get(event.toolCallId);
2307
+ if (!component) {
2308
+ component = new ToolExecutionComponent(event.toolName, event.toolCallId, event.args, {
2309
+ showImages: this.settingsManager.getShowImages(),
2310
+ imageWidthCells: this.settingsManager.getImageWidthCells(),
2311
+ }, this.getRegisteredToolDefinition(event.toolName), this.ui, this.sessionManager.getCwd());
2312
+ component.setExpanded(this.toolOutputExpanded);
2313
+ this.chatContainer.addChild(component);
2314
+ this.pendingTools.set(event.toolCallId, component);
2315
+ }
2316
+ component.markExecutionStarted();
2317
+ this.ui.requestRender();
2318
+ break;
2319
+ }
2320
+ case "tool_execution_update": {
2321
+ const component = this.pendingTools.get(event.toolCallId);
2322
+ if (component) {
2323
+ component.updateResult({ ...event.partialResult, isError: false }, true);
2324
+ this.ui.requestRender();
2325
+ }
2326
+ break;
2327
+ }
2328
+ case "tool_execution_end": {
2329
+ const component = this.pendingTools.get(event.toolCallId);
2330
+ if (component) {
2331
+ component.updateResult({ ...event.result, isError: event.isError });
2332
+ this.pendingTools.delete(event.toolCallId);
2333
+ this.ui.requestRender();
2334
+ }
2335
+ break;
2336
+ }
2337
+ case "agent_end":
2338
+ if (this.settingsManager.getShowTerminalProgress()) {
2339
+ this.ui.terminal.setProgress(false);
2340
+ }
2341
+ if (this.loadingAnimation) {
2342
+ this.loadingAnimation.stop();
2343
+ this.loadingAnimation = undefined;
2344
+ this.statusContainer.clear();
2345
+ }
2346
+ if (this.streamingComponent) {
2347
+ this.chatContainer.removeChild(this.streamingComponent);
2348
+ this.streamingComponent = undefined;
2349
+ this.streamingMessage = undefined;
2350
+ }
2351
+ this.pendingTools.clear();
2352
+ await this.checkShutdownRequested();
2353
+ this.ui.requestRender();
2354
+ break;
2355
+ case "compaction_start": {
2356
+ if (this.settingsManager.getShowTerminalProgress()) {
2357
+ this.ui.terminal.setProgress(true);
2358
+ }
2359
+ // Keep editor active; submissions are queued during compaction.
2360
+ this.autoCompactionEscapeHandler = this.defaultEditor.onEscape;
2361
+ this.defaultEditor.onEscape = () => {
2362
+ this.session.abortCompaction();
2363
+ };
2364
+ this.statusContainer.clear();
2365
+ const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
2366
+ const label = event.reason === "manual"
2367
+ ? `Compacting context... ${cancelHint}`
2368
+ : `${event.reason === "overflow" ? "Context overflow detected, " : ""}Auto-compacting... ${cancelHint}`;
2369
+ this.autoCompactionLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
2370
+ this.statusContainer.addChild(this.autoCompactionLoader);
2371
+ this.ui.requestRender();
2372
+ break;
2373
+ }
2374
+ case "compaction_end": {
2375
+ if (this.settingsManager.getShowTerminalProgress()) {
2376
+ this.ui.terminal.setProgress(false);
2377
+ }
2378
+ if (this.autoCompactionEscapeHandler) {
2379
+ this.defaultEditor.onEscape = this.autoCompactionEscapeHandler;
2380
+ this.autoCompactionEscapeHandler = undefined;
2381
+ }
2382
+ if (this.autoCompactionLoader) {
2383
+ this.autoCompactionLoader.stop();
2384
+ this.autoCompactionLoader = undefined;
2385
+ this.statusContainer.clear();
2386
+ }
2387
+ if (event.aborted) {
2388
+ if (event.reason === "manual") {
2389
+ this.showError("Compaction cancelled");
2390
+ }
2391
+ else {
2392
+ this.showStatus("Auto-compaction cancelled");
2393
+ }
2394
+ }
2395
+ else if (event.result) {
2396
+ this.chatContainer.clear();
2397
+ this.rebuildChatFromMessages();
2398
+ this.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
2399
+ this.footer.invalidate();
2400
+ }
2401
+ else if (event.errorMessage) {
2402
+ if (event.reason === "manual") {
2403
+ this.showError(event.errorMessage);
2404
+ }
2405
+ else {
2406
+ this.chatContainer.addChild(new Spacer(1));
2407
+ this.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
2408
+ }
2409
+ }
2410
+ void this.flushCompactionQueue({ willRetry: event.willRetry });
2411
+ this.ui.requestRender();
2412
+ break;
2413
+ }
2414
+ case "auto_retry_start": {
2415
+ // Set up escape to abort retry
2416
+ this.retryEscapeHandler = this.defaultEditor.onEscape;
2417
+ this.defaultEditor.onEscape = () => {
2418
+ this.session.abortRetry();
2419
+ };
2420
+ // Show retry indicator
2421
+ this.statusContainer.clear();
2422
+ this.retryCountdown?.dispose();
2423
+ const retryMessage = (seconds) => `Retrying (${event.attempt}/${event.maxAttempts}) in ${seconds}s... (${keyText("app.interrupt")} to cancel)`;
2424
+ this.retryLoader = new Loader(this.ui, (spinner) => theme.fg("warning", spinner), (text) => theme.fg("muted", text), retryMessage(Math.ceil(event.delayMs / 1000)));
2425
+ this.retryCountdown = new CountdownTimer(event.delayMs, this.ui, (seconds) => {
2426
+ this.retryLoader?.setMessage(retryMessage(seconds));
2427
+ }, () => {
2428
+ this.retryCountdown = undefined;
2429
+ });
2430
+ this.statusContainer.addChild(this.retryLoader);
2431
+ this.ui.requestRender();
2432
+ break;
2433
+ }
2434
+ case "auto_retry_end": {
2435
+ // Restore escape handler
2436
+ if (this.retryEscapeHandler) {
2437
+ this.defaultEditor.onEscape = this.retryEscapeHandler;
2438
+ this.retryEscapeHandler = undefined;
2439
+ }
2440
+ if (this.retryCountdown) {
2441
+ this.retryCountdown.dispose();
2442
+ this.retryCountdown = undefined;
2443
+ }
2444
+ // Stop loader
2445
+ if (this.retryLoader) {
2446
+ this.retryLoader.stop();
2447
+ this.retryLoader = undefined;
2448
+ this.statusContainer.clear();
2449
+ }
2450
+ // Show error only on final failure (success shows normal response)
2451
+ if (!event.success) {
2452
+ this.showError(`Retry failed after ${event.attempt} attempts: ${event.finalError || "Unknown error"}`);
2453
+ }
2454
+ this.ui.requestRender();
2455
+ break;
2456
+ }
2457
+ }
2458
+ }
2459
+ /** Extract text content from a user message */
2460
+ getUserMessageText(message) {
2461
+ if (message.role !== "user")
2462
+ return "";
2463
+ const textBlocks = typeof message.content === "string"
2464
+ ? [{ type: "text", text: message.content }]
2465
+ : message.content.filter((c) => c.type === "text");
2466
+ return textBlocks.map((c) => c.text).join("");
2467
+ }
2468
+ /**
2469
+ * Show a status message in the chat.
2470
+ *
2471
+ * If multiple status messages are emitted back-to-back (without anything else being added to the chat),
2472
+ * we update the previous status line instead of appending new ones to avoid log spam.
2473
+ */
2474
+ showStatus(message) {
2475
+ const children = this.chatContainer.children;
2476
+ const last = children.length > 0 ? children[children.length - 1] : undefined;
2477
+ const secondLast = children.length > 1 ? children[children.length - 2] : undefined;
2478
+ if (last && secondLast && last === this.lastStatusText && secondLast === this.lastStatusSpacer) {
2479
+ this.lastStatusText.setText(theme.fg("dim", message));
2480
+ this.ui.requestRender();
2481
+ return;
2482
+ }
2483
+ const spacer = new Spacer(1);
2484
+ const text = new Text(theme.fg("dim", message), 1, 0);
2485
+ this.chatContainer.addChild(spacer);
2486
+ this.chatContainer.addChild(text);
2487
+ this.lastStatusSpacer = spacer;
2488
+ this.lastStatusText = text;
2489
+ this.ui.requestRender();
2490
+ }
2491
+ addMessageToChat(message, options) {
2492
+ switch (message.role) {
2493
+ case "bashExecution": {
2494
+ const component = new BashExecutionComponent(message.command, this.ui, message.excludeFromContext);
2495
+ if (message.output) {
2496
+ component.appendOutput(message.output);
2497
+ }
2498
+ component.setComplete(message.exitCode, message.cancelled, message.truncated ? { truncated: true } : undefined, message.fullOutputPath);
2499
+ this.chatContainer.addChild(component);
2500
+ break;
2501
+ }
2502
+ case "custom": {
2503
+ if (message.display) {
2504
+ const renderer = this.session.extensionRunner.getMessageRenderer(message.customType);
2505
+ const component = new CustomMessageComponent(message, renderer, this.getMarkdownThemeWithSettings());
2506
+ component.setExpanded(this.toolOutputExpanded);
2507
+ this.chatContainer.addChild(component);
2508
+ }
2509
+ break;
2510
+ }
2511
+ case "compactionSummary": {
2512
+ this.chatContainer.addChild(new Spacer(1));
2513
+ const component = new CompactionSummaryMessageComponent(message, this.getMarkdownThemeWithSettings());
2514
+ component.setExpanded(this.toolOutputExpanded);
2515
+ this.chatContainer.addChild(component);
2516
+ break;
2517
+ }
2518
+ case "branchSummary": {
2519
+ this.chatContainer.addChild(new Spacer(1));
2520
+ const component = new BranchSummaryMessageComponent(message, this.getMarkdownThemeWithSettings());
2521
+ component.setExpanded(this.toolOutputExpanded);
2522
+ this.chatContainer.addChild(component);
2523
+ break;
2524
+ }
2525
+ case "user": {
2526
+ const textContent = this.getUserMessageText(message);
2527
+ if (textContent) {
2528
+ if (this.chatContainer.children.length > 0) {
2529
+ this.chatContainer.addChild(new Spacer(1));
2530
+ }
2531
+ const skillBlock = parseSkillBlock(textContent);
2532
+ if (skillBlock) {
2533
+ // Render skill block (collapsible)
2534
+ const component = new SkillInvocationMessageComponent(skillBlock, this.getMarkdownThemeWithSettings());
2535
+ component.setExpanded(this.toolOutputExpanded);
2536
+ this.chatContainer.addChild(component);
2537
+ // Render user message separately if present
2538
+ if (skillBlock.userMessage) {
2539
+ const userComponent = new UserMessageComponent(skillBlock.userMessage, this.getMarkdownThemeWithSettings());
2540
+ this.chatContainer.addChild(userComponent);
2541
+ }
2542
+ }
2543
+ else {
2544
+ const userComponent = new UserMessageComponent(textContent, this.getMarkdownThemeWithSettings());
2545
+ this.chatContainer.addChild(userComponent);
2546
+ }
2547
+ if (options?.populateHistory) {
2548
+ this.editor.addToHistory?.(textContent);
2549
+ }
2550
+ }
2551
+ break;
2552
+ }
2553
+ case "assistant": {
2554
+ const assistantComponent = new AssistantMessageComponent(message, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel);
2555
+ this.chatContainer.addChild(assistantComponent);
2556
+ break;
2557
+ }
2558
+ case "toolResult": {
2559
+ // Tool results are rendered inline with tool calls, handled separately
2560
+ break;
2561
+ }
2562
+ default: {
2563
+ const _exhaustive = message;
2564
+ }
2565
+ }
2566
+ }
2567
+ /**
2568
+ * Render session context to chat. Used for initial load and rebuild after compaction.
2569
+ * @param sessionContext Session context to render
2570
+ * @param options.updateFooter Update footer state
2571
+ * @param options.populateHistory Add user messages to editor history
2572
+ */
2573
+ renderSessionContext(sessionContext, options = {}) {
2574
+ this.pendingTools.clear();
2575
+ const renderedPendingTools = new Map();
2576
+ if (options.updateFooter) {
2577
+ this.footer.invalidate();
2578
+ this.updateEditorBorderColor();
2579
+ }
2580
+ for (const message of sessionContext.messages) {
2581
+ // Assistant messages need special handling for tool calls
2582
+ if (message.role === "assistant") {
2583
+ this.addMessageToChat(message);
2584
+ // Render tool call components
2585
+ for (const content of message.content) {
2586
+ if (content.type === "toolCall") {
2587
+ const component = new ToolExecutionComponent(content.name, content.id, content.arguments, {
2588
+ showImages: this.settingsManager.getShowImages(),
2589
+ imageWidthCells: this.settingsManager.getImageWidthCells(),
2590
+ }, this.getRegisteredToolDefinition(content.name), this.ui, this.sessionManager.getCwd());
2591
+ component.setExpanded(this.toolOutputExpanded);
2592
+ this.chatContainer.addChild(component);
2593
+ if (message.stopReason === "aborted" || message.stopReason === "error") {
2594
+ let errorMessage;
2595
+ if (message.stopReason === "aborted") {
2596
+ const retryAttempt = this.session.retryAttempt;
2597
+ errorMessage =
2598
+ retryAttempt > 0
2599
+ ? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? "s" : ""}`
2600
+ : "Operation aborted";
2601
+ }
2602
+ else {
2603
+ errorMessage = message.errorMessage || "Error";
2604
+ }
2605
+ component.updateResult({ content: [{ type: "text", text: errorMessage }], isError: true });
2606
+ }
2607
+ else {
2608
+ renderedPendingTools.set(content.id, component);
2609
+ }
2610
+ }
2611
+ }
2612
+ }
2613
+ else if (message.role === "toolResult") {
2614
+ // Match tool results to pending tool components
2615
+ const component = renderedPendingTools.get(message.toolCallId);
2616
+ if (component) {
2617
+ component.updateResult(message);
2618
+ renderedPendingTools.delete(message.toolCallId);
2619
+ }
2620
+ }
2621
+ else {
2622
+ // All other messages use standard rendering
2623
+ this.addMessageToChat(message, options);
2624
+ }
2625
+ }
2626
+ for (const [toolCallId, component] of renderedPendingTools) {
2627
+ this.pendingTools.set(toolCallId, component);
2628
+ }
2629
+ this.ui.requestRender();
2630
+ }
2631
+ renderInitialMessages() {
2632
+ // Get aligned messages and entries from session context
2633
+ const context = this.sessionManager.buildSessionContext();
2634
+ this.renderSessionContext(context, {
2635
+ updateFooter: true,
2636
+ populateHistory: true,
2637
+ });
2638
+ // Show compaction info if session was compacted
2639
+ const allEntries = this.sessionManager.getEntries();
2640
+ const compactionCount = allEntries.filter((e) => e.type === "compaction").length;
2641
+ if (compactionCount > 0) {
2642
+ const times = compactionCount === 1 ? "1 time" : `${compactionCount} times`;
2643
+ this.showStatus(`Session compacted ${times}`);
2644
+ }
2645
+ }
2646
+ async getUserInput() {
2647
+ const queuedInput = this.pendingUserInputs.shift();
2648
+ if (queuedInput !== undefined) {
2649
+ return queuedInput;
2650
+ }
2651
+ return new Promise((resolve) => {
2652
+ this.onInputCallback = (text) => {
2653
+ this.onInputCallback = undefined;
2654
+ resolve(text);
2655
+ };
2656
+ });
2657
+ }
2658
+ rebuildChatFromMessages() {
2659
+ this.chatContainer.clear();
2660
+ const context = this.sessionManager.buildSessionContext();
2661
+ this.renderSessionContext(context);
2662
+ }
2663
+ // =========================================================================
2664
+ // Key handlers
2665
+ // =========================================================================
2666
+ handleCtrlC() {
2667
+ const now = Date.now();
2668
+ if (now - this.lastSigintTime < 500) {
2669
+ void this.shutdown();
2670
+ }
2671
+ else {
2672
+ this.clearEditor();
2673
+ this.lastSigintTime = now;
2674
+ }
2675
+ }
2676
+ handleCtrlD() {
2677
+ // Only called when editor is empty (enforced by CustomEditor)
2678
+ void this.shutdown();
2679
+ }
2680
+ /**
2681
+ * Gracefully shutdown the agent.
2682
+ * Stops the TUI before emitting shutdown events so extension UI cleanup cannot
2683
+ * repaint the final frame while the process is exiting.
2684
+ */
2685
+ isShuttingDown = false;
2686
+ async shutdown(options) {
2687
+ if (this.isShuttingDown)
2688
+ return;
2689
+ this.isShuttingDown = true;
2690
+ this.unregisterSignalHandlers();
2691
+ if (options?.fromSignal) {
2692
+ // Signal-triggered shutdown (SIGTERM/SIGHUP). Emit extension cleanup
2693
+ // (session_shutdown) BEFORE touching the terminal. Extension teardown
2694
+ // such as removing sockets does not write to the tty, so it must not be
2695
+ // skipped if a later terminal-restore write fails on a dead or stalled
2696
+ // terminal. If the terminal is gone, the restore writes below emit EIO,
2697
+ // which the stdout/stderr error handler turns into emergencyTerminalExit;
2698
+ // the render loop is already idle, so this cannot hot-spin (see #4144).
2699
+ await this.runtimeHost.dispose();
2700
+ await this.ui.terminal.drainInput(1000);
2701
+ this.stop();
2702
+ process.exit(0);
2703
+ }
2704
+ // Interactive quit (Ctrl+D, Ctrl+C, /quit, extension shutdown()). Stop the
2705
+ // TUI before emitting shutdown events so extension UI cleanup cannot repaint
2706
+ // the final frame while the process is exiting.
2707
+ // Drain any in-flight Kitty key release events before stopping.
2708
+ // This prevents escape sequences from leaking to the parent shell over slow SSH.
2709
+ await this.ui.terminal.drainInput(1000);
2710
+ this.stop();
2711
+ await this.runtimeHost.dispose();
2712
+ const resumeCommand = formatResumeCommand(this.sessionManager);
2713
+ if (resumeCommand) {
2714
+ process.stdout.write(`${chalk.dim("To resume this session:")} ${resumeCommand}\n`);
2715
+ }
2716
+ process.exit(0);
2717
+ }
2718
+ emergencyTerminalExit() {
2719
+ this.isShuttingDown = true;
2720
+ this.unregisterSignalHandlers();
2721
+ killTrackedDetachedChildren();
2722
+ // The terminal is gone. Do not run normal shutdown because TUI and
2723
+ // extension cleanup can write restore sequences and re-trigger EIO.
2724
+ process.exit(129);
2725
+ }
2726
+ /**
2727
+ * Last-resort handler for uncaught exceptions. The TUI puts stdin into raw
2728
+ * mode and hides the cursor; without this handler, an uncaught throw from
2729
+ * anywhere (e.g. an extension's async `ChildProcess.on("exit")` callback)
2730
+ * tears down the process while leaving the terminal in raw mode with no
2731
+ * cursor, requiring `stty sane && reset` to recover.
2732
+ *
2733
+ * Unlike emergencyTerminalExit, the terminal is still alive here, so we
2734
+ * call ui.stop() to restore cooked mode, the cursor, and disable bracketed
2735
+ * paste / Kitty / modifyOtherKeys sequences.
2736
+ */
2737
+ uncaughtCrash(error) {
2738
+ if (this.isShuttingDown) {
2739
+ process.exit(1);
2740
+ }
2741
+ this.isShuttingDown = true;
2742
+ try {
2743
+ this.unregisterSignalHandlers();
2744
+ }
2745
+ catch { }
2746
+ try {
2747
+ killTrackedDetachedChildren();
2748
+ }
2749
+ catch { }
2750
+ try {
2751
+ this.ui.stop();
2752
+ }
2753
+ catch { }
2754
+ console.error("pi exiting due to uncaughtException:");
2755
+ console.error(error);
2756
+ process.exit(1);
2757
+ }
2758
+ /**
2759
+ * Check if shutdown was requested and perform shutdown if so.
2760
+ */
2761
+ async checkShutdownRequested() {
2762
+ if (!this.shutdownRequested)
2763
+ return;
2764
+ await this.shutdown();
2765
+ }
2766
+ registerSignalHandlers() {
2767
+ this.unregisterSignalHandlers();
2768
+ const signals = ["SIGTERM"];
2769
+ if (process.platform !== "win32") {
2770
+ signals.push("SIGHUP");
2771
+ }
2772
+ for (const signal of signals) {
2773
+ const handler = () => {
2774
+ // SIGHUP no longer hard-exits: graceful shutdown emits session_shutdown
2775
+ // first, then attempts terminal restore. A genuinely dead terminal
2776
+ // surfaces as an EIO on the restore writes, which the stdout/stderr
2777
+ // error handler converts into emergencyTerminalExit (see #4144, #5080).
2778
+ killTrackedDetachedChildren();
2779
+ void this.shutdown({ fromSignal: true });
2780
+ };
2781
+ process.prependListener(signal, handler);
2782
+ this.signalCleanupHandlers.push(() => process.off(signal, handler));
2783
+ }
2784
+ const terminalErrorHandler = (error) => {
2785
+ if (isDeadTerminalError(error)) {
2786
+ this.emergencyTerminalExit();
2787
+ }
2788
+ throw error;
2789
+ };
2790
+ process.stdout.on("error", terminalErrorHandler);
2791
+ process.stderr.on("error", terminalErrorHandler);
2792
+ this.signalCleanupHandlers.push(() => process.stdout.off("error", terminalErrorHandler));
2793
+ this.signalCleanupHandlers.push(() => process.stderr.off("error", terminalErrorHandler));
2794
+ // Restore the terminal before the process dies on any uncaught throw.
2795
+ // Without this, an unhandled exception from extension code (or anywhere
2796
+ // in pi) leaves the terminal in raw mode with no cursor.
2797
+ const uncaughtExceptionHandler = (error) => this.uncaughtCrash(error);
2798
+ process.prependListener("uncaughtException", uncaughtExceptionHandler);
2799
+ this.signalCleanupHandlers.push(() => process.off("uncaughtException", uncaughtExceptionHandler));
2800
+ }
2801
+ unregisterSignalHandlers() {
2802
+ for (const cleanup of this.signalCleanupHandlers) {
2803
+ cleanup();
2804
+ }
2805
+ this.signalCleanupHandlers = [];
2806
+ }
2807
+ handleCtrlZ() {
2808
+ if (process.platform === "win32") {
2809
+ this.showStatus("Suspend to background is not supported on Windows");
2810
+ return;
2811
+ }
2812
+ // Keep the event loop alive while suspended. Without this, stopping the TUI
2813
+ // can leave Node with no ref'ed handles, causing the process to exit on fg
2814
+ // before the SIGCONT handler gets a chance to restore the terminal.
2815
+ const suspendKeepAlive = setInterval(() => { }, 2 ** 30);
2816
+ // Ignore SIGINT while suspended so Ctrl+C in the terminal does not
2817
+ // kill the backgrounded process. The handler is removed on resume.
2818
+ const ignoreSigint = () => { };
2819
+ process.on("SIGINT", ignoreSigint);
2820
+ // Set up handler to restore TUI when resumed
2821
+ process.once("SIGCONT", () => {
2822
+ clearInterval(suspendKeepAlive);
2823
+ process.removeListener("SIGINT", ignoreSigint);
2824
+ this.ui.start();
2825
+ this.ui.requestRender(true);
2826
+ });
2827
+ try {
2828
+ // Stop the TUI (restore terminal to normal mode)
2829
+ this.ui.stop();
2830
+ // Send SIGTSTP to process group (pid=0 means all processes in group)
2831
+ process.kill(0, "SIGTSTP");
2832
+ }
2833
+ catch (error) {
2834
+ clearInterval(suspendKeepAlive);
2835
+ process.removeListener("SIGINT", ignoreSigint);
2836
+ throw error;
2837
+ }
2838
+ }
2839
+ async handleFollowUp() {
2840
+ const text = (this.editor.getExpandedText?.() ?? this.editor.getText()).trim();
2841
+ if (!text)
2842
+ return;
2843
+ // Queue input during compaction (extension commands execute immediately)
2844
+ if (this.session.isCompacting) {
2845
+ if (this.isExtensionCommand(text)) {
2846
+ this.editor.addToHistory?.(text);
2847
+ this.editor.setText("");
2848
+ await this.session.prompt(text);
2849
+ }
2850
+ else {
2851
+ this.queueCompactionMessage(text, "followUp");
2852
+ }
2853
+ return;
2854
+ }
2855
+ // Alt+Enter queues a follow-up message (waits until agent finishes)
2856
+ // This handles extension commands (execute immediately), prompt template expansion, and queueing
2857
+ if (this.session.isStreaming) {
2858
+ this.editor.addToHistory?.(text);
2859
+ this.editor.setText("");
2860
+ await this.session.prompt(text, { streamingBehavior: "followUp" });
2861
+ this.updatePendingMessagesDisplay();
2862
+ this.ui.requestRender();
2863
+ }
2864
+ // If not streaming, Alt+Enter acts like regular Enter (trigger onSubmit)
2865
+ else if (this.editor.onSubmit) {
2866
+ this.editor.setText("");
2867
+ this.editor.onSubmit(text);
2868
+ }
2869
+ }
2870
+ handleDequeue() {
2871
+ const restored = this.restoreQueuedMessagesToEditor();
2872
+ if (restored === 0) {
2873
+ this.showStatus("No queued messages to restore");
2874
+ }
2875
+ else {
2876
+ this.showStatus(`Restored ${restored} queued message${restored > 1 ? "s" : ""} to editor`);
2877
+ }
2878
+ }
2879
+ updateEditorBorderColor() {
2880
+ if (this.isBashMode) {
2881
+ this.editor.borderColor = theme.getBashModeBorderColor();
2882
+ }
2883
+ else {
2884
+ const level = this.session.thinkingLevel || "off";
2885
+ this.editor.borderColor = theme.getThinkingBorderColor(level);
2886
+ }
2887
+ this.ui.requestRender();
2888
+ }
2889
+ cycleThinkingLevel() {
2890
+ const newLevel = this.session.cycleThinkingLevel();
2891
+ if (newLevel === undefined) {
2892
+ this.showStatus("Current model does not support thinking");
2893
+ }
2894
+ else {
2895
+ this.footer.invalidate();
2896
+ this.updateEditorBorderColor();
2897
+ this.showStatus(`Thinking level: ${newLevel}`);
2898
+ }
2899
+ }
2900
+ async cycleModel(direction) {
2901
+ try {
2902
+ const result = await this.session.cycleModel(direction);
2903
+ if (result === undefined) {
2904
+ const msg = this.session.scopedModels.length > 0 ? "Only one model in scope" : "Only one model available";
2905
+ this.showStatus(msg);
2906
+ }
2907
+ else {
2908
+ this.footer.invalidate();
2909
+ this.updateEditorBorderColor();
2910
+ const thinkingStr = result.model.reasoning && result.thinkingLevel !== "off" ? ` (thinking: ${result.thinkingLevel})` : "";
2911
+ this.showStatus(`Switched to ${result.model.name || result.model.id}${thinkingStr}`);
2912
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(result.model);
2913
+ }
2914
+ }
2915
+ catch (error) {
2916
+ this.showError(error instanceof Error ? error.message : String(error));
2917
+ }
2918
+ }
2919
+ toggleToolOutputExpansion() {
2920
+ this.setToolsExpanded(!this.toolOutputExpanded);
2921
+ }
2922
+ setToolsExpanded(expanded) {
2923
+ this.toolOutputExpanded = expanded;
2924
+ const activeHeader = this.customHeader ?? this.builtInHeader;
2925
+ if (isExpandable(activeHeader)) {
2926
+ activeHeader.setExpanded(expanded);
2927
+ }
2928
+ for (const child of this.chatContainer.children) {
2929
+ if (isExpandable(child)) {
2930
+ child.setExpanded(expanded);
2931
+ }
2932
+ }
2933
+ this.ui.requestRender();
2934
+ }
2935
+ toggleThinkingBlockVisibility() {
2936
+ this.hideThinkingBlock = !this.hideThinkingBlock;
2937
+ this.settingsManager.setHideThinkingBlock(this.hideThinkingBlock);
2938
+ // Rebuild chat from session messages
2939
+ this.chatContainer.clear();
2940
+ this.rebuildChatFromMessages();
2941
+ // If streaming, re-add the streaming component with updated visibility and re-render
2942
+ if (this.streamingComponent && this.streamingMessage) {
2943
+ this.streamingComponent.setHideThinkingBlock(this.hideThinkingBlock);
2944
+ this.streamingComponent.updateContent(this.streamingMessage);
2945
+ this.chatContainer.addChild(this.streamingComponent);
2946
+ }
2947
+ this.showStatus(`Thinking blocks: ${this.hideThinkingBlock ? "hidden" : "visible"}`);
2948
+ }
2949
+ async openExternalEditor() {
2950
+ // Determine editor (respect $VISUAL, then $EDITOR)
2951
+ const editorCmd = process.env.VISUAL || process.env.EDITOR;
2952
+ if (!editorCmd) {
2953
+ this.showWarning("No editor configured. Set $VISUAL or $EDITOR environment variable.");
2954
+ return;
2955
+ }
2956
+ const currentText = this.editor.getExpandedText?.() ?? this.editor.getText();
2957
+ const tmpFile = path.join(os.tmpdir(), `pi-editor-${Date.now()}.omk.md`);
2958
+ try {
2959
+ // Write current content to temp file
2960
+ fs.writeFileSync(tmpFile, currentText, "utf-8");
2961
+ // Stop TUI to release terminal
2962
+ this.ui.stop();
2963
+ // Split by space to support editor arguments (e.g., "code --wait")
2964
+ const [editor, ...editorArgs] = editorCmd.split(" ");
2965
+ process.stdout.write(`Launching external editor: ${editorCmd}\nPi will resume when the editor exits.\n`);
2966
+ // Do not use spawnSync here. On Windows, synchronous child_process calls can keep
2967
+ // Node/libuv's console input read active after ui.stop() pauses stdin, racing
2968
+ // vim/nvim for the console input buffer until Ctrl+C cancels the pending read.
2969
+ const status = await new Promise((resolve) => {
2970
+ const child = spawn(editor, [...editorArgs, tmpFile], {
2971
+ stdio: "inherit",
2972
+ shell: process.platform === "win32",
2973
+ });
2974
+ child.on("error", () => resolve(null));
2975
+ child.on("close", (code) => resolve(code));
2976
+ });
2977
+ // On successful exit (status 0), replace editor content
2978
+ if (status === 0) {
2979
+ const newContent = fs.readFileSync(tmpFile, "utf-8").replace(/\n$/, "");
2980
+ this.editor.setText(newContent);
2981
+ }
2982
+ // On non-zero exit, keep original text (no action needed)
2983
+ }
2984
+ finally {
2985
+ // Clean up temp file
2986
+ try {
2987
+ fs.unlinkSync(tmpFile);
2988
+ }
2989
+ catch {
2990
+ // Ignore cleanup errors
2991
+ }
2992
+ // Restart TUI
2993
+ this.ui.start();
2994
+ // Force full re-render since external editor uses alternate screen
2995
+ this.ui.requestRender(true);
2996
+ }
2997
+ }
2998
+ // =========================================================================
2999
+ // UI helpers
3000
+ // =========================================================================
3001
+ clearEditor() {
3002
+ this.editor.setText("");
3003
+ this.ui.requestRender();
3004
+ }
3005
+ showError(errorMessage) {
3006
+ this.chatContainer.addChild(new Spacer(1));
3007
+ this.chatContainer.addChild(new Text(theme.fg("error", `Error: ${errorMessage}`), 1, 0));
3008
+ this.chatContainer.addChild(new Spacer(1));
3009
+ this.ui.requestRender();
3010
+ }
3011
+ showWarning(warningMessage) {
3012
+ this.chatContainer.addChild(new Spacer(1));
3013
+ this.chatContainer.addChild(new Text(theme.fg("warning", `Warning: ${warningMessage}`), 1, 0));
3014
+ this.ui.requestRender();
3015
+ }
3016
+ showNewVersionNotification(release) {
3017
+ const action = theme.fg("accent", `${APP_NAME} update`);
3018
+ const updateInstruction = theme.fg("muted", `New version ${release.version} is available. Run `) + action;
3019
+ const changelogUrl = "https://github.com/dmae97/omk/releases";
3020
+ const changelogLink = getCapabilities().hyperlinks
3021
+ ? hyperlink(theme.fg("accent", "open changelog"), changelogUrl)
3022
+ : theme.fg("accent", changelogUrl);
3023
+ const changelogLine = theme.fg("muted", "Changelog: ") + changelogLink;
3024
+ const note = release.note?.trim();
3025
+ this.chatContainer.addChild(new Spacer(1));
3026
+ this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
3027
+ this.chatContainer.addChild(new Text(`${theme.bold(theme.fg("warning", "Update Available"))}\n${updateInstruction}`, 1, 0));
3028
+ if (note) {
3029
+ this.chatContainer.addChild(new Spacer(1));
3030
+ this.chatContainer.addChild(new Markdown(note, 1, 0, this.getMarkdownThemeWithSettings(), {
3031
+ color: (text) => theme.fg("muted", text),
3032
+ }));
3033
+ this.chatContainer.addChild(new Spacer(1));
3034
+ }
3035
+ this.chatContainer.addChild(new Text(changelogLine, 1, 0));
3036
+ this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
3037
+ this.ui.requestRender();
3038
+ }
3039
+ showPackageUpdateNotification(packages) {
3040
+ const action = theme.fg("accent", `${APP_NAME} update`);
3041
+ const updateInstruction = theme.fg("muted", "Package updates are available. Run ") + action;
3042
+ const packageLines = packages.map((pkg) => `- ${pkg}`).join("\n");
3043
+ this.chatContainer.addChild(new Spacer(1));
3044
+ this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
3045
+ this.chatContainer.addChild(new Text(`${theme.bold(theme.fg("warning", "Package Updates Available"))}\n${updateInstruction}\n${theme.fg("muted", "Packages:")}\n${packageLines}`, 1, 0));
3046
+ this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
3047
+ this.ui.requestRender();
3048
+ }
3049
+ /**
3050
+ * Get all queued messages (read-only).
3051
+ * Combines session queue and compaction queue.
3052
+ */
3053
+ getAllQueuedMessages() {
3054
+ return {
3055
+ steering: [
3056
+ ...this.session.getSteeringMessages(),
3057
+ ...this.compactionQueuedMessages.filter((msg) => msg.mode === "steer").map((msg) => msg.text),
3058
+ ],
3059
+ followUp: [
3060
+ ...this.session.getFollowUpMessages(),
3061
+ ...this.compactionQueuedMessages.filter((msg) => msg.mode === "followUp").map((msg) => msg.text),
3062
+ ],
3063
+ };
3064
+ }
3065
+ /**
3066
+ * Clear all queued messages and return their contents.
3067
+ * Clears both session queue and compaction queue.
3068
+ */
3069
+ clearAllQueues() {
3070
+ const { steering, followUp } = this.session.clearQueue();
3071
+ const compactionSteering = this.compactionQueuedMessages
3072
+ .filter((msg) => msg.mode === "steer")
3073
+ .map((msg) => msg.text);
3074
+ const compactionFollowUp = this.compactionQueuedMessages
3075
+ .filter((msg) => msg.mode === "followUp")
3076
+ .map((msg) => msg.text);
3077
+ this.compactionQueuedMessages = [];
3078
+ return {
3079
+ steering: [...steering, ...compactionSteering],
3080
+ followUp: [...followUp, ...compactionFollowUp],
3081
+ };
3082
+ }
3083
+ updatePendingMessagesDisplay() {
3084
+ this.pendingMessagesContainer.clear();
3085
+ const { steering: steeringMessages, followUp: followUpMessages } = this.getAllQueuedMessages();
3086
+ if (steeringMessages.length > 0 || followUpMessages.length > 0) {
3087
+ this.pendingMessagesContainer.addChild(new Spacer(1));
3088
+ for (const message of steeringMessages) {
3089
+ const text = theme.fg("dim", `Steering: ${message}`);
3090
+ this.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));
3091
+ }
3092
+ for (const message of followUpMessages) {
3093
+ const text = theme.fg("dim", `Follow-up: ${message}`);
3094
+ this.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));
3095
+ }
3096
+ const dequeueHint = this.getAppKeyDisplay("app.message.dequeue");
3097
+ const hintText = theme.fg("dim", `↳ ${dequeueHint} to edit all queued messages`);
3098
+ this.pendingMessagesContainer.addChild(new TruncatedText(hintText, 1, 0));
3099
+ }
3100
+ }
3101
+ restoreQueuedMessagesToEditor(options) {
3102
+ const { steering, followUp } = this.clearAllQueues();
3103
+ const allQueued = [...steering, ...followUp];
3104
+ if (allQueued.length === 0) {
3105
+ this.updatePendingMessagesDisplay();
3106
+ if (options?.abort) {
3107
+ this.agent.abort();
3108
+ }
3109
+ return 0;
3110
+ }
3111
+ const queuedText = allQueued.join("\n\n");
3112
+ const currentText = options?.currentText ?? this.editor.getText();
3113
+ const combinedText = [queuedText, currentText].filter((t) => t.trim()).join("\n\n");
3114
+ this.editor.setText(combinedText);
3115
+ this.updatePendingMessagesDisplay();
3116
+ if (options?.abort) {
3117
+ this.agent.abort();
3118
+ }
3119
+ return allQueued.length;
3120
+ }
3121
+ queueCompactionMessage(text, mode) {
3122
+ this.compactionQueuedMessages.push({ text, mode });
3123
+ this.editor.addToHistory?.(text);
3124
+ this.editor.setText("");
3125
+ this.updatePendingMessagesDisplay();
3126
+ this.showStatus("Queued message for after compaction");
3127
+ }
3128
+ isExtensionCommand(text) {
3129
+ if (!text.startsWith("/"))
3130
+ return false;
3131
+ const extensionRunner = this.session.extensionRunner;
3132
+ const spaceIndex = text.indexOf(" ");
3133
+ const commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);
3134
+ return !!extensionRunner.getCommand(commandName);
3135
+ }
3136
+ async flushCompactionQueue(options) {
3137
+ if (this.compactionQueuedMessages.length === 0) {
3138
+ return;
3139
+ }
3140
+ const queuedMessages = [...this.compactionQueuedMessages];
3141
+ this.compactionQueuedMessages = [];
3142
+ this.updatePendingMessagesDisplay();
3143
+ const restoreQueue = (error) => {
3144
+ this.session.clearQueue();
3145
+ this.compactionQueuedMessages = queuedMessages;
3146
+ this.updatePendingMessagesDisplay();
3147
+ this.showError(`Failed to send queued message${queuedMessages.length > 1 ? "s" : ""}: ${error instanceof Error ? error.message : String(error)}`);
3148
+ };
3149
+ try {
3150
+ if (options?.willRetry) {
3151
+ // When retry is pending, queue messages for the retry turn
3152
+ for (const message of queuedMessages) {
3153
+ if (this.isExtensionCommand(message.text)) {
3154
+ await this.session.prompt(message.text);
3155
+ }
3156
+ else if (message.mode === "followUp") {
3157
+ await this.session.followUp(message.text);
3158
+ }
3159
+ else {
3160
+ await this.session.steer(message.text);
3161
+ }
3162
+ }
3163
+ this.updatePendingMessagesDisplay();
3164
+ return;
3165
+ }
3166
+ // Find first non-extension-command message to use as prompt
3167
+ const firstPromptIndex = queuedMessages.findIndex((message) => !this.isExtensionCommand(message.text));
3168
+ if (firstPromptIndex === -1) {
3169
+ // All extension commands - execute them all
3170
+ for (const message of queuedMessages) {
3171
+ await this.session.prompt(message.text);
3172
+ }
3173
+ return;
3174
+ }
3175
+ // Execute any extension commands before the first prompt
3176
+ const preCommands = queuedMessages.slice(0, firstPromptIndex);
3177
+ const firstPrompt = queuedMessages[firstPromptIndex];
3178
+ const rest = queuedMessages.slice(firstPromptIndex + 1);
3179
+ for (const message of preCommands) {
3180
+ await this.session.prompt(message.text);
3181
+ }
3182
+ // Send first prompt (starts streaming)
3183
+ const promptPromise = this.session.prompt(firstPrompt.text).catch((error) => {
3184
+ restoreQueue(error);
3185
+ });
3186
+ // Queue remaining messages
3187
+ for (const message of rest) {
3188
+ if (this.isExtensionCommand(message.text)) {
3189
+ await this.session.prompt(message.text);
3190
+ }
3191
+ else if (message.mode === "followUp") {
3192
+ await this.session.followUp(message.text);
3193
+ }
3194
+ else {
3195
+ await this.session.steer(message.text);
3196
+ }
3197
+ }
3198
+ this.updatePendingMessagesDisplay();
3199
+ void promptPromise;
3200
+ }
3201
+ catch (error) {
3202
+ restoreQueue(error);
3203
+ }
3204
+ }
3205
+ /** Move pending bash components from pending area to chat */
3206
+ flushPendingBashComponents() {
3207
+ for (const component of this.pendingBashComponents) {
3208
+ this.pendingMessagesContainer.removeChild(component);
3209
+ this.chatContainer.addChild(component);
3210
+ }
3211
+ this.pendingBashComponents = [];
3212
+ }
3213
+ // =========================================================================
3214
+ // Selectors
3215
+ // =========================================================================
3216
+ /**
3217
+ * Shows a selector component in place of the editor.
3218
+ * @param create Factory that receives a `done` callback and returns the component and focus target
3219
+ */
3220
+ showSelector(create) {
3221
+ const done = () => {
3222
+ this.editorContainer.clear();
3223
+ this.editorContainer.addChild(this.editor);
3224
+ this.ui.setFocus(this.editor);
3225
+ };
3226
+ const { component, focus } = create(done);
3227
+ this.editorContainer.clear();
3228
+ this.editorContainer.addChild(component);
3229
+ this.ui.setFocus(focus);
3230
+ this.ui.requestRender();
3231
+ }
3232
+ showSettingsSelector() {
3233
+ this.showSelector((done) => {
3234
+ const selector = new SettingsSelectorComponent({
3235
+ autoCompact: this.session.autoCompactionEnabled,
3236
+ showImages: this.settingsManager.getShowImages(),
3237
+ imageWidthCells: this.settingsManager.getImageWidthCells(),
3238
+ autoResizeImages: this.settingsManager.getImageAutoResize(),
3239
+ blockImages: this.settingsManager.getBlockImages(),
3240
+ enableSkillCommands: this.settingsManager.getEnableSkillCommands(),
3241
+ steeringMode: this.session.steeringMode,
3242
+ followUpMode: this.session.followUpMode,
3243
+ transport: this.settingsManager.getTransport(),
3244
+ httpIdleTimeoutMs: this.settingsManager.getHttpIdleTimeoutMs(),
3245
+ thinkingLevel: this.session.thinkingLevel,
3246
+ availableThinkingLevels: this.session.getAvailableThinkingLevels(),
3247
+ currentTheme: this.settingsManager.getTheme() || "dark",
3248
+ availableThemes: getAvailableThemes(),
3249
+ hideThinkingBlock: this.hideThinkingBlock,
3250
+ collapseChangelog: this.settingsManager.getCollapseChangelog(),
3251
+ enableInstallTelemetry: this.settingsManager.getEnableInstallTelemetry(),
3252
+ doubleEscapeAction: this.settingsManager.getDoubleEscapeAction(),
3253
+ treeFilterMode: this.settingsManager.getTreeFilterMode(),
3254
+ showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
3255
+ editorPaddingX: this.settingsManager.getEditorPaddingX(),
3256
+ autocompleteMaxVisible: this.settingsManager.getAutocompleteMaxVisible(),
3257
+ quietStartup: this.settingsManager.getQuietStartup(),
3258
+ clearOnShrink: this.settingsManager.getClearOnShrink(),
3259
+ showTerminalProgress: this.settingsManager.getShowTerminalProgress(),
3260
+ warnings: this.settingsManager.getWarnings(),
3261
+ }, {
3262
+ onAutoCompactChange: (enabled) => {
3263
+ this.session.setAutoCompactionEnabled(enabled);
3264
+ this.footer.setAutoCompactEnabled(enabled);
3265
+ },
3266
+ onShowImagesChange: (enabled) => {
3267
+ this.settingsManager.setShowImages(enabled);
3268
+ for (const child of this.chatContainer.children) {
3269
+ if (child instanceof ToolExecutionComponent) {
3270
+ child.setShowImages(enabled);
3271
+ }
3272
+ }
3273
+ },
3274
+ onImageWidthCellsChange: (width) => {
3275
+ this.settingsManager.setImageWidthCells(width);
3276
+ for (const child of this.chatContainer.children) {
3277
+ if (child instanceof ToolExecutionComponent) {
3278
+ child.setImageWidthCells(width);
3279
+ }
3280
+ }
3281
+ },
3282
+ onAutoResizeImagesChange: (enabled) => {
3283
+ this.settingsManager.setImageAutoResize(enabled);
3284
+ },
3285
+ onBlockImagesChange: (blocked) => {
3286
+ this.settingsManager.setBlockImages(blocked);
3287
+ },
3288
+ onEnableSkillCommandsChange: (enabled) => {
3289
+ this.settingsManager.setEnableSkillCommands(enabled);
3290
+ this.setupAutocompleteProvider();
3291
+ },
3292
+ onSteeringModeChange: (mode) => {
3293
+ this.session.setSteeringMode(mode);
3294
+ },
3295
+ onFollowUpModeChange: (mode) => {
3296
+ this.session.setFollowUpMode(mode);
3297
+ },
3298
+ onTransportChange: (transport) => {
3299
+ this.settingsManager.setTransport(transport);
3300
+ this.session.agent.transport = transport;
3301
+ },
3302
+ onHttpIdleTimeoutMsChange: (timeoutMs) => {
3303
+ this.settingsManager.setHttpIdleTimeoutMs(timeoutMs);
3304
+ configureHttpDispatcher(timeoutMs);
3305
+ this.showStatus(`HTTP idle timeout: ${formatHttpIdleTimeoutMs(timeoutMs)}`);
3306
+ },
3307
+ onThinkingLevelChange: (level) => {
3308
+ this.session.setThinkingLevel(level);
3309
+ this.footer.invalidate();
3310
+ this.updateEditorBorderColor();
3311
+ },
3312
+ onThemeChange: (themeName) => {
3313
+ const result = setTheme(themeName, true);
3314
+ this.settingsManager.setTheme(themeName);
3315
+ this.ui.invalidate();
3316
+ if (!result.success) {
3317
+ this.showError(`Failed to load theme "${themeName}": ${result.error}\nFell back to dark theme.`);
3318
+ }
3319
+ },
3320
+ onThemePreview: (themeName) => {
3321
+ const result = setTheme(themeName, true);
3322
+ if (result.success) {
3323
+ this.ui.invalidate();
3324
+ this.ui.requestRender();
3325
+ }
3326
+ },
3327
+ onHideThinkingBlockChange: (hidden) => {
3328
+ this.hideThinkingBlock = hidden;
3329
+ this.settingsManager.setHideThinkingBlock(hidden);
3330
+ for (const child of this.chatContainer.children) {
3331
+ if (child instanceof AssistantMessageComponent) {
3332
+ child.setHideThinkingBlock(hidden);
3333
+ }
3334
+ }
3335
+ this.chatContainer.clear();
3336
+ this.rebuildChatFromMessages();
3337
+ },
3338
+ onCollapseChangelogChange: (collapsed) => {
3339
+ this.settingsManager.setCollapseChangelog(collapsed);
3340
+ },
3341
+ onEnableInstallTelemetryChange: (enabled) => {
3342
+ this.settingsManager.setEnableInstallTelemetry(enabled);
3343
+ },
3344
+ onQuietStartupChange: (enabled) => {
3345
+ this.settingsManager.setQuietStartup(enabled);
3346
+ },
3347
+ onDoubleEscapeActionChange: (action) => {
3348
+ this.settingsManager.setDoubleEscapeAction(action);
3349
+ },
3350
+ onTreeFilterModeChange: (mode) => {
3351
+ this.settingsManager.setTreeFilterMode(mode);
3352
+ },
3353
+ onShowHardwareCursorChange: (enabled) => {
3354
+ this.settingsManager.setShowHardwareCursor(enabled);
3355
+ this.ui.setShowHardwareCursor(enabled);
3356
+ },
3357
+ onEditorPaddingXChange: (padding) => {
3358
+ this.settingsManager.setEditorPaddingX(padding);
3359
+ this.defaultEditor.setPaddingX(padding);
3360
+ if (this.editor !== this.defaultEditor && this.editor.setPaddingX !== undefined) {
3361
+ this.editor.setPaddingX(padding);
3362
+ }
3363
+ },
3364
+ onAutocompleteMaxVisibleChange: (maxVisible) => {
3365
+ this.settingsManager.setAutocompleteMaxVisible(maxVisible);
3366
+ this.defaultEditor.setAutocompleteMaxVisible(maxVisible);
3367
+ if (this.editor !== this.defaultEditor && this.editor.setAutocompleteMaxVisible !== undefined) {
3368
+ this.editor.setAutocompleteMaxVisible(maxVisible);
3369
+ }
3370
+ },
3371
+ onClearOnShrinkChange: (enabled) => {
3372
+ this.settingsManager.setClearOnShrink(enabled);
3373
+ this.ui.setClearOnShrink(enabled);
3374
+ },
3375
+ onShowTerminalProgressChange: (enabled) => {
3376
+ this.settingsManager.setShowTerminalProgress(enabled);
3377
+ },
3378
+ onWarningsChange: (warnings) => {
3379
+ this.settingsManager.setWarnings(warnings);
3380
+ },
3381
+ onCancel: () => {
3382
+ done();
3383
+ this.ui.requestRender();
3384
+ },
3385
+ });
3386
+ return { component: selector, focus: selector.getSettingsList() };
3387
+ });
3388
+ }
3389
+ async handleModelCommand(searchTerm) {
3390
+ if (!searchTerm) {
3391
+ this.showModelSelector();
3392
+ return;
3393
+ }
3394
+ const model = await this.findExactModelMatch(searchTerm);
3395
+ if (model) {
3396
+ try {
3397
+ await this.session.setModel(model);
3398
+ this.footer.invalidate();
3399
+ this.updateEditorBorderColor();
3400
+ this.showStatus(`Model: ${model.id}`);
3401
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(model);
3402
+ this.checkDaxnutsEasterEgg(model);
3403
+ }
3404
+ catch (error) {
3405
+ this.showError(error instanceof Error ? error.message : String(error));
3406
+ }
3407
+ return;
3408
+ }
3409
+ this.showModelSelector(searchTerm);
3410
+ }
3411
+ async findExactModelMatch(searchTerm) {
3412
+ const models = await this.getModelCandidates();
3413
+ return findExactModelReferenceMatch(searchTerm, models);
3414
+ }
3415
+ async getModelCandidates() {
3416
+ if (this.session.scopedModels.length > 0) {
3417
+ return this.session.scopedModels.map((scoped) => scoped.model);
3418
+ }
3419
+ this.session.modelRegistry.refresh();
3420
+ try {
3421
+ return await this.session.modelRegistry.getAvailable();
3422
+ }
3423
+ catch {
3424
+ return [];
3425
+ }
3426
+ }
3427
+ /** Update the footer's available provider count from current model candidates */
3428
+ async updateAvailableProviderCount() {
3429
+ const models = await this.getModelCandidates();
3430
+ const uniqueProviders = new Set(models.map((m) => m.provider));
3431
+ this.footerDataProvider.setAvailableProviderCount(uniqueProviders.size);
3432
+ }
3433
+ async maybeWarnAboutAnthropicSubscriptionAuth(model = this.session.model) {
3434
+ if (this.settingsManager.getWarnings().anthropicExtraUsage === false) {
3435
+ return;
3436
+ }
3437
+ if (this.anthropicSubscriptionWarningShown) {
3438
+ return;
3439
+ }
3440
+ if (!model || model.provider !== "anthropic") {
3441
+ return;
3442
+ }
3443
+ const storedCredential = this.session.modelRegistry.authStorage.get("anthropic");
3444
+ if (storedCredential?.type === "oauth") {
3445
+ this.anthropicSubscriptionWarningShown = true;
3446
+ this.showWarning(ANTHROPIC_SUBSCRIPTION_AUTH_WARNING);
3447
+ return;
3448
+ }
3449
+ try {
3450
+ const apiKey = await this.session.modelRegistry.getApiKeyForProvider(model.provider);
3451
+ if (!isAnthropicSubscriptionAuthKey(apiKey)) {
3452
+ return;
3453
+ }
3454
+ this.anthropicSubscriptionWarningShown = true;
3455
+ this.showWarning(ANTHROPIC_SUBSCRIPTION_AUTH_WARNING);
3456
+ }
3457
+ catch {
3458
+ // Ignore auth lookup failures for warning-only checks.
3459
+ }
3460
+ }
3461
+ showModelSelector(initialSearchInput) {
3462
+ this.showSelector((done) => {
3463
+ const selector = new ModelSelectorComponent(this.ui, this.session.model, this.settingsManager, this.session.modelRegistry, this.session.scopedModels, async (model) => {
3464
+ try {
3465
+ await this.session.setModel(model);
3466
+ this.footer.invalidate();
3467
+ this.updateEditorBorderColor();
3468
+ done();
3469
+ this.showStatus(`Model: ${model.id}`);
3470
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(model);
3471
+ this.checkDaxnutsEasterEgg(model);
3472
+ }
3473
+ catch (error) {
3474
+ done();
3475
+ this.showError(error instanceof Error ? error.message : String(error));
3476
+ }
3477
+ }, () => {
3478
+ done();
3479
+ this.ui.requestRender();
3480
+ }, initialSearchInput);
3481
+ return { component: selector, focus: selector };
3482
+ });
3483
+ }
3484
+ async showModelsSelector() {
3485
+ // Get all available models
3486
+ this.session.modelRegistry.refresh();
3487
+ const allModels = this.session.modelRegistry.getAvailable();
3488
+ if (allModels.length === 0) {
3489
+ this.showStatus("No models available");
3490
+ return;
3491
+ }
3492
+ // Check if session has scoped models (from previous session-only changes or CLI --models)
3493
+ const sessionScopedModels = this.session.scopedModels;
3494
+ const hasSessionScope = sessionScopedModels.length > 0;
3495
+ // Build enabled model IDs from session state or settings
3496
+ let currentEnabledIds = null;
3497
+ if (hasSessionScope) {
3498
+ // Use current session's scoped models
3499
+ currentEnabledIds = sessionScopedModels.map((scoped) => `${scoped.model.provider}/${scoped.model.id}`);
3500
+ }
3501
+ else {
3502
+ // Fall back to settings
3503
+ const patterns = this.settingsManager.getEnabledModels();
3504
+ if (patterns !== undefined && patterns.length > 0) {
3505
+ const scopedModels = await resolveModelScope(patterns, this.session.modelRegistry);
3506
+ currentEnabledIds = scopedModels.map((scoped) => `${scoped.model.provider}/${scoped.model.id}`);
3507
+ }
3508
+ }
3509
+ // Helper to update session's scoped models (session-only, no persist)
3510
+ const updateSessionModels = async (enabledIds) => {
3511
+ currentEnabledIds = enabledIds === null ? null : [...enabledIds];
3512
+ if (enabledIds && enabledIds.length > 0 && enabledIds.length < allModels.length) {
3513
+ const newScopedModels = await resolveModelScope(enabledIds, this.session.modelRegistry);
3514
+ this.session.setScopedModels(newScopedModels.map((sm) => ({
3515
+ model: sm.model,
3516
+ thinkingLevel: sm.thinkingLevel,
3517
+ })));
3518
+ }
3519
+ else {
3520
+ // All enabled or none enabled = no filter
3521
+ this.session.setScopedModels([]);
3522
+ }
3523
+ await this.updateAvailableProviderCount();
3524
+ this.ui.requestRender();
3525
+ };
3526
+ this.showSelector((done) => {
3527
+ const selector = new ScopedModelsSelectorComponent({
3528
+ allModels,
3529
+ enabledModelIds: currentEnabledIds,
3530
+ }, {
3531
+ onChange: async (enabledIds) => {
3532
+ await updateSessionModels(enabledIds);
3533
+ },
3534
+ onPersist: (enabledIds) => {
3535
+ // Persist to settings
3536
+ const newPatterns = enabledIds === null || enabledIds.length === allModels.length
3537
+ ? undefined // All enabled = clear filter
3538
+ : enabledIds;
3539
+ this.settingsManager.setEnabledModels(newPatterns ? [...newPatterns] : undefined);
3540
+ this.showStatus("Model selection saved to settings");
3541
+ },
3542
+ onCancel: () => {
3543
+ done();
3544
+ this.ui.requestRender();
3545
+ },
3546
+ });
3547
+ return { component: selector, focus: selector };
3548
+ });
3549
+ }
3550
+ showUserMessageSelector() {
3551
+ const userMessages = this.session.getUserMessagesForForking();
3552
+ if (userMessages.length === 0) {
3553
+ this.showStatus("No messages to fork from");
3554
+ return;
3555
+ }
3556
+ const initialSelectedId = userMessages[userMessages.length - 1]?.entryId;
3557
+ this.showSelector((done) => {
3558
+ const selector = new UserMessageSelectorComponent(userMessages.map((m) => ({ id: m.entryId, text: m.text })), async (entryId) => {
3559
+ try {
3560
+ const result = await this.runtimeHost.fork(entryId);
3561
+ if (result.cancelled) {
3562
+ done();
3563
+ this.ui.requestRender();
3564
+ return;
3565
+ }
3566
+ this.renderCurrentSessionState();
3567
+ this.editor.setText(result.selectedText ?? "");
3568
+ done();
3569
+ this.showStatus("Forked to new session");
3570
+ }
3571
+ catch (error) {
3572
+ done();
3573
+ this.showError(error instanceof Error ? error.message : String(error));
3574
+ }
3575
+ }, () => {
3576
+ done();
3577
+ this.ui.requestRender();
3578
+ }, initialSelectedId);
3579
+ return { component: selector, focus: selector.getMessageList() };
3580
+ });
3581
+ }
3582
+ async handleCloneCommand() {
3583
+ const leafId = this.sessionManager.getLeafId();
3584
+ if (!leafId) {
3585
+ this.showStatus("Nothing to clone yet");
3586
+ return;
3587
+ }
3588
+ try {
3589
+ const result = await this.runtimeHost.fork(leafId, { position: "at" });
3590
+ if (result.cancelled) {
3591
+ this.ui.requestRender();
3592
+ return;
3593
+ }
3594
+ this.renderCurrentSessionState();
3595
+ this.editor.setText("");
3596
+ this.showStatus("Cloned to new session");
3597
+ }
3598
+ catch (error) {
3599
+ this.showError(error instanceof Error ? error.message : String(error));
3600
+ }
3601
+ }
3602
+ showTreeSelector(initialSelectedId) {
3603
+ const tree = this.sessionManager.getTree();
3604
+ const realLeafId = this.sessionManager.getLeafId();
3605
+ const initialFilterMode = this.settingsManager.getTreeFilterMode();
3606
+ if (tree.length === 0) {
3607
+ this.showStatus("No entries in session");
3608
+ return;
3609
+ }
3610
+ this.showSelector((done) => {
3611
+ const selector = new TreeSelectorComponent(tree, realLeafId, this.ui.terminal.rows, async (entryId) => {
3612
+ // Selecting the current leaf is a no-op (already there)
3613
+ if (entryId === realLeafId) {
3614
+ done();
3615
+ this.showStatus("Already at this point");
3616
+ return;
3617
+ }
3618
+ // Ask about summarization
3619
+ done(); // Close selector first
3620
+ // Loop until user makes a complete choice or cancels to tree
3621
+ let wantsSummary = false;
3622
+ let customInstructions;
3623
+ // Check if we should skip the prompt (user preference to always default to no summary)
3624
+ if (!this.settingsManager.getBranchSummarySkipPrompt()) {
3625
+ while (true) {
3626
+ const summaryChoice = await this.showExtensionSelector("Summarize branch?", [
3627
+ "No summary",
3628
+ "Summarize",
3629
+ "Summarize with custom prompt",
3630
+ ]);
3631
+ if (summaryChoice === undefined) {
3632
+ // User pressed escape - re-show tree selector with same selection
3633
+ this.showTreeSelector(entryId);
3634
+ return;
3635
+ }
3636
+ wantsSummary = summaryChoice !== "No summary";
3637
+ if (summaryChoice === "Summarize with custom prompt") {
3638
+ customInstructions = await this.showExtensionEditor("Custom summarization instructions");
3639
+ if (customInstructions === undefined) {
3640
+ // User cancelled - loop back to summary selector
3641
+ continue;
3642
+ }
3643
+ }
3644
+ // User made a complete choice
3645
+ break;
3646
+ }
3647
+ }
3648
+ // Set up escape handler and loader if summarizing
3649
+ let summaryLoader;
3650
+ const originalOnEscape = this.defaultEditor.onEscape;
3651
+ if (wantsSummary) {
3652
+ this.defaultEditor.onEscape = () => {
3653
+ this.session.abortBranchSummary();
3654
+ };
3655
+ this.chatContainer.addChild(new Spacer(1));
3656
+ summaryLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), `Summarizing branch... (${keyText("app.interrupt")} to cancel)`);
3657
+ this.statusContainer.addChild(summaryLoader);
3658
+ this.ui.requestRender();
3659
+ }
3660
+ try {
3661
+ const result = await this.session.navigateTree(entryId, {
3662
+ summarize: wantsSummary,
3663
+ customInstructions,
3664
+ });
3665
+ if (result.aborted) {
3666
+ // Summarization aborted - re-show tree selector with same selection
3667
+ this.showStatus("Branch summarization cancelled");
3668
+ this.showTreeSelector(entryId);
3669
+ return;
3670
+ }
3671
+ if (result.cancelled) {
3672
+ this.showStatus("Navigation cancelled");
3673
+ return;
3674
+ }
3675
+ // Update UI
3676
+ this.chatContainer.clear();
3677
+ this.renderInitialMessages();
3678
+ if (result.editorText && !this.editor.getText().trim()) {
3679
+ this.editor.setText(result.editorText);
3680
+ }
3681
+ this.showStatus("Navigated to selected point");
3682
+ void this.flushCompactionQueue({ willRetry: false });
3683
+ }
3684
+ catch (error) {
3685
+ this.showError(error instanceof Error ? error.message : String(error));
3686
+ }
3687
+ finally {
3688
+ if (summaryLoader) {
3689
+ summaryLoader.stop();
3690
+ this.statusContainer.clear();
3691
+ }
3692
+ this.defaultEditor.onEscape = originalOnEscape;
3693
+ }
3694
+ }, () => {
3695
+ done();
3696
+ this.ui.requestRender();
3697
+ }, (entryId, label) => {
3698
+ this.sessionManager.appendLabelChange(entryId, label);
3699
+ this.ui.requestRender();
3700
+ }, initialSelectedId, initialFilterMode);
3701
+ return { component: selector, focus: selector };
3702
+ });
3703
+ }
3704
+ showSessionSelector() {
3705
+ this.showSelector((done) => {
3706
+ const selector = new SessionSelectorComponent((onProgress) => SessionManager.list(this.sessionManager.getCwd(), this.sessionManager.getSessionDir(), onProgress), (onProgress) => this.sessionManager.usesDefaultSessionDir()
3707
+ ? SessionManager.listAll(onProgress)
3708
+ : SessionManager.listAll(this.sessionManager.getSessionDir(), onProgress), async (sessionPath) => {
3709
+ done();
3710
+ await this.handleResumeSession(sessionPath);
3711
+ }, () => {
3712
+ done();
3713
+ this.ui.requestRender();
3714
+ }, () => {
3715
+ void this.shutdown();
3716
+ }, () => this.ui.requestRender(), {
3717
+ renameSession: async (sessionFilePath, nextName) => {
3718
+ const next = (nextName ?? "").trim();
3719
+ if (!next)
3720
+ return;
3721
+ const mgr = SessionManager.open(sessionFilePath);
3722
+ mgr.appendSessionInfo(next);
3723
+ },
3724
+ showRenameHint: true,
3725
+ keybindings: this.keybindings,
3726
+ }, this.sessionManager.getSessionFile());
3727
+ return { component: selector, focus: selector };
3728
+ });
3729
+ }
3730
+ async handleResumeSession(sessionPath, options) {
3731
+ if (this.loadingAnimation) {
3732
+ this.loadingAnimation.stop();
3733
+ this.loadingAnimation = undefined;
3734
+ }
3735
+ this.statusContainer.clear();
3736
+ try {
3737
+ const result = await this.runtimeHost.switchSession(sessionPath, {
3738
+ withSession: options?.withSession,
3739
+ });
3740
+ if (result.cancelled) {
3741
+ return result;
3742
+ }
3743
+ this.renderCurrentSessionState();
3744
+ this.showStatus("Resumed session");
3745
+ return result;
3746
+ }
3747
+ catch (error) {
3748
+ if (error instanceof MissingSessionCwdError) {
3749
+ const selectedCwd = await this.promptForMissingSessionCwd(error);
3750
+ if (!selectedCwd) {
3751
+ this.showStatus("Resume cancelled");
3752
+ return { cancelled: true };
3753
+ }
3754
+ const result = await this.runtimeHost.switchSession(sessionPath, {
3755
+ cwdOverride: selectedCwd,
3756
+ withSession: options?.withSession,
3757
+ });
3758
+ if (result.cancelled) {
3759
+ return result;
3760
+ }
3761
+ this.renderCurrentSessionState();
3762
+ this.showStatus("Resumed session in current cwd");
3763
+ return result;
3764
+ }
3765
+ return this.handleFatalRuntimeError("Failed to resume session", error);
3766
+ }
3767
+ }
3768
+ getLoginProviderOptions(authType) {
3769
+ const authStorage = this.session.modelRegistry.authStorage;
3770
+ const oauthProviders = authStorage.getOAuthProviders();
3771
+ const oauthProviderIds = new Set(oauthProviders.map((provider) => provider.id));
3772
+ const options = oauthProviders.map((provider) => ({
3773
+ id: provider.id,
3774
+ name: provider.name,
3775
+ authType: "oauth",
3776
+ }));
3777
+ const modelProviders = new Set(this.session.modelRegistry.getAll().map((model) => model.provider));
3778
+ for (const providerId of modelProviders) {
3779
+ if (!isApiKeyLoginProvider(providerId, oauthProviderIds)) {
3780
+ continue;
3781
+ }
3782
+ options.push({
3783
+ id: providerId,
3784
+ name: this.session.modelRegistry.getProviderDisplayName(providerId),
3785
+ authType: "api_key",
3786
+ });
3787
+ }
3788
+ const filteredOptions = authType ? options.filter((option) => option.authType === authType) : options;
3789
+ return filteredOptions.sort((a, b) => a.name.localeCompare(b.name));
3790
+ }
3791
+ getLogoutProviderOptions() {
3792
+ const authStorage = this.session.modelRegistry.authStorage;
3793
+ const options = [];
3794
+ for (const providerId of authStorage.list()) {
3795
+ const credential = authStorage.get(providerId);
3796
+ if (!credential) {
3797
+ continue;
3798
+ }
3799
+ options.push({
3800
+ id: providerId,
3801
+ name: this.session.modelRegistry.getProviderDisplayName(providerId),
3802
+ authType: credential.type,
3803
+ });
3804
+ }
3805
+ return options.sort((a, b) => a.name.localeCompare(b.name));
3806
+ }
3807
+ showLoginAuthTypeSelector() {
3808
+ const subscriptionLabel = "Use a subscription";
3809
+ const apiKeyLabel = "Use an API key";
3810
+ this.showSelector((done) => {
3811
+ const selector = new ExtensionSelectorComponent("Select authentication method:", [subscriptionLabel, apiKeyLabel], (option) => {
3812
+ done();
3813
+ const authType = option === subscriptionLabel ? "oauth" : "api_key";
3814
+ this.showLoginProviderSelector(authType);
3815
+ }, () => {
3816
+ done();
3817
+ this.ui.requestRender();
3818
+ });
3819
+ return { component: selector, focus: selector };
3820
+ });
3821
+ }
3822
+ showLoginProviderSelector(authType) {
3823
+ const providerOptions = this.getLoginProviderOptions(authType);
3824
+ if (providerOptions.length === 0) {
3825
+ this.showStatus(authType === "oauth" ? "No subscription providers available." : "No API key providers available.");
3826
+ return;
3827
+ }
3828
+ this.showSelector((done) => {
3829
+ const selector = new OAuthSelectorComponent("login", this.session.modelRegistry.authStorage, providerOptions, async (providerId) => {
3830
+ done();
3831
+ const providerOption = providerOptions.find((provider) => provider.id === providerId);
3832
+ if (!providerOption) {
3833
+ return;
3834
+ }
3835
+ if (providerOption.authType === "oauth") {
3836
+ await this.showLoginDialog(providerOption.id, providerOption.name);
3837
+ }
3838
+ else if (providerOption.id === BEDROCK_PROVIDER_ID) {
3839
+ this.showBedrockSetupDialog(providerOption.id, providerOption.name);
3840
+ }
3841
+ else {
3842
+ await this.showApiKeyLoginDialog(providerOption.id, providerOption.name);
3843
+ }
3844
+ }, () => {
3845
+ done();
3846
+ this.showLoginAuthTypeSelector();
3847
+ }, (providerId) => this.session.modelRegistry.getProviderAuthStatus(providerId));
3848
+ return { component: selector, focus: selector };
3849
+ });
3850
+ }
3851
+ async showOAuthSelector(mode) {
3852
+ if (mode === "login") {
3853
+ this.showLoginAuthTypeSelector();
3854
+ return;
3855
+ }
3856
+ const providerOptions = this.getLogoutProviderOptions();
3857
+ if (providerOptions.length === 0) {
3858
+ this.showStatus("No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.");
3859
+ return;
3860
+ }
3861
+ this.showSelector((done) => {
3862
+ const selector = new OAuthSelectorComponent(mode, this.session.modelRegistry.authStorage, providerOptions, async (providerId) => {
3863
+ done();
3864
+ const providerOption = providerOptions.find((provider) => provider.id === providerId);
3865
+ if (!providerOption) {
3866
+ return;
3867
+ }
3868
+ try {
3869
+ this.session.modelRegistry.authStorage.logout(providerOption.id);
3870
+ this.session.modelRegistry.refresh();
3871
+ await this.updateAvailableProviderCount();
3872
+ const message = providerOption.authType === "oauth"
3873
+ ? `Logged out of ${providerOption.name}`
3874
+ : `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;
3875
+ this.showStatus(message);
3876
+ }
3877
+ catch (error) {
3878
+ this.showError(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);
3879
+ }
3880
+ }, () => {
3881
+ done();
3882
+ this.ui.requestRender();
3883
+ });
3884
+ return { component: selector, focus: selector };
3885
+ });
3886
+ }
3887
+ async completeProviderAuthentication(providerId, providerName, authType, previousModel) {
3888
+ this.session.modelRegistry.refresh();
3889
+ const actionLabel = authType === "oauth" ? `Logged in to ${providerName}` : `Saved API key for ${providerName}`;
3890
+ let selectedModel;
3891
+ let selectionError;
3892
+ if (isUnknownModel(previousModel)) {
3893
+ const availableModels = this.session.modelRegistry.getAvailable();
3894
+ const providerModels = availableModels.filter((model) => model.provider === providerId);
3895
+ if (!hasDefaultModelProvider(providerId)) {
3896
+ selectionError = `${actionLabel}, but no default model is configured for provider "${providerId}". Use /model to select a model.`;
3897
+ }
3898
+ else if (providerModels.length === 0) {
3899
+ selectionError = `${actionLabel}, but no models are available for that provider. Use /model to select a model.`;
3900
+ }
3901
+ else {
3902
+ const defaultModelId = defaultModelPerProvider[providerId];
3903
+ selectedModel = providerModels.find((model) => model.id === defaultModelId);
3904
+ if (!selectedModel) {
3905
+ selectionError = `${actionLabel}, but its default model "${defaultModelId}" is not available. Use /model to select a model.`;
3906
+ }
3907
+ else {
3908
+ try {
3909
+ await this.session.setModel(selectedModel);
3910
+ }
3911
+ catch (error) {
3912
+ selectedModel = undefined;
3913
+ const errorMessage = error instanceof Error ? error.message : String(error);
3914
+ selectionError = `${actionLabel}, but selecting its default model failed: ${errorMessage}. Use /model to select a model.`;
3915
+ }
3916
+ }
3917
+ }
3918
+ }
3919
+ await this.updateAvailableProviderCount();
3920
+ this.footer.invalidate();
3921
+ this.updateEditorBorderColor();
3922
+ if (selectedModel) {
3923
+ this.showStatus(`${actionLabel}. Selected ${selectedModel.id}. Credentials saved to ${getAuthPath()}`);
3924
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);
3925
+ this.checkDaxnutsEasterEgg(selectedModel);
3926
+ }
3927
+ else {
3928
+ this.showStatus(`${actionLabel}. Credentials saved to ${getAuthPath()}`);
3929
+ if (selectionError) {
3930
+ this.showError(selectionError);
3931
+ }
3932
+ else {
3933
+ void this.maybeWarnAboutAnthropicSubscriptionAuth();
3934
+ }
3935
+ }
3936
+ }
3937
+ showBedrockSetupDialog(providerId, providerName) {
3938
+ const restoreEditor = () => {
3939
+ this.editorContainer.clear();
3940
+ this.editorContainer.addChild(this.editor);
3941
+ this.ui.setFocus(this.editor);
3942
+ this.ui.requestRender();
3943
+ };
3944
+ const dialog = new LoginDialogComponent(this.ui, providerId, () => restoreEditor(), providerName, "Amazon Bedrock setup");
3945
+ dialog.showInfo([
3946
+ theme.fg("text", "Amazon Bedrock uses AWS credentials instead of a single API key."),
3947
+ theme.fg("text", "Configure an AWS profile, IAM keys, bearer token, or role-based credentials."),
3948
+ theme.fg("muted", "See:"),
3949
+ theme.fg("accent", ` ${path.join(getDocsPath(), "providers.md")}`),
3950
+ ]);
3951
+ this.editorContainer.clear();
3952
+ this.editorContainer.addChild(dialog);
3953
+ this.ui.setFocus(dialog);
3954
+ this.ui.requestRender();
3955
+ }
3956
+ async showApiKeyLoginDialog(providerId, providerName) {
3957
+ const previousModel = this.session.model;
3958
+ const dialog = new LoginDialogComponent(this.ui, providerId, (_success, _message) => {
3959
+ // Completion handled below
3960
+ }, providerName);
3961
+ this.editorContainer.clear();
3962
+ this.editorContainer.addChild(dialog);
3963
+ this.ui.setFocus(dialog);
3964
+ this.ui.requestRender();
3965
+ const restoreEditor = () => {
3966
+ this.editorContainer.clear();
3967
+ this.editorContainer.addChild(this.editor);
3968
+ this.ui.setFocus(this.editor);
3969
+ this.ui.requestRender();
3970
+ };
3971
+ try {
3972
+ const apiKey = (await dialog.showPrompt("Enter API key:")).trim();
3973
+ if (!apiKey) {
3974
+ throw new Error("API key cannot be empty.");
3975
+ }
3976
+ this.session.modelRegistry.authStorage.set(providerId, { type: "api_key", key: apiKey });
3977
+ restoreEditor();
3978
+ await this.completeProviderAuthentication(providerId, providerName, "api_key", previousModel);
3979
+ }
3980
+ catch (error) {
3981
+ restoreEditor();
3982
+ const errorMsg = error instanceof Error ? error.message : String(error);
3983
+ if (errorMsg !== "Login cancelled") {
3984
+ this.showError(`Failed to save API key for ${providerName}: ${errorMsg}`);
3985
+ }
3986
+ }
3987
+ }
3988
+ showOAuthLoginSelect(dialog, prompt) {
3989
+ return new Promise((resolve) => {
3990
+ const restoreDialog = () => {
3991
+ this.editorContainer.clear();
3992
+ this.editorContainer.addChild(dialog);
3993
+ this.ui.setFocus(dialog);
3994
+ this.ui.requestRender();
3995
+ };
3996
+ const labels = prompt.options.map((option) => option.label);
3997
+ const selector = new ExtensionSelectorComponent(prompt.message, labels, (optionLabel) => {
3998
+ restoreDialog();
3999
+ resolve(prompt.options.find((option) => option.label === optionLabel)?.id);
4000
+ }, () => {
4001
+ restoreDialog();
4002
+ resolve(undefined);
4003
+ });
4004
+ this.editorContainer.clear();
4005
+ this.editorContainer.addChild(selector);
4006
+ this.ui.setFocus(selector);
4007
+ this.ui.requestRender();
4008
+ });
4009
+ }
4010
+ async showLoginDialog(providerId, providerName) {
4011
+ const providerInfo = this.session.modelRegistry.authStorage
4012
+ .getOAuthProviders()
4013
+ .find((provider) => provider.id === providerId);
4014
+ const previousModel = this.session.model;
4015
+ // Providers that use callback servers (can paste redirect URL)
4016
+ const usesCallbackServer = providerInfo?.usesCallbackServer ?? false;
4017
+ // Create login dialog component
4018
+ const dialog = new LoginDialogComponent(this.ui, providerId, (_success, _message) => {
4019
+ // Completion handled below
4020
+ }, providerName);
4021
+ // Show dialog in editor container
4022
+ this.editorContainer.clear();
4023
+ this.editorContainer.addChild(dialog);
4024
+ this.ui.setFocus(dialog);
4025
+ this.ui.requestRender();
4026
+ // Promise for manual code input (racing with callback server)
4027
+ let manualCodeResolve;
4028
+ let manualCodeReject;
4029
+ const manualCodePromise = new Promise((resolve, reject) => {
4030
+ manualCodeResolve = resolve;
4031
+ manualCodeReject = reject;
4032
+ });
4033
+ // Restore editor helper
4034
+ const restoreEditor = () => {
4035
+ this.editorContainer.clear();
4036
+ this.editorContainer.addChild(this.editor);
4037
+ this.ui.setFocus(this.editor);
4038
+ this.ui.requestRender();
4039
+ };
4040
+ try {
4041
+ await this.session.modelRegistry.authStorage.login(providerId, {
4042
+ onAuth: (info) => {
4043
+ dialog.showAuth(info.url, info.instructions);
4044
+ if (usesCallbackServer) {
4045
+ // Show input for manual paste, racing with callback
4046
+ dialog
4047
+ .showManualInput("Paste redirect URL below, or complete login in browser:")
4048
+ .then((value) => {
4049
+ if (value && manualCodeResolve) {
4050
+ manualCodeResolve(value);
4051
+ manualCodeResolve = undefined;
4052
+ }
4053
+ })
4054
+ .catch(() => {
4055
+ if (manualCodeReject) {
4056
+ manualCodeReject(new Error("Login cancelled"));
4057
+ manualCodeReject = undefined;
4058
+ }
4059
+ });
4060
+ }
4061
+ // For Anthropic: onPrompt is called immediately after
4062
+ },
4063
+ onDeviceCode: (info) => {
4064
+ dialog.showDeviceCode(info);
4065
+ dialog.showWaiting("Waiting for authentication...");
4066
+ },
4067
+ onPrompt: async (prompt) => {
4068
+ return dialog.showPrompt(prompt.message, prompt.placeholder);
4069
+ },
4070
+ onProgress: (message) => {
4071
+ dialog.showProgress(message);
4072
+ },
4073
+ onSelect: (prompt) => this.showOAuthLoginSelect(dialog, prompt),
4074
+ onManualCodeInput: () => manualCodePromise,
4075
+ signal: dialog.signal,
4076
+ });
4077
+ // Success
4078
+ restoreEditor();
4079
+ await this.completeProviderAuthentication(providerId, providerName, "oauth", previousModel);
4080
+ }
4081
+ catch (error) {
4082
+ restoreEditor();
4083
+ const errorMsg = error instanceof Error ? error.message : String(error);
4084
+ if (errorMsg !== "Login cancelled") {
4085
+ this.showError(`Failed to login to ${providerName}: ${errorMsg}`);
4086
+ }
4087
+ }
4088
+ }
4089
+ // =========================================================================
4090
+ // Command handlers
4091
+ // =========================================================================
4092
+ async handleReloadCommand() {
4093
+ if (this.session.isStreaming) {
4094
+ this.showWarning("Wait for the current response to finish before reloading.");
4095
+ return;
4096
+ }
4097
+ if (this.session.isCompacting) {
4098
+ this.showWarning("Wait for compaction to finish before reloading.");
4099
+ return;
4100
+ }
4101
+ this.resetExtensionUI();
4102
+ const reloadBox = new Container();
4103
+ const borderColor = (s) => theme.fg("border", s);
4104
+ reloadBox.addChild(new DynamicBorder(borderColor));
4105
+ reloadBox.addChild(new Spacer(1));
4106
+ reloadBox.addChild(new Text(theme.fg("muted", "Reloading keybindings, extensions, skills, prompts, themes..."), 1, 0));
4107
+ reloadBox.addChild(new Spacer(1));
4108
+ reloadBox.addChild(new DynamicBorder(borderColor));
4109
+ const previousEditor = this.editor;
4110
+ this.editorContainer.clear();
4111
+ this.editorContainer.addChild(reloadBox);
4112
+ this.ui.setFocus(reloadBox);
4113
+ this.ui.requestRender(true);
4114
+ await new Promise((resolve) => process.nextTick(resolve));
4115
+ const dismissReloadBox = (editor) => {
4116
+ this.editorContainer.clear();
4117
+ this.editorContainer.addChild(editor);
4118
+ this.ui.setFocus(editor);
4119
+ this.ui.requestRender();
4120
+ };
4121
+ try {
4122
+ await this.session.reload();
4123
+ configureHttpDispatcher(this.settingsManager.getHttpIdleTimeoutMs());
4124
+ this.keybindings.reload();
4125
+ const activeHeader = this.customHeader ?? this.builtInHeader;
4126
+ if (isExpandable(activeHeader)) {
4127
+ activeHeader.setExpanded(this.toolOutputExpanded);
4128
+ }
4129
+ setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
4130
+ this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
4131
+ const themeName = this.settingsManager.getTheme();
4132
+ const themeResult = themeName ? setTheme(themeName, true) : { success: true };
4133
+ if (!themeResult.success) {
4134
+ this.showError(`Failed to load theme "${themeName}": ${themeResult.error}\nFell back to dark theme.`);
4135
+ }
4136
+ const editorPaddingX = this.settingsManager.getEditorPaddingX();
4137
+ const autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();
4138
+ this.defaultEditor.setPaddingX(editorPaddingX);
4139
+ this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);
4140
+ if (this.editor !== this.defaultEditor) {
4141
+ this.editor.setPaddingX?.(editorPaddingX);
4142
+ this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);
4143
+ }
4144
+ this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());
4145
+ this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
4146
+ this.setupAutocompleteProvider();
4147
+ const runner = this.session.extensionRunner;
4148
+ this.setupExtensionShortcuts(runner);
4149
+ this.rebuildChatFromMessages();
4150
+ dismissReloadBox(this.editor);
4151
+ this.showLoadedResources({
4152
+ force: false,
4153
+ showDiagnosticsWhenQuiet: true,
4154
+ });
4155
+ const modelsJsonError = this.session.modelRegistry.getError();
4156
+ if (modelsJsonError) {
4157
+ this.showError(`models.json error: ${modelsJsonError}`);
4158
+ }
4159
+ this.showStatus("Reloaded keybindings, extensions, skills, prompts, themes");
4160
+ }
4161
+ catch (error) {
4162
+ dismissReloadBox(previousEditor);
4163
+ this.showError(`Reload failed: ${error instanceof Error ? error.message : String(error)}`);
4164
+ }
4165
+ }
4166
+ async handleExportCommand(text) {
4167
+ const outputPath = this.getPathCommandArgument(text, "/export");
4168
+ try {
4169
+ if (outputPath?.endsWith(".jsonl")) {
4170
+ const filePath = this.session.exportToJsonl(outputPath);
4171
+ this.showStatus(`Session exported to: ${filePath}`);
4172
+ }
4173
+ else {
4174
+ const filePath = await this.session.exportToHtml(outputPath);
4175
+ this.showStatus(`Session exported to: ${filePath}`);
4176
+ }
4177
+ }
4178
+ catch (error) {
4179
+ this.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
4180
+ }
4181
+ }
4182
+ getPathCommandArgument(text, command) {
4183
+ if (text === command) {
4184
+ return undefined;
4185
+ }
4186
+ if (!text.startsWith(`${command} `)) {
4187
+ return undefined;
4188
+ }
4189
+ const argsString = text.slice(command.length + 1).trimStart();
4190
+ if (!argsString) {
4191
+ return undefined;
4192
+ }
4193
+ const firstChar = argsString[0];
4194
+ if (firstChar === '"' || firstChar === "'") {
4195
+ const closingQuoteIndex = argsString.indexOf(firstChar, 1);
4196
+ if (closingQuoteIndex < 0) {
4197
+ return undefined;
4198
+ }
4199
+ return argsString.slice(1, closingQuoteIndex);
4200
+ }
4201
+ const firstWhitespaceIndex = argsString.search(/\s/);
4202
+ if (firstWhitespaceIndex < 0) {
4203
+ return argsString;
4204
+ }
4205
+ return argsString.slice(0, firstWhitespaceIndex);
4206
+ }
4207
+ async handleImportCommand(text) {
4208
+ const inputPath = this.getPathCommandArgument(text, "/import");
4209
+ if (!inputPath) {
4210
+ this.showError("Usage: /import <path.jsonl>");
4211
+ return;
4212
+ }
4213
+ const confirmed = await this.showExtensionConfirm("Import session", `Replace current session with ${inputPath}?`);
4214
+ if (!confirmed) {
4215
+ this.showStatus("Import cancelled");
4216
+ return;
4217
+ }
4218
+ try {
4219
+ if (this.loadingAnimation) {
4220
+ this.loadingAnimation.stop();
4221
+ this.loadingAnimation = undefined;
4222
+ }
4223
+ this.statusContainer.clear();
4224
+ const result = await this.runtimeHost.importFromJsonl(inputPath);
4225
+ if (result.cancelled) {
4226
+ this.showStatus("Import cancelled");
4227
+ return;
4228
+ }
4229
+ this.renderCurrentSessionState();
4230
+ this.showStatus(`Session imported from: ${inputPath}`);
4231
+ }
4232
+ catch (error) {
4233
+ if (error instanceof MissingSessionCwdError) {
4234
+ const selectedCwd = await this.promptForMissingSessionCwd(error);
4235
+ if (!selectedCwd) {
4236
+ this.showStatus("Import cancelled");
4237
+ return;
4238
+ }
4239
+ const result = await this.runtimeHost.importFromJsonl(inputPath, selectedCwd);
4240
+ if (result.cancelled) {
4241
+ this.showStatus("Import cancelled");
4242
+ return;
4243
+ }
4244
+ this.renderCurrentSessionState();
4245
+ this.showStatus(`Session imported from: ${inputPath}`);
4246
+ return;
4247
+ }
4248
+ if (error instanceof SessionImportFileNotFoundError) {
4249
+ this.showError(`Failed to import session: ${error.message}`);
4250
+ return;
4251
+ }
4252
+ await this.handleFatalRuntimeError("Failed to import session", error);
4253
+ }
4254
+ }
4255
+ async handleShareCommand() {
4256
+ // Check if gh is available and logged in
4257
+ try {
4258
+ const authResult = spawnSync("gh", ["auth", "status"], { encoding: "utf-8" });
4259
+ if (authResult.status !== 0) {
4260
+ this.showError("GitHub CLI is not logged in. Run 'gh auth login' first.");
4261
+ return;
4262
+ }
4263
+ }
4264
+ catch {
4265
+ this.showError("GitHub CLI (gh) is not installed. Install it from https://cli.github.com/");
4266
+ return;
4267
+ }
4268
+ // Export to a temp file
4269
+ const tmpFile = path.join(os.tmpdir(), "session.html");
4270
+ try {
4271
+ await this.session.exportToHtml(tmpFile);
4272
+ }
4273
+ catch (error) {
4274
+ this.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
4275
+ return;
4276
+ }
4277
+ // Show cancellable loader, replacing the editor
4278
+ const loader = new BorderedLoader(this.ui, theme, "Creating gist...");
4279
+ this.editorContainer.clear();
4280
+ this.editorContainer.addChild(loader);
4281
+ this.ui.setFocus(loader);
4282
+ this.ui.requestRender();
4283
+ const restoreEditor = () => {
4284
+ loader.dispose();
4285
+ this.editorContainer.clear();
4286
+ this.editorContainer.addChild(this.editor);
4287
+ this.ui.setFocus(this.editor);
4288
+ try {
4289
+ fs.unlinkSync(tmpFile);
4290
+ }
4291
+ catch {
4292
+ // Ignore cleanup errors
4293
+ }
4294
+ };
4295
+ // Create a secret gist asynchronously
4296
+ let proc = null;
4297
+ loader.onAbort = () => {
4298
+ proc?.kill();
4299
+ restoreEditor();
4300
+ this.showStatus("Share cancelled");
4301
+ };
4302
+ try {
4303
+ const result = await new Promise((resolve) => {
4304
+ proc = spawn("gh", ["gist", "create", "--public=false", tmpFile]);
4305
+ let stdout = "";
4306
+ let stderr = "";
4307
+ proc.stdout?.on("data", (data) => {
4308
+ stdout += data.toString();
4309
+ });
4310
+ proc.stderr?.on("data", (data) => {
4311
+ stderr += data.toString();
4312
+ });
4313
+ proc.on("close", (code) => resolve({ stdout, stderr, code }));
4314
+ });
4315
+ if (loader.signal.aborted)
4316
+ return;
4317
+ restoreEditor();
4318
+ if (result.code !== 0) {
4319
+ const errorMsg = result.stderr?.trim() || "Unknown error";
4320
+ this.showError(`Failed to create gist: ${errorMsg}`);
4321
+ return;
4322
+ }
4323
+ // Extract gist ID from the URL returned by gh
4324
+ // gh returns something like: https://gist.github.com/username/GIST_ID
4325
+ const gistUrl = result.stdout?.trim();
4326
+ const gistId = gistUrl?.split("/").pop();
4327
+ if (!gistId) {
4328
+ this.showError("Failed to parse gist ID from gh output");
4329
+ return;
4330
+ }
4331
+ // Create the preview URL
4332
+ const previewUrl = getShareViewerUrl(gistId);
4333
+ this.showStatus(`Share URL: ${previewUrl}\nGist: ${gistUrl}`);
4334
+ }
4335
+ catch (error) {
4336
+ if (!loader.signal.aborted) {
4337
+ restoreEditor();
4338
+ this.showError(`Failed to create gist: ${error instanceof Error ? error.message : "Unknown error"}`);
4339
+ }
4340
+ }
4341
+ }
4342
+ async handleCopyCommand() {
4343
+ const text = this.session.getLastAssistantText();
4344
+ if (!text) {
4345
+ this.showError("No agent messages to copy yet.");
4346
+ return;
4347
+ }
4348
+ try {
4349
+ await copyToClipboard(text);
4350
+ this.showStatus("Copied last agent message to clipboard");
4351
+ }
4352
+ catch (error) {
4353
+ this.showError(error instanceof Error ? error.message : String(error));
4354
+ }
4355
+ }
4356
+ handleNameCommand(text) {
4357
+ const name = text.replace(/^\/name\s*/, "").trim();
4358
+ if (!name) {
4359
+ const currentName = this.sessionManager.getSessionName();
4360
+ if (currentName) {
4361
+ this.chatContainer.addChild(new Spacer(1));
4362
+ this.chatContainer.addChild(new Text(theme.fg("dim", `Session name: ${currentName}`), 1, 0));
4363
+ }
4364
+ else {
4365
+ this.showWarning("Usage: /name <name>");
4366
+ }
4367
+ this.ui.requestRender();
4368
+ return;
4369
+ }
4370
+ this.session.setSessionName(name);
4371
+ this.chatContainer.addChild(new Spacer(1));
4372
+ this.chatContainer.addChild(new Text(theme.fg("dim", `Session name set: ${name}`), 1, 0));
4373
+ this.ui.requestRender();
4374
+ }
4375
+ handleSessionCommand() {
4376
+ const stats = this.session.getSessionStats();
4377
+ const sessionName = this.sessionManager.getSessionName();
4378
+ let info = `${theme.bold("Session Info")}\n\n`;
4379
+ if (sessionName) {
4380
+ info += `${theme.fg("dim", "Name:")} ${sessionName}\n`;
4381
+ }
4382
+ info += `${theme.fg("dim", "File:")} ${stats.sessionFile ?? "In-memory"}\n`;
4383
+ info += `${theme.fg("dim", "ID:")} ${stats.sessionId}\n\n`;
4384
+ info += `${theme.bold("Messages")}\n`;
4385
+ info += `${theme.fg("dim", "User:")} ${stats.userMessages}\n`;
4386
+ info += `${theme.fg("dim", "Assistant:")} ${stats.assistantMessages}\n`;
4387
+ info += `${theme.fg("dim", "Tool Calls:")} ${stats.toolCalls}\n`;
4388
+ info += `${theme.fg("dim", "Tool Results:")} ${stats.toolResults}\n`;
4389
+ info += `${theme.fg("dim", "Total:")} ${stats.totalMessages}\n\n`;
4390
+ info += `${theme.bold("Tokens")}\n`;
4391
+ info += `${theme.fg("dim", "Input:")} ${stats.tokens.input.toLocaleString()}\n`;
4392
+ info += `${theme.fg("dim", "Output:")} ${stats.tokens.output.toLocaleString()}\n`;
4393
+ if (stats.tokens.cacheRead > 0) {
4394
+ info += `${theme.fg("dim", "Cache Read:")} ${stats.tokens.cacheRead.toLocaleString()}\n`;
4395
+ }
4396
+ if (stats.tokens.cacheWrite > 0) {
4397
+ info += `${theme.fg("dim", "Cache Write:")} ${stats.tokens.cacheWrite.toLocaleString()}\n`;
4398
+ }
4399
+ info += `${theme.fg("dim", "Total:")} ${stats.tokens.total.toLocaleString()}\n`;
4400
+ if (stats.cost > 0) {
4401
+ info += `\n${theme.bold("Cost")}\n`;
4402
+ info += `${theme.fg("dim", "Total:")} ${stats.cost.toFixed(4)}`;
4403
+ }
4404
+ this.chatContainer.addChild(new Spacer(1));
4405
+ this.chatContainer.addChild(new Text(info, 1, 0));
4406
+ this.ui.requestRender();
4407
+ }
4408
+ handleChangelogCommand() {
4409
+ const changelogPath = getChangelogPath();
4410
+ const allEntries = parseChangelog(changelogPath);
4411
+ const changelogMarkdown = allEntries.length > 0
4412
+ ? allEntries
4413
+ .reverse()
4414
+ .map((e) => e.content)
4415
+ .join("\n\n")
4416
+ : "No changelog entries found.";
4417
+ this.chatContainer.addChild(new Spacer(1));
4418
+ this.chatContainer.addChild(new DynamicBorder());
4419
+ this.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
4420
+ this.chatContainer.addChild(new Spacer(1));
4421
+ this.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, this.getMarkdownThemeWithSettings()));
4422
+ this.chatContainer.addChild(new DynamicBorder());
4423
+ this.ui.requestRender();
4424
+ }
4425
+ /**
4426
+ * Get capitalized display string for an app keybinding action.
4427
+ */
4428
+ getAppKeyDisplay(action) {
4429
+ return keyDisplayText(action);
4430
+ }
4431
+ /**
4432
+ * Get capitalized display string for an editor keybinding action.
4433
+ */
4434
+ getEditorKeyDisplay(action) {
4435
+ return keyDisplayText(action);
4436
+ }
4437
+ handleHotkeysCommand() {
4438
+ // Navigation keybindings
4439
+ const cursorUp = this.getEditorKeyDisplay("tui.editor.cursorUp");
4440
+ const cursorDown = this.getEditorKeyDisplay("tui.editor.cursorDown");
4441
+ const cursorLeft = this.getEditorKeyDisplay("tui.editor.cursorLeft");
4442
+ const cursorRight = this.getEditorKeyDisplay("tui.editor.cursorRight");
4443
+ const cursorWordLeft = this.getEditorKeyDisplay("tui.editor.cursorWordLeft");
4444
+ const cursorWordRight = this.getEditorKeyDisplay("tui.editor.cursorWordRight");
4445
+ const cursorLineStart = this.getEditorKeyDisplay("tui.editor.cursorLineStart");
4446
+ const cursorLineEnd = this.getEditorKeyDisplay("tui.editor.cursorLineEnd");
4447
+ const jumpForward = this.getEditorKeyDisplay("tui.editor.jumpForward");
4448
+ const jumpBackward = this.getEditorKeyDisplay("tui.editor.jumpBackward");
4449
+ const pageUp = this.getEditorKeyDisplay("tui.editor.pageUp");
4450
+ const pageDown = this.getEditorKeyDisplay("tui.editor.pageDown");
4451
+ // Editing keybindings
4452
+ const submit = this.getEditorKeyDisplay("tui.input.submit");
4453
+ const newLine = this.getEditorKeyDisplay("tui.input.newLine");
4454
+ const deleteWordBackward = this.getEditorKeyDisplay("tui.editor.deleteWordBackward");
4455
+ const deleteWordForward = this.getEditorKeyDisplay("tui.editor.deleteWordForward");
4456
+ const deleteToLineStart = this.getEditorKeyDisplay("tui.editor.deleteToLineStart");
4457
+ const deleteToLineEnd = this.getEditorKeyDisplay("tui.editor.deleteToLineEnd");
4458
+ const yank = this.getEditorKeyDisplay("tui.editor.yank");
4459
+ const yankPop = this.getEditorKeyDisplay("tui.editor.yankPop");
4460
+ const undo = this.getEditorKeyDisplay("tui.editor.undo");
4461
+ const tab = this.getEditorKeyDisplay("tui.input.tab");
4462
+ // App keybindings
4463
+ const interrupt = this.getAppKeyDisplay("app.interrupt");
4464
+ const clear = this.getAppKeyDisplay("app.clear");
4465
+ const exit = this.getAppKeyDisplay("app.exit");
4466
+ const suspend = this.getAppKeyDisplay("app.suspend");
4467
+ const cycleThinkingLevel = this.getAppKeyDisplay("app.thinking.cycle");
4468
+ const cycleModelForward = this.getAppKeyDisplay("app.model.cycleForward");
4469
+ const selectModel = this.getAppKeyDisplay("app.model.select");
4470
+ const expandTools = this.getAppKeyDisplay("app.tools.expand");
4471
+ const toggleThinking = this.getAppKeyDisplay("app.thinking.toggle");
4472
+ const externalEditor = this.getAppKeyDisplay("app.editor.external");
4473
+ const cycleModelBackward = this.getAppKeyDisplay("app.model.cycleBackward");
4474
+ const followUp = this.getAppKeyDisplay("app.message.followUp");
4475
+ const dequeue = this.getAppKeyDisplay("app.message.dequeue");
4476
+ const pasteImage = this.getAppKeyDisplay("app.clipboard.pasteImage");
4477
+ let hotkeys = `
4478
+ **Navigation**
4479
+ | Key | Action |
4480
+ |-----|--------|
4481
+ | \`${cursorUp}\` / \`${cursorDown}\` / \`${cursorLeft}\` / \`${cursorRight}\` | Move cursor / browse history (Up when empty) |
4482
+ | \`${cursorWordLeft}\` / \`${cursorWordRight}\` | Move by word |
4483
+ | \`${cursorLineStart}\` | Start of line |
4484
+ | \`${cursorLineEnd}\` | End of line |
4485
+ | \`${jumpForward}\` | Jump forward to character |
4486
+ | \`${jumpBackward}\` | Jump backward to character |
4487
+ | \`${pageUp}\` / \`${pageDown}\` | Scroll by page |
4488
+
4489
+ **Editing**
4490
+ | Key | Action |
4491
+ |-----|--------|
4492
+ | \`${submit}\` | Send message |
4493
+ | \`${newLine}\` | New line${process.platform === "win32" ? " (Ctrl+Enter on Windows Terminal)" : ""} |
4494
+ | \`${deleteWordBackward}\` | Delete word backwards |
4495
+ | \`${deleteWordForward}\` | Delete word forwards |
4496
+ | \`${deleteToLineStart}\` | Delete to start of line |
4497
+ | \`${deleteToLineEnd}\` | Delete to end of line |
4498
+ | \`${yank}\` | Paste the most-recently-deleted text |
4499
+ | \`${yankPop}\` | Cycle through the deleted text after pasting |
4500
+ | \`${undo}\` | Undo |
4501
+
4502
+ **Other**
4503
+ | Key | Action |
4504
+ |-----|--------|
4505
+ | \`${tab}\` | Path completion / accept autocomplete |
4506
+ | \`${interrupt}\` | Cancel autocomplete / abort streaming |
4507
+ | \`${clear}\` | Clear editor (first) / exit (second) |
4508
+ | \`${exit}\` | Exit (when editor is empty) |
4509
+ | \`${suspend}\` | Suspend to background |
4510
+ | \`${cycleThinkingLevel}\` | Cycle thinking level |
4511
+ | \`${cycleModelForward}\` / \`${cycleModelBackward}\` | Cycle models |
4512
+ | \`${selectModel}\` | Open model selector |
4513
+ | \`${expandTools}\` | Toggle tool output expansion |
4514
+ | \`${toggleThinking}\` | Toggle thinking block visibility |
4515
+ | \`${externalEditor}\` | Edit message in external editor |
4516
+ | \`${followUp}\` | Queue follow-up message |
4517
+ | \`${dequeue}\` | Restore queued messages |
4518
+ | \`${pasteImage}\` | Paste image from clipboard |
4519
+ | \`/\` | Slash commands |
4520
+ | \`!\` | Run bash command |
4521
+ | \`!!\` | Run bash command (excluded from context) |
4522
+ `;
4523
+ // Add extension-registered shortcuts
4524
+ const extensionRunner = this.session.extensionRunner;
4525
+ const shortcuts = extensionRunner.getShortcuts(this.keybindings.getEffectiveConfig());
4526
+ if (shortcuts.size > 0) {
4527
+ hotkeys += `
4528
+ **Extensions**
4529
+ | Key | Action |
4530
+ |-----|--------|
4531
+ `;
4532
+ for (const [key, shortcut] of shortcuts) {
4533
+ const description = shortcut.description ?? shortcut.extensionPath;
4534
+ const keyDisplay = formatKeyText(key, { capitalize: true });
4535
+ hotkeys += `| \`${keyDisplay}\` | ${description} |\n`;
4536
+ }
4537
+ }
4538
+ this.chatContainer.addChild(new Spacer(1));
4539
+ this.chatContainer.addChild(new DynamicBorder());
4540
+ this.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "Keyboard Shortcuts")), 1, 0));
4541
+ this.chatContainer.addChild(new Spacer(1));
4542
+ this.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, this.getMarkdownThemeWithSettings()));
4543
+ this.chatContainer.addChild(new DynamicBorder());
4544
+ this.ui.requestRender();
4545
+ }
4546
+ async handleClearCommand() {
4547
+ if (this.loadingAnimation) {
4548
+ this.loadingAnimation.stop();
4549
+ this.loadingAnimation = undefined;
4550
+ }
4551
+ this.statusContainer.clear();
4552
+ try {
4553
+ const result = await this.runtimeHost.newSession();
4554
+ if (result.cancelled) {
4555
+ return;
4556
+ }
4557
+ this.renderCurrentSessionState();
4558
+ this.chatContainer.addChild(new Spacer(1));
4559
+ this.chatContainer.addChild(new Text(`${theme.fg("accent", "✓ New session started")}`, 1, 1));
4560
+ this.ui.requestRender();
4561
+ }
4562
+ catch (error) {
4563
+ await this.handleFatalRuntimeError("Failed to create session", error);
4564
+ }
4565
+ }
4566
+ handleDebugCommand() {
4567
+ const width = this.ui.terminal.columns;
4568
+ const height = this.ui.terminal.rows;
4569
+ const allLines = this.ui.render(width);
4570
+ const debugLogPath = getDebugLogPath();
4571
+ const debugData = [
4572
+ `Debug output at ${new Date().toISOString()}`,
4573
+ `Terminal: ${width}x${height}`,
4574
+ `Total lines: ${allLines.length}`,
4575
+ "",
4576
+ "=== All rendered lines with visible widths ===",
4577
+ ...allLines.map((line, idx) => {
4578
+ const vw = visibleWidth(line);
4579
+ const escaped = JSON.stringify(line);
4580
+ return `[${idx}] (w=${vw}) ${escaped}`;
4581
+ }),
4582
+ "",
4583
+ "=== Agent messages (JSONL) ===",
4584
+ ...this.session.messages.map((msg) => JSON.stringify(msg)),
4585
+ "",
4586
+ ].join("\n");
4587
+ fs.mkdirSync(path.dirname(debugLogPath), { recursive: true });
4588
+ fs.writeFileSync(debugLogPath, debugData);
4589
+ this.chatContainer.addChild(new Spacer(1));
4590
+ this.chatContainer.addChild(new Text(`${theme.fg("accent", "✓ Debug log written")}\n${theme.fg("muted", debugLogPath)}`, 1, 1));
4591
+ this.ui.requestRender();
4592
+ }
4593
+ handleArminSaysHi() {
4594
+ this.chatContainer.addChild(new Spacer(1));
4595
+ this.chatContainer.addChild(new ArminComponent(this.ui));
4596
+ this.ui.requestRender();
4597
+ }
4598
+ handleDementedDelves() {
4599
+ this.chatContainer.addChild(new Spacer(1));
4600
+ this.chatContainer.addChild(new EarendilAnnouncementComponent());
4601
+ this.ui.requestRender();
4602
+ }
4603
+ handleDaxnuts() {
4604
+ this.chatContainer.addChild(new Spacer(1));
4605
+ this.chatContainer.addChild(new DaxnutsComponent(this.ui));
4606
+ this.ui.requestRender();
4607
+ }
4608
+ checkDaxnutsEasterEgg(model) {
4609
+ if (model.provider === "opencode" && model.id.toLowerCase().includes("kimi-k2.5")) {
4610
+ this.handleDaxnuts();
4611
+ }
4612
+ }
4613
+ async handleBashCommand(command, excludeFromContext = false) {
4614
+ const extensionRunner = this.session.extensionRunner;
4615
+ // Emit user_bash event to let extensions intercept
4616
+ const eventResult = await extensionRunner.emitUserBash({
4617
+ type: "user_bash",
4618
+ command,
4619
+ excludeFromContext,
4620
+ cwd: this.sessionManager.getCwd(),
4621
+ });
4622
+ // If extension returned a full result, use it directly
4623
+ if (eventResult?.result) {
4624
+ const result = eventResult.result;
4625
+ // Create UI component for display
4626
+ this.bashComponent = new BashExecutionComponent(command, this.ui, excludeFromContext);
4627
+ if (this.session.isStreaming) {
4628
+ this.pendingMessagesContainer.addChild(this.bashComponent);
4629
+ this.pendingBashComponents.push(this.bashComponent);
4630
+ }
4631
+ else {
4632
+ this.chatContainer.addChild(this.bashComponent);
4633
+ }
4634
+ // Show output and complete
4635
+ if (result.output) {
4636
+ this.bashComponent.appendOutput(result.output);
4637
+ }
4638
+ this.bashComponent.setComplete(result.exitCode, result.cancelled, result.truncated ? { truncated: true, content: result.output } : undefined, result.fullOutputPath);
4639
+ // Record the result in session
4640
+ this.session.recordBashResult(command, result, { excludeFromContext });
4641
+ this.bashComponent = undefined;
4642
+ this.ui.requestRender();
4643
+ return;
4644
+ }
4645
+ // Normal execution path (possibly with custom operations)
4646
+ const isDeferred = this.session.isStreaming;
4647
+ this.bashComponent = new BashExecutionComponent(command, this.ui, excludeFromContext);
4648
+ if (isDeferred) {
4649
+ // Show in pending area when agent is streaming
4650
+ this.pendingMessagesContainer.addChild(this.bashComponent);
4651
+ this.pendingBashComponents.push(this.bashComponent);
4652
+ }
4653
+ else {
4654
+ // Show in chat immediately when agent is idle
4655
+ this.chatContainer.addChild(this.bashComponent);
4656
+ }
4657
+ this.ui.requestRender();
4658
+ try {
4659
+ const result = await this.session.executeBash(command, (chunk) => {
4660
+ if (this.bashComponent) {
4661
+ this.bashComponent.appendOutput(chunk);
4662
+ this.ui.requestRender();
4663
+ }
4664
+ }, { excludeFromContext, operations: eventResult?.operations });
4665
+ if (this.bashComponent) {
4666
+ this.bashComponent.setComplete(result.exitCode, result.cancelled, result.truncated ? { truncated: true, content: result.output } : undefined, result.fullOutputPath);
4667
+ }
4668
+ }
4669
+ catch (error) {
4670
+ if (this.bashComponent) {
4671
+ this.bashComponent.setComplete(undefined, false);
4672
+ }
4673
+ this.showError(`Bash command failed: ${error instanceof Error ? error.message : "Unknown error"}`);
4674
+ }
4675
+ this.bashComponent = undefined;
4676
+ this.ui.requestRender();
4677
+ }
4678
+ async handleCompactCommand(customInstructions) {
4679
+ const entries = this.sessionManager.getEntries();
4680
+ const messageCount = entries.filter((e) => e.type === "message").length;
4681
+ if (messageCount < 2) {
4682
+ this.showWarning("Nothing to compact (no messages yet)");
4683
+ return;
4684
+ }
4685
+ if (this.loadingAnimation) {
4686
+ this.loadingAnimation.stop();
4687
+ this.loadingAnimation = undefined;
4688
+ }
4689
+ this.statusContainer.clear();
4690
+ try {
4691
+ await this.session.compact(customInstructions);
4692
+ }
4693
+ catch {
4694
+ // Ignore, will be emitted as an event
4695
+ }
4696
+ }
4697
+ stop() {
4698
+ this.unregisterSignalHandlers();
4699
+ if (this.settingsManager.getShowTerminalProgress()) {
4700
+ this.ui.terminal.setProgress(false);
4701
+ }
4702
+ if (this.loadingAnimation) {
4703
+ this.loadingAnimation.stop();
4704
+ this.loadingAnimation = undefined;
4705
+ }
4706
+ this.clearExtensionTerminalInputListeners();
4707
+ this.footer.dispose();
4708
+ this.footerDataProvider.dispose();
4709
+ if (this.metricsTimer) {
4710
+ clearInterval(this.metricsTimer);
4711
+ this.metricsTimer = null;
4712
+ }
4713
+ if (this.unsubscribe) {
4714
+ this.unsubscribe();
4715
+ }
4716
+ if (this.isInitialized) {
4717
+ this.ui.stop();
4718
+ this.isInitialized = false;
4719
+ }
4720
+ }
4721
+ }
4722
+ //# sourceMappingURL=interactive-mode.js.map