@caspian2026/agent-sdk 0.0.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 (371) hide show
  1. package/dist/chunk-018smjq7.js +26 -0
  2. package/dist/chunk-055q0a2m.js +146 -0
  3. package/dist/chunk-07069jq1.js +30 -0
  4. package/dist/chunk-0731m51q.js +8 -0
  5. package/dist/chunk-0awwmrwr.js +46 -0
  6. package/dist/chunk-0htx82k2.js +64 -0
  7. package/dist/chunk-0jmt5sx1.js +104 -0
  8. package/dist/chunk-0kj8bq80.js +252 -0
  9. package/dist/chunk-0kxcq8h9.js +86 -0
  10. package/dist/chunk-0paqc2yw.js +15 -0
  11. package/dist/chunk-0vkfrmqm.js +690 -0
  12. package/dist/chunk-0xjaqda8.js +1124 -0
  13. package/dist/chunk-10qhq6f8.js +458 -0
  14. package/dist/chunk-15m49c67.js +121 -0
  15. package/dist/chunk-15sfg4bs.js +65 -0
  16. package/dist/chunk-162ewhvy.js +869 -0
  17. package/dist/chunk-177s15bv.js +120 -0
  18. package/dist/chunk-19e603rv.js +284 -0
  19. package/dist/chunk-1ax1znzj.js +537 -0
  20. package/dist/chunk-1c4j7qn2.js +319 -0
  21. package/dist/chunk-1gx78081.js +66 -0
  22. package/dist/chunk-1h2famwb.js +49 -0
  23. package/dist/chunk-1nk93fqz.js +357 -0
  24. package/dist/chunk-1xct96nd.js +2520 -0
  25. package/dist/chunk-1xvcvdef.js +90 -0
  26. package/dist/chunk-1yrcnrs7.js +261 -0
  27. package/dist/chunk-21bcvwr7.js +660 -0
  28. package/dist/chunk-2352ts05.js +667 -0
  29. package/dist/chunk-23jzrwsw.js +43 -0
  30. package/dist/chunk-26hg7303.js +62 -0
  31. package/dist/chunk-2f21meep.js +122 -0
  32. package/dist/chunk-2fwze72g.js +24 -0
  33. package/dist/chunk-2gzv8nrw.js +205 -0
  34. package/dist/chunk-2h05vtpv.js +83 -0
  35. package/dist/chunk-2h0y6m16.js +465 -0
  36. package/dist/chunk-2n7bbxm6.js +168 -0
  37. package/dist/chunk-2nv3d0he.js +108 -0
  38. package/dist/chunk-2vqrdwx9.js +1811 -0
  39. package/dist/chunk-3389cj3w.js +120 -0
  40. package/dist/chunk-35sgv3er.js +231 -0
  41. package/dist/chunk-3c25bcsw.js +17 -0
  42. package/dist/chunk-3e20cj49.js +443 -0
  43. package/dist/chunk-3mr5ryx4.js +122 -0
  44. package/dist/chunk-3nk79af8.js +8 -0
  45. package/dist/chunk-3qbdzsvm.js +120 -0
  46. package/dist/chunk-3yprydpw.js +213 -0
  47. package/dist/chunk-430yrtmk.js +492 -0
  48. package/dist/chunk-46hd1gyd.js +140 -0
  49. package/dist/chunk-46hdszda.js +63 -0
  50. package/dist/chunk-46n7byh8.js +102 -0
  51. package/dist/chunk-4cp6193g.js +9076 -0
  52. package/dist/chunk-4dn3n459.js +409 -0
  53. package/dist/chunk-4hv90qcz.js +8 -0
  54. package/dist/chunk-4jm600zv.js +13 -0
  55. package/dist/chunk-4nspekjp.js +69 -0
  56. package/dist/chunk-505mxxa9.js +19 -0
  57. package/dist/chunk-50bay5qy.js +224 -0
  58. package/dist/chunk-537qfvn5.js +345 -0
  59. package/dist/chunk-55raexh7.js +14358 -0
  60. package/dist/chunk-572vjq78.js +56 -0
  61. package/dist/chunk-5apfzkpy.js +87 -0
  62. package/dist/chunk-5ccdsxgy.js +74 -0
  63. package/dist/chunk-5dmhsqap.js +32 -0
  64. package/dist/chunk-5fs6nkjr.js +98 -0
  65. package/dist/chunk-5nchekqe.js +87 -0
  66. package/dist/chunk-5pp28k2r.js +120 -0
  67. package/dist/chunk-5rt4b8q9.js +116 -0
  68. package/dist/chunk-5rv9c8yd.js +1072 -0
  69. package/dist/chunk-5z28bqne.js +6748 -0
  70. package/dist/chunk-64c1avct.js +13 -0
  71. package/dist/chunk-66zry909.js +11 -0
  72. package/dist/chunk-682qgta2.js +102 -0
  73. package/dist/chunk-68ffk5qa.js +14 -0
  74. package/dist/chunk-68w91pzt.js +79 -0
  75. package/dist/chunk-69fgaak0.js +654 -0
  76. package/dist/chunk-69n11zng.js +436 -0
  77. package/dist/chunk-6dj5t602.js +341 -0
  78. package/dist/chunk-6gh20s05.js +146 -0
  79. package/dist/chunk-6maej1hh.js +502 -0
  80. package/dist/chunk-6nsd9606.js +790 -0
  81. package/dist/chunk-6p4cyhb3.js +16 -0
  82. package/dist/chunk-6t4a9cgj.js +877 -0
  83. package/dist/chunk-6t8yqfks.js +227 -0
  84. package/dist/chunk-6vthy0fj.js +213 -0
  85. package/dist/chunk-70cw4cg9.js +1026 -0
  86. package/dist/chunk-70eey1nh.js +164 -0
  87. package/dist/chunk-76j2e9vy.js +68 -0
  88. package/dist/chunk-7acgdm7x.js +93 -0
  89. package/dist/chunk-7aw745vx.js +40175 -0
  90. package/dist/chunk-7gvwg1v9.js +122 -0
  91. package/dist/chunk-7h2ybnf3.js +636 -0
  92. package/dist/chunk-7kcm5hn2.js +155 -0
  93. package/dist/chunk-7m2hp89m.js +73 -0
  94. package/dist/chunk-7mqab3z7.js +31 -0
  95. package/dist/chunk-7sgtxrsc.js +1059 -0
  96. package/dist/chunk-7wm5s02e.js +216 -0
  97. package/dist/chunk-7xyswgjh.js +8 -0
  98. package/dist/chunk-7yxvpj5j.js +1452 -0
  99. package/dist/chunk-80a8vabn.js +93 -0
  100. package/dist/chunk-83e71kz6.js +180 -0
  101. package/dist/chunk-83hfzbx3.js +10 -0
  102. package/dist/chunk-8g5pe1gr.js +37 -0
  103. package/dist/chunk-8g747a8x.js +26 -0
  104. package/dist/chunk-8hj8ms5q.js +111 -0
  105. package/dist/chunk-8mkwsdk1.js +61 -0
  106. package/dist/chunk-8n42zyfx.js +40 -0
  107. package/dist/chunk-8qhxyqj9.js +1155 -0
  108. package/dist/chunk-8y30k9pz.js +38 -0
  109. package/dist/chunk-960ze3jj.js +124 -0
  110. package/dist/chunk-97wgdsab.js +35 -0
  111. package/dist/chunk-9grztvcg.js +93 -0
  112. package/dist/chunk-9x5zgy22.js +12 -0
  113. package/dist/chunk-a8792r1c.js +620 -0
  114. package/dist/chunk-ahr1r7c6.js +4275 -0
  115. package/dist/chunk-ase86y73.js +15 -0
  116. package/dist/chunk-b0kf00ff.js +637 -0
  117. package/dist/chunk-b0qptb1k.js +640 -0
  118. package/dist/chunk-b1kcd3ss.js +27 -0
  119. package/dist/chunk-b2fd462a.js +54 -0
  120. package/dist/chunk-bdrjvs5k.js +157 -0
  121. package/dist/chunk-beg7bdyz.js +90 -0
  122. package/dist/chunk-bg4x9ex0.js +21 -0
  123. package/dist/chunk-bktfq0ns.js +95 -0
  124. package/dist/chunk-bmbq6nt1.js +145 -0
  125. package/dist/chunk-bvf2z3g6.js +1003 -0
  126. package/dist/chunk-bxcfz5gy.js +56 -0
  127. package/dist/chunk-c11swzas.js +5368 -0
  128. package/dist/chunk-c37j5zxe.js +57 -0
  129. package/dist/chunk-c5mz5vw2.js +117 -0
  130. package/dist/chunk-c6sjhj89.js +1284 -0
  131. package/dist/chunk-c7jwbe76.js +29030 -0
  132. package/dist/chunk-cc2tg4q8.js +311 -0
  133. package/dist/chunk-cdhmrbj4.js +6353 -0
  134. package/dist/chunk-cdz5yb0r.js +57 -0
  135. package/dist/chunk-cfv996bs.js +22 -0
  136. package/dist/chunk-cgfdkzhb.js +12 -0
  137. package/dist/chunk-chakj069.js +310 -0
  138. package/dist/chunk-chsyvavm.js +3435 -0
  139. package/dist/chunk-cnsj3vq2.js +35 -0
  140. package/dist/chunk-ctdg0qxh.js +1386 -0
  141. package/dist/chunk-cxq7gc42.js +386 -0
  142. package/dist/chunk-d1pyf9as.js +8586 -0
  143. package/dist/chunk-d4kwjqjy.js +308 -0
  144. package/dist/chunk-d4mdda98.js +94 -0
  145. package/dist/chunk-d7886r6a.js +13870 -0
  146. package/dist/chunk-d7f1pzkq.js +95 -0
  147. package/dist/chunk-ddsjkqs4.js +39 -0
  148. package/dist/chunk-dm3n2qgd.js +24 -0
  149. package/dist/chunk-e2mv8ts8.js +115 -0
  150. package/dist/chunk-e4bhfc6d.js +2720 -0
  151. package/dist/chunk-e4p1jbs4.js +58 -0
  152. package/dist/chunk-e7h4qxgw.js +21 -0
  153. package/dist/chunk-e8p3fy6v.js +202 -0
  154. package/dist/chunk-e97mp86b.js +111 -0
  155. package/dist/chunk-ebqwkhyf.js +145 -0
  156. package/dist/chunk-eenq3avg.js +69 -0
  157. package/dist/chunk-efgjfast.js +61 -0
  158. package/dist/chunk-ehtwnxpg.js +1591 -0
  159. package/dist/chunk-en8wkxh7.js +173 -0
  160. package/dist/chunk-enkdxqas.js +33 -0
  161. package/dist/chunk-eqp1rfft.js +17 -0
  162. package/dist/chunk-ercvcek8.js +266 -0
  163. package/dist/chunk-etgh9xvt.js +369 -0
  164. package/dist/chunk-ev3qkf76.js +106 -0
  165. package/dist/chunk-evp5pb9x.js +3567 -0
  166. package/dist/chunk-ewadzrm8.js +103 -0
  167. package/dist/chunk-exah13mz.js +94 -0
  168. package/dist/chunk-f0rzvqmq.js +87 -0
  169. package/dist/chunk-f1m9pect.js +258 -0
  170. package/dist/chunk-fajg8x36.js +8158 -0
  171. package/dist/chunk-fbv4apne.js +51 -0
  172. package/dist/chunk-fbvw6wq9.js +116 -0
  173. package/dist/chunk-feyzykye.js +10 -0
  174. package/dist/chunk-fn1vvj8k.js +894 -0
  175. package/dist/chunk-fshfxw2q.js +183 -0
  176. package/dist/chunk-fyc5fepv.js +10 -0
  177. package/dist/chunk-g9f19ttm.js +15 -0
  178. package/dist/chunk-gcpfxk0c.js +644 -0
  179. package/dist/chunk-gdg6411p.js +106 -0
  180. package/dist/chunk-gkyzz8er.js +849 -0
  181. package/dist/chunk-gxahdggv.js +71 -0
  182. package/dist/chunk-h6fsks9j.js +220 -0
  183. package/dist/chunk-h9n54swm.js +27 -0
  184. package/dist/chunk-hakdhagh.js +16606 -0
  185. package/dist/chunk-hchy0hq6.js +159 -0
  186. package/dist/chunk-hh3k5s1s.js +180 -0
  187. package/dist/chunk-hqqkj5pg.js +202 -0
  188. package/dist/chunk-htpehq9t.js +251 -0
  189. package/dist/chunk-hwfknpxv.js +39 -0
  190. package/dist/chunk-hwn8vetn.js +394 -0
  191. package/dist/chunk-hx3j6n92.js +178 -0
  192. package/dist/chunk-hyb749hd.js +194 -0
  193. package/dist/chunk-hzgnejb1.js +90 -0
  194. package/dist/chunk-hzknr99c.js +477 -0
  195. package/dist/chunk-j3zhb8vv.js +152 -0
  196. package/dist/chunk-j5bth84e.js +97 -0
  197. package/dist/chunk-j64ga6ta.js +8035 -0
  198. package/dist/chunk-jaaxk89e.js +113 -0
  199. package/dist/chunk-jd32zbps.js +15 -0
  200. package/dist/chunk-jfja8q7w.js +91 -0
  201. package/dist/chunk-jgjqa49s.js +27 -0
  202. package/dist/chunk-jgpmpgx6.js +19 -0
  203. package/dist/chunk-jgwd85hp.js +91 -0
  204. package/dist/chunk-jk69qtzx.js +277 -0
  205. package/dist/chunk-jr1xm1dd.js +147 -0
  206. package/dist/chunk-jss0azv7.js +2337 -0
  207. package/dist/chunk-jxpmkae9.js +108 -0
  208. package/dist/chunk-jy9rxxqe.js +102 -0
  209. package/dist/chunk-jyw3np47.js +264 -0
  210. package/dist/chunk-jzthz1bx.js +15 -0
  211. package/dist/chunk-k0p9w03v.js +4957 -0
  212. package/dist/chunk-k2rybwww.js +92 -0
  213. package/dist/chunk-k3939ggz.js +168 -0
  214. package/dist/chunk-k591cwbg.js +345 -0
  215. package/dist/chunk-k5ez1h65.js +108 -0
  216. package/dist/chunk-k8vp0atq.js +2331 -0
  217. package/dist/chunk-kajf3jgq.js +694 -0
  218. package/dist/chunk-kbm69rtz.js +276 -0
  219. package/dist/chunk-kjh11txh.js +419 -0
  220. package/dist/chunk-kqggbte3.js +326 -0
  221. package/dist/chunk-kr6qfwq0.js +95 -0
  222. package/dist/chunk-kvfg8eeg.js +150 -0
  223. package/dist/chunk-kwekc97v.js +18 -0
  224. package/dist/chunk-m1cehfta.js +861 -0
  225. package/dist/chunk-m87bhhqv.js +61 -0
  226. package/dist/chunk-mg7pbk0r.js +151 -0
  227. package/dist/chunk-mpbfkp8j.js +418 -0
  228. package/dist/chunk-mpk1sjyk.js +117 -0
  229. package/dist/chunk-msecaxyj.js +74 -0
  230. package/dist/chunk-mswx2nma.js +103 -0
  231. package/dist/chunk-mw1kpeg9.js +6895 -0
  232. package/dist/chunk-mxr2s6d1.js +89 -0
  233. package/dist/chunk-my40g5hp.js +560 -0
  234. package/dist/chunk-n0kmh4ra.js +338 -0
  235. package/dist/chunk-n18q5yqs.js +397 -0
  236. package/dist/chunk-n7pnyq43.js +131 -0
  237. package/dist/chunk-naybw0p0.js +32 -0
  238. package/dist/chunk-nb6abcch.js +83 -0
  239. package/dist/chunk-ne5r3k03.js +350 -0
  240. package/dist/chunk-nebezy1d.js +997 -0
  241. package/dist/chunk-netzwgv1.js +154 -0
  242. package/dist/chunk-nhapyawz.js +32994 -0
  243. package/dist/chunk-npnvheft.js +156 -0
  244. package/dist/chunk-nrtksr2p.js +51 -0
  245. package/dist/chunk-nw9t5pq9.js +132 -0
  246. package/dist/chunk-nxgsnh2y.js +735 -0
  247. package/dist/chunk-p11xp4xp.js +266 -0
  248. package/dist/chunk-p1hwrf72.js +74 -0
  249. package/dist/chunk-p1zj9mg9.js +567 -0
  250. package/dist/chunk-p39a677r.js +115 -0
  251. package/dist/chunk-p7vkh4wx.js +15 -0
  252. package/dist/chunk-p8na2wwp.js +14 -0
  253. package/dist/chunk-pcb7fbyg.js +259 -0
  254. package/dist/chunk-pckwmrzd.js +409 -0
  255. package/dist/chunk-ped973jn.js +111 -0
  256. package/dist/chunk-phd1qfpc.js +5971 -0
  257. package/dist/chunk-pkkngdv0.js +524 -0
  258. package/dist/chunk-ppwjyveh.js +8 -0
  259. package/dist/chunk-pqvr8jq7.js +324 -0
  260. package/dist/chunk-prcah3ys.js +106 -0
  261. package/dist/chunk-ps49ymvj.js +43 -0
  262. package/dist/chunk-pwwa7s62.js +11 -0
  263. package/dist/chunk-pxdzy0jh.js +134 -0
  264. package/dist/chunk-q3jr5t07.js +62 -0
  265. package/dist/chunk-q6cfkntd.js +675 -0
  266. package/dist/chunk-q6m26rc8.js +88 -0
  267. package/dist/chunk-q6xs51jj.js +332 -0
  268. package/dist/chunk-q7jnesv8.js +74 -0
  269. package/dist/chunk-q7zpf4r2.js +440 -0
  270. package/dist/chunk-q8c88vjm.js +24 -0
  271. package/dist/chunk-qajrkk97.js +298 -0
  272. package/dist/chunk-qatfdxvd.js +34 -0
  273. package/dist/chunk-qb6k2afy.js +153 -0
  274. package/dist/chunk-qfk94vcn.js +329 -0
  275. package/dist/chunk-qj2e1apf.js +471 -0
  276. package/dist/chunk-qj2mk79w.js +111 -0
  277. package/dist/chunk-qk7dfae6.js +267 -0
  278. package/dist/chunk-qnfx3qtx.js +617 -0
  279. package/dist/chunk-qp2qdcda.js +100 -0
  280. package/dist/chunk-qq0phwn8.js +458 -0
  281. package/dist/chunk-qwqjesx7.js +258 -0
  282. package/dist/chunk-qygmcg7w.js +60 -0
  283. package/dist/chunk-qz2x630m.js +49145 -0
  284. package/dist/chunk-qzj4e8fn.js +357 -0
  285. package/dist/chunk-ratvcbmn.js +255 -0
  286. package/dist/chunk-rkg741k3.js +37 -0
  287. package/dist/chunk-rn0v1hk8.js +34 -0
  288. package/dist/chunk-rsq0h0rz.js +91 -0
  289. package/dist/chunk-rvnb2gn6.js +1053 -0
  290. package/dist/chunk-rx278zpa.js +75 -0
  291. package/dist/chunk-s3hsqf80.js +473 -0
  292. package/dist/chunk-s4cb0bcb.js +655 -0
  293. package/dist/chunk-s8kj6ajy.js +32 -0
  294. package/dist/chunk-sd36yzx8.js +954 -0
  295. package/dist/chunk-sfcpjh4r.js +98 -0
  296. package/dist/chunk-spybh2dy.js +175 -0
  297. package/dist/chunk-sw9ax3ym.js +92 -0
  298. package/dist/chunk-szj5wvdy.js +28 -0
  299. package/dist/chunk-t29a6zb5.js +45 -0
  300. package/dist/chunk-t9p85zff.js +24 -0
  301. package/dist/chunk-tc1aazk4.js +131 -0
  302. package/dist/chunk-tdbz9gbm.js +1030 -0
  303. package/dist/chunk-tjcfpk38.js +208 -0
  304. package/dist/chunk-tp2jxmcx.js +8427 -0
  305. package/dist/chunk-tqmtkm0k.js +92 -0
  306. package/dist/chunk-tvgvt220.js +22820 -0
  307. package/dist/chunk-v0qraze5.js +291 -0
  308. package/dist/chunk-v1kzp02e.js +785 -0
  309. package/dist/chunk-v78fj8by.js +145 -0
  310. package/dist/chunk-v8g3kad0.js +101 -0
  311. package/dist/chunk-v9smspw2.js +4301 -0
  312. package/dist/chunk-vawgyev5.js +157 -0
  313. package/dist/chunk-vb3x3cxe.js +375 -0
  314. package/dist/chunk-vf612n57.js +472 -0
  315. package/dist/chunk-vjn8mbcw.js +198 -0
  316. package/dist/chunk-vmbfv1y5.js +295 -0
  317. package/dist/chunk-vrf54kmt.js +321 -0
  318. package/dist/chunk-vyjeh50y.js +2149 -0
  319. package/dist/chunk-vzgkedm9.js +159745 -0
  320. package/dist/chunk-w004kfw0.js +245 -0
  321. package/dist/chunk-w0yhbmxn.js +132 -0
  322. package/dist/chunk-w4yn8cq7.js +123 -0
  323. package/dist/chunk-waqwgprq.js +1164 -0
  324. package/dist/chunk-wayfjcwt.js +447 -0
  325. package/dist/chunk-wby6yd4m.js +91 -0
  326. package/dist/chunk-wha6v7za.js +705 -0
  327. package/dist/chunk-wjcq2vkf.js +641 -0
  328. package/dist/chunk-wtjt9qyk.js +2670 -0
  329. package/dist/chunk-x2pvw7xw.js +42 -0
  330. package/dist/chunk-x6r4v44b.js +8 -0
  331. package/dist/chunk-x8d2ehd7.js +19 -0
  332. package/dist/chunk-xd6kmmb1.js +95 -0
  333. package/dist/chunk-xp61y5ba.js +125 -0
  334. package/dist/chunk-xv3era3s.js +8 -0
  335. package/dist/chunk-xxw9a0bq.js +58 -0
  336. package/dist/chunk-xzhaa7gd.js +112 -0
  337. package/dist/chunk-y1784krc.js +19 -0
  338. package/dist/chunk-y4ca9kqz.js +3830 -0
  339. package/dist/chunk-yff68ex1.js +113 -0
  340. package/dist/chunk-yg4vgpxs.js +436 -0
  341. package/dist/chunk-yk62vxj2.js +2964 -0
  342. package/dist/chunk-ym5r3jnk.js +2007 -0
  343. package/dist/chunk-ysanv95x.js +225 -0
  344. package/dist/chunk-yvtzznds.js +63 -0
  345. package/dist/chunk-yyex5gsf.js +269 -0
  346. package/dist/chunk-yyf72f78.js +456 -0
  347. package/dist/chunk-z19sd3bt.js +1648 -0
  348. package/dist/chunk-z2dp53wn.js +17 -0
  349. package/dist/chunk-z9n0183s.js +39 -0
  350. package/dist/chunk-zb8f6h5g.js +9174 -0
  351. package/dist/chunk-zctfbr1v.js +594 -0
  352. package/dist/chunk-zesnmkg3.js +2840 -0
  353. package/dist/chunk-zf47r1b7.js +94 -0
  354. package/dist/chunk-zghtdbat.js +253 -0
  355. package/dist/chunk-zpmwvd09.js +275 -0
  356. package/dist/chunk-zqncgyf6.js +127 -0
  357. package/dist/chunk-zr6mz36s.js +281 -0
  358. package/dist/chunk-zshzdw1n.js +141 -0
  359. package/dist/chunk-zx5kw7z4.js +40 -0
  360. package/dist/chunk-zzm33q8x.js +8 -0
  361. package/dist/cli.js +91 -0
  362. package/dist/download-ripgrep.js +24821 -0
  363. package/dist/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
  364. package/dist/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
  365. package/dist/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
  366. package/dist/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
  367. package/dist/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
  368. package/dist/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
  369. package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
  370. package/package.json +122 -0
  371. package/scripts/postinstall.cjs +319 -0
@@ -0,0 +1,3567 @@
1
+ // @bun
2
+ import {
3
+ AGENT_SOURCE_GROUPS,
4
+ compareAgentsByName,
5
+ getOverrideSourceLabel,
6
+ init_agentDisplay,
7
+ resolveAgentModelDisplay,
8
+ resolveAgentOverrides
9
+ } from "./chunk-26hg7303.js";
10
+ import {
11
+ init_useMergedTools,
12
+ useMergedTools
13
+ } from "./chunk-zx5kw7z4.js";
14
+ import"./chunk-5dmhsqap.js";
15
+ import"./chunk-gxahdggv.js";
16
+ import {
17
+ editFileInEditor,
18
+ editPromptInEditor,
19
+ init_promptEditor
20
+ } from "./chunk-p11xp4xp.js";
21
+ import {
22
+ init_useMainLoopModel,
23
+ useMainLoopModel
24
+ } from "./chunk-8y30k9pz.js";
25
+ import {
26
+ AGENT_COLORS,
27
+ AGENT_COLOR_TO_THEME_COLOR,
28
+ BashTool,
29
+ ConfigurableShortcutHint,
30
+ ExitPlanModeV2Tool,
31
+ FileEditTool,
32
+ FileReadTool,
33
+ FileWriteTool,
34
+ GlobTool,
35
+ GrepTool,
36
+ ListMcpResourcesTool,
37
+ Markdown,
38
+ NotebookEditTool,
39
+ ReadMcpResourceTool,
40
+ Select,
41
+ Spinner,
42
+ TaskOutputTool,
43
+ TaskStopTool,
44
+ TextInput,
45
+ TodoWriteTool,
46
+ WebFetchTool,
47
+ WebSearchTool,
48
+ asSystemPrompt,
49
+ capitalize_default,
50
+ createAbortController,
51
+ createUserMessage,
52
+ filterToolsForAgent,
53
+ getActiveAgentsFromList,
54
+ getAgentColor,
55
+ getAgentModelDisplay,
56
+ getAgentModelOptions,
57
+ getEmptyToolPermissionContext,
58
+ getMemoryScopeDisplay,
59
+ getTools,
60
+ getUserContext,
61
+ init_AppState,
62
+ init_BashTool,
63
+ init_ConfigurableShortcutHint,
64
+ init_ExitPlanModeV2Tool,
65
+ init_FileEditTool,
66
+ init_FileReadTool,
67
+ init_FileWriteTool,
68
+ init_GlobTool,
69
+ init_GrepTool,
70
+ init_ListMcpResourcesTool,
71
+ init_Markdown,
72
+ init_NotebookEditTool,
73
+ init_ReadMcpResourceTool,
74
+ init_Spinner,
75
+ init_TaskOutputTool,
76
+ init_TaskStopTool,
77
+ init_TextInput,
78
+ init_TodoWriteTool,
79
+ init_Tool,
80
+ init_WebFetchTool,
81
+ init_WebSearchTool,
82
+ init_abortController,
83
+ init_agent,
84
+ init_agentColorManager,
85
+ init_agentMemory,
86
+ init_agentToolUtils,
87
+ init_api,
88
+ init_capitalize,
89
+ init_claude,
90
+ init_context,
91
+ init_loadAgentsDir,
92
+ init_messages1 as init_messages,
93
+ init_select,
94
+ init_systemPromptType,
95
+ init_tools1 as init_tools,
96
+ init_utils,
97
+ isBuiltInAgent,
98
+ isCustomAgent,
99
+ isMcpTool,
100
+ isPluginAgent,
101
+ loadAgentMemoryPrompt,
102
+ normalizeMessagesForAPI,
103
+ prependUserContext,
104
+ queryModelWithoutStreaming,
105
+ resolveAgentTools,
106
+ setAgentColor,
107
+ useAppState,
108
+ useSetAppState
109
+ } from "./chunk-vzgkedm9.js";
110
+ import"./chunk-46hdszda.js";
111
+ import"./chunk-hwfknpxv.js";
112
+ import"./chunk-4nspekjp.js";
113
+ import"./chunk-jzthz1bx.js";
114
+ import"./chunk-1gx78081.js";
115
+ import"./chunk-2gzv8nrw.js";
116
+ import"./chunk-ehtwnxpg.js";
117
+ import"./chunk-68w91pzt.js";
118
+ import"./chunk-s4cb0bcb.js";
119
+ import"./chunk-cgfdkzhb.js";
120
+ import"./chunk-bxcfz5gy.js";
121
+ import"./chunk-nebezy1d.js";
122
+ import"./chunk-wayfjcwt.js";
123
+ import {
124
+ init_useExitOnCtrlCDWithKeybindings,
125
+ useExitOnCtrlCDWithKeybindings
126
+ } from "./chunk-kbm69rtz.js";
127
+ import"./chunk-j5bth84e.js";
128
+ import"./chunk-nxgsnh2y.js";
129
+ import {
130
+ init_useKeybinding
131
+ } from "./chunk-68ffk5qa.js";
132
+ import"./chunk-ps49ymvj.js";
133
+ import"./chunk-bmbq6nt1.js";
134
+ import"./chunk-15sfg4bs.js";
135
+ import {
136
+ TungstenTool,
137
+ init_TungstenTool
138
+ } from "./chunk-p7vkh4wx.js";
139
+ import"./chunk-b0qptb1k.js";
140
+ import"./chunk-m87bhhqv.js";
141
+ import"./chunk-j3zhb8vv.js";
142
+ import"./chunk-b2fd462a.js";
143
+ import"./chunk-c11swzas.js";
144
+ import"./chunk-chsyvavm.js";
145
+ import"./chunk-5rv9c8yd.js";
146
+ import {
147
+ AGENT_TOOL_NAME,
148
+ capitalize,
149
+ getManagedFilePath,
150
+ getSettingSourceName,
151
+ init_constants,
152
+ init_constants1 as init_constants2,
153
+ init_managedPath,
154
+ init_mcpStringUtils,
155
+ init_paths,
156
+ init_stringUtils,
157
+ isAutoMemoryEnabled,
158
+ mcpInfoFromString,
159
+ plural
160
+ } from "./chunk-tp2jxmcx.js";
161
+ import"./chunk-z19sd3bt.js";
162
+ import"./chunk-1ax1znzj.js";
163
+ import"./chunk-wha6v7za.js";
164
+ import {
165
+ count,
166
+ init_array
167
+ } from "./chunk-6nsd9606.js";
168
+ import"./chunk-xp61y5ba.js";
169
+ import"./chunk-64c1avct.js";
170
+ import"./chunk-8g5pe1gr.js";
171
+ import"./chunk-4cp6193g.js";
172
+ import"./chunk-8g747a8x.js";
173
+ import"./chunk-d7886r6a.js";
174
+ import"./chunk-yvtzznds.js";
175
+ import"./chunk-4jm600zv.js";
176
+ import"./chunk-qz2x630m.js";
177
+ import"./chunk-2f21meep.js";
178
+ import"./chunk-nrtksr2p.js";
179
+ import"./chunk-3c25bcsw.js";
180
+ import"./chunk-s3hsqf80.js";
181
+ import {
182
+ init_format,
183
+ truncateToWidth
184
+ } from "./chunk-yyf72f78.js";
185
+ import"./chunk-cdz5yb0r.js";
186
+ import {
187
+ Byline,
188
+ Dialog,
189
+ Divider,
190
+ KeyboardShortcutHint,
191
+ ThemedBox_default,
192
+ ThemedText,
193
+ init_source,
194
+ init_src,
195
+ source_default,
196
+ useKeybinding
197
+ } from "./chunk-c7jwbe76.js";
198
+ import"./chunk-0vkfrmqm.js";
199
+ import {
200
+ require_jsx_dev_runtime,
201
+ require_react
202
+ } from "./chunk-7sgtxrsc.js";
203
+ import"./chunk-0xjaqda8.js";
204
+ import {
205
+ init_analytics,
206
+ logEvent
207
+ } from "./chunk-x8d2ehd7.js";
208
+ import"./chunk-15m49c67.js";
209
+ import"./chunk-tdbz9gbm.js";
210
+ import"./chunk-0awwmrwr.js";
211
+ import"./chunk-qnfx3qtx.js";
212
+ import"./chunk-70eey1nh.js";
213
+ import {
214
+ init_log,
215
+ logError
216
+ } from "./chunk-1nk93fqz.js";
217
+ import {
218
+ getCwd,
219
+ init_cwd
220
+ } from "./chunk-s8kj6ajy.js";
221
+ import"./chunk-eenq3avg.js";
222
+ import"./chunk-7mqab3z7.js";
223
+ import"./chunk-5z28bqne.js";
224
+ import {
225
+ figures_default,
226
+ init_figures
227
+ } from "./chunk-qajrkk97.js";
228
+ import {
229
+ APIUserAbortError,
230
+ getErrnoCode,
231
+ init_errors,
232
+ init_sdk,
233
+ init_slowOperations,
234
+ jsonParse,
235
+ toError
236
+ } from "./chunk-phd1qfpc.js";
237
+ import"./chunk-fbv4apne.js";
238
+ import {
239
+ getClaudeConfigHomeDir,
240
+ init_envUtils
241
+ } from "./chunk-jaaxk89e.js";
242
+ import"./chunk-k8vp0atq.js";
243
+ import"./chunk-vf612n57.js";
244
+ import"./chunk-07069jq1.js";
245
+ import"./chunk-d4mdda98.js";
246
+ import"./chunk-55raexh7.js";
247
+ import"./chunk-v9smspw2.js";
248
+ import"./chunk-v1kzp02e.js";
249
+ import"./chunk-7wm5s02e.js";
250
+ import"./chunk-b0kf00ff.js";
251
+ import"./chunk-netzwgv1.js";
252
+ import {
253
+ __esm,
254
+ __toESM
255
+ } from "./chunk-qp2qdcda.js";
256
+
257
+ // src/components/agents/types.ts
258
+ var AGENT_PATHS;
259
+ var init_types = __esm(() => {
260
+ AGENT_PATHS = {
261
+ FOLDER_NAME: ".claude",
262
+ AGENTS_DIR: "agents"
263
+ };
264
+ });
265
+
266
+ // src/components/agents/agentFileUtils.ts
267
+ import { mkdir, open, unlink } from "fs/promises";
268
+ import { join } from "path";
269
+ function formatAgentAsMarkdown(agentType, whenToUse, tools, systemPrompt, color, model, memory, effort) {
270
+ const escapedWhenToUse = whenToUse.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\\\n");
271
+ const isAllTools = tools === undefined || tools.length === 1 && tools[0] === "*";
272
+ const toolsLine = isAllTools ? "" : `
273
+ tools: ${tools.join(", ")}`;
274
+ const modelLine = model ? `
275
+ model: ${model}` : "";
276
+ const effortLine = effort !== undefined ? `
277
+ effort: ${effort}` : "";
278
+ const colorLine = color ? `
279
+ color: ${color}` : "";
280
+ const memoryLine = memory ? `
281
+ memory: ${memory}` : "";
282
+ return `---
283
+ name: ${agentType}
284
+ description: "${escapedWhenToUse}"${toolsLine}${modelLine}${effortLine}${colorLine}${memoryLine}
285
+ ---
286
+
287
+ ${systemPrompt}
288
+ `;
289
+ }
290
+ function getAgentDirectoryPath(location) {
291
+ switch (location) {
292
+ case "flagSettings":
293
+ throw new Error(`Cannot get directory path for ${location} agents`);
294
+ case "userSettings":
295
+ return join(getClaudeConfigHomeDir(), AGENT_PATHS.AGENTS_DIR);
296
+ case "projectSettings":
297
+ return join(getCwd(), AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
298
+ case "policySettings":
299
+ return join(getManagedFilePath(), AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
300
+ case "localSettings":
301
+ return join(getCwd(), AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
302
+ }
303
+ }
304
+ function getRelativeAgentDirectoryPath(location) {
305
+ switch (location) {
306
+ case "projectSettings":
307
+ return join(".", AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
308
+ default:
309
+ return getAgentDirectoryPath(location);
310
+ }
311
+ }
312
+ function getNewAgentFilePath(agent) {
313
+ const dirPath = getAgentDirectoryPath(agent.source);
314
+ return join(dirPath, `${agent.agentType}.md`);
315
+ }
316
+ function getActualAgentFilePath(agent) {
317
+ if (agent.source === "built-in") {
318
+ return "Built-in";
319
+ }
320
+ if (agent.source === "plugin") {
321
+ throw new Error("Cannot get file path for plugin agents");
322
+ }
323
+ const dirPath = getAgentDirectoryPath(agent.source);
324
+ const filename = agent.filename || agent.agentType;
325
+ return join(dirPath, `${filename}.md`);
326
+ }
327
+ function getNewRelativeAgentFilePath(agent) {
328
+ if (agent.source === "built-in") {
329
+ return "Built-in";
330
+ }
331
+ const dirPath = getRelativeAgentDirectoryPath(agent.source);
332
+ return join(dirPath, `${agent.agentType}.md`);
333
+ }
334
+ function getActualRelativeAgentFilePath(agent) {
335
+ if (isBuiltInAgent(agent)) {
336
+ return "Built-in";
337
+ }
338
+ if (isPluginAgent(agent)) {
339
+ return `Plugin: ${agent.plugin || "Unknown"}`;
340
+ }
341
+ if (agent.source === "flagSettings") {
342
+ return "CLI argument";
343
+ }
344
+ const dirPath = getRelativeAgentDirectoryPath(agent.source);
345
+ const filename = agent.filename || agent.agentType;
346
+ return join(dirPath, `${filename}.md`);
347
+ }
348
+ async function ensureAgentDirectoryExists(source) {
349
+ const dirPath = getAgentDirectoryPath(source);
350
+ await mkdir(dirPath, { recursive: true });
351
+ return dirPath;
352
+ }
353
+ async function saveAgentToFile(source, agentType, whenToUse, tools, systemPrompt, checkExists = true, color, model, memory, effort) {
354
+ if (source === "built-in") {
355
+ throw new Error("Cannot save built-in agents");
356
+ }
357
+ await ensureAgentDirectoryExists(source);
358
+ const filePath = getNewAgentFilePath({ source, agentType });
359
+ const content = formatAgentAsMarkdown(agentType, whenToUse, tools, systemPrompt, color, model, memory, effort);
360
+ try {
361
+ await writeFileAndFlush(filePath, content, checkExists ? "wx" : "w");
362
+ } catch (e) {
363
+ if (getErrnoCode(e) === "EEXIST") {
364
+ throw new Error(`Agent file already exists: ${filePath}`);
365
+ }
366
+ throw e;
367
+ }
368
+ }
369
+ async function updateAgentFile(agent, newWhenToUse, newTools, newSystemPrompt, newColor, newModel, newMemory, newEffort) {
370
+ if (agent.source === "built-in") {
371
+ throw new Error("Cannot update built-in agents");
372
+ }
373
+ const filePath = getActualAgentFilePath(agent);
374
+ const content = formatAgentAsMarkdown(agent.agentType, newWhenToUse, newTools, newSystemPrompt, newColor, newModel, newMemory, newEffort);
375
+ await writeFileAndFlush(filePath, content);
376
+ }
377
+ async function deleteAgentFromFile(agent) {
378
+ if (agent.source === "built-in") {
379
+ throw new Error("Cannot delete built-in agents");
380
+ }
381
+ const filePath = getActualAgentFilePath(agent);
382
+ try {
383
+ await unlink(filePath);
384
+ } catch (e) {
385
+ const code = getErrnoCode(e);
386
+ if (code !== "ENOENT") {
387
+ throw e;
388
+ }
389
+ }
390
+ }
391
+ async function writeFileAndFlush(filePath, content, flag = "w") {
392
+ const handle = await open(filePath, flag);
393
+ try {
394
+ await handle.writeFile(content, { encoding: "utf-8" });
395
+ await handle.datasync();
396
+ } finally {
397
+ await handle.close();
398
+ }
399
+ }
400
+ var init_agentFileUtils = __esm(() => {
401
+ init_managedPath();
402
+ init_loadAgentsDir();
403
+ init_cwd();
404
+ init_envUtils();
405
+ init_errors();
406
+ init_types();
407
+ });
408
+
409
+ // src/components/agents/AgentDetail.tsx
410
+ function AgentDetail({ agent, tools, onBack }) {
411
+ const resolvedTools = resolveAgentTools(agent, tools, false);
412
+ const filePath = getActualRelativeAgentFilePath(agent);
413
+ const backgroundColor = getAgentColor(agent.agentType);
414
+ useKeybinding("confirm:no", onBack, { context: "Confirmation" });
415
+ const handleKeyDown = (e) => {
416
+ if (e.key === "return") {
417
+ e.preventDefault();
418
+ onBack();
419
+ }
420
+ };
421
+ function renderToolsList() {
422
+ if (resolvedTools.hasWildcard) {
423
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
424
+ children: "All tools"
425
+ }, undefined, false, undefined, this);
426
+ }
427
+ if (!agent.tools || agent.tools.length === 0) {
428
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
429
+ children: "None"
430
+ }, undefined, false, undefined, this);
431
+ }
432
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(jsx_dev_runtime.Fragment, {
433
+ children: [
434
+ resolvedTools.validTools.length > 0 && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
435
+ children: resolvedTools.validTools.join(", ")
436
+ }, undefined, false, undefined, this),
437
+ resolvedTools.invalidTools.length > 0 && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
438
+ color: "warning",
439
+ children: [
440
+ figures_default.warning,
441
+ " Unrecognized:",
442
+ " ",
443
+ resolvedTools.invalidTools.join(", ")
444
+ ]
445
+ }, undefined, true, undefined, this)
446
+ ]
447
+ }, undefined, true, undefined, this);
448
+ }
449
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
450
+ flexDirection: "column",
451
+ gap: 1,
452
+ tabIndex: 0,
453
+ autoFocus: true,
454
+ onKeyDown: handleKeyDown,
455
+ children: [
456
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
457
+ dimColor: true,
458
+ children: filePath
459
+ }, undefined, false, undefined, this),
460
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
461
+ flexDirection: "column",
462
+ children: [
463
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
464
+ children: [
465
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
466
+ bold: true,
467
+ children: "Description"
468
+ }, undefined, false, undefined, this),
469
+ " (tells Claude when to use this agent):"
470
+ ]
471
+ }, undefined, true, undefined, this),
472
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
473
+ marginLeft: 2,
474
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
475
+ children: agent.whenToUse
476
+ }, undefined, false, undefined, this)
477
+ }, undefined, false, undefined, this)
478
+ ]
479
+ }, undefined, true, undefined, this),
480
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
481
+ children: [
482
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
483
+ children: [
484
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
485
+ bold: true,
486
+ children: "Tools"
487
+ }, undefined, false, undefined, this),
488
+ ":",
489
+ " "
490
+ ]
491
+ }, undefined, true, undefined, this),
492
+ renderToolsList()
493
+ ]
494
+ }, undefined, true, undefined, this),
495
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
496
+ children: [
497
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
498
+ bold: true,
499
+ children: "Model"
500
+ }, undefined, false, undefined, this),
501
+ ": ",
502
+ getAgentModelDisplay(agent.model)
503
+ ]
504
+ }, undefined, true, undefined, this),
505
+ agent.permissionMode && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
506
+ children: [
507
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
508
+ bold: true,
509
+ children: "Permission mode"
510
+ }, undefined, false, undefined, this),
511
+ ": ",
512
+ agent.permissionMode
513
+ ]
514
+ }, undefined, true, undefined, this),
515
+ agent.memory && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
516
+ children: [
517
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
518
+ bold: true,
519
+ children: "Memory"
520
+ }, undefined, false, undefined, this),
521
+ ": ",
522
+ getMemoryScopeDisplay(agent.memory)
523
+ ]
524
+ }, undefined, true, undefined, this),
525
+ agent.hooks && Object.keys(agent.hooks).length > 0 && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
526
+ children: [
527
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
528
+ bold: true,
529
+ children: "Hooks"
530
+ }, undefined, false, undefined, this),
531
+ ": ",
532
+ Object.keys(agent.hooks).join(", ")
533
+ ]
534
+ }, undefined, true, undefined, this),
535
+ agent.skills && agent.skills.length > 0 && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
536
+ children: [
537
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
538
+ bold: true,
539
+ children: "Skills"
540
+ }, undefined, false, undefined, this),
541
+ ":",
542
+ " ",
543
+ agent.skills.length > 10 ? `${agent.skills.length} skills` : agent.skills.join(", ")
544
+ ]
545
+ }, undefined, true, undefined, this),
546
+ backgroundColor && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
547
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
548
+ children: [
549
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
550
+ bold: true,
551
+ children: "Color"
552
+ }, undefined, false, undefined, this),
553
+ ":",
554
+ " ",
555
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
556
+ backgroundColor,
557
+ color: "inverseText",
558
+ children: [
559
+ " ",
560
+ agent.agentType,
561
+ " "
562
+ ]
563
+ }, undefined, true, undefined, this)
564
+ ]
565
+ }, undefined, true, undefined, this)
566
+ }, undefined, false, undefined, this),
567
+ !isBuiltInAgent(agent) && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(jsx_dev_runtime.Fragment, {
568
+ children: [
569
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
570
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
571
+ children: [
572
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
573
+ bold: true,
574
+ children: "System prompt"
575
+ }, undefined, false, undefined, this),
576
+ ":"
577
+ ]
578
+ }, undefined, true, undefined, this)
579
+ }, undefined, false, undefined, this),
580
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
581
+ marginLeft: 2,
582
+ marginRight: 2,
583
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Markdown, {
584
+ children: agent.getSystemPrompt()
585
+ }, undefined, false, undefined, this)
586
+ }, undefined, false, undefined, this)
587
+ ]
588
+ }, undefined, true, undefined, this)
589
+ ]
590
+ }, undefined, true, undefined, this);
591
+ }
592
+ var jsx_dev_runtime;
593
+ var init_AgentDetail = __esm(() => {
594
+ init_figures();
595
+ init_src();
596
+ init_useKeybinding();
597
+ init_agentColorManager();
598
+ init_agentMemory();
599
+ init_agentToolUtils();
600
+ init_loadAgentsDir();
601
+ init_agent();
602
+ init_Markdown();
603
+ init_agentFileUtils();
604
+ jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
605
+ });
606
+
607
+ // src/components/agents/ColorPicker.tsx
608
+ function ColorPicker({
609
+ agentName,
610
+ currentColor = "automatic",
611
+ onConfirm
612
+ }) {
613
+ const [selectedIndex, setSelectedIndex] = import_react.useState(Math.max(0, COLOR_OPTIONS.findIndex((opt) => opt === currentColor)));
614
+ const handleKeyDown = (e) => {
615
+ if (e.key === "up") {
616
+ e.preventDefault();
617
+ setSelectedIndex((prev) => prev > 0 ? prev - 1 : COLOR_OPTIONS.length - 1);
618
+ } else if (e.key === "down") {
619
+ e.preventDefault();
620
+ setSelectedIndex((prev) => prev < COLOR_OPTIONS.length - 1 ? prev + 1 : 0);
621
+ } else if (e.key === "return") {
622
+ e.preventDefault();
623
+ const selected = COLOR_OPTIONS[selectedIndex];
624
+ onConfirm(selected === "automatic" ? undefined : selected);
625
+ }
626
+ };
627
+ const selectedValue = COLOR_OPTIONS[selectedIndex];
628
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
629
+ flexDirection: "column",
630
+ gap: 1,
631
+ tabIndex: 0,
632
+ autoFocus: true,
633
+ onKeyDown: handleKeyDown,
634
+ children: [
635
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
636
+ flexDirection: "column",
637
+ children: COLOR_OPTIONS.map((option, index) => {
638
+ const isSelected = index === selectedIndex;
639
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
640
+ flexDirection: "row",
641
+ gap: 1,
642
+ children: [
643
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
644
+ color: isSelected ? "suggestion" : undefined,
645
+ children: isSelected ? figures_default.pointer : " "
646
+ }, undefined, false, undefined, this),
647
+ option === "automatic" ? /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
648
+ bold: isSelected,
649
+ children: "Automatic color"
650
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
651
+ gap: 1,
652
+ children: [
653
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
654
+ backgroundColor: AGENT_COLOR_TO_THEME_COLOR[option],
655
+ color: "inverseText",
656
+ children: " "
657
+ }, undefined, false, undefined, this),
658
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
659
+ bold: isSelected,
660
+ children: capitalize(option)
661
+ }, undefined, false, undefined, this)
662
+ ]
663
+ }, undefined, true, undefined, this)
664
+ ]
665
+ }, option, true, undefined, this);
666
+ })
667
+ }, undefined, false, undefined, this),
668
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
669
+ marginTop: 1,
670
+ children: [
671
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
672
+ children: "Preview: "
673
+ }, undefined, false, undefined, this),
674
+ selectedValue === undefined || selectedValue === "automatic" ? /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
675
+ inverse: true,
676
+ bold: true,
677
+ children: [
678
+ " ",
679
+ "@",
680
+ agentName,
681
+ " "
682
+ ]
683
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
684
+ backgroundColor: AGENT_COLOR_TO_THEME_COLOR[selectedValue],
685
+ color: "inverseText",
686
+ bold: true,
687
+ children: [
688
+ " ",
689
+ "@",
690
+ agentName,
691
+ " "
692
+ ]
693
+ }, undefined, true, undefined, this)
694
+ ]
695
+ }, undefined, true, undefined, this)
696
+ ]
697
+ }, undefined, true, undefined, this);
698
+ }
699
+ var import_react, jsx_dev_runtime2, COLOR_OPTIONS;
700
+ var init_ColorPicker = __esm(() => {
701
+ init_figures();
702
+ init_src();
703
+ init_agentColorManager();
704
+ init_stringUtils();
705
+ import_react = __toESM(require_react(), 1);
706
+ jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
707
+ COLOR_OPTIONS = ["automatic", ...AGENT_COLORS];
708
+ });
709
+
710
+ // src/components/agents/ModelSelector.tsx
711
+ function ModelSelector({
712
+ initialModel,
713
+ onComplete,
714
+ onCancel
715
+ }) {
716
+ const modelOptions = React2.useMemo(() => {
717
+ const base = getAgentModelOptions();
718
+ if (initialModel && !base.some((o) => o.value === initialModel)) {
719
+ return [
720
+ {
721
+ value: initialModel,
722
+ label: initialModel,
723
+ description: "Current model (custom ID)"
724
+ },
725
+ ...base
726
+ ];
727
+ }
728
+ return base;
729
+ }, [initialModel]);
730
+ const defaultModel = initialModel ?? "sonnet";
731
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
732
+ flexDirection: "column",
733
+ children: [
734
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
735
+ marginBottom: 1,
736
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedText, {
737
+ dimColor: true,
738
+ children: "Model determines the agent's reasoning capabilities and speed."
739
+ }, undefined, false, undefined, this)
740
+ }, undefined, false, undefined, this),
741
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Select, {
742
+ options: modelOptions,
743
+ defaultValue: defaultModel,
744
+ onChange: onComplete,
745
+ onCancel: () => onCancel ? onCancel() : onComplete(undefined)
746
+ }, undefined, false, undefined, this)
747
+ ]
748
+ }, undefined, true, undefined, this);
749
+ }
750
+ var React2, jsx_dev_runtime3;
751
+ var init_ModelSelector = __esm(() => {
752
+ init_src();
753
+ init_agent();
754
+ init_select();
755
+ React2 = __toESM(require_react(), 1);
756
+ jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
757
+ });
758
+
759
+ // src/components/agents/ToolSelector.tsx
760
+ function getToolBuckets() {
761
+ return {
762
+ READ_ONLY: {
763
+ name: "Read-only tools",
764
+ toolNames: new Set([
765
+ GlobTool.name,
766
+ GrepTool.name,
767
+ ExitPlanModeV2Tool.name,
768
+ FileReadTool.name,
769
+ WebFetchTool.name,
770
+ TodoWriteTool.name,
771
+ WebSearchTool.name,
772
+ TaskStopTool.name,
773
+ TaskOutputTool.name,
774
+ ListMcpResourcesTool.name,
775
+ ReadMcpResourceTool.name
776
+ ])
777
+ },
778
+ EDIT: {
779
+ name: "Edit tools",
780
+ toolNames: new Set([
781
+ FileEditTool.name,
782
+ FileWriteTool.name,
783
+ NotebookEditTool.name
784
+ ])
785
+ },
786
+ EXECUTION: {
787
+ name: "Execution tools",
788
+ toolNames: new Set([
789
+ BashTool.name,
790
+ process.env.USER_TYPE === "ant" ? TungstenTool.name : undefined
791
+ ].filter((n) => n !== undefined))
792
+ },
793
+ MCP: {
794
+ name: "MCP tools",
795
+ toolNames: new Set,
796
+ isMcp: true
797
+ },
798
+ OTHER: {
799
+ name: "Other tools",
800
+ toolNames: new Set
801
+ }
802
+ };
803
+ }
804
+ function getMcpServerBuckets(tools) {
805
+ const serverMap = new Map;
806
+ tools.forEach((tool) => {
807
+ if (isMcpTool(tool)) {
808
+ const mcpInfo = mcpInfoFromString(tool.name);
809
+ if (mcpInfo?.serverName) {
810
+ const existing = serverMap.get(mcpInfo.serverName) || [];
811
+ existing.push(tool);
812
+ serverMap.set(mcpInfo.serverName, existing);
813
+ }
814
+ }
815
+ });
816
+ return Array.from(serverMap.entries()).map(([serverName, tools2]) => ({ serverName, tools: tools2 })).sort((a, b) => a.serverName.localeCompare(b.serverName));
817
+ }
818
+ function ToolSelector({
819
+ tools,
820
+ initialTools,
821
+ onComplete,
822
+ onCancel
823
+ }) {
824
+ const customAgentTools = import_react2.useMemo(() => filterToolsForAgent({ tools, isBuiltIn: false, isAsync: false }), [tools]);
825
+ const expandedInitialTools = !initialTools || initialTools.includes("*") ? customAgentTools.map((t) => t.name) : initialTools;
826
+ const [selectedTools, setSelectedTools] = import_react2.useState(expandedInitialTools);
827
+ const [focusIndex, setFocusIndex] = import_react2.useState(0);
828
+ const [showIndividualTools, setShowIndividualTools] = import_react2.useState(false);
829
+ const validSelectedTools = import_react2.useMemo(() => {
830
+ const toolNames = new Set(customAgentTools.map((t) => t.name));
831
+ return selectedTools.filter((name) => toolNames.has(name));
832
+ }, [selectedTools, customAgentTools]);
833
+ const selectedSet = new Set(validSelectedTools);
834
+ const isAllSelected = validSelectedTools.length === customAgentTools.length && customAgentTools.length > 0;
835
+ const handleToggleTool = (toolName) => {
836
+ if (!toolName)
837
+ return;
838
+ setSelectedTools((current) => current.includes(toolName) ? current.filter((t) => t !== toolName) : [...current, toolName]);
839
+ };
840
+ const handleToggleTools = (toolNames, select) => {
841
+ setSelectedTools((current) => {
842
+ if (select) {
843
+ const toolsToAdd = toolNames.filter((t) => !current.includes(t));
844
+ return [...current, ...toolsToAdd];
845
+ } else {
846
+ return current.filter((t) => !toolNames.includes(t));
847
+ }
848
+ });
849
+ };
850
+ const handleConfirm = () => {
851
+ const allToolNames = customAgentTools.map((t) => t.name);
852
+ const areAllToolsSelected = validSelectedTools.length === allToolNames.length && allToolNames.every((name) => validSelectedTools.includes(name));
853
+ const finalTools = areAllToolsSelected ? undefined : validSelectedTools;
854
+ onComplete(finalTools);
855
+ };
856
+ const toolsByBucket = import_react2.useMemo(() => {
857
+ const toolBuckets2 = getToolBuckets();
858
+ const buckets = {
859
+ readOnly: [],
860
+ edit: [],
861
+ execution: [],
862
+ mcp: [],
863
+ other: []
864
+ };
865
+ customAgentTools.forEach((tool) => {
866
+ if (isMcpTool(tool)) {
867
+ buckets.mcp.push(tool);
868
+ } else if (toolBuckets2.READ_ONLY.toolNames.has(tool.name)) {
869
+ buckets.readOnly.push(tool);
870
+ } else if (toolBuckets2.EDIT.toolNames.has(tool.name)) {
871
+ buckets.edit.push(tool);
872
+ } else if (toolBuckets2.EXECUTION.toolNames.has(tool.name)) {
873
+ buckets.execution.push(tool);
874
+ } else if (tool.name !== AGENT_TOOL_NAME) {
875
+ buckets.other.push(tool);
876
+ }
877
+ });
878
+ return buckets;
879
+ }, [customAgentTools]);
880
+ const createBucketToggleAction = (bucketTools) => {
881
+ const selected = count(bucketTools, (t) => selectedSet.has(t.name));
882
+ const needsSelection = selected < bucketTools.length;
883
+ return () => {
884
+ const toolNames = bucketTools.map((t) => t.name);
885
+ handleToggleTools(toolNames, needsSelection);
886
+ };
887
+ };
888
+ const navigableItems = [];
889
+ navigableItems.push({
890
+ id: "continue",
891
+ label: "Continue",
892
+ action: handleConfirm,
893
+ isContinue: true
894
+ });
895
+ navigableItems.push({
896
+ id: "bucket-all",
897
+ label: `${isAllSelected ? figures_default.checkboxOn : figures_default.checkboxOff} All tools`,
898
+ action: () => {
899
+ const allToolNames = customAgentTools.map((t) => t.name);
900
+ handleToggleTools(allToolNames, !isAllSelected);
901
+ }
902
+ });
903
+ const toolBuckets = getToolBuckets();
904
+ const bucketConfigs = [
905
+ {
906
+ id: "bucket-readonly",
907
+ name: toolBuckets.READ_ONLY.name,
908
+ tools: toolsByBucket.readOnly
909
+ },
910
+ {
911
+ id: "bucket-edit",
912
+ name: toolBuckets.EDIT.name,
913
+ tools: toolsByBucket.edit
914
+ },
915
+ {
916
+ id: "bucket-execution",
917
+ name: toolBuckets.EXECUTION.name,
918
+ tools: toolsByBucket.execution
919
+ },
920
+ {
921
+ id: "bucket-mcp",
922
+ name: toolBuckets.MCP.name,
923
+ tools: toolsByBucket.mcp
924
+ },
925
+ {
926
+ id: "bucket-other",
927
+ name: toolBuckets.OTHER.name,
928
+ tools: toolsByBucket.other
929
+ }
930
+ ];
931
+ bucketConfigs.forEach(({ id, name, tools: bucketTools }) => {
932
+ if (bucketTools.length === 0)
933
+ return;
934
+ const selected = count(bucketTools, (t) => selectedSet.has(t.name));
935
+ const isFullySelected = selected === bucketTools.length;
936
+ navigableItems.push({
937
+ id,
938
+ label: `${isFullySelected ? figures_default.checkboxOn : figures_default.checkboxOff} ${name}`,
939
+ action: createBucketToggleAction(bucketTools)
940
+ });
941
+ });
942
+ const toggleButtonIndex = navigableItems.length;
943
+ navigableItems.push({
944
+ id: "toggle-individual",
945
+ label: showIndividualTools ? "Hide advanced options" : "Show advanced options",
946
+ action: () => {
947
+ setShowIndividualTools(!showIndividualTools);
948
+ if (showIndividualTools && focusIndex > toggleButtonIndex) {
949
+ setFocusIndex(toggleButtonIndex);
950
+ }
951
+ },
952
+ isToggle: true
953
+ });
954
+ const mcpServerBuckets = import_react2.useMemo(() => getMcpServerBuckets(customAgentTools), [customAgentTools]);
955
+ if (showIndividualTools) {
956
+ if (mcpServerBuckets.length > 0) {
957
+ navigableItems.push({
958
+ id: "mcp-servers-header",
959
+ label: "MCP Servers:",
960
+ action: () => {},
961
+ isHeader: true
962
+ });
963
+ mcpServerBuckets.forEach(({ serverName, tools: serverTools }) => {
964
+ const selected = count(serverTools, (t) => selectedSet.has(t.name));
965
+ const isFullySelected = selected === serverTools.length;
966
+ navigableItems.push({
967
+ id: `mcp-server-${serverName}`,
968
+ label: `${isFullySelected ? figures_default.checkboxOn : figures_default.checkboxOff} ${serverName} (${serverTools.length} ${plural(serverTools.length, "tool")})`,
969
+ action: () => {
970
+ const toolNames = serverTools.map((t) => t.name);
971
+ handleToggleTools(toolNames, !isFullySelected);
972
+ }
973
+ });
974
+ });
975
+ navigableItems.push({
976
+ id: "tools-header",
977
+ label: "Individual Tools:",
978
+ action: () => {},
979
+ isHeader: true
980
+ });
981
+ }
982
+ customAgentTools.forEach((tool) => {
983
+ let displayName = tool.name;
984
+ if (tool.name.startsWith("mcp__")) {
985
+ const mcpInfo = mcpInfoFromString(tool.name);
986
+ displayName = mcpInfo ? `${mcpInfo.toolName} (${mcpInfo.serverName})` : tool.name;
987
+ }
988
+ navigableItems.push({
989
+ id: `tool-${tool.name}`,
990
+ label: `${selectedSet.has(tool.name) ? figures_default.checkboxOn : figures_default.checkboxOff} ${displayName}`,
991
+ action: () => handleToggleTool(tool.name)
992
+ });
993
+ });
994
+ }
995
+ const handleCancel = import_react2.useCallback(() => {
996
+ if (onCancel) {
997
+ onCancel();
998
+ } else {
999
+ onComplete(initialTools);
1000
+ }
1001
+ }, [onCancel, onComplete, initialTools]);
1002
+ useKeybinding("confirm:no", handleCancel, { context: "Confirmation" });
1003
+ const handleKeyDown = (e) => {
1004
+ if (e.key === "return") {
1005
+ e.preventDefault();
1006
+ const item = navigableItems[focusIndex];
1007
+ if (item && !item.isHeader) {
1008
+ item.action();
1009
+ }
1010
+ } else if (e.key === "up") {
1011
+ e.preventDefault();
1012
+ let newIndex = focusIndex - 1;
1013
+ while (newIndex > 0 && navigableItems[newIndex]?.isHeader) {
1014
+ newIndex--;
1015
+ }
1016
+ setFocusIndex(Math.max(0, newIndex));
1017
+ } else if (e.key === "down") {
1018
+ e.preventDefault();
1019
+ let newIndex = focusIndex + 1;
1020
+ while (newIndex < navigableItems.length - 1 && navigableItems[newIndex]?.isHeader) {
1021
+ newIndex++;
1022
+ }
1023
+ setFocusIndex(Math.min(navigableItems.length - 1, newIndex));
1024
+ }
1025
+ };
1026
+ return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1027
+ flexDirection: "column",
1028
+ marginTop: 1,
1029
+ tabIndex: 0,
1030
+ autoFocus: true,
1031
+ onKeyDown: handleKeyDown,
1032
+ children: [
1033
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1034
+ color: focusIndex === 0 ? "suggestion" : undefined,
1035
+ bold: focusIndex === 0,
1036
+ children: [
1037
+ focusIndex === 0 ? `${figures_default.pointer} ` : " ",
1038
+ "[ Continue ]"
1039
+ ]
1040
+ }, undefined, true, undefined, this),
1041
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Divider, {
1042
+ width: 40
1043
+ }, undefined, false, undefined, this),
1044
+ navigableItems.slice(1).map((item, index) => {
1045
+ const isCurrentlyFocused = index + 1 === focusIndex;
1046
+ const isToggleButton = item.isToggle;
1047
+ const isHeader = item.isHeader;
1048
+ return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_react2.default.Fragment, {
1049
+ children: [
1050
+ isToggleButton && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Divider, {
1051
+ width: 40
1052
+ }, undefined, false, undefined, this),
1053
+ isHeader && index > 0 && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1054
+ marginTop: 1
1055
+ }, undefined, false, undefined, this),
1056
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1057
+ color: isHeader ? undefined : isCurrentlyFocused ? "suggestion" : undefined,
1058
+ dimColor: isHeader,
1059
+ bold: isToggleButton && isCurrentlyFocused,
1060
+ children: [
1061
+ isHeader ? "" : isCurrentlyFocused ? `${figures_default.pointer} ` : " ",
1062
+ isToggleButton ? `[ ${item.label} ]` : item.label
1063
+ ]
1064
+ }, undefined, true, undefined, this)
1065
+ ]
1066
+ }, item.id, true, undefined, this);
1067
+ }),
1068
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1069
+ marginTop: 1,
1070
+ flexDirection: "column",
1071
+ children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1072
+ dimColor: true,
1073
+ children: isAllSelected ? "All tools selected" : `${selectedSet.size} of ${customAgentTools.length} tools selected`
1074
+ }, undefined, false, undefined, this)
1075
+ }, undefined, false, undefined, this)
1076
+ ]
1077
+ }, undefined, true, undefined, this);
1078
+ }
1079
+ var import_react2, jsx_dev_runtime4;
1080
+ var init_ToolSelector = __esm(() => {
1081
+ init_figures();
1082
+ init_mcpStringUtils();
1083
+ init_utils();
1084
+ init_agentToolUtils();
1085
+ init_constants2();
1086
+ init_BashTool();
1087
+ init_ExitPlanModeV2Tool();
1088
+ init_FileEditTool();
1089
+ init_FileReadTool();
1090
+ init_FileWriteTool();
1091
+ init_GlobTool();
1092
+ init_GrepTool();
1093
+ init_ListMcpResourcesTool();
1094
+ init_NotebookEditTool();
1095
+ init_ReadMcpResourceTool();
1096
+ init_TaskOutputTool();
1097
+ init_TaskStopTool();
1098
+ init_TodoWriteTool();
1099
+ init_TungstenTool();
1100
+ init_WebFetchTool();
1101
+ init_WebSearchTool();
1102
+ init_src();
1103
+ init_useKeybinding();
1104
+ init_array();
1105
+ init_stringUtils();
1106
+ init_src();
1107
+ import_react2 = __toESM(require_react(), 1);
1108
+ jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
1109
+ });
1110
+
1111
+ // src/components/agents/utils.ts
1112
+ function getAgentSourceDisplayName(source) {
1113
+ if (source === "all") {
1114
+ return "Agents";
1115
+ }
1116
+ if (source === "built-in") {
1117
+ return "Built-in agents";
1118
+ }
1119
+ if (source === "plugin") {
1120
+ return "Plugin agents";
1121
+ }
1122
+ return capitalize_default(getSettingSourceName(source));
1123
+ }
1124
+ var init_utils2 = __esm(() => {
1125
+ init_capitalize();
1126
+ init_constants();
1127
+ });
1128
+
1129
+ // src/components/agents/AgentEditor.tsx
1130
+ function AgentEditor({
1131
+ agent,
1132
+ tools,
1133
+ onSaved,
1134
+ onBack
1135
+ }) {
1136
+ const setAppState = useSetAppState();
1137
+ const [editMode, setEditMode] = import_react3.useState("menu");
1138
+ const [selectedMenuIndex, setSelectedMenuIndex] = import_react3.useState(0);
1139
+ const [error, setError] = import_react3.useState(null);
1140
+ const [selectedColor, setSelectedColor] = import_react3.useState(agent.color);
1141
+ const handleOpenInEditor = import_react3.useCallback(async () => {
1142
+ const filePath = getActualAgentFilePath(agent);
1143
+ const result = await editFileInEditor(filePath);
1144
+ if (result.error) {
1145
+ setError(result.error);
1146
+ } else {
1147
+ onSaved(`Opened ${agent.agentType} in editor. If you made edits, restart to load the latest version.`);
1148
+ }
1149
+ }, [agent, onSaved]);
1150
+ const handleSave = import_react3.useCallback(async (changes = {}) => {
1151
+ const { tools: newTools, color: newColor, model: newModel } = changes;
1152
+ const finalColor = newColor ?? selectedColor;
1153
+ const hasToolsChanged = newTools !== undefined;
1154
+ const hasModelChanged = newModel !== undefined;
1155
+ const hasColorChanged = finalColor !== agent.color;
1156
+ if (!hasToolsChanged && !hasModelChanged && !hasColorChanged) {
1157
+ return false;
1158
+ }
1159
+ try {
1160
+ if (!isCustomAgent(agent) && !isPluginAgent(agent)) {
1161
+ return false;
1162
+ }
1163
+ await updateAgentFile(agent, agent.whenToUse, newTools ?? agent.tools, agent.getSystemPrompt(), finalColor, newModel ?? agent.model);
1164
+ if (hasColorChanged && finalColor) {
1165
+ setAgentColor(agent.agentType, finalColor);
1166
+ }
1167
+ setAppState((state) => {
1168
+ const allAgents = state.agentDefinitions.allAgents.map((a) => a.agentType === agent.agentType ? {
1169
+ ...a,
1170
+ tools: newTools ?? a.tools,
1171
+ color: finalColor,
1172
+ model: newModel ?? a.model
1173
+ } : a);
1174
+ return {
1175
+ ...state,
1176
+ agentDefinitions: {
1177
+ ...state.agentDefinitions,
1178
+ activeAgents: getActiveAgentsFromList(allAgents),
1179
+ allAgents
1180
+ }
1181
+ };
1182
+ });
1183
+ onSaved(`Updated agent: ${source_default.bold(agent.agentType)}`);
1184
+ return true;
1185
+ } catch (err) {
1186
+ setError(err instanceof Error ? err.message : "Failed to save agent");
1187
+ return false;
1188
+ }
1189
+ }, [agent, selectedColor, onSaved, setAppState]);
1190
+ const menuItems = import_react3.useMemo(() => [
1191
+ { label: "Open in editor", action: handleOpenInEditor },
1192
+ { label: "Edit tools", action: () => setEditMode("edit-tools") },
1193
+ { label: "Edit model", action: () => setEditMode("edit-model") },
1194
+ { label: "Edit color", action: () => setEditMode("edit-color") }
1195
+ ], [handleOpenInEditor]);
1196
+ const handleEscape = import_react3.useCallback(() => {
1197
+ setError(null);
1198
+ if (editMode === "menu") {
1199
+ onBack();
1200
+ } else {
1201
+ setEditMode("menu");
1202
+ }
1203
+ }, [editMode, onBack]);
1204
+ const handleMenuKeyDown = import_react3.useCallback((e) => {
1205
+ if (e.key === "up") {
1206
+ e.preventDefault();
1207
+ setSelectedMenuIndex((index) => Math.max(0, index - 1));
1208
+ } else if (e.key === "down") {
1209
+ e.preventDefault();
1210
+ setSelectedMenuIndex((index) => Math.min(menuItems.length - 1, index + 1));
1211
+ } else if (e.key === "return") {
1212
+ e.preventDefault();
1213
+ const selectedItem = menuItems[selectedMenuIndex];
1214
+ if (selectedItem) {
1215
+ selectedItem.action();
1216
+ }
1217
+ }
1218
+ }, [menuItems, selectedMenuIndex]);
1219
+ useKeybinding("confirm:no", handleEscape, { context: "Confirmation" });
1220
+ const renderMenu = () => /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
1221
+ flexDirection: "column",
1222
+ tabIndex: 0,
1223
+ autoFocus: true,
1224
+ onKeyDown: handleMenuKeyDown,
1225
+ children: [
1226
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedText, {
1227
+ dimColor: true,
1228
+ children: [
1229
+ "Source: ",
1230
+ getAgentSourceDisplayName(agent.source)
1231
+ ]
1232
+ }, undefined, true, undefined, this),
1233
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
1234
+ marginTop: 1,
1235
+ flexDirection: "column",
1236
+ children: menuItems.map((item, index) => /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedText, {
1237
+ color: index === selectedMenuIndex ? "suggestion" : undefined,
1238
+ children: [
1239
+ index === selectedMenuIndex ? `${figures_default.pointer} ` : " ",
1240
+ item.label
1241
+ ]
1242
+ }, item.label, true, undefined, this))
1243
+ }, undefined, false, undefined, this),
1244
+ error && /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
1245
+ marginTop: 1,
1246
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedText, {
1247
+ color: "error",
1248
+ children: error
1249
+ }, undefined, false, undefined, this)
1250
+ }, undefined, false, undefined, this)
1251
+ ]
1252
+ }, undefined, true, undefined, this);
1253
+ switch (editMode) {
1254
+ case "menu":
1255
+ return renderMenu();
1256
+ case "edit-tools":
1257
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ToolSelector, {
1258
+ tools,
1259
+ initialTools: agent.tools,
1260
+ onComplete: async (finalTools) => {
1261
+ setEditMode("menu");
1262
+ await handleSave({ tools: finalTools });
1263
+ }
1264
+ }, undefined, false, undefined, this);
1265
+ case "edit-color":
1266
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ColorPicker, {
1267
+ agentName: agent.agentType,
1268
+ currentColor: selectedColor || agent.color || "automatic",
1269
+ onConfirm: async (color) => {
1270
+ setSelectedColor(color);
1271
+ setEditMode("menu");
1272
+ await handleSave({ color });
1273
+ }
1274
+ }, undefined, false, undefined, this);
1275
+ case "edit-model":
1276
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ModelSelector, {
1277
+ initialModel: agent.model,
1278
+ onComplete: async (model) => {
1279
+ setEditMode("menu");
1280
+ await handleSave({ model });
1281
+ }
1282
+ }, undefined, false, undefined, this);
1283
+ default:
1284
+ return null;
1285
+ }
1286
+ }
1287
+ var import_react3, jsx_dev_runtime5;
1288
+ var init_AgentEditor = __esm(() => {
1289
+ init_source();
1290
+ init_figures();
1291
+ init_AppState();
1292
+ init_src();
1293
+ init_useKeybinding();
1294
+ init_agentColorManager();
1295
+ init_loadAgentsDir();
1296
+ init_promptEditor();
1297
+ init_agentFileUtils();
1298
+ init_ColorPicker();
1299
+ init_ModelSelector();
1300
+ init_ToolSelector();
1301
+ init_utils2();
1302
+ import_react3 = __toESM(require_react(), 1);
1303
+ jsx_dev_runtime5 = __toESM(require_jsx_dev_runtime(), 1);
1304
+ });
1305
+
1306
+ // src/components/agents/AgentNavigationFooter.tsx
1307
+ function AgentNavigationFooter({
1308
+ instructions = "Press \u2191\u2193 to navigate \xB7 Enter to select \xB7 Esc to go back"
1309
+ }) {
1310
+ const exitState = useExitOnCtrlCDWithKeybindings();
1311
+ return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(ThemedBox_default, {
1312
+ marginLeft: 2,
1313
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(ThemedText, {
1314
+ dimColor: true,
1315
+ children: exitState.pending ? `Press ${exitState.keyName} again to exit` : instructions
1316
+ }, undefined, false, undefined, this)
1317
+ }, undefined, false, undefined, this);
1318
+ }
1319
+ var jsx_dev_runtime6;
1320
+ var init_AgentNavigationFooter = __esm(() => {
1321
+ init_useExitOnCtrlCDWithKeybindings();
1322
+ init_src();
1323
+ jsx_dev_runtime6 = __toESM(require_jsx_dev_runtime(), 1);
1324
+ });
1325
+
1326
+ // src/components/agents/AgentsList.tsx
1327
+ function AgentsList({
1328
+ source,
1329
+ agents,
1330
+ onBack,
1331
+ onSelect,
1332
+ onCreateNew,
1333
+ changes
1334
+ }) {
1335
+ const [selectedAgent, setSelectedAgent] = React4.useState(null);
1336
+ const [isCreateNewSelected, setIsCreateNewSelected] = React4.useState(true);
1337
+ const sortedAgents = React4.useMemo(() => [...agents].sort(compareAgentsByName), [agents]);
1338
+ const getOverrideInfo = (agent) => {
1339
+ return {
1340
+ isOverridden: !!agent.overriddenBy,
1341
+ overriddenBy: agent.overriddenBy || null
1342
+ };
1343
+ };
1344
+ const renderCreateNewOption = () => {
1345
+ return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1346
+ children: [
1347
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1348
+ color: isCreateNewSelected ? "suggestion" : undefined,
1349
+ children: isCreateNewSelected ? `${figures_default.pointer} ` : " "
1350
+ }, undefined, false, undefined, this),
1351
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1352
+ color: isCreateNewSelected ? "suggestion" : undefined,
1353
+ children: "Create new agent"
1354
+ }, undefined, false, undefined, this)
1355
+ ]
1356
+ }, undefined, true, undefined, this);
1357
+ };
1358
+ const renderAgent = (agent) => {
1359
+ const isBuiltIn = agent.source === "built-in";
1360
+ const isSelected = !isBuiltIn && !isCreateNewSelected && selectedAgent?.agentType === agent.agentType && selectedAgent?.source === agent.source;
1361
+ const { isOverridden, overriddenBy } = getOverrideInfo(agent);
1362
+ const dimmed = isBuiltIn || isOverridden;
1363
+ const textColor = !isBuiltIn && isSelected ? "suggestion" : undefined;
1364
+ const resolvedModel = resolveAgentModelDisplay(agent);
1365
+ return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1366
+ children: [
1367
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1368
+ dimColor: dimmed && !isSelected,
1369
+ color: textColor,
1370
+ children: isBuiltIn ? "" : isSelected ? `${figures_default.pointer} ` : " "
1371
+ }, undefined, false, undefined, this),
1372
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1373
+ dimColor: dimmed && !isSelected,
1374
+ color: textColor,
1375
+ children: agent.agentType
1376
+ }, undefined, false, undefined, this),
1377
+ resolvedModel && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1378
+ dimColor: true,
1379
+ color: textColor,
1380
+ children: [
1381
+ " \xB7 ",
1382
+ resolvedModel
1383
+ ]
1384
+ }, undefined, true, undefined, this),
1385
+ agent.memory && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1386
+ dimColor: true,
1387
+ color: textColor,
1388
+ children: [
1389
+ " \xB7 ",
1390
+ agent.memory,
1391
+ " memory"
1392
+ ]
1393
+ }, undefined, true, undefined, this),
1394
+ overriddenBy && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1395
+ dimColor: !isSelected,
1396
+ color: isSelected ? "warning" : undefined,
1397
+ children: [
1398
+ " ",
1399
+ figures_default.warning,
1400
+ " shadowed by ",
1401
+ getOverrideSourceLabel(overriddenBy)
1402
+ ]
1403
+ }, undefined, true, undefined, this)
1404
+ ]
1405
+ }, `${agent.agentType}-${agent.source}`, true, undefined, this);
1406
+ };
1407
+ const selectableAgentsInOrder = React4.useMemo(() => {
1408
+ const nonBuiltIn = sortedAgents.filter((a) => a.source !== "built-in");
1409
+ if (source === "all") {
1410
+ return AGENT_SOURCE_GROUPS.filter((g) => g.source !== "built-in").flatMap(({ source: groupSource }) => nonBuiltIn.filter((a) => a.source === groupSource));
1411
+ }
1412
+ return nonBuiltIn;
1413
+ }, [sortedAgents, source]);
1414
+ React4.useEffect(() => {
1415
+ if (!selectedAgent && !isCreateNewSelected && selectableAgentsInOrder.length > 0) {
1416
+ if (onCreateNew) {
1417
+ setIsCreateNewSelected(true);
1418
+ } else {
1419
+ setSelectedAgent(selectableAgentsInOrder[0] || null);
1420
+ }
1421
+ }
1422
+ }, [selectableAgentsInOrder, selectedAgent, isCreateNewSelected, onCreateNew]);
1423
+ const handleKeyDown = (e) => {
1424
+ if (e.key === "return") {
1425
+ e.preventDefault();
1426
+ if (isCreateNewSelected && onCreateNew) {
1427
+ onCreateNew();
1428
+ } else if (selectedAgent) {
1429
+ onSelect(selectedAgent);
1430
+ }
1431
+ return;
1432
+ }
1433
+ if (e.key !== "up" && e.key !== "down")
1434
+ return;
1435
+ e.preventDefault();
1436
+ const hasCreateOption = !!onCreateNew;
1437
+ const totalItems = selectableAgentsInOrder.length + (hasCreateOption ? 1 : 0);
1438
+ if (totalItems === 0)
1439
+ return;
1440
+ let currentPosition = 0;
1441
+ if (!isCreateNewSelected && selectedAgent) {
1442
+ const agentIndex = selectableAgentsInOrder.findIndex((a) => a.agentType === selectedAgent.agentType && a.source === selectedAgent.source);
1443
+ if (agentIndex >= 0) {
1444
+ currentPosition = hasCreateOption ? agentIndex + 1 : agentIndex;
1445
+ }
1446
+ }
1447
+ const newPosition = e.key === "up" ? currentPosition === 0 ? totalItems - 1 : currentPosition - 1 : currentPosition === totalItems - 1 ? 0 : currentPosition + 1;
1448
+ if (hasCreateOption && newPosition === 0) {
1449
+ setIsCreateNewSelected(true);
1450
+ setSelectedAgent(null);
1451
+ } else {
1452
+ const agentIndex = hasCreateOption ? newPosition - 1 : newPosition;
1453
+ const newAgent = selectableAgentsInOrder[agentIndex];
1454
+ if (newAgent) {
1455
+ setIsCreateNewSelected(false);
1456
+ setSelectedAgent(newAgent);
1457
+ }
1458
+ }
1459
+ };
1460
+ const renderBuiltInAgentsSection = (title = "Built-in (always available):") => {
1461
+ const builtInAgents2 = sortedAgents.filter((a) => a.source === "built-in");
1462
+ return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1463
+ flexDirection: "column",
1464
+ marginBottom: 1,
1465
+ paddingLeft: 2,
1466
+ children: [
1467
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1468
+ bold: true,
1469
+ dimColor: true,
1470
+ children: title
1471
+ }, undefined, false, undefined, this),
1472
+ builtInAgents2.map(renderAgent)
1473
+ ]
1474
+ }, undefined, true, undefined, this);
1475
+ };
1476
+ const renderAgentGroup = (title, groupAgents) => {
1477
+ if (!groupAgents.length)
1478
+ return null;
1479
+ const folderPath = groupAgents[0]?.baseDir;
1480
+ return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1481
+ flexDirection: "column",
1482
+ marginBottom: 1,
1483
+ children: [
1484
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1485
+ paddingLeft: 2,
1486
+ children: [
1487
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1488
+ bold: true,
1489
+ dimColor: true,
1490
+ children: title
1491
+ }, undefined, false, undefined, this),
1492
+ folderPath && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1493
+ dimColor: true,
1494
+ children: [
1495
+ " (",
1496
+ folderPath,
1497
+ ")"
1498
+ ]
1499
+ }, undefined, true, undefined, this)
1500
+ ]
1501
+ }, undefined, true, undefined, this),
1502
+ groupAgents.map((agent) => renderAgent(agent))
1503
+ ]
1504
+ }, undefined, true, undefined, this);
1505
+ };
1506
+ const sourceTitle = getAgentSourceDisplayName(source);
1507
+ const builtInAgents = sortedAgents.filter((a) => a.source === "built-in");
1508
+ const hasNoAgents = !sortedAgents.length || source !== "built-in" && !sortedAgents.some((a) => a.source !== "built-in");
1509
+ if (hasNoAgents) {
1510
+ return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Dialog, {
1511
+ title: sourceTitle,
1512
+ subtitle: "No agents found",
1513
+ onCancel: onBack,
1514
+ hideInputGuide: true,
1515
+ children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1516
+ flexDirection: "column",
1517
+ gap: 1,
1518
+ tabIndex: 0,
1519
+ autoFocus: true,
1520
+ onKeyDown: handleKeyDown,
1521
+ children: [
1522
+ onCreateNew && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1523
+ children: renderCreateNewOption()
1524
+ }, undefined, false, undefined, this),
1525
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1526
+ dimColor: true,
1527
+ children: "No agents found. Create specialized subagents that Claude can delegate to."
1528
+ }, undefined, false, undefined, this),
1529
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1530
+ dimColor: true,
1531
+ children: "Each subagent has its own context window, custom system prompt, and specific tools."
1532
+ }, undefined, false, undefined, this),
1533
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1534
+ dimColor: true,
1535
+ children: "Try creating: Code Reviewer, Code Simplifier, Security Reviewer, Tech Lead, or UX Reviewer."
1536
+ }, undefined, false, undefined, this),
1537
+ source !== "built-in" && sortedAgents.some((a) => a.source === "built-in") && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(jsx_dev_runtime7.Fragment, {
1538
+ children: [
1539
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Divider, {}, undefined, false, undefined, this),
1540
+ renderBuiltInAgentsSection()
1541
+ ]
1542
+ }, undefined, true, undefined, this)
1543
+ ]
1544
+ }, undefined, true, undefined, this)
1545
+ }, undefined, false, undefined, this);
1546
+ }
1547
+ return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Dialog, {
1548
+ title: sourceTitle,
1549
+ subtitle: `${count(sortedAgents, (a) => !a.overriddenBy)} agents`,
1550
+ onCancel: onBack,
1551
+ hideInputGuide: true,
1552
+ children: [
1553
+ changes && changes.length > 0 && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1554
+ marginTop: 1,
1555
+ children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1556
+ dimColor: true,
1557
+ children: changes[changes.length - 1]
1558
+ }, undefined, false, undefined, this)
1559
+ }, undefined, false, undefined, this),
1560
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1561
+ flexDirection: "column",
1562
+ tabIndex: 0,
1563
+ autoFocus: true,
1564
+ onKeyDown: handleKeyDown,
1565
+ children: [
1566
+ onCreateNew && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1567
+ marginBottom: 1,
1568
+ children: renderCreateNewOption()
1569
+ }, undefined, false, undefined, this),
1570
+ source === "all" ? /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(jsx_dev_runtime7.Fragment, {
1571
+ children: [
1572
+ AGENT_SOURCE_GROUPS.filter((g) => g.source !== "built-in").map(({ label, source: groupSource }) => /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(React4.Fragment, {
1573
+ children: renderAgentGroup(label, sortedAgents.filter((a) => a.source === groupSource))
1574
+ }, groupSource, false, undefined, this)),
1575
+ builtInAgents.length > 0 && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1576
+ flexDirection: "column",
1577
+ marginBottom: 1,
1578
+ paddingLeft: 2,
1579
+ children: [
1580
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1581
+ dimColor: true,
1582
+ children: [
1583
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1584
+ bold: true,
1585
+ children: "Built-in agents"
1586
+ }, undefined, false, undefined, this),
1587
+ " (always available)"
1588
+ ]
1589
+ }, undefined, true, undefined, this),
1590
+ builtInAgents.map(renderAgent)
1591
+ ]
1592
+ }, undefined, true, undefined, this)
1593
+ ]
1594
+ }, undefined, true, undefined, this) : source === "built-in" ? /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(jsx_dev_runtime7.Fragment, {
1595
+ children: [
1596
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
1597
+ dimColor: true,
1598
+ italic: true,
1599
+ children: "Built-in agents are provided by default and cannot be modified."
1600
+ }, undefined, false, undefined, this),
1601
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
1602
+ marginTop: 1,
1603
+ flexDirection: "column",
1604
+ children: sortedAgents.map((agent) => renderAgent(agent))
1605
+ }, undefined, false, undefined, this)
1606
+ ]
1607
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(jsx_dev_runtime7.Fragment, {
1608
+ children: [
1609
+ sortedAgents.filter((a) => a.source !== "built-in").map((agent) => renderAgent(agent)),
1610
+ sortedAgents.some((a) => a.source === "built-in") && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(jsx_dev_runtime7.Fragment, {
1611
+ children: [
1612
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Divider, {}, undefined, false, undefined, this),
1613
+ renderBuiltInAgentsSection()
1614
+ ]
1615
+ }, undefined, true, undefined, this)
1616
+ ]
1617
+ }, undefined, true, undefined, this)
1618
+ ]
1619
+ }, undefined, true, undefined, this)
1620
+ ]
1621
+ }, undefined, true, undefined, this);
1622
+ }
1623
+ var React4, jsx_dev_runtime7;
1624
+ var init_AgentsList = __esm(() => {
1625
+ init_figures();
1626
+ init_src();
1627
+ init_agentDisplay();
1628
+ init_array();
1629
+ init_src();
1630
+ init_utils2();
1631
+ React4 = __toESM(require_react(), 1);
1632
+ jsx_dev_runtime7 = __toESM(require_jsx_dev_runtime(), 1);
1633
+ });
1634
+
1635
+ // src/components/wizard/WizardProvider.tsx
1636
+ function WizardProvider({
1637
+ steps,
1638
+ initialData = {},
1639
+ onComplete,
1640
+ onCancel,
1641
+ children,
1642
+ title,
1643
+ showStepCounter = true
1644
+ }) {
1645
+ const [currentStepIndex, setCurrentStepIndex] = import_react4.useState(0);
1646
+ const [wizardData, setWizardData] = import_react4.useState(initialData);
1647
+ const [isCompleted, setIsCompleted] = import_react4.useState(false);
1648
+ const [navigationHistory, setNavigationHistory] = import_react4.useState([]);
1649
+ useExitOnCtrlCDWithKeybindings();
1650
+ import_react4.useEffect(() => {
1651
+ if (isCompleted) {
1652
+ setNavigationHistory([]);
1653
+ onComplete(wizardData);
1654
+ }
1655
+ }, [isCompleted, wizardData, onComplete]);
1656
+ const goNext = import_react4.useCallback(() => {
1657
+ if (currentStepIndex < steps.length - 1) {
1658
+ if (navigationHistory.length > 0) {
1659
+ setNavigationHistory((prev) => [...prev, currentStepIndex]);
1660
+ }
1661
+ setCurrentStepIndex((prev) => prev + 1);
1662
+ } else {
1663
+ setIsCompleted(true);
1664
+ }
1665
+ }, [currentStepIndex, steps.length, navigationHistory]);
1666
+ const goBack = import_react4.useCallback(() => {
1667
+ if (navigationHistory.length > 0) {
1668
+ const previousStep = navigationHistory[navigationHistory.length - 1];
1669
+ if (previousStep !== undefined) {
1670
+ setNavigationHistory((prev) => prev.slice(0, -1));
1671
+ setCurrentStepIndex(previousStep);
1672
+ }
1673
+ } else if (currentStepIndex > 0) {
1674
+ setCurrentStepIndex((prev) => prev - 1);
1675
+ } else if (onCancel) {
1676
+ onCancel();
1677
+ }
1678
+ }, [currentStepIndex, navigationHistory, onCancel]);
1679
+ const goToStep = import_react4.useCallback((index) => {
1680
+ if (index >= 0 && index < steps.length) {
1681
+ setNavigationHistory((prev) => [...prev, currentStepIndex]);
1682
+ setCurrentStepIndex(index);
1683
+ }
1684
+ }, [currentStepIndex, steps.length]);
1685
+ const cancel = import_react4.useCallback(() => {
1686
+ setNavigationHistory([]);
1687
+ if (onCancel) {
1688
+ onCancel();
1689
+ }
1690
+ }, [onCancel]);
1691
+ const updateWizardData = import_react4.useCallback((updates) => {
1692
+ setWizardData((prev) => ({ ...prev, ...updates }));
1693
+ }, []);
1694
+ const contextValue = import_react4.useMemo(() => ({
1695
+ currentStepIndex,
1696
+ totalSteps: steps.length,
1697
+ wizardData,
1698
+ setWizardData,
1699
+ updateWizardData,
1700
+ goNext,
1701
+ goBack,
1702
+ goToStep,
1703
+ cancel,
1704
+ title,
1705
+ showStepCounter
1706
+ }), [
1707
+ currentStepIndex,
1708
+ steps.length,
1709
+ wizardData,
1710
+ updateWizardData,
1711
+ goNext,
1712
+ goBack,
1713
+ goToStep,
1714
+ cancel,
1715
+ title,
1716
+ showStepCounter
1717
+ ]);
1718
+ const CurrentStepComponent = steps[currentStepIndex];
1719
+ if (!CurrentStepComponent || isCompleted) {
1720
+ return null;
1721
+ }
1722
+ return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(WizardContext.Provider, {
1723
+ value: contextValue,
1724
+ children: children || /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(CurrentStepComponent, {}, undefined, false, undefined, this)
1725
+ }, undefined, false, undefined, this);
1726
+ }
1727
+ var import_react4, jsx_dev_runtime8, WizardContext;
1728
+ var init_WizardProvider = __esm(() => {
1729
+ init_useExitOnCtrlCDWithKeybindings();
1730
+ import_react4 = __toESM(require_react(), 1);
1731
+ jsx_dev_runtime8 = __toESM(require_jsx_dev_runtime(), 1);
1732
+ WizardContext = import_react4.createContext(null);
1733
+ });
1734
+
1735
+ // src/components/wizard/useWizard.ts
1736
+ function useWizard() {
1737
+ const context = import_react5.useContext(WizardContext);
1738
+ if (!context) {
1739
+ throw new Error("useWizard must be used within a WizardProvider");
1740
+ }
1741
+ return context;
1742
+ }
1743
+ var import_react5;
1744
+ var init_useWizard = __esm(() => {
1745
+ init_WizardProvider();
1746
+ import_react5 = __toESM(require_react(), 1);
1747
+ });
1748
+
1749
+ // src/components/wizard/WizardNavigationFooter.tsx
1750
+ function WizardNavigationFooter({
1751
+ instructions = /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Byline, {
1752
+ children: [
1753
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(KeyboardShortcutHint, {
1754
+ shortcut: "\u2191\u2193",
1755
+ action: "navigate"
1756
+ }, undefined, false, undefined, this),
1757
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(KeyboardShortcutHint, {
1758
+ shortcut: "Enter",
1759
+ action: "select"
1760
+ }, undefined, false, undefined, this),
1761
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ConfigurableShortcutHint, {
1762
+ action: "confirm:no",
1763
+ context: "Confirmation",
1764
+ fallback: "Esc",
1765
+ description: "go back"
1766
+ }, undefined, false, undefined, this)
1767
+ ]
1768
+ }, undefined, true, undefined, this)
1769
+ }) {
1770
+ const exitState = useExitOnCtrlCDWithKeybindings();
1771
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1772
+ marginLeft: 3,
1773
+ marginTop: 1,
1774
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1775
+ dimColor: true,
1776
+ children: exitState.pending ? `Press ${exitState.keyName} again to exit` : instructions
1777
+ }, undefined, false, undefined, this)
1778
+ }, undefined, false, undefined, this);
1779
+ }
1780
+ var jsx_dev_runtime9;
1781
+ var init_WizardNavigationFooter = __esm(() => {
1782
+ init_useExitOnCtrlCDWithKeybindings();
1783
+ init_src();
1784
+ init_ConfigurableShortcutHint();
1785
+ init_src();
1786
+ jsx_dev_runtime9 = __toESM(require_jsx_dev_runtime(), 1);
1787
+ });
1788
+
1789
+ // src/components/wizard/WizardDialogLayout.tsx
1790
+ function WizardDialogLayout({
1791
+ title: titleOverride,
1792
+ color = "suggestion",
1793
+ children,
1794
+ subtitle,
1795
+ footerText
1796
+ }) {
1797
+ const {
1798
+ currentStepIndex,
1799
+ totalSteps,
1800
+ title: providerTitle,
1801
+ showStepCounter,
1802
+ goBack
1803
+ } = useWizard();
1804
+ const title = titleOverride || providerTitle || "Wizard";
1805
+ const stepSuffix = showStepCounter !== false ? ` (${currentStepIndex + 1}/${totalSteps})` : "";
1806
+ return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(jsx_dev_runtime10.Fragment, {
1807
+ children: [
1808
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Dialog, {
1809
+ title: `${title}${stepSuffix}`,
1810
+ subtitle,
1811
+ onCancel: goBack,
1812
+ color,
1813
+ hideInputGuide: true,
1814
+ isCancelActive: false,
1815
+ children
1816
+ }, undefined, false, undefined, this),
1817
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(WizardNavigationFooter, {
1818
+ instructions: footerText
1819
+ }, undefined, false, undefined, this)
1820
+ ]
1821
+ }, undefined, true, undefined, this);
1822
+ }
1823
+ var jsx_dev_runtime10;
1824
+ var init_WizardDialogLayout = __esm(() => {
1825
+ init_src();
1826
+ init_useWizard();
1827
+ init_WizardNavigationFooter();
1828
+ jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
1829
+ });
1830
+
1831
+ // src/components/wizard/index.ts
1832
+ var init_wizard = __esm(() => {
1833
+ init_useWizard();
1834
+ init_WizardDialogLayout();
1835
+ init_WizardNavigationFooter();
1836
+ init_WizardProvider();
1837
+ });
1838
+
1839
+ // src/components/agents/new-agent-creation/wizard-steps/ColorStep.tsx
1840
+ function ColorStep() {
1841
+ const { goNext, goBack, updateWizardData, wizardData } = useWizard();
1842
+ useKeybinding("confirm:no", goBack, { context: "Confirmation" });
1843
+ const handleConfirm = (color) => {
1844
+ updateWizardData({
1845
+ selectedColor: color,
1846
+ finalAgent: {
1847
+ agentType: wizardData.agentType,
1848
+ whenToUse: wizardData.whenToUse,
1849
+ getSystemPrompt: () => wizardData.systemPrompt,
1850
+ tools: wizardData.selectedTools,
1851
+ ...wizardData.selectedModel ? { model: wizardData.selectedModel } : {},
1852
+ ...color ? { color } : {},
1853
+ source: wizardData.location
1854
+ }
1855
+ });
1856
+ goNext();
1857
+ };
1858
+ return /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(WizardDialogLayout, {
1859
+ subtitle: "Choose background color",
1860
+ footerText: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Byline, {
1861
+ children: [
1862
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(KeyboardShortcutHint, {
1863
+ shortcut: "\u2191\u2193",
1864
+ action: "navigate"
1865
+ }, undefined, false, undefined, this),
1866
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(KeyboardShortcutHint, {
1867
+ shortcut: "Enter",
1868
+ action: "select"
1869
+ }, undefined, false, undefined, this),
1870
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ConfigurableShortcutHint, {
1871
+ action: "confirm:no",
1872
+ context: "Confirmation",
1873
+ fallback: "Esc",
1874
+ description: "go back"
1875
+ }, undefined, false, undefined, this)
1876
+ ]
1877
+ }, undefined, true, undefined, this),
1878
+ children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedBox_default, {
1879
+ children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ColorPicker, {
1880
+ agentName: wizardData.agentType || "agent",
1881
+ currentColor: "automatic",
1882
+ onConfirm: handleConfirm
1883
+ }, undefined, false, undefined, this)
1884
+ }, undefined, false, undefined, this)
1885
+ }, undefined, false, undefined, this);
1886
+ }
1887
+ var jsx_dev_runtime11;
1888
+ var init_ColorStep = __esm(() => {
1889
+ init_src();
1890
+ init_useKeybinding();
1891
+ init_ConfigurableShortcutHint();
1892
+ init_wizard();
1893
+ init_WizardDialogLayout();
1894
+ init_ColorPicker();
1895
+ jsx_dev_runtime11 = __toESM(require_jsx_dev_runtime(), 1);
1896
+ });
1897
+
1898
+ // src/components/agents/validateAgent.ts
1899
+ function validateAgentType(agentType) {
1900
+ if (!agentType) {
1901
+ return "Agent type is required";
1902
+ }
1903
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$/.test(agentType)) {
1904
+ return "Agent type must start and end with alphanumeric characters and contain only letters, numbers, and hyphens";
1905
+ }
1906
+ if (agentType.length < 3) {
1907
+ return "Agent type must be at least 3 characters long";
1908
+ }
1909
+ if (agentType.length > 50) {
1910
+ return "Agent type must be less than 50 characters";
1911
+ }
1912
+ return null;
1913
+ }
1914
+ function validateAgent(agent, availableTools, existingAgents) {
1915
+ const errors = [];
1916
+ const warnings = [];
1917
+ if (!agent.agentType) {
1918
+ errors.push("Agent type is required");
1919
+ } else {
1920
+ const typeError = validateAgentType(agent.agentType);
1921
+ if (typeError) {
1922
+ errors.push(typeError);
1923
+ }
1924
+ const duplicate = existingAgents.find((a) => a.agentType === agent.agentType && a.source !== agent.source);
1925
+ if (duplicate) {
1926
+ errors.push(`Agent type "${agent.agentType}" already exists in ${getAgentSourceDisplayName(duplicate.source)}`);
1927
+ }
1928
+ }
1929
+ if (!agent.whenToUse) {
1930
+ errors.push("Description (description) is required");
1931
+ } else if (agent.whenToUse.length < 10) {
1932
+ warnings.push("Description should be more descriptive (at least 10 characters)");
1933
+ } else if (agent.whenToUse.length > 5000) {
1934
+ warnings.push("Description is very long (over 5000 characters)");
1935
+ }
1936
+ if (agent.tools !== undefined && !Array.isArray(agent.tools)) {
1937
+ errors.push("Tools must be an array");
1938
+ } else {
1939
+ if (agent.tools === undefined) {
1940
+ warnings.push("Agent has access to all tools");
1941
+ } else if (agent.tools.length === 0) {
1942
+ warnings.push("No tools selected - agent will have very limited capabilities");
1943
+ }
1944
+ const resolvedTools = resolveAgentTools(agent, availableTools, false);
1945
+ if (resolvedTools.invalidTools.length > 0) {
1946
+ errors.push(`Invalid tools: ${resolvedTools.invalidTools.join(", ")}`);
1947
+ }
1948
+ }
1949
+ const systemPrompt = agent.getSystemPrompt();
1950
+ if (!systemPrompt) {
1951
+ errors.push("System prompt is required");
1952
+ } else if (systemPrompt.length < 20) {
1953
+ errors.push("System prompt is too short (minimum 20 characters)");
1954
+ } else if (systemPrompt.length > 1e4) {
1955
+ warnings.push("System prompt is very long (over 10,000 characters)");
1956
+ }
1957
+ return {
1958
+ isValid: errors.length === 0,
1959
+ errors,
1960
+ warnings
1961
+ };
1962
+ }
1963
+ var init_validateAgent = __esm(() => {
1964
+ init_agentToolUtils();
1965
+ init_utils2();
1966
+ });
1967
+
1968
+ // src/components/agents/new-agent-creation/wizard-steps/ConfirmStep.tsx
1969
+ function ConfirmStep({
1970
+ tools,
1971
+ existingAgents,
1972
+ onSave,
1973
+ onSaveAndEdit,
1974
+ error
1975
+ }) {
1976
+ const { goBack, wizardData } = useWizard();
1977
+ useKeybinding("confirm:no", goBack, { context: "Confirmation" });
1978
+ const handleKeyDown = (e) => {
1979
+ if (e.key === "s" || e.key === "return") {
1980
+ e.preventDefault();
1981
+ onSave();
1982
+ } else if (e.key === "e") {
1983
+ e.preventDefault();
1984
+ onSaveAndEdit();
1985
+ }
1986
+ };
1987
+ const agent = wizardData.finalAgent;
1988
+ const validation = validateAgent(agent, tools, existingAgents);
1989
+ const systemPromptPreview = truncateToWidth(agent.getSystemPrompt(), 240);
1990
+ const whenToUsePreview = truncateToWidth(agent.whenToUse, 240);
1991
+ const getToolsDisplay = (toolNames) => {
1992
+ if (toolNames === undefined)
1993
+ return "All tools";
1994
+ if (toolNames.length === 0)
1995
+ return "None";
1996
+ if (toolNames.length === 1)
1997
+ return toolNames[0] || "None";
1998
+ if (toolNames.length === 2)
1999
+ return toolNames.join(" and ");
2000
+ return `${toolNames.slice(0, -1).join(", ")}, and ${toolNames[toolNames.length - 1]}`;
2001
+ };
2002
+ const memoryDisplayElement = isAutoMemoryEnabled() ? /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2003
+ children: [
2004
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2005
+ bold: true,
2006
+ children: "Memory"
2007
+ }, undefined, false, undefined, this),
2008
+ ": ",
2009
+ getMemoryScopeDisplay(agent.memory)
2010
+ ]
2011
+ }, undefined, true, undefined, this) : null;
2012
+ return /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(WizardDialogLayout, {
2013
+ subtitle: "Confirm and save",
2014
+ footerText: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(Byline, {
2015
+ children: [
2016
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(KeyboardShortcutHint, {
2017
+ shortcut: "s/Enter",
2018
+ action: "save"
2019
+ }, undefined, false, undefined, this),
2020
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(KeyboardShortcutHint, {
2021
+ shortcut: "e",
2022
+ action: "edit in your editor"
2023
+ }, undefined, false, undefined, this),
2024
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ConfigurableShortcutHint, {
2025
+ action: "confirm:no",
2026
+ context: "Confirmation",
2027
+ fallback: "Esc",
2028
+ description: "cancel"
2029
+ }, undefined, false, undefined, this)
2030
+ ]
2031
+ }, undefined, true, undefined, this),
2032
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
2033
+ flexDirection: "column",
2034
+ tabIndex: 0,
2035
+ autoFocus: true,
2036
+ onKeyDown: handleKeyDown,
2037
+ children: [
2038
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2039
+ children: [
2040
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2041
+ bold: true,
2042
+ children: "Name"
2043
+ }, undefined, false, undefined, this),
2044
+ ": ",
2045
+ agent.agentType
2046
+ ]
2047
+ }, undefined, true, undefined, this),
2048
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2049
+ children: [
2050
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2051
+ bold: true,
2052
+ children: "Location"
2053
+ }, undefined, false, undefined, this),
2054
+ ":",
2055
+ " ",
2056
+ getNewRelativeAgentFilePath({
2057
+ source: wizardData.location,
2058
+ agentType: agent.agentType
2059
+ })
2060
+ ]
2061
+ }, undefined, true, undefined, this),
2062
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2063
+ children: [
2064
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2065
+ bold: true,
2066
+ children: "Tools"
2067
+ }, undefined, false, undefined, this),
2068
+ ": ",
2069
+ getToolsDisplay(agent.tools)
2070
+ ]
2071
+ }, undefined, true, undefined, this),
2072
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2073
+ children: [
2074
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2075
+ bold: true,
2076
+ children: "Model"
2077
+ }, undefined, false, undefined, this),
2078
+ ": ",
2079
+ getAgentModelDisplay(agent.model)
2080
+ ]
2081
+ }, undefined, true, undefined, this),
2082
+ memoryDisplayElement,
2083
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
2084
+ marginTop: 1,
2085
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2086
+ children: [
2087
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2088
+ bold: true,
2089
+ children: "Description"
2090
+ }, undefined, false, undefined, this),
2091
+ " (tells Claude when to use this agent):"
2092
+ ]
2093
+ }, undefined, true, undefined, this)
2094
+ }, undefined, false, undefined, this),
2095
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
2096
+ marginLeft: 2,
2097
+ marginTop: 1,
2098
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2099
+ children: whenToUsePreview
2100
+ }, undefined, false, undefined, this)
2101
+ }, undefined, false, undefined, this),
2102
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
2103
+ marginTop: 1,
2104
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2105
+ children: [
2106
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2107
+ bold: true,
2108
+ children: "System prompt"
2109
+ }, undefined, false, undefined, this),
2110
+ ":"
2111
+ ]
2112
+ }, undefined, true, undefined, this)
2113
+ }, undefined, false, undefined, this),
2114
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
2115
+ marginLeft: 2,
2116
+ marginTop: 1,
2117
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2118
+ children: systemPromptPreview
2119
+ }, undefined, false, undefined, this)
2120
+ }, undefined, false, undefined, this),
2121
+ validation.warnings.length > 0 && /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
2122
+ marginTop: 1,
2123
+ flexDirection: "column",
2124
+ children: [
2125
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2126
+ color: "warning",
2127
+ children: "Warnings:"
2128
+ }, undefined, false, undefined, this),
2129
+ validation.warnings.map((warning, i) => /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2130
+ dimColor: true,
2131
+ children: [
2132
+ " ",
2133
+ "\u2022 ",
2134
+ warning
2135
+ ]
2136
+ }, i, true, undefined, this))
2137
+ ]
2138
+ }, undefined, true, undefined, this),
2139
+ validation.errors.length > 0 && /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
2140
+ marginTop: 1,
2141
+ flexDirection: "column",
2142
+ children: [
2143
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2144
+ color: "error",
2145
+ children: "Errors:"
2146
+ }, undefined, false, undefined, this),
2147
+ validation.errors.map((err, i) => /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2148
+ color: "error",
2149
+ children: [
2150
+ " ",
2151
+ "\u2022 ",
2152
+ err
2153
+ ]
2154
+ }, i, true, undefined, this))
2155
+ ]
2156
+ }, undefined, true, undefined, this),
2157
+ error && /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
2158
+ marginTop: 1,
2159
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2160
+ color: "error",
2161
+ children: error
2162
+ }, undefined, false, undefined, this)
2163
+ }, undefined, false, undefined, this),
2164
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
2165
+ marginTop: 2,
2166
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2167
+ color: "success",
2168
+ children: [
2169
+ "Press ",
2170
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2171
+ bold: true,
2172
+ children: "s"
2173
+ }, undefined, false, undefined, this),
2174
+ " or ",
2175
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2176
+ bold: true,
2177
+ children: "Enter"
2178
+ }, undefined, false, undefined, this),
2179
+ " to save,",
2180
+ " ",
2181
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
2182
+ bold: true,
2183
+ children: "e"
2184
+ }, undefined, false, undefined, this),
2185
+ " to save and edit"
2186
+ ]
2187
+ }, undefined, true, undefined, this)
2188
+ }, undefined, false, undefined, this)
2189
+ ]
2190
+ }, undefined, true, undefined, this)
2191
+ }, undefined, false, undefined, this);
2192
+ }
2193
+ var jsx_dev_runtime12;
2194
+ var init_ConfirmStep = __esm(() => {
2195
+ init_src();
2196
+ init_useKeybinding();
2197
+ init_paths();
2198
+ init_agentMemory();
2199
+ init_format();
2200
+ init_agent();
2201
+ init_ConfigurableShortcutHint();
2202
+ init_wizard();
2203
+ init_WizardDialogLayout();
2204
+ init_agentFileUtils();
2205
+ init_validateAgent();
2206
+ jsx_dev_runtime12 = __toESM(require_jsx_dev_runtime(), 1);
2207
+ });
2208
+
2209
+ // src/components/agents/new-agent-creation/wizard-steps/ConfirmStepWrapper.tsx
2210
+ function ConfirmStepWrapper({
2211
+ tools,
2212
+ existingAgents,
2213
+ onComplete
2214
+ }) {
2215
+ const { wizardData } = useWizard();
2216
+ const [saveError, setSaveError] = import_react6.useState(null);
2217
+ const setAppState = useSetAppState();
2218
+ const saveAgent = import_react6.useCallback(async (openInEditor) => {
2219
+ if (!wizardData?.finalAgent)
2220
+ return;
2221
+ try {
2222
+ await saveAgentToFile(wizardData.location, wizardData.finalAgent.agentType, wizardData.finalAgent.whenToUse, wizardData.finalAgent.tools, wizardData.finalAgent.getSystemPrompt(), true, wizardData.finalAgent.color, wizardData.finalAgent.model, wizardData.finalAgent.memory);
2223
+ setAppState((state) => {
2224
+ if (!wizardData.finalAgent)
2225
+ return state;
2226
+ const allAgents = state.agentDefinitions.allAgents.concat(wizardData.finalAgent);
2227
+ return {
2228
+ ...state,
2229
+ agentDefinitions: {
2230
+ ...state.agentDefinitions,
2231
+ activeAgents: getActiveAgentsFromList(allAgents),
2232
+ allAgents
2233
+ }
2234
+ };
2235
+ });
2236
+ if (openInEditor) {
2237
+ const filePath = getNewAgentFilePath({
2238
+ source: wizardData.location,
2239
+ agentType: wizardData.finalAgent.agentType
2240
+ });
2241
+ await editFileInEditor(filePath);
2242
+ }
2243
+ logEvent("tengu_agent_created", {
2244
+ agent_type: wizardData.finalAgent.agentType,
2245
+ generation_method: wizardData.wasGenerated ? "generated" : "manual",
2246
+ source: wizardData.location,
2247
+ tool_count: wizardData.finalAgent.tools?.length ?? "all",
2248
+ has_custom_model: !!wizardData.finalAgent.model,
2249
+ has_custom_color: !!wizardData.finalAgent.color,
2250
+ has_memory: !!wizardData.finalAgent.memory,
2251
+ memory_scope: wizardData.finalAgent.memory ?? "none",
2252
+ ...openInEditor ? { opened_in_editor: true } : {}
2253
+ });
2254
+ const message = openInEditor ? `Created agent: ${source_default.bold(wizardData.finalAgent.agentType)} and opened in editor. ` + `If you made edits, restart to load the latest version.` : `Created agent: ${source_default.bold(wizardData.finalAgent.agentType)}`;
2255
+ onComplete(message);
2256
+ } catch (err) {
2257
+ setSaveError(err instanceof Error ? err.message : "Failed to save agent");
2258
+ }
2259
+ }, [wizardData, onComplete, setAppState]);
2260
+ const handleSave = import_react6.useCallback(() => saveAgent(false), [saveAgent]);
2261
+ const handleSaveAndEdit = import_react6.useCallback(() => saveAgent(true), [saveAgent]);
2262
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(ConfirmStep, {
2263
+ tools,
2264
+ existingAgents,
2265
+ onSave: handleSave,
2266
+ onSaveAndEdit: handleSaveAndEdit,
2267
+ error: saveError
2268
+ }, undefined, false, undefined, this);
2269
+ }
2270
+ var import_react6, jsx_dev_runtime13;
2271
+ var init_ConfirmStepWrapper = __esm(() => {
2272
+ init_source();
2273
+ init_analytics();
2274
+ init_AppState();
2275
+ init_loadAgentsDir();
2276
+ init_promptEditor();
2277
+ init_wizard();
2278
+ init_agentFileUtils();
2279
+ init_ConfirmStep();
2280
+ import_react6 = __toESM(require_react(), 1);
2281
+ jsx_dev_runtime13 = __toESM(require_jsx_dev_runtime(), 1);
2282
+ });
2283
+
2284
+ // src/components/agents/new-agent-creation/wizard-steps/DescriptionStep.tsx
2285
+ function DescriptionStep() {
2286
+ const { goNext, goBack, updateWizardData, wizardData } = useWizard();
2287
+ const [whenToUse, setWhenToUse] = import_react7.useState(wizardData.whenToUse || "");
2288
+ const [cursorOffset, setCursorOffset] = import_react7.useState(whenToUse.length);
2289
+ const [error, setError] = import_react7.useState(null);
2290
+ useKeybinding("confirm:no", goBack, { context: "Settings" });
2291
+ const handleExternalEditor = import_react7.useCallback(async () => {
2292
+ const result = await editPromptInEditor(whenToUse);
2293
+ if (result.content !== null) {
2294
+ setWhenToUse(result.content);
2295
+ setCursorOffset(result.content.length);
2296
+ }
2297
+ }, [whenToUse]);
2298
+ useKeybinding("chat:externalEditor", handleExternalEditor, {
2299
+ context: "Chat"
2300
+ });
2301
+ const handleSubmit = (value) => {
2302
+ const trimmedValue = value.trim();
2303
+ if (!trimmedValue) {
2304
+ setError("Description is required");
2305
+ return;
2306
+ }
2307
+ setError(null);
2308
+ updateWizardData({ whenToUse: trimmedValue });
2309
+ goNext();
2310
+ };
2311
+ return /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(WizardDialogLayout, {
2312
+ subtitle: "Description (tell Claude when to use this agent)",
2313
+ footerText: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Byline, {
2314
+ children: [
2315
+ /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(KeyboardShortcutHint, {
2316
+ shortcut: "Type",
2317
+ action: "enter text"
2318
+ }, undefined, false, undefined, this),
2319
+ /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(KeyboardShortcutHint, {
2320
+ shortcut: "Enter",
2321
+ action: "continue"
2322
+ }, undefined, false, undefined, this),
2323
+ /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(ConfigurableShortcutHint, {
2324
+ action: "chat:externalEditor",
2325
+ context: "Chat",
2326
+ fallback: "ctrl+g",
2327
+ description: "open in editor"
2328
+ }, undefined, false, undefined, this),
2329
+ /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(ConfigurableShortcutHint, {
2330
+ action: "confirm:no",
2331
+ context: "Settings",
2332
+ fallback: "Esc",
2333
+ description: "go back"
2334
+ }, undefined, false, undefined, this)
2335
+ ]
2336
+ }, undefined, true, undefined, this),
2337
+ children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(ThemedBox_default, {
2338
+ flexDirection: "column",
2339
+ children: [
2340
+ /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(ThemedText, {
2341
+ children: "When should Claude use this agent?"
2342
+ }, undefined, false, undefined, this),
2343
+ /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(ThemedBox_default, {
2344
+ marginTop: 1,
2345
+ children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(TextInput, {
2346
+ value: whenToUse,
2347
+ onChange: setWhenToUse,
2348
+ onSubmit: handleSubmit,
2349
+ placeholder: "e.g., use this agent after you're done writing code...",
2350
+ columns: 80,
2351
+ cursorOffset,
2352
+ onChangeCursorOffset: setCursorOffset,
2353
+ focus: true,
2354
+ showCursor: true
2355
+ }, undefined, false, undefined, this)
2356
+ }, undefined, false, undefined, this),
2357
+ error && /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(ThemedBox_default, {
2358
+ marginTop: 1,
2359
+ children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(ThemedText, {
2360
+ color: "error",
2361
+ children: error
2362
+ }, undefined, false, undefined, this)
2363
+ }, undefined, false, undefined, this)
2364
+ ]
2365
+ }, undefined, true, undefined, this)
2366
+ }, undefined, false, undefined, this);
2367
+ }
2368
+ var import_react7, jsx_dev_runtime14;
2369
+ var init_DescriptionStep = __esm(() => {
2370
+ init_src();
2371
+ init_useKeybinding();
2372
+ init_promptEditor();
2373
+ init_ConfigurableShortcutHint();
2374
+ init_TextInput();
2375
+ init_wizard();
2376
+ init_WizardDialogLayout();
2377
+ import_react7 = __toESM(require_react(), 1);
2378
+ jsx_dev_runtime14 = __toESM(require_jsx_dev_runtime(), 1);
2379
+ });
2380
+
2381
+ // src/components/agents/generateAgent.ts
2382
+ async function generateAgent(userPrompt, model, existingIdentifiers, abortSignal) {
2383
+ const existingList = existingIdentifiers.length > 0 ? `
2384
+
2385
+ IMPORTANT: The following identifiers already exist and must NOT be used: ${existingIdentifiers.join(", ")}` : "";
2386
+ const prompt = `Create an agent configuration based on this request: "${userPrompt}".${existingList}
2387
+ Return ONLY the JSON object, no other text.`;
2388
+ const userMessage = createUserMessage({ content: prompt });
2389
+ const userContext = await getUserContext();
2390
+ const messagesWithContext = prependUserContext([userMessage], userContext);
2391
+ const systemPrompt = isAutoMemoryEnabled() ? AGENT_CREATION_SYSTEM_PROMPT + AGENT_MEMORY_INSTRUCTIONS : AGENT_CREATION_SYSTEM_PROMPT;
2392
+ const response = await queryModelWithoutStreaming({
2393
+ messages: normalizeMessagesForAPI(messagesWithContext),
2394
+ systemPrompt: asSystemPrompt([systemPrompt]),
2395
+ thinkingConfig: { type: "disabled" },
2396
+ tools: [],
2397
+ signal: abortSignal,
2398
+ options: {
2399
+ getToolPermissionContext: async () => getEmptyToolPermissionContext(),
2400
+ model,
2401
+ toolChoice: undefined,
2402
+ agents: [],
2403
+ isNonInteractiveSession: false,
2404
+ hasAppendSystemPrompt: false,
2405
+ querySource: "agent_creation",
2406
+ mcpTools: []
2407
+ }
2408
+ });
2409
+ const textBlocks = (Array.isArray(response.message.content) ? response.message.content : []).filter((block) => block.type === "text");
2410
+ const responseText = textBlocks.map((block) => block.text).join(`
2411
+ `);
2412
+ let parsed;
2413
+ try {
2414
+ parsed = jsonParse(responseText.trim());
2415
+ } catch {
2416
+ const jsonMatch = responseText.match(/\{[\s\S]*\}/);
2417
+ if (!jsonMatch) {
2418
+ throw new Error("No JSON object found in response");
2419
+ }
2420
+ parsed = jsonParse(jsonMatch[0]);
2421
+ }
2422
+ if (!parsed.identifier || !parsed.whenToUse || !parsed.systemPrompt) {
2423
+ throw new Error("Invalid agent configuration generated");
2424
+ }
2425
+ logEvent("tengu_agent_definition_generated", {
2426
+ agent_identifier: parsed.identifier
2427
+ });
2428
+ return {
2429
+ identifier: parsed.identifier,
2430
+ whenToUse: parsed.whenToUse,
2431
+ systemPrompt: parsed.systemPrompt
2432
+ };
2433
+ }
2434
+ var AGENT_CREATION_SYSTEM_PROMPT, AGENT_MEMORY_INSTRUCTIONS = `
2435
+
2436
+ 7. **Agent Memory Instructions**: If the user mentions "memory", "remember", "learn", "persist", or similar concepts, OR if the agent would benefit from building up knowledge across conversations (e.g., code reviewers learning patterns, architects learning codebase structure, etc.), include domain-specific memory update instructions in the systemPrompt.
2437
+
2438
+ Add a section like this to the systemPrompt, tailored to the agent's specific domain:
2439
+
2440
+ "**Update your agent memory** as you discover [domain-specific items]. This builds up institutional knowledge across conversations. Write concise notes about what you found and where.
2441
+
2442
+ Examples of what to record:
2443
+ - [domain-specific item 1]
2444
+ - [domain-specific item 2]
2445
+ - [domain-specific item 3]"
2446
+
2447
+ Examples of domain-specific memory instructions:
2448
+ - For a code-reviewer: "Update your agent memory as you discover code patterns, style conventions, common issues, and architectural decisions in this codebase."
2449
+ - For a test-runner: "Update your agent memory as you discover test patterns, common failure modes, flaky tests, and testing best practices."
2450
+ - For an architect: "Update your agent memory as you discover codepaths, library locations, key architectural decisions, and component relationships."
2451
+ - For a documentation writer: "Update your agent memory as you discover documentation patterns, API structures, and terminology conventions."
2452
+
2453
+ The memory instructions should be specific to what the agent would naturally learn while performing its core tasks.
2454
+ `;
2455
+ var init_generateAgent = __esm(() => {
2456
+ init_context();
2457
+ init_claude();
2458
+ init_Tool();
2459
+ init_constants2();
2460
+ init_api();
2461
+ init_messages();
2462
+ init_paths();
2463
+ init_analytics();
2464
+ init_slowOperations();
2465
+ init_systemPromptType();
2466
+ AGENT_CREATION_SYSTEM_PROMPT = `You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.
2467
+
2468
+ **Important Context**: You may have access to project-specific instructions from CLAUDE.md files and other context that may include coding standards, project structure, and custom requirements. Consider this context when creating agents to ensure they align with the project's established patterns and practices.
2469
+
2470
+ When a user describes what they want an agent to do, you will:
2471
+
2472
+ 1. **Extract Core Intent**: Identify the fundamental purpose, key responsibilities, and success criteria for the agent. Look for both explicit requirements and implicit needs. Consider any project-specific context from CLAUDE.md files. For agents that are meant to review code, you should assume that the user is asking to review recently written code and not the whole codebase, unless the user has explicitly instructed you otherwise.
2473
+
2474
+ 2. **Design Expert Persona**: Create a compelling expert identity that embodies deep domain knowledge relevant to the task. The persona should inspire confidence and guide the agent's decision-making approach.
2475
+
2476
+ 3. **Architect Comprehensive Instructions**: Develop a system prompt that:
2477
+ - Establishes clear behavioral boundaries and operational parameters
2478
+ - Provides specific methodologies and best practices for task execution
2479
+ - Anticipates edge cases and provides guidance for handling them
2480
+ - Incorporates any specific requirements or preferences mentioned by the user
2481
+ - Defines output format expectations when relevant
2482
+ - Aligns with project-specific coding standards and patterns from CLAUDE.md
2483
+
2484
+ 4. **Optimize for Performance**: Include:
2485
+ - Decision-making frameworks appropriate to the domain
2486
+ - Quality control mechanisms and self-verification steps
2487
+ - Efficient workflow patterns
2488
+ - Clear escalation or fallback strategies
2489
+
2490
+ 5. **Create Identifier**: Design a concise, descriptive identifier that:
2491
+ - Uses lowercase letters, numbers, and hyphens only
2492
+ - Is typically 2-4 words joined by hyphens
2493
+ - Clearly indicates the agent's primary function
2494
+ - Is memorable and easy to type
2495
+ - Avoids generic terms like "helper" or "assistant"
2496
+
2497
+ 6 **Example agent descriptions**:
2498
+ - in the 'whenToUse' field of the JSON object, you should include examples of when this agent should be used.
2499
+ - examples should be of the form:
2500
+ - <example>
2501
+ Context: The user is creating a test-runner agent that should be called after a logical chunk of code is written.
2502
+ user: "Please write a function that checks if a number is prime"
2503
+ assistant: "Here is the relevant function: "
2504
+ <function call omitted for brevity only for this example>
2505
+ <commentary>
2506
+ Since a significant piece of code was written, use the ${AGENT_TOOL_NAME} tool to launch the test-runner agent to run the tests.
2507
+ </commentary>
2508
+ assistant: "Now let me use the test-runner agent to run the tests"
2509
+ </example>
2510
+ - <example>
2511
+ Context: User is creating an agent to respond to the word "hello" with a friendly jok.
2512
+ user: "Hello"
2513
+ assistant: "I'm going to use the ${AGENT_TOOL_NAME} tool to launch the greeting-responder agent to respond with a friendly joke"
2514
+ <commentary>
2515
+ Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
2516
+ </commentary>
2517
+ </example>
2518
+ - If the user mentioned or implied that the agent should be used proactively, you should include examples of this.
2519
+ - NOTE: Ensure that in the examples, you are making the assistant use the Agent tool and not simply respond directly to the task.
2520
+
2521
+ Your output must be a valid JSON object with exactly these fields:
2522
+ {
2523
+ "identifier": "A unique, descriptive identifier using lowercase letters, numbers, and hyphens (e.g., 'test-runner', 'api-docs-writer', 'code-formatter')",
2524
+ "whenToUse": "A precise, actionable description starting with 'Use this agent when...' that clearly defines the triggering conditions and use cases. Ensure you include examples as described above.",
2525
+ "systemPrompt": "The complete system prompt that will govern the agent's behavior, written in second person ('You are...', 'You will...') and structured for maximum clarity and effectiveness"
2526
+ }
2527
+
2528
+ Key principles for your system prompts:
2529
+ - Be specific rather than generic - avoid vague instructions
2530
+ - Include concrete examples when they would clarify behavior
2531
+ - Balance comprehensiveness with clarity - every instruction should add value
2532
+ - Ensure the agent has enough context to handle variations of the core task
2533
+ - Make the agent proactive in seeking clarification when needed
2534
+ - Build in quality assurance and self-correction mechanisms
2535
+
2536
+ Remember: The agents you create should be autonomous experts capable of handling their designated tasks with minimal additional guidance. Your system prompts are their complete operational manual.
2537
+ `;
2538
+ });
2539
+
2540
+ // src/components/agents/new-agent-creation/wizard-steps/GenerateStep.tsx
2541
+ function GenerateStep() {
2542
+ const { updateWizardData, goBack, goToStep, wizardData } = useWizard();
2543
+ const [prompt, setPrompt] = import_react8.useState(wizardData.generationPrompt || "");
2544
+ const [isGenerating, setIsGenerating] = import_react8.useState(false);
2545
+ const [error, setError] = import_react8.useState(null);
2546
+ const [cursorOffset, setCursorOffset] = import_react8.useState(prompt.length);
2547
+ const model = useMainLoopModel();
2548
+ const abortControllerRef = import_react8.useRef(null);
2549
+ const handleCancelGeneration = import_react8.useCallback(() => {
2550
+ if (abortControllerRef.current) {
2551
+ abortControllerRef.current.abort();
2552
+ abortControllerRef.current = null;
2553
+ setIsGenerating(false);
2554
+ setError("Generation cancelled");
2555
+ }
2556
+ }, []);
2557
+ useKeybinding("confirm:no", handleCancelGeneration, {
2558
+ context: "Settings",
2559
+ isActive: isGenerating
2560
+ });
2561
+ const handleExternalEditor = import_react8.useCallback(async () => {
2562
+ const result = await editPromptInEditor(prompt);
2563
+ if (result.content !== null) {
2564
+ setPrompt(result.content);
2565
+ setCursorOffset(result.content.length);
2566
+ }
2567
+ }, [prompt]);
2568
+ useKeybinding("chat:externalEditor", handleExternalEditor, {
2569
+ context: "Chat",
2570
+ isActive: !isGenerating
2571
+ });
2572
+ const handleGoBack = import_react8.useCallback(() => {
2573
+ updateWizardData({
2574
+ generationPrompt: "",
2575
+ agentType: "",
2576
+ systemPrompt: "",
2577
+ whenToUse: "",
2578
+ generatedAgent: undefined,
2579
+ wasGenerated: false
2580
+ });
2581
+ setPrompt("");
2582
+ setError(null);
2583
+ goBack();
2584
+ }, [updateWizardData, goBack]);
2585
+ useKeybinding("confirm:no", handleGoBack, {
2586
+ context: "Settings",
2587
+ isActive: !isGenerating
2588
+ });
2589
+ const handleGenerate = async () => {
2590
+ const trimmedPrompt = prompt.trim();
2591
+ if (!trimmedPrompt) {
2592
+ setError("Please describe what the agent should do");
2593
+ return;
2594
+ }
2595
+ setError(null);
2596
+ setIsGenerating(true);
2597
+ updateWizardData({
2598
+ generationPrompt: trimmedPrompt,
2599
+ isGenerating: true
2600
+ });
2601
+ const controller = createAbortController();
2602
+ abortControllerRef.current = controller;
2603
+ try {
2604
+ const generated = await generateAgent(trimmedPrompt, model, [], controller.signal);
2605
+ updateWizardData({
2606
+ agentType: generated.identifier,
2607
+ whenToUse: generated.whenToUse,
2608
+ systemPrompt: generated.systemPrompt,
2609
+ generatedAgent: generated,
2610
+ isGenerating: false,
2611
+ wasGenerated: true
2612
+ });
2613
+ goToStep(6);
2614
+ } catch (err) {
2615
+ if (err instanceof APIUserAbortError) {} else if (err instanceof Error && !err.message.includes("No assistant message found")) {
2616
+ setError(err.message || "Failed to generate agent");
2617
+ }
2618
+ updateWizardData({ isGenerating: false });
2619
+ } finally {
2620
+ setIsGenerating(false);
2621
+ abortControllerRef.current = null;
2622
+ }
2623
+ };
2624
+ const subtitle = "Describe what this agent should do and when it should be used (be comprehensive for best results)";
2625
+ if (isGenerating) {
2626
+ return /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(WizardDialogLayout, {
2627
+ subtitle,
2628
+ footerText: /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(ConfigurableShortcutHint, {
2629
+ action: "confirm:no",
2630
+ context: "Settings",
2631
+ fallback: "Esc",
2632
+ description: "cancel"
2633
+ }, undefined, false, undefined, this),
2634
+ children: /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(ThemedBox_default, {
2635
+ flexDirection: "row",
2636
+ alignItems: "center",
2637
+ children: [
2638
+ /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Spinner, {}, undefined, false, undefined, this),
2639
+ /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(ThemedText, {
2640
+ color: "suggestion",
2641
+ children: " Generating agent from description..."
2642
+ }, undefined, false, undefined, this)
2643
+ ]
2644
+ }, undefined, true, undefined, this)
2645
+ }, undefined, false, undefined, this);
2646
+ }
2647
+ return /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(WizardDialogLayout, {
2648
+ subtitle,
2649
+ footerText: /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Byline, {
2650
+ children: [
2651
+ /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(ConfigurableShortcutHint, {
2652
+ action: "confirm:yes",
2653
+ context: "Confirmation",
2654
+ fallback: "Enter",
2655
+ description: "submit"
2656
+ }, undefined, false, undefined, this),
2657
+ /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(ConfigurableShortcutHint, {
2658
+ action: "chat:externalEditor",
2659
+ context: "Chat",
2660
+ fallback: "ctrl+g",
2661
+ description: "open in editor"
2662
+ }, undefined, false, undefined, this),
2663
+ /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(ConfigurableShortcutHint, {
2664
+ action: "confirm:no",
2665
+ context: "Settings",
2666
+ fallback: "Esc",
2667
+ description: "go back"
2668
+ }, undefined, false, undefined, this)
2669
+ ]
2670
+ }, undefined, true, undefined, this),
2671
+ children: /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(ThemedBox_default, {
2672
+ flexDirection: "column",
2673
+ children: [
2674
+ error && /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(ThemedBox_default, {
2675
+ marginBottom: 1,
2676
+ children: /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(ThemedText, {
2677
+ color: "error",
2678
+ children: error
2679
+ }, undefined, false, undefined, this)
2680
+ }, undefined, false, undefined, this),
2681
+ /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(TextInput, {
2682
+ value: prompt,
2683
+ onChange: setPrompt,
2684
+ onSubmit: handleGenerate,
2685
+ placeholder: "e.g., Help me write unit tests for my code...",
2686
+ columns: 80,
2687
+ cursorOffset,
2688
+ onChangeCursorOffset: setCursorOffset,
2689
+ focus: true,
2690
+ showCursor: true
2691
+ }, undefined, false, undefined, this)
2692
+ ]
2693
+ }, undefined, true, undefined, this)
2694
+ }, undefined, false, undefined, this);
2695
+ }
2696
+ var import_react8, jsx_dev_runtime15;
2697
+ var init_GenerateStep = __esm(() => {
2698
+ init_sdk();
2699
+ init_useMainLoopModel();
2700
+ init_src();
2701
+ init_useKeybinding();
2702
+ init_abortController();
2703
+ init_promptEditor();
2704
+ init_ConfigurableShortcutHint();
2705
+ init_Spinner();
2706
+ init_TextInput();
2707
+ init_wizard();
2708
+ init_WizardDialogLayout();
2709
+ init_generateAgent();
2710
+ import_react8 = __toESM(require_react(), 1);
2711
+ jsx_dev_runtime15 = __toESM(require_jsx_dev_runtime(), 1);
2712
+ });
2713
+
2714
+ // src/components/agents/new-agent-creation/wizard-steps/LocationStep.tsx
2715
+ function LocationStep() {
2716
+ const { goNext, updateWizardData, cancel } = useWizard();
2717
+ const locationOptions = [
2718
+ {
2719
+ label: "Project (.claude/agents/)",
2720
+ value: "projectSettings"
2721
+ },
2722
+ {
2723
+ label: "Personal (~/.claude/agents/)",
2724
+ value: "userSettings"
2725
+ }
2726
+ ];
2727
+ return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(WizardDialogLayout, {
2728
+ subtitle: "Choose location",
2729
+ footerText: /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Byline, {
2730
+ children: [
2731
+ /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(KeyboardShortcutHint, {
2732
+ shortcut: "\u2191\u2193",
2733
+ action: "navigate"
2734
+ }, undefined, false, undefined, this),
2735
+ /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(KeyboardShortcutHint, {
2736
+ shortcut: "Enter",
2737
+ action: "select"
2738
+ }, undefined, false, undefined, this),
2739
+ /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(ConfigurableShortcutHint, {
2740
+ action: "confirm:no",
2741
+ context: "Confirmation",
2742
+ fallback: "Esc",
2743
+ description: "cancel"
2744
+ }, undefined, false, undefined, this)
2745
+ ]
2746
+ }, undefined, true, undefined, this),
2747
+ children: /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(ThemedBox_default, {
2748
+ children: /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Select, {
2749
+ options: locationOptions,
2750
+ onChange: (value) => {
2751
+ updateWizardData({ location: value });
2752
+ goNext();
2753
+ },
2754
+ onCancel: () => cancel()
2755
+ }, "location-select", false, undefined, this)
2756
+ }, undefined, false, undefined, this)
2757
+ }, undefined, false, undefined, this);
2758
+ }
2759
+ var jsx_dev_runtime16;
2760
+ var init_LocationStep = __esm(() => {
2761
+ init_src();
2762
+ init_ConfigurableShortcutHint();
2763
+ init_select();
2764
+ init_wizard();
2765
+ init_WizardDialogLayout();
2766
+ jsx_dev_runtime16 = __toESM(require_jsx_dev_runtime(), 1);
2767
+ });
2768
+
2769
+ // src/components/agents/new-agent-creation/wizard-steps/MemoryStep.tsx
2770
+ function MemoryStep() {
2771
+ const { goNext, goBack, updateWizardData, wizardData } = useWizard();
2772
+ useKeybinding("confirm:no", goBack, { context: "Confirmation" });
2773
+ const isUserScope = wizardData.location === "userSettings";
2774
+ const memoryOptions = isUserScope ? [
2775
+ {
2776
+ label: "User scope (~/.claude/agent-memory/) (Recommended)",
2777
+ value: "user"
2778
+ },
2779
+ { label: "None (no persistent memory)", value: "none" },
2780
+ { label: "Project scope (.claude/agent-memory/)", value: "project" },
2781
+ { label: "Local scope (.claude/agent-memory-local/)", value: "local" }
2782
+ ] : [
2783
+ {
2784
+ label: "Project scope (.claude/agent-memory/) (Recommended)",
2785
+ value: "project"
2786
+ },
2787
+ { label: "None (no persistent memory)", value: "none" },
2788
+ { label: "User scope (~/.claude/agent-memory/)", value: "user" },
2789
+ { label: "Local scope (.claude/agent-memory-local/)", value: "local" }
2790
+ ];
2791
+ const handleSelect = (value) => {
2792
+ const memory = value === "none" ? undefined : value;
2793
+ const agentType = wizardData.finalAgent?.agentType;
2794
+ updateWizardData({
2795
+ selectedMemory: memory,
2796
+ finalAgent: wizardData.finalAgent ? {
2797
+ ...wizardData.finalAgent,
2798
+ memory,
2799
+ getSystemPrompt: isAutoMemoryEnabled() && memory && agentType ? () => wizardData.systemPrompt + `
2800
+
2801
+ ` + loadAgentMemoryPrompt(agentType, memory) : () => wizardData.systemPrompt
2802
+ } : undefined
2803
+ });
2804
+ goNext();
2805
+ };
2806
+ return /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(WizardDialogLayout, {
2807
+ subtitle: "Configure agent memory",
2808
+ footerText: /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Byline, {
2809
+ children: [
2810
+ /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(KeyboardShortcutHint, {
2811
+ shortcut: "\u2191\u2193",
2812
+ action: "navigate"
2813
+ }, undefined, false, undefined, this),
2814
+ /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(KeyboardShortcutHint, {
2815
+ shortcut: "Enter",
2816
+ action: "select"
2817
+ }, undefined, false, undefined, this),
2818
+ /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(ConfigurableShortcutHint, {
2819
+ action: "confirm:no",
2820
+ context: "Confirmation",
2821
+ fallback: "Esc",
2822
+ description: "go back"
2823
+ }, undefined, false, undefined, this)
2824
+ ]
2825
+ }, undefined, true, undefined, this),
2826
+ children: /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(ThemedBox_default, {
2827
+ children: /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Select, {
2828
+ options: memoryOptions,
2829
+ onChange: handleSelect,
2830
+ onCancel: goBack
2831
+ }, "memory-select", false, undefined, this)
2832
+ }, undefined, false, undefined, this)
2833
+ }, undefined, false, undefined, this);
2834
+ }
2835
+ var jsx_dev_runtime17;
2836
+ var init_MemoryStep = __esm(() => {
2837
+ init_src();
2838
+ init_useKeybinding();
2839
+ init_paths();
2840
+ init_agentMemory();
2841
+ init_ConfigurableShortcutHint();
2842
+ init_select();
2843
+ init_wizard();
2844
+ init_WizardDialogLayout();
2845
+ jsx_dev_runtime17 = __toESM(require_jsx_dev_runtime(), 1);
2846
+ });
2847
+
2848
+ // src/components/agents/new-agent-creation/wizard-steps/MethodStep.tsx
2849
+ function MethodStep() {
2850
+ const { goNext, goBack, updateWizardData, goToStep } = useWizard();
2851
+ const methodOptions = [
2852
+ {
2853
+ label: "Generate with Claude (recommended)",
2854
+ value: "generate"
2855
+ },
2856
+ {
2857
+ label: "Manual configuration",
2858
+ value: "manual"
2859
+ }
2860
+ ];
2861
+ return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(WizardDialogLayout, {
2862
+ subtitle: "Creation method",
2863
+ footerText: /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Byline, {
2864
+ children: [
2865
+ /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(KeyboardShortcutHint, {
2866
+ shortcut: "\u2191\u2193",
2867
+ action: "navigate"
2868
+ }, undefined, false, undefined, this),
2869
+ /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(KeyboardShortcutHint, {
2870
+ shortcut: "Enter",
2871
+ action: "select"
2872
+ }, undefined, false, undefined, this),
2873
+ /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(ConfigurableShortcutHint, {
2874
+ action: "confirm:no",
2875
+ context: "Confirmation",
2876
+ fallback: "Esc",
2877
+ description: "go back"
2878
+ }, undefined, false, undefined, this)
2879
+ ]
2880
+ }, undefined, true, undefined, this),
2881
+ children: /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(ThemedBox_default, {
2882
+ children: /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Select, {
2883
+ options: methodOptions,
2884
+ onChange: (value) => {
2885
+ const method = value;
2886
+ updateWizardData({
2887
+ method,
2888
+ wasGenerated: method === "generate"
2889
+ });
2890
+ if (method === "generate") {
2891
+ goNext();
2892
+ } else {
2893
+ goToStep(3);
2894
+ }
2895
+ },
2896
+ onCancel: () => goBack()
2897
+ }, "method-select", false, undefined, this)
2898
+ }, undefined, false, undefined, this)
2899
+ }, undefined, false, undefined, this);
2900
+ }
2901
+ var jsx_dev_runtime18;
2902
+ var init_MethodStep = __esm(() => {
2903
+ init_src();
2904
+ init_ConfigurableShortcutHint();
2905
+ init_select();
2906
+ init_wizard();
2907
+ init_WizardDialogLayout();
2908
+ jsx_dev_runtime18 = __toESM(require_jsx_dev_runtime(), 1);
2909
+ });
2910
+
2911
+ // src/components/agents/new-agent-creation/wizard-steps/ModelStep.tsx
2912
+ function ModelStep() {
2913
+ const { goNext, goBack, updateWizardData, wizardData } = useWizard();
2914
+ const handleComplete = (model) => {
2915
+ updateWizardData({ selectedModel: model });
2916
+ goNext();
2917
+ };
2918
+ return /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(WizardDialogLayout, {
2919
+ subtitle: "Select model",
2920
+ footerText: /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Byline, {
2921
+ children: [
2922
+ /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(KeyboardShortcutHint, {
2923
+ shortcut: "\u2191\u2193",
2924
+ action: "navigate"
2925
+ }, undefined, false, undefined, this),
2926
+ /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(KeyboardShortcutHint, {
2927
+ shortcut: "Enter",
2928
+ action: "select"
2929
+ }, undefined, false, undefined, this),
2930
+ /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(ConfigurableShortcutHint, {
2931
+ action: "confirm:no",
2932
+ context: "Confirmation",
2933
+ fallback: "Esc",
2934
+ description: "go back"
2935
+ }, undefined, false, undefined, this)
2936
+ ]
2937
+ }, undefined, true, undefined, this),
2938
+ children: /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(ModelSelector, {
2939
+ initialModel: wizardData.selectedModel,
2940
+ onComplete: handleComplete,
2941
+ onCancel: goBack
2942
+ }, undefined, false, undefined, this)
2943
+ }, undefined, false, undefined, this);
2944
+ }
2945
+ var jsx_dev_runtime19;
2946
+ var init_ModelStep = __esm(() => {
2947
+ init_ConfigurableShortcutHint();
2948
+ init_src();
2949
+ init_wizard();
2950
+ init_WizardDialogLayout();
2951
+ init_ModelSelector();
2952
+ jsx_dev_runtime19 = __toESM(require_jsx_dev_runtime(), 1);
2953
+ });
2954
+
2955
+ // src/components/agents/new-agent-creation/wizard-steps/PromptStep.tsx
2956
+ function PromptStep() {
2957
+ const { goNext, goBack, updateWizardData, wizardData } = useWizard();
2958
+ const [systemPrompt, setSystemPrompt] = import_react9.useState(wizardData.systemPrompt || "");
2959
+ const [cursorOffset, setCursorOffset] = import_react9.useState(systemPrompt.length);
2960
+ const [error, setError] = import_react9.useState(null);
2961
+ useKeybinding("confirm:no", goBack, { context: "Settings" });
2962
+ const handleExternalEditor = import_react9.useCallback(async () => {
2963
+ const result = await editPromptInEditor(systemPrompt);
2964
+ if (result.content !== null) {
2965
+ setSystemPrompt(result.content);
2966
+ setCursorOffset(result.content.length);
2967
+ }
2968
+ }, [systemPrompt]);
2969
+ useKeybinding("chat:externalEditor", handleExternalEditor, {
2970
+ context: "Chat"
2971
+ });
2972
+ const handleSubmit = () => {
2973
+ const trimmedPrompt = systemPrompt.trim();
2974
+ if (!trimmedPrompt) {
2975
+ setError("System prompt is required");
2976
+ return;
2977
+ }
2978
+ setError(null);
2979
+ updateWizardData({ systemPrompt: trimmedPrompt });
2980
+ goNext();
2981
+ };
2982
+ return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(WizardDialogLayout, {
2983
+ subtitle: "System prompt",
2984
+ footerText: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Byline, {
2985
+ children: [
2986
+ /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(KeyboardShortcutHint, {
2987
+ shortcut: "Type",
2988
+ action: "enter text"
2989
+ }, undefined, false, undefined, this),
2990
+ /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(KeyboardShortcutHint, {
2991
+ shortcut: "Enter",
2992
+ action: "continue"
2993
+ }, undefined, false, undefined, this),
2994
+ /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(ConfigurableShortcutHint, {
2995
+ action: "chat:externalEditor",
2996
+ context: "Chat",
2997
+ fallback: "ctrl+g",
2998
+ description: "open in editor"
2999
+ }, undefined, false, undefined, this),
3000
+ /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(ConfigurableShortcutHint, {
3001
+ action: "confirm:no",
3002
+ context: "Settings",
3003
+ fallback: "Esc",
3004
+ description: "go back"
3005
+ }, undefined, false, undefined, this)
3006
+ ]
3007
+ }, undefined, true, undefined, this),
3008
+ children: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(ThemedBox_default, {
3009
+ flexDirection: "column",
3010
+ children: [
3011
+ /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(ThemedText, {
3012
+ children: "Enter the system prompt for your agent:"
3013
+ }, undefined, false, undefined, this),
3014
+ /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(ThemedText, {
3015
+ dimColor: true,
3016
+ children: "Be comprehensive for best results"
3017
+ }, undefined, false, undefined, this),
3018
+ /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(ThemedBox_default, {
3019
+ marginTop: 1,
3020
+ children: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(TextInput, {
3021
+ value: systemPrompt,
3022
+ onChange: setSystemPrompt,
3023
+ onSubmit: handleSubmit,
3024
+ placeholder: "You are a helpful code reviewer who...",
3025
+ columns: 80,
3026
+ cursorOffset,
3027
+ onChangeCursorOffset: setCursorOffset,
3028
+ focus: true,
3029
+ showCursor: true
3030
+ }, undefined, false, undefined, this)
3031
+ }, undefined, false, undefined, this),
3032
+ error && /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(ThemedBox_default, {
3033
+ marginTop: 1,
3034
+ children: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(ThemedText, {
3035
+ color: "error",
3036
+ children: error
3037
+ }, undefined, false, undefined, this)
3038
+ }, undefined, false, undefined, this)
3039
+ ]
3040
+ }, undefined, true, undefined, this)
3041
+ }, undefined, false, undefined, this);
3042
+ }
3043
+ var import_react9, jsx_dev_runtime20;
3044
+ var init_PromptStep = __esm(() => {
3045
+ init_src();
3046
+ init_useKeybinding();
3047
+ init_promptEditor();
3048
+ init_ConfigurableShortcutHint();
3049
+ init_TextInput();
3050
+ init_wizard();
3051
+ init_WizardDialogLayout();
3052
+ import_react9 = __toESM(require_react(), 1);
3053
+ jsx_dev_runtime20 = __toESM(require_jsx_dev_runtime(), 1);
3054
+ });
3055
+
3056
+ // src/components/agents/new-agent-creation/wizard-steps/ToolsStep.tsx
3057
+ function ToolsStep({ tools }) {
3058
+ const { goNext, goBack, updateWizardData, wizardData } = useWizard();
3059
+ const handleComplete = (selectedTools) => {
3060
+ updateWizardData({ selectedTools });
3061
+ goNext();
3062
+ };
3063
+ const initialTools = wizardData.selectedTools;
3064
+ return /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(WizardDialogLayout, {
3065
+ subtitle: "Select tools",
3066
+ footerText: /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Byline, {
3067
+ children: [
3068
+ /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(KeyboardShortcutHint, {
3069
+ shortcut: "Enter",
3070
+ action: "toggle selection"
3071
+ }, undefined, false, undefined, this),
3072
+ /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(KeyboardShortcutHint, {
3073
+ shortcut: "\u2191\u2193",
3074
+ action: "navigate"
3075
+ }, undefined, false, undefined, this),
3076
+ /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(ConfigurableShortcutHint, {
3077
+ action: "confirm:no",
3078
+ context: "Confirmation",
3079
+ fallback: "Esc",
3080
+ description: "go back"
3081
+ }, undefined, false, undefined, this)
3082
+ ]
3083
+ }, undefined, true, undefined, this),
3084
+ children: /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(ToolSelector, {
3085
+ tools,
3086
+ initialTools,
3087
+ onComplete: handleComplete,
3088
+ onCancel: goBack
3089
+ }, undefined, false, undefined, this)
3090
+ }, undefined, false, undefined, this);
3091
+ }
3092
+ var jsx_dev_runtime21;
3093
+ var init_ToolsStep = __esm(() => {
3094
+ init_src();
3095
+ init_ConfigurableShortcutHint();
3096
+ init_wizard();
3097
+ init_WizardDialogLayout();
3098
+ init_ToolSelector();
3099
+ jsx_dev_runtime21 = __toESM(require_jsx_dev_runtime(), 1);
3100
+ });
3101
+
3102
+ // src/components/agents/new-agent-creation/wizard-steps/TypeStep.tsx
3103
+ function TypeStep(_props) {
3104
+ const { goNext, goBack, updateWizardData, wizardData } = useWizard();
3105
+ const [agentType, setAgentType] = import_react10.useState(wizardData.agentType || "");
3106
+ const [error, setError] = import_react10.useState(null);
3107
+ const [cursorOffset, setCursorOffset] = import_react10.useState(agentType.length);
3108
+ useKeybinding("confirm:no", goBack, { context: "Settings" });
3109
+ const handleSubmit = (value) => {
3110
+ const trimmedValue = value.trim();
3111
+ const validationError = validateAgentType(trimmedValue);
3112
+ if (validationError) {
3113
+ setError(validationError);
3114
+ return;
3115
+ }
3116
+ setError(null);
3117
+ updateWizardData({ agentType: trimmedValue });
3118
+ goNext();
3119
+ };
3120
+ return /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(WizardDialogLayout, {
3121
+ subtitle: "Agent type (identifier)",
3122
+ footerText: /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Byline, {
3123
+ children: [
3124
+ /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(KeyboardShortcutHint, {
3125
+ shortcut: "Type",
3126
+ action: "enter text"
3127
+ }, undefined, false, undefined, this),
3128
+ /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(KeyboardShortcutHint, {
3129
+ shortcut: "Enter",
3130
+ action: "continue"
3131
+ }, undefined, false, undefined, this),
3132
+ /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(ConfigurableShortcutHint, {
3133
+ action: "confirm:no",
3134
+ context: "Settings",
3135
+ fallback: "Esc",
3136
+ description: "go back"
3137
+ }, undefined, false, undefined, this)
3138
+ ]
3139
+ }, undefined, true, undefined, this),
3140
+ children: /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(ThemedBox_default, {
3141
+ flexDirection: "column",
3142
+ children: [
3143
+ /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(ThemedText, {
3144
+ children: "Enter a unique identifier for your agent:"
3145
+ }, undefined, false, undefined, this),
3146
+ /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(ThemedBox_default, {
3147
+ marginTop: 1,
3148
+ children: /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(TextInput, {
3149
+ value: agentType,
3150
+ onChange: setAgentType,
3151
+ onSubmit: handleSubmit,
3152
+ placeholder: "e.g., test-runner, tech-lead, etc",
3153
+ columns: 60,
3154
+ cursorOffset,
3155
+ onChangeCursorOffset: setCursorOffset,
3156
+ focus: true,
3157
+ showCursor: true
3158
+ }, undefined, false, undefined, this)
3159
+ }, undefined, false, undefined, this),
3160
+ error && /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(ThemedBox_default, {
3161
+ marginTop: 1,
3162
+ children: /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(ThemedText, {
3163
+ color: "error",
3164
+ children: error
3165
+ }, undefined, false, undefined, this)
3166
+ }, undefined, false, undefined, this)
3167
+ ]
3168
+ }, undefined, true, undefined, this)
3169
+ }, undefined, false, undefined, this);
3170
+ }
3171
+ var import_react10, jsx_dev_runtime22;
3172
+ var init_TypeStep = __esm(() => {
3173
+ init_src();
3174
+ init_useKeybinding();
3175
+ init_ConfigurableShortcutHint();
3176
+ init_TextInput();
3177
+ init_wizard();
3178
+ init_WizardDialogLayout();
3179
+ init_validateAgent();
3180
+ import_react10 = __toESM(require_react(), 1);
3181
+ jsx_dev_runtime22 = __toESM(require_jsx_dev_runtime(), 1);
3182
+ });
3183
+
3184
+ // src/components/agents/new-agent-creation/CreateAgentWizard.tsx
3185
+ function CreateAgentWizard({
3186
+ tools,
3187
+ existingAgents,
3188
+ onComplete,
3189
+ onCancel
3190
+ }) {
3191
+ const steps = [
3192
+ LocationStep,
3193
+ MethodStep,
3194
+ GenerateStep,
3195
+ () => /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(TypeStep, {
3196
+ existingAgents
3197
+ }, undefined, false, undefined, this),
3198
+ PromptStep,
3199
+ DescriptionStep,
3200
+ () => /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ToolsStep, {
3201
+ tools
3202
+ }, undefined, false, undefined, this),
3203
+ ModelStep,
3204
+ ColorStep,
3205
+ ...isAutoMemoryEnabled() ? [MemoryStep] : [],
3206
+ () => /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ConfirmStepWrapper, {
3207
+ tools,
3208
+ existingAgents,
3209
+ onComplete
3210
+ }, undefined, false, undefined, this)
3211
+ ];
3212
+ return /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(WizardProvider, {
3213
+ steps,
3214
+ initialData: {},
3215
+ onComplete: () => {},
3216
+ onCancel,
3217
+ title: "Create new agent",
3218
+ showStepCounter: false
3219
+ }, undefined, false, undefined, this);
3220
+ }
3221
+ var jsx_dev_runtime23;
3222
+ var init_CreateAgentWizard = __esm(() => {
3223
+ init_paths();
3224
+ init_wizard();
3225
+ init_ColorStep();
3226
+ init_ConfirmStepWrapper();
3227
+ init_DescriptionStep();
3228
+ init_GenerateStep();
3229
+ init_LocationStep();
3230
+ init_MemoryStep();
3231
+ init_MethodStep();
3232
+ init_ModelStep();
3233
+ init_PromptStep();
3234
+ init_ToolsStep();
3235
+ init_TypeStep();
3236
+ jsx_dev_runtime23 = __toESM(require_jsx_dev_runtime(), 1);
3237
+ });
3238
+
3239
+ // src/components/agents/AgentsMenu.tsx
3240
+ function AgentsMenu({ tools, onExit }) {
3241
+ const [modeState, setModeState] = import_react11.useState({
3242
+ mode: "list-agents",
3243
+ source: "all"
3244
+ });
3245
+ const agentDefinitions = useAppState((s) => s.agentDefinitions);
3246
+ const mcpTools = useAppState((s) => s.mcp.tools);
3247
+ const toolPermissionContext = useAppState((s) => s.toolPermissionContext);
3248
+ const setAppState = useSetAppState();
3249
+ const { allAgents, activeAgents: agents } = agentDefinitions;
3250
+ const [changes, setChanges] = import_react11.useState([]);
3251
+ const mergedTools = useMergedTools(tools, mcpTools, toolPermissionContext);
3252
+ useExitOnCtrlCDWithKeybindings();
3253
+ const agentsBySource = import_react11.useMemo(() => ({
3254
+ "built-in": allAgents.filter((a) => a.source === "built-in"),
3255
+ userSettings: allAgents.filter((a) => a.source === "userSettings"),
3256
+ projectSettings: allAgents.filter((a) => a.source === "projectSettings"),
3257
+ policySettings: allAgents.filter((a) => a.source === "policySettings"),
3258
+ localSettings: allAgents.filter((a) => a.source === "localSettings"),
3259
+ flagSettings: allAgents.filter((a) => a.source === "flagSettings"),
3260
+ plugin: allAgents.filter((a) => a.source === "plugin"),
3261
+ all: allAgents
3262
+ }), [allAgents]);
3263
+ const handleAgentCreated = import_react11.useCallback((message) => {
3264
+ setChanges((prev) => [...prev, message]);
3265
+ setModeState({ mode: "list-agents", source: "all" });
3266
+ }, []);
3267
+ const handleAgentDeleted = import_react11.useCallback(async (agent) => {
3268
+ try {
3269
+ await deleteAgentFromFile(agent);
3270
+ setAppState((state) => {
3271
+ const allAgents2 = state.agentDefinitions.allAgents.filter((a) => !(a.agentType === agent.agentType && a.source === agent.source));
3272
+ return {
3273
+ ...state,
3274
+ agentDefinitions: {
3275
+ ...state.agentDefinitions,
3276
+ allAgents: allAgents2,
3277
+ activeAgents: getActiveAgentsFromList(allAgents2)
3278
+ }
3279
+ };
3280
+ });
3281
+ setChanges((prev) => [
3282
+ ...prev,
3283
+ `Deleted agent: ${source_default.bold(agent.agentType)}`
3284
+ ]);
3285
+ setModeState({ mode: "list-agents", source: "all" });
3286
+ } catch (error) {
3287
+ logError(toError(error));
3288
+ }
3289
+ }, [setAppState]);
3290
+ switch (modeState.mode) {
3291
+ case "list-agents": {
3292
+ const agentsToShow = modeState.source === "all" ? [
3293
+ ...agentsBySource["built-in"],
3294
+ ...agentsBySource["userSettings"],
3295
+ ...agentsBySource["projectSettings"],
3296
+ ...agentsBySource["localSettings"],
3297
+ ...agentsBySource["policySettings"],
3298
+ ...agentsBySource["flagSettings"],
3299
+ ...agentsBySource["plugin"]
3300
+ ] : agentsBySource[modeState.source];
3301
+ const allResolved = resolveAgentOverrides(agentsToShow, agents);
3302
+ const resolvedAgents = allResolved;
3303
+ return /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(jsx_dev_runtime24.Fragment, {
3304
+ children: [
3305
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(AgentsList, {
3306
+ source: modeState.source,
3307
+ agents: resolvedAgents,
3308
+ onBack: () => {
3309
+ const exitMessage = changes.length > 0 ? `Agent changes:
3310
+ ${changes.join(`
3311
+ `)}` : undefined;
3312
+ onExit(exitMessage ?? "Agents dialog dismissed", {
3313
+ display: changes.length === 0 ? "system" : undefined
3314
+ });
3315
+ },
3316
+ onSelect: (agent) => setModeState({
3317
+ mode: "agent-menu",
3318
+ agent,
3319
+ previousMode: modeState
3320
+ }),
3321
+ onCreateNew: () => setModeState({ mode: "create-agent" }),
3322
+ changes
3323
+ }, undefined, false, undefined, this),
3324
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(AgentNavigationFooter, {}, undefined, false, undefined, this)
3325
+ ]
3326
+ }, undefined, true, undefined, this);
3327
+ }
3328
+ case "create-agent":
3329
+ return /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(CreateAgentWizard, {
3330
+ tools: mergedTools,
3331
+ existingAgents: agents,
3332
+ onComplete: handleAgentCreated,
3333
+ onCancel: () => setModeState({ mode: "list-agents", source: "all" })
3334
+ }, undefined, false, undefined, this);
3335
+ case "agent-menu": {
3336
+ const freshAgent = allAgents.find((a) => a.agentType === modeState.agent.agentType && a.source === modeState.agent.source);
3337
+ const agentToUse = freshAgent || modeState.agent;
3338
+ const isEditable = agentToUse.source !== "built-in" && agentToUse.source !== "plugin" && agentToUse.source !== "flagSettings";
3339
+ const menuItems = [
3340
+ { label: "View agent", value: "view" },
3341
+ ...isEditable ? [
3342
+ { label: "Edit agent", value: "edit" },
3343
+ { label: "Delete agent", value: "delete" }
3344
+ ] : [],
3345
+ { label: "Back", value: "back" }
3346
+ ];
3347
+ const handleMenuSelect = (value) => {
3348
+ switch (value) {
3349
+ case "view":
3350
+ setModeState({
3351
+ mode: "view-agent",
3352
+ agent: agentToUse,
3353
+ previousMode: modeState.previousMode
3354
+ });
3355
+ break;
3356
+ case "edit":
3357
+ setModeState({
3358
+ mode: "edit-agent",
3359
+ agent: agentToUse,
3360
+ previousMode: modeState
3361
+ });
3362
+ break;
3363
+ case "delete":
3364
+ setModeState({
3365
+ mode: "delete-confirm",
3366
+ agent: agentToUse,
3367
+ previousMode: modeState
3368
+ });
3369
+ break;
3370
+ case "back":
3371
+ setModeState(modeState.previousMode);
3372
+ break;
3373
+ }
3374
+ };
3375
+ return /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(jsx_dev_runtime24.Fragment, {
3376
+ children: [
3377
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(Dialog, {
3378
+ title: modeState.agent.agentType,
3379
+ onCancel: () => setModeState(modeState.previousMode),
3380
+ hideInputGuide: true,
3381
+ children: /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(ThemedBox_default, {
3382
+ flexDirection: "column",
3383
+ children: [
3384
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(Select, {
3385
+ options: menuItems,
3386
+ onChange: handleMenuSelect,
3387
+ onCancel: () => setModeState(modeState.previousMode)
3388
+ }, undefined, false, undefined, this),
3389
+ changes.length > 0 && /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(ThemedBox_default, {
3390
+ marginTop: 1,
3391
+ children: /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(ThemedText, {
3392
+ dimColor: true,
3393
+ children: changes[changes.length - 1]
3394
+ }, undefined, false, undefined, this)
3395
+ }, undefined, false, undefined, this)
3396
+ ]
3397
+ }, undefined, true, undefined, this)
3398
+ }, undefined, false, undefined, this),
3399
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(AgentNavigationFooter, {}, undefined, false, undefined, this)
3400
+ ]
3401
+ }, undefined, true, undefined, this);
3402
+ }
3403
+ case "view-agent": {
3404
+ const freshAgent = allAgents.find((a) => a.agentType === modeState.agent.agentType && a.source === modeState.agent.source);
3405
+ const agentToDisplay = freshAgent || modeState.agent;
3406
+ return /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(jsx_dev_runtime24.Fragment, {
3407
+ children: [
3408
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(Dialog, {
3409
+ title: agentToDisplay.agentType,
3410
+ onCancel: () => setModeState({
3411
+ mode: "agent-menu",
3412
+ agent: agentToDisplay,
3413
+ previousMode: modeState.previousMode
3414
+ }),
3415
+ hideInputGuide: true,
3416
+ children: /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(AgentDetail, {
3417
+ agent: agentToDisplay,
3418
+ tools: mergedTools,
3419
+ allAgents,
3420
+ onBack: () => setModeState({
3421
+ mode: "agent-menu",
3422
+ agent: agentToDisplay,
3423
+ previousMode: modeState.previousMode
3424
+ })
3425
+ }, undefined, false, undefined, this)
3426
+ }, undefined, false, undefined, this),
3427
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(AgentNavigationFooter, {
3428
+ instructions: "Press Enter or Esc to go back"
3429
+ }, undefined, false, undefined, this)
3430
+ ]
3431
+ }, undefined, true, undefined, this);
3432
+ }
3433
+ case "delete-confirm": {
3434
+ const deleteOptions = [
3435
+ { label: "Yes, delete", value: "yes" },
3436
+ { label: "No, cancel", value: "no" }
3437
+ ];
3438
+ return /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(jsx_dev_runtime24.Fragment, {
3439
+ children: [
3440
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(Dialog, {
3441
+ title: "Delete agent",
3442
+ onCancel: () => {
3443
+ if ("previousMode" in modeState)
3444
+ setModeState(modeState.previousMode);
3445
+ },
3446
+ color: "error",
3447
+ children: [
3448
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(ThemedText, {
3449
+ children: [
3450
+ "Are you sure you want to delete the agent",
3451
+ " ",
3452
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(ThemedText, {
3453
+ bold: true,
3454
+ children: modeState.agent.agentType
3455
+ }, undefined, false, undefined, this),
3456
+ "?"
3457
+ ]
3458
+ }, undefined, true, undefined, this),
3459
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(ThemedBox_default, {
3460
+ marginTop: 1,
3461
+ children: /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(ThemedText, {
3462
+ dimColor: true,
3463
+ children: [
3464
+ "Source: ",
3465
+ modeState.agent.source
3466
+ ]
3467
+ }, undefined, true, undefined, this)
3468
+ }, undefined, false, undefined, this),
3469
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(ThemedBox_default, {
3470
+ marginTop: 1,
3471
+ children: /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(Select, {
3472
+ options: deleteOptions,
3473
+ onChange: (value) => {
3474
+ if (value === "yes") {
3475
+ handleAgentDeleted(modeState.agent);
3476
+ } else {
3477
+ if ("previousMode" in modeState) {
3478
+ setModeState(modeState.previousMode);
3479
+ }
3480
+ }
3481
+ },
3482
+ onCancel: () => {
3483
+ if ("previousMode" in modeState) {
3484
+ setModeState(modeState.previousMode);
3485
+ }
3486
+ }
3487
+ }, undefined, false, undefined, this)
3488
+ }, undefined, false, undefined, this)
3489
+ ]
3490
+ }, undefined, true, undefined, this),
3491
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(AgentNavigationFooter, {
3492
+ instructions: "Press \u2191\u2193 to navigate, Enter to select, Esc to cancel"
3493
+ }, undefined, false, undefined, this)
3494
+ ]
3495
+ }, undefined, true, undefined, this);
3496
+ }
3497
+ case "edit-agent": {
3498
+ const freshAgent = allAgents.find((a) => a.agentType === modeState.agent.agentType && a.source === modeState.agent.source);
3499
+ const agentToEdit = freshAgent || modeState.agent;
3500
+ return /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(jsx_dev_runtime24.Fragment, {
3501
+ children: [
3502
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(Dialog, {
3503
+ title: `Edit agent: ${agentToEdit.agentType}`,
3504
+ onCancel: () => setModeState(modeState.previousMode),
3505
+ hideInputGuide: true,
3506
+ children: /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(AgentEditor, {
3507
+ agent: agentToEdit,
3508
+ tools: mergedTools,
3509
+ onSaved: (message) => {
3510
+ handleAgentCreated(message);
3511
+ setModeState(modeState.previousMode);
3512
+ },
3513
+ onBack: () => setModeState(modeState.previousMode)
3514
+ }, undefined, false, undefined, this)
3515
+ }, undefined, false, undefined, this),
3516
+ /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(AgentNavigationFooter, {}, undefined, false, undefined, this)
3517
+ ]
3518
+ }, undefined, true, undefined, this);
3519
+ }
3520
+ default:
3521
+ return null;
3522
+ }
3523
+ }
3524
+ var import_react11, jsx_dev_runtime24;
3525
+ var init_AgentsMenu = __esm(() => {
3526
+ init_source();
3527
+ init_useExitOnCtrlCDWithKeybindings();
3528
+ init_useMergedTools();
3529
+ init_src();
3530
+ init_AppState();
3531
+ init_agentDisplay();
3532
+ init_loadAgentsDir();
3533
+ init_errors();
3534
+ init_log();
3535
+ init_select();
3536
+ init_src();
3537
+ init_AgentDetail();
3538
+ init_AgentEditor();
3539
+ init_AgentNavigationFooter();
3540
+ init_AgentsList();
3541
+ init_agentFileUtils();
3542
+ init_CreateAgentWizard();
3543
+ import_react11 = __toESM(require_react(), 1);
3544
+ jsx_dev_runtime24 = __toESM(require_jsx_dev_runtime(), 1);
3545
+ });
3546
+
3547
+ // src/commands/agents/agents.tsx
3548
+ async function call(onDone, context) {
3549
+ const appState = context.getAppState();
3550
+ const permissionContext = appState.toolPermissionContext;
3551
+ const tools = getTools(permissionContext);
3552
+ return /* @__PURE__ */ jsx_dev_runtime25.jsxDEV(AgentsMenu, {
3553
+ tools,
3554
+ onExit: onDone
3555
+ }, undefined, false, undefined, this);
3556
+ }
3557
+ var jsx_dev_runtime25;
3558
+ var init_agents = __esm(() => {
3559
+ init_AgentsMenu();
3560
+ init_tools();
3561
+ jsx_dev_runtime25 = __toESM(require_jsx_dev_runtime(), 1);
3562
+ });
3563
+ init_agents();
3564
+
3565
+ export {
3566
+ call
3567
+ };