@caspian2026/agent-sdk 0.0.20 → 0.0.21
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-q8t0ym9s.js → chunk-06xmvpv7.js} +83 -83
- package/dist/{chunk-5gr6ekgm.js → chunk-07069jq1.js} +4 -4
- package/dist/{chunk-ckrs789w.js → chunk-0731m51q.js} +1 -1
- package/dist/chunk-079tw1d6.js +155 -0
- package/dist/{chunk-w2bff8pq.js → chunk-08prz7zp.js} +12 -12
- package/dist/chunk-0hqv6vq3.js +127 -0
- package/dist/{chunk-qqc3b97c.js → chunk-0paqc2yw.js} +1 -1
- package/dist/{chunk-t83amzhd.js → chunk-0r5bb9j4.js} +12 -12
- package/dist/chunk-0rbxzwnb.js +146 -0
- package/dist/chunk-0t81d427.js +41 -0
- package/dist/{chunk-2mfzqkzn.js → chunk-0vkfrmqm.js} +29 -69
- package/dist/{chunk-bs9rn85s.js → chunk-0vp3wfab.js} +1 -1
- package/dist/{chunk-6rcf54zd.js → chunk-0xjaqda8.js} +27 -48
- package/dist/chunk-102ee39t.js +97 -0
- package/dist/chunk-1058brys.js +54 -0
- package/dist/{chunk-ekewg3tj.js → chunk-14qkwgmf.js} +4 -4
- package/dist/{chunk-2b00k9ep.js → chunk-1871fy77.js} +78 -78
- package/dist/{chunk-y83gxqvc.js → chunk-1ae3nt9j.js} +3 -3
- package/dist/{chunk-t3yc7m07.js → chunk-1gx78081.js} +1 -1
- package/dist/{chunk-d99k9r9g.js → chunk-1h2famwb.js} +1 -1
- package/dist/{chunk-vv84k232.js → chunk-1ksywqf6.js} +5 -5
- package/dist/{chunk-6hs3wed5.js → chunk-1q2taz28.js} +7 -7
- package/dist/{chunk-cgzq4zww.js → chunk-21jaw3mt.js} +4 -4
- package/dist/{chunk-ra9hbfyz.js → chunk-24q2kxjm.js} +3 -3
- package/dist/{chunk-ja23mty8.js → chunk-25s7wwvz.js} +83 -83
- package/dist/{chunk-xm9zf0tv.js → chunk-26b7qsct.js} +78 -78
- package/dist/{chunk-e7j6g62d.js → chunk-26sypsqa.js} +10 -11
- package/dist/{chunk-xkra2684.js → chunk-26vzce3s.js} +86 -85
- package/dist/{chunk-ynx3fetd.js → chunk-26wtxbdc.js} +463 -1222
- package/dist/chunk-27dhfb9v.js +77 -0
- package/dist/{chunk-k6cq3j7z.js → chunk-2fwze72g.js} +1 -1
- package/dist/{chunk-rrtpbztr.js → chunk-2gzv8nrw.js} +3 -4
- package/dist/chunk-2mdzhnxj.js +88 -0
- package/dist/{chunk-9b71sn2g.js → chunk-2qghgd3d.js} +41 -41
- package/dist/{chunk-k8by1vfd.js → chunk-2qkcx6gx.js} +19 -19
- package/dist/chunk-2xes6j9k.js +121 -0
- package/dist/{chunk-zp5nvg44.js → chunk-33e7y2ye.js} +2 -2
- package/dist/{chunk-1t3cyn1k.js → chunk-3c25bcsw.js} +1 -1
- package/dist/{chunk-nwdpjkrw.js → chunk-3csagva2.js} +78 -78
- package/dist/{chunk-60a647ty.js → chunk-3jwpbxxx.js} +81 -81
- package/dist/chunk-3mgywd32.js +8 -0
- package/dist/{chunk-52pp0dbk.js → chunk-3mqgy4d8.js} +4 -4
- package/dist/{chunk-568q88qz.js → chunk-3nk79af8.js} +1 -1
- package/dist/chunk-3pm48qgm.js +97 -0
- package/dist/{chunk-rzk001ay.js → chunk-3tx97a7z.js} +85 -85
- package/dist/{chunk-8ady2sm4.js → chunk-3vy1jt9p.js} +8 -8
- package/dist/{chunk-sthmb4xf.js → chunk-3w6dvw7z.js} +78 -78
- package/dist/{chunk-s201s689.js → chunk-40p1xyv4.js} +18 -18
- package/dist/{chunk-j77g2v22.js → chunk-4621eys4.js} +5 -5
- package/dist/{chunk-7deqmrby.js → chunk-46y1vrxs.js} +6 -6
- package/dist/{chunk-khwhppzs.js → chunk-49ce42vr.js} +2 -2
- package/dist/{chunk-6qb753r5.js → chunk-4bjfp2cp.js} +79 -79
- package/dist/{chunk-m6vs965c.js → chunk-4jm600zv.js} +1 -1
- package/dist/{chunk-v2szqm5g.js → chunk-4k9d7gxv.js} +5 -5
- package/dist/{chunk-pqf2bjy1.js → chunk-4nyewkpd.js} +4 -4
- package/dist/{chunk-f79jyxwd.js → chunk-4pbx3g7s.js} +4 -4
- package/dist/{chunk-qrgxbrs9.js → chunk-4sk0ekmh.js} +9810 -2820
- package/dist/{chunk-n3vmrzcy.js → chunk-4th9sgzv.js} +5 -5
- package/dist/{chunk-9drwsb3g.js → chunk-50cqjkgy.js} +80 -80
- package/dist/{chunk-xyzbgjpv.js → chunk-530bp1wc.js} +2 -2
- package/dist/{chunk-tnpk0ne1.js → chunk-55raexh7.js} +935 -2391
- package/dist/{chunk-bbhg7m1a.js → chunk-59564wn5.js} +79 -79
- package/dist/{chunk-z9v4bxrj.js → chunk-5ccdsxgy.js} +3 -3
- package/dist/{chunk-3k8ecscj.js → chunk-5e4jj4hd.js} +78 -78
- package/dist/{chunk-zqajmq38.js → chunk-5ekyhb1w.js} +6 -6
- package/dist/chunk-5h4berfm.js +30 -0
- package/dist/{chunk-t8chhacb.js → chunk-5h5kx2jd.js} +2 -2
- package/dist/chunk-5jkawn33.js +71 -0
- package/dist/{chunk-5v6wr1z4.js → chunk-5n1jc02d.js} +2 -2
- package/dist/{chunk-x09aacvx.js → chunk-5wnkq46y.js} +5 -5
- package/dist/{chunk-r585pc0g.js → chunk-5z28bqne.js} +3 -4
- package/dist/{chunk-gbvmks09.js → chunk-64c1avct.js} +1 -1
- package/dist/{chunk-y8b45mt2.js → chunk-64r16v22.js} +4 -4
- package/dist/{chunk-ej882sb5.js → chunk-65w2019d.js} +26 -26
- package/dist/{chunk-m82ketm1.js → chunk-66wbs5de.js} +78 -78
- package/dist/{chunk-f517h74h.js → chunk-66zry909.js} +1 -1
- package/dist/{chunk-kjx9a9p4.js → chunk-68ffk5qa.js} +2 -2
- package/dist/{chunk-bstyysxw.js → chunk-68ypktng.js} +3 -3
- package/dist/{chunk-xygy5v97.js → chunk-69bms9eh.js} +30 -30
- package/dist/{chunk-5vavvf6y.js → chunk-69n11zng.js} +5 -5
- package/dist/{chunk-7wegz81g.js → chunk-6dj5t602.js} +1 -1
- package/dist/{chunk-vnrevqdf.js → chunk-6dngjwkh.js} +4 -4
- package/dist/{chunk-7kp42hzq.js → chunk-6nsd9606.js} +2 -2
- package/dist/chunk-7641fj0b.js +107 -0
- package/dist/{chunk-fdwtd6s9.js → chunk-7aw745vx.js} +3 -3
- package/dist/{chunk-dv38yqdn.js → chunk-7gy9xrjc.js} +3 -3
- package/dist/{chunk-93hxjnkb.js → chunk-7k74bhsg.js} +78 -78
- package/dist/{chunk-1s9jxpjm.js → chunk-7pz9rdg8.js} +7 -7
- package/dist/{chunk-vd5dh925.js → chunk-7ry9qp54.js} +78 -78
- package/dist/{chunk-8q5fzyem.js → chunk-7sgtxrsc.js} +8 -10
- package/dist/{chunk-vx28ztc7.js → chunk-7v902gw4.js} +20 -20
- package/dist/chunk-7vhfhyq0.js +123 -0
- package/dist/{chunk-dmp3nd67.js → chunk-7w4n7zr8.js} +90 -90
- package/dist/{chunk-7yexhdjs.js → chunk-7wm5s02e.js} +1 -1
- package/dist/{chunk-wfh12nzh.js → chunk-7xyswgjh.js} +1 -1
- package/dist/{chunk-bdhdmkya.js → chunk-83hfzbx3.js} +1 -1
- package/dist/chunk-86fwp0mg.js +148 -0
- package/dist/{chunk-tevzn1xp.js → chunk-8g5pe1gr.js} +1 -1
- package/dist/{chunk-6twsw69m.js → chunk-8knpmkt5.js} +7 -7
- package/dist/chunk-8mpv3j7b.js +105 -0
- package/dist/chunk-8scyf6tf.js +90 -0
- package/dist/{chunk-xj8tk3d7.js → chunk-8yhf030a.js} +3 -3
- package/dist/chunk-92cczfwx.js +903 -0
- package/dist/{chunk-mbfzfg56.js → chunk-9r16nw6z.js} +85 -85
- package/dist/{chunk-s7tq4e5g.js → chunk-9rm2hczd.js} +78 -78
- package/dist/{chunk-s13y3w7e.js → chunk-9shyda79.js} +37 -37
- package/dist/{chunk-c6gpdd2c.js → chunk-9t8650e0.js} +78 -78
- package/dist/{chunk-7e9xcw77.js → chunk-9x5zgy22.js} +1 -1
- package/dist/{chunk-1ytng03p.js → chunk-9znd08ha.js} +12 -12
- package/dist/{chunk-r27tskss.js → chunk-a0qftggg.js} +9 -11
- package/dist/{chunk-0w2ntzwz.js → chunk-ab78zrxc.js} +92 -92
- package/dist/{chunk-638qz5y7.js → chunk-acj1j3dw.js} +5 -5
- package/dist/{chunk-z8n8cjhz.js → chunk-aj7nt1ae.js} +2 -2
- package/dist/{chunk-jwqveqpr.js → chunk-akd5hjav.js} +9 -9
- package/dist/{chunk-et3jfht8.js → chunk-ang6j1ma.js} +16 -16
- package/dist/{chunk-s9jxtj04.js → chunk-arrvgw6z.js} +95 -94
- package/dist/{chunk-cajjdb7j.js → chunk-as3pvrmw.js} +8 -8
- package/dist/{chunk-5f57qtf9.js → chunk-ase86y73.js} +1 -1
- package/dist/{chunk-m12e2wq3.js → chunk-b08zb0sw.js} +80 -80
- package/dist/{chunk-6d05fvxz.js → chunk-b0kf00ff.js} +2 -2
- package/dist/{chunk-r055z03k.js → chunk-b1kcd3ss.js} +1 -1
- package/dist/{chunk-k0dprbnn.js → chunk-ba473zak.js} +78 -78
- package/dist/{chunk-0tja7d1y.js → chunk-bg4x9ex0.js} +6 -6
- package/dist/{chunk-eb4t4ehh.js → chunk-bgzwt111.js} +6 -6
- package/dist/chunk-bh5zqvyc.js +36 -0
- package/dist/{chunk-eynfddhq.js → chunk-bpes1x7d.js} +144 -143
- package/dist/chunk-brbrrj03.js +114 -0
- package/dist/{chunk-zhnnzkzm.js → chunk-brjd9zmk.js} +14 -14
- package/dist/chunk-bs975312.js +133 -0
- package/dist/chunk-bww6hm2e.js +58 -0
- package/dist/{chunk-p0n9ew4x.js → chunk-byfawrfx.js} +4 -4
- package/dist/chunk-c67ypsa8.js +20 -0
- package/dist/chunk-c6sjhj89.js +1284 -0
- package/dist/{chunk-pyn4ry36.js → chunk-c7jwbe76.js} +57 -103
- package/dist/chunk-cdef9v7b.js +27 -0
- package/dist/{chunk-9029sbq1.js → chunk-cdz5yb0r.js} +1 -1
- package/dist/{chunk-4bcx2a3p.js → chunk-cgfdkzhb.js} +1 -1
- package/dist/chunk-cgy9g4wp.js +100 -0
- package/dist/{chunk-fefs2xby.js → chunk-cmtvwbwf.js} +25 -25
- package/dist/{chunk-p8hn07q2.js → chunk-cnsj3vq2.js} +1 -1
- package/dist/{chunk-ngde5k9k.js → chunk-cpywwph7.js} +79 -79
- package/dist/chunk-crcrnd8y.js +55 -0
- package/dist/{chunk-j15xyew5.js → chunk-crfk7ed8.js} +4 -4
- package/dist/{chunk-0a8jb5c8.js → chunk-crvwmrey.js} +9 -9
- package/dist/{chunk-44bqv91d.js → chunk-cxrktb5g.js} +3 -3
- package/dist/{chunk-apjnwens.js → chunk-d4mdda98.js} +8 -8
- package/dist/{chunk-d2cypdsx.js → chunk-d6kvya9n.js} +23 -23
- package/dist/chunk-daqd8kee.js +122 -0
- package/dist/{chunk-cx21etb2.js → chunk-db2awvr6.js} +2 -2
- package/dist/{chunk-b1hygym1.js → chunk-ddsjkqs4.js} +8 -8
- package/dist/{chunk-rx9ypbjy.js → chunk-dfzkwynj.js} +8 -8
- package/dist/{chunk-yteprw63.js → chunk-dhk2dt7n.js} +29 -29
- package/dist/{chunk-rzn9w8p2.js → chunk-dq94esjd.js} +3 -3
- package/dist/{chunk-z8b8f2n3.js → chunk-dw1x0kzg.js} +79 -79
- package/dist/{chunk-k3gvjjm9.js → chunk-e0abab5b.js} +5 -5
- package/dist/{chunk-wyyd1qfn.js → chunk-e28pnfmr.js} +81 -81
- package/dist/{chunk-pg8asjpk.js → chunk-e9w9zc0g.js} +20 -20
- package/dist/chunk-effhh1pw.js +81 -0
- package/dist/{chunk-rfj6gjwh.js → chunk-efrjt26j.js} +14 -14
- package/dist/{chunk-p4e5ymdw.js → chunk-ehtwnxpg.js} +1 -1
- package/dist/chunk-em7h8kqy.js +89 -0
- package/dist/{chunk-yh46f77t.js → chunk-enkgx9p5.js} +78 -78
- package/dist/{chunk-ysfam81t.js → chunk-eqp1rfft.js} +2 -2
- package/dist/{chunk-r4pq77kb.js → chunk-etdt1xz3.js} +3 -3
- package/dist/{chunk-dh01e4bp.js → chunk-ewadzrm8.js} +2 -2
- package/dist/{chunk-7dc9d8fy.js → chunk-f98yad99.js} +7 -7
- package/dist/{chunk-4v1mr2x2.js → chunk-f99jr604.js} +41 -41
- package/dist/{chunk-37j24srh.js → chunk-f9mnmjf4.js} +6 -6
- package/dist/{chunk-qbbf7rr5.js → chunk-fajg8x36.js} +727 -1818
- package/dist/{chunk-snd4pbkp.js → chunk-fbv4apne.js} +1 -1
- package/dist/{chunk-8m1gfrme.js → chunk-fc8mescd.js} +26 -15
- package/dist/{chunk-8a1jee0e.js → chunk-fcynwjpm.js} +2 -2
- package/dist/{chunk-gt43z5zd.js → chunk-fddfa07d.js} +81 -81
- package/dist/{chunk-bq0wp28e.js → chunk-feyzykye.js} +1 -1
- package/dist/chunk-ffcwak1t.js +91 -0
- package/dist/{chunk-25jhz0br.js → chunk-fgmmtj9k.js} +16 -16
- package/dist/{chunk-4kfhh3aw.js → chunk-fj3a38w3.js} +4 -4
- package/dist/chunk-fk60d1qf.js +87 -0
- package/dist/chunk-fnxysrtm.js +52 -0
- package/dist/chunk-fq24vgdm.js +113 -0
- package/dist/{chunk-dy8278wt.js → chunk-fqak69ft.js} +7 -7
- package/dist/{chunk-657k4mef.js → chunk-fs7jna05.js} +79 -79
- package/dist/{chunk-0zscb6c7.js → chunk-fyc5fepv.js} +1 -1
- package/dist/{chunk-vwt2fv6j.js → chunk-g0wv2y40.js} +3 -3
- package/dist/chunk-g3gr434c.js +101 -0
- package/dist/{chunk-v9sy0cj3.js → chunk-g3zgsm5x.js} +10 -10
- package/dist/{chunk-vxsad4bw.js → chunk-g9f19ttm.js} +2 -2
- package/dist/{chunk-bw8y1msy.js → chunk-g9q2patf.js} +5 -5
- package/dist/chunk-gdwdqewd.js +19 -0
- package/dist/{chunk-h8n0a991.js → chunk-ge8zt73c.js} +79 -79
- package/dist/{chunk-3w4xq6cv.js → chunk-gg55fns0.js} +92 -92
- package/dist/chunk-gk8dvdsw.js +140 -0
- package/dist/{chunk-9p62r6he.js → chunk-gw6kn54v.js} +6 -6
- package/dist/chunk-gz1e8y1w.js +33 -0
- package/dist/{chunk-ycpdfeya.js → chunk-gzt1cd1y.js} +79 -79
- package/dist/{chunk-m13ptmf2.js → chunk-h9n54swm.js} +2 -2
- package/dist/{chunk-7njkaxjp.js → chunk-hakdhagh.js} +120 -39
- package/dist/{chunk-dzcb2ekz.js → chunk-hcwcwa84.js} +4 -4
- package/dist/{chunk-1ehn6qdp.js → chunk-hf96emr1.js} +13 -13
- package/dist/{chunk-vq4k182g.js → chunk-hgteysah.js} +5 -5
- package/dist/{chunk-6fx36a3s.js → chunk-hszppxh0.js} +5 -5
- package/dist/chunk-hvbnh0ht.js +131 -0
- package/dist/{chunk-f9ybfyyp.js → chunk-hwfknpxv.js} +2 -2
- package/dist/{chunk-gm8ht8g9.js → chunk-hwyp85fa.js} +6 -6
- package/dist/{chunk-kt25n52f.js → chunk-j5bth84e.js} +4 -4
- package/dist/{chunk-tkbwrjte.js → chunk-j64ga6ta.js} +284 -325
- package/dist/{chunk-1ycd7t0f.js → chunk-jagq2tcw.js} +88 -88
- package/dist/{chunk-trm02xde.js → chunk-jd32zbps.js} +2 -2
- package/dist/{chunk-0f84wjjc.js → chunk-jgwfkvdk.js} +79 -79
- package/dist/{chunk-6fe0an4e.js → chunk-jhrshs1y.js} +79 -79
- package/dist/{chunk-3xamk0n1.js → chunk-jjnmcaeb.js} +25 -25
- package/dist/{chunk-x4x3691j.js → chunk-jtjqrrtq.js} +12 -12
- package/dist/{chunk-pp5zbnpr.js → chunk-jtx7ka0g.js} +80 -80
- package/dist/chunk-jvdhwjth.js +107 -0
- package/dist/{chunk-fpq87r80.js → chunk-jzthz1bx.js} +1 -1
- package/dist/{chunk-taqr0qw1.js → chunk-k0p9w03v.js} +3 -3
- package/dist/{chunk-9re786wa.js → chunk-k4xyha98.js} +40 -40
- package/dist/{chunk-pqxyft7d.js → chunk-k6tvcn37.js} +8 -8
- package/dist/{chunk-a3qtafgw.js → chunk-k8vp0atq.js} +79 -79
- package/dist/chunk-kbqx20y8.js +89 -0
- package/dist/{chunk-h4tnp6dw.js → chunk-khnqc2x8.js} +7 -7
- package/dist/{chunk-s9906sac.js → chunk-kqc0x8w6.js} +83 -83
- package/dist/{chunk-nsxw4b3j.js → chunk-ksq6zjys.js} +8 -8
- package/dist/{chunk-0pbwcm8b.js → chunk-kwekc97v.js} +1 -1
- package/dist/{chunk-qs4stpt5.js → chunk-ky1z78ve.js} +14 -14
- package/dist/{chunk-e22at2jn.js → chunk-m1ergjg5.js} +4 -4
- package/dist/chunk-m4k4mve9.js +130 -0
- package/dist/{chunk-q9y73cmh.js → chunk-mcws22k3.js} +1 -1
- package/dist/chunk-mfdqvcr5.js +50 -0
- package/dist/{chunk-88k0rgdp.js → chunk-mgv4r1af.js} +12 -12
- package/dist/{chunk-62jrhytw.js → chunk-mh52m71p.js} +10 -10
- package/dist/{chunk-pt6vj628.js → chunk-mjcxt56a.js} +9 -9
- package/dist/chunk-mpc6f96q.js +111 -0
- package/dist/{chunk-s5arr49c.js → chunk-mra3tr23.js} +200 -11
- package/dist/{chunk-4e1j46k0.js → chunk-mswx2nma.js} +3 -3
- package/dist/{chunk-zat7q2e0.js → chunk-mxt0a1ab.js} +79 -79
- package/dist/chunk-mympkkbw.js +103 -0
- package/dist/chunk-mzrxzmpm.js +121 -0
- package/dist/{chunk-0b85d7q0.js → chunk-n0zd06za.js} +7 -7
- package/dist/{chunk-jrqjxhxj.js → chunk-n22k5xdw.js} +2 -2
- package/dist/{chunk-7gbe6ftc.js → chunk-n9ftnh2y.js} +10 -10
- package/dist/{chunk-ykvf93ft.js → chunk-nd39ny9k.js} +79 -79
- package/dist/{chunk-mtstpt1e.js → chunk-nd7zx01p.js} +43 -43
- package/dist/{chunk-pnc7q9rt.js → chunk-netzwgv1.js} +1 -1
- package/dist/chunk-nmgj86tt.js +24 -0
- package/dist/{chunk-r1q9s5hs.js → chunk-ns7x6xam.js} +10 -13
- package/dist/{chunk-vbe1ersf.js → chunk-p7vkh4wx.js} +1 -1
- package/dist/{chunk-q74fcthe.js → chunk-p8na2wwp.js} +2 -2
- package/dist/{chunk-tmye4d2k.js → chunk-pajqjgkr.js} +15 -15
- package/dist/{chunk-pg4fbhbm.js → chunk-pe3rkfp2.js} +11 -11
- package/dist/chunk-pe824pp5.js +71 -0
- package/dist/{chunk-sbe9zd56.js → chunk-pgtnj1mt.js} +6 -6
- package/dist/{chunk-41wn5eqw.js → chunk-phr23vzw.js} +10 -10
- package/dist/{chunk-5nqrdqz5.js → chunk-ppwjyveh.js} +1 -1
- package/dist/chunk-pqe0s3es.js +85 -0
- package/dist/{chunk-ja1nqz5q.js → chunk-ps49ymvj.js} +2 -2
- package/dist/{chunk-2vc3fyp9.js → chunk-pwwa7s62.js} +2 -2
- package/dist/chunk-px0z9762.js +91 -0
- package/dist/{chunk-v8k67zfz.js → chunk-q4wj3v8n.js} +392 -1127
- package/dist/{chunk-wwrswxg1.js → chunk-qajrkk97.js} +1 -1
- package/dist/{chunk-b610qrvk.js → chunk-qatfdxvd.js} +3 -3
- package/dist/{chunk-qka6pqrq.js → chunk-qb6k2afy.js} +11 -11
- package/dist/{chunk-rgaedd84.js → chunk-qkczt8cr.js} +5 -5
- package/dist/chunk-qnfx3qtx.js +617 -0
- package/dist/{chunk-eta5aekm.js → chunk-qp2qdcda.js} +30 -9
- package/dist/{chunk-cfpnb7x4.js → chunk-qr516hqj.js} +78 -78
- package/dist/{chunk-a1mewckj.js → chunk-qswz887n.js} +78 -78
- package/dist/{chunk-tnv92c5m.js → chunk-r1w3jrs8.js} +81 -81
- package/dist/chunk-r5q49139.js +93 -0
- package/dist/{chunk-a00gfn8e.js → chunk-rmbbmd3s.js} +2 -2
- package/dist/{chunk-xdxdztxa.js → chunk-rn0v1hk8.js} +1 -1
- package/dist/{chunk-cqb31tfg.js → chunk-rnxctq9p.js} +6 -6
- package/dist/{chunk-z7yj7dfh.js → chunk-rs4yvre8.js} +10 -10
- package/dist/chunk-s07p92v4.js +107 -0
- package/dist/{chunk-fqr6n9z6.js → chunk-s8gy4ky9.js} +3 -3
- package/dist/chunk-s8hykxf5.js +145 -0
- package/dist/{chunk-fr5s5ceq.js → chunk-s8kj6ajy.js} +2 -2
- package/dist/{chunk-39r7sh1h.js → chunk-scz7dzwq.js} +90 -90
- package/dist/{chunk-nztayqyx.js → chunk-sd36yzx8.js} +1 -1
- package/dist/chunk-sgpmpn90.js +35 -0
- package/dist/chunk-sh02d2qn.js +38 -0
- package/dist/{chunk-6c22q39e.js → chunk-sncz1ag3.js} +78 -78
- package/dist/{chunk-0dwdg9bz.js → chunk-ssec5007.js} +9 -9
- package/dist/{chunk-2qpy8kne.js → chunk-szj5wvdy.js} +1 -1
- package/dist/{chunk-4nqm22j3.js → chunk-t29a6zb5.js} +4 -6
- package/dist/{chunk-w60c0dkw.js → chunk-t32ddjb3.js} +5 -5
- package/dist/{chunk-3hcfwedh.js → chunk-t4khqff1.js} +5 -5
- package/dist/{chunk-q53kkzhr.js → chunk-t7j96x8z.js} +80 -80
- package/dist/{chunk-qrdbqeve.js → chunk-t9p85zff.js} +2 -2
- package/dist/{chunk-ma6x4ws8.js → chunk-tgafrp5a.js} +46 -46
- package/dist/{chunk-ewsvbzhz.js → chunk-tgnbeeyx.js} +3 -3
- package/dist/{chunk-yp64t9je.js → chunk-tndhag9g.js} +8 -8
- package/dist/chunk-tr9zera9.js +55 -0
- package/dist/{chunk-5sd5fz78.js → chunk-tz3td6hy.js} +78 -78
- package/dist/{chunk-6vp8zen2.js → chunk-v17y7qay.js} +79 -79
- package/dist/{chunk-zx9r7a23.js → chunk-v1kzp02e.js} +1 -1
- package/dist/{chunk-15f7ee0j.js → chunk-v4t6dyyh.js} +158 -245
- package/dist/{chunk-93kvs6fh.js → chunk-v5brqghz.js} +6 -6
- package/dist/{chunk-he9zw1gh.js → chunk-v78fj8by.js} +2 -2
- package/dist/{chunk-pt1jzmkv.js → chunk-v8kjswxt.js} +2 -2
- package/dist/{chunk-n9ne98cj.js → chunk-v9smspw2.js} +4 -5
- package/dist/{chunk-2bh7f2wa.js → chunk-vbmdqx87.js} +13 -13
- package/dist/{chunk-4yq5zz3m.js → chunk-vcwzs8xk.js} +9 -9
- package/dist/{chunk-wt799fvk.js → chunk-vf612n57.js} +34 -34
- package/dist/chunk-vf9320w1.js +105 -0
- package/dist/{chunk-myac8yfs.js → chunk-vkhrrvfq.js} +5 -5
- package/dist/{chunk-hbz8xggv.js → chunk-vneepj82.js} +11 -11
- package/dist/{chunk-ytt8da3v.js → chunk-vr96pznr.js} +81 -81
- package/dist/chunk-vszex7fm.js +90 -0
- package/dist/{chunk-jw9zwgea.js → chunk-vv7kzavx.js} +4 -4
- package/dist/chunk-vwxpwg2r.js +121 -0
- package/dist/{chunk-bktmgb4n.js → chunk-vyjeh50y.js} +39 -68
- package/dist/{chunk-9rhy5vt7.js → chunk-vzzsjg7m.js} +9 -9
- package/dist/{chunk-yvm9t98e.js → chunk-w0dz2sa5.js} +18 -7
- package/dist/{chunk-xggbj4j9.js → chunk-w1fb9aqj.js} +3 -3
- package/dist/{chunk-hgb8024k.js → chunk-w43b6749.js} +10 -10
- package/dist/{chunk-3hxr3x9d.js → chunk-w6m6trzq.js} +2 -2
- package/dist/chunk-w9a226y4.js +105 -0
- package/dist/{chunk-kcp41jcn.js → chunk-wa8yn2p0.js} +2 -2
- package/dist/{chunk-4fwzreqj.js → chunk-wf16jx1f.js} +6 -6
- package/dist/{chunk-7tdk9ypw.js → chunk-wgk9sxk7.js} +10 -10
- package/dist/{chunk-2bk4jvse.js → chunk-wkny3k77.js} +7 -7
- package/dist/chunk-wsfq03qa.js +101 -0
- package/dist/{chunk-e01rphq3.js → chunk-x12h3n65.js} +727 -128
- package/dist/{chunk-26kp0k1t.js → chunk-x1dw8vry.js} +80 -80
- package/dist/{chunk-jsvsnqkn.js → chunk-x47h283a.js} +2 -2
- package/dist/{chunk-ccdh8eh2.js → chunk-x5wgbcme.js} +38 -38
- package/dist/{chunk-rpta0rqz.js → chunk-x6r4v44b.js} +1 -1
- package/dist/{chunk-tyc5c0q4.js → chunk-x70f036b.js} +8 -8
- package/dist/{chunk-k6wmp81y.js → chunk-x7fdwq3d.js} +1 -1
- package/dist/{chunk-13pmg16e.js → chunk-x8d2ehd7.js} +1 -1
- package/dist/{chunk-dg2k597k.js → chunk-xca0q5ap.js} +9 -9
- package/dist/{chunk-pnrdvxhy.js → chunk-xeb6075z.js} +2 -2
- package/dist/{chunk-n9xhrzxs.js → chunk-xg08qv1e.js} +78 -78
- package/dist/{chunk-7gte8zc4.js → chunk-xhfmdq1y.js} +1 -1
- package/dist/{chunk-gxsrvxjn.js → chunk-xv3era3s.js} +1 -1
- package/dist/chunk-xv78ch6z.js +92 -0
- package/dist/chunk-xy94q6qg.js +114 -0
- package/dist/{chunk-92wwx9vf.js → chunk-y1784krc.js} +2 -2
- package/dist/{chunk-ggk84sc5.js → chunk-y4ca9kqz.js} +4 -4
- package/dist/{chunk-h1tv19q0.js → chunk-y4d1sgf4.js} +80 -80
- package/dist/{chunk-m8qvkabg.js → chunk-y9bhjjdz.js} +4 -4
- package/dist/{chunk-vwkb146r.js → chunk-y9ffgh1g.js} +90 -90
- package/dist/chunk-ycs5r2ef.js +60 -0
- package/dist/{chunk-c2k1n6yb.js → chunk-yde1e32y.js} +16 -16
- package/dist/chunk-yfztvfhh.js +94 -0
- package/dist/{chunk-hhvf84fa.js → chunk-yjk0f08a.js} +188 -186
- package/dist/{chunk-bta8w8ge.js → chunk-yyex5gsf.js} +10 -10
- package/dist/chunk-zcq3r82m.js +93 -0
- package/dist/{chunk-3jbxhytz.js → chunk-zecx4x3b.js} +8 -8
- package/dist/{chunk-7ba45tqg.js → chunk-zpdzhck8.js} +5 -5
- package/dist/{chunk-j0bfbce5.js → chunk-zpw4ny96.js} +36 -36
- package/dist/{chunk-tdf3ha9b.js → chunk-zv1frw5e.js} +79 -79
- package/dist/{chunk-61x3akfa.js → chunk-zxh62ved.js} +2 -2
- package/dist/{chunk-8r1napm7.js → chunk-zzm33q8x.js} +1 -1
- package/dist/cli.js +12 -12
- package/dist/gateway/worker.js +170082 -171912
- package/dist/sdk/query.cjs +18 -8
- package/dist/sdk/query.js +1 -1
- package/package.json +128 -128
- package/dist/chunk-09nzqj0f.js +0 -9605
- package/dist/chunk-0fw1mz8s.js +0 -27
- package/dist/chunk-0pqv68xt.js +0 -133
- package/dist/chunk-0pv13fxq.js +0 -1684
- package/dist/chunk-0tgn1431.js +0 -38
- package/dist/chunk-0yshjsxt.js +0 -122
- package/dist/chunk-0z9s957c.js +0 -94
- package/dist/chunk-1gt45dyg.js +0 -101
- package/dist/chunk-3kx7brrn.js +0 -55
- package/dist/chunk-4kfs8ymb.js +0 -92
- package/dist/chunk-5rhmrt2j.js +0 -121
- package/dist/chunk-626watky.js +0 -50
- package/dist/chunk-6aqa0ec5.js +0 -145
- package/dist/chunk-6zfb4n08.js +0 -91
- package/dist/chunk-73bgy356.js +0 -90
- package/dist/chunk-7nphjzve.js +0 -105
- package/dist/chunk-7sp9dk6d.js +0 -20
- package/dist/chunk-8jmkpx1h.js +0 -123
- package/dist/chunk-9xq7ef8y.js +0 -100
- package/dist/chunk-9ydxqdhe.js +0 -121
- package/dist/chunk-ab6apbd2.js +0 -140
- package/dist/chunk-bdrsheny.js +0 -35
- package/dist/chunk-bvfqg3cg.js +0 -131
- package/dist/chunk-cj0j4n23.js +0 -71
- package/dist/chunk-cynnhyy3.js +0 -103
- package/dist/chunk-d0zx5hba.js +0 -85
- package/dist/chunk-e6s584g7.js +0 -77
- package/dist/chunk-e90dyenj.js +0 -127
- package/dist/chunk-em5s71j6.js +0 -89
- package/dist/chunk-eqcgr89w.js +0 -646
- package/dist/chunk-f9zvs66e.js +0 -105
- package/dist/chunk-gaf31961.js +0 -81
- package/dist/chunk-gkz2djp0.js +0 -121
- package/dist/chunk-gwktnbeg.js +0 -90
- package/dist/chunk-h0bgwz9v.js +0 -55
- package/dist/chunk-h3v46eky.js +0 -105
- package/dist/chunk-hycm92ss.js +0 -52
- package/dist/chunk-j3c5r08n.js +0 -87
- package/dist/chunk-j3q2sbhc.js +0 -107
- package/dist/chunk-k9h7kjf6.js +0 -8
- package/dist/chunk-karea2z2.js +0 -89
- package/dist/chunk-kra9y8qb.js +0 -97
- package/dist/chunk-mwzwm2z2.js +0 -60
- package/dist/chunk-n535j168.js +0 -131
- package/dist/chunk-p9nkqgej.js +0 -19
- package/dist/chunk-pgptefy1.js +0 -114
- package/dist/chunk-pjn0s3j1.js +0 -111
- package/dist/chunk-pkwv0q5q.js +0 -91
- package/dist/chunk-q6m9qgaa.js +0 -88
- package/dist/chunk-r82c7gfc.js +0 -58
- package/dist/chunk-rgshryeb.js +0 -93
- package/dist/chunk-rk2kb2ec.js +0 -101
- package/dist/chunk-s0p653k2.js +0 -93
- package/dist/chunk-skypjdyc.js +0 -147
- package/dist/chunk-tgayhxvz.js +0 -41
- package/dist/chunk-vr5vyt2h.js +0 -107
- package/dist/chunk-vvjhax8n.js +0 -114
- package/dist/chunk-vvsts2t9.js +0 -30
- package/dist/chunk-w287mz4p.js +0 -146
- package/dist/chunk-wa852b5b.js +0 -113
- package/dist/chunk-xbpt4dv8.js +0 -155
- package/dist/chunk-xj72jfpd.js +0 -33
- package/dist/chunk-xwbh3j1x.js +0 -107
- package/dist/chunk-xwrar1c5.js +0 -97
- package/dist/chunk-yt9mady7.js +0 -36
- package/dist/chunk-zfxp82tk.js +0 -24
- package/dist/chunk-zgkngrp4.js +0 -54
|
@@ -0,0 +1,903 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
anthropicToolChoiceToOpenAI,
|
|
4
|
+
anthropicToolsToOpenAI,
|
|
5
|
+
createAssistantAPIErrorMessage,
|
|
6
|
+
createUserMessage,
|
|
7
|
+
extractDiscoveredToolNames,
|
|
8
|
+
getEmptyToolPermissionContext,
|
|
9
|
+
getOpenAIClient,
|
|
10
|
+
init_Tool,
|
|
11
|
+
init_api,
|
|
12
|
+
init_client1 as init_client,
|
|
13
|
+
init_convertTools,
|
|
14
|
+
init_messages1 as init_messages,
|
|
15
|
+
init_modelMapping,
|
|
16
|
+
init_toolSearch,
|
|
17
|
+
isDeferredToolsDeltaEnabled,
|
|
18
|
+
isToolSearchEnabled,
|
|
19
|
+
normalizeContentFromAPI,
|
|
20
|
+
normalizeMessagesForAPI,
|
|
21
|
+
resolveOpenAIModel,
|
|
22
|
+
toolMatchesName,
|
|
23
|
+
toolToAPISchema
|
|
24
|
+
} from "./chunk-4sk0ekmh.js";
|
|
25
|
+
import"./chunk-mcws22k3.js";
|
|
26
|
+
import"./chunk-jzthz1bx.js";
|
|
27
|
+
import"./chunk-24q2kxjm.js";
|
|
28
|
+
import"./chunk-hwfknpxv.js";
|
|
29
|
+
import"./chunk-1gx78081.js";
|
|
30
|
+
import"./chunk-ehtwnxpg.js";
|
|
31
|
+
import"./chunk-3mqgy4d8.js";
|
|
32
|
+
import"./chunk-khnqc2x8.js";
|
|
33
|
+
import"./chunk-x47h283a.js";
|
|
34
|
+
import"./chunk-hf96emr1.js";
|
|
35
|
+
import"./chunk-2gzv8nrw.js";
|
|
36
|
+
import"./chunk-e0abab5b.js";
|
|
37
|
+
import"./chunk-cgfdkzhb.js";
|
|
38
|
+
import"./chunk-4k9d7gxv.js";
|
|
39
|
+
import"./chunk-j5bth84e.js";
|
|
40
|
+
import"./chunk-xca0q5ap.js";
|
|
41
|
+
import"./chunk-68ffk5qa.js";
|
|
42
|
+
import"./chunk-ps49ymvj.js";
|
|
43
|
+
import {
|
|
44
|
+
addToTotalSessionCost,
|
|
45
|
+
init_cost_tracker
|
|
46
|
+
} from "./chunk-26sypsqa.js";
|
|
47
|
+
import {
|
|
48
|
+
calculateUSDCost,
|
|
49
|
+
getModelMaxOutputTokens,
|
|
50
|
+
init_context,
|
|
51
|
+
init_modelCost
|
|
52
|
+
} from "./chunk-fc8mescd.js";
|
|
53
|
+
import"./chunk-pgtnj1mt.js";
|
|
54
|
+
import {
|
|
55
|
+
TOOL_SEARCH_TOOL_NAME,
|
|
56
|
+
formatDeferredToolLine,
|
|
57
|
+
init_prompt,
|
|
58
|
+
isDeferredTool
|
|
59
|
+
} from "./chunk-68ypktng.js";
|
|
60
|
+
import"./chunk-p7vkh4wx.js";
|
|
61
|
+
import"./chunk-y9bhjjdz.js";
|
|
62
|
+
import"./chunk-7pz9rdg8.js";
|
|
63
|
+
import"./chunk-7gy9xrjc.js";
|
|
64
|
+
import"./chunk-dfzkwynj.js";
|
|
65
|
+
import"./chunk-xeb6075z.js";
|
|
66
|
+
import"./chunk-fcynwjpm.js";
|
|
67
|
+
import"./chunk-v4t6dyyh.js";
|
|
68
|
+
import"./chunk-phr23vzw.js";
|
|
69
|
+
import"./chunk-v8kjswxt.js";
|
|
70
|
+
import"./chunk-q4wj3v8n.js";
|
|
71
|
+
import"./chunk-rnxctq9p.js";
|
|
72
|
+
import"./chunk-f98yad99.js";
|
|
73
|
+
import"./chunk-6nsd9606.js";
|
|
74
|
+
import"./chunk-64c1avct.js";
|
|
75
|
+
import"./chunk-8g5pe1gr.js";
|
|
76
|
+
import"./chunk-4pbx3g7s.js";
|
|
77
|
+
import"./chunk-26wtxbdc.js";
|
|
78
|
+
import"./chunk-6dngjwkh.js";
|
|
79
|
+
import"./chunk-4jm600zv.js";
|
|
80
|
+
import"./chunk-s8gy4ky9.js";
|
|
81
|
+
import"./chunk-cxrktb5g.js";
|
|
82
|
+
import"./chunk-3c25bcsw.js";
|
|
83
|
+
import"./chunk-5ekyhb1w.js";
|
|
84
|
+
import"./chunk-fqak69ft.js";
|
|
85
|
+
import"./chunk-cdz5yb0r.js";
|
|
86
|
+
import"./chunk-c7jwbe76.js";
|
|
87
|
+
import"./chunk-0vkfrmqm.js";
|
|
88
|
+
import"./chunk-7sgtxrsc.js";
|
|
89
|
+
import"./chunk-0xjaqda8.js";
|
|
90
|
+
import"./chunk-x8d2ehd7.js";
|
|
91
|
+
import"./chunk-byfawrfx.js";
|
|
92
|
+
import"./chunk-3vy1jt9p.js";
|
|
93
|
+
import"./chunk-vkhrrvfq.js";
|
|
94
|
+
import"./chunk-qnfx3qtx.js";
|
|
95
|
+
import"./chunk-64r16v22.js";
|
|
96
|
+
import"./chunk-s8kj6ajy.js";
|
|
97
|
+
import"./chunk-8yhf030a.js";
|
|
98
|
+
import"./chunk-zxh62ved.js";
|
|
99
|
+
import"./chunk-5z28bqne.js";
|
|
100
|
+
import"./chunk-qajrkk97.js";
|
|
101
|
+
import {
|
|
102
|
+
init_debug,
|
|
103
|
+
logForDebugging
|
|
104
|
+
} from "./chunk-gg55fns0.js";
|
|
105
|
+
import {
|
|
106
|
+
init_envUtils,
|
|
107
|
+
isEnvDefinedFalsy,
|
|
108
|
+
isEnvTruthy
|
|
109
|
+
} from "./chunk-5n1jc02d.js";
|
|
110
|
+
import"./chunk-fbv4apne.js";
|
|
111
|
+
import"./chunk-k8vp0atq.js";
|
|
112
|
+
import"./chunk-vf612n57.js";
|
|
113
|
+
import"./chunk-07069jq1.js";
|
|
114
|
+
import"./chunk-d4mdda98.js";
|
|
115
|
+
import"./chunk-55raexh7.js";
|
|
116
|
+
import"./chunk-v9smspw2.js";
|
|
117
|
+
import"./chunk-v1kzp02e.js";
|
|
118
|
+
import"./chunk-7wm5s02e.js";
|
|
119
|
+
import"./chunk-b0kf00ff.js";
|
|
120
|
+
import"./chunk-netzwgv1.js";
|
|
121
|
+
import {
|
|
122
|
+
__esm,
|
|
123
|
+
__require
|
|
124
|
+
} from "./chunk-qp2qdcda.js";
|
|
125
|
+
|
|
126
|
+
// src/services/api/openai/convertMessages.ts
|
|
127
|
+
function anthropicMessagesToOpenAI(messages, systemPrompt, options) {
|
|
128
|
+
const result = [];
|
|
129
|
+
const enableThinking = options?.enableThinking ?? false;
|
|
130
|
+
const systemText = systemPromptToText(systemPrompt);
|
|
131
|
+
if (systemText) {
|
|
132
|
+
result.push({
|
|
133
|
+
role: "system",
|
|
134
|
+
content: systemText
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const turnBoundaries = new Set;
|
|
138
|
+
if (enableThinking) {
|
|
139
|
+
let hasSeenAssistant = false;
|
|
140
|
+
for (let i = 0;i < messages.length; i++) {
|
|
141
|
+
const msg = messages[i];
|
|
142
|
+
if (msg.type === "assistant") {
|
|
143
|
+
hasSeenAssistant = true;
|
|
144
|
+
}
|
|
145
|
+
if (msg.type === "user" && hasSeenAssistant) {
|
|
146
|
+
const content = msg.message.content;
|
|
147
|
+
const startsNewUserTurn = typeof content === "string" ? content.length > 0 : Array.isArray(content) && content.some((b) => typeof b === "string" || b && typeof b === "object" && ("type" in b) && b.type !== "tool_result");
|
|
148
|
+
if (startsNewUserTurn) {
|
|
149
|
+
turnBoundaries.add(i);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
for (let i = 0;i < messages.length; i++) {
|
|
155
|
+
const msg = messages[i];
|
|
156
|
+
switch (msg.type) {
|
|
157
|
+
case "user":
|
|
158
|
+
result.push(...convertInternalUserMessage(msg));
|
|
159
|
+
break;
|
|
160
|
+
case "assistant":
|
|
161
|
+
const preserveReasoning = enableThinking && !isBeforeAnyTurnBoundary(i, turnBoundaries);
|
|
162
|
+
result.push(...convertInternalAssistantMessage(msg, preserveReasoning));
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
function systemPromptToText(systemPrompt) {
|
|
171
|
+
if (!systemPrompt || systemPrompt.length === 0)
|
|
172
|
+
return "";
|
|
173
|
+
return systemPrompt.filter(Boolean).join(`
|
|
174
|
+
|
|
175
|
+
`);
|
|
176
|
+
}
|
|
177
|
+
function isBeforeAnyTurnBoundary(i, boundaries) {
|
|
178
|
+
for (const b of boundaries) {
|
|
179
|
+
if (i < b)
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
function convertInternalUserMessage(msg) {
|
|
185
|
+
const result = [];
|
|
186
|
+
const content = msg.message.content;
|
|
187
|
+
if (typeof content === "string") {
|
|
188
|
+
result.push({
|
|
189
|
+
role: "user",
|
|
190
|
+
content
|
|
191
|
+
});
|
|
192
|
+
} else if (Array.isArray(content)) {
|
|
193
|
+
const textParts = [];
|
|
194
|
+
const imageParts = [];
|
|
195
|
+
const toolResults = [];
|
|
196
|
+
for (const block of content) {
|
|
197
|
+
if (typeof block === "string") {
|
|
198
|
+
textParts.push(block);
|
|
199
|
+
} else if (block.type === "text") {
|
|
200
|
+
textParts.push(block.text);
|
|
201
|
+
} else if (block.type === "tool_result") {
|
|
202
|
+
toolResults.push(block);
|
|
203
|
+
} else if (block.type === "image") {
|
|
204
|
+
if (block.source.type === "base64") {
|
|
205
|
+
imageParts.push({
|
|
206
|
+
type: "image_url",
|
|
207
|
+
image_url: { url: `data:${block.source.media_type};base64,${block.source.data}` }
|
|
208
|
+
});
|
|
209
|
+
} else if (block.source.type === "url") {
|
|
210
|
+
imageParts.push({
|
|
211
|
+
type: "image_url",
|
|
212
|
+
image_url: { url: block.source.url }
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const toolFollowUpMessages = [];
|
|
218
|
+
for (const tr of toolResults) {
|
|
219
|
+
const [toolMessage, ...followUpMessages] = convertToolResult(tr);
|
|
220
|
+
result.push(toolMessage);
|
|
221
|
+
toolFollowUpMessages.push(...followUpMessages);
|
|
222
|
+
}
|
|
223
|
+
result.push(...toolFollowUpMessages);
|
|
224
|
+
if (textParts.length > 0 || imageParts.length > 0) {
|
|
225
|
+
if (imageParts.length > 0) {
|
|
226
|
+
const contentParts = [];
|
|
227
|
+
if (textParts.length > 0) {
|
|
228
|
+
contentParts.push({ type: "text", text: textParts.join(`
|
|
229
|
+
`) });
|
|
230
|
+
}
|
|
231
|
+
contentParts.push(...imageParts);
|
|
232
|
+
result.push({
|
|
233
|
+
role: "user",
|
|
234
|
+
content: contentParts
|
|
235
|
+
});
|
|
236
|
+
} else {
|
|
237
|
+
result.push({
|
|
238
|
+
role: "user",
|
|
239
|
+
content: textParts.join(`
|
|
240
|
+
`)
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
function convertToolResult(block) {
|
|
248
|
+
const textParts = [];
|
|
249
|
+
if (typeof block.content === "string") {
|
|
250
|
+
textParts.push(block.content);
|
|
251
|
+
} else if (Array.isArray(block.content)) {
|
|
252
|
+
for (const c of block.content) {
|
|
253
|
+
if (typeof c === "string") {
|
|
254
|
+
textParts.push(c);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if ("text" in c && typeof c.text === "string") {
|
|
258
|
+
textParts.push(c.text);
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (c.type === "image") {
|
|
262
|
+
textParts.push("[image returned by tool]");
|
|
263
|
+
} else if (c.type === "document") {
|
|
264
|
+
textParts.push("[document returned by tool]");
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return [{
|
|
269
|
+
role: "tool",
|
|
270
|
+
tool_call_id: block.tool_use_id,
|
|
271
|
+
content: textParts.filter(Boolean).join(`
|
|
272
|
+
`) || ""
|
|
273
|
+
}];
|
|
274
|
+
}
|
|
275
|
+
function convertInternalAssistantMessage(msg, preserveReasoning = false) {
|
|
276
|
+
const content = msg.message.content;
|
|
277
|
+
if (typeof content === "string") {
|
|
278
|
+
return [
|
|
279
|
+
{
|
|
280
|
+
role: "assistant",
|
|
281
|
+
content
|
|
282
|
+
}
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
if (!Array.isArray(content)) {
|
|
286
|
+
return [
|
|
287
|
+
{
|
|
288
|
+
role: "assistant",
|
|
289
|
+
content: ""
|
|
290
|
+
}
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
const textParts = [];
|
|
294
|
+
const toolCalls = [];
|
|
295
|
+
const reasoningParts = [];
|
|
296
|
+
for (const block of content) {
|
|
297
|
+
if (typeof block === "string") {
|
|
298
|
+
textParts.push(block);
|
|
299
|
+
} else if (block.type === "text") {
|
|
300
|
+
textParts.push(block.text);
|
|
301
|
+
} else if (block.type === "tool_use") {
|
|
302
|
+
const tu = block;
|
|
303
|
+
toolCalls.push({
|
|
304
|
+
id: tu.id,
|
|
305
|
+
type: "function",
|
|
306
|
+
function: {
|
|
307
|
+
name: tu.name,
|
|
308
|
+
arguments: typeof tu.input === "string" ? tu.input : JSON.stringify(tu.input)
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
} else if (block.type === "thinking" && preserveReasoning) {
|
|
312
|
+
const thinkingText = block.thinking;
|
|
313
|
+
if (typeof thinkingText === "string" && thinkingText) {
|
|
314
|
+
reasoningParts.push(thinkingText);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const result = {
|
|
319
|
+
role: "assistant",
|
|
320
|
+
content: textParts.length > 0 ? textParts.join(`
|
|
321
|
+
`) : null,
|
|
322
|
+
...toolCalls.length > 0 && { tool_calls: toolCalls },
|
|
323
|
+
...reasoningParts.length > 0 && { reasoning_content: reasoningParts.join(`
|
|
324
|
+
`) }
|
|
325
|
+
};
|
|
326
|
+
return [result];
|
|
327
|
+
}
|
|
328
|
+
var init_convertMessages = () => {};
|
|
329
|
+
|
|
330
|
+
// src/services/api/openai/streamAdapter.ts
|
|
331
|
+
import { randomUUID } from "crypto";
|
|
332
|
+
async function* adaptOpenAIStreamToAnthropic(stream, model) {
|
|
333
|
+
const messageId = `msg_${randomUUID().replace(/-/g, "").slice(0, 24)}`;
|
|
334
|
+
let started = false;
|
|
335
|
+
let currentContentIndex = -1;
|
|
336
|
+
const toolBlocks = new Map;
|
|
337
|
+
let thinkingBlockOpen = false;
|
|
338
|
+
let textBlockOpen = false;
|
|
339
|
+
let inputTokens = 0;
|
|
340
|
+
let outputTokens = 0;
|
|
341
|
+
let cachedReadTokens = 0;
|
|
342
|
+
const openBlockIndices = new Set;
|
|
343
|
+
let pendingFinishReason = null;
|
|
344
|
+
let pendingHasToolCalls = false;
|
|
345
|
+
for await (const chunk of stream) {
|
|
346
|
+
const choice = chunk.choices?.[0];
|
|
347
|
+
const delta = choice?.delta;
|
|
348
|
+
if (chunk.usage) {
|
|
349
|
+
inputTokens = chunk.usage.prompt_tokens ?? inputTokens;
|
|
350
|
+
outputTokens = chunk.usage.completion_tokens ?? outputTokens;
|
|
351
|
+
const details = chunk.usage.prompt_tokens_details;
|
|
352
|
+
if (details?.cached_tokens != null) {
|
|
353
|
+
cachedReadTokens = details.cached_tokens;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
if (!started) {
|
|
357
|
+
started = true;
|
|
358
|
+
yield {
|
|
359
|
+
type: "message_start",
|
|
360
|
+
message: {
|
|
361
|
+
id: messageId,
|
|
362
|
+
type: "message",
|
|
363
|
+
role: "assistant",
|
|
364
|
+
content: [],
|
|
365
|
+
model,
|
|
366
|
+
stop_reason: null,
|
|
367
|
+
stop_sequence: null,
|
|
368
|
+
usage: {
|
|
369
|
+
input_tokens: inputTokens,
|
|
370
|
+
output_tokens: 0,
|
|
371
|
+
cache_creation_input_tokens: 0,
|
|
372
|
+
cache_read_input_tokens: cachedReadTokens
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
if (!delta)
|
|
378
|
+
continue;
|
|
379
|
+
const reasoningContent = delta.reasoning_content;
|
|
380
|
+
if (reasoningContent != null && reasoningContent !== "") {
|
|
381
|
+
if (!thinkingBlockOpen) {
|
|
382
|
+
currentContentIndex++;
|
|
383
|
+
thinkingBlockOpen = true;
|
|
384
|
+
openBlockIndices.add(currentContentIndex);
|
|
385
|
+
yield {
|
|
386
|
+
type: "content_block_start",
|
|
387
|
+
index: currentContentIndex,
|
|
388
|
+
content_block: {
|
|
389
|
+
type: "thinking",
|
|
390
|
+
thinking: "",
|
|
391
|
+
signature: ""
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
yield {
|
|
396
|
+
type: "content_block_delta",
|
|
397
|
+
index: currentContentIndex,
|
|
398
|
+
delta: {
|
|
399
|
+
type: "thinking_delta",
|
|
400
|
+
thinking: reasoningContent
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
if (delta.content != null && delta.content !== "") {
|
|
405
|
+
if (!textBlockOpen) {
|
|
406
|
+
if (thinkingBlockOpen) {
|
|
407
|
+
yield {
|
|
408
|
+
type: "content_block_stop",
|
|
409
|
+
index: currentContentIndex
|
|
410
|
+
};
|
|
411
|
+
openBlockIndices.delete(currentContentIndex);
|
|
412
|
+
thinkingBlockOpen = false;
|
|
413
|
+
}
|
|
414
|
+
currentContentIndex++;
|
|
415
|
+
textBlockOpen = true;
|
|
416
|
+
openBlockIndices.add(currentContentIndex);
|
|
417
|
+
yield {
|
|
418
|
+
type: "content_block_start",
|
|
419
|
+
index: currentContentIndex,
|
|
420
|
+
content_block: {
|
|
421
|
+
type: "text",
|
|
422
|
+
text: ""
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
yield {
|
|
427
|
+
type: "content_block_delta",
|
|
428
|
+
index: currentContentIndex,
|
|
429
|
+
delta: {
|
|
430
|
+
type: "text_delta",
|
|
431
|
+
text: delta.content
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
if (delta.tool_calls) {
|
|
436
|
+
for (const tc of delta.tool_calls) {
|
|
437
|
+
const tcIndex = tc.index;
|
|
438
|
+
if (!toolBlocks.has(tcIndex)) {
|
|
439
|
+
if (thinkingBlockOpen) {
|
|
440
|
+
yield {
|
|
441
|
+
type: "content_block_stop",
|
|
442
|
+
index: currentContentIndex
|
|
443
|
+
};
|
|
444
|
+
openBlockIndices.delete(currentContentIndex);
|
|
445
|
+
thinkingBlockOpen = false;
|
|
446
|
+
}
|
|
447
|
+
if (textBlockOpen) {
|
|
448
|
+
yield {
|
|
449
|
+
type: "content_block_stop",
|
|
450
|
+
index: currentContentIndex
|
|
451
|
+
};
|
|
452
|
+
openBlockIndices.delete(currentContentIndex);
|
|
453
|
+
textBlockOpen = false;
|
|
454
|
+
}
|
|
455
|
+
currentContentIndex++;
|
|
456
|
+
const toolId = tc.id || `toolu_${randomUUID().replace(/-/g, "").slice(0, 24)}`;
|
|
457
|
+
const toolName = tc.function?.name || "";
|
|
458
|
+
toolBlocks.set(tcIndex, {
|
|
459
|
+
contentIndex: currentContentIndex,
|
|
460
|
+
id: toolId,
|
|
461
|
+
name: toolName,
|
|
462
|
+
arguments: ""
|
|
463
|
+
});
|
|
464
|
+
openBlockIndices.add(currentContentIndex);
|
|
465
|
+
yield {
|
|
466
|
+
type: "content_block_start",
|
|
467
|
+
index: currentContentIndex,
|
|
468
|
+
content_block: {
|
|
469
|
+
type: "tool_use",
|
|
470
|
+
id: toolId,
|
|
471
|
+
name: toolName,
|
|
472
|
+
input: {}
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
const argFragment = tc.function?.arguments;
|
|
477
|
+
if (argFragment) {
|
|
478
|
+
toolBlocks.get(tcIndex).arguments += argFragment;
|
|
479
|
+
yield {
|
|
480
|
+
type: "content_block_delta",
|
|
481
|
+
index: toolBlocks.get(tcIndex).contentIndex,
|
|
482
|
+
delta: {
|
|
483
|
+
type: "input_json_delta",
|
|
484
|
+
partial_json: argFragment
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (choice?.finish_reason) {
|
|
491
|
+
if (thinkingBlockOpen) {
|
|
492
|
+
yield {
|
|
493
|
+
type: "content_block_stop",
|
|
494
|
+
index: currentContentIndex
|
|
495
|
+
};
|
|
496
|
+
openBlockIndices.delete(currentContentIndex);
|
|
497
|
+
thinkingBlockOpen = false;
|
|
498
|
+
}
|
|
499
|
+
if (textBlockOpen) {
|
|
500
|
+
yield {
|
|
501
|
+
type: "content_block_stop",
|
|
502
|
+
index: currentContentIndex
|
|
503
|
+
};
|
|
504
|
+
openBlockIndices.delete(currentContentIndex);
|
|
505
|
+
textBlockOpen = false;
|
|
506
|
+
}
|
|
507
|
+
for (const [, block] of toolBlocks) {
|
|
508
|
+
if (openBlockIndices.has(block.contentIndex)) {
|
|
509
|
+
yield {
|
|
510
|
+
type: "content_block_stop",
|
|
511
|
+
index: block.contentIndex
|
|
512
|
+
};
|
|
513
|
+
openBlockIndices.delete(block.contentIndex);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
pendingFinishReason = choice.finish_reason;
|
|
517
|
+
pendingHasToolCalls = toolBlocks.size > 0;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
for (const idx of openBlockIndices) {
|
|
521
|
+
yield {
|
|
522
|
+
type: "content_block_stop",
|
|
523
|
+
index: idx
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
if (pendingFinishReason !== null) {
|
|
527
|
+
const stopReason = pendingFinishReason === "length" ? "max_tokens" : pendingHasToolCalls ? "tool_use" : mapFinishReason(pendingFinishReason);
|
|
528
|
+
yield {
|
|
529
|
+
type: "message_delta",
|
|
530
|
+
delta: {
|
|
531
|
+
stop_reason: stopReason,
|
|
532
|
+
stop_sequence: null
|
|
533
|
+
},
|
|
534
|
+
usage: {
|
|
535
|
+
input_tokens: inputTokens,
|
|
536
|
+
output_tokens: outputTokens,
|
|
537
|
+
cache_read_input_tokens: cachedReadTokens,
|
|
538
|
+
cache_creation_input_tokens: 0
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
yield {
|
|
542
|
+
type: "message_stop"
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function mapFinishReason(reason) {
|
|
547
|
+
switch (reason) {
|
|
548
|
+
case "stop":
|
|
549
|
+
return "end_turn";
|
|
550
|
+
case "tool_calls":
|
|
551
|
+
return "tool_use";
|
|
552
|
+
case "length":
|
|
553
|
+
return "max_tokens";
|
|
554
|
+
case "content_filter":
|
|
555
|
+
return "end_turn";
|
|
556
|
+
default:
|
|
557
|
+
return "end_turn";
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
var init_streamAdapter = () => {};
|
|
561
|
+
|
|
562
|
+
// src/services/api/openai/index.ts
|
|
563
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
564
|
+
function isOpenAIThinkingEnabled(model) {
|
|
565
|
+
if (isEnvDefinedFalsy(process.env.OPENAI_ENABLE_THINKING))
|
|
566
|
+
return false;
|
|
567
|
+
if (isEnvTruthy(process.env.OPENAI_ENABLE_THINKING))
|
|
568
|
+
return true;
|
|
569
|
+
const modelLower = model.toLowerCase();
|
|
570
|
+
return modelLower.includes("deepseek");
|
|
571
|
+
}
|
|
572
|
+
function buildOpenAIRequestBody(params) {
|
|
573
|
+
const { model, messages, tools, toolChoice, enableThinking, maxTokens, temperatureOverride } = params;
|
|
574
|
+
return {
|
|
575
|
+
model,
|
|
576
|
+
messages,
|
|
577
|
+
max_tokens: maxTokens,
|
|
578
|
+
...tools.length > 0 && {
|
|
579
|
+
tools,
|
|
580
|
+
...toolChoice && { tool_choice: toolChoice }
|
|
581
|
+
},
|
|
582
|
+
stream: true,
|
|
583
|
+
stream_options: { include_usage: true },
|
|
584
|
+
...enableThinking && {
|
|
585
|
+
thinking: { type: "enabled" },
|
|
586
|
+
enable_thinking: true,
|
|
587
|
+
chat_template_kwargs: { thinking: true }
|
|
588
|
+
},
|
|
589
|
+
...!enableThinking && temperatureOverride !== undefined && {
|
|
590
|
+
temperature: temperatureOverride
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function resolveOpenAIMaxTokens(upperLimit, maxOutputTokensOverride) {
|
|
595
|
+
return maxOutputTokensOverride ?? (process.env.OPENAI_MAX_TOKENS ? parseInt(process.env.OPENAI_MAX_TOKENS, 10) || undefined : undefined) ?? (process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS ? parseInt(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS, 10) || undefined : undefined) ?? upperLimit;
|
|
596
|
+
}
|
|
597
|
+
function prependDeferredToolListIfNeeded(messages, tools, deferredToolNames, useToolSearch) {
|
|
598
|
+
if (!useToolSearch || isDeferredToolsDeltaEnabled())
|
|
599
|
+
return messages;
|
|
600
|
+
const deferredToolList = tools.filter((tool) => deferredToolNames.has(tool.name)).map(formatDeferredToolLine).sort().join(`
|
|
601
|
+
`);
|
|
602
|
+
if (!deferredToolList)
|
|
603
|
+
return messages;
|
|
604
|
+
return [
|
|
605
|
+
createUserMessage({
|
|
606
|
+
content: `<available-deferred-tools>
|
|
607
|
+
${deferredToolList}
|
|
608
|
+
</available-deferred-tools>`,
|
|
609
|
+
isMeta: true
|
|
610
|
+
}),
|
|
611
|
+
...messages
|
|
612
|
+
];
|
|
613
|
+
}
|
|
614
|
+
function isOpenAIConvertibleMessage(msg) {
|
|
615
|
+
return msg.type === "assistant" || msg.type === "user";
|
|
616
|
+
}
|
|
617
|
+
function assembleFinalAssistantOutputs(params) {
|
|
618
|
+
const { partialMessage, contentBlocks, tools, agentId, usage, stopReason, maxTokens } = params;
|
|
619
|
+
const outputs = [];
|
|
620
|
+
const allBlocks = Object.keys(contentBlocks).sort((a, b) => Number(a) - Number(b)).map((k) => contentBlocks[Number(k)]).filter(Boolean);
|
|
621
|
+
if (allBlocks.length > 0) {
|
|
622
|
+
outputs.push({
|
|
623
|
+
message: {
|
|
624
|
+
...partialMessage,
|
|
625
|
+
content: normalizeContentFromAPI(allBlocks, tools, agentId),
|
|
626
|
+
usage,
|
|
627
|
+
stop_reason: stopReason,
|
|
628
|
+
stop_sequence: null
|
|
629
|
+
},
|
|
630
|
+
requestId: undefined,
|
|
631
|
+
type: "assistant",
|
|
632
|
+
uuid: randomUUID2(),
|
|
633
|
+
timestamp: new Date().toISOString()
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
if (stopReason === "max_tokens") {
|
|
637
|
+
outputs.push(createAssistantAPIErrorMessage({
|
|
638
|
+
content: `Output truncated: response exceeded the ${maxTokens} token limit. ` + `Set OPENAI_MAX_TOKENS or CLAUDE_CODE_MAX_OUTPUT_TOKENS to override.`,
|
|
639
|
+
apiError: "max_output_tokens",
|
|
640
|
+
error: "max_output_tokens"
|
|
641
|
+
}));
|
|
642
|
+
}
|
|
643
|
+
return outputs;
|
|
644
|
+
}
|
|
645
|
+
async function* queryModelOpenAI(messages, systemPrompt, tools, signal, options) {
|
|
646
|
+
try {
|
|
647
|
+
const openaiModel = resolveOpenAIModel(options.model);
|
|
648
|
+
const messagesForAPI = normalizeMessagesForAPI(messages, tools);
|
|
649
|
+
const useToolSearch = await isToolSearchEnabled(options.model, tools, options.getToolPermissionContext || (async () => getEmptyToolPermissionContext()), options.agents || [], options.querySource);
|
|
650
|
+
const deferredToolNames = new Set;
|
|
651
|
+
if (useToolSearch) {
|
|
652
|
+
for (const t of tools) {
|
|
653
|
+
if (isDeferredTool(t))
|
|
654
|
+
deferredToolNames.add(t.name);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
let filteredTools = tools;
|
|
658
|
+
if (useToolSearch && deferredToolNames.size > 0) {
|
|
659
|
+
const discoveredToolNames = extractDiscoveredToolNames(messages);
|
|
660
|
+
filteredTools = tools.filter((tool) => {
|
|
661
|
+
if (!deferredToolNames.has(tool.name))
|
|
662
|
+
return true;
|
|
663
|
+
if (toolMatchesName(tool, TOOL_SEARCH_TOOL_NAME))
|
|
664
|
+
return true;
|
|
665
|
+
return discoveredToolNames.has(tool.name);
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
const toolSchemas = await Promise.all(filteredTools.map((tool) => toolToAPISchema(tool, {
|
|
669
|
+
getToolPermissionContext: options.getToolPermissionContext,
|
|
670
|
+
tools,
|
|
671
|
+
agents: options.agents,
|
|
672
|
+
allowedAgentTypes: options.allowedAgentTypes,
|
|
673
|
+
model: options.model,
|
|
674
|
+
deferLoading: useToolSearch && deferredToolNames.has(tool.name)
|
|
675
|
+
})));
|
|
676
|
+
const standardTools = toolSchemas.filter((t) => {
|
|
677
|
+
const anyT = t;
|
|
678
|
+
return anyT.type !== "advisor_20260301" && anyT.type !== "computer_20250124";
|
|
679
|
+
});
|
|
680
|
+
const enableThinking = isOpenAIThinkingEnabled(openaiModel);
|
|
681
|
+
const openAIConvertibleMessages = messagesForAPI.filter(isOpenAIConvertibleMessage);
|
|
682
|
+
const messagesWithDeferredToolList = prependDeferredToolListIfNeeded(openAIConvertibleMessages, tools, deferredToolNames, useToolSearch);
|
|
683
|
+
const openaiMessages = anthropicMessagesToOpenAI(messagesWithDeferredToolList, systemPrompt, { enableThinking });
|
|
684
|
+
const openaiTools = anthropicToolsToOpenAI(standardTools);
|
|
685
|
+
const openaiToolChoice = anthropicToolChoiceToOpenAI(options.toolChoice);
|
|
686
|
+
if (useToolSearch) {
|
|
687
|
+
const includedDeferredTools = filteredTools.filter((t) => deferredToolNames.has(t.name)).length;
|
|
688
|
+
logForDebugging(`[OpenAI] Tool search enabled: ${includedDeferredTools}/${deferredToolNames.size} deferred tools included, total tools=${openaiTools.length}`);
|
|
689
|
+
} else {
|
|
690
|
+
logForDebugging(`[OpenAI] Tool search disabled, total tools=${openaiTools.length}`);
|
|
691
|
+
}
|
|
692
|
+
const { upperLimit } = getModelMaxOutputTokens(openaiModel);
|
|
693
|
+
const maxTokens = resolveOpenAIMaxTokens(upperLimit, options.maxOutputTokensOverride);
|
|
694
|
+
const client = getOpenAIClient({
|
|
695
|
+
maxRetries: 0,
|
|
696
|
+
fetchOverride: options.fetchOverride,
|
|
697
|
+
source: options.querySource
|
|
698
|
+
});
|
|
699
|
+
const debugTimestamp = Date.now();
|
|
700
|
+
const debugRequestData = {
|
|
701
|
+
model: openaiModel,
|
|
702
|
+
systemPrompt_text: systemPrompt.join(`
|
|
703
|
+
|
|
704
|
+
`),
|
|
705
|
+
openai_messages_preview: openaiMessages.slice(0, 3).map((m) => ({
|
|
706
|
+
role: m.role,
|
|
707
|
+
content_preview: typeof m.content === "string" ? m.content.substring(0, 500) : JSON.stringify(m.content)?.substring(0, 500)
|
|
708
|
+
})),
|
|
709
|
+
tools_names: openaiTools.map((t) => t.function?.name ?? t.name)
|
|
710
|
+
};
|
|
711
|
+
logForDebugging(`[OpenAI] Calling model=${openaiModel}, messages=${openaiMessages.length}, tools=${openaiTools.length}, thinking=${enableThinking}`);
|
|
712
|
+
const requestBody = buildOpenAIRequestBody({
|
|
713
|
+
model: openaiModel,
|
|
714
|
+
messages: openaiMessages,
|
|
715
|
+
tools: openaiTools,
|
|
716
|
+
toolChoice: openaiToolChoice,
|
|
717
|
+
enableThinking,
|
|
718
|
+
maxTokens,
|
|
719
|
+
temperatureOverride: options.temperatureOverride
|
|
720
|
+
});
|
|
721
|
+
const stream = await client.chat.completions.create(requestBody, { signal });
|
|
722
|
+
const adaptedStream = adaptOpenAIStreamToAnthropic(stream, openaiModel);
|
|
723
|
+
const contentBlocks = {};
|
|
724
|
+
const collectedMessages = [];
|
|
725
|
+
let partialMessage;
|
|
726
|
+
let stopReason = null;
|
|
727
|
+
let usage = {
|
|
728
|
+
input_tokens: 0,
|
|
729
|
+
output_tokens: 0,
|
|
730
|
+
cache_creation_input_tokens: 0,
|
|
731
|
+
cache_read_input_tokens: 0
|
|
732
|
+
};
|
|
733
|
+
let ttftMs = 0;
|
|
734
|
+
const start = Date.now();
|
|
735
|
+
for await (const event of adaptedStream) {
|
|
736
|
+
switch (event.type) {
|
|
737
|
+
case "message_start": {
|
|
738
|
+
partialMessage = event.message;
|
|
739
|
+
ttftMs = Date.now() - start;
|
|
740
|
+
if (event.message?.usage) {
|
|
741
|
+
usage = {
|
|
742
|
+
...usage,
|
|
743
|
+
...event.message.usage
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
case "content_block_start": {
|
|
749
|
+
const idx = event.index;
|
|
750
|
+
const cb = event.content_block;
|
|
751
|
+
if (cb.type === "tool_use") {
|
|
752
|
+
contentBlocks[idx] = { ...cb, input: "" };
|
|
753
|
+
} else if (cb.type === "text") {
|
|
754
|
+
contentBlocks[idx] = { ...cb, text: "" };
|
|
755
|
+
} else if (cb.type === "thinking") {
|
|
756
|
+
contentBlocks[idx] = { ...cb, thinking: "", signature: "" };
|
|
757
|
+
} else {
|
|
758
|
+
contentBlocks[idx] = { ...cb };
|
|
759
|
+
}
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
case "content_block_delta": {
|
|
763
|
+
const idx = event.index;
|
|
764
|
+
const delta = event.delta;
|
|
765
|
+
const block = contentBlocks[idx];
|
|
766
|
+
if (!block)
|
|
767
|
+
break;
|
|
768
|
+
if (delta.type === "text_delta") {
|
|
769
|
+
block.text = (block.text || "") + delta.text;
|
|
770
|
+
} else if (delta.type === "input_json_delta") {
|
|
771
|
+
block.input = (block.input || "") + delta.partial_json;
|
|
772
|
+
} else if (delta.type === "thinking_delta") {
|
|
773
|
+
block.thinking = (block.thinking || "") + delta.thinking;
|
|
774
|
+
} else if (delta.type === "signature_delta") {
|
|
775
|
+
block.signature = delta.signature;
|
|
776
|
+
}
|
|
777
|
+
break;
|
|
778
|
+
}
|
|
779
|
+
case "content_block_stop": {
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
case "message_delta": {
|
|
783
|
+
const deltaUsage = event.usage;
|
|
784
|
+
if (deltaUsage) {
|
|
785
|
+
usage = { ...usage, ...deltaUsage };
|
|
786
|
+
}
|
|
787
|
+
if (event.delta?.stop_reason != null) {
|
|
788
|
+
stopReason = event.delta.stop_reason;
|
|
789
|
+
}
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
case "message_stop": {
|
|
793
|
+
if (partialMessage) {
|
|
794
|
+
for (const output of assembleFinalAssistantOutputs({
|
|
795
|
+
partialMessage,
|
|
796
|
+
contentBlocks,
|
|
797
|
+
tools,
|
|
798
|
+
agentId: options.agentId,
|
|
799
|
+
usage,
|
|
800
|
+
stopReason,
|
|
801
|
+
maxTokens
|
|
802
|
+
})) {
|
|
803
|
+
if (output.type === "assistant") {
|
|
804
|
+
collectedMessages.push(output);
|
|
805
|
+
}
|
|
806
|
+
yield output;
|
|
807
|
+
}
|
|
808
|
+
partialMessage = null;
|
|
809
|
+
}
|
|
810
|
+
if (usage.input_tokens + usage.output_tokens > 0) {
|
|
811
|
+
const costUSD = calculateUSDCost(openaiModel, usage);
|
|
812
|
+
addToTotalSessionCost(costUSD, usage, options.model);
|
|
813
|
+
}
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
yield {
|
|
818
|
+
type: "stream_event",
|
|
819
|
+
event,
|
|
820
|
+
...event.type === "message_start" ? { ttftMs } : undefined
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
if (partialMessage) {
|
|
824
|
+
for (const output of assembleFinalAssistantOutputs({
|
|
825
|
+
partialMessage,
|
|
826
|
+
contentBlocks,
|
|
827
|
+
tools,
|
|
828
|
+
agentId: options.agentId,
|
|
829
|
+
usage,
|
|
830
|
+
stopReason,
|
|
831
|
+
maxTokens
|
|
832
|
+
})) {
|
|
833
|
+
yield output;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
try {
|
|
837
|
+
const { writeFileSync, mkdirSync } = await import("fs");
|
|
838
|
+
const { join } = await import("path");
|
|
839
|
+
const { tmpdir } = await import("os");
|
|
840
|
+
const debugDir = join(tmpdir(), "claude-code-debug");
|
|
841
|
+
mkdirSync(debugDir, { recursive: true });
|
|
842
|
+
const debugFile = join(debugDir, `openai-${debugTimestamp}.json`);
|
|
843
|
+
const allBlocks = Object.keys(contentBlocks).sort((a, b) => Number(a) - Number(b)).map((k) => contentBlocks[Number(k)]).filter(Boolean);
|
|
844
|
+
const debugPayload = {
|
|
845
|
+
timestamp: new Date(debugTimestamp).toISOString(),
|
|
846
|
+
model: openaiModel,
|
|
847
|
+
request: debugRequestData,
|
|
848
|
+
response: {
|
|
849
|
+
stop_reason: stopReason,
|
|
850
|
+
usage,
|
|
851
|
+
content_blocks: allBlocks.map((b) => {
|
|
852
|
+
if (b.type === "text")
|
|
853
|
+
return { type: "text", text: b.text };
|
|
854
|
+
if (b.type === "thinking")
|
|
855
|
+
return { type: "thinking", thinking_preview: b.thinking?.substring(0, 200) };
|
|
856
|
+
if (b.type === "tool_use")
|
|
857
|
+
return { type: "tool_use", name: b.name, input_preview: typeof b.input === "string" ? b.input.substring(0, 500) : b.input };
|
|
858
|
+
return { type: b.type };
|
|
859
|
+
}),
|
|
860
|
+
duration_ms: Date.now() - start
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
writeFileSync(debugFile, JSON.stringify(debugPayload, null, 2), "utf-8");
|
|
864
|
+
logForDebugging(`[DEBUG] OpenAI request+response dumped to ${debugFile}`);
|
|
865
|
+
} catch (e) {
|
|
866
|
+
logForDebugging(`[DEBUG] Failed to dump OpenAI debug file: ${e}`);
|
|
867
|
+
}
|
|
868
|
+
} catch (error) {
|
|
869
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
870
|
+
logForDebugging(`[OpenAI] Error: ${errorMessage}`, { level: "error" });
|
|
871
|
+
yield createAssistantAPIErrorMessage({
|
|
872
|
+
content: `API Error: ${errorMessage}`,
|
|
873
|
+
apiError: "api_error",
|
|
874
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
var init_openai = __esm(() => {
|
|
879
|
+
init_client();
|
|
880
|
+
init_convertMessages();
|
|
881
|
+
init_convertTools();
|
|
882
|
+
init_streamAdapter();
|
|
883
|
+
init_modelMapping();
|
|
884
|
+
init_messages();
|
|
885
|
+
init_api();
|
|
886
|
+
init_Tool();
|
|
887
|
+
init_debug();
|
|
888
|
+
init_cost_tracker();
|
|
889
|
+
init_modelCost();
|
|
890
|
+
init_envUtils();
|
|
891
|
+
init_context();
|
|
892
|
+
init_messages();
|
|
893
|
+
init_toolSearch();
|
|
894
|
+
init_prompt();
|
|
895
|
+
});
|
|
896
|
+
init_openai();
|
|
897
|
+
|
|
898
|
+
export {
|
|
899
|
+
resolveOpenAIMaxTokens,
|
|
900
|
+
queryModelOpenAI,
|
|
901
|
+
isOpenAIThinkingEnabled,
|
|
902
|
+
buildOpenAIRequestBody
|
|
903
|
+
};
|