@caspian2026/agent-sdk 0.0.25 → 0.0.27

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 +1005 -982
  3. package/dist/sdk/query.cjs +2 -362
  4. package/dist/sdk/query.js +2 -367
  5. package/package.json +126 -128
  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,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-3fdgrwd2.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 };