@theokit/sdk 4.53.1 → 4.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1184 -0
- package/README.md +9 -4
- package/dist/a2a/agent-mailbox.d.cts +27 -0
- package/dist/a2a/agent-mailbox.d.ts +27 -0
- package/dist/a2a/index.cjs +9 -4
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +7 -2
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/message-bus.d.cts +39 -0
- package/dist/a2a/message-bus.d.ts +39 -0
- package/dist/a2a/subagent.d.cts +68 -7
- package/dist/a2a/subagent.d.ts +68 -7
- package/dist/a2a/types.d.cts +26 -0
- package/dist/a2a/types.d.ts +26 -0
- package/dist/{agent-B9HXlwID.d.ts → agent-D3Xr_-6Z.d.cts} +245 -850
- package/dist/{agent-nLqeXKIX.d.cts → agent-DIu6FooJ.d.ts} +245 -850
- package/dist/agent-HDEVVUBS.js +52 -0
- package/dist/{agent-FFVV4U5N.js.map → agent-HDEVVUBS.js.map} +1 -1
- package/dist/agent-R2HOJFZJ.cjs +61 -0
- package/dist/{agent-YLAHVHEH.cjs.map → agent-R2HOJFZJ.cjs.map} +1 -1
- package/dist/agent-builder.d.ts +19 -0
- package/dist/agent-session-store-P6V3FINW.js +7 -0
- package/dist/{agent-session-store-TNCGL5RN.js.map → agent-session-store-P6V3FINW.js.map} +1 -1
- package/dist/agent-session-store-ZJ3JSRS4.cjs +24 -0
- package/dist/{agent-session-store-DUGBAX5V.cjs.map → agent-session-store-ZJ3JSRS4.cjs.map} +1 -1
- package/dist/agent.d.ts +9 -6
- package/dist/auth/index.cjs +52 -35
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.js +26 -9
- package/dist/auth/index.js.map +1 -1
- package/dist/{batch-UPKN4SG6.js → batch-2TGJMNCJ.js} +14 -13
- package/dist/batch-2TGJMNCJ.js.map +1 -0
- package/dist/{batch-ZEFN5SO7.cjs → batch-ND32UKZS.cjs} +31 -30
- package/dist/batch-ND32UKZS.cjs.map +1 -0
- package/dist/{chunk-TTJ54H3E.cjs → chunk-2ADR2GSO.cjs} +8 -8
- package/dist/chunk-2ADR2GSO.cjs.map +1 -0
- package/dist/chunk-2BDH744Z.js +15 -0
- package/dist/chunk-2BDH744Z.js.map +1 -0
- package/dist/{chunk-VGPXHHF3.cjs → chunk-2C72DXQF.cjs} +63 -27
- package/dist/chunk-2C72DXQF.cjs.map +1 -0
- package/dist/{chunk-4Q4K4WB5.js → chunk-2D34UTDC.js} +20 -4
- package/dist/chunk-2D34UTDC.js.map +1 -0
- package/dist/{chunk-UFIXH26P.js → chunk-2QKTVKH3.js} +4 -4
- package/dist/{chunk-UFIXH26P.js.map → chunk-2QKTVKH3.js.map} +1 -1
- package/dist/{chunk-GBBDINFK.js → chunk-3E77SX4H.js} +4 -4
- package/dist/{chunk-GBBDINFK.js.map → chunk-3E77SX4H.js.map} +1 -1
- package/dist/{chunk-VYHJZVL5.cjs → chunk-3EE6LVWT.cjs} +2 -2
- package/dist/chunk-3EE6LVWT.cjs.map +1 -0
- package/dist/{chunk-5NBUH3NO.js → chunk-3OR54XG4.js} +2 -2
- package/dist/{chunk-C6Y6CWYD.cjs.map → chunk-3OR54XG4.js.map} +1 -1
- package/dist/{chunk-ZN2DGEY3.cjs → chunk-3YJNUKYN.cjs} +15 -15
- package/dist/{chunk-ZN2DGEY3.cjs.map → chunk-3YJNUKYN.cjs.map} +1 -1
- package/dist/{chunk-POWRZSK4.js → chunk-44JAAH4X.js} +3 -3
- package/dist/{chunk-POWRZSK4.js.map → chunk-44JAAH4X.js.map} +1 -1
- package/dist/{chunk-SSDD676S.js → chunk-44MBDIHG.js} +4 -4
- package/dist/{chunk-SSDD676S.js.map → chunk-44MBDIHG.js.map} +1 -1
- package/dist/{chunk-OY7O3Q6R.js → chunk-4ERPXIVB.js} +5 -5
- package/dist/{chunk-OY7O3Q6R.js.map → chunk-4ERPXIVB.js.map} +1 -1
- package/dist/{chunk-3BK6YR5P.cjs → chunk-4I55V454.cjs} +4 -4
- package/dist/{chunk-3BK6YR5P.cjs.map → chunk-4I55V454.cjs.map} +1 -1
- package/dist/{chunk-B4YA6BRS.cjs → chunk-4O5TGQBW.cjs} +30 -7
- package/dist/chunk-4O5TGQBW.cjs.map +1 -0
- package/dist/{chunk-4JBHSLQO.cjs → chunk-4OTIXDMU.cjs} +2 -2
- package/dist/{chunk-4JBHSLQO.cjs.map → chunk-4OTIXDMU.cjs.map} +1 -1
- package/dist/{chunk-C6Y6CWYD.cjs → chunk-52NKC5HT.cjs} +2 -2
- package/dist/chunk-52NKC5HT.cjs.map +1 -0
- package/dist/{chunk-665SFFFR.cjs → chunk-53CBTBWO.cjs} +11 -11
- package/dist/{chunk-665SFFFR.cjs.map → chunk-53CBTBWO.cjs.map} +1 -1
- package/dist/{chunk-FFM3SJTQ.js → chunk-5JLFFPCH.js} +4 -4
- package/dist/{chunk-FFM3SJTQ.js.map → chunk-5JLFFPCH.js.map} +1 -1
- package/dist/{chunk-34XOCZJO.js → chunk-5PHVENFV.js} +3 -3
- package/dist/chunk-5PHVENFV.js.map +1 -0
- package/dist/{chunk-BDTVFIPB.cjs → chunk-5UOVYM3P.cjs} +36 -31
- package/dist/chunk-5UOVYM3P.cjs.map +1 -0
- package/dist/{chunk-VF7X6HDR.cjs → chunk-5USCYPPI.cjs} +15 -15
- package/dist/{chunk-VF7X6HDR.cjs.map → chunk-5USCYPPI.cjs.map} +1 -1
- package/dist/chunk-6HTXPPHK.cjs +18 -0
- package/dist/chunk-6HTXPPHK.cjs.map +1 -0
- package/dist/{chunk-D24WJWN2.js → chunk-AEOZTXVW.js} +3 -3
- package/dist/{chunk-D24WJWN2.js.map → chunk-AEOZTXVW.js.map} +1 -1
- package/dist/{chunk-DGOG5NXR.js → chunk-AG5JPQIY.js} +3 -3
- package/dist/{chunk-DGOG5NXR.js.map → chunk-AG5JPQIY.js.map} +1 -1
- package/dist/{chunk-BFYGJGC5.js → chunk-AQLGBKNT.js} +3 -3
- package/dist/chunk-AQLGBKNT.js.map +1 -0
- package/dist/{chunk-7W7ZWMLQ.js → chunk-AWO27VRZ.js} +3 -3
- package/dist/chunk-AWO27VRZ.js.map +1 -0
- package/dist/{chunk-VYCKUKPA.cjs → chunk-B2J4ZMZL.cjs} +3 -2
- package/dist/chunk-B2J4ZMZL.cjs.map +1 -0
- package/dist/{chunk-BERBYXFH.js → chunk-BMAZLQQ4.js} +3 -3
- package/dist/{chunk-BERBYXFH.js.map → chunk-BMAZLQQ4.js.map} +1 -1
- package/dist/{chunk-5YKNEMXR.cjs → chunk-BVZW2B5V.cjs} +4 -4
- package/dist/chunk-BVZW2B5V.cjs.map +1 -0
- package/dist/{chunk-MSFLYJDY.js → chunk-CQ2TQ32Y.js} +4 -4
- package/dist/chunk-CQ2TQ32Y.js.map +1 -0
- package/dist/{chunk-C5DEO6OI.cjs → chunk-CQGYNZ3K.cjs} +4 -4
- package/dist/{chunk-C5DEO6OI.cjs.map → chunk-CQGYNZ3K.cjs.map} +1 -1
- package/dist/{chunk-D75S2X6I.cjs → chunk-CTCGWIUD.cjs} +5 -5
- package/dist/{chunk-D75S2X6I.cjs.map → chunk-CTCGWIUD.cjs.map} +1 -1
- package/dist/{chunk-NZL4BNFQ.js → chunk-CV7XMBHP.js} +4 -4
- package/dist/chunk-CV7XMBHP.js.map +1 -0
- package/dist/{chunk-SEL2ZQMT.js → chunk-DAPSQZT4.js} +15 -10
- package/dist/chunk-DAPSQZT4.js.map +1 -0
- package/dist/{chunk-SVO5WPZX.cjs → chunk-DQKERTND.cjs} +11 -11
- package/dist/{chunk-SVO5WPZX.cjs.map → chunk-DQKERTND.cjs.map} +1 -1
- package/dist/{chunk-N5CR3TJZ.js → chunk-DZBSJX6J.js} +4 -4
- package/dist/{chunk-N5CR3TJZ.js.map → chunk-DZBSJX6J.js.map} +1 -1
- package/dist/{chunk-RAHSWE5C.cjs → chunk-EI2Q7SJ5.cjs} +12 -12
- package/dist/chunk-EI2Q7SJ5.cjs.map +1 -0
- package/dist/{chunk-UCFONJBG.js → chunk-EPSICJLZ.js} +2 -2
- package/dist/{chunk-UCFONJBG.js.map → chunk-EPSICJLZ.js.map} +1 -1
- package/dist/{chunk-3X6PM7DU.cjs → chunk-F3YZMOAU.cjs} +8 -8
- package/dist/{chunk-3X6PM7DU.cjs.map → chunk-F3YZMOAU.cjs.map} +1 -1
- package/dist/{chunk-F77UENR6.cjs → chunk-F5WMX4EA.cjs} +586 -398
- package/dist/chunk-F5WMX4EA.cjs.map +1 -0
- package/dist/{chunk-HE4BIAOS.js → chunk-F7AQV62G.js} +5 -4
- package/dist/chunk-F7AQV62G.js.map +1 -0
- package/dist/{chunk-2RW7K6FN.cjs → chunk-GHX4P3V2.cjs} +2 -2
- package/dist/chunk-GHX4P3V2.cjs.map +1 -0
- package/dist/{chunk-B6HOIWQ6.js → chunk-GJ6RK75E.js} +5 -5
- package/dist/chunk-GJ6RK75E.js.map +1 -0
- package/dist/{chunk-FOXKFTVZ.cjs → chunk-GNT35C5U.cjs} +13 -13
- package/dist/chunk-GNT35C5U.cjs.map +1 -0
- package/dist/{chunk-4NAKHID5.js → chunk-GTKFV7O5.js} +2 -2
- package/dist/chunk-GTKFV7O5.js.map +1 -0
- package/dist/{chunk-ELKO4ZLR.cjs → chunk-GWC3HADL.cjs} +4 -4
- package/dist/{chunk-ELKO4ZLR.cjs.map → chunk-GWC3HADL.cjs.map} +1 -1
- package/dist/{chunk-OXNYIMZZ.js → chunk-H73MEMQB.js} +2 -2
- package/dist/chunk-H73MEMQB.js.map +1 -0
- package/dist/{chunk-E7FJOO4G.cjs → chunk-HJBMA5MB.cjs} +11 -11
- package/dist/{chunk-E7FJOO4G.cjs.map → chunk-HJBMA5MB.cjs.map} +1 -1
- package/dist/{chunk-2FYEVT2B.cjs → chunk-HLPSLDGL.cjs} +275 -160
- package/dist/chunk-HLPSLDGL.cjs.map +1 -0
- package/dist/{chunk-VW6M4B3Z.cjs → chunk-HY57ULY2.cjs} +5 -5
- package/dist/{chunk-VW6M4B3Z.cjs.map → chunk-HY57ULY2.cjs.map} +1 -1
- package/dist/{chunk-CAH3G4IS.js → chunk-HY66GLM6.js} +2 -2
- package/dist/chunk-HY66GLM6.js.map +1 -0
- package/dist/{chunk-G3JWXOGY.js → chunk-I5BE5M5L.js} +310 -122
- package/dist/chunk-I5BE5M5L.js.map +1 -0
- package/dist/{chunk-C4H6PB5J.cjs → chunk-I6TGFUCO.cjs} +4 -4
- package/dist/{chunk-C4H6PB5J.cjs.map → chunk-I6TGFUCO.cjs.map} +1 -1
- package/dist/{chunk-U4UJHOSH.js → chunk-IDCKSLYH.js} +3 -3
- package/dist/{chunk-U4UJHOSH.js.map → chunk-IDCKSLYH.js.map} +1 -1
- package/dist/{chunk-WQ53UQL4.cjs → chunk-ILCGLTSA.cjs} +4 -4
- package/dist/{chunk-WQ53UQL4.cjs.map → chunk-ILCGLTSA.cjs.map} +1 -1
- package/dist/{chunk-QBTVATSF.cjs → chunk-ITSSOVOB.cjs} +44 -47
- package/dist/chunk-ITSSOVOB.cjs.map +1 -0
- package/dist/{chunk-V6HWJQQV.js → chunk-IVNNSANC.js} +27 -30
- package/dist/chunk-IVNNSANC.js.map +1 -0
- package/dist/{chunk-SZHU7A5B.cjs → chunk-IWBGCBR6.cjs} +4 -4
- package/dist/{chunk-SZHU7A5B.cjs.map → chunk-IWBGCBR6.cjs.map} +1 -1
- package/dist/{chunk-Q4RESANI.cjs → chunk-J24VJOH3.cjs} +20 -4
- package/dist/chunk-J24VJOH3.cjs.map +1 -0
- package/dist/{chunk-Y4AXQOT4.cjs → chunk-JHPGF3FP.cjs} +8 -8
- package/dist/{chunk-Y4AXQOT4.cjs.map → chunk-JHPGF3FP.cjs.map} +1 -1
- package/dist/{chunk-BM6N4KHO.cjs → chunk-JTB5Q42C.cjs} +6 -22
- package/dist/chunk-JTB5Q42C.cjs.map +1 -0
- package/dist/{chunk-LPVIRJVF.cjs → chunk-K3FW2XZD.cjs} +9 -9
- package/dist/{chunk-LPVIRJVF.cjs.map → chunk-K3FW2XZD.cjs.map} +1 -1
- package/dist/{chunk-LS3LMQ23.js → chunk-MVAPK2BX.js} +162 -49
- package/dist/chunk-MVAPK2BX.js.map +1 -0
- package/dist/{chunk-XPR366DL.cjs → chunk-NGESVVJN.cjs} +17 -17
- package/dist/chunk-NGESVVJN.cjs.map +1 -0
- package/dist/{chunk-VUKQL3L2.cjs → chunk-NIRE5CNO.cjs} +20 -13
- package/dist/chunk-NIRE5CNO.cjs.map +1 -0
- package/dist/{chunk-VC5ABJXC.js → chunk-NLTVXLGT.js} +3 -3
- package/dist/{chunk-VC5ABJXC.js.map → chunk-NLTVXLGT.js.map} +1 -1
- package/dist/chunk-NUKRL3I6.cjs +23 -0
- package/dist/chunk-NUKRL3I6.cjs.map +1 -0
- package/dist/{chunk-R5YZACGK.js → chunk-OC4NTGMN.js} +3 -3
- package/dist/{chunk-R5YZACGK.js.map → chunk-OC4NTGMN.js.map} +1 -1
- package/dist/{chunk-GOVJO4YE.js → chunk-OHBIUXKM.js} +6 -6
- package/dist/chunk-OHBIUXKM.js.map +1 -0
- package/dist/{chunk-FPYT5WZP.cjs → chunk-P6A3M6VD.cjs} +10 -10
- package/dist/{chunk-FPYT5WZP.cjs.map → chunk-P6A3M6VD.cjs.map} +1 -1
- package/dist/{chunk-OKLYRPKL.cjs → chunk-Q47R5E2X.cjs} +8 -8
- package/dist/chunk-Q47R5E2X.cjs.map +1 -0
- package/dist/{chunk-HSQ5Q3I5.js → chunk-Q4CMI2LP.js} +12 -5
- package/dist/chunk-Q4CMI2LP.js.map +1 -0
- package/dist/{chunk-2XLKLVVR.js → chunk-Q5EWJPRY.js} +2 -2
- package/dist/chunk-Q5EWJPRY.js.map +1 -0
- package/dist/{chunk-SK4QLUBK.js → chunk-QARJGQSA.js} +16 -7
- package/dist/chunk-QARJGQSA.js.map +1 -0
- package/dist/{chunk-CZ2GKKYL.cjs → chunk-QDED6YO6.cjs} +5 -5
- package/dist/{chunk-CZ2GKKYL.cjs.map → chunk-QDED6YO6.cjs.map} +1 -1
- package/dist/{chunk-VK7MAV65.cjs → chunk-QKLOP4VC.cjs} +2 -2
- package/dist/{chunk-VK7MAV65.cjs.map → chunk-QKLOP4VC.cjs.map} +1 -1
- package/dist/{chunk-FIOCJYLA.js → chunk-QRSUA2CV.js} +3 -3
- package/dist/{chunk-FIOCJYLA.js.map → chunk-QRSUA2CV.js.map} +1 -1
- package/dist/{chunk-ZT57WTUJ.cjs → chunk-R3UPQFKK.cjs} +21 -12
- package/dist/chunk-R3UPQFKK.cjs.map +1 -0
- package/dist/{chunk-X2FR4OIT.js → chunk-R7WIIPUR.js} +2 -2
- package/dist/chunk-R7WIIPUR.js.map +1 -0
- package/dist/{chunk-RP5HQVLD.js → chunk-RNB4APBZ.js} +30 -7
- package/dist/chunk-RNB4APBZ.js.map +1 -0
- package/dist/{chunk-GD63JPGC.cjs → chunk-ROYPRJH4.cjs} +9 -9
- package/dist/{chunk-GD63JPGC.cjs.map → chunk-ROYPRJH4.cjs.map} +1 -1
- package/dist/{chunk-V26QVGUG.js → chunk-RUDY2GTT.js} +59 -23
- package/dist/chunk-RUDY2GTT.js.map +1 -0
- package/dist/{chunk-JIQRXKTA.cjs → chunk-SKXBJ2NU.cjs} +7 -7
- package/dist/chunk-SKXBJ2NU.cjs.map +1 -0
- package/dist/{chunk-XROIW6BH.js → chunk-SUKXXLWD.js} +6 -6
- package/dist/chunk-SUKXXLWD.js.map +1 -0
- package/dist/{chunk-LTSTGCL6.js → chunk-T73NA43R.js} +3 -3
- package/dist/{chunk-LTSTGCL6.js.map → chunk-T73NA43R.js.map} +1 -1
- package/dist/chunk-T7O6K6PX.js +20 -0
- package/dist/chunk-T7O6K6PX.js.map +1 -0
- package/dist/{chunk-5F5NWKPN.js → chunk-T7XEKOVW.js} +5 -20
- package/dist/chunk-T7XEKOVW.js.map +1 -0
- package/dist/{chunk-HAWE74GQ.cjs → chunk-U2AC6JUP.cjs} +8 -8
- package/dist/chunk-U2AC6JUP.cjs.map +1 -0
- package/dist/{chunk-3WVMJY7F.js → chunk-UC3HT2S4.js} +3 -3
- package/dist/{chunk-3WVMJY7F.js.map → chunk-UC3HT2S4.js.map} +1 -1
- package/dist/{chunk-PBZ7HMBP.js → chunk-UPRJR6IP.js} +4 -4
- package/dist/chunk-UPRJR6IP.js.map +1 -0
- package/dist/{chunk-3V7UJLQT.js → chunk-UQGQFBRL.js} +3 -3
- package/dist/chunk-UQGQFBRL.js.map +1 -0
- package/dist/{chunk-2D43RD5D.cjs → chunk-V2UUGUY4.cjs} +27 -27
- package/dist/chunk-V2UUGUY4.cjs.map +1 -0
- package/dist/{chunk-6AZDM6LK.js → chunk-VF7EWVDG.js} +3 -3
- package/dist/{chunk-6AZDM6LK.js.map → chunk-VF7EWVDG.js.map} +1 -1
- package/dist/{chunk-PNVDQL5Y.cjs → chunk-VTYY7XL5.cjs} +2 -2
- package/dist/chunk-VTYY7XL5.cjs.map +1 -0
- package/dist/{chunk-Y4I4EQFK.js → chunk-WKRSH2VR.js} +3 -3
- package/dist/{chunk-Y4I4EQFK.js.map → chunk-WKRSH2VR.js.map} +1 -1
- package/dist/{chunk-4QEC4CCS.js → chunk-WTMU7J4U.js} +2 -2
- package/dist/{chunk-4QEC4CCS.js.map → chunk-WTMU7J4U.js.map} +1 -1
- package/dist/{chunk-KSWHTR54.js → chunk-XN7NOENA.js} +6 -6
- package/dist/chunk-XN7NOENA.js.map +1 -0
- package/dist/{chunk-ADLLFY3H.cjs → chunk-XSX2UU6Y.cjs} +10 -9
- package/dist/chunk-XSX2UU6Y.cjs.map +1 -0
- package/dist/{chunk-LD4MOBFX.js → chunk-XV4IZNV4.js} +9 -9
- package/dist/chunk-XV4IZNV4.js.map +1 -0
- package/dist/{chunk-EZ2YEF4F.cjs → chunk-XWL6O3SW.cjs} +4 -4
- package/dist/chunk-XWL6O3SW.cjs.map +1 -0
- package/dist/{chunk-PGP7IOJ2.js → chunk-YMA4S2WO.js} +4 -4
- package/dist/{chunk-PGP7IOJ2.js.map → chunk-YMA4S2WO.js.map} +1 -1
- package/dist/{chunk-OUOXM36O.cjs → chunk-YPJ5NH5N.cjs} +11 -11
- package/dist/chunk-YPJ5NH5N.cjs.map +1 -0
- package/dist/{chunk-YLQQX5W2.cjs → chunk-ZF2LDKQQ.cjs} +2 -2
- package/dist/chunk-ZF2LDKQQ.cjs.map +1 -0
- package/dist/{chunk-L5YO6PWL.cjs → chunk-ZNW6V4Y6.cjs} +2 -2
- package/dist/chunk-ZNW6V4Y6.cjs.map +1 -0
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/theokit-client.d.cts +36 -0
- package/dist/client/theokit-client.d.ts +36 -0
- package/dist/client/types.d.cts +30 -0
- package/dist/client/types.d.ts +30 -0
- package/dist/compact-session-FUJDVF7B.js +22 -0
- package/dist/{compact-session-4MNKNMO2.js.map → compact-session-FUJDVF7B.js.map} +1 -1
- package/dist/compact-session-LEWF554G.cjs +59 -0
- package/dist/{compact-session-EPFBQ46Z.cjs.map → compact-session-LEWF554G.cjs.map} +1 -1
- package/dist/compaction.cjs +17 -16
- package/dist/compaction.d.cts +13 -13
- package/dist/compaction.d.ts +13 -13
- package/dist/compaction.js +4 -3
- package/dist/concurrency.cjs +7 -6
- package/dist/concurrency.cjs.map +1 -1
- package/dist/concurrency.js +5 -4
- package/dist/concurrency.js.map +1 -1
- package/dist/context/index.cjs +7 -7
- package/dist/context/index.js +3 -3
- package/dist/context-FDOON2DB.js +6 -0
- package/dist/{context-ENXZNF6J.js.map → context-FDOON2DB.js.map} +1 -1
- package/dist/context-VMIE4BMD.cjs +23 -0
- package/dist/{context-7USNN6LP.cjs.map → context-VMIE4BMD.cjs.map} +1 -1
- package/dist/cron-BcWmzWzT.d.cts +240 -0
- package/dist/cron-De6hzWCF.d.ts +240 -0
- package/dist/cron.cjs +43 -41
- package/dist/cron.d.cts +5 -3
- package/dist/cron.d.ts +5 -3
- package/dist/cron.js +42 -40
- package/dist/define-tool.d.ts +14 -6
- package/dist/{errors-BSoXcl3F.d.cts → errors-BgJH9PHi.d.cts} +39 -24
- package/dist/{errors-CHllybaU.d.ts → errors-C5fJUqLk.d.ts} +39 -24
- package/dist/errors.cjs +22 -21
- package/dist/errors.d.cts +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +3 -2
- package/dist/eval.cjs +61 -58
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.d.cts +38 -0
- package/dist/eval.d.ts +38 -0
- package/dist/eval.js +51 -48
- package/dist/eval.js.map +1 -1
- package/dist/event-bus.d.ts +16 -0
- package/dist/{executor-2Z6XJJJG.js → executor-BMEHFOXZ.js} +8 -7
- package/dist/executor-BMEHFOXZ.js.map +1 -0
- package/dist/{executor-2Z3LGG3I.cjs → executor-ZERJ3DGN.cjs} +25 -24
- package/dist/executor-ZERJ3DGN.cjs.map +1 -0
- package/dist/filesystem/index.cjs +8 -7
- package/dist/filesystem/index.cjs.map +1 -1
- package/dist/filesystem/index.js +4 -3
- package/dist/filesystem/index.js.map +1 -1
- package/dist/filesystem/local-filesystem.d.cts +18 -0
- package/dist/filesystem/local-filesystem.d.ts +18 -0
- package/dist/filesystem/types.d.cts +12 -0
- package/dist/filesystem/types.d.ts +12 -0
- package/dist/fs-session-store-3MOJQGP2.cjs +20 -0
- package/dist/{fs-session-store-VVY2AHWG.cjs.map → fs-session-store-3MOJQGP2.cjs.map} +1 -1
- package/dist/fs-session-store-IN7JTTXD.js +11 -0
- package/dist/{fs-session-store-R5FD3EN6.js.map → fs-session-store-IN7JTTXD.js.map} +1 -1
- package/dist/generate-object-N5MDZUJI.js +8 -0
- package/dist/{generate-object-WQRCXFD2.js.map → generate-object-N5MDZUJI.js.map} +1 -1
- package/dist/generate-object-PGSP5U7N.cjs +21 -0
- package/dist/{generate-object-AVXOJK2I.cjs.map → generate-object-PGSP5U7N.cjs.map} +1 -1
- package/dist/generate-object.d.ts +20 -0
- package/dist/index-manager-NG5YENWO.cjs +22 -0
- package/dist/{index-manager-VRU3A2YL.cjs.map → index-manager-NG5YENWO.cjs.map} +1 -1
- package/dist/index-manager-ZMRJ6ZII.js +13 -0
- package/dist/{index-manager-WS7TVKUW.js.map → index-manager-ZMRJ6ZII.js.map} +1 -1
- package/dist/index.cjs +169 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +702 -54
- package/dist/index.d.ts +702 -54
- package/dist/index.js +61 -58
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-GMBMJVNZ.js → inject-session-BJMJH5BX.js} +9 -8
- package/dist/inject-session-BJMJH5BX.js.map +1 -0
- package/dist/inject-session-WQGGMCQY.cjs +29 -0
- package/dist/inject-session-WQGGMCQY.cjs.map +1 -0
- package/dist/internal/auth/auth-types.d.ts +83 -1
- package/dist/internal/auth/credential-store.d.ts +34 -6
- package/dist/internal/auth/oauth-device.d.ts +0 -1
- package/dist/internal/auth/resolve-credential.d.ts +40 -0
- package/dist/internal/budget/tracker/budget.d.ts +12 -14
- package/dist/internal/budget/usage-accumulator.d.ts +15 -0
- package/dist/internal/llm/anthropic-shared.d.ts +8 -4
- package/dist/internal/llm/model-identifier.d.ts +26 -0
- package/dist/internal/llm/openai.d.ts +8 -0
- package/dist/internal/llm/prompt-cache-key.d.ts +1 -0
- package/dist/internal/llm/responses.d.ts +67 -1
- package/dist/internal/llm/router.d.ts +8 -0
- package/dist/internal/llm/types.d.ts +27 -1
- package/dist/internal/local-agent/real-local-run-provider.d.ts +8 -3
- package/dist/internal/local-agent/real-local-run-tools.d.ts +23 -4
- package/dist/internal/mcp/oauth.d.ts +5 -0
- package/dist/internal/mcp/token-storage.d.ts +34 -0
- package/dist/internal/memory/adapters/index.cjs +12 -11
- package/dist/internal/memory/adapters/index.d.cts +3 -1
- package/dist/internal/memory/adapters/index.d.ts +3 -1
- package/dist/internal/memory/adapters/index.js +9 -8
- package/dist/internal/memory/adapters/openai-compatible.d.cts +45 -0
- package/dist/internal/memory/adapters/openai-compatible.d.ts +45 -0
- package/dist/internal/memory/embedding-cache.d.ts +42 -1
- package/dist/internal/memory/escape-like-pattern.d.ts +22 -0
- package/dist/internal/memory/sqlite-vec-loader.d.ts +1 -3
- package/dist/internal/memory/storage/markdown-store.d.ts +0 -5
- package/dist/internal/persistence/cwd-mutex.d.cts +34 -0
- package/dist/internal/persistence/cwd-mutex.d.ts +34 -0
- package/dist/internal/persistence/exclusive-create.d.cts +31 -0
- package/dist/internal/persistence/exclusive-create.d.ts +31 -0
- package/dist/internal/persistence/file-lock.d.cts +28 -0
- package/dist/internal/persistence/file-lock.d.ts +28 -0
- package/dist/internal/persistence/fs-session-store.d.cts +3 -0
- package/dist/internal/persistence/fs-session-store.d.ts +3 -0
- package/dist/internal/persistence/fts5-sanitize.d.cts +20 -0
- package/dist/internal/persistence/fts5-sanitize.d.ts +20 -0
- package/dist/internal/persistence/index.cjs +40 -39
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.d.cts +6 -1
- package/dist/internal/persistence/index.d.ts +6 -1
- package/dist/internal/persistence/index.js +9 -8
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/persistence/paths.d.cts +54 -1
- package/dist/internal/persistence/paths.d.ts +54 -1
- package/dist/internal/persistence/persistence-schema.d.cts +9 -1
- package/dist/internal/persistence/persistence-schema.d.ts +9 -1
- package/dist/internal/persistence/schema-version.d.cts +215 -1
- package/dist/internal/persistence/schema-version.d.ts +215 -1
- package/dist/internal/persistence/session-writer.d.cts +7 -7
- package/dist/internal/persistence/session-writer.d.ts +7 -7
- package/dist/internal/persistence/sqlite-cas.d.cts +37 -1
- package/dist/internal/persistence/sqlite-cas.d.ts +37 -1
- package/dist/internal/persistence/sqlite-open.d.cts +14 -0
- package/dist/internal/persistence/sqlite-open.d.ts +14 -0
- package/dist/internal/persistence/sqlite-wal.d.cts +45 -0
- package/dist/internal/persistence/sqlite-wal.d.ts +45 -0
- package/dist/internal/persistence/transcript-ops.d.cts +7 -1
- package/dist/internal/persistence/transcript-ops.d.ts +7 -1
- package/dist/internal/plugins/types.d.cts +1 -1
- package/dist/internal/plugins/types.d.ts +1 -1
- package/dist/internal/providers/builtin/openai-chatgpt.d.ts +12 -0
- package/dist/internal/providers/catalog-loader.d.ts +8 -0
- package/dist/internal/providers/catalog-schema.d.ts +55 -0
- package/dist/internal/providers/catalog-source-models-dev.d.ts +36 -0
- package/dist/internal/runtime/concurrency/delegation-depth.d.ts +27 -0
- package/dist/internal/runtime/concurrency/subagent-credentials.d.ts +33 -1
- package/dist/internal/runtime/context/context-discovery-runner.d.ts +44 -0
- package/dist/internal/runtime/context/context-discovery.d.ts +58 -0
- package/dist/internal/runtime/context/context-rules-frontmatter.d.ts +70 -1
- package/dist/internal/runtime/fixtures/fixture-mode.d.ts +15 -1
- package/dist/internal/runtime/lifecycle/post-run-lifecycle.d.ts +15 -0
- package/dist/internal/runtime/registry/agent-registry-store.d.ts +12 -0
- package/dist/internal/runtime/registry/live-agent-registry.d.ts +37 -0
- package/dist/internal/scorers/llm-judge.d.ts +6 -1
- package/dist/internal/security/index.cjs +14 -13
- package/dist/internal/security/index.d.cts +4 -1
- package/dist/internal/security/index.d.ts +4 -1
- package/dist/internal/security/index.js +4 -3
- package/dist/internal/security/path-guard.d.cts +46 -0
- package/dist/internal/security/path-guard.d.ts +46 -0
- package/dist/internal/security/redact.d.cts +71 -0
- package/dist/internal/security/redact.d.ts +71 -0
- package/dist/internal/session/agent-session.d.ts +15 -4
- package/dist/internal/session/session-cache.d.ts +5 -0
- package/dist/internal/task/store.d.ts +91 -5
- package/dist/internal/telemetry/span-names.d.ts +0 -1
- package/dist/internal/telemetry/tracer.d.ts +14 -0
- package/dist/job-queue.d.ts +18 -0
- package/dist/judge-call-DWHAJATE.js +6 -0
- package/dist/{judge-call-MDIPTBJI.js.map → judge-call-DWHAJATE.js.map} +1 -1
- package/dist/judge-call-EGYRC2RE.cjs +23 -0
- package/dist/{judge-call-G5SGV2M2.cjs.map → judge-call-EGYRC2RE.cjs.map} +1 -1
- package/dist/mcp-auth.cjs +41 -25
- package/dist/mcp-auth.cjs.map +1 -1
- package/dist/mcp-auth.js +34 -18
- package/dist/mcp-auth.js.map +1 -1
- package/dist/models.cjs +42 -27
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +25 -10
- package/dist/models.js.map +1 -1
- package/dist/oauth-transaction-store-BT4GLTLK.cjs +36 -0
- package/dist/{oauth-transaction-store-7CKHPQRN.cjs.map → oauth-transaction-store-BT4GLTLK.cjs.map} +1 -1
- package/dist/oauth-transaction-store-W52KVHQ4.js +3 -0
- package/dist/{oauth-transaction-store-W74I6EFD.js.map → oauth-transaction-store-W52KVHQ4.js.map} +1 -1
- package/dist/path-safety.cjs +11 -10
- package/dist/path-safety.js +4 -3
- package/dist/permission-engine.d.ts +55 -0
- package/dist/persistence.cjs +43 -42
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +13 -12
- package/dist/persistence.js.map +1 -1
- package/dist/project.cjs +9 -8
- package/dist/project.cjs.map +1 -1
- package/dist/project.js +5 -4
- package/dist/project.js.map +1 -1
- package/dist/providers.cjs +23 -0
- package/dist/providers.cjs.map +1 -0
- package/dist/providers.d.cts +29 -0
- package/dist/providers.d.ts +29 -0
- package/dist/providers.js +10 -0
- package/dist/providers.js.map +1 -0
- package/dist/registry-VFKX7WOP.cjs +47 -0
- package/dist/{registry-63ASMXT4.cjs.map → registry-VFKX7WOP.cjs.map} +1 -1
- package/dist/registry-VFP3WWQP.js +10 -0
- package/dist/{registry-O7FJ2MPM.js.map → registry-VFP3WWQP.js.map} +1 -1
- package/dist/retry.cjs +5 -4
- package/dist/retry.js +4 -3
- package/dist/{run-C8FBAC8o.d.cts → run-BYSHf58D.d.cts} +185 -33
- package/dist/{run-C8FBAC8o.d.ts → run-BYSHf58D.d.ts} +185 -33
- package/dist/{run-to-completion-JDPIUKSH.js → run-to-completion-DRO77625.js} +3 -3
- package/dist/{run-to-completion-JDPIUKSH.js.map → run-to-completion-DRO77625.js.map} +1 -1
- package/dist/{run-to-completion-J73I6IY4.cjs → run-to-completion-X4OWM673.cjs} +13 -13
- package/dist/{run-to-completion-J73I6IY4.cjs.map → run-to-completion-X4OWM673.cjs.map} +1 -1
- package/dist/sandbox/bwrap.d.cts +27 -13
- package/dist/sandbox/bwrap.d.ts +27 -13
- package/dist/sandbox/index.cjs +20 -19
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.js +5 -4
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/linux-sandbox.d.cts +72 -0
- package/dist/sandbox/linux-sandbox.d.ts +72 -0
- package/dist/sandbox/local-sandbox.d.cts +41 -0
- package/dist/sandbox/local-sandbox.d.ts +41 -0
- package/dist/sandbox/seccomp.d.cts +6 -0
- package/dist/sandbox/seccomp.d.ts +6 -0
- package/dist/sandbox/types.d.cts +64 -0
- package/dist/sandbox/types.d.ts +64 -0
- package/dist/scorers.d.ts +38 -7
- package/dist/sdk-agent-D8qJVkuV.d.ts +860 -0
- package/dist/sdk-agent-DEoKhA8a.d.cts +860 -0
- package/dist/server/auth/errors.d.cts +1 -1
- package/dist/server/auth/errors.d.ts +1 -1
- package/dist/server/auth/index.cjs +29 -21
- package/dist/server/auth/index.cjs.map +1 -1
- package/dist/server/auth/index.d.cts +25 -15
- package/dist/server/auth/index.d.ts +25 -15
- package/dist/server/auth/index.js +15 -7
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/oauth-transaction-store.d.cts +13 -1
- package/dist/server/auth/oauth-transaction-store.d.ts +13 -1
- package/dist/server/auth/orchestrator.d.cts +1 -1
- package/dist/server/auth/orchestrator.d.ts +1 -1
- package/dist/server/auth/types.d.cts +1 -1
- package/dist/server/auth/types.d.ts +1 -1
- package/dist/server/auth/validate-return-to.d.cts +21 -11
- package/dist/server/auth/validate-return-to.d.ts +21 -11
- package/dist/server/errors-envelope.cjs +15 -14
- package/dist/server/errors-envelope.cjs.map +1 -1
- package/dist/server/errors-envelope.d.cts +4 -4
- package/dist/server/errors-envelope.d.ts +4 -4
- package/dist/server/errors-envelope.js +4 -3
- package/dist/server/errors-envelope.js.map +1 -1
- package/dist/session-transcript-AKDYYGXQ.js +6 -0
- package/dist/{session-transcript-RAKEK76V.js.map → session-transcript-AKDYYGXQ.js.map} +1 -1
- package/dist/session-transcript-JXHFTB7G.cjs +51 -0
- package/dist/{session-transcript-DOM3UTXR.cjs.map → session-transcript-JXHFTB7G.cjs.map} +1 -1
- package/dist/skills.cjs +8 -7
- package/dist/skills.js +6 -5
- package/dist/stream-object-BUCF5PHO.cjs +21 -0
- package/dist/{stream-object-L3Q7PBMF.cjs.map → stream-object-BUCF5PHO.cjs.map} +1 -1
- package/dist/stream-object-L57K4OFS.js +8 -0
- package/dist/{stream-object-ZYXWS4B2.js.map → stream-object-L57K4OFS.js.map} +1 -1
- package/dist/{stream-to-completion-DFJ5T3BK.js → stream-to-completion-QV5HCL3J.js} +3 -3
- package/dist/{stream-to-completion-DFJ5T3BK.js.map → stream-to-completion-QV5HCL3J.js.map} +1 -1
- package/dist/{stream-to-completion-H2MHISSK.cjs → stream-to-completion-SRISU5AB.cjs} +10 -10
- package/dist/{stream-to-completion-H2MHISSK.cjs.map → stream-to-completion-SRISU5AB.cjs.map} +1 -1
- package/dist/subagents-loader-AZIXJ7D3.cjs +16 -0
- package/dist/{subagents-loader-VRW73QQT.cjs.map → subagents-loader-AZIXJ7D3.cjs.map} +1 -1
- package/dist/subagents-loader-J54ESLDV.js +7 -0
- package/dist/{subagents-loader-I56GSKAQ.js.map → subagents-loader-J54ESLDV.js.map} +1 -1
- package/dist/subagents-loader.cjs +7 -6
- package/dist/subagents-loader.cjs.map +1 -1
- package/dist/subagents-loader.d.cts +3 -2
- package/dist/subagents-loader.d.ts +3 -2
- package/dist/subagents-loader.js +5 -4
- package/dist/subagents-loader.js.map +1 -1
- package/dist/subscription/define-subscription.d.cts +1 -1
- package/dist/subscription/define-subscription.d.ts +1 -1
- package/dist/subscription/index.cjs +22 -9
- package/dist/subscription/index.cjs.map +1 -1
- package/dist/subscription/index.d.cts +1 -1
- package/dist/subscription/index.d.ts +1 -1
- package/dist/subscription/index.js +21 -8
- package/dist/subscription/index.js.map +1 -1
- package/dist/subscription/internal/adapter-types.d.cts +1 -1
- package/dist/subscription/internal/adapter-types.d.ts +1 -1
- package/dist/subscription/internal/server-integration.d.cts +1 -1
- package/dist/subscription/internal/server-integration.d.ts +1 -1
- package/dist/subscription/internal/sse-encoder.d.cts +1 -1
- package/dist/subscription/internal/sse-encoder.d.ts +1 -1
- package/dist/subscription/internal/sse-parser.d.cts +1 -1
- package/dist/subscription/internal/sse-parser.d.ts +1 -1
- package/dist/subscription/internal/subscription-runtime.d.cts +1 -1
- package/dist/subscription/internal/subscription-runtime.d.ts +1 -1
- package/dist/subscription/internal/ws-adapter-node.d.cts +1 -1
- package/dist/subscription/internal/ws-adapter-node.d.ts +1 -1
- package/dist/subscription/theokit-subscribe.d.cts +14 -1
- package/dist/subscription/theokit-subscribe.d.ts +14 -1
- package/dist/subscription/types.d.cts +19 -1
- package/dist/subscription/types.d.ts +19 -1
- package/dist/task-store.cjs +8 -7
- package/dist/task-store.js +5 -4
- package/dist/types/agent-prims.d.ts +14 -0
- package/dist/types/agent.d.ts +92 -11
- package/dist/types/batch.d.ts +7 -1
- package/dist/types/conversation.d.ts +18 -5
- package/dist/types/goal-events.d.ts +4 -8
- package/dist/types/memory-adapter.d.ts +12 -1
- package/dist/types/plugin.d.ts +101 -0
- package/dist/types/provider-profile.d.ts +32 -0
- package/dist/types/run-events.d.ts +28 -1
- package/dist/types/run.d.ts +35 -23
- package/dist/types/sdk-agent.d.ts +14 -0
- package/dist/types/session-record.d.ts +18 -1
- package/dist/types/task.d.ts +15 -1
- package/dist/types/theokit.d.ts +10 -1
- package/dist/types/updates.d.ts +35 -4
- package/dist/types/workflow.d.ts +155 -0
- package/dist/workflow.cjs +29 -28
- package/dist/workflow.d.cts +666 -17
- package/dist/workflow.d.ts +666 -17
- package/dist/workflow.js +8 -7
- package/docs/error-codes.md +215 -0
- package/docs/harness-capability-map.md +1358 -0
- package/package.json +29 -16
- package/bin/init-claude.mjs +0 -68
- package/claude-template/AGENTS.md +0 -157
- package/claude-template/CLAUDE.md +0 -66
- package/claude-template/dot-claude/rules/theokit-conventions.md +0 -32
- package/claude-template/dot-claude/settings.json +0 -16
- package/claude-template/dot-claude/skills/theokit-agent-core/SKILL.md +0 -209
- package/claude-template/dot-claude/skills/theokit-auth/SKILL.md +0 -102
- package/claude-template/dot-claude/skills/theokit-budget/SKILL.md +0 -176
- package/claude-template/dot-claude/skills/theokit-client/SKILL.md +0 -58
- package/claude-template/dot-claude/skills/theokit-compaction/SKILL.md +0 -102
- package/claude-template/dot-claude/skills/theokit-concurrency/SKILL.md +0 -68
- package/claude-template/dot-claude/skills/theokit-config/SKILL.md +0 -139
- package/claude-template/dot-claude/skills/theokit-cron/SKILL.md +0 -148
- package/claude-template/dot-claude/skills/theokit-di/SKILL.md +0 -233
- package/claude-template/dot-claude/skills/theokit-di-agent/SKILL.md +0 -294
- package/claude-template/dot-claude/skills/theokit-errors/SKILL.md +0 -172
- package/claude-template/dot-claude/skills/theokit-eval/SKILL.md +0 -179
- package/claude-template/dot-claude/skills/theokit-filesystem/SKILL.md +0 -74
- package/claude-template/dot-claude/skills/theokit-gateways/SKILL.md +0 -209
- package/claude-template/dot-claude/skills/theokit-memory/SKILL.md +0 -176
- package/claude-template/dot-claude/skills/theokit-messages/SKILL.md +0 -58
- package/claude-template/dot-claude/skills/theokit-models/SKILL.md +0 -79
- package/claude-template/dot-claude/skills/theokit-path-safety/SKILL.md +0 -60
- package/claude-template/dot-claude/skills/theokit-persistence/SKILL.md +0 -85
- package/claude-template/dot-claude/skills/theokit-project/SKILL.md +0 -55
- package/claude-template/dot-claude/skills/theokit-retry/SKILL.md +0 -50
- package/claude-template/dot-claude/skills/theokit-sandbox/SKILL.md +0 -93
- package/claude-template/dot-claude/skills/theokit-sanitize/SKILL.md +0 -66
- package/claude-template/dot-claude/skills/theokit-skills/SKILL.md +0 -68
- package/claude-template/dot-claude/skills/theokit-streaming/SKILL.md +0 -156
- package/claude-template/dot-claude/skills/theokit-subagents/SKILL.md +0 -109
- package/claude-template/dot-claude/skills/theokit-subscriptions/SKILL.md +0 -148
- package/claude-template/dot-claude/skills/theokit-task-store/SKILL.md +0 -75
- package/claude-template/dot-claude/skills/theokit-tools/SKILL.md +0 -170
- package/claude-template/dot-claude/skills/theokit-workflows/SKILL.md +0 -218
- package/dist/agent-FFVV4U5N.js +0 -50
- package/dist/agent-YLAHVHEH.cjs +0 -59
- package/dist/agent-session-store-DUGBAX5V.cjs +0 -23
- package/dist/agent-session-store-TNCGL5RN.js +0 -6
- package/dist/batch-UPKN4SG6.js.map +0 -1
- package/dist/batch-ZEFN5SO7.cjs.map +0 -1
- package/dist/chunk-2D43RD5D.cjs.map +0 -1
- package/dist/chunk-2FYEVT2B.cjs.map +0 -1
- package/dist/chunk-2RW7K6FN.cjs.map +0 -1
- package/dist/chunk-2XLKLVVR.js.map +0 -1
- package/dist/chunk-34XOCZJO.js.map +0 -1
- package/dist/chunk-3V7UJLQT.js.map +0 -1
- package/dist/chunk-4NAKHID5.js.map +0 -1
- package/dist/chunk-4Q4K4WB5.js.map +0 -1
- package/dist/chunk-5F5NWKPN.js.map +0 -1
- package/dist/chunk-5NBUH3NO.js.map +0 -1
- package/dist/chunk-5YKNEMXR.cjs.map +0 -1
- package/dist/chunk-7W7ZWMLQ.js.map +0 -1
- package/dist/chunk-ADLLFY3H.cjs.map +0 -1
- package/dist/chunk-B4YA6BRS.cjs.map +0 -1
- package/dist/chunk-B6HOIWQ6.js.map +0 -1
- package/dist/chunk-BDTVFIPB.cjs.map +0 -1
- package/dist/chunk-BFYGJGC5.js.map +0 -1
- package/dist/chunk-BM6N4KHO.cjs.map +0 -1
- package/dist/chunk-CAH3G4IS.js.map +0 -1
- package/dist/chunk-EZ2YEF4F.cjs.map +0 -1
- package/dist/chunk-F77UENR6.cjs.map +0 -1
- package/dist/chunk-FOXKFTVZ.cjs.map +0 -1
- package/dist/chunk-G3JWXOGY.js.map +0 -1
- package/dist/chunk-GOVJO4YE.js.map +0 -1
- package/dist/chunk-HAWE74GQ.cjs.map +0 -1
- package/dist/chunk-HE4BIAOS.js.map +0 -1
- package/dist/chunk-HSQ5Q3I5.js.map +0 -1
- package/dist/chunk-JIQRXKTA.cjs.map +0 -1
- package/dist/chunk-KSWHTR54.js.map +0 -1
- package/dist/chunk-L5YO6PWL.cjs.map +0 -1
- package/dist/chunk-LD4MOBFX.js.map +0 -1
- package/dist/chunk-LS3LMQ23.js.map +0 -1
- package/dist/chunk-MSFLYJDY.js.map +0 -1
- package/dist/chunk-NZL4BNFQ.js.map +0 -1
- package/dist/chunk-OKLYRPKL.cjs.map +0 -1
- package/dist/chunk-OUOXM36O.cjs.map +0 -1
- package/dist/chunk-OXNYIMZZ.js.map +0 -1
- package/dist/chunk-PBZ7HMBP.js.map +0 -1
- package/dist/chunk-PNVDQL5Y.cjs.map +0 -1
- package/dist/chunk-Q4RESANI.cjs.map +0 -1
- package/dist/chunk-QBTVATSF.cjs.map +0 -1
- package/dist/chunk-RAHSWE5C.cjs.map +0 -1
- package/dist/chunk-RP5HQVLD.js.map +0 -1
- package/dist/chunk-SEL2ZQMT.js.map +0 -1
- package/dist/chunk-SK4QLUBK.js.map +0 -1
- package/dist/chunk-TTJ54H3E.cjs.map +0 -1
- package/dist/chunk-V26QVGUG.js.map +0 -1
- package/dist/chunk-V6HWJQQV.js.map +0 -1
- package/dist/chunk-VGPXHHF3.cjs.map +0 -1
- package/dist/chunk-VUKQL3L2.cjs.map +0 -1
- package/dist/chunk-VYCKUKPA.cjs.map +0 -1
- package/dist/chunk-VYHJZVL5.cjs.map +0 -1
- package/dist/chunk-X2FR4OIT.js.map +0 -1
- package/dist/chunk-XPR366DL.cjs.map +0 -1
- package/dist/chunk-XROIW6BH.js.map +0 -1
- package/dist/chunk-YLQQX5W2.cjs.map +0 -1
- package/dist/chunk-ZT57WTUJ.cjs.map +0 -1
- package/dist/compact-session-4MNKNMO2.js +0 -21
- package/dist/compact-session-EPFBQ46Z.cjs +0 -58
- package/dist/context-7USNN6LP.cjs +0 -22
- package/dist/context-ENXZNF6J.js +0 -5
- package/dist/cron-BMjgFH-_.d.ts +0 -631
- package/dist/cron-DFDdCdMM.d.cts +0 -631
- package/dist/executor-2Z3LGG3I.cjs.map +0 -1
- package/dist/executor-2Z6XJJJG.js.map +0 -1
- package/dist/fs-session-store-R5FD3EN6.js +0 -10
- package/dist/fs-session-store-VVY2AHWG.cjs +0 -19
- package/dist/generate-object-AVXOJK2I.cjs +0 -20
- package/dist/generate-object-WQRCXFD2.js +0 -7
- package/dist/index-manager-VRU3A2YL.cjs +0 -21
- package/dist/index-manager-WS7TVKUW.js +0 -12
- package/dist/inject-session-AUQLBDRS.cjs +0 -28
- package/dist/inject-session-AUQLBDRS.cjs.map +0 -1
- package/dist/inject-session-GMBMJVNZ.js.map +0 -1
- package/dist/judge-call-G5SGV2M2.cjs +0 -22
- package/dist/judge-call-MDIPTBJI.js +0 -5
- package/dist/oauth-transaction-store-7CKHPQRN.cjs +0 -32
- package/dist/oauth-transaction-store-W74I6EFD.js +0 -3
- package/dist/registry-63ASMXT4.cjs +0 -46
- package/dist/registry-O7FJ2MPM.js +0 -9
- package/dist/session-transcript-DOM3UTXR.cjs +0 -50
- package/dist/session-transcript-RAKEK76V.js +0 -5
- package/dist/stream-object-L3Q7PBMF.cjs +0 -20
- package/dist/stream-object-ZYXWS4B2.js +0 -7
- package/dist/subagents-loader-I56GSKAQ.js +0 -6
- package/dist/subagents-loader-VRW73QQT.cjs +0 -15
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkV2UUGUY4_cjs = require('./chunk-V2UUGUY4.cjs');
|
|
4
|
+
var chunk5UOVYM3P_cjs = require('./chunk-5UOVYM3P.cjs');
|
|
5
|
+
var chunk53CBTBWO_cjs = require('./chunk-53CBTBWO.cjs');
|
|
5
6
|
var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
7
|
+
var chunkNGESVVJN_cjs = require('./chunk-NGESVVJN.cjs');
|
|
8
|
+
var chunkEI2Q7SJ5_cjs = require('./chunk-EI2Q7SJ5.cjs');
|
|
9
|
+
var chunkYPJ5NH5N_cjs = require('./chunk-YPJ5NH5N.cjs');
|
|
10
|
+
var chunkHLPSLDGL_cjs = require('./chunk-HLPSLDGL.cjs');
|
|
10
11
|
var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var chunkQ47R5E2X_cjs = require('./chunk-Q47R5E2X.cjs');
|
|
13
|
+
var chunkU2AC6JUP_cjs = require('./chunk-U2AC6JUP.cjs');
|
|
14
|
+
var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
|
|
14
15
|
var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
|
|
15
|
-
var
|
|
16
|
+
var chunk4O5TGQBW_cjs = require('./chunk-4O5TGQBW.cjs');
|
|
16
17
|
var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
|
|
18
|
+
var chunk3YJNUKYN_cjs = require('./chunk-3YJNUKYN.cjs');
|
|
17
19
|
var chunkVJ26EKGJ_cjs = require('./chunk-VJ26EKGJ.cjs');
|
|
18
|
-
var
|
|
19
|
-
var chunkY4AXQOT4_cjs = require('./chunk-Y4AXQOT4.cjs');
|
|
20
|
-
var chunkTTJ54H3E_cjs = require('./chunk-TTJ54H3E.cjs');
|
|
21
|
-
var chunkYLQQX5W2_cjs = require('./chunk-YLQQX5W2.cjs');
|
|
22
|
-
var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
|
|
23
|
-
var chunkC4H6PB5J_cjs = require('./chunk-C4H6PB5J.cjs');
|
|
24
|
-
var chunkE7FJOO4G_cjs = require('./chunk-E7FJOO4G.cjs');
|
|
25
|
-
var chunkADLLFY3H_cjs = require('./chunk-ADLLFY3H.cjs');
|
|
26
|
-
var chunkVYHJZVL5_cjs = require('./chunk-VYHJZVL5.cjs');
|
|
27
|
-
var chunkVUKQL3L2_cjs = require('./chunk-VUKQL3L2.cjs');
|
|
28
|
-
var chunkZN2DGEY3_cjs = require('./chunk-ZN2DGEY3.cjs');
|
|
29
|
-
var chunkZT57WTUJ_cjs = require('./chunk-ZT57WTUJ.cjs');
|
|
20
|
+
var chunkR3UPQFKK_cjs = require('./chunk-R3UPQFKK.cjs');
|
|
30
21
|
var chunkVKJ7V7EB_cjs = require('./chunk-VKJ7V7EB.cjs');
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
22
|
+
var chunkILCGLTSA_cjs = require('./chunk-ILCGLTSA.cjs');
|
|
23
|
+
var chunkJHPGF3FP_cjs = require('./chunk-JHPGF3FP.cjs');
|
|
24
|
+
var chunk2ADR2GSO_cjs = require('./chunk-2ADR2GSO.cjs');
|
|
25
|
+
var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
|
|
26
|
+
var chunkI6TGFUCO_cjs = require('./chunk-I6TGFUCO.cjs');
|
|
27
|
+
var chunkHJBMA5MB_cjs = require('./chunk-HJBMA5MB.cjs');
|
|
28
|
+
var chunkIWBGCBR6_cjs = require('./chunk-IWBGCBR6.cjs');
|
|
29
|
+
var chunkXSX2UU6Y_cjs = require('./chunk-XSX2UU6Y.cjs');
|
|
30
|
+
var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
|
|
31
|
+
var chunk6HTXPPHK_cjs = require('./chunk-6HTXPPHK.cjs');
|
|
32
|
+
var chunkNIRE5CNO_cjs = require('./chunk-NIRE5CNO.cjs');
|
|
33
|
+
var chunkK3FW2XZD_cjs = require('./chunk-K3FW2XZD.cjs');
|
|
34
|
+
var chunkJTB5Q42C_cjs = require('./chunk-JTB5Q42C.cjs');
|
|
35
|
+
var chunkNUKRL3I6_cjs = require('./chunk-NUKRL3I6.cjs');
|
|
34
36
|
var promises = require('fs/promises');
|
|
35
37
|
var crypto = require('crypto');
|
|
36
38
|
var path = require('path');
|
|
@@ -226,7 +228,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
|
|
|
226
228
|
const { output, maxRetries, errorStrategy, ...sendOptions } = options;
|
|
227
229
|
const run = await agent.send(input, sendOptions);
|
|
228
230
|
const result = await run.wait();
|
|
229
|
-
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-
|
|
231
|
+
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-PGSP5U7N.cjs');
|
|
230
232
|
const answer = structurableAnswerOrThrow(result, GenerateObjectError);
|
|
231
233
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
232
234
|
const facade = getAgentFacade();
|
|
@@ -315,7 +317,7 @@ function normalizeModel(m) {
|
|
|
315
317
|
if (m === void 0 || typeof m !== "string") return m;
|
|
316
318
|
const id = m.trim();
|
|
317
319
|
if (id.length === 0) {
|
|
318
|
-
throw new
|
|
320
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
319
321
|
'model must be a non-empty "provider/model" id string or a ModelSelection object',
|
|
320
322
|
{ code: "invalid_model_selection" }
|
|
321
323
|
);
|
|
@@ -451,7 +453,7 @@ function registryPath(cwd) {
|
|
|
451
453
|
return path.join(cwd, REGISTRY_RELATIVE_PATH);
|
|
452
454
|
}
|
|
453
455
|
async function loadRegistry(cwd) {
|
|
454
|
-
return
|
|
456
|
+
return chunkU2AC6JUP_cjs.readVersionedJson({
|
|
455
457
|
path: registryPath(cwd),
|
|
456
458
|
currentVersion: SCHEMA_VERSION,
|
|
457
459
|
defaultValue: () => ({}),
|
|
@@ -474,8 +476,8 @@ async function saveRegistry(cwd, agents2) {
|
|
|
474
476
|
serialized[id] = toSerialized(agent);
|
|
475
477
|
}
|
|
476
478
|
const path = registryPath(cwd);
|
|
477
|
-
await
|
|
478
|
-
await
|
|
479
|
+
await chunkZF2LDKQQ_cjs.withCwdMutex(`registry:${cwd}`, async () => {
|
|
480
|
+
await chunkU2AC6JUP_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
|
|
479
481
|
});
|
|
480
482
|
}
|
|
481
483
|
function toSerialized(agent) {
|
|
@@ -542,7 +544,7 @@ function scheduleSaveForCwd(cwd) {
|
|
|
542
544
|
}
|
|
543
545
|
} catch (cause) {
|
|
544
546
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
545
|
-
|
|
547
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] registry persist failed (${cwd}): ${msg}
|
|
546
548
|
`);
|
|
547
549
|
} finally {
|
|
548
550
|
pendingSaves.delete(cwd);
|
|
@@ -558,10 +560,11 @@ function registerAgent(agent) {
|
|
|
558
560
|
function getRegisteredAgent(agentId) {
|
|
559
561
|
return agents.get(agentId);
|
|
560
562
|
}
|
|
561
|
-
function listRegisteredAgents(runtime, cwd) {
|
|
563
|
+
function listRegisteredAgents(runtime, cwd, includeArchived = false) {
|
|
562
564
|
let out = Array.from(agents.values());
|
|
563
565
|
if (runtime !== void 0) out = out.filter((agent) => agent.runtime === runtime);
|
|
564
566
|
if (cwd !== void 0) out = out.filter((agent) => resolveRegistryCwd(agent) === cwd);
|
|
567
|
+
if (!includeArchived) out = out.filter((agent) => !agent.archived);
|
|
565
568
|
return out;
|
|
566
569
|
}
|
|
567
570
|
function updateRegisteredAgent(agentId, update) {
|
|
@@ -881,14 +884,14 @@ async function readLegacyFacts(jsonPath) {
|
|
|
881
884
|
}
|
|
882
885
|
async function writeMigratedFacts(cwd, jsonPath, facts) {
|
|
883
886
|
try {
|
|
884
|
-
for (const fact of facts) await
|
|
887
|
+
for (const fact of facts) await chunk5UOVYM3P_cjs.appendFactToMarkdown(cwd, fact);
|
|
885
888
|
await promises.unlink(jsonPath).catch(() => void 0);
|
|
886
|
-
|
|
889
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
|
|
887
890
|
`);
|
|
888
891
|
return { migrated: true, factCount: facts.length };
|
|
889
892
|
} catch (cause) {
|
|
890
893
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
891
|
-
|
|
894
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] memory migration failed (readonly fs?): ${message}
|
|
892
895
|
`);
|
|
893
896
|
return { migrated: false, factCount: 0, reason: "readonly-fs" };
|
|
894
897
|
}
|
|
@@ -898,12 +901,12 @@ async function migrateLegacyJson(cwd, config) {
|
|
|
898
901
|
const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
|
|
899
902
|
if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
|
|
900
903
|
migrationRun.add(key);
|
|
901
|
-
const jsonPath =
|
|
904
|
+
const jsonPath = chunk5UOVYM3P_cjs.legacyMemoryJsonPath(cwd, config);
|
|
902
905
|
if (!await fileExists(jsonPath)) {
|
|
903
906
|
return { migrated: false, factCount: 0, reason: "no-legacy-json" };
|
|
904
907
|
}
|
|
905
|
-
if (await fileExists(
|
|
906
|
-
|
|
908
|
+
if (await fileExists(chunk5UOVYM3P_cjs.memoryMdPath(cwd))) {
|
|
909
|
+
chunkNUKRL3I6_cjs.diag(
|
|
907
910
|
`[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
|
|
908
911
|
`
|
|
909
912
|
);
|
|
@@ -927,13 +930,13 @@ function extractMemoryFact(message) {
|
|
|
927
930
|
async function readMemoryFacts(cwd, config) {
|
|
928
931
|
if (!config.enabled) return [];
|
|
929
932
|
await migrateLegacyJson(cwd, config);
|
|
930
|
-
return
|
|
933
|
+
return chunk5UOVYM3P_cjs.readFacts(cwd, config);
|
|
931
934
|
}
|
|
932
935
|
async function appendMemoryFact(cwd, config, fact) {
|
|
933
936
|
if (!config.enabled) return;
|
|
934
937
|
await migrateLegacyJson(cwd, config);
|
|
935
|
-
const sanitized = { text:
|
|
936
|
-
await
|
|
938
|
+
const sanitized = { text: chunkJTB5Q42C_cjs.redactSecrets(fact.text) };
|
|
939
|
+
await chunk5UOVYM3P_cjs.appendFact(cwd, config, sanitized);
|
|
937
940
|
}
|
|
938
941
|
|
|
939
942
|
// src/internal/runtime/fixtures/fixture-scripts.ts
|
|
@@ -1281,7 +1284,7 @@ function redactScriptSecrets(script) {
|
|
|
1281
1284
|
function redactEventSecrets(event) {
|
|
1282
1285
|
const serialized = JSON.stringify(event);
|
|
1283
1286
|
const localStripped = serialized.replace(FIXTURE_SENTINEL, "***");
|
|
1284
|
-
const redacted =
|
|
1287
|
+
const redacted = chunkJTB5Q42C_cjs.redactSecrets(localStripped);
|
|
1285
1288
|
if (redacted === serialized) return event;
|
|
1286
1289
|
return JSON.parse(redacted);
|
|
1287
1290
|
}
|
|
@@ -1603,8 +1606,8 @@ function createRealCloudRun(options) {
|
|
|
1603
1606
|
cancellable: false,
|
|
1604
1607
|
conversation: []
|
|
1605
1608
|
};
|
|
1606
|
-
const apiKey =
|
|
1607
|
-
const baseUrl =
|
|
1609
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.agentOptions.apiKey);
|
|
1610
|
+
const baseUrl = chunkHLPSLDGL_cjs.getConfiguredBaseUrl();
|
|
1608
1611
|
const handle = new RealCloudRun(
|
|
1609
1612
|
{
|
|
1610
1613
|
id,
|
|
@@ -1677,7 +1680,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1677
1680
|
});
|
|
1678
1681
|
if (!response.ok) {
|
|
1679
1682
|
const text = await response.text().catch(() => "");
|
|
1680
|
-
throw new
|
|
1683
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(
|
|
1681
1684
|
`Cloud Run endpoint returned ${response.status}: ${text.slice(0, 200)}`,
|
|
1682
1685
|
{ code: "cloud_run_http_error" }
|
|
1683
1686
|
);
|
|
@@ -1687,7 +1690,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1687
1690
|
async consumeStream(response) {
|
|
1688
1691
|
let finalStatus = "finished";
|
|
1689
1692
|
let finalText = "";
|
|
1690
|
-
for await (const record of
|
|
1693
|
+
for await (const record of chunkHLPSLDGL_cjs.parseSseStream(response.body, this.controller.signal)) {
|
|
1691
1694
|
const parsed = safeParse(record.data);
|
|
1692
1695
|
if (parsed === void 0) continue;
|
|
1693
1696
|
const update = this.applyRecord(record.event, parsed);
|
|
@@ -1711,7 +1714,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1711
1714
|
}
|
|
1712
1715
|
if (eventName === "result") {
|
|
1713
1716
|
const update = {
|
|
1714
|
-
finalStatus: parsed.status
|
|
1717
|
+
finalStatus: parsed.status === void 0 ? "finished" : toRunStatus(parsed.status)
|
|
1715
1718
|
};
|
|
1716
1719
|
if (typeof parsed.result === "string") update.finalText = parsed.result;
|
|
1717
1720
|
return update;
|
|
@@ -1723,7 +1726,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1723
1726
|
type: "status",
|
|
1724
1727
|
agent_id: this.agentId,
|
|
1725
1728
|
run_id: this.id,
|
|
1726
|
-
status
|
|
1729
|
+
status: toWireStatus(status)
|
|
1727
1730
|
};
|
|
1728
1731
|
}
|
|
1729
1732
|
buildAssistantEvent(text) {
|
|
@@ -1745,6 +1748,43 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1745
1748
|
this.transitionTo("error");
|
|
1746
1749
|
}
|
|
1747
1750
|
};
|
|
1751
|
+
var SERVER_STATUS_TO_RUN_STATUS = {
|
|
1752
|
+
creating: "running",
|
|
1753
|
+
running: "running",
|
|
1754
|
+
finished: "finished",
|
|
1755
|
+
error: "error",
|
|
1756
|
+
cancelled: "cancelled",
|
|
1757
|
+
expired: "error"
|
|
1758
|
+
};
|
|
1759
|
+
var WIRE_STATUSES = [
|
|
1760
|
+
"CREATING",
|
|
1761
|
+
"RUNNING",
|
|
1762
|
+
"FINISHED",
|
|
1763
|
+
"ERROR",
|
|
1764
|
+
"CANCELLED",
|
|
1765
|
+
"EXPIRED"
|
|
1766
|
+
];
|
|
1767
|
+
function toWireStatus(token) {
|
|
1768
|
+
if (typeof token === "string") {
|
|
1769
|
+
const upper = token.toUpperCase();
|
|
1770
|
+
const match = WIRE_STATUSES.find((candidate) => candidate === upper);
|
|
1771
|
+
if (match !== void 0) return match;
|
|
1772
|
+
}
|
|
1773
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(
|
|
1774
|
+
`Cloud Run stream reported an unrecognised status ${JSON.stringify(token)}; expected one of ${WIRE_STATUSES.join(", ")} (case-insensitive)`,
|
|
1775
|
+
{ code: "cloud_run_unknown_status" }
|
|
1776
|
+
);
|
|
1777
|
+
}
|
|
1778
|
+
function toRunStatus(token) {
|
|
1779
|
+
if (typeof token === "string") {
|
|
1780
|
+
const mapped = SERVER_STATUS_TO_RUN_STATUS[token.toLowerCase()];
|
|
1781
|
+
if (mapped !== void 0) return mapped;
|
|
1782
|
+
}
|
|
1783
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(
|
|
1784
|
+
`Cloud Run stream reported an unrecognised status ${JSON.stringify(token)}; expected one of ${Object.keys(SERVER_STATUS_TO_RUN_STATUS).join(", ")} (case-insensitive)`,
|
|
1785
|
+
{ code: "cloud_run_unknown_status" }
|
|
1786
|
+
);
|
|
1787
|
+
}
|
|
1748
1788
|
function safeParse(data2) {
|
|
1749
1789
|
try {
|
|
1750
1790
|
return JSON.parse(data2);
|
|
@@ -1795,8 +1835,8 @@ var CloudAgent = class {
|
|
|
1795
1835
|
* cloud operations are pre-release and must surface explicit errors.
|
|
1796
1836
|
*/
|
|
1797
1837
|
isFixtureMode() {
|
|
1798
|
-
const apiKey =
|
|
1799
|
-
return
|
|
1838
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(this.options.apiKey);
|
|
1839
|
+
return chunkHLPSLDGL_cjs.isFixtureApiKey(apiKey) && chunkHLPSLDGL_cjs.getConfiguredBaseUrl() === void 0;
|
|
1800
1840
|
}
|
|
1801
1841
|
// SE9 — integrated structured output; delegates to the shared helper.
|
|
1802
1842
|
generate(message, options) {
|
|
@@ -1810,8 +1850,9 @@ var CloudAgent = class {
|
|
|
1810
1850
|
);
|
|
1811
1851
|
}
|
|
1812
1852
|
async send(message, options = {}) {
|
|
1853
|
+
if (this.disposed) throw new chunkK3FW2XZD_cjs.AgentDisposedError(this.agentId);
|
|
1813
1854
|
if (options.tools !== void 0 && options.tools.length > 0) {
|
|
1814
|
-
throw new
|
|
1855
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
1815
1856
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
1816
1857
|
{ code: "cloud_custom_tools_rejected" }
|
|
1817
1858
|
);
|
|
@@ -1821,7 +1862,7 @@ var CloudAgent = class {
|
|
|
1821
1862
|
throw new UnsupportedTaskOperationError("send", { cause: void 0 });
|
|
1822
1863
|
}
|
|
1823
1864
|
return new Promise((resolve, reject) => {
|
|
1824
|
-
void
|
|
1865
|
+
void chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${this.agentId}`, async () => {
|
|
1825
1866
|
let run;
|
|
1826
1867
|
try {
|
|
1827
1868
|
run = await this.sendLocked(message, options);
|
|
@@ -1846,8 +1887,8 @@ var CloudAgent = class {
|
|
|
1846
1887
|
}
|
|
1847
1888
|
const userText = typeof message === "string" ? message : message.text;
|
|
1848
1889
|
const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
|
|
1849
|
-
const apiKey =
|
|
1850
|
-
const useRealRuntime = apiKey !== void 0 && !
|
|
1890
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(this.options.apiKey);
|
|
1891
|
+
const useRealRuntime = apiKey !== void 0 && !chunkHLPSLDGL_cjs.isFixtureApiKey(apiKey) && chunkHLPSLDGL_cjs.getConfiguredBaseUrl() !== void 0;
|
|
1851
1892
|
return useRealRuntime ? createRealCloudRun({
|
|
1852
1893
|
agentId: this.agentId,
|
|
1853
1894
|
model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
|
|
@@ -1896,7 +1937,7 @@ var CloudAgent = class {
|
|
|
1896
1937
|
listArtifacts() {
|
|
1897
1938
|
if (!this.isFixtureMode()) {
|
|
1898
1939
|
return Promise.reject(
|
|
1899
|
-
new
|
|
1940
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
1900
1941
|
"Cloud runtime is pre-release. listArtifacts() will return real artifacts when Theo PaaS ships; today it is only available in fixture mode (theo_test_* keys).",
|
|
1901
1942
|
{ code: "cloud_runtime_pre_release" }
|
|
1902
1943
|
)
|
|
@@ -1906,11 +1947,11 @@ var CloudAgent = class {
|
|
|
1906
1947
|
}
|
|
1907
1948
|
downloadArtifact(path) {
|
|
1908
1949
|
try {
|
|
1909
|
-
|
|
1950
|
+
chunkR3UPQFKK_cjs.validateArtifactPath(path);
|
|
1910
1951
|
} catch (cause) {
|
|
1911
|
-
if (cause instanceof
|
|
1952
|
+
if (cause instanceof chunkR3UPQFKK_cjs.PathTraversalError) {
|
|
1912
1953
|
return Promise.reject(
|
|
1913
|
-
new
|
|
1954
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(`Artifact path must stay inside the workspace: ${path}`, {
|
|
1914
1955
|
code: "artifact_path_traversal",
|
|
1915
1956
|
cause
|
|
1916
1957
|
})
|
|
@@ -1920,7 +1961,7 @@ var CloudAgent = class {
|
|
|
1920
1961
|
}
|
|
1921
1962
|
if (!this.isFixtureMode()) {
|
|
1922
1963
|
return Promise.reject(
|
|
1923
|
-
new
|
|
1964
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
1924
1965
|
"Cloud runtime is pre-release. downloadArtifact() will fetch real PaaS artifacts when the cloud runtime ships; today it is only available in fixture mode (theo_test_* keys).",
|
|
1925
1966
|
{ code: "cloud_runtime_pre_release" }
|
|
1926
1967
|
)
|
|
@@ -1929,7 +1970,7 @@ var CloudAgent = class {
|
|
|
1929
1970
|
const match = buildFixtureArtifacts().find((artifact) => artifact.path === path);
|
|
1930
1971
|
if (match === void 0) {
|
|
1931
1972
|
return Promise.reject(
|
|
1932
|
-
new
|
|
1973
|
+
new chunkK3FW2XZD_cjs.UnknownAgentError(`Artifact ${path} not found`, { code: "unknown_artifact" })
|
|
1933
1974
|
);
|
|
1934
1975
|
}
|
|
1935
1976
|
return Promise.resolve(Buffer.from(`fixture artifact content for ${path}
|
|
@@ -1943,7 +1984,7 @@ var CloudAgent = class {
|
|
|
1943
1984
|
* @public
|
|
1944
1985
|
*/
|
|
1945
1986
|
runUntil() {
|
|
1946
|
-
throw new
|
|
1987
|
+
throw new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
1947
1988
|
"Agent.runUntil() is not supported on cloud agents. Cloud runtime manages goal loops server-side. Use a local agent for autonomous Ralph loops.",
|
|
1948
1989
|
"runUntil"
|
|
1949
1990
|
);
|
|
@@ -1954,7 +1995,7 @@ var CloudAgent = class {
|
|
|
1954
1995
|
* @public
|
|
1955
1996
|
*/
|
|
1956
1997
|
fork() {
|
|
1957
|
-
throw new
|
|
1998
|
+
throw new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
1958
1999
|
"Agent.fork() is not supported on cloud agents. Fork inheritance requires local credential + system-prompt access. Use a local agent.",
|
|
1959
2000
|
"fork"
|
|
1960
2001
|
);
|
|
@@ -1966,7 +2007,7 @@ var CloudAgent = class {
|
|
|
1966
2007
|
* @public
|
|
1967
2008
|
*/
|
|
1968
2009
|
runToCompletion() {
|
|
1969
|
-
throw new
|
|
2010
|
+
throw new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
1970
2011
|
"Agent.runToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
1971
2012
|
"runToCompletion"
|
|
1972
2013
|
);
|
|
@@ -1978,7 +2019,7 @@ var CloudAgent = class {
|
|
|
1978
2019
|
* @public
|
|
1979
2020
|
*/
|
|
1980
2021
|
streamToCompletion() {
|
|
1981
|
-
throw new
|
|
2022
|
+
throw new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
1982
2023
|
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
1983
2024
|
"streamToCompletion"
|
|
1984
2025
|
);
|
|
@@ -1992,7 +2033,7 @@ var CloudAgent = class {
|
|
|
1992
2033
|
*/
|
|
1993
2034
|
usePersonality() {
|
|
1994
2035
|
return Promise.reject(
|
|
1995
|
-
new
|
|
2036
|
+
new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
1996
2037
|
"Agent.usePersonality() is not supported on cloud agents (pre-release). Use a local agent or wait for cloud GA.",
|
|
1997
2038
|
"usePersonality"
|
|
1998
2039
|
)
|
|
@@ -2020,7 +2061,7 @@ function validateCloudToolParity(options) {
|
|
|
2020
2061
|
function rejectProcessors(options) {
|
|
2021
2062
|
const hasProcessors = (options.inputProcessors?.length ?? 0) > 0 || (options.outputProcessors?.length ?? 0) > 0;
|
|
2022
2063
|
if (hasProcessors) {
|
|
2023
|
-
throw new
|
|
2064
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2024
2065
|
"Cloud agents can't run guardrail processors \u2014 a Processor carries function handlers that don't survive serialization to PaaS. Run processors on a local agent, or move the guardrail into a server-side gateway in front of TheoCloud.",
|
|
2025
2066
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2026
2067
|
);
|
|
@@ -2028,7 +2069,7 @@ function rejectProcessors(options) {
|
|
|
2028
2069
|
}
|
|
2029
2070
|
function rejectFunctionSystemPrompt(options) {
|
|
2030
2071
|
if (typeof options.systemPrompt === "function") {
|
|
2031
|
-
throw new
|
|
2072
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2032
2073
|
"Cloud agents require systemPrompt as a serializable string. SystemPromptResolver functions can't run on PaaS \u2014 resolve to a string before Agent.create() or move the dynamic logic into a hook rule.",
|
|
2033
2074
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2034
2075
|
);
|
|
@@ -2036,7 +2077,7 @@ function rejectFunctionSystemPrompt(options) {
|
|
|
2036
2077
|
}
|
|
2037
2078
|
function rejectFunctionSkills(options) {
|
|
2038
2079
|
if (typeof options.skills === "function") {
|
|
2039
|
-
throw new
|
|
2080
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2040
2081
|
"Cloud agents require skills as a static settings object. SkillsResolver functions can't run on PaaS \u2014 resolve to a SkillsSettings object before Agent.create() or move the dynamic logic into a hook rule.",
|
|
2041
2082
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2042
2083
|
);
|
|
@@ -2048,7 +2089,7 @@ function rejectStdioMcpLocalPaths(options) {
|
|
|
2048
2089
|
if (!isStdioCommandConfig(config)) continue;
|
|
2049
2090
|
const command = config.command ?? "";
|
|
2050
2091
|
if (isLocalPath(command)) {
|
|
2051
|
-
throw new
|
|
2092
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2052
2093
|
`MCP server "${name}" uses a local-FS command path (${command}). Cloud agents can't reach local binaries \u2014 use a bare command (npx, uvx, node, \u2026) that the PaaS VM image provides, or switch to an HTTP MCP server.`,
|
|
2053
2094
|
{ code: "cloud_incompatible_mcp_stdio_local" }
|
|
2054
2095
|
);
|
|
@@ -2068,19 +2109,19 @@ function isLocalPath(command) {
|
|
|
2068
2109
|
function resolveSessionDir(local) {
|
|
2069
2110
|
if (local?.sessionDir !== void 0) {
|
|
2070
2111
|
if (local.baseDir !== void 0) {
|
|
2071
|
-
|
|
2112
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2072
2113
|
"[theokit-sdk] local.sessionDir and local.baseDir are both set; using sessionDir. baseDir is the deprecated name for the same option (#301)."
|
|
2073
2114
|
);
|
|
2074
2115
|
}
|
|
2075
|
-
return
|
|
2116
|
+
return chunkJHPGF3FP_cjs.expandTilde(local.sessionDir);
|
|
2076
2117
|
}
|
|
2077
2118
|
if (local?.baseDir !== void 0) {
|
|
2078
|
-
|
|
2119
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2079
2120
|
"[theokit-sdk] local.baseDir is deprecated; rename it to local.sessionDir (#301). It is the directory for session transcripts, not the working directory \u2014 that is local.cwd."
|
|
2080
2121
|
);
|
|
2081
|
-
return
|
|
2122
|
+
return chunkJHPGF3FP_cjs.expandTilde(local.baseDir);
|
|
2082
2123
|
}
|
|
2083
|
-
return
|
|
2124
|
+
return chunkJHPGF3FP_cjs.defaultBaseDir();
|
|
2084
2125
|
}
|
|
2085
2126
|
var SCHEMA_VERSION2 = 1;
|
|
2086
2127
|
var FILE_NAME = "personality.json";
|
|
@@ -2107,14 +2148,14 @@ async function readState(filePath) {
|
|
|
2107
2148
|
try {
|
|
2108
2149
|
parsed = JSON.parse(raw);
|
|
2109
2150
|
} catch {
|
|
2110
|
-
|
|
2151
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
2111
2152
|
"personality-store-json-parse",
|
|
2112
2153
|
"[theokit-sdk] personality.json is malformed; treating as empty"
|
|
2113
2154
|
);
|
|
2114
2155
|
return emptyState();
|
|
2115
2156
|
}
|
|
2116
2157
|
if (!isStateV1(parsed)) {
|
|
2117
|
-
|
|
2158
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
2118
2159
|
"personality-store-bad-version",
|
|
2119
2160
|
`[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
|
|
2120
2161
|
);
|
|
@@ -2145,9 +2186,9 @@ var PersonalityStore = class {
|
|
|
2145
2186
|
try {
|
|
2146
2187
|
await this.#persist(agentId, slug);
|
|
2147
2188
|
} catch (err) {
|
|
2148
|
-
|
|
2189
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
2149
2190
|
`personality-store-persist-failure-${agentId}`,
|
|
2150
|
-
`[theokit-sdk] personality persist failed for ${
|
|
2191
|
+
`[theokit-sdk] personality persist failed for ${chunkJTB5Q42C_cjs.redactSecrets(agentId)}: ${chunkJTB5Q42C_cjs.redactSecrets(
|
|
2151
2192
|
err.message
|
|
2152
2193
|
)}`
|
|
2153
2194
|
);
|
|
@@ -2162,9 +2203,9 @@ var PersonalityStore = class {
|
|
|
2162
2203
|
try {
|
|
2163
2204
|
state = await readState(filePath);
|
|
2164
2205
|
} catch (err) {
|
|
2165
|
-
|
|
2206
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
2166
2207
|
`personality-store-hydrate-failure-${agentId}`,
|
|
2167
|
-
`[theokit-sdk] personality hydrate failed for ${
|
|
2208
|
+
`[theokit-sdk] personality hydrate failed for ${chunkJTB5Q42C_cjs.redactSecrets(agentId)}: ${chunkJTB5Q42C_cjs.redactSecrets(
|
|
2168
2209
|
err.message
|
|
2169
2210
|
)}`
|
|
2170
2211
|
);
|
|
@@ -2181,17 +2222,17 @@ var PersonalityStore = class {
|
|
|
2181
2222
|
async #persist(agentId, slug) {
|
|
2182
2223
|
const filePath = this.#filePath();
|
|
2183
2224
|
await promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
2184
|
-
await
|
|
2225
|
+
await chunk2ADR2GSO_cjs.withFileLock(filePath, async () => {
|
|
2185
2226
|
const current = await readState(filePath);
|
|
2186
2227
|
const nextAgents = { ...current.agents };
|
|
2187
2228
|
if (slug === void 0) delete nextAgents[agentId];
|
|
2188
2229
|
else nextAgents[agentId] = slug;
|
|
2189
2230
|
const next = { version: SCHEMA_VERSION2, agents: nextAgents };
|
|
2190
|
-
await
|
|
2231
|
+
await chunkI6TGFUCO_cjs.atomicWriteJson(filePath, next);
|
|
2191
2232
|
});
|
|
2192
2233
|
}
|
|
2193
2234
|
#filePath() {
|
|
2194
|
-
return path.join(
|
|
2235
|
+
return path.join(chunkU2AC6JUP_cjs.getTheokitHome(this.#cwd), FILE_NAME);
|
|
2195
2236
|
}
|
|
2196
2237
|
};
|
|
2197
2238
|
|
|
@@ -2214,7 +2255,7 @@ function createPluginContext() {
|
|
|
2214
2255
|
},
|
|
2215
2256
|
on(hook, handler) {
|
|
2216
2257
|
if (typeof handler !== "function") {
|
|
2217
|
-
|
|
2258
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] ignoring non-function handler for hook "${hook}"
|
|
2218
2259
|
`);
|
|
2219
2260
|
return;
|
|
2220
2261
|
}
|
|
@@ -2267,7 +2308,7 @@ var PluginManager = class {
|
|
|
2267
2308
|
const seen = /* @__PURE__ */ new Set();
|
|
2268
2309
|
for (const plugin of plugins) {
|
|
2269
2310
|
if (seen.has(plugin.name)) {
|
|
2270
|
-
|
|
2311
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2271
2312
|
`[theokit-sdk] duplicate plugin name "${plugin.name}" \u2014 both will register independently
|
|
2272
2313
|
`
|
|
2273
2314
|
);
|
|
@@ -2294,7 +2335,7 @@ var PluginManager = class {
|
|
|
2294
2335
|
*/
|
|
2295
2336
|
async register(plugin) {
|
|
2296
2337
|
if (plugin.kind !== "general") {
|
|
2297
|
-
throw new
|
|
2338
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2298
2339
|
`late register supports general plugins only (got "${plugin.kind}" for "${plugin.name}")`,
|
|
2299
2340
|
{ code: "plugin_late_register_kind" }
|
|
2300
2341
|
);
|
|
@@ -2351,7 +2392,7 @@ var PluginManager = class {
|
|
|
2351
2392
|
parts.push(result.recalledContext);
|
|
2352
2393
|
}
|
|
2353
2394
|
} catch (err) {
|
|
2354
|
-
|
|
2395
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2355
2396
|
`[theokit-sdk] pre_user_send hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2356
2397
|
`
|
|
2357
2398
|
);
|
|
@@ -2379,7 +2420,7 @@ var PluginManager = class {
|
|
|
2379
2420
|
try {
|
|
2380
2421
|
await h(ctx);
|
|
2381
2422
|
} catch (err) {
|
|
2382
|
-
|
|
2423
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2383
2424
|
`[theokit-sdk] post_assistant_reply hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2384
2425
|
`
|
|
2385
2426
|
);
|
|
@@ -2395,7 +2436,7 @@ var PluginManager = class {
|
|
|
2395
2436
|
try {
|
|
2396
2437
|
await h(ctx);
|
|
2397
2438
|
} catch (err) {
|
|
2398
|
-
|
|
2439
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2399
2440
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2400
2441
|
`
|
|
2401
2442
|
);
|
|
@@ -2410,7 +2451,7 @@ var PluginManager = class {
|
|
|
2410
2451
|
const out = await h(current, ctx);
|
|
2411
2452
|
if (out !== void 0) current = out;
|
|
2412
2453
|
} catch (err) {
|
|
2413
|
-
|
|
2454
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2414
2455
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2415
2456
|
`
|
|
2416
2457
|
);
|
|
@@ -2552,7 +2593,7 @@ var HooksExecutor = class {
|
|
|
2552
2593
|
this.config = {};
|
|
2553
2594
|
return;
|
|
2554
2595
|
}
|
|
2555
|
-
this.config = await
|
|
2596
|
+
this.config = await chunk53CBTBWO_cjs.loadHookConfig(this.cwd);
|
|
2556
2597
|
}
|
|
2557
2598
|
/** Fire every hook registered for `event` and aggregate the decisions. */
|
|
2558
2599
|
async run(payload) {
|
|
@@ -2656,13 +2697,16 @@ function buildContextBudgetEvent(model, resolved) {
|
|
|
2656
2697
|
}
|
|
2657
2698
|
|
|
2658
2699
|
// src/internal/runtime/lifecycle/post-run-lifecycle.ts
|
|
2700
|
+
function sessionTranscriptAllowed(memory) {
|
|
2701
|
+
return memory?.enabled !== false;
|
|
2702
|
+
}
|
|
2659
2703
|
function resolveWindowForRun(model, contextWindow) {
|
|
2660
2704
|
const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
|
|
2661
|
-
return
|
|
2705
|
+
return chunkXSX2UU6Y_cjs.resolveEffectiveContextWindow({
|
|
2662
2706
|
...override !== void 0 ? { override } : {},
|
|
2663
|
-
catalog:
|
|
2664
|
-
margin:
|
|
2665
|
-
floor:
|
|
2707
|
+
catalog: chunkNIRE5CNO_cjs.getCatalogModelInfo(model)?.limit?.context,
|
|
2708
|
+
margin: chunkXSX2UU6Y_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2709
|
+
floor: chunkXSX2UU6Y_cjs.CONTEXT_WINDOW_FLOOR
|
|
2666
2710
|
});
|
|
2667
2711
|
}
|
|
2668
2712
|
async function runPostRunLifecycle(inputs) {
|
|
@@ -2686,32 +2730,32 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2686
2730
|
try {
|
|
2687
2731
|
const partial = await safeConversation(run);
|
|
2688
2732
|
if (partial !== void 0) {
|
|
2689
|
-
|
|
2733
|
+
chunkV2UUGUY4_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2690
2734
|
userText,
|
|
2691
2735
|
conversation: partial
|
|
2692
2736
|
});
|
|
2693
2737
|
}
|
|
2694
2738
|
} catch (cause) {
|
|
2695
2739
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2696
|
-
|
|
2740
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2697
2741
|
`);
|
|
2698
2742
|
}
|
|
2699
|
-
await
|
|
2743
|
+
await chunkV2UUGUY4_cjs.flushSessionWrites();
|
|
2700
2744
|
return;
|
|
2701
2745
|
}
|
|
2702
2746
|
if (result.result !== void 0) {
|
|
2703
|
-
|
|
2747
|
+
chunkV2UUGUY4_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2704
2748
|
}
|
|
2705
2749
|
const conversation = await safeConversation(run);
|
|
2706
2750
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2707
2751
|
const effectiveWindow = resolvedWindow.window;
|
|
2708
2752
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2709
2753
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2710
|
-
|
|
2754
|
+
chunkNGESVVJN_cjs.emitRunEvent(onRunEvent, budgetEvent);
|
|
2711
2755
|
}
|
|
2712
2756
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2713
2757
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2714
|
-
|
|
2758
|
+
chunkV2UUGUY4_cjs.persistTurnToTranscript(
|
|
2715
2759
|
sessionStore,
|
|
2716
2760
|
{ cwd: workspaceCwd, agentId, model },
|
|
2717
2761
|
agentId,
|
|
@@ -2723,15 +2767,15 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2723
2767
|
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2724
2768
|
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2725
2769
|
contextWindow: effectiveWindow,
|
|
2726
|
-
summarize:
|
|
2770
|
+
summarize: chunkHLPSLDGL_cjs.buildDefaultSummarizer({
|
|
2727
2771
|
agentModel: model,
|
|
2728
2772
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2729
2773
|
})
|
|
2730
2774
|
}
|
|
2731
2775
|
},
|
|
2732
|
-
onRunEvent !== void 0 ? () =>
|
|
2776
|
+
onRunEvent !== void 0 ? () => chunkNGESVVJN_cjs.emitRunEvent(onRunEvent, { type: "compact_boundary", trigger: "auto" }) : void 0
|
|
2733
2777
|
);
|
|
2734
|
-
if (result.status === "finished" && result.result !== void 0) {
|
|
2778
|
+
if (result.status === "finished" && result.result !== void 0 && sessionTranscriptAllowed(inputs.memory)) {
|
|
2735
2779
|
const summaryArgs = {
|
|
2736
2780
|
cwd: workspaceCwd,
|
|
2737
2781
|
runId: result.id,
|
|
@@ -2745,14 +2789,14 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2745
2789
|
if (memoryProvider?.recordSessionSummary !== void 0) {
|
|
2746
2790
|
await memoryProvider.recordSessionSummary(summaryArgs);
|
|
2747
2791
|
} else {
|
|
2748
|
-
await
|
|
2792
|
+
await chunk5UOVYM3P_cjs.writeSessionSummary(summaryArgs);
|
|
2749
2793
|
}
|
|
2750
2794
|
if (!shouldUsePortMemoryPath()) {
|
|
2751
2795
|
void memoryGlue.syncIfReady();
|
|
2752
2796
|
}
|
|
2753
2797
|
} catch (cause) {
|
|
2754
2798
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2755
|
-
|
|
2799
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] session summary write failed (${result.id}): ${message}
|
|
2756
2800
|
`);
|
|
2757
2801
|
}
|
|
2758
2802
|
}
|
|
@@ -2765,7 +2809,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2765
2809
|
agentId,
|
|
2766
2810
|
runId: result.id
|
|
2767
2811
|
});
|
|
2768
|
-
await
|
|
2812
|
+
await chunkV2UUGUY4_cjs.flushSessionWrites();
|
|
2769
2813
|
}
|
|
2770
2814
|
async function safeConversation(run) {
|
|
2771
2815
|
try {
|
|
@@ -2840,7 +2884,7 @@ var warned = /* @__PURE__ */ new Set();
|
|
|
2840
2884
|
function warnDoubleReasoningOnce() {
|
|
2841
2885
|
if (warned.has("double-reasoning")) return;
|
|
2842
2886
|
warned.add("double-reasoning");
|
|
2843
|
-
|
|
2887
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2844
2888
|
"[theokit-sdk] `reasoning: true` skipped \u2014 a native reasoning model is configured (model.params thinking/reasoning); native reasoning wins. Remove one to silence.\n"
|
|
2845
2889
|
);
|
|
2846
2890
|
}
|
|
@@ -2873,9 +2917,9 @@ var SkillsManager = class {
|
|
|
2873
2917
|
}
|
|
2874
2918
|
async refresh() {
|
|
2875
2919
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
2876
|
-
const discovered = await
|
|
2920
|
+
const discovered = await chunk3YJNUKYN_cjs.discoverSkills(skillsRoot, {
|
|
2877
2921
|
onInvalidSkill: (info) => {
|
|
2878
|
-
|
|
2922
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
2879
2923
|
`);
|
|
2880
2924
|
}
|
|
2881
2925
|
});
|
|
@@ -2899,7 +2943,7 @@ var SkillsManager = class {
|
|
|
2899
2943
|
async get(name) {
|
|
2900
2944
|
const skill = this.skills.find((s) => s.name === name);
|
|
2901
2945
|
if (skill === void 0) return void 0;
|
|
2902
|
-
const instructions = typeof skill.instructions === "string" ? skill.instructions :
|
|
2946
|
+
const instructions = typeof skill.instructions === "string" ? skill.instructions : chunk3YJNUKYN_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
|
|
2903
2947
|
const references = skill.references;
|
|
2904
2948
|
return {
|
|
2905
2949
|
name: skill.name,
|
|
@@ -2985,7 +3029,7 @@ async function safeCall(fn, fallback, label = "safeCall") {
|
|
|
2985
3029
|
return await fn();
|
|
2986
3030
|
} catch (cause) {
|
|
2987
3031
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2988
|
-
|
|
3032
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] ${label} failed: ${message}
|
|
2989
3033
|
`);
|
|
2990
3034
|
return fallback;
|
|
2991
3035
|
}
|
|
@@ -2999,7 +3043,7 @@ var ActiveMemoryPromptProvider = class {
|
|
|
2999
3043
|
if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
|
|
3000
3044
|
return Promise.resolve(void 0);
|
|
3001
3045
|
}
|
|
3002
|
-
const body =
|
|
3046
|
+
const body = chunk3YJNUKYN_cjs.escapeBlockBody(ctx.activeMemorySummary);
|
|
3003
3047
|
return Promise.resolve(`<active-memory>
|
|
3004
3048
|
${body}
|
|
3005
3049
|
</active-memory>`);
|
|
@@ -3052,7 +3096,7 @@ function formatSource(name, tokens) {
|
|
|
3052
3096
|
if (tokens.length === 0) {
|
|
3053
3097
|
return ` <source name="${escapeAttribute(name)}" />`;
|
|
3054
3098
|
}
|
|
3055
|
-
const body =
|
|
3099
|
+
const body = chunk3YJNUKYN_cjs.escapeBlockBody(tokens.join(" "));
|
|
3056
3100
|
return ` <source name="${escapeAttribute(name)}">
|
|
3057
3101
|
${body}
|
|
3058
3102
|
</source>`;
|
|
@@ -3068,7 +3112,7 @@ var MemoryPromptProvider = class {
|
|
|
3068
3112
|
contribute(ctx) {
|
|
3069
3113
|
if (ctx.memoryAutoInject === false) return Promise.resolve(void 0);
|
|
3070
3114
|
if (ctx.memory.length === 0) return Promise.resolve(void 0);
|
|
3071
|
-
const lines = ctx.memory.map((fact) => ` - ${
|
|
3115
|
+
const lines = ctx.memory.map((fact) => ` - ${chunk3YJNUKYN_cjs.escapeBlockBody(fact.text)}`);
|
|
3072
3116
|
return Promise.resolve(`<memory>
|
|
3073
3117
|
${lines.join("\n")}
|
|
3074
3118
|
</memory>`);
|
|
@@ -3090,7 +3134,7 @@ var SkillsPromptProvider = class {
|
|
|
3090
3134
|
priority = 20;
|
|
3091
3135
|
contribute(ctx) {
|
|
3092
3136
|
if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
|
|
3093
|
-
return Promise.resolve(
|
|
3137
|
+
return Promise.resolve(chunk3YJNUKYN_cjs.buildSkillsBlock(ctx.skills));
|
|
3094
3138
|
}
|
|
3095
3139
|
};
|
|
3096
3140
|
|
|
@@ -3102,7 +3146,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
|
|
|
3102
3146
|
for (const p of providers) {
|
|
3103
3147
|
const key = `${p.priority}:${p.id}`;
|
|
3104
3148
|
if (seen.has(key)) {
|
|
3105
|
-
throw new
|
|
3149
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Duplicate system-prompt provider ${key}`, {
|
|
3106
3150
|
code: "pipeline_duplicate_provider"
|
|
3107
3151
|
});
|
|
3108
3152
|
}
|
|
@@ -3149,7 +3193,7 @@ function validateAgentOptions(options) {
|
|
|
3149
3193
|
ensureRuntimeShape(options);
|
|
3150
3194
|
if (options.local !== void 0) {
|
|
3151
3195
|
if (options.model === void 0) {
|
|
3152
|
-
throw new
|
|
3196
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError("Local agents require a model selection", {
|
|
3153
3197
|
code: "missing_model"
|
|
3154
3198
|
});
|
|
3155
3199
|
}
|
|
@@ -3173,7 +3217,7 @@ function validateCredentialPoolShape(options) {
|
|
|
3173
3217
|
([, arr]) => Array.isArray(arr) && arr.some((k) => typeof k === "string" && k.length > 0)
|
|
3174
3218
|
);
|
|
3175
3219
|
if (populated.length === 0) return;
|
|
3176
|
-
throw new
|
|
3220
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3177
3221
|
"Ambiguous credential configuration: use either `apiKey: '...'` (single-key, simplest) OR `apiKeys: { provider: [...] }` (multi-key pool), not both.",
|
|
3178
3222
|
{ code: "credential_pool_ambiguous" }
|
|
3179
3223
|
);
|
|
@@ -3182,7 +3226,7 @@ function validatePlugins(options) {
|
|
|
3182
3226
|
const plugins = options.plugins;
|
|
3183
3227
|
if (plugins?.paths === void 0) return;
|
|
3184
3228
|
if (options.cloud !== void 0 && plugins.paths.length > 0) {
|
|
3185
|
-
throw new
|
|
3229
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3186
3230
|
"Cloud agents require committed plugin manifests; local plugin paths are not supported",
|
|
3187
3231
|
{ code: "cloud_plugin_path_rejected" }
|
|
3188
3232
|
);
|
|
@@ -3190,7 +3234,7 @@ function validatePlugins(options) {
|
|
|
3190
3234
|
}
|
|
3191
3235
|
function ensureRuntimeShape(options) {
|
|
3192
3236
|
if (options.local !== void 0 && options.cloud !== void 0) {
|
|
3193
|
-
throw new
|
|
3237
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3194
3238
|
"Pass either local or cloud \u2014 they are mutually exclusive runtimes",
|
|
3195
3239
|
{ code: "runtime_exclusive" }
|
|
3196
3240
|
);
|
|
@@ -3198,7 +3242,7 @@ function ensureRuntimeShape(options) {
|
|
|
3198
3242
|
}
|
|
3199
3243
|
function rejectProgrammaticHooks(options) {
|
|
3200
3244
|
if (options.hooks !== void 0) {
|
|
3201
|
-
throw new
|
|
3245
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3202
3246
|
"Programmatic hooks are not supported \u2014 hooks are file-based only (.theokit/hooks.json)",
|
|
3203
3247
|
{ code: "programmatic_hooks_rejected" }
|
|
3204
3248
|
);
|
|
@@ -3208,7 +3252,7 @@ function validateCloud(cloud) {
|
|
|
3208
3252
|
if (cloud.envVars !== void 0) {
|
|
3209
3253
|
for (const key of Object.keys(cloud.envVars)) {
|
|
3210
3254
|
if (key.startsWith("THEOKIT_")) {
|
|
3211
|
-
throw new
|
|
3255
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3212
3256
|
`Cloud envVars cannot use the reserved THEOKIT_ prefix (got "${key}")`,
|
|
3213
3257
|
{ code: "reserved_env_prefix" }
|
|
3214
3258
|
);
|
|
@@ -3220,7 +3264,7 @@ function validateMcpServers(options) {
|
|
|
3220
3264
|
if (options.mcpServers === void 0) return;
|
|
3221
3265
|
for (const [name, config] of Object.entries(options.mcpServers)) {
|
|
3222
3266
|
if (options.cloud !== void 0 && isStdioWithCwd(config)) {
|
|
3223
|
-
throw new
|
|
3267
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3224
3268
|
`MCP server "${name}" uses stdio with cwd, which is rejected for cloud agents`,
|
|
3225
3269
|
{ code: "cloud_stdio_cwd_rejected" }
|
|
3226
3270
|
);
|
|
@@ -3239,25 +3283,31 @@ function validateSubagents(agents2) {
|
|
|
3239
3283
|
if (agents2 === void 0) return;
|
|
3240
3284
|
for (const [name, definition] of Object.entries(agents2)) {
|
|
3241
3285
|
if (typeof definition.description !== "string" || definition.description.length === 0) {
|
|
3242
|
-
throw new
|
|
3286
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty description`, {
|
|
3243
3287
|
code: "subagent_missing_description"
|
|
3244
3288
|
});
|
|
3245
3289
|
}
|
|
3246
3290
|
if (typeof definition.prompt !== "string" || definition.prompt.length === 0) {
|
|
3247
|
-
throw new
|
|
3291
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty prompt`, {
|
|
3248
3292
|
code: "subagent_missing_prompt"
|
|
3249
3293
|
});
|
|
3250
3294
|
}
|
|
3251
3295
|
}
|
|
3252
3296
|
}
|
|
3253
3297
|
var TOOL_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;
|
|
3254
|
-
var
|
|
3255
|
-
|
|
3298
|
+
var BUILTIN_TOOL_NAMES = ["shell", "memory_search", "memory_get"];
|
|
3299
|
+
var RESERVED_TOOL_NAMES = new Set(BUILTIN_TOOL_NAMES);
|
|
3300
|
+
function reservedNamesFor(withheld) {
|
|
3301
|
+
if (withheld === void 0 || withheld.length === 0) return RESERVED_TOOL_NAMES;
|
|
3302
|
+
return new Set(BUILTIN_TOOL_NAMES.filter((name) => !withheld.includes(name)));
|
|
3303
|
+
}
|
|
3304
|
+
function validateToolCatalog(tools, withheldBuiltins) {
|
|
3305
|
+
const reserved = reservedNamesFor(withheldBuiltins);
|
|
3256
3306
|
const seen = /* @__PURE__ */ new Set();
|
|
3257
3307
|
for (const tool of tools) {
|
|
3258
|
-
validateSingleTool(tool);
|
|
3308
|
+
validateSingleTool(tool, reserved);
|
|
3259
3309
|
if (seen.has(tool.name)) {
|
|
3260
|
-
throw new
|
|
3310
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Duplicate custom tool name "${tool.name}"`, {
|
|
3261
3311
|
code: "duplicate_tool_name"
|
|
3262
3312
|
});
|
|
3263
3313
|
}
|
|
@@ -3268,37 +3318,37 @@ function validateCustomTools(options) {
|
|
|
3268
3318
|
const tools = options.tools;
|
|
3269
3319
|
if (tools === void 0 || tools.length === 0) return;
|
|
3270
3320
|
if (options.cloud !== void 0) {
|
|
3271
|
-
throw new
|
|
3321
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3272
3322
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
3273
3323
|
{ code: "cloud_custom_tools_rejected" }
|
|
3274
3324
|
);
|
|
3275
3325
|
}
|
|
3276
|
-
validateToolCatalog(tools);
|
|
3326
|
+
validateToolCatalog(tools, options.withheldBuiltinTools);
|
|
3277
3327
|
}
|
|
3278
|
-
function validateSingleTool(tool) {
|
|
3279
|
-
validateToolName(tool);
|
|
3328
|
+
function validateSingleTool(tool, reserved) {
|
|
3329
|
+
validateToolName(tool, reserved);
|
|
3280
3330
|
validateToolDescription(tool);
|
|
3281
3331
|
validateToolSchema(tool);
|
|
3282
3332
|
if (typeof tool.handler !== "function") {
|
|
3283
|
-
throw new
|
|
3333
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a handler function`, {
|
|
3284
3334
|
code: "tool_missing_handler"
|
|
3285
3335
|
});
|
|
3286
3336
|
}
|
|
3287
3337
|
}
|
|
3288
|
-
function validateToolName(tool) {
|
|
3338
|
+
function validateToolName(tool, reserved) {
|
|
3289
3339
|
if (typeof tool.name !== "string" || tool.name.length === 0) {
|
|
3290
|
-
throw new
|
|
3340
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError("Custom tool requires a non-empty name", {
|
|
3291
3341
|
code: "tool_missing_name"
|
|
3292
3342
|
});
|
|
3293
3343
|
}
|
|
3294
3344
|
if (!TOOL_NAME_PATTERN.test(tool.name)) {
|
|
3295
|
-
throw new
|
|
3345
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3296
3346
|
`Custom tool name "${tool.name}" must match /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/`,
|
|
3297
3347
|
{ code: "tool_invalid_name" }
|
|
3298
3348
|
);
|
|
3299
3349
|
}
|
|
3300
|
-
if (
|
|
3301
|
-
throw new
|
|
3350
|
+
if (reserved.has(tool.name) || tool.name.startsWith("mcp_")) {
|
|
3351
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3302
3352
|
`Custom tool name "${tool.name}" collides with a reserved SDK tool name`,
|
|
3303
3353
|
{ code: "tool_reserved_name" }
|
|
3304
3354
|
);
|
|
@@ -3306,7 +3356,7 @@ function validateToolName(tool) {
|
|
|
3306
3356
|
}
|
|
3307
3357
|
function validateToolDescription(tool) {
|
|
3308
3358
|
if (typeof tool.description !== "string" || tool.description.length === 0) {
|
|
3309
|
-
throw new
|
|
3359
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a non-empty description`, {
|
|
3310
3360
|
code: "tool_missing_description"
|
|
3311
3361
|
});
|
|
3312
3362
|
}
|
|
@@ -3314,12 +3364,12 @@ function validateToolDescription(tool) {
|
|
|
3314
3364
|
function validateToolSchema(tool) {
|
|
3315
3365
|
const schema = tool.inputSchema;
|
|
3316
3366
|
if (schema === null || schema === void 0 || typeof schema !== "object") {
|
|
3317
|
-
throw new
|
|
3367
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires an inputSchema object`, {
|
|
3318
3368
|
code: "tool_missing_schema"
|
|
3319
3369
|
});
|
|
3320
3370
|
}
|
|
3321
3371
|
if (schema.type !== "object") {
|
|
3322
|
-
throw new
|
|
3372
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3323
3373
|
`Custom tool "${tool.name}" inputSchema must declare \`type: "object"\``,
|
|
3324
3374
|
{ code: "tool_invalid_schema_type" }
|
|
3325
3375
|
);
|
|
@@ -3330,7 +3380,7 @@ function validateMemory(options) {
|
|
|
3330
3380
|
if (memory?.storePath === void 0) return;
|
|
3331
3381
|
const storePath = memory.storePath;
|
|
3332
3382
|
if (storePath.includes("..") || storePath.startsWith("/") || /^[A-Z]:/i.test(storePath)) {
|
|
3333
|
-
throw new
|
|
3383
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3334
3384
|
`Memory storePath must stay inside the workspace; got "${storePath}"`,
|
|
3335
3385
|
{ code: "memory_path_traversal" }
|
|
3336
3386
|
);
|
|
@@ -3352,7 +3402,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3352
3402
|
};
|
|
3353
3403
|
function safeRequire(moduleName) {
|
|
3354
3404
|
try {
|
|
3355
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3405
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-F5WMX4EA.cjs', document.baseURI).href)));
|
|
3356
3406
|
return r(moduleName);
|
|
3357
3407
|
} catch {
|
|
3358
3408
|
return void 0;
|
|
@@ -3431,7 +3481,7 @@ var langfuseAdapter = {
|
|
|
3431
3481
|
}
|
|
3432
3482
|
}
|
|
3433
3483
|
if (lf.LangfuseSpanProcessor === void 0) {
|
|
3434
|
-
|
|
3484
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3435
3485
|
"[theokit-sdk] @langfuse/node detected but LangfuseSpanProcessor not found (v2?). Use Langfuse v3+ for auto-instrumentation.\n"
|
|
3436
3486
|
);
|
|
3437
3487
|
return;
|
|
@@ -3459,6 +3509,9 @@ var langsmithAdapter = {
|
|
|
3459
3509
|
|
|
3460
3510
|
// src/internal/telemetry/adapters/posthog.ts
|
|
3461
3511
|
var registeredHere6 = false;
|
|
3512
|
+
function presentEnv(value) {
|
|
3513
|
+
return value !== void 0 && value.trim().length > 0 ? value : void 0;
|
|
3514
|
+
}
|
|
3462
3515
|
var posthogAdapter = {
|
|
3463
3516
|
moduleName: "posthog-node",
|
|
3464
3517
|
displayName: "PostHog",
|
|
@@ -3468,12 +3521,12 @@ var posthogAdapter = {
|
|
|
3468
3521
|
const ph = safeRequire("posthog-node");
|
|
3469
3522
|
const otel = safeRequire("@opentelemetry/api");
|
|
3470
3523
|
if (ph === void 0 || otel === void 0) return;
|
|
3471
|
-
const key = process.env.POSTHOG_API_KEY ?? process.env.POSTHOG_PROJECT_API_KEY;
|
|
3524
|
+
const key = presentEnv(process.env.POSTHOG_API_KEY) ?? presentEnv(process.env.POSTHOG_PROJECT_API_KEY);
|
|
3472
3525
|
if (typeof key !== "string" || key.length === 0) {
|
|
3473
3526
|
return;
|
|
3474
3527
|
}
|
|
3475
3528
|
const client = new ph.PostHog(key, {
|
|
3476
|
-
host: process.env.POSTHOG_HOST ?? "https://us.i.posthog.com"
|
|
3529
|
+
host: presentEnv(process.env.POSTHOG_HOST) ?? "https://us.i.posthog.com"
|
|
3477
3530
|
});
|
|
3478
3531
|
const provider = otel.trace.getTracerProvider();
|
|
3479
3532
|
if (provider.addSpanProcessor === void 0) return;
|
|
@@ -3560,11 +3613,11 @@ function tryAutoRegisterAdapters(settings) {
|
|
|
3560
3613
|
try {
|
|
3561
3614
|
adapter.register();
|
|
3562
3615
|
registered.add(adapter.moduleName);
|
|
3563
|
-
|
|
3616
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] telemetry: ${adapter.displayName} auto-instrumented.
|
|
3564
3617
|
`);
|
|
3565
3618
|
} catch (cause) {
|
|
3566
3619
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3567
|
-
|
|
3620
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3568
3621
|
`[theokit-sdk] telemetry: ${adapter.displayName} detected but failed to register: ${message}
|
|
3569
3622
|
`
|
|
3570
3623
|
);
|
|
@@ -3577,7 +3630,7 @@ var cachedOtel;
|
|
|
3577
3630
|
function loadOtel() {
|
|
3578
3631
|
if (cachedOtel === void 0) {
|
|
3579
3632
|
try {
|
|
3580
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3633
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-F5WMX4EA.cjs', document.baseURI).href)));
|
|
3581
3634
|
const mod = r("@opentelemetry/api");
|
|
3582
3635
|
cachedOtel = mod;
|
|
3583
3636
|
} catch {
|
|
@@ -3620,7 +3673,7 @@ function safe(op, fallback) {
|
|
|
3620
3673
|
if (!warnedOnce) {
|
|
3621
3674
|
warnedOnce = true;
|
|
3622
3675
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3623
|
-
|
|
3676
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3624
3677
|
`[theokit-sdk] telemetry exporter error (suppressed; agent.send continues): ${message}
|
|
3625
3678
|
`
|
|
3626
3679
|
);
|
|
@@ -3634,7 +3687,7 @@ function createTelemetry(settings) {
|
|
|
3634
3687
|
if (otel === null) {
|
|
3635
3688
|
if (!warnedOnce) {
|
|
3636
3689
|
warnedOnce = true;
|
|
3637
|
-
|
|
3690
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3638
3691
|
"[theokit-sdk] telemetry.enabled = true but `@opentelemetry/api` is not installed; telemetry is a no-op.\n"
|
|
3639
3692
|
);
|
|
3640
3693
|
}
|
|
@@ -3728,12 +3781,12 @@ function wrapSpan(span, openSpans) {
|
|
|
3728
3781
|
}
|
|
3729
3782
|
function redactAttrValue(value) {
|
|
3730
3783
|
if (typeof value !== "string") return value;
|
|
3731
|
-
return
|
|
3784
|
+
return chunkJTB5Q42C_cjs.redactSecrets(value);
|
|
3732
3785
|
}
|
|
3733
3786
|
function redactAttrs(attrs) {
|
|
3734
3787
|
const out = {};
|
|
3735
3788
|
for (const [k, v] of Object.entries(attrs)) {
|
|
3736
|
-
out[k] = typeof v === "string" ?
|
|
3789
|
+
out[k] = typeof v === "string" ? chunkJTB5Q42C_cjs.redactSecrets(v) : v;
|
|
3737
3790
|
}
|
|
3738
3791
|
return out;
|
|
3739
3792
|
}
|
|
@@ -3751,10 +3804,11 @@ var ProvidersManagerImpl = class {
|
|
|
3751
3804
|
routes() {
|
|
3752
3805
|
const resolved = [];
|
|
3753
3806
|
const modelProvider = providerFromModel(this.model);
|
|
3807
|
+
const modelId = this.model?.id;
|
|
3754
3808
|
const seen = /* @__PURE__ */ new Set();
|
|
3755
3809
|
if (this.providers?.routes !== void 0) {
|
|
3756
3810
|
for (const route of this.providers.routes) {
|
|
3757
|
-
const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
|
|
3811
|
+
const resolvedRoute = resolveRoute(route, modelProvider, modelId, this.plugins);
|
|
3758
3812
|
if (!seen.has(route.capability)) {
|
|
3759
3813
|
seen.add(route.capability);
|
|
3760
3814
|
resolved.push(resolvedRoute);
|
|
@@ -3770,9 +3824,9 @@ function providerFromModel(model) {
|
|
|
3770
3824
|
if (id.includes(":")) return id.split(":")[0];
|
|
3771
3825
|
return void 0;
|
|
3772
3826
|
}
|
|
3773
|
-
function resolveRoute(route, modelProvider, plugins) {
|
|
3827
|
+
function resolveRoute(route, modelProvider, modelId, plugins) {
|
|
3774
3828
|
if (route.capability === "chat" && modelProvider === route.provider) {
|
|
3775
|
-
const modelName = extractModelName(modelProvider, route);
|
|
3829
|
+
const modelName = extractModelName(modelProvider, modelId, route);
|
|
3776
3830
|
const base = {
|
|
3777
3831
|
capability: route.capability,
|
|
3778
3832
|
provider: route.provider,
|
|
@@ -3794,13 +3848,11 @@ function resolveRoute(route, modelProvider, plugins) {
|
|
|
3794
3848
|
reason: "explicit-route"
|
|
3795
3849
|
};
|
|
3796
3850
|
}
|
|
3797
|
-
function extractModelName(prefix, route) {
|
|
3851
|
+
function extractModelName(prefix, modelId, route) {
|
|
3798
3852
|
if (route.model !== void 0) return route.model;
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
if (provider === "anthropic") return "claude-3-7-sonnet";
|
|
3803
|
-
return void 0;
|
|
3853
|
+
if (prefix !== route.provider || modelId === void 0) return void 0;
|
|
3854
|
+
const name = modelId.slice(modelId.indexOf(":") + 1);
|
|
3855
|
+
return name.length > 0 ? name : void 0;
|
|
3804
3856
|
}
|
|
3805
3857
|
var MAX_MD_FILE_BYTES = 1048576;
|
|
3806
3858
|
async function loadMarkdownEntities(opts) {
|
|
@@ -3815,10 +3867,10 @@ async function loadMarkdownEntities(opts) {
|
|
|
3815
3867
|
const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
|
|
3816
3868
|
if (raw === null) continue;
|
|
3817
3869
|
const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
|
|
3818
|
-
const fields =
|
|
3870
|
+
const fields = chunkIWBGCBR6_cjs.parseSimpleYaml(split.frontmatter);
|
|
3819
3871
|
const parsed = schema.safeParse(fields);
|
|
3820
3872
|
if (!parsed.success) {
|
|
3821
|
-
throw new
|
|
3873
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3822
3874
|
`Invalid frontmatter in ${resolved.source}: ${parsed.error.message}`,
|
|
3823
3875
|
{ code: `${errorCodePrefix}_frontmatter_invalid` }
|
|
3824
3876
|
);
|
|
@@ -3836,13 +3888,13 @@ async function assertFileSizeUnderCap(source, errorCodePrefix) {
|
|
|
3836
3888
|
try {
|
|
3837
3889
|
const info = await promises.stat(source);
|
|
3838
3890
|
if (info.size > MAX_MD_FILE_BYTES) {
|
|
3839
|
-
throw new
|
|
3891
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3840
3892
|
`Config file ${source} exceeds 1 MB size limit (${info.size} bytes). Reduce the file or split into multiple entities.`,
|
|
3841
3893
|
{ code: `${errorCodePrefix}_file_too_large` }
|
|
3842
3894
|
);
|
|
3843
3895
|
}
|
|
3844
3896
|
} catch (cause) {
|
|
3845
|
-
if (cause instanceof
|
|
3897
|
+
if (cause instanceof chunkK3FW2XZD_cjs.ConfigurationError) throw cause;
|
|
3846
3898
|
}
|
|
3847
3899
|
}
|
|
3848
3900
|
async function readDirSafe(dir, errorCodePrefix) {
|
|
@@ -3851,7 +3903,7 @@ async function readDirSafe(dir, errorCodePrefix) {
|
|
|
3851
3903
|
} catch (cause) {
|
|
3852
3904
|
const code = cause.code;
|
|
3853
3905
|
if (code === "ENOENT") return null;
|
|
3854
|
-
throw new
|
|
3906
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Failed to read ${dir}`, {
|
|
3855
3907
|
code: `${errorCodePrefix}_dir_read_error`,
|
|
3856
3908
|
cause
|
|
3857
3909
|
});
|
|
@@ -3868,7 +3920,7 @@ function resolveEntryPath(entry, pattern, dir) {
|
|
|
3868
3920
|
function splitFrontmatter(raw, source, errorCodePrefix) {
|
|
3869
3921
|
const match = /^---\s*\n([\s\S]*?)\n---\s*(?:\n|$)/.exec(raw);
|
|
3870
3922
|
if (match === null) {
|
|
3871
|
-
throw new
|
|
3923
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3872
3924
|
`Missing or malformed frontmatter in ${source} (expected \`---\` delimited block at file head)`,
|
|
3873
3925
|
{ code: `${errorCodePrefix}_missing_frontmatter` }
|
|
3874
3926
|
);
|
|
@@ -3897,7 +3949,7 @@ function applyAggregateCap(sources, maxTotal) {
|
|
|
3897
3949
|
}
|
|
3898
3950
|
const remaining = maxTotal - totalBytes;
|
|
3899
3951
|
if (remaining > 0) {
|
|
3900
|
-
const { finalContent } =
|
|
3952
|
+
const { finalContent } = chunkQ47R5E2X_cjs.truncateWithMarker(s.content, remaining);
|
|
3901
3953
|
kept.push({ ...s, content: finalContent, truncated: true });
|
|
3902
3954
|
totalBytes = maxTotal;
|
|
3903
3955
|
} else {
|
|
@@ -3971,9 +4023,9 @@ var FileContextManager = class {
|
|
|
3971
4023
|
this.lastScope = [...touchedFiles];
|
|
3972
4024
|
const config = await loadContextConfig(this.cwd);
|
|
3973
4025
|
const legacy = await loadSources(config, this.cwd);
|
|
3974
|
-
const maxBytesPerFile = this.settings.maxBytesPerFile ??
|
|
4026
|
+
const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkQ47R5E2X_cjs.DEFAULT_MAX_BYTES_PER_FILE;
|
|
3975
4027
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
3976
|
-
const discovered = await
|
|
4028
|
+
const discovered = await chunkQ47R5E2X_cjs.runDiscovery({
|
|
3977
4029
|
cwd: this.cwd,
|
|
3978
4030
|
maxBytesPerFile,
|
|
3979
4031
|
skipLegacyTheokitContext: true,
|
|
@@ -4042,7 +4094,7 @@ async function loadContextConfig(cwd) {
|
|
|
4042
4094
|
});
|
|
4043
4095
|
if (mdEntities.length > 0) {
|
|
4044
4096
|
if (fs.existsSync(jsonPath)) {
|
|
4045
|
-
|
|
4097
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4046
4098
|
"context-both-present",
|
|
4047
4099
|
"[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
|
|
4048
4100
|
);
|
|
@@ -4052,7 +4104,7 @@ async function loadContextConfig(cwd) {
|
|
|
4052
4104
|
};
|
|
4053
4105
|
}
|
|
4054
4106
|
if (!fs.existsSync(jsonPath)) return { sources: [] };
|
|
4055
|
-
|
|
4107
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4056
4108
|
"context-json-deprecated",
|
|
4057
4109
|
"[theokit-sdk] .theokit/context.json is deprecated; migrate to .theokit/context/<name>.md via theokit-migrate-config"
|
|
4058
4110
|
);
|
|
@@ -4060,7 +4112,7 @@ async function loadContextConfig(cwd) {
|
|
|
4060
4112
|
try {
|
|
4061
4113
|
raw = await promises.readFile(jsonPath, "utf8");
|
|
4062
4114
|
} catch (cause) {
|
|
4063
|
-
throw new
|
|
4115
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Failed to read context config: ${jsonPath}`, {
|
|
4064
4116
|
code: "context_read_error",
|
|
4065
4117
|
cause
|
|
4066
4118
|
});
|
|
@@ -4072,13 +4124,13 @@ function parseConfig(raw, configPath) {
|
|
|
4072
4124
|
try {
|
|
4073
4125
|
parsed = JSON.parse(raw);
|
|
4074
4126
|
} catch (cause) {
|
|
4075
|
-
throw new
|
|
4127
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Invalid JSON in context config: ${configPath}`, {
|
|
4076
4128
|
code: "context_json_invalid",
|
|
4077
4129
|
cause
|
|
4078
4130
|
});
|
|
4079
4131
|
}
|
|
4080
4132
|
if (!parsed || typeof parsed !== "object") {
|
|
4081
|
-
throw new
|
|
4133
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Context config must be an object: ${configPath}`, {
|
|
4082
4134
|
code: "context_config_shape"
|
|
4083
4135
|
});
|
|
4084
4136
|
}
|
|
@@ -4093,7 +4145,7 @@ function parseConfig(raw, configPath) {
|
|
|
4093
4145
|
}
|
|
4094
4146
|
function readSources(sourcesRaw, configPath) {
|
|
4095
4147
|
if (!Array.isArray(sourcesRaw)) {
|
|
4096
|
-
throw new
|
|
4148
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Context config sources must be an array: ${configPath}`, {
|
|
4097
4149
|
code: "context_sources_shape"
|
|
4098
4150
|
});
|
|
4099
4151
|
}
|
|
@@ -4118,7 +4170,6 @@ async function loadSources(config, cwd) {
|
|
|
4118
4170
|
continue;
|
|
4119
4171
|
}
|
|
4120
4172
|
try {
|
|
4121
|
-
await promises.stat(absolute);
|
|
4122
4173
|
const content = await promises.readFile(absolute, "utf8");
|
|
4123
4174
|
const tokens = tokenizeContent(content);
|
|
4124
4175
|
results.push({ ...source, status: "included", tokens });
|
|
@@ -4191,7 +4242,7 @@ var PluginsManager = class {
|
|
|
4191
4242
|
async refresh() {
|
|
4192
4243
|
this.plugins = [];
|
|
4193
4244
|
const pluginsRoot = path.join(this.cwd, ".theokit", "plugins");
|
|
4194
|
-
const entries = await
|
|
4245
|
+
const entries = await chunkIWBGCBR6_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
|
|
4195
4246
|
for (const entry of entries) {
|
|
4196
4247
|
if (!entry.isDirectory()) continue;
|
|
4197
4248
|
const folderName = entry.name;
|
|
@@ -4199,13 +4250,13 @@ var PluginsManager = class {
|
|
|
4199
4250
|
const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
|
|
4200
4251
|
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
|
|
4201
4252
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4202
|
-
|
|
4253
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4203
4254
|
`plugin-${folderName}-both`,
|
|
4204
4255
|
`[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
|
|
4205
4256
|
);
|
|
4206
4257
|
}
|
|
4207
4258
|
if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4208
|
-
|
|
4259
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4209
4260
|
"plugin-json-deprecated",
|
|
4210
4261
|
"[theokit-sdk] plugin.json manifests are deprecated; migrate to PLUGIN.md via theokit-migrate-config"
|
|
4211
4262
|
);
|
|
@@ -4223,20 +4274,35 @@ var PluginsManager = class {
|
|
|
4223
4274
|
const entry = metadata.entry;
|
|
4224
4275
|
if (entry === void 0) return;
|
|
4225
4276
|
const pluginRoot = path.join(this.cwd, ".theokit", "plugins", folderName);
|
|
4226
|
-
const entryPath =
|
|
4277
|
+
const entryPath = chunkR3UPQFKK_cjs.safePathJoin(pluginRoot, entry);
|
|
4227
4278
|
try {
|
|
4228
4279
|
await promises.readFile(entryPath, "utf8");
|
|
4229
4280
|
} catch (cause) {
|
|
4230
|
-
throw new
|
|
4281
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${metadata.name} entry file is missing: ${entry}`, {
|
|
4231
4282
|
code: "plugin_entry_missing",
|
|
4232
4283
|
cause
|
|
4233
4284
|
});
|
|
4234
4285
|
}
|
|
4235
4286
|
}
|
|
4287
|
+
/**
|
|
4288
|
+
* B-107 measured this guard as unreachable and it was REMOVED on 2026-08-20. The pre-push gate
|
|
4289
|
+
* caught the regression the same hour: `tests/contract/plugins.contract.test.ts:69` drives
|
|
4290
|
+
* `Agent.create` with `cloud` plus `plugins.paths` and requires a `ConfigurationError`.
|
|
4291
|
+
*
|
|
4292
|
+
* The measurement that said "unreachable" was a `tsc` probe returning TS2353 — `plugins.paths` is
|
|
4293
|
+
* not in the declared `AgentOptions`. That proves the option is undeclarable in TypeScript; it
|
|
4294
|
+
* does NOT prove the value cannot arrive. The contract test casts through a `ProposedAgentOptions`
|
|
4295
|
+
* shape it declares itself, which is exactly what a JavaScript caller, a JSON config or an `as`
|
|
4296
|
+
* cast does. Runtime boundary validation exists for values types cannot stop
|
|
4297
|
+
* (`rules/architecture.md` § 1) — so "the type system forbids it" is never on its own a reason to
|
|
4298
|
+
* delete a boundary check.
|
|
4299
|
+
*
|
|
4300
|
+
* Do not remove this again without making `tests/contract/plugins.contract.test.ts` go red first.
|
|
4301
|
+
*/
|
|
4236
4302
|
assertCloudRules() {
|
|
4237
4303
|
if (!this.cloud) return;
|
|
4238
4304
|
if (this.localPaths !== void 0 && this.localPaths.length > 0) {
|
|
4239
|
-
throw new
|
|
4305
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
4240
4306
|
"Cloud agents reject local plugin paths \u2014 plugins must come from committed repo files",
|
|
4241
4307
|
{ code: "cloud_plugin_path_rejected" }
|
|
4242
4308
|
);
|
|
@@ -4248,7 +4314,7 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4248
4314
|
try {
|
|
4249
4315
|
raw = await promises.readFile(manifestPath, "utf8");
|
|
4250
4316
|
} catch (cause) {
|
|
4251
|
-
throw new
|
|
4317
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} is missing plugin.json`, {
|
|
4252
4318
|
code: "plugin_missing_manifest",
|
|
4253
4319
|
cause
|
|
4254
4320
|
});
|
|
@@ -4257,13 +4323,13 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4257
4323
|
try {
|
|
4258
4324
|
parsed = JSON.parse(raw);
|
|
4259
4325
|
} catch (cause) {
|
|
4260
|
-
throw new
|
|
4326
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} manifest is invalid JSON`, {
|
|
4261
4327
|
code: "plugin_manifest_invalid",
|
|
4262
4328
|
cause
|
|
4263
4329
|
});
|
|
4264
4330
|
}
|
|
4265
4331
|
if (!parsed || typeof parsed !== "object") {
|
|
4266
|
-
throw new
|
|
4332
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} manifest must be an object`, {
|
|
4267
4333
|
code: "plugin_manifest_shape"
|
|
4268
4334
|
});
|
|
4269
4335
|
}
|
|
@@ -4282,7 +4348,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4282
4348
|
try {
|
|
4283
4349
|
raw = await promises.readFile(mdPath, "utf8");
|
|
4284
4350
|
} catch (cause) {
|
|
4285
|
-
throw new
|
|
4351
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} is missing PLUGIN.md`, {
|
|
4286
4352
|
code: "plugin_missing_manifest",
|
|
4287
4353
|
cause
|
|
4288
4354
|
});
|
|
@@ -4297,7 +4363,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4297
4363
|
});
|
|
4298
4364
|
const entity = entities.find((e) => e.slug === "PLUGIN");
|
|
4299
4365
|
if (entity === void 0) {
|
|
4300
|
-
throw new
|
|
4366
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} PLUGIN.md not parseable`, {
|
|
4301
4367
|
code: "plugin_missing_manifest"
|
|
4302
4368
|
});
|
|
4303
4369
|
}
|
|
@@ -4571,7 +4637,7 @@ function assertValidThresholds(soft, hard) {
|
|
|
4571
4637
|
["hardThreshold", hard]
|
|
4572
4638
|
]) {
|
|
4573
4639
|
if (!Number.isInteger(value) || value < 1) {
|
|
4574
|
-
throw new
|
|
4640
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
4575
4641
|
`doomLoop.${label} must be a positive integer (received ${value}).`,
|
|
4576
4642
|
{ code: "invalid_doom_loop_threshold" }
|
|
4577
4643
|
);
|
|
@@ -4794,8 +4860,10 @@ async function initLoopContext(inputs) {
|
|
|
4794
4860
|
memoryProviderHandle = void 0;
|
|
4795
4861
|
}
|
|
4796
4862
|
}
|
|
4797
|
-
const
|
|
4863
|
+
const withheld = new Set(inputs.withheldBuiltinTools ?? []);
|
|
4864
|
+
const tools = await collectTools(inputs.mcp, withheld, inputs.runEventSink);
|
|
4798
4865
|
for (const memTool of inputs.memoryTools ?? []) {
|
|
4866
|
+
if (withheld.has(memTool.name)) continue;
|
|
4799
4867
|
tools.push({
|
|
4800
4868
|
name: memTool.name,
|
|
4801
4869
|
description: memTool.description,
|
|
@@ -4821,6 +4889,7 @@ async function initLoopContext(inputs) {
|
|
|
4821
4889
|
providerTools = [];
|
|
4822
4890
|
}
|
|
4823
4891
|
for (const providerTool of providerTools) {
|
|
4892
|
+
if (withheld.has(providerTool.name)) continue;
|
|
4824
4893
|
tools.push({
|
|
4825
4894
|
name: providerTool.name,
|
|
4826
4895
|
description: providerTool.description,
|
|
@@ -4880,18 +4949,25 @@ async function initLoopContext(inputs) {
|
|
|
4880
4949
|
}
|
|
4881
4950
|
async function safeListTools(client, serverName, sink) {
|
|
4882
4951
|
try {
|
|
4883
|
-
|
|
4952
|
+
const listed = await client.listTools();
|
|
4953
|
+
chunkNGESVVJN_cjs.emitRunEvent(sink, {
|
|
4954
|
+
type: "mcp_server_ready",
|
|
4955
|
+
serverName: serverName ?? "unknown",
|
|
4956
|
+
tools: listed.map((tool) => tool.name)
|
|
4957
|
+
});
|
|
4958
|
+
return listed;
|
|
4884
4959
|
} catch (cause) {
|
|
4885
4960
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
4886
4961
|
const server = serverName ?? "unknown";
|
|
4887
|
-
|
|
4962
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] mcp listTools failed (server=${server}): ${message}
|
|
4888
4963
|
`);
|
|
4889
|
-
|
|
4964
|
+
chunkNGESVVJN_cjs.emitRunEvent(sink, { type: "mcp_server_failed", serverName: server, message });
|
|
4890
4965
|
return [];
|
|
4891
4966
|
}
|
|
4892
4967
|
}
|
|
4893
|
-
|
|
4894
|
-
|
|
4968
|
+
function shellToolDescriptor(withheld) {
|
|
4969
|
+
if (withheld.has("shell")) return [];
|
|
4970
|
+
return [
|
|
4895
4971
|
{
|
|
4896
4972
|
name: "shell",
|
|
4897
4973
|
description: "Run a shell command in the workspace and return stdout/stderr.",
|
|
@@ -4903,6 +4979,9 @@ async function collectTools(mcp, sink) {
|
|
|
4903
4979
|
origin: "shell"
|
|
4904
4980
|
}
|
|
4905
4981
|
];
|
|
4982
|
+
}
|
|
4983
|
+
async function collectTools(mcp, withheld, sink) {
|
|
4984
|
+
const tools = shellToolDescriptor(withheld);
|
|
4906
4985
|
for (const [serverName, client] of mcp.entries()) {
|
|
4907
4986
|
const mcpTools = await safeListTools(client, serverName, sink);
|
|
4908
4987
|
for (const tool of mcpTools) {
|
|
@@ -4921,6 +5000,13 @@ async function collectTools(mcp, sink) {
|
|
|
4921
5000
|
function sanitize(name) {
|
|
4922
5001
|
return name.replace(/[^a-zA-Z0-9-]+/g, "_").replace(/^[_-]+|[_-]+$/g, "");
|
|
4923
5002
|
}
|
|
5003
|
+
var KEY_PREFIX = "theokit-";
|
|
5004
|
+
var KEY_HEX_LENGTH = 32;
|
|
5005
|
+
function derivePromptCacheKey(sessionId) {
|
|
5006
|
+
if (sessionId === void 0 || sessionId.trim().length === 0) return void 0;
|
|
5007
|
+
const digest = crypto.createHash("sha256").update(sessionId, "utf8").digest("hex");
|
|
5008
|
+
return `${KEY_PREFIX}${digest.slice(0, KEY_HEX_LENGTH)}`;
|
|
5009
|
+
}
|
|
4924
5010
|
|
|
4925
5011
|
// src/internal/tool-dispatch/strip-think.ts
|
|
4926
5012
|
var THINK_PATTERN = /<think>[\s\S]*?<\/think>\s*/g;
|
|
@@ -4954,7 +5040,7 @@ function emitLlmMetrics(inputs, result, startAt) {
|
|
|
4954
5040
|
inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.LLM_USAGE_MISSING, 1, {
|
|
4955
5041
|
provider: inputs.llm.name
|
|
4956
5042
|
});
|
|
4957
|
-
|
|
5043
|
+
chunkNUKRL3I6_cjs.diag(
|
|
4958
5044
|
`[theokit-sdk] llm usage missing from ${inputs.llm.name} finish \u2014 budget may undercount
|
|
4959
5045
|
`
|
|
4960
5046
|
);
|
|
@@ -4992,6 +5078,16 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
4992
5078
|
// Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
|
|
4993
5079
|
// text close even though tools are advertised). Absent ⇒ provider default (auto).
|
|
4994
5080
|
...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
|
|
5081
|
+
// usetheokit/theokit-sdk#383 — the prompt-cache key, derived HERE and from `inputs.agentId`
|
|
5082
|
+
// because this is the one place that sees the session identity on every round. `agentId` is
|
|
5083
|
+
// the run's session identity (`Agent.getOrCreate(sessionId)`), so the derived key is identical
|
|
5084
|
+
// on round 1 and round 12 of a turn, identical on turn 2 of the same session, and different
|
|
5085
|
+
// for a different session. Deriving it per round from a stable input is what makes it a cache
|
|
5086
|
+
// key; minting one anywhere that runs more than once per session would not be.
|
|
5087
|
+
...(() => {
|
|
5088
|
+
const key = derivePromptCacheKey(inputs.agentId);
|
|
5089
|
+
return key !== void 0 ? { promptCacheKey: key } : {};
|
|
5090
|
+
})(),
|
|
4995
5091
|
messages: ctx.messages,
|
|
4996
5092
|
tools: ctx.tools.map(toLlmTool)
|
|
4997
5093
|
},
|
|
@@ -5032,13 +5128,12 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
5032
5128
|
};
|
|
5033
5129
|
}
|
|
5034
5130
|
async function collectLlmEvents(generator, inputs, ctx) {
|
|
5035
|
-
let accumulatedText = "";
|
|
5036
5131
|
let errored = false;
|
|
5037
5132
|
let finishValue;
|
|
5038
5133
|
let thinking;
|
|
5134
|
+
const partial = { text: "" };
|
|
5039
5135
|
try {
|
|
5040
|
-
const result = await runCollectorLoop(generator, inputs, ctx);
|
|
5041
|
-
accumulatedText = result.accumulatedText;
|
|
5136
|
+
const result = await runCollectorLoop(generator, inputs, ctx, partial);
|
|
5042
5137
|
errored = result.errored;
|
|
5043
5138
|
finishValue = result.finishValue;
|
|
5044
5139
|
thinking = result.thinking;
|
|
@@ -5048,10 +5143,12 @@ async function collectLlmEvents(generator, inputs, ctx) {
|
|
|
5048
5143
|
ctx.events.push(buildAssistantEvent(inputs, "[aborted]"));
|
|
5049
5144
|
} else {
|
|
5050
5145
|
registerLoopError(ctx, cause);
|
|
5051
|
-
ctx.finalText =
|
|
5146
|
+
ctx.finalText = partial.text;
|
|
5147
|
+
if (partial.text !== "") ctx.events.push(buildAssistantEvent(inputs, partial.text));
|
|
5052
5148
|
}
|
|
5053
5149
|
errored = true;
|
|
5054
5150
|
}
|
|
5151
|
+
const accumulatedText = partial.text;
|
|
5055
5152
|
return {
|
|
5056
5153
|
accumulatedText,
|
|
5057
5154
|
errored,
|
|
@@ -5082,8 +5179,7 @@ async function consumeStreamEvent(inputs, reasoning, event) {
|
|
|
5082
5179
|
}
|
|
5083
5180
|
return "";
|
|
5084
5181
|
}
|
|
5085
|
-
async function runCollectorLoop(generator, inputs, ctx) {
|
|
5086
|
-
let accumulatedText = "";
|
|
5182
|
+
async function runCollectorLoop(generator, inputs, ctx, partial) {
|
|
5087
5183
|
const reasoning = { text: "", startedAt: void 0, signature: void 0 };
|
|
5088
5184
|
let errored = false;
|
|
5089
5185
|
let finishValue;
|
|
@@ -5097,16 +5193,16 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
5097
5193
|
}
|
|
5098
5194
|
if (next.value.type === "error") {
|
|
5099
5195
|
registerLoopError(ctx, next.value);
|
|
5100
|
-
ctx.finalText =
|
|
5196
|
+
ctx.finalText = partial.text;
|
|
5101
5197
|
errored = true;
|
|
5102
5198
|
break;
|
|
5103
5199
|
}
|
|
5104
|
-
|
|
5200
|
+
partial.text += await consumeStreamEvent(inputs, reasoning, next.value);
|
|
5105
5201
|
}
|
|
5106
5202
|
} finally {
|
|
5107
5203
|
thinking = await finalizeReasoning(inputs, ctx, reasoning);
|
|
5108
5204
|
}
|
|
5109
|
-
return {
|
|
5205
|
+
return { errored, finishValue, ...thinking !== void 0 ? { thinking } : {} };
|
|
5110
5206
|
}
|
|
5111
5207
|
async function consumeReasoningDelta(inputs, reasoning, delta) {
|
|
5112
5208
|
if (delta.signature !== void 0) reasoning.signature = delta.signature;
|
|
@@ -5250,7 +5346,7 @@ function coerceArgsToSchema(args, schema) {
|
|
|
5250
5346
|
}
|
|
5251
5347
|
|
|
5252
5348
|
// src/tool-error.ts
|
|
5253
|
-
var ToolError = class extends
|
|
5349
|
+
var ToolError = class extends chunkK3FW2XZD_cjs.TheokitAgentError {
|
|
5254
5350
|
name = "ToolError";
|
|
5255
5351
|
/** The error content surfaced to the model: a string, or text/image blocks. */
|
|
5256
5352
|
content;
|
|
@@ -5444,7 +5540,7 @@ function raceToolExecution(exec, opts) {
|
|
|
5444
5540
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
5445
5541
|
async function dispatchTools(inputs, tools, toolCalls, events, parentSpan) {
|
|
5446
5542
|
const maxConcurrent = inputs.maxConcurrentTools ?? 4;
|
|
5447
|
-
return
|
|
5543
|
+
return chunkILCGLTSA_cjs.mapWithConcurrency(
|
|
5448
5544
|
toolCalls,
|
|
5449
5545
|
maxConcurrent,
|
|
5450
5546
|
(call) => dispatchSingleCall(inputs, tools, call, events, parentSpan)
|
|
@@ -5472,7 +5568,7 @@ async function dispatchSingleCall(inputs, tools, call, events, parentSpan) {
|
|
|
5472
5568
|
toolSpan?.end();
|
|
5473
5569
|
return fileVeto;
|
|
5474
5570
|
}
|
|
5475
|
-
|
|
5571
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5476
5572
|
type: "tool_progress",
|
|
5477
5573
|
toolName: workingCall.name,
|
|
5478
5574
|
toolCallId: callId
|
|
@@ -5503,7 +5599,7 @@ function applyRepairAndExtractCall(tools, call) {
|
|
|
5503
5599
|
function vetoFromForkWhitelist(inputs, call, callId, events) {
|
|
5504
5600
|
const whitelistDecision = chunkVJ26EKGJ_cjs.checkToolWhitelist(call.name);
|
|
5505
5601
|
if (whitelistDecision.allowed) return void 0;
|
|
5506
|
-
|
|
5602
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5507
5603
|
type: "permission_denied",
|
|
5508
5604
|
toolName: call.name,
|
|
5509
5605
|
toolCallId: callId,
|
|
@@ -5548,7 +5644,7 @@ async function vetoFromPluginPreHook(inputs, call, callId, events) {
|
|
|
5548
5644
|
...inputs.permissionMode !== void 0 ? { permissionMode: inputs.permissionMode } : {}
|
|
5549
5645
|
});
|
|
5550
5646
|
if (pluginVeto === void 0) return void 0;
|
|
5551
|
-
|
|
5647
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5552
5648
|
type: "permission_denied",
|
|
5553
5649
|
toolName: call.name,
|
|
5554
5650
|
toolCallId: callId,
|
|
@@ -5577,7 +5673,7 @@ async function vetoFromFileHookPreDecision(inputs, call, callId, events) {
|
|
|
5577
5673
|
runId: inputs.runId
|
|
5578
5674
|
});
|
|
5579
5675
|
if (!preDecision.blocked) return void 0;
|
|
5580
|
-
|
|
5676
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5581
5677
|
type: "permission_denied",
|
|
5582
5678
|
toolName: call.name,
|
|
5583
5679
|
toolCallId: callId,
|
|
@@ -5678,7 +5774,7 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
|
|
|
5678
5774
|
agentId: inputs.agentId,
|
|
5679
5775
|
runId: inputs.runId
|
|
5680
5776
|
}).catch((err) => {
|
|
5681
|
-
|
|
5777
|
+
chunkNUKRL3I6_cjs.diag(
|
|
5682
5778
|
`[theokit-sdk] postToolUse hook error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5683
5779
|
`
|
|
5684
5780
|
);
|
|
@@ -5697,7 +5793,7 @@ async function emitToolLifecycleDelta(inputs, update) {
|
|
|
5697
5793
|
try {
|
|
5698
5794
|
await inputs.onDelta({ update });
|
|
5699
5795
|
} catch (err) {
|
|
5700
|
-
|
|
5796
|
+
chunkNUKRL3I6_cjs.diag(
|
|
5701
5797
|
`[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5702
5798
|
`
|
|
5703
5799
|
);
|
|
@@ -5709,7 +5805,7 @@ async function safeEmitToolHook(callback, event) {
|
|
|
5709
5805
|
await callback(event);
|
|
5710
5806
|
} catch (cause) {
|
|
5711
5807
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
5712
|
-
|
|
5808
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] tool lifecycle hook threw: ${msg}
|
|
5713
5809
|
`);
|
|
5714
5810
|
}
|
|
5715
5811
|
}
|
|
@@ -5776,7 +5872,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
5776
5872
|
(p) => (
|
|
5777
5873
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
5778
5874
|
// structured content); image blocks pass through untouched.
|
|
5779
|
-
p.type === "tool_result" ? { ...p, content:
|
|
5875
|
+
p.type === "tool_result" ? { ...p, content: chunkHLPSLDGL_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
5780
5876
|
)
|
|
5781
5877
|
);
|
|
5782
5878
|
}
|
|
@@ -5928,7 +6024,7 @@ function stripDateSuffix(model) {
|
|
|
5928
6024
|
return model.replace(/-\d{4}-?\d{2}-?\d{2}$/, "");
|
|
5929
6025
|
}
|
|
5930
6026
|
function normalizeAnthropicDots(model) {
|
|
5931
|
-
return model.replace(/(
|
|
6027
|
+
return model.replace(/(?<=\d)\.(?=\d)/g, "-");
|
|
5932
6028
|
}
|
|
5933
6029
|
function stripOpenRouterPrefix(modelId) {
|
|
5934
6030
|
return modelId.startsWith("openrouter/") ? modelId.slice("openrouter/".length) : modelId;
|
|
@@ -5971,7 +6067,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
5971
6067
|
const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
|
|
5972
6068
|
if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
|
|
5973
6069
|
for (const key of candidates) {
|
|
5974
|
-
const info =
|
|
6070
|
+
const info = chunkNIRE5CNO_cjs.getCatalogModelInfo(key);
|
|
5975
6071
|
const cost = info?.cost;
|
|
5976
6072
|
if (cost === void 0) continue;
|
|
5977
6073
|
const [prov, ...modelParts] = key.split("/");
|
|
@@ -5983,7 +6079,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
5983
6079
|
...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
|
|
5984
6080
|
...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
|
|
5985
6081
|
// M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
|
|
5986
|
-
pricingVersion:
|
|
6082
|
+
pricingVersion: chunkNIRE5CNO_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
|
|
5987
6083
|
};
|
|
5988
6084
|
}
|
|
5989
6085
|
return void 0;
|
|
@@ -6109,7 +6205,7 @@ function accumulateUsage(usage, turn) {
|
|
|
6109
6205
|
function computeUsageCost(inputs, usage) {
|
|
6110
6206
|
const modelId = inputs.model.id;
|
|
6111
6207
|
if (modelId === void 0 || modelId === "auto") return void 0;
|
|
6112
|
-
const parsed =
|
|
6208
|
+
const parsed = chunk3EE6LVWT_cjs.parseModelId(modelId);
|
|
6113
6209
|
const provider = parsed.provider ?? inputs.llm.name;
|
|
6114
6210
|
const model = parsed.provider !== void 0 ? parsed.name : modelId;
|
|
6115
6211
|
return computeCost({ provider, model, usage });
|
|
@@ -6181,6 +6277,12 @@ async function runAgentLoop(inputs) {
|
|
|
6181
6277
|
}
|
|
6182
6278
|
if (budget.shouldContinue() === false && ctx.finalStatus === "finished" && ctx.finalText === "") {
|
|
6183
6279
|
ctx.finalStatus = "error";
|
|
6280
|
+
if (ctx.error === void 0) {
|
|
6281
|
+
ctx.error = {
|
|
6282
|
+
message: `Run stopped after ${budget.total} iteration(s) without producing a reply \u2014 the model was still calling tools when the budget ran out. Raise \`SendOptions.maxIterations\` (default 8), or inspect \`RunResult.stoppedAtIterationLimit\` to continue the run.`,
|
|
6283
|
+
code: "iteration_limit_reached"
|
|
6284
|
+
};
|
|
6285
|
+
}
|
|
6184
6286
|
}
|
|
6185
6287
|
sendSpan?.setAttribute("status", ctx.finalStatus);
|
|
6186
6288
|
if (ctx.stoppedByDoomLoop === true) sendSpan?.setAttribute("stoppedByDoomLoop", true);
|
|
@@ -6436,15 +6538,15 @@ var FallbackLlmClient = class {
|
|
|
6436
6538
|
let lastError;
|
|
6437
6539
|
for (const client of this.clients) {
|
|
6438
6540
|
if (signal.aborted) throw abortError(signal);
|
|
6439
|
-
const attempt = await
|
|
6541
|
+
const attempt = await chunkHLPSLDGL_cjs.tryFirstEvent(client, request, signal, true);
|
|
6440
6542
|
if (attempt.kind === "handshake_error") {
|
|
6441
6543
|
lastError = attempt.error;
|
|
6442
6544
|
continue;
|
|
6443
6545
|
}
|
|
6444
|
-
return yield*
|
|
6546
|
+
return yield* chunkHLPSLDGL_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6445
6547
|
}
|
|
6446
6548
|
if (lastError !== void 0) throw lastError;
|
|
6447
|
-
throw new
|
|
6549
|
+
throw new chunkK3FW2XZD_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
6448
6550
|
code: "fallback_empty_chain"
|
|
6449
6551
|
});
|
|
6450
6552
|
}
|
|
@@ -6467,7 +6569,7 @@ function reconnectDelay(attempt) {
|
|
|
6467
6569
|
return ms <= 0 ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, ms));
|
|
6468
6570
|
}
|
|
6469
6571
|
function mcpTimeoutError(name, timeoutMs) {
|
|
6470
|
-
return new
|
|
6572
|
+
return new chunkK3FW2XZD_cjs.NetworkError(`MCP ${name} request timed out after ${timeoutMs}ms`, {
|
|
6471
6573
|
code: "mcp_timeout"
|
|
6472
6574
|
});
|
|
6473
6575
|
}
|
|
@@ -6550,7 +6652,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6550
6652
|
child.stdin.on("error", () => void 0);
|
|
6551
6653
|
child.on("error", () => {
|
|
6552
6654
|
this.rejectAllPending(
|
|
6553
|
-
new
|
|
6655
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} process crashed`, { code: "mcp_crashed" })
|
|
6554
6656
|
);
|
|
6555
6657
|
});
|
|
6556
6658
|
child.on("exit", () => {
|
|
@@ -6558,7 +6660,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6558
6660
|
this.child = void 0;
|
|
6559
6661
|
this.dropped = true;
|
|
6560
6662
|
this.rejectAllPending(
|
|
6561
|
-
new
|
|
6663
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6562
6664
|
);
|
|
6563
6665
|
});
|
|
6564
6666
|
}
|
|
@@ -6586,7 +6688,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6586
6688
|
if (this.child !== void 0) return Promise.resolve();
|
|
6587
6689
|
if (!this.dropped) {
|
|
6588
6690
|
return Promise.reject(
|
|
6589
|
-
new
|
|
6691
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6590
6692
|
);
|
|
6591
6693
|
}
|
|
6592
6694
|
this.reconnectPromise ??= this.reconnect().finally(() => {
|
|
@@ -6607,13 +6709,13 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6607
6709
|
lastErr = err;
|
|
6608
6710
|
}
|
|
6609
6711
|
}
|
|
6610
|
-
throw new
|
|
6712
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} reconnect exhausted`, {
|
|
6611
6713
|
code: "mcp_disconnected",
|
|
6612
6714
|
...lastErr instanceof Error ? { cause: lastErr } : {}
|
|
6613
6715
|
});
|
|
6614
6716
|
}
|
|
6615
6717
|
async close() {
|
|
6616
|
-
this.rejectAllPending(new
|
|
6718
|
+
this.rejectAllPending(new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
|
|
6617
6719
|
const child = this.child;
|
|
6618
6720
|
this.child = void 0;
|
|
6619
6721
|
this.dropped = false;
|
|
@@ -6632,7 +6734,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6632
6734
|
if (this.buffer.length > MAX_STDIO_BUFFER_BYTES) {
|
|
6633
6735
|
this.buffer = "";
|
|
6634
6736
|
this.rejectAllPending(
|
|
6635
|
-
new
|
|
6737
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} exceeded stdout buffer limit`, {
|
|
6636
6738
|
code: "mcp_buffer_overflow"
|
|
6637
6739
|
})
|
|
6638
6740
|
);
|
|
@@ -6667,7 +6769,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6667
6769
|
if (child !== void 0) return this.send(child, method, params);
|
|
6668
6770
|
if (this.dropped) return this.reconnectAndRequest(method, params);
|
|
6669
6771
|
return Promise.reject(
|
|
6670
|
-
new
|
|
6772
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6671
6773
|
);
|
|
6672
6774
|
}
|
|
6673
6775
|
/** M2 #59 — reconnect a dropped client, then send. Separate async path so the
|
|
@@ -6676,7 +6778,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6676
6778
|
await this.ensureConnected();
|
|
6677
6779
|
const child = this.child;
|
|
6678
6780
|
if (child === void 0) {
|
|
6679
|
-
throw new
|
|
6781
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" });
|
|
6680
6782
|
}
|
|
6681
6783
|
return this.send(child, method, params);
|
|
6682
6784
|
}
|
|
@@ -6693,7 +6795,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6693
6795
|
this.child = void 0;
|
|
6694
6796
|
this.dropped = true;
|
|
6695
6797
|
this.rejectAllPending(
|
|
6696
|
-
new
|
|
6798
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6697
6799
|
);
|
|
6698
6800
|
}, this.timeoutMs);
|
|
6699
6801
|
this.pending.set(id, { resolve, reject, timer });
|
|
@@ -6744,12 +6846,6 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6744
6846
|
...this.config.headers ?? {}
|
|
6745
6847
|
};
|
|
6746
6848
|
}
|
|
6747
|
-
/**
|
|
6748
|
-
* Capture the session on the FIRST response that carries it (the `initialize`).
|
|
6749
|
-
*
|
|
6750
|
-
* Never overwritten by a later one: a server that re-issues mid-session would otherwise split
|
|
6751
|
-
* the session in two, and the second half would not see the first half's state.
|
|
6752
|
-
*/
|
|
6753
6849
|
/**
|
|
6754
6850
|
* Read one JSON-RPC response, in either encoding the server may choose.
|
|
6755
6851
|
*
|
|
@@ -6771,10 +6867,16 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6771
6867
|
if (payload === "") continue;
|
|
6772
6868
|
return JSON.parse(payload);
|
|
6773
6869
|
}
|
|
6774
|
-
throw new
|
|
6870
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
|
|
6775
6871
|
code: "mcp_http_error"
|
|
6776
6872
|
});
|
|
6777
6873
|
}
|
|
6874
|
+
/**
|
|
6875
|
+
* Capture the session on the FIRST response that carries it (the `initialize`).
|
|
6876
|
+
*
|
|
6877
|
+
* Never overwritten by a later one: a server that re-issues mid-session would otherwise split
|
|
6878
|
+
* the session in two, and the second half would not see the first half's state.
|
|
6879
|
+
*/
|
|
6778
6880
|
captureSession(response) {
|
|
6779
6881
|
if (this.sessionId !== void 0) return;
|
|
6780
6882
|
const issued = response.headers.get("mcp-session-id");
|
|
@@ -6799,7 +6901,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6799
6901
|
throw cause;
|
|
6800
6902
|
}
|
|
6801
6903
|
if (!response.ok) {
|
|
6802
|
-
throw new
|
|
6904
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} returned ${response.status}`, {
|
|
6803
6905
|
code: "mcp_http_error"
|
|
6804
6906
|
});
|
|
6805
6907
|
}
|
|
@@ -6815,14 +6917,14 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6815
6917
|
function resolveMcpCwd(configCwd) {
|
|
6816
6918
|
if (configCwd === void 0) return process.cwd();
|
|
6817
6919
|
if (path.isAbsolute(configCwd)) return configCwd;
|
|
6818
|
-
return
|
|
6920
|
+
return chunkR3UPQFKK_cjs.safePathJoin(process.cwd(), configCwd);
|
|
6819
6921
|
}
|
|
6820
6922
|
|
|
6821
6923
|
// src/internal/providers/register-plugin-providers.ts
|
|
6822
6924
|
function registerPluginProviderProfiles(entries) {
|
|
6823
6925
|
let registered2 = 0;
|
|
6824
6926
|
for (const entry of entries) {
|
|
6825
|
-
|
|
6927
|
+
chunkNIRE5CNO_cjs.registerProvider(entry.profile);
|
|
6826
6928
|
registered2 += 1;
|
|
6827
6929
|
}
|
|
6828
6930
|
return registered2;
|
|
@@ -6902,7 +7004,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
|
|
|
6902
7004
|
if (exposedSet.has(name)) continue;
|
|
6903
7005
|
const hint = suggestClosest(name, exposedSet);
|
|
6904
7006
|
const message = hint !== void 0 ? `[theokit-sdk] personality "${opts?.personalityName ?? "?"}" references unknown tool "${name}"; did you mean "${hint}"?` : `[theokit-sdk] personality "${opts?.personalityName ?? "?"}" references unknown tool "${name}" (not exposed)`;
|
|
6905
|
-
|
|
7007
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
6906
7008
|
`personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
|
|
6907
7009
|
message
|
|
6908
7010
|
);
|
|
@@ -6944,7 +7046,7 @@ function levenshtein(a, b) {
|
|
|
6944
7046
|
// src/internal/local-agent/real-local-run-tools.ts
|
|
6945
7047
|
function declarativeSubagentTools(agents2, parentTools) {
|
|
6946
7048
|
if (agents2 === void 0 || Object.keys(agents2).length === 0) return [];
|
|
6947
|
-
return
|
|
7049
|
+
return chunk4O5TGQBW_cjs.subAgentToolsFromDefinitions(agents2, parentTools);
|
|
6948
7050
|
}
|
|
6949
7051
|
function resolveInheritedCredentials(agentOptions) {
|
|
6950
7052
|
const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
|
|
@@ -6956,14 +7058,20 @@ function resolveInheritedCredentials(agentOptions) {
|
|
|
6956
7058
|
...parentSandbox !== void 0 ? { sandbox: parentSandbox } : {}
|
|
6957
7059
|
};
|
|
6958
7060
|
}
|
|
6959
|
-
function
|
|
7061
|
+
function withheldBuiltinsInput(agentOptions) {
|
|
7062
|
+
const withheld = agentOptions.withheldBuiltinTools;
|
|
7063
|
+
if (withheld === void 0 || withheld.length === 0) return {};
|
|
7064
|
+
return { withheldBuiltinTools: withheld };
|
|
7065
|
+
}
|
|
7066
|
+
function buildRunToolCatalogInput(agentOptions, sendOptions, pluginManager, personalityToolWhitelist, agentId, personalityName, subagents, effectiveModel) {
|
|
7067
|
+
const builtins = withheldBuiltinsInput(agentOptions);
|
|
6960
7068
|
const baseTools = sendOptions?.tools ?? agentOptions.tools ?? [];
|
|
6961
7069
|
const agentsForTools = subagents !== void 0 && Object.keys(subagents).length > 0 ? subagents : agentOptions.agents;
|
|
6962
7070
|
const subagentTools = declarativeSubagentTools(agentsForTools, baseTools);
|
|
6963
7071
|
const pluginTools = pluginManager?.aggregated.tools ?? [];
|
|
6964
7072
|
const reasoningTools = reasoningActive(agentOptions.reasoning, effectiveModel) ? [createThinkTool()] : [];
|
|
6965
7073
|
if (baseTools.length === 0 && subagentTools.length === 0 && pluginTools.length === 0 && reasoningTools.length === 0) {
|
|
6966
|
-
return
|
|
7074
|
+
return builtins;
|
|
6967
7075
|
}
|
|
6968
7076
|
const allTools = [...baseTools, ...subagentTools, ...pluginTools, ...reasoningTools];
|
|
6969
7077
|
const merged = allTools.map((tool) => ({
|
|
@@ -6976,8 +7084,8 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
|
|
|
6976
7084
|
agentId,
|
|
6977
7085
|
personalityName
|
|
6978
7086
|
});
|
|
6979
|
-
if (customTools.length === 0 && personalityToolWhitelist === void 0) return
|
|
6980
|
-
return { customTools };
|
|
7087
|
+
if (customTools.length === 0 && personalityToolWhitelist === void 0) return builtins;
|
|
7088
|
+
return { customTools, ...builtins };
|
|
6981
7089
|
}
|
|
6982
7090
|
|
|
6983
7091
|
// src/internal/local-agent/real-local-run.ts
|
|
@@ -7011,25 +7119,26 @@ function createRealLocalRun(options) {
|
|
|
7011
7119
|
}
|
|
7012
7120
|
var pluginProvidersAnnounced = false;
|
|
7013
7121
|
function resolveRunProvider(options) {
|
|
7014
|
-
|
|
7122
|
+
chunkNIRE5CNO_cjs.registerBuiltins();
|
|
7015
7123
|
const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
|
|
7016
7124
|
const registered2 = registerPluginProviderProfiles(profiles);
|
|
7017
7125
|
if (registered2 > 0 && !pluginProvidersAnnounced) {
|
|
7018
7126
|
pluginProvidersAnnounced = true;
|
|
7019
7127
|
const names = profiles.map((e) => e.profile.name).join(", ");
|
|
7020
|
-
|
|
7128
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] registered ${registered2} plugin provider profile(s): ${names}
|
|
7021
7129
|
`);
|
|
7022
7130
|
}
|
|
7023
|
-
const parsedModel =
|
|
7024
|
-
const modelInferredProvider = parsedModel.provider !== void 0 &&
|
|
7025
|
-
const keyInferredProvider =
|
|
7026
|
-
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ??
|
|
7131
|
+
const parsedModel = chunk3EE6LVWT_cjs.parseModelId(options.model?.id);
|
|
7132
|
+
const modelInferredProvider = parsedModel.provider !== void 0 && chunkNIRE5CNO_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
|
|
7133
|
+
const keyInferredProvider = chunkHLPSLDGL_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
|
|
7134
|
+
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkHLPSLDGL_cjs.detectPrimaryProvider();
|
|
7135
|
+
chunkHLPSLDGL_cjs.warnProviderPrecedenceOnce(modelInferredProvider, primary);
|
|
7027
7136
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7028
7137
|
return { primary, effectiveModelId };
|
|
7029
7138
|
}
|
|
7030
7139
|
function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
7031
7140
|
if (apiKey === void 0 || apiKey.length === 0) return pools;
|
|
7032
|
-
if (
|
|
7141
|
+
if (chunkHLPSLDGL_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
|
|
7033
7142
|
const existing = pools?.[primary];
|
|
7034
7143
|
if (existing !== void 0 && existing.length > 0) return pools;
|
|
7035
7144
|
return { ...pools ?? {}, [primary]: [apiKey] };
|
|
@@ -7037,7 +7146,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
|
7037
7146
|
function buildLoopInputs(options, runId, userText, userImages) {
|
|
7038
7147
|
const maxIterations = options.sendOptions.maxIterations;
|
|
7039
7148
|
if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
|
|
7040
|
-
throw new
|
|
7149
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
7041
7150
|
`SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
|
|
7042
7151
|
{ code: "invalid_max_iterations" }
|
|
7043
7152
|
);
|
|
@@ -7052,14 +7161,16 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7052
7161
|
const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
|
|
7053
7162
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7054
7163
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7055
|
-
const
|
|
7164
|
+
const modelBaseUrl = options.model?.url;
|
|
7165
|
+
const chain = chunkHLPSLDGL_cjs.resolveProviderChain({
|
|
7056
7166
|
primary,
|
|
7167
|
+
...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
|
|
7057
7168
|
...fallback !== void 0 ? { fallback } : {},
|
|
7058
7169
|
...apiKeys !== void 0 ? { apiKeys } : {},
|
|
7059
7170
|
...credentialPoolStrategy !== void 0 ? { credentialPoolStrategy } : {},
|
|
7060
7171
|
...extractToolCallsFromContent === true ? { extractToolCallsFromContent: true } : {},
|
|
7061
7172
|
...rateLimitSink !== void 0 ? {
|
|
7062
|
-
onRateLimit: (info) =>
|
|
7173
|
+
onRateLimit: (info) => chunkNGESVVJN_cjs.emitRunEvent(rateLimitSink, { type: "rate_limit", ...info })
|
|
7063
7174
|
} : {}
|
|
7064
7175
|
});
|
|
7065
7176
|
const llm = chain.length === 1 ? chain[0] : new FallbackLlmClient(chain);
|
|
@@ -7090,7 +7201,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7090
7201
|
} : {},
|
|
7091
7202
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
7092
7203
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
7093
|
-
...
|
|
7204
|
+
...buildRunToolCatalogInput(
|
|
7094
7205
|
options.agentOptions,
|
|
7095
7206
|
options.sendOptions,
|
|
7096
7207
|
options.pluginManager,
|
|
@@ -7241,7 +7352,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7241
7352
|
};
|
|
7242
7353
|
try {
|
|
7243
7354
|
const runLoop = () => inputs.activeTools !== void 0 ? chunkVJ26EKGJ_cjs.withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : runAgentLoop(inputs);
|
|
7244
|
-
const output = await
|
|
7355
|
+
const output = await chunk4O5TGQBW_cjs.withInheritedSubAgentCredentials(this.inheritedCredentials, runLoop);
|
|
7245
7356
|
this.applyAgentLoopOutput(output);
|
|
7246
7357
|
this.transitionTo(output.finalStatus);
|
|
7247
7358
|
} catch (cause) {
|
|
@@ -7334,7 +7445,7 @@ function buildRealRunOptions(args) {
|
|
|
7334
7445
|
};
|
|
7335
7446
|
}
|
|
7336
7447
|
async function createFixtureRunHelper(args) {
|
|
7337
|
-
const sessionMessages =
|
|
7448
|
+
const sessionMessages = chunkV2UUGUY4_cjs.getSessionMessages(args.inputs.agentId);
|
|
7338
7449
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7339
7450
|
return createLocalRun({
|
|
7340
7451
|
agentId: args.inputs.agentId,
|
|
@@ -7352,8 +7463,8 @@ async function createFixtureRunHelper(args) {
|
|
|
7352
7463
|
});
|
|
7353
7464
|
}
|
|
7354
7465
|
async function dispatchLocalRun(args) {
|
|
7355
|
-
const apiKey =
|
|
7356
|
-
if (
|
|
7466
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(args.inputs.options.apiKey);
|
|
7467
|
+
if (chunkHLPSLDGL_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7357
7468
|
return createRealLocalRun(
|
|
7358
7469
|
buildRealRunOptions({
|
|
7359
7470
|
inputs: args.inputs,
|
|
@@ -7388,20 +7499,20 @@ async function readProjectMcpServers(cwd) {
|
|
|
7388
7499
|
|
|
7389
7500
|
// src/internal/local-agent/local-agent-invalidate.ts
|
|
7390
7501
|
async function applyDeferredInvalidation(agentId, pending, refresh) {
|
|
7391
|
-
|
|
7502
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] applying deferred cache invalidation (${agentId}): ${pending.reason}
|
|
7392
7503
|
`);
|
|
7393
7504
|
try {
|
|
7394
7505
|
await refresh();
|
|
7395
7506
|
} catch (err) {
|
|
7396
7507
|
const msg = err instanceof Error ? err.message : String(err);
|
|
7397
|
-
|
|
7508
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] invalidateCache reload failed (continuing): ${msg}
|
|
7398
7509
|
`);
|
|
7399
7510
|
}
|
|
7400
7511
|
}
|
|
7401
7512
|
async function invalidateCacheImpl(agentId, reason, options, disposed, dispose, setPending) {
|
|
7402
7513
|
if (disposed) return;
|
|
7403
7514
|
if (options.applyNow === true) {
|
|
7404
|
-
|
|
7515
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] invalidateCache applyNow disposing agent (${agentId}): ${reason}
|
|
7405
7516
|
`);
|
|
7406
7517
|
await dispose();
|
|
7407
7518
|
return;
|
|
@@ -7462,7 +7573,7 @@ var LiveAgentRegistry = class {
|
|
|
7462
7573
|
const existing = this.#agents.get(id);
|
|
7463
7574
|
if (existing !== void 0 && existing.agent !== agent) {
|
|
7464
7575
|
void existing.agent.dispose().catch(() => {
|
|
7465
|
-
|
|
7576
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] dispose during overwrite failed (${id})
|
|
7466
7577
|
`);
|
|
7467
7578
|
});
|
|
7468
7579
|
}
|
|
@@ -7566,7 +7677,7 @@ var LiveAgentRegistry = class {
|
|
|
7566
7677
|
await agent.dispose();
|
|
7567
7678
|
} catch (cause) {
|
|
7568
7679
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7569
|
-
|
|
7680
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] dispose during eviction failed (${id}): ${msg}
|
|
7570
7681
|
`);
|
|
7571
7682
|
}
|
|
7572
7683
|
if (this.#onEvict !== void 0) {
|
|
@@ -7574,7 +7685,7 @@ var LiveAgentRegistry = class {
|
|
|
7574
7685
|
this.#onEvict(id, reason);
|
|
7575
7686
|
} catch (cause) {
|
|
7576
7687
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7577
|
-
|
|
7688
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] onEvict listener threw (${id}): ${msg}
|
|
7578
7689
|
`);
|
|
7579
7690
|
}
|
|
7580
7691
|
}
|
|
@@ -7590,7 +7701,7 @@ async function acquireLeaseIfPossible(store, agentId) {
|
|
|
7590
7701
|
await a.call(store, agentId);
|
|
7591
7702
|
} catch (err) {
|
|
7592
7703
|
if (err instanceof Error && err.name === "SessionBusyError") throw err;
|
|
7593
|
-
|
|
7704
|
+
chunkNUKRL3I6_cjs.diag(
|
|
7594
7705
|
`[theokit-sdk] writer lease unavailable for ${agentId} (${err instanceof Error ? err.message : String(err)}) \u2014 proceeding without single-writer protection
|
|
7595
7706
|
`
|
|
7596
7707
|
);
|
|
@@ -7607,18 +7718,18 @@ async function disposeSessionStore(store) {
|
|
|
7607
7718
|
async function disposeLocalAgentSession(agent) {
|
|
7608
7719
|
liveAgentRegistry.forget(agent.agentId);
|
|
7609
7720
|
agent.lifecycleAbortController.abort();
|
|
7610
|
-
await
|
|
7721
|
+
await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
7611
7722
|
disposeSessionMcpClients(agent.agentId);
|
|
7612
|
-
await
|
|
7723
|
+
await chunkV2UUGUY4_cjs.flushSessionWrites();
|
|
7613
7724
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
7614
7725
|
await disposeSessionStore(agent.sessionStore);
|
|
7615
|
-
|
|
7726
|
+
chunkV2UUGUY4_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
7616
7727
|
}
|
|
7617
7728
|
async function reloadLocalAgent(agent) {
|
|
7618
7729
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
7619
7730
|
if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
|
|
7620
7731
|
if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
|
|
7621
|
-
return await
|
|
7732
|
+
return await chunkHJBMA5MB_cjs.loadSubagents(
|
|
7622
7733
|
agent.workspaceCwd,
|
|
7623
7734
|
agent.settingSourcesIncludeProject,
|
|
7624
7735
|
agent.options.agents
|
|
@@ -7626,12 +7737,12 @@ async function reloadLocalAgent(agent) {
|
|
|
7626
7737
|
}
|
|
7627
7738
|
async function persistActiveMemoryTranscript(cwd, transcript) {
|
|
7628
7739
|
try {
|
|
7629
|
-
const dir = path.join(
|
|
7740
|
+
const dir = path.join(chunk5UOVYM3P_cjs.memoryDir(cwd), "transcripts", "active-memory");
|
|
7630
7741
|
const file = path.join(dir, `${transcript.runId}.json`);
|
|
7631
|
-
await
|
|
7742
|
+
await chunkI6TGFUCO_cjs.atomicWriteJson(file, transcript);
|
|
7632
7743
|
} catch (cause) {
|
|
7633
7744
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7634
|
-
|
|
7745
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] active-memory transcript persist failed: ${message}
|
|
7635
7746
|
`);
|
|
7636
7747
|
}
|
|
7637
7748
|
}
|
|
@@ -7752,7 +7863,7 @@ async function searchOnce(args, cfg, query, started) {
|
|
|
7752
7863
|
return { summary, durationMs: Date.now() - started, status: "ok", hits };
|
|
7753
7864
|
} catch (cause) {
|
|
7754
7865
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7755
|
-
|
|
7866
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] active-memory recall failed: ${message}
|
|
7756
7867
|
`);
|
|
7757
7868
|
return { summary: void 0, durationMs: Date.now() - started, status: "error", hits: [] };
|
|
7758
7869
|
}
|
|
@@ -7872,7 +7983,7 @@ var azureOpenAiMemoryEmbeddingProviderAdapter = {
|
|
|
7872
7983
|
transport: "remote",
|
|
7873
7984
|
authProviderId: "azure-openai",
|
|
7874
7985
|
autoSelectPriority: 25,
|
|
7875
|
-
create: (options) =>
|
|
7986
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7876
7987
|
{
|
|
7877
7988
|
id: "azure-openai",
|
|
7878
7989
|
defaultBaseUrl: "https://your-resource.openai.azure.com",
|
|
@@ -7908,7 +8019,7 @@ var cohereMemoryEmbeddingProviderAdapter = {
|
|
|
7908
8019
|
transport: "remote",
|
|
7909
8020
|
authProviderId: "cohere",
|
|
7910
8021
|
autoSelectPriority: 30,
|
|
7911
|
-
create: (options) =>
|
|
8022
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7912
8023
|
{
|
|
7913
8024
|
id: "cohere",
|
|
7914
8025
|
defaultBaseUrl: "https://api.cohere.com",
|
|
@@ -7954,7 +8065,7 @@ var deepinfraMemoryEmbeddingProviderAdapter = {
|
|
|
7954
8065
|
transport: "remote",
|
|
7955
8066
|
authProviderId: "deepinfra",
|
|
7956
8067
|
autoSelectPriority: 13,
|
|
7957
|
-
create: (options) =>
|
|
8068
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7958
8069
|
{
|
|
7959
8070
|
id: "deepinfra",
|
|
7960
8071
|
defaultBaseUrl: "https://api.deepinfra.com",
|
|
@@ -7980,7 +8091,7 @@ var geminiMemoryEmbeddingProviderAdapter = {
|
|
|
7980
8091
|
transport: "remote",
|
|
7981
8092
|
authProviderId: "gemini",
|
|
7982
8093
|
autoSelectPriority: 30,
|
|
7983
|
-
create: (options) =>
|
|
8094
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7984
8095
|
{
|
|
7985
8096
|
id: "gemini",
|
|
7986
8097
|
defaultBaseUrl: "https://generativelanguage.googleapis.com",
|
|
@@ -8008,7 +8119,7 @@ var jinaMemoryEmbeddingProviderAdapter = {
|
|
|
8008
8119
|
transport: "remote",
|
|
8009
8120
|
authProviderId: "jina",
|
|
8010
8121
|
autoSelectPriority: 35,
|
|
8011
|
-
create: (options) =>
|
|
8122
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8012
8123
|
{
|
|
8013
8124
|
id: "jina",
|
|
8014
8125
|
defaultBaseUrl: "https://api.jina.ai",
|
|
@@ -8031,7 +8142,7 @@ var mistralMemoryEmbeddingProviderAdapter = {
|
|
|
8031
8142
|
transport: "remote",
|
|
8032
8143
|
authProviderId: "mistral",
|
|
8033
8144
|
autoSelectPriority: 18,
|
|
8034
|
-
create: (options) =>
|
|
8145
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8035
8146
|
{
|
|
8036
8147
|
id: "mistral",
|
|
8037
8148
|
defaultBaseUrl: "https://api.mistral.ai",
|
|
@@ -8073,7 +8184,7 @@ var ollamaMemoryEmbeddingProviderAdapter = {
|
|
|
8073
8184
|
autoSelectPriority: 10,
|
|
8074
8185
|
create: (options) => {
|
|
8075
8186
|
const apiKey = options.apiKey ?? process.env.OLLAMA_API_KEY ?? OLLAMA_LOCAL_SENTINEL_KEY;
|
|
8076
|
-
return
|
|
8187
|
+
return chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8077
8188
|
{
|
|
8078
8189
|
id: "ollama",
|
|
8079
8190
|
defaultBaseUrl: "http://localhost:11434",
|
|
@@ -8100,7 +8211,7 @@ var openAiMemoryEmbeddingProviderAdapter = {
|
|
|
8100
8211
|
transport: "remote",
|
|
8101
8212
|
authProviderId: "openai",
|
|
8102
8213
|
autoSelectPriority: 20,
|
|
8103
|
-
create: (options) =>
|
|
8214
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8104
8215
|
{
|
|
8105
8216
|
id: "openai",
|
|
8106
8217
|
defaultBaseUrl: "https://api.openai.com",
|
|
@@ -8127,7 +8238,7 @@ var openRouterMemoryEmbeddingProviderAdapter = {
|
|
|
8127
8238
|
transport: "remote",
|
|
8128
8239
|
authProviderId: "openrouter",
|
|
8129
8240
|
autoSelectPriority: 15,
|
|
8130
|
-
create: (options) =>
|
|
8241
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8131
8242
|
{
|
|
8132
8243
|
id: "openrouter",
|
|
8133
8244
|
defaultBaseUrl: "https://openrouter.ai/api",
|
|
@@ -8155,7 +8266,7 @@ var voyageMemoryEmbeddingProviderAdapter = {
|
|
|
8155
8266
|
transport: "remote",
|
|
8156
8267
|
authProviderId: "voyage",
|
|
8157
8268
|
autoSelectPriority: 14,
|
|
8158
|
-
create: (options) =>
|
|
8269
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8159
8270
|
{
|
|
8160
8271
|
id: "voyage",
|
|
8161
8272
|
defaultBaseUrl: "https://api.voyageai.com",
|
|
@@ -8256,7 +8367,7 @@ function createMemorySearchTool(opts) {
|
|
|
8256
8367
|
};
|
|
8257
8368
|
}
|
|
8258
8369
|
function createMemoryGetTool(opts) {
|
|
8259
|
-
const memoryRoot = path.resolve(
|
|
8370
|
+
const memoryRoot = path.resolve(chunk5UOVYM3P_cjs.memoryDir(opts.cwd));
|
|
8260
8371
|
return {
|
|
8261
8372
|
name: "memory_get",
|
|
8262
8373
|
description: GET_DESCRIPTION,
|
|
@@ -8267,7 +8378,7 @@ function createMemoryGetTool(opts) {
|
|
|
8267
8378
|
const lines = readNumber(input.lines);
|
|
8268
8379
|
const resolved = path.resolve(memoryRoot, relPath);
|
|
8269
8380
|
if (!isPathInside(memoryRoot, resolved)) {
|
|
8270
|
-
throw new
|
|
8381
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8271
8382
|
`memory_get rejected path that escapes memory root: ${relPath}`,
|
|
8272
8383
|
{ code: "memory_path_escapes_root" }
|
|
8273
8384
|
);
|
|
@@ -8287,7 +8398,7 @@ function readString(value, errorIfMissing, allowUndefined = false) {
|
|
|
8287
8398
|
if (typeof value === "string") return value;
|
|
8288
8399
|
if (allowUndefined && (value === void 0 || value === null)) return "";
|
|
8289
8400
|
if (errorIfMissing !== void 0) {
|
|
8290
|
-
throw new
|
|
8401
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(errorIfMissing, { code: "memory_tool_bad_args" });
|
|
8291
8402
|
}
|
|
8292
8403
|
return "";
|
|
8293
8404
|
}
|
|
@@ -8362,7 +8473,7 @@ var LocalAgentMemory = class {
|
|
|
8362
8473
|
const openOpts = { cwd: this.workspaceCwd };
|
|
8363
8474
|
if (embedding !== void 0) openOpts.embedding = embedding;
|
|
8364
8475
|
if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
|
|
8365
|
-
this.index = await
|
|
8476
|
+
this.index = await chunk5UOVYM3P_cjs.IndexManager.open(openOpts);
|
|
8366
8477
|
await this.index.sync();
|
|
8367
8478
|
this.toolsCache = [
|
|
8368
8479
|
createMemorySearchTool({ index: this.index }),
|
|
@@ -8377,7 +8488,7 @@ var LocalAgentMemory = class {
|
|
|
8377
8488
|
const warned2 = g[sym];
|
|
8378
8489
|
if (!warned2.has(message)) {
|
|
8379
8490
|
warned2.add(message);
|
|
8380
|
-
|
|
8491
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] memory tools unavailable: ${message}
|
|
8381
8492
|
`);
|
|
8382
8493
|
}
|
|
8383
8494
|
return void 0;
|
|
@@ -8386,7 +8497,7 @@ var LocalAgentMemory = class {
|
|
|
8386
8497
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8387
8498
|
const cfg = this.options.memory?.activeRecall;
|
|
8388
8499
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8389
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8500
|
+
if (this.breaker === void 0) this.breaker = new chunkHLPSLDGL_cjs.CircuitBreaker();
|
|
8390
8501
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8391
8502
|
const result = await runActiveMemory({
|
|
8392
8503
|
userText,
|
|
@@ -8436,7 +8547,7 @@ var LocalAgentMemory = class {
|
|
|
8436
8547
|
await this.index.sync();
|
|
8437
8548
|
} catch (cause) {
|
|
8438
8549
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8439
|
-
|
|
8550
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] session index sync failed: ${message}
|
|
8440
8551
|
`);
|
|
8441
8552
|
}
|
|
8442
8553
|
}
|
|
@@ -8449,7 +8560,7 @@ var LocalAgentMemory = class {
|
|
|
8449
8560
|
return await adapter.create(cfg.model !== void 0 ? { model: cfg.model } : {});
|
|
8450
8561
|
} catch (cause) {
|
|
8451
8562
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8452
|
-
|
|
8563
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] memory embedding ${cfg.provider} unavailable: ${message}
|
|
8453
8564
|
`);
|
|
8454
8565
|
return void 0;
|
|
8455
8566
|
}
|
|
@@ -8457,22 +8568,33 @@ var LocalAgentMemory = class {
|
|
|
8457
8568
|
};
|
|
8458
8569
|
|
|
8459
8570
|
// src/internal/local-agent/local-agent-memory-direct.ts
|
|
8571
|
+
async function createAvailableAdapters(entries, workspaceCwd) {
|
|
8572
|
+
const available = [];
|
|
8573
|
+
for (const entry of entries) {
|
|
8574
|
+
const instance = await entry.createProvider(workspaceCwd);
|
|
8575
|
+
if (instance.isAvailable() === false) {
|
|
8576
|
+
chunkNUKRL3I6_cjs.diag(
|
|
8577
|
+
`[theokit-sdk] memory adapter "${instance.id}" reports itself unavailable (plugin "${entry.pluginName}") \u2014 skipping it. Check its credentials.
|
|
8578
|
+
`
|
|
8579
|
+
);
|
|
8580
|
+
continue;
|
|
8581
|
+
}
|
|
8582
|
+
available.push(instance);
|
|
8583
|
+
}
|
|
8584
|
+
return available;
|
|
8585
|
+
}
|
|
8460
8586
|
function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
8461
8587
|
let resolved;
|
|
8462
8588
|
async function ensure() {
|
|
8463
8589
|
if (resolved !== void 0) return resolved;
|
|
8464
8590
|
const entries = pluginManager.aggregated.memoryProviders;
|
|
8465
|
-
const created =
|
|
8466
|
-
for (const entry of entries) {
|
|
8467
|
-
const instance = await entry.createProvider(workspaceCwd);
|
|
8468
|
-
created.push(instance);
|
|
8469
|
-
}
|
|
8591
|
+
const created = await createAvailableAdapters(entries, workspaceCwd);
|
|
8470
8592
|
for (const adapter of created) {
|
|
8471
8593
|
if (adapter.initialize !== void 0) {
|
|
8472
8594
|
await adapter.initialize();
|
|
8473
8595
|
}
|
|
8474
8596
|
}
|
|
8475
|
-
resolved = { adapters: created, initialized: true };
|
|
8597
|
+
resolved = { adapters: created, initialized: true, registered: entries.length };
|
|
8476
8598
|
return resolved;
|
|
8477
8599
|
}
|
|
8478
8600
|
function mergeContext(partial) {
|
|
@@ -8485,7 +8607,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8485
8607
|
...partial?.metadata !== void 0 ? { metadata: partial.metadata } : defaultContext?.metadata !== void 0 ? { metadata: defaultContext.metadata } : {}
|
|
8486
8608
|
};
|
|
8487
8609
|
if (merged.userId === "") {
|
|
8488
|
-
throw new
|
|
8610
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8489
8611
|
"agent.memory requires a userId \u2014 either set AgentOptions.memoryContext.userId or pass ctx.userId at call time.",
|
|
8490
8612
|
{ code: "memory_context_missing_user_id" }
|
|
8491
8613
|
);
|
|
@@ -8495,8 +8617,8 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8495
8617
|
async function requireAdapters() {
|
|
8496
8618
|
const r = await ensure();
|
|
8497
8619
|
if (r.adapters.length === 0) {
|
|
8498
|
-
throw new
|
|
8499
|
-
"No memory adapter registered. Pass a memory plugin in AgentOptions.plugins (e.g. supermemoryMemory({...}))."
|
|
8620
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8621
|
+
r.registered === 0 ? "No memory adapter registered. Pass a memory plugin in AgentOptions.plugins (e.g. supermemoryMemory({...}))." : `All ${r.registered} registered memory adapter(s) reported themselves unavailable \u2014 see the warnings naming each one. Check their credentials.`,
|
|
8500
8622
|
{ code: "no_memory_adapter" }
|
|
8501
8623
|
);
|
|
8502
8624
|
}
|
|
@@ -8536,7 +8658,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8536
8658
|
const prefix = id.split(":", 1)[0] ?? "";
|
|
8537
8659
|
const target = adapters.find((a) => a.id === prefix);
|
|
8538
8660
|
if (target === void 0) {
|
|
8539
|
-
throw new
|
|
8661
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8540
8662
|
`No adapter found for MemoryId prefix "${prefix}" (registered: ${adapters.map((a) => a.id).join(", ")}).`,
|
|
8541
8663
|
{ code: "no_memory_adapter" }
|
|
8542
8664
|
);
|
|
@@ -8609,7 +8731,7 @@ function createLocalAgentMemoryProvider(opts) {
|
|
|
8609
8731
|
return { facts: [], systemPromptAdditions: summary };
|
|
8610
8732
|
},
|
|
8611
8733
|
async recordSessionSummary(args) {
|
|
8612
|
-
await
|
|
8734
|
+
await chunk5UOVYM3P_cjs.writeSessionSummary(args);
|
|
8613
8735
|
},
|
|
8614
8736
|
async sync(handle) {
|
|
8615
8737
|
const state = handle[INTERNAL_LAM_KEY];
|
|
@@ -8687,19 +8809,19 @@ var PersonalityRegistry = class _PersonalityRegistry {
|
|
|
8687
8809
|
function addEntity(byName, entity, origin, collisionMap) {
|
|
8688
8810
|
const fm = entity.frontmatter;
|
|
8689
8811
|
if (PersonalityRegistry.isReservedClearSlug(fm.name)) {
|
|
8690
|
-
throw new
|
|
8812
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8691
8813
|
`Personality name "${fm.name}" is reserved (used to clear active preset)`,
|
|
8692
8814
|
{ code: "personality_reserved_name" }
|
|
8693
8815
|
);
|
|
8694
8816
|
}
|
|
8695
8817
|
if (entity.body.trim().length === 0) {
|
|
8696
|
-
throw new
|
|
8818
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8697
8819
|
`Personality "${fm.name}" has empty body (system prompt required)`,
|
|
8698
8820
|
{ code: "personality_empty_body" }
|
|
8699
8821
|
);
|
|
8700
8822
|
}
|
|
8701
8823
|
if (origin === "project" && collisionMap?.has(fm.name)) {
|
|
8702
|
-
|
|
8824
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
8703
8825
|
`personality-collision-${fm.name}`,
|
|
8704
8826
|
`[theokit-sdk] personality "${fm.name}" overridden by project preset`
|
|
8705
8827
|
);
|
|
@@ -8728,7 +8850,7 @@ async function performPersonalitySwitch(args) {
|
|
|
8728
8850
|
const preset = args.registry.get(args.requestedName);
|
|
8729
8851
|
if (preset === void 0) {
|
|
8730
8852
|
const available = args.registry.all().map((p) => p.name).join(", ") || "(none)";
|
|
8731
|
-
throw new
|
|
8853
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8732
8854
|
`Personality "${args.requestedName}" not found. Available: ${available}`,
|
|
8733
8855
|
{ code: "personality_not_found" }
|
|
8734
8856
|
);
|
|
@@ -8749,14 +8871,14 @@ async function performPersonalitySwitch(args) {
|
|
|
8749
8871
|
|
|
8750
8872
|
// src/internal/local-agent/local-agent-personality-extensions.ts
|
|
8751
8873
|
function resolveActivePersonalityPreset(args) {
|
|
8752
|
-
const forkCtx =
|
|
8874
|
+
const forkCtx = chunk53CBTBWO_cjs.currentPersonalityContext();
|
|
8753
8875
|
const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
|
|
8754
8876
|
if (slug === void 0) return void 0;
|
|
8755
8877
|
return args.personalityRegistry?.get(slug);
|
|
8756
8878
|
}
|
|
8757
8879
|
async function ensurePersonalityRegistryIfNeeded(args) {
|
|
8758
8880
|
if (args.personalityRegistry !== void 0) return args.personalityRegistry;
|
|
8759
|
-
const forkSlug =
|
|
8881
|
+
const forkSlug = chunk53CBTBWO_cjs.currentPersonalityContext()?.slug;
|
|
8760
8882
|
const ownSlug = args.personalityStore.active(args.agentId);
|
|
8761
8883
|
if (forkSlug === void 0 && ownSlug === void 0) return void 0;
|
|
8762
8884
|
return await PersonalityRegistry.load(args.workspaceCwd);
|
|
@@ -8770,8 +8892,8 @@ ${preset.systemPrompt}`;
|
|
|
8770
8892
|
}
|
|
8771
8893
|
async function localAgentUsePersonality(args) {
|
|
8772
8894
|
if (args.disposed) throw new Error("Agent has been disposed");
|
|
8773
|
-
if (
|
|
8774
|
-
|
|
8895
|
+
if (chunk53CBTBWO_cjs.currentPersonalityContext() !== void 0) {
|
|
8896
|
+
chunk53CBTBWO_cjs.warnPersonalitySwitchInsideFork(args.agentId);
|
|
8775
8897
|
return null;
|
|
8776
8898
|
}
|
|
8777
8899
|
let registry = args.personalityRegistry;
|
|
@@ -8779,7 +8901,7 @@ async function localAgentUsePersonality(args) {
|
|
|
8779
8901
|
registry = await PersonalityRegistry.load(args.workspaceCwd);
|
|
8780
8902
|
args.onRegistryLoaded(registry);
|
|
8781
8903
|
}
|
|
8782
|
-
return
|
|
8904
|
+
return chunkZF2LDKQQ_cjs.withCwdMutex(
|
|
8783
8905
|
`agent-send:${args.agentId}`,
|
|
8784
8906
|
() => performPersonalitySwitch({
|
|
8785
8907
|
agentId: args.agentId,
|
|
@@ -8788,8 +8910,8 @@ async function localAgentUsePersonality(args) {
|
|
|
8788
8910
|
registry,
|
|
8789
8911
|
store: args.personalityStore,
|
|
8790
8912
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
8791
|
-
appendSessionMessage: (msg) =>
|
|
8792
|
-
clearSession: () =>
|
|
8913
|
+
appendSessionMessage: (msg) => chunkV2UUGUY4_cjs.appendSessionMessage(args.agentId, msg),
|
|
8914
|
+
clearSession: () => chunkV2UUGUY4_cjs.clearSession(args.agentId),
|
|
8793
8915
|
opts: args.opts ?? {}
|
|
8794
8916
|
})
|
|
8795
8917
|
);
|
|
@@ -8800,7 +8922,7 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
8800
8922
|
async function* wrap() {
|
|
8801
8923
|
const { runUntilImpl } = await import('./run-until-U2B5FJJI.cjs');
|
|
8802
8924
|
const buildDeps = async () => {
|
|
8803
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
8925
|
+
const { judgeCallImpl } = await import('./judge-call-EGYRC2RE.cjs');
|
|
8804
8926
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
8805
8927
|
const create = getAgentFacade().create;
|
|
8806
8928
|
return {
|
|
@@ -8821,19 +8943,19 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
8821
8943
|
}
|
|
8822
8944
|
function localAgentRunToCompletion(agent, message, options) {
|
|
8823
8945
|
async function run() {
|
|
8824
|
-
const { runToCompletionImpl } = await import('./run-to-completion-
|
|
8946
|
+
const { runToCompletionImpl } = await import('./run-to-completion-X4OWM673.cjs');
|
|
8825
8947
|
return runToCompletionImpl({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
8826
8948
|
}
|
|
8827
8949
|
return run();
|
|
8828
8950
|
}
|
|
8829
8951
|
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
8830
|
-
const { streamToCompletionImpl } = await import('./stream-to-completion-
|
|
8952
|
+
const { streamToCompletionImpl } = await import('./stream-to-completion-SRISU5AB.cjs');
|
|
8831
8953
|
return yield* streamToCompletionImpl({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
8832
8954
|
}
|
|
8833
8955
|
async function localAgentFork(parent, options) {
|
|
8834
8956
|
const { forkAgentImpl } = await import('./fork-agent-Y2IK2RYU.cjs');
|
|
8835
8957
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
8836
|
-
const { withPersonalityContext } = await import('./context-
|
|
8958
|
+
const { withPersonalityContext } = await import('./context-VMIE4BMD.cjs');
|
|
8837
8959
|
const create = getAgentFacade().create;
|
|
8838
8960
|
return withPersonalityContext(
|
|
8839
8961
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
@@ -8893,7 +9015,7 @@ function wrapRunWithCompletionCheck(args) {
|
|
|
8893
9015
|
judgeOpts
|
|
8894
9016
|
);
|
|
8895
9017
|
const complete = !verdict.parseFailed && verdict.verdict === "done";
|
|
8896
|
-
|
|
9018
|
+
chunkNGESVVJN_cjs.emitRunEvent(args.onRunEvent, {
|
|
8897
9019
|
type: "completion_check",
|
|
8898
9020
|
complete,
|
|
8899
9021
|
reason: verdict.reason
|
|
@@ -9040,7 +9162,7 @@ function wrapRunWithOutputProcessors(args) {
|
|
|
9040
9162
|
if (result.status !== "finished" || result.result === void 0) return result;
|
|
9041
9163
|
const res = await runOutputProcessors(args.processors, result.result, args.agentId);
|
|
9042
9164
|
if (res.kind === "ok") return { ...result, result: res.value };
|
|
9043
|
-
|
|
9165
|
+
chunkNGESVVJN_cjs.emitRunEvent(args.onRunEvent, {
|
|
9044
9166
|
type: "tripwire",
|
|
9045
9167
|
reason: res.tripwire.reason,
|
|
9046
9168
|
processorId: res.tripwire.processorId
|
|
@@ -9083,6 +9205,15 @@ ${recalled}
|
|
|
9083
9205
|
${args.userText}`;
|
|
9084
9206
|
return typeof args.original === "string" ? wrapped : { ...args.original, text: wrapped };
|
|
9085
9207
|
}
|
|
9208
|
+
async function runCalledATool(run) {
|
|
9209
|
+
try {
|
|
9210
|
+
for await (const event of run.stream()) {
|
|
9211
|
+
if (event.type === "tool_call") return true;
|
|
9212
|
+
}
|
|
9213
|
+
} catch {
|
|
9214
|
+
}
|
|
9215
|
+
return false;
|
|
9216
|
+
}
|
|
9086
9217
|
function wrapRunWithPostReplyHook(args) {
|
|
9087
9218
|
const handlers = args.pluginManager.hooksFor("post_assistant_reply");
|
|
9088
9219
|
if (handlers.length === 0) return args.run;
|
|
@@ -9094,6 +9225,12 @@ function wrapRunWithPostReplyHook(args) {
|
|
|
9094
9225
|
reply: replyText,
|
|
9095
9226
|
agentId: args.agentId,
|
|
9096
9227
|
runId: result.id,
|
|
9228
|
+
// #358 — whether this reply is safely replayable. A consumer (the semantic cache) must not
|
|
9229
|
+
// re-serve an answer produced by a tool call, and had nothing to key on. The run knows:
|
|
9230
|
+
// `stream()` replays its buffered events after `wait()` (ADR 0006), so a `tool_call` among
|
|
9231
|
+
// them is the signal. Computed here, inside a path that only runs when a hook is registered
|
|
9232
|
+
// and is already fire-and-forget, so it never lands on the caller's critical path.
|
|
9233
|
+
usedTools: await runCalledATool(args.run),
|
|
9097
9234
|
...args.options.memoryContext !== void 0 ? { memoryContext: args.options.memoryContext } : {}
|
|
9098
9235
|
};
|
|
9099
9236
|
void args.pluginManager.runPostAssistantReplyHooks(ctx);
|
|
@@ -9115,7 +9252,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9115
9252
|
}
|
|
9116
9253
|
const res = await runInputProcessors(processors, rawUserText, inputs.agentId);
|
|
9117
9254
|
if (res.kind === "tripwire") {
|
|
9118
|
-
|
|
9255
|
+
chunkNGESVVJN_cjs.emitRunEvent(options.onRunEvent, {
|
|
9119
9256
|
type: "tripwire",
|
|
9120
9257
|
reason: res.tripwire.reason,
|
|
9121
9258
|
processorId: res.tripwire.processorId
|
|
@@ -9132,7 +9269,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9132
9269
|
return { userText: res.value, effectiveMessage };
|
|
9133
9270
|
}
|
|
9134
9271
|
async function executeSendLocked(inputs, message, options) {
|
|
9135
|
-
if (inputs.disposed) throw new
|
|
9272
|
+
if (inputs.disposed) throw new chunkK3FW2XZD_cjs.AgentDisposedError(inputs.agentId);
|
|
9136
9273
|
await consumePending(inputs.agentId, inputs.invalidationPending, inputs.clearInvalidation, inputs.reload);
|
|
9137
9274
|
const sendModel = normalizeModel(options.model);
|
|
9138
9275
|
inputs.applyModelOverride(sendModel);
|
|
@@ -9143,7 +9280,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9143
9280
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9144
9281
|
await inputs.options.onBeforeSend({
|
|
9145
9282
|
conversationId: inputs.agentId,
|
|
9146
|
-
previousMessageCount:
|
|
9283
|
+
previousMessageCount: chunkV2UUGUY4_cjs.getSessionMessages(inputs.agentId).length
|
|
9147
9284
|
});
|
|
9148
9285
|
}
|
|
9149
9286
|
await inputs.runPreHook(userText);
|
|
@@ -9155,8 +9292,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9155
9292
|
userText,
|
|
9156
9293
|
sendOptions: options
|
|
9157
9294
|
});
|
|
9158
|
-
const priorMessages = [...
|
|
9159
|
-
|
|
9295
|
+
const priorMessages = [...chunkV2UUGUY4_cjs.getSessionMessages(inputs.agentId)];
|
|
9296
|
+
chunkV2UUGUY4_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9160
9297
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9161
9298
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
|
|
9162
9299
|
const portPathActive = shouldUsePortMemoryPath();
|
|
@@ -9214,7 +9351,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9214
9351
|
function buildCompletionCheckDeps() {
|
|
9215
9352
|
return {
|
|
9216
9353
|
judge: async (ctx, opts) => {
|
|
9217
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9354
|
+
const { judgeCallImpl } = await import('./judge-call-EGYRC2RE.cjs');
|
|
9218
9355
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9219
9356
|
return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
|
|
9220
9357
|
}
|
|
@@ -9234,7 +9371,7 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
|
|
|
9234
9371
|
promptPreview: userText.slice(0, 120),
|
|
9235
9372
|
...opts.meta ?? {}
|
|
9236
9373
|
};
|
|
9237
|
-
void
|
|
9374
|
+
void chunkNGESVVJN_cjs.submit({
|
|
9238
9375
|
kind: "run",
|
|
9239
9376
|
work: async (ctx) => {
|
|
9240
9377
|
ctx.signal.addEventListener(
|
|
@@ -9319,7 +9456,7 @@ var LocalAgent = class {
|
|
|
9319
9456
|
this.options = options;
|
|
9320
9457
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
9321
9458
|
this.transcriptBaseDir = resolveSessionDir(options.local);
|
|
9322
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
9459
|
+
this.sessionStore = options.local?.sessionStore ?? new chunkYPJ5NH5N_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
9323
9460
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
9324
9461
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
9325
9462
|
const sub = bootstrapSubmanagers({
|
|
@@ -9362,14 +9499,14 @@ var LocalAgent = class {
|
|
|
9362
9499
|
if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
|
|
9363
9500
|
const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
|
|
9364
9501
|
await this.pluginManagerCode.initialize(codePlugins);
|
|
9365
|
-
this.resolvedSubagents = await
|
|
9502
|
+
this.resolvedSubagents = await chunkHJBMA5MB_cjs.loadSubagents(
|
|
9366
9503
|
this.workspaceCwd,
|
|
9367
9504
|
this.settingSourcesIncludeProject,
|
|
9368
9505
|
this.options.agents
|
|
9369
9506
|
);
|
|
9370
9507
|
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9371
9508
|
try {
|
|
9372
|
-
await
|
|
9509
|
+
await chunkV2UUGUY4_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9373
9510
|
await this.personalityStore.hydrate(this.agentId);
|
|
9374
9511
|
} catch (err) {
|
|
9375
9512
|
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
@@ -9391,14 +9528,14 @@ var LocalAgent = class {
|
|
|
9391
9528
|
}
|
|
9392
9529
|
async send(message, options = {}) {
|
|
9393
9530
|
if (options.tools !== void 0 && options.tools.length > 0) {
|
|
9394
|
-
validateToolCatalog(options.tools);
|
|
9531
|
+
validateToolCatalog(options.tools, this.options.withheldBuiltinTools);
|
|
9395
9532
|
}
|
|
9396
9533
|
const sendSpan = this._telemetry.startSpan(SPAN_NAMES.AGENT_SEND, {
|
|
9397
9534
|
agentId: this.agentId,
|
|
9398
9535
|
...this.model?.id !== void 0 ? { model: this.model.id } : {}
|
|
9399
9536
|
});
|
|
9400
9537
|
return new Promise((resolve, reject) => {
|
|
9401
|
-
void
|
|
9538
|
+
void chunkZF2LDKQQ_cjs.withCwdMutex(
|
|
9402
9539
|
`agent-send:${this.agentId}`,
|
|
9403
9540
|
() => this.runLockedSendCycle(message, options, sendSpan, resolve, reject)
|
|
9404
9541
|
);
|
|
@@ -9449,6 +9586,8 @@ var LocalAgent = class {
|
|
|
9449
9586
|
...options.onRunEvent !== void 0 ? { onRunEvent: options.onRunEvent } : {},
|
|
9450
9587
|
hooksExecutor: this.hooksExecutor,
|
|
9451
9588
|
memoryGlue: this.memoryGlue,
|
|
9589
|
+
// usetheokit/theokit-sdk#382 — the transcript write reads this and nothing else.
|
|
9590
|
+
memory: this.options.memory,
|
|
9452
9591
|
...postRunProvider !== void 0 ? { memoryProvider: postRunProvider } : {}
|
|
9453
9592
|
});
|
|
9454
9593
|
} finally {
|
|
@@ -9518,7 +9657,7 @@ var LocalAgent = class {
|
|
|
9518
9657
|
agentId: this.agentId
|
|
9519
9658
|
});
|
|
9520
9659
|
if (preRun.blocked) {
|
|
9521
|
-
throw new
|
|
9660
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
9522
9661
|
`preRun hook denied execution: ${preRun.reason ?? "unspecified"}`,
|
|
9523
9662
|
{ code: "hook_denied" }
|
|
9524
9663
|
);
|
|
@@ -9599,7 +9738,7 @@ var LocalAgent = class {
|
|
|
9599
9738
|
}
|
|
9600
9739
|
// biome-ignore format: G8 budget — see listArtifacts.
|
|
9601
9740
|
downloadArtifact(_path) {
|
|
9602
|
-
return Promise.reject(new
|
|
9741
|
+
return Promise.reject(new chunkK3FW2XZD_cjs.UnsupportedRunOperationError("Artifacts are not supported for local agents", "downloadArtifact"));
|
|
9603
9742
|
}
|
|
9604
9743
|
// biome-ignore format: G8 budget — delegates to `local-agent-runtime-extensions.ts`; kept 1-line.
|
|
9605
9744
|
runUntil(goal, options) {
|
|
@@ -9644,7 +9783,7 @@ async function guardAgainstIdCollision(options) {
|
|
|
9644
9783
|
const persistenceCwd = resolveAgentPersistenceCwd(options);
|
|
9645
9784
|
await hydrateRegistryFromDisk(persistenceCwd);
|
|
9646
9785
|
if (getRegisteredAgent(options.agentId) !== void 0) {
|
|
9647
|
-
throw new
|
|
9786
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
9648
9787
|
`Agent "${options.agentId}" already exists. Use Agent.resume("${options.agentId}") to reattach, or pick a different agentId.`,
|
|
9649
9788
|
{ code: "agent_id_already_exists" }
|
|
9650
9789
|
);
|
|
@@ -9677,7 +9816,7 @@ async function maybeInjectHandoffTools(options) {
|
|
|
9677
9816
|
const spec = "@theokit/sdk-handoff/internal/tool-injector";
|
|
9678
9817
|
mod = await import(spec);
|
|
9679
9818
|
} catch (err) {
|
|
9680
|
-
throw new
|
|
9819
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
9681
9820
|
"Agent.create({ handoffs: [...] }) requires @theokit/sdk-handoff. Install it: pnpm add @theokit/sdk-handoff. Or migrate to the preferred plugin pattern: plugins: [Handoff.asPlugin({ targets: [...] })] (see docs/migration/1-x-to-2-0.md#handoff).",
|
|
9682
9821
|
{ code: "handoff_package_missing", cause: err }
|
|
9683
9822
|
);
|
|
@@ -9694,47 +9833,57 @@ async function maybeInjectHandoffTools(options) {
|
|
|
9694
9833
|
tools: [...existingTools, ...handoffTools]
|
|
9695
9834
|
};
|
|
9696
9835
|
}
|
|
9836
|
+
function keyWillFlowToProvider(apiKey, provider) {
|
|
9837
|
+
if (chunkHLPSLDGL_cjs.isFixtureApiKey(apiKey)) return false;
|
|
9838
|
+
if (chunkHLPSLDGL_cjs.getConfiguredBaseUrl() !== void 0) return false;
|
|
9839
|
+
if (provider === void 0) return false;
|
|
9840
|
+
const profile = chunk6HTXPPHK_cjs.getProviderProfile(provider);
|
|
9841
|
+
if (profile === void 0) return false;
|
|
9842
|
+
return profile.authType !== "none";
|
|
9843
|
+
}
|
|
9844
|
+
function missingApiKeyMessage() {
|
|
9845
|
+
const present = chunkHLPSLDGL_cjs.presentProviderCredentialEnvVars();
|
|
9846
|
+
const base = `Missing API key \u2014 set ${chunkJTB5Q42C_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
|
|
9847
|
+
if (present.length === 0) return `${base}.`;
|
|
9848
|
+
return `${base}. ${present.join(" and ")} ${present.length === 1 ? "is" : "are"} set, but a provider credential is not read from the environment automatically \u2014 pass it explicitly, e.g. \`Agent.create({ apiKey: process.env.${present[0]}, ... })\`.`;
|
|
9849
|
+
}
|
|
9697
9850
|
async function createLocalAgent(options) {
|
|
9698
|
-
const apiKey =
|
|
9851
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.apiKey);
|
|
9699
9852
|
if (apiKey === void 0) {
|
|
9700
|
-
throw new
|
|
9853
|
+
throw new chunkK3FW2XZD_cjs.AuthenticationError(missingApiKeyMessage(), { code: "missing_api_key" });
|
|
9701
9854
|
}
|
|
9702
|
-
const
|
|
9855
|
+
const provider = providerFromModelId(normalizeModel(options.model)?.id);
|
|
9856
|
+
const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
|
|
9703
9857
|
const shape = validateApiKeyShape(apiKey, {
|
|
9704
9858
|
strict: willFlowToProvider,
|
|
9705
9859
|
// `options.model` is already normalized by `runCreateUnderSpan`; `normalizeModel`
|
|
9706
9860
|
// here is the idempotent narrowing of the widened public type (`{id}` passes
|
|
9707
9861
|
// through by reference) — cleaner than an `as` cast.
|
|
9708
|
-
...willFlowToProvider ? { provider
|
|
9862
|
+
...willFlowToProvider ? { provider } : {}
|
|
9709
9863
|
});
|
|
9710
9864
|
if (shape.malformed) {
|
|
9711
|
-
throw new
|
|
9712
|
-
}
|
|
9713
|
-
if (!chunk2FYEVT2B_cjs.isFixtureApiKey(apiKey) && chunk2FYEVT2B_cjs.getConfiguredBaseUrl() === void 0 && !chunk2FYEVT2B_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
9714
|
-
throw new chunkLPVIRJVF_cjs.AuthenticationError("Invalid API key", {
|
|
9715
|
-
code: "authentication_error"
|
|
9716
|
-
});
|
|
9865
|
+
throw new chunkK3FW2XZD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
9717
9866
|
}
|
|
9718
9867
|
const agent = new LocalAgent(options);
|
|
9719
9868
|
await agent.initialize();
|
|
9720
9869
|
return agent;
|
|
9721
9870
|
}
|
|
9722
9871
|
async function createCloudAgent(options) {
|
|
9723
|
-
const apiKey =
|
|
9872
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.apiKey);
|
|
9724
9873
|
if (apiKey === void 0) {
|
|
9725
|
-
throw new
|
|
9874
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError("Missing API key for cloud agent", {
|
|
9726
9875
|
code: "missing_api_key"
|
|
9727
9876
|
});
|
|
9728
9877
|
}
|
|
9729
9878
|
const shape = validateApiKeyShape(apiKey);
|
|
9730
9879
|
if (shape.malformed) {
|
|
9731
|
-
throw new
|
|
9880
|
+
throw new chunkK3FW2XZD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
9732
9881
|
}
|
|
9733
|
-
const baseUrl =
|
|
9882
|
+
const baseUrl = chunkHLPSLDGL_cjs.getConfiguredBaseUrl();
|
|
9734
9883
|
if (baseUrl === void 0) {
|
|
9735
9884
|
return new CloudAgent(options);
|
|
9736
9885
|
}
|
|
9737
|
-
const response = await
|
|
9886
|
+
const response = await chunkHLPSLDGL_cjs.httpRequest("/v1/agents", {
|
|
9738
9887
|
apiKey,
|
|
9739
9888
|
method: "POST",
|
|
9740
9889
|
body: {
|
|
@@ -9759,7 +9908,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
9759
9908
|
return process.cwd();
|
|
9760
9909
|
}
|
|
9761
9910
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
9762
|
-
await
|
|
9911
|
+
await chunkHLPSLDGL_cjs.discoverProviderPlugins();
|
|
9763
9912
|
await validateRehydratedAgent(agentId, existing);
|
|
9764
9913
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
9765
9914
|
const mergedOptions = {
|
|
@@ -9790,7 +9939,7 @@ async function validateRehydratedAgent(agentId, entry) {
|
|
|
9790
9939
|
throw new Error(`Workspace path is not a directory: ${candidate}`);
|
|
9791
9940
|
}
|
|
9792
9941
|
} catch (cause) {
|
|
9793
|
-
throw new
|
|
9942
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
9794
9943
|
`Agent "${agentId}" cannot be rehydrated \u2014 workspace cwd "${candidate}" is missing or inaccessible.`,
|
|
9795
9944
|
{ code: "agent_rehydration_failed", cause }
|
|
9796
9945
|
);
|
|
@@ -9835,17 +9984,33 @@ async function setAgentName(agentId, name) {
|
|
|
9835
9984
|
updateRegisteredAgent(agentId, { name });
|
|
9836
9985
|
await flushRegistrySaves();
|
|
9837
9986
|
}
|
|
9838
|
-
async function getRegisteredAgentOrThrow(agentId) {
|
|
9987
|
+
async function getRegisteredAgentOrThrow(agentId, cwd = process.cwd()) {
|
|
9839
9988
|
let agent = getRegisteredAgent(agentId);
|
|
9840
9989
|
if (agent === void 0) {
|
|
9841
|
-
await hydrateRegistryFromDisk(
|
|
9990
|
+
await hydrateRegistryFromDisk(cwd);
|
|
9842
9991
|
agent = getRegisteredAgent(agentId);
|
|
9843
9992
|
}
|
|
9844
9993
|
if (agent === void 0) {
|
|
9845
|
-
throw new
|
|
9994
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(`Agent ${agentId} not found`, { code: "unknown_agent" });
|
|
9846
9995
|
}
|
|
9847
9996
|
return agent;
|
|
9848
9997
|
}
|
|
9998
|
+
function paginateByKey(all, keyOf, limit, cursor, sortByKey) {
|
|
9999
|
+
if (limit === void 0) return { items: [...all] };
|
|
10000
|
+
const ordered = sortByKey ? [...all].sort((a, b) => {
|
|
10001
|
+
const ka = keyOf(a);
|
|
10002
|
+
const kb = keyOf(b);
|
|
10003
|
+
return ka < kb ? -1 : ka > kb ? 1 : 0;
|
|
10004
|
+
}) : [...all];
|
|
10005
|
+
const startIndex = cursor === void 0 ? 0 : ordered.findIndex((item) => keyOf(item) === cursor) + 1;
|
|
10006
|
+
const page = ordered.slice(startIndex, startIndex + limit);
|
|
10007
|
+
const hasMore = startIndex + limit < ordered.length;
|
|
10008
|
+
const last = page[page.length - 1];
|
|
10009
|
+
return {
|
|
10010
|
+
items: page,
|
|
10011
|
+
...hasMore && last !== void 0 ? { nextCursor: keyOf(last) } : {}
|
|
10012
|
+
};
|
|
10013
|
+
}
|
|
9849
10014
|
|
|
9850
10015
|
// src/agent.ts
|
|
9851
10016
|
var streamObjectImport;
|
|
@@ -9887,7 +10052,7 @@ var Agent = class _Agent {
|
|
|
9887
10052
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
9888
10053
|
});
|
|
9889
10054
|
try {
|
|
9890
|
-
await
|
|
10055
|
+
await chunkHLPSLDGL_cjs.discoverProviderPlugins();
|
|
9891
10056
|
const agent = await runCreateUnderSpan(options, span);
|
|
9892
10057
|
return agent;
|
|
9893
10058
|
} catch (err) {
|
|
@@ -9928,8 +10093,8 @@ var Agent = class _Agent {
|
|
|
9928
10093
|
const run = await agent.send(message);
|
|
9929
10094
|
const result = await run.wait();
|
|
9930
10095
|
if (options.throwOnError === true && result.status === "error" && result.error !== void 0) {
|
|
9931
|
-
throw new
|
|
9932
|
-
code:
|
|
10096
|
+
throw new chunkK3FW2XZD_cjs.AgentRunError(result.error.message, {
|
|
10097
|
+
code: chunkK3FW2XZD_cjs.coerceToKnownAgentRunErrorCode(result.error.code),
|
|
9933
10098
|
cause: result.error.cause
|
|
9934
10099
|
});
|
|
9935
10100
|
}
|
|
@@ -9956,7 +10121,7 @@ var Agent = class _Agent {
|
|
|
9956
10121
|
if (existing !== void 0) {
|
|
9957
10122
|
return await rehydrateExistingAgent(agentId, existing, options);
|
|
9958
10123
|
}
|
|
9959
|
-
throw new
|
|
10124
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
9960
10125
|
`Agent "${agentId}" not found. Use Agent.create({ agentId, ... }) for first-time setup, or catch UnknownAgentError to branch resume-vs-create.`,
|
|
9961
10126
|
{ code: "unknown_agent" }
|
|
9962
10127
|
);
|
|
@@ -9985,7 +10150,7 @@ var Agent = class _Agent {
|
|
|
9985
10150
|
* @public
|
|
9986
10151
|
*/
|
|
9987
10152
|
static async generateObject(options) {
|
|
9988
|
-
const { generateObjectImpl } = await import('./generate-object-
|
|
10153
|
+
const { generateObjectImpl } = await import('./generate-object-PGSP5U7N.cjs');
|
|
9989
10154
|
return generateObjectImpl(options, {
|
|
9990
10155
|
create: (opts) => _Agent.create(opts),
|
|
9991
10156
|
delete: (agentId) => _Agent.delete(agentId)
|
|
@@ -10009,7 +10174,7 @@ var Agent = class _Agent {
|
|
|
10009
10174
|
delete: (agentId) => _Agent.delete(agentId)
|
|
10010
10175
|
};
|
|
10011
10176
|
async function* wrapper() {
|
|
10012
|
-
streamObjectImport ??= import('./stream-object-
|
|
10177
|
+
streamObjectImport ??= import('./stream-object-BUCF5PHO.cjs');
|
|
10013
10178
|
const { streamObjectImpl } = await streamObjectImport;
|
|
10014
10179
|
yield* streamObjectImpl(options, deps);
|
|
10015
10180
|
}
|
|
@@ -10033,7 +10198,7 @@ var Agent = class _Agent {
|
|
|
10033
10198
|
* @public
|
|
10034
10199
|
*/
|
|
10035
10200
|
static async batch(prompts, options) {
|
|
10036
|
-
const { batchImpl } = await import('./batch-
|
|
10201
|
+
const { batchImpl } = await import('./batch-ND32UKZS.cjs');
|
|
10037
10202
|
return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
|
|
10038
10203
|
}
|
|
10039
10204
|
/**
|
|
@@ -10077,34 +10242,57 @@ var Agent = class _Agent {
|
|
|
10077
10242
|
return fresh;
|
|
10078
10243
|
}
|
|
10079
10244
|
/**
|
|
10080
|
-
* List agents (local or cloud). M107 — `cwd` is READ
|
|
10081
|
-
* `limit`/`cursor`
|
|
10245
|
+
* List agents (local or cloud). M107 — `cwd` is READ, not ignored. B-115 (2026-08-19) —
|
|
10246
|
+
* `includeArchived` and `limit`/`cursor` are READ too now; see `ListAgentsOptions`'s doc for the
|
|
10247
|
+
* pagination contract and why the unlimited (no `limit`) case is unaffected.
|
|
10082
10248
|
*
|
|
10083
10249
|
* @public
|
|
10084
10250
|
*/
|
|
10085
10251
|
static async list(options = {}) {
|
|
10086
10252
|
const cwd = ("cwd" in options ? options.cwd : void 0) ?? process.cwd();
|
|
10087
10253
|
await hydrateRegistryFromDisk(cwd);
|
|
10088
|
-
const
|
|
10089
|
-
|
|
10254
|
+
const includeArchived = "includeArchived" in options ? options.includeArchived ?? false : false;
|
|
10255
|
+
const agents2 = listRegisteredAgents(options.runtime, cwd, includeArchived);
|
|
10256
|
+
const { items, nextCursor } = paginateByKey(
|
|
10257
|
+
agents2,
|
|
10258
|
+
(agent) => agent.agentId,
|
|
10259
|
+
options.limit,
|
|
10260
|
+
options.cursor,
|
|
10261
|
+
/* sortByKey */
|
|
10262
|
+
true
|
|
10263
|
+
);
|
|
10264
|
+
return {
|
|
10265
|
+
items: items.map((agent) => toAgentInfo(agent)),
|
|
10266
|
+
...nextCursor !== void 0 ? { nextCursor } : {}
|
|
10267
|
+
};
|
|
10090
10268
|
}
|
|
10091
10269
|
/**
|
|
10092
|
-
* Get metadata for a single agent.
|
|
10270
|
+
* Get metadata for a single agent. B-115 (2026-08-19) — `cwd` is READ now (see
|
|
10271
|
+
* `GetAgentOptions`'s doc); it used to be accepted and silently ignored.
|
|
10093
10272
|
*
|
|
10094
10273
|
* @public
|
|
10095
10274
|
*/
|
|
10096
|
-
static async get(agentId,
|
|
10097
|
-
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10275
|
+
static async get(agentId, options = {}) {
|
|
10276
|
+
const agent = await getRegisteredAgentOrThrow(agentId, options.cwd);
|
|
10098
10277
|
return toAgentInfo(agent);
|
|
10099
10278
|
}
|
|
10100
10279
|
/**
|
|
10101
|
-
* List runs for an agent.
|
|
10280
|
+
* List runs for an agent. B-115 (2026-08-19) — `cwd` and `limit`/`cursor` are READ now (see
|
|
10281
|
+
* `ListRunsOptions`'s doc); they used to be accepted and silently ignored.
|
|
10102
10282
|
*
|
|
10103
10283
|
* @public
|
|
10104
10284
|
*/
|
|
10105
|
-
static async listRuns(agentId,
|
|
10106
|
-
await getRegisteredAgentOrThrow(agentId);
|
|
10107
|
-
|
|
10285
|
+
static async listRuns(agentId, options = {}) {
|
|
10286
|
+
await getRegisteredAgentOrThrow(agentId, options.cwd);
|
|
10287
|
+
const { items, nextCursor } = paginateByKey(
|
|
10288
|
+
listRunsByAgent(agentId),
|
|
10289
|
+
(run) => run.id,
|
|
10290
|
+
options.limit,
|
|
10291
|
+
options.cursor,
|
|
10292
|
+
/* sortByKey */
|
|
10293
|
+
false
|
|
10294
|
+
);
|
|
10295
|
+
return { items, ...nextCursor !== void 0 ? { nextCursor } : {} };
|
|
10108
10296
|
}
|
|
10109
10297
|
/**
|
|
10110
10298
|
* Get a single run.
|
|
@@ -10113,14 +10301,14 @@ var Agent = class _Agent {
|
|
|
10113
10301
|
*/
|
|
10114
10302
|
static async getRun(runId, options = {}) {
|
|
10115
10303
|
if (options.runtime === "cloud") {
|
|
10116
|
-
throw new
|
|
10304
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
10117
10305
|
"Cloud runtime is pre-release. Theo PaaS endpoints are not wired yet \u2014 getRun({ runtime: 'cloud' }) will be enabled when the PaaS ships.",
|
|
10118
10306
|
{ code: "cloud_runtime_pre_release" }
|
|
10119
10307
|
);
|
|
10120
10308
|
}
|
|
10121
10309
|
const existing = getRun(runId);
|
|
10122
10310
|
if (existing !== void 0) return existing;
|
|
10123
|
-
throw new
|
|
10311
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10124
10312
|
`Run ${runId} is not in this process's registry. It may have been disposed, persisted in a previous process, or never created.`,
|
|
10125
10313
|
{ code: "run_not_found" }
|
|
10126
10314
|
);
|
|
@@ -10167,13 +10355,13 @@ var Agent = class _Agent {
|
|
|
10167
10355
|
reg = getRegisteredAgent(agentId);
|
|
10168
10356
|
}
|
|
10169
10357
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10170
|
-
throw new
|
|
10358
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10171
10359
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10172
10360
|
);
|
|
10173
10361
|
}
|
|
10174
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10362
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-LEWF554G.cjs');
|
|
10175
10363
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10176
|
-
return
|
|
10364
|
+
return chunkV2UUGUY4_cjs.enqueueSessionWrite(
|
|
10177
10365
|
cwd,
|
|
10178
10366
|
agentId,
|
|
10179
10367
|
() => compactSessionTranscript({
|
|
@@ -10203,11 +10391,11 @@ var Agent = class _Agent {
|
|
|
10203
10391
|
reg = getRegisteredAgent(agentId);
|
|
10204
10392
|
}
|
|
10205
10393
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10206
|
-
throw new
|
|
10394
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10207
10395
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10208
10396
|
);
|
|
10209
10397
|
}
|
|
10210
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10398
|
+
const { injectSessionTurn } = await import('./inject-session-WQGGMCQY.cjs');
|
|
10211
10399
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10212
10400
|
await injectSessionTurn({
|
|
10213
10401
|
store,
|
|
@@ -10242,11 +10430,11 @@ var Agent = class _Agent {
|
|
|
10242
10430
|
reg = getRegisteredAgent(agentId);
|
|
10243
10431
|
}
|
|
10244
10432
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10245
|
-
throw new
|
|
10433
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10246
10434
|
`No local agent "${agentId}" registered \u2014 transcript targets local sessions.`
|
|
10247
10435
|
);
|
|
10248
10436
|
}
|
|
10249
|
-
const { readSessionMessages } = await import('./agent-session-store-
|
|
10437
|
+
const { readSessionMessages } = await import('./agent-session-store-ZJ3JSRS4.cjs');
|
|
10250
10438
|
const { store } = await openLocalStore(reg);
|
|
10251
10439
|
return readSessionMessages(store, agentId);
|
|
10252
10440
|
}
|
|
@@ -10267,7 +10455,7 @@ var Agent = class _Agent {
|
|
|
10267
10455
|
*/
|
|
10268
10456
|
static async describe(agentId) {
|
|
10269
10457
|
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10270
|
-
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-
|
|
10458
|
+
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-AZIXJ7D3.cjs');
|
|
10271
10459
|
const settingSources = agent.options.local?.settingSources;
|
|
10272
10460
|
const subagents = await loadSubagents2(
|
|
10273
10461
|
agent.cwd ?? process.cwd(),
|
|
@@ -10282,7 +10470,7 @@ var Agent = class _Agent {
|
|
|
10282
10470
|
//
|
|
10283
10471
|
// Honest limit, stated because the alternative is an implied claim: `tools` is still the
|
|
10284
10472
|
// DECLARED catalog. Plugin tools and the reasoning `think` tool are assembled per run by
|
|
10285
|
-
// `
|
|
10473
|
+
// `buildRunToolCatalogInput`, so they are not knowable from the registry alone. Documented on
|
|
10286
10474
|
// `AgentDescription.tools`.
|
|
10287
10475
|
tools: (agent.options.tools ?? []).map((tool) => ({
|
|
10288
10476
|
name: tool.name,
|
|
@@ -10311,12 +10499,12 @@ async function getOrCreateUncached(agentId, options) {
|
|
|
10311
10499
|
try {
|
|
10312
10500
|
return await Agent.resume(agentId, options);
|
|
10313
10501
|
} catch (err) {
|
|
10314
|
-
if (!(err instanceof
|
|
10502
|
+
if (!(err instanceof chunkK3FW2XZD_cjs.UnknownAgentError)) throw err;
|
|
10315
10503
|
}
|
|
10316
10504
|
try {
|
|
10317
10505
|
return await Agent.create({ ...options, agentId });
|
|
10318
10506
|
} catch (err) {
|
|
10319
|
-
if (err instanceof
|
|
10507
|
+
if (err instanceof chunkK3FW2XZD_cjs.ConfigurationError && err.code === "agent_id_already_exists") {
|
|
10320
10508
|
return await Agent.resume(agentId, options);
|
|
10321
10509
|
}
|
|
10322
10510
|
throw err;
|
|
@@ -10334,8 +10522,8 @@ async function openLocalStore(reg) {
|
|
|
10334
10522
|
const cwd = reg.cwd ?? process.cwd();
|
|
10335
10523
|
const optModel = reg.options.model;
|
|
10336
10524
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
10337
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
10338
|
-
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-
|
|
10525
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-3MOJQGP2.cjs');
|
|
10526
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-JXHFTB7G.cjs');
|
|
10339
10527
|
const configuredSessionDir = reg.options.local?.sessionDir ?? reg.options.local?.baseDir;
|
|
10340
10528
|
const baseDir = configuredSessionDir !== void 0 ? expandTilde2(configuredSessionDir) : defaultBaseDir2();
|
|
10341
10529
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
@@ -10352,5 +10540,5 @@ exports.computeCost = computeCost;
|
|
|
10352
10540
|
exports.generateCronId = generateCronId;
|
|
10353
10541
|
exports.getPricingEntry = getPricingEntry;
|
|
10354
10542
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10355
|
-
//# sourceMappingURL=chunk-
|
|
10356
|
-
//# sourceMappingURL=chunk-
|
|
10543
|
+
//# sourceMappingURL=chunk-F5WMX4EA.cjs.map
|
|
10544
|
+
//# sourceMappingURL=chunk-F5WMX4EA.cjs.map
|