@theokit/sdk 4.53.1 → 4.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1184 -0
- package/README.md +9 -4
- package/dist/a2a/agent-mailbox.d.cts +27 -0
- package/dist/a2a/agent-mailbox.d.ts +27 -0
- package/dist/a2a/index.cjs +9 -4
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +7 -2
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/message-bus.d.cts +39 -0
- package/dist/a2a/message-bus.d.ts +39 -0
- package/dist/a2a/subagent.d.cts +68 -7
- package/dist/a2a/subagent.d.ts +68 -7
- package/dist/a2a/types.d.cts +26 -0
- package/dist/a2a/types.d.ts +26 -0
- package/dist/{agent-B9HXlwID.d.ts → agent-D3Xr_-6Z.d.cts} +245 -850
- package/dist/{agent-nLqeXKIX.d.cts → agent-DIu6FooJ.d.ts} +245 -850
- package/dist/agent-HDEVVUBS.js +52 -0
- package/dist/{agent-FFVV4U5N.js.map → agent-HDEVVUBS.js.map} +1 -1
- package/dist/agent-R2HOJFZJ.cjs +61 -0
- package/dist/{agent-YLAHVHEH.cjs.map → agent-R2HOJFZJ.cjs.map} +1 -1
- package/dist/agent-builder.d.ts +19 -0
- package/dist/agent-session-store-P6V3FINW.js +7 -0
- package/dist/{agent-session-store-TNCGL5RN.js.map → agent-session-store-P6V3FINW.js.map} +1 -1
- package/dist/agent-session-store-ZJ3JSRS4.cjs +24 -0
- package/dist/{agent-session-store-DUGBAX5V.cjs.map → agent-session-store-ZJ3JSRS4.cjs.map} +1 -1
- package/dist/agent.d.ts +9 -6
- package/dist/auth/index.cjs +52 -35
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.js +26 -9
- package/dist/auth/index.js.map +1 -1
- package/dist/{batch-UPKN4SG6.js → batch-2TGJMNCJ.js} +14 -13
- package/dist/batch-2TGJMNCJ.js.map +1 -0
- package/dist/{batch-ZEFN5SO7.cjs → batch-ND32UKZS.cjs} +31 -30
- package/dist/batch-ND32UKZS.cjs.map +1 -0
- package/dist/{chunk-TTJ54H3E.cjs → chunk-2ADR2GSO.cjs} +8 -8
- package/dist/chunk-2ADR2GSO.cjs.map +1 -0
- package/dist/chunk-2BDH744Z.js +15 -0
- package/dist/chunk-2BDH744Z.js.map +1 -0
- package/dist/{chunk-VGPXHHF3.cjs → chunk-2C72DXQF.cjs} +63 -27
- package/dist/chunk-2C72DXQF.cjs.map +1 -0
- package/dist/{chunk-4Q4K4WB5.js → chunk-2D34UTDC.js} +20 -4
- package/dist/chunk-2D34UTDC.js.map +1 -0
- package/dist/{chunk-UFIXH26P.js → chunk-2QKTVKH3.js} +4 -4
- package/dist/{chunk-UFIXH26P.js.map → chunk-2QKTVKH3.js.map} +1 -1
- package/dist/{chunk-GBBDINFK.js → chunk-3E77SX4H.js} +4 -4
- package/dist/{chunk-GBBDINFK.js.map → chunk-3E77SX4H.js.map} +1 -1
- package/dist/{chunk-VYHJZVL5.cjs → chunk-3EE6LVWT.cjs} +2 -2
- package/dist/chunk-3EE6LVWT.cjs.map +1 -0
- package/dist/{chunk-5NBUH3NO.js → chunk-3OR54XG4.js} +2 -2
- package/dist/{chunk-C6Y6CWYD.cjs.map → chunk-3OR54XG4.js.map} +1 -1
- package/dist/{chunk-ZN2DGEY3.cjs → chunk-3YJNUKYN.cjs} +15 -15
- package/dist/{chunk-ZN2DGEY3.cjs.map → chunk-3YJNUKYN.cjs.map} +1 -1
- package/dist/{chunk-POWRZSK4.js → chunk-44JAAH4X.js} +3 -3
- package/dist/{chunk-POWRZSK4.js.map → chunk-44JAAH4X.js.map} +1 -1
- package/dist/{chunk-SSDD676S.js → chunk-44MBDIHG.js} +4 -4
- package/dist/{chunk-SSDD676S.js.map → chunk-44MBDIHG.js.map} +1 -1
- package/dist/{chunk-OY7O3Q6R.js → chunk-4ERPXIVB.js} +5 -5
- package/dist/{chunk-OY7O3Q6R.js.map → chunk-4ERPXIVB.js.map} +1 -1
- package/dist/{chunk-3BK6YR5P.cjs → chunk-4I55V454.cjs} +4 -4
- package/dist/{chunk-3BK6YR5P.cjs.map → chunk-4I55V454.cjs.map} +1 -1
- package/dist/{chunk-B4YA6BRS.cjs → chunk-4O5TGQBW.cjs} +30 -7
- package/dist/chunk-4O5TGQBW.cjs.map +1 -0
- package/dist/{chunk-4JBHSLQO.cjs → chunk-4OTIXDMU.cjs} +2 -2
- package/dist/{chunk-4JBHSLQO.cjs.map → chunk-4OTIXDMU.cjs.map} +1 -1
- package/dist/{chunk-C6Y6CWYD.cjs → chunk-52NKC5HT.cjs} +2 -2
- package/dist/chunk-52NKC5HT.cjs.map +1 -0
- package/dist/{chunk-665SFFFR.cjs → chunk-53CBTBWO.cjs} +11 -11
- package/dist/{chunk-665SFFFR.cjs.map → chunk-53CBTBWO.cjs.map} +1 -1
- package/dist/{chunk-FFM3SJTQ.js → chunk-5JLFFPCH.js} +4 -4
- package/dist/{chunk-FFM3SJTQ.js.map → chunk-5JLFFPCH.js.map} +1 -1
- package/dist/{chunk-34XOCZJO.js → chunk-5PHVENFV.js} +3 -3
- package/dist/chunk-5PHVENFV.js.map +1 -0
- package/dist/{chunk-BDTVFIPB.cjs → chunk-5UOVYM3P.cjs} +36 -31
- package/dist/chunk-5UOVYM3P.cjs.map +1 -0
- package/dist/{chunk-VF7X6HDR.cjs → chunk-5USCYPPI.cjs} +15 -15
- package/dist/{chunk-VF7X6HDR.cjs.map → chunk-5USCYPPI.cjs.map} +1 -1
- package/dist/chunk-6HTXPPHK.cjs +18 -0
- package/dist/chunk-6HTXPPHK.cjs.map +1 -0
- package/dist/{chunk-D24WJWN2.js → chunk-AEOZTXVW.js} +3 -3
- package/dist/{chunk-D24WJWN2.js.map → chunk-AEOZTXVW.js.map} +1 -1
- package/dist/{chunk-DGOG5NXR.js → chunk-AG5JPQIY.js} +3 -3
- package/dist/{chunk-DGOG5NXR.js.map → chunk-AG5JPQIY.js.map} +1 -1
- package/dist/{chunk-BFYGJGC5.js → chunk-AQLGBKNT.js} +3 -3
- package/dist/chunk-AQLGBKNT.js.map +1 -0
- package/dist/{chunk-7W7ZWMLQ.js → chunk-AWO27VRZ.js} +3 -3
- package/dist/chunk-AWO27VRZ.js.map +1 -0
- package/dist/{chunk-VYCKUKPA.cjs → chunk-B2J4ZMZL.cjs} +3 -2
- package/dist/chunk-B2J4ZMZL.cjs.map +1 -0
- package/dist/{chunk-BERBYXFH.js → chunk-BMAZLQQ4.js} +3 -3
- package/dist/{chunk-BERBYXFH.js.map → chunk-BMAZLQQ4.js.map} +1 -1
- package/dist/{chunk-5YKNEMXR.cjs → chunk-BVZW2B5V.cjs} +4 -4
- package/dist/chunk-BVZW2B5V.cjs.map +1 -0
- package/dist/{chunk-MSFLYJDY.js → chunk-CQ2TQ32Y.js} +4 -4
- package/dist/chunk-CQ2TQ32Y.js.map +1 -0
- package/dist/{chunk-C5DEO6OI.cjs → chunk-CQGYNZ3K.cjs} +4 -4
- package/dist/{chunk-C5DEO6OI.cjs.map → chunk-CQGYNZ3K.cjs.map} +1 -1
- package/dist/{chunk-D75S2X6I.cjs → chunk-CTCGWIUD.cjs} +5 -5
- package/dist/{chunk-D75S2X6I.cjs.map → chunk-CTCGWIUD.cjs.map} +1 -1
- package/dist/{chunk-NZL4BNFQ.js → chunk-CV7XMBHP.js} +4 -4
- package/dist/chunk-CV7XMBHP.js.map +1 -0
- package/dist/{chunk-SEL2ZQMT.js → chunk-DAPSQZT4.js} +15 -10
- package/dist/chunk-DAPSQZT4.js.map +1 -0
- package/dist/{chunk-SVO5WPZX.cjs → chunk-DQKERTND.cjs} +11 -11
- package/dist/{chunk-SVO5WPZX.cjs.map → chunk-DQKERTND.cjs.map} +1 -1
- package/dist/{chunk-N5CR3TJZ.js → chunk-DZBSJX6J.js} +4 -4
- package/dist/{chunk-N5CR3TJZ.js.map → chunk-DZBSJX6J.js.map} +1 -1
- package/dist/{chunk-RAHSWE5C.cjs → chunk-EI2Q7SJ5.cjs} +12 -12
- package/dist/chunk-EI2Q7SJ5.cjs.map +1 -0
- package/dist/{chunk-UCFONJBG.js → chunk-EPSICJLZ.js} +2 -2
- package/dist/{chunk-UCFONJBG.js.map → chunk-EPSICJLZ.js.map} +1 -1
- package/dist/{chunk-3X6PM7DU.cjs → chunk-F3YZMOAU.cjs} +8 -8
- package/dist/{chunk-3X6PM7DU.cjs.map → chunk-F3YZMOAU.cjs.map} +1 -1
- package/dist/{chunk-F77UENR6.cjs → chunk-F5WMX4EA.cjs} +586 -398
- package/dist/chunk-F5WMX4EA.cjs.map +1 -0
- package/dist/{chunk-HE4BIAOS.js → chunk-F7AQV62G.js} +5 -4
- package/dist/chunk-F7AQV62G.js.map +1 -0
- package/dist/{chunk-2RW7K6FN.cjs → chunk-GHX4P3V2.cjs} +2 -2
- package/dist/chunk-GHX4P3V2.cjs.map +1 -0
- package/dist/{chunk-B6HOIWQ6.js → chunk-GJ6RK75E.js} +5 -5
- package/dist/chunk-GJ6RK75E.js.map +1 -0
- package/dist/{chunk-FOXKFTVZ.cjs → chunk-GNT35C5U.cjs} +13 -13
- package/dist/chunk-GNT35C5U.cjs.map +1 -0
- package/dist/{chunk-4NAKHID5.js → chunk-GTKFV7O5.js} +2 -2
- package/dist/chunk-GTKFV7O5.js.map +1 -0
- package/dist/{chunk-ELKO4ZLR.cjs → chunk-GWC3HADL.cjs} +4 -4
- package/dist/{chunk-ELKO4ZLR.cjs.map → chunk-GWC3HADL.cjs.map} +1 -1
- package/dist/{chunk-OXNYIMZZ.js → chunk-H73MEMQB.js} +2 -2
- package/dist/chunk-H73MEMQB.js.map +1 -0
- package/dist/{chunk-E7FJOO4G.cjs → chunk-HJBMA5MB.cjs} +11 -11
- package/dist/{chunk-E7FJOO4G.cjs.map → chunk-HJBMA5MB.cjs.map} +1 -1
- package/dist/{chunk-2FYEVT2B.cjs → chunk-HLPSLDGL.cjs} +275 -160
- package/dist/chunk-HLPSLDGL.cjs.map +1 -0
- package/dist/{chunk-VW6M4B3Z.cjs → chunk-HY57ULY2.cjs} +5 -5
- package/dist/{chunk-VW6M4B3Z.cjs.map → chunk-HY57ULY2.cjs.map} +1 -1
- package/dist/{chunk-CAH3G4IS.js → chunk-HY66GLM6.js} +2 -2
- package/dist/chunk-HY66GLM6.js.map +1 -0
- package/dist/{chunk-G3JWXOGY.js → chunk-I5BE5M5L.js} +310 -122
- package/dist/chunk-I5BE5M5L.js.map +1 -0
- package/dist/{chunk-C4H6PB5J.cjs → chunk-I6TGFUCO.cjs} +4 -4
- package/dist/{chunk-C4H6PB5J.cjs.map → chunk-I6TGFUCO.cjs.map} +1 -1
- package/dist/{chunk-U4UJHOSH.js → chunk-IDCKSLYH.js} +3 -3
- package/dist/{chunk-U4UJHOSH.js.map → chunk-IDCKSLYH.js.map} +1 -1
- package/dist/{chunk-WQ53UQL4.cjs → chunk-ILCGLTSA.cjs} +4 -4
- package/dist/{chunk-WQ53UQL4.cjs.map → chunk-ILCGLTSA.cjs.map} +1 -1
- package/dist/{chunk-QBTVATSF.cjs → chunk-ITSSOVOB.cjs} +44 -47
- package/dist/chunk-ITSSOVOB.cjs.map +1 -0
- package/dist/{chunk-V6HWJQQV.js → chunk-IVNNSANC.js} +27 -30
- package/dist/chunk-IVNNSANC.js.map +1 -0
- package/dist/{chunk-SZHU7A5B.cjs → chunk-IWBGCBR6.cjs} +4 -4
- package/dist/{chunk-SZHU7A5B.cjs.map → chunk-IWBGCBR6.cjs.map} +1 -1
- package/dist/{chunk-Q4RESANI.cjs → chunk-J24VJOH3.cjs} +20 -4
- package/dist/chunk-J24VJOH3.cjs.map +1 -0
- package/dist/{chunk-Y4AXQOT4.cjs → chunk-JHPGF3FP.cjs} +8 -8
- package/dist/{chunk-Y4AXQOT4.cjs.map → chunk-JHPGF3FP.cjs.map} +1 -1
- package/dist/{chunk-BM6N4KHO.cjs → chunk-JTB5Q42C.cjs} +6 -22
- package/dist/chunk-JTB5Q42C.cjs.map +1 -0
- package/dist/{chunk-LPVIRJVF.cjs → chunk-K3FW2XZD.cjs} +9 -9
- package/dist/{chunk-LPVIRJVF.cjs.map → chunk-K3FW2XZD.cjs.map} +1 -1
- package/dist/{chunk-LS3LMQ23.js → chunk-MVAPK2BX.js} +162 -49
- package/dist/chunk-MVAPK2BX.js.map +1 -0
- package/dist/{chunk-XPR366DL.cjs → chunk-NGESVVJN.cjs} +17 -17
- package/dist/chunk-NGESVVJN.cjs.map +1 -0
- package/dist/{chunk-VUKQL3L2.cjs → chunk-NIRE5CNO.cjs} +20 -13
- package/dist/chunk-NIRE5CNO.cjs.map +1 -0
- package/dist/{chunk-VC5ABJXC.js → chunk-NLTVXLGT.js} +3 -3
- package/dist/{chunk-VC5ABJXC.js.map → chunk-NLTVXLGT.js.map} +1 -1
- package/dist/chunk-NUKRL3I6.cjs +23 -0
- package/dist/chunk-NUKRL3I6.cjs.map +1 -0
- package/dist/{chunk-R5YZACGK.js → chunk-OC4NTGMN.js} +3 -3
- package/dist/{chunk-R5YZACGK.js.map → chunk-OC4NTGMN.js.map} +1 -1
- package/dist/{chunk-GOVJO4YE.js → chunk-OHBIUXKM.js} +6 -6
- package/dist/chunk-OHBIUXKM.js.map +1 -0
- package/dist/{chunk-FPYT5WZP.cjs → chunk-P6A3M6VD.cjs} +10 -10
- package/dist/{chunk-FPYT5WZP.cjs.map → chunk-P6A3M6VD.cjs.map} +1 -1
- package/dist/{chunk-OKLYRPKL.cjs → chunk-Q47R5E2X.cjs} +8 -8
- package/dist/chunk-Q47R5E2X.cjs.map +1 -0
- package/dist/{chunk-HSQ5Q3I5.js → chunk-Q4CMI2LP.js} +12 -5
- package/dist/chunk-Q4CMI2LP.js.map +1 -0
- package/dist/{chunk-2XLKLVVR.js → chunk-Q5EWJPRY.js} +2 -2
- package/dist/chunk-Q5EWJPRY.js.map +1 -0
- package/dist/{chunk-SK4QLUBK.js → chunk-QARJGQSA.js} +16 -7
- package/dist/chunk-QARJGQSA.js.map +1 -0
- package/dist/{chunk-CZ2GKKYL.cjs → chunk-QDED6YO6.cjs} +5 -5
- package/dist/{chunk-CZ2GKKYL.cjs.map → chunk-QDED6YO6.cjs.map} +1 -1
- package/dist/{chunk-VK7MAV65.cjs → chunk-QKLOP4VC.cjs} +2 -2
- package/dist/{chunk-VK7MAV65.cjs.map → chunk-QKLOP4VC.cjs.map} +1 -1
- package/dist/{chunk-FIOCJYLA.js → chunk-QRSUA2CV.js} +3 -3
- package/dist/{chunk-FIOCJYLA.js.map → chunk-QRSUA2CV.js.map} +1 -1
- package/dist/{chunk-ZT57WTUJ.cjs → chunk-R3UPQFKK.cjs} +21 -12
- package/dist/chunk-R3UPQFKK.cjs.map +1 -0
- package/dist/{chunk-X2FR4OIT.js → chunk-R7WIIPUR.js} +2 -2
- package/dist/chunk-R7WIIPUR.js.map +1 -0
- package/dist/{chunk-RP5HQVLD.js → chunk-RNB4APBZ.js} +30 -7
- package/dist/chunk-RNB4APBZ.js.map +1 -0
- package/dist/{chunk-GD63JPGC.cjs → chunk-ROYPRJH4.cjs} +9 -9
- package/dist/{chunk-GD63JPGC.cjs.map → chunk-ROYPRJH4.cjs.map} +1 -1
- package/dist/{chunk-V26QVGUG.js → chunk-RUDY2GTT.js} +59 -23
- package/dist/chunk-RUDY2GTT.js.map +1 -0
- package/dist/{chunk-JIQRXKTA.cjs → chunk-SKXBJ2NU.cjs} +7 -7
- package/dist/chunk-SKXBJ2NU.cjs.map +1 -0
- package/dist/{chunk-XROIW6BH.js → chunk-SUKXXLWD.js} +6 -6
- package/dist/chunk-SUKXXLWD.js.map +1 -0
- package/dist/{chunk-LTSTGCL6.js → chunk-T73NA43R.js} +3 -3
- package/dist/{chunk-LTSTGCL6.js.map → chunk-T73NA43R.js.map} +1 -1
- package/dist/chunk-T7O6K6PX.js +20 -0
- package/dist/chunk-T7O6K6PX.js.map +1 -0
- package/dist/{chunk-5F5NWKPN.js → chunk-T7XEKOVW.js} +5 -20
- package/dist/chunk-T7XEKOVW.js.map +1 -0
- package/dist/{chunk-HAWE74GQ.cjs → chunk-U2AC6JUP.cjs} +8 -8
- package/dist/chunk-U2AC6JUP.cjs.map +1 -0
- package/dist/{chunk-3WVMJY7F.js → chunk-UC3HT2S4.js} +3 -3
- package/dist/{chunk-3WVMJY7F.js.map → chunk-UC3HT2S4.js.map} +1 -1
- package/dist/{chunk-PBZ7HMBP.js → chunk-UPRJR6IP.js} +4 -4
- package/dist/chunk-UPRJR6IP.js.map +1 -0
- package/dist/{chunk-3V7UJLQT.js → chunk-UQGQFBRL.js} +3 -3
- package/dist/chunk-UQGQFBRL.js.map +1 -0
- package/dist/{chunk-2D43RD5D.cjs → chunk-V2UUGUY4.cjs} +27 -27
- package/dist/chunk-V2UUGUY4.cjs.map +1 -0
- package/dist/{chunk-6AZDM6LK.js → chunk-VF7EWVDG.js} +3 -3
- package/dist/{chunk-6AZDM6LK.js.map → chunk-VF7EWVDG.js.map} +1 -1
- package/dist/{chunk-PNVDQL5Y.cjs → chunk-VTYY7XL5.cjs} +2 -2
- package/dist/chunk-VTYY7XL5.cjs.map +1 -0
- package/dist/{chunk-Y4I4EQFK.js → chunk-WKRSH2VR.js} +3 -3
- package/dist/{chunk-Y4I4EQFK.js.map → chunk-WKRSH2VR.js.map} +1 -1
- package/dist/{chunk-4QEC4CCS.js → chunk-WTMU7J4U.js} +2 -2
- package/dist/{chunk-4QEC4CCS.js.map → chunk-WTMU7J4U.js.map} +1 -1
- package/dist/{chunk-KSWHTR54.js → chunk-XN7NOENA.js} +6 -6
- package/dist/chunk-XN7NOENA.js.map +1 -0
- package/dist/{chunk-ADLLFY3H.cjs → chunk-XSX2UU6Y.cjs} +10 -9
- package/dist/chunk-XSX2UU6Y.cjs.map +1 -0
- package/dist/{chunk-LD4MOBFX.js → chunk-XV4IZNV4.js} +9 -9
- package/dist/chunk-XV4IZNV4.js.map +1 -0
- package/dist/{chunk-EZ2YEF4F.cjs → chunk-XWL6O3SW.cjs} +4 -4
- package/dist/chunk-XWL6O3SW.cjs.map +1 -0
- package/dist/{chunk-PGP7IOJ2.js → chunk-YMA4S2WO.js} +4 -4
- package/dist/{chunk-PGP7IOJ2.js.map → chunk-YMA4S2WO.js.map} +1 -1
- package/dist/{chunk-OUOXM36O.cjs → chunk-YPJ5NH5N.cjs} +11 -11
- package/dist/chunk-YPJ5NH5N.cjs.map +1 -0
- package/dist/{chunk-YLQQX5W2.cjs → chunk-ZF2LDKQQ.cjs} +2 -2
- package/dist/chunk-ZF2LDKQQ.cjs.map +1 -0
- package/dist/{chunk-L5YO6PWL.cjs → chunk-ZNW6V4Y6.cjs} +2 -2
- package/dist/chunk-ZNW6V4Y6.cjs.map +1 -0
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/theokit-client.d.cts +36 -0
- package/dist/client/theokit-client.d.ts +36 -0
- package/dist/client/types.d.cts +30 -0
- package/dist/client/types.d.ts +30 -0
- package/dist/compact-session-FUJDVF7B.js +22 -0
- package/dist/{compact-session-4MNKNMO2.js.map → compact-session-FUJDVF7B.js.map} +1 -1
- package/dist/compact-session-LEWF554G.cjs +59 -0
- package/dist/{compact-session-EPFBQ46Z.cjs.map → compact-session-LEWF554G.cjs.map} +1 -1
- package/dist/compaction.cjs +17 -16
- package/dist/compaction.d.cts +13 -13
- package/dist/compaction.d.ts +13 -13
- package/dist/compaction.js +4 -3
- package/dist/concurrency.cjs +7 -6
- package/dist/concurrency.cjs.map +1 -1
- package/dist/concurrency.js +5 -4
- package/dist/concurrency.js.map +1 -1
- package/dist/context/index.cjs +7 -7
- package/dist/context/index.js +3 -3
- package/dist/context-FDOON2DB.js +6 -0
- package/dist/{context-ENXZNF6J.js.map → context-FDOON2DB.js.map} +1 -1
- package/dist/context-VMIE4BMD.cjs +23 -0
- package/dist/{context-7USNN6LP.cjs.map → context-VMIE4BMD.cjs.map} +1 -1
- package/dist/cron-BcWmzWzT.d.cts +240 -0
- package/dist/cron-De6hzWCF.d.ts +240 -0
- package/dist/cron.cjs +43 -41
- package/dist/cron.d.cts +5 -3
- package/dist/cron.d.ts +5 -3
- package/dist/cron.js +42 -40
- package/dist/define-tool.d.ts +14 -6
- package/dist/{errors-BSoXcl3F.d.cts → errors-BgJH9PHi.d.cts} +39 -24
- package/dist/{errors-CHllybaU.d.ts → errors-C5fJUqLk.d.ts} +39 -24
- package/dist/errors.cjs +22 -21
- package/dist/errors.d.cts +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +3 -2
- package/dist/eval.cjs +61 -58
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.d.cts +38 -0
- package/dist/eval.d.ts +38 -0
- package/dist/eval.js +51 -48
- package/dist/eval.js.map +1 -1
- package/dist/event-bus.d.ts +16 -0
- package/dist/{executor-2Z6XJJJG.js → executor-BMEHFOXZ.js} +8 -7
- package/dist/executor-BMEHFOXZ.js.map +1 -0
- package/dist/{executor-2Z3LGG3I.cjs → executor-ZERJ3DGN.cjs} +25 -24
- package/dist/executor-ZERJ3DGN.cjs.map +1 -0
- package/dist/filesystem/index.cjs +8 -7
- package/dist/filesystem/index.cjs.map +1 -1
- package/dist/filesystem/index.js +4 -3
- package/dist/filesystem/index.js.map +1 -1
- package/dist/filesystem/local-filesystem.d.cts +18 -0
- package/dist/filesystem/local-filesystem.d.ts +18 -0
- package/dist/filesystem/types.d.cts +12 -0
- package/dist/filesystem/types.d.ts +12 -0
- package/dist/fs-session-store-3MOJQGP2.cjs +20 -0
- package/dist/{fs-session-store-VVY2AHWG.cjs.map → fs-session-store-3MOJQGP2.cjs.map} +1 -1
- package/dist/fs-session-store-IN7JTTXD.js +11 -0
- package/dist/{fs-session-store-R5FD3EN6.js.map → fs-session-store-IN7JTTXD.js.map} +1 -1
- package/dist/generate-object-N5MDZUJI.js +8 -0
- package/dist/{generate-object-WQRCXFD2.js.map → generate-object-N5MDZUJI.js.map} +1 -1
- package/dist/generate-object-PGSP5U7N.cjs +21 -0
- package/dist/{generate-object-AVXOJK2I.cjs.map → generate-object-PGSP5U7N.cjs.map} +1 -1
- package/dist/generate-object.d.ts +20 -0
- package/dist/index-manager-NG5YENWO.cjs +22 -0
- package/dist/{index-manager-VRU3A2YL.cjs.map → index-manager-NG5YENWO.cjs.map} +1 -1
- package/dist/index-manager-ZMRJ6ZII.js +13 -0
- package/dist/{index-manager-WS7TVKUW.js.map → index-manager-ZMRJ6ZII.js.map} +1 -1
- package/dist/index.cjs +169 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +702 -54
- package/dist/index.d.ts +702 -54
- package/dist/index.js +61 -58
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-GMBMJVNZ.js → inject-session-BJMJH5BX.js} +9 -8
- package/dist/inject-session-BJMJH5BX.js.map +1 -0
- package/dist/inject-session-WQGGMCQY.cjs +29 -0
- package/dist/inject-session-WQGGMCQY.cjs.map +1 -0
- package/dist/internal/auth/auth-types.d.ts +83 -1
- package/dist/internal/auth/credential-store.d.ts +34 -6
- package/dist/internal/auth/oauth-device.d.ts +0 -1
- package/dist/internal/auth/resolve-credential.d.ts +40 -0
- package/dist/internal/budget/tracker/budget.d.ts +12 -14
- package/dist/internal/budget/usage-accumulator.d.ts +15 -0
- package/dist/internal/llm/anthropic-shared.d.ts +8 -4
- package/dist/internal/llm/model-identifier.d.ts +26 -0
- package/dist/internal/llm/openai.d.ts +8 -0
- package/dist/internal/llm/prompt-cache-key.d.ts +1 -0
- package/dist/internal/llm/responses.d.ts +67 -1
- package/dist/internal/llm/router.d.ts +8 -0
- package/dist/internal/llm/types.d.ts +27 -1
- package/dist/internal/local-agent/real-local-run-provider.d.ts +8 -3
- package/dist/internal/local-agent/real-local-run-tools.d.ts +23 -4
- package/dist/internal/mcp/oauth.d.ts +5 -0
- package/dist/internal/mcp/token-storage.d.ts +34 -0
- package/dist/internal/memory/adapters/index.cjs +12 -11
- package/dist/internal/memory/adapters/index.d.cts +3 -1
- package/dist/internal/memory/adapters/index.d.ts +3 -1
- package/dist/internal/memory/adapters/index.js +9 -8
- package/dist/internal/memory/adapters/openai-compatible.d.cts +45 -0
- package/dist/internal/memory/adapters/openai-compatible.d.ts +45 -0
- package/dist/internal/memory/embedding-cache.d.ts +42 -1
- package/dist/internal/memory/escape-like-pattern.d.ts +22 -0
- package/dist/internal/memory/sqlite-vec-loader.d.ts +1 -3
- package/dist/internal/memory/storage/markdown-store.d.ts +0 -5
- package/dist/internal/persistence/cwd-mutex.d.cts +34 -0
- package/dist/internal/persistence/cwd-mutex.d.ts +34 -0
- package/dist/internal/persistence/exclusive-create.d.cts +31 -0
- package/dist/internal/persistence/exclusive-create.d.ts +31 -0
- package/dist/internal/persistence/file-lock.d.cts +28 -0
- package/dist/internal/persistence/file-lock.d.ts +28 -0
- package/dist/internal/persistence/fs-session-store.d.cts +3 -0
- package/dist/internal/persistence/fs-session-store.d.ts +3 -0
- package/dist/internal/persistence/fts5-sanitize.d.cts +20 -0
- package/dist/internal/persistence/fts5-sanitize.d.ts +20 -0
- package/dist/internal/persistence/index.cjs +40 -39
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.d.cts +6 -1
- package/dist/internal/persistence/index.d.ts +6 -1
- package/dist/internal/persistence/index.js +9 -8
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/persistence/paths.d.cts +54 -1
- package/dist/internal/persistence/paths.d.ts +54 -1
- package/dist/internal/persistence/persistence-schema.d.cts +9 -1
- package/dist/internal/persistence/persistence-schema.d.ts +9 -1
- package/dist/internal/persistence/schema-version.d.cts +215 -1
- package/dist/internal/persistence/schema-version.d.ts +215 -1
- package/dist/internal/persistence/session-writer.d.cts +7 -7
- package/dist/internal/persistence/session-writer.d.ts +7 -7
- package/dist/internal/persistence/sqlite-cas.d.cts +37 -1
- package/dist/internal/persistence/sqlite-cas.d.ts +37 -1
- package/dist/internal/persistence/sqlite-open.d.cts +14 -0
- package/dist/internal/persistence/sqlite-open.d.ts +14 -0
- package/dist/internal/persistence/sqlite-wal.d.cts +45 -0
- package/dist/internal/persistence/sqlite-wal.d.ts +45 -0
- package/dist/internal/persistence/transcript-ops.d.cts +7 -1
- package/dist/internal/persistence/transcript-ops.d.ts +7 -1
- package/dist/internal/plugins/types.d.cts +1 -1
- package/dist/internal/plugins/types.d.ts +1 -1
- package/dist/internal/providers/builtin/openai-chatgpt.d.ts +12 -0
- package/dist/internal/providers/catalog-loader.d.ts +8 -0
- package/dist/internal/providers/catalog-schema.d.ts +55 -0
- package/dist/internal/providers/catalog-source-models-dev.d.ts +36 -0
- package/dist/internal/runtime/concurrency/delegation-depth.d.ts +27 -0
- package/dist/internal/runtime/concurrency/subagent-credentials.d.ts +33 -1
- package/dist/internal/runtime/context/context-discovery-runner.d.ts +44 -0
- package/dist/internal/runtime/context/context-discovery.d.ts +58 -0
- package/dist/internal/runtime/context/context-rules-frontmatter.d.ts +70 -1
- package/dist/internal/runtime/fixtures/fixture-mode.d.ts +15 -1
- package/dist/internal/runtime/lifecycle/post-run-lifecycle.d.ts +15 -0
- package/dist/internal/runtime/registry/agent-registry-store.d.ts +12 -0
- package/dist/internal/runtime/registry/live-agent-registry.d.ts +37 -0
- package/dist/internal/scorers/llm-judge.d.ts +6 -1
- package/dist/internal/security/index.cjs +14 -13
- package/dist/internal/security/index.d.cts +4 -1
- package/dist/internal/security/index.d.ts +4 -1
- package/dist/internal/security/index.js +4 -3
- package/dist/internal/security/path-guard.d.cts +46 -0
- package/dist/internal/security/path-guard.d.ts +46 -0
- package/dist/internal/security/redact.d.cts +71 -0
- package/dist/internal/security/redact.d.ts +71 -0
- package/dist/internal/session/agent-session.d.ts +15 -4
- package/dist/internal/session/session-cache.d.ts +5 -0
- package/dist/internal/task/store.d.ts +91 -5
- package/dist/internal/telemetry/span-names.d.ts +0 -1
- package/dist/internal/telemetry/tracer.d.ts +14 -0
- package/dist/job-queue.d.ts +18 -0
- package/dist/judge-call-DWHAJATE.js +6 -0
- package/dist/{judge-call-MDIPTBJI.js.map → judge-call-DWHAJATE.js.map} +1 -1
- package/dist/judge-call-EGYRC2RE.cjs +23 -0
- package/dist/{judge-call-G5SGV2M2.cjs.map → judge-call-EGYRC2RE.cjs.map} +1 -1
- package/dist/mcp-auth.cjs +41 -25
- package/dist/mcp-auth.cjs.map +1 -1
- package/dist/mcp-auth.js +34 -18
- package/dist/mcp-auth.js.map +1 -1
- package/dist/models.cjs +42 -27
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +25 -10
- package/dist/models.js.map +1 -1
- package/dist/oauth-transaction-store-BT4GLTLK.cjs +36 -0
- package/dist/{oauth-transaction-store-7CKHPQRN.cjs.map → oauth-transaction-store-BT4GLTLK.cjs.map} +1 -1
- package/dist/oauth-transaction-store-W52KVHQ4.js +3 -0
- package/dist/{oauth-transaction-store-W74I6EFD.js.map → oauth-transaction-store-W52KVHQ4.js.map} +1 -1
- package/dist/path-safety.cjs +11 -10
- package/dist/path-safety.js +4 -3
- package/dist/permission-engine.d.ts +55 -0
- package/dist/persistence.cjs +43 -42
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +13 -12
- package/dist/persistence.js.map +1 -1
- package/dist/project.cjs +9 -8
- package/dist/project.cjs.map +1 -1
- package/dist/project.js +5 -4
- package/dist/project.js.map +1 -1
- package/dist/providers.cjs +23 -0
- package/dist/providers.cjs.map +1 -0
- package/dist/providers.d.cts +29 -0
- package/dist/providers.d.ts +29 -0
- package/dist/providers.js +10 -0
- package/dist/providers.js.map +1 -0
- package/dist/registry-VFKX7WOP.cjs +47 -0
- package/dist/{registry-63ASMXT4.cjs.map → registry-VFKX7WOP.cjs.map} +1 -1
- package/dist/registry-VFP3WWQP.js +10 -0
- package/dist/{registry-O7FJ2MPM.js.map → registry-VFP3WWQP.js.map} +1 -1
- package/dist/retry.cjs +5 -4
- package/dist/retry.js +4 -3
- package/dist/{run-C8FBAC8o.d.cts → run-BYSHf58D.d.cts} +185 -33
- package/dist/{run-C8FBAC8o.d.ts → run-BYSHf58D.d.ts} +185 -33
- package/dist/{run-to-completion-JDPIUKSH.js → run-to-completion-DRO77625.js} +3 -3
- package/dist/{run-to-completion-JDPIUKSH.js.map → run-to-completion-DRO77625.js.map} +1 -1
- package/dist/{run-to-completion-J73I6IY4.cjs → run-to-completion-X4OWM673.cjs} +13 -13
- package/dist/{run-to-completion-J73I6IY4.cjs.map → run-to-completion-X4OWM673.cjs.map} +1 -1
- package/dist/sandbox/bwrap.d.cts +27 -13
- package/dist/sandbox/bwrap.d.ts +27 -13
- package/dist/sandbox/index.cjs +20 -19
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.js +5 -4
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/linux-sandbox.d.cts +72 -0
- package/dist/sandbox/linux-sandbox.d.ts +72 -0
- package/dist/sandbox/local-sandbox.d.cts +41 -0
- package/dist/sandbox/local-sandbox.d.ts +41 -0
- package/dist/sandbox/seccomp.d.cts +6 -0
- package/dist/sandbox/seccomp.d.ts +6 -0
- package/dist/sandbox/types.d.cts +64 -0
- package/dist/sandbox/types.d.ts +64 -0
- package/dist/scorers.d.ts +38 -7
- package/dist/sdk-agent-D8qJVkuV.d.ts +860 -0
- package/dist/sdk-agent-DEoKhA8a.d.cts +860 -0
- package/dist/server/auth/errors.d.cts +1 -1
- package/dist/server/auth/errors.d.ts +1 -1
- package/dist/server/auth/index.cjs +29 -21
- package/dist/server/auth/index.cjs.map +1 -1
- package/dist/server/auth/index.d.cts +25 -15
- package/dist/server/auth/index.d.ts +25 -15
- package/dist/server/auth/index.js +15 -7
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/oauth-transaction-store.d.cts +13 -1
- package/dist/server/auth/oauth-transaction-store.d.ts +13 -1
- package/dist/server/auth/orchestrator.d.cts +1 -1
- package/dist/server/auth/orchestrator.d.ts +1 -1
- package/dist/server/auth/types.d.cts +1 -1
- package/dist/server/auth/types.d.ts +1 -1
- package/dist/server/auth/validate-return-to.d.cts +21 -11
- package/dist/server/auth/validate-return-to.d.ts +21 -11
- package/dist/server/errors-envelope.cjs +15 -14
- package/dist/server/errors-envelope.cjs.map +1 -1
- package/dist/server/errors-envelope.d.cts +4 -4
- package/dist/server/errors-envelope.d.ts +4 -4
- package/dist/server/errors-envelope.js +4 -3
- package/dist/server/errors-envelope.js.map +1 -1
- package/dist/session-transcript-AKDYYGXQ.js +6 -0
- package/dist/{session-transcript-RAKEK76V.js.map → session-transcript-AKDYYGXQ.js.map} +1 -1
- package/dist/session-transcript-JXHFTB7G.cjs +51 -0
- package/dist/{session-transcript-DOM3UTXR.cjs.map → session-transcript-JXHFTB7G.cjs.map} +1 -1
- package/dist/skills.cjs +8 -7
- package/dist/skills.js +6 -5
- package/dist/stream-object-BUCF5PHO.cjs +21 -0
- package/dist/{stream-object-L3Q7PBMF.cjs.map → stream-object-BUCF5PHO.cjs.map} +1 -1
- package/dist/stream-object-L57K4OFS.js +8 -0
- package/dist/{stream-object-ZYXWS4B2.js.map → stream-object-L57K4OFS.js.map} +1 -1
- package/dist/{stream-to-completion-DFJ5T3BK.js → stream-to-completion-QV5HCL3J.js} +3 -3
- package/dist/{stream-to-completion-DFJ5T3BK.js.map → stream-to-completion-QV5HCL3J.js.map} +1 -1
- package/dist/{stream-to-completion-H2MHISSK.cjs → stream-to-completion-SRISU5AB.cjs} +10 -10
- package/dist/{stream-to-completion-H2MHISSK.cjs.map → stream-to-completion-SRISU5AB.cjs.map} +1 -1
- package/dist/subagents-loader-AZIXJ7D3.cjs +16 -0
- package/dist/{subagents-loader-VRW73QQT.cjs.map → subagents-loader-AZIXJ7D3.cjs.map} +1 -1
- package/dist/subagents-loader-J54ESLDV.js +7 -0
- package/dist/{subagents-loader-I56GSKAQ.js.map → subagents-loader-J54ESLDV.js.map} +1 -1
- package/dist/subagents-loader.cjs +7 -6
- package/dist/subagents-loader.cjs.map +1 -1
- package/dist/subagents-loader.d.cts +3 -2
- package/dist/subagents-loader.d.ts +3 -2
- package/dist/subagents-loader.js +5 -4
- package/dist/subagents-loader.js.map +1 -1
- package/dist/subscription/define-subscription.d.cts +1 -1
- package/dist/subscription/define-subscription.d.ts +1 -1
- package/dist/subscription/index.cjs +22 -9
- package/dist/subscription/index.cjs.map +1 -1
- package/dist/subscription/index.d.cts +1 -1
- package/dist/subscription/index.d.ts +1 -1
- package/dist/subscription/index.js +21 -8
- package/dist/subscription/index.js.map +1 -1
- package/dist/subscription/internal/adapter-types.d.cts +1 -1
- package/dist/subscription/internal/adapter-types.d.ts +1 -1
- package/dist/subscription/internal/server-integration.d.cts +1 -1
- package/dist/subscription/internal/server-integration.d.ts +1 -1
- package/dist/subscription/internal/sse-encoder.d.cts +1 -1
- package/dist/subscription/internal/sse-encoder.d.ts +1 -1
- package/dist/subscription/internal/sse-parser.d.cts +1 -1
- package/dist/subscription/internal/sse-parser.d.ts +1 -1
- package/dist/subscription/internal/subscription-runtime.d.cts +1 -1
- package/dist/subscription/internal/subscription-runtime.d.ts +1 -1
- package/dist/subscription/internal/ws-adapter-node.d.cts +1 -1
- package/dist/subscription/internal/ws-adapter-node.d.ts +1 -1
- package/dist/subscription/theokit-subscribe.d.cts +14 -1
- package/dist/subscription/theokit-subscribe.d.ts +14 -1
- package/dist/subscription/types.d.cts +19 -1
- package/dist/subscription/types.d.ts +19 -1
- package/dist/task-store.cjs +8 -7
- package/dist/task-store.js +5 -4
- package/dist/types/agent-prims.d.ts +14 -0
- package/dist/types/agent.d.ts +92 -11
- package/dist/types/batch.d.ts +7 -1
- package/dist/types/conversation.d.ts +18 -5
- package/dist/types/goal-events.d.ts +4 -8
- package/dist/types/memory-adapter.d.ts +12 -1
- package/dist/types/plugin.d.ts +101 -0
- package/dist/types/provider-profile.d.ts +32 -0
- package/dist/types/run-events.d.ts +28 -1
- package/dist/types/run.d.ts +35 -23
- package/dist/types/sdk-agent.d.ts +14 -0
- package/dist/types/session-record.d.ts +18 -1
- package/dist/types/task.d.ts +15 -1
- package/dist/types/theokit.d.ts +10 -1
- package/dist/types/updates.d.ts +35 -4
- package/dist/types/workflow.d.ts +155 -0
- package/dist/workflow.cjs +29 -28
- package/dist/workflow.d.cts +666 -17
- package/dist/workflow.d.ts +666 -17
- package/dist/workflow.js +8 -7
- package/docs/error-codes.md +215 -0
- package/docs/harness-capability-map.md +1358 -0
- package/package.json +29 -16
- package/bin/init-claude.mjs +0 -68
- package/claude-template/AGENTS.md +0 -157
- package/claude-template/CLAUDE.md +0 -66
- package/claude-template/dot-claude/rules/theokit-conventions.md +0 -32
- package/claude-template/dot-claude/settings.json +0 -16
- package/claude-template/dot-claude/skills/theokit-agent-core/SKILL.md +0 -209
- package/claude-template/dot-claude/skills/theokit-auth/SKILL.md +0 -102
- package/claude-template/dot-claude/skills/theokit-budget/SKILL.md +0 -176
- package/claude-template/dot-claude/skills/theokit-client/SKILL.md +0 -58
- package/claude-template/dot-claude/skills/theokit-compaction/SKILL.md +0 -102
- package/claude-template/dot-claude/skills/theokit-concurrency/SKILL.md +0 -68
- package/claude-template/dot-claude/skills/theokit-config/SKILL.md +0 -139
- package/claude-template/dot-claude/skills/theokit-cron/SKILL.md +0 -148
- package/claude-template/dot-claude/skills/theokit-di/SKILL.md +0 -233
- package/claude-template/dot-claude/skills/theokit-di-agent/SKILL.md +0 -294
- package/claude-template/dot-claude/skills/theokit-errors/SKILL.md +0 -172
- package/claude-template/dot-claude/skills/theokit-eval/SKILL.md +0 -179
- package/claude-template/dot-claude/skills/theokit-filesystem/SKILL.md +0 -74
- package/claude-template/dot-claude/skills/theokit-gateways/SKILL.md +0 -209
- package/claude-template/dot-claude/skills/theokit-memory/SKILL.md +0 -176
- package/claude-template/dot-claude/skills/theokit-messages/SKILL.md +0 -58
- package/claude-template/dot-claude/skills/theokit-models/SKILL.md +0 -79
- package/claude-template/dot-claude/skills/theokit-path-safety/SKILL.md +0 -60
- package/claude-template/dot-claude/skills/theokit-persistence/SKILL.md +0 -85
- package/claude-template/dot-claude/skills/theokit-project/SKILL.md +0 -55
- package/claude-template/dot-claude/skills/theokit-retry/SKILL.md +0 -50
- package/claude-template/dot-claude/skills/theokit-sandbox/SKILL.md +0 -93
- package/claude-template/dot-claude/skills/theokit-sanitize/SKILL.md +0 -66
- package/claude-template/dot-claude/skills/theokit-skills/SKILL.md +0 -68
- package/claude-template/dot-claude/skills/theokit-streaming/SKILL.md +0 -156
- package/claude-template/dot-claude/skills/theokit-subagents/SKILL.md +0 -109
- package/claude-template/dot-claude/skills/theokit-subscriptions/SKILL.md +0 -148
- package/claude-template/dot-claude/skills/theokit-task-store/SKILL.md +0 -75
- package/claude-template/dot-claude/skills/theokit-tools/SKILL.md +0 -170
- package/claude-template/dot-claude/skills/theokit-workflows/SKILL.md +0 -218
- package/dist/agent-FFVV4U5N.js +0 -50
- package/dist/agent-YLAHVHEH.cjs +0 -59
- package/dist/agent-session-store-DUGBAX5V.cjs +0 -23
- package/dist/agent-session-store-TNCGL5RN.js +0 -6
- package/dist/batch-UPKN4SG6.js.map +0 -1
- package/dist/batch-ZEFN5SO7.cjs.map +0 -1
- package/dist/chunk-2D43RD5D.cjs.map +0 -1
- package/dist/chunk-2FYEVT2B.cjs.map +0 -1
- package/dist/chunk-2RW7K6FN.cjs.map +0 -1
- package/dist/chunk-2XLKLVVR.js.map +0 -1
- package/dist/chunk-34XOCZJO.js.map +0 -1
- package/dist/chunk-3V7UJLQT.js.map +0 -1
- package/dist/chunk-4NAKHID5.js.map +0 -1
- package/dist/chunk-4Q4K4WB5.js.map +0 -1
- package/dist/chunk-5F5NWKPN.js.map +0 -1
- package/dist/chunk-5NBUH3NO.js.map +0 -1
- package/dist/chunk-5YKNEMXR.cjs.map +0 -1
- package/dist/chunk-7W7ZWMLQ.js.map +0 -1
- package/dist/chunk-ADLLFY3H.cjs.map +0 -1
- package/dist/chunk-B4YA6BRS.cjs.map +0 -1
- package/dist/chunk-B6HOIWQ6.js.map +0 -1
- package/dist/chunk-BDTVFIPB.cjs.map +0 -1
- package/dist/chunk-BFYGJGC5.js.map +0 -1
- package/dist/chunk-BM6N4KHO.cjs.map +0 -1
- package/dist/chunk-CAH3G4IS.js.map +0 -1
- package/dist/chunk-EZ2YEF4F.cjs.map +0 -1
- package/dist/chunk-F77UENR6.cjs.map +0 -1
- package/dist/chunk-FOXKFTVZ.cjs.map +0 -1
- package/dist/chunk-G3JWXOGY.js.map +0 -1
- package/dist/chunk-GOVJO4YE.js.map +0 -1
- package/dist/chunk-HAWE74GQ.cjs.map +0 -1
- package/dist/chunk-HE4BIAOS.js.map +0 -1
- package/dist/chunk-HSQ5Q3I5.js.map +0 -1
- package/dist/chunk-JIQRXKTA.cjs.map +0 -1
- package/dist/chunk-KSWHTR54.js.map +0 -1
- package/dist/chunk-L5YO6PWL.cjs.map +0 -1
- package/dist/chunk-LD4MOBFX.js.map +0 -1
- package/dist/chunk-LS3LMQ23.js.map +0 -1
- package/dist/chunk-MSFLYJDY.js.map +0 -1
- package/dist/chunk-NZL4BNFQ.js.map +0 -1
- package/dist/chunk-OKLYRPKL.cjs.map +0 -1
- package/dist/chunk-OUOXM36O.cjs.map +0 -1
- package/dist/chunk-OXNYIMZZ.js.map +0 -1
- package/dist/chunk-PBZ7HMBP.js.map +0 -1
- package/dist/chunk-PNVDQL5Y.cjs.map +0 -1
- package/dist/chunk-Q4RESANI.cjs.map +0 -1
- package/dist/chunk-QBTVATSF.cjs.map +0 -1
- package/dist/chunk-RAHSWE5C.cjs.map +0 -1
- package/dist/chunk-RP5HQVLD.js.map +0 -1
- package/dist/chunk-SEL2ZQMT.js.map +0 -1
- package/dist/chunk-SK4QLUBK.js.map +0 -1
- package/dist/chunk-TTJ54H3E.cjs.map +0 -1
- package/dist/chunk-V26QVGUG.js.map +0 -1
- package/dist/chunk-V6HWJQQV.js.map +0 -1
- package/dist/chunk-VGPXHHF3.cjs.map +0 -1
- package/dist/chunk-VUKQL3L2.cjs.map +0 -1
- package/dist/chunk-VYCKUKPA.cjs.map +0 -1
- package/dist/chunk-VYHJZVL5.cjs.map +0 -1
- package/dist/chunk-X2FR4OIT.js.map +0 -1
- package/dist/chunk-XPR366DL.cjs.map +0 -1
- package/dist/chunk-XROIW6BH.js.map +0 -1
- package/dist/chunk-YLQQX5W2.cjs.map +0 -1
- package/dist/chunk-ZT57WTUJ.cjs.map +0 -1
- package/dist/compact-session-4MNKNMO2.js +0 -21
- package/dist/compact-session-EPFBQ46Z.cjs +0 -58
- package/dist/context-7USNN6LP.cjs +0 -22
- package/dist/context-ENXZNF6J.js +0 -5
- package/dist/cron-BMjgFH-_.d.ts +0 -631
- package/dist/cron-DFDdCdMM.d.cts +0 -631
- package/dist/executor-2Z3LGG3I.cjs.map +0 -1
- package/dist/executor-2Z6XJJJG.js.map +0 -1
- package/dist/fs-session-store-R5FD3EN6.js +0 -10
- package/dist/fs-session-store-VVY2AHWG.cjs +0 -19
- package/dist/generate-object-AVXOJK2I.cjs +0 -20
- package/dist/generate-object-WQRCXFD2.js +0 -7
- package/dist/index-manager-VRU3A2YL.cjs +0 -21
- package/dist/index-manager-WS7TVKUW.js +0 -12
- package/dist/inject-session-AUQLBDRS.cjs +0 -28
- package/dist/inject-session-AUQLBDRS.cjs.map +0 -1
- package/dist/inject-session-GMBMJVNZ.js.map +0 -1
- package/dist/judge-call-G5SGV2M2.cjs +0 -22
- package/dist/judge-call-MDIPTBJI.js +0 -5
- package/dist/oauth-transaction-store-7CKHPQRN.cjs +0 -32
- package/dist/oauth-transaction-store-W74I6EFD.js +0 -3
- package/dist/registry-63ASMXT4.cjs +0 -46
- package/dist/registry-O7FJ2MPM.js +0 -9
- package/dist/session-transcript-DOM3UTXR.cjs +0 -50
- package/dist/session-transcript-RAKEK76V.js +0 -5
- package/dist/stream-object-L3Q7PBMF.cjs +0 -20
- package/dist/stream-object-ZYXWS4B2.js +0 -7
- package/dist/subagents-loader-I56GSKAQ.js +0 -6
- package/dist/subagents-loader-VRW73QQT.cjs +0 -15
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkF3YZMOAU_cjs = require('./chunk-F3YZMOAU.cjs');
|
|
4
|
+
var chunk4OTIXDMU_cjs = require('./chunk-4OTIXDMU.cjs');
|
|
5
|
+
var chunkDQKERTND_cjs = require('./chunk-DQKERTND.cjs');
|
|
6
6
|
var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
|
|
7
7
|
var chunkFRITRLZQ_cjs = require('./chunk-FRITRLZQ.cjs');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
8
|
+
var chunkJHPGF3FP_cjs = require('./chunk-JHPGF3FP.cjs');
|
|
9
|
+
var chunkXSX2UU6Y_cjs = require('./chunk-XSX2UU6Y.cjs');
|
|
10
|
+
var chunkNIRE5CNO_cjs = require('./chunk-NIRE5CNO.cjs');
|
|
11
|
+
var chunkK3FW2XZD_cjs = require('./chunk-K3FW2XZD.cjs');
|
|
12
|
+
var chunkNUKRL3I6_cjs = require('./chunk-NUKRL3I6.cjs');
|
|
13
13
|
var fs = require('fs');
|
|
14
14
|
var promises = require('fs/promises');
|
|
15
15
|
var os = require('os');
|
|
@@ -18,7 +18,7 @@ var url = require('url');
|
|
|
18
18
|
var module$1 = require('module');
|
|
19
19
|
|
|
20
20
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
21
|
-
var discoveryState =
|
|
21
|
+
var discoveryState = chunkNIRE5CNO_cjs.globalSingleton("theokit-sdk.providers.discovered", () => ({
|
|
22
22
|
done: false
|
|
23
23
|
}));
|
|
24
24
|
function pluginsRoot() {
|
|
@@ -40,19 +40,19 @@ function loadTrustedNames() {
|
|
|
40
40
|
else discarded += 1;
|
|
41
41
|
}
|
|
42
42
|
if (discarded > 0) {
|
|
43
|
-
|
|
43
|
+
chunkNUKRL3I6_cjs.diag(
|
|
44
44
|
`[theokit-sdk] WARN: ${path} contains ${discarded} non-string entr${discarded === 1 ? "y" : "ies"} \u2014 discarded (entries must be plugin-name strings)
|
|
45
45
|
`
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
} else {
|
|
49
|
-
|
|
49
|
+
chunkNUKRL3I6_cjs.diag(
|
|
50
50
|
`[theokit-sdk] WARN: ${path} is not a JSON array \u2014 trusting NO provider plugins (fail-closed)
|
|
51
51
|
`
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
} catch {
|
|
55
|
-
|
|
55
|
+
chunkNUKRL3I6_cjs.diag(
|
|
56
56
|
`[theokit-sdk] WARN: ${path} is not valid JSON \u2014 trusting NO provider plugins (fail-closed)
|
|
57
57
|
`
|
|
58
58
|
);
|
|
@@ -78,7 +78,7 @@ async function discoverProviderPlugins() {
|
|
|
78
78
|
const trusted = loadTrustedNames();
|
|
79
79
|
for (const entry of entries) {
|
|
80
80
|
if (!trusted.has(entry)) {
|
|
81
|
-
|
|
81
|
+
chunkNUKRL3I6_cjs.diag(
|
|
82
82
|
`[theokit-sdk] WARN: provider plugin "${entry}" is present but NOT trusted \u2014 skipped. To trust it, add "${entry}" to ${trustFilePath()} (JSON array of names) or THEOKIT_TRUSTED_PROVIDERS (comma-separated), then restart the process.
|
|
83
83
|
`
|
|
84
84
|
);
|
|
@@ -97,13 +97,13 @@ async function loadOne(dir, entryName) {
|
|
|
97
97
|
if (plugin !== null && typeof plugin === "object" && plugin.kind === "model-provider") {
|
|
98
98
|
const profile = plugin.profile;
|
|
99
99
|
if (profile !== void 0 && typeof profile === "object") {
|
|
100
|
-
|
|
100
|
+
chunkNIRE5CNO_cjs.registerProvider(profile);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
return;
|
|
104
104
|
} catch (err) {
|
|
105
105
|
const msg = err instanceof Error ? err.message : String(err);
|
|
106
|
-
|
|
106
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] failed to load provider plugin "${entryName}": ${msg}
|
|
107
107
|
`);
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
@@ -115,7 +115,7 @@ function mapAnthropicError(args) {
|
|
|
115
115
|
const { status, body, headers, endpoint } = args;
|
|
116
116
|
const code = mapAnthropicStatusToCode(status, body);
|
|
117
117
|
const message = formatMessage(status, code);
|
|
118
|
-
const metadata =
|
|
118
|
+
const metadata = chunkDQKERTND_cjs.buildErrorMetadata({
|
|
119
119
|
provider: "anthropic",
|
|
120
120
|
endpoint,
|
|
121
121
|
code,
|
|
@@ -124,24 +124,24 @@ function mapAnthropicError(args) {
|
|
|
124
124
|
body
|
|
125
125
|
});
|
|
126
126
|
if (status === 401 || status === 403) {
|
|
127
|
-
return new
|
|
127
|
+
return new chunkK3FW2XZD_cjs.AuthenticationError(message, { code: "anthropic_auth_failed", metadata });
|
|
128
128
|
}
|
|
129
129
|
if (status === 429) {
|
|
130
|
-
return new
|
|
130
|
+
return new chunkK3FW2XZD_cjs.RateLimitError(message, { code: "anthropic_rate_limit", metadata });
|
|
131
131
|
}
|
|
132
132
|
if (status === 400) {
|
|
133
|
-
return new
|
|
133
|
+
return new chunkK3FW2XZD_cjs.ConfigurationError(message, {
|
|
134
134
|
code: `anthropic_${code}`,
|
|
135
135
|
metadata
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
if (status === 408) {
|
|
139
|
-
return new
|
|
139
|
+
return new chunkK3FW2XZD_cjs.NetworkError(message, { code: "anthropic_timeout", metadata });
|
|
140
140
|
}
|
|
141
141
|
if (status >= 500 && status < 600) {
|
|
142
|
-
return new
|
|
142
|
+
return new chunkK3FW2XZD_cjs.NetworkError(message, { code: "anthropic_server_error", metadata });
|
|
143
143
|
}
|
|
144
|
-
return new
|
|
144
|
+
return new chunkK3FW2XZD_cjs.UnknownAgentError(message, { code: "anthropic_unknown", metadata });
|
|
145
145
|
}
|
|
146
146
|
function mapAnthropicStatusToCode(status, body) {
|
|
147
147
|
if (status === 401 || status === 403) return "auth_failed";
|
|
@@ -190,17 +190,34 @@ function mapOpenAIFinish(reason) {
|
|
|
190
190
|
return "end_turn";
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
+
function asTokenCount(value) {
|
|
194
|
+
const n = typeof value === "string" ? Number(value) : value;
|
|
195
|
+
if (typeof n !== "number" || !Number.isFinite(n) || n < 0) return void 0;
|
|
196
|
+
return Math.floor(n);
|
|
197
|
+
}
|
|
198
|
+
function assign(finish, key, value) {
|
|
199
|
+
if (value === void 0) return;
|
|
200
|
+
const count = asTokenCount(value);
|
|
201
|
+
if (count === void 0) {
|
|
202
|
+
chunkNUKRL3I6_cjs.diag(
|
|
203
|
+
`[theokit-sdk] provider reported an unusable ${key} (${String(value)}) \u2014 dropping it. Usage and cost for this turn will be incomplete.
|
|
204
|
+
`
|
|
205
|
+
);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
finish[key] = count;
|
|
209
|
+
}
|
|
193
210
|
function makeLlmFinish(state) {
|
|
194
211
|
const finish = {
|
|
195
212
|
stopReason: state.stopReason,
|
|
196
213
|
text: state.text,
|
|
197
214
|
toolCalls: state.toolCalls
|
|
198
215
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
216
|
+
assign(finish, "inputTokens", state.inputTokens);
|
|
217
|
+
assign(finish, "outputTokens", state.outputTokens);
|
|
218
|
+
assign(finish, "cacheReadTokens", state.cacheReadTokens);
|
|
219
|
+
assign(finish, "cacheWriteTokens", state.cacheWriteTokens);
|
|
220
|
+
assign(finish, "reasoningTokens", state.reasoningTokens);
|
|
204
221
|
if (state.thinking !== void 0) finish.thinking = state.thinking;
|
|
205
222
|
return finish;
|
|
206
223
|
}
|
|
@@ -212,7 +229,7 @@ function toBlockToolResultContent(content) {
|
|
|
212
229
|
function toStringToolResultContent(content, providerName) {
|
|
213
230
|
if (typeof content === "string") return content;
|
|
214
231
|
if (content.some((block) => block.type === "image")) {
|
|
215
|
-
throw new
|
|
232
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
216
233
|
`provider "${providerName}" does not support image content in tool results`
|
|
217
234
|
);
|
|
218
235
|
}
|
|
@@ -391,7 +408,7 @@ function readWithIdleTimeout(reader, idleTimeoutMs) {
|
|
|
391
408
|
(resolve, reject) => {
|
|
392
409
|
const timer = setTimeout(() => {
|
|
393
410
|
reject(
|
|
394
|
-
new
|
|
411
|
+
new chunkK3FW2XZD_cjs.NetworkError(`SSE stream idle for ${idleTimeoutMs}ms \u2014 upstream stalled`, {
|
|
395
412
|
code: "stream_idle_timeout"
|
|
396
413
|
})
|
|
397
414
|
);
|
|
@@ -468,9 +485,9 @@ function ehAbort(err) {
|
|
|
468
485
|
}
|
|
469
486
|
function wrapTransportError(err, ctx) {
|
|
470
487
|
if (ehAbort(err)) return err;
|
|
471
|
-
if (err instanceof
|
|
488
|
+
if (err instanceof chunkK3FW2XZD_cjs.TheokitAgentError) return err;
|
|
472
489
|
const detail = err instanceof Error ? err.message : String(err);
|
|
473
|
-
return new
|
|
490
|
+
return new chunkK3FW2XZD_cjs.NetworkError(`${ctx.providerId} transport failure on ${ctx.endpoint}: ${detail}`, {
|
|
474
491
|
code: "transport_failure",
|
|
475
492
|
cause: err
|
|
476
493
|
});
|
|
@@ -534,7 +551,7 @@ var AnthropicClient = class {
|
|
|
534
551
|
for (const event of events) yield event;
|
|
535
552
|
}
|
|
536
553
|
if (!accumulator.finishReasonSeen) {
|
|
537
|
-
throw new
|
|
554
|
+
throw new chunkK3FW2XZD_cjs.NetworkError("Anthropic SSE stream truncated (no stop_reason)", {
|
|
538
555
|
code: "stream_truncated"
|
|
539
556
|
});
|
|
540
557
|
}
|
|
@@ -687,7 +704,7 @@ function classifyBedrockError(args, awsType, message) {
|
|
|
687
704
|
return "unknown";
|
|
688
705
|
}
|
|
689
706
|
function buildBedrockMetadata(args, code) {
|
|
690
|
-
return
|
|
707
|
+
return chunkDQKERTND_cjs.buildErrorMetadata({
|
|
691
708
|
provider: "bedrock",
|
|
692
709
|
endpoint: args.endpoint,
|
|
693
710
|
code,
|
|
@@ -704,19 +721,19 @@ function mapBedrockError(args) {
|
|
|
704
721
|
const metadata = buildBedrockMetadata(args, code);
|
|
705
722
|
switch (code) {
|
|
706
723
|
case "rate_limit":
|
|
707
|
-
return new
|
|
724
|
+
return new chunkK3FW2XZD_cjs.RateLimitError(`Bedrock throttled: ${message}`, { metadata });
|
|
708
725
|
case "auth_failed":
|
|
709
|
-
return new
|
|
726
|
+
return new chunkK3FW2XZD_cjs.AuthenticationError(`Bedrock auth: ${message}`, { metadata });
|
|
710
727
|
case "invalid_request": {
|
|
711
728
|
const friendly = message.includes("use case details") ? `Bedrock account setup required: ${message} (AWS Console \u2192 Bedrock \u2192 Model access \u2192 Anthropic \u2192 Submit use case form, then retry in 15 min.)` : `Bedrock validation: ${message}`;
|
|
712
|
-
return new
|
|
729
|
+
return new chunkK3FW2XZD_cjs.ConfigurationError(friendly, { metadata });
|
|
713
730
|
}
|
|
714
731
|
case "timeout":
|
|
715
|
-
return new
|
|
732
|
+
return new chunkK3FW2XZD_cjs.NetworkError(`Bedrock timeout: ${message}`, { metadata });
|
|
716
733
|
case "server_error":
|
|
717
|
-
return new
|
|
734
|
+
return new chunkK3FW2XZD_cjs.NetworkError(`Bedrock server error: ${message}`, { metadata });
|
|
718
735
|
default:
|
|
719
|
-
return new
|
|
736
|
+
return new chunkK3FW2XZD_cjs.UnknownAgentError(`Bedrock unknown: ${message}`, { metadata });
|
|
720
737
|
}
|
|
721
738
|
}
|
|
722
739
|
function parseBody(body) {
|
|
@@ -740,7 +757,7 @@ async function resolveBedrockToken(region) {
|
|
|
740
757
|
return cachedToken.value;
|
|
741
758
|
}
|
|
742
759
|
try {
|
|
743
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
760
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-HLPSLDGL.cjs', document.baseURI).href)));
|
|
744
761
|
const gen = r("@aws/bedrock-token-generator");
|
|
745
762
|
if (typeof gen.getToken !== "function") return void 0;
|
|
746
763
|
const providers = r("@aws-sdk/credential-providers");
|
|
@@ -768,16 +785,16 @@ var BedrockAnthropicClient = class {
|
|
|
768
785
|
if (fromOpts !== void 0 && fromOpts.length > 0) return fromOpts;
|
|
769
786
|
const fromEnv = await resolveBedrockToken(region);
|
|
770
787
|
if (fromEnv !== void 0 && fromEnv.length > 0) return fromEnv;
|
|
771
|
-
throw new
|
|
788
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
772
789
|
"Bedrock requires AWS_BEARER_TOKEN_BEDROCK env var, or install `@aws/bedrock-token-generator` for auto-refresh, or pass apiKey explicitly.",
|
|
773
790
|
{ code: "auth_failed" }
|
|
774
791
|
);
|
|
775
792
|
}
|
|
776
793
|
async *stream(request, signal) {
|
|
777
|
-
const region =
|
|
794
|
+
const region = chunkNIRE5CNO_cjs.inferRegionFromModelId(request.model) ?? process.env.AWS_REGION ?? "us-east-1";
|
|
778
795
|
const token = await this.resolveTokenOrThrow(region);
|
|
779
|
-
const bareModel =
|
|
780
|
-
const baseUrl = this.options.baseUrl ??
|
|
796
|
+
const bareModel = chunkNIRE5CNO_cjs.stripBedrockPrefix(request.model);
|
|
797
|
+
const baseUrl = this.options.baseUrl ?? chunkNIRE5CNO_cjs.resolveBedrockBaseUrl(request.model);
|
|
781
798
|
const endpoint = `/model/${encodeURIComponent(bareModel)}/invoke`;
|
|
782
799
|
const url = `${baseUrl}${endpoint}`;
|
|
783
800
|
const response = await postAnthropicRequest({
|
|
@@ -832,7 +849,7 @@ var FaultInjectingLlmClient = class {
|
|
|
832
849
|
return yield* this.inner.stream(request, signal);
|
|
833
850
|
}
|
|
834
851
|
if (parsed.status >= 400) {
|
|
835
|
-
throw
|
|
852
|
+
throw chunkDQKERTND_cjs.mapOpenAICompatibleError({
|
|
836
853
|
providerId: this.name,
|
|
837
854
|
status: parsed.status,
|
|
838
855
|
body: parsed.body,
|
|
@@ -879,7 +896,7 @@ function parseOverrideOrWarnOnce() {
|
|
|
879
896
|
function warnInvalidJsonOnce(_raw) {
|
|
880
897
|
if (warnedInvalidJson) return;
|
|
881
898
|
warnedInvalidJson = true;
|
|
882
|
-
|
|
899
|
+
chunkNUKRL3I6_cjs.diag(
|
|
883
900
|
`[theokit-sdk] ${ENV_OVERRIDE_KEY} is set but value is not valid JSON of shape \`{"status": number, "body": object | string}\`. Falling back to real LLM call. This warning is shown once per process.
|
|
884
901
|
`
|
|
885
902
|
);
|
|
@@ -907,7 +924,7 @@ function mapOllamaTransportError(args) {
|
|
|
907
924
|
if (args.providerId !== "ollama") return void 0;
|
|
908
925
|
const causeCode = extractCauseCode(args.cause);
|
|
909
926
|
if (causeCode !== "ECONNREFUSED" && causeCode !== "ENOTFOUND") return void 0;
|
|
910
|
-
const metadata =
|
|
927
|
+
const metadata = chunkDQKERTND_cjs.buildErrorMetadata({
|
|
911
928
|
provider: "ollama",
|
|
912
929
|
endpoint: args.endpoint,
|
|
913
930
|
code: "network",
|
|
@@ -915,7 +932,7 @@ function mapOllamaTransportError(args) {
|
|
|
915
932
|
headers: void 0,
|
|
916
933
|
body: { cause: causeCode }
|
|
917
934
|
});
|
|
918
|
-
return new
|
|
935
|
+
return new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
919
936
|
"Ollama is not reachable. Run `ollama serve` to start the local runtime, or set OLLAMA_HOST to point at a remote Ollama server.",
|
|
920
937
|
{ code: "ollama_unreachable", metadata }
|
|
921
938
|
);
|
|
@@ -925,7 +942,7 @@ function mapOllamaHttpError(args) {
|
|
|
925
942
|
const errString = extractErrorString(args.body).toLowerCase();
|
|
926
943
|
if (args.status === 404 && errString.includes("not found") && errString.includes("pull")) {
|
|
927
944
|
const modelHint = extractModelName(errString);
|
|
928
|
-
const metadata =
|
|
945
|
+
const metadata = chunkDQKERTND_cjs.buildErrorMetadata({
|
|
929
946
|
provider: "ollama",
|
|
930
947
|
endpoint: args.endpoint,
|
|
931
948
|
code: "model_unavailable",
|
|
@@ -934,13 +951,13 @@ function mapOllamaHttpError(args) {
|
|
|
934
951
|
body: args.body
|
|
935
952
|
});
|
|
936
953
|
const pullCmd = modelHint !== void 0 ? `ollama pull ${modelHint}` : "ollama pull <model>";
|
|
937
|
-
return new
|
|
954
|
+
return new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
938
955
|
`Ollama model is not pulled. Run \`${pullCmd}\` to download it first.`,
|
|
939
956
|
{ code: "ollama_model_not_pulled", metadata }
|
|
940
957
|
);
|
|
941
958
|
}
|
|
942
959
|
if (args.status === 503 && errString.includes("model is loading")) {
|
|
943
|
-
const metadata =
|
|
960
|
+
const metadata = chunkDQKERTND_cjs.buildErrorMetadata({
|
|
944
961
|
provider: "ollama",
|
|
945
962
|
endpoint: args.endpoint,
|
|
946
963
|
code: "server_error",
|
|
@@ -948,7 +965,7 @@ function mapOllamaHttpError(args) {
|
|
|
948
965
|
headers: args.headers,
|
|
949
966
|
body: args.body
|
|
950
967
|
});
|
|
951
|
-
return new
|
|
968
|
+
return new chunkK3FW2XZD_cjs.NetworkError(
|
|
952
969
|
"Ollama model is loading. Retry in a few seconds \u2014 Ollama is warming up the model into memory.",
|
|
953
970
|
{ code: "ollama_model_loading", metadata }
|
|
954
971
|
);
|
|
@@ -1169,7 +1186,7 @@ function toOllamaMessages(message) {
|
|
|
1169
1186
|
}
|
|
1170
1187
|
if (message.role === "user") {
|
|
1171
1188
|
if (message.content.some((p) => p.type === "image")) {
|
|
1172
|
-
throw new
|
|
1189
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
1173
1190
|
"image input is not supported on the ollama-native provider; use an OpenAI/OpenRouter model for multimodal turns",
|
|
1174
1191
|
{ code: "ollama_image_unsupported" }
|
|
1175
1192
|
);
|
|
@@ -1230,10 +1247,21 @@ function shouldUseFixtureMode(apiKey) {
|
|
|
1230
1247
|
if (getConfiguredBaseUrl() !== void 0) return false;
|
|
1231
1248
|
return isFixtureApiKey(apiKey);
|
|
1232
1249
|
}
|
|
1250
|
+
var PROVIDER_CREDENTIAL_ENV_VARS = [
|
|
1251
|
+
"ANTHROPIC_API_KEY",
|
|
1252
|
+
"OPENAI_API_KEY",
|
|
1253
|
+
"OPENROUTER_API_KEY"
|
|
1254
|
+
];
|
|
1255
|
+
function presentProviderCredentialEnvVars() {
|
|
1256
|
+
return PROVIDER_CREDENTIAL_ENV_VARS.filter((name) => {
|
|
1257
|
+
const value = process.env[name];
|
|
1258
|
+
return typeof value === "string" && value.length > 0;
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1233
1261
|
function shouldUseRealLocalRuntime(apiKey) {
|
|
1234
1262
|
if (isFixtureApiKey(apiKey)) return false;
|
|
1235
1263
|
if (apiKey === void 0 || apiKey.length === 0) return false;
|
|
1236
|
-
return
|
|
1264
|
+
return presentProviderCredentialEnvVars().length > 0 || isAwsBedrockAuthAvailable() || isGcpVertexAuthAvailable() || isLocalNoAuthProviderAvailable();
|
|
1237
1265
|
}
|
|
1238
1266
|
function isAwsBedrockAuthAvailable() {
|
|
1239
1267
|
if (typeof process.env.AWS_BEARER_TOKEN_BEDROCK === "string" && process.env.AWS_BEARER_TOKEN_BEDROCK.length > 0) {
|
|
@@ -1298,7 +1326,7 @@ async function safeFetch(fetchFn, url, init) {
|
|
|
1298
1326
|
try {
|
|
1299
1327
|
return await fetchFn(url, init);
|
|
1300
1328
|
} catch (cause) {
|
|
1301
|
-
throw new
|
|
1329
|
+
throw new chunkK3FW2XZD_cjs.NetworkError("HTTP request failed", { code: "network_error", cause });
|
|
1302
1330
|
}
|
|
1303
1331
|
}
|
|
1304
1332
|
async function safeParseJsonResponse(response) {
|
|
@@ -1325,7 +1353,7 @@ function mapHttpStatusToError(status, body) {
|
|
|
1325
1353
|
cause: body
|
|
1326
1354
|
};
|
|
1327
1355
|
if (envelope.code === "integration_not_connected") {
|
|
1328
|
-
return new
|
|
1356
|
+
return new chunkK3FW2XZD_cjs.IntegrationNotConnectedError(message, {
|
|
1329
1357
|
provider: envelope.provider ?? "unknown",
|
|
1330
1358
|
helpUrl: envelope.helpUrl ?? "",
|
|
1331
1359
|
code: envelope.code,
|
|
@@ -1333,18 +1361,18 @@ function mapHttpStatusToError(status, body) {
|
|
|
1333
1361
|
});
|
|
1334
1362
|
}
|
|
1335
1363
|
if (status === 401 || status === 403) {
|
|
1336
|
-
return new
|
|
1364
|
+
return new chunkK3FW2XZD_cjs.AuthenticationError(message, errorOptions);
|
|
1337
1365
|
}
|
|
1338
1366
|
if (status === 429) {
|
|
1339
|
-
return new
|
|
1367
|
+
return new chunkK3FW2XZD_cjs.RateLimitError(message, errorOptions);
|
|
1340
1368
|
}
|
|
1341
1369
|
if (status >= 400 && status < 500) {
|
|
1342
|
-
return new
|
|
1370
|
+
return new chunkK3FW2XZD_cjs.ConfigurationError(message, errorOptions);
|
|
1343
1371
|
}
|
|
1344
1372
|
if (status >= 500) {
|
|
1345
|
-
return new
|
|
1373
|
+
return new chunkK3FW2XZD_cjs.NetworkError(message, errorOptions);
|
|
1346
1374
|
}
|
|
1347
|
-
return new
|
|
1375
|
+
return new chunkK3FW2XZD_cjs.UnknownAgentError(message, errorOptions);
|
|
1348
1376
|
}
|
|
1349
1377
|
function extractErrorEnvelope(body) {
|
|
1350
1378
|
if (!body || typeof body !== "object") return {};
|
|
@@ -1598,7 +1626,7 @@ var OpenAIClient = class {
|
|
|
1598
1626
|
endpoint: "/v1/chat/completions"
|
|
1599
1627
|
});
|
|
1600
1628
|
if (ollamaMapped !== void 0) throw ollamaMapped;
|
|
1601
|
-
throw
|
|
1629
|
+
throw chunkDQKERTND_cjs.mapOpenAICompatibleError({
|
|
1602
1630
|
providerId,
|
|
1603
1631
|
status: response.status,
|
|
1604
1632
|
body,
|
|
@@ -1614,7 +1642,14 @@ var OpenAIClient = class {
|
|
|
1614
1642
|
new Set(request.tools?.map((tool) => tool.name) ?? [])
|
|
1615
1643
|
);
|
|
1616
1644
|
let sawDone = false;
|
|
1617
|
-
|
|
1645
|
+
const records = (async function* () {
|
|
1646
|
+
try {
|
|
1647
|
+
yield* parseSseStream(response.body, signal);
|
|
1648
|
+
} catch (readErr) {
|
|
1649
|
+
throw wrapTransportError(readErr, { providerId, endpoint: "/v1/chat/completions" });
|
|
1650
|
+
}
|
|
1651
|
+
})();
|
|
1652
|
+
for await (const record of records) {
|
|
1618
1653
|
if (record.data === "[DONE]") {
|
|
1619
1654
|
sawDone = true;
|
|
1620
1655
|
break;
|
|
@@ -1627,7 +1662,7 @@ var OpenAIClient = class {
|
|
|
1627
1662
|
}
|
|
1628
1663
|
if (chunk.error !== void 0 && chunk.error !== null) {
|
|
1629
1664
|
const status = typeof chunk.error.code === "number" ? chunk.error.code : 502;
|
|
1630
|
-
throw
|
|
1665
|
+
throw chunkDQKERTND_cjs.mapOpenAICompatibleError({
|
|
1631
1666
|
providerId,
|
|
1632
1667
|
status,
|
|
1633
1668
|
body: chunk,
|
|
@@ -1639,7 +1674,7 @@ var OpenAIClient = class {
|
|
|
1639
1674
|
for (const event of events) yield event;
|
|
1640
1675
|
}
|
|
1641
1676
|
if (!sawDone && !accumulator.finishReasonSeen) {
|
|
1642
|
-
throw new
|
|
1677
|
+
throw new chunkK3FW2XZD_cjs.NetworkError("SSE stream truncated (no finish_reason / [DONE])", {
|
|
1643
1678
|
code: "stream_truncated"
|
|
1644
1679
|
});
|
|
1645
1680
|
}
|
|
@@ -1771,13 +1806,13 @@ var OpenAIStreamAccumulator = class {
|
|
|
1771
1806
|
toolCalls.push(...recovered.toolCalls);
|
|
1772
1807
|
text = recovered.residualText;
|
|
1773
1808
|
stopReason = "tool_use";
|
|
1774
|
-
|
|
1809
|
+
chunkNUKRL3I6_cjs.diag(
|
|
1775
1810
|
`[theokit-sdk] recovered ${recovered.toolCalls.length} leaked tool call(s) from assistant content (provider="${this.providerName}", names=${recovered.toolCalls.map((c) => c.name).join(",")})
|
|
1776
1811
|
`
|
|
1777
1812
|
);
|
|
1778
1813
|
}
|
|
1779
1814
|
if (recovered.droppedNames.length > 0) {
|
|
1780
|
-
|
|
1815
|
+
chunkNUKRL3I6_cjs.diag(
|
|
1781
1816
|
`[theokit-sdk] dropped ${recovered.droppedNames.length} leaked block(s) whose name is not a tool in the request (provider="${this.providerName}", names=${recovered.droppedNames.join(",")})
|
|
1782
1817
|
`
|
|
1783
1818
|
);
|
|
@@ -1899,10 +1934,10 @@ async function tryFirstEvent(client, request, signal, logFallback = false) {
|
|
|
1899
1934
|
const firstResult = await generator.next();
|
|
1900
1935
|
return { kind: "ok", generator, firstResult };
|
|
1901
1936
|
} catch (cause) {
|
|
1902
|
-
if (cause instanceof
|
|
1937
|
+
if (cause instanceof chunkK3FW2XZD_cjs.NetworkError || cause instanceof chunkK3FW2XZD_cjs.RateLimitError || cause instanceof chunkK3FW2XZD_cjs.AuthenticationError) {
|
|
1903
1938
|
if (logFallback) {
|
|
1904
1939
|
const errCode = cause.metadata?.code ?? cause.code ?? "unknown";
|
|
1905
|
-
|
|
1940
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] provider ${client.name} failed (${errCode}): falling back
|
|
1906
1941
|
`);
|
|
1907
1942
|
}
|
|
1908
1943
|
return { kind: "handshake_error", error: cause };
|
|
@@ -1944,7 +1979,7 @@ var PoolAwareLlmClient = class {
|
|
|
1944
1979
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: stream() must serialize pool-select → build client → first-event probe → classify → retry/rotate/propagate. Extracting helpers fragments the linear narrative; the comments above each branch keep it readable.
|
|
1945
1980
|
async *stream(request, signal) {
|
|
1946
1981
|
if (this.breaker.shouldSkip(this.pool.provider)) {
|
|
1947
|
-
throw new
|
|
1982
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`${this.pool.provider} circuit open \u2014 failing fast`, {
|
|
1948
1983
|
code: "circuit_open"
|
|
1949
1984
|
});
|
|
1950
1985
|
}
|
|
@@ -1963,7 +1998,7 @@ var PoolAwareLlmClient = class {
|
|
|
1963
1998
|
}
|
|
1964
1999
|
if (entry === null) {
|
|
1965
2000
|
this.breaker.recordTimeout(this.pool.provider);
|
|
1966
|
-
throw new
|
|
2001
|
+
throw new chunkK3FW2XZD_cjs.CredentialPoolExhaustedError(
|
|
1967
2002
|
`All ${this.pool.provider} credentials exhausted; next retry available at ${this.nextRetryHint() ?? "unknown"}`,
|
|
1968
2003
|
{ provider: this.pool.provider, nextRetryAt: this.nextRetryHint() }
|
|
1969
2004
|
);
|
|
@@ -1977,13 +2012,13 @@ var PoolAwareLlmClient = class {
|
|
|
1977
2012
|
}
|
|
1978
2013
|
const decision = classifyAndDecide(attempt.error, hasRetried429);
|
|
1979
2014
|
if (decision === "retry") {
|
|
1980
|
-
const backoffMs =
|
|
2015
|
+
const backoffMs = chunkF3YZMOAU_cjs.computeBackoffMs({
|
|
1981
2016
|
attempt: 0,
|
|
1982
2017
|
...this.backoffBaseMs !== void 0 ? { baseMs: this.backoffBaseMs } : {},
|
|
1983
2018
|
...this.rng !== void 0 ? { rng: this.rng } : {}
|
|
1984
2019
|
});
|
|
1985
2020
|
this.onRateLimit?.({ attempt: 1, retryAfterMs: backoffMs });
|
|
1986
|
-
await
|
|
2021
|
+
await chunkF3YZMOAU_cjs.sleepWithAbort(backoffMs, signal);
|
|
1987
2022
|
hasRetried429 = true;
|
|
1988
2023
|
continue;
|
|
1989
2024
|
}
|
|
@@ -1995,7 +2030,7 @@ var PoolAwareLlmClient = class {
|
|
|
1995
2030
|
...parseRetryAfterMs(attempt.error) !== void 0 ? { resetAtMs: parseRetryAfterMs(attempt.error) } : {}
|
|
1996
2031
|
});
|
|
1997
2032
|
} catch (persistErr) {
|
|
1998
|
-
|
|
2033
|
+
chunkNUKRL3I6_cjs.diag(
|
|
1999
2034
|
`[theokit-sdk] credential-pool: persist failed during rotate; continuing in-memory: ${persistErr instanceof Error ? persistErr.message : String(persistErr)}
|
|
2000
2035
|
`
|
|
2001
2036
|
);
|
|
@@ -2017,8 +2052,8 @@ var PoolAwareLlmClient = class {
|
|
|
2017
2052
|
}
|
|
2018
2053
|
};
|
|
2019
2054
|
function classifyAndDecide(error, hasRetried429) {
|
|
2020
|
-
if (error instanceof
|
|
2021
|
-
if (error instanceof
|
|
2055
|
+
if (error instanceof chunkK3FW2XZD_cjs.NetworkError) return "propagate";
|
|
2056
|
+
if (error instanceof chunkK3FW2XZD_cjs.AuthenticationError) return "rotate";
|
|
2022
2057
|
const status = error.metadata?.statusCode ?? 429;
|
|
2023
2058
|
if (status === 402) return "rotate";
|
|
2024
2059
|
return hasRetried429 ? "rotate" : "retry";
|
|
@@ -2031,8 +2066,8 @@ function parseRetryAfterMs(error) {
|
|
|
2031
2066
|
return void 0;
|
|
2032
2067
|
}
|
|
2033
2068
|
function inferStatusCode(error) {
|
|
2034
|
-
if (error instanceof
|
|
2035
|
-
if (error instanceof
|
|
2069
|
+
if (error instanceof chunkK3FW2XZD_cjs.AuthenticationError) return 401;
|
|
2070
|
+
if (error instanceof chunkK3FW2XZD_cjs.RateLimitError) return 429;
|
|
2036
2071
|
return 0;
|
|
2037
2072
|
}
|
|
2038
2073
|
function abortError(signal) {
|
|
@@ -2041,7 +2076,7 @@ function abortError(signal) {
|
|
|
2041
2076
|
}
|
|
2042
2077
|
|
|
2043
2078
|
// src/internal/llm/responses.ts
|
|
2044
|
-
function messageToInputItems(message) {
|
|
2079
|
+
function messageToInputItems(message, reasoningByCallId) {
|
|
2045
2080
|
const items = [];
|
|
2046
2081
|
if (message.role === "user") {
|
|
2047
2082
|
const content = [];
|
|
@@ -2068,6 +2103,14 @@ function messageToInputItems(message) {
|
|
|
2068
2103
|
if (part.type === "text") {
|
|
2069
2104
|
content.push({ type: "output_text", text: part.text });
|
|
2070
2105
|
} else if (part.type === "tool_use") {
|
|
2106
|
+
for (const reasoning of reasoningByCallId?.get(part.id) ?? []) {
|
|
2107
|
+
items.push({
|
|
2108
|
+
type: "reasoning",
|
|
2109
|
+
id: reasoning.id,
|
|
2110
|
+
encrypted_content: reasoning.encrypted_content,
|
|
2111
|
+
summary: []
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2071
2114
|
items.push({
|
|
2072
2115
|
type: "function_call",
|
|
2073
2116
|
call_id: part.id,
|
|
@@ -2083,10 +2126,10 @@ function messageToInputItems(message) {
|
|
|
2083
2126
|
if (text.length > 0) items.push({ role: "system", content: text });
|
|
2084
2127
|
return items;
|
|
2085
2128
|
}
|
|
2086
|
-
function buildResponsesBody(request) {
|
|
2129
|
+
function buildResponsesBody(request, options = {}) {
|
|
2087
2130
|
const input = [];
|
|
2088
2131
|
for (const message of request.messages) {
|
|
2089
|
-
for (const item of messageToInputItems(message)) input.push(item);
|
|
2132
|
+
for (const item of messageToInputItems(message, options.reasoningByCallId)) input.push(item);
|
|
2090
2133
|
}
|
|
2091
2134
|
const slash = request.model.lastIndexOf("/");
|
|
2092
2135
|
const model = slash >= 0 ? request.model.slice(slash + 1) : request.model;
|
|
@@ -2103,9 +2146,21 @@ function buildResponsesBody(request) {
|
|
|
2103
2146
|
strict: false
|
|
2104
2147
|
}));
|
|
2105
2148
|
if (tools.length > 0) body.tools = tools;
|
|
2106
|
-
|
|
2149
|
+
applyPromptCachingFields(body, request, options);
|
|
2107
2150
|
return body;
|
|
2108
2151
|
}
|
|
2152
|
+
function applyPromptCachingFields(body, request, options) {
|
|
2153
|
+
const carryReasoning = options.encryptedReasoning === true;
|
|
2154
|
+
if (request.reasoning !== void 0) {
|
|
2155
|
+
body.reasoning = {
|
|
2156
|
+
effort: request.reasoning.effort,
|
|
2157
|
+
...carryReasoning ? { context: "all_turns" } : {}
|
|
2158
|
+
};
|
|
2159
|
+
}
|
|
2160
|
+
if (carryReasoning) body.include = ["reasoning.encrypted_content"];
|
|
2161
|
+
if (request.promptCacheKey !== void 0) body.prompt_cache_key = request.promptCacheKey;
|
|
2162
|
+
}
|
|
2163
|
+
var MAX_REMEMBERED_REASONING_CALLS = 256;
|
|
2109
2164
|
var ResponsesApiClient = class {
|
|
2110
2165
|
constructor(options) {
|
|
2111
2166
|
this.options = options;
|
|
@@ -2117,6 +2172,26 @@ var ResponsesApiClient = class {
|
|
|
2117
2172
|
name;
|
|
2118
2173
|
baseUrl;
|
|
2119
2174
|
fetchImpl;
|
|
2175
|
+
/**
|
|
2176
|
+
* usetheokit/theokit-sdk#383 — reasoning ciphertext captured from earlier rounds, keyed by the
|
|
2177
|
+
* `call_id` it preceded. Held on the CLIENT rather than threaded through `LlmRequest` because a
|
|
2178
|
+
* round's reasoning is provider-shaped ciphertext with a provider-shaped ordering rule; the agent
|
|
2179
|
+
* loop has no use for it and the same client instance serves every round of a turn. Insertion
|
|
2180
|
+
* order is the eviction order (see {@link MAX_REMEMBERED_REASONING_CALLS}).
|
|
2181
|
+
*/
|
|
2182
|
+
reasoningByCallId = /* @__PURE__ */ new Map();
|
|
2183
|
+
/**
|
|
2184
|
+
* usetheokit/theokit-sdk#383 — bind a batch of reasoning ciphertext to the tool call it produced,
|
|
2185
|
+
* evicting the oldest binding once the cap is reached.
|
|
2186
|
+
*/
|
|
2187
|
+
rememberReasoning(callId, items) {
|
|
2188
|
+
this.reasoningByCallId.set(callId, [...items]);
|
|
2189
|
+
while (this.reasoningByCallId.size > MAX_REMEMBERED_REASONING_CALLS) {
|
|
2190
|
+
const oldest = this.reasoningByCallId.keys().next();
|
|
2191
|
+
if (oldest.done === true) break;
|
|
2192
|
+
this.reasoningByCallId.delete(oldest.value);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2120
2195
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: the SSE dispatch (text / reasoning / tool-call add+delta+done / terminal+usage / error) is one cohesive state machine, mirroring OpenAIStreamAccumulator.consume.
|
|
2121
2196
|
async *stream(request, signal) {
|
|
2122
2197
|
const providerId = this.options.providerName ?? "openai";
|
|
@@ -2131,7 +2206,15 @@ var ResponsesApiClient = class {
|
|
|
2131
2206
|
method: "POST",
|
|
2132
2207
|
signal,
|
|
2133
2208
|
headers,
|
|
2134
|
-
body: JSON.stringify(
|
|
2209
|
+
body: JSON.stringify(
|
|
2210
|
+
// Both options ride the SAME flag on purpose: a provider that never declared support gets
|
|
2211
|
+
// the byte-identical pre-#383 body, even in the impossible case where it returned ciphertext
|
|
2212
|
+
// nobody asked for.
|
|
2213
|
+
buildResponsesBody(
|
|
2214
|
+
request,
|
|
2215
|
+
this.options.encryptedReasoning === true ? { encryptedReasoning: true, reasoningByCallId: this.reasoningByCallId } : {}
|
|
2216
|
+
)
|
|
2217
|
+
)
|
|
2135
2218
|
});
|
|
2136
2219
|
if (!response.ok) {
|
|
2137
2220
|
const text2 = await response.text().catch(() => "");
|
|
@@ -2140,7 +2223,7 @@ var ResponsesApiClient = class {
|
|
|
2140
2223
|
body = JSON.parse(text2);
|
|
2141
2224
|
} catch {
|
|
2142
2225
|
}
|
|
2143
|
-
throw
|
|
2226
|
+
throw chunkDQKERTND_cjs.mapOpenAICompatibleError({
|
|
2144
2227
|
providerId,
|
|
2145
2228
|
status: response.status,
|
|
2146
2229
|
body,
|
|
@@ -2154,7 +2237,10 @@ var ResponsesApiClient = class {
|
|
|
2154
2237
|
let inputTokens;
|
|
2155
2238
|
let outputTokens;
|
|
2156
2239
|
let reasoningTokens;
|
|
2240
|
+
let cacheReadTokens;
|
|
2241
|
+
let cacheWriteTokens;
|
|
2157
2242
|
const pending = {};
|
|
2243
|
+
let unclaimedReasoning = [];
|
|
2158
2244
|
if (response.body !== null) {
|
|
2159
2245
|
for await (const record of parseSseStream(response.body, signal)) {
|
|
2160
2246
|
if (record.data === "[DONE]") break;
|
|
@@ -2174,6 +2260,12 @@ var ResponsesApiClient = class {
|
|
|
2174
2260
|
} else if (t === "response.reasoning_summary_text.delta" || t === "response.reasoning_text.delta") {
|
|
2175
2261
|
const d = event.delta ?? "";
|
|
2176
2262
|
if (d.length > 0) yield { type: "reasoning_delta", text: d };
|
|
2263
|
+
} else if (t === "response.output_item.done" && event.item?.type === "reasoning") {
|
|
2264
|
+
const id = event.item.id;
|
|
2265
|
+
const encrypted = event.item.encrypted_content;
|
|
2266
|
+
if (id !== void 0 && encrypted !== void 0 && encrypted.length > 0) {
|
|
2267
|
+
unclaimedReasoning.push({ id, encrypted_content: encrypted });
|
|
2268
|
+
}
|
|
2177
2269
|
} else if (t === "response.output_item.added" && event.item?.type === "function_call") {
|
|
2178
2270
|
const id = event.item.id ?? event.item.call_id ?? "call-0";
|
|
2179
2271
|
pending[id] = {
|
|
@@ -2199,6 +2291,10 @@ var ResponsesApiClient = class {
|
|
|
2199
2291
|
input: parseToolArguments(rawArgs)
|
|
2200
2292
|
};
|
|
2201
2293
|
toolCalls.push(call);
|
|
2294
|
+
if (unclaimedReasoning.length > 0) {
|
|
2295
|
+
this.rememberReasoning(call.id, unclaimedReasoning);
|
|
2296
|
+
unclaimedReasoning = [];
|
|
2297
|
+
}
|
|
2202
2298
|
delete pending[id];
|
|
2203
2299
|
} else if (t === "response.completed" || t === "response.incomplete") {
|
|
2204
2300
|
const usage = event.response?.usage;
|
|
@@ -2206,12 +2302,14 @@ var ResponsesApiClient = class {
|
|
|
2206
2302
|
inputTokens = usage.input_tokens;
|
|
2207
2303
|
outputTokens = usage.output_tokens;
|
|
2208
2304
|
reasoningTokens = usage.output_tokens_details?.reasoning_tokens;
|
|
2305
|
+
cacheReadTokens = usage.input_tokens_details?.cached_tokens;
|
|
2306
|
+
cacheWriteTokens = usage.input_tokens_details?.cache_write_tokens;
|
|
2209
2307
|
}
|
|
2210
2308
|
stopReason = t === "response.incomplete" ? "max_tokens" : "end_turn";
|
|
2211
2309
|
} else if (t === "response.failed" || t === "error") {
|
|
2212
2310
|
const msg = event.response?.error?.message ?? event.message ?? "responses stream failed";
|
|
2213
2311
|
yield { type: "error", message: msg };
|
|
2214
|
-
throw
|
|
2312
|
+
throw chunkDQKERTND_cjs.mapOpenAICompatibleError({
|
|
2215
2313
|
providerId,
|
|
2216
2314
|
status: 502,
|
|
2217
2315
|
body: { error: { message: msg } },
|
|
@@ -2228,7 +2326,9 @@ var ResponsesApiClient = class {
|
|
|
2228
2326
|
toolCalls,
|
|
2229
2327
|
inputTokens,
|
|
2230
2328
|
outputTokens,
|
|
2231
|
-
reasoningTokens
|
|
2329
|
+
reasoningTokens,
|
|
2330
|
+
cacheReadTokens,
|
|
2331
|
+
cacheWriteTokens
|
|
2232
2332
|
});
|
|
2233
2333
|
}
|
|
2234
2334
|
};
|
|
@@ -2242,14 +2342,14 @@ function abortError2(signal) {
|
|
|
2242
2342
|
// src/internal/llm/retrying-client.ts
|
|
2243
2343
|
var MAX_ATTEMPTS = 3;
|
|
2244
2344
|
function isRetriableError(err) {
|
|
2245
|
-
if (!
|
|
2246
|
-
if (err instanceof
|
|
2247
|
-
if (err instanceof
|
|
2248
|
-
if (err instanceof
|
|
2345
|
+
if (!chunkK3FW2XZD_cjs.isTransientError(err)) return false;
|
|
2346
|
+
if (err instanceof chunkK3FW2XZD_cjs.CredentialPoolExhaustedError) return false;
|
|
2347
|
+
if (err instanceof chunkK3FW2XZD_cjs.TheokitAgentError && err.code === "circuit_open") return false;
|
|
2348
|
+
if (err instanceof chunkK3FW2XZD_cjs.RateLimitError && err.metadata?.statusCode === 402) return false;
|
|
2249
2349
|
return true;
|
|
2250
2350
|
}
|
|
2251
2351
|
function retryAfterHintMs(err) {
|
|
2252
|
-
if (!(err instanceof
|
|
2352
|
+
if (!(err instanceof chunkK3FW2XZD_cjs.RateLimitError)) return void 0;
|
|
2253
2353
|
const seconds = err.metadata?.retryAfter;
|
|
2254
2354
|
return typeof seconds === "number" && seconds > 0 ? seconds * 1e3 : void 0;
|
|
2255
2355
|
}
|
|
@@ -2295,16 +2395,16 @@ var RetryingLlmClient = class {
|
|
|
2295
2395
|
*/
|
|
2296
2396
|
async #waitBackoff(err, attempt, signal) {
|
|
2297
2397
|
const hint = retryAfterHintMs(err);
|
|
2298
|
-
const ms =
|
|
2398
|
+
const ms = chunkF3YZMOAU_cjs.computeBackoffMs({
|
|
2299
2399
|
attempt,
|
|
2300
2400
|
...hint !== void 0 ? { retryAfterMs: hint } : {},
|
|
2301
2401
|
...this.#rng !== void 0 ? { rng: this.#rng } : {}
|
|
2302
2402
|
});
|
|
2303
2403
|
const cause = err instanceof Error ? err.name : typeof err;
|
|
2304
|
-
|
|
2404
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2305
2405
|
`retry ${attempt + 1}/${MAX_ATTEMPTS} in ${String(ms)}ms \u2014 ${cause}` + (hint !== void 0 ? ` (Retry-After: ${String(hint)}ms)` : "")
|
|
2306
2406
|
);
|
|
2307
|
-
await
|
|
2407
|
+
await chunkF3YZMOAU_cjs.sleepWithAbort(ms, signal);
|
|
2308
2408
|
}
|
|
2309
2409
|
async *stream(request, signal) {
|
|
2310
2410
|
let lastError;
|
|
@@ -2342,7 +2442,7 @@ function classifyVertexError(args, errStatus) {
|
|
|
2342
2442
|
return "unknown";
|
|
2343
2443
|
}
|
|
2344
2444
|
function vertexMetadata(args, code) {
|
|
2345
|
-
return
|
|
2445
|
+
return chunkDQKERTND_cjs.buildErrorMetadata({
|
|
2346
2446
|
provider: "vertex",
|
|
2347
2447
|
endpoint: args.endpoint,
|
|
2348
2448
|
code,
|
|
@@ -2352,23 +2452,23 @@ function vertexMetadata(args, code) {
|
|
|
2352
2452
|
});
|
|
2353
2453
|
}
|
|
2354
2454
|
var VERTEX_ERROR_BUILDERS = {
|
|
2355
|
-
rate_limit: (args, msg) => new
|
|
2455
|
+
rate_limit: (args, msg) => new chunkK3FW2XZD_cjs.RateLimitError(`Vertex quota exhausted: ${msg}`, {
|
|
2356
2456
|
metadata: vertexMetadata(args, "rate_limit")
|
|
2357
2457
|
}),
|
|
2358
|
-
auth_unauthenticated: (args, msg) => new
|
|
2458
|
+
auth_unauthenticated: (args, msg) => new chunkK3FW2XZD_cjs.AuthenticationError(`Vertex unauthenticated: ${msg}`, {
|
|
2359
2459
|
metadata: vertexMetadata(args, "auth_failed")
|
|
2360
2460
|
}),
|
|
2361
|
-
auth_permission: (args, msg) => new
|
|
2461
|
+
auth_permission: (args, msg) => new chunkK3FW2XZD_cjs.AuthenticationError(`Vertex permission denied: ${msg}`, {
|
|
2362
2462
|
metadata: vertexMetadata(args, "auth_failed")
|
|
2363
2463
|
}),
|
|
2364
|
-
invalid_request: (args, msg) => new
|
|
2464
|
+
invalid_request: (args, msg) => new chunkK3FW2XZD_cjs.ConfigurationError(`Vertex validation: ${msg}`, {
|
|
2365
2465
|
metadata: vertexMetadata(args, "invalid_request")
|
|
2366
2466
|
}),
|
|
2367
|
-
timeout: (args, msg) => new
|
|
2368
|
-
server_error: (args, msg) => new
|
|
2467
|
+
timeout: (args, msg) => new chunkK3FW2XZD_cjs.NetworkError(`Vertex timeout: ${msg}`, { metadata: vertexMetadata(args, "timeout") }),
|
|
2468
|
+
server_error: (args, msg) => new chunkK3FW2XZD_cjs.NetworkError(`Vertex server error: ${msg}`, {
|
|
2369
2469
|
metadata: vertexMetadata(args, "server_error")
|
|
2370
2470
|
}),
|
|
2371
|
-
unknown: (args, msg) => new
|
|
2471
|
+
unknown: (args, msg) => new chunkK3FW2XZD_cjs.UnknownAgentError(`Vertex unknown: ${msg}`, { metadata: vertexMetadata(args, "unknown") })
|
|
2372
2472
|
};
|
|
2373
2473
|
function mapVertexError(args) {
|
|
2374
2474
|
const parsed = parseBody2(args.body);
|
|
@@ -2404,12 +2504,12 @@ async function resolveVertexAccessToken() {
|
|
|
2404
2504
|
async function getAuthClientOrThrow() {
|
|
2405
2505
|
let mod;
|
|
2406
2506
|
try {
|
|
2407
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
2507
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-HLPSLDGL.cjs', document.baseURI).href)));
|
|
2408
2508
|
mod = r("google-auth-library");
|
|
2409
2509
|
} catch (err) {
|
|
2410
2510
|
const isModuleMissing = err instanceof Error && (err.message.includes("Cannot find module") || err.code === "MODULE_NOT_FOUND");
|
|
2411
2511
|
if (isModuleMissing) {
|
|
2412
|
-
throw new
|
|
2512
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2413
2513
|
"Vertex provider requires `google-auth-library`. Install: `pnpm add google-auth-library`.",
|
|
2414
2514
|
{ code: "auth_failed", cause: err }
|
|
2415
2515
|
);
|
|
@@ -2420,7 +2520,7 @@ async function getAuthClientOrThrow() {
|
|
|
2420
2520
|
const auth = new mod.GoogleAuth({ scopes: [SCOPE_CLOUD_PLATFORM] });
|
|
2421
2521
|
return await auth.getClient();
|
|
2422
2522
|
} catch (err) {
|
|
2423
|
-
|
|
2523
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2424
2524
|
`[theokit-sdk] Vertex ADC initialization failed: ${err instanceof Error ? err.message : String(err)}
|
|
2425
2525
|
`
|
|
2426
2526
|
);
|
|
@@ -2446,7 +2546,7 @@ var VertexAnthropicClient = class {
|
|
|
2446
2546
|
resolveProjectOrThrow() {
|
|
2447
2547
|
const projectId = this.options.projectId ?? resolveVertexProjectId();
|
|
2448
2548
|
if (projectId !== void 0) return projectId;
|
|
2449
|
-
throw new
|
|
2549
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2450
2550
|
"Vertex requires a project id. Set GOOGLE_CLOUD_PROJECT env var or run `gcloud config set project <id>`.",
|
|
2451
2551
|
{ code: "auth_failed" }
|
|
2452
2552
|
);
|
|
@@ -2456,7 +2556,7 @@ var VertexAnthropicClient = class {
|
|
|
2456
2556
|
if (fromOpts !== void 0 && fromOpts.length > 0) return fromOpts;
|
|
2457
2557
|
const fromAdc = await resolveVertexAccessToken();
|
|
2458
2558
|
if (fromAdc !== void 0 && fromAdc.length > 0) return fromAdc;
|
|
2459
|
-
throw new
|
|
2559
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2460
2560
|
"Vertex could not resolve an access token. Run `gcloud auth application-default login` or set GOOGLE_APPLICATION_CREDENTIALS to a service-account JSON path.",
|
|
2461
2561
|
{ code: "auth_failed" }
|
|
2462
2562
|
);
|
|
@@ -2465,8 +2565,8 @@ var VertexAnthropicClient = class {
|
|
|
2465
2565
|
const projectId = this.resolveProjectOrThrow();
|
|
2466
2566
|
const location = this.options.location ?? resolveVertexLocation();
|
|
2467
2567
|
const accessToken = await this.resolveTokenOrThrow();
|
|
2468
|
-
const baseUrl =
|
|
2469
|
-
const bareModel =
|
|
2568
|
+
const baseUrl = chunkNIRE5CNO_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "anthropic" });
|
|
2569
|
+
const bareModel = chunkNIRE5CNO_cjs.stripVertexPrefix(request.model);
|
|
2470
2570
|
const endpoint = `/models/${encodeURIComponent(bareModel)}:rawPredict`;
|
|
2471
2571
|
const url = `${baseUrl}${endpoint}`;
|
|
2472
2572
|
const response = await postAnthropicRequest({
|
|
@@ -2502,7 +2602,7 @@ var VertexGeminiClient = class {
|
|
|
2502
2602
|
async *stream(request, signal) {
|
|
2503
2603
|
const projectId = this.options.projectId ?? resolveVertexProjectId();
|
|
2504
2604
|
if (projectId === void 0) {
|
|
2505
|
-
throw new
|
|
2605
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2506
2606
|
"Vertex requires a project id. Set GOOGLE_CLOUD_PROJECT env var or run `gcloud config set project <id>`.",
|
|
2507
2607
|
{ code: "auth_failed" }
|
|
2508
2608
|
);
|
|
@@ -2510,19 +2610,15 @@ var VertexGeminiClient = class {
|
|
|
2510
2610
|
const location = this.options.location ?? resolveVertexLocation();
|
|
2511
2611
|
const accessToken = this.options.apiKey !== void 0 && this.options.apiKey.length > 0 ? this.options.apiKey : await resolveVertexAccessToken();
|
|
2512
2612
|
if (accessToken === void 0 || accessToken.length === 0) {
|
|
2513
|
-
throw new
|
|
2613
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2514
2614
|
"Vertex could not resolve an access token. Run `gcloud auth application-default login` or set GOOGLE_APPLICATION_CREDENTIALS to a service-account JSON path.",
|
|
2515
2615
|
{ code: "auth_failed" }
|
|
2516
2616
|
);
|
|
2517
2617
|
}
|
|
2518
|
-
const baseUrl =
|
|
2618
|
+
const baseUrl = chunkNIRE5CNO_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "gemini" });
|
|
2519
2619
|
const url = `${baseUrl}/chat/completions`;
|
|
2520
2620
|
const innerFetch = this.options.fetch ?? fetch;
|
|
2521
|
-
const rewriteFetch = (
|
|
2522
|
-
const requested = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
2523
|
-
const targetUrl = requested.endsWith("/v1/chat/completions") ? url : requested;
|
|
2524
|
-
return innerFetch(targetUrl, init);
|
|
2525
|
-
};
|
|
2621
|
+
const rewriteFetch = (_input, init) => innerFetch(url, init);
|
|
2526
2622
|
const inner = new OpenAIClient({
|
|
2527
2623
|
apiKey: accessToken,
|
|
2528
2624
|
baseUrl: "https://_vertex_placeholder",
|
|
@@ -2541,7 +2637,7 @@ var VertexRouterClient = class {
|
|
|
2541
2637
|
options;
|
|
2542
2638
|
name = "vertex";
|
|
2543
2639
|
async *stream(request, signal) {
|
|
2544
|
-
const dialect =
|
|
2640
|
+
const dialect = chunkNIRE5CNO_cjs.inferModelDialect(request.model);
|
|
2545
2641
|
if (dialect === "anthropic") {
|
|
2546
2642
|
const inner2 = new VertexAnthropicClient(this.options);
|
|
2547
2643
|
return yield* inner2.stream(request, signal);
|
|
@@ -2553,73 +2649,73 @@ var VertexRouterClient = class {
|
|
|
2553
2649
|
|
|
2554
2650
|
// src/internal/llm/router.ts
|
|
2555
2651
|
function resolveProviderChain(options) {
|
|
2556
|
-
|
|
2652
|
+
chunkNIRE5CNO_cjs.registerBuiltins();
|
|
2557
2653
|
return buildChain(options);
|
|
2558
2654
|
}
|
|
2559
2655
|
function buildChain(options) {
|
|
2560
2656
|
warnUnknownProvidersInApiKeys(options.apiKeys);
|
|
2561
2657
|
const seen = /* @__PURE__ */ new Set();
|
|
2562
2658
|
const clients = [];
|
|
2563
|
-
const addClient = (name) => {
|
|
2659
|
+
const addClient = (name, perCallBaseUrl) => {
|
|
2564
2660
|
const lowered = name.toLowerCase();
|
|
2565
2661
|
if (seen.has(lowered)) return;
|
|
2566
2662
|
seen.add(lowered);
|
|
2567
|
-
const client = buildClient(lowered, options);
|
|
2663
|
+
const client = buildClient(lowered, options, perCallBaseUrl);
|
|
2568
2664
|
if (client !== void 0) clients.push(maybeWrapWithFaultInjection(client));
|
|
2569
2665
|
};
|
|
2570
|
-
addClient(options.primary);
|
|
2666
|
+
addClient(options.primary, options.baseUrl);
|
|
2571
2667
|
for (const fallback of options.fallback ?? []) addClient(fallback);
|
|
2572
2668
|
if (clients.length === 0) {
|
|
2573
|
-
throw new
|
|
2669
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2574
2670
|
`No provider client could be resolved (primary=${options.primary}). Set ANTHROPIC_API_KEY or OPENAI_API_KEY / OPENROUTER_API_KEY.`,
|
|
2575
2671
|
{ code: "provider_unresolved" }
|
|
2576
2672
|
);
|
|
2577
2673
|
}
|
|
2578
2674
|
return clients;
|
|
2579
2675
|
}
|
|
2580
|
-
function buildClient(name, routerOptions) {
|
|
2581
|
-
const baseProfile =
|
|
2676
|
+
function buildClient(name, routerOptions, perCallBaseUrl) {
|
|
2677
|
+
const baseProfile = chunkNIRE5CNO_cjs.getProviderProfile(name);
|
|
2582
2678
|
if (baseProfile === void 0) return void 0;
|
|
2583
2679
|
const profile = routerOptions.extractToolCallsFromContent === true && baseProfile.extractToolCallsFromContent !== true ? { ...baseProfile, extractToolCallsFromContent: true } : baseProfile;
|
|
2584
2680
|
const resilience = routerOptions.onRateLimit !== void 0 ? { onRateLimit: routerOptions.onRateLimit } : {};
|
|
2585
|
-
const ambient =
|
|
2681
|
+
const ambient = chunkF3YZMOAU_cjs.currentCredentialPool(name);
|
|
2586
2682
|
if (ambient !== void 0) {
|
|
2587
2683
|
return new RetryingLlmClient(
|
|
2588
2684
|
new PoolAwareLlmClient(
|
|
2589
2685
|
ambient,
|
|
2590
|
-
(apiKey) => selectTransport(profile, apiKey),
|
|
2686
|
+
(apiKey) => selectTransport(profile, apiKey, perCallBaseUrl),
|
|
2591
2687
|
void 0,
|
|
2592
2688
|
resilience
|
|
2593
2689
|
)
|
|
2594
2690
|
);
|
|
2595
2691
|
}
|
|
2596
2692
|
const poolKeys = filterPoolKeys(routerOptions.apiKeys?.[name]);
|
|
2597
|
-
const noAuthOverride = maybeBuildNoAuthTransport(profile, poolKeys);
|
|
2693
|
+
const noAuthOverride = maybeBuildNoAuthTransport(profile, poolKeys, perCallBaseUrl);
|
|
2598
2694
|
if (noAuthOverride !== void 0) return noAuthOverride;
|
|
2599
|
-
return buildPoolOrSingle({ name, profile, poolKeys, routerOptions });
|
|
2695
|
+
return buildPoolOrSingle({ name, profile, poolKeys, routerOptions, perCallBaseUrl });
|
|
2600
2696
|
}
|
|
2601
|
-
function maybeBuildNoAuthTransport(profile, poolKeys) {
|
|
2697
|
+
function maybeBuildNoAuthTransport(profile, poolKeys, baseUrl) {
|
|
2602
2698
|
if (profile.authType !== "none" || poolKeys === void 0 || poolKeys.length === 0) {
|
|
2603
2699
|
return void 0;
|
|
2604
2700
|
}
|
|
2605
2701
|
warnNoAuthApiKeysIgnoredOnce(profile.name);
|
|
2606
2702
|
const sentinel = sentinelForNoAuth(profile);
|
|
2607
2703
|
if (sentinel === void 0) return void 0;
|
|
2608
|
-
return selectTransport(profile, sentinel);
|
|
2704
|
+
return selectTransport(profile, sentinel, baseUrl);
|
|
2609
2705
|
}
|
|
2610
2706
|
function buildPoolOrSingle(args) {
|
|
2611
|
-
const { name, profile, poolKeys, routerOptions } = args;
|
|
2707
|
+
const { name, profile, poolKeys, routerOptions, perCallBaseUrl } = args;
|
|
2612
2708
|
if (poolKeys !== void 0 && poolKeys.length >= 2) {
|
|
2613
2709
|
const strategy = routerOptions.credentialPoolStrategy?.[name] ?? "fill_first";
|
|
2614
2710
|
const entries = poolKeys.map(
|
|
2615
|
-
(accessToken, priority) =>
|
|
2711
|
+
(accessToken, priority) => chunkF3YZMOAU_cjs.newPooledCredential({ provider: name, accessToken, priority, source: "manual" })
|
|
2616
2712
|
);
|
|
2617
|
-
const pool = new
|
|
2713
|
+
const pool = new chunkF3YZMOAU_cjs.CredentialPool(name, entries, strategy);
|
|
2618
2714
|
const resilience = routerOptions.onRateLimit !== void 0 ? { onRateLimit: routerOptions.onRateLimit } : {};
|
|
2619
2715
|
return new RetryingLlmClient(
|
|
2620
2716
|
new PoolAwareLlmClient(
|
|
2621
2717
|
pool,
|
|
2622
|
-
(apiKey2) => selectTransport(profile, apiKey2),
|
|
2718
|
+
(apiKey2) => selectTransport(profile, apiKey2, perCallBaseUrl),
|
|
2623
2719
|
void 0,
|
|
2624
2720
|
resilience
|
|
2625
2721
|
)
|
|
@@ -2627,7 +2723,7 @@ function buildPoolOrSingle(args) {
|
|
|
2627
2723
|
}
|
|
2628
2724
|
const apiKey = poolKeys?.[0] ?? resolveApiKey(profile.envVars) ?? sentinelForNoAuth(profile) ?? sentinelForLazyAuth(profile);
|
|
2629
2725
|
if (apiKey === void 0) return void 0;
|
|
2630
|
-
return new RetryingLlmClient(selectTransport(profile, apiKey));
|
|
2726
|
+
return new RetryingLlmClient(selectTransport(profile, apiKey, perCallBaseUrl));
|
|
2631
2727
|
}
|
|
2632
2728
|
function resolveBaseUrlEnvOverride(providerName) {
|
|
2633
2729
|
switch (providerName) {
|
|
@@ -2635,8 +2731,6 @@ function resolveBaseUrlEnvOverride(providerName) {
|
|
|
2635
2731
|
return process.env.OPENAI_API_BASE_URL;
|
|
2636
2732
|
case "openrouter":
|
|
2637
2733
|
return process.env.OPENROUTER_API_BASE_URL;
|
|
2638
|
-
case "ollama":
|
|
2639
|
-
return process.env.OLLAMA_HOST;
|
|
2640
2734
|
case "lmstudio":
|
|
2641
2735
|
return process.env.LMSTUDIO_HOST;
|
|
2642
2736
|
case "llamacpp":
|
|
@@ -2649,7 +2743,7 @@ var warnedNoAuthApiKeys = /* @__PURE__ */ new Set();
|
|
|
2649
2743
|
function warnNoAuthApiKeysIgnoredOnce(provider) {
|
|
2650
2744
|
if (warnedNoAuthApiKeys.has(provider)) return;
|
|
2651
2745
|
warnedNoAuthApiKeys.add(provider);
|
|
2652
|
-
|
|
2746
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2653
2747
|
`[theokit-sdk] provider "${provider}" has authType: "none" \u2014 apiKeys ignored (no auth required for local runtime).
|
|
2654
2748
|
`
|
|
2655
2749
|
);
|
|
@@ -2675,10 +2769,10 @@ function warnUnknownProvidersInApiKeys(apiKeys) {
|
|
|
2675
2769
|
if (apiKeys === void 0) return;
|
|
2676
2770
|
for (const name of Object.keys(apiKeys)) {
|
|
2677
2771
|
if (warnedProviders.has(name)) continue;
|
|
2678
|
-
const profile =
|
|
2772
|
+
const profile = chunkNIRE5CNO_cjs.getProviderProfile(name);
|
|
2679
2773
|
if (profile === void 0) {
|
|
2680
2774
|
warnedProviders.add(name);
|
|
2681
|
-
|
|
2775
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2682
2776
|
`[theokit-sdk] credential-pool: unknown provider "${name}" in apiKeys (no profile registered)
|
|
2683
2777
|
`
|
|
2684
2778
|
);
|
|
@@ -2692,7 +2786,7 @@ function resolveApiKey(envVars) {
|
|
|
2692
2786
|
}
|
|
2693
2787
|
return void 0;
|
|
2694
2788
|
}
|
|
2695
|
-
function selectTransport(profile, apiKey) {
|
|
2789
|
+
function selectTransport(profile, apiKey, baseUrl) {
|
|
2696
2790
|
const applyTransform = () => {
|
|
2697
2791
|
if (profile.transform === void 0) return {};
|
|
2698
2792
|
const ctx = { apiKey };
|
|
@@ -2710,14 +2804,14 @@ function selectTransport(profile, apiKey) {
|
|
|
2710
2804
|
if (apiKey !== "__oauth_lazy_token__") return;
|
|
2711
2805
|
const auth = t.headers?.authorization ?? t.headers?.Authorization;
|
|
2712
2806
|
if (t.fetch === void 0 && auth === void 0) {
|
|
2713
|
-
throw new
|
|
2807
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2714
2808
|
`provider "${profile.name}" uses OAuth (authType: ${profile.authType}) but no credential was resolved. Register a ProviderProfile.transform whose fetch (or headers.authorization) supplies the bearer \u2014 typically via resolveCredential() from "@theokit/sdk/auth".`
|
|
2715
2809
|
);
|
|
2716
2810
|
}
|
|
2717
2811
|
};
|
|
2718
2812
|
if (profile.apiMode === "chat_completions") {
|
|
2719
2813
|
if (profile.name === "ollama") {
|
|
2720
|
-
const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
|
|
2814
|
+
const ollamaBase = baseUrl ?? process.env.OLLAMA_HOST ?? profile.baseUrl;
|
|
2721
2815
|
return new OllamaNativeClient({ apiKey, baseUrl: ollamaBase });
|
|
2722
2816
|
}
|
|
2723
2817
|
const opts = { apiKey };
|
|
@@ -2734,6 +2828,7 @@ function selectTransport(profile, apiKey) {
|
|
|
2734
2828
|
}
|
|
2735
2829
|
const envOverride = resolveBaseUrlEnvOverride(profile.name);
|
|
2736
2830
|
if (envOverride !== void 0) opts.baseUrl = envOverride;
|
|
2831
|
+
if (baseUrl !== void 0) opts.baseUrl = baseUrl;
|
|
2737
2832
|
return comTransform(opts, (o) => new OpenAIClient(o));
|
|
2738
2833
|
}
|
|
2739
2834
|
if (profile.apiMode === "anthropic_messages") {
|
|
@@ -2742,12 +2837,15 @@ function selectTransport(profile, apiKey) {
|
|
|
2742
2837
|
return new VertexRouterClient(realKey !== void 0 ? { apiKey: realKey } : {});
|
|
2743
2838
|
}
|
|
2744
2839
|
const opts = { apiKey };
|
|
2745
|
-
opts.baseUrl = process.env.ANTHROPIC_API_BASE_URL ?? profile.baseUrl;
|
|
2840
|
+
opts.baseUrl = baseUrl ?? process.env.ANTHROPIC_API_BASE_URL ?? profile.baseUrl;
|
|
2746
2841
|
return comTransform(opts, (o) => new AnthropicClient(o));
|
|
2747
2842
|
}
|
|
2748
2843
|
if (profile.apiMode === "bedrock_anthropic") {
|
|
2749
2844
|
const realKey = apiKey === "__bedrock_lazy_token__" ? void 0 : apiKey;
|
|
2750
|
-
return new BedrockAnthropicClient(
|
|
2845
|
+
return new BedrockAnthropicClient({
|
|
2846
|
+
...realKey !== void 0 ? { apiKey: realKey } : {},
|
|
2847
|
+
...baseUrl !== void 0 ? { baseUrl } : {}
|
|
2848
|
+
});
|
|
2751
2849
|
}
|
|
2752
2850
|
if (profile.apiMode === "responses_api") {
|
|
2753
2851
|
const t = applyTransform();
|
|
@@ -2755,13 +2853,17 @@ function selectTransport(profile, apiKey) {
|
|
|
2755
2853
|
const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
|
|
2756
2854
|
return new ResponsesApiClient({
|
|
2757
2855
|
apiKey,
|
|
2758
|
-
|
|
2856
|
+
// Per-call URL first, same contract as every other branch (B-150).
|
|
2857
|
+
...(baseUrl ?? profile.baseUrl) !== void 0 ? { baseUrl: baseUrl ?? profile.baseUrl } : {},
|
|
2759
2858
|
...mergedHeaders !== void 0 ? { extraHeaders: mergedHeaders } : {},
|
|
2760
2859
|
...t.fetch !== void 0 ? { fetch: t.fetch } : {},
|
|
2860
|
+
// usetheokit/theokit-sdk#383 — forwarded only when the profile declares it, so a provider that
|
|
2861
|
+
// has not been measured against `reasoning.context` keeps the request it had.
|
|
2862
|
+
...profile.encryptedReasoning === true ? { encryptedReasoning: true } : {},
|
|
2761
2863
|
providerName: profile.name
|
|
2762
2864
|
});
|
|
2763
2865
|
}
|
|
2764
|
-
throw new
|
|
2866
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2765
2867
|
`Provider "${profile.name}" requires apiMode "${profile.apiMode}" but no transport is registered. Install a third-party transport plugin (@theokit-transport-${profile.apiMode}) or use a provider with apiMode "chat_completions" or "anthropic_messages".`,
|
|
2766
2868
|
{ code: "transport_unavailable" }
|
|
2767
2869
|
);
|
|
@@ -2771,7 +2873,7 @@ function selectTransport(profile, apiKey) {
|
|
|
2771
2873
|
function inferProviderFromApiKey(apiKey) {
|
|
2772
2874
|
const provider = chunkFRITRLZQ_cjs.providerFromApiKeyPrefix(apiKey);
|
|
2773
2875
|
if (provider === void 0) return void 0;
|
|
2774
|
-
return
|
|
2876
|
+
return chunkNIRE5CNO_cjs.getProviderProfile(provider) === void 0 ? void 0 : provider;
|
|
2775
2877
|
}
|
|
2776
2878
|
function detectPrimaryProvider() {
|
|
2777
2879
|
if (process.env.ANTHROPIC_API_KEY !== void 0 && process.env.ANTHROPIC_API_KEY.length > 0) {
|
|
@@ -2785,6 +2887,17 @@ function detectPrimaryProvider() {
|
|
|
2785
2887
|
}
|
|
2786
2888
|
return "openai";
|
|
2787
2889
|
}
|
|
2890
|
+
var warnedProviderPrecedence = /* @__PURE__ */ new Set();
|
|
2891
|
+
function warnProviderPrecedenceOnce(asked, used) {
|
|
2892
|
+
if (asked === void 0 || asked === used) return;
|
|
2893
|
+
const key = `${asked}->${used}`;
|
|
2894
|
+
if (warnedProviderPrecedence.has(key)) return;
|
|
2895
|
+
warnedProviderPrecedence.add(key);
|
|
2896
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2897
|
+
`[theokit-sdk] model id names provider "${asked}", but "${used}" was used \u2014 an explicit \`providers.routes[0]\` or the API key's own prefix outranks the model id's prefix. Pass \`providers.routes\` to choose deliberately.
|
|
2898
|
+
`
|
|
2899
|
+
);
|
|
2900
|
+
}
|
|
2788
2901
|
|
|
2789
2902
|
// src/internal/runtime/compression/compression-model-registry.ts
|
|
2790
2903
|
var EXACT_REGISTRY = /* @__PURE__ */ new Map([
|
|
@@ -2906,7 +3019,7 @@ function plainText(content) {
|
|
|
2906
3019
|
}
|
|
2907
3020
|
async function compactSessionTranscript(opts) {
|
|
2908
3021
|
const prior = await opts.store.readRecords(opts.loc.agentId);
|
|
2909
|
-
const history =
|
|
3022
|
+
const history = chunkJHPGF3FP_cjs.reconstructMessages(prior);
|
|
2910
3023
|
const compressible = [];
|
|
2911
3024
|
for (const m of history) {
|
|
2912
3025
|
const text = plainText(m.content);
|
|
@@ -2914,14 +3027,14 @@ async function compactSessionTranscript(opts) {
|
|
|
2914
3027
|
compressible.push({ role: m.role, content: text });
|
|
2915
3028
|
}
|
|
2916
3029
|
}
|
|
2917
|
-
const preTokens =
|
|
3030
|
+
const preTokens = chunkXSX2UU6Y_cjs.estimateTokens(compressible.map((m) => m.content).join("\n"));
|
|
2918
3031
|
const summaryBody = await opts.summarize(compressible);
|
|
2919
3032
|
const preserved = [];
|
|
2920
3033
|
let budget = 0;
|
|
2921
3034
|
for (let i = compressible.length - 1; i >= 0; i--) {
|
|
2922
3035
|
const m = compressible[i];
|
|
2923
3036
|
if (m === void 0 || m.role !== "user" || isCompactSummary(m.content)) continue;
|
|
2924
|
-
const cost =
|
|
3037
|
+
const cost = chunkXSX2UU6Y_cjs.estimateTokens(m.content);
|
|
2925
3038
|
if (budget + cost > COMPACT_USER_MESSAGE_MAX_TOKENS) {
|
|
2926
3039
|
const remaining = COMPACT_USER_MESSAGE_MAX_TOKENS - budget;
|
|
2927
3040
|
if (remaining > 50) {
|
|
@@ -2935,7 +3048,7 @@ async function compactSessionTranscript(opts) {
|
|
|
2935
3048
|
}
|
|
2936
3049
|
const summary = `${COMPACT_SUMMARY_MARKER}
|
|
2937
3050
|
${summaryBody}`;
|
|
2938
|
-
const transcript =
|
|
3051
|
+
const transcript = chunkJHPGF3FP_cjs.SessionTranscript.fromRecords(prior, {
|
|
2939
3052
|
cwd: opts.loc.cwd,
|
|
2940
3053
|
sessionId: opts.sessionId,
|
|
2941
3054
|
model: opts.loc.model ?? "unknown"
|
|
@@ -2945,8 +3058,8 @@ ${summaryBody}`;
|
|
|
2945
3058
|
transcript.appendUserTurn(summary);
|
|
2946
3059
|
const delta = transcript.records().slice(prior.length);
|
|
2947
3060
|
await opts.store.appendRecords(opts.loc.agentId, delta);
|
|
2948
|
-
|
|
2949
|
-
const postTokens =
|
|
3061
|
+
chunk4OTIXDMU_cjs.invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);
|
|
3062
|
+
const postTokens = chunkXSX2UU6Y_cjs.estimateTokens([...preserved, summary].join("\n"));
|
|
2950
3063
|
return { preTokens, postTokens };
|
|
2951
3064
|
}
|
|
2952
3065
|
function resolveSummarizerRoute(opts) {
|
|
@@ -2955,9 +3068,9 @@ function resolveSummarizerRoute(opts) {
|
|
|
2955
3068
|
}
|
|
2956
3069
|
function buildDefaultSummarizer(opts) {
|
|
2957
3070
|
return async (messages) => {
|
|
2958
|
-
|
|
3071
|
+
chunkNIRE5CNO_cjs.registerBuiltins();
|
|
2959
3072
|
const modelPrefix = opts.agentModel.includes("/") ? opts.agentModel.slice(0, opts.agentModel.indexOf("/")) : void 0;
|
|
2960
|
-
const prefixProfile = modelPrefix !== void 0 ?
|
|
3073
|
+
const prefixProfile = modelPrefix !== void 0 ? chunkNIRE5CNO_cjs.getProviderProfile(modelPrefix) : void 0;
|
|
2961
3074
|
const prefixUsable = prefixProfile !== void 0 && (prefixProfile.authType !== "api_key" || prefixProfile.envVars.some((v) => (process.env[v] ?? "").length > 0));
|
|
2962
3075
|
const route = resolveSummarizerRoute({
|
|
2963
3076
|
keyProvider: inferProviderFromApiKey(opts.apiKey),
|
|
@@ -3028,7 +3141,7 @@ async function autoCompactIfNeeded(opts) {
|
|
|
3028
3141
|
return true;
|
|
3029
3142
|
} catch (cause) {
|
|
3030
3143
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
3031
|
-
|
|
3144
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] auto-compaction failed (left transcript untouched): ${msg}
|
|
3032
3145
|
`);
|
|
3033
3146
|
return false;
|
|
3034
3147
|
}
|
|
@@ -3050,6 +3163,7 @@ exports.isFixtureApiKey = isFixtureApiKey;
|
|
|
3050
3163
|
exports.mapOllamaHttpError = mapOllamaHttpError;
|
|
3051
3164
|
exports.mapOllamaTransportError = mapOllamaTransportError;
|
|
3052
3165
|
exports.parseSseStream = parseSseStream;
|
|
3166
|
+
exports.presentProviderCredentialEnvVars = presentProviderCredentialEnvVars;
|
|
3053
3167
|
exports.readErrorResponseBody = readErrorResponseBody;
|
|
3054
3168
|
exports.relayStream = relayStream;
|
|
3055
3169
|
exports.renderToolResultContentText = renderToolResultContentText;
|
|
@@ -3059,5 +3173,6 @@ exports.shouldAutoCompact = shouldAutoCompact;
|
|
|
3059
3173
|
exports.shouldUseFixtureMode = shouldUseFixtureMode;
|
|
3060
3174
|
exports.shouldUseRealLocalRuntime = shouldUseRealLocalRuntime;
|
|
3061
3175
|
exports.tryFirstEvent = tryFirstEvent;
|
|
3062
|
-
|
|
3063
|
-
//# sourceMappingURL=chunk-
|
|
3176
|
+
exports.warnProviderPrecedenceOnce = warnProviderPrecedenceOnce;
|
|
3177
|
+
//# sourceMappingURL=chunk-HLPSLDGL.cjs.map
|
|
3178
|
+
//# sourceMappingURL=chunk-HLPSLDGL.cjs.map
|