@theokit/sdk 4.53.1 → 4.54.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 +1088 -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-CIUgz7cN.d.cts} +190 -850
- package/dist/{agent-nLqeXKIX.d.cts → agent-DSec-E0c.d.ts} +190 -850
- package/dist/agent-NOEGF4GI.cjs +61 -0
- package/dist/{agent-YLAHVHEH.cjs.map → agent-NOEGF4GI.cjs.map} +1 -1
- package/dist/agent-VGD5WL4N.js +52 -0
- package/dist/{agent-FFVV4U5N.js.map → agent-VGD5WL4N.js.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-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-3KGLRRFC.cjs +18 -0
- package/dist/chunk-3KGLRRFC.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-2D43RD5D.cjs → chunk-5BJV5UPY.cjs} +27 -27
- package/dist/chunk-5BJV5UPY.cjs.map +1 -0
- 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-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-V6HWJQQV.js → chunk-AGSBJD2L.js} +27 -30
- package/dist/chunk-AGSBJD2L.js.map +1 -0
- 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-GOVJO4YE.js → chunk-DUIF54UP.js} +6 -6
- package/dist/chunk-DUIF54UP.js.map +1 -0
- 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-HE4BIAOS.js → chunk-F7AQV62G.js} +5 -4
- package/dist/chunk-F7AQV62G.js.map +1 -0
- package/dist/{chunk-HSQ5Q3I5.js → chunk-FXEUP75G.js} +5 -5
- package/dist/chunk-FXEUP75G.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-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-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-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-XPR366DL.cjs → chunk-NGESVVJN.cjs} +17 -17
- package/dist/chunk-NGESVVJN.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-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-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-VUKQL3L2.cjs → chunk-RM7Y65IG.cjs} +13 -13
- package/dist/chunk-RM7Y65IG.cjs.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-SSQZA3DZ.js +15 -0
- package/dist/chunk-SSQZA3DZ.js.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-G3JWXOGY.js → chunk-TPTZA6NI.js} +250 -103
- package/dist/chunk-TPTZA6NI.js.map +1 -0
- package/dist/{chunk-QBTVATSF.cjs → chunk-TTHBHAJI.cjs} +44 -47
- package/dist/chunk-TTHBHAJI.cjs.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-F77UENR6.cjs → chunk-UFAO4T7Z.cjs} +526 -379
- package/dist/chunk-UFAO4T7Z.cjs.map +1 -0
- package/dist/{chunk-2FYEVT2B.cjs → chunk-UNDROG5N.cjs} +201 -154
- package/dist/chunk-UNDROG5N.cjs.map +1 -0
- 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-LS3LMQ23.js → chunk-VDEWG5TV.js} +88 -43
- package/dist/chunk-VDEWG5TV.js.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-K5LXTBPJ.js +22 -0
- package/dist/{compact-session-4MNKNMO2.js.map → compact-session-K5LXTBPJ.js.map} +1 -1
- package/dist/compact-session-YCT6JMBX.cjs +59 -0
- package/dist/{compact-session-EPFBQ46Z.cjs.map → compact-session-YCT6JMBX.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-CRwy2JBF.d.ts +240 -0
- package/dist/cron-DxxeQ-sK.d.cts +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-DDR6X6PC.js} +9 -8
- package/dist/inject-session-DDR6X6PC.js.map +1 -0
- package/dist/inject-session-XLO3KTBM.cjs +29 -0
- package/dist/inject-session-XLO3KTBM.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/router.d.ts +8 -0
- package/dist/internal/llm/types.d.ts +12 -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 +8 -0
- 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 +50 -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 +19 -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 +1357 -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 chunkRM7Y65IG_cjs = require('./chunk-RM7Y65IG.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 = chunkRM7Y65IG_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
|
+
chunkRM7Y65IG_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-UNDROG5N.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 = chunkRM7Y65IG_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 = chunkRM7Y65IG_cjs.stripBedrockPrefix(request.model);
|
|
797
|
+
const baseUrl = this.options.baseUrl ?? chunkRM7Y65IG_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) {
|
|
@@ -2140,7 +2175,7 @@ var ResponsesApiClient = class {
|
|
|
2140
2175
|
body = JSON.parse(text2);
|
|
2141
2176
|
} catch {
|
|
2142
2177
|
}
|
|
2143
|
-
throw
|
|
2178
|
+
throw chunkDQKERTND_cjs.mapOpenAICompatibleError({
|
|
2144
2179
|
providerId,
|
|
2145
2180
|
status: response.status,
|
|
2146
2181
|
body,
|
|
@@ -2211,7 +2246,7 @@ var ResponsesApiClient = class {
|
|
|
2211
2246
|
} else if (t === "response.failed" || t === "error") {
|
|
2212
2247
|
const msg = event.response?.error?.message ?? event.message ?? "responses stream failed";
|
|
2213
2248
|
yield { type: "error", message: msg };
|
|
2214
|
-
throw
|
|
2249
|
+
throw chunkDQKERTND_cjs.mapOpenAICompatibleError({
|
|
2215
2250
|
providerId,
|
|
2216
2251
|
status: 502,
|
|
2217
2252
|
body: { error: { message: msg } },
|
|
@@ -2242,14 +2277,14 @@ function abortError2(signal) {
|
|
|
2242
2277
|
// src/internal/llm/retrying-client.ts
|
|
2243
2278
|
var MAX_ATTEMPTS = 3;
|
|
2244
2279
|
function isRetriableError(err) {
|
|
2245
|
-
if (!
|
|
2246
|
-
if (err instanceof
|
|
2247
|
-
if (err instanceof
|
|
2248
|
-
if (err instanceof
|
|
2280
|
+
if (!chunkK3FW2XZD_cjs.isTransientError(err)) return false;
|
|
2281
|
+
if (err instanceof chunkK3FW2XZD_cjs.CredentialPoolExhaustedError) return false;
|
|
2282
|
+
if (err instanceof chunkK3FW2XZD_cjs.TheokitAgentError && err.code === "circuit_open") return false;
|
|
2283
|
+
if (err instanceof chunkK3FW2XZD_cjs.RateLimitError && err.metadata?.statusCode === 402) return false;
|
|
2249
2284
|
return true;
|
|
2250
2285
|
}
|
|
2251
2286
|
function retryAfterHintMs(err) {
|
|
2252
|
-
if (!(err instanceof
|
|
2287
|
+
if (!(err instanceof chunkK3FW2XZD_cjs.RateLimitError)) return void 0;
|
|
2253
2288
|
const seconds = err.metadata?.retryAfter;
|
|
2254
2289
|
return typeof seconds === "number" && seconds > 0 ? seconds * 1e3 : void 0;
|
|
2255
2290
|
}
|
|
@@ -2295,16 +2330,16 @@ var RetryingLlmClient = class {
|
|
|
2295
2330
|
*/
|
|
2296
2331
|
async #waitBackoff(err, attempt, signal) {
|
|
2297
2332
|
const hint = retryAfterHintMs(err);
|
|
2298
|
-
const ms =
|
|
2333
|
+
const ms = chunkF3YZMOAU_cjs.computeBackoffMs({
|
|
2299
2334
|
attempt,
|
|
2300
2335
|
...hint !== void 0 ? { retryAfterMs: hint } : {},
|
|
2301
2336
|
...this.#rng !== void 0 ? { rng: this.#rng } : {}
|
|
2302
2337
|
});
|
|
2303
2338
|
const cause = err instanceof Error ? err.name : typeof err;
|
|
2304
|
-
|
|
2339
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2305
2340
|
`retry ${attempt + 1}/${MAX_ATTEMPTS} in ${String(ms)}ms \u2014 ${cause}` + (hint !== void 0 ? ` (Retry-After: ${String(hint)}ms)` : "")
|
|
2306
2341
|
);
|
|
2307
|
-
await
|
|
2342
|
+
await chunkF3YZMOAU_cjs.sleepWithAbort(ms, signal);
|
|
2308
2343
|
}
|
|
2309
2344
|
async *stream(request, signal) {
|
|
2310
2345
|
let lastError;
|
|
@@ -2342,7 +2377,7 @@ function classifyVertexError(args, errStatus) {
|
|
|
2342
2377
|
return "unknown";
|
|
2343
2378
|
}
|
|
2344
2379
|
function vertexMetadata(args, code) {
|
|
2345
|
-
return
|
|
2380
|
+
return chunkDQKERTND_cjs.buildErrorMetadata({
|
|
2346
2381
|
provider: "vertex",
|
|
2347
2382
|
endpoint: args.endpoint,
|
|
2348
2383
|
code,
|
|
@@ -2352,23 +2387,23 @@ function vertexMetadata(args, code) {
|
|
|
2352
2387
|
});
|
|
2353
2388
|
}
|
|
2354
2389
|
var VERTEX_ERROR_BUILDERS = {
|
|
2355
|
-
rate_limit: (args, msg) => new
|
|
2390
|
+
rate_limit: (args, msg) => new chunkK3FW2XZD_cjs.RateLimitError(`Vertex quota exhausted: ${msg}`, {
|
|
2356
2391
|
metadata: vertexMetadata(args, "rate_limit")
|
|
2357
2392
|
}),
|
|
2358
|
-
auth_unauthenticated: (args, msg) => new
|
|
2393
|
+
auth_unauthenticated: (args, msg) => new chunkK3FW2XZD_cjs.AuthenticationError(`Vertex unauthenticated: ${msg}`, {
|
|
2359
2394
|
metadata: vertexMetadata(args, "auth_failed")
|
|
2360
2395
|
}),
|
|
2361
|
-
auth_permission: (args, msg) => new
|
|
2396
|
+
auth_permission: (args, msg) => new chunkK3FW2XZD_cjs.AuthenticationError(`Vertex permission denied: ${msg}`, {
|
|
2362
2397
|
metadata: vertexMetadata(args, "auth_failed")
|
|
2363
2398
|
}),
|
|
2364
|
-
invalid_request: (args, msg) => new
|
|
2399
|
+
invalid_request: (args, msg) => new chunkK3FW2XZD_cjs.ConfigurationError(`Vertex validation: ${msg}`, {
|
|
2365
2400
|
metadata: vertexMetadata(args, "invalid_request")
|
|
2366
2401
|
}),
|
|
2367
|
-
timeout: (args, msg) => new
|
|
2368
|
-
server_error: (args, msg) => new
|
|
2402
|
+
timeout: (args, msg) => new chunkK3FW2XZD_cjs.NetworkError(`Vertex timeout: ${msg}`, { metadata: vertexMetadata(args, "timeout") }),
|
|
2403
|
+
server_error: (args, msg) => new chunkK3FW2XZD_cjs.NetworkError(`Vertex server error: ${msg}`, {
|
|
2369
2404
|
metadata: vertexMetadata(args, "server_error")
|
|
2370
2405
|
}),
|
|
2371
|
-
unknown: (args, msg) => new
|
|
2406
|
+
unknown: (args, msg) => new chunkK3FW2XZD_cjs.UnknownAgentError(`Vertex unknown: ${msg}`, { metadata: vertexMetadata(args, "unknown") })
|
|
2372
2407
|
};
|
|
2373
2408
|
function mapVertexError(args) {
|
|
2374
2409
|
const parsed = parseBody2(args.body);
|
|
@@ -2404,12 +2439,12 @@ async function resolveVertexAccessToken() {
|
|
|
2404
2439
|
async function getAuthClientOrThrow() {
|
|
2405
2440
|
let mod;
|
|
2406
2441
|
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-
|
|
2442
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UNDROG5N.cjs', document.baseURI).href)));
|
|
2408
2443
|
mod = r("google-auth-library");
|
|
2409
2444
|
} catch (err) {
|
|
2410
2445
|
const isModuleMissing = err instanceof Error && (err.message.includes("Cannot find module") || err.code === "MODULE_NOT_FOUND");
|
|
2411
2446
|
if (isModuleMissing) {
|
|
2412
|
-
throw new
|
|
2447
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2413
2448
|
"Vertex provider requires `google-auth-library`. Install: `pnpm add google-auth-library`.",
|
|
2414
2449
|
{ code: "auth_failed", cause: err }
|
|
2415
2450
|
);
|
|
@@ -2420,7 +2455,7 @@ async function getAuthClientOrThrow() {
|
|
|
2420
2455
|
const auth = new mod.GoogleAuth({ scopes: [SCOPE_CLOUD_PLATFORM] });
|
|
2421
2456
|
return await auth.getClient();
|
|
2422
2457
|
} catch (err) {
|
|
2423
|
-
|
|
2458
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2424
2459
|
`[theokit-sdk] Vertex ADC initialization failed: ${err instanceof Error ? err.message : String(err)}
|
|
2425
2460
|
`
|
|
2426
2461
|
);
|
|
@@ -2446,7 +2481,7 @@ var VertexAnthropicClient = class {
|
|
|
2446
2481
|
resolveProjectOrThrow() {
|
|
2447
2482
|
const projectId = this.options.projectId ?? resolveVertexProjectId();
|
|
2448
2483
|
if (projectId !== void 0) return projectId;
|
|
2449
|
-
throw new
|
|
2484
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2450
2485
|
"Vertex requires a project id. Set GOOGLE_CLOUD_PROJECT env var or run `gcloud config set project <id>`.",
|
|
2451
2486
|
{ code: "auth_failed" }
|
|
2452
2487
|
);
|
|
@@ -2456,7 +2491,7 @@ var VertexAnthropicClient = class {
|
|
|
2456
2491
|
if (fromOpts !== void 0 && fromOpts.length > 0) return fromOpts;
|
|
2457
2492
|
const fromAdc = await resolveVertexAccessToken();
|
|
2458
2493
|
if (fromAdc !== void 0 && fromAdc.length > 0) return fromAdc;
|
|
2459
|
-
throw new
|
|
2494
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2460
2495
|
"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
2496
|
{ code: "auth_failed" }
|
|
2462
2497
|
);
|
|
@@ -2465,8 +2500,8 @@ var VertexAnthropicClient = class {
|
|
|
2465
2500
|
const projectId = this.resolveProjectOrThrow();
|
|
2466
2501
|
const location = this.options.location ?? resolveVertexLocation();
|
|
2467
2502
|
const accessToken = await this.resolveTokenOrThrow();
|
|
2468
|
-
const baseUrl =
|
|
2469
|
-
const bareModel =
|
|
2503
|
+
const baseUrl = chunkRM7Y65IG_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "anthropic" });
|
|
2504
|
+
const bareModel = chunkRM7Y65IG_cjs.stripVertexPrefix(request.model);
|
|
2470
2505
|
const endpoint = `/models/${encodeURIComponent(bareModel)}:rawPredict`;
|
|
2471
2506
|
const url = `${baseUrl}${endpoint}`;
|
|
2472
2507
|
const response = await postAnthropicRequest({
|
|
@@ -2502,7 +2537,7 @@ var VertexGeminiClient = class {
|
|
|
2502
2537
|
async *stream(request, signal) {
|
|
2503
2538
|
const projectId = this.options.projectId ?? resolveVertexProjectId();
|
|
2504
2539
|
if (projectId === void 0) {
|
|
2505
|
-
throw new
|
|
2540
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2506
2541
|
"Vertex requires a project id. Set GOOGLE_CLOUD_PROJECT env var or run `gcloud config set project <id>`.",
|
|
2507
2542
|
{ code: "auth_failed" }
|
|
2508
2543
|
);
|
|
@@ -2510,19 +2545,15 @@ var VertexGeminiClient = class {
|
|
|
2510
2545
|
const location = this.options.location ?? resolveVertexLocation();
|
|
2511
2546
|
const accessToken = this.options.apiKey !== void 0 && this.options.apiKey.length > 0 ? this.options.apiKey : await resolveVertexAccessToken();
|
|
2512
2547
|
if (accessToken === void 0 || accessToken.length === 0) {
|
|
2513
|
-
throw new
|
|
2548
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2514
2549
|
"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
2550
|
{ code: "auth_failed" }
|
|
2516
2551
|
);
|
|
2517
2552
|
}
|
|
2518
|
-
const baseUrl =
|
|
2553
|
+
const baseUrl = chunkRM7Y65IG_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "gemini" });
|
|
2519
2554
|
const url = `${baseUrl}/chat/completions`;
|
|
2520
2555
|
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
|
-
};
|
|
2556
|
+
const rewriteFetch = (_input, init) => innerFetch(url, init);
|
|
2526
2557
|
const inner = new OpenAIClient({
|
|
2527
2558
|
apiKey: accessToken,
|
|
2528
2559
|
baseUrl: "https://_vertex_placeholder",
|
|
@@ -2541,7 +2572,7 @@ var VertexRouterClient = class {
|
|
|
2541
2572
|
options;
|
|
2542
2573
|
name = "vertex";
|
|
2543
2574
|
async *stream(request, signal) {
|
|
2544
|
-
const dialect =
|
|
2575
|
+
const dialect = chunkRM7Y65IG_cjs.inferModelDialect(request.model);
|
|
2545
2576
|
if (dialect === "anthropic") {
|
|
2546
2577
|
const inner2 = new VertexAnthropicClient(this.options);
|
|
2547
2578
|
return yield* inner2.stream(request, signal);
|
|
@@ -2553,73 +2584,73 @@ var VertexRouterClient = class {
|
|
|
2553
2584
|
|
|
2554
2585
|
// src/internal/llm/router.ts
|
|
2555
2586
|
function resolveProviderChain(options) {
|
|
2556
|
-
|
|
2587
|
+
chunkRM7Y65IG_cjs.registerBuiltins();
|
|
2557
2588
|
return buildChain(options);
|
|
2558
2589
|
}
|
|
2559
2590
|
function buildChain(options) {
|
|
2560
2591
|
warnUnknownProvidersInApiKeys(options.apiKeys);
|
|
2561
2592
|
const seen = /* @__PURE__ */ new Set();
|
|
2562
2593
|
const clients = [];
|
|
2563
|
-
const addClient = (name) => {
|
|
2594
|
+
const addClient = (name, perCallBaseUrl) => {
|
|
2564
2595
|
const lowered = name.toLowerCase();
|
|
2565
2596
|
if (seen.has(lowered)) return;
|
|
2566
2597
|
seen.add(lowered);
|
|
2567
|
-
const client = buildClient(lowered, options);
|
|
2598
|
+
const client = buildClient(lowered, options, perCallBaseUrl);
|
|
2568
2599
|
if (client !== void 0) clients.push(maybeWrapWithFaultInjection(client));
|
|
2569
2600
|
};
|
|
2570
|
-
addClient(options.primary);
|
|
2601
|
+
addClient(options.primary, options.baseUrl);
|
|
2571
2602
|
for (const fallback of options.fallback ?? []) addClient(fallback);
|
|
2572
2603
|
if (clients.length === 0) {
|
|
2573
|
-
throw new
|
|
2604
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2574
2605
|
`No provider client could be resolved (primary=${options.primary}). Set ANTHROPIC_API_KEY or OPENAI_API_KEY / OPENROUTER_API_KEY.`,
|
|
2575
2606
|
{ code: "provider_unresolved" }
|
|
2576
2607
|
);
|
|
2577
2608
|
}
|
|
2578
2609
|
return clients;
|
|
2579
2610
|
}
|
|
2580
|
-
function buildClient(name, routerOptions) {
|
|
2581
|
-
const baseProfile =
|
|
2611
|
+
function buildClient(name, routerOptions, perCallBaseUrl) {
|
|
2612
|
+
const baseProfile = chunkRM7Y65IG_cjs.getProviderProfile(name);
|
|
2582
2613
|
if (baseProfile === void 0) return void 0;
|
|
2583
2614
|
const profile = routerOptions.extractToolCallsFromContent === true && baseProfile.extractToolCallsFromContent !== true ? { ...baseProfile, extractToolCallsFromContent: true } : baseProfile;
|
|
2584
2615
|
const resilience = routerOptions.onRateLimit !== void 0 ? { onRateLimit: routerOptions.onRateLimit } : {};
|
|
2585
|
-
const ambient =
|
|
2616
|
+
const ambient = chunkF3YZMOAU_cjs.currentCredentialPool(name);
|
|
2586
2617
|
if (ambient !== void 0) {
|
|
2587
2618
|
return new RetryingLlmClient(
|
|
2588
2619
|
new PoolAwareLlmClient(
|
|
2589
2620
|
ambient,
|
|
2590
|
-
(apiKey) => selectTransport(profile, apiKey),
|
|
2621
|
+
(apiKey) => selectTransport(profile, apiKey, perCallBaseUrl),
|
|
2591
2622
|
void 0,
|
|
2592
2623
|
resilience
|
|
2593
2624
|
)
|
|
2594
2625
|
);
|
|
2595
2626
|
}
|
|
2596
2627
|
const poolKeys = filterPoolKeys(routerOptions.apiKeys?.[name]);
|
|
2597
|
-
const noAuthOverride = maybeBuildNoAuthTransport(profile, poolKeys);
|
|
2628
|
+
const noAuthOverride = maybeBuildNoAuthTransport(profile, poolKeys, perCallBaseUrl);
|
|
2598
2629
|
if (noAuthOverride !== void 0) return noAuthOverride;
|
|
2599
|
-
return buildPoolOrSingle({ name, profile, poolKeys, routerOptions });
|
|
2630
|
+
return buildPoolOrSingle({ name, profile, poolKeys, routerOptions, perCallBaseUrl });
|
|
2600
2631
|
}
|
|
2601
|
-
function maybeBuildNoAuthTransport(profile, poolKeys) {
|
|
2632
|
+
function maybeBuildNoAuthTransport(profile, poolKeys, baseUrl) {
|
|
2602
2633
|
if (profile.authType !== "none" || poolKeys === void 0 || poolKeys.length === 0) {
|
|
2603
2634
|
return void 0;
|
|
2604
2635
|
}
|
|
2605
2636
|
warnNoAuthApiKeysIgnoredOnce(profile.name);
|
|
2606
2637
|
const sentinel = sentinelForNoAuth(profile);
|
|
2607
2638
|
if (sentinel === void 0) return void 0;
|
|
2608
|
-
return selectTransport(profile, sentinel);
|
|
2639
|
+
return selectTransport(profile, sentinel, baseUrl);
|
|
2609
2640
|
}
|
|
2610
2641
|
function buildPoolOrSingle(args) {
|
|
2611
|
-
const { name, profile, poolKeys, routerOptions } = args;
|
|
2642
|
+
const { name, profile, poolKeys, routerOptions, perCallBaseUrl } = args;
|
|
2612
2643
|
if (poolKeys !== void 0 && poolKeys.length >= 2) {
|
|
2613
2644
|
const strategy = routerOptions.credentialPoolStrategy?.[name] ?? "fill_first";
|
|
2614
2645
|
const entries = poolKeys.map(
|
|
2615
|
-
(accessToken, priority) =>
|
|
2646
|
+
(accessToken, priority) => chunkF3YZMOAU_cjs.newPooledCredential({ provider: name, accessToken, priority, source: "manual" })
|
|
2616
2647
|
);
|
|
2617
|
-
const pool = new
|
|
2648
|
+
const pool = new chunkF3YZMOAU_cjs.CredentialPool(name, entries, strategy);
|
|
2618
2649
|
const resilience = routerOptions.onRateLimit !== void 0 ? { onRateLimit: routerOptions.onRateLimit } : {};
|
|
2619
2650
|
return new RetryingLlmClient(
|
|
2620
2651
|
new PoolAwareLlmClient(
|
|
2621
2652
|
pool,
|
|
2622
|
-
(apiKey2) => selectTransport(profile, apiKey2),
|
|
2653
|
+
(apiKey2) => selectTransport(profile, apiKey2, perCallBaseUrl),
|
|
2623
2654
|
void 0,
|
|
2624
2655
|
resilience
|
|
2625
2656
|
)
|
|
@@ -2627,7 +2658,7 @@ function buildPoolOrSingle(args) {
|
|
|
2627
2658
|
}
|
|
2628
2659
|
const apiKey = poolKeys?.[0] ?? resolveApiKey(profile.envVars) ?? sentinelForNoAuth(profile) ?? sentinelForLazyAuth(profile);
|
|
2629
2660
|
if (apiKey === void 0) return void 0;
|
|
2630
|
-
return new RetryingLlmClient(selectTransport(profile, apiKey));
|
|
2661
|
+
return new RetryingLlmClient(selectTransport(profile, apiKey, perCallBaseUrl));
|
|
2631
2662
|
}
|
|
2632
2663
|
function resolveBaseUrlEnvOverride(providerName) {
|
|
2633
2664
|
switch (providerName) {
|
|
@@ -2635,8 +2666,6 @@ function resolveBaseUrlEnvOverride(providerName) {
|
|
|
2635
2666
|
return process.env.OPENAI_API_BASE_URL;
|
|
2636
2667
|
case "openrouter":
|
|
2637
2668
|
return process.env.OPENROUTER_API_BASE_URL;
|
|
2638
|
-
case "ollama":
|
|
2639
|
-
return process.env.OLLAMA_HOST;
|
|
2640
2669
|
case "lmstudio":
|
|
2641
2670
|
return process.env.LMSTUDIO_HOST;
|
|
2642
2671
|
case "llamacpp":
|
|
@@ -2649,7 +2678,7 @@ var warnedNoAuthApiKeys = /* @__PURE__ */ new Set();
|
|
|
2649
2678
|
function warnNoAuthApiKeysIgnoredOnce(provider) {
|
|
2650
2679
|
if (warnedNoAuthApiKeys.has(provider)) return;
|
|
2651
2680
|
warnedNoAuthApiKeys.add(provider);
|
|
2652
|
-
|
|
2681
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2653
2682
|
`[theokit-sdk] provider "${provider}" has authType: "none" \u2014 apiKeys ignored (no auth required for local runtime).
|
|
2654
2683
|
`
|
|
2655
2684
|
);
|
|
@@ -2675,10 +2704,10 @@ function warnUnknownProvidersInApiKeys(apiKeys) {
|
|
|
2675
2704
|
if (apiKeys === void 0) return;
|
|
2676
2705
|
for (const name of Object.keys(apiKeys)) {
|
|
2677
2706
|
if (warnedProviders.has(name)) continue;
|
|
2678
|
-
const profile =
|
|
2707
|
+
const profile = chunkRM7Y65IG_cjs.getProviderProfile(name);
|
|
2679
2708
|
if (profile === void 0) {
|
|
2680
2709
|
warnedProviders.add(name);
|
|
2681
|
-
|
|
2710
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2682
2711
|
`[theokit-sdk] credential-pool: unknown provider "${name}" in apiKeys (no profile registered)
|
|
2683
2712
|
`
|
|
2684
2713
|
);
|
|
@@ -2692,7 +2721,7 @@ function resolveApiKey(envVars) {
|
|
|
2692
2721
|
}
|
|
2693
2722
|
return void 0;
|
|
2694
2723
|
}
|
|
2695
|
-
function selectTransport(profile, apiKey) {
|
|
2724
|
+
function selectTransport(profile, apiKey, baseUrl) {
|
|
2696
2725
|
const applyTransform = () => {
|
|
2697
2726
|
if (profile.transform === void 0) return {};
|
|
2698
2727
|
const ctx = { apiKey };
|
|
@@ -2710,14 +2739,14 @@ function selectTransport(profile, apiKey) {
|
|
|
2710
2739
|
if (apiKey !== "__oauth_lazy_token__") return;
|
|
2711
2740
|
const auth = t.headers?.authorization ?? t.headers?.Authorization;
|
|
2712
2741
|
if (t.fetch === void 0 && auth === void 0) {
|
|
2713
|
-
throw new
|
|
2742
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2714
2743
|
`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
2744
|
);
|
|
2716
2745
|
}
|
|
2717
2746
|
};
|
|
2718
2747
|
if (profile.apiMode === "chat_completions") {
|
|
2719
2748
|
if (profile.name === "ollama") {
|
|
2720
|
-
const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
|
|
2749
|
+
const ollamaBase = baseUrl ?? process.env.OLLAMA_HOST ?? profile.baseUrl;
|
|
2721
2750
|
return new OllamaNativeClient({ apiKey, baseUrl: ollamaBase });
|
|
2722
2751
|
}
|
|
2723
2752
|
const opts = { apiKey };
|
|
@@ -2734,6 +2763,7 @@ function selectTransport(profile, apiKey) {
|
|
|
2734
2763
|
}
|
|
2735
2764
|
const envOverride = resolveBaseUrlEnvOverride(profile.name);
|
|
2736
2765
|
if (envOverride !== void 0) opts.baseUrl = envOverride;
|
|
2766
|
+
if (baseUrl !== void 0) opts.baseUrl = baseUrl;
|
|
2737
2767
|
return comTransform(opts, (o) => new OpenAIClient(o));
|
|
2738
2768
|
}
|
|
2739
2769
|
if (profile.apiMode === "anthropic_messages") {
|
|
@@ -2742,12 +2772,15 @@ function selectTransport(profile, apiKey) {
|
|
|
2742
2772
|
return new VertexRouterClient(realKey !== void 0 ? { apiKey: realKey } : {});
|
|
2743
2773
|
}
|
|
2744
2774
|
const opts = { apiKey };
|
|
2745
|
-
opts.baseUrl = process.env.ANTHROPIC_API_BASE_URL ?? profile.baseUrl;
|
|
2775
|
+
opts.baseUrl = baseUrl ?? process.env.ANTHROPIC_API_BASE_URL ?? profile.baseUrl;
|
|
2746
2776
|
return comTransform(opts, (o) => new AnthropicClient(o));
|
|
2747
2777
|
}
|
|
2748
2778
|
if (profile.apiMode === "bedrock_anthropic") {
|
|
2749
2779
|
const realKey = apiKey === "__bedrock_lazy_token__" ? void 0 : apiKey;
|
|
2750
|
-
return new BedrockAnthropicClient(
|
|
2780
|
+
return new BedrockAnthropicClient({
|
|
2781
|
+
...realKey !== void 0 ? { apiKey: realKey } : {},
|
|
2782
|
+
...baseUrl !== void 0 ? { baseUrl } : {}
|
|
2783
|
+
});
|
|
2751
2784
|
}
|
|
2752
2785
|
if (profile.apiMode === "responses_api") {
|
|
2753
2786
|
const t = applyTransform();
|
|
@@ -2755,13 +2788,14 @@ function selectTransport(profile, apiKey) {
|
|
|
2755
2788
|
const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
|
|
2756
2789
|
return new ResponsesApiClient({
|
|
2757
2790
|
apiKey,
|
|
2758
|
-
|
|
2791
|
+
// Per-call URL first, same contract as every other branch (B-150).
|
|
2792
|
+
...(baseUrl ?? profile.baseUrl) !== void 0 ? { baseUrl: baseUrl ?? profile.baseUrl } : {},
|
|
2759
2793
|
...mergedHeaders !== void 0 ? { extraHeaders: mergedHeaders } : {},
|
|
2760
2794
|
...t.fetch !== void 0 ? { fetch: t.fetch } : {},
|
|
2761
2795
|
providerName: profile.name
|
|
2762
2796
|
});
|
|
2763
2797
|
}
|
|
2764
|
-
throw new
|
|
2798
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2765
2799
|
`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
2800
|
{ code: "transport_unavailable" }
|
|
2767
2801
|
);
|
|
@@ -2771,7 +2805,7 @@ function selectTransport(profile, apiKey) {
|
|
|
2771
2805
|
function inferProviderFromApiKey(apiKey) {
|
|
2772
2806
|
const provider = chunkFRITRLZQ_cjs.providerFromApiKeyPrefix(apiKey);
|
|
2773
2807
|
if (provider === void 0) return void 0;
|
|
2774
|
-
return
|
|
2808
|
+
return chunkRM7Y65IG_cjs.getProviderProfile(provider) === void 0 ? void 0 : provider;
|
|
2775
2809
|
}
|
|
2776
2810
|
function detectPrimaryProvider() {
|
|
2777
2811
|
if (process.env.ANTHROPIC_API_KEY !== void 0 && process.env.ANTHROPIC_API_KEY.length > 0) {
|
|
@@ -2785,6 +2819,17 @@ function detectPrimaryProvider() {
|
|
|
2785
2819
|
}
|
|
2786
2820
|
return "openai";
|
|
2787
2821
|
}
|
|
2822
|
+
var warnedProviderPrecedence = /* @__PURE__ */ new Set();
|
|
2823
|
+
function warnProviderPrecedenceOnce(asked, used) {
|
|
2824
|
+
if (asked === void 0 || asked === used) return;
|
|
2825
|
+
const key = `${asked}->${used}`;
|
|
2826
|
+
if (warnedProviderPrecedence.has(key)) return;
|
|
2827
|
+
warnedProviderPrecedence.add(key);
|
|
2828
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2829
|
+
`[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.
|
|
2830
|
+
`
|
|
2831
|
+
);
|
|
2832
|
+
}
|
|
2788
2833
|
|
|
2789
2834
|
// src/internal/runtime/compression/compression-model-registry.ts
|
|
2790
2835
|
var EXACT_REGISTRY = /* @__PURE__ */ new Map([
|
|
@@ -2906,7 +2951,7 @@ function plainText(content) {
|
|
|
2906
2951
|
}
|
|
2907
2952
|
async function compactSessionTranscript(opts) {
|
|
2908
2953
|
const prior = await opts.store.readRecords(opts.loc.agentId);
|
|
2909
|
-
const history =
|
|
2954
|
+
const history = chunkJHPGF3FP_cjs.reconstructMessages(prior);
|
|
2910
2955
|
const compressible = [];
|
|
2911
2956
|
for (const m of history) {
|
|
2912
2957
|
const text = plainText(m.content);
|
|
@@ -2914,14 +2959,14 @@ async function compactSessionTranscript(opts) {
|
|
|
2914
2959
|
compressible.push({ role: m.role, content: text });
|
|
2915
2960
|
}
|
|
2916
2961
|
}
|
|
2917
|
-
const preTokens =
|
|
2962
|
+
const preTokens = chunkXSX2UU6Y_cjs.estimateTokens(compressible.map((m) => m.content).join("\n"));
|
|
2918
2963
|
const summaryBody = await opts.summarize(compressible);
|
|
2919
2964
|
const preserved = [];
|
|
2920
2965
|
let budget = 0;
|
|
2921
2966
|
for (let i = compressible.length - 1; i >= 0; i--) {
|
|
2922
2967
|
const m = compressible[i];
|
|
2923
2968
|
if (m === void 0 || m.role !== "user" || isCompactSummary(m.content)) continue;
|
|
2924
|
-
const cost =
|
|
2969
|
+
const cost = chunkXSX2UU6Y_cjs.estimateTokens(m.content);
|
|
2925
2970
|
if (budget + cost > COMPACT_USER_MESSAGE_MAX_TOKENS) {
|
|
2926
2971
|
const remaining = COMPACT_USER_MESSAGE_MAX_TOKENS - budget;
|
|
2927
2972
|
if (remaining > 50) {
|
|
@@ -2935,7 +2980,7 @@ async function compactSessionTranscript(opts) {
|
|
|
2935
2980
|
}
|
|
2936
2981
|
const summary = `${COMPACT_SUMMARY_MARKER}
|
|
2937
2982
|
${summaryBody}`;
|
|
2938
|
-
const transcript =
|
|
2983
|
+
const transcript = chunkJHPGF3FP_cjs.SessionTranscript.fromRecords(prior, {
|
|
2939
2984
|
cwd: opts.loc.cwd,
|
|
2940
2985
|
sessionId: opts.sessionId,
|
|
2941
2986
|
model: opts.loc.model ?? "unknown"
|
|
@@ -2945,8 +2990,8 @@ ${summaryBody}`;
|
|
|
2945
2990
|
transcript.appendUserTurn(summary);
|
|
2946
2991
|
const delta = transcript.records().slice(prior.length);
|
|
2947
2992
|
await opts.store.appendRecords(opts.loc.agentId, delta);
|
|
2948
|
-
|
|
2949
|
-
const postTokens =
|
|
2993
|
+
chunk4OTIXDMU_cjs.invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);
|
|
2994
|
+
const postTokens = chunkXSX2UU6Y_cjs.estimateTokens([...preserved, summary].join("\n"));
|
|
2950
2995
|
return { preTokens, postTokens };
|
|
2951
2996
|
}
|
|
2952
2997
|
function resolveSummarizerRoute(opts) {
|
|
@@ -2955,9 +3000,9 @@ function resolveSummarizerRoute(opts) {
|
|
|
2955
3000
|
}
|
|
2956
3001
|
function buildDefaultSummarizer(opts) {
|
|
2957
3002
|
return async (messages) => {
|
|
2958
|
-
|
|
3003
|
+
chunkRM7Y65IG_cjs.registerBuiltins();
|
|
2959
3004
|
const modelPrefix = opts.agentModel.includes("/") ? opts.agentModel.slice(0, opts.agentModel.indexOf("/")) : void 0;
|
|
2960
|
-
const prefixProfile = modelPrefix !== void 0 ?
|
|
3005
|
+
const prefixProfile = modelPrefix !== void 0 ? chunkRM7Y65IG_cjs.getProviderProfile(modelPrefix) : void 0;
|
|
2961
3006
|
const prefixUsable = prefixProfile !== void 0 && (prefixProfile.authType !== "api_key" || prefixProfile.envVars.some((v) => (process.env[v] ?? "").length > 0));
|
|
2962
3007
|
const route = resolveSummarizerRoute({
|
|
2963
3008
|
keyProvider: inferProviderFromApiKey(opts.apiKey),
|
|
@@ -3028,7 +3073,7 @@ async function autoCompactIfNeeded(opts) {
|
|
|
3028
3073
|
return true;
|
|
3029
3074
|
} catch (cause) {
|
|
3030
3075
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
3031
|
-
|
|
3076
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] auto-compaction failed (left transcript untouched): ${msg}
|
|
3032
3077
|
`);
|
|
3033
3078
|
return false;
|
|
3034
3079
|
}
|
|
@@ -3050,6 +3095,7 @@ exports.isFixtureApiKey = isFixtureApiKey;
|
|
|
3050
3095
|
exports.mapOllamaHttpError = mapOllamaHttpError;
|
|
3051
3096
|
exports.mapOllamaTransportError = mapOllamaTransportError;
|
|
3052
3097
|
exports.parseSseStream = parseSseStream;
|
|
3098
|
+
exports.presentProviderCredentialEnvVars = presentProviderCredentialEnvVars;
|
|
3053
3099
|
exports.readErrorResponseBody = readErrorResponseBody;
|
|
3054
3100
|
exports.relayStream = relayStream;
|
|
3055
3101
|
exports.renderToolResultContentText = renderToolResultContentText;
|
|
@@ -3059,5 +3105,6 @@ exports.shouldAutoCompact = shouldAutoCompact;
|
|
|
3059
3105
|
exports.shouldUseFixtureMode = shouldUseFixtureMode;
|
|
3060
3106
|
exports.shouldUseRealLocalRuntime = shouldUseRealLocalRuntime;
|
|
3061
3107
|
exports.tryFirstEvent = tryFirstEvent;
|
|
3062
|
-
|
|
3063
|
-
//# sourceMappingURL=chunk-
|
|
3108
|
+
exports.warnProviderPrecedenceOnce = warnProviderPrecedenceOnce;
|
|
3109
|
+
//# sourceMappingURL=chunk-UNDROG5N.cjs.map
|
|
3110
|
+
//# sourceMappingURL=chunk-UNDROG5N.cjs.map
|