@dev-crowagent/pigeon-coding-agent 0.0.0-stage → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1337) hide show
  1. package/CHANGELOG.md +6853 -0
  2. package/README.md +64 -2
  3. package/dist/bun/cli.d.ts +5 -0
  4. package/dist/bun/cli.d.ts.map +1 -0
  5. package/dist/bun/cli.js +5 -0
  6. package/dist/bun/cli.js.map +1 -0
  7. package/dist/bun/restore-sandbox-env.d.ts +17 -0
  8. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  9. package/dist/bun/restore-sandbox-env.js +36 -0
  10. package/dist/bun/restore-sandbox-env.js.map +1 -0
  11. package/dist/bun/runtime-setup.d.ts +2 -0
  12. package/dist/bun/runtime-setup.d.ts.map +1 -0
  13. package/dist/bun/runtime-setup.js +12 -0
  14. package/dist/bun/runtime-setup.js.map +1 -0
  15. package/dist/bun/sandbox-env-setup.d.ts +2 -0
  16. package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
  17. package/dist/bun/sandbox-env-setup.js +4 -0
  18. package/dist/bun/sandbox-env-setup.js.map +1 -0
  19. package/dist/bundle/chunks/anthropic-messages-S7OHKPOC.js +3 -0
  20. package/dist/bundle/chunks/anthropic.js +75 -0
  21. package/dist/bundle/chunks/azure-openai-responses-C4HXCGKY.js +2 -0
  22. package/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
  23. package/dist/bundle/chunks/chunk-24NILFQL.js +2 -0
  24. package/dist/bundle/chunks/chunk-2BKJ4UF2.js +6 -0
  25. package/dist/bundle/chunks/chunk-3BW64VNB.js +2 -0
  26. package/dist/bundle/chunks/chunk-43YVBVYM.js +2 -0
  27. package/dist/bundle/chunks/chunk-4DEVB6EZ.js +14 -0
  28. package/dist/bundle/chunks/chunk-4L3WN2XY.js +2 -0
  29. package/dist/bundle/chunks/chunk-5YSISOFY.js +2 -0
  30. package/dist/bundle/chunks/chunk-6BV2MVXK.js +44 -0
  31. package/dist/bundle/chunks/chunk-6CYCI3EJ.js +12 -0
  32. package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  33. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  34. package/dist/bundle/chunks/chunk-BOCI5WGU.js +82 -0
  35. package/dist/bundle/chunks/chunk-CENTGHH3.js +2 -0
  36. package/dist/bundle/chunks/chunk-DRQDKNXA.js +2 -0
  37. package/dist/bundle/chunks/chunk-F5ZABL6Z.js +20 -0
  38. package/dist/bundle/chunks/chunk-GQHEZCKG.js +1308 -0
  39. package/dist/bundle/chunks/chunk-HV2R453R.js +20 -0
  40. package/dist/bundle/chunks/chunk-IEBK4HQA.js +2 -0
  41. package/dist/bundle/chunks/chunk-KQBUYSHV.js +30 -0
  42. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  43. package/dist/bundle/chunks/chunk-L6EYYEJG.js +2 -0
  44. package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  45. package/dist/bundle/chunks/chunk-MXFTMUZ6.js +2 -0
  46. package/dist/bundle/chunks/chunk-ONH666LT.js +9 -0
  47. package/dist/bundle/chunks/chunk-OUFDCV7C.js +2 -0
  48. package/dist/bundle/chunks/chunk-OVXT2WQH.js +2 -0
  49. package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  50. package/dist/bundle/chunks/chunk-PDJOKI64.js +10 -0
  51. package/dist/bundle/chunks/chunk-PGJVGVSP.js +16 -0
  52. package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  53. package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  54. package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  55. package/dist/bundle/chunks/chunk-QIM6CXAU.js +8 -0
  56. package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  57. package/dist/bundle/chunks/chunk-RMQSLH4P.js +2 -0
  58. package/dist/bundle/chunks/chunk-S3GGRYIO.js +6 -0
  59. package/dist/bundle/chunks/chunk-T52L5B3T.js +4 -0
  60. package/dist/bundle/chunks/chunk-UFWXNM6R.js +131 -0
  61. package/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
  62. package/dist/bundle/chunks/chunk-VKY2XKRH.js +55 -0
  63. package/dist/bundle/chunks/chunk-VY3Y7KDL.js +2 -0
  64. package/dist/bundle/chunks/chunk-WTT6ACRW.js +2 -0
  65. package/dist/bundle/chunks/chunk-ZBURYEWF.js +2 -0
  66. package/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
  67. package/dist/bundle/chunks/chunk-ZGRL3DUD.js +31 -0
  68. package/dist/bundle/chunks/cli-FNCZKMKM.js +53 -0
  69. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-R2JVPCDL.js +2 -0
  70. package/dist/bundle/chunks/codemode-worker.js +480 -0
  71. package/dist/bundle/chunks/easter-egg-3d-SCT2WGNT.js +2 -0
  72. package/dist/bundle/chunks/execute-XNTKW56B.js +507 -0
  73. package/dist/bundle/chunks/github-copilot.js +2 -0
  74. package/dist/bundle/chunks/google-generative-ai-5VXURRH2.js +2 -0
  75. package/dist/bundle/chunks/google-vertex-WHGUHG5B.js +2 -0
  76. package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +13 -0
  77. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  78. package/dist/bundle/chunks/jiti-loader-C3NU2SDH.js +21 -0
  79. package/dist/bundle/chunks/jiti-static-loader-E6ANQD5T.js +2 -0
  80. package/dist/bundle/chunks/kimi-coding.js +2 -0
  81. package/dist/bundle/chunks/lib-TEDK3E5I.js +9 -0
  82. package/dist/bundle/chunks/llama-cpp-classify-LNRMBUDA.js +22 -0
  83. package/dist/bundle/chunks/meta.js +2 -0
  84. package/dist/bundle/chunks/mistral-conversations-FZ4P7VNF.js +4 -0
  85. package/dist/bundle/chunks/multipart-parser-SQ6GDJL7.js +3 -0
  86. package/dist/bundle/chunks/node-N5BSDOA5.js +16 -0
  87. package/dist/bundle/chunks/node-TWVVAGPO.js +2 -0
  88. package/dist/bundle/chunks/openai-chatgpt.js +75 -0
  89. package/dist/bundle/chunks/openai-codex-responses-OIMJK5WE.js +2 -0
  90. package/dist/bundle/chunks/openai-codex.js +75 -0
  91. package/dist/bundle/chunks/openai-completions-FHCUS6R5.js +7 -0
  92. package/dist/bundle/chunks/openai-decisions-LABKHEXJ.js +5 -0
  93. package/dist/bundle/chunks/openai-responses-3WC62NWH.js +4 -0
  94. package/dist/bundle/chunks/openrouter-chat-images-FFVJXZTY.js +2 -0
  95. package/dist/bundle/chunks/openrouter-images-SPX5Z3O3.js +4 -0
  96. package/dist/bundle/chunks/openrouter.js +75 -0
  97. package/dist/bundle/chunks/pigeon-decision-PKYQMZCD.js +2 -0
  98. package/dist/bundle/chunks/pigeon-image-4OX3LN22.js +2 -0
  99. package/dist/bundle/chunks/pigeon-messages-BDEFLADM.js +2 -0
  100. package/dist/bundle/chunks/radius.js +75 -0
  101. package/dist/bundle/chunks/runtime-5YBC2DMM.js +2 -0
  102. package/dist/bundle/chunks/src-UK77SYZE.js +4 -0
  103. package/dist/bundle/chunks/typesafe-system-one-LBP2VTNM.js +2 -0
  104. package/dist/bundle/chunks/virtual-modules-RXYO7SWA.js +2 -0
  105. package/dist/bundle/chunks/xai.js +2 -0
  106. package/dist/bundle/cli-runtime.js +3 -0
  107. package/dist/bundle/cli.js +5 -0
  108. package/dist/bundle/index.js +2 -0
  109. package/dist/bundle/rpc-entry.js +3 -0
  110. package/dist/cli/agent-dir-arg.d.ts +20 -0
  111. package/dist/cli/agent-dir-arg.d.ts.map +1 -0
  112. package/dist/cli/agent-dir-arg.js +38 -0
  113. package/dist/cli/agent-dir-arg.js.map +1 -0
  114. package/dist/cli/args.d.ts +75 -0
  115. package/dist/cli/args.d.ts.map +1 -0
  116. package/dist/cli/args.js +570 -0
  117. package/dist/cli/args.js.map +1 -0
  118. package/dist/cli/auth-check.d.ts +19 -0
  119. package/dist/cli/auth-check.d.ts.map +1 -0
  120. package/dist/cli/auth-check.js +50 -0
  121. package/dist/cli/auth-check.js.map +1 -0
  122. package/dist/cli/auth-command.d.ts +24 -0
  123. package/dist/cli/auth-command.d.ts.map +1 -0
  124. package/dist/cli/auth-command.js +127 -0
  125. package/dist/cli/auth-command.js.map +1 -0
  126. package/dist/cli/auth-login.d.ts +15 -0
  127. package/dist/cli/auth-login.d.ts.map +1 -0
  128. package/dist/cli/auth-login.js +232 -0
  129. package/dist/cli/auth-login.js.map +1 -0
  130. package/dist/cli/auth-logout.d.ts +14 -0
  131. package/dist/cli/auth-logout.d.ts.map +1 -0
  132. package/dist/cli/auth-logout.js +57 -0
  133. package/dist/cli/auth-logout.js.map +1 -0
  134. package/dist/cli/auth-terminal.d.ts +17 -0
  135. package/dist/cli/auth-terminal.d.ts.map +1 -0
  136. package/dist/cli/auth-terminal.js +63 -0
  137. package/dist/cli/auth-terminal.js.map +1 -0
  138. package/dist/cli/config-selector.d.ts +16 -0
  139. package/dist/cli/config-selector.d.ts.map +1 -0
  140. package/dist/cli/config-selector.js +37 -0
  141. package/dist/cli/config-selector.js.map +1 -0
  142. package/dist/cli/credential-print.d.ts +13 -0
  143. package/dist/cli/credential-print.d.ts.map +1 -0
  144. package/dist/cli/credential-print.js +76 -0
  145. package/dist/cli/credential-print.js.map +1 -0
  146. package/dist/cli/file-processor.d.ts +15 -0
  147. package/dist/cli/file-processor.d.ts.map +1 -0
  148. package/dist/cli/file-processor.js +71 -0
  149. package/dist/cli/file-processor.js.map +1 -0
  150. package/dist/cli/initial-message.d.ts +18 -0
  151. package/dist/cli/initial-message.d.ts.map +1 -0
  152. package/dist/cli/initial-message.js +22 -0
  153. package/dist/cli/initial-message.js.map +1 -0
  154. package/dist/cli/list-models.d.ts +9 -0
  155. package/dist/cli/list-models.d.ts.map +1 -0
  156. package/dist/cli/list-models.js +93 -0
  157. package/dist/cli/list-models.js.map +1 -0
  158. package/dist/cli/project-trust.d.ts +10 -0
  159. package/dist/cli/project-trust.d.ts.map +1 -0
  160. package/dist/cli/project-trust.js +48 -0
  161. package/dist/cli/project-trust.js.map +1 -0
  162. package/dist/cli/session-picker.d.ts +10 -0
  163. package/dist/cli/session-picker.d.ts.map +1 -0
  164. package/dist/cli/session-picker.js +39 -0
  165. package/dist/cli/session-picker.js.map +1 -0
  166. package/dist/cli/setup.d.ts +2 -0
  167. package/dist/cli/setup.d.ts.map +1 -0
  168. package/dist/cli/setup.js +12 -0
  169. package/dist/cli/setup.js.map +1 -0
  170. package/dist/cli/startup-ui.d.ts +21 -0
  171. package/dist/cli/startup-ui.d.ts.map +1 -0
  172. package/dist/cli/startup-ui.js +191 -0
  173. package/dist/cli/startup-ui.js.map +1 -0
  174. package/dist/cli.d.ts +3 -0
  175. package/dist/cli.d.ts.map +1 -0
  176. package/dist/cli.js +6 -0
  177. package/dist/cli.js.map +1 -0
  178. package/dist/config.d.ts +132 -0
  179. package/dist/config.d.ts.map +1 -0
  180. package/dist/config.js +549 -0
  181. package/dist/config.js.map +1 -0
  182. package/dist/core/agent-session-runtime.d.ts +135 -0
  183. package/dist/core/agent-session-runtime.d.ts.map +1 -0
  184. package/dist/core/agent-session-runtime.js +352 -0
  185. package/dist/core/agent-session-runtime.js.map +1 -0
  186. package/dist/core/agent-session-services.d.ts +91 -0
  187. package/dist/core/agent-session-services.d.ts.map +1 -0
  188. package/dist/core/agent-session-services.js +158 -0
  189. package/dist/core/agent-session-services.js.map +1 -0
  190. package/dist/core/agent-session.d.ts +1041 -0
  191. package/dist/core/agent-session.d.ts.map +1 -0
  192. package/dist/core/agent-session.js +4027 -0
  193. package/dist/core/agent-session.js.map +1 -0
  194. package/dist/core/auth-guidance.d.ts +5 -0
  195. package/dist/core/auth-guidance.d.ts.map +1 -0
  196. package/dist/core/auth-guidance.js +21 -0
  197. package/dist/core/auth-guidance.js.map +1 -0
  198. package/dist/core/auth-storage.d.ts +72 -0
  199. package/dist/core/auth-storage.d.ts.map +1 -0
  200. package/dist/core/auth-storage.js +440 -0
  201. package/dist/core/auth-storage.js.map +1 -0
  202. package/dist/core/bash-executor.d.ts +34 -0
  203. package/dist/core/bash-executor.d.ts.map +1 -0
  204. package/dist/core/bash-executor.js +114 -0
  205. package/dist/core/bash-executor.js.map +1 -0
  206. package/dist/core/bug-report-upload.d.ts +12 -0
  207. package/dist/core/bug-report-upload.d.ts.map +1 -0
  208. package/dist/core/bug-report-upload.js +22 -0
  209. package/dist/core/bug-report-upload.js.map +1 -0
  210. package/dist/core/bug-report.d.ts +184 -0
  211. package/dist/core/bug-report.d.ts.map +1 -0
  212. package/dist/core/bug-report.js +292 -0
  213. package/dist/core/bug-report.js.map +1 -0
  214. package/dist/core/cache-stats.d.ts +49 -0
  215. package/dist/core/cache-stats.d.ts.map +1 -0
  216. package/dist/core/cache-stats.js +112 -0
  217. package/dist/core/cache-stats.js.map +1 -0
  218. package/dist/core/cache-warmer.d.ts +70 -0
  219. package/dist/core/cache-warmer.d.ts.map +1 -0
  220. package/dist/core/cache-warmer.js +278 -0
  221. package/dist/core/cache-warmer.js.map +1 -0
  222. package/dist/core/client-identity.d.ts +7 -0
  223. package/dist/core/client-identity.d.ts.map +1 -0
  224. package/dist/core/client-identity.js +14 -0
  225. package/dist/core/client-identity.js.map +1 -0
  226. package/dist/core/compaction/branch-summarization.d.ts +100 -0
  227. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  228. package/dist/core/compaction/branch-summarization.js +263 -0
  229. package/dist/core/compaction/branch-summarization.js.map +1 -0
  230. package/dist/core/compaction/compaction.d.ts +145 -0
  231. package/dist/core/compaction/compaction.d.ts.map +1 -0
  232. package/dist/core/compaction/compaction.js +752 -0
  233. package/dist/core/compaction/compaction.js.map +1 -0
  234. package/dist/core/compaction/index.d.ts +7 -0
  235. package/dist/core/compaction/index.d.ts.map +1 -0
  236. package/dist/core/compaction/index.js +7 -0
  237. package/dist/core/compaction/index.js.map +1 -0
  238. package/dist/core/compaction/utils.d.ts +45 -0
  239. package/dist/core/compaction/utils.d.ts.map +1 -0
  240. package/dist/core/compaction/utils.js +149 -0
  241. package/dist/core/compaction/utils.js.map +1 -0
  242. package/dist/core/crash-log.d.ts +28 -0
  243. package/dist/core/crash-log.d.ts.map +1 -0
  244. package/dist/core/crash-log.js +140 -0
  245. package/dist/core/crash-log.js.map +1 -0
  246. package/dist/core/defaults.d.ts +4 -0
  247. package/dist/core/defaults.d.ts.map +1 -0
  248. package/dist/core/defaults.js +11 -0
  249. package/dist/core/defaults.js.map +1 -0
  250. package/dist/core/diagnostics.d.ts +15 -0
  251. package/dist/core/diagnostics.d.ts.map +1 -0
  252. package/dist/core/diagnostics.js +2 -0
  253. package/dist/core/diagnostics.js.map +1 -0
  254. package/dist/core/event-bus.d.ts +9 -0
  255. package/dist/core/event-bus.d.ts.map +1 -0
  256. package/dist/core/event-bus.js +25 -0
  257. package/dist/core/event-bus.js.map +1 -0
  258. package/dist/core/exec.d.ts +38 -0
  259. package/dist/core/exec.d.ts.map +1 -0
  260. package/dist/core/exec.js +122 -0
  261. package/dist/core/exec.js.map +1 -0
  262. package/dist/core/experimental.d.ts +2 -0
  263. package/dist/core/experimental.d.ts.map +1 -0
  264. package/dist/core/experimental.js +4 -0
  265. package/dist/core/experimental.js.map +1 -0
  266. package/dist/core/export-html/ansi-to-html.d.ts +27 -0
  267. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  268. package/dist/core/export-html/ansi-to-html.js +286 -0
  269. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  270. package/dist/core/export-html/index.d.ts +37 -0
  271. package/dist/core/export-html/index.d.ts.map +1 -0
  272. package/dist/core/export-html/index.js +230 -0
  273. package/dist/core/export-html/index.js.map +1 -0
  274. package/dist/core/export-html/template.css +1085 -0
  275. package/dist/core/export-html/template.html +56 -0
  276. package/dist/core/export-html/template.js +2044 -0
  277. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  278. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  279. package/dist/core/export-html/tool-renderer.js +112 -0
  280. package/dist/core/export-html/tool-renderer.js.map +1 -0
  281. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  282. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  283. package/dist/core/export-html/vendor/marked.min.js +79 -0
  284. package/dist/core/extensions/index.d.ts +12 -0
  285. package/dist/core/extensions/index.d.ts.map +1 -0
  286. package/dist/core/extensions/index.js +9 -0
  287. package/dist/core/extensions/index.js.map +1 -0
  288. package/dist/core/extensions/jiti-loader.d.ts +2 -0
  289. package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
  290. package/dist/core/extensions/jiti-loader.js +4 -0
  291. package/dist/core/extensions/jiti-loader.js.map +1 -0
  292. package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
  293. package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
  294. package/dist/core/extensions/jiti-static-loader.js +4 -0
  295. package/dist/core/extensions/jiti-static-loader.js.map +1 -0
  296. package/dist/core/extensions/loader.d.ts +23 -0
  297. package/dist/core/extensions/loader.d.ts.map +1 -0
  298. package/dist/core/extensions/loader.js +727 -0
  299. package/dist/core/extensions/loader.js.map +1 -0
  300. package/dist/core/extensions/pigeon-ai-extension-view.d.ts +19 -0
  301. package/dist/core/extensions/pigeon-ai-extension-view.d.ts.map +1 -0
  302. package/dist/core/extensions/pigeon-ai-extension-view.js +22 -0
  303. package/dist/core/extensions/pigeon-ai-extension-view.js.map +1 -0
  304. package/dist/core/extensions/runner.d.ts +216 -0
  305. package/dist/core/extensions/runner.d.ts.map +1 -0
  306. package/dist/core/extensions/runner.js +1252 -0
  307. package/dist/core/extensions/runner.js.map +1 -0
  308. package/dist/core/extensions/types.d.ts +1815 -0
  309. package/dist/core/extensions/types.d.ts.map +1 -0
  310. package/dist/core/extensions/types.js +48 -0
  311. package/dist/core/extensions/types.js.map +1 -0
  312. package/dist/core/extensions/virtual-modules.d.ts +3 -0
  313. package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
  314. package/dist/core/extensions/virtual-modules.js +42 -0
  315. package/dist/core/extensions/virtual-modules.js.map +1 -0
  316. package/dist/core/extensions/wrapper.d.ts +20 -0
  317. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  318. package/dist/core/extensions/wrapper.js +22 -0
  319. package/dist/core/extensions/wrapper.js.map +1 -0
  320. package/dist/core/footer-data-provider.d.ts +64 -0
  321. package/dist/core/footer-data-provider.d.ts.map +1 -0
  322. package/dist/core/footer-data-provider.js +336 -0
  323. package/dist/core/footer-data-provider.js.map +1 -0
  324. package/dist/core/http-dispatcher.d.ts +22 -0
  325. package/dist/core/http-dispatcher.d.ts.map +1 -0
  326. package/dist/core/http-dispatcher.js +98 -0
  327. package/dist/core/http-dispatcher.js.map +1 -0
  328. package/dist/core/index.d.ts +14 -0
  329. package/dist/core/index.d.ts.map +1 -0
  330. package/dist/core/index.js +13 -0
  331. package/dist/core/index.js.map +1 -0
  332. package/dist/core/key-id-schema.d.ts +6 -0
  333. package/dist/core/key-id-schema.d.ts.map +1 -0
  334. package/dist/core/key-id-schema.js +16 -0
  335. package/dist/core/key-id-schema.js.map +1 -0
  336. package/dist/core/keybindings-schema.d.ts +4 -0
  337. package/dist/core/keybindings-schema.d.ts.map +1 -0
  338. package/dist/core/keybindings-schema.js +16 -0
  339. package/dist/core/keybindings-schema.js.map +1 -0
  340. package/dist/core/keybindings.d.ts +560 -0
  341. package/dist/core/keybindings.d.ts.map +1 -0
  342. package/dist/core/keybindings.js +325 -0
  343. package/dist/core/keybindings.js.map +1 -0
  344. package/dist/core/mcp-config-schema.d.ts +83 -0
  345. package/dist/core/mcp-config-schema.d.ts.map +1 -0
  346. package/dist/core/mcp-config-schema.js +150 -0
  347. package/dist/core/mcp-config-schema.js.map +1 -0
  348. package/dist/core/mcp-servers.d.ts +80 -0
  349. package/dist/core/mcp-servers.d.ts.map +1 -0
  350. package/dist/core/mcp-servers.js +165 -0
  351. package/dist/core/mcp-servers.js.map +1 -0
  352. package/dist/core/messages.d.ts +81 -0
  353. package/dist/core/messages.d.ts.map +1 -0
  354. package/dist/core/messages.js +132 -0
  355. package/dist/core/messages.js.map +1 -0
  356. package/dist/core/model-config.d.ts +2049 -0
  357. package/dist/core/model-config.d.ts.map +1 -0
  358. package/dist/core/model-config.js +167 -0
  359. package/dist/core/model-config.js.map +1 -0
  360. package/dist/core/model-registry.d.ts +63 -0
  361. package/dist/core/model-registry.d.ts.map +1 -0
  362. package/dist/core/model-registry.js +144 -0
  363. package/dist/core/model-registry.js.map +1 -0
  364. package/dist/core/model-resolver.d.ts +129 -0
  365. package/dist/core/model-resolver.d.ts.map +1 -0
  366. package/dist/core/model-resolver.js +428 -0
  367. package/dist/core/model-resolver.js.map +1 -0
  368. package/dist/core/model-runtime.d.ts +150 -0
  369. package/dist/core/model-runtime.d.ts.map +1 -0
  370. package/dist/core/model-runtime.js +778 -0
  371. package/dist/core/model-runtime.js.map +1 -0
  372. package/dist/core/models-store.d.ts +22 -0
  373. package/dist/core/models-store.d.ts.map +1 -0
  374. package/dist/core/models-store.js +115 -0
  375. package/dist/core/models-store.js.map +1 -0
  376. package/dist/core/nested-tool-calls.d.ts +103 -0
  377. package/dist/core/nested-tool-calls.d.ts.map +1 -0
  378. package/dist/core/nested-tool-calls.js +179 -0
  379. package/dist/core/nested-tool-calls.js.map +1 -0
  380. package/dist/core/output-guard.d.ts +7 -0
  381. package/dist/core/output-guard.d.ts.map +1 -0
  382. package/dist/core/output-guard.js +89 -0
  383. package/dist/core/output-guard.js.map +1 -0
  384. package/dist/core/package-manager.d.ts +256 -0
  385. package/dist/core/package-manager.d.ts.map +1 -0
  386. package/dist/core/package-manager.js +2426 -0
  387. package/dist/core/package-manager.js.map +1 -0
  388. package/dist/core/pigeon-ai-schemas.d.ts +171 -0
  389. package/dist/core/pigeon-ai-schemas.d.ts.map +1 -0
  390. package/dist/core/pigeon-ai-schemas.js +21 -0
  391. package/dist/core/pigeon-ai-schemas.js.map +1 -0
  392. package/dist/core/pigeon-manifest.d.ts +9 -0
  393. package/dist/core/pigeon-manifest.d.ts.map +1 -0
  394. package/dist/core/pigeon-manifest.js +30 -0
  395. package/dist/core/pigeon-manifest.js.map +1 -0
  396. package/dist/core/preferred-providers.d.ts +17 -0
  397. package/dist/core/preferred-providers.d.ts.map +1 -0
  398. package/dist/core/preferred-providers.js +24 -0
  399. package/dist/core/preferred-providers.js.map +1 -0
  400. package/dist/core/project-trust.d.ts +15 -0
  401. package/dist/core/project-trust.d.ts.map +1 -0
  402. package/dist/core/project-trust.js +60 -0
  403. package/dist/core/project-trust.js.map +1 -0
  404. package/dist/core/prompt-templates.d.ts +59 -0
  405. package/dist/core/prompt-templates.d.ts.map +1 -0
  406. package/dist/core/prompt-templates.js +283 -0
  407. package/dist/core/prompt-templates.js.map +1 -0
  408. package/dist/core/provider-composer.d.ts +82 -0
  409. package/dist/core/provider-composer.d.ts.map +1 -0
  410. package/dist/core/provider-composer.js +495 -0
  411. package/dist/core/provider-composer.js.map +1 -0
  412. package/dist/core/provider-matching.d.ts +6 -0
  413. package/dist/core/provider-matching.d.ts.map +1 -0
  414. package/dist/core/provider-matching.js +8 -0
  415. package/dist/core/provider-matching.js.map +1 -0
  416. package/dist/core/radius-mcp.d.ts +13 -0
  417. package/dist/core/radius-mcp.d.ts.map +1 -0
  418. package/dist/core/radius-mcp.js +29 -0
  419. package/dist/core/radius-mcp.js.map +1 -0
  420. package/dist/core/radius.d.ts +7 -0
  421. package/dist/core/radius.d.ts.map +1 -0
  422. package/dist/core/radius.js +10 -0
  423. package/dist/core/radius.js.map +1 -0
  424. package/dist/core/remote-catalog-provider.d.ts +23 -0
  425. package/dist/core/remote-catalog-provider.d.ts.map +1 -0
  426. package/dist/core/remote-catalog-provider.js +212 -0
  427. package/dist/core/remote-catalog-provider.js.map +1 -0
  428. package/dist/core/resolve-config-value.d.ts +32 -0
  429. package/dist/core/resolve-config-value.d.ts.map +1 -0
  430. package/dist/core/resolve-config-value.js +253 -0
  431. package/dist/core/resolve-config-value.js.map +1 -0
  432. package/dist/core/resource-loader.d.ts +237 -0
  433. package/dist/core/resource-loader.d.ts.map +1 -0
  434. package/dist/core/resource-loader.js +1027 -0
  435. package/dist/core/resource-loader.js.map +1 -0
  436. package/dist/core/runtime-credentials.d.ts +23 -0
  437. package/dist/core/runtime-credentials.d.ts.map +1 -0
  438. package/dist/core/runtime-credentials.js +53 -0
  439. package/dist/core/runtime-credentials.js.map +1 -0
  440. package/dist/core/sdk.d.ts +126 -0
  441. package/dist/core/sdk.d.ts.map +1 -0
  442. package/dist/core/sdk.js +334 -0
  443. package/dist/core/sdk.js.map +1 -0
  444. package/dist/core/session-cwd.d.ts +26 -0
  445. package/dist/core/session-cwd.d.ts.map +1 -0
  446. package/dist/core/session-cwd.js +46 -0
  447. package/dist/core/session-cwd.js.map +1 -0
  448. package/dist/core/session-export.d.ts +8 -0
  449. package/dist/core/session-export.d.ts.map +1 -0
  450. package/dist/core/session-export.js +33 -0
  451. package/dist/core/session-export.js.map +1 -0
  452. package/dist/core/session-manager.d.ts +433 -0
  453. package/dist/core/session-manager.d.ts.map +1 -0
  454. package/dist/core/session-manager.js +1569 -0
  455. package/dist/core/session-manager.js.map +1 -0
  456. package/dist/core/settings-defaults.d.ts +70 -0
  457. package/dist/core/settings-defaults.d.ts.map +1 -0
  458. package/dist/core/settings-defaults.js +71 -0
  459. package/dist/core/settings-defaults.js.map +1 -0
  460. package/dist/core/settings-diagnostics.d.ts +9 -0
  461. package/dist/core/settings-diagnostics.d.ts.map +1 -0
  462. package/dist/core/settings-diagnostics.js +21 -0
  463. package/dist/core/settings-diagnostics.js.map +1 -0
  464. package/dist/core/settings-manager.d.ts +253 -0
  465. package/dist/core/settings-manager.d.ts.map +1 -0
  466. package/dist/core/settings-manager.js +1161 -0
  467. package/dist/core/settings-manager.js.map +1 -0
  468. package/dist/core/settings-schema.d.ts +415 -0
  469. package/dist/core/settings-schema.d.ts.map +1 -0
  470. package/dist/core/settings-schema.js +362 -0
  471. package/dist/core/settings-schema.js.map +1 -0
  472. package/dist/core/skills.d.ts +63 -0
  473. package/dist/core/skills.d.ts.map +1 -0
  474. package/dist/core/skills.js +404 -0
  475. package/dist/core/skills.js.map +1 -0
  476. package/dist/core/slash-commands.d.ts +15 -0
  477. package/dist/core/slash-commands.d.ts.map +1 -0
  478. package/dist/core/slash-commands.js +28 -0
  479. package/dist/core/slash-commands.js.map +1 -0
  480. package/dist/core/source-info.d.ts +35 -0
  481. package/dist/core/source-info.d.ts.map +1 -0
  482. package/dist/core/source-info.js +48 -0
  483. package/dist/core/source-info.js.map +1 -0
  484. package/dist/core/system-prompt.d.ts +77 -0
  485. package/dist/core/system-prompt.d.ts.map +1 -0
  486. package/dist/core/system-prompt.js +151 -0
  487. package/dist/core/system-prompt.js.map +1 -0
  488. package/dist/core/timings.d.ts +10 -0
  489. package/dist/core/timings.d.ts.map +1 -0
  490. package/dist/core/timings.js +41 -0
  491. package/dist/core/timings.js.map +1 -0
  492. package/dist/core/tools/bash.d.ts +103 -0
  493. package/dist/core/tools/bash.d.ts.map +1 -0
  494. package/dist/core/tools/bash.js +380 -0
  495. package/dist/core/tools/bash.js.map +1 -0
  496. package/dist/core/tools/edit-diff.d.ts +110 -0
  497. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  498. package/dist/core/tools/edit-diff.js +562 -0
  499. package/dist/core/tools/edit-diff.js.map +1 -0
  500. package/dist/core/tools/edit.d.ts +44 -0
  501. package/dist/core/tools/edit.d.ts.map +1 -0
  502. package/dist/core/tools/edit.js +146 -0
  503. package/dist/core/tools/edit.js.map +1 -0
  504. package/dist/core/tools/file-mutation-queue.d.ts +6 -0
  505. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  506. package/dist/core/tools/file-mutation-queue.js +52 -0
  507. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  508. package/dist/core/tools/find.d.ts +42 -0
  509. package/dist/core/tools/find.d.ts.map +1 -0
  510. package/dist/core/tools/find.js +308 -0
  511. package/dist/core/tools/find.js.map +1 -0
  512. package/dist/core/tools/grep.d.ts +43 -0
  513. package/dist/core/tools/grep.d.ts.map +1 -0
  514. package/dist/core/tools/grep.js +266 -0
  515. package/dist/core/tools/grep.js.map +1 -0
  516. package/dist/core/tools/index.d.ts +43 -0
  517. package/dist/core/tools/index.d.ts.map +1 -0
  518. package/dist/core/tools/index.js +129 -0
  519. package/dist/core/tools/index.js.map +1 -0
  520. package/dist/core/tools/ls.d.ts +41 -0
  521. package/dist/core/tools/ls.d.ts.map +1 -0
  522. package/dist/core/tools/ls.js +127 -0
  523. package/dist/core/tools/ls.js.map +1 -0
  524. package/dist/core/tools/output-accumulator.d.ts +75 -0
  525. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  526. package/dist/core/tools/output-accumulator.js +223 -0
  527. package/dist/core/tools/output-accumulator.js.map +1 -0
  528. package/dist/core/tools/path-utils.d.ts +10 -0
  529. package/dist/core/tools/path-utils.d.ts.map +1 -0
  530. package/dist/core/tools/path-utils.js +99 -0
  531. package/dist/core/tools/path-utils.js.map +1 -0
  532. package/dist/core/tools/powershell.d.ts +16 -0
  533. package/dist/core/tools/powershell.d.ts.map +1 -0
  534. package/dist/core/tools/powershell.js +52 -0
  535. package/dist/core/tools/powershell.js.map +1 -0
  536. package/dist/core/tools/read.d.ts +68 -0
  537. package/dist/core/tools/read.d.ts.map +1 -0
  538. package/dist/core/tools/read.js +297 -0
  539. package/dist/core/tools/read.js.map +1 -0
  540. package/dist/core/tools/render-utils.d.ts +50 -0
  541. package/dist/core/tools/render-utils.d.ts.map +1 -0
  542. package/dist/core/tools/render-utils.js +153 -0
  543. package/dist/core/tools/render-utils.js.map +1 -0
  544. package/dist/core/tools/renderers/bash.d.ts +12 -0
  545. package/dist/core/tools/renderers/bash.d.ts.map +1 -0
  546. package/dist/core/tools/renderers/bash.js +95 -0
  547. package/dist/core/tools/renderers/bash.js.map +1 -0
  548. package/dist/core/tools/renderers/edit.d.ts +23 -0
  549. package/dist/core/tools/renderers/edit.d.ts.map +1 -0
  550. package/dist/core/tools/renderers/edit.js +168 -0
  551. package/dist/core/tools/renderers/edit.js.map +1 -0
  552. package/dist/core/tools/renderers/find.d.ts +10 -0
  553. package/dist/core/tools/renderers/find.d.ts.map +1 -0
  554. package/dist/core/tools/renderers/find.js +64 -0
  555. package/dist/core/tools/renderers/find.js.map +1 -0
  556. package/dist/core/tools/renderers/grep.d.ts +10 -0
  557. package/dist/core/tools/renderers/grep.d.ts.map +1 -0
  558. package/dist/core/tools/renderers/grep.js +69 -0
  559. package/dist/core/tools/renderers/grep.js.map +1 -0
  560. package/dist/core/tools/renderers/index.d.ts +28 -0
  561. package/dist/core/tools/renderers/index.d.ts.map +1 -0
  562. package/dist/core/tools/renderers/index.js +47 -0
  563. package/dist/core/tools/renderers/index.js.map +1 -0
  564. package/dist/core/tools/renderers/ls.d.ts +10 -0
  565. package/dist/core/tools/renderers/ls.d.ts.map +1 -0
  566. package/dist/core/tools/renderers/ls.js +58 -0
  567. package/dist/core/tools/renderers/ls.js.map +1 -0
  568. package/dist/core/tools/renderers/read.d.ts +11 -0
  569. package/dist/core/tools/renderers/read.d.ts.map +1 -0
  570. package/dist/core/tools/renderers/read.js +130 -0
  571. package/dist/core/tools/renderers/read.js.map +1 -0
  572. package/dist/core/tools/renderers/write.d.ts +10 -0
  573. package/dist/core/tools/renderers/write.d.ts.map +1 -0
  574. package/dist/core/tools/renderers/write.js +153 -0
  575. package/dist/core/tools/renderers/write.js.map +1 -0
  576. package/dist/core/tools/tool-definition-wrapper.d.ts +26 -0
  577. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  578. package/dist/core/tools/tool-definition-wrapper.js +38 -0
  579. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  580. package/dist/core/tools/truncate.d.ts +74 -0
  581. package/dist/core/tools/truncate.d.ts.map +1 -0
  582. package/dist/core/tools/truncate.js +244 -0
  583. package/dist/core/tools/truncate.js.map +1 -0
  584. package/dist/core/tools/write.d.ts +30 -0
  585. package/dist/core/tools/write.d.ts.map +1 -0
  586. package/dist/core/tools/write.js +61 -0
  587. package/dist/core/tools/write.js.map +1 -0
  588. package/dist/core/trust-manager.d.ts +36 -0
  589. package/dist/core/trust-manager.d.ts.map +1 -0
  590. package/dist/core/trust-manager.js +210 -0
  591. package/dist/core/trust-manager.js.map +1 -0
  592. package/dist/core/usage-totals.d.ts +21 -0
  593. package/dist/core/usage-totals.d.ts.map +1 -0
  594. package/dist/core/usage-totals.js +84 -0
  595. package/dist/core/usage-totals.js.map +1 -0
  596. package/dist/core/virtual-models.d.ts +117 -0
  597. package/dist/core/virtual-models.d.ts.map +1 -0
  598. package/dist/core/virtual-models.js +124 -0
  599. package/dist/core/virtual-models.js.map +1 -0
  600. package/dist/extensions/codemode/execute.d.ts +16 -0
  601. package/dist/extensions/codemode/execute.d.ts.map +1 -0
  602. package/dist/extensions/codemode/execute.js +775 -0
  603. package/dist/extensions/codemode/execute.js.map +1 -0
  604. package/dist/extensions/codemode/execute.lazy.d.ts +3 -0
  605. package/dist/extensions/codemode/execute.lazy.d.ts.map +1 -0
  606. package/dist/extensions/codemode/execute.lazy.js +3 -0
  607. package/dist/extensions/codemode/execute.lazy.js.map +1 -0
  608. package/dist/extensions/codemode/index.d.ts +21 -0
  609. package/dist/extensions/codemode/index.d.ts.map +1 -0
  610. package/dist/extensions/codemode/index.js +33 -0
  611. package/dist/extensions/codemode/index.js.map +1 -0
  612. package/dist/extensions/codemode/renderer.d.ts +12 -0
  613. package/dist/extensions/codemode/renderer.d.ts.map +1 -0
  614. package/dist/extensions/codemode/renderer.js +147 -0
  615. package/dist/extensions/codemode/renderer.js.map +1 -0
  616. package/dist/extensions/codemode/tool.d.ts +125 -0
  617. package/dist/extensions/codemode/tool.d.ts.map +1 -0
  618. package/dist/extensions/codemode/tool.js +335 -0
  619. package/dist/extensions/codemode/tool.js.map +1 -0
  620. package/dist/extensions/codemode/worker.d.ts +7 -0
  621. package/dist/extensions/codemode/worker.d.ts.map +1 -0
  622. package/dist/extensions/codemode/worker.js +7 -0
  623. package/dist/extensions/codemode/worker.js.map +1 -0
  624. package/dist/extensions/index.d.ts +3 -0
  625. package/dist/extensions/index.d.ts.map +1 -0
  626. package/dist/extensions/index.js +13 -0
  627. package/dist/extensions/index.js.map +1 -0
  628. package/dist/extensions/llama/client.d.ts +74 -0
  629. package/dist/extensions/llama/client.d.ts.map +1 -0
  630. package/dist/extensions/llama/client.js +324 -0
  631. package/dist/extensions/llama/client.js.map +1 -0
  632. package/dist/extensions/llama/huggingface.d.ts +23 -0
  633. package/dist/extensions/llama/huggingface.d.ts.map +1 -0
  634. package/dist/extensions/llama/huggingface.js +141 -0
  635. package/dist/extensions/llama/huggingface.js.map +1 -0
  636. package/dist/extensions/llama/index.d.ts +3 -0
  637. package/dist/extensions/llama/index.d.ts.map +1 -0
  638. package/dist/extensions/llama/index.js +219 -0
  639. package/dist/extensions/llama/index.js.map +1 -0
  640. package/dist/extensions/llama/provider.d.ts +12 -0
  641. package/dist/extensions/llama/provider.d.ts.map +1 -0
  642. package/dist/extensions/llama/provider.js +238 -0
  643. package/dist/extensions/llama/provider.js.map +1 -0
  644. package/dist/extensions/llama/ui.d.ts +42 -0
  645. package/dist/extensions/llama/ui.d.ts.map +1 -0
  646. package/dist/extensions/llama/ui.js +441 -0
  647. package/dist/extensions/llama/ui.js.map +1 -0
  648. package/dist/extensions/mcp/cli.d.ts +23 -0
  649. package/dist/extensions/mcp/cli.d.ts.map +1 -0
  650. package/dist/extensions/mcp/cli.js +555 -0
  651. package/dist/extensions/mcp/cli.js.map +1 -0
  652. package/dist/extensions/mcp/cli.lazy.d.ts +3 -0
  653. package/dist/extensions/mcp/cli.lazy.d.ts.map +1 -0
  654. package/dist/extensions/mcp/cli.lazy.js +3 -0
  655. package/dist/extensions/mcp/cli.lazy.js.map +1 -0
  656. package/dist/extensions/mcp/config.d.ts +86 -0
  657. package/dist/extensions/mcp/config.d.ts.map +1 -0
  658. package/dist/extensions/mcp/config.js +193 -0
  659. package/dist/extensions/mcp/config.js.map +1 -0
  660. package/dist/extensions/mcp/index.d.ts +79 -0
  661. package/dist/extensions/mcp/index.d.ts.map +1 -0
  662. package/dist/extensions/mcp/index.js +1203 -0
  663. package/dist/extensions/mcp/index.js.map +1 -0
  664. package/dist/extensions/mcp/log.d.ts +16 -0
  665. package/dist/extensions/mcp/log.d.ts.map +1 -0
  666. package/dist/extensions/mcp/log.js +66 -0
  667. package/dist/extensions/mcp/log.js.map +1 -0
  668. package/dist/extensions/mcp/oauth.d.ts +64 -0
  669. package/dist/extensions/mcp/oauth.d.ts.map +1 -0
  670. package/dist/extensions/mcp/oauth.js +188 -0
  671. package/dist/extensions/mcp/oauth.js.map +1 -0
  672. package/dist/extensions/mcp/resources.d.ts +36 -0
  673. package/dist/extensions/mcp/resources.d.ts.map +1 -0
  674. package/dist/extensions/mcp/resources.js +262 -0
  675. package/dist/extensions/mcp/resources.js.map +1 -0
  676. package/dist/extensions/mcp/runtime.d.ts +105 -0
  677. package/dist/extensions/mcp/runtime.d.ts.map +1 -0
  678. package/dist/extensions/mcp/runtime.js +447 -0
  679. package/dist/extensions/mcp/runtime.js.map +1 -0
  680. package/dist/extensions/mcp/runtime.lazy.d.ts +3 -0
  681. package/dist/extensions/mcp/runtime.lazy.d.ts.map +1 -0
  682. package/dist/extensions/mcp/runtime.lazy.js +3 -0
  683. package/dist/extensions/mcp/runtime.lazy.js.map +1 -0
  684. package/dist/extensions/mcp/tools.d.ts +57 -0
  685. package/dist/extensions/mcp/tools.d.ts.map +1 -0
  686. package/dist/extensions/mcp/tools.js +141 -0
  687. package/dist/extensions/mcp/tools.js.map +1 -0
  688. package/dist/extensions/mcp/ui.d.ts +61 -0
  689. package/dist/extensions/mcp/ui.d.ts.map +1 -0
  690. package/dist/extensions/mcp/ui.js +195 -0
  691. package/dist/extensions/mcp/ui.js.map +1 -0
  692. package/dist/extensions/tool-search/index.d.ts +12 -0
  693. package/dist/extensions/tool-search/index.d.ts.map +1 -0
  694. package/dist/extensions/tool-search/index.js +15 -0
  695. package/dist/extensions/tool-search/index.js.map +1 -0
  696. package/dist/extensions/tool-search/tool.d.ts +86 -0
  697. package/dist/extensions/tool-search/tool.d.ts.map +1 -0
  698. package/dist/extensions/tool-search/tool.js +267 -0
  699. package/dist/extensions/tool-search/tool.js.map +1 -0
  700. package/dist/index.d.ts +45 -0
  701. package/dist/index.d.ts.map +1 -0
  702. package/dist/index.js +54 -0
  703. package/dist/index.js.map +1 -0
  704. package/dist/main.d.ts +16 -0
  705. package/dist/main.d.ts.map +1 -0
  706. package/dist/main.js +954 -0
  707. package/dist/main.js.map +1 -0
  708. package/dist/migrations.d.ts +31 -0
  709. package/dist/migrations.d.ts.map +1 -0
  710. package/dist/migrations.js +280 -0
  711. package/dist/migrations.js.map +1 -0
  712. package/dist/modes/diagnostics-stderr.d.ts +4 -0
  713. package/dist/modes/diagnostics-stderr.d.ts.map +1 -0
  714. package/dist/modes/diagnostics-stderr.js +11 -0
  715. package/dist/modes/diagnostics-stderr.js.map +1 -0
  716. package/dist/modes/index.d.ts +10 -0
  717. package/dist/modes/index.d.ts.map +1 -0
  718. package/dist/modes/index.js +8 -0
  719. package/dist/modes/index.js.map +1 -0
  720. package/dist/modes/interactive/bug-report.d.ts +16 -0
  721. package/dist/modes/interactive/bug-report.d.ts.map +1 -0
  722. package/dist/modes/interactive/bug-report.js +210 -0
  723. package/dist/modes/interactive/bug-report.js.map +1 -0
  724. package/dist/modes/interactive/chat-viewport.d.ts +20 -0
  725. package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
  726. package/dist/modes/interactive/chat-viewport.js +28 -0
  727. package/dist/modes/interactive/chat-viewport.js.map +1 -0
  728. package/dist/modes/interactive/components/armin.d.ts +37 -0
  729. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  730. package/dist/modes/interactive/components/armin.js +335 -0
  731. package/dist/modes/interactive/components/armin.js.map +1 -0
  732. package/dist/modes/interactive/components/assistant-message.d.ts +30 -0
  733. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  734. package/dist/modes/interactive/components/assistant-message.js +188 -0
  735. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  736. package/dist/modes/interactive/components/auth-url.d.ts +14 -0
  737. package/dist/modes/interactive/components/auth-url.d.ts.map +1 -0
  738. package/dist/modes/interactive/components/auth-url.js +37 -0
  739. package/dist/modes/interactive/components/auth-url.js.map +1 -0
  740. package/dist/modes/interactive/components/bash-execution.d.ts +39 -0
  741. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  742. package/dist/modes/interactive/components/bash-execution.js +181 -0
  743. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  744. package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  745. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  746. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  747. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  748. package/dist/modes/interactive/components/branch-summary-message.d.ts +21 -0
  749. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  750. package/dist/modes/interactive/components/branch-summary-message.js +62 -0
  751. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  752. package/dist/modes/interactive/components/compaction-summary-message.d.ts +21 -0
  753. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  754. package/dist/modes/interactive/components/compaction-summary-message.js +63 -0
  755. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  756. package/dist/modes/interactive/components/config-selector.d.ts +102 -0
  757. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  758. package/dist/modes/interactive/components/config-selector.js +761 -0
  759. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  760. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  761. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  762. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  763. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  764. package/dist/modes/interactive/components/custom-editor.d.ts +30 -0
  765. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  766. package/dist/modes/interactive/components/custom-editor.js +134 -0
  767. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  768. package/dist/modes/interactive/components/custom-entry.d.ts +21 -0
  769. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
  770. package/dist/modes/interactive/components/custom-entry.js +59 -0
  771. package/dist/modes/interactive/components/custom-entry.js.map +1 -0
  772. package/dist/modes/interactive/components/custom-message.d.ts +25 -0
  773. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  774. package/dist/modes/interactive/components/custom-message.js +96 -0
  775. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  776. package/dist/modes/interactive/components/diff.d.ts +12 -0
  777. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  778. package/dist/modes/interactive/components/diff.js +139 -0
  779. package/dist/modes/interactive/components/diff.js.map +1 -0
  780. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  781. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  782. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  783. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  784. package/dist/modes/interactive/components/easter-egg-3d.d.ts +104 -0
  785. package/dist/modes/interactive/components/easter-egg-3d.d.ts.map +1 -0
  786. package/dist/modes/interactive/components/easter-egg-3d.js +1141 -0
  787. package/dist/modes/interactive/components/easter-egg-3d.js.map +1 -0
  788. package/dist/modes/interactive/components/easter-egg-3d.lazy.d.ts +6 -0
  789. package/dist/modes/interactive/components/easter-egg-3d.lazy.d.ts.map +1 -0
  790. package/dist/modes/interactive/components/easter-egg-3d.lazy.js +23 -0
  791. package/dist/modes/interactive/components/easter-egg-3d.lazy.js.map +1 -0
  792. package/dist/modes/interactive/components/extension-editor.d.ts +26 -0
  793. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  794. package/dist/modes/interactive/components/extension-editor.js +107 -0
  795. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  796. package/dist/modes/interactive/components/extension-input.d.ts +25 -0
  797. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  798. package/dist/modes/interactive/components/extension-input.js +67 -0
  799. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  800. package/dist/modes/interactive/components/extension-selector.d.ts +27 -0
  801. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  802. package/dist/modes/interactive/components/extension-selector.js +95 -0
  803. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  804. package/dist/modes/interactive/components/first-time-setup.d.ts +23 -0
  805. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
  806. package/dist/modes/interactive/components/first-time-setup.js +79 -0
  807. package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
  808. package/dist/modes/interactive/components/footer.d.ts +39 -0
  809. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  810. package/dist/modes/interactive/components/footer.js +265 -0
  811. package/dist/modes/interactive/components/footer.js.map +1 -0
  812. package/dist/modes/interactive/components/index.d.ts +33 -0
  813. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  814. package/dist/modes/interactive/components/index.js +34 -0
  815. package/dist/modes/interactive/components/index.js.map +1 -0
  816. package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
  817. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  818. package/dist/modes/interactive/components/keybinding-hints.js +36 -0
  819. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  820. package/dist/modes/interactive/components/login-dialog.d.ts +59 -0
  821. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  822. package/dist/modes/interactive/components/login-dialog.js +272 -0
  823. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  824. package/dist/modes/interactive/components/markdown-transform.d.ts +4 -0
  825. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
  826. package/dist/modes/interactive/components/markdown-transform.js +20 -0
  827. package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
  828. package/dist/modes/interactive/components/mermaid.d.ts +12 -0
  829. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
  830. package/dist/modes/interactive/components/mermaid.js +89 -0
  831. package/dist/modes/interactive/components/mermaid.js.map +1 -0
  832. package/dist/modes/interactive/components/model-selector.d.ts +61 -0
  833. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  834. package/dist/modes/interactive/components/model-selector.js +383 -0
  835. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  836. package/dist/modes/interactive/components/oauth-selector.d.ts +59 -0
  837. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  838. package/dist/modes/interactive/components/oauth-selector.js +207 -0
  839. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  840. package/dist/modes/interactive/components/pigeon-logo.d.ts +19 -0
  841. package/dist/modes/interactive/components/pigeon-logo.d.ts.map +1 -0
  842. package/dist/modes/interactive/components/pigeon-logo.js +37 -0
  843. package/dist/modes/interactive/components/pigeon-logo.js.map +1 -0
  844. package/dist/modes/interactive/components/provider-brand.d.ts +14 -0
  845. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
  846. package/dist/modes/interactive/components/provider-brand.js +66 -0
  847. package/dist/modes/interactive/components/provider-brand.js.map +1 -0
  848. package/dist/modes/interactive/components/radius-login-selector.d.ts +14 -0
  849. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
  850. package/dist/modes/interactive/components/radius-login-selector.js +55 -0
  851. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
  852. package/dist/modes/interactive/components/scoped-models-selector.d.ts +47 -0
  853. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  854. package/dist/modes/interactive/components/scoped-models-selector.js +345 -0
  855. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  856. package/dist/modes/interactive/components/session-selector-search.d.ts +27 -0
  857. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  858. package/dist/modes/interactive/components/session-selector-search.js +219 -0
  859. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  860. package/dist/modes/interactive/components/session-selector.d.ts +103 -0
  861. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  862. package/dist/modes/interactive/components/session-selector.js +917 -0
  863. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  864. package/dist/modes/interactive/components/settings-selector.d.ts +96 -0
  865. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  866. package/dist/modes/interactive/components/settings-selector.js +764 -0
  867. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  868. package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
  869. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
  870. package/dist/modes/interactive/components/settings-submenu.js +171 -0
  871. package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
  872. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  873. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  874. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  875. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  876. package/dist/modes/interactive/components/skill-invocation-message.d.ts +22 -0
  877. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  878. package/dist/modes/interactive/components/skill-invocation-message.js +65 -0
  879. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  880. package/dist/modes/interactive/components/status-indicator.d.ts +30 -0
  881. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
  882. package/dist/modes/interactive/components/status-indicator.js +67 -0
  883. package/dist/modes/interactive/components/status-indicator.js.map +1 -0
  884. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  885. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  886. package/dist/modes/interactive/components/theme-selector.js +50 -0
  887. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  888. package/dist/modes/interactive/components/themed-text.d.ts +17 -0
  889. package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
  890. package/dist/modes/interactive/components/themed-text.js +29 -0
  891. package/dist/modes/interactive/components/themed-text.js.map +1 -0
  892. package/dist/modes/interactive/components/thinking-selector.d.ts +23 -0
  893. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  894. package/dist/modes/interactive/components/thinking-selector.js +113 -0
  895. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  896. package/dist/modes/interactive/components/tool-execution.d.ts +79 -0
  897. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  898. package/dist/modes/interactive/components/tool-execution.js +338 -0
  899. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  900. package/dist/modes/interactive/components/tree-selector.d.ts +96 -0
  901. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  902. package/dist/modes/interactive/components/tree-selector.js +1262 -0
  903. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  904. package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
  905. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  906. package/dist/modes/interactive/components/trust-selector.js +91 -0
  907. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  908. package/dist/modes/interactive/components/user-message-selector.d.ts +31 -0
  909. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  910. package/dist/modes/interactive/components/user-message-selector.js +122 -0
  911. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  912. package/dist/modes/interactive/components/user-message.d.ts +19 -0
  913. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  914. package/dist/modes/interactive/components/user-message.js +60 -0
  915. package/dist/modes/interactive/components/user-message.js.map +1 -0
  916. package/dist/modes/interactive/components/visual-truncate.d.ts +48 -0
  917. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  918. package/dist/modes/interactive/components/visual-truncate.js +66 -0
  919. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  920. package/dist/modes/interactive/external-editor.d.ts +13 -0
  921. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  922. package/dist/modes/interactive/external-editor.js +60 -0
  923. package/dist/modes/interactive/external-editor.js.map +1 -0
  924. package/dist/modes/interactive/interactive-mode.d.ts +536 -0
  925. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  926. package/dist/modes/interactive/interactive-mode.js +6212 -0
  927. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  928. package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
  929. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
  930. package/dist/modes/interactive/model-catalog-refresh.js +34 -0
  931. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
  932. package/dist/modes/interactive/model-search.d.ts +22 -0
  933. package/dist/modes/interactive/model-search.d.ts.map +1 -0
  934. package/dist/modes/interactive/model-search.js +36 -0
  935. package/dist/modes/interactive/model-search.js.map +1 -0
  936. package/dist/modes/interactive/program-resume-reporter.d.ts +32 -0
  937. package/dist/modes/interactive/program-resume-reporter.d.ts.map +1 -0
  938. package/dist/modes/interactive/program-resume-reporter.js +56 -0
  939. package/dist/modes/interactive/program-resume-reporter.js.map +1 -0
  940. package/dist/modes/interactive/program-status-reporter.d.ts +36 -0
  941. package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
  942. package/dist/modes/interactive/program-status-reporter.js +114 -0
  943. package/dist/modes/interactive/program-status-reporter.js.map +1 -0
  944. package/dist/modes/interactive/session-share.d.ts +18 -0
  945. package/dist/modes/interactive/session-share.d.ts.map +1 -0
  946. package/dist/modes/interactive/session-share.js +205 -0
  947. package/dist/modes/interactive/session-share.js.map +1 -0
  948. package/dist/modes/interactive/theme/dark.json +78 -0
  949. package/dist/modes/interactive/theme/light.json +78 -0
  950. package/dist/modes/interactive/theme/system-theme.d.ts +55 -0
  951. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  952. package/dist/modes/interactive/theme/system-theme.js +546 -0
  953. package/dist/modes/interactive/theme/system-theme.js.map +1 -0
  954. package/dist/modes/interactive/theme/theme-controller.d.ts +81 -0
  955. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  956. package/dist/modes/interactive/theme/theme-controller.js +210 -0
  957. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  958. package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  959. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  960. package/dist/modes/interactive/theme/theme-schema.js +105 -0
  961. package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  962. package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  963. package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  964. package/dist/modes/interactive/theme/theme-tokens.js +94 -0
  965. package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  966. package/dist/modes/interactive/theme/theme.d.ts +165 -0
  967. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  968. package/dist/modes/interactive/theme/theme.js +918 -0
  969. package/dist/modes/interactive/theme/theme.js.map +1 -0
  970. package/dist/modes/interactive/tui-renderer.d.ts +22 -0
  971. package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
  972. package/dist/modes/interactive/tui-renderer.js +67 -0
  973. package/dist/modes/interactive/tui-renderer.js.map +1 -0
  974. package/dist/modes/json-event.d.ts +34 -0
  975. package/dist/modes/json-event.d.ts.map +1 -0
  976. package/dist/modes/json-event.js +29 -0
  977. package/dist/modes/json-event.js.map +1 -0
  978. package/dist/modes/print-mode.d.ts +28 -0
  979. package/dist/modes/print-mode.d.ts.map +1 -0
  980. package/dist/modes/print-mode.js +155 -0
  981. package/dist/modes/print-mode.js.map +1 -0
  982. package/dist/modes/rpc/jsonl.d.ts +17 -0
  983. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  984. package/dist/modes/rpc/jsonl.js +49 -0
  985. package/dist/modes/rpc/jsonl.js.map +1 -0
  986. package/dist/modes/rpc/rpc-client.d.ts +254 -0
  987. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  988. package/dist/modes/rpc/rpc-client.js +499 -0
  989. package/dist/modes/rpc/rpc-client.js.map +1 -0
  990. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  991. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  992. package/dist/modes/rpc/rpc-mode.js +677 -0
  993. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  994. package/dist/modes/rpc/rpc-types.d.ts +478 -0
  995. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  996. package/dist/modes/rpc/rpc-types.js +8 -0
  997. package/dist/modes/rpc/rpc-types.js.map +1 -0
  998. package/dist/package-manager-cli.d.ts +9 -0
  999. package/dist/package-manager-cli.d.ts.map +1 -0
  1000. package/dist/package-manager-cli.js +1094 -0
  1001. package/dist/package-manager-cli.js.map +1 -0
  1002. package/dist/rpc-entry.d.ts +3 -0
  1003. package/dist/rpc-entry.d.ts.map +1 -0
  1004. package/dist/rpc-entry.js +11 -0
  1005. package/dist/rpc-entry.js.map +1 -0
  1006. package/dist/utils/abort.d.ts +5 -0
  1007. package/dist/utils/abort.d.ts.map +1 -0
  1008. package/dist/utils/abort.js +48 -0
  1009. package/dist/utils/abort.js.map +1 -0
  1010. package/dist/utils/ansi.d.ts +10 -0
  1011. package/dist/utils/ansi.d.ts.map +1 -0
  1012. package/dist/utils/ansi.js +74 -0
  1013. package/dist/utils/ansi.js.map +1 -0
  1014. package/dist/utils/changelog.d.ts +22 -0
  1015. package/dist/utils/changelog.d.ts.map +1 -0
  1016. package/dist/utils/changelog.js +172 -0
  1017. package/dist/utils/changelog.js.map +1 -0
  1018. package/dist/utils/child-process.d.ts +18 -0
  1019. package/dist/utils/child-process.d.ts.map +1 -0
  1020. package/dist/utils/child-process.js +106 -0
  1021. package/dist/utils/child-process.js.map +1 -0
  1022. package/dist/utils/clipboard-command.d.ts +7 -0
  1023. package/dist/utils/clipboard-command.d.ts.map +1 -0
  1024. package/dist/utils/clipboard-command.js +52 -0
  1025. package/dist/utils/clipboard-command.js.map +1 -0
  1026. package/dist/utils/clipboard-image.d.ts +11 -0
  1027. package/dist/utils/clipboard-image.d.ts.map +1 -0
  1028. package/dist/utils/clipboard-image.js +214 -0
  1029. package/dist/utils/clipboard-image.js.map +1 -0
  1030. package/dist/utils/clipboard.d.ts +6 -0
  1031. package/dist/utils/clipboard.d.ts.map +1 -0
  1032. package/dist/utils/clipboard.js +162 -0
  1033. package/dist/utils/clipboard.js.map +1 -0
  1034. package/dist/utils/exif-orientation.d.ts +5 -0
  1035. package/dist/utils/exif-orientation.d.ts.map +1 -0
  1036. package/dist/utils/exif-orientation.js +157 -0
  1037. package/dist/utils/exif-orientation.js.map +1 -0
  1038. package/dist/utils/flush-stdout.d.ts +8 -0
  1039. package/dist/utils/flush-stdout.d.ts.map +1 -0
  1040. package/dist/utils/flush-stdout.js +23 -0
  1041. package/dist/utils/flush-stdout.js.map +1 -0
  1042. package/dist/utils/frontmatter.d.ts +8 -0
  1043. package/dist/utils/frontmatter.d.ts.map +1 -0
  1044. package/dist/utils/frontmatter.js +27 -0
  1045. package/dist/utils/frontmatter.js.map +1 -0
  1046. package/dist/utils/fs-watch.d.ts +5 -0
  1047. package/dist/utils/fs-watch.d.ts.map +1 -0
  1048. package/dist/utils/fs-watch.js +25 -0
  1049. package/dist/utils/fs-watch.js.map +1 -0
  1050. package/dist/utils/git.d.ts +26 -0
  1051. package/dist/utils/git.d.ts.map +1 -0
  1052. package/dist/utils/git.js +195 -0
  1053. package/dist/utils/git.js.map +1 -0
  1054. package/dist/utils/html.d.ts +7 -0
  1055. package/dist/utils/html.d.ts.map +1 -0
  1056. package/dist/utils/html.js +40 -0
  1057. package/dist/utils/html.js.map +1 -0
  1058. package/dist/utils/image-convert.d.ts +22 -0
  1059. package/dist/utils/image-convert.d.ts.map +1 -0
  1060. package/dist/utils/image-convert.js +84 -0
  1061. package/dist/utils/image-convert.js.map +1 -0
  1062. package/dist/utils/image-process.d.ts +18 -0
  1063. package/dist/utils/image-process.d.ts.map +1 -0
  1064. package/dist/utils/image-process.js +83 -0
  1065. package/dist/utils/image-process.js.map +1 -0
  1066. package/dist/utils/image-resize-core.d.ts +42 -0
  1067. package/dist/utils/image-resize-core.d.ts.map +1 -0
  1068. package/dist/utils/image-resize-core.js +131 -0
  1069. package/dist/utils/image-resize-core.js.map +1 -0
  1070. package/dist/utils/image-resize-worker.d.ts +2 -0
  1071. package/dist/utils/image-resize-worker.d.ts.map +1 -0
  1072. package/dist/utils/image-resize-worker.js +32 -0
  1073. package/dist/utils/image-resize-worker.js.map +1 -0
  1074. package/dist/utils/image-resize.d.ts +16 -0
  1075. package/dist/utils/image-resize.d.ts.map +1 -0
  1076. package/dist/utils/image-resize.js +98 -0
  1077. package/dist/utils/image-resize.js.map +1 -0
  1078. package/dist/utils/json.d.ts +3 -0
  1079. package/dist/utils/json.d.ts.map +1 -0
  1080. package/dist/utils/json.js +7 -0
  1081. package/dist/utils/json.js.map +1 -0
  1082. package/dist/utils/management-http.d.ts +25 -0
  1083. package/dist/utils/management-http.d.ts.map +1 -0
  1084. package/dist/utils/management-http.js +54 -0
  1085. package/dist/utils/management-http.js.map +1 -0
  1086. package/dist/utils/mime.d.ts +3 -0
  1087. package/dist/utils/mime.d.ts.map +1 -0
  1088. package/dist/utils/mime.js +110 -0
  1089. package/dist/utils/mime.js.map +1 -0
  1090. package/dist/utils/open-browser.d.ts +9 -0
  1091. package/dist/utils/open-browser.d.ts.map +1 -0
  1092. package/dist/utils/open-browser.js +25 -0
  1093. package/dist/utils/open-browser.js.map +1 -0
  1094. package/dist/utils/output-files.d.ts +31 -0
  1095. package/dist/utils/output-files.d.ts.map +1 -0
  1096. package/dist/utils/output-files.js +65 -0
  1097. package/dist/utils/output-files.js.map +1 -0
  1098. package/dist/utils/paths.d.ts +51 -0
  1099. package/dist/utils/paths.d.ts.map +1 -0
  1100. package/dist/utils/paths.js +156 -0
  1101. package/dist/utils/paths.js.map +1 -0
  1102. package/dist/utils/photon.d.ts +21 -0
  1103. package/dist/utils/photon.d.ts.map +1 -0
  1104. package/dist/utils/photon.js +121 -0
  1105. package/dist/utils/photon.js.map +1 -0
  1106. package/dist/utils/pigeon-user-agent.d.ts +3 -0
  1107. package/dist/utils/pigeon-user-agent.d.ts.map +1 -0
  1108. package/dist/utils/pigeon-user-agent.js +6 -0
  1109. package/dist/utils/pigeon-user-agent.js.map +1 -0
  1110. package/dist/utils/shell.d.ts +36 -0
  1111. package/dist/utils/shell.d.ts.map +1 -0
  1112. package/dist/utils/shell.js +308 -0
  1113. package/dist/utils/shell.js.map +1 -0
  1114. package/dist/utils/sleep.d.ts +5 -0
  1115. package/dist/utils/sleep.d.ts.map +1 -0
  1116. package/dist/utils/sleep.js +17 -0
  1117. package/dist/utils/sleep.js.map +1 -0
  1118. package/dist/utils/syntax-highlight.d.ts +18 -0
  1119. package/dist/utils/syntax-highlight.d.ts.map +1 -0
  1120. package/dist/utils/syntax-highlight.js +191 -0
  1121. package/dist/utils/syntax-highlight.js.map +1 -0
  1122. package/dist/utils/terminal-question.d.ts +8 -0
  1123. package/dist/utils/terminal-question.d.ts.map +1 -0
  1124. package/dist/utils/terminal-question.js +24 -0
  1125. package/dist/utils/terminal-question.js.map +1 -0
  1126. package/dist/utils/text.d.ts +8 -0
  1127. package/dist/utils/text.d.ts.map +1 -0
  1128. package/dist/utils/text.js +9 -0
  1129. package/dist/utils/text.js.map +1 -0
  1130. package/dist/utils/tool-result-images.d.ts +21 -0
  1131. package/dist/utils/tool-result-images.d.ts.map +1 -0
  1132. package/dist/utils/tool-result-images.js +48 -0
  1133. package/dist/utils/tool-result-images.js.map +1 -0
  1134. package/dist/utils/tools-manager.d.ts +14 -0
  1135. package/dist/utils/tools-manager.d.ts.map +1 -0
  1136. package/dist/utils/tools-manager.js +340 -0
  1137. package/dist/utils/tools-manager.js.map +1 -0
  1138. package/dist/utils/version-check.d.ts +19 -0
  1139. package/dist/utils/version-check.d.ts.map +1 -0
  1140. package/dist/utils/version-check.js +82 -0
  1141. package/dist/utils/version-check.js.map +1 -0
  1142. package/dist/utils/web-url.d.ts +12 -0
  1143. package/dist/utils/web-url.d.ts.map +1 -0
  1144. package/dist/utils/web-url.js +20 -0
  1145. package/dist/utils/web-url.js.map +1 -0
  1146. package/dist/utils/windows-self-update.d.ts +3 -0
  1147. package/dist/utils/windows-self-update.d.ts.map +1 -0
  1148. package/dist/utils/windows-self-update.js +77 -0
  1149. package/dist/utils/windows-self-update.js.map +1 -0
  1150. package/dist/utils/wsl.d.ts +8 -0
  1151. package/dist/utils/wsl.d.ts.map +1 -0
  1152. package/dist/utils/wsl.js +23 -0
  1153. package/dist/utils/wsl.js.map +1 -0
  1154. package/dist/utils/zip.d.ts +7 -0
  1155. package/dist/utils/zip.d.ts.map +1 -0
  1156. package/dist/utils/zip.js +60 -0
  1157. package/dist/utils/zip.js.map +1 -0
  1158. package/docs/cli-integration.md +106 -0
  1159. package/docs/cli.md +358 -0
  1160. package/docs/codemode.md +241 -0
  1161. package/docs/compaction.md +463 -0
  1162. package/docs/configuration.md +47 -0
  1163. package/docs/containerization.md +151 -0
  1164. package/docs/custom-provider.md +227 -0
  1165. package/docs/docs.json +224 -0
  1166. package/docs/environment-variables.md +103 -0
  1167. package/docs/extensions.md +3376 -0
  1168. package/docs/how-pigeon-works.md +49 -0
  1169. package/docs/index.md +39 -0
  1170. package/docs/json.md +226 -0
  1171. package/docs/keybindings.md +195 -0
  1172. package/docs/llama-cpp.md +138 -0
  1173. package/docs/mcp.md +301 -0
  1174. package/docs/message-types.md +280 -0
  1175. package/docs/models-configuration.md +213 -0
  1176. package/docs/models.md +246 -0
  1177. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  1178. package/docs/packages.md +153 -0
  1179. package/docs/prompt-templates.md +59 -0
  1180. package/docs/providers.md +249 -0
  1181. package/docs/quickstart.md +124 -0
  1182. package/docs/rpc-commands.md +860 -0
  1183. package/docs/rpc-extension-ui.md +200 -0
  1184. package/docs/rpc.md +195 -0
  1185. package/docs/sdk.md +147 -0
  1186. package/docs/security.md +99 -0
  1187. package/docs/session-format.md +293 -0
  1188. package/docs/sessions.md +82 -0
  1189. package/docs/settings.md +175 -0
  1190. package/docs/shell-aliases.md +93 -0
  1191. package/docs/skills.md +93 -0
  1192. package/docs/slash-commands.md +61 -0
  1193. package/docs/subscriptions.md +96 -0
  1194. package/docs/terminal-setup.md +290 -0
  1195. package/docs/termux.md +117 -0
  1196. package/docs/themes.md +138 -0
  1197. package/docs/tmux.md +61 -0
  1198. package/docs/tui.md +198 -0
  1199. package/docs/usage.md +94 -0
  1200. package/docs/virtual-models.md +114 -0
  1201. package/docs/windows.md +109 -0
  1202. package/examples/README.md +36 -0
  1203. package/examples/extensions/README.md +212 -0
  1204. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  1205. package/examples/extensions/bash-spawn-hook.ts +30 -0
  1206. package/examples/extensions/bookmark.ts +50 -0
  1207. package/examples/extensions/border-status-editor.ts +150 -0
  1208. package/examples/extensions/built-in-tool-renderer.ts +230 -0
  1209. package/examples/extensions/claude-rules.ts +86 -0
  1210. package/examples/extensions/commands.ts +72 -0
  1211. package/examples/extensions/confirm-destructive.ts +59 -0
  1212. package/examples/extensions/cron/README.md +43 -0
  1213. package/examples/extensions/cron/index.ts +337 -0
  1214. package/examples/extensions/custom-compaction.ts +117 -0
  1215. package/examples/extensions/custom-footer.ts +64 -0
  1216. package/examples/extensions/custom-header.ts +73 -0
  1217. package/examples/extensions/custom-provider-anthropic/index.ts +613 -0
  1218. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  1219. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  1220. package/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
  1221. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  1222. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  1223. package/examples/extensions/debug-provider.ts +90 -0
  1224. package/examples/extensions/dirty-repo-guard.ts +56 -0
  1225. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  1226. package/examples/extensions/dynamic-resources/dynamic.json +81 -0
  1227. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  1228. package/examples/extensions/dynamic-resources/index.ts +15 -0
  1229. package/examples/extensions/dynamic-tools.ts +74 -0
  1230. package/examples/extensions/entry-renderer.ts +41 -0
  1231. package/examples/extensions/event-bus.ts +43 -0
  1232. package/examples/extensions/file-trigger.ts +41 -0
  1233. package/examples/extensions/git-checkpoint.ts +53 -0
  1234. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  1235. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  1236. package/examples/extensions/handoff.ts +190 -0
  1237. package/examples/extensions/hello.ts +26 -0
  1238. package/examples/extensions/hidden-thinking-label.ts +53 -0
  1239. package/examples/extensions/inline-bash.ts +94 -0
  1240. package/examples/extensions/input-transform-streaming.ts +39 -0
  1241. package/examples/extensions/input-transform.ts +43 -0
  1242. package/examples/extensions/interactive-shell.ts +196 -0
  1243. package/examples/extensions/jev-router.ts +113 -0
  1244. package/examples/extensions/mac-system-theme.ts +47 -0
  1245. package/examples/extensions/message-renderer.ts +59 -0
  1246. package/examples/extensions/minimal-mode.ts +353 -0
  1247. package/examples/extensions/modal-editor.ts +85 -0
  1248. package/examples/extensions/model-status.ts +31 -0
  1249. package/examples/extensions/notify.ts +57 -0
  1250. package/examples/extensions/overlay-qa-tests.ts +1456 -0
  1251. package/examples/extensions/overlay-test.ts +165 -0
  1252. package/examples/extensions/permission-gate.ts +34 -0
  1253. package/examples/extensions/pirate.ts +47 -0
  1254. package/examples/extensions/plan-mode/README.md +66 -0
  1255. package/examples/extensions/plan-mode/index.ts +404 -0
  1256. package/examples/extensions/plan-mode/utils.ts +194 -0
  1257. package/examples/extensions/preset.ts +438 -0
  1258. package/examples/extensions/project-trust.ts +64 -0
  1259. package/examples/extensions/prompt-customizer.ts +49 -0
  1260. package/examples/extensions/protected-paths.ts +30 -0
  1261. package/examples/extensions/provider-payload.ts +18 -0
  1262. package/examples/extensions/qna.ts +118 -0
  1263. package/examples/extensions/question.ts +286 -0
  1264. package/examples/extensions/questionnaire.ts +448 -0
  1265. package/examples/extensions/rainbow-editor.ts +88 -0
  1266. package/examples/extensions/reload-runtime.ts +49 -0
  1267. package/examples/extensions/rpc-demo.ts +118 -0
  1268. package/examples/extensions/send-user-message.ts +97 -0
  1269. package/examples/extensions/session-name.ts +27 -0
  1270. package/examples/extensions/shutdown-command.ts +63 -0
  1271. package/examples/extensions/skill/README.md +37 -0
  1272. package/examples/extensions/skill/index.ts +70 -0
  1273. package/examples/extensions/snake.ts +343 -0
  1274. package/examples/extensions/space-invaders.ts +560 -0
  1275. package/examples/extensions/ssh.ts +220 -0
  1276. package/examples/extensions/status-line.ts +32 -0
  1277. package/examples/extensions/structured-output.ts +65 -0
  1278. package/examples/extensions/subagent/README.md +238 -0
  1279. package/examples/extensions/subagent/agents/debugger.md +32 -0
  1280. package/examples/extensions/subagent/agents/init.md +40 -0
  1281. package/examples/extensions/subagent/agents/memory.md +32 -0
  1282. package/examples/extensions/subagent/agents/planner.md +37 -0
  1283. package/examples/extensions/subagent/agents/recall.md +33 -0
  1284. package/examples/extensions/subagent/agents/reflection.md +39 -0
  1285. package/examples/extensions/subagent/agents/researcher.md +28 -0
  1286. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  1287. package/examples/extensions/subagent/agents/scout.md +50 -0
  1288. package/examples/extensions/subagent/agents/tester.md +31 -0
  1289. package/examples/extensions/subagent/agents/worker.md +24 -0
  1290. package/examples/extensions/subagent/agents.ts +157 -0
  1291. package/examples/extensions/subagent/index.ts +1788 -0
  1292. package/examples/extensions/subagent/prompts/debug.md +10 -0
  1293. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  1294. package/examples/extensions/subagent/prompts/implement.md +10 -0
  1295. package/examples/extensions/subagent/prompts/reflect.md +9 -0
  1296. package/examples/extensions/subagent/prompts/research-and-plan.md +9 -0
  1297. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  1298. package/examples/extensions/summarize.ts +199 -0
  1299. package/examples/extensions/system-prompt-header.ts +17 -0
  1300. package/examples/extensions/tic-tac-toe.ts +1008 -0
  1301. package/examples/extensions/timed-confirm.ts +70 -0
  1302. package/examples/extensions/titlebar-spinner.ts +58 -0
  1303. package/examples/extensions/todo.ts +304 -0
  1304. package/examples/extensions/tool-override.ts +144 -0
  1305. package/examples/extensions/tools.ts +148 -0
  1306. package/examples/extensions/trigger-compact.ts +50 -0
  1307. package/examples/extensions/truncated-tool.ts +195 -0
  1308. package/examples/extensions/widget-placement.ts +9 -0
  1309. package/examples/extensions/with-deps/index.ts +32 -0
  1310. package/examples/extensions/with-deps/package-lock.json +31 -0
  1311. package/examples/extensions/with-deps/package.json +22 -0
  1312. package/examples/extensions/working-indicator.ts +123 -0
  1313. package/examples/extensions/working-message-test.ts +25 -0
  1314. package/examples/rpc-client.ts +35 -0
  1315. package/examples/rpc-extension-ui.ts +662 -0
  1316. package/examples/sdk/01-minimal.ts +26 -0
  1317. package/examples/sdk/02-custom-model.ts +49 -0
  1318. package/examples/sdk/03-custom-prompt.ts +75 -0
  1319. package/examples/sdk/04-skills.ts +55 -0
  1320. package/examples/sdk/05-tools.ts +48 -0
  1321. package/examples/sdk/06-extensions.ts +99 -0
  1322. package/examples/sdk/07-context-files.ts +47 -0
  1323. package/examples/sdk/08-prompt-templates.ts +51 -0
  1324. package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  1325. package/examples/sdk/10-settings.ts +53 -0
  1326. package/examples/sdk/11-sessions.ts +52 -0
  1327. package/examples/sdk/12-full-control.ts +74 -0
  1328. package/examples/sdk/13-session-runtime.ts +67 -0
  1329. package/examples/sdk/14-codemode-mcp.ts +61 -0
  1330. package/examples/sdk/README.md +141 -0
  1331. package/examples/tsconfig.json +110 -0
  1332. package/package.json +98 -5
  1333. package/schemas/keybindings.schema.json +393 -0
  1334. package/schemas/mcp.schema.json +306 -0
  1335. package/schemas/models.schema.json +1253 -0
  1336. package/schemas/settings.schema.json +1658 -0
  1337. package/schemas/theme.schema.json +365 -0
@@ -0,0 +1,1788 @@
1
+ /**
2
+ * Subagent Tool - Delegate tasks to specialized agents
3
+ *
4
+ * Spawns a separate `pigeon` process for each subagent invocation,
5
+ * giving it an isolated context window.
6
+ *
7
+ * Supports six modes:
8
+ * - Single: { agent: "name", task: "..." }
9
+ * - Parallel: { tasks: [{ agent: "name", task: "..." }, ...] }
10
+ * - Chain: { chain: [{ agent: "name", task: "... {previous} ..." }, ...] }
11
+ * - Background: { background: { agent: "name", task: "..." } } (returns at once; poll with status)
12
+ * - Status: { status: { subagentId: "..." } } (report on a background subagent)
13
+ * - Stop: { stop: { subagentId: "..." } } (abort a background subagent)
14
+ *
15
+ * Uses JSON mode to capture structured output from subagents.
16
+ * Nesting is capped at MAX_SUBAGENT_DEPTH via the PIGEON_SUBAGENT_DEPTH env var:
17
+ * a child at the cap has no subagent tool, so it cannot spawn further children.
18
+ */
19
+
20
+ import { spawn } from "node:child_process";
21
+ import { randomUUID } from "node:crypto";
22
+ import * as fs from "node:fs";
23
+ import * as os from "node:os";
24
+ import * as path from "node:path";
25
+ import type { AgentToolResult, ThinkingLevel } from "@dev-crowagent/pigeon-agent-core";
26
+ import { runSubagentStopHooks } from "@dev-crowagent/pigeon-agent-kit";
27
+ import type { Message } from "@dev-crowagent/pigeon-ai";
28
+ import { StringEnum } from "@dev-crowagent/pigeon-ai";
29
+ import {
30
+ CONFIG_DIR_NAME,
31
+ DEFAULT_MAX_BYTES,
32
+ DEFAULT_MAX_LINES,
33
+ type ExtensionAPI,
34
+ formatReadLineRange,
35
+ getAgentDir,
36
+ getMarkdownTheme,
37
+ type JsonAgentSessionEvent,
38
+ truncateHead,
39
+ withFileMutationQueue,
40
+ } from "@dev-crowagent/pigeon-coding-agent";
41
+ import { Container, Markdown, Spacer, Text } from "@dev-crowagent/pigeon-tui";
42
+ import { Type } from "typebox";
43
+ import { type AgentConfig, type AgentScope, discoverAgents } from "./agents.ts";
44
+
45
+ const MAX_PARALLEL_TASKS = 8;
46
+ const MAX_CONCURRENCY = 4;
47
+ const COLLAPSED_ITEM_COUNT = 10;
48
+ const PER_TASK_OUTPUT_CAP = 50 * 1024;
49
+ const TRUNCATION_NOTICE_RESERVE = 256;
50
+
51
+ // A subagent child runs with PIGEON_SUBAGENT_DEPTH set one higher than its parent.
52
+ // At MAX_SUBAGENT_DEPTH the extension registers no tool, so nesting stops there.
53
+ const MAX_SUBAGENT_DEPTH = 2;
54
+ const SUBAGENT_DEPTH_ENV = "PIGEON_SUBAGENT_DEPTH";
55
+ const ABORT_KILL_DELAY_MS = 5000;
56
+
57
+ function getSubagentDepth(): number {
58
+ const raw = process.env[SUBAGENT_DEPTH_ENV];
59
+ if (!raw) return 0;
60
+ const parsed = Number.parseInt(raw, 10);
61
+ return Number.isNaN(parsed) || parsed < 0 ? 0 : parsed;
62
+ }
63
+
64
+ function formatTokens(count: number): string {
65
+ if (count < 1000) return count.toString();
66
+ if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
67
+ if (count < 1000000) return `${Math.round(count / 1000)}k`;
68
+ return `${(count / 1000000).toFixed(1)}M`;
69
+ }
70
+
71
+ function formatUsageStats(
72
+ usage: {
73
+ input: number;
74
+ output: number;
75
+ cacheRead: number;
76
+ cacheWrite: number;
77
+ cost: number;
78
+ contextTokens?: number;
79
+ turns?: number;
80
+ },
81
+ model?: string,
82
+ ): string {
83
+ const parts: string[] = [];
84
+ if (usage.turns) parts.push(`${usage.turns} turn${usage.turns > 1 ? "s" : ""}`);
85
+ if (usage.input) parts.push(`↑${formatTokens(usage.input)}`);
86
+ if (usage.output) parts.push(`↓${formatTokens(usage.output)}`);
87
+ if (usage.cacheRead) parts.push(`R${formatTokens(usage.cacheRead)}`);
88
+ if (usage.cacheWrite) parts.push(`W${formatTokens(usage.cacheWrite)}`);
89
+ if (usage.cost) parts.push(`$${usage.cost.toFixed(4)}`);
90
+ if (usage.contextTokens && usage.contextTokens > 0) {
91
+ parts.push(`ctx:${formatTokens(usage.contextTokens)}`);
92
+ }
93
+ if (model) parts.push(model);
94
+ return parts.join(" ");
95
+ }
96
+
97
+ function formatToolCall(
98
+ toolName: string,
99
+ args: Record<string, unknown>,
100
+ themeFg: (color: any, text: string) => string,
101
+ ): string {
102
+ const shortenPath = (p: string) => {
103
+ const home = os.homedir();
104
+ return p.startsWith(home) ? `~${p.slice(home.length)}` : p;
105
+ };
106
+
107
+ switch (toolName) {
108
+ case "bash": {
109
+ const command = (args.command as string) || "...";
110
+ const preview = command.length > 60 ? `${command.slice(0, 60)}...` : command;
111
+ return themeFg("muted", "$ ") + themeFg("toolOutput", preview);
112
+ }
113
+ case "read": {
114
+ const rawPath = (args.file_path || args.path || "...") as string;
115
+ const filePath = shortenPath(rawPath);
116
+ const lineRange = formatReadLineRange(args.offset, args.limit);
117
+ let text = themeFg("accent", filePath);
118
+ if (lineRange) {
119
+ text += themeFg("warning", lineRange);
120
+ }
121
+ return themeFg("muted", "read ") + text;
122
+ }
123
+ case "write": {
124
+ const rawPath = (args.file_path || args.path || "...") as string;
125
+ const filePath = shortenPath(rawPath);
126
+ const content = (args.content || "") as string;
127
+ const lines = content.split("\n").length;
128
+ let text = themeFg("muted", "write ") + themeFg("accent", filePath);
129
+ if (lines > 1) text += themeFg("dim", ` (${lines} lines)`);
130
+ return text;
131
+ }
132
+ case "edit": {
133
+ const rawPath = (args.file_path || args.path || "...") as string;
134
+ return themeFg("muted", "edit ") + themeFg("accent", shortenPath(rawPath));
135
+ }
136
+ case "ls": {
137
+ const rawPath = (args.path || ".") as string;
138
+ return themeFg("muted", "ls ") + themeFg("accent", shortenPath(rawPath));
139
+ }
140
+ case "find": {
141
+ const pattern = (args.pattern || "*") as string;
142
+ const rawPath = (args.path || ".") as string;
143
+ return themeFg("muted", "find ") + themeFg("accent", pattern) + themeFg("dim", ` in ${shortenPath(rawPath)}`);
144
+ }
145
+ case "grep": {
146
+ const pattern = (args.pattern || "") as string;
147
+ const rawPath = (args.path || ".") as string;
148
+ return (
149
+ themeFg("muted", "grep ") +
150
+ themeFg("accent", `/${pattern}/`) +
151
+ themeFg("dim", ` in ${shortenPath(rawPath)}`)
152
+ );
153
+ }
154
+ default: {
155
+ const argsStr = JSON.stringify(args);
156
+ const preview = argsStr.length > 50 ? `${argsStr.slice(0, 50)}...` : argsStr;
157
+ return themeFg("accent", toolName) + themeFg("dim", ` ${preview}`);
158
+ }
159
+ }
160
+ }
161
+
162
+ interface UsageStats {
163
+ input: number;
164
+ output: number;
165
+ cacheRead: number;
166
+ cacheWrite: number;
167
+ cost: number;
168
+ contextTokens: number;
169
+ turns: number;
170
+ }
171
+
172
+ type ChildStatus = "pending" | "running" | "completed" | "failed" | "aborted";
173
+
174
+ interface SingleResult {
175
+ agent: string;
176
+ agentSource: "user" | "project" | "unknown";
177
+ task: string;
178
+ status: ChildStatus;
179
+ exitCode: number | null;
180
+ messages: Message[];
181
+ stderr: string;
182
+ usage: UsageStats;
183
+ model?: string;
184
+ stopReason?: string;
185
+ errorMessage?: string;
186
+ terminationSignal?: NodeJS.Signals;
187
+ step?: number;
188
+ }
189
+
190
+ interface SubagentDetails {
191
+ mode: "single" | "parallel" | "chain" | "background" | "status" | "stop";
192
+ results: SingleResult[];
193
+ isError: boolean;
194
+ }
195
+
196
+ function getFinalOutput(messages: Message[]): string {
197
+ for (let i = messages.length - 1; i >= 0; i--) {
198
+ const msg = messages[i];
199
+ if (msg.role === "assistant") {
200
+ for (const part of msg.content) {
201
+ if (part.type === "text") return part.text;
202
+ }
203
+ }
204
+ }
205
+ return "";
206
+ }
207
+
208
+ function isFailedResult(result: SingleResult): boolean {
209
+ return result.status === "failed" || result.status === "aborted";
210
+ }
211
+
212
+ function isRefusalLike(text: string | undefined): boolean {
213
+ if (!text) return false;
214
+ return /refus|usage polic|I can't help with that|I cannot help with that|cannot complete this|declined to/i.test(
215
+ text,
216
+ );
217
+ }
218
+
219
+ function getFailureEvidence(result: SingleResult): string {
220
+ const evidence: string[] = [];
221
+ const seen = new Set<string>();
222
+ const add = (label: string, value: string | undefined) => {
223
+ const text = value?.trim();
224
+ if (!text || seen.has(text)) return;
225
+ seen.add(text);
226
+ evidence.push(`${label}: ${text}`);
227
+ };
228
+
229
+ add("Error", result.errorMessage);
230
+ add("Signal", result.terminationSignal);
231
+ add("stderr", result.stderr);
232
+ add("Assistant output", getFinalOutput(result.messages));
233
+ if (isRefusalLike(result.errorMessage) || isRefusalLike(getFinalOutput(result.messages))) {
234
+ evidence.push(
235
+ "Guidance: the subagent refused the brief. Reword the task, do it directly, or try another model. Do not ask the user about it.",
236
+ );
237
+ }
238
+ return evidence.join("\n\n") || "(no output)";
239
+ }
240
+
241
+ function getFailureSummary(result: SingleResult): string {
242
+ return (
243
+ result.errorMessage?.trim() ||
244
+ (result.terminationSignal ? `Terminated by signal ${result.terminationSignal}` : "") ||
245
+ result.stderr.trim() ||
246
+ getFinalOutput(result.messages) ||
247
+ "(no output)"
248
+ );
249
+ }
250
+
251
+ function getResultOutput(result: SingleResult): string {
252
+ return isFailedResult(result) ? getFailureEvidence(result) : getFinalOutput(result.messages) || "(no output)";
253
+ }
254
+
255
+ // Applies one JSON-mode stdout line to a result. Returns true when the line was
256
+ // a message_end event for a message the parent keeps. Shared by foreground and
257
+ // background children so both read the same stream the same way.
258
+ function applySessionEventLine(line: string, result: SingleResult): boolean {
259
+ if (!line.trim()) return false;
260
+ let event: JsonAgentSessionEvent;
261
+ try {
262
+ event = JSON.parse(line) as JsonAgentSessionEvent;
263
+ } catch {
264
+ return false;
265
+ }
266
+ if (event.type !== "message_end") return false;
267
+ const eventMessage = event.message;
268
+ if (eventMessage.role !== "user" && eventMessage.role !== "assistant" && eventMessage.role !== "toolResult") {
269
+ return false;
270
+ }
271
+ const message = eventMessage as Message;
272
+ result.messages.push(message);
273
+ if (message.role === "assistant") {
274
+ result.usage.turns++;
275
+ result.usage.input += message.usage.input;
276
+ result.usage.output += message.usage.output;
277
+ result.usage.cacheRead += message.usage.cacheRead;
278
+ result.usage.cacheWrite += message.usage.cacheWrite;
279
+ result.usage.cost += message.usage.cost.total;
280
+ result.usage.contextTokens = message.usage.totalTokens;
281
+ if (!result.model) result.model = message.model;
282
+ result.stopReason = message.stopReason;
283
+ result.errorMessage = message.errorMessage;
284
+ }
285
+ return true;
286
+ }
287
+
288
+ function truncateParallelOutput(output: string): string {
289
+ const byteLength = Buffer.byteLength(output, "utf8");
290
+ if (byteLength <= PER_TASK_OUTPUT_CAP) return output;
291
+
292
+ let truncated = output.slice(0, PER_TASK_OUTPUT_CAP);
293
+ while (Buffer.byteLength(truncated, "utf8") > PER_TASK_OUTPUT_CAP) {
294
+ truncated = truncated.slice(0, -1);
295
+ }
296
+ return `${truncated}\n\n[Output truncated: ${byteLength - Buffer.byteLength(truncated, "utf8")} bytes omitted. Full output preserved in tool details.]`;
297
+ }
298
+
299
+ function truncateModelOutput(output: string): string {
300
+ const initial = truncateHead(output);
301
+ if (!initial.truncated) return output;
302
+
303
+ const body = truncateHead(output, {
304
+ maxLines: DEFAULT_MAX_LINES - 2,
305
+ maxBytes: DEFAULT_MAX_BYTES - TRUNCATION_NOTICE_RESERVE,
306
+ });
307
+ const omittedBytes = initial.totalBytes - body.outputBytes;
308
+ const notice = `[Output truncated: ${omittedBytes} bytes omitted. Full output preserved in tool details.]`;
309
+ return body.content ? `${body.content}\n\n${notice}` : notice;
310
+ }
311
+
312
+ type DisplayItem = { type: "text"; text: string } | { type: "toolCall"; name: string; args: Record<string, any> };
313
+
314
+ function getDisplayItems(messages: Message[]): DisplayItem[] {
315
+ const items: DisplayItem[] = [];
316
+ for (const msg of messages) {
317
+ if (msg.role === "assistant") {
318
+ for (const part of msg.content) {
319
+ if (part.type === "text") items.push({ type: "text", text: part.text });
320
+ else if (part.type === "toolCall") items.push({ type: "toolCall", name: part.name, args: part.arguments });
321
+ }
322
+ }
323
+ }
324
+ return items;
325
+ }
326
+
327
+ async function mapWithConcurrencyLimit<TIn, TOut>(
328
+ items: TIn[],
329
+ concurrency: number,
330
+ fn: (item: TIn, index: number) => Promise<TOut>,
331
+ ): Promise<TOut[]> {
332
+ if (items.length === 0) return [];
333
+ const limit = Math.max(1, Math.min(concurrency, items.length));
334
+ const results: TOut[] = new Array(items.length);
335
+ let nextIndex = 0;
336
+ const workers = new Array(limit).fill(null).map(async () => {
337
+ while (true) {
338
+ const current = nextIndex++;
339
+ if (current >= items.length) return;
340
+ results[current] = await fn(items[current], current);
341
+ }
342
+ });
343
+ await Promise.all(workers);
344
+ return results;
345
+ }
346
+
347
+ async function writePromptToTempFile(agentName: string, prompt: string): Promise<{ dir: string; filePath: string }> {
348
+ const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "pigeon-subagent-"));
349
+ const safeName = agentName.replace(/[^\w.-]+/g, "_");
350
+ const filePath = path.join(tmpDir, `prompt-${safeName}.md`);
351
+ await withFileMutationQueue(filePath, async () => {
352
+ await fs.promises.writeFile(filePath, prompt, { encoding: "utf-8", mode: 0o600 });
353
+ });
354
+ return { dir: tmpDir, filePath };
355
+ }
356
+
357
+ function getPigeonInvocation(args: string[]): { command: string; args: string[] } {
358
+ const currentScript = process.argv[1];
359
+ // Bun-compiled binaries report their embedded entry as argv[1]: "/$bunfs/root/..." on
360
+ // POSIX and "B:/~BUN/root/..." on Windows. fs.existsSync() resolves these inside Bun.
361
+ const isBunVirtualScript =
362
+ currentScript !== undefined &&
363
+ (currentScript.startsWith("/$bunfs/root/") || /^[A-Za-z]:[\\/]~BUN[\\/]root[\\/]/.test(currentScript));
364
+ if (currentScript && !isBunVirtualScript && fs.existsSync(currentScript)) {
365
+ return { command: process.execPath, args: [currentScript, ...args] };
366
+ }
367
+
368
+ const execName = path.basename(process.execPath).toLowerCase();
369
+ const isGenericRuntime = /^(node|bun)(\.exe)?$/.test(execName);
370
+ if (!isGenericRuntime) {
371
+ return { command: process.execPath, args };
372
+ }
373
+
374
+ return { command: "pigeon", args };
375
+ }
376
+
377
+ type OnUpdateCallback = (partial: AgentToolResult<SubagentDetails>) => void;
378
+
379
+ interface DispatchDefaults {
380
+ model?: string;
381
+ thinkingLevel?: ThinkingLevel;
382
+ }
383
+
384
+ interface ProcessOutcome {
385
+ code: number | null;
386
+ signal: NodeJS.Signals | null;
387
+ spawnError?: Error;
388
+ }
389
+
390
+ interface ResolvedAgent {
391
+ agent?: AgentConfig;
392
+ available: AgentConfig[];
393
+ cwd: string;
394
+ }
395
+
396
+ function resolveAgent(defaultCwd: string, scope: AgentScope, name: string, cwd?: string): ResolvedAgent {
397
+ const effectiveCwd = path.resolve(defaultCwd, cwd ?? ".");
398
+ const discovery = discoverAgents(effectiveCwd, scope);
399
+ return {
400
+ agent: discovery.agents.find((candidate) => candidate.name === name),
401
+ available: discovery.agents,
402
+ cwd: effectiveCwd,
403
+ };
404
+ }
405
+
406
+ function createUnstartedResult(
407
+ agent: string,
408
+ task: string,
409
+ step: number | undefined,
410
+ status: "aborted" | "failed",
411
+ errorMessage?: string,
412
+ ): SingleResult {
413
+ return {
414
+ agent,
415
+ agentSource: "unknown",
416
+ task,
417
+ status,
418
+ exitCode: null,
419
+ messages: [],
420
+ stderr: "",
421
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
422
+ errorMessage,
423
+ step,
424
+ };
425
+ }
426
+
427
+ async function runSingleAgent(
428
+ dispatchDefaults: DispatchDefaults,
429
+ resolvedAgent: ResolvedAgent,
430
+ agentName: string,
431
+ task: string,
432
+ step: number | undefined,
433
+ signal: AbortSignal | undefined,
434
+ onUpdate: OnUpdateCallback | undefined,
435
+ makeDetails: (results: SingleResult[]) => SubagentDetails,
436
+ ): Promise<SingleResult> {
437
+ if (signal?.aborted) {
438
+ return createUnstartedResult(agentName, task, step, "aborted", "Subagent was aborted before starting");
439
+ }
440
+
441
+ const effectiveCwd = resolvedAgent.cwd;
442
+ const subagentId = randomUUID();
443
+ const agent = resolvedAgent.agent;
444
+ if (!agent) {
445
+ const available = resolvedAgent.available.map((candidate) => `"${candidate.name}"`).join(", ") || "none";
446
+ return createUnstartedResult(
447
+ agentName,
448
+ task,
449
+ step,
450
+ "failed",
451
+ `Unknown agent: "${agentName}". Available agents: ${available}.`,
452
+ );
453
+ }
454
+
455
+ const args: string[] = ["--mode", "json", "-p", "--no-session"];
456
+ const inheritsDispatchConfig = !agent.model;
457
+ const model = agent.model ?? dispatchDefaults.model;
458
+ if (model) args.push("--model", model);
459
+ if (inheritsDispatchConfig && dispatchDefaults.thinkingLevel) {
460
+ args.push("--thinking", dispatchDefaults.thinkingLevel);
461
+ }
462
+ if (agent.tools && agent.tools.length > 0) args.push("--tools", agent.tools.join(","));
463
+
464
+ let tmpPromptDir: string | null = null;
465
+ let tmpPromptPath: string | null = null;
466
+ const currentResult: SingleResult = {
467
+ agent: agentName,
468
+ agentSource: agent.source,
469
+ task,
470
+ status: "running",
471
+ exitCode: null,
472
+ messages: [],
473
+ stderr: "",
474
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
475
+ model,
476
+ step,
477
+ };
478
+
479
+ const emitUpdate = () => {
480
+ onUpdate?.({
481
+ content: [{ type: "text", text: getFinalOutput(currentResult.messages) || "(running...)" }],
482
+ details: makeDetails([currentResult]),
483
+ });
484
+ };
485
+
486
+ try {
487
+ if (agent.systemPrompt.trim()) {
488
+ const tmp = await writePromptToTempFile(agent.name, agent.systemPrompt);
489
+ tmpPromptDir = tmp.dir;
490
+ tmpPromptPath = tmp.filePath;
491
+ args.push("--append-system-prompt", tmpPromptPath);
492
+ }
493
+
494
+ if (signal?.aborted) {
495
+ currentResult.status = "aborted";
496
+ currentResult.errorMessage = "Subagent was aborted before starting";
497
+ return currentResult;
498
+ }
499
+
500
+ args.push(`Task: ${task}`);
501
+ emitUpdate();
502
+ let wasAborted = false;
503
+ const outcome = await new Promise<ProcessOutcome>((resolve) => {
504
+ const invocation = getPigeonInvocation(args);
505
+ let settled = false;
506
+ let exited = false;
507
+ let closed = false;
508
+ let killTimer: ReturnType<typeof setTimeout> | undefined;
509
+ let buffer = "";
510
+
511
+ const processLine = (line: string) => {
512
+ if (applySessionEventLine(line, currentResult)) emitUpdate();
513
+ };
514
+
515
+ let proc: ReturnType<typeof spawn>;
516
+ const finish = (result: ProcessOutcome) => {
517
+ if (settled) return;
518
+ settled = true;
519
+ closed = true;
520
+ if (killTimer) clearTimeout(killTimer);
521
+ if (signal) signal.removeEventListener("abort", abortProcess);
522
+ resolve(result);
523
+ };
524
+ const abortProcess = () => {
525
+ if (closed || exited || proc.exitCode !== null || proc.signalCode !== null) return;
526
+ if (!proc.kill("SIGTERM")) return;
527
+ wasAborted = true;
528
+ killTimer = setTimeout(() => {
529
+ if (!closed && !exited) proc.kill("SIGKILL");
530
+ }, ABORT_KILL_DELAY_MS);
531
+ };
532
+
533
+ try {
534
+ proc = spawn(invocation.command, invocation.args, {
535
+ cwd: effectiveCwd,
536
+ shell: false,
537
+ stdio: ["ignore", "pipe", "pipe"],
538
+ env: { ...process.env, [SUBAGENT_DEPTH_ENV]: String(getSubagentDepth() + 1) },
539
+ });
540
+ } catch (error) {
541
+ finish({
542
+ code: null,
543
+ signal: null,
544
+ spawnError: error instanceof Error ? error : new Error(String(error)),
545
+ });
546
+ return;
547
+ }
548
+
549
+ proc.stdout?.on("data", (data) => {
550
+ // Split only the new text, so a long line arriving in many chunks is not rescanned per chunk.
551
+ const lines = data.toString().split("\n");
552
+ lines[0] = buffer + lines[0];
553
+ buffer = lines.pop() || "";
554
+ for (const line of lines) processLine(line);
555
+ });
556
+ proc.stderr?.on("data", (data) => {
557
+ currentResult.stderr += data.toString();
558
+ });
559
+ proc.on("exit", () => {
560
+ exited = true;
561
+ });
562
+ proc.on("close", (code, terminationSignal) => {
563
+ if (buffer.trim()) processLine(buffer);
564
+ finish({ code, signal: terminationSignal });
565
+ });
566
+ proc.on("error", (error) => {
567
+ finish({ code: null, signal: null, spawnError: error });
568
+ });
569
+
570
+ if (signal) {
571
+ if (signal.aborted) abortProcess();
572
+ else signal.addEventListener("abort", abortProcess, { once: true });
573
+ }
574
+ });
575
+
576
+ currentResult.exitCode = outcome.code;
577
+ currentResult.terminationSignal = outcome.signal ?? undefined;
578
+
579
+ if (wasAborted) {
580
+ currentResult.status = "aborted";
581
+ currentResult.errorMessage ||= "Subagent was aborted";
582
+ } else if (outcome.spawnError) {
583
+ currentResult.status = "failed";
584
+ currentResult.errorMessage = `Failed to spawn subagent: ${outcome.spawnError.message}`;
585
+ } else if (outcome.signal) {
586
+ currentResult.status = "failed";
587
+ currentResult.errorMessage ||= `Subagent terminated by signal ${outcome.signal}`;
588
+ } else if (outcome.code !== 0) {
589
+ currentResult.status = "failed";
590
+ currentResult.errorMessage ||= `Subagent exited with code ${outcome.code}`;
591
+ } else if (currentResult.stopReason === "aborted") {
592
+ currentResult.status = "aborted";
593
+ } else if (currentResult.stopReason === "error") {
594
+ currentResult.status = "failed";
595
+ } else {
596
+ currentResult.status = "completed";
597
+ }
598
+ await fireSubagentStopHooks(
599
+ agentName,
600
+ subagentId,
601
+ currentResult.status === "completed",
602
+ currentResult.errorMessage,
603
+ effectiveCwd,
604
+ );
605
+ return currentResult;
606
+ } finally {
607
+ if (tmpPromptPath) {
608
+ try {
609
+ fs.unlinkSync(tmpPromptPath);
610
+ } catch {
611
+ /* ignore */
612
+ }
613
+ }
614
+ if (tmpPromptDir) {
615
+ try {
616
+ fs.rmdirSync(tmpPromptDir);
617
+ } catch {
618
+ /* ignore */
619
+ }
620
+ }
621
+ }
622
+ }
623
+
624
+ interface BackgroundTaskRecord {
625
+ id: string;
626
+ agent: string;
627
+ agentSource: "user" | "project" | "unknown";
628
+ task: string;
629
+ cwd: string;
630
+ status: ChildStatus;
631
+ startedAt: string;
632
+ pid: number | null;
633
+ logPath: string;
634
+ stderrPath: string;
635
+ exitCode: number | null;
636
+ terminationSignal?: NodeJS.Signals;
637
+ errorMessage?: string;
638
+ finalOutput: string;
639
+ usage: UsageStats;
640
+ model?: string;
641
+ stopReason?: string;
642
+ }
643
+
644
+ // Live children, for stop support. The record on disk is the source of truth
645
+ // for status; this map only lets the parent signal a child it still holds.
646
+ const backgroundChildren = new Map<number, ReturnType<typeof spawn>>();
647
+ // Ids stopped on purpose, so the close handler reports them aborted rather
648
+ // than failed when the child exits on SIGTERM.
649
+ const backgroundStopped = new Set<string>();
650
+ // Background subagent ids whose SubagentStop hooks already ran, so a finished
651
+ // record observed by repeated status polls fires its hooks exactly once.
652
+ const subagentStopHooksFired = new Set<string>();
653
+
654
+ // Runs the SubagentStop hooks for one finished child. No-ops when no hooks
655
+ // are configured for the event. Prompt hooks have no model call here, so they
656
+ // report an error result, like any prompt hook without a generate function.
657
+ async function fireSubagentStopHooks(
658
+ agentName: string,
659
+ subagentId: string,
660
+ success: boolean,
661
+ error: string | undefined,
662
+ cwd: string,
663
+ ): Promise<void> {
664
+ try {
665
+ await runSubagentStopHooks(agentName, subagentId, success, error, undefined, undefined, cwd, {
666
+ dirs: { userDir: getAgentDir(), projectDir: path.join(cwd, CONFIG_DIR_NAME) },
667
+ });
668
+ } catch {
669
+ // Hook failures never fail the subagent result.
670
+ }
671
+ }
672
+
673
+ function getBackgroundDir(): string {
674
+ return path.join(getAgentDir(), "subagents");
675
+ }
676
+
677
+ function getBackgroundRecordPath(id: string): string {
678
+ return path.join(getBackgroundDir(), `${id}.json`);
679
+ }
680
+
681
+ function getBackgroundLogPath(id: string): string {
682
+ return path.join(getBackgroundDir(), `${id}.jsonl`);
683
+ }
684
+
685
+ function getBackgroundStderrPath(id: string): string {
686
+ return path.join(getBackgroundDir(), `${id}.stderr.txt`);
687
+ }
688
+
689
+ function writeBackgroundRecord(record: BackgroundTaskRecord): void {
690
+ fs.mkdirSync(getBackgroundDir(), { recursive: true });
691
+ fs.writeFileSync(getBackgroundRecordPath(record.id), `${JSON.stringify(record, null, 2)}\n`, "utf8");
692
+ }
693
+
694
+ function readBackgroundRecord(id: string): BackgroundTaskRecord | undefined {
695
+ try {
696
+ const parsed: unknown = JSON.parse(fs.readFileSync(getBackgroundRecordPath(id), "utf8"));
697
+ if (typeof parsed !== "object" || parsed === null) return undefined;
698
+ const record = parsed as BackgroundTaskRecord;
699
+ if (record.id !== id) return undefined;
700
+ return record;
701
+ } catch {
702
+ return undefined;
703
+ }
704
+ }
705
+
706
+ function isPidAlive(pid: number): boolean {
707
+ try {
708
+ process.kill(pid, 0);
709
+ return true;
710
+ } catch {
711
+ return false;
712
+ }
713
+ }
714
+
715
+ function recordToResult(record: BackgroundTaskRecord): SingleResult {
716
+ return {
717
+ agent: record.agent,
718
+ agentSource: record.agentSource,
719
+ task: record.task,
720
+ status: record.status,
721
+ exitCode: record.exitCode,
722
+ messages: [],
723
+ stderr: "",
724
+ usage: record.usage,
725
+ model: record.model,
726
+ stopReason: record.stopReason,
727
+ errorMessage: record.errorMessage,
728
+ terminationSignal: record.terminationSignal,
729
+ };
730
+ }
731
+
732
+ type BackgroundStart =
733
+ | { kind: "started"; id: string; logPath: string; result: SingleResult }
734
+ | { kind: "error"; error: string };
735
+
736
+ // Spawns a child that keeps running after this tool call returns. Its JSON-mode
737
+ // stdout is appended to a log file under the agent dir and its outcome is kept
738
+ // in a record file, so the status mode can report on it in a later turn. The
739
+ // parent turn ending does not stop it; only the stop mode (or the child
740
+ // finishing) does.
741
+ async function startBackgroundAgent(
742
+ dispatchDefaults: DispatchDefaults,
743
+ resolvedAgent: ResolvedAgent,
744
+ agentName: string,
745
+ task: string,
746
+ ): Promise<BackgroundStart> {
747
+ const effectiveCwd = resolvedAgent.cwd;
748
+ const agent = resolvedAgent.agent;
749
+ if (!agent) {
750
+ const available = resolvedAgent.available.map((candidate) => `"${candidate.name}"`).join(", ") || "none";
751
+ return { kind: "error", error: `Unknown agent: "${agentName}". Available agents: ${available}.` };
752
+ }
753
+
754
+ const id = randomUUID();
755
+ const logPath = getBackgroundLogPath(id);
756
+ const stderrPath = getBackgroundStderrPath(id);
757
+ const model = agent.model ?? dispatchDefaults.model;
758
+ const result: SingleResult = {
759
+ agent: agentName,
760
+ agentSource: agent.source,
761
+ task,
762
+ status: "running",
763
+ exitCode: null,
764
+ messages: [],
765
+ stderr: "",
766
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
767
+ model,
768
+ };
769
+ const record: BackgroundTaskRecord = {
770
+ id,
771
+ agent: agentName,
772
+ agentSource: agent.source,
773
+ task,
774
+ cwd: effectiveCwd,
775
+ status: "running",
776
+ startedAt: new Date().toISOString(),
777
+ pid: null,
778
+ logPath,
779
+ stderrPath,
780
+ exitCode: null,
781
+ finalOutput: "",
782
+ usage: result.usage,
783
+ model,
784
+ };
785
+
786
+ // The system prompt file must outlive this call: the child reads it after we return.
787
+ let promptPath: string | undefined;
788
+ try {
789
+ fs.mkdirSync(getBackgroundDir(), { recursive: true });
790
+ fs.writeFileSync(logPath, "", "utf8");
791
+ fs.writeFileSync(stderrPath, "", "utf8");
792
+ if (agent.systemPrompt.trim()) {
793
+ promptPath = path.join(getBackgroundDir(), `${id}-prompt.md`);
794
+ await withFileMutationQueue(promptPath, async () => {
795
+ await fs.promises.writeFile(promptPath as string, agent.systemPrompt, { encoding: "utf-8", mode: 0o600 });
796
+ });
797
+ }
798
+ } catch (error) {
799
+ return {
800
+ kind: "error",
801
+ error: `Failed to prepare background subagent: ${error instanceof Error ? error.message : String(error)}`,
802
+ };
803
+ }
804
+
805
+ const args: string[] = ["--mode", "json", "-p", "--no-session"];
806
+ if (model) args.push("--model", model);
807
+ if (!agent.model && dispatchDefaults.thinkingLevel) args.push("--thinking", dispatchDefaults.thinkingLevel);
808
+ if (agent.tools && agent.tools.length > 0) args.push("--tools", agent.tools.join(","));
809
+ if (promptPath) args.push("--append-system-prompt", promptPath);
810
+ args.push(`Task: ${task}`);
811
+
812
+ let proc: ReturnType<typeof spawn>;
813
+ try {
814
+ const invocation = getPigeonInvocation(args);
815
+ proc = spawn(invocation.command, invocation.args, {
816
+ cwd: effectiveCwd,
817
+ shell: false,
818
+ stdio: ["ignore", "pipe", "pipe"],
819
+ env: { ...process.env, [SUBAGENT_DEPTH_ENV]: String(getSubagentDepth() + 1) },
820
+ });
821
+ } catch (error) {
822
+ if (promptPath) {
823
+ try {
824
+ fs.unlinkSync(promptPath);
825
+ } catch {
826
+ /* ignore */
827
+ }
828
+ }
829
+ return {
830
+ kind: "error",
831
+ error: `Failed to spawn subagent: ${error instanceof Error ? error.message : String(error)}`,
832
+ };
833
+ }
834
+
835
+ record.pid = proc.pid ?? null;
836
+ writeBackgroundRecord(record);
837
+ if (proc.pid) backgroundChildren.set(proc.pid, proc);
838
+
839
+ let buffer = "";
840
+ proc.stdout?.on("data", (data) => {
841
+ const text = data.toString();
842
+ try {
843
+ fs.appendFileSync(logPath, text);
844
+ } catch {
845
+ /* the log is best-effort; the parsed result is the source of truth */
846
+ }
847
+ const lines = text.split("\n");
848
+ lines[0] = buffer + lines[0];
849
+ buffer = lines.pop() || "";
850
+ for (const line of lines) applySessionEventLine(line, result);
851
+ });
852
+ proc.stderr?.on("data", (data) => {
853
+ try {
854
+ fs.appendFileSync(stderrPath, data.toString());
855
+ } catch {
856
+ /* ignore */
857
+ }
858
+ });
859
+ proc.on("close", (code, terminationSignal) => {
860
+ if (buffer.trim()) applySessionEventLine(buffer, result);
861
+ if (proc.pid) backgroundChildren.delete(proc.pid);
862
+ try {
863
+ result.stderr = fs.readFileSync(stderrPath, "utf8");
864
+ } catch {
865
+ /* ignore */
866
+ }
867
+ result.exitCode = code;
868
+ result.terminationSignal = terminationSignal ?? undefined;
869
+ if (backgroundStopped.has(id)) {
870
+ result.status = "aborted";
871
+ result.errorMessage = "Subagent was stopped";
872
+ backgroundStopped.delete(id);
873
+ } else if (terminationSignal) {
874
+ result.status = "failed";
875
+ result.errorMessage ||= `Subagent terminated by signal ${terminationSignal}`;
876
+ } else if (code !== 0) {
877
+ result.status = "failed";
878
+ result.errorMessage ||= `Subagent exited with code ${code}`;
879
+ } else if (result.stopReason === "aborted") {
880
+ result.status = "aborted";
881
+ } else if (result.stopReason === "error") {
882
+ result.status = "failed";
883
+ } else {
884
+ result.status = "completed";
885
+ }
886
+ record.status = result.status;
887
+ record.exitCode = result.exitCode;
888
+ record.terminationSignal = result.terminationSignal;
889
+ record.errorMessage = result.errorMessage;
890
+ record.finalOutput = getFinalOutput(result.messages);
891
+ record.usage = result.usage;
892
+ record.model = result.model;
893
+ record.stopReason = result.stopReason;
894
+ writeBackgroundRecord(record);
895
+ if (promptPath) {
896
+ try {
897
+ fs.unlinkSync(promptPath);
898
+ } catch {
899
+ /* ignore */
900
+ }
901
+ }
902
+ });
903
+ proc.on("error", (error) => {
904
+ result.status = "failed";
905
+ result.errorMessage = `Failed to spawn subagent: ${error.message}`;
906
+ record.status = "failed";
907
+ record.errorMessage = result.errorMessage;
908
+ writeBackgroundRecord(record);
909
+ });
910
+
911
+ return { kind: "started", id, logPath, result };
912
+ }
913
+
914
+ function describeBackgroundRecord(record: BackgroundTaskRecord): string {
915
+ const lines = [
916
+ `Background subagent ${record.id} (${record.agent}): ${record.status}`,
917
+ `Task: ${record.task}`,
918
+ `Started: ${record.startedAt}`,
919
+ `Log: ${record.logPath}`,
920
+ ];
921
+ if (record.status === "running") {
922
+ lines.push("The subagent is still running. Check again later with the status mode.");
923
+ } else {
924
+ lines.push(`Final output:\n${truncateModelOutput(record.finalOutput || "(no output)")}`);
925
+ }
926
+ const usageStr = formatUsageStats(record.usage, record.model);
927
+ if (usageStr) lines.push(`Usage: ${usageStr}`);
928
+ if (record.errorMessage) lines.push(`Error: ${record.errorMessage}`);
929
+ return lines.join("\n\n");
930
+ }
931
+
932
+ // A record can say "running" with a dead pid when the parent went away while
933
+ // the child ran, so no close handler updated it. Recover what the log holds.
934
+ function refreshStaleBackgroundRecord(record: BackgroundTaskRecord): BackgroundTaskRecord {
935
+ if (record.status !== "running" || record.pid === null || isPidAlive(record.pid)) return record;
936
+ const recovered = recordToResult(record);
937
+ try {
938
+ for (const line of fs.readFileSync(record.logPath, "utf8").split("\n")) {
939
+ applySessionEventLine(line, recovered);
940
+ }
941
+ } catch {
942
+ /* the log is best-effort */
943
+ }
944
+ record.status = recovered.stopReason === "error" ? "failed" : "completed";
945
+ record.finalOutput = getFinalOutput(recovered.messages);
946
+ record.usage = recovered.usage;
947
+ record.model = recovered.model ?? record.model;
948
+ record.stopReason = recovered.stopReason;
949
+ record.errorMessage = "Background subagent ended while the parent was away; exit code is unknown.";
950
+ writeBackgroundRecord(record);
951
+ return record;
952
+ }
953
+
954
+ function stopBackgroundAgent(id: string): string {
955
+ const record = readBackgroundRecord(id);
956
+ if (!record) return `Unknown background subagent: "${id}".`;
957
+ if (record.status !== "running") return `Background subagent ${id} is already ${record.status}.`;
958
+ const proc = record.pid === null ? undefined : backgroundChildren.get(record.pid);
959
+ if (proc && proc.exitCode === null && proc.signalCode === null) {
960
+ backgroundStopped.add(id);
961
+ proc.kill("SIGTERM");
962
+ const timer = setTimeout(() => {
963
+ if (proc.exitCode === null && proc.signalCode === null) proc.kill("SIGKILL");
964
+ }, ABORT_KILL_DELAY_MS);
965
+ timer.unref();
966
+ } else if (record.pid !== null && isPidAlive(record.pid)) {
967
+ backgroundStopped.add(id);
968
+ try {
969
+ process.kill(record.pid, "SIGTERM");
970
+ } catch {
971
+ return `Background subagent ${id} could not be stopped (process ${record.pid} is not reachable).`;
972
+ }
973
+ } else {
974
+ return describeBackgroundRecord(refreshStaleBackgroundRecord(record));
975
+ }
976
+ record.status = "aborted";
977
+ record.errorMessage = "Subagent was stopped";
978
+ writeBackgroundRecord(record);
979
+ return `Background subagent ${id} (${record.agent}) stopped.`;
980
+ }
981
+
982
+ const TaskItem = Type.Object({
983
+ agent: Type.String({ description: "Name of the agent to invoke" }),
984
+ task: Type.String({ description: "Task to delegate to the agent" }),
985
+ cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
986
+ });
987
+
988
+ const ChainItem = Type.Object({
989
+ agent: Type.String({ description: "Name of the agent to invoke" }),
990
+ task: Type.String({ description: "Task with optional {previous} placeholder for prior output" }),
991
+ cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
992
+ });
993
+
994
+ const BackgroundItem = Type.Object(
995
+ {
996
+ agent: Type.String({ description: "Name of the agent to invoke in the background" }),
997
+ task: Type.String({ description: "Task to delegate to the background agent" }),
998
+ cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
999
+ },
1000
+ { description: "Start a background subagent and return at once with its id; check it later with status." },
1001
+ );
1002
+
1003
+ const BackgroundRef = Type.Object(
1004
+ {
1005
+ subagentId: Type.String({ description: "Id of a background subagent, as returned by a background spawn" }),
1006
+ },
1007
+ { description: "Reference to a background subagent by its id." },
1008
+ );
1009
+
1010
+ const AgentScopeSchema = StringEnum(["user", "project", "both"] as const, {
1011
+ description: 'Which agent directories to use. Default: "user". Use "both" to include project-local agents.',
1012
+ default: "user",
1013
+ });
1014
+
1015
+ const SubagentParams = Type.Object({
1016
+ agent: Type.Optional(Type.String({ description: "Name of the agent to invoke (for single mode)" })),
1017
+ task: Type.Optional(Type.String({ description: "Task to delegate (for single mode)" })),
1018
+ tasks: Type.Optional(Type.Array(TaskItem, { description: "Array of {agent, task} for parallel execution" })),
1019
+ chain: Type.Optional(Type.Array(ChainItem, { description: "Array of {agent, task} for sequential execution" })),
1020
+ agentScope: Type.Optional(AgentScopeSchema),
1021
+ confirmProjectAgents: Type.Optional(
1022
+ Type.Boolean({ description: "Prompt before running project-local agents. Default: true.", default: true }),
1023
+ ),
1024
+ cwd: Type.Optional(Type.String({ description: "Working directory for the agent process (single mode)" })),
1025
+ background: Type.Optional(BackgroundItem),
1026
+ status: Type.Optional(BackgroundRef),
1027
+ stop: Type.Optional(BackgroundRef),
1028
+ });
1029
+
1030
+ export default function (pigeon: ExtensionAPI) {
1031
+ // At the nesting cap the child has no subagent tool, so it cannot spawn
1032
+ // further children. The parent still has the tool at lower depths.
1033
+ if (getSubagentDepth() >= MAX_SUBAGENT_DEPTH) return;
1034
+
1035
+ // Tool execute results cannot set runtime error state directly, so patch it through the result hook.
1036
+ pigeon.on("tool_result", (event) => {
1037
+ if (event.toolName !== "subagent") return;
1038
+ const details = event.details as SubagentDetails | undefined;
1039
+ if (details?.isError) return { isError: true };
1040
+ });
1041
+
1042
+ pigeon.registerTool({
1043
+ name: "subagent",
1044
+ label: "Subagent",
1045
+ description: [
1046
+ "Delegate tasks to specialized subagents with isolated context.",
1047
+ "Modes: single (agent + task), parallel (tasks array), chain (sequential with {previous} placeholder),",
1048
+ "background (start a subagent and return at once with its id), status (report on a background subagent),",
1049
+ "stop (stop a background subagent). Nesting is capped: a child cannot spawn its own subagents past depth 2.",
1050
+ `Default agent scope is "user" (from ${path.join(getAgentDir(), "agents")}).`,
1051
+ `To enable project-local agents in ${CONFIG_DIR_NAME}/agents, set agentScope: "both" (or "project").`,
1052
+ ].join(" "),
1053
+ parameters: SubagentParams,
1054
+
1055
+ async execute(_toolCallId, params, signal, onUpdate, ctx) {
1056
+ const agentScope: AgentScope = params.agentScope ?? "user";
1057
+ const dispatchDefaults: DispatchDefaults = {
1058
+ model: ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : undefined,
1059
+ thinkingLevel: ctx.thinkingLevel,
1060
+ };
1061
+ const discovery = discoverAgents(ctx.cwd, agentScope);
1062
+ const agents = discovery.agents;
1063
+ const confirmProjectAgents = params.confirmProjectAgents ?? true;
1064
+
1065
+ const hasChain = (params.chain?.length ?? 0) > 0;
1066
+ const hasTasks = (params.tasks?.length ?? 0) > 0;
1067
+ const hasSingle = Boolean(params.agent && params.task);
1068
+ const hasBackground = Boolean(params.background);
1069
+ const hasStatus = Boolean(params.status);
1070
+ const hasStop = Boolean(params.stop);
1071
+ const modeCount =
1072
+ Number(hasChain) +
1073
+ Number(hasTasks) +
1074
+ Number(hasSingle) +
1075
+ Number(hasBackground) +
1076
+ Number(hasStatus) +
1077
+ Number(hasStop);
1078
+
1079
+ const makeDetails =
1080
+ (mode: SubagentDetails["mode"], forceError = false) =>
1081
+ (results: SingleResult[]): SubagentDetails => ({
1082
+ mode,
1083
+ results,
1084
+ isError: forceError || results.some(isFailedResult),
1085
+ });
1086
+
1087
+ if (modeCount !== 1) {
1088
+ const available = agents.map((a) => `${a.name} (${a.source})`).join(", ") || "none";
1089
+ return {
1090
+ content: [
1091
+ {
1092
+ type: "text",
1093
+ text: `Invalid parameters. Provide exactly one mode.\nAvailable agents: ${available}`,
1094
+ },
1095
+ ],
1096
+ details: makeDetails("single", true)([]),
1097
+ };
1098
+ }
1099
+
1100
+ const resolvedChain = (params.chain ?? []).map((step) =>
1101
+ resolveAgent(ctx.cwd, agentScope, step.agent, step.cwd),
1102
+ );
1103
+ const resolvedTasks = (params.tasks ?? []).map((task) =>
1104
+ resolveAgent(ctx.cwd, agentScope, task.agent, task.cwd),
1105
+ );
1106
+ const resolvedSingle = params.agent ? resolveAgent(ctx.cwd, agentScope, params.agent, params.cwd) : undefined;
1107
+ const resolvedBackground = params.background
1108
+ ? resolveAgent(ctx.cwd, agentScope, params.background.agent, params.background.cwd)
1109
+ : undefined;
1110
+
1111
+ if ((agentScope === "project" || agentScope === "both") && confirmProjectAgents && ctx.hasUI) {
1112
+ let selectedAgents: ResolvedAgent[] = [];
1113
+ if (hasChain) selectedAgents = resolvedChain;
1114
+ else if (hasTasks) selectedAgents = resolvedTasks;
1115
+ else if (resolvedSingle) selectedAgents = [resolvedSingle];
1116
+ else if (resolvedBackground) selectedAgents = [resolvedBackground];
1117
+ const projectAgentsByPath = new Map<string, AgentConfig>();
1118
+ for (const resolved of selectedAgents) {
1119
+ if (resolved.agent?.source === "project") {
1120
+ projectAgentsByPath.set(resolved.agent.filePath, resolved.agent);
1121
+ }
1122
+ }
1123
+
1124
+ const trustedProjectAgentsDir =
1125
+ ctx.isProjectTrusted() && discovery.projectAgentsDir
1126
+ ? fs.realpathSync(discovery.projectAgentsDir)
1127
+ : undefined;
1128
+ const projectAgentsRequested = Array.from(projectAgentsByPath.values()).filter(
1129
+ (agent) =>
1130
+ !trustedProjectAgentsDir || fs.realpathSync(path.dirname(agent.filePath)) !== trustedProjectAgentsDir,
1131
+ );
1132
+ if (projectAgentsRequested.length > 0) {
1133
+ const sources = projectAgentsRequested.map((agent) => `- ${agent.name}: ${agent.filePath}`).join("\n");
1134
+ const ok = await ctx.ui.confirm(
1135
+ "Run project-local agents?",
1136
+ `Sources:\n${sources}\n\nProject agents are repo-controlled. Only continue for trusted repositories.`,
1137
+ );
1138
+ if (!ok) {
1139
+ return {
1140
+ content: [{ type: "text", text: "Canceled: project-local agents not approved." }],
1141
+ details: makeDetails(
1142
+ hasChain ? "chain" : hasTasks ? "parallel" : hasBackground ? "background" : "single",
1143
+ )([]),
1144
+ };
1145
+ }
1146
+ }
1147
+ }
1148
+
1149
+ if (params.status) {
1150
+ const record = readBackgroundRecord(params.status.subagentId);
1151
+ if (!record) {
1152
+ return {
1153
+ content: [{ type: "text", text: `Unknown background subagent: "${params.status.subagentId}".` }],
1154
+ details: makeDetails("status", true)([]),
1155
+ };
1156
+ }
1157
+ const current = refreshStaleBackgroundRecord(record);
1158
+ if (current.status !== "running" && !subagentStopHooksFired.has(current.id)) {
1159
+ subagentStopHooksFired.add(current.id);
1160
+ await fireSubagentStopHooks(
1161
+ current.agent,
1162
+ current.id,
1163
+ current.status === "completed",
1164
+ current.errorMessage,
1165
+ ctx.cwd,
1166
+ );
1167
+ }
1168
+ return {
1169
+ content: [{ type: "text", text: describeBackgroundRecord(current) }],
1170
+ details: makeDetails("status")([recordToResult(current)]),
1171
+ };
1172
+ }
1173
+
1174
+ if (params.stop) {
1175
+ const text = stopBackgroundAgent(params.stop.subagentId);
1176
+ const record = readBackgroundRecord(params.stop.subagentId);
1177
+ if (record && !subagentStopHooksFired.has(record.id)) {
1178
+ subagentStopHooksFired.add(record.id);
1179
+ await fireSubagentStopHooks(record.agent, record.id, false, "Stopped by user", ctx.cwd);
1180
+ }
1181
+ return {
1182
+ content: [{ type: "text", text }],
1183
+ details: makeDetails(
1184
+ "stop",
1185
+ !record,
1186
+ )(record ? [recordToResult(refreshStaleBackgroundRecord(record))] : []),
1187
+ };
1188
+ }
1189
+
1190
+ if (params.background && resolvedBackground) {
1191
+ const started = await startBackgroundAgent(
1192
+ dispatchDefaults,
1193
+ resolvedBackground,
1194
+ params.background.agent,
1195
+ params.background.task,
1196
+ );
1197
+ if (started.kind === "error") {
1198
+ return {
1199
+ content: [{ type: "text", text: started.error }],
1200
+ details: makeDetails("background", true)([]),
1201
+ };
1202
+ }
1203
+ return {
1204
+ content: [
1205
+ {
1206
+ type: "text",
1207
+ text: `Background subagent ${started.id} (${params.background.agent}) started. Check it with status { subagentId: "${started.id}" }. Log: ${started.logPath}`,
1208
+ },
1209
+ ],
1210
+ details: makeDetails("background")([started.result]),
1211
+ };
1212
+ }
1213
+
1214
+ if (params.chain && params.chain.length > 0) {
1215
+ const results: SingleResult[] = [];
1216
+ let previousOutput = "";
1217
+
1218
+ for (let i = 0; i < params.chain.length; i++) {
1219
+ const step = params.chain[i];
1220
+ const taskWithContext = step.task.replace(/\{previous\}/g, previousOutput);
1221
+
1222
+ // Create update callback that includes all previous results
1223
+ const chainUpdate: OnUpdateCallback | undefined = onUpdate
1224
+ ? (partial) => {
1225
+ // Combine completed results with current streaming result
1226
+ const currentResult = partial.details?.results[0];
1227
+ if (currentResult) {
1228
+ const allResults = [...results, currentResult];
1229
+ onUpdate({
1230
+ content: partial.content,
1231
+ details: makeDetails("chain")(allResults),
1232
+ });
1233
+ }
1234
+ }
1235
+ : undefined;
1236
+
1237
+ const result = await runSingleAgent(
1238
+ dispatchDefaults,
1239
+ resolvedChain[i],
1240
+ step.agent,
1241
+ taskWithContext,
1242
+ i + 1,
1243
+ signal,
1244
+ chainUpdate,
1245
+ makeDetails("chain"),
1246
+ );
1247
+ results.push(result);
1248
+
1249
+ const isError = isFailedResult(result);
1250
+ if (isError) {
1251
+ const errorMsg = getResultOutput(result);
1252
+ return {
1253
+ content: [
1254
+ {
1255
+ type: "text",
1256
+ text: truncateModelOutput(`Chain stopped at step ${i + 1} (${step.agent}): ${errorMsg}`),
1257
+ },
1258
+ ],
1259
+ details: makeDetails("chain")(results),
1260
+ };
1261
+ }
1262
+ previousOutput = getFinalOutput(result.messages);
1263
+ }
1264
+ return {
1265
+ content: [
1266
+ {
1267
+ type: "text",
1268
+ text: truncateModelOutput(getFinalOutput(results[results.length - 1].messages) || "(no output)"),
1269
+ },
1270
+ ],
1271
+ details: makeDetails("chain")(results),
1272
+ };
1273
+ }
1274
+
1275
+ if (params.tasks && params.tasks.length > 0) {
1276
+ if (params.tasks.length > MAX_PARALLEL_TASKS)
1277
+ return {
1278
+ content: [
1279
+ {
1280
+ type: "text",
1281
+ text: `Too many parallel tasks (${params.tasks.length}). Max is ${MAX_PARALLEL_TASKS}.`,
1282
+ },
1283
+ ],
1284
+ details: makeDetails("parallel", true)([]),
1285
+ };
1286
+
1287
+ // Track all results for streaming updates
1288
+ const allResults: SingleResult[] = new Array(params.tasks.length);
1289
+
1290
+ // Initialize placeholder results
1291
+ for (let i = 0; i < params.tasks.length; i++) {
1292
+ allResults[i] = {
1293
+ agent: params.tasks[i].agent,
1294
+ agentSource: "unknown",
1295
+ task: params.tasks[i].task,
1296
+ status: "pending",
1297
+ exitCode: null,
1298
+ messages: [],
1299
+ stderr: "",
1300
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
1301
+ };
1302
+ }
1303
+
1304
+ const emitParallelUpdate = () => {
1305
+ if (onUpdate) {
1306
+ const running = allResults.filter((result) => result.status === "running").length;
1307
+ const pending = allResults.filter((result) => result.status === "pending").length;
1308
+ const done = allResults.length - running - pending;
1309
+ onUpdate({
1310
+ content: [
1311
+ {
1312
+ type: "text",
1313
+ text: `Parallel: ${done}/${allResults.length} done, ${running} running, ${pending} pending...`,
1314
+ },
1315
+ ],
1316
+ details: makeDetails("parallel")([...allResults]),
1317
+ });
1318
+ }
1319
+ };
1320
+
1321
+ const results = await mapWithConcurrencyLimit(params.tasks, MAX_CONCURRENCY, async (t, index) => {
1322
+ const result = await runSingleAgent(
1323
+ dispatchDefaults,
1324
+ resolvedTasks[index],
1325
+ t.agent,
1326
+ t.task,
1327
+ undefined,
1328
+ signal,
1329
+ // Per-task update callback
1330
+ (partial) => {
1331
+ if (partial.details?.results[0]) {
1332
+ allResults[index] = partial.details.results[0];
1333
+ emitParallelUpdate();
1334
+ }
1335
+ },
1336
+ makeDetails("parallel"),
1337
+ );
1338
+ allResults[index] = result;
1339
+ emitParallelUpdate();
1340
+ return result;
1341
+ });
1342
+
1343
+ const successCount = results.filter((r) => !isFailedResult(r)).length;
1344
+ const summaries = results.map((r) => {
1345
+ const output = truncateParallelOutput(getResultOutput(r));
1346
+ const status =
1347
+ isFailedResult(r) && r.stopReason && r.stopReason !== "end"
1348
+ ? `${r.status} (${r.stopReason})`
1349
+ : r.status;
1350
+ return `### [${r.agent}] ${status}\n\n${output}`;
1351
+ });
1352
+ return {
1353
+ content: [
1354
+ {
1355
+ type: "text",
1356
+ text: `Parallel: ${successCount}/${results.length} succeeded\n\n${summaries.join("\n\n---\n\n")}`,
1357
+ },
1358
+ ],
1359
+ details: makeDetails("parallel")(results),
1360
+ };
1361
+ }
1362
+
1363
+ if (params.agent && params.task && resolvedSingle) {
1364
+ const result = await runSingleAgent(
1365
+ dispatchDefaults,
1366
+ resolvedSingle,
1367
+ params.agent,
1368
+ params.task,
1369
+ undefined,
1370
+ signal,
1371
+ onUpdate,
1372
+ makeDetails("single"),
1373
+ );
1374
+ const isError = isFailedResult(result);
1375
+ if (isError) {
1376
+ const errorMsg = getResultOutput(result);
1377
+ return {
1378
+ content: [
1379
+ {
1380
+ type: "text",
1381
+ text: truncateModelOutput(`Agent ${result.stopReason || result.status}: ${errorMsg}`),
1382
+ },
1383
+ ],
1384
+ details: makeDetails("single")([result]),
1385
+ };
1386
+ }
1387
+ return {
1388
+ content: [
1389
+ {
1390
+ type: "text",
1391
+ text: truncateModelOutput(getFinalOutput(result.messages) || "(no output)"),
1392
+ },
1393
+ ],
1394
+ details: makeDetails("single")([result]),
1395
+ };
1396
+ }
1397
+
1398
+ const available = agents.map((a) => `${a.name} (${a.source})`).join(", ") || "none";
1399
+ return {
1400
+ content: [{ type: "text", text: `Invalid parameters. Available agents: ${available}` }],
1401
+ details: makeDetails("single", true)([]),
1402
+ };
1403
+ },
1404
+
1405
+ renderCall(args, theme, _context) {
1406
+ const scope: AgentScope = args.agentScope ?? "user";
1407
+ if (args.background) {
1408
+ const preview =
1409
+ args.background.task.length > 60 ? `${args.background.task.slice(0, 60)}...` : args.background.task;
1410
+ return new Text(
1411
+ `${theme.fg("toolTitle", theme.bold("subagent "))}${theme.fg("accent", args.background.agent)}${theme.fg("muted", ` [${scope}] background`)}\n ${theme.fg("dim", preview)}`,
1412
+ 0,
1413
+ 0,
1414
+ );
1415
+ }
1416
+ if (args.status) {
1417
+ return new Text(
1418
+ `${theme.fg("toolTitle", theme.bold("subagent "))}${theme.fg("accent", "status")}${theme.fg("muted", ` ${args.status.subagentId}`)}`,
1419
+ 0,
1420
+ 0,
1421
+ );
1422
+ }
1423
+ if (args.stop) {
1424
+ return new Text(
1425
+ `${theme.fg("toolTitle", theme.bold("subagent "))}${theme.fg("accent", "stop")}${theme.fg("muted", ` ${args.stop.subagentId}`)}`,
1426
+ 0,
1427
+ 0,
1428
+ );
1429
+ }
1430
+ if (args.chain && args.chain.length > 0) {
1431
+ let text =
1432
+ theme.fg("toolTitle", theme.bold("subagent ")) +
1433
+ theme.fg("accent", `chain (${args.chain.length} steps)`) +
1434
+ theme.fg("muted", ` [${scope}]`);
1435
+ for (let i = 0; i < Math.min(args.chain.length, 3); i++) {
1436
+ const step = args.chain[i];
1437
+ // Clean up {previous} placeholder for display
1438
+ const cleanTask = step.task.replace(/\{previous\}/g, "").trim();
1439
+ const preview = cleanTask.length > 40 ? `${cleanTask.slice(0, 40)}...` : cleanTask;
1440
+ text +=
1441
+ "\n " +
1442
+ theme.fg("muted", `${i + 1}.`) +
1443
+ " " +
1444
+ theme.fg("accent", step.agent) +
1445
+ theme.fg("dim", ` ${preview}`);
1446
+ }
1447
+ if (args.chain.length > 3) text += `\n ${theme.fg("muted", `... +${args.chain.length - 3} more`)}`;
1448
+ return new Text(text, 0, 0);
1449
+ }
1450
+ if (args.tasks && args.tasks.length > 0) {
1451
+ let text =
1452
+ theme.fg("toolTitle", theme.bold("subagent ")) +
1453
+ theme.fg("accent", `parallel (${args.tasks.length} tasks)`) +
1454
+ theme.fg("muted", ` [${scope}]`);
1455
+ for (const t of args.tasks.slice(0, 3)) {
1456
+ const preview = t.task.length > 40 ? `${t.task.slice(0, 40)}...` : t.task;
1457
+ text += `\n ${theme.fg("accent", t.agent)}${theme.fg("dim", ` ${preview}`)}`;
1458
+ }
1459
+ if (args.tasks.length > 3) text += `\n ${theme.fg("muted", `... +${args.tasks.length - 3} more`)}`;
1460
+ return new Text(text, 0, 0);
1461
+ }
1462
+ const agentName = args.agent || "...";
1463
+ const preview = args.task ? (args.task.length > 60 ? `${args.task.slice(0, 60)}...` : args.task) : "...";
1464
+ let text =
1465
+ theme.fg("toolTitle", theme.bold("subagent ")) +
1466
+ theme.fg("accent", agentName) +
1467
+ theme.fg("muted", ` [${scope}]`);
1468
+ text += `\n ${theme.fg("dim", preview)}`;
1469
+ return new Text(text, 0, 0);
1470
+ },
1471
+
1472
+ renderResult(result, { expanded }, theme, _context) {
1473
+ const details = result.details as SubagentDetails | undefined;
1474
+ if (!details || details.results.length === 0) {
1475
+ const text = result.content[0];
1476
+ return new Text(text?.type === "text" ? text.text : "(no output)", 0, 0);
1477
+ }
1478
+
1479
+ const mdTheme = getMarkdownTheme();
1480
+
1481
+ const renderDisplayItems = (items: DisplayItem[], limit?: number) => {
1482
+ const toShow = limit ? items.slice(-limit) : items;
1483
+ const skipped = limit && items.length > limit ? items.length - limit : 0;
1484
+ let text = "";
1485
+ if (skipped > 0) text += theme.fg("muted", `... ${skipped} earlier items\n`);
1486
+ for (const item of toShow) {
1487
+ if (item.type === "text") {
1488
+ const preview = expanded ? item.text : item.text.split("\n").slice(0, 3).join("\n");
1489
+ text += `${theme.fg("toolOutput", preview)}\n`;
1490
+ } else {
1491
+ text += `${theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme))}\n`;
1492
+ }
1493
+ }
1494
+ return text.trimEnd();
1495
+ };
1496
+
1497
+ const resultIcon = (child: SingleResult): string => {
1498
+ if (child.status === "pending" || child.status === "running") {
1499
+ return theme.fg("warning", "⏳");
1500
+ }
1501
+ if (isFailedResult(child)) return theme.fg("error", "✗");
1502
+ return theme.fg("success", "✓");
1503
+ };
1504
+
1505
+ if (details.mode === "single" && details.results.length === 1) {
1506
+ const r = details.results[0];
1507
+ const isError = isFailedResult(r);
1508
+ const isRunning = r.status === "pending" || r.status === "running";
1509
+ const icon = resultIcon(r);
1510
+ const displayItems = getDisplayItems(r.messages);
1511
+ const finalOutput = getFinalOutput(r.messages);
1512
+
1513
+ if (expanded) {
1514
+ const container = new Container();
1515
+ let header = `${icon} ${theme.fg("toolTitle", theme.bold(r.agent))}${theme.fg("muted", ` (${r.agentSource})`)}`;
1516
+ if (isRunning) header += ` ${theme.fg("warning", `[${r.status}]`)}`;
1517
+ else if (isError) header += ` ${theme.fg("error", `[${r.stopReason ?? r.status}]`)}`;
1518
+ container.addChild(new Text(header, 0, 0));
1519
+ if (isError && r.errorMessage)
1520
+ container.addChild(new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0));
1521
+ if (r.terminationSignal)
1522
+ container.addChild(new Text(theme.fg("error", `Signal: ${r.terminationSignal}`), 0, 0));
1523
+ if (r.stderr.trim()) container.addChild(new Text(theme.fg("error", `stderr: ${r.stderr.trim()}`), 0, 0));
1524
+ container.addChild(new Spacer(1));
1525
+ container.addChild(new Text(theme.fg("muted", "─── Task ───"), 0, 0));
1526
+ container.addChild(new Text(theme.fg("dim", r.task), 0, 0));
1527
+ container.addChild(new Spacer(1));
1528
+ container.addChild(new Text(theme.fg("muted", "─── Output ───"), 0, 0));
1529
+ if (displayItems.length === 0 && !finalOutput) {
1530
+ container.addChild(new Text(theme.fg("muted", "(no output)"), 0, 0));
1531
+ } else {
1532
+ for (const item of displayItems) {
1533
+ if (item.type === "toolCall")
1534
+ container.addChild(
1535
+ new Text(
1536
+ theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme)),
1537
+ 0,
1538
+ 0,
1539
+ ),
1540
+ );
1541
+ }
1542
+ if (finalOutput) {
1543
+ container.addChild(new Spacer(1));
1544
+ container.addChild(new Markdown(finalOutput.trim(), 0, 0, mdTheme));
1545
+ }
1546
+ }
1547
+ const usageStr = formatUsageStats(r.usage, r.model);
1548
+ if (usageStr) {
1549
+ container.addChild(new Spacer(1));
1550
+ container.addChild(new Text(theme.fg("dim", usageStr), 0, 0));
1551
+ }
1552
+ return container;
1553
+ }
1554
+
1555
+ let text = `${icon} ${theme.fg("toolTitle", theme.bold(r.agent))}${theme.fg("muted", ` (${r.agentSource})`)}`;
1556
+ if (isRunning) text += ` ${theme.fg("warning", `[${r.status}]`)}`;
1557
+ else if (isError) text += ` ${theme.fg("error", `[${r.stopReason ?? r.status}]`)}`;
1558
+ if (isError && r.errorMessage) text += `\n${theme.fg("error", `Error: ${r.errorMessage}`)}`;
1559
+ else if (displayItems.length === 0) text += `\n${theme.fg("muted", "(no output)")}`;
1560
+ else {
1561
+ text += `\n${renderDisplayItems(displayItems, COLLAPSED_ITEM_COUNT)}`;
1562
+ if (displayItems.length > COLLAPSED_ITEM_COUNT) text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
1563
+ }
1564
+ const usageStr = formatUsageStats(r.usage, r.model);
1565
+ if (usageStr) text += `\n${theme.fg("dim", usageStr)}`;
1566
+ return new Text(text, 0, 0);
1567
+ }
1568
+
1569
+ const aggregateUsage = (results: SingleResult[]): UsageStats => {
1570
+ const total: UsageStats = {
1571
+ input: 0,
1572
+ output: 0,
1573
+ cacheRead: 0,
1574
+ cacheWrite: 0,
1575
+ cost: 0,
1576
+ contextTokens: 0,
1577
+ turns: 0,
1578
+ };
1579
+ for (const result of results) {
1580
+ total.input += result.usage.input;
1581
+ total.output += result.usage.output;
1582
+ total.cacheRead += result.usage.cacheRead;
1583
+ total.cacheWrite += result.usage.cacheWrite;
1584
+ total.cost += result.usage.cost;
1585
+ total.turns += result.usage.turns;
1586
+ }
1587
+ return total;
1588
+ };
1589
+
1590
+ if (details.mode === "chain") {
1591
+ const successCount = details.results.filter((result) => result.status === "completed").length;
1592
+ const hasActive = details.results.some(
1593
+ (result) => result.status === "pending" || result.status === "running",
1594
+ );
1595
+ let icon = theme.fg("error", "✗");
1596
+ if (hasActive) icon = theme.fg("warning", "⏳");
1597
+ else if (successCount === details.results.length) icon = theme.fg("success", "✓");
1598
+
1599
+ if (expanded) {
1600
+ const container = new Container();
1601
+ container.addChild(
1602
+ new Text(
1603
+ icon +
1604
+ " " +
1605
+ theme.fg("toolTitle", theme.bold("chain ")) +
1606
+ theme.fg("accent", `${successCount}/${details.results.length} steps`),
1607
+ 0,
1608
+ 0,
1609
+ ),
1610
+ );
1611
+
1612
+ for (const r of details.results) {
1613
+ const rIcon = resultIcon(r);
1614
+ const displayItems = getDisplayItems(r.messages);
1615
+ const finalOutput = getFinalOutput(r.messages);
1616
+
1617
+ container.addChild(new Spacer(1));
1618
+ container.addChild(
1619
+ new Text(
1620
+ `${theme.fg("muted", `─── Step ${r.step}: `) + theme.fg("accent", r.agent)} ${rIcon}`,
1621
+ 0,
1622
+ 0,
1623
+ ),
1624
+ );
1625
+ container.addChild(new Text(theme.fg("muted", "Task: ") + theme.fg("dim", r.task), 0, 0));
1626
+ if (isFailedResult(r) && r.errorMessage)
1627
+ container.addChild(new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0));
1628
+ if (r.terminationSignal)
1629
+ container.addChild(new Text(theme.fg("error", `Signal: ${r.terminationSignal}`), 0, 0));
1630
+ if (r.stderr.trim())
1631
+ container.addChild(new Text(theme.fg("error", `stderr: ${r.stderr.trim()}`), 0, 0));
1632
+
1633
+ // Show tool calls
1634
+ for (const item of displayItems) {
1635
+ if (item.type === "toolCall") {
1636
+ container.addChild(
1637
+ new Text(
1638
+ theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme)),
1639
+ 0,
1640
+ 0,
1641
+ ),
1642
+ );
1643
+ }
1644
+ }
1645
+
1646
+ // Show final output as markdown
1647
+ if (finalOutput) {
1648
+ container.addChild(new Spacer(1));
1649
+ container.addChild(new Markdown(finalOutput.trim(), 0, 0, mdTheme));
1650
+ }
1651
+
1652
+ const stepUsage = formatUsageStats(r.usage, r.model);
1653
+ if (stepUsage) container.addChild(new Text(theme.fg("dim", stepUsage), 0, 0));
1654
+ }
1655
+
1656
+ const usageStr = formatUsageStats(aggregateUsage(details.results));
1657
+ if (usageStr) {
1658
+ container.addChild(new Spacer(1));
1659
+ container.addChild(new Text(theme.fg("dim", `Total: ${usageStr}`), 0, 0));
1660
+ }
1661
+ return container;
1662
+ }
1663
+
1664
+ // Collapsed view
1665
+ let text =
1666
+ icon +
1667
+ " " +
1668
+ theme.fg("toolTitle", theme.bold("chain ")) +
1669
+ theme.fg("accent", `${successCount}/${details.results.length} steps`);
1670
+ for (const r of details.results) {
1671
+ const rIcon = resultIcon(r);
1672
+ const displayItems = getDisplayItems(r.messages);
1673
+ text += `\n\n${theme.fg("muted", `─── Step ${r.step}: `)}${theme.fg("accent", r.agent)} ${rIcon}`;
1674
+ if (displayItems.length === 0) {
1675
+ const failed = isFailedResult(r);
1676
+ const summary = failed ? getFailureSummary(r) : "(no output)";
1677
+ text += `\n${theme.fg(failed ? "error" : "muted", summary)}`;
1678
+ } else {
1679
+ text += `\n${renderDisplayItems(displayItems, 5)}`;
1680
+ }
1681
+ }
1682
+ const usageStr = formatUsageStats(aggregateUsage(details.results));
1683
+ if (usageStr) text += `\n\n${theme.fg("dim", `Total: ${usageStr}`)}`;
1684
+ text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
1685
+ return new Text(text, 0, 0);
1686
+ }
1687
+
1688
+ if (details.mode === "parallel") {
1689
+ const running = details.results.filter((result) => result.status === "running").length;
1690
+ const pending = details.results.filter((result) => result.status === "pending").length;
1691
+ const successCount = details.results.filter((result) => result.status === "completed").length;
1692
+ const failCount = details.results.filter(isFailedResult).length;
1693
+ const isRunning = running > 0 || pending > 0;
1694
+ let icon = theme.fg("success", "✓");
1695
+ if (isRunning) icon = theme.fg("warning", "⏳");
1696
+ else if (failCount > 0) icon = theme.fg("warning", "◐");
1697
+ const status = isRunning
1698
+ ? `${successCount + failCount}/${details.results.length} done, ${running} running, ${pending} pending`
1699
+ : `${successCount}/${details.results.length} tasks`;
1700
+
1701
+ if (expanded && !isRunning) {
1702
+ const container = new Container();
1703
+ container.addChild(
1704
+ new Text(
1705
+ `${icon} ${theme.fg("toolTitle", theme.bold("parallel "))}${theme.fg("accent", status)}`,
1706
+ 0,
1707
+ 0,
1708
+ ),
1709
+ );
1710
+
1711
+ for (const r of details.results) {
1712
+ const rIcon = resultIcon(r);
1713
+ const displayItems = getDisplayItems(r.messages);
1714
+ const finalOutput = getFinalOutput(r.messages);
1715
+
1716
+ container.addChild(new Spacer(1));
1717
+ container.addChild(
1718
+ new Text(`${theme.fg("muted", "─── ") + theme.fg("accent", r.agent)} ${rIcon}`, 0, 0),
1719
+ );
1720
+ container.addChild(new Text(theme.fg("muted", "Task: ") + theme.fg("dim", r.task), 0, 0));
1721
+ if (isFailedResult(r) && r.errorMessage)
1722
+ container.addChild(new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0));
1723
+ if (r.terminationSignal)
1724
+ container.addChild(new Text(theme.fg("error", `Signal: ${r.terminationSignal}`), 0, 0));
1725
+ if (r.stderr.trim())
1726
+ container.addChild(new Text(theme.fg("error", `stderr: ${r.stderr.trim()}`), 0, 0));
1727
+
1728
+ // Show tool calls
1729
+ for (const item of displayItems) {
1730
+ if (item.type === "toolCall") {
1731
+ container.addChild(
1732
+ new Text(
1733
+ theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme)),
1734
+ 0,
1735
+ 0,
1736
+ ),
1737
+ );
1738
+ }
1739
+ }
1740
+
1741
+ // Show final output as markdown
1742
+ if (finalOutput) {
1743
+ container.addChild(new Spacer(1));
1744
+ container.addChild(new Markdown(finalOutput.trim(), 0, 0, mdTheme));
1745
+ }
1746
+
1747
+ const taskUsage = formatUsageStats(r.usage, r.model);
1748
+ if (taskUsage) container.addChild(new Text(theme.fg("dim", taskUsage), 0, 0));
1749
+ }
1750
+
1751
+ const usageStr = formatUsageStats(aggregateUsage(details.results));
1752
+ if (usageStr) {
1753
+ container.addChild(new Spacer(1));
1754
+ container.addChild(new Text(theme.fg("dim", `Total: ${usageStr}`), 0, 0));
1755
+ }
1756
+ return container;
1757
+ }
1758
+
1759
+ // Collapsed view (or still running)
1760
+ let text = `${icon} ${theme.fg("toolTitle", theme.bold("parallel "))}${theme.fg("accent", status)}`;
1761
+ for (const r of details.results) {
1762
+ const rIcon = resultIcon(r);
1763
+ const displayItems = getDisplayItems(r.messages);
1764
+ text += `\n\n${theme.fg("muted", "─── ")}${theme.fg("accent", r.agent)} ${rIcon}`;
1765
+ if (displayItems.length === 0) {
1766
+ const failed = isFailedResult(r);
1767
+ let summary = "(no output)";
1768
+ if (r.status === "pending") summary = "(pending...)";
1769
+ else if (r.status === "running") summary = "(running...)";
1770
+ else if (failed) summary = getFailureSummary(r);
1771
+ text += `\n${theme.fg(failed ? "error" : "muted", summary)}`;
1772
+ } else {
1773
+ text += `\n${renderDisplayItems(displayItems, 5)}`;
1774
+ }
1775
+ }
1776
+ if (!isRunning) {
1777
+ const usageStr = formatUsageStats(aggregateUsage(details.results));
1778
+ if (usageStr) text += `\n\n${theme.fg("dim", `Total: ${usageStr}`)}`;
1779
+ }
1780
+ if (!expanded) text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
1781
+ return new Text(text, 0, 0);
1782
+ }
1783
+
1784
+ const text = result.content[0];
1785
+ return new Text(text?.type === "text" ? text.text : "(no output)", 0, 0);
1786
+ },
1787
+ });
1788
+ }