@sayknow-cli/coding-agent 0.2.2

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 (2036) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +37 -0
  3. package/dist/types/async/index.d.ts +2 -0
  4. package/dist/types/async/job-manager.d.ts +326 -0
  5. package/dist/types/async/support.d.ts +2 -0
  6. package/dist/types/autoresearch/dashboard.d.ts +4 -0
  7. package/dist/types/autoresearch/git.d.ts +36 -0
  8. package/dist/types/autoresearch/helpers.d.ts +24 -0
  9. package/dist/types/autoresearch/index.d.ts +2 -0
  10. package/dist/types/autoresearch/state.d.ts +17 -0
  11. package/dist/types/autoresearch/storage.d.ts +142 -0
  12. package/dist/types/autoresearch/tools/init-experiment.d.ts +31 -0
  13. package/dist/types/autoresearch/tools/log-experiment.d.ts +23 -0
  14. package/dist/types/autoresearch/tools/run-experiment.d.ts +8 -0
  15. package/dist/types/autoresearch/tools/update-notes.d.ts +12 -0
  16. package/dist/types/autoresearch/types.d.ts +154 -0
  17. package/dist/types/capability/context-file.d.ts +17 -0
  18. package/dist/types/capability/extension-module.d.ts +15 -0
  19. package/dist/types/capability/extension.d.ts +28 -0
  20. package/dist/types/capability/fs.d.ts +20 -0
  21. package/dist/types/capability/hook.d.ts +19 -0
  22. package/dist/types/capability/index.d.ts +80 -0
  23. package/dist/types/capability/instruction.d.ts +17 -0
  24. package/dist/types/capability/mcp.d.ts +45 -0
  25. package/dist/types/capability/prompt.d.ts +15 -0
  26. package/dist/types/capability/rule.d.ts +61 -0
  27. package/dist/types/capability/settings.d.ts +15 -0
  28. package/dist/types/capability/skill.d.ts +36 -0
  29. package/dist/types/capability/slash-command.d.ts +17 -0
  30. package/dist/types/capability/ssh.d.ts +23 -0
  31. package/dist/types/capability/system-prompt.d.ts +15 -0
  32. package/dist/types/capability/tool.d.ts +19 -0
  33. package/dist/types/capability/types.d.ts +154 -0
  34. package/dist/types/cli/agents-cli.d.ts +12 -0
  35. package/dist/types/cli/args.d.ts +56 -0
  36. package/dist/types/cli/auth-broker-cli.d.ts +25 -0
  37. package/dist/types/cli/auth-gateway-cli.d.ts +18 -0
  38. package/dist/types/cli/classify-install-target.d.ts +18 -0
  39. package/dist/types/cli/commands/init-xdg.d.ts +1 -0
  40. package/dist/types/cli/config-cli.d.ts +22 -0
  41. package/dist/types/cli/fast-help.d.ts +1 -0
  42. package/dist/types/cli/file-processor.d.ts +11 -0
  43. package/dist/types/cli/grep-cli.d.ts +17 -0
  44. package/dist/types/cli/initial-message.d.ts +17 -0
  45. package/dist/types/cli/list-models.d.ts +36 -0
  46. package/dist/types/cli/plugin-cli.d.ts +32 -0
  47. package/dist/types/cli/read-cli.d.ts +4 -0
  48. package/dist/types/cli/session-picker.d.ts +3 -0
  49. package/dist/types/cli/setup-cli.d.ts +54 -0
  50. package/dist/types/cli/shell-cli.d.ts +8 -0
  51. package/dist/types/cli/skills-cli.d.ts +9 -0
  52. package/dist/types/cli/ssh-cli.d.ts +21 -0
  53. package/dist/types/cli/stats-cli.d.ts +17 -0
  54. package/dist/types/cli/update-cli.d.ts +41 -0
  55. package/dist/types/cli/web-search-cli.d.ts +32 -0
  56. package/dist/types/cli/worktree-cli.d.ts +26 -0
  57. package/dist/types/cli.d.ts +3 -0
  58. package/dist/types/commands/acp.d.ts +12 -0
  59. package/dist/types/commands/agents.d.ts +34 -0
  60. package/dist/types/commands/auth-broker.d.ts +54 -0
  61. package/dist/types/commands/auth-gateway.d.ts +32 -0
  62. package/dist/types/commands/codex-native-hook.d.ts +6 -0
  63. package/dist/types/commands/commit.d.ts +27 -0
  64. package/dist/types/commands/config.d.ts +30 -0
  65. package/dist/types/commands/contribution-prep.d.ts +18 -0
  66. package/dist/types/commands/coordinator.d.ts +19 -0
  67. package/dist/types/commands/deep-interview.d.ts +51 -0
  68. package/dist/types/commands/gc.d.ts +26 -0
  69. package/dist/types/commands/grep.d.ts +42 -0
  70. package/dist/types/commands/harness.d.ts +43 -0
  71. package/dist/types/commands/launch.d.ts +127 -0
  72. package/dist/types/commands/mcp-serve.d.ts +24 -0
  73. package/dist/types/commands/plugin.d.ts +52 -0
  74. package/dist/types/commands/ralplan.d.ts +7 -0
  75. package/dist/types/commands/read.d.ts +15 -0
  76. package/dist/types/commands/rlm.d.ts +10 -0
  77. package/dist/types/commands/session.d.ts +24 -0
  78. package/dist/types/commands/setup.d.ts +105 -0
  79. package/dist/types/commands/shell.d.ts +21 -0
  80. package/dist/types/commands/skills.d.ts +26 -0
  81. package/dist/types/commands/ssh.d.ts +48 -0
  82. package/dist/types/commands/state.d.ts +7 -0
  83. package/dist/types/commands/stats.d.ts +25 -0
  84. package/dist/types/commands/team.d.ts +24 -0
  85. package/dist/types/commands/ultragoal.d.ts +8 -0
  86. package/dist/types/commands/update.d.ts +20 -0
  87. package/dist/types/commands/web-search.d.ts +87 -0
  88. package/dist/types/commands/worktree.d.ts +34 -0
  89. package/dist/types/commit/agentic/agent.d.ts +31 -0
  90. package/dist/types/commit/agentic/fallback.d.ts +5 -0
  91. package/dist/types/commit/agentic/index.d.ts +2 -0
  92. package/dist/types/commit/agentic/state.d.ts +58 -0
  93. package/dist/types/commit/agentic/tools/analyze-file.d.ts +19 -0
  94. package/dist/types/commit/agentic/tools/git-file-diff.d.ts +10 -0
  95. package/dist/types/commit/agentic/tools/git-hunk.d.ts +9 -0
  96. package/dist/types/commit/agentic/tools/git-overview.d.ts +9 -0
  97. package/dist/types/commit/agentic/tools/index.d.ts +16 -0
  98. package/dist/types/commit/agentic/tools/propose-changelog.d.ts +28 -0
  99. package/dist/types/commit/agentic/tools/propose-commit.d.ts +36 -0
  100. package/dist/types/commit/agentic/tools/recent-commits.d.ts +7 -0
  101. package/dist/types/commit/agentic/tools/schemas.d.ts +27 -0
  102. package/dist/types/commit/agentic/tools/split-commit.d.ts +53 -0
  103. package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
  104. package/dist/types/commit/agentic/trivial.d.ts +7 -0
  105. package/dist/types/commit/agentic/validation.d.ts +20 -0
  106. package/dist/types/commit/analysis/conventional.d.ts +22 -0
  107. package/dist/types/commit/analysis/index.d.ts +4 -0
  108. package/dist/types/commit/analysis/scope.d.ts +6 -0
  109. package/dist/types/commit/analysis/summary.d.ts +19 -0
  110. package/dist/types/commit/analysis/validation.d.ts +8 -0
  111. package/dist/types/commit/changelog/detect.d.ts +2 -0
  112. package/dist/types/commit/changelog/generate.d.ts +30 -0
  113. package/dist/types/commit/changelog/index.d.ts +30 -0
  114. package/dist/types/commit/changelog/parse.d.ts +2 -0
  115. package/dist/types/commit/cli.d.ts +3 -0
  116. package/dist/types/commit/git/diff.d.ts +5 -0
  117. package/dist/types/commit/index.d.ts +4 -0
  118. package/dist/types/commit/map-reduce/index.d.ts +28 -0
  119. package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
  120. package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
  121. package/dist/types/commit/map-reduce/utils.d.ts +2 -0
  122. package/dist/types/commit/message.d.ts +2 -0
  123. package/dist/types/commit/model-selection.d.ts +15 -0
  124. package/dist/types/commit/pipeline.d.ts +5 -0
  125. package/dist/types/commit/shared-llm.d.ts +54 -0
  126. package/dist/types/commit/types.d.ts +78 -0
  127. package/dist/types/commit/utils/exclusions.d.ts +4 -0
  128. package/dist/types/commit/utils.d.ts +20 -0
  129. package/dist/types/config/config-file.d.ts +58 -0
  130. package/dist/types/config/file-lock-gc.d.ts +5 -0
  131. package/dist/types/config/file-lock.d.ts +35 -0
  132. package/dist/types/config/keybindings.d.ts +349 -0
  133. package/dist/types/config/model-equivalence.d.ts +24 -0
  134. package/dist/types/config/model-profile-activation.d.ts +39 -0
  135. package/dist/types/config/model-profiles.d.ts +37 -0
  136. package/dist/types/config/model-registry.d.ts +457 -0
  137. package/dist/types/config/model-resolver.d.ts +217 -0
  138. package/dist/types/config/models-config-schema.d.ts +690 -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 +3581 -0
  142. package/dist/types/config/settings.d.ts +134 -0
  143. package/dist/types/config/skill-settings-defaults.d.ts +14 -0
  144. package/dist/types/config.d.ts +66 -0
  145. package/dist/types/coordinator/contract.d.ts +4 -0
  146. package/dist/types/coordinator-mcp/policy.d.ts +24 -0
  147. package/dist/types/coordinator-mcp/safety.d.ts +26 -0
  148. package/dist/types/coordinator-mcp/server.d.ts +58 -0
  149. package/dist/types/cursor.d.ts +24 -0
  150. package/dist/types/dap/client.d.ts +39 -0
  151. package/dist/types/dap/config.d.ts +6 -0
  152. package/dist/types/dap/index.d.ts +4 -0
  153. package/dist/types/dap/session.d.ts +108 -0
  154. package/dist/types/dap/types.d.ts +524 -0
  155. package/dist/types/debug/crash-diagnostics.d.ts +45 -0
  156. package/dist/types/debug/index.d.ts +15 -0
  157. package/dist/types/debug/log-formatting.d.ts +4 -0
  158. package/dist/types/debug/log-viewer.d.ts +68 -0
  159. package/dist/types/debug/profiler.d.ts +24 -0
  160. package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
  161. package/dist/types/debug/raw-sse.d.ts +16 -0
  162. package/dist/types/debug/report-bundle.d.ts +55 -0
  163. package/dist/types/debug/runtime-gauges.d.ts +6 -0
  164. package/dist/types/debug/system-info.d.ts +26 -0
  165. package/dist/types/deep-interview/render-middleware.d.ts +6 -0
  166. package/dist/types/defaults/skc/extensions/grok-build/index.d.ts +1 -0
  167. package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/index.d.ts +1 -0
  168. package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/models/catalog.d.ts +25 -0
  169. package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/payload/sanitize.d.ts +27 -0
  170. package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/billing.d.ts +8 -0
  171. package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/register.d.ts +5 -0
  172. package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/stream.d.ts +10 -0
  173. package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/usage.d.ts +2 -0
  174. package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/shared/base-url.d.ts +2 -0
  175. package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/shared/errors.d.ts +38 -0
  176. package/dist/types/defaults/skc-defaults.d.ts +57 -0
  177. package/dist/types/defaults/skc-grok-cli.d.ts +5 -0
  178. package/dist/types/discovery/agents-md.d.ts +1 -0
  179. package/dist/types/discovery/agents.d.ts +12 -0
  180. package/dist/types/discovery/builtin.d.ts +1 -0
  181. package/dist/types/discovery/claude-plugins.d.ts +1 -0
  182. package/dist/types/discovery/claude.d.ts +1 -0
  183. package/dist/types/discovery/cline.d.ts +1 -0
  184. package/dist/types/discovery/codex.d.ts +1 -0
  185. package/dist/types/discovery/cursor.d.ts +16 -0
  186. package/dist/types/discovery/gemini.d.ts +1 -0
  187. package/dist/types/discovery/github.d.ts +1 -0
  188. package/dist/types/discovery/helpers.d.ts +271 -0
  189. package/dist/types/discovery/index.d.ts +48 -0
  190. package/dist/types/discovery/mcp-json.d.ts +1 -0
  191. package/dist/types/discovery/opencode.d.ts +1 -0
  192. package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
  193. package/dist/types/discovery/ssh.d.ts +1 -0
  194. package/dist/types/discovery/substitute-plugin-root.d.ts +5 -0
  195. package/dist/types/discovery/vscode.d.ts +1 -0
  196. package/dist/types/discovery/windsurf.d.ts +13 -0
  197. package/dist/types/edit/apply-patch/index.d.ts +35 -0
  198. package/dist/types/edit/apply-patch/parser.d.ts +34 -0
  199. package/dist/types/edit/diff.d.ts +75 -0
  200. package/dist/types/edit/file-read-cache.d.ts +25 -0
  201. package/dist/types/edit/index.d.ts +58 -0
  202. package/dist/types/edit/modes/apply-patch.d.ts +24 -0
  203. package/dist/types/edit/modes/patch.d.ts +99 -0
  204. package/dist/types/edit/modes/replace.d.ts +149 -0
  205. package/dist/types/edit/normalize.d.ts +43 -0
  206. package/dist/types/edit/notebook.d.ts +26 -0
  207. package/dist/types/edit/read-file.d.ts +8 -0
  208. package/dist/types/edit/renderer.d.ts +110 -0
  209. package/dist/types/edit/streaming.d.ts +66 -0
  210. package/dist/types/eval/backend.d.ts +40 -0
  211. package/dist/types/eval/index.d.ts +4 -0
  212. package/dist/types/eval/js/context-manager.d.ts +27 -0
  213. package/dist/types/eval/js/executor.d.ts +29 -0
  214. package/dist/types/eval/js/index.d.ts +10 -0
  215. package/dist/types/eval/js/shared/helpers.d.ts +38 -0
  216. package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
  217. package/dist/types/eval/js/shared/prelude.d.ts +1 -0
  218. package/dist/types/eval/js/shared/rewrite-imports.d.ts +6 -0
  219. package/dist/types/eval/js/shared/runtime.d.ts +47 -0
  220. package/dist/types/eval/js/shared/types.d.ts +24 -0
  221. package/dist/types/eval/js/tool-bridge.d.ts +18 -0
  222. package/dist/types/eval/js/worker-core.d.ts +5 -0
  223. package/dist/types/eval/js/worker-entry.d.ts +1 -0
  224. package/dist/types/eval/js/worker-protocol.d.ts +77 -0
  225. package/dist/types/eval/py/display.d.ts +25 -0
  226. package/dist/types/eval/py/executor.d.ts +88 -0
  227. package/dist/types/eval/py/index.d.ts +10 -0
  228. package/dist/types/eval/py/kernel.d.ts +65 -0
  229. package/dist/types/eval/py/prelude.d.ts +1 -0
  230. package/dist/types/eval/py/runtime.d.ts +29 -0
  231. package/dist/types/eval/py/tool-bridge.d.ts +20 -0
  232. package/dist/types/eval/types.d.ts +52 -0
  233. package/dist/types/exa/factory.d.ts +13 -0
  234. package/dist/types/exa/index.d.ts +20 -0
  235. package/dist/types/exa/mcp-client.d.ts +45 -0
  236. package/dist/types/exa/render.d.ts +19 -0
  237. package/dist/types/exa/researcher.d.ts +9 -0
  238. package/dist/types/exa/search.d.ts +9 -0
  239. package/dist/types/exa/types.d.ts +155 -0
  240. package/dist/types/exa/websets.d.ts +9 -0
  241. package/dist/types/exec/bash-executor.d.ts +64 -0
  242. package/dist/types/exec/exec.d.ts +25 -0
  243. package/dist/types/exec/idle-timeout-watchdog.d.ts +18 -0
  244. package/dist/types/exec/non-interactive-env.d.ts +1 -0
  245. package/dist/types/export/custom-share.d.ts +20 -0
  246. package/dist/types/export/html/index.d.ts +10 -0
  247. package/dist/types/export/html/template.generated.d.ts +1 -0
  248. package/dist/types/export/html/template.macro.d.ts +5 -0
  249. package/dist/types/export/ttsr.d.ts +44 -0
  250. package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
  251. package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
  252. package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
  253. package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
  254. package/dist/types/extensibility/custom-commands/types.d.ts +106 -0
  255. package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
  256. package/dist/types/extensibility/custom-tools/loader.d.ts +69 -0
  257. package/dist/types/extensibility/custom-tools/types.d.ts +229 -0
  258. package/dist/types/extensibility/custom-tools/wrapper.d.ts +24 -0
  259. package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
  260. package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
  261. package/dist/types/extensibility/extensions/index.d.ts +9 -0
  262. package/dist/types/extensibility/extensions/loader.d.ts +43 -0
  263. package/dist/types/extensibility/extensions/prefix-command-bridge.d.ts +35 -0
  264. package/dist/types/extensibility/extensions/runner.d.ts +134 -0
  265. package/dist/types/extensibility/extensions/types.d.ts +891 -0
  266. package/dist/types/extensibility/extensions/wrapper.d.ts +55 -0
  267. package/dist/types/extensibility/hooks/index.d.ts +5 -0
  268. package/dist/types/extensibility/hooks/loader.d.ts +89 -0
  269. package/dist/types/extensibility/hooks/runner.d.ts +126 -0
  270. package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
  271. package/dist/types/extensibility/hooks/types.d.ts +431 -0
  272. package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
  273. package/dist/types/extensibility/plugins/git-url.d.ts +34 -0
  274. package/dist/types/extensibility/plugins/index.d.ts +7 -0
  275. package/dist/types/extensibility/plugins/installer.d.ts +5 -0
  276. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
  277. package/dist/types/extensibility/plugins/loader.d.ts +31 -0
  278. package/dist/types/extensibility/plugins/manager.d.ts +65 -0
  279. package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
  280. package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
  281. package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
  282. package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
  283. package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
  284. package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
  285. package/dist/types/extensibility/plugins/marketplace/types.d.ts +130 -0
  286. package/dist/types/extensibility/plugins/parser.d.ts +52 -0
  287. package/dist/types/extensibility/plugins/types.d.ts +149 -0
  288. package/dist/types/extensibility/shared-events.d.ts +280 -0
  289. package/dist/types/extensibility/skc-plugins/activation.d.ts +14 -0
  290. package/dist/types/extensibility/skc-plugins/index.d.ts +9 -0
  291. package/dist/types/extensibility/skc-plugins/injection.d.ts +31 -0
  292. package/dist/types/extensibility/skc-plugins/loader.d.ts +3 -0
  293. package/dist/types/extensibility/skc-plugins/paths.d.ts +8 -0
  294. package/dist/types/extensibility/skc-plugins/schema.d.ts +3 -0
  295. package/dist/types/extensibility/skc-plugins/state.d.ts +9 -0
  296. package/dist/types/extensibility/skc-plugins/tools.d.ts +8 -0
  297. package/dist/types/extensibility/skc-plugins/types.d.ts +64 -0
  298. package/dist/types/extensibility/skc-plugins/validation.d.ts +4 -0
  299. package/dist/types/extensibility/skills.d.ts +82 -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/goals/index.d.ts +3 -0
  305. package/dist/types/goals/runtime.d.ts +62 -0
  306. package/dist/types/goals/state.d.ts +32 -0
  307. package/dist/types/goals/tools/goal-tool.d.ts +62 -0
  308. package/dist/types/harness-control-plane/classifier.d.ts +13 -0
  309. package/dist/types/harness-control-plane/control-endpoint.d.ts +31 -0
  310. package/dist/types/harness-control-plane/finalize.d.ts +60 -0
  311. package/dist/types/harness-control-plane/gc-adapter.d.ts +3 -0
  312. package/dist/types/harness-control-plane/operate.d.ts +35 -0
  313. package/dist/types/harness-control-plane/owner.d.ts +53 -0
  314. package/dist/types/harness-control-plane/phase-rollup.d.ts +23 -0
  315. package/dist/types/harness-control-plane/preserve.d.ts +19 -0
  316. package/dist/types/harness-control-plane/receipt-ingest.d.ts +19 -0
  317. package/dist/types/harness-control-plane/receipt-spool.d.ts +19 -0
  318. package/dist/types/harness-control-plane/receipts.d.ts +149 -0
  319. package/dist/types/harness-control-plane/rpc-adapter.d.ts +69 -0
  320. package/dist/types/harness-control-plane/seams.d.ts +21 -0
  321. package/dist/types/harness-control-plane/session-lease.d.ts +65 -0
  322. package/dist/types/harness-control-plane/state-machine.d.ts +24 -0
  323. package/dist/types/harness-control-plane/storage.d.ts +80 -0
  324. package/dist/types/harness-control-plane/types.d.ts +187 -0
  325. package/dist/types/hashline/anchors.d.ts +20 -0
  326. package/dist/types/hashline/apply.d.ts +14 -0
  327. package/dist/types/hashline/constants.d.ts +19 -0
  328. package/dist/types/hashline/diff-preview.d.ts +2 -0
  329. package/dist/types/hashline/diff.d.ts +17 -0
  330. package/dist/types/hashline/execute.d.ts +4 -0
  331. package/dist/types/hashline/hash.d.ts +123 -0
  332. package/dist/types/hashline/index.d.ts +13 -0
  333. package/dist/types/hashline/input.d.ts +11 -0
  334. package/dist/types/hashline/parser.d.ts +7 -0
  335. package/dist/types/hashline/prefixes.d.ts +7 -0
  336. package/dist/types/hashline/recovery.d.ts +27 -0
  337. package/dist/types/hashline/stream.d.ts +2 -0
  338. package/dist/types/hashline/types.d.ts +77 -0
  339. package/dist/types/hindsight/backend.d.ts +13 -0
  340. package/dist/types/hindsight/bank.d.ts +54 -0
  341. package/dist/types/hindsight/client.d.ts +224 -0
  342. package/dist/types/hindsight/config.d.ts +51 -0
  343. package/dist/types/hindsight/content.d.ts +70 -0
  344. package/dist/types/hindsight/index.d.ts +8 -0
  345. package/dist/types/hindsight/mental-models.d.ts +125 -0
  346. package/dist/types/hindsight/state.d.ts +99 -0
  347. package/dist/types/hindsight/transcript.d.ts +28 -0
  348. package/dist/types/hooks/codex-native-hooks-config.d.ts +29 -0
  349. package/dist/types/hooks/native-skill-hook.d.ts +16 -0
  350. package/dist/types/hooks/skill-keywords.d.ts +18 -0
  351. package/dist/types/hooks/skill-state.d.ts +85 -0
  352. package/dist/types/i18n/index.d.ts +38 -0
  353. package/dist/types/i18n/messages/de.d.ts +2 -0
  354. package/dist/types/i18n/messages/de.messages.d.ts +1 -0
  355. package/dist/types/i18n/messages/de.settings.d.ts +1 -0
  356. package/dist/types/i18n/messages/en.d.ts +66 -0
  357. package/dist/types/i18n/messages/es.d.ts +2 -0
  358. package/dist/types/i18n/messages/es.messages.d.ts +1 -0
  359. package/dist/types/i18n/messages/es.settings.d.ts +1 -0
  360. package/dist/types/i18n/messages/fr.d.ts +2 -0
  361. package/dist/types/i18n/messages/fr.messages.d.ts +1 -0
  362. package/dist/types/i18n/messages/fr.settings.d.ts +1 -0
  363. package/dist/types/i18n/messages/ja.d.ts +2 -0
  364. package/dist/types/i18n/messages/ja.messages.d.ts +1 -0
  365. package/dist/types/i18n/messages/ja.settings.d.ts +1 -0
  366. package/dist/types/i18n/messages/ko.d.ts +2 -0
  367. package/dist/types/i18n/messages/ko.messages.d.ts +1 -0
  368. package/dist/types/i18n/messages/ko.settings.d.ts +1 -0
  369. package/dist/types/i18n/messages/zh.d.ts +2 -0
  370. package/dist/types/i18n/messages/zh.messages.d.ts +1 -0
  371. package/dist/types/i18n/messages/zh.settings.d.ts +1 -0
  372. package/dist/types/index.d.ts +33 -0
  373. package/dist/types/internal-urls/agent-protocol.d.ts +12 -0
  374. package/dist/types/internal-urls/artifact-protocol.d.ts +6 -0
  375. package/dist/types/internal-urls/docs-index.generated.d.ts +2 -0
  376. package/dist/types/internal-urls/index.d.ts +20 -0
  377. package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
  378. package/dist/types/internal-urls/json-query.d.ts +30 -0
  379. package/dist/types/internal-urls/local-protocol.d.ts +39 -0
  380. package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
  381. package/dist/types/internal-urls/memory-protocol.d.ts +23 -0
  382. package/dist/types/internal-urls/parse.d.ts +19 -0
  383. package/dist/types/internal-urls/registry-helpers.d.ts +11 -0
  384. package/dist/types/internal-urls/router.d.ts +14 -0
  385. package/dist/types/internal-urls/rule-protocol.d.ts +6 -0
  386. package/dist/types/internal-urls/skc-protocol.d.ts +12 -0
  387. package/dist/types/internal-urls/skill-protocol.d.ts +13 -0
  388. package/dist/types/internal-urls/types.d.ts +109 -0
  389. package/dist/types/lsp/client.d.ts +66 -0
  390. package/dist/types/lsp/clients/biome-client.d.ts +16 -0
  391. package/dist/types/lsp/clients/index.d.ts +19 -0
  392. package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
  393. package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
  394. package/dist/types/lsp/config.d.ts +65 -0
  395. package/dist/types/lsp/edits.d.ts +23 -0
  396. package/dist/types/lsp/index.d.ts +130 -0
  397. package/dist/types/lsp/lspmux.d.ts +58 -0
  398. package/dist/types/lsp/render.d.ts +32 -0
  399. package/dist/types/lsp/startup-events.d.ts +11 -0
  400. package/dist/types/lsp/types.d.ts +304 -0
  401. package/dist/types/lsp/utils.d.ts +108 -0
  402. package/dist/types/main.d.ts +70 -0
  403. package/dist/types/memories/index.d.ts +28 -0
  404. package/dist/types/memories/storage.d.ts +110 -0
  405. package/dist/types/memory-backend/index.d.ts +4 -0
  406. package/dist/types/memory-backend/local-backend.d.ts +9 -0
  407. package/dist/types/memory-backend/off-backend.d.ts +7 -0
  408. package/dist/types/memory-backend/resolve.d.ts +15 -0
  409. package/dist/types/memory-backend/types.d.ts +61 -0
  410. package/dist/types/modes/acp/acp-agent.d.ts +61 -0
  411. package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
  412. package/dist/types/modes/acp/acp-event-mapper.d.ts +34 -0
  413. package/dist/types/modes/acp/acp-mode.d.ts +5 -0
  414. package/dist/types/modes/acp/index.d.ts +2 -0
  415. package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
  416. package/dist/types/modes/bridge/auth.d.ts +12 -0
  417. package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
  418. package/dist/types/modes/bridge/bridge-mode.d.ts +47 -0
  419. package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
  420. package/dist/types/modes/bridge/event-stream.d.ts +8 -0
  421. package/dist/types/modes/components/agent-dashboard.d.ts +21 -0
  422. package/dist/types/modes/components/assistant-message.d.ts +16 -0
  423. package/dist/types/modes/components/bash-execution.d.ts +29 -0
  424. package/dist/types/modes/components/bordered-loader.d.ts +11 -0
  425. package/dist/types/modes/components/branch-summary-message.d.ts +13 -0
  426. package/dist/types/modes/components/btw-panel.d.ts +16 -0
  427. package/dist/types/modes/components/compaction-summary-message.d.ts +13 -0
  428. package/dist/types/modes/components/countdown-timer.d.ts +14 -0
  429. package/dist/types/modes/components/custom-editor.d.ts +62 -0
  430. package/dist/types/modes/components/custom-message.d.ts +15 -0
  431. package/dist/types/modes/components/custom-model-preset-wizard.d.ts +12 -0
  432. package/dist/types/modes/components/custom-provider-wizard.d.ts +10 -0
  433. package/dist/types/modes/components/diff.d.ts +11 -0
  434. package/dist/types/modes/components/dynamic-border.d.ts +14 -0
  435. package/dist/types/modes/components/eval-execution.d.ts +23 -0
  436. package/dist/types/modes/components/execution-shared.d.ts +46 -0
  437. package/dist/types/modes/components/extensions/extension-dashboard.d.ts +26 -0
  438. package/dist/types/modes/components/extensions/extension-list.d.ts +39 -0
  439. package/dist/types/modes/components/extensions/index.d.ts +8 -0
  440. package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
  441. package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
  442. package/dist/types/modes/components/extensions/types.d.ts +151 -0
  443. package/dist/types/modes/components/footer.d.ts +30 -0
  444. package/dist/types/modes/components/history-search.d.ts +7 -0
  445. package/dist/types/modes/components/hook-editor.d.ts +18 -0
  446. package/dist/types/modes/components/hook-input.d.ts +15 -0
  447. package/dist/types/modes/components/hook-message.d.ts +15 -0
  448. package/dist/types/modes/components/hook-selector.d.ts +48 -0
  449. package/dist/types/modes/components/index.d.ts +35 -0
  450. package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
  451. package/dist/types/modes/components/jobs-overlay.d.ts +30 -0
  452. package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
  453. package/dist/types/modes/components/login-dialog.d.ts +32 -0
  454. package/dist/types/modes/components/message-frame.d.ts +42 -0
  455. package/dist/types/modes/components/model-selector.d.ts +46 -0
  456. package/dist/types/modes/components/oauth-selector.d.ts +15 -0
  457. package/dist/types/modes/components/plugin-selector.d.ts +26 -0
  458. package/dist/types/modes/components/plugin-settings.d.ts +66 -0
  459. package/dist/types/modes/components/provider-onboarding-selector.d.ts +7 -0
  460. package/dist/types/modes/components/queue-mode-selector.d.ts +9 -0
  461. package/dist/types/modes/components/read-tool-group.d.ts +30 -0
  462. package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +26 -0
  463. package/dist/types/modes/components/session-observer-overlay.d.ts +11 -0
  464. package/dist/types/modes/components/session-selector.d.ts +30 -0
  465. package/dist/types/modes/components/settings-defs.d.ts +50 -0
  466. package/dist/types/modes/components/settings-selector.d.ts +56 -0
  467. package/dist/types/modes/components/show-images-selector.d.ts +9 -0
  468. package/dist/types/modes/components/skill-hud/render.d.ts +2 -0
  469. package/dist/types/modes/components/skill-message.d.ts +9 -0
  470. package/dist/types/modes/components/status-line/context-thresholds.d.ts +4 -0
  471. package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
  472. package/dist/types/modes/components/status-line/index.d.ts +4 -0
  473. package/dist/types/modes/components/status-line/presets.d.ts +3 -0
  474. package/dist/types/modes/components/status-line/segments.d.ts +5 -0
  475. package/dist/types/modes/components/status-line/separators.d.ts +3 -0
  476. package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
  477. package/dist/types/modes/components/status-line/types.d.ts +79 -0
  478. package/dist/types/modes/components/status-line.d.ts +82 -0
  479. package/dist/types/modes/components/theme-selector.d.ts +10 -0
  480. package/dist/types/modes/components/thinking-selector.d.ts +10 -0
  481. package/dist/types/modes/components/todo-reminder.d.ts +13 -0
  482. package/dist/types/modes/components/tool-execution.d.ts +54 -0
  483. package/dist/types/modes/components/tree-selector.d.ts +31 -0
  484. package/dist/types/modes/components/ttsr-notification.d.ts +13 -0
  485. package/dist/types/modes/components/user-message-selector.d.ts +28 -0
  486. package/dist/types/modes/components/user-message.d.ts +7 -0
  487. package/dist/types/modes/components/visual-truncate.d.ts +19 -0
  488. package/dist/types/modes/components/welcome.d.ts +35 -0
  489. package/dist/types/modes/controllers/btw-controller.d.ts +10 -0
  490. package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
  491. package/dist/types/modes/controllers/command-controller.d.ts +38 -0
  492. package/dist/types/modes/controllers/event-controller.d.ts +12 -0
  493. package/dist/types/modes/controllers/extension-ui-controller.d.ts +80 -0
  494. package/dist/types/modes/controllers/input-controller.d.ts +39 -0
  495. package/dist/types/modes/controllers/runtime-mcp-command-controller.d.ts +10 -0
  496. package/dist/types/modes/controllers/selector-controller.d.ts +57 -0
  497. package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
  498. package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
  499. package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
  500. package/dist/types/modes/index.d.ts +10 -0
  501. package/dist/types/modes/interactive-mode.d.ts +266 -0
  502. package/dist/types/modes/jobs-observer.d.ts +57 -0
  503. package/dist/types/modes/oauth-manual-input.d.ts +8 -0
  504. package/dist/types/modes/print-mode.d.ts +33 -0
  505. package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
  506. package/dist/types/modes/rpc/host-tools.d.ts +1 -0
  507. package/dist/types/modes/rpc/host-uris.d.ts +1 -0
  508. package/dist/types/modes/rpc/rpc-client.d.ts +288 -0
  509. package/dist/types/modes/rpc/rpc-mode.d.ts +87 -0
  510. package/dist/types/modes/rpc/rpc-socket-security.d.ts +7 -0
  511. package/dist/types/modes/rpc/rpc-types.d.ts +779 -0
  512. package/dist/types/modes/runtime-init.d.ts +21 -0
  513. package/dist/types/modes/session-observer-registry.d.ts +26 -0
  514. package/dist/types/modes/shared/agent-wire/approval-gate.d.ts +57 -0
  515. package/dist/types/modes/shared/agent-wire/command-contract.d.ts +18 -0
  516. package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +37 -0
  517. package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
  518. package/dist/types/modes/shared/agent-wire/deep-interview-gate.d.ts +60 -0
  519. package/dist/types/modes/shared/agent-wire/event-contract.d.ts +84 -0
  520. package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +38 -0
  521. package/dist/types/modes/shared/agent-wire/event-observation.d.ts +37 -0
  522. package/dist/types/modes/shared/agent-wire/handshake.d.ts +56 -0
  523. package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
  524. package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
  525. package/dist/types/modes/shared/agent-wire/protocol.d.ts +25 -0
  526. package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
  527. package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
  528. package/dist/types/modes/shared/agent-wire/session-registry.d.ts +25 -0
  529. package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
  530. package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
  531. package/dist/types/modes/shared/agent-wire/unattended-action-policy.d.ts +29 -0
  532. package/dist/types/modes/shared/agent-wire/unattended-audit.d.ts +68 -0
  533. package/dist/types/modes/shared/agent-wire/unattended-run-controller.d.ts +161 -0
  534. package/dist/types/modes/shared/agent-wire/unattended-session.d.ts +72 -0
  535. package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +114 -0
  536. package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +39 -0
  537. package/dist/types/modes/shared.d.ts +15 -0
  538. package/dist/types/modes/theme/defaults/index.d.ts +553 -0
  539. package/dist/types/modes/theme/mermaid-cache.d.ts +9 -0
  540. package/dist/types/modes/theme/shimmer.d.ts +38 -0
  541. package/dist/types/modes/theme/theme.d.ts +275 -0
  542. package/dist/types/modes/types.d.ts +278 -0
  543. package/dist/types/modes/utils/abort-message.d.ts +4 -0
  544. package/dist/types/modes/utils/context-usage.d.ts +51 -0
  545. package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
  546. package/dist/types/modes/utils/keybinding-matchers.d.ts +10 -0
  547. package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
  548. package/dist/types/modes/utils/ui-helpers.d.ts +53 -0
  549. package/dist/types/plan-mode/approved-plan.d.ts +49 -0
  550. package/dist/types/plan-mode/state.d.ts +6 -0
  551. package/dist/types/registry/agent-registry.d.ts +62 -0
  552. package/dist/types/reminders/star-reminder.d.ts +115 -0
  553. package/dist/types/rlm/artifacts.d.ts +9 -0
  554. package/dist/types/rlm/complete-research-tool.d.ts +35 -0
  555. package/dist/types/rlm/data-context.d.ts +6 -0
  556. package/dist/types/rlm/index.d.ts +35 -0
  557. package/dist/types/rlm/notebook.d.ts +12 -0
  558. package/dist/types/rlm/preset.d.ts +23 -0
  559. package/dist/types/rlm/python-tool.d.ts +16 -0
  560. package/dist/types/rlm/report.d.ts +14 -0
  561. package/dist/types/rlm/types.d.ts +37 -0
  562. package/dist/types/runtime/process-lifecycle.d.ts +108 -0
  563. package/dist/types/runtime-mcp/client.d.ts +74 -0
  564. package/dist/types/runtime-mcp/config-writer.d.ts +53 -0
  565. package/dist/types/runtime-mcp/config.d.ts +75 -0
  566. package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +7 -0
  567. package/dist/types/runtime-mcp/index.d.ts +18 -0
  568. package/dist/types/runtime-mcp/json-rpc.d.ts +22 -0
  569. package/dist/types/runtime-mcp/loader.d.ts +43 -0
  570. package/dist/types/runtime-mcp/manager.d.ts +193 -0
  571. package/dist/types/runtime-mcp/oauth-discovery.d.ts +40 -0
  572. package/dist/types/runtime-mcp/oauth-flow.d.ts +59 -0
  573. package/dist/types/runtime-mcp/render.d.ts +25 -0
  574. package/dist/types/runtime-mcp/smithery-auth.d.ts +16 -0
  575. package/dist/types/runtime-mcp/smithery-connect.d.ts +38 -0
  576. package/dist/types/runtime-mcp/smithery-registry.d.ts +51 -0
  577. package/dist/types/runtime-mcp/tool-bridge.d.ts +86 -0
  578. package/dist/types/runtime-mcp/tool-cache.d.ts +8 -0
  579. package/dist/types/runtime-mcp/transports/http.d.ts +36 -0
  580. package/dist/types/runtime-mcp/transports/index.d.ts +5 -0
  581. package/dist/types/runtime-mcp/transports/stdio.d.ts +29 -0
  582. package/dist/types/runtime-mcp/types.d.ts +335 -0
  583. package/dist/types/sdk.d.ts +243 -0
  584. package/dist/types/secrets/index.d.ts +9 -0
  585. package/dist/types/secrets/obfuscator.d.ts +23 -0
  586. package/dist/types/secrets/regex.d.ts +2 -0
  587. package/dist/types/session/agent-session.d.ts +1078 -0
  588. package/dist/types/session/agent-storage.d.ts +100 -0
  589. package/dist/types/session/artifacts.d.ts +64 -0
  590. package/dist/types/session/auth-broker-config.d.ts +13 -0
  591. package/dist/types/session/auth-storage.d.ts +6 -0
  592. package/dist/types/session/blob-store.d.ts +135 -0
  593. package/dist/types/session/client-bridge.d.ts +88 -0
  594. package/dist/types/session/contribution-prep.d.ts +47 -0
  595. package/dist/types/session/history-storage.d.ts +16 -0
  596. package/dist/types/session/messages.d.ts +165 -0
  597. package/dist/types/session/session-dump-format.d.ts +22 -0
  598. package/dist/types/session/session-manager.d.ts +587 -0
  599. package/dist/types/session/session-storage.d.ts +88 -0
  600. package/dist/types/session/streaming-output.d.ts +209 -0
  601. package/dist/types/session/tool-choice-queue.d.ts +84 -0
  602. package/dist/types/session/yield-queue.d.ts +24 -0
  603. package/dist/types/setup/credential-import.d.ts +79 -0
  604. package/dist/types/setup/hermes-setup.d.ts +78 -0
  605. package/dist/types/setup/model-onboarding-guidance.d.ts +9 -0
  606. package/dist/types/setup/provider-onboarding.d.ts +52 -0
  607. package/dist/types/skc-runtime/cli-write-receipt.d.ts +24 -0
  608. package/dist/types/skc-runtime/deep-interview-recorder.d.ts +103 -0
  609. package/dist/types/skc-runtime/deep-interview-runtime.d.ts +36 -0
  610. package/dist/types/skc-runtime/deep-interview-state.d.ts +112 -0
  611. package/dist/types/skc-runtime/gc-render.d.ts +6 -0
  612. package/dist/types/skc-runtime/gc-runtime.d.ts +134 -0
  613. package/dist/types/skc-runtime/goal-mode-request.d.ts +53 -0
  614. package/dist/types/skc-runtime/launch-tmux.d.ts +76 -0
  615. package/dist/types/skc-runtime/launch-worktree.d.ts +46 -0
  616. package/dist/types/skc-runtime/ledger-event-renderer.d.ts +68 -0
  617. package/dist/types/skc-runtime/ralplan-runtime.d.ts +25 -0
  618. package/dist/types/skc-runtime/restricted-role-agent-bash.d.ts +2 -0
  619. package/dist/types/skc-runtime/session-state-sidecar.d.ts +27 -0
  620. package/dist/types/skc-runtime/state-graph.d.ts +4 -0
  621. package/dist/types/skc-runtime/state-migrations.d.ts +33 -0
  622. package/dist/types/skc-runtime/state-renderer.d.ts +65 -0
  623. package/dist/types/skc-runtime/state-runtime.d.ts +37 -0
  624. package/dist/types/skc-runtime/state-schema.d.ts +317 -0
  625. package/dist/types/skc-runtime/state-validation.d.ts +6 -0
  626. package/dist/types/skc-runtime/state-writer.d.ts +209 -0
  627. package/dist/types/skc-runtime/team-gc.d.ts +7 -0
  628. package/dist/types/skc-runtime/team-runtime.d.ts +353 -0
  629. package/dist/types/skc-runtime/tmux-common.d.ts +61 -0
  630. package/dist/types/skc-runtime/tmux-gc.d.ts +7 -0
  631. package/dist/types/skc-runtime/tmux-sessions.d.ts +40 -0
  632. package/dist/types/skc-runtime/ultragoal-guard.d.ts +36 -0
  633. package/dist/types/skc-runtime/ultragoal-runtime.d.ts +210 -0
  634. package/dist/types/skc-runtime/workflow-command-ref.d.ts +43 -0
  635. package/dist/types/skc-runtime/workflow-manifest.d.ts +54 -0
  636. package/dist/types/skill-state/active-state.d.ts +114 -0
  637. package/dist/types/skill-state/deep-interview-mutation-guard.d.ts +33 -0
  638. package/dist/types/skill-state/initial-phase.d.ts +12 -0
  639. package/dist/types/skill-state/workflow-hud.d.ts +81 -0
  640. package/dist/types/skill-state/workflow-state-contract.d.ts +57 -0
  641. package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
  642. package/dist/types/slash-commands/acp-builtins.d.ts +18 -0
  643. package/dist/types/slash-commands/builtin-registry.d.ts +24 -0
  644. package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
  645. package/dist/types/slash-commands/helpers/fast-status-report.d.ts +76 -0
  646. package/dist/types/slash-commands/helpers/format.d.ts +10 -0
  647. package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
  648. package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
  649. package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
  650. package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
  651. package/dist/types/slash-commands/helpers/usage-report.d.ts +7 -0
  652. package/dist/types/slash-commands/types.d.ts +118 -0
  653. package/dist/types/ssh/config-writer.d.ts +49 -0
  654. package/dist/types/ssh/connection-manager.d.ts +33 -0
  655. package/dist/types/ssh/ssh-executor.d.ts +37 -0
  656. package/dist/types/ssh/sshfs-mount.d.ts +6 -0
  657. package/dist/types/ssh/utils.d.ts +2 -0
  658. package/dist/types/stt/downloader.d.ts +9 -0
  659. package/dist/types/stt/index.d.ts +3 -0
  660. package/dist/types/stt/recorder.d.ts +13 -0
  661. package/dist/types/stt/setup.d.ts +18 -0
  662. package/dist/types/stt/stt-controller.d.ts +16 -0
  663. package/dist/types/stt/transcriber.d.ts +16 -0
  664. package/dist/types/system-prompt.d.ts +93 -0
  665. package/dist/types/task/agents.d.ts +28 -0
  666. package/dist/types/task/commands.d.ts +35 -0
  667. package/dist/types/task/discovery.d.ts +19 -0
  668. package/dist/types/task/executor.d.ts +113 -0
  669. package/dist/types/task/fork-context-advisory.d.ts +13 -0
  670. package/dist/types/task/id.d.ts +7 -0
  671. package/dist/types/task/index.d.ts +43 -0
  672. package/dist/types/task/name-generator.d.ts +16 -0
  673. package/dist/types/task/output-manager.d.ts +36 -0
  674. package/dist/types/task/parallel.d.ts +34 -0
  675. package/dist/types/task/receipt.d.ts +87 -0
  676. package/dist/types/task/render.d.ts +28 -0
  677. package/dist/types/task/roi-reconciliation.d.ts +27 -0
  678. package/dist/types/task/simple-mode.d.ts +8 -0
  679. package/dist/types/task/skc-command.d.ts +7 -0
  680. package/dist/types/task/spawn-gate.d.ts +38 -0
  681. package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
  682. package/dist/types/task/types.d.ts +508 -0
  683. package/dist/types/task/worktree.d.ts +94 -0
  684. package/dist/types/thinking-metadata.d.ts +16 -0
  685. package/dist/types/thinking.d.ts +22 -0
  686. package/dist/types/tool-discovery/tool-index.d.ts +112 -0
  687. package/dist/types/tools/archive-reader.d.ts +40 -0
  688. package/dist/types/tools/ask.d.ts +123 -0
  689. package/dist/types/tools/ast-edit.d.ts +77 -0
  690. package/dist/types/tools/ast-grep.d.ts +69 -0
  691. package/dist/types/tools/auto-generated-guard.d.ts +17 -0
  692. package/dist/types/tools/bash-allowed-prefixes.d.ts +10 -0
  693. package/dist/types/tools/bash-command-fixup.d.ts +11 -0
  694. package/dist/types/tools/bash-interactive.d.ts +16 -0
  695. package/dist/types/tools/bash-interceptor.d.ts +24 -0
  696. package/dist/types/tools/bash-pty-selection.d.ts +7 -0
  697. package/dist/types/tools/bash-skill-urls.d.ts +31 -0
  698. package/dist/types/tools/bash.d.ts +157 -0
  699. package/dist/types/tools/browser/actions.d.ts +54 -0
  700. package/dist/types/tools/browser/attach.d.ts +50 -0
  701. package/dist/types/tools/browser/launch.d.ts +62 -0
  702. package/dist/types/tools/browser/readable.d.ts +17 -0
  703. package/dist/types/tools/browser/registry.d.ts +57 -0
  704. package/dist/types/tools/browser/render.d.ts +53 -0
  705. package/dist/types/tools/browser/tab-protocol.d.ts +144 -0
  706. package/dist/types/tools/browser/tab-supervisor.d.ts +72 -0
  707. package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
  708. package/dist/types/tools/browser/tab-worker.d.ts +19 -0
  709. package/dist/types/tools/browser.d.ts +211 -0
  710. package/dist/types/tools/calculator.d.ts +76 -0
  711. package/dist/types/tools/checkpoint.d.ts +63 -0
  712. package/dist/types/tools/computer/render.d.ts +17 -0
  713. package/dist/types/tools/computer.d.ts +465 -0
  714. package/dist/types/tools/conflict-detect.d.ts +205 -0
  715. package/dist/types/tools/context.d.ts +19 -0
  716. package/dist/types/tools/cron.d.ts +116 -0
  717. package/dist/types/tools/debug.d.ts +209 -0
  718. package/dist/types/tools/eval.d.ts +108 -0
  719. package/dist/types/tools/fetch.d.ts +61 -0
  720. package/dist/types/tools/file-recorder.d.ts +13 -0
  721. package/dist/types/tools/find.d.ts +95 -0
  722. package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
  723. package/dist/types/tools/gh-format.d.ts +6 -0
  724. package/dist/types/tools/gh-renderer.d.ts +25 -0
  725. package/dist/types/tools/gh.d.ts +356 -0
  726. package/dist/types/tools/github-cache.d.ts +103 -0
  727. package/dist/types/tools/grouped-file-output.d.ts +36 -0
  728. package/dist/types/tools/hindsight-recall.d.ts +21 -0
  729. package/dist/types/tools/hindsight-reflect.d.ts +23 -0
  730. package/dist/types/tools/hindsight-retain.d.ts +27 -0
  731. package/dist/types/tools/image-gen.d.ts +79 -0
  732. package/dist/types/tools/index.d.ts +297 -0
  733. package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
  734. package/dist/types/tools/inspect-image.d.ts +31 -0
  735. package/dist/types/tools/irc.d.ts +79 -0
  736. package/dist/types/tools/job.d.ts +78 -0
  737. package/dist/types/tools/json-tree.d.ts +23 -0
  738. package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
  739. package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
  740. package/dist/types/tools/jtd-utils.d.ts +42 -0
  741. package/dist/types/tools/list-limit.d.ts +12 -0
  742. package/dist/types/tools/match-line-format.d.ts +11 -0
  743. package/dist/types/tools/monitor.d.ts +54 -0
  744. package/dist/types/tools/output-meta.d.ts +204 -0
  745. package/dist/types/tools/path-utils.d.ts +147 -0
  746. package/dist/types/tools/plan-mode-guard.d.ts +18 -0
  747. package/dist/types/tools/read.d.ts +85 -0
  748. package/dist/types/tools/recipe/index.d.ts +45 -0
  749. package/dist/types/tools/recipe/render.d.ts +36 -0
  750. package/dist/types/tools/recipe/runner.d.ts +60 -0
  751. package/dist/types/tools/recipe/runners/cargo.d.ts +16 -0
  752. package/dist/types/tools/recipe/runners/index.d.ts +2 -0
  753. package/dist/types/tools/recipe/runners/just.d.ts +2 -0
  754. package/dist/types/tools/recipe/runners/make.d.ts +2 -0
  755. package/dist/types/tools/recipe/runners/pkg.d.ts +2 -0
  756. package/dist/types/tools/recipe/runners/task.d.ts +2 -0
  757. package/dist/types/tools/render-mermaid.d.ts +37 -0
  758. package/dist/types/tools/render-utils.d.ts +158 -0
  759. package/dist/types/tools/renderers.d.ts +26 -0
  760. package/dist/types/tools/resolve.d.ts +80 -0
  761. package/dist/types/tools/review.d.ts +63 -0
  762. package/dist/types/tools/search-tool-bm25.d.ts +65 -0
  763. package/dist/types/tools/search.d.ts +93 -0
  764. package/dist/types/tools/skill.d.ts +47 -0
  765. package/dist/types/tools/sqlite-reader.d.ts +94 -0
  766. package/dist/types/tools/ssh.d.ts +67 -0
  767. package/dist/types/tools/subagent-render.d.ts +31 -0
  768. package/dist/types/tools/subagent.d.ts +114 -0
  769. package/dist/types/tools/todo-write.d.ts +120 -0
  770. package/dist/types/tools/tool-errors.d.ts +33 -0
  771. package/dist/types/tools/tool-result.d.ts +30 -0
  772. package/dist/types/tools/tool-timeouts.d.ts +56 -0
  773. package/dist/types/tools/ultragoal-ask-guard.d.ts +5 -0
  774. package/dist/types/tools/vim.d.ts +58 -0
  775. package/dist/types/tools/write.d.ts +59 -0
  776. package/dist/types/tools/yield.d.ts +25 -0
  777. package/dist/types/tui/code-cell.d.ts +32 -0
  778. package/dist/types/tui/file-list.d.ts +22 -0
  779. package/dist/types/tui/hyperlink.d.ts +42 -0
  780. package/dist/types/tui/index.d.ts +11 -0
  781. package/dist/types/tui/output-block.d.ts +28 -0
  782. package/dist/types/tui/status-line.d.ts +18 -0
  783. package/dist/types/tui/tree-list.d.ts +19 -0
  784. package/dist/types/tui/types.d.ts +13 -0
  785. package/dist/types/tui/utils.d.ts +36 -0
  786. package/dist/types/utils/changelog.d.ts +36 -0
  787. package/dist/types/utils/clipboard.d.ts +22 -0
  788. package/dist/types/utils/command-args.d.ts +9 -0
  789. package/dist/types/utils/commit-message-generator.d.ts +7 -0
  790. package/dist/types/utils/edit-mode.d.ts +13 -0
  791. package/dist/types/utils/event-bus.d.ts +6 -0
  792. package/dist/types/utils/external-editor.d.ts +17 -0
  793. package/dist/types/utils/file-display-mode.d.ts +27 -0
  794. package/dist/types/utils/file-mentions.d.ts +11 -0
  795. package/dist/types/utils/git.d.ts +361 -0
  796. package/dist/types/utils/image-loading.d.ts +26 -0
  797. package/dist/types/utils/image-resize.d.ts +39 -0
  798. package/dist/types/utils/lang-from-path.d.ts +8 -0
  799. package/dist/types/utils/markit.d.ts +7 -0
  800. package/dist/types/utils/open.d.ts +2 -0
  801. package/dist/types/utils/session-color.d.ts +10 -0
  802. package/dist/types/utils/shell-snapshot.d.ts +5 -0
  803. package/dist/types/utils/sixel.d.ts +21 -0
  804. package/dist/types/utils/title-generator.d.ts +31 -0
  805. package/dist/types/utils/tool-choice.d.ts +20 -0
  806. package/dist/types/utils/tools-manager.d.ts +9 -0
  807. package/dist/types/vim/buffer.d.ts +41 -0
  808. package/dist/types/vim/commands.d.ts +6 -0
  809. package/dist/types/vim/engine.d.ts +47 -0
  810. package/dist/types/vim/parser.d.ts +3 -0
  811. package/dist/types/vim/render.d.ts +25 -0
  812. package/dist/types/vim/types.d.ts +182 -0
  813. package/dist/types/web/kagi.d.ts +23 -0
  814. package/dist/types/web/parallel.d.ts +58 -0
  815. package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
  816. package/dist/types/web/scrapers/arxiv.d.ts +5 -0
  817. package/dist/types/web/scrapers/aur.d.ts +5 -0
  818. package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
  819. package/dist/types/web/scrapers/bluesky.d.ts +5 -0
  820. package/dist/types/web/scrapers/brew.d.ts +5 -0
  821. package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
  822. package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
  823. package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
  824. package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
  825. package/dist/types/web/scrapers/clojars.d.ts +5 -0
  826. package/dist/types/web/scrapers/coingecko.d.ts +5 -0
  827. package/dist/types/web/scrapers/crates-io.d.ts +5 -0
  828. package/dist/types/web/scrapers/crossref.d.ts +2 -0
  829. package/dist/types/web/scrapers/devto.d.ts +5 -0
  830. package/dist/types/web/scrapers/discogs.d.ts +8 -0
  831. package/dist/types/web/scrapers/discourse.d.ts +5 -0
  832. package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
  833. package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
  834. package/dist/types/web/scrapers/fdroid.d.ts +5 -0
  835. package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
  836. package/dist/types/web/scrapers/flathub.d.ts +2 -0
  837. package/dist/types/web/scrapers/github-gist.d.ts +5 -0
  838. package/dist/types/web/scrapers/github.d.ts +12 -0
  839. package/dist/types/web/scrapers/gitlab.d.ts +5 -0
  840. package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
  841. package/dist/types/web/scrapers/hackage.d.ts +5 -0
  842. package/dist/types/web/scrapers/hackernews.d.ts +2 -0
  843. package/dist/types/web/scrapers/hex.d.ts +5 -0
  844. package/dist/types/web/scrapers/huggingface.d.ts +2 -0
  845. package/dist/types/web/scrapers/iacr.d.ts +5 -0
  846. package/dist/types/web/scrapers/index.d.ts +84 -0
  847. package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
  848. package/dist/types/web/scrapers/lemmy.d.ts +2 -0
  849. package/dist/types/web/scrapers/lobsters.d.ts +5 -0
  850. package/dist/types/web/scrapers/mastodon.d.ts +5 -0
  851. package/dist/types/web/scrapers/maven.d.ts +6 -0
  852. package/dist/types/web/scrapers/mdn.d.ts +2 -0
  853. package/dist/types/web/scrapers/metacpan.d.ts +5 -0
  854. package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
  855. package/dist/types/web/scrapers/npm.d.ts +5 -0
  856. package/dist/types/web/scrapers/nuget.d.ts +5 -0
  857. package/dist/types/web/scrapers/nvd.d.ts +5 -0
  858. package/dist/types/web/scrapers/ollama.d.ts +2 -0
  859. package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
  860. package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
  861. package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
  862. package/dist/types/web/scrapers/orcid.d.ts +5 -0
  863. package/dist/types/web/scrapers/osv.d.ts +5 -0
  864. package/dist/types/web/scrapers/packagist.d.ts +5 -0
  865. package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
  866. package/dist/types/web/scrapers/pubmed.d.ts +5 -0
  867. package/dist/types/web/scrapers/pypi.d.ts +5 -0
  868. package/dist/types/web/scrapers/rawg.d.ts +2 -0
  869. package/dist/types/web/scrapers/readthedocs.d.ts +2 -0
  870. package/dist/types/web/scrapers/reddit.d.ts +5 -0
  871. package/dist/types/web/scrapers/repology.d.ts +5 -0
  872. package/dist/types/web/scrapers/rfc.d.ts +5 -0
  873. package/dist/types/web/scrapers/rubygems.d.ts +5 -0
  874. package/dist/types/web/scrapers/searchcode.d.ts +2 -0
  875. package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
  876. package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
  877. package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
  878. package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
  879. package/dist/types/web/scrapers/spdx.d.ts +5 -0
  880. package/dist/types/web/scrapers/spotify.d.ts +8 -0
  881. package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
  882. package/dist/types/web/scrapers/terraform.d.ts +5 -0
  883. package/dist/types/web/scrapers/tldr.d.ts +7 -0
  884. package/dist/types/web/scrapers/twitter.d.ts +5 -0
  885. package/dist/types/web/scrapers/types.d.ts +78 -0
  886. package/dist/types/web/scrapers/utils.d.ts +26 -0
  887. package/dist/types/web/scrapers/vimeo.d.ts +5 -0
  888. package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
  889. package/dist/types/web/scrapers/w3c.d.ts +2 -0
  890. package/dist/types/web/scrapers/wikidata.d.ts +5 -0
  891. package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
  892. package/dist/types/web/scrapers/youtube.d.ts +5 -0
  893. package/dist/types/web/search/index.d.ts +115 -0
  894. package/dist/types/web/search/provider.d.ts +24 -0
  895. package/dist/types/web/search/providers/anthropic.d.ts +32 -0
  896. package/dist/types/web/search/providers/base.d.ts +90 -0
  897. package/dist/types/web/search/providers/brave.d.ts +27 -0
  898. package/dist/types/web/search/providers/codex.d.ts +35 -0
  899. package/dist/types/web/search/providers/duckduckgo.d.ts +57 -0
  900. package/dist/types/web/search/providers/exa.d.ts +52 -0
  901. package/dist/types/web/search/providers/gemini.d.ts +57 -0
  902. package/dist/types/web/search/providers/jina.d.ts +26 -0
  903. package/dist/types/web/search/providers/kagi.d.ts +24 -0
  904. package/dist/types/web/search/providers/kimi.d.ts +27 -0
  905. package/dist/types/web/search/providers/openai-compatible.d.ts +9 -0
  906. package/dist/types/web/search/providers/parallel.d.ts +15 -0
  907. package/dist/types/web/search/providers/perplexity.d.ts +38 -0
  908. package/dist/types/web/search/providers/searxng.d.ts +44 -0
  909. package/dist/types/web/search/providers/synthetic.d.ts +21 -0
  910. package/dist/types/web/search/providers/tavily.d.ts +29 -0
  911. package/dist/types/web/search/providers/utils.d.ts +52 -0
  912. package/dist/types/web/search/providers/xai.d.ts +64 -0
  913. package/dist/types/web/search/providers/zai.d.ts +28 -0
  914. package/dist/types/web/search/render.d.ts +35 -0
  915. package/dist/types/web/search/types.d.ts +364 -0
  916. package/dist/types/web/search/utils.d.ts +4 -0
  917. package/dist/types/workspace-tree.d.ts +42 -0
  918. package/examples/README.md +21 -0
  919. package/examples/custom-tools/README.md +104 -0
  920. package/examples/custom-tools/hello/index.ts +20 -0
  921. package/examples/extensions/README.md +120 -0
  922. package/examples/extensions/api-demo.ts +79 -0
  923. package/examples/extensions/chalk-logger.ts +25 -0
  924. package/examples/extensions/hello.ts +31 -0
  925. package/examples/extensions/pirate.ts +43 -0
  926. package/examples/extensions/plan-mode.ts +549 -0
  927. package/examples/extensions/reload-runtime.ts +38 -0
  928. package/examples/extensions/tools.ts +144 -0
  929. package/examples/extensions/with-deps/index.ts +36 -0
  930. package/examples/extensions/with-deps/package-lock.json +31 -0
  931. package/examples/extensions/with-deps/package.json +16 -0
  932. package/examples/hooks/README.md +56 -0
  933. package/examples/hooks/auto-commit-on-exit.ts +48 -0
  934. package/examples/hooks/confirm-destructive.ts +58 -0
  935. package/examples/hooks/custom-compaction.ts +115 -0
  936. package/examples/hooks/dirty-repo-guard.ts +51 -0
  937. package/examples/hooks/file-trigger.ts +40 -0
  938. package/examples/hooks/git-checkpoint.ts +52 -0
  939. package/examples/hooks/handoff.ts +149 -0
  940. package/examples/hooks/permission-gate.ts +33 -0
  941. package/examples/hooks/protected-paths.ts +29 -0
  942. package/examples/hooks/qna.ts +118 -0
  943. package/examples/hooks/status-line.ts +39 -0
  944. package/examples/sdk/01-minimal.ts +21 -0
  945. package/examples/sdk/02-custom-model.ts +49 -0
  946. package/examples/sdk/03-custom-prompt.ts +46 -0
  947. package/examples/sdk/04-skills.ts +43 -0
  948. package/examples/sdk/06-extensions.ts +82 -0
  949. package/examples/sdk/06-hooks.ts +61 -0
  950. package/examples/sdk/07-context-files.ts +35 -0
  951. package/examples/sdk/08-prompt-templates.ts +41 -0
  952. package/examples/sdk/08-slash-commands.ts +46 -0
  953. package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
  954. package/examples/sdk/11-sessions.ts +47 -0
  955. package/examples/sdk/README.md +172 -0
  956. package/package.json +540 -0
  957. package/scripts/build-binary.ts +95 -0
  958. package/scripts/format-prompts.ts +68 -0
  959. package/scripts/generate-docs-index.ts +71 -0
  960. package/scripts/generate-template.ts +33 -0
  961. package/src/async/index.ts +2 -0
  962. package/src/async/job-manager.ts +1489 -0
  963. package/src/async/support.ts +6 -0
  964. package/src/autoresearch/command-resume.md +14 -0
  965. package/src/autoresearch/dashboard.ts +446 -0
  966. package/src/autoresearch/git.ts +319 -0
  967. package/src/autoresearch/helpers.ts +218 -0
  968. package/src/autoresearch/index.ts +536 -0
  969. package/src/autoresearch/prompt-setup.md +43 -0
  970. package/src/autoresearch/prompt.md +103 -0
  971. package/src/autoresearch/resume-message.md +10 -0
  972. package/src/autoresearch/state.ts +273 -0
  973. package/src/autoresearch/storage.ts +699 -0
  974. package/src/autoresearch/tools/init-experiment.ts +272 -0
  975. package/src/autoresearch/tools/log-experiment.ts +524 -0
  976. package/src/autoresearch/tools/run-experiment.ts +475 -0
  977. package/src/autoresearch/tools/update-notes.ts +109 -0
  978. package/src/autoresearch/types.ts +168 -0
  979. package/src/bun-imports.d.ts +28 -0
  980. package/src/capability/context-file.ts +44 -0
  981. package/src/capability/extension-module.ts +34 -0
  982. package/src/capability/extension.ts +47 -0
  983. package/src/capability/fs.ts +107 -0
  984. package/src/capability/hook.ts +40 -0
  985. package/src/capability/index.ts +436 -0
  986. package/src/capability/instruction.ts +37 -0
  987. package/src/capability/mcp.ts +74 -0
  988. package/src/capability/prompt.ts +35 -0
  989. package/src/capability/rule.ts +244 -0
  990. package/src/capability/settings.ts +34 -0
  991. package/src/capability/skill.ts +56 -0
  992. package/src/capability/slash-command.ts +40 -0
  993. package/src/capability/ssh.ts +41 -0
  994. package/src/capability/system-prompt.ts +34 -0
  995. package/src/capability/tool.ts +38 -0
  996. package/src/capability/types.ts +168 -0
  997. package/src/cli/agents-cli.ts +141 -0
  998. package/src/cli/args.ts +306 -0
  999. package/src/cli/auth-broker-cli.ts +748 -0
  1000. package/src/cli/auth-gateway-cli.ts +411 -0
  1001. package/src/cli/classify-install-target.ts +50 -0
  1002. package/src/cli/commands/init-xdg.ts +27 -0
  1003. package/src/cli/config-cli.ts +426 -0
  1004. package/src/cli/fast-help.ts +82 -0
  1005. package/src/cli/file-processor.ts +123 -0
  1006. package/src/cli/grep-cli.ts +160 -0
  1007. package/src/cli/initial-message.ts +58 -0
  1008. package/src/cli/list-models.ts +206 -0
  1009. package/src/cli/plugin-cli.ts +942 -0
  1010. package/src/cli/read-cli.ts +57 -0
  1011. package/src/cli/session-picker.ts +52 -0
  1012. package/src/cli/setup-cli.ts +675 -0
  1013. package/src/cli/shell-cli.ts +176 -0
  1014. package/src/cli/skills-cli.ts +88 -0
  1015. package/src/cli/ssh-cli.ts +179 -0
  1016. package/src/cli/stats-cli.ts +238 -0
  1017. package/src/cli/update-cli.ts +459 -0
  1018. package/src/cli/web-search-cli.ts +248 -0
  1019. package/src/cli/worktree-cli.ts +291 -0
  1020. package/src/cli.ts +225 -0
  1021. package/src/commands/acp.ts +24 -0
  1022. package/src/commands/agents.ts +57 -0
  1023. package/src/commands/auth-broker.ts +96 -0
  1024. package/src/commands/auth-gateway.ts +63 -0
  1025. package/src/commands/codex-native-hook.ts +11 -0
  1026. package/src/commands/commit.ts +46 -0
  1027. package/src/commands/config.ts +51 -0
  1028. package/src/commands/contribution-prep.ts +41 -0
  1029. package/src/commands/coordinator.ts +113 -0
  1030. package/src/commands/deep-interview.ts +39 -0
  1031. package/src/commands/gc.ts +22 -0
  1032. package/src/commands/grep.ts +48 -0
  1033. package/src/commands/harness.ts +1207 -0
  1034. package/src/commands/launch.ts +178 -0
  1035. package/src/commands/mcp-serve.ts +63 -0
  1036. package/src/commands/plugin.ts +78 -0
  1037. package/src/commands/ralplan.ts +19 -0
  1038. package/src/commands/read.ts +35 -0
  1039. package/src/commands/rlm.ts +19 -0
  1040. package/src/commands/session.ts +152 -0
  1041. package/src/commands/setup.ts +91 -0
  1042. package/src/commands/shell.ts +29 -0
  1043. package/src/commands/skills.ts +48 -0
  1044. package/src/commands/ssh.ts +60 -0
  1045. package/src/commands/state.ts +24 -0
  1046. package/src/commands/stats.ts +29 -0
  1047. package/src/commands/team.ts +216 -0
  1048. package/src/commands/ultragoal.ts +41 -0
  1049. package/src/commands/update.ts +21 -0
  1050. package/src/commands/web-search.ts +108 -0
  1051. package/src/commands/worktree.ts +56 -0
  1052. package/src/commit/agentic/agent.ts +316 -0
  1053. package/src/commit/agentic/fallback.ts +96 -0
  1054. package/src/commit/agentic/index.ts +356 -0
  1055. package/src/commit/agentic/prompts/analyze-file.md +22 -0
  1056. package/src/commit/agentic/prompts/session-user.md +25 -0
  1057. package/src/commit/agentic/prompts/split-confirm.md +1 -0
  1058. package/src/commit/agentic/prompts/system.md +38 -0
  1059. package/src/commit/agentic/state.ts +60 -0
  1060. package/src/commit/agentic/tools/analyze-file.ts +127 -0
  1061. package/src/commit/agentic/tools/git-file-diff.ts +191 -0
  1062. package/src/commit/agentic/tools/git-hunk.ts +50 -0
  1063. package/src/commit/agentic/tools/git-overview.ts +81 -0
  1064. package/src/commit/agentic/tools/index.ts +54 -0
  1065. package/src/commit/agentic/tools/propose-changelog.ts +144 -0
  1066. package/src/commit/agentic/tools/propose-commit.ts +109 -0
  1067. package/src/commit/agentic/tools/recent-commits.ts +81 -0
  1068. package/src/commit/agentic/tools/schemas.ts +23 -0
  1069. package/src/commit/agentic/tools/split-commit.ts +238 -0
  1070. package/src/commit/agentic/topo-sort.ts +44 -0
  1071. package/src/commit/agentic/trivial.ts +51 -0
  1072. package/src/commit/agentic/validation.ts +183 -0
  1073. package/src/commit/analysis/conventional.ts +64 -0
  1074. package/src/commit/analysis/index.ts +4 -0
  1075. package/src/commit/analysis/scope.ts +242 -0
  1076. package/src/commit/analysis/summary.ts +105 -0
  1077. package/src/commit/analysis/validation.ts +66 -0
  1078. package/src/commit/changelog/detect.ts +40 -0
  1079. package/src/commit/changelog/generate.ts +97 -0
  1080. package/src/commit/changelog/index.ts +234 -0
  1081. package/src/commit/changelog/parse.ts +44 -0
  1082. package/src/commit/cli.ts +85 -0
  1083. package/src/commit/git/diff.ts +148 -0
  1084. package/src/commit/index.ts +5 -0
  1085. package/src/commit/map-reduce/index.ts +69 -0
  1086. package/src/commit/map-reduce/map-phase.ts +193 -0
  1087. package/src/commit/map-reduce/reduce-phase.ts +49 -0
  1088. package/src/commit/map-reduce/utils.ts +9 -0
  1089. package/src/commit/message.ts +11 -0
  1090. package/src/commit/model-selection.ts +51 -0
  1091. package/src/commit/pipeline.ts +244 -0
  1092. package/src/commit/prompts/analysis-system.md +148 -0
  1093. package/src/commit/prompts/analysis-user.md +38 -0
  1094. package/src/commit/prompts/changelog-system.md +50 -0
  1095. package/src/commit/prompts/changelog-user.md +18 -0
  1096. package/src/commit/prompts/file-observer-system.md +24 -0
  1097. package/src/commit/prompts/file-observer-user.md +8 -0
  1098. package/src/commit/prompts/reduce-system.md +50 -0
  1099. package/src/commit/prompts/reduce-user.md +17 -0
  1100. package/src/commit/prompts/summary-retry.md +3 -0
  1101. package/src/commit/prompts/summary-system.md +38 -0
  1102. package/src/commit/prompts/summary-user.md +13 -0
  1103. package/src/commit/prompts/types-description.md +2 -0
  1104. package/src/commit/shared-llm.ts +77 -0
  1105. package/src/commit/types.ts +118 -0
  1106. package/src/commit/utils/exclusions.ts +42 -0
  1107. package/src/commit/utils.ts +58 -0
  1108. package/src/config/config-file.ts +232 -0
  1109. package/src/config/file-lock-gc.ts +193 -0
  1110. package/src/config/file-lock.ts +185 -0
  1111. package/src/config/keybindings.ts +510 -0
  1112. package/src/config/mcp-schema.json +230 -0
  1113. package/src/config/model-equivalence.ts +811 -0
  1114. package/src/config/model-profile-activation.ts +249 -0
  1115. package/src/config/model-profiles.ts +396 -0
  1116. package/src/config/model-registry.ts +2816 -0
  1117. package/src/config/model-resolver.ts +1336 -0
  1118. package/src/config/models-config-schema.ts +258 -0
  1119. package/src/config/prompt-templates.ts +310 -0
  1120. package/src/config/resolve-config-value.ts +94 -0
  1121. package/src/config/settings-schema.ts +3183 -0
  1122. package/src/config/settings.ts +967 -0
  1123. package/src/config/skill-settings-defaults.ts +27 -0
  1124. package/src/config.ts +212 -0
  1125. package/src/coordinator/contract.ts +22 -0
  1126. package/src/coordinator-mcp/policy.ts +160 -0
  1127. package/src/coordinator-mcp/safety.ts +80 -0
  1128. package/src/coordinator-mcp/server.ts +2006 -0
  1129. package/src/cursor.ts +392 -0
  1130. package/src/dap/client.ts +730 -0
  1131. package/src/dap/config.ts +150 -0
  1132. package/src/dap/defaults.json +211 -0
  1133. package/src/dap/index.ts +4 -0
  1134. package/src/dap/session.ts +1343 -0
  1135. package/src/dap/types.ts +600 -0
  1136. package/src/debug/crash-diagnostics.ts +223 -0
  1137. package/src/debug/index.ts +459 -0
  1138. package/src/debug/log-formatting.ts +58 -0
  1139. package/src/debug/log-viewer.ts +908 -0
  1140. package/src/debug/profiler.ts +162 -0
  1141. package/src/debug/raw-sse-buffer.ts +270 -0
  1142. package/src/debug/raw-sse.ts +213 -0
  1143. package/src/debug/report-bundle.ts +365 -0
  1144. package/src/debug/runtime-gauges.ts +20 -0
  1145. package/src/debug/system-info.ts +111 -0
  1146. package/src/deep-interview/render-middleware.ts +372 -0
  1147. package/src/defaults/skc/agent.models.grok-cli.yml +36 -0
  1148. package/src/defaults/skc/extensions/grok-build/index.ts +1 -0
  1149. package/src/defaults/skc/extensions/grok-build/package.json +7 -0
  1150. package/src/defaults/skc/extensions/grok-cli-vendor/biome.json +39 -0
  1151. package/src/defaults/skc/extensions/grok-cli-vendor/package.json +8 -0
  1152. package/src/defaults/skc/extensions/grok-cli-vendor/src/index.ts +1 -0
  1153. package/src/defaults/skc/extensions/grok-cli-vendor/src/models/catalog.ts +155 -0
  1154. package/src/defaults/skc/extensions/grok-cli-vendor/src/payload/sanitize.ts +361 -0
  1155. package/src/defaults/skc/extensions/grok-cli-vendor/src/provider/billing.ts +57 -0
  1156. package/src/defaults/skc/extensions/grok-cli-vendor/src/provider/register.ts +99 -0
  1157. package/src/defaults/skc/extensions/grok-cli-vendor/src/provider/stream.ts +50 -0
  1158. package/src/defaults/skc/extensions/grok-cli-vendor/src/provider/usage.ts +56 -0
  1159. package/src/defaults/skc/extensions/grok-cli-vendor/src/shared/base-url.ts +36 -0
  1160. package/src/defaults/skc/extensions/grok-cli-vendor/src/shared/errors.ts +44 -0
  1161. package/src/defaults/skc/skills/deep-interview/SKILL.md +879 -0
  1162. package/src/defaults/skc/skills/deep-interview/auto-answer-uncertain.md +37 -0
  1163. package/src/defaults/skc/skills/deep-interview/auto-research-greenfield.md +42 -0
  1164. package/src/defaults/skc/skills/deep-interview/lateral-review-panel.md +49 -0
  1165. package/src/defaults/skc/skills/ralplan/SKILL.md +191 -0
  1166. package/src/defaults/skc/skills/team/SKILL.md +442 -0
  1167. package/src/defaults/skc/skills/ultragoal/SKILL.md +349 -0
  1168. package/src/defaults/skc/skills/ultragoal/ai-slop-cleaner.md +61 -0
  1169. package/src/defaults/skc-defaults.ts +217 -0
  1170. package/src/defaults/skc-grok-cli.ts +22 -0
  1171. package/src/discovery/agents-md.ts +67 -0
  1172. package/src/discovery/agents.ts +230 -0
  1173. package/src/discovery/builtin.ts +932 -0
  1174. package/src/discovery/claude-plugins.ts +407 -0
  1175. package/src/discovery/claude.ts +313 -0
  1176. package/src/discovery/cline.ts +83 -0
  1177. package/src/discovery/codex.ts +330 -0
  1178. package/src/discovery/cursor.ts +220 -0
  1179. package/src/discovery/gemini.ts +383 -0
  1180. package/src/discovery/github.ts +118 -0
  1181. package/src/discovery/helpers.ts +992 -0
  1182. package/src/discovery/index.ts +76 -0
  1183. package/src/discovery/mcp-json.ts +171 -0
  1184. package/src/discovery/opencode.ts +398 -0
  1185. package/src/discovery/plugin-dir-roots.ts +28 -0
  1186. package/src/discovery/ssh.ts +153 -0
  1187. package/src/discovery/substitute-plugin-root.ts +29 -0
  1188. package/src/discovery/vscode.ts +105 -0
  1189. package/src/discovery/windsurf.ts +147 -0
  1190. package/src/edit/apply-patch/index.ts +87 -0
  1191. package/src/edit/apply-patch/parser.ts +174 -0
  1192. package/src/edit/diff.ts +873 -0
  1193. package/src/edit/file-read-cache.ts +95 -0
  1194. package/src/edit/index.ts +528 -0
  1195. package/src/edit/modes/apply-patch.lark +19 -0
  1196. package/src/edit/modes/apply-patch.ts +53 -0
  1197. package/src/edit/modes/patch.ts +1835 -0
  1198. package/src/edit/modes/replace.ts +1161 -0
  1199. package/src/edit/normalize.ts +375 -0
  1200. package/src/edit/notebook.ts +226 -0
  1201. package/src/edit/read-file.ts +43 -0
  1202. package/src/edit/renderer.ts +683 -0
  1203. package/src/edit/streaming.ts +561 -0
  1204. package/src/eval/backend.ts +43 -0
  1205. package/src/eval/index.ts +4 -0
  1206. package/src/eval/js/context-manager.ts +577 -0
  1207. package/src/eval/js/executor.ts +136 -0
  1208. package/src/eval/js/index.ts +47 -0
  1209. package/src/eval/js/shared/helpers.ts +237 -0
  1210. package/src/eval/js/shared/indirect-eval.ts +30 -0
  1211. package/src/eval/js/shared/prelude.ts +2 -0
  1212. package/src/eval/js/shared/prelude.txt +70 -0
  1213. package/src/eval/js/shared/rewrite-imports.ts +415 -0
  1214. package/src/eval/js/shared/runtime.ts +301 -0
  1215. package/src/eval/js/shared/types.ts +18 -0
  1216. package/src/eval/js/tool-bridge.ts +144 -0
  1217. package/src/eval/js/worker-core.ts +150 -0
  1218. package/src/eval/js/worker-entry.ts +24 -0
  1219. package/src/eval/js/worker-protocol.ts +41 -0
  1220. package/src/eval/py/display.ts +71 -0
  1221. package/src/eval/py/executor.ts +678 -0
  1222. package/src/eval/py/index.ts +58 -0
  1223. package/src/eval/py/kernel.ts +712 -0
  1224. package/src/eval/py/prelude.py +462 -0
  1225. package/src/eval/py/prelude.ts +3 -0
  1226. package/src/eval/py/runner.py +964 -0
  1227. package/src/eval/py/runtime.ts +331 -0
  1228. package/src/eval/py/tool-bridge.ts +137 -0
  1229. package/src/eval/types.ts +48 -0
  1230. package/src/exa/factory.ts +60 -0
  1231. package/src/exa/index.ts +27 -0
  1232. package/src/exa/mcp-client.ts +364 -0
  1233. package/src/exa/render.ts +244 -0
  1234. package/src/exa/researcher.ts +36 -0
  1235. package/src/exa/search.ts +47 -0
  1236. package/src/exa/types.ts +166 -0
  1237. package/src/exa/websets.ts +248 -0
  1238. package/src/exec/bash-executor.ts +403 -0
  1239. package/src/exec/exec.ts +53 -0
  1240. package/src/exec/idle-timeout-watchdog.ts +126 -0
  1241. package/src/exec/non-interactive-env.ts +48 -0
  1242. package/src/export/custom-share.ts +65 -0
  1243. package/src/export/html/index.ts +168 -0
  1244. package/src/export/html/template.css +1060 -0
  1245. package/src/export/html/template.generated.ts +2 -0
  1246. package/src/export/html/template.html +47 -0
  1247. package/src/export/html/template.js +2268 -0
  1248. package/src/export/html/template.macro.ts +25 -0
  1249. package/src/export/html/vendor/highlight.min.js +1213 -0
  1250. package/src/export/html/vendor/marked.min.js +6 -0
  1251. package/src/export/ttsr.ts +434 -0
  1252. package/src/extensibility/custom-commands/bundled/ci-green/index.ts +25 -0
  1253. package/src/extensibility/custom-commands/bundled/review/index.ts +456 -0
  1254. package/src/extensibility/custom-commands/index.ts +2 -0
  1255. package/src/extensibility/custom-commands/loader.ts +238 -0
  1256. package/src/extensibility/custom-commands/types.ts +113 -0
  1257. package/src/extensibility/custom-tools/index.ts +7 -0
  1258. package/src/extensibility/custom-tools/loader.ts +245 -0
  1259. package/src/extensibility/custom-tools/types.ts +257 -0
  1260. package/src/extensibility/custom-tools/wrapper.ts +49 -0
  1261. package/src/extensibility/extensions/compact-handler.ts +40 -0
  1262. package/src/extensibility/extensions/get-commands-handler.ts +80 -0
  1263. package/src/extensibility/extensions/index.ts +16 -0
  1264. package/src/extensibility/extensions/loader.ts +551 -0
  1265. package/src/extensibility/extensions/prefix-command-bridge.ts +128 -0
  1266. package/src/extensibility/extensions/runner.ts +900 -0
  1267. package/src/extensibility/extensions/types.ts +1286 -0
  1268. package/src/extensibility/extensions/wrapper.ts +190 -0
  1269. package/src/extensibility/hooks/index.ts +5 -0
  1270. package/src/extensibility/hooks/loader.ts +257 -0
  1271. package/src/extensibility/hooks/runner.ts +425 -0
  1272. package/src/extensibility/hooks/tool-wrapper.ts +107 -0
  1273. package/src/extensibility/hooks/types.ts +599 -0
  1274. package/src/extensibility/plugins/doctor.ts +66 -0
  1275. package/src/extensibility/plugins/git-url.ts +281 -0
  1276. package/src/extensibility/plugins/index.ts +9 -0
  1277. package/src/extensibility/plugins/installer.ts +192 -0
  1278. package/src/extensibility/plugins/legacy-pi-compat.ts +336 -0
  1279. package/src/extensibility/plugins/loader.ts +288 -0
  1280. package/src/extensibility/plugins/manager.ts +731 -0
  1281. package/src/extensibility/plugins/marketplace/cache.ts +136 -0
  1282. package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
  1283. package/src/extensibility/plugins/marketplace/index.ts +6 -0
  1284. package/src/extensibility/plugins/marketplace/manager.ts +770 -0
  1285. package/src/extensibility/plugins/marketplace/registry.ts +196 -0
  1286. package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
  1287. package/src/extensibility/plugins/marketplace/types.ts +191 -0
  1288. package/src/extensibility/plugins/parser.ts +105 -0
  1289. package/src/extensibility/plugins/types.ts +194 -0
  1290. package/src/extensibility/shared-events.ts +344 -0
  1291. package/src/extensibility/skc-plugins/activation.ts +87 -0
  1292. package/src/extensibility/skc-plugins/index.ts +9 -0
  1293. package/src/extensibility/skc-plugins/injection.ts +114 -0
  1294. package/src/extensibility/skc-plugins/loader.ts +131 -0
  1295. package/src/extensibility/skc-plugins/paths.ts +66 -0
  1296. package/src/extensibility/skc-plugins/schema.ts +79 -0
  1297. package/src/extensibility/skc-plugins/state.ts +29 -0
  1298. package/src/extensibility/skc-plugins/tools.ts +47 -0
  1299. package/src/extensibility/skc-plugins/types.ts +97 -0
  1300. package/src/extensibility/skc-plugins/validation.ts +76 -0
  1301. package/src/extensibility/skills.ts +423 -0
  1302. package/src/extensibility/slash-commands.ts +236 -0
  1303. package/src/extensibility/tool-proxy.ts +25 -0
  1304. package/src/extensibility/typebox.ts +418 -0
  1305. package/src/extensibility/utils.ts +44 -0
  1306. package/src/goals/index.ts +3 -0
  1307. package/src/goals/runtime.ts +419 -0
  1308. package/src/goals/state.ts +66 -0
  1309. package/src/goals/tools/goal-tool.ts +237 -0
  1310. package/src/harness-control-plane/classifier.ts +128 -0
  1311. package/src/harness-control-plane/control-endpoint.ts +148 -0
  1312. package/src/harness-control-plane/finalize.ts +340 -0
  1313. package/src/harness-control-plane/gc-adapter.ts +184 -0
  1314. package/src/harness-control-plane/operate.ts +225 -0
  1315. package/src/harness-control-plane/owner.ts +684 -0
  1316. package/src/harness-control-plane/phase-rollup.ts +96 -0
  1317. package/src/harness-control-plane/preserve.ts +102 -0
  1318. package/src/harness-control-plane/receipt-ingest.ts +127 -0
  1319. package/src/harness-control-plane/receipt-spool.ts +128 -0
  1320. package/src/harness-control-plane/receipts.ts +482 -0
  1321. package/src/harness-control-plane/rpc-adapter.ts +290 -0
  1322. package/src/harness-control-plane/seams.ts +39 -0
  1323. package/src/harness-control-plane/session-lease.ts +388 -0
  1324. package/src/harness-control-plane/state-machine.ts +119 -0
  1325. package/src/harness-control-plane/storage.ts +492 -0
  1326. package/src/harness-control-plane/types.ts +267 -0
  1327. package/src/hashline/anchors.ts +113 -0
  1328. package/src/hashline/apply.ts +737 -0
  1329. package/src/hashline/bigrams.json +649 -0
  1330. package/src/hashline/constants.ts +25 -0
  1331. package/src/hashline/diff-preview.ts +43 -0
  1332. package/src/hashline/diff.ts +56 -0
  1333. package/src/hashline/execute.ts +267 -0
  1334. package/src/hashline/grammar.lark +21 -0
  1335. package/src/hashline/hash.ts +196 -0
  1336. package/src/hashline/index.ts +13 -0
  1337. package/src/hashline/input.ts +130 -0
  1338. package/src/hashline/parser.ts +246 -0
  1339. package/src/hashline/prefixes.ts +101 -0
  1340. package/src/hashline/recovery.ts +113 -0
  1341. package/src/hashline/stream.ts +123 -0
  1342. package/src/hashline/types.ts +68 -0
  1343. package/src/hindsight/backend.ts +205 -0
  1344. package/src/hindsight/bank.ts +131 -0
  1345. package/src/hindsight/client.ts +598 -0
  1346. package/src/hindsight/config.ts +175 -0
  1347. package/src/hindsight/content.ts +210 -0
  1348. package/src/hindsight/index.ts +8 -0
  1349. package/src/hindsight/mental-models.ts +383 -0
  1350. package/src/hindsight/seeds.json +32 -0
  1351. package/src/hindsight/state.ts +469 -0
  1352. package/src/hindsight/transcript.ts +71 -0
  1353. package/src/hooks/codex-native-hooks-config.ts +143 -0
  1354. package/src/hooks/native-skill-hook.ts +305 -0
  1355. package/src/hooks/skill-keywords.ts +88 -0
  1356. package/src/hooks/skill-state.ts +753 -0
  1357. package/src/i18n/index.ts +188 -0
  1358. package/src/i18n/messages/de.messages.ts +308 -0
  1359. package/src/i18n/messages/de.settings.ts +805 -0
  1360. package/src/i18n/messages/de.ts +65 -0
  1361. package/src/i18n/messages/en.ts +86 -0
  1362. package/src/i18n/messages/es.messages.ts +314 -0
  1363. package/src/i18n/messages/es.settings.ts +798 -0
  1364. package/src/i18n/messages/es.ts +65 -0
  1365. package/src/i18n/messages/fr.messages.ts +312 -0
  1366. package/src/i18n/messages/fr.settings.ts +771 -0
  1367. package/src/i18n/messages/fr.ts +65 -0
  1368. package/src/i18n/messages/ja.messages.ts +314 -0
  1369. package/src/i18n/messages/ja.settings.ts +809 -0
  1370. package/src/i18n/messages/ja.ts +69 -0
  1371. package/src/i18n/messages/ko.messages.ts +312 -0
  1372. package/src/i18n/messages/ko.settings.ts +798 -0
  1373. package/src/i18n/messages/ko.ts +69 -0
  1374. package/src/i18n/messages/zh.messages.ts +298 -0
  1375. package/src/i18n/messages/zh.settings.ts +779 -0
  1376. package/src/i18n/messages/zh.ts +69 -0
  1377. package/src/index.ts +56 -0
  1378. package/src/internal-urls/agent-protocol.ts +176 -0
  1379. package/src/internal-urls/artifact-protocol.ts +84 -0
  1380. package/src/internal-urls/docs-index.generated.ts +106 -0
  1381. package/src/internal-urls/index.ts +21 -0
  1382. package/src/internal-urls/issue-pr-protocol.ts +577 -0
  1383. package/src/internal-urls/json-query.ts +126 -0
  1384. package/src/internal-urls/local-protocol.ts +249 -0
  1385. package/src/internal-urls/mcp-protocol.ts +151 -0
  1386. package/src/internal-urls/memory-protocol.ts +165 -0
  1387. package/src/internal-urls/parse.ts +72 -0
  1388. package/src/internal-urls/registry-helpers.ts +28 -0
  1389. package/src/internal-urls/router.ts +78 -0
  1390. package/src/internal-urls/rule-protocol.ts +38 -0
  1391. package/src/internal-urls/skc-protocol.ts +83 -0
  1392. package/src/internal-urls/skill-protocol.ts +103 -0
  1393. package/src/internal-urls/types.ts +114 -0
  1394. package/src/lsp/client.ts +1012 -0
  1395. package/src/lsp/clients/biome-client.ts +202 -0
  1396. package/src/lsp/clients/index.ts +50 -0
  1397. package/src/lsp/clients/lsp-linter-client.ts +93 -0
  1398. package/src/lsp/clients/swiftlint-client.ts +120 -0
  1399. package/src/lsp/config.ts +492 -0
  1400. package/src/lsp/defaults.json +494 -0
  1401. package/src/lsp/edits.ts +166 -0
  1402. package/src/lsp/index.ts +2283 -0
  1403. package/src/lsp/lspmux.ts +257 -0
  1404. package/src/lsp/render.ts +692 -0
  1405. package/src/lsp/startup-events.ts +13 -0
  1406. package/src/lsp/types.ts +445 -0
  1407. package/src/lsp/utils.ts +678 -0
  1408. package/src/main.ts +1080 -0
  1409. package/src/memories/index.ts +1137 -0
  1410. package/src/memories/storage.ts +577 -0
  1411. package/src/memory-backend/index.ts +4 -0
  1412. package/src/memory-backend/local-backend.ts +38 -0
  1413. package/src/memory-backend/off-backend.ts +16 -0
  1414. package/src/memory-backend/resolve.ts +24 -0
  1415. package/src/memory-backend/types.ts +79 -0
  1416. package/src/modes/acp/acp-agent.ts +2203 -0
  1417. package/src/modes/acp/acp-client-bridge.ts +154 -0
  1418. package/src/modes/acp/acp-event-mapper.ts +911 -0
  1419. package/src/modes/acp/acp-mode.ts +23 -0
  1420. package/src/modes/acp/index.ts +2 -0
  1421. package/src/modes/acp/terminal-auth.ts +37 -0
  1422. package/src/modes/bridge/auth.ts +41 -0
  1423. package/src/modes/bridge/bridge-client-bridge.ts +47 -0
  1424. package/src/modes/bridge/bridge-mode.ts +664 -0
  1425. package/src/modes/bridge/bridge-ui-context.ts +200 -0
  1426. package/src/modes/bridge/event-stream.ts +70 -0
  1427. package/src/modes/components/agent-dashboard.ts +1120 -0
  1428. package/src/modes/components/assistant-message.ts +255 -0
  1429. package/src/modes/components/bash-execution.ts +232 -0
  1430. package/src/modes/components/bordered-loader.ts +41 -0
  1431. package/src/modes/components/branch-summary-message.ts +45 -0
  1432. package/src/modes/components/btw-panel.ts +104 -0
  1433. package/src/modes/components/compaction-summary-message.ts +51 -0
  1434. package/src/modes/components/countdown-timer.ts +75 -0
  1435. package/src/modes/components/custom-editor.ts +363 -0
  1436. package/src/modes/components/custom-message.ts +65 -0
  1437. package/src/modes/components/custom-model-preset-wizard.ts +293 -0
  1438. package/src/modes/components/custom-provider-wizard.ts +318 -0
  1439. package/src/modes/components/diff.ts +363 -0
  1440. package/src/modes/components/dynamic-border.ts +25 -0
  1441. package/src/modes/components/eval-execution.ts +168 -0
  1442. package/src/modes/components/execution-shared.ts +102 -0
  1443. package/src/modes/components/extensions/extension-dashboard.ts +350 -0
  1444. package/src/modes/components/extensions/extension-list.ts +492 -0
  1445. package/src/modes/components/extensions/index.ts +9 -0
  1446. package/src/modes/components/extensions/inspector-panel.ts +317 -0
  1447. package/src/modes/components/extensions/state-manager.ts +628 -0
  1448. package/src/modes/components/extensions/types.ts +191 -0
  1449. package/src/modes/components/footer.ts +270 -0
  1450. package/src/modes/components/history-search.ts +162 -0
  1451. package/src/modes/components/hook-editor.ts +151 -0
  1452. package/src/modes/components/hook-input.ts +79 -0
  1453. package/src/modes/components/hook-message.ts +68 -0
  1454. package/src/modes/components/hook-selector.ts +582 -0
  1455. package/src/modes/components/index.ts +36 -0
  1456. package/src/modes/components/jobs-overlay-model.ts +109 -0
  1457. package/src/modes/components/jobs-overlay.ts +172 -0
  1458. package/src/modes/components/keybinding-hints.ts +65 -0
  1459. package/src/modes/components/login-dialog.ts +164 -0
  1460. package/src/modes/components/message-frame.ts +88 -0
  1461. package/src/modes/components/model-selector.ts +1477 -0
  1462. package/src/modes/components/oauth-selector.ts +253 -0
  1463. package/src/modes/components/plugin-selector.ts +95 -0
  1464. package/src/modes/components/plugin-settings.ts +488 -0
  1465. package/src/modes/components/provider-onboarding-selector.ts +98 -0
  1466. package/src/modes/components/queue-mode-selector.ts +56 -0
  1467. package/src/modes/components/read-tool-group.ts +267 -0
  1468. package/src/modes/components/runtime-mcp-add-wizard.ts +1392 -0
  1469. package/src/modes/components/session-observer-overlay.ts +839 -0
  1470. package/src/modes/components/session-selector.ts +343 -0
  1471. package/src/modes/components/settings-defs.ts +175 -0
  1472. package/src/modes/components/settings-selector.ts +662 -0
  1473. package/src/modes/components/show-images-selector.ts +45 -0
  1474. package/src/modes/components/skill-hud/render.ts +83 -0
  1475. package/src/modes/components/skill-message.ts +152 -0
  1476. package/src/modes/components/status-line/context-thresholds.ts +68 -0
  1477. package/src/modes/components/status-line/git-utils.ts +42 -0
  1478. package/src/modes/components/status-line/index.ts +4 -0
  1479. package/src/modes/components/status-line/presets.ts +119 -0
  1480. package/src/modes/components/status-line/segments.ts +590 -0
  1481. package/src/modes/components/status-line/separators.ts +55 -0
  1482. package/src/modes/components/status-line/token-rate.ts +66 -0
  1483. package/src/modes/components/status-line/types.ts +92 -0
  1484. package/src/modes/components/status-line.ts +853 -0
  1485. package/src/modes/components/theme-selector.ts +63 -0
  1486. package/src/modes/components/thinking-selector.ts +52 -0
  1487. package/src/modes/components/todo-reminder.ts +40 -0
  1488. package/src/modes/components/tool-execution.ts +853 -0
  1489. package/src/modes/components/tree-selector.ts +930 -0
  1490. package/src/modes/components/ttsr-notification.ts +80 -0
  1491. package/src/modes/components/user-message-selector.ts +141 -0
  1492. package/src/modes/components/user-message.ts +51 -0
  1493. package/src/modes/components/visual-truncate.ts +63 -0
  1494. package/src/modes/components/welcome.ts +409 -0
  1495. package/src/modes/controllers/btw-controller.ts +105 -0
  1496. package/src/modes/controllers/command-controller-shared.ts +108 -0
  1497. package/src/modes/controllers/command-controller.ts +1672 -0
  1498. package/src/modes/controllers/event-controller.ts +852 -0
  1499. package/src/modes/controllers/extension-ui-controller.ts +1017 -0
  1500. package/src/modes/controllers/input-controller.ts +1047 -0
  1501. package/src/modes/controllers/runtime-mcp-command-controller.ts +1934 -0
  1502. package/src/modes/controllers/selector-controller.ts +1407 -0
  1503. package/src/modes/controllers/ssh-command-controller.ts +384 -0
  1504. package/src/modes/controllers/todo-command-controller.ts +485 -0
  1505. package/src/modes/data/emojis.json +1 -0
  1506. package/src/modes/emoji-autocomplete.ts +285 -0
  1507. package/src/modes/index.ts +35 -0
  1508. package/src/modes/interactive-mode.ts +2677 -0
  1509. package/src/modes/jobs-observer.ts +204 -0
  1510. package/src/modes/oauth-manual-input.ts +42 -0
  1511. package/src/modes/print-mode.ts +131 -0
  1512. package/src/modes/prompt-action-autocomplete.ts +409 -0
  1513. package/src/modes/rpc/host-tools.ts +1 -0
  1514. package/src/modes/rpc/host-uris.ts +1 -0
  1515. package/src/modes/rpc/rpc-client.ts +1085 -0
  1516. package/src/modes/rpc/rpc-mode.ts +808 -0
  1517. package/src/modes/rpc/rpc-socket-security.ts +103 -0
  1518. package/src/modes/rpc/rpc-types.ts +613 -0
  1519. package/src/modes/runtime-init.ts +116 -0
  1520. package/src/modes/session-observer-registry.ts +146 -0
  1521. package/src/modes/shared/agent-wire/approval-gate.ts +151 -0
  1522. package/src/modes/shared/agent-wire/command-contract.ts +18 -0
  1523. package/src/modes/shared/agent-wire/command-dispatch.ts +466 -0
  1524. package/src/modes/shared/agent-wire/command-validation.ts +167 -0
  1525. package/src/modes/shared/agent-wire/deep-interview-gate.ts +251 -0
  1526. package/src/modes/shared/agent-wire/event-contract.ts +147 -0
  1527. package/src/modes/shared/agent-wire/event-envelope.ts +140 -0
  1528. package/src/modes/shared/agent-wire/event-observation.ts +397 -0
  1529. package/src/modes/shared/agent-wire/handshake.ts +157 -0
  1530. package/src/modes/shared/agent-wire/host-tool-bridge.ts +197 -0
  1531. package/src/modes/shared/agent-wire/host-uri-bridge.ts +236 -0
  1532. package/src/modes/shared/agent-wire/protocol.ts +46 -0
  1533. package/src/modes/shared/agent-wire/responses.ts +17 -0
  1534. package/src/modes/shared/agent-wire/scopes.ts +92 -0
  1535. package/src/modes/shared/agent-wire/session-registry.ts +109 -0
  1536. package/src/modes/shared/agent-wire/ui-request-broker.ts +150 -0
  1537. package/src/modes/shared/agent-wire/ui-result.ts +48 -0
  1538. package/src/modes/shared/agent-wire/unattended-action-policy.ts +365 -0
  1539. package/src/modes/shared/agent-wire/unattended-audit.ts +175 -0
  1540. package/src/modes/shared/agent-wire/unattended-run-controller.ts +426 -0
  1541. package/src/modes/shared/agent-wire/unattended-session.ts +219 -0
  1542. package/src/modes/shared/agent-wire/workflow-gate-broker.ts +324 -0
  1543. package/src/modes/shared/agent-wire/workflow-gate-schema.ts +331 -0
  1544. package/src/modes/shared.ts +55 -0
  1545. package/src/modes/theme/defaults/blue-octopus.json +126 -0
  1546. package/src/modes/theme/defaults/claude-code.json +100 -0
  1547. package/src/modes/theme/defaults/codex.json +100 -0
  1548. package/src/modes/theme/defaults/index.ts +13 -0
  1549. package/src/modes/theme/defaults/opencode.json +102 -0
  1550. package/src/modes/theme/defaults/red-octopus.json +123 -0
  1551. package/src/modes/theme/mermaid-cache.ts +29 -0
  1552. package/src/modes/theme/shimmer.ts +219 -0
  1553. package/src/modes/theme/theme-schema.json +429 -0
  1554. package/src/modes/theme/theme.ts +2452 -0
  1555. package/src/modes/types.ts +313 -0
  1556. package/src/modes/utils/abort-message.ts +41 -0
  1557. package/src/modes/utils/context-usage.ts +391 -0
  1558. package/src/modes/utils/hotkeys-markdown.ts +61 -0
  1559. package/src/modes/utils/keybinding-matchers.ts +30 -0
  1560. package/src/modes/utils/tools-markdown.ts +27 -0
  1561. package/src/modes/utils/ui-helpers.ts +749 -0
  1562. package/src/plan-mode/approved-plan.ts +163 -0
  1563. package/src/plan-mode/state.ts +6 -0
  1564. package/src/prompts/agents/architect.md +92 -0
  1565. package/src/prompts/agents/critic.md +65 -0
  1566. package/src/prompts/agents/executor.md +63 -0
  1567. package/src/prompts/agents/explore.md +58 -0
  1568. package/src/prompts/agents/frontmatter.md +14 -0
  1569. package/src/prompts/agents/init.md +34 -0
  1570. package/src/prompts/agents/plan.md +49 -0
  1571. package/src/prompts/agents/planner.md +60 -0
  1572. package/src/prompts/agents/reviewer.md +141 -0
  1573. package/src/prompts/agents/task.md +16 -0
  1574. package/src/prompts/ci-green-request.md +36 -0
  1575. package/src/prompts/goals/goal-continuation.md +26 -0
  1576. package/src/prompts/goals/goal-mode-active.md +22 -0
  1577. package/src/prompts/memories/consolidation.md +30 -0
  1578. package/src/prompts/memories/read-path.md +10 -0
  1579. package/src/prompts/memories/stage_one_input.md +6 -0
  1580. package/src/prompts/memories/stage_one_system.md +21 -0
  1581. package/src/prompts/memories/unavailable.md +9 -0
  1582. package/src/prompts/review-request.md +70 -0
  1583. package/src/prompts/system/agent-creation-architect.md +75 -0
  1584. package/src/prompts/system/agent-creation-user.md +6 -0
  1585. package/src/prompts/system/auto-continue.md +1 -0
  1586. package/src/prompts/system/btw-user.md +8 -0
  1587. package/src/prompts/system/commit-message-system.md +2 -0
  1588. package/src/prompts/system/custom-system-prompt.md +64 -0
  1589. package/src/prompts/system/eager-todo.md +13 -0
  1590. package/src/prompts/system/irc-incoming.md +8 -0
  1591. package/src/prompts/system/plan-mode-active.md +116 -0
  1592. package/src/prompts/system/plan-mode-approved.md +28 -0
  1593. package/src/prompts/system/plan-mode-compact-instructions.md +16 -0
  1594. package/src/prompts/system/plan-mode-reference.md +14 -0
  1595. package/src/prompts/system/plan-mode-subagent.md +34 -0
  1596. package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
  1597. package/src/prompts/system/project-prompt.md +46 -0
  1598. package/src/prompts/system/rlm-report-command.md +1 -0
  1599. package/src/prompts/system/rlm-research.md +23 -0
  1600. package/src/prompts/system/subagent-system-prompt.md +60 -0
  1601. package/src/prompts/system/subagent-user-prompt.md +3 -0
  1602. package/src/prompts/system/subagent-yield-reminder.md +12 -0
  1603. package/src/prompts/system/system-prompt.md +275 -0
  1604. package/src/prompts/system/title-system.md +2 -0
  1605. package/src/prompts/system/ttsr-interrupt.md +7 -0
  1606. package/src/prompts/system/ttsr-tool-reminder.md +5 -0
  1607. package/src/prompts/system/web-search.md +25 -0
  1608. package/src/prompts/tools/apply-patch.md +65 -0
  1609. package/src/prompts/tools/ask.md +29 -0
  1610. package/src/prompts/tools/ast-edit.md +39 -0
  1611. package/src/prompts/tools/ast-grep.md +42 -0
  1612. package/src/prompts/tools/async-result.md +8 -0
  1613. package/src/prompts/tools/bash.md +69 -0
  1614. package/src/prompts/tools/browser.md +75 -0
  1615. package/src/prompts/tools/calculator.md +10 -0
  1616. package/src/prompts/tools/checkpoint.md +16 -0
  1617. package/src/prompts/tools/computer.md +74 -0
  1618. package/src/prompts/tools/cron.md +25 -0
  1619. package/src/prompts/tools/debug.md +33 -0
  1620. package/src/prompts/tools/eval.md +75 -0
  1621. package/src/prompts/tools/find.md +34 -0
  1622. package/src/prompts/tools/github.md +20 -0
  1623. package/src/prompts/tools/goal.md +21 -0
  1624. package/src/prompts/tools/hashline.md +130 -0
  1625. package/src/prompts/tools/image-gen.md +7 -0
  1626. package/src/prompts/tools/inspect-image-system.md +20 -0
  1627. package/src/prompts/tools/inspect-image.md +32 -0
  1628. package/src/prompts/tools/irc.md +49 -0
  1629. package/src/prompts/tools/job.md +27 -0
  1630. package/src/prompts/tools/lsp.md +42 -0
  1631. package/src/prompts/tools/monitor.md +30 -0
  1632. package/src/prompts/tools/patch.md +70 -0
  1633. package/src/prompts/tools/read.md +82 -0
  1634. package/src/prompts/tools/recall.md +6 -0
  1635. package/src/prompts/tools/recipe.md +16 -0
  1636. package/src/prompts/tools/reflect.md +6 -0
  1637. package/src/prompts/tools/render-mermaid.md +9 -0
  1638. package/src/prompts/tools/replace.md +36 -0
  1639. package/src/prompts/tools/resolve.md +9 -0
  1640. package/src/prompts/tools/retain.md +7 -0
  1641. package/src/prompts/tools/rewind.md +13 -0
  1642. package/src/prompts/tools/search-tool-bm25.md +33 -0
  1643. package/src/prompts/tools/search.md +25 -0
  1644. package/src/prompts/tools/skill.md +28 -0
  1645. package/src/prompts/tools/ssh.md +35 -0
  1646. package/src/prompts/tools/subagent.md +56 -0
  1647. package/src/prompts/tools/task-summary.md +22 -0
  1648. package/src/prompts/tools/task.md +86 -0
  1649. package/src/prompts/tools/todo-write.md +50 -0
  1650. package/src/prompts/tools/vim.md +98 -0
  1651. package/src/prompts/tools/web-search.md +17 -0
  1652. package/src/prompts/tools/write.md +14 -0
  1653. package/src/registry/agent-registry.ts +140 -0
  1654. package/src/reminders/star-reminder.ts +420 -0
  1655. package/src/rlm/artifacts.ts +60 -0
  1656. package/src/rlm/complete-research-tool.ts +163 -0
  1657. package/src/rlm/data-context.ts +26 -0
  1658. package/src/rlm/index.ts +339 -0
  1659. package/src/rlm/notebook.ts +108 -0
  1660. package/src/rlm/preset.ts +76 -0
  1661. package/src/rlm/python-tool.ts +68 -0
  1662. package/src/rlm/report.ts +70 -0
  1663. package/src/rlm/types.ts +40 -0
  1664. package/src/runtime/process-lifecycle.ts +400 -0
  1665. package/src/runtime-mcp/client.ts +485 -0
  1666. package/src/runtime-mcp/config-writer.ts +225 -0
  1667. package/src/runtime-mcp/config.ts +365 -0
  1668. package/src/runtime-mcp/discoverable-tool-metadata.ts +25 -0
  1669. package/src/runtime-mcp/index.ts +29 -0
  1670. package/src/runtime-mcp/json-rpc.ts +84 -0
  1671. package/src/runtime-mcp/loader.ts +124 -0
  1672. package/src/runtime-mcp/manager.ts +1331 -0
  1673. package/src/runtime-mcp/oauth-discovery.ts +349 -0
  1674. package/src/runtime-mcp/oauth-flow.ts +409 -0
  1675. package/src/runtime-mcp/render.ts +123 -0
  1676. package/src/runtime-mcp/smithery-auth.ts +104 -0
  1677. package/src/runtime-mcp/smithery-connect.ts +145 -0
  1678. package/src/runtime-mcp/smithery-registry.ts +477 -0
  1679. package/src/runtime-mcp/tool-bridge.ts +416 -0
  1680. package/src/runtime-mcp/tool-cache.ts +117 -0
  1681. package/src/runtime-mcp/transports/http.ts +504 -0
  1682. package/src/runtime-mcp/transports/index.ts +6 -0
  1683. package/src/runtime-mcp/transports/stdio.ts +352 -0
  1684. package/src/runtime-mcp/types.ts +426 -0
  1685. package/src/sdk.ts +2290 -0
  1686. package/src/secrets/index.ts +116 -0
  1687. package/src/secrets/obfuscator.ts +352 -0
  1688. package/src/secrets/regex.ts +21 -0
  1689. package/src/session/agent-session.ts +10226 -0
  1690. package/src/session/agent-storage.ts +466 -0
  1691. package/src/session/artifacts.ts +150 -0
  1692. package/src/session/auth-broker-config.ts +102 -0
  1693. package/src/session/auth-storage.ts +23 -0
  1694. package/src/session/blob-store.ts +428 -0
  1695. package/src/session/client-bridge.ts +85 -0
  1696. package/src/session/contribution-prep.ts +320 -0
  1697. package/src/session/history-storage.ts +332 -0
  1698. package/src/session/messages.ts +406 -0
  1699. package/src/session/session-dump-format.ts +209 -0
  1700. package/src/session/session-manager.ts +4049 -0
  1701. package/src/session/session-storage.ts +415 -0
  1702. package/src/session/streaming-output.ts +1269 -0
  1703. package/src/session/tool-choice-queue.ts +236 -0
  1704. package/src/session/yield-queue.ts +155 -0
  1705. package/src/setup/credential-import.ts +429 -0
  1706. package/src/setup/hermes/templates/operator-instructions.v1.md +36 -0
  1707. package/src/setup/hermes-setup.ts +484 -0
  1708. package/src/setup/model-onboarding-guidance.ts +48 -0
  1709. package/src/setup/provider-onboarding.ts +358 -0
  1710. package/src/skc-runtime/cli-write-receipt.ts +31 -0
  1711. package/src/skc-runtime/deep-interview-recorder.ts +457 -0
  1712. package/src/skc-runtime/deep-interview-runtime.ts +639 -0
  1713. package/src/skc-runtime/deep-interview-state.ts +324 -0
  1714. package/src/skc-runtime/gc-render.ts +70 -0
  1715. package/src/skc-runtime/gc-runtime.ts +403 -0
  1716. package/src/skc-runtime/goal-mode-request.ts +223 -0
  1717. package/src/skc-runtime/launch-tmux.ts +423 -0
  1718. package/src/skc-runtime/launch-worktree.ts +302 -0
  1719. package/src/skc-runtime/ledger-event-renderer.ts +164 -0
  1720. package/src/skc-runtime/ralplan-runtime.ts +877 -0
  1721. package/src/skc-runtime/restricted-role-agent-bash.ts +5 -0
  1722. package/src/skc-runtime/session-state-sidecar.ts +177 -0
  1723. package/src/skc-runtime/state-graph.ts +86 -0
  1724. package/src/skc-runtime/state-migrations.ts +179 -0
  1725. package/src/skc-runtime/state-renderer.ts +354 -0
  1726. package/src/skc-runtime/state-runtime.ts +2023 -0
  1727. package/src/skc-runtime/state-schema.ts +192 -0
  1728. package/src/skc-runtime/state-validation.ts +49 -0
  1729. package/src/skc-runtime/state-writer.ts +1012 -0
  1730. package/src/skc-runtime/team-gc.ts +49 -0
  1731. package/src/skc-runtime/team-runtime.ts +4355 -0
  1732. package/src/skc-runtime/tmux-common.ts +172 -0
  1733. package/src/skc-runtime/tmux-gc.ts +239 -0
  1734. package/src/skc-runtime/tmux-sessions.ts +271 -0
  1735. package/src/skc-runtime/ultragoal-guard.ts +455 -0
  1736. package/src/skc-runtime/ultragoal-runtime.ts +3684 -0
  1737. package/src/skc-runtime/workflow-command-ref.ts +239 -0
  1738. package/src/skc-runtime/workflow-manifest.generated.json +1676 -0
  1739. package/src/skc-runtime/workflow-manifest.ts +454 -0
  1740. package/src/skill-state/active-state.ts +839 -0
  1741. package/src/skill-state/deep-interview-mutation-guard.ts +452 -0
  1742. package/src/skill-state/initial-phase.ts +19 -0
  1743. package/src/skill-state/workflow-hud.ts +274 -0
  1744. package/src/skill-state/workflow-state-contract.ts +150 -0
  1745. package/src/skill-state/workflow-state-version.ts +3 -0
  1746. package/src/slash-commands/acp-builtins.ts +55 -0
  1747. package/src/slash-commands/builtin-registry.ts +1206 -0
  1748. package/src/slash-commands/helpers/context-report.ts +149 -0
  1749. package/src/slash-commands/helpers/fast-status-report.ts +111 -0
  1750. package/src/slash-commands/helpers/format.ts +46 -0
  1751. package/src/slash-commands/helpers/mcp.ts +532 -0
  1752. package/src/slash-commands/helpers/parse.ts +85 -0
  1753. package/src/slash-commands/helpers/ssh.ts +195 -0
  1754. package/src/slash-commands/helpers/todo.ts +279 -0
  1755. package/src/slash-commands/helpers/usage-report.ts +91 -0
  1756. package/src/slash-commands/types.ts +125 -0
  1757. package/src/ssh/config-writer.ts +183 -0
  1758. package/src/ssh/connection-manager.ts +482 -0
  1759. package/src/ssh/ssh-executor.ts +133 -0
  1760. package/src/ssh/sshfs-mount.ts +140 -0
  1761. package/src/ssh/utils.ts +8 -0
  1762. package/src/stt/downloader.ts +71 -0
  1763. package/src/stt/index.ts +3 -0
  1764. package/src/stt/recorder.ts +351 -0
  1765. package/src/stt/setup.ts +52 -0
  1766. package/src/stt/stt-controller.ts +160 -0
  1767. package/src/stt/transcribe.py +70 -0
  1768. package/src/stt/transcriber.ts +91 -0
  1769. package/src/system-prompt.ts +581 -0
  1770. package/src/task/agents.ts +164 -0
  1771. package/src/task/commands.ts +131 -0
  1772. package/src/task/discovery.ts +136 -0
  1773. package/src/task/executor.ts +1733 -0
  1774. package/src/task/fork-context-advisory.ts +99 -0
  1775. package/src/task/id.ts +33 -0
  1776. package/src/task/index.ts +1788 -0
  1777. package/src/task/name-generator.ts +1577 -0
  1778. package/src/task/output-manager.ts +108 -0
  1779. package/src/task/parallel.ts +116 -0
  1780. package/src/task/receipt.ts +304 -0
  1781. package/src/task/render.ts +1101 -0
  1782. package/src/task/roi-reconciliation.ts +90 -0
  1783. package/src/task/simple-mode.ts +27 -0
  1784. package/src/task/skc-command.ts +26 -0
  1785. package/src/task/spawn-gate.ts +132 -0
  1786. package/src/task/subprocess-tool-registry.ts +88 -0
  1787. package/src/task/types.ts +431 -0
  1788. package/src/task/worktree.ts +506 -0
  1789. package/src/thinking-metadata.ts +51 -0
  1790. package/src/thinking.ts +73 -0
  1791. package/src/tool-discovery/tool-index.ts +400 -0
  1792. package/src/tools/archive-reader.ts +330 -0
  1793. package/src/tools/ask.ts +998 -0
  1794. package/src/tools/ast-edit.ts +550 -0
  1795. package/src/tools/ast-grep.ts +424 -0
  1796. package/src/tools/auto-generated-guard.ts +305 -0
  1797. package/src/tools/bash-allowed-prefixes.ts +252 -0
  1798. package/src/tools/bash-command-fixup.ts +37 -0
  1799. package/src/tools/bash-interactive.ts +388 -0
  1800. package/src/tools/bash-interceptor.ts +67 -0
  1801. package/src/tools/bash-pty-selection.ts +14 -0
  1802. package/src/tools/bash-skill-urls.ts +248 -0
  1803. package/src/tools/bash.ts +1302 -0
  1804. package/src/tools/browser/actions.ts +189 -0
  1805. package/src/tools/browser/attach.ts +275 -0
  1806. package/src/tools/browser/launch.ts +651 -0
  1807. package/src/tools/browser/readable.ts +95 -0
  1808. package/src/tools/browser/registry.ts +384 -0
  1809. package/src/tools/browser/render.ts +220 -0
  1810. package/src/tools/browser/tab-protocol.ts +105 -0
  1811. package/src/tools/browser/tab-supervisor.ts +599 -0
  1812. package/src/tools/browser/tab-worker-entry.ts +21 -0
  1813. package/src/tools/browser/tab-worker.ts +1054 -0
  1814. package/src/tools/browser.ts +458 -0
  1815. package/src/tools/calculator.ts +540 -0
  1816. package/src/tools/checkpoint.ts +134 -0
  1817. package/src/tools/computer/render.ts +78 -0
  1818. package/src/tools/computer.ts +640 -0
  1819. package/src/tools/conflict-detect.ts +672 -0
  1820. package/src/tools/context.ts +39 -0
  1821. package/src/tools/cron.ts +709 -0
  1822. package/src/tools/debug.ts +1014 -0
  1823. package/src/tools/eval.ts +1101 -0
  1824. package/src/tools/fetch.ts +1482 -0
  1825. package/src/tools/file-recorder.ts +35 -0
  1826. package/src/tools/find.ts +543 -0
  1827. package/src/tools/fs-cache-invalidation.ts +28 -0
  1828. package/src/tools/gh-format.ts +12 -0
  1829. package/src/tools/gh-renderer.ts +428 -0
  1830. package/src/tools/gh.ts +3737 -0
  1831. package/src/tools/github-cache.ts +548 -0
  1832. package/src/tools/grouped-file-output.ts +96 -0
  1833. package/src/tools/hindsight-recall.ts +66 -0
  1834. package/src/tools/hindsight-reflect.ts +55 -0
  1835. package/src/tools/hindsight-retain.ts +54 -0
  1836. package/src/tools/image-gen.ts +1284 -0
  1837. package/src/tools/index.ts +595 -0
  1838. package/src/tools/inspect-image-renderer.ts +103 -0
  1839. package/src/tools/inspect-image.ts +167 -0
  1840. package/src/tools/irc.ts +239 -0
  1841. package/src/tools/job.ts +614 -0
  1842. package/src/tools/json-tree.ts +256 -0
  1843. package/src/tools/jtd-to-json-schema.ts +219 -0
  1844. package/src/tools/jtd-to-typescript.ts +136 -0
  1845. package/src/tools/jtd-utils.ts +102 -0
  1846. package/src/tools/list-limit.ts +40 -0
  1847. package/src/tools/match-line-format.ts +22 -0
  1848. package/src/tools/monitor.ts +252 -0
  1849. package/src/tools/output-meta.ts +754 -0
  1850. package/src/tools/path-utils.ts +741 -0
  1851. package/src/tools/plan-mode-guard.ts +68 -0
  1852. package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
  1853. package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
  1854. package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
  1855. package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
  1856. package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
  1857. package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
  1858. package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
  1859. package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
  1860. package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
  1861. package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
  1862. package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
  1863. package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
  1864. package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
  1865. package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
  1866. package/src/tools/read.ts +2332 -0
  1867. package/src/tools/recipe/index.ts +80 -0
  1868. package/src/tools/recipe/render.ts +19 -0
  1869. package/src/tools/recipe/runner.ts +219 -0
  1870. package/src/tools/recipe/runners/cargo.ts +131 -0
  1871. package/src/tools/recipe/runners/index.ts +8 -0
  1872. package/src/tools/recipe/runners/just.ts +73 -0
  1873. package/src/tools/recipe/runners/make.ts +101 -0
  1874. package/src/tools/recipe/runners/pkg.ts +167 -0
  1875. package/src/tools/recipe/runners/task.ts +72 -0
  1876. package/src/tools/render-mermaid.ts +68 -0
  1877. package/src/tools/render-utils.ts +774 -0
  1878. package/src/tools/renderers.ts +79 -0
  1879. package/src/tools/resolve.ts +333 -0
  1880. package/src/tools/review.ts +252 -0
  1881. package/src/tools/search-tool-bm25.ts +360 -0
  1882. package/src/tools/search.ts +787 -0
  1883. package/src/tools/skill.ts +170 -0
  1884. package/src/tools/sqlite-reader.ts +750 -0
  1885. package/src/tools/ssh.ts +310 -0
  1886. package/src/tools/subagent-render.ts +268 -0
  1887. package/src/tools/subagent.ts +862 -0
  1888. package/src/tools/todo-write.ts +695 -0
  1889. package/src/tools/tool-errors.ts +62 -0
  1890. package/src/tools/tool-result.ts +86 -0
  1891. package/src/tools/tool-timeouts.ts +31 -0
  1892. package/src/tools/ultragoal-ask-guard.ts +39 -0
  1893. package/src/tools/vim.ts +949 -0
  1894. package/src/tools/write.ts +953 -0
  1895. package/src/tools/yield.ts +268 -0
  1896. package/src/tui/code-cell.ts +201 -0
  1897. package/src/tui/file-list.ts +55 -0
  1898. package/src/tui/hyperlink.ts +126 -0
  1899. package/src/tui/index.ts +12 -0
  1900. package/src/tui/output-block.ts +150 -0
  1901. package/src/tui/status-line.ts +39 -0
  1902. package/src/tui/tree-list.ts +84 -0
  1903. package/src/tui/types.ts +15 -0
  1904. package/src/tui/utils.ts +103 -0
  1905. package/src/utils/changelog.ts +121 -0
  1906. package/src/utils/clipboard.ts +156 -0
  1907. package/src/utils/command-args.ts +76 -0
  1908. package/src/utils/commit-message-generator.ts +135 -0
  1909. package/src/utils/edit-mode.ts +42 -0
  1910. package/src/utils/event-bus.ts +33 -0
  1911. package/src/utils/external-editor.ts +65 -0
  1912. package/src/utils/file-display-mode.ts +45 -0
  1913. package/src/utils/file-mentions.ts +376 -0
  1914. package/src/utils/git.ts +1536 -0
  1915. package/src/utils/image-loading.ts +102 -0
  1916. package/src/utils/image-resize.ts +309 -0
  1917. package/src/utils/lang-from-path.ts +239 -0
  1918. package/src/utils/markit.ts +89 -0
  1919. package/src/utils/open.ts +20 -0
  1920. package/src/utils/session-color.ts +43 -0
  1921. package/src/utils/shell-snapshot.ts +187 -0
  1922. package/src/utils/sixel.ts +69 -0
  1923. package/src/utils/title-generator.ts +237 -0
  1924. package/src/utils/tool-choice.ts +62 -0
  1925. package/src/utils/tools-manager.ts +363 -0
  1926. package/src/vim/buffer.ts +309 -0
  1927. package/src/vim/commands.ts +382 -0
  1928. package/src/vim/engine.ts +2409 -0
  1929. package/src/vim/parser.ts +134 -0
  1930. package/src/vim/render.ts +252 -0
  1931. package/src/vim/types.ts +197 -0
  1932. package/src/web/kagi.ts +183 -0
  1933. package/src/web/parallel.ts +349 -0
  1934. package/src/web/scrapers/artifacthub.ts +207 -0
  1935. package/src/web/scrapers/arxiv.ts +83 -0
  1936. package/src/web/scrapers/aur.ts +162 -0
  1937. package/src/web/scrapers/biorxiv.ts +133 -0
  1938. package/src/web/scrapers/bluesky.ts +262 -0
  1939. package/src/web/scrapers/brew.ts +172 -0
  1940. package/src/web/scrapers/cheatsh.ts +68 -0
  1941. package/src/web/scrapers/chocolatey.ts +196 -0
  1942. package/src/web/scrapers/choosealicense.ts +95 -0
  1943. package/src/web/scrapers/cisa-kev.ts +87 -0
  1944. package/src/web/scrapers/clojars.ts +154 -0
  1945. package/src/web/scrapers/coingecko.ts +177 -0
  1946. package/src/web/scrapers/crates-io.ts +97 -0
  1947. package/src/web/scrapers/crossref.ts +136 -0
  1948. package/src/web/scrapers/devto.ts +147 -0
  1949. package/src/web/scrapers/discogs.ts +306 -0
  1950. package/src/web/scrapers/discourse.ts +197 -0
  1951. package/src/web/scrapers/dockerhub.ts +138 -0
  1952. package/src/web/scrapers/docs-rs.ts +653 -0
  1953. package/src/web/scrapers/fdroid.ts +134 -0
  1954. package/src/web/scrapers/firefox-addons.ts +191 -0
  1955. package/src/web/scrapers/flathub.ts +223 -0
  1956. package/src/web/scrapers/github-gist.ts +58 -0
  1957. package/src/web/scrapers/github.ts +452 -0
  1958. package/src/web/scrapers/gitlab.ts +401 -0
  1959. package/src/web/scrapers/go-pkg.ts +266 -0
  1960. package/src/web/scrapers/hackage.ts +140 -0
  1961. package/src/web/scrapers/hackernews.ts +189 -0
  1962. package/src/web/scrapers/hex.ts +105 -0
  1963. package/src/web/scrapers/huggingface.ts +321 -0
  1964. package/src/web/scrapers/iacr.ts +89 -0
  1965. package/src/web/scrapers/index.ts +252 -0
  1966. package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
  1967. package/src/web/scrapers/lemmy.ts +203 -0
  1968. package/src/web/scrapers/lobsters.ts +175 -0
  1969. package/src/web/scrapers/mastodon.ts +292 -0
  1970. package/src/web/scrapers/maven.ts +138 -0
  1971. package/src/web/scrapers/mdn.ts +173 -0
  1972. package/src/web/scrapers/metacpan.ts +222 -0
  1973. package/src/web/scrapers/musicbrainz.ts +250 -0
  1974. package/src/web/scrapers/npm.ts +98 -0
  1975. package/src/web/scrapers/nuget.ts +183 -0
  1976. package/src/web/scrapers/nvd.ts +222 -0
  1977. package/src/web/scrapers/ollama.ts +239 -0
  1978. package/src/web/scrapers/open-vsx.ts +106 -0
  1979. package/src/web/scrapers/opencorporates.ts +292 -0
  1980. package/src/web/scrapers/openlibrary.ts +336 -0
  1981. package/src/web/scrapers/orcid.ts +286 -0
  1982. package/src/web/scrapers/osv.ts +176 -0
  1983. package/src/web/scrapers/packagist.ts +160 -0
  1984. package/src/web/scrapers/pub-dev.ts +143 -0
  1985. package/src/web/scrapers/pubmed.ts +211 -0
  1986. package/src/web/scrapers/pypi.ts +112 -0
  1987. package/src/web/scrapers/rawg.ts +110 -0
  1988. package/src/web/scrapers/readthedocs.ts +120 -0
  1989. package/src/web/scrapers/reddit.ts +95 -0
  1990. package/src/web/scrapers/repology.ts +251 -0
  1991. package/src/web/scrapers/rfc.ts +201 -0
  1992. package/src/web/scrapers/rubygems.ts +103 -0
  1993. package/src/web/scrapers/searchcode.ts +189 -0
  1994. package/src/web/scrapers/sec-edgar.ts +261 -0
  1995. package/src/web/scrapers/semantic-scholar.ts +171 -0
  1996. package/src/web/scrapers/snapcraft.ts +187 -0
  1997. package/src/web/scrapers/sourcegraph.ts +336 -0
  1998. package/src/web/scrapers/spdx.ts +108 -0
  1999. package/src/web/scrapers/spotify.ts +198 -0
  2000. package/src/web/scrapers/stackoverflow.ts +120 -0
  2001. package/src/web/scrapers/terraform.ts +277 -0
  2002. package/src/web/scrapers/tldr.ts +47 -0
  2003. package/src/web/scrapers/twitter.ts +93 -0
  2004. package/src/web/scrapers/types.ts +318 -0
  2005. package/src/web/scrapers/utils.ts +109 -0
  2006. package/src/web/scrapers/vimeo.ts +133 -0
  2007. package/src/web/scrapers/vscode-marketplace.ts +187 -0
  2008. package/src/web/scrapers/w3c.ts +156 -0
  2009. package/src/web/scrapers/wikidata.ts +344 -0
  2010. package/src/web/scrapers/wikipedia.ts +84 -0
  2011. package/src/web/scrapers/youtube.ts +319 -0
  2012. package/src/web/search/index.ts +326 -0
  2013. package/src/web/search/provider.ts +324 -0
  2014. package/src/web/search/providers/anthropic.ts +302 -0
  2015. package/src/web/search/providers/base.ts +94 -0
  2016. package/src/web/search/providers/brave.ts +149 -0
  2017. package/src/web/search/providers/codex.ts +557 -0
  2018. package/src/web/search/providers/duckduckgo.ts +279 -0
  2019. package/src/web/search/providers/exa.ts +197 -0
  2020. package/src/web/search/providers/gemini.ts +455 -0
  2021. package/src/web/search/providers/jina.ts +101 -0
  2022. package/src/web/search/providers/kagi.ts +75 -0
  2023. package/src/web/search/providers/kimi.ts +171 -0
  2024. package/src/web/search/providers/openai-compatible.ts +151 -0
  2025. package/src/web/search/providers/parallel.ts +210 -0
  2026. package/src/web/search/providers/perplexity.ts +575 -0
  2027. package/src/web/search/providers/searxng.ts +309 -0
  2028. package/src/web/search/providers/synthetic.ts +108 -0
  2029. package/src/web/search/providers/tavily.ts +173 -0
  2030. package/src/web/search/providers/utils.ts +128 -0
  2031. package/src/web/search/providers/xai.ts +511 -0
  2032. package/src/web/search/providers/zai.ts +320 -0
  2033. package/src/web/search/render.ts +306 -0
  2034. package/src/web/search/types.ts +473 -0
  2035. package/src/web/search/utils.ts +17 -0
  2036. package/src/workspace-tree.ts +286 -0
