@redscope-ai/redscope 1.0.0
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.
- package/README.md +224 -0
- package/dist/chunk-090920rk.js +288 -0
- package/dist/chunk-0afb2r78.js +141 -0
- package/dist/chunk-0d4ekx1g.js +73 -0
- package/dist/chunk-0g6nwbhq.js +15 -0
- package/dist/chunk-0qj905nt.js +18 -0
- package/dist/chunk-0s5btnn1.js +186 -0
- package/dist/chunk-0s8fars0.js +91 -0
- package/dist/chunk-10ev3dvh.js +312 -0
- package/dist/chunk-10k5jfc5.js +1295 -0
- package/dist/chunk-12tspwqa.js +240 -0
- package/dist/chunk-13qesvnw.js +17 -0
- package/dist/chunk-143eh1e0.js +121 -0
- package/dist/chunk-14p6wvsq.js +39 -0
- package/dist/chunk-19f3zb1m.js +342 -0
- package/dist/chunk-1a5cep8h.js +145 -0
- package/dist/chunk-1abw9kkn.js +34 -0
- package/dist/chunk-1aer7c78.js +118 -0
- package/dist/chunk-1dazz4g6.js +154 -0
- package/dist/chunk-1fcf4ty1.js +142 -0
- package/dist/chunk-1gnxhyf8.js +62 -0
- package/dist/chunk-1he3944e.js +8124 -0
- package/dist/chunk-1jpayz7y.js +952 -0
- package/dist/chunk-1qd6f6vk.js +269 -0
- package/dist/chunk-1v0kpe62.js +2547 -0
- package/dist/chunk-1w20m7gw.js +445 -0
- package/dist/chunk-1y7kp51j.js +72 -0
- package/dist/chunk-1ycb5sxt.js +247 -0
- package/dist/chunk-1zbwhcbt.js +1124 -0
- package/dist/chunk-20psem54.js +116 -0
- package/dist/chunk-23h69r5b.js +30 -0
- package/dist/chunk-23x86ptv.js +473 -0
- package/dist/chunk-24fyv3jz.js +378 -0
- package/dist/chunk-24kv69g3.js +97 -0
- package/dist/chunk-2azx8zsc.js +125 -0
- package/dist/chunk-2d1gwzz9.js +524 -0
- package/dist/chunk-2g0ytd9d.js +29058 -0
- package/dist/chunk-2hfp9kat.js +21 -0
- package/dist/chunk-2j875eq6.js +37 -0
- package/dist/chunk-2kcgxnvp.js +39 -0
- package/dist/chunk-2kz09j2s.js +23 -0
- package/dist/chunk-2mwnwp0n.js +17 -0
- package/dist/chunk-2p1cqhcn.js +921 -0
- package/dist/chunk-2p369q9z.js +61 -0
- package/dist/chunk-2rf6asgf.js +151 -0
- package/dist/chunk-2vr7mqx1.js +384 -0
- package/dist/chunk-2xcg933e.js +205 -0
- package/dist/chunk-2ypwckbz.js +40310 -0
- package/dist/chunk-30wnahyg.js +626 -0
- package/dist/chunk-326zehp8.js +204 -0
- package/dist/chunk-32s6jzgw.js +183 -0
- package/dist/chunk-35yzt1a7.js +202 -0
- package/dist/chunk-38frkej6.js +62 -0
- package/dist/chunk-3abaq08g.js +34 -0
- package/dist/chunk-3h59ttr5.js +32 -0
- package/dist/chunk-3nk9q8dr.js +154 -0
- package/dist/chunk-3prrxevm.js +224 -0
- package/dist/chunk-3tv8p9xw.js +127 -0
- package/dist/chunk-3txyekes.js +19 -0
- package/dist/chunk-3vfxjn7g.js +19 -0
- package/dist/chunk-3w9sye8h.js +81 -0
- package/dist/chunk-3y69j7y8.js +24 -0
- package/dist/chunk-3zwjpkjh.js +1603 -0
- package/dist/chunk-40t1d75v.js +3442 -0
- package/dist/chunk-470kmby4.js +318 -0
- package/dist/chunk-47jc141z.js +335 -0
- package/dist/chunk-48rz50ct.js +868 -0
- package/dist/chunk-49wv03ts.js +232 -0
- package/dist/chunk-4a189mn2.js +103 -0
- package/dist/chunk-4c4fmh7a.js +15 -0
- package/dist/chunk-4ct8dsj5.js +49 -0
- package/dist/chunk-4kqt1pm1.js +100 -0
- package/dist/chunk-4ng0xy0e.js +802 -0
- package/dist/chunk-4spgkgr3.js +43 -0
- package/dist/chunk-4tjdwtyy.js +19 -0
- package/dist/chunk-4tr60273.js +370 -0
- package/dist/chunk-4vnaeng5.js +29 -0
- package/dist/chunk-4wbqpeaw.js +871 -0
- package/dist/chunk-4wgkv3fv.js +1140 -0
- package/dist/chunk-4yjskjb6.js +40 -0
- package/dist/chunk-50m3a23z.js +35 -0
- package/dist/chunk-511f79az.js +182 -0
- package/dist/chunk-51sgztvv.js +161 -0
- package/dist/chunk-563fcpv1.js +290 -0
- package/dist/chunk-564cnq6v.js +735 -0
- package/dist/chunk-569r8cxc.js +31 -0
- package/dist/chunk-570x55d4.js +12 -0
- package/dist/chunk-571556cm.js +80 -0
- package/dist/chunk-59t4c56e.js +63 -0
- package/dist/chunk-5axjhkma.js +36 -0
- package/dist/chunk-5b188q5e.js +157 -0
- package/dist/chunk-5dmn1865.js +439 -0
- package/dist/chunk-5ks4829r.js +267 -0
- package/dist/chunk-5mmhfbxb.js +1078 -0
- package/dist/chunk-5rdt14hy.js +742 -0
- package/dist/chunk-5ssryexj.js +121 -0
- package/dist/chunk-5v95pnq4.js +15 -0
- package/dist/chunk-5xvjt2t9.js +68 -0
- package/dist/chunk-5zyq6t1q.js +118 -0
- package/dist/chunk-60fkafk2.js +15 -0
- package/dist/chunk-62fjkf5q.js +46 -0
- package/dist/chunk-64gazrrb.js +8067 -0
- package/dist/chunk-65tq2yjx.js +126 -0
- package/dist/chunk-65zbgg1n.js +14 -0
- package/dist/chunk-66v8mty3.js +264 -0
- package/dist/chunk-6acx5heq.js +292 -0
- package/dist/chunk-6hr7742d.js +61 -0
- package/dist/chunk-6hygvrhn.js +143 -0
- package/dist/chunk-6kjh280m.js +128 -0
- package/dist/chunk-6s0q1s5r.js +66 -0
- package/dist/chunk-6x35ffpx.js +690 -0
- package/dist/chunk-71jfy1hh.js +570 -0
- package/dist/chunk-71sdcaq6.js +15 -0
- package/dist/chunk-754qdxs5.js +92 -0
- package/dist/chunk-79v5bkj4.js +1176 -0
- package/dist/chunk-7br0w7j5.js +151 -0
- package/dist/chunk-7cjgrzz1.js +298 -0
- package/dist/chunk-7d41ks0y.js +133 -0
- package/dist/chunk-7f40pmtr.js +71 -0
- package/dist/chunk-7g15x8hm.js +131 -0
- package/dist/chunk-7gtnzdet.js +120 -0
- package/dist/chunk-7h0z4aqx.js +702 -0
- package/dist/chunk-7h7e5a7d.js +25 -0
- package/dist/chunk-7m2cznwr.js +40 -0
- package/dist/chunk-7nvday0n.js +252 -0
- package/dist/chunk-7qey87th.js +145 -0
- package/dist/chunk-7qx3xhv3.js +9076 -0
- package/dist/chunk-7tfdhkpy.js +61 -0
- package/dist/chunk-80m511j6.js +121 -0
- package/dist/chunk-80ysxfe9.js +784 -0
- package/dist/chunk-8375zk8t.js +17200 -0
- package/dist/chunk-85bpkyy9.js +412 -0
- package/dist/chunk-85tcn547.js +876 -0
- package/dist/chunk-85vqgbc8.js +13 -0
- package/dist/chunk-86626jb4.js +49 -0
- package/dist/chunk-87ms17f6.js +444 -0
- package/dist/chunk-87mz239c.js +118 -0
- package/dist/chunk-89vdzt4e.js +254 -0
- package/dist/chunk-89z3e99z.js +159 -0
- package/dist/chunk-8cwrz1dd.js +1806 -0
- package/dist/chunk-8gv2pjby.js +21 -0
- package/dist/chunk-8hdevr3s.js +140 -0
- package/dist/chunk-8hdsk6qc.js +710 -0
- package/dist/chunk-8kct9arg.js +724 -0
- package/dist/chunk-8kf8h7xf.js +23 -0
- package/dist/chunk-8qed8ymj.js +605 -0
- package/dist/chunk-8sdgr592.js +101 -0
- package/dist/chunk-8we9w8pw.js +111 -0
- package/dist/chunk-8xnm5637.js +72 -0
- package/dist/chunk-8y3q0eqy.js +67 -0
- package/dist/chunk-8yvsnrkr.js +3449 -0
- package/dist/chunk-8zz4z1q3.js +42 -0
- package/dist/chunk-90eyff3k.js +119 -0
- package/dist/chunk-92bjkrf2.js +121 -0
- package/dist/chunk-92zrc7c6.js +327 -0
- package/dist/chunk-935nrvdb.js +13 -0
- package/dist/chunk-94pfyv6a.js +48 -0
- package/dist/chunk-9568p8se.js +115 -0
- package/dist/chunk-96km1ywr.js +37 -0
- package/dist/chunk-980bg4w4.js +163 -0
- package/dist/chunk-9a9g5hbj.js +205 -0
- package/dist/chunk-9cm4725d.js +4395 -0
- package/dist/chunk-9ds3vzq8.js +847 -0
- package/dist/chunk-9ffc9n60.js +618 -0
- package/dist/chunk-9fstrwv2.js +184 -0
- package/dist/chunk-9gt0g0qe.js +153 -0
- package/dist/chunk-9h9k5vz3.js +2761 -0
- package/dist/chunk-9he8bmhy.js +17 -0
- package/dist/chunk-9hn8e6h1.js +12 -0
- package/dist/chunk-9j0n3g8e.js +179 -0
- package/dist/chunk-9j6pa3ft.js +251 -0
- package/dist/chunk-9jpg9dn7.js +122 -0
- package/dist/chunk-9mycnwj5.js +46 -0
- package/dist/chunk-9npy2c17.js +517 -0
- package/dist/chunk-9p6sec8n.js +34 -0
- package/dist/chunk-9pnym83h.js +4584 -0
- package/dist/chunk-9skwrnd2.js +25 -0
- package/dist/chunk-9tsfaqr8.js +459 -0
- package/dist/chunk-9tsw3cqv.js +5924 -0
- package/dist/chunk-9w6ckyk4.js +49 -0
- package/dist/chunk-a15bwzv6.js +147 -0
- package/dist/chunk-a9t6cp69.js +28 -0
- package/dist/chunk-ad2yk19p.js +102 -0
- package/dist/chunk-ad4cw4nw.js +336 -0
- package/dist/chunk-ad69fbsk.js +347 -0
- package/dist/chunk-ae76ded0.js +30 -0
- package/dist/chunk-aeysytks.js +216 -0
- package/dist/chunk-ag81m9bq.js +61 -0
- package/dist/chunk-ahx7gp6r.js +4448 -0
- package/dist/chunk-aj4tk4tk.js +23 -0
- package/dist/chunk-an82t9jc.js +104 -0
- package/dist/chunk-apg95qd7.js +1393 -0
- package/dist/chunk-aq5n2adz.js +27 -0
- package/dist/chunk-aw4s3a99.js +208 -0
- package/dist/chunk-awgdfggg.js +14 -0
- package/dist/chunk-ayymxgn1.js +164 -0
- package/dist/chunk-azbab59e.js +637 -0
- package/dist/chunk-azdxq2a3.js +293 -0
- package/dist/chunk-b0tjx3k1.js +523 -0
- package/dist/chunk-b5pp4g2g.js +371 -0
- package/dist/chunk-b5zm8dt6.js +26 -0
- package/dist/chunk-bcnye5a0.js +109 -0
- package/dist/chunk-beqz3k49.js +190 -0
- package/dist/chunk-bf906wpw.js +147 -0
- package/dist/chunk-bgan4cpf.js +13 -0
- package/dist/chunk-bhzp13h7.js +1178 -0
- package/dist/chunk-bk403kpw.js +142 -0
- package/dist/chunk-bmq4c135.js +489 -0
- package/dist/chunk-bprbeda7.js +35 -0
- package/dist/chunk-bst7czdd.js +888 -0
- package/dist/chunk-bths4xgn.js +111 -0
- package/dist/chunk-btjn3qby.js +13 -0
- package/dist/chunk-bwb1vxnt.js +120 -0
- package/dist/chunk-bxa6tw4m.js +643 -0
- package/dist/chunk-bxfjr8qb.js +27 -0
- package/dist/chunk-bxpzhrej.js +73 -0
- package/dist/chunk-bzyzrq0k.js +51 -0
- package/dist/chunk-c0k7b0jw.js +4265 -0
- package/dist/chunk-c17f0h2s.js +16 -0
- package/dist/chunk-c1yc761e.js +6748 -0
- package/dist/chunk-c5g9shkw.js +298 -0
- package/dist/chunk-c696122m.js +69 -0
- package/dist/chunk-c92b3yxx.js +109 -0
- package/dist/chunk-c9aqz56y.js +143 -0
- package/dist/chunk-cba7c5w3.js +345 -0
- package/dist/chunk-cbcxbbe6.js +6543 -0
- package/dist/chunk-cdfjb87h.js +11 -0
- package/dist/chunk-ce8zjt1y.js +136 -0
- package/dist/chunk-cep7e37k.js +22740 -0
- package/dist/chunk-chs5qm8d.js +258 -0
- package/dist/chunk-ckydq33g.js +144 -0
- package/dist/chunk-cnge6wpj.js +514 -0
- package/dist/chunk-cpnsvqf1.js +13 -0
- package/dist/chunk-cqqebkv4.js +32 -0
- package/dist/chunk-cvqpp7dk.js +627 -0
- package/dist/chunk-cwc33j40.js +65 -0
- package/dist/chunk-cypvrq2a.js +155 -0
- package/dist/chunk-d1ha0swn.js +475 -0
- package/dist/chunk-d2an0138.js +35 -0
- package/dist/chunk-d2tt72ck.js +343 -0
- package/dist/chunk-d6wvcqrw.js +9507 -0
- package/dist/chunk-d7ys2kka.js +991 -0
- package/dist/chunk-dbts5q5p.js +122 -0
- package/dist/chunk-dct29ggs.js +295 -0
- package/dist/chunk-de0qnnf7.js +1059 -0
- package/dist/chunk-dep72ce4.js +513 -0
- package/dist/chunk-dgpvgy8x.js +47 -0
- package/dist/chunk-dhhd7dtc.js +20 -0
- package/dist/chunk-dhzpmxv6.js +594 -0
- package/dist/chunk-djes4da7.js +413 -0
- package/dist/chunk-dnhv3vx7.js +166 -0
- package/dist/chunk-dqtvafan.js +2365 -0
- package/dist/chunk-dr4a3tcp.js +60 -0
- package/dist/chunk-dz2xk9kb.js +100 -0
- package/dist/chunk-dz7nc6rf.js +15 -0
- package/dist/chunk-e3abfxpy.js +1486 -0
- package/dist/chunk-e3cq9z89.js +85 -0
- package/dist/chunk-e3j7m7k2.js +642 -0
- package/dist/chunk-e4dsy4g1.js +9951 -0
- package/dist/chunk-e5592pnn.js +197 -0
- package/dist/chunk-e55hdegh.js +129 -0
- package/dist/chunk-e5r5r04e.js +1030 -0
- package/dist/chunk-e60zztbt.js +442 -0
- package/dist/chunk-e7qq6vn0.js +372 -0
- package/dist/chunk-e9aat7xw.js +80 -0
- package/dist/chunk-e9d5v3zs.js +143 -0
- package/dist/chunk-eax32zk4.js +87 -0
- package/dist/chunk-ebfwmbx1.js +117 -0
- package/dist/chunk-ec71pb8t.js +971 -0
- package/dist/chunk-eemjb825.js +17252 -0
- package/dist/chunk-ees8xdhd.js +256 -0
- package/dist/chunk-eewg66y1.js +112 -0
- package/dist/chunk-eg22v12d.js +266 -0
- package/dist/chunk-enzzk67f.js +313 -0
- package/dist/chunk-eskhp70f.js +117 -0
- package/dist/chunk-ewx6z4g8.js +55 -0
- package/dist/chunk-eyvx461k.js +76 -0
- package/dist/chunk-eztq2b5f.js +94 -0
- package/dist/chunk-f0ffwzdd.js +321 -0
- package/dist/chunk-f80n68mf.js +119 -0
- package/dist/chunk-fae2hjxp.js +99 -0
- package/dist/chunk-fbtfp370.js +60 -0
- package/dist/chunk-fc6ndtgf.js +94 -0
- package/dist/chunk-fdwabr8p.js +13870 -0
- package/dist/chunk-fejeqe61.js +785 -0
- package/dist/chunk-fh0d6mvk.js +168 -0
- package/dist/chunk-fh19zcaf.js +304 -0
- package/dist/chunk-fh8bd39r.js +186 -0
- package/dist/chunk-fj2ebbpn.js +33 -0
- package/dist/chunk-fjn632v7.js +194 -0
- package/dist/chunk-fncpkzs5.js +1389 -0
- package/dist/chunk-fpd1gpt8.js +332 -0
- package/dist/chunk-fq9snrnh.js +295 -0
- package/dist/chunk-fqcfzg3j.js +207 -0
- package/dist/chunk-ftt3vqj2.js +1919 -0
- package/dist/chunk-g06pm4n9.js +395 -0
- package/dist/chunk-g4m5pf4g.js +8 -0
- package/dist/chunk-g72h52y6.js +36 -0
- package/dist/chunk-g79ej71s.js +1627 -0
- package/dist/chunk-g7fwk59d.js +19 -0
- package/dist/chunk-g9jnkrtm.js +663 -0
- package/dist/chunk-g9vg5d7t.js +38 -0
- package/dist/chunk-ga1jkyqy.js +1636 -0
- package/dist/chunk-gaaap2nk.js +676 -0
- package/dist/chunk-gc6erq5q.js +483 -0
- package/dist/chunk-gjrcmf0a.js +752 -0
- package/dist/chunk-gmdy2w3z.js +238999 -0
- package/dist/chunk-gsz4yrrk.js +81 -0
- package/dist/chunk-gy47rjy8.js +3830 -0
- package/dist/chunk-h12a4f4x.js +11 -0
- package/dist/chunk-h1yratmg.js +725 -0
- package/dist/chunk-h9y0jnsy.js +155 -0
- package/dist/chunk-hbhs3mwy.js +133 -0
- package/dist/chunk-hbs8cmb4.js +8 -0
- package/dist/chunk-hdk0t1ht.js +940 -0
- package/dist/chunk-hef8dx4s.js +178 -0
- package/dist/chunk-hgsca8mt.js +381 -0
- package/dist/chunk-hhsxm2yr.js +67 -0
- package/dist/chunk-hj5tzzpd.js +39 -0
- package/dist/chunk-hjxqmtg5.js +94 -0
- package/dist/chunk-hn4w9pkj.js +68 -0
- package/dist/chunk-hnprkjgp.js +25 -0
- package/dist/chunk-hq3n5ex7.js +183 -0
- package/dist/chunk-hqjspfma.js +158 -0
- package/dist/chunk-hqxp6b72.js +1198 -0
- package/dist/chunk-hs6nrmq6.js +94 -0
- package/dist/chunk-hwba5xdc.js +267 -0
- package/dist/chunk-hy566ev3.js +430 -0
- package/dist/chunk-hzmzwte2.js +153 -0
- package/dist/chunk-hzxzvzw8.js +274 -0
- package/dist/chunk-j139fzgs.js +114 -0
- package/dist/chunk-j1mep9ck.js +62 -0
- package/dist/chunk-j3xveeg4.js +273 -0
- package/dist/chunk-j5y1s11j.js +100 -0
- package/dist/chunk-j9475b46.js +26 -0
- package/dist/chunk-j9rgqs8m.js +1192 -0
- package/dist/chunk-jccjaddz.js +74 -0
- package/dist/chunk-jdkwfy9e.js +35 -0
- package/dist/chunk-jdqp0r4h.js +6157 -0
- package/dist/chunk-jdzk4zwn.js +587 -0
- package/dist/chunk-jfafmkte.js +49 -0
- package/dist/chunk-jg3r989b.js +16 -0
- package/dist/chunk-jhtccjc9.js +54 -0
- package/dist/chunk-jj2ff1pr.js +688 -0
- package/dist/chunk-jmv7k0jn.js +37 -0
- package/dist/chunk-jmxzmwpw.js +65 -0
- package/dist/chunk-jnjxdqyr.js +353 -0
- package/dist/chunk-jsbbez9j.js +138 -0
- package/dist/chunk-jvpt2dc0.js +424 -0
- package/dist/chunk-jwd7cka0.js +34 -0
- package/dist/chunk-jy5er3st.js +15 -0
- package/dist/chunk-jyby79z5.js +121 -0
- package/dist/chunk-jzyr6j5n.js +332 -0
- package/dist/chunk-k49xc781.js +63 -0
- package/dist/chunk-k7dt2g4a.js +41 -0
- package/dist/chunk-k7hexw3v.js +969 -0
- package/dist/chunk-k7wwkraa.js +117 -0
- package/dist/chunk-kb3758f7.js +51 -0
- package/dist/chunk-kc67kt75.js +3119 -0
- package/dist/chunk-kdhmfxmh.js +3149 -0
- package/dist/chunk-kejdd6zc.js +51 -0
- package/dist/chunk-kekrjeem.js +402 -0
- package/dist/chunk-kez5r0zz.js +280 -0
- package/dist/chunk-kfsvcs5t.js +75 -0
- package/dist/chunk-khtvffc4.js +285 -0
- package/dist/chunk-kkz4w1tv.js +64 -0
- package/dist/chunk-kmywng0j.js +272 -0
- package/dist/chunk-kq6vcpdr.js +224 -0
- package/dist/chunk-kqzdszcc.js +37 -0
- package/dist/chunk-ktxpp02w.js +435 -0
- package/dist/chunk-kwcvhbtz.js +26 -0
- package/dist/chunk-kx0cm9qr.js +128 -0
- package/dist/chunk-kxcmqz10.js +120 -0
- package/dist/chunk-kxwava1g.js +14 -0
- package/dist/chunk-kywtr3jg.js +825 -0
- package/dist/chunk-kzwg923p.js +8 -0
- package/dist/chunk-m1eq3sgv.js +255 -0
- package/dist/chunk-m21h5zb4.js +119 -0
- package/dist/chunk-m2c3bjv1.js +111 -0
- package/dist/chunk-m41e19ms.js +42 -0
- package/dist/chunk-m7ka36ex.js +97 -0
- package/dist/chunk-m81w8tbm.js +259 -0
- package/dist/chunk-m95ggkax.js +281 -0
- package/dist/chunk-manx26xa.js +145 -0
- package/dist/chunk-mdxh3pk2.js +298 -0
- package/dist/chunk-mhbfkcja.js +311 -0
- package/dist/chunk-mjnr5erm.js +173 -0
- package/dist/chunk-mngvnmwp.js +135 -0
- package/dist/chunk-mvfqanv5.js +63 -0
- package/dist/chunk-mw1nesq1.js +140 -0
- package/dist/chunk-mx168925.js +661 -0
- package/dist/chunk-mxwvj18g.js +795 -0
- package/dist/chunk-my7r5mba.js +257 -0
- package/dist/chunk-myaa1kkf.js +17 -0
- package/dist/chunk-myypc3tn.js +46 -0
- package/dist/chunk-mzcnmnpq.js +3379 -0
- package/dist/chunk-mznav6d1.js +194 -0
- package/dist/chunk-n0qxskpr.js +24 -0
- package/dist/chunk-n6a6hgtp.js +394 -0
- package/dist/chunk-n6d5fgx0.js +254 -0
- package/dist/chunk-n6ym3n03.js +120 -0
- package/dist/chunk-n9g24mwe.js +104 -0
- package/dist/chunk-naamqdf9.js +185 -0
- package/dist/chunk-nb2jk7zj.js +15 -0
- package/dist/chunk-nbkbq9en.js +67 -0
- package/dist/chunk-ndttd6es.js +38 -0
- package/dist/chunk-nfygaaxg.js +133 -0
- package/dist/chunk-ngdzpszd.js +454 -0
- package/dist/chunk-nmfwksa4.js +1297 -0
- package/dist/chunk-nt837qt9.js +21 -0
- package/dist/chunk-nwc3v0vp.js +691 -0
- package/dist/chunk-nz8ha95p.js +3610 -0
- package/dist/chunk-nzxfj0gq.js +2007 -0
- package/dist/chunk-p0r8887g.js +6932 -0
- package/dist/chunk-p1seyqdm.js +120 -0
- package/dist/chunk-p425zbgw.js +726 -0
- package/dist/chunk-p7hamd2c.js +146 -0
- package/dist/chunk-pdvg91cg.js +32 -0
- package/dist/chunk-pecy49yr.js +14649 -0
- package/dist/chunk-pfxrg89f.js +547 -0
- package/dist/chunk-pfyw3155.js +2750 -0
- package/dist/chunk-pr8m11pm.js +1192 -0
- package/dist/chunk-ptxteaeh.js +1591 -0
- package/dist/chunk-pv164mac.js +394 -0
- package/dist/chunk-pxxhtxf5.js +10154 -0
- package/dist/chunk-q0e485mg.js +61 -0
- package/dist/chunk-q1vrhh0q.js +458 -0
- package/dist/chunk-q2h79ncs.js +370 -0
- package/dist/chunk-q3b4n194.js +56 -0
- package/dist/chunk-q44zc68f.js +4301 -0
- package/dist/chunk-q8gknbdx.js +352 -0
- package/dist/chunk-q8xk3kdj.js +11 -0
- package/dist/chunk-qak46xtp.js +119 -0
- package/dist/chunk-qfq7absv.js +95 -0
- package/dist/chunk-qfsn720k.js +151 -0
- package/dist/chunk-qg4811f6.js +228 -0
- package/dist/chunk-qgzn3qps.js +90 -0
- package/dist/chunk-qhaggqkt.js +113 -0
- package/dist/chunk-qjjp27z8.js +195 -0
- package/dist/chunk-qxp0nye6.js +34 -0
- package/dist/chunk-qy3nagaq.js +4957 -0
- package/dist/chunk-qz2meav1.js +1452 -0
- package/dist/chunk-r50hne7m.js +63 -0
- package/dist/chunk-r6m0vgnv.js +80 -0
- package/dist/chunk-r7yw38vf.js +22864 -0
- package/dist/chunk-r8xc618w.js +42 -0
- package/dist/chunk-r961r5kj.js +87 -0
- package/dist/chunk-r9b5xrh0.js +66 -0
- package/dist/chunk-rcn2pd6q.js +477 -0
- package/dist/chunk-rdeh8p3y.js +148 -0
- package/dist/chunk-rg9x1742.js +542 -0
- package/dist/chunk-rgyzsbs3.js +39 -0
- package/dist/chunk-rk2fsxtz.js +16 -0
- package/dist/chunk-rkchkwv9.js +40 -0
- package/dist/chunk-rp8whpb3.js +478 -0
- package/dist/chunk-rpkxdtgr.js +68 -0
- package/dist/chunk-rpmntgyh.js +394 -0
- package/dist/chunk-rpshz4dy.js +614 -0
- package/dist/chunk-rqd60ay5.js +133 -0
- package/dist/chunk-rrsjf2ea.js +229 -0
- package/dist/chunk-rtjk8c8e.js +173 -0
- package/dist/chunk-rw0y2wdf.js +1017 -0
- package/dist/chunk-rx5w7ess.js +663 -0
- package/dist/chunk-rx8t9d35.js +1947 -0
- package/dist/chunk-rxcazxgf.js +195 -0
- package/dist/chunk-rxg6q3bp.js +1413 -0
- package/dist/chunk-rxrb7xnd.js +71 -0
- package/dist/chunk-rxrzxff3.js +118 -0
- package/dist/chunk-ryqjc943.js +71 -0
- package/dist/chunk-rzk9k2rf.js +81 -0
- package/dist/chunk-s2qv0nht.js +119 -0
- package/dist/chunk-s3hafnk3.js +2285 -0
- package/dist/chunk-s4a496tt.js +226 -0
- package/dist/chunk-s4d1h3ka.js +35 -0
- package/dist/chunk-sm3k3ze4.js +16525 -0
- package/dist/chunk-sn0bja82.js +385 -0
- package/dist/chunk-sngjggw1.js +4227 -0
- package/dist/chunk-sq047n34.js +364 -0
- package/dist/chunk-sttwe2tw.js +8584 -0
- package/dist/chunk-sw8qx1r0.js +86 -0
- package/dist/chunk-swstah6a.js +240 -0
- package/dist/chunk-syrkr0mf.js +63 -0
- package/dist/chunk-sz206bd9.js +26 -0
- package/dist/chunk-t09669cj.js +333 -0
- package/dist/chunk-t5f8e30k.js +602 -0
- package/dist/chunk-t5m78mc8.js +432 -0
- package/dist/chunk-t5x1dqwn.js +143 -0
- package/dist/chunk-t877ea0w.js +168 -0
- package/dist/chunk-t91hb71c.js +17 -0
- package/dist/chunk-tb636bcf.js +942 -0
- package/dist/chunk-tb8sykbr.js +426 -0
- package/dist/chunk-tbdkekz3.js +125 -0
- package/dist/chunk-td2gsz7s.js +225 -0
- package/dist/chunk-tenvxbyh.js +20 -0
- package/dist/chunk-texg4qqt.js +317 -0
- package/dist/chunk-teymzz80.js +266 -0
- package/dist/chunk-tj26qpf7.js +153 -0
- package/dist/chunk-tk85ec4p.js +395 -0
- package/dist/chunk-tq205h01.js +164 -0
- package/dist/chunk-tqzddjzg.js +61 -0
- package/dist/chunk-trqrj23e.js +134 -0
- package/dist/chunk-tw1hfsxv.js +2477 -0
- package/dist/chunk-txxdfq83.js +122 -0
- package/dist/chunk-v0yhe582.js +31 -0
- package/dist/chunk-v14184xm.js +15 -0
- package/dist/chunk-v1h9z4hw.js +138 -0
- package/dist/chunk-v3ey5j7f.js +329 -0
- package/dist/chunk-v3nh1sfn.js +208 -0
- package/dist/chunk-v3x8tcc0.js +45 -0
- package/dist/chunk-v4nqnvqq.js +3984 -0
- package/dist/chunk-v4ypszbb.js +15 -0
- package/dist/chunk-v7wbqcx9.js +63 -0
- package/dist/chunk-v8r5fev3.js +341 -0
- package/dist/chunk-v9zg5kzx.js +2810 -0
- package/dist/chunk-va1wh5ss.js +24 -0
- package/dist/chunk-vbfswhht.js +42 -0
- package/dist/chunk-ve7x2tfq.js +124 -0
- package/dist/chunk-vfz8k89y.js +485 -0
- package/dist/chunk-vgm5k14x.js +35678 -0
- package/dist/chunk-vh9pej3c.js +247 -0
- package/dist/chunk-vjxqyt6f.js +3820 -0
- package/dist/chunk-vpb1xstn.js +178 -0
- package/dist/chunk-vqt79tj8.js +110 -0
- package/dist/chunk-vr0n9pv9.js +152 -0
- package/dist/chunk-vrejmja5.js +90 -0
- package/dist/chunk-vrxasmdw.js +449 -0
- package/dist/chunk-vrxb946v.js +125 -0
- package/dist/chunk-vv4kj0q8.js +98 -0
- package/dist/chunk-vvpfng7w.js +8 -0
- package/dist/chunk-vw6ybyew.js +2007 -0
- package/dist/chunk-vwenx8ke.js +17 -0
- package/dist/chunk-vwfa0s5a.js +155 -0
- package/dist/chunk-vx71j8xe.js +63 -0
- package/dist/chunk-vxbjzggp.js +43 -0
- package/dist/chunk-vxjxtz8w.js +440 -0
- package/dist/chunk-vy0c1bwp.js +9 -0
- package/dist/chunk-w3zczyse.js +14 -0
- package/dist/chunk-w4p5t920.js +655 -0
- package/dist/chunk-w68wc625.js +287 -0
- package/dist/chunk-w9ddp3yf.js +96 -0
- package/dist/chunk-wcggm5ja.js +125 -0
- package/dist/chunk-wgnyph3q.js +1306 -0
- package/dist/chunk-wjm5pc1e.js +134 -0
- package/dist/chunk-wnve0drm.js +131 -0
- package/dist/chunk-wp27ev2k.js +135 -0
- package/dist/chunk-wyvy8a4x.js +131 -0
- package/dist/chunk-x671y4dk.js +129 -0
- package/dist/chunk-xbj5keyy.js +22 -0
- package/dist/chunk-xf4fzms8.js +39 -0
- package/dist/chunk-xf59k3zg.js +65 -0
- package/dist/chunk-xgzc4w49.js +204 -0
- package/dist/chunk-xhj7g13b.js +2149 -0
- package/dist/chunk-xjp0cd00.js +56 -0
- package/dist/chunk-xkhnmhqs.js +74 -0
- package/dist/chunk-xkrkqx61.js +55 -0
- package/dist/chunk-xmpgmeb8.js +114 -0
- package/dist/chunk-xrw80zgd.js +4249 -0
- package/dist/chunk-xrzc96g0.js +202 -0
- package/dist/chunk-xt76sm44.js +318 -0
- package/dist/chunk-xwet3awb.js +20 -0
- package/dist/chunk-xyg1sk2w.js +78 -0
- package/dist/chunk-y0jpkqb0.js +180 -0
- package/dist/chunk-y1q7rt9n.js +102 -0
- package/dist/chunk-y67ntyek.js +258 -0
- package/dist/chunk-ybk37qp9.js +37 -0
- package/dist/chunk-yc1stfve.js +5386 -0
- package/dist/chunk-ychjpjef.js +62 -0
- package/dist/chunk-yez8fa9g.js +276 -0
- package/dist/chunk-ygm7xszr.js +90 -0
- package/dist/chunk-ym11azkj.js +37 -0
- package/dist/chunk-ympz2h15.js +578 -0
- package/dist/chunk-yqx3az3n.js +129 -0
- package/dist/chunk-yt3nfhcc.js +152 -0
- package/dist/chunk-yy8q0n8s.js +120 -0
- package/dist/chunk-yzb92zxv.js +8 -0
- package/dist/chunk-yzet6xyr.js +119 -0
- package/dist/chunk-yzm97qp1.js +226 -0
- package/dist/chunk-z0jgeax8.js +35 -0
- package/dist/chunk-z1r3z6w6.js +29 -0
- package/dist/chunk-z2dp53wn.js +17 -0
- package/dist/chunk-z79355gz.js +308 -0
- package/dist/chunk-z7e94hxz.js +251 -0
- package/dist/chunk-z8cqdcec.js +173 -0
- package/dist/chunk-z99tbg45.js +148 -0
- package/dist/chunk-z9nsjcht.js +37 -0
- package/dist/chunk-za3k6h2h.js +470 -0
- package/dist/chunk-zacynq5p.js +265 -0
- package/dist/chunk-zb0x40az.js +1785 -0
- package/dist/chunk-zbxtzycc.js +274 -0
- package/dist/chunk-zga50181.js +342 -0
- package/dist/chunk-zhb2pns1.js +44 -0
- package/dist/chunk-zkch6trx.js +231 -0
- package/dist/chunk-znf3z4qt.js +954 -0
- package/dist/chunk-zp8zwdgq.js +72 -0
- package/dist/chunk-ztjd8pyf.js +120 -0
- package/dist/chunk-ztmb7geg.js +173 -0
- package/dist/chunk-zvr4snzv.js +887 -0
- package/dist/chunk-zw62m6n3.js +34858 -0
- package/dist/chunk-zwwdebd0.js +65 -0
- package/dist/chunk-zxc6x9w8.js +340 -0
- package/dist/chunk-zy2e7sz0.js +8 -0
- package/dist/chunk-zzf074w3.js +196 -0
- package/dist/chunk-zzz0nwb5.js +310 -0
- package/dist/cli-bun.js +2 -0
- package/dist/cli-node.js +2 -0
- package/dist/cli.js +218 -0
- package/dist/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
- package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/package.json +243 -0
- package/scripts/chrome-mcp-bridge-resolver.mjs +43 -0
- package/scripts/chrome-mcp-env.mjs +19 -0
- package/scripts/postinstall.cjs +339 -0
- package/scripts/run-parallel.mjs +10 -0
- package/scripts/setup-chrome-mcp.mjs +69 -0
|
@@ -0,0 +1,3984 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
QueryEngine
|
|
4
|
+
} from "./chunk-rw0y2wdf.js";
|
|
5
|
+
import"./chunk-apg95qd7.js";
|
|
6
|
+
import"./chunk-qg4811f6.js";
|
|
7
|
+
import"./chunk-d2an0138.js";
|
|
8
|
+
import"./chunk-3abaq08g.js";
|
|
9
|
+
import {
|
|
10
|
+
applySafeConfigEnvironmentVariables,
|
|
11
|
+
deserializeMessages,
|
|
12
|
+
getCommands,
|
|
13
|
+
getDefaultAppState,
|
|
14
|
+
getEmptyToolPermissionContext,
|
|
15
|
+
getLastSessionLog,
|
|
16
|
+
getModelOptions,
|
|
17
|
+
getTools,
|
|
18
|
+
hasPermissionsToUseTool,
|
|
19
|
+
init_AppStateStore,
|
|
20
|
+
init_Tool,
|
|
21
|
+
init_commands1 as init_commands,
|
|
22
|
+
init_conversationRecovery,
|
|
23
|
+
init_listSessionsImpl,
|
|
24
|
+
init_managedEnv,
|
|
25
|
+
init_modelOptions,
|
|
26
|
+
init_permissions,
|
|
27
|
+
init_sessionStorage,
|
|
28
|
+
init_tools1 as init_tools,
|
|
29
|
+
listSessionsImpl,
|
|
30
|
+
sessionIdExists
|
|
31
|
+
} from "./chunk-gmdy2w3z.js";
|
|
32
|
+
import"./chunk-q0e485mg.js";
|
|
33
|
+
import"./chunk-2kcgxnvp.js";
|
|
34
|
+
import"./chunk-14p6wvsq.js";
|
|
35
|
+
import"./chunk-6s0q1s5r.js";
|
|
36
|
+
import"./chunk-3w9sye8h.js";
|
|
37
|
+
import"./chunk-nzxfj0gq.js";
|
|
38
|
+
import"./chunk-vr0n9pv9.js";
|
|
39
|
+
import"./chunk-9a9g5hbj.js";
|
|
40
|
+
import"./chunk-ptxteaeh.js";
|
|
41
|
+
import"./chunk-w4p5t920.js";
|
|
42
|
+
import"./chunk-rgyzsbs3.js";
|
|
43
|
+
import"./chunk-q3b4n194.js";
|
|
44
|
+
import"./chunk-kywtr3jg.js";
|
|
45
|
+
import"./chunk-eewg66y1.js";
|
|
46
|
+
import"./chunk-71sdcaq6.js";
|
|
47
|
+
import"./chunk-9hn8e6h1.js";
|
|
48
|
+
import"./chunk-7qey87th.js";
|
|
49
|
+
import"./chunk-zw62m6n3.js";
|
|
50
|
+
import"./chunk-1w20m7gw.js";
|
|
51
|
+
import"./chunk-zzf074w3.js";
|
|
52
|
+
import"./chunk-rpmntgyh.js";
|
|
53
|
+
import {
|
|
54
|
+
FileStateCache,
|
|
55
|
+
init_fileStateCache
|
|
56
|
+
} from "./chunk-24kv69g3.js";
|
|
57
|
+
import"./chunk-hzxzvzw8.js";
|
|
58
|
+
import"./chunk-30wnahyg.js";
|
|
59
|
+
import"./chunk-ztmb7geg.js";
|
|
60
|
+
import"./chunk-tbdkekz3.js";
|
|
61
|
+
import"./chunk-65zbgg1n.js";
|
|
62
|
+
import"./chunk-4spgkgr3.js";
|
|
63
|
+
import"./chunk-60fkafk2.js";
|
|
64
|
+
import"./chunk-50m3a23z.js";
|
|
65
|
+
import"./chunk-6hygvrhn.js";
|
|
66
|
+
import"./chunk-7tfdhkpy.js";
|
|
67
|
+
import"./chunk-8gv2pjby.js";
|
|
68
|
+
import"./chunk-g06pm4n9.js";
|
|
69
|
+
import"./chunk-2p369q9z.js";
|
|
70
|
+
import"./chunk-z0jgeax8.js";
|
|
71
|
+
import"./chunk-w68wc625.js";
|
|
72
|
+
import"./chunk-6hr7742d.js";
|
|
73
|
+
import"./chunk-xyg1sk2w.js";
|
|
74
|
+
import"./chunk-935nrvdb.js";
|
|
75
|
+
import"./chunk-8zz4z1q3.js";
|
|
76
|
+
import"./chunk-fncpkzs5.js";
|
|
77
|
+
import"./chunk-hqxp6b72.js";
|
|
78
|
+
import"./chunk-m2c3bjv1.js";
|
|
79
|
+
import"./chunk-jhtccjc9.js";
|
|
80
|
+
import"./chunk-7nvday0n.js";
|
|
81
|
+
import"./chunk-vxbjzggp.js";
|
|
82
|
+
import"./chunk-yc1stfve.js";
|
|
83
|
+
import"./chunk-8yvsnrkr.js";
|
|
84
|
+
import"./chunk-5mmhfbxb.js";
|
|
85
|
+
import {
|
|
86
|
+
enableConfigs,
|
|
87
|
+
getMainLoopModel,
|
|
88
|
+
getSettings_DEPRECATED,
|
|
89
|
+
init_config1 as init_config,
|
|
90
|
+
init_model,
|
|
91
|
+
init_settings1 as init_settings
|
|
92
|
+
} from "./chunk-eemjb825.js";
|
|
93
|
+
import"./chunk-ga1jkyqy.js";
|
|
94
|
+
import"./chunk-y1q7rt9n.js";
|
|
95
|
+
import"./chunk-8kct9arg.js";
|
|
96
|
+
import"./chunk-k7hexw3v.js";
|
|
97
|
+
import"./chunk-trqrj23e.js";
|
|
98
|
+
import"./chunk-za3k6h2h.js";
|
|
99
|
+
import"./chunk-8kf8h7xf.js";
|
|
100
|
+
import"./chunk-bgan4cpf.js";
|
|
101
|
+
import"./chunk-jmv7k0jn.js";
|
|
102
|
+
import"./chunk-hjxqmtg5.js";
|
|
103
|
+
import"./chunk-bzyzrq0k.js";
|
|
104
|
+
import"./chunk-vwenx8ke.js";
|
|
105
|
+
import"./chunk-q2h79ncs.js";
|
|
106
|
+
import"./chunk-v4ypszbb.js";
|
|
107
|
+
import"./chunk-qfsn720k.js";
|
|
108
|
+
import"./chunk-7qx3xhv3.js";
|
|
109
|
+
import {
|
|
110
|
+
init_v4
|
|
111
|
+
} from "./chunk-j9475b46.js";
|
|
112
|
+
import {
|
|
113
|
+
exports_external
|
|
114
|
+
} from "./chunk-fdwabr8p.js";
|
|
115
|
+
import"./chunk-e4dsy4g1.js";
|
|
116
|
+
import"./chunk-326zehp8.js";
|
|
117
|
+
import"./chunk-kc67kt75.js";
|
|
118
|
+
import"./chunk-40t1d75v.js";
|
|
119
|
+
import"./chunk-dbts5q5p.js";
|
|
120
|
+
import"./chunk-e3abfxpy.js";
|
|
121
|
+
import"./chunk-q44zc68f.js";
|
|
122
|
+
import"./chunk-fejeqe61.js";
|
|
123
|
+
import"./chunk-q1vrhh0q.js";
|
|
124
|
+
import"./chunk-hn4w9pkj.js";
|
|
125
|
+
import"./chunk-2g0ytd9d.js";
|
|
126
|
+
import"./chunk-de0qnnf7.js";
|
|
127
|
+
import"./chunk-j1mep9ck.js";
|
|
128
|
+
import"./chunk-6x35ffpx.js";
|
|
129
|
+
import"./chunk-1zbwhcbt.js";
|
|
130
|
+
import"./chunk-92bjkrf2.js";
|
|
131
|
+
import"./chunk-10k5jfc5.js";
|
|
132
|
+
import"./chunk-n9g24mwe.js";
|
|
133
|
+
import"./chunk-e3j7m7k2.js";
|
|
134
|
+
import"./chunk-hzmzwte2.js";
|
|
135
|
+
import"./chunk-pdvg91cg.js";
|
|
136
|
+
import"./chunk-c696122m.js";
|
|
137
|
+
import"./chunk-xbj5keyy.js";
|
|
138
|
+
import"./chunk-c1yc761e.js";
|
|
139
|
+
import"./chunk-c5g9shkw.js";
|
|
140
|
+
import"./chunk-aeysytks.js";
|
|
141
|
+
import"./chunk-s3hafnk3.js";
|
|
142
|
+
import"./chunk-kb3758f7.js";
|
|
143
|
+
import {
|
|
144
|
+
init_state,
|
|
145
|
+
setOriginalCwd
|
|
146
|
+
} from "./chunk-9h9k5vz3.js";
|
|
147
|
+
import"./chunk-xmpgmeb8.js";
|
|
148
|
+
import"./chunk-2kz09j2s.js";
|
|
149
|
+
import"./chunk-c0k7b0jw.js";
|
|
150
|
+
import"./chunk-pecy49yr.js";
|
|
151
|
+
import"./chunk-azbab59e.js";
|
|
152
|
+
import"./chunk-3nk9q8dr.js";
|
|
153
|
+
import"./chunk-hhsxm2yr.js";
|
|
154
|
+
|
|
155
|
+
// node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/acp.js
|
|
156
|
+
init_v4();
|
|
157
|
+
|
|
158
|
+
// node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
159
|
+
var AGENT_METHODS = {
|
|
160
|
+
authenticate: "authenticate",
|
|
161
|
+
document_did_change: "document/didChange",
|
|
162
|
+
document_did_close: "document/didClose",
|
|
163
|
+
document_did_focus: "document/didFocus",
|
|
164
|
+
document_did_open: "document/didOpen",
|
|
165
|
+
document_did_save: "document/didSave",
|
|
166
|
+
initialize: "initialize",
|
|
167
|
+
logout: "logout",
|
|
168
|
+
nes_accept: "nes/accept",
|
|
169
|
+
nes_close: "nes/close",
|
|
170
|
+
nes_reject: "nes/reject",
|
|
171
|
+
nes_start: "nes/start",
|
|
172
|
+
nes_suggest: "nes/suggest",
|
|
173
|
+
session_cancel: "session/cancel",
|
|
174
|
+
session_close: "session/close",
|
|
175
|
+
session_fork: "session/fork",
|
|
176
|
+
session_list: "session/list",
|
|
177
|
+
session_load: "session/load",
|
|
178
|
+
session_new: "session/new",
|
|
179
|
+
session_prompt: "session/prompt",
|
|
180
|
+
session_resume: "session/resume",
|
|
181
|
+
session_set_config_option: "session/set_config_option",
|
|
182
|
+
session_set_mode: "session/set_mode",
|
|
183
|
+
session_set_model: "session/set_model"
|
|
184
|
+
};
|
|
185
|
+
var CLIENT_METHODS = {
|
|
186
|
+
elicitation_complete: "elicitation/complete",
|
|
187
|
+
elicitation_create: "elicitation/create",
|
|
188
|
+
fs_read_text_file: "fs/read_text_file",
|
|
189
|
+
fs_write_text_file: "fs/write_text_file",
|
|
190
|
+
session_request_permission: "session/request_permission",
|
|
191
|
+
session_update: "session/update",
|
|
192
|
+
terminal_create: "terminal/create",
|
|
193
|
+
terminal_kill: "terminal/kill",
|
|
194
|
+
terminal_output: "terminal/output",
|
|
195
|
+
terminal_release: "terminal/release",
|
|
196
|
+
terminal_wait_for_exit: "terminal/wait_for_exit"
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js
|
|
200
|
+
init_v4();
|
|
201
|
+
var zAuthCapabilities = exports_external.object({
|
|
202
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
203
|
+
terminal: exports_external.boolean().optional().default(false)
|
|
204
|
+
});
|
|
205
|
+
var zAuthEnvVar = exports_external.object({
|
|
206
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
207
|
+
label: exports_external.string().nullish(),
|
|
208
|
+
name: exports_external.string(),
|
|
209
|
+
optional: exports_external.boolean().optional().default(false),
|
|
210
|
+
secret: exports_external.boolean().optional().default(true)
|
|
211
|
+
});
|
|
212
|
+
var zAuthMethodAgent = exports_external.object({
|
|
213
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
214
|
+
description: exports_external.string().nullish(),
|
|
215
|
+
id: exports_external.string(),
|
|
216
|
+
name: exports_external.string()
|
|
217
|
+
});
|
|
218
|
+
var zAuthMethodEnvVar = exports_external.object({
|
|
219
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
220
|
+
description: exports_external.string().nullish(),
|
|
221
|
+
id: exports_external.string(),
|
|
222
|
+
link: exports_external.string().nullish(),
|
|
223
|
+
name: exports_external.string(),
|
|
224
|
+
vars: exports_external.array(zAuthEnvVar)
|
|
225
|
+
});
|
|
226
|
+
var zAuthMethodTerminal = exports_external.object({
|
|
227
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
228
|
+
args: exports_external.array(exports_external.string()).optional(),
|
|
229
|
+
description: exports_external.string().nullish(),
|
|
230
|
+
env: exports_external.record(exports_external.string(), exports_external.string()).optional(),
|
|
231
|
+
id: exports_external.string(),
|
|
232
|
+
name: exports_external.string()
|
|
233
|
+
});
|
|
234
|
+
var zAuthMethod = exports_external.union([
|
|
235
|
+
zAuthMethodEnvVar.and(exports_external.object({
|
|
236
|
+
type: exports_external.literal("env_var")
|
|
237
|
+
})),
|
|
238
|
+
zAuthMethodTerminal.and(exports_external.object({
|
|
239
|
+
type: exports_external.literal("terminal")
|
|
240
|
+
})),
|
|
241
|
+
zAuthMethodAgent
|
|
242
|
+
]);
|
|
243
|
+
var zAuthenticateRequest = exports_external.object({
|
|
244
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
245
|
+
methodId: exports_external.string()
|
|
246
|
+
});
|
|
247
|
+
var zAuthenticateResponse = exports_external.object({
|
|
248
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
249
|
+
});
|
|
250
|
+
var zBlobResourceContents = exports_external.object({
|
|
251
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
252
|
+
blob: exports_external.string(),
|
|
253
|
+
mimeType: exports_external.string().nullish(),
|
|
254
|
+
uri: exports_external.string()
|
|
255
|
+
});
|
|
256
|
+
var zBooleanPropertySchema = exports_external.object({
|
|
257
|
+
default: exports_external.boolean().nullish(),
|
|
258
|
+
description: exports_external.string().nullish(),
|
|
259
|
+
title: exports_external.string().nullish()
|
|
260
|
+
});
|
|
261
|
+
var zCloseNesResponse = exports_external.object({
|
|
262
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
263
|
+
});
|
|
264
|
+
var zCloseSessionResponse = exports_external.object({
|
|
265
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
266
|
+
});
|
|
267
|
+
var zCost = exports_external.object({
|
|
268
|
+
amount: exports_external.number(),
|
|
269
|
+
currency: exports_external.string()
|
|
270
|
+
});
|
|
271
|
+
var zCreateTerminalResponse = exports_external.object({
|
|
272
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
273
|
+
terminalId: exports_external.string()
|
|
274
|
+
});
|
|
275
|
+
var zDiff = exports_external.object({
|
|
276
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
277
|
+
newText: exports_external.string(),
|
|
278
|
+
oldText: exports_external.string().nullish(),
|
|
279
|
+
path: exports_external.string()
|
|
280
|
+
});
|
|
281
|
+
var zElicitationContentValue = exports_external.union([
|
|
282
|
+
exports_external.string(),
|
|
283
|
+
exports_external.number(),
|
|
284
|
+
exports_external.number(),
|
|
285
|
+
exports_external.boolean(),
|
|
286
|
+
exports_external.array(exports_external.string())
|
|
287
|
+
]);
|
|
288
|
+
var zElicitationAcceptAction = exports_external.object({
|
|
289
|
+
content: exports_external.record(exports_external.string(), zElicitationContentValue).nullish()
|
|
290
|
+
});
|
|
291
|
+
var zCreateElicitationResponse = exports_external.intersection(exports_external.union([
|
|
292
|
+
zElicitationAcceptAction.and(exports_external.object({
|
|
293
|
+
action: exports_external.literal("accept")
|
|
294
|
+
})),
|
|
295
|
+
exports_external.object({
|
|
296
|
+
action: exports_external.literal("decline")
|
|
297
|
+
}),
|
|
298
|
+
exports_external.object({
|
|
299
|
+
action: exports_external.literal("cancel")
|
|
300
|
+
})
|
|
301
|
+
]), exports_external.object({
|
|
302
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
303
|
+
}));
|
|
304
|
+
var zElicitationFormCapabilities = exports_external.object({
|
|
305
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
306
|
+
});
|
|
307
|
+
var zElicitationId = exports_external.string();
|
|
308
|
+
var zCompleteElicitationNotification = exports_external.object({
|
|
309
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
310
|
+
elicitationId: zElicitationId
|
|
311
|
+
});
|
|
312
|
+
var zElicitationSchemaType = exports_external.literal("object");
|
|
313
|
+
var zElicitationStringType = exports_external.literal("string");
|
|
314
|
+
var zElicitationUrlCapabilities = exports_external.object({
|
|
315
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
316
|
+
});
|
|
317
|
+
var zElicitationCapabilities = exports_external.object({
|
|
318
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
319
|
+
form: zElicitationFormCapabilities.nullish(),
|
|
320
|
+
url: zElicitationUrlCapabilities.nullish()
|
|
321
|
+
});
|
|
322
|
+
var zEnumOption = exports_external.object({
|
|
323
|
+
const: exports_external.string(),
|
|
324
|
+
title: exports_external.string()
|
|
325
|
+
});
|
|
326
|
+
var zEnvVariable = exports_external.object({
|
|
327
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
328
|
+
name: exports_external.string(),
|
|
329
|
+
value: exports_external.string()
|
|
330
|
+
});
|
|
331
|
+
var zErrorCode = exports_external.union([
|
|
332
|
+
exports_external.literal(-32700),
|
|
333
|
+
exports_external.literal(-32600),
|
|
334
|
+
exports_external.literal(-32601),
|
|
335
|
+
exports_external.literal(-32602),
|
|
336
|
+
exports_external.literal(-32603),
|
|
337
|
+
exports_external.literal(-32800),
|
|
338
|
+
exports_external.literal(-32000),
|
|
339
|
+
exports_external.literal(-32002),
|
|
340
|
+
exports_external.literal(-32042),
|
|
341
|
+
exports_external.number().int().min(-2147483648, {
|
|
342
|
+
message: "Invalid value: Expected int32 to be >= -2147483648"
|
|
343
|
+
}).max(2147483647, {
|
|
344
|
+
message: "Invalid value: Expected int32 to be <= 2147483647"
|
|
345
|
+
})
|
|
346
|
+
]);
|
|
347
|
+
var zError = exports_external.object({
|
|
348
|
+
code: zErrorCode,
|
|
349
|
+
data: exports_external.unknown().optional(),
|
|
350
|
+
message: exports_external.string()
|
|
351
|
+
});
|
|
352
|
+
var zExtNotification = exports_external.unknown();
|
|
353
|
+
var zExtRequest = exports_external.unknown();
|
|
354
|
+
var zExtResponse = exports_external.unknown();
|
|
355
|
+
var zFileSystemCapabilities = exports_external.object({
|
|
356
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
357
|
+
readTextFile: exports_external.boolean().optional().default(false),
|
|
358
|
+
writeTextFile: exports_external.boolean().optional().default(false)
|
|
359
|
+
});
|
|
360
|
+
var zHttpHeader = exports_external.object({
|
|
361
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
362
|
+
name: exports_external.string(),
|
|
363
|
+
value: exports_external.string()
|
|
364
|
+
});
|
|
365
|
+
var zImplementation = exports_external.object({
|
|
366
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
367
|
+
name: exports_external.string(),
|
|
368
|
+
title: exports_external.string().nullish(),
|
|
369
|
+
version: exports_external.string()
|
|
370
|
+
});
|
|
371
|
+
var zIntegerPropertySchema = exports_external.object({
|
|
372
|
+
default: exports_external.number().nullish(),
|
|
373
|
+
description: exports_external.string().nullish(),
|
|
374
|
+
maximum: exports_external.number().nullish(),
|
|
375
|
+
minimum: exports_external.number().nullish(),
|
|
376
|
+
title: exports_external.string().nullish()
|
|
377
|
+
});
|
|
378
|
+
var zKillTerminalResponse = exports_external.object({
|
|
379
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
380
|
+
});
|
|
381
|
+
var zListSessionsRequest = exports_external.object({
|
|
382
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
383
|
+
additionalDirectories: exports_external.array(exports_external.string()).optional(),
|
|
384
|
+
cursor: exports_external.string().nullish(),
|
|
385
|
+
cwd: exports_external.string().nullish()
|
|
386
|
+
});
|
|
387
|
+
var zLogoutCapabilities = exports_external.object({
|
|
388
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
389
|
+
});
|
|
390
|
+
var zAgentAuthCapabilities = exports_external.object({
|
|
391
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
392
|
+
logout: zLogoutCapabilities.nullish()
|
|
393
|
+
});
|
|
394
|
+
var zLogoutRequest = exports_external.object({
|
|
395
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
396
|
+
});
|
|
397
|
+
var zLogoutResponse = exports_external.object({
|
|
398
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
399
|
+
});
|
|
400
|
+
var zMcpCapabilities = exports_external.object({
|
|
401
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
402
|
+
http: exports_external.boolean().optional().default(false),
|
|
403
|
+
sse: exports_external.boolean().optional().default(false)
|
|
404
|
+
});
|
|
405
|
+
var zMcpServerHttp = exports_external.object({
|
|
406
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
407
|
+
headers: exports_external.array(zHttpHeader),
|
|
408
|
+
name: exports_external.string(),
|
|
409
|
+
url: exports_external.string()
|
|
410
|
+
});
|
|
411
|
+
var zMcpServerSse = exports_external.object({
|
|
412
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
413
|
+
headers: exports_external.array(zHttpHeader),
|
|
414
|
+
name: exports_external.string(),
|
|
415
|
+
url: exports_external.string()
|
|
416
|
+
});
|
|
417
|
+
var zMcpServerStdio = exports_external.object({
|
|
418
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
419
|
+
args: exports_external.array(exports_external.string()),
|
|
420
|
+
command: exports_external.string(),
|
|
421
|
+
env: exports_external.array(zEnvVariable),
|
|
422
|
+
name: exports_external.string()
|
|
423
|
+
});
|
|
424
|
+
var zMcpServer = exports_external.union([
|
|
425
|
+
zMcpServerHttp.and(exports_external.object({
|
|
426
|
+
type: exports_external.literal("http")
|
|
427
|
+
})),
|
|
428
|
+
zMcpServerSse.and(exports_external.object({
|
|
429
|
+
type: exports_external.literal("sse")
|
|
430
|
+
})),
|
|
431
|
+
zMcpServerStdio
|
|
432
|
+
]);
|
|
433
|
+
var zModelId = exports_external.string();
|
|
434
|
+
var zModelInfo = exports_external.object({
|
|
435
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
436
|
+
description: exports_external.string().nullish(),
|
|
437
|
+
modelId: zModelId,
|
|
438
|
+
name: exports_external.string()
|
|
439
|
+
});
|
|
440
|
+
var zNesDiagnosticSeverity = exports_external.union([
|
|
441
|
+
exports_external.literal("error"),
|
|
442
|
+
exports_external.literal("warning"),
|
|
443
|
+
exports_external.literal("information"),
|
|
444
|
+
exports_external.literal("hint")
|
|
445
|
+
]);
|
|
446
|
+
var zNesDiagnosticsCapabilities = exports_external.object({
|
|
447
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
448
|
+
});
|
|
449
|
+
var zNesDocumentDidCloseCapabilities = exports_external.object({
|
|
450
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
451
|
+
});
|
|
452
|
+
var zNesDocumentDidFocusCapabilities = exports_external.object({
|
|
453
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
454
|
+
});
|
|
455
|
+
var zNesDocumentDidOpenCapabilities = exports_external.object({
|
|
456
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
457
|
+
});
|
|
458
|
+
var zNesDocumentDidSaveCapabilities = exports_external.object({
|
|
459
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
460
|
+
});
|
|
461
|
+
var zNesEditHistoryCapabilities = exports_external.object({
|
|
462
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
463
|
+
maxCount: exports_external.number().int().gte(0).max(4294967295, {
|
|
464
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
465
|
+
}).nullish()
|
|
466
|
+
});
|
|
467
|
+
var zNesEditHistoryEntry = exports_external.object({
|
|
468
|
+
diff: exports_external.string(),
|
|
469
|
+
uri: exports_external.string()
|
|
470
|
+
});
|
|
471
|
+
var zNesExcerpt = exports_external.object({
|
|
472
|
+
endLine: exports_external.number().int().gte(0).max(4294967295, {
|
|
473
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
474
|
+
}),
|
|
475
|
+
startLine: exports_external.number().int().gte(0).max(4294967295, {
|
|
476
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
477
|
+
}),
|
|
478
|
+
text: exports_external.string()
|
|
479
|
+
});
|
|
480
|
+
var zNesJumpCapabilities = exports_external.object({
|
|
481
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
482
|
+
});
|
|
483
|
+
var zNesOpenFilesCapabilities = exports_external.object({
|
|
484
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
485
|
+
});
|
|
486
|
+
var zNesRecentFile = exports_external.object({
|
|
487
|
+
languageId: exports_external.string(),
|
|
488
|
+
text: exports_external.string(),
|
|
489
|
+
uri: exports_external.string()
|
|
490
|
+
});
|
|
491
|
+
var zNesRecentFilesCapabilities = exports_external.object({
|
|
492
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
493
|
+
maxCount: exports_external.number().int().gte(0).max(4294967295, {
|
|
494
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
495
|
+
}).nullish()
|
|
496
|
+
});
|
|
497
|
+
var zNesRejectReason = exports_external.union([
|
|
498
|
+
exports_external.literal("rejected"),
|
|
499
|
+
exports_external.literal("ignored"),
|
|
500
|
+
exports_external.literal("replaced"),
|
|
501
|
+
exports_external.literal("cancelled")
|
|
502
|
+
]);
|
|
503
|
+
var zNesRelatedSnippet = exports_external.object({
|
|
504
|
+
excerpts: exports_external.array(zNesExcerpt),
|
|
505
|
+
uri: exports_external.string()
|
|
506
|
+
});
|
|
507
|
+
var zNesRelatedSnippetsCapabilities = exports_external.object({
|
|
508
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
509
|
+
});
|
|
510
|
+
var zNesRenameCapabilities = exports_external.object({
|
|
511
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
512
|
+
});
|
|
513
|
+
var zNesRepository = exports_external.object({
|
|
514
|
+
name: exports_external.string(),
|
|
515
|
+
owner: exports_external.string(),
|
|
516
|
+
remoteUrl: exports_external.string()
|
|
517
|
+
});
|
|
518
|
+
var zNesSearchAndReplaceCapabilities = exports_external.object({
|
|
519
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
520
|
+
});
|
|
521
|
+
var zClientNesCapabilities = exports_external.object({
|
|
522
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
523
|
+
jump: zNesJumpCapabilities.nullish(),
|
|
524
|
+
rename: zNesRenameCapabilities.nullish(),
|
|
525
|
+
searchAndReplace: zNesSearchAndReplaceCapabilities.nullish()
|
|
526
|
+
});
|
|
527
|
+
var zNesSearchAndReplaceSuggestion = exports_external.object({
|
|
528
|
+
id: exports_external.string(),
|
|
529
|
+
isRegex: exports_external.boolean().nullish(),
|
|
530
|
+
replace: exports_external.string(),
|
|
531
|
+
search: exports_external.string(),
|
|
532
|
+
uri: exports_external.string()
|
|
533
|
+
});
|
|
534
|
+
var zNesTriggerKind = exports_external.union([
|
|
535
|
+
exports_external.literal("automatic"),
|
|
536
|
+
exports_external.literal("diagnostic"),
|
|
537
|
+
exports_external.literal("manual")
|
|
538
|
+
]);
|
|
539
|
+
var zNesUserActionsCapabilities = exports_external.object({
|
|
540
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
541
|
+
maxCount: exports_external.number().int().gte(0).max(4294967295, {
|
|
542
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
543
|
+
}).nullish()
|
|
544
|
+
});
|
|
545
|
+
var zNesContextCapabilities = exports_external.object({
|
|
546
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
547
|
+
diagnostics: zNesDiagnosticsCapabilities.nullish(),
|
|
548
|
+
editHistory: zNesEditHistoryCapabilities.nullish(),
|
|
549
|
+
openFiles: zNesOpenFilesCapabilities.nullish(),
|
|
550
|
+
recentFiles: zNesRecentFilesCapabilities.nullish(),
|
|
551
|
+
relatedSnippets: zNesRelatedSnippetsCapabilities.nullish(),
|
|
552
|
+
userActions: zNesUserActionsCapabilities.nullish()
|
|
553
|
+
});
|
|
554
|
+
var zNewSessionRequest = exports_external.object({
|
|
555
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
556
|
+
additionalDirectories: exports_external.array(exports_external.string()).optional(),
|
|
557
|
+
cwd: exports_external.string(),
|
|
558
|
+
mcpServers: exports_external.array(zMcpServer)
|
|
559
|
+
});
|
|
560
|
+
var zNumberPropertySchema = exports_external.object({
|
|
561
|
+
default: exports_external.number().nullish(),
|
|
562
|
+
description: exports_external.string().nullish(),
|
|
563
|
+
maximum: exports_external.number().nullish(),
|
|
564
|
+
minimum: exports_external.number().nullish(),
|
|
565
|
+
title: exports_external.string().nullish()
|
|
566
|
+
});
|
|
567
|
+
var zPermissionOptionId = exports_external.string();
|
|
568
|
+
var zPermissionOptionKind = exports_external.union([
|
|
569
|
+
exports_external.literal("allow_once"),
|
|
570
|
+
exports_external.literal("allow_always"),
|
|
571
|
+
exports_external.literal("reject_once"),
|
|
572
|
+
exports_external.literal("reject_always")
|
|
573
|
+
]);
|
|
574
|
+
var zPermissionOption = exports_external.object({
|
|
575
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
576
|
+
kind: zPermissionOptionKind,
|
|
577
|
+
name: exports_external.string(),
|
|
578
|
+
optionId: zPermissionOptionId
|
|
579
|
+
});
|
|
580
|
+
var zPlanEntryPriority = exports_external.union([
|
|
581
|
+
exports_external.literal("high"),
|
|
582
|
+
exports_external.literal("medium"),
|
|
583
|
+
exports_external.literal("low")
|
|
584
|
+
]);
|
|
585
|
+
var zPlanEntryStatus = exports_external.union([
|
|
586
|
+
exports_external.literal("pending"),
|
|
587
|
+
exports_external.literal("in_progress"),
|
|
588
|
+
exports_external.literal("completed")
|
|
589
|
+
]);
|
|
590
|
+
var zPlanEntry = exports_external.object({
|
|
591
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
592
|
+
content: exports_external.string(),
|
|
593
|
+
priority: zPlanEntryPriority,
|
|
594
|
+
status: zPlanEntryStatus
|
|
595
|
+
});
|
|
596
|
+
var zPlan = exports_external.object({
|
|
597
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
598
|
+
entries: exports_external.array(zPlanEntry)
|
|
599
|
+
});
|
|
600
|
+
var zPosition = exports_external.object({
|
|
601
|
+
character: exports_external.number().int().gte(0).max(4294967295, {
|
|
602
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
603
|
+
}),
|
|
604
|
+
line: exports_external.number().int().gte(0).max(4294967295, {
|
|
605
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
606
|
+
})
|
|
607
|
+
});
|
|
608
|
+
var zNesJumpSuggestion = exports_external.object({
|
|
609
|
+
id: exports_external.string(),
|
|
610
|
+
position: zPosition,
|
|
611
|
+
uri: exports_external.string()
|
|
612
|
+
});
|
|
613
|
+
var zNesRenameSuggestion = exports_external.object({
|
|
614
|
+
id: exports_external.string(),
|
|
615
|
+
newName: exports_external.string(),
|
|
616
|
+
position: zPosition,
|
|
617
|
+
uri: exports_external.string()
|
|
618
|
+
});
|
|
619
|
+
var zNesUserAction = exports_external.object({
|
|
620
|
+
action: exports_external.string(),
|
|
621
|
+
position: zPosition,
|
|
622
|
+
timestampMs: exports_external.number(),
|
|
623
|
+
uri: exports_external.string()
|
|
624
|
+
});
|
|
625
|
+
var zPositionEncodingKind = exports_external.union([
|
|
626
|
+
exports_external.literal("utf-16"),
|
|
627
|
+
exports_external.literal("utf-32"),
|
|
628
|
+
exports_external.literal("utf-8")
|
|
629
|
+
]);
|
|
630
|
+
var zClientCapabilities = exports_external.object({
|
|
631
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
632
|
+
auth: zAuthCapabilities.optional().default({ terminal: false }),
|
|
633
|
+
elicitation: zElicitationCapabilities.nullish(),
|
|
634
|
+
fs: zFileSystemCapabilities.optional().default({ readTextFile: false, writeTextFile: false }),
|
|
635
|
+
nes: zClientNesCapabilities.nullish(),
|
|
636
|
+
positionEncodings: exports_external.array(zPositionEncodingKind).optional(),
|
|
637
|
+
terminal: exports_external.boolean().optional().default(false)
|
|
638
|
+
});
|
|
639
|
+
var zPromptCapabilities = exports_external.object({
|
|
640
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
641
|
+
audio: exports_external.boolean().optional().default(false),
|
|
642
|
+
embeddedContext: exports_external.boolean().optional().default(false),
|
|
643
|
+
image: exports_external.boolean().optional().default(false)
|
|
644
|
+
});
|
|
645
|
+
var zProtocolVersion = exports_external.number().int().gte(0).lte(65535);
|
|
646
|
+
var zInitializeRequest = exports_external.object({
|
|
647
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
648
|
+
clientCapabilities: zClientCapabilities.optional().default({
|
|
649
|
+
auth: { terminal: false },
|
|
650
|
+
fs: { readTextFile: false, writeTextFile: false },
|
|
651
|
+
terminal: false
|
|
652
|
+
}),
|
|
653
|
+
clientInfo: zImplementation.nullish(),
|
|
654
|
+
protocolVersion: zProtocolVersion
|
|
655
|
+
});
|
|
656
|
+
var zRange = exports_external.object({
|
|
657
|
+
end: zPosition,
|
|
658
|
+
start: zPosition
|
|
659
|
+
});
|
|
660
|
+
var zNesDiagnostic = exports_external.object({
|
|
661
|
+
message: exports_external.string(),
|
|
662
|
+
range: zRange,
|
|
663
|
+
severity: zNesDiagnosticSeverity,
|
|
664
|
+
uri: exports_external.string()
|
|
665
|
+
});
|
|
666
|
+
var zNesOpenFile = exports_external.object({
|
|
667
|
+
languageId: exports_external.string(),
|
|
668
|
+
lastFocusedMs: exports_external.number().nullish(),
|
|
669
|
+
uri: exports_external.string(),
|
|
670
|
+
visibleRange: zRange.nullish()
|
|
671
|
+
});
|
|
672
|
+
var zNesSuggestContext = exports_external.object({
|
|
673
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
674
|
+
diagnostics: exports_external.array(zNesDiagnostic).nullish(),
|
|
675
|
+
editHistory: exports_external.array(zNesEditHistoryEntry).nullish(),
|
|
676
|
+
openFiles: exports_external.array(zNesOpenFile).nullish(),
|
|
677
|
+
recentFiles: exports_external.array(zNesRecentFile).nullish(),
|
|
678
|
+
relatedSnippets: exports_external.array(zNesRelatedSnippet).nullish(),
|
|
679
|
+
userActions: exports_external.array(zNesUserAction).nullish()
|
|
680
|
+
});
|
|
681
|
+
var zNesTextEdit = exports_external.object({
|
|
682
|
+
newText: exports_external.string(),
|
|
683
|
+
range: zRange
|
|
684
|
+
});
|
|
685
|
+
var zNesEditSuggestion = exports_external.object({
|
|
686
|
+
cursorPosition: zPosition.nullish(),
|
|
687
|
+
edits: exports_external.array(zNesTextEdit),
|
|
688
|
+
id: exports_external.string(),
|
|
689
|
+
uri: exports_external.string()
|
|
690
|
+
});
|
|
691
|
+
var zNesSuggestion = exports_external.union([
|
|
692
|
+
zNesEditSuggestion.and(exports_external.object({
|
|
693
|
+
kind: exports_external.literal("edit")
|
|
694
|
+
})),
|
|
695
|
+
zNesJumpSuggestion.and(exports_external.object({
|
|
696
|
+
kind: exports_external.literal("jump")
|
|
697
|
+
})),
|
|
698
|
+
zNesRenameSuggestion.and(exports_external.object({
|
|
699
|
+
kind: exports_external.literal("rename")
|
|
700
|
+
})),
|
|
701
|
+
zNesSearchAndReplaceSuggestion.and(exports_external.object({
|
|
702
|
+
kind: exports_external.literal("searchAndReplace")
|
|
703
|
+
}))
|
|
704
|
+
]);
|
|
705
|
+
var zReadTextFileResponse = exports_external.object({
|
|
706
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
707
|
+
content: exports_external.string()
|
|
708
|
+
});
|
|
709
|
+
var zReleaseTerminalResponse = exports_external.object({
|
|
710
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
711
|
+
});
|
|
712
|
+
var zRequestId = exports_external.union([exports_external.number(), exports_external.string()]).nullable();
|
|
713
|
+
var zCancelRequestNotification = exports_external.object({
|
|
714
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
715
|
+
requestId: zRequestId
|
|
716
|
+
});
|
|
717
|
+
var zElicitationRequestScope = exports_external.object({
|
|
718
|
+
requestId: zRequestId
|
|
719
|
+
});
|
|
720
|
+
var zRole = exports_external.enum(["assistant", "user"]);
|
|
721
|
+
var zAnnotations = exports_external.object({
|
|
722
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
723
|
+
audience: exports_external.array(zRole).nullish(),
|
|
724
|
+
lastModified: exports_external.string().nullish(),
|
|
725
|
+
priority: exports_external.number().nullish()
|
|
726
|
+
});
|
|
727
|
+
var zAudioContent = exports_external.object({
|
|
728
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
729
|
+
annotations: zAnnotations.nullish(),
|
|
730
|
+
data: exports_external.string(),
|
|
731
|
+
mimeType: exports_external.string()
|
|
732
|
+
});
|
|
733
|
+
var zImageContent = exports_external.object({
|
|
734
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
735
|
+
annotations: zAnnotations.nullish(),
|
|
736
|
+
data: exports_external.string(),
|
|
737
|
+
mimeType: exports_external.string(),
|
|
738
|
+
uri: exports_external.string().nullish()
|
|
739
|
+
});
|
|
740
|
+
var zResourceLink = exports_external.object({
|
|
741
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
742
|
+
annotations: zAnnotations.nullish(),
|
|
743
|
+
description: exports_external.string().nullish(),
|
|
744
|
+
mimeType: exports_external.string().nullish(),
|
|
745
|
+
name: exports_external.string(),
|
|
746
|
+
size: exports_external.number().nullish(),
|
|
747
|
+
title: exports_external.string().nullish(),
|
|
748
|
+
uri: exports_external.string()
|
|
749
|
+
});
|
|
750
|
+
var zSelectedPermissionOutcome = exports_external.object({
|
|
751
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
752
|
+
optionId: zPermissionOptionId
|
|
753
|
+
});
|
|
754
|
+
var zRequestPermissionOutcome = exports_external.union([
|
|
755
|
+
exports_external.object({
|
|
756
|
+
outcome: exports_external.literal("cancelled")
|
|
757
|
+
}),
|
|
758
|
+
zSelectedPermissionOutcome.and(exports_external.object({
|
|
759
|
+
outcome: exports_external.literal("selected")
|
|
760
|
+
}))
|
|
761
|
+
]);
|
|
762
|
+
var zRequestPermissionResponse = exports_external.object({
|
|
763
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
764
|
+
outcome: zRequestPermissionOutcome
|
|
765
|
+
});
|
|
766
|
+
var zSessionAdditionalDirectoriesCapabilities = exports_external.object({
|
|
767
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
768
|
+
});
|
|
769
|
+
var zSessionCloseCapabilities = exports_external.object({
|
|
770
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
771
|
+
});
|
|
772
|
+
var zSessionConfigBoolean = exports_external.object({
|
|
773
|
+
currentValue: exports_external.boolean()
|
|
774
|
+
});
|
|
775
|
+
var zSessionConfigGroupId = exports_external.string();
|
|
776
|
+
var zSessionConfigId = exports_external.string();
|
|
777
|
+
var zSessionConfigOptionCategory = exports_external.union([
|
|
778
|
+
exports_external.literal("mode"),
|
|
779
|
+
exports_external.literal("model"),
|
|
780
|
+
exports_external.literal("thought_level"),
|
|
781
|
+
exports_external.string()
|
|
782
|
+
]);
|
|
783
|
+
var zSessionConfigValueId = exports_external.string();
|
|
784
|
+
var zSessionConfigSelectOption = exports_external.object({
|
|
785
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
786
|
+
description: exports_external.string().nullish(),
|
|
787
|
+
name: exports_external.string(),
|
|
788
|
+
value: zSessionConfigValueId
|
|
789
|
+
});
|
|
790
|
+
var zSessionConfigSelectGroup = exports_external.object({
|
|
791
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
792
|
+
group: zSessionConfigGroupId,
|
|
793
|
+
name: exports_external.string(),
|
|
794
|
+
options: exports_external.array(zSessionConfigSelectOption)
|
|
795
|
+
});
|
|
796
|
+
var zSessionConfigSelectOptions = exports_external.union([
|
|
797
|
+
exports_external.array(zSessionConfigSelectOption),
|
|
798
|
+
exports_external.array(zSessionConfigSelectGroup)
|
|
799
|
+
]);
|
|
800
|
+
var zSessionConfigSelect = exports_external.object({
|
|
801
|
+
currentValue: zSessionConfigValueId,
|
|
802
|
+
options: zSessionConfigSelectOptions
|
|
803
|
+
});
|
|
804
|
+
var zSessionConfigOption = exports_external.intersection(exports_external.union([
|
|
805
|
+
zSessionConfigSelect.and(exports_external.object({
|
|
806
|
+
type: exports_external.literal("select")
|
|
807
|
+
})),
|
|
808
|
+
zSessionConfigBoolean.and(exports_external.object({
|
|
809
|
+
type: exports_external.literal("boolean")
|
|
810
|
+
}))
|
|
811
|
+
]), exports_external.object({
|
|
812
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
813
|
+
category: zSessionConfigOptionCategory.nullish(),
|
|
814
|
+
description: exports_external.string().nullish(),
|
|
815
|
+
id: zSessionConfigId,
|
|
816
|
+
name: exports_external.string()
|
|
817
|
+
}));
|
|
818
|
+
var zConfigOptionUpdate = exports_external.object({
|
|
819
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
820
|
+
configOptions: exports_external.array(zSessionConfigOption)
|
|
821
|
+
});
|
|
822
|
+
var zSessionForkCapabilities = exports_external.object({
|
|
823
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
824
|
+
});
|
|
825
|
+
var zSessionId = exports_external.string();
|
|
826
|
+
var zAcceptNesNotification = exports_external.object({
|
|
827
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
828
|
+
id: exports_external.string(),
|
|
829
|
+
sessionId: zSessionId
|
|
830
|
+
});
|
|
831
|
+
var zCancelNotification = exports_external.object({
|
|
832
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
833
|
+
sessionId: zSessionId
|
|
834
|
+
});
|
|
835
|
+
var zCloseNesRequest = exports_external.object({
|
|
836
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
837
|
+
sessionId: zSessionId
|
|
838
|
+
});
|
|
839
|
+
var zCloseSessionRequest = exports_external.object({
|
|
840
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
841
|
+
sessionId: zSessionId
|
|
842
|
+
});
|
|
843
|
+
var zCreateTerminalRequest = exports_external.object({
|
|
844
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
845
|
+
args: exports_external.array(exports_external.string()).optional(),
|
|
846
|
+
command: exports_external.string(),
|
|
847
|
+
cwd: exports_external.string().nullish(),
|
|
848
|
+
env: exports_external.array(zEnvVariable).optional(),
|
|
849
|
+
outputByteLimit: exports_external.number().nullish(),
|
|
850
|
+
sessionId: zSessionId
|
|
851
|
+
});
|
|
852
|
+
var zDidCloseDocumentNotification = exports_external.object({
|
|
853
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
854
|
+
sessionId: zSessionId,
|
|
855
|
+
uri: exports_external.string()
|
|
856
|
+
});
|
|
857
|
+
var zDidFocusDocumentNotification = exports_external.object({
|
|
858
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
859
|
+
position: zPosition,
|
|
860
|
+
sessionId: zSessionId,
|
|
861
|
+
uri: exports_external.string(),
|
|
862
|
+
version: exports_external.number(),
|
|
863
|
+
visibleRange: zRange
|
|
864
|
+
});
|
|
865
|
+
var zDidOpenDocumentNotification = exports_external.object({
|
|
866
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
867
|
+
languageId: exports_external.string(),
|
|
868
|
+
sessionId: zSessionId,
|
|
869
|
+
text: exports_external.string(),
|
|
870
|
+
uri: exports_external.string(),
|
|
871
|
+
version: exports_external.number()
|
|
872
|
+
});
|
|
873
|
+
var zDidSaveDocumentNotification = exports_external.object({
|
|
874
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
875
|
+
sessionId: zSessionId,
|
|
876
|
+
uri: exports_external.string()
|
|
877
|
+
});
|
|
878
|
+
var zForkSessionRequest = exports_external.object({
|
|
879
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
880
|
+
additionalDirectories: exports_external.array(exports_external.string()).optional(),
|
|
881
|
+
cwd: exports_external.string(),
|
|
882
|
+
mcpServers: exports_external.array(zMcpServer).optional(),
|
|
883
|
+
sessionId: zSessionId
|
|
884
|
+
});
|
|
885
|
+
var zKillTerminalRequest = exports_external.object({
|
|
886
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
887
|
+
sessionId: zSessionId,
|
|
888
|
+
terminalId: exports_external.string()
|
|
889
|
+
});
|
|
890
|
+
var zLoadSessionRequest = exports_external.object({
|
|
891
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
892
|
+
additionalDirectories: exports_external.array(exports_external.string()).optional(),
|
|
893
|
+
cwd: exports_external.string(),
|
|
894
|
+
mcpServers: exports_external.array(zMcpServer),
|
|
895
|
+
sessionId: zSessionId
|
|
896
|
+
});
|
|
897
|
+
var zReadTextFileRequest = exports_external.object({
|
|
898
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
899
|
+
limit: exports_external.number().int().gte(0).max(4294967295, {
|
|
900
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
901
|
+
}).nullish(),
|
|
902
|
+
line: exports_external.number().int().gte(0).max(4294967295, {
|
|
903
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
904
|
+
}).nullish(),
|
|
905
|
+
path: exports_external.string(),
|
|
906
|
+
sessionId: zSessionId
|
|
907
|
+
});
|
|
908
|
+
var zRejectNesNotification = exports_external.object({
|
|
909
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
910
|
+
id: exports_external.string(),
|
|
911
|
+
reason: zNesRejectReason.nullish(),
|
|
912
|
+
sessionId: zSessionId
|
|
913
|
+
});
|
|
914
|
+
var zReleaseTerminalRequest = exports_external.object({
|
|
915
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
916
|
+
sessionId: zSessionId,
|
|
917
|
+
terminalId: exports_external.string()
|
|
918
|
+
});
|
|
919
|
+
var zResumeSessionRequest = 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
|
+
mcpServers: exports_external.array(zMcpServer).optional(),
|
|
924
|
+
sessionId: zSessionId
|
|
925
|
+
});
|
|
926
|
+
var zSessionInfo = exports_external.object({
|
|
927
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
928
|
+
additionalDirectories: exports_external.array(exports_external.string()).optional(),
|
|
929
|
+
cwd: exports_external.string(),
|
|
930
|
+
sessionId: zSessionId,
|
|
931
|
+
title: exports_external.string().nullish(),
|
|
932
|
+
updatedAt: exports_external.string().nullish()
|
|
933
|
+
});
|
|
934
|
+
var zListSessionsResponse = exports_external.object({
|
|
935
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
936
|
+
nextCursor: exports_external.string().nullish(),
|
|
937
|
+
sessions: exports_external.array(zSessionInfo)
|
|
938
|
+
});
|
|
939
|
+
var zSessionInfoUpdate = exports_external.object({
|
|
940
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
941
|
+
title: exports_external.string().nullish(),
|
|
942
|
+
updatedAt: exports_external.string().nullish()
|
|
943
|
+
});
|
|
944
|
+
var zSessionListCapabilities = exports_external.object({
|
|
945
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
946
|
+
});
|
|
947
|
+
var zSessionModeId = exports_external.string();
|
|
948
|
+
var zCurrentModeUpdate = exports_external.object({
|
|
949
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
950
|
+
currentModeId: zSessionModeId
|
|
951
|
+
});
|
|
952
|
+
var zSessionMode = exports_external.object({
|
|
953
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
954
|
+
description: exports_external.string().nullish(),
|
|
955
|
+
id: zSessionModeId,
|
|
956
|
+
name: exports_external.string()
|
|
957
|
+
});
|
|
958
|
+
var zSessionModeState = exports_external.object({
|
|
959
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
960
|
+
availableModes: exports_external.array(zSessionMode),
|
|
961
|
+
currentModeId: zSessionModeId
|
|
962
|
+
});
|
|
963
|
+
var zSessionModelState = exports_external.object({
|
|
964
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
965
|
+
availableModels: exports_external.array(zModelInfo),
|
|
966
|
+
currentModelId: zModelId
|
|
967
|
+
});
|
|
968
|
+
var zForkSessionResponse = 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
|
+
sessionId: zSessionId
|
|
974
|
+
});
|
|
975
|
+
var zLoadSessionResponse = exports_external.object({
|
|
976
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
977
|
+
configOptions: exports_external.array(zSessionConfigOption).nullish(),
|
|
978
|
+
models: zSessionModelState.nullish(),
|
|
979
|
+
modes: zSessionModeState.nullish()
|
|
980
|
+
});
|
|
981
|
+
var zNewSessionResponse = 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
|
+
sessionId: zSessionId
|
|
987
|
+
});
|
|
988
|
+
var zResumeSessionResponse = exports_external.object({
|
|
989
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
990
|
+
configOptions: exports_external.array(zSessionConfigOption).nullish(),
|
|
991
|
+
models: zSessionModelState.nullish(),
|
|
992
|
+
modes: zSessionModeState.nullish()
|
|
993
|
+
});
|
|
994
|
+
var zSessionResumeCapabilities = exports_external.object({
|
|
995
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
996
|
+
});
|
|
997
|
+
var zSessionCapabilities = exports_external.object({
|
|
998
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
999
|
+
additionalDirectories: zSessionAdditionalDirectoriesCapabilities.nullish(),
|
|
1000
|
+
close: zSessionCloseCapabilities.nullish(),
|
|
1001
|
+
fork: zSessionForkCapabilities.nullish(),
|
|
1002
|
+
list: zSessionListCapabilities.nullish(),
|
|
1003
|
+
resume: zSessionResumeCapabilities.nullish()
|
|
1004
|
+
});
|
|
1005
|
+
var zSetSessionConfigOptionRequest = exports_external.intersection(exports_external.union([
|
|
1006
|
+
exports_external.object({
|
|
1007
|
+
type: exports_external.literal("boolean"),
|
|
1008
|
+
value: exports_external.boolean()
|
|
1009
|
+
}),
|
|
1010
|
+
exports_external.object({
|
|
1011
|
+
value: zSessionConfigValueId
|
|
1012
|
+
})
|
|
1013
|
+
]), exports_external.object({
|
|
1014
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1015
|
+
configId: zSessionConfigId,
|
|
1016
|
+
sessionId: zSessionId
|
|
1017
|
+
}));
|
|
1018
|
+
var zSetSessionConfigOptionResponse = exports_external.object({
|
|
1019
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1020
|
+
configOptions: exports_external.array(zSessionConfigOption)
|
|
1021
|
+
});
|
|
1022
|
+
var zSetSessionModeRequest = exports_external.object({
|
|
1023
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1024
|
+
modeId: zSessionModeId,
|
|
1025
|
+
sessionId: zSessionId
|
|
1026
|
+
});
|
|
1027
|
+
var zSetSessionModeResponse = exports_external.object({
|
|
1028
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
1029
|
+
});
|
|
1030
|
+
var zSetSessionModelRequest = exports_external.object({
|
|
1031
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1032
|
+
modelId: zModelId,
|
|
1033
|
+
sessionId: zSessionId
|
|
1034
|
+
});
|
|
1035
|
+
var zSetSessionModelResponse = exports_external.object({
|
|
1036
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
1037
|
+
});
|
|
1038
|
+
var zStartNesResponse = exports_external.object({
|
|
1039
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1040
|
+
sessionId: zSessionId
|
|
1041
|
+
});
|
|
1042
|
+
var zStopReason = exports_external.union([
|
|
1043
|
+
exports_external.literal("end_turn"),
|
|
1044
|
+
exports_external.literal("max_tokens"),
|
|
1045
|
+
exports_external.literal("max_turn_requests"),
|
|
1046
|
+
exports_external.literal("refusal"),
|
|
1047
|
+
exports_external.literal("cancelled")
|
|
1048
|
+
]);
|
|
1049
|
+
var zStringFormat = exports_external.union([
|
|
1050
|
+
exports_external.literal("email"),
|
|
1051
|
+
exports_external.literal("uri"),
|
|
1052
|
+
exports_external.literal("date"),
|
|
1053
|
+
exports_external.literal("date-time")
|
|
1054
|
+
]);
|
|
1055
|
+
var zStringPropertySchema = exports_external.object({
|
|
1056
|
+
default: exports_external.string().nullish(),
|
|
1057
|
+
description: exports_external.string().nullish(),
|
|
1058
|
+
enum: exports_external.array(exports_external.string()).nullish(),
|
|
1059
|
+
format: zStringFormat.nullish(),
|
|
1060
|
+
maxLength: exports_external.number().int().gte(0).max(4294967295, {
|
|
1061
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
1062
|
+
}).nullish(),
|
|
1063
|
+
minLength: exports_external.number().int().gte(0).max(4294967295, {
|
|
1064
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
1065
|
+
}).nullish(),
|
|
1066
|
+
oneOf: exports_external.array(zEnumOption).nullish(),
|
|
1067
|
+
pattern: exports_external.string().nullish(),
|
|
1068
|
+
title: exports_external.string().nullish()
|
|
1069
|
+
});
|
|
1070
|
+
var zSuggestNesRequest = exports_external.object({
|
|
1071
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1072
|
+
context: zNesSuggestContext.nullish(),
|
|
1073
|
+
position: zPosition,
|
|
1074
|
+
selection: zRange.nullish(),
|
|
1075
|
+
sessionId: zSessionId,
|
|
1076
|
+
triggerKind: zNesTriggerKind,
|
|
1077
|
+
uri: exports_external.string(),
|
|
1078
|
+
version: exports_external.number()
|
|
1079
|
+
});
|
|
1080
|
+
var zSuggestNesResponse = exports_external.object({
|
|
1081
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1082
|
+
suggestions: exports_external.array(zNesSuggestion)
|
|
1083
|
+
});
|
|
1084
|
+
var zTerminal = exports_external.object({
|
|
1085
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1086
|
+
terminalId: exports_external.string()
|
|
1087
|
+
});
|
|
1088
|
+
var zTerminalExitStatus = exports_external.object({
|
|
1089
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1090
|
+
exitCode: exports_external.number().int().gte(0).max(4294967295, {
|
|
1091
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
1092
|
+
}).nullish(),
|
|
1093
|
+
signal: exports_external.string().nullish()
|
|
1094
|
+
});
|
|
1095
|
+
var zTerminalOutputRequest = exports_external.object({
|
|
1096
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1097
|
+
sessionId: zSessionId,
|
|
1098
|
+
terminalId: exports_external.string()
|
|
1099
|
+
});
|
|
1100
|
+
var zTerminalOutputResponse = exports_external.object({
|
|
1101
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1102
|
+
exitStatus: zTerminalExitStatus.nullish(),
|
|
1103
|
+
output: exports_external.string(),
|
|
1104
|
+
truncated: exports_external.boolean()
|
|
1105
|
+
});
|
|
1106
|
+
var zTextContent = exports_external.object({
|
|
1107
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1108
|
+
annotations: zAnnotations.nullish(),
|
|
1109
|
+
text: exports_external.string()
|
|
1110
|
+
});
|
|
1111
|
+
var zTextDocumentContentChangeEvent = exports_external.object({
|
|
1112
|
+
range: zRange.nullish(),
|
|
1113
|
+
text: exports_external.string()
|
|
1114
|
+
});
|
|
1115
|
+
var zDidChangeDocumentNotification = exports_external.object({
|
|
1116
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1117
|
+
contentChanges: exports_external.array(zTextDocumentContentChangeEvent),
|
|
1118
|
+
sessionId: zSessionId,
|
|
1119
|
+
uri: exports_external.string(),
|
|
1120
|
+
version: exports_external.number()
|
|
1121
|
+
});
|
|
1122
|
+
var zClientNotification = exports_external.object({
|
|
1123
|
+
method: exports_external.string(),
|
|
1124
|
+
params: exports_external.union([
|
|
1125
|
+
zCancelNotification,
|
|
1126
|
+
zDidOpenDocumentNotification,
|
|
1127
|
+
zDidChangeDocumentNotification,
|
|
1128
|
+
zDidCloseDocumentNotification,
|
|
1129
|
+
zDidSaveDocumentNotification,
|
|
1130
|
+
zDidFocusDocumentNotification,
|
|
1131
|
+
zAcceptNesNotification,
|
|
1132
|
+
zRejectNesNotification,
|
|
1133
|
+
zExtNotification
|
|
1134
|
+
]).nullish()
|
|
1135
|
+
});
|
|
1136
|
+
var zTextDocumentSyncKind = exports_external.union([
|
|
1137
|
+
exports_external.literal("full"),
|
|
1138
|
+
exports_external.literal("incremental")
|
|
1139
|
+
]);
|
|
1140
|
+
var zNesDocumentDidChangeCapabilities = exports_external.object({
|
|
1141
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1142
|
+
syncKind: zTextDocumentSyncKind
|
|
1143
|
+
});
|
|
1144
|
+
var zNesDocumentEventCapabilities = exports_external.object({
|
|
1145
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1146
|
+
didChange: zNesDocumentDidChangeCapabilities.nullish(),
|
|
1147
|
+
didClose: zNesDocumentDidCloseCapabilities.nullish(),
|
|
1148
|
+
didFocus: zNesDocumentDidFocusCapabilities.nullish(),
|
|
1149
|
+
didOpen: zNesDocumentDidOpenCapabilities.nullish(),
|
|
1150
|
+
didSave: zNesDocumentDidSaveCapabilities.nullish()
|
|
1151
|
+
});
|
|
1152
|
+
var zNesEventCapabilities = exports_external.object({
|
|
1153
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1154
|
+
document: zNesDocumentEventCapabilities.nullish()
|
|
1155
|
+
});
|
|
1156
|
+
var zNesCapabilities = exports_external.object({
|
|
1157
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1158
|
+
context: zNesContextCapabilities.nullish(),
|
|
1159
|
+
events: zNesEventCapabilities.nullish()
|
|
1160
|
+
});
|
|
1161
|
+
var zAgentCapabilities = exports_external.object({
|
|
1162
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1163
|
+
auth: zAgentAuthCapabilities.optional().default({}),
|
|
1164
|
+
loadSession: exports_external.boolean().optional().default(false),
|
|
1165
|
+
mcpCapabilities: zMcpCapabilities.optional().default({ http: false, sse: false }),
|
|
1166
|
+
nes: zNesCapabilities.nullish(),
|
|
1167
|
+
positionEncoding: zPositionEncodingKind.nullish(),
|
|
1168
|
+
promptCapabilities: zPromptCapabilities.optional().default({
|
|
1169
|
+
audio: false,
|
|
1170
|
+
embeddedContext: false,
|
|
1171
|
+
image: false
|
|
1172
|
+
}),
|
|
1173
|
+
sessionCapabilities: zSessionCapabilities.optional().default({})
|
|
1174
|
+
});
|
|
1175
|
+
var zInitializeResponse = exports_external.object({
|
|
1176
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1177
|
+
agentCapabilities: zAgentCapabilities.optional().default({
|
|
1178
|
+
auth: {},
|
|
1179
|
+
loadSession: false,
|
|
1180
|
+
mcpCapabilities: { http: false, sse: false },
|
|
1181
|
+
promptCapabilities: {
|
|
1182
|
+
audio: false,
|
|
1183
|
+
embeddedContext: false,
|
|
1184
|
+
image: false
|
|
1185
|
+
},
|
|
1186
|
+
sessionCapabilities: {}
|
|
1187
|
+
}),
|
|
1188
|
+
agentInfo: zImplementation.nullish(),
|
|
1189
|
+
authMethods: exports_external.array(zAuthMethod).optional().default([]),
|
|
1190
|
+
protocolVersion: zProtocolVersion
|
|
1191
|
+
});
|
|
1192
|
+
var zTextResourceContents = exports_external.object({
|
|
1193
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1194
|
+
mimeType: exports_external.string().nullish(),
|
|
1195
|
+
text: exports_external.string(),
|
|
1196
|
+
uri: exports_external.string()
|
|
1197
|
+
});
|
|
1198
|
+
var zEmbeddedResourceResource = exports_external.union([
|
|
1199
|
+
zTextResourceContents,
|
|
1200
|
+
zBlobResourceContents
|
|
1201
|
+
]);
|
|
1202
|
+
var zEmbeddedResource = exports_external.object({
|
|
1203
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1204
|
+
annotations: zAnnotations.nullish(),
|
|
1205
|
+
resource: zEmbeddedResourceResource
|
|
1206
|
+
});
|
|
1207
|
+
var zContentBlock = exports_external.union([
|
|
1208
|
+
zTextContent.and(exports_external.object({
|
|
1209
|
+
type: exports_external.literal("text")
|
|
1210
|
+
})),
|
|
1211
|
+
zImageContent.and(exports_external.object({
|
|
1212
|
+
type: exports_external.literal("image")
|
|
1213
|
+
})),
|
|
1214
|
+
zAudioContent.and(exports_external.object({
|
|
1215
|
+
type: exports_external.literal("audio")
|
|
1216
|
+
})),
|
|
1217
|
+
zResourceLink.and(exports_external.object({
|
|
1218
|
+
type: exports_external.literal("resource_link")
|
|
1219
|
+
})),
|
|
1220
|
+
zEmbeddedResource.and(exports_external.object({
|
|
1221
|
+
type: exports_external.literal("resource")
|
|
1222
|
+
}))
|
|
1223
|
+
]);
|
|
1224
|
+
var zContent = exports_external.object({
|
|
1225
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1226
|
+
content: zContentBlock
|
|
1227
|
+
});
|
|
1228
|
+
var zContentChunk = exports_external.object({
|
|
1229
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1230
|
+
content: zContentBlock,
|
|
1231
|
+
messageId: exports_external.string().nullish()
|
|
1232
|
+
});
|
|
1233
|
+
var zPromptRequest = exports_external.object({
|
|
1234
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1235
|
+
messageId: exports_external.string().nullish(),
|
|
1236
|
+
prompt: exports_external.array(zContentBlock),
|
|
1237
|
+
sessionId: zSessionId
|
|
1238
|
+
});
|
|
1239
|
+
var zTitledMultiSelectItems = exports_external.object({
|
|
1240
|
+
anyOf: exports_external.array(zEnumOption)
|
|
1241
|
+
});
|
|
1242
|
+
var zToolCallContent = exports_external.union([
|
|
1243
|
+
zContent.and(exports_external.object({
|
|
1244
|
+
type: exports_external.literal("content")
|
|
1245
|
+
})),
|
|
1246
|
+
zDiff.and(exports_external.object({
|
|
1247
|
+
type: exports_external.literal("diff")
|
|
1248
|
+
})),
|
|
1249
|
+
zTerminal.and(exports_external.object({
|
|
1250
|
+
type: exports_external.literal("terminal")
|
|
1251
|
+
}))
|
|
1252
|
+
]);
|
|
1253
|
+
var zToolCallId = exports_external.string();
|
|
1254
|
+
var zElicitationSessionScope = exports_external.object({
|
|
1255
|
+
sessionId: zSessionId,
|
|
1256
|
+
toolCallId: zToolCallId.nullish()
|
|
1257
|
+
});
|
|
1258
|
+
var zElicitationUrlMode = exports_external.intersection(exports_external.union([zElicitationSessionScope, zElicitationRequestScope]), exports_external.object({
|
|
1259
|
+
elicitationId: zElicitationId,
|
|
1260
|
+
url: exports_external.string().url()
|
|
1261
|
+
}));
|
|
1262
|
+
var zToolCallLocation = exports_external.object({
|
|
1263
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1264
|
+
line: exports_external.number().int().gte(0).max(4294967295, {
|
|
1265
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
1266
|
+
}).nullish(),
|
|
1267
|
+
path: exports_external.string()
|
|
1268
|
+
});
|
|
1269
|
+
var zToolCallStatus = exports_external.union([
|
|
1270
|
+
exports_external.literal("pending"),
|
|
1271
|
+
exports_external.literal("in_progress"),
|
|
1272
|
+
exports_external.literal("completed"),
|
|
1273
|
+
exports_external.literal("failed")
|
|
1274
|
+
]);
|
|
1275
|
+
var zToolKind = exports_external.union([
|
|
1276
|
+
exports_external.literal("read"),
|
|
1277
|
+
exports_external.literal("edit"),
|
|
1278
|
+
exports_external.literal("delete"),
|
|
1279
|
+
exports_external.literal("move"),
|
|
1280
|
+
exports_external.literal("search"),
|
|
1281
|
+
exports_external.literal("execute"),
|
|
1282
|
+
exports_external.literal("think"),
|
|
1283
|
+
exports_external.literal("fetch"),
|
|
1284
|
+
exports_external.literal("switch_mode"),
|
|
1285
|
+
exports_external.literal("other")
|
|
1286
|
+
]);
|
|
1287
|
+
var zToolCall = exports_external.object({
|
|
1288
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1289
|
+
content: exports_external.array(zToolCallContent).optional(),
|
|
1290
|
+
kind: zToolKind.optional(),
|
|
1291
|
+
locations: exports_external.array(zToolCallLocation).optional(),
|
|
1292
|
+
rawInput: exports_external.unknown().optional(),
|
|
1293
|
+
rawOutput: exports_external.unknown().optional(),
|
|
1294
|
+
status: zToolCallStatus.optional(),
|
|
1295
|
+
title: exports_external.string(),
|
|
1296
|
+
toolCallId: zToolCallId
|
|
1297
|
+
});
|
|
1298
|
+
var zToolCallUpdate = exports_external.object({
|
|
1299
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1300
|
+
content: exports_external.array(zToolCallContent).nullish(),
|
|
1301
|
+
kind: zToolKind.nullish(),
|
|
1302
|
+
locations: exports_external.array(zToolCallLocation).nullish(),
|
|
1303
|
+
rawInput: exports_external.unknown().optional(),
|
|
1304
|
+
rawOutput: exports_external.unknown().optional(),
|
|
1305
|
+
status: zToolCallStatus.nullish(),
|
|
1306
|
+
title: exports_external.string().nullish(),
|
|
1307
|
+
toolCallId: zToolCallId
|
|
1308
|
+
});
|
|
1309
|
+
var zRequestPermissionRequest = exports_external.object({
|
|
1310
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1311
|
+
options: exports_external.array(zPermissionOption),
|
|
1312
|
+
sessionId: zSessionId,
|
|
1313
|
+
toolCall: zToolCallUpdate
|
|
1314
|
+
});
|
|
1315
|
+
var zUnstructuredCommandInput = exports_external.object({
|
|
1316
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1317
|
+
hint: exports_external.string()
|
|
1318
|
+
});
|
|
1319
|
+
var zAvailableCommandInput = zUnstructuredCommandInput;
|
|
1320
|
+
var zAvailableCommand = exports_external.object({
|
|
1321
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1322
|
+
description: exports_external.string(),
|
|
1323
|
+
input: zAvailableCommandInput.nullish(),
|
|
1324
|
+
name: exports_external.string()
|
|
1325
|
+
});
|
|
1326
|
+
var zAvailableCommandsUpdate = exports_external.object({
|
|
1327
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1328
|
+
availableCommands: exports_external.array(zAvailableCommand)
|
|
1329
|
+
});
|
|
1330
|
+
var zUntitledMultiSelectItems = exports_external.object({
|
|
1331
|
+
enum: exports_external.array(exports_external.string()),
|
|
1332
|
+
type: zElicitationStringType
|
|
1333
|
+
});
|
|
1334
|
+
var zMultiSelectItems = exports_external.union([
|
|
1335
|
+
zUntitledMultiSelectItems,
|
|
1336
|
+
zTitledMultiSelectItems
|
|
1337
|
+
]);
|
|
1338
|
+
var zMultiSelectPropertySchema = exports_external.object({
|
|
1339
|
+
default: exports_external.array(exports_external.string()).nullish(),
|
|
1340
|
+
description: exports_external.string().nullish(),
|
|
1341
|
+
items: zMultiSelectItems,
|
|
1342
|
+
maxItems: exports_external.number().nullish(),
|
|
1343
|
+
minItems: exports_external.number().nullish(),
|
|
1344
|
+
title: exports_external.string().nullish()
|
|
1345
|
+
});
|
|
1346
|
+
var zElicitationPropertySchema = exports_external.union([
|
|
1347
|
+
zStringPropertySchema.and(exports_external.object({
|
|
1348
|
+
type: exports_external.literal("string")
|
|
1349
|
+
})),
|
|
1350
|
+
zNumberPropertySchema.and(exports_external.object({
|
|
1351
|
+
type: exports_external.literal("number")
|
|
1352
|
+
})),
|
|
1353
|
+
zIntegerPropertySchema.and(exports_external.object({
|
|
1354
|
+
type: exports_external.literal("integer")
|
|
1355
|
+
})),
|
|
1356
|
+
zBooleanPropertySchema.and(exports_external.object({
|
|
1357
|
+
type: exports_external.literal("boolean")
|
|
1358
|
+
})),
|
|
1359
|
+
zMultiSelectPropertySchema.and(exports_external.object({
|
|
1360
|
+
type: exports_external.literal("array")
|
|
1361
|
+
}))
|
|
1362
|
+
]);
|
|
1363
|
+
var zElicitationSchema = exports_external.object({
|
|
1364
|
+
description: exports_external.string().nullish(),
|
|
1365
|
+
properties: exports_external.record(exports_external.string(), zElicitationPropertySchema).optional().default({}),
|
|
1366
|
+
required: exports_external.array(exports_external.string()).nullish(),
|
|
1367
|
+
title: exports_external.string().nullish(),
|
|
1368
|
+
type: zElicitationSchemaType.optional().default("object")
|
|
1369
|
+
});
|
|
1370
|
+
var zElicitationFormMode = exports_external.intersection(exports_external.union([zElicitationSessionScope, zElicitationRequestScope]), exports_external.object({
|
|
1371
|
+
requestedSchema: zElicitationSchema
|
|
1372
|
+
}));
|
|
1373
|
+
var zCreateElicitationRequest = exports_external.intersection(exports_external.union([
|
|
1374
|
+
zElicitationFormMode.and(exports_external.object({
|
|
1375
|
+
mode: exports_external.literal("form")
|
|
1376
|
+
})),
|
|
1377
|
+
zElicitationUrlMode.and(exports_external.object({
|
|
1378
|
+
mode: exports_external.literal("url")
|
|
1379
|
+
}))
|
|
1380
|
+
]), exports_external.object({
|
|
1381
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1382
|
+
message: exports_external.string()
|
|
1383
|
+
}));
|
|
1384
|
+
var zUsage = exports_external.object({
|
|
1385
|
+
cachedReadTokens: exports_external.number().nullish(),
|
|
1386
|
+
cachedWriteTokens: exports_external.number().nullish(),
|
|
1387
|
+
inputTokens: exports_external.number(),
|
|
1388
|
+
outputTokens: exports_external.number(),
|
|
1389
|
+
thoughtTokens: exports_external.number().nullish(),
|
|
1390
|
+
totalTokens: exports_external.number()
|
|
1391
|
+
});
|
|
1392
|
+
var zPromptResponse = exports_external.object({
|
|
1393
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1394
|
+
stopReason: zStopReason,
|
|
1395
|
+
usage: zUsage.nullish(),
|
|
1396
|
+
userMessageId: exports_external.string().nullish()
|
|
1397
|
+
});
|
|
1398
|
+
var zAgentResponse = exports_external.union([
|
|
1399
|
+
exports_external.object({
|
|
1400
|
+
id: zRequestId,
|
|
1401
|
+
result: exports_external.union([
|
|
1402
|
+
zInitializeResponse,
|
|
1403
|
+
zAuthenticateResponse,
|
|
1404
|
+
zLogoutResponse,
|
|
1405
|
+
zNewSessionResponse,
|
|
1406
|
+
zLoadSessionResponse,
|
|
1407
|
+
zListSessionsResponse,
|
|
1408
|
+
zForkSessionResponse,
|
|
1409
|
+
zResumeSessionResponse,
|
|
1410
|
+
zCloseSessionResponse,
|
|
1411
|
+
zSetSessionModeResponse,
|
|
1412
|
+
zSetSessionConfigOptionResponse,
|
|
1413
|
+
zPromptResponse,
|
|
1414
|
+
zSetSessionModelResponse,
|
|
1415
|
+
zStartNesResponse,
|
|
1416
|
+
zSuggestNesResponse,
|
|
1417
|
+
zCloseNesResponse,
|
|
1418
|
+
zExtResponse
|
|
1419
|
+
])
|
|
1420
|
+
}),
|
|
1421
|
+
exports_external.object({
|
|
1422
|
+
error: zError,
|
|
1423
|
+
id: zRequestId
|
|
1424
|
+
})
|
|
1425
|
+
]);
|
|
1426
|
+
var zUsageUpdate = exports_external.object({
|
|
1427
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1428
|
+
cost: zCost.nullish(),
|
|
1429
|
+
size: exports_external.number(),
|
|
1430
|
+
used: exports_external.number()
|
|
1431
|
+
});
|
|
1432
|
+
var zSessionUpdate = exports_external.union([
|
|
1433
|
+
zContentChunk.and(exports_external.object({
|
|
1434
|
+
sessionUpdate: exports_external.literal("user_message_chunk")
|
|
1435
|
+
})),
|
|
1436
|
+
zContentChunk.and(exports_external.object({
|
|
1437
|
+
sessionUpdate: exports_external.literal("agent_message_chunk")
|
|
1438
|
+
})),
|
|
1439
|
+
zContentChunk.and(exports_external.object({
|
|
1440
|
+
sessionUpdate: exports_external.literal("agent_thought_chunk")
|
|
1441
|
+
})),
|
|
1442
|
+
zToolCall.and(exports_external.object({
|
|
1443
|
+
sessionUpdate: exports_external.literal("tool_call")
|
|
1444
|
+
})),
|
|
1445
|
+
zToolCallUpdate.and(exports_external.object({
|
|
1446
|
+
sessionUpdate: exports_external.literal("tool_call_update")
|
|
1447
|
+
})),
|
|
1448
|
+
zPlan.and(exports_external.object({
|
|
1449
|
+
sessionUpdate: exports_external.literal("plan")
|
|
1450
|
+
})),
|
|
1451
|
+
zAvailableCommandsUpdate.and(exports_external.object({
|
|
1452
|
+
sessionUpdate: exports_external.literal("available_commands_update")
|
|
1453
|
+
})),
|
|
1454
|
+
zCurrentModeUpdate.and(exports_external.object({
|
|
1455
|
+
sessionUpdate: exports_external.literal("current_mode_update")
|
|
1456
|
+
})),
|
|
1457
|
+
zConfigOptionUpdate.and(exports_external.object({
|
|
1458
|
+
sessionUpdate: exports_external.literal("config_option_update")
|
|
1459
|
+
})),
|
|
1460
|
+
zSessionInfoUpdate.and(exports_external.object({
|
|
1461
|
+
sessionUpdate: exports_external.literal("session_info_update")
|
|
1462
|
+
})),
|
|
1463
|
+
zUsageUpdate.and(exports_external.object({
|
|
1464
|
+
sessionUpdate: exports_external.literal("usage_update")
|
|
1465
|
+
}))
|
|
1466
|
+
]);
|
|
1467
|
+
var zSessionNotification = exports_external.object({
|
|
1468
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1469
|
+
sessionId: zSessionId,
|
|
1470
|
+
update: zSessionUpdate
|
|
1471
|
+
});
|
|
1472
|
+
var zAgentNotification = exports_external.object({
|
|
1473
|
+
method: exports_external.string(),
|
|
1474
|
+
params: exports_external.union([
|
|
1475
|
+
zSessionNotification,
|
|
1476
|
+
zCompleteElicitationNotification,
|
|
1477
|
+
zExtNotification
|
|
1478
|
+
]).nullish()
|
|
1479
|
+
});
|
|
1480
|
+
var zWaitForTerminalExitRequest = exports_external.object({
|
|
1481
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1482
|
+
sessionId: zSessionId,
|
|
1483
|
+
terminalId: exports_external.string()
|
|
1484
|
+
});
|
|
1485
|
+
var zWaitForTerminalExitResponse = exports_external.object({
|
|
1486
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1487
|
+
exitCode: exports_external.number().int().gte(0).max(4294967295, {
|
|
1488
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
1489
|
+
}).nullish(),
|
|
1490
|
+
signal: exports_external.string().nullish()
|
|
1491
|
+
});
|
|
1492
|
+
var zWorkspaceFolder = exports_external.object({
|
|
1493
|
+
name: exports_external.string(),
|
|
1494
|
+
uri: exports_external.string()
|
|
1495
|
+
});
|
|
1496
|
+
var zStartNesRequest = exports_external.object({
|
|
1497
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1498
|
+
repository: zNesRepository.nullish(),
|
|
1499
|
+
workspaceFolders: exports_external.array(zWorkspaceFolder).nullish(),
|
|
1500
|
+
workspaceUri: exports_external.string().nullish()
|
|
1501
|
+
});
|
|
1502
|
+
var zClientRequest = exports_external.object({
|
|
1503
|
+
id: zRequestId,
|
|
1504
|
+
method: exports_external.string(),
|
|
1505
|
+
params: exports_external.union([
|
|
1506
|
+
zInitializeRequest,
|
|
1507
|
+
zAuthenticateRequest,
|
|
1508
|
+
zLogoutRequest,
|
|
1509
|
+
zNewSessionRequest,
|
|
1510
|
+
zLoadSessionRequest,
|
|
1511
|
+
zListSessionsRequest,
|
|
1512
|
+
zForkSessionRequest,
|
|
1513
|
+
zResumeSessionRequest,
|
|
1514
|
+
zCloseSessionRequest,
|
|
1515
|
+
zSetSessionModeRequest,
|
|
1516
|
+
zSetSessionConfigOptionRequest,
|
|
1517
|
+
zPromptRequest,
|
|
1518
|
+
zSetSessionModelRequest,
|
|
1519
|
+
zStartNesRequest,
|
|
1520
|
+
zSuggestNesRequest,
|
|
1521
|
+
zCloseNesRequest,
|
|
1522
|
+
zExtRequest
|
|
1523
|
+
]).nullish()
|
|
1524
|
+
});
|
|
1525
|
+
var zWriteTextFileRequest = exports_external.object({
|
|
1526
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish(),
|
|
1527
|
+
content: exports_external.string(),
|
|
1528
|
+
path: exports_external.string(),
|
|
1529
|
+
sessionId: zSessionId
|
|
1530
|
+
});
|
|
1531
|
+
var zAgentRequest = exports_external.object({
|
|
1532
|
+
id: zRequestId,
|
|
1533
|
+
method: exports_external.string(),
|
|
1534
|
+
params: exports_external.union([
|
|
1535
|
+
zWriteTextFileRequest,
|
|
1536
|
+
zReadTextFileRequest,
|
|
1537
|
+
zRequestPermissionRequest,
|
|
1538
|
+
zCreateTerminalRequest,
|
|
1539
|
+
zTerminalOutputRequest,
|
|
1540
|
+
zReleaseTerminalRequest,
|
|
1541
|
+
zWaitForTerminalExitRequest,
|
|
1542
|
+
zKillTerminalRequest,
|
|
1543
|
+
zCreateElicitationRequest,
|
|
1544
|
+
zExtRequest
|
|
1545
|
+
]).nullish()
|
|
1546
|
+
});
|
|
1547
|
+
var zWriteTextFileResponse = exports_external.object({
|
|
1548
|
+
_meta: exports_external.record(exports_external.string(), exports_external.unknown()).nullish()
|
|
1549
|
+
});
|
|
1550
|
+
var zClientResponse = exports_external.union([
|
|
1551
|
+
exports_external.object({
|
|
1552
|
+
id: zRequestId,
|
|
1553
|
+
result: exports_external.union([
|
|
1554
|
+
zWriteTextFileResponse,
|
|
1555
|
+
zReadTextFileResponse,
|
|
1556
|
+
zRequestPermissionResponse,
|
|
1557
|
+
zCreateTerminalResponse,
|
|
1558
|
+
zTerminalOutputResponse,
|
|
1559
|
+
zReleaseTerminalResponse,
|
|
1560
|
+
zWaitForTerminalExitResponse,
|
|
1561
|
+
zKillTerminalResponse,
|
|
1562
|
+
zCreateElicitationResponse,
|
|
1563
|
+
zExtResponse
|
|
1564
|
+
])
|
|
1565
|
+
}),
|
|
1566
|
+
exports_external.object({
|
|
1567
|
+
error: zError,
|
|
1568
|
+
id: zRequestId
|
|
1569
|
+
})
|
|
1570
|
+
]);
|
|
1571
|
+
// node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/stream.js
|
|
1572
|
+
function ndJsonStream(output, input) {
|
|
1573
|
+
const textEncoder = new TextEncoder;
|
|
1574
|
+
const textDecoder = new TextDecoder;
|
|
1575
|
+
const readable = new ReadableStream({
|
|
1576
|
+
async start(controller) {
|
|
1577
|
+
let content = "";
|
|
1578
|
+
const reader = input.getReader();
|
|
1579
|
+
try {
|
|
1580
|
+
while (true) {
|
|
1581
|
+
const { value, done } = await reader.read();
|
|
1582
|
+
if (done) {
|
|
1583
|
+
break;
|
|
1584
|
+
}
|
|
1585
|
+
if (!value) {
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1588
|
+
content += textDecoder.decode(value, { stream: true });
|
|
1589
|
+
const lines = content.split(`
|
|
1590
|
+
`);
|
|
1591
|
+
content = lines.pop() || "";
|
|
1592
|
+
for (const line of lines) {
|
|
1593
|
+
const trimmedLine = line.trim();
|
|
1594
|
+
if (trimmedLine) {
|
|
1595
|
+
try {
|
|
1596
|
+
const message = JSON.parse(trimmedLine);
|
|
1597
|
+
controller.enqueue(message);
|
|
1598
|
+
} catch (err) {
|
|
1599
|
+
console.error("Failed to parse JSON message:", trimmedLine, err);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
} catch (err) {
|
|
1605
|
+
controller.error(err);
|
|
1606
|
+
return;
|
|
1607
|
+
} finally {
|
|
1608
|
+
reader.releaseLock();
|
|
1609
|
+
}
|
|
1610
|
+
controller.close();
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
const writable = new WritableStream({
|
|
1614
|
+
async write(message) {
|
|
1615
|
+
const content = JSON.stringify(message) + `
|
|
1616
|
+
`;
|
|
1617
|
+
const writer = output.getWriter();
|
|
1618
|
+
try {
|
|
1619
|
+
await writer.write(textEncoder.encode(content));
|
|
1620
|
+
} finally {
|
|
1621
|
+
writer.releaseLock();
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
return { readable, writable };
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
// node_modules/.bun/@agentclientprotocol+sdk@0.19.0+3c5d820c62823f0b/node_modules/@agentclientprotocol/sdk/dist/acp.js
|
|
1629
|
+
class AgentSideConnection {
|
|
1630
|
+
#connection;
|
|
1631
|
+
constructor(toAgent, stream2) {
|
|
1632
|
+
const agent = toAgent(this);
|
|
1633
|
+
const requestHandler = async (method, params) => {
|
|
1634
|
+
switch (method) {
|
|
1635
|
+
case AGENT_METHODS.initialize: {
|
|
1636
|
+
const validatedParams = zInitializeRequest.parse(params);
|
|
1637
|
+
return agent.initialize(validatedParams);
|
|
1638
|
+
}
|
|
1639
|
+
case AGENT_METHODS.session_new: {
|
|
1640
|
+
const validatedParams = zNewSessionRequest.parse(params);
|
|
1641
|
+
return agent.newSession(validatedParams);
|
|
1642
|
+
}
|
|
1643
|
+
case AGENT_METHODS.session_load: {
|
|
1644
|
+
if (!agent.loadSession) {
|
|
1645
|
+
throw RequestError.methodNotFound(method);
|
|
1646
|
+
}
|
|
1647
|
+
const validatedParams = zLoadSessionRequest.parse(params);
|
|
1648
|
+
return agent.loadSession(validatedParams);
|
|
1649
|
+
}
|
|
1650
|
+
case AGENT_METHODS.session_list: {
|
|
1651
|
+
if (!agent.listSessions) {
|
|
1652
|
+
throw RequestError.methodNotFound(method);
|
|
1653
|
+
}
|
|
1654
|
+
const validatedParams = zListSessionsRequest.parse(params);
|
|
1655
|
+
return agent.listSessions(validatedParams);
|
|
1656
|
+
}
|
|
1657
|
+
case AGENT_METHODS.session_fork: {
|
|
1658
|
+
if (!agent.unstable_forkSession) {
|
|
1659
|
+
throw RequestError.methodNotFound(method);
|
|
1660
|
+
}
|
|
1661
|
+
const validatedParams = zForkSessionRequest.parse(params);
|
|
1662
|
+
return agent.unstable_forkSession(validatedParams);
|
|
1663
|
+
}
|
|
1664
|
+
case AGENT_METHODS.session_resume: {
|
|
1665
|
+
if (!agent.unstable_resumeSession) {
|
|
1666
|
+
throw RequestError.methodNotFound(method);
|
|
1667
|
+
}
|
|
1668
|
+
const validatedParams = zResumeSessionRequest.parse(params);
|
|
1669
|
+
return agent.unstable_resumeSession(validatedParams);
|
|
1670
|
+
}
|
|
1671
|
+
case AGENT_METHODS.session_close: {
|
|
1672
|
+
if (!agent.unstable_closeSession) {
|
|
1673
|
+
throw RequestError.methodNotFound(method);
|
|
1674
|
+
}
|
|
1675
|
+
const validatedParams = zCloseSessionRequest.parse(params);
|
|
1676
|
+
return agent.unstable_closeSession(validatedParams);
|
|
1677
|
+
}
|
|
1678
|
+
case AGENT_METHODS.session_set_mode: {
|
|
1679
|
+
if (!agent.setSessionMode) {
|
|
1680
|
+
throw RequestError.methodNotFound(method);
|
|
1681
|
+
}
|
|
1682
|
+
const validatedParams = zSetSessionModeRequest.parse(params);
|
|
1683
|
+
const result = await agent.setSessionMode(validatedParams);
|
|
1684
|
+
return result ?? {};
|
|
1685
|
+
}
|
|
1686
|
+
case AGENT_METHODS.authenticate: {
|
|
1687
|
+
const validatedParams = zAuthenticateRequest.parse(params);
|
|
1688
|
+
const result = await agent.authenticate(validatedParams);
|
|
1689
|
+
return result ?? {};
|
|
1690
|
+
}
|
|
1691
|
+
case AGENT_METHODS.logout: {
|
|
1692
|
+
if (!agent.unstable_logout) {
|
|
1693
|
+
throw RequestError.methodNotFound(method);
|
|
1694
|
+
}
|
|
1695
|
+
const validatedParams = zLogoutRequest.parse(params);
|
|
1696
|
+
const result = await agent.unstable_logout(validatedParams);
|
|
1697
|
+
return result ?? {};
|
|
1698
|
+
}
|
|
1699
|
+
case AGENT_METHODS.session_prompt: {
|
|
1700
|
+
const validatedParams = zPromptRequest.parse(params);
|
|
1701
|
+
return agent.prompt(validatedParams);
|
|
1702
|
+
}
|
|
1703
|
+
case AGENT_METHODS.session_set_model: {
|
|
1704
|
+
if (!agent.unstable_setSessionModel) {
|
|
1705
|
+
throw RequestError.methodNotFound(method);
|
|
1706
|
+
}
|
|
1707
|
+
const validatedParams = zSetSessionModelRequest.parse(params);
|
|
1708
|
+
const result = await agent.unstable_setSessionModel(validatedParams);
|
|
1709
|
+
return result ?? {};
|
|
1710
|
+
}
|
|
1711
|
+
case AGENT_METHODS.session_set_config_option: {
|
|
1712
|
+
if (!agent.setSessionConfigOption) {
|
|
1713
|
+
throw RequestError.methodNotFound(method);
|
|
1714
|
+
}
|
|
1715
|
+
const validatedParams = zSetSessionConfigOptionRequest.parse(params);
|
|
1716
|
+
return agent.setSessionConfigOption(validatedParams);
|
|
1717
|
+
}
|
|
1718
|
+
case AGENT_METHODS.nes_start: {
|
|
1719
|
+
if (!agent.unstable_startNes) {
|
|
1720
|
+
throw RequestError.methodNotFound(method);
|
|
1721
|
+
}
|
|
1722
|
+
const validatedParams = zStartNesRequest.parse(params);
|
|
1723
|
+
return agent.unstable_startNes(validatedParams);
|
|
1724
|
+
}
|
|
1725
|
+
case AGENT_METHODS.nes_suggest: {
|
|
1726
|
+
if (!agent.unstable_suggestNes) {
|
|
1727
|
+
throw RequestError.methodNotFound(method);
|
|
1728
|
+
}
|
|
1729
|
+
const validatedParams = zSuggestNesRequest.parse(params);
|
|
1730
|
+
return agent.unstable_suggestNes(validatedParams);
|
|
1731
|
+
}
|
|
1732
|
+
case AGENT_METHODS.nes_close: {
|
|
1733
|
+
if (!agent.unstable_closeNes) {
|
|
1734
|
+
throw RequestError.methodNotFound(method);
|
|
1735
|
+
}
|
|
1736
|
+
const validatedParams = zCloseNesRequest.parse(params);
|
|
1737
|
+
const result = await agent.unstable_closeNes(validatedParams);
|
|
1738
|
+
return result ?? {};
|
|
1739
|
+
}
|
|
1740
|
+
default:
|
|
1741
|
+
if (agent.extMethod) {
|
|
1742
|
+
return agent.extMethod(method, params);
|
|
1743
|
+
}
|
|
1744
|
+
throw RequestError.methodNotFound(method);
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
const notificationHandler = async (method, params) => {
|
|
1748
|
+
switch (method) {
|
|
1749
|
+
case AGENT_METHODS.session_cancel: {
|
|
1750
|
+
const validatedParams = zCancelNotification.parse(params);
|
|
1751
|
+
return agent.cancel(validatedParams);
|
|
1752
|
+
}
|
|
1753
|
+
case AGENT_METHODS.document_did_open: {
|
|
1754
|
+
if (!agent.unstable_didOpenDocument)
|
|
1755
|
+
return;
|
|
1756
|
+
const validatedParams = zDidOpenDocumentNotification.parse(params);
|
|
1757
|
+
return agent.unstable_didOpenDocument(validatedParams);
|
|
1758
|
+
}
|
|
1759
|
+
case AGENT_METHODS.document_did_change: {
|
|
1760
|
+
if (!agent.unstable_didChangeDocument)
|
|
1761
|
+
return;
|
|
1762
|
+
const validatedParams = zDidChangeDocumentNotification.parse(params);
|
|
1763
|
+
return agent.unstable_didChangeDocument(validatedParams);
|
|
1764
|
+
}
|
|
1765
|
+
case AGENT_METHODS.document_did_close: {
|
|
1766
|
+
if (!agent.unstable_didCloseDocument)
|
|
1767
|
+
return;
|
|
1768
|
+
const validatedParams = zDidCloseDocumentNotification.parse(params);
|
|
1769
|
+
return agent.unstable_didCloseDocument(validatedParams);
|
|
1770
|
+
}
|
|
1771
|
+
case AGENT_METHODS.document_did_save: {
|
|
1772
|
+
if (!agent.unstable_didSaveDocument)
|
|
1773
|
+
return;
|
|
1774
|
+
const validatedParams = zDidSaveDocumentNotification.parse(params);
|
|
1775
|
+
return agent.unstable_didSaveDocument(validatedParams);
|
|
1776
|
+
}
|
|
1777
|
+
case AGENT_METHODS.document_did_focus: {
|
|
1778
|
+
if (!agent.unstable_didFocusDocument)
|
|
1779
|
+
return;
|
|
1780
|
+
const validatedParams = zDidFocusDocumentNotification.parse(params);
|
|
1781
|
+
return agent.unstable_didFocusDocument(validatedParams);
|
|
1782
|
+
}
|
|
1783
|
+
case AGENT_METHODS.nes_accept: {
|
|
1784
|
+
if (!agent.unstable_acceptNes)
|
|
1785
|
+
return;
|
|
1786
|
+
const validatedParams = zAcceptNesNotification.parse(params);
|
|
1787
|
+
return agent.unstable_acceptNes(validatedParams);
|
|
1788
|
+
}
|
|
1789
|
+
case AGENT_METHODS.nes_reject: {
|
|
1790
|
+
if (!agent.unstable_rejectNes)
|
|
1791
|
+
return;
|
|
1792
|
+
const validatedParams = zRejectNesNotification.parse(params);
|
|
1793
|
+
return agent.unstable_rejectNes(validatedParams);
|
|
1794
|
+
}
|
|
1795
|
+
default:
|
|
1796
|
+
if (agent.extNotification) {
|
|
1797
|
+
return agent.extNotification(method, params);
|
|
1798
|
+
}
|
|
1799
|
+
throw RequestError.methodNotFound(method);
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
this.#connection = new Connection(requestHandler, notificationHandler, stream2);
|
|
1803
|
+
}
|
|
1804
|
+
async sessionUpdate(params) {
|
|
1805
|
+
return await this.#connection.sendNotification(CLIENT_METHODS.session_update, params);
|
|
1806
|
+
}
|
|
1807
|
+
async requestPermission(params) {
|
|
1808
|
+
return await this.#connection.sendRequest(CLIENT_METHODS.session_request_permission, params);
|
|
1809
|
+
}
|
|
1810
|
+
async readTextFile(params) {
|
|
1811
|
+
return await this.#connection.sendRequest(CLIENT_METHODS.fs_read_text_file, params);
|
|
1812
|
+
}
|
|
1813
|
+
async writeTextFile(params) {
|
|
1814
|
+
return await this.#connection.sendRequest(CLIENT_METHODS.fs_write_text_file, params) ?? {};
|
|
1815
|
+
}
|
|
1816
|
+
async createTerminal(params) {
|
|
1817
|
+
const response = await this.#connection.sendRequest(CLIENT_METHODS.terminal_create, params);
|
|
1818
|
+
return new TerminalHandle(response.terminalId, params.sessionId, this.#connection);
|
|
1819
|
+
}
|
|
1820
|
+
async unstable_createElicitation(params) {
|
|
1821
|
+
return await this.#connection.sendRequest(CLIENT_METHODS.elicitation_create, params);
|
|
1822
|
+
}
|
|
1823
|
+
async unstable_completeElicitation(params) {
|
|
1824
|
+
return await this.#connection.sendNotification(CLIENT_METHODS.elicitation_complete, params);
|
|
1825
|
+
}
|
|
1826
|
+
async extMethod(method, params) {
|
|
1827
|
+
return await this.#connection.sendRequest(method, params);
|
|
1828
|
+
}
|
|
1829
|
+
async extNotification(method, params) {
|
|
1830
|
+
return await this.#connection.sendNotification(method, params);
|
|
1831
|
+
}
|
|
1832
|
+
get signal() {
|
|
1833
|
+
return this.#connection.signal;
|
|
1834
|
+
}
|
|
1835
|
+
get closed() {
|
|
1836
|
+
return this.#connection.closed;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
class TerminalHandle {
|
|
1841
|
+
id;
|
|
1842
|
+
#sessionId;
|
|
1843
|
+
#connection;
|
|
1844
|
+
constructor(id, sessionId, conn) {
|
|
1845
|
+
this.id = id;
|
|
1846
|
+
this.#sessionId = sessionId;
|
|
1847
|
+
this.#connection = conn;
|
|
1848
|
+
}
|
|
1849
|
+
async currentOutput() {
|
|
1850
|
+
return await this.#connection.sendRequest(CLIENT_METHODS.terminal_output, {
|
|
1851
|
+
sessionId: this.#sessionId,
|
|
1852
|
+
terminalId: this.id
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
async waitForExit() {
|
|
1856
|
+
return await this.#connection.sendRequest(CLIENT_METHODS.terminal_wait_for_exit, {
|
|
1857
|
+
sessionId: this.#sessionId,
|
|
1858
|
+
terminalId: this.id
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
async kill() {
|
|
1862
|
+
return await this.#connection.sendRequest(CLIENT_METHODS.terminal_kill, {
|
|
1863
|
+
sessionId: this.#sessionId,
|
|
1864
|
+
terminalId: this.id
|
|
1865
|
+
}) ?? {};
|
|
1866
|
+
}
|
|
1867
|
+
async release() {
|
|
1868
|
+
return await this.#connection.sendRequest(CLIENT_METHODS.terminal_release, {
|
|
1869
|
+
sessionId: this.#sessionId,
|
|
1870
|
+
terminalId: this.id
|
|
1871
|
+
}) ?? {};
|
|
1872
|
+
}
|
|
1873
|
+
async[Symbol.asyncDispose]() {
|
|
1874
|
+
await this.release();
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
class ClientSideConnection {
|
|
1879
|
+
#connection;
|
|
1880
|
+
constructor(toClient, stream2) {
|
|
1881
|
+
const client = toClient(this);
|
|
1882
|
+
const requestHandler = async (method, params) => {
|
|
1883
|
+
switch (method) {
|
|
1884
|
+
case CLIENT_METHODS.fs_write_text_file: {
|
|
1885
|
+
const validatedParams = zWriteTextFileRequest.parse(params);
|
|
1886
|
+
return client.writeTextFile?.(validatedParams);
|
|
1887
|
+
}
|
|
1888
|
+
case CLIENT_METHODS.fs_read_text_file: {
|
|
1889
|
+
const validatedParams = zReadTextFileRequest.parse(params);
|
|
1890
|
+
return client.readTextFile?.(validatedParams);
|
|
1891
|
+
}
|
|
1892
|
+
case CLIENT_METHODS.session_request_permission: {
|
|
1893
|
+
const validatedParams = zRequestPermissionRequest.parse(params);
|
|
1894
|
+
return client.requestPermission(validatedParams);
|
|
1895
|
+
}
|
|
1896
|
+
case CLIENT_METHODS.terminal_create: {
|
|
1897
|
+
const validatedParams = zCreateTerminalRequest.parse(params);
|
|
1898
|
+
return client.createTerminal?.(validatedParams);
|
|
1899
|
+
}
|
|
1900
|
+
case CLIENT_METHODS.terminal_output: {
|
|
1901
|
+
const validatedParams = zTerminalOutputRequest.parse(params);
|
|
1902
|
+
return client.terminalOutput?.(validatedParams);
|
|
1903
|
+
}
|
|
1904
|
+
case CLIENT_METHODS.terminal_release: {
|
|
1905
|
+
const validatedParams = zReleaseTerminalRequest.parse(params);
|
|
1906
|
+
const result = await client.releaseTerminal?.(validatedParams);
|
|
1907
|
+
return result ?? {};
|
|
1908
|
+
}
|
|
1909
|
+
case CLIENT_METHODS.terminal_wait_for_exit: {
|
|
1910
|
+
const validatedParams = zWaitForTerminalExitRequest.parse(params);
|
|
1911
|
+
return client.waitForTerminalExit?.(validatedParams);
|
|
1912
|
+
}
|
|
1913
|
+
case CLIENT_METHODS.terminal_kill: {
|
|
1914
|
+
const validatedParams = zKillTerminalRequest.parse(params);
|
|
1915
|
+
const result = await client.killTerminal?.(validatedParams);
|
|
1916
|
+
return result ?? {};
|
|
1917
|
+
}
|
|
1918
|
+
case CLIENT_METHODS.elicitation_create: {
|
|
1919
|
+
if (!client.unstable_createElicitation) {
|
|
1920
|
+
throw RequestError.methodNotFound(method);
|
|
1921
|
+
}
|
|
1922
|
+
const validatedParams = zCreateElicitationRequest.parse(params);
|
|
1923
|
+
return client.unstable_createElicitation(validatedParams);
|
|
1924
|
+
}
|
|
1925
|
+
default:
|
|
1926
|
+
if (client.extMethod) {
|
|
1927
|
+
return client.extMethod(method, params);
|
|
1928
|
+
}
|
|
1929
|
+
throw RequestError.methodNotFound(method);
|
|
1930
|
+
}
|
|
1931
|
+
};
|
|
1932
|
+
const notificationHandler = async (method, params) => {
|
|
1933
|
+
switch (method) {
|
|
1934
|
+
case CLIENT_METHODS.session_update: {
|
|
1935
|
+
const validatedParams = zSessionNotification.parse(params);
|
|
1936
|
+
return client.sessionUpdate(validatedParams);
|
|
1937
|
+
}
|
|
1938
|
+
case CLIENT_METHODS.elicitation_complete: {
|
|
1939
|
+
if (!client.unstable_completeElicitation)
|
|
1940
|
+
return;
|
|
1941
|
+
const validatedParams = zCompleteElicitationNotification.parse(params);
|
|
1942
|
+
return client.unstable_completeElicitation(validatedParams);
|
|
1943
|
+
}
|
|
1944
|
+
default:
|
|
1945
|
+
if (client.extNotification) {
|
|
1946
|
+
return client.extNotification(method, params);
|
|
1947
|
+
}
|
|
1948
|
+
throw RequestError.methodNotFound(method);
|
|
1949
|
+
}
|
|
1950
|
+
};
|
|
1951
|
+
this.#connection = new Connection(requestHandler, notificationHandler, stream2);
|
|
1952
|
+
}
|
|
1953
|
+
async initialize(params) {
|
|
1954
|
+
return await this.#connection.sendRequest(AGENT_METHODS.initialize, params);
|
|
1955
|
+
}
|
|
1956
|
+
async newSession(params) {
|
|
1957
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_new, params);
|
|
1958
|
+
}
|
|
1959
|
+
async loadSession(params) {
|
|
1960
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_load, params) ?? {};
|
|
1961
|
+
}
|
|
1962
|
+
async unstable_forkSession(params) {
|
|
1963
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_fork, params);
|
|
1964
|
+
}
|
|
1965
|
+
async listSessions(params) {
|
|
1966
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_list, params);
|
|
1967
|
+
}
|
|
1968
|
+
async unstable_resumeSession(params) {
|
|
1969
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_resume, params);
|
|
1970
|
+
}
|
|
1971
|
+
async unstable_closeSession(params) {
|
|
1972
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_close, params);
|
|
1973
|
+
}
|
|
1974
|
+
async setSessionMode(params) {
|
|
1975
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_set_mode, params) ?? {};
|
|
1976
|
+
}
|
|
1977
|
+
async unstable_setSessionModel(params) {
|
|
1978
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_set_model, params) ?? {};
|
|
1979
|
+
}
|
|
1980
|
+
async setSessionConfigOption(params) {
|
|
1981
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_set_config_option, params);
|
|
1982
|
+
}
|
|
1983
|
+
async authenticate(params) {
|
|
1984
|
+
return await this.#connection.sendRequest(AGENT_METHODS.authenticate, params) ?? {};
|
|
1985
|
+
}
|
|
1986
|
+
async unstable_logout(params) {
|
|
1987
|
+
return await this.#connection.sendRequest(AGENT_METHODS.logout, params) ?? {};
|
|
1988
|
+
}
|
|
1989
|
+
async prompt(params) {
|
|
1990
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_prompt, params);
|
|
1991
|
+
}
|
|
1992
|
+
async cancel(params) {
|
|
1993
|
+
return await this.#connection.sendNotification(AGENT_METHODS.session_cancel, params);
|
|
1994
|
+
}
|
|
1995
|
+
async unstable_startNes(params) {
|
|
1996
|
+
return await this.#connection.sendRequest(AGENT_METHODS.nes_start, params);
|
|
1997
|
+
}
|
|
1998
|
+
async unstable_suggestNes(params) {
|
|
1999
|
+
return await this.#connection.sendRequest(AGENT_METHODS.nes_suggest, params);
|
|
2000
|
+
}
|
|
2001
|
+
async unstable_closeNes(params) {
|
|
2002
|
+
return await this.#connection.sendRequest(AGENT_METHODS.nes_close, params) ?? {};
|
|
2003
|
+
}
|
|
2004
|
+
async unstable_didOpenDocument(params) {
|
|
2005
|
+
return await this.#connection.sendNotification(AGENT_METHODS.document_did_open, params);
|
|
2006
|
+
}
|
|
2007
|
+
async unstable_didChangeDocument(params) {
|
|
2008
|
+
return await this.#connection.sendNotification(AGENT_METHODS.document_did_change, params);
|
|
2009
|
+
}
|
|
2010
|
+
async unstable_didCloseDocument(params) {
|
|
2011
|
+
return await this.#connection.sendNotification(AGENT_METHODS.document_did_close, params);
|
|
2012
|
+
}
|
|
2013
|
+
async unstable_didSaveDocument(params) {
|
|
2014
|
+
return await this.#connection.sendNotification(AGENT_METHODS.document_did_save, params);
|
|
2015
|
+
}
|
|
2016
|
+
async unstable_didFocusDocument(params) {
|
|
2017
|
+
return await this.#connection.sendNotification(AGENT_METHODS.document_did_focus, params);
|
|
2018
|
+
}
|
|
2019
|
+
async unstable_acceptNes(params) {
|
|
2020
|
+
return await this.#connection.sendNotification(AGENT_METHODS.nes_accept, params);
|
|
2021
|
+
}
|
|
2022
|
+
async unstable_rejectNes(params) {
|
|
2023
|
+
return await this.#connection.sendNotification(AGENT_METHODS.nes_reject, params);
|
|
2024
|
+
}
|
|
2025
|
+
async extMethod(method, params) {
|
|
2026
|
+
return await this.#connection.sendRequest(method, params);
|
|
2027
|
+
}
|
|
2028
|
+
async extNotification(method, params) {
|
|
2029
|
+
return await this.#connection.sendNotification(method, params);
|
|
2030
|
+
}
|
|
2031
|
+
get signal() {
|
|
2032
|
+
return this.#connection.signal;
|
|
2033
|
+
}
|
|
2034
|
+
get closed() {
|
|
2035
|
+
return this.#connection.closed;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
class Connection {
|
|
2040
|
+
#pendingResponses = new Map;
|
|
2041
|
+
#nextRequestId = 0;
|
|
2042
|
+
#requestHandler;
|
|
2043
|
+
#notificationHandler;
|
|
2044
|
+
#stream;
|
|
2045
|
+
#writeQueue = Promise.resolve();
|
|
2046
|
+
#abortController = new AbortController;
|
|
2047
|
+
#closedPromise;
|
|
2048
|
+
constructor(requestHandler, notificationHandler, stream2) {
|
|
2049
|
+
this.#requestHandler = requestHandler;
|
|
2050
|
+
this.#notificationHandler = notificationHandler;
|
|
2051
|
+
this.#stream = stream2;
|
|
2052
|
+
this.#closedPromise = new Promise((resolve) => {
|
|
2053
|
+
this.#abortController.signal.addEventListener("abort", () => resolve());
|
|
2054
|
+
});
|
|
2055
|
+
this.#receive();
|
|
2056
|
+
}
|
|
2057
|
+
get signal() {
|
|
2058
|
+
return this.#abortController.signal;
|
|
2059
|
+
}
|
|
2060
|
+
get closed() {
|
|
2061
|
+
return this.#closedPromise;
|
|
2062
|
+
}
|
|
2063
|
+
async#receive() {
|
|
2064
|
+
let closeError = undefined;
|
|
2065
|
+
try {
|
|
2066
|
+
const reader = this.#stream.readable.getReader();
|
|
2067
|
+
try {
|
|
2068
|
+
while (!this.#abortController.signal.aborted) {
|
|
2069
|
+
const { value: message, done } = await reader.read();
|
|
2070
|
+
if (done) {
|
|
2071
|
+
break;
|
|
2072
|
+
}
|
|
2073
|
+
if (!message) {
|
|
2074
|
+
continue;
|
|
2075
|
+
}
|
|
2076
|
+
try {
|
|
2077
|
+
this.#processMessage(message);
|
|
2078
|
+
} catch (err) {
|
|
2079
|
+
console.error("Unexpected error during message processing:", message, err);
|
|
2080
|
+
if ("id" in message && message.id !== undefined) {
|
|
2081
|
+
this.#sendMessage({
|
|
2082
|
+
jsonrpc: "2.0",
|
|
2083
|
+
id: message.id,
|
|
2084
|
+
error: {
|
|
2085
|
+
code: -32700,
|
|
2086
|
+
message: "Parse error"
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
} finally {
|
|
2093
|
+
reader.releaseLock();
|
|
2094
|
+
}
|
|
2095
|
+
} catch (error) {
|
|
2096
|
+
closeError = error;
|
|
2097
|
+
} finally {
|
|
2098
|
+
this.#close(closeError);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
#close(error) {
|
|
2102
|
+
if (this.#abortController.signal.aborted) {
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
const closeError = error ?? new Error("ACP connection closed");
|
|
2106
|
+
for (const pendingResponse of this.#pendingResponses.values()) {
|
|
2107
|
+
pendingResponse.reject(closeError);
|
|
2108
|
+
}
|
|
2109
|
+
this.#pendingResponses.clear();
|
|
2110
|
+
this.#abortController.abort(closeError);
|
|
2111
|
+
}
|
|
2112
|
+
async#processMessage(message) {
|
|
2113
|
+
if ("method" in message && "id" in message) {
|
|
2114
|
+
const response = await this.#tryCallRequestHandler(message.method, message.params);
|
|
2115
|
+
if ("error" in response) {
|
|
2116
|
+
console.error("Error handling request", message, response.error);
|
|
2117
|
+
}
|
|
2118
|
+
await this.#sendMessage({
|
|
2119
|
+
jsonrpc: "2.0",
|
|
2120
|
+
id: message.id,
|
|
2121
|
+
...response
|
|
2122
|
+
});
|
|
2123
|
+
} else if ("method" in message) {
|
|
2124
|
+
const response = await this.#tryCallNotificationHandler(message.method, message.params);
|
|
2125
|
+
if ("error" in response) {
|
|
2126
|
+
console.error("Error handling notification", message, response.error);
|
|
2127
|
+
}
|
|
2128
|
+
} else if ("id" in message) {
|
|
2129
|
+
this.#handleResponse(message);
|
|
2130
|
+
} else {
|
|
2131
|
+
console.error("Invalid message", { message });
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
async#tryCallRequestHandler(method, params) {
|
|
2135
|
+
try {
|
|
2136
|
+
const result = await this.#requestHandler(method, params);
|
|
2137
|
+
return { result: result ?? null };
|
|
2138
|
+
} catch (error) {
|
|
2139
|
+
if (error instanceof RequestError) {
|
|
2140
|
+
return error.toResult();
|
|
2141
|
+
}
|
|
2142
|
+
if (error instanceof exports_external.ZodError) {
|
|
2143
|
+
return RequestError.invalidParams(error.format()).toResult();
|
|
2144
|
+
}
|
|
2145
|
+
let details;
|
|
2146
|
+
if (error instanceof Error) {
|
|
2147
|
+
details = error.message;
|
|
2148
|
+
} else if (typeof error === "object" && error != null && "message" in error && typeof error.message === "string") {
|
|
2149
|
+
details = error.message;
|
|
2150
|
+
}
|
|
2151
|
+
try {
|
|
2152
|
+
return RequestError.internalError(details ? JSON.parse(details) : {}).toResult();
|
|
2153
|
+
} catch {
|
|
2154
|
+
return RequestError.internalError({ details }).toResult();
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
async#tryCallNotificationHandler(method, params) {
|
|
2159
|
+
try {
|
|
2160
|
+
await this.#notificationHandler(method, params);
|
|
2161
|
+
return { result: null };
|
|
2162
|
+
} catch (error) {
|
|
2163
|
+
if (error instanceof RequestError) {
|
|
2164
|
+
return error.toResult();
|
|
2165
|
+
}
|
|
2166
|
+
if (error instanceof exports_external.ZodError) {
|
|
2167
|
+
return RequestError.invalidParams(error.format()).toResult();
|
|
2168
|
+
}
|
|
2169
|
+
let details;
|
|
2170
|
+
if (error instanceof Error) {
|
|
2171
|
+
details = error.message;
|
|
2172
|
+
} else if (typeof error === "object" && error != null && "message" in error && typeof error.message === "string") {
|
|
2173
|
+
details = error.message;
|
|
2174
|
+
}
|
|
2175
|
+
try {
|
|
2176
|
+
return RequestError.internalError(details ? JSON.parse(details) : {}).toResult();
|
|
2177
|
+
} catch {
|
|
2178
|
+
return RequestError.internalError({ details }).toResult();
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
#handleResponse(response) {
|
|
2183
|
+
const pendingResponse = this.#pendingResponses.get(response.id);
|
|
2184
|
+
if (pendingResponse) {
|
|
2185
|
+
if ("result" in response) {
|
|
2186
|
+
pendingResponse.resolve(response.result);
|
|
2187
|
+
} else if ("error" in response) {
|
|
2188
|
+
const { code, message, data } = response.error;
|
|
2189
|
+
pendingResponse.reject(new RequestError(code, message, data));
|
|
2190
|
+
}
|
|
2191
|
+
this.#pendingResponses.delete(response.id);
|
|
2192
|
+
} else {
|
|
2193
|
+
console.error("Got response to unknown request", response.id);
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
async sendRequest(method, params) {
|
|
2197
|
+
this.#throwIfClosed();
|
|
2198
|
+
const id = this.#nextRequestId++;
|
|
2199
|
+
const responsePromise = new Promise((resolve, reject) => {
|
|
2200
|
+
this.#pendingResponses.set(id, { resolve, reject });
|
|
2201
|
+
});
|
|
2202
|
+
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
2203
|
+
return responsePromise;
|
|
2204
|
+
}
|
|
2205
|
+
async sendNotification(method, params) {
|
|
2206
|
+
this.#throwIfClosed();
|
|
2207
|
+
await this.#sendMessage({ jsonrpc: "2.0", method, params });
|
|
2208
|
+
}
|
|
2209
|
+
#throwIfClosed() {
|
|
2210
|
+
if (this.#abortController.signal.aborted) {
|
|
2211
|
+
throw this.#abortController.signal.reason ?? new Error("ACP connection closed");
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
async#sendMessage(message) {
|
|
2215
|
+
this.#writeQueue = this.#writeQueue.then(async () => {
|
|
2216
|
+
const writer = this.#stream.writable.getWriter();
|
|
2217
|
+
try {
|
|
2218
|
+
await writer.write(message);
|
|
2219
|
+
} finally {
|
|
2220
|
+
writer.releaseLock();
|
|
2221
|
+
}
|
|
2222
|
+
}).catch((error) => {
|
|
2223
|
+
this.#close(error);
|
|
2224
|
+
});
|
|
2225
|
+
return this.#writeQueue;
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
class RequestError extends Error {
|
|
2230
|
+
code;
|
|
2231
|
+
data;
|
|
2232
|
+
constructor(code, message, data) {
|
|
2233
|
+
super(message);
|
|
2234
|
+
this.code = code;
|
|
2235
|
+
this.name = "RequestError";
|
|
2236
|
+
this.data = data;
|
|
2237
|
+
}
|
|
2238
|
+
static parseError(data, additionalMessage) {
|
|
2239
|
+
return new RequestError(-32700, `Parse error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
2240
|
+
}
|
|
2241
|
+
static invalidRequest(data, additionalMessage) {
|
|
2242
|
+
return new RequestError(-32600, `Invalid request${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
2243
|
+
}
|
|
2244
|
+
static methodNotFound(method) {
|
|
2245
|
+
return new RequestError(-32601, `"Method not found": ${method}`, {
|
|
2246
|
+
method
|
|
2247
|
+
});
|
|
2248
|
+
}
|
|
2249
|
+
static invalidParams(data, additionalMessage) {
|
|
2250
|
+
return new RequestError(-32602, `Invalid params${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
2251
|
+
}
|
|
2252
|
+
static internalError(data, additionalMessage) {
|
|
2253
|
+
return new RequestError(-32603, `Internal error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
2254
|
+
}
|
|
2255
|
+
static authRequired(data, additionalMessage) {
|
|
2256
|
+
return new RequestError(-32000, `Authentication required${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
2257
|
+
}
|
|
2258
|
+
static resourceNotFound(uri) {
|
|
2259
|
+
return new RequestError(-32002, `Resource not found${uri ? `: ${uri}` : ""}`, uri && { uri });
|
|
2260
|
+
}
|
|
2261
|
+
toResult() {
|
|
2262
|
+
return {
|
|
2263
|
+
error: {
|
|
2264
|
+
code: this.code,
|
|
2265
|
+
message: this.message,
|
|
2266
|
+
data: this.data
|
|
2267
|
+
}
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
2270
|
+
toErrorResponse() {
|
|
2271
|
+
return {
|
|
2272
|
+
code: this.code,
|
|
2273
|
+
message: this.message,
|
|
2274
|
+
data: this.data
|
|
2275
|
+
};
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
// src/services/acp/entry.ts
|
|
2280
|
+
import { Readable, Writable } from "stream";
|
|
2281
|
+
|
|
2282
|
+
// src/services/acp/agent.ts
|
|
2283
|
+
init_conversationRecovery();
|
|
2284
|
+
init_sessionStorage();
|
|
2285
|
+
import { randomUUID } from "crypto";
|
|
2286
|
+
init_tools();
|
|
2287
|
+
init_Tool();
|
|
2288
|
+
init_commands();
|
|
2289
|
+
init_state();
|
|
2290
|
+
init_config();
|
|
2291
|
+
init_fileStateCache();
|
|
2292
|
+
init_AppStateStore();
|
|
2293
|
+
|
|
2294
|
+
// src/services/acp/permissions.ts
|
|
2295
|
+
init_permissions();
|
|
2296
|
+
|
|
2297
|
+
// src/services/acp/utils.ts
|
|
2298
|
+
import * as path from "path";
|
|
2299
|
+
var IS_ROOT = typeof process.geteuid === "function" ? process.geteuid() === 0 : typeof process.getuid === "function" ? process.getuid() === 0 : false;
|
|
2300
|
+
var ALLOW_BYPASS = !IS_ROOT || !!process.env.IS_SANDBOX;
|
|
2301
|
+
var PERMISSION_MODE_ALIASES = {
|
|
2302
|
+
auto: "auto",
|
|
2303
|
+
default: "default",
|
|
2304
|
+
acceptedits: "acceptEdits",
|
|
2305
|
+
dontask: "dontAsk",
|
|
2306
|
+
plan: "plan",
|
|
2307
|
+
bypasspermissions: "bypassPermissions",
|
|
2308
|
+
bypass: "bypassPermissions"
|
|
2309
|
+
};
|
|
2310
|
+
function resolvePermissionMode(defaultMode, source = "permissions.defaultMode") {
|
|
2311
|
+
if (defaultMode === undefined) {
|
|
2312
|
+
return "default";
|
|
2313
|
+
}
|
|
2314
|
+
if (typeof defaultMode !== "string") {
|
|
2315
|
+
throw new Error(`Invalid ${source}: expected a string.`);
|
|
2316
|
+
}
|
|
2317
|
+
const normalized = defaultMode.trim().toLowerCase();
|
|
2318
|
+
if (normalized === "") {
|
|
2319
|
+
throw new Error(`Invalid ${source}: expected a non-empty string.`);
|
|
2320
|
+
}
|
|
2321
|
+
const mapped = PERMISSION_MODE_ALIASES[normalized];
|
|
2322
|
+
if (!mapped) {
|
|
2323
|
+
throw new Error(`Invalid ${source}: ${defaultMode}.`);
|
|
2324
|
+
}
|
|
2325
|
+
if (mapped === "bypassPermissions" && !ALLOW_BYPASS) {
|
|
2326
|
+
throw new Error(`Invalid ${source}: bypassPermissions is not available when running as root.`);
|
|
2327
|
+
}
|
|
2328
|
+
return mapped;
|
|
2329
|
+
}
|
|
2330
|
+
function computeSessionFingerprint(params) {
|
|
2331
|
+
const servers = [...params.mcpServers ?? []].sort((a, b) => a.name.localeCompare(b.name));
|
|
2332
|
+
return JSON.stringify({ cwd: params.cwd, mcpServers: servers });
|
|
2333
|
+
}
|
|
2334
|
+
var MAX_TITLE_LENGTH = 256;
|
|
2335
|
+
function sanitizeTitle(text) {
|
|
2336
|
+
const sanitized = text.replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").trim();
|
|
2337
|
+
if (sanitized.length <= MAX_TITLE_LENGTH) {
|
|
2338
|
+
return sanitized;
|
|
2339
|
+
}
|
|
2340
|
+
return sanitized.slice(0, MAX_TITLE_LENGTH - 1) + "\u2026";
|
|
2341
|
+
}
|
|
2342
|
+
function toDisplayPath(filePath, cwd) {
|
|
2343
|
+
if (!cwd)
|
|
2344
|
+
return filePath;
|
|
2345
|
+
const resolvedCwd = path.resolve(cwd);
|
|
2346
|
+
const resolvedFile = path.resolve(filePath);
|
|
2347
|
+
if (resolvedFile.startsWith(resolvedCwd + path.sep) || resolvedFile === resolvedCwd) {
|
|
2348
|
+
return path.relative(resolvedCwd, resolvedFile).replaceAll("\\", "/");
|
|
2349
|
+
}
|
|
2350
|
+
return filePath;
|
|
2351
|
+
}
|
|
2352
|
+
function markdownEscape(text) {
|
|
2353
|
+
let escape = "```";
|
|
2354
|
+
for (const m of text.matchAll(/^```+/gm) ?? []) {
|
|
2355
|
+
while (m[0].length >= escape.length) {
|
|
2356
|
+
escape += "`";
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
return escape + `
|
|
2360
|
+
` + text + (text.endsWith(`
|
|
2361
|
+
`) ? "" : `
|
|
2362
|
+
`) + escape;
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
// src/services/acp/bridge.ts
|
|
2366
|
+
function toolInfoFromToolUse(toolUse, _supportsTerminalOutput = false, cwd) {
|
|
2367
|
+
const name = toolUse.name;
|
|
2368
|
+
const input = toolUse.input;
|
|
2369
|
+
switch (name) {
|
|
2370
|
+
case "Agent":
|
|
2371
|
+
case "Task": {
|
|
2372
|
+
const description = input?.description ?? "Task";
|
|
2373
|
+
const prompt = input?.prompt;
|
|
2374
|
+
return {
|
|
2375
|
+
title: description,
|
|
2376
|
+
kind: "think",
|
|
2377
|
+
content: prompt ? [{ type: "content", content: { type: "text", text: prompt } }] : []
|
|
2378
|
+
};
|
|
2379
|
+
}
|
|
2380
|
+
case "Bash": {
|
|
2381
|
+
const command = input?.command ?? "Terminal";
|
|
2382
|
+
const description = input?.description;
|
|
2383
|
+
return {
|
|
2384
|
+
title: command,
|
|
2385
|
+
kind: "execute",
|
|
2386
|
+
content: _supportsTerminalOutput ? [{ type: "terminal", terminalId: toolUse.id }] : description ? [{ type: "content", content: { type: "text", text: description } }] : []
|
|
2387
|
+
};
|
|
2388
|
+
}
|
|
2389
|
+
case "Read": {
|
|
2390
|
+
const filePath = input?.file_path ?? "File";
|
|
2391
|
+
const offset = input?.offset;
|
|
2392
|
+
const limit = input?.limit;
|
|
2393
|
+
let suffix = "";
|
|
2394
|
+
if (limit && limit > 0) {
|
|
2395
|
+
suffix = ` (${offset ?? 1} - ${(offset ?? 1) + limit - 1})`;
|
|
2396
|
+
} else if (offset) {
|
|
2397
|
+
suffix = ` (from line ${offset})`;
|
|
2398
|
+
}
|
|
2399
|
+
const displayPath = filePath ? toDisplayPath(filePath, cwd) : "File";
|
|
2400
|
+
return {
|
|
2401
|
+
title: `Read ${displayPath}${suffix}`,
|
|
2402
|
+
kind: "read",
|
|
2403
|
+
locations: filePath ? [{ path: filePath, line: offset ?? 1 }] : [],
|
|
2404
|
+
content: []
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
case "Write": {
|
|
2408
|
+
const filePath = input?.file_path ?? "";
|
|
2409
|
+
const content = input?.content ?? "";
|
|
2410
|
+
const displayPath = filePath ? toDisplayPath(filePath, cwd) : undefined;
|
|
2411
|
+
return {
|
|
2412
|
+
title: displayPath ? `Write ${displayPath}` : "Write",
|
|
2413
|
+
kind: "edit",
|
|
2414
|
+
content: filePath ? [{ type: "diff", path: filePath, oldText: null, newText: content }] : [{ type: "content", content: { type: "text", text: content } }],
|
|
2415
|
+
locations: filePath ? [{ path: filePath }] : []
|
|
2416
|
+
};
|
|
2417
|
+
}
|
|
2418
|
+
case "Edit": {
|
|
2419
|
+
const filePath = input?.file_path ?? "";
|
|
2420
|
+
const oldString = input?.old_string ?? "";
|
|
2421
|
+
const newString = input?.new_string ?? "";
|
|
2422
|
+
const displayPath = filePath ? toDisplayPath(filePath, cwd) : undefined;
|
|
2423
|
+
return {
|
|
2424
|
+
title: displayPath ? `Edit ${displayPath}` : "Edit",
|
|
2425
|
+
kind: "edit",
|
|
2426
|
+
content: filePath ? [{ type: "diff", path: filePath, oldText: oldString || null, newText: newString }] : [],
|
|
2427
|
+
locations: filePath ? [{ path: filePath }] : []
|
|
2428
|
+
};
|
|
2429
|
+
}
|
|
2430
|
+
case "Glob": {
|
|
2431
|
+
const globPath = input?.path ?? "";
|
|
2432
|
+
const pattern = input?.pattern ?? "";
|
|
2433
|
+
let label = "Find";
|
|
2434
|
+
if (globPath)
|
|
2435
|
+
label += ` \`${globPath}\``;
|
|
2436
|
+
if (pattern)
|
|
2437
|
+
label += ` \`${pattern}\``;
|
|
2438
|
+
return {
|
|
2439
|
+
title: label,
|
|
2440
|
+
kind: "search",
|
|
2441
|
+
content: [],
|
|
2442
|
+
locations: globPath ? [{ path: globPath }] : []
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
case "Grep": {
|
|
2446
|
+
const grepPattern = input?.pattern ?? "";
|
|
2447
|
+
const grepPath = input?.path ?? "";
|
|
2448
|
+
let label = "grep";
|
|
2449
|
+
if (input?.["-i"])
|
|
2450
|
+
label += " -i";
|
|
2451
|
+
if (input?.["-n"])
|
|
2452
|
+
label += " -n";
|
|
2453
|
+
if (input?.["-A"] !== undefined)
|
|
2454
|
+
label += ` -A ${input["-A"]}`;
|
|
2455
|
+
if (input?.["-B"] !== undefined)
|
|
2456
|
+
label += ` -B ${input["-B"]}`;
|
|
2457
|
+
if (input?.["-C"] !== undefined)
|
|
2458
|
+
label += ` -C ${input["-C"]}`;
|
|
2459
|
+
if (input?.output_mode === "files_with_matches")
|
|
2460
|
+
label += " -l";
|
|
2461
|
+
else if (input?.output_mode === "count")
|
|
2462
|
+
label += " -c";
|
|
2463
|
+
if (input?.head_limit !== undefined)
|
|
2464
|
+
label += ` | head -${input.head_limit}`;
|
|
2465
|
+
if (input?.glob)
|
|
2466
|
+
label += ` --include="${input.glob}"`;
|
|
2467
|
+
if (input?.type)
|
|
2468
|
+
label += ` --type=${input.type}`;
|
|
2469
|
+
if (input?.multiline)
|
|
2470
|
+
label += " -P";
|
|
2471
|
+
if (grepPattern)
|
|
2472
|
+
label += ` "${grepPattern}"`;
|
|
2473
|
+
if (grepPath)
|
|
2474
|
+
label += ` ${grepPath}`;
|
|
2475
|
+
return {
|
|
2476
|
+
title: label,
|
|
2477
|
+
kind: "search",
|
|
2478
|
+
content: []
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
case "WebFetch": {
|
|
2482
|
+
const url = input?.url ?? "";
|
|
2483
|
+
const fetchPrompt = input?.prompt;
|
|
2484
|
+
return {
|
|
2485
|
+
title: url ? `Fetch ${url}` : "Fetch",
|
|
2486
|
+
kind: "fetch",
|
|
2487
|
+
content: fetchPrompt ? [{ type: "content", content: { type: "text", text: fetchPrompt } }] : []
|
|
2488
|
+
};
|
|
2489
|
+
}
|
|
2490
|
+
case "WebSearch": {
|
|
2491
|
+
const query = input?.query ?? "Web search";
|
|
2492
|
+
let label = `"${query}"`;
|
|
2493
|
+
const allowed = input?.allowed_domains;
|
|
2494
|
+
const blocked = input?.blocked_domains;
|
|
2495
|
+
if (allowed && allowed.length > 0)
|
|
2496
|
+
label += ` (allowed: ${allowed.join(", ")})`;
|
|
2497
|
+
if (blocked && blocked.length > 0)
|
|
2498
|
+
label += ` (blocked: ${blocked.join(", ")})`;
|
|
2499
|
+
return {
|
|
2500
|
+
title: label,
|
|
2501
|
+
kind: "fetch",
|
|
2502
|
+
content: []
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
case "TodoWrite": {
|
|
2506
|
+
const todos = input?.todos;
|
|
2507
|
+
return {
|
|
2508
|
+
title: Array.isArray(todos) ? `Update TODOs: ${todos.map((t) => t.content).join(", ")}` : "Update TODOs",
|
|
2509
|
+
kind: "think",
|
|
2510
|
+
content: []
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
case "ExitPlanMode": {
|
|
2514
|
+
const plan = input?.plan;
|
|
2515
|
+
return {
|
|
2516
|
+
title: "Ready to code?",
|
|
2517
|
+
kind: "switch_mode",
|
|
2518
|
+
content: plan ? [{ type: "content", content: { type: "text", text: plan } }] : []
|
|
2519
|
+
};
|
|
2520
|
+
}
|
|
2521
|
+
default:
|
|
2522
|
+
return {
|
|
2523
|
+
title: name || "Unknown Tool",
|
|
2524
|
+
kind: "other",
|
|
2525
|
+
content: []
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
function toolUpdateFromToolResult(toolResult, toolUse, _supportsTerminalOutput = false) {
|
|
2530
|
+
if (!toolUse)
|
|
2531
|
+
return {};
|
|
2532
|
+
const isError = toolResult.is_error === true;
|
|
2533
|
+
const resultContent = toolResult.content;
|
|
2534
|
+
if (isError && resultContent) {
|
|
2535
|
+
return toAcpContentUpdate(resultContent, true);
|
|
2536
|
+
}
|
|
2537
|
+
switch (toolUse.name) {
|
|
2538
|
+
case "Read": {
|
|
2539
|
+
if (typeof resultContent === "string" && resultContent.length > 0) {
|
|
2540
|
+
return {
|
|
2541
|
+
content: [
|
|
2542
|
+
{
|
|
2543
|
+
type: "content",
|
|
2544
|
+
content: { type: "text", text: markdownEscape(resultContent) }
|
|
2545
|
+
}
|
|
2546
|
+
]
|
|
2547
|
+
};
|
|
2548
|
+
}
|
|
2549
|
+
if (Array.isArray(resultContent) && resultContent.length > 0) {
|
|
2550
|
+
return {
|
|
2551
|
+
content: resultContent.map((c) => ({
|
|
2552
|
+
type: "content",
|
|
2553
|
+
content: c.type === "text" ? { type: "text", text: markdownEscape(c.text) } : toAcpContentBlock(c, false)
|
|
2554
|
+
}))
|
|
2555
|
+
};
|
|
2556
|
+
}
|
|
2557
|
+
return {};
|
|
2558
|
+
}
|
|
2559
|
+
case "Bash": {
|
|
2560
|
+
let output = "";
|
|
2561
|
+
let exitCode = isError ? 1 : 0;
|
|
2562
|
+
const terminalId = String(toolUse.id);
|
|
2563
|
+
if (resultContent && typeof resultContent === "object" && !Array.isArray(resultContent) && resultContent.type === "bash_code_execution_result") {
|
|
2564
|
+
const bashResult = resultContent;
|
|
2565
|
+
output = [bashResult.stdout, bashResult.stderr].filter(Boolean).join(`
|
|
2566
|
+
`);
|
|
2567
|
+
exitCode = bashResult.return_code ?? (isError ? 1 : 0);
|
|
2568
|
+
} else if (typeof resultContent === "string") {
|
|
2569
|
+
output = resultContent;
|
|
2570
|
+
} else if (Array.isArray(resultContent) && resultContent.length > 0) {
|
|
2571
|
+
output = resultContent.map((c) => c.type === "text" ? c.text : "").join(`
|
|
2572
|
+
`);
|
|
2573
|
+
}
|
|
2574
|
+
if (_supportsTerminalOutput) {
|
|
2575
|
+
return {
|
|
2576
|
+
content: [{ type: "terminal", terminalId }],
|
|
2577
|
+
_meta: {
|
|
2578
|
+
terminal_info: { terminal_id: terminalId },
|
|
2579
|
+
terminal_output: { terminal_id: terminalId, data: output },
|
|
2580
|
+
terminal_exit: { terminal_id: terminalId, exit_code: exitCode, signal: null }
|
|
2581
|
+
}
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
if (output.trim()) {
|
|
2585
|
+
return {
|
|
2586
|
+
content: [
|
|
2587
|
+
{
|
|
2588
|
+
type: "content",
|
|
2589
|
+
content: {
|
|
2590
|
+
type: "text",
|
|
2591
|
+
text: `\`\`\`console
|
|
2592
|
+
${output.trimEnd()}
|
|
2593
|
+
\`\`\``
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
]
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
return {};
|
|
2600
|
+
}
|
|
2601
|
+
case "Edit":
|
|
2602
|
+
case "Write": {
|
|
2603
|
+
return {};
|
|
2604
|
+
}
|
|
2605
|
+
case "ExitPlanMode": {
|
|
2606
|
+
return { title: "Exited Plan Mode" };
|
|
2607
|
+
}
|
|
2608
|
+
default: {
|
|
2609
|
+
return toAcpContentUpdate(resultContent ?? "", isError);
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
function toAcpContentUpdate(content, isError) {
|
|
2614
|
+
if (Array.isArray(content) && content.length > 0) {
|
|
2615
|
+
return {
|
|
2616
|
+
content: content.map((c) => ({
|
|
2617
|
+
type: "content",
|
|
2618
|
+
content: toAcpContentBlock(c, isError)
|
|
2619
|
+
}))
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
if (typeof content === "string" && content.length > 0) {
|
|
2623
|
+
return {
|
|
2624
|
+
content: [
|
|
2625
|
+
{
|
|
2626
|
+
type: "content",
|
|
2627
|
+
content: {
|
|
2628
|
+
type: "text",
|
|
2629
|
+
text: isError ? `\`\`\`
|
|
2630
|
+
${content}
|
|
2631
|
+
\`\`\`` : content
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
]
|
|
2635
|
+
};
|
|
2636
|
+
}
|
|
2637
|
+
return {};
|
|
2638
|
+
}
|
|
2639
|
+
function toAcpContentBlock(content, isError) {
|
|
2640
|
+
const wrapText = (text) => ({
|
|
2641
|
+
type: "text",
|
|
2642
|
+
text: isError ? `\`\`\`
|
|
2643
|
+
${text}
|
|
2644
|
+
\`\`\`` : text
|
|
2645
|
+
});
|
|
2646
|
+
const type = content.type;
|
|
2647
|
+
switch (type) {
|
|
2648
|
+
case "text": {
|
|
2649
|
+
const text = content.text;
|
|
2650
|
+
return { type: "text", text: isError ? `\`\`\`
|
|
2651
|
+
${text}
|
|
2652
|
+
\`\`\`` : text };
|
|
2653
|
+
}
|
|
2654
|
+
case "image": {
|
|
2655
|
+
const source = content.source;
|
|
2656
|
+
if (source?.type === "base64") {
|
|
2657
|
+
return {
|
|
2658
|
+
type: "image",
|
|
2659
|
+
data: source.data,
|
|
2660
|
+
mimeType: source.media_type
|
|
2661
|
+
};
|
|
2662
|
+
}
|
|
2663
|
+
return wrapText(source?.type === "url" ? `[image: ${source.url}]` : "[image: file reference]");
|
|
2664
|
+
}
|
|
2665
|
+
case "tool_reference":
|
|
2666
|
+
return wrapText(`Tool: ${content.tool_name}`);
|
|
2667
|
+
case "tool_search_tool_search_result": {
|
|
2668
|
+
const refs = content.tool_references;
|
|
2669
|
+
return wrapText(`Tools found: ${refs?.map((r) => r.tool_name).join(", ") || "none"}`);
|
|
2670
|
+
}
|
|
2671
|
+
case "tool_search_tool_result_error":
|
|
2672
|
+
return wrapText(`Error: ${content.error_code}${content.error_message ? ` - ${content.error_message}` : ""}`);
|
|
2673
|
+
case "web_search_result":
|
|
2674
|
+
return wrapText(`${content.title} (${content.url})`);
|
|
2675
|
+
case "web_search_tool_result_error":
|
|
2676
|
+
return wrapText(`Error: ${content.error_code}`);
|
|
2677
|
+
case "web_fetch_result":
|
|
2678
|
+
return wrapText(`Fetched: ${content.url}`);
|
|
2679
|
+
case "web_fetch_tool_result_error":
|
|
2680
|
+
return wrapText(`Error: ${content.error_code}`);
|
|
2681
|
+
case "code_execution_result":
|
|
2682
|
+
case "bash_code_execution_result":
|
|
2683
|
+
return wrapText(`Output: ${content.stdout || content.stderr || ""}`);
|
|
2684
|
+
case "code_execution_tool_result_error":
|
|
2685
|
+
case "bash_code_execution_tool_result_error":
|
|
2686
|
+
return wrapText(`Error: ${content.error_code}`);
|
|
2687
|
+
case "text_editor_code_execution_view_result":
|
|
2688
|
+
return wrapText(content.content);
|
|
2689
|
+
case "text_editor_code_execution_create_result":
|
|
2690
|
+
return wrapText(content.is_file_update ? "File updated" : "File created");
|
|
2691
|
+
case "text_editor_code_execution_str_replace_result": {
|
|
2692
|
+
const lines = content.lines;
|
|
2693
|
+
return wrapText(lines?.join(`
|
|
2694
|
+
`) || "");
|
|
2695
|
+
}
|
|
2696
|
+
case "text_editor_code_execution_tool_result_error":
|
|
2697
|
+
return wrapText(`Error: ${content.error_code}${content.error_message ? ` - ${content.error_message}` : ""}`);
|
|
2698
|
+
default:
|
|
2699
|
+
try {
|
|
2700
|
+
return { type: "text", text: JSON.stringify(content) };
|
|
2701
|
+
} catch {
|
|
2702
|
+
return { type: "text", text: "[content]" };
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
function nextSdkMessageOrAbort(sdkMessages, abortSignal) {
|
|
2707
|
+
if (abortSignal.aborted) {
|
|
2708
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
2709
|
+
}
|
|
2710
|
+
let abortHandler;
|
|
2711
|
+
const abortPromise = new Promise((resolve2) => {
|
|
2712
|
+
abortHandler = () => resolve2({ done: true, value: undefined });
|
|
2713
|
+
abortSignal.addEventListener("abort", abortHandler, { once: true });
|
|
2714
|
+
});
|
|
2715
|
+
return Promise.race([sdkMessages.next(), abortPromise]).finally(() => {
|
|
2716
|
+
if (abortHandler) {
|
|
2717
|
+
abortSignal.removeEventListener("abort", abortHandler);
|
|
2718
|
+
}
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
async function forwardSessionUpdates(sessionId, sdkMessages, conn, abortSignal, toolUseCache, clientCapabilities, cwd, isCancelled) {
|
|
2722
|
+
let stopReason = "end_turn";
|
|
2723
|
+
const accumulatedUsage = {
|
|
2724
|
+
inputTokens: 0,
|
|
2725
|
+
outputTokens: 0,
|
|
2726
|
+
cachedReadTokens: 0,
|
|
2727
|
+
cachedWriteTokens: 0
|
|
2728
|
+
};
|
|
2729
|
+
let lastAssistantTotalUsage = null;
|
|
2730
|
+
let lastAssistantModel = null;
|
|
2731
|
+
let lastContextWindowSize = 200000;
|
|
2732
|
+
try {
|
|
2733
|
+
while (!abortSignal.aborted) {
|
|
2734
|
+
const nextResult = await nextSdkMessageOrAbort(sdkMessages, abortSignal);
|
|
2735
|
+
if (nextResult.done || abortSignal.aborted)
|
|
2736
|
+
break;
|
|
2737
|
+
const msg = nextResult.value;
|
|
2738
|
+
if (msg == null)
|
|
2739
|
+
continue;
|
|
2740
|
+
const type = msg.type;
|
|
2741
|
+
switch (type) {
|
|
2742
|
+
case "system": {
|
|
2743
|
+
const subtype = msg.subtype;
|
|
2744
|
+
if (subtype === "compact_boundary") {
|
|
2745
|
+
lastAssistantTotalUsage = 0;
|
|
2746
|
+
await conn.sessionUpdate({
|
|
2747
|
+
sessionId,
|
|
2748
|
+
update: {
|
|
2749
|
+
sessionUpdate: "usage_update",
|
|
2750
|
+
used: 0,
|
|
2751
|
+
size: lastContextWindowSize
|
|
2752
|
+
}
|
|
2753
|
+
});
|
|
2754
|
+
await conn.sessionUpdate({
|
|
2755
|
+
sessionId,
|
|
2756
|
+
update: {
|
|
2757
|
+
sessionUpdate: "agent_message_chunk",
|
|
2758
|
+
content: { type: "text", text: `
|
|
2759
|
+
|
|
2760
|
+
Compacting completed.` }
|
|
2761
|
+
}
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
break;
|
|
2765
|
+
}
|
|
2766
|
+
case "result": {
|
|
2767
|
+
const usage = msg.usage;
|
|
2768
|
+
if (usage) {
|
|
2769
|
+
accumulatedUsage.inputTokens += usage.input_tokens;
|
|
2770
|
+
accumulatedUsage.outputTokens += usage.output_tokens;
|
|
2771
|
+
accumulatedUsage.cachedReadTokens += usage.cache_read_input_tokens;
|
|
2772
|
+
accumulatedUsage.cachedWriteTokens += usage.cache_creation_input_tokens;
|
|
2773
|
+
}
|
|
2774
|
+
const modelUsage = msg.modelUsage;
|
|
2775
|
+
if (modelUsage && lastAssistantModel) {
|
|
2776
|
+
const match = getMatchingModelUsage(modelUsage, lastAssistantModel);
|
|
2777
|
+
if (match?.contextWindow) {
|
|
2778
|
+
lastContextWindowSize = match.contextWindow;
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
const usedTokens = lastAssistantTotalUsage ?? accumulatedUsage.inputTokens + accumulatedUsage.outputTokens + accumulatedUsage.cachedReadTokens + accumulatedUsage.cachedWriteTokens;
|
|
2782
|
+
const totalCostUsd = msg.total_cost_usd;
|
|
2783
|
+
await conn.sessionUpdate({
|
|
2784
|
+
sessionId,
|
|
2785
|
+
update: {
|
|
2786
|
+
sessionUpdate: "usage_update",
|
|
2787
|
+
used: usedTokens,
|
|
2788
|
+
size: lastContextWindowSize,
|
|
2789
|
+
cost: totalCostUsd != null ? { amount: totalCostUsd, currency: "USD" } : undefined
|
|
2790
|
+
}
|
|
2791
|
+
});
|
|
2792
|
+
const subtype = msg.subtype;
|
|
2793
|
+
const isError = msg.is_error;
|
|
2794
|
+
if (abortSignal.aborted) {
|
|
2795
|
+
stopReason = "cancelled";
|
|
2796
|
+
break;
|
|
2797
|
+
}
|
|
2798
|
+
switch (subtype) {
|
|
2799
|
+
case "success": {
|
|
2800
|
+
const stopReasonStr = msg.stop_reason;
|
|
2801
|
+
if (stopReasonStr === "max_tokens") {
|
|
2802
|
+
stopReason = "max_tokens";
|
|
2803
|
+
}
|
|
2804
|
+
if (isError) {
|
|
2805
|
+
stopReason = "end_turn";
|
|
2806
|
+
}
|
|
2807
|
+
break;
|
|
2808
|
+
}
|
|
2809
|
+
case "error_during_execution": {
|
|
2810
|
+
if (msg.stop_reason === "max_tokens") {
|
|
2811
|
+
stopReason = "max_tokens";
|
|
2812
|
+
} else if (isError) {
|
|
2813
|
+
stopReason = "end_turn";
|
|
2814
|
+
} else {
|
|
2815
|
+
stopReason = "end_turn";
|
|
2816
|
+
}
|
|
2817
|
+
break;
|
|
2818
|
+
}
|
|
2819
|
+
case "error_max_budget_usd":
|
|
2820
|
+
case "error_max_turns":
|
|
2821
|
+
case "error_max_structured_output_retries":
|
|
2822
|
+
if (isError) {
|
|
2823
|
+
stopReason = "max_turn_requests";
|
|
2824
|
+
} else {
|
|
2825
|
+
stopReason = "max_turn_requests";
|
|
2826
|
+
}
|
|
2827
|
+
break;
|
|
2828
|
+
}
|
|
2829
|
+
break;
|
|
2830
|
+
}
|
|
2831
|
+
case "stream_event": {
|
|
2832
|
+
const notifications = streamEventToAcpNotifications(msg, sessionId, toolUseCache, conn, {
|
|
2833
|
+
clientCapabilities,
|
|
2834
|
+
cwd
|
|
2835
|
+
});
|
|
2836
|
+
for (const notification of notifications) {
|
|
2837
|
+
await conn.sessionUpdate(notification);
|
|
2838
|
+
}
|
|
2839
|
+
break;
|
|
2840
|
+
}
|
|
2841
|
+
case "assistant": {
|
|
2842
|
+
const assistantMsg = msg.message;
|
|
2843
|
+
const parentToolUseId = msg.parent_tool_use_id;
|
|
2844
|
+
if (assistantMsg?.usage && parentToolUseId === null) {
|
|
2845
|
+
const msgUsage = assistantMsg.usage;
|
|
2846
|
+
lastAssistantTotalUsage = (msgUsage.input_tokens ?? 0) + (msgUsage.output_tokens ?? 0) + (msgUsage.cache_read_input_tokens ?? 0) + (msgUsage.cache_creation_input_tokens ?? 0);
|
|
2847
|
+
}
|
|
2848
|
+
if (parentToolUseId === null && assistantMsg?.model && assistantMsg.model !== "<synthetic>") {
|
|
2849
|
+
lastAssistantModel = assistantMsg.model;
|
|
2850
|
+
}
|
|
2851
|
+
const notifications = assistantMessageToAcpNotifications(msg, sessionId, toolUseCache, conn, {
|
|
2852
|
+
clientCapabilities,
|
|
2853
|
+
cwd
|
|
2854
|
+
});
|
|
2855
|
+
for (const notification of notifications) {
|
|
2856
|
+
await conn.sessionUpdate(notification);
|
|
2857
|
+
}
|
|
2858
|
+
break;
|
|
2859
|
+
}
|
|
2860
|
+
case "user": {
|
|
2861
|
+
break;
|
|
2862
|
+
}
|
|
2863
|
+
case "progress": {
|
|
2864
|
+
const progressData = msg.data;
|
|
2865
|
+
if (!progressData)
|
|
2866
|
+
break;
|
|
2867
|
+
const progressType = progressData.type;
|
|
2868
|
+
if (progressType === "agent_progress" || progressType === "skill_progress") {
|
|
2869
|
+
const progressMessage = progressData.message;
|
|
2870
|
+
if (progressMessage) {
|
|
2871
|
+
const content = progressMessage.content;
|
|
2872
|
+
if (content) {
|
|
2873
|
+
for (const block of content) {
|
|
2874
|
+
if (block.type === "text") {
|
|
2875
|
+
await conn.sessionUpdate({
|
|
2876
|
+
sessionId,
|
|
2877
|
+
update: {
|
|
2878
|
+
sessionUpdate: "agent_message_chunk",
|
|
2879
|
+
content: { type: "text", text: block.text }
|
|
2880
|
+
}
|
|
2881
|
+
});
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
break;
|
|
2888
|
+
}
|
|
2889
|
+
case "tool_use_summary": {
|
|
2890
|
+
break;
|
|
2891
|
+
}
|
|
2892
|
+
case "attachment": {
|
|
2893
|
+
break;
|
|
2894
|
+
}
|
|
2895
|
+
case "compact_boundary": {
|
|
2896
|
+
lastAssistantTotalUsage = 0;
|
|
2897
|
+
await conn.sessionUpdate({
|
|
2898
|
+
sessionId,
|
|
2899
|
+
update: {
|
|
2900
|
+
sessionUpdate: "usage_update",
|
|
2901
|
+
used: 0,
|
|
2902
|
+
size: lastContextWindowSize
|
|
2903
|
+
}
|
|
2904
|
+
});
|
|
2905
|
+
await conn.sessionUpdate({
|
|
2906
|
+
sessionId,
|
|
2907
|
+
update: {
|
|
2908
|
+
sessionUpdate: "agent_message_chunk",
|
|
2909
|
+
content: { type: "text", text: `
|
|
2910
|
+
|
|
2911
|
+
Compacting completed.` }
|
|
2912
|
+
}
|
|
2913
|
+
});
|
|
2914
|
+
break;
|
|
2915
|
+
}
|
|
2916
|
+
default:
|
|
2917
|
+
break;
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
if (abortSignal.aborted || isCancelled?.()) {
|
|
2921
|
+
return { stopReason: "cancelled", usage: accumulatedUsage };
|
|
2922
|
+
}
|
|
2923
|
+
} catch (err) {
|
|
2924
|
+
if (abortSignal.aborted) {
|
|
2925
|
+
return { stopReason: "cancelled", usage: accumulatedUsage };
|
|
2926
|
+
}
|
|
2927
|
+
throw err;
|
|
2928
|
+
}
|
|
2929
|
+
return { stopReason, usage: accumulatedUsage };
|
|
2930
|
+
}
|
|
2931
|
+
function assistantMessageToAcpNotifications(msg, sessionId, toolUseCache, conn, options) {
|
|
2932
|
+
const message = msg.message;
|
|
2933
|
+
if (!message)
|
|
2934
|
+
return [];
|
|
2935
|
+
const content = message.content;
|
|
2936
|
+
if (!content)
|
|
2937
|
+
return [];
|
|
2938
|
+
if (typeof content === "string") {
|
|
2939
|
+
return [
|
|
2940
|
+
{
|
|
2941
|
+
sessionId,
|
|
2942
|
+
update: {
|
|
2943
|
+
sessionUpdate: "agent_message_chunk",
|
|
2944
|
+
content: { type: "text", text: content }
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
];
|
|
2948
|
+
}
|
|
2949
|
+
return toAcpNotifications(content, "assistant", sessionId, toolUseCache, conn, undefined, options);
|
|
2950
|
+
}
|
|
2951
|
+
function streamEventToAcpNotifications(msg, sessionId, toolUseCache, conn, options) {
|
|
2952
|
+
const event = msg.event;
|
|
2953
|
+
if (!event)
|
|
2954
|
+
return [];
|
|
2955
|
+
switch (event.type) {
|
|
2956
|
+
case "content_block_start": {
|
|
2957
|
+
const contentBlock = event.content_block;
|
|
2958
|
+
if (!contentBlock)
|
|
2959
|
+
return [];
|
|
2960
|
+
return toAcpNotifications([contentBlock], "assistant", sessionId, toolUseCache, conn, undefined, {
|
|
2961
|
+
clientCapabilities: options?.clientCapabilities,
|
|
2962
|
+
parentToolUseId: msg.parent_tool_use_id,
|
|
2963
|
+
cwd: options?.cwd
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
case "content_block_delta": {
|
|
2967
|
+
const delta = event.delta;
|
|
2968
|
+
if (!delta)
|
|
2969
|
+
return [];
|
|
2970
|
+
return toAcpNotifications([delta], "assistant", sessionId, toolUseCache, conn, undefined, {
|
|
2971
|
+
clientCapabilities: options?.clientCapabilities,
|
|
2972
|
+
parentToolUseId: msg.parent_tool_use_id,
|
|
2973
|
+
cwd: options?.cwd
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
2976
|
+
case "message_start":
|
|
2977
|
+
case "message_delta":
|
|
2978
|
+
case "message_stop":
|
|
2979
|
+
case "content_block_stop":
|
|
2980
|
+
return [];
|
|
2981
|
+
default:
|
|
2982
|
+
return [];
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
function toAcpNotifications(content, role, sessionId, toolUseCache, _conn, _logger, options) {
|
|
2986
|
+
const output = [];
|
|
2987
|
+
for (const chunk of content) {
|
|
2988
|
+
const chunkType = chunk.type;
|
|
2989
|
+
let update = null;
|
|
2990
|
+
switch (chunkType) {
|
|
2991
|
+
case "text":
|
|
2992
|
+
case "text_delta": {
|
|
2993
|
+
const text = chunk.text ?? "";
|
|
2994
|
+
update = {
|
|
2995
|
+
sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
|
|
2996
|
+
content: { type: "text", text }
|
|
2997
|
+
};
|
|
2998
|
+
break;
|
|
2999
|
+
}
|
|
3000
|
+
case "thinking":
|
|
3001
|
+
case "thinking_delta": {
|
|
3002
|
+
const thinking = chunk.thinking ?? "";
|
|
3003
|
+
update = {
|
|
3004
|
+
sessionUpdate: "agent_thought_chunk",
|
|
3005
|
+
content: { type: "text", text: thinking }
|
|
3006
|
+
};
|
|
3007
|
+
break;
|
|
3008
|
+
}
|
|
3009
|
+
case "image": {
|
|
3010
|
+
const source = chunk.source;
|
|
3011
|
+
if (source?.type === "base64") {
|
|
3012
|
+
update = {
|
|
3013
|
+
sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
|
|
3014
|
+
content: {
|
|
3015
|
+
type: "image",
|
|
3016
|
+
data: source.data,
|
|
3017
|
+
mimeType: source.media_type
|
|
3018
|
+
}
|
|
3019
|
+
};
|
|
3020
|
+
}
|
|
3021
|
+
break;
|
|
3022
|
+
}
|
|
3023
|
+
case "tool_use":
|
|
3024
|
+
case "server_tool_use":
|
|
3025
|
+
case "mcp_tool_use": {
|
|
3026
|
+
const toolUseId = chunk.id ?? "";
|
|
3027
|
+
const toolName = chunk.name ?? "unknown";
|
|
3028
|
+
const toolInput = chunk.input;
|
|
3029
|
+
const alreadyCached = toolUseId in toolUseCache;
|
|
3030
|
+
toolUseCache[toolUseId] = {
|
|
3031
|
+
type: chunkType,
|
|
3032
|
+
id: toolUseId,
|
|
3033
|
+
name: toolName,
|
|
3034
|
+
input: toolInput
|
|
3035
|
+
};
|
|
3036
|
+
if (toolName === "TodoWrite") {
|
|
3037
|
+
const todos = toolInput?.todos;
|
|
3038
|
+
if (Array.isArray(todos)) {
|
|
3039
|
+
const entries = todos.map((todo) => ({
|
|
3040
|
+
content: todo.content,
|
|
3041
|
+
status: normalizePlanStatus(todo.status),
|
|
3042
|
+
priority: "medium"
|
|
3043
|
+
}));
|
|
3044
|
+
update = {
|
|
3045
|
+
sessionUpdate: "plan",
|
|
3046
|
+
entries
|
|
3047
|
+
};
|
|
3048
|
+
}
|
|
3049
|
+
} else {
|
|
3050
|
+
const rawInput = toolInput ? { ...toolInput } : {};
|
|
3051
|
+
if (alreadyCached) {
|
|
3052
|
+
update = {
|
|
3053
|
+
_meta: {
|
|
3054
|
+
claudeCode: { toolName }
|
|
3055
|
+
},
|
|
3056
|
+
toolCallId: toolUseId,
|
|
3057
|
+
sessionUpdate: "tool_call_update",
|
|
3058
|
+
rawInput,
|
|
3059
|
+
...toolInfoFromToolUse({ name: toolName, id: toolUseId, input: toolInput ?? {} }, false, options?.cwd)
|
|
3060
|
+
};
|
|
3061
|
+
} else {
|
|
3062
|
+
update = {
|
|
3063
|
+
_meta: {
|
|
3064
|
+
claudeCode: { toolName }
|
|
3065
|
+
},
|
|
3066
|
+
toolCallId: toolUseId,
|
|
3067
|
+
sessionUpdate: "tool_call",
|
|
3068
|
+
rawInput,
|
|
3069
|
+
status: "pending",
|
|
3070
|
+
...toolInfoFromToolUse({ name: toolName, id: toolUseId, input: toolInput ?? {} }, false, options?.cwd)
|
|
3071
|
+
};
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
break;
|
|
3075
|
+
}
|
|
3076
|
+
case "tool_result":
|
|
3077
|
+
case "mcp_tool_result": {
|
|
3078
|
+
const toolUseId = chunk.tool_use_id ?? "";
|
|
3079
|
+
const toolUse = toolUseCache[toolUseId];
|
|
3080
|
+
if (!toolUse)
|
|
3081
|
+
break;
|
|
3082
|
+
if (toolUse.name !== "TodoWrite") {
|
|
3083
|
+
const toolUpdate = toolUpdateFromToolResult(chunk, { name: toolUse.name, id: toolUse.id }, false);
|
|
3084
|
+
update = {
|
|
3085
|
+
_meta: {
|
|
3086
|
+
claudeCode: { toolName: toolUse.name }
|
|
3087
|
+
},
|
|
3088
|
+
toolCallId: toolUseId,
|
|
3089
|
+
sessionUpdate: "tool_call_update",
|
|
3090
|
+
status: chunk.is_error === true ? "failed" : "completed",
|
|
3091
|
+
rawOutput: chunk.content,
|
|
3092
|
+
...toolUpdate
|
|
3093
|
+
};
|
|
3094
|
+
}
|
|
3095
|
+
break;
|
|
3096
|
+
}
|
|
3097
|
+
case "redacted_thinking":
|
|
3098
|
+
case "input_json_delta":
|
|
3099
|
+
case "citations_delta":
|
|
3100
|
+
case "signature_delta":
|
|
3101
|
+
case "container_upload":
|
|
3102
|
+
case "compaction":
|
|
3103
|
+
case "compaction_delta":
|
|
3104
|
+
break;
|
|
3105
|
+
}
|
|
3106
|
+
if (update) {
|
|
3107
|
+
if (options?.parentToolUseId) {
|
|
3108
|
+
const existingMeta = update._meta;
|
|
3109
|
+
update._meta = {
|
|
3110
|
+
...existingMeta,
|
|
3111
|
+
claudeCode: {
|
|
3112
|
+
...existingMeta?.claudeCode ?? {},
|
|
3113
|
+
parentToolUseId: options.parentToolUseId
|
|
3114
|
+
}
|
|
3115
|
+
};
|
|
3116
|
+
}
|
|
3117
|
+
output.push({ sessionId, update });
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
return output;
|
|
3121
|
+
}
|
|
3122
|
+
function normalizePlanStatus(status) {
|
|
3123
|
+
if (status === "in_progress")
|
|
3124
|
+
return "in_progress";
|
|
3125
|
+
if (status === "completed")
|
|
3126
|
+
return "completed";
|
|
3127
|
+
return "pending";
|
|
3128
|
+
}
|
|
3129
|
+
async function replayHistoryMessages(sessionId, messages, conn, toolUseCache, clientCapabilities, cwd) {
|
|
3130
|
+
for (const msg of messages) {
|
|
3131
|
+
const type = msg.type;
|
|
3132
|
+
if (type !== "user" && type !== "assistant")
|
|
3133
|
+
continue;
|
|
3134
|
+
if (msg.isMeta === true)
|
|
3135
|
+
continue;
|
|
3136
|
+
const messageData = msg.message;
|
|
3137
|
+
const content = messageData?.content;
|
|
3138
|
+
if (!content)
|
|
3139
|
+
continue;
|
|
3140
|
+
const role = type === "assistant" ? "assistant" : "user";
|
|
3141
|
+
if (typeof content === "string") {
|
|
3142
|
+
if (!content.trim())
|
|
3143
|
+
continue;
|
|
3144
|
+
await conn.sessionUpdate({
|
|
3145
|
+
sessionId,
|
|
3146
|
+
update: {
|
|
3147
|
+
sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
|
|
3148
|
+
content: { type: "text", text: content }
|
|
3149
|
+
}
|
|
3150
|
+
});
|
|
3151
|
+
continue;
|
|
3152
|
+
}
|
|
3153
|
+
if (Array.isArray(content)) {
|
|
3154
|
+
const notifications = toAcpNotifications(content, role, sessionId, toolUseCache, conn, undefined, { clientCapabilities, cwd });
|
|
3155
|
+
for (const notification of notifications) {
|
|
3156
|
+
await conn.sessionUpdate(notification);
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
function commonPrefixLength(a, b) {
|
|
3162
|
+
let i = 0;
|
|
3163
|
+
const maxLen = Math.min(a.length, b.length);
|
|
3164
|
+
while (i < maxLen && a[i] === b[i])
|
|
3165
|
+
i++;
|
|
3166
|
+
return i;
|
|
3167
|
+
}
|
|
3168
|
+
function getMatchingModelUsage(modelUsage, currentModel) {
|
|
3169
|
+
let bestKey = null;
|
|
3170
|
+
let bestLen = 0;
|
|
3171
|
+
for (const key of Object.keys(modelUsage)) {
|
|
3172
|
+
const len = commonPrefixLength(key, currentModel);
|
|
3173
|
+
if (len > bestLen) {
|
|
3174
|
+
bestLen = len;
|
|
3175
|
+
bestKey = key;
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
return bestKey ? modelUsage[bestKey] ?? null : null;
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
// src/services/acp/permissions.ts
|
|
3182
|
+
function createAcpCanUseTool(conn, sessionId, getCurrentMode, clientCapabilities, cwd, onModeChange, isBypassModeAvailable) {
|
|
3183
|
+
return async (tool, input, context, assistantMessage, toolUseID, forceDecision) => {
|
|
3184
|
+
const supportsTerminalOutput = checkTerminalOutput(clientCapabilities);
|
|
3185
|
+
if (tool.name === "ExitPlanMode") {
|
|
3186
|
+
return handleExitPlanMode(conn, sessionId, toolUseID, input, supportsTerminalOutput, cwd, onModeChange, isBypassModeAvailable);
|
|
3187
|
+
}
|
|
3188
|
+
if (forceDecision !== undefined) {
|
|
3189
|
+
return forceDecision;
|
|
3190
|
+
}
|
|
3191
|
+
try {
|
|
3192
|
+
const pipelineResult = await hasPermissionsToUseTool(tool, input, context, assistantMessage, toolUseID);
|
|
3193
|
+
if (pipelineResult.behavior === "allow") {
|
|
3194
|
+
return pipelineResult;
|
|
3195
|
+
}
|
|
3196
|
+
if (pipelineResult.behavior === "deny") {
|
|
3197
|
+
return pipelineResult;
|
|
3198
|
+
}
|
|
3199
|
+
} catch (err) {
|
|
3200
|
+
console.error("[ACP Permissions] Pipeline error:", err);
|
|
3201
|
+
return {
|
|
3202
|
+
behavior: "deny",
|
|
3203
|
+
message: "Permission pipeline failed",
|
|
3204
|
+
decisionReason: {
|
|
3205
|
+
type: "other",
|
|
3206
|
+
reason: "Permission pipeline failed"
|
|
3207
|
+
},
|
|
3208
|
+
toolUseID
|
|
3209
|
+
};
|
|
3210
|
+
}
|
|
3211
|
+
const info = toolInfoFromToolUse({ name: tool.name, id: toolUseID, input }, supportsTerminalOutput, cwd);
|
|
3212
|
+
const toolCall = {
|
|
3213
|
+
toolCallId: toolUseID,
|
|
3214
|
+
title: info.title,
|
|
3215
|
+
kind: info.kind,
|
|
3216
|
+
status: "pending",
|
|
3217
|
+
rawInput: input
|
|
3218
|
+
};
|
|
3219
|
+
const options = [
|
|
3220
|
+
{ kind: "allow_always", name: "Always Allow", optionId: "allow_always" },
|
|
3221
|
+
{ kind: "allow_once", name: "Allow", optionId: "allow" },
|
|
3222
|
+
{ kind: "reject_once", name: "Reject", optionId: "reject" }
|
|
3223
|
+
];
|
|
3224
|
+
try {
|
|
3225
|
+
const response = await conn.requestPermission({
|
|
3226
|
+
sessionId,
|
|
3227
|
+
toolCall,
|
|
3228
|
+
options
|
|
3229
|
+
});
|
|
3230
|
+
if (response.outcome.outcome === "cancelled") {
|
|
3231
|
+
return {
|
|
3232
|
+
behavior: "deny",
|
|
3233
|
+
message: "Permission request cancelled by client",
|
|
3234
|
+
decisionReason: { type: "mode", mode: "default" }
|
|
3235
|
+
};
|
|
3236
|
+
}
|
|
3237
|
+
if (response.outcome.outcome === "selected" && "optionId" in response.outcome && response.outcome.optionId !== undefined) {
|
|
3238
|
+
const optionId = response.outcome.optionId;
|
|
3239
|
+
if (optionId === "allow" || optionId === "allow_always") {
|
|
3240
|
+
return {
|
|
3241
|
+
behavior: "allow",
|
|
3242
|
+
updatedInput: input
|
|
3243
|
+
};
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
return {
|
|
3247
|
+
behavior: "deny",
|
|
3248
|
+
message: "Permission denied by client",
|
|
3249
|
+
decisionReason: { type: "mode", mode: "default" }
|
|
3250
|
+
};
|
|
3251
|
+
} catch (err) {
|
|
3252
|
+
console.error("[ACP Permissions] Client request error:", err);
|
|
3253
|
+
return {
|
|
3254
|
+
behavior: "deny",
|
|
3255
|
+
message: "Permission request failed",
|
|
3256
|
+
decisionReason: { type: "mode", mode: "default" }
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
};
|
|
3260
|
+
}
|
|
3261
|
+
async function handleExitPlanMode(conn, sessionId, toolUseID, input, supportsTerminalOutput, cwd, onModeChange, isBypassModeAvailable) {
|
|
3262
|
+
const options = [
|
|
3263
|
+
{ kind: "allow_always", name: 'Yes, and use "auto" mode', optionId: "auto" },
|
|
3264
|
+
{ kind: "allow_always", name: "Yes, and auto-accept edits", optionId: "acceptEdits" },
|
|
3265
|
+
{ kind: "allow_once", name: "Yes, and manually approve edits", optionId: "default" },
|
|
3266
|
+
{ kind: "reject_once", name: "No, keep planning", optionId: "plan" }
|
|
3267
|
+
];
|
|
3268
|
+
if (isBypassModeAvailable?.() === true) {
|
|
3269
|
+
options.unshift({
|
|
3270
|
+
kind: "allow_always",
|
|
3271
|
+
name: "Yes, and bypass permissions",
|
|
3272
|
+
optionId: "bypassPermissions"
|
|
3273
|
+
});
|
|
3274
|
+
}
|
|
3275
|
+
const info = toolInfoFromToolUse({ name: "ExitPlanMode", id: toolUseID, input }, supportsTerminalOutput, cwd);
|
|
3276
|
+
const toolCall = {
|
|
3277
|
+
toolCallId: toolUseID,
|
|
3278
|
+
title: info.title,
|
|
3279
|
+
kind: info.kind,
|
|
3280
|
+
status: "pending",
|
|
3281
|
+
rawInput: input
|
|
3282
|
+
};
|
|
3283
|
+
const response = await conn.requestPermission({
|
|
3284
|
+
sessionId,
|
|
3285
|
+
toolCall,
|
|
3286
|
+
options
|
|
3287
|
+
});
|
|
3288
|
+
if (response.outcome.outcome === "cancelled") {
|
|
3289
|
+
return {
|
|
3290
|
+
behavior: "deny",
|
|
3291
|
+
message: "Tool use aborted",
|
|
3292
|
+
decisionReason: { type: "mode", mode: "default" }
|
|
3293
|
+
};
|
|
3294
|
+
}
|
|
3295
|
+
if (response.outcome.outcome === "selected" && "optionId" in response.outcome && response.outcome.optionId !== undefined) {
|
|
3296
|
+
const selectedOption = response.outcome.optionId;
|
|
3297
|
+
const isOfferedOption = options.some((option) => option.optionId === selectedOption);
|
|
3298
|
+
if (isOfferedOption && (selectedOption === "default" || selectedOption === "acceptEdits" || selectedOption === "auto" || selectedOption === "bypassPermissions")) {
|
|
3299
|
+
onModeChange?.(selectedOption);
|
|
3300
|
+
await conn.sessionUpdate({
|
|
3301
|
+
sessionId,
|
|
3302
|
+
update: {
|
|
3303
|
+
sessionUpdate: "current_mode_update",
|
|
3304
|
+
currentModeId: selectedOption
|
|
3305
|
+
}
|
|
3306
|
+
});
|
|
3307
|
+
return {
|
|
3308
|
+
behavior: "allow",
|
|
3309
|
+
updatedInput: input
|
|
3310
|
+
};
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
return {
|
|
3314
|
+
behavior: "deny",
|
|
3315
|
+
message: "User rejected request to exit plan mode.",
|
|
3316
|
+
decisionReason: { type: "mode", mode: "plan" }
|
|
3317
|
+
};
|
|
3318
|
+
}
|
|
3319
|
+
function checkTerminalOutput(clientCapabilities) {
|
|
3320
|
+
if (!clientCapabilities)
|
|
3321
|
+
return false;
|
|
3322
|
+
const meta = clientCapabilities._meta;
|
|
3323
|
+
if (!meta || typeof meta !== "object")
|
|
3324
|
+
return false;
|
|
3325
|
+
return meta["terminal_output"] === true;
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3328
|
+
// src/services/acp/promptConversion.ts
|
|
3329
|
+
function promptToQueryInput(prompt) {
|
|
3330
|
+
if (!prompt || prompt.length === 0)
|
|
3331
|
+
return "";
|
|
3332
|
+
const parts = [];
|
|
3333
|
+
for (const block of prompt) {
|
|
3334
|
+
const b = block;
|
|
3335
|
+
if (b.type === "text") {
|
|
3336
|
+
parts.push(String(b.text ?? ""));
|
|
3337
|
+
} else if (b.type === "resource_link") {
|
|
3338
|
+
const name = typeof b.name === "string" ? b.name : undefined;
|
|
3339
|
+
const uri = typeof b.uri === "string" ? b.uri : undefined;
|
|
3340
|
+
parts.push(formatResourceLink(name, uri));
|
|
3341
|
+
} else if (b.type === "resource") {
|
|
3342
|
+
const resource = b.resource;
|
|
3343
|
+
if (resource && typeof resource.text === "string") {
|
|
3344
|
+
parts.push(resource.text);
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
return parts.filter((part) => part.length > 0).join(`
|
|
3349
|
+
`);
|
|
3350
|
+
}
|
|
3351
|
+
function formatResourceLink(name, uri) {
|
|
3352
|
+
const details = [];
|
|
3353
|
+
if (name && name.length > 0)
|
|
3354
|
+
details.push(`name=${name}`);
|
|
3355
|
+
if (uri && uri.length > 0)
|
|
3356
|
+
details.push(`uri=${uri}`);
|
|
3357
|
+
return details.length > 0 ? `Resource link: ${details.join(", ")}` : "Resource link";
|
|
3358
|
+
}
|
|
3359
|
+
|
|
3360
|
+
// src/services/acp/agent.ts
|
|
3361
|
+
init_listSessionsImpl();
|
|
3362
|
+
init_model();
|
|
3363
|
+
init_modelOptions();
|
|
3364
|
+
init_settings();
|
|
3365
|
+
|
|
3366
|
+
class AcpAgent {
|
|
3367
|
+
conn;
|
|
3368
|
+
sessions = new Map;
|
|
3369
|
+
clientCapabilities;
|
|
3370
|
+
constructor(conn) {
|
|
3371
|
+
this.conn = conn;
|
|
3372
|
+
}
|
|
3373
|
+
async initialize(params) {
|
|
3374
|
+
this.clientCapabilities = params.clientCapabilities;
|
|
3375
|
+
return {
|
|
3376
|
+
protocolVersion: 1,
|
|
3377
|
+
agentInfo: {
|
|
3378
|
+
name: "claude-code",
|
|
3379
|
+
title: "RedScope AI",
|
|
3380
|
+
version: typeof globalThis.MACRO === "object" && globalThis.MACRO !== null ? String(globalThis.MACRO.VERSION ?? "0.0.0") : "0.0.0"
|
|
3381
|
+
},
|
|
3382
|
+
agentCapabilities: {
|
|
3383
|
+
_meta: {
|
|
3384
|
+
claudeCode: {
|
|
3385
|
+
promptQueueing: true
|
|
3386
|
+
}
|
|
3387
|
+
},
|
|
3388
|
+
promptCapabilities: {
|
|
3389
|
+
image: true,
|
|
3390
|
+
embeddedContext: true
|
|
3391
|
+
},
|
|
3392
|
+
mcpCapabilities: {
|
|
3393
|
+
http: true,
|
|
3394
|
+
sse: true
|
|
3395
|
+
},
|
|
3396
|
+
loadSession: true,
|
|
3397
|
+
sessionCapabilities: {
|
|
3398
|
+
fork: {},
|
|
3399
|
+
list: {},
|
|
3400
|
+
resume: {},
|
|
3401
|
+
close: {}
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
};
|
|
3405
|
+
}
|
|
3406
|
+
async authenticate(_params) {
|
|
3407
|
+
return {};
|
|
3408
|
+
}
|
|
3409
|
+
async newSession(params) {
|
|
3410
|
+
const result = await this.createSession(params);
|
|
3411
|
+
this.scheduleAvailableCommandsUpdate(result.sessionId);
|
|
3412
|
+
return result;
|
|
3413
|
+
}
|
|
3414
|
+
async unstable_resumeSession(params) {
|
|
3415
|
+
const result = await this.getOrCreateSession(params);
|
|
3416
|
+
this.scheduleAvailableCommandsUpdate(result.sessionId);
|
|
3417
|
+
return result;
|
|
3418
|
+
}
|
|
3419
|
+
async loadSession(params) {
|
|
3420
|
+
const result = await this.getOrCreateSession(params);
|
|
3421
|
+
this.scheduleAvailableCommandsUpdate(result.sessionId);
|
|
3422
|
+
return result;
|
|
3423
|
+
}
|
|
3424
|
+
async listSessions(params) {
|
|
3425
|
+
const candidates = await listSessionsImpl({
|
|
3426
|
+
dir: params.cwd ?? undefined,
|
|
3427
|
+
limit: 100
|
|
3428
|
+
});
|
|
3429
|
+
const sessions = [];
|
|
3430
|
+
for (const candidate of candidates) {
|
|
3431
|
+
if (!candidate.cwd)
|
|
3432
|
+
continue;
|
|
3433
|
+
sessions.push({
|
|
3434
|
+
sessionId: candidate.sessionId,
|
|
3435
|
+
cwd: candidate.cwd,
|
|
3436
|
+
title: sanitizeTitle(candidate.summary ?? ""),
|
|
3437
|
+
updatedAt: new Date(candidate.lastModified).toISOString()
|
|
3438
|
+
});
|
|
3439
|
+
}
|
|
3440
|
+
return { sessions };
|
|
3441
|
+
}
|
|
3442
|
+
async unstable_forkSession(params) {
|
|
3443
|
+
const response = await this.createSession({
|
|
3444
|
+
cwd: params.cwd,
|
|
3445
|
+
mcpServers: params.mcpServers ?? [],
|
|
3446
|
+
_meta: params._meta
|
|
3447
|
+
});
|
|
3448
|
+
this.scheduleAvailableCommandsUpdate(response.sessionId);
|
|
3449
|
+
return response;
|
|
3450
|
+
}
|
|
3451
|
+
async unstable_closeSession(params) {
|
|
3452
|
+
const session = this.sessions.get(params.sessionId);
|
|
3453
|
+
if (!session) {
|
|
3454
|
+
throw new Error("Session not found");
|
|
3455
|
+
}
|
|
3456
|
+
await this.teardownSession(params.sessionId);
|
|
3457
|
+
return {};
|
|
3458
|
+
}
|
|
3459
|
+
async prompt(params) {
|
|
3460
|
+
const session = this.sessions.get(params.sessionId);
|
|
3461
|
+
if (!session) {
|
|
3462
|
+
throw new Error(`Session ${params.sessionId} not found`);
|
|
3463
|
+
}
|
|
3464
|
+
const promptInput = promptToQueryInput(params.prompt);
|
|
3465
|
+
if (!promptInput.trim()) {
|
|
3466
|
+
return { stopReason: "end_turn" };
|
|
3467
|
+
}
|
|
3468
|
+
const promptCancelGeneration = session.cancelGeneration;
|
|
3469
|
+
if (session.promptRunning) {
|
|
3470
|
+
const promptUuid = randomUUID();
|
|
3471
|
+
const cancelled = await new Promise((resolve2) => {
|
|
3472
|
+
session.pendingQueue.push(promptUuid);
|
|
3473
|
+
session.pendingMessages.set(promptUuid, { resolve: resolve2 });
|
|
3474
|
+
});
|
|
3475
|
+
if (cancelled) {
|
|
3476
|
+
return { stopReason: "cancelled" };
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
if (session.cancelGeneration !== promptCancelGeneration) {
|
|
3480
|
+
return { stopReason: "cancelled" };
|
|
3481
|
+
}
|
|
3482
|
+
session.cancelled = false;
|
|
3483
|
+
session.promptRunning = true;
|
|
3484
|
+
try {
|
|
3485
|
+
session.queryEngine.resetAbortController();
|
|
3486
|
+
const sdkMessages = session.queryEngine.submitMessage(promptInput);
|
|
3487
|
+
const { stopReason, usage } = await forwardSessionUpdates(params.sessionId, sdkMessages, this.conn, session.queryEngine.getAbortSignal(), session.toolUseCache, this.clientCapabilities, session.cwd, () => session.cancelled);
|
|
3488
|
+
if (session.cancelled) {
|
|
3489
|
+
return { stopReason: "cancelled" };
|
|
3490
|
+
}
|
|
3491
|
+
return {
|
|
3492
|
+
stopReason,
|
|
3493
|
+
usage: usage ? {
|
|
3494
|
+
inputTokens: usage.inputTokens,
|
|
3495
|
+
outputTokens: usage.outputTokens,
|
|
3496
|
+
cachedReadTokens: usage.cachedReadTokens,
|
|
3497
|
+
cachedWriteTokens: usage.cachedWriteTokens,
|
|
3498
|
+
totalTokens: usage.inputTokens + usage.outputTokens + usage.cachedReadTokens + usage.cachedWriteTokens
|
|
3499
|
+
} : undefined
|
|
3500
|
+
};
|
|
3501
|
+
} catch (err) {
|
|
3502
|
+
if (session.cancelled) {
|
|
3503
|
+
return { stopReason: "cancelled" };
|
|
3504
|
+
}
|
|
3505
|
+
if (err instanceof Error && (err.message.includes("terminated") || err.message.includes("process exited"))) {
|
|
3506
|
+
this.teardownSession(params.sessionId);
|
|
3507
|
+
throw new Error("The Claude Agent process exited unexpectedly. Please start a new session.");
|
|
3508
|
+
}
|
|
3509
|
+
throw err;
|
|
3510
|
+
} finally {
|
|
3511
|
+
const nextPrompt = popNextPendingPrompt(session);
|
|
3512
|
+
if (nextPrompt) {
|
|
3513
|
+
session.promptRunning = true;
|
|
3514
|
+
nextPrompt.resolve(false);
|
|
3515
|
+
} else {
|
|
3516
|
+
session.promptRunning = false;
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
async cancel(params) {
|
|
3521
|
+
const session = this.sessions.get(params.sessionId);
|
|
3522
|
+
if (!session)
|
|
3523
|
+
return;
|
|
3524
|
+
session.cancelled = true;
|
|
3525
|
+
session.cancelGeneration += 1;
|
|
3526
|
+
for (const [, pending] of session.pendingMessages) {
|
|
3527
|
+
pending.resolve(true);
|
|
3528
|
+
}
|
|
3529
|
+
session.pendingMessages.clear();
|
|
3530
|
+
session.pendingQueue = [];
|
|
3531
|
+
session.pendingQueueHead = 0;
|
|
3532
|
+
session.queryEngine.interrupt();
|
|
3533
|
+
}
|
|
3534
|
+
async setSessionMode(params) {
|
|
3535
|
+
const session = this.sessions.get(params.sessionId);
|
|
3536
|
+
if (!session) {
|
|
3537
|
+
throw new Error("Session not found");
|
|
3538
|
+
}
|
|
3539
|
+
this.applySessionMode(params.sessionId, params.modeId);
|
|
3540
|
+
await this.updateConfigOption(params.sessionId, "mode", params.modeId);
|
|
3541
|
+
return {};
|
|
3542
|
+
}
|
|
3543
|
+
async unstable_setSessionModel(params) {
|
|
3544
|
+
const session = this.sessions.get(params.sessionId);
|
|
3545
|
+
if (!session) {
|
|
3546
|
+
throw new Error("Session not found");
|
|
3547
|
+
}
|
|
3548
|
+
session.queryEngine.setModel(params.modelId);
|
|
3549
|
+
await this.updateConfigOption(params.sessionId, "model", params.modelId);
|
|
3550
|
+
return {};
|
|
3551
|
+
}
|
|
3552
|
+
async setSessionConfigOption(params) {
|
|
3553
|
+
const session = this.sessions.get(params.sessionId);
|
|
3554
|
+
if (!session) {
|
|
3555
|
+
throw new Error("Session not found");
|
|
3556
|
+
}
|
|
3557
|
+
if (typeof params.value !== "string") {
|
|
3558
|
+
throw new Error(`Invalid value for config option ${params.configId}: ${String(params.value)}`);
|
|
3559
|
+
}
|
|
3560
|
+
const option = session.configOptions.find((o) => o.id === params.configId);
|
|
3561
|
+
if (!option) {
|
|
3562
|
+
throw new Error(`Unknown config option: ${params.configId}`);
|
|
3563
|
+
}
|
|
3564
|
+
const value = params.value;
|
|
3565
|
+
if (params.configId === "mode") {
|
|
3566
|
+
this.applySessionMode(params.sessionId, value);
|
|
3567
|
+
await this.conn.sessionUpdate({
|
|
3568
|
+
sessionId: params.sessionId,
|
|
3569
|
+
update: {
|
|
3570
|
+
sessionUpdate: "current_mode_update",
|
|
3571
|
+
currentModeId: value
|
|
3572
|
+
}
|
|
3573
|
+
});
|
|
3574
|
+
} else if (params.configId === "model") {
|
|
3575
|
+
session.queryEngine.setModel(value);
|
|
3576
|
+
}
|
|
3577
|
+
this.syncSessionConfigState(session, params.configId, value);
|
|
3578
|
+
session.configOptions = session.configOptions.map((o) => o.id === params.configId && typeof o.currentValue === "string" ? { ...o, currentValue: value } : o);
|
|
3579
|
+
return { configOptions: session.configOptions };
|
|
3580
|
+
}
|
|
3581
|
+
async createSession(params, opts = {}) {
|
|
3582
|
+
enableConfigs();
|
|
3583
|
+
const sessionId = opts.sessionId ?? randomUUID();
|
|
3584
|
+
const cwd = params.cwd;
|
|
3585
|
+
setOriginalCwd(cwd);
|
|
3586
|
+
const previousProcessCwd = process.cwd();
|
|
3587
|
+
let processCwdChanged = false;
|
|
3588
|
+
try {
|
|
3589
|
+
process.chdir(cwd);
|
|
3590
|
+
processCwdChanged = true;
|
|
3591
|
+
} catch {}
|
|
3592
|
+
try {
|
|
3593
|
+
const permissionContext = getEmptyToolPermissionContext();
|
|
3594
|
+
const tools = getTools(permissionContext);
|
|
3595
|
+
const meta = params._meta;
|
|
3596
|
+
const hasMetaPermissionMode = hasOwnField(meta, "permissionMode");
|
|
3597
|
+
const metaPermissionMode = hasMetaPermissionMode ? meta?.permissionMode : undefined;
|
|
3598
|
+
const settingsPermissionMode = this.getSetting("permissions.defaultMode");
|
|
3599
|
+
const permissionMode = resolveSessionPermissionMode(metaPermissionMode, hasMetaPermissionMode, settingsPermissionMode);
|
|
3600
|
+
const canUseTool = createAcpCanUseTool(this.conn, sessionId, () => this.sessions.get(sessionId)?.modes.currentModeId ?? "default", this.clientCapabilities, cwd, (modeId) => {
|
|
3601
|
+
this.applySessionMode(sessionId, modeId);
|
|
3602
|
+
}, () => this.sessions.get(sessionId)?.appState.toolPermissionContext.isBypassPermissionsModeAvailable ?? false);
|
|
3603
|
+
const isBypassAvailable = isAcpBypassPermissionModeAvailable(settingsPermissionMode);
|
|
3604
|
+
const appState = {
|
|
3605
|
+
...getDefaultAppState(),
|
|
3606
|
+
toolPermissionContext: {
|
|
3607
|
+
...permissionContext,
|
|
3608
|
+
mode: permissionMode,
|
|
3609
|
+
isBypassPermissionsModeAvailable: isBypassAvailable
|
|
3610
|
+
}
|
|
3611
|
+
};
|
|
3612
|
+
const commands = await getCommands(cwd);
|
|
3613
|
+
const engineConfig = {
|
|
3614
|
+
cwd,
|
|
3615
|
+
tools,
|
|
3616
|
+
commands,
|
|
3617
|
+
mcpClients: [],
|
|
3618
|
+
agents: [],
|
|
3619
|
+
canUseTool,
|
|
3620
|
+
getAppState: () => appState,
|
|
3621
|
+
setAppState: (updater) => {
|
|
3622
|
+
const updated = updater(appState);
|
|
3623
|
+
Object.assign(appState, updated);
|
|
3624
|
+
},
|
|
3625
|
+
readFileCache: new FileStateCache(500, 50 * 1024 * 1024),
|
|
3626
|
+
includePartialMessages: true,
|
|
3627
|
+
replayUserMessages: true,
|
|
3628
|
+
initialMessages: opts.initialMessages
|
|
3629
|
+
};
|
|
3630
|
+
const queryEngine = new QueryEngine(engineConfig);
|
|
3631
|
+
const availableModes = [
|
|
3632
|
+
{ id: "default", name: "Default", description: "Standard behavior, prompts for dangerous operations" },
|
|
3633
|
+
{ id: "acceptEdits", name: "Accept Edits", description: "Auto-accept file edit operations" },
|
|
3634
|
+
{ id: "plan", name: "Plan Mode", description: "Planning mode, no actual tool execution" },
|
|
3635
|
+
{ id: "auto", name: "Auto", description: "Use a model classifier to approve/deny permission prompts." },
|
|
3636
|
+
...isBypassAvailable ? [{ id: "bypassPermissions", name: "Bypass Permissions", description: "Skip all permission checks" }] : [],
|
|
3637
|
+
{ id: "dontAsk", name: "Don't Ask", description: "Don't prompt for permissions, deny if not pre-approved" }
|
|
3638
|
+
];
|
|
3639
|
+
const modes = {
|
|
3640
|
+
currentModeId: permissionMode,
|
|
3641
|
+
availableModes
|
|
3642
|
+
};
|
|
3643
|
+
const modelOptions = getModelOptions();
|
|
3644
|
+
const currentModel = getMainLoopModel();
|
|
3645
|
+
const models = {
|
|
3646
|
+
availableModels: modelOptions.map((m) => ({
|
|
3647
|
+
modelId: String(m.value ?? ""),
|
|
3648
|
+
name: m.label ?? String(m.value ?? ""),
|
|
3649
|
+
description: m.description ?? undefined
|
|
3650
|
+
})),
|
|
3651
|
+
currentModelId: currentModel
|
|
3652
|
+
};
|
|
3653
|
+
queryEngine.setModel(currentModel);
|
|
3654
|
+
const configOptions = buildConfigOptions(modes, models);
|
|
3655
|
+
const session = {
|
|
3656
|
+
queryEngine,
|
|
3657
|
+
cancelled: false,
|
|
3658
|
+
cancelGeneration: 0,
|
|
3659
|
+
cwd,
|
|
3660
|
+
modes,
|
|
3661
|
+
models,
|
|
3662
|
+
configOptions,
|
|
3663
|
+
promptRunning: false,
|
|
3664
|
+
pendingMessages: new Map,
|
|
3665
|
+
pendingQueue: [],
|
|
3666
|
+
pendingQueueHead: 0,
|
|
3667
|
+
toolUseCache: {},
|
|
3668
|
+
clientCapabilities: this.clientCapabilities,
|
|
3669
|
+
appState,
|
|
3670
|
+
commands,
|
|
3671
|
+
sessionFingerprint: computeSessionFingerprint({
|
|
3672
|
+
cwd,
|
|
3673
|
+
mcpServers: params.mcpServers
|
|
3674
|
+
})
|
|
3675
|
+
};
|
|
3676
|
+
this.sessions.set(sessionId, session);
|
|
3677
|
+
return {
|
|
3678
|
+
sessionId,
|
|
3679
|
+
models,
|
|
3680
|
+
modes,
|
|
3681
|
+
configOptions
|
|
3682
|
+
};
|
|
3683
|
+
} finally {
|
|
3684
|
+
if (processCwdChanged) {
|
|
3685
|
+
process.chdir(previousProcessCwd);
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
async getOrCreateSession(params) {
|
|
3690
|
+
const existingSession = this.sessions.get(params.sessionId);
|
|
3691
|
+
if (existingSession) {
|
|
3692
|
+
const fingerprint = computeSessionFingerprint({
|
|
3693
|
+
cwd: params.cwd,
|
|
3694
|
+
mcpServers: params.mcpServers
|
|
3695
|
+
});
|
|
3696
|
+
if (fingerprint === existingSession.sessionFingerprint) {
|
|
3697
|
+
return {
|
|
3698
|
+
sessionId: params.sessionId,
|
|
3699
|
+
modes: existingSession.modes,
|
|
3700
|
+
models: existingSession.models,
|
|
3701
|
+
configOptions: existingSession.configOptions
|
|
3702
|
+
};
|
|
3703
|
+
}
|
|
3704
|
+
await this.teardownSession(params.sessionId);
|
|
3705
|
+
}
|
|
3706
|
+
setOriginalCwd(params.cwd);
|
|
3707
|
+
let initialMessages;
|
|
3708
|
+
if (sessionIdExists(params.sessionId)) {
|
|
3709
|
+
try {
|
|
3710
|
+
const log = await getLastSessionLog(params.sessionId);
|
|
3711
|
+
if (log && log.messages.length > 0) {
|
|
3712
|
+
initialMessages = deserializeMessages(log.messages);
|
|
3713
|
+
}
|
|
3714
|
+
} catch (err) {
|
|
3715
|
+
console.error("[ACP] Failed to load session history:", err);
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
const response = await this.createSession({
|
|
3719
|
+
cwd: params.cwd,
|
|
3720
|
+
mcpServers: params.mcpServers ?? [],
|
|
3721
|
+
_meta: params._meta
|
|
3722
|
+
}, { sessionId: params.sessionId, initialMessages });
|
|
3723
|
+
if (initialMessages && initialMessages.length > 0) {
|
|
3724
|
+
const session = this.sessions.get(params.sessionId);
|
|
3725
|
+
if (session) {
|
|
3726
|
+
await replayHistoryMessages(params.sessionId, initialMessages, this.conn, session.toolUseCache, this.clientCapabilities, session.cwd);
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
return {
|
|
3730
|
+
sessionId: response.sessionId,
|
|
3731
|
+
modes: response.modes,
|
|
3732
|
+
models: response.models,
|
|
3733
|
+
configOptions: response.configOptions
|
|
3734
|
+
};
|
|
3735
|
+
}
|
|
3736
|
+
async teardownSession(sessionId) {
|
|
3737
|
+
const session = this.sessions.get(sessionId);
|
|
3738
|
+
if (!session)
|
|
3739
|
+
return;
|
|
3740
|
+
await this.cancel({ sessionId });
|
|
3741
|
+
this.sessions.delete(sessionId);
|
|
3742
|
+
}
|
|
3743
|
+
applySessionMode(sessionId, modeId) {
|
|
3744
|
+
if (!isPermissionMode(modeId)) {
|
|
3745
|
+
throw new Error(`Invalid mode: ${modeId}`);
|
|
3746
|
+
}
|
|
3747
|
+
const session = this.sessions.get(sessionId);
|
|
3748
|
+
if (session) {
|
|
3749
|
+
if (modeId === "bypassPermissions" && !session.appState.toolPermissionContext.isBypassPermissionsModeAvailable) {
|
|
3750
|
+
throw new Error(`Mode not available: ${modeId}`);
|
|
3751
|
+
}
|
|
3752
|
+
const isAvailable = session.modes.availableModes.some((mode) => mode.id === modeId);
|
|
3753
|
+
if (!isAvailable) {
|
|
3754
|
+
throw new Error(`Mode not available: ${modeId}`);
|
|
3755
|
+
}
|
|
3756
|
+
session.modes = { ...session.modes, currentModeId: modeId };
|
|
3757
|
+
session.appState.toolPermissionContext = {
|
|
3758
|
+
...session.appState.toolPermissionContext,
|
|
3759
|
+
mode: modeId
|
|
3760
|
+
};
|
|
3761
|
+
}
|
|
3762
|
+
}
|
|
3763
|
+
async updateConfigOption(sessionId, configId, value) {
|
|
3764
|
+
const session = this.sessions.get(sessionId);
|
|
3765
|
+
if (!session)
|
|
3766
|
+
return;
|
|
3767
|
+
this.syncSessionConfigState(session, configId, value);
|
|
3768
|
+
session.configOptions = session.configOptions.map((o) => o.id === configId && typeof o.currentValue === "string" ? { ...o, currentValue: value } : o);
|
|
3769
|
+
await this.conn.sessionUpdate({
|
|
3770
|
+
sessionId,
|
|
3771
|
+
update: {
|
|
3772
|
+
sessionUpdate: "config_option_update",
|
|
3773
|
+
configOptions: session.configOptions
|
|
3774
|
+
}
|
|
3775
|
+
});
|
|
3776
|
+
}
|
|
3777
|
+
syncSessionConfigState(session, configId, value) {
|
|
3778
|
+
if (configId === "mode") {
|
|
3779
|
+
session.modes = { ...session.modes, currentModeId: value };
|
|
3780
|
+
} else if (configId === "model") {
|
|
3781
|
+
session.models = { ...session.models, currentModelId: value };
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
async sendAvailableCommandsUpdate(sessionId) {
|
|
3785
|
+
const session = this.sessions.get(sessionId);
|
|
3786
|
+
if (!session)
|
|
3787
|
+
return;
|
|
3788
|
+
const availableCommands = session.commands.filter((cmd) => cmd.type === "prompt" && !cmd.isHidden && cmd.userInvocable !== false).map((cmd) => ({
|
|
3789
|
+
name: cmd.name,
|
|
3790
|
+
description: cmd.description,
|
|
3791
|
+
input: cmd.argumentHint ? { hint: cmd.argumentHint } : undefined
|
|
3792
|
+
}));
|
|
3793
|
+
await this.conn.sessionUpdate({
|
|
3794
|
+
sessionId,
|
|
3795
|
+
update: {
|
|
3796
|
+
sessionUpdate: "available_commands_update",
|
|
3797
|
+
availableCommands
|
|
3798
|
+
}
|
|
3799
|
+
});
|
|
3800
|
+
}
|
|
3801
|
+
scheduleAvailableCommandsUpdate(sessionId) {
|
|
3802
|
+
setTimeout(() => {
|
|
3803
|
+
this.sendAvailableCommandsUpdate(sessionId).catch((err) => {
|
|
3804
|
+
console.error("[ACP] Failed to send available commands update:", err);
|
|
3805
|
+
});
|
|
3806
|
+
}, 0);
|
|
3807
|
+
}
|
|
3808
|
+
getSetting(key) {
|
|
3809
|
+
const settings = getSettings_DEPRECATED();
|
|
3810
|
+
const value = key.split(".").reduce((current, segment) => {
|
|
3811
|
+
if (!current || typeof current !== "object")
|
|
3812
|
+
return;
|
|
3813
|
+
return current[segment];
|
|
3814
|
+
}, settings);
|
|
3815
|
+
return value;
|
|
3816
|
+
}
|
|
3817
|
+
}
|
|
3818
|
+
var permissionModeIds = [
|
|
3819
|
+
"auto",
|
|
3820
|
+
"default",
|
|
3821
|
+
"acceptEdits",
|
|
3822
|
+
"bypassPermissions",
|
|
3823
|
+
"dontAsk",
|
|
3824
|
+
"plan"
|
|
3825
|
+
];
|
|
3826
|
+
function isPermissionMode(modeId) {
|
|
3827
|
+
return permissionModeIds.includes(modeId);
|
|
3828
|
+
}
|
|
3829
|
+
function resolveSessionPermissionMode(metaMode, hasMetaMode, settingsMode) {
|
|
3830
|
+
if (hasMetaMode) {
|
|
3831
|
+
const metaResolved = resolveRequiredPermissionMode(metaMode, "_meta.permissionMode");
|
|
3832
|
+
if (metaResolved === "bypassPermissions" && !isAcpBypassPermissionModeAvailable(settingsMode)) {
|
|
3833
|
+
throw new Error("Mode not available: bypassPermissions requires a local ACP bypass opt-in.");
|
|
3834
|
+
}
|
|
3835
|
+
return metaResolved;
|
|
3836
|
+
}
|
|
3837
|
+
const settingsResolved = resolveConfiguredPermissionMode(settingsMode);
|
|
3838
|
+
return settingsResolved ?? "default";
|
|
3839
|
+
}
|
|
3840
|
+
function resolveRequiredPermissionMode(mode, source) {
|
|
3841
|
+
if (mode === undefined || mode === null) {
|
|
3842
|
+
throw new Error(`Invalid ${source}: expected a string.`);
|
|
3843
|
+
}
|
|
3844
|
+
return resolvePermissionMode(mode, source);
|
|
3845
|
+
}
|
|
3846
|
+
function resolveConfiguredPermissionMode(mode) {
|
|
3847
|
+
if (mode === undefined || mode === null)
|
|
3848
|
+
return;
|
|
3849
|
+
try {
|
|
3850
|
+
return resolvePermissionMode(mode, "permissions.defaultMode");
|
|
3851
|
+
} catch (err) {
|
|
3852
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
3853
|
+
console.error("[ACP] Invalid permissions.defaultMode, using default:", reason);
|
|
3854
|
+
return;
|
|
3855
|
+
}
|
|
3856
|
+
}
|
|
3857
|
+
function hasOwnField(value, key) {
|
|
3858
|
+
return !!value && Object.hasOwn(value, key);
|
|
3859
|
+
}
|
|
3860
|
+
function isAcpBypassPermissionModeAvailable(settingsMode) {
|
|
3861
|
+
return isProcessBypassPermissionModeAvailable() && (isAcpBypassLocallyEnabled() || isSettingsBypassPermissionMode(settingsMode));
|
|
3862
|
+
}
|
|
3863
|
+
function isProcessBypassPermissionModeAvailable() {
|
|
3864
|
+
if (process.env.IS_SANDBOX)
|
|
3865
|
+
return true;
|
|
3866
|
+
if (typeof process.geteuid === "function")
|
|
3867
|
+
return process.geteuid() !== 0;
|
|
3868
|
+
if (typeof process.getuid === "function")
|
|
3869
|
+
return process.getuid() !== 0;
|
|
3870
|
+
return true;
|
|
3871
|
+
}
|
|
3872
|
+
function isAcpBypassLocallyEnabled() {
|
|
3873
|
+
return process.env.ACP_PERMISSION_MODE === "bypassPermissions" || isTruthyEnv(process.env.CLAUDE_CODE_ACP_ALLOW_BYPASS_PERMISSIONS);
|
|
3874
|
+
}
|
|
3875
|
+
function isSettingsBypassPermissionMode(settingsMode) {
|
|
3876
|
+
try {
|
|
3877
|
+
return resolvePermissionMode(settingsMode) === "bypassPermissions";
|
|
3878
|
+
} catch {
|
|
3879
|
+
return false;
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
function isTruthyEnv(value) {
|
|
3883
|
+
return value === "1" || value?.toLowerCase() === "true";
|
|
3884
|
+
}
|
|
3885
|
+
function popNextPendingPrompt(session) {
|
|
3886
|
+
while (session.pendingQueueHead < session.pendingQueue.length) {
|
|
3887
|
+
const nextId = session.pendingQueue[session.pendingQueueHead++];
|
|
3888
|
+
if (!nextId)
|
|
3889
|
+
continue;
|
|
3890
|
+
const next = session.pendingMessages.get(nextId);
|
|
3891
|
+
if (!next)
|
|
3892
|
+
continue;
|
|
3893
|
+
session.pendingMessages.delete(nextId);
|
|
3894
|
+
compactPendingQueue(session);
|
|
3895
|
+
return next;
|
|
3896
|
+
}
|
|
3897
|
+
compactPendingQueue(session);
|
|
3898
|
+
return;
|
|
3899
|
+
}
|
|
3900
|
+
function compactPendingQueue(session) {
|
|
3901
|
+
if (session.pendingQueueHead === 0)
|
|
3902
|
+
return;
|
|
3903
|
+
if (session.pendingQueueHead >= session.pendingQueue.length) {
|
|
3904
|
+
session.pendingQueue = [];
|
|
3905
|
+
session.pendingQueueHead = 0;
|
|
3906
|
+
return;
|
|
3907
|
+
}
|
|
3908
|
+
if (session.pendingQueueHead > 1024 && session.pendingQueueHead * 2 > session.pendingQueue.length) {
|
|
3909
|
+
session.pendingQueue = session.pendingQueue.slice(session.pendingQueueHead);
|
|
3910
|
+
session.pendingQueueHead = 0;
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
function buildConfigOptions(modes, models) {
|
|
3914
|
+
return [
|
|
3915
|
+
{
|
|
3916
|
+
id: "mode",
|
|
3917
|
+
name: "Mode",
|
|
3918
|
+
description: "Session permission mode",
|
|
3919
|
+
category: "mode",
|
|
3920
|
+
type: "select",
|
|
3921
|
+
currentValue: modes.currentModeId,
|
|
3922
|
+
options: modes.availableModes.map((m) => ({
|
|
3923
|
+
value: m.id,
|
|
3924
|
+
name: m.name,
|
|
3925
|
+
description: m.description
|
|
3926
|
+
}))
|
|
3927
|
+
},
|
|
3928
|
+
{
|
|
3929
|
+
id: "model",
|
|
3930
|
+
name: "Model",
|
|
3931
|
+
description: "AI model to use",
|
|
3932
|
+
category: "model",
|
|
3933
|
+
type: "select",
|
|
3934
|
+
currentValue: models.currentModelId,
|
|
3935
|
+
options: models.availableModels.map((m) => ({
|
|
3936
|
+
value: m.modelId,
|
|
3937
|
+
name: m.name,
|
|
3938
|
+
description: m.description ?? undefined
|
|
3939
|
+
}))
|
|
3940
|
+
}
|
|
3941
|
+
];
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
// src/services/acp/entry.ts
|
|
3945
|
+
init_config();
|
|
3946
|
+
init_managedEnv();
|
|
3947
|
+
function createAcpStream(nodeReadable, nodeWritable) {
|
|
3948
|
+
const readableFromClient = Readable.toWeb(nodeReadable);
|
|
3949
|
+
const writableToClient = Writable.toWeb(nodeWritable);
|
|
3950
|
+
return ndJsonStream(writableToClient, readableFromClient);
|
|
3951
|
+
}
|
|
3952
|
+
async function runAcpAgent() {
|
|
3953
|
+
enableConfigs();
|
|
3954
|
+
applySafeConfigEnvironmentVariables();
|
|
3955
|
+
const stream2 = createAcpStream(process.stdin, process.stdout);
|
|
3956
|
+
let agent;
|
|
3957
|
+
const connection = new AgentSideConnection((conn) => {
|
|
3958
|
+
agent = new AcpAgent(conn);
|
|
3959
|
+
return agent;
|
|
3960
|
+
}, stream2);
|
|
3961
|
+
console.log = console.error;
|
|
3962
|
+
console.info = console.error;
|
|
3963
|
+
console.warn = console.error;
|
|
3964
|
+
console.debug = console.error;
|
|
3965
|
+
async function shutdown() {
|
|
3966
|
+
for (const [sessionId] of agent.sessions) {
|
|
3967
|
+
try {
|
|
3968
|
+
await agent.unstable_closeSession({ sessionId });
|
|
3969
|
+
} catch {}
|
|
3970
|
+
}
|
|
3971
|
+
process.exit(0);
|
|
3972
|
+
}
|
|
3973
|
+
connection.closed.then(shutdown).catch(shutdown);
|
|
3974
|
+
process.on("SIGTERM", shutdown);
|
|
3975
|
+
process.on("SIGINT", shutdown);
|
|
3976
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
3977
|
+
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
3978
|
+
});
|
|
3979
|
+
process.stdin.resume();
|
|
3980
|
+
}
|
|
3981
|
+
export {
|
|
3982
|
+
runAcpAgent,
|
|
3983
|
+
createAcpStream
|
|
3984
|
+
};
|