@caspian2026/agent-sdk 0.0.8 → 0.0.9
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/dist/chunk-04h360ha.js +57 -0
- package/dist/{chunk-jmkn11my.js → chunk-04pw5akr.js} +20 -20
- package/dist/{chunk-veap97he.js → chunk-0gpem3pk.js} +46 -45
- package/dist/{chunk-0mej3p7q.js → chunk-0txtpamh.js} +14 -14
- package/dist/{chunk-4m9df5ef.js → chunk-0v89r445.js} +17 -21
- package/dist/chunk-0vp3wfab.js +12 -0
- package/dist/{chunk-268jd0rc.js → chunk-1486qzk5.js} +6 -4
- package/dist/chunk-1efrnkxx.js +468 -0
- package/dist/chunk-1gaw18rz.js +93 -0
- package/dist/{chunk-69r3hm9b.js → chunk-1hqb50ne.js} +13 -19
- package/dist/chunk-1hqvvvrt.js +96 -0
- package/dist/{chunk-qjyg1dv7.js → chunk-1hx5g6qy.js} +6 -10
- package/dist/{chunk-3g1vqhyx.js → chunk-1kmwf4vn.js} +17 -21
- package/dist/{chunk-naybw0p0.js → chunk-1nhnn2rg.js} +8 -8
- package/dist/{chunk-jjh7m5sg.js → chunk-1nvcmzj1.js} +66 -77
- package/dist/{chunk-2f21meep.js → chunk-1v01c96r.js} +1 -1
- package/dist/{chunk-7n51wk9k.js → chunk-1vp22nex.js} +2 -2
- package/dist/{chunk-jcwkgtbp.js → chunk-1yfc1d48.js} +52 -90
- package/dist/{chunk-83e71kz6.js → chunk-2072dpbx.js} +2 -2
- package/dist/{chunk-7rnqsng2.js → chunk-22mfb6bp.js} +19 -19
- package/dist/{chunk-d7886r6a.js → chunk-26wtxbdc.js} +7774 -7774
- package/dist/{chunk-x94btg29.js → chunk-2m32xn94.js} +17 -21
- package/dist/{chunk-mw1kpeg9.js → chunk-2nrarbza.js} +1909 -1377
- package/dist/chunk-2vbash3m.js +331 -0
- package/dist/{chunk-c11swzas.js → chunk-2vteceqh.js} +5 -5
- package/dist/{chunk-3zxswxtg.js → chunk-2y8x7xt7.js} +2 -2
- package/dist/{chunk-s7q42kp2.js → chunk-2yxqz99n.js} +9 -9
- package/dist/{chunk-qyqpb15f.js → chunk-35nft36d.js} +205 -261
- package/dist/{chunk-88xc4d7f.js → chunk-35z2vxep.js} +49 -48
- package/dist/{chunk-15m49c67.js → chunk-3e28fvn0.js} +2 -2
- package/dist/{chunk-2xvc97x4.js → chunk-3e4r5pmc.js} +3 -3
- package/dist/{chunk-a3ws4gae.js → chunk-3fn3ysvs.js} +47 -46
- package/dist/{chunk-4hv90qcz.js → chunk-3mgywd32.js} +1 -1
- package/dist/{chunk-pwqm47kn.js → chunk-3npsy4c4.js} +46 -45
- package/dist/{chunk-xz655xxa.js → chunk-3pzwd6qq.js} +2 -2
- package/dist/{chunk-70eey1nh.js → chunk-40s88wdg.js} +2 -2
- package/dist/{chunk-w0gmf6bv.js → chunk-42a0nyrq.js} +47 -46
- package/dist/{chunk-jvmybb06.js → chunk-44t1xk05.js} +46 -45
- package/dist/{chunk-0awwmrwr.js → chunk-4ayjwyqj.js} +2 -2
- package/dist/{chunk-a4npwxvb.js → chunk-4myad919.js} +46 -45
- package/dist/{chunk-8g747a8x.js → chunk-4pbx3g7s.js} +1 -1
- package/dist/chunk-4vtvwg7e.js +99 -0
- package/dist/{chunk-qcnhb4cd.js → chunk-54wn2jdr.js} +3 -3
- package/dist/{chunk-1nk93fqz.js → chunk-5cxjxxx8.js} +2 -7
- package/dist/chunk-5m3m7hr5.js +108 -0
- package/dist/{chunk-a3wczqrp.js → chunk-5mrc0ps5.js} +37 -41
- package/dist/{chunk-zmra45az.js → chunk-5tw3gj5z.js} +47 -46
- package/dist/{chunk-87e209aj.js → chunk-5zcygjb2.js} +46 -45
- package/dist/{chunk-mk1y74w7.js → chunk-65q3hqkw.js} +17 -21
- package/dist/{chunk-vajwapkf.js → chunk-67wms97m.js} +17 -23
- package/dist/chunk-6cfcqjty.js +441 -0
- package/dist/{chunk-rc9x0raa.js → chunk-6hs0cptm.js} +56 -55
- package/dist/{chunk-bmbq6nt1.js → chunk-6wzg2hpc.js} +2 -2
- package/dist/chunk-72qa16xm.js +91 -0
- package/dist/chunk-7cdy4aj6.js +150 -0
- package/dist/chunk-7cje7scj.js +1534 -0
- package/dist/{chunk-e7h4qxgw.js → chunk-7etkb4pr.js} +4 -4
- package/dist/{chunk-1ax1znzj.js → chunk-7hrmxpha.js} +6 -6
- package/dist/{chunk-wha6v7za.js → chunk-7krg0dkt.js} +2 -2
- package/dist/{chunk-vvsbvz2b.js → chunk-7skyagc2.js} +2 -2
- package/dist/{chunk-hzknr99c.js → chunk-83b2frat.js} +4 -4
- package/dist/{chunk-qvd3hbqs.js → chunk-84cdy41j.js} +5 -5
- package/dist/{chunk-bxcfz5gy.js → chunk-87xg6yb4.js} +1 -1
- package/dist/{chunk-nrtksr2p.js → chunk-8b2y3x7a.js} +1 -1
- package/dist/{chunk-c9dmpdss.js → chunk-8ckwc9k8.js} +46 -45
- package/dist/{chunk-67a4147x.js → chunk-8jy18nx9.js} +1 -1
- package/dist/{chunk-f2hbn5rk.js → chunk-93vwm44t.js} +100420 -57118
- package/dist/{chunk-cfgha78n.js → chunk-9957ffjc.js} +2 -2
- package/dist/{chunk-cdj51xbj.js → chunk-9byfzaeq.js} +46 -45
- package/dist/chunk-9ewnsd7f.js +31 -0
- package/dist/{chunk-xwg327ys.js → chunk-9w114071.js} +6 -6
- package/dist/chunk-9wf3fc4t.js +29 -0
- package/dist/chunk-9z9teq7p.js +87 -0
- package/dist/{chunk-6p4cyhb3.js → chunk-a6d2q415.js} +2 -2
- package/dist/{chunk-jgzxmtpf.js → chunk-ay5fvc2r.js} +52 -52
- package/dist/{chunk-1ybvj5df.js → chunk-ayx9aq2k.js} +47 -46
- package/dist/{chunk-23fkapww.js → chunk-azv68vk1.js} +2 -2
- package/dist/chunk-b547q41s.js +92 -0
- package/dist/{chunk-jgjqa49s.js → chunk-b56smerd.js} +3 -3
- package/dist/{chunk-enkdxqas.js → chunk-b5asw4tj.js} +6 -6
- package/dist/{chunk-nk82j7r2.js → chunk-b6prbsae.js} +7 -7
- package/dist/{chunk-ya40p6vj.js → chunk-b89ese8r.js} +46 -45
- package/dist/{chunk-byb2mn1c.js → chunk-be77bcs8.js} +118 -450
- package/dist/{chunk-m46xyqr6.js → chunk-bf03a1w7.js} +48 -47
- package/dist/{chunk-dmqeqxfz.js → chunk-bjdknxqn.js} +46 -45
- package/dist/{chunk-m87bhhqv.js → chunk-bzatg35k.js} +1 -1
- package/dist/{chunk-8ybw2s0h.js → chunk-c4d52460.js} +4 -4
- package/dist/{chunk-6g5qbbxk.js → chunk-c5zkrd7r.js} +47 -46
- package/dist/{chunk-4140c8xy.js → chunk-c6hsz5ey.js} +20 -24
- package/dist/{chunk-wqvr37xp.js → chunk-cay13mxk.js} +15 -31
- package/dist/{chunk-s3hsqf80.js → chunk-cexw1jmv.js} +30 -81
- package/dist/{chunk-cvm2tmwg.js → chunk-ckh4f9ry.js} +20 -24
- package/dist/{chunk-qn8z4r79.js → chunk-cr1dv2js.js} +50 -48
- package/dist/{chunk-88cekjja.js → chunk-d8z7pyrb.js} +47 -46
- package/dist/chunk-dexkgxt4.js +211 -0
- package/dist/{chunk-xxw9a0bq.js → chunk-dhwr4fz4.js} +2 -2
- package/dist/{chunk-0ym2z0c7.js → chunk-dj7d67ya.js} +1 -1
- package/dist/chunk-djfq8ws0.js +124 -0
- package/dist/{chunk-x2pvw7xw.js → chunk-dmyedkpw.js} +8 -8
- package/dist/{chunk-v0bykh19.js → chunk-dngfdsm9.js} +108 -102
- package/dist/{chunk-8nfn89nz.js → chunk-dt3epnwj.js} +9 -9
- package/dist/{chunk-4r50c14n.js → chunk-dz6zxh89.js} +46 -45
- package/dist/{chunk-jh965sa0.js → chunk-e7ag583m.js} +47 -46
- package/dist/{chunk-th4y838y.js → chunk-ec6ga5ey.js} +51 -50
- package/dist/{chunk-4g0nj78p.js → chunk-ecbh4n6q.js} +46 -45
- package/dist/{chunk-ydcsbj4t.js → chunk-ecv9kbtk.js} +11 -9
- package/dist/{chunk-nvwwtq1w.js → chunk-ecvy1ng2.js} +49 -48
- package/dist/{chunk-s4zb3f1b.js → chunk-ef2m4xyz.js} +46 -45
- package/dist/{chunk-psnsve7m.js → chunk-etbb3dss.js} +49 -48
- package/dist/{chunk-jgpmpgx6.js → chunk-etdt1xz3.js} +1 -1
- package/dist/{chunk-jxfp3g9b.js → chunk-ev7h351p.js} +4 -4
- package/dist/{chunk-njxgct8f.js → chunk-ey0n4emm.js} +46 -45
- package/dist/{chunk-af868wet.js → chunk-f4tdn7yr.js} +46 -45
- package/dist/{chunk-bd5sqj86.js → chunk-f4v7t54y.js} +11 -11
- package/dist/{chunk-8ywngxqt.js → chunk-fesvrjhd.js} +10 -10
- package/dist/{chunk-j4m8fd76.js → chunk-frm7mphm.js} +7 -11
- package/dist/{chunk-kek5v6ef.js → chunk-frwznxnf.js} +3 -3
- package/dist/{chunk-030rqd3a.js → chunk-ftsdm7y7.js} +54 -53
- package/dist/{chunk-vdcm8hz6.js → chunk-g597bz1j.js} +47 -46
- package/dist/chunk-g5pe8dew.js +25 -0
- package/dist/{chunk-tvzr9c8a.js → chunk-g78fetxa.js} +46 -45
- package/dist/{chunk-ga86yjm1.js → chunk-gdwdqewd.js} +3 -3
- package/dist/{chunk-dvcwahst.js → chunk-ghwvqhx9.js} +51 -50
- package/dist/chunk-gkn3jgqn.js +123 -0
- package/dist/{chunk-23q4jpn2.js → chunk-grqhgr2b.js} +3 -3
- package/dist/chunk-grqkx44z.js +90 -0
- package/dist/{chunk-21jsjcfa.js → chunk-gzj94jgg.js} +46 -45
- package/dist/{chunk-g5pgham9.js → chunk-h3vyya5n.js} +20 -14
- package/dist/{chunk-15edybe0.js → chunk-h4xfadhf.js} +1 -1
- package/dist/chunk-h61d4awv.js +95 -0
- package/dist/{chunk-w05jpkkr.js → chunk-hae34yd0.js} +5 -9
- package/dist/{chunk-rtmh0v4c.js → chunk-hb1gr101.js} +6 -6
- package/dist/{chunk-5a5w0ygx.js → chunk-hg45r671.js} +2 -2
- package/dist/{chunk-d9yghsfg.js → chunk-hg6fwhj1.js} +1 -1
- package/dist/{chunk-1cq2vrzq.js → chunk-hgmhngje.js} +4 -4
- package/dist/{chunk-vvjgdzhn.js → chunk-hparkfvt.js} +55 -51
- package/dist/{chunk-ahrhwpm9.js → chunk-hqjdgc6c.js} +2 -2
- package/dist/{chunk-37p5p94r.js → chunk-hrhp26d7.js} +55 -54
- package/dist/{chunk-xrpstt41.js → chunk-hzbr9543.js} +4 -4
- package/dist/{chunk-1dwvgrfc.js → chunk-j0gke393.js} +46 -45
- package/dist/{chunk-yyf72f78.js → chunk-j35mw64g.js} +4 -2
- package/dist/{chunk-425w66ka.js → chunk-j99ms5ep.js} +4 -4
- package/dist/{chunk-dtgh4te6.js → chunk-jgvmjwnx.js} +46 -45
- package/dist/{chunk-87scz097.js → chunk-jj4zs4gr.js} +46 -45
- package/dist/{chunk-am3qcgzp.js → chunk-jjz3hs34.js} +56 -55
- package/dist/{chunk-1a6ez1mg.js → chunk-jksf0ax9.js} +51 -49
- package/dist/{chunk-gdhz1652.js → chunk-jqfrz5g9.js} +27 -30
- package/dist/{chunk-q7jnesv8.js → chunk-jsj3fx0g.js} +5 -5
- package/dist/{chunk-vawgyev5.js → chunk-jtgyzqbq.js} +3 -3
- package/dist/{chunk-xfkfh5sd.js → chunk-jwpp2bq2.js} +1808 -1643
- package/dist/{chunk-zq6ezxh2.js → chunk-jwwpfq76.js} +49 -45
- package/dist/{chunk-qq5d2s0d.js → chunk-jxp2j9t5.js} +46 -45
- package/dist/{chunk-zctfbr1v.js → chunk-k7cw1a8a.js} +1 -1
- package/dist/chunk-k8jpbz31.js +62 -0
- package/dist/{chunk-tdbz9gbm.js → chunk-kjqyhxz7.js} +6 -6
- package/dist/{chunk-yc23zxmj.js → chunk-kxrrtr3p.js} +1 -1
- package/dist/chunk-m70n19dz.js +93 -0
- package/dist/{chunk-4nspekjp.js → chunk-mcws22k3.js} +1 -28
- package/dist/{chunk-a1bf2kh4.js → chunk-mewywsar.js} +46 -45
- package/dist/{chunk-k7g9gcr9.js → chunk-mmhkcj7c.js} +64 -58
- package/dist/{chunk-rm2vtv77.js → chunk-msxggy37.js} +22 -25
- package/dist/{chunk-s1tg295x.js → chunk-njw0haha.js} +10 -8
- package/dist/{chunk-5rv9c8yd.js → chunk-nrjtxhyr.js} +1 -1
- package/dist/{chunk-nqn45znr.js → chunk-ns7x6xam.js} +9 -9
- package/dist/{chunk-jaaxk89e.js → chunk-nsc89h0n.js} +2 -22
- package/dist/{chunk-z19sd3bt.js → chunk-p4196wzm.js} +5 -5
- package/dist/{chunk-1dgdjrm1.js → chunk-p791ydbm.js} +4 -4
- package/dist/{chunk-1zhy5cbc.js → chunk-p9ny0p2a.js} +13 -13
- package/dist/{chunk-phd1qfpc.js → chunk-pd2vy8hx.js} +5 -5
- package/dist/{chunk-gnj7tyj6.js → chunk-pddf0719.js} +49 -48
- package/dist/{chunk-6t5zvnrg.js → chunk-pfarypfq.js} +48 -46
- package/dist/{chunk-w4yn8cq7.js → chunk-psm26hv7.js} +8 -8
- package/dist/{chunk-hwn8vetn.js → chunk-pwpk3gm6.js} +10 -10
- package/dist/{chunk-va8drjmv.js → chunk-q14wrksq.js} +48 -47
- package/dist/{chunk-twqzmqsn.js → chunk-q4f1g9y6.js} +31 -27
- package/dist/{chunk-23jzrwsw.js → chunk-q6tdxy8v.js} +5 -5
- package/dist/chunk-q8hxwh48.js +445 -0
- package/dist/{chunk-eenq3avg.js → chunk-qcrpqjya.js} +1 -1
- package/dist/{chunk-e7efcp3k.js → chunk-qctsv1d7.js} +257 -2857
- package/dist/{chunk-ck0ap688.js → chunk-qkczt8cr.js} +4 -4
- package/dist/{chunk-2fxpd35d.js → chunk-qkp4ygnk.js} +2 -2
- package/dist/{chunk-c3d2cnz5.js → chunk-qqs58ywv.js} +7 -7
- package/dist/{chunk-qdnxk7d7.js → chunk-qxjhw1dt.js} +29 -30
- package/dist/{chunk-rkg741k3.js → chunk-qz0xdht6.js} +14 -14
- package/dist/chunk-r3ehjkj5.js +123 -0
- package/dist/{chunk-wbbykfdd.js → chunk-r5nd93kc.js} +1 -1
- package/dist/{chunk-yzcjz0gg.js → chunk-r6nnp8mj.js} +46 -45
- package/dist/{chunk-bm5rc541.js → chunk-r7684mmh.js} +5 -5
- package/dist/chunk-ratnrv9v.js +517 -0
- package/dist/{chunk-nx7c354z.js → chunk-rfbbcx5s.js} +46 -45
- package/dist/{chunk-z9n0183s.js → chunk-rfq9kmsy.js} +9 -9
- package/dist/{chunk-qsc98gbe.js → chunk-rhvn1rqs.js} +2 -2
- package/dist/{chunk-gvrjgq1n.js → chunk-rjq5nf1c.js} +16 -20
- package/dist/{chunk-xp61y5ba.js → chunk-rkv8bdtr.js} +2 -2
- package/dist/{chunk-tff58196.js → chunk-rmpaj37q.js} +48 -47
- package/dist/{chunk-k1crm94z.js → chunk-rn1s097c.js} +46 -45
- package/dist/{chunk-c42pqnxx.js → chunk-rnxpvm3m.js} +1 -1
- package/dist/{chunk-k0v0cz71.js → chunk-rpsqtvkx.js} +46 -45
- package/dist/{chunk-t5vbqd9d.js → chunk-rx4mcfg1.js} +55 -54
- package/dist/{chunk-30smv00b.js → chunk-rygxwjtc.js} +47 -46
- package/dist/{chunk-jpc9zwsk.js → chunk-rz94yg8c.js} +3 -3
- package/dist/{chunk-0m9w9esf.js → chunk-s19b0bc7.js} +46 -45
- package/dist/{chunk-wayfjcwt.js → chunk-sdfvr9ps.js} +4 -4
- package/dist/{chunk-fkhs3myp.js → chunk-sh2v9ywv.js} +5 -3
- package/dist/{chunk-1avzakfd.js → chunk-sjpqw47t.js} +3 -3
- package/dist/{chunk-7mqab3z7.js → chunk-skp5w8bq.js} +1 -1
- package/dist/{chunk-76j2e9vy.js → chunk-snxp8mxj.js} +2 -2
- package/dist/{chunk-vsqwd13w.js → chunk-ssb4wba6.js} +17 -19
- package/dist/{chunk-kva79cra.js → chunk-szzff973.js} +7 -5
- package/dist/{chunk-st73prx0.js → chunk-t1pygy19.js} +47 -46
- package/dist/{chunk-q1ah9nbq.js → chunk-t1s91wrk.js} +1 -1
- package/dist/{chunk-3skj4gfg.js → chunk-t3gmfcy7.js} +47 -46
- package/dist/{chunk-xw8pjerk.js → chunk-t9eeyrkn.js} +48 -47
- package/dist/{chunk-0jtbeesf.js → chunk-tf859h88.js} +16 -20
- package/dist/{chunk-denyma1s.js → chunk-thenr6b3.js} +14 -12
- package/dist/{chunk-234668cb.js → chunk-thmtkfgj.js} +5 -5
- package/dist/chunk-tj7v47cp.js +20 -0
- package/dist/{chunk-12k745vf.js → chunk-tpk67mjc.js} +3 -3
- package/dist/chunk-trvc6jh7.js +92 -0
- package/dist/{chunk-9v13f3gm.js → chunk-ttyfhx12.js} +524 -195
- package/dist/{chunk-q87kegxh.js → chunk-txgbs4hp.js} +49 -48
- package/dist/{chunk-25bwa70y.js → chunk-ty1cyqr7.js} +49 -48
- package/dist/{chunk-r6kaak61.js → chunk-v0tgjdx0.js} +16 -20
- package/dist/chunk-v3s93bzd.js +34 -0
- package/dist/{chunk-4cp6193g.js → chunk-v4t6dyyh.js} +2 -2
- package/dist/{chunk-fape0yfp.js → chunk-v4wba09w.js} +46 -45
- package/dist/{chunk-h02gcdx5.js → chunk-v5g8nf5h.js} +8 -8
- package/dist/{chunk-jtztm8f5.js → chunk-v6hbqcmr.js} +44 -43
- package/dist/{chunk-21gmrwhs.js → chunk-vajsk9ya.js} +17 -21
- package/dist/{chunk-8hpq2659.js → chunk-vbtm9g57.js} +1 -1
- package/dist/{chunk-q7e0106d.js → chunk-vk3nb2xe.js} +51 -56
- package/dist/{chunk-ad3v6mzw.js → chunk-vmbht6ec.js} +12 -12
- package/dist/{chunk-as5rvw4n.js → chunk-vmp5rk8q.js} +17 -21
- package/dist/{chunk-1x0y4426.js → chunk-vtmxgm1m.js} +4 -4
- package/dist/{chunk-pb92bj1h.js → chunk-vw5jzpcm.js} +6 -6
- package/dist/{chunk-5cem2v7n.js → chunk-vyz3v0qx.js} +5 -5
- package/dist/{chunk-hxzt3r84.js → chunk-w3782jck.js} +51 -50
- package/dist/{chunk-1vnd9s2j.js → chunk-w3gnkyfc.js} +57 -66
- package/dist/chunk-w6mcmmt5.js +1457 -0
- package/dist/chunk-wa0xgm6m.js +988 -0
- package/dist/{chunk-vrjbc8ap.js → chunk-wa8yn2p0.js} +1 -1
- package/dist/{chunk-hya4c599.js → chunk-wg47eg7y.js} +46 -45
- package/dist/{chunk-y7we499r.js → chunk-wgd4n1q7.js} +8 -8
- package/dist/{chunk-0g5cy3wj.js → chunk-wgk9sxk7.js} +4 -4
- package/dist/{chunk-wr3pd88n.js → chunk-wkt2q02c.js} +40 -9
- package/dist/{chunk-gbte7d7h.js → chunk-wm1zm5xj.js} +4 -2
- package/dist/{chunk-3hwa20vg.js → chunk-wtpgjmjd.js} +49 -46
- package/dist/{chunk-dbwmzvfj.js → chunk-wxkrq9eb.js} +46 -45
- package/dist/{chunk-d00mfc1e.js → chunk-x2bnzvd6.js} +46 -45
- package/dist/{chunk-2xbyb015.js → chunk-x3jthbjq.js} +47 -46
- package/dist/chunk-x7fdwq3d.js +33 -0
- package/dist/{chunk-zhk465tg.js → chunk-xcrzgyce.js} +46 -45
- package/dist/{chunk-chsyvavm.js → chunk-xeb6075z.js} +1 -1
- package/dist/{chunk-6ksdp40n.js → chunk-xffb3dsw.js} +1 -1
- package/dist/{chunk-2j3v2dgk.js → chunk-xgbd6ec5.js} +47 -46
- package/dist/{chunk-n7pnyq43.js → chunk-xhfmdq1y.js} +16 -0
- package/dist/{chunk-2v4x8kaq.js → chunk-xhn4ptjn.js} +51 -50
- package/dist/{chunk-w1sv7j01.js → chunk-xs7zsmzk.js} +46 -45
- package/dist/chunk-xswyz2es.js +118 -0
- package/dist/{chunk-ky39hkg1.js → chunk-xtdm6ejq.js} +9 -7
- package/dist/{chunk-hh3k5s1s.js → chunk-xvk90wpt.js} +3 -3
- package/dist/{chunk-5awgsvrw.js → chunk-xw99fqv1.js} +14 -6
- package/dist/{chunk-xnv6kb39.js → chunk-y32em34x.js} +22 -23
- package/dist/chunk-y5wfy524.js +94 -0
- package/dist/{chunk-fk8crdnk.js → chunk-ya9dxex0.js} +48 -46
- package/dist/{chunk-97wgdsab.js → chunk-z16txqz0.js} +3 -3
- package/dist/{chunk-yvtzznds.js → chunk-z6wm96eh.js} +2 -2
- package/dist/{chunk-nqrc7pc4.js → chunk-zcgprbyy.js} +29 -27
- package/dist/chunk-zqbnw3n2.js +197 -0
- package/dist/{chunk-d6rypdxt.js → chunk-zxywawr7.js} +1 -1
- package/dist/{chunk-jj5wj46b.js → chunk-zyjkg76f.js} +7 -7
- package/dist/cli.js +8 -8
- package/dist/gateway/index.js +326 -0
- package/dist/gateway/worker.js +482241 -0
- package/package.json +1 -1
- package/dist/chunk-11cz07kz.js +0 -93
- package/dist/chunk-1pbtp2z2.js +0 -92
- package/dist/chunk-25y2dtzf.js +0 -91
- package/dist/chunk-3hyj0zpy.js +0 -95
- package/dist/chunk-4kqjjakw.js +0 -73
- package/dist/chunk-4zwqbg7s.js +0 -87
- package/dist/chunk-5be33wja.js +0 -120
- package/dist/chunk-70mgxhkz.js +0 -369
- package/dist/chunk-7gmk09cq.js +0 -116
- package/dist/chunk-8dprcdra.js +0 -92
- package/dist/chunk-8xwx1xtg.js +0 -120
- package/dist/chunk-a579wjd2.js +0 -436
- package/dist/chunk-axqk3mxk.js +0 -116
- package/dist/chunk-c0ckmxr1.js +0 -86
- package/dist/chunk-c6t24y8q.js +0 -94
- package/dist/chunk-cfv996bs.js +0 -22
- package/dist/chunk-e5t5eefc.js +0 -62
- package/dist/chunk-eyph0250.js +0 -88
- package/dist/chunk-f825x57v.js +0 -91
- package/dist/chunk-h9xx5bj6.js +0 -91
- package/dist/chunk-j1dg659r.js +0 -89
- package/dist/chunk-jk8seqkk.js +0 -90
- package/dist/chunk-jzg4nddc.js +0 -92
- package/dist/chunk-k5vy0s3c.js +0 -93
- package/dist/chunk-ke820fjw.js +0 -91
- package/dist/chunk-kyzd4p8z.js +0 -111
- package/dist/chunk-njrt3tac.js +0 -640
- package/dist/chunk-pavb6a7w.js +0 -516
- package/dist/chunk-q268gpa0.js +0 -145
- package/dist/chunk-qvh1w3t7.js +0 -157
- package/dist/chunk-qy1es4jj.js +0 -95
- package/dist/chunk-qz2x630m.js +0 -49145
- package/dist/chunk-tw48evtr.js +0 -40
- package/dist/chunk-w0gfctyc.js +0 -117
- package/dist/chunk-y0fhjxef.js +0 -276
- package/dist/chunk-y275vgmw.js +0 -654
- package/dist/chunk-zq7pmdas.js +0 -1003
package/dist/chunk-zq7pmdas.js
DELETED
|
@@ -1,1003 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
init_SSETransport,
|
|
4
|
-
parseSSEFrames
|
|
5
|
-
} from "./chunk-a579wjd2.js";
|
|
6
|
-
import {
|
|
7
|
-
createAssistantAPIErrorMessage,
|
|
8
|
-
init_api,
|
|
9
|
-
init_messages1 as init_messages,
|
|
10
|
-
normalizeContentFromAPI,
|
|
11
|
-
normalizeMessagesForAPI,
|
|
12
|
-
toolToAPISchema
|
|
13
|
-
} from "./chunk-f2hbn5rk.js";
|
|
14
|
-
import"./chunk-jpc9zwsk.js";
|
|
15
|
-
import"./chunk-hwfknpxv.js";
|
|
16
|
-
import"./chunk-4nspekjp.js";
|
|
17
|
-
import"./chunk-jzthz1bx.js";
|
|
18
|
-
import"./chunk-1gx78081.js";
|
|
19
|
-
import"./chunk-qcnhb4cd.js";
|
|
20
|
-
import"./chunk-s7q42kp2.js";
|
|
21
|
-
import"./chunk-2gzv8nrw.js";
|
|
22
|
-
import"./chunk-ehtwnxpg.js";
|
|
23
|
-
import"./chunk-wr3pd88n.js";
|
|
24
|
-
import"./chunk-wayfjcwt.js";
|
|
25
|
-
import"./chunk-cgfdkzhb.js";
|
|
26
|
-
import"./chunk-bxcfz5gy.js";
|
|
27
|
-
import"./chunk-y0fhjxef.js";
|
|
28
|
-
import"./chunk-j5bth84e.js";
|
|
29
|
-
import"./chunk-nk82j7r2.js";
|
|
30
|
-
import"./chunk-68ffk5qa.js";
|
|
31
|
-
import"./chunk-ps49ymvj.js";
|
|
32
|
-
import"./chunk-p7vkh4wx.js";
|
|
33
|
-
import"./chunk-bmbq6nt1.js";
|
|
34
|
-
import"./chunk-yc23zxmj.js";
|
|
35
|
-
import"./chunk-njrt3tac.js";
|
|
36
|
-
import"./chunk-m87bhhqv.js";
|
|
37
|
-
import"./chunk-xwg327ys.js";
|
|
38
|
-
import"./chunk-xz655xxa.js";
|
|
39
|
-
import"./chunk-c11swzas.js";
|
|
40
|
-
import"./chunk-chsyvavm.js";
|
|
41
|
-
import"./chunk-5rv9c8yd.js";
|
|
42
|
-
import"./chunk-e7efcp3k.js";
|
|
43
|
-
import {
|
|
44
|
-
init_json,
|
|
45
|
-
safeParseJSON
|
|
46
|
-
} from "./chunk-z19sd3bt.js";
|
|
47
|
-
import"./chunk-1ax1znzj.js";
|
|
48
|
-
import"./chunk-6nsd9606.js";
|
|
49
|
-
import"./chunk-xp61y5ba.js";
|
|
50
|
-
import"./chunk-64c1avct.js";
|
|
51
|
-
import {
|
|
52
|
-
getProxyFetchOptions,
|
|
53
|
-
init_proxy
|
|
54
|
-
} from "./chunk-wha6v7za.js";
|
|
55
|
-
import"./chunk-8g5pe1gr.js";
|
|
56
|
-
import"./chunk-4cp6193g.js";
|
|
57
|
-
import"./chunk-8g747a8x.js";
|
|
58
|
-
import"./chunk-d7886r6a.js";
|
|
59
|
-
import"./chunk-yvtzznds.js";
|
|
60
|
-
import"./chunk-4jm600zv.js";
|
|
61
|
-
import"./chunk-qz2x630m.js";
|
|
62
|
-
import"./chunk-2f21meep.js";
|
|
63
|
-
import"./chunk-nrtksr2p.js";
|
|
64
|
-
import"./chunk-3c25bcsw.js";
|
|
65
|
-
import"./chunk-s3hsqf80.js";
|
|
66
|
-
import"./chunk-yyf72f78.js";
|
|
67
|
-
import"./chunk-cdz5yb0r.js";
|
|
68
|
-
import"./chunk-c7jwbe76.js";
|
|
69
|
-
import"./chunk-0vkfrmqm.js";
|
|
70
|
-
import"./chunk-7sgtxrsc.js";
|
|
71
|
-
import"./chunk-0xjaqda8.js";
|
|
72
|
-
import"./chunk-x8d2ehd7.js";
|
|
73
|
-
import"./chunk-15m49c67.js";
|
|
74
|
-
import"./chunk-tdbz9gbm.js";
|
|
75
|
-
import"./chunk-0awwmrwr.js";
|
|
76
|
-
import"./chunk-qnfx3qtx.js";
|
|
77
|
-
import"./chunk-70eey1nh.js";
|
|
78
|
-
import"./chunk-1nk93fqz.js";
|
|
79
|
-
import"./chunk-s8kj6ajy.js";
|
|
80
|
-
import"./chunk-eenq3avg.js";
|
|
81
|
-
import"./chunk-7mqab3z7.js";
|
|
82
|
-
import"./chunk-5z28bqne.js";
|
|
83
|
-
import"./chunk-qajrkk97.js";
|
|
84
|
-
import {
|
|
85
|
-
errorMessage,
|
|
86
|
-
init_debug,
|
|
87
|
-
init_errors,
|
|
88
|
-
logForDebugging
|
|
89
|
-
} from "./chunk-phd1qfpc.js";
|
|
90
|
-
import"./chunk-fbv4apne.js";
|
|
91
|
-
import"./chunk-jaaxk89e.js";
|
|
92
|
-
import"./chunk-k8vp0atq.js";
|
|
93
|
-
import"./chunk-vf612n57.js";
|
|
94
|
-
import"./chunk-07069jq1.js";
|
|
95
|
-
import"./chunk-d4mdda98.js";
|
|
96
|
-
import"./chunk-55raexh7.js";
|
|
97
|
-
import"./chunk-v9smspw2.js";
|
|
98
|
-
import"./chunk-v1kzp02e.js";
|
|
99
|
-
import"./chunk-7wm5s02e.js";
|
|
100
|
-
import"./chunk-b0kf00ff.js";
|
|
101
|
-
import"./chunk-netzwgv1.js";
|
|
102
|
-
import {
|
|
103
|
-
__esm
|
|
104
|
-
} from "./chunk-qp2qdcda.js";
|
|
105
|
-
|
|
106
|
-
// src/services/api/gemini/client.ts
|
|
107
|
-
function getGeminiBaseUrl() {
|
|
108
|
-
return (process.env.GEMINI_BASE_URL || DEFAULT_GEMINI_BASE_URL).replace(/\/+$/, "");
|
|
109
|
-
}
|
|
110
|
-
function getGeminiModelPath(model) {
|
|
111
|
-
const normalized = model.replace(/^\/+/, "");
|
|
112
|
-
return normalized.startsWith("models/") ? normalized : `models/${normalized}`;
|
|
113
|
-
}
|
|
114
|
-
async function* streamGeminiGenerateContent(params) {
|
|
115
|
-
const fetchImpl = params.fetchOverride ?? fetch;
|
|
116
|
-
const url = `${getGeminiBaseUrl()}/${getGeminiModelPath(params.model)}:streamGenerateContent?alt=sse`;
|
|
117
|
-
const response = await fetchImpl(url, {
|
|
118
|
-
method: "POST",
|
|
119
|
-
headers: {
|
|
120
|
-
"Content-Type": "application/json",
|
|
121
|
-
"x-goog-api-key": process.env.GEMINI_API_KEY || ""
|
|
122
|
-
},
|
|
123
|
-
body: JSON.stringify(params.body),
|
|
124
|
-
signal: params.signal,
|
|
125
|
-
...getProxyFetchOptions({ forAnthropicAPI: false })
|
|
126
|
-
});
|
|
127
|
-
if (!response.ok) {
|
|
128
|
-
const body = await response.text();
|
|
129
|
-
throw new Error(`Gemini API request failed (${response.status} ${response.statusText}): ${body || "empty response body"}`);
|
|
130
|
-
}
|
|
131
|
-
if (!response.body) {
|
|
132
|
-
throw new Error("Gemini API returned no response body");
|
|
133
|
-
}
|
|
134
|
-
const reader = response.body.getReader();
|
|
135
|
-
const decoder = new TextDecoder;
|
|
136
|
-
let buffer = "";
|
|
137
|
-
try {
|
|
138
|
-
while (true) {
|
|
139
|
-
const { done, value } = await reader.read();
|
|
140
|
-
if (done)
|
|
141
|
-
break;
|
|
142
|
-
buffer += decoder.decode(value, STREAM_DECODE_OPTS);
|
|
143
|
-
const { frames: frames2, remaining } = parseSSEFrames(buffer);
|
|
144
|
-
buffer = remaining;
|
|
145
|
-
for (const frame of frames2) {
|
|
146
|
-
if (!frame.data || frame.data === "[DONE]")
|
|
147
|
-
continue;
|
|
148
|
-
try {
|
|
149
|
-
yield JSON.parse(frame.data);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
throw new Error(`Failed to parse Gemini SSE payload: ${errorMessage(error)}`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
buffer += decoder.decode();
|
|
156
|
-
const { frames } = parseSSEFrames(buffer);
|
|
157
|
-
for (const frame of frames) {
|
|
158
|
-
if (!frame.data || frame.data === "[DONE]")
|
|
159
|
-
continue;
|
|
160
|
-
try {
|
|
161
|
-
yield JSON.parse(frame.data);
|
|
162
|
-
} catch (error) {
|
|
163
|
-
throw new Error(`Failed to parse trailing Gemini SSE payload: ${errorMessage(error)}`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
} finally {
|
|
167
|
-
reader.releaseLock();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
var DEFAULT_GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta", STREAM_DECODE_OPTS;
|
|
171
|
-
var init_client = __esm(() => {
|
|
172
|
-
init_SSETransport();
|
|
173
|
-
init_errors();
|
|
174
|
-
init_proxy();
|
|
175
|
-
STREAM_DECODE_OPTS = { stream: true };
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
// src/services/api/gemini/types.ts
|
|
179
|
-
var GEMINI_THOUGHT_SIGNATURE_FIELD = "_geminiThoughtSignature";
|
|
180
|
-
var init_types = () => {};
|
|
181
|
-
|
|
182
|
-
// src/services/api/gemini/convertMessages.ts
|
|
183
|
-
function anthropicMessagesToGemini(messages, systemPrompt) {
|
|
184
|
-
const contents = [];
|
|
185
|
-
const toolNamesById = new Map;
|
|
186
|
-
for (const msg of messages) {
|
|
187
|
-
if (msg.type === "assistant") {
|
|
188
|
-
const content = convertInternalAssistantMessage(msg);
|
|
189
|
-
if (content.parts.length > 0) {
|
|
190
|
-
contents.push(content);
|
|
191
|
-
}
|
|
192
|
-
const assistantContent = msg.message.content;
|
|
193
|
-
if (Array.isArray(assistantContent)) {
|
|
194
|
-
for (const block of assistantContent) {
|
|
195
|
-
if (typeof block !== "string" && block.type === "tool_use") {
|
|
196
|
-
toolNamesById.set(block.id, block.name);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
if (msg.type === "user") {
|
|
203
|
-
const content = convertInternalUserMessage(msg, toolNamesById);
|
|
204
|
-
if (content.parts.length > 0) {
|
|
205
|
-
contents.push(content);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
const systemText = systemPromptToText(systemPrompt);
|
|
210
|
-
return {
|
|
211
|
-
contents,
|
|
212
|
-
...systemText ? {
|
|
213
|
-
systemInstruction: {
|
|
214
|
-
parts: [{ text: systemText }]
|
|
215
|
-
}
|
|
216
|
-
} : {}
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
function systemPromptToText(systemPrompt) {
|
|
220
|
-
if (!systemPrompt || systemPrompt.length === 0)
|
|
221
|
-
return "";
|
|
222
|
-
return systemPrompt.filter(Boolean).join(`
|
|
223
|
-
|
|
224
|
-
`);
|
|
225
|
-
}
|
|
226
|
-
function convertInternalUserMessage(msg, toolNamesById) {
|
|
227
|
-
const content = msg.message.content;
|
|
228
|
-
if (typeof content === "string") {
|
|
229
|
-
return {
|
|
230
|
-
role: "user",
|
|
231
|
-
parts: createTextGeminiParts(content)
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
if (!Array.isArray(content)) {
|
|
235
|
-
return { role: "user", parts: [] };
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
role: "user",
|
|
239
|
-
parts: content.flatMap((block) => convertUserContentBlockToGeminiParts(block, toolNamesById))
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
function convertUserContentBlockToGeminiParts(block, toolNamesById) {
|
|
243
|
-
if (typeof block === "string") {
|
|
244
|
-
return createTextGeminiParts(block);
|
|
245
|
-
}
|
|
246
|
-
if (block.type === "text") {
|
|
247
|
-
return createTextGeminiParts(block.text);
|
|
248
|
-
}
|
|
249
|
-
if (block.type === "tool_result") {
|
|
250
|
-
const toolResult = block;
|
|
251
|
-
return [
|
|
252
|
-
{
|
|
253
|
-
functionResponse: {
|
|
254
|
-
name: toolNamesById.get(toolResult.tool_use_id) ?? toolResult.tool_use_id,
|
|
255
|
-
response: toolResultToResponseObject(toolResult)
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
];
|
|
259
|
-
}
|
|
260
|
-
if (block.type === "image") {
|
|
261
|
-
const source = block.source;
|
|
262
|
-
if (source?.type === "base64" && typeof source.data === "string") {
|
|
263
|
-
const mediaType = source.media_type || "image/png";
|
|
264
|
-
return [
|
|
265
|
-
{
|
|
266
|
-
inlineData: {
|
|
267
|
-
mimeType: mediaType,
|
|
268
|
-
data: source.data
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
];
|
|
272
|
-
}
|
|
273
|
-
if (source?.type === "url" && typeof source.url === "string") {
|
|
274
|
-
return createTextGeminiParts(`[image: ${source.url}]`);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return [];
|
|
278
|
-
}
|
|
279
|
-
function convertInternalAssistantMessage(msg) {
|
|
280
|
-
const content = msg.message.content;
|
|
281
|
-
if (typeof content === "string") {
|
|
282
|
-
return {
|
|
283
|
-
role: "model",
|
|
284
|
-
parts: createTextGeminiParts(content)
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
if (!Array.isArray(content)) {
|
|
288
|
-
return { role: "model", parts: [] };
|
|
289
|
-
}
|
|
290
|
-
const parts = [];
|
|
291
|
-
for (const block of content) {
|
|
292
|
-
if (typeof block === "string") {
|
|
293
|
-
parts.push(...createTextGeminiParts(block));
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
if (block.type === "text") {
|
|
297
|
-
parts.push(...createTextGeminiParts(block.text, getGeminiThoughtSignature(block)));
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
if (block.type === "thinking") {
|
|
301
|
-
const thinkingPart = createThinkingGeminiPart(block.thinking, block.signature);
|
|
302
|
-
if (thinkingPart) {
|
|
303
|
-
parts.push(thinkingPart);
|
|
304
|
-
}
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
if (block.type === "tool_use") {
|
|
308
|
-
const toolUse = block;
|
|
309
|
-
parts.push({
|
|
310
|
-
functionCall: {
|
|
311
|
-
name: toolUse.name,
|
|
312
|
-
args: normalizeToolUseInput(toolUse.input)
|
|
313
|
-
},
|
|
314
|
-
...getGeminiThoughtSignature(block) && {
|
|
315
|
-
thoughtSignature: getGeminiThoughtSignature(block)
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return { role: "model", parts };
|
|
321
|
-
}
|
|
322
|
-
function createTextGeminiParts(value, thoughtSignature) {
|
|
323
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
324
|
-
return [];
|
|
325
|
-
}
|
|
326
|
-
return [
|
|
327
|
-
{
|
|
328
|
-
text: value,
|
|
329
|
-
...thoughtSignature && { thoughtSignature }
|
|
330
|
-
}
|
|
331
|
-
];
|
|
332
|
-
}
|
|
333
|
-
function createThinkingGeminiPart(value, thoughtSignature) {
|
|
334
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
return {
|
|
338
|
-
text: value,
|
|
339
|
-
thought: true,
|
|
340
|
-
...thoughtSignature && { thoughtSignature }
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function normalizeToolUseInput(input) {
|
|
344
|
-
if (typeof input === "string") {
|
|
345
|
-
const parsed = safeParseJSON(input);
|
|
346
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
347
|
-
return parsed;
|
|
348
|
-
}
|
|
349
|
-
return parsed === null ? {} : { value: parsed };
|
|
350
|
-
}
|
|
351
|
-
if (input && typeof input === "object" && !Array.isArray(input)) {
|
|
352
|
-
return input;
|
|
353
|
-
}
|
|
354
|
-
return input === undefined ? {} : { value: input };
|
|
355
|
-
}
|
|
356
|
-
function toolResultToResponseObject(block) {
|
|
357
|
-
const result = normalizeToolResultContent(block.content);
|
|
358
|
-
if (result && typeof result === "object" && !Array.isArray(result)) {
|
|
359
|
-
return block.is_error ? { ...result, is_error: true } : result;
|
|
360
|
-
}
|
|
361
|
-
return {
|
|
362
|
-
result,
|
|
363
|
-
...block.is_error ? { is_error: true } : {}
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
function normalizeToolResultContent(content) {
|
|
367
|
-
if (typeof content === "string") {
|
|
368
|
-
const parsed = safeParseJSON(content);
|
|
369
|
-
return parsed ?? content;
|
|
370
|
-
}
|
|
371
|
-
if (Array.isArray(content)) {
|
|
372
|
-
const text = content.map((part) => {
|
|
373
|
-
if (typeof part === "string")
|
|
374
|
-
return part;
|
|
375
|
-
if (part && typeof part === "object" && "text" in part && typeof part.text === "string") {
|
|
376
|
-
return part.text;
|
|
377
|
-
}
|
|
378
|
-
return "";
|
|
379
|
-
}).filter(Boolean).join(`
|
|
380
|
-
`);
|
|
381
|
-
const parsed = safeParseJSON(text);
|
|
382
|
-
return parsed ?? text;
|
|
383
|
-
}
|
|
384
|
-
return content ?? "";
|
|
385
|
-
}
|
|
386
|
-
function getGeminiThoughtSignature(block) {
|
|
387
|
-
const signature = block[GEMINI_THOUGHT_SIGNATURE_FIELD];
|
|
388
|
-
return typeof signature === "string" && signature.length > 0 ? signature : undefined;
|
|
389
|
-
}
|
|
390
|
-
var init_convertMessages = __esm(() => {
|
|
391
|
-
init_json();
|
|
392
|
-
init_types();
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
// src/services/api/gemini/convertTools.ts
|
|
396
|
-
function normalizeGeminiJsonSchemaType(value) {
|
|
397
|
-
if (typeof value === "string") {
|
|
398
|
-
return GEMINI_JSON_SCHEMA_TYPES.has(value) ? value : undefined;
|
|
399
|
-
}
|
|
400
|
-
if (Array.isArray(value)) {
|
|
401
|
-
const normalized = value.filter((item) => typeof item === "string" && GEMINI_JSON_SCHEMA_TYPES.has(item));
|
|
402
|
-
const unique = Array.from(new Set(normalized));
|
|
403
|
-
if (unique.length === 0)
|
|
404
|
-
return;
|
|
405
|
-
return unique.length === 1 ? unique[0] : unique;
|
|
406
|
-
}
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
function inferGeminiJsonSchemaTypeFromValue(value) {
|
|
410
|
-
if (value === null)
|
|
411
|
-
return "null";
|
|
412
|
-
if (Array.isArray(value))
|
|
413
|
-
return "array";
|
|
414
|
-
if (typeof value === "string")
|
|
415
|
-
return "string";
|
|
416
|
-
if (typeof value === "boolean")
|
|
417
|
-
return "boolean";
|
|
418
|
-
if (typeof value === "number") {
|
|
419
|
-
return Number.isInteger(value) ? "integer" : "number";
|
|
420
|
-
}
|
|
421
|
-
if (typeof value === "object")
|
|
422
|
-
return "object";
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
function inferGeminiJsonSchemaTypeFromEnum(values) {
|
|
426
|
-
const inferred = values.map(inferGeminiJsonSchemaTypeFromValue).filter((value) => value !== undefined);
|
|
427
|
-
const unique = Array.from(new Set(inferred));
|
|
428
|
-
if (unique.length === 0)
|
|
429
|
-
return;
|
|
430
|
-
return unique.length === 1 ? unique[0] : unique;
|
|
431
|
-
}
|
|
432
|
-
function addNullToGeminiJsonSchemaType(value) {
|
|
433
|
-
if (value === undefined)
|
|
434
|
-
return ["null"];
|
|
435
|
-
if (Array.isArray(value)) {
|
|
436
|
-
return value.includes("null") ? value : [...value, "null"];
|
|
437
|
-
}
|
|
438
|
-
return value === "null" ? value : [value, "null"];
|
|
439
|
-
}
|
|
440
|
-
function sanitizeGeminiJsonSchemaProperties(value) {
|
|
441
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
const sanitizedEntries = Object.entries(value).map(([key, schema]) => [key, sanitizeGeminiJsonSchema(schema)]).filter(([, schema]) => Object.keys(schema).length > 0);
|
|
445
|
-
if (sanitizedEntries.length === 0) {
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
return Object.fromEntries(sanitizedEntries);
|
|
449
|
-
}
|
|
450
|
-
function sanitizeGeminiJsonSchemaArray(value) {
|
|
451
|
-
if (!Array.isArray(value))
|
|
452
|
-
return;
|
|
453
|
-
const sanitized = value.map((item) => sanitizeGeminiJsonSchema(item)).filter((item) => Object.keys(item).length > 0);
|
|
454
|
-
return sanitized.length > 0 ? sanitized : undefined;
|
|
455
|
-
}
|
|
456
|
-
function sanitizeGeminiJsonSchema(schema) {
|
|
457
|
-
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|
|
458
|
-
return {};
|
|
459
|
-
}
|
|
460
|
-
const source = schema;
|
|
461
|
-
const result = {};
|
|
462
|
-
let type = normalizeGeminiJsonSchemaType(source.type);
|
|
463
|
-
if (source.const !== undefined) {
|
|
464
|
-
result.enum = [source.const];
|
|
465
|
-
type = type ?? inferGeminiJsonSchemaTypeFromValue(source.const);
|
|
466
|
-
} else if (Array.isArray(source.enum) && source.enum.length > 0) {
|
|
467
|
-
result.enum = source.enum;
|
|
468
|
-
type = type ?? inferGeminiJsonSchemaTypeFromEnum(source.enum);
|
|
469
|
-
}
|
|
470
|
-
if (!type) {
|
|
471
|
-
if (source.properties && typeof source.properties === "object") {
|
|
472
|
-
type = "object";
|
|
473
|
-
} else if (source.items !== undefined || source.prefixItems !== undefined) {
|
|
474
|
-
type = "array";
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
if (source.nullable === true) {
|
|
478
|
-
type = addNullToGeminiJsonSchemaType(type);
|
|
479
|
-
}
|
|
480
|
-
if (type) {
|
|
481
|
-
result.type = type;
|
|
482
|
-
}
|
|
483
|
-
if (typeof source.title === "string") {
|
|
484
|
-
result.title = source.title;
|
|
485
|
-
}
|
|
486
|
-
if (typeof source.description === "string") {
|
|
487
|
-
result.description = source.description;
|
|
488
|
-
}
|
|
489
|
-
if (typeof source.format === "string") {
|
|
490
|
-
result.format = source.format;
|
|
491
|
-
}
|
|
492
|
-
if (typeof source.pattern === "string") {
|
|
493
|
-
result.pattern = source.pattern;
|
|
494
|
-
}
|
|
495
|
-
if (typeof source.minimum === "number") {
|
|
496
|
-
result.minimum = source.minimum;
|
|
497
|
-
} else if (typeof source.exclusiveMinimum === "number") {
|
|
498
|
-
result.minimum = source.exclusiveMinimum;
|
|
499
|
-
}
|
|
500
|
-
if (typeof source.maximum === "number") {
|
|
501
|
-
result.maximum = source.maximum;
|
|
502
|
-
} else if (typeof source.exclusiveMaximum === "number") {
|
|
503
|
-
result.maximum = source.exclusiveMaximum;
|
|
504
|
-
}
|
|
505
|
-
if (typeof source.minItems === "number") {
|
|
506
|
-
result.minItems = source.minItems;
|
|
507
|
-
}
|
|
508
|
-
if (typeof source.maxItems === "number") {
|
|
509
|
-
result.maxItems = source.maxItems;
|
|
510
|
-
}
|
|
511
|
-
if (typeof source.minLength === "number") {
|
|
512
|
-
result.minLength = source.minLength;
|
|
513
|
-
}
|
|
514
|
-
if (typeof source.maxLength === "number") {
|
|
515
|
-
result.maxLength = source.maxLength;
|
|
516
|
-
}
|
|
517
|
-
if (typeof source.minProperties === "number") {
|
|
518
|
-
result.minProperties = source.minProperties;
|
|
519
|
-
}
|
|
520
|
-
if (typeof source.maxProperties === "number") {
|
|
521
|
-
result.maxProperties = source.maxProperties;
|
|
522
|
-
}
|
|
523
|
-
const properties = sanitizeGeminiJsonSchemaProperties(source.properties);
|
|
524
|
-
if (properties) {
|
|
525
|
-
result.properties = properties;
|
|
526
|
-
result.propertyOrdering = Object.keys(properties);
|
|
527
|
-
}
|
|
528
|
-
if (Array.isArray(source.required)) {
|
|
529
|
-
const required = source.required.filter((item) => typeof item === "string");
|
|
530
|
-
if (required.length > 0) {
|
|
531
|
-
result.required = required;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
if (typeof source.additionalProperties === "boolean") {
|
|
535
|
-
result.additionalProperties = source.additionalProperties;
|
|
536
|
-
} else {
|
|
537
|
-
const additionalProperties = sanitizeGeminiJsonSchema(source.additionalProperties);
|
|
538
|
-
if (Object.keys(additionalProperties).length > 0) {
|
|
539
|
-
result.additionalProperties = additionalProperties;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
const items = sanitizeGeminiJsonSchema(source.items);
|
|
543
|
-
if (Object.keys(items).length > 0) {
|
|
544
|
-
result.items = items;
|
|
545
|
-
}
|
|
546
|
-
const prefixItems = sanitizeGeminiJsonSchemaArray(source.prefixItems);
|
|
547
|
-
if (prefixItems) {
|
|
548
|
-
result.prefixItems = prefixItems;
|
|
549
|
-
}
|
|
550
|
-
const anyOf = sanitizeGeminiJsonSchemaArray(source.anyOf ?? source.oneOf);
|
|
551
|
-
if (anyOf) {
|
|
552
|
-
result.anyOf = anyOf;
|
|
553
|
-
}
|
|
554
|
-
return result;
|
|
555
|
-
}
|
|
556
|
-
function sanitizeGeminiFunctionParameters(schema) {
|
|
557
|
-
const sanitized = sanitizeGeminiJsonSchema(schema);
|
|
558
|
-
if (Object.keys(sanitized).length > 0) {
|
|
559
|
-
return sanitized;
|
|
560
|
-
}
|
|
561
|
-
return {
|
|
562
|
-
type: "object",
|
|
563
|
-
properties: {}
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
function anthropicToolsToGemini(tools) {
|
|
567
|
-
const functionDeclarations = tools.filter((tool) => {
|
|
568
|
-
return tool.type === "custom" || !("type" in tool) || tool.type !== "server";
|
|
569
|
-
}).map((tool) => {
|
|
570
|
-
const anyTool = tool;
|
|
571
|
-
const name = anyTool.name || "";
|
|
572
|
-
const description = anyTool.description || "";
|
|
573
|
-
const inputSchema = anyTool.input_schema ?? {
|
|
574
|
-
type: "object",
|
|
575
|
-
properties: {}
|
|
576
|
-
};
|
|
577
|
-
return {
|
|
578
|
-
name,
|
|
579
|
-
description,
|
|
580
|
-
parametersJsonSchema: sanitizeGeminiFunctionParameters(inputSchema)
|
|
581
|
-
};
|
|
582
|
-
});
|
|
583
|
-
return functionDeclarations.length > 0 ? [{ functionDeclarations }] : [];
|
|
584
|
-
}
|
|
585
|
-
function anthropicToolChoiceToGemini(toolChoice) {
|
|
586
|
-
if (!toolChoice || typeof toolChoice !== "object")
|
|
587
|
-
return;
|
|
588
|
-
const tc = toolChoice;
|
|
589
|
-
const type = tc.type;
|
|
590
|
-
switch (type) {
|
|
591
|
-
case "auto":
|
|
592
|
-
return { mode: "AUTO" };
|
|
593
|
-
case "any":
|
|
594
|
-
return { mode: "ANY" };
|
|
595
|
-
case "tool":
|
|
596
|
-
return {
|
|
597
|
-
mode: "ANY",
|
|
598
|
-
allowedFunctionNames: typeof tc.name === "string" ? [tc.name] : undefined
|
|
599
|
-
};
|
|
600
|
-
default:
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
var GEMINI_JSON_SCHEMA_TYPES;
|
|
605
|
-
var init_convertTools = __esm(() => {
|
|
606
|
-
GEMINI_JSON_SCHEMA_TYPES = new Set([
|
|
607
|
-
"string",
|
|
608
|
-
"number",
|
|
609
|
-
"integer",
|
|
610
|
-
"boolean",
|
|
611
|
-
"object",
|
|
612
|
-
"array",
|
|
613
|
-
"null"
|
|
614
|
-
]);
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
// src/services/api/gemini/modelMapping.ts
|
|
618
|
-
function getModelFamily(model) {
|
|
619
|
-
if (/haiku/i.test(model))
|
|
620
|
-
return "haiku";
|
|
621
|
-
if (/opus/i.test(model))
|
|
622
|
-
return "opus";
|
|
623
|
-
if (/sonnet/i.test(model))
|
|
624
|
-
return "sonnet";
|
|
625
|
-
return null;
|
|
626
|
-
}
|
|
627
|
-
function resolveGeminiModel(anthropicModel) {
|
|
628
|
-
if (process.env.GEMINI_MODEL) {
|
|
629
|
-
return process.env.GEMINI_MODEL;
|
|
630
|
-
}
|
|
631
|
-
const cleanModel = anthropicModel.replace(/\[1m\]$/i, "");
|
|
632
|
-
const family = getModelFamily(cleanModel);
|
|
633
|
-
if (!family) {
|
|
634
|
-
return cleanModel;
|
|
635
|
-
}
|
|
636
|
-
const geminiEnvVar = `GEMINI_DEFAULT_${family.toUpperCase()}_MODEL`;
|
|
637
|
-
const geminiModel = process.env[geminiEnvVar];
|
|
638
|
-
if (geminiModel) {
|
|
639
|
-
return geminiModel;
|
|
640
|
-
}
|
|
641
|
-
const sharedEnvVar = `ANTHROPIC_DEFAULT_${family.toUpperCase()}_MODEL`;
|
|
642
|
-
const resolvedModel = process.env[sharedEnvVar];
|
|
643
|
-
if (resolvedModel) {
|
|
644
|
-
return resolvedModel;
|
|
645
|
-
}
|
|
646
|
-
throw new Error(`Gemini provider requires GEMINI_MODEL or ${geminiEnvVar} (or ${sharedEnvVar} for backward compatibility) to be configured.`);
|
|
647
|
-
}
|
|
648
|
-
var init_modelMapping = () => {};
|
|
649
|
-
|
|
650
|
-
// src/services/api/gemini/streamAdapter.ts
|
|
651
|
-
import { randomUUID } from "crypto";
|
|
652
|
-
async function* adaptGeminiStreamToAnthropic(stream, model) {
|
|
653
|
-
const messageId = `msg_${randomUUID().replace(/-/g, "").slice(0, 24)}`;
|
|
654
|
-
let started = false;
|
|
655
|
-
let stopped = false;
|
|
656
|
-
let nextContentIndex = 0;
|
|
657
|
-
let openTextLikeBlock = null;
|
|
658
|
-
let sawToolUse = false;
|
|
659
|
-
let finishReason;
|
|
660
|
-
let inputTokens = 0;
|
|
661
|
-
let outputTokens = 0;
|
|
662
|
-
for await (const chunk of stream) {
|
|
663
|
-
const usage = chunk.usageMetadata;
|
|
664
|
-
if (usage) {
|
|
665
|
-
inputTokens = usage.promptTokenCount ?? inputTokens;
|
|
666
|
-
outputTokens = (usage.candidatesTokenCount ?? 0) + (usage.thoughtsTokenCount ?? 0);
|
|
667
|
-
}
|
|
668
|
-
if (!started) {
|
|
669
|
-
started = true;
|
|
670
|
-
yield {
|
|
671
|
-
type: "message_start",
|
|
672
|
-
message: {
|
|
673
|
-
id: messageId,
|
|
674
|
-
type: "message",
|
|
675
|
-
role: "assistant",
|
|
676
|
-
content: [],
|
|
677
|
-
model,
|
|
678
|
-
stop_reason: null,
|
|
679
|
-
stop_sequence: null,
|
|
680
|
-
usage: {
|
|
681
|
-
input_tokens: inputTokens,
|
|
682
|
-
output_tokens: 0,
|
|
683
|
-
cache_creation_input_tokens: 0,
|
|
684
|
-
cache_read_input_tokens: 0
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
const candidate = chunk.candidates?.[0];
|
|
690
|
-
const parts = candidate?.content?.parts ?? [];
|
|
691
|
-
for (const part of parts) {
|
|
692
|
-
if (part.functionCall) {
|
|
693
|
-
if (openTextLikeBlock) {
|
|
694
|
-
yield {
|
|
695
|
-
type: "content_block_stop",
|
|
696
|
-
index: openTextLikeBlock.index
|
|
697
|
-
};
|
|
698
|
-
openTextLikeBlock = null;
|
|
699
|
-
}
|
|
700
|
-
sawToolUse = true;
|
|
701
|
-
const toolIndex = nextContentIndex++;
|
|
702
|
-
const toolId = `toolu_${randomUUID().replace(/-/g, "").slice(0, 24)}`;
|
|
703
|
-
yield {
|
|
704
|
-
type: "content_block_start",
|
|
705
|
-
index: toolIndex,
|
|
706
|
-
content_block: {
|
|
707
|
-
type: "tool_use",
|
|
708
|
-
id: toolId,
|
|
709
|
-
name: part.functionCall.name || "",
|
|
710
|
-
input: {}
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
if (part.thoughtSignature) {
|
|
714
|
-
yield {
|
|
715
|
-
type: "content_block_delta",
|
|
716
|
-
index: toolIndex,
|
|
717
|
-
delta: {
|
|
718
|
-
type: "signature_delta",
|
|
719
|
-
signature: part.thoughtSignature
|
|
720
|
-
}
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
if (part.functionCall.args && Object.keys(part.functionCall.args).length > 0) {
|
|
724
|
-
yield {
|
|
725
|
-
type: "content_block_delta",
|
|
726
|
-
index: toolIndex,
|
|
727
|
-
delta: {
|
|
728
|
-
type: "input_json_delta",
|
|
729
|
-
partial_json: JSON.stringify(part.functionCall.args)
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
yield {
|
|
734
|
-
type: "content_block_stop",
|
|
735
|
-
index: toolIndex
|
|
736
|
-
};
|
|
737
|
-
continue;
|
|
738
|
-
}
|
|
739
|
-
const textLikeType = getTextLikeBlockType(part);
|
|
740
|
-
if (textLikeType) {
|
|
741
|
-
if (!openTextLikeBlock || openTextLikeBlock.type !== textLikeType) {
|
|
742
|
-
if (openTextLikeBlock) {
|
|
743
|
-
yield {
|
|
744
|
-
type: "content_block_stop",
|
|
745
|
-
index: openTextLikeBlock.index
|
|
746
|
-
};
|
|
747
|
-
}
|
|
748
|
-
openTextLikeBlock = {
|
|
749
|
-
index: nextContentIndex++,
|
|
750
|
-
type: textLikeType
|
|
751
|
-
};
|
|
752
|
-
yield {
|
|
753
|
-
type: "content_block_start",
|
|
754
|
-
index: openTextLikeBlock.index,
|
|
755
|
-
content_block: textLikeType === "thinking" ? {
|
|
756
|
-
type: "thinking",
|
|
757
|
-
thinking: "",
|
|
758
|
-
signature: ""
|
|
759
|
-
} : {
|
|
760
|
-
type: "text",
|
|
761
|
-
text: ""
|
|
762
|
-
}
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
if (part.text) {
|
|
766
|
-
yield {
|
|
767
|
-
type: "content_block_delta",
|
|
768
|
-
index: openTextLikeBlock.index,
|
|
769
|
-
delta: textLikeType === "thinking" ? {
|
|
770
|
-
type: "thinking_delta",
|
|
771
|
-
thinking: part.text
|
|
772
|
-
} : {
|
|
773
|
-
type: "text_delta",
|
|
774
|
-
text: part.text
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
if (part.thoughtSignature) {
|
|
779
|
-
yield {
|
|
780
|
-
type: "content_block_delta",
|
|
781
|
-
index: openTextLikeBlock.index,
|
|
782
|
-
delta: {
|
|
783
|
-
type: "signature_delta",
|
|
784
|
-
signature: part.thoughtSignature
|
|
785
|
-
}
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
|
-
continue;
|
|
789
|
-
}
|
|
790
|
-
if (part.thoughtSignature && openTextLikeBlock) {
|
|
791
|
-
yield {
|
|
792
|
-
type: "content_block_delta",
|
|
793
|
-
index: openTextLikeBlock.index,
|
|
794
|
-
delta: {
|
|
795
|
-
type: "signature_delta",
|
|
796
|
-
signature: part.thoughtSignature
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
if (candidate?.finishReason) {
|
|
802
|
-
finishReason = candidate.finishReason;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
if (!started) {
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
if (openTextLikeBlock) {
|
|
809
|
-
yield {
|
|
810
|
-
type: "content_block_stop",
|
|
811
|
-
index: openTextLikeBlock.index
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
if (!stopped) {
|
|
815
|
-
yield {
|
|
816
|
-
type: "message_delta",
|
|
817
|
-
delta: {
|
|
818
|
-
stop_reason: mapGeminiFinishReason(finishReason, sawToolUse),
|
|
819
|
-
stop_sequence: null
|
|
820
|
-
},
|
|
821
|
-
usage: {
|
|
822
|
-
output_tokens: outputTokens
|
|
823
|
-
}
|
|
824
|
-
};
|
|
825
|
-
yield {
|
|
826
|
-
type: "message_stop"
|
|
827
|
-
};
|
|
828
|
-
stopped = true;
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
function getTextLikeBlockType(part) {
|
|
832
|
-
if (typeof part.text !== "string") {
|
|
833
|
-
return null;
|
|
834
|
-
}
|
|
835
|
-
return part.thought ? "thinking" : "text";
|
|
836
|
-
}
|
|
837
|
-
function mapGeminiFinishReason(reason, sawToolUse) {
|
|
838
|
-
switch (reason) {
|
|
839
|
-
case "MAX_TOKENS":
|
|
840
|
-
return "max_tokens";
|
|
841
|
-
case "STOP":
|
|
842
|
-
case "FINISH_REASON_UNSPECIFIED":
|
|
843
|
-
case "SAFETY":
|
|
844
|
-
case "RECITATION":
|
|
845
|
-
case "BLOCKLIST":
|
|
846
|
-
case "PROHIBITED_CONTENT":
|
|
847
|
-
case "SPII":
|
|
848
|
-
case "MALFORMED_FUNCTION_CALL":
|
|
849
|
-
default:
|
|
850
|
-
return sawToolUse ? "tool_use" : "end_turn";
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
var init_streamAdapter = () => {};
|
|
854
|
-
|
|
855
|
-
// src/services/api/gemini/index.ts
|
|
856
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
857
|
-
async function* queryModelGemini(messages, systemPrompt, tools, signal, options, thinkingConfig) {
|
|
858
|
-
try {
|
|
859
|
-
const geminiModel = resolveGeminiModel(options.model);
|
|
860
|
-
const messagesForAPI = normalizeMessagesForAPI(messages, tools);
|
|
861
|
-
const toolSchemas = await Promise.all(tools.map((tool) => toolToAPISchema(tool, {
|
|
862
|
-
getToolPermissionContext: options.getToolPermissionContext,
|
|
863
|
-
tools,
|
|
864
|
-
agents: options.agents,
|
|
865
|
-
allowedAgentTypes: options.allowedAgentTypes,
|
|
866
|
-
model: options.model
|
|
867
|
-
})));
|
|
868
|
-
const standardTools = toolSchemas.filter((t) => {
|
|
869
|
-
const anyTool = t;
|
|
870
|
-
return anyTool.type !== "advisor_20260301" && anyTool.type !== "computer_20250124";
|
|
871
|
-
});
|
|
872
|
-
const { contents, systemInstruction } = anthropicMessagesToGemini(messagesForAPI, systemPrompt);
|
|
873
|
-
const geminiTools = anthropicToolsToGemini(standardTools);
|
|
874
|
-
const toolChoice = anthropicToolChoiceToGemini(options.toolChoice);
|
|
875
|
-
const stream = streamGeminiGenerateContent({
|
|
876
|
-
model: geminiModel,
|
|
877
|
-
signal,
|
|
878
|
-
fetchOverride: options.fetchOverride,
|
|
879
|
-
body: {
|
|
880
|
-
contents,
|
|
881
|
-
...systemInstruction && { systemInstruction },
|
|
882
|
-
...geminiTools.length > 0 && { tools: geminiTools },
|
|
883
|
-
...toolChoice && {
|
|
884
|
-
toolConfig: {
|
|
885
|
-
functionCallingConfig: toolChoice
|
|
886
|
-
}
|
|
887
|
-
},
|
|
888
|
-
generationConfig: {
|
|
889
|
-
...options.temperatureOverride !== undefined && {
|
|
890
|
-
temperature: options.temperatureOverride
|
|
891
|
-
},
|
|
892
|
-
...thinkingConfig.type !== "disabled" && {
|
|
893
|
-
thinkingConfig: {
|
|
894
|
-
includeThoughts: true,
|
|
895
|
-
...thinkingConfig.type === "enabled" && {
|
|
896
|
-
thinkingBudget: thinkingConfig.budgetTokens
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
});
|
|
903
|
-
logForDebugging(`[Gemini] Calling model=${geminiModel}, messages=${contents.length}, tools=${geminiTools.length}`);
|
|
904
|
-
const adaptedStream = adaptGeminiStreamToAnthropic(stream, geminiModel);
|
|
905
|
-
const contentBlocks = {};
|
|
906
|
-
let partialMessage = undefined;
|
|
907
|
-
let ttftMs = 0;
|
|
908
|
-
const start = Date.now();
|
|
909
|
-
for await (const event of adaptedStream) {
|
|
910
|
-
switch (event.type) {
|
|
911
|
-
case "message_start":
|
|
912
|
-
partialMessage = event.message;
|
|
913
|
-
ttftMs = Date.now() - start;
|
|
914
|
-
break;
|
|
915
|
-
case "content_block_start": {
|
|
916
|
-
const idx = event.index;
|
|
917
|
-
const cb = event.content_block;
|
|
918
|
-
if (cb.type === "tool_use") {
|
|
919
|
-
contentBlocks[idx] = { ...cb, input: "" };
|
|
920
|
-
} else if (cb.type === "text") {
|
|
921
|
-
contentBlocks[idx] = { ...cb, text: "" };
|
|
922
|
-
} else if (cb.type === "thinking") {
|
|
923
|
-
contentBlocks[idx] = { ...cb, thinking: "", signature: "" };
|
|
924
|
-
} else {
|
|
925
|
-
contentBlocks[idx] = { ...cb };
|
|
926
|
-
}
|
|
927
|
-
break;
|
|
928
|
-
}
|
|
929
|
-
case "content_block_delta": {
|
|
930
|
-
const idx = event.index;
|
|
931
|
-
const delta = event.delta;
|
|
932
|
-
const block = contentBlocks[idx];
|
|
933
|
-
if (!block)
|
|
934
|
-
break;
|
|
935
|
-
if (delta.type === "text_delta") {
|
|
936
|
-
block.text = (block.text || "") + delta.text;
|
|
937
|
-
} else if (delta.type === "input_json_delta") {
|
|
938
|
-
block.input = (block.input || "") + delta.partial_json;
|
|
939
|
-
} else if (delta.type === "thinking_delta") {
|
|
940
|
-
block.thinking = (block.thinking || "") + delta.thinking;
|
|
941
|
-
} else if (delta.type === "signature_delta") {
|
|
942
|
-
if (block.type === "thinking") {
|
|
943
|
-
block.signature = delta.signature;
|
|
944
|
-
} else {
|
|
945
|
-
block[GEMINI_THOUGHT_SIGNATURE_FIELD] = delta.signature;
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
break;
|
|
949
|
-
}
|
|
950
|
-
case "content_block_stop": {
|
|
951
|
-
const idx = event.index;
|
|
952
|
-
const block = contentBlocks[idx];
|
|
953
|
-
if (!block || !partialMessage)
|
|
954
|
-
break;
|
|
955
|
-
const message = {
|
|
956
|
-
message: {
|
|
957
|
-
...partialMessage,
|
|
958
|
-
content: normalizeContentFromAPI([block], tools, options.agentId)
|
|
959
|
-
},
|
|
960
|
-
requestId: undefined,
|
|
961
|
-
type: "assistant",
|
|
962
|
-
uuid: randomUUID2(),
|
|
963
|
-
timestamp: new Date().toISOString()
|
|
964
|
-
};
|
|
965
|
-
yield message;
|
|
966
|
-
break;
|
|
967
|
-
}
|
|
968
|
-
case "message_delta":
|
|
969
|
-
case "message_stop":
|
|
970
|
-
break;
|
|
971
|
-
}
|
|
972
|
-
yield {
|
|
973
|
-
type: "stream_event",
|
|
974
|
-
event,
|
|
975
|
-
...event.type === "message_start" ? { ttftMs } : undefined
|
|
976
|
-
};
|
|
977
|
-
}
|
|
978
|
-
} catch (error) {
|
|
979
|
-
const errorMessage2 = error instanceof Error ? error.message : String(error);
|
|
980
|
-
logForDebugging(`[Gemini] Error: ${errorMessage2}`, { level: "error" });
|
|
981
|
-
yield createAssistantAPIErrorMessage({
|
|
982
|
-
content: `API Error: ${errorMessage2}`,
|
|
983
|
-
apiError: "api_error",
|
|
984
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
var init_gemini = __esm(() => {
|
|
989
|
-
init_api();
|
|
990
|
-
init_debug();
|
|
991
|
-
init_messages();
|
|
992
|
-
init_client();
|
|
993
|
-
init_convertMessages();
|
|
994
|
-
init_convertTools();
|
|
995
|
-
init_modelMapping();
|
|
996
|
-
init_streamAdapter();
|
|
997
|
-
init_types();
|
|
998
|
-
});
|
|
999
|
-
init_gemini();
|
|
1000
|
-
|
|
1001
|
-
export {
|
|
1002
|
-
queryModelGemini
|
|
1003
|
-
};
|