@@ -0,0 +1,2677 @@
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 { type Agent, type AgentMessage, type AgentToolResult, ThinkingLevel } from "@sayknow-cli/agent-core";
8
+ import type { CompactionOutcome } from "@sayknow-cli/agent-core/compaction";
9
+ import {
10
+ type AssistantMessage,
11
+ type ImageContent,
12
+ type Message,
13
+ type Model,
14
+ modelsAreEqual,
15
+ type UsageReport,
16
+ } from "@sayknow-cli/ai";
17
+ import type { Component, EditorTheme, SlashCommand } from "@sayknow-cli/tui";
18
+ import {
19
+ Container,
20
+ clearRenderCache,
21
+ Loader,
22
+ Markdown,
23
+ ProcessTerminal,
24
+ Spacer,
25
+ Text,
26
+ TUI,
27
+ visibleWidth,
28
+ } from "@sayknow-cli/tui";
29
+ import { APP_NAME, adjustHsv, getProjectDir, hsvToRgb, isEnoent, logger, postmortem, prompt } from "@sayknow-cli/utils";
30
+ import chalk from "chalk";
31
+ import { AsyncJobManager } from "../async";
32
+ import { KeybindingsManager } from "../config/keybindings";
33
+ import { isSettingsInitialized, type Settings, settings } from "../config/settings";
34
+ import { DEFAULT_SKC_DEFINITION_NAMES } from "../defaults/skc-defaults";
35
+ import type {
36
+ ExtensionUIContext,
37
+ ExtensionUIDialogOptions,
38
+ ExtensionWidgetContent,
39
+ ExtensionWidgetOptions,
40
+ } from "../extensibility/extensions";
41
+ import type { CompactOptions } from "../extensibility/extensions/types";
42
+ import { resolveSkillSlashCommands, type Skill } from "../extensibility/skills";
43
+ import { BUILTIN_SLASH_COMMANDS, loadSlashCommands } from "../extensibility/slash-commands";
44
+ import { type Goal, type GoalModeState, normalizeGoal } from "../goals/state";
45
+ import { t } from "../i18n";
46
+ import { resolveLocalUrlToPath } from "../internal-urls";
47
+ import { LSP_STARTUP_EVENT_CHANNEL, type LspStartupEvent } from "../lsp/startup-events";
48
+ import {
49
+ humanizePlanTitle,
50
+ type PlanApprovalDetails,
51
+ renameApprovedPlanFile,
52
+ resolvePlanTitle,
53
+ } from "../plan-mode/approved-plan";
54
+ import planModeApprovedPrompt from "../prompts/system/plan-mode-approved.md" with { type: "text" };
55
+ import planModeCompactInstructionsPrompt from "../prompts/system/plan-mode-compact-instructions.md" with {
56
+ type: "text",
57
+ };
58
+ import {
59
+ createStarReminderBeforeAgentStartContributor,
60
+ scheduleLaunchStarReminderAfterFirstRender,
61
+ starReminderLaunchGate,
62
+ } from "../reminders/star-reminder";
63
+ import type { AgentSession, AgentSessionEvent } from "../session/agent-session";
64
+ import { HistoryStorage } from "../session/history-storage";
65
+ import type { SessionContext, SessionManager } from "../session/session-manager";
66
+ import { getRecentSessions } from "../session/session-manager";
67
+ import { consumePendingGoalModeRequest } from "../skc-runtime/goal-mode-request";
68
+ import { formatDuration } from "../slash-commands/helpers/format";
69
+ import { STTController, type SttState } from "../stt";
70
+ import type { LspStartupServerInfo } from "../tools";
71
+ import { normalizeLocalScheme } from "../tools/path-utils";
72
+ import { type ResolveToolDetails, runResolveInvocation } from "../tools/resolve";
73
+ import { formatPhaseDisplayName } from "../tools/todo-write";
74
+ import { ToolError } from "../tools/tool-errors";
75
+ import type { EventBus } from "../utils/event-bus";
76
+ import { getEditorCommand, openInEditor } from "../utils/external-editor";
77
+ import { getSessionAccentAnsi, getSessionAccentHex } from "../utils/session-color";
78
+ import { popTerminalTitle, pushTerminalTitle, setSessionTerminalTitle } from "../utils/title-generator";
79
+ import type { AssistantMessageComponent } from "./components/assistant-message";
80
+ import type { BashExecutionComponent } from "./components/bash-execution";
81
+ import { CustomEditor } from "./components/custom-editor";
82
+ import { DynamicBorder } from "./components/dynamic-border";
83
+ import type { EvalExecutionComponent } from "./components/eval-execution";
84
+ import type { HookEditorComponent } from "./components/hook-editor";
85
+ import type { HookInputComponent } from "./components/hook-input";
86
+ import type { HookSelectorComponent } from "./components/hook-selector";
87
+ import { StatusLineComponent } from "./components/status-line";
88
+ import type { ToolExecutionHandle } from "./components/tool-execution";
89
+ import { WelcomeComponent, type LspServerInfo as WelcomeLspServerInfo } from "./components/welcome";
90
+ import { BtwController } from "./controllers/btw-controller";
91
+ import { CommandController } from "./controllers/command-controller";
92
+ import { EventController } from "./controllers/event-controller";
93
+ import { ExtensionUiController } from "./controllers/extension-ui-controller";
94
+ import { InputController } from "./controllers/input-controller";
95
+ import { SelectorController } from "./controllers/selector-controller";
96
+ import { SSHCommandController } from "./controllers/ssh-command-controller";
97
+ import { TodoCommandController } from "./controllers/todo-command-controller";
98
+ import { JobsObserver } from "./jobs-observer";
99
+ import { OAuthManualInputManager } from "./oauth-manual-input";
100
+ import { SessionObserverRegistry } from "./session-observer-registry";
101
+ import { interruptHint } from "./shared";
102
+ import { type ShimmerPalette, shimmerSegments, shimmerText } from "./theme/shimmer";
103
+ import type { Theme } from "./theme/theme";
104
+ import {
105
+ getEditorTheme,
106
+ getMarkdownTheme,
107
+ getSymbolTheme,
108
+ onTerminalAppearanceChange,
109
+ onThemeChange,
110
+ theme,
111
+ } from "./theme/theme";
112
+ import type { CompactionQueuedMessage, InteractiveModeContext, SubmittedUserInput, TodoItem, TodoPhase } from "./types";
113
+ import { UiHelpers } from "./utils/ui-helpers";
114
+
115
+ const INTERACTIVE_ABORT_CLEANUP_TIMEOUT_MS = 5_000;
116
+
117
+ const HINT_SHIMMER_PALETTE: ShimmerPalette = {
118
+ low: "dim",
119
+ mid: "muted",
120
+ high: "borderAccent",
121
+ };
122
+
123
+ function getDefaultInputPrefix(): string {
124
+ return `${theme.fg("accent", ">")} `;
125
+ }
126
+
127
+ function getShellInputPrefix(isNoContext: boolean): string {
128
+ const shellLabel = isNoContext
129
+ ? theme.fg("warning", theme.bold("shell no-context"))
130
+ : theme.fg("bashMode", theme.bold("shell"));
131
+ return `${shellLabel} ${getDefaultInputPrefix()}`;
132
+ }
133
+
134
+ function configureDefaultComposerChrome(editor: CustomEditor): void {
135
+ editor.setBorderVisible(true);
136
+ editor.setBorderStyle("sharp");
137
+ editor.setClosedBorderBox(true);
138
+ editor.setPromptGutter(undefined);
139
+ editor.setInputPrefix(getDefaultInputPrefix());
140
+ editor.setPlaceholder("Type your message...");
141
+ editor.setPaddingX(1);
142
+ editor.setTopBorder(undefined);
143
+ }
144
+
145
+ interface WorkingMessageAccent {
146
+ main: string;
147
+ dim: string;
148
+ }
149
+
150
+ function renderWorkingMessage(message: string, accent?: WorkingMessageAccent): string {
151
+ const palette = accent
152
+ ? ({
153
+ low: "dim",
154
+ mid: { ansi: accent.main },
155
+ high: { ansi: accent.main },
156
+ bold: true,
157
+ } satisfies ShimmerPalette)
158
+ : undefined;
159
+ const hint = interruptHint();
160
+ if (!message.endsWith(hint)) return shimmerText(message, theme, palette);
161
+ const header = message.slice(0, -hint.length);
162
+ const hintPalette = accent
163
+ ? ({
164
+ low: "dim",
165
+ mid: { ansi: accent.dim },
166
+ high: { ansi: accent.dim },
167
+ } satisfies ShimmerPalette)
168
+ : HINT_SHIMMER_PALETTE;
169
+ return shimmerSegments(
170
+ [
171
+ { text: header, palette },
172
+ { text: hint, palette: hintPalette },
173
+ ],
174
+ theme,
175
+ );
176
+ }
177
+
178
+ const EDITOR_MAX_HEIGHT_MIN = 6;
179
+ const EDITOR_MAX_HEIGHT_MAX = 18;
180
+ const EDITOR_RESERVED_ROWS = 12;
181
+ const EDITOR_FALLBACK_ROWS = 24;
182
+
183
+ const HUD_NOTE_SUP_DIGITS: Record<string, string> = {
184
+ "0": "\u2070",
185
+ "1": "\u00b9",
186
+ "2": "\u00b2",
187
+ "3": "\u00b3",
188
+ "4": "\u2074",
189
+ "5": "\u2075",
190
+ "6": "\u2076",
191
+ "7": "\u2077",
192
+ "8": "\u2078",
193
+ "9": "\u2079",
194
+ };
195
+
196
+ function formatHudNoteMarker(count: number): string {
197
+ if (count <= 0) return "";
198
+ const sub = String(count)
199
+ .split("")
200
+ .map(d => HUD_NOTE_SUP_DIGITS[d] ?? d)
201
+ .join("");
202
+ return theme.fg("dim", chalk.italic(` \u207a${sub}`));
203
+ }
204
+
205
+ type GoalSubcommand = "set" | "show" | "pause" | "resume" | "drop";
206
+
207
+ const GOAL_SUBCOMMANDS = new Set<GoalSubcommand>(["set", "show", "pause", "resume", "drop"]);
208
+
209
+ function parseGoalSubcommand(args: string): { sub: GoalSubcommand | undefined; rest: string } {
210
+ const trimmed = args.trim();
211
+ if (!trimmed) return { sub: undefined, rest: "" };
212
+ const match = /^(\S+)(?:\s+([\s\S]*))?$/.exec(trimmed);
213
+ if (!match) return { sub: undefined, rest: trimmed };
214
+ const first = match[1].toLowerCase();
215
+ if (GOAL_SUBCOMMANDS.has(first as GoalSubcommand)) {
216
+ return { sub: first as GoalSubcommand, rest: match[2]?.trim() ?? "" };
217
+ }
218
+ return { sub: undefined, rest: trimmed };
219
+ }
220
+
221
+ /** Options for creating an InteractiveMode instance (for future API use) */
222
+ export interface InteractiveModeOptions {
223
+ /** Providers that were migrated during startup */
224
+ migratedProviders?: string[];
225
+ /** Warning message if model fallback occurred */
226
+ modelFallbackMessage?: string;
227
+ /** Initial message to send */
228
+ initialMessage?: string;
229
+ /** Initial images to include with the message */
230
+ initialImages?: ImageContent[];
231
+ /** Additional initial messages to queue */
232
+ initialMessages?: string[];
233
+ }
234
+
235
+ export class InteractiveMode implements InteractiveModeContext {
236
+ session: AgentSession;
237
+ sessionManager: SessionManager;
238
+ settings: Settings;
239
+ keybindings: KeybindingsManager;
240
+ agent: Agent;
241
+ historyStorage?: HistoryStorage;
242
+
243
+ ui: TUI;
244
+ chatContainer: Container;
245
+ pendingMessagesContainer: Container;
246
+ statusContainer: Container;
247
+ todoContainer: Container;
248
+ btwContainer: Container;
249
+ editor: CustomEditor;
250
+ editorContainer: Container;
251
+ hookWidgetContainerAbove: Container;
252
+ hookWidgetContainerBelow: Container;
253
+ statusLine: StatusLineComponent;
254
+
255
+ isInitialized = false;
256
+ isBackgrounded = false;
257
+ isBashMode = false;
258
+ isBashNoContext = false;
259
+ toolOutputExpanded = false;
260
+ todoExpanded = false;
261
+ planModeEnabled = false;
262
+ planModePaused = false;
263
+ goalModeEnabled = false;
264
+ goalModePaused = false;
265
+ planModePlanFilePath: string | undefined = undefined;
266
+ todoPhases: TodoPhase[] = [];
267
+ hideThinkingBlock = false;
268
+ pendingImages: ImageContent[] = [];
269
+ compactionQueuedMessages: CompactionQueuedMessage[] = [];
270
+ pendingTools = new Map<string, ToolExecutionHandle>();
271
+ pendingBashComponents: BashExecutionComponent[] = [];
272
+ bashComponent: BashExecutionComponent | undefined = undefined;
273
+ pendingPythonComponents: EvalExecutionComponent[] = [];
274
+ pythonComponent: EvalExecutionComponent | undefined = undefined;
275
+ isPythonMode = false;
276
+ streamingComponent: AssistantMessageComponent | undefined = undefined;
277
+ streamingMessage: AssistantMessage | undefined = undefined;
278
+ loadingAnimation: Loader | undefined = undefined;
279
+ autoCompactionLoader: Loader | undefined = undefined;
280
+ retryLoader: Loader | undefined = undefined;
281
+ #pendingWorkingMessage: string | undefined;
282
+ get #defaultWorkingMessage(): string {
283
+ return `Working…${interruptHint()}`;
284
+ }
285
+ autoCompactionEscapeHandler?: () => void;
286
+ retryEscapeHandler?: () => void;
287
+ retryCountdownTimer?: NodeJS.Timeout;
288
+ unsubscribe?: () => void;
289
+ onInputCallback?: (input: SubmittedUserInput) => void;
290
+ optimisticUserMessageSignature: string | undefined = undefined;
291
+ locallySubmittedUserSignatures: Set<string> = new Set();
292
+ #pendingSubmittedInput: SubmittedUserInput | undefined;
293
+ #pendingSubmissionDispose: (() => void) | undefined;
294
+ lastSigintTime = 0;
295
+ lastEscapeTime = 0;
296
+ lastComposerClearEscapeTime = 0;
297
+ shutdownRequested = false;
298
+ #isShuttingDown = false;
299
+ hookSelector: HookSelectorComponent | undefined = undefined;
300
+ hookInput: HookInputComponent | undefined = undefined;
301
+ hookEditor: HookEditorComponent | undefined = undefined;
302
+ lastStatusSpacer: Spacer | undefined = undefined;
303
+ lastStatusText: Text | undefined = undefined;
304
+ fileSlashCommands: Set<string> = new Set();
305
+ skillCommands: Map<string, Skill> = new Map();
306
+ oauthManualInput: OAuthManualInputManager = new OAuthManualInputManager();
307
+
308
+ #baseSlashCommands: SlashCommand[] = [];
309
+ #baseReservedSlashCommandNames: Set<string> = new Set();
310
+ #cleanupUnsubscribe?: () => void;
311
+ #subprocessTeardownUnsubscribe?: () => void;
312
+ readonly #version: string;
313
+ readonly #changelogMarkdown: string | undefined;
314
+ #planModePreviousTools: string[] | undefined;
315
+ #goalModePreviousTools: string[] | undefined;
316
+ #goalContinuationTimer: NodeJS.Timeout | undefined;
317
+ #goalTurnHadToolCalls = false;
318
+ #goalContinuationTurnInFlight = false;
319
+ #goalSuppressNextContinuation = false;
320
+ #planModePreviousModelState: { model: Model; thinkingLevel?: ThinkingLevel } | undefined;
321
+ #pendingModelSwitch: { model: Model; thinkingLevel?: ThinkingLevel } | undefined;
322
+ #planModeHasEntered = false;
323
+ #planReviewContainer: Container | undefined;
324
+ readonly lspServers: LspStartupServerInfo[] | undefined = undefined;
325
+ mcpManager?: import("../runtime-mcp").MCPManager;
326
+ readonly #toolUiContextSetter: (uiContext: ExtensionUIContext, hasUI: boolean) => void;
327
+
328
+ readonly #btwController: BtwController;
329
+ readonly #commandController: CommandController;
330
+ readonly #todoCommandController: TodoCommandController;
331
+ readonly #eventController: EventController;
332
+ readonly #extensionUiController: ExtensionUiController;
333
+ readonly #inputController: InputController;
334
+ readonly #selectorController: SelectorController;
335
+ readonly #uiHelpers: UiHelpers;
336
+ #sttController: STTController | undefined;
337
+ #voiceAnimationInterval: NodeJS.Timeout | undefined;
338
+ #voiceHue = 0;
339
+ #voicePreviousShowHardwareCursor: boolean | null = null;
340
+ #voicePreviousUseTerminalCursor: boolean | null = null;
341
+ #resizeHandler?: () => void;
342
+ #observerRegistry: SessionObserverRegistry;
343
+ #jobsObserver?: JobsObserver;
344
+ #eventBus?: EventBus;
345
+ #eventBusUnsubscribers: Array<() => void> = [];
346
+ #welcomeComponent?: WelcomeComponent;
347
+
348
+ constructor(
349
+ session: AgentSession,
350
+ version: string,
351
+ changelogMarkdown: string | undefined = undefined,
352
+ setToolUIContext: (uiContext: ExtensionUIContext, hasUI: boolean) => void = () => {},
353
+ lspServers: LspStartupServerInfo[] | undefined = undefined,
354
+ mcpManager?: import("../runtime-mcp").MCPManager,
355
+ eventBus?: EventBus,
356
+ ) {
357
+ this.session = session;
358
+ this.sessionManager = session.sessionManager;
359
+ this.settings = session.settings;
360
+ this.keybindings = KeybindingsManager.inMemory();
361
+ this.agent = session.agent;
362
+ this.#version = version;
363
+ this.#changelogMarkdown = changelogMarkdown;
364
+ this.#toolUiContextSetter = setToolUIContext;
365
+ this.lspServers = lspServers;
366
+ this.mcpManager = mcpManager;
367
+ this.#eventBus = eventBus;
368
+ if (eventBus) {
369
+ this.#eventBusUnsubscribers.push(
370
+ eventBus.on(LSP_STARTUP_EVENT_CHANNEL, data => {
371
+ this.#handleLspStartupEvent(data as LspStartupEvent);
372
+ }),
373
+ );
374
+ }
375
+
376
+ this.ui = new TUI(new ProcessTerminal(), settings.get("showHardwareCursor"));
377
+ this.ui.setClearOnShrink(settings.get("clearOnShrink"));
378
+ this.chatContainer = new Container();
379
+ this.pendingMessagesContainer = new Container();
380
+ this.statusContainer = new Container();
381
+ this.todoContainer = new Container();
382
+ this.btwContainer = new Container();
383
+ this.editor = new CustomEditor(getEditorTheme());
384
+ configureDefaultComposerChrome(this.editor);
385
+ this.editor.setUseTerminalCursor(this.ui.getShowHardwareCursor());
386
+ this.editor.setAutocompleteMaxVisible(settings.get("autocompleteMaxVisible"));
387
+ this.editor.onAutocompleteCancel = () => {
388
+ this.ui.requestRender(true);
389
+ };
390
+ this.editor.onAutocompleteUpdate = () => {
391
+ this.ui.requestRender();
392
+ };
393
+ this.#syncEditorMaxHeight();
394
+ this.#resizeHandler = () => {
395
+ this.#syncEditorMaxHeight();
396
+ this.updateEditorChrome();
397
+ };
398
+ process.stdout.on("resize", this.#resizeHandler);
399
+ try {
400
+ this.historyStorage = HistoryStorage.open();
401
+ this.editor.setHistoryStorage(this.historyStorage);
402
+ } catch (error) {
403
+ logger.warn("History storage unavailable", { error: String(error) });
404
+ }
405
+ this.hookWidgetContainerAbove = new Container();
406
+ this.hookWidgetContainerAbove.addChild(new Spacer(1));
407
+ this.hookWidgetContainerBelow = new Container();
408
+ this.editorContainer = new Container();
409
+ this.editorContainer.addChild(this.editor);
410
+ this.statusLine = new StatusLineComponent(session, { version: this.#version });
411
+ this.statusLine.setAutoCompactEnabled(session.autoCompactionEnabled);
412
+
413
+ this.hideThinkingBlock = settings.get("hideThinkingBlock");
414
+
415
+ const builtinCommandNames = new Set(BUILTIN_SLASH_COMMANDS.map(c => c.name));
416
+ const hookCommands: SlashCommand[] = (
417
+ this.session.extensionRunner?.getRegisteredCommands(builtinCommandNames) ?? []
418
+ ).map(cmd => ({
419
+ name: cmd.name,
420
+ description: cmd.description ?? "(hook command)",
421
+ getArgumentCompletions: cmd.getArgumentCompletions,
422
+ }));
423
+
424
+ // Convert custom commands (TypeScript) to SlashCommand format
425
+ const customCommands: SlashCommand[] = this.session.customCommands.map(loaded => ({
426
+ name: loaded.command.name,
427
+ description: `${loaded.command.description} (${loaded.source})`,
428
+ }));
429
+
430
+ this.#baseSlashCommands = [...BUILTIN_SLASH_COMMANDS, ...hookCommands, ...customCommands];
431
+ this.#baseReservedSlashCommandNames = new Set(this.#baseSlashCommands.map(command => command.name));
432
+ this.#rebuildSkillSlashCommands();
433
+
434
+ this.#uiHelpers = new UiHelpers(this);
435
+ this.#btwController = new BtwController(this);
436
+ this.#extensionUiController = new ExtensionUiController(this);
437
+ this.#eventController = new EventController(this);
438
+ this.#commandController = new CommandController(this);
439
+ this.#todoCommandController = new TodoCommandController(this);
440
+ this.#selectorController = new SelectorController(this);
441
+ this.#inputController = new InputController(this);
442
+ this.#observerRegistry = new SessionObserverRegistry();
443
+ }
444
+
445
+ async init(): Promise<void> {
446
+ if (this.isInitialized) return;
447
+
448
+ this.keybindings = logger.time("InteractiveMode.init:keybindings", () => KeybindingsManager.create());
449
+
450
+ // Register session manager flush for signal handlers (SIGINT, SIGTERM, SIGHUP)
451
+ this.#cleanupUnsubscribe = postmortem.register("session-manager-flush", () => this.sessionManager.flush());
452
+
453
+ // Tear down subprocess-spawning tools (browser Chrome, Python eval kernel) on a
454
+ // signal kill (SIGINT/SIGTERM/SIGHUP) so they aren't reparented to PID 1 (#698).
455
+ // The graceful /quit path already releases these via session.dispose(); this hook
456
+ // is the bounded, idempotent fallback for an external kill that bypasses it.
457
+ this.#subprocessTeardownUnsubscribe = postmortem.register("session-subprocess-teardown", () =>
458
+ this.session.disposeChildSubprocesses(),
459
+ );
460
+
461
+ await logger.time(
462
+ "InteractiveMode.init:slashCommands",
463
+ this.refreshSlashCommandState.bind(this),
464
+ getProjectDir(),
465
+ );
466
+
467
+ // Get current model info for welcome screen
468
+ const modelName = this.session.model?.name ?? "Unknown";
469
+ const providerName = this.session.model?.provider ?? "Unknown";
470
+
471
+ // Get recent sessions
472
+ const recentSessions = await logger.time("InteractiveMode.init:recentSessions", () =>
473
+ getRecentSessions(this.sessionManager.getSessionDir()).then(sessions =>
474
+ sessions.map(s => ({
475
+ name: s.name,
476
+ timeAgo: s.timeAgo,
477
+ })),
478
+ ),
479
+ );
480
+
481
+ const startupQuiet = settings.get("startup.quiet");
482
+ this.#welcomeComponent = undefined;
483
+
484
+ for (const warning of this.session.configWarnings) {
485
+ this.ui.addChild(new Text(theme.fg("warning", `Warning: ${warning}`), 1, 0));
486
+ this.ui.addChild(new Spacer(1));
487
+ }
488
+
489
+ if (!startupQuiet) {
490
+ // Add welcome header
491
+ this.#welcomeComponent = new WelcomeComponent(
492
+ this.#version,
493
+ modelName,
494
+ providerName,
495
+ recentSessions,
496
+ this.#getWelcomeLspServers(),
497
+ );
498
+
499
+ // Setup UI layout
500
+ this.ui.addChild(new Spacer(1));
501
+ this.ui.addChild(this.#welcomeComponent);
502
+ this.ui.addChild(new Spacer(1));
503
+ this.#welcomeComponent.playIntro(() => this.ui.requestRender());
504
+
505
+ // Add changelog if provided
506
+ if (this.#changelogMarkdown) {
507
+ this.ui.addChild(new DynamicBorder());
508
+ if (settings.get("collapseChangelog")) {
509
+ const versionMatch = this.#changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
510
+ const latestVersion = versionMatch ? versionMatch[1] : this.#version;
511
+ const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
512
+ this.ui.addChild(new Text(condensedText, 1, 0));
513
+ } else {
514
+ this.ui.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
515
+ this.ui.addChild(new Spacer(1));
516
+ this.ui.addChild(new Markdown(this.#changelogMarkdown.trim(), 1, 0, getMarkdownTheme()));
517
+ this.ui.addChild(new Spacer(1));
518
+ }
519
+ this.ui.addChild(new DynamicBorder());
520
+ }
521
+ }
522
+
523
+ this.ui.addChild(this.chatContainer);
524
+ this.ui.addChild(this.pendingMessagesContainer);
525
+ this.ui.addChild(this.statusContainer);
526
+ this.ui.addChild(this.todoContainer);
527
+ this.ui.addChild(this.btwContainer);
528
+ this.ui.addChild(this.statusLine); // Main status rail + hook statuses; composer chrome is rendered by the editor.
529
+ this.ui.addChild(this.hookWidgetContainerAbove);
530
+ this.ui.addChild(this.editorContainer);
531
+ this.ui.addChild(this.hookWidgetContainerBelow);
532
+ this.ui.setFocus(this.editor);
533
+
534
+ this.#inputController.setupKeyHandlers();
535
+ this.#inputController.setupEditorSubmitHandler();
536
+
537
+ // Wire observer registry to EventBus
538
+ if (this.#eventBus) {
539
+ this.#observerRegistry.subscribeToEventBus(this.#eventBus);
540
+ }
541
+ this.#observerRegistry.setMainSession(this.sessionManager.getSessionFile() ?? undefined);
542
+ this.#observerRegistry.onChange(() => {
543
+ this.statusLine.setSubagentCount(this.#observerRegistry.getActiveSubagentCount());
544
+ this.ui.requestRender();
545
+ });
546
+
547
+ // Event-driven monitor/cron jobs widget. Scoped to this session's owner so
548
+ // overlay actions cannot mutate another agent's background work.
549
+ const jobManager = AsyncJobManager.instance();
550
+ if (jobManager) {
551
+ const jobsObserver = new JobsObserver(jobManager, this.session.getAgentId());
552
+ this.#jobsObserver = jobsObserver;
553
+ this.statusLine.setJobs(jobsObserver.getSnapshot());
554
+ jobsObserver.onChange(() => {
555
+ this.statusLine.setJobs(jobsObserver.getSnapshot());
556
+ this.ui.requestRender();
557
+ });
558
+ }
559
+
560
+ // Load initial todos
561
+ await this.#loadTodoList();
562
+
563
+ // Start the UI
564
+ this.ui.start();
565
+ pushTerminalTitle();
566
+ setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
567
+ this.updateEditorChrome();
568
+ this.#syncEditorMaxHeight();
569
+ this.isInitialized = true;
570
+ this.ui.requestRender(true);
571
+
572
+ // GitHub star reminder (interactive-only). Register the decline-driven
573
+ // injection contributor and schedule the launch nudge after the first
574
+ // render so the networked gh check never blocks startup.
575
+ const starReminderGate = starReminderLaunchGate({
576
+ enabled: settings.get("starReminder.enabled"),
577
+ quiet: startupQuiet,
578
+ });
579
+ if (starReminderGate.register) {
580
+ this.session.registerBeforeAgentStartContributor(
581
+ createStarReminderBeforeAgentStartContributor({
582
+ getSessionId: () => this.sessionManager.getSessionId(),
583
+ }),
584
+ );
585
+ }
586
+ if (starReminderGate.schedule) {
587
+ scheduleLaunchStarReminderAfterFirstRender({
588
+ confirm: (title, message) => this.showHookConfirm(title, message),
589
+ isIdle: () => !this.session.isStreaming && !this.isBackgrounded && !this.hookSelector,
590
+ });
591
+ }
592
+
593
+ // Initialize hooks with TUI-based UI context
594
+ await this.initHooksAndCustomTools();
595
+
596
+ // Restore mode from session (e.g. plan mode on resume)
597
+ await this.#restoreModeFromSession();
598
+
599
+ // Restore unsent editor draft from previous session shutdown (Ctrl+D).
600
+ // One-shot: consumeDraft removes the sidecar after read so the next
601
+ // resume does not re-restore the same text.
602
+ try {
603
+ const draft = await this.sessionManager.consumeDraft();
604
+ if (draft && !this.editor.getText()) {
605
+ this.editor.setText(draft);
606
+ this.updateEditorChrome();
607
+ this.ui.requestRender();
608
+ }
609
+ } catch (err) {
610
+ logger.warn("Failed to restore session draft", { error: String(err) });
611
+ }
612
+
613
+ // Subscribe to agent events
614
+ this.#subscribeToAgent();
615
+
616
+ this.#eventBusUnsubscribers.push(
617
+ this.session.subscribe(event => {
618
+ void this.#handleGoalSessionEvent(event);
619
+ }),
620
+ );
621
+ // Set up theme file watcher
622
+ onThemeChange(() => {
623
+ clearRenderCache();
624
+ configureDefaultComposerChrome(this.editor);
625
+ this.ui.invalidate();
626
+ this.updateEditorChrome();
627
+ this.ui.requestRender();
628
+ });
629
+
630
+ // Subscribe to terminal dark/light appearance changes.
631
+ // The terminal queries background color via OSC 11 at startup and on
632
+ // Mode 2031 notifications, computing luminance to detect dark/light.
633
+ this.ui.terminal.onAppearanceChange(mode => {
634
+ onTerminalAppearanceChange(mode);
635
+ });
636
+
637
+ // Set up git branch watcher
638
+ this.statusLine.watchBranch(() => {
639
+ this.updateEditorChrome();
640
+ this.ui.requestRender();
641
+ });
642
+
643
+ // Initial top border update
644
+ this.updateEditorChrome();
645
+ }
646
+
647
+ /** Reload slash commands and autocomplete for the provided working directory. */
648
+ async refreshSlashCommandState(cwd?: string): Promise<void> {
649
+ const basePath = cwd ?? this.sessionManager.getCwd();
650
+ const fileCommands = await loadSlashCommands({ cwd: basePath });
651
+ const fileCommandNames = new Set(fileCommands.map(cmd => cmd.name));
652
+ this.fileSlashCommands = fileCommandNames;
653
+ const fileSlashCommands: SlashCommand[] = fileCommands.map(cmd => ({
654
+ name: cmd.name,
655
+ description: cmd.description,
656
+ }));
657
+ const skillCommands = this.#rebuildSkillSlashCommands(fileCommandNames);
658
+ const slashCommands = [...this.#baseSlashCommands, ...skillCommands];
659
+ const autocompleteProvider = this.#inputController.createAutocompleteProvider(
660
+ [...slashCommands, ...fileSlashCommands],
661
+ basePath,
662
+ );
663
+ this.editor.setAutocompleteProvider(autocompleteProvider);
664
+ this.session.setSlashCommands(fileCommands);
665
+ }
666
+
667
+ #rebuildSkillSlashCommands(fileCommandNames: ReadonlySet<string> = new Set()): SlashCommand[] {
668
+ this.skillCommands.clear();
669
+ if (!settings.get("skills.enableSkillCommands")) {
670
+ return [];
671
+ }
672
+ const reservedDirectCommandNames = new Set([
673
+ ...this.#baseReservedSlashCommandNames,
674
+ ...Array.from(fileCommandNames),
675
+ ]);
676
+ const resolvedCommands = resolveSkillSlashCommands(this.session.skills, reservedDirectCommandNames);
677
+ for (const command of resolvedCommands) {
678
+ this.skillCommands.set(command.name, command.skill);
679
+ }
680
+ const defaultSkcNames = new Set<string>(DEFAULT_SKC_DEFINITION_NAMES);
681
+ return resolvedCommands.map(command => ({
682
+ name: command.name,
683
+ description: command.description,
684
+ // Pin the bundled SKC workflow skills above generic commands in autocomplete.
685
+ ...(defaultSkcNames.has(command.skill.name) ? { priority: 100 } : {}),
686
+ }));
687
+ }
688
+
689
+ async getUserInput(): Promise<SubmittedUserInput> {
690
+ if (this.session.getGoalModeState()?.mode === "exiting") {
691
+ await this.#exitGoalMode({ reason: "completed", silent: true });
692
+ }
693
+ const { promise, resolve } = Promise.withResolvers<SubmittedUserInput>();
694
+ this.onInputCallback = input => {
695
+ this.onInputCallback = undefined;
696
+ resolve(input);
697
+ };
698
+ this.#scheduleGoalContinuation();
699
+ return promise;
700
+ }
701
+
702
+ #scheduleGoalContinuation(): void {
703
+ this.#cancelGoalContinuation();
704
+ if (!this.onInputCallback) return;
705
+ if (!this.session.settings.get("goal.continuationModes").includes("interactive")) return;
706
+ if (this.planModeEnabled || this.planModePaused) return;
707
+ if (!this.goalModeEnabled || this.goalModePaused) return;
708
+ if (this.#goalSuppressNextContinuation) return;
709
+ if (this.#pendingSubmittedInput) return;
710
+ if (this.editor.getText().trim().length > 0) return;
711
+ if ((this.pendingImages?.length ?? 0) > 0) return;
712
+ const state = this.session.getGoalModeState();
713
+ if (!state?.enabled || state.goal.status !== "active") return;
714
+ const prompt = this.session.goalRuntime.buildContinuationPrompt();
715
+ if (!prompt) return;
716
+ this.#goalContinuationTimer = setTimeout(() => {
717
+ this.#goalContinuationTimer = undefined;
718
+ if (!this.onInputCallback) return;
719
+ if (!this.goalModeEnabled || this.goalModePaused) return;
720
+ if (this.#pendingSubmittedInput) return;
721
+ if (this.editor.getText().trim().length > 0) return;
722
+ if ((this.pendingImages?.length ?? 0) > 0) return;
723
+ // Never fire an autonomous continuation prompt() while the session is
724
+ // busy. A wedged/orphaned subagent turn can leave isStreaming stuck true;
725
+ // firing prompt() here throws AgentBusyError, which submitInteractiveInput
726
+ // surfaces as a red "Error: Agent is already processing…" and then loops
727
+ // back to getUserInput(), re-arming this timer — an infinite error spam.
728
+ // Re-arm and only fire once the session returns to idle.
729
+ if (this.session.isStreaming || this.session.isCompacting) {
730
+ this.#scheduleGoalContinuation();
731
+ return;
732
+ }
733
+ const latestState = this.session.getGoalModeState();
734
+ if (!latestState?.enabled || latestState.goal.status !== "active") return;
735
+ this.#goalContinuationTurnInFlight = true;
736
+ this.onInputCallback(
737
+ this.startPendingSubmission({
738
+ text: prompt,
739
+ customType: "goal-continuation",
740
+ display: false,
741
+ }),
742
+ );
743
+ }, 800);
744
+ }
745
+
746
+ #cancelGoalContinuation(): void {
747
+ if (this.#goalContinuationTimer) {
748
+ clearTimeout(this.#goalContinuationTimer);
749
+ this.#goalContinuationTimer = undefined;
750
+ }
751
+ }
752
+
753
+ recordLocalSubmission(text: string, imageCount = 0): () => void {
754
+ if (this.isKnownSlashCommand(text)) {
755
+ return () => {};
756
+ }
757
+ const signature = `${text}\u0000${imageCount}`;
758
+ this.locallySubmittedUserSignatures.add(signature);
759
+ let disposed = false;
760
+ return () => {
761
+ if (disposed) return;
762
+ disposed = true;
763
+ this.locallySubmittedUserSignatures.delete(signature);
764
+ };
765
+ }
766
+
767
+ async withLocalSubmission<T>(text: string, fn: () => Promise<T>, options?: { imageCount?: number }): Promise<T> {
768
+ const dispose = this.recordLocalSubmission(text, options?.imageCount ?? 0);
769
+ try {
770
+ return await fn();
771
+ } catch (err) {
772
+ dispose();
773
+ throw err;
774
+ }
775
+ }
776
+
777
+ startPendingSubmission(input: {
778
+ text: string;
779
+ images?: ImageContent[];
780
+ customType?: string;
781
+ display?: boolean;
782
+ }): SubmittedUserInput {
783
+ const submission: SubmittedUserInput = {
784
+ text: input.text,
785
+ images: input.images,
786
+ customType: input.customType,
787
+ display: input.display,
788
+ cancelled: false,
789
+ started: false,
790
+ };
791
+ this.#pendingSubmittedInput = submission;
792
+ if (!submission.customType) {
793
+ this.#resetGoalContinuationSuppression();
794
+ const imageCount = submission.images?.length ?? 0;
795
+ this.optimisticUserMessageSignature = `${submission.text}\u0000${imageCount}`;
796
+ this.#pendingSubmissionDispose = this.recordLocalSubmission(submission.text, imageCount);
797
+ this.addMessageToChat({
798
+ role: "user",
799
+ content: [{ type: "text", text: submission.text }, ...(submission.images ?? [])],
800
+ attribution: "user",
801
+ timestamp: Date.now(),
802
+ });
803
+ } else {
804
+ this.optimisticUserMessageSignature = undefined;
805
+ this.#pendingSubmissionDispose = undefined;
806
+ }
807
+ this.editor.setText("");
808
+ this.ensureLoadingAnimation();
809
+ this.ui.requestRender();
810
+ return submission;
811
+ }
812
+
813
+ cancelPendingSubmission(): boolean {
814
+ const submission = this.#pendingSubmittedInput;
815
+ if (!submission || submission.started) {
816
+ return false;
817
+ }
818
+
819
+ submission.cancelled = true;
820
+ this.#pendingSubmittedInput = undefined;
821
+ this.optimisticUserMessageSignature = undefined;
822
+ this.#pendingSubmissionDispose?.();
823
+ this.#pendingSubmissionDispose = undefined;
824
+ this.#pendingWorkingMessage = undefined;
825
+ if (submission.customType === "goal-continuation") {
826
+ this.#goalContinuationTurnInFlight = false;
827
+ }
828
+ if (this.loadingAnimation) {
829
+ this.loadingAnimation.stop();
830
+ this.loadingAnimation = undefined;
831
+ this.statusContainer.clear();
832
+ }
833
+ if (!submission.customType) {
834
+ this.pendingImages = submission.images ? [...submission.images] : [];
835
+ this.rebuildChatFromMessages();
836
+ this.editor.setText(submission.text);
837
+ }
838
+ this.updateEditorChrome();
839
+ this.ui.requestRender();
840
+ return true;
841
+ }
842
+
843
+ markPendingSubmissionStarted(input: SubmittedUserInput): boolean {
844
+ if (this.#pendingSubmittedInput !== input || input.cancelled) {
845
+ return false;
846
+ }
847
+ input.started = true;
848
+ return true;
849
+ }
850
+
851
+ finishPendingSubmission(input: SubmittedUserInput): void {
852
+ const wasPendingSubmission = this.#pendingSubmittedInput === input;
853
+ const pendingSubmissionDispose = this.#pendingSubmissionDispose;
854
+ if (wasPendingSubmission) {
855
+ this.#pendingSubmittedInput = undefined;
856
+ this.#pendingSubmissionDispose = undefined;
857
+ }
858
+ if (input.customType === "goal-continuation") {
859
+ this.#goalContinuationTurnInFlight = false;
860
+ }
861
+
862
+ if (wasPendingSubmission && !this.session.isStreaming && !this.streamingComponent) {
863
+ this.optimisticUserMessageSignature = undefined;
864
+ pendingSubmissionDispose?.();
865
+ this.#pendingWorkingMessage = undefined;
866
+ if (this.loadingAnimation) {
867
+ this.loadingAnimation.stop();
868
+ this.loadingAnimation = undefined;
869
+ this.statusContainer.clear();
870
+ }
871
+ }
872
+ }
873
+
874
+ #computeEditorMaxHeight(): number {
875
+ const rows = this.ui.terminal.rows;
876
+ const terminalRows = Number.isFinite(rows) && rows > 0 ? rows : EDITOR_FALLBACK_ROWS;
877
+ const maxHeight = terminalRows - EDITOR_RESERVED_ROWS;
878
+ return Math.max(EDITOR_MAX_HEIGHT_MIN, Math.min(EDITOR_MAX_HEIGHT_MAX, maxHeight));
879
+ }
880
+
881
+ #syncEditorMaxHeight(): void {
882
+ this.editor.setMaxHeight(this.#computeEditorMaxHeight());
883
+ }
884
+
885
+ updateEditorChrome(): void {
886
+ if (this.isBashMode) {
887
+ this.editor.borderColor = this.isBashNoContext
888
+ ? (str: string) => theme.fg("warning", str)
889
+ : theme.getBashModeBorderColor();
890
+ this.editor.setInputPrefix(getShellInputPrefix(this.isBashNoContext));
891
+ } else if (this.isPythonMode) {
892
+ this.editor.borderColor = theme.getPythonModeBorderColor();
893
+ } else {
894
+ const accentEnabled = !isSettingsInitialized() || settings.get("statusLine.sessionAccent") !== false;
895
+ const sessionName = accentEnabled ? this.sessionManager.getSessionName() : undefined;
896
+ const hex = sessionName ? getSessionAccentHex(sessionName) : undefined;
897
+ const ansi = getSessionAccentAnsi(hex);
898
+ if (ansi) {
899
+ this.editor.borderColor = (str: string) => `${ansi}${str}\x1b[39m`;
900
+ } else {
901
+ const level = this.session.thinkingLevel ?? ThinkingLevel.Off;
902
+ this.editor.borderColor = theme.getThinkingBorderColor(level);
903
+ }
904
+ }
905
+ if (!this.isBashMode) {
906
+ this.editor.setInputPrefix(getDefaultInputPrefix());
907
+ }
908
+ this.#setComposerTopBorder();
909
+ this.ui.requestRender();
910
+ }
911
+
912
+ updateEditorBorderColor(): void {
913
+ this.updateEditorChrome();
914
+ }
915
+
916
+ updateEditorTopBorder(): void {
917
+ this.#setComposerTopBorder();
918
+ }
919
+
920
+ #setComposerTopBorder(): void {
921
+ // Keep the composer as a plain closed input rectangle; status-line
922
+ // rendering stays outside the input area.
923
+ this.editor.setTopBorder(undefined);
924
+ }
925
+
926
+ rebuildChatFromMessages(): void {
927
+ this.chatContainer.clear();
928
+ const context = this.session.buildDisplaySessionContext();
929
+ this.renderSessionContext(context);
930
+ }
931
+
932
+ #formatTodoLine(todo: TodoItem, prefix: string): string {
933
+ const checkbox = theme.checkbox;
934
+ const marker = formatHudNoteMarker(todo.notes?.length ?? 0);
935
+ switch (todo.status) {
936
+ case "completed":
937
+ return theme.fg("success", `${prefix}${checkbox.checked} ${chalk.strikethrough(todo.content)}`) + marker;
938
+ case "in_progress":
939
+ return theme.fg("accent", `${prefix}${checkbox.unchecked} ${todo.content}`) + marker;
940
+ case "abandoned":
941
+ return theme.fg("error", `${prefix}${checkbox.unchecked} ${chalk.strikethrough(todo.content)}`) + marker;
942
+ default:
943
+ return theme.fg("dim", `${prefix}${checkbox.unchecked} ${todo.content}`) + marker;
944
+ }
945
+ }
946
+
947
+ #getActivePhase(phases: TodoPhase[]): TodoPhase | undefined {
948
+ const nonEmpty = phases.filter(phase => phase.tasks.length > 0);
949
+ const active = nonEmpty.find(phase =>
950
+ phase.tasks.some(task => task.status === "pending" || task.status === "in_progress"),
951
+ );
952
+ return active ?? nonEmpty[nonEmpty.length - 1];
953
+ }
954
+
955
+ #renderTodoList(): void {
956
+ this.todoContainer.clear();
957
+ const phases = this.todoPhases.filter(phase => phase.tasks.length > 0);
958
+ if (phases.length === 0) {
959
+ return;
960
+ }
961
+
962
+ const indent = " ";
963
+ const hook = theme.tree.hook;
964
+ const lines = ["", indent + theme.bold(theme.fg("accent", "Todos"))];
965
+
966
+ if (!this.todoExpanded) {
967
+ const activeIdx = phases.indexOf(this.#getActivePhase(phases) ?? phases[0]);
968
+ const activePhase = phases[activeIdx];
969
+ if (!activePhase) return;
970
+ lines.push(
971
+ `${indent}${theme.fg("accent", `${hook} ${formatPhaseDisplayName(activePhase.name, activeIdx + 1)}`)}`,
972
+ );
973
+ const visibleTasks = activePhase.tasks.slice(0, 5);
974
+ visibleTasks.forEach((todo, index) => {
975
+ const prefix = `${indent}${index === 0 ? hook : " "} `;
976
+ lines.push(this.#formatTodoLine(todo, prefix));
977
+ });
978
+ if (visibleTasks.length < activePhase.tasks.length) {
979
+ const remaining = activePhase.tasks.length - visibleTasks.length;
980
+ lines.push(theme.fg("muted", `${indent} ${hook} +${remaining} more`));
981
+ }
982
+ this.todoContainer.addChild(new Text(lines.join("\n"), 1, 0));
983
+ return;
984
+ }
985
+
986
+ phases.forEach((phase, phaseIndex) => {
987
+ lines.push(`${indent}${theme.fg("accent", `${hook} ${formatPhaseDisplayName(phase.name, phaseIndex + 1)}`)}`);
988
+ phase.tasks.forEach((todo, index) => {
989
+ const prefix = `${indent}${index === 0 ? hook : " "} `;
990
+ lines.push(this.#formatTodoLine(todo, prefix));
991
+ });
992
+ });
993
+
994
+ this.todoContainer.addChild(new Text(lines.join("\n"), 1, 0));
995
+ }
996
+
997
+ async #loadTodoList(): Promise<void> {
998
+ this.todoPhases = this.session.getTodoPhases();
999
+ this.#renderTodoList();
1000
+ }
1001
+
1002
+ async #getPlanFilePath(): Promise<string> {
1003
+ return "local://PLAN.md";
1004
+ }
1005
+
1006
+ #resolvePlanFilePath(planFilePath: string): string {
1007
+ if (planFilePath.startsWith("local:")) {
1008
+ const normalized = normalizeLocalScheme(planFilePath);
1009
+ return resolveLocalUrlToPath(normalized, {
1010
+ getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
1011
+ getSessionId: () => this.sessionManager.getSessionId(),
1012
+ });
1013
+ }
1014
+ return path.resolve(this.sessionManager.getCwd(), planFilePath);
1015
+ }
1016
+
1017
+ #updatePlanModeStatus(): void {
1018
+ const status =
1019
+ this.planModeEnabled || this.planModePaused
1020
+ ? {
1021
+ enabled: this.planModeEnabled,
1022
+ paused: this.planModePaused,
1023
+ }
1024
+ : undefined;
1025
+ this.statusLine.setPlanModeStatus(status);
1026
+ this.updateEditorChrome();
1027
+ this.ui.requestRender();
1028
+ }
1029
+
1030
+ #updateGoalModeStatus(): void {
1031
+ const status =
1032
+ this.goalModeEnabled || this.goalModePaused
1033
+ ? { enabled: this.goalModeEnabled, paused: this.goalModePaused }
1034
+ : undefined;
1035
+ this.statusLine.setGoalModeStatus(status);
1036
+ this.updateEditorChrome();
1037
+ this.ui.requestRender();
1038
+ }
1039
+
1040
+ #resetGoalContinuationSuppression(): void {
1041
+ this.#goalSuppressNextContinuation = false;
1042
+ }
1043
+
1044
+ #getPausedGoalState(): GoalModeState | undefined {
1045
+ const state = this.session.getGoalModeState();
1046
+ if (!state?.goal || state.enabled || state.goal.status !== "paused") {
1047
+ return undefined;
1048
+ }
1049
+ return state;
1050
+ }
1051
+
1052
+ #goalFromModeData(modeData: SessionContext["modeData"]): Goal | undefined {
1053
+ return normalizeGoal(modeData?.goal) ?? undefined;
1054
+ }
1055
+
1056
+ async #handleGoalSessionEvent(event: AgentSessionEvent): Promise<void> {
1057
+ if (event.type === "agent_start") {
1058
+ this.#goalTurnHadToolCalls = false;
1059
+ this.#cancelGoalContinuation();
1060
+ return;
1061
+ }
1062
+ if (event.type === "tool_execution_start") {
1063
+ this.#goalTurnHadToolCalls = true;
1064
+ if (!this.#goalContinuationTurnInFlight) {
1065
+ this.#resetGoalContinuationSuppression();
1066
+ }
1067
+ return;
1068
+ }
1069
+ if (event.type === "message_start" && event.message.role === "user" && !event.message.synthetic) {
1070
+ this.#resetGoalContinuationSuppression();
1071
+ return;
1072
+ }
1073
+ if (event.type === "goal_updated") {
1074
+ // Handle drop before clearing goalModeEnabled so #exitGoalMode can
1075
+ // still restore the previous tool set while the flag is true.
1076
+ if (event.state?.goal?.status === "dropped") {
1077
+ await this.#exitGoalMode({ reason: "dropped", silent: true });
1078
+ return;
1079
+ }
1080
+ if (event.state?.enabled === true && !this.#goalModePreviousTools) {
1081
+ this.#goalModePreviousTools = this.session.getActiveToolNames();
1082
+ }
1083
+ this.goalModeEnabled = event.state?.enabled === true;
1084
+ this.goalModePaused = event.state?.enabled !== true && event.state?.goal?.status === "paused";
1085
+ if (!event.state?.enabled) {
1086
+ this.#cancelGoalContinuation();
1087
+ }
1088
+ this.#updateGoalModeStatus();
1089
+ return;
1090
+ }
1091
+ if (event.type !== "agent_end") {
1092
+ return;
1093
+ }
1094
+ if (this.#goalContinuationTurnInFlight) {
1095
+ this.#goalSuppressNextContinuation = !this.#goalTurnHadToolCalls;
1096
+ this.#goalContinuationTurnInFlight = false;
1097
+ }
1098
+ if (this.session.getGoalModeState()?.mode === "exiting") {
1099
+ await this.#exitGoalMode({ reason: "completed", silent: true });
1100
+ return;
1101
+ }
1102
+ this.#scheduleGoalContinuation();
1103
+ }
1104
+
1105
+ async #applyPlanModeModel(): Promise<void> {
1106
+ const resolved = this.session.resolveRoleModelWithThinking("plan");
1107
+ if (!resolved.model) return;
1108
+
1109
+ const currentModel = this.session.model;
1110
+ const sameModel = modelsAreEqual(currentModel, resolved.model);
1111
+ const planThinkingLevel = resolved.explicitThinkingLevel ? resolved.thinkingLevel : undefined;
1112
+
1113
+ this.#planModePreviousModelState = currentModel
1114
+ ? { model: currentModel, thinkingLevel: this.session.thinkingLevel }
1115
+ : undefined;
1116
+
1117
+ if (!sameModel) {
1118
+ if (this.session.isStreaming) {
1119
+ this.#pendingModelSwitch = { model: resolved.model, thinkingLevel: planThinkingLevel };
1120
+ return;
1121
+ }
1122
+ try {
1123
+ await this.session.setModelTemporary(resolved.model, planThinkingLevel);
1124
+ } catch (error) {
1125
+ this.showWarning(
1126
+ `Failed to switch to plan model for plan mode: ${error instanceof Error ? error.message : String(error)}`,
1127
+ );
1128
+ }
1129
+ } else if (planThinkingLevel) {
1130
+ this.session.setThinkingLevel(planThinkingLevel);
1131
+ }
1132
+ }
1133
+
1134
+ /** Apply any deferred model switch after the current stream ends. */
1135
+ async flushPendingModelSwitch(): Promise<void> {
1136
+ const pending = this.#pendingModelSwitch;
1137
+ if (!pending) return;
1138
+ this.#pendingModelSwitch = undefined;
1139
+ try {
1140
+ await this.session.setModelTemporary(pending.model, pending.thinkingLevel);
1141
+ } catch (error) {
1142
+ this.showWarning(
1143
+ `Failed to switch model after streaming: ${error instanceof Error ? error.message : String(error)}`,
1144
+ );
1145
+ }
1146
+ }
1147
+
1148
+ /** Restore mode state from session entries on resume (e.g. plan mode). */
1149
+ async #restoreModeFromSession(): Promise<void> {
1150
+ const sessionContext = this.sessionManager.buildSessionContext();
1151
+ const goalEnabled = this.session.settings.get("goal.enabled");
1152
+ if (!goalEnabled && (sessionContext.mode === "goal" || sessionContext.mode === "goal_paused")) {
1153
+ this.sessionManager.appendModeChange("none");
1154
+ return;
1155
+ }
1156
+ if (sessionContext.mode === "goal" || sessionContext.mode === "goal_paused") {
1157
+ const goal = this.#goalFromModeData(sessionContext.modeData);
1158
+ if (!goal) {
1159
+ this.sessionManager.appendModeChange("none");
1160
+ return;
1161
+ }
1162
+ this.session.setGoalModeState({
1163
+ enabled: sessionContext.mode === "goal",
1164
+ mode: "active",
1165
+ goal,
1166
+ });
1167
+ const restored = await this.session.goalRuntime.onThreadResumed();
1168
+ this.goalModeEnabled = restored?.enabled === true;
1169
+ this.goalModePaused = restored?.enabled !== true && restored?.goal.status === "paused";
1170
+ // Keep `goal` armed on resumed threads; it is part of the default active tool set.
1171
+ if (restored?.goal) {
1172
+ const previousTools = this.session.getActiveToolNames();
1173
+ this.#goalModePreviousTools = previousTools;
1174
+ await this.session.setActiveToolsByName([...new Set([...previousTools, "goal"])]);
1175
+ }
1176
+ this.#updateGoalModeStatus();
1177
+ return;
1178
+ }
1179
+ const pendingGoal = goalEnabled
1180
+ ? await consumePendingGoalModeRequest(this.sessionManager.getCwd(), this.sessionManager.getSessionId())
1181
+ : null;
1182
+ if (pendingGoal) {
1183
+ await this.#enterGoalMode({ objective: pendingGoal.objective, silent: true });
1184
+ this.#scheduleGoalContinuation();
1185
+ return;
1186
+ }
1187
+ if (!this.session.settings.get("plan.enabled")) {
1188
+ // Clear stale plan/plan_paused mode so re-enabling the setting
1189
+ // later doesn't unexpectedly restore an old plan session.
1190
+ if (sessionContext.mode === "plan" || sessionContext.mode === "plan_paused") {
1191
+ this.sessionManager.appendModeChange("none");
1192
+ }
1193
+ return;
1194
+ }
1195
+ if (sessionContext.mode === "plan") {
1196
+ const planFilePath = sessionContext.modeData?.planFilePath as string | undefined;
1197
+ await this.#enterPlanMode({ planFilePath });
1198
+ } else if (sessionContext.mode === "plan_paused") {
1199
+ this.planModePaused = true;
1200
+ this.#planModeHasEntered = true;
1201
+ this.#updatePlanModeStatus();
1202
+ }
1203
+ }
1204
+
1205
+ async #enterPlanMode(options?: { planFilePath?: string; workflow?: "parallel" | "iterative" }): Promise<void> {
1206
+ if (this.planModeEnabled) {
1207
+ return;
1208
+ }
1209
+ if (this.goalModeEnabled || this.goalModePaused) {
1210
+ this.showWarning("Exit goal mode first.");
1211
+ return;
1212
+ }
1213
+
1214
+ this.planModePaused = false;
1215
+
1216
+ const planFilePath = options?.planFilePath ?? (await this.#getPlanFilePath());
1217
+ const previousTools = this.session.getActiveToolNames();
1218
+ const hasResolveTool = this.session.getToolByName("resolve") !== undefined;
1219
+ const planTools = hasResolveTool ? [...previousTools, "resolve"] : previousTools;
1220
+ const uniquePlanTools = [...new Set(planTools)];
1221
+
1222
+ this.#planModePreviousTools = previousTools;
1223
+ this.planModePlanFilePath = planFilePath;
1224
+ this.planModeEnabled = true;
1225
+
1226
+ await this.session.setActiveToolsByName(uniquePlanTools);
1227
+ this.session.setPlanModeState({
1228
+ enabled: true,
1229
+ planFilePath,
1230
+ workflow: options?.workflow ?? "parallel",
1231
+ reentry: this.#planModeHasEntered,
1232
+ });
1233
+ this.session.setStandingResolveHandler?.(input => this.#runPlanApprovalResolve(input));
1234
+ if (this.session.isStreaming) {
1235
+ await this.session.sendPlanModeContext({ deliverAs: "steer" });
1236
+ }
1237
+ this.#planModeHasEntered = true;
1238
+ await this.#applyPlanModeModel();
1239
+ this.#updatePlanModeStatus();
1240
+ this.sessionManager.appendModeChange("plan", { planFilePath });
1241
+ this.showStatus(`Plan mode enabled. Plan file: ${planFilePath}`);
1242
+ }
1243
+
1244
+ /** Standing resolve dispatcher registered while plan mode is active. The agent
1245
+ * submits the finalized plan by calling `resolve { action: "apply", extra: { title } }`;
1246
+ * this handler validates the plan file exists, normalizes the title, and shapes the
1247
+ * payload that `event-controller` forwards to `handlePlanApproval`. */
1248
+ #runPlanApprovalResolve(input: unknown): Promise<AgentToolResult<ResolveToolDetails>> {
1249
+ return runResolveInvocation(input as Parameters<typeof runResolveInvocation>[0], {
1250
+ sourceToolName: "plan_approval",
1251
+ label: "Plan ready for approval",
1252
+ apply: async (_reason, extra) => {
1253
+ const state = this.session.getPlanModeState?.();
1254
+ if (!state?.enabled) {
1255
+ throw new ToolError("Plan mode is not active.");
1256
+ }
1257
+ const planFilePath = state.planFilePath;
1258
+ const planContent = await this.#readPlanFile(planFilePath);
1259
+ if (planContent === null) {
1260
+ throw new ToolError(
1261
+ `Plan file not found at ${planFilePath}. Write the finalized plan to ${planFilePath} before requesting approval.`,
1262
+ );
1263
+ }
1264
+ const normalized = resolvePlanTitle({
1265
+ suppliedTitle: extra?.title,
1266
+ planContent,
1267
+ planFilePath,
1268
+ });
1269
+ const details: PlanApprovalDetails = {
1270
+ planFilePath,
1271
+ finalPlanFilePath: `local://${normalized.fileName}`,
1272
+ title: normalized.title,
1273
+ planExists: true,
1274
+ };
1275
+ return {
1276
+ content: [{ type: "text" as const, text: "Plan ready for approval." }],
1277
+ details,
1278
+ };
1279
+ },
1280
+ });
1281
+ }
1282
+
1283
+ async #exitPlanMode(options?: { silent?: boolean; paused?: boolean }): Promise<void> {
1284
+ if (!this.planModeEnabled) {
1285
+ return;
1286
+ }
1287
+
1288
+ const previousTools = this.#planModePreviousTools;
1289
+ if (previousTools && previousTools.length > 0) {
1290
+ await this.session.setActiveToolsByName(previousTools);
1291
+ }
1292
+ if (this.#planModePreviousModelState) {
1293
+ const prev = this.#planModePreviousModelState;
1294
+ if (modelsAreEqual(this.session.model, prev.model)) {
1295
+ // Same model — only thinking level may differ. Avoid setModelTemporary()
1296
+ // which would reset provider-side sessions (openai-responses/OpenAI code backend) and
1297
+ // break conversation continuity.
1298
+ this.session.setThinkingLevel(prev.thinkingLevel);
1299
+ } else if (this.session.isStreaming) {
1300
+ this.#pendingModelSwitch = { model: prev.model, thinkingLevel: prev.thinkingLevel };
1301
+ } else {
1302
+ await this.session.setModelTemporary(prev.model, prev.thinkingLevel);
1303
+ }
1304
+ // If #applyPlanModeModel queued a deferred switch to the plan-role model
1305
+ // (because the session was streaming on entry), drop it now: we are
1306
+ // leaving plan mode, so flushing it on the next agent_end would land the
1307
+ // session on the plan-role model after the user has exited plan mode
1308
+ // (issue #816). Only clear when the pending target matches the plan-role
1309
+ // model — leave any unrelated user-queued switch intact.
1310
+ const pending = this.#pendingModelSwitch;
1311
+ if (pending) {
1312
+ const planResolution = this.session.resolveRoleModelWithThinking("plan");
1313
+ if (planResolution.model && modelsAreEqual(pending.model, planResolution.model)) {
1314
+ this.#pendingModelSwitch = undefined;
1315
+ }
1316
+ }
1317
+ }
1318
+ this.session.setStandingResolveHandler?.(null);
1319
+ this.session.setPlanModeState(undefined);
1320
+ this.planModeEnabled = false;
1321
+ this.planModePaused = options?.paused ?? false;
1322
+ this.planModePlanFilePath = undefined;
1323
+ this.#planModePreviousTools = undefined;
1324
+ this.#planModePreviousModelState = undefined;
1325
+ this.#updatePlanModeStatus();
1326
+ const paused = options?.paused ?? false;
1327
+ this.sessionManager.appendModeChange(paused ? "plan_paused" : "none");
1328
+ if (!options?.silent) {
1329
+ this.showStatus(paused ? "Plan mode paused." : "Plan mode disabled.");
1330
+ }
1331
+ }
1332
+
1333
+ async #enterGoalMode(options: { objective?: string; resume?: boolean; silent?: boolean }): Promise<void> {
1334
+ if (this.goalModeEnabled) {
1335
+ return;
1336
+ }
1337
+ if (this.planModeEnabled || this.planModePaused) {
1338
+ this.showWarning("Exit plan mode first.");
1339
+ return;
1340
+ }
1341
+ const previousTools = this.session.getActiveToolNames();
1342
+ const goalTools = [...new Set([...previousTools, "goal"])];
1343
+ this.#goalModePreviousTools = previousTools;
1344
+ this.goalModePaused = false;
1345
+ const state = options.resume
1346
+ ? await this.session.goalRuntime.resumeGoal()
1347
+ : await this.session.goalRuntime.createGoal({ objective: options.objective ?? "" });
1348
+ await this.session.setActiveToolsByName(goalTools);
1349
+ this.session.setGoalModeState(state);
1350
+ this.goalModeEnabled = true;
1351
+ this.#resetGoalContinuationSuppression();
1352
+ this.#updateGoalModeStatus();
1353
+ if (this.session.isStreaming) {
1354
+ await this.session.sendGoalModeContext({ deliverAs: "steer" });
1355
+ }
1356
+ if (!options.silent) {
1357
+ this.showStatus(options.resume ? "Goal mode resumed." : "Goal mode enabled.");
1358
+ }
1359
+ }
1360
+
1361
+ async #exitGoalMode(options?: {
1362
+ silent?: boolean;
1363
+ paused?: boolean;
1364
+ reason?: "completed" | "paused" | "dropped";
1365
+ }): Promise<void> {
1366
+ const previousTools = this.#goalModePreviousTools;
1367
+ // Drop keeps the `goal` tool callable so the agent can immediately create a new
1368
+ // goal in the same session without a leader-side cleanup. Complete (and pause)
1369
+ // exit goal mode and restore the pre-goal tool set even when the goal_updated
1370
+ // event has already cleared goalModeEnabled (see #completeGoalFromTool emitting
1371
+ // state.enabled = false before #exitGoalMode runs). Spec: deep-interview-ultragoal-goal-tool-wiring AC1+AC2.
1372
+ const shouldRestoreTools =
1373
+ previousTools &&
1374
+ options?.reason !== "dropped" &&
1375
+ (this.goalModeEnabled || options?.reason === "completed" || options?.paused === true);
1376
+ if (shouldRestoreTools) {
1377
+ await this.session.setActiveToolsByName(previousTools);
1378
+ }
1379
+ const currentState = this.session.getGoalModeState();
1380
+ if (options?.reason === "completed") {
1381
+ this.session.setGoalModeState(undefined);
1382
+ this.sessionManager.appendModeChange("none");
1383
+ this.sessionManager.appendCustomEntry("goal-completed", {
1384
+ objective: currentState?.goal?.objective,
1385
+ tokensUsed: currentState?.goal?.tokensUsed,
1386
+ timeUsedSeconds: currentState?.goal?.timeUsedSeconds,
1387
+ });
1388
+ }
1389
+ this.goalModeEnabled = false;
1390
+ this.goalModePaused = options?.paused ?? false;
1391
+ this.#goalModePreviousTools = undefined;
1392
+ this.#goalContinuationTurnInFlight = false;
1393
+ this.#cancelGoalContinuation();
1394
+ this.#updateGoalModeStatus();
1395
+ if (!options?.silent) {
1396
+ if (options?.reason === "completed") {
1397
+ this.showStatus("Goal mode completed.");
1398
+ } else if (options?.reason === "dropped") {
1399
+ this.showStatus("Goal dropped.");
1400
+ } else if (options?.paused) {
1401
+ this.showStatus("Goal mode paused.");
1402
+ } else {
1403
+ this.showStatus("Goal mode disabled.");
1404
+ }
1405
+ }
1406
+ }
1407
+
1408
+ async #readPlanFile(planFilePath: string): Promise<string | null> {
1409
+ const resolvedPath = this.#resolvePlanFilePath(planFilePath);
1410
+ try {
1411
+ return await Bun.file(resolvedPath).text();
1412
+ } catch (error) {
1413
+ if (isEnoent(error)) {
1414
+ return null;
1415
+ }
1416
+ throw error;
1417
+ }
1418
+ }
1419
+
1420
+ #renderPlanPreview(planContent: string, options?: { append?: boolean }): void {
1421
+ const existingContainer = this.#planReviewContainer;
1422
+ const replaceExisting = options?.append !== true && existingContainer !== undefined;
1423
+ const planReviewContainer = replaceExisting ? existingContainer : new Container();
1424
+ planReviewContainer.clear();
1425
+ planReviewContainer.addChild(new Spacer(1));
1426
+ planReviewContainer.addChild(new DynamicBorder());
1427
+ planReviewContainer.addChild(new Text(theme.bold(theme.fg("accent", "Plan Review")), 1, 1));
1428
+ planReviewContainer.addChild(new Spacer(1));
1429
+ planReviewContainer.addChild(new Markdown(planContent, 1, 1, getMarkdownTheme()));
1430
+ planReviewContainer.addChild(new DynamicBorder());
1431
+ if (!replaceExisting) {
1432
+ this.chatContainer.addChild(planReviewContainer);
1433
+ }
1434
+ this.#planReviewContainer = planReviewContainer;
1435
+ this.ui.requestRender();
1436
+ }
1437
+
1438
+ #getEditorTerminalPath(): string | null {
1439
+ if (process.platform === "win32") {
1440
+ return null;
1441
+ }
1442
+ return "/dev/tty";
1443
+ }
1444
+
1445
+ async #openEditorTerminalHandle(): Promise<fs.FileHandle | null> {
1446
+ const terminalPath = this.#getEditorTerminalPath();
1447
+ if (!terminalPath) {
1448
+ return null;
1449
+ }
1450
+ try {
1451
+ return await fs.open(terminalPath, "r+");
1452
+ } catch {
1453
+ return null;
1454
+ }
1455
+ }
1456
+
1457
+ #getPlanReviewHelpText(): string {
1458
+ const externalEditorKey = this.keybindings.getDisplayString("app.editor.external");
1459
+ if (!externalEditorKey) {
1460
+ return t("nav.hint");
1461
+ }
1462
+ return `up/down navigate enter select ${externalEditorKey.toLowerCase()} open in editor esc cancel`;
1463
+ }
1464
+
1465
+ async #openPlanInExternalEditor(planFilePath: string): Promise<void> {
1466
+ const editorCmd = getEditorCommand();
1467
+ if (!editorCmd) {
1468
+ this.showWarning("No editor configured. Set $VISUAL or $EDITOR environment variable.");
1469
+ return;
1470
+ }
1471
+
1472
+ const resolvedPath = this.#resolvePlanFilePath(planFilePath);
1473
+ let currentText: string;
1474
+ try {
1475
+ currentText = await Bun.file(resolvedPath).text();
1476
+ } catch (error) {
1477
+ if (isEnoent(error)) {
1478
+ this.showError(`Plan file not found at ${planFilePath}`);
1479
+ return;
1480
+ }
1481
+ this.showWarning(`Failed to open external editor: ${error instanceof Error ? error.message : String(error)}`);
1482
+ return;
1483
+ }
1484
+
1485
+ let ttyHandle: fs.FileHandle | null = null;
1486
+ try {
1487
+ ttyHandle = await this.#openEditorTerminalHandle();
1488
+ this.ui.stop();
1489
+
1490
+ const stdio: [number | "inherit", number | "inherit", number | "inherit"] = ttyHandle
1491
+ ? [ttyHandle.fd, ttyHandle.fd, ttyHandle.fd]
1492
+ : ["inherit", "inherit", "inherit"];
1493
+
1494
+ const result = await openInEditor(editorCmd, currentText, {
1495
+ extension: path.extname(resolvedPath) || ".md",
1496
+ stdio,
1497
+ trimTrailingNewline: false,
1498
+ });
1499
+ if (result !== null) {
1500
+ await Bun.write(resolvedPath, result);
1501
+ this.#renderPlanPreview(result);
1502
+ this.showStatus("Plan updated in external editor.");
1503
+ }
1504
+ } catch (error) {
1505
+ this.showWarning(`Failed to open external editor: ${error instanceof Error ? error.message : String(error)}`);
1506
+ } finally {
1507
+ if (ttyHandle) {
1508
+ await ttyHandle.close();
1509
+ }
1510
+ this.ui.start();
1511
+ this.ui.requestRender(true);
1512
+ }
1513
+ }
1514
+
1515
+ async #approvePlan(
1516
+ planContent: string,
1517
+ options: {
1518
+ planFilePath: string;
1519
+ finalPlanFilePath: string;
1520
+ title: string;
1521
+ preserveContext?: boolean;
1522
+ compactBeforeExecute?: boolean;
1523
+ },
1524
+ ): Promise<void> {
1525
+ await renameApprovedPlanFile({
1526
+ planFilePath: options.planFilePath,
1527
+ finalPlanFilePath: options.finalPlanFilePath,
1528
+ getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
1529
+ getSessionId: () => this.sessionManager.getSessionId(),
1530
+ });
1531
+ const previousTools = this.#planModePreviousTools ?? this.session.getActiveToolNames();
1532
+
1533
+ // Mark the pending abort caused by the plan-mode → compaction transition as
1534
+ // silent BEFORE #exitPlanMode raises it. The `finally` below clears the
1535
+ // flag on every terminal compaction outcome (ok / cancelled / failed /
1536
+ // throw) so a leaked flag cannot silence a later unrelated abort.
1537
+ // Branchless mark+clear when !compactBeforeExecute: mark is gated; clear
1538
+ // is unconditional and idempotent.
1539
+ if (options.compactBeforeExecute) {
1540
+ this.session.markPlanCompactAbortPending();
1541
+ }
1542
+ let compactOutcome: CompactionOutcome | undefined;
1543
+ try {
1544
+ await this.#exitPlanMode({ silent: true, paused: false });
1545
+
1546
+ if (!options.preserveContext) {
1547
+ await this.handleClearCommand();
1548
+ // The new session has a fresh local:// root — persist the approved plan there
1549
+ // so `local://<title>.md` resolves correctly in the execution session.
1550
+ const newLocalPath = resolveLocalUrlToPath(options.finalPlanFilePath, {
1551
+ getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
1552
+ getSessionId: () => this.sessionManager.getSessionId(),
1553
+ });
1554
+ await Bun.write(newLocalPath, planContent);
1555
+ } else if (options.compactBeforeExecute) {
1556
+ // Distill the plan-mode transcript before the execution turn is queued so
1557
+ // the plan-approved synthetic prompt lands as a fresh cache anchor.
1558
+ // Outcome is consumed after tool-restoration and plan-reference-path
1559
+ // bookkeeping below; `markPlanReferenceSent` is intentionally deferred
1560
+ // past the cancel guard — see the comment at the cancel branch.
1561
+ // Cancellation skips the synthetic-prompt dispatch (operator's explicit
1562
+ // abort is honored); failure proceeds best-effort — approval intent stands.
1563
+ const compactionPrompt = prompt.render(planModeCompactInstructionsPrompt, {
1564
+ planFilePath: options.finalPlanFilePath,
1565
+ });
1566
+ // Pin the plan reference path BEFORE compaction so any user messages
1567
+ // queued during the compaction await (which `handleCompactCommand`
1568
+ // flushes via `flushCompactionQueue` before returning) see the
1569
+ // approved plan in `#buildPlanReferenceMessage`. Reassignment after
1570
+ // the try/finally is idempotent and kept for the !compactBeforeExecute
1571
+ // branch.
1572
+ this.session.setPlanReferencePath(options.finalPlanFilePath);
1573
+ compactOutcome = await this.handleCompactCommand(compactionPrompt);
1574
+ }
1575
+ } finally {
1576
+ // Unconditional clear. Idempotent: a no-op when the flag was never set
1577
+ // (i.e., the !compactBeforeExecute branch), and a no-op when the flag
1578
+ // was already consumed by AgentSession.#handleAgentEvent's aborted
1579
+ // message_end stamping. Guarantees the flag is dead at every exit.
1580
+ this.session.clearPlanCompactAbortPending();
1581
+ }
1582
+
1583
+ // Tool restoration runs on every path — the plan mode tools must be
1584
+ // retired regardless of whether the synthetic prompt fires.
1585
+ if (previousTools.length > 0) {
1586
+ await this.session.setActiveToolsByName(previousTools);
1587
+ }
1588
+ this.session.setPlanReferencePath(options.finalPlanFilePath);
1589
+
1590
+ if (compactOutcome === "cancelled") {
1591
+ // Explicit abort: honor it. `executeCompaction` already surfaced
1592
+ // `showError("Compaction cancelled")` to the operator; we add the
1593
+ // deferred-dispatch warning and exit. `markPlanReferenceSent` is
1594
+ // intentionally skipped here: `#planReferenceSent` stays false, so
1595
+ // `AgentSession.#buildPlanReferenceMessage` will inject the plan
1596
+ // reference on the operator's next `prompt()` call. If we marked it
1597
+ // sent here, the executor's first turn would have no plan context.
1598
+ this.showWarning(
1599
+ "Plan approved, but compaction was cancelled — execution not dispatched. Submit a turn to continue.",
1600
+ );
1601
+ return;
1602
+ }
1603
+
1604
+ // Approved plans land in a fresh (or compacted) session whose first user-visible
1605
+ // turn is the synthetic plan-approved prompt — that path bypasses the
1606
+ // input-controller's title generation. Seed an auto-name from the plan title
1607
+ // so the session is not left unnamed. `setSessionName("auto")` is a no-op
1608
+ // when the user has already chosen a name (preserveContext paths).
1609
+ const seededName = humanizePlanTitle(options.title);
1610
+ if (seededName && !this.sessionManager.getSessionName()) {
1611
+ const applied = await this.sessionManager.setSessionName(seededName, "auto");
1612
+ if (applied) {
1613
+ setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
1614
+ this.updateEditorChrome();
1615
+ }
1616
+ }
1617
+
1618
+ // markPlanReferenceSent fires only on the dispatch path so the synthetic
1619
+ // plan-approved prompt is the source of the reference injection.
1620
+ this.session.markPlanReferenceSent();
1621
+ const planModePrompt = prompt.render(planModeApprovedPrompt, {
1622
+ planContent,
1623
+ finalPlanFilePath: options.finalPlanFilePath,
1624
+ contextPreserved: options.preserveContext === true,
1625
+ });
1626
+ await this.session.prompt(planModePrompt, { synthetic: true });
1627
+ }
1628
+
1629
+ async handlePlanModeCommand(initialPrompt?: string): Promise<void> {
1630
+ if (this.goalModeEnabled || this.goalModePaused) {
1631
+ this.showWarning("Exit goal mode first.");
1632
+ return;
1633
+ }
1634
+ if (this.planModeEnabled) {
1635
+ const confirmed = await this.showHookConfirm(
1636
+ "Exit plan mode?",
1637
+ "This exits plan mode without approving a plan.",
1638
+ );
1639
+ if (!confirmed) return;
1640
+ await this.#exitPlanMode({ paused: true });
1641
+ return;
1642
+ }
1643
+ if (!this.session.settings.get("plan.enabled")) {
1644
+ this.showWarning("Plan mode is disabled. Enable it in settings (plan.enabled).");
1645
+ return;
1646
+ }
1647
+ await this.#enterPlanMode();
1648
+ if (initialPrompt && this.onInputCallback) {
1649
+ this.onInputCallback(this.startPendingSubmission({ text: initialPrompt }));
1650
+ }
1651
+ }
1652
+
1653
+ async handleGoalModeCommand(rest?: string): Promise<void> {
1654
+ try {
1655
+ if (this.planModeEnabled || this.planModePaused) {
1656
+ this.showWarning("Exit plan mode first.");
1657
+ return;
1658
+ }
1659
+ if (!this.session.settings.get("goal.enabled")) {
1660
+ this.showWarning("Goal mode is disabled. Enable it in settings (goal.enabled).");
1661
+ return;
1662
+ }
1663
+ const { sub, rest: subRest } = parseGoalSubcommand(rest ?? "");
1664
+ if (sub) {
1665
+ await this.#dispatchGoalSubcommand(sub, subRest);
1666
+ return;
1667
+ }
1668
+ if (this.goalModeEnabled) {
1669
+ if (subRest) {
1670
+ this.showStatus("Goal mode is already active. Use /goal to manage it, or /goal drop to start over.");
1671
+ return;
1672
+ }
1673
+ await this.#openGoalMenu("active");
1674
+ return;
1675
+ }
1676
+ const pausedState = this.#getPausedGoalState();
1677
+ if (pausedState) {
1678
+ if (subRest) {
1679
+ this.showWarning("Resume the current goal first, or drop it before setting a new objective.");
1680
+ return;
1681
+ }
1682
+ await this.#openGoalMenu("paused");
1683
+ return;
1684
+ }
1685
+ if (subRest) {
1686
+ await this.#startGoalFromObjective(subRest);
1687
+ return;
1688
+ }
1689
+ const objective = (
1690
+ await this.showHookEditor("Goal objective", undefined, undefined, { promptStyle: true })
1691
+ )?.trim();
1692
+ if (!objective) return;
1693
+ await this.#startGoalFromObjective(objective);
1694
+ } catch (error) {
1695
+ this.showError(error instanceof Error ? error.message : String(error));
1696
+ }
1697
+ }
1698
+
1699
+ async #dispatchGoalSubcommand(sub: GoalSubcommand, rest: string): Promise<void> {
1700
+ switch (sub) {
1701
+ case "set":
1702
+ await this.#handleGoalSetSubcommand(rest);
1703
+ return;
1704
+ case "show":
1705
+ this.#showGoalDetails();
1706
+ return;
1707
+ case "pause":
1708
+ await this.#pauseGoalAction();
1709
+ return;
1710
+ case "resume":
1711
+ await this.#resumeGoalAction();
1712
+ return;
1713
+ case "drop":
1714
+ await this.#confirmAndDropGoal();
1715
+ return;
1716
+ }
1717
+ }
1718
+
1719
+ async #openGoalMenu(state: "active" | "paused"): Promise<void> {
1720
+ const goal = this.session.getGoalModeState()?.goal;
1721
+ if (!goal) return;
1722
+ const summary = goal.objective.length > 48 ? `${goal.objective.slice(0, 47)}…` : goal.objective;
1723
+ const title = state === "active" ? `Goal: ${summary} (${goal.status})` : `Goal paused: ${summary}`;
1724
+ const items = state === "active" ? ["Show details", "Pause", "Drop"] : ["Resume", "Show details", "Drop"];
1725
+ const choice = await this.showHookSelector(title, items);
1726
+ if (!choice) return;
1727
+ switch (choice) {
1728
+ case "Show details":
1729
+ this.#showGoalDetails();
1730
+ return;
1731
+ case "Pause":
1732
+ await this.#pauseGoalAction();
1733
+ return;
1734
+ case "Resume":
1735
+ await this.#resumeGoalAction();
1736
+ return;
1737
+ case "Drop":
1738
+ await this.#confirmAndDropGoal();
1739
+ return;
1740
+ }
1741
+ }
1742
+
1743
+ #showGoalDetails(): void {
1744
+ const state = this.session.getGoalModeState();
1745
+ const goal = state?.goal;
1746
+ if (!goal) {
1747
+ this.showStatus("No goal set.");
1748
+ return;
1749
+ }
1750
+ const used = goal.tokensUsed.toLocaleString();
1751
+ const lines = [
1752
+ `Objective: ${goal.objective}`,
1753
+ `Status: ${goal.status}${state?.enabled ? "" : " (paused)"}`,
1754
+ `Tokens used: ${used}`,
1755
+ `Time spent: ${formatDuration(goal.timeUsedSeconds * 1000)}`,
1756
+ ];
1757
+ this.showStatus(lines.join("\n"));
1758
+ }
1759
+
1760
+ async #pauseGoalAction(): Promise<void> {
1761
+ if (!this.goalModeEnabled) {
1762
+ this.showWarning("No active goal to pause.");
1763
+ return;
1764
+ }
1765
+ await this.session.goalRuntime.pauseGoal();
1766
+ await this.#exitGoalMode({ paused: true, reason: "paused" });
1767
+ }
1768
+
1769
+ async #resumeGoalAction(): Promise<void> {
1770
+ if (!this.#getPausedGoalState()) {
1771
+ this.showWarning("No paused goal to resume.");
1772
+ return;
1773
+ }
1774
+ await this.#enterGoalMode({ resume: true, silent: true });
1775
+ this.showStatus("Goal mode resumed.");
1776
+ this.#scheduleGoalContinuation();
1777
+ }
1778
+
1779
+ async #confirmAndDropGoal(): Promise<void> {
1780
+ if (!this.goalModeEnabled && !this.#getPausedGoalState()) {
1781
+ this.showWarning("No goal to drop.");
1782
+ return;
1783
+ }
1784
+ const confirmed = await this.showHookConfirm(
1785
+ "Drop goal?",
1786
+ "This removes the goal record. Accumulated usage stays in the session log.",
1787
+ );
1788
+ if (!confirmed) return;
1789
+ await this.session.goalRuntime.dropGoal();
1790
+ await this.#exitGoalMode({ reason: "dropped" });
1791
+ }
1792
+
1793
+ async #startGoalFromObjective(objective: string): Promise<void> {
1794
+ await this.#enterGoalMode({ objective, silent: true });
1795
+ this.#resetGoalContinuationSuppression();
1796
+ if (this.onInputCallback) {
1797
+ this.onInputCallback(this.startPendingSubmission({ text: objective }));
1798
+ }
1799
+ }
1800
+
1801
+ async #replaceGoalFromObjective(objective: string): Promise<void> {
1802
+ const state = await this.session.goalRuntime.replaceGoal({ objective });
1803
+ this.session.setGoalModeState(state);
1804
+ this.goalModeEnabled = true;
1805
+ this.goalModePaused = false;
1806
+ this.#resetGoalContinuationSuppression();
1807
+ this.#updateGoalModeStatus();
1808
+ if (this.session.isStreaming) {
1809
+ await this.session.sendGoalModeContext({ deliverAs: "steer" });
1810
+ }
1811
+ if (this.onInputCallback) {
1812
+ this.onInputCallback(this.startPendingSubmission({ text: objective }));
1813
+ }
1814
+ }
1815
+
1816
+ async #handleGoalSetSubcommand(rest: string): Promise<void> {
1817
+ if (!this.goalModeEnabled && this.#getPausedGoalState()) {
1818
+ this.showWarning("Resume the current goal first, or drop it before setting a new objective.");
1819
+ return;
1820
+ }
1821
+ const objective = rest.trim()
1822
+ ? rest.trim()
1823
+ : (await this.showHookEditor("Goal objective", undefined, undefined, { promptStyle: true }))?.trim();
1824
+ if (!objective) return;
1825
+ if (this.goalModeEnabled) {
1826
+ await this.#replaceGoalFromObjective(objective);
1827
+ return;
1828
+ }
1829
+ await this.#startGoalFromObjective(objective);
1830
+ }
1831
+
1832
+ async handlePlanApproval(details: PlanApprovalDetails): Promise<void> {
1833
+ if (!this.planModeEnabled) {
1834
+ this.showWarning("Plan mode is not active.");
1835
+ return;
1836
+ }
1837
+
1838
+ // Abort the agent to prevent it from continuing (e.g., re-submitting the
1839
+ // plan) while the popup is showing. The event listener fires asynchronously
1840
+ // (agent's #emit is fire-and-forget), so without this the model sees
1841
+ // "Plan ready for approval." and immediately re-invokes `resolve` in a loop.
1842
+ await this.session.abort({ timeoutMs: INTERACTIVE_ABORT_CLEANUP_TIMEOUT_MS });
1843
+
1844
+ const planFilePath = details.planFilePath || this.planModePlanFilePath || (await this.#getPlanFilePath());
1845
+ this.planModePlanFilePath = planFilePath;
1846
+ const planContent = await this.#readPlanFile(planFilePath);
1847
+ if (!planContent) {
1848
+ this.showError(`Plan file not found at ${planFilePath}`);
1849
+ return;
1850
+ }
1851
+
1852
+ this.#renderPlanPreview(planContent, { append: true });
1853
+ const choice = await this.showHookSelector(
1854
+ "Plan mode - next step",
1855
+ ["Approve and execute", "Approve and compact context", "Approve and keep context", "Refine plan"],
1856
+ {
1857
+ helpText: this.#getPlanReviewHelpText(),
1858
+ onExternalEditor: () => void this.#openPlanInExternalEditor(planFilePath),
1859
+ },
1860
+ );
1861
+
1862
+ if (
1863
+ choice === "Approve and execute" ||
1864
+ choice === "Approve and compact context" ||
1865
+ choice === "Approve and keep context"
1866
+ ) {
1867
+ const finalPlanFilePath = details.finalPlanFilePath || planFilePath;
1868
+ try {
1869
+ const latestPlanContent = await this.#readPlanFile(planFilePath);
1870
+ if (!latestPlanContent) {
1871
+ this.showError(`Plan file not found at ${planFilePath}`);
1872
+ return;
1873
+ }
1874
+ await this.#approvePlan(latestPlanContent, {
1875
+ planFilePath,
1876
+ finalPlanFilePath,
1877
+ title: details.title,
1878
+ preserveContext: choice !== "Approve and execute",
1879
+ compactBeforeExecute: choice === "Approve and compact context",
1880
+ });
1881
+ } catch (error) {
1882
+ this.showError(
1883
+ `Failed to finalize approved plan: ${error instanceof Error ? error.message : String(error)}`,
1884
+ );
1885
+ }
1886
+ return;
1887
+ }
1888
+ }
1889
+
1890
+ stop(): void {
1891
+ if (this.loadingAnimation) {
1892
+ this.loadingAnimation.stop();
1893
+ this.loadingAnimation = undefined;
1894
+ }
1895
+ this.#cleanupMicAnimation();
1896
+ this.#cancelGoalContinuation();
1897
+ if (this.#sttController) {
1898
+ this.#sttController.dispose();
1899
+ this.#sttController = undefined;
1900
+ }
1901
+ this.#extensionUiController.clearExtensionTerminalInputListeners();
1902
+ this.#extensionUiController.clearHookWidgets();
1903
+ for (const unsubscribe of this.#eventBusUnsubscribers) {
1904
+ unsubscribe();
1905
+ }
1906
+ this.#eventBusUnsubscribers = [];
1907
+ this.#observerRegistry.dispose();
1908
+ this.#eventController.dispose();
1909
+ this.statusLine.dispose();
1910
+ this.#jobsObserver?.dispose();
1911
+ this.editor.dispose();
1912
+ if (this.#resizeHandler) {
1913
+ process.stdout.removeListener("resize", this.#resizeHandler);
1914
+ this.#resizeHandler = undefined;
1915
+ }
1916
+ if (this.unsubscribe) {
1917
+ this.unsubscribe();
1918
+ }
1919
+ if (this.#cleanupUnsubscribe) {
1920
+ this.#cleanupUnsubscribe();
1921
+ }
1922
+ if (this.#subprocessTeardownUnsubscribe) {
1923
+ this.#subprocessTeardownUnsubscribe();
1924
+ }
1925
+ if (this.isInitialized) {
1926
+ this.ui.stop();
1927
+ this.isInitialized = false;
1928
+ }
1929
+ }
1930
+
1931
+ async shutdown(): Promise<void> {
1932
+ if (this.#isShuttingDown) return;
1933
+ this.#isShuttingDown = true;
1934
+
1935
+ // Snapshot the editor before any teardown empties it. Persisting the draft
1936
+ // here covers Ctrl+D shutdown with non-empty text; for /exit the editor is
1937
+ // already cleared so saveDraft("") just removes any stale sidecar.
1938
+ const draftText = this.editor.getText();
1939
+
1940
+ // Flush pending session writes before shutdown
1941
+ await this.sessionManager.flush();
1942
+ try {
1943
+ await this.sessionManager.saveDraft(draftText);
1944
+ } catch (err) {
1945
+ logger.warn("Failed to save session draft", { error: String(err) });
1946
+ }
1947
+ this.#btwController.dispose();
1948
+
1949
+ // Emit shutdown event to hooks
1950
+ await this.session.dispose();
1951
+
1952
+ if (this.isInitialized) {
1953
+ this.ui.requestRender(true);
1954
+ }
1955
+
1956
+ // Wait for any pending renders to complete
1957
+ // requestRender() uses process.nextTick(), so we wait one tick
1958
+ await new Promise(resolve => process.nextTick(resolve));
1959
+
1960
+ // Drain any in-flight Kitty key release events before stopping.
1961
+ // This prevents escape sequences from leaking to the parent shell over slow SSH.
1962
+ await this.ui.terminal.drainInput(1000);
1963
+ popTerminalTitle();
1964
+ this.stop();
1965
+
1966
+ // Print resumption hint if this is a persisted session
1967
+ const sessionId = this.sessionManager.getSessionId();
1968
+ const sessionFile = this.sessionManager.getSessionFile();
1969
+ if (sessionId && sessionFile) {
1970
+ process.stderr.write(`\n${chalk.dim(`Resume this session with ${APP_NAME} --resume ${sessionId}`)}\n`);
1971
+ }
1972
+
1973
+ await postmortem.quit(0);
1974
+ }
1975
+
1976
+ async checkShutdownRequested(): Promise<void> {
1977
+ if (!this.shutdownRequested) return;
1978
+ await this.shutdown();
1979
+ }
1980
+
1981
+ // Extension UI integration
1982
+ setToolUIContext(uiContext: ExtensionUIContext, hasUI: boolean): void {
1983
+ this.#toolUiContextSetter(uiContext, hasUI);
1984
+ }
1985
+
1986
+ initializeHookRunner(uiContext: ExtensionUIContext, hasUI: boolean): void {
1987
+ this.#extensionUiController.initializeHookRunner(uiContext, hasUI);
1988
+ }
1989
+ createBackgroundUiContext(): ExtensionUIContext {
1990
+ return this.#extensionUiController.createBackgroundUiContext();
1991
+ }
1992
+
1993
+ setEditorComponent(
1994
+ factory: ((tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) => CustomEditor) | undefined,
1995
+ ): void {
1996
+ const previousEditor = this.editor;
1997
+ const previousText = previousEditor.getText();
1998
+ const nextEditor = factory
1999
+ ? factory(this.ui, getEditorTheme(), this.keybindings)
2000
+ : new CustomEditor(getEditorTheme());
2001
+
2002
+ configureDefaultComposerChrome(nextEditor);
2003
+ nextEditor.setUseTerminalCursor(this.ui.getShowHardwareCursor());
2004
+ nextEditor.setAutocompleteMaxVisible(this.settings.get("autocompleteMaxVisible"));
2005
+ nextEditor.onAutocompleteCancel = () => {
2006
+ this.ui.requestRender(true);
2007
+ };
2008
+ nextEditor.onAutocompleteUpdate = () => {
2009
+ this.ui.requestRender();
2010
+ };
2011
+ nextEditor.setMaxHeight(this.#computeEditorMaxHeight());
2012
+ if (this.historyStorage) {
2013
+ nextEditor.setHistoryStorage(this.historyStorage);
2014
+ }
2015
+ nextEditor.setText(previousText);
2016
+ previousEditor.dispose();
2017
+
2018
+ this.editorContainer.clear();
2019
+ this.editor = nextEditor;
2020
+ this.editorContainer.addChild(nextEditor);
2021
+ this.ui.setFocus(nextEditor);
2022
+
2023
+ this.#inputController.setupKeyHandlers();
2024
+ this.#inputController.setupEditorSubmitHandler();
2025
+
2026
+ void this.refreshSlashCommandState().catch(error => {
2027
+ logger.warn("Failed to refresh slash command state for custom editor", { error: String(error) });
2028
+ });
2029
+
2030
+ this.updateEditorChrome();
2031
+ this.ui.requestRender();
2032
+ }
2033
+
2034
+ // Event handling
2035
+ async handleBackgroundEvent(event: AgentSessionEvent): Promise<void> {
2036
+ await this.#eventController.handleBackgroundEvent(event);
2037
+ }
2038
+
2039
+ // UI helpers
2040
+ showStatus(message: string, options?: { dim?: boolean }): void {
2041
+ this.#uiHelpers.showStatus(message, options);
2042
+ }
2043
+
2044
+ showError(message: string): void {
2045
+ this.#pendingSubmittedInput = undefined;
2046
+ this.optimisticUserMessageSignature = undefined;
2047
+ this.#pendingSubmissionDispose?.();
2048
+ this.#pendingSubmissionDispose = undefined;
2049
+ this.#pendingWorkingMessage = undefined;
2050
+ if (this.loadingAnimation) {
2051
+ this.loadingAnimation.stop();
2052
+ this.loadingAnimation = undefined;
2053
+ this.statusContainer.clear();
2054
+ }
2055
+ this.#uiHelpers.showError(message);
2056
+ }
2057
+
2058
+ showWarning(message: string): void {
2059
+ this.#uiHelpers.showWarning(message);
2060
+ }
2061
+
2062
+ #handleLspStartupEvent(event: LspStartupEvent): void {
2063
+ this.#updateWelcomeLspServers();
2064
+
2065
+ if (event.type === "failed") {
2066
+ this.showWarning(`LSP startup failed: ${event.error}. It will retry lazily on write.`);
2067
+ return;
2068
+ }
2069
+
2070
+ const failedServers = event.servers.filter(server => server.status === "error");
2071
+
2072
+ if (failedServers.length === 1) {
2073
+ const failedServer = failedServers[0];
2074
+ const detail = failedServer.error ? `: ${failedServer.error}` : "";
2075
+ this.showWarning(`LSP startup failed for ${failedServer.name}${detail}. It will retry lazily on write.`);
2076
+ return;
2077
+ }
2078
+
2079
+ if (failedServers.length > 1) {
2080
+ const failedNames = failedServers.map(server => server.name).join(", ");
2081
+ this.showWarning(`LSP startup failed for ${failedNames}. It will retry lazily on write.`);
2082
+ }
2083
+ }
2084
+
2085
+ #getWelcomeLspServers(): WelcomeLspServerInfo[] {
2086
+ return (
2087
+ this.lspServers?.map(server => ({
2088
+ name: server.name,
2089
+ status: server.status,
2090
+ fileTypes: server.fileTypes,
2091
+ })) ?? []
2092
+ );
2093
+ }
2094
+
2095
+ #updateWelcomeLspServers(): void {
2096
+ if (!this.#welcomeComponent) {
2097
+ return;
2098
+ }
2099
+
2100
+ this.#welcomeComponent.setLspServers(this.#getWelcomeLspServers());
2101
+ this.ui.requestRender();
2102
+ }
2103
+
2104
+ #getWorkingMessageAccent(): WorkingMessageAccent | undefined {
2105
+ const accentEnabled = !isSettingsInitialized() || settings.get("statusLine.sessionAccent") !== false;
2106
+ const sessionName = accentEnabled ? this.sessionManager.getSessionName() : undefined;
2107
+ if (!sessionName) return undefined;
2108
+ const hex = getSessionAccentHex(sessionName);
2109
+ const main = getSessionAccentAnsi(hex);
2110
+ const dim = getSessionAccentAnsi(adjustHsv(hex, { s: 0.55, v: 0.65 }));
2111
+ return main && dim ? { main, dim } : undefined;
2112
+ }
2113
+
2114
+ ensureLoadingAnimation(): void {
2115
+ if (!this.loadingAnimation) {
2116
+ this.statusContainer.clear();
2117
+ this.loadingAnimation = new Loader(
2118
+ this.ui,
2119
+ spinner => {
2120
+ const accent = this.#getWorkingMessageAccent();
2121
+ return accent ? `${accent.main}${spinner}\x1b[39m` : theme.fg("accent", spinner);
2122
+ },
2123
+ message => renderWorkingMessage(message, this.#getWorkingMessageAccent()),
2124
+ this.#defaultWorkingMessage,
2125
+ getSymbolTheme().spinnerFrames,
2126
+ );
2127
+ this.statusContainer.addChild(this.loadingAnimation);
2128
+ }
2129
+
2130
+ this.applyPendingWorkingMessage();
2131
+ }
2132
+
2133
+ setWorkingMessage(message?: string): void {
2134
+ if (message === undefined) {
2135
+ this.#pendingWorkingMessage = undefined;
2136
+ if (this.loadingAnimation) {
2137
+ this.loadingAnimation.setMessage(this.#defaultWorkingMessage);
2138
+ }
2139
+ return;
2140
+ }
2141
+
2142
+ if (this.loadingAnimation) {
2143
+ this.loadingAnimation.setMessage(message);
2144
+ return;
2145
+ }
2146
+
2147
+ this.#pendingWorkingMessage = message;
2148
+ }
2149
+
2150
+ applyPendingWorkingMessage(): void {
2151
+ if (this.#pendingWorkingMessage === undefined) {
2152
+ return;
2153
+ }
2154
+
2155
+ const message = this.#pendingWorkingMessage;
2156
+ this.#pendingWorkingMessage = undefined;
2157
+ this.setWorkingMessage(message);
2158
+ }
2159
+
2160
+ showNewVersionNotification(newVersion: string): void {
2161
+ this.#uiHelpers.showNewVersionNotification(newVersion);
2162
+ }
2163
+
2164
+ clearEditor(): void {
2165
+ this.#uiHelpers.clearEditor();
2166
+ }
2167
+
2168
+ updatePendingMessagesDisplay(): void {
2169
+ this.#uiHelpers.updatePendingMessagesDisplay();
2170
+ }
2171
+
2172
+ queueCompactionMessage(text: string, mode: "steer" | "followUp"): void {
2173
+ this.#uiHelpers.queueCompactionMessage(text, mode);
2174
+ }
2175
+
2176
+ flushCompactionQueue(options?: { willRetry?: boolean }): Promise<void> {
2177
+ return this.#uiHelpers.flushCompactionQueue(options);
2178
+ }
2179
+
2180
+ flushPendingBashComponents(): void {
2181
+ this.#uiHelpers.flushPendingBashComponents();
2182
+ }
2183
+
2184
+ isKnownSlashCommand(text: string): boolean {
2185
+ return this.#uiHelpers.isKnownSlashCommand(text);
2186
+ }
2187
+
2188
+ addMessageToChat(message: AgentMessage, options?: { populateHistory?: boolean }): Component[] {
2189
+ return this.#uiHelpers.addMessageToChat(message, options);
2190
+ }
2191
+
2192
+ renderSessionContext(
2193
+ sessionContext: SessionContext,
2194
+ options?: { updateFooter?: boolean; populateHistory?: boolean },
2195
+ ): void {
2196
+ this.#uiHelpers.renderSessionContext(sessionContext, options);
2197
+ }
2198
+
2199
+ renderInitialMessages(prebuiltContext?: SessionContext, options?: { preserveExistingChat?: boolean }): void {
2200
+ this.#uiHelpers.renderInitialMessages(prebuiltContext, options);
2201
+ }
2202
+
2203
+ getUserMessageText(message: Message): string {
2204
+ return this.#uiHelpers.getUserMessageText(message);
2205
+ }
2206
+
2207
+ findLastAssistantMessage(): AssistantMessage | undefined {
2208
+ return this.#uiHelpers.findLastAssistantMessage();
2209
+ }
2210
+
2211
+ extractAssistantText(message: AssistantMessage): string {
2212
+ return this.#uiHelpers.extractAssistantText(message);
2213
+ }
2214
+
2215
+ // Command handling
2216
+ handleExportCommand(text: string): Promise<void> {
2217
+ return this.#commandController.handleExportCommand(text);
2218
+ }
2219
+
2220
+ handleDumpCommand() {
2221
+ return this.#commandController.handleDumpCommand();
2222
+ }
2223
+
2224
+ handleDebugTranscriptCommand(): Promise<void> {
2225
+ return this.#commandController.handleDebugTranscriptCommand();
2226
+ }
2227
+
2228
+ handleShareCommand(): Promise<void> {
2229
+ return this.#commandController.handleShareCommand();
2230
+ }
2231
+
2232
+ handleCopyCommand(sub?: string) {
2233
+ return this.#commandController.handleCopyCommand(sub);
2234
+ }
2235
+
2236
+ handleTodoCommand(args: string): Promise<void> {
2237
+ return this.#todoCommandController.handleTodoCommand(args);
2238
+ }
2239
+
2240
+ handleSessionCommand(): Promise<void> {
2241
+ return this.#commandController.handleSessionCommand();
2242
+ }
2243
+
2244
+ handleJobsCommand(): Promise<void> {
2245
+ return this.#commandController.handleJobsCommand();
2246
+ }
2247
+
2248
+ handleUsageCommand(reports?: UsageReport[] | null): Promise<void> {
2249
+ return this.#commandController.handleUsageCommand(reports);
2250
+ }
2251
+
2252
+ async handleChangelogCommand(showFull = false): Promise<void> {
2253
+ await this.#commandController.handleChangelogCommand(showFull);
2254
+ }
2255
+
2256
+ handleHotkeysCommand(): void {
2257
+ this.#commandController.handleHotkeysCommand();
2258
+ }
2259
+
2260
+ handleToolsCommand(): void {
2261
+ this.#commandController.handleToolsCommand();
2262
+ }
2263
+
2264
+ handleContextCommand(): void {
2265
+ this.#commandController.handleContextCommand();
2266
+ }
2267
+
2268
+ #prepareSessionSwitch(): void {
2269
+ this.#btwController.dispose();
2270
+ this.#extensionUiController.clearExtensionTerminalInputListeners();
2271
+ this.#planReviewContainer = undefined;
2272
+ }
2273
+
2274
+ handleClearCommand(): Promise<void> {
2275
+ this.#prepareSessionSwitch();
2276
+ return this.#commandController.handleClearCommand();
2277
+ }
2278
+
2279
+ handleDropCommand(): Promise<void> {
2280
+ this.#prepareSessionSwitch();
2281
+ return this.#commandController.handleDropCommand();
2282
+ }
2283
+
2284
+ handleForkCommand(): Promise<void> {
2285
+ this.#btwController.dispose();
2286
+ return this.#commandController.handleForkCommand();
2287
+ }
2288
+
2289
+ handleMoveCommand(targetPath: string): Promise<void> {
2290
+ return this.#commandController.handleMoveCommand(targetPath);
2291
+ }
2292
+
2293
+ handleRenameCommand(title: string): Promise<void> {
2294
+ return this.#commandController.handleRenameCommand(title);
2295
+ }
2296
+
2297
+ handleMemoryCommand(text: string): Promise<void> {
2298
+ return this.#commandController.handleMemoryCommand(text);
2299
+ }
2300
+
2301
+ async handleSTTToggle(): Promise<void> {
2302
+ if (!settings.get("stt.enabled")) {
2303
+ this.showWarning("Speech-to-text is disabled. Enable it in settings: stt.enabled");
2304
+ return;
2305
+ }
2306
+ if (!this.#sttController) {
2307
+ this.#sttController = new STTController();
2308
+ }
2309
+ await this.#sttController.toggle(this.editor, {
2310
+ showWarning: (msg: string) => this.showWarning(msg),
2311
+ showStatus: (msg: string) => this.showStatus(msg),
2312
+ onStateChange: (state: SttState) => {
2313
+ if (state === "recording") {
2314
+ this.#voicePreviousShowHardwareCursor = this.ui.getShowHardwareCursor();
2315
+ this.#voicePreviousUseTerminalCursor = this.editor.getUseTerminalCursor();
2316
+ this.ui.setShowHardwareCursor(false);
2317
+ this.editor.setUseTerminalCursor(false);
2318
+ this.#startMicAnimation();
2319
+ } else if (state === "transcribing") {
2320
+ this.#stopMicAnimation();
2321
+ this.#setMicCursor({ r: 200, g: 200, b: 200 });
2322
+ } else {
2323
+ this.#cleanupMicAnimation();
2324
+ }
2325
+ this.updateEditorChrome();
2326
+ this.ui.requestRender();
2327
+ },
2328
+ });
2329
+ }
2330
+
2331
+ #setMicCursor(color: { r: number; g: number; b: number }): void {
2332
+ this.editor.cursorOverride = `\x1b[38;2;${color.r};${color.g};${color.b}m${theme.icon.mic}\x1b[0m`;
2333
+ // Theme symbols can be wide (for example, 🎤), so measure the rendered override.
2334
+ this.editor.cursorOverrideWidth = visibleWidth(this.editor.cursorOverride);
2335
+ }
2336
+
2337
+ #updateMicIcon(): void {
2338
+ const { r, g, b } = hsvToRgb({ h: this.#voiceHue, s: 0.9, v: 1.0 });
2339
+ this.#setMicCursor({ r, g, b });
2340
+ }
2341
+
2342
+ #startMicAnimation(): void {
2343
+ if (this.#voiceAnimationInterval) return;
2344
+ this.#voiceHue = 0;
2345
+ this.#updateMicIcon();
2346
+ this.#voiceAnimationInterval = setInterval(() => {
2347
+ this.#voiceHue = (this.#voiceHue + 8) % 360;
2348
+ this.#updateMicIcon();
2349
+ this.ui.requestRender();
2350
+ }, 60);
2351
+ }
2352
+
2353
+ #stopMicAnimation(): void {
2354
+ if (this.#voiceAnimationInterval) {
2355
+ clearInterval(this.#voiceAnimationInterval);
2356
+ this.#voiceAnimationInterval = undefined;
2357
+ }
2358
+ }
2359
+
2360
+ #cleanupMicAnimation(): void {
2361
+ if (this.#voiceAnimationInterval) {
2362
+ clearInterval(this.#voiceAnimationInterval);
2363
+ this.#voiceAnimationInterval = undefined;
2364
+ }
2365
+ this.editor.cursorOverride = undefined;
2366
+ this.editor.cursorOverrideWidth = undefined;
2367
+ if (this.#voicePreviousShowHardwareCursor !== null) {
2368
+ this.ui.setShowHardwareCursor(this.#voicePreviousShowHardwareCursor);
2369
+ this.#voicePreviousShowHardwareCursor = null;
2370
+ }
2371
+ if (this.#voicePreviousUseTerminalCursor !== null) {
2372
+ this.editor.setUseTerminalCursor(this.#voicePreviousUseTerminalCursor);
2373
+ this.#voicePreviousUseTerminalCursor = null;
2374
+ }
2375
+ }
2376
+
2377
+ showDebugSelector(): void {
2378
+ this.#selectorController.showDebugSelector();
2379
+ }
2380
+
2381
+ showSessionObserver(): void {
2382
+ const sessions = this.#observerRegistry.getSessions();
2383
+ if (sessions.length <= 1) {
2384
+ this.showStatus("No active subagent sessions");
2385
+ return;
2386
+ }
2387
+ this.#selectorController.showSessionObserver(this.#observerRegistry);
2388
+ }
2389
+
2390
+ showJobsOverlay(): void {
2391
+ if (!this.#jobsObserver) {
2392
+ this.showStatus("Background jobs are unavailable in this session");
2393
+ return;
2394
+ }
2395
+ this.#selectorController.showJobsOverlay(this.#jobsObserver);
2396
+ }
2397
+
2398
+ resetObserverRegistry(): void {
2399
+ this.#observerRegistry.resetSessions();
2400
+ this.#observerRegistry.setMainSession(this.sessionManager.getSessionFile() ?? undefined);
2401
+ }
2402
+
2403
+ handleBashCommand(command: string, excludeFromContext?: boolean): Promise<void> {
2404
+ return this.#commandController.handleBashCommand(command, excludeFromContext);
2405
+ }
2406
+
2407
+ handlePythonCommand(code: string, excludeFromContext?: boolean): Promise<void> {
2408
+ return this.#commandController.handlePythonCommand(code, excludeFromContext);
2409
+ }
2410
+
2411
+ async handleMCPCommand(_text: string): Promise<void> {
2412
+ this.showWarning(`MCP commands are not available in ${APP_NAME}.`);
2413
+ }
2414
+
2415
+ async handleSSHCommand(text: string): Promise<void> {
2416
+ const controller = new SSHCommandController(this);
2417
+ await controller.handle(text);
2418
+ }
2419
+
2420
+ handleCompactCommand(customInstructions?: string): Promise<CompactionOutcome> {
2421
+ return this.#commandController.handleCompactCommand(customInstructions);
2422
+ }
2423
+
2424
+ handleHandoffCommand(customInstructions?: string): Promise<void> {
2425
+ return this.#commandController.handleHandoffCommand(customInstructions);
2426
+ }
2427
+
2428
+ handleContributionPrepCommand(customInstructions?: string): Promise<void> {
2429
+ return this.#commandController.handleContributionPrepCommand(customInstructions);
2430
+ }
2431
+
2432
+ executeCompaction(
2433
+ customInstructionsOrOptions?: string | CompactOptions,
2434
+ isAuto?: boolean,
2435
+ ): Promise<CompactionOutcome> {
2436
+ return this.#commandController.executeCompaction(customInstructionsOrOptions, isAuto);
2437
+ }
2438
+
2439
+ openInBrowser(urlOrPath: string): void {
2440
+ this.#commandController.openInBrowser(urlOrPath);
2441
+ }
2442
+
2443
+ // Selector handling
2444
+ showSettingsSelector(): void {
2445
+ this.#selectorController.showSettingsSelector();
2446
+ }
2447
+
2448
+ showThemeSelector(): void {
2449
+ this.#selectorController.showThemeSelector();
2450
+ }
2451
+
2452
+ showHistorySearch(): void {
2453
+ this.#selectorController.showHistorySearch();
2454
+ }
2455
+
2456
+ showExtensionsDashboard(): void {
2457
+ void this.#selectorController.showExtensionsDashboard();
2458
+ }
2459
+
2460
+ showAgentsDashboard(): void {
2461
+ void this.#selectorController.showAgentsDashboard();
2462
+ }
2463
+
2464
+ showModelSelector(options?: { temporaryOnly?: boolean }): void {
2465
+ this.#selectorController.showModelSelector(options);
2466
+ }
2467
+
2468
+ showProviderOnboarding(): void {
2469
+ this.#selectorController.showProviderOnboarding();
2470
+ }
2471
+
2472
+ showPluginSelector(mode?: "install" | "uninstall"): void {
2473
+ void this.#selectorController.showPluginSelector(mode);
2474
+ }
2475
+
2476
+ showUserMessageSelector(): void {
2477
+ this.#selectorController.showUserMessageSelector();
2478
+ }
2479
+
2480
+ showTreeSelector(): void {
2481
+ this.#selectorController.showTreeSelector();
2482
+ }
2483
+
2484
+ showSessionSelector(): void {
2485
+ this.#selectorController.showSessionSelector();
2486
+ }
2487
+
2488
+ handleResumeSession(sessionPath: string): Promise<void> {
2489
+ this.#btwController.dispose();
2490
+ this.resetObserverRegistry();
2491
+ return this.#selectorController.handleResumeSession(sessionPath);
2492
+ }
2493
+
2494
+ handleSessionDeleteCommand(): Promise<void> {
2495
+ return this.#selectorController.handleSessionDeleteCommand();
2496
+ }
2497
+
2498
+ showOAuthSelector(mode: "login" | "logout", providerId?: string): Promise<void> {
2499
+ return this.#selectorController.showOAuthSelector(mode, providerId);
2500
+ }
2501
+
2502
+ showHookConfirm(title: string, message: string): Promise<boolean> {
2503
+ return this.#extensionUiController.showHookConfirm(title, message);
2504
+ }
2505
+
2506
+ // Input handling
2507
+ handleCtrlC(): void {
2508
+ this.#inputController.handleCtrlC();
2509
+ }
2510
+
2511
+ handleCtrlD(): void {
2512
+ this.#inputController.handleCtrlD();
2513
+ }
2514
+
2515
+ handleCtrlZ(): void {
2516
+ this.#inputController.handleCtrlZ();
2517
+ }
2518
+
2519
+ handleDequeue(): void {
2520
+ this.#inputController.handleDequeue();
2521
+ }
2522
+
2523
+ handleBackgroundCommand(): void {
2524
+ this.#inputController.handleBackgroundCommand();
2525
+ }
2526
+
2527
+ handleImagePaste(): Promise<boolean> {
2528
+ return this.#inputController.handleImagePaste();
2529
+ }
2530
+
2531
+ handleBtwCommand(question: string): Promise<void> {
2532
+ return this.#btwController.start(question);
2533
+ }
2534
+
2535
+ hasActiveBtw(): boolean {
2536
+ return this.#btwController.hasActiveRequest();
2537
+ }
2538
+
2539
+ handleBtwEscape(): boolean {
2540
+ return this.#btwController.handleEscape();
2541
+ }
2542
+
2543
+ cycleThinkingLevel(): void {
2544
+ this.#inputController.cycleThinkingLevel();
2545
+ }
2546
+
2547
+ cycleRoleModel(options?: { temporary?: boolean }): Promise<void> {
2548
+ return this.#inputController.cycleRoleModel(options);
2549
+ }
2550
+
2551
+ toggleToolOutputExpansion(): void {
2552
+ this.#inputController.toggleToolOutputExpansion();
2553
+ }
2554
+
2555
+ setToolsExpanded(expanded: boolean): void {
2556
+ this.#inputController.setToolsExpanded(expanded);
2557
+ }
2558
+
2559
+ toggleThinkingBlockVisibility(): void {
2560
+ this.#inputController.toggleThinkingBlockVisibility();
2561
+ }
2562
+
2563
+ toggleTodoExpansion(): void {
2564
+ this.todoExpanded = !this.todoExpanded;
2565
+ this.#renderTodoList();
2566
+ this.ui.requestRender();
2567
+ }
2568
+
2569
+ setTodos(todos: TodoItem[] | TodoPhase[]): void {
2570
+ if (todos.length > 0 && "tasks" in todos[0]) {
2571
+ this.todoPhases = todos as TodoPhase[];
2572
+ } else {
2573
+ this.todoPhases = [
2574
+ {
2575
+ name: "Todos",
2576
+ tasks: todos as TodoItem[],
2577
+ },
2578
+ ];
2579
+ }
2580
+ this.#renderTodoList();
2581
+ this.ui.requestRender();
2582
+ }
2583
+
2584
+ async reloadTodos(): Promise<void> {
2585
+ await this.#loadTodoList();
2586
+ this.ui.requestRender();
2587
+ }
2588
+
2589
+ openExternalEditor(): void {
2590
+ this.#inputController.openExternalEditor();
2591
+ }
2592
+
2593
+ registerExtensionShortcuts(): void {
2594
+ this.#inputController.registerExtensionShortcuts();
2595
+ }
2596
+
2597
+ // Hook UI methods
2598
+ initHooksAndCustomTools(): Promise<void> {
2599
+ return this.#extensionUiController.initHooksAndCustomTools();
2600
+ }
2601
+
2602
+ emitCustomToolSessionEvent(
2603
+ reason: "start" | "switch" | "branch" | "tree" | "shutdown",
2604
+ previousSessionFile?: string,
2605
+ ): Promise<void> {
2606
+ return this.#extensionUiController.emitCustomToolSessionEvent(reason, previousSessionFile);
2607
+ }
2608
+
2609
+ setHookWidget(key: string, content: ExtensionWidgetContent, options?: ExtensionWidgetOptions): void {
2610
+ this.#extensionUiController.setHookWidget(key, content, options);
2611
+ }
2612
+
2613
+ setHookStatus(key: string, text: string | undefined): void {
2614
+ this.#extensionUiController.setHookStatus(key, text);
2615
+ }
2616
+
2617
+ showHookSelector(
2618
+ title: string,
2619
+ options: string[],
2620
+ dialogOptions?: ExtensionUIDialogOptions,
2621
+ ): Promise<string | undefined> {
2622
+ return this.#extensionUiController.showHookSelector(title, options, dialogOptions);
2623
+ }
2624
+
2625
+ hideHookSelector(): void {
2626
+ this.#extensionUiController.hideHookSelector();
2627
+ }
2628
+
2629
+ showHookInput(title: string, placeholder?: string): Promise<string | undefined> {
2630
+ return this.#extensionUiController.showHookInput(title, placeholder);
2631
+ }
2632
+
2633
+ hideHookInput(): void {
2634
+ this.#extensionUiController.hideHookInput();
2635
+ }
2636
+
2637
+ showHookEditor(
2638
+ title: string,
2639
+ prefill?: string,
2640
+ dialogOptions?: ExtensionUIDialogOptions,
2641
+ editorOptions?: { promptStyle?: boolean },
2642
+ ): Promise<string | undefined> {
2643
+ return this.#extensionUiController.showHookEditor(title, prefill, dialogOptions, editorOptions);
2644
+ }
2645
+
2646
+ hideHookEditor(): void {
2647
+ this.#extensionUiController.hideHookEditor();
2648
+ }
2649
+
2650
+ showHookNotify(message: string, type?: "info" | "warning" | "error"): void {
2651
+ this.#extensionUiController.showHookNotify(message, type);
2652
+ }
2653
+
2654
+ showHookCustom<T>(
2655
+ factory: (
2656
+ tui: TUI,
2657
+ theme: Theme,
2658
+ keybindings: KeybindingsManager,
2659
+ done: (result: T) => void,
2660
+ ) => (Component & { dispose?(): void }) | Promise<Component & { dispose?(): void }>,
2661
+ options?: { overlay?: boolean },
2662
+ ): Promise<T> {
2663
+ return this.#extensionUiController.showHookCustom(factory, options);
2664
+ }
2665
+
2666
+ showExtensionError(extensionPath: string, error: string): void {
2667
+ this.#extensionUiController.showExtensionError(extensionPath, error);
2668
+ }
2669
+
2670
+ showToolError(toolName: string, error: string): void {
2671
+ this.#extensionUiController.showToolError(toolName, error);
2672
+ }
2673
+
2674
+ #subscribeToAgent(): void {
2675
+ this.#eventController.subscribeToAgent();
2676
+ }
2677
+ }