autohand-cli 0.7.14 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. package/README.md +97 -2
  2. package/assets/icon.png +0 -0
  3. package/dist/AgentRegistry-7LDL5HJH.js +10 -0
  4. package/dist/AgentRegistry-NQCLWABO.cjs +10 -0
  5. package/dist/{AutomodeManager-NGRAO2MH.js → AutomodeManager-MWLKGPZK.js} +2 -0
  6. package/dist/{AutomodeManager-ZKQMBM4T.cjs → AutomodeManager-NYIZNODK.cjs} +3 -1
  7. package/dist/CommunitySkillsCache-6QPRMTJO.js +8 -0
  8. package/dist/CommunitySkillsCache-GTQMOCCO.cjs +8 -0
  9. package/dist/{GitHubRegistryFetcher-US2JJID4.js → GitHubRegistryFetcher-6JQ5JEDZ.js} +1 -0
  10. package/dist/{GitHubRegistryFetcher-K744NNAJ.cjs → GitHubRegistryFetcher-S7QFUEKV.cjs} +1 -0
  11. package/dist/HookManager-Q2KYMCP4.cjs +7 -0
  12. package/dist/HookManager-TTP4Y6DC.js +7 -0
  13. package/dist/ImportWizard-35YBJ4AM.cjs +466 -0
  14. package/dist/ImportWizard-XH7CINCH.js +466 -0
  15. package/dist/LearnAdvisor-A4Q5PPBI.js +9 -0
  16. package/dist/LearnAdvisor-GASQD7HT.cjs +9 -0
  17. package/dist/McpClientManager-7RM6YT35.js +8 -0
  18. package/dist/McpClientManager-RKD7C6OY.cjs +8 -0
  19. package/dist/MemoryManager-GUNLRP5S.js +8 -0
  20. package/dist/MemoryManager-TNSGKDKX.cjs +8 -0
  21. package/dist/{PermissionManager-U5OMGR3L.js → PermissionManager-ATUV34LQ.js} +4 -3
  22. package/dist/PermissionManager-KMN53FJP.cjs +11 -0
  23. package/dist/ProjectProfiler-UMJJSOCE.js +194 -0
  24. package/dist/ProjectProfiler-ZDWR2ODG.cjs +194 -0
  25. package/dist/ProviderFactory-MR5B23QJ.js +9 -0
  26. package/dist/ProviderFactory-VFGCJJX6.cjs +9 -0
  27. package/dist/SessionManager-FEUAU3ZJ.cjs +10 -0
  28. package/dist/SessionManager-IKWAK2PI.js +10 -0
  29. package/dist/SkillsRegistry-KPQFTRIT.cjs +9 -0
  30. package/dist/SkillsRegistry-XJSKPDF2.js +9 -0
  31. package/dist/SubAgent-NYH6GWQ3.js +11 -0
  32. package/dist/SubAgent-PZKBDUBA.cjs +11 -0
  33. package/dist/{SyncApiClient-AYXYSOJM.js → SyncApiClient-LVIO4C2S.js} +1 -0
  34. package/dist/{SyncApiClient-ID3KXEMA.cjs → SyncApiClient-ZNYMT36M.cjs} +1 -0
  35. package/dist/about-HHTF2YFL.js +12 -0
  36. package/dist/about-JGRVNNQC.cjs +12 -0
  37. package/dist/actionExecutor-U6IBN2TU.cjs +19 -0
  38. package/dist/actionExecutor-XT5FW3W6.js +19 -0
  39. package/dist/add-dir-247K3XRY.js +10 -0
  40. package/dist/add-dir-GS4DXKKH.cjs +10 -0
  41. package/dist/agents/builtin/code-cleaner.md +14 -0
  42. package/dist/agents/builtin/docs-writer.md +14 -0
  43. package/dist/agents/builtin/researcher.md +14 -0
  44. package/dist/agents/builtin/reviewer.md +15 -0
  45. package/dist/agents/builtin/tester.md +15 -0
  46. package/dist/agents/builtin/todo-resolver.md +15 -0
  47. package/dist/agents-R6ZEFTVR.cjs +12 -0
  48. package/dist/agents-WJPQWQF2.js +12 -0
  49. package/dist/agents-new-HKVEIBDJ.js +14 -0
  50. package/dist/agents-new-X6GTHIO6.cjs +14 -0
  51. package/dist/assets/icon.png +0 -0
  52. package/dist/autoSkill-6TGBTEQD.js +20 -0
  53. package/dist/autoSkill-H4T6VVDA.cjs +20 -0
  54. package/dist/automode-BC6NVECO.js +10 -0
  55. package/dist/automode-WN2RSOGW.cjs +10 -0
  56. package/dist/{cc-UTTLESTY.js → cc-7LEIJ3KF.js} +1 -0
  57. package/dist/{cc-2W6M7J45.cjs → cc-Q5MM4AWC.cjs} +1 -0
  58. package/dist/{chunk-N4ZSG6JJ.cjs → chunk-22D2CNTP.cjs} +2 -2
  59. package/dist/chunk-245KJE5Y.cjs +55 -0
  60. package/dist/chunk-24QIWILL.js +51 -0
  61. package/dist/{chunk-MYNHJHDZ.js → chunk-2AA5MFES.js} +1 -1
  62. package/dist/{chunk-TSY7JHIV.cjs → chunk-33A755XB.cjs} +2 -2
  63. package/dist/chunk-33RSHBDH.js +131 -0
  64. package/dist/{chunk-QRGPAUST.js → chunk-34M3HWLR.js} +2 -2
  65. package/dist/{chunk-U7CZFKPL.cjs → chunk-3K2ESU53.cjs} +2 -2
  66. package/dist/{chunk-SIGWDEPS.cjs → chunk-3L53OA4E.cjs} +10 -10
  67. package/dist/chunk-3OEDGIFW.js +42 -0
  68. package/dist/chunk-3OTU3RS3.cjs +1607 -0
  69. package/dist/{chunk-MNSTWHK3.cjs → chunk-3PCTTUNW.cjs} +11 -11
  70. package/dist/{chunk-P5VDZ6PV.js → chunk-3PDTTAKJ.js} +1 -1
  71. package/dist/chunk-47CKWKEX.cjs +59 -0
  72. package/dist/{chunk-Z4J4W6YQ.cjs → chunk-4JNNTOGF.cjs} +2 -48
  73. package/dist/{chunk-GVZPIQWB.js → chunk-4PKF7WPD.js} +11 -5
  74. package/dist/{chunk-3S4DEIJP.cjs → chunk-5IXII4HX.cjs} +2 -2
  75. package/dist/{chunk-CRQKDBLD.js → chunk-5P2NXKP3.js} +98 -64
  76. package/dist/{chunk-DSKVMFRM.cjs → chunk-643VRA5S.cjs} +12 -4
  77. package/dist/{chunk-VVBBEYTH.cjs → chunk-6HYLHBQG.cjs} +10 -10
  78. package/dist/{chunk-L5ZFPWHY.js → chunk-6OYHF6MF.js} +12 -4
  79. package/dist/{chunk-BPTBKO7D.js → chunk-6RF7UKUS.js} +224 -37
  80. package/dist/{chunk-YHGTBPEC.js → chunk-6ZCULLCA.js} +1 -1
  81. package/dist/{chunk-VHBUKGRG.js → chunk-72FKPBT5.js} +4 -4
  82. package/dist/{chunk-2U5HFVRO.cjs → chunk-7BTSG4ME.cjs} +5165 -2194
  83. package/dist/chunk-7UOUW76C.js +603 -0
  84. package/dist/{chunk-FEVHH525.cjs → chunk-A4IJHHV7.cjs} +11 -5
  85. package/dist/{chunk-B6EBHCK2.cjs → chunk-AEJH23FO.cjs} +6 -6
  86. package/dist/{chunk-WLTVF77A.js → chunk-ALYU6VTM.js} +1 -1
  87. package/dist/{chunk-NMWEDN4Z.js → chunk-APIXPPMT.js} +5165 -2194
  88. package/dist/chunk-AS6RTLN7.cjs +203 -0
  89. package/dist/{chunk-BHV7CBNT.js → chunk-AYS2ASM7.js} +1 -1
  90. package/dist/{chunk-GRSVQ5YZ.js → chunk-AYSFIUFW.js} +44 -12
  91. package/dist/{chunk-NUHYCFHW.cjs → chunk-BVKXEQVG.cjs} +54 -65
  92. package/dist/chunk-BWN2CLLM.cjs +298 -0
  93. package/dist/{chunk-4HA7IHLJ.cjs → chunk-C5IJIM2V.cjs} +38 -16
  94. package/dist/{chunk-SRLY7K6J.js → chunk-CAMZTXV6.js} +2 -2
  95. package/dist/chunk-CDBPBM2K.cjs +29 -0
  96. package/dist/chunk-CNBKZEX5.cjs +109 -0
  97. package/dist/{chunk-WQUQ5JMM.js → chunk-CWMZKFTT.js} +4 -4
  98. package/dist/{chunk-CKN2BLHK.cjs → chunk-CZXGCVTR.cjs} +2 -2
  99. package/dist/{chunk-SZP4ULM5.cjs → chunk-DJDE4DTT.cjs} +17 -17
  100. package/dist/chunk-DN573ME7.cjs +1675 -0
  101. package/dist/chunk-DRE2RXBZ.js +4498 -0
  102. package/dist/chunk-DSPQEHDT.js +29 -0
  103. package/dist/{chunk-SFNT5DYE.cjs → chunk-DVUHHH3B.cjs} +4 -4
  104. package/dist/chunk-DVZOENQ7.cjs +58 -0
  105. package/dist/{chunk-PWLLLJHU.js → chunk-EGFT4PGW.js} +3 -1
  106. package/dist/chunk-EGMZDTSL.js +55 -0
  107. package/dist/chunk-EZMINVLU.js +123 -0
  108. package/dist/chunk-FHK7UDOJ.cjs +42 -0
  109. package/dist/{chunk-KWRUQRXR.js → chunk-FKSDEWDH.js} +44 -10
  110. package/dist/chunk-FMB3TSWP.cjs +218 -0
  111. package/dist/chunk-FW774QXH.js +1838 -0
  112. package/dist/{chunk-MY3TZER2.js → chunk-G27PQQFD.js} +1 -1
  113. package/dist/{chunk-Y2ZSH3YF.cjs → chunk-G3V4SFET.cjs} +57 -23
  114. package/dist/chunk-G4CAKI3V.js +58 -0
  115. package/dist/{chunk-FB6JWNJS.js → chunk-GBHDROGL.js} +54 -65
  116. package/dist/{chunk-DEAEO7RI.js → chunk-GJH7XMSK.js} +15 -1
  117. package/dist/chunk-GLBAF54O.js +218 -0
  118. package/dist/{chunk-S47TCZDL.js → chunk-H5SWOLG6.js} +7 -7
  119. package/dist/chunk-HBXAA3XB.js +83 -0
  120. package/dist/{chunk-63BXZQZW.js → chunk-HIVRCQS2.js} +26 -4
  121. package/dist/{chunk-WOGJXDBU.cjs → chunk-HLHTG5ZU.cjs} +18 -4
  122. package/dist/{chunk-FK2DVRPJ.js → chunk-HLQV64Y5.js} +170 -4
  123. package/dist/chunk-HOAHWIQ5.cjs +260 -0
  124. package/dist/{chunk-D2XFTCRP.js → chunk-HQ7YZKXE.js} +1 -1
  125. package/dist/{chunk-L42HTMMR.cjs → chunk-HTLINWX6.cjs} +2 -2
  126. package/dist/{chunk-PKOAXQKW.cjs → chunk-HVKOZ2VP.cjs} +11 -11
  127. package/dist/chunk-HXGBSJL5.cjs +27 -0
  128. package/dist/chunk-I5IW3T2Y.js +310 -0
  129. package/dist/chunk-IETRBBMP.cjs +603 -0
  130. package/dist/{chunk-MTALRU7R.cjs → chunk-IFFXSTOM.cjs} +3 -3
  131. package/dist/{chunk-V7YTCNMN.cjs → chunk-IKGWDOGU.cjs} +174 -8
  132. package/dist/chunk-IQ5RXU6O.js +1675 -0
  133. package/dist/{chunk-ZBIBLOZL.js → chunk-IVM5F2AE.js} +500 -317
  134. package/dist/chunk-J4Q7XR3G.js +260 -0
  135. package/dist/{chunk-XL77XYI2.cjs → chunk-J6QET7EF.cjs} +27 -7
  136. package/dist/{chunk-TQB222ZB.js → chunk-JCLYQ2JC.js} +2 -2
  137. package/dist/chunk-JSBRDJBE.js +30 -0
  138. package/dist/{chunk-XPOHYKR3.js → chunk-JX3DFKBI.js} +2 -2
  139. package/dist/chunk-JYTDYJVW.js +27 -0
  140. package/dist/{chunk-6SHHB2VD.js → chunk-KPELYZ6L.js} +2 -2
  141. package/dist/{chunk-ZLOTP56B.cjs → chunk-KWXVKLQ5.cjs} +5 -5
  142. package/dist/chunk-L3WAH3EM.cjs +131 -0
  143. package/dist/{chunk-ZXIQCYYV.cjs → chunk-LA7H35XM.cjs} +9 -9
  144. package/dist/chunk-LENHP55G.cjs +1838 -0
  145. package/dist/chunk-LJFUXC56.cjs +123 -0
  146. package/dist/{chunk-R5OO7MEB.cjs → chunk-LNMYK2F5.cjs} +22 -22
  147. package/dist/chunk-LQGVEP3E.js +109 -0
  148. package/dist/{chunk-KXAAEROY.js → chunk-LWUJFGOZ.js} +2 -2
  149. package/dist/chunk-MAKMSQMQ.cjs +504 -0
  150. package/dist/{chunk-BG4OQUKP.js → chunk-MBBY4ZIK.js} +1 -1
  151. package/dist/chunk-MSED7RH2.cjs +267 -0
  152. package/dist/{chunk-NMGF2KUN.js → chunk-MYISNQH4.js} +1 -1
  153. package/dist/chunk-N23UAW4I.js +59 -0
  154. package/dist/chunk-N254NRHT.cjs +30 -0
  155. package/dist/{chunk-TOTDRAWG.js → chunk-NDMIPTV4.js} +1 -1
  156. package/dist/{chunk-AIH6GUGB.cjs → chunk-NNPAM4HC.cjs} +5 -5
  157. package/dist/{chunk-HSPWX4Z2.cjs → chunk-O4IF4NJT.cjs} +231 -44
  158. package/dist/{chunk-DZHR34H6.cjs → chunk-OGV4WJ5L.cjs} +8 -8
  159. package/dist/chunk-OHUZKDGX.js +348 -0
  160. package/dist/{chunk-BRXIEKJ3.cjs → chunk-OLSBBZW6.cjs} +5 -5
  161. package/dist/{chunk-MILZEEUV.js → chunk-OOKY3HPZ.js} +9 -3
  162. package/dist/chunk-P47WPOXN.js +298 -0
  163. package/dist/{chunk-ULMPJUJW.cjs → chunk-PRRCJFU3.cjs} +23 -23
  164. package/dist/{chunk-SMHY3Q7B.cjs → chunk-Q7XSCYND.cjs} +54 -22
  165. package/dist/chunk-QCLYBIMM.cjs +51 -0
  166. package/dist/chunk-QMAKTSZB.cjs +48 -0
  167. package/dist/{chunk-DTFR3WD6.js → chunk-QNGEW5TC.js} +1 -1
  168. package/dist/chunk-QOXPOR5D.js +267 -0
  169. package/dist/chunk-R33VKSH5.cjs +348 -0
  170. package/dist/{chunk-RJP3SZ7Q.cjs → chunk-RD5XAJR2.cjs} +492 -309
  171. package/dist/chunk-RGR6ME5J.cjs +844 -0
  172. package/dist/{chunk-EOGKE5GD.cjs → chunk-RKJTGGMU.cjs} +221 -126
  173. package/dist/{chunk-GD4AFYJ3.js → chunk-RO6WYEWH.js} +24 -4
  174. package/dist/chunk-S52YW5ZQ.js +844 -0
  175. package/dist/{chunk-6DWXHBAY.js → chunk-SAHBLB3E.js} +222 -127
  176. package/dist/{chunk-JHOQABEF.js → chunk-SCXX4LW5.js} +5 -5
  177. package/dist/{chunk-GIZL57FE.cjs → chunk-SEKD5FH3.cjs} +3 -1
  178. package/dist/{chunk-JWPI6O5Z.js → chunk-SKV2F3NM.js} +31 -4
  179. package/dist/{chunk-FHUNAB2K.cjs → chunk-SKYG33B2.cjs} +33 -6
  180. package/dist/{chunk-BISFR6ZL.js → chunk-SLQAYV3W.js} +1 -1
  181. package/dist/{chunk-RFNCTE4V.cjs → chunk-SYVYLZZF.cjs} +2 -2
  182. package/dist/{chunk-3XJD56Z4.js → chunk-T73IDKDF.js} +10 -3
  183. package/dist/chunk-TBEGGJNC.cjs +310 -0
  184. package/dist/{chunk-RRZS5A53.js → chunk-TNZRZQ7Q.js} +1 -1
  185. package/dist/{chunk-CH4SPVFD.cjs → chunk-TXSDBGKX.cjs} +10 -3
  186. package/dist/chunk-U3WDY42C.cjs +42 -0
  187. package/dist/{chunk-425MT6Y5.cjs → chunk-U46VYPLR.cjs} +9 -9
  188. package/dist/{chunk-OLG7LZBD.js → chunk-VG34MG2U.js} +1 -1
  189. package/dist/{chunk-XDVG3NM4.js → chunk-W3X6PAC7.js} +2 -48
  190. package/dist/{chunk-LYMTYC67.js → chunk-WHE2SWHU.js} +2 -2
  191. package/dist/chunk-WM5PAOTQ.cjs +4498 -0
  192. package/dist/chunk-WNUVPKBW.js +42 -0
  193. package/dist/{chunk-EV53SLSB.cjs → chunk-WPVWQSL7.cjs} +4 -4
  194. package/dist/chunk-WQ3VJXZB.js +118 -0
  195. package/dist/{chunk-HMRDNRTH.js → chunk-X2MSVKDV.js} +2 -2
  196. package/dist/chunk-X3WS5LDG.js +504 -0
  197. package/dist/{chunk-43XS26AQ.cjs → chunk-X5VSP65C.cjs} +4 -4
  198. package/dist/{chunk-DSCQPWUB.cjs → chunk-X5YJ34FZ.cjs} +15 -15
  199. package/dist/chunk-XAV24VYN.js +48 -0
  200. package/dist/chunk-XDLH4EDL.cjs +118 -0
  201. package/dist/{chunk-X765A7J5.js → chunk-XRZEUWKF.js} +1 -1
  202. package/dist/{chunk-ZKZRFH37.cjs → chunk-XTB6VJVQ.cjs} +6 -6
  203. package/dist/{chunk-H3GBSPK5.js → chunk-XX2ZO7DS.js} +14 -6
  204. package/dist/{chunk-RUZB43HU.cjs → chunk-Y72HH2TF.cjs} +22 -14
  205. package/dist/chunk-YFXTE422.cjs +92 -0
  206. package/dist/{chunk-OSUWEUZE.js → chunk-YGN4CQIP.js} +1 -1
  207. package/dist/{chunk-KC5FPUOF.cjs → chunk-YRLYSQEQ.cjs} +2 -2
  208. package/dist/{chunk-3KBBARKO.js → chunk-YZXUDM5X.js} +85 -28
  209. package/dist/chunk-Z36XBUMX.cjs +83 -0
  210. package/dist/chunk-ZK6HOR62.js +92 -0
  211. package/dist/{chunk-PDKNHU5G.cjs → chunk-ZQE72E6W.cjs} +22 -16
  212. package/dist/chunk-ZVY2XD6T.js +1607 -0
  213. package/dist/{chunk-XBUMKEFN.cjs → chunk-ZYQMLKOK.cjs} +91 -34
  214. package/dist/clear-UO4MNWZW.cjs +12 -0
  215. package/dist/clear-ZJ5NYP6E.js +12 -0
  216. package/dist/communityInstaller-6KCFN7YZ.js +19 -0
  217. package/dist/communityInstaller-PVSOFDZD.cjs +19 -0
  218. package/dist/completion-MMF2PN2H.js +14 -0
  219. package/dist/completion-UI5WKHXI.cjs +14 -0
  220. package/dist/config-E7RINK4R.cjs +18 -0
  221. package/dist/config-ZN66VXPS.js +18 -0
  222. package/dist/constants-6CPCJ3DY.cjs +21 -0
  223. package/dist/{constants-V6J54N3X.js → constants-UFM5B232.js} +2 -1
  224. package/dist/{defaultHooks-WLMRQUXG.cjs → defaultHooks-RCXPHF4M.cjs} +3 -1
  225. package/dist/{defaultHooks-R56VYG7I.js → defaultHooks-RDRMER3Z.js} +2 -0
  226. package/dist/export-N4XIVDSL.cjs +12 -0
  227. package/dist/export-W22L4D5C.js +12 -0
  228. package/dist/extractSessionMemories-SDW2MVBQ.cjs +7 -0
  229. package/dist/extractSessionMemories-V7K42ZHW.js +7 -0
  230. package/dist/feedback-DR6ADSNE.cjs +15 -0
  231. package/dist/feedback-FEEAP4QW.js +15 -0
  232. package/dist/filesystem-3SGCW2BF.js +10 -0
  233. package/dist/filesystem-MCFXJQ6R.cjs +10 -0
  234. package/dist/formatters-6K7QVWQL.cjs +10 -0
  235. package/dist/formatters-DQHO5I36.js +10 -0
  236. package/dist/{help-LKKQU2TN.js → help-2BLR7L43.js} +3 -2
  237. package/dist/help-AQHGTS7P.cjs +12 -0
  238. package/dist/{history-AV4XBFRK.js → history-5FZ3M2AK.js} +3 -2
  239. package/dist/history-NIUDRMKA.cjs +14 -0
  240. package/dist/hooks-2EY4IPKV.js +13 -0
  241. package/dist/hooks-LJVORRIG.cjs +13 -0
  242. package/dist/i18n-ARDG2SMC.cjs +33 -0
  243. package/dist/{i18n-BSAPXM56.js → i18n-K7QOWIBH.js} +2 -1
  244. package/dist/ide-GFW6IJHD.js +12 -0
  245. package/dist/ide-N2ZNSSB3.cjs +12 -0
  246. package/dist/import-DFVN3KNZ.js +10 -0
  247. package/dist/import-QEME3E4T.cjs +170 -0
  248. package/dist/import-UXM3VK7B.js +170 -0
  249. package/dist/import-ZS6DPGU5.cjs +10 -0
  250. package/dist/index.cjs +11233 -11804
  251. package/dist/index.js +12594 -13165
  252. package/dist/init-PY75HA3S.cjs +10 -0
  253. package/dist/init-QNMWLAVY.js +10 -0
  254. package/dist/language-5UE4G2BT.cjs +18 -0
  255. package/dist/language-UXMHEZUJ.js +18 -0
  256. package/dist/learn-HJ3FLNZC.cjs +20 -0
  257. package/dist/learn-MVYS3RU5.js +20 -0
  258. package/dist/{lint-44UQJ673.cjs → lint-D5UOJWIK.cjs} +1 -0
  259. package/dist/{lint-TA2ZHVLM.js → lint-NJPZWVN2.js} +1 -0
  260. package/dist/{localProjectPermissions-WQYMGI42.js → localProjectPermissions-N77HA3XK.js} +3 -2
  261. package/dist/localProjectPermissions-UFSMNTBJ.cjs +18 -0
  262. package/dist/login-DSE7H63A.js +20 -0
  263. package/dist/login-V3MEWPKN.cjs +20 -0
  264. package/dist/logout-BMVCLKKW.js +18 -0
  265. package/dist/logout-XEG7FHOZ.cjs +18 -0
  266. package/dist/mcp-PYUR4PHO.js +18 -0
  267. package/dist/mcp-SG6JFLGC.cjs +18 -0
  268. package/dist/{mcp-install-2KVKRAMQ.cjs → mcp-install-G27HSS3Z.cjs} +26 -14
  269. package/dist/{mcp-install-77UXRN6R.js → mcp-install-VESN42PI.js} +21 -9
  270. package/dist/memory-4ZMMEZ2Z.js +10 -0
  271. package/dist/memory-QSGMVVGH.cjs +10 -0
  272. package/dist/message-JUBOK2VU.js +9 -0
  273. package/dist/message-ZJ5AYAMT.cjs +9 -0
  274. package/dist/model-NANLBZ4Z.cjs +10 -0
  275. package/dist/model-ZXNV4AF7.js +10 -0
  276. package/dist/new-5QJY5JP2.js +12 -0
  277. package/dist/new-PMMG55UX.cjs +12 -0
  278. package/dist/{patch-BAAQIYSW.js → patch-5F6VBIT3.js} +2 -0
  279. package/dist/{patch-J32X2QQP.cjs → patch-MOD7QC3D.cjs} +3 -1
  280. package/dist/permissions-LECTCJ4H.cjs +13 -0
  281. package/dist/permissions-VP5VGIBL.js +13 -0
  282. package/dist/{plan-JFGNRL2S.js → plan-G5CEKJI4.js} +1 -0
  283. package/dist/{plan-B3CW5DXJ.cjs → plan-QKOHE3LH.cjs} +1 -0
  284. package/dist/quit-BKOOPHU5.cjs +10 -0
  285. package/dist/quit-FVFNYACP.js +10 -0
  286. package/dist/registry-KWZGYJC2.js +2108 -0
  287. package/dist/registry-YN4FQPOO.cjs +2108 -0
  288. package/dist/resume-EXFQSQPH.js +13 -0
  289. package/dist/resume-PP2IQM5S.cjs +13 -0
  290. package/dist/search-C56FBN67.cjs +17 -0
  291. package/dist/search-XGZDYBF4.js +17 -0
  292. package/dist/{session-T3TAZ5ZU.cjs → session-BSU2L5UI.cjs} +1 -0
  293. package/dist/{session-H5QWKE5E.js → session-SZMRN5KG.js} +1 -0
  294. package/dist/sessions-54KI3F2Q.js +10 -0
  295. package/dist/sessions-DDTSPNVW.cjs +10 -0
  296. package/dist/settings-BDO37TTO.cjs +30 -0
  297. package/dist/settings-FHRDFPLK.js +30 -0
  298. package/dist/share-IERCTBGN.cjs +14 -0
  299. package/dist/share-TGROUE6R.js +14 -0
  300. package/dist/skills-6OL4OSGA.js +76 -0
  301. package/dist/skills-FYY6F2WV.cjs +76 -0
  302. package/dist/skills-OM4IGBAA.cjs +26 -0
  303. package/dist/skills-S3GRN323.js +26 -0
  304. package/dist/{skills-install-MQINL3EC.js → skills-install-6CSWC24P.js} +97 -26
  305. package/dist/{skills-install-IKJZN4G2.cjs → skills-install-O3LZ2ETC.cjs} +106 -35
  306. package/dist/skills-new-ALD2PTHN.js +15 -0
  307. package/dist/skills-new-PWLKK7GW.cjs +15 -0
  308. package/dist/slashCommands-L4ZD33LJ.js +75 -0
  309. package/dist/slashCommands-YY2VUUDF.cjs +75 -0
  310. package/dist/status-3PC5XWSS.cjs +11 -0
  311. package/dist/status-KCLVOYPD.js +11 -0
  312. package/dist/sync-6SDWG5RK.js +18 -0
  313. package/dist/sync-7JMZVEQD.cjs +40 -0
  314. package/dist/{sync-EXYX7HXW.js → sync-KWX67OUN.js} +3 -2
  315. package/dist/sync-WHURZL3U.cjs +18 -0
  316. package/dist/tasks-5FPBIFLC.js +9 -0
  317. package/dist/tasks-TXGKGNH6.cjs +9 -0
  318. package/dist/team-5YXP3JGR.js +9 -0
  319. package/dist/team-IIWEZKNR.cjs +9 -0
  320. package/dist/teammate-2KMKJXAM.cjs +139 -0
  321. package/dist/teammate-L6EZQ3I2.js +139 -0
  322. package/dist/theme-BE5A4FPN.cjs +18 -0
  323. package/dist/theme-YMFCQP7J.js +18 -0
  324. package/dist/ui/questionModal.cjs +7 -25
  325. package/dist/ui/questionModal.js +6 -24
  326. package/dist/undo-KZHUUZTD.cjs +10 -0
  327. package/dist/undo-NEIEHQVX.js +10 -0
  328. package/dist/update-TVAJMMBC.js +82 -0
  329. package/dist/update-Z6BIIQDC.cjs +82 -0
  330. package/package.json +10 -3
  331. package/dist/CommunitySkillsCache-ILWHWE5P.js +0 -7
  332. package/dist/CommunitySkillsCache-KHC6RUJW.cjs +0 -7
  333. package/dist/HookManager-X47HCM5G.cjs +0 -6
  334. package/dist/HookManager-ZXKHCD7U.js +0 -6
  335. package/dist/MemoryManager-6ZT7IDO5.cjs +0 -7
  336. package/dist/MemoryManager-AJGS5AKB.js +0 -7
  337. package/dist/PermissionManager-HG6W2DGU.cjs +0 -10
  338. package/dist/SessionManager-BJ2G6VV4.cjs +0 -9
  339. package/dist/SessionManager-ENPGYK5J.js +0 -9
  340. package/dist/SkillsRegistry-6ZFOCT25.cjs +0 -8
  341. package/dist/SkillsRegistry-C2SHOZ5D.js +0 -8
  342. package/dist/about-3BJTNSLK.js +0 -11
  343. package/dist/about-EABQNJGV.cjs +0 -11
  344. package/dist/add-dir-7FD4DMDA.cjs +0 -9
  345. package/dist/add-dir-LOYJ4YB5.js +0 -9
  346. package/dist/agents-2Y6ASV7C.js +0 -10
  347. package/dist/agents-UOSPKLQL.cjs +0 -10
  348. package/dist/agents-new-23NSGAM5.js +0 -13
  349. package/dist/agents-new-WI2EL7IJ.cjs +0 -13
  350. package/dist/automode-LGWTY3UX.js +0 -9
  351. package/dist/automode-WLBQ7MN7.cjs +0 -9
  352. package/dist/chunk-5UBW2BGC.js +0 -33
  353. package/dist/chunk-I6DBWNLN.cjs +0 -169
  354. package/dist/chunk-IZBCMJHJ.cjs +0 -33
  355. package/dist/completion-7WGMHKOR.cjs +0 -13
  356. package/dist/completion-KH33NSGP.js +0 -13
  357. package/dist/constants-RBQTR32A.cjs +0 -20
  358. package/dist/export-3QN3IH7A.js +0 -11
  359. package/dist/export-BI54X3MP.cjs +0 -11
  360. package/dist/feedback-CI4OIPOS.cjs +0 -14
  361. package/dist/feedback-GFPL5STE.js +0 -14
  362. package/dist/formatters-N5IJKYZY.cjs +0 -8
  363. package/dist/formatters-UG6VZJJ5.js +0 -8
  364. package/dist/help-CWMUGD3V.cjs +0 -11
  365. package/dist/history-73VBEMSI.cjs +0 -13
  366. package/dist/hooks-62UDQBGH.cjs +0 -12
  367. package/dist/hooks-XORDJD5X.js +0 -12
  368. package/dist/i18n-X2IU2EZD.cjs +0 -32
  369. package/dist/ide-RPKZALQV.js +0 -11
  370. package/dist/ide-YMNXJB6A.cjs +0 -11
  371. package/dist/init-J5HR4R7U.js +0 -9
  372. package/dist/init-JCC7RVMC.cjs +0 -9
  373. package/dist/language-AZISJCEZ.js +0 -16
  374. package/dist/language-F65RA6FZ.cjs +0 -16
  375. package/dist/localProjectPermissions-2EATUDZM.cjs +0 -17
  376. package/dist/login-5HLPMECE.js +0 -18
  377. package/dist/login-ISWYYBXP.cjs +0 -18
  378. package/dist/logout-3EKZM5J3.cjs +0 -16
  379. package/dist/logout-GE7TSZ24.js +0 -16
  380. package/dist/mcp-EW64QRFA.cjs +0 -15
  381. package/dist/mcp-VHS7AMF2.js +0 -15
  382. package/dist/memory-2I473RU3.js +0 -9
  383. package/dist/memory-JZ6NPSP3.cjs +0 -9
  384. package/dist/model-GXZLARPT.js +0 -9
  385. package/dist/model-Y274DBDO.cjs +0 -9
  386. package/dist/new-BG5VIGZ7.cjs +0 -9
  387. package/dist/new-YXFDQOA7.js +0 -9
  388. package/dist/permissions-QILEAGBP.cjs +0 -12
  389. package/dist/permissions-WVEOVMWO.js +0 -12
  390. package/dist/quit-NC32OEJG.cjs +0 -9
  391. package/dist/quit-WRRIGU33.js +0 -9
  392. package/dist/resume-GJIKIDPR.cjs +0 -12
  393. package/dist/resume-RMJNCAOK.js +0 -12
  394. package/dist/search-UIWIXB73.js +0 -14
  395. package/dist/search-WQNXDA2E.cjs +0 -14
  396. package/dist/sessions-HPFX2GDD.js +0 -9
  397. package/dist/sessions-SAQU6MFA.cjs +0 -9
  398. package/dist/share-2WH5ZVOO.cjs +0 -13
  399. package/dist/share-PSSWWVV5.js +0 -13
  400. package/dist/skills-LJZA6PVJ.js +0 -13
  401. package/dist/skills-YTYGART7.cjs +0 -13
  402. package/dist/skills-new-3WCU3CWB.js +0 -14
  403. package/dist/skills-new-O5LFVFZU.cjs +0 -14
  404. package/dist/slashCommands-7IRDOXOQ.cjs +0 -55
  405. package/dist/slashCommands-C6CAQA25.js +0 -55
  406. package/dist/status-4EDV2LSY.cjs +0 -10
  407. package/dist/status-NU7TJDCE.js +0 -10
  408. package/dist/sync-3GFSEIAZ.js +0 -16
  409. package/dist/sync-6M3WRKMH.cjs +0 -39
  410. package/dist/sync-CQNQDNTJ.cjs +0 -16
  411. package/dist/theme-EMJGULMI.cjs +0 -16
  412. package/dist/theme-FGDSXNU3.js +0 -16
  413. package/dist/undo-CTXQYE7C.cjs +0 -9
  414. package/dist/undo-HX2ZMECP.js +0 -9
@@ -0,0 +1,1838 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkBVKXEQVGcjs = require('./chunk-BVKXEQVG.cjs');
4
+
5
+
6
+ var _chunkCNBKZEX5cjs = require('./chunk-CNBKZEX5.cjs');
7
+
8
+
9
+ var _chunkULQ6MDSJcjs = require('./chunk-ULQ6MDSJ.cjs');
10
+
11
+ // src/core/agents/SubAgent.ts
12
+ var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
13
+
14
+ // src/core/toolFilter.ts
15
+ var TOOL_CATEGORIES = {
16
+ // Meta tools
17
+ tools_registry: "meta",
18
+ plan: "meta",
19
+ todo_write: "meta",
20
+ smart_context_cropper: "meta",
21
+ save_memory: "meta",
22
+ recall_memory: "meta",
23
+ create_meta_tool: "meta",
24
+ delegate_task: "meta",
25
+ delegate_parallel: "meta",
26
+ create_team: "meta",
27
+ add_teammate: "meta",
28
+ create_task: "meta",
29
+ team_status: "meta",
30
+ send_team_message: "meta",
31
+ ask_followup_question: "meta",
32
+ // Read operations
33
+ read_file: "read",
34
+ search: "read",
35
+ search_with_context: "read",
36
+ semantic_search: "read",
37
+ list_tree: "read",
38
+ file_stats: "read",
39
+ checksum: "read",
40
+ // Write operations
41
+ write_file: "write",
42
+ append_file: "write",
43
+ apply_patch: "write",
44
+ search_replace: "write",
45
+ format_file: "write",
46
+ multi_file_edit: "write",
47
+ // Create operations
48
+ create_directory: "create",
49
+ copy_path: "create",
50
+ rename_path: "create",
51
+ add_dependency: "create",
52
+ // Delete operations
53
+ delete_path: "delete",
54
+ remove_dependency: "delete",
55
+ // Git read operations
56
+ git_diff: "git_read",
57
+ git_status: "git_read",
58
+ git_list_untracked: "git_read",
59
+ git_diff_range: "git_read",
60
+ git_stash_list: "git_read",
61
+ git_branch: "git_read",
62
+ git_log: "git_read",
63
+ git_worktree_list: "git_read",
64
+ git_worktree_status_all: "git_read",
65
+ // Git write operations
66
+ git_checkout: "git_write",
67
+ git_apply_patch: "git_write",
68
+ git_worktree_add: "git_write",
69
+ git_worktree_remove: "git_write",
70
+ git_worktree_cleanup: "git_write",
71
+ git_worktree_run_parallel: "git_write",
72
+ git_worktree_sync: "git_write",
73
+ git_worktree_create_for_pr: "git_write",
74
+ git_worktree_create_from_template: "git_write",
75
+ git_stash: "git_write",
76
+ git_stash_pop: "git_write",
77
+ git_stash_apply: "git_write",
78
+ git_stash_drop: "git_write",
79
+ git_switch: "git_write",
80
+ git_cherry_pick: "git_write",
81
+ git_cherry_pick_abort: "git_write",
82
+ git_cherry_pick_continue: "git_write",
83
+ git_rebase: "git_write",
84
+ git_rebase_abort: "git_write",
85
+ git_rebase_continue: "git_write",
86
+ git_rebase_skip: "git_write",
87
+ git_merge: "git_write",
88
+ git_merge_abort: "git_write",
89
+ git_commit: "git_write",
90
+ git_add: "git_write",
91
+ git_reset: "git_write",
92
+ git_fetch: "git_write",
93
+ git_pull: "git_write",
94
+ git_push: "git_write",
95
+ // Shell operations
96
+ run_command: "shell",
97
+ custom_command: "shell"
98
+ };
99
+ var CONTEXT_POLICIES = {
100
+ // CLI: Full access to everything
101
+ cli: {
102
+ allowedCategories: ["read", "write", "create", "delete", "git_read", "git_write", "shell", "meta"]
103
+ },
104
+ // Slack: Chat-based, no file exploration or shell access
105
+ // Focuses on answering questions and simple operations
106
+ slack: {
107
+ allowedCategories: ["meta", "git_read"],
108
+ blockedTools: [
109
+ "list_tree",
110
+ // Don't expose directory structure
111
+ "search",
112
+ // Don't allow broad searches
113
+ "search_with_context",
114
+ // Don't allow broad searches
115
+ "semantic_search",
116
+ // Don't allow broad searches
117
+ "run_command",
118
+ // No shell access
119
+ "custom_command",
120
+ // No shell access
121
+ "file_stats",
122
+ // Don't expose file metadata
123
+ "checksum",
124
+ // Don't expose file checksums
125
+ "ask_followup_question"
126
+ // Requires interactive terminal
127
+ ]
128
+ },
129
+ // API: Programmatic access with sensible defaults
130
+ // Allows most operations except dangerous ones
131
+ api: {
132
+ allowedCategories: ["read", "write", "create", "git_read", "git_write", "meta"],
133
+ blockedTools: [
134
+ "delete_path",
135
+ // No deletions via API
136
+ "run_command",
137
+ // No shell access
138
+ "custom_command",
139
+ // No shell access
140
+ "git_push",
141
+ // No pushing via API
142
+ "git_reset",
143
+ // No resets via API
144
+ "ask_followup_question"
145
+ // Requires interactive terminal
146
+ ],
147
+ requireApprovalFor: [
148
+ "git_commit",
149
+ "git_merge",
150
+ "git_rebase"
151
+ ]
152
+ },
153
+ // Restricted: Read-only mode
154
+ restricted: {
155
+ allowedCategories: ["read", "git_read", "meta"],
156
+ blockedTools: [
157
+ "list_tree",
158
+ // Even in read mode, don't expose full structure
159
+ "ask_followup_question"
160
+ // Requires interactive terminal (may be running in restricted non-interactive mode)
161
+ ]
162
+ }
163
+ };
164
+ function getToolCategory(toolName) {
165
+ return _nullishCoalesce(TOOL_CATEGORIES[toolName], () => ( "meta"));
166
+ }
167
+ var ToolFilter = class {
168
+ constructor(context = "cli", customPolicy) {
169
+ this.context = context;
170
+ const basePolicy = CONTEXT_POLICIES[context];
171
+ this.policy = {
172
+ ...basePolicy,
173
+ ...customPolicy,
174
+ allowedCategories: _nullishCoalesce(_optionalChain([customPolicy, 'optionalAccess', _ => _.allowedCategories]), () => ( basePolicy.allowedCategories)),
175
+ blockedTools: [
176
+ ..._nullishCoalesce(basePolicy.blockedTools, () => ( [])),
177
+ ..._nullishCoalesce(_optionalChain([customPolicy, 'optionalAccess', _2 => _2.blockedTools]), () => ( []))
178
+ ],
179
+ allowedTools: _optionalChain([customPolicy, 'optionalAccess', _3 => _3.allowedTools]),
180
+ requireApprovalFor: [
181
+ ..._nullishCoalesce(basePolicy.requireApprovalFor, () => ( [])),
182
+ ..._nullishCoalesce(_optionalChain([customPolicy, 'optionalAccess', _4 => _4.requireApprovalFor]), () => ( []))
183
+ ]
184
+ };
185
+ }
186
+ /**
187
+ * Check if a tool is allowed in the current context
188
+ */
189
+ isAllowed(toolName) {
190
+ if (this.policy.allowedTools && this.policy.allowedTools.length > 0) {
191
+ return this.policy.allowedTools.includes(toolName);
192
+ }
193
+ if (_optionalChain([this, 'access', _5 => _5.policy, 'access', _6 => _6.blockedTools, 'optionalAccess', _7 => _7.includes, 'call', _8 => _8(toolName)])) {
194
+ return false;
195
+ }
196
+ const category = getToolCategory(toolName);
197
+ return this.policy.allowedCategories.includes(category);
198
+ }
199
+ /**
200
+ * Check if a tool requires approval (beyond its default setting)
201
+ */
202
+ requiresApproval(toolName, defaultRequiresApproval) {
203
+ if (_optionalChain([this, 'access', _9 => _9.policy, 'access', _10 => _10.requireApprovalFor, 'optionalAccess', _11 => _11.includes, 'call', _12 => _12(toolName)])) {
204
+ return true;
205
+ }
206
+ return _nullishCoalesce(defaultRequiresApproval, () => ( false));
207
+ }
208
+ /**
209
+ * Filter a list of tool definitions
210
+ */
211
+ filterDefinitions(definitions) {
212
+ return definitions.filter((def) => this.isAllowed(def.name)).map((def) => ({
213
+ ...def,
214
+ requiresApproval: this.requiresApproval(def.name, def.requiresApproval)
215
+ }));
216
+ }
217
+ /**
218
+ * Get the current context
219
+ */
220
+ getContext() {
221
+ return this.context;
222
+ }
223
+ /**
224
+ * Get a summary of what's allowed/blocked for logging
225
+ */
226
+ getSummary() {
227
+ const allTools = Object.keys(TOOL_CATEGORIES);
228
+ const allowed = allTools.filter((t) => this.isAllowed(t));
229
+ const blocked = allTools.filter((t) => !this.isAllowed(t));
230
+ return {
231
+ allowed,
232
+ blocked,
233
+ categories: this.policy.allowedCategories
234
+ };
235
+ }
236
+ };
237
+ var RELEVANCE_CATEGORIES = {
238
+ // Always include
239
+ read_file: "always",
240
+ write_file: "always",
241
+ search: "always",
242
+ list_tree: "always",
243
+ plan: "always",
244
+ run_command: "always",
245
+ todo_write: "always",
246
+ // Filesystem
247
+ append_file: "filesystem",
248
+ apply_patch: "filesystem",
249
+ create_directory: "filesystem",
250
+ delete_path: "filesystem",
251
+ rename_path: "filesystem",
252
+ copy_path: "filesystem",
253
+ search_replace: "filesystem",
254
+ format_file: "filesystem",
255
+ file_stats: "filesystem",
256
+ checksum: "filesystem",
257
+ multi_file_edit: "filesystem",
258
+ search_with_context: "search",
259
+ semantic_search: "search",
260
+ // Basic git
261
+ git_diff: "git_basic",
262
+ git_status: "git_basic",
263
+ git_list_untracked: "git_basic",
264
+ git_add: "git_basic",
265
+ git_commit: "git_basic",
266
+ git_log: "git_basic",
267
+ git_branch: "git_basic",
268
+ git_switch: "git_basic",
269
+ git_checkout: "git_basic",
270
+ git_diff_range: "git_basic",
271
+ git_apply_patch: "git_basic",
272
+ git_fetch: "git_basic",
273
+ git_pull: "git_basic",
274
+ git_push: "git_basic",
275
+ git_stash: "git_basic",
276
+ git_stash_list: "git_basic",
277
+ git_stash_pop: "git_basic",
278
+ git_stash_apply: "git_basic",
279
+ git_stash_drop: "git_basic",
280
+ // Advanced git
281
+ git_merge: "git_advanced",
282
+ git_merge_abort: "git_advanced",
283
+ git_rebase: "git_advanced",
284
+ git_rebase_abort: "git_advanced",
285
+ git_rebase_continue: "git_advanced",
286
+ git_rebase_skip: "git_advanced",
287
+ git_cherry_pick: "git_advanced",
288
+ git_cherry_pick_abort: "git_advanced",
289
+ git_cherry_pick_continue: "git_advanced",
290
+ git_reset: "git_advanced",
291
+ git_worktree_list: "git_advanced",
292
+ git_worktree_add: "git_advanced",
293
+ git_worktree_remove: "git_advanced",
294
+ git_worktree_status_all: "git_advanced",
295
+ git_worktree_cleanup: "git_advanced",
296
+ git_worktree_run_parallel: "git_advanced",
297
+ git_worktree_sync: "git_advanced",
298
+ git_worktree_create_for_pr: "git_advanced",
299
+ git_worktree_create_from_template: "git_advanced",
300
+ // Dependencies
301
+ add_dependency: "dependencies",
302
+ remove_dependency: "dependencies",
303
+ // Meta
304
+ tools_registry: "meta",
305
+ save_memory: "meta",
306
+ recall_memory: "meta",
307
+ smart_context_cropper: "meta",
308
+ create_meta_tool: "meta",
309
+ custom_command: "meta",
310
+ delegate_task: "meta",
311
+ delegate_parallel: "meta",
312
+ create_team: "meta",
313
+ add_teammate: "meta",
314
+ create_task: "meta",
315
+ team_status: "meta",
316
+ send_team_message: "meta",
317
+ ask_followup_question: "always",
318
+ // User interaction should always be available when in interactive mode
319
+ find_agent_skills: "always"
320
+ // Skill search should always be available so the LLM can explore community skills
321
+ };
322
+ var CATEGORY_TRIGGERS = {
323
+ always: [],
324
+ filesystem: ["file", "directory", "folder", "create", "delete", "rename", "copy", "move", "format", "edit"],
325
+ git_basic: ["git", "commit", "branch", "diff", "status", "stash", "pull", "push"],
326
+ git_advanced: ["merge", "rebase", "cherry-pick", "worktree", "reset"],
327
+ search: ["search", "find", "grep", "look for", "locate", "where is"],
328
+ dependencies: ["dependency", "dependencies", "package", "npm", "install", "yarn", "bun add"],
329
+ meta: [
330
+ "tool",
331
+ "delegate",
332
+ "agent",
333
+ "remember",
334
+ "memory",
335
+ "recall",
336
+ "team",
337
+ "teammate",
338
+ "together",
339
+ "engineers",
340
+ "crew",
341
+ "collaborate"
342
+ ]
343
+ };
344
+ function detectRelevantCategories(messages) {
345
+ const categories = /* @__PURE__ */ new Set(["always"]);
346
+ const recentMessages = messages.slice(-8);
347
+ const recentText = recentMessages.map((m) => _nullishCoalesce(m.content, () => ( ""))).join(" ").toLowerCase();
348
+ for (const [category, triggers] of Object.entries(CATEGORY_TRIGGERS)) {
349
+ if (triggers.some((trigger) => recentText.includes(trigger))) {
350
+ categories.add(category);
351
+ }
352
+ }
353
+ for (const msg of recentMessages) {
354
+ if (msg.tool_calls) {
355
+ for (const call of msg.tool_calls) {
356
+ const category = RELEVANCE_CATEGORIES[call.function.name];
357
+ if (category) {
358
+ categories.add(category);
359
+ }
360
+ }
361
+ }
362
+ if (msg.role === "tool" && msg.name) {
363
+ const category = RELEVANCE_CATEGORIES[msg.name];
364
+ if (category) {
365
+ categories.add(category);
366
+ }
367
+ }
368
+ }
369
+ return categories;
370
+ }
371
+ function filterToolsByRelevance(tools, messages) {
372
+ const relevantCategories = detectRelevantCategories(messages);
373
+ return tools.filter((tool) => {
374
+ const category = RELEVANCE_CATEGORIES[tool.name];
375
+ return !category || relevantCategories.has(category);
376
+ });
377
+ }
378
+
379
+ // src/core/toolManager.ts
380
+ var DEFAULT_TOOL_DEFINITIONS = [
381
+ {
382
+ name: "tools_registry",
383
+ description: "List all available tools (built-in and meta)"
384
+ },
385
+ {
386
+ name: "plan",
387
+ description: 'Create a structured implementation plan with detailed numbered steps before executing a task. Always break the task into concrete, actionable steps (e.g. "1. Read existing auth code\\n2. Create JWT utility module\\n3. Add login endpoint"). Each step should be a single clear action. Aim for 3-10 steps depending on complexity.',
388
+ parameters: {
389
+ type: "object",
390
+ properties: {
391
+ notes: {
392
+ type: "string",
393
+ description: 'A numbered step-by-step plan. Each step on its own line starting with "N. " (e.g. "1. Read existing code\\n2. Create new module\\n3. Write tests"). Be specific and actionable - avoid single vague descriptions.'
394
+ }
395
+ }
396
+ }
397
+ },
398
+ {
399
+ name: "ask_followup_question",
400
+ description: "Ask the user a follow-up question to gather clarification or preferences. Use when you need specific information to proceed. Include suggested answers when possible to guide the response. Only available in interactive and plan mode.",
401
+ parameters: {
402
+ type: "object",
403
+ properties: {
404
+ question: { type: "string", description: "The specific question to ask the user" },
405
+ suggested_answers: {
406
+ type: "array",
407
+ description: "Optional list of 2-4 suggested answers to guide the user response",
408
+ items: { type: "string", description: "A suggested answer option" }
409
+ }
410
+ },
411
+ required: ["question"]
412
+ },
413
+ requiresApproval: false
414
+ // User interaction, not a mutation
415
+ },
416
+ {
417
+ name: "read_file",
418
+ description: "Read file contents. For large files (>2500 lines), use offset and limit to read in chunks.",
419
+ parameters: {
420
+ type: "object",
421
+ properties: {
422
+ path: { type: "string", description: "Relative path to the file to read" },
423
+ offset: { type: "number", description: "Line number to start reading from (0-indexed). Use for large files." },
424
+ limit: { type: "number", description: "Maximum number of lines to read. Use for large files." }
425
+ },
426
+ required: ["path"]
427
+ }
428
+ },
429
+ {
430
+ name: "write_file",
431
+ description: "Write full contents to a file",
432
+ parameters: {
433
+ type: "object",
434
+ properties: {
435
+ path: { type: "string", description: "Relative path to the file" },
436
+ contents: { type: "string", description: "Full file contents to write" }
437
+ },
438
+ required: ["path", "contents"]
439
+ }
440
+ },
441
+ {
442
+ name: "append_file",
443
+ description: "Append text to a file",
444
+ parameters: {
445
+ type: "object",
446
+ properties: {
447
+ path: { type: "string", description: "Relative path to the file" },
448
+ contents: { type: "string", description: "Text to append" }
449
+ },
450
+ required: ["path", "contents"]
451
+ }
452
+ },
453
+ {
454
+ name: "apply_patch",
455
+ description: "Apply a unified diff to a file",
456
+ parameters: {
457
+ type: "object",
458
+ properties: {
459
+ path: { type: "string", description: "Relative path to the file" },
460
+ patch: { type: "string", description: "Unified diff patch content" }
461
+ },
462
+ required: ["path", "patch"]
463
+ }
464
+ },
465
+ {
466
+ name: "search",
467
+ description: "Search workspace text",
468
+ parameters: {
469
+ type: "object",
470
+ properties: {
471
+ query: { type: "string", description: "Text to search for" },
472
+ path: { type: "string", description: "Optional relative path to search in" }
473
+ },
474
+ required: ["query"]
475
+ }
476
+ },
477
+ {
478
+ name: "search_with_context",
479
+ description: "Search workspace text with surrounding context",
480
+ parameters: {
481
+ type: "object",
482
+ properties: {
483
+ query: { type: "string", description: "Text to search for" },
484
+ path: { type: "string", description: "Optional relative path to search in" },
485
+ context: { type: "number", description: "Number of context lines (default 2)" },
486
+ limit: { type: "number", description: "Maximum results (default 10)" }
487
+ },
488
+ required: ["query"]
489
+ }
490
+ },
491
+ {
492
+ name: "semantic_search",
493
+ description: "Search workspace text semantically with gitignore awareness",
494
+ parameters: {
495
+ type: "object",
496
+ properties: {
497
+ query: { type: "string", description: "Text to search for" },
498
+ path: { type: "string", description: "Optional relative path to search in" },
499
+ limit: { type: "number", description: "Maximum results (default 5)" },
500
+ window: { type: "number", description: "Context window size (default 400)" }
501
+ },
502
+ required: ["query"]
503
+ }
504
+ },
505
+ {
506
+ name: "create_directory",
507
+ description: "Create a directory",
508
+ parameters: {
509
+ type: "object",
510
+ properties: {
511
+ path: { type: "string", description: "Relative path for new directory" }
512
+ },
513
+ required: ["path"]
514
+ }
515
+ },
516
+ {
517
+ name: "delete_path",
518
+ description: "Remove files or directories from the workspace",
519
+ parameters: {
520
+ type: "object",
521
+ properties: {
522
+ path: { type: "string", description: "Relative path to delete" }
523
+ },
524
+ required: ["path"]
525
+ },
526
+ requiresApproval: true
527
+ },
528
+ {
529
+ name: "rename_path",
530
+ description: "Rename a file or directory",
531
+ parameters: {
532
+ type: "object",
533
+ properties: {
534
+ from: { type: "string", description: "Current relative path" },
535
+ to: { type: "string", description: "New relative path" }
536
+ },
537
+ required: ["from", "to"]
538
+ }
539
+ },
540
+ {
541
+ name: "copy_path",
542
+ description: "Copy a file or directory",
543
+ parameters: {
544
+ type: "object",
545
+ properties: {
546
+ from: { type: "string", description: "Source relative path" },
547
+ to: { type: "string", description: "Destination relative path" }
548
+ },
549
+ required: ["from", "to"]
550
+ }
551
+ },
552
+ {
553
+ name: "search_replace",
554
+ description: "Apply precise text replacements using SEARCH/REPLACE blocks. SEARCH must match exactly. Multiple blocks applied in sequence.",
555
+ parameters: {
556
+ type: "object",
557
+ properties: {
558
+ path: { type: "string", description: "File path" },
559
+ blocks: { type: "string", description: "SEARCH/REPLACE block content" }
560
+ },
561
+ required: ["path", "blocks"]
562
+ }
563
+ },
564
+ {
565
+ name: "run_command",
566
+ description: "Execute shell commands with optional directory, background mode, and description. Prefer dedicated tools: read_file over cat, search over grep, search_replace over sed.",
567
+ parameters: {
568
+ type: "object",
569
+ properties: {
570
+ command: { type: "string", description: "Command to execute" },
571
+ args: { type: "array", description: "Command arguments", items: { type: "string", description: "Single argument" } },
572
+ directory: { type: "string", description: "Directory relative to workspace root to execute in" },
573
+ description: { type: "string", description: "Brief description of what this command does (shown to user)" },
574
+ background: { type: "boolean", description: "Run process in background (returns PID, useful for dev servers)" }
575
+ },
576
+ required: ["command"]
577
+ },
578
+ requiresApproval: true,
579
+ approvalMessage: "Allow the agent to run a shell command?"
580
+ },
581
+ {
582
+ name: "add_dependency",
583
+ description: "Add a package dependency (supports dev flag)",
584
+ parameters: {
585
+ type: "object",
586
+ properties: {
587
+ name: { type: "string", description: "Package name" },
588
+ version: { type: "string", description: "Version specifier" },
589
+ dev: { type: "boolean", description: "Install as dev dependency" }
590
+ },
591
+ required: ["name"]
592
+ }
593
+ },
594
+ {
595
+ name: "remove_dependency",
596
+ description: "Remove a package dependency (supports dev flag)",
597
+ parameters: {
598
+ type: "object",
599
+ properties: {
600
+ name: { type: "string", description: "Package name" },
601
+ dev: { type: "boolean", description: "Remove from dev dependencies" }
602
+ },
603
+ required: ["name"]
604
+ }
605
+ },
606
+ {
607
+ name: "format_file",
608
+ description: "Format a file with a named formatter",
609
+ parameters: {
610
+ type: "object",
611
+ properties: {
612
+ path: { type: "string", description: "Relative path to the file" },
613
+ formatter: { type: "string", description: "Formatter name (prettier, eslint, etc.)" }
614
+ },
615
+ required: ["path", "formatter"]
616
+ }
617
+ },
618
+ {
619
+ name: "list_tree",
620
+ description: "List a directory tree for the workspace",
621
+ parameters: {
622
+ type: "object",
623
+ properties: {
624
+ path: { type: "string", description: "Relative path (default: workspace root)" },
625
+ depth: { type: "number", description: "Maximum depth (default: 2)" }
626
+ }
627
+ }
628
+ },
629
+ {
630
+ name: "file_stats",
631
+ description: "Return file statistics and metadata",
632
+ parameters: {
633
+ type: "object",
634
+ properties: {
635
+ path: { type: "string", description: "Relative path to the file" }
636
+ },
637
+ required: ["path"]
638
+ }
639
+ },
640
+ {
641
+ name: "checksum",
642
+ description: "Compute a checksum for a file",
643
+ parameters: {
644
+ type: "object",
645
+ properties: {
646
+ path: { type: "string", description: "Relative path to the file" },
647
+ algorithm: { type: "string", description: "Hash algorithm (default: sha256)" }
648
+ },
649
+ required: ["path"]
650
+ }
651
+ },
652
+ {
653
+ name: "git_diff",
654
+ description: "Show git diff for a file",
655
+ parameters: {
656
+ type: "object",
657
+ properties: {
658
+ path: { type: "string", description: "Relative path to the file" }
659
+ },
660
+ required: ["path"]
661
+ }
662
+ },
663
+ {
664
+ name: "git_checkout",
665
+ description: "Restore a file from git",
666
+ parameters: {
667
+ type: "object",
668
+ properties: {
669
+ path: { type: "string", description: "Relative path to the file" }
670
+ },
671
+ required: ["path"]
672
+ }
673
+ },
674
+ {
675
+ name: "git_status",
676
+ description: "Show git status for the workspace"
677
+ },
678
+ {
679
+ name: "git_list_untracked",
680
+ description: "List untracked git files"
681
+ },
682
+ {
683
+ name: "git_diff_range",
684
+ description: "Show git diff for a range or staged files",
685
+ parameters: {
686
+ type: "object",
687
+ properties: {
688
+ range: { type: "string", description: "Commit range (e.g., HEAD~3..HEAD)" },
689
+ staged: { type: "boolean", description: "Show staged changes only" },
690
+ paths: { type: "array", description: "Specific paths to diff", items: { type: "string", description: "Path to diff" } }
691
+ }
692
+ }
693
+ },
694
+ {
695
+ name: "git_apply_patch",
696
+ description: "Apply a git patch to the working tree",
697
+ parameters: {
698
+ type: "object",
699
+ properties: {
700
+ patch: { type: "string", description: "Git patch content" }
701
+ },
702
+ required: ["patch"]
703
+ },
704
+ requiresApproval: true
705
+ },
706
+ {
707
+ name: "git_worktree_list",
708
+ description: "List git worktrees"
709
+ },
710
+ {
711
+ name: "git_worktree_add",
712
+ description: "Add a git worktree (may modify git state)",
713
+ parameters: {
714
+ type: "object",
715
+ properties: {
716
+ path: { type: "string", description: "Path for the new worktree" },
717
+ ref: { type: "string", description: "Branch or commit to checkout" }
718
+ },
719
+ required: ["path"]
720
+ },
721
+ requiresApproval: true
722
+ },
723
+ {
724
+ name: "git_worktree_remove",
725
+ description: "Remove a git worktree",
726
+ parameters: {
727
+ type: "object",
728
+ properties: {
729
+ path: { type: "string", description: "Path of the worktree to remove" },
730
+ force: { type: "boolean", description: "Force removal" }
731
+ },
732
+ required: ["path"]
733
+ },
734
+ requiresApproval: true
735
+ },
736
+ {
737
+ name: "git_worktree_status_all",
738
+ description: "Get comprehensive status of all worktrees (changes, commits, sync state)"
739
+ },
740
+ {
741
+ name: "git_worktree_cleanup",
742
+ description: "Find and clean up stale/merged worktrees",
743
+ parameters: {
744
+ type: "object",
745
+ properties: {
746
+ dry_run: { type: "boolean", description: "Preview without removing" },
747
+ remove_merged: { type: "boolean", description: "Remove merged branches" },
748
+ remove_stale: { type: "boolean", description: "Remove stale worktrees" }
749
+ }
750
+ },
751
+ requiresApproval: true
752
+ },
753
+ {
754
+ name: "git_worktree_run_parallel",
755
+ description: "Run a command in parallel across all worktrees",
756
+ parameters: {
757
+ type: "object",
758
+ properties: {
759
+ command: { type: "string", description: "Command to run" },
760
+ timeout: { type: "number", description: "Timeout in ms" },
761
+ max_concurrent: { type: "number", description: "Max parallel executions" }
762
+ },
763
+ required: ["command"]
764
+ },
765
+ requiresApproval: true
766
+ },
767
+ {
768
+ name: "git_worktree_sync",
769
+ description: "Sync changes from main branch to all worktrees (rebase or merge)",
770
+ parameters: {
771
+ type: "object",
772
+ properties: {
773
+ strategy: { type: "string", description: "Sync strategy: rebase or merge" },
774
+ main_branch: { type: "string", description: "Main branch name" },
775
+ dry_run: { type: "boolean", description: "Preview without syncing" }
776
+ }
777
+ },
778
+ requiresApproval: true
779
+ },
780
+ {
781
+ name: "git_worktree_create_for_pr",
782
+ description: "Create a worktree for reviewing a specific PR",
783
+ parameters: {
784
+ type: "object",
785
+ properties: {
786
+ pr_number: { type: "number", description: "PR number" },
787
+ remote: { type: "string", description: "Remote name (default: origin)" }
788
+ },
789
+ required: ["pr_number"]
790
+ },
791
+ requiresApproval: true
792
+ },
793
+ {
794
+ name: "git_worktree_create_from_template",
795
+ description: "Create a worktree using a template (feature, hotfix, release, review, experiment)",
796
+ parameters: {
797
+ type: "object",
798
+ properties: {
799
+ template: { type: "string", description: "Template name" },
800
+ branch: { type: "string", description: "Branch name for the worktree" },
801
+ base_branch: { type: "string", description: "Base branch to branch from" },
802
+ run_setup: { type: "boolean", description: "Run setup commands" }
803
+ },
804
+ required: ["template", "branch"]
805
+ },
806
+ requiresApproval: true
807
+ },
808
+ {
809
+ name: "git_stash",
810
+ description: "Stash current changes (supports message, include-untracked, keep-index)",
811
+ parameters: {
812
+ type: "object",
813
+ properties: {
814
+ message: { type: "string", description: "Stash message" },
815
+ include_untracked: { type: "boolean", description: "Include untracked files" },
816
+ keep_index: { type: "boolean", description: "Keep staged changes" }
817
+ }
818
+ }
819
+ },
820
+ {
821
+ name: "git_stash_list",
822
+ description: "List all stashed changes"
823
+ },
824
+ {
825
+ name: "git_stash_pop",
826
+ description: "Apply and remove the most recent stash (or specified stash)",
827
+ parameters: {
828
+ type: "object",
829
+ properties: {
830
+ stash_ref: { type: "string", description: "Stash reference (e.g., stash@{0})" }
831
+ }
832
+ },
833
+ requiresApproval: true
834
+ },
835
+ {
836
+ name: "git_stash_apply",
837
+ description: "Apply a stash without removing it",
838
+ parameters: {
839
+ type: "object",
840
+ properties: {
841
+ stash_ref: { type: "string", description: "Stash reference (e.g., stash@{0})" }
842
+ }
843
+ }
844
+ },
845
+ {
846
+ name: "git_stash_drop",
847
+ description: "Drop a stash entry",
848
+ parameters: {
849
+ type: "object",
850
+ properties: {
851
+ stash_ref: { type: "string", description: "Stash reference (e.g., stash@{0})" }
852
+ }
853
+ },
854
+ requiresApproval: true
855
+ },
856
+ {
857
+ name: "git_branch",
858
+ description: "List or create/delete branches",
859
+ parameters: {
860
+ type: "object",
861
+ properties: {
862
+ branch_name: { type: "string", description: "Branch name (omit to list)" },
863
+ delete: { type: "boolean", description: "Delete the branch" },
864
+ force: { type: "boolean", description: "Force delete" }
865
+ }
866
+ }
867
+ },
868
+ {
869
+ name: "git_switch",
870
+ description: "Switch to a branch (can create with -c flag)",
871
+ parameters: {
872
+ type: "object",
873
+ properties: {
874
+ branch_name: { type: "string", description: "Branch to switch to" },
875
+ create: { type: "boolean", description: "Create new branch" }
876
+ },
877
+ required: ["branch_name"]
878
+ }
879
+ },
880
+ {
881
+ name: "git_cherry_pick",
882
+ description: "Cherry-pick commits onto current branch",
883
+ parameters: {
884
+ type: "object",
885
+ properties: {
886
+ commits: { type: "array", description: "Commit SHAs to cherry-pick", items: { type: "string", description: "Commit SHA" } },
887
+ no_commit: { type: "boolean", description: "Apply without committing" },
888
+ mainline: { type: "number", description: "Parent number for merge commits" }
889
+ },
890
+ required: ["commits"]
891
+ },
892
+ requiresApproval: true
893
+ },
894
+ {
895
+ name: "git_cherry_pick_abort",
896
+ description: "Abort an in-progress cherry-pick"
897
+ },
898
+ {
899
+ name: "git_cherry_pick_continue",
900
+ description: "Continue an in-progress cherry-pick after resolving conflicts"
901
+ },
902
+ {
903
+ name: "git_rebase",
904
+ description: "Rebase current branch onto another (non-interactive)",
905
+ parameters: {
906
+ type: "object",
907
+ properties: {
908
+ upstream: { type: "string", description: "Upstream branch to rebase onto" },
909
+ onto: { type: "string", description: "New base commit" },
910
+ autosquash: { type: "boolean", description: "Auto-squash fixup commits" }
911
+ },
912
+ required: ["upstream"]
913
+ },
914
+ requiresApproval: true
915
+ },
916
+ {
917
+ name: "git_rebase_abort",
918
+ description: "Abort an in-progress rebase"
919
+ },
920
+ {
921
+ name: "git_rebase_continue",
922
+ description: "Continue an in-progress rebase after resolving conflicts"
923
+ },
924
+ {
925
+ name: "git_rebase_skip",
926
+ description: "Skip the current commit during a rebase"
927
+ },
928
+ {
929
+ name: "git_merge",
930
+ description: "Merge a branch into current branch",
931
+ parameters: {
932
+ type: "object",
933
+ properties: {
934
+ branch: { type: "string", description: "Branch to merge" },
935
+ no_commit: { type: "boolean", description: "Merge without committing" },
936
+ no_ff: { type: "boolean", description: "No fast-forward" },
937
+ squash: { type: "boolean", description: "Squash commits" },
938
+ message: { type: "string", description: "Merge commit message" }
939
+ },
940
+ required: ["branch"]
941
+ },
942
+ requiresApproval: true
943
+ },
944
+ {
945
+ name: "git_merge_abort",
946
+ description: "Abort an in-progress merge"
947
+ },
948
+ {
949
+ name: "git_commit",
950
+ description: "Create a commit with the staged changes",
951
+ parameters: {
952
+ type: "object",
953
+ properties: {
954
+ message: { type: "string", description: "Commit message" },
955
+ amend: { type: "boolean", description: "Amend previous commit" },
956
+ allow_empty: { type: "boolean", description: "Allow empty commit" }
957
+ },
958
+ required: ["message"]
959
+ },
960
+ requiresApproval: true
961
+ },
962
+ {
963
+ name: "git_add",
964
+ description: "Stage files for commit",
965
+ parameters: {
966
+ type: "object",
967
+ properties: {
968
+ paths: { type: "array", description: "Paths to stage (default: all)", items: { type: "string", description: "Path to stage" } }
969
+ }
970
+ }
971
+ },
972
+ {
973
+ name: "git_reset",
974
+ description: "Reset HEAD and/or working tree (soft/mixed/hard)",
975
+ parameters: {
976
+ type: "object",
977
+ properties: {
978
+ mode: { type: "string", description: "Reset mode: soft, mixed, or hard", enum: ["soft", "mixed", "hard"] },
979
+ ref: { type: "string", description: "Commit reference to reset to" }
980
+ }
981
+ },
982
+ requiresApproval: true
983
+ },
984
+ {
985
+ name: "auto_commit",
986
+ description: "Automatically stage all changes and create a commit. In interactive mode, user can accept/edit/reject the message. In yes/non-interactive mode, commits immediately with the suggested or provided message.",
987
+ parameters: {
988
+ type: "object",
989
+ properties: {
990
+ message: { type: "string", description: "Optional commit message (auto-generated if not provided)" },
991
+ stage_all: { type: "boolean", description: "Stage all changes before committing (default: true)" }
992
+ }
993
+ },
994
+ requiresApproval: false
995
+ // Interactive flow prompts inside the tool; yes/non-interactive auto-approves
996
+ },
997
+ {
998
+ name: "git_log",
999
+ description: "Show commit history",
1000
+ parameters: {
1001
+ type: "object",
1002
+ properties: {
1003
+ max_count: { type: "number", description: "Maximum commits to show" },
1004
+ oneline: { type: "boolean", description: "One line per commit" },
1005
+ graph: { type: "boolean", description: "Show branch graph" },
1006
+ all: { type: "boolean", description: "Show all branches" }
1007
+ }
1008
+ }
1009
+ },
1010
+ {
1011
+ name: "git_fetch",
1012
+ description: "Fetch from remote repository",
1013
+ parameters: {
1014
+ type: "object",
1015
+ properties: {
1016
+ remote: { type: "string", description: "Remote name (default: origin)" },
1017
+ branch: { type: "string", description: "Branch to fetch" }
1018
+ }
1019
+ }
1020
+ },
1021
+ {
1022
+ name: "git_pull",
1023
+ description: "Pull changes from remote",
1024
+ parameters: {
1025
+ type: "object",
1026
+ properties: {
1027
+ remote: { type: "string", description: "Remote name (default: origin)" },
1028
+ branch: { type: "string", description: "Branch to pull" }
1029
+ }
1030
+ },
1031
+ requiresApproval: true
1032
+ },
1033
+ {
1034
+ name: "git_push",
1035
+ description: "Push changes to remote",
1036
+ parameters: {
1037
+ type: "object",
1038
+ properties: {
1039
+ remote: { type: "string", description: "Remote name (default: origin)" },
1040
+ branch: { type: "string", description: "Branch to push" },
1041
+ force: { type: "boolean", description: "Force push" },
1042
+ set_upstream: { type: "boolean", description: "Set upstream tracking" }
1043
+ }
1044
+ },
1045
+ requiresApproval: true
1046
+ },
1047
+ {
1048
+ name: "custom_command",
1049
+ description: "Define and execute a one-off command (saved for reuse)",
1050
+ parameters: {
1051
+ type: "object",
1052
+ properties: {
1053
+ name: { type: "string", description: "Command name for reuse" },
1054
+ command: { type: "string", description: "Shell command" },
1055
+ args: { type: "array", description: "Command arguments", items: { type: "string", description: "Single argument" } },
1056
+ description: { type: "string", description: "Command description" },
1057
+ dangerous: { type: "boolean", description: "Mark as dangerous" }
1058
+ },
1059
+ required: ["name", "command"]
1060
+ }
1061
+ },
1062
+ {
1063
+ name: "multi_file_edit",
1064
+ description: "Apply multiple edits to a file",
1065
+ parameters: {
1066
+ type: "object",
1067
+ properties: {
1068
+ file_path: { type: "string", description: "Relative path to the file" },
1069
+ edits: {
1070
+ type: "array",
1071
+ description: "Array of {old_string, new_string, replace_all?}",
1072
+ items: {
1073
+ type: "object",
1074
+ properties: {
1075
+ old_string: { type: "string", description: "Text to replace" },
1076
+ new_string: { type: "string", description: "Replacement text" },
1077
+ replace_all: { type: "boolean", description: "Replace all occurrences (default: false)" }
1078
+ },
1079
+ required: ["old_string", "new_string"]
1080
+ }
1081
+ }
1082
+ },
1083
+ required: ["file_path", "edits"]
1084
+ },
1085
+ requiresApproval: true
1086
+ },
1087
+ {
1088
+ name: "todo_write",
1089
+ description: "Persist and update the todo list. Send the COMPLETE updated todo list each time (not incremental changes).",
1090
+ parameters: {
1091
+ type: "object",
1092
+ properties: {
1093
+ tasks: {
1094
+ type: "array",
1095
+ description: "The complete updated todo list with all tasks and their current statuses",
1096
+ items: {
1097
+ type: "object",
1098
+ properties: {
1099
+ content: { type: "string", description: "Task description (what needs to be done)" },
1100
+ status: { type: "string", enum: ["pending", "in_progress", "completed"], description: "Current task status" },
1101
+ activeForm: { type: "string", description: 'Present continuous form shown during execution (e.g., "Running tests")' }
1102
+ },
1103
+ required: ["content", "status", "activeForm"]
1104
+ }
1105
+ }
1106
+ },
1107
+ required: ["tasks"]
1108
+ }
1109
+ },
1110
+ {
1111
+ name: "smart_context_cropper",
1112
+ description: "Trim conversation history when context is full",
1113
+ parameters: {
1114
+ type: "object",
1115
+ properties: {
1116
+ crop_direction: { type: "string", description: "Direction: top or bottom", enum: ["top", "bottom"] },
1117
+ crop_amount: { type: "number", description: "Number of messages to crop" },
1118
+ need_user_approve: { type: "boolean", description: "Ask user for approval" },
1119
+ deleted_messages_summary: { type: "string", description: "Summary of cropped content" }
1120
+ },
1121
+ required: ["crop_direction", "crop_amount"]
1122
+ }
1123
+ },
1124
+ {
1125
+ name: "save_memory",
1126
+ description: "Save a fact or preference to memory for recall in future sessions. Use for important user preferences, project conventions, or key information worth remembering.",
1127
+ parameters: {
1128
+ type: "object",
1129
+ properties: {
1130
+ fact: { type: "string", description: "The fact or preference to remember. Should be a clear, self-contained statement." },
1131
+ level: { type: "string", description: 'Storage level: "user" (global across projects) or "project" (specific to current workspace)', enum: ["user", "project"] }
1132
+ },
1133
+ required: ["fact"]
1134
+ }
1135
+ },
1136
+ {
1137
+ name: "recall_memory",
1138
+ description: "Recall stored memories and preferences. Use to check what preferences are already saved or to find specific information.",
1139
+ parameters: {
1140
+ type: "object",
1141
+ properties: {
1142
+ query: { type: "string", description: "Optional search query to filter memories. If omitted, returns all memories." },
1143
+ level: { type: "string", description: 'Filter by level: "user" (global) or "project" (workspace-specific). If omitted, returns both.', enum: ["user", "project"] }
1144
+ },
1145
+ required: []
1146
+ }
1147
+ },
1148
+ {
1149
+ name: "create_meta_tool",
1150
+ description: "Create a new reusable tool that persists across sessions. Use for automating repetitive shell commands or extending capabilities.",
1151
+ parameters: {
1152
+ type: "object",
1153
+ properties: {
1154
+ name: { type: "string", description: "Tool name in snake_case (e.g., analyze_imports, count_lines)" },
1155
+ description: { type: "string", description: "Clear description of what the tool does" },
1156
+ parameters: { type: "object", description: "JSON Schema defining tool parameters" },
1157
+ handler: { type: "string", description: 'Shell command template with {{param}} placeholders (e.g., "grep -E {{pattern}} {{path}}")' }
1158
+ },
1159
+ required: ["name", "description", "parameters", "handler"]
1160
+ }
1161
+ },
1162
+ // Web Search Operations
1163
+ {
1164
+ name: "web_search",
1165
+ description: "Search the web for up-to-date information about packages, libraries, frameworks, documentation, changelogs, and more. Use this when you need current information that may have changed after your training data.",
1166
+ parameters: {
1167
+ type: "object",
1168
+ properties: {
1169
+ query: { type: "string", description: 'Search query (e.g., "react 19 new features", "zod changelog latest")' },
1170
+ max_results: { type: "number", description: "Maximum results to return (default: 5)" },
1171
+ search_type: { type: "string", description: "Type of search: general, packages, docs, changelog", enum: ["general", "packages", "docs", "changelog"] }
1172
+ },
1173
+ required: ["query"]
1174
+ }
1175
+ },
1176
+ {
1177
+ name: "fetch_url",
1178
+ description: "Fetch and extract text content from a URL. Useful for reading documentation, changelogs, release notes, or any web page.",
1179
+ parameters: {
1180
+ type: "object",
1181
+ properties: {
1182
+ url: { type: "string", description: "URL to fetch" },
1183
+ max_length: { type: "number", description: "Maximum characters to return (default: 30000)" }
1184
+ },
1185
+ required: ["url"]
1186
+ }
1187
+ },
1188
+ {
1189
+ name: "package_info",
1190
+ description: "Get detailed information about a package from npm, PyPI (Python), crates.io (Rust), Go modules, or RubyGems. Auto-detects registry or specify explicitly.",
1191
+ parameters: {
1192
+ type: "object",
1193
+ properties: {
1194
+ package_name: { type: "string", description: 'Package name (e.g., "react", "requests", "serde", "github.com/gin-gonic/gin")' },
1195
+ registry: { type: "string", description: "Package registry: npm, pypi, crates, go, rubygems (auto-detected if not specified)", enum: ["npm", "pypi", "crates", "go", "rubygems"] },
1196
+ version: { type: "string", description: "Specific version to get info for (default: latest)" }
1197
+ },
1198
+ required: ["package_name"]
1199
+ }
1200
+ },
1201
+ {
1202
+ name: "web_repo",
1203
+ description: `Browse GitHub and GitLab repositories. Supports three operations:
1204
+
1205
+ - 'info': Get repo metadata (description, stars, language, license, default branch)
1206
+ - 'list': List directory contents (files and folders at a path)
1207
+ - 'fetch': Get raw file content (defaults to README.md)
1208
+
1209
+ Repo formats: Full URL (https://github.com/owner/repo), or shorthand (github:owner/repo, gitlab:group/project).
1210
+
1211
+ Examples:
1212
+ { repo: "github:openai/codex", operation: "info" }
1213
+ { repo: "gitlab:inkscape/inkscape", operation: "list", path: "src" }
1214
+ { repo: "github:openai/codex", operation: "fetch", path: "codex-cli/src/utils.ts" }`,
1215
+ parameters: {
1216
+ type: "object",
1217
+ properties: {
1218
+ repo: { type: "string", description: "Repository URL or shorthand (github:owner/repo, gitlab:group/project)" },
1219
+ operation: { type: "string", description: "Operation to perform", enum: ["info", "list", "fetch"] },
1220
+ path: { type: "string", description: "File/directory path (default: root for list, README.md for fetch)" },
1221
+ branch: { type: "string", description: "Branch name (default: repo default branch)" }
1222
+ },
1223
+ required: ["repo", "operation"]
1224
+ }
1225
+ },
1226
+ // Skills Discovery
1227
+ {
1228
+ name: "find_agent_skills",
1229
+ description: "Search the community skills registry for agent skills that match a query. Returns skills with name, description, category, languages, and frameworks. Use this to discover skills that could help with the current task or project.",
1230
+ parameters: {
1231
+ type: "object",
1232
+ properties: {
1233
+ query: { type: "string", description: 'Search terms \u2014 skill name, language, framework, or use-case (e.g. "react testing", "python api", "docker deployment")' },
1234
+ category: { type: "string", description: 'Optional category filter (e.g. "languages", "frameworks", "workflows", "testing")' },
1235
+ limit: { type: "number", description: "Maximum results to return (default: 10, max: 20)" }
1236
+ },
1237
+ required: ["query"]
1238
+ }
1239
+ }
1240
+ ];
1241
+ var ToolManager = class _ToolManager {
1242
+ constructor(options) {
1243
+ this.definitions = /* @__PURE__ */ new Map();
1244
+ this.executor = options.executor;
1245
+ this.confirmApproval = options.confirmApproval;
1246
+ this.toolFilter = new ToolFilter(_nullishCoalesce(options.clientContext, () => ( "cli")), options.customPolicy);
1247
+ const defs = _nullishCoalesce(options.definitions, () => ( DEFAULT_TOOL_DEFINITIONS));
1248
+ for (const def of defs) {
1249
+ this.register(def);
1250
+ }
1251
+ }
1252
+ register(definition) {
1253
+ this.definitions.set(definition.name, definition);
1254
+ }
1255
+ /**
1256
+ * Register meta-tools from ToolsRegistry dynamically
1257
+ * Called during session initialization to load persisted tools
1258
+ */
1259
+ registerMetaTools(toolDefinitions) {
1260
+ for (const def of toolDefinitions) {
1261
+ if (DEFAULT_TOOL_DEFINITIONS.some((d) => d.name === def.name)) {
1262
+ continue;
1263
+ }
1264
+ this.definitions.set(def.name, def);
1265
+ }
1266
+ }
1267
+ /**
1268
+ * Replace all MCP tools (mcp__*) with a fresh set.
1269
+ * Keeps built-ins and non-MCP meta-tools intact.
1270
+ */
1271
+ replaceMcpTools(toolDefinitions) {
1272
+ for (const name of Array.from(this.definitions.keys())) {
1273
+ if (name.startsWith("mcp__")) {
1274
+ this.definitions.delete(name);
1275
+ }
1276
+ }
1277
+ this.registerMetaTools(toolDefinitions);
1278
+ }
1279
+ /**
1280
+ * Check if a tool name conflicts with built-in definitions
1281
+ */
1282
+ isBuiltInTool(name) {
1283
+ return DEFAULT_TOOL_DEFINITIONS.some((d) => d.name === name);
1284
+ }
1285
+ listToolNames() {
1286
+ return Array.from(this.definitions.keys()).filter((name) => this.toolFilter.isAllowed(name));
1287
+ }
1288
+ /**
1289
+ * List all tool definitions (unfiltered)
1290
+ */
1291
+ listAllDefinitions() {
1292
+ return Array.from(this.definitions.values());
1293
+ }
1294
+ /**
1295
+ * List tool definitions filtered by client context
1296
+ */
1297
+ listDefinitions() {
1298
+ return this.toolFilter.filterDefinitions(Array.from(this.definitions.values()));
1299
+ }
1300
+ /**
1301
+ * Get the current tool filter
1302
+ */
1303
+ getFilter() {
1304
+ return this.toolFilter;
1305
+ }
1306
+ /**
1307
+ * Check if a specific tool is allowed in the current context
1308
+ */
1309
+ isToolAllowed(toolName) {
1310
+ return this.toolFilter.isAllowed(toolName);
1311
+ }
1312
+ /**
1313
+ * Convert tool definitions to FunctionDefinition format for LLM function calling
1314
+ * This is used when passing tools to the LLM API
1315
+ */
1316
+ toFunctionDefinitions() {
1317
+ return this.listDefinitions().map((def) => _ToolManager.toFunctionDefinition(def));
1318
+ }
1319
+ /**
1320
+ * Convert a single tool definition to FunctionDefinition format
1321
+ */
1322
+ static toFunctionDefinition(def) {
1323
+ return {
1324
+ name: def.name,
1325
+ description: def.description,
1326
+ parameters: def.parameters ? {
1327
+ type: "object",
1328
+ properties: Object.fromEntries(
1329
+ Object.entries(def.parameters.properties).map(([key, param]) => [
1330
+ key,
1331
+ {
1332
+ type: param.type,
1333
+ description: param.description,
1334
+ enum: param.enum,
1335
+ items: param.type === "array" ? _ToolManager.normalizeItemsStatic(param.items) : void 0,
1336
+ properties: param.type === "object" ? _ToolManager.normalizeObjectPropertiesStatic(
1337
+ param.properties
1338
+ ) : void 0,
1339
+ required: param.type === "object" && Array.isArray(param.required) ? param.required : void 0,
1340
+ additionalProperties: param.type === "object" ? true : void 0
1341
+ }
1342
+ ])
1343
+ ),
1344
+ required: def.parameters.required
1345
+ } : void 0
1346
+ };
1347
+ }
1348
+ static normalizeItemsStatic(items) {
1349
+ if (!items) return { type: "string" };
1350
+ if (items.type !== "object") {
1351
+ return { type: items.type, description: items.description, enum: items.enum };
1352
+ }
1353
+ const objItems = items;
1354
+ return {
1355
+ type: "object",
1356
+ description: items.description,
1357
+ properties: _ToolManager.normalizeObjectPropertiesStatic(objItems.properties),
1358
+ required: objItems.required,
1359
+ additionalProperties: true
1360
+ };
1361
+ }
1362
+ static normalizeObjectPropertiesStatic(props) {
1363
+ const safeProps = _nullishCoalesce(props, () => ( {}));
1364
+ return Object.fromEntries(
1365
+ Object.entries(safeProps).map(([k, v]) => [
1366
+ k,
1367
+ {
1368
+ type: v.type,
1369
+ description: v.description,
1370
+ enum: v.enum,
1371
+ items: v.type === "array" ? _ToolManager.normalizeItemsStatic(v.items) : void 0,
1372
+ properties: v.type === "object" ? _ToolManager.normalizeObjectPropertiesStatic(v.properties) : void 0,
1373
+ required: v.type === "object" && Array.isArray(v.required) ? v.required : void 0,
1374
+ additionalProperties: v.type === "object" ? true : void 0
1375
+ }
1376
+ ])
1377
+ );
1378
+ }
1379
+ async execute(toolCalls) {
1380
+ const results = [];
1381
+ const planModeManager = _chunkULQ6MDSJcjs.getPlanModeManager.call(void 0, );
1382
+ const isInPlanningPhase = planModeManager.isEnabled() && planModeManager.getPhase() === "planning";
1383
+ const readOnlyTools = isInPlanningPhase ? new Set(planModeManager.getReadOnlyTools()) : null;
1384
+ for (const call of toolCalls) {
1385
+ if (!this.toolFilter.isAllowed(call.tool)) {
1386
+ results.push({
1387
+ tool: call.tool,
1388
+ success: false,
1389
+ error: `Tool '${call.tool}' is not available in the current context (${this.toolFilter.getContext()})`
1390
+ });
1391
+ continue;
1392
+ }
1393
+ if (readOnlyTools && !readOnlyTools.has(call.tool)) {
1394
+ results.push({
1395
+ tool: call.tool,
1396
+ success: false,
1397
+ error: `Tool '${call.tool}' is not available in plan mode. Only read-only tools are allowed during planning. Use 'plan' tool to create a plan, then accept it to execute write operations.`
1398
+ });
1399
+ continue;
1400
+ }
1401
+ const definition = this.definitions.get(call.tool);
1402
+ const requiresApproval = this.toolFilter.requiresApproval(call.tool, _optionalChain([definition, 'optionalAccess', _13 => _13.requiresApproval]));
1403
+ if (requiresApproval) {
1404
+ let message = _nullishCoalesce(_optionalChain([definition, 'optionalAccess', _14 => _14.approvalMessage]), () => ( `Allow tool ${call.tool}?`));
1405
+ const permContext = { tool: call.tool };
1406
+ if (call.tool === "run_command" && call.args) {
1407
+ const cmd = String(call.args.command || "");
1408
+ const args = Array.isArray(call.args.args) ? call.args.args.join(" ") : "";
1409
+ const fullCommand = args ? `${cmd} ${args}` : cmd;
1410
+ const dir = call.args.directory ? ` (in ${call.args.directory})` : "";
1411
+ message = `Run this command${dir}?
1412
+ $ ${fullCommand}`;
1413
+ permContext.command = fullCommand;
1414
+ } else if (call.tool === "delete_path" && _optionalChain([call, 'access', _15 => _15.args, 'optionalAccess', _16 => _16.path])) {
1415
+ message = `Delete this path?
1416
+ ${call.args.path}`;
1417
+ permContext.path = String(call.args.path);
1418
+ } else if (call.tool === "write_file" && _optionalChain([call, 'access', _17 => _17.args, 'optionalAccess', _18 => _18.path])) {
1419
+ message = `Write to this file?
1420
+ ${call.args.path}`;
1421
+ permContext.path = String(call.args.path);
1422
+ } else if (call.tool === "multi_file_edit" && _optionalChain([call, 'access', _19 => _19.args, 'optionalAccess', _20 => _20.file_path])) {
1423
+ const editCount = Array.isArray(call.args.edits) ? call.args.edits.length : 0;
1424
+ message = `Edit this file (${editCount} change${editCount === 1 ? "" : "s"})?
1425
+ ${call.args.file_path}`;
1426
+ permContext.path = String(call.args.file_path);
1427
+ }
1428
+ const confirmed = await this.confirmApproval(message, permContext);
1429
+ if (!confirmed) {
1430
+ results.push({
1431
+ tool: call.tool,
1432
+ success: false,
1433
+ output: "Tool execution skipped by user."
1434
+ });
1435
+ continue;
1436
+ }
1437
+ }
1438
+ try {
1439
+ const action = this.toAction(call);
1440
+ const output = await this.executor(action, { toolCallId: call.id, tool: call.tool });
1441
+ results.push({
1442
+ tool: call.tool,
1443
+ success: true,
1444
+ output
1445
+ });
1446
+ } catch (error) {
1447
+ results.push({
1448
+ tool: call.tool,
1449
+ success: false,
1450
+ error: error instanceof Error ? error.message : String(error)
1451
+ });
1452
+ }
1453
+ }
1454
+ return results;
1455
+ }
1456
+ toAction(call) {
1457
+ return {
1458
+ type: call.tool,
1459
+ ..._nullishCoalesce(call.args, () => ( {}))
1460
+ };
1461
+ }
1462
+ };
1463
+
1464
+ // src/core/agents/AgentDelegator.ts
1465
+
1466
+ var DEFAULT_MAX_DEPTH = 3;
1467
+ var AgentDelegator = class {
1468
+ constructor(llm, actionExecutor, options = {}) {
1469
+ this.llm = llm;
1470
+ this.actionExecutor = actionExecutor;
1471
+ this.subagentCounter = 0;
1472
+ this.registry = _chunkBVKXEQVGcjs.AgentRegistry.getInstance();
1473
+ this.clientContext = _nullishCoalesce(options.clientContext, () => ( "cli"));
1474
+ this.currentDepth = _nullishCoalesce(options.currentDepth, () => ( 0));
1475
+ this.maxDepth = _nullishCoalesce(options.maxDepth, () => ( DEFAULT_MAX_DEPTH));
1476
+ this.onSubagentStop = options.onSubagentStop;
1477
+ }
1478
+ generateSubagentId() {
1479
+ return `subagent-${Date.now()}-${++this.subagentCounter}`;
1480
+ }
1481
+ async delegateTask(agentName, task) {
1482
+ if (this.currentDepth >= this.maxDepth) {
1483
+ return `Error: Maximum delegation depth (${this.maxDepth}) reached. Cannot delegate to '${agentName}'.`;
1484
+ }
1485
+ await this.registry.loadAgents();
1486
+ const agentConfig = this.registry.getAgent(agentName);
1487
+ if (!agentConfig) {
1488
+ return `Error: Agent '${agentName}' not found. Use /agents to list available agents.`;
1489
+ }
1490
+ const subAgentOptions = {
1491
+ clientContext: this.clientContext,
1492
+ depth: this.currentDepth + 1,
1493
+ maxDepth: this.maxDepth
1494
+ };
1495
+ const subagentId = this.generateSubagentId();
1496
+ const startTime = Date.now();
1497
+ const agent = new SubAgent(agentConfig, this.llm, this.actionExecutor, subAgentOptions);
1498
+ try {
1499
+ const result = await agent.run(task);
1500
+ if (this.onSubagentStop) {
1501
+ await this.onSubagentStop({
1502
+ subagentId,
1503
+ subagentName: agentName,
1504
+ subagentType: _nullishCoalesce(agentConfig.source, () => ( "user")),
1505
+ success: true,
1506
+ duration: Date.now() - startTime
1507
+ });
1508
+ }
1509
+ return result;
1510
+ } catch (error) {
1511
+ const errorMessage = error.message;
1512
+ if (this.onSubagentStop) {
1513
+ await this.onSubagentStop({
1514
+ subagentId,
1515
+ subagentName: agentName,
1516
+ subagentType: _nullishCoalesce(agentConfig.source, () => ( "user")),
1517
+ success: false,
1518
+ error: errorMessage,
1519
+ duration: Date.now() - startTime
1520
+ });
1521
+ }
1522
+ return `Error running agent '${agentName}': ${errorMessage}`;
1523
+ }
1524
+ }
1525
+ async delegateParallel(tasks) {
1526
+ if (this.currentDepth >= this.maxDepth) {
1527
+ return `Error: Maximum delegation depth (${this.maxDepth}) reached. Cannot delegate parallel tasks.`;
1528
+ }
1529
+ if (tasks.length > 5) {
1530
+ return `Error: Maximum 5 parallel agents allowed. You requested ${tasks.length}.`;
1531
+ }
1532
+ await this.registry.loadAgents();
1533
+ const subAgentOptions = {
1534
+ clientContext: this.clientContext,
1535
+ depth: this.currentDepth + 1,
1536
+ maxDepth: this.maxDepth
1537
+ };
1538
+ const promises = tasks.map(async ({ agent_name, task }) => {
1539
+ const agentConfig = this.registry.getAgent(agent_name);
1540
+ if (!agentConfig) {
1541
+ return `[${agent_name}] Error: Agent not found.`;
1542
+ }
1543
+ const subagentId = this.generateSubagentId();
1544
+ const startTime = Date.now();
1545
+ const agent = new SubAgent(agentConfig, this.llm, this.actionExecutor, subAgentOptions);
1546
+ try {
1547
+ const result = await agent.run(task);
1548
+ if (this.onSubagentStop) {
1549
+ await this.onSubagentStop({
1550
+ subagentId,
1551
+ subagentName: agent_name,
1552
+ subagentType: _nullishCoalesce(agentConfig.source, () => ( "user")),
1553
+ success: true,
1554
+ duration: Date.now() - startTime
1555
+ });
1556
+ }
1557
+ return `[${agent_name}] Result:
1558
+ ${result}`;
1559
+ } catch (error) {
1560
+ const errorMessage = error.message;
1561
+ if (this.onSubagentStop) {
1562
+ await this.onSubagentStop({
1563
+ subagentId,
1564
+ subagentName: agent_name,
1565
+ subagentType: _nullishCoalesce(agentConfig.source, () => ( "user")),
1566
+ success: false,
1567
+ error: errorMessage,
1568
+ duration: Date.now() - startTime
1569
+ });
1570
+ }
1571
+ return `[${agent_name}] Failed: ${errorMessage}`;
1572
+ }
1573
+ });
1574
+ const results = await Promise.all(promises);
1575
+ return results.join("\n\n" + _chalk2.default.gray("\u2500".repeat(40)) + "\n\n");
1576
+ }
1577
+ /**
1578
+ * Get the current delegation depth
1579
+ */
1580
+ getDepth() {
1581
+ return this.currentDepth;
1582
+ }
1583
+ /**
1584
+ * Check if further delegation is allowed
1585
+ */
1586
+ canDelegate() {
1587
+ return this.currentDepth < this.maxDepth;
1588
+ }
1589
+ };
1590
+
1591
+ // src/core/agents/SubAgent.ts
1592
+ var DELEGATION_TOOL_DEFINITIONS = [
1593
+ {
1594
+ name: "delegate_task",
1595
+ description: "Delegate a task to another specialized sub-agent",
1596
+ parameters: {
1597
+ type: "object",
1598
+ properties: {
1599
+ agent_name: { type: "string", description: "Name of the agent to delegate to" },
1600
+ task: { type: "string", description: "Task description for the sub-agent" }
1601
+ },
1602
+ required: ["agent_name", "task"]
1603
+ }
1604
+ },
1605
+ {
1606
+ name: "delegate_parallel",
1607
+ description: "Run multiple sub-agents in parallel (max 5)",
1608
+ parameters: {
1609
+ type: "object",
1610
+ properties: {
1611
+ tasks: { type: "array", description: "Array of {agent_name, task} objects" }
1612
+ },
1613
+ required: ["tasks"]
1614
+ }
1615
+ }
1616
+ ];
1617
+ var SubAgent = class {
1618
+ constructor(config, llm, actionExecutor, options) {
1619
+ this.config = config;
1620
+ this.llm = llm;
1621
+ this.actionExecutor = actionExecutor;
1622
+ this.delegator = null;
1623
+ this.name = config.name;
1624
+ this.options = options;
1625
+ const canDelegate = options.depth < options.maxDepth;
1626
+ const allowedTools = new Set(config.tools);
1627
+ let definitions = DEFAULT_TOOL_DEFINITIONS.filter((def) => allowedTools.has(def.name));
1628
+ if (canDelegate) {
1629
+ definitions = [...definitions, ...DELEGATION_TOOL_DEFINITIONS];
1630
+ }
1631
+ const toolFilter = new ToolFilter(options.clientContext);
1632
+ definitions = toolFilter.filterDefinitions(definitions);
1633
+ if (canDelegate) {
1634
+ this.delegator = new AgentDelegator(llm, actionExecutor, {
1635
+ clientContext: options.clientContext,
1636
+ currentDepth: options.depth,
1637
+ maxDepth: options.maxDepth
1638
+ });
1639
+ }
1640
+ this.toolManager = new ToolManager({
1641
+ executor: async (action, context) => {
1642
+ if (action.type === "delegate_task" && this.delegator) {
1643
+ return this.delegator.delegateTask(
1644
+ action.agent_name,
1645
+ action.task
1646
+ );
1647
+ }
1648
+ if (action.type === "delegate_parallel" && this.delegator) {
1649
+ return this.delegator.delegateParallel(action.tasks);
1650
+ }
1651
+ return this.actionExecutor.execute(action, context);
1652
+ },
1653
+ confirmApproval: async () => true,
1654
+ // Sub-agents auto-approve (inherit from main agent in future)
1655
+ definitions,
1656
+ clientContext: options.clientContext
1657
+ });
1658
+ const enhancedSystemPrompt = this.buildSystemPrompt(config.systemPrompt, definitions);
1659
+ this.conversation = new (0, _chunkCNBKZEX5cjs.ConversationManager)();
1660
+ this.conversation.reset(enhancedSystemPrompt);
1661
+ }
1662
+ /**
1663
+ * Build system prompt with tool signatures for the LLM
1664
+ */
1665
+ buildSystemPrompt(basePrompt, tools) {
1666
+ const toolSignatures = tools.map((def) => this.formatToolSignature(def)).join("\n");
1667
+ return [
1668
+ basePrompt,
1669
+ "",
1670
+ "## Available Tools",
1671
+ "You have access to the following tools. Use them when needed:",
1672
+ "",
1673
+ toolSignatures,
1674
+ "",
1675
+ "## Response Format",
1676
+ "Always respond with structured JSON:",
1677
+ "```json",
1678
+ "{",
1679
+ ' "thought": "Your reasoning about what to do next",',
1680
+ ' "toolCalls": [{"tool": "tool_name", "args": {...}}],',
1681
+ ' "finalResponse": "Your final answer when done (omit toolCalls if providing this)"',
1682
+ "}",
1683
+ "```",
1684
+ "",
1685
+ `Depth: ${this.options.depth}/${this.options.maxDepth} ${this.delegator ? "(can delegate further)" : "(max depth reached)"}`
1686
+ ].join("\n");
1687
+ }
1688
+ /**
1689
+ * Format a tool definition as a signature string
1690
+ */
1691
+ formatToolSignature(def) {
1692
+ const params = _optionalChain([def, 'access', _21 => _21.parameters, 'optionalAccess', _22 => _22.properties]) ? Object.entries(def.parameters.properties).map(([name, prop]) => {
1693
+ const required = _optionalChain([def, 'access', _23 => _23.parameters, 'optionalAccess', _24 => _24.required, 'optionalAccess', _25 => _25.includes, 'call', _26 => _26(name)]) ? "" : "?";
1694
+ return `${name}${required}: ${prop.type}`;
1695
+ }).join(", ") : "";
1696
+ return `- ${def.name}(${params}): ${def.description}`;
1697
+ }
1698
+ async run(task) {
1699
+ console.log(_chalk2.default.cyan(`
1700
+ \u{1F916} Sub-agent '${this.name}' starting task... (depth ${this.options.depth}/${this.options.maxDepth})`));
1701
+ this.conversation.addMessage({ role: "user", content: task });
1702
+ const tools = this.toolManager.toFunctionDefinitions();
1703
+ const maxIterations = 10;
1704
+ for (let i = 0; i < maxIterations; i++) {
1705
+ const completion = await this.llm.complete({
1706
+ messages: this.conversation.history(),
1707
+ model: this.config.model,
1708
+ temperature: 0.2,
1709
+ tools: tools.length > 0 ? tools : void 0,
1710
+ toolChoice: tools.length > 0 ? "auto" : void 0
1711
+ });
1712
+ const payload = this.parseResponse(completion);
1713
+ if (_optionalChain([completion, 'access', _27 => _27.toolCalls, 'optionalAccess', _28 => _28.length])) {
1714
+ this.conversation.addMessage({
1715
+ role: "assistant",
1716
+ content: completion.content || ""
1717
+ });
1718
+ } else {
1719
+ this.conversation.addMessage({ role: "assistant", content: completion.content });
1720
+ }
1721
+ if (payload.thought) {
1722
+ console.log(_chalk2.default.gray(`[${this.name}] ${payload.thought}`));
1723
+ }
1724
+ if (payload.toolCalls && payload.toolCalls.length > 0) {
1725
+ const results = await this.toolManager.execute(payload.toolCalls);
1726
+ for (let j = 0; j < results.length; j++) {
1727
+ const result = results[j];
1728
+ const toolCall = _optionalChain([completion, 'access', _29 => _29.toolCalls, 'optionalAccess', _30 => _30[j]]);
1729
+ const content = result.success ? _nullishCoalesce(result.output, () => ( "(no output)")) : _nullishCoalesce(result.error, () => ( "Tool failed"));
1730
+ this.conversation.addMessage({
1731
+ role: "tool",
1732
+ name: result.tool,
1733
+ content,
1734
+ tool_call_id: _optionalChain([toolCall, 'optionalAccess', _31 => _31.id])
1735
+ });
1736
+ if (!result.success) {
1737
+ console.log(_chalk2.default.red(`[${this.name}] Tool ${result.tool} failed: ${content}`));
1738
+ }
1739
+ }
1740
+ continue;
1741
+ }
1742
+ const response = _nullishCoalesce(_nullishCoalesce(payload.finalResponse, () => ( payload.response)), () => ( completion.content));
1743
+ console.log(_chalk2.default.cyan(`[${this.name}] Finished.`));
1744
+ return response;
1745
+ }
1746
+ return `[${this.name}] Failed to complete task within ${maxIterations} iterations.`;
1747
+ }
1748
+ /**
1749
+ * Parse LLM response, preferring native tool calls over JSON parsing
1750
+ */
1751
+ parseResponse(completion) {
1752
+ if (completion.toolCalls && completion.toolCalls.length > 0) {
1753
+ return {
1754
+ thought: completion.content || void 0,
1755
+ toolCalls: completion.toolCalls.map((tc) => ({
1756
+ tool: tc.function.name,
1757
+ args: this.safeParseJson(tc.function.arguments)
1758
+ }))
1759
+ };
1760
+ }
1761
+ return this.parsePayload(completion.content);
1762
+ }
1763
+ /**
1764
+ * Safely parse JSON, returning empty object on failure
1765
+ */
1766
+ safeParseJson(json) {
1767
+ try {
1768
+ return JSON.parse(json);
1769
+ } catch (e) {
1770
+ return {};
1771
+ }
1772
+ }
1773
+ parsePayload(raw) {
1774
+ const jsonMatch = raw.match(/\{[\s\S]*\}/);
1775
+ if (!jsonMatch) {
1776
+ return { finalResponse: raw.trim() };
1777
+ }
1778
+ try {
1779
+ const parsed = JSON.parse(jsonMatch[0]);
1780
+ const hasExpectedFields = "thought" in parsed || "toolCalls" in parsed || "finalResponse" in parsed || "response" in parsed;
1781
+ if (hasExpectedFields) {
1782
+ return {
1783
+ thought: typeof parsed.thought === "string" ? parsed.thought : void 0,
1784
+ toolCalls: Array.isArray(parsed.toolCalls) ? parsed.toolCalls : void 0,
1785
+ finalResponse: _nullishCoalesce((typeof parsed.finalResponse === "string" ? parsed.finalResponse : void 0), () => ( (typeof parsed.response === "string" ? parsed.response : void 0))),
1786
+ response: typeof parsed.response === "string" ? parsed.response : void 0
1787
+ };
1788
+ }
1789
+ const contentValue = this.extractContentFromJson(parsed);
1790
+ if (contentValue) {
1791
+ return { finalResponse: contentValue };
1792
+ }
1793
+ return { finalResponse: raw.trim() };
1794
+ } catch (e2) {
1795
+ return { finalResponse: raw.trim() };
1796
+ }
1797
+ }
1798
+ /**
1799
+ * Extracts content from non-standard JSON response formats.
1800
+ */
1801
+ extractContentFromJson(parsed) {
1802
+ const contentFields = ["content", "text", "message", "answer", "output", "result", "reply"];
1803
+ for (const field of contentFields) {
1804
+ const value = parsed[field];
1805
+ if (typeof value === "string" && value.trim()) {
1806
+ return value.trim();
1807
+ }
1808
+ }
1809
+ if (parsed.message && typeof parsed.message === "object") {
1810
+ const msg = parsed.message;
1811
+ if (typeof msg.content === "string" && msg.content.trim()) {
1812
+ return msg.content.trim();
1813
+ }
1814
+ }
1815
+ return void 0;
1816
+ }
1817
+ };
1818
+
1819
+
1820
+
1821
+
1822
+
1823
+
1824
+
1825
+ exports.filterToolsByRelevance = filterToolsByRelevance; exports.DEFAULT_TOOL_DEFINITIONS = DEFAULT_TOOL_DEFINITIONS; exports.ToolManager = ToolManager; exports.SubAgent = SubAgent; exports.AgentDelegator = AgentDelegator;
1826
+ /**
1827
+ * @license
1828
+ * Copyright 2025 Autohand AI LLC
1829
+ * SPDX-License-Identifier: Apache-2.0
1830
+ *
1831
+ * Tool filtering based on client context and risk categories
1832
+ * Inspired by Claude Code's permission model
1833
+ */
1834
+ /**
1835
+ * @license
1836
+ * Copyright 2025 Autohand AI LLC
1837
+ * SPDX-License-Identifier: Apache-2.0
1838
+ */