claude-code-best 1.3.7 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/README.md +1 -0
  2. package/dist/{chunk-cdgv0k77.js → chunk-00vfg42v.js} +61 -59
  3. package/dist/{chunk-6ex0f5ej.js → chunk-01ysfcs0.js} +6 -8
  4. package/dist/{chunk-1vzb650a.js → chunk-04ws37gv.js} +6 -8
  5. package/dist/{chunk-7etmzq13.js → chunk-0b0fq180.js} +27 -27
  6. package/dist/{chunk-drsh1vv8.js → chunk-0cs46nj6.js} +63 -62
  7. package/dist/chunk-0fzcyd0s.js +116 -0
  8. package/dist/{chunk-7nebst32.js → chunk-0knhp7v5.js} +2 -2
  9. package/dist/{chunk-n42nvr59.js → chunk-0xth516w.js} +14 -14
  10. package/dist/{chunk-egcx83tp.js → chunk-0y6h57c5.js} +6 -6
  11. package/dist/{chunk-d267stxj.js → chunk-0z0m6mm5.js} +1 -1
  12. package/dist/{chunk-y10byvag.js → chunk-196qs1ty.js} +30 -29
  13. package/dist/chunk-1d39h7zf.js +57 -0
  14. package/dist/{chunk-antr836n.js → chunk-1k3ahc24.js} +59 -57
  15. package/dist/{chunk-5scrgrwv.js → chunk-1nhx3qpn.js} +2 -2
  16. package/dist/{chunk-zv5yt0g4.js → chunk-1qbype3e.js} +9 -9
  17. package/dist/{chunk-bkzs71af.js → chunk-1r70yykn.js} +3 -3
  18. package/dist/{chunk-tvnrwrg3.js → chunk-1x1wb96n.js} +62 -60
  19. package/dist/{chunk-j44ngncb.js → chunk-1yscv3t1.js} +7 -9
  20. package/dist/{chunk-zhe3rws3.js → chunk-27ppq985.js} +7 -9
  21. package/dist/{chunk-kbshq7zc.js → chunk-28a1ffp7.js} +59 -56
  22. package/dist/{chunk-m95fj0wm.js → chunk-2ag1bjqx.js} +4 -4
  23. package/dist/{chunk-2fx2x8qp.js → chunk-2cz1rwf3.js} +22 -21
  24. package/dist/{chunk-v1chtgnf.js → chunk-2m6jk78c.js} +1 -1
  25. package/dist/{chunk-nzchm0f2.js → chunk-2mhgyhns.js} +1 -1
  26. package/dist/{chunk-n5pe3jtt.js → chunk-2pjptqfa.js} +2 -2
  27. package/dist/{chunk-5r3wgr44.js → chunk-2qfb22ax.js} +29 -1399
  28. package/dist/{chunk-n0rn505k.js → chunk-2rcaw0yh.js} +4 -4
  29. package/dist/{chunk-wp9nwczx.js → chunk-2rtngpm1.js} +8 -10
  30. package/dist/{chunk-s2cwz71x.js → chunk-2tzmvvew.js} +60 -57
  31. package/dist/{chunk-ydraa9ey.js → chunk-2xrp0wp0.js} +70 -68
  32. package/dist/{chunk-jty4xkhc.js → chunk-313nbvgt.js} +5 -5
  33. package/dist/chunk-3e2a6c4k.js +33 -0
  34. package/dist/{chunk-hbf3y5tw.js → chunk-3fnhdnj6.js} +22 -21
  35. package/dist/{chunk-qahkzpj6.js → chunk-3g6kvmg4.js} +6 -8
  36. package/dist/{chunk-kz13d2bs.js → chunk-3mapywg0.js} +2 -2
  37. package/dist/{chunk-tw4tjc73.js → chunk-3rk983b5.js} +1 -1
  38. package/dist/chunk-3vc6mx77.js +119 -0
  39. package/dist/{chunk-nsxw7en4.js → chunk-3yzyedet.js} +23 -22
  40. package/dist/{chunk-1q82ecz5.js → chunk-40w1c21c.js} +58 -55
  41. package/dist/{chunk-bnvd1jc1.js → chunk-4brmjvph.js} +4 -4
  42. package/dist/{chunk-zwrt0s3s.js → chunk-4er46edn.js} +69 -141
  43. package/dist/{chunk-fsex4yt2.js → chunk-4h9ek408.js} +7 -9
  44. package/dist/chunk-4mdqm8b7.js +115 -0
  45. package/dist/{chunk-9p95042q.js → chunk-4qjh89qr.js} +1 -1
  46. package/dist/chunk-506gq3zq.js +104 -0
  47. package/dist/{chunk-w6rh4zpx.js → chunk-5158j5ph.js} +8 -10
  48. package/dist/{chunk-d969b8ne.js → chunk-524xgs6r.js} +7 -7
  49. package/dist/{chunk-76hrbqgr.js → chunk-52rnpp5t.js} +16 -18
  50. package/dist/{chunk-0a2qnsbr.js → chunk-54bwa086.js} +61 -57
  51. package/dist/{chunk-qn4cbm38.js → chunk-5famfv4a.js} +23 -22
  52. package/dist/{chunk-kmgp6prw.js → chunk-5khwvj1z.js} +112 -5
  53. package/dist/{chunk-9byk2a4b.js → chunk-5m7095hq.js} +25 -25
  54. package/dist/{chunk-g14ex9z0.js → chunk-5mv51kkx.js} +59 -56
  55. package/dist/{chunk-p2sww3pd.js → chunk-5vqwq0f9.js} +59 -56
  56. package/dist/{chunk-s26mv9yh.js → chunk-5zbp0a48.js} +7 -8
  57. package/dist/{chunk-pvtzf6vs.js → chunk-60xm3v9r.js} +3 -3
  58. package/dist/chunk-6356tyx5.js +32 -0
  59. package/dist/{chunk-1vzaw5f6.js → chunk-66s9m31j.js} +23 -22
  60. package/dist/{chunk-c1cm8km0.js → chunk-6ebb5ym0.js} +58 -55
  61. package/dist/{chunk-yp2yx0qj.js → chunk-6f0296p8.js} +5 -7
  62. package/dist/{chunk-m2cskgz4.js → chunk-6gftrxn5.js} +86 -81
  63. package/dist/{chunk-y95se10r.js → chunk-6h1reb8m.js} +22 -21
  64. package/dist/{chunk-fy6tp8zj.js → chunk-6pb9n4m3.js} +2 -2
  65. package/dist/{chunk-ardzdtan.js → chunk-6y2wszkc.js} +1 -1
  66. package/dist/{chunk-4ydmya8m.js → chunk-6y8e5c85.js} +24 -22
  67. package/dist/{chunk-rshk7m9c.js → chunk-718k4vsj.js} +62 -60
  68. package/dist/{chunk-tm4w23dp.js → chunk-72091jsk.js} +1 -1
  69. package/dist/{chunk-xtaw765g.js → chunk-760hjt0a.js} +3 -3
  70. package/dist/chunk-77dnrj5q.js +119 -0
  71. package/dist/{chunk-gz4r3k7a.js → chunk-77w9ffyy.js} +5 -5
  72. package/dist/{chunk-xaw4scep.js → chunk-78009jh9.js} +2 -2
  73. package/dist/{chunk-6xr5mayh.js → chunk-79vh2q13.js} +58 -55
  74. package/dist/{chunk-p7d5ms03.js → chunk-7ba2qns8.js} +22 -21
  75. package/dist/{chunk-6wrs3ahh.js → chunk-7dy65axk.js} +22 -21
  76. package/dist/{chunk-n35gnb9g.js → chunk-7hmy36fh.js} +121 -2
  77. package/dist/{chunk-erxndz83.js → chunk-7kfps7yt.js} +7 -9
  78. package/dist/chunk-7r3d9nyj.js +113 -0
  79. package/dist/{chunk-dne2ghq6.js → chunk-7yfxza07.js} +16 -22
  80. package/dist/chunk-7zw138yt.js +32 -0
  81. package/dist/{chunk-6ye6d9gw.js → chunk-81dxa3fd.js} +1 -1
  82. package/dist/{chunk-540608wh.js → chunk-86jhenxk.js} +66 -57
  83. package/dist/chunk-88mfsn97.js +115 -0
  84. package/dist/{chunk-zy4fsy90.js → chunk-8gs07wbw.js} +18 -18
  85. package/dist/{chunk-4ayhftnk.js → chunk-8h4gpg9r.js} +83 -119
  86. package/dist/{chunk-brnc96x6.js → chunk-8h7bg6q9.js} +203 -24
  87. package/dist/chunk-8mspr5sg.js +47 -0
  88. package/dist/{chunk-62dx37pf.js → chunk-8pskaz4y.js} +9 -11
  89. package/dist/{chunk-sn3wbs2w.js → chunk-8xbwczap.js} +58 -55
  90. package/dist/{chunk-tw2wjsnb.js → chunk-8xsjtkh4.js} +4 -4
  91. package/dist/{chunk-ky85ntn8.js → chunk-8y0ghcs4.js} +69 -66
  92. package/dist/chunk-8zzqydag.js +101 -0
  93. package/dist/{chunk-cpvn0j86.js → chunk-924n94wb.js} +22 -21
  94. package/dist/{chunk-0asd58w2.js → chunk-92p2k7yk.js} +11 -11
  95. package/dist/{chunk-qvywetwr.js → chunk-93cd0z7w.js} +66 -64
  96. package/dist/{chunk-db82mfh9.js → chunk-97svwq59.js} +73 -71
  97. package/dist/{chunk-3j857x3k.js → chunk-99cjjht1.js} +60 -58
  98. package/dist/{chunk-pedmqmrf.js → chunk-9awawyvh.js} +6 -6
  99. package/dist/{chunk-22rs73mh.js → chunk-9b6wqcyk.js} +60 -57
  100. package/dist/{chunk-cxf74p1t.js → chunk-9datyj43.js} +2 -2
  101. package/dist/{chunk-n1pa72ns.js → chunk-9qh5f9r3.js} +7 -12
  102. package/dist/{chunk-vb6w46m9.js → chunk-9revwk5g.js} +59 -56
  103. package/dist/{chunk-g71q1n7x.js → chunk-a0m994d6.js} +58 -55
  104. package/dist/{chunk-ftajx4gw.js → chunk-a0qhdfct.js} +49 -160
  105. package/dist/{chunk-0xq2bfvv.js → chunk-a5w8nyhg.js} +2 -2
  106. package/dist/{chunk-ms9225af.js → chunk-a85wqwq4.js} +58 -55
  107. package/dist/{chunk-3c81vb6k.js → chunk-a92eevfn.js} +6 -8
  108. package/dist/{chunk-2katyzq9.js → chunk-ab6gc90x.js} +3 -5
  109. package/dist/{chunk-j50zvssc.js → chunk-ad6rg8vz.js} +5 -5
  110. package/dist/{chunk-z7svjppe.js → chunk-admwpsa6.js} +10 -14
  111. package/dist/{chunk-v081mpyx.js → chunk-ahexmj4s.js} +24 -26
  112. package/dist/{chunk-7z0078sp.js → chunk-att0rknb.js} +2 -2
  113. package/dist/{chunk-prgsmrmy.js → chunk-axenqvc8.js} +2 -2
  114. package/dist/{chunk-mfzgqp0c.js → chunk-azq1qstz.js} +10 -14
  115. package/dist/{chunk-zajs1j2b.js → chunk-b125aa22.js} +59 -57
  116. package/dist/{chunk-9f01qpne.js → chunk-b4wfv4fx.js} +73 -71
  117. package/dist/{chunk-ns3babbs.js → chunk-b5wxetbv.js} +224 -1
  118. package/dist/chunk-b62vj92a.js +94 -0
  119. package/dist/{chunk-9v5bwvbm.js → chunk-b6drr9se.js} +63 -61
  120. package/dist/chunk-b7kfr260.js +168 -0
  121. package/dist/chunk-b9pqgq8z.js +37 -0
  122. package/dist/{chunk-c8rgc3hw.js → chunk-bevwqet9.js} +66 -64
  123. package/dist/{chunk-m2rx2dtd.js → chunk-bgf5zvvv.js} +91 -89
  124. package/dist/{chunk-fye86v7m.js → chunk-bq8zdg7m.js} +58 -55
  125. package/dist/chunk-bww2h6d4.js +114 -0
  126. package/dist/{chunk-m83vaktc.js → chunk-bx165r58.js} +1 -1
  127. package/dist/{chunk-4q5a5mjb.js → chunk-c092k38b.js} +3532 -1684
  128. package/dist/{chunk-163379k5.js → chunk-c0avjkfn.js} +58 -55
  129. package/dist/{chunk-ermvk1xn.js → chunk-c3s22pgw.js} +61 -58
  130. package/dist/{chunk-zahg0adp.js → chunk-c4g5qaey.js} +5 -5
  131. package/dist/{chunk-f6wypwa6.js → chunk-c6nthjxa.js} +6 -4
  132. package/dist/{chunk-wmd0v561.js → chunk-c7d1acex.js} +5 -7
  133. package/dist/{chunk-wmbpegg3.js → chunk-c7t69jmn.js} +1 -1
  134. package/dist/{chunk-vm0b9vaz.js → chunk-cg3bb5pe.js} +9 -9
  135. package/dist/{chunk-m8v1x99r.js → chunk-chzfw06n.js} +3 -5
  136. package/dist/chunk-cm2xfg7q.js +1394 -0
  137. package/dist/{chunk-4yxd0e7k.js → chunk-crj9bjh5.js} +58 -55
  138. package/dist/{chunk-v4nrk2f9.js → chunk-cstkqpd5.js} +7 -8
  139. package/dist/{chunk-3nwsgn73.js → chunk-ctj2ehwz.js} +59 -56
  140. package/dist/{chunk-mcbqmbp2.js → chunk-cwwfyvbq.js} +6 -4
  141. package/dist/{chunk-9nddm5c7.js → chunk-cxf9amp4.js} +2 -3
  142. package/dist/chunk-cxmyg49v.js +104 -0
  143. package/dist/{chunk-5wb5ym2h.js → chunk-cy1z66c2.js} +3 -5
  144. package/dist/{chunk-nbzntnkz.js → chunk-d2q17m4k.js} +60 -58
  145. package/dist/{chunk-ymtkahxp.js → chunk-d2wzkwws.js} +69 -66
  146. package/dist/{chunk-x4t0n8t3.js → chunk-d4qdesrx.js} +3 -4
  147. package/dist/chunk-d4zyytan.js +3802 -0
  148. package/dist/{chunk-8q4yg5pk.js → chunk-d57t992t.js} +9 -96
  149. package/dist/{chunk-g2tmm7k7.js → chunk-dafnbqhh.js} +76 -74
  150. package/dist/{chunk-tjbjxrqz.js → chunk-dfcm57ek.js} +6 -6
  151. package/dist/{chunk-ynjbppdn.js → chunk-dgnwk906.js} +60 -58
  152. package/dist/{chunk-7gxyarah.js → chunk-dhwpmz98.js} +61 -58
  153. package/dist/{chunk-yevbmk5g.js → chunk-djzvjzdg.js} +3 -3
  154. package/dist/chunk-dm5e2sj0.js +187 -0
  155. package/dist/{chunk-145d3809.js → chunk-dnpy3zcs.js} +63 -60
  156. package/dist/{chunk-h7ffkxg4.js → chunk-drvfxfe5.js} +26 -25
  157. package/dist/{chunk-c14sp904.js → chunk-dv4dsh0t.js} +7 -7
  158. package/dist/{chunk-9ejadhq8.js → chunk-dyp88vca.js} +64 -62
  159. package/dist/{chunk-xfft38wf.js → chunk-dytg8n15.js} +12 -12
  160. package/dist/{chunk-j3ctqpsn.js → chunk-e1bt4m2g.js} +2 -2
  161. package/dist/{chunk-vvm5az9j.js → chunk-e23snepr.js} +3 -3
  162. package/dist/{chunk-hgfw7nx2.js → chunk-e6sqr0av.js} +58 -55
  163. package/dist/{chunk-v7xwthvg.js → chunk-e9eyqwk5.js} +405 -283
  164. package/dist/{chunk-2wvxqpfc.js → chunk-efkjha6m.js} +8 -9
  165. package/dist/{chunk-3s2gjp2n.js → chunk-ekpm458a.js} +67 -65
  166. package/dist/{chunk-vf3etxnx.js → chunk-emxnq07z.js} +1 -1
  167. package/dist/{chunk-c4x4fb6d.js → chunk-erkssp71.js} +58 -55
  168. package/dist/chunk-es08rrda.js +112 -0
  169. package/dist/{chunk-c209ascy.js → chunk-ewxpkqxt.js} +9 -9
  170. package/dist/{chunk-1wykga1n.js → chunk-f25pnrvx.js} +4 -6
  171. package/dist/chunk-f2y3t9hh.js +295 -0
  172. package/dist/{chunk-427mfnyx.js → chunk-f31b63fd.js} +1 -1
  173. package/dist/{chunk-2dsqf7sp.js → chunk-f57cvf1d.js} +1 -1
  174. package/dist/{chunk-ry1jb15g.js → chunk-f872fekv.js} +58 -55
  175. package/dist/{chunk-r7s0jwb1.js → chunk-faey4sqw.js} +59 -56
  176. package/dist/{chunk-40ax4h54.js → chunk-fbbjchdz.js} +60 -58
  177. package/dist/{chunk-fskf0b3x.js → chunk-fbedkst6.js} +6 -8
  178. package/dist/{chunk-9msn8xwq.js → chunk-fckykghd.js} +2 -3
  179. package/dist/{chunk-ztrgnar4.js → chunk-fdbvcs34.js} +7 -9
  180. package/dist/{chunk-667f3w39.js → chunk-ffpz33kr.js} +23 -22
  181. package/dist/{chunk-0fpkjw2j.js → chunk-ffvja87d.js} +8 -10
  182. package/dist/{chunk-r6gyed9y.js → chunk-fjpdtr6s.js} +9 -9
  183. package/dist/{chunk-8y1zs48n.js → chunk-fnpd8cnq.js} +1 -1
  184. package/dist/{chunk-eef1npre.js → chunk-fxpsa506.js} +4 -6
  185. package/dist/{chunk-2z6bv21c.js → chunk-fxrrsvnw.js} +23 -27
  186. package/dist/chunk-fz4wmnm6.js +157 -0
  187. package/dist/{chunk-2c4jgf3n.js → chunk-g3dbfhxa.js} +5 -7
  188. package/dist/{chunk-s13m8efn.js → chunk-g86dg6h5.js} +5 -5
  189. package/dist/{chunk-h7mpryyc.js → chunk-gc4x22mt.js} +59 -56
  190. package/dist/{chunk-5s1bctjb.js → chunk-gfxebcsw.js} +28 -28
  191. package/dist/chunk-ghbtnfr2.js +117 -0
  192. package/dist/{chunk-gpk30ekc.js → chunk-gqftywrx.js} +23 -22
  193. package/dist/{chunk-z2aps7d9.js → chunk-gwrngewt.js} +3 -3
  194. package/dist/{chunk-psp1n9vg.js → chunk-gxfbedta.js} +1 -1
  195. package/dist/{chunk-fq1j9zm0.js → chunk-gybj15eh.js} +2 -3
  196. package/dist/chunk-h0vzd5vg.js +1012 -0
  197. package/dist/{chunk-0ahxmrws.js → chunk-h14dkna4.js} +23 -22
  198. package/dist/{chunk-x42kc5wj.js → chunk-h26xfh6d.js} +22 -21
  199. package/dist/{chunk-nwgkkhk7.js → chunk-h2vfn30x.js} +4 -4
  200. package/dist/{chunk-mh8752jz.js → chunk-h37gar4j.js} +1 -1
  201. package/dist/{chunk-n612gr22.js → chunk-h4k9kgjw.js} +59 -56
  202. package/dist/{chunk-1av0kkwh.js → chunk-hc1tkwfn.js} +3 -5
  203. package/dist/{chunk-h5dk6k0g.js → chunk-hf086e2e.js} +58 -55
  204. package/dist/{chunk-66j7fn6z.js → chunk-hhwqk5as.js} +58 -55
  205. package/dist/{chunk-e8zmtbry.js → chunk-hjw03d0k.js} +60 -58
  206. package/dist/{chunk-e1t8jh0t.js → chunk-hkh1vbm6.js} +58 -55
  207. package/dist/{chunk-81dq52pk.js → chunk-hnxmafvc.js} +2 -2
  208. package/dist/{chunk-cj8m3h8r.js → chunk-hqpzpr71.js} +2 -2
  209. package/dist/{chunk-s3aygngf.js → chunk-hrz2d28r.js} +62 -60
  210. package/dist/chunk-hxb3js2g.js +91 -0
  211. package/dist/{chunk-j06y02aw.js → chunk-hxc8e6wd.js} +1 -1
  212. package/dist/chunk-hyy2fcba.js +351 -0
  213. package/dist/{chunk-dvf5921w.js → chunk-hyz9tx05.js} +15 -17
  214. package/dist/{chunk-ag3hbrat.js → chunk-j34h8cfj.js} +23 -22
  215. package/dist/{chunk-b31v41mz.js → chunk-j5w0b4d2.js} +23 -22
  216. package/dist/{chunk-2tcznfv0.js → chunk-j66ragf9.js} +1 -1
  217. package/dist/chunk-j7b884wk.js +397 -0
  218. package/dist/{chunk-35xyzbd2.js → chunk-ja21qbpj.js} +65 -62
  219. package/dist/{chunk-dchgtage.js → chunk-ja3eb4h9.js} +3 -3
  220. package/dist/{chunk-2crz81z3.js → chunk-jac470kz.js} +1 -1
  221. package/dist/{chunk-9nydmbm4.js → chunk-jaqtnpbt.js} +2 -2
  222. package/dist/{chunk-e03zrq9n.js → chunk-jc5dtv57.js} +60 -58
  223. package/dist/{chunk-jg7na104.js → chunk-jda4vjad.js} +58 -55
  224. package/dist/{chunk-drnxbc1w.js → chunk-jeqt4y47.js} +2 -2
  225. package/dist/{chunk-r7r3jm3y.js → chunk-jga4j8jp.js} +59 -57
  226. package/dist/{chunk-58rg6rn2.js → chunk-jge10dbd.js} +4 -6
  227. package/dist/{chunk-9k2c5sxb.js → chunk-jhbj5mnf.js} +58 -55
  228. package/dist/{chunk-zh6xf1fd.js → chunk-jje04m6z.js} +2 -2
  229. package/dist/{chunk-qkrenskm.js → chunk-jnfd01as.js} +9 -11
  230. package/dist/chunk-jpbkdg47.js +131 -0
  231. package/dist/{chunk-xcq3rdb0.js → chunk-jwb3bqa7.js} +27 -31
  232. package/dist/{chunk-s1p2w5a5.js → chunk-jy4dnnjk.js} +5 -5
  233. package/dist/{chunk-c9p5eyxf.js → chunk-k27dq4vd.js} +60 -57
  234. package/dist/{chunk-kmcaa88h.js → chunk-k81zec2p.js} +1 -1
  235. package/dist/{chunk-fxqp3yt4.js → chunk-kb2b4rkg.js} +4 -5
  236. package/dist/{chunk-h6dqpbac.js → chunk-kbsckx2r.js} +3 -3
  237. package/dist/{chunk-451hjtv9.js → chunk-kvezjrjy.js} +58 -55
  238. package/dist/{chunk-zc1s4swn.js → chunk-kw2ymvyv.js} +6 -8
  239. package/dist/{chunk-9jg130e9.js → chunk-kymh4vxw.js} +58 -55
  240. package/dist/{chunk-z66q1nam.js → chunk-kz3q1ce0.js} +58 -55
  241. package/dist/chunk-m089kb0s.js +312 -0
  242. package/dist/{chunk-86tz7yxt.js → chunk-m1efbjqe.js} +58 -55
  243. package/dist/chunk-m1xw79dd.js +1757 -0
  244. package/dist/{chunk-k303kw9v.js → chunk-m365zhp8.js} +59 -56
  245. package/dist/{chunk-0h4sw1v3.js → chunk-m97dyxn0.js} +61 -60
  246. package/dist/{chunk-e4jqbn4d.js → chunk-m9w972ny.js} +2 -4
  247. package/dist/{chunk-eserktyd.js → chunk-mb93ek5j.js} +4 -6
  248. package/dist/{chunk-c96k89rp.js → chunk-mgjc0yj9.js} +59 -57
  249. package/dist/{chunk-qmckdcc4.js → chunk-mh2pdxpc.js} +60 -58
  250. package/dist/{chunk-hnx0eg6x.js → chunk-mkae8zj9.js} +3 -3
  251. package/dist/{chunk-h0s737p0.js → chunk-mmq55gyp.js} +4 -4
  252. package/dist/{chunk-5k4kh5n9.js → chunk-ndrn50x0.js} +59 -57
  253. package/dist/{chunk-0pxmxyxv.js → chunk-ng2xq7ey.js} +3 -3
  254. package/dist/{chunk-gdb6dvba.js → chunk-nsbpzpmf.js} +61 -59
  255. package/dist/{chunk-18mm4jf8.js → chunk-nz7sgbbr.js} +5 -5
  256. package/dist/{chunk-t0b0bas5.js → chunk-nzfwsrd7.js} +3 -3
  257. package/dist/{chunk-rhxtttx1.js → chunk-p3zbzfbn.js} +3 -3
  258. package/dist/{chunk-9tc901nb.js → chunk-p5jssxha.js} +24 -24
  259. package/dist/{chunk-zmpygkz6.js → chunk-p7es39d1.js} +47 -122
  260. package/dist/{chunk-qwj4n799.js → chunk-p7pj6wf8.js} +1 -1
  261. package/dist/{chunk-855katq2.js → chunk-p9f12fp9.js} +60 -57
  262. package/dist/chunk-pb73zgyd.js +55 -0
  263. package/dist/chunk-prpjmapz.js +117 -0
  264. package/dist/{chunk-379rspd7.js → chunk-ps01q3n9.js} +64 -63
  265. package/dist/{chunk-ay9wm3tf.js → chunk-q19p9j0v.js} +5 -5
  266. package/dist/{chunk-536fmbtq.js → chunk-q7e12ymw.js} +4 -4
  267. package/dist/{chunk-w65283w4.js → chunk-qgajfxr7.js} +7 -7
  268. package/dist/{chunk-24qcj0k5.js → chunk-qgnsf30p.js} +24 -23
  269. package/dist/{chunk-xvjdbsfa.js → chunk-qs2atqgy.js} +60 -58
  270. package/dist/chunk-r469z4mx.js +183 -0
  271. package/dist/chunk-r5mqktt5.js +100 -0
  272. package/dist/chunk-r854e43q.js +25 -0
  273. package/dist/{chunk-fx6ghdvg.js → chunk-rbgr86hh.js} +59 -57
  274. package/dist/{chunk-qxv21mcq.js → chunk-rbvawtdz.js} +59 -56
  275. package/dist/chunk-rce8gj2b.js +93 -0
  276. package/dist/{chunk-t0twk3e5.js → chunk-rd2884ff.js} +1 -1
  277. package/dist/{chunk-c2ktjyc0.js → chunk-reqz49y3.js} +336 -1149
  278. package/dist/{chunk-b4twmt0s.js → chunk-rhjb0dgd.js} +24 -23
  279. package/dist/{chunk-bpmw0wp2.js → chunk-rq1nfp7x.js} +60 -58
  280. package/dist/{chunk-qhbchv06.js → chunk-rsr0mksm.js} +61 -59
  281. package/dist/{chunk-txeekahj.js → chunk-rz3rq0gt.js} +4 -6
  282. package/dist/{chunk-14mkqwft.js → chunk-rz69sqyh.js} +70 -68
  283. package/dist/{chunk-gfk81w5r.js → chunk-s2n5kxm0.js} +5 -5
  284. package/dist/{chunk-3b9ar57s.js → chunk-s39ksgef.js} +4 -6
  285. package/dist/{chunk-3er4wswe.js → chunk-s70z817q.js} +197 -196
  286. package/dist/{chunk-5h17d17z.js → chunk-se153zng.js} +1 -1
  287. package/dist/chunk-spqq5qf1.js +116 -0
  288. package/dist/{chunk-xjd32sva.js → chunk-srnstx2s.js} +23 -22
  289. package/dist/{chunk-s9nr589x.js → chunk-sv7afh51.js} +6 -8
  290. package/dist/{chunk-b6whrv9m.js → chunk-swzfr1f5.js} +24 -23
  291. package/dist/{chunk-2h06sph0.js → chunk-t2822cex.js} +63 -60
  292. package/dist/{chunk-h93tjx98.js → chunk-t2re5hhc.js} +125 -119
  293. package/dist/{chunk-r325sbz7.js → chunk-t7e9etws.js} +23 -25
  294. package/dist/{chunk-59mg8c5k.js → chunk-tnx1zk9t.js} +62 -59
  295. package/dist/{chunk-rgpxnjx4.js → chunk-tw24rz1x.js} +11 -13
  296. package/dist/{chunk-r8m19xnp.js → chunk-v038k0we.js} +4 -6
  297. package/dist/chunk-v2qqkqxp.js +116 -0
  298. package/dist/{chunk-fjne3x6c.js → chunk-v4qke3cz.js} +8 -8
  299. package/dist/{chunk-qwa5erw8.js → chunk-v6p3019x.js} +24 -23
  300. package/dist/{chunk-4stgesb0.js → chunk-vatz6gan.js} +25 -27
  301. package/dist/chunk-vfmx405p.js +14 -0
  302. package/dist/{chunk-x639j7py.js → chunk-vnn4x6jw.js} +62 -59
  303. package/dist/{chunk-b4btw5kv.js → chunk-vpe2s4eq.js} +7 -9
  304. package/dist/{chunk-2t5ve6ev.js → chunk-vsbyhpfy.js} +1 -1
  305. package/dist/{chunk-52evx0rm.js → chunk-w0pf4mvz.js} +12 -16
  306. package/dist/chunk-w5j0dhpp.js +14 -0
  307. package/dist/{chunk-vqawqpkx.js → chunk-w7zp9j8v.js} +72 -70
  308. package/dist/{chunk-d2vb6m9e.js → chunk-wd8mqz95.js} +3 -5
  309. package/dist/chunk-wj0c0zfa.js +36 -0
  310. package/dist/{chunk-ps5rsyxe.js → chunk-wqdr8v9x.js} +58 -55
  311. package/dist/{chunk-vpp13z80.js → chunk-wxa2hdfg.js} +2 -2
  312. package/dist/{chunk-kh04yrpx.js → chunk-wy3f5b81.js} +59 -56
  313. package/dist/{chunk-5dn1m1r7.js → chunk-x0ym1db4.js} +2 -4
  314. package/dist/{chunk-d73t8nhj.js → chunk-x1t80e36.js} +39 -39
  315. package/dist/{chunk-08a6n2pp.js → chunk-x63c39tp.js} +5 -7
  316. package/dist/{chunk-q890kpff.js → chunk-x6622cb2.js} +23 -22
  317. package/dist/{chunk-wcxc5m91.js → chunk-x95fhbwq.js} +1 -1
  318. package/dist/{chunk-px27vhxx.js → chunk-x9gbnheg.js} +8 -10
  319. package/dist/{chunk-9gypgvd7.js → chunk-xahpt5e2.js} +3 -5
  320. package/dist/{chunk-y3rg86fk.js → chunk-xct1m4sf.js} +23 -22
  321. package/dist/chunk-xee276gg.js +367 -0
  322. package/dist/{chunk-n8whv674.js → chunk-xfkf8q6w.js} +5 -6
  323. package/dist/chunk-xhesahm0.js +15 -0
  324. package/dist/{chunk-tbma29g4.js → chunk-xk1wdwxq.js} +60 -57
  325. package/dist/{chunk-gwah3f17.js → chunk-xpj4qca4.js} +58 -55
  326. package/dist/{chunk-h6wkvzrd.js → chunk-xqk8srdh.js} +6 -8
  327. package/dist/{chunk-39zy97qa.js → chunk-xsc3ccj0.js} +3 -3
  328. package/dist/{chunk-y82s03p7.js → chunk-xwc8e4yv.js} +2 -2
  329. package/dist/{chunk-8wv29424.js → chunk-xxmxv448.js} +8 -9
  330. package/dist/{chunk-symd8dvh.js → chunk-xz7cf7fa.js} +69 -66
  331. package/dist/{chunk-h7bkf3h2.js → chunk-y3qdyf8r.js} +28 -27
  332. package/dist/{chunk-j5eb93j4.js → chunk-y48wfwm4.js} +1 -517
  333. package/dist/{chunk-6qexrv9a.js → chunk-y7vzcjyn.js} +60 -58
  334. package/dist/chunk-yb03gvd8.js +271 -0
  335. package/dist/chunk-yem3ge7z.js +182 -0
  336. package/dist/{chunk-vmpcmvqq.js → chunk-yf5qwpnp.js} +3 -3
  337. package/dist/{chunk-awwfrm4f.js → chunk-yrnbgtk0.js} +26 -25
  338. package/dist/{chunk-64mwy58c.js → chunk-yrs92qya.js} +5 -7
  339. package/dist/{chunk-y29pdynp.js → chunk-ys6cza46.js} +7 -9
  340. package/dist/{chunk-kcp8svja.js → chunk-yvgmpc5z.js} +5 -5
  341. package/dist/{chunk-3avnvgnv.js → chunk-yxr0yf6h.js} +4 -4
  342. package/dist/{chunk-ar8awa36.js → chunk-yyc1yvnr.js} +59 -57
  343. package/dist/{chunk-kmzv85ze.js → chunk-z0vk43bt.js} +69 -66
  344. package/dist/chunk-z1seyvya.js +110 -0
  345. package/dist/{chunk-2pdcq92c.js → chunk-z6hqga26.js} +3 -4
  346. package/dist/{chunk-5ccpwbk7.js → chunk-z7hv619f.js} +58 -55
  347. package/dist/{chunk-1ez8vf1y.js → chunk-zb0mctxm.js} +6 -6
  348. package/dist/{chunk-49n22kr8.js → chunk-zhyc7npp.js} +58 -55
  349. package/dist/{chunk-9r28w6ye.js → chunk-zttmdag3.js} +1 -1
  350. package/dist/{chunk-p1af059d.js → chunk-zvegtrc4.js} +63 -60
  351. package/dist/{chunk-n2gc23dm.js → chunk-zwsrj2yy.js} +9 -11
  352. package/dist/cli.js +58 -22
  353. package/package.json +12 -4
  354. package/dist/chunk-0731m51q.js +0 -8
  355. package/dist/chunk-2fwze72g.js +0 -24
  356. package/dist/chunk-3ev51j3h.js +0 -117
  357. package/dist/chunk-5cc50ecq.js +0 -116
  358. package/dist/chunk-74v2mh4t.js +0 -40
  359. package/dist/chunk-9b0btjar.js +0 -114
  360. package/dist/chunk-bhvmpf9m.js +0 -113
  361. package/dist/chunk-bzps3qec.js +0 -113
  362. package/dist/chunk-e6nenv5n.js +0 -112
  363. package/dist/chunk-ez958w7j.js +0 -110
  364. package/dist/chunk-fve53rbk.js +0 -22
  365. package/dist/chunk-g5rf37hh.js +0 -116
  366. package/dist/chunk-ga2vcmhy.js +0 -111
  367. package/dist/chunk-k5c76pvm.js +0 -114
  368. package/dist/chunk-npf5eh3g.js +0 -8
  369. package/dist/chunk-ppwjyveh.js +0 -8
  370. package/dist/chunk-t38536jf.js +0 -254
  371. package/dist/chunk-tf8gr3bs.js +0 -112
  372. package/dist/chunk-vam5at9t.js +0 -175
  373. package/dist/chunk-vxnvzfnv.js +0 -233
  374. package/dist/chunk-wef34bk5.js +0 -107
  375. package/dist/chunk-wkjjv1jr.js +0 -1026
  376. package/dist/chunk-wkx2xsed.js +0 -113
  377. package/dist/chunk-x6r4v44b.js +0 -8
  378. package/dist/chunk-xwhmcc3g.js +0 -109
@@ -0,0 +1,3802 @@
1
+ // @bun
2
+ import {
3
+ QueryEngine
4
+ } from "./chunk-h0vzd5vg.js";
5
+ import"./chunk-cm2xfg7q.js";
6
+ import"./chunk-cnsj3vq2.js";
7
+ import"./chunk-djzvjzdg.js";
8
+ import"./chunk-rn0v1hk8.js";
9
+ import {
10
+ applySafeConfigEnvironmentVariables,
11
+ deserializeMessages,
12
+ getCommands,
13
+ getDefaultAppState,
14
+ getEmptyToolPermissionContext,
15
+ getLastSessionLog,
16
+ getModelOptions,
17
+ getTools,
18
+ init_AppStateStore,
19
+ init_Tool,
20
+ init_commands1 as init_commands,
21
+ init_conversationRecovery,
22
+ init_listSessionsImpl,
23
+ init_managedEnv,
24
+ init_modelOptions,
25
+ init_sessionStorage,
26
+ init_tools1 as init_tools,
27
+ listSessionsImpl,
28
+ sessionIdExists
29
+ } from "./chunk-c092k38b.js";
30
+ import"./chunk-m1xw79dd.js";
31
+ import"./chunk-kbsckx2r.js";
32
+ import"./chunk-qe3qr56q.js";
33
+ import"./chunk-x63c39tp.js";
34
+ import"./chunk-et824jj8.js";
35
+ import"./chunk-k81zec2p.js";
36
+ import"./chunk-var1et7e.js";
37
+ import"./chunk-8pskaz4y.js";
38
+ import"./chunk-2gzv8nrw.js";
39
+ import"./chunk-ehtwnxpg.js";
40
+ import"./chunk-a5w8nyhg.js";
41
+ import"./chunk-s2n5kxm0.js";
42
+ import"./chunk-cgfdkzhb.js";
43
+ import"./chunk-2f6hs25r.js";
44
+ import"./chunk-9datyj43.js";
45
+ import"./chunk-sv7afh51.js";
46
+ import"./chunk-j7b884wk.js";
47
+ import"./chunk-qgajfxr7.js";
48
+ import {
49
+ FileStateCache,
50
+ init_fileStateCache
51
+ } from "./chunk-zttmdag3.js";
52
+ import"./chunk-a0qhdfct.js";
53
+ import"./chunk-fz4wmnm6.js";
54
+ import"./chunk-ps49ymvj.js";
55
+ import"./chunk-chzfw06n.js";
56
+ import"./chunk-rd2884ff.js";
57
+ import"./chunk-t4kcvmes.js";
58
+ import"./chunk-jac470kz.js";
59
+ import"./chunk-h37gar4j.js";
60
+ import"./chunk-cy1z66c2.js";
61
+ import"./chunk-fnpd8cnq.js";
62
+ import"./chunk-wxa2hdfg.js";
63
+ import"./chunk-4jm600zv.js";
64
+ import"./chunk-fdbvcs34.js";
65
+ import"./chunk-f57cvf1d.js";
66
+ import"./chunk-rkmwx1yz.js";
67
+ import"./chunk-xahpt5e2.js";
68
+ import"./chunk-ykr5qx9v.js";
69
+ import"./chunk-g86dg6h5.js";
70
+ import"./chunk-2mhgyhns.js";
71
+ import"./chunk-1nhx3qpn.js";
72
+ import"./chunk-7kfps7yt.js";
73
+ import"./chunk-ad6rg8vz.js";
74
+ import"./chunk-x95fhbwq.js";
75
+ import {
76
+ enableConfigs,
77
+ getMainLoopModel,
78
+ init_config1 as init_config,
79
+ init_model
80
+ } from "./chunk-p7es39d1.js";
81
+ import"./chunk-mkae8zj9.js";
82
+ import"./chunk-cxmyg49v.js";
83
+ import"./chunk-zwarn9h7.js";
84
+ import"./chunk-hxc8e6wd.js";
85
+ import"./chunk-7hmy36fh.js";
86
+ import"./chunk-6kpbgc5w.js";
87
+ import"./chunk-d57t992t.js";
88
+ import"./chunk-64c1avct.js";
89
+ import"./chunk-0knhp7v5.js";
90
+ import"./chunk-8g5pe1gr.js";
91
+ import"./chunk-b62vj92a.js";
92
+ import"./chunk-4cp6193g.js";
93
+ import {
94
+ init_v4
95
+ } from "./chunk-8g747a8x.js";
96
+ import {
97
+ exports_external
98
+ } from "./chunk-d7886r6a.js";
99
+ import"./chunk-90wp6wez.js";
100
+ import"./chunk-a8ejc632.js";
101
+ import"./chunk-f5ma3nh5.js";
102
+ import"./chunk-qz2x630m.js";
103
+ import"./chunk-c7t69jmn.js";
104
+ import"./chunk-6y2wszkc.js";
105
+ import"./chunk-3c25bcsw.js";
106
+ import"./chunk-9qh5f9r3.js";
107
+ import"./chunk-xhesahm0.js";
108
+ import"./chunk-rh5a2rg9.js";
109
+ import"./chunk-p2816w9z.js";
110
+ import"./chunk-v9smspw2.js";
111
+ import"./chunk-v1kzp02e.js";
112
+ import"./chunk-axenqvc8.js";
113
+ import"./chunk-crmjpsqe.js";
114
+ import"./chunk-m9w972ny.js";
115
+ import"./chunk-b5wxetbv.js";
116
+ import"./chunk-h0rbjg6x.js";
117
+ import"./chunk-0vkfrmqm.js";
118
+ import"./chunk-0xjaqda8.js";
119
+ import"./chunk-78009jh9.js";
120
+ import"./chunk-9awawyvh.js";
121
+ import"./chunk-hqpzpr71.js";
122
+ import"./chunk-zs5b1dgr.js";
123
+ import"./chunk-hnxmafvc.js";
124
+ import"./chunk-tv74hgw9.js";
125
+ import"./chunk-wd8mqz95.js";
126
+ import"./chunk-8tnsngw2.js";
127
+ import"./chunk-vsbyhpfy.js";
128
+ import"./chunk-p7pj6wf8.js";
129
+ import"./chunk-5z28bqne.js";
130
+ import"./chunk-qajrkk97.js";
131
+ import"./chunk-5khwvj1z.js";
132
+ import"./chunk-fbv4apne.js";
133
+ import {
134
+ init_state,
135
+ setOriginalCwd
136
+ } from "./chunk-gzp6rza1.js";
137
+ import"./chunk-50dgek10.js";
138
+ import"./chunk-7wm5s02e.js";
139
+ import"./chunk-z0csm2zq.js";
140
+ import"./chunk-hxhwzgnn.js";
141
+ import"./chunk-qx8z601m.js";
142
+ import"./chunk-cgm6758j.js";
143
+ import"./chunk-9m27g5s1.js";
144
+ import"./chunk-8pn8tvgg.js";
145
+ import"./chunk-netzwgv1.js";
146
+ import"./chunk-qp2qdcda.js";
147
+
148
+ // node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/acp.js
149
+ init_v4();
150
+
151
+ // node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
152
+ var AGENT_METHODS = {
153
+ authenticate: "authenticate",
154
+ document_did_change: "document/didChange",
155
+ document_did_close: "document/didClose",
156
+ document_did_focus: "document/didFocus",
157
+ document_did_open: "document/didOpen",
158
+ document_did_save: "document/didSave",
159
+ initialize: "initialize",
160
+ logout: "logout",
161
+ nes_accept: "nes/accept",
162
+ nes_close: "nes/close",
163
+ nes_reject: "nes/reject",
164
+ nes_start: "nes/start",
165
+ nes_suggest: "nes/suggest",
166
+ session_cancel: "session/cancel",
167
+ session_close: "session/close",
168
+ session_fork: "session/fork",
169
+ session_list: "session/list",
170
+ session_load: "session/load",
171
+ session_new: "session/new",
172
+ session_prompt: "session/prompt",
173
+ session_resume: "session/resume",
174
+ session_set_config_option: "session/set_config_option",
175
+ session_set_mode: "session/set_mode",
176
+ session_set_model: "session/set_model"
177
+ };
178
+ var CLIENT_METHODS = {
179
+ elicitation_complete: "elicitation/complete",
180
+ elicitation_create: "elicitation/create",
181
+ fs_read_text_file: "fs/read_text_file",
182
+ fs_write_text_file: "fs/write_text_file",
183
+ session_request_permission: "session/request_permission",
184
+ session_update: "session/update",
185
+ terminal_create: "terminal/create",
186
+ terminal_kill: "terminal/kill",
187
+ terminal_output: "terminal/output",
188
+ terminal_release: "terminal/release",
189
+ terminal_wait_for_exit: "terminal/wait_for_exit"
190
+ };
191
+
192
+ // node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js
193
+ init_v4();
194
+ var zAuthCapabilities = exports_external.object({
195
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
196
+ terminal: exports_external.boolean().optional().default(false)
197
+ });
198
+ var zAuthEnvVar = exports_external.object({
199
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
200
+ label: exports_external.string().nullish(),
201
+ name: exports_external.string(),
202
+ optional: exports_external.boolean().optional().default(false),
203
+ secret: exports_external.boolean().optional().default(true)
204
+ });
205
+ var zAuthMethodAgent = exports_external.object({
206
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
207
+ description: exports_external.string().nullish(),
208
+ id: exports_external.string(),
209
+ name: exports_external.string()
210
+ });
211
+ var zAuthMethodEnvVar = exports_external.object({
212
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
213
+ description: exports_external.string().nullish(),
214
+ id: exports_external.string(),
215
+ link: exports_external.string().nullish(),
216
+ name: exports_external.string(),
217
+ vars: exports_external.array(zAuthEnvVar)
218
+ });
219
+ var zAuthMethodTerminal = exports_external.object({
220
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
221
+ args: exports_external.array(exports_external.string()).optional(),
222
+ description: exports_external.string().nullish(),
223
+ env: exports_external.record(exports_external.string(), exports_external.string()).optional(),
224
+ id: exports_external.string(),
225
+ name: exports_external.string()
226
+ });
227
+ var zAuthMethod = exports_external.union([
228
+ zAuthMethodEnvVar.and(exports_external.object({
229
+ type: exports_external.literal("env_var")
230
+ })),
231
+ zAuthMethodTerminal.and(exports_external.object({
232
+ type: exports_external.literal("terminal")
233
+ })),
234
+ zAuthMethodAgent
235
+ ]);
236
+ var zAuthenticateRequest = exports_external.object({
237
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
238
+ methodId: exports_external.string()
239
+ });
240
+ var zAuthenticateResponse = exports_external.object({
241
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
242
+ });
243
+ var zBlobResourceContents = exports_external.object({
244
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
245
+ blob: exports_external.string(),
246
+ mimeType: exports_external.string().nullish(),
247
+ uri: exports_external.string()
248
+ });
249
+ var zBooleanPropertySchema = exports_external.object({
250
+ default: exports_external.boolean().nullish(),
251
+ description: exports_external.string().nullish(),
252
+ title: exports_external.string().nullish()
253
+ });
254
+ var zCloseNesResponse = exports_external.object({
255
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
256
+ });
257
+ var zCloseSessionResponse = exports_external.object({
258
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
259
+ });
260
+ var zCost = exports_external.object({
261
+ amount: exports_external.number(),
262
+ currency: exports_external.string()
263
+ });
264
+ var zCreateTerminalResponse = exports_external.object({
265
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
266
+ terminalId: exports_external.string()
267
+ });
268
+ var zDiff = exports_external.object({
269
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
270
+ newText: exports_external.string(),
271
+ oldText: exports_external.string().nullish(),
272
+ path: exports_external.string()
273
+ });
274
+ var zElicitationContentValue = exports_external.union([
275
+ exports_external.string(),
276
+ exports_external.number(),
277
+ exports_external.number(),
278
+ exports_external.boolean(),
279
+ exports_external.array(exports_external.string())
280
+ ]);
281
+ var zElicitationAcceptAction = exports_external.object({
282
+ content: exports_external.record(exports_external.string(), zElicitationContentValue).nullish()
283
+ });
284
+ var zCreateElicitationResponse = exports_external.intersection(exports_external.union([
285
+ zElicitationAcceptAction.and(exports_external.object({
286
+ action: exports_external.literal("accept")
287
+ })),
288
+ exports_external.object({
289
+ action: exports_external.literal("decline")
290
+ }),
291
+ exports_external.object({
292
+ action: exports_external.literal("cancel")
293
+ })
294
+ ]), exports_external.object({
295
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
296
+ }));
297
+ var zElicitationFormCapabilities = exports_external.object({
298
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
299
+ });
300
+ var zElicitationId = exports_external.string();
301
+ var zCompleteElicitationNotification = exports_external.object({
302
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
303
+ elicitationId: zElicitationId
304
+ });
305
+ var zElicitationSchemaType = exports_external.literal("object");
306
+ var zElicitationStringType = exports_external.literal("string");
307
+ var zElicitationUrlCapabilities = exports_external.object({
308
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
309
+ });
310
+ var zElicitationCapabilities = exports_external.object({
311
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
312
+ form: zElicitationFormCapabilities.nullish(),
313
+ url: zElicitationUrlCapabilities.nullish()
314
+ });
315
+ var zEnumOption = exports_external.object({
316
+ const: exports_external.string(),
317
+ title: exports_external.string()
318
+ });
319
+ var zEnvVariable = exports_external.object({
320
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
321
+ name: exports_external.string(),
322
+ value: exports_external.string()
323
+ });
324
+ var zErrorCode = exports_external.union([
325
+ exports_external.literal(-32700),
326
+ exports_external.literal(-32600),
327
+ exports_external.literal(-32601),
328
+ exports_external.literal(-32602),
329
+ exports_external.literal(-32603),
330
+ exports_external.literal(-32800),
331
+ exports_external.literal(-32000),
332
+ exports_external.literal(-32002),
333
+ exports_external.literal(-32042),
334
+ exports_external.number().int().min(-2147483648, {
335
+ message: "Invalid value: Expected int32 to be >= -2147483648"
336
+ }).max(2147483647, {
337
+ message: "Invalid value: Expected int32 to be <= 2147483647"
338
+ })
339
+ ]);
340
+ var zError = exports_external.object({
341
+ code: zErrorCode,
342
+ data: exports_external.unknown().optional(),
343
+ message: exports_external.string()
344
+ });
345
+ var zExtNotification = exports_external.unknown();
346
+ var zExtRequest = exports_external.unknown();
347
+ var zExtResponse = exports_external.unknown();
348
+ var zFileSystemCapabilities = exports_external.object({
349
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
350
+ readTextFile: exports_external.boolean().optional().default(false),
351
+ writeTextFile: exports_external.boolean().optional().default(false)
352
+ });
353
+ var zHttpHeader = exports_external.object({
354
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
355
+ name: exports_external.string(),
356
+ value: exports_external.string()
357
+ });
358
+ var zImplementation = exports_external.object({
359
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
360
+ name: exports_external.string(),
361
+ title: exports_external.string().nullish(),
362
+ version: exports_external.string()
363
+ });
364
+ var zIntegerPropertySchema = exports_external.object({
365
+ default: exports_external.number().nullish(),
366
+ description: exports_external.string().nullish(),
367
+ maximum: exports_external.number().nullish(),
368
+ minimum: exports_external.number().nullish(),
369
+ title: exports_external.string().nullish()
370
+ });
371
+ var zKillTerminalResponse = exports_external.object({
372
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
373
+ });
374
+ var zListSessionsRequest = exports_external.object({
375
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
376
+ additionalDirectories: exports_external.array(exports_external.string()).optional(),
377
+ cursor: exports_external.string().nullish(),
378
+ cwd: exports_external.string().nullish()
379
+ });
380
+ var zLogoutCapabilities = exports_external.object({
381
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
382
+ });
383
+ var zAgentAuthCapabilities = exports_external.object({
384
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
385
+ logout: zLogoutCapabilities.nullish()
386
+ });
387
+ var zLogoutRequest = exports_external.object({
388
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
389
+ });
390
+ var zLogoutResponse = exports_external.object({
391
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
392
+ });
393
+ var zMcpCapabilities = exports_external.object({
394
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
395
+ http: exports_external.boolean().optional().default(false),
396
+ sse: exports_external.boolean().optional().default(false)
397
+ });
398
+ var zMcpServerHttp = exports_external.object({
399
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
400
+ headers: exports_external.array(zHttpHeader),
401
+ name: exports_external.string(),
402
+ url: exports_external.string()
403
+ });
404
+ var zMcpServerSse = exports_external.object({
405
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
406
+ headers: exports_external.array(zHttpHeader),
407
+ name: exports_external.string(),
408
+ url: exports_external.string()
409
+ });
410
+ var zMcpServerStdio = exports_external.object({
411
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
412
+ args: exports_external.array(exports_external.string()),
413
+ command: exports_external.string(),
414
+ env: exports_external.array(zEnvVariable),
415
+ name: exports_external.string()
416
+ });
417
+ var zMcpServer = exports_external.union([
418
+ zMcpServerHttp.and(exports_external.object({
419
+ type: exports_external.literal("http")
420
+ })),
421
+ zMcpServerSse.and(exports_external.object({
422
+ type: exports_external.literal("sse")
423
+ })),
424
+ zMcpServerStdio
425
+ ]);
426
+ var zModelId = exports_external.string();
427
+ var zModelInfo = exports_external.object({
428
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
429
+ description: exports_external.string().nullish(),
430
+ modelId: zModelId,
431
+ name: exports_external.string()
432
+ });
433
+ var zNesDiagnosticSeverity = exports_external.union([
434
+ exports_external.literal("error"),
435
+ exports_external.literal("warning"),
436
+ exports_external.literal("information"),
437
+ exports_external.literal("hint")
438
+ ]);
439
+ var zNesDiagnosticsCapabilities = exports_external.object({
440
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
441
+ });
442
+ var zNesDocumentDidCloseCapabilities = exports_external.object({
443
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
444
+ });
445
+ var zNesDocumentDidFocusCapabilities = exports_external.object({
446
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
447
+ });
448
+ var zNesDocumentDidOpenCapabilities = exports_external.object({
449
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
450
+ });
451
+ var zNesDocumentDidSaveCapabilities = exports_external.object({
452
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
453
+ });
454
+ var zNesEditHistoryCapabilities = exports_external.object({
455
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
456
+ maxCount: exports_external.number().int().gte(0).max(4294967295, {
457
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
458
+ }).nullish()
459
+ });
460
+ var zNesEditHistoryEntry = exports_external.object({
461
+ diff: exports_external.string(),
462
+ uri: exports_external.string()
463
+ });
464
+ var zNesExcerpt = exports_external.object({
465
+ endLine: exports_external.number().int().gte(0).max(4294967295, {
466
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
467
+ }),
468
+ startLine: exports_external.number().int().gte(0).max(4294967295, {
469
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
470
+ }),
471
+ text: exports_external.string()
472
+ });
473
+ var zNesJumpCapabilities = exports_external.object({
474
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
475
+ });
476
+ var zNesOpenFilesCapabilities = exports_external.object({
477
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
478
+ });
479
+ var zNesRecentFile = exports_external.object({
480
+ languageId: exports_external.string(),
481
+ text: exports_external.string(),
482
+ uri: exports_external.string()
483
+ });
484
+ var zNesRecentFilesCapabilities = exports_external.object({
485
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
486
+ maxCount: exports_external.number().int().gte(0).max(4294967295, {
487
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
488
+ }).nullish()
489
+ });
490
+ var zNesRejectReason = exports_external.union([
491
+ exports_external.literal("rejected"),
492
+ exports_external.literal("ignored"),
493
+ exports_external.literal("replaced"),
494
+ exports_external.literal("cancelled")
495
+ ]);
496
+ var zNesRelatedSnippet = exports_external.object({
497
+ excerpts: exports_external.array(zNesExcerpt),
498
+ uri: exports_external.string()
499
+ });
500
+ var zNesRelatedSnippetsCapabilities = exports_external.object({
501
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
502
+ });
503
+ var zNesRenameCapabilities = exports_external.object({
504
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
505
+ });
506
+ var zNesRepository = exports_external.object({
507
+ name: exports_external.string(),
508
+ owner: exports_external.string(),
509
+ remoteUrl: exports_external.string()
510
+ });
511
+ var zNesSearchAndReplaceCapabilities = exports_external.object({
512
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
513
+ });
514
+ var zClientNesCapabilities = exports_external.object({
515
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
516
+ jump: zNesJumpCapabilities.nullish(),
517
+ rename: zNesRenameCapabilities.nullish(),
518
+ searchAndReplace: zNesSearchAndReplaceCapabilities.nullish()
519
+ });
520
+ var zNesSearchAndReplaceSuggestion = exports_external.object({
521
+ id: exports_external.string(),
522
+ isRegex: exports_external.boolean().nullish(),
523
+ replace: exports_external.string(),
524
+ search: exports_external.string(),
525
+ uri: exports_external.string()
526
+ });
527
+ var zNesTriggerKind = exports_external.union([
528
+ exports_external.literal("automatic"),
529
+ exports_external.literal("diagnostic"),
530
+ exports_external.literal("manual")
531
+ ]);
532
+ var zNesUserActionsCapabilities = exports_external.object({
533
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
534
+ maxCount: exports_external.number().int().gte(0).max(4294967295, {
535
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
536
+ }).nullish()
537
+ });
538
+ var zNesContextCapabilities = exports_external.object({
539
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
540
+ diagnostics: zNesDiagnosticsCapabilities.nullish(),
541
+ editHistory: zNesEditHistoryCapabilities.nullish(),
542
+ openFiles: zNesOpenFilesCapabilities.nullish(),
543
+ recentFiles: zNesRecentFilesCapabilities.nullish(),
544
+ relatedSnippets: zNesRelatedSnippetsCapabilities.nullish(),
545
+ userActions: zNesUserActionsCapabilities.nullish()
546
+ });
547
+ var zNewSessionRequest = exports_external.object({
548
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
549
+ additionalDirectories: exports_external.array(exports_external.string()).optional(),
550
+ cwd: exports_external.string(),
551
+ mcpServers: exports_external.array(zMcpServer)
552
+ });
553
+ var zNumberPropertySchema = exports_external.object({
554
+ default: exports_external.number().nullish(),
555
+ description: exports_external.string().nullish(),
556
+ maximum: exports_external.number().nullish(),
557
+ minimum: exports_external.number().nullish(),
558
+ title: exports_external.string().nullish()
559
+ });
560
+ var zPermissionOptionId = exports_external.string();
561
+ var zPermissionOptionKind = exports_external.union([
562
+ exports_external.literal("allow_once"),
563
+ exports_external.literal("allow_always"),
564
+ exports_external.literal("reject_once"),
565
+ exports_external.literal("reject_always")
566
+ ]);
567
+ var zPermissionOption = exports_external.object({
568
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
569
+ kind: zPermissionOptionKind,
570
+ name: exports_external.string(),
571
+ optionId: zPermissionOptionId
572
+ });
573
+ var zPlanEntryPriority = exports_external.union([
574
+ exports_external.literal("high"),
575
+ exports_external.literal("medium"),
576
+ exports_external.literal("low")
577
+ ]);
578
+ var zPlanEntryStatus = exports_external.union([
579
+ exports_external.literal("pending"),
580
+ exports_external.literal("in_progress"),
581
+ exports_external.literal("completed")
582
+ ]);
583
+ var zPlanEntry = exports_external.object({
584
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
585
+ content: exports_external.string(),
586
+ priority: zPlanEntryPriority,
587
+ status: zPlanEntryStatus
588
+ });
589
+ var zPlan = exports_external.object({
590
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
591
+ entries: exports_external.array(zPlanEntry)
592
+ });
593
+ var zPosition = exports_external.object({
594
+ character: exports_external.number().int().gte(0).max(4294967295, {
595
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
596
+ }),
597
+ line: exports_external.number().int().gte(0).max(4294967295, {
598
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
599
+ })
600
+ });
601
+ var zNesJumpSuggestion = exports_external.object({
602
+ id: exports_external.string(),
603
+ position: zPosition,
604
+ uri: exports_external.string()
605
+ });
606
+ var zNesRenameSuggestion = exports_external.object({
607
+ id: exports_external.string(),
608
+ newName: exports_external.string(),
609
+ position: zPosition,
610
+ uri: exports_external.string()
611
+ });
612
+ var zNesUserAction = exports_external.object({
613
+ action: exports_external.string(),
614
+ position: zPosition,
615
+ timestampMs: exports_external.number(),
616
+ uri: exports_external.string()
617
+ });
618
+ var zPositionEncodingKind = exports_external.union([
619
+ exports_external.literal("utf-16"),
620
+ exports_external.literal("utf-32"),
621
+ exports_external.literal("utf-8")
622
+ ]);
623
+ var zClientCapabilities = exports_external.object({
624
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
625
+ auth: zAuthCapabilities.optional().default({ terminal: false }),
626
+ elicitation: zElicitationCapabilities.nullish(),
627
+ fs: zFileSystemCapabilities.optional().default({ readTextFile: false, writeTextFile: false }),
628
+ nes: zClientNesCapabilities.nullish(),
629
+ positionEncodings: exports_external.array(zPositionEncodingKind).optional(),
630
+ terminal: exports_external.boolean().optional().default(false)
631
+ });
632
+ var zPromptCapabilities = exports_external.object({
633
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
634
+ audio: exports_external.boolean().optional().default(false),
635
+ embeddedContext: exports_external.boolean().optional().default(false),
636
+ image: exports_external.boolean().optional().default(false)
637
+ });
638
+ var zProtocolVersion = exports_external.number().int().gte(0).lte(65535);
639
+ var zInitializeRequest = exports_external.object({
640
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
641
+ clientCapabilities: zClientCapabilities.optional().default({
642
+ auth: { terminal: false },
643
+ fs: { readTextFile: false, writeTextFile: false },
644
+ terminal: false
645
+ }),
646
+ clientInfo: zImplementation.nullish(),
647
+ protocolVersion: zProtocolVersion
648
+ });
649
+ var zRange = exports_external.object({
650
+ end: zPosition,
651
+ start: zPosition
652
+ });
653
+ var zNesDiagnostic = exports_external.object({
654
+ message: exports_external.string(),
655
+ range: zRange,
656
+ severity: zNesDiagnosticSeverity,
657
+ uri: exports_external.string()
658
+ });
659
+ var zNesOpenFile = exports_external.object({
660
+ languageId: exports_external.string(),
661
+ lastFocusedMs: exports_external.number().nullish(),
662
+ uri: exports_external.string(),
663
+ visibleRange: zRange.nullish()
664
+ });
665
+ var zNesSuggestContext = exports_external.object({
666
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
667
+ diagnostics: exports_external.array(zNesDiagnostic).nullish(),
668
+ editHistory: exports_external.array(zNesEditHistoryEntry).nullish(),
669
+ openFiles: exports_external.array(zNesOpenFile).nullish(),
670
+ recentFiles: exports_external.array(zNesRecentFile).nullish(),
671
+ relatedSnippets: exports_external.array(zNesRelatedSnippet).nullish(),
672
+ userActions: exports_external.array(zNesUserAction).nullish()
673
+ });
674
+ var zNesTextEdit = exports_external.object({
675
+ newText: exports_external.string(),
676
+ range: zRange
677
+ });
678
+ var zNesEditSuggestion = exports_external.object({
679
+ cursorPosition: zPosition.nullish(),
680
+ edits: exports_external.array(zNesTextEdit),
681
+ id: exports_external.string(),
682
+ uri: exports_external.string()
683
+ });
684
+ var zNesSuggestion = exports_external.union([
685
+ zNesEditSuggestion.and(exports_external.object({
686
+ kind: exports_external.literal("edit")
687
+ })),
688
+ zNesJumpSuggestion.and(exports_external.object({
689
+ kind: exports_external.literal("jump")
690
+ })),
691
+ zNesRenameSuggestion.and(exports_external.object({
692
+ kind: exports_external.literal("rename")
693
+ })),
694
+ zNesSearchAndReplaceSuggestion.and(exports_external.object({
695
+ kind: exports_external.literal("searchAndReplace")
696
+ }))
697
+ ]);
698
+ var zReadTextFileResponse = exports_external.object({
699
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
700
+ content: exports_external.string()
701
+ });
702
+ var zReleaseTerminalResponse = exports_external.object({
703
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
704
+ });
705
+ var zRequestId = exports_external.union([exports_external.number(), exports_external.string()]).nullable();
706
+ var zCancelRequestNotification = exports_external.object({
707
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
708
+ requestId: zRequestId
709
+ });
710
+ var zElicitationRequestScope = exports_external.object({
711
+ requestId: zRequestId
712
+ });
713
+ var zRole = exports_external.enum(["assistant", "user"]);
714
+ var zAnnotations = exports_external.object({
715
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
716
+ audience: exports_external.array(zRole).nullish(),
717
+ lastModified: exports_external.string().nullish(),
718
+ priority: exports_external.number().nullish()
719
+ });
720
+ var zAudioContent = exports_external.object({
721
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
722
+ annotations: zAnnotations.nullish(),
723
+ data: exports_external.string(),
724
+ mimeType: exports_external.string()
725
+ });
726
+ var zImageContent = exports_external.object({
727
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
728
+ annotations: zAnnotations.nullish(),
729
+ data: exports_external.string(),
730
+ mimeType: exports_external.string(),
731
+ uri: exports_external.string().nullish()
732
+ });
733
+ var zResourceLink = exports_external.object({
734
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
735
+ annotations: zAnnotations.nullish(),
736
+ description: exports_external.string().nullish(),
737
+ mimeType: exports_external.string().nullish(),
738
+ name: exports_external.string(),
739
+ size: exports_external.number().nullish(),
740
+ title: exports_external.string().nullish(),
741
+ uri: exports_external.string()
742
+ });
743
+ var zSelectedPermissionOutcome = exports_external.object({
744
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
745
+ optionId: zPermissionOptionId
746
+ });
747
+ var zRequestPermissionOutcome = exports_external.union([
748
+ exports_external.object({
749
+ outcome: exports_external.literal("cancelled")
750
+ }),
751
+ zSelectedPermissionOutcome.and(exports_external.object({
752
+ outcome: exports_external.literal("selected")
753
+ }))
754
+ ]);
755
+ var zRequestPermissionResponse = exports_external.object({
756
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
757
+ outcome: zRequestPermissionOutcome
758
+ });
759
+ var zSessionAdditionalDirectoriesCapabilities = exports_external.object({
760
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
761
+ });
762
+ var zSessionCloseCapabilities = exports_external.object({
763
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
764
+ });
765
+ var zSessionConfigBoolean = exports_external.object({
766
+ currentValue: exports_external.boolean()
767
+ });
768
+ var zSessionConfigGroupId = exports_external.string();
769
+ var zSessionConfigId = exports_external.string();
770
+ var zSessionConfigOptionCategory = exports_external.union([
771
+ exports_external.literal("mode"),
772
+ exports_external.literal("model"),
773
+ exports_external.literal("thought_level"),
774
+ exports_external.string()
775
+ ]);
776
+ var zSessionConfigValueId = exports_external.string();
777
+ var zSessionConfigSelectOption = exports_external.object({
778
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
779
+ description: exports_external.string().nullish(),
780
+ name: exports_external.string(),
781
+ value: zSessionConfigValueId
782
+ });
783
+ var zSessionConfigSelectGroup = exports_external.object({
784
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
785
+ group: zSessionConfigGroupId,
786
+ name: exports_external.string(),
787
+ options: exports_external.array(zSessionConfigSelectOption)
788
+ });
789
+ var zSessionConfigSelectOptions = exports_external.union([
790
+ exports_external.array(zSessionConfigSelectOption),
791
+ exports_external.array(zSessionConfigSelectGroup)
792
+ ]);
793
+ var zSessionConfigSelect = exports_external.object({
794
+ currentValue: zSessionConfigValueId,
795
+ options: zSessionConfigSelectOptions
796
+ });
797
+ var zSessionConfigOption = exports_external.intersection(exports_external.union([
798
+ zSessionConfigSelect.and(exports_external.object({
799
+ type: exports_external.literal("select")
800
+ })),
801
+ zSessionConfigBoolean.and(exports_external.object({
802
+ type: exports_external.literal("boolean")
803
+ }))
804
+ ]), exports_external.object({
805
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
806
+ category: zSessionConfigOptionCategory.nullish(),
807
+ description: exports_external.string().nullish(),
808
+ id: zSessionConfigId,
809
+ name: exports_external.string()
810
+ }));
811
+ var zConfigOptionUpdate = exports_external.object({
812
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
813
+ configOptions: exports_external.array(zSessionConfigOption)
814
+ });
815
+ var zSessionForkCapabilities = exports_external.object({
816
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
817
+ });
818
+ var zSessionId = exports_external.string();
819
+ var zAcceptNesNotification = exports_external.object({
820
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
821
+ id: exports_external.string(),
822
+ sessionId: zSessionId
823
+ });
824
+ var zCancelNotification = exports_external.object({
825
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
826
+ sessionId: zSessionId
827
+ });
828
+ var zCloseNesRequest = exports_external.object({
829
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
830
+ sessionId: zSessionId
831
+ });
832
+ var zCloseSessionRequest = exports_external.object({
833
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
834
+ sessionId: zSessionId
835
+ });
836
+ var zCreateTerminalRequest = exports_external.object({
837
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
838
+ args: exports_external.array(exports_external.string()).optional(),
839
+ command: exports_external.string(),
840
+ cwd: exports_external.string().nullish(),
841
+ env: exports_external.array(zEnvVariable).optional(),
842
+ outputByteLimit: exports_external.number().nullish(),
843
+ sessionId: zSessionId
844
+ });
845
+ var zDidCloseDocumentNotification = exports_external.object({
846
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
847
+ sessionId: zSessionId,
848
+ uri: exports_external.string()
849
+ });
850
+ var zDidFocusDocumentNotification = exports_external.object({
851
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
852
+ position: zPosition,
853
+ sessionId: zSessionId,
854
+ uri: exports_external.string(),
855
+ version: exports_external.number(),
856
+ visibleRange: zRange
857
+ });
858
+ var zDidOpenDocumentNotification = exports_external.object({
859
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
860
+ languageId: exports_external.string(),
861
+ sessionId: zSessionId,
862
+ text: exports_external.string(),
863
+ uri: exports_external.string(),
864
+ version: exports_external.number()
865
+ });
866
+ var zDidSaveDocumentNotification = exports_external.object({
867
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
868
+ sessionId: zSessionId,
869
+ uri: exports_external.string()
870
+ });
871
+ var zForkSessionRequest = exports_external.object({
872
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
873
+ additionalDirectories: exports_external.array(exports_external.string()).optional(),
874
+ cwd: exports_external.string(),
875
+ mcpServers: exports_external.array(zMcpServer).optional(),
876
+ sessionId: zSessionId
877
+ });
878
+ var zKillTerminalRequest = exports_external.object({
879
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
880
+ sessionId: zSessionId,
881
+ terminalId: exports_external.string()
882
+ });
883
+ var zLoadSessionRequest = exports_external.object({
884
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
885
+ additionalDirectories: exports_external.array(exports_external.string()).optional(),
886
+ cwd: exports_external.string(),
887
+ mcpServers: exports_external.array(zMcpServer),
888
+ sessionId: zSessionId
889
+ });
890
+ var zReadTextFileRequest = exports_external.object({
891
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
892
+ limit: exports_external.number().int().gte(0).max(4294967295, {
893
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
894
+ }).nullish(),
895
+ line: exports_external.number().int().gte(0).max(4294967295, {
896
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
897
+ }).nullish(),
898
+ path: exports_external.string(),
899
+ sessionId: zSessionId
900
+ });
901
+ var zRejectNesNotification = exports_external.object({
902
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
903
+ id: exports_external.string(),
904
+ reason: zNesRejectReason.nullish(),
905
+ sessionId: zSessionId
906
+ });
907
+ var zReleaseTerminalRequest = exports_external.object({
908
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
909
+ sessionId: zSessionId,
910
+ terminalId: exports_external.string()
911
+ });
912
+ var zResumeSessionRequest = exports_external.object({
913
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
914
+ additionalDirectories: exports_external.array(exports_external.string()).optional(),
915
+ cwd: exports_external.string(),
916
+ mcpServers: exports_external.array(zMcpServer).optional(),
917
+ sessionId: zSessionId
918
+ });
919
+ var zSessionInfo = exports_external.object({
920
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
921
+ additionalDirectories: exports_external.array(exports_external.string()).optional(),
922
+ cwd: exports_external.string(),
923
+ sessionId: zSessionId,
924
+ title: exports_external.string().nullish(),
925
+ updatedAt: exports_external.string().nullish()
926
+ });
927
+ var zListSessionsResponse = exports_external.object({
928
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
929
+ nextCursor: exports_external.string().nullish(),
930
+ sessions: exports_external.array(zSessionInfo)
931
+ });
932
+ var zSessionInfoUpdate = exports_external.object({
933
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
934
+ title: exports_external.string().nullish(),
935
+ updatedAt: exports_external.string().nullish()
936
+ });
937
+ var zSessionListCapabilities = exports_external.object({
938
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
939
+ });
940
+ var zSessionModeId = exports_external.string();
941
+ var zCurrentModeUpdate = exports_external.object({
942
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
943
+ currentModeId: zSessionModeId
944
+ });
945
+ var zSessionMode = exports_external.object({
946
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
947
+ description: exports_external.string().nullish(),
948
+ id: zSessionModeId,
949
+ name: exports_external.string()
950
+ });
951
+ var zSessionModeState = exports_external.object({
952
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
953
+ availableModes: exports_external.array(zSessionMode),
954
+ currentModeId: zSessionModeId
955
+ });
956
+ var zSessionModelState = exports_external.object({
957
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
958
+ availableModels: exports_external.array(zModelInfo),
959
+ currentModelId: zModelId
960
+ });
961
+ var zForkSessionResponse = exports_external.object({
962
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
963
+ configOptions: exports_external.array(zSessionConfigOption).nullish(),
964
+ models: zSessionModelState.nullish(),
965
+ modes: zSessionModeState.nullish(),
966
+ sessionId: zSessionId
967
+ });
968
+ var zLoadSessionResponse = exports_external.object({
969
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
970
+ configOptions: exports_external.array(zSessionConfigOption).nullish(),
971
+ models: zSessionModelState.nullish(),
972
+ modes: zSessionModeState.nullish()
973
+ });
974
+ var zNewSessionResponse = exports_external.object({
975
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
976
+ configOptions: exports_external.array(zSessionConfigOption).nullish(),
977
+ models: zSessionModelState.nullish(),
978
+ modes: zSessionModeState.nullish(),
979
+ sessionId: zSessionId
980
+ });
981
+ var zResumeSessionResponse = exports_external.object({
982
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
983
+ configOptions: exports_external.array(zSessionConfigOption).nullish(),
984
+ models: zSessionModelState.nullish(),
985
+ modes: zSessionModeState.nullish()
986
+ });
987
+ var zSessionResumeCapabilities = exports_external.object({
988
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
989
+ });
990
+ var zSessionCapabilities = exports_external.object({
991
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
992
+ additionalDirectories: zSessionAdditionalDirectoriesCapabilities.nullish(),
993
+ close: zSessionCloseCapabilities.nullish(),
994
+ fork: zSessionForkCapabilities.nullish(),
995
+ list: zSessionListCapabilities.nullish(),
996
+ resume: zSessionResumeCapabilities.nullish()
997
+ });
998
+ var zSetSessionConfigOptionRequest = exports_external.intersection(exports_external.union([
999
+ exports_external.object({
1000
+ type: exports_external.literal("boolean"),
1001
+ value: exports_external.boolean()
1002
+ }),
1003
+ exports_external.object({
1004
+ value: zSessionConfigValueId
1005
+ })
1006
+ ]), exports_external.object({
1007
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1008
+ configId: zSessionConfigId,
1009
+ sessionId: zSessionId
1010
+ }));
1011
+ var zSetSessionConfigOptionResponse = exports_external.object({
1012
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1013
+ configOptions: exports_external.array(zSessionConfigOption)
1014
+ });
1015
+ var zSetSessionModeRequest = exports_external.object({
1016
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1017
+ modeId: zSessionModeId,
1018
+ sessionId: zSessionId
1019
+ });
1020
+ var zSetSessionModeResponse = exports_external.object({
1021
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
1022
+ });
1023
+ var zSetSessionModelRequest = exports_external.object({
1024
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1025
+ modelId: zModelId,
1026
+ sessionId: zSessionId
1027
+ });
1028
+ var zSetSessionModelResponse = exports_external.object({
1029
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
1030
+ });
1031
+ var zStartNesResponse = exports_external.object({
1032
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1033
+ sessionId: zSessionId
1034
+ });
1035
+ var zStopReason = exports_external.union([
1036
+ exports_external.literal("end_turn"),
1037
+ exports_external.literal("max_tokens"),
1038
+ exports_external.literal("max_turn_requests"),
1039
+ exports_external.literal("refusal"),
1040
+ exports_external.literal("cancelled")
1041
+ ]);
1042
+ var zStringFormat = exports_external.union([
1043
+ exports_external.literal("email"),
1044
+ exports_external.literal("uri"),
1045
+ exports_external.literal("date"),
1046
+ exports_external.literal("date-time")
1047
+ ]);
1048
+ var zStringPropertySchema = exports_external.object({
1049
+ default: exports_external.string().nullish(),
1050
+ description: exports_external.string().nullish(),
1051
+ enum: exports_external.array(exports_external.string()).nullish(),
1052
+ format: zStringFormat.nullish(),
1053
+ maxLength: exports_external.number().int().gte(0).max(4294967295, {
1054
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
1055
+ }).nullish(),
1056
+ minLength: exports_external.number().int().gte(0).max(4294967295, {
1057
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
1058
+ }).nullish(),
1059
+ oneOf: exports_external.array(zEnumOption).nullish(),
1060
+ pattern: exports_external.string().nullish(),
1061
+ title: exports_external.string().nullish()
1062
+ });
1063
+ var zSuggestNesRequest = exports_external.object({
1064
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1065
+ context: zNesSuggestContext.nullish(),
1066
+ position: zPosition,
1067
+ selection: zRange.nullish(),
1068
+ sessionId: zSessionId,
1069
+ triggerKind: zNesTriggerKind,
1070
+ uri: exports_external.string(),
1071
+ version: exports_external.number()
1072
+ });
1073
+ var zSuggestNesResponse = exports_external.object({
1074
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1075
+ suggestions: exports_external.array(zNesSuggestion)
1076
+ });
1077
+ var zTerminal = exports_external.object({
1078
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1079
+ terminalId: exports_external.string()
1080
+ });
1081
+ var zTerminalExitStatus = exports_external.object({
1082
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1083
+ exitCode: exports_external.number().int().gte(0).max(4294967295, {
1084
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
1085
+ }).nullish(),
1086
+ signal: exports_external.string().nullish()
1087
+ });
1088
+ var zTerminalOutputRequest = exports_external.object({
1089
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1090
+ sessionId: zSessionId,
1091
+ terminalId: exports_external.string()
1092
+ });
1093
+ var zTerminalOutputResponse = exports_external.object({
1094
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1095
+ exitStatus: zTerminalExitStatus.nullish(),
1096
+ output: exports_external.string(),
1097
+ truncated: exports_external.boolean()
1098
+ });
1099
+ var zTextContent = exports_external.object({
1100
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1101
+ annotations: zAnnotations.nullish(),
1102
+ text: exports_external.string()
1103
+ });
1104
+ var zTextDocumentContentChangeEvent = exports_external.object({
1105
+ range: zRange.nullish(),
1106
+ text: exports_external.string()
1107
+ });
1108
+ var zDidChangeDocumentNotification = exports_external.object({
1109
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1110
+ contentChanges: exports_external.array(zTextDocumentContentChangeEvent),
1111
+ sessionId: zSessionId,
1112
+ uri: exports_external.string(),
1113
+ version: exports_external.number()
1114
+ });
1115
+ var zClientNotification = exports_external.object({
1116
+ method: exports_external.string(),
1117
+ params: exports_external.union([
1118
+ zCancelNotification,
1119
+ zDidOpenDocumentNotification,
1120
+ zDidChangeDocumentNotification,
1121
+ zDidCloseDocumentNotification,
1122
+ zDidSaveDocumentNotification,
1123
+ zDidFocusDocumentNotification,
1124
+ zAcceptNesNotification,
1125
+ zRejectNesNotification,
1126
+ zExtNotification
1127
+ ]).nullish()
1128
+ });
1129
+ var zTextDocumentSyncKind = exports_external.union([
1130
+ exports_external.literal("full"),
1131
+ exports_external.literal("incremental")
1132
+ ]);
1133
+ var zNesDocumentDidChangeCapabilities = exports_external.object({
1134
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1135
+ syncKind: zTextDocumentSyncKind
1136
+ });
1137
+ var zNesDocumentEventCapabilities = exports_external.object({
1138
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1139
+ didChange: zNesDocumentDidChangeCapabilities.nullish(),
1140
+ didClose: zNesDocumentDidCloseCapabilities.nullish(),
1141
+ didFocus: zNesDocumentDidFocusCapabilities.nullish(),
1142
+ didOpen: zNesDocumentDidOpenCapabilities.nullish(),
1143
+ didSave: zNesDocumentDidSaveCapabilities.nullish()
1144
+ });
1145
+ var zNesEventCapabilities = exports_external.object({
1146
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1147
+ document: zNesDocumentEventCapabilities.nullish()
1148
+ });
1149
+ var zNesCapabilities = exports_external.object({
1150
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1151
+ context: zNesContextCapabilities.nullish(),
1152
+ events: zNesEventCapabilities.nullish()
1153
+ });
1154
+ var zAgentCapabilities = exports_external.object({
1155
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1156
+ auth: zAgentAuthCapabilities.optional().default({}),
1157
+ loadSession: exports_external.boolean().optional().default(false),
1158
+ mcpCapabilities: zMcpCapabilities.optional().default({ http: false, sse: false }),
1159
+ nes: zNesCapabilities.nullish(),
1160
+ positionEncoding: zPositionEncodingKind.nullish(),
1161
+ promptCapabilities: zPromptCapabilities.optional().default({
1162
+ audio: false,
1163
+ embeddedContext: false,
1164
+ image: false
1165
+ }),
1166
+ sessionCapabilities: zSessionCapabilities.optional().default({})
1167
+ });
1168
+ var zInitializeResponse = exports_external.object({
1169
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1170
+ agentCapabilities: zAgentCapabilities.optional().default({
1171
+ auth: {},
1172
+ loadSession: false,
1173
+ mcpCapabilities: { http: false, sse: false },
1174
+ promptCapabilities: {
1175
+ audio: false,
1176
+ embeddedContext: false,
1177
+ image: false
1178
+ },
1179
+ sessionCapabilities: {}
1180
+ }),
1181
+ agentInfo: zImplementation.nullish(),
1182
+ authMethods: exports_external.array(zAuthMethod).optional().default([]),
1183
+ protocolVersion: zProtocolVersion
1184
+ });
1185
+ var zTextResourceContents = exports_external.object({
1186
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1187
+ mimeType: exports_external.string().nullish(),
1188
+ text: exports_external.string(),
1189
+ uri: exports_external.string()
1190
+ });
1191
+ var zEmbeddedResourceResource = exports_external.union([
1192
+ zTextResourceContents,
1193
+ zBlobResourceContents
1194
+ ]);
1195
+ var zEmbeddedResource = exports_external.object({
1196
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1197
+ annotations: zAnnotations.nullish(),
1198
+ resource: zEmbeddedResourceResource
1199
+ });
1200
+ var zContentBlock = exports_external.union([
1201
+ zTextContent.and(exports_external.object({
1202
+ type: exports_external.literal("text")
1203
+ })),
1204
+ zImageContent.and(exports_external.object({
1205
+ type: exports_external.literal("image")
1206
+ })),
1207
+ zAudioContent.and(exports_external.object({
1208
+ type: exports_external.literal("audio")
1209
+ })),
1210
+ zResourceLink.and(exports_external.object({
1211
+ type: exports_external.literal("resource_link")
1212
+ })),
1213
+ zEmbeddedResource.and(exports_external.object({
1214
+ type: exports_external.literal("resource")
1215
+ }))
1216
+ ]);
1217
+ var zContent = exports_external.object({
1218
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1219
+ content: zContentBlock
1220
+ });
1221
+ var zContentChunk = exports_external.object({
1222
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1223
+ content: zContentBlock,
1224
+ messageId: exports_external.string().nullish()
1225
+ });
1226
+ var zPromptRequest = exports_external.object({
1227
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1228
+ messageId: exports_external.string().nullish(),
1229
+ prompt: exports_external.array(zContentBlock),
1230
+ sessionId: zSessionId
1231
+ });
1232
+ var zTitledMultiSelectItems = exports_external.object({
1233
+ anyOf: exports_external.array(zEnumOption)
1234
+ });
1235
+ var zToolCallContent = exports_external.union([
1236
+ zContent.and(exports_external.object({
1237
+ type: exports_external.literal("content")
1238
+ })),
1239
+ zDiff.and(exports_external.object({
1240
+ type: exports_external.literal("diff")
1241
+ })),
1242
+ zTerminal.and(exports_external.object({
1243
+ type: exports_external.literal("terminal")
1244
+ }))
1245
+ ]);
1246
+ var zToolCallId = exports_external.string();
1247
+ var zElicitationSessionScope = exports_external.object({
1248
+ sessionId: zSessionId,
1249
+ toolCallId: zToolCallId.nullish()
1250
+ });
1251
+ var zElicitationUrlMode = exports_external.intersection(exports_external.union([zElicitationSessionScope, zElicitationRequestScope]), exports_external.object({
1252
+ elicitationId: zElicitationId,
1253
+ url: exports_external.string().url()
1254
+ }));
1255
+ var zToolCallLocation = exports_external.object({
1256
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1257
+ line: exports_external.number().int().gte(0).max(4294967295, {
1258
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
1259
+ }).nullish(),
1260
+ path: exports_external.string()
1261
+ });
1262
+ var zToolCallStatus = exports_external.union([
1263
+ exports_external.literal("pending"),
1264
+ exports_external.literal("in_progress"),
1265
+ exports_external.literal("completed"),
1266
+ exports_external.literal("failed")
1267
+ ]);
1268
+ var zToolKind = exports_external.union([
1269
+ exports_external.literal("read"),
1270
+ exports_external.literal("edit"),
1271
+ exports_external.literal("delete"),
1272
+ exports_external.literal("move"),
1273
+ exports_external.literal("search"),
1274
+ exports_external.literal("execute"),
1275
+ exports_external.literal("think"),
1276
+ exports_external.literal("fetch"),
1277
+ exports_external.literal("switch_mode"),
1278
+ exports_external.literal("other")
1279
+ ]);
1280
+ var zToolCall = exports_external.object({
1281
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1282
+ content: exports_external.array(zToolCallContent).optional(),
1283
+ kind: zToolKind.optional(),
1284
+ locations: exports_external.array(zToolCallLocation).optional(),
1285
+ rawInput: exports_external.unknown().optional(),
1286
+ rawOutput: exports_external.unknown().optional(),
1287
+ status: zToolCallStatus.optional(),
1288
+ title: exports_external.string(),
1289
+ toolCallId: zToolCallId
1290
+ });
1291
+ var zToolCallUpdate = exports_external.object({
1292
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1293
+ content: exports_external.array(zToolCallContent).nullish(),
1294
+ kind: zToolKind.nullish(),
1295
+ locations: exports_external.array(zToolCallLocation).nullish(),
1296
+ rawInput: exports_external.unknown().optional(),
1297
+ rawOutput: exports_external.unknown().optional(),
1298
+ status: zToolCallStatus.nullish(),
1299
+ title: exports_external.string().nullish(),
1300
+ toolCallId: zToolCallId
1301
+ });
1302
+ var zRequestPermissionRequest = exports_external.object({
1303
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1304
+ options: exports_external.array(zPermissionOption),
1305
+ sessionId: zSessionId,
1306
+ toolCall: zToolCallUpdate
1307
+ });
1308
+ var zUnstructuredCommandInput = exports_external.object({
1309
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1310
+ hint: exports_external.string()
1311
+ });
1312
+ var zAvailableCommandInput = zUnstructuredCommandInput;
1313
+ var zAvailableCommand = exports_external.object({
1314
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1315
+ description: exports_external.string(),
1316
+ input: zAvailableCommandInput.nullish(),
1317
+ name: exports_external.string()
1318
+ });
1319
+ var zAvailableCommandsUpdate = exports_external.object({
1320
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1321
+ availableCommands: exports_external.array(zAvailableCommand)
1322
+ });
1323
+ var zUntitledMultiSelectItems = exports_external.object({
1324
+ enum: exports_external.array(exports_external.string()),
1325
+ type: zElicitationStringType
1326
+ });
1327
+ var zMultiSelectItems = exports_external.union([
1328
+ zUntitledMultiSelectItems,
1329
+ zTitledMultiSelectItems
1330
+ ]);
1331
+ var zMultiSelectPropertySchema = exports_external.object({
1332
+ default: exports_external.array(exports_external.string()).nullish(),
1333
+ description: exports_external.string().nullish(),
1334
+ items: zMultiSelectItems,
1335
+ maxItems: exports_external.number().nullish(),
1336
+ minItems: exports_external.number().nullish(),
1337
+ title: exports_external.string().nullish()
1338
+ });
1339
+ var zElicitationPropertySchema = exports_external.union([
1340
+ zStringPropertySchema.and(exports_external.object({
1341
+ type: exports_external.literal("string")
1342
+ })),
1343
+ zNumberPropertySchema.and(exports_external.object({
1344
+ type: exports_external.literal("number")
1345
+ })),
1346
+ zIntegerPropertySchema.and(exports_external.object({
1347
+ type: exports_external.literal("integer")
1348
+ })),
1349
+ zBooleanPropertySchema.and(exports_external.object({
1350
+ type: exports_external.literal("boolean")
1351
+ })),
1352
+ zMultiSelectPropertySchema.and(exports_external.object({
1353
+ type: exports_external.literal("array")
1354
+ }))
1355
+ ]);
1356
+ var zElicitationSchema = exports_external.object({
1357
+ description: exports_external.string().nullish(),
1358
+ properties: exports_external.record(exports_external.string(), zElicitationPropertySchema).optional().default({}),
1359
+ required: exports_external.array(exports_external.string()).nullish(),
1360
+ title: exports_external.string().nullish(),
1361
+ type: zElicitationSchemaType.optional().default("object")
1362
+ });
1363
+ var zElicitationFormMode = exports_external.intersection(exports_external.union([zElicitationSessionScope, zElicitationRequestScope]), exports_external.object({
1364
+ requestedSchema: zElicitationSchema
1365
+ }));
1366
+ var zCreateElicitationRequest = exports_external.intersection(exports_external.union([
1367
+ zElicitationFormMode.and(exports_external.object({
1368
+ mode: exports_external.literal("form")
1369
+ })),
1370
+ zElicitationUrlMode.and(exports_external.object({
1371
+ mode: exports_external.literal("url")
1372
+ }))
1373
+ ]), exports_external.object({
1374
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1375
+ message: exports_external.string()
1376
+ }));
1377
+ var zUsage = exports_external.object({
1378
+ cachedReadTokens: exports_external.number().nullish(),
1379
+ cachedWriteTokens: exports_external.number().nullish(),
1380
+ inputTokens: exports_external.number(),
1381
+ outputTokens: exports_external.number(),
1382
+ thoughtTokens: exports_external.number().nullish(),
1383
+ totalTokens: exports_external.number()
1384
+ });
1385
+ var zPromptResponse = exports_external.object({
1386
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1387
+ stopReason: zStopReason,
1388
+ usage: zUsage.nullish(),
1389
+ userMessageId: exports_external.string().nullish()
1390
+ });
1391
+ var zAgentResponse = exports_external.union([
1392
+ exports_external.object({
1393
+ id: zRequestId,
1394
+ result: exports_external.union([
1395
+ zInitializeResponse,
1396
+ zAuthenticateResponse,
1397
+ zLogoutResponse,
1398
+ zNewSessionResponse,
1399
+ zLoadSessionResponse,
1400
+ zListSessionsResponse,
1401
+ zForkSessionResponse,
1402
+ zResumeSessionResponse,
1403
+ zCloseSessionResponse,
1404
+ zSetSessionModeResponse,
1405
+ zSetSessionConfigOptionResponse,
1406
+ zPromptResponse,
1407
+ zSetSessionModelResponse,
1408
+ zStartNesResponse,
1409
+ zSuggestNesResponse,
1410
+ zCloseNesResponse,
1411
+ zExtResponse
1412
+ ])
1413
+ }),
1414
+ exports_external.object({
1415
+ error: zError,
1416
+ id: zRequestId
1417
+ })
1418
+ ]);
1419
+ var zUsageUpdate = exports_external.object({
1420
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1421
+ cost: zCost.nullish(),
1422
+ size: exports_external.number(),
1423
+ used: exports_external.number()
1424
+ });
1425
+ var zSessionUpdate = exports_external.union([
1426
+ zContentChunk.and(exports_external.object({
1427
+ sessionUpdate: exports_external.literal("user_message_chunk")
1428
+ })),
1429
+ zContentChunk.and(exports_external.object({
1430
+ sessionUpdate: exports_external.literal("agent_message_chunk")
1431
+ })),
1432
+ zContentChunk.and(exports_external.object({
1433
+ sessionUpdate: exports_external.literal("agent_thought_chunk")
1434
+ })),
1435
+ zToolCall.and(exports_external.object({
1436
+ sessionUpdate: exports_external.literal("tool_call")
1437
+ })),
1438
+ zToolCallUpdate.and(exports_external.object({
1439
+ sessionUpdate: exports_external.literal("tool_call_update")
1440
+ })),
1441
+ zPlan.and(exports_external.object({
1442
+ sessionUpdate: exports_external.literal("plan")
1443
+ })),
1444
+ zAvailableCommandsUpdate.and(exports_external.object({
1445
+ sessionUpdate: exports_external.literal("available_commands_update")
1446
+ })),
1447
+ zCurrentModeUpdate.and(exports_external.object({
1448
+ sessionUpdate: exports_external.literal("current_mode_update")
1449
+ })),
1450
+ zConfigOptionUpdate.and(exports_external.object({
1451
+ sessionUpdate: exports_external.literal("config_option_update")
1452
+ })),
1453
+ zSessionInfoUpdate.and(exports_external.object({
1454
+ sessionUpdate: exports_external.literal("session_info_update")
1455
+ })),
1456
+ zUsageUpdate.and(exports_external.object({
1457
+ sessionUpdate: exports_external.literal("usage_update")
1458
+ }))
1459
+ ]);
1460
+ var zSessionNotification = exports_external.object({
1461
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1462
+ sessionId: zSessionId,
1463
+ update: zSessionUpdate
1464
+ });
1465
+ var zAgentNotification = exports_external.object({
1466
+ method: exports_external.string(),
1467
+ params: exports_external.union([
1468
+ zSessionNotification,
1469
+ zCompleteElicitationNotification,
1470
+ zExtNotification
1471
+ ]).nullish()
1472
+ });
1473
+ var zWaitForTerminalExitRequest = exports_external.object({
1474
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1475
+ sessionId: zSessionId,
1476
+ terminalId: exports_external.string()
1477
+ });
1478
+ var zWaitForTerminalExitResponse = exports_external.object({
1479
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1480
+ exitCode: exports_external.number().int().gte(0).max(4294967295, {
1481
+ message: "Invalid value: Expected uint32 to be <= 4294967295"
1482
+ }).nullish(),
1483
+ signal: exports_external.string().nullish()
1484
+ });
1485
+ var zWorkspaceFolder = exports_external.object({
1486
+ name: exports_external.string(),
1487
+ uri: exports_external.string()
1488
+ });
1489
+ var zStartNesRequest = exports_external.object({
1490
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1491
+ repository: zNesRepository.nullish(),
1492
+ workspaceFolders: exports_external.array(zWorkspaceFolder).nullish(),
1493
+ workspaceUri: exports_external.string().nullish()
1494
+ });
1495
+ var zClientRequest = exports_external.object({
1496
+ id: zRequestId,
1497
+ method: exports_external.string(),
1498
+ params: exports_external.union([
1499
+ zInitializeRequest,
1500
+ zAuthenticateRequest,
1501
+ zLogoutRequest,
1502
+ zNewSessionRequest,
1503
+ zLoadSessionRequest,
1504
+ zListSessionsRequest,
1505
+ zForkSessionRequest,
1506
+ zResumeSessionRequest,
1507
+ zCloseSessionRequest,
1508
+ zSetSessionModeRequest,
1509
+ zSetSessionConfigOptionRequest,
1510
+ zPromptRequest,
1511
+ zSetSessionModelRequest,
1512
+ zStartNesRequest,
1513
+ zSuggestNesRequest,
1514
+ zCloseNesRequest,
1515
+ zExtRequest
1516
+ ]).nullish()
1517
+ });
1518
+ var zWriteTextFileRequest = exports_external.object({
1519
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
1520
+ content: exports_external.string(),
1521
+ path: exports_external.string(),
1522
+ sessionId: zSessionId
1523
+ });
1524
+ var zAgentRequest = exports_external.object({
1525
+ id: zRequestId,
1526
+ method: exports_external.string(),
1527
+ params: exports_external.union([
1528
+ zWriteTextFileRequest,
1529
+ zReadTextFileRequest,
1530
+ zRequestPermissionRequest,
1531
+ zCreateTerminalRequest,
1532
+ zTerminalOutputRequest,
1533
+ zReleaseTerminalRequest,
1534
+ zWaitForTerminalExitRequest,
1535
+ zKillTerminalRequest,
1536
+ zCreateElicitationRequest,
1537
+ zExtRequest
1538
+ ]).nullish()
1539
+ });
1540
+ var zWriteTextFileResponse = exports_external.object({
1541
+ _meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
1542
+ });
1543
+ var zClientResponse = exports_external.union([
1544
+ exports_external.object({
1545
+ id: zRequestId,
1546
+ result: exports_external.union([
1547
+ zWriteTextFileResponse,
1548
+ zReadTextFileResponse,
1549
+ zRequestPermissionResponse,
1550
+ zCreateTerminalResponse,
1551
+ zTerminalOutputResponse,
1552
+ zReleaseTerminalResponse,
1553
+ zWaitForTerminalExitResponse,
1554
+ zKillTerminalResponse,
1555
+ zCreateElicitationResponse,
1556
+ zExtResponse
1557
+ ])
1558
+ }),
1559
+ exports_external.object({
1560
+ error: zError,
1561
+ id: zRequestId
1562
+ })
1563
+ ]);
1564
+ // node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/stream.js
1565
+ function ndJsonStream(output, input) {
1566
+ const textEncoder = new TextEncoder;
1567
+ const textDecoder = new TextDecoder;
1568
+ const readable = new ReadableStream({
1569
+ async start(controller) {
1570
+ let content = "";
1571
+ const reader = input.getReader();
1572
+ try {
1573
+ while (true) {
1574
+ const { value, done } = await reader.read();
1575
+ if (done) {
1576
+ break;
1577
+ }
1578
+ if (!value) {
1579
+ continue;
1580
+ }
1581
+ content += textDecoder.decode(value, { stream: true });
1582
+ const lines = content.split(`
1583
+ `);
1584
+ content = lines.pop() || "";
1585
+ for (const line of lines) {
1586
+ const trimmedLine = line.trim();
1587
+ if (trimmedLine) {
1588
+ try {
1589
+ const message = JSON.parse(trimmedLine);
1590
+ controller.enqueue(message);
1591
+ } catch (err) {
1592
+ console.error("Failed to parse JSON message:", trimmedLine, err);
1593
+ }
1594
+ }
1595
+ }
1596
+ }
1597
+ } catch (err) {
1598
+ controller.error(err);
1599
+ return;
1600
+ } finally {
1601
+ reader.releaseLock();
1602
+ }
1603
+ controller.close();
1604
+ }
1605
+ });
1606
+ const writable = new WritableStream({
1607
+ async write(message) {
1608
+ const content = JSON.stringify(message) + `
1609
+ `;
1610
+ const writer = output.getWriter();
1611
+ try {
1612
+ await writer.write(textEncoder.encode(content));
1613
+ } finally {
1614
+ writer.releaseLock();
1615
+ }
1616
+ }
1617
+ });
1618
+ return { readable, writable };
1619
+ }
1620
+
1621
+ // node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/acp.js
1622
+ class AgentSideConnection {
1623
+ #connection;
1624
+ constructor(toAgent, stream2) {
1625
+ const agent = toAgent(this);
1626
+ const requestHandler = async (method, params) => {
1627
+ switch (method) {
1628
+ case AGENT_METHODS.initialize: {
1629
+ const validatedParams = zInitializeRequest.parse(params);
1630
+ return agent.initialize(validatedParams);
1631
+ }
1632
+ case AGENT_METHODS.session_new: {
1633
+ const validatedParams = zNewSessionRequest.parse(params);
1634
+ return agent.newSession(validatedParams);
1635
+ }
1636
+ case AGENT_METHODS.session_load: {
1637
+ if (!agent.loadSession) {
1638
+ throw RequestError.methodNotFound(method);
1639
+ }
1640
+ const validatedParams = zLoadSessionRequest.parse(params);
1641
+ return agent.loadSession(validatedParams);
1642
+ }
1643
+ case AGENT_METHODS.session_list: {
1644
+ if (!agent.listSessions) {
1645
+ throw RequestError.methodNotFound(method);
1646
+ }
1647
+ const validatedParams = zListSessionsRequest.parse(params);
1648
+ return agent.listSessions(validatedParams);
1649
+ }
1650
+ case AGENT_METHODS.session_fork: {
1651
+ if (!agent.unstable_forkSession) {
1652
+ throw RequestError.methodNotFound(method);
1653
+ }
1654
+ const validatedParams = zForkSessionRequest.parse(params);
1655
+ return agent.unstable_forkSession(validatedParams);
1656
+ }
1657
+ case AGENT_METHODS.session_resume: {
1658
+ if (!agent.unstable_resumeSession) {
1659
+ throw RequestError.methodNotFound(method);
1660
+ }
1661
+ const validatedParams = zResumeSessionRequest.parse(params);
1662
+ return agent.unstable_resumeSession(validatedParams);
1663
+ }
1664
+ case AGENT_METHODS.session_close: {
1665
+ if (!agent.unstable_closeSession) {
1666
+ throw RequestError.methodNotFound(method);
1667
+ }
1668
+ const validatedParams = zCloseSessionRequest.parse(params);
1669
+ return agent.unstable_closeSession(validatedParams);
1670
+ }
1671
+ case AGENT_METHODS.session_set_mode: {
1672
+ if (!agent.setSessionMode) {
1673
+ throw RequestError.methodNotFound(method);
1674
+ }
1675
+ const validatedParams = zSetSessionModeRequest.parse(params);
1676
+ const result = await agent.setSessionMode(validatedParams);
1677
+ return result ?? {};
1678
+ }
1679
+ case AGENT_METHODS.authenticate: {
1680
+ const validatedParams = zAuthenticateRequest.parse(params);
1681
+ const result = await agent.authenticate(validatedParams);
1682
+ return result ?? {};
1683
+ }
1684
+ case AGENT_METHODS.logout: {
1685
+ if (!agent.unstable_logout) {
1686
+ throw RequestError.methodNotFound(method);
1687
+ }
1688
+ const validatedParams = zLogoutRequest.parse(params);
1689
+ const result = await agent.unstable_logout(validatedParams);
1690
+ return result ?? {};
1691
+ }
1692
+ case AGENT_METHODS.session_prompt: {
1693
+ const validatedParams = zPromptRequest.parse(params);
1694
+ return agent.prompt(validatedParams);
1695
+ }
1696
+ case AGENT_METHODS.session_set_model: {
1697
+ if (!agent.unstable_setSessionModel) {
1698
+ throw RequestError.methodNotFound(method);
1699
+ }
1700
+ const validatedParams = zSetSessionModelRequest.parse(params);
1701
+ const result = await agent.unstable_setSessionModel(validatedParams);
1702
+ return result ?? {};
1703
+ }
1704
+ case AGENT_METHODS.session_set_config_option: {
1705
+ if (!agent.setSessionConfigOption) {
1706
+ throw RequestError.methodNotFound(method);
1707
+ }
1708
+ const validatedParams = zSetSessionConfigOptionRequest.parse(params);
1709
+ return agent.setSessionConfigOption(validatedParams);
1710
+ }
1711
+ case AGENT_METHODS.nes_start: {
1712
+ if (!agent.unstable_startNes) {
1713
+ throw RequestError.methodNotFound(method);
1714
+ }
1715
+ const validatedParams = zStartNesRequest.parse(params);
1716
+ return agent.unstable_startNes(validatedParams);
1717
+ }
1718
+ case AGENT_METHODS.nes_suggest: {
1719
+ if (!agent.unstable_suggestNes) {
1720
+ throw RequestError.methodNotFound(method);
1721
+ }
1722
+ const validatedParams = zSuggestNesRequest.parse(params);
1723
+ return agent.unstable_suggestNes(validatedParams);
1724
+ }
1725
+ case AGENT_METHODS.nes_close: {
1726
+ if (!agent.unstable_closeNes) {
1727
+ throw RequestError.methodNotFound(method);
1728
+ }
1729
+ const validatedParams = zCloseNesRequest.parse(params);
1730
+ const result = await agent.unstable_closeNes(validatedParams);
1731
+ return result ?? {};
1732
+ }
1733
+ default:
1734
+ if (agent.extMethod) {
1735
+ return agent.extMethod(method, params);
1736
+ }
1737
+ throw RequestError.methodNotFound(method);
1738
+ }
1739
+ };
1740
+ const notificationHandler = async (method, params) => {
1741
+ switch (method) {
1742
+ case AGENT_METHODS.session_cancel: {
1743
+ const validatedParams = zCancelNotification.parse(params);
1744
+ return agent.cancel(validatedParams);
1745
+ }
1746
+ case AGENT_METHODS.document_did_open: {
1747
+ if (!agent.unstable_didOpenDocument)
1748
+ return;
1749
+ const validatedParams = zDidOpenDocumentNotification.parse(params);
1750
+ return agent.unstable_didOpenDocument(validatedParams);
1751
+ }
1752
+ case AGENT_METHODS.document_did_change: {
1753
+ if (!agent.unstable_didChangeDocument)
1754
+ return;
1755
+ const validatedParams = zDidChangeDocumentNotification.parse(params);
1756
+ return agent.unstable_didChangeDocument(validatedParams);
1757
+ }
1758
+ case AGENT_METHODS.document_did_close: {
1759
+ if (!agent.unstable_didCloseDocument)
1760
+ return;
1761
+ const validatedParams = zDidCloseDocumentNotification.parse(params);
1762
+ return agent.unstable_didCloseDocument(validatedParams);
1763
+ }
1764
+ case AGENT_METHODS.document_did_save: {
1765
+ if (!agent.unstable_didSaveDocument)
1766
+ return;
1767
+ const validatedParams = zDidSaveDocumentNotification.parse(params);
1768
+ return agent.unstable_didSaveDocument(validatedParams);
1769
+ }
1770
+ case AGENT_METHODS.document_did_focus: {
1771
+ if (!agent.unstable_didFocusDocument)
1772
+ return;
1773
+ const validatedParams = zDidFocusDocumentNotification.parse(params);
1774
+ return agent.unstable_didFocusDocument(validatedParams);
1775
+ }
1776
+ case AGENT_METHODS.nes_accept: {
1777
+ if (!agent.unstable_acceptNes)
1778
+ return;
1779
+ const validatedParams = zAcceptNesNotification.parse(params);
1780
+ return agent.unstable_acceptNes(validatedParams);
1781
+ }
1782
+ case AGENT_METHODS.nes_reject: {
1783
+ if (!agent.unstable_rejectNes)
1784
+ return;
1785
+ const validatedParams = zRejectNesNotification.parse(params);
1786
+ return agent.unstable_rejectNes(validatedParams);
1787
+ }
1788
+ default:
1789
+ if (agent.extNotification) {
1790
+ return agent.extNotification(method, params);
1791
+ }
1792
+ throw RequestError.methodNotFound(method);
1793
+ }
1794
+ };
1795
+ this.#connection = new Connection(requestHandler, notificationHandler, stream2);
1796
+ }
1797
+ async sessionUpdate(params) {
1798
+ return await this.#connection.sendNotification(CLIENT_METHODS.session_update, params);
1799
+ }
1800
+ async requestPermission(params) {
1801
+ return await this.#connection.sendRequest(CLIENT_METHODS.session_request_permission, params);
1802
+ }
1803
+ async readTextFile(params) {
1804
+ return await this.#connection.sendRequest(CLIENT_METHODS.fs_read_text_file, params);
1805
+ }
1806
+ async writeTextFile(params) {
1807
+ return await this.#connection.sendRequest(CLIENT_METHODS.fs_write_text_file, params) ?? {};
1808
+ }
1809
+ async createTerminal(params) {
1810
+ const response = await this.#connection.sendRequest(CLIENT_METHODS.terminal_create, params);
1811
+ return new TerminalHandle(response.terminalId, params.sessionId, this.#connection);
1812
+ }
1813
+ async unstable_createElicitation(params) {
1814
+ return await this.#connection.sendRequest(CLIENT_METHODS.elicitation_create, params);
1815
+ }
1816
+ async unstable_completeElicitation(params) {
1817
+ return await this.#connection.sendNotification(CLIENT_METHODS.elicitation_complete, params);
1818
+ }
1819
+ async extMethod(method, params) {
1820
+ return await this.#connection.sendRequest(method, params);
1821
+ }
1822
+ async extNotification(method, params) {
1823
+ return await this.#connection.sendNotification(method, params);
1824
+ }
1825
+ get signal() {
1826
+ return this.#connection.signal;
1827
+ }
1828
+ get closed() {
1829
+ return this.#connection.closed;
1830
+ }
1831
+ }
1832
+
1833
+ class TerminalHandle {
1834
+ id;
1835
+ #sessionId;
1836
+ #connection;
1837
+ constructor(id, sessionId, conn) {
1838
+ this.id = id;
1839
+ this.#sessionId = sessionId;
1840
+ this.#connection = conn;
1841
+ }
1842
+ async currentOutput() {
1843
+ return await this.#connection.sendRequest(CLIENT_METHODS.terminal_output, {
1844
+ sessionId: this.#sessionId,
1845
+ terminalId: this.id
1846
+ });
1847
+ }
1848
+ async waitForExit() {
1849
+ return await this.#connection.sendRequest(CLIENT_METHODS.terminal_wait_for_exit, {
1850
+ sessionId: this.#sessionId,
1851
+ terminalId: this.id
1852
+ });
1853
+ }
1854
+ async kill() {
1855
+ return await this.#connection.sendRequest(CLIENT_METHODS.terminal_kill, {
1856
+ sessionId: this.#sessionId,
1857
+ terminalId: this.id
1858
+ }) ?? {};
1859
+ }
1860
+ async release() {
1861
+ return await this.#connection.sendRequest(CLIENT_METHODS.terminal_release, {
1862
+ sessionId: this.#sessionId,
1863
+ terminalId: this.id
1864
+ }) ?? {};
1865
+ }
1866
+ async[Symbol.asyncDispose]() {
1867
+ await this.release();
1868
+ }
1869
+ }
1870
+
1871
+ class ClientSideConnection {
1872
+ #connection;
1873
+ constructor(toClient, stream2) {
1874
+ const client = toClient(this);
1875
+ const requestHandler = async (method, params) => {
1876
+ switch (method) {
1877
+ case CLIENT_METHODS.fs_write_text_file: {
1878
+ const validatedParams = zWriteTextFileRequest.parse(params);
1879
+ return client.writeTextFile?.(validatedParams);
1880
+ }
1881
+ case CLIENT_METHODS.fs_read_text_file: {
1882
+ const validatedParams = zReadTextFileRequest.parse(params);
1883
+ return client.readTextFile?.(validatedParams);
1884
+ }
1885
+ case CLIENT_METHODS.session_request_permission: {
1886
+ const validatedParams = zRequestPermissionRequest.parse(params);
1887
+ return client.requestPermission(validatedParams);
1888
+ }
1889
+ case CLIENT_METHODS.terminal_create: {
1890
+ const validatedParams = zCreateTerminalRequest.parse(params);
1891
+ return client.createTerminal?.(validatedParams);
1892
+ }
1893
+ case CLIENT_METHODS.terminal_output: {
1894
+ const validatedParams = zTerminalOutputRequest.parse(params);
1895
+ return client.terminalOutput?.(validatedParams);
1896
+ }
1897
+ case CLIENT_METHODS.terminal_release: {
1898
+ const validatedParams = zReleaseTerminalRequest.parse(params);
1899
+ const result = await client.releaseTerminal?.(validatedParams);
1900
+ return result ?? {};
1901
+ }
1902
+ case CLIENT_METHODS.terminal_wait_for_exit: {
1903
+ const validatedParams = zWaitForTerminalExitRequest.parse(params);
1904
+ return client.waitForTerminalExit?.(validatedParams);
1905
+ }
1906
+ case CLIENT_METHODS.terminal_kill: {
1907
+ const validatedParams = zKillTerminalRequest.parse(params);
1908
+ const result = await client.killTerminal?.(validatedParams);
1909
+ return result ?? {};
1910
+ }
1911
+ case CLIENT_METHODS.elicitation_create: {
1912
+ if (!client.unstable_createElicitation) {
1913
+ throw RequestError.methodNotFound(method);
1914
+ }
1915
+ const validatedParams = zCreateElicitationRequest.parse(params);
1916
+ return client.unstable_createElicitation(validatedParams);
1917
+ }
1918
+ default:
1919
+ if (client.extMethod) {
1920
+ return client.extMethod(method, params);
1921
+ }
1922
+ throw RequestError.methodNotFound(method);
1923
+ }
1924
+ };
1925
+ const notificationHandler = async (method, params) => {
1926
+ switch (method) {
1927
+ case CLIENT_METHODS.session_update: {
1928
+ const validatedParams = zSessionNotification.parse(params);
1929
+ return client.sessionUpdate(validatedParams);
1930
+ }
1931
+ case CLIENT_METHODS.elicitation_complete: {
1932
+ if (!client.unstable_completeElicitation)
1933
+ return;
1934
+ const validatedParams = zCompleteElicitationNotification.parse(params);
1935
+ return client.unstable_completeElicitation(validatedParams);
1936
+ }
1937
+ default:
1938
+ if (client.extNotification) {
1939
+ return client.extNotification(method, params);
1940
+ }
1941
+ throw RequestError.methodNotFound(method);
1942
+ }
1943
+ };
1944
+ this.#connection = new Connection(requestHandler, notificationHandler, stream2);
1945
+ }
1946
+ async initialize(params) {
1947
+ return await this.#connection.sendRequest(AGENT_METHODS.initialize, params);
1948
+ }
1949
+ async newSession(params) {
1950
+ return await this.#connection.sendRequest(AGENT_METHODS.session_new, params);
1951
+ }
1952
+ async loadSession(params) {
1953
+ return await this.#connection.sendRequest(AGENT_METHODS.session_load, params) ?? {};
1954
+ }
1955
+ async unstable_forkSession(params) {
1956
+ return await this.#connection.sendRequest(AGENT_METHODS.session_fork, params);
1957
+ }
1958
+ async listSessions(params) {
1959
+ return await this.#connection.sendRequest(AGENT_METHODS.session_list, params);
1960
+ }
1961
+ async unstable_resumeSession(params) {
1962
+ return await this.#connection.sendRequest(AGENT_METHODS.session_resume, params);
1963
+ }
1964
+ async unstable_closeSession(params) {
1965
+ return await this.#connection.sendRequest(AGENT_METHODS.session_close, params);
1966
+ }
1967
+ async setSessionMode(params) {
1968
+ return await this.#connection.sendRequest(AGENT_METHODS.session_set_mode, params) ?? {};
1969
+ }
1970
+ async unstable_setSessionModel(params) {
1971
+ return await this.#connection.sendRequest(AGENT_METHODS.session_set_model, params) ?? {};
1972
+ }
1973
+ async setSessionConfigOption(params) {
1974
+ return await this.#connection.sendRequest(AGENT_METHODS.session_set_config_option, params);
1975
+ }
1976
+ async authenticate(params) {
1977
+ return await this.#connection.sendRequest(AGENT_METHODS.authenticate, params) ?? {};
1978
+ }
1979
+ async unstable_logout(params) {
1980
+ return await this.#connection.sendRequest(AGENT_METHODS.logout, params) ?? {};
1981
+ }
1982
+ async prompt(params) {
1983
+ return await this.#connection.sendRequest(AGENT_METHODS.session_prompt, params);
1984
+ }
1985
+ async cancel(params) {
1986
+ return await this.#connection.sendNotification(AGENT_METHODS.session_cancel, params);
1987
+ }
1988
+ async unstable_startNes(params) {
1989
+ return await this.#connection.sendRequest(AGENT_METHODS.nes_start, params);
1990
+ }
1991
+ async unstable_suggestNes(params) {
1992
+ return await this.#connection.sendRequest(AGENT_METHODS.nes_suggest, params);
1993
+ }
1994
+ async unstable_closeNes(params) {
1995
+ return await this.#connection.sendRequest(AGENT_METHODS.nes_close, params) ?? {};
1996
+ }
1997
+ async unstable_didOpenDocument(params) {
1998
+ return await this.#connection.sendNotification(AGENT_METHODS.document_did_open, params);
1999
+ }
2000
+ async unstable_didChangeDocument(params) {
2001
+ return await this.#connection.sendNotification(AGENT_METHODS.document_did_change, params);
2002
+ }
2003
+ async unstable_didCloseDocument(params) {
2004
+ return await this.#connection.sendNotification(AGENT_METHODS.document_did_close, params);
2005
+ }
2006
+ async unstable_didSaveDocument(params) {
2007
+ return await this.#connection.sendNotification(AGENT_METHODS.document_did_save, params);
2008
+ }
2009
+ async unstable_didFocusDocument(params) {
2010
+ return await this.#connection.sendNotification(AGENT_METHODS.document_did_focus, params);
2011
+ }
2012
+ async unstable_acceptNes(params) {
2013
+ return await this.#connection.sendNotification(AGENT_METHODS.nes_accept, params);
2014
+ }
2015
+ async unstable_rejectNes(params) {
2016
+ return await this.#connection.sendNotification(AGENT_METHODS.nes_reject, params);
2017
+ }
2018
+ async extMethod(method, params) {
2019
+ return await this.#connection.sendRequest(method, params);
2020
+ }
2021
+ async extNotification(method, params) {
2022
+ return await this.#connection.sendNotification(method, params);
2023
+ }
2024
+ get signal() {
2025
+ return this.#connection.signal;
2026
+ }
2027
+ get closed() {
2028
+ return this.#connection.closed;
2029
+ }
2030
+ }
2031
+
2032
+ class Connection {
2033
+ #pendingResponses = new Map;
2034
+ #nextRequestId = 0;
2035
+ #requestHandler;
2036
+ #notificationHandler;
2037
+ #stream;
2038
+ #writeQueue = Promise.resolve();
2039
+ #abortController = new AbortController;
2040
+ #closedPromise;
2041
+ constructor(requestHandler, notificationHandler, stream2) {
2042
+ this.#requestHandler = requestHandler;
2043
+ this.#notificationHandler = notificationHandler;
2044
+ this.#stream = stream2;
2045
+ this.#closedPromise = new Promise((resolve) => {
2046
+ this.#abortController.signal.addEventListener("abort", () => resolve());
2047
+ });
2048
+ this.#receive();
2049
+ }
2050
+ get signal() {
2051
+ return this.#abortController.signal;
2052
+ }
2053
+ get closed() {
2054
+ return this.#closedPromise;
2055
+ }
2056
+ async#receive() {
2057
+ let closeError = undefined;
2058
+ try {
2059
+ const reader = this.#stream.readable.getReader();
2060
+ try {
2061
+ while (!this.#abortController.signal.aborted) {
2062
+ const { value: message, done } = await reader.read();
2063
+ if (done) {
2064
+ break;
2065
+ }
2066
+ if (!message) {
2067
+ continue;
2068
+ }
2069
+ try {
2070
+ this.#processMessage(message);
2071
+ } catch (err) {
2072
+ console.error("Unexpected error during message processing:", message, err);
2073
+ if ("id" in message && message.id !== undefined) {
2074
+ this.#sendMessage({
2075
+ jsonrpc: "2.0",
2076
+ id: message.id,
2077
+ error: {
2078
+ code: -32700,
2079
+ message: "Parse error"
2080
+ }
2081
+ });
2082
+ }
2083
+ }
2084
+ }
2085
+ } finally {
2086
+ reader.releaseLock();
2087
+ }
2088
+ } catch (error) {
2089
+ closeError = error;
2090
+ } finally {
2091
+ this.#close(closeError);
2092
+ }
2093
+ }
2094
+ #close(error) {
2095
+ if (this.#abortController.signal.aborted) {
2096
+ return;
2097
+ }
2098
+ const closeError = error ?? new Error("ACP connection closed");
2099
+ for (const pendingResponse of this.#pendingResponses.values()) {
2100
+ pendingResponse.reject(closeError);
2101
+ }
2102
+ this.#pendingResponses.clear();
2103
+ this.#abortController.abort(closeError);
2104
+ }
2105
+ async#processMessage(message) {
2106
+ if ("method" in message && "id" in message) {
2107
+ const response = await this.#tryCallRequestHandler(message.method, message.params);
2108
+ if ("error" in response) {
2109
+ console.error("Error handling request", message, response.error);
2110
+ }
2111
+ await this.#sendMessage({
2112
+ jsonrpc: "2.0",
2113
+ id: message.id,
2114
+ ...response
2115
+ });
2116
+ } else if ("method" in message) {
2117
+ const response = await this.#tryCallNotificationHandler(message.method, message.params);
2118
+ if ("error" in response) {
2119
+ console.error("Error handling notification", message, response.error);
2120
+ }
2121
+ } else if ("id" in message) {
2122
+ this.#handleResponse(message);
2123
+ } else {
2124
+ console.error("Invalid message", { message });
2125
+ }
2126
+ }
2127
+ async#tryCallRequestHandler(method, params) {
2128
+ try {
2129
+ const result = await this.#requestHandler(method, params);
2130
+ return { result: result ?? null };
2131
+ } catch (error) {
2132
+ if (error instanceof RequestError) {
2133
+ return error.toResult();
2134
+ }
2135
+ if (error instanceof exports_external.ZodError) {
2136
+ return RequestError.invalidParams(error.format()).toResult();
2137
+ }
2138
+ let details;
2139
+ if (error instanceof Error) {
2140
+ details = error.message;
2141
+ } else if (typeof error === "object" && error != null && "message" in error && typeof error.message === "string") {
2142
+ details = error.message;
2143
+ }
2144
+ try {
2145
+ return RequestError.internalError(details ? JSON.parse(details) : {}).toResult();
2146
+ } catch {
2147
+ return RequestError.internalError({ details }).toResult();
2148
+ }
2149
+ }
2150
+ }
2151
+ async#tryCallNotificationHandler(method, params) {
2152
+ try {
2153
+ await this.#notificationHandler(method, params);
2154
+ return { result: null };
2155
+ } catch (error) {
2156
+ if (error instanceof RequestError) {
2157
+ return error.toResult();
2158
+ }
2159
+ if (error instanceof exports_external.ZodError) {
2160
+ return RequestError.invalidParams(error.format()).toResult();
2161
+ }
2162
+ let details;
2163
+ if (error instanceof Error) {
2164
+ details = error.message;
2165
+ } else if (typeof error === "object" && error != null && "message" in error && typeof error.message === "string") {
2166
+ details = error.message;
2167
+ }
2168
+ try {
2169
+ return RequestError.internalError(details ? JSON.parse(details) : {}).toResult();
2170
+ } catch {
2171
+ return RequestError.internalError({ details }).toResult();
2172
+ }
2173
+ }
2174
+ }
2175
+ #handleResponse(response) {
2176
+ const pendingResponse = this.#pendingResponses.get(response.id);
2177
+ if (pendingResponse) {
2178
+ if ("result" in response) {
2179
+ pendingResponse.resolve(response.result);
2180
+ } else if ("error" in response) {
2181
+ const { code, message, data } = response.error;
2182
+ pendingResponse.reject(new RequestError(code, message, data));
2183
+ }
2184
+ this.#pendingResponses.delete(response.id);
2185
+ } else {
2186
+ console.error("Got response to unknown request", response.id);
2187
+ }
2188
+ }
2189
+ async sendRequest(method, params) {
2190
+ this.#throwIfClosed();
2191
+ const id = this.#nextRequestId++;
2192
+ const responsePromise = new Promise((resolve, reject) => {
2193
+ this.#pendingResponses.set(id, { resolve, reject });
2194
+ });
2195
+ await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
2196
+ return responsePromise;
2197
+ }
2198
+ async sendNotification(method, params) {
2199
+ this.#throwIfClosed();
2200
+ await this.#sendMessage({ jsonrpc: "2.0", method, params });
2201
+ }
2202
+ #throwIfClosed() {
2203
+ if (this.#abortController.signal.aborted) {
2204
+ throw this.#abortController.signal.reason ?? new Error("ACP connection closed");
2205
+ }
2206
+ }
2207
+ async#sendMessage(message) {
2208
+ this.#writeQueue = this.#writeQueue.then(async () => {
2209
+ const writer = this.#stream.writable.getWriter();
2210
+ try {
2211
+ await writer.write(message);
2212
+ } finally {
2213
+ writer.releaseLock();
2214
+ }
2215
+ }).catch((error) => {
2216
+ this.#close(error);
2217
+ });
2218
+ return this.#writeQueue;
2219
+ }
2220
+ }
2221
+
2222
+ class RequestError extends Error {
2223
+ code;
2224
+ data;
2225
+ constructor(code, message, data) {
2226
+ super(message);
2227
+ this.code = code;
2228
+ this.name = "RequestError";
2229
+ this.data = data;
2230
+ }
2231
+ static parseError(data, additionalMessage) {
2232
+ return new RequestError(-32700, `Parse error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
2233
+ }
2234
+ static invalidRequest(data, additionalMessage) {
2235
+ return new RequestError(-32600, `Invalid request${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
2236
+ }
2237
+ static methodNotFound(method) {
2238
+ return new RequestError(-32601, `"Method not found": ${method}`, {
2239
+ method
2240
+ });
2241
+ }
2242
+ static invalidParams(data, additionalMessage) {
2243
+ return new RequestError(-32602, `Invalid params${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
2244
+ }
2245
+ static internalError(data, additionalMessage) {
2246
+ return new RequestError(-32603, `Internal error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
2247
+ }
2248
+ static authRequired(data, additionalMessage) {
2249
+ return new RequestError(-32000, `Authentication required${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
2250
+ }
2251
+ static resourceNotFound(uri) {
2252
+ return new RequestError(-32002, `Resource not found${uri ? `: ${uri}` : ""}`, uri && { uri });
2253
+ }
2254
+ toResult() {
2255
+ return {
2256
+ error: {
2257
+ code: this.code,
2258
+ message: this.message,
2259
+ data: this.data
2260
+ }
2261
+ };
2262
+ }
2263
+ toErrorResponse() {
2264
+ return {
2265
+ code: this.code,
2266
+ message: this.message,
2267
+ data: this.data
2268
+ };
2269
+ }
2270
+ }
2271
+
2272
+ // src/services/acp/entry.ts
2273
+ import { Readable, Writable } from "stream";
2274
+
2275
+ // src/services/acp/agent.ts
2276
+ init_conversationRecovery();
2277
+ init_sessionStorage();
2278
+ import { randomUUID } from "crypto";
2279
+ init_tools();
2280
+ init_Tool();
2281
+ init_commands();
2282
+ init_state();
2283
+ init_config();
2284
+ init_fileStateCache();
2285
+ init_AppStateStore();
2286
+
2287
+ // src/services/acp/utils.ts
2288
+ import * as path from "path";
2289
+ var IS_ROOT = typeof process.geteuid === "function" ? process.geteuid() === 0 : typeof process.getuid === "function" ? process.getuid() === 0 : false;
2290
+ var ALLOW_BYPASS = !IS_ROOT || !!process.env.IS_SANDBOX;
2291
+ var PERMISSION_MODE_ALIASES = {
2292
+ auto: "auto",
2293
+ default: "default",
2294
+ acceptedits: "acceptEdits",
2295
+ dontask: "dontAsk",
2296
+ plan: "plan",
2297
+ bypasspermissions: "bypassPermissions",
2298
+ bypass: "bypassPermissions"
2299
+ };
2300
+ function resolvePermissionMode(defaultMode) {
2301
+ if (defaultMode === undefined) {
2302
+ return "default";
2303
+ }
2304
+ if (typeof defaultMode !== "string") {
2305
+ throw new Error("Invalid permissions.defaultMode: expected a string.");
2306
+ }
2307
+ const normalized = defaultMode.trim().toLowerCase();
2308
+ if (normalized === "") {
2309
+ throw new Error("Invalid permissions.defaultMode: expected a non-empty string.");
2310
+ }
2311
+ const mapped = PERMISSION_MODE_ALIASES[normalized];
2312
+ if (!mapped) {
2313
+ throw new Error(`Invalid permissions.defaultMode: ${defaultMode}.`);
2314
+ }
2315
+ if (mapped === "bypassPermissions" && !ALLOW_BYPASS) {
2316
+ throw new Error("Invalid permissions.defaultMode: bypassPermissions is not available when running as root.");
2317
+ }
2318
+ return mapped;
2319
+ }
2320
+ function computeSessionFingerprint(params) {
2321
+ const servers = [...params.mcpServers ?? []].sort((a, b) => a.name.localeCompare(b.name));
2322
+ return JSON.stringify({ cwd: params.cwd, mcpServers: servers });
2323
+ }
2324
+ var MAX_TITLE_LENGTH = 256;
2325
+ function sanitizeTitle(text) {
2326
+ const sanitized = text.replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").trim();
2327
+ if (sanitized.length <= MAX_TITLE_LENGTH) {
2328
+ return sanitized;
2329
+ }
2330
+ return sanitized.slice(0, MAX_TITLE_LENGTH - 1) + "\u2026";
2331
+ }
2332
+ function toDisplayPath(filePath, cwd) {
2333
+ if (!cwd)
2334
+ return filePath;
2335
+ const resolvedCwd = path.resolve(cwd);
2336
+ const resolvedFile = path.resolve(filePath);
2337
+ if (resolvedFile.startsWith(resolvedCwd + path.sep) || resolvedFile === resolvedCwd) {
2338
+ return path.relative(resolvedCwd, resolvedFile);
2339
+ }
2340
+ return filePath;
2341
+ }
2342
+ function markdownEscape(text) {
2343
+ let escape = "```";
2344
+ for (const m of text.matchAll(/^```+/gm) ?? []) {
2345
+ while (m[0].length >= escape.length) {
2346
+ escape += "`";
2347
+ }
2348
+ }
2349
+ return escape + `
2350
+ ` + text + (text.endsWith(`
2351
+ `) ? "" : `
2352
+ `) + escape;
2353
+ }
2354
+
2355
+ // src/services/acp/bridge.ts
2356
+ function toolInfoFromToolUse(toolUse, _supportsTerminalOutput = false, cwd) {
2357
+ const name = toolUse.name;
2358
+ const input = toolUse.input;
2359
+ switch (name) {
2360
+ case "Agent":
2361
+ case "Task": {
2362
+ const description = input?.description ?? "Task";
2363
+ const prompt = input?.prompt;
2364
+ return {
2365
+ title: description,
2366
+ kind: "think",
2367
+ content: prompt ? [{ type: "content", content: { type: "text", text: prompt } }] : []
2368
+ };
2369
+ }
2370
+ case "Bash": {
2371
+ const command = input?.command ?? "Terminal";
2372
+ const description = input?.description;
2373
+ return {
2374
+ title: command,
2375
+ kind: "execute",
2376
+ content: _supportsTerminalOutput ? [{ type: "terminal", terminalId: toolUse.id }] : description ? [{ type: "content", content: { type: "text", text: description } }] : []
2377
+ };
2378
+ }
2379
+ case "Read": {
2380
+ const filePath = input?.file_path ?? "File";
2381
+ const offset = input?.offset;
2382
+ const limit = input?.limit;
2383
+ let suffix = "";
2384
+ if (limit && limit > 0) {
2385
+ suffix = ` (${offset ?? 1} - ${(offset ?? 1) + limit - 1})`;
2386
+ } else if (offset) {
2387
+ suffix = ` (from line ${offset})`;
2388
+ }
2389
+ const displayPath = filePath ? toDisplayPath(filePath, cwd) : "File";
2390
+ return {
2391
+ title: `Read ${displayPath}${suffix}`,
2392
+ kind: "read",
2393
+ locations: filePath ? [{ path: filePath, line: offset ?? 1 }] : [],
2394
+ content: []
2395
+ };
2396
+ }
2397
+ case "Write": {
2398
+ const filePath = input?.file_path ?? "";
2399
+ const content = input?.content ?? "";
2400
+ const displayPath = filePath ? toDisplayPath(filePath, cwd) : undefined;
2401
+ return {
2402
+ title: displayPath ? `Write ${displayPath}` : "Write",
2403
+ kind: "edit",
2404
+ content: filePath ? [{ type: "diff", path: filePath, oldText: null, newText: content }] : [{ type: "content", content: { type: "text", text: content } }],
2405
+ locations: filePath ? [{ path: filePath }] : []
2406
+ };
2407
+ }
2408
+ case "Edit": {
2409
+ const filePath = input?.file_path ?? "";
2410
+ const oldString = input?.old_string ?? "";
2411
+ const newString = input?.new_string ?? "";
2412
+ const displayPath = filePath ? toDisplayPath(filePath, cwd) : undefined;
2413
+ return {
2414
+ title: displayPath ? `Edit ${displayPath}` : "Edit",
2415
+ kind: "edit",
2416
+ content: filePath ? [{ type: "diff", path: filePath, oldText: oldString || null, newText: newString }] : [],
2417
+ locations: filePath ? [{ path: filePath }] : []
2418
+ };
2419
+ }
2420
+ case "Glob": {
2421
+ const globPath = input?.path ?? "";
2422
+ const pattern = input?.pattern ?? "";
2423
+ let label = "Find";
2424
+ if (globPath)
2425
+ label += ` \`${globPath}\``;
2426
+ if (pattern)
2427
+ label += ` \`${pattern}\``;
2428
+ return {
2429
+ title: label,
2430
+ kind: "search",
2431
+ content: [],
2432
+ locations: globPath ? [{ path: globPath }] : []
2433
+ };
2434
+ }
2435
+ case "Grep": {
2436
+ const grepPattern = input?.pattern ?? "";
2437
+ const grepPath = input?.path ?? "";
2438
+ let label = "grep";
2439
+ if (input?.["-i"])
2440
+ label += " -i";
2441
+ if (input?.["-n"])
2442
+ label += " -n";
2443
+ if (input?.["-A"] !== undefined)
2444
+ label += ` -A ${input["-A"]}`;
2445
+ if (input?.["-B"] !== undefined)
2446
+ label += ` -B ${input["-B"]}`;
2447
+ if (input?.["-C"] !== undefined)
2448
+ label += ` -C ${input["-C"]}`;
2449
+ if (input?.output_mode === "files_with_matches")
2450
+ label += " -l";
2451
+ else if (input?.output_mode === "count")
2452
+ label += " -c";
2453
+ if (input?.head_limit !== undefined)
2454
+ label += ` | head -${input.head_limit}`;
2455
+ if (input?.glob)
2456
+ label += ` --include="${input.glob}"`;
2457
+ if (input?.type)
2458
+ label += ` --type=${input.type}`;
2459
+ if (input?.multiline)
2460
+ label += " -P";
2461
+ if (grepPattern)
2462
+ label += ` "${grepPattern}"`;
2463
+ if (grepPath)
2464
+ label += ` ${grepPath}`;
2465
+ return {
2466
+ title: label,
2467
+ kind: "search",
2468
+ content: []
2469
+ };
2470
+ }
2471
+ case "WebFetch": {
2472
+ const url = input?.url ?? "";
2473
+ const fetchPrompt = input?.prompt;
2474
+ return {
2475
+ title: url ? `Fetch ${url}` : "Fetch",
2476
+ kind: "fetch",
2477
+ content: fetchPrompt ? [{ type: "content", content: { type: "text", text: fetchPrompt } }] : []
2478
+ };
2479
+ }
2480
+ case "WebSearch": {
2481
+ const query = input?.query ?? "Web search";
2482
+ let label = `"${query}"`;
2483
+ const allowed = input?.allowed_domains;
2484
+ const blocked = input?.blocked_domains;
2485
+ if (allowed && allowed.length > 0)
2486
+ label += ` (allowed: ${allowed.join(", ")})`;
2487
+ if (blocked && blocked.length > 0)
2488
+ label += ` (blocked: ${blocked.join(", ")})`;
2489
+ return {
2490
+ title: label,
2491
+ kind: "fetch",
2492
+ content: []
2493
+ };
2494
+ }
2495
+ case "TodoWrite": {
2496
+ const todos = input?.todos;
2497
+ return {
2498
+ title: Array.isArray(todos) ? `Update TODOs: ${todos.map((t) => t.content).join(", ")}` : "Update TODOs",
2499
+ kind: "think",
2500
+ content: []
2501
+ };
2502
+ }
2503
+ case "ExitPlanMode": {
2504
+ const plan = input?.plan;
2505
+ return {
2506
+ title: "Ready to code?",
2507
+ kind: "switch_mode",
2508
+ content: plan ? [{ type: "content", content: { type: "text", text: plan } }] : []
2509
+ };
2510
+ }
2511
+ default:
2512
+ return {
2513
+ title: name || "Unknown Tool",
2514
+ kind: "other",
2515
+ content: []
2516
+ };
2517
+ }
2518
+ }
2519
+ function toolUpdateFromToolResult(toolResult, toolUse, _supportsTerminalOutput = false) {
2520
+ if (!toolUse)
2521
+ return {};
2522
+ const isError = toolResult.is_error === true;
2523
+ const resultContent = toolResult.content;
2524
+ if (isError && resultContent) {
2525
+ return toAcpContentUpdate(resultContent, true);
2526
+ }
2527
+ switch (toolUse.name) {
2528
+ case "Read": {
2529
+ if (typeof resultContent === "string" && resultContent.length > 0) {
2530
+ return {
2531
+ content: [
2532
+ {
2533
+ type: "content",
2534
+ content: { type: "text", text: markdownEscape(resultContent) }
2535
+ }
2536
+ ]
2537
+ };
2538
+ }
2539
+ if (Array.isArray(resultContent) && resultContent.length > 0) {
2540
+ return {
2541
+ content: resultContent.map((c) => ({
2542
+ type: "content",
2543
+ content: c.type === "text" ? { type: "text", text: markdownEscape(c.text) } : toAcpContentBlock(c, false)
2544
+ }))
2545
+ };
2546
+ }
2547
+ return {};
2548
+ }
2549
+ case "Bash": {
2550
+ let output = "";
2551
+ let exitCode = isError ? 1 : 0;
2552
+ const terminalId = String(toolUse.id);
2553
+ if (resultContent && typeof resultContent === "object" && !Array.isArray(resultContent) && resultContent.type === "bash_code_execution_result") {
2554
+ const bashResult = resultContent;
2555
+ output = [bashResult.stdout, bashResult.stderr].filter(Boolean).join(`
2556
+ `);
2557
+ exitCode = bashResult.return_code ?? (isError ? 1 : 0);
2558
+ } else if (typeof resultContent === "string") {
2559
+ output = resultContent;
2560
+ } else if (Array.isArray(resultContent) && resultContent.length > 0) {
2561
+ output = resultContent.map((c) => c.type === "text" ? c.text : "").join(`
2562
+ `);
2563
+ }
2564
+ if (_supportsTerminalOutput) {
2565
+ return {
2566
+ content: [{ type: "terminal", terminalId }],
2567
+ _meta: {
2568
+ terminal_info: { terminal_id: terminalId },
2569
+ terminal_output: { terminal_id: terminalId, data: output },
2570
+ terminal_exit: { terminal_id: terminalId, exit_code: exitCode, signal: null }
2571
+ }
2572
+ };
2573
+ }
2574
+ if (output.trim()) {
2575
+ return {
2576
+ content: [
2577
+ {
2578
+ type: "content",
2579
+ content: {
2580
+ type: "text",
2581
+ text: `\`\`\`console
2582
+ ${output.trimEnd()}
2583
+ \`\`\``
2584
+ }
2585
+ }
2586
+ ]
2587
+ };
2588
+ }
2589
+ return {};
2590
+ }
2591
+ case "Edit":
2592
+ case "Write": {
2593
+ return {};
2594
+ }
2595
+ case "ExitPlanMode": {
2596
+ return { title: "Exited Plan Mode" };
2597
+ }
2598
+ default: {
2599
+ return toAcpContentUpdate(resultContent ?? "", isError);
2600
+ }
2601
+ }
2602
+ }
2603
+ function toAcpContentUpdate(content, isError) {
2604
+ if (Array.isArray(content) && content.length > 0) {
2605
+ return {
2606
+ content: content.map((c) => ({
2607
+ type: "content",
2608
+ content: toAcpContentBlock(c, isError)
2609
+ }))
2610
+ };
2611
+ }
2612
+ if (typeof content === "string" && content.length > 0) {
2613
+ return {
2614
+ content: [
2615
+ {
2616
+ type: "content",
2617
+ content: {
2618
+ type: "text",
2619
+ text: isError ? `\`\`\`
2620
+ ${content}
2621
+ \`\`\`` : content
2622
+ }
2623
+ }
2624
+ ]
2625
+ };
2626
+ }
2627
+ return {};
2628
+ }
2629
+ function toAcpContentBlock(content, isError) {
2630
+ const wrapText = (text) => ({
2631
+ type: "text",
2632
+ text: isError ? `\`\`\`
2633
+ ${text}
2634
+ \`\`\`` : text
2635
+ });
2636
+ const type = content.type;
2637
+ switch (type) {
2638
+ case "text": {
2639
+ const text = content.text;
2640
+ return { type: "text", text: isError ? `\`\`\`
2641
+ ${text}
2642
+ \`\`\`` : text };
2643
+ }
2644
+ case "image": {
2645
+ const source = content.source;
2646
+ if (source?.type === "base64") {
2647
+ return {
2648
+ type: "image",
2649
+ data: source.data,
2650
+ mimeType: source.media_type
2651
+ };
2652
+ }
2653
+ return wrapText(source?.type === "url" ? `[image: ${source.url}]` : "[image: file reference]");
2654
+ }
2655
+ case "tool_reference":
2656
+ return wrapText(`Tool: ${content.tool_name}`);
2657
+ case "tool_search_tool_search_result": {
2658
+ const refs = content.tool_references;
2659
+ return wrapText(`Tools found: ${refs?.map((r) => r.tool_name).join(", ") || "none"}`);
2660
+ }
2661
+ case "tool_search_tool_result_error":
2662
+ return wrapText(`Error: ${content.error_code}${content.error_message ? ` - ${content.error_message}` : ""}`);
2663
+ case "web_search_result":
2664
+ return wrapText(`${content.title} (${content.url})`);
2665
+ case "web_search_tool_result_error":
2666
+ return wrapText(`Error: ${content.error_code}`);
2667
+ case "web_fetch_result":
2668
+ return wrapText(`Fetched: ${content.url}`);
2669
+ case "web_fetch_tool_result_error":
2670
+ return wrapText(`Error: ${content.error_code}`);
2671
+ case "code_execution_result":
2672
+ case "bash_code_execution_result":
2673
+ return wrapText(`Output: ${content.stdout || content.stderr || ""}`);
2674
+ case "code_execution_tool_result_error":
2675
+ case "bash_code_execution_tool_result_error":
2676
+ return wrapText(`Error: ${content.error_code}`);
2677
+ case "text_editor_code_execution_view_result":
2678
+ return wrapText(content.content);
2679
+ case "text_editor_code_execution_create_result":
2680
+ return wrapText(content.is_file_update ? "File updated" : "File created");
2681
+ case "text_editor_code_execution_str_replace_result": {
2682
+ const lines = content.lines;
2683
+ return wrapText(lines?.join(`
2684
+ `) || "");
2685
+ }
2686
+ case "text_editor_code_execution_tool_result_error":
2687
+ return wrapText(`Error: ${content.error_code}${content.error_message ? ` - ${content.error_message}` : ""}`);
2688
+ default:
2689
+ try {
2690
+ return { type: "text", text: JSON.stringify(content) };
2691
+ } catch {
2692
+ return { type: "text", text: "[content]" };
2693
+ }
2694
+ }
2695
+ }
2696
+ async function forwardSessionUpdates(sessionId, sdkMessages, conn, abortSignal, toolUseCache, clientCapabilities, cwd, isCancelled) {
2697
+ let stopReason = "end_turn";
2698
+ const accumulatedUsage = {
2699
+ inputTokens: 0,
2700
+ outputTokens: 0,
2701
+ cachedReadTokens: 0,
2702
+ cachedWriteTokens: 0
2703
+ };
2704
+ let lastAssistantTotalUsage = null;
2705
+ let lastAssistantModel = null;
2706
+ let lastContextWindowSize = 200000;
2707
+ try {
2708
+ while (!abortSignal.aborted) {
2709
+ const nextResult = await Promise.race([
2710
+ sdkMessages.next(),
2711
+ new Promise((resolve2) => {
2712
+ if (abortSignal.aborted) {
2713
+ resolve2({ done: true, value: undefined });
2714
+ return;
2715
+ }
2716
+ const handler = () => resolve2({ done: true, value: undefined });
2717
+ abortSignal.addEventListener("abort", handler, { once: true });
2718
+ })
2719
+ ]);
2720
+ if (nextResult.done || abortSignal.aborted)
2721
+ break;
2722
+ const msg = nextResult.value;
2723
+ const type = msg.type;
2724
+ switch (type) {
2725
+ case "system": {
2726
+ const subtype = msg.subtype;
2727
+ if (subtype === "compact_boundary") {
2728
+ lastAssistantTotalUsage = 0;
2729
+ await conn.sessionUpdate({
2730
+ sessionId,
2731
+ update: {
2732
+ sessionUpdate: "usage_update",
2733
+ used: 0,
2734
+ size: lastContextWindowSize
2735
+ }
2736
+ });
2737
+ await conn.sessionUpdate({
2738
+ sessionId,
2739
+ update: {
2740
+ sessionUpdate: "agent_message_chunk",
2741
+ content: { type: "text", text: `
2742
+
2743
+ Compacting completed.` }
2744
+ }
2745
+ });
2746
+ }
2747
+ break;
2748
+ }
2749
+ case "result": {
2750
+ const usage = msg.usage;
2751
+ if (usage) {
2752
+ accumulatedUsage.inputTokens += usage.input_tokens;
2753
+ accumulatedUsage.outputTokens += usage.output_tokens;
2754
+ accumulatedUsage.cachedReadTokens += usage.cache_read_input_tokens;
2755
+ accumulatedUsage.cachedWriteTokens += usage.cache_creation_input_tokens;
2756
+ }
2757
+ const modelUsage = msg.modelUsage;
2758
+ if (modelUsage && lastAssistantModel) {
2759
+ const match = getMatchingModelUsage(modelUsage, lastAssistantModel);
2760
+ if (match?.contextWindow) {
2761
+ lastContextWindowSize = match.contextWindow;
2762
+ }
2763
+ }
2764
+ const usedTokens = lastAssistantTotalUsage ?? accumulatedUsage.inputTokens + accumulatedUsage.outputTokens + accumulatedUsage.cachedReadTokens + accumulatedUsage.cachedWriteTokens;
2765
+ const totalCostUsd = msg.total_cost_usd;
2766
+ await conn.sessionUpdate({
2767
+ sessionId,
2768
+ update: {
2769
+ sessionUpdate: "usage_update",
2770
+ used: usedTokens,
2771
+ size: lastContextWindowSize,
2772
+ cost: totalCostUsd != null ? { amount: totalCostUsd, currency: "USD" } : undefined
2773
+ }
2774
+ });
2775
+ const subtype = msg.subtype;
2776
+ const isError = msg.is_error;
2777
+ if (abortSignal.aborted) {
2778
+ stopReason = "cancelled";
2779
+ break;
2780
+ }
2781
+ switch (subtype) {
2782
+ case "success": {
2783
+ const stopReasonStr = msg.stop_reason;
2784
+ if (stopReasonStr === "max_tokens") {
2785
+ stopReason = "max_tokens";
2786
+ }
2787
+ if (isError) {
2788
+ stopReason = "end_turn";
2789
+ }
2790
+ break;
2791
+ }
2792
+ case "error_during_execution": {
2793
+ if (msg.stop_reason === "max_tokens") {
2794
+ stopReason = "max_tokens";
2795
+ } else if (isError) {
2796
+ stopReason = "end_turn";
2797
+ } else {
2798
+ stopReason = "end_turn";
2799
+ }
2800
+ break;
2801
+ }
2802
+ case "error_max_budget_usd":
2803
+ case "error_max_turns":
2804
+ case "error_max_structured_output_retries":
2805
+ if (isError) {
2806
+ stopReason = "max_turn_requests";
2807
+ } else {
2808
+ stopReason = "max_turn_requests";
2809
+ }
2810
+ break;
2811
+ }
2812
+ break;
2813
+ }
2814
+ case "stream_event": {
2815
+ const notifications = streamEventToAcpNotifications(msg, sessionId, toolUseCache, conn, {
2816
+ clientCapabilities,
2817
+ cwd
2818
+ });
2819
+ for (const notification of notifications) {
2820
+ await conn.sessionUpdate(notification);
2821
+ }
2822
+ break;
2823
+ }
2824
+ case "assistant": {
2825
+ const assistantMsg = msg.message;
2826
+ const parentToolUseId = msg.parent_tool_use_id;
2827
+ if (assistantMsg?.usage && parentToolUseId === null) {
2828
+ const msgUsage = assistantMsg.usage;
2829
+ lastAssistantTotalUsage = (msgUsage.input_tokens ?? 0) + (msgUsage.output_tokens ?? 0) + (msgUsage.cache_read_input_tokens ?? 0) + (msgUsage.cache_creation_input_tokens ?? 0);
2830
+ }
2831
+ if (parentToolUseId === null && assistantMsg?.model && assistantMsg.model !== "<synthetic>") {
2832
+ lastAssistantModel = assistantMsg.model;
2833
+ }
2834
+ const notifications = assistantMessageToAcpNotifications(msg, sessionId, toolUseCache, conn, {
2835
+ clientCapabilities,
2836
+ cwd
2837
+ });
2838
+ for (const notification of notifications) {
2839
+ await conn.sessionUpdate(notification);
2840
+ }
2841
+ break;
2842
+ }
2843
+ case "user": {
2844
+ break;
2845
+ }
2846
+ case "progress": {
2847
+ const progressData = msg.data;
2848
+ if (!progressData)
2849
+ break;
2850
+ const progressType = progressData.type;
2851
+ if (progressType === "agent_progress" || progressType === "skill_progress") {
2852
+ const progressMessage = progressData.message;
2853
+ if (progressMessage) {
2854
+ const content = progressMessage.content;
2855
+ if (content) {
2856
+ for (const block of content) {
2857
+ if (block.type === "text") {
2858
+ await conn.sessionUpdate({
2859
+ sessionId,
2860
+ update: {
2861
+ sessionUpdate: "agent_message_chunk",
2862
+ content: { type: "text", text: block.text }
2863
+ }
2864
+ });
2865
+ }
2866
+ }
2867
+ }
2868
+ }
2869
+ }
2870
+ break;
2871
+ }
2872
+ case "tool_use_summary": {
2873
+ break;
2874
+ }
2875
+ case "attachment": {
2876
+ break;
2877
+ }
2878
+ case "compact_boundary": {
2879
+ lastAssistantTotalUsage = 0;
2880
+ await conn.sessionUpdate({
2881
+ sessionId,
2882
+ update: {
2883
+ sessionUpdate: "usage_update",
2884
+ used: 0,
2885
+ size: lastContextWindowSize
2886
+ }
2887
+ });
2888
+ await conn.sessionUpdate({
2889
+ sessionId,
2890
+ update: {
2891
+ sessionUpdate: "agent_message_chunk",
2892
+ content: { type: "text", text: `
2893
+
2894
+ Compacting completed.` }
2895
+ }
2896
+ });
2897
+ break;
2898
+ }
2899
+ default:
2900
+ break;
2901
+ }
2902
+ }
2903
+ if (abortSignal.aborted || isCancelled?.()) {
2904
+ return { stopReason: "cancelled", usage: accumulatedUsage };
2905
+ }
2906
+ } catch (err) {
2907
+ if (abortSignal.aborted) {
2908
+ return { stopReason: "cancelled", usage: accumulatedUsage };
2909
+ }
2910
+ throw err;
2911
+ }
2912
+ return { stopReason, usage: accumulatedUsage };
2913
+ }
2914
+ function assistantMessageToAcpNotifications(msg, sessionId, toolUseCache, conn, options) {
2915
+ const message = msg.message;
2916
+ if (!message)
2917
+ return [];
2918
+ const content = message.content;
2919
+ if (!content)
2920
+ return [];
2921
+ if (typeof content === "string") {
2922
+ return [
2923
+ {
2924
+ sessionId,
2925
+ update: {
2926
+ sessionUpdate: "agent_message_chunk",
2927
+ content: { type: "text", text: content }
2928
+ }
2929
+ }
2930
+ ];
2931
+ }
2932
+ return toAcpNotifications(content, "assistant", sessionId, toolUseCache, conn, undefined, options);
2933
+ }
2934
+ function streamEventToAcpNotifications(msg, sessionId, toolUseCache, conn, options) {
2935
+ const event = msg.event;
2936
+ if (!event)
2937
+ return [];
2938
+ switch (event.type) {
2939
+ case "content_block_start": {
2940
+ const contentBlock = event.content_block;
2941
+ if (!contentBlock)
2942
+ return [];
2943
+ return toAcpNotifications([contentBlock], "assistant", sessionId, toolUseCache, conn, undefined, {
2944
+ clientCapabilities: options?.clientCapabilities,
2945
+ parentToolUseId: msg.parent_tool_use_id,
2946
+ cwd: options?.cwd
2947
+ });
2948
+ }
2949
+ case "content_block_delta": {
2950
+ const delta = event.delta;
2951
+ if (!delta)
2952
+ return [];
2953
+ return toAcpNotifications([delta], "assistant", sessionId, toolUseCache, conn, undefined, {
2954
+ clientCapabilities: options?.clientCapabilities,
2955
+ parentToolUseId: msg.parent_tool_use_id,
2956
+ cwd: options?.cwd
2957
+ });
2958
+ }
2959
+ case "message_start":
2960
+ case "message_delta":
2961
+ case "message_stop":
2962
+ case "content_block_stop":
2963
+ return [];
2964
+ default:
2965
+ return [];
2966
+ }
2967
+ }
2968
+ function toAcpNotifications(content, role, sessionId, toolUseCache, _conn, _logger, options) {
2969
+ const output = [];
2970
+ for (const chunk of content) {
2971
+ const chunkType = chunk.type;
2972
+ let update = null;
2973
+ switch (chunkType) {
2974
+ case "text":
2975
+ case "text_delta": {
2976
+ const text = chunk.text ?? "";
2977
+ update = {
2978
+ sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
2979
+ content: { type: "text", text }
2980
+ };
2981
+ break;
2982
+ }
2983
+ case "thinking":
2984
+ case "thinking_delta": {
2985
+ const thinking = chunk.thinking ?? "";
2986
+ update = {
2987
+ sessionUpdate: "agent_thought_chunk",
2988
+ content: { type: "text", text: thinking }
2989
+ };
2990
+ break;
2991
+ }
2992
+ case "image": {
2993
+ const source = chunk.source;
2994
+ if (source?.type === "base64") {
2995
+ update = {
2996
+ sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
2997
+ content: {
2998
+ type: "image",
2999
+ data: source.data,
3000
+ mimeType: source.media_type
3001
+ }
3002
+ };
3003
+ }
3004
+ break;
3005
+ }
3006
+ case "tool_use":
3007
+ case "server_tool_use":
3008
+ case "mcp_tool_use": {
3009
+ const toolUseId = chunk.id ?? "";
3010
+ const toolName = chunk.name ?? "unknown";
3011
+ const toolInput = chunk.input;
3012
+ const alreadyCached = toolUseId in toolUseCache;
3013
+ toolUseCache[toolUseId] = {
3014
+ type: chunkType,
3015
+ id: toolUseId,
3016
+ name: toolName,
3017
+ input: toolInput
3018
+ };
3019
+ if (toolName === "TodoWrite") {
3020
+ const todos = toolInput?.todos;
3021
+ if (Array.isArray(todos)) {
3022
+ const entries = todos.map((todo) => ({
3023
+ content: todo.content,
3024
+ status: normalizePlanStatus(todo.status),
3025
+ priority: "medium"
3026
+ }));
3027
+ update = {
3028
+ sessionUpdate: "plan",
3029
+ entries
3030
+ };
3031
+ }
3032
+ } else {
3033
+ let rawInput;
3034
+ try {
3035
+ rawInput = JSON.parse(JSON.stringify(toolInput ?? {}));
3036
+ } catch {}
3037
+ if (alreadyCached) {
3038
+ update = {
3039
+ _meta: {
3040
+ claudeCode: { toolName }
3041
+ },
3042
+ toolCallId: toolUseId,
3043
+ sessionUpdate: "tool_call_update",
3044
+ rawInput,
3045
+ ...toolInfoFromToolUse({ name: toolName, id: toolUseId, input: toolInput ?? {} }, false, options?.cwd)
3046
+ };
3047
+ } else {
3048
+ update = {
3049
+ _meta: {
3050
+ claudeCode: { toolName }
3051
+ },
3052
+ toolCallId: toolUseId,
3053
+ sessionUpdate: "tool_call",
3054
+ rawInput,
3055
+ status: "pending",
3056
+ ...toolInfoFromToolUse({ name: toolName, id: toolUseId, input: toolInput ?? {} }, false, options?.cwd)
3057
+ };
3058
+ }
3059
+ }
3060
+ break;
3061
+ }
3062
+ case "tool_result":
3063
+ case "mcp_tool_result": {
3064
+ const toolUseId = chunk.tool_use_id ?? "";
3065
+ const toolUse = toolUseCache[toolUseId];
3066
+ if (!toolUse)
3067
+ break;
3068
+ if (toolUse.name !== "TodoWrite") {
3069
+ const toolUpdate = toolUpdateFromToolResult(chunk, { name: toolUse.name, id: toolUse.id }, false);
3070
+ update = {
3071
+ _meta: {
3072
+ claudeCode: { toolName: toolUse.name }
3073
+ },
3074
+ toolCallId: toolUseId,
3075
+ sessionUpdate: "tool_call_update",
3076
+ status: chunk.is_error === true ? "failed" : "completed",
3077
+ rawOutput: chunk.content,
3078
+ ...toolUpdate
3079
+ };
3080
+ }
3081
+ break;
3082
+ }
3083
+ case "redacted_thinking":
3084
+ case "input_json_delta":
3085
+ case "citations_delta":
3086
+ case "signature_delta":
3087
+ case "container_upload":
3088
+ case "compaction":
3089
+ case "compaction_delta":
3090
+ break;
3091
+ }
3092
+ if (update) {
3093
+ if (options?.parentToolUseId) {
3094
+ const existingMeta = update._meta;
3095
+ update._meta = {
3096
+ ...existingMeta,
3097
+ claudeCode: {
3098
+ ...existingMeta?.claudeCode ?? {},
3099
+ parentToolUseId: options.parentToolUseId
3100
+ }
3101
+ };
3102
+ }
3103
+ output.push({ sessionId, update });
3104
+ }
3105
+ }
3106
+ return output;
3107
+ }
3108
+ function normalizePlanStatus(status) {
3109
+ if (status === "in_progress")
3110
+ return "in_progress";
3111
+ if (status === "completed")
3112
+ return "completed";
3113
+ return "pending";
3114
+ }
3115
+ async function replayHistoryMessages(sessionId, messages, conn, toolUseCache, clientCapabilities, cwd) {
3116
+ for (const msg of messages) {
3117
+ const type = msg.type;
3118
+ if (type !== "user" && type !== "assistant")
3119
+ continue;
3120
+ if (msg.isMeta === true)
3121
+ continue;
3122
+ const messageData = msg.message;
3123
+ const content = messageData?.content;
3124
+ if (!content)
3125
+ continue;
3126
+ const role = type === "assistant" ? "assistant" : "user";
3127
+ if (typeof content === "string") {
3128
+ if (!content.trim())
3129
+ continue;
3130
+ await conn.sessionUpdate({
3131
+ sessionId,
3132
+ update: {
3133
+ sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
3134
+ content: { type: "text", text: content }
3135
+ }
3136
+ });
3137
+ continue;
3138
+ }
3139
+ if (Array.isArray(content)) {
3140
+ const notifications = toAcpNotifications(content, role, sessionId, toolUseCache, conn, undefined, { clientCapabilities, cwd });
3141
+ for (const notification of notifications) {
3142
+ await conn.sessionUpdate(notification);
3143
+ }
3144
+ }
3145
+ }
3146
+ }
3147
+ function commonPrefixLength(a, b) {
3148
+ let i = 0;
3149
+ const maxLen = Math.min(a.length, b.length);
3150
+ while (i < maxLen && a[i] === b[i])
3151
+ i++;
3152
+ return i;
3153
+ }
3154
+ function getMatchingModelUsage(modelUsage, currentModel) {
3155
+ let bestKey = null;
3156
+ let bestLen = 0;
3157
+ for (const key of Object.keys(modelUsage)) {
3158
+ const len = commonPrefixLength(key, currentModel);
3159
+ if (len > bestLen) {
3160
+ bestLen = len;
3161
+ bestKey = key;
3162
+ }
3163
+ }
3164
+ return bestKey ? modelUsage[bestKey] ?? null : null;
3165
+ }
3166
+
3167
+ // src/services/acp/permissions.ts
3168
+ var IS_ROOT2 = typeof process.geteuid === "function" ? process.geteuid() === 0 : typeof process.getuid === "function" ? process.getuid() === 0 : false;
3169
+ var ALLOW_BYPASS2 = !IS_ROOT2 || !!process.env.IS_SANDBOX;
3170
+ function createAcpCanUseTool(conn, sessionId, getCurrentMode, clientCapabilities, cwd) {
3171
+ return async (tool, input, _context, _assistantMessage, toolUseID, _forceDecision) => {
3172
+ const supportsTerminalOutput = checkTerminalOutput(clientCapabilities);
3173
+ if (tool.name === "ExitPlanMode") {
3174
+ return handleExitPlanMode(conn, sessionId, toolUseID, input, supportsTerminalOutput, cwd);
3175
+ }
3176
+ if (getCurrentMode() === "bypassPermissions") {
3177
+ return {
3178
+ behavior: "allow",
3179
+ updatedInput: input
3180
+ };
3181
+ }
3182
+ const info = toolInfoFromToolUse({ name: tool.name, id: toolUseID, input }, supportsTerminalOutput, cwd);
3183
+ const toolCall = {
3184
+ toolCallId: toolUseID,
3185
+ title: info.title,
3186
+ kind: info.kind,
3187
+ status: "pending",
3188
+ rawInput: input
3189
+ };
3190
+ const options = [
3191
+ { kind: "allow_always", name: "Always Allow", optionId: "allow_always" },
3192
+ { kind: "allow_once", name: "Allow", optionId: "allow" },
3193
+ { kind: "reject_once", name: "Reject", optionId: "reject" }
3194
+ ];
3195
+ try {
3196
+ const response = await conn.requestPermission({
3197
+ sessionId,
3198
+ toolCall,
3199
+ options
3200
+ });
3201
+ if (response.outcome.outcome === "cancelled") {
3202
+ return {
3203
+ behavior: "deny",
3204
+ message: "Permission request cancelled by client",
3205
+ decisionReason: { type: "mode", mode: "default" }
3206
+ };
3207
+ }
3208
+ if (response.outcome.outcome === "selected" && "optionId" in response.outcome && response.outcome.optionId !== undefined) {
3209
+ const optionId = response.outcome.optionId;
3210
+ if (optionId === "allow" || optionId === "allow_always") {
3211
+ return {
3212
+ behavior: "allow",
3213
+ updatedInput: input
3214
+ };
3215
+ }
3216
+ }
3217
+ return {
3218
+ behavior: "deny",
3219
+ message: "Permission denied by client",
3220
+ decisionReason: { type: "mode", mode: "default" }
3221
+ };
3222
+ } catch {
3223
+ return {
3224
+ behavior: "deny",
3225
+ message: "Permission request failed",
3226
+ decisionReason: { type: "mode", mode: "default" }
3227
+ };
3228
+ }
3229
+ };
3230
+ }
3231
+ async function handleExitPlanMode(conn, sessionId, toolUseID, input, supportsTerminalOutput, cwd) {
3232
+ const options = [
3233
+ { kind: "allow_always", name: 'Yes, and use "auto" mode', optionId: "auto" },
3234
+ { kind: "allow_always", name: "Yes, and auto-accept edits", optionId: "acceptEdits" },
3235
+ { kind: "allow_once", name: "Yes, and manually approve edits", optionId: "default" },
3236
+ { kind: "reject_once", name: "No, keep planning", optionId: "plan" }
3237
+ ];
3238
+ if (ALLOW_BYPASS2) {
3239
+ options.unshift({
3240
+ kind: "allow_always",
3241
+ name: "Yes, and bypass permissions",
3242
+ optionId: "bypassPermissions"
3243
+ });
3244
+ }
3245
+ const info = toolInfoFromToolUse({ name: "ExitPlanMode", id: toolUseID, input }, supportsTerminalOutput, cwd);
3246
+ const toolCall = {
3247
+ toolCallId: toolUseID,
3248
+ title: info.title,
3249
+ kind: info.kind,
3250
+ status: "pending",
3251
+ rawInput: input
3252
+ };
3253
+ const response = await conn.requestPermission({
3254
+ sessionId,
3255
+ toolCall,
3256
+ options
3257
+ });
3258
+ if (response.outcome.outcome === "cancelled") {
3259
+ return {
3260
+ behavior: "deny",
3261
+ message: "Tool use aborted",
3262
+ decisionReason: { type: "mode", mode: "default" }
3263
+ };
3264
+ }
3265
+ if (response.outcome.outcome === "selected" && "optionId" in response.outcome && response.outcome.optionId !== undefined) {
3266
+ const selectedOption = response.outcome.optionId;
3267
+ if (selectedOption === "default" || selectedOption === "acceptEdits" || selectedOption === "auto" || selectedOption === "bypassPermissions") {
3268
+ await conn.sessionUpdate({
3269
+ sessionId,
3270
+ update: {
3271
+ sessionUpdate: "current_mode_update",
3272
+ currentModeId: selectedOption
3273
+ }
3274
+ });
3275
+ return {
3276
+ behavior: "allow",
3277
+ updatedInput: input
3278
+ };
3279
+ }
3280
+ }
3281
+ return {
3282
+ behavior: "deny",
3283
+ message: "User rejected request to exit plan mode.",
3284
+ decisionReason: { type: "mode", mode: "plan" }
3285
+ };
3286
+ }
3287
+ function checkTerminalOutput(clientCapabilities) {
3288
+ if (!clientCapabilities)
3289
+ return false;
3290
+ const meta = clientCapabilities._meta;
3291
+ if (!meta || typeof meta !== "object")
3292
+ return false;
3293
+ return meta["terminal_output"] === true;
3294
+ }
3295
+
3296
+ // src/services/acp/agent.ts
3297
+ init_listSessionsImpl();
3298
+ init_model();
3299
+ init_modelOptions();
3300
+
3301
+ class AcpAgent {
3302
+ conn;
3303
+ sessions = new Map;
3304
+ clientCapabilities;
3305
+ constructor(conn) {
3306
+ this.conn = conn;
3307
+ }
3308
+ async initialize(params) {
3309
+ this.clientCapabilities = params.clientCapabilities;
3310
+ return {
3311
+ protocolVersion: 1,
3312
+ agentInfo: {
3313
+ name: "claude-code",
3314
+ title: "Claude Code",
3315
+ version: typeof globalThis.MACRO === "object" && globalThis.MACRO !== null ? String(globalThis.MACRO.VERSION ?? "0.0.0") : "0.0.0"
3316
+ },
3317
+ agentCapabilities: {
3318
+ _meta: {
3319
+ claudeCode: {
3320
+ promptQueueing: true
3321
+ }
3322
+ },
3323
+ promptCapabilities: {
3324
+ image: true,
3325
+ embeddedContext: true
3326
+ },
3327
+ mcpCapabilities: {
3328
+ http: true,
3329
+ sse: true
3330
+ },
3331
+ loadSession: true,
3332
+ sessionCapabilities: {
3333
+ fork: {},
3334
+ list: {},
3335
+ resume: {},
3336
+ close: {}
3337
+ }
3338
+ }
3339
+ };
3340
+ }
3341
+ async authenticate(_params) {
3342
+ return {};
3343
+ }
3344
+ async newSession(params) {
3345
+ return this.createSession(params);
3346
+ }
3347
+ async unstable_resumeSession(params) {
3348
+ const result = await this.getOrCreateSession(params);
3349
+ setTimeout(() => {
3350
+ this.sendAvailableCommandsUpdate(params.sessionId);
3351
+ }, 0);
3352
+ return result;
3353
+ }
3354
+ async loadSession(params) {
3355
+ const result = await this.getOrCreateSession(params);
3356
+ setTimeout(() => {
3357
+ this.sendAvailableCommandsUpdate(params.sessionId);
3358
+ }, 0);
3359
+ return result;
3360
+ }
3361
+ async listSessions(params) {
3362
+ const candidates = await listSessionsImpl({
3363
+ dir: params.cwd ?? undefined,
3364
+ limit: 100
3365
+ });
3366
+ const sessions = [];
3367
+ for (const candidate of candidates) {
3368
+ if (!candidate.cwd)
3369
+ continue;
3370
+ sessions.push({
3371
+ sessionId: candidate.sessionId,
3372
+ cwd: candidate.cwd,
3373
+ title: sanitizeTitle(candidate.summary ?? ""),
3374
+ updatedAt: new Date(candidate.lastModified).toISOString()
3375
+ });
3376
+ }
3377
+ return { sessions };
3378
+ }
3379
+ async unstable_forkSession(params) {
3380
+ const response = await this.createSession({
3381
+ cwd: params.cwd,
3382
+ mcpServers: params.mcpServers ?? [],
3383
+ _meta: params._meta
3384
+ });
3385
+ setTimeout(() => {
3386
+ this.sendAvailableCommandsUpdate(response.sessionId);
3387
+ }, 0);
3388
+ return response;
3389
+ }
3390
+ async unstable_closeSession(params) {
3391
+ const session = this.sessions.get(params.sessionId);
3392
+ if (!session) {
3393
+ throw new Error("Session not found");
3394
+ }
3395
+ await this.teardownSession(params.sessionId);
3396
+ return {};
3397
+ }
3398
+ async prompt(params) {
3399
+ const session = this.sessions.get(params.sessionId);
3400
+ if (!session) {
3401
+ throw new Error(`Session ${params.sessionId} not found`);
3402
+ }
3403
+ session.cancelled = false;
3404
+ const promptInput = promptToQueryInput(params.prompt);
3405
+ if (!promptInput.trim()) {
3406
+ return { stopReason: "end_turn" };
3407
+ }
3408
+ if (session.promptRunning) {
3409
+ const order = session.nextPendingOrder++;
3410
+ const promptUuid = randomUUID();
3411
+ const cancelled = await new Promise((resolve2) => {
3412
+ session.pendingMessages.set(promptUuid, { resolve: resolve2, order });
3413
+ });
3414
+ if (cancelled) {
3415
+ return { stopReason: "cancelled" };
3416
+ }
3417
+ }
3418
+ session.promptRunning = true;
3419
+ try {
3420
+ session.queryEngine.resetAbortController();
3421
+ const sdkMessages = session.queryEngine.submitMessage(promptInput);
3422
+ const { stopReason, usage } = await forwardSessionUpdates(params.sessionId, sdkMessages, this.conn, session.queryEngine.getAbortSignal(), session.toolUseCache, this.clientCapabilities, session.cwd, () => session.cancelled);
3423
+ if (session.cancelled) {
3424
+ return { stopReason: "cancelled" };
3425
+ }
3426
+ return {
3427
+ stopReason,
3428
+ usage: usage ? {
3429
+ inputTokens: usage.inputTokens,
3430
+ outputTokens: usage.outputTokens,
3431
+ cachedReadTokens: usage.cachedReadTokens,
3432
+ cachedWriteTokens: usage.cachedWriteTokens,
3433
+ totalTokens: usage.inputTokens + usage.outputTokens + usage.cachedReadTokens + usage.cachedWriteTokens
3434
+ } : undefined
3435
+ };
3436
+ } catch (err) {
3437
+ if (session.cancelled) {
3438
+ return { stopReason: "cancelled" };
3439
+ }
3440
+ if (err instanceof Error && (err.message.includes("terminated") || err.message.includes("process exited"))) {
3441
+ this.teardownSession(params.sessionId);
3442
+ throw new Error("The Claude Agent process exited unexpectedly. Please start a new session.");
3443
+ }
3444
+ console.error("[ACP] prompt error:", err);
3445
+ return { stopReason: "end_turn" };
3446
+ } finally {
3447
+ session.promptRunning = false;
3448
+ if (session.pendingMessages.size > 0) {
3449
+ const next = [...session.pendingMessages.entries()].sort((a, b) => a[1].order - b[1].order)[0];
3450
+ if (next) {
3451
+ next[1].resolve(false);
3452
+ session.pendingMessages.delete(next[0]);
3453
+ }
3454
+ }
3455
+ }
3456
+ }
3457
+ async cancel(params) {
3458
+ const session = this.sessions.get(params.sessionId);
3459
+ if (!session)
3460
+ return;
3461
+ session.cancelled = true;
3462
+ for (const [, pending] of session.pendingMessages) {
3463
+ pending.resolve(true);
3464
+ }
3465
+ session.pendingMessages.clear();
3466
+ session.queryEngine.interrupt();
3467
+ }
3468
+ async setSessionMode(params) {
3469
+ const session = this.sessions.get(params.sessionId);
3470
+ if (!session) {
3471
+ throw new Error("Session not found");
3472
+ }
3473
+ this.applySessionMode(params.sessionId, params.modeId);
3474
+ await this.updateConfigOption(params.sessionId, "mode", params.modeId);
3475
+ return {};
3476
+ }
3477
+ async unstable_setSessionModel(params) {
3478
+ const session = this.sessions.get(params.sessionId);
3479
+ if (!session) {
3480
+ throw new Error("Session not found");
3481
+ }
3482
+ session.queryEngine.setModel(params.modelId);
3483
+ await this.updateConfigOption(params.sessionId, "model", params.modelId);
3484
+ }
3485
+ async setSessionConfigOption(params) {
3486
+ const session = this.sessions.get(params.sessionId);
3487
+ if (!session) {
3488
+ throw new Error("Session not found");
3489
+ }
3490
+ if (typeof params.value !== "string") {
3491
+ throw new Error(`Invalid value for config option ${params.configId}: ${String(params.value)}`);
3492
+ }
3493
+ const option = session.configOptions.find((o) => o.id === params.configId);
3494
+ if (!option) {
3495
+ throw new Error(`Unknown config option: ${params.configId}`);
3496
+ }
3497
+ const value = params.value;
3498
+ if (params.configId === "mode") {
3499
+ this.applySessionMode(params.sessionId, value);
3500
+ await this.conn.sessionUpdate({
3501
+ sessionId: params.sessionId,
3502
+ update: {
3503
+ sessionUpdate: "current_mode_update",
3504
+ currentModeId: value
3505
+ }
3506
+ });
3507
+ } else if (params.configId === "model") {
3508
+ session.queryEngine.setModel(value);
3509
+ }
3510
+ this.syncSessionConfigState(session, params.configId, value);
3511
+ session.configOptions = session.configOptions.map((o) => o.id === params.configId && typeof o.currentValue === "string" ? { ...o, currentValue: value } : o);
3512
+ return { configOptions: session.configOptions };
3513
+ }
3514
+ async createSession(params, opts = {}) {
3515
+ enableConfigs();
3516
+ const sessionId = opts.sessionId ?? randomUUID();
3517
+ const cwd = params.cwd;
3518
+ setOriginalCwd(cwd);
3519
+ try {
3520
+ process.chdir(cwd);
3521
+ } catch {}
3522
+ const permissionContext = getEmptyToolPermissionContext();
3523
+ const tools = getTools(permissionContext);
3524
+ const permissionMode = resolvePermissionMode(this.getSetting("permissions.defaultMode"));
3525
+ const canUseTool = createAcpCanUseTool(this.conn, sessionId, () => this.sessions.get(sessionId)?.modes.currentModeId ?? "default", this.clientCapabilities, cwd);
3526
+ const appState = {
3527
+ ...getDefaultAppState(),
3528
+ toolPermissionContext: {
3529
+ ...permissionContext,
3530
+ mode: permissionMode
3531
+ }
3532
+ };
3533
+ const commands = await getCommands(cwd);
3534
+ const engineConfig = {
3535
+ cwd,
3536
+ tools,
3537
+ commands,
3538
+ mcpClients: [],
3539
+ agents: [],
3540
+ canUseTool,
3541
+ getAppState: () => appState,
3542
+ setAppState: (updater) => {
3543
+ const updated = updater(appState);
3544
+ Object.assign(appState, updated);
3545
+ },
3546
+ readFileCache: new FileStateCache(500, 50 * 1024 * 1024),
3547
+ includePartialMessages: true,
3548
+ replayUserMessages: true,
3549
+ initialMessages: opts.initialMessages
3550
+ };
3551
+ const queryEngine = new QueryEngine(engineConfig);
3552
+ const availableModes = [
3553
+ { id: "auto", name: "Auto", description: "Use a model classifier to approve/deny permission prompts." },
3554
+ { id: "default", name: "Default", description: "Standard behavior, prompts for dangerous operations" },
3555
+ { id: "acceptEdits", name: "Accept Edits", description: "Auto-accept file edit operations" },
3556
+ { id: "plan", name: "Plan Mode", description: "Planning mode, no actual tool execution" },
3557
+ { id: "dontAsk", name: "Don't Ask", description: "Don't prompt for permissions, deny if not pre-approved" }
3558
+ ];
3559
+ const modes = {
3560
+ currentModeId: permissionMode,
3561
+ availableModes
3562
+ };
3563
+ const modelOptions = getModelOptions();
3564
+ const currentModel = getMainLoopModel();
3565
+ const models = {
3566
+ availableModels: modelOptions.map((m) => ({
3567
+ modelId: String(m.value ?? ""),
3568
+ name: m.label ?? String(m.value ?? ""),
3569
+ description: m.description ?? undefined
3570
+ })),
3571
+ currentModelId: currentModel
3572
+ };
3573
+ queryEngine.setModel(currentModel);
3574
+ const configOptions = buildConfigOptions(modes, models);
3575
+ const session = {
3576
+ queryEngine,
3577
+ cancelled: false,
3578
+ cwd,
3579
+ modes,
3580
+ models,
3581
+ configOptions,
3582
+ promptRunning: false,
3583
+ pendingMessages: new Map,
3584
+ nextPendingOrder: 0,
3585
+ toolUseCache: {},
3586
+ clientCapabilities: this.clientCapabilities,
3587
+ appState,
3588
+ commands,
3589
+ sessionFingerprint: computeSessionFingerprint({
3590
+ cwd,
3591
+ mcpServers: params.mcpServers
3592
+ })
3593
+ };
3594
+ this.sessions.set(sessionId, session);
3595
+ setTimeout(() => {
3596
+ this.sendAvailableCommandsUpdate(sessionId);
3597
+ }, 0);
3598
+ return {
3599
+ sessionId,
3600
+ models,
3601
+ modes,
3602
+ configOptions
3603
+ };
3604
+ }
3605
+ async getOrCreateSession(params) {
3606
+ const existingSession = this.sessions.get(params.sessionId);
3607
+ if (existingSession) {
3608
+ const fingerprint = computeSessionFingerprint({
3609
+ cwd: params.cwd,
3610
+ mcpServers: params.mcpServers
3611
+ });
3612
+ if (fingerprint === existingSession.sessionFingerprint) {
3613
+ return {
3614
+ sessionId: params.sessionId,
3615
+ modes: existingSession.modes,
3616
+ models: existingSession.models,
3617
+ configOptions: existingSession.configOptions
3618
+ };
3619
+ }
3620
+ await this.teardownSession(params.sessionId);
3621
+ }
3622
+ setOriginalCwd(params.cwd);
3623
+ let initialMessages;
3624
+ if (sessionIdExists(params.sessionId)) {
3625
+ try {
3626
+ const log = await getLastSessionLog(params.sessionId);
3627
+ if (log && log.messages.length > 0) {
3628
+ initialMessages = deserializeMessages(log.messages);
3629
+ }
3630
+ } catch (err) {
3631
+ console.error("[ACP] Failed to load session history:", err);
3632
+ }
3633
+ }
3634
+ const response = await this.createSession({
3635
+ cwd: params.cwd,
3636
+ mcpServers: params.mcpServers ?? [],
3637
+ _meta: params._meta
3638
+ }, { sessionId: params.sessionId, initialMessages });
3639
+ if (initialMessages && initialMessages.length > 0) {
3640
+ const session = this.sessions.get(params.sessionId);
3641
+ if (session) {
3642
+ await replayHistoryMessages(params.sessionId, initialMessages, this.conn, session.toolUseCache, this.clientCapabilities, session.cwd);
3643
+ }
3644
+ }
3645
+ return {
3646
+ sessionId: response.sessionId,
3647
+ modes: response.modes,
3648
+ models: response.models,
3649
+ configOptions: response.configOptions
3650
+ };
3651
+ }
3652
+ async teardownSession(sessionId) {
3653
+ const session = this.sessions.get(sessionId);
3654
+ if (!session)
3655
+ return;
3656
+ await this.cancel({ sessionId });
3657
+ this.sessions.delete(sessionId);
3658
+ }
3659
+ applySessionMode(sessionId, modeId) {
3660
+ const validModes = ["auto", "default", "acceptEdits", "bypassPermissions", "dontAsk", "plan"];
3661
+ if (!validModes.includes(modeId)) {
3662
+ throw new Error(`Invalid mode: ${modeId}`);
3663
+ }
3664
+ const session = this.sessions.get(sessionId);
3665
+ if (session) {
3666
+ session.modes = { ...session.modes, currentModeId: modeId };
3667
+ }
3668
+ }
3669
+ async updateConfigOption(sessionId, configId, value) {
3670
+ const session = this.sessions.get(sessionId);
3671
+ if (!session)
3672
+ return;
3673
+ this.syncSessionConfigState(session, configId, value);
3674
+ session.configOptions = session.configOptions.map((o) => o.id === configId && typeof o.currentValue === "string" ? { ...o, currentValue: value } : o);
3675
+ await this.conn.sessionUpdate({
3676
+ sessionId,
3677
+ update: {
3678
+ sessionUpdate: "config_option_update",
3679
+ configOptions: session.configOptions
3680
+ }
3681
+ });
3682
+ }
3683
+ syncSessionConfigState(session, configId, value) {
3684
+ if (configId === "mode") {
3685
+ session.modes = { ...session.modes, currentModeId: value };
3686
+ } else if (configId === "model") {
3687
+ session.models = { ...session.models, currentModelId: value };
3688
+ }
3689
+ }
3690
+ async sendAvailableCommandsUpdate(sessionId) {
3691
+ const session = this.sessions.get(sessionId);
3692
+ if (!session)
3693
+ return;
3694
+ const availableCommands = session.commands.filter((cmd) => cmd.type === "prompt" && !cmd.isHidden && cmd.userInvocable !== false).map((cmd) => ({
3695
+ name: cmd.name,
3696
+ description: cmd.description,
3697
+ input: cmd.argumentHint ? { hint: cmd.argumentHint } : undefined
3698
+ }));
3699
+ await this.conn.sessionUpdate({
3700
+ sessionId,
3701
+ update: {
3702
+ sessionUpdate: "available_commands_update",
3703
+ availableCommands
3704
+ }
3705
+ });
3706
+ }
3707
+ getSetting(key) {
3708
+ return;
3709
+ }
3710
+ }
3711
+ function promptToQueryInput(prompt) {
3712
+ if (!prompt || prompt.length === 0)
3713
+ return "";
3714
+ const parts = [];
3715
+ for (const block of prompt) {
3716
+ const b = block;
3717
+ if (b.type === "text") {
3718
+ parts.push(b.text);
3719
+ } else if (b.type === "resource_link") {
3720
+ parts.push(`[${b.name ?? ""}](${b.uri})`);
3721
+ } else if (b.type === "resource") {
3722
+ const resource = b.resource;
3723
+ if (resource && "text" in resource) {
3724
+ parts.push(resource.text);
3725
+ }
3726
+ }
3727
+ }
3728
+ return parts.join(`
3729
+ `);
3730
+ }
3731
+ function buildConfigOptions(modes, models) {
3732
+ return [
3733
+ {
3734
+ id: "mode",
3735
+ name: "Mode",
3736
+ description: "Session permission mode",
3737
+ category: "mode",
3738
+ type: "select",
3739
+ currentValue: modes.currentModeId,
3740
+ options: modes.availableModes.map((m) => ({
3741
+ value: m.id,
3742
+ name: m.name,
3743
+ description: m.description
3744
+ }))
3745
+ },
3746
+ {
3747
+ id: "model",
3748
+ name: "Model",
3749
+ description: "AI model to use",
3750
+ category: "model",
3751
+ type: "select",
3752
+ currentValue: models.currentModelId,
3753
+ options: models.availableModels.map((m) => ({
3754
+ value: m.modelId,
3755
+ name: m.name,
3756
+ description: m.description ?? undefined
3757
+ }))
3758
+ }
3759
+ ];
3760
+ }
3761
+
3762
+ // src/services/acp/entry.ts
3763
+ init_config();
3764
+ init_managedEnv();
3765
+ function createAcpStream(nodeReadable, nodeWritable) {
3766
+ const readableFromClient = Readable.toWeb(nodeReadable);
3767
+ const writableToClient = Writable.toWeb(nodeWritable);
3768
+ return ndJsonStream(writableToClient, readableFromClient);
3769
+ }
3770
+ async function runAcpAgent() {
3771
+ enableConfigs();
3772
+ applySafeConfigEnvironmentVariables();
3773
+ const stream2 = createAcpStream(process.stdin, process.stdout);
3774
+ let agent;
3775
+ const connection = new AgentSideConnection((conn) => {
3776
+ agent = new AcpAgent(conn);
3777
+ return agent;
3778
+ }, stream2);
3779
+ console.log = console.error;
3780
+ console.info = console.error;
3781
+ console.warn = console.error;
3782
+ console.debug = console.error;
3783
+ async function shutdown() {
3784
+ for (const [sessionId] of agent.sessions) {
3785
+ try {
3786
+ await agent.unstable_closeSession({ sessionId });
3787
+ } catch {}
3788
+ }
3789
+ process.exit(0);
3790
+ }
3791
+ connection.closed.then(shutdown).catch(shutdown);
3792
+ process.on("SIGTERM", shutdown);
3793
+ process.on("SIGINT", shutdown);
3794
+ process.on("unhandledRejection", (reason, promise) => {
3795
+ console.error("Unhandled Rejection at:", promise, "reason:", reason);
3796
+ });
3797
+ process.stdin.resume();
3798
+ }
3799
+ export {
3800
+ runAcpAgent,
3801
+ createAcpStream
3802
+ };