@caspian2026/agent-sdk 0.0.25 → 0.0.26

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