@costrict/csc 4.0.1

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