@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,2007 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
CCR_SESSION_INGRESS_TOKEN_PATH,
|
|
4
|
+
init_authFileDescriptor,
|
|
5
|
+
maybePersistTokenForSubprocesses,
|
|
6
|
+
readTokenFromWellKnownFile
|
|
7
|
+
} from "./chunk-eemjb825.js";
|
|
8
|
+
import {
|
|
9
|
+
init_diagLogs,
|
|
10
|
+
logForDiagnosticsNoPII
|
|
11
|
+
} from "./chunk-10k5jfc5.js";
|
|
12
|
+
import {
|
|
13
|
+
errorMessage,
|
|
14
|
+
getCompatibleUserConfigFile,
|
|
15
|
+
getFsImplementation,
|
|
16
|
+
init_cleanupRegistry,
|
|
17
|
+
init_debug,
|
|
18
|
+
init_envUtils,
|
|
19
|
+
init_errors,
|
|
20
|
+
init_fsOperations,
|
|
21
|
+
init_redscopeCompat,
|
|
22
|
+
isEnvTruthy,
|
|
23
|
+
logForDebugging,
|
|
24
|
+
registerCleanup
|
|
25
|
+
} from "./chunk-s3hafnk3.js";
|
|
26
|
+
import {
|
|
27
|
+
getIsNonInteractiveSession,
|
|
28
|
+
getSessionId,
|
|
29
|
+
getSessionIngressToken,
|
|
30
|
+
init_state,
|
|
31
|
+
setSessionIngressToken
|
|
32
|
+
} from "./chunk-9h9k5vz3.js";
|
|
33
|
+
import {
|
|
34
|
+
__esm,
|
|
35
|
+
__export
|
|
36
|
+
} from "./chunk-hhsxm2yr.js";
|
|
37
|
+
|
|
38
|
+
// packages/@ant/model-provider/src/types/usage.ts
|
|
39
|
+
var EMPTY_USAGE;
|
|
40
|
+
var init_usage = __esm(() => {
|
|
41
|
+
EMPTY_USAGE = {
|
|
42
|
+
input_tokens: 0,
|
|
43
|
+
cache_creation_input_tokens: 0,
|
|
44
|
+
cache_read_input_tokens: 0,
|
|
45
|
+
output_tokens: 0,
|
|
46
|
+
server_tool_use: { web_search_requests: 0, web_fetch_requests: 0 },
|
|
47
|
+
service_tier: "standard",
|
|
48
|
+
cache_creation: {
|
|
49
|
+
ephemeral_1h_input_tokens: 0,
|
|
50
|
+
ephemeral_5m_input_tokens: 0
|
|
51
|
+
},
|
|
52
|
+
inference_geo: "",
|
|
53
|
+
iterations: [],
|
|
54
|
+
speed: "standard"
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// packages/@ant/model-provider/src/types/systemPrompt.ts
|
|
59
|
+
function asSystemPrompt(value) {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
var init_systemPrompt = () => {};
|
|
63
|
+
|
|
64
|
+
// packages/@ant/model-provider/src/providers/openai/modelMapping.ts
|
|
65
|
+
function getModelFamily(model) {
|
|
66
|
+
if (/haiku/i.test(model))
|
|
67
|
+
return "haiku";
|
|
68
|
+
if (/opus/i.test(model))
|
|
69
|
+
return "opus";
|
|
70
|
+
if (/sonnet/i.test(model))
|
|
71
|
+
return "sonnet";
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function resolveOpenAIModel(anthropicModel) {
|
|
75
|
+
if (process.env.OPENAI_MODEL) {
|
|
76
|
+
return process.env.OPENAI_MODEL;
|
|
77
|
+
}
|
|
78
|
+
if (process.env.REDSCOPE_MODEL) {
|
|
79
|
+
return process.env.REDSCOPE_MODEL;
|
|
80
|
+
}
|
|
81
|
+
const cleanModel = anthropicModel.replace(/\[1m\]$/, "");
|
|
82
|
+
const family = getModelFamily(cleanModel);
|
|
83
|
+
if (family) {
|
|
84
|
+
const openaiEnvVar = `OPENAI_DEFAULT_${family.toUpperCase()}_MODEL`;
|
|
85
|
+
const openaiOverride = process.env[openaiEnvVar];
|
|
86
|
+
if (openaiOverride)
|
|
87
|
+
return openaiOverride;
|
|
88
|
+
const redscopeEnvVar = `REDSCOPE_DEFAULT_${family.toUpperCase()}_MODEL`;
|
|
89
|
+
const redscopeOverride = process.env[redscopeEnvVar];
|
|
90
|
+
if (redscopeOverride)
|
|
91
|
+
return redscopeOverride;
|
|
92
|
+
const anthropicEnvVar = `ANTHROPIC_DEFAULT_${family.toUpperCase()}_MODEL`;
|
|
93
|
+
const anthropicOverride = process.env[anthropicEnvVar];
|
|
94
|
+
if (anthropicOverride)
|
|
95
|
+
return anthropicOverride;
|
|
96
|
+
}
|
|
97
|
+
return DEFAULT_MODEL_MAP[cleanModel] ?? cleanModel;
|
|
98
|
+
}
|
|
99
|
+
var DEFAULT_MODEL_MAP;
|
|
100
|
+
var init_modelMapping = __esm(() => {
|
|
101
|
+
DEFAULT_MODEL_MAP = {
|
|
102
|
+
"claude-sonnet-4-20250514": "gpt-4o",
|
|
103
|
+
"claude-sonnet-4-5-20250929": "gpt-4o",
|
|
104
|
+
"claude-sonnet-4-6": "gpt-4o",
|
|
105
|
+
"claude-opus-4-20250514": "o3",
|
|
106
|
+
"claude-opus-4-1-20250805": "o3",
|
|
107
|
+
"claude-opus-4-5-20251101": "o3",
|
|
108
|
+
"claude-opus-4-6": "o3",
|
|
109
|
+
"claude-haiku-4-5-20251001": "gpt-4o-mini",
|
|
110
|
+
"claude-3-5-haiku-20241022": "gpt-4o-mini",
|
|
111
|
+
"claude-3-7-sonnet-20250219": "gpt-4o",
|
|
112
|
+
"claude-3-5-sonnet-20241022": "gpt-4o"
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// packages/@ant/model-provider/src/providers/grok/modelMapping.ts
|
|
117
|
+
function getModelFamily2(model) {
|
|
118
|
+
if (/haiku/i.test(model))
|
|
119
|
+
return "haiku";
|
|
120
|
+
if (/opus/i.test(model))
|
|
121
|
+
return "opus";
|
|
122
|
+
if (/sonnet/i.test(model))
|
|
123
|
+
return "sonnet";
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
function getUserModelMap() {
|
|
127
|
+
const raw = process.env.GROK_MODEL_MAP;
|
|
128
|
+
if (!raw)
|
|
129
|
+
return null;
|
|
130
|
+
try {
|
|
131
|
+
const parsed = JSON.parse(raw);
|
|
132
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
133
|
+
return parsed;
|
|
134
|
+
}
|
|
135
|
+
} catch {}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
function resolveGrokModel(anthropicModel) {
|
|
139
|
+
if (process.env.GROK_MODEL) {
|
|
140
|
+
return process.env.GROK_MODEL;
|
|
141
|
+
}
|
|
142
|
+
const cleanModel = anthropicModel.replace(/\[1m\]$/, "");
|
|
143
|
+
const family = getModelFamily2(cleanModel);
|
|
144
|
+
const userMap = getUserModelMap();
|
|
145
|
+
if (userMap && family && userMap[family]) {
|
|
146
|
+
return userMap[family];
|
|
147
|
+
}
|
|
148
|
+
if (family) {
|
|
149
|
+
const grokEnvVar = `GROK_DEFAULT_${family.toUpperCase()}_MODEL`;
|
|
150
|
+
const grokOverride = process.env[grokEnvVar];
|
|
151
|
+
if (grokOverride)
|
|
152
|
+
return grokOverride;
|
|
153
|
+
const anthropicEnvVar = `ANTHROPIC_DEFAULT_${family.toUpperCase()}_MODEL`;
|
|
154
|
+
const anthropicOverride = process.env[anthropicEnvVar];
|
|
155
|
+
if (anthropicOverride)
|
|
156
|
+
return anthropicOverride;
|
|
157
|
+
}
|
|
158
|
+
if (DEFAULT_MODEL_MAP2[cleanModel]) {
|
|
159
|
+
return DEFAULT_MODEL_MAP2[cleanModel];
|
|
160
|
+
}
|
|
161
|
+
if (family && DEFAULT_FAMILY_MAP[family]) {
|
|
162
|
+
return DEFAULT_FAMILY_MAP[family];
|
|
163
|
+
}
|
|
164
|
+
return cleanModel;
|
|
165
|
+
}
|
|
166
|
+
var DEFAULT_MODEL_MAP2, DEFAULT_FAMILY_MAP;
|
|
167
|
+
var init_modelMapping2 = __esm(() => {
|
|
168
|
+
DEFAULT_MODEL_MAP2 = {
|
|
169
|
+
"claude-sonnet-4-20250514": "grok-3-mini-fast",
|
|
170
|
+
"claude-sonnet-4-5-20250929": "grok-3-mini-fast",
|
|
171
|
+
"claude-sonnet-4-6": "grok-3-mini-fast",
|
|
172
|
+
"claude-opus-4-20250514": "grok-4.20-reasoning",
|
|
173
|
+
"claude-opus-4-1-20250805": "grok-4.20-reasoning",
|
|
174
|
+
"claude-opus-4-5-20251101": "grok-4.20-reasoning",
|
|
175
|
+
"claude-opus-4-6": "grok-4.20-reasoning",
|
|
176
|
+
"claude-haiku-4-5-20251001": "grok-3-mini-fast",
|
|
177
|
+
"claude-3-5-haiku-20241022": "grok-3-mini-fast",
|
|
178
|
+
"claude-3-7-sonnet-20250219": "grok-3-mini-fast",
|
|
179
|
+
"claude-3-5-sonnet-20241022": "grok-3-mini-fast"
|
|
180
|
+
};
|
|
181
|
+
DEFAULT_FAMILY_MAP = {
|
|
182
|
+
opus: "grok-4.20-reasoning",
|
|
183
|
+
sonnet: "grok-3-mini-fast",
|
|
184
|
+
haiku: "grok-3-mini-fast"
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// packages/@ant/model-provider/src/providers/gemini/modelMapping.ts
|
|
189
|
+
function getModelFamily3(model) {
|
|
190
|
+
if (/haiku/i.test(model))
|
|
191
|
+
return "haiku";
|
|
192
|
+
if (/opus/i.test(model))
|
|
193
|
+
return "opus";
|
|
194
|
+
if (/sonnet/i.test(model))
|
|
195
|
+
return "sonnet";
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
function resolveGeminiModel(anthropicModel) {
|
|
199
|
+
if (process.env.GEMINI_MODEL) {
|
|
200
|
+
return process.env.GEMINI_MODEL;
|
|
201
|
+
}
|
|
202
|
+
const cleanModel = anthropicModel.replace(/\[1m\]$/i, "");
|
|
203
|
+
const family = getModelFamily3(cleanModel);
|
|
204
|
+
if (!family) {
|
|
205
|
+
return cleanModel;
|
|
206
|
+
}
|
|
207
|
+
const geminiEnvVar = `GEMINI_DEFAULT_${family.toUpperCase()}_MODEL`;
|
|
208
|
+
const geminiModel = process.env[geminiEnvVar];
|
|
209
|
+
if (geminiModel) {
|
|
210
|
+
return geminiModel;
|
|
211
|
+
}
|
|
212
|
+
const sharedEnvVar = `ANTHROPIC_DEFAULT_${family.toUpperCase()}_MODEL`;
|
|
213
|
+
const resolvedModel = process.env[sharedEnvVar];
|
|
214
|
+
if (resolvedModel) {
|
|
215
|
+
return resolvedModel;
|
|
216
|
+
}
|
|
217
|
+
throw new Error(`Gemini provider requires GEMINI_MODEL or ${geminiEnvVar} (or ${sharedEnvVar} for backward compatibility) to be configured.`);
|
|
218
|
+
}
|
|
219
|
+
var init_modelMapping3 = () => {};
|
|
220
|
+
|
|
221
|
+
// packages/@ant/model-provider/src/providers/gemini/types.ts
|
|
222
|
+
var GEMINI_THOUGHT_SIGNATURE_FIELD = "_geminiThoughtSignature";
|
|
223
|
+
var init_types = () => {};
|
|
224
|
+
|
|
225
|
+
// packages/@ant/model-provider/src/providers/gemini/convertMessages.ts
|
|
226
|
+
function safeParseJSON(json) {
|
|
227
|
+
if (!json)
|
|
228
|
+
return null;
|
|
229
|
+
try {
|
|
230
|
+
return JSON.parse(json);
|
|
231
|
+
} catch {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function anthropicMessagesToGemini(messages, systemPrompt) {
|
|
236
|
+
const contents = [];
|
|
237
|
+
const toolNamesById = new Map;
|
|
238
|
+
for (const msg of messages) {
|
|
239
|
+
if (msg.type === "assistant") {
|
|
240
|
+
const content = convertInternalAssistantMessage(msg);
|
|
241
|
+
if (content.parts.length > 0) {
|
|
242
|
+
contents.push(content);
|
|
243
|
+
}
|
|
244
|
+
const assistantContent = msg.message.content;
|
|
245
|
+
if (Array.isArray(assistantContent)) {
|
|
246
|
+
for (const block of assistantContent) {
|
|
247
|
+
if (typeof block !== "string" && block.type === "tool_use") {
|
|
248
|
+
toolNamesById.set(block.id, block.name);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (msg.type === "user") {
|
|
255
|
+
const content = convertInternalUserMessage(msg, toolNamesById);
|
|
256
|
+
if (content.parts.length > 0) {
|
|
257
|
+
contents.push(content);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const systemText = systemPromptToText(systemPrompt);
|
|
262
|
+
return {
|
|
263
|
+
contents,
|
|
264
|
+
...systemText ? {
|
|
265
|
+
systemInstruction: {
|
|
266
|
+
parts: [{ text: systemText }]
|
|
267
|
+
}
|
|
268
|
+
} : {}
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function systemPromptToText(systemPrompt) {
|
|
272
|
+
if (!systemPrompt || systemPrompt.length === 0)
|
|
273
|
+
return "";
|
|
274
|
+
return systemPrompt.filter(Boolean).join(`
|
|
275
|
+
|
|
276
|
+
`);
|
|
277
|
+
}
|
|
278
|
+
function convertInternalUserMessage(msg, toolNamesById) {
|
|
279
|
+
const content = msg.message.content;
|
|
280
|
+
if (typeof content === "string") {
|
|
281
|
+
return {
|
|
282
|
+
role: "user",
|
|
283
|
+
parts: createTextGeminiParts(content)
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
if (!Array.isArray(content)) {
|
|
287
|
+
return { role: "user", parts: [] };
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
role: "user",
|
|
291
|
+
parts: content.flatMap((block) => convertUserContentBlockToGeminiParts(block, toolNamesById))
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function convertUserContentBlockToGeminiParts(block, toolNamesById) {
|
|
295
|
+
if (typeof block === "string") {
|
|
296
|
+
return createTextGeminiParts(block);
|
|
297
|
+
}
|
|
298
|
+
if (block.type === "text") {
|
|
299
|
+
return createTextGeminiParts(block.text);
|
|
300
|
+
}
|
|
301
|
+
if (block.type === "tool_result") {
|
|
302
|
+
const toolResult = block;
|
|
303
|
+
return [
|
|
304
|
+
{
|
|
305
|
+
functionResponse: {
|
|
306
|
+
name: toolNamesById.get(toolResult.tool_use_id) ?? toolResult.tool_use_id,
|
|
307
|
+
response: toolResultToResponseObject(toolResult)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
];
|
|
311
|
+
}
|
|
312
|
+
if (block.type === "image") {
|
|
313
|
+
const source = block.source;
|
|
314
|
+
if (source?.type === "base64" && typeof source.data === "string") {
|
|
315
|
+
const mediaType = source.media_type || "image/png";
|
|
316
|
+
return [
|
|
317
|
+
{
|
|
318
|
+
inlineData: {
|
|
319
|
+
mimeType: mediaType,
|
|
320
|
+
data: source.data
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
];
|
|
324
|
+
}
|
|
325
|
+
if (source?.type === "url" && typeof source.url === "string") {
|
|
326
|
+
return createTextGeminiParts(`[image: ${source.url}]`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return [];
|
|
330
|
+
}
|
|
331
|
+
function convertInternalAssistantMessage(msg) {
|
|
332
|
+
const content = msg.message.content;
|
|
333
|
+
if (typeof content === "string") {
|
|
334
|
+
return {
|
|
335
|
+
role: "model",
|
|
336
|
+
parts: createTextGeminiParts(content)
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
if (!Array.isArray(content)) {
|
|
340
|
+
return { role: "model", parts: [] };
|
|
341
|
+
}
|
|
342
|
+
const parts = [];
|
|
343
|
+
for (const block of content) {
|
|
344
|
+
if (typeof block === "string") {
|
|
345
|
+
parts.push(...createTextGeminiParts(block));
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (block.type === "text") {
|
|
349
|
+
parts.push(...createTextGeminiParts(block.text, getGeminiThoughtSignature(block)));
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (block.type === "thinking") {
|
|
353
|
+
const thinkingPart = createThinkingGeminiPart(block.thinking, block.signature);
|
|
354
|
+
if (thinkingPart) {
|
|
355
|
+
parts.push(thinkingPart);
|
|
356
|
+
}
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (block.type === "tool_use") {
|
|
360
|
+
const toolUse = block;
|
|
361
|
+
parts.push({
|
|
362
|
+
functionCall: {
|
|
363
|
+
name: toolUse.name,
|
|
364
|
+
args: normalizeToolUseInput(toolUse.input)
|
|
365
|
+
},
|
|
366
|
+
...getGeminiThoughtSignature(block) && {
|
|
367
|
+
thoughtSignature: getGeminiThoughtSignature(block)
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return { role: "model", parts };
|
|
373
|
+
}
|
|
374
|
+
function createTextGeminiParts(value, thoughtSignature) {
|
|
375
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
376
|
+
return [];
|
|
377
|
+
}
|
|
378
|
+
return [
|
|
379
|
+
{
|
|
380
|
+
text: value,
|
|
381
|
+
...thoughtSignature && { thoughtSignature }
|
|
382
|
+
}
|
|
383
|
+
];
|
|
384
|
+
}
|
|
385
|
+
function createThinkingGeminiPart(value, thoughtSignature) {
|
|
386
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
text: value,
|
|
391
|
+
thought: true,
|
|
392
|
+
...thoughtSignature && { thoughtSignature }
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function normalizeToolUseInput(input) {
|
|
396
|
+
if (typeof input === "string") {
|
|
397
|
+
const parsed = safeParseJSON(input);
|
|
398
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
399
|
+
return parsed;
|
|
400
|
+
}
|
|
401
|
+
return parsed === null ? {} : { value: parsed };
|
|
402
|
+
}
|
|
403
|
+
if (input && typeof input === "object" && !Array.isArray(input)) {
|
|
404
|
+
return input;
|
|
405
|
+
}
|
|
406
|
+
return input === undefined ? {} : { value: input };
|
|
407
|
+
}
|
|
408
|
+
function toolResultToResponseObject(block) {
|
|
409
|
+
const result = normalizeToolResultContent(block.content);
|
|
410
|
+
if (result && typeof result === "object" && !Array.isArray(result)) {
|
|
411
|
+
return block.is_error ? { ...result, is_error: true } : result;
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
result,
|
|
415
|
+
...block.is_error ? { is_error: true } : {}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function normalizeToolResultContent(content) {
|
|
419
|
+
if (typeof content === "string") {
|
|
420
|
+
const parsed = safeParseJSON(content);
|
|
421
|
+
return parsed ?? content;
|
|
422
|
+
}
|
|
423
|
+
if (Array.isArray(content)) {
|
|
424
|
+
const text = content.map((part) => {
|
|
425
|
+
if (typeof part === "string")
|
|
426
|
+
return part;
|
|
427
|
+
if (part && typeof part === "object" && "text" in part && typeof part.text === "string") {
|
|
428
|
+
return part.text;
|
|
429
|
+
}
|
|
430
|
+
return "";
|
|
431
|
+
}).filter(Boolean).join(`
|
|
432
|
+
`);
|
|
433
|
+
const parsed = safeParseJSON(text);
|
|
434
|
+
return parsed ?? text;
|
|
435
|
+
}
|
|
436
|
+
return content ?? "";
|
|
437
|
+
}
|
|
438
|
+
function getGeminiThoughtSignature(block) {
|
|
439
|
+
const signature = block[GEMINI_THOUGHT_SIGNATURE_FIELD];
|
|
440
|
+
return typeof signature === "string" && signature.length > 0 ? signature : undefined;
|
|
441
|
+
}
|
|
442
|
+
var init_convertMessages = __esm(() => {
|
|
443
|
+
init_types();
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
// packages/@ant/model-provider/src/providers/gemini/convertTools.ts
|
|
447
|
+
function normalizeGeminiJsonSchemaType(value) {
|
|
448
|
+
if (typeof value === "string") {
|
|
449
|
+
return GEMINI_JSON_SCHEMA_TYPES.has(value) ? value : undefined;
|
|
450
|
+
}
|
|
451
|
+
if (Array.isArray(value)) {
|
|
452
|
+
const normalized = value.filter((item) => typeof item === "string" && GEMINI_JSON_SCHEMA_TYPES.has(item));
|
|
453
|
+
const unique = Array.from(new Set(normalized));
|
|
454
|
+
if (unique.length === 0)
|
|
455
|
+
return;
|
|
456
|
+
return unique.length === 1 ? unique[0] : unique;
|
|
457
|
+
}
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
function inferGeminiJsonSchemaTypeFromValue(value) {
|
|
461
|
+
if (value === null)
|
|
462
|
+
return "null";
|
|
463
|
+
if (Array.isArray(value))
|
|
464
|
+
return "array";
|
|
465
|
+
if (typeof value === "string")
|
|
466
|
+
return "string";
|
|
467
|
+
if (typeof value === "boolean")
|
|
468
|
+
return "boolean";
|
|
469
|
+
if (typeof value === "number") {
|
|
470
|
+
return Number.isInteger(value) ? "integer" : "number";
|
|
471
|
+
}
|
|
472
|
+
if (typeof value === "object")
|
|
473
|
+
return "object";
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
function inferGeminiJsonSchemaTypeFromEnum(values) {
|
|
477
|
+
const inferred = values.map(inferGeminiJsonSchemaTypeFromValue).filter((value) => value !== undefined);
|
|
478
|
+
const unique = Array.from(new Set(inferred));
|
|
479
|
+
if (unique.length === 0)
|
|
480
|
+
return;
|
|
481
|
+
return unique.length === 1 ? unique[0] : unique;
|
|
482
|
+
}
|
|
483
|
+
function addNullToGeminiJsonSchemaType(value) {
|
|
484
|
+
if (value === undefined)
|
|
485
|
+
return ["null"];
|
|
486
|
+
if (Array.isArray(value)) {
|
|
487
|
+
return value.includes("null") ? value : [...value, "null"];
|
|
488
|
+
}
|
|
489
|
+
return value === "null" ? value : [value, "null"];
|
|
490
|
+
}
|
|
491
|
+
function sanitizeGeminiJsonSchemaProperties(value) {
|
|
492
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
const sanitizedEntries = Object.entries(value).map(([key, schema]) => [key, sanitizeGeminiJsonSchema(schema)]).filter(([, schema]) => Object.keys(schema).length > 0);
|
|
496
|
+
if (sanitizedEntries.length === 0) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
return Object.fromEntries(sanitizedEntries);
|
|
500
|
+
}
|
|
501
|
+
function sanitizeGeminiJsonSchemaArray(value) {
|
|
502
|
+
if (!Array.isArray(value))
|
|
503
|
+
return;
|
|
504
|
+
const sanitized = value.map((item) => sanitizeGeminiJsonSchema(item)).filter((item) => Object.keys(item).length > 0);
|
|
505
|
+
return sanitized.length > 0 ? sanitized : undefined;
|
|
506
|
+
}
|
|
507
|
+
function sanitizeGeminiJsonSchema(schema) {
|
|
508
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|
|
509
|
+
return {};
|
|
510
|
+
}
|
|
511
|
+
const source = schema;
|
|
512
|
+
const result = {};
|
|
513
|
+
let type = normalizeGeminiJsonSchemaType(source.type);
|
|
514
|
+
if (source.const !== undefined) {
|
|
515
|
+
result.enum = [source.const];
|
|
516
|
+
type = type ?? inferGeminiJsonSchemaTypeFromValue(source.const);
|
|
517
|
+
} else if (Array.isArray(source.enum) && source.enum.length > 0) {
|
|
518
|
+
result.enum = source.enum;
|
|
519
|
+
type = type ?? inferGeminiJsonSchemaTypeFromEnum(source.enum);
|
|
520
|
+
}
|
|
521
|
+
if (!type) {
|
|
522
|
+
if (source.properties && typeof source.properties === "object") {
|
|
523
|
+
type = "object";
|
|
524
|
+
} else if (source.items !== undefined || source.prefixItems !== undefined) {
|
|
525
|
+
type = "array";
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (source.nullable === true) {
|
|
529
|
+
type = addNullToGeminiJsonSchemaType(type);
|
|
530
|
+
}
|
|
531
|
+
if (type) {
|
|
532
|
+
result.type = type;
|
|
533
|
+
}
|
|
534
|
+
if (typeof source.title === "string") {
|
|
535
|
+
result.title = source.title;
|
|
536
|
+
}
|
|
537
|
+
if (typeof source.description === "string") {
|
|
538
|
+
result.description = source.description;
|
|
539
|
+
}
|
|
540
|
+
if (typeof source.format === "string") {
|
|
541
|
+
result.format = source.format;
|
|
542
|
+
}
|
|
543
|
+
if (typeof source.pattern === "string") {
|
|
544
|
+
result.pattern = source.pattern;
|
|
545
|
+
}
|
|
546
|
+
if (typeof source.minimum === "number") {
|
|
547
|
+
result.minimum = source.minimum;
|
|
548
|
+
} else if (typeof source.exclusiveMinimum === "number") {
|
|
549
|
+
result.minimum = source.exclusiveMinimum;
|
|
550
|
+
}
|
|
551
|
+
if (typeof source.maximum === "number") {
|
|
552
|
+
result.maximum = source.maximum;
|
|
553
|
+
} else if (typeof source.exclusiveMaximum === "number") {
|
|
554
|
+
result.maximum = source.exclusiveMaximum;
|
|
555
|
+
}
|
|
556
|
+
if (typeof source.minItems === "number") {
|
|
557
|
+
result.minItems = source.minItems;
|
|
558
|
+
}
|
|
559
|
+
if (typeof source.maxItems === "number") {
|
|
560
|
+
result.maxItems = source.maxItems;
|
|
561
|
+
}
|
|
562
|
+
if (typeof source.minLength === "number") {
|
|
563
|
+
result.minLength = source.minLength;
|
|
564
|
+
}
|
|
565
|
+
if (typeof source.maxLength === "number") {
|
|
566
|
+
result.maxLength = source.maxLength;
|
|
567
|
+
}
|
|
568
|
+
if (typeof source.minProperties === "number") {
|
|
569
|
+
result.minProperties = source.minProperties;
|
|
570
|
+
}
|
|
571
|
+
if (typeof source.maxProperties === "number") {
|
|
572
|
+
result.maxProperties = source.maxProperties;
|
|
573
|
+
}
|
|
574
|
+
const properties = sanitizeGeminiJsonSchemaProperties(source.properties);
|
|
575
|
+
if (properties) {
|
|
576
|
+
result.properties = properties;
|
|
577
|
+
result.propertyOrdering = Object.keys(properties);
|
|
578
|
+
}
|
|
579
|
+
if (Array.isArray(source.required)) {
|
|
580
|
+
const required = source.required.filter((item) => typeof item === "string");
|
|
581
|
+
if (required.length > 0) {
|
|
582
|
+
result.required = required;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (typeof source.additionalProperties === "boolean") {
|
|
586
|
+
result.additionalProperties = source.additionalProperties;
|
|
587
|
+
} else {
|
|
588
|
+
const additionalProperties = sanitizeGeminiJsonSchema(source.additionalProperties);
|
|
589
|
+
if (Object.keys(additionalProperties).length > 0) {
|
|
590
|
+
result.additionalProperties = additionalProperties;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
const items = sanitizeGeminiJsonSchema(source.items);
|
|
594
|
+
if (Object.keys(items).length > 0) {
|
|
595
|
+
result.items = items;
|
|
596
|
+
}
|
|
597
|
+
const prefixItems = sanitizeGeminiJsonSchemaArray(source.prefixItems);
|
|
598
|
+
if (prefixItems) {
|
|
599
|
+
result.prefixItems = prefixItems;
|
|
600
|
+
}
|
|
601
|
+
const anyOf = sanitizeGeminiJsonSchemaArray(source.anyOf ?? source.oneOf);
|
|
602
|
+
if (anyOf) {
|
|
603
|
+
result.anyOf = anyOf;
|
|
604
|
+
}
|
|
605
|
+
return result;
|
|
606
|
+
}
|
|
607
|
+
function sanitizeGeminiFunctionParameters(schema) {
|
|
608
|
+
const sanitized = sanitizeGeminiJsonSchema(schema);
|
|
609
|
+
if (Object.keys(sanitized).length > 0) {
|
|
610
|
+
return sanitized;
|
|
611
|
+
}
|
|
612
|
+
return {
|
|
613
|
+
type: "object",
|
|
614
|
+
properties: {}
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
function anthropicToolsToGemini(tools) {
|
|
618
|
+
const functionDeclarations = tools.filter((tool) => {
|
|
619
|
+
const toolType = tool.type;
|
|
620
|
+
return tool.type === "custom" || !("type" in tool) || toolType !== "server";
|
|
621
|
+
}).map((tool) => {
|
|
622
|
+
const anyTool = tool;
|
|
623
|
+
const name = anyTool.name || "";
|
|
624
|
+
const description = anyTool.description || "";
|
|
625
|
+
const inputSchema = anyTool.input_schema ?? {
|
|
626
|
+
type: "object",
|
|
627
|
+
properties: {}
|
|
628
|
+
};
|
|
629
|
+
return {
|
|
630
|
+
name,
|
|
631
|
+
description,
|
|
632
|
+
parametersJsonSchema: sanitizeGeminiFunctionParameters(inputSchema)
|
|
633
|
+
};
|
|
634
|
+
});
|
|
635
|
+
return functionDeclarations.length > 0 ? [{ functionDeclarations }] : [];
|
|
636
|
+
}
|
|
637
|
+
function anthropicToolChoiceToGemini(toolChoice) {
|
|
638
|
+
if (!toolChoice || typeof toolChoice !== "object")
|
|
639
|
+
return;
|
|
640
|
+
const tc = toolChoice;
|
|
641
|
+
const type = tc.type;
|
|
642
|
+
switch (type) {
|
|
643
|
+
case "auto":
|
|
644
|
+
return { mode: "AUTO" };
|
|
645
|
+
case "any":
|
|
646
|
+
return { mode: "ANY" };
|
|
647
|
+
case "tool":
|
|
648
|
+
return {
|
|
649
|
+
mode: "ANY",
|
|
650
|
+
allowedFunctionNames: typeof tc.name === "string" ? [tc.name] : undefined
|
|
651
|
+
};
|
|
652
|
+
default:
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
var GEMINI_JSON_SCHEMA_TYPES;
|
|
657
|
+
var init_convertTools = __esm(() => {
|
|
658
|
+
GEMINI_JSON_SCHEMA_TYPES = new Set([
|
|
659
|
+
"string",
|
|
660
|
+
"number",
|
|
661
|
+
"integer",
|
|
662
|
+
"boolean",
|
|
663
|
+
"object",
|
|
664
|
+
"array",
|
|
665
|
+
"null"
|
|
666
|
+
]);
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
// packages/@ant/model-provider/src/providers/gemini/streamAdapter.ts
|
|
670
|
+
import { randomUUID } from "crypto";
|
|
671
|
+
async function* adaptGeminiStreamToAnthropic(stream, model) {
|
|
672
|
+
const messageId = `msg_${randomUUID().replace(/-/g, "").slice(0, 24)}`;
|
|
673
|
+
let started = false;
|
|
674
|
+
let stopped = false;
|
|
675
|
+
let nextContentIndex = 0;
|
|
676
|
+
let openTextLikeBlock = null;
|
|
677
|
+
let sawToolUse = false;
|
|
678
|
+
let finishReason;
|
|
679
|
+
let inputTokens = 0;
|
|
680
|
+
let outputTokens = 0;
|
|
681
|
+
for await (const chunk of stream) {
|
|
682
|
+
const usage = chunk.usageMetadata;
|
|
683
|
+
if (usage) {
|
|
684
|
+
inputTokens = usage.promptTokenCount ?? inputTokens;
|
|
685
|
+
outputTokens = (usage.candidatesTokenCount ?? 0) + (usage.thoughtsTokenCount ?? 0);
|
|
686
|
+
}
|
|
687
|
+
if (!started) {
|
|
688
|
+
started = true;
|
|
689
|
+
yield {
|
|
690
|
+
type: "message_start",
|
|
691
|
+
message: {
|
|
692
|
+
id: messageId,
|
|
693
|
+
type: "message",
|
|
694
|
+
role: "assistant",
|
|
695
|
+
content: [],
|
|
696
|
+
model,
|
|
697
|
+
stop_reason: null,
|
|
698
|
+
stop_sequence: null,
|
|
699
|
+
usage: {
|
|
700
|
+
input_tokens: inputTokens,
|
|
701
|
+
output_tokens: 0,
|
|
702
|
+
cache_creation_input_tokens: 0,
|
|
703
|
+
cache_read_input_tokens: 0
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
const candidate = chunk.candidates?.[0];
|
|
709
|
+
const parts = candidate?.content?.parts ?? [];
|
|
710
|
+
for (const part of parts) {
|
|
711
|
+
if (part.functionCall) {
|
|
712
|
+
if (openTextLikeBlock) {
|
|
713
|
+
yield {
|
|
714
|
+
type: "content_block_stop",
|
|
715
|
+
index: openTextLikeBlock.index
|
|
716
|
+
};
|
|
717
|
+
openTextLikeBlock = null;
|
|
718
|
+
}
|
|
719
|
+
sawToolUse = true;
|
|
720
|
+
const toolIndex = nextContentIndex++;
|
|
721
|
+
const toolId = `toolu_${randomUUID().replace(/-/g, "").slice(0, 24)}`;
|
|
722
|
+
yield {
|
|
723
|
+
type: "content_block_start",
|
|
724
|
+
index: toolIndex,
|
|
725
|
+
content_block: {
|
|
726
|
+
type: "tool_use",
|
|
727
|
+
id: toolId,
|
|
728
|
+
name: part.functionCall.name || "",
|
|
729
|
+
input: {}
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
if (part.thoughtSignature) {
|
|
733
|
+
yield {
|
|
734
|
+
type: "content_block_delta",
|
|
735
|
+
index: toolIndex,
|
|
736
|
+
delta: {
|
|
737
|
+
type: "signature_delta",
|
|
738
|
+
signature: part.thoughtSignature
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
if (part.functionCall.args && Object.keys(part.functionCall.args).length > 0) {
|
|
743
|
+
yield {
|
|
744
|
+
type: "content_block_delta",
|
|
745
|
+
index: toolIndex,
|
|
746
|
+
delta: {
|
|
747
|
+
type: "input_json_delta",
|
|
748
|
+
partial_json: JSON.stringify(part.functionCall.args)
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
yield {
|
|
753
|
+
type: "content_block_stop",
|
|
754
|
+
index: toolIndex
|
|
755
|
+
};
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
const textLikeType = getTextLikeBlockType(part);
|
|
759
|
+
if (textLikeType) {
|
|
760
|
+
if (!openTextLikeBlock || openTextLikeBlock.type !== textLikeType) {
|
|
761
|
+
if (openTextLikeBlock) {
|
|
762
|
+
yield {
|
|
763
|
+
type: "content_block_stop",
|
|
764
|
+
index: openTextLikeBlock.index
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
openTextLikeBlock = {
|
|
768
|
+
index: nextContentIndex++,
|
|
769
|
+
type: textLikeType
|
|
770
|
+
};
|
|
771
|
+
yield {
|
|
772
|
+
type: "content_block_start",
|
|
773
|
+
index: openTextLikeBlock.index,
|
|
774
|
+
content_block: textLikeType === "thinking" ? {
|
|
775
|
+
type: "thinking",
|
|
776
|
+
thinking: "",
|
|
777
|
+
signature: ""
|
|
778
|
+
} : {
|
|
779
|
+
type: "text",
|
|
780
|
+
text: ""
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
if (part.text) {
|
|
785
|
+
yield {
|
|
786
|
+
type: "content_block_delta",
|
|
787
|
+
index: openTextLikeBlock.index,
|
|
788
|
+
delta: textLikeType === "thinking" ? {
|
|
789
|
+
type: "thinking_delta",
|
|
790
|
+
thinking: part.text
|
|
791
|
+
} : {
|
|
792
|
+
type: "text_delta",
|
|
793
|
+
text: part.text
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
if (part.thoughtSignature) {
|
|
798
|
+
yield {
|
|
799
|
+
type: "content_block_delta",
|
|
800
|
+
index: openTextLikeBlock.index,
|
|
801
|
+
delta: {
|
|
802
|
+
type: "signature_delta",
|
|
803
|
+
signature: part.thoughtSignature
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
if (part.thoughtSignature && openTextLikeBlock) {
|
|
810
|
+
yield {
|
|
811
|
+
type: "content_block_delta",
|
|
812
|
+
index: openTextLikeBlock.index,
|
|
813
|
+
delta: {
|
|
814
|
+
type: "signature_delta",
|
|
815
|
+
signature: part.thoughtSignature
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
if (candidate?.finishReason) {
|
|
821
|
+
finishReason = candidate.finishReason;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
if (!started) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if (openTextLikeBlock) {
|
|
828
|
+
yield {
|
|
829
|
+
type: "content_block_stop",
|
|
830
|
+
index: openTextLikeBlock.index
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
if (!stopped) {
|
|
834
|
+
yield {
|
|
835
|
+
type: "message_delta",
|
|
836
|
+
delta: {
|
|
837
|
+
stop_reason: mapGeminiFinishReason(finishReason, sawToolUse),
|
|
838
|
+
stop_sequence: null
|
|
839
|
+
},
|
|
840
|
+
usage: {
|
|
841
|
+
output_tokens: outputTokens
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
yield {
|
|
845
|
+
type: "message_stop"
|
|
846
|
+
};
|
|
847
|
+
stopped = true;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
function getTextLikeBlockType(part) {
|
|
851
|
+
if (typeof part.text !== "string") {
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
854
|
+
return part.thought ? "thinking" : "text";
|
|
855
|
+
}
|
|
856
|
+
function mapGeminiFinishReason(reason, sawToolUse) {
|
|
857
|
+
switch (reason) {
|
|
858
|
+
case "MAX_TOKENS":
|
|
859
|
+
return "max_tokens";
|
|
860
|
+
case "STOP":
|
|
861
|
+
case "FINISH_REASON_UNSPECIFIED":
|
|
862
|
+
case "SAFETY":
|
|
863
|
+
case "RECITATION":
|
|
864
|
+
case "BLOCKLIST":
|
|
865
|
+
case "PROHIBITED_CONTENT":
|
|
866
|
+
case "SPII":
|
|
867
|
+
case "MALFORMED_FUNCTION_CALL":
|
|
868
|
+
default:
|
|
869
|
+
return sawToolUse ? "tool_use" : "end_turn";
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
var init_streamAdapter = () => {};
|
|
873
|
+
|
|
874
|
+
// packages/@ant/model-provider/src/errorUtils.ts
|
|
875
|
+
function extractConnectionErrorDetails(error) {
|
|
876
|
+
if (!error || typeof error !== "object") {
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
let current = error;
|
|
880
|
+
const maxDepth = 5;
|
|
881
|
+
let depth = 0;
|
|
882
|
+
while (current && depth < maxDepth) {
|
|
883
|
+
if (current instanceof Error && "code" in current && typeof current.code === "string") {
|
|
884
|
+
const code = current.code;
|
|
885
|
+
const isSSLError = SSL_ERROR_CODES.has(code);
|
|
886
|
+
return {
|
|
887
|
+
code,
|
|
888
|
+
message: current.message,
|
|
889
|
+
isSSLError
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
if (current instanceof Error && "cause" in current && current.cause !== current) {
|
|
893
|
+
current = current.cause;
|
|
894
|
+
depth++;
|
|
895
|
+
} else {
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return null;
|
|
900
|
+
}
|
|
901
|
+
function getSSLErrorHint(error) {
|
|
902
|
+
const details = extractConnectionErrorDetails(error);
|
|
903
|
+
if (!details?.isSSLError) {
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
906
|
+
return `SSL certificate error (${details.code}). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run /doctor for details.`;
|
|
907
|
+
}
|
|
908
|
+
function sanitizeMessageHTML(message) {
|
|
909
|
+
if (message.includes("<!DOCTYPE html") || message.includes("<html")) {
|
|
910
|
+
const titleMatch = message.match(/<title>([^<]+)<\/title>/);
|
|
911
|
+
if (titleMatch && titleMatch[1]) {
|
|
912
|
+
return titleMatch[1].trim();
|
|
913
|
+
}
|
|
914
|
+
return "";
|
|
915
|
+
}
|
|
916
|
+
return message;
|
|
917
|
+
}
|
|
918
|
+
function sanitizeAPIError(apiError) {
|
|
919
|
+
const message = apiError.message;
|
|
920
|
+
if (!message) {
|
|
921
|
+
return "";
|
|
922
|
+
}
|
|
923
|
+
return sanitizeMessageHTML(message);
|
|
924
|
+
}
|
|
925
|
+
function hasNestedError(value) {
|
|
926
|
+
return typeof value === "object" && value !== null && "error" in value && typeof value.error === "object" && value.error !== null;
|
|
927
|
+
}
|
|
928
|
+
function extractNestedErrorMessage(error) {
|
|
929
|
+
if (!hasNestedError(error)) {
|
|
930
|
+
return null;
|
|
931
|
+
}
|
|
932
|
+
const narrowed = error;
|
|
933
|
+
const nested = narrowed.error;
|
|
934
|
+
const deepMsg = nested?.error?.message;
|
|
935
|
+
if (typeof deepMsg === "string" && deepMsg.length > 0) {
|
|
936
|
+
const sanitized = sanitizeMessageHTML(deepMsg);
|
|
937
|
+
if (sanitized.length > 0) {
|
|
938
|
+
return sanitized;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
const msg = nested?.message;
|
|
942
|
+
if (typeof msg === "string" && msg.length > 0) {
|
|
943
|
+
const sanitized = sanitizeMessageHTML(msg);
|
|
944
|
+
if (sanitized.length > 0) {
|
|
945
|
+
return sanitized;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
return null;
|
|
949
|
+
}
|
|
950
|
+
function formatAPIError(error) {
|
|
951
|
+
const connectionDetails = extractConnectionErrorDetails(error);
|
|
952
|
+
if (connectionDetails) {
|
|
953
|
+
const { code, isSSLError } = connectionDetails;
|
|
954
|
+
if (code === "ETIMEDOUT") {
|
|
955
|
+
return "Request timed out. Check your internet connection and proxy settings";
|
|
956
|
+
}
|
|
957
|
+
if (isSSLError) {
|
|
958
|
+
switch (code) {
|
|
959
|
+
case "UNABLE_TO_VERIFY_LEAF_SIGNATURE":
|
|
960
|
+
case "UNABLE_TO_GET_ISSUER_CERT":
|
|
961
|
+
case "UNABLE_TO_GET_ISSUER_CERT_LOCALLY":
|
|
962
|
+
return "Unable to connect to API: SSL certificate verification failed. Check your proxy or corporate SSL certificates";
|
|
963
|
+
case "CERT_HAS_EXPIRED":
|
|
964
|
+
return "Unable to connect to API: SSL certificate has expired";
|
|
965
|
+
case "CERT_REVOKED":
|
|
966
|
+
return "Unable to connect to API: SSL certificate has been revoked";
|
|
967
|
+
case "DEPTH_ZERO_SELF_SIGNED_CERT":
|
|
968
|
+
case "SELF_SIGNED_CERT_IN_CHAIN":
|
|
969
|
+
return "Unable to connect to API: Self-signed certificate detected. Check your proxy or corporate SSL certificates";
|
|
970
|
+
case "ERR_TLS_CERT_ALTNAME_INVALID":
|
|
971
|
+
case "HOSTNAME_MISMATCH":
|
|
972
|
+
return "Unable to connect to API: SSL certificate hostname mismatch";
|
|
973
|
+
case "CERT_NOT_YET_VALID":
|
|
974
|
+
return "Unable to connect to API: SSL certificate is not yet valid";
|
|
975
|
+
default:
|
|
976
|
+
return `Unable to connect to API: SSL error (${code})`;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
if (error.message === "Connection error.") {
|
|
981
|
+
if (connectionDetails?.code) {
|
|
982
|
+
return `Unable to connect to API (${connectionDetails.code})`;
|
|
983
|
+
}
|
|
984
|
+
return "Unable to connect to API. Check your internet connection";
|
|
985
|
+
}
|
|
986
|
+
if (!error.message) {
|
|
987
|
+
return extractNestedErrorMessage(error) ?? `API error (status ${error.status ?? "unknown"})`;
|
|
988
|
+
}
|
|
989
|
+
const sanitizedMessage = sanitizeAPIError(error);
|
|
990
|
+
return sanitizedMessage !== error.message && sanitizedMessage.length > 0 ? sanitizedMessage : error.message;
|
|
991
|
+
}
|
|
992
|
+
var SSL_ERROR_CODES;
|
|
993
|
+
var init_errorUtils = __esm(() => {
|
|
994
|
+
SSL_ERROR_CODES = new Set([
|
|
995
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
996
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
997
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
998
|
+
"CERT_SIGNATURE_FAILURE",
|
|
999
|
+
"CERT_NOT_YET_VALID",
|
|
1000
|
+
"CERT_HAS_EXPIRED",
|
|
1001
|
+
"CERT_REVOKED",
|
|
1002
|
+
"CERT_REJECTED",
|
|
1003
|
+
"CERT_UNTRUSTED",
|
|
1004
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
1005
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
1006
|
+
"CERT_CHAIN_TOO_LONG",
|
|
1007
|
+
"PATH_LENGTH_EXCEEDED",
|
|
1008
|
+
"ERR_TLS_CERT_ALTNAME_INVALID",
|
|
1009
|
+
"HOSTNAME_MISMATCH",
|
|
1010
|
+
"ERR_TLS_HANDSHAKE_TIMEOUT",
|
|
1011
|
+
"ERR_SSL_WRONG_VERSION_NUMBER",
|
|
1012
|
+
"ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC"
|
|
1013
|
+
]);
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
// packages/@ant/model-provider/src/shared/openaiConvertMessages.ts
|
|
1017
|
+
function anthropicMessagesToOpenAI(messages, systemPrompt, _options) {
|
|
1018
|
+
const result = [];
|
|
1019
|
+
const systemText = systemPromptToText2(systemPrompt);
|
|
1020
|
+
if (systemText) {
|
|
1021
|
+
result.push({
|
|
1022
|
+
role: "system",
|
|
1023
|
+
content: systemText
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
for (const msg of messages) {
|
|
1027
|
+
switch (msg.type) {
|
|
1028
|
+
case "user":
|
|
1029
|
+
result.push(...convertInternalUserMessage2(msg));
|
|
1030
|
+
break;
|
|
1031
|
+
case "assistant":
|
|
1032
|
+
result.push(...convertInternalAssistantMessage2(msg));
|
|
1033
|
+
break;
|
|
1034
|
+
default:
|
|
1035
|
+
break;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
return result;
|
|
1039
|
+
}
|
|
1040
|
+
function systemPromptToText2(systemPrompt) {
|
|
1041
|
+
if (!systemPrompt || systemPrompt.length === 0)
|
|
1042
|
+
return "";
|
|
1043
|
+
return systemPrompt.filter(Boolean).join(`
|
|
1044
|
+
|
|
1045
|
+
`);
|
|
1046
|
+
}
|
|
1047
|
+
function convertInternalUserMessage2(msg) {
|
|
1048
|
+
const result = [];
|
|
1049
|
+
const content = msg.message.content;
|
|
1050
|
+
if (typeof content === "string") {
|
|
1051
|
+
result.push({
|
|
1052
|
+
role: "user",
|
|
1053
|
+
content
|
|
1054
|
+
});
|
|
1055
|
+
} else if (Array.isArray(content)) {
|
|
1056
|
+
const textParts = [];
|
|
1057
|
+
const toolResults = [];
|
|
1058
|
+
const imageParts = [];
|
|
1059
|
+
for (const block of content) {
|
|
1060
|
+
if (typeof block === "string") {
|
|
1061
|
+
textParts.push(block);
|
|
1062
|
+
} else if (block.type === "text") {
|
|
1063
|
+
textParts.push(block.text);
|
|
1064
|
+
} else if (block.type === "tool_result") {
|
|
1065
|
+
toolResults.push(block);
|
|
1066
|
+
} else if (block.type === "image") {
|
|
1067
|
+
const imagePart = convertImageBlockToOpenAI(block);
|
|
1068
|
+
if (imagePart) {
|
|
1069
|
+
imageParts.push(imagePart);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
for (const tr of toolResults) {
|
|
1074
|
+
result.push(convertToolResult(tr));
|
|
1075
|
+
}
|
|
1076
|
+
if (imageParts.length > 0) {
|
|
1077
|
+
const multiContent = [];
|
|
1078
|
+
if (textParts.length > 0) {
|
|
1079
|
+
multiContent.push({ type: "text", text: textParts.join(`
|
|
1080
|
+
`) });
|
|
1081
|
+
}
|
|
1082
|
+
multiContent.push(...imageParts);
|
|
1083
|
+
result.push({
|
|
1084
|
+
role: "user",
|
|
1085
|
+
content: multiContent
|
|
1086
|
+
});
|
|
1087
|
+
} else if (textParts.length > 0) {
|
|
1088
|
+
result.push({
|
|
1089
|
+
role: "user",
|
|
1090
|
+
content: textParts.join(`
|
|
1091
|
+
`)
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
return result;
|
|
1096
|
+
}
|
|
1097
|
+
function convertToolResult(block) {
|
|
1098
|
+
let content;
|
|
1099
|
+
if (typeof block.content === "string") {
|
|
1100
|
+
content = block.content;
|
|
1101
|
+
} else if (Array.isArray(block.content)) {
|
|
1102
|
+
content = block.content.map((c) => {
|
|
1103
|
+
if (typeof c === "string")
|
|
1104
|
+
return c;
|
|
1105
|
+
if ("text" in c)
|
|
1106
|
+
return c.text;
|
|
1107
|
+
return "";
|
|
1108
|
+
}).filter(Boolean).join(`
|
|
1109
|
+
`);
|
|
1110
|
+
} else {
|
|
1111
|
+
content = "";
|
|
1112
|
+
}
|
|
1113
|
+
return {
|
|
1114
|
+
role: "tool",
|
|
1115
|
+
tool_call_id: block.tool_use_id,
|
|
1116
|
+
content
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
function convertInternalAssistantMessage2(msg) {
|
|
1120
|
+
const content = msg.message.content;
|
|
1121
|
+
if (typeof content === "string") {
|
|
1122
|
+
return [
|
|
1123
|
+
{
|
|
1124
|
+
role: "assistant",
|
|
1125
|
+
content
|
|
1126
|
+
}
|
|
1127
|
+
];
|
|
1128
|
+
}
|
|
1129
|
+
if (!Array.isArray(content)) {
|
|
1130
|
+
return [
|
|
1131
|
+
{
|
|
1132
|
+
role: "assistant",
|
|
1133
|
+
content: ""
|
|
1134
|
+
}
|
|
1135
|
+
];
|
|
1136
|
+
}
|
|
1137
|
+
const textParts = [];
|
|
1138
|
+
const toolCalls = [];
|
|
1139
|
+
const reasoningParts = [];
|
|
1140
|
+
for (const block of content) {
|
|
1141
|
+
if (typeof block === "string") {
|
|
1142
|
+
textParts.push(block);
|
|
1143
|
+
} else if (block.type === "text") {
|
|
1144
|
+
textParts.push(block.text);
|
|
1145
|
+
} else if (block.type === "tool_use") {
|
|
1146
|
+
const tu = block;
|
|
1147
|
+
toolCalls.push({
|
|
1148
|
+
id: tu.id,
|
|
1149
|
+
type: "function",
|
|
1150
|
+
function: {
|
|
1151
|
+
name: tu.name,
|
|
1152
|
+
arguments: typeof tu.input === "string" ? tu.input : JSON.stringify(tu.input)
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
} else if (block.type === "thinking") {
|
|
1156
|
+
const thinkingText = block.thinking;
|
|
1157
|
+
if (typeof thinkingText === "string" && thinkingText) {
|
|
1158
|
+
reasoningParts.push(thinkingText);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
const result = {
|
|
1163
|
+
role: "assistant",
|
|
1164
|
+
content: textParts.length > 0 ? textParts.join(`
|
|
1165
|
+
`) : null,
|
|
1166
|
+
...toolCalls.length > 0 && { tool_calls: toolCalls },
|
|
1167
|
+
...reasoningParts.length > 0 && {
|
|
1168
|
+
reasoning_content: reasoningParts.join(`
|
|
1169
|
+
`)
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
return [result];
|
|
1173
|
+
}
|
|
1174
|
+
function convertImageBlockToOpenAI(block) {
|
|
1175
|
+
const source = block.source;
|
|
1176
|
+
if (!source)
|
|
1177
|
+
return null;
|
|
1178
|
+
if (source.type === "base64" && typeof source.data === "string") {
|
|
1179
|
+
const mediaType = source.media_type || "image/png";
|
|
1180
|
+
return {
|
|
1181
|
+
type: "image_url",
|
|
1182
|
+
image_url: {
|
|
1183
|
+
url: `data:${mediaType};base64,${source.data}`
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
if (source.type === "url" && typeof source.url === "string") {
|
|
1188
|
+
return {
|
|
1189
|
+
type: "image_url",
|
|
1190
|
+
image_url: {
|
|
1191
|
+
url: source.url
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
return null;
|
|
1196
|
+
}
|
|
1197
|
+
var init_openaiConvertMessages = () => {};
|
|
1198
|
+
|
|
1199
|
+
// packages/@ant/model-provider/src/shared/openaiConvertTools.ts
|
|
1200
|
+
function anthropicToolsToOpenAI(tools) {
|
|
1201
|
+
return tools.filter((tool) => {
|
|
1202
|
+
const toolType = tool.type;
|
|
1203
|
+
return tool.type === "custom" || !("type" in tool) || toolType !== "server";
|
|
1204
|
+
}).map((tool) => {
|
|
1205
|
+
const anyTool = tool;
|
|
1206
|
+
const name = anyTool.name || "";
|
|
1207
|
+
const description = anyTool.description || "";
|
|
1208
|
+
const inputSchema = anyTool.input_schema;
|
|
1209
|
+
return {
|
|
1210
|
+
type: "function",
|
|
1211
|
+
function: {
|
|
1212
|
+
name,
|
|
1213
|
+
description,
|
|
1214
|
+
parameters: sanitizeJsonSchema(inputSchema || { type: "object", properties: {} })
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
function sanitizeJsonSchema(schema) {
|
|
1220
|
+
if (!schema || typeof schema !== "object")
|
|
1221
|
+
return schema;
|
|
1222
|
+
const result = { ...schema };
|
|
1223
|
+
if ("const" in result) {
|
|
1224
|
+
result.enum = [result.const];
|
|
1225
|
+
delete result.const;
|
|
1226
|
+
}
|
|
1227
|
+
const objectKeys = [
|
|
1228
|
+
"properties",
|
|
1229
|
+
"definitions",
|
|
1230
|
+
"$defs",
|
|
1231
|
+
"patternProperties"
|
|
1232
|
+
];
|
|
1233
|
+
for (const key of objectKeys) {
|
|
1234
|
+
const nested = result[key];
|
|
1235
|
+
if (nested && typeof nested === "object") {
|
|
1236
|
+
const sanitized = {};
|
|
1237
|
+
for (const [k, v] of Object.entries(nested)) {
|
|
1238
|
+
sanitized[k] = v && typeof v === "object" ? sanitizeJsonSchema(v) : v;
|
|
1239
|
+
}
|
|
1240
|
+
result[key] = sanitized;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
const singleKeys = [
|
|
1244
|
+
"items",
|
|
1245
|
+
"additionalProperties",
|
|
1246
|
+
"not",
|
|
1247
|
+
"if",
|
|
1248
|
+
"then",
|
|
1249
|
+
"else",
|
|
1250
|
+
"contains",
|
|
1251
|
+
"propertyNames"
|
|
1252
|
+
];
|
|
1253
|
+
for (const key of singleKeys) {
|
|
1254
|
+
const nested = result[key];
|
|
1255
|
+
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
1256
|
+
result[key] = sanitizeJsonSchema(nested);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
const arrayKeys = ["anyOf", "oneOf", "allOf"];
|
|
1260
|
+
for (const key of arrayKeys) {
|
|
1261
|
+
const nested = result[key];
|
|
1262
|
+
if (Array.isArray(nested)) {
|
|
1263
|
+
result[key] = nested.map((item) => item && typeof item === "object" ? sanitizeJsonSchema(item) : item);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
return result;
|
|
1267
|
+
}
|
|
1268
|
+
function anthropicToolChoiceToOpenAI(toolChoice) {
|
|
1269
|
+
if (!toolChoice || typeof toolChoice !== "object")
|
|
1270
|
+
return;
|
|
1271
|
+
const tc = toolChoice;
|
|
1272
|
+
const type = tc.type;
|
|
1273
|
+
switch (type) {
|
|
1274
|
+
case "auto":
|
|
1275
|
+
return "auto";
|
|
1276
|
+
case "any":
|
|
1277
|
+
return "required";
|
|
1278
|
+
case "tool":
|
|
1279
|
+
return {
|
|
1280
|
+
type: "function",
|
|
1281
|
+
function: { name: tc.name }
|
|
1282
|
+
};
|
|
1283
|
+
default:
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
var init_openaiConvertTools = () => {};
|
|
1288
|
+
|
|
1289
|
+
// packages/@ant/model-provider/src/shared/openaiStreamAdapter.ts
|
|
1290
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
1291
|
+
async function* adaptOpenAIStreamToAnthropic(stream, model) {
|
|
1292
|
+
const messageId = `msg_${randomUUID2().replace(/-/g, "").slice(0, 24)}`;
|
|
1293
|
+
let started = false;
|
|
1294
|
+
let currentContentIndex = -1;
|
|
1295
|
+
const toolBlocks = new Map;
|
|
1296
|
+
let thinkingBlockOpen = false;
|
|
1297
|
+
let textBlockOpen = false;
|
|
1298
|
+
let inputTokens = 0;
|
|
1299
|
+
let outputTokens = 0;
|
|
1300
|
+
let cachedReadTokens = 0;
|
|
1301
|
+
const openBlockIndices = new Set;
|
|
1302
|
+
let pendingFinishReason = null;
|
|
1303
|
+
let pendingHasToolCalls = false;
|
|
1304
|
+
for await (const chunk of stream) {
|
|
1305
|
+
const choice = chunk.choices?.[0];
|
|
1306
|
+
const delta = choice?.delta;
|
|
1307
|
+
if (chunk.usage) {
|
|
1308
|
+
inputTokens = chunk.usage.prompt_tokens ?? inputTokens;
|
|
1309
|
+
outputTokens = chunk.usage.completion_tokens ?? outputTokens;
|
|
1310
|
+
const details = chunk.usage.prompt_tokens_details;
|
|
1311
|
+
if (details?.cached_tokens != null) {
|
|
1312
|
+
cachedReadTokens = details.cached_tokens;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
if (!started) {
|
|
1316
|
+
started = true;
|
|
1317
|
+
yield {
|
|
1318
|
+
type: "message_start",
|
|
1319
|
+
message: {
|
|
1320
|
+
id: messageId,
|
|
1321
|
+
type: "message",
|
|
1322
|
+
role: "assistant",
|
|
1323
|
+
content: [],
|
|
1324
|
+
model,
|
|
1325
|
+
stop_reason: null,
|
|
1326
|
+
stop_sequence: null,
|
|
1327
|
+
usage: {
|
|
1328
|
+
input_tokens: inputTokens,
|
|
1329
|
+
output_tokens: 0,
|
|
1330
|
+
cache_creation_input_tokens: 0,
|
|
1331
|
+
cache_read_input_tokens: cachedReadTokens
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
if (!delta)
|
|
1337
|
+
continue;
|
|
1338
|
+
const reasoningContent = delta.reasoning_content;
|
|
1339
|
+
if (reasoningContent != null && reasoningContent !== "") {
|
|
1340
|
+
if (!thinkingBlockOpen) {
|
|
1341
|
+
currentContentIndex++;
|
|
1342
|
+
thinkingBlockOpen = true;
|
|
1343
|
+
openBlockIndices.add(currentContentIndex);
|
|
1344
|
+
yield {
|
|
1345
|
+
type: "content_block_start",
|
|
1346
|
+
index: currentContentIndex,
|
|
1347
|
+
content_block: {
|
|
1348
|
+
type: "thinking",
|
|
1349
|
+
thinking: "",
|
|
1350
|
+
signature: ""
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
yield {
|
|
1355
|
+
type: "content_block_delta",
|
|
1356
|
+
index: currentContentIndex,
|
|
1357
|
+
delta: {
|
|
1358
|
+
type: "thinking_delta",
|
|
1359
|
+
thinking: reasoningContent
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
if (delta.content != null && delta.content !== "") {
|
|
1364
|
+
if (!textBlockOpen) {
|
|
1365
|
+
if (thinkingBlockOpen) {
|
|
1366
|
+
yield {
|
|
1367
|
+
type: "content_block_stop",
|
|
1368
|
+
index: currentContentIndex
|
|
1369
|
+
};
|
|
1370
|
+
openBlockIndices.delete(currentContentIndex);
|
|
1371
|
+
thinkingBlockOpen = false;
|
|
1372
|
+
}
|
|
1373
|
+
currentContentIndex++;
|
|
1374
|
+
textBlockOpen = true;
|
|
1375
|
+
openBlockIndices.add(currentContentIndex);
|
|
1376
|
+
yield {
|
|
1377
|
+
type: "content_block_start",
|
|
1378
|
+
index: currentContentIndex,
|
|
1379
|
+
content_block: {
|
|
1380
|
+
type: "text",
|
|
1381
|
+
text: ""
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
yield {
|
|
1386
|
+
type: "content_block_delta",
|
|
1387
|
+
index: currentContentIndex,
|
|
1388
|
+
delta: {
|
|
1389
|
+
type: "text_delta",
|
|
1390
|
+
text: delta.content
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
if (delta.tool_calls) {
|
|
1395
|
+
for (const tc of delta.tool_calls) {
|
|
1396
|
+
const tcIndex = tc.index;
|
|
1397
|
+
if (!toolBlocks.has(tcIndex)) {
|
|
1398
|
+
if (thinkingBlockOpen) {
|
|
1399
|
+
yield {
|
|
1400
|
+
type: "content_block_stop",
|
|
1401
|
+
index: currentContentIndex
|
|
1402
|
+
};
|
|
1403
|
+
openBlockIndices.delete(currentContentIndex);
|
|
1404
|
+
thinkingBlockOpen = false;
|
|
1405
|
+
}
|
|
1406
|
+
if (textBlockOpen) {
|
|
1407
|
+
yield {
|
|
1408
|
+
type: "content_block_stop",
|
|
1409
|
+
index: currentContentIndex
|
|
1410
|
+
};
|
|
1411
|
+
openBlockIndices.delete(currentContentIndex);
|
|
1412
|
+
textBlockOpen = false;
|
|
1413
|
+
}
|
|
1414
|
+
currentContentIndex++;
|
|
1415
|
+
const toolId = tc.id || `toolu_${randomUUID2().replace(/-/g, "").slice(0, 24)}`;
|
|
1416
|
+
const toolName = tc.function?.name || "";
|
|
1417
|
+
toolBlocks.set(tcIndex, {
|
|
1418
|
+
contentIndex: currentContentIndex,
|
|
1419
|
+
id: toolId,
|
|
1420
|
+
name: toolName,
|
|
1421
|
+
arguments: ""
|
|
1422
|
+
});
|
|
1423
|
+
openBlockIndices.add(currentContentIndex);
|
|
1424
|
+
yield {
|
|
1425
|
+
type: "content_block_start",
|
|
1426
|
+
index: currentContentIndex,
|
|
1427
|
+
content_block: {
|
|
1428
|
+
type: "tool_use",
|
|
1429
|
+
id: toolId,
|
|
1430
|
+
name: toolName,
|
|
1431
|
+
input: {}
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1435
|
+
const argFragment = tc.function?.arguments;
|
|
1436
|
+
if (argFragment) {
|
|
1437
|
+
toolBlocks.get(tcIndex).arguments += argFragment;
|
|
1438
|
+
yield {
|
|
1439
|
+
type: "content_block_delta",
|
|
1440
|
+
index: toolBlocks.get(tcIndex).contentIndex,
|
|
1441
|
+
delta: {
|
|
1442
|
+
type: "input_json_delta",
|
|
1443
|
+
partial_json: argFragment
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
if (choice?.finish_reason) {
|
|
1450
|
+
if (thinkingBlockOpen) {
|
|
1451
|
+
yield {
|
|
1452
|
+
type: "content_block_stop",
|
|
1453
|
+
index: currentContentIndex
|
|
1454
|
+
};
|
|
1455
|
+
openBlockIndices.delete(currentContentIndex);
|
|
1456
|
+
thinkingBlockOpen = false;
|
|
1457
|
+
}
|
|
1458
|
+
if (textBlockOpen) {
|
|
1459
|
+
yield {
|
|
1460
|
+
type: "content_block_stop",
|
|
1461
|
+
index: currentContentIndex
|
|
1462
|
+
};
|
|
1463
|
+
openBlockIndices.delete(currentContentIndex);
|
|
1464
|
+
textBlockOpen = false;
|
|
1465
|
+
}
|
|
1466
|
+
for (const [, block] of toolBlocks) {
|
|
1467
|
+
if (openBlockIndices.has(block.contentIndex)) {
|
|
1468
|
+
yield {
|
|
1469
|
+
type: "content_block_stop",
|
|
1470
|
+
index: block.contentIndex
|
|
1471
|
+
};
|
|
1472
|
+
openBlockIndices.delete(block.contentIndex);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
pendingFinishReason = choice.finish_reason;
|
|
1476
|
+
pendingHasToolCalls = toolBlocks.size > 0;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
for (const idx of openBlockIndices) {
|
|
1480
|
+
yield {
|
|
1481
|
+
type: "content_block_stop",
|
|
1482
|
+
index: idx
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
if (pendingFinishReason !== null) {
|
|
1486
|
+
const stopReason = pendingFinishReason === "length" ? "max_tokens" : pendingHasToolCalls ? "tool_use" : mapFinishReason(pendingFinishReason);
|
|
1487
|
+
yield {
|
|
1488
|
+
type: "message_delta",
|
|
1489
|
+
delta: {
|
|
1490
|
+
stop_reason: stopReason,
|
|
1491
|
+
stop_sequence: null
|
|
1492
|
+
},
|
|
1493
|
+
usage: {
|
|
1494
|
+
input_tokens: inputTokens,
|
|
1495
|
+
output_tokens: outputTokens,
|
|
1496
|
+
cache_read_input_tokens: cachedReadTokens,
|
|
1497
|
+
cache_creation_input_tokens: 0
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
yield {
|
|
1501
|
+
type: "message_stop"
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
function mapFinishReason(reason) {
|
|
1506
|
+
switch (reason) {
|
|
1507
|
+
case "stop":
|
|
1508
|
+
return "end_turn";
|
|
1509
|
+
case "tool_calls":
|
|
1510
|
+
return "tool_use";
|
|
1511
|
+
case "length":
|
|
1512
|
+
return "max_tokens";
|
|
1513
|
+
case "content_filter":
|
|
1514
|
+
return "end_turn";
|
|
1515
|
+
default:
|
|
1516
|
+
return "end_turn";
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
var init_openaiStreamAdapter = () => {};
|
|
1520
|
+
|
|
1521
|
+
// packages/@ant/model-provider/src/hooks/index.ts
|
|
1522
|
+
var init_hooks = () => {};
|
|
1523
|
+
|
|
1524
|
+
// packages/@ant/model-provider/src/client/index.ts
|
|
1525
|
+
var init_client = () => {};
|
|
1526
|
+
|
|
1527
|
+
// packages/@ant/model-provider/src/types/message.ts
|
|
1528
|
+
var init_message = () => {};
|
|
1529
|
+
|
|
1530
|
+
// packages/@ant/model-provider/src/types/errors.ts
|
|
1531
|
+
var init_errors2 = () => {};
|
|
1532
|
+
|
|
1533
|
+
// packages/@ant/model-provider/src/types/index.ts
|
|
1534
|
+
var init_types2 = __esm(() => {
|
|
1535
|
+
init_message();
|
|
1536
|
+
init_usage();
|
|
1537
|
+
init_errors2();
|
|
1538
|
+
init_systemPrompt();
|
|
1539
|
+
});
|
|
1540
|
+
|
|
1541
|
+
// packages/@ant/model-provider/src/index.ts
|
|
1542
|
+
var init_src = __esm(() => {
|
|
1543
|
+
init_hooks();
|
|
1544
|
+
init_client();
|
|
1545
|
+
init_modelMapping();
|
|
1546
|
+
init_modelMapping2();
|
|
1547
|
+
init_modelMapping3();
|
|
1548
|
+
init_convertMessages();
|
|
1549
|
+
init_convertTools();
|
|
1550
|
+
init_streamAdapter();
|
|
1551
|
+
init_types();
|
|
1552
|
+
init_errorUtils();
|
|
1553
|
+
init_openaiConvertMessages();
|
|
1554
|
+
init_openaiConvertTools();
|
|
1555
|
+
init_openaiStreamAdapter();
|
|
1556
|
+
init_types2();
|
|
1557
|
+
});
|
|
1558
|
+
|
|
1559
|
+
// src/utils/sdkEventQueue.ts
|
|
1560
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
1561
|
+
function enqueueSdkEvent(event) {
|
|
1562
|
+
if (!getIsNonInteractiveSession()) {
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1565
|
+
if (queue.length >= MAX_QUEUE_SIZE) {
|
|
1566
|
+
queue.shift();
|
|
1567
|
+
}
|
|
1568
|
+
queue.push(event);
|
|
1569
|
+
}
|
|
1570
|
+
function drainSdkEvents() {
|
|
1571
|
+
if (queue.length === 0) {
|
|
1572
|
+
return [];
|
|
1573
|
+
}
|
|
1574
|
+
const events = queue.splice(0);
|
|
1575
|
+
return events.map((e) => ({
|
|
1576
|
+
...e,
|
|
1577
|
+
uuid: randomUUID3(),
|
|
1578
|
+
session_id: getSessionId()
|
|
1579
|
+
}));
|
|
1580
|
+
}
|
|
1581
|
+
function emitTaskTerminatedSdk(taskId, status, opts) {
|
|
1582
|
+
enqueueSdkEvent({
|
|
1583
|
+
type: "system",
|
|
1584
|
+
subtype: "task_notification",
|
|
1585
|
+
task_id: taskId,
|
|
1586
|
+
tool_use_id: opts?.toolUseId,
|
|
1587
|
+
status,
|
|
1588
|
+
output_file: opts?.outputFile ?? "",
|
|
1589
|
+
summary: opts?.summary ?? "",
|
|
1590
|
+
usage: opts?.usage
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
var MAX_QUEUE_SIZE = 1000, queue;
|
|
1594
|
+
var init_sdkEventQueue = __esm(() => {
|
|
1595
|
+
init_state();
|
|
1596
|
+
queue = [];
|
|
1597
|
+
});
|
|
1598
|
+
|
|
1599
|
+
// src/utils/sessionIngressAuth.ts
|
|
1600
|
+
function getTokenFromFileDescriptor() {
|
|
1601
|
+
const cachedToken = getSessionIngressToken();
|
|
1602
|
+
if (cachedToken !== undefined) {
|
|
1603
|
+
return cachedToken;
|
|
1604
|
+
}
|
|
1605
|
+
const fdEnv = process.env.CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR;
|
|
1606
|
+
if (!fdEnv) {
|
|
1607
|
+
const path = process.env.CLAUDE_SESSION_INGRESS_TOKEN_FILE ?? CCR_SESSION_INGRESS_TOKEN_PATH;
|
|
1608
|
+
const fromFile = readTokenFromWellKnownFile(path, "session ingress token");
|
|
1609
|
+
setSessionIngressToken(fromFile);
|
|
1610
|
+
return fromFile;
|
|
1611
|
+
}
|
|
1612
|
+
const fd = parseInt(fdEnv, 10);
|
|
1613
|
+
if (Number.isNaN(fd)) {
|
|
1614
|
+
logForDebugging(`CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR must be a valid file descriptor number, got: ${fdEnv}`, { level: "error" });
|
|
1615
|
+
setSessionIngressToken(null);
|
|
1616
|
+
return null;
|
|
1617
|
+
}
|
|
1618
|
+
try {
|
|
1619
|
+
const fsOps = getFsImplementation();
|
|
1620
|
+
const fdPath = process.platform === "darwin" || process.platform === "freebsd" ? `/dev/fd/${fd}` : `/proc/self/fd/${fd}`;
|
|
1621
|
+
const token = fsOps.readFileSync(fdPath, { encoding: "utf8" }).trim();
|
|
1622
|
+
if (!token) {
|
|
1623
|
+
logForDebugging("File descriptor contained empty token", {
|
|
1624
|
+
level: "error"
|
|
1625
|
+
});
|
|
1626
|
+
setSessionIngressToken(null);
|
|
1627
|
+
return null;
|
|
1628
|
+
}
|
|
1629
|
+
logForDebugging(`Successfully read token from file descriptor ${fd}`);
|
|
1630
|
+
setSessionIngressToken(token);
|
|
1631
|
+
maybePersistTokenForSubprocesses(CCR_SESSION_INGRESS_TOKEN_PATH, token, "session ingress token");
|
|
1632
|
+
return token;
|
|
1633
|
+
} catch (error) {
|
|
1634
|
+
logForDebugging(`Failed to read token from file descriptor ${fd}: ${errorMessage(error)}`, { level: "error" });
|
|
1635
|
+
const path = process.env.CLAUDE_SESSION_INGRESS_TOKEN_FILE ?? CCR_SESSION_INGRESS_TOKEN_PATH;
|
|
1636
|
+
const fromFile = readTokenFromWellKnownFile(path, "session ingress token");
|
|
1637
|
+
setSessionIngressToken(fromFile);
|
|
1638
|
+
return fromFile;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
function getSessionIngressAuthToken() {
|
|
1642
|
+
const envToken = process.env.CLAUDE_CODE_SESSION_ACCESS_TOKEN;
|
|
1643
|
+
if (envToken) {
|
|
1644
|
+
return envToken;
|
|
1645
|
+
}
|
|
1646
|
+
return getTokenFromFileDescriptor();
|
|
1647
|
+
}
|
|
1648
|
+
function getSessionIngressAuthHeaders() {
|
|
1649
|
+
const token = getSessionIngressAuthToken();
|
|
1650
|
+
if (!token)
|
|
1651
|
+
return {};
|
|
1652
|
+
if (token.startsWith("sk-ant-sid")) {
|
|
1653
|
+
const headers = {
|
|
1654
|
+
Cookie: `sessionKey=${token}`
|
|
1655
|
+
};
|
|
1656
|
+
const orgUuid = process.env.CLAUDE_CODE_ORGANIZATION_UUID;
|
|
1657
|
+
if (orgUuid) {
|
|
1658
|
+
headers["X-Organization-Uuid"] = orgUuid;
|
|
1659
|
+
}
|
|
1660
|
+
return headers;
|
|
1661
|
+
}
|
|
1662
|
+
return { Authorization: `Bearer ${token}` };
|
|
1663
|
+
}
|
|
1664
|
+
function updateSessionIngressAuthToken(token) {
|
|
1665
|
+
process.env.CLAUDE_CODE_SESSION_ACCESS_TOKEN = token;
|
|
1666
|
+
}
|
|
1667
|
+
var init_sessionIngressAuth = __esm(() => {
|
|
1668
|
+
init_state();
|
|
1669
|
+
init_authFileDescriptor();
|
|
1670
|
+
init_debug();
|
|
1671
|
+
init_errors();
|
|
1672
|
+
init_fsOperations();
|
|
1673
|
+
});
|
|
1674
|
+
|
|
1675
|
+
// src/proactive/index.ts
|
|
1676
|
+
var exports_proactive = {};
|
|
1677
|
+
__export(exports_proactive, {
|
|
1678
|
+
subscribeToProactiveChanges: () => subscribeToProactiveChanges,
|
|
1679
|
+
shouldTick: () => shouldTick,
|
|
1680
|
+
setNextTickAt: () => setNextTickAt,
|
|
1681
|
+
setContextBlocked: () => setContextBlocked,
|
|
1682
|
+
resumeProactive: () => resumeProactive,
|
|
1683
|
+
pauseProactive: () => pauseProactive,
|
|
1684
|
+
isProactivePaused: () => isProactivePaused,
|
|
1685
|
+
isProactiveActive: () => isProactiveActive,
|
|
1686
|
+
isContextBlocked: () => isContextBlocked,
|
|
1687
|
+
getNextTickAt: () => getNextTickAt,
|
|
1688
|
+
getActivationSource: () => getActivationSource,
|
|
1689
|
+
deactivateProactive: () => deactivateProactive,
|
|
1690
|
+
activateProactive: () => activateProactive
|
|
1691
|
+
});
|
|
1692
|
+
function notify() {
|
|
1693
|
+
for (const cb of listeners) {
|
|
1694
|
+
try {
|
|
1695
|
+
cb();
|
|
1696
|
+
} catch {}
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
function isProactiveActive() {
|
|
1700
|
+
return active;
|
|
1701
|
+
}
|
|
1702
|
+
function activateProactive(source) {
|
|
1703
|
+
if (active)
|
|
1704
|
+
return;
|
|
1705
|
+
active = true;
|
|
1706
|
+
paused = false;
|
|
1707
|
+
contextBlocked = false;
|
|
1708
|
+
activationSource = source;
|
|
1709
|
+
notify();
|
|
1710
|
+
}
|
|
1711
|
+
function deactivateProactive() {
|
|
1712
|
+
if (!active)
|
|
1713
|
+
return;
|
|
1714
|
+
active = false;
|
|
1715
|
+
paused = false;
|
|
1716
|
+
contextBlocked = false;
|
|
1717
|
+
nextTickAt = null;
|
|
1718
|
+
activationSource = undefined;
|
|
1719
|
+
notify();
|
|
1720
|
+
}
|
|
1721
|
+
function isProactivePaused() {
|
|
1722
|
+
return paused;
|
|
1723
|
+
}
|
|
1724
|
+
function pauseProactive() {
|
|
1725
|
+
if (!active || paused)
|
|
1726
|
+
return;
|
|
1727
|
+
paused = true;
|
|
1728
|
+
nextTickAt = null;
|
|
1729
|
+
notify();
|
|
1730
|
+
}
|
|
1731
|
+
function resumeProactive() {
|
|
1732
|
+
if (!active || !paused)
|
|
1733
|
+
return;
|
|
1734
|
+
paused = false;
|
|
1735
|
+
notify();
|
|
1736
|
+
}
|
|
1737
|
+
function setContextBlocked(blocked) {
|
|
1738
|
+
if (contextBlocked === blocked)
|
|
1739
|
+
return;
|
|
1740
|
+
contextBlocked = blocked;
|
|
1741
|
+
if (blocked) {
|
|
1742
|
+
nextTickAt = null;
|
|
1743
|
+
}
|
|
1744
|
+
notify();
|
|
1745
|
+
}
|
|
1746
|
+
function isContextBlocked() {
|
|
1747
|
+
return contextBlocked;
|
|
1748
|
+
}
|
|
1749
|
+
function setNextTickAt(ts) {
|
|
1750
|
+
nextTickAt = ts;
|
|
1751
|
+
notify();
|
|
1752
|
+
}
|
|
1753
|
+
function getNextTickAt() {
|
|
1754
|
+
if (!active || paused || contextBlocked)
|
|
1755
|
+
return null;
|
|
1756
|
+
return nextTickAt;
|
|
1757
|
+
}
|
|
1758
|
+
function getActivationSource() {
|
|
1759
|
+
return activationSource;
|
|
1760
|
+
}
|
|
1761
|
+
function subscribeToProactiveChanges(cb) {
|
|
1762
|
+
listeners.add(cb);
|
|
1763
|
+
return () => {
|
|
1764
|
+
listeners.delete(cb);
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
function shouldTick() {
|
|
1768
|
+
return active && !paused && !contextBlocked;
|
|
1769
|
+
}
|
|
1770
|
+
var active = false, paused = false, contextBlocked = false, nextTickAt = null, activationSource, listeners;
|
|
1771
|
+
var init_proactive = __esm(() => {
|
|
1772
|
+
listeners = new Set;
|
|
1773
|
+
});
|
|
1774
|
+
|
|
1775
|
+
// src/utils/sessionState.ts
|
|
1776
|
+
function setSessionStateChangedListener(cb) {
|
|
1777
|
+
stateListener = cb;
|
|
1778
|
+
}
|
|
1779
|
+
function setSessionMetadataChangedListener(cb, options) {
|
|
1780
|
+
metadataListener = cb;
|
|
1781
|
+
if (!cb || !options?.replayCurrent) {
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
const snapshot = getSessionMetadataSnapshot();
|
|
1785
|
+
if (Object.keys(snapshot).length === 0) {
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
cb(snapshot);
|
|
1789
|
+
}
|
|
1790
|
+
function setPermissionModeChangedListener(cb) {
|
|
1791
|
+
permissionModeListener = cb;
|
|
1792
|
+
}
|
|
1793
|
+
function normalizeAutomationState(state) {
|
|
1794
|
+
if (!state || state.enabled !== true) {
|
|
1795
|
+
return null;
|
|
1796
|
+
}
|
|
1797
|
+
return {
|
|
1798
|
+
enabled: true,
|
|
1799
|
+
phase: state.phase === "standby" || state.phase === "sleeping" ? state.phase : null,
|
|
1800
|
+
next_tick_at: typeof state.next_tick_at === "number" ? state.next_tick_at : null,
|
|
1801
|
+
sleep_until: typeof state.sleep_until === "number" ? state.sleep_until : null
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
function automationStateKey(state) {
|
|
1805
|
+
return JSON.stringify(state);
|
|
1806
|
+
}
|
|
1807
|
+
function applyMetadataUpdate(metadata) {
|
|
1808
|
+
const nextMetadata = { ...currentMetadata };
|
|
1809
|
+
for (const key of Object.keys(metadata)) {
|
|
1810
|
+
const value = metadata[key];
|
|
1811
|
+
if (value === undefined) {
|
|
1812
|
+
delete nextMetadata[key];
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
nextMetadata[key] = value;
|
|
1816
|
+
}
|
|
1817
|
+
currentMetadata = nextMetadata;
|
|
1818
|
+
}
|
|
1819
|
+
function getSessionMetadataSnapshot() {
|
|
1820
|
+
const snapshot = { ...currentMetadata };
|
|
1821
|
+
if (currentAutomationState) {
|
|
1822
|
+
snapshot.automation_state = { ...currentAutomationState };
|
|
1823
|
+
} else if ("automation_state" in currentMetadata) {
|
|
1824
|
+
snapshot.automation_state = currentMetadata.automation_state ?? null;
|
|
1825
|
+
}
|
|
1826
|
+
return snapshot;
|
|
1827
|
+
}
|
|
1828
|
+
function getSessionState() {
|
|
1829
|
+
return currentState;
|
|
1830
|
+
}
|
|
1831
|
+
function notifySessionStateChanged(state, details) {
|
|
1832
|
+
currentState = state;
|
|
1833
|
+
stateListener?.(state, details);
|
|
1834
|
+
if (state === "requires_action" && details) {
|
|
1835
|
+
hasPendingAction = true;
|
|
1836
|
+
notifySessionMetadataChanged({
|
|
1837
|
+
pending_action: details
|
|
1838
|
+
});
|
|
1839
|
+
} else if (hasPendingAction) {
|
|
1840
|
+
hasPendingAction = false;
|
|
1841
|
+
notifySessionMetadataChanged({ pending_action: null });
|
|
1842
|
+
}
|
|
1843
|
+
if (state === "idle") {
|
|
1844
|
+
notifySessionMetadataChanged({ task_summary: null });
|
|
1845
|
+
}
|
|
1846
|
+
if (state !== "idle") {
|
|
1847
|
+
notifyAutomationStateChanged(isProactiveActive() ? {
|
|
1848
|
+
enabled: true,
|
|
1849
|
+
phase: null,
|
|
1850
|
+
next_tick_at: null,
|
|
1851
|
+
sleep_until: null
|
|
1852
|
+
} : null);
|
|
1853
|
+
}
|
|
1854
|
+
if (isEnvTruthy(process.env.CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS)) {
|
|
1855
|
+
enqueueSdkEvent({
|
|
1856
|
+
type: "system",
|
|
1857
|
+
subtype: "session_state_changed",
|
|
1858
|
+
state
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
function notifySessionMetadataChanged(metadata) {
|
|
1863
|
+
applyMetadataUpdate(metadata);
|
|
1864
|
+
metadataListener?.(metadata);
|
|
1865
|
+
}
|
|
1866
|
+
function notifyAutomationStateChanged(state) {
|
|
1867
|
+
const nextState = normalizeAutomationState(state);
|
|
1868
|
+
if (automationStateKey(nextState) === automationStateKey(currentAutomationState)) {
|
|
1869
|
+
return;
|
|
1870
|
+
}
|
|
1871
|
+
currentAutomationState = nextState;
|
|
1872
|
+
applyMetadataUpdate({ automation_state: nextState });
|
|
1873
|
+
metadataListener?.({ automation_state: nextState });
|
|
1874
|
+
}
|
|
1875
|
+
function notifyPermissionModeChanged(mode) {
|
|
1876
|
+
permissionModeListener?.(mode);
|
|
1877
|
+
}
|
|
1878
|
+
var stateListener = null, metadataListener = null, permissionModeListener = null, hasPendingAction = false, currentState = "idle", currentAutomationState = null, currentMetadata;
|
|
1879
|
+
var init_sessionState = __esm(() => {
|
|
1880
|
+
init_proactive();
|
|
1881
|
+
init_envUtils();
|
|
1882
|
+
init_sdkEventQueue();
|
|
1883
|
+
currentMetadata = {};
|
|
1884
|
+
});
|
|
1885
|
+
|
|
1886
|
+
// src/bridge/rcDebugLog.ts
|
|
1887
|
+
import { appendFileSync, mkdirSync, existsSync } from "fs";
|
|
1888
|
+
import { dirname } from "path";
|
|
1889
|
+
function ensureLogDir() {
|
|
1890
|
+
const dir = dirname(LOG_PATH);
|
|
1891
|
+
if (!existsSync(dir))
|
|
1892
|
+
mkdirSync(dir, { recursive: true });
|
|
1893
|
+
}
|
|
1894
|
+
function rcLog(msg) {
|
|
1895
|
+
try {
|
|
1896
|
+
if (!headerWritten) {
|
|
1897
|
+
ensureLogDir();
|
|
1898
|
+
appendFileSync(LOG_PATH, `
|
|
1899
|
+
===== RC-DEBUG session ${new Date().toISOString()} =====
|
|
1900
|
+
`);
|
|
1901
|
+
headerWritten = true;
|
|
1902
|
+
}
|
|
1903
|
+
const ts = new Date().toISOString().slice(11, 23);
|
|
1904
|
+
appendFileSync(LOG_PATH, `[${ts}] ${msg}
|
|
1905
|
+
`);
|
|
1906
|
+
} catch {}
|
|
1907
|
+
}
|
|
1908
|
+
var LOG_PATH, headerWritten = false;
|
|
1909
|
+
var init_rcDebugLog = __esm(() => {
|
|
1910
|
+
init_redscopeCompat();
|
|
1911
|
+
LOG_PATH = getCompatibleUserConfigFile("rc-debug.log");
|
|
1912
|
+
});
|
|
1913
|
+
|
|
1914
|
+
// src/utils/sessionActivity.ts
|
|
1915
|
+
function startHeartbeatTimer() {
|
|
1916
|
+
clearIdleTimer();
|
|
1917
|
+
heartbeatTimer = setInterval(() => {
|
|
1918
|
+
logForDiagnosticsNoPII("debug", "session_keepalive_heartbeat", {
|
|
1919
|
+
refcount
|
|
1920
|
+
});
|
|
1921
|
+
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE_SEND_KEEPALIVES)) {
|
|
1922
|
+
activityCallback?.();
|
|
1923
|
+
}
|
|
1924
|
+
}, SESSION_ACTIVITY_INTERVAL_MS);
|
|
1925
|
+
}
|
|
1926
|
+
function startIdleTimer() {
|
|
1927
|
+
clearIdleTimer();
|
|
1928
|
+
if (activityCallback === null) {
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
idleTimer = setTimeout(() => {
|
|
1932
|
+
logForDiagnosticsNoPII("info", "session_idle_30s");
|
|
1933
|
+
idleTimer = null;
|
|
1934
|
+
}, SESSION_ACTIVITY_INTERVAL_MS);
|
|
1935
|
+
}
|
|
1936
|
+
function clearIdleTimer() {
|
|
1937
|
+
if (idleTimer !== null) {
|
|
1938
|
+
clearTimeout(idleTimer);
|
|
1939
|
+
idleTimer = null;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
function registerSessionActivityCallback(cb) {
|
|
1943
|
+
activityCallback = cb;
|
|
1944
|
+
if (refcount > 0 && heartbeatTimer === null) {
|
|
1945
|
+
startHeartbeatTimer();
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
function unregisterSessionActivityCallback() {
|
|
1949
|
+
activityCallback = null;
|
|
1950
|
+
if (heartbeatTimer !== null) {
|
|
1951
|
+
clearInterval(heartbeatTimer);
|
|
1952
|
+
heartbeatTimer = null;
|
|
1953
|
+
}
|
|
1954
|
+
clearIdleTimer();
|
|
1955
|
+
}
|
|
1956
|
+
function sendSessionActivitySignal() {
|
|
1957
|
+
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE_SEND_KEEPALIVES)) {
|
|
1958
|
+
activityCallback?.();
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
function isSessionActivityTrackingActive() {
|
|
1962
|
+
return activityCallback !== null;
|
|
1963
|
+
}
|
|
1964
|
+
function startSessionActivity(reason) {
|
|
1965
|
+
refcount++;
|
|
1966
|
+
activeReasons.set(reason, (activeReasons.get(reason) ?? 0) + 1);
|
|
1967
|
+
if (refcount === 1) {
|
|
1968
|
+
oldestActivityStartedAt = Date.now();
|
|
1969
|
+
if (activityCallback !== null && heartbeatTimer === null) {
|
|
1970
|
+
startHeartbeatTimer();
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
if (!cleanupRegistered) {
|
|
1974
|
+
cleanupRegistered = true;
|
|
1975
|
+
registerCleanup(async () => {
|
|
1976
|
+
logForDiagnosticsNoPII("info", "session_activity_at_shutdown", {
|
|
1977
|
+
refcount,
|
|
1978
|
+
active: Object.fromEntries(activeReasons),
|
|
1979
|
+
oldest_activity_ms: refcount > 0 && oldestActivityStartedAt !== null ? Date.now() - oldestActivityStartedAt : null
|
|
1980
|
+
});
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
function stopSessionActivity(reason) {
|
|
1985
|
+
if (refcount > 0) {
|
|
1986
|
+
refcount--;
|
|
1987
|
+
}
|
|
1988
|
+
const n = (activeReasons.get(reason) ?? 0) - 1;
|
|
1989
|
+
if (n > 0)
|
|
1990
|
+
activeReasons.set(reason, n);
|
|
1991
|
+
else
|
|
1992
|
+
activeReasons.delete(reason);
|
|
1993
|
+
if (refcount === 0 && heartbeatTimer !== null) {
|
|
1994
|
+
clearInterval(heartbeatTimer);
|
|
1995
|
+
heartbeatTimer = null;
|
|
1996
|
+
startIdleTimer();
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
var SESSION_ACTIVITY_INTERVAL_MS = 30000, activityCallback = null, refcount = 0, activeReasons, oldestActivityStartedAt = null, heartbeatTimer = null, idleTimer = null, cleanupRegistered = false;
|
|
2000
|
+
var init_sessionActivity = __esm(() => {
|
|
2001
|
+
init_cleanupRegistry();
|
|
2002
|
+
init_diagLogs();
|
|
2003
|
+
init_envUtils();
|
|
2004
|
+
activeReasons = new Map;
|
|
2005
|
+
});
|
|
2006
|
+
|
|
2007
|
+
export { EMPTY_USAGE, asSystemPrompt, resolveOpenAIModel, resolveGrokModel, resolveGeminiModel, GEMINI_THOUGHT_SIGNATURE_FIELD, anthropicMessagesToGemini, anthropicToolsToGemini, anthropicToolChoiceToGemini, adaptGeminiStreamToAnthropic, extractConnectionErrorDetails, getSSLErrorHint, formatAPIError, anthropicMessagesToOpenAI, anthropicToolsToOpenAI, anthropicToolChoiceToOpenAI, adaptOpenAIStreamToAnthropic, init_src, enqueueSdkEvent, drainSdkEvents, emitTaskTerminatedSdk, init_sdkEventQueue, getSessionIngressAuthToken, getSessionIngressAuthHeaders, updateSessionIngressAuthToken, init_sessionIngressAuth, isProactiveActive, isProactivePaused, isContextBlocked, setNextTickAt, shouldTick, exports_proactive, init_proactive, setSessionStateChangedListener, setSessionMetadataChangedListener, setPermissionModeChangedListener, getSessionState, notifySessionStateChanged, notifySessionMetadataChanged, notifyAutomationStateChanged, notifyPermissionModeChanged, init_sessionState, registerSessionActivityCallback, unregisterSessionActivityCallback, sendSessionActivitySignal, isSessionActivityTrackingActive, startSessionActivity, stopSessionActivity, init_sessionActivity, rcLog, init_rcDebugLog };
|