@oh-my-pi-zen/pi-coding-agent 16.3.6-zen.1

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 (2454) hide show
  1. package/CHANGELOG.md +13088 -0
  2. package/README.md +35 -0
  3. package/dist/cli.js +22542 -0
  4. package/dist/types/advisor/__tests__/advisor.test.d.ts +1 -0
  5. package/dist/types/advisor/__tests__/config.test.d.ts +1 -0
  6. package/dist/types/advisor/__tests__/emission-guard.test.d.ts +1 -0
  7. package/dist/types/advisor/advise-tool.d.ts +106 -0
  8. package/dist/types/advisor/config.d.ts +90 -0
  9. package/dist/types/advisor/emission-guard.d.ts +73 -0
  10. package/dist/types/advisor/index.d.ts +6 -0
  11. package/dist/types/advisor/runtime.d.ts +76 -0
  12. package/dist/types/advisor/transcript-recorder.d.ts +63 -0
  13. package/dist/types/advisor/watchdog.d.ts +38 -0
  14. package/dist/types/async/index.d.ts +1 -0
  15. package/dist/types/async/job-manager.d.ts +121 -0
  16. package/dist/types/auto-thinking/classifier.d.ts +37 -0
  17. package/dist/types/autolearn/controller.d.ts +25 -0
  18. package/dist/types/autolearn/managed-skills.d.ts +45 -0
  19. package/dist/types/autoresearch/dashboard.d.ts +4 -0
  20. package/dist/types/autoresearch/git.d.ts +36 -0
  21. package/dist/types/autoresearch/helpers.d.ts +24 -0
  22. package/dist/types/autoresearch/index.d.ts +2 -0
  23. package/dist/types/autoresearch/state.d.ts +17 -0
  24. package/dist/types/autoresearch/storage.d.ts +142 -0
  25. package/dist/types/autoresearch/tools/init-experiment.d.ts +27 -0
  26. package/dist/types/autoresearch/tools/log-experiment.d.ts +21 -0
  27. package/dist/types/autoresearch/tools/run-experiment.d.ts +7 -0
  28. package/dist/types/autoresearch/tools/update-notes.d.ts +11 -0
  29. package/dist/types/autoresearch/types.d.ts +154 -0
  30. package/dist/types/capability/context-file.d.ts +17 -0
  31. package/dist/types/capability/extension-module.d.ts +15 -0
  32. package/dist/types/capability/extension.d.ts +28 -0
  33. package/dist/types/capability/fs.d.ts +20 -0
  34. package/dist/types/capability/hook.d.ts +19 -0
  35. package/dist/types/capability/index.d.ts +80 -0
  36. package/dist/types/capability/instruction.d.ts +17 -0
  37. package/dist/types/capability/mcp.d.ts +47 -0
  38. package/dist/types/capability/prompt.d.ts +15 -0
  39. package/dist/types/capability/rule-buckets.d.ts +30 -0
  40. package/dist/types/capability/rule.d.ts +73 -0
  41. package/dist/types/capability/settings.d.ts +15 -0
  42. package/dist/types/capability/skill.d.ts +43 -0
  43. package/dist/types/capability/slash-command.d.ts +17 -0
  44. package/dist/types/capability/ssh.d.ts +23 -0
  45. package/dist/types/capability/system-prompt.d.ts +15 -0
  46. package/dist/types/capability/tool.d.ts +19 -0
  47. package/dist/types/capability/types.d.ts +154 -0
  48. package/dist/types/cli/agents-cli.d.ts +12 -0
  49. package/dist/types/cli/args.d.ts +77 -0
  50. package/dist/types/cli/auth-broker-cli.d.ts +25 -0
  51. package/dist/types/cli/auth-gateway-cli.d.ts +26 -0
  52. package/dist/types/cli/bench-cli.d.ts +85 -0
  53. package/dist/types/cli/classify-install-target.d.ts +12 -0
  54. package/dist/types/cli/claude-trace-cli.d.ts +54 -0
  55. package/dist/types/cli/commands/init-xdg.d.ts +1 -0
  56. package/dist/types/cli/completion-gen.d.ts +80 -0
  57. package/dist/types/cli/config-cli.d.ts +22 -0
  58. package/dist/types/cli/dry-balance-cli.d.ts +113 -0
  59. package/dist/types/cli/extension-flags.d.ts +36 -0
  60. package/dist/types/cli/file-processor.d.ts +11 -0
  61. package/dist/types/cli/flag-tables.d.ts +144 -0
  62. package/dist/types/cli/gallery-cli.d.ts +49 -0
  63. package/dist/types/cli/gallery-fixtures/agentic.d.ts +2 -0
  64. package/dist/types/cli/gallery-fixtures/codeintel.d.ts +3 -0
  65. package/dist/types/cli/gallery-fixtures/edit.d.ts +3 -0
  66. package/dist/types/cli/gallery-fixtures/fs.d.ts +2 -0
  67. package/dist/types/cli/gallery-fixtures/index.d.ts +4 -0
  68. package/dist/types/cli/gallery-fixtures/interaction.d.ts +3 -0
  69. package/dist/types/cli/gallery-fixtures/memory.d.ts +2 -0
  70. package/dist/types/cli/gallery-fixtures/misc.d.ts +3 -0
  71. package/dist/types/cli/gallery-fixtures/search.d.ts +3 -0
  72. package/dist/types/cli/gallery-fixtures/shell.d.ts +3 -0
  73. package/dist/types/cli/gallery-fixtures/types.d.ts +55 -0
  74. package/dist/types/cli/gallery-fixtures/web.d.ts +2 -0
  75. package/dist/types/cli/gallery-screenshot.d.ts +35 -0
  76. package/dist/types/cli/gc-cli.d.ts +58 -0
  77. package/dist/types/cli/grep-cli.d.ts +17 -0
  78. package/dist/types/cli/grievances-cli.d.ts +37 -0
  79. package/dist/types/cli/initial-message.d.ts +17 -0
  80. package/dist/types/cli/models-cli.d.ts +49 -0
  81. package/dist/types/cli/plugin-cli.d.ts +32 -0
  82. package/dist/types/cli/profile-alias.d.ts +29 -0
  83. package/dist/types/cli/profile-bootstrap.d.ts +55 -0
  84. package/dist/types/cli/read-cli.d.ts +4 -0
  85. package/dist/types/cli/session-picker.d.ts +11 -0
  86. package/dist/types/cli/setup-cli.d.ts +24 -0
  87. package/dist/types/cli/setup-model-picker.d.ts +14 -0
  88. package/dist/types/cli/shell-cli.d.ts +8 -0
  89. package/dist/types/cli/ssh-cli.d.ts +21 -0
  90. package/dist/types/cli/startup-cwd.d.ts +2 -0
  91. package/dist/types/cli/stats-cli.d.ts +17 -0
  92. package/dist/types/cli/tiny-models-cli.d.ts +11 -0
  93. package/dist/types/cli/ttsr-cli.d.ts +39 -0
  94. package/dist/types/cli/update-cli.d.ts +106 -0
  95. package/dist/types/cli/update-cli.test.d.ts +1 -0
  96. package/dist/types/cli/usage-cli.d.ts +95 -0
  97. package/dist/types/cli/web-search-cli.d.ts +20 -0
  98. package/dist/types/cli/worktree-cli.d.ts +26 -0
  99. package/dist/types/cli-commands.d.ts +33 -0
  100. package/dist/types/cli.d.ts +3 -0
  101. package/dist/types/collab/crypto.d.ts +7 -0
  102. package/dist/types/collab/display-name.d.ts +3 -0
  103. package/dist/types/collab/guest.d.ts +52 -0
  104. package/dist/types/collab/host.d.ts +43 -0
  105. package/dist/types/collab/protocol.d.ts +143 -0
  106. package/dist/types/collab/relay-client.d.ts +22 -0
  107. package/dist/types/collab/replication-shrink.d.ts +39 -0
  108. package/dist/types/commands/acp.d.ts +12 -0
  109. package/dist/types/commands/agents.d.ts +34 -0
  110. package/dist/types/commands/auth-broker.d.ts +54 -0
  111. package/dist/types/commands/auth-gateway.d.ts +35 -0
  112. package/dist/types/commands/bench.d.ts +37 -0
  113. package/dist/types/commands/commit.d.ts +27 -0
  114. package/dist/types/commands/complete.d.ts +6 -0
  115. package/dist/types/commands/completions.d.ts +13 -0
  116. package/dist/types/commands/config.d.ts +30 -0
  117. package/dist/types/commands/dry-balance.d.ts +31 -0
  118. package/dist/types/commands/gallery.d.ts +47 -0
  119. package/dist/types/commands/gc.d.ts +37 -0
  120. package/dist/types/commands/grep.d.ts +42 -0
  121. package/dist/types/commands/grievances.d.ts +40 -0
  122. package/dist/types/commands/install.d.ts +51 -0
  123. package/dist/types/commands/join.d.ts +12 -0
  124. package/dist/types/commands/launch.d.ts +148 -0
  125. package/dist/types/commands/models.d.ts +33 -0
  126. package/dist/types/commands/plugin.d.ts +52 -0
  127. package/dist/types/commands/read.d.ts +15 -0
  128. package/dist/types/commands/say.d.ts +24 -0
  129. package/dist/types/commands/setup.d.ts +34 -0
  130. package/dist/types/commands/shell.d.ts +21 -0
  131. package/dist/types/commands/ssh.d.ts +48 -0
  132. package/dist/types/commands/stats.d.ts +25 -0
  133. package/dist/types/commands/tiny-models.d.ts +22 -0
  134. package/dist/types/commands/token.d.ts +34 -0
  135. package/dist/types/commands/ttsr.d.ts +57 -0
  136. package/dist/types/commands/update.d.ts +25 -0
  137. package/dist/types/commands/usage.d.ts +34 -0
  138. package/dist/types/commands/web-search.d.ts +33 -0
  139. package/dist/types/commands/worktree.d.ts +31 -0
  140. package/dist/types/commit/agentic/agent.d.ts +31 -0
  141. package/dist/types/commit/agentic/fallback.d.ts +5 -0
  142. package/dist/types/commit/agentic/index.d.ts +2 -0
  143. package/dist/types/commit/agentic/state.d.ts +58 -0
  144. package/dist/types/commit/agentic/tools/analyze-file.d.ts +18 -0
  145. package/dist/types/commit/agentic/tools/git-file-diff.d.ts +9 -0
  146. package/dist/types/commit/agentic/tools/git-hunk.d.ts +8 -0
  147. package/dist/types/commit/agentic/tools/git-overview.d.ts +8 -0
  148. package/dist/types/commit/agentic/tools/index.d.ts +16 -0
  149. package/dist/types/commit/agentic/tools/propose-changelog.d.ts +27 -0
  150. package/dist/types/commit/agentic/tools/propose-commit.d.ts +15 -0
  151. package/dist/types/commit/agentic/tools/recent-commits.d.ts +6 -0
  152. package/dist/types/commit/agentic/tools/schemas.d.ts +6 -0
  153. package/dist/types/commit/agentic/tools/split-commit.d.ts +32 -0
  154. package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
  155. package/dist/types/commit/agentic/trivial.d.ts +7 -0
  156. package/dist/types/commit/agentic/validation.d.ts +20 -0
  157. package/dist/types/commit/analysis/conventional.d.ts +22 -0
  158. package/dist/types/commit/analysis/index.d.ts +4 -0
  159. package/dist/types/commit/analysis/scope.d.ts +6 -0
  160. package/dist/types/commit/analysis/summary.d.ts +19 -0
  161. package/dist/types/commit/analysis/validation.d.ts +8 -0
  162. package/dist/types/commit/changelog/detect.d.ts +2 -0
  163. package/dist/types/commit/changelog/generate.d.ts +29 -0
  164. package/dist/types/commit/changelog/index.d.ts +30 -0
  165. package/dist/types/commit/changelog/parse.d.ts +2 -0
  166. package/dist/types/commit/cli.d.ts +3 -0
  167. package/dist/types/commit/git/diff.d.ts +5 -0
  168. package/dist/types/commit/index.d.ts +4 -0
  169. package/dist/types/commit/map-reduce/index.d.ts +28 -0
  170. package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
  171. package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
  172. package/dist/types/commit/map-reduce/utils.d.ts +2 -0
  173. package/dist/types/commit/message.d.ts +2 -0
  174. package/dist/types/commit/model-selection.d.ts +26 -0
  175. package/dist/types/commit/pipeline.d.ts +5 -0
  176. package/dist/types/commit/shared-llm.d.ts +27 -0
  177. package/dist/types/commit/types.d.ts +78 -0
  178. package/dist/types/commit/utils/exclusions.d.ts +4 -0
  179. package/dist/types/commit/utils.d.ts +20 -0
  180. package/dist/types/config/api-key-resolver.d.ts +43 -0
  181. package/dist/types/config/append-only-context-mode.d.ts +9 -0
  182. package/dist/types/config/config-file.d.ts +62 -0
  183. package/dist/types/config/file-lock.d.ts +29 -0
  184. package/dist/types/config/inline-tool-descriptors-mode.d.ts +12 -0
  185. package/dist/types/config/keybindings.d.ts +362 -0
  186. package/dist/types/config/model-discovery.d.ts +68 -0
  187. package/dist/types/config/model-registry.d.ts +251 -0
  188. package/dist/types/config/model-resolver.d.ts +300 -0
  189. package/dist/types/config/model-roles.d.ts +29 -0
  190. package/dist/types/config/models-config-schema.d.ts +697 -0
  191. package/dist/types/config/models-config.d.ts +436 -0
  192. package/dist/types/config/prompt-templates.d.ts +32 -0
  193. package/dist/types/config/provider-globals.d.ts +7 -0
  194. package/dist/types/config/resolve-config-value.d.ts +17 -0
  195. package/dist/types/config/service-tier.d.ts +49 -0
  196. package/dist/types/config/settings-schema.d.ts +5668 -0
  197. package/dist/types/config/settings.d.ts +181 -0
  198. package/dist/types/config.d.ts +92 -0
  199. package/dist/types/cursor.d.ts +22 -0
  200. package/dist/types/dap/client.d.ts +46 -0
  201. package/dist/types/dap/config.d.ts +19 -0
  202. package/dist/types/dap/index.d.ts +4 -0
  203. package/dist/types/dap/session.d.ts +108 -0
  204. package/dist/types/dap/types.d.ts +534 -0
  205. package/dist/types/debug/index.d.ts +15 -0
  206. package/dist/types/debug/log-formatting.d.ts +4 -0
  207. package/dist/types/debug/log-viewer.d.ts +69 -0
  208. package/dist/types/debug/profiler.d.ts +24 -0
  209. package/dist/types/debug/protocol-probe.d.ts +38 -0
  210. package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
  211. package/dist/types/debug/raw-sse.d.ts +19 -0
  212. package/dist/types/debug/remote-debugger.d.ts +45 -0
  213. package/dist/types/debug/report-bundle.d.ts +58 -0
  214. package/dist/types/debug/system-info.d.ts +26 -0
  215. package/dist/types/debug/terminal-info.d.ts +33 -0
  216. package/dist/types/discovery/agents-md.d.ts +1 -0
  217. package/dist/types/discovery/agents.d.ts +12 -0
  218. package/dist/types/discovery/at-imports.d.ts +15 -0
  219. package/dist/types/discovery/builtin-defaults.d.ts +1 -0
  220. package/dist/types/discovery/builtin-rules/index.d.ts +7 -0
  221. package/dist/types/discovery/builtin.d.ts +1 -0
  222. package/dist/types/discovery/claude-plugins.d.ts +1 -0
  223. package/dist/types/discovery/claude.d.ts +1 -0
  224. package/dist/types/discovery/cline.d.ts +1 -0
  225. package/dist/types/discovery/codex.d.ts +1 -0
  226. package/dist/types/discovery/cursor.d.ts +16 -0
  227. package/dist/types/discovery/gemini.d.ts +1 -0
  228. package/dist/types/discovery/github.d.ts +1 -0
  229. package/dist/types/discovery/helpers.d.ts +278 -0
  230. package/dist/types/discovery/index.d.ts +53 -0
  231. package/dist/types/discovery/mcp-json.d.ts +1 -0
  232. package/dist/types/discovery/omp-extension-roots.d.ts +43 -0
  233. package/dist/types/discovery/omp-plugins.d.ts +1 -0
  234. package/dist/types/discovery/opencode.d.ts +1 -0
  235. package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
  236. package/dist/types/discovery/ssh.d.ts +1 -0
  237. package/dist/types/discovery/substitute-plugin-root.d.ts +1 -0
  238. package/dist/types/discovery/vscode.d.ts +1 -0
  239. package/dist/types/discovery/windsurf.d.ts +13 -0
  240. package/dist/types/edit/apply-patch/index.d.ts +35 -0
  241. package/dist/types/edit/apply-patch/parser.d.ts +34 -0
  242. package/dist/types/edit/diff.d.ts +60 -0
  243. package/dist/types/edit/file-snapshot-store.d.ts +74 -0
  244. package/dist/types/edit/hashline/block-resolver.d.ts +9 -0
  245. package/dist/types/edit/hashline/diff.d.ts +29 -0
  246. package/dist/types/edit/hashline/execute.d.ts +28 -0
  247. package/dist/types/edit/hashline/filesystem.d.ts +43 -0
  248. package/dist/types/edit/hashline/index.d.ts +5 -0
  249. package/dist/types/edit/hashline/noop-loop-guard.d.ts +72 -0
  250. package/dist/types/edit/hashline/params.d.ts +4 -0
  251. package/dist/types/edit/index.d.ts +83 -0
  252. package/dist/types/edit/modes/apply-patch.d.ts +23 -0
  253. package/dist/types/edit/modes/patch.d.ts +101 -0
  254. package/dist/types/edit/modes/replace.d.ts +141 -0
  255. package/dist/types/edit/normalize.d.ts +31 -0
  256. package/dist/types/edit/notebook.d.ts +23 -0
  257. package/dist/types/edit/read-file.d.ts +2 -0
  258. package/dist/types/edit/renderer.d.ts +118 -0
  259. package/dist/types/edit/snapshot-details.d.ts +33 -0
  260. package/dist/types/edit/streaming.d.ts +105 -0
  261. package/dist/types/eval/__tests__/agent-bridge.test.d.ts +1 -0
  262. package/dist/types/eval/__tests__/bridge-timeout.test.d.ts +1 -0
  263. package/dist/types/eval/__tests__/budget-bridge.test.d.ts +1 -0
  264. package/dist/types/eval/__tests__/completion-bridge.test.d.ts +1 -0
  265. package/dist/types/eval/__tests__/helpers-local-roots.test.d.ts +1 -0
  266. package/dist/types/eval/__tests__/idle-timeout.test.d.ts +1 -0
  267. package/dist/types/eval/__tests__/js-context-manager.test.d.ts +1 -0
  268. package/dist/types/eval/__tests__/julia-prelude.test.d.ts +1 -0
  269. package/dist/types/eval/__tests__/kernel-spawn.test.d.ts +1 -0
  270. package/dist/types/eval/__tests__/prelude-agent.test.d.ts +1 -0
  271. package/dist/types/eval/agent-bridge.d.ts +48 -0
  272. package/dist/types/eval/backend-helpers.d.ts +23 -0
  273. package/dist/types/eval/backend.d.ts +60 -0
  274. package/dist/types/eval/bridge-timeout.d.ts +27 -0
  275. package/dist/types/eval/budget-bridge.d.ts +29 -0
  276. package/dist/types/eval/completion-bridge.d.ts +25 -0
  277. package/dist/types/eval/concurrency-bridge.d.ts +26 -0
  278. package/dist/types/eval/executor-base.d.ts +118 -0
  279. package/dist/types/eval/idle-timeout.d.ts +26 -0
  280. package/dist/types/eval/index.d.ts +6 -0
  281. package/dist/types/eval/jl/executor.d.ts +44 -0
  282. package/dist/types/eval/jl/index.d.ts +11 -0
  283. package/dist/types/eval/jl/kernel.d.ts +28 -0
  284. package/dist/types/eval/jl/prelude.d.ts +1 -0
  285. package/dist/types/eval/jl/runtime.d.ts +22 -0
  286. package/dist/types/eval/js/context-manager.d.ts +40 -0
  287. package/dist/types/eval/js/executor.d.ts +38 -0
  288. package/dist/types/eval/js/index.d.ts +11 -0
  289. package/dist/types/eval/js/shared/helpers.d.ts +32 -0
  290. package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
  291. package/dist/types/eval/js/shared/local-module-loader.d.ts +16 -0
  292. package/dist/types/eval/js/shared/prelude.d.ts +1 -0
  293. package/dist/types/eval/js/shared/rewrite-imports.d.ts +25 -0
  294. package/dist/types/eval/js/shared/runtime.d.ts +59 -0
  295. package/dist/types/eval/js/shared/types.d.ts +24 -0
  296. package/dist/types/eval/js/tool-bridge.d.ts +20 -0
  297. package/dist/types/eval/js/worker-core.d.ts +6 -0
  298. package/dist/types/eval/js/worker-entry.d.ts +1 -0
  299. package/dist/types/eval/js/worker-protocol.d.ts +83 -0
  300. package/dist/types/eval/kernel-base.d.ts +105 -0
  301. package/dist/types/eval/py/__tests__/prelude.test.d.ts +1 -0
  302. package/dist/types/eval/py/__tests__/runner-shell-output.test.d.ts +1 -0
  303. package/dist/types/eval/py/display.d.ts +25 -0
  304. package/dist/types/eval/py/executor.d.ts +107 -0
  305. package/dist/types/eval/py/index.d.ts +11 -0
  306. package/dist/types/eval/py/kernel.d.ts +17 -0
  307. package/dist/types/eval/py/prelude.d.ts +1 -0
  308. package/dist/types/eval/py/runtime.d.ts +40 -0
  309. package/dist/types/eval/py/spawn-options.d.ts +58 -0
  310. package/dist/types/eval/py/tool-bridge.d.ts +16 -0
  311. package/dist/types/eval/rb/executor.d.ts +77 -0
  312. package/dist/types/eval/rb/index.d.ts +11 -0
  313. package/dist/types/eval/rb/kernel.d.ts +31 -0
  314. package/dist/types/eval/rb/prelude.d.ts +1 -0
  315. package/dist/types/eval/rb/runtime.d.ts +23 -0
  316. package/dist/types/eval/runtime-env.d.ts +24 -0
  317. package/dist/types/eval/session-id.d.ts +3 -0
  318. package/dist/types/eval/types.d.ts +52 -0
  319. package/dist/types/exa/index.d.ts +2 -0
  320. package/dist/types/exa/mcp-client.d.ts +53 -0
  321. package/dist/types/exa/types.d.ts +72 -0
  322. package/dist/types/exec/bash-executor.d.ts +45 -0
  323. package/dist/types/exec/exec.d.ts +25 -0
  324. package/dist/types/exec/non-interactive-env.d.ts +3 -0
  325. package/dist/types/export/custom-share.d.ts +19 -0
  326. package/dist/types/export/html/index.d.ts +78 -0
  327. package/dist/types/export/html/web-palette.d.ts +117 -0
  328. package/dist/types/export/share.d.ts +55 -0
  329. package/dist/types/export/ttsr.d.ts +67 -0
  330. package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
  331. package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
  332. package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
  333. package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
  334. package/dist/types/extensibility/custom-commands/types.d.ts +112 -0
  335. package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
  336. package/dist/types/extensibility/custom-tools/loader.d.ts +89 -0
  337. package/dist/types/extensibility/custom-tools/types.d.ts +244 -0
  338. package/dist/types/extensibility/custom-tools/wrapper.d.ts +23 -0
  339. package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
  340. package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
  341. package/dist/types/extensibility/extensions/index.d.ts +8 -0
  342. package/dist/types/extensibility/extensions/loader.d.ts +59 -0
  343. package/dist/types/extensibility/extensions/model-api.d.ts +17 -0
  344. package/dist/types/extensibility/extensions/runner.d.ts +161 -0
  345. package/dist/types/extensibility/extensions/types.d.ts +962 -0
  346. package/dist/types/extensibility/extensions/wrapper.d.ts +54 -0
  347. package/dist/types/extensibility/hooks/index.d.ts +6 -0
  348. package/dist/types/extensibility/hooks/loader.d.ts +65 -0
  349. package/dist/types/extensibility/hooks/runner.d.ts +126 -0
  350. package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
  351. package/dist/types/extensibility/hooks/types.d.ts +442 -0
  352. package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +35 -0
  353. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +115 -0
  354. package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
  355. package/dist/types/extensibility/plugins/git-url.d.ts +44 -0
  356. package/dist/types/extensibility/plugins/index.d.ts +7 -0
  357. package/dist/types/extensibility/plugins/installer.d.ts +5 -0
  358. package/dist/types/extensibility/plugins/legacy-pi-bundled-keys.d.ts +10 -0
  359. package/dist/types/extensibility/plugins/legacy-pi-bundled-registry.d.ts +10 -0
  360. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +79 -0
  361. package/dist/types/extensibility/plugins/loader.d.ts +59 -0
  362. package/dist/types/extensibility/plugins/manager.d.ts +76 -0
  363. package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
  364. package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
  365. package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
  366. package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
  367. package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
  368. package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
  369. package/dist/types/extensibility/plugins/marketplace/types.d.ts +131 -0
  370. package/dist/types/extensibility/plugins/marketplace-auto-update.d.ts +8 -0
  371. package/dist/types/extensibility/plugins/parser.d.ts +53 -0
  372. package/dist/types/extensibility/plugins/runtime-config.d.ts +3 -0
  373. package/dist/types/extensibility/plugins/types.d.ts +149 -0
  374. package/dist/types/extensibility/session-handler-types.d.ts +23 -0
  375. package/dist/types/extensibility/shared-events.d.ts +308 -0
  376. package/dist/types/extensibility/skills.d.ts +97 -0
  377. package/dist/types/extensibility/slash-commands.d.ts +38 -0
  378. package/dist/types/extensibility/tool-event-input.d.ts +9 -0
  379. package/dist/types/extensibility/tool-proxy.d.ts +4 -0
  380. package/dist/types/extensibility/typebox.d.ts +177 -0
  381. package/dist/types/extensibility/utils.d.ts +24 -0
  382. package/dist/types/goals/guided-setup.d.ts +18 -0
  383. package/dist/types/goals/index.d.ts +3 -0
  384. package/dist/types/goals/runtime.d.ts +69 -0
  385. package/dist/types/goals/state.d.ts +35 -0
  386. package/dist/types/goals/tools/goal-tool.d.ts +53 -0
  387. package/dist/types/hindsight/backend.d.ts +13 -0
  388. package/dist/types/hindsight/bank.d.ts +62 -0
  389. package/dist/types/hindsight/client.d.ts +228 -0
  390. package/dist/types/hindsight/client.test.d.ts +1 -0
  391. package/dist/types/hindsight/config.d.ts +51 -0
  392. package/dist/types/hindsight/content.d.ts +73 -0
  393. package/dist/types/hindsight/index.d.ts +8 -0
  394. package/dist/types/hindsight/mental-models.d.ts +134 -0
  395. package/dist/types/hindsight/state.d.ts +105 -0
  396. package/dist/types/hindsight/transcript.d.ts +28 -0
  397. package/dist/types/index.d.ts +43 -0
  398. package/dist/types/internal-urls/__tests__/ssh-protocol.test.d.ts +1 -0
  399. package/dist/types/internal-urls/agent-protocol.d.ts +13 -0
  400. package/dist/types/internal-urls/artifact-protocol.d.ts +15 -0
  401. package/dist/types/internal-urls/docs-index.d.ts +19 -0
  402. package/dist/types/internal-urls/filesystem-resource.d.ts +9 -0
  403. package/dist/types/internal-urls/history-protocol.d.ts +14 -0
  404. package/dist/types/internal-urls/index.d.ts +25 -0
  405. package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
  406. package/dist/types/internal-urls/json-query.d.ts +30 -0
  407. package/dist/types/internal-urls/local-protocol.d.ts +79 -0
  408. package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
  409. package/dist/types/internal-urls/memory-protocol.d.ts +24 -0
  410. package/dist/types/internal-urls/omp-protocol.d.ts +13 -0
  411. package/dist/types/internal-urls/parse.d.ts +19 -0
  412. package/dist/types/internal-urls/registry-helpers.d.ts +12 -0
  413. package/dist/types/internal-urls/router.d.ts +21 -0
  414. package/dist/types/internal-urls/rule-protocol.d.ts +7 -0
  415. package/dist/types/internal-urls/skill-protocol.d.ts +14 -0
  416. package/dist/types/internal-urls/ssh-protocol.d.ts +10 -0
  417. package/dist/types/internal-urls/types.d.ts +175 -0
  418. package/dist/types/internal-urls/vault-protocol.d.ts +93 -0
  419. package/dist/types/irc/bus.d.ts +86 -0
  420. package/dist/types/jsonrpc/message-framing.d.ts +35 -0
  421. package/dist/types/lib/xai-http.d.ts +40 -0
  422. package/dist/types/lsp/client.d.ts +84 -0
  423. package/dist/types/lsp/clients/biome-client.d.ts +16 -0
  424. package/dist/types/lsp/clients/index.d.ts +19 -0
  425. package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
  426. package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
  427. package/dist/types/lsp/config.d.ts +69 -0
  428. package/dist/types/lsp/diagnostics-ledger.d.ts +10 -0
  429. package/dist/types/lsp/edits.d.ts +34 -0
  430. package/dist/types/lsp/format-options.d.ts +32 -0
  431. package/dist/types/lsp/index.d.ts +120 -0
  432. package/dist/types/lsp/lspmux.d.ts +58 -0
  433. package/dist/types/lsp/render.d.ts +32 -0
  434. package/dist/types/lsp/startup-events.d.ts +11 -0
  435. package/dist/types/lsp/types.d.ts +300 -0
  436. package/dist/types/lsp/utils.d.ts +116 -0
  437. package/dist/types/main.d.ts +70 -0
  438. package/dist/types/markit/converters/docx.d.ts +6 -0
  439. package/dist/types/markit/converters/epub.d.ts +15 -0
  440. package/dist/types/markit/converters/pdf/columns.d.ts +35 -0
  441. package/dist/types/markit/converters/pdf/extract.d.ts +10 -0
  442. package/dist/types/markit/converters/pdf/grid.d.ts +25 -0
  443. package/dist/types/markit/converters/pdf/headers.d.ts +24 -0
  444. package/dist/types/markit/converters/pdf/index.d.ts +6 -0
  445. package/dist/types/markit/converters/pdf/render.d.ts +24 -0
  446. package/dist/types/markit/converters/pdf/types.d.ts +75 -0
  447. package/dist/types/markit/converters/pptx.d.ts +57 -0
  448. package/dist/types/markit/converters/xlsx.d.ts +25 -0
  449. package/dist/types/markit/index.d.ts +2 -0
  450. package/dist/types/markit/registry.d.ts +16 -0
  451. package/dist/types/markit/types.d.ts +30 -0
  452. package/dist/types/mcp/client.d.ts +83 -0
  453. package/dist/types/mcp/config-writer.d.ts +101 -0
  454. package/dist/types/mcp/config.d.ts +75 -0
  455. package/dist/types/mcp/index.d.ts +18 -0
  456. package/dist/types/mcp/json-rpc.d.ts +32 -0
  457. package/dist/types/mcp/loader.d.ts +44 -0
  458. package/dist/types/mcp/manager.d.ts +215 -0
  459. package/dist/types/mcp/oauth-credentials.d.ts +17 -0
  460. package/dist/types/mcp/oauth-discovery.d.ts +65 -0
  461. package/dist/types/mcp/oauth-flow.d.ts +145 -0
  462. package/dist/types/mcp/render.d.ts +25 -0
  463. package/dist/types/mcp/smithery-auth.d.ts +16 -0
  464. package/dist/types/mcp/smithery-connect.d.ts +38 -0
  465. package/dist/types/mcp/smithery-registry.d.ts +52 -0
  466. package/dist/types/mcp/smithery-registry.test.d.ts +1 -0
  467. package/dist/types/mcp/startup-events.d.ts +28 -0
  468. package/dist/types/mcp/timeout.d.ts +9 -0
  469. package/dist/types/mcp/tool-bridge.d.ts +95 -0
  470. package/dist/types/mcp/tool-cache.d.ts +8 -0
  471. package/dist/types/mcp/transports/http.d.ts +45 -0
  472. package/dist/types/mcp/transports/index.d.ts +6 -0
  473. package/dist/types/mcp/transports/sse.d.ts +20 -0
  474. package/dist/types/mcp/transports/stdio.d.ts +108 -0
  475. package/dist/types/mcp/transports/stdio.test.d.ts +1 -0
  476. package/dist/types/mcp/types.d.ts +340 -0
  477. package/dist/types/memories/index.d.ts +54 -0
  478. package/dist/types/memories/storage.d.ts +110 -0
  479. package/dist/types/memory-backend/index.d.ts +7 -0
  480. package/dist/types/memory-backend/local-backend.d.ts +10 -0
  481. package/dist/types/memory-backend/off-backend.d.ts +7 -0
  482. package/dist/types/memory-backend/resolve.d.ts +16 -0
  483. package/dist/types/memory-backend/runtime.d.ts +4 -0
  484. package/dist/types/memory-backend/types.d.ts +132 -0
  485. package/dist/types/mnemopi/backend.d.ts +4 -0
  486. package/dist/types/mnemopi/config.d.ts +60 -0
  487. package/dist/types/mnemopi/embed-client.d.ts +53 -0
  488. package/dist/types/mnemopi/embed-protocol.d.ts +52 -0
  489. package/dist/types/mnemopi/embed-worker.d.ts +12 -0
  490. package/dist/types/mnemopi/index.d.ts +3 -0
  491. package/dist/types/mnemopi/state.d.ts +130 -0
  492. package/dist/types/modes/acp/acp-agent.d.ts +60 -0
  493. package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
  494. package/dist/types/modes/acp/acp-event-mapper.d.ts +33 -0
  495. package/dist/types/modes/acp/acp-mode.d.ts +5 -0
  496. package/dist/types/modes/acp/index.d.ts +2 -0
  497. package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
  498. package/dist/types/modes/components/__tests__/move-overlay.test.d.ts +1 -0
  499. package/dist/types/modes/components/__tests__/skill-message.test.d.ts +1 -0
  500. package/dist/types/modes/components/advisor-config.d.ts +59 -0
  501. package/dist/types/modes/components/advisor-message.d.ts +11 -0
  502. package/dist/types/modes/components/agent-dashboard.d.ts +22 -0
  503. package/dist/types/modes/components/agent-hub.d.ts +77 -0
  504. package/dist/types/modes/components/agent-transcript-viewer.d.ts +40 -0
  505. package/dist/types/modes/components/assistant-message.d.ts +58 -0
  506. package/dist/types/modes/components/background-tan-message.d.ts +9 -0
  507. package/dist/types/modes/components/bash-execution.d.ts +35 -0
  508. package/dist/types/modes/components/bordered-loader.d.ts +11 -0
  509. package/dist/types/modes/components/btw-panel.d.ts +19 -0
  510. package/dist/types/modes/components/cache-invalidation-marker.d.ts +52 -0
  511. package/dist/types/modes/components/chat-block.d.ts +64 -0
  512. package/dist/types/modes/components/chat-transcript-builder.d.ts +45 -0
  513. package/dist/types/modes/components/collab-prompt-message.d.ts +10 -0
  514. package/dist/types/modes/components/compaction-summary-message.d.ts +46 -0
  515. package/dist/types/modes/components/copy-selector.d.ts +22 -0
  516. package/dist/types/modes/components/countdown-timer.d.ts +14 -0
  517. package/dist/types/modes/components/custom-editor.d.ts +163 -0
  518. package/dist/types/modes/components/custom-editor.test.d.ts +1 -0
  519. package/dist/types/modes/components/custom-message.d.ts +15 -0
  520. package/dist/types/modes/components/diff.d.ts +11 -0
  521. package/dist/types/modes/components/dynamic-border.d.ts +14 -0
  522. package/dist/types/modes/components/error-banner.d.ts +11 -0
  523. package/dist/types/modes/components/eval-execution.d.ts +29 -0
  524. package/dist/types/modes/components/execution-shared.d.ts +46 -0
  525. package/dist/types/modes/components/extensions/extension-dashboard.d.ts +43 -0
  526. package/dist/types/modes/components/extensions/extension-list.d.ts +52 -0
  527. package/dist/types/modes/components/extensions/index.d.ts +8 -0
  528. package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
  529. package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
  530. package/dist/types/modes/components/extensions/types.d.ts +147 -0
  531. package/dist/types/modes/components/footer.d.ts +30 -0
  532. package/dist/types/modes/components/history-search.d.ts +7 -0
  533. package/dist/types/modes/components/hook-editor.d.ts +24 -0
  534. package/dist/types/modes/components/hook-input.d.ts +19 -0
  535. package/dist/types/modes/components/hook-message.d.ts +15 -0
  536. package/dist/types/modes/components/hook-selector.d.ts +68 -0
  537. package/dist/types/modes/components/index.d.ts +38 -0
  538. package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
  539. package/dist/types/modes/components/late-diagnostics-message.d.ts +20 -0
  540. package/dist/types/modes/components/login-dialog.d.ts +40 -0
  541. package/dist/types/modes/components/logout-account-selector.d.ts +8 -0
  542. package/dist/types/modes/components/mcp-add-wizard.d.ts +38 -0
  543. package/dist/types/modes/components/message-frame.d.ts +44 -0
  544. package/dist/types/modes/components/model-selector.d.ts +36 -0
  545. package/dist/types/modes/components/move-overlay.d.ts +23 -0
  546. package/dist/types/modes/components/oauth-selector.d.ts +23 -0
  547. package/dist/types/modes/components/omfg-panel.d.ts +19 -0
  548. package/dist/types/modes/components/overlay-box.d.ts +17 -0
  549. package/dist/types/modes/components/plan-review-overlay.d.ts +61 -0
  550. package/dist/types/modes/components/plan-toc.d.ts +41 -0
  551. package/dist/types/modes/components/plugin-selector.d.ts +27 -0
  552. package/dist/types/modes/components/plugin-settings.d.ts +103 -0
  553. package/dist/types/modes/components/queue-mode-selector.d.ts +10 -0
  554. package/dist/types/modes/components/read-tool-group.d.ts +38 -0
  555. package/dist/types/modes/components/reset-usage-selector.d.ts +12 -0
  556. package/dist/types/modes/components/segment-track.d.ts +27 -0
  557. package/dist/types/modes/components/select-list-mouse-routing.d.ts +2 -0
  558. package/dist/types/modes/components/selector-helpers.d.ts +53 -0
  559. package/dist/types/modes/components/session-selector.d.ts +94 -0
  560. package/dist/types/modes/components/settings-defs.d.ts +60 -0
  561. package/dist/types/modes/components/settings-selector.d.ts +70 -0
  562. package/dist/types/modes/components/show-images-selector.d.ts +10 -0
  563. package/dist/types/modes/components/skill-message.d.ts +9 -0
  564. package/dist/types/modes/components/snapcompact-shape-preview.d.ts +31 -0
  565. package/dist/types/modes/components/status-line/component.d.ts +94 -0
  566. package/dist/types/modes/components/status-line/component.test.d.ts +1 -0
  567. package/dist/types/modes/components/status-line/context-thresholds.d.ts +10 -0
  568. package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
  569. package/dist/types/modes/components/status-line/index.d.ts +5 -0
  570. package/dist/types/modes/components/status-line/presets.d.ts +3 -0
  571. package/dist/types/modes/components/status-line/segments.d.ts +5 -0
  572. package/dist/types/modes/components/status-line/separators.d.ts +3 -0
  573. package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
  574. package/dist/types/modes/components/status-line/types.d.ts +150 -0
  575. package/dist/types/modes/components/theme-selector.d.ts +11 -0
  576. package/dist/types/modes/components/thinking-selector.d.ts +11 -0
  577. package/dist/types/modes/components/tiny-title-download-progress.d.ts +11 -0
  578. package/dist/types/modes/components/todo-reminder.d.ts +15 -0
  579. package/dist/types/modes/components/tool-execution.d.ts +117 -0
  580. package/dist/types/modes/components/transcript-container.d.ts +86 -0
  581. package/dist/types/modes/components/tree-selector.d.ts +31 -0
  582. package/dist/types/modes/components/ttsr-notification.d.ts +17 -0
  583. package/dist/types/modes/components/usage-row.d.ts +3 -0
  584. package/dist/types/modes/components/user-message-selector.d.ts +28 -0
  585. package/dist/types/modes/components/user-message.d.ts +9 -0
  586. package/dist/types/modes/components/visual-truncate.d.ts +19 -0
  587. package/dist/types/modes/components/welcome.d.ts +66 -0
  588. package/dist/types/modes/controllers/btw-controller.d.ts +14 -0
  589. package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
  590. package/dist/types/modes/controllers/command-controller.d.ts +55 -0
  591. package/dist/types/modes/controllers/event-controller.d.ts +28 -0
  592. package/dist/types/modes/controllers/extension-ui-controller.d.ts +88 -0
  593. package/dist/types/modes/controllers/input-controller.d.ts +71 -0
  594. package/dist/types/modes/controllers/mcp-command-controller.d.ts +44 -0
  595. package/dist/types/modes/controllers/omfg-controller.d.ts +10 -0
  596. package/dist/types/modes/controllers/omfg-rule.d.ts +26 -0
  597. package/dist/types/modes/controllers/selector-controller.d.ts +61 -0
  598. package/dist/types/modes/controllers/session-focus-controller.d.ts +31 -0
  599. package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
  600. package/dist/types/modes/controllers/streaming-reveal.d.ts +45 -0
  601. package/dist/types/modes/controllers/tan-command-controller.d.ts +6 -0
  602. package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
  603. package/dist/types/modes/controllers/tool-args-reveal.d.ts +77 -0
  604. package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
  605. package/dist/types/modes/gradient-highlight.d.ts +32 -0
  606. package/dist/types/modes/image-references.d.ts +28 -0
  607. package/dist/types/modes/index.d.ts +10 -0
  608. package/dist/types/modes/interactive-mode.d.ts +401 -0
  609. package/dist/types/modes/internal-url-autocomplete.d.ts +43 -0
  610. package/dist/types/modes/loop-limit.d.ts +35 -0
  611. package/dist/types/modes/magic-keywords.d.ts +26 -0
  612. package/dist/types/modes/markdown-prose.d.ts +27 -0
  613. package/dist/types/modes/oauth-manual-input.d.ts +15 -0
  614. package/dist/types/modes/orchestrate.d.ts +15 -0
  615. package/dist/types/modes/print-mode.d.ts +29 -0
  616. package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
  617. package/dist/types/modes/rpc/host-tools.d.ts +16 -0
  618. package/dist/types/modes/rpc/host-uris.d.ts +38 -0
  619. package/dist/types/modes/rpc/rpc-client.d.ts +304 -0
  620. package/dist/types/modes/rpc/rpc-mode.d.ts +145 -0
  621. package/dist/types/modes/rpc/rpc-subagents.d.ts +24 -0
  622. package/dist/types/modes/rpc/rpc-types.d.ts +705 -0
  623. package/dist/types/modes/running-subagent-badge.d.ts +6 -0
  624. package/dist/types/modes/runtime-init.d.ts +25 -0
  625. package/dist/types/modes/session-observer-registry.d.ts +35 -0
  626. package/dist/types/modes/session-teardown.d.ts +63 -0
  627. package/dist/types/modes/session-teardown.test.d.ts +1 -0
  628. package/dist/types/modes/setup-version.d.ts +11 -0
  629. package/dist/types/modes/setup-wizard/index.d.ts +22 -0
  630. package/dist/types/modes/setup-wizard/lazy.d.ts +2 -0
  631. package/dist/types/modes/setup-wizard/scenes/glyph.d.ts +2 -0
  632. package/dist/types/modes/setup-wizard/scenes/outro.d.ts +2 -0
  633. package/dist/types/modes/setup-wizard/scenes/providers.d.ts +2 -0
  634. package/dist/types/modes/setup-wizard/scenes/sign-in.d.ts +22 -0
  635. package/dist/types/modes/setup-wizard/scenes/splash.d.ts +11 -0
  636. package/dist/types/modes/setup-wizard/scenes/theme.d.ts +2 -0
  637. package/dist/types/modes/setup-wizard/scenes/types.d.ts +52 -0
  638. package/dist/types/modes/setup-wizard/scenes/web-search.d.ts +23 -0
  639. package/dist/types/modes/setup-wizard/startup-splash.d.ts +7 -0
  640. package/dist/types/modes/setup-wizard/wizard-overlay.d.ts +15 -0
  641. package/dist/types/modes/shared.d.ts +15 -0
  642. package/dist/types/modes/skill-command.d.ts +32 -0
  643. package/dist/types/modes/theme/defaults/index.d.ts +9436 -0
  644. package/dist/types/modes/theme/mermaid-cache.d.ts +26 -0
  645. package/dist/types/modes/theme/mermaid-rendering.test.d.ts +1 -0
  646. package/dist/types/modes/theme/shimmer.d.ts +40 -0
  647. package/dist/types/modes/theme/theme.d.ts +360 -0
  648. package/dist/types/modes/turn-budget.d.ts +18 -0
  649. package/dist/types/modes/types.d.ts +399 -0
  650. package/dist/types/modes/ultrathink.d.ts +15 -0
  651. package/dist/types/modes/utils/context-usage.d.ts +64 -0
  652. package/dist/types/modes/utils/copy-targets.d.ts +75 -0
  653. package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
  654. package/dist/types/modes/utils/interactive-context-helpers.d.ts +14 -0
  655. package/dist/types/modes/utils/keybinding-matchers.d.ts +32 -0
  656. package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
  657. package/dist/types/modes/utils/transcript-render-helpers.d.ts +63 -0
  658. package/dist/types/modes/utils/ui-helpers.d.ts +55 -0
  659. package/dist/types/modes/workflow.d.ts +15 -0
  660. package/dist/types/plan-mode/approved-plan-prompt.test.d.ts +1 -0
  661. package/dist/types/plan-mode/approved-plan.d.ts +68 -0
  662. package/dist/types/plan-mode/plan-handoff.d.ts +20 -0
  663. package/dist/types/plan-mode/plan-protection.d.ts +12 -0
  664. package/dist/types/plan-mode/state.d.ts +6 -0
  665. package/dist/types/registry/agent-lifecycle.d.ts +66 -0
  666. package/dist/types/registry/agent-registry.d.ts +97 -0
  667. package/dist/types/sdk.d.ts +370 -0
  668. package/dist/types/secrets/index.d.ts +9 -0
  669. package/dist/types/secrets/obfuscator.d.ts +63 -0
  670. package/dist/types/secrets/regex.d.ts +2 -0
  671. package/dist/types/session/agent-session.d.ts +1419 -0
  672. package/dist/types/session/agent-storage.d.ts +97 -0
  673. package/dist/types/session/artifacts.d.ts +61 -0
  674. package/dist/types/session/auth-broker-config.d.ts +45 -0
  675. package/dist/types/session/auth-storage.d.ts +7 -0
  676. package/dist/types/session/blob-store.d.ts +68 -0
  677. package/dist/types/session/client-bridge.d.ts +88 -0
  678. package/dist/types/session/codex-auto-reset.d.ts +111 -0
  679. package/dist/types/session/compact-modes.d.ts +60 -0
  680. package/dist/types/session/exit-diagnostics.d.ts +48 -0
  681. package/dist/types/session/history-storage.d.ts +30 -0
  682. package/dist/types/session/indexed-session-storage.d.ts +65 -0
  683. package/dist/types/session/messages.d.ts +220 -0
  684. package/dist/types/session/messages.test.d.ts +1 -0
  685. package/dist/types/session/provider-image-budget.d.ts +3 -0
  686. package/dist/types/session/redis-session-storage.d.ts +51 -0
  687. package/dist/types/session/session-context.d.ts +44 -0
  688. package/dist/types/session/session-dump-format.d.ts +30 -0
  689. package/dist/types/session/session-entries.d.ts +197 -0
  690. package/dist/types/session/session-history-format.d.ts +49 -0
  691. package/dist/types/session/session-listing.d.ts +78 -0
  692. package/dist/types/session/session-loader.d.ts +29 -0
  693. package/dist/types/session/session-manager.d.ts +306 -0
  694. package/dist/types/session/session-migrations.d.ts +12 -0
  695. package/dist/types/session/session-paths.d.ts +25 -0
  696. package/dist/types/session/session-persistence.d.ts +12 -0
  697. package/dist/types/session/session-storage.d.ts +129 -0
  698. package/dist/types/session/session-title-slot.d.ts +19 -0
  699. package/dist/types/session/settings-stream-fn.d.ts +21 -0
  700. package/dist/types/session/shake-types.d.ts +24 -0
  701. package/dist/types/session/snapcompact-inline.d.ts +145 -0
  702. package/dist/types/session/snapcompact-savings-journal.d.ts +46 -0
  703. package/dist/types/session/sql-session-storage.d.ts +72 -0
  704. package/dist/types/session/streaming-output.d.ts +229 -0
  705. package/dist/types/session/tool-choice-queue.d.ts +94 -0
  706. package/dist/types/session/turn-persistence.d.ts +88 -0
  707. package/dist/types/session/unexpected-stop-classifier.d.ts +13 -0
  708. package/dist/types/session/yield-queue.d.ts +37 -0
  709. package/dist/types/slash-commands/acp-builtins.d.ts +34 -0
  710. package/dist/types/slash-commands/available-commands.d.ts +34 -0
  711. package/dist/types/slash-commands/builtin-registry.d.ts +36 -0
  712. package/dist/types/slash-commands/helpers/active-oauth-account.d.ts +14 -0
  713. package/dist/types/slash-commands/helpers/collab-qrcode.d.ts +13 -0
  714. package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
  715. package/dist/types/slash-commands/helpers/format.d.ts +10 -0
  716. package/dist/types/slash-commands/helpers/logout.d.ts +15 -0
  717. package/dist/types/slash-commands/helpers/marketplace-manager.d.ts +8 -0
  718. package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
  719. package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
  720. package/dist/types/slash-commands/helpers/reset-usage.d.ts +27 -0
  721. package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
  722. package/dist/types/slash-commands/helpers/stats-dashboard.d.ts +13 -0
  723. package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
  724. package/dist/types/slash-commands/helpers/usage-report.d.ts +7 -0
  725. package/dist/types/slash-commands/marketplace-install-parser.d.ts +33 -0
  726. package/dist/types/slash-commands/types.d.ts +127 -0
  727. package/dist/types/ssh/__tests__/connection-manager-args.test.d.ts +1 -0
  728. package/dist/types/ssh/__tests__/connection-manager-timeout.test.d.ts +1 -0
  729. package/dist/types/ssh/__tests__/file-transfer-posix-guard.test.d.ts +1 -0
  730. package/dist/types/ssh/__tests__/sshfs-mount.test.d.ts +1 -0
  731. package/dist/types/ssh/config-writer.d.ts +49 -0
  732. package/dist/types/ssh/connection-manager.d.ts +109 -0
  733. package/dist/types/ssh/file-transfer.d.ts +79 -0
  734. package/dist/types/ssh/ssh-executor.d.ts +37 -0
  735. package/dist/types/ssh/sshfs-mount.d.ts +15 -0
  736. package/dist/types/ssh/utils.d.ts +24 -0
  737. package/dist/types/startup-splash.d.ts +12 -0
  738. package/dist/types/stt/asr-client.d.ts +68 -0
  739. package/dist/types/stt/asr-protocol.d.ts +97 -0
  740. package/dist/types/stt/asr-worker.d.ts +2 -0
  741. package/dist/types/stt/downloader.d.ts +47 -0
  742. package/dist/types/stt/endpointer.d.ts +59 -0
  743. package/dist/types/stt/index.d.ts +8 -0
  744. package/dist/types/stt/models.d.ts +120 -0
  745. package/dist/types/stt/recorder.d.ts +30 -0
  746. package/dist/types/stt/stt-controller.d.ts +24 -0
  747. package/dist/types/stt/submit-trigger.d.ts +30 -0
  748. package/dist/types/stt/transcriber.d.ts +14 -0
  749. package/dist/types/stt/wav.d.ts +29 -0
  750. package/dist/types/subprocess/worker-client.d.ts +163 -0
  751. package/dist/types/subprocess/worker-runtime.d.ts +118 -0
  752. package/dist/types/system-prompt.d.ts +128 -0
  753. package/dist/types/system-prompt.test.d.ts +1 -0
  754. package/dist/types/task/agents.d.ts +28 -0
  755. package/dist/types/task/commands.d.ts +35 -0
  756. package/dist/types/task/discovery.d.ts +20 -0
  757. package/dist/types/task/executor.d.ts +214 -0
  758. package/dist/types/task/index.d.ts +79 -0
  759. package/dist/types/task/isolation-runner.d.ts +128 -0
  760. package/dist/types/task/name-generator.d.ts +16 -0
  761. package/dist/types/task/omp-command.d.ts +7 -0
  762. package/dist/types/task/output-manager.d.ts +20 -0
  763. package/dist/types/task/parallel.d.ts +55 -0
  764. package/dist/types/task/persisted-revive.d.ts +36 -0
  765. package/dist/types/task/provider-concurrency.d.ts +40 -0
  766. package/dist/types/task/render.d.ts +34 -0
  767. package/dist/types/task/render.test.d.ts +1 -0
  768. package/dist/types/task/renderer.d.ts +14 -0
  769. package/dist/types/task/repair-args.d.ts +53 -0
  770. package/dist/types/task/spawn-policy.d.ts +17 -0
  771. package/dist/types/task/spawn-policy.test.d.ts +1 -0
  772. package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
  773. package/dist/types/task/types.d.ts +384 -0
  774. package/dist/types/task/worktree.d.ts +135 -0
  775. package/dist/types/task/yield-assembly.d.ts +28 -0
  776. package/dist/types/telemetry-export.d.ts +19 -0
  777. package/dist/types/thinking.d.ts +96 -0
  778. package/dist/types/tiny/device.d.ts +78 -0
  779. package/dist/types/tiny/dtype.d.ts +85 -0
  780. package/dist/types/tiny/models.d.ts +230 -0
  781. package/dist/types/tiny/text.d.ts +44 -0
  782. package/dist/types/tiny/title-client.d.ts +68 -0
  783. package/dist/types/tiny/title-protocol.d.ts +78 -0
  784. package/dist/types/tiny/worker.d.ts +2 -0
  785. package/dist/types/tool-discovery/mode.d.ts +8 -0
  786. package/dist/types/tool-discovery/tool-index.d.ts +57 -0
  787. package/dist/types/tools/__tests__/eval-description.test.d.ts +1 -0
  788. package/dist/types/tools/__tests__/json-tree.test.d.ts +1 -0
  789. package/dist/types/tools/acp-bridge.d.ts +29 -0
  790. package/dist/types/tools/approval.d.ts +46 -0
  791. package/dist/types/tools/ask.d.ts +119 -0
  792. package/dist/types/tools/ast-edit.d.ts +84 -0
  793. package/dist/types/tools/ast-grep.d.ts +76 -0
  794. package/dist/types/tools/auto-generated-guard.d.ts +17 -0
  795. package/dist/types/tools/bash-command-fixup.d.ts +11 -0
  796. package/dist/types/tools/bash-interactive.d.ts +16 -0
  797. package/dist/types/tools/bash-interceptor.d.ts +24 -0
  798. package/dist/types/tools/bash-pty-selection.d.ts +7 -0
  799. package/dist/types/tools/bash-skill-urls.d.ts +31 -0
  800. package/dist/types/tools/bash.d.ts +173 -0
  801. package/dist/types/tools/browser/aria/aria-snapshot.d.ts +39 -0
  802. package/dist/types/tools/browser/attach.d.ts +34 -0
  803. package/dist/types/tools/browser/cmux/cmux-tab.d.ts +212 -0
  804. package/dist/types/tools/browser/cmux/rpc.d.ts +70 -0
  805. package/dist/types/tools/browser/cmux/socket-client.d.ts +19 -0
  806. package/dist/types/tools/browser/launch.d.ts +67 -0
  807. package/dist/types/tools/browser/readable.d.ts +17 -0
  808. package/dist/types/tools/browser/registry.d.ts +58 -0
  809. package/dist/types/tools/browser/render.d.ts +54 -0
  810. package/dist/types/tools/browser/run-cancellation.d.ts +4 -0
  811. package/dist/types/tools/browser/tab-protocol.d.ts +146 -0
  812. package/dist/types/tools/browser/tab-supervisor.d.ts +114 -0
  813. package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
  814. package/dist/types/tools/browser/tab-worker.d.ts +56 -0
  815. package/dist/types/tools/browser.d.ts +96 -0
  816. package/dist/types/tools/builtin-names.d.ts +6 -0
  817. package/dist/types/tools/checkpoint.d.ts +72 -0
  818. package/dist/types/tools/conflict-detect.d.ts +221 -0
  819. package/dist/types/tools/context.d.ts +19 -0
  820. package/dist/types/tools/debug.d.ts +157 -0
  821. package/dist/types/tools/eval-backends.d.ts +15 -0
  822. package/dist/types/tools/eval-render.d.ts +58 -0
  823. package/dist/types/tools/eval.d.ts +66 -0
  824. package/dist/types/tools/fetch.d.ts +99 -0
  825. package/dist/types/tools/file-recorder.d.ts +13 -0
  826. package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
  827. package/dist/types/tools/gh-cache-invalidation.d.ts +6 -0
  828. package/dist/types/tools/gh-format.d.ts +6 -0
  829. package/dist/types/tools/gh-renderer.d.ts +25 -0
  830. package/dist/types/tools/gh.d.ts +331 -0
  831. package/dist/types/tools/github-cache.d.ts +123 -0
  832. package/dist/types/tools/glob.d.ts +96 -0
  833. package/dist/types/tools/grep.d.ts +99 -0
  834. package/dist/types/tools/grouped-file-output.d.ts +70 -0
  835. package/dist/types/tools/image-gen.d.ts +66 -0
  836. package/dist/types/tools/index.d.ts +368 -0
  837. package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
  838. package/dist/types/tools/inspect-image.d.ts +32 -0
  839. package/dist/types/tools/irc.d.ts +112 -0
  840. package/dist/types/tools/job.d.ts +73 -0
  841. package/dist/types/tools/json-tree.d.ts +23 -0
  842. package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
  843. package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
  844. package/dist/types/tools/jtd-utils.d.ts +42 -0
  845. package/dist/types/tools/learn.d.ts +44 -0
  846. package/dist/types/tools/list-limit.d.ts +12 -0
  847. package/dist/types/tools/manage-skill.d.ts +31 -0
  848. package/dist/types/tools/match-line-format.d.ts +11 -0
  849. package/dist/types/tools/memory-edit.d.ts +31 -0
  850. package/dist/types/tools/memory-recall.d.ts +23 -0
  851. package/dist/types/tools/memory-reflect.d.ts +25 -0
  852. package/dist/types/tools/memory-render.d.ts +63 -0
  853. package/dist/types/tools/memory-retain.d.ts +29 -0
  854. package/dist/types/tools/output-meta.d.ts +211 -0
  855. package/dist/types/tools/output-schema-validator.d.ts +77 -0
  856. package/dist/types/tools/path-utils.d.ts +267 -0
  857. package/dist/types/tools/plan-mode-guard.d.ts +33 -0
  858. package/dist/types/tools/read.d.ts +87 -0
  859. package/dist/types/tools/render-utils.d.ts +218 -0
  860. package/dist/types/tools/renderers.d.ts +49 -0
  861. package/dist/types/tools/report-tool-issue.d.ts +127 -0
  862. package/dist/types/tools/resolve.d.ts +94 -0
  863. package/dist/types/tools/review.d.ts +59 -0
  864. package/dist/types/tools/search-tool-bm25.d.ts +65 -0
  865. package/dist/types/tools/sqlite-reader.d.ts +114 -0
  866. package/dist/types/tools/ssh.d.ts +74 -0
  867. package/dist/types/tools/todo.d.ts +126 -0
  868. package/dist/types/tools/tool-errors.d.ts +33 -0
  869. package/dist/types/tools/tool-result.d.ts +34 -0
  870. package/dist/types/tools/tool-timeouts.d.ts +51 -0
  871. package/dist/types/tools/tts.d.ts +42 -0
  872. package/dist/types/tools/write.d.ts +66 -0
  873. package/dist/types/tools/yield.d.ts +39 -0
  874. package/dist/types/tts/downloader.d.ts +20 -0
  875. package/dist/types/tts/index.d.ts +10 -0
  876. package/dist/types/tts/models.d.ts +82 -0
  877. package/dist/types/tts/player.d.ts +32 -0
  878. package/dist/types/tts/runtime.d.ts +6 -0
  879. package/dist/types/tts/speakable.d.ts +47 -0
  880. package/dist/types/tts/speech-enhancer.d.ts +46 -0
  881. package/dist/types/tts/streaming-player.d.ts +40 -0
  882. package/dist/types/tts/tts-client.d.ts +69 -0
  883. package/dist/types/tts/tts-protocol.d.ts +102 -0
  884. package/dist/types/tts/tts-worker.d.ts +2 -0
  885. package/dist/types/tts/vocalizer.d.ts +48 -0
  886. package/dist/types/tts/wav.d.ts +8 -0
  887. package/dist/types/tui/code-cell.d.ts +47 -0
  888. package/dist/types/tui/file-list.d.ts +22 -0
  889. package/dist/types/tui/hyperlink.d.ts +61 -0
  890. package/dist/types/tui/index.d.ts +12 -0
  891. package/dist/types/tui/output-block.d.ts +59 -0
  892. package/dist/types/tui/status-line.d.ts +21 -0
  893. package/dist/types/tui/tree-list.d.ts +20 -0
  894. package/dist/types/tui/types.d.ts +13 -0
  895. package/dist/types/tui/utils.d.ts +36 -0
  896. package/dist/types/tui/width-aware-text.d.ts +23 -0
  897. package/dist/types/utils/active-repo-context.d.ts +8 -0
  898. package/dist/types/utils/block-context.d.ts +35 -0
  899. package/dist/types/utils/changelog.d.ts +33 -0
  900. package/dist/types/utils/clipboard.d.ts +37 -0
  901. package/dist/types/utils/command-args.d.ts +9 -0
  902. package/dist/types/utils/commit-message-generator.d.ts +7 -0
  903. package/dist/types/utils/edit-mode.d.ts +13 -0
  904. package/dist/types/utils/enhanced-paste.d.ts +20 -0
  905. package/dist/types/utils/event-bus.d.ts +6 -0
  906. package/dist/types/utils/external-editor.d.ts +27 -0
  907. package/dist/types/utils/fetch-timeout.d.ts +4 -0
  908. package/dist/types/utils/file-display-mode.d.ts +27 -0
  909. package/dist/types/utils/file-mentions.d.ts +13 -0
  910. package/dist/types/utils/git.d.ts +471 -0
  911. package/dist/types/utils/image-loading.d.ts +67 -0
  912. package/dist/types/utils/image-resize.d.ts +42 -0
  913. package/dist/types/utils/image-vision-fallback.d.ts +28 -0
  914. package/dist/types/utils/ipc.d.ts +22 -0
  915. package/dist/types/utils/jj.d.ts +74 -0
  916. package/dist/types/utils/lang-from-path.d.ts +8 -0
  917. package/dist/types/utils/markit-cache.d.ts +23 -0
  918. package/dist/types/utils/markit.d.ts +20 -0
  919. package/dist/types/utils/mupdf-wasm-embed.d.ts +1 -0
  920. package/dist/types/utils/open.d.ts +2 -0
  921. package/dist/types/utils/prompt-path.d.ts +1 -0
  922. package/dist/types/utils/qrcode.d.ts +48 -0
  923. package/dist/types/utils/session-color.d.ts +27 -0
  924. package/dist/types/utils/shell-snapshot.d.ts +15 -0
  925. package/dist/types/utils/sixel.d.ts +21 -0
  926. package/dist/types/utils/thinking-display.d.ts +7 -0
  927. package/dist/types/utils/title-generator.d.ts +33 -0
  928. package/dist/types/utils/tool-choice.d.ts +15 -0
  929. package/dist/types/utils/tools-manager.d.ts +12 -0
  930. package/dist/types/utils/turndown.d.ts +15 -0
  931. package/dist/types/utils/zip.d.ts +119 -0
  932. package/dist/types/web/kagi.d.ts +99 -0
  933. package/dist/types/web/parallel.d.ts +67 -0
  934. package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
  935. package/dist/types/web/scrapers/arxiv.d.ts +5 -0
  936. package/dist/types/web/scrapers/aur.d.ts +5 -0
  937. package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
  938. package/dist/types/web/scrapers/bluesky.d.ts +5 -0
  939. package/dist/types/web/scrapers/brew.d.ts +5 -0
  940. package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
  941. package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
  942. package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
  943. package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
  944. package/dist/types/web/scrapers/clojars.d.ts +5 -0
  945. package/dist/types/web/scrapers/coingecko.d.ts +5 -0
  946. package/dist/types/web/scrapers/crates-io.d.ts +5 -0
  947. package/dist/types/web/scrapers/crossref.d.ts +2 -0
  948. package/dist/types/web/scrapers/devto.d.ts +5 -0
  949. package/dist/types/web/scrapers/discogs.d.ts +8 -0
  950. package/dist/types/web/scrapers/discourse.d.ts +5 -0
  951. package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
  952. package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
  953. package/dist/types/web/scrapers/fdroid.d.ts +5 -0
  954. package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
  955. package/dist/types/web/scrapers/flathub.d.ts +2 -0
  956. package/dist/types/web/scrapers/github-gist.d.ts +5 -0
  957. package/dist/types/web/scrapers/github.d.ts +34 -0
  958. package/dist/types/web/scrapers/gitlab.d.ts +5 -0
  959. package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
  960. package/dist/types/web/scrapers/hackage.d.ts +5 -0
  961. package/dist/types/web/scrapers/hackernews.d.ts +2 -0
  962. package/dist/types/web/scrapers/hex.d.ts +5 -0
  963. package/dist/types/web/scrapers/huggingface.d.ts +2 -0
  964. package/dist/types/web/scrapers/iacr.d.ts +5 -0
  965. package/dist/types/web/scrapers/index.d.ts +84 -0
  966. package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
  967. package/dist/types/web/scrapers/lemmy.d.ts +2 -0
  968. package/dist/types/web/scrapers/lobsters.d.ts +5 -0
  969. package/dist/types/web/scrapers/mastodon.d.ts +5 -0
  970. package/dist/types/web/scrapers/maven.d.ts +6 -0
  971. package/dist/types/web/scrapers/mdn.d.ts +2 -0
  972. package/dist/types/web/scrapers/metacpan.d.ts +5 -0
  973. package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
  974. package/dist/types/web/scrapers/npm.d.ts +5 -0
  975. package/dist/types/web/scrapers/nuget.d.ts +5 -0
  976. package/dist/types/web/scrapers/nvd.d.ts +5 -0
  977. package/dist/types/web/scrapers/ollama.d.ts +2 -0
  978. package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
  979. package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
  980. package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
  981. package/dist/types/web/scrapers/orcid.d.ts +5 -0
  982. package/dist/types/web/scrapers/osv.d.ts +5 -0
  983. package/dist/types/web/scrapers/packagist.d.ts +5 -0
  984. package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
  985. package/dist/types/web/scrapers/pubmed.d.ts +5 -0
  986. package/dist/types/web/scrapers/pypi.d.ts +5 -0
  987. package/dist/types/web/scrapers/rawg.d.ts +2 -0
  988. package/dist/types/web/scrapers/readthedocs.d.ts +5 -0
  989. package/dist/types/web/scrapers/reddit.d.ts +5 -0
  990. package/dist/types/web/scrapers/repology.d.ts +5 -0
  991. package/dist/types/web/scrapers/rfc.d.ts +5 -0
  992. package/dist/types/web/scrapers/rubygems.d.ts +5 -0
  993. package/dist/types/web/scrapers/searchcode.d.ts +2 -0
  994. package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
  995. package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
  996. package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
  997. package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
  998. package/dist/types/web/scrapers/spdx.d.ts +5 -0
  999. package/dist/types/web/scrapers/spotify.d.ts +8 -0
  1000. package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
  1001. package/dist/types/web/scrapers/terraform.d.ts +5 -0
  1002. package/dist/types/web/scrapers/tldr.d.ts +7 -0
  1003. package/dist/types/web/scrapers/twitter.d.ts +5 -0
  1004. package/dist/types/web/scrapers/types.d.ts +90 -0
  1005. package/dist/types/web/scrapers/utils.d.ts +26 -0
  1006. package/dist/types/web/scrapers/vimeo.d.ts +5 -0
  1007. package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
  1008. package/dist/types/web/scrapers/w3c.d.ts +2 -0
  1009. package/dist/types/web/scrapers/wikidata.d.ts +5 -0
  1010. package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
  1011. package/dist/types/web/scrapers/youtube.d.ts +5 -0
  1012. package/dist/types/web/search/index.d.ts +74 -0
  1013. package/dist/types/web/search/provider.d.ts +30 -0
  1014. package/dist/types/web/search/providers/anthropic.d.ts +33 -0
  1015. package/dist/types/web/search/providers/base.d.ts +84 -0
  1016. package/dist/types/web/search/providers/brave.d.ts +28 -0
  1017. package/dist/types/web/search/providers/codex.d.ts +36 -0
  1018. package/dist/types/web/search/providers/duckduckgo.d.ts +14 -0
  1019. package/dist/types/web/search/providers/exa.d.ts +70 -0
  1020. package/dist/types/web/search/providers/firecrawl.d.ts +28 -0
  1021. package/dist/types/web/search/providers/gemini.d.ts +63 -0
  1022. package/dist/types/web/search/providers/jina.d.ts +31 -0
  1023. package/dist/types/web/search/providers/kagi.d.ts +30 -0
  1024. package/dist/types/web/search/providers/kimi.d.ts +32 -0
  1025. package/dist/types/web/search/providers/parallel.d.ts +16 -0
  1026. package/dist/types/web/search/providers/perplexity-auth.d.ts +37 -0
  1027. package/dist/types/web/search/providers/perplexity.d.ts +58 -0
  1028. package/dist/types/web/search/providers/searxng.d.ts +45 -0
  1029. package/dist/types/web/search/providers/synthetic.d.ts +25 -0
  1030. package/dist/types/web/search/providers/tavily.d.ts +30 -0
  1031. package/dist/types/web/search/providers/tinyfish.d.ts +29 -0
  1032. package/dist/types/web/search/providers/utils.d.ts +52 -0
  1033. package/dist/types/web/search/providers/xai.d.ts +13 -0
  1034. package/dist/types/web/search/providers/zai.d.ts +29 -0
  1035. package/dist/types/web/search/render.d.ts +34 -0
  1036. package/dist/types/web/search/types.d.ts +431 -0
  1037. package/dist/types/web/search/utils.d.ts +4 -0
  1038. package/dist/types/workspace-tree.d.ts +42 -0
  1039. package/examples/README.md +21 -0
  1040. package/examples/custom-tools/README.md +104 -0
  1041. package/examples/custom-tools/hello/index.ts +20 -0
  1042. package/examples/extensions/README.md +142 -0
  1043. package/examples/extensions/api-demo.ts +79 -0
  1044. package/examples/extensions/chalk-logger.ts +25 -0
  1045. package/examples/extensions/hello.ts +31 -0
  1046. package/examples/extensions/pirate.ts +43 -0
  1047. package/examples/extensions/plan-mode.ts +549 -0
  1048. package/examples/extensions/reload-runtime.ts +38 -0
  1049. package/examples/extensions/thinking-note.ts +13 -0
  1050. package/examples/extensions/tools.ts +145 -0
  1051. package/examples/extensions/with-deps/index.ts +36 -0
  1052. package/examples/extensions/with-deps/package-lock.json +31 -0
  1053. package/examples/extensions/with-deps/package.json +17 -0
  1054. package/examples/hooks/README.md +56 -0
  1055. package/examples/hooks/auto-commit-on-exit.ts +48 -0
  1056. package/examples/hooks/confirm-destructive.ts +58 -0
  1057. package/examples/hooks/custom-compaction.ts +115 -0
  1058. package/examples/hooks/dirty-repo-guard.ts +51 -0
  1059. package/examples/hooks/file-trigger.ts +40 -0
  1060. package/examples/hooks/git-checkpoint.ts +52 -0
  1061. package/examples/hooks/handoff.ts +149 -0
  1062. package/examples/hooks/permission-gate.ts +33 -0
  1063. package/examples/hooks/protected-paths.ts +29 -0
  1064. package/examples/hooks/qna.ts +118 -0
  1065. package/examples/hooks/status-line.ts +39 -0
  1066. package/examples/sdk/01-minimal.ts +21 -0
  1067. package/examples/sdk/02-custom-model.ts +49 -0
  1068. package/examples/sdk/03-custom-prompt.ts +46 -0
  1069. package/examples/sdk/04-skills.ts +43 -0
  1070. package/examples/sdk/06-extensions.ts +82 -0
  1071. package/examples/sdk/06-hooks.ts +61 -0
  1072. package/examples/sdk/07-context-files.ts +35 -0
  1073. package/examples/sdk/08-prompt-templates.ts +41 -0
  1074. package/examples/sdk/08-slash-commands.ts +46 -0
  1075. package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
  1076. package/examples/sdk/11-sessions.ts +47 -0
  1077. package/examples/sdk/12-redis-sessions.ts +54 -0
  1078. package/examples/sdk/13-sql-sessions.ts +61 -0
  1079. package/examples/sdk/README.md +172 -0
  1080. package/package.json +594 -0
  1081. package/scripts/bench-guard.ts +71 -0
  1082. package/scripts/build-binary.ts +135 -0
  1083. package/scripts/bundle-dist.ts +129 -0
  1084. package/scripts/embed-mupdf-wasm.ts +67 -0
  1085. package/scripts/format-prompts.ts +68 -0
  1086. package/scripts/generate-aria-snapshot.ts +134 -0
  1087. package/scripts/generate-docs-index.ts +148 -0
  1088. package/scripts/generate-legacy-pi-bundled-registry.ts +420 -0
  1089. package/scripts/generate-share-viewer.ts +36 -0
  1090. package/scripts/measure-prompt-tokens.ts +63 -0
  1091. package/scripts/omp +42 -0
  1092. package/scripts/omp.ts +19 -0
  1093. package/src/advisor/__tests__/advisor.test.ts +1662 -0
  1094. package/src/advisor/__tests__/config.test.ts +173 -0
  1095. package/src/advisor/__tests__/emission-guard.test.ts +147 -0
  1096. package/src/advisor/advise-tool.ts +203 -0
  1097. package/src/advisor/config.ts +258 -0
  1098. package/src/advisor/emission-guard.ts +172 -0
  1099. package/src/advisor/index.ts +6 -0
  1100. package/src/advisor/runtime.ts +518 -0
  1101. package/src/advisor/transcript-recorder.ts +159 -0
  1102. package/src/advisor/watchdog.ts +135 -0
  1103. package/src/async/index.ts +1 -0
  1104. package/src/async/job-manager.ts +698 -0
  1105. package/src/auto-thinking/classifier.ts +195 -0
  1106. package/src/autolearn/controller.ts +145 -0
  1107. package/src/autolearn/managed-skills.ts +255 -0
  1108. package/src/autoresearch/command-resume.md +14 -0
  1109. package/src/autoresearch/dashboard.ts +436 -0
  1110. package/src/autoresearch/git.ts +331 -0
  1111. package/src/autoresearch/helpers.ts +218 -0
  1112. package/src/autoresearch/index.ts +541 -0
  1113. package/src/autoresearch/prompt-setup.md +43 -0
  1114. package/src/autoresearch/prompt.md +103 -0
  1115. package/src/autoresearch/resume-message.md +10 -0
  1116. package/src/autoresearch/state.ts +273 -0
  1117. package/src/autoresearch/storage.ts +700 -0
  1118. package/src/autoresearch/tools/init-experiment.ts +269 -0
  1119. package/src/autoresearch/tools/log-experiment.ts +521 -0
  1120. package/src/autoresearch/tools/run-experiment.ts +407 -0
  1121. package/src/autoresearch/tools/update-notes.ts +109 -0
  1122. package/src/autoresearch/types.ts +168 -0
  1123. package/src/capability/context-file.ts +44 -0
  1124. package/src/capability/extension-module.ts +34 -0
  1125. package/src/capability/extension.ts +47 -0
  1126. package/src/capability/fs.ts +117 -0
  1127. package/src/capability/hook.ts +40 -0
  1128. package/src/capability/index.ts +436 -0
  1129. package/src/capability/instruction.ts +37 -0
  1130. package/src/capability/mcp.ts +76 -0
  1131. package/src/capability/prompt.ts +35 -0
  1132. package/src/capability/rule-buckets.ts +66 -0
  1133. package/src/capability/rule.ts +261 -0
  1134. package/src/capability/settings.ts +34 -0
  1135. package/src/capability/skill.ts +63 -0
  1136. package/src/capability/slash-command.ts +40 -0
  1137. package/src/capability/ssh.ts +41 -0
  1138. package/src/capability/system-prompt.ts +34 -0
  1139. package/src/capability/tool.ts +38 -0
  1140. package/src/capability/types.ts +168 -0
  1141. package/src/cli/agents-cli.ts +138 -0
  1142. package/src/cli/args.ts +393 -0
  1143. package/src/cli/auth-broker-cli.ts +921 -0
  1144. package/src/cli/auth-gateway-cli.ts +608 -0
  1145. package/src/cli/bench-cli.ts +623 -0
  1146. package/src/cli/classify-install-target.ts +76 -0
  1147. package/src/cli/claude-trace-cli.ts +795 -0
  1148. package/src/cli/commands/init-xdg.ts +27 -0
  1149. package/src/cli/completion-gen.ts +550 -0
  1150. package/src/cli/config-cli.ts +422 -0
  1151. package/src/cli/dry-balance-cli.ts +853 -0
  1152. package/src/cli/extension-flags.ts +48 -0
  1153. package/src/cli/file-processor.ts +133 -0
  1154. package/src/cli/flag-tables.ts +325 -0
  1155. package/src/cli/gallery-cli.ts +272 -0
  1156. package/src/cli/gallery-fixtures/agentic.ts +416 -0
  1157. package/src/cli/gallery-fixtures/codeintel.ts +187 -0
  1158. package/src/cli/gallery-fixtures/edit.ts +254 -0
  1159. package/src/cli/gallery-fixtures/fs.ts +220 -0
  1160. package/src/cli/gallery-fixtures/index.ts +40 -0
  1161. package/src/cli/gallery-fixtures/interaction.ts +46 -0
  1162. package/src/cli/gallery-fixtures/memory.ts +81 -0
  1163. package/src/cli/gallery-fixtures/misc.ts +250 -0
  1164. package/src/cli/gallery-fixtures/search.ts +213 -0
  1165. package/src/cli/gallery-fixtures/shell.ts +159 -0
  1166. package/src/cli/gallery-fixtures/types.ts +57 -0
  1167. package/src/cli/gallery-fixtures/web.ts +158 -0
  1168. package/src/cli/gallery-screenshot.ts +279 -0
  1169. package/src/cli/gc-cli.ts +946 -0
  1170. package/src/cli/grep-cli.ts +160 -0
  1171. package/src/cli/grievances-cli.ts +256 -0
  1172. package/src/cli/initial-message.ts +58 -0
  1173. package/src/cli/models-cli.ts +368 -0
  1174. package/src/cli/plugin-cli.ts +996 -0
  1175. package/src/cli/profile-alias.ts +369 -0
  1176. package/src/cli/profile-bootstrap.ts +233 -0
  1177. package/src/cli/read-cli.ts +57 -0
  1178. package/src/cli/session-picker.ts +93 -0
  1179. package/src/cli/setup-cli.ts +332 -0
  1180. package/src/cli/setup-model-picker.ts +43 -0
  1181. package/src/cli/shell-cli.ts +176 -0
  1182. package/src/cli/ssh-cli.ts +179 -0
  1183. package/src/cli/startup-cwd.ts +58 -0
  1184. package/src/cli/stats-cli.ts +229 -0
  1185. package/src/cli/tiny-models-cli.ts +153 -0
  1186. package/src/cli/ttsr-cli.ts +995 -0
  1187. package/src/cli/update-cli.test.ts +28 -0
  1188. package/src/cli/update-cli.ts +944 -0
  1189. package/src/cli/usage-cli.ts +857 -0
  1190. package/src/cli/web-search-cli.ts +137 -0
  1191. package/src/cli/worktree-cli.ts +294 -0
  1192. package/src/cli-commands.ts +131 -0
  1193. package/src/cli.ts +348 -0
  1194. package/src/collab/crypto.ts +63 -0
  1195. package/src/collab/display-name.ts +13 -0
  1196. package/src/collab/guest.ts +731 -0
  1197. package/src/collab/host.ts +690 -0
  1198. package/src/collab/protocol.ts +296 -0
  1199. package/src/collab/relay-client.ts +216 -0
  1200. package/src/collab/replication-shrink.ts +111 -0
  1201. package/src/commands/acp.ts +24 -0
  1202. package/src/commands/agents.ts +57 -0
  1203. package/src/commands/auth-broker.ts +99 -0
  1204. package/src/commands/auth-gateway.ts +69 -0
  1205. package/src/commands/bench.ts +51 -0
  1206. package/src/commands/commit.ts +46 -0
  1207. package/src/commands/complete.ts +66 -0
  1208. package/src/commands/completions.ts +60 -0
  1209. package/src/commands/config.ts +51 -0
  1210. package/src/commands/dry-balance.ts +43 -0
  1211. package/src/commands/gallery.ts +60 -0
  1212. package/src/commands/gc.ts +46 -0
  1213. package/src/commands/grep.ts +48 -0
  1214. package/src/commands/grievances.ts +51 -0
  1215. package/src/commands/install.ts +107 -0
  1216. package/src/commands/join.ts +39 -0
  1217. package/src/commands/launch.ts +182 -0
  1218. package/src/commands/models.ts +60 -0
  1219. package/src/commands/plugin.ts +78 -0
  1220. package/src/commands/read.ts +38 -0
  1221. package/src/commands/say.ts +102 -0
  1222. package/src/commands/setup.ts +67 -0
  1223. package/src/commands/shell.ts +29 -0
  1224. package/src/commands/ssh.ts +60 -0
  1225. package/src/commands/stats.ts +29 -0
  1226. package/src/commands/tiny-models.ts +36 -0
  1227. package/src/commands/token.ts +162 -0
  1228. package/src/commands/ttsr.ts +125 -0
  1229. package/src/commands/update.ts +27 -0
  1230. package/src/commands/usage.ts +43 -0
  1231. package/src/commands/web-search.ts +42 -0
  1232. package/src/commands/worktree.ts +62 -0
  1233. package/src/commit/agentic/agent.ts +318 -0
  1234. package/src/commit/agentic/fallback.ts +96 -0
  1235. package/src/commit/agentic/index.ts +355 -0
  1236. package/src/commit/agentic/prompts/analyze-file.md +22 -0
  1237. package/src/commit/agentic/prompts/session-user.md +25 -0
  1238. package/src/commit/agentic/prompts/split-confirm.md +1 -0
  1239. package/src/commit/agentic/prompts/system.md +38 -0
  1240. package/src/commit/agentic/state.ts +60 -0
  1241. package/src/commit/agentic/tools/analyze-file.ts +149 -0
  1242. package/src/commit/agentic/tools/git-file-diff.ts +191 -0
  1243. package/src/commit/agentic/tools/git-hunk.ts +52 -0
  1244. package/src/commit/agentic/tools/git-overview.ts +81 -0
  1245. package/src/commit/agentic/tools/index.ts +54 -0
  1246. package/src/commit/agentic/tools/propose-changelog.ts +147 -0
  1247. package/src/commit/agentic/tools/propose-commit.ts +109 -0
  1248. package/src/commit/agentic/tools/recent-commits.ts +81 -0
  1249. package/src/commit/agentic/tools/schemas.ts +11 -0
  1250. package/src/commit/agentic/tools/split-commit.ts +241 -0
  1251. package/src/commit/agentic/topo-sort.ts +44 -0
  1252. package/src/commit/agentic/trivial.ts +51 -0
  1253. package/src/commit/agentic/validation.ts +183 -0
  1254. package/src/commit/analysis/conventional.ts +64 -0
  1255. package/src/commit/analysis/index.ts +4 -0
  1256. package/src/commit/analysis/scope.ts +242 -0
  1257. package/src/commit/analysis/summary.ts +107 -0
  1258. package/src/commit/analysis/validation.ts +66 -0
  1259. package/src/commit/changelog/detect.ts +40 -0
  1260. package/src/commit/changelog/generate.ts +101 -0
  1261. package/src/commit/changelog/index.ts +234 -0
  1262. package/src/commit/changelog/parse.ts +44 -0
  1263. package/src/commit/cli.ts +85 -0
  1264. package/src/commit/git/diff.ts +148 -0
  1265. package/src/commit/index.ts +5 -0
  1266. package/src/commit/map-reduce/index.ts +69 -0
  1267. package/src/commit/map-reduce/map-phase.ts +193 -0
  1268. package/src/commit/map-reduce/reduce-phase.ts +49 -0
  1269. package/src/commit/map-reduce/utils.ts +9 -0
  1270. package/src/commit/message.ts +11 -0
  1271. package/src/commit/model-selection.ts +95 -0
  1272. package/src/commit/pipeline.ts +243 -0
  1273. package/src/commit/prompts/analysis-system.md +148 -0
  1274. package/src/commit/prompts/analysis-user.md +38 -0
  1275. package/src/commit/prompts/changelog-system.md +50 -0
  1276. package/src/commit/prompts/changelog-user.md +18 -0
  1277. package/src/commit/prompts/file-observer-system.md +24 -0
  1278. package/src/commit/prompts/file-observer-user.md +8 -0
  1279. package/src/commit/prompts/reduce-system.md +50 -0
  1280. package/src/commit/prompts/reduce-user.md +17 -0
  1281. package/src/commit/prompts/summary-retry.md +3 -0
  1282. package/src/commit/prompts/summary-system.md +38 -0
  1283. package/src/commit/prompts/summary-user.md +13 -0
  1284. package/src/commit/prompts/types-description.md +2 -0
  1285. package/src/commit/shared-llm.ts +70 -0
  1286. package/src/commit/types.ts +118 -0
  1287. package/src/commit/utils/exclusions.ts +42 -0
  1288. package/src/commit/utils.ts +58 -0
  1289. package/src/config/api-key-resolver.ts +67 -0
  1290. package/src/config/append-only-context-mode.ts +76 -0
  1291. package/src/config/config-file.ts +315 -0
  1292. package/src/config/file-lock.ts +164 -0
  1293. package/src/config/inline-tool-descriptors-mode.ts +26 -0
  1294. package/src/config/keybindings.ts +636 -0
  1295. package/src/config/mcp-schema.json +247 -0
  1296. package/src/config/model-discovery.ts +919 -0
  1297. package/src/config/model-registry.ts +2275 -0
  1298. package/src/config/model-resolver.ts +1798 -0
  1299. package/src/config/model-roles.ts +99 -0
  1300. package/src/config/models-config-schema.ts +293 -0
  1301. package/src/config/models-config.ts +134 -0
  1302. package/src/config/prompt-templates.ts +205 -0
  1303. package/src/config/provider-globals.ts +25 -0
  1304. package/src/config/resolve-config-value.ts +94 -0
  1305. package/src/config/service-tier.ts +116 -0
  1306. package/src/config/settings-schema.ts +5247 -0
  1307. package/src/config/settings.ts +1540 -0
  1308. package/src/config.ts +242 -0
  1309. package/src/cursor.ts +340 -0
  1310. package/src/dap/client.ts +764 -0
  1311. package/src/dap/config.ts +333 -0
  1312. package/src/dap/defaults.json +212 -0
  1313. package/src/dap/index.ts +4 -0
  1314. package/src/dap/session.ts +1441 -0
  1315. package/src/dap/types.ts +610 -0
  1316. package/src/debug/index.ts +584 -0
  1317. package/src/debug/log-formatting.ts +58 -0
  1318. package/src/debug/log-viewer.ts +966 -0
  1319. package/src/debug/profiler.ts +168 -0
  1320. package/src/debug/protocol-probe.ts +267 -0
  1321. package/src/debug/raw-sse-buffer.ts +294 -0
  1322. package/src/debug/raw-sse.ts +312 -0
  1323. package/src/debug/remote-debugger.ts +151 -0
  1324. package/src/debug/report-bundle.ts +375 -0
  1325. package/src/debug/system-info.ts +111 -0
  1326. package/src/debug/terminal-info.ts +124 -0
  1327. package/src/discovery/agents-md.ts +67 -0
  1328. package/src/discovery/agents.ts +230 -0
  1329. package/src/discovery/at-imports.ts +273 -0
  1330. package/src/discovery/builtin-defaults.ts +39 -0
  1331. package/src/discovery/builtin-rules/go-add-cleanup.md +32 -0
  1332. package/src/discovery/builtin-rules/go-bench-loop.md +36 -0
  1333. package/src/discovery/builtin-rules/go-exp-promoted.md +39 -0
  1334. package/src/discovery/builtin-rules/go-ioutil.md +36 -0
  1335. package/src/discovery/builtin-rules/go-join-hostport.md +29 -0
  1336. package/src/discovery/builtin-rules/go-new-expr.md +44 -0
  1337. package/src/discovery/builtin-rules/go-rand-v2.md +40 -0
  1338. package/src/discovery/builtin-rules/go-range-int.md +45 -0
  1339. package/src/discovery/builtin-rules/index.ts +72 -0
  1340. package/src/discovery/builtin-rules/rs-box-leak.md +48 -0
  1341. package/src/discovery/builtin-rules/rs-future-prelude.md +23 -0
  1342. package/src/discovery/builtin-rules/rs-lazylock.md +51 -0
  1343. package/src/discovery/builtin-rules/rs-match-ergonomics.md +67 -0
  1344. package/src/discovery/builtin-rules/rs-parking-lot.md +44 -0
  1345. package/src/discovery/builtin-rules/rs-result-type.md +19 -0
  1346. package/src/discovery/builtin-rules/ts-bare-catch.md +38 -0
  1347. package/src/discovery/builtin-rules/ts-import-type.md +42 -0
  1348. package/src/discovery/builtin-rules/ts-no-any.md +65 -0
  1349. package/src/discovery/builtin-rules/ts-no-deprecated-leftovers.md +44 -0
  1350. package/src/discovery/builtin-rules/ts-no-dynamic-import.md +39 -0
  1351. package/src/discovery/builtin-rules/ts-no-inline-cast-access.md +55 -0
  1352. package/src/discovery/builtin-rules/ts-no-return-type.md +44 -0
  1353. package/src/discovery/builtin-rules/ts-no-test-timers.md +55 -0
  1354. package/src/discovery/builtin-rules/ts-no-tiny-functions.md +51 -0
  1355. package/src/discovery/builtin-rules/ts-promise-with-resolvers.md +65 -0
  1356. package/src/discovery/builtin-rules/ts-redundant-clear-guard.md +75 -0
  1357. package/src/discovery/builtin-rules/ts-set-map.md +28 -0
  1358. package/src/discovery/builtin.ts +934 -0
  1359. package/src/discovery/claude-plugins.ts +387 -0
  1360. package/src/discovery/claude.ts +584 -0
  1361. package/src/discovery/cline.ts +83 -0
  1362. package/src/discovery/codex.ts +530 -0
  1363. package/src/discovery/cursor.ts +220 -0
  1364. package/src/discovery/gemini.ts +383 -0
  1365. package/src/discovery/github.ts +337 -0
  1366. package/src/discovery/helpers.ts +1102 -0
  1367. package/src/discovery/index.ts +81 -0
  1368. package/src/discovery/mcp-json.ts +172 -0
  1369. package/src/discovery/omp-extension-roots.ts +213 -0
  1370. package/src/discovery/omp-plugins.ts +383 -0
  1371. package/src/discovery/opencode.ts +441 -0
  1372. package/src/discovery/plugin-dir-roots.ts +28 -0
  1373. package/src/discovery/ssh.ts +153 -0
  1374. package/src/discovery/substitute-plugin-root.ts +29 -0
  1375. package/src/discovery/vscode.ts +105 -0
  1376. package/src/discovery/windsurf.ts +147 -0
  1377. package/src/edit/apply-patch/index.ts +87 -0
  1378. package/src/edit/apply-patch/parser.ts +174 -0
  1379. package/src/edit/diff.ts +999 -0
  1380. package/src/edit/file-snapshot-store.ts +157 -0
  1381. package/src/edit/hashline/block-resolver.ts +33 -0
  1382. package/src/edit/hashline/diff.ts +356 -0
  1383. package/src/edit/hashline/execute.ts +279 -0
  1384. package/src/edit/hashline/filesystem.ts +205 -0
  1385. package/src/edit/hashline/index.ts +5 -0
  1386. package/src/edit/hashline/noop-loop-guard.ts +99 -0
  1387. package/src/edit/hashline/params.ts +12 -0
  1388. package/src/edit/index.ts +705 -0
  1389. package/src/edit/modes/apply-patch.lark +19 -0
  1390. package/src/edit/modes/apply-patch.ts +53 -0
  1391. package/src/edit/modes/patch.ts +1950 -0
  1392. package/src/edit/modes/replace.ts +1137 -0
  1393. package/src/edit/normalize.ts +345 -0
  1394. package/src/edit/notebook.ts +242 -0
  1395. package/src/edit/read-file.ts +25 -0
  1396. package/src/edit/renderer.ts +969 -0
  1397. package/src/edit/snapshot-details.ts +77 -0
  1398. package/src/edit/streaming.ts +698 -0
  1399. package/src/eval/__tests__/agent-bridge.test.ts +1399 -0
  1400. package/src/eval/__tests__/bridge-timeout.test.ts +64 -0
  1401. package/src/eval/__tests__/budget-bridge.test.ts +69 -0
  1402. package/src/eval/__tests__/completion-bridge.test.ts +412 -0
  1403. package/src/eval/__tests__/helpers-local-roots.test.ts +55 -0
  1404. package/src/eval/__tests__/idle-timeout.test.ts +80 -0
  1405. package/src/eval/__tests__/js-context-manager.test.ts +291 -0
  1406. package/src/eval/__tests__/julia-prelude.test.ts +66 -0
  1407. package/src/eval/__tests__/kernel-spawn.test.ts +103 -0
  1408. package/src/eval/__tests__/prelude-agent.test.ts +107 -0
  1409. package/src/eval/agent-bridge.ts +584 -0
  1410. package/src/eval/backend-helpers.ts +48 -0
  1411. package/src/eval/backend.ts +71 -0
  1412. package/src/eval/bridge-timeout.ts +44 -0
  1413. package/src/eval/budget-bridge.ts +48 -0
  1414. package/src/eval/completion-bridge.ts +211 -0
  1415. package/src/eval/concurrency-bridge.ts +34 -0
  1416. package/src/eval/executor-base.ts +425 -0
  1417. package/src/eval/idle-timeout.ts +91 -0
  1418. package/src/eval/index.ts +6 -0
  1419. package/src/eval/jl/executor.ts +540 -0
  1420. package/src/eval/jl/index.ts +54 -0
  1421. package/src/eval/jl/kernel.ts +235 -0
  1422. package/src/eval/jl/prelude.jl +735 -0
  1423. package/src/eval/jl/prelude.ts +3 -0
  1424. package/src/eval/jl/runner.jl +666 -0
  1425. package/src/eval/jl/runtime.ts +118 -0
  1426. package/src/eval/js/context-manager.ts +621 -0
  1427. package/src/eval/js/executor.ts +173 -0
  1428. package/src/eval/js/index.ts +40 -0
  1429. package/src/eval/js/shared/helpers.ts +170 -0
  1430. package/src/eval/js/shared/indirect-eval.ts +30 -0
  1431. package/src/eval/js/shared/local-module-loader.ts +364 -0
  1432. package/src/eval/js/shared/prelude.ts +2 -0
  1433. package/src/eval/js/shared/prelude.txt +293 -0
  1434. package/src/eval/js/shared/rewrite-imports.ts +532 -0
  1435. package/src/eval/js/shared/runtime.ts +574 -0
  1436. package/src/eval/js/shared/types.ts +18 -0
  1437. package/src/eval/js/tool-bridge.ts +163 -0
  1438. package/src/eval/js/worker-core.ts +151 -0
  1439. package/src/eval/js/worker-entry.ts +37 -0
  1440. package/src/eval/js/worker-protocol.ts +47 -0
  1441. package/src/eval/kernel-base.ts +569 -0
  1442. package/src/eval/py/__tests__/prelude.test.ts +32 -0
  1443. package/src/eval/py/__tests__/runner-shell-output.test.ts +157 -0
  1444. package/src/eval/py/display.ts +71 -0
  1445. package/src/eval/py/executor.ts +533 -0
  1446. package/src/eval/py/index.ts +57 -0
  1447. package/src/eval/py/kernel.ts +233 -0
  1448. package/src/eval/py/prelude.py +625 -0
  1449. package/src/eval/py/prelude.ts +3 -0
  1450. package/src/eval/py/runner.py +1322 -0
  1451. package/src/eval/py/runtime.ts +276 -0
  1452. package/src/eval/py/spawn-options.ts +126 -0
  1453. package/src/eval/py/tool-bridge.ts +182 -0
  1454. package/src/eval/rb/executor.ts +504 -0
  1455. package/src/eval/rb/index.ts +54 -0
  1456. package/src/eval/rb/kernel.ts +230 -0
  1457. package/src/eval/rb/prelude.rb +553 -0
  1458. package/src/eval/rb/prelude.ts +3 -0
  1459. package/src/eval/rb/runner.rb +581 -0
  1460. package/src/eval/rb/runtime.ts +132 -0
  1461. package/src/eval/runtime-env.ts +104 -0
  1462. package/src/eval/session-id.ts +8 -0
  1463. package/src/eval/types.ts +48 -0
  1464. package/src/exa/index.ts +2 -0
  1465. package/src/exa/mcp-client.ts +370 -0
  1466. package/src/exa/types.ts +69 -0
  1467. package/src/exec/bash-executor.ts +473 -0
  1468. package/src/exec/exec.ts +53 -0
  1469. package/src/exec/non-interactive-env.ts +119 -0
  1470. package/src/export/custom-share.ts +65 -0
  1471. package/src/export/html/index.ts +308 -0
  1472. package/src/export/html/share-loader.js +102 -0
  1473. package/src/export/html/template.css +1337 -0
  1474. package/src/export/html/template.html +49 -0
  1475. package/src/export/html/template.js +1634 -0
  1476. package/src/export/html/tool-views.generated.js +37 -0
  1477. package/src/export/html/vendor/highlight.min.js +1213 -0
  1478. package/src/export/html/vendor/marked.min.js +6 -0
  1479. package/src/export/html/web-palette.ts +142 -0
  1480. package/src/export/share.ts +481 -0
  1481. package/src/export/ttsr.ts +583 -0
  1482. package/src/extensibility/custom-commands/bundled/ci-green/index.ts +54 -0
  1483. package/src/extensibility/custom-commands/bundled/review/index.ts +698 -0
  1484. package/src/extensibility/custom-commands/index.ts +2 -0
  1485. package/src/extensibility/custom-commands/loader.ts +242 -0
  1486. package/src/extensibility/custom-commands/types.ts +119 -0
  1487. package/src/extensibility/custom-tools/index.ts +7 -0
  1488. package/src/extensibility/custom-tools/loader.ts +268 -0
  1489. package/src/extensibility/custom-tools/types.ts +280 -0
  1490. package/src/extensibility/custom-tools/wrapper.ts +47 -0
  1491. package/src/extensibility/extensions/compact-handler.ts +40 -0
  1492. package/src/extensibility/extensions/get-commands-handler.ts +78 -0
  1493. package/src/extensibility/extensions/index.ts +16 -0
  1494. package/src/extensibility/extensions/loader.ts +596 -0
  1495. package/src/extensibility/extensions/model-api.ts +39 -0
  1496. package/src/extensibility/extensions/runner.ts +1039 -0
  1497. package/src/extensibility/extensions/types.ts +1394 -0
  1498. package/src/extensibility/extensions/wrapper.ts +266 -0
  1499. package/src/extensibility/hooks/index.ts +6 -0
  1500. package/src/extensibility/hooks/loader.ts +244 -0
  1501. package/src/extensibility/hooks/runner.ts +425 -0
  1502. package/src/extensibility/hooks/tool-wrapper.ts +117 -0
  1503. package/src/extensibility/hooks/types.ts +613 -0
  1504. package/src/extensibility/legacy-pi-ai-shim.ts +73 -0
  1505. package/src/extensibility/legacy-pi-coding-agent-shim.ts +646 -0
  1506. package/src/extensibility/plugins/doctor.ts +65 -0
  1507. package/src/extensibility/plugins/git-url.ts +367 -0
  1508. package/src/extensibility/plugins/index.ts +9 -0
  1509. package/src/extensibility/plugins/installer.ts +201 -0
  1510. package/src/extensibility/plugins/legacy-pi-bundled-keys.ts +1011 -0
  1511. package/src/extensibility/plugins/legacy-pi-bundled-registry.ts +3430 -0
  1512. package/src/extensibility/plugins/legacy-pi-compat.ts +1141 -0
  1513. package/src/extensibility/plugins/loader.ts +535 -0
  1514. package/src/extensibility/plugins/manager.ts +1121 -0
  1515. package/src/extensibility/plugins/marketplace/cache.ts +136 -0
  1516. package/src/extensibility/plugins/marketplace/fetcher.ts +315 -0
  1517. package/src/extensibility/plugins/marketplace/index.ts +6 -0
  1518. package/src/extensibility/plugins/marketplace/manager.ts +926 -0
  1519. package/src/extensibility/plugins/marketplace/registry.ts +196 -0
  1520. package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
  1521. package/src/extensibility/plugins/marketplace/types.ts +192 -0
  1522. package/src/extensibility/plugins/marketplace-auto-update.ts +49 -0
  1523. package/src/extensibility/plugins/parser.ts +107 -0
  1524. package/src/extensibility/plugins/runtime-config.ts +9 -0
  1525. package/src/extensibility/plugins/types.ts +194 -0
  1526. package/src/extensibility/session-handler-types.ts +21 -0
  1527. package/src/extensibility/shared-events.ts +376 -0
  1528. package/src/extensibility/skills.ts +508 -0
  1529. package/src/extensibility/slash-commands.ts +131 -0
  1530. package/src/extensibility/tool-event-input.ts +80 -0
  1531. package/src/extensibility/tool-proxy.ts +28 -0
  1532. package/src/extensibility/typebox.ts +945 -0
  1533. package/src/extensibility/utils.ts +118 -0
  1534. package/src/goals/guided-setup.ts +143 -0
  1535. package/src/goals/index.ts +3 -0
  1536. package/src/goals/runtime.ts +521 -0
  1537. package/src/goals/state.ts +37 -0
  1538. package/src/goals/tools/goal-tool.ts +251 -0
  1539. package/src/hindsight/backend.ts +354 -0
  1540. package/src/hindsight/bank.ts +156 -0
  1541. package/src/hindsight/client.test.ts +33 -0
  1542. package/src/hindsight/client.ts +643 -0
  1543. package/src/hindsight/config.ts +175 -0
  1544. package/src/hindsight/content.ts +266 -0
  1545. package/src/hindsight/index.ts +8 -0
  1546. package/src/hindsight/mental-models.ts +429 -0
  1547. package/src/hindsight/seeds.json +32 -0
  1548. package/src/hindsight/state.ts +492 -0
  1549. package/src/hindsight/transcript.ts +71 -0
  1550. package/src/index.ts +66 -0
  1551. package/src/internal-urls/__tests__/ssh-protocol.test.ts +331 -0
  1552. package/src/internal-urls/agent-protocol.ts +146 -0
  1553. package/src/internal-urls/artifact-protocol.ts +151 -0
  1554. package/src/internal-urls/docs-index.generated.txt +2 -0
  1555. package/src/internal-urls/docs-index.ts +101 -0
  1556. package/src/internal-urls/filesystem-resource.ts +34 -0
  1557. package/src/internal-urls/history-protocol.ts +118 -0
  1558. package/src/internal-urls/index.ts +26 -0
  1559. package/src/internal-urls/issue-pr-protocol.ts +594 -0
  1560. package/src/internal-urls/json-query.ts +126 -0
  1561. package/src/internal-urls/local-protocol.ts +469 -0
  1562. package/src/internal-urls/mcp-protocol.ts +151 -0
  1563. package/src/internal-urls/memory-protocol.ts +173 -0
  1564. package/src/internal-urls/omp-protocol.ts +94 -0
  1565. package/src/internal-urls/parse.ts +72 -0
  1566. package/src/internal-urls/registry-helpers.ts +40 -0
  1567. package/src/internal-urls/router.ts +107 -0
  1568. package/src/internal-urls/rule-protocol.ts +45 -0
  1569. package/src/internal-urls/skill-protocol.ts +112 -0
  1570. package/src/internal-urls/ssh-protocol.ts +367 -0
  1571. package/src/internal-urls/types.ts +182 -0
  1572. package/src/internal-urls/vault-protocol.ts +939 -0
  1573. package/src/irc/bus.ts +320 -0
  1574. package/src/jsonrpc/message-framing.ts +142 -0
  1575. package/src/lib/xai-http.ts +124 -0
  1576. package/src/lsp/client.ts +1249 -0
  1577. package/src/lsp/clients/biome-client.ts +264 -0
  1578. package/src/lsp/clients/index.ts +50 -0
  1579. package/src/lsp/clients/lsp-linter-client.ts +85 -0
  1580. package/src/lsp/clients/swiftlint-client.ts +120 -0
  1581. package/src/lsp/config.ts +531 -0
  1582. package/src/lsp/defaults.json +499 -0
  1583. package/src/lsp/diagnostics-ledger.ts +51 -0
  1584. package/src/lsp/edits.ts +288 -0
  1585. package/src/lsp/format-options.ts +119 -0
  1586. package/src/lsp/index.ts +2539 -0
  1587. package/src/lsp/lspmux.ts +233 -0
  1588. package/src/lsp/render.ts +668 -0
  1589. package/src/lsp/startup-events.ts +13 -0
  1590. package/src/lsp/types.ts +444 -0
  1591. package/src/lsp/utils.ts +718 -0
  1592. package/src/main.ts +1474 -0
  1593. package/src/markit/NOTICE +32 -0
  1594. package/src/markit/converters/docx.ts +56 -0
  1595. package/src/markit/converters/epub.ts +136 -0
  1596. package/src/markit/converters/mammoth.d.ts +24 -0
  1597. package/src/markit/converters/pdf/columns.ts +103 -0
  1598. package/src/markit/converters/pdf/extract.ts +574 -0
  1599. package/src/markit/converters/pdf/grid.ts +780 -0
  1600. package/src/markit/converters/pdf/headers.ts +106 -0
  1601. package/src/markit/converters/pdf/index.ts +146 -0
  1602. package/src/markit/converters/pdf/render.ts +501 -0
  1603. package/src/markit/converters/pdf/types.ts +84 -0
  1604. package/src/markit/converters/pptx.ts +325 -0
  1605. package/src/markit/converters/xlsx.ts +173 -0
  1606. package/src/markit/index.ts +2 -0
  1607. package/src/markit/registry.ts +59 -0
  1608. package/src/markit/types.ts +35 -0
  1609. package/src/mcp/client.ts +511 -0
  1610. package/src/mcp/config-writer.ts +350 -0
  1611. package/src/mcp/config.ts +369 -0
  1612. package/src/mcp/index.ts +29 -0
  1613. package/src/mcp/json-rpc.ts +122 -0
  1614. package/src/mcp/loader.ts +125 -0
  1615. package/src/mcp/manager.ts +1362 -0
  1616. package/src/mcp/oauth-credentials.ts +104 -0
  1617. package/src/mcp/oauth-discovery.ts +560 -0
  1618. package/src/mcp/oauth-flow.ts +787 -0
  1619. package/src/mcp/render.ts +155 -0
  1620. package/src/mcp/smithery-auth.ts +107 -0
  1621. package/src/mcp/smithery-connect.ts +154 -0
  1622. package/src/mcp/smithery-registry.test.ts +51 -0
  1623. package/src/mcp/smithery-registry.ts +500 -0
  1624. package/src/mcp/startup-events.ts +116 -0
  1625. package/src/mcp/timeout.ts +59 -0
  1626. package/src/mcp/tool-bridge.ts +484 -0
  1627. package/src/mcp/tool-cache.ts +117 -0
  1628. package/src/mcp/transports/http.ts +523 -0
  1629. package/src/mcp/transports/index.ts +7 -0
  1630. package/src/mcp/transports/sse.ts +377 -0
  1631. package/src/mcp/transports/stdio.test.ts +95 -0
  1632. package/src/mcp/transports/stdio.ts +663 -0
  1633. package/src/mcp/types.ts +430 -0
  1634. package/src/memories/index.ts +1395 -0
  1635. package/src/memories/storage.ts +578 -0
  1636. package/src/memory-backend/index.ts +18 -0
  1637. package/src/memory-backend/local-backend.ts +47 -0
  1638. package/src/memory-backend/off-backend.ts +25 -0
  1639. package/src/memory-backend/resolve.ts +25 -0
  1640. package/src/memory-backend/runtime.ts +66 -0
  1641. package/src/memory-backend/types.ts +166 -0
  1642. package/src/mnemopi/backend.ts +612 -0
  1643. package/src/mnemopi/config.ts +267 -0
  1644. package/src/mnemopi/embed-client.ts +246 -0
  1645. package/src/mnemopi/embed-protocol.ts +35 -0
  1646. package/src/mnemopi/embed-worker.ts +113 -0
  1647. package/src/mnemopi/index.ts +3 -0
  1648. package/src/mnemopi/state.ts +722 -0
  1649. package/src/modes/acp/acp-agent.ts +2372 -0
  1650. package/src/modes/acp/acp-client-bridge.ts +154 -0
  1651. package/src/modes/acp/acp-event-mapper.ts +1002 -0
  1652. package/src/modes/acp/acp-mode.ts +23 -0
  1653. package/src/modes/acp/index.ts +2 -0
  1654. package/src/modes/acp/terminal-auth.ts +37 -0
  1655. package/src/modes/components/__tests__/move-overlay.test.ts +237 -0
  1656. package/src/modes/components/__tests__/skill-message.test.ts +92 -0
  1657. package/src/modes/components/advisor-config.ts +555 -0
  1658. package/src/modes/components/advisor-message.ts +109 -0
  1659. package/src/modes/components/agent-dashboard.ts +1183 -0
  1660. package/src/modes/components/agent-hub.ts +586 -0
  1661. package/src/modes/components/agent-transcript-viewer.ts +649 -0
  1662. package/src/modes/components/assistant-message.ts +869 -0
  1663. package/src/modes/components/background-tan-message.ts +36 -0
  1664. package/src/modes/components/bash-execution.ts +229 -0
  1665. package/src/modes/components/bordered-loader.ts +41 -0
  1666. package/src/modes/components/btw-panel.ts +124 -0
  1667. package/src/modes/components/cache-invalidation-marker.ts +110 -0
  1668. package/src/modes/components/chat-block.ts +111 -0
  1669. package/src/modes/components/chat-transcript-builder.ts +449 -0
  1670. package/src/modes/components/collab-prompt-message.ts +32 -0
  1671. package/src/modes/components/compaction-summary-message.ts +215 -0
  1672. package/src/modes/components/copy-selector.ts +206 -0
  1673. package/src/modes/components/countdown-timer.ts +75 -0
  1674. package/src/modes/components/custom-editor.test.ts +283 -0
  1675. package/src/modes/components/custom-editor.ts +835 -0
  1676. package/src/modes/components/custom-message.ts +67 -0
  1677. package/src/modes/components/diff.ts +254 -0
  1678. package/src/modes/components/dynamic-border.ts +34 -0
  1679. package/src/modes/components/error-banner.ts +33 -0
  1680. package/src/modes/components/eval-execution.ts +167 -0
  1681. package/src/modes/components/execution-shared.ts +101 -0
  1682. package/src/modes/components/extensions/extension-dashboard.ts +492 -0
  1683. package/src/modes/components/extensions/extension-list.ts +507 -0
  1684. package/src/modes/components/extensions/index.ts +9 -0
  1685. package/src/modes/components/extensions/inspector-panel.ts +321 -0
  1686. package/src/modes/components/extensions/state-manager.ts +648 -0
  1687. package/src/modes/components/extensions/types.ts +186 -0
  1688. package/src/modes/components/footer.ts +276 -0
  1689. package/src/modes/components/history-search.ts +268 -0
  1690. package/src/modes/components/hook-editor.ts +183 -0
  1691. package/src/modes/components/hook-input.ts +87 -0
  1692. package/src/modes/components/hook-message.ts +67 -0
  1693. package/src/modes/components/hook-selector.ts +678 -0
  1694. package/src/modes/components/index.ts +40 -0
  1695. package/src/modes/components/keybinding-hints.ts +65 -0
  1696. package/src/modes/components/late-diagnostics-message.ts +60 -0
  1697. package/src/modes/components/login-dialog.ts +178 -0
  1698. package/src/modes/components/logout-account-selector.ts +130 -0
  1699. package/src/modes/components/mcp-add-wizard.ts +1408 -0
  1700. package/src/modes/components/message-frame.ts +92 -0
  1701. package/src/modes/components/model-selector.ts +1267 -0
  1702. package/src/modes/components/move-overlay.ts +294 -0
  1703. package/src/modes/components/oauth-selector.ts +457 -0
  1704. package/src/modes/components/omfg-panel.ts +141 -0
  1705. package/src/modes/components/overlay-box.ts +109 -0
  1706. package/src/modes/components/plan-review-overlay.ts +847 -0
  1707. package/src/modes/components/plan-toc.ts +138 -0
  1708. package/src/modes/components/plugin-selector.ts +100 -0
  1709. package/src/modes/components/plugin-settings.ts +745 -0
  1710. package/src/modes/components/queue-mode-selector.ts +61 -0
  1711. package/src/modes/components/read-tool-group.ts +676 -0
  1712. package/src/modes/components/reset-usage-selector.ts +161 -0
  1713. package/src/modes/components/segment-track.ts +89 -0
  1714. package/src/modes/components/select-list-mouse-routing.ts +35 -0
  1715. package/src/modes/components/selector-helpers.ts +129 -0
  1716. package/src/modes/components/session-selector.ts +744 -0
  1717. package/src/modes/components/settings-defs.ts +238 -0
  1718. package/src/modes/components/settings-selector.ts +1265 -0
  1719. package/src/modes/components/show-images-selector.ts +50 -0
  1720. package/src/modes/components/skill-message.ts +110 -0
  1721. package/src/modes/components/snapcompact-shape-preview-doc.md +18 -0
  1722. package/src/modes/components/snapcompact-shape-preview.ts +192 -0
  1723. package/src/modes/components/status-line/component.test.ts +44 -0
  1724. package/src/modes/components/status-line/component.ts +1308 -0
  1725. package/src/modes/components/status-line/context-thresholds.ts +86 -0
  1726. package/src/modes/components/status-line/git-utils.ts +42 -0
  1727. package/src/modes/components/status-line/index.ts +5 -0
  1728. package/src/modes/components/status-line/presets.ts +106 -0
  1729. package/src/modes/components/status-line/segments.ts +663 -0
  1730. package/src/modes/components/status-line/separators.ts +55 -0
  1731. package/src/modes/components/status-line/token-rate.ts +66 -0
  1732. package/src/modes/components/status-line/types.ts +147 -0
  1733. package/src/modes/components/theme-selector.ts +68 -0
  1734. package/src/modes/components/thinking-selector.ts +57 -0
  1735. package/src/modes/components/tiny-title-download-progress.ts +90 -0
  1736. package/src/modes/components/tips.txt +24 -0
  1737. package/src/modes/components/todo-reminder.ts +43 -0
  1738. package/src/modes/components/tool-execution.ts +1308 -0
  1739. package/src/modes/components/transcript-container.ts +456 -0
  1740. package/src/modes/components/tree-selector.ts +1002 -0
  1741. package/src/modes/components/ttsr-notification.ts +123 -0
  1742. package/src/modes/components/usage-row.ts +32 -0
  1743. package/src/modes/components/user-message-selector.ts +227 -0
  1744. package/src/modes/components/user-message.ts +68 -0
  1745. package/src/modes/components/visual-truncate.ts +63 -0
  1746. package/src/modes/components/welcome.ts +579 -0
  1747. package/src/modes/controllers/btw-controller.ts +198 -0
  1748. package/src/modes/controllers/command-controller-shared.ts +109 -0
  1749. package/src/modes/controllers/command-controller.ts +1751 -0
  1750. package/src/modes/controllers/event-controller.ts +1497 -0
  1751. package/src/modes/controllers/extension-ui-controller.ts +977 -0
  1752. package/src/modes/controllers/input-controller.ts +1851 -0
  1753. package/src/modes/controllers/mcp-command-controller.ts +2364 -0
  1754. package/src/modes/controllers/omfg-controller.ts +283 -0
  1755. package/src/modes/controllers/omfg-rule.ts +647 -0
  1756. package/src/modes/controllers/selector-controller.ts +1443 -0
  1757. package/src/modes/controllers/session-focus-controller.ts +112 -0
  1758. package/src/modes/controllers/ssh-command-controller.ts +384 -0
  1759. package/src/modes/controllers/streaming-reveal.ts +392 -0
  1760. package/src/modes/controllers/tan-command-controller.ts +190 -0
  1761. package/src/modes/controllers/todo-command-controller.ts +484 -0
  1762. package/src/modes/controllers/tool-args-reveal.ts +582 -0
  1763. package/src/modes/data/emojis.json +1 -0
  1764. package/src/modes/emoji-autocomplete.ts +285 -0
  1765. package/src/modes/gradient-highlight.ts +99 -0
  1766. package/src/modes/image-references.ts +137 -0
  1767. package/src/modes/index.ts +17 -0
  1768. package/src/modes/interactive-mode.ts +4223 -0
  1769. package/src/modes/internal-url-autocomplete.ts +158 -0
  1770. package/src/modes/loop-limit.ts +192 -0
  1771. package/src/modes/magic-keywords.ts +42 -0
  1772. package/src/modes/markdown-prose.ts +247 -0
  1773. package/src/modes/oauth-manual-input.ts +69 -0
  1774. package/src/modes/orchestrate.ts +42 -0
  1775. package/src/modes/print-mode.ts +130 -0
  1776. package/src/modes/prompt-action-autocomplete.ts +262 -0
  1777. package/src/modes/rpc/host-tools.ts +186 -0
  1778. package/src/modes/rpc/host-uris.ts +235 -0
  1779. package/src/modes/rpc/rpc-client.ts +1033 -0
  1780. package/src/modes/rpc/rpc-mode.ts +1311 -0
  1781. package/src/modes/rpc/rpc-subagents.ts +265 -0
  1782. package/src/modes/rpc/rpc-types.ts +499 -0
  1783. package/src/modes/running-subagent-badge.ts +13 -0
  1784. package/src/modes/runtime-init.ts +142 -0
  1785. package/src/modes/session-observer-registry.ts +215 -0
  1786. package/src/modes/session-teardown.test.ts +219 -0
  1787. package/src/modes/session-teardown.ts +82 -0
  1788. package/src/modes/setup-version.ts +11 -0
  1789. package/src/modes/setup-wizard/index.ts +101 -0
  1790. package/src/modes/setup-wizard/lazy.ts +16 -0
  1791. package/src/modes/setup-wizard/scenes/glyph.ts +103 -0
  1792. package/src/modes/setup-wizard/scenes/outro.ts +35 -0
  1793. package/src/modes/setup-wizard/scenes/providers.ts +104 -0
  1794. package/src/modes/setup-wizard/scenes/sign-in.ts +304 -0
  1795. package/src/modes/setup-wizard/scenes/splash.ts +201 -0
  1796. package/src/modes/setup-wizard/scenes/theme.ts +320 -0
  1797. package/src/modes/setup-wizard/scenes/types.ts +57 -0
  1798. package/src/modes/setup-wizard/scenes/web-search.ts +140 -0
  1799. package/src/modes/setup-wizard/startup-splash.ts +107 -0
  1800. package/src/modes/setup-wizard/wizard-overlay.ts +335 -0
  1801. package/src/modes/shared.ts +49 -0
  1802. package/src/modes/skill-command.ts +91 -0
  1803. package/src/modes/theme/dark.json +95 -0
  1804. package/src/modes/theme/defaults/alabaster.json +93 -0
  1805. package/src/modes/theme/defaults/amethyst.json +96 -0
  1806. package/src/modes/theme/defaults/anthracite.json +93 -0
  1807. package/src/modes/theme/defaults/basalt.json +91 -0
  1808. package/src/modes/theme/defaults/birch.json +95 -0
  1809. package/src/modes/theme/defaults/dark-abyss.json +91 -0
  1810. package/src/modes/theme/defaults/dark-arctic.json +104 -0
  1811. package/src/modes/theme/defaults/dark-aurora.json +95 -0
  1812. package/src/modes/theme/defaults/dark-catppuccin.json +107 -0
  1813. package/src/modes/theme/defaults/dark-cavern.json +91 -0
  1814. package/src/modes/theme/defaults/dark-copper.json +95 -0
  1815. package/src/modes/theme/defaults/dark-cosmos.json +90 -0
  1816. package/src/modes/theme/defaults/dark-cyberpunk.json +102 -0
  1817. package/src/modes/theme/defaults/dark-dracula.json +98 -0
  1818. package/src/modes/theme/defaults/dark-eclipse.json +91 -0
  1819. package/src/modes/theme/defaults/dark-ember.json +95 -0
  1820. package/src/modes/theme/defaults/dark-equinox.json +90 -0
  1821. package/src/modes/theme/defaults/dark-forest.json +96 -0
  1822. package/src/modes/theme/defaults/dark-github.json +105 -0
  1823. package/src/modes/theme/defaults/dark-gruvbox.json +112 -0
  1824. package/src/modes/theme/defaults/dark-lavender.json +95 -0
  1825. package/src/modes/theme/defaults/dark-lunar.json +89 -0
  1826. package/src/modes/theme/defaults/dark-midnight.json +95 -0
  1827. package/src/modes/theme/defaults/dark-monochrome.json +94 -0
  1828. package/src/modes/theme/defaults/dark-monokai.json +98 -0
  1829. package/src/modes/theme/defaults/dark-nebula.json +90 -0
  1830. package/src/modes/theme/defaults/dark-nord.json +97 -0
  1831. package/src/modes/theme/defaults/dark-ocean.json +101 -0
  1832. package/src/modes/theme/defaults/dark-one.json +100 -0
  1833. package/src/modes/theme/defaults/dark-poimandres.json +142 -0
  1834. package/src/modes/theme/defaults/dark-rainforest.json +91 -0
  1835. package/src/modes/theme/defaults/dark-reef.json +91 -0
  1836. package/src/modes/theme/defaults/dark-retro.json +92 -0
  1837. package/src/modes/theme/defaults/dark-rose-pine.json +96 -0
  1838. package/src/modes/theme/defaults/dark-sakura.json +95 -0
  1839. package/src/modes/theme/defaults/dark-slate.json +95 -0
  1840. package/src/modes/theme/defaults/dark-solarized.json +97 -0
  1841. package/src/modes/theme/defaults/dark-solstice.json +90 -0
  1842. package/src/modes/theme/defaults/dark-starfall.json +91 -0
  1843. package/src/modes/theme/defaults/dark-sunset.json +99 -0
  1844. package/src/modes/theme/defaults/dark-swamp.json +90 -0
  1845. package/src/modes/theme/defaults/dark-synthwave.json +103 -0
  1846. package/src/modes/theme/defaults/dark-taiga.json +91 -0
  1847. package/src/modes/theme/defaults/dark-terminal.json +95 -0
  1848. package/src/modes/theme/defaults/dark-tokyo-night.json +101 -0
  1849. package/src/modes/theme/defaults/dark-tundra.json +91 -0
  1850. package/src/modes/theme/defaults/dark-twilight.json +91 -0
  1851. package/src/modes/theme/defaults/dark-volcanic.json +91 -0
  1852. package/src/modes/theme/defaults/graphite.json +92 -0
  1853. package/src/modes/theme/defaults/index.ts +199 -0
  1854. package/src/modes/theme/defaults/light-arctic.json +107 -0
  1855. package/src/modes/theme/defaults/light-aurora-day.json +91 -0
  1856. package/src/modes/theme/defaults/light-canyon.json +91 -0
  1857. package/src/modes/theme/defaults/light-catppuccin.json +106 -0
  1858. package/src/modes/theme/defaults/light-cirrus.json +90 -0
  1859. package/src/modes/theme/defaults/light-coral.json +95 -0
  1860. package/src/modes/theme/defaults/light-cyberpunk.json +96 -0
  1861. package/src/modes/theme/defaults/light-dawn.json +90 -0
  1862. package/src/modes/theme/defaults/light-dunes.json +91 -0
  1863. package/src/modes/theme/defaults/light-eucalyptus.json +95 -0
  1864. package/src/modes/theme/defaults/light-forest.json +100 -0
  1865. package/src/modes/theme/defaults/light-frost.json +95 -0
  1866. package/src/modes/theme/defaults/light-github.json +115 -0
  1867. package/src/modes/theme/defaults/light-glacier.json +91 -0
  1868. package/src/modes/theme/defaults/light-gruvbox.json +108 -0
  1869. package/src/modes/theme/defaults/light-haze.json +90 -0
  1870. package/src/modes/theme/defaults/light-honeycomb.json +95 -0
  1871. package/src/modes/theme/defaults/light-lagoon.json +91 -0
  1872. package/src/modes/theme/defaults/light-lavender.json +95 -0
  1873. package/src/modes/theme/defaults/light-meadow.json +91 -0
  1874. package/src/modes/theme/defaults/light-mint.json +95 -0
  1875. package/src/modes/theme/defaults/light-monochrome.json +101 -0
  1876. package/src/modes/theme/defaults/light-ocean.json +99 -0
  1877. package/src/modes/theme/defaults/light-one.json +99 -0
  1878. package/src/modes/theme/defaults/light-opal.json +91 -0
  1879. package/src/modes/theme/defaults/light-orchard.json +91 -0
  1880. package/src/modes/theme/defaults/light-paper.json +95 -0
  1881. package/src/modes/theme/defaults/light-poimandres.json +142 -0
  1882. package/src/modes/theme/defaults/light-prism.json +90 -0
  1883. package/src/modes/theme/defaults/light-retro.json +98 -0
  1884. package/src/modes/theme/defaults/light-sand.json +95 -0
  1885. package/src/modes/theme/defaults/light-savanna.json +91 -0
  1886. package/src/modes/theme/defaults/light-solarized.json +102 -0
  1887. package/src/modes/theme/defaults/light-soleil.json +90 -0
  1888. package/src/modes/theme/defaults/light-sunset.json +99 -0
  1889. package/src/modes/theme/defaults/light-synthwave.json +98 -0
  1890. package/src/modes/theme/defaults/light-tokyo-night.json +111 -0
  1891. package/src/modes/theme/defaults/light-wetland.json +91 -0
  1892. package/src/modes/theme/defaults/light-zenith.json +89 -0
  1893. package/src/modes/theme/defaults/limestone.json +94 -0
  1894. package/src/modes/theme/defaults/mahogany.json +97 -0
  1895. package/src/modes/theme/defaults/marble.json +93 -0
  1896. package/src/modes/theme/defaults/obsidian.json +91 -0
  1897. package/src/modes/theme/defaults/onyx.json +91 -0
  1898. package/src/modes/theme/defaults/pearl.json +93 -0
  1899. package/src/modes/theme/defaults/porcelain.json +91 -0
  1900. package/src/modes/theme/defaults/quartz.json +96 -0
  1901. package/src/modes/theme/defaults/sandstone.json +95 -0
  1902. package/src/modes/theme/defaults/titanium.json +90 -0
  1903. package/src/modes/theme/light.json +93 -0
  1904. package/src/modes/theme/mermaid-cache.ts +92 -0
  1905. package/src/modes/theme/mermaid-rendering.test.ts +53 -0
  1906. package/src/modes/theme/shimmer.ts +269 -0
  1907. package/src/modes/theme/theme-schema.json +459 -0
  1908. package/src/modes/theme/theme.ts +3004 -0
  1909. package/src/modes/turn-budget.ts +31 -0
  1910. package/src/modes/types.ts +437 -0
  1911. package/src/modes/ultrathink.ts +41 -0
  1912. package/src/modes/utils/context-usage.ts +432 -0
  1913. package/src/modes/utils/copy-targets.ts +378 -0
  1914. package/src/modes/utils/hotkeys-markdown.ts +62 -0
  1915. package/src/modes/utils/interactive-context-helpers.ts +27 -0
  1916. package/src/modes/utils/keybinding-matchers.ts +86 -0
  1917. package/src/modes/utils/tools-markdown.ts +27 -0
  1918. package/src/modes/utils/transcript-render-helpers.ts +184 -0
  1919. package/src/modes/utils/ui-helpers.ts +864 -0
  1920. package/src/modes/workflow.ts +42 -0
  1921. package/src/plan-mode/approved-plan-prompt.test.ts +36 -0
  1922. package/src/plan-mode/approved-plan.ts +186 -0
  1923. package/src/plan-mode/plan-handoff.ts +37 -0
  1924. package/src/plan-mode/plan-protection.ts +31 -0
  1925. package/src/plan-mode/state.ts +6 -0
  1926. package/src/priority.json +60 -0
  1927. package/src/prompts/advisor/active-repo-watchdog.md +6 -0
  1928. package/src/prompts/advisor/advise-tool.md +3 -0
  1929. package/src/prompts/advisor/context-files.md +8 -0
  1930. package/src/prompts/advisor/system.md +89 -0
  1931. package/src/prompts/agents/designer.md +74 -0
  1932. package/src/prompts/agents/explore.md +58 -0
  1933. package/src/prompts/agents/frontmatter.md +11 -0
  1934. package/src/prompts/agents/init.md +33 -0
  1935. package/src/prompts/agents/librarian.md +119 -0
  1936. package/src/prompts/agents/plan.md +48 -0
  1937. package/src/prompts/agents/reviewer.md +140 -0
  1938. package/src/prompts/agents/task.md +17 -0
  1939. package/src/prompts/agents/tester.md +111 -0
  1940. package/src/prompts/bench.md +6 -0
  1941. package/src/prompts/ci-green-request.md +36 -0
  1942. package/src/prompts/dry-balance-bench.md +8 -0
  1943. package/src/prompts/goals/goal-budget-limit.md +16 -0
  1944. package/src/prompts/goals/goal-continuation.md +28 -0
  1945. package/src/prompts/goals/goal-mode-active.md +23 -0
  1946. package/src/prompts/goals/goal-mode-context.md +4 -0
  1947. package/src/prompts/goals/goal-todo-context.md +20 -0
  1948. package/src/prompts/goals/guided-goal-interview.md +8 -0
  1949. package/src/prompts/goals/guided-goal-system.md +12 -0
  1950. package/src/prompts/memories/consolidation.md +30 -0
  1951. package/src/prompts/memories/consolidation_system.md +4 -0
  1952. package/src/prompts/memories/read-path.md +17 -0
  1953. package/src/prompts/memories/stage_one_input.md +6 -0
  1954. package/src/prompts/memories/stage_one_system.md +21 -0
  1955. package/src/prompts/review-custom-request.md +21 -0
  1956. package/src/prompts/review-headless-request.md +16 -0
  1957. package/src/prompts/review-request.md +68 -0
  1958. package/src/prompts/skills/autoload.md +8 -0
  1959. package/src/prompts/skills/user-invocation.md +11 -0
  1960. package/src/prompts/steering/parent-irc.md +5 -0
  1961. package/src/prompts/steering/user-interjection.md +9 -0
  1962. package/src/prompts/system/active-repo-context.md +4 -0
  1963. package/src/prompts/system/agent-creation-architect.md +50 -0
  1964. package/src/prompts/system/agent-creation-user.md +6 -0
  1965. package/src/prompts/system/auto-continue.md +1 -0
  1966. package/src/prompts/system/auto-thinking-difficulty-local.md +14 -0
  1967. package/src/prompts/system/auto-thinking-difficulty.md +12 -0
  1968. package/src/prompts/system/autolearn-guidance-learn.md +1 -0
  1969. package/src/prompts/system/autolearn-guidance.md +7 -0
  1970. package/src/prompts/system/autolearn-nudge-autocontinue.md +5 -0
  1971. package/src/prompts/system/background-tan-dispatch.md +8 -0
  1972. package/src/prompts/system/btw-user.md +8 -0
  1973. package/src/prompts/system/commit-message-system.md +14 -0
  1974. package/src/prompts/system/custom-system-prompt.md +64 -0
  1975. package/src/prompts/system/eager-task.md +7 -0
  1976. package/src/prompts/system/eager-todo.md +18 -0
  1977. package/src/prompts/system/empty-stop-retry.md +4 -0
  1978. package/src/prompts/system/gemini-tool-call-reminder.md +9 -0
  1979. package/src/prompts/system/interrupted-thinking.md +7 -0
  1980. package/src/prompts/system/irc-autoreply.md +6 -0
  1981. package/src/prompts/system/irc-incoming.md +9 -0
  1982. package/src/prompts/system/manual-continue.md +7 -0
  1983. package/src/prompts/system/memory-consolidation-system.md +8 -0
  1984. package/src/prompts/system/memory-extraction-system.md +26 -0
  1985. package/src/prompts/system/mid-run-todo-nudge.md +3 -0
  1986. package/src/prompts/system/omfg-user.md +50 -0
  1987. package/src/prompts/system/orchestrate-notice.md +40 -0
  1988. package/src/prompts/system/personalities/default.md +18 -0
  1989. package/src/prompts/system/personalities/friendly.md +17 -0
  1990. package/src/prompts/system/personalities/pragmatic.md +15 -0
  1991. package/src/prompts/system/plan-mode-active.md +118 -0
  1992. package/src/prompts/system/plan-mode-approved.md +22 -0
  1993. package/src/prompts/system/plan-mode-compact-instructions.md +17 -0
  1994. package/src/prompts/system/plan-mode-reference.md +10 -0
  1995. package/src/prompts/system/plan-mode-subagent.md +33 -0
  1996. package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
  1997. package/src/prompts/system/project-prompt.md +54 -0
  1998. package/src/prompts/system/recap-user.md +9 -0
  1999. package/src/prompts/system/rewind-report.md +6 -0
  2000. package/src/prompts/system/side-channel-no-tools.md +3 -0
  2001. package/src/prompts/system/snapcompact-context-frames-note.md +1 -0
  2002. package/src/prompts/system/snapcompact-context-stub.md +1 -0
  2003. package/src/prompts/system/snapcompact-system-frames-note.md +1 -0
  2004. package/src/prompts/system/snapcompact-system-stub.md +1 -0
  2005. package/src/prompts/system/snapcompact-toolresult-note.md +1 -0
  2006. package/src/prompts/system/speech-rewrite.md +15 -0
  2007. package/src/prompts/system/subagent-system-prompt.md +77 -0
  2008. package/src/prompts/system/subagent-user-prompt.md +3 -0
  2009. package/src/prompts/system/subagent-yield-reminder.md +13 -0
  2010. package/src/prompts/system/system-prompt.md +248 -0
  2011. package/src/prompts/system/thinking-loop-redirect.md +10 -0
  2012. package/src/prompts/system/tiny-title-system.md +8 -0
  2013. package/src/prompts/system/title-marker-instruction.md +1 -0
  2014. package/src/prompts/system/title-system-marker.md +17 -0
  2015. package/src/prompts/system/title-system.md +17 -0
  2016. package/src/prompts/system/tool-call-loop-redirect.md +8 -0
  2017. package/src/prompts/system/ttsr-interrupt.md +7 -0
  2018. package/src/prompts/system/ttsr-tool-reminder.md +5 -0
  2019. package/src/prompts/system/ultrathink-notice.md +3 -0
  2020. package/src/prompts/system/unexpected-stop-classifier.md +17 -0
  2021. package/src/prompts/system/unexpected-stop-retry.md +4 -0
  2022. package/src/prompts/system/web-search.md +25 -0
  2023. package/src/prompts/system/workflow-notice.md +70 -0
  2024. package/src/prompts/tools/apply-patch.md +65 -0
  2025. package/src/prompts/tools/ask.md +22 -0
  2026. package/src/prompts/tools/ast-edit.md +22 -0
  2027. package/src/prompts/tools/ast-grep.md +25 -0
  2028. package/src/prompts/tools/async-result.md +8 -0
  2029. package/src/prompts/tools/bash.md +57 -0
  2030. package/src/prompts/tools/browser.md +45 -0
  2031. package/src/prompts/tools/checkpoint.md +15 -0
  2032. package/src/prompts/tools/debug.md +17 -0
  2033. package/src/prompts/tools/eval.md +72 -0
  2034. package/src/prompts/tools/github.md +17 -0
  2035. package/src/prompts/tools/glob.md +15 -0
  2036. package/src/prompts/tools/goal.md +11 -0
  2037. package/src/prompts/tools/grep.md +22 -0
  2038. package/src/prompts/tools/image-attachment-describe-system.md +8 -0
  2039. package/src/prompts/tools/image-attachment-describe.md +10 -0
  2040. package/src/prompts/tools/image-gen.md +7 -0
  2041. package/src/prompts/tools/inspect-image-system.md +20 -0
  2042. package/src/prompts/tools/inspect-image.md +22 -0
  2043. package/src/prompts/tools/irc.md +24 -0
  2044. package/src/prompts/tools/job.md +11 -0
  2045. package/src/prompts/tools/learn.md +7 -0
  2046. package/src/prompts/tools/lsp-late-diagnostic.md +8 -0
  2047. package/src/prompts/tools/lsp.md +28 -0
  2048. package/src/prompts/tools/manage-skill.md +9 -0
  2049. package/src/prompts/tools/memory-edit.md +8 -0
  2050. package/src/prompts/tools/patch.md +57 -0
  2051. package/src/prompts/tools/read.md +77 -0
  2052. package/src/prompts/tools/recall.md +5 -0
  2053. package/src/prompts/tools/reflect.md +5 -0
  2054. package/src/prompts/tools/replace.md +29 -0
  2055. package/src/prompts/tools/resolve.md +4 -0
  2056. package/src/prompts/tools/retain.md +6 -0
  2057. package/src/prompts/tools/rewind.md +14 -0
  2058. package/src/prompts/tools/search-tool-bm25.md +32 -0
  2059. package/src/prompts/tools/ssh.md +23 -0
  2060. package/src/prompts/tools/task-summary.md +17 -0
  2061. package/src/prompts/tools/task.md +68 -0
  2062. package/src/prompts/tools/todo.md +39 -0
  2063. package/src/prompts/tools/web-search.md +6 -0
  2064. package/src/prompts/tools/write.md +14 -0
  2065. package/src/registry/agent-lifecycle.ts +270 -0
  2066. package/src/registry/agent-registry.ts +190 -0
  2067. package/src/sdk.ts +3037 -0
  2068. package/src/secrets/index.ts +123 -0
  2069. package/src/secrets/obfuscator.ts +441 -0
  2070. package/src/secrets/regex.ts +21 -0
  2071. package/src/session/agent-session.ts +15855 -0
  2072. package/src/session/agent-storage.ts +478 -0
  2073. package/src/session/artifacts.ts +153 -0
  2074. package/src/session/auth-broker-config.ts +92 -0
  2075. package/src/session/auth-storage.ts +24 -0
  2076. package/src/session/blob-store.ts +279 -0
  2077. package/src/session/client-bridge.ts +85 -0
  2078. package/src/session/codex-auto-reset.ts +202 -0
  2079. package/src/session/compact-modes.ts +105 -0
  2080. package/src/session/exit-diagnostics.ts +202 -0
  2081. package/src/session/history-storage.ts +360 -0
  2082. package/src/session/indexed-session-storage.ts +537 -0
  2083. package/src/session/messages.test.ts +125 -0
  2084. package/src/session/messages.ts +740 -0
  2085. package/src/session/provider-image-budget.ts +86 -0
  2086. package/src/session/redis-session-storage.ts +217 -0
  2087. package/src/session/session-context.ts +442 -0
  2088. package/src/session/session-dump-format.ts +216 -0
  2089. package/src/session/session-entries.ts +241 -0
  2090. package/src/session/session-history-format.ts +396 -0
  2091. package/src/session/session-listing.ts +652 -0
  2092. package/src/session/session-loader.ts +284 -0
  2093. package/src/session/session-manager.ts +1995 -0
  2094. package/src/session/session-migrations.ts +78 -0
  2095. package/src/session/session-paths.ts +193 -0
  2096. package/src/session/session-persistence.ts +266 -0
  2097. package/src/session/session-storage.ts +734 -0
  2098. package/src/session/session-title-slot.ts +141 -0
  2099. package/src/session/settings-stream-fn.ts +73 -0
  2100. package/src/session/shake-types.ts +43 -0
  2101. package/src/session/snapcompact-inline.ts +561 -0
  2102. package/src/session/snapcompact-savings-journal.ts +113 -0
  2103. package/src/session/sql-session-storage.ts +374 -0
  2104. package/src/session/streaming-output.ts +1330 -0
  2105. package/src/session/tool-choice-queue.ts +290 -0
  2106. package/src/session/turn-persistence.ts +142 -0
  2107. package/src/session/unexpected-stop-classifier.ts +129 -0
  2108. package/src/session/yield-queue.ts +183 -0
  2109. package/src/slash-commands/acp-builtins.ts +70 -0
  2110. package/src/slash-commands/available-commands.ts +105 -0
  2111. package/src/slash-commands/builtin-registry.ts +2554 -0
  2112. package/src/slash-commands/helpers/active-oauth-account.ts +44 -0
  2113. package/src/slash-commands/helpers/collab-qrcode.ts +28 -0
  2114. package/src/slash-commands/helpers/context-report.ts +66 -0
  2115. package/src/slash-commands/helpers/format.ts +46 -0
  2116. package/src/slash-commands/helpers/logout.ts +88 -0
  2117. package/src/slash-commands/helpers/marketplace-manager.ts +25 -0
  2118. package/src/slash-commands/helpers/mcp.ts +533 -0
  2119. package/src/slash-commands/helpers/parse.ts +85 -0
  2120. package/src/slash-commands/helpers/reset-usage.ts +66 -0
  2121. package/src/slash-commands/helpers/ssh.ts +195 -0
  2122. package/src/slash-commands/helpers/stats-dashboard.ts +85 -0
  2123. package/src/slash-commands/helpers/todo.ts +285 -0
  2124. package/src/slash-commands/helpers/usage-report.ts +162 -0
  2125. package/src/slash-commands/marketplace-install-parser.ts +99 -0
  2126. package/src/slash-commands/types.ts +137 -0
  2127. package/src/ssh/__tests__/connection-manager-args.test.ts +191 -0
  2128. package/src/ssh/__tests__/connection-manager-timeout.test.ts +61 -0
  2129. package/src/ssh/__tests__/file-transfer-posix-guard.test.ts +105 -0
  2130. package/src/ssh/__tests__/sshfs-mount.test.ts +13 -0
  2131. package/src/ssh/config-writer.ts +183 -0
  2132. package/src/ssh/connection-manager.ts +667 -0
  2133. package/src/ssh/file-transfer.ts +214 -0
  2134. package/src/ssh/ssh-executor.ts +178 -0
  2135. package/src/ssh/sshfs-mount.ts +163 -0
  2136. package/src/ssh/utils.ts +51 -0
  2137. package/src/startup-splash.ts +19 -0
  2138. package/src/stt/asr-client.ts +401 -0
  2139. package/src/stt/asr-protocol.ts +65 -0
  2140. package/src/stt/asr-worker.ts +638 -0
  2141. package/src/stt/downloader.ts +144 -0
  2142. package/src/stt/endpointer.ts +259 -0
  2143. package/src/stt/index.ts +8 -0
  2144. package/src/stt/models.ts +150 -0
  2145. package/src/stt/recorder.ts +538 -0
  2146. package/src/stt/stt-controller.ts +409 -0
  2147. package/src/stt/submit-trigger.ts +74 -0
  2148. package/src/stt/transcriber.ts +60 -0
  2149. package/src/stt/wav.ts +173 -0
  2150. package/src/subprocess/worker-client.ts +456 -0
  2151. package/src/subprocess/worker-runtime.ts +494 -0
  2152. package/src/system-prompt.test.ts +158 -0
  2153. package/src/system-prompt.ts +787 -0
  2154. package/src/task/agents.ts +166 -0
  2155. package/src/task/commands.ts +132 -0
  2156. package/src/task/discovery.ts +145 -0
  2157. package/src/task/executor.ts +2481 -0
  2158. package/src/task/index.ts +1481 -0
  2159. package/src/task/isolation-runner.ts +384 -0
  2160. package/src/task/name-generator.ts +1577 -0
  2161. package/src/task/omp-command.ts +26 -0
  2162. package/src/task/output-manager.ts +93 -0
  2163. package/src/task/parallel.ts +178 -0
  2164. package/src/task/persisted-revive.ts +128 -0
  2165. package/src/task/provider-concurrency.ts +100 -0
  2166. package/src/task/render.test.ts +121 -0
  2167. package/src/task/render.ts +1761 -0
  2168. package/src/task/renderer.ts +15 -0
  2169. package/src/task/repair-args.ts +129 -0
  2170. package/src/task/spawn-policy.test.ts +63 -0
  2171. package/src/task/spawn-policy.ts +58 -0
  2172. package/src/task/subprocess-tool-registry.ts +88 -0
  2173. package/src/task/types.ts +495 -0
  2174. package/src/task/worktree.ts +935 -0
  2175. package/src/task/yield-assembly.ts +198 -0
  2176. package/src/telemetry-export.ts +144 -0
  2177. package/src/thinking.ts +219 -0
  2178. package/src/tiny/device.ts +111 -0
  2179. package/src/tiny/dtype.ts +101 -0
  2180. package/src/tiny/models.ts +268 -0
  2181. package/src/tiny/text.ts +336 -0
  2182. package/src/tiny/title-client.ts +438 -0
  2183. package/src/tiny/title-protocol.ts +56 -0
  2184. package/src/tiny/worker.ts +351 -0
  2185. package/src/tool-discovery/mode.ts +24 -0
  2186. package/src/tool-discovery/tool-index.ts +271 -0
  2187. package/src/tools/__tests__/eval-description.test.ts +19 -0
  2188. package/src/tools/__tests__/json-tree.test.ts +35 -0
  2189. package/src/tools/acp-bridge.ts +71 -0
  2190. package/src/tools/approval.ts +189 -0
  2191. package/src/tools/ask.ts +1213 -0
  2192. package/src/tools/ast-edit.ts +708 -0
  2193. package/src/tools/ast-grep.ts +520 -0
  2194. package/src/tools/auto-generated-guard.ts +322 -0
  2195. package/src/tools/bash-command-fixup.ts +37 -0
  2196. package/src/tools/bash-interactive.ts +408 -0
  2197. package/src/tools/bash-interceptor.ts +67 -0
  2198. package/src/tools/bash-pty-selection.ts +14 -0
  2199. package/src/tools/bash-skill-urls.ts +248 -0
  2200. package/src/tools/bash.ts +1421 -0
  2201. package/src/tools/browser/aria/aria-snapshot.bundle.txt +7 -0
  2202. package/src/tools/browser/aria/aria-snapshot.ts +103 -0
  2203. package/src/tools/browser/attach.ts +194 -0
  2204. package/src/tools/browser/cmux/cmux-tab.ts +1378 -0
  2205. package/src/tools/browser/cmux/rpc.ts +156 -0
  2206. package/src/tools/browser/cmux/socket-client.ts +309 -0
  2207. package/src/tools/browser/launch.ts +749 -0
  2208. package/src/tools/browser/readable.ts +112 -0
  2209. package/src/tools/browser/registry.ts +266 -0
  2210. package/src/tools/browser/render.ts +223 -0
  2211. package/src/tools/browser/run-cancellation.ts +47 -0
  2212. package/src/tools/browser/tab-protocol.ts +107 -0
  2213. package/src/tools/browser/tab-supervisor.ts +956 -0
  2214. package/src/tools/browser/tab-worker-entry.ts +29 -0
  2215. package/src/tools/browser/tab-worker.ts +1433 -0
  2216. package/src/tools/browser.ts +409 -0
  2217. package/src/tools/builtin-names.ts +58 -0
  2218. package/src/tools/checkpoint.ts +150 -0
  2219. package/src/tools/conflict-detect.ts +718 -0
  2220. package/src/tools/context.ts +39 -0
  2221. package/src/tools/debug.ts +1088 -0
  2222. package/src/tools/eval-backends.ts +34 -0
  2223. package/src/tools/eval-render.ts +776 -0
  2224. package/src/tools/eval.ts +767 -0
  2225. package/src/tools/fetch.ts +1966 -0
  2226. package/src/tools/file-recorder.ts +35 -0
  2227. package/src/tools/fs-cache-invalidation.ts +28 -0
  2228. package/src/tools/gh-cache-invalidation.ts +255 -0
  2229. package/src/tools/gh-format.ts +12 -0
  2230. package/src/tools/gh-renderer.ts +484 -0
  2231. package/src/tools/gh.ts +3752 -0
  2232. package/src/tools/github-cache.ts +663 -0
  2233. package/src/tools/glob.ts +639 -0
  2234. package/src/tools/grep.ts +1836 -0
  2235. package/src/tools/grouped-file-output.ts +210 -0
  2236. package/src/tools/image-gen.ts +1587 -0
  2237. package/src/tools/index.ts +682 -0
  2238. package/src/tools/inspect-image-renderer.ts +132 -0
  2239. package/src/tools/inspect-image.ts +260 -0
  2240. package/src/tools/irc.ts +827 -0
  2241. package/src/tools/job.ts +612 -0
  2242. package/src/tools/json-tree.ts +260 -0
  2243. package/src/tools/jtd-to-json-schema.ts +219 -0
  2244. package/src/tools/jtd-to-typescript.ts +136 -0
  2245. package/src/tools/jtd-utils.ts +102 -0
  2246. package/src/tools/learn.ts +141 -0
  2247. package/src/tools/list-limit.ts +40 -0
  2248. package/src/tools/manage-skill.ts +100 -0
  2249. package/src/tools/match-line-format.ts +20 -0
  2250. package/src/tools/memory-edit.ts +59 -0
  2251. package/src/tools/memory-recall.ts +102 -0
  2252. package/src/tools/memory-reflect.ts +88 -0
  2253. package/src/tools/memory-render.ts +202 -0
  2254. package/src/tools/memory-retain.ts +89 -0
  2255. package/src/tools/output-meta.ts +818 -0
  2256. package/src/tools/output-schema-validator.ts +307 -0
  2257. package/src/tools/path-utils.ts +1279 -0
  2258. package/src/tools/plan-mode-guard.ts +155 -0
  2259. package/src/tools/puppeteer/00_stealth_tampering.txt +44 -0
  2260. package/src/tools/puppeteer/01_stealth_activity.txt +80 -0
  2261. package/src/tools/puppeteer/02_stealth_hairline.txt +57 -0
  2262. package/src/tools/puppeteer/03_stealth_botd.txt +380 -0
  2263. package/src/tools/puppeteer/04_stealth_iframe.txt +174 -0
  2264. package/src/tools/puppeteer/05_stealth_webgl.txt +233 -0
  2265. package/src/tools/puppeteer/06_stealth_screen.txt +260 -0
  2266. package/src/tools/puppeteer/07_stealth_fonts.txt +99 -0
  2267. package/src/tools/puppeteer/08_stealth_audio.txt +63 -0
  2268. package/src/tools/puppeteer/09_stealth_locale.txt +51 -0
  2269. package/src/tools/puppeteer/10_stealth_plugins.txt +212 -0
  2270. package/src/tools/puppeteer/11_stealth_hardware.txt +59 -0
  2271. package/src/tools/puppeteer/12_stealth_codecs.txt +42 -0
  2272. package/src/tools/puppeteer/13_stealth_worker.txt +235 -0
  2273. package/src/tools/read.ts +3522 -0
  2274. package/src/tools/render-utils.ts +913 -0
  2275. package/src/tools/renderers.ts +107 -0
  2276. package/src/tools/report-tool-issue.ts +530 -0
  2277. package/src/tools/resolve.ts +302 -0
  2278. package/src/tools/review.ts +261 -0
  2279. package/src/tools/search-tool-bm25.ts +351 -0
  2280. package/src/tools/sqlite-reader.ts +884 -0
  2281. package/src/tools/ssh.ts +397 -0
  2282. package/src/tools/todo.ts +944 -0
  2283. package/src/tools/tool-errors.ts +62 -0
  2284. package/src/tools/tool-result.ts +102 -0
  2285. package/src/tools/tool-timeouts.ts +30 -0
  2286. package/src/tools/tts.ts +266 -0
  2287. package/src/tools/write.ts +1219 -0
  2288. package/src/tools/yield.ts +455 -0
  2289. package/src/tts/downloader.ts +64 -0
  2290. package/src/tts/index.ts +10 -0
  2291. package/src/tts/models.ts +137 -0
  2292. package/src/tts/player.ts +137 -0
  2293. package/src/tts/runtime.ts +21 -0
  2294. package/src/tts/speakable.ts +382 -0
  2295. package/src/tts/speech-enhancer.ts +204 -0
  2296. package/src/tts/streaming-player.ts +321 -0
  2297. package/src/tts/tts-client.ts +475 -0
  2298. package/src/tts/tts-protocol.ts +69 -0
  2299. package/src/tts/tts-worker.ts +434 -0
  2300. package/src/tts/vocalizer.ts +393 -0
  2301. package/src/tts/wav.ts +58 -0
  2302. package/src/tui/code-cell.ts +268 -0
  2303. package/src/tui/file-list.ts +55 -0
  2304. package/src/tui/hyperlink.ts +178 -0
  2305. package/src/tui/index.ts +13 -0
  2306. package/src/tui/output-block.ts +251 -0
  2307. package/src/tui/status-line.ts +54 -0
  2308. package/src/tui/tree-list.ts +133 -0
  2309. package/src/tui/types.ts +15 -0
  2310. package/src/tui/utils.ts +103 -0
  2311. package/src/tui/width-aware-text.ts +58 -0
  2312. package/src/utils/active-repo-context.ts +143 -0
  2313. package/src/utils/block-context.ts +312 -0
  2314. package/src/utils/changelog.ts +132 -0
  2315. package/src/utils/clipboard.ts +356 -0
  2316. package/src/utils/command-args.ts +76 -0
  2317. package/src/utils/commit-message-generator.ts +146 -0
  2318. package/src/utils/edit-mode.ts +58 -0
  2319. package/src/utils/enhanced-paste.ts +230 -0
  2320. package/src/utils/event-bus.ts +33 -0
  2321. package/src/utils/external-editor.ts +78 -0
  2322. package/src/utils/fetch-timeout.ts +10 -0
  2323. package/src/utils/file-display-mode.ts +44 -0
  2324. package/src/utils/file-mentions.ts +293 -0
  2325. package/src/utils/git.ts +2181 -0
  2326. package/src/utils/image-loading.ts +231 -0
  2327. package/src/utils/image-resize.ts +420 -0
  2328. package/src/utils/image-vision-fallback.ts +196 -0
  2329. package/src/utils/ipc.ts +38 -0
  2330. package/src/utils/jj.ts +295 -0
  2331. package/src/utils/lang-from-path.ts +244 -0
  2332. package/src/utils/markit-cache.ts +166 -0
  2333. package/src/utils/markit.ts +211 -0
  2334. package/src/utils/mupdf-wasm-embed.ts +12 -0
  2335. package/src/utils/open.ts +100 -0
  2336. package/src/utils/prompt-path.ts +3 -0
  2337. package/src/utils/qrcode.ts +535 -0
  2338. package/src/utils/session-color.ts +142 -0
  2339. package/src/utils/shell-snapshot-fn-env.sh +60 -0
  2340. package/src/utils/shell-snapshot.ts +306 -0
  2341. package/src/utils/sixel.ts +69 -0
  2342. package/src/utils/thinking-display.ts +117 -0
  2343. package/src/utils/title-generator.ts +348 -0
  2344. package/src/utils/tool-choice.ts +49 -0
  2345. package/src/utils/tools-manager.ts +429 -0
  2346. package/src/utils/turndown.ts +83 -0
  2347. package/src/utils/zip.ts +1091 -0
  2348. package/src/web/kagi.ts +304 -0
  2349. package/src/web/parallel.ts +354 -0
  2350. package/src/web/scrapers/artifacthub.ts +207 -0
  2351. package/src/web/scrapers/arxiv.ts +83 -0
  2352. package/src/web/scrapers/aur.ts +162 -0
  2353. package/src/web/scrapers/biorxiv.ts +133 -0
  2354. package/src/web/scrapers/bluesky.ts +262 -0
  2355. package/src/web/scrapers/brew.ts +172 -0
  2356. package/src/web/scrapers/cheatsh.ts +68 -0
  2357. package/src/web/scrapers/chocolatey.ts +196 -0
  2358. package/src/web/scrapers/choosealicense.ts +95 -0
  2359. package/src/web/scrapers/cisa-kev.ts +87 -0
  2360. package/src/web/scrapers/clojars.ts +154 -0
  2361. package/src/web/scrapers/coingecko.ts +177 -0
  2362. package/src/web/scrapers/crates-io.ts +97 -0
  2363. package/src/web/scrapers/crossref.ts +136 -0
  2364. package/src/web/scrapers/devto.ts +147 -0
  2365. package/src/web/scrapers/discogs.ts +306 -0
  2366. package/src/web/scrapers/discourse.ts +197 -0
  2367. package/src/web/scrapers/dockerhub.ts +138 -0
  2368. package/src/web/scrapers/docs-rs.ts +652 -0
  2369. package/src/web/scrapers/fdroid.ts +134 -0
  2370. package/src/web/scrapers/firefox-addons.ts +191 -0
  2371. package/src/web/scrapers/flathub.ts +223 -0
  2372. package/src/web/scrapers/github-gist.ts +58 -0
  2373. package/src/web/scrapers/github.ts +800 -0
  2374. package/src/web/scrapers/gitlab.ts +401 -0
  2375. package/src/web/scrapers/go-pkg.ts +266 -0
  2376. package/src/web/scrapers/hackage.ts +140 -0
  2377. package/src/web/scrapers/hackernews.ts +189 -0
  2378. package/src/web/scrapers/hex.ts +105 -0
  2379. package/src/web/scrapers/huggingface.ts +321 -0
  2380. package/src/web/scrapers/iacr.ts +89 -0
  2381. package/src/web/scrapers/index.ts +252 -0
  2382. package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
  2383. package/src/web/scrapers/lemmy.ts +203 -0
  2384. package/src/web/scrapers/lobsters.ts +175 -0
  2385. package/src/web/scrapers/mastodon.ts +292 -0
  2386. package/src/web/scrapers/maven.ts +138 -0
  2387. package/src/web/scrapers/mdn.ts +173 -0
  2388. package/src/web/scrapers/metacpan.ts +222 -0
  2389. package/src/web/scrapers/musicbrainz.ts +250 -0
  2390. package/src/web/scrapers/npm.ts +98 -0
  2391. package/src/web/scrapers/nuget.ts +183 -0
  2392. package/src/web/scrapers/nvd.ts +222 -0
  2393. package/src/web/scrapers/ollama.ts +239 -0
  2394. package/src/web/scrapers/open-vsx.ts +106 -0
  2395. package/src/web/scrapers/opencorporates.ts +292 -0
  2396. package/src/web/scrapers/openlibrary.ts +336 -0
  2397. package/src/web/scrapers/orcid.ts +286 -0
  2398. package/src/web/scrapers/osv.ts +176 -0
  2399. package/src/web/scrapers/packagist.ts +160 -0
  2400. package/src/web/scrapers/pub-dev.ts +143 -0
  2401. package/src/web/scrapers/pubmed.ts +211 -0
  2402. package/src/web/scrapers/pypi.ts +112 -0
  2403. package/src/web/scrapers/rawg.ts +110 -0
  2404. package/src/web/scrapers/readthedocs.ts +120 -0
  2405. package/src/web/scrapers/reddit.ts +95 -0
  2406. package/src/web/scrapers/repology.ts +251 -0
  2407. package/src/web/scrapers/rfc.ts +201 -0
  2408. package/src/web/scrapers/rubygems.ts +103 -0
  2409. package/src/web/scrapers/searchcode.ts +189 -0
  2410. package/src/web/scrapers/sec-edgar.ts +261 -0
  2411. package/src/web/scrapers/semantic-scholar.ts +171 -0
  2412. package/src/web/scrapers/snapcraft.ts +187 -0
  2413. package/src/web/scrapers/sourcegraph.ts +336 -0
  2414. package/src/web/scrapers/spdx.ts +108 -0
  2415. package/src/web/scrapers/spotify.ts +198 -0
  2416. package/src/web/scrapers/stackoverflow.ts +120 -0
  2417. package/src/web/scrapers/terraform.ts +277 -0
  2418. package/src/web/scrapers/tldr.ts +47 -0
  2419. package/src/web/scrapers/twitter.ts +94 -0
  2420. package/src/web/scrapers/types.ts +354 -0
  2421. package/src/web/scrapers/utils.ts +109 -0
  2422. package/src/web/scrapers/vimeo.ts +133 -0
  2423. package/src/web/scrapers/vscode-marketplace.ts +187 -0
  2424. package/src/web/scrapers/w3c.ts +156 -0
  2425. package/src/web/scrapers/wikidata.ts +344 -0
  2426. package/src/web/scrapers/wikipedia.ts +84 -0
  2427. package/src/web/scrapers/youtube.ts +325 -0
  2428. package/src/web/search/index.ts +312 -0
  2429. package/src/web/search/provider.ts +214 -0
  2430. package/src/web/search/providers/anthropic.ts +343 -0
  2431. package/src/web/search/providers/base.ts +91 -0
  2432. package/src/web/search/providers/brave.ts +152 -0
  2433. package/src/web/search/providers/codex.ts +593 -0
  2434. package/src/web/search/providers/duckduckgo.ts +212 -0
  2435. package/src/web/search/providers/exa.ts +484 -0
  2436. package/src/web/search/providers/firecrawl.ts +144 -0
  2437. package/src/web/search/providers/gemini.ts +618 -0
  2438. package/src/web/search/providers/jina.ts +111 -0
  2439. package/src/web/search/providers/kagi.ts +86 -0
  2440. package/src/web/search/providers/kimi.ts +196 -0
  2441. package/src/web/search/providers/parallel.ts +136 -0
  2442. package/src/web/search/providers/perplexity-auth.ts +133 -0
  2443. package/src/web/search/providers/perplexity.ts +878 -0
  2444. package/src/web/search/providers/searxng.ts +325 -0
  2445. package/src/web/search/providers/synthetic.ts +114 -0
  2446. package/src/web/search/providers/tavily.ts +193 -0
  2447. package/src/web/search/providers/tinyfish.ts +159 -0
  2448. package/src/web/search/providers/utils.ts +128 -0
  2449. package/src/web/search/providers/xai.ts +292 -0
  2450. package/src/web/search/providers/zai.ts +419 -0
  2451. package/src/web/search/render.ts +262 -0
  2452. package/src/web/search/types.ts +470 -0
  2453. package/src/web/search/utils.ts +17 -0
  2454. package/src/workspace-tree.ts +326 -0
@@ -0,0 +1,1851 @@
1
+ import * as fs from "node:fs/promises";
2
+ import * as path from "node:path";
3
+ import { ThinkingLevel } from "@oh-my-pi-zen/pi-agent-core";
4
+ import type { ImageContent } from "@oh-my-pi-zen/pi-ai";
5
+ import { type AutocompleteProvider, matchesKey, type SlashCommand } from "@oh-my-pi-zen/pi-tui";
6
+ import { $env, isEnoent, logger, sanitizeText } from "@oh-my-pi-zen/pi-utils";
7
+ import { isSettingsInitialized, settings } from "../../config/settings";
8
+ import { resolveLocalRoot } from "../../internal-urls";
9
+ import { AssistantMessageComponent } from "../../modes/components/assistant-message";
10
+ import { extractImagePathFromText } from "../../modes/components/custom-editor";
11
+ import { renderSegmentTrack } from "../../modes/components/segment-track";
12
+ import { TinyTitleDownloadProgressComponent } from "../../modes/components/tiny-title-download-progress";
13
+ import { expandEmoticons } from "../../modes/emoji-autocomplete";
14
+ import { materializeImageReferenceLinks, shiftImageMarkers } from "../../modes/image-references";
15
+ import { createPromptActionAutocompleteProvider } from "../../modes/prompt-action-autocomplete";
16
+ import { invokeSkillCommandFromText, isKnownSkillCommand } from "../../modes/skill-command";
17
+ import type { InteractiveModeContext } from "../../modes/types";
18
+ import manualContinuePrompt from "../../prompts/system/manual-continue.md" with { type: "text" };
19
+ import { USER_INTERRUPT_LABEL } from "../../session/messages";
20
+ import { executeBuiltinSlashCommand } from "../../slash-commands/builtin-registry";
21
+ import { isTinyTitleLocalModelKey } from "../../tiny/models";
22
+ import { isLowSignalTitleInput } from "../../tiny/text";
23
+ import { tinyTitleClient } from "../../tiny/title-client";
24
+ import type { TinyTitleProgressEvent } from "../../tiny/title-protocol";
25
+ import { shortenPath, TRUNCATE_LENGTHS, truncateToWidth } from "../../tools/render-utils";
26
+ import {
27
+ copyToClipboard,
28
+ readImageFromClipboard,
29
+ readMacFileUrlsFromClipboard,
30
+ readTextFromClipboard,
31
+ } from "../../utils/clipboard";
32
+ import { EnhancedPasteController } from "../../utils/enhanced-paste";
33
+ import { getEditorCommand, openInEditor } from "../../utils/external-editor";
34
+ import { ensureSupportedImageInput, ImageInputTooLargeError, loadImageInput } from "../../utils/image-loading";
35
+ import { resizeImage } from "../../utils/image-resize";
36
+ import { generateSessionTitle } from "../../utils/title-generator";
37
+
38
+ /**
39
+ * Slash commands that may carry secrets in their arguments should never be
40
+ * persisted to history.
41
+ *
42
+ * - /login accepts three callback forms (redirect URL, query string, raw auth
43
+ * code) — all can contain OAuth code=/state= params.
44
+ * - /join <link> carries a 32-byte room key and optional write token.
45
+ * - /mcp add --token <token> carries a bearer token.
46
+ *
47
+ * The command name is extracted the same way as parseSlashCommand() — splitting
48
+ * on the earliest whitespace or colon — so /login:?code=... is correctly matched.
49
+ */
50
+ export function shouldSkipHistory(slashText: string): boolean {
51
+ if (!slashText.startsWith("/")) return false;
52
+ const body = slashText.slice(1);
53
+ // Match parseSlashCommand: split on earliest whitespace or colon.
54
+ const firstWs = body.search(/\s/);
55
+ const firstColon = body.indexOf(":");
56
+ const sep = firstWs === -1 ? firstColon : firstColon === -1 ? firstWs : Math.min(firstWs, firstColon);
57
+ const name = sep === -1 ? body : body.slice(0, sep);
58
+ const hasArgs = sep !== -1;
59
+ // /login <anything> — parseCallbackInput() accepts redirect URLs, query
60
+ // strings (?code=...), and raw auth codes, all of which carry secrets.
61
+ if (name === "login" && hasArgs) return true;
62
+ // /join <link> — the link carries the 32-byte room key and write token.
63
+ if (name === "join" && hasArgs) return true;
64
+ if (name === "mcp") {
65
+ const args = body.slice(sep + 1).trim();
66
+ return args.startsWith("add") && /--token\s/.test(args);
67
+ }
68
+ return false;
69
+ }
70
+
71
+ interface Expandable {
72
+ setExpanded(expanded: boolean): void;
73
+ }
74
+
75
+ function isExpandable(obj: unknown): obj is Expandable {
76
+ return typeof obj === "object" && obj !== null && "setExpanded" in obj && typeof obj.setExpanded === "function";
77
+ }
78
+
79
+ /** Minimal contract for any component that can receive a paste payload directly. */
80
+ interface PasteTarget {
81
+ pasteText(text: string): void;
82
+ }
83
+
84
+ function hasPasteText(value: unknown): value is PasteTarget {
85
+ return typeof value === "object" && value !== null && typeof (value as PasteTarget).pasteText === "function";
86
+ }
87
+
88
+ function pythonCommandPrefixLength(trimmedText: string): 0 | 1 | 2 {
89
+ if (trimmedText.charCodeAt(0) !== 36 /* $ */) return 0;
90
+ if (trimmedText.charCodeAt(1) === 123 /* { */) return 0;
91
+
92
+ const prefixLength = trimmedText.charCodeAt(1) === 36 /* $ */ ? 2 : 1;
93
+ const next = trimmedText.charCodeAt(prefixLength);
94
+ if (Number.isNaN(next)) return prefixLength;
95
+ return next === 32 || next === 9 || next === 10 || next === 13 ? prefixLength : 0;
96
+ }
97
+
98
+ function parsePythonCommandInput(text: string): { code: string; isExcluded: boolean } | undefined {
99
+ const trimmed = text.trimStart();
100
+ const prefixLength = pythonCommandPrefixLength(trimmed);
101
+ if (prefixLength === 0) return undefined;
102
+ return {
103
+ code: trimmed.slice(prefixLength).trim(),
104
+ isExcluded: prefixLength === 2,
105
+ };
106
+ }
107
+
108
+ /** Wrap pasted text in `<attachment>` tags so the model treats it as one quoted block. */
109
+ function wrapPasteInAttachmentBlock(content: string): string {
110
+ return `<attachment>\n${content}\n</attachment>`;
111
+ }
112
+
113
+ /** Run a teardown abort that must never throw (Esc / Ctrl+C path). A thrown
114
+ * error is logged at debug instead of silently swallowed, so a failing abort
115
+ * stays diagnosable without disturbing teardown ordering. */
116
+ function safeAbort(label: string, fn: () => void): void {
117
+ try {
118
+ fn();
119
+ } catch (err) {
120
+ logger.debug(`Failed to abort ${label}`, { error: err instanceof Error ? err.message : String(err) });
121
+ }
122
+ }
123
+
124
+ const TINY_TITLE_PROGRESS_DONE_TTL_MS = 3_000;
125
+ // A cached model fires its file-load events in a short burst and then goes silent
126
+ // while onnxruntime builds the session; a genuine download keeps streaming progress
127
+ // events for seconds. Only reveal the bar once a still-incomplete event arrives after
128
+ // this grace window, so an already-downloaded model never flashes the bar.
129
+ const TINY_TITLE_PROGRESS_REVEAL_DELAY_MS = 1_000;
130
+ // Double-tap ← on an empty editor opens the Agent Hub (and, in a focused
131
+ // subagent view, ←← returns to the main session). The second tap must land
132
+ // inside this window. The lower bound rejects terminal-synthesized arrow-key
133
+ // bursts: "click to move cursor" / pointer features in iTerm2, WezTerm, kitty,
134
+ // and tmux emit several arrow keys in a single stdin read (sub-millisecond
135
+ // apart) on a stray click, which used to pop the hub with no key ever pressed.
136
+ // Three or more rapid taps are likewise treated as a burst, not a gesture. A
137
+ // deliberate human double-tap is always tens of milliseconds apart.
138
+ const LEFT_DOUBLE_TAP_MIN_GAP_MS = 40;
139
+ const LEFT_DOUBLE_TAP_MAX_GAP_MS = 500;
140
+ const STREAMING_ESCAPE_CANCEL_WINDOW_MS = 2_000;
141
+
142
+ export class InputController {
143
+ constructor(
144
+ private ctx: InteractiveModeContext,
145
+ /** Injectable clipboard reads so tests can drive paste flows without a real clipboard. */
146
+ private clipboard: {
147
+ readImage: typeof readImageFromClipboard;
148
+ readText: typeof readTextFromClipboard;
149
+ readMacFileUrls?: typeof readMacFileUrlsFromClipboard;
150
+ } = {
151
+ readImage: readImageFromClipboard,
152
+ readText: readTextFromClipboard,
153
+ readMacFileUrls: readMacFileUrlsFromClipboard,
154
+ },
155
+ ) {}
156
+
157
+ #enhancedPaste?: EnhancedPasteController;
158
+ #focusedLeftTapListenerInstalled = false;
159
+ #btwBranchListenerInstalled = false;
160
+ #btwCopyListenerInstalled = false;
161
+ // Tap counter for the double-← gesture; reset whenever a quiet gap
162
+ // (>= LEFT_DOUBLE_TAP_MAX_GAP_MS) starts a fresh sequence. See
163
+ // #detectLeftDoubleTap.
164
+ #leftTapCount = 0;
165
+ // Streaming turns use a two-step Esc: first press arms this token, second press
166
+ // within the window aborts the same live assistant turn. The token is a per-turn
167
+ // sentinel minted lazily on demand and reset on every `agent_start`/`agent_end`
168
+ // (see setupKeyHandlers), so it survives `message_start`/`message_update`
169
+ // transitions inside a single turn but cannot leak across turn boundaries.
170
+ #streamingEscapeTurnSentinel: object | undefined;
171
+ #streamingEscapeArmedToken: object | undefined;
172
+ #streamingEscapeArmedUntil = 0;
173
+ #streamingEscapeTimer: NodeJS.Timeout | undefined;
174
+ #streamingEscapeSessionSubscribed = false;
175
+ // Sequential index for `local://attachment-N` references created by large-paste and
176
+ // pasted-file attachments. Seeded from 0 and bumped past existing attachment files.
177
+ #attachmentCounter = 0;
178
+
179
+ #showTinyTitleDownloadProgress(modelKey: string): void {
180
+ if (!isTinyTitleLocalModelKey(modelKey)) return;
181
+ const component = new TinyTitleDownloadProgressComponent(modelKey);
182
+ let added = false;
183
+ let disposed = false;
184
+ let removeTimer: NodeJS.Timeout | undefined;
185
+ const remove = (): void => {
186
+ if (disposed) return;
187
+ disposed = true;
188
+ unsubscribe();
189
+ if (removeTimer) {
190
+ clearTimeout(removeTimer);
191
+ removeTimer = undefined;
192
+ }
193
+ if (added) {
194
+ this.ctx.chatContainer.removeChild(component);
195
+ this.ctx.ui.requestRender();
196
+ }
197
+ };
198
+ const scheduleRemove = (): void => {
199
+ if (removeTimer) clearTimeout(removeTimer);
200
+ removeTimer = setTimeout(remove, TINY_TITLE_PROGRESS_DONE_TTL_MS);
201
+ removeTimer.unref?.();
202
+ };
203
+ let revealAt = 0;
204
+ const update = (event: TinyTitleProgressEvent): void => {
205
+ if (disposed || event.modelKey !== modelKey) return;
206
+ component.update(event);
207
+ if (revealAt === 0) revealAt = performance.now() + TINY_TITLE_PROGRESS_REVEAL_DELAY_MS;
208
+ const complete = component.isComplete();
209
+ // Reveal only for a download still in flight past the grace window. Cache hits
210
+ // either complete or fall silent (onnx init emits no events) before this fires.
211
+ if (!added && !complete && performance.now() >= revealAt) {
212
+ this.ctx.chatContainer.addChild(component);
213
+ added = true;
214
+ }
215
+ if (added) this.ctx.ui.requestRender();
216
+ if (complete) {
217
+ if (added) scheduleRemove();
218
+ else remove();
219
+ }
220
+ };
221
+ const unsubscribe = tinyTitleClient.onProgress(update);
222
+ }
223
+
224
+ #clearStreamingEscapeArm(): void {
225
+ this.#streamingEscapeArmedToken = undefined;
226
+ this.#streamingEscapeArmedUntil = 0;
227
+ if (this.#streamingEscapeTimer) {
228
+ clearTimeout(this.#streamingEscapeTimer);
229
+ this.#streamingEscapeTimer = undefined;
230
+ }
231
+ }
232
+
233
+ #handleStreamingEscape(): void {
234
+ if (!this.#streamingEscapeTurnSentinel) {
235
+ this.#streamingEscapeTurnSentinel = {};
236
+ }
237
+ const token = this.#streamingEscapeTurnSentinel;
238
+ const now = Date.now();
239
+ if (this.#streamingEscapeArmedToken === token && now <= this.#streamingEscapeArmedUntil) {
240
+ this.#clearStreamingEscapeArm();
241
+ void this.ctx.session.abort({ reason: USER_INTERRUPT_LABEL });
242
+ return;
243
+ }
244
+
245
+ this.#clearStreamingEscapeArm();
246
+ this.#streamingEscapeArmedToken = token;
247
+ this.#streamingEscapeArmedUntil = now + STREAMING_ESCAPE_CANCEL_WINDOW_MS;
248
+ this.#streamingEscapeTimer = setTimeout(() => {
249
+ if (this.#streamingEscapeArmedToken === token && Date.now() >= this.#streamingEscapeArmedUntil) {
250
+ this.#clearStreamingEscapeArm();
251
+ }
252
+ }, STREAMING_ESCAPE_CANCEL_WINDOW_MS);
253
+ this.#streamingEscapeTimer.unref?.();
254
+ this.ctx.showStatus("Press Esc again within 2s to cancel streaming.");
255
+ }
256
+
257
+ setupKeyHandlers(): void {
258
+ this.ctx.editor.setActionKeys("app.interrupt", this.ctx.keybindings.getKeys("app.interrupt"));
259
+ if (!this.#streamingEscapeSessionSubscribed && typeof this.ctx.session.subscribe === "function") {
260
+ this.#streamingEscapeSessionSubscribed = true;
261
+ this.ctx.session.subscribe(event => {
262
+ if (event.type === "agent_start" || event.type === "agent_end") {
263
+ this.#streamingEscapeTurnSentinel = undefined;
264
+ this.#clearStreamingEscapeArm();
265
+ }
266
+ });
267
+ }
268
+ if (!this.#focusedLeftTapListenerInstalled) {
269
+ this.#focusedLeftTapListenerInstalled = true;
270
+ this.ctx.ui.addInputListener(data => {
271
+ if (!this.ctx.focusedAgentId) return undefined;
272
+ if (!matchesKey(data, "left")) return undefined;
273
+ if (this.ctx.editor.getText().trim()) return undefined;
274
+ this.#handleFocusedLeftTap();
275
+ return { consume: true };
276
+ });
277
+ }
278
+ if (!this.#btwBranchListenerInstalled) {
279
+ this.#btwBranchListenerInstalled = true;
280
+ this.ctx.ui.addInputListener(data => {
281
+ if (!matchesKey(data, "b")) return undefined;
282
+ if (!this.ctx.canBranchBtw()) return undefined;
283
+ if (this.ctx.ui.getFocused() !== this.ctx.editor) return undefined;
284
+ if (this.ctx.editor.getText().trim()) return undefined;
285
+ void this.ctx.handleBtwBranchKey();
286
+ return { consume: true };
287
+ });
288
+ }
289
+ if (!this.#btwCopyListenerInstalled) {
290
+ this.#btwCopyListenerInstalled = true;
291
+ this.ctx.ui.addInputListener(data => {
292
+ if (!matchesKey(data, "c")) return undefined;
293
+ if (!this.ctx.canCopyBtw()) return undefined;
294
+ if (this.ctx.ui.getFocused() !== this.ctx.editor) return undefined;
295
+ if (this.ctx.editor.getText().trim()) return undefined;
296
+ void this.ctx.handleBtwCopyKey();
297
+ return { consume: true };
298
+ });
299
+ }
300
+ this.ctx.editor.onEscape = () => {
301
+ // Active context maintenance owns Esc: auto/manual compaction,
302
+ // handoff generation, and auto-retry backoff all advertise
303
+ // "(esc to cancel)". Dispatch on live session state instead of
304
+ // swapping onEscape handlers — interleaved start/end events used
305
+ // to clobber the single saved-handler slot (auto-compaction start
306
+ // → /compact → auto end → manual finally), leaving Esc wired to a
307
+ // stale no-op closure until restart.
308
+ //
309
+ // While a subagent is focused, Esc honors the advertised view action
310
+ // ("Esc returns to main") instead of cancelling maintenance —
311
+ // accidentally killing a focused subagent's compaction on the way out
312
+ // was #2819. The auto-maintenance loaders relabel their hint to match
313
+ // (see EventController). Main-session maintenance still owns Esc and
314
+ // stays cancellable from the main view (focused submit gates /compact
315
+ // and handoff, so manual maintenance is main-only anyway).
316
+ if (!this.ctx.focusedAgentId) {
317
+ const viewSession = this.ctx.viewSession;
318
+ let aborted = false;
319
+ if (viewSession.isCompacting) {
320
+ safeAbort("compaction", () => viewSession.abortCompaction());
321
+ aborted = true;
322
+ }
323
+ if (viewSession.isGeneratingHandoff) {
324
+ safeAbort("handoff", () => viewSession.abortHandoff());
325
+ aborted = true;
326
+ }
327
+ if (viewSession.isRetrying) {
328
+ safeAbort("retry", () => viewSession.abortRetry());
329
+ aborted = true;
330
+ }
331
+ if (aborted) return;
332
+ }
333
+
334
+ if (this.ctx.loopModeEnabled) {
335
+ this.ctx.pauseLoop();
336
+ if (this.ctx.session.isStreaming) {
337
+ this.#handleStreamingEscape();
338
+ } else {
339
+ this.ctx.cancelPendingSubmission();
340
+ }
341
+ return;
342
+ }
343
+ if (this.ctx.hasActiveBtw() && this.ctx.handleBtwEscape()) {
344
+ return;
345
+ }
346
+ if (this.ctx.hasActiveOmfg() && this.ctx.handleOmfgEscape()) {
347
+ return;
348
+ }
349
+ if (this.ctx.focusedAgentId) {
350
+ // Esc never interrupts the focused agent's turn: clear typed text,
351
+ // else return the view to the main session. Interrupt via empty
352
+ // steer-flush submit if needed.
353
+ if (this.ctx.editor.getText().trim()) {
354
+ this.ctx.editor.setText("");
355
+ this.ctx.ui.requestRender();
356
+ } else {
357
+ void this.ctx.unfocusSession();
358
+ }
359
+ return; // double-escape backtrack (/tree, /branch) stays main-only
360
+ }
361
+ if (this.ctx.collabGuest) {
362
+ // Guest Esc: ask the host to interrupt its agent; the local replica
363
+ // session is never streaming, so the native abort path below would
364
+ // no-op.
365
+ if (this.ctx.collabGuest.state?.isStreaming || this.ctx.loadingAnimation) {
366
+ this.ctx.collabGuest.sendAbort();
367
+ }
368
+ return;
369
+ }
370
+ if (this.ctx.loadingAnimation) {
371
+ if (this.ctx.cancelPendingSubmission()) {
372
+ return;
373
+ }
374
+ this.restoreQueuedMessagesToEditor({ abort: true });
375
+ } else if (this.ctx.session.isBashRunning) {
376
+ this.ctx.session.abortBash();
377
+ } else if (this.ctx.isBashMode) {
378
+ this.ctx.editor.setText("");
379
+ this.ctx.isBashMode = false;
380
+ this.ctx.updateEditorBorderColor();
381
+ } else if (this.ctx.session.isEvalRunning) {
382
+ this.ctx.session.abortEval();
383
+ } else if (this.ctx.isPythonMode) {
384
+ this.ctx.editor.setText("");
385
+ this.ctx.isPythonMode = false;
386
+ this.ctx.updateEditorBorderColor();
387
+ } else if (this.ctx.session.isStreaming) {
388
+ this.#handleStreamingEscape();
389
+ } else if (this.ctx.editor.getText().trim()) {
390
+ // Esc must not destroy an in-progress draft; it only disarms a previous empty-editor Esc.
391
+ this.ctx.lastEscapeTime = 0;
392
+ this.#clearStreamingEscapeArm();
393
+ } else {
394
+ // Double-interrupt with empty editor triggers /tree, /branch, or nothing based on setting
395
+ const action = settings.get("doubleEscapeAction");
396
+ if (action !== "none") {
397
+ const now = Date.now();
398
+ if (now - this.ctx.lastEscapeTime < 500) {
399
+ if (action === "tree") {
400
+ this.ctx.showTreeSelector();
401
+ } else {
402
+ this.ctx.showUserMessageSelector();
403
+ }
404
+ this.ctx.ui.resetDisplay();
405
+ this.ctx.lastEscapeTime = 0;
406
+ } else {
407
+ this.ctx.lastEscapeTime = now;
408
+ }
409
+ }
410
+ }
411
+ };
412
+
413
+ this.ctx.editor.setActionKeys("app.clear", this.ctx.keybindings.getKeys("app.clear"));
414
+ this.ctx.editor.onClear = () => this.handleCtrlC();
415
+ this.ctx.editor.setActionKeys("app.exit", this.ctx.keybindings.getKeys("app.exit"));
416
+ this.ctx.editor.setActionKeys("app.display.reset", this.ctx.keybindings.getKeys("app.display.reset"));
417
+ this.ctx.editor.onDisplayReset = () => this.ctx.ui.resetDisplay();
418
+ this.ctx.editor.onExit = () => this.handleCtrlD();
419
+ this.ctx.editor.setActionKeys("app.suspend", this.ctx.keybindings.getKeys("app.suspend"));
420
+ this.ctx.editor.onSuspend = () => this.handleCtrlZ();
421
+ this.ctx.editor.setActionKeys("app.thinking.cycle", this.ctx.keybindings.getKeys("app.thinking.cycle"));
422
+ this.ctx.editor.onCycleThinkingLevel = () => this.cycleThinkingLevel();
423
+ this.ctx.editor.setActionKeys("app.model.cycleForward", this.ctx.keybindings.getKeys("app.model.cycleForward"));
424
+ this.ctx.editor.onCycleModelForward = () => this.cycleRoleModel("forward");
425
+ this.ctx.editor.setActionKeys("app.model.cycleBackward", this.ctx.keybindings.getKeys("app.model.cycleBackward"));
426
+ this.ctx.editor.onCycleModelBackward = () => this.cycleRoleModel("backward");
427
+ this.ctx.editor.setActionKeys(
428
+ "app.model.selectTemporary",
429
+ this.ctx.keybindings.getKeys("app.model.selectTemporary"),
430
+ );
431
+ this.ctx.editor.onSelectModelTemporary = () => this.ctx.showModelSelector({ temporaryOnly: true });
432
+
433
+ // Global debug handler on TUI (works regardless of focus)
434
+ this.ctx.ui.onDebug = () => this.ctx.showDebugSelector();
435
+ this.ctx.editor.setActionKeys("app.model.select", this.ctx.keybindings.getKeys("app.model.select"));
436
+ this.ctx.editor.onSelectModel = () => this.ctx.showModelSelector();
437
+ this.ctx.editor.setActionKeys("app.history.search", this.ctx.keybindings.getKeys("app.history.search"));
438
+ this.ctx.editor.onHistorySearch = () => this.ctx.showHistorySearch();
439
+ this.ctx.editor.setActionKeys("app.thinking.toggle", this.ctx.keybindings.getKeys("app.thinking.toggle"));
440
+ this.ctx.editor.onToggleThinking = () => this.ctx.toggleThinkingBlockVisibility();
441
+ this.ctx.editor.setActionKeys("app.editor.external", this.ctx.keybindings.getKeys("app.editor.external"));
442
+ this.ctx.editor.onExternalEditor = () => void this.openExternalEditor();
443
+ this.ctx.editor.setActionKeys(
444
+ "app.clipboard.pasteImage",
445
+ this.ctx.keybindings.getKeys("app.clipboard.pasteImage"),
446
+ );
447
+ this.ctx.editor.onPasteImage = () => this.handleImagePaste();
448
+ this.ctx.editor.onPasteImagePath = path => this.handleImagePathPaste(path);
449
+ this.ctx.editor.setActionKeys(
450
+ "app.clipboard.pasteTextRaw",
451
+ this.ctx.keybindings.getKeys("app.clipboard.pasteTextRaw"),
452
+ );
453
+ this.ctx.editor.onPasteTextRaw = () => void this.handleClipboardTextRawPaste();
454
+ this.ctx.editor.onLargePaste = (text, lineCount) => this.handleLargePaste(text, lineCount);
455
+ this.ctx.editor.setActionKeys(
456
+ "app.clipboard.copyPrompt",
457
+ this.ctx.keybindings.getKeys("app.clipboard.copyPrompt"),
458
+ );
459
+ this.ctx.editor.onCopyPrompt = () => this.handleCopyPrompt();
460
+ this.ctx.editor.setActionKeys("app.tools.expand", this.ctx.keybindings.getKeys("app.tools.expand"));
461
+ this.ctx.editor.onExpandTools = () => this.toggleToolOutputExpansion();
462
+ this.ctx.editor.setActionKeys("app.message.dequeue", this.ctx.keybindings.getKeys("app.message.dequeue"));
463
+ this.ctx.editor.onDequeue = () => this.handleDequeue();
464
+ this.ctx.editor.setActionKeys("app.retry", this.ctx.keybindings.getKeys("app.retry"));
465
+ this.ctx.editor.onRetry = () => void this.handleRetry();
466
+ this.ctx.editor.clearCustomKeyHandlers();
467
+ // Wire up extension shortcuts
468
+ this.registerExtensionShortcuts();
469
+ const planModeKeys = this.ctx.keybindings.getKeys("app.plan.toggle");
470
+ for (const key of planModeKeys) {
471
+ this.ctx.editor.setCustomKeyHandler(key, () => void this.ctx.handlePlanModeCommand());
472
+ }
473
+
474
+ for (const key of this.ctx.keybindings.getKeys("app.session.new")) {
475
+ this.ctx.editor.setCustomKeyHandler(key, () => this.ctx.handleClearCommand());
476
+ }
477
+ for (const key of this.ctx.keybindings.getKeys("app.session.tree")) {
478
+ this.ctx.editor.setCustomKeyHandler(key, () => this.ctx.showTreeSelector());
479
+ }
480
+ for (const key of this.ctx.keybindings.getKeys("app.session.fork")) {
481
+ this.ctx.editor.setCustomKeyHandler(key, () => this.ctx.showUserMessageSelector());
482
+ }
483
+ for (const key of this.ctx.keybindings.getKeys("app.session.resume")) {
484
+ this.ctx.editor.setCustomKeyHandler(key, () => this.ctx.showSessionSelector());
485
+ }
486
+ for (const key of this.ctx.keybindings.getKeys("app.message.followUp")) {
487
+ this.ctx.editor.setCustomKeyHandler(key, () => void this.handleFollowUp());
488
+ }
489
+ for (const key of this.ctx.keybindings.getKeys("app.stt.toggle")) {
490
+ this.ctx.editor.setCustomKeyHandler(key, () => void this.ctx.handleSTTToggle());
491
+ }
492
+ // Hold the space bar to push-to-talk: the editor recognizes the auto-repeat burst, tracks
493
+ // the spam back out, and toggles STT on hold start / release. Gated on `stt.enabled` so a
494
+ // disabled STT leaves the space bar typing normally.
495
+ this.ctx.editor.sttHoldEnabled = () => settings.get("stt.enabled");
496
+ this.ctx.editor.onSpaceHoldStart = () => void this.ctx.handleSTTToggle();
497
+ this.ctx.editor.onSpaceHoldEnd = () => void this.ctx.handleSTTToggle();
498
+ for (const key of this.ctx.keybindings.getKeys("app.clipboard.copyLine")) {
499
+ this.ctx.editor.setCustomKeyHandler(key, () => this.handleCopyCurrentLine());
500
+ }
501
+ const hubKeys = new Set([
502
+ ...this.ctx.keybindings.getKeys("app.agents.hub"),
503
+ ...this.ctx.keybindings.getKeys("app.session.observe"),
504
+ ]);
505
+ for (const key of hubKeys) {
506
+ this.ctx.editor.setCustomKeyHandler(key, () => this.ctx.showAgentHub());
507
+ }
508
+
509
+ // Double-tap left arrow on an empty editor: opens the agent hub from the
510
+ // main session, or returns the focused subagent view to the main session.
511
+ // Focused ←← intentionally matches Esc. From the main session the gesture
512
+ // stays inert when there are no subagents (requireContent); the explicit
513
+ // hub key still opens the empty roster.
514
+ this.ctx.editor.onLeftAtStart = () => {
515
+ if (this.ctx.focusedAgentId) {
516
+ this.#handleFocusedLeftTap();
517
+ return;
518
+ }
519
+ if (this.#detectLeftDoubleTap()) {
520
+ this.ctx.showAgentHub({ requireContent: true });
521
+ }
522
+ };
523
+
524
+ this.#setupEnhancedPaste();
525
+
526
+ this.ctx.editor.onChange = (text: string) => {
527
+ const wasBashMode = this.ctx.isBashMode;
528
+ const wasPythonMode = this.ctx.isPythonMode;
529
+ const trimmed = text.trimStart();
530
+ this.ctx.isBashMode = trimmed.startsWith("!");
531
+ this.ctx.isPythonMode = pythonCommandPrefixLength(trimmed) > 0;
532
+ if (wasBashMode !== this.ctx.isBashMode || wasPythonMode !== this.ctx.isPythonMode) {
533
+ this.ctx.updateEditorBorderColor();
534
+ }
535
+ };
536
+ }
537
+
538
+ #handleFocusedLeftTap(): void {
539
+ if (this.#detectLeftDoubleTap()) {
540
+ void this.ctx.unfocusSession();
541
+ }
542
+ }
543
+
544
+ /**
545
+ * Detect a deliberate double-← gesture, rejecting terminal-synthesized arrow
546
+ * bursts. Returns true only on the *second* tap of a fresh sequence when it
547
+ * lands a human-plausible interval after the first
548
+ * (`[LEFT_DOUBLE_TAP_MIN_GAP_MS, LEFT_DOUBLE_TAP_MAX_GAP_MS)`). Taps closer
549
+ * than the lower bound, or any third-and-later tap before a quiet gap, are a
550
+ * burst and never fire — so a stray click that makes the terminal emit a run
551
+ * of ← keys can no longer pop the Agent Hub.
552
+ */
553
+ #detectLeftDoubleTap(): boolean {
554
+ const now = Date.now();
555
+ const sinceLast = now - this.ctx.lastLeftTapTime;
556
+ this.ctx.lastLeftTapTime = now;
557
+ if (sinceLast >= LEFT_DOUBLE_TAP_MAX_GAP_MS) {
558
+ // Quiet gap: this tap starts a fresh sequence.
559
+ this.#leftTapCount = 1;
560
+ return false;
561
+ }
562
+ this.#leftTapCount += 1;
563
+ if (this.#leftTapCount === 2 && sinceLast >= LEFT_DOUBLE_TAP_MIN_GAP_MS) {
564
+ // Exactly two taps, the second a human-plausible interval after the first.
565
+ this.#leftTapCount = 0;
566
+ this.ctx.lastLeftTapTime = 0;
567
+ return true;
568
+ }
569
+ return false;
570
+ }
571
+
572
+ #setupEnhancedPaste(): void {
573
+ if (this.#enhancedPaste) return;
574
+
575
+ this.#enhancedPaste = new EnhancedPasteController({
576
+ write: data => this.ctx.ui.terminal.write(data),
577
+ pasteText: text => {
578
+ // Route enhanced-paste text to the currently focused component when it
579
+ // exposes a `pasteText` hook (modal Input prompts: OAuth API-key entry,
580
+ // Perplexity OTP, GitHub Enterprise URL, manual redirect URL). Falling
581
+ // back to the main editor would have buried the text in the detached
582
+ // editor while the modal Input had focus (#2127).
583
+ const focused = this.ctx.ui.getFocused();
584
+ const target = focused && focused !== this.ctx.editor && hasPasteText(focused) ? focused : this.ctx.editor;
585
+ target.pasteText(text);
586
+ this.ctx.ui.requestRender();
587
+ },
588
+ pasteImage: async image => {
589
+ // Images can only land in the main editor — when a modal Input is
590
+ // focused, refuse rather than dump the binary blob in a hidden buffer.
591
+ const focused = this.ctx.ui.getFocused();
592
+ if (focused && focused !== this.ctx.editor && hasPasteText(focused)) {
593
+ this.ctx.showStatus("Image paste is not supported in this prompt");
594
+ return;
595
+ }
596
+ await this.#normalizeAndInsertPastedImage(image, `Unsupported pasted image format: ${image.mimeType}`);
597
+ },
598
+ showStatus: message => this.ctx.showStatus(message),
599
+ });
600
+ this.ctx.ui.addInputListener(data => (this.#enhancedPaste?.handleInput(data) ? { consume: true } : undefined));
601
+ this.ctx.ui.addStartListener(() => this.#enhancedPaste?.enable());
602
+ }
603
+
604
+ setupEditorSubmitHandler(): void {
605
+ this.ctx.editor.onSubmit = async (text: string) => {
606
+ text = text.trim();
607
+ const hasPendingImages = this.ctx.editor.pendingImages.length > 0;
608
+ if ((!isSettingsInitialized() || settings.get("emojiAutocomplete")) && text) text = expandEmoticons(text);
609
+
610
+ // Focused subagent session: the editor is a plain chat box for it.
611
+ // Everything below (continue shortcuts, slash/bash/python, loop,
612
+ // compaction queueing) is main-session-only.
613
+ if (this.ctx.focusedAgentId) {
614
+ await this.#submitToFocusedSession(text, "steer");
615
+ return;
616
+ }
617
+
618
+ // Empty submit while streaming with queued messages: abort the active
619
+ // turn and let the post-unwind drain deliver the agent-core queue.
620
+ if (!text && !hasPendingImages && this.ctx.session.isStreaming) {
621
+ if (this.ctx.session.queuedMessageCount > 0) {
622
+ const aborting = this.ctx.session.abort({ reason: USER_INTERRUPT_LABEL });
623
+ await aborting;
624
+ this.ctx.updatePendingMessagesDisplay();
625
+ this.ctx.ui.requestRender();
626
+ }
627
+ return;
628
+ }
629
+
630
+ if (!text && !hasPendingImages) return;
631
+
632
+ // Continue shortcuts: "." or "c" resume the agent with a hidden agent-authored
633
+ // developer directive (no visible user message) instead of an empty turn, so the
634
+ // model continues the prior intent rather than second-guessing the interrupt.
635
+ if (text === "." || text === "c") {
636
+ if (this.ctx.onInputCallback) {
637
+ this.ctx.editor.clearDraft();
638
+ this.ctx.onInputCallback({
639
+ text: manualContinuePrompt,
640
+ cancelled: false,
641
+ started: true,
642
+ synthetic: true,
643
+ userInitiated: true,
644
+ });
645
+ }
646
+ return;
647
+ }
648
+
649
+ const runner = this.ctx.session.extensionRunner;
650
+ let inputImages = this.ctx.editor.pendingImages.length > 0 ? [...this.ctx.editor.pendingImages] : undefined;
651
+ let inputImageLinks =
652
+ this.ctx.editor.pendingImageLinks.length > 0 ? [...this.ctx.editor.pendingImageLinks] : undefined;
653
+ let hasInputImages = (inputImages?.length ?? 0) > 0;
654
+
655
+ if (runner?.hasHandlers("input")) {
656
+ const result = await runner.emitInput(text, inputImages, "interactive");
657
+ if (result?.handled) {
658
+ this.ctx.editor.clearDraft();
659
+ return;
660
+ }
661
+ if (result?.text !== undefined) {
662
+ text = result.text.trim();
663
+ }
664
+ if (result?.images !== undefined) {
665
+ inputImages = result.images;
666
+ inputImageLinks = await materializeImageReferenceLinks(
667
+ inputImages,
668
+ this.ctx.sessionManager.putBlob.bind(this.ctx.sessionManager),
669
+ );
670
+ }
671
+ hasInputImages = (inputImages?.length ?? 0) > 0;
672
+ }
673
+
674
+ if (!text && !hasInputImages) return;
675
+
676
+ // Handle built-in slash commands
677
+ if (text) {
678
+ const slashResult = await executeBuiltinSlashCommand(text, {
679
+ ctx: this.ctx,
680
+ });
681
+ if (slashResult === true) {
682
+ if (!shouldSkipHistory(text)) this.ctx.editor.addToHistory(text);
683
+ return;
684
+ }
685
+ if (typeof slashResult === "string") {
686
+ // Command handled but returned remaining text to use as prompt.
687
+ // Record the original slash command text so Up Arrow recalls
688
+ // "/loop 10 fix bug" rather than just "fix bug".
689
+ if (!shouldSkipHistory(text)) this.ctx.editor.addToHistory(text);
690
+ text = slashResult;
691
+ }
692
+ }
693
+
694
+ // Collab guest: prompts execute on the host; local slash/skill/bash/
695
+ // python execution is host-only (builtins are gated inside
696
+ // executeBuiltinSlashCommand, which already consumed allowed ones).
697
+ if (this.ctx.collabGuest) {
698
+ if (text.startsWith("/")) {
699
+ this.ctx.showStatus(`${text.split(/\s+/, 1)[0]} is host-only during a collab session`);
700
+ this.ctx.editor.setText("");
701
+ return;
702
+ }
703
+ if (text.startsWith("!") || parsePythonCommandInput(text)) {
704
+ this.ctx.showStatus("Local execution is host-only during a collab session");
705
+ this.ctx.editor.setText("");
706
+ return;
707
+ }
708
+ if (this.ctx.collabGuest.readOnly) {
709
+ // Keep the typed text: the prompt was not consumed.
710
+ this.ctx.showStatus("This collab link is read-only — prompting is disabled");
711
+ return;
712
+ }
713
+ const images = inputImages && inputImages.length > 0 ? [...inputImages] : undefined;
714
+ this.ctx.editor.clearDraft(text);
715
+ // No local render: the prompt comes back from the host as a
716
+ // collab-prompt event/entry and renders with the author badge.
717
+ this.ctx.collabGuest.sendPrompt(text, images);
718
+ return;
719
+ }
720
+
721
+ // Handle skill commands (/skill:name [args]). Enter ⇒ steer (matches the
722
+ // free-text Enter semantics below); Ctrl+Enter routes through `handleFollowUp`.
723
+ // During compaction, queue immediately so bash/python/loop-mode branches do
724
+ // not consume the skill before the compaction-resume path re-parses it.
725
+ if (text && isKnownSkillCommand(this.ctx, text)) {
726
+ if (this.ctx.session.isCompacting) {
727
+ const images = inputImages && inputImages.length > 0 ? [...inputImages] : undefined;
728
+ this.ctx.queueCompactionMessage(text, "steer", images);
729
+ return;
730
+ }
731
+ if (await this.#invokeSkillCommand(text, "steer", inputImages, inputImageLinks)) {
732
+ return;
733
+ }
734
+ }
735
+
736
+ // Handle bash command (! for normal, !! for excluded from context)
737
+ if (text.startsWith("!")) {
738
+ const isExcluded = text.startsWith("!!");
739
+ const command = isExcluded ? text.slice(2).trim() : text.slice(1).trim();
740
+ if (command) {
741
+ if (this.ctx.session.isBashRunning) {
742
+ this.ctx.showWarning("A bash command is already running. Press Esc to cancel it first.");
743
+ this.ctx.editor.setText(text);
744
+ return;
745
+ }
746
+ this.ctx.editor.addToHistory(text);
747
+ await this.ctx.handleBashCommand(command, isExcluded);
748
+ this.ctx.isBashMode = false;
749
+ this.ctx.updateEditorBorderColor();
750
+ return;
751
+ }
752
+ }
753
+
754
+ // Handle python command (`$ <code>` for normal, `$$ <code>` for excluded from context).
755
+ // Shell-style variables such as `$HOME` are normal prose unless a space follows the sigil.
756
+ const pythonCommand = parsePythonCommandInput(text);
757
+ if (pythonCommand) {
758
+ const { code, isExcluded } = pythonCommand;
759
+ if (code) {
760
+ if (this.ctx.session.isEvalRunning) {
761
+ this.ctx.showWarning("A Python execution is already running. Press Esc to cancel it first.");
762
+ this.ctx.editor.setText(text);
763
+ return;
764
+ }
765
+ this.ctx.editor.addToHistory(text);
766
+ await this.ctx.handlePythonCommand(code, isExcluded);
767
+ this.ctx.isPythonMode = false;
768
+ this.ctx.updateEditorBorderColor();
769
+ return;
770
+ }
771
+ }
772
+
773
+ // While loop mode is on, every user-typed prompt becomes the new loop
774
+ // prompt that auto-resubmits after each yield.
775
+ if (this.ctx.loopModeEnabled) {
776
+ this.ctx.loopPrompt = text;
777
+ }
778
+
779
+ // Queue input during compaction
780
+ if (this.ctx.session.isCompacting) {
781
+ const images = inputImages && inputImages.length > 0 ? [...inputImages] : undefined;
782
+ this.ctx.queueCompactionMessage(text, "steer", images);
783
+ return;
784
+ }
785
+
786
+ // If streaming, use prompt() with steer behavior
787
+ // This handles extension commands (execute immediately), prompt template expansion, and queueing
788
+ if (this.ctx.session.isStreaming) {
789
+ this.ctx.editor.addToHistory(text);
790
+ this.ctx.editor.setText("");
791
+ this.ctx.editor.imageLinks = undefined;
792
+ const images = inputImages && inputImages.length > 0 ? [...inputImages] : undefined;
793
+ this.ctx.editor.pendingImages = [];
794
+ this.ctx.editor.pendingImageLinks = [];
795
+ // Record the signature so the queued message's eventual delivery
796
+ // (a user-role `message_start` event) leaves any draft the user has
797
+ // typed since queuing intact. Same protection as #783, applied to
798
+ // the streaming/queue path.
799
+ try {
800
+ await this.ctx.withLocalSubmission(
801
+ text,
802
+ () => this.ctx.session.prompt(text, { streamingBehavior: "steer", images }),
803
+ { imageCount: images?.length ?? 0 },
804
+ );
805
+ } catch (error) {
806
+ // Don't lose the queued steer draft: restore text and images so
807
+ // the user can retry after dispatch validation/queue failures.
808
+ this.ctx.editor.setText(text);
809
+ if (images && images.length > 0) {
810
+ this.ctx.editor.pendingImages = [...images];
811
+ this.ctx.editor.pendingImageLinks = inputImageLinks
812
+ ? [...inputImageLinks]
813
+ : images.map(() => undefined);
814
+ this.ctx.editor.imageLinks = this.ctx.editor.pendingImageLinks;
815
+ }
816
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
817
+ }
818
+ this.ctx.updatePendingMessagesDisplay();
819
+ this.ctx.ui.requestRender();
820
+ return;
821
+ }
822
+
823
+ // Normal message submission
824
+ // First, move any pending bash components to chat
825
+ this.ctx.flushPendingBashComponents();
826
+
827
+ // Auto-generate a session title while the session is still unnamed.
828
+ // Greetings / acknowledgements / empty input carry no task, so they are
829
+ // skipped deterministically (no model invoked, no download-progress UI)
830
+ // and the session stays unnamed — the next user message gets a fresh
831
+ // chance, so titling defers past "hi" instead of latching onto it.
832
+ if (!this.ctx.sessionManager.getSessionName() && !$env.PI_NO_TITLE && !isLowSignalTitleInput(text)) {
833
+ this.#showTinyTitleDownloadProgress(this.ctx.settings.get("providers.tinyModel"));
834
+ const registry = this.ctx.session.modelRegistry;
835
+ generateSessionTitle(
836
+ text,
837
+ registry,
838
+ this.ctx.settings,
839
+ this.ctx.session.sessionId,
840
+ this.ctx.session.model,
841
+ provider => this.ctx.session.agent.metadataForProvider(provider),
842
+ this.ctx.session.titleSystemPrompt,
843
+ )
844
+ .then(async title => {
845
+ // Re-check: a concurrent attempt for an earlier message may have
846
+ // already named the session. Don't clobber it. Terminal title and
847
+ // accent updates fire from the onSessionNameChanged listener.
848
+ if (title && !this.ctx.sessionManager.getSessionName()) {
849
+ await this.ctx.sessionManager.setSessionName(title, "auto");
850
+ }
851
+ })
852
+ .catch(err => {
853
+ logger.warn("title-generator: uncaught auto-title error", {
854
+ sessionId: this.ctx.session.sessionId,
855
+ reason: "uncaught-auto-title-error",
856
+ error: err instanceof Error ? err.message : String(err),
857
+ });
858
+ });
859
+ }
860
+
861
+ if (this.ctx.onInputCallback) {
862
+ // Include any pending images from clipboard paste
863
+ this.ctx.editor.imageLinks = undefined;
864
+ const images = inputImages && inputImages.length > 0 ? [...inputImages] : undefined;
865
+ this.ctx.editor.pendingImages = [];
866
+ this.ctx.editor.pendingImageLinks = [];
867
+
868
+ // Render user message immediately, then let session events catch up.
869
+ // Tag the submission as "steer": this is a normal Enter the controller
870
+ // believed was idle, but a background turn can start in the gap before
871
+ // `submitInteractiveInput` dispatches it. Steering matches the
872
+ // streaming-branch Enter (above) and keeps the message from throwing
873
+ // AgentBusyError on that race.
874
+ const submission = this.ctx.startPendingSubmission({
875
+ text,
876
+ images,
877
+ imageLinks: inputImageLinks,
878
+ streamingBehavior: "steer",
879
+ });
880
+
881
+ this.ctx.onInputCallback(submission);
882
+ } else {
883
+ // No input waiter: the main loop is between turns (post-turn
884
+ // epilogue, retry backoff, or a scheduled continue) with the agent
885
+ // momentarily idle. The editor already cleared itself on Enter, so
886
+ // falling through here would silently swallow the message. Submit a
887
+ // real prompt directly; if a background turn starts in the gap,
888
+ // `streamingBehavior: "steer"` preserves the typed-message queueing
889
+ // semantics instead of throwing AgentBusyError.
890
+ this.ctx.editor.imageLinks = undefined;
891
+ const images = inputImages && inputImages.length > 0 ? [...inputImages] : undefined;
892
+ this.ctx.editor.pendingImages = [];
893
+ this.ctx.editor.pendingImageLinks = [];
894
+ try {
895
+ await this.ctx.withLocalSubmission(
896
+ text,
897
+ () => this.ctx.session.prompt(text, { streamingBehavior: "steer", images }),
898
+ {
899
+ imageCount: images?.length ?? 0,
900
+ },
901
+ );
902
+ } catch (error) {
903
+ // Don't lose the message: hand the text and images back to the
904
+ // editor so the user can retry (e.g. prompt dispatch rejecting an
905
+ // extension command).
906
+ this.ctx.editor.setText(text);
907
+ if (images && images.length > 0) {
908
+ this.ctx.editor.pendingImages = [...images];
909
+ this.ctx.editor.pendingImageLinks = inputImageLinks
910
+ ? [...inputImageLinks]
911
+ : images.map(() => undefined);
912
+ this.ctx.editor.imageLinks = this.ctx.editor.pendingImageLinks;
913
+ }
914
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
915
+ }
916
+ this.ctx.updatePendingMessagesDisplay();
917
+ this.ctx.ui.requestRender();
918
+ }
919
+ this.ctx.editor.addToHistory(text);
920
+ };
921
+ }
922
+
923
+ /** Submit editor text to the focused subagent session (chat-only focus policy). */
924
+ async #submitToFocusedSession(text: string, streamingBehavior: "steer" | "followUp"): Promise<void> {
925
+ const target = this.ctx.viewSession;
926
+ const images = this.ctx.editor.pendingImages.length > 0 ? [...this.ctx.editor.pendingImages] : undefined;
927
+ const imageLinks =
928
+ images && this.ctx.editor.pendingImageLinks.length > 0 ? [...this.ctx.editor.pendingImageLinks] : undefined;
929
+ if (!text && !images) {
930
+ if (target.isStreaming && target.queuedMessageCount > 0) {
931
+ const aborting = target.abort({ reason: USER_INTERRUPT_LABEL });
932
+ await aborting;
933
+ this.ctx.updatePendingMessagesDisplay();
934
+ this.ctx.ui.requestRender();
935
+ }
936
+ return;
937
+ }
938
+ if (text && (text.startsWith("/") || text.startsWith("!") || parsePythonCommandInput(text))) {
939
+ this.ctx.showStatus("Commands run in the main session — press ←← to return first");
940
+ return; // editor text not cleared: Editor does not auto-clear on submit
941
+ }
942
+ this.ctx.editor.clearDraft(text);
943
+ try {
944
+ // prompt() handles idle (new turn) and streaming (queues per streamingBehavior).
945
+ await this.ctx.withLocalSubmission(text, () => target.prompt(text, { streamingBehavior, images }), {
946
+ imageCount: images?.length ?? 0,
947
+ });
948
+ } catch (error) {
949
+ // Hand the message back, mirroring the main submit error path: restore
950
+ // pasted images so the user can retry an image-only or text+image draft.
951
+ this.ctx.editor.setText(text);
952
+ if (images && images.length > 0) {
953
+ this.ctx.editor.pendingImages = [...images];
954
+ this.ctx.editor.pendingImageLinks = imageLinks ? [...imageLinks] : images.map(() => undefined);
955
+ this.ctx.editor.imageLinks = this.ctx.editor.pendingImageLinks;
956
+ }
957
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
958
+ }
959
+ this.ctx.updatePendingMessagesDisplay();
960
+ this.ctx.ui.requestRender();
961
+ }
962
+
963
+ handleCtrlC(): void {
964
+ // Sync-flush the session JSONL so in-flight writes survive a hard exit.
965
+ // The TUI consumes Ctrl+C as a key event in raw mode, so postmortem's
966
+ // process-level SIGINT handler never fires. shutdown() awaits its own
967
+ // async flush — this sync pass is a superset that also covers the
968
+ // first-press case and the hard-abort path below.
969
+ try {
970
+ this.ctx.sessionManager.flushSync();
971
+ } catch (err) {
972
+ logger.warn("session-manager sync flush on Ctrl+C failed", {
973
+ error: err instanceof Error ? err.message : String(err),
974
+ });
975
+ }
976
+
977
+ // Hard-abort: a Ctrl+C arriving while shutdown() is already running
978
+ // means the user has waited long enough for whatever teardown step is
979
+ // stuck (typically an extension's session_shutdown handler hanging on
980
+ // IPC). The 2s session_shutdown cap (see runner.ts) already bounds the
981
+ // common case; this is the defense-in-depth ladder for everything
982
+ // else. See issue #2600.
983
+ if (this.ctx.isShuttingDown) {
984
+ process.exit(130); // 128 + SIGINT
985
+ }
986
+
987
+ const now = Date.now();
988
+ if (now - this.ctx.lastSigintTime < 500) {
989
+ void this.ctx.shutdown();
990
+ } else {
991
+ this.ctx.clearEditor();
992
+ this.ctx.lastSigintTime = now;
993
+ }
994
+ }
995
+
996
+ handleCtrlD(): void {
997
+ // Editor text (if any) is snapshotted at the start of shutdown() and
998
+ // persisted as a draft for the next resume. Empty text is also fine —
999
+ // shutdown clears any stale sidecar in that case.
1000
+ void this.ctx.shutdown();
1001
+ }
1002
+
1003
+ handleCtrlZ(): void {
1004
+ // Job-control suspend is POSIX-only: on Windows `process.kill(_, "SIGSTOP")`
1005
+ // throws `TypeError: Unknown signal: SIGSTOP` and takes the whole agent down
1006
+ // via an uncaught exception (issue #2036, originally for SIGTSTP — same
1007
+ // shape for SIGSTOP). No-op on platforms that cannot suspend.
1008
+ if (process.platform === "win32") {
1009
+ this.ctx.showStatus("Suspend (Ctrl+Z) is not supported on this platform");
1010
+ return;
1011
+ }
1012
+
1013
+ // Capture the listener so we can detach it if the signal never fires;
1014
+ // otherwise a failed suspend would leave a stale SIGCONT handler that
1015
+ // fires on the next unrelated continue and tries to re-`start()` an
1016
+ // already-running TUI.
1017
+ const onResume = (): void => {
1018
+ this.ctx.ui.start();
1019
+ this.ctx.ui.requestRender(true);
1020
+ };
1021
+ process.once("SIGCONT", onResume);
1022
+
1023
+ // Stop the TUI (restore terminal to normal mode) before sending the
1024
+ // signal so the parent shell sees a sane terminal state.
1025
+ this.ctx.ui.stop();
1026
+
1027
+ try {
1028
+ // SIGSTOP — not SIGTSTP — to the foreground process group (pid=0).
1029
+ //
1030
+ // SIGTSTP: brush-core (the embedded shell behind every bash tool call)
1031
+ // installs a tokio SIGTSTP listener on `Process::wait` to detect when
1032
+ // its children have been stopped (`crates/vendor/brush-core/src/sys/
1033
+ // unix/signal.rs::tstp_signal_listener` → `tokio::signal::unix::
1034
+ // signal(SIGTSTP)`). Per tokio's documented contract, the first call
1035
+ // for a given SignalKind permanently replaces the kernel-default
1036
+ // handler for the lifetime of the process. So once the user has
1037
+ // issued even one bash command — e.g. `/usr/bin/true` — SIGTSTP no
1038
+ // longer stops omp: tokio swallows it and the TUI ends up torn down
1039
+ // while the process keeps running with no live terminal (issue
1040
+ // [#3461]). SIGSTOP cannot be caught, blocked, or ignored, so the
1041
+ // kernel stops the process regardless of installed handlers.
1042
+ //
1043
+ // pid=0 (foreground process group, not just our PID): omp is not
1044
+ // always the shell's direct child. Package-manager launchers (`npx`,
1045
+ // `pnpm exec`, `bunx`, …) wait on the real CLI from a parent shim
1046
+ // that shares omp's process group, and a `omp … | tee log` style
1047
+ // pipeline puts a sibling foreground job member in the same group
1048
+ // too. The shell sees the job as stopped only when its direct
1049
+ // child / pipeline leader is stopped, so suspending only our PID
1050
+ // leaves wrappers and pipeline peers running and the terminal
1051
+ // hung — exactly the failure shape we're fixing. Stopping the whole
1052
+ // group keeps the shell's job-control view consistent. Long-lived
1053
+ // children that must survive the suspend (MCP stdio servers via
1054
+ // the `detached: true` spawn in `mcp/transports/stdio.ts`, every
1055
+ // brush external command via brush's per-child `setsid` in
1056
+ // `crates/vendor/brush-core/src/commands.rs`) are already in
1057
+ // their own sessions, so pgid=0 does not reach them.
1058
+ process.kill(0, "SIGSTOP");
1059
+ } catch (err) {
1060
+ // The runtime refused the signal (e.g. seccomp filter blocks SIGSTOP
1061
+ // delivery to the process group). Tear the resume hook down and
1062
+ // bring the TUI back so the user is not stranded on a frozen prompt.
1063
+ process.removeListener("SIGCONT", onResume);
1064
+ this.ctx.ui.start();
1065
+ this.ctx.ui.requestRender(true);
1066
+ const reason = err instanceof Error ? err.message : String(err);
1067
+ this.ctx.showError(`Failed to suspend: ${reason}`);
1068
+ }
1069
+ }
1070
+
1071
+ handleDequeue(): void {
1072
+ const restored = this.restoreQueuedMessagesToEditor();
1073
+ if (restored === 0) {
1074
+ this.ctx.showStatus("No queued messages to restore");
1075
+ } else {
1076
+ this.ctx.showStatus(`Restored ${restored} queued message${restored > 1 ? "s" : ""} to editor`);
1077
+ }
1078
+ }
1079
+
1080
+ /**
1081
+ * Dispatch a `/skill:<name> [args]` invocation through `promptCustomMessage`
1082
+ * using the supplied `streamingBehavior`. Returns false when the text is not
1083
+ * a registered skill command and leaves the editor state untouched. Registered
1084
+ * skills consume the full composer draft (text plus pending images) before
1085
+ * dispatch; if dispatch rejects, the draft is restored so the user can retry.
1086
+ */
1087
+ async #invokeSkillCommand(
1088
+ text: string,
1089
+ streamingBehavior: "steer" | "followUp",
1090
+ images?: ImageContent[],
1091
+ imageLinks?: (string | undefined)[],
1092
+ ): Promise<boolean> {
1093
+ if (!isKnownSkillCommand(this.ctx, text)) return false;
1094
+ const draftImages = images && images.length > 0 ? [...images] : undefined;
1095
+ const draftImageLinks = draftImages && imageLinks && imageLinks.length > 0 ? [...imageLinks] : undefined;
1096
+ const restoreDraft = () => {
1097
+ this.ctx.editor.setText(text);
1098
+ if (draftImages && draftImages.length > 0) {
1099
+ this.ctx.editor.pendingImages = [...draftImages];
1100
+ this.ctx.editor.pendingImageLinks = draftImageLinks
1101
+ ? [...draftImageLinks]
1102
+ : draftImages.map(() => undefined);
1103
+ this.ctx.editor.imageLinks = this.ctx.editor.pendingImageLinks;
1104
+ }
1105
+ };
1106
+
1107
+ this.ctx.editor.clearDraft(text);
1108
+ try {
1109
+ const handled = await invokeSkillCommandFromText(this.ctx, text, streamingBehavior, {
1110
+ images: draftImages,
1111
+ propagateErrors: true,
1112
+ });
1113
+ if (!handled) {
1114
+ restoreDraft();
1115
+ return false;
1116
+ }
1117
+ return true;
1118
+ } catch (error) {
1119
+ restoreDraft();
1120
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
1121
+ return true;
1122
+ } finally {
1123
+ if (this.ctx.session.isStreaming) {
1124
+ this.ctx.updatePendingMessagesDisplay();
1125
+ this.ctx.ui.requestRender();
1126
+ }
1127
+ }
1128
+ }
1129
+
1130
+ async handleRetry(): Promise<void> {
1131
+ if (this.ctx.collabGuest) {
1132
+ this.ctx.showStatus("/retry is host-only during a collab session");
1133
+ return;
1134
+ }
1135
+ const didRetry = await this.ctx.viewSession.retry();
1136
+ if (didRetry) {
1137
+ this.ctx.editor.clearDraft();
1138
+ } else {
1139
+ this.ctx.showStatus("Nothing to retry");
1140
+ }
1141
+ }
1142
+
1143
+ /** Send editor text as a follow-up message (queued behind current stream). */
1144
+ async handleFollowUp(): Promise<void> {
1145
+ let text = this.ctx.editor.getExpandedText().trim();
1146
+ const images = this.ctx.editor.pendingImages.length > 0 ? [...this.ctx.editor.pendingImages] : undefined;
1147
+ const imageLinks =
1148
+ images && this.ctx.editor.pendingImageLinks.length > 0 ? [...this.ctx.editor.pendingImageLinks] : undefined;
1149
+ if (!text && !images) return;
1150
+
1151
+ // Focused subagent session: follow-ups go to it; non-chat input is gated.
1152
+ if (this.ctx.focusedAgentId) {
1153
+ await this.#submitToFocusedSession(text, "followUp");
1154
+ return;
1155
+ }
1156
+
1157
+ // Compaction first: while compacting, free text gets queued via
1158
+ // `queueCompactionMessage`, and `/skill:*` rides the same queue so a
1159
+ // skill typed during compaction is not lost or short-circuited through
1160
+ // `promptCustomMessage`. The compaction-resume path re-parses the
1161
+ // queued text into a user-attributed skill invocation before delivery.
1162
+ if (this.ctx.session.isCompacting) {
1163
+ const images = this.ctx.editor.pendingImages.length > 0 ? [...this.ctx.editor.pendingImages] : undefined;
1164
+ this.ctx.queueCompactionMessage(text, "followUp", images);
1165
+ return;
1166
+ }
1167
+
1168
+ if (text) {
1169
+ const slashResult = await executeBuiltinSlashCommand(text, {
1170
+ ctx: this.ctx,
1171
+ });
1172
+ if (slashResult === true) {
1173
+ if (!shouldSkipHistory(text)) this.ctx.editor.addToHistory(text);
1174
+ return;
1175
+ }
1176
+ if (typeof slashResult === "string") {
1177
+ // Command handled but returned remaining text to use as prompt.
1178
+ // Record the original slash command text so Up Arrow recalls it.
1179
+ if (!shouldSkipHistory(text)) this.ctx.editor.addToHistory(text);
1180
+ text = slashResult;
1181
+ }
1182
+ }
1183
+
1184
+ // Skill commands invoke through the custom-message path regardless of
1185
+ // which keybinding submitted them. Enter routes them as `steer`;
1186
+ // Ctrl+Enter (this handler) routes them as `followUp`.
1187
+ if (text && (await this.#invokeSkillCommand(text, "followUp", images, imageLinks))) {
1188
+ return;
1189
+ }
1190
+
1191
+ // Hand the message back on dispatch failure (model/API-key validation,
1192
+ // queue rejection): restore both text AND pending images so an image-only
1193
+ // or text+image draft can be retried, mirroring the main submit error path.
1194
+ const restoreOnError = (error: unknown) => {
1195
+ this.ctx.editor.setText(text);
1196
+ if (images && images.length > 0) {
1197
+ this.ctx.editor.pendingImages = [...images];
1198
+ this.ctx.editor.pendingImageLinks = imageLinks ? [...imageLinks] : images.map(() => undefined);
1199
+ this.ctx.editor.imageLinks = this.ctx.editor.pendingImageLinks;
1200
+ }
1201
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
1202
+ };
1203
+
1204
+ if (this.ctx.session.isStreaming) {
1205
+ this.ctx.editor.clearDraft(text);
1206
+ try {
1207
+ await this.ctx.withLocalSubmission(
1208
+ text,
1209
+ () => this.ctx.session.prompt(text, { streamingBehavior: "followUp", images }),
1210
+ { imageCount: images?.length ?? 0 },
1211
+ );
1212
+ } catch (error) {
1213
+ restoreOnError(error);
1214
+ }
1215
+ this.ctx.updatePendingMessagesDisplay();
1216
+ this.ctx.ui.requestRender();
1217
+ return;
1218
+ }
1219
+
1220
+ // Not streaming — just submit normally
1221
+ this.ctx.editor.clearDraft(text);
1222
+ try {
1223
+ await this.ctx.withLocalSubmission(text, () => this.ctx.session.prompt(text, { images }), {
1224
+ imageCount: images?.length ?? 0,
1225
+ });
1226
+ } catch (error) {
1227
+ restoreOnError(error);
1228
+ }
1229
+ }
1230
+
1231
+ restoreQueuedMessagesToEditor(options?: { abort?: boolean; currentText?: string }): number {
1232
+ this.ctx.locallySubmittedUserSignatures.clear();
1233
+ // On Esc (abort) drop non-user internal steers so the post-abort drain can't
1234
+ // auto-resume; plain Alt+Up dequeue preserves them for the continuing stream.
1235
+ const { steering, followUp } = this.ctx.session.clearQueue({ forInterrupt: options?.abort });
1236
+ // Messages typed while compacting live in `compactionQueuedMessages`, not the
1237
+ // agent queue `clearQueue()` drains — but the pending bar shows the same
1238
+ // "Alt+Up to edit" hint for them (ui-helpers `updatePendingMessagesDisplay`).
1239
+ // Drain them here too so the dequeue restores every message the hint
1240
+ // advertises; otherwise a skill/text queued during compaction is stranded and
1241
+ // Alt+Up reports "No queued messages to restore".
1242
+ const compactionQueued = this.ctx.compactionQueuedMessages;
1243
+ this.ctx.compactionQueuedMessages = [];
1244
+ const allQueued = [
1245
+ ...steering,
1246
+ ...compactionQueued.filter(e => e.mode === "steer").map(e => ({ text: e.text, images: e.images })),
1247
+ ...followUp,
1248
+ ...compactionQueued.filter(e => e.mode === "followUp").map(e => ({ text: e.text, images: e.images })),
1249
+ ];
1250
+ if (allQueued.length === 0) {
1251
+ this.ctx.updatePendingMessagesDisplay();
1252
+ if (options?.abort) {
1253
+ void this.ctx.session.abort({ reason: USER_INTERRUPT_LABEL });
1254
+ }
1255
+ return 0;
1256
+ }
1257
+ // Image markers are positional: `[Image #N]` ↔ `pendingImages[N-1]`. Each
1258
+ // queued message numbered its markers against its own local image list
1259
+ // (1..K). Because we prepend the queued text but append the queued images
1260
+ // to `pendingImages`, any existing draft images (M of them) — plus images
1261
+ // already pulled in by earlier queued messages — shift the slot index that
1262
+ // every marker must point to. Bumping each message's markers by the
1263
+ // running offset keeps the merged text aligned with the merged
1264
+ // `pendingImages` order; draft markers stay valid because draft images
1265
+ // keep their original positions.
1266
+ const queuedImages = allQueued.flatMap(e => e.images ?? []);
1267
+ let queuedText: string;
1268
+ if (queuedImages.length > 0) {
1269
+ const parts: string[] = [];
1270
+ let imageOffset = this.ctx.editor.pendingImages.length;
1271
+ for (const entry of allQueued) {
1272
+ parts.push(shiftImageMarkers(entry.text, imageOffset));
1273
+ if (entry.images && entry.images.length > 0) imageOffset += entry.images.length;
1274
+ }
1275
+ queuedText = parts.join("\n\n");
1276
+ } else {
1277
+ queuedText = allQueued.map(e => e.text).join("\n\n");
1278
+ }
1279
+ const currentText = options?.currentText ?? this.ctx.editor.getText();
1280
+ const combinedText = [queuedText, currentText].filter(t => t.trim()).join("\n\n");
1281
+ this.ctx.editor.setText(combinedText);
1282
+ // Hand queued images back to the pending-image buffer (links are
1283
+ // re-materialized lazily; the restored text already carries the
1284
+ // renumbered `[Image #N, WxH]` markers).
1285
+ if (queuedImages.length > 0) {
1286
+ this.ctx.editor.pendingImages.push(...queuedImages);
1287
+ this.ctx.editor.pendingImageLinks.push(...queuedImages.map(() => undefined));
1288
+ this.ctx.editor.imageLinks = this.ctx.editor.pendingImageLinks;
1289
+ }
1290
+ this.ctx.updatePendingMessagesDisplay();
1291
+ if (options?.abort) {
1292
+ void this.ctx.session.abort({ reason: USER_INTERRUPT_LABEL });
1293
+ }
1294
+ return allQueued.length;
1295
+ }
1296
+
1297
+ async #insertPendingImage(imageData: ImageContent): Promise<void> {
1298
+ const imageLink = (
1299
+ await materializeImageReferenceLinks(
1300
+ [
1301
+ {
1302
+ type: "image",
1303
+ data: imageData.data,
1304
+ mimeType: imageData.mimeType,
1305
+ },
1306
+ ],
1307
+ this.ctx.sessionManager.putBlob.bind(this.ctx.sessionManager),
1308
+ )
1309
+ )?.[0];
1310
+ this.ctx.editor.pendingImages.push({
1311
+ type: "image",
1312
+ data: imageData.data,
1313
+ mimeType: imageData.mimeType,
1314
+ });
1315
+ this.ctx.editor.pendingImageLinks.push(imageLink);
1316
+ this.ctx.editor.imageLinks = this.ctx.editor.pendingImageLinks;
1317
+ const imageNum = this.ctx.editor.pendingImages.length;
1318
+ const dims = await this.#imageDimensions(imageData);
1319
+ const label = dims ? `[Image #${imageNum}, ${dims.width}x${dims.height}]` : `[Image #${imageNum}]`;
1320
+ this.ctx.editor.insertText(`${label} `);
1321
+ this.ctx.ui.requestRender();
1322
+ }
1323
+
1324
+ /** Probe pixel dimensions for the marker label (`[Image #N, WxH]`). Returns undefined when the
1325
+ * header can't be decoded, so the caller falls back to a bare `[Image #N]`. */
1326
+ async #imageDimensions(image: ImageContent): Promise<{ width: number; height: number } | undefined> {
1327
+ try {
1328
+ const { width, height } = await new Bun.Image(Buffer.from(image.data, "base64")).metadata();
1329
+ if (width && height) return { width, height };
1330
+ } catch {
1331
+ // Unknown/corrupt header — fall back to a bare label.
1332
+ }
1333
+ return undefined;
1334
+ }
1335
+
1336
+ async #normalizeAndInsertPastedImage(image: ImageContent, unsupportedMessage: string): Promise<boolean> {
1337
+ let imageData = await ensureSupportedImageInput(image);
1338
+ if (!imageData) {
1339
+ this.ctx.showStatus(unsupportedMessage);
1340
+ return false;
1341
+ }
1342
+ if (settings.get("images.autoResize")) {
1343
+ try {
1344
+ const resized = await resizeImage({
1345
+ type: "image",
1346
+ data: imageData.data,
1347
+ mimeType: imageData.mimeType,
1348
+ });
1349
+ imageData = { type: "image", data: resized.data, mimeType: resized.mimeType };
1350
+ } catch {
1351
+ // Keep the normalized image when resize fails.
1352
+ }
1353
+ }
1354
+ await this.#insertPendingImage(imageData);
1355
+ return true;
1356
+ }
1357
+
1358
+ /**
1359
+ * Win+Shift+S on Windows 11 leaves the screenshot bitmap on the clipboard
1360
+ * while the terminal pastes a transient packaged-app TempState path
1361
+ * (…\MicrosoftWindows.Client.Core_*\TempState\…) that is already gone — or
1362
+ * never materialized — by the time we read it. Whenever a pasted image path
1363
+ * can't be turned into an image locally, those clipboard bytes are the real
1364
+ * payload, so prefer them before degrading to a text paste.
1365
+ *
1366
+ * Skipped over SSH: the clipboard read would hit the remote host, not the
1367
+ * terminal that holds the screenshot. Returns true when the clipboard owned
1368
+ * the outcome (image attached, or an unsupported-format status surfaced), so
1369
+ * the caller stops without emitting its own degraded diagnostic.
1370
+ */
1371
+ async #tryPasteClipboardImage(): Promise<boolean> {
1372
+ const env = process.env;
1373
+ if (env.SSH_CONNECTION || env.SSH_TTY || env.SSH_CLIENT) return false;
1374
+ try {
1375
+ const image = await this.clipboard.readImage();
1376
+ if (!image) return false;
1377
+ await this.#normalizeAndInsertPastedImage(
1378
+ { type: "image", data: image.data.toBase64(), mimeType: image.mimeType },
1379
+ `Unsupported clipboard image format: ${image.mimeType}`,
1380
+ );
1381
+ return true;
1382
+ } catch {
1383
+ return false;
1384
+ }
1385
+ }
1386
+
1387
+ async handleImagePathPaste(path: string): Promise<void> {
1388
+ try {
1389
+ const image = await loadImageInput({
1390
+ path,
1391
+ cwd: this.ctx.sessionManager.getCwd(),
1392
+ autoResize: false,
1393
+ });
1394
+ if (!image) {
1395
+ // Path resolved but is not a readable image (e.g. a zero-byte or
1396
+ // locked transient screenshot file). Prefer the clipboard bytes.
1397
+ if (await this.#tryPasteClipboardImage()) return;
1398
+ this.ctx.editor.pasteText(path);
1399
+ this.ctx.ui.requestRender();
1400
+ this.ctx.showStatus("Pasted path is not a supported image");
1401
+ return;
1402
+ }
1403
+ await this.#normalizeAndInsertPastedImage(
1404
+ { type: "image", data: image.data, mimeType: image.mimeType },
1405
+ `Unsupported pasted image format: ${image.mimeType}`,
1406
+ );
1407
+ } catch (error) {
1408
+ if (error instanceof ImageInputTooLargeError) {
1409
+ this.ctx.editor.pasteText(path);
1410
+ this.ctx.ui.requestRender();
1411
+ this.ctx.showStatus(error.message);
1412
+ return;
1413
+ }
1414
+ if (isEnoent(error)) {
1415
+ // #2375: the bracketed paste forwarded by a local terminal carries a
1416
+ // path on the *local* filesystem. The bytes may still be on the
1417
+ // clipboard (Win+Shift+S), so try those before giving up.
1418
+ if (await this.#tryPasteClipboardImage()) return;
1419
+ // Over SSH the clipboard lives on the remote host, so the path is
1420
+ // genuinely unreachable; pasting it as text would look like the
1421
+ // image was attached when nothing was sent. Surface an SSH-aware
1422
+ // diagnostic instead. The pasted path is untrusted terminal input —
1423
+ // strip control/ANSI/newlines, collapse home to `~`, and bound the
1424
+ // displayed length before splicing it into the status string.
1425
+ const env = process.env;
1426
+ const overSsh = Boolean(env.SSH_CONNECTION || env.SSH_TTY || env.SSH_CLIENT);
1427
+ const displayPath = truncateToWidth(
1428
+ shortenPath(
1429
+ sanitizeText(path)
1430
+ .replace(/[\r\n\t]+/g, " ")
1431
+ .trim(),
1432
+ ),
1433
+ TRUNCATE_LENGTHS.CONTENT,
1434
+ );
1435
+ this.ctx.showStatus(
1436
+ overSsh
1437
+ ? `Image not found at ${displayPath}. Over SSH this path is local to your terminal — paste the image directly (clipboard image-paste shortcut) to send its bytes.`
1438
+ : `Image not found at ${displayPath}`,
1439
+ );
1440
+ return;
1441
+ }
1442
+ if (await this.#tryPasteClipboardImage()) return;
1443
+ this.ctx.editor.pasteText(path);
1444
+ this.ctx.ui.requestRender();
1445
+ this.ctx.showStatus("Failed to read pasted image path");
1446
+ }
1447
+ }
1448
+
1449
+ async handleImagePaste(): Promise<boolean> {
1450
+ try {
1451
+ const image = await this.clipboard.readImage();
1452
+ if (image) {
1453
+ return await this.#normalizeAndInsertPastedImage(
1454
+ {
1455
+ type: "image",
1456
+ data: image.data.toBase64(),
1457
+ mimeType: image.mimeType,
1458
+ },
1459
+ `Unsupported clipboard image format: ${image.mimeType}`,
1460
+ );
1461
+ }
1462
+ // #3506: macOS Finder `Cmd+C` puts only a `public.file-url`
1463
+ // representation on the pasteboard. `pbpaste` (the backing call
1464
+ // for `readText` on Darwin) only surfaces plain text / RTF / EPS,
1465
+ // so it returns empty for file-url-only pasteboards — the smart
1466
+ // text fallback below would dead-end with "Clipboard is empty".
1467
+ // Reach the file URL directly via AppleScript and route every
1468
+ // image-shaped path through {@link handleImagePathPaste}, matching
1469
+ // the bracketed-paste handler in `CustomEditor.handleInput` which
1470
+ // iterates every extracted image path. Multi-image Finder
1471
+ // selections must not silently drop after the first attach.
1472
+ // `readMacFileUrls` returns an empty list off Darwin, so the
1473
+ // check is free on every other platform.
1474
+ const fileUrls = (await this.clipboard.readMacFileUrls?.()) ?? [];
1475
+ let attachedFromFileUrls = false;
1476
+ for (const url of fileUrls) {
1477
+ const candidate = extractImagePathFromText(url);
1478
+ if (!candidate) continue;
1479
+ await this.handleImagePathPaste(candidate);
1480
+ attachedFromFileUrls = true;
1481
+ }
1482
+ if (attachedFromFileUrls) return true;
1483
+ // Smart paste (#1628): no image on the clipboard — fall back to
1484
+ // pasting its text so the same chord covers both payload kinds.
1485
+ // Hosts that pre-empt the terminal's own paste (VS Code's
1486
+ // integrated terminal, Win+V clipboard history) deliver only
1487
+ // this keypress, so a miss here must not dead-end.
1488
+ const text = await this.clipboard.readText();
1489
+ if (!text) {
1490
+ this.ctx.showStatus("Clipboard is empty");
1491
+ return false;
1492
+ }
1493
+ // #3506: when the clipboard text is an explicit image file path,
1494
+ // route through {@link handleImagePathPaste} so the image is
1495
+ // loaded and attached instead of pasting the path as literal
1496
+ // text. Covers terminals that paste the Finder file path as
1497
+ // plain text rather than as a `public.file-url` (most macOS
1498
+ // terminals do this for image clipboards).
1499
+ const imagePath = extractImagePathFromText(text);
1500
+ if (imagePath) {
1501
+ await this.handleImagePathPaste(imagePath);
1502
+ return true;
1503
+ }
1504
+ // Route to the focused component when it accepts pastes (modal
1505
+ // Input prompts), matching the enhanced-paste text path (#2127).
1506
+ const focused = this.ctx.ui.getFocused();
1507
+ const target = focused && focused !== this.ctx.editor && hasPasteText(focused) ? focused : this.ctx.editor;
1508
+ target.pasteText(text);
1509
+ this.ctx.ui.requestRender();
1510
+ return true;
1511
+ } catch {
1512
+ this.ctx.showStatus("Failed to read clipboard");
1513
+ return false;
1514
+ }
1515
+ }
1516
+
1517
+ async handleClipboardTextRawPaste(): Promise<void> {
1518
+ try {
1519
+ const text = await this.clipboard.readText();
1520
+ if (text) {
1521
+ this.ctx.editor.insertText(text);
1522
+ this.ctx.ui.requestRender();
1523
+ } else {
1524
+ this.ctx.showStatus("No text in clipboard to paste raw");
1525
+ }
1526
+ } catch {
1527
+ this.ctx.showStatus("Failed to paste raw text from clipboard");
1528
+ }
1529
+ }
1530
+
1531
+ /**
1532
+ * Editor `onLargePaste` hook: gate a marker-sized paste behind the large-paste menu. Returns
1533
+ * `true` to intercept (the editor skips its default `[Paste]` marker) once the paste reaches the
1534
+ * configured `paste.largeMenuThreshold` line count; otherwise `false` for default collapse-to-marker
1535
+ * behavior. The async menu is fired and forgotten — the editor only needs the synchronous verdict.
1536
+ */
1537
+ handleLargePaste(text: string, lineCount: number): boolean {
1538
+ const threshold = this.ctx.settings.get("paste.largeMenuThreshold");
1539
+ if (!(threshold > 0) || lineCount < threshold) return false;
1540
+ void this.presentLargePasteMenu(text, lineCount);
1541
+ return true;
1542
+ }
1543
+
1544
+ /**
1545
+ * Present the large-paste menu and apply the chosen action: wrap in `<attachment>` tags (collapsed
1546
+ * to a `[Paste]` marker that expands on submit), save the text to a file and reference its path so
1547
+ * the agent can `read` it on demand, or paste inline. Cancelling (Esc) falls back to the default
1548
+ * inline paste marker, so the pasted content is never lost.
1549
+ */
1550
+ async presentLargePasteMenu(text: string, lineCount: number): Promise<void> {
1551
+ const WRAPPED_BLOCK = "Attach as a wrapped block";
1552
+ const LOCAL_FILE = "Attach as local file";
1553
+ const INLINE = "Paste inline";
1554
+
1555
+ let choice: string | undefined;
1556
+ try {
1557
+ choice = await this.ctx.showHookSelector(
1558
+ `Pasted ${lineCount} lines`,
1559
+ [
1560
+ { label: WRAPPED_BLOCK, description: "Wrap the text in <attachment> tags, collapsed to a marker" },
1561
+ { label: LOCAL_FILE, description: "Save the text to a local://attachment file" },
1562
+ { label: INLINE, description: "Collapse the text to an inline paste marker" },
1563
+ ],
1564
+ { helpText: "Esc to paste inline" },
1565
+ );
1566
+ } catch (error) {
1567
+ logger.warn("large-paste menu failed", { error: error instanceof Error ? error.message : String(error) });
1568
+ choice = undefined;
1569
+ }
1570
+
1571
+ switch (choice) {
1572
+ case WRAPPED_BLOCK:
1573
+ this.ctx.editor.insertPaste(wrapPasteInAttachmentBlock(text));
1574
+ break;
1575
+ case LOCAL_FILE:
1576
+ await this.#attachPasteAsFile(text, lineCount);
1577
+ break;
1578
+ case INLINE:
1579
+ this.ctx.editor.insertPaste(text);
1580
+ break;
1581
+ default:
1582
+ // Esc / cancel: keep the original behavior — collapse to an inline paste marker.
1583
+ this.ctx.editor.insertPaste(text);
1584
+ break;
1585
+ }
1586
+ this.ctx.ui.requestRender();
1587
+ }
1588
+
1589
+ /**
1590
+ * Save a large paste to the session's `local://` store and insert a clean `local://attachment-N`
1591
+ * reference into the editor so the agent can `read` it on demand — instead of inlining the text or
1592
+ * leaking a raw temp path. Falls back to an inline paste marker when the write fails, so the
1593
+ * content is never lost.
1594
+ */
1595
+ async #attachPasteAsFile(text: string, lineCount: number): Promise<void> {
1596
+ try {
1597
+ // Mirror the exact mapping the read tool's local:// resolver uses so a later
1598
+ // `read local://attachment-N` lands on the file written here.
1599
+ const localRoot = resolveLocalRoot({
1600
+ getArtifactsDir: () => this.ctx.sessionManager.getArtifactsDir(),
1601
+ getSessionId: () => this.ctx.sessionManager.getSessionId(),
1602
+ });
1603
+ let name: string;
1604
+ let filePath: string;
1605
+ do {
1606
+ this.#attachmentCounter++;
1607
+ name = `attachment-${this.#attachmentCounter}`;
1608
+ filePath = path.join(localRoot, name);
1609
+ } while (await Bun.file(filePath).exists());
1610
+ await Bun.write(filePath, text);
1611
+ this.ctx.editor.insertText(`local://${name} `);
1612
+ this.ctx.showStatus(`Saved ${lineCount} pasted lines to local://${name}`);
1613
+ } catch (error) {
1614
+ logger.warn("failed to save large paste to file", {
1615
+ error: error instanceof Error ? error.message : String(error),
1616
+ });
1617
+ this.ctx.editor.insertPaste(text);
1618
+ this.ctx.showError("Failed to save paste to a file — pasted inline instead");
1619
+ }
1620
+ }
1621
+
1622
+ createAutocompleteProvider(commands: SlashCommand[], basePath: string): AutocompleteProvider {
1623
+ return createPromptActionAutocompleteProvider({
1624
+ commands,
1625
+ basePath,
1626
+ keybindings: this.ctx.keybindings,
1627
+ copyCurrentLine: () => this.handleCopyCurrentLine(),
1628
+ copyPrompt: () => this.handleCopyPrompt(),
1629
+ undo: prefix => this.ctx.editor.undoPastTransientText(prefix),
1630
+ moveCursorToMessageEnd: () => this.ctx.editor.moveToMessageEnd(),
1631
+ moveCursorToMessageStart: () => this.ctx.editor.moveToMessageStart(),
1632
+ moveCursorToLineStart: () => this.ctx.editor.moveToLineStart(),
1633
+ moveCursorToLineEnd: () => this.ctx.editor.moveToLineEnd(),
1634
+ });
1635
+ }
1636
+
1637
+ /** Copy the current editor line to the system clipboard. */
1638
+ handleCopyCurrentLine(): void {
1639
+ const { line } = this.ctx.editor.getCursor();
1640
+ const text = this.ctx.editor.getLines()[line] || "";
1641
+ if (!text) {
1642
+ this.ctx.showStatus("Nothing to copy");
1643
+ return;
1644
+ }
1645
+ try {
1646
+ copyToClipboard(text);
1647
+ const sanitized = sanitizeText(text);
1648
+ const preview = sanitized.length > 30 ? `${sanitized.slice(0, 30)}...` : sanitized;
1649
+ this.ctx.showStatus(`Copied line: ${preview}`);
1650
+ } catch {
1651
+ this.ctx.showWarning("Failed to copy to clipboard");
1652
+ }
1653
+ }
1654
+
1655
+ /** Copy current prompt text to system clipboard. */
1656
+ handleCopyPrompt(): void {
1657
+ const text = this.ctx.editor.getText();
1658
+ if (!text) {
1659
+ this.ctx.showStatus("Nothing to copy");
1660
+ return;
1661
+ }
1662
+ try {
1663
+ copyToClipboard(text);
1664
+ const sanitized = sanitizeText(text);
1665
+ const preview = sanitized.length > 30 ? `${sanitized.slice(0, 30)}...` : sanitized;
1666
+ this.ctx.showStatus(`Copied: ${preview}`);
1667
+ } catch {
1668
+ this.ctx.showWarning("Failed to copy to clipboard");
1669
+ }
1670
+ }
1671
+
1672
+ cycleThinkingLevel(): void {
1673
+ if (this.ctx.focusedAgentId) {
1674
+ this.ctx.showStatus("Model/thinking apply to the main session — press ←← to return first");
1675
+ return;
1676
+ }
1677
+ const newLevel = this.ctx.session.cycleThinkingLevel();
1678
+ if (newLevel === undefined) {
1679
+ this.ctx.showStatus("Current model does not support thinking");
1680
+ } else {
1681
+ this.ctx.statusLine.invalidate();
1682
+ this.ctx.updateEditorBorderColor();
1683
+ }
1684
+ }
1685
+
1686
+ async cycleRoleModel(direction: "forward" | "backward" = "forward"): Promise<void> {
1687
+ if (this.ctx.focusedAgentId) {
1688
+ this.ctx.showStatus("Model/thinking apply to the main session — press ←← to return first");
1689
+ return;
1690
+ }
1691
+ try {
1692
+ const cycleOrder = settings.get("cycleOrder");
1693
+ const result = await this.ctx.session.cycleRoleModels(cycleOrder, direction);
1694
+ if (!result) {
1695
+ this.ctx.showStatus("Only one role model available");
1696
+ return;
1697
+ }
1698
+
1699
+ this.ctx.statusLine.invalidate();
1700
+ this.ctx.updateEditorBorderColor();
1701
+ // The status line already reports the resolved model + thinking level, so
1702
+ // the cycle status is just a status-line-style chip track (active role
1703
+ // filled), matching the plan-approval model slider. It renders into its
1704
+ // own anchored container above the editor (cleared+rebuilt each cycle),
1705
+ // so it updates in place instead of stacking duplicates in the scrollback.
1706
+ const track = renderSegmentTrack(
1707
+ cycleOrder.map(role => ({ label: role })),
1708
+ cycleOrder.indexOf(result.role),
1709
+ );
1710
+ this.ctx.showModelCycleTrack(track);
1711
+ } catch (error) {
1712
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
1713
+ }
1714
+ }
1715
+
1716
+ toggleToolOutputExpansion(): void {
1717
+ this.setToolsExpanded(!this.ctx.toolOutputExpanded);
1718
+ }
1719
+
1720
+ setToolsExpanded(expanded: boolean): void {
1721
+ this.ctx.toolOutputExpanded = expanded;
1722
+ for (const child of this.ctx.chatContainer.children) {
1723
+ if (isExpandable(child)) {
1724
+ child.setExpanded(expanded);
1725
+ }
1726
+ }
1727
+ // Toggling expansion mutates every block, but on ED3-risk terminals the
1728
+ // transcript freezes a snapshot of each block once it scrolls past the live
1729
+ // region (committed native scrollback is immutable there). A plain repaint
1730
+ // replays those stale snapshots, so the toggle appears to do nothing above
1731
+ // the live block. resetDisplay() invalidates the snapshots and forces a
1732
+ // full clear + replay — the keyboard-accessible resize-reset equivalent —
1733
+ // which is the only path that re-emits the whole transcript at its new
1734
+ // heights.
1735
+ this.ctx.ui.resetDisplay();
1736
+ }
1737
+
1738
+ toggleThinkingBlockVisibility(): void {
1739
+ // When thinking is "off" and the session has not produced reasoning
1740
+ // content, thinking blocks stay auto-hidden; the toggle would only corrupt
1741
+ // the persisted preference. OpenAI-compatible servers can stream reasoning
1742
+ // without advertising model support, so observed thinking content unlocks
1743
+ // the display toggle.
1744
+ const thinkingOff =
1745
+ ((this.ctx.viewSession ?? this.ctx.session)?.thinkingLevel ?? ThinkingLevel.Off) === ThinkingLevel.Off;
1746
+ if (thinkingOff && !this.ctx.hasDisplayableThinkingContent) {
1747
+ this.ctx.showStatus("Thinking is off — enable thinking to show blocks");
1748
+ return;
1749
+ }
1750
+ this.ctx.hideThinkingBlock = !this.ctx.hideThinkingBlock;
1751
+ this.ctx.settings.set("hideThinkingBlock", this.ctx.hideThinkingBlock);
1752
+
1753
+ for (const child of this.ctx.chatContainer.children) {
1754
+ if (child instanceof AssistantMessageComponent) {
1755
+ child.setHideThinkingBlock(this.ctx.hideThinkingBlock);
1756
+ }
1757
+ }
1758
+
1759
+ if (this.ctx.streamingComponent && this.ctx.streamingMessage) {
1760
+ this.ctx.streamingComponent.setHideThinkingBlock(this.ctx.hideThinkingBlock);
1761
+ this.ctx.streamingComponent.updateContent(this.ctx.streamingMessage);
1762
+ }
1763
+
1764
+ // Every block now carries the new flag, but on ED3-risk terminals the
1765
+ // blocks that scrolled past the live region are frozen snapshots in
1766
+ // committed scrollback — a plain repaint replays them stale, so scrolling
1767
+ // up still shows the old thinking expanded. resetDisplay() retires those
1768
+ // snapshots (it invalidates every block) and forces a full clear + replay
1769
+ // of the whole transcript, matching setToolsExpanded()'s redraw.
1770
+ this.ctx.ui.resetDisplay();
1771
+
1772
+ this.ctx.showStatus(`Thinking blocks: ${this.ctx.hideThinkingBlock ? "hidden" : "visible"}`);
1773
+ }
1774
+
1775
+ #getEditorTerminalPath(): string | null {
1776
+ if (process.platform === "win32") {
1777
+ return null;
1778
+ }
1779
+ return "/dev/tty";
1780
+ }
1781
+
1782
+ async #openEditorTerminalHandle(): Promise<fs.FileHandle | null> {
1783
+ const terminalPath = this.#getEditorTerminalPath();
1784
+ if (!terminalPath) {
1785
+ return null;
1786
+ }
1787
+ try {
1788
+ return await fs.open(terminalPath, "r+");
1789
+ } catch {
1790
+ return null;
1791
+ }
1792
+ }
1793
+
1794
+ async openExternalEditor(): Promise<void> {
1795
+ const editorCmd = getEditorCommand();
1796
+ if (!editorCmd) {
1797
+ this.ctx.showWarning("No editor configured. Set $VISUAL or $EDITOR environment variable.");
1798
+ return;
1799
+ }
1800
+
1801
+ const currentText = this.ctx.editor.getExpandedText?.() ?? this.ctx.editor.getText();
1802
+
1803
+ let ttyHandle: fs.FileHandle | null = null;
1804
+ try {
1805
+ ttyHandle = await this.#openEditorTerminalHandle();
1806
+ this.ctx.ui.stop();
1807
+
1808
+ const stdio: [number | "inherit", number | "inherit", number | "inherit"] = ttyHandle
1809
+ ? [ttyHandle.fd, ttyHandle.fd, ttyHandle.fd]
1810
+ : ["inherit", "inherit", "inherit"];
1811
+
1812
+ const result = await openInEditor(editorCmd, currentText, { extension: ".omp.md", stdio });
1813
+ if (result !== null) {
1814
+ this.ctx.editor.setText(result);
1815
+ }
1816
+ } catch (error) {
1817
+ this.ctx.showWarning(
1818
+ `Failed to open external editor: ${error instanceof Error ? error.message : String(error)}`,
1819
+ );
1820
+ } finally {
1821
+ if (ttyHandle) {
1822
+ await ttyHandle.close();
1823
+ }
1824
+
1825
+ this.ctx.ui.start();
1826
+ this.ctx.ui.requestRender();
1827
+ }
1828
+ }
1829
+
1830
+ registerExtensionShortcuts(): void {
1831
+ const runner = this.ctx.session.extensionRunner;
1832
+ if (!runner) return;
1833
+
1834
+ const shortcuts = runner.getShortcuts();
1835
+ for (const [keyId, shortcut] of shortcuts) {
1836
+ this.ctx.editor.setCustomKeyHandler(keyId, () => {
1837
+ const ctx = runner.createCommandContext();
1838
+ try {
1839
+ shortcut.handler(ctx);
1840
+ } catch (err) {
1841
+ runner.emitError({
1842
+ extensionPath: shortcut.extensionPath,
1843
+ event: "shortcut",
1844
+ error: err instanceof Error ? err.message : String(err),
1845
+ stack: err instanceof Error ? err.stack : undefined,
1846
+ });
1847
+ }
1848
+ });
1849
+ }
1850
+ }
1851
+ }