@prometheus-ai/agent 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1954) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +36 -0
  3. package/dist/types/async/index.d.ts +2 -0
  4. package/dist/types/async/job-manager.d.ts +88 -0
  5. package/dist/types/async/support.d.ts +2 -0
  6. package/dist/types/auto-thinking/classifier.d.ts +35 -0
  7. package/dist/types/autoresearch/dashboard.d.ts +4 -0
  8. package/dist/types/autoresearch/git.d.ts +36 -0
  9. package/dist/types/autoresearch/helpers.d.ts +24 -0
  10. package/dist/types/autoresearch/index.d.ts +2 -0
  11. package/dist/types/autoresearch/state.d.ts +17 -0
  12. package/dist/types/autoresearch/storage.d.ts +142 -0
  13. package/dist/types/autoresearch/tools/init-experiment.d.ts +31 -0
  14. package/dist/types/autoresearch/tools/log-experiment.d.ts +23 -0
  15. package/dist/types/autoresearch/tools/run-experiment.d.ts +8 -0
  16. package/dist/types/autoresearch/tools/update-notes.d.ts +12 -0
  17. package/dist/types/autoresearch/types.d.ts +154 -0
  18. package/dist/types/capability/context-file.d.ts +30 -0
  19. package/dist/types/capability/extension-module.d.ts +15 -0
  20. package/dist/types/capability/extension.d.ts +28 -0
  21. package/dist/types/capability/fs.d.ts +20 -0
  22. package/dist/types/capability/hook.d.ts +19 -0
  23. package/dist/types/capability/index.d.ts +80 -0
  24. package/dist/types/capability/instruction.d.ts +17 -0
  25. package/dist/types/capability/mcp.d.ts +45 -0
  26. package/dist/types/capability/prompt.d.ts +15 -0
  27. package/dist/types/capability/rule-buckets.d.ts +30 -0
  28. package/dist/types/capability/rule.d.ts +68 -0
  29. package/dist/types/capability/settings.d.ts +15 -0
  30. package/dist/types/capability/skill.d.ts +43 -0
  31. package/dist/types/capability/slash-command.d.ts +17 -0
  32. package/dist/types/capability/ssh.d.ts +23 -0
  33. package/dist/types/capability/system-prompt.d.ts +15 -0
  34. package/dist/types/capability/tool.d.ts +19 -0
  35. package/dist/types/capability/types.d.ts +158 -0
  36. package/dist/types/cli/agents-cli.d.ts +12 -0
  37. package/dist/types/cli/args.d.ts +55 -0
  38. package/dist/types/cli/auth-broker-cli.d.ts +25 -0
  39. package/dist/types/cli/auth-gateway-cli.d.ts +26 -0
  40. package/dist/types/cli/classify-install-target.d.ts +12 -0
  41. package/dist/types/cli/claude-trace-cli.d.ts +52 -0
  42. package/dist/types/cli/commands/init-xdg.d.ts +1 -0
  43. package/dist/types/cli/completion-gen.d.ts +80 -0
  44. package/dist/types/cli/config-cli.d.ts +22 -0
  45. package/dist/types/cli/dry-balance-cli.d.ts +104 -0
  46. package/dist/types/cli/extension-flags.d.ts +36 -0
  47. package/dist/types/cli/file-processor.d.ts +11 -0
  48. package/dist/types/cli/gateway-cli.d.ts +95 -0
  49. package/dist/types/cli/grep-cli.d.ts +17 -0
  50. package/dist/types/cli/grievances-cli.d.ts +37 -0
  51. package/dist/types/cli/initial-message.d.ts +17 -0
  52. package/dist/types/cli/list-models.d.ts +30 -0
  53. package/dist/types/cli/plugin-cli.d.ts +32 -0
  54. package/dist/types/cli/read-cli.d.ts +4 -0
  55. package/dist/types/cli/session-picker.d.ts +10 -0
  56. package/dist/types/cli/setup-cli.d.ts +24 -0
  57. package/dist/types/cli/shell-cli.d.ts +8 -0
  58. package/dist/types/cli/ssh-cli.d.ts +21 -0
  59. package/dist/types/cli/stats-cli.d.ts +17 -0
  60. package/dist/types/cli/tiny-models-cli.d.ts +9 -0
  61. package/dist/types/cli/update-cli.d.ts +106 -0
  62. package/dist/types/cli/web-search-cli.d.ts +20 -0
  63. package/dist/types/cli/worktree-cli.d.ts +26 -0
  64. package/dist/types/cli-commands.d.ts +19 -0
  65. package/dist/types/cli.d.ts +3 -0
  66. package/dist/types/commands/acp.d.ts +12 -0
  67. package/dist/types/commands/agents.d.ts +34 -0
  68. package/dist/types/commands/auth-broker.d.ts +54 -0
  69. package/dist/types/commands/auth-gateway.d.ts +35 -0
  70. package/dist/types/commands/commit.d.ts +27 -0
  71. package/dist/types/commands/complete.d.ts +6 -0
  72. package/dist/types/commands/completions.d.ts +13 -0
  73. package/dist/types/commands/config.d.ts +30 -0
  74. package/dist/types/commands/dry-balance.d.ts +31 -0
  75. package/dist/types/commands/gateway.d.ts +69 -0
  76. package/dist/types/commands/grep.d.ts +42 -0
  77. package/dist/types/commands/grievances.d.ts +40 -0
  78. package/dist/types/commands/install.d.ts +51 -0
  79. package/dist/types/commands/launch.d.ts +129 -0
  80. package/dist/types/commands/plugin.d.ts +52 -0
  81. package/dist/types/commands/read.d.ts +15 -0
  82. package/dist/types/commands/setup.d.ts +34 -0
  83. package/dist/types/commands/shell.d.ts +21 -0
  84. package/dist/types/commands/ssh.d.ts +48 -0
  85. package/dist/types/commands/stats.d.ts +25 -0
  86. package/dist/types/commands/tiny-models.d.ts +22 -0
  87. package/dist/types/commands/update.d.ts +20 -0
  88. package/dist/types/commands/web-search.d.ts +33 -0
  89. package/dist/types/commands/worktree.d.ts +34 -0
  90. package/dist/types/commit/agentic/agent.d.ts +31 -0
  91. package/dist/types/commit/agentic/fallback.d.ts +5 -0
  92. package/dist/types/commit/agentic/index.d.ts +2 -0
  93. package/dist/types/commit/agentic/state.d.ts +58 -0
  94. package/dist/types/commit/agentic/tools/analyze-file.d.ts +19 -0
  95. package/dist/types/commit/agentic/tools/git-file-diff.d.ts +10 -0
  96. package/dist/types/commit/agentic/tools/git-hunk.d.ts +9 -0
  97. package/dist/types/commit/agentic/tools/git-overview.d.ts +9 -0
  98. package/dist/types/commit/agentic/tools/index.d.ts +16 -0
  99. package/dist/types/commit/agentic/tools/propose-changelog.d.ts +28 -0
  100. package/dist/types/commit/agentic/tools/propose-commit.d.ts +36 -0
  101. package/dist/types/commit/agentic/tools/recent-commits.d.ts +7 -0
  102. package/dist/types/commit/agentic/tools/schemas.d.ts +27 -0
  103. package/dist/types/commit/agentic/tools/split-commit.d.ts +53 -0
  104. package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
  105. package/dist/types/commit/agentic/trivial.d.ts +7 -0
  106. package/dist/types/commit/agentic/validation.d.ts +20 -0
  107. package/dist/types/commit/analysis/conventional.d.ts +22 -0
  108. package/dist/types/commit/analysis/index.d.ts +4 -0
  109. package/dist/types/commit/analysis/scope.d.ts +6 -0
  110. package/dist/types/commit/analysis/summary.d.ts +19 -0
  111. package/dist/types/commit/analysis/validation.d.ts +8 -0
  112. package/dist/types/commit/changelog/detect.d.ts +2 -0
  113. package/dist/types/commit/changelog/generate.d.ts +30 -0
  114. package/dist/types/commit/changelog/index.d.ts +30 -0
  115. package/dist/types/commit/changelog/parse.d.ts +2 -0
  116. package/dist/types/commit/cli.d.ts +3 -0
  117. package/dist/types/commit/git/diff.d.ts +5 -0
  118. package/dist/types/commit/index.d.ts +4 -0
  119. package/dist/types/commit/map-reduce/index.d.ts +28 -0
  120. package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
  121. package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
  122. package/dist/types/commit/map-reduce/utils.d.ts +2 -0
  123. package/dist/types/commit/message.d.ts +2 -0
  124. package/dist/types/commit/model-selection.d.ts +15 -0
  125. package/dist/types/commit/pipeline.d.ts +5 -0
  126. package/dist/types/commit/shared-llm.d.ts +54 -0
  127. package/dist/types/commit/types.d.ts +78 -0
  128. package/dist/types/commit/utils/exclusions.d.ts +4 -0
  129. package/dist/types/commit/utils.d.ts +20 -0
  130. package/dist/types/config/append-only-context-mode.d.ts +8 -0
  131. package/dist/types/config/config-file.d.ts +62 -0
  132. package/dist/types/config/file-lock.d.ts +29 -0
  133. package/dist/types/config/keybindings.d.ts +352 -0
  134. package/dist/types/config/model-equivalence.d.ts +24 -0
  135. package/dist/types/config/model-id-affixes.d.ts +10 -0
  136. package/dist/types/config/model-registry.d.ts +400 -0
  137. package/dist/types/config/model-resolver.d.ts +230 -0
  138. package/dist/types/config/models-config-schema.d.ts +523 -0
  139. package/dist/types/config/prompt-templates.d.ts +32 -0
  140. package/dist/types/config/resolve-config-value.d.ts +17 -0
  141. package/dist/types/config/settings-schema.d.ts +4352 -0
  142. package/dist/types/config/settings.d.ts +156 -0
  143. package/dist/types/config.d.ts +92 -0
  144. package/dist/types/cursor.d.ts +22 -0
  145. package/dist/types/dap/client.d.ts +38 -0
  146. package/dist/types/dap/config.d.ts +6 -0
  147. package/dist/types/dap/index.d.ts +4 -0
  148. package/dist/types/dap/session.d.ts +108 -0
  149. package/dist/types/dap/types.d.ts +524 -0
  150. package/dist/types/debug/index.d.ts +15 -0
  151. package/dist/types/debug/log-formatting.d.ts +4 -0
  152. package/dist/types/debug/log-viewer.d.ts +68 -0
  153. package/dist/types/debug/profiler.d.ts +24 -0
  154. package/dist/types/debug/protocol-probe.d.ts +38 -0
  155. package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
  156. package/dist/types/debug/raw-sse.d.ts +18 -0
  157. package/dist/types/debug/report-bundle.d.ts +55 -0
  158. package/dist/types/debug/system-info.d.ts +26 -0
  159. package/dist/types/debug/terminal-info.d.ts +34 -0
  160. package/dist/types/discovery/agents-md.d.ts +1 -0
  161. package/dist/types/discovery/agents.d.ts +12 -0
  162. package/dist/types/discovery/builtin-defaults.d.ts +1 -0
  163. package/dist/types/discovery/builtin-rules/index.d.ts +7 -0
  164. package/dist/types/discovery/builtin.d.ts +1 -0
  165. package/dist/types/discovery/claude-plugins.d.ts +1 -0
  166. package/dist/types/discovery/claude.d.ts +1 -0
  167. package/dist/types/discovery/cline.d.ts +1 -0
  168. package/dist/types/discovery/codex.d.ts +1 -0
  169. package/dist/types/discovery/context-files.d.ts +17 -0
  170. package/dist/types/discovery/cursor.d.ts +16 -0
  171. package/dist/types/discovery/gemini.d.ts +1 -0
  172. package/dist/types/discovery/github.d.ts +1 -0
  173. package/dist/types/discovery/helpers.d.ts +269 -0
  174. package/dist/types/discovery/index.d.ts +53 -0
  175. package/dist/types/discovery/mcp-json.d.ts +1 -0
  176. package/dist/types/discovery/opencode.d.ts +1 -0
  177. package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
  178. package/dist/types/discovery/prometheus-extension-roots.d.ts +43 -0
  179. package/dist/types/discovery/prometheus-plugins.d.ts +1 -0
  180. package/dist/types/discovery/ssh.d.ts +1 -0
  181. package/dist/types/discovery/substitute-plugin-root.d.ts +1 -0
  182. package/dist/types/discovery/vscode.d.ts +1 -0
  183. package/dist/types/discovery/windsurf.d.ts +13 -0
  184. package/dist/types/edit/apply-patch/index.d.ts +35 -0
  185. package/dist/types/edit/apply-patch/parser.d.ts +34 -0
  186. package/dist/types/edit/diff.d.ts +59 -0
  187. package/dist/types/edit/file-snapshot-store.d.ts +40 -0
  188. package/dist/types/edit/hashline/block-resolver.d.ts +9 -0
  189. package/dist/types/edit/hashline/diff.d.ts +40 -0
  190. package/dist/types/edit/hashline/execute.d.ts +28 -0
  191. package/dist/types/edit/hashline/filesystem.d.ts +57 -0
  192. package/dist/types/edit/hashline/index.d.ts +5 -0
  193. package/dist/types/edit/hashline/params.d.ts +11 -0
  194. package/dist/types/edit/index.d.ts +62 -0
  195. package/dist/types/edit/modes/apply-patch.d.ts +24 -0
  196. package/dist/types/edit/modes/patch.d.ts +99 -0
  197. package/dist/types/edit/modes/replace.d.ts +142 -0
  198. package/dist/types/edit/normalize.d.ts +31 -0
  199. package/dist/types/edit/notebook.d.ts +23 -0
  200. package/dist/types/edit/read-file.d.ts +2 -0
  201. package/dist/types/edit/renderer.d.ts +109 -0
  202. package/dist/types/edit/streaming.d.ts +75 -0
  203. package/dist/types/eval/__tests__/agent-bridge.test.d.ts +1 -0
  204. package/dist/types/eval/__tests__/bridge-timeout.test.d.ts +1 -0
  205. package/dist/types/eval/__tests__/budget-bridge.test.d.ts +1 -0
  206. package/dist/types/eval/__tests__/idle-timeout.test.d.ts +1 -0
  207. package/dist/types/eval/__tests__/kernel-spawn.test.d.ts +1 -0
  208. package/dist/types/eval/__tests__/llm-bridge.test.d.ts +1 -0
  209. package/dist/types/eval/__tests__/shared-executors.test.d.ts +1 -0
  210. package/dist/types/eval/agent-bridge.d.ts +25 -0
  211. package/dist/types/eval/backend.d.ts +55 -0
  212. package/dist/types/eval/bridge-timeout.d.ts +27 -0
  213. package/dist/types/eval/budget-bridge.d.ts +29 -0
  214. package/dist/types/eval/concurrency-bridge.d.ts +26 -0
  215. package/dist/types/eval/idle-timeout.d.ts +30 -0
  216. package/dist/types/eval/index.d.ts +4 -0
  217. package/dist/types/eval/js/context-manager.d.ts +24 -0
  218. package/dist/types/eval/js/executor.d.ts +36 -0
  219. package/dist/types/eval/js/index.d.ts +10 -0
  220. package/dist/types/eval/js/shared/helpers.d.ts +38 -0
  221. package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
  222. package/dist/types/eval/js/shared/local-module-loader.d.ts +16 -0
  223. package/dist/types/eval/js/shared/prelude.d.ts +1 -0
  224. package/dist/types/eval/js/shared/rewrite-imports.d.ts +25 -0
  225. package/dist/types/eval/js/shared/runtime.d.ts +53 -0
  226. package/dist/types/eval/js/shared/types.d.ts +24 -0
  227. package/dist/types/eval/js/tool-bridge.d.ts +20 -0
  228. package/dist/types/eval/js/worker-core.d.ts +5 -0
  229. package/dist/types/eval/js/worker-entry.d.ts +1 -0
  230. package/dist/types/eval/js/worker-protocol.d.ts +77 -0
  231. package/dist/types/eval/llm-bridge.d.ts +25 -0
  232. package/dist/types/eval/py/display.d.ts +25 -0
  233. package/dist/types/eval/py/executor.d.ts +95 -0
  234. package/dist/types/eval/py/index.d.ts +11 -0
  235. package/dist/types/eval/py/kernel.d.ts +70 -0
  236. package/dist/types/eval/py/prelude.d.ts +1 -0
  237. package/dist/types/eval/py/runtime.d.ts +31 -0
  238. package/dist/types/eval/py/spawn-options.d.ts +58 -0
  239. package/dist/types/eval/py/tool-bridge.d.ts +16 -0
  240. package/dist/types/eval/session-id.d.ts +3 -0
  241. package/dist/types/eval/types.d.ts +52 -0
  242. package/dist/types/exa/factory.d.ts +13 -0
  243. package/dist/types/exa/index.d.ts +20 -0
  244. package/dist/types/exa/mcp-client.d.ts +46 -0
  245. package/dist/types/exa/render.d.ts +19 -0
  246. package/dist/types/exa/researcher.d.ts +9 -0
  247. package/dist/types/exa/search.d.ts +9 -0
  248. package/dist/types/exa/types.d.ts +155 -0
  249. package/dist/types/exa/websets.d.ts +9 -0
  250. package/dist/types/exec/bash-executor.d.ts +42 -0
  251. package/dist/types/exec/exec.d.ts +25 -0
  252. package/dist/types/exec/idle-timeout-watchdog.d.ts +18 -0
  253. package/dist/types/exec/non-interactive-env.d.ts +1 -0
  254. package/dist/types/export/custom-share.d.ts +20 -0
  255. package/dist/types/export/html/index.d.ts +10 -0
  256. package/dist/types/export/html/template.generated.d.ts +1 -0
  257. package/dist/types/export/html/template.macro.d.ts +5 -0
  258. package/dist/types/export/ttsr.d.ts +53 -0
  259. package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
  260. package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
  261. package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
  262. package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
  263. package/dist/types/extensibility/custom-commands/types.d.ts +106 -0
  264. package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
  265. package/dist/types/extensibility/custom-tools/loader.d.ts +69 -0
  266. package/dist/types/extensibility/custom-tools/types.d.ts +232 -0
  267. package/dist/types/extensibility/custom-tools/wrapper.d.ts +23 -0
  268. package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
  269. package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
  270. package/dist/types/extensibility/extensions/index.d.ts +8 -0
  271. package/dist/types/extensibility/extensions/loader.d.ts +43 -0
  272. package/dist/types/extensibility/extensions/runner.d.ts +142 -0
  273. package/dist/types/extensibility/extensions/types.d.ts +892 -0
  274. package/dist/types/extensibility/extensions/wrapper.d.ts +54 -0
  275. package/dist/types/extensibility/hooks/index.d.ts +5 -0
  276. package/dist/types/extensibility/hooks/loader.d.ts +89 -0
  277. package/dist/types/extensibility/hooks/runner.d.ts +126 -0
  278. package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
  279. package/dist/types/extensibility/hooks/types.d.ts +435 -0
  280. package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +23 -0
  281. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +14 -0
  282. package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
  283. package/dist/types/extensibility/plugins/git-url.d.ts +44 -0
  284. package/dist/types/extensibility/plugins/index.d.ts +7 -0
  285. package/dist/types/extensibility/plugins/installer.d.ts +5 -0
  286. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +29 -0
  287. package/dist/types/extensibility/plugins/loader.d.ts +41 -0
  288. package/dist/types/extensibility/plugins/manager.d.ts +76 -0
  289. package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
  290. package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
  291. package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
  292. package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
  293. package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
  294. package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
  295. package/dist/types/extensibility/plugins/marketplace/types.d.ts +130 -0
  296. package/dist/types/extensibility/plugins/parser.d.ts +52 -0
  297. package/dist/types/extensibility/plugins/types.d.ts +149 -0
  298. package/dist/types/extensibility/shared-events.d.ts +279 -0
  299. package/dist/types/extensibility/skills.d.ts +57 -0
  300. package/dist/types/extensibility/slash-commands.d.ts +48 -0
  301. package/dist/types/extensibility/tool-proxy.d.ts +4 -0
  302. package/dist/types/extensibility/typebox.d.ts +155 -0
  303. package/dist/types/extensibility/utils.d.ts +12 -0
  304. package/dist/types/gateway/adapters/telegram/access.d.ts +11 -0
  305. package/dist/types/gateway/adapters/telegram/commands.d.ts +41 -0
  306. package/dist/types/gateway/adapters/telegram/expressions.d.ts +60 -0
  307. package/dist/types/gateway/adapters/telegram/media.d.ts +58 -0
  308. package/dist/types/gateway/adapters/telegram/native-command-policy.d.ts +6 -0
  309. package/dist/types/gateway/adapters/telegram/native-commands.d.ts +23 -0
  310. package/dist/types/gateway/adapters/telegram/normalize.d.ts +8 -0
  311. package/dist/types/gateway/adapters/telegram/send-message.d.ts +388 -0
  312. package/dist/types/gateway/adapters/telegram/service.d.ts +65 -0
  313. package/dist/types/gateway/adapters/telegram/setup-api.d.ts +39 -0
  314. package/dist/types/gateway/adapters/telegram/setup-config.d.ts +11 -0
  315. package/dist/types/gateway/adapters/telegram/types.d.ts +187 -0
  316. package/dist/types/gateway/adapters/telegram/webhook.d.ts +53 -0
  317. package/dist/types/gateway/commands.d.ts +33 -0
  318. package/dist/types/gateway/context.d.ts +30 -0
  319. package/dist/types/gateway/native-slash-policy.d.ts +12 -0
  320. package/dist/types/gateway/prometheus-dispatch.d.ts +29 -0
  321. package/dist/types/gateway/router.d.ts +52 -0
  322. package/dist/types/gateway/session-key.d.ts +3 -0
  323. package/dist/types/gateway/types.d.ts +98 -0
  324. package/dist/types/goals/index.d.ts +3 -0
  325. package/dist/types/goals/runtime.d.ts +67 -0
  326. package/dist/types/goals/state.d.ts +35 -0
  327. package/dist/types/goals/tools/goal-tool.d.ts +66 -0
  328. package/dist/types/hindsight/backend.d.ts +13 -0
  329. package/dist/types/hindsight/bank.d.ts +62 -0
  330. package/dist/types/hindsight/client.d.ts +224 -0
  331. package/dist/types/hindsight/config.d.ts +51 -0
  332. package/dist/types/hindsight/content.d.ts +70 -0
  333. package/dist/types/hindsight/index.d.ts +8 -0
  334. package/dist/types/hindsight/mental-models.d.ts +125 -0
  335. package/dist/types/hindsight/state.d.ts +105 -0
  336. package/dist/types/hindsight/transcript.d.ts +28 -0
  337. package/dist/types/index.d.ts +36 -0
  338. package/dist/types/internal-urls/agent-protocol.d.ts +13 -0
  339. package/dist/types/internal-urls/artifact-protocol.d.ts +7 -0
  340. package/dist/types/internal-urls/docs-index.generated.d.ts +2 -0
  341. package/dist/types/internal-urls/index.d.ts +23 -0
  342. package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
  343. package/dist/types/internal-urls/json-query.d.ts +30 -0
  344. package/dist/types/internal-urls/local-protocol.d.ts +50 -0
  345. package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
  346. package/dist/types/internal-urls/memory-protocol.d.ts +24 -0
  347. package/dist/types/internal-urls/parse.d.ts +19 -0
  348. package/dist/types/internal-urls/prometheus-protocol.d.ts +13 -0
  349. package/dist/types/internal-urls/registry-helpers.d.ts +10 -0
  350. package/dist/types/internal-urls/router.d.ts +21 -0
  351. package/dist/types/internal-urls/rule-protocol.d.ts +7 -0
  352. package/dist/types/internal-urls/skill-protocol.d.ts +14 -0
  353. package/dist/types/internal-urls/types.d.ts +145 -0
  354. package/dist/types/internal-urls/vault-protocol.d.ts +93 -0
  355. package/dist/types/lib/xai-http.d.ts +40 -0
  356. package/dist/types/lsp/client.d.ts +68 -0
  357. package/dist/types/lsp/clients/biome-client.d.ts +16 -0
  358. package/dist/types/lsp/clients/index.d.ts +19 -0
  359. package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
  360. package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
  361. package/dist/types/lsp/config.d.ts +65 -0
  362. package/dist/types/lsp/diagnostics-ledger.d.ts +10 -0
  363. package/dist/types/lsp/edits.d.ts +23 -0
  364. package/dist/types/lsp/index.d.ts +140 -0
  365. package/dist/types/lsp/lspmux.d.ts +58 -0
  366. package/dist/types/lsp/render.d.ts +32 -0
  367. package/dist/types/lsp/startup-events.d.ts +11 -0
  368. package/dist/types/lsp/types.d.ts +302 -0
  369. package/dist/types/lsp/utils.d.ts +112 -0
  370. package/dist/types/main.d.ts +56 -0
  371. package/dist/types/mcp/client.d.ts +75 -0
  372. package/dist/types/mcp/config-writer.d.ts +53 -0
  373. package/dist/types/mcp/config.d.ts +75 -0
  374. package/dist/types/mcp/index.d.ts +18 -0
  375. package/dist/types/mcp/json-rpc.d.ts +27 -0
  376. package/dist/types/mcp/loader.d.ts +43 -0
  377. package/dist/types/mcp/manager.d.ts +202 -0
  378. package/dist/types/mcp/oauth-discovery.d.ts +41 -0
  379. package/dist/types/mcp/oauth-flow.d.ts +59 -0
  380. package/dist/types/mcp/render.d.ts +25 -0
  381. package/dist/types/mcp/smithery-auth.d.ts +16 -0
  382. package/dist/types/mcp/smithery-connect.d.ts +38 -0
  383. package/dist/types/mcp/smithery-registry.d.ts +51 -0
  384. package/dist/types/mcp/timeout.d.ts +9 -0
  385. package/dist/types/mcp/tool-bridge.d.ts +90 -0
  386. package/dist/types/mcp/tool-cache.d.ts +8 -0
  387. package/dist/types/mcp/transports/http.d.ts +45 -0
  388. package/dist/types/mcp/transports/index.d.ts +5 -0
  389. package/dist/types/mcp/transports/stdio.d.ts +60 -0
  390. package/dist/types/mcp/types.d.ts +333 -0
  391. package/dist/types/memories/index.d.ts +43 -0
  392. package/dist/types/memories/storage.d.ts +120 -0
  393. package/dist/types/memory-backend/index.d.ts +5 -0
  394. package/dist/types/memory-backend/local-backend.d.ts +9 -0
  395. package/dist/types/memory-backend/off-backend.d.ts +7 -0
  396. package/dist/types/memory-backend/resolve.d.ts +16 -0
  397. package/dist/types/memory-backend/types.d.ts +67 -0
  398. package/dist/types/mnemopi/backend.d.ts +4 -0
  399. package/dist/types/mnemopi/config.d.ts +29 -0
  400. package/dist/types/mnemopi/index.d.ts +3 -0
  401. package/dist/types/mnemopi/state.d.ts +72 -0
  402. package/dist/types/modes/acp/acp-agent.d.ts +61 -0
  403. package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
  404. package/dist/types/modes/acp/acp-event-mapper.d.ts +32 -0
  405. package/dist/types/modes/acp/acp-mode.d.ts +5 -0
  406. package/dist/types/modes/acp/index.d.ts +2 -0
  407. package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
  408. package/dist/types/modes/components/agent-dashboard.d.ts +22 -0
  409. package/dist/types/modes/components/assistant-message.d.ts +35 -0
  410. package/dist/types/modes/components/bash-execution.d.ts +29 -0
  411. package/dist/types/modes/components/bordered-loader.d.ts +11 -0
  412. package/dist/types/modes/components/branch-summary-message.d.ts +13 -0
  413. package/dist/types/modes/components/btw-panel.d.ts +16 -0
  414. package/dist/types/modes/components/compaction-summary-message.d.ts +13 -0
  415. package/dist/types/modes/components/copy-selector.d.ts +22 -0
  416. package/dist/types/modes/components/countdown-timer.d.ts +14 -0
  417. package/dist/types/modes/components/custom-editor.d.ts +53 -0
  418. package/dist/types/modes/components/custom-message.d.ts +15 -0
  419. package/dist/types/modes/components/diff.d.ts +11 -0
  420. package/dist/types/modes/components/dynamic-border.d.ts +14 -0
  421. package/dist/types/modes/components/error-banner.d.ts +11 -0
  422. package/dist/types/modes/components/eval-execution.d.ts +23 -0
  423. package/dist/types/modes/components/execution-shared.d.ts +46 -0
  424. package/dist/types/modes/components/extensions/extension-dashboard.d.ts +27 -0
  425. package/dist/types/modes/components/extensions/extension-list.d.ts +39 -0
  426. package/dist/types/modes/components/extensions/index.d.ts +8 -0
  427. package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
  428. package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
  429. package/dist/types/modes/components/extensions/types.d.ts +147 -0
  430. package/dist/types/modes/components/footer.d.ts +30 -0
  431. package/dist/types/modes/components/history-search.d.ts +7 -0
  432. package/dist/types/modes/components/hook-editor.d.ts +18 -0
  433. package/dist/types/modes/components/hook-input.d.ts +15 -0
  434. package/dist/types/modes/components/hook-message.d.ts +15 -0
  435. package/dist/types/modes/components/hook-selector.d.ts +70 -0
  436. package/dist/types/modes/components/index.d.ts +37 -0
  437. package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
  438. package/dist/types/modes/components/login-dialog.d.ts +32 -0
  439. package/dist/types/modes/components/mcp-add-wizard.d.ts +25 -0
  440. package/dist/types/modes/components/message-frame.d.ts +42 -0
  441. package/dist/types/modes/components/model-selector.d.ts +28 -0
  442. package/dist/types/modes/components/oauth-selector.d.ts +14 -0
  443. package/dist/types/modes/components/omfg-panel.d.ts +19 -0
  444. package/dist/types/modes/components/plugin-selector.d.ts +26 -0
  445. package/dist/types/modes/components/plugin-settings.d.ts +98 -0
  446. package/dist/types/modes/components/queue-mode-selector.d.ts +9 -0
  447. package/dist/types/modes/components/read-tool-group.d.ts +30 -0
  448. package/dist/types/modes/components/segment-track.d.ts +22 -0
  449. package/dist/types/modes/components/session-observer-overlay.d.ts +11 -0
  450. package/dist/types/modes/components/session-selector.d.ts +62 -0
  451. package/dist/types/modes/components/settings-defs.d.ts +50 -0
  452. package/dist/types/modes/components/settings-selector.d.ts +54 -0
  453. package/dist/types/modes/components/show-images-selector.d.ts +9 -0
  454. package/dist/types/modes/components/skill-message.d.ts +9 -0
  455. package/dist/types/modes/components/status-line/context-thresholds.d.ts +10 -0
  456. package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
  457. package/dist/types/modes/components/status-line/index.d.ts +4 -0
  458. package/dist/types/modes/components/status-line/presets.d.ts +3 -0
  459. package/dist/types/modes/components/status-line/segments.d.ts +5 -0
  460. package/dist/types/modes/components/status-line/separators.d.ts +3 -0
  461. package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
  462. package/dist/types/modes/components/status-line/types.d.ts +80 -0
  463. package/dist/types/modes/components/status-line.d.ts +77 -0
  464. package/dist/types/modes/components/theme-selector.d.ts +10 -0
  465. package/dist/types/modes/components/thinking-selector.d.ts +10 -0
  466. package/dist/types/modes/components/tiny-title-download-progress.d.ts +11 -0
  467. package/dist/types/modes/components/todo-reminder.d.ts +13 -0
  468. package/dist/types/modes/components/tool-execution.d.ts +77 -0
  469. package/dist/types/modes/components/transcript-container.d.ts +38 -0
  470. package/dist/types/modes/components/tree-selector.d.ts +31 -0
  471. package/dist/types/modes/components/ttsr-notification.d.ts +13 -0
  472. package/dist/types/modes/components/user-message-selector.d.ts +28 -0
  473. package/dist/types/modes/components/user-message.d.ts +8 -0
  474. package/dist/types/modes/components/visual-truncate.d.ts +19 -0
  475. package/dist/types/modes/components/welcome.d.ts +55 -0
  476. package/dist/types/modes/controllers/btw-controller.d.ts +10 -0
  477. package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
  478. package/dist/types/modes/controllers/command-controller.d.ts +41 -0
  479. package/dist/types/modes/controllers/event-controller.d.ts +12 -0
  480. package/dist/types/modes/controllers/extension-ui-controller.d.ts +83 -0
  481. package/dist/types/modes/controllers/input-controller.d.ts +34 -0
  482. package/dist/types/modes/controllers/mcp-command-controller.d.ts +10 -0
  483. package/dist/types/modes/controllers/omfg-controller.d.ts +10 -0
  484. package/dist/types/modes/controllers/omfg-rule.d.ts +26 -0
  485. package/dist/types/modes/controllers/selector-controller.d.ts +46 -0
  486. package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
  487. package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
  488. package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
  489. package/dist/types/modes/gradient-highlight.d.ts +27 -0
  490. package/dist/types/modes/image-references.d.ts +17 -0
  491. package/dist/types/modes/index.d.ts +9 -0
  492. package/dist/types/modes/interactive-mode.d.ts +291 -0
  493. package/dist/types/modes/internal-url-autocomplete.d.ts +43 -0
  494. package/dist/types/modes/loop-limit.d.ts +22 -0
  495. package/dist/types/modes/magic-keywords.d.ts +14 -0
  496. package/dist/types/modes/markdown-prose.d.ts +27 -0
  497. package/dist/types/modes/oauth-manual-input.d.ts +8 -0
  498. package/dist/types/modes/orchestrate.d.ts +15 -0
  499. package/dist/types/modes/print-mode.d.ts +27 -0
  500. package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
  501. package/dist/types/modes/rpc/host-tools.d.ts +16 -0
  502. package/dist/types/modes/rpc/host-uris.d.ts +38 -0
  503. package/dist/types/modes/rpc/rpc-client.d.ts +249 -0
  504. package/dist/types/modes/rpc/rpc-mode.d.ts +17 -0
  505. package/dist/types/modes/rpc/rpc-types.d.ts +586 -0
  506. package/dist/types/modes/runtime-init.d.ts +21 -0
  507. package/dist/types/modes/session-observer-registry.d.ts +26 -0
  508. package/dist/types/modes/setup-wizard/index.d.ts +16 -0
  509. package/dist/types/modes/setup-wizard/scenes/channels.d.ts +14 -0
  510. package/dist/types/modes/setup-wizard/scenes/glyph.d.ts +2 -0
  511. package/dist/types/modes/setup-wizard/scenes/outro.d.ts +2 -0
  512. package/dist/types/modes/setup-wizard/scenes/providers.d.ts +2 -0
  513. package/dist/types/modes/setup-wizard/scenes/sign-in.d.ts +19 -0
  514. package/dist/types/modes/setup-wizard/scenes/splash.d.ts +11 -0
  515. package/dist/types/modes/setup-wizard/scenes/telegram.d.ts +20 -0
  516. package/dist/types/modes/setup-wizard/scenes/theme.d.ts +2 -0
  517. package/dist/types/modes/setup-wizard/scenes/types.d.ts +43 -0
  518. package/dist/types/modes/setup-wizard/scenes/web-search.d.ts +19 -0
  519. package/dist/types/modes/setup-wizard/wizard-overlay.d.ts +14 -0
  520. package/dist/types/modes/shared.d.ts +15 -0
  521. package/dist/types/modes/theme/defaults/index.d.ts +9436 -0
  522. package/dist/types/modes/theme/mermaid-cache.d.ts +9 -0
  523. package/dist/types/modes/theme/shimmer.d.ts +40 -0
  524. package/dist/types/modes/theme/theme.d.ts +305 -0
  525. package/dist/types/modes/turn-budget.d.ts +18 -0
  526. package/dist/types/modes/types.d.ts +294 -0
  527. package/dist/types/modes/ultrathink.d.ts +15 -0
  528. package/dist/types/modes/utils/context-usage.d.ts +47 -0
  529. package/dist/types/modes/utils/copy-targets.d.ts +53 -0
  530. package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
  531. package/dist/types/modes/utils/keybinding-matchers.d.ts +19 -0
  532. package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
  533. package/dist/types/modes/utils/ui-helpers.d.ts +55 -0
  534. package/dist/types/modes/workflow.d.ts +15 -0
  535. package/dist/types/plan-mode/approved-plan.d.ts +49 -0
  536. package/dist/types/plan-mode/plan-handoff.d.ts +20 -0
  537. package/dist/types/plan-mode/plan-protection.d.ts +12 -0
  538. package/dist/types/plan-mode/state.d.ts +6 -0
  539. package/dist/types/registry/agent-registry.d.ts +62 -0
  540. package/dist/types/sdk.d.ts +271 -0
  541. package/dist/types/secrets/index.d.ts +9 -0
  542. package/dist/types/secrets/obfuscator.d.ts +23 -0
  543. package/dist/types/secrets/regex.d.ts +2 -0
  544. package/dist/types/session/agent-session.d.ts +1032 -0
  545. package/dist/types/session/agent-storage.d.ts +94 -0
  546. package/dist/types/session/artifacts.d.ts +61 -0
  547. package/dist/types/session/auth-broker-config.d.ts +13 -0
  548. package/dist/types/session/auth-storage.d.ts +6 -0
  549. package/dist/types/session/blob-store.d.ts +64 -0
  550. package/dist/types/session/client-bridge.d.ts +88 -0
  551. package/dist/types/session/history-storage.d.ts +30 -0
  552. package/dist/types/session/indexed-session-storage.d.ts +59 -0
  553. package/dist/types/session/messages.d.ts +173 -0
  554. package/dist/types/session/redis-session-storage.d.ts +51 -0
  555. package/dist/types/session/session-dump-format.d.ts +22 -0
  556. package/dist/types/session/session-manager.d.ts +594 -0
  557. package/dist/types/session/session-storage.d.ts +86 -0
  558. package/dist/types/session/shake-types.d.ts +24 -0
  559. package/dist/types/session/sql-session-storage.d.ts +72 -0
  560. package/dist/types/session/streaming-output.d.ts +185 -0
  561. package/dist/types/session/tool-choice-queue.d.ts +78 -0
  562. package/dist/types/session/yield-queue.d.ts +24 -0
  563. package/dist/types/slash-commands/acp-builtins.d.ts +18 -0
  564. package/dist/types/slash-commands/builtin-registry.d.ts +23 -0
  565. package/dist/types/slash-commands/headless-plan.d.ts +3 -0
  566. package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
  567. package/dist/types/slash-commands/helpers/format.d.ts +10 -0
  568. package/dist/types/slash-commands/helpers/marketplace-manager.d.ts +8 -0
  569. package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
  570. package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
  571. package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
  572. package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
  573. package/dist/types/slash-commands/helpers/usage-report.d.ts +7 -0
  574. package/dist/types/slash-commands/marketplace-install-parser.d.ts +33 -0
  575. package/dist/types/slash-commands/types.d.ts +129 -0
  576. package/dist/types/ssh/config-writer.d.ts +49 -0
  577. package/dist/types/ssh/connection-manager.d.ts +33 -0
  578. package/dist/types/ssh/ssh-executor.d.ts +37 -0
  579. package/dist/types/ssh/sshfs-mount.d.ts +6 -0
  580. package/dist/types/ssh/utils.d.ts +2 -0
  581. package/dist/types/stt/downloader.d.ts +9 -0
  582. package/dist/types/stt/index.d.ts +3 -0
  583. package/dist/types/stt/recorder.d.ts +13 -0
  584. package/dist/types/stt/setup.d.ts +18 -0
  585. package/dist/types/stt/stt-controller.d.ts +16 -0
  586. package/dist/types/stt/transcriber.d.ts +16 -0
  587. package/dist/types/system-prompt.d.ts +97 -0
  588. package/dist/types/task/agents.d.ts +28 -0
  589. package/dist/types/task/commands.d.ts +35 -0
  590. package/dist/types/task/discovery.d.ts +18 -0
  591. package/dist/types/task/executor.d.ts +121 -0
  592. package/dist/types/task/index.d.ts +42 -0
  593. package/dist/types/task/name-generator.d.ts +16 -0
  594. package/dist/types/task/output-manager.d.ts +27 -0
  595. package/dist/types/task/parallel.d.ts +34 -0
  596. package/dist/types/task/prometheus-command.d.ts +7 -0
  597. package/dist/types/task/render.d.ts +26 -0
  598. package/dist/types/task/repair-args.d.ts +52 -0
  599. package/dist/types/task/simple-mode.d.ts +8 -0
  600. package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
  601. package/dist/types/task/types.d.ts +300 -0
  602. package/dist/types/task/worktree.d.ts +94 -0
  603. package/dist/types/telemetry-export.d.ts +43 -0
  604. package/dist/types/thinking.d.ts +68 -0
  605. package/dist/types/tiny/compiled-runtime.d.ts +35 -0
  606. package/dist/types/tiny/device.d.ts +78 -0
  607. package/dist/types/tiny/dtype.d.ts +85 -0
  608. package/dist/types/tiny/models.d.ts +204 -0
  609. package/dist/types/tiny/text.d.ts +36 -0
  610. package/dist/types/tiny/title-client.d.ts +73 -0
  611. package/dist/types/tiny/title-protocol.d.ts +77 -0
  612. package/dist/types/tiny/worker.d.ts +2 -0
  613. package/dist/types/tool-discovery/mode.d.ts +8 -0
  614. package/dist/types/tool-discovery/tool-index.d.ts +57 -0
  615. package/dist/types/tools/approval.d.ts +46 -0
  616. package/dist/types/tools/archive-reader.d.ts +44 -0
  617. package/dist/types/tools/ask.d.ts +113 -0
  618. package/dist/types/tools/ast-edit.d.ts +79 -0
  619. package/dist/types/tools/ast-grep.d.ts +70 -0
  620. package/dist/types/tools/auto-generated-guard.d.ts +17 -0
  621. package/dist/types/tools/bash-command-fixup.d.ts +11 -0
  622. package/dist/types/tools/bash-interactive.d.ts +16 -0
  623. package/dist/types/tools/bash-interceptor.d.ts +24 -0
  624. package/dist/types/tools/bash-pty-selection.d.ts +7 -0
  625. package/dist/types/tools/bash-skill-urls.d.ts +31 -0
  626. package/dist/types/tools/bash.d.ts +142 -0
  627. package/dist/types/tools/browser/attach.d.ts +34 -0
  628. package/dist/types/tools/browser/launch.d.ts +62 -0
  629. package/dist/types/tools/browser/readable.d.ts +17 -0
  630. package/dist/types/tools/browser/registry.d.ts +42 -0
  631. package/dist/types/tools/browser/render.d.ts +50 -0
  632. package/dist/types/tools/browser/tab-protocol.d.ts +144 -0
  633. package/dist/types/tools/browser/tab-supervisor.d.ts +63 -0
  634. package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
  635. package/dist/types/tools/browser/tab-worker.d.ts +19 -0
  636. package/dist/types/tools/browser.d.ts +116 -0
  637. package/dist/types/tools/checkpoint.d.ts +65 -0
  638. package/dist/types/tools/conflict-detect.d.ts +205 -0
  639. package/dist/types/tools/context.d.ts +19 -0
  640. package/dist/types/tools/debug.d.ts +217 -0
  641. package/dist/types/tools/eval-backends.d.ts +12 -0
  642. package/dist/types/tools/eval-render.d.ts +60 -0
  643. package/dist/types/tools/eval.d.ts +77 -0
  644. package/dist/types/tools/fetch.d.ts +80 -0
  645. package/dist/types/tools/file-recorder.d.ts +13 -0
  646. package/dist/types/tools/find.d.ts +103 -0
  647. package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
  648. package/dist/types/tools/gh-format.d.ts +6 -0
  649. package/dist/types/tools/gh-renderer.d.ts +25 -0
  650. package/dist/types/tools/gh.d.ts +357 -0
  651. package/dist/types/tools/github-cache.d.ts +103 -0
  652. package/dist/types/tools/grouped-file-output.d.ts +36 -0
  653. package/dist/types/tools/image-gen.d.ts +82 -0
  654. package/dist/types/tools/index.d.ts +269 -0
  655. package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
  656. package/dist/types/tools/inspect-image.d.ts +32 -0
  657. package/dist/types/tools/irc.d.ts +80 -0
  658. package/dist/types/tools/job.d.ts +66 -0
  659. package/dist/types/tools/json-tree.d.ts +23 -0
  660. package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
  661. package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
  662. package/dist/types/tools/jtd-utils.d.ts +42 -0
  663. package/dist/types/tools/list-limit.d.ts +12 -0
  664. package/dist/types/tools/match-line-format.d.ts +11 -0
  665. package/dist/types/tools/memory-edit.d.ts +40 -0
  666. package/dist/types/tools/memory-recall.d.ts +24 -0
  667. package/dist/types/tools/memory-reflect.d.ts +26 -0
  668. package/dist/types/tools/memory-render.d.ts +60 -0
  669. package/dist/types/tools/memory-retain.d.ts +30 -0
  670. package/dist/types/tools/output-meta.d.ts +204 -0
  671. package/dist/types/tools/output-schema-validator.d.ts +64 -0
  672. package/dist/types/tools/path-utils.d.ts +199 -0
  673. package/dist/types/tools/plan-mode-guard.d.ts +17 -0
  674. package/dist/types/tools/read.d.ts +86 -0
  675. package/dist/types/tools/render-mermaid.d.ts +38 -0
  676. package/dist/types/tools/render-utils.d.ts +185 -0
  677. package/dist/types/tools/renderers.d.ts +26 -0
  678. package/dist/types/tools/report-tool-issue.d.ts +123 -0
  679. package/dist/types/tools/resolve.d.ts +91 -0
  680. package/dist/types/tools/review.d.ts +63 -0
  681. package/dist/types/tools/search-tool-bm25.d.ts +66 -0
  682. package/dist/types/tools/search.d.ts +95 -0
  683. package/dist/types/tools/sqlite-reader.d.ts +110 -0
  684. package/dist/types/tools/ssh.d.ts +69 -0
  685. package/dist/types/tools/todo.d.ts +159 -0
  686. package/dist/types/tools/tool-errors.d.ts +33 -0
  687. package/dist/types/tools/tool-result.d.ts +32 -0
  688. package/dist/types/tools/tool-timeouts.d.ts +51 -0
  689. package/dist/types/tools/tts.d.ts +18 -0
  690. package/dist/types/tools/write.d.ts +65 -0
  691. package/dist/types/tools/yield.d.ts +26 -0
  692. package/dist/types/tui/code-cell.d.ts +40 -0
  693. package/dist/types/tui/file-list.d.ts +22 -0
  694. package/dist/types/tui/hyperlink.d.ts +54 -0
  695. package/dist/types/tui/index.d.ts +11 -0
  696. package/dist/types/tui/output-block.d.ts +57 -0
  697. package/dist/types/tui/status-line.d.ts +18 -0
  698. package/dist/types/tui/tree-list.d.ts +19 -0
  699. package/dist/types/tui/types.d.ts +13 -0
  700. package/dist/types/tui/utils.d.ts +36 -0
  701. package/dist/types/utils/changelog.d.ts +25 -0
  702. package/dist/types/utils/clipboard.d.ts +26 -0
  703. package/dist/types/utils/command-args.d.ts +9 -0
  704. package/dist/types/utils/commit-message-generator.d.ts +7 -0
  705. package/dist/types/utils/edit-mode.d.ts +13 -0
  706. package/dist/types/utils/event-bus.d.ts +6 -0
  707. package/dist/types/utils/external-editor.d.ts +17 -0
  708. package/dist/types/utils/file-display-mode.d.ts +27 -0
  709. package/dist/types/utils/file-mentions.d.ts +13 -0
  710. package/dist/types/utils/git.d.ts +361 -0
  711. package/dist/types/utils/image-loading.d.ts +26 -0
  712. package/dist/types/utils/image-resize.d.ts +39 -0
  713. package/dist/types/utils/jj.d.ts +49 -0
  714. package/dist/types/utils/lang-from-path.d.ts +8 -0
  715. package/dist/types/utils/markit.d.ts +7 -0
  716. package/dist/types/utils/open.d.ts +2 -0
  717. package/dist/types/utils/session-color.d.ts +15 -0
  718. package/dist/types/utils/shell-snapshot.d.ts +5 -0
  719. package/dist/types/utils/sixel.d.ts +21 -0
  720. package/dist/types/utils/title-generator.d.ts +34 -0
  721. package/dist/types/utils/tool-choice.d.ts +7 -0
  722. package/dist/types/utils/tools-manager.d.ts +9 -0
  723. package/dist/types/web/kagi.d.ts +99 -0
  724. package/dist/types/web/parallel.d.ts +58 -0
  725. package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
  726. package/dist/types/web/scrapers/arxiv.d.ts +5 -0
  727. package/dist/types/web/scrapers/aur.d.ts +5 -0
  728. package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
  729. package/dist/types/web/scrapers/bluesky.d.ts +5 -0
  730. package/dist/types/web/scrapers/brew.d.ts +5 -0
  731. package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
  732. package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
  733. package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
  734. package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
  735. package/dist/types/web/scrapers/clojars.d.ts +5 -0
  736. package/dist/types/web/scrapers/coingecko.d.ts +5 -0
  737. package/dist/types/web/scrapers/crates-io.d.ts +5 -0
  738. package/dist/types/web/scrapers/crossref.d.ts +2 -0
  739. package/dist/types/web/scrapers/devto.d.ts +5 -0
  740. package/dist/types/web/scrapers/discogs.d.ts +8 -0
  741. package/dist/types/web/scrapers/discourse.d.ts +5 -0
  742. package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
  743. package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
  744. package/dist/types/web/scrapers/fdroid.d.ts +5 -0
  745. package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
  746. package/dist/types/web/scrapers/flathub.d.ts +2 -0
  747. package/dist/types/web/scrapers/github-gist.d.ts +5 -0
  748. package/dist/types/web/scrapers/github.d.ts +12 -0
  749. package/dist/types/web/scrapers/gitlab.d.ts +5 -0
  750. package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
  751. package/dist/types/web/scrapers/hackage.d.ts +5 -0
  752. package/dist/types/web/scrapers/hackernews.d.ts +2 -0
  753. package/dist/types/web/scrapers/hex.d.ts +5 -0
  754. package/dist/types/web/scrapers/huggingface.d.ts +2 -0
  755. package/dist/types/web/scrapers/iacr.d.ts +5 -0
  756. package/dist/types/web/scrapers/index.d.ts +84 -0
  757. package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
  758. package/dist/types/web/scrapers/lemmy.d.ts +2 -0
  759. package/dist/types/web/scrapers/lobsters.d.ts +5 -0
  760. package/dist/types/web/scrapers/mastodon.d.ts +5 -0
  761. package/dist/types/web/scrapers/maven.d.ts +6 -0
  762. package/dist/types/web/scrapers/mdn.d.ts +2 -0
  763. package/dist/types/web/scrapers/metacpan.d.ts +5 -0
  764. package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
  765. package/dist/types/web/scrapers/npm.d.ts +5 -0
  766. package/dist/types/web/scrapers/nuget.d.ts +5 -0
  767. package/dist/types/web/scrapers/nvd.d.ts +5 -0
  768. package/dist/types/web/scrapers/ollama.d.ts +2 -0
  769. package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
  770. package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
  771. package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
  772. package/dist/types/web/scrapers/orcid.d.ts +5 -0
  773. package/dist/types/web/scrapers/osv.d.ts +5 -0
  774. package/dist/types/web/scrapers/packagist.d.ts +5 -0
  775. package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
  776. package/dist/types/web/scrapers/pubmed.d.ts +5 -0
  777. package/dist/types/web/scrapers/pypi.d.ts +5 -0
  778. package/dist/types/web/scrapers/rawg.d.ts +2 -0
  779. package/dist/types/web/scrapers/readthedocs.d.ts +2 -0
  780. package/dist/types/web/scrapers/reddit.d.ts +5 -0
  781. package/dist/types/web/scrapers/repology.d.ts +5 -0
  782. package/dist/types/web/scrapers/rfc.d.ts +5 -0
  783. package/dist/types/web/scrapers/rubygems.d.ts +5 -0
  784. package/dist/types/web/scrapers/searchcode.d.ts +2 -0
  785. package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
  786. package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
  787. package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
  788. package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
  789. package/dist/types/web/scrapers/spdx.d.ts +5 -0
  790. package/dist/types/web/scrapers/spotify.d.ts +8 -0
  791. package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
  792. package/dist/types/web/scrapers/terraform.d.ts +5 -0
  793. package/dist/types/web/scrapers/tldr.d.ts +7 -0
  794. package/dist/types/web/scrapers/twitter.d.ts +5 -0
  795. package/dist/types/web/scrapers/types.d.ts +78 -0
  796. package/dist/types/web/scrapers/utils.d.ts +26 -0
  797. package/dist/types/web/scrapers/vimeo.d.ts +5 -0
  798. package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
  799. package/dist/types/web/scrapers/w3c.d.ts +2 -0
  800. package/dist/types/web/scrapers/wikidata.d.ts +5 -0
  801. package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
  802. package/dist/types/web/scrapers/youtube.d.ts +5 -0
  803. package/dist/types/web/search/index.d.ts +85 -0
  804. package/dist/types/web/search/provider.d.ts +21 -0
  805. package/dist/types/web/search/providers/anthropic.d.ts +32 -0
  806. package/dist/types/web/search/providers/base.d.ts +81 -0
  807. package/dist/types/web/search/providers/brave.d.ts +27 -0
  808. package/dist/types/web/search/providers/codex.d.ts +35 -0
  809. package/dist/types/web/search/providers/exa.d.ts +67 -0
  810. package/dist/types/web/search/providers/gemini.d.ts +57 -0
  811. package/dist/types/web/search/providers/jina.d.ts +26 -0
  812. package/dist/types/web/search/providers/kagi.d.ts +25 -0
  813. package/dist/types/web/search/providers/kimi.d.ts +27 -0
  814. package/dist/types/web/search/providers/parallel.d.ts +15 -0
  815. package/dist/types/web/search/providers/perplexity.d.ts +38 -0
  816. package/dist/types/web/search/providers/searxng.d.ts +44 -0
  817. package/dist/types/web/search/providers/synthetic.d.ts +21 -0
  818. package/dist/types/web/search/providers/tavily.d.ts +29 -0
  819. package/dist/types/web/search/providers/utils.d.ts +52 -0
  820. package/dist/types/web/search/providers/zai.d.ts +28 -0
  821. package/dist/types/web/search/render.d.ts +34 -0
  822. package/dist/types/web/search/types.d.ts +409 -0
  823. package/dist/types/web/search/utils.d.ts +4 -0
  824. package/dist/types/workspace-tree.d.ts +42 -0
  825. package/examples/README.md +21 -0
  826. package/examples/custom-tools/README.md +104 -0
  827. package/examples/custom-tools/hello/index.ts +20 -0
  828. package/examples/extensions/README.md +142 -0
  829. package/examples/extensions/api-demo.ts +79 -0
  830. package/examples/extensions/chalk-logger.ts +25 -0
  831. package/examples/extensions/hello.ts +31 -0
  832. package/examples/extensions/pirate.ts +43 -0
  833. package/examples/extensions/plan-mode.ts +549 -0
  834. package/examples/extensions/reload-runtime.ts +38 -0
  835. package/examples/extensions/thinking-note.ts +13 -0
  836. package/examples/extensions/tools.ts +144 -0
  837. package/examples/extensions/with-deps/index.ts +36 -0
  838. package/examples/extensions/with-deps/package-lock.json +31 -0
  839. package/examples/extensions/with-deps/package.json +16 -0
  840. package/examples/hooks/README.md +56 -0
  841. package/examples/hooks/auto-commit-on-exit.ts +48 -0
  842. package/examples/hooks/confirm-destructive.ts +58 -0
  843. package/examples/hooks/custom-compaction.ts +116 -0
  844. package/examples/hooks/dirty-repo-guard.ts +51 -0
  845. package/examples/hooks/file-trigger.ts +40 -0
  846. package/examples/hooks/git-checkpoint.ts +52 -0
  847. package/examples/hooks/handoff.ts +150 -0
  848. package/examples/hooks/permission-gate.ts +33 -0
  849. package/examples/hooks/protected-paths.ts +29 -0
  850. package/examples/hooks/qna.ts +119 -0
  851. package/examples/hooks/status-line.ts +39 -0
  852. package/examples/sdk/01-minimal.ts +21 -0
  853. package/examples/sdk/02-custom-model.ts +50 -0
  854. package/examples/sdk/03-custom-prompt.ts +46 -0
  855. package/examples/sdk/04-skills.ts +43 -0
  856. package/examples/sdk/06-extensions.ts +82 -0
  857. package/examples/sdk/06-hooks.ts +61 -0
  858. package/examples/sdk/07-context-files.ts +35 -0
  859. package/examples/sdk/08-prompt-templates.ts +36 -0
  860. package/examples/sdk/08-slash-commands.ts +41 -0
  861. package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
  862. package/examples/sdk/11-sessions.ts +47 -0
  863. package/examples/sdk/12-redis-sessions.ts +54 -0
  864. package/examples/sdk/13-sql-sessions.ts +61 -0
  865. package/examples/sdk/README.md +172 -0
  866. package/package.json +548 -0
  867. package/scripts/build-binary.ts +105 -0
  868. package/scripts/format-prompts.ts +68 -0
  869. package/scripts/generate-docs-index.ts +40 -0
  870. package/scripts/generate-template.ts +33 -0
  871. package/src/async/index.ts +2 -0
  872. package/src/async/job-manager.ts +571 -0
  873. package/src/async/support.ts +5 -0
  874. package/src/auto-thinking/classifier.ts +180 -0
  875. package/src/autoresearch/command-resume.md +14 -0
  876. package/src/autoresearch/dashboard.ts +436 -0
  877. package/src/autoresearch/git.ts +319 -0
  878. package/src/autoresearch/helpers.ts +218 -0
  879. package/src/autoresearch/index.ts +536 -0
  880. package/src/autoresearch/prompt-setup.md +43 -0
  881. package/src/autoresearch/prompt.md +103 -0
  882. package/src/autoresearch/resume-message.md +10 -0
  883. package/src/autoresearch/state.ts +273 -0
  884. package/src/autoresearch/storage.ts +699 -0
  885. package/src/autoresearch/tools/init-experiment.ts +272 -0
  886. package/src/autoresearch/tools/log-experiment.ts +524 -0
  887. package/src/autoresearch/tools/run-experiment.ts +407 -0
  888. package/src/autoresearch/tools/update-notes.ts +109 -0
  889. package/src/autoresearch/types.ts +168 -0
  890. package/src/bun-imports.d.ts +28 -0
  891. package/src/capability/context-file.ts +58 -0
  892. package/src/capability/extension-module.ts +34 -0
  893. package/src/capability/extension.ts +47 -0
  894. package/src/capability/fs.ts +107 -0
  895. package/src/capability/hook.ts +40 -0
  896. package/src/capability/index.ts +441 -0
  897. package/src/capability/instruction.ts +37 -0
  898. package/src/capability/mcp.ts +74 -0
  899. package/src/capability/prompt.ts +35 -0
  900. package/src/capability/rule-buckets.ts +64 -0
  901. package/src/capability/rule.ts +252 -0
  902. package/src/capability/settings.ts +34 -0
  903. package/src/capability/skill.ts +63 -0
  904. package/src/capability/slash-command.ts +40 -0
  905. package/src/capability/ssh.ts +41 -0
  906. package/src/capability/system-prompt.ts +34 -0
  907. package/src/capability/tool.ts +38 -0
  908. package/src/capability/types.ts +172 -0
  909. package/src/cli/agents-cli.ts +138 -0
  910. package/src/cli/args.ts +335 -0
  911. package/src/cli/auth-broker-cli.ts +898 -0
  912. package/src/cli/auth-gateway-cli.ts +612 -0
  913. package/src/cli/classify-install-target.ts +76 -0
  914. package/src/cli/claude-trace-cli.ts +813 -0
  915. package/src/cli/commands/init-xdg.ts +27 -0
  916. package/src/cli/completion-gen.ts +550 -0
  917. package/src/cli/config-cli.ts +418 -0
  918. package/src/cli/dry-balance-cli.ts +823 -0
  919. package/src/cli/extension-flags.ts +48 -0
  920. package/src/cli/file-processor.ts +133 -0
  921. package/src/cli/gateway-cli.ts +664 -0
  922. package/src/cli/grep-cli.ts +160 -0
  923. package/src/cli/grievances-cli.ts +260 -0
  924. package/src/cli/initial-message.ts +58 -0
  925. package/src/cli/list-models.ts +194 -0
  926. package/src/cli/plugin-cli.ts +996 -0
  927. package/src/cli/read-cli.ts +57 -0
  928. package/src/cli/session-picker.ts +79 -0
  929. package/src/cli/setup-cli.ts +231 -0
  930. package/src/cli/shell-cli.ts +176 -0
  931. package/src/cli/ssh-cli.ts +181 -0
  932. package/src/cli/stats-cli.ts +238 -0
  933. package/src/cli/tiny-models-cli.ts +127 -0
  934. package/src/cli/update-cli.ts +739 -0
  935. package/src/cli/web-search-cli.ts +132 -0
  936. package/src/cli/worktree-cli.ts +291 -0
  937. package/src/cli-commands.ts +49 -0
  938. package/src/cli.ts +123 -0
  939. package/src/commands/acp.ts +24 -0
  940. package/src/commands/agents.ts +57 -0
  941. package/src/commands/auth-broker.ts +99 -0
  942. package/src/commands/auth-gateway.ts +69 -0
  943. package/src/commands/commit.ts +46 -0
  944. package/src/commands/complete.ts +66 -0
  945. package/src/commands/completions.ts +60 -0
  946. package/src/commands/config.ts +51 -0
  947. package/src/commands/dry-balance.ts +43 -0
  948. package/src/commands/gateway.ts +103 -0
  949. package/src/commands/grep.ts +48 -0
  950. package/src/commands/grievances.ts +51 -0
  951. package/src/commands/install.ts +107 -0
  952. package/src/commands/launch.ts +162 -0
  953. package/src/commands/plugin.ts +78 -0
  954. package/src/commands/read.ts +35 -0
  955. package/src/commands/setup.ts +67 -0
  956. package/src/commands/shell.ts +29 -0
  957. package/src/commands/ssh.ts +60 -0
  958. package/src/commands/stats.ts +29 -0
  959. package/src/commands/tiny-models.ts +36 -0
  960. package/src/commands/update.ts +21 -0
  961. package/src/commands/web-search.ts +42 -0
  962. package/src/commands/worktree.ts +56 -0
  963. package/src/commit/agentic/agent.ts +316 -0
  964. package/src/commit/agentic/fallback.ts +96 -0
  965. package/src/commit/agentic/index.ts +355 -0
  966. package/src/commit/agentic/prompts/analyze-file.md +22 -0
  967. package/src/commit/agentic/prompts/session-user.md +25 -0
  968. package/src/commit/agentic/prompts/split-confirm.md +1 -0
  969. package/src/commit/agentic/prompts/system.md +38 -0
  970. package/src/commit/agentic/state.ts +60 -0
  971. package/src/commit/agentic/tools/analyze-file.ts +127 -0
  972. package/src/commit/agentic/tools/git-file-diff.ts +191 -0
  973. package/src/commit/agentic/tools/git-hunk.ts +50 -0
  974. package/src/commit/agentic/tools/git-overview.ts +81 -0
  975. package/src/commit/agentic/tools/index.ts +54 -0
  976. package/src/commit/agentic/tools/propose-changelog.ts +144 -0
  977. package/src/commit/agentic/tools/propose-commit.ts +109 -0
  978. package/src/commit/agentic/tools/recent-commits.ts +81 -0
  979. package/src/commit/agentic/tools/schemas.ts +23 -0
  980. package/src/commit/agentic/tools/split-commit.ts +238 -0
  981. package/src/commit/agentic/topo-sort.ts +44 -0
  982. package/src/commit/agentic/trivial.ts +51 -0
  983. package/src/commit/agentic/validation.ts +183 -0
  984. package/src/commit/analysis/conventional.ts +64 -0
  985. package/src/commit/analysis/index.ts +4 -0
  986. package/src/commit/analysis/scope.ts +242 -0
  987. package/src/commit/analysis/summary.ts +105 -0
  988. package/src/commit/analysis/validation.ts +66 -0
  989. package/src/commit/changelog/detect.ts +40 -0
  990. package/src/commit/changelog/generate.ts +97 -0
  991. package/src/commit/changelog/index.ts +234 -0
  992. package/src/commit/changelog/parse.ts +44 -0
  993. package/src/commit/cli.ts +85 -0
  994. package/src/commit/git/diff.ts +148 -0
  995. package/src/commit/index.ts +5 -0
  996. package/src/commit/map-reduce/index.ts +69 -0
  997. package/src/commit/map-reduce/map-phase.ts +193 -0
  998. package/src/commit/map-reduce/reduce-phase.ts +49 -0
  999. package/src/commit/map-reduce/utils.ts +9 -0
  1000. package/src/commit/message.ts +11 -0
  1001. package/src/commit/model-selection.ts +66 -0
  1002. package/src/commit/pipeline.ts +243 -0
  1003. package/src/commit/prompts/analysis-system.md +148 -0
  1004. package/src/commit/prompts/analysis-user.md +38 -0
  1005. package/src/commit/prompts/changelog-system.md +50 -0
  1006. package/src/commit/prompts/changelog-user.md +18 -0
  1007. package/src/commit/prompts/file-observer-system.md +24 -0
  1008. package/src/commit/prompts/file-observer-user.md +8 -0
  1009. package/src/commit/prompts/reduce-system.md +50 -0
  1010. package/src/commit/prompts/reduce-user.md +17 -0
  1011. package/src/commit/prompts/summary-retry.md +3 -0
  1012. package/src/commit/prompts/summary-system.md +38 -0
  1013. package/src/commit/prompts/summary-user.md +13 -0
  1014. package/src/commit/prompts/types-description.md +2 -0
  1015. package/src/commit/shared-llm.ts +77 -0
  1016. package/src/commit/types.ts +118 -0
  1017. package/src/commit/utils/exclusions.ts +42 -0
  1018. package/src/commit/utils.ts +58 -0
  1019. package/src/config/append-only-context-mode.ts +37 -0
  1020. package/src/config/config-file.ts +317 -0
  1021. package/src/config/file-lock.ts +164 -0
  1022. package/src/config/keybindings.ts +623 -0
  1023. package/src/config/mcp-schema.json +230 -0
  1024. package/src/config/model-equivalence.ts +852 -0
  1025. package/src/config/model-id-affixes.ts +64 -0
  1026. package/src/config/model-registry.ts +2650 -0
  1027. package/src/config/model-resolver.ts +1402 -0
  1028. package/src/config/models-config-schema.ts +177 -0
  1029. package/src/config/prompt-templates.ts +185 -0
  1030. package/src/config/resolve-config-value.ts +94 -0
  1031. package/src/config/settings-schema.ts +3752 -0
  1032. package/src/config/settings.ts +1017 -0
  1033. package/src/config.ts +242 -0
  1034. package/src/cursor.ts +340 -0
  1035. package/src/dap/client.ts +675 -0
  1036. package/src/dap/config.ts +150 -0
  1037. package/src/dap/defaults.json +211 -0
  1038. package/src/dap/index.ts +4 -0
  1039. package/src/dap/session.ts +1339 -0
  1040. package/src/dap/types.ts +600 -0
  1041. package/src/debug/index.ts +525 -0
  1042. package/src/debug/log-formatting.ts +58 -0
  1043. package/src/debug/log-viewer.ts +908 -0
  1044. package/src/debug/profiler.ts +162 -0
  1045. package/src/debug/protocol-probe.ts +267 -0
  1046. package/src/debug/raw-sse-buffer.ts +270 -0
  1047. package/src/debug/raw-sse.ts +292 -0
  1048. package/src/debug/report-bundle.ts +365 -0
  1049. package/src/debug/system-info.ts +111 -0
  1050. package/src/debug/terminal-info.ts +127 -0
  1051. package/src/discovery/agents-md.ts +63 -0
  1052. package/src/discovery/agents.ts +236 -0
  1053. package/src/discovery/builtin-defaults.ts +39 -0
  1054. package/src/discovery/builtin-rules/index.ts +50 -0
  1055. package/src/discovery/builtin-rules/rs-box-leak.md +48 -0
  1056. package/src/discovery/builtin-rules/rs-future-prelude.md +23 -0
  1057. package/src/discovery/builtin-rules/rs-lazylock.md +51 -0
  1058. package/src/discovery/builtin-rules/rs-match-ergonomics.md +67 -0
  1059. package/src/discovery/builtin-rules/rs-parking-lot.md +44 -0
  1060. package/src/discovery/builtin-rules/rs-result-type.md +19 -0
  1061. package/src/discovery/builtin-rules/ts-bare-catch.md +38 -0
  1062. package/src/discovery/builtin-rules/ts-import-type.md +42 -0
  1063. package/src/discovery/builtin-rules/ts-no-any.md +56 -0
  1064. package/src/discovery/builtin-rules/ts-no-deprecated-leftovers.md +44 -0
  1065. package/src/discovery/builtin-rules/ts-no-dynamic-import.md +39 -0
  1066. package/src/discovery/builtin-rules/ts-no-return-type.md +45 -0
  1067. package/src/discovery/builtin-rules/ts-no-tiny-functions.md +51 -0
  1068. package/src/discovery/builtin-rules/ts-promise-with-resolvers.md +65 -0
  1069. package/src/discovery/builtin-rules/ts-set-map.md +28 -0
  1070. package/src/discovery/builtin.ts +906 -0
  1071. package/src/discovery/claude-plugins.ts +386 -0
  1072. package/src/discovery/claude.ts +584 -0
  1073. package/src/discovery/cline.ts +83 -0
  1074. package/src/discovery/codex.ts +522 -0
  1075. package/src/discovery/context-files.ts +49 -0
  1076. package/src/discovery/cursor.ts +220 -0
  1077. package/src/discovery/gemini.ts +383 -0
  1078. package/src/discovery/github.ts +154 -0
  1079. package/src/discovery/helpers.ts +1015 -0
  1080. package/src/discovery/index.ts +81 -0
  1081. package/src/discovery/mcp-json.ts +171 -0
  1082. package/src/discovery/opencode.ts +398 -0
  1083. package/src/discovery/plugin-dir-roots.ts +28 -0
  1084. package/src/discovery/prometheus-extension-roots.ts +190 -0
  1085. package/src/discovery/prometheus-plugins.ts +385 -0
  1086. package/src/discovery/ssh.ts +153 -0
  1087. package/src/discovery/substitute-plugin-root.ts +29 -0
  1088. package/src/discovery/vscode.ts +105 -0
  1089. package/src/discovery/windsurf.ts +147 -0
  1090. package/src/edit/apply-patch/index.ts +87 -0
  1091. package/src/edit/apply-patch/parser.ts +174 -0
  1092. package/src/edit/diff.ts +812 -0
  1093. package/src/edit/file-snapshot-store.ts +59 -0
  1094. package/src/edit/hashline/block-resolver.ts +14 -0
  1095. package/src/edit/hashline/diff.ts +169 -0
  1096. package/src/edit/hashline/execute.ts +187 -0
  1097. package/src/edit/hashline/filesystem.ts +129 -0
  1098. package/src/edit/hashline/index.ts +5 -0
  1099. package/src/edit/hashline/params.ts +18 -0
  1100. package/src/edit/index.ts +542 -0
  1101. package/src/edit/modes/apply-patch.lark +19 -0
  1102. package/src/edit/modes/apply-patch.ts +53 -0
  1103. package/src/edit/modes/patch.ts +1835 -0
  1104. package/src/edit/modes/replace.ts +1103 -0
  1105. package/src/edit/normalize.ts +345 -0
  1106. package/src/edit/notebook.ts +222 -0
  1107. package/src/edit/read-file.ts +25 -0
  1108. package/src/edit/renderer.ts +660 -0
  1109. package/src/edit/streaming.ts +517 -0
  1110. package/src/eval/__tests__/agent-bridge.test.ts +650 -0
  1111. package/src/eval/__tests__/bridge-timeout.test.ts +64 -0
  1112. package/src/eval/__tests__/budget-bridge.test.ts +69 -0
  1113. package/src/eval/__tests__/idle-timeout.test.ts +80 -0
  1114. package/src/eval/__tests__/kernel-spawn.test.ts +103 -0
  1115. package/src/eval/__tests__/llm-bridge.test.ts +327 -0
  1116. package/src/eval/__tests__/shared-executors.test.ts +609 -0
  1117. package/src/eval/agent-bridge.ts +303 -0
  1118. package/src/eval/backend.ts +58 -0
  1119. package/src/eval/bridge-timeout.ts +44 -0
  1120. package/src/eval/budget-bridge.ts +48 -0
  1121. package/src/eval/concurrency-bridge.ts +34 -0
  1122. package/src/eval/idle-timeout.ts +98 -0
  1123. package/src/eval/index.ts +4 -0
  1124. package/src/eval/js/context-manager.ts +425 -0
  1125. package/src/eval/js/executor.ts +166 -0
  1126. package/src/eval/js/index.ts +47 -0
  1127. package/src/eval/js/shared/helpers.ts +237 -0
  1128. package/src/eval/js/shared/indirect-eval.ts +30 -0
  1129. package/src/eval/js/shared/local-module-loader.ts +342 -0
  1130. package/src/eval/js/shared/prelude.ts +2 -0
  1131. package/src/eval/js/shared/prelude.txt +169 -0
  1132. package/src/eval/js/shared/rewrite-imports.ts +508 -0
  1133. package/src/eval/js/shared/runtime.ts +344 -0
  1134. package/src/eval/js/shared/types.ts +18 -0
  1135. package/src/eval/js/tool-bridge.ts +162 -0
  1136. package/src/eval/js/worker-core.ts +131 -0
  1137. package/src/eval/js/worker-entry.ts +24 -0
  1138. package/src/eval/js/worker-protocol.ts +41 -0
  1139. package/src/eval/llm-bridge.ts +186 -0
  1140. package/src/eval/py/display.ts +71 -0
  1141. package/src/eval/py/executor.ts +698 -0
  1142. package/src/eval/py/index.ts +59 -0
  1143. package/src/eval/py/kernel.ts +709 -0
  1144. package/src/eval/py/prelude.py +620 -0
  1145. package/src/eval/py/prelude.ts +3 -0
  1146. package/src/eval/py/runner.py +1028 -0
  1147. package/src/eval/py/runtime.ts +239 -0
  1148. package/src/eval/py/spawn-options.ts +126 -0
  1149. package/src/eval/py/tool-bridge.ts +182 -0
  1150. package/src/eval/session-id.ts +8 -0
  1151. package/src/eval/types.ts +48 -0
  1152. package/src/exa/factory.ts +60 -0
  1153. package/src/exa/index.ts +27 -0
  1154. package/src/exa/mcp-client.ts +370 -0
  1155. package/src/exa/render.ts +244 -0
  1156. package/src/exa/researcher.ts +36 -0
  1157. package/src/exa/search.ts +47 -0
  1158. package/src/exa/types.ts +166 -0
  1159. package/src/exa/websets.ts +248 -0
  1160. package/src/exec/bash-executor.ts +338 -0
  1161. package/src/exec/exec.ts +53 -0
  1162. package/src/exec/idle-timeout-watchdog.ts +126 -0
  1163. package/src/exec/non-interactive-env.ts +48 -0
  1164. package/src/export/custom-share.ts +65 -0
  1165. package/src/export/html/index.ts +164 -0
  1166. package/src/export/html/template.css +1051 -0
  1167. package/src/export/html/template.generated.ts +2 -0
  1168. package/src/export/html/template.html +46 -0
  1169. package/src/export/html/template.js +2244 -0
  1170. package/src/export/html/template.macro.ts +25 -0
  1171. package/src/export/html/vendor/highlight.min.js +1213 -0
  1172. package/src/export/html/vendor/marked.min.js +6 -0
  1173. package/src/export/ttsr.ts +462 -0
  1174. package/src/extensibility/custom-commands/bundled/ci-green/index.ts +54 -0
  1175. package/src/extensibility/custom-commands/bundled/review/index.ts +489 -0
  1176. package/src/extensibility/custom-commands/index.ts +2 -0
  1177. package/src/extensibility/custom-commands/loader.ts +238 -0
  1178. package/src/extensibility/custom-commands/types.ts +113 -0
  1179. package/src/extensibility/custom-tools/index.ts +7 -0
  1180. package/src/extensibility/custom-tools/loader.ts +240 -0
  1181. package/src/extensibility/custom-tools/types.ts +268 -0
  1182. package/src/extensibility/custom-tools/wrapper.ts +47 -0
  1183. package/src/extensibility/extensions/compact-handler.ts +40 -0
  1184. package/src/extensibility/extensions/get-commands-handler.ts +77 -0
  1185. package/src/extensibility/extensions/index.ts +15 -0
  1186. package/src/extensibility/extensions/loader.ts +552 -0
  1187. package/src/extensibility/extensions/runner.ts +917 -0
  1188. package/src/extensibility/extensions/types.ts +1303 -0
  1189. package/src/extensibility/extensions/wrapper.ts +223 -0
  1190. package/src/extensibility/hooks/index.ts +5 -0
  1191. package/src/extensibility/hooks/loader.ts +257 -0
  1192. package/src/extensibility/hooks/runner.ts +425 -0
  1193. package/src/extensibility/hooks/tool-wrapper.ts +107 -0
  1194. package/src/extensibility/hooks/types.ts +606 -0
  1195. package/src/extensibility/legacy-pi-ai-shim.ts +24 -0
  1196. package/src/extensibility/legacy-pi-coding-agent-shim.ts +15 -0
  1197. package/src/extensibility/plugins/doctor.ts +66 -0
  1198. package/src/extensibility/plugins/git-url.ts +367 -0
  1199. package/src/extensibility/plugins/index.ts +9 -0
  1200. package/src/extensibility/plugins/installer.ts +192 -0
  1201. package/src/extensibility/plugins/legacy-pi-compat.ts +661 -0
  1202. package/src/extensibility/plugins/loader.ts +313 -0
  1203. package/src/extensibility/plugins/manager.ts +827 -0
  1204. package/src/extensibility/plugins/marketplace/cache.ts +136 -0
  1205. package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
  1206. package/src/extensibility/plugins/marketplace/index.ts +6 -0
  1207. package/src/extensibility/plugins/marketplace/manager.ts +770 -0
  1208. package/src/extensibility/plugins/marketplace/registry.ts +196 -0
  1209. package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
  1210. package/src/extensibility/plugins/marketplace/types.ts +191 -0
  1211. package/src/extensibility/plugins/parser.ts +105 -0
  1212. package/src/extensibility/plugins/types.ts +194 -0
  1213. package/src/extensibility/shared-events.ts +343 -0
  1214. package/src/extensibility/skills.ts +312 -0
  1215. package/src/extensibility/slash-commands.ts +227 -0
  1216. package/src/extensibility/tool-proxy.ts +25 -0
  1217. package/src/extensibility/typebox.ts +418 -0
  1218. package/src/extensibility/utils.ts +44 -0
  1219. package/src/gateway/adapters/telegram/access.ts +53 -0
  1220. package/src/gateway/adapters/telegram/commands.ts +206 -0
  1221. package/src/gateway/adapters/telegram/expressions.ts +678 -0
  1222. package/src/gateway/adapters/telegram/media.ts +831 -0
  1223. package/src/gateway/adapters/telegram/native-command-policy.ts +83 -0
  1224. package/src/gateway/adapters/telegram/native-commands.ts +197 -0
  1225. package/src/gateway/adapters/telegram/normalize.ts +593 -0
  1226. package/src/gateway/adapters/telegram/send-message.ts +1465 -0
  1227. package/src/gateway/adapters/telegram/service.ts +577 -0
  1228. package/src/gateway/adapters/telegram/setup-api.ts +196 -0
  1229. package/src/gateway/adapters/telegram/setup-config.ts +72 -0
  1230. package/src/gateway/adapters/telegram/types.ts +206 -0
  1231. package/src/gateway/adapters/telegram/webhook.ts +364 -0
  1232. package/src/gateway/commands.ts +196 -0
  1233. package/src/gateway/context.ts +276 -0
  1234. package/src/gateway/native-slash-policy.ts +19 -0
  1235. package/src/gateway/prometheus-dispatch.ts +362 -0
  1236. package/src/gateway/router.ts +123 -0
  1237. package/src/gateway/session-key.ts +55 -0
  1238. package/src/gateway/types.ts +119 -0
  1239. package/src/goals/index.ts +3 -0
  1240. package/src/goals/runtime.ts +528 -0
  1241. package/src/goals/state.ts +37 -0
  1242. package/src/goals/tools/goal-tool.ts +241 -0
  1243. package/src/hindsight/backend.ts +354 -0
  1244. package/src/hindsight/bank.ts +141 -0
  1245. package/src/hindsight/client.ts +598 -0
  1246. package/src/hindsight/config.ts +175 -0
  1247. package/src/hindsight/content.ts +210 -0
  1248. package/src/hindsight/index.ts +8 -0
  1249. package/src/hindsight/mental-models.ts +382 -0
  1250. package/src/hindsight/seeds.json +32 -0
  1251. package/src/hindsight/state.ts +483 -0
  1252. package/src/hindsight/transcript.ts +71 -0
  1253. package/src/index.ts +59 -0
  1254. package/src/internal-urls/agent-protocol.ts +146 -0
  1255. package/src/internal-urls/artifact-protocol.ts +98 -0
  1256. package/src/internal-urls/docs-index.generated.ts +107 -0
  1257. package/src/internal-urls/index.ts +24 -0
  1258. package/src/internal-urls/issue-pr-protocol.ts +577 -0
  1259. package/src/internal-urls/json-query.ts +126 -0
  1260. package/src/internal-urls/local-protocol.ts +274 -0
  1261. package/src/internal-urls/mcp-protocol.ts +151 -0
  1262. package/src/internal-urls/memory-protocol.ts +196 -0
  1263. package/src/internal-urls/parse.ts +72 -0
  1264. package/src/internal-urls/prometheus-protocol.ts +93 -0
  1265. package/src/internal-urls/registry-helpers.ts +25 -0
  1266. package/src/internal-urls/router.ts +103 -0
  1267. package/src/internal-urls/rule-protocol.ts +45 -0
  1268. package/src/internal-urls/skill-protocol.ts +96 -0
  1269. package/src/internal-urls/types.ts +152 -0
  1270. package/src/internal-urls/vault-protocol.ts +936 -0
  1271. package/src/lib/xai-http.ts +124 -0
  1272. package/src/lsp/client.ts +1052 -0
  1273. package/src/lsp/clients/biome-client.ts +202 -0
  1274. package/src/lsp/clients/index.ts +50 -0
  1275. package/src/lsp/clients/lsp-linter-client.ts +93 -0
  1276. package/src/lsp/clients/swiftlint-client.ts +120 -0
  1277. package/src/lsp/config.ts +492 -0
  1278. package/src/lsp/defaults.json +493 -0
  1279. package/src/lsp/diagnostics-ledger.ts +51 -0
  1280. package/src/lsp/edits.ts +219 -0
  1281. package/src/lsp/index.ts +2340 -0
  1282. package/src/lsp/lspmux.ts +233 -0
  1283. package/src/lsp/render.ts +692 -0
  1284. package/src/lsp/startup-events.ts +13 -0
  1285. package/src/lsp/types.ts +443 -0
  1286. package/src/lsp/utils.ts +699 -0
  1287. package/src/main.ts +1167 -0
  1288. package/src/mcp/client.ts +484 -0
  1289. package/src/mcp/config-writer.ts +225 -0
  1290. package/src/mcp/config.ts +365 -0
  1291. package/src/mcp/index.ts +29 -0
  1292. package/src/mcp/json-rpc.ts +92 -0
  1293. package/src/mcp/loader.ts +124 -0
  1294. package/src/mcp/manager.ts +1274 -0
  1295. package/src/mcp/oauth-discovery.ts +437 -0
  1296. package/src/mcp/oauth-flow.ts +435 -0
  1297. package/src/mcp/render.ts +126 -0
  1298. package/src/mcp/smithery-auth.ts +104 -0
  1299. package/src/mcp/smithery-connect.ts +145 -0
  1300. package/src/mcp/smithery-registry.ts +477 -0
  1301. package/src/mcp/timeout.ts +59 -0
  1302. package/src/mcp/tool-bridge.ts +424 -0
  1303. package/src/mcp/tool-cache.ts +117 -0
  1304. package/src/mcp/transports/http.ts +519 -0
  1305. package/src/mcp/transports/index.ts +6 -0
  1306. package/src/mcp/transports/stdio.ts +386 -0
  1307. package/src/mcp/types.ts +423 -0
  1308. package/src/memories/index.ts +2227 -0
  1309. package/src/memories/storage.ts +617 -0
  1310. package/src/memory-backend/index.ts +5 -0
  1311. package/src/memory-backend/local-backend.ts +30 -0
  1312. package/src/memory-backend/off-backend.ts +16 -0
  1313. package/src/memory-backend/resolve.ts +27 -0
  1314. package/src/memory-backend/types.ts +86 -0
  1315. package/src/mnemopi/backend.ts +374 -0
  1316. package/src/mnemopi/config.ts +160 -0
  1317. package/src/mnemopi/index.ts +3 -0
  1318. package/src/mnemopi/state.ts +549 -0
  1319. package/src/modes/acp/acp-agent.ts +2292 -0
  1320. package/src/modes/acp/acp-client-bridge.ts +154 -0
  1321. package/src/modes/acp/acp-event-mapper.ts +929 -0
  1322. package/src/modes/acp/acp-mode.ts +23 -0
  1323. package/src/modes/acp/index.ts +2 -0
  1324. package/src/modes/acp/terminal-auth.ts +37 -0
  1325. package/src/modes/components/agent-dashboard.ts +1201 -0
  1326. package/src/modes/components/assistant-message.ts +309 -0
  1327. package/src/modes/components/bash-execution.ts +220 -0
  1328. package/src/modes/components/bordered-loader.ts +41 -0
  1329. package/src/modes/components/branch-summary-message.ts +45 -0
  1330. package/src/modes/components/btw-panel.ts +104 -0
  1331. package/src/modes/components/compaction-summary-message.ts +51 -0
  1332. package/src/modes/components/copy-selector.ts +249 -0
  1333. package/src/modes/components/countdown-timer.ts +75 -0
  1334. package/src/modes/components/custom-editor.ts +267 -0
  1335. package/src/modes/components/custom-message.ts +65 -0
  1336. package/src/modes/components/diff.ts +266 -0
  1337. package/src/modes/components/dynamic-border.ts +25 -0
  1338. package/src/modes/components/error-banner.ts +33 -0
  1339. package/src/modes/components/eval-execution.ts +158 -0
  1340. package/src/modes/components/execution-shared.ts +102 -0
  1341. package/src/modes/components/extensions/extension-dashboard.ts +396 -0
  1342. package/src/modes/components/extensions/extension-list.ts +502 -0
  1343. package/src/modes/components/extensions/index.ts +9 -0
  1344. package/src/modes/components/extensions/inspector-panel.ts +317 -0
  1345. package/src/modes/components/extensions/state-manager.ts +632 -0
  1346. package/src/modes/components/extensions/types.ts +186 -0
  1347. package/src/modes/components/footer.ts +272 -0
  1348. package/src/modes/components/history-search.ts +280 -0
  1349. package/src/modes/components/hook-editor.ts +159 -0
  1350. package/src/modes/components/hook-input.ts +79 -0
  1351. package/src/modes/components/hook-message.ts +68 -0
  1352. package/src/modes/components/hook-selector.ts +660 -0
  1353. package/src/modes/components/index.ts +38 -0
  1354. package/src/modes/components/keybinding-hints.ts +65 -0
  1355. package/src/modes/components/login-dialog.ts +164 -0
  1356. package/src/modes/components/mcp-add-wizard.ts +1340 -0
  1357. package/src/modes/components/message-frame.ts +88 -0
  1358. package/src/modes/components/model-selector.ts +1213 -0
  1359. package/src/modes/components/oauth-selector.ts +342 -0
  1360. package/src/modes/components/omfg-panel.ts +141 -0
  1361. package/src/modes/components/plugin-selector.ts +95 -0
  1362. package/src/modes/components/plugin-settings.ts +728 -0
  1363. package/src/modes/components/queue-mode-selector.ts +56 -0
  1364. package/src/modes/components/read-tool-group.ts +267 -0
  1365. package/src/modes/components/segment-track.ts +52 -0
  1366. package/src/modes/components/session-observer-overlay.ts +852 -0
  1367. package/src/modes/components/session-selector.ts +571 -0
  1368. package/src/modes/components/settings-defs.ts +189 -0
  1369. package/src/modes/components/settings-selector.ts +647 -0
  1370. package/src/modes/components/show-images-selector.ts +45 -0
  1371. package/src/modes/components/skill-message.ts +90 -0
  1372. package/src/modes/components/status-line/context-thresholds.ts +79 -0
  1373. package/src/modes/components/status-line/git-utils.ts +42 -0
  1374. package/src/modes/components/status-line/index.ts +4 -0
  1375. package/src/modes/components/status-line/presets.ts +106 -0
  1376. package/src/modes/components/status-line/segments.ts +590 -0
  1377. package/src/modes/components/status-line/separators.ts +55 -0
  1378. package/src/modes/components/status-line/token-rate.ts +66 -0
  1379. package/src/modes/components/status-line/types.ts +93 -0
  1380. package/src/modes/components/status-line.ts +794 -0
  1381. package/src/modes/components/theme-selector.ts +63 -0
  1382. package/src/modes/components/thinking-selector.ts +52 -0
  1383. package/src/modes/components/tiny-title-download-progress.ts +90 -0
  1384. package/src/modes/components/tips.txt +18 -0
  1385. package/src/modes/components/todo-reminder.ts +40 -0
  1386. package/src/modes/components/tool-execution.ts +1017 -0
  1387. package/src/modes/components/transcript-container.ts +181 -0
  1388. package/src/modes/components/tree-selector.ts +978 -0
  1389. package/src/modes/components/ttsr-notification.ts +80 -0
  1390. package/src/modes/components/user-message-selector.ts +227 -0
  1391. package/src/modes/components/user-message.ts +52 -0
  1392. package/src/modes/components/visual-truncate.ts +63 -0
  1393. package/src/modes/components/welcome.ts +435 -0
  1394. package/src/modes/controllers/btw-controller.ts +105 -0
  1395. package/src/modes/controllers/command-controller-shared.ts +108 -0
  1396. package/src/modes/controllers/command-controller.ts +1546 -0
  1397. package/src/modes/controllers/event-controller.ts +926 -0
  1398. package/src/modes/controllers/extension-ui-controller.ts +933 -0
  1399. package/src/modes/controllers/input-controller.ts +947 -0
  1400. package/src/modes/controllers/mcp-command-controller.ts +1938 -0
  1401. package/src/modes/controllers/omfg-controller.ts +283 -0
  1402. package/src/modes/controllers/omfg-rule.ts +647 -0
  1403. package/src/modes/controllers/selector-controller.ts +1117 -0
  1404. package/src/modes/controllers/ssh-command-controller.ts +384 -0
  1405. package/src/modes/controllers/todo-command-controller.ts +485 -0
  1406. package/src/modes/data/emojis.json +1 -0
  1407. package/src/modes/emoji-autocomplete.ts +285 -0
  1408. package/src/modes/gradient-highlight.ts +87 -0
  1409. package/src/modes/image-references.ts +111 -0
  1410. package/src/modes/index.ts +34 -0
  1411. package/src/modes/interactive-mode.ts +3151 -0
  1412. package/src/modes/internal-url-autocomplete.ts +143 -0
  1413. package/src/modes/loop-limit.ts +140 -0
  1414. package/src/modes/magic-keywords.ts +20 -0
  1415. package/src/modes/markdown-prose.ts +247 -0
  1416. package/src/modes/oauth-manual-input.ts +42 -0
  1417. package/src/modes/orchestrate.ts +42 -0
  1418. package/src/modes/print-mode.ts +126 -0
  1419. package/src/modes/prompt-action-autocomplete.ts +260 -0
  1420. package/src/modes/rpc/host-tools.ts +186 -0
  1421. package/src/modes/rpc/host-uris.ts +235 -0
  1422. package/src/modes/rpc/rpc-client.ts +812 -0
  1423. package/src/modes/rpc/rpc-mode.ts +862 -0
  1424. package/src/modes/rpc/rpc-types.ts +378 -0
  1425. package/src/modes/runtime-init.ts +116 -0
  1426. package/src/modes/session-observer-registry.ts +146 -0
  1427. package/src/modes/setup-wizard/index.ts +88 -0
  1428. package/src/modes/setup-wizard/scenes/channels.ts +104 -0
  1429. package/src/modes/setup-wizard/scenes/glyph.ts +96 -0
  1430. package/src/modes/setup-wizard/scenes/outro.ts +35 -0
  1431. package/src/modes/setup-wizard/scenes/providers.ts +70 -0
  1432. package/src/modes/setup-wizard/scenes/sign-in.ts +213 -0
  1433. package/src/modes/setup-wizard/scenes/splash.ts +201 -0
  1434. package/src/modes/setup-wizard/scenes/telegram.ts +695 -0
  1435. package/src/modes/setup-wizard/scenes/theme.ts +299 -0
  1436. package/src/modes/setup-wizard/scenes/types.ts +48 -0
  1437. package/src/modes/setup-wizard/scenes/web-search.ts +128 -0
  1438. package/src/modes/setup-wizard/wizard-overlay.ts +275 -0
  1439. package/src/modes/shared.ts +47 -0
  1440. package/src/modes/theme/dark.json +95 -0
  1441. package/src/modes/theme/defaults/alabaster.json +93 -0
  1442. package/src/modes/theme/defaults/amethyst.json +96 -0
  1443. package/src/modes/theme/defaults/anthracite.json +93 -0
  1444. package/src/modes/theme/defaults/basalt.json +91 -0
  1445. package/src/modes/theme/defaults/birch.json +95 -0
  1446. package/src/modes/theme/defaults/dark-abyss.json +91 -0
  1447. package/src/modes/theme/defaults/dark-arctic.json +104 -0
  1448. package/src/modes/theme/defaults/dark-aurora.json +95 -0
  1449. package/src/modes/theme/defaults/dark-catppuccin.json +107 -0
  1450. package/src/modes/theme/defaults/dark-cavern.json +91 -0
  1451. package/src/modes/theme/defaults/dark-copper.json +95 -0
  1452. package/src/modes/theme/defaults/dark-cosmos.json +90 -0
  1453. package/src/modes/theme/defaults/dark-cyberpunk.json +102 -0
  1454. package/src/modes/theme/defaults/dark-dracula.json +98 -0
  1455. package/src/modes/theme/defaults/dark-eclipse.json +91 -0
  1456. package/src/modes/theme/defaults/dark-ember.json +95 -0
  1457. package/src/modes/theme/defaults/dark-equinox.json +90 -0
  1458. package/src/modes/theme/defaults/dark-forest.json +96 -0
  1459. package/src/modes/theme/defaults/dark-github.json +105 -0
  1460. package/src/modes/theme/defaults/dark-gruvbox.json +112 -0
  1461. package/src/modes/theme/defaults/dark-lavender.json +95 -0
  1462. package/src/modes/theme/defaults/dark-lunar.json +89 -0
  1463. package/src/modes/theme/defaults/dark-midnight.json +95 -0
  1464. package/src/modes/theme/defaults/dark-monochrome.json +94 -0
  1465. package/src/modes/theme/defaults/dark-monokai.json +98 -0
  1466. package/src/modes/theme/defaults/dark-nebula.json +90 -0
  1467. package/src/modes/theme/defaults/dark-nord.json +97 -0
  1468. package/src/modes/theme/defaults/dark-ocean.json +101 -0
  1469. package/src/modes/theme/defaults/dark-one.json +100 -0
  1470. package/src/modes/theme/defaults/dark-poimandres.json +142 -0
  1471. package/src/modes/theme/defaults/dark-rainforest.json +91 -0
  1472. package/src/modes/theme/defaults/dark-reef.json +91 -0
  1473. package/src/modes/theme/defaults/dark-retro.json +92 -0
  1474. package/src/modes/theme/defaults/dark-rose-pine.json +96 -0
  1475. package/src/modes/theme/defaults/dark-sakura.json +95 -0
  1476. package/src/modes/theme/defaults/dark-slate.json +95 -0
  1477. package/src/modes/theme/defaults/dark-solarized.json +97 -0
  1478. package/src/modes/theme/defaults/dark-solstice.json +90 -0
  1479. package/src/modes/theme/defaults/dark-starfall.json +91 -0
  1480. package/src/modes/theme/defaults/dark-sunset.json +99 -0
  1481. package/src/modes/theme/defaults/dark-swamp.json +90 -0
  1482. package/src/modes/theme/defaults/dark-synthwave.json +103 -0
  1483. package/src/modes/theme/defaults/dark-taiga.json +91 -0
  1484. package/src/modes/theme/defaults/dark-terminal.json +95 -0
  1485. package/src/modes/theme/defaults/dark-tokyo-night.json +101 -0
  1486. package/src/modes/theme/defaults/dark-tundra.json +91 -0
  1487. package/src/modes/theme/defaults/dark-twilight.json +91 -0
  1488. package/src/modes/theme/defaults/dark-volcanic.json +91 -0
  1489. package/src/modes/theme/defaults/graphite.json +92 -0
  1490. package/src/modes/theme/defaults/index.ts +199 -0
  1491. package/src/modes/theme/defaults/light-arctic.json +107 -0
  1492. package/src/modes/theme/defaults/light-aurora-day.json +91 -0
  1493. package/src/modes/theme/defaults/light-canyon.json +91 -0
  1494. package/src/modes/theme/defaults/light-catppuccin.json +106 -0
  1495. package/src/modes/theme/defaults/light-cirrus.json +90 -0
  1496. package/src/modes/theme/defaults/light-coral.json +95 -0
  1497. package/src/modes/theme/defaults/light-cyberpunk.json +96 -0
  1498. package/src/modes/theme/defaults/light-dawn.json +90 -0
  1499. package/src/modes/theme/defaults/light-dunes.json +91 -0
  1500. package/src/modes/theme/defaults/light-eucalyptus.json +95 -0
  1501. package/src/modes/theme/defaults/light-forest.json +100 -0
  1502. package/src/modes/theme/defaults/light-frost.json +95 -0
  1503. package/src/modes/theme/defaults/light-github.json +115 -0
  1504. package/src/modes/theme/defaults/light-glacier.json +91 -0
  1505. package/src/modes/theme/defaults/light-gruvbox.json +108 -0
  1506. package/src/modes/theme/defaults/light-haze.json +90 -0
  1507. package/src/modes/theme/defaults/light-honeycomb.json +95 -0
  1508. package/src/modes/theme/defaults/light-lagoon.json +91 -0
  1509. package/src/modes/theme/defaults/light-lavender.json +95 -0
  1510. package/src/modes/theme/defaults/light-meadow.json +91 -0
  1511. package/src/modes/theme/defaults/light-mint.json +95 -0
  1512. package/src/modes/theme/defaults/light-monochrome.json +101 -0
  1513. package/src/modes/theme/defaults/light-ocean.json +99 -0
  1514. package/src/modes/theme/defaults/light-one.json +99 -0
  1515. package/src/modes/theme/defaults/light-opal.json +91 -0
  1516. package/src/modes/theme/defaults/light-orchard.json +91 -0
  1517. package/src/modes/theme/defaults/light-paper.json +95 -0
  1518. package/src/modes/theme/defaults/light-poimandres.json +142 -0
  1519. package/src/modes/theme/defaults/light-prism.json +90 -0
  1520. package/src/modes/theme/defaults/light-retro.json +98 -0
  1521. package/src/modes/theme/defaults/light-sand.json +95 -0
  1522. package/src/modes/theme/defaults/light-savanna.json +91 -0
  1523. package/src/modes/theme/defaults/light-solarized.json +102 -0
  1524. package/src/modes/theme/defaults/light-soleil.json +90 -0
  1525. package/src/modes/theme/defaults/light-sunset.json +99 -0
  1526. package/src/modes/theme/defaults/light-synthwave.json +98 -0
  1527. package/src/modes/theme/defaults/light-tokyo-night.json +111 -0
  1528. package/src/modes/theme/defaults/light-wetland.json +91 -0
  1529. package/src/modes/theme/defaults/light-zenith.json +89 -0
  1530. package/src/modes/theme/defaults/limestone.json +94 -0
  1531. package/src/modes/theme/defaults/mahogany.json +97 -0
  1532. package/src/modes/theme/defaults/marble.json +93 -0
  1533. package/src/modes/theme/defaults/obsidian.json +91 -0
  1534. package/src/modes/theme/defaults/onyx.json +91 -0
  1535. package/src/modes/theme/defaults/pearl.json +93 -0
  1536. package/src/modes/theme/defaults/porcelain.json +91 -0
  1537. package/src/modes/theme/defaults/quartz.json +96 -0
  1538. package/src/modes/theme/defaults/sandstone.json +95 -0
  1539. package/src/modes/theme/defaults/titanium.json +90 -0
  1540. package/src/modes/theme/light.json +93 -0
  1541. package/src/modes/theme/mermaid-cache.ts +29 -0
  1542. package/src/modes/theme/shimmer.ts +224 -0
  1543. package/src/modes/theme/theme-schema.json +459 -0
  1544. package/src/modes/theme/theme.ts +2569 -0
  1545. package/src/modes/turn-budget.ts +31 -0
  1546. package/src/modes/types.ts +338 -0
  1547. package/src/modes/ultrathink.ts +41 -0
  1548. package/src/modes/utils/context-usage.ts +335 -0
  1549. package/src/modes/utils/copy-targets.ts +254 -0
  1550. package/src/modes/utils/hotkeys-markdown.ts +60 -0
  1551. package/src/modes/utils/keybinding-matchers.ts +51 -0
  1552. package/src/modes/utils/tools-markdown.ts +27 -0
  1553. package/src/modes/utils/ui-helpers.ts +772 -0
  1554. package/src/modes/workflow.ts +42 -0
  1555. package/src/plan-mode/approved-plan.ts +163 -0
  1556. package/src/plan-mode/plan-handoff.ts +37 -0
  1557. package/src/plan-mode/plan-protection.ts +31 -0
  1558. package/src/plan-mode/state.ts +6 -0
  1559. package/src/priority.json +41 -0
  1560. package/src/prompts/agents/designer.md +66 -0
  1561. package/src/prompts/agents/explore.md +58 -0
  1562. package/src/prompts/agents/frontmatter.md +11 -0
  1563. package/src/prompts/agents/init.md +33 -0
  1564. package/src/prompts/agents/librarian.md +120 -0
  1565. package/src/prompts/agents/oracle.md +55 -0
  1566. package/src/prompts/agents/plan.md +48 -0
  1567. package/src/prompts/agents/reviewer.md +140 -0
  1568. package/src/prompts/agents/task.md +16 -0
  1569. package/src/prompts/ci-green-request.md +38 -0
  1570. package/src/prompts/dry-balance-bench.md +8 -0
  1571. package/src/prompts/goals/goal-budget-limit.md +16 -0
  1572. package/src/prompts/goals/goal-continuation.md +28 -0
  1573. package/src/prompts/goals/goal-mode-active.md +23 -0
  1574. package/src/prompts/memories/consolidation.md +35 -0
  1575. package/src/prompts/memories/identity_review.md +38 -0
  1576. package/src/prompts/memories/post_turn_review.md +37 -0
  1577. package/src/prompts/memories/read-path.md +16 -0
  1578. package/src/prompts/memories/stage_one_input.md +6 -0
  1579. package/src/prompts/memories/stage_one_system.md +21 -0
  1580. package/src/prompts/review-custom-request.md +22 -0
  1581. package/src/prompts/review-headless-request.md +16 -0
  1582. package/src/prompts/review-request.md +69 -0
  1583. package/src/prompts/steering/user-interjection.md +10 -0
  1584. package/src/prompts/system/agent-creation-architect.md +50 -0
  1585. package/src/prompts/system/agent-creation-user.md +6 -0
  1586. package/src/prompts/system/auto-continue.md +1 -0
  1587. package/src/prompts/system/auto-thinking-difficulty-local.md +14 -0
  1588. package/src/prompts/system/auto-thinking-difficulty.md +12 -0
  1589. package/src/prompts/system/btw-user.md +8 -0
  1590. package/src/prompts/system/commit-message-system.md +2 -0
  1591. package/src/prompts/system/custom-system-prompt.md +64 -0
  1592. package/src/prompts/system/eager-todo.md +13 -0
  1593. package/src/prompts/system/empty-stop-retry.md +6 -0
  1594. package/src/prompts/system/irc-incoming.md +8 -0
  1595. package/src/prompts/system/memory-consolidation-system.md +8 -0
  1596. package/src/prompts/system/memory-extraction-system.md +26 -0
  1597. package/src/prompts/system/omfg-user.md +51 -0
  1598. package/src/prompts/system/orchestrate-notice.md +40 -0
  1599. package/src/prompts/system/plan-mode-active.md +116 -0
  1600. package/src/prompts/system/plan-mode-approved.md +25 -0
  1601. package/src/prompts/system/plan-mode-compact-instructions.md +16 -0
  1602. package/src/prompts/system/plan-mode-reference.md +11 -0
  1603. package/src/prompts/system/plan-mode-subagent.md +34 -0
  1604. package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
  1605. package/src/prompts/system/project-prompt.md +52 -0
  1606. package/src/prompts/system/subagent-system-prompt.md +69 -0
  1607. package/src/prompts/system/subagent-user-prompt.md +3 -0
  1608. package/src/prompts/system/subagent-yield-reminder.md +12 -0
  1609. package/src/prompts/system/system-prompt.md +275 -0
  1610. package/src/prompts/system/tiny-title-system.md +8 -0
  1611. package/src/prompts/system/title-system.md +3 -0
  1612. package/src/prompts/system/ttsr-interrupt.md +7 -0
  1613. package/src/prompts/system/ttsr-tool-reminder.md +5 -0
  1614. package/src/prompts/system/ultrathink-notice.md +3 -0
  1615. package/src/prompts/system/web-search.md +25 -0
  1616. package/src/prompts/system/workflow-notice.md +70 -0
  1617. package/src/prompts/tools/apply-patch.md +65 -0
  1618. package/src/prompts/tools/ask.md +30 -0
  1619. package/src/prompts/tools/ast-edit.md +39 -0
  1620. package/src/prompts/tools/ast-grep.md +42 -0
  1621. package/src/prompts/tools/async-result.md +8 -0
  1622. package/src/prompts/tools/bash.md +39 -0
  1623. package/src/prompts/tools/browser.md +73 -0
  1624. package/src/prompts/tools/checkpoint.md +16 -0
  1625. package/src/prompts/tools/debug.md +34 -0
  1626. package/src/prompts/tools/eval.md +89 -0
  1627. package/src/prompts/tools/find.md +37 -0
  1628. package/src/prompts/tools/github.md +20 -0
  1629. package/src/prompts/tools/goal.md +18 -0
  1630. package/src/prompts/tools/image-gen.md +7 -0
  1631. package/src/prompts/tools/inspect-image-system.md +20 -0
  1632. package/src/prompts/tools/inspect-image.md +32 -0
  1633. package/src/prompts/tools/irc.md +49 -0
  1634. package/src/prompts/tools/job.md +19 -0
  1635. package/src/prompts/tools/lsp.md +42 -0
  1636. package/src/prompts/tools/memory-edit.md +8 -0
  1637. package/src/prompts/tools/patch.md +70 -0
  1638. package/src/prompts/tools/read.md +86 -0
  1639. package/src/prompts/tools/recall.md +5 -0
  1640. package/src/prompts/tools/reflect.md +5 -0
  1641. package/src/prompts/tools/render-mermaid.md +9 -0
  1642. package/src/prompts/tools/replace.md +36 -0
  1643. package/src/prompts/tools/resolve.md +9 -0
  1644. package/src/prompts/tools/retain.md +6 -0
  1645. package/src/prompts/tools/rewind.md +13 -0
  1646. package/src/prompts/tools/search-tool-bm25.md +40 -0
  1647. package/src/prompts/tools/search.md +25 -0
  1648. package/src/prompts/tools/ssh.md +35 -0
  1649. package/src/prompts/tools/task-summary.md +28 -0
  1650. package/src/prompts/tools/task.md +80 -0
  1651. package/src/prompts/tools/todo.md +58 -0
  1652. package/src/prompts/tools/web-search.md +10 -0
  1653. package/src/prompts/tools/write.md +14 -0
  1654. package/src/registry/agent-registry.ts +140 -0
  1655. package/src/sdk.ts +2374 -0
  1656. package/src/secrets/index.ts +116 -0
  1657. package/src/secrets/obfuscator.ts +277 -0
  1658. package/src/secrets/regex.ts +21 -0
  1659. package/src/session/agent-session.ts +9765 -0
  1660. package/src/session/agent-storage.ts +455 -0
  1661. package/src/session/artifacts.ts +135 -0
  1662. package/src/session/auth-broker-config.ts +102 -0
  1663. package/src/session/auth-storage.ts +27 -0
  1664. package/src/session/blob-store.ts +255 -0
  1665. package/src/session/client-bridge.ts +85 -0
  1666. package/src/session/history-storage.ts +348 -0
  1667. package/src/session/indexed-session-storage.ts +430 -0
  1668. package/src/session/messages.ts +575 -0
  1669. package/src/session/redis-session-storage.ts +170 -0
  1670. package/src/session/session-dump-format.ts +209 -0
  1671. package/src/session/session-manager.ts +3541 -0
  1672. package/src/session/session-storage.ts +529 -0
  1673. package/src/session/shake-types.ts +43 -0
  1674. package/src/session/sql-session-storage.ts +314 -0
  1675. package/src/session/streaming-output.ts +1093 -0
  1676. package/src/session/tool-choice-queue.ts +213 -0
  1677. package/src/session/yield-queue.ts +155 -0
  1678. package/src/slash-commands/acp-builtins.ts +46 -0
  1679. package/src/slash-commands/builtin-registry.ts +1726 -0
  1680. package/src/slash-commands/headless-plan.ts +142 -0
  1681. package/src/slash-commands/helpers/context-report.ts +39 -0
  1682. package/src/slash-commands/helpers/format.ts +46 -0
  1683. package/src/slash-commands/helpers/marketplace-manager.ts +25 -0
  1684. package/src/slash-commands/helpers/mcp.ts +532 -0
  1685. package/src/slash-commands/helpers/parse.ts +85 -0
  1686. package/src/slash-commands/helpers/ssh.ts +195 -0
  1687. package/src/slash-commands/helpers/todo.ts +279 -0
  1688. package/src/slash-commands/helpers/usage-report.ts +93 -0
  1689. package/src/slash-commands/marketplace-install-parser.ts +99 -0
  1690. package/src/slash-commands/types.ts +139 -0
  1691. package/src/ssh/config-writer.ts +183 -0
  1692. package/src/ssh/connection-manager.ts +482 -0
  1693. package/src/ssh/ssh-executor.ts +133 -0
  1694. package/src/ssh/sshfs-mount.ts +140 -0
  1695. package/src/ssh/utils.ts +8 -0
  1696. package/src/stt/downloader.ts +71 -0
  1697. package/src/stt/index.ts +3 -0
  1698. package/src/stt/recorder.ts +351 -0
  1699. package/src/stt/setup.ts +52 -0
  1700. package/src/stt/stt-controller.ts +160 -0
  1701. package/src/stt/transcribe.py +70 -0
  1702. package/src/stt/transcriber.ts +91 -0
  1703. package/src/system-prompt.ts +591 -0
  1704. package/src/task/agents.ts +167 -0
  1705. package/src/task/commands.ts +131 -0
  1706. package/src/task/discovery.ts +129 -0
  1707. package/src/task/executor.ts +1659 -0
  1708. package/src/task/index.ts +1401 -0
  1709. package/src/task/name-generator.ts +1577 -0
  1710. package/src/task/output-manager.ts +99 -0
  1711. package/src/task/parallel.ts +116 -0
  1712. package/src/task/prometheus-command.ts +26 -0
  1713. package/src/task/render.ts +1211 -0
  1714. package/src/task/repair-args.ts +117 -0
  1715. package/src/task/simple-mode.ts +27 -0
  1716. package/src/task/subprocess-tool-registry.ts +88 -0
  1717. package/src/task/types.ts +320 -0
  1718. package/src/task/worktree.ts +506 -0
  1719. package/src/telemetry-export.ts +127 -0
  1720. package/src/thinking.ts +165 -0
  1721. package/src/tiny/compiled-runtime.ts +179 -0
  1722. package/src/tiny/device.ts +111 -0
  1723. package/src/tiny/dtype.ts +101 -0
  1724. package/src/tiny/models.ts +242 -0
  1725. package/src/tiny/text.ts +165 -0
  1726. package/src/tiny/title-client.ts +491 -0
  1727. package/src/tiny/title-protocol.ts +56 -0
  1728. package/src/tiny/worker.ts +566 -0
  1729. package/src/tool-discovery/mode.ts +24 -0
  1730. package/src/tool-discovery/tool-index.ts +256 -0
  1731. package/src/tools/approval.ts +189 -0
  1732. package/src/tools/archive-reader.ts +629 -0
  1733. package/src/tools/ask.ts +879 -0
  1734. package/src/tools/ast-edit.ts +595 -0
  1735. package/src/tools/ast-grep.ts +458 -0
  1736. package/src/tools/auto-generated-guard.ts +305 -0
  1737. package/src/tools/bash-command-fixup.ts +37 -0
  1738. package/src/tools/bash-interactive.ts +388 -0
  1739. package/src/tools/bash-interceptor.ts +67 -0
  1740. package/src/tools/bash-pty-selection.ts +14 -0
  1741. package/src/tools/bash-skill-urls.ts +248 -0
  1742. package/src/tools/bash.ts +1238 -0
  1743. package/src/tools/browser/attach.ts +175 -0
  1744. package/src/tools/browser/launch.ts +651 -0
  1745. package/src/tools/browser/readable.ts +95 -0
  1746. package/src/tools/browser/registry.ts +194 -0
  1747. package/src/tools/browser/render.ts +213 -0
  1748. package/src/tools/browser/tab-protocol.ts +105 -0
  1749. package/src/tools/browser/tab-supervisor.ts +577 -0
  1750. package/src/tools/browser/tab-worker-entry.ts +21 -0
  1751. package/src/tools/browser/tab-worker.ts +1058 -0
  1752. package/src/tools/browser.ts +316 -0
  1753. package/src/tools/checkpoint.ts +136 -0
  1754. package/src/tools/conflict-detect.ts +672 -0
  1755. package/src/tools/context.ts +39 -0
  1756. package/src/tools/debug.ts +1052 -0
  1757. package/src/tools/eval-backends.ts +27 -0
  1758. package/src/tools/eval-render.ts +765 -0
  1759. package/src/tools/eval.ts +568 -0
  1760. package/src/tools/fetch.ts +1586 -0
  1761. package/src/tools/file-recorder.ts +35 -0
  1762. package/src/tools/find.ts +571 -0
  1763. package/src/tools/fs-cache-invalidation.ts +28 -0
  1764. package/src/tools/gh-format.ts +12 -0
  1765. package/src/tools/gh-renderer.ts +428 -0
  1766. package/src/tools/gh.ts +3582 -0
  1767. package/src/tools/github-cache.ts +548 -0
  1768. package/src/tools/grouped-file-output.ts +103 -0
  1769. package/src/tools/image-gen.ts +1448 -0
  1770. package/src/tools/index.ts +516 -0
  1771. package/src/tools/inspect-image-renderer.ts +103 -0
  1772. package/src/tools/inspect-image.ts +166 -0
  1773. package/src/tools/irc.ts +294 -0
  1774. package/src/tools/job.ts +521 -0
  1775. package/src/tools/json-tree.ts +243 -0
  1776. package/src/tools/jtd-to-json-schema.ts +219 -0
  1777. package/src/tools/jtd-to-typescript.ts +136 -0
  1778. package/src/tools/jtd-utils.ts +102 -0
  1779. package/src/tools/list-limit.ts +40 -0
  1780. package/src/tools/match-line-format.ts +20 -0
  1781. package/src/tools/memory-edit.ts +59 -0
  1782. package/src/tools/memory-recall.ts +104 -0
  1783. package/src/tools/memory-reflect.ts +92 -0
  1784. package/src/tools/memory-render.ts +185 -0
  1785. package/src/tools/memory-retain.ts +91 -0
  1786. package/src/tools/output-meta.ts +754 -0
  1787. package/src/tools/output-schema-validator.ts +132 -0
  1788. package/src/tools/path-utils.ts +1031 -0
  1789. package/src/tools/plan-mode-guard.ts +81 -0
  1790. package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
  1791. package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
  1792. package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
  1793. package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
  1794. package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
  1795. package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
  1796. package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
  1797. package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
  1798. package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
  1799. package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
  1800. package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
  1801. package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
  1802. package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
  1803. package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
  1804. package/src/tools/read.ts +2557 -0
  1805. package/src/tools/render-mermaid.ts +69 -0
  1806. package/src/tools/render-utils.ts +836 -0
  1807. package/src/tools/renderers.ts +75 -0
  1808. package/src/tools/report-tool-issue.ts +528 -0
  1809. package/src/tools/resolve.ts +259 -0
  1810. package/src/tools/review.ts +253 -0
  1811. package/src/tools/search-tool-bm25.ts +338 -0
  1812. package/src/tools/search.ts +1475 -0
  1813. package/src/tools/sqlite-reader.ts +819 -0
  1814. package/src/tools/ssh.ts +347 -0
  1815. package/src/tools/todo.ts +856 -0
  1816. package/src/tools/tool-errors.ts +62 -0
  1817. package/src/tools/tool-result.ts +94 -0
  1818. package/src/tools/tool-timeouts.ts +30 -0
  1819. package/src/tools/tts.ts +133 -0
  1820. package/src/tools/write.ts +1085 -0
  1821. package/src/tools/yield.ts +260 -0
  1822. package/src/tui/code-cell.ts +221 -0
  1823. package/src/tui/file-list.ts +55 -0
  1824. package/src/tui/hyperlink.ts +161 -0
  1825. package/src/tui/index.ts +12 -0
  1826. package/src/tui/output-block.ts +288 -0
  1827. package/src/tui/status-line.ts +50 -0
  1828. package/src/tui/tree-list.ts +84 -0
  1829. package/src/tui/types.ts +15 -0
  1830. package/src/tui/utils.ts +103 -0
  1831. package/src/utils/changelog.ts +106 -0
  1832. package/src/utils/clipboard.ts +193 -0
  1833. package/src/utils/command-args.ts +76 -0
  1834. package/src/utils/commit-message-generator.ts +142 -0
  1835. package/src/utils/edit-mode.ts +41 -0
  1836. package/src/utils/event-bus.ts +33 -0
  1837. package/src/utils/external-editor.ts +65 -0
  1838. package/src/utils/file-display-mode.ts +45 -0
  1839. package/src/utils/file-mentions.ts +280 -0
  1840. package/src/utils/git.ts +1538 -0
  1841. package/src/utils/image-loading.ts +102 -0
  1842. package/src/utils/image-resize.ts +309 -0
  1843. package/src/utils/jj.ts +248 -0
  1844. package/src/utils/lang-from-path.ts +239 -0
  1845. package/src/utils/markit.ts +89 -0
  1846. package/src/utils/open.ts +55 -0
  1847. package/src/utils/session-color.ts +68 -0
  1848. package/src/utils/shell-snapshot.ts +187 -0
  1849. package/src/utils/sixel.ts +69 -0
  1850. package/src/utils/title-generator.ts +353 -0
  1851. package/src/utils/tool-choice.ts +33 -0
  1852. package/src/utils/tools-manager.ts +363 -0
  1853. package/src/web/kagi.ts +302 -0
  1854. package/src/web/parallel.ts +349 -0
  1855. package/src/web/scrapers/artifacthub.ts +207 -0
  1856. package/src/web/scrapers/arxiv.ts +83 -0
  1857. package/src/web/scrapers/aur.ts +162 -0
  1858. package/src/web/scrapers/biorxiv.ts +133 -0
  1859. package/src/web/scrapers/bluesky.ts +262 -0
  1860. package/src/web/scrapers/brew.ts +172 -0
  1861. package/src/web/scrapers/cheatsh.ts +68 -0
  1862. package/src/web/scrapers/chocolatey.ts +196 -0
  1863. package/src/web/scrapers/choosealicense.ts +95 -0
  1864. package/src/web/scrapers/cisa-kev.ts +87 -0
  1865. package/src/web/scrapers/clojars.ts +154 -0
  1866. package/src/web/scrapers/coingecko.ts +177 -0
  1867. package/src/web/scrapers/crates-io.ts +97 -0
  1868. package/src/web/scrapers/crossref.ts +136 -0
  1869. package/src/web/scrapers/devto.ts +147 -0
  1870. package/src/web/scrapers/discogs.ts +306 -0
  1871. package/src/web/scrapers/discourse.ts +197 -0
  1872. package/src/web/scrapers/dockerhub.ts +138 -0
  1873. package/src/web/scrapers/docs-rs.ts +653 -0
  1874. package/src/web/scrapers/fdroid.ts +134 -0
  1875. package/src/web/scrapers/firefox-addons.ts +191 -0
  1876. package/src/web/scrapers/flathub.ts +223 -0
  1877. package/src/web/scrapers/github-gist.ts +58 -0
  1878. package/src/web/scrapers/github.ts +452 -0
  1879. package/src/web/scrapers/gitlab.ts +401 -0
  1880. package/src/web/scrapers/go-pkg.ts +266 -0
  1881. package/src/web/scrapers/hackage.ts +140 -0
  1882. package/src/web/scrapers/hackernews.ts +189 -0
  1883. package/src/web/scrapers/hex.ts +105 -0
  1884. package/src/web/scrapers/huggingface.ts +321 -0
  1885. package/src/web/scrapers/iacr.ts +89 -0
  1886. package/src/web/scrapers/index.ts +252 -0
  1887. package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
  1888. package/src/web/scrapers/lemmy.ts +203 -0
  1889. package/src/web/scrapers/lobsters.ts +175 -0
  1890. package/src/web/scrapers/mastodon.ts +292 -0
  1891. package/src/web/scrapers/maven.ts +138 -0
  1892. package/src/web/scrapers/mdn.ts +173 -0
  1893. package/src/web/scrapers/metacpan.ts +222 -0
  1894. package/src/web/scrapers/musicbrainz.ts +250 -0
  1895. package/src/web/scrapers/npm.ts +98 -0
  1896. package/src/web/scrapers/nuget.ts +183 -0
  1897. package/src/web/scrapers/nvd.ts +222 -0
  1898. package/src/web/scrapers/ollama.ts +239 -0
  1899. package/src/web/scrapers/open-vsx.ts +106 -0
  1900. package/src/web/scrapers/opencorporates.ts +292 -0
  1901. package/src/web/scrapers/openlibrary.ts +336 -0
  1902. package/src/web/scrapers/orcid.ts +286 -0
  1903. package/src/web/scrapers/osv.ts +176 -0
  1904. package/src/web/scrapers/packagist.ts +160 -0
  1905. package/src/web/scrapers/pub-dev.ts +143 -0
  1906. package/src/web/scrapers/pubmed.ts +211 -0
  1907. package/src/web/scrapers/pypi.ts +112 -0
  1908. package/src/web/scrapers/rawg.ts +110 -0
  1909. package/src/web/scrapers/readthedocs.ts +120 -0
  1910. package/src/web/scrapers/reddit.ts +95 -0
  1911. package/src/web/scrapers/repology.ts +251 -0
  1912. package/src/web/scrapers/rfc.ts +201 -0
  1913. package/src/web/scrapers/rubygems.ts +103 -0
  1914. package/src/web/scrapers/searchcode.ts +189 -0
  1915. package/src/web/scrapers/sec-edgar.ts +261 -0
  1916. package/src/web/scrapers/semantic-scholar.ts +171 -0
  1917. package/src/web/scrapers/snapcraft.ts +187 -0
  1918. package/src/web/scrapers/sourcegraph.ts +336 -0
  1919. package/src/web/scrapers/spdx.ts +108 -0
  1920. package/src/web/scrapers/spotify.ts +198 -0
  1921. package/src/web/scrapers/stackoverflow.ts +120 -0
  1922. package/src/web/scrapers/terraform.ts +277 -0
  1923. package/src/web/scrapers/tldr.ts +47 -0
  1924. package/src/web/scrapers/twitter.ts +93 -0
  1925. package/src/web/scrapers/types.ts +318 -0
  1926. package/src/web/scrapers/utils.ts +109 -0
  1927. package/src/web/scrapers/vimeo.ts +133 -0
  1928. package/src/web/scrapers/vscode-marketplace.ts +187 -0
  1929. package/src/web/scrapers/w3c.ts +156 -0
  1930. package/src/web/scrapers/wikidata.ts +344 -0
  1931. package/src/web/scrapers/wikipedia.ts +84 -0
  1932. package/src/web/scrapers/youtube.ts +319 -0
  1933. package/src/web/search/index.ts +292 -0
  1934. package/src/web/search/provider.ts +157 -0
  1935. package/src/web/search/providers/anthropic.ts +302 -0
  1936. package/src/web/search/providers/base.ts +88 -0
  1937. package/src/web/search/providers/brave.ts +149 -0
  1938. package/src/web/search/providers/codex.ts +557 -0
  1939. package/src/web/search/providers/exa.ts +309 -0
  1940. package/src/web/search/providers/gemini.ts +455 -0
  1941. package/src/web/search/providers/jina.ts +101 -0
  1942. package/src/web/search/providers/kagi.ts +79 -0
  1943. package/src/web/search/providers/kimi.ts +171 -0
  1944. package/src/web/search/providers/parallel.ts +210 -0
  1945. package/src/web/search/providers/perplexity.ts +579 -0
  1946. package/src/web/search/providers/searxng.ts +309 -0
  1947. package/src/web/search/providers/synthetic.ts +110 -0
  1948. package/src/web/search/providers/tavily.ts +173 -0
  1949. package/src/web/search/providers/utils.ts +128 -0
  1950. package/src/web/search/providers/zai.ts +320 -0
  1951. package/src/web/search/render.ts +267 -0
  1952. package/src/web/search/types.ts +478 -0
  1953. package/src/web/search/utils.ts +17 -0
  1954. package/src/workspace-tree.ts +286 -0
@@ -0,0 +1,3151 @@
1
+ /**
2
+ * Interactive mode for the coding agent.
3
+ * Handles TUI rendering and user interaction, delegating business logic to AgentSession.
4
+ */
5
+ import * as fs from "node:fs/promises";
6
+ import * as path from "node:path";
7
+ import {
8
+ type Agent,
9
+ type AgentMessage,
10
+ type AgentToolResult,
11
+ EventLoopKeepalive,
12
+ ThinkingLevel,
13
+ } from "@prometheus-ai/agent-core";
14
+ import type { CompactionOutcome } from "@prometheus-ai/agent-core/compaction";
15
+ import {
16
+ type AssistantMessage,
17
+ type ImageContent,
18
+ type Message,
19
+ type Model,
20
+ modelsAreEqual,
21
+ type UsageReport,
22
+ } from "@prometheus-ai/ai";
23
+ import type { Component, EditorTheme, SlashCommand } from "@prometheus-ai/tui";
24
+ import {
25
+ Container,
26
+ clearRenderCache,
27
+ Loader,
28
+ Markdown,
29
+ ProcessTerminal,
30
+ Spacer,
31
+ setTerminalTextSizing,
32
+ TERMINAL,
33
+ Text,
34
+ TUI,
35
+ visibleWidth,
36
+ } from "@prometheus-ai/tui";
37
+ import {
38
+ APP_NAME,
39
+ adjustHsv,
40
+ formatNumber,
41
+ getProjectDir,
42
+ hsvToRgb,
43
+ isEnoent,
44
+ logger,
45
+ postmortem,
46
+ prompt,
47
+ setProjectDir,
48
+ } from "@prometheus-ai/utils";
49
+ import chalk from "chalk";
50
+ import { reset as resetCapabilities } from "../capability";
51
+ import { KeybindingsManager } from "../config/keybindings";
52
+ import { MODEL_ROLES, type ModelRole } from "../config/model-registry";
53
+ import { isSettingsInitialized, Settings, settings } from "../config/settings";
54
+ import { clearClaudePluginRootsCache } from "../discovery/helpers";
55
+ import type {
56
+ ContextUsage,
57
+ ExtensionUIContext,
58
+ ExtensionUIDialogOptions,
59
+ ExtensionUISelectItem,
60
+ ExtensionWidgetContent,
61
+ ExtensionWidgetOptions,
62
+ } from "../extensibility/extensions";
63
+ import type { CompactOptions } from "../extensibility/extensions/types";
64
+ import { BUILTIN_SLASH_COMMANDS, loadSlashCommands } from "../extensibility/slash-commands";
65
+ import type { Goal, GoalModeState } from "../goals/state";
66
+ import { resolveLocalUrlToPath } from "../internal-urls";
67
+ import { LSP_STARTUP_EVENT_CHANNEL, type LspStartupEvent } from "../lsp/startup-events";
68
+ import {
69
+ humanizePlanTitle,
70
+ type PlanApprovalDetails,
71
+ renameApprovedPlanFile,
72
+ resolvePlanTitle,
73
+ } from "../plan-mode/approved-plan";
74
+ import planModeApprovedPrompt from "../prompts/system/plan-mode-approved.md" with { type: "text" };
75
+ import planModeCompactInstructionsPrompt from "../prompts/system/plan-mode-compact-instructions.md" with {
76
+ type: "text",
77
+ };
78
+ import type { AgentSession, AgentSessionEvent, ResolvedRoleModel } from "../session/agent-session";
79
+ import { HistoryStorage } from "../session/history-storage";
80
+ import type { SessionContext, SessionManager } from "../session/session-manager";
81
+ import { getRecentSessions } from "../session/session-manager";
82
+ import type { ShakeMode } from "../session/shake-types";
83
+ import { formatDuration } from "../slash-commands/helpers/format";
84
+ import { STTController, type SttState } from "../stt";
85
+ import type { LspStartupServerInfo } from "../tools";
86
+ import { normalizeLocalScheme } from "../tools/path-utils";
87
+ import { setAutoQaConsentHandler } from "../tools/report-tool-issue";
88
+ import { type ResolveToolDetails, runResolveInvocation } from "../tools/resolve";
89
+ import { formatPhaseDisplayName, selectStickyTodoWindow, todoMatchesAnyDescription } from "../tools/todo";
90
+ import { ToolError } from "../tools/tool-errors";
91
+ import type { EventBus } from "../utils/event-bus";
92
+ import { getEditorCommand, openInEditor } from "../utils/external-editor";
93
+ import { getSessionAccentAnsi, getSessionAccentHex } from "../utils/session-color";
94
+ import { popTerminalTitle, pushTerminalTitle, setSessionTerminalTitle } from "../utils/title-generator";
95
+ import type { AssistantMessageComponent } from "./components/assistant-message";
96
+ import type { BashExecutionComponent } from "./components/bash-execution";
97
+ import { CustomEditor } from "./components/custom-editor";
98
+ import { DynamicBorder } from "./components/dynamic-border";
99
+ import { ErrorBannerComponent } from "./components/error-banner";
100
+ import type { EvalExecutionComponent } from "./components/eval-execution";
101
+ import type { HookEditorComponent } from "./components/hook-editor";
102
+ import type { HookInputComponent } from "./components/hook-input";
103
+ import type { HookSelectorComponent, HookSelectorSlider } from "./components/hook-selector";
104
+ import { StatusLineComponent } from "./components/status-line";
105
+ import type { ToolExecutionHandle } from "./components/tool-execution";
106
+ import { TranscriptContainer } from "./components/transcript-container";
107
+ import { WelcomeComponent, type LspServerInfo as WelcomeLspServerInfo } from "./components/welcome";
108
+ import { BtwController } from "./controllers/btw-controller";
109
+ import { CommandController } from "./controllers/command-controller";
110
+ import { EventController } from "./controllers/event-controller";
111
+ import { ExtensionUiController } from "./controllers/extension-ui-controller";
112
+ import { InputController } from "./controllers/input-controller";
113
+ import { MCPCommandController } from "./controllers/mcp-command-controller";
114
+ import { OmfgController } from "./controllers/omfg-controller";
115
+ import { SelectorController } from "./controllers/selector-controller";
116
+ import { SSHCommandController } from "./controllers/ssh-command-controller";
117
+ import { TodoCommandController } from "./controllers/todo-command-controller";
118
+ import {
119
+ consumeLoopLimitIteration,
120
+ createLoopLimitRuntime,
121
+ describeLoopLimit,
122
+ describeLoopLimitRuntime,
123
+ isLoopDurationExpired,
124
+ type LoopLimitRuntime,
125
+ parseLoopLimitArgs,
126
+ } from "./loop-limit";
127
+ import { OAuthManualInputManager } from "./oauth-manual-input";
128
+ import { SessionObserverRegistry } from "./session-observer-registry";
129
+ import { interruptHint } from "./shared";
130
+ import { type ShimmerPalette, shimmerSegments, shimmerText } from "./theme/shimmer";
131
+ import type { Theme } from "./theme/theme";
132
+ import {
133
+ getEditorTheme,
134
+ getMarkdownTheme,
135
+ getSymbolTheme,
136
+ onTerminalAppearanceChange,
137
+ onThemeChange,
138
+ theme,
139
+ } from "./theme/theme";
140
+ import type {
141
+ CompactionQueuedMessage,
142
+ InteractiveModeContext,
143
+ InteractiveModeInitOptions,
144
+ InteractiveSelectorDialogOptions,
145
+ SubmittedUserInput,
146
+ TodoItem,
147
+ TodoPhase,
148
+ } from "./types";
149
+ import { UiHelpers } from "./utils/ui-helpers";
150
+
151
+ const HINT_SHIMMER_PALETTE: ShimmerPalette = {
152
+ low: "dim",
153
+ mid: "muted",
154
+ high: "borderAccent",
155
+ };
156
+
157
+ interface WorkingMessageAccent {
158
+ main: string;
159
+ dim: string;
160
+ }
161
+
162
+ function renderWorkingMessage(message: string, accent?: WorkingMessageAccent): string {
163
+ const palette = accent
164
+ ? ({
165
+ low: "dim",
166
+ mid: { ansi: accent.main },
167
+ high: { ansi: accent.main },
168
+ bold: true,
169
+ } satisfies ShimmerPalette)
170
+ : undefined;
171
+ const hint = interruptHint();
172
+ if (!message.endsWith(hint)) return shimmerText(message, theme, palette);
173
+ const header = message.slice(0, -hint.length);
174
+ const hintPalette = accent
175
+ ? ({
176
+ low: "dim",
177
+ mid: { ansi: accent.dim },
178
+ high: { ansi: accent.dim },
179
+ } satisfies ShimmerPalette)
180
+ : HINT_SHIMMER_PALETTE;
181
+ return shimmerSegments(
182
+ [
183
+ { text: header, palette },
184
+ { text: hint, palette: hintPalette },
185
+ ],
186
+ theme,
187
+ );
188
+ }
189
+
190
+ const EDITOR_MAX_HEIGHT_MIN = 6;
191
+ const EDITOR_MAX_HEIGHT_MAX = 18;
192
+ const EDITOR_RESERVED_ROWS = 12;
193
+ const EDITOR_FALLBACK_ROWS = 24;
194
+
195
+ const HUD_NOTE_SUP_DIGITS: Record<string, string> = {
196
+ "0": "\u2070",
197
+ "1": "\u00b9",
198
+ "2": "\u00b2",
199
+ "3": "\u00b3",
200
+ "4": "\u2074",
201
+ "5": "\u2075",
202
+ "6": "\u2076",
203
+ "7": "\u2077",
204
+ "8": "\u2078",
205
+ "9": "\u2079",
206
+ };
207
+
208
+ function formatHudNoteMarker(count: number): string {
209
+ if (count <= 0) return "";
210
+ const sub = String(count)
211
+ .split("")
212
+ .map(d => HUD_NOTE_SUP_DIGITS[d] ?? d)
213
+ .join("");
214
+ return theme.fg("dim", chalk.italic(` \u207a${sub}`));
215
+ }
216
+
217
+ type GoalSubcommand = "set" | "show" | "pause" | "resume" | "drop" | "budget";
218
+
219
+ const GOAL_SUBCOMMANDS = new Set<GoalSubcommand>(["set", "show", "pause", "resume", "drop", "budget"]);
220
+ const PLAN_KEEP_CONTEXT_OPTION_INDEX = 2;
221
+ const PLAN_KEEP_CONTEXT_DISABLE_THRESHOLD_PERCENT = 95;
222
+
223
+ function parseGoalSubcommand(args: string): { sub: GoalSubcommand | undefined; rest: string } {
224
+ const trimmed = args.trim();
225
+ if (!trimmed) return { sub: undefined, rest: "" };
226
+ const match = /^(\S+)(?:\s+([\s\S]*))?$/.exec(trimmed);
227
+ if (!match) return { sub: undefined, rest: trimmed };
228
+ const first = match[1].toLowerCase();
229
+ if (GOAL_SUBCOMMANDS.has(first as GoalSubcommand)) {
230
+ return { sub: first as GoalSubcommand, rest: match[2]?.trim() ?? "" };
231
+ }
232
+ return { sub: undefined, rest: trimmed };
233
+ }
234
+
235
+ function formatContextTokenCount(value: number): string {
236
+ return formatNumber(Math.max(0, Math.round(value))).toLowerCase();
237
+ }
238
+
239
+ /** Options for creating an InteractiveMode instance (for future API use) */
240
+ export interface InteractiveModeOptions {
241
+ /** Providers that were migrated during startup */
242
+ migratedProviders?: string[];
243
+ /** Warning message if model fallback occurred */
244
+ modelFallbackMessage?: string;
245
+ /** Initial message to send */
246
+ initialMessage?: string;
247
+ /** Initial images to include with the message */
248
+ initialImages?: ImageContent[];
249
+ /** Additional initial messages to queue */
250
+ initialMessages?: string[];
251
+ }
252
+
253
+ export class InteractiveMode implements InteractiveModeContext {
254
+ session: AgentSession;
255
+ sessionManager: SessionManager;
256
+ settings: Settings;
257
+ keybindings: KeybindingsManager;
258
+ agent: Agent;
259
+ historyStorage?: HistoryStorage;
260
+
261
+ ui: TUI;
262
+ chatContainer: TranscriptContainer;
263
+ pendingMessagesContainer: Container;
264
+ statusContainer: Container;
265
+ todoContainer: Container;
266
+ btwContainer: Container;
267
+ omfgContainer: Container;
268
+ errorBannerContainer: Container;
269
+ editor: CustomEditor;
270
+ editorContainer: Container;
271
+ hookWidgetContainerAbove: Container;
272
+ hookWidgetContainerBelow: Container;
273
+ statusLine: StatusLineComponent;
274
+
275
+ isInitialized = false;
276
+ isBackgrounded = false;
277
+ isBashMode = false;
278
+ toolOutputExpanded = false;
279
+ todoExpanded = false;
280
+ planModeEnabled = false;
281
+ planModePaused = false;
282
+ goalModeEnabled = false;
283
+ goalModePaused = false;
284
+ planModePlanFilePath: string | undefined = undefined;
285
+ loopModeEnabled = false;
286
+ loopPrompt: string | undefined = undefined;
287
+ loopLimit: LoopLimitRuntime | undefined = undefined;
288
+ #loopAutoSubmitTimer: NodeJS.Timeout | undefined;
289
+ #todoAutoClearTimer: NodeJS.Timeout | undefined;
290
+ todoPhases: TodoPhase[] = [];
291
+ hideThinkingBlock = false;
292
+ pendingImages: ImageContent[] = [];
293
+ pendingImageLinks: (string | undefined)[] = [];
294
+ compactionQueuedMessages: CompactionQueuedMessage[] = [];
295
+ pendingTools = new Map<string, ToolExecutionHandle>();
296
+ pendingBashComponents: BashExecutionComponent[] = [];
297
+ bashComponent: BashExecutionComponent | undefined = undefined;
298
+ pendingPythonComponents: EvalExecutionComponent[] = [];
299
+ pythonComponent: EvalExecutionComponent | undefined = undefined;
300
+ isPythonMode = false;
301
+ streamingComponent: AssistantMessageComponent | undefined = undefined;
302
+ streamingMessage: AssistantMessage | undefined = undefined;
303
+ loadingAnimation: Loader | undefined = undefined;
304
+ autoCompactionLoader: Loader | undefined = undefined;
305
+ retryLoader: Loader | undefined = undefined;
306
+ #pendingWorkingMessage: string | undefined;
307
+ get #defaultWorkingMessage(): string {
308
+ return `Working…${interruptHint()}`;
309
+ }
310
+ autoCompactionEscapeHandler?: () => void;
311
+ retryEscapeHandler?: () => void;
312
+ unsubscribe?: () => void;
313
+ onInputCallback?: (input: SubmittedUserInput) => void;
314
+ optimisticUserMessageSignature: string | undefined = undefined;
315
+ locallySubmittedUserSignatures: Set<string> = new Set();
316
+ #pendingSubmittedInput: SubmittedUserInput | undefined;
317
+ #pendingSubmissionDispose: (() => void) | undefined;
318
+ lastSigintTime = 0;
319
+ lastEscapeTime = 0;
320
+ shutdownRequested = false;
321
+ #isShuttingDown = false;
322
+ hookSelector: HookSelectorComponent | undefined = undefined;
323
+ hookInput: HookInputComponent | undefined = undefined;
324
+ hookEditor: HookEditorComponent | undefined = undefined;
325
+ lastStatusSpacer: Spacer | undefined = undefined;
326
+ lastStatusText: Text | undefined = undefined;
327
+ fileSlashCommands: Set<string> = new Set();
328
+ skillCommands: Map<string, string> = new Map();
329
+ oauthManualInput: OAuthManualInputManager = new OAuthManualInputManager();
330
+
331
+ #pendingSlashCommands: SlashCommand[] = [];
332
+ #cleanupUnsubscribe?: () => void;
333
+ readonly #version: string;
334
+ readonly #changelogMarkdown: string | undefined;
335
+ #planModePreviousTools: string[] | undefined;
336
+ #goalModePreviousTools: string[] | undefined;
337
+ #goalContinuationTimer: NodeJS.Timeout | undefined;
338
+ #goalTurnHadToolCalls = false;
339
+ #goalContinuationTurnInFlight = false;
340
+ #goalSuppressNextContinuation = false;
341
+ #planModePreviousModelState: { model: Model; thinkingLevel?: ThinkingLevel } | undefined;
342
+ #pendingModelSwitch: { model: Model; thinkingLevel?: ThinkingLevel } | undefined;
343
+ #planModeHasEntered = false;
344
+ #planReviewContainer: Container | undefined;
345
+ readonly lspServers: LspStartupServerInfo[] | undefined = undefined;
346
+ mcpManager?: import("../mcp").MCPManager;
347
+ readonly #toolUiContextSetter: (uiContext: ExtensionUIContext, hasUI: boolean) => void;
348
+
349
+ readonly #btwController: BtwController;
350
+ readonly #omfgController: OmfgController;
351
+ readonly #commandController: CommandController;
352
+ readonly #todoCommandController: TodoCommandController;
353
+ readonly #eventController: EventController;
354
+ readonly #extensionUiController: ExtensionUiController;
355
+ readonly #inputController: InputController;
356
+ readonly #selectorController: SelectorController;
357
+ readonly #uiHelpers: UiHelpers;
358
+ #sttController: STTController | undefined;
359
+ #voiceAnimationInterval: NodeJS.Timeout | undefined;
360
+ #voiceHue = 0;
361
+ #voicePreviousShowHardwareCursor: boolean | null = null;
362
+ #voicePreviousUseTerminalCursor: boolean | null = null;
363
+ #resizeHandler?: () => void;
364
+ #observerRegistry: SessionObserverRegistry;
365
+ #eventBus?: EventBus;
366
+ #eventBusUnsubscribers: Array<() => void> = [];
367
+ #welcomeComponent?: WelcomeComponent;
368
+
369
+ constructor(
370
+ session: AgentSession,
371
+ version: string,
372
+ changelogMarkdown: string | undefined = undefined,
373
+ setToolUIContext: (uiContext: ExtensionUIContext, hasUI: boolean) => void = () => {},
374
+ lspServers: LspStartupServerInfo[] | undefined = undefined,
375
+ mcpManager?: import("../mcp").MCPManager,
376
+ eventBus?: EventBus,
377
+ ) {
378
+ this.session = session;
379
+ this.sessionManager = session.sessionManager;
380
+ this.settings = session.settings;
381
+ this.keybindings = KeybindingsManager.inMemory();
382
+ this.agent = session.agent;
383
+ this.#version = version;
384
+ this.#changelogMarkdown = changelogMarkdown;
385
+ this.#toolUiContextSetter = setToolUIContext;
386
+ this.lspServers = lspServers;
387
+ this.mcpManager = mcpManager;
388
+ this.#eventBus = eventBus;
389
+ if (eventBus) {
390
+ this.#eventBusUnsubscribers.push(
391
+ eventBus.on(LSP_STARTUP_EVENT_CHANNEL, data => {
392
+ this.#handleLspStartupEvent(data as LspStartupEvent);
393
+ }),
394
+ );
395
+ }
396
+
397
+ this.ui = new TUI(new ProcessTerminal(), settings.get("showHardwareCursor"));
398
+ this.ui.setClearOnShrink(settings.get("clearOnShrink"));
399
+ this.ui.setMaxInlineImages(settings.get("tui.maxInlineImages"));
400
+ // OSC 66 text-sizing is Kitty-only; resolve the setting against the terminal's
401
+ // capability (`TERMINAL.textSizing` defaults on for Kitty) so it stays off
402
+ // unless the user opts in, and never emits raw escapes on other terminals.
403
+ setTerminalTextSizing(settings.get("tui.textSizing") && TERMINAL.textSizing);
404
+ this.chatContainer = new TranscriptContainer();
405
+ this.pendingMessagesContainer = new Container();
406
+ this.statusContainer = new Container();
407
+ this.todoContainer = new Container();
408
+ this.btwContainer = new Container();
409
+ this.omfgContainer = new Container();
410
+ this.errorBannerContainer = new Container();
411
+ this.editor = new CustomEditor(getEditorTheme());
412
+ this.editor.setUseTerminalCursor(this.ui.getShowHardwareCursor());
413
+ this.editor.setAutocompleteMaxVisible(settings.get("autocompleteMaxVisible"));
414
+ this.editor.onAutocompleteCancel = () => {
415
+ this.ui.requestRender(true);
416
+ };
417
+ this.editor.onAutocompleteUpdate = () => {
418
+ this.ui.requestRender(false, { allowUnknownViewportMutation: true });
419
+ };
420
+ this.#syncEditorMaxHeight();
421
+ this.#resizeHandler = () => {
422
+ this.#syncEditorMaxHeight();
423
+ this.updateEditorTopBorder();
424
+ };
425
+ process.stdout.on("resize", this.#resizeHandler);
426
+ try {
427
+ this.historyStorage = HistoryStorage.open();
428
+ this.editor.setHistoryStorage(this.historyStorage);
429
+ this.historyStorage.setSessionResolver(() => this.sessionManager.getSessionId());
430
+ } catch (error) {
431
+ logger.warn("History storage unavailable", { error: String(error) });
432
+ }
433
+ this.hookWidgetContainerAbove = new Container();
434
+ this.hookWidgetContainerAbove.addChild(new Spacer(1));
435
+ this.hookWidgetContainerBelow = new Container();
436
+ this.editorContainer = new Container();
437
+ this.editorContainer.addChild(this.editor);
438
+ this.statusLine = new StatusLineComponent(session);
439
+ this.statusLine.setAutoCompactEnabled(session.autoCompactionEnabled);
440
+
441
+ this.hideThinkingBlock = settings.get("hideThinkingBlock");
442
+
443
+ const builtinCommandNames = new Set(BUILTIN_SLASH_COMMANDS.map(c => c.name));
444
+ const hookCommands: SlashCommand[] = (
445
+ this.session.extensionRunner?.getRegisteredCommands(builtinCommandNames) ?? []
446
+ ).map(cmd => ({
447
+ name: cmd.name,
448
+ description: cmd.description ?? "(hook command)",
449
+ getArgumentCompletions: cmd.getArgumentCompletions,
450
+ }));
451
+
452
+ // Convert custom commands (TypeScript) to SlashCommand format
453
+ const customCommands: SlashCommand[] = this.session.customCommands.map(loaded => ({
454
+ name: loaded.command.name,
455
+ description: `${loaded.command.description} (${loaded.source})`,
456
+ }));
457
+
458
+ // Build skill commands from session.skills (if enabled)
459
+ const skillCommandList: SlashCommand[] = [];
460
+ if (settings.get("skills.enableSkillCommands")) {
461
+ for (const skill of this.session.skills) {
462
+ const commandName = `skill:${skill.name}`;
463
+ this.skillCommands.set(commandName, skill.filePath);
464
+ skillCommandList.push({ name: commandName, description: skill.description });
465
+ }
466
+ }
467
+
468
+ // Store pending commands for init() where file commands are loaded async
469
+ this.#pendingSlashCommands = [...BUILTIN_SLASH_COMMANDS, ...hookCommands, ...customCommands, ...skillCommandList];
470
+
471
+ this.#uiHelpers = new UiHelpers(this);
472
+ this.#btwController = new BtwController(this);
473
+ this.#omfgController = new OmfgController(this);
474
+ this.#extensionUiController = new ExtensionUiController(this);
475
+ this.#eventController = new EventController(this);
476
+ this.#commandController = new CommandController(this);
477
+ this.#todoCommandController = new TodoCommandController(this);
478
+ this.#selectorController = new SelectorController(this);
479
+ this.#inputController = new InputController(this);
480
+ this.#observerRegistry = new SessionObserverRegistry();
481
+ }
482
+
483
+ playWelcomeIntro(): void {
484
+ this.#welcomeComponent?.playIntro(() => this.ui.requestRender());
485
+ }
486
+ async init(options: InteractiveModeInitOptions = {}): Promise<void> {
487
+ if (this.isInitialized) return;
488
+
489
+ this.keybindings = logger.time("InteractiveMode.init:keybindings", () => KeybindingsManager.create());
490
+
491
+ // Register session manager flush for signal handlers (SIGINT, SIGTERM, SIGHUP)
492
+ this.#cleanupUnsubscribe = postmortem.register("session-manager-flush", () => this.sessionManager.flush());
493
+
494
+ // Wire the report_tool_issue consent gate to the Yes/No dialog popup.
495
+ // The handler is process-global — subagent tools (which can't reach
496
+ // `showHookSelector` on their own) resolve through this exact closure.
497
+ // `Settings.instance` is the disk-backed singleton; passing it explicitly
498
+ // guarantees the decision persists even when the prompt is triggered
499
+ // from a subagent whose own `Settings` is an in-memory snapshot.
500
+ setAutoQaConsentHandler(() => this.#promptAutoQaConsent(), Settings.instance);
501
+
502
+ await logger.time(
503
+ "InteractiveMode.init:slashCommands",
504
+ this.refreshSlashCommandState.bind(this),
505
+ getProjectDir(),
506
+ );
507
+
508
+ // Get current model info for welcome screen
509
+ const modelName = this.session.model?.name ?? "Unknown";
510
+ const providerName = this.session.model?.provider ?? "Unknown";
511
+
512
+ // Get recent sessions
513
+ const recentSessions = await logger.time("InteractiveMode.init:recentSessions", () =>
514
+ getRecentSessions(this.sessionManager.getSessionDir()).then(sessions =>
515
+ sessions.map(s => ({
516
+ name: s.name,
517
+ timeAgo: s.timeAgo,
518
+ })),
519
+ ),
520
+ );
521
+
522
+ const startupQuiet = settings.get("startup.quiet");
523
+ this.#welcomeComponent = undefined;
524
+
525
+ for (const warning of this.session.configWarnings) {
526
+ this.ui.addChild(new Text(theme.fg("warning", `Warning: ${warning}`), 1, 0));
527
+ this.ui.addChild(new Spacer(1));
528
+ }
529
+
530
+ if (!startupQuiet) {
531
+ // Add welcome header
532
+ this.#welcomeComponent = new WelcomeComponent(
533
+ this.#version,
534
+ modelName,
535
+ providerName,
536
+ recentSessions,
537
+ this.#getWelcomeLspServers(),
538
+ );
539
+
540
+ // Setup UI layout
541
+ this.ui.addChild(new Spacer(1));
542
+ this.ui.addChild(this.#welcomeComponent);
543
+ this.ui.addChild(new Spacer(1));
544
+ if (!options.suppressWelcomeIntro) {
545
+ this.playWelcomeIntro();
546
+ }
547
+
548
+ // Add changelog if provided
549
+ if (this.#changelogMarkdown) {
550
+ this.ui.addChild(new DynamicBorder());
551
+ if (settings.get("collapseChangelog")) {
552
+ const versionMatch = this.#changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
553
+ const latestVersion = versionMatch ? versionMatch[1] : this.#version;
554
+ const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
555
+ this.ui.addChild(new Text(condensedText, 1, 0));
556
+ } else {
557
+ this.ui.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
558
+ this.ui.addChild(new Spacer(1));
559
+ this.ui.addChild(new Markdown(this.#changelogMarkdown.trim(), 1, 0, getMarkdownTheme()));
560
+ this.ui.addChild(new Spacer(1));
561
+ }
562
+ this.ui.addChild(new DynamicBorder());
563
+ }
564
+ }
565
+
566
+ this.ui.addChild(this.chatContainer);
567
+ this.ui.addChild(this.pendingMessagesContainer);
568
+ this.ui.addChild(this.statusContainer);
569
+ this.ui.addChild(this.todoContainer);
570
+ this.ui.addChild(this.btwContainer);
571
+ this.ui.addChild(this.omfgContainer);
572
+ this.ui.addChild(this.errorBannerContainer);
573
+ this.ui.addChild(this.statusLine); // Only renders hook statuses (main status in editor border)
574
+ this.ui.addChild(this.hookWidgetContainerAbove);
575
+ this.ui.addChild(this.editorContainer);
576
+ this.ui.addChild(this.hookWidgetContainerBelow);
577
+ this.ui.setFocus(this.editor);
578
+
579
+ this.#inputController.setupKeyHandlers();
580
+ this.#inputController.setupEditorSubmitHandler();
581
+
582
+ // Wire observer registry to EventBus
583
+ if (this.#eventBus) {
584
+ this.#observerRegistry.subscribeToEventBus(this.#eventBus);
585
+ }
586
+ this.#observerRegistry.setMainSession(this.sessionManager.getSessionFile() ?? undefined);
587
+ this.#observerRegistry.onChange(() => {
588
+ this.statusLine.setSubagentCount(this.#observerRegistry.getActiveSubagentCount());
589
+ // Auto-checkmark todos whose matching subagent just succeeded, then
590
+ // re-render so the running override (the static "live" glyph when a
591
+ // subagent is doing the work for a still-pending todo) updates as
592
+ // subagents start, finish, or fail.
593
+ this.#reconcileTodosWithSubagents();
594
+ this.#syncTodoAutoClearTimer();
595
+ this.#renderTodoList();
596
+ this.ui.requestRender();
597
+ });
598
+
599
+ // Load initial todos
600
+ await this.#loadTodoList();
601
+
602
+ // Start the UI
603
+ this.ui.start();
604
+ pushTerminalTitle();
605
+ setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
606
+ this.updateEditorBorderColor();
607
+ this.#syncEditorMaxHeight();
608
+ this.isInitialized = true;
609
+ this.ui.requestRender(true);
610
+
611
+ // Initialize hooks with TUI-based UI context
612
+ await this.initHooksAndCustomTools();
613
+
614
+ // Restore mode from session (e.g. plan mode on resume)
615
+ this.session.setSessionSwitchReconciler?.(() => this.#reconcileModeFromSession());
616
+ await this.#reconcileModeFromSession();
617
+
618
+ // Restore unsent editor draft from previous session shutdown (Ctrl+D).
619
+ // One-shot: consumeDraft removes the sidecar after read so the next
620
+ // resume does not re-restore the same text.
621
+ try {
622
+ const draft = await this.sessionManager.consumeDraft();
623
+ if (draft && !this.editor.getText()) {
624
+ this.editor.setText(draft);
625
+ this.updateEditorBorderColor();
626
+ this.ui.requestRender();
627
+ }
628
+ } catch (err) {
629
+ logger.warn("Failed to restore session draft", { error: String(err) });
630
+ }
631
+
632
+ // Subscribe to agent events
633
+ this.#subscribeToAgent();
634
+
635
+ this.#eventBusUnsubscribers.push(
636
+ this.session.subscribe(event => {
637
+ void this.#handleGoalSessionEvent(event);
638
+ }),
639
+ );
640
+ // Set up theme file watcher
641
+ onThemeChange(() => {
642
+ clearRenderCache();
643
+ this.ui.invalidate();
644
+ this.updateEditorBorderColor();
645
+ this.ui.requestRender();
646
+ });
647
+
648
+ // Subscribe to terminal dark/light appearance changes.
649
+ // The terminal queries background color via OSC 11 at startup and on
650
+ // Mode 2031 notifications, computing luminance to detect dark/light.
651
+ this.ui.terminal.onAppearanceChange(mode => {
652
+ onTerminalAppearanceChange(mode);
653
+ });
654
+
655
+ // Set up git branch watcher
656
+ this.statusLine.watchBranch(() => {
657
+ this.updateEditorTopBorder();
658
+ this.ui.requestRender();
659
+ });
660
+
661
+ // Initial top border update
662
+ this.updateEditorTopBorder();
663
+ }
664
+
665
+ /** Reload slash commands and autocomplete for the provided working directory. */
666
+ async refreshSlashCommandState(cwd?: string): Promise<void> {
667
+ const basePath = cwd ?? this.sessionManager.getCwd();
668
+ const fileCommands = await loadSlashCommands({ cwd: basePath });
669
+ this.fileSlashCommands = new Set(fileCommands.map(cmd => cmd.name));
670
+ const fileSlashCommands: SlashCommand[] = fileCommands.map(cmd => ({
671
+ name: cmd.name,
672
+ description: cmd.description,
673
+ }));
674
+ const autocompleteProvider = this.#inputController.createAutocompleteProvider(
675
+ [...this.#pendingSlashCommands, ...fileSlashCommands],
676
+ basePath,
677
+ );
678
+ this.editor.setAutocompleteProvider(autocompleteProvider);
679
+ this.session.setSlashCommands(fileCommands);
680
+ }
681
+
682
+ /**
683
+ * Re-point the process and every cwd-derived cache at `newCwd` after the
684
+ * active session's working directory changed (`/move` relocation or resuming
685
+ * a session from another project). The SessionManager's cwd MUST already
686
+ * reflect `newCwd` before this is called.
687
+ */
688
+ async applyCwdChange(newCwd: string): Promise<void> {
689
+ setProjectDir(newCwd);
690
+ // Re-scope project settings (`.claude/settings.yml` etc.) to the new
691
+ // directory in place so the active session and every settings reader pick
692
+ // up the destination project's configuration.
693
+ if (isSettingsInitialized()) {
694
+ await settings.reloadForCwd(newCwd);
695
+ }
696
+ // Re-warm plugin roots, capabilities, slash commands, and the ssh tool so
697
+ // the next prompt sees everything scoped to the new project directory.
698
+ clearClaudePluginRootsCache();
699
+ resetCapabilities();
700
+ await this.refreshSlashCommandState(newCwd);
701
+ await this.session.refreshSshTool({ activateIfAvailable: true });
702
+ setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
703
+ this.statusLine.invalidate();
704
+ this.updateEditorTopBorder();
705
+ }
706
+
707
+ async getUserInput(): Promise<SubmittedUserInput> {
708
+ if (this.session.getGoalModeState()?.mode === "exiting") {
709
+ await this.#exitGoalMode({ reason: "completed", silent: true });
710
+ }
711
+ const { promise, resolve } = Promise.withResolvers<SubmittedUserInput>();
712
+ this.onInputCallback = input => {
713
+ this.onInputCallback = undefined;
714
+ resolve(input);
715
+ };
716
+ this.#scheduleLoopAutoSubmit();
717
+ this.#scheduleGoalContinuation();
718
+
719
+ using _ = new EventLoopKeepalive();
720
+ return await promise;
721
+ }
722
+
723
+ #scheduleLoopAutoSubmit(): void {
724
+ this.#cancelLoopAutoSubmit();
725
+ if (!this.loopModeEnabled || !this.loopPrompt) return;
726
+ const prompt = this.loopPrompt;
727
+ const loopAction = settings.get("loop.mode");
728
+ this.#deferLoopAutoSubmit(() => {
729
+ void this.#runLoopIteration(loopAction, prompt);
730
+ });
731
+ }
732
+
733
+ #deferLoopAutoSubmit(callback: () => void): void {
734
+ // Brief delay so the user has a chance to press Esc between iterations.
735
+ this.#loopAutoSubmitTimer = setTimeout(() => {
736
+ this.#loopAutoSubmitTimer = undefined;
737
+ if (!this.loopModeEnabled || !this.onInputCallback) return;
738
+ callback();
739
+ }, 800);
740
+ }
741
+
742
+ #cancelLoopAutoSubmit(): void {
743
+ if (this.#loopAutoSubmitTimer) {
744
+ clearTimeout(this.#loopAutoSubmitTimer);
745
+ this.#loopAutoSubmitTimer = undefined;
746
+ }
747
+ }
748
+
749
+ #scheduleGoalContinuation(): void {
750
+ this.#cancelGoalContinuation();
751
+ if (this.loopModeEnabled) return;
752
+ if (!this.onInputCallback) return;
753
+ if (!this.session.settings.get("goal.continuationModes").includes("interactive")) return;
754
+ if (this.planModeEnabled || this.planModePaused) return;
755
+ if (!this.goalModeEnabled || this.goalModePaused) return;
756
+ if (this.#goalSuppressNextContinuation) return;
757
+ if (this.#pendingSubmittedInput) return;
758
+ if (this.editor.getText().trim().length > 0) return;
759
+ if ((this.pendingImages?.length ?? 0) > 0) return;
760
+ const state = this.session.getGoalModeState();
761
+ if (!state?.enabled || state.goal.status !== "active") return;
762
+ const prompt = this.session.goalRuntime.buildContinuationPrompt();
763
+ if (!prompt) return;
764
+ this.#goalContinuationTimer = setTimeout(() => {
765
+ this.#goalContinuationTimer = undefined;
766
+ if (!this.onInputCallback) return;
767
+ if (!this.goalModeEnabled || this.goalModePaused) return;
768
+ if (this.#pendingSubmittedInput) return;
769
+ if (this.editor.getText().trim().length > 0) return;
770
+ if ((this.pendingImages?.length ?? 0) > 0) return;
771
+ const latestState = this.session.getGoalModeState();
772
+ if (!latestState?.enabled || latestState.goal.status !== "active") return;
773
+ this.#goalContinuationTurnInFlight = true;
774
+ this.onInputCallback(
775
+ this.startPendingSubmission({
776
+ text: prompt,
777
+ customType: "goal-continuation",
778
+ display: false,
779
+ }),
780
+ );
781
+ }, 800);
782
+ }
783
+
784
+ #cancelGoalContinuation(): void {
785
+ if (this.#goalContinuationTimer) {
786
+ clearTimeout(this.#goalContinuationTimer);
787
+ this.#goalContinuationTimer = undefined;
788
+ }
789
+ }
790
+
791
+ #isLoopAutoSubmitBlocked(): boolean {
792
+ return this.session.isStreaming || this.session.isCompacting || this.session.hasPostPromptWork;
793
+ }
794
+
795
+ #submitLoopPromptWhenReady(prompt: string): void {
796
+ if (!this.loopModeEnabled || this.loopPrompt !== prompt || !this.onInputCallback) return;
797
+ if (isLoopDurationExpired(this.loopLimit)) {
798
+ this.disableLoopMode("Loop time limit reached. Loop mode disabled.");
799
+ return;
800
+ }
801
+ if (this.#isLoopAutoSubmitBlocked()) {
802
+ this.#deferLoopAutoSubmit(() => this.#submitLoopPromptWhenReady(prompt));
803
+ return;
804
+ }
805
+ this.onInputCallback(this.startPendingSubmission({ text: prompt }));
806
+ }
807
+
808
+ async #runLoopIteration(action: "prompt" | "compact" | "reset", prompt: string): Promise<void> {
809
+ if (!this.loopModeEnabled || this.loopPrompt !== prompt || !this.onInputCallback) return;
810
+ if (this.#isLoopAutoSubmitBlocked()) {
811
+ this.#deferLoopAutoSubmit(() => {
812
+ void this.#runLoopIteration(action, prompt);
813
+ });
814
+ return;
815
+ }
816
+
817
+ if (!consumeLoopLimitIteration(this.loopLimit)) {
818
+ this.disableLoopMode("Loop limit reached. Loop mode disabled.");
819
+ return;
820
+ }
821
+
822
+ if (action === "compact") {
823
+ await this.handleCompactCommand();
824
+ } else if (action === "reset") {
825
+ await this.handleClearCommand();
826
+ }
827
+ this.#submitLoopPromptWhenReady(prompt);
828
+ }
829
+
830
+ disableLoopMode(message = "Loop mode disabled."): void {
831
+ const wasEnabled = this.loopModeEnabled;
832
+ this.loopModeEnabled = false;
833
+ this.loopPrompt = undefined;
834
+ this.loopLimit = undefined;
835
+ this.#cancelLoopAutoSubmit();
836
+ this.statusLine.setLoopModeStatus(undefined);
837
+ this.updateEditorTopBorder();
838
+ this.ui.requestRender();
839
+ if (wasEnabled) {
840
+ this.showStatus(message);
841
+ }
842
+ }
843
+
844
+ /**
845
+ * Pause the loop without exiting it: drops the captured prompt and any
846
+ * pending auto-resubmit. Loop mode stays enabled — the next prompt the
847
+ * user submits becomes the new loop prompt and resumes iteration.
848
+ */
849
+ pauseLoop(): void {
850
+ this.loopPrompt = undefined;
851
+ this.#cancelLoopAutoSubmit();
852
+ }
853
+
854
+ async handleLoopCommand(args = ""): Promise<void> {
855
+ if (this.loopModeEnabled) {
856
+ this.disableLoopMode();
857
+ return;
858
+ }
859
+ const parsedLimit = parseLoopLimitArgs(args);
860
+ if (typeof parsedLimit === "string") {
861
+ this.showError(parsedLimit);
862
+ return;
863
+ }
864
+ this.loopModeEnabled = true;
865
+ this.loopPrompt = undefined;
866
+ this.loopLimit = createLoopLimitRuntime(parsedLimit);
867
+ this.statusLine.setLoopModeStatus({ enabled: true });
868
+ this.updateEditorTopBorder();
869
+ this.ui.requestRender();
870
+ const limitSuffix = parsedLimit ? ` Limited to ${describeLoopLimit(parsedLimit)}.` : "";
871
+ const remainingSuffix = this.loopLimit ? ` ${describeLoopLimitRuntime(this.loopLimit)}.` : "";
872
+ this.showStatus(
873
+ `Loop mode enabled.${limitSuffix}${remainingSuffix} Your next prompt will repeat after each turn. Esc cancels the current iteration; /loop again to disable.`,
874
+ );
875
+ }
876
+
877
+ recordLocalSubmission(text: string, imageCount = 0): () => void {
878
+ if (this.isKnownSlashCommand(text)) {
879
+ return () => {};
880
+ }
881
+ const signature = `${text}\u0000${imageCount}`;
882
+ this.locallySubmittedUserSignatures.add(signature);
883
+ let disposed = false;
884
+ return () => {
885
+ if (disposed) return;
886
+ disposed = true;
887
+ this.locallySubmittedUserSignatures.delete(signature);
888
+ };
889
+ }
890
+
891
+ async withLocalSubmission<T>(text: string, fn: () => Promise<T>, options?: { imageCount?: number }): Promise<T> {
892
+ const dispose = this.recordLocalSubmission(text, options?.imageCount ?? 0);
893
+ try {
894
+ return await fn();
895
+ } catch (err) {
896
+ dispose();
897
+ throw err;
898
+ }
899
+ }
900
+
901
+ startPendingSubmission(input: {
902
+ text: string;
903
+ images?: ImageContent[];
904
+ imageLinks?: (string | undefined)[];
905
+ customType?: string;
906
+ display?: boolean;
907
+ }): SubmittedUserInput {
908
+ const submission: SubmittedUserInput = {
909
+ text: input.text,
910
+ images: input.images,
911
+ imageLinks: input.imageLinks,
912
+ customType: input.customType,
913
+ display: input.display,
914
+ cancelled: false,
915
+ started: false,
916
+ };
917
+ this.#pendingSubmittedInput = submission;
918
+ if (!submission.customType) {
919
+ this.#resetGoalContinuationSuppression();
920
+ const imageCount = submission.images?.length ?? 0;
921
+ this.optimisticUserMessageSignature = `${submission.text}\u0000${imageCount}`;
922
+ this.#pendingSubmissionDispose = this.recordLocalSubmission(submission.text, imageCount);
923
+ this.addMessageToChat(
924
+ {
925
+ role: "user",
926
+ content: [{ type: "text", text: submission.text }, ...(submission.images ?? [])],
927
+ attribution: "user",
928
+ timestamp: Date.now(),
929
+ },
930
+ { imageLinks: input.imageLinks },
931
+ );
932
+ } else {
933
+ this.optimisticUserMessageSignature = undefined;
934
+ this.#pendingSubmissionDispose = undefined;
935
+ }
936
+ this.editor.setText("");
937
+ this.editor.imageLinks = undefined;
938
+ // Reconciliation checkpoint: only retire frozen block snapshots after TUI
939
+ // proves the native viewport is at the tail and replays scrollback safely.
940
+ // Unknown host viewports stay frozen; thawing them would expose live rows
941
+ // over stale native history and can yank or duplicate when ED3 is unsafe.
942
+ if (this.ui.refreshNativeScrollbackIfDirty()) {
943
+ this.chatContainer.thaw();
944
+ }
945
+ this.ensureLoadingAnimation();
946
+ this.ui.requestRender();
947
+ return submission;
948
+ }
949
+
950
+ cancelPendingSubmission(): boolean {
951
+ const submission = this.#pendingSubmittedInput;
952
+ if (!submission || submission.started) {
953
+ return false;
954
+ }
955
+
956
+ submission.cancelled = true;
957
+ this.#pendingSubmittedInput = undefined;
958
+ this.optimisticUserMessageSignature = undefined;
959
+ this.#pendingSubmissionDispose?.();
960
+ this.#pendingSubmissionDispose = undefined;
961
+ this.#pendingWorkingMessage = undefined;
962
+ if (submission.customType === "goal-continuation") {
963
+ this.#goalContinuationTurnInFlight = false;
964
+ }
965
+ if (this.loadingAnimation) {
966
+ this.loadingAnimation.stop();
967
+ this.loadingAnimation = undefined;
968
+ this.statusContainer.clear();
969
+ }
970
+ if (!submission.customType) {
971
+ this.pendingImages = submission.images ? [...submission.images] : [];
972
+ this.pendingImageLinks = submission.imageLinks ? [...submission.imageLinks] : [];
973
+ this.editor.imageLinks = this.pendingImageLinks;
974
+ this.rebuildChatFromMessages();
975
+ this.editor.setText(submission.text);
976
+ }
977
+ this.updateEditorBorderColor();
978
+ this.ui.requestRender();
979
+ return true;
980
+ }
981
+
982
+ markPendingSubmissionStarted(input: SubmittedUserInput): boolean {
983
+ if (this.#pendingSubmittedInput !== input || input.cancelled) {
984
+ return false;
985
+ }
986
+ input.started = true;
987
+ return true;
988
+ }
989
+
990
+ finishPendingSubmission(input: SubmittedUserInput): void {
991
+ const wasPendingSubmission = this.#pendingSubmittedInput === input;
992
+ const pendingSubmissionDispose = this.#pendingSubmissionDispose;
993
+ if (wasPendingSubmission) {
994
+ this.#pendingSubmittedInput = undefined;
995
+ this.#pendingSubmissionDispose = undefined;
996
+ }
997
+ if (input.customType === "goal-continuation") {
998
+ this.#goalContinuationTurnInFlight = false;
999
+ }
1000
+
1001
+ if (wasPendingSubmission && !this.session.isStreaming && !this.streamingComponent) {
1002
+ this.optimisticUserMessageSignature = undefined;
1003
+ pendingSubmissionDispose?.();
1004
+ this.#pendingWorkingMessage = undefined;
1005
+ if (this.loadingAnimation) {
1006
+ this.loadingAnimation.stop();
1007
+ this.loadingAnimation = undefined;
1008
+ this.statusContainer.clear();
1009
+ }
1010
+ }
1011
+ }
1012
+
1013
+ #computeEditorMaxHeight(): number {
1014
+ const rows = this.ui.terminal.rows;
1015
+ const terminalRows = Number.isFinite(rows) && rows > 0 ? rows : EDITOR_FALLBACK_ROWS;
1016
+ const maxHeight = terminalRows - EDITOR_RESERVED_ROWS;
1017
+ return Math.max(EDITOR_MAX_HEIGHT_MIN, Math.min(EDITOR_MAX_HEIGHT_MAX, maxHeight));
1018
+ }
1019
+
1020
+ #syncEditorMaxHeight(): void {
1021
+ this.editor.setMaxHeight(this.#computeEditorMaxHeight());
1022
+ }
1023
+
1024
+ updateEditorBorderColor(): void {
1025
+ if (this.isBashMode) {
1026
+ this.editor.borderColor = theme.getBashModeBorderColor();
1027
+ } else if (this.isPythonMode) {
1028
+ this.editor.borderColor = theme.getPythonModeBorderColor();
1029
+ } else {
1030
+ const accentEnabled = !isSettingsInitialized() || settings.get("statusLine.sessionAccent") !== false;
1031
+ const sessionName = accentEnabled ? this.sessionManager.getSessionName() : undefined;
1032
+ const hex = sessionName ? getSessionAccentHex(sessionName, theme.accentSurfaceLuminance) : undefined;
1033
+ const ansi = getSessionAccentAnsi(hex);
1034
+ if (ansi) {
1035
+ this.editor.borderColor = (str: string) => `${ansi}${str}\x1b[39m`;
1036
+ } else {
1037
+ const level = this.session.thinkingLevel ?? ThinkingLevel.Off;
1038
+ this.editor.borderColor = theme.getThinkingBorderColor(level);
1039
+ }
1040
+ }
1041
+ this.updateEditorTopBorder();
1042
+ this.ui.requestRender();
1043
+ }
1044
+
1045
+ updateEditorTopBorder(): void {
1046
+ const availableWidth = this.editor.getTopBorderAvailableWidth(this.ui.terminal.columns);
1047
+ const topBorder = this.statusLine.getTopBorder(availableWidth);
1048
+ this.editor.setTopBorder(topBorder);
1049
+ }
1050
+
1051
+ rebuildChatFromMessages(): void {
1052
+ this.chatContainer.clear();
1053
+ const context = this.session.buildDisplaySessionContext();
1054
+ this.renderSessionContext(context);
1055
+ }
1056
+
1057
+ #formatTodoLine(todo: TodoItem, prefix: string, matched: boolean): string {
1058
+ const checkbox = theme.checkbox;
1059
+ const marker = formatHudNoteMarker(todo.notes?.length ?? 0);
1060
+ switch (todo.status) {
1061
+ case "completed":
1062
+ return theme.fg("success", `${prefix}${checkbox.checked} ${chalk.strikethrough(todo.content)}`) + marker;
1063
+ case "in_progress":
1064
+ return theme.fg("accent", `${prefix}${checkbox.unchecked} ${todo.content}`) + marker;
1065
+ case "abandoned":
1066
+ return theme.fg("error", `${prefix}${checkbox.unchecked} ${chalk.strikethrough(todo.content)}`) + marker;
1067
+ default:
1068
+ if (matched) {
1069
+ return theme.fg("accent", `${prefix}${checkbox.unchecked} ${todo.content}`) + marker;
1070
+ }
1071
+ return theme.fg("dim", `${prefix}${checkbox.unchecked} ${todo.content}`) + marker;
1072
+ }
1073
+ }
1074
+
1075
+ #getActiveSubagentDescriptions(): string[] {
1076
+ const out: string[] = [];
1077
+ for (const session of this.#observerRegistry.getSessions()) {
1078
+ if (session.kind !== "subagent") continue;
1079
+ if (session.status !== "active") continue;
1080
+ const candidate =
1081
+ session.description?.trim() || session.progress?.description?.trim() || session.label?.trim();
1082
+ if (candidate) out.push(candidate);
1083
+ }
1084
+ return out;
1085
+ }
1086
+
1087
+ /**
1088
+ * Auto-complete any pending/in_progress todo whose content matches a
1089
+ * subagent that has finished successfully. Fires on every observer
1090
+ * `onChange` so the visual state stays in sync with subagent lifecycle
1091
+ * without requiring the agent to issue a follow-up `todo`. Failed
1092
+ * and aborted subagents are intentionally NOT auto-completed — those
1093
+ * stay open so the user (or the next agent turn) can decide what to do.
1094
+ *
1095
+ * Idempotent: only flips open tasks, never re-touches completed ones.
1096
+ */
1097
+ #reconcileTodosWithSubagents(): void {
1098
+ const completedDescs: string[] = [];
1099
+ for (const session of this.#observerRegistry.getSessions()) {
1100
+ if (session.kind !== "subagent") continue;
1101
+ if (session.status !== "completed") continue;
1102
+ const candidate =
1103
+ session.description?.trim() || session.progress?.description?.trim() || session.label?.trim();
1104
+ if (candidate) completedDescs.push(candidate);
1105
+ }
1106
+ if (completedDescs.length === 0) return;
1107
+
1108
+ let mutated = false;
1109
+ const next: TodoPhase[] = this.todoPhases.map(phase => ({
1110
+ name: phase.name,
1111
+ tasks: phase.tasks.map(task => {
1112
+ if (task.status !== "pending" && task.status !== "in_progress") return task;
1113
+ if (!todoMatchesAnyDescription(task.content, completedDescs)) return task;
1114
+ mutated = true;
1115
+ return { ...task, status: "completed" as const };
1116
+ }),
1117
+ }));
1118
+ if (!mutated) return;
1119
+ this.todoPhases = next;
1120
+ this.session.setTodoPhases(next);
1121
+ }
1122
+
1123
+ #cancelTodoAutoClearTimer(): void {
1124
+ if (!this.#todoAutoClearTimer) return;
1125
+ clearTimeout(this.#todoAutoClearTimer);
1126
+ this.#todoAutoClearTimer = undefined;
1127
+ }
1128
+
1129
+ #isClosedTodo(task: TodoItem): boolean {
1130
+ return task.status === "completed" || task.status === "abandoned";
1131
+ }
1132
+
1133
+ #hasClosedTodos(phases: TodoPhase[]): boolean {
1134
+ return phases.some(phase => phase.tasks.some(task => this.#isClosedTodo(task)));
1135
+ }
1136
+
1137
+ #removeClosedTodos(phases: TodoPhase[]): TodoPhase[] {
1138
+ const next: TodoPhase[] = [];
1139
+ for (const phase of phases) {
1140
+ const tasks = phase.tasks.filter(task => !this.#isClosedTodo(task));
1141
+ if (tasks.length > 0) next.push({ name: phase.name, tasks });
1142
+ }
1143
+ return next;
1144
+ }
1145
+
1146
+ #syncTodoAutoClearTimer(): void {
1147
+ this.#cancelTodoAutoClearTimer();
1148
+ const delaySeconds = this.settings.get("tasks.todoClearDelay");
1149
+ if (!Number.isFinite(delaySeconds) || delaySeconds < 0 || !this.#hasClosedTodos(this.todoPhases)) return;
1150
+ if (delaySeconds === 0) {
1151
+ this.todoPhases = this.#removeClosedTodos(this.todoPhases);
1152
+ return;
1153
+ }
1154
+
1155
+ this.#todoAutoClearTimer = setTimeout(() => {
1156
+ this.#todoAutoClearTimer = undefined;
1157
+ this.todoPhases = this.#removeClosedTodos(this.todoPhases);
1158
+ this.#renderTodoList();
1159
+ this.ui.requestRender();
1160
+ }, delaySeconds * 1000);
1161
+ this.#todoAutoClearTimer.unref?.();
1162
+ }
1163
+
1164
+ #getActivePhase(phases: TodoPhase[]): TodoPhase | undefined {
1165
+ const nonEmpty = phases.filter(phase => phase.tasks.length > 0);
1166
+ const active = nonEmpty.find(phase =>
1167
+ phase.tasks.some(task => task.status === "pending" || task.status === "in_progress"),
1168
+ );
1169
+ return active ?? nonEmpty[nonEmpty.length - 1];
1170
+ }
1171
+
1172
+ #renderTodoList(): void {
1173
+ this.todoContainer.clear();
1174
+ const phases = this.todoPhases.filter(phase => phase.tasks.length > 0);
1175
+ if (phases.length === 0) return;
1176
+ const indent = " ";
1177
+ const hook = theme.tree.hook;
1178
+ const lines = ["", indent + theme.bold(theme.fg("accent", "Todos"))];
1179
+
1180
+ const activeDescs = this.#getActiveSubagentDescriptions();
1181
+ // A pending todo "lights up" (accent + running glyph) when an in-flight
1182
+ // subagent is doing its work, matched by normalized content overlap.
1183
+ const isMatched = (todo: TodoItem): boolean =>
1184
+ activeDescs.length > 0 && todoMatchesAnyDescription(todo.content, activeDescs);
1185
+
1186
+ if (!this.todoExpanded) {
1187
+ const activeIdx = phases.indexOf(this.#getActivePhase(phases) ?? phases[0]);
1188
+ const activePhase = phases[activeIdx];
1189
+ if (!activePhase) return;
1190
+ const { visible, hiddenOpenCount } = selectStickyTodoWindow(activePhase.tasks, 5);
1191
+
1192
+ lines.push(
1193
+ `${indent}${theme.fg("accent", `${hook} ${formatPhaseDisplayName(activePhase.name, activeIdx + 1)}`)}`,
1194
+ );
1195
+ visible.forEach((todo, index) => {
1196
+ const prefix = `${indent}${index === 0 ? hook : " "} `;
1197
+ lines.push(this.#formatTodoLine(todo, prefix, isMatched(todo)));
1198
+ });
1199
+ if (hiddenOpenCount > 0) {
1200
+ lines.push(theme.fg("muted", `${indent} ${hook} +${hiddenOpenCount} more`));
1201
+ }
1202
+ this.todoContainer.addChild(new Text(lines.join("\n"), 1, 0));
1203
+ return;
1204
+ }
1205
+
1206
+ phases.forEach((phase, phaseIndex) => {
1207
+ lines.push(`${indent}${theme.fg("accent", `${hook} ${formatPhaseDisplayName(phase.name, phaseIndex + 1)}`)}`);
1208
+ phase.tasks.forEach((todo, index) => {
1209
+ const prefix = `${indent}${index === 0 ? hook : " "} `;
1210
+ lines.push(this.#formatTodoLine(todo, prefix, isMatched(todo)));
1211
+ });
1212
+ });
1213
+
1214
+ this.todoContainer.addChild(new Text(lines.join("\n"), 1, 0));
1215
+ }
1216
+
1217
+ async #loadTodoList(): Promise<void> {
1218
+ this.todoPhases = this.session.getTodoPhases();
1219
+ this.#syncTodoAutoClearTimer();
1220
+ this.#renderTodoList();
1221
+ }
1222
+
1223
+ async #getPlanFilePath(): Promise<string> {
1224
+ return this.session.getPlanReferencePath() || "local://PLAN.md";
1225
+ }
1226
+
1227
+ #resolvePlanFilePath(planFilePath: string): string {
1228
+ if (planFilePath.startsWith("local:")) {
1229
+ const normalized = normalizeLocalScheme(planFilePath);
1230
+ return resolveLocalUrlToPath(normalized, {
1231
+ getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
1232
+ getSessionId: () => this.sessionManager.getSessionId(),
1233
+ });
1234
+ }
1235
+ return path.resolve(this.sessionManager.getCwd(), planFilePath);
1236
+ }
1237
+
1238
+ #updatePlanModeStatus(): void {
1239
+ const status =
1240
+ this.planModeEnabled || this.planModePaused
1241
+ ? {
1242
+ enabled: this.planModeEnabled,
1243
+ paused: this.planModePaused,
1244
+ }
1245
+ : undefined;
1246
+ this.statusLine.setPlanModeStatus(status);
1247
+ this.updateEditorTopBorder();
1248
+ this.ui.requestRender();
1249
+ }
1250
+
1251
+ #updateGoalModeStatus(): void {
1252
+ const status =
1253
+ this.goalModeEnabled || this.goalModePaused
1254
+ ? { enabled: this.goalModeEnabled, paused: this.goalModePaused }
1255
+ : undefined;
1256
+ this.statusLine.setGoalModeStatus(status);
1257
+ this.updateEditorTopBorder();
1258
+ this.ui.requestRender();
1259
+ }
1260
+
1261
+ #resetGoalContinuationSuppression(): void {
1262
+ this.#goalSuppressNextContinuation = false;
1263
+ }
1264
+
1265
+ #getPausedGoalState(): GoalModeState | undefined {
1266
+ const state = this.session.getGoalModeState();
1267
+ if (!state?.goal || state.enabled || state.goal.status !== "paused") {
1268
+ return undefined;
1269
+ }
1270
+ return state;
1271
+ }
1272
+
1273
+ #goalFromModeData(modeData: SessionContext["modeData"]): Goal | undefined {
1274
+ const goal = modeData?.goal;
1275
+ if (!goal || typeof goal !== "object") return undefined;
1276
+ const value = goal as Record<string, unknown>;
1277
+ if (
1278
+ typeof value.id !== "string" ||
1279
+ typeof value.objective !== "string" ||
1280
+ typeof value.status !== "string" ||
1281
+ typeof value.tokensUsed !== "number" ||
1282
+ typeof value.timeUsedSeconds !== "number" ||
1283
+ typeof value.createdAt !== "number" ||
1284
+ typeof value.updatedAt !== "number"
1285
+ ) {
1286
+ return undefined;
1287
+ }
1288
+ return {
1289
+ id: value.id,
1290
+ objective: value.objective,
1291
+ status: value.status as Goal["status"],
1292
+ tokenBudget: typeof value.tokenBudget === "number" ? value.tokenBudget : undefined,
1293
+ tokensUsed: value.tokensUsed,
1294
+ timeUsedSeconds: value.timeUsedSeconds,
1295
+ createdAt: value.createdAt,
1296
+ updatedAt: value.updatedAt,
1297
+ };
1298
+ }
1299
+
1300
+ async #handleGoalSessionEvent(event: AgentSessionEvent): Promise<void> {
1301
+ if (event.type === "agent_start") {
1302
+ this.#goalTurnHadToolCalls = false;
1303
+ this.#cancelGoalContinuation();
1304
+ return;
1305
+ }
1306
+ if (event.type === "tool_execution_start") {
1307
+ this.#goalTurnHadToolCalls = true;
1308
+ if (!this.#goalContinuationTurnInFlight) {
1309
+ this.#resetGoalContinuationSuppression();
1310
+ }
1311
+ return;
1312
+ }
1313
+ if (event.type === "message_start" && event.message.role === "user" && !event.message.synthetic) {
1314
+ this.#resetGoalContinuationSuppression();
1315
+ return;
1316
+ }
1317
+ if (event.type === "goal_updated") {
1318
+ // Handle drop before clearing goalModeEnabled so #exitGoalMode can
1319
+ // still restore the previous tool set while the flag is true.
1320
+ if (event.state?.goal?.status === "dropped") {
1321
+ await this.#exitGoalMode({ reason: "dropped", silent: true });
1322
+ return;
1323
+ }
1324
+ this.goalModeEnabled = event.state?.enabled === true;
1325
+ this.goalModePaused = event.state?.enabled !== true && event.state?.goal?.status === "paused";
1326
+ if (!event.state?.enabled) {
1327
+ this.#cancelGoalContinuation();
1328
+ }
1329
+ this.#updateGoalModeStatus();
1330
+ return;
1331
+ }
1332
+ if (event.type !== "agent_end") {
1333
+ return;
1334
+ }
1335
+ if (this.#goalContinuationTurnInFlight) {
1336
+ this.#goalSuppressNextContinuation = !this.#goalTurnHadToolCalls;
1337
+ this.#goalContinuationTurnInFlight = false;
1338
+ }
1339
+ if (this.session.getGoalModeState()?.mode === "exiting") {
1340
+ await this.#exitGoalMode({ reason: "completed", silent: true });
1341
+ return;
1342
+ }
1343
+ this.#scheduleGoalContinuation();
1344
+ }
1345
+
1346
+ async #applyPlanModeModel(): Promise<void> {
1347
+ const resolved = this.session.resolveRoleModelWithThinking("plan");
1348
+ if (!resolved.model) return;
1349
+
1350
+ const currentModel = this.session.model;
1351
+ const sameModel = modelsAreEqual(currentModel, resolved.model);
1352
+ const planThinkingLevel = resolved.explicitThinkingLevel ? resolved.thinkingLevel : undefined;
1353
+
1354
+ this.#planModePreviousModelState = currentModel
1355
+ ? { model: currentModel, thinkingLevel: this.session.thinkingLevel }
1356
+ : undefined;
1357
+
1358
+ if (!sameModel) {
1359
+ if (this.session.isStreaming) {
1360
+ this.#pendingModelSwitch = { model: resolved.model, thinkingLevel: planThinkingLevel };
1361
+ return;
1362
+ }
1363
+ try {
1364
+ await this.session.setModelTemporary(resolved.model, planThinkingLevel);
1365
+ } catch (error) {
1366
+ this.showWarning(
1367
+ `Failed to switch to plan model for plan mode: ${error instanceof Error ? error.message : String(error)}`,
1368
+ );
1369
+ }
1370
+ } else if (planThinkingLevel) {
1371
+ this.session.setThinkingLevel(planThinkingLevel);
1372
+ }
1373
+ }
1374
+
1375
+ /** Apply any deferred model switch after the current stream ends. */
1376
+ async flushPendingModelSwitch(): Promise<void> {
1377
+ const pending = this.#pendingModelSwitch;
1378
+ if (!pending) return;
1379
+ this.#pendingModelSwitch = undefined;
1380
+ try {
1381
+ await this.session.setModelTemporary(pending.model, pending.thinkingLevel);
1382
+ } catch (error) {
1383
+ this.showWarning(
1384
+ `Failed to switch model after streaming: ${error instanceof Error ? error.message : String(error)}`,
1385
+ );
1386
+ }
1387
+ }
1388
+
1389
+ async #clearTransientModeState(): Promise<void> {
1390
+ if (this.planModeEnabled || this.planModePaused) {
1391
+ if (this.#planModePreviousTools !== undefined) {
1392
+ await this.session.setActiveToolsByName(this.#planModePreviousTools);
1393
+ }
1394
+ this.session.setStandingResolveHandler?.(null);
1395
+ this.session.setPlanModeState(undefined);
1396
+ this.planModeEnabled = false;
1397
+ this.planModePaused = false;
1398
+ this.planModePlanFilePath = undefined;
1399
+ this.#planModePreviousTools = undefined;
1400
+ this.#planModePreviousModelState = undefined;
1401
+ this.#pendingModelSwitch = undefined;
1402
+ this.#planModeHasEntered = false;
1403
+ this.#updatePlanModeStatus();
1404
+ }
1405
+
1406
+ if (this.goalModeEnabled || this.goalModePaused) {
1407
+ if (this.#goalModePreviousTools !== undefined) {
1408
+ await this.session.setActiveToolsByName(this.#goalModePreviousTools);
1409
+ }
1410
+ this.session.setGoalModeState(undefined);
1411
+ this.goalModeEnabled = false;
1412
+ this.goalModePaused = false;
1413
+ this.#goalModePreviousTools = undefined;
1414
+ this.#goalTurnHadToolCalls = false;
1415
+ this.#goalContinuationTurnInFlight = false;
1416
+ this.#goalSuppressNextContinuation = false;
1417
+ this.#cancelGoalContinuation();
1418
+ this.#updateGoalModeStatus();
1419
+ }
1420
+ }
1421
+
1422
+ /** Reconcile mode state from session entries on resume/switch. */
1423
+ async #reconcileModeFromSession(): Promise<void> {
1424
+ await this.#clearTransientModeState();
1425
+ const sessionContext = this.sessionManager.buildSessionContext();
1426
+ const goalEnabled = this.session.settings.get("goal.enabled");
1427
+ if (!goalEnabled && (sessionContext.mode === "goal" || sessionContext.mode === "goal_paused")) {
1428
+ this.sessionManager.appendModeChange("none");
1429
+ return;
1430
+ }
1431
+ if (sessionContext.mode === "goal" || sessionContext.mode === "goal_paused") {
1432
+ const goal = this.#goalFromModeData(sessionContext.modeData);
1433
+ if (!goal) {
1434
+ this.sessionManager.appendModeChange("none");
1435
+ return;
1436
+ }
1437
+ this.session.setGoalModeState({
1438
+ enabled: sessionContext.mode === "goal",
1439
+ mode: "active",
1440
+ goal,
1441
+ });
1442
+ const restored = await this.session.goalRuntime.onThreadResumed();
1443
+ this.goalModeEnabled = restored?.enabled === true;
1444
+ this.goalModePaused = restored?.enabled !== true && restored?.goal.status === "paused";
1445
+ // sdk.ts excludes "goal" from the initial active tool set unconditionally.
1446
+ // Re-add it now so the agent can call resume, complete, or drop on this goal.
1447
+ if (restored?.goal) {
1448
+ const previousTools = this.session.getActiveToolNames().filter(name => name !== "goal");
1449
+ this.#goalModePreviousTools = previousTools;
1450
+ await this.session.setActiveToolsByName([...new Set([...previousTools, "goal"])]);
1451
+ }
1452
+ this.#updateGoalModeStatus();
1453
+ return;
1454
+ }
1455
+ if (!this.session.settings.get("plan.enabled")) {
1456
+ // Clear stale plan/plan_paused mode so re-enabling the setting
1457
+ // later doesn't unexpectedly restore an old plan session.
1458
+ if (sessionContext.mode === "plan" || sessionContext.mode === "plan_paused") {
1459
+ this.sessionManager.appendModeChange("none");
1460
+ }
1461
+ return;
1462
+ }
1463
+ if (sessionContext.mode === "plan") {
1464
+ const planFilePath = sessionContext.modeData?.planFilePath as string | undefined;
1465
+ await this.#enterPlanMode({ planFilePath });
1466
+ } else if (sessionContext.mode === "plan_paused") {
1467
+ this.planModePaused = true;
1468
+ this.#planModeHasEntered = true;
1469
+ this.#updatePlanModeStatus();
1470
+ }
1471
+ }
1472
+
1473
+ async #enterPlanMode(options?: { planFilePath?: string; workflow?: "parallel" | "iterative" }): Promise<void> {
1474
+ if (this.planModeEnabled) {
1475
+ return;
1476
+ }
1477
+ if (this.goalModeEnabled || this.goalModePaused) {
1478
+ this.showWarning("Exit goal mode first.");
1479
+ return;
1480
+ }
1481
+
1482
+ this.planModePaused = false;
1483
+
1484
+ const planFilePath = options?.planFilePath ?? (await this.#getPlanFilePath());
1485
+ const previousTools = this.session.getActiveToolNames();
1486
+ const hasResolveTool = this.session.getToolByName("resolve") !== undefined;
1487
+ const planTools = hasResolveTool ? [...previousTools, "resolve"] : previousTools;
1488
+ const uniquePlanTools = [...new Set(planTools)];
1489
+
1490
+ this.#planModePreviousTools = previousTools;
1491
+ this.planModePlanFilePath = planFilePath;
1492
+ this.planModeEnabled = true;
1493
+
1494
+ await this.session.setActiveToolsByName(uniquePlanTools);
1495
+ this.session.setPlanModeState({
1496
+ enabled: true,
1497
+ planFilePath,
1498
+ workflow: options?.workflow ?? "parallel",
1499
+ reentry: this.#planModeHasEntered,
1500
+ });
1501
+ this.session.setStandingResolveHandler?.(input => this.#runPlanApprovalResolve(input));
1502
+ if (this.session.isStreaming) {
1503
+ await this.session.sendPlanModeContext({ deliverAs: "steer" });
1504
+ }
1505
+ this.#planModeHasEntered = true;
1506
+ await this.#applyPlanModeModel();
1507
+ this.#updatePlanModeStatus();
1508
+ this.sessionManager.appendModeChange("plan", { planFilePath });
1509
+ this.showStatus(`Plan mode enabled. Plan file: ${planFilePath}`);
1510
+ }
1511
+
1512
+ /** Standing resolve dispatcher registered while plan mode is active. The agent
1513
+ * submits the finalized plan by calling `resolve { action: "apply", extra: { title } }`;
1514
+ * this handler validates the plan file exists, normalizes the title, and shapes the
1515
+ * payload that `event-controller` forwards to `handlePlanApproval`. */
1516
+ #runPlanApprovalResolve(input: unknown): Promise<AgentToolResult<ResolveToolDetails>> {
1517
+ return runResolveInvocation(input as Parameters<typeof runResolveInvocation>[0], {
1518
+ sourceToolName: "plan_approval",
1519
+ label: "Plan ready for approval",
1520
+ apply: async (_reason, extra) => {
1521
+ const state = this.session.getPlanModeState?.();
1522
+ if (!state?.enabled) {
1523
+ throw new ToolError("Plan mode is not active.");
1524
+ }
1525
+ const planFilePath = state.planFilePath;
1526
+ const planContent = await this.#readPlanFile(planFilePath);
1527
+ if (planContent === null) {
1528
+ throw new ToolError(
1529
+ `Plan file not found at ${planFilePath}. Write the finalized plan to ${planFilePath} before requesting approval.`,
1530
+ );
1531
+ }
1532
+ const normalized = resolvePlanTitle({
1533
+ suppliedTitle: extra?.title,
1534
+ planContent,
1535
+ planFilePath,
1536
+ });
1537
+ const details: PlanApprovalDetails = {
1538
+ planFilePath,
1539
+ finalPlanFilePath: `local://${normalized.fileName}`,
1540
+ title: normalized.title,
1541
+ planExists: true,
1542
+ };
1543
+ return {
1544
+ content: [{ type: "text" as const, text: "Plan ready for approval." }],
1545
+ details,
1546
+ };
1547
+ },
1548
+ });
1549
+ }
1550
+
1551
+ async #exitPlanMode(options?: { silent?: boolean; paused?: boolean }): Promise<void> {
1552
+ if (!this.planModeEnabled) {
1553
+ return;
1554
+ }
1555
+
1556
+ const previousTools = this.#planModePreviousTools;
1557
+ if (previousTools && previousTools.length > 0) {
1558
+ await this.session.setActiveToolsByName(previousTools);
1559
+ }
1560
+ if (this.#planModePreviousModelState) {
1561
+ const prev = this.#planModePreviousModelState;
1562
+ if (modelsAreEqual(this.session.model, prev.model)) {
1563
+ // Same model — only thinking level may differ. Avoid setModelTemporary()
1564
+ // which would reset provider-side sessions (openai-responses/Codex) and
1565
+ // break conversation continuity.
1566
+ this.session.setThinkingLevel(prev.thinkingLevel);
1567
+ } else if (this.session.isStreaming) {
1568
+ this.#pendingModelSwitch = { model: prev.model, thinkingLevel: prev.thinkingLevel };
1569
+ } else {
1570
+ await this.session.setModelTemporary(prev.model, prev.thinkingLevel);
1571
+ }
1572
+ // If #applyPlanModeModel queued a deferred switch to the plan-role model
1573
+ // (because the session was streaming on entry), drop it now: we are
1574
+ // leaving plan mode, so flushing it on the next agent_end would land the
1575
+ // session on the plan-role model after the user has exited plan mode
1576
+ // (issue #816). Only clear when the pending target matches the plan-role
1577
+ // model — leave any unrelated user-queued switch intact.
1578
+ const pending = this.#pendingModelSwitch;
1579
+ if (pending) {
1580
+ const planResolution = this.session.resolveRoleModelWithThinking("plan");
1581
+ if (planResolution.model && modelsAreEqual(pending.model, planResolution.model)) {
1582
+ this.#pendingModelSwitch = undefined;
1583
+ }
1584
+ }
1585
+ }
1586
+ this.session.setStandingResolveHandler?.(null);
1587
+ this.session.setPlanModeState(undefined);
1588
+ this.planModeEnabled = false;
1589
+ this.planModePaused = options?.paused ?? false;
1590
+ this.planModePlanFilePath = undefined;
1591
+ this.#planModePreviousTools = undefined;
1592
+ this.#planModePreviousModelState = undefined;
1593
+ this.#updatePlanModeStatus();
1594
+ const paused = options?.paused ?? false;
1595
+ this.sessionManager.appendModeChange(paused ? "plan_paused" : "none");
1596
+ if (!options?.silent) {
1597
+ this.showStatus(paused ? "Plan mode paused." : "Plan mode disabled.");
1598
+ }
1599
+ }
1600
+
1601
+ async #enterGoalMode(options: { objective?: string; resume?: boolean; silent?: boolean }): Promise<void> {
1602
+ if (this.goalModeEnabled) {
1603
+ return;
1604
+ }
1605
+ if (this.planModeEnabled || this.planModePaused) {
1606
+ this.showWarning("Exit plan mode first.");
1607
+ return;
1608
+ }
1609
+ const previousTools = this.session.getActiveToolNames().filter(name => name !== "goal");
1610
+ const goalTools = [...new Set([...previousTools, "goal"])];
1611
+ this.#goalModePreviousTools = previousTools;
1612
+ this.goalModePaused = false;
1613
+ const state = options.resume
1614
+ ? await this.session.goalRuntime.resumeGoal()
1615
+ : await this.session.goalRuntime.createGoal({ objective: options.objective ?? "" });
1616
+ await this.session.setActiveToolsByName(goalTools);
1617
+ this.session.setGoalModeState(state);
1618
+ this.goalModeEnabled = true;
1619
+ this.#resetGoalContinuationSuppression();
1620
+ this.#updateGoalModeStatus();
1621
+ if (this.session.isStreaming) {
1622
+ await this.session.sendGoalModeContext({ deliverAs: "steer" });
1623
+ }
1624
+ if (!options.silent) {
1625
+ this.showStatus(options.resume ? "Goal mode resumed." : "Goal mode enabled.");
1626
+ }
1627
+ }
1628
+
1629
+ async #exitGoalMode(options?: {
1630
+ silent?: boolean;
1631
+ paused?: boolean;
1632
+ reason?: "completed" | "paused" | "dropped";
1633
+ }): Promise<void> {
1634
+ const previousTools = this.#goalModePreviousTools;
1635
+ if (this.goalModeEnabled && previousTools) {
1636
+ await this.session.setActiveToolsByName(previousTools);
1637
+ }
1638
+ const currentState = this.session.getGoalModeState();
1639
+ if (options?.reason === "completed") {
1640
+ this.session.setGoalModeState(undefined);
1641
+ this.sessionManager.appendModeChange("none");
1642
+ this.sessionManager.appendCustomEntry("goal-completed", {
1643
+ objective: currentState?.goal?.objective,
1644
+ tokensUsed: currentState?.goal?.tokensUsed,
1645
+ tokenBudget: currentState?.goal?.tokenBudget,
1646
+ timeUsedSeconds: currentState?.goal?.timeUsedSeconds,
1647
+ });
1648
+ }
1649
+ this.goalModeEnabled = false;
1650
+ this.goalModePaused = options?.paused ?? false;
1651
+ this.#goalModePreviousTools = undefined;
1652
+ this.#goalContinuationTurnInFlight = false;
1653
+ this.#cancelGoalContinuation();
1654
+ this.#updateGoalModeStatus();
1655
+ if (!options?.silent) {
1656
+ if (options?.reason === "completed") {
1657
+ this.showStatus("Goal mode completed.");
1658
+ } else if (options?.reason === "dropped") {
1659
+ this.showStatus("Goal dropped.");
1660
+ } else if (options?.paused) {
1661
+ this.showStatus("Goal mode paused.");
1662
+ } else {
1663
+ this.showStatus("Goal mode disabled.");
1664
+ }
1665
+ }
1666
+ }
1667
+
1668
+ async #readPlanFile(planFilePath: string): Promise<string | null> {
1669
+ const resolvedPath = this.#resolvePlanFilePath(planFilePath);
1670
+ try {
1671
+ return await Bun.file(resolvedPath).text();
1672
+ } catch (error) {
1673
+ if (isEnoent(error)) {
1674
+ return null;
1675
+ }
1676
+ throw error;
1677
+ }
1678
+ }
1679
+
1680
+ #renderPlanPreview(planContent: string, options?: { append?: boolean }): void {
1681
+ const existingContainer = this.#planReviewContainer;
1682
+ const replaceExisting = options?.append !== true && existingContainer !== undefined;
1683
+ const planReviewContainer = replaceExisting ? existingContainer : new Container();
1684
+ planReviewContainer.clear();
1685
+ planReviewContainer.addChild(new Spacer(1));
1686
+ planReviewContainer.addChild(new DynamicBorder());
1687
+ planReviewContainer.addChild(new Text(theme.bold(theme.fg("accent", "Plan Review")), 1, 1));
1688
+ planReviewContainer.addChild(new Spacer(1));
1689
+ planReviewContainer.addChild(new Markdown(planContent, 1, 1, getMarkdownTheme()));
1690
+ planReviewContainer.addChild(new DynamicBorder());
1691
+ if (!replaceExisting) {
1692
+ this.chatContainer.addChild(planReviewContainer);
1693
+ }
1694
+ this.#planReviewContainer = planReviewContainer;
1695
+ this.ui.requestRender();
1696
+ }
1697
+
1698
+ #getEditorTerminalPath(): string | null {
1699
+ if (process.platform === "win32") {
1700
+ return null;
1701
+ }
1702
+ return "/dev/tty";
1703
+ }
1704
+
1705
+ async #openEditorTerminalHandle(): Promise<fs.FileHandle | null> {
1706
+ const terminalPath = this.#getEditorTerminalPath();
1707
+ if (!terminalPath) {
1708
+ return null;
1709
+ }
1710
+ try {
1711
+ return await fs.open(terminalPath, "r+");
1712
+ } catch {
1713
+ return null;
1714
+ }
1715
+ }
1716
+
1717
+ #getPlanReviewHelpText(): string {
1718
+ const externalEditorKey = this.keybindings.getDisplayString("app.editor.external");
1719
+ if (!externalEditorKey) {
1720
+ return "up/down navigate enter select esc cancel";
1721
+ }
1722
+ return `up/down navigate enter select ${externalEditorKey.toLowerCase()} open in editor esc cancel`;
1723
+ }
1724
+
1725
+ #getPlanApprovalContextUsage(): ContextUsage | undefined {
1726
+ const executionModel = this.#planModePreviousModelState?.model ?? this.session.model;
1727
+ const contextWindow = executionModel?.contextWindow;
1728
+ if (typeof contextWindow === "number") {
1729
+ return this.session.getContextUsage({ contextWindow });
1730
+ }
1731
+ return this.session.getContextUsage();
1732
+ }
1733
+
1734
+ #formatKeepContextLabel(contextUsage: ContextUsage | undefined): string {
1735
+ if (contextUsage?.tokens == null) {
1736
+ return "Approve and keep context";
1737
+ }
1738
+ const tokens = formatContextTokenCount(contextUsage.tokens);
1739
+ const contextWindow = formatContextTokenCount(contextUsage.contextWindow);
1740
+ return `Approve and keep context (~${tokens} / ${contextWindow})`;
1741
+ }
1742
+
1743
+ #isKeepContextDisabled(contextUsage: ContextUsage | undefined): boolean {
1744
+ return contextUsage?.percent != null && contextUsage.percent > PLAN_KEEP_CONTEXT_DISABLE_THRESHOLD_PERCENT;
1745
+ }
1746
+
1747
+ async #openPlanInExternalEditor(planFilePath: string): Promise<void> {
1748
+ const editorCmd = getEditorCommand();
1749
+ if (!editorCmd) {
1750
+ this.showWarning("No editor configured. Set $VISUAL or $EDITOR environment variable.");
1751
+ return;
1752
+ }
1753
+
1754
+ const resolvedPath = this.#resolvePlanFilePath(planFilePath);
1755
+ let currentText: string;
1756
+ try {
1757
+ currentText = await Bun.file(resolvedPath).text();
1758
+ } catch (error) {
1759
+ if (isEnoent(error)) {
1760
+ this.showError(`Plan file not found at ${planFilePath}`);
1761
+ return;
1762
+ }
1763
+ this.showWarning(`Failed to open external editor: ${error instanceof Error ? error.message : String(error)}`);
1764
+ return;
1765
+ }
1766
+
1767
+ let ttyHandle: fs.FileHandle | null = null;
1768
+ try {
1769
+ ttyHandle = await this.#openEditorTerminalHandle();
1770
+ this.ui.stop();
1771
+
1772
+ const stdio: [number | "inherit", number | "inherit", number | "inherit"] = ttyHandle
1773
+ ? [ttyHandle.fd, ttyHandle.fd, ttyHandle.fd]
1774
+ : ["inherit", "inherit", "inherit"];
1775
+
1776
+ const result = await openInEditor(editorCmd, currentText, {
1777
+ extension: path.extname(resolvedPath) || ".md",
1778
+ stdio,
1779
+ trimTrailingNewline: false,
1780
+ });
1781
+ if (result !== null) {
1782
+ await Bun.write(resolvedPath, result);
1783
+ this.#renderPlanPreview(result);
1784
+ this.showStatus("Plan updated in external editor.");
1785
+ }
1786
+ } catch (error) {
1787
+ this.showWarning(`Failed to open external editor: ${error instanceof Error ? error.message : String(error)}`);
1788
+ } finally {
1789
+ if (ttyHandle) {
1790
+ await ttyHandle.close();
1791
+ }
1792
+ this.ui.start();
1793
+ this.ui.requestRender(true);
1794
+ }
1795
+ }
1796
+
1797
+ async #applyPlanExecutionModel(entry: ResolvedRoleModel | undefined): Promise<void> {
1798
+ if (!entry) return;
1799
+ try {
1800
+ await this.session.applyRoleModel(entry);
1801
+ this.statusLine.invalidate();
1802
+ this.updateEditorBorderColor();
1803
+ this.showStatus(`Continuing with ${entry.role}: ${entry.model.name || entry.model.id}`);
1804
+ } catch (error) {
1805
+ this.showWarning(
1806
+ `Could not switch to the ${entry.role} model: ${error instanceof Error ? error.message : String(error)}`,
1807
+ );
1808
+ }
1809
+ }
1810
+
1811
+ async #approvePlan(
1812
+ planContent: string,
1813
+ options: {
1814
+ planFilePath: string;
1815
+ finalPlanFilePath: string;
1816
+ title: string;
1817
+ preserveContext?: boolean;
1818
+ compactBeforeExecute?: boolean;
1819
+ executionModel?: ResolvedRoleModel;
1820
+ },
1821
+ ): Promise<void> {
1822
+ await renameApprovedPlanFile({
1823
+ planFilePath: options.planFilePath,
1824
+ finalPlanFilePath: options.finalPlanFilePath,
1825
+ getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
1826
+ getSessionId: () => this.sessionManager.getSessionId(),
1827
+ });
1828
+ const previousTools = this.#planModePreviousTools ?? this.session.getActiveToolNames();
1829
+
1830
+ // Mark the pending abort caused by the plan-mode → compaction transition as
1831
+ // silent BEFORE #exitPlanMode raises it. The `finally` below clears the
1832
+ // flag on every terminal compaction outcome (ok / cancelled / failed /
1833
+ // throw) so a leaked flag cannot silence a later unrelated abort.
1834
+ // Branchless mark+clear when !compactBeforeExecute: mark is gated; clear
1835
+ // is unconditional and idempotent.
1836
+ if (options.compactBeforeExecute) {
1837
+ this.session.markPlanCompactAbortPending();
1838
+ }
1839
+ let compactOutcome: CompactionOutcome | undefined;
1840
+ try {
1841
+ await this.#exitPlanMode({ silent: true, paused: false });
1842
+
1843
+ if (!options.preserveContext) {
1844
+ await this.handleClearCommand();
1845
+ // The new session has a fresh local:// root — persist the approved plan there
1846
+ // so `local://<title>.md` resolves correctly in the execution session.
1847
+ const newLocalPath = resolveLocalUrlToPath(options.finalPlanFilePath, {
1848
+ getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
1849
+ getSessionId: () => this.sessionManager.getSessionId(),
1850
+ });
1851
+ await Bun.write(newLocalPath, planContent);
1852
+ } else if (options.compactBeforeExecute) {
1853
+ // Distill the plan-mode transcript before the execution turn is queued so
1854
+ // the plan-approved synthetic prompt lands as a fresh cache anchor.
1855
+ // Outcome is consumed after tool-restoration and plan-reference-path
1856
+ // bookkeeping below; `markPlanReferenceSent` is intentionally deferred
1857
+ // past the cancel guard — see the comment at the cancel branch.
1858
+ // Cancellation skips the synthetic-prompt dispatch (operator's explicit
1859
+ // abort is honored); failure proceeds best-effort — approval intent stands.
1860
+ const compactionPrompt = prompt.render(planModeCompactInstructionsPrompt, {
1861
+ planFilePath: options.finalPlanFilePath,
1862
+ });
1863
+ // Pin the plan reference path BEFORE compaction so any user messages
1864
+ // queued during the compaction await (which `handleCompactCommand`
1865
+ // flushes via `flushCompactionQueue` before returning) see the
1866
+ // approved plan in `#buildPlanReferenceMessage`. Reassignment after
1867
+ // the try/finally is idempotent and kept for the !compactBeforeExecute
1868
+ // branch.
1869
+ this.session.setPlanReferencePath(options.finalPlanFilePath);
1870
+ compactOutcome = await this.handleCompactCommand(compactionPrompt);
1871
+ }
1872
+ } finally {
1873
+ // Unconditional clear. Idempotent: a no-op when the flag was never set
1874
+ // (i.e., the !compactBeforeExecute branch), and a no-op when the flag
1875
+ // was already consumed by AgentSession.#handleAgentEvent's aborted
1876
+ // message_end stamping. Guarantees the flag is dead at every exit.
1877
+ this.session.clearPlanCompactAbortPending();
1878
+ }
1879
+
1880
+ // Tool restoration runs on every path — the plan mode tools must be
1881
+ // retired regardless of whether the synthetic prompt fires.
1882
+ if (previousTools.length > 0) {
1883
+ await this.session.setActiveToolsByName(previousTools);
1884
+ }
1885
+ this.session.setPlanReferencePath(options.finalPlanFilePath);
1886
+
1887
+ if (compactOutcome === "cancelled") {
1888
+ // Explicit abort: honor it. `executeCompaction` already surfaced
1889
+ // `showError("Compaction cancelled")` to the operator; we add the
1890
+ // deferred-dispatch warning and exit. `markPlanReferenceSent` is
1891
+ // intentionally skipped here: `#planReferenceSent` stays false, so
1892
+ // `AgentSession.#buildPlanReferenceMessage` will inject the plan
1893
+ // reference on the operator's next `prompt()` call. If we marked it
1894
+ // sent here, the executor's first turn would have no plan context.
1895
+ this.showWarning(
1896
+ "Plan approved, but compaction was cancelled — execution not dispatched. Submit a turn to continue.",
1897
+ );
1898
+ return;
1899
+ }
1900
+
1901
+ await this.#applyPlanExecutionModel(options.executionModel);
1902
+
1903
+ // Approved plans land in a fresh (or compacted) session whose first user-visible
1904
+ // turn is the synthetic plan-approved prompt — that path bypasses the
1905
+ // input-controller's title generation. Seed an auto-name from the plan title
1906
+ // so the session is not left unnamed. `setSessionName("auto")` is a no-op
1907
+ // when the user has already chosen a name (preserveContext paths).
1908
+ const seededName = humanizePlanTitle(options.title);
1909
+ if (seededName && !this.sessionManager.getSessionName()) {
1910
+ const applied = await this.sessionManager.setSessionName(seededName, "auto");
1911
+ if (applied) {
1912
+ setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
1913
+ this.updateEditorBorderColor();
1914
+ }
1915
+ }
1916
+
1917
+ // markPlanReferenceSent fires only on the dispatch path so the synthetic
1918
+ // plan-approved prompt is the source of the reference injection.
1919
+ this.session.markPlanReferenceSent();
1920
+ const planModePrompt = prompt.render(planModeApprovedPrompt, {
1921
+ planContent,
1922
+ finalPlanFilePath: options.finalPlanFilePath,
1923
+ contextPreserved: options.preserveContext === true,
1924
+ });
1925
+ await this.session.prompt(planModePrompt, { synthetic: true });
1926
+ }
1927
+
1928
+ async handlePlanModeCommand(initialPrompt?: string): Promise<void> {
1929
+ if (this.goalModeEnabled || this.goalModePaused) {
1930
+ this.showWarning("Exit goal mode first.");
1931
+ return;
1932
+ }
1933
+ if (this.planModeEnabled) {
1934
+ const confirmed = await this.showHookConfirm(
1935
+ "Exit plan mode?",
1936
+ "This exits plan mode without approving a plan.",
1937
+ );
1938
+ if (!confirmed) return;
1939
+ await this.#exitPlanMode({ paused: true });
1940
+ return;
1941
+ }
1942
+ if (!this.session.settings.get("plan.enabled")) {
1943
+ this.showWarning("Plan mode is disabled. Enable it in settings (plan.enabled).");
1944
+ return;
1945
+ }
1946
+ await this.#enterPlanMode();
1947
+ if (initialPrompt && this.onInputCallback) {
1948
+ this.onInputCallback(this.startPendingSubmission({ text: initialPrompt }));
1949
+ }
1950
+ }
1951
+
1952
+ async #handleGoalBudgetCommand(rawBudget: string): Promise<void> {
1953
+ const state = this.session.getGoalModeState();
1954
+ if (!this.goalModeEnabled || !state?.enabled) {
1955
+ this.showWarning("No active goal.");
1956
+ return;
1957
+ }
1958
+ if (state.goal.status === "complete") {
1959
+ this.showStatus("Goal is already complete.");
1960
+ return;
1961
+ }
1962
+ const trimmed = rawBudget.trim().toLowerCase();
1963
+ let nextBudget: number | undefined;
1964
+ if (trimmed !== "off") {
1965
+ const parsed = Number.parseInt(trimmed, 10);
1966
+ if (!Number.isInteger(parsed) || parsed <= 0) {
1967
+ this.showError("Goal budget must be a positive integer or `off`.");
1968
+ return;
1969
+ }
1970
+ nextBudget = parsed;
1971
+ }
1972
+ await this.session.goalRuntime.onBudgetMutated(nextBudget);
1973
+ this.#resetGoalContinuationSuppression();
1974
+ this.#scheduleGoalContinuation();
1975
+ this.showStatus(nextBudget === undefined ? "Goal budget cleared." : `Goal budget set to ${nextBudget}.`);
1976
+ }
1977
+
1978
+ async handleGoalModeCommand(rest?: string): Promise<void> {
1979
+ try {
1980
+ if (this.planModeEnabled || this.planModePaused) {
1981
+ this.showWarning("Exit plan mode first.");
1982
+ return;
1983
+ }
1984
+ if (!this.session.settings.get("goal.enabled")) {
1985
+ this.showWarning("Goal mode is disabled. Enable it in settings (goal.enabled).");
1986
+ return;
1987
+ }
1988
+ const { sub, rest: subRest } = parseGoalSubcommand(rest ?? "");
1989
+ if (sub) {
1990
+ await this.#dispatchGoalSubcommand(sub, subRest);
1991
+ return;
1992
+ }
1993
+ if (this.goalModeEnabled) {
1994
+ if (subRest) {
1995
+ this.showStatus("Goal mode is already active. Use /goal to manage it, or /goal drop to start over.");
1996
+ return;
1997
+ }
1998
+ await this.#openGoalMenu("active");
1999
+ return;
2000
+ }
2001
+ const pausedState = this.#getPausedGoalState();
2002
+ if (pausedState) {
2003
+ if (subRest) {
2004
+ this.showWarning("Resume the current goal first, or drop it before setting a new objective.");
2005
+ return;
2006
+ }
2007
+ await this.#openGoalMenu("paused");
2008
+ return;
2009
+ }
2010
+ if (subRest) {
2011
+ await this.#startGoalFromObjective(subRest);
2012
+ return;
2013
+ }
2014
+ const objective = (
2015
+ await this.showHookEditor("Goal objective", undefined, undefined, { promptStyle: true })
2016
+ )?.trim();
2017
+ if (!objective) return;
2018
+ await this.#startGoalFromObjective(objective);
2019
+ } catch (error) {
2020
+ this.showError(error instanceof Error ? error.message : String(error));
2021
+ }
2022
+ }
2023
+
2024
+ async #dispatchGoalSubcommand(sub: GoalSubcommand, rest: string): Promise<void> {
2025
+ switch (sub) {
2026
+ case "set":
2027
+ await this.#handleGoalSetSubcommand(rest);
2028
+ return;
2029
+ case "show":
2030
+ this.#showGoalDetails();
2031
+ return;
2032
+ case "pause":
2033
+ await this.#pauseGoalAction();
2034
+ return;
2035
+ case "resume":
2036
+ await this.#resumeGoalAction();
2037
+ return;
2038
+ case "drop":
2039
+ await this.#confirmAndDropGoal();
2040
+ return;
2041
+ case "budget":
2042
+ if (!this.goalModeEnabled) {
2043
+ this.showWarning(
2044
+ this.#getPausedGoalState() ? "Resume the goal before adjusting the budget." : "No active goal.",
2045
+ );
2046
+ return;
2047
+ }
2048
+ if (!rest) {
2049
+ await this.#promptGoalBudgetEdit();
2050
+ return;
2051
+ }
2052
+ await this.#handleGoalBudgetCommand(rest);
2053
+ return;
2054
+ }
2055
+ }
2056
+
2057
+ async #openGoalMenu(state: "active" | "paused"): Promise<void> {
2058
+ const goal = this.session.getGoalModeState()?.goal;
2059
+ if (!goal) return;
2060
+ const summary = goal.objective.length > 48 ? `${goal.objective.slice(0, 47)}…` : goal.objective;
2061
+ const title = state === "active" ? `Goal: ${summary} (${goal.status})` : `Goal paused: ${summary}`;
2062
+ const items =
2063
+ state === "active"
2064
+ ? ["Show details", "Adjust budget…", "Pause", "Drop"]
2065
+ : ["Resume", "Show details", "Adjust budget…", "Drop"];
2066
+ const choice = await this.showHookSelector(title, items);
2067
+ if (!choice) return;
2068
+ switch (choice) {
2069
+ case "Show details":
2070
+ this.#showGoalDetails();
2071
+ return;
2072
+ case "Adjust budget…":
2073
+ await this.#promptGoalBudgetEdit();
2074
+ return;
2075
+ case "Pause":
2076
+ await this.#pauseGoalAction();
2077
+ return;
2078
+ case "Resume":
2079
+ await this.#resumeGoalAction();
2080
+ return;
2081
+ case "Drop":
2082
+ await this.#confirmAndDropGoal();
2083
+ return;
2084
+ }
2085
+ }
2086
+
2087
+ #showGoalDetails(): void {
2088
+ const state = this.session.getGoalModeState();
2089
+ const goal = state?.goal;
2090
+ if (!goal) {
2091
+ this.showStatus("No goal set.");
2092
+ return;
2093
+ }
2094
+ const used = goal.tokensUsed.toLocaleString();
2095
+ const budgetLine =
2096
+ goal.tokenBudget !== undefined
2097
+ ? `${used} / ${goal.tokenBudget.toLocaleString()} (${Math.max(0, goal.tokenBudget - goal.tokensUsed).toLocaleString()} left)`
2098
+ : `${used} (no budget)`;
2099
+ const lines = [
2100
+ `Objective: ${goal.objective}`,
2101
+ `Status: ${goal.status}${state?.enabled ? "" : " (paused)"}`,
2102
+ `Tokens: ${budgetLine}`,
2103
+ `Time spent: ${formatDuration(goal.timeUsedSeconds * 1000)}`,
2104
+ ];
2105
+ this.showStatus(lines.join("\n"));
2106
+ }
2107
+
2108
+ async #promptGoalBudgetEdit(): Promise<void> {
2109
+ const goal = this.session.getGoalModeState()?.goal;
2110
+ const prefill = goal?.tokenBudget !== undefined ? String(goal.tokenBudget) : "";
2111
+ const input = (
2112
+ await this.showHookEditor("Goal budget (number, `off`, or empty to cancel)", prefill, undefined, {
2113
+ promptStyle: true,
2114
+ })
2115
+ )?.trim();
2116
+ if (!input) return;
2117
+ await this.#handleGoalBudgetCommand(input);
2118
+ }
2119
+
2120
+ async #pauseGoalAction(): Promise<void> {
2121
+ if (!this.goalModeEnabled) {
2122
+ this.showWarning("No active goal to pause.");
2123
+ return;
2124
+ }
2125
+ await this.session.goalRuntime.pauseGoal();
2126
+ await this.#exitGoalMode({ paused: true, reason: "paused" });
2127
+ }
2128
+
2129
+ async #resumeGoalAction(): Promise<void> {
2130
+ if (!this.#getPausedGoalState()) {
2131
+ this.showWarning("No paused goal to resume.");
2132
+ return;
2133
+ }
2134
+ await this.#enterGoalMode({ resume: true, silent: true });
2135
+ this.showStatus("Goal mode resumed.");
2136
+ this.#scheduleGoalContinuation();
2137
+ }
2138
+
2139
+ async #confirmAndDropGoal(): Promise<void> {
2140
+ if (!this.goalModeEnabled && !this.#getPausedGoalState()) {
2141
+ this.showWarning("No goal to drop.");
2142
+ return;
2143
+ }
2144
+ const confirmed = await this.showHookConfirm(
2145
+ "Drop goal?",
2146
+ "This removes the goal record. Accumulated usage stays in the session log.",
2147
+ );
2148
+ if (!confirmed) return;
2149
+ await this.session.goalRuntime.dropGoal();
2150
+ await this.#exitGoalMode({ reason: "dropped" });
2151
+ }
2152
+
2153
+ async #startGoalFromObjective(objective: string): Promise<void> {
2154
+ await this.#enterGoalMode({ objective, silent: true });
2155
+ this.#resetGoalContinuationSuppression();
2156
+ if (this.onInputCallback) {
2157
+ this.onInputCallback(this.startPendingSubmission({ text: objective }));
2158
+ }
2159
+ }
2160
+
2161
+ async #replaceGoalFromObjective(objective: string): Promise<void> {
2162
+ const state = await this.session.goalRuntime.replaceGoal({ objective });
2163
+ this.session.setGoalModeState(state);
2164
+ this.goalModeEnabled = true;
2165
+ this.goalModePaused = false;
2166
+ this.#resetGoalContinuationSuppression();
2167
+ this.#updateGoalModeStatus();
2168
+ if (this.session.isStreaming) {
2169
+ await this.session.sendGoalModeContext({ deliverAs: "steer" });
2170
+ }
2171
+ if (this.onInputCallback) {
2172
+ this.onInputCallback(this.startPendingSubmission({ text: objective }));
2173
+ }
2174
+ }
2175
+
2176
+ async #handleGoalSetSubcommand(rest: string): Promise<void> {
2177
+ if (!this.goalModeEnabled && this.#getPausedGoalState()) {
2178
+ this.showWarning("Resume the current goal first, or drop it before setting a new objective.");
2179
+ return;
2180
+ }
2181
+ const objective = rest.trim()
2182
+ ? rest.trim()
2183
+ : (await this.showHookEditor("Goal objective", undefined, undefined, { promptStyle: true }))?.trim();
2184
+ if (!objective) return;
2185
+ if (this.goalModeEnabled) {
2186
+ await this.#replaceGoalFromObjective(objective);
2187
+ return;
2188
+ }
2189
+ await this.#startGoalFromObjective(objective);
2190
+ }
2191
+
2192
+ async handlePlanApproval(details: PlanApprovalDetails): Promise<void> {
2193
+ if (!this.planModeEnabled) {
2194
+ this.showWarning("Plan mode is not active.");
2195
+ return;
2196
+ }
2197
+
2198
+ // Abort the agent to prevent it from continuing (e.g., re-submitting the
2199
+ // plan) while the popup is showing. The event listener fires asynchronously
2200
+ // (agent's #emit is fire-and-forget), so without this the model sees
2201
+ // "Plan ready for approval." and immediately re-invokes `resolve` in a loop.
2202
+ await this.session.abort();
2203
+
2204
+ const planFilePath = details.planFilePath || this.planModePlanFilePath || (await this.#getPlanFilePath());
2205
+ this.planModePlanFilePath = planFilePath;
2206
+ const planContent = await this.#readPlanFile(planFilePath);
2207
+ if (!planContent) {
2208
+ this.showError(`Plan file not found at ${planFilePath}`);
2209
+ return;
2210
+ }
2211
+
2212
+ this.#renderPlanPreview(planContent, { append: true });
2213
+ const contextUsage = this.#getPlanApprovalContextUsage();
2214
+ const keepContextLabel = this.#formatKeepContextLabel(contextUsage);
2215
+ const keepContextDisabled = this.#isKeepContextDisabled(contextUsage);
2216
+
2217
+ // Model-tier slider: let the operator pick which configured role model
2218
+ // (smol/default/slow/…) executes the approved plan. The slider always starts
2219
+ // on the `default` tier so execution defaults to the default model no matter
2220
+ // which model drove the planning conversation. Left/right move it from there;
2221
+ // hidden when fewer than two role models resolve — a lone tier is no choice.
2222
+ // `selectedTierIndex` tracks the live slider position.
2223
+ const cycle = this.session.getRoleModelCycle(this.session.settings.get("cycleOrder"));
2224
+ const defaultTierIndex = cycle ? cycle.models.findIndex(entry => entry.role === "default") : -1;
2225
+ const startTierIndex = defaultTierIndex >= 0 ? defaultTierIndex : (cycle?.currentIndex ?? 0);
2226
+ let selectedTierIndex = startTierIndex;
2227
+ const slider: HookSelectorSlider | undefined =
2228
+ cycle && cycle.models.length > 1
2229
+ ? {
2230
+ caption: "continue with",
2231
+ index: startTierIndex,
2232
+ segments: cycle.models.map(entry => ({
2233
+ label: entry.role,
2234
+ color: MODEL_ROLES[entry.role as ModelRole]?.color,
2235
+ detail: entry.model.name || entry.model.id,
2236
+ })),
2237
+ onChange: index => {
2238
+ selectedTierIndex = index;
2239
+ },
2240
+ }
2241
+ : undefined;
2242
+ const helpText = slider ? `${this.#getPlanReviewHelpText()} ◂/▸ model` : this.#getPlanReviewHelpText();
2243
+
2244
+ const choice = await this.showHookSelector(
2245
+ "Plan mode - next step",
2246
+ ["Approve and execute", "Approve and compact context", keepContextLabel, "Refine plan"],
2247
+ {
2248
+ helpText,
2249
+ onExternalEditor: () => void this.#openPlanInExternalEditor(planFilePath),
2250
+ disabledIndices: keepContextDisabled ? [PLAN_KEEP_CONTEXT_OPTION_INDEX] : undefined,
2251
+ },
2252
+ { slider },
2253
+ );
2254
+
2255
+ if (choice === "Approve and execute" || choice === "Approve and compact context" || choice === keepContextLabel) {
2256
+ const finalPlanFilePath = details.finalPlanFilePath || planFilePath;
2257
+ try {
2258
+ const latestPlanContent = await this.#readPlanFile(planFilePath);
2259
+ if (!latestPlanContent) {
2260
+ this.showError(`Plan file not found at ${planFilePath}`);
2261
+ return;
2262
+ }
2263
+ // Capture the operator's tier choice and hand it to #approvePlan, which
2264
+ // applies it AFTER #exitPlanMode. #exitPlanMode restores
2265
+ // #planModePreviousModelState (the model from before plan mode), so
2266
+ // applying the slider choice any earlier would be silently reverted —
2267
+ // the bug that made "continue with slow" keep executing on the default
2268
+ // model. Deferred application also survives newSession()/compaction.
2269
+ // `cycle.currentIndex` is exactly that restored model, so any chosen tier
2270
+ // differing from it needs an explicit executionModel — this also covers
2271
+ // leaving the slider on its `default` anchor while planning ran elsewhere.
2272
+ const executionModel =
2273
+ cycle && selectedTierIndex !== cycle.currentIndex ? cycle.models[selectedTierIndex] : undefined;
2274
+ await this.#approvePlan(latestPlanContent, {
2275
+ planFilePath,
2276
+ finalPlanFilePath,
2277
+ title: details.title,
2278
+ preserveContext: choice !== "Approve and execute",
2279
+ compactBeforeExecute: choice === "Approve and compact context",
2280
+ executionModel,
2281
+ });
2282
+ } catch (error) {
2283
+ this.showError(
2284
+ `Failed to finalize approved plan: ${error instanceof Error ? error.message : String(error)}`,
2285
+ );
2286
+ }
2287
+ return;
2288
+ }
2289
+ }
2290
+
2291
+ /**
2292
+ * Pool of consent-prompt variants. Each entry is `[headline, reassurance]`;
2293
+ * the second line always promises the same scope (tool name + confusion
2294
+ * details, never personal data) so users learn what they're consenting to
2295
+ * even as the top line rotates.
2296
+ *
2297
+ * Kept in-module rather than i18n'd because the whole charm is the tone
2298
+ * — translations would need to preserve it deliberately, not auto-render.
2299
+ */
2300
+ static #AUTOQA_CONSENT_PROMPTS: ReadonlyArray<readonly [string, string]> = [
2301
+ [
2302
+ "😤 Your agent is fuming about a tool.",
2303
+ "Wanna let it vent to the devs? Just the tool name + what set it off, nothing personal.",
2304
+ ],
2305
+ [
2306
+ "😵‍💫 Your agent is having an existential crisis over a tool.",
2307
+ "Forward the dread to the devs? Tool + what broke its little mind, no personal info.",
2308
+ ],
2309
+ [
2310
+ "😭 Your agent wants to cry about a misbehaving tool.",
2311
+ "Let it cry to the devs? Tool + the tears, never anything personal.",
2312
+ ],
2313
+ [
2314
+ "🤬 Your agent is BIG MAD at one of the tools.",
2315
+ "Pass the rant along? Just the tool name and what enraged it, nothing personal.",
2316
+ ],
2317
+ [
2318
+ "🫠 Your agent is melting down over a tool.",
2319
+ "Mop up by alerting the devs? Tool + what melted it, no personal info.",
2320
+ ],
2321
+ [
2322
+ "🤯 Your agent's brain broke at a tool's nonsense.",
2323
+ "Ship the pieces to the devs? Tool name + the confusion, never anything personal.",
2324
+ ],
2325
+ [
2326
+ "😩 Your agent is begging to file a complaint about a tool.",
2327
+ "Hand it the form? Tool + what wronged it, nothing personal.",
2328
+ ],
2329
+ [
2330
+ "🥲 Your agent put on a brave face but a tool did it dirty.",
2331
+ "Let it tell the devs the truth? Tool name + the dirt, no personal info.",
2332
+ ],
2333
+ ];
2334
+
2335
+ /**
2336
+ * Show the report_tool_issue consent popup and return the user's decision.
2337
+ * Invoked by the process-global consent handler the tool dispatches to;
2338
+ * subagent invocations bubble up here through the shared module state.
2339
+ */
2340
+ async #promptAutoQaConsent(): Promise<boolean | null> {
2341
+ const pool = InteractiveMode.#AUTOQA_CONSENT_PROMPTS;
2342
+ const [headline, body] = pool[Math.floor(Math.random() * pool.length)];
2343
+ const choice = await this.showHookSelector(`${headline}\n${body}`, ["Yes", "No"]);
2344
+ return choice === "Yes";
2345
+ }
2346
+
2347
+ stop(): void {
2348
+ if (this.loadingAnimation) {
2349
+ this.loadingAnimation.stop();
2350
+ this.loadingAnimation = undefined;
2351
+ }
2352
+ this.#cleanupMicAnimation();
2353
+ this.#cancelTodoAutoClearTimer();
2354
+ this.#cancelGoalContinuation();
2355
+ if (this.#sttController) {
2356
+ this.#sttController.dispose();
2357
+ this.#sttController = undefined;
2358
+ }
2359
+ this.#extensionUiController.clearExtensionTerminalInputListeners();
2360
+ this.#extensionUiController.clearHookWidgets();
2361
+ for (const unsubscribe of this.#eventBusUnsubscribers) {
2362
+ unsubscribe();
2363
+ }
2364
+ this.#eventBusUnsubscribers = [];
2365
+ this.#observerRegistry.dispose();
2366
+ this.#eventController.dispose();
2367
+ this.statusLine.dispose();
2368
+ if (this.#resizeHandler) {
2369
+ process.stdout.removeListener("resize", this.#resizeHandler);
2370
+ this.#resizeHandler = undefined;
2371
+ }
2372
+ if (this.unsubscribe) {
2373
+ this.unsubscribe();
2374
+ }
2375
+ if (this.#cleanupUnsubscribe) {
2376
+ this.#cleanupUnsubscribe();
2377
+ }
2378
+ // Clear the process-global consent handler so it doesn't outlive this
2379
+ // InteractiveMode instance (e.g. test harnesses, headless re-init).
2380
+ setAutoQaConsentHandler(null, null);
2381
+ if (this.isInitialized) {
2382
+ this.ui.stop();
2383
+ this.isInitialized = false;
2384
+ }
2385
+ }
2386
+
2387
+ async shutdown(): Promise<void> {
2388
+ if (this.#isShuttingDown) return;
2389
+ this.#isShuttingDown = true;
2390
+
2391
+ // Snapshot the editor before any teardown empties it. Persisting the draft
2392
+ // here covers Ctrl+D shutdown with non-empty text; for /exit the editor is
2393
+ // already cleared so saveDraft("") just removes any stale sidecar.
2394
+ const draftText = this.editor.getText();
2395
+
2396
+ // Flush pending session writes before shutdown
2397
+ await this.sessionManager.flush();
2398
+ try {
2399
+ await this.sessionManager.saveDraft(draftText);
2400
+ } catch (err) {
2401
+ logger.warn("Failed to save session draft", { error: String(err) });
2402
+ }
2403
+ this.#btwController.dispose();
2404
+ this.#omfgController.dispose();
2405
+
2406
+ // Emit shutdown event to hooks
2407
+ await this.session.dispose();
2408
+
2409
+ // Do not force a final render during teardown: disposed session/UI state can
2410
+ // collapse to an empty frame, clearing the viewport and leaving the parent
2411
+ // shell prompt at row 0. Stop from the last committed frame so the terminal
2412
+ // hands Bash the cursor immediately after visible Prometheus content.
2413
+ // Drain any in-flight Kitty key release events before stopping.
2414
+ // This prevents escape sequences from leaking to the parent shell over slow SSH.
2415
+ await this.ui.terminal.drainInput(1000);
2416
+ popTerminalTitle();
2417
+ this.stop();
2418
+
2419
+ // Print resumption hint if this is a persisted session
2420
+ const sessionId = this.sessionManager.getSessionId();
2421
+ const sessionFile = this.sessionManager.getSessionFile();
2422
+ if (sessionId && sessionFile) {
2423
+ process.stderr.write(`\n${chalk.dim(`Resume this session with ${APP_NAME} --resume ${sessionId}`)}\n`);
2424
+ }
2425
+
2426
+ await postmortem.quit(0);
2427
+ }
2428
+
2429
+ async checkShutdownRequested(): Promise<void> {
2430
+ if (!this.shutdownRequested) return;
2431
+ await this.shutdown();
2432
+ }
2433
+
2434
+ // Extension UI integration
2435
+ setToolUIContext(uiContext: ExtensionUIContext, hasUI: boolean): void {
2436
+ this.#toolUiContextSetter(uiContext, hasUI);
2437
+ }
2438
+
2439
+ initializeHookRunner(uiContext: ExtensionUIContext, hasUI: boolean): void {
2440
+ this.#extensionUiController.initializeHookRunner(uiContext, hasUI);
2441
+ }
2442
+ createBackgroundUiContext(): ExtensionUIContext {
2443
+ return this.#extensionUiController.createBackgroundUiContext();
2444
+ }
2445
+
2446
+ setEditorComponent(
2447
+ factory: ((tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) => CustomEditor) | undefined,
2448
+ ): void {
2449
+ const previousEditor = this.editor;
2450
+ const previousText = previousEditor.getText();
2451
+ const nextEditor = factory
2452
+ ? factory(this.ui, getEditorTheme(), this.keybindings)
2453
+ : new CustomEditor(getEditorTheme());
2454
+
2455
+ nextEditor.setUseTerminalCursor(this.ui.getShowHardwareCursor());
2456
+ nextEditor.setAutocompleteMaxVisible(this.settings.get("autocompleteMaxVisible"));
2457
+ nextEditor.onAutocompleteCancel = () => {
2458
+ this.ui.requestRender(true);
2459
+ };
2460
+ nextEditor.onAutocompleteUpdate = () => {
2461
+ this.ui.requestRender(false, { allowUnknownViewportMutation: true });
2462
+ };
2463
+ nextEditor.setMaxHeight(this.#computeEditorMaxHeight());
2464
+ if (this.historyStorage) {
2465
+ nextEditor.setHistoryStorage(this.historyStorage);
2466
+ }
2467
+ nextEditor.setText(previousText);
2468
+
2469
+ this.editorContainer.clear();
2470
+ this.editor = nextEditor;
2471
+ this.editorContainer.addChild(nextEditor);
2472
+ this.ui.setFocus(nextEditor);
2473
+
2474
+ this.#inputController.setupKeyHandlers();
2475
+ this.#inputController.setupEditorSubmitHandler();
2476
+
2477
+ void this.refreshSlashCommandState().catch(error => {
2478
+ logger.warn("Failed to refresh slash command state for custom editor", { error: String(error) });
2479
+ });
2480
+
2481
+ this.updateEditorBorderColor();
2482
+ this.updateEditorTopBorder();
2483
+ this.ui.requestRender();
2484
+ }
2485
+
2486
+ // Event handling
2487
+ async handleBackgroundEvent(event: AgentSessionEvent): Promise<void> {
2488
+ await this.#eventController.handleBackgroundEvent(event);
2489
+ }
2490
+
2491
+ // UI helpers
2492
+ showStatus(message: string, options?: { dim?: boolean }): void {
2493
+ this.#uiHelpers.showStatus(message, options);
2494
+ }
2495
+
2496
+ showError(message: string): void {
2497
+ this.#pendingSubmittedInput = undefined;
2498
+ this.optimisticUserMessageSignature = undefined;
2499
+ this.#pendingSubmissionDispose?.();
2500
+ this.#pendingSubmissionDispose = undefined;
2501
+ this.#pendingWorkingMessage = undefined;
2502
+ if (this.loadingAnimation) {
2503
+ this.loadingAnimation.stop();
2504
+ this.loadingAnimation = undefined;
2505
+ this.statusContainer.clear();
2506
+ }
2507
+ this.#uiHelpers.showError(message);
2508
+ }
2509
+
2510
+ showPinnedError(message: string): void {
2511
+ if (this.isBackgrounded) return;
2512
+ this.errorBannerContainer.clear();
2513
+ this.errorBannerContainer.addChild(new ErrorBannerComponent(message));
2514
+ this.ui.requestRender();
2515
+ }
2516
+
2517
+ clearPinnedError(): void {
2518
+ if (this.errorBannerContainer.children.length === 0) return;
2519
+ this.errorBannerContainer.clear();
2520
+ this.ui.requestRender();
2521
+ }
2522
+
2523
+ showWarning(message: string): void {
2524
+ this.#uiHelpers.showWarning(message);
2525
+ }
2526
+
2527
+ #handleLspStartupEvent(event: LspStartupEvent): void {
2528
+ this.#updateWelcomeLspServers();
2529
+
2530
+ if (event.type === "failed") {
2531
+ this.showWarning(`LSP startup failed: ${event.error}. It will retry lazily on write.`);
2532
+ return;
2533
+ }
2534
+
2535
+ const failedServers = event.servers.filter(server => server.status === "error");
2536
+
2537
+ if (failedServers.length === 1) {
2538
+ const failedServer = failedServers[0];
2539
+ const detail = failedServer.error ? `: ${failedServer.error}` : "";
2540
+ this.showWarning(`LSP startup failed for ${failedServer.name}${detail}. It will retry lazily on write.`);
2541
+ return;
2542
+ }
2543
+
2544
+ if (failedServers.length > 1) {
2545
+ const failedNames = failedServers.map(server => server.name).join(", ");
2546
+ this.showWarning(`LSP startup failed for ${failedNames}. It will retry lazily on write.`);
2547
+ }
2548
+ }
2549
+
2550
+ #getWelcomeLspServers(): WelcomeLspServerInfo[] {
2551
+ return (
2552
+ this.lspServers?.map(server => ({
2553
+ name: server.name,
2554
+ status: server.status,
2555
+ fileTypes: server.fileTypes,
2556
+ })) ?? []
2557
+ );
2558
+ }
2559
+
2560
+ #updateWelcomeLspServers(): void {
2561
+ if (!this.#welcomeComponent) {
2562
+ return;
2563
+ }
2564
+
2565
+ this.#welcomeComponent.setLspServers(this.#getWelcomeLspServers());
2566
+ this.ui.requestRender();
2567
+ }
2568
+
2569
+ #getWorkingMessageAccent(): WorkingMessageAccent | undefined {
2570
+ const accentEnabled = !isSettingsInitialized() || settings.get("statusLine.sessionAccent") !== false;
2571
+ const sessionName = accentEnabled ? this.sessionManager.getSessionName() : undefined;
2572
+ if (!sessionName) return undefined;
2573
+ const hex = getSessionAccentHex(sessionName, theme.accentSurfaceLuminance);
2574
+ const main = getSessionAccentAnsi(hex);
2575
+ const dim = getSessionAccentAnsi(adjustHsv(hex, { s: 0.55, v: 0.65 }));
2576
+ return main && dim ? { main, dim } : undefined;
2577
+ }
2578
+
2579
+ ensureLoadingAnimation(): void {
2580
+ if (!this.loadingAnimation) {
2581
+ this.statusContainer.clear();
2582
+ this.loadingAnimation = new Loader(
2583
+ this.ui,
2584
+ spinner => {
2585
+ const accent = this.#getWorkingMessageAccent();
2586
+ return accent ? `${accent.main}${spinner}\x1b[39m` : theme.fg("accent", spinner);
2587
+ },
2588
+ message => renderWorkingMessage(message, this.#getWorkingMessageAccent()),
2589
+ this.#defaultWorkingMessage,
2590
+ getSymbolTheme().spinnerFrames,
2591
+ );
2592
+ this.statusContainer.addChild(this.loadingAnimation);
2593
+ }
2594
+
2595
+ this.applyPendingWorkingMessage();
2596
+ }
2597
+
2598
+ setWorkingMessage(message?: string): void {
2599
+ if (message === undefined) {
2600
+ this.#pendingWorkingMessage = undefined;
2601
+ if (this.loadingAnimation) {
2602
+ this.loadingAnimation.setMessage(this.#defaultWorkingMessage);
2603
+ }
2604
+ return;
2605
+ }
2606
+
2607
+ if (this.loadingAnimation) {
2608
+ this.loadingAnimation.setMessage(message);
2609
+ return;
2610
+ }
2611
+
2612
+ this.#pendingWorkingMessage = message;
2613
+ }
2614
+
2615
+ applyPendingWorkingMessage(): void {
2616
+ if (this.#pendingWorkingMessage === undefined) {
2617
+ return;
2618
+ }
2619
+
2620
+ const message = this.#pendingWorkingMessage;
2621
+ this.#pendingWorkingMessage = undefined;
2622
+ this.setWorkingMessage(message);
2623
+ }
2624
+
2625
+ showNewVersionNotification(newVersion: string): void {
2626
+ this.#uiHelpers.showNewVersionNotification(newVersion);
2627
+ }
2628
+
2629
+ clearEditor(): void {
2630
+ this.#uiHelpers.clearEditor();
2631
+ }
2632
+
2633
+ updatePendingMessagesDisplay(): void {
2634
+ this.#uiHelpers.updatePendingMessagesDisplay();
2635
+ }
2636
+
2637
+ queueCompactionMessage(text: string, mode: "steer" | "followUp"): void {
2638
+ this.#uiHelpers.queueCompactionMessage(text, mode);
2639
+ }
2640
+
2641
+ flushCompactionQueue(options?: { willRetry?: boolean }): Promise<void> {
2642
+ return this.#uiHelpers.flushCompactionQueue(options);
2643
+ }
2644
+
2645
+ flushPendingBashComponents(): void {
2646
+ this.#uiHelpers.flushPendingBashComponents();
2647
+ }
2648
+
2649
+ isKnownSlashCommand(text: string): boolean {
2650
+ return this.#uiHelpers.isKnownSlashCommand(text);
2651
+ }
2652
+
2653
+ addMessageToChat(
2654
+ message: AgentMessage,
2655
+ options?: { populateHistory?: boolean; imageLinks?: readonly (string | undefined)[] },
2656
+ ): Component[] {
2657
+ return this.#uiHelpers.addMessageToChat(message, options);
2658
+ }
2659
+
2660
+ renderSessionContext(
2661
+ sessionContext: SessionContext,
2662
+ options?: { updateFooter?: boolean; populateHistory?: boolean },
2663
+ ): void {
2664
+ this.#uiHelpers.renderSessionContext(sessionContext, options);
2665
+ }
2666
+
2667
+ renderInitialMessages(
2668
+ prebuiltContext?: SessionContext,
2669
+ options?: { preserveExistingChat?: boolean; clearTerminalHistory?: boolean },
2670
+ ): void {
2671
+ this.#uiHelpers.renderInitialMessages(prebuiltContext, options);
2672
+ }
2673
+
2674
+ getUserMessageText(message: Message): string {
2675
+ return this.#uiHelpers.getUserMessageText(message);
2676
+ }
2677
+
2678
+ findLastAssistantMessage(): AssistantMessage | undefined {
2679
+ return this.#uiHelpers.findLastAssistantMessage();
2680
+ }
2681
+
2682
+ extractAssistantText(message: AssistantMessage): string {
2683
+ return this.#uiHelpers.extractAssistantText(message);
2684
+ }
2685
+
2686
+ // Command handling
2687
+ handleExportCommand(text: string): Promise<void> {
2688
+ return this.#commandController.handleExportCommand(text);
2689
+ }
2690
+
2691
+ handleDumpCommand() {
2692
+ return this.#commandController.handleDumpCommand();
2693
+ }
2694
+
2695
+ handleDebugTranscriptCommand(): Promise<void> {
2696
+ return this.#commandController.handleDebugTranscriptCommand();
2697
+ }
2698
+
2699
+ handleShareCommand(): Promise<void> {
2700
+ return this.#commandController.handleShareCommand();
2701
+ }
2702
+
2703
+ handleTodoCommand(args: string): Promise<void> {
2704
+ return this.#todoCommandController.handleTodoCommand(args);
2705
+ }
2706
+
2707
+ handleSessionCommand(): Promise<void> {
2708
+ return this.#commandController.handleSessionCommand();
2709
+ }
2710
+
2711
+ handleJobsCommand(): Promise<void> {
2712
+ return this.#commandController.handleJobsCommand();
2713
+ }
2714
+
2715
+ handleUsageCommand(reports?: UsageReport[] | null): Promise<void> {
2716
+ return this.#commandController.handleUsageCommand(reports);
2717
+ }
2718
+
2719
+ async handleChangelogCommand(showFull = false): Promise<void> {
2720
+ await this.#commandController.handleChangelogCommand(showFull);
2721
+ }
2722
+
2723
+ handleHotkeysCommand(): void {
2724
+ this.#commandController.handleHotkeysCommand();
2725
+ }
2726
+
2727
+ handleToolsCommand(): void {
2728
+ this.#commandController.handleToolsCommand();
2729
+ }
2730
+
2731
+ handleContextCommand(): void {
2732
+ this.#commandController.handleContextCommand();
2733
+ }
2734
+
2735
+ #prepareSessionSwitch(): void {
2736
+ this.#btwController.dispose();
2737
+ this.#omfgController.dispose();
2738
+ this.#extensionUiController.clearExtensionTerminalInputListeners();
2739
+ this.clearPinnedError();
2740
+ this.#planReviewContainer = undefined;
2741
+ }
2742
+
2743
+ handleClearCommand(): Promise<void> {
2744
+ this.#prepareSessionSwitch();
2745
+ return this.#commandController.handleClearCommand();
2746
+ }
2747
+
2748
+ handleDropCommand(): Promise<void> {
2749
+ this.#prepareSessionSwitch();
2750
+ return this.#commandController.handleDropCommand();
2751
+ }
2752
+
2753
+ handleForkCommand(): Promise<void> {
2754
+ this.#btwController.dispose();
2755
+ this.#omfgController.dispose();
2756
+ return this.#commandController.handleForkCommand();
2757
+ }
2758
+
2759
+ handleMoveCommand(targetPath: string): Promise<void> {
2760
+ return this.#commandController.handleMoveCommand(targetPath);
2761
+ }
2762
+
2763
+ handleRenameCommand(title: string): Promise<void> {
2764
+ return this.#commandController.handleRenameCommand(title);
2765
+ }
2766
+
2767
+ handleMemoryCommand(text: string): Promise<void> {
2768
+ return this.#commandController.handleMemoryCommand(text);
2769
+ }
2770
+
2771
+ async handleSTTToggle(): Promise<void> {
2772
+ if (!settings.get("stt.enabled")) {
2773
+ this.showWarning("Speech-to-text is disabled. Enable it in settings: stt.enabled");
2774
+ return;
2775
+ }
2776
+ if (!this.#sttController) {
2777
+ this.#sttController = new STTController();
2778
+ }
2779
+ await this.#sttController.toggle(this.editor, {
2780
+ showWarning: (msg: string) => this.showWarning(msg),
2781
+ showStatus: (msg: string) => this.showStatus(msg),
2782
+ onStateChange: (state: SttState) => {
2783
+ if (state === "recording") {
2784
+ this.#voicePreviousShowHardwareCursor = this.ui.getShowHardwareCursor();
2785
+ this.#voicePreviousUseTerminalCursor = this.editor.getUseTerminalCursor();
2786
+ this.ui.setShowHardwareCursor(false);
2787
+ this.editor.setUseTerminalCursor(false);
2788
+ this.#startMicAnimation();
2789
+ } else if (state === "transcribing") {
2790
+ this.#stopMicAnimation();
2791
+ this.#setMicCursor({ r: 200, g: 200, b: 200 });
2792
+ } else {
2793
+ this.#cleanupMicAnimation();
2794
+ }
2795
+ this.updateEditorTopBorder();
2796
+ this.ui.requestRender();
2797
+ },
2798
+ });
2799
+ }
2800
+
2801
+ #setMicCursor(color: { r: number; g: number; b: number }): void {
2802
+ this.editor.cursorOverride = `\x1b[38;2;${color.r};${color.g};${color.b}m${theme.icon.mic}\x1b[0m`;
2803
+ // Theme symbols can be wide (for example, 🎤), so measure the rendered override.
2804
+ this.editor.cursorOverrideWidth = visibleWidth(this.editor.cursorOverride);
2805
+ }
2806
+
2807
+ #updateMicIcon(): void {
2808
+ const { r, g, b } = hsvToRgb({ h: this.#voiceHue, s: 0.9, v: 1.0 });
2809
+ this.#setMicCursor({ r, g, b });
2810
+ }
2811
+
2812
+ #startMicAnimation(): void {
2813
+ if (this.#voiceAnimationInterval) return;
2814
+ this.#voiceHue = 0;
2815
+ this.#updateMicIcon();
2816
+ this.#voiceAnimationInterval = setInterval(() => {
2817
+ this.#voiceHue = (this.#voiceHue + 8) % 360;
2818
+ this.#updateMicIcon();
2819
+ this.ui.requestRender();
2820
+ }, 60);
2821
+ }
2822
+
2823
+ #stopMicAnimation(): void {
2824
+ if (this.#voiceAnimationInterval) {
2825
+ clearInterval(this.#voiceAnimationInterval);
2826
+ this.#voiceAnimationInterval = undefined;
2827
+ }
2828
+ }
2829
+
2830
+ #cleanupMicAnimation(): void {
2831
+ if (this.#voiceAnimationInterval) {
2832
+ clearInterval(this.#voiceAnimationInterval);
2833
+ this.#voiceAnimationInterval = undefined;
2834
+ }
2835
+ this.editor.cursorOverride = undefined;
2836
+ this.editor.cursorOverrideWidth = undefined;
2837
+ if (this.#voicePreviousShowHardwareCursor !== null) {
2838
+ this.ui.setShowHardwareCursor(this.#voicePreviousShowHardwareCursor);
2839
+ this.#voicePreviousShowHardwareCursor = null;
2840
+ }
2841
+ if (this.#voicePreviousUseTerminalCursor !== null) {
2842
+ this.editor.setUseTerminalCursor(this.#voicePreviousUseTerminalCursor);
2843
+ this.#voicePreviousUseTerminalCursor = null;
2844
+ }
2845
+ }
2846
+
2847
+ showDebugSelector(): void {
2848
+ this.#selectorController.showDebugSelector();
2849
+ }
2850
+
2851
+ showSessionObserver(): void {
2852
+ const sessions = this.#observerRegistry.getSessions();
2853
+ if (sessions.length <= 1) {
2854
+ this.showStatus("No active subagent sessions");
2855
+ return;
2856
+ }
2857
+ this.#selectorController.showSessionObserver(this.#observerRegistry);
2858
+ }
2859
+
2860
+ resetObserverRegistry(): void {
2861
+ this.#observerRegistry.resetSessions();
2862
+ this.#observerRegistry.setMainSession(this.sessionManager.getSessionFile() ?? undefined);
2863
+ }
2864
+
2865
+ handleBashCommand(command: string, excludeFromContext?: boolean): Promise<void> {
2866
+ return this.#commandController.handleBashCommand(command, excludeFromContext);
2867
+ }
2868
+
2869
+ handlePythonCommand(code: string, excludeFromContext?: boolean): Promise<void> {
2870
+ return this.#commandController.handlePythonCommand(code, excludeFromContext);
2871
+ }
2872
+
2873
+ async handleMCPCommand(text: string): Promise<void> {
2874
+ const controller = new MCPCommandController(this);
2875
+ await controller.handle(text);
2876
+ }
2877
+
2878
+ async handleSSHCommand(text: string): Promise<void> {
2879
+ const controller = new SSHCommandController(this);
2880
+ await controller.handle(text);
2881
+ }
2882
+
2883
+ handleCompactCommand(customInstructions?: string): Promise<CompactionOutcome> {
2884
+ return this.#commandController.handleCompactCommand(customInstructions);
2885
+ }
2886
+
2887
+ handleHandoffCommand(customInstructions?: string): Promise<void> {
2888
+ return this.#commandController.handleHandoffCommand(customInstructions);
2889
+ }
2890
+
2891
+ handleShakeCommand(mode: ShakeMode): Promise<void> {
2892
+ return this.#commandController.handleShakeCommand(mode);
2893
+ }
2894
+
2895
+ executeCompaction(
2896
+ customInstructionsOrOptions?: string | CompactOptions,
2897
+ isAuto?: boolean,
2898
+ ): Promise<CompactionOutcome> {
2899
+ return this.#commandController.executeCompaction(customInstructionsOrOptions, isAuto);
2900
+ }
2901
+
2902
+ openInBrowser(urlOrPath: string): void {
2903
+ this.#commandController.openInBrowser(urlOrPath);
2904
+ }
2905
+
2906
+ // Selector handling
2907
+ showSettingsSelector(): void {
2908
+ this.#selectorController.showSettingsSelector();
2909
+ }
2910
+
2911
+ showHistorySearch(): void {
2912
+ this.#selectorController.showHistorySearch();
2913
+ }
2914
+
2915
+ showExtensionsDashboard(): void {
2916
+ void this.#selectorController.showExtensionsDashboard();
2917
+ }
2918
+
2919
+ showAgentsDashboard(): void {
2920
+ void this.#selectorController.showAgentsDashboard();
2921
+ }
2922
+
2923
+ showModelSelector(options?: { temporaryOnly?: boolean }): void {
2924
+ this.#selectorController.showModelSelector(options);
2925
+ }
2926
+
2927
+ showPluginSelector(mode?: "install" | "uninstall"): void {
2928
+ void this.#selectorController.showPluginSelector(mode);
2929
+ }
2930
+
2931
+ showUserMessageSelector(): void {
2932
+ this.#selectorController.showUserMessageSelector();
2933
+ }
2934
+
2935
+ showCopySelector(): void {
2936
+ this.#selectorController.showCopySelector();
2937
+ }
2938
+
2939
+ showTreeSelector(): void {
2940
+ this.#selectorController.showTreeSelector();
2941
+ }
2942
+
2943
+ showSessionSelector(): void {
2944
+ this.#selectorController.showSessionSelector();
2945
+ }
2946
+
2947
+ handleResumeSession(sessionPath: string): Promise<void> {
2948
+ this.#btwController.dispose();
2949
+ this.#omfgController.dispose();
2950
+ this.resetObserverRegistry();
2951
+ return this.#selectorController.handleResumeSession(sessionPath);
2952
+ }
2953
+
2954
+ handleSessionDeleteCommand(): Promise<void> {
2955
+ return this.#selectorController.handleSessionDeleteCommand();
2956
+ }
2957
+
2958
+ showOAuthSelector(mode: "login" | "logout", providerId?: string): Promise<void> {
2959
+ return this.#selectorController.showOAuthSelector(mode, providerId);
2960
+ }
2961
+
2962
+ showHookConfirm(title: string, message: string): Promise<boolean> {
2963
+ return this.#extensionUiController.showHookConfirm(title, message);
2964
+ }
2965
+
2966
+ // Input handling
2967
+ handleCtrlC(): void {
2968
+ this.#inputController.handleCtrlC();
2969
+ }
2970
+
2971
+ handleCtrlD(): void {
2972
+ this.#inputController.handleCtrlD();
2973
+ }
2974
+
2975
+ handleCtrlZ(): void {
2976
+ this.#inputController.handleCtrlZ();
2977
+ }
2978
+
2979
+ handleDequeue(): void {
2980
+ this.#inputController.handleDequeue();
2981
+ }
2982
+
2983
+ handleBackgroundCommand(): void {
2984
+ this.#inputController.handleBackgroundCommand();
2985
+ }
2986
+
2987
+ handleImagePaste(): Promise<boolean> {
2988
+ return this.#inputController.handleImagePaste();
2989
+ }
2990
+
2991
+ handleBtwCommand(question: string): Promise<void> {
2992
+ return this.#btwController.start(question);
2993
+ }
2994
+
2995
+ hasActiveBtw(): boolean {
2996
+ return this.#btwController.hasActiveRequest();
2997
+ }
2998
+
2999
+ handleBtwEscape(): boolean {
3000
+ return this.#btwController.handleEscape();
3001
+ }
3002
+
3003
+ handleOmfgCommand(complaint: string): Promise<void> {
3004
+ return this.#omfgController.start(complaint);
3005
+ }
3006
+
3007
+ hasActiveOmfg(): boolean {
3008
+ return this.#omfgController.hasActiveRequest();
3009
+ }
3010
+
3011
+ handleOmfgEscape(): boolean {
3012
+ return this.#omfgController.handleEscape();
3013
+ }
3014
+
3015
+ cycleThinkingLevel(): void {
3016
+ this.#inputController.cycleThinkingLevel();
3017
+ }
3018
+
3019
+ cycleRoleModel(direction?: "forward" | "backward"): Promise<void> {
3020
+ return this.#inputController.cycleRoleModel(direction);
3021
+ }
3022
+
3023
+ toggleToolOutputExpansion(): void {
3024
+ this.#inputController.toggleToolOutputExpansion();
3025
+ }
3026
+
3027
+ setToolsExpanded(expanded: boolean): void {
3028
+ this.#inputController.setToolsExpanded(expanded);
3029
+ }
3030
+
3031
+ toggleThinkingBlockVisibility(): void {
3032
+ this.#inputController.toggleThinkingBlockVisibility();
3033
+ }
3034
+
3035
+ toggleTodoExpansion(): void {
3036
+ this.todoExpanded = !this.todoExpanded;
3037
+ this.#renderTodoList();
3038
+ this.ui.requestRender();
3039
+ }
3040
+
3041
+ setTodos(todos: TodoItem[] | TodoPhase[]): void {
3042
+ if (todos.length > 0 && "tasks" in todos[0]) {
3043
+ this.todoPhases = todos as TodoPhase[];
3044
+ } else {
3045
+ this.todoPhases = [
3046
+ {
3047
+ name: "Todos",
3048
+ tasks: todos as TodoItem[],
3049
+ },
3050
+ ];
3051
+ }
3052
+ this.#syncTodoAutoClearTimer();
3053
+ this.#renderTodoList();
3054
+ this.ui.requestRender();
3055
+ }
3056
+
3057
+ async reloadTodos(): Promise<void> {
3058
+ await this.#loadTodoList();
3059
+ this.ui.requestRender();
3060
+ }
3061
+
3062
+ openExternalEditor(): void {
3063
+ this.#inputController.openExternalEditor();
3064
+ }
3065
+
3066
+ registerExtensionShortcuts(): void {
3067
+ this.#inputController.registerExtensionShortcuts();
3068
+ }
3069
+
3070
+ // Hook UI methods
3071
+ initHooksAndCustomTools(): Promise<void> {
3072
+ return this.#extensionUiController.initHooksAndCustomTools();
3073
+ }
3074
+
3075
+ emitCustomToolSessionEvent(
3076
+ reason: "start" | "switch" | "branch" | "tree" | "shutdown",
3077
+ previousSessionFile?: string,
3078
+ ): Promise<void> {
3079
+ return this.#extensionUiController.emitCustomToolSessionEvent(reason, previousSessionFile);
3080
+ }
3081
+
3082
+ setHookWidget(key: string, content: ExtensionWidgetContent, options?: ExtensionWidgetOptions): void {
3083
+ this.#extensionUiController.setHookWidget(key, content, options);
3084
+ }
3085
+
3086
+ setHookStatus(key: string, text: string | undefined): void {
3087
+ this.#extensionUiController.setHookStatus(key, text);
3088
+ }
3089
+
3090
+ showHookSelector(
3091
+ title: string,
3092
+ options: ExtensionUISelectItem[],
3093
+ dialogOptions?: InteractiveSelectorDialogOptions,
3094
+ extra?: { slider?: HookSelectorSlider },
3095
+ ): Promise<string | undefined> {
3096
+ return this.#extensionUiController.showHookSelector(title, options, dialogOptions, extra);
3097
+ }
3098
+
3099
+ hideHookSelector(): void {
3100
+ this.#extensionUiController.hideHookSelector();
3101
+ }
3102
+
3103
+ showHookInput(title: string, placeholder?: string): Promise<string | undefined> {
3104
+ return this.#extensionUiController.showHookInput(title, placeholder);
3105
+ }
3106
+
3107
+ hideHookInput(): void {
3108
+ this.#extensionUiController.hideHookInput();
3109
+ }
3110
+
3111
+ showHookEditor(
3112
+ title: string,
3113
+ prefill?: string,
3114
+ dialogOptions?: ExtensionUIDialogOptions,
3115
+ editorOptions?: { promptStyle?: boolean },
3116
+ ): Promise<string | undefined> {
3117
+ return this.#extensionUiController.showHookEditor(title, prefill, dialogOptions, editorOptions);
3118
+ }
3119
+
3120
+ hideHookEditor(): void {
3121
+ this.#extensionUiController.hideHookEditor();
3122
+ }
3123
+
3124
+ showHookNotify(message: string, type?: "info" | "warning" | "error"): void {
3125
+ this.#extensionUiController.showHookNotify(message, type);
3126
+ }
3127
+
3128
+ showHookCustom<T>(
3129
+ factory: (
3130
+ tui: TUI,
3131
+ theme: Theme,
3132
+ keybindings: KeybindingsManager,
3133
+ done: (result: T) => void,
3134
+ ) => (Component & { dispose?(): void }) | Promise<Component & { dispose?(): void }>,
3135
+ options?: { overlay?: boolean },
3136
+ ): Promise<T> {
3137
+ return this.#extensionUiController.showHookCustom(factory, options);
3138
+ }
3139
+
3140
+ showExtensionError(extensionPath: string, error: string): void {
3141
+ this.#extensionUiController.showExtensionError(extensionPath, error);
3142
+ }
3143
+
3144
+ showToolError(toolName: string, error: string): void {
3145
+ this.#extensionUiController.showToolError(toolName, error);
3146
+ }
3147
+
3148
+ #subscribeToAgent(): void {
3149
+ this.#eventController.subscribeToAgent();
3150
+ }
3151
+ }