@caspian2026/agent-sdk 0.0.24 → 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 +196 -47
  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-05kvhzd7.js +0 -3561
  7. package/dist/chunk-07069jq1.js +0 -30
  8. package/dist/chunk-0731m51q.js +0 -8
  9. package/dist/chunk-08bspa4b.js +0 -673
  10. package/dist/chunk-0brkf8q8.js +0 -89
  11. package/dist/chunk-0n843xh7.js +0 -261
  12. package/dist/chunk-0nbp5jwx.js +0 -8583
  13. package/dist/chunk-0nj16az9.js +0 -169
  14. package/dist/chunk-0paqc2yw.js +0 -15
  15. package/dist/chunk-0q6b50ps.js +0 -111
  16. package/dist/chunk-0r5bb9j4.js +0 -477
  17. package/dist/chunk-0rpz1wgn.js +0 -1030
  18. package/dist/chunk-0t81d427.js +0 -41
  19. package/dist/chunk-0vaw02wq.js +0 -24
  20. package/dist/chunk-0vkfrmqm.js +0 -690
  21. package/dist/chunk-0vp3wfab.js +0 -12
  22. package/dist/chunk-0vr10742.js +0 -1809
  23. package/dist/chunk-0xjaqda8.js +0 -1124
  24. package/dist/chunk-13ehyphg.js +0 -223
  25. package/dist/chunk-15jsw9bb.js +0 -349
  26. package/dist/chunk-16m7eyyw.js +0 -1385
  27. package/dist/chunk-1ae3nt9j.js +0 -31
  28. package/dist/chunk-1gq4r3v1.js +0 -308
  29. package/dist/chunk-1gx78081.js +0 -66
  30. package/dist/chunk-1h2famwb.js +0 -49
  31. package/dist/chunk-1n546sfg.js +0 -200
  32. package/dist/chunk-1qg06d60.js +0 -494
  33. package/dist/chunk-1t0rqstn.js +0 -146
  34. package/dist/chunk-1z8p2eqd.js +0 -40
  35. package/dist/chunk-1zjh9cc5.js +0 -266
  36. package/dist/chunk-20ahkkrb.js +0 -132
  37. package/dist/chunk-21pbfch8.js +0 -105
  38. package/dist/chunk-26wtxbdc.js +0 -13870
  39. package/dist/chunk-2fwze72g.js +0 -24
  40. package/dist/chunk-2gcbr1c7.js +0 -107
  41. package/dist/chunk-2grc1yr8.js +0 -654
  42. package/dist/chunk-2gzv8nrw.js +0 -205
  43. package/dist/chunk-2r212cvt.js +0 -253
  44. package/dist/chunk-2s74bt6e.js +0 -317
  45. package/dist/chunk-2v385w7r.js +0 -7422
  46. package/dist/chunk-2wtkvpp2.js +0 -167
  47. package/dist/chunk-31rsspfr.js +0 -418
  48. package/dist/chunk-3c25bcsw.js +0 -17
  49. package/dist/chunk-3jm08aaw.js +0 -91
  50. package/dist/chunk-3mgywd32.js +0 -8
  51. package/dist/chunk-3nk79af8.js +0 -8
  52. package/dist/chunk-3v4sk2py.js +0 -101
  53. package/dist/chunk-3vwft0eh.js +0 -349
  54. package/dist/chunk-3vy1jt9p.js +0 -1010
  55. package/dist/chunk-3wvqzq9w.js +0 -92
  56. package/dist/chunk-3wvv2s8d.js +0 -336
  57. package/dist/chunk-4060b3s2.js +0 -108
  58. package/dist/chunk-434e0vh4.js +0 -275
  59. package/dist/chunk-46dm23zs.js +0 -344
  60. package/dist/chunk-4bh4qs70.js +0 -209
  61. package/dist/chunk-4cxzbqws.js +0 -94
  62. package/dist/chunk-4jm600zv.js +0 -13
  63. package/dist/chunk-4k9d7gxv.js +0 -118
  64. package/dist/chunk-4nc3t6ms.js +0 -396
  65. package/dist/chunk-4pbx3g7s.js +0 -26
  66. package/dist/chunk-4qhh8bpa.js +0 -54
  67. package/dist/chunk-4v63px9y.js +0 -133
  68. package/dist/chunk-4xnnzt3j.js +0 -74
  69. package/dist/chunk-4zchh01h.js +0 -201
  70. package/dist/chunk-5216fha8.js +0 -1163
  71. package/dist/chunk-55raexh7.js +0 -14358
  72. package/dist/chunk-5bffhf64.js +0 -81
  73. package/dist/chunk-5ccdsxgy.js +0 -74
  74. package/dist/chunk-5ddh2hyn.js +0 -91
  75. package/dist/chunk-5e6ncq5j.js +0 -61
  76. package/dist/chunk-5ekyhb1w.js +0 -422
  77. package/dist/chunk-5fy4r8rv.js +0 -52
  78. package/dist/chunk-5h5kx2jd.js +0 -34
  79. package/dist/chunk-5mbgdvyz.js +0 -847
  80. package/dist/chunk-5n1jc02d.js +0 -87
  81. package/dist/chunk-5pysjah8.js +0 -1543
  82. package/dist/chunk-5ssfz438.js +0 -323
  83. package/dist/chunk-5z28bqne.js +0 -6748
  84. package/dist/chunk-603y0mmg.js +0 -50
  85. package/dist/chunk-62v5kkff.js +0 -90
  86. package/dist/chunk-64c1avct.js +0 -13
  87. package/dist/chunk-64r16v22.js +0 -162
  88. package/dist/chunk-64smdx4a.js +0 -418
  89. package/dist/chunk-66zry909.js +0 -11
  90. package/dist/chunk-68ffk5qa.js +0 -14
  91. package/dist/chunk-69n11zng.js +0 -436
  92. package/dist/chunk-6dj5t602.js +0 -341
  93. package/dist/chunk-6dngjwkh.js +0 -63
  94. package/dist/chunk-6nsd9606.js +0 -790
  95. package/dist/chunk-6pkh8frk.js +0 -253
  96. package/dist/chunk-6qcmt5eb.js +0 -251
  97. package/dist/chunk-6ww7451s.js +0 -60
  98. package/dist/chunk-6xgb0kqz.js +0 -90
  99. package/dist/chunk-72ys9m07.js +0 -121
  100. package/dist/chunk-741sgvtx.js +0 -121
  101. package/dist/chunk-7aw745vx.js +0 -40175
  102. package/dist/chunk-7c8b8cfb.js +0 -219
  103. package/dist/chunk-7mwt4e1z.js +0 -234
  104. package/dist/chunk-7sgtxrsc.js +0 -1059
  105. package/dist/chunk-7wm5s02e.js +0 -216
  106. package/dist/chunk-7xyswgjh.js +0 -8
  107. package/dist/chunk-80a197ez.js +0 -1438
  108. package/dist/chunk-83hfzbx3.js +0 -10
  109. package/dist/chunk-8akrsgad.js +0 -55
  110. package/dist/chunk-8g5pe1gr.js +0 -37
  111. package/dist/chunk-8s07t4k7.js +0 -40
  112. package/dist/chunk-8yhf030a.js +0 -69
  113. package/dist/chunk-928tzaa8.js +0 -107
  114. package/dist/chunk-949pjzj9.js +0 -266
  115. package/dist/chunk-9aycd4z9.js +0 -490
  116. package/dist/chunk-9bzqvsz5.js +0 -211
  117. package/dist/chunk-9q3xfy27.js +0 -460
  118. package/dist/chunk-9vzg1360.js +0 -153
  119. package/dist/chunk-9wbh8n1y.js +0 -63
  120. package/dist/chunk-9x5zgy22.js +0 -12
  121. package/dist/chunk-9zdj4ypz.js +0 -206
  122. package/dist/chunk-a0bvcgyd.js +0 -127
  123. package/dist/chunk-a4m3yr2q.js +0 -117
  124. package/dist/chunk-a8jd4gee.js +0 -227
  125. package/dist/chunk-ase86y73.js +0 -15
  126. package/dist/chunk-atfzpm6r.js +0 -325
  127. package/dist/chunk-awqsddp2.js +0 -338
  128. package/dist/chunk-awrgzpk6.js +0 -29
  129. package/dist/chunk-b0kf00ff.js +0 -637
  130. package/dist/chunk-b1kcd3ss.js +0 -27
  131. package/dist/chunk-b4hy21c4.js +0 -140
  132. package/dist/chunk-b9mkm8mg.js +0 -111
  133. package/dist/chunk-bdjx14rd.js +0 -594
  134. package/dist/chunk-bfb41q9h.js +0 -295
  135. package/dist/chunk-bg4x9ex0.js +0 -21
  136. package/dist/chunk-bh5zqvyc.js +0 -36
  137. package/dist/chunk-bn0zv2y2.js +0 -1154
  138. package/dist/chunk-bn7t681c.js +0 -2669
  139. package/dist/chunk-br4wgffc.js +0 -393
  140. package/dist/chunk-brjd9zmk.js +0 -42
  141. package/dist/chunk-byfawrfx.js +0 -121
  142. package/dist/chunk-c6sjhj89.js +0 -1284
  143. package/dist/chunk-c7jwbe76.js +0 -29030
  144. package/dist/chunk-cdef9v7b.js +0 -27
  145. package/dist/chunk-cdz5yb0r.js +0 -57
  146. package/dist/chunk-cevq1787.js +0 -2718
  147. package/dist/chunk-cgfdkzhb.js +0 -12
  148. package/dist/chunk-cgqw4x5z.js +0 -155
  149. package/dist/chunk-cmmmc8e0.js +0 -212
  150. package/dist/chunk-cnsj3vq2.js +0 -35
  151. package/dist/chunk-cxrktb5g.js +0 -51
  152. package/dist/chunk-cyhrb0bk.js +0 -251
  153. package/dist/chunk-d23rmn8r.js +0 -62
  154. package/dist/chunk-d4mdda98.js +0 -94
  155. package/dist/chunk-dcwp94cj.js +0 -152
  156. package/dist/chunk-ddsjkqs4.js +0 -39
  157. package/dist/chunk-ddv56j39.js +0 -148
  158. package/dist/chunk-dfq6pbq7.js +0 -5822
  159. package/dist/chunk-dfzkwynj.js +0 -5368
  160. package/dist/chunk-dkgkd8b7.js +0 -516
  161. package/dist/chunk-dpnmf0pq.js +0 -312
  162. package/dist/chunk-dygx7vcc.js +0 -226
  163. package/dist/chunk-e0abab5b.js +0 -445
  164. package/dist/chunk-e5qhvhjy.js +0 -168
  165. package/dist/chunk-e60y6r1n.js +0 -20
  166. package/dist/chunk-e68kgvcq.js +0 -79
  167. package/dist/chunk-e9w9zc0g.js +0 -392
  168. package/dist/chunk-ecj9w6tm.js +0 -558
  169. package/dist/chunk-ehtwnxpg.js +0 -1591
  170. package/dist/chunk-eqp1rfft.js +0 -17
  171. package/dist/chunk-etdt1xz3.js +0 -19
  172. package/dist/chunk-ewadzrm8.js +0 -103
  173. package/dist/chunk-f03s83vj.js +0 -91
  174. package/dist/chunk-f3kk0p3s.js +0 -150
  175. package/dist/chunk-f3pjerx4.js +0 -4265
  176. package/dist/chunk-f6h5weh6.js +0 -61
  177. package/dist/chunk-fajg8x36.js +0 -8158
  178. package/dist/chunk-fbv4apne.js +0 -51
  179. package/dist/chunk-fcynwjpm.js +0 -1072
  180. package/dist/chunk-fdvaf6nn.js +0 -20
  181. package/dist/chunk-feyzykye.js +0 -10
  182. package/dist/chunk-ff85rwvc.js +0 -180
  183. package/dist/chunk-fqak69ft.js +0 -458
  184. package/dist/chunk-fxdkbabd.js +0 -195
  185. package/dist/chunk-fyc5fepv.js +0 -10
  186. package/dist/chunk-g78c6ztj.js +0 -89
  187. package/dist/chunk-g8ee7yza.js +0 -105
  188. package/dist/chunk-g9f19ttm.js +0 -15
  189. package/dist/chunk-gcktsbxb.js +0 -77
  190. package/dist/chunk-gdwdqewd.js +0 -19
  191. package/dist/chunk-gg55fns0.js +0 -6440
  192. package/dist/chunk-gnpt1t6q.js +0 -209364
  193. package/dist/chunk-gsbw2j2b.js +0 -276
  194. package/dist/chunk-gybt680f.js +0 -9114
  195. package/dist/chunk-gz1e8y1w.js +0 -33
  196. package/dist/chunk-gz7vn2gg.js +0 -114
  197. package/dist/chunk-h0d5eat0.js +0 -101
  198. package/dist/chunk-h27tjbp3.js +0 -33118
  199. package/dist/chunk-h2yy8k4c.js +0 -58
  200. package/dist/chunk-h5acpdqt.js +0 -103
  201. package/dist/chunk-h63r8vps.js +0 -2840
  202. package/dist/chunk-h64x5b04.js +0 -860
  203. package/dist/chunk-h92snc84.js +0 -420
  204. package/dist/chunk-h9n54swm.js +0 -27
  205. package/dist/chunk-hafcrnpc.js +0 -145
  206. package/dist/chunk-hakdhagh.js +0 -16606
  207. package/dist/chunk-hk4phsaw.js +0 -388
  208. package/dist/chunk-hph1bmqw.js +0 -65
  209. package/dist/chunk-hvnztnp3.js +0 -71
  210. package/dist/chunk-hwfknpxv.js +0 -39
  211. package/dist/chunk-j2xxd002.js +0 -1052
  212. package/dist/chunk-j3qbygme.js +0 -105
  213. package/dist/chunk-j5bth84e.js +0 -97
  214. package/dist/chunk-j64ga6ta.js +0 -8035
  215. package/dist/chunk-jbwgyskk.js +0 -385
  216. package/dist/chunk-jd32zbps.js +0 -15
  217. package/dist/chunk-jdhkh2bb.js +0 -618
  218. package/dist/chunk-jeqcwgt7.js +0 -177
  219. package/dist/chunk-jf75p9ap.js +0 -445
  220. package/dist/chunk-jgvk0za1.js +0 -260
  221. package/dist/chunk-jhpaevah.js +0 -565
  222. package/dist/chunk-jmjwrbwd.js +0 -635
  223. package/dist/chunk-jpdbfwvq.js +0 -100
  224. package/dist/chunk-jps4m6sz.js +0 -183
  225. package/dist/chunk-jwf0s51s.js +0 -867
  226. package/dist/chunk-jxge4dgh.js +0 -83
  227. package/dist/chunk-jz71gv95.js +0 -1161
  228. package/dist/chunk-jzthz1bx.js +0 -15
  229. package/dist/chunk-jzvd2ycp.js +0 -120
  230. package/dist/chunk-k0p9w03v.js +0 -4957
  231. package/dist/chunk-k4dcreh0.js +0 -442
  232. package/dist/chunk-k7akhwkn.js +0 -151
  233. package/dist/chunk-k8vp0atq.js +0 -2331
  234. package/dist/chunk-kgd7gfvk.js +0 -407
  235. package/dist/chunk-km5ycg1j.js +0 -87
  236. package/dist/chunk-kvyrxzj8.js +0 -26
  237. package/dist/chunk-kwekc97v.js +0 -18
  238. package/dist/chunk-ky1z78ve.js +0 -119
  239. package/dist/chunk-mcws22k3.js +0 -42
  240. package/dist/chunk-mjazvyd8.js +0 -528
  241. package/dist/chunk-mswx2nma.js +0 -103
  242. package/dist/chunk-mz6a0phh.js +0 -2962
  243. package/dist/chunk-n2tg12hg.js +0 -374
  244. package/dist/chunk-n3fv4ya7.js +0 -146
  245. package/dist/chunk-n4eabmqd.js +0 -93
  246. package/dist/chunk-n4tx7baq.js +0 -193
  247. package/dist/chunk-n6g4jbeh.js +0 -289
  248. package/dist/chunk-n6wzfxf1.js +0 -100
  249. package/dist/chunk-ndcmqfkv.js +0 -244
  250. package/dist/chunk-netzwgv1.js +0 -154
  251. package/dist/chunk-nhcg04jt.js +0 -120
  252. package/dist/chunk-nhsm3ntd.js +0 -439
  253. package/dist/chunk-njev89d1.js +0 -2335
  254. package/dist/chunk-nmgj86tt.js +0 -24
  255. package/dist/chunk-ns7x6xam.js +0 -22820
  256. package/dist/chunk-p7vkh4wx.js +0 -15
  257. package/dist/chunk-p8na2wwp.js +0 -14
  258. package/dist/chunk-p97fd5af.js +0 -684
  259. package/dist/chunk-pe3rkfp2.js +0 -74
  260. package/dist/chunk-pgtnj1mt.js +0 -705
  261. package/dist/chunk-phmnkw9y.js +0 -283
  262. package/dist/chunk-pnds7g1q.js +0 -130
  263. package/dist/chunk-ppwjyveh.js +0 -8
  264. package/dist/chunk-pqqxdk5f.js +0 -543
  265. package/dist/chunk-ps49ymvj.js +0 -43
  266. package/dist/chunk-pwwa7s62.js +0 -11
  267. package/dist/chunk-q3hfrat2.js +0 -313
  268. package/dist/chunk-qajrkk97.js +0 -298
  269. package/dist/chunk-qatfdxvd.js +0 -34
  270. package/dist/chunk-qb5qcctj.js +0 -206
  271. package/dist/chunk-qb6k2afy.js +0 -153
  272. package/dist/chunk-qgk93a75.js +0 -85
  273. package/dist/chunk-qkczt8cr.js +0 -24
  274. package/dist/chunk-qn1be1vf.js +0 -267
  275. package/dist/chunk-qnfx3qtx.js +0 -617
  276. package/dist/chunk-qnwne2m4.js +0 -87
  277. package/dist/chunk-qp2qdcda.js +0 -100
  278. package/dist/chunk-qpp3wwh5.js +0 -697
  279. package/dist/chunk-r0bx1gc7.js +0 -174
  280. package/dist/chunk-radnwk8x.js +0 -107
  281. package/dist/chunk-rkv5jq0y.js +0 -71
  282. package/dist/chunk-rmbbmd3s.js +0 -68
  283. package/dist/chunk-rmgbs5an.js +0 -640
  284. package/dist/chunk-rn0v1hk8.js +0 -34
  285. package/dist/chunk-rnxctq9p.js +0 -1646
  286. package/dist/chunk-rtd39n81.js +0 -95
  287. package/dist/chunk-s8gy4ky9.js +0 -122
  288. package/dist/chunk-s8kj6ajy.js +0 -32
  289. package/dist/chunk-sd36yzx8.js +0 -954
  290. package/dist/chunk-sdenh194.js +0 -121
  291. package/dist/chunk-sdtqp75c.js +0 -55
  292. package/dist/chunk-sedbc8ep.js +0 -212
  293. package/dist/chunk-sfrb15b2.js +0 -321
  294. package/dist/chunk-sgpmpn90.js +0 -35
  295. package/dist/chunk-sh02d2qn.js +0 -38
  296. package/dist/chunk-shd4yhsf.js +0 -32
  297. package/dist/chunk-shkycj1q.js +0 -178
  298. package/dist/chunk-sk7h93je.js +0 -153
  299. package/dist/chunk-sm8g6fsm.js +0 -122
  300. package/dist/chunk-snrjy66h.js +0 -671
  301. package/dist/chunk-sq4a0yjh.js +0 -116
  302. package/dist/chunk-sr3t4thh.js +0 -895
  303. package/dist/chunk-srj6qnf6.js +0 -107
  304. package/dist/chunk-sz62n77p.js +0 -155
  305. package/dist/chunk-szj5wvdy.js +0 -28
  306. package/dist/chunk-t29a6zb5.js +0 -45
  307. package/dist/chunk-t2ecddwj.js +0 -731
  308. package/dist/chunk-t33hmmmm.js +0 -113
  309. package/dist/chunk-t4khqff1.js +0 -16
  310. package/dist/chunk-t9p85zff.js +0 -24
  311. package/dist/chunk-ta3jyvxs.js +0 -984
  312. package/dist/chunk-tkx5eec8.js +0 -54
  313. package/dist/chunk-v1kzp02e.js +0 -785
  314. package/dist/chunk-v4t6dyyh.js +0 -9076
  315. package/dist/chunk-v78fj8by.js +0 -145
  316. package/dist/chunk-v8kjswxt.js +0 -61
  317. package/dist/chunk-v9smspw2.js +0 -4301
  318. package/dist/chunk-vf612n57.js +0 -472
  319. package/dist/chunk-vkhrrvfq.js +0 -44
  320. package/dist/chunk-vt5wm07k.js +0 -74
  321. package/dist/chunk-vvvrv61g.js +0 -875
  322. package/dist/chunk-vyjeh50y.js +0 -2149
  323. package/dist/chunk-w0kxcv73.js +0 -97
  324. package/dist/chunk-w6m6trzq.js +0 -58
  325. package/dist/chunk-wa8yn2p0.js +0 -2007
  326. package/dist/chunk-wb18cecv.js +0 -995
  327. package/dist/chunk-wgk9sxk7.js +0 -329
  328. package/dist/chunk-wh0ev1bw.js +0 -111
  329. package/dist/chunk-wka1647p.js +0 -98
  330. package/dist/chunk-wnwfwyj4.js +0 -90
  331. package/dist/chunk-wpdchyy2.js +0 -97
  332. package/dist/chunk-x3g44n7k.js +0 -114
  333. package/dist/chunk-x47h283a.js +0 -56
  334. package/dist/chunk-x6r4v44b.js +0 -8
  335. package/dist/chunk-x7fdwq3d.js +0 -33
  336. package/dist/chunk-x8d2ehd7.js +0 -19
  337. package/dist/chunk-xbeg2hej.js +0 -257
  338. package/dist/chunk-xeb6075z.js +0 -3435
  339. package/dist/chunk-xhfmdq1y.js +0 -147
  340. package/dist/chunk-xhscn33a.js +0 -138
  341. package/dist/chunk-xv3era3s.js +0 -8
  342. package/dist/chunk-xz5gbhc3.js +0 -93
  343. package/dist/chunk-y1784krc.js +0 -19
  344. package/dist/chunk-y1vyezct.js +0 -123
  345. package/dist/chunk-y45ecntg.js +0 -942
  346. package/dist/chunk-y4ca9kqz.js +0 -3830
  347. package/dist/chunk-y9bhjjdz.js +0 -145
  348. package/dist/chunk-yb3bxv3w.js +0 -30
  349. package/dist/chunk-ye2q9gqj.js +0 -332
  350. package/dist/chunk-yfg3adfq.js +0 -88
  351. package/dist/chunk-yst0wmgw.js +0 -269
  352. package/dist/chunk-ywe9dbnz.js +0 -460
  353. package/dist/chunk-yyex5gsf.js +0 -269
  354. package/dist/chunk-yz2kzqk5.js +0 -439
  355. package/dist/chunk-z263ehpg.js +0 -131
  356. package/dist/chunk-z2dp53wn.js +0 -17
  357. package/dist/chunk-zaq348h2.js +0 -281
  358. package/dist/chunk-zr0qx9q0.js +0 -642
  359. package/dist/chunk-zxh62ved.js +0 -31
  360. package/dist/chunk-zy5vn8sd.js +0 -329
  361. package/dist/chunk-zzm33q8x.js +0 -8
  362. package/dist/cli.js +0 -91
@@ -1,995 +0,0 @@
1
- // @bun
2
- import {
3
- init_array,
4
- init_lockfile,
5
- lock
6
- } from "./chunk-6nsd9606.js";
7
- import {
8
- init_lazySchema,
9
- lazySchema
10
- } from "./chunk-64c1avct.js";
11
- import {
12
- init_v4
13
- } from "./chunk-4pbx3g7s.js";
14
- import {
15
- exports_external
16
- } from "./chunk-26wtxbdc.js";
17
- import {
18
- TEAM_LEAD_NAME,
19
- init_constants
20
- } from "./chunk-4jm600zv.js";
21
- import {
22
- gitExe,
23
- init_git
24
- } from "./chunk-3vy1jt9p.js";
25
- import {
26
- execFileNoThrowWithCwd,
27
- init_execFileNoThrow
28
- } from "./chunk-64r16v22.js";
29
- import {
30
- errorMessage,
31
- getErrnoCode,
32
- init_debug,
33
- init_errors,
34
- init_log,
35
- init_slowOperations,
36
- jsonParse,
37
- jsonStringify,
38
- logError,
39
- logForDebugging
40
- } from "./chunk-gg55fns0.js";
41
- import {
42
- getClaudeConfigHomeDir,
43
- getTeamsDir,
44
- init_envUtils,
45
- isEnvTruthy
46
- } from "./chunk-5n1jc02d.js";
47
- import {
48
- createSignal,
49
- getIsNonInteractiveSession,
50
- getSessionCreatedTeams,
51
- getSessionId,
52
- init_signal,
53
- init_state
54
- } from "./chunk-k8vp0atq.js";
55
- import {
56
- __esm,
57
- __export,
58
- __require
59
- } from "./chunk-qp2qdcda.js";
60
-
61
- // src/utils/teammateContext.ts
62
- import { AsyncLocalStorage } from "async_hooks";
63
- function getTeammateContext() {
64
- return teammateContextStorage.getStore();
65
- }
66
- function runWithTeammateContext(context, fn) {
67
- return teammateContextStorage.run(context, fn);
68
- }
69
- function isInProcessTeammate() {
70
- return teammateContextStorage.getStore() !== undefined;
71
- }
72
- function createTeammateContext(config) {
73
- return {
74
- ...config,
75
- isInProcess: true
76
- };
77
- }
78
- var teammateContextStorage;
79
- var init_teammateContext = __esm(() => {
80
- teammateContextStorage = new AsyncLocalStorage;
81
- });
82
-
83
- // src/utils/teammate.ts
84
- var exports_teammate = {};
85
- __export(exports_teammate, {
86
- waitForTeammatesToBecomeIdle: () => waitForTeammatesToBecomeIdle,
87
- setDynamicTeamContext: () => setDynamicTeamContext,
88
- runWithTeammateContext: () => runWithTeammateContext,
89
- isTeammate: () => isTeammate,
90
- isTeamLead: () => isTeamLead,
91
- isPlanModeRequired: () => isPlanModeRequired,
92
- isInProcessTeammate: () => isInProcessTeammate,
93
- hasWorkingInProcessTeammates: () => hasWorkingInProcessTeammates,
94
- hasActiveInProcessTeammates: () => hasActiveInProcessTeammates,
95
- getTeammateContext: () => getTeammateContext,
96
- getTeammateColor: () => getTeammateColor,
97
- getTeamName: () => getTeamName,
98
- getParentSessionId: () => getParentSessionId,
99
- getDynamicTeamContext: () => getDynamicTeamContext,
100
- getAgentName: () => getAgentName,
101
- getAgentId: () => getAgentId,
102
- createTeammateContext: () => createTeammateContext,
103
- clearDynamicTeamContext: () => clearDynamicTeamContext
104
- });
105
- function getParentSessionId() {
106
- const inProcessCtx = getTeammateContext();
107
- if (inProcessCtx)
108
- return inProcessCtx.parentSessionId;
109
- return dynamicTeamContext?.parentSessionId;
110
- }
111
- function setDynamicTeamContext(context) {
112
- dynamicTeamContext = context;
113
- }
114
- function clearDynamicTeamContext() {
115
- dynamicTeamContext = null;
116
- }
117
- function getDynamicTeamContext() {
118
- return dynamicTeamContext;
119
- }
120
- function getAgentId() {
121
- const inProcessCtx = getTeammateContext();
122
- if (inProcessCtx)
123
- return inProcessCtx.agentId;
124
- return dynamicTeamContext?.agentId;
125
- }
126
- function getAgentName() {
127
- const inProcessCtx = getTeammateContext();
128
- if (inProcessCtx)
129
- return inProcessCtx.agentName;
130
- return dynamicTeamContext?.agentName;
131
- }
132
- function getTeamName(teamContext) {
133
- const inProcessCtx = getTeammateContext();
134
- if (inProcessCtx)
135
- return inProcessCtx.teamName;
136
- if (dynamicTeamContext?.teamName)
137
- return dynamicTeamContext.teamName;
138
- return teamContext?.teamName;
139
- }
140
- function isTeammate() {
141
- const inProcessCtx = getTeammateContext();
142
- if (inProcessCtx)
143
- return true;
144
- return !!(dynamicTeamContext?.agentId && dynamicTeamContext?.teamName);
145
- }
146
- function getTeammateColor() {
147
- const inProcessCtx = getTeammateContext();
148
- if (inProcessCtx)
149
- return inProcessCtx.color;
150
- return dynamicTeamContext?.color;
151
- }
152
- function isPlanModeRequired() {
153
- const inProcessCtx = getTeammateContext();
154
- if (inProcessCtx)
155
- return inProcessCtx.planModeRequired;
156
- if (dynamicTeamContext !== null) {
157
- return dynamicTeamContext.planModeRequired;
158
- }
159
- return isEnvTruthy(process.env.CLAUDE_CODE_PLAN_MODE_REQUIRED);
160
- }
161
- function isTeamLead(teamContext) {
162
- if (!teamContext?.leadAgentId) {
163
- return false;
164
- }
165
- const myAgentId = getAgentId();
166
- const leadAgentId = teamContext.leadAgentId;
167
- if (myAgentId === leadAgentId) {
168
- return true;
169
- }
170
- if (!myAgentId) {
171
- return true;
172
- }
173
- return false;
174
- }
175
- function hasActiveInProcessTeammates(appState) {
176
- for (const task of Object.values(appState.tasks)) {
177
- if (task.type === "in_process_teammate" && task.status === "running") {
178
- return true;
179
- }
180
- }
181
- return false;
182
- }
183
- function hasWorkingInProcessTeammates(appState) {
184
- for (const task of Object.values(appState.tasks)) {
185
- if (task.type === "in_process_teammate" && task.status === "running" && !task.isIdle) {
186
- return true;
187
- }
188
- }
189
- return false;
190
- }
191
- function waitForTeammatesToBecomeIdle(setAppState, appState) {
192
- const workingTaskIds = [];
193
- for (const [taskId, task] of Object.entries(appState.tasks)) {
194
- if (task.type === "in_process_teammate" && task.status === "running" && !task.isIdle) {
195
- workingTaskIds.push(taskId);
196
- }
197
- }
198
- if (workingTaskIds.length === 0) {
199
- return Promise.resolve();
200
- }
201
- return new Promise((resolve) => {
202
- let remaining = workingTaskIds.length;
203
- const onIdle = () => {
204
- remaining--;
205
- if (remaining === 0) {
206
- resolve();
207
- }
208
- };
209
- setAppState((prev) => {
210
- const newTasks = { ...prev.tasks };
211
- for (const taskId of workingTaskIds) {
212
- const task = newTasks[taskId];
213
- if (task && task.type === "in_process_teammate") {
214
- if (task.isIdle) {
215
- onIdle();
216
- } else {
217
- newTasks[taskId] = {
218
- ...task,
219
- onIdleCallbacks: [...task.onIdleCallbacks ?? [], onIdle]
220
- };
221
- }
222
- }
223
- }
224
- return { ...prev, tasks: newTasks };
225
- });
226
- });
227
- }
228
- var dynamicTeamContext = null;
229
- var init_teammate = __esm(() => {
230
- init_teammateContext();
231
- init_envUtils();
232
- init_teammateContext();
233
- });
234
-
235
- // src/utils/tasks.ts
236
- import { mkdir, readdir, readFile, unlink, writeFile } from "fs/promises";
237
- import { join } from "path";
238
- function setLeaderTeamName(teamName) {
239
- if (leaderTeamName === teamName)
240
- return;
241
- leaderTeamName = teamName;
242
- notifyTasksUpdated();
243
- }
244
- function clearLeaderTeamName() {
245
- if (leaderTeamName === undefined)
246
- return;
247
- leaderTeamName = undefined;
248
- notifyTasksUpdated();
249
- }
250
- function notifyTasksUpdated() {
251
- try {
252
- tasksUpdated.emit();
253
- } catch {}
254
- }
255
- function getHighWaterMarkPath(taskListId) {
256
- return join(getTasksDir(taskListId), HIGH_WATER_MARK_FILE);
257
- }
258
- async function readHighWaterMark(taskListId) {
259
- const path = getHighWaterMarkPath(taskListId);
260
- try {
261
- const content = (await readFile(path, "utf-8")).trim();
262
- const value = parseInt(content, 10);
263
- return isNaN(value) ? 0 : value;
264
- } catch {
265
- return 0;
266
- }
267
- }
268
- async function writeHighWaterMark(taskListId, value) {
269
- const path = getHighWaterMarkPath(taskListId);
270
- await writeFile(path, String(value));
271
- }
272
- function isTodoV2Enabled() {
273
- if (isEnvTruthy(process.env.CLAUDE_CODE_ENABLE_TASKS)) {
274
- return true;
275
- }
276
- return !getIsNonInteractiveSession();
277
- }
278
- async function resetTaskList(taskListId) {
279
- const dir = getTasksDir(taskListId);
280
- const lockPath = await ensureTaskListLockFile(taskListId);
281
- let release;
282
- try {
283
- release = await lock(lockPath, LOCK_OPTIONS);
284
- const currentHighest = await findHighestTaskIdFromFiles(taskListId);
285
- if (currentHighest > 0) {
286
- const existingMark = await readHighWaterMark(taskListId);
287
- if (currentHighest > existingMark) {
288
- await writeHighWaterMark(taskListId, currentHighest);
289
- }
290
- }
291
- let files;
292
- try {
293
- files = await readdir(dir);
294
- } catch {
295
- files = [];
296
- }
297
- for (const file of files) {
298
- if (file.endsWith(".json") && !file.startsWith(".")) {
299
- const filePath = join(dir, file);
300
- try {
301
- await unlink(filePath);
302
- } catch {}
303
- }
304
- }
305
- notifyTasksUpdated();
306
- } finally {
307
- if (release) {
308
- await release();
309
- }
310
- }
311
- }
312
- function getTaskListId() {
313
- if (process.env.CLAUDE_CODE_TASK_LIST_ID) {
314
- return process.env.CLAUDE_CODE_TASK_LIST_ID;
315
- }
316
- const teammateCtx = getTeammateContext();
317
- if (teammateCtx) {
318
- return teammateCtx.teamName;
319
- }
320
- return getTeamName() || leaderTeamName || getSessionId();
321
- }
322
- function sanitizePathComponent(input) {
323
- return input.replace(/[^a-zA-Z0-9_-]/g, "-");
324
- }
325
- function getTasksDir(taskListId) {
326
- return join(getClaudeConfigHomeDir(), "tasks", sanitizePathComponent(taskListId));
327
- }
328
- function getTaskPath(taskListId, taskId) {
329
- return join(getTasksDir(taskListId), `${sanitizePathComponent(taskId)}.json`);
330
- }
331
- async function ensureTasksDir(taskListId) {
332
- const dir = getTasksDir(taskListId);
333
- try {
334
- await mkdir(dir, { recursive: true });
335
- } catch {}
336
- }
337
- async function findHighestTaskIdFromFiles(taskListId) {
338
- const dir = getTasksDir(taskListId);
339
- let files;
340
- try {
341
- files = await readdir(dir);
342
- } catch {
343
- return 0;
344
- }
345
- let highest = 0;
346
- for (const file of files) {
347
- if (!file.endsWith(".json")) {
348
- continue;
349
- }
350
- const taskId = parseInt(file.replace(".json", ""), 10);
351
- if (!isNaN(taskId) && taskId > highest) {
352
- highest = taskId;
353
- }
354
- }
355
- return highest;
356
- }
357
- async function findHighestTaskId(taskListId) {
358
- const [fromFiles, fromMark] = await Promise.all([
359
- findHighestTaskIdFromFiles(taskListId),
360
- readHighWaterMark(taskListId)
361
- ]);
362
- return Math.max(fromFiles, fromMark);
363
- }
364
- async function createTask(taskListId, taskData) {
365
- const lockPath = await ensureTaskListLockFile(taskListId);
366
- let release;
367
- try {
368
- release = await lock(lockPath, LOCK_OPTIONS);
369
- const highestId = await findHighestTaskId(taskListId);
370
- const id = String(highestId + 1);
371
- const task = { id, ...taskData };
372
- const path = getTaskPath(taskListId, id);
373
- await writeFile(path, jsonStringify(task, null, 2));
374
- notifyTasksUpdated();
375
- return id;
376
- } finally {
377
- if (release) {
378
- await release();
379
- }
380
- }
381
- }
382
- async function getTask(taskListId, taskId) {
383
- const path = getTaskPath(taskListId, taskId);
384
- try {
385
- const content = await readFile(path, "utf-8");
386
- const data = jsonParse(content);
387
- if (process.env.USER_TYPE === "ant") {
388
- if (data.status === "open")
389
- data.status = "pending";
390
- else if (data.status === "resolved")
391
- data.status = "completed";
392
- else if (data.status && ["planning", "implementing", "reviewing", "verifying"].includes(data.status)) {
393
- data.status = "in_progress";
394
- }
395
- }
396
- const parsed = TaskSchema().safeParse(data);
397
- if (!parsed.success) {
398
- logForDebugging(`[Tasks] Task ${taskId} failed schema validation: ${parsed.error.message}`);
399
- return null;
400
- }
401
- return parsed.data;
402
- } catch (e) {
403
- const code = getErrnoCode(e);
404
- if (code === "ENOENT") {
405
- return null;
406
- }
407
- logForDebugging(`[Tasks] Failed to read task ${taskId}: ${errorMessage(e)}`);
408
- logError(e);
409
- return null;
410
- }
411
- }
412
- async function updateTaskUnsafe(taskListId, taskId, updates) {
413
- const existing = await getTask(taskListId, taskId);
414
- if (!existing) {
415
- return null;
416
- }
417
- const updated = { ...existing, ...updates, id: taskId };
418
- const path = getTaskPath(taskListId, taskId);
419
- await writeFile(path, jsonStringify(updated, null, 2));
420
- notifyTasksUpdated();
421
- return updated;
422
- }
423
- async function updateTask(taskListId, taskId, updates) {
424
- const path = getTaskPath(taskListId, taskId);
425
- const taskBeforeLock = await getTask(taskListId, taskId);
426
- if (!taskBeforeLock) {
427
- return null;
428
- }
429
- let release;
430
- try {
431
- release = await lock(path, LOCK_OPTIONS);
432
- return await updateTaskUnsafe(taskListId, taskId, updates);
433
- } finally {
434
- await release?.();
435
- }
436
- }
437
- async function deleteTask(taskListId, taskId) {
438
- const path = getTaskPath(taskListId, taskId);
439
- try {
440
- const numericId = parseInt(taskId, 10);
441
- if (!isNaN(numericId)) {
442
- const currentMark = await readHighWaterMark(taskListId);
443
- if (numericId > currentMark) {
444
- await writeHighWaterMark(taskListId, numericId);
445
- }
446
- }
447
- try {
448
- await unlink(path);
449
- } catch (e) {
450
- const code = getErrnoCode(e);
451
- if (code === "ENOENT") {
452
- return false;
453
- }
454
- throw e;
455
- }
456
- const allTasks = await listTasks(taskListId);
457
- for (const task of allTasks) {
458
- const newBlocks = task.blocks.filter((id) => id !== taskId);
459
- const newBlockedBy = task.blockedBy.filter((id) => id !== taskId);
460
- if (newBlocks.length !== task.blocks.length || newBlockedBy.length !== task.blockedBy.length) {
461
- await updateTask(taskListId, task.id, {
462
- blocks: newBlocks,
463
- blockedBy: newBlockedBy
464
- });
465
- }
466
- }
467
- notifyTasksUpdated();
468
- return true;
469
- } catch {
470
- return false;
471
- }
472
- }
473
- async function listTasks(taskListId) {
474
- const dir = getTasksDir(taskListId);
475
- let files;
476
- try {
477
- files = await readdir(dir);
478
- } catch {
479
- return [];
480
- }
481
- const taskIds = files.filter((f) => f.endsWith(".json")).map((f) => f.replace(".json", ""));
482
- const results = await Promise.all(taskIds.map((id) => getTask(taskListId, id)));
483
- return results.filter((t) => t !== null);
484
- }
485
- async function blockTask(taskListId, fromTaskId, toTaskId) {
486
- const [fromTask, toTask] = await Promise.all([
487
- getTask(taskListId, fromTaskId),
488
- getTask(taskListId, toTaskId)
489
- ]);
490
- if (!fromTask || !toTask) {
491
- return false;
492
- }
493
- if (!fromTask.blocks.includes(toTaskId)) {
494
- await updateTask(taskListId, fromTaskId, {
495
- blocks: [...fromTask.blocks, toTaskId]
496
- });
497
- }
498
- if (!toTask.blockedBy.includes(fromTaskId)) {
499
- await updateTask(taskListId, toTaskId, {
500
- blockedBy: [...toTask.blockedBy, fromTaskId]
501
- });
502
- }
503
- return true;
504
- }
505
- function getTaskListLockPath(taskListId) {
506
- return join(getTasksDir(taskListId), ".lock");
507
- }
508
- async function ensureTaskListLockFile(taskListId) {
509
- await ensureTasksDir(taskListId);
510
- const lockPath = getTaskListLockPath(taskListId);
511
- try {
512
- await writeFile(lockPath, "", { flag: "wx" });
513
- } catch {}
514
- return lockPath;
515
- }
516
- async function claimTask(taskListId, taskId, claimantAgentId, options = {}) {
517
- const taskPath = getTaskPath(taskListId, taskId);
518
- const taskBeforeLock = await getTask(taskListId, taskId);
519
- if (!taskBeforeLock) {
520
- return { success: false, reason: "task_not_found" };
521
- }
522
- if (options.checkAgentBusy) {
523
- return claimTaskWithBusyCheck(taskListId, taskId, claimantAgentId);
524
- }
525
- let release;
526
- try {
527
- release = await lock(taskPath, LOCK_OPTIONS);
528
- const task = await getTask(taskListId, taskId);
529
- if (!task) {
530
- return { success: false, reason: "task_not_found" };
531
- }
532
- if (task.owner && task.owner !== claimantAgentId) {
533
- return { success: false, reason: "already_claimed", task };
534
- }
535
- if (task.status === "completed") {
536
- return { success: false, reason: "already_resolved", task };
537
- }
538
- const allTasks = await listTasks(taskListId);
539
- const unresolvedTaskIds = new Set(allTasks.filter((t) => t.status !== "completed").map((t) => t.id));
540
- const blockedByTasks = task.blockedBy.filter((id) => unresolvedTaskIds.has(id));
541
- if (blockedByTasks.length > 0) {
542
- return { success: false, reason: "blocked", task, blockedByTasks };
543
- }
544
- const updated = await updateTaskUnsafe(taskListId, taskId, {
545
- owner: claimantAgentId
546
- });
547
- return { success: true, task: updated };
548
- } catch (error) {
549
- logForDebugging(`[Tasks] Failed to claim task ${taskId}: ${errorMessage(error)}`);
550
- logError(error);
551
- return { success: false, reason: "task_not_found" };
552
- } finally {
553
- if (release) {
554
- await release();
555
- }
556
- }
557
- }
558
- async function claimTaskWithBusyCheck(taskListId, taskId, claimantAgentId) {
559
- const lockPath = await ensureTaskListLockFile(taskListId);
560
- let release;
561
- try {
562
- release = await lock(lockPath, LOCK_OPTIONS);
563
- const allTasks = await listTasks(taskListId);
564
- const task = allTasks.find((t) => t.id === taskId);
565
- if (!task) {
566
- return { success: false, reason: "task_not_found" };
567
- }
568
- if (task.owner && task.owner !== claimantAgentId) {
569
- return { success: false, reason: "already_claimed", task };
570
- }
571
- if (task.status === "completed") {
572
- return { success: false, reason: "already_resolved", task };
573
- }
574
- const unresolvedTaskIds = new Set(allTasks.filter((t) => t.status !== "completed").map((t) => t.id));
575
- const blockedByTasks = task.blockedBy.filter((id) => unresolvedTaskIds.has(id));
576
- if (blockedByTasks.length > 0) {
577
- return { success: false, reason: "blocked", task, blockedByTasks };
578
- }
579
- const agentOpenTasks = allTasks.filter((t) => t.status !== "completed" && t.owner === claimantAgentId && t.id !== taskId);
580
- if (agentOpenTasks.length > 0) {
581
- return {
582
- success: false,
583
- reason: "agent_busy",
584
- task,
585
- busyWithTasks: agentOpenTasks.map((t) => t.id)
586
- };
587
- }
588
- const updated = await updateTask(taskListId, taskId, {
589
- owner: claimantAgentId
590
- });
591
- return { success: true, task: updated };
592
- } catch (error) {
593
- logForDebugging(`[Tasks] Failed to claim task ${taskId} with busy check: ${errorMessage(error)}`);
594
- logError(error);
595
- return { success: false, reason: "task_not_found" };
596
- } finally {
597
- if (release) {
598
- await release();
599
- }
600
- }
601
- }
602
- async function unassignTeammateTasks(teamName, teammateId, teammateName, reason) {
603
- const tasks = await listTasks(teamName);
604
- const unresolvedAssignedTasks = tasks.filter((t) => t.status !== "completed" && (t.owner === teammateId || t.owner === teammateName));
605
- for (const task of unresolvedAssignedTasks) {
606
- await updateTask(teamName, task.id, { owner: undefined, status: "pending" });
607
- }
608
- if (unresolvedAssignedTasks.length > 0) {
609
- logForDebugging(`[Tasks] Unassigned ${unresolvedAssignedTasks.length} task(s) from ${teammateName}`);
610
- }
611
- const actionVerb = reason === "terminated" ? "was terminated" : "has shut down";
612
- let notificationMessage = `${teammateName} ${actionVerb}.`;
613
- if (unresolvedAssignedTasks.length > 0) {
614
- const taskList = unresolvedAssignedTasks.map((t) => `#${t.id} "${t.subject}"`).join(", ");
615
- notificationMessage += ` ${unresolvedAssignedTasks.length} task(s) were unassigned: ${taskList}. Use TaskList to check availability and TaskUpdate with owner to reassign them to idle teammates.`;
616
- }
617
- return {
618
- unassignedTasks: unresolvedAssignedTasks.map((t) => ({
619
- id: t.id,
620
- subject: t.subject
621
- })),
622
- notificationMessage
623
- };
624
- }
625
- var tasksUpdated, leaderTeamName, onTasksUpdated, TASK_STATUSES, TaskStatusSchema, TaskSchema, HIGH_WATER_MARK_FILE = ".highwatermark", LOCK_OPTIONS, DEFAULT_TASKS_MODE_TASK_LIST_ID = "tasklist";
626
- var init_tasks = __esm(() => {
627
- init_v4();
628
- init_state();
629
- init_array();
630
- init_debug();
631
- init_envUtils();
632
- init_errors();
633
- init_lazySchema();
634
- init_lockfile();
635
- init_log();
636
- init_signal();
637
- init_slowOperations();
638
- init_teammate();
639
- init_teammateContext();
640
- tasksUpdated = createSignal();
641
- onTasksUpdated = tasksUpdated.subscribe;
642
- TASK_STATUSES = ["pending", "in_progress", "completed"];
643
- TaskStatusSchema = lazySchema(() => exports_external.enum(["pending", "in_progress", "completed"]));
644
- TaskSchema = lazySchema(() => exports_external.object({
645
- id: exports_external.string(),
646
- subject: exports_external.string(),
647
- description: exports_external.string(),
648
- activeForm: exports_external.string().optional(),
649
- owner: exports_external.string().optional(),
650
- status: TaskStatusSchema(),
651
- blocks: exports_external.array(exports_external.string()),
652
- blockedBy: exports_external.array(exports_external.string()),
653
- metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
654
- }));
655
- LOCK_OPTIONS = {
656
- retries: {
657
- retries: 30,
658
- minTimeout: 5,
659
- maxTimeout: 100
660
- }
661
- };
662
- });
663
-
664
- // src/utils/swarm/backends/types.ts
665
- function isPaneBackend(type) {
666
- return type === "tmux" || type === "iterm2";
667
- }
668
- var init_types = () => {};
669
-
670
- // src/utils/swarm/teamHelpers.ts
671
- import { mkdirSync, readFileSync, writeFileSync } from "fs";
672
- import { mkdir as mkdir2, readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
673
- import { join as join2 } from "path";
674
- function sanitizeName(name) {
675
- return name.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
676
- }
677
- function sanitizeAgentName(name) {
678
- return name.replace(/@/g, "-");
679
- }
680
- function getTeamDir(teamName) {
681
- return join2(getTeamsDir(), sanitizeName(teamName));
682
- }
683
- function getTeamFilePath(teamName) {
684
- return join2(getTeamDir(teamName), "config.json");
685
- }
686
- function readTeamFile(teamName) {
687
- try {
688
- const content = readFileSync(getTeamFilePath(teamName), "utf-8");
689
- return jsonParse(content);
690
- } catch (e) {
691
- if (getErrnoCode(e) === "ENOENT")
692
- return null;
693
- logForDebugging(`[TeammateTool] Failed to read team file for ${teamName}: ${errorMessage(e)}`);
694
- return null;
695
- }
696
- }
697
- async function readTeamFileAsync(teamName) {
698
- try {
699
- const content = await readFile2(getTeamFilePath(teamName), "utf-8");
700
- return jsonParse(content);
701
- } catch (e) {
702
- if (getErrnoCode(e) === "ENOENT")
703
- return null;
704
- logForDebugging(`[TeammateTool] Failed to read team file for ${teamName}: ${errorMessage(e)}`);
705
- return null;
706
- }
707
- }
708
- function writeTeamFile(teamName, teamFile) {
709
- const teamDir = getTeamDir(teamName);
710
- mkdirSync(teamDir, { recursive: true });
711
- writeFileSync(getTeamFilePath(teamName), jsonStringify(teamFile, null, 2));
712
- }
713
- async function writeTeamFileAsync(teamName, teamFile) {
714
- const teamDir = getTeamDir(teamName);
715
- await mkdir2(teamDir, { recursive: true });
716
- await writeFile2(getTeamFilePath(teamName), jsonStringify(teamFile, null, 2));
717
- }
718
- function removeTeammateFromTeamFile(teamName, identifier) {
719
- const identifierStr = identifier.agentId || identifier.name;
720
- if (!identifierStr) {
721
- logForDebugging("[TeammateTool] removeTeammateFromTeamFile called with no identifier");
722
- return false;
723
- }
724
- const teamFile = readTeamFile(teamName);
725
- if (!teamFile) {
726
- logForDebugging(`[TeammateTool] Cannot remove teammate ${identifierStr}: failed to read team file for "${teamName}"`);
727
- return false;
728
- }
729
- const originalLength = teamFile.members.length;
730
- teamFile.members = teamFile.members.filter((m) => {
731
- if (identifier.agentId && m.agentId === identifier.agentId)
732
- return false;
733
- if (identifier.name && m.name === identifier.name)
734
- return false;
735
- return true;
736
- });
737
- if (teamFile.members.length === originalLength) {
738
- logForDebugging(`[TeammateTool] Teammate ${identifierStr} not found in team file for "${teamName}"`);
739
- return false;
740
- }
741
- writeTeamFile(teamName, teamFile);
742
- logForDebugging(`[TeammateTool] Removed teammate from team file: ${identifierStr}`);
743
- return true;
744
- }
745
- function addHiddenPaneId(teamName, paneId) {
746
- const teamFile = readTeamFile(teamName);
747
- if (!teamFile) {
748
- return false;
749
- }
750
- const hiddenPaneIds = teamFile.hiddenPaneIds ?? [];
751
- if (!hiddenPaneIds.includes(paneId)) {
752
- hiddenPaneIds.push(paneId);
753
- teamFile.hiddenPaneIds = hiddenPaneIds;
754
- writeTeamFile(teamName, teamFile);
755
- logForDebugging(`[TeammateTool] Added ${paneId} to hidden panes for team ${teamName}`);
756
- }
757
- return true;
758
- }
759
- function removeHiddenPaneId(teamName, paneId) {
760
- const teamFile = readTeamFile(teamName);
761
- if (!teamFile) {
762
- return false;
763
- }
764
- const hiddenPaneIds = teamFile.hiddenPaneIds ?? [];
765
- const index = hiddenPaneIds.indexOf(paneId);
766
- if (index !== -1) {
767
- hiddenPaneIds.splice(index, 1);
768
- teamFile.hiddenPaneIds = hiddenPaneIds;
769
- writeTeamFile(teamName, teamFile);
770
- logForDebugging(`[TeammateTool] Removed ${paneId} from hidden panes for team ${teamName}`);
771
- }
772
- return true;
773
- }
774
- function removeMemberFromTeam(teamName, tmuxPaneId) {
775
- const teamFile = readTeamFile(teamName);
776
- if (!teamFile) {
777
- return false;
778
- }
779
- const memberIndex = teamFile.members.findIndex((m) => m.tmuxPaneId === tmuxPaneId);
780
- if (memberIndex === -1) {
781
- return false;
782
- }
783
- teamFile.members.splice(memberIndex, 1);
784
- if (teamFile.hiddenPaneIds) {
785
- const hiddenIndex = teamFile.hiddenPaneIds.indexOf(tmuxPaneId);
786
- if (hiddenIndex !== -1) {
787
- teamFile.hiddenPaneIds.splice(hiddenIndex, 1);
788
- }
789
- }
790
- writeTeamFile(teamName, teamFile);
791
- logForDebugging(`[TeammateTool] Removed member with pane ${tmuxPaneId} from team ${teamName}`);
792
- return true;
793
- }
794
- function removeMemberByAgentId(teamName, agentId) {
795
- const teamFile = readTeamFile(teamName);
796
- if (!teamFile) {
797
- return false;
798
- }
799
- const memberIndex = teamFile.members.findIndex((m) => m.agentId === agentId);
800
- if (memberIndex === -1) {
801
- return false;
802
- }
803
- teamFile.members.splice(memberIndex, 1);
804
- writeTeamFile(teamName, teamFile);
805
- logForDebugging(`[TeammateTool] Removed member ${agentId} from team ${teamName}`);
806
- return true;
807
- }
808
- function setMemberMode(teamName, memberName, mode) {
809
- const teamFile = readTeamFile(teamName);
810
- if (!teamFile) {
811
- return false;
812
- }
813
- const member = teamFile.members.find((m) => m.name === memberName);
814
- if (!member) {
815
- logForDebugging(`[TeammateTool] Cannot set member mode: member ${memberName} not found in team ${teamName}`);
816
- return false;
817
- }
818
- if (member.mode === mode) {
819
- return true;
820
- }
821
- const updatedMembers = teamFile.members.map((m) => m.name === memberName ? { ...m, mode } : m);
822
- writeTeamFile(teamName, { ...teamFile, members: updatedMembers });
823
- logForDebugging(`[TeammateTool] Set member ${memberName} in team ${teamName} to mode: ${mode}`);
824
- return true;
825
- }
826
- function syncTeammateMode(mode, teamNameOverride) {
827
- if (!isTeammate())
828
- return;
829
- const teamName = teamNameOverride ?? getTeamName();
830
- const agentName = getAgentName();
831
- if (teamName && agentName) {
832
- setMemberMode(teamName, agentName, mode);
833
- }
834
- }
835
- function setMultipleMemberModes(teamName, modeUpdates) {
836
- const teamFile = readTeamFile(teamName);
837
- if (!teamFile) {
838
- return false;
839
- }
840
- const updateMap = new Map(modeUpdates.map((u) => [u.memberName, u.mode]));
841
- let anyChanged = false;
842
- const updatedMembers = teamFile.members.map((member) => {
843
- const newMode = updateMap.get(member.name);
844
- if (newMode !== undefined && member.mode !== newMode) {
845
- anyChanged = true;
846
- return { ...member, mode: newMode };
847
- }
848
- return member;
849
- });
850
- if (anyChanged) {
851
- writeTeamFile(teamName, { ...teamFile, members: updatedMembers });
852
- logForDebugging(`[TeammateTool] Set ${modeUpdates.length} member modes in team ${teamName}`);
853
- }
854
- return true;
855
- }
856
- async function setMemberActive(teamName, memberName, isActive) {
857
- const teamFile = await readTeamFileAsync(teamName);
858
- if (!teamFile) {
859
- logForDebugging(`[TeammateTool] Cannot set member active: team ${teamName} not found`);
860
- return;
861
- }
862
- const member = teamFile.members.find((m) => m.name === memberName);
863
- if (!member) {
864
- logForDebugging(`[TeammateTool] Cannot set member active: member ${memberName} not found in team ${teamName}`);
865
- return;
866
- }
867
- if (member.isActive === isActive) {
868
- return;
869
- }
870
- member.isActive = isActive;
871
- await writeTeamFileAsync(teamName, teamFile);
872
- logForDebugging(`[TeammateTool] Set member ${memberName} in team ${teamName} to ${isActive ? "active" : "idle"}`);
873
- }
874
- async function destroyWorktree(worktreePath) {
875
- const gitFilePath = join2(worktreePath, ".git");
876
- let mainRepoPath = null;
877
- try {
878
- const gitFileContent = (await readFile2(gitFilePath, "utf-8")).trim();
879
- const match = gitFileContent.match(/^gitdir:\s*(.+)$/);
880
- if (match && match[1]) {
881
- const worktreeGitDir = match[1];
882
- const mainGitDir = join2(worktreeGitDir, "..", "..");
883
- mainRepoPath = join2(mainGitDir, "..");
884
- }
885
- } catch {}
886
- if (mainRepoPath) {
887
- const result = await execFileNoThrowWithCwd(gitExe(), ["worktree", "remove", "--force", worktreePath], { cwd: mainRepoPath });
888
- if (result.code === 0) {
889
- logForDebugging(`[TeammateTool] Removed worktree via git: ${worktreePath}`);
890
- return;
891
- }
892
- if (result.stderr?.includes("not a working tree")) {
893
- logForDebugging(`[TeammateTool] Worktree already removed: ${worktreePath}`);
894
- return;
895
- }
896
- logForDebugging(`[TeammateTool] git worktree remove failed, falling back to rm: ${result.stderr}`);
897
- }
898
- try {
899
- await rm(worktreePath, { recursive: true, force: true });
900
- logForDebugging(`[TeammateTool] Removed worktree directory manually: ${worktreePath}`);
901
- } catch (error) {
902
- logForDebugging(`[TeammateTool] Failed to remove worktree ${worktreePath}: ${errorMessage(error)}`);
903
- }
904
- }
905
- function registerTeamForSessionCleanup(teamName) {
906
- getSessionCreatedTeams().add(teamName);
907
- }
908
- function unregisterTeamForSessionCleanup(teamName) {
909
- getSessionCreatedTeams().delete(teamName);
910
- }
911
- async function cleanupSessionTeams() {
912
- const sessionCreatedTeams = getSessionCreatedTeams();
913
- if (sessionCreatedTeams.size === 0)
914
- return;
915
- const teams = Array.from(sessionCreatedTeams);
916
- logForDebugging(`cleanupSessionTeams: removing ${teams.length} orphan team dir(s): ${teams.join(", ")}`);
917
- await Promise.allSettled(teams.map((name) => killOrphanedTeammatePanes(name)));
918
- await Promise.allSettled(teams.map((name) => cleanupTeamDirectories(name)));
919
- sessionCreatedTeams.clear();
920
- }
921
- async function killOrphanedTeammatePanes(teamName) {
922
- const teamFile = readTeamFile(teamName);
923
- if (!teamFile)
924
- return;
925
- const paneMembers = teamFile.members.filter((m) => m.name !== TEAM_LEAD_NAME && m.tmuxPaneId && m.backendType && isPaneBackend(m.backendType));
926
- if (paneMembers.length === 0)
927
- return;
928
- const [{ ensureBackendsRegistered, getBackendByType }, { isInsideTmux }] = await Promise.all([
929
- import("./chunk-b9mkm8mg.js"),
930
- import("./chunk-0t81d427.js")
931
- ]);
932
- await ensureBackendsRegistered();
933
- const useExternalSession = !await isInsideTmux();
934
- await Promise.allSettled(paneMembers.map(async (m) => {
935
- if (!m.tmuxPaneId || !m.backendType || !isPaneBackend(m.backendType)) {
936
- return;
937
- }
938
- const ok = await getBackendByType(m.backendType).killPane(m.tmuxPaneId, useExternalSession);
939
- logForDebugging(`cleanupSessionTeams: killPane ${m.name} (${m.backendType} ${m.tmuxPaneId}) \u2192 ${ok}`);
940
- }));
941
- }
942
- async function cleanupTeamDirectories(teamName) {
943
- const sanitizedName = sanitizeName(teamName);
944
- const teamFile = readTeamFile(teamName);
945
- const worktreePaths = [];
946
- if (teamFile) {
947
- for (const member of teamFile.members) {
948
- if (member.worktreePath) {
949
- worktreePaths.push(member.worktreePath);
950
- }
951
- }
952
- }
953
- for (const worktreePath of worktreePaths) {
954
- await destroyWorktree(worktreePath);
955
- }
956
- const teamDir = getTeamDir(teamName);
957
- try {
958
- await rm(teamDir, { recursive: true, force: true });
959
- logForDebugging(`[TeammateTool] Cleaned up team directory: ${teamDir}`);
960
- } catch (error) {
961
- logForDebugging(`[TeammateTool] Failed to clean up team directory ${teamDir}: ${errorMessage(error)}`);
962
- }
963
- const tasksDir = getTasksDir(sanitizedName);
964
- try {
965
- await rm(tasksDir, { recursive: true, force: true });
966
- logForDebugging(`[TeammateTool] Cleaned up tasks directory: ${tasksDir}`);
967
- notifyTasksUpdated();
968
- } catch (error) {
969
- logForDebugging(`[TeammateTool] Failed to clean up tasks directory ${tasksDir}: ${errorMessage(error)}`);
970
- }
971
- }
972
- var inputSchema;
973
- var init_teamHelpers = __esm(() => {
974
- init_v4();
975
- init_state();
976
- init_debug();
977
- init_envUtils();
978
- init_errors();
979
- init_execFileNoThrow();
980
- init_git();
981
- init_lazySchema();
982
- init_slowOperations();
983
- init_tasks();
984
- init_teammate();
985
- init_types();
986
- init_constants();
987
- inputSchema = lazySchema(() => exports_external.strictObject({
988
- operation: exports_external.enum(["spawnTeam", "cleanup"]).describe("Operation: spawnTeam to create a team, cleanup to remove team and task directories."),
989
- agent_type: exports_external.string().optional().describe('Type/role of the team lead (e.g., "researcher", "test-runner"). ' + "Used for team file and inter-agent coordination."),
990
- team_name: exports_external.string().optional().describe("Name for the new team to create (required for spawnTeam)."),
991
- description: exports_external.string().optional().describe("Team description/purpose (only used with spawnTeam).")
992
- }));
993
- });
994
-
995
- export { getTeammateContext, runWithTeammateContext, isInProcessTeammate, createTeammateContext, init_teammateContext, getParentSessionId, getDynamicTeamContext, getAgentId, getAgentName, getTeamName, isTeammate, getTeammateColor, isPlanModeRequired, isTeamLead, hasActiveInProcessTeammates, hasWorkingInProcessTeammates, waitForTeammatesToBecomeIdle, exports_teammate, init_teammate, setLeaderTeamName, clearLeaderTeamName, onTasksUpdated, TASK_STATUSES, TaskStatusSchema, isTodoV2Enabled, resetTaskList, getTaskListId, sanitizePathComponent, getTasksDir, ensureTasksDir, createTask, getTask, updateTask, deleteTask, listTasks, blockTask, claimTask, unassignTeammateTasks, DEFAULT_TASKS_MODE_TASK_LIST_ID, init_tasks, isPaneBackend, init_types, inputSchema, sanitizeName, sanitizeAgentName, getTeamDir, getTeamFilePath, readTeamFile, readTeamFileAsync, writeTeamFileAsync, removeTeammateFromTeamFile, addHiddenPaneId, removeHiddenPaneId, removeMemberFromTeam, removeMemberByAgentId, setMemberMode, syncTeammateMode, setMultipleMemberModes, setMemberActive, registerTeamForSessionCleanup, unregisterTeamForSessionCleanup, cleanupSessionTeams, cleanupTeamDirectories, init_teamHelpers };