@theokit/sdk 4.53.1 → 4.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1088 -0
- package/README.md +9 -4
- package/dist/a2a/agent-mailbox.d.cts +27 -0
- package/dist/a2a/agent-mailbox.d.ts +27 -0
- package/dist/a2a/index.cjs +9 -4
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +7 -2
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/message-bus.d.cts +39 -0
- package/dist/a2a/message-bus.d.ts +39 -0
- package/dist/a2a/subagent.d.cts +68 -7
- package/dist/a2a/subagent.d.ts +68 -7
- package/dist/a2a/types.d.cts +26 -0
- package/dist/a2a/types.d.ts +26 -0
- package/dist/{agent-B9HXlwID.d.ts → agent-CIUgz7cN.d.cts} +190 -850
- package/dist/{agent-nLqeXKIX.d.cts → agent-DSec-E0c.d.ts} +190 -850
- package/dist/agent-NOEGF4GI.cjs +61 -0
- package/dist/{agent-YLAHVHEH.cjs.map → agent-NOEGF4GI.cjs.map} +1 -1
- package/dist/agent-VGD5WL4N.js +52 -0
- package/dist/{agent-FFVV4U5N.js.map → agent-VGD5WL4N.js.map} +1 -1
- package/dist/agent-builder.d.ts +19 -0
- package/dist/agent-session-store-P6V3FINW.js +7 -0
- package/dist/{agent-session-store-TNCGL5RN.js.map → agent-session-store-P6V3FINW.js.map} +1 -1
- package/dist/agent-session-store-ZJ3JSRS4.cjs +24 -0
- package/dist/{agent-session-store-DUGBAX5V.cjs.map → agent-session-store-ZJ3JSRS4.cjs.map} +1 -1
- package/dist/agent.d.ts +9 -6
- package/dist/auth/index.cjs +52 -35
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.js +26 -9
- package/dist/auth/index.js.map +1 -1
- package/dist/{batch-UPKN4SG6.js → batch-2TGJMNCJ.js} +14 -13
- package/dist/batch-2TGJMNCJ.js.map +1 -0
- package/dist/{batch-ZEFN5SO7.cjs → batch-ND32UKZS.cjs} +31 -30
- package/dist/batch-ND32UKZS.cjs.map +1 -0
- package/dist/{chunk-TTJ54H3E.cjs → chunk-2ADR2GSO.cjs} +8 -8
- package/dist/chunk-2ADR2GSO.cjs.map +1 -0
- package/dist/{chunk-VGPXHHF3.cjs → chunk-2C72DXQF.cjs} +63 -27
- package/dist/chunk-2C72DXQF.cjs.map +1 -0
- package/dist/{chunk-4Q4K4WB5.js → chunk-2D34UTDC.js} +20 -4
- package/dist/chunk-2D34UTDC.js.map +1 -0
- package/dist/{chunk-UFIXH26P.js → chunk-2QKTVKH3.js} +4 -4
- package/dist/{chunk-UFIXH26P.js.map → chunk-2QKTVKH3.js.map} +1 -1
- package/dist/{chunk-GBBDINFK.js → chunk-3E77SX4H.js} +4 -4
- package/dist/{chunk-GBBDINFK.js.map → chunk-3E77SX4H.js.map} +1 -1
- package/dist/{chunk-VYHJZVL5.cjs → chunk-3EE6LVWT.cjs} +2 -2
- package/dist/chunk-3EE6LVWT.cjs.map +1 -0
- package/dist/chunk-3KGLRRFC.cjs +18 -0
- package/dist/chunk-3KGLRRFC.cjs.map +1 -0
- package/dist/{chunk-5NBUH3NO.js → chunk-3OR54XG4.js} +2 -2
- package/dist/{chunk-C6Y6CWYD.cjs.map → chunk-3OR54XG4.js.map} +1 -1
- package/dist/{chunk-ZN2DGEY3.cjs → chunk-3YJNUKYN.cjs} +15 -15
- package/dist/{chunk-ZN2DGEY3.cjs.map → chunk-3YJNUKYN.cjs.map} +1 -1
- package/dist/{chunk-POWRZSK4.js → chunk-44JAAH4X.js} +3 -3
- package/dist/{chunk-POWRZSK4.js.map → chunk-44JAAH4X.js.map} +1 -1
- package/dist/{chunk-SSDD676S.js → chunk-44MBDIHG.js} +4 -4
- package/dist/{chunk-SSDD676S.js.map → chunk-44MBDIHG.js.map} +1 -1
- package/dist/{chunk-OY7O3Q6R.js → chunk-4ERPXIVB.js} +5 -5
- package/dist/{chunk-OY7O3Q6R.js.map → chunk-4ERPXIVB.js.map} +1 -1
- package/dist/{chunk-3BK6YR5P.cjs → chunk-4I55V454.cjs} +4 -4
- package/dist/{chunk-3BK6YR5P.cjs.map → chunk-4I55V454.cjs.map} +1 -1
- package/dist/{chunk-B4YA6BRS.cjs → chunk-4O5TGQBW.cjs} +30 -7
- package/dist/chunk-4O5TGQBW.cjs.map +1 -0
- package/dist/{chunk-4JBHSLQO.cjs → chunk-4OTIXDMU.cjs} +2 -2
- package/dist/{chunk-4JBHSLQO.cjs.map → chunk-4OTIXDMU.cjs.map} +1 -1
- package/dist/{chunk-C6Y6CWYD.cjs → chunk-52NKC5HT.cjs} +2 -2
- package/dist/chunk-52NKC5HT.cjs.map +1 -0
- package/dist/{chunk-665SFFFR.cjs → chunk-53CBTBWO.cjs} +11 -11
- package/dist/{chunk-665SFFFR.cjs.map → chunk-53CBTBWO.cjs.map} +1 -1
- package/dist/{chunk-2D43RD5D.cjs → chunk-5BJV5UPY.cjs} +27 -27
- package/dist/chunk-5BJV5UPY.cjs.map +1 -0
- package/dist/{chunk-FFM3SJTQ.js → chunk-5JLFFPCH.js} +4 -4
- package/dist/{chunk-FFM3SJTQ.js.map → chunk-5JLFFPCH.js.map} +1 -1
- package/dist/{chunk-34XOCZJO.js → chunk-5PHVENFV.js} +3 -3
- package/dist/chunk-5PHVENFV.js.map +1 -0
- package/dist/{chunk-BDTVFIPB.cjs → chunk-5UOVYM3P.cjs} +36 -31
- package/dist/chunk-5UOVYM3P.cjs.map +1 -0
- package/dist/{chunk-VF7X6HDR.cjs → chunk-5USCYPPI.cjs} +15 -15
- package/dist/{chunk-VF7X6HDR.cjs.map → chunk-5USCYPPI.cjs.map} +1 -1
- package/dist/{chunk-D24WJWN2.js → chunk-AEOZTXVW.js} +3 -3
- package/dist/{chunk-D24WJWN2.js.map → chunk-AEOZTXVW.js.map} +1 -1
- package/dist/{chunk-DGOG5NXR.js → chunk-AG5JPQIY.js} +3 -3
- package/dist/{chunk-DGOG5NXR.js.map → chunk-AG5JPQIY.js.map} +1 -1
- package/dist/{chunk-V6HWJQQV.js → chunk-AGSBJD2L.js} +27 -30
- package/dist/chunk-AGSBJD2L.js.map +1 -0
- package/dist/{chunk-BFYGJGC5.js → chunk-AQLGBKNT.js} +3 -3
- package/dist/chunk-AQLGBKNT.js.map +1 -0
- package/dist/{chunk-7W7ZWMLQ.js → chunk-AWO27VRZ.js} +3 -3
- package/dist/chunk-AWO27VRZ.js.map +1 -0
- package/dist/{chunk-VYCKUKPA.cjs → chunk-B2J4ZMZL.cjs} +3 -2
- package/dist/chunk-B2J4ZMZL.cjs.map +1 -0
- package/dist/{chunk-BERBYXFH.js → chunk-BMAZLQQ4.js} +3 -3
- package/dist/{chunk-BERBYXFH.js.map → chunk-BMAZLQQ4.js.map} +1 -1
- package/dist/{chunk-5YKNEMXR.cjs → chunk-BVZW2B5V.cjs} +4 -4
- package/dist/chunk-BVZW2B5V.cjs.map +1 -0
- package/dist/{chunk-MSFLYJDY.js → chunk-CQ2TQ32Y.js} +4 -4
- package/dist/chunk-CQ2TQ32Y.js.map +1 -0
- package/dist/{chunk-C5DEO6OI.cjs → chunk-CQGYNZ3K.cjs} +4 -4
- package/dist/{chunk-C5DEO6OI.cjs.map → chunk-CQGYNZ3K.cjs.map} +1 -1
- package/dist/{chunk-D75S2X6I.cjs → chunk-CTCGWIUD.cjs} +5 -5
- package/dist/{chunk-D75S2X6I.cjs.map → chunk-CTCGWIUD.cjs.map} +1 -1
- package/dist/{chunk-NZL4BNFQ.js → chunk-CV7XMBHP.js} +4 -4
- package/dist/chunk-CV7XMBHP.js.map +1 -0
- package/dist/{chunk-SEL2ZQMT.js → chunk-DAPSQZT4.js} +15 -10
- package/dist/chunk-DAPSQZT4.js.map +1 -0
- package/dist/{chunk-SVO5WPZX.cjs → chunk-DQKERTND.cjs} +11 -11
- package/dist/{chunk-SVO5WPZX.cjs.map → chunk-DQKERTND.cjs.map} +1 -1
- package/dist/{chunk-GOVJO4YE.js → chunk-DUIF54UP.js} +6 -6
- package/dist/chunk-DUIF54UP.js.map +1 -0
- package/dist/{chunk-N5CR3TJZ.js → chunk-DZBSJX6J.js} +4 -4
- package/dist/{chunk-N5CR3TJZ.js.map → chunk-DZBSJX6J.js.map} +1 -1
- package/dist/{chunk-RAHSWE5C.cjs → chunk-EI2Q7SJ5.cjs} +12 -12
- package/dist/chunk-EI2Q7SJ5.cjs.map +1 -0
- package/dist/{chunk-UCFONJBG.js → chunk-EPSICJLZ.js} +2 -2
- package/dist/{chunk-UCFONJBG.js.map → chunk-EPSICJLZ.js.map} +1 -1
- package/dist/{chunk-3X6PM7DU.cjs → chunk-F3YZMOAU.cjs} +8 -8
- package/dist/{chunk-3X6PM7DU.cjs.map → chunk-F3YZMOAU.cjs.map} +1 -1
- package/dist/{chunk-HE4BIAOS.js → chunk-F7AQV62G.js} +5 -4
- package/dist/chunk-F7AQV62G.js.map +1 -0
- package/dist/{chunk-HSQ5Q3I5.js → chunk-FXEUP75G.js} +5 -5
- package/dist/chunk-FXEUP75G.js.map +1 -0
- package/dist/{chunk-2RW7K6FN.cjs → chunk-GHX4P3V2.cjs} +2 -2
- package/dist/chunk-GHX4P3V2.cjs.map +1 -0
- package/dist/{chunk-B6HOIWQ6.js → chunk-GJ6RK75E.js} +5 -5
- package/dist/chunk-GJ6RK75E.js.map +1 -0
- package/dist/{chunk-FOXKFTVZ.cjs → chunk-GNT35C5U.cjs} +13 -13
- package/dist/chunk-GNT35C5U.cjs.map +1 -0
- package/dist/{chunk-4NAKHID5.js → chunk-GTKFV7O5.js} +2 -2
- package/dist/chunk-GTKFV7O5.js.map +1 -0
- package/dist/{chunk-ELKO4ZLR.cjs → chunk-GWC3HADL.cjs} +4 -4
- package/dist/{chunk-ELKO4ZLR.cjs.map → chunk-GWC3HADL.cjs.map} +1 -1
- package/dist/{chunk-OXNYIMZZ.js → chunk-H73MEMQB.js} +2 -2
- package/dist/chunk-H73MEMQB.js.map +1 -0
- package/dist/{chunk-E7FJOO4G.cjs → chunk-HJBMA5MB.cjs} +11 -11
- package/dist/{chunk-E7FJOO4G.cjs.map → chunk-HJBMA5MB.cjs.map} +1 -1
- package/dist/{chunk-VW6M4B3Z.cjs → chunk-HY57ULY2.cjs} +5 -5
- package/dist/{chunk-VW6M4B3Z.cjs.map → chunk-HY57ULY2.cjs.map} +1 -1
- package/dist/{chunk-CAH3G4IS.js → chunk-HY66GLM6.js} +2 -2
- package/dist/chunk-HY66GLM6.js.map +1 -0
- package/dist/{chunk-C4H6PB5J.cjs → chunk-I6TGFUCO.cjs} +4 -4
- package/dist/{chunk-C4H6PB5J.cjs.map → chunk-I6TGFUCO.cjs.map} +1 -1
- package/dist/{chunk-U4UJHOSH.js → chunk-IDCKSLYH.js} +3 -3
- package/dist/{chunk-U4UJHOSH.js.map → chunk-IDCKSLYH.js.map} +1 -1
- package/dist/{chunk-WQ53UQL4.cjs → chunk-ILCGLTSA.cjs} +4 -4
- package/dist/{chunk-WQ53UQL4.cjs.map → chunk-ILCGLTSA.cjs.map} +1 -1
- package/dist/{chunk-SZHU7A5B.cjs → chunk-IWBGCBR6.cjs} +4 -4
- package/dist/{chunk-SZHU7A5B.cjs.map → chunk-IWBGCBR6.cjs.map} +1 -1
- package/dist/{chunk-Q4RESANI.cjs → chunk-J24VJOH3.cjs} +20 -4
- package/dist/chunk-J24VJOH3.cjs.map +1 -0
- package/dist/{chunk-Y4AXQOT4.cjs → chunk-JHPGF3FP.cjs} +8 -8
- package/dist/{chunk-Y4AXQOT4.cjs.map → chunk-JHPGF3FP.cjs.map} +1 -1
- package/dist/{chunk-BM6N4KHO.cjs → chunk-JTB5Q42C.cjs} +6 -22
- package/dist/chunk-JTB5Q42C.cjs.map +1 -0
- package/dist/{chunk-LPVIRJVF.cjs → chunk-K3FW2XZD.cjs} +9 -9
- package/dist/{chunk-LPVIRJVF.cjs.map → chunk-K3FW2XZD.cjs.map} +1 -1
- package/dist/{chunk-XPR366DL.cjs → chunk-NGESVVJN.cjs} +17 -17
- package/dist/chunk-NGESVVJN.cjs.map +1 -0
- package/dist/{chunk-VC5ABJXC.js → chunk-NLTVXLGT.js} +3 -3
- package/dist/{chunk-VC5ABJXC.js.map → chunk-NLTVXLGT.js.map} +1 -1
- package/dist/chunk-NUKRL3I6.cjs +23 -0
- package/dist/chunk-NUKRL3I6.cjs.map +1 -0
- package/dist/{chunk-R5YZACGK.js → chunk-OC4NTGMN.js} +3 -3
- package/dist/{chunk-R5YZACGK.js.map → chunk-OC4NTGMN.js.map} +1 -1
- package/dist/{chunk-FPYT5WZP.cjs → chunk-P6A3M6VD.cjs} +10 -10
- package/dist/{chunk-FPYT5WZP.cjs.map → chunk-P6A3M6VD.cjs.map} +1 -1
- package/dist/{chunk-OKLYRPKL.cjs → chunk-Q47R5E2X.cjs} +8 -8
- package/dist/chunk-Q47R5E2X.cjs.map +1 -0
- package/dist/{chunk-2XLKLVVR.js → chunk-Q5EWJPRY.js} +2 -2
- package/dist/chunk-Q5EWJPRY.js.map +1 -0
- package/dist/{chunk-SK4QLUBK.js → chunk-QARJGQSA.js} +16 -7
- package/dist/chunk-QARJGQSA.js.map +1 -0
- package/dist/{chunk-CZ2GKKYL.cjs → chunk-QDED6YO6.cjs} +5 -5
- package/dist/{chunk-CZ2GKKYL.cjs.map → chunk-QDED6YO6.cjs.map} +1 -1
- package/dist/{chunk-VK7MAV65.cjs → chunk-QKLOP4VC.cjs} +2 -2
- package/dist/{chunk-VK7MAV65.cjs.map → chunk-QKLOP4VC.cjs.map} +1 -1
- package/dist/{chunk-FIOCJYLA.js → chunk-QRSUA2CV.js} +3 -3
- package/dist/{chunk-FIOCJYLA.js.map → chunk-QRSUA2CV.js.map} +1 -1
- package/dist/{chunk-ZT57WTUJ.cjs → chunk-R3UPQFKK.cjs} +21 -12
- package/dist/chunk-R3UPQFKK.cjs.map +1 -0
- package/dist/{chunk-X2FR4OIT.js → chunk-R7WIIPUR.js} +2 -2
- package/dist/chunk-R7WIIPUR.js.map +1 -0
- package/dist/{chunk-VUKQL3L2.cjs → chunk-RM7Y65IG.cjs} +13 -13
- package/dist/chunk-RM7Y65IG.cjs.map +1 -0
- package/dist/{chunk-RP5HQVLD.js → chunk-RNB4APBZ.js} +30 -7
- package/dist/chunk-RNB4APBZ.js.map +1 -0
- package/dist/{chunk-GD63JPGC.cjs → chunk-ROYPRJH4.cjs} +9 -9
- package/dist/{chunk-GD63JPGC.cjs.map → chunk-ROYPRJH4.cjs.map} +1 -1
- package/dist/{chunk-V26QVGUG.js → chunk-RUDY2GTT.js} +59 -23
- package/dist/chunk-RUDY2GTT.js.map +1 -0
- package/dist/{chunk-JIQRXKTA.cjs → chunk-SKXBJ2NU.cjs} +7 -7
- package/dist/chunk-SKXBJ2NU.cjs.map +1 -0
- package/dist/chunk-SSQZA3DZ.js +15 -0
- package/dist/chunk-SSQZA3DZ.js.map +1 -0
- package/dist/{chunk-XROIW6BH.js → chunk-SUKXXLWD.js} +6 -6
- package/dist/chunk-SUKXXLWD.js.map +1 -0
- package/dist/{chunk-LTSTGCL6.js → chunk-T73NA43R.js} +3 -3
- package/dist/{chunk-LTSTGCL6.js.map → chunk-T73NA43R.js.map} +1 -1
- package/dist/chunk-T7O6K6PX.js +20 -0
- package/dist/chunk-T7O6K6PX.js.map +1 -0
- package/dist/{chunk-5F5NWKPN.js → chunk-T7XEKOVW.js} +5 -20
- package/dist/chunk-T7XEKOVW.js.map +1 -0
- package/dist/{chunk-G3JWXOGY.js → chunk-TPTZA6NI.js} +250 -103
- package/dist/chunk-TPTZA6NI.js.map +1 -0
- package/dist/{chunk-QBTVATSF.cjs → chunk-TTHBHAJI.cjs} +44 -47
- package/dist/chunk-TTHBHAJI.cjs.map +1 -0
- package/dist/{chunk-HAWE74GQ.cjs → chunk-U2AC6JUP.cjs} +8 -8
- package/dist/chunk-U2AC6JUP.cjs.map +1 -0
- package/dist/{chunk-3WVMJY7F.js → chunk-UC3HT2S4.js} +3 -3
- package/dist/{chunk-3WVMJY7F.js.map → chunk-UC3HT2S4.js.map} +1 -1
- package/dist/{chunk-F77UENR6.cjs → chunk-UFAO4T7Z.cjs} +526 -379
- package/dist/chunk-UFAO4T7Z.cjs.map +1 -0
- package/dist/{chunk-2FYEVT2B.cjs → chunk-UNDROG5N.cjs} +201 -154
- package/dist/chunk-UNDROG5N.cjs.map +1 -0
- package/dist/{chunk-PBZ7HMBP.js → chunk-UPRJR6IP.js} +4 -4
- package/dist/chunk-UPRJR6IP.js.map +1 -0
- package/dist/{chunk-3V7UJLQT.js → chunk-UQGQFBRL.js} +3 -3
- package/dist/chunk-UQGQFBRL.js.map +1 -0
- package/dist/{chunk-LS3LMQ23.js → chunk-VDEWG5TV.js} +88 -43
- package/dist/chunk-VDEWG5TV.js.map +1 -0
- package/dist/{chunk-6AZDM6LK.js → chunk-VF7EWVDG.js} +3 -3
- package/dist/{chunk-6AZDM6LK.js.map → chunk-VF7EWVDG.js.map} +1 -1
- package/dist/{chunk-PNVDQL5Y.cjs → chunk-VTYY7XL5.cjs} +2 -2
- package/dist/chunk-VTYY7XL5.cjs.map +1 -0
- package/dist/{chunk-Y4I4EQFK.js → chunk-WKRSH2VR.js} +3 -3
- package/dist/{chunk-Y4I4EQFK.js.map → chunk-WKRSH2VR.js.map} +1 -1
- package/dist/{chunk-4QEC4CCS.js → chunk-WTMU7J4U.js} +2 -2
- package/dist/{chunk-4QEC4CCS.js.map → chunk-WTMU7J4U.js.map} +1 -1
- package/dist/{chunk-KSWHTR54.js → chunk-XN7NOENA.js} +6 -6
- package/dist/chunk-XN7NOENA.js.map +1 -0
- package/dist/{chunk-ADLLFY3H.cjs → chunk-XSX2UU6Y.cjs} +10 -9
- package/dist/chunk-XSX2UU6Y.cjs.map +1 -0
- package/dist/{chunk-LD4MOBFX.js → chunk-XV4IZNV4.js} +9 -9
- package/dist/chunk-XV4IZNV4.js.map +1 -0
- package/dist/{chunk-EZ2YEF4F.cjs → chunk-XWL6O3SW.cjs} +4 -4
- package/dist/chunk-XWL6O3SW.cjs.map +1 -0
- package/dist/{chunk-PGP7IOJ2.js → chunk-YMA4S2WO.js} +4 -4
- package/dist/{chunk-PGP7IOJ2.js.map → chunk-YMA4S2WO.js.map} +1 -1
- package/dist/{chunk-OUOXM36O.cjs → chunk-YPJ5NH5N.cjs} +11 -11
- package/dist/chunk-YPJ5NH5N.cjs.map +1 -0
- package/dist/{chunk-YLQQX5W2.cjs → chunk-ZF2LDKQQ.cjs} +2 -2
- package/dist/chunk-ZF2LDKQQ.cjs.map +1 -0
- package/dist/{chunk-L5YO6PWL.cjs → chunk-ZNW6V4Y6.cjs} +2 -2
- package/dist/chunk-ZNW6V4Y6.cjs.map +1 -0
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/theokit-client.d.cts +36 -0
- package/dist/client/theokit-client.d.ts +36 -0
- package/dist/client/types.d.cts +30 -0
- package/dist/client/types.d.ts +30 -0
- package/dist/compact-session-K5LXTBPJ.js +22 -0
- package/dist/{compact-session-4MNKNMO2.js.map → compact-session-K5LXTBPJ.js.map} +1 -1
- package/dist/compact-session-YCT6JMBX.cjs +59 -0
- package/dist/{compact-session-EPFBQ46Z.cjs.map → compact-session-YCT6JMBX.cjs.map} +1 -1
- package/dist/compaction.cjs +17 -16
- package/dist/compaction.d.cts +13 -13
- package/dist/compaction.d.ts +13 -13
- package/dist/compaction.js +4 -3
- package/dist/concurrency.cjs +7 -6
- package/dist/concurrency.cjs.map +1 -1
- package/dist/concurrency.js +5 -4
- package/dist/concurrency.js.map +1 -1
- package/dist/context/index.cjs +7 -7
- package/dist/context/index.js +3 -3
- package/dist/context-FDOON2DB.js +6 -0
- package/dist/{context-ENXZNF6J.js.map → context-FDOON2DB.js.map} +1 -1
- package/dist/context-VMIE4BMD.cjs +23 -0
- package/dist/{context-7USNN6LP.cjs.map → context-VMIE4BMD.cjs.map} +1 -1
- package/dist/cron-CRwy2JBF.d.ts +240 -0
- package/dist/cron-DxxeQ-sK.d.cts +240 -0
- package/dist/cron.cjs +43 -41
- package/dist/cron.d.cts +5 -3
- package/dist/cron.d.ts +5 -3
- package/dist/cron.js +42 -40
- package/dist/define-tool.d.ts +14 -6
- package/dist/{errors-BSoXcl3F.d.cts → errors-BgJH9PHi.d.cts} +39 -24
- package/dist/{errors-CHllybaU.d.ts → errors-C5fJUqLk.d.ts} +39 -24
- package/dist/errors.cjs +22 -21
- package/dist/errors.d.cts +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +3 -2
- package/dist/eval.cjs +61 -58
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.d.cts +38 -0
- package/dist/eval.d.ts +38 -0
- package/dist/eval.js +51 -48
- package/dist/eval.js.map +1 -1
- package/dist/event-bus.d.ts +16 -0
- package/dist/{executor-2Z6XJJJG.js → executor-BMEHFOXZ.js} +8 -7
- package/dist/executor-BMEHFOXZ.js.map +1 -0
- package/dist/{executor-2Z3LGG3I.cjs → executor-ZERJ3DGN.cjs} +25 -24
- package/dist/executor-ZERJ3DGN.cjs.map +1 -0
- package/dist/filesystem/index.cjs +8 -7
- package/dist/filesystem/index.cjs.map +1 -1
- package/dist/filesystem/index.js +4 -3
- package/dist/filesystem/index.js.map +1 -1
- package/dist/filesystem/local-filesystem.d.cts +18 -0
- package/dist/filesystem/local-filesystem.d.ts +18 -0
- package/dist/filesystem/types.d.cts +12 -0
- package/dist/filesystem/types.d.ts +12 -0
- package/dist/fs-session-store-3MOJQGP2.cjs +20 -0
- package/dist/{fs-session-store-VVY2AHWG.cjs.map → fs-session-store-3MOJQGP2.cjs.map} +1 -1
- package/dist/fs-session-store-IN7JTTXD.js +11 -0
- package/dist/{fs-session-store-R5FD3EN6.js.map → fs-session-store-IN7JTTXD.js.map} +1 -1
- package/dist/generate-object-N5MDZUJI.js +8 -0
- package/dist/{generate-object-WQRCXFD2.js.map → generate-object-N5MDZUJI.js.map} +1 -1
- package/dist/generate-object-PGSP5U7N.cjs +21 -0
- package/dist/{generate-object-AVXOJK2I.cjs.map → generate-object-PGSP5U7N.cjs.map} +1 -1
- package/dist/generate-object.d.ts +20 -0
- package/dist/index-manager-NG5YENWO.cjs +22 -0
- package/dist/{index-manager-VRU3A2YL.cjs.map → index-manager-NG5YENWO.cjs.map} +1 -1
- package/dist/index-manager-ZMRJ6ZII.js +13 -0
- package/dist/{index-manager-WS7TVKUW.js.map → index-manager-ZMRJ6ZII.js.map} +1 -1
- package/dist/index.cjs +169 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +702 -54
- package/dist/index.d.ts +702 -54
- package/dist/index.js +61 -58
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-GMBMJVNZ.js → inject-session-DDR6X6PC.js} +9 -8
- package/dist/inject-session-DDR6X6PC.js.map +1 -0
- package/dist/inject-session-XLO3KTBM.cjs +29 -0
- package/dist/inject-session-XLO3KTBM.cjs.map +1 -0
- package/dist/internal/auth/auth-types.d.ts +83 -1
- package/dist/internal/auth/credential-store.d.ts +34 -6
- package/dist/internal/auth/oauth-device.d.ts +0 -1
- package/dist/internal/auth/resolve-credential.d.ts +40 -0
- package/dist/internal/budget/tracker/budget.d.ts +12 -14
- package/dist/internal/budget/usage-accumulator.d.ts +15 -0
- package/dist/internal/llm/anthropic-shared.d.ts +8 -4
- package/dist/internal/llm/model-identifier.d.ts +26 -0
- package/dist/internal/llm/openai.d.ts +8 -0
- package/dist/internal/llm/router.d.ts +8 -0
- package/dist/internal/llm/types.d.ts +12 -1
- package/dist/internal/local-agent/real-local-run-provider.d.ts +8 -3
- package/dist/internal/local-agent/real-local-run-tools.d.ts +8 -0
- package/dist/internal/mcp/oauth.d.ts +5 -0
- package/dist/internal/mcp/token-storage.d.ts +34 -0
- package/dist/internal/memory/adapters/index.cjs +12 -11
- package/dist/internal/memory/adapters/index.d.cts +3 -1
- package/dist/internal/memory/adapters/index.d.ts +3 -1
- package/dist/internal/memory/adapters/index.js +9 -8
- package/dist/internal/memory/adapters/openai-compatible.d.cts +45 -0
- package/dist/internal/memory/adapters/openai-compatible.d.ts +45 -0
- package/dist/internal/memory/embedding-cache.d.ts +42 -1
- package/dist/internal/memory/escape-like-pattern.d.ts +22 -0
- package/dist/internal/memory/sqlite-vec-loader.d.ts +1 -3
- package/dist/internal/memory/storage/markdown-store.d.ts +0 -5
- package/dist/internal/persistence/cwd-mutex.d.cts +34 -0
- package/dist/internal/persistence/cwd-mutex.d.ts +34 -0
- package/dist/internal/persistence/exclusive-create.d.cts +31 -0
- package/dist/internal/persistence/exclusive-create.d.ts +31 -0
- package/dist/internal/persistence/file-lock.d.cts +28 -0
- package/dist/internal/persistence/file-lock.d.ts +28 -0
- package/dist/internal/persistence/fs-session-store.d.cts +3 -0
- package/dist/internal/persistence/fs-session-store.d.ts +3 -0
- package/dist/internal/persistence/fts5-sanitize.d.cts +20 -0
- package/dist/internal/persistence/fts5-sanitize.d.ts +20 -0
- package/dist/internal/persistence/index.cjs +40 -39
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.d.cts +6 -1
- package/dist/internal/persistence/index.d.ts +6 -1
- package/dist/internal/persistence/index.js +9 -8
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/persistence/paths.d.cts +54 -1
- package/dist/internal/persistence/paths.d.ts +54 -1
- package/dist/internal/persistence/persistence-schema.d.cts +9 -1
- package/dist/internal/persistence/persistence-schema.d.ts +9 -1
- package/dist/internal/persistence/schema-version.d.cts +215 -1
- package/dist/internal/persistence/schema-version.d.ts +215 -1
- package/dist/internal/persistence/session-writer.d.cts +7 -7
- package/dist/internal/persistence/session-writer.d.ts +7 -7
- package/dist/internal/persistence/sqlite-cas.d.cts +37 -1
- package/dist/internal/persistence/sqlite-cas.d.ts +37 -1
- package/dist/internal/persistence/sqlite-open.d.cts +14 -0
- package/dist/internal/persistence/sqlite-open.d.ts +14 -0
- package/dist/internal/persistence/sqlite-wal.d.cts +45 -0
- package/dist/internal/persistence/sqlite-wal.d.ts +45 -0
- package/dist/internal/persistence/transcript-ops.d.cts +7 -1
- package/dist/internal/persistence/transcript-ops.d.ts +7 -1
- package/dist/internal/plugins/types.d.cts +1 -1
- package/dist/internal/plugins/types.d.ts +1 -1
- package/dist/internal/providers/builtin/openai-chatgpt.d.ts +12 -0
- package/dist/internal/providers/catalog-loader.d.ts +8 -0
- package/dist/internal/providers/catalog-schema.d.ts +55 -0
- package/dist/internal/providers/catalog-source-models-dev.d.ts +36 -0
- package/dist/internal/runtime/concurrency/delegation-depth.d.ts +27 -0
- package/dist/internal/runtime/concurrency/subagent-credentials.d.ts +33 -1
- package/dist/internal/runtime/context/context-discovery-runner.d.ts +44 -0
- package/dist/internal/runtime/context/context-discovery.d.ts +58 -0
- package/dist/internal/runtime/context/context-rules-frontmatter.d.ts +70 -1
- package/dist/internal/runtime/fixtures/fixture-mode.d.ts +15 -1
- package/dist/internal/runtime/lifecycle/post-run-lifecycle.d.ts +15 -0
- package/dist/internal/runtime/registry/agent-registry-store.d.ts +12 -0
- package/dist/internal/runtime/registry/live-agent-registry.d.ts +37 -0
- package/dist/internal/scorers/llm-judge.d.ts +6 -1
- package/dist/internal/security/index.cjs +14 -13
- package/dist/internal/security/index.d.cts +4 -1
- package/dist/internal/security/index.d.ts +4 -1
- package/dist/internal/security/index.js +4 -3
- package/dist/internal/security/path-guard.d.cts +46 -0
- package/dist/internal/security/path-guard.d.ts +46 -0
- package/dist/internal/security/redact.d.cts +71 -0
- package/dist/internal/security/redact.d.ts +71 -0
- package/dist/internal/session/agent-session.d.ts +15 -4
- package/dist/internal/session/session-cache.d.ts +5 -0
- package/dist/internal/task/store.d.ts +91 -5
- package/dist/internal/telemetry/span-names.d.ts +0 -1
- package/dist/internal/telemetry/tracer.d.ts +14 -0
- package/dist/job-queue.d.ts +18 -0
- package/dist/judge-call-DWHAJATE.js +6 -0
- package/dist/{judge-call-MDIPTBJI.js.map → judge-call-DWHAJATE.js.map} +1 -1
- package/dist/judge-call-EGYRC2RE.cjs +23 -0
- package/dist/{judge-call-G5SGV2M2.cjs.map → judge-call-EGYRC2RE.cjs.map} +1 -1
- package/dist/mcp-auth.cjs +41 -25
- package/dist/mcp-auth.cjs.map +1 -1
- package/dist/mcp-auth.js +34 -18
- package/dist/mcp-auth.js.map +1 -1
- package/dist/models.cjs +42 -27
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +25 -10
- package/dist/models.js.map +1 -1
- package/dist/oauth-transaction-store-BT4GLTLK.cjs +36 -0
- package/dist/{oauth-transaction-store-7CKHPQRN.cjs.map → oauth-transaction-store-BT4GLTLK.cjs.map} +1 -1
- package/dist/oauth-transaction-store-W52KVHQ4.js +3 -0
- package/dist/{oauth-transaction-store-W74I6EFD.js.map → oauth-transaction-store-W52KVHQ4.js.map} +1 -1
- package/dist/path-safety.cjs +11 -10
- package/dist/path-safety.js +4 -3
- package/dist/permission-engine.d.ts +55 -0
- package/dist/persistence.cjs +43 -42
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +13 -12
- package/dist/persistence.js.map +1 -1
- package/dist/project.cjs +9 -8
- package/dist/project.cjs.map +1 -1
- package/dist/project.js +5 -4
- package/dist/project.js.map +1 -1
- package/dist/providers.cjs +23 -0
- package/dist/providers.cjs.map +1 -0
- package/dist/providers.d.cts +29 -0
- package/dist/providers.d.ts +29 -0
- package/dist/providers.js +10 -0
- package/dist/providers.js.map +1 -0
- package/dist/registry-VFKX7WOP.cjs +47 -0
- package/dist/{registry-63ASMXT4.cjs.map → registry-VFKX7WOP.cjs.map} +1 -1
- package/dist/registry-VFP3WWQP.js +10 -0
- package/dist/{registry-O7FJ2MPM.js.map → registry-VFP3WWQP.js.map} +1 -1
- package/dist/retry.cjs +5 -4
- package/dist/retry.js +4 -3
- package/dist/{run-C8FBAC8o.d.cts → run-BYSHf58D.d.cts} +185 -33
- package/dist/{run-C8FBAC8o.d.ts → run-BYSHf58D.d.ts} +185 -33
- package/dist/{run-to-completion-JDPIUKSH.js → run-to-completion-DRO77625.js} +3 -3
- package/dist/{run-to-completion-JDPIUKSH.js.map → run-to-completion-DRO77625.js.map} +1 -1
- package/dist/{run-to-completion-J73I6IY4.cjs → run-to-completion-X4OWM673.cjs} +13 -13
- package/dist/{run-to-completion-J73I6IY4.cjs.map → run-to-completion-X4OWM673.cjs.map} +1 -1
- package/dist/sandbox/bwrap.d.cts +27 -13
- package/dist/sandbox/bwrap.d.ts +27 -13
- package/dist/sandbox/index.cjs +20 -19
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.js +5 -4
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/linux-sandbox.d.cts +72 -0
- package/dist/sandbox/linux-sandbox.d.ts +72 -0
- package/dist/sandbox/local-sandbox.d.cts +41 -0
- package/dist/sandbox/local-sandbox.d.ts +41 -0
- package/dist/sandbox/seccomp.d.cts +6 -0
- package/dist/sandbox/seccomp.d.ts +6 -0
- package/dist/sandbox/types.d.cts +64 -0
- package/dist/sandbox/types.d.ts +64 -0
- package/dist/scorers.d.ts +38 -7
- package/dist/sdk-agent-D8qJVkuV.d.ts +860 -0
- package/dist/sdk-agent-DEoKhA8a.d.cts +860 -0
- package/dist/server/auth/errors.d.cts +1 -1
- package/dist/server/auth/errors.d.ts +1 -1
- package/dist/server/auth/index.cjs +29 -21
- package/dist/server/auth/index.cjs.map +1 -1
- package/dist/server/auth/index.d.cts +25 -15
- package/dist/server/auth/index.d.ts +25 -15
- package/dist/server/auth/index.js +15 -7
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/oauth-transaction-store.d.cts +13 -1
- package/dist/server/auth/oauth-transaction-store.d.ts +13 -1
- package/dist/server/auth/orchestrator.d.cts +1 -1
- package/dist/server/auth/orchestrator.d.ts +1 -1
- package/dist/server/auth/types.d.cts +1 -1
- package/dist/server/auth/types.d.ts +1 -1
- package/dist/server/auth/validate-return-to.d.cts +21 -11
- package/dist/server/auth/validate-return-to.d.ts +21 -11
- package/dist/server/errors-envelope.cjs +15 -14
- package/dist/server/errors-envelope.cjs.map +1 -1
- package/dist/server/errors-envelope.d.cts +4 -4
- package/dist/server/errors-envelope.d.ts +4 -4
- package/dist/server/errors-envelope.js +4 -3
- package/dist/server/errors-envelope.js.map +1 -1
- package/dist/session-transcript-AKDYYGXQ.js +6 -0
- package/dist/{session-transcript-RAKEK76V.js.map → session-transcript-AKDYYGXQ.js.map} +1 -1
- package/dist/session-transcript-JXHFTB7G.cjs +51 -0
- package/dist/{session-transcript-DOM3UTXR.cjs.map → session-transcript-JXHFTB7G.cjs.map} +1 -1
- package/dist/skills.cjs +8 -7
- package/dist/skills.js +6 -5
- package/dist/stream-object-BUCF5PHO.cjs +21 -0
- package/dist/{stream-object-L3Q7PBMF.cjs.map → stream-object-BUCF5PHO.cjs.map} +1 -1
- package/dist/stream-object-L57K4OFS.js +8 -0
- package/dist/{stream-object-ZYXWS4B2.js.map → stream-object-L57K4OFS.js.map} +1 -1
- package/dist/{stream-to-completion-DFJ5T3BK.js → stream-to-completion-QV5HCL3J.js} +3 -3
- package/dist/{stream-to-completion-DFJ5T3BK.js.map → stream-to-completion-QV5HCL3J.js.map} +1 -1
- package/dist/{stream-to-completion-H2MHISSK.cjs → stream-to-completion-SRISU5AB.cjs} +10 -10
- package/dist/{stream-to-completion-H2MHISSK.cjs.map → stream-to-completion-SRISU5AB.cjs.map} +1 -1
- package/dist/subagents-loader-AZIXJ7D3.cjs +16 -0
- package/dist/{subagents-loader-VRW73QQT.cjs.map → subagents-loader-AZIXJ7D3.cjs.map} +1 -1
- package/dist/subagents-loader-J54ESLDV.js +7 -0
- package/dist/{subagents-loader-I56GSKAQ.js.map → subagents-loader-J54ESLDV.js.map} +1 -1
- package/dist/subagents-loader.cjs +7 -6
- package/dist/subagents-loader.cjs.map +1 -1
- package/dist/subagents-loader.d.cts +3 -2
- package/dist/subagents-loader.d.ts +3 -2
- package/dist/subagents-loader.js +5 -4
- package/dist/subagents-loader.js.map +1 -1
- package/dist/subscription/define-subscription.d.cts +1 -1
- package/dist/subscription/define-subscription.d.ts +1 -1
- package/dist/subscription/index.cjs +22 -9
- package/dist/subscription/index.cjs.map +1 -1
- package/dist/subscription/index.d.cts +1 -1
- package/dist/subscription/index.d.ts +1 -1
- package/dist/subscription/index.js +21 -8
- package/dist/subscription/index.js.map +1 -1
- package/dist/subscription/internal/adapter-types.d.cts +1 -1
- package/dist/subscription/internal/adapter-types.d.ts +1 -1
- package/dist/subscription/internal/server-integration.d.cts +1 -1
- package/dist/subscription/internal/server-integration.d.ts +1 -1
- package/dist/subscription/internal/sse-encoder.d.cts +1 -1
- package/dist/subscription/internal/sse-encoder.d.ts +1 -1
- package/dist/subscription/internal/sse-parser.d.cts +1 -1
- package/dist/subscription/internal/sse-parser.d.ts +1 -1
- package/dist/subscription/internal/subscription-runtime.d.cts +1 -1
- package/dist/subscription/internal/subscription-runtime.d.ts +1 -1
- package/dist/subscription/internal/ws-adapter-node.d.cts +1 -1
- package/dist/subscription/internal/ws-adapter-node.d.ts +1 -1
- package/dist/subscription/theokit-subscribe.d.cts +14 -1
- package/dist/subscription/theokit-subscribe.d.ts +14 -1
- package/dist/subscription/types.d.cts +19 -1
- package/dist/subscription/types.d.ts +19 -1
- package/dist/task-store.cjs +8 -7
- package/dist/task-store.js +5 -4
- package/dist/types/agent-prims.d.ts +14 -0
- package/dist/types/agent.d.ts +50 -11
- package/dist/types/batch.d.ts +7 -1
- package/dist/types/conversation.d.ts +18 -5
- package/dist/types/goal-events.d.ts +4 -8
- package/dist/types/memory-adapter.d.ts +12 -1
- package/dist/types/plugin.d.ts +101 -0
- package/dist/types/provider-profile.d.ts +19 -0
- package/dist/types/run-events.d.ts +28 -1
- package/dist/types/run.d.ts +35 -23
- package/dist/types/sdk-agent.d.ts +14 -0
- package/dist/types/session-record.d.ts +18 -1
- package/dist/types/task.d.ts +15 -1
- package/dist/types/theokit.d.ts +10 -1
- package/dist/types/updates.d.ts +35 -4
- package/dist/types/workflow.d.ts +155 -0
- package/dist/workflow.cjs +29 -28
- package/dist/workflow.d.cts +666 -17
- package/dist/workflow.d.ts +666 -17
- package/dist/workflow.js +8 -7
- package/docs/error-codes.md +215 -0
- package/docs/harness-capability-map.md +1357 -0
- package/package.json +29 -16
- package/bin/init-claude.mjs +0 -68
- package/claude-template/AGENTS.md +0 -157
- package/claude-template/CLAUDE.md +0 -66
- package/claude-template/dot-claude/rules/theokit-conventions.md +0 -32
- package/claude-template/dot-claude/settings.json +0 -16
- package/claude-template/dot-claude/skills/theokit-agent-core/SKILL.md +0 -209
- package/claude-template/dot-claude/skills/theokit-auth/SKILL.md +0 -102
- package/claude-template/dot-claude/skills/theokit-budget/SKILL.md +0 -176
- package/claude-template/dot-claude/skills/theokit-client/SKILL.md +0 -58
- package/claude-template/dot-claude/skills/theokit-compaction/SKILL.md +0 -102
- package/claude-template/dot-claude/skills/theokit-concurrency/SKILL.md +0 -68
- package/claude-template/dot-claude/skills/theokit-config/SKILL.md +0 -139
- package/claude-template/dot-claude/skills/theokit-cron/SKILL.md +0 -148
- package/claude-template/dot-claude/skills/theokit-di/SKILL.md +0 -233
- package/claude-template/dot-claude/skills/theokit-di-agent/SKILL.md +0 -294
- package/claude-template/dot-claude/skills/theokit-errors/SKILL.md +0 -172
- package/claude-template/dot-claude/skills/theokit-eval/SKILL.md +0 -179
- package/claude-template/dot-claude/skills/theokit-filesystem/SKILL.md +0 -74
- package/claude-template/dot-claude/skills/theokit-gateways/SKILL.md +0 -209
- package/claude-template/dot-claude/skills/theokit-memory/SKILL.md +0 -176
- package/claude-template/dot-claude/skills/theokit-messages/SKILL.md +0 -58
- package/claude-template/dot-claude/skills/theokit-models/SKILL.md +0 -79
- package/claude-template/dot-claude/skills/theokit-path-safety/SKILL.md +0 -60
- package/claude-template/dot-claude/skills/theokit-persistence/SKILL.md +0 -85
- package/claude-template/dot-claude/skills/theokit-project/SKILL.md +0 -55
- package/claude-template/dot-claude/skills/theokit-retry/SKILL.md +0 -50
- package/claude-template/dot-claude/skills/theokit-sandbox/SKILL.md +0 -93
- package/claude-template/dot-claude/skills/theokit-sanitize/SKILL.md +0 -66
- package/claude-template/dot-claude/skills/theokit-skills/SKILL.md +0 -68
- package/claude-template/dot-claude/skills/theokit-streaming/SKILL.md +0 -156
- package/claude-template/dot-claude/skills/theokit-subagents/SKILL.md +0 -109
- package/claude-template/dot-claude/skills/theokit-subscriptions/SKILL.md +0 -148
- package/claude-template/dot-claude/skills/theokit-task-store/SKILL.md +0 -75
- package/claude-template/dot-claude/skills/theokit-tools/SKILL.md +0 -170
- package/claude-template/dot-claude/skills/theokit-workflows/SKILL.md +0 -218
- package/dist/agent-FFVV4U5N.js +0 -50
- package/dist/agent-YLAHVHEH.cjs +0 -59
- package/dist/agent-session-store-DUGBAX5V.cjs +0 -23
- package/dist/agent-session-store-TNCGL5RN.js +0 -6
- package/dist/batch-UPKN4SG6.js.map +0 -1
- package/dist/batch-ZEFN5SO7.cjs.map +0 -1
- package/dist/chunk-2D43RD5D.cjs.map +0 -1
- package/dist/chunk-2FYEVT2B.cjs.map +0 -1
- package/dist/chunk-2RW7K6FN.cjs.map +0 -1
- package/dist/chunk-2XLKLVVR.js.map +0 -1
- package/dist/chunk-34XOCZJO.js.map +0 -1
- package/dist/chunk-3V7UJLQT.js.map +0 -1
- package/dist/chunk-4NAKHID5.js.map +0 -1
- package/dist/chunk-4Q4K4WB5.js.map +0 -1
- package/dist/chunk-5F5NWKPN.js.map +0 -1
- package/dist/chunk-5NBUH3NO.js.map +0 -1
- package/dist/chunk-5YKNEMXR.cjs.map +0 -1
- package/dist/chunk-7W7ZWMLQ.js.map +0 -1
- package/dist/chunk-ADLLFY3H.cjs.map +0 -1
- package/dist/chunk-B4YA6BRS.cjs.map +0 -1
- package/dist/chunk-B6HOIWQ6.js.map +0 -1
- package/dist/chunk-BDTVFIPB.cjs.map +0 -1
- package/dist/chunk-BFYGJGC5.js.map +0 -1
- package/dist/chunk-BM6N4KHO.cjs.map +0 -1
- package/dist/chunk-CAH3G4IS.js.map +0 -1
- package/dist/chunk-EZ2YEF4F.cjs.map +0 -1
- package/dist/chunk-F77UENR6.cjs.map +0 -1
- package/dist/chunk-FOXKFTVZ.cjs.map +0 -1
- package/dist/chunk-G3JWXOGY.js.map +0 -1
- package/dist/chunk-GOVJO4YE.js.map +0 -1
- package/dist/chunk-HAWE74GQ.cjs.map +0 -1
- package/dist/chunk-HE4BIAOS.js.map +0 -1
- package/dist/chunk-HSQ5Q3I5.js.map +0 -1
- package/dist/chunk-JIQRXKTA.cjs.map +0 -1
- package/dist/chunk-KSWHTR54.js.map +0 -1
- package/dist/chunk-L5YO6PWL.cjs.map +0 -1
- package/dist/chunk-LD4MOBFX.js.map +0 -1
- package/dist/chunk-LS3LMQ23.js.map +0 -1
- package/dist/chunk-MSFLYJDY.js.map +0 -1
- package/dist/chunk-NZL4BNFQ.js.map +0 -1
- package/dist/chunk-OKLYRPKL.cjs.map +0 -1
- package/dist/chunk-OUOXM36O.cjs.map +0 -1
- package/dist/chunk-OXNYIMZZ.js.map +0 -1
- package/dist/chunk-PBZ7HMBP.js.map +0 -1
- package/dist/chunk-PNVDQL5Y.cjs.map +0 -1
- package/dist/chunk-Q4RESANI.cjs.map +0 -1
- package/dist/chunk-QBTVATSF.cjs.map +0 -1
- package/dist/chunk-RAHSWE5C.cjs.map +0 -1
- package/dist/chunk-RP5HQVLD.js.map +0 -1
- package/dist/chunk-SEL2ZQMT.js.map +0 -1
- package/dist/chunk-SK4QLUBK.js.map +0 -1
- package/dist/chunk-TTJ54H3E.cjs.map +0 -1
- package/dist/chunk-V26QVGUG.js.map +0 -1
- package/dist/chunk-V6HWJQQV.js.map +0 -1
- package/dist/chunk-VGPXHHF3.cjs.map +0 -1
- package/dist/chunk-VUKQL3L2.cjs.map +0 -1
- package/dist/chunk-VYCKUKPA.cjs.map +0 -1
- package/dist/chunk-VYHJZVL5.cjs.map +0 -1
- package/dist/chunk-X2FR4OIT.js.map +0 -1
- package/dist/chunk-XPR366DL.cjs.map +0 -1
- package/dist/chunk-XROIW6BH.js.map +0 -1
- package/dist/chunk-YLQQX5W2.cjs.map +0 -1
- package/dist/chunk-ZT57WTUJ.cjs.map +0 -1
- package/dist/compact-session-4MNKNMO2.js +0 -21
- package/dist/compact-session-EPFBQ46Z.cjs +0 -58
- package/dist/context-7USNN6LP.cjs +0 -22
- package/dist/context-ENXZNF6J.js +0 -5
- package/dist/cron-BMjgFH-_.d.ts +0 -631
- package/dist/cron-DFDdCdMM.d.cts +0 -631
- package/dist/executor-2Z3LGG3I.cjs.map +0 -1
- package/dist/executor-2Z6XJJJG.js.map +0 -1
- package/dist/fs-session-store-R5FD3EN6.js +0 -10
- package/dist/fs-session-store-VVY2AHWG.cjs +0 -19
- package/dist/generate-object-AVXOJK2I.cjs +0 -20
- package/dist/generate-object-WQRCXFD2.js +0 -7
- package/dist/index-manager-VRU3A2YL.cjs +0 -21
- package/dist/index-manager-WS7TVKUW.js +0 -12
- package/dist/inject-session-AUQLBDRS.cjs +0 -28
- package/dist/inject-session-AUQLBDRS.cjs.map +0 -1
- package/dist/inject-session-GMBMJVNZ.js.map +0 -1
- package/dist/judge-call-G5SGV2M2.cjs +0 -22
- package/dist/judge-call-MDIPTBJI.js +0 -5
- package/dist/oauth-transaction-store-7CKHPQRN.cjs +0 -32
- package/dist/oauth-transaction-store-W74I6EFD.js +0 -3
- package/dist/registry-63ASMXT4.cjs +0 -46
- package/dist/registry-O7FJ2MPM.js +0 -9
- package/dist/session-transcript-DOM3UTXR.cjs +0 -50
- package/dist/session-transcript-RAKEK76V.js +0 -5
- package/dist/stream-object-L3Q7PBMF.cjs +0 -20
- package/dist/stream-object-ZYXWS4B2.js +0 -7
- package/dist/subagents-loader-I56GSKAQ.js +0 -6
- package/dist/subagents-loader-VRW73QQT.cjs +0 -15
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk5BJV5UPY_cjs = require('./chunk-5BJV5UPY.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 chunkUNDROG5N_cjs = require('./chunk-UNDROG5N.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 chunk3KGLRRFC_cjs = require('./chunk-3KGLRRFC.cjs');
|
|
32
|
+
var chunkRM7Y65IG_cjs = require('./chunk-RM7Y65IG.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 = chunkUNDROG5N_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 chunkUNDROG5N_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 chunkUNDROG5N_cjs.isFixtureApiKey(apiKey) && chunkUNDROG5N_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 && !chunkUNDROG5N_cjs.isFixtureApiKey(apiKey) && chunkUNDROG5N_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) {
|
|
@@ -2658,11 +2699,11 @@ function buildContextBudgetEvent(model, resolved) {
|
|
|
2658
2699
|
// src/internal/runtime/lifecycle/post-run-lifecycle.ts
|
|
2659
2700
|
function resolveWindowForRun(model, contextWindow) {
|
|
2660
2701
|
const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
|
|
2661
|
-
return
|
|
2702
|
+
return chunkXSX2UU6Y_cjs.resolveEffectiveContextWindow({
|
|
2662
2703
|
...override !== void 0 ? { override } : {},
|
|
2663
|
-
catalog:
|
|
2664
|
-
margin:
|
|
2665
|
-
floor:
|
|
2704
|
+
catalog: chunkRM7Y65IG_cjs.getCatalogModelInfo(model)?.limit?.context,
|
|
2705
|
+
margin: chunkXSX2UU6Y_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2706
|
+
floor: chunkXSX2UU6Y_cjs.CONTEXT_WINDOW_FLOOR
|
|
2666
2707
|
});
|
|
2667
2708
|
}
|
|
2668
2709
|
async function runPostRunLifecycle(inputs) {
|
|
@@ -2686,32 +2727,32 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2686
2727
|
try {
|
|
2687
2728
|
const partial = await safeConversation(run);
|
|
2688
2729
|
if (partial !== void 0) {
|
|
2689
|
-
|
|
2730
|
+
chunk5BJV5UPY_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2690
2731
|
userText,
|
|
2691
2732
|
conversation: partial
|
|
2692
2733
|
});
|
|
2693
2734
|
}
|
|
2694
2735
|
} catch (cause) {
|
|
2695
2736
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2696
|
-
|
|
2737
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2697
2738
|
`);
|
|
2698
2739
|
}
|
|
2699
|
-
await
|
|
2740
|
+
await chunk5BJV5UPY_cjs.flushSessionWrites();
|
|
2700
2741
|
return;
|
|
2701
2742
|
}
|
|
2702
2743
|
if (result.result !== void 0) {
|
|
2703
|
-
|
|
2744
|
+
chunk5BJV5UPY_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2704
2745
|
}
|
|
2705
2746
|
const conversation = await safeConversation(run);
|
|
2706
2747
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2707
2748
|
const effectiveWindow = resolvedWindow.window;
|
|
2708
2749
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2709
2750
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2710
|
-
|
|
2751
|
+
chunkNGESVVJN_cjs.emitRunEvent(onRunEvent, budgetEvent);
|
|
2711
2752
|
}
|
|
2712
2753
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2713
2754
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2714
|
-
|
|
2755
|
+
chunk5BJV5UPY_cjs.persistTurnToTranscript(
|
|
2715
2756
|
sessionStore,
|
|
2716
2757
|
{ cwd: workspaceCwd, agentId, model },
|
|
2717
2758
|
agentId,
|
|
@@ -2723,13 +2764,13 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2723
2764
|
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2724
2765
|
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2725
2766
|
contextWindow: effectiveWindow,
|
|
2726
|
-
summarize:
|
|
2767
|
+
summarize: chunkUNDROG5N_cjs.buildDefaultSummarizer({
|
|
2727
2768
|
agentModel: model,
|
|
2728
2769
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2729
2770
|
})
|
|
2730
2771
|
}
|
|
2731
2772
|
},
|
|
2732
|
-
onRunEvent !== void 0 ? () =>
|
|
2773
|
+
onRunEvent !== void 0 ? () => chunkNGESVVJN_cjs.emitRunEvent(onRunEvent, { type: "compact_boundary", trigger: "auto" }) : void 0
|
|
2733
2774
|
);
|
|
2734
2775
|
if (result.status === "finished" && result.result !== void 0) {
|
|
2735
2776
|
const summaryArgs = {
|
|
@@ -2745,14 +2786,14 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2745
2786
|
if (memoryProvider?.recordSessionSummary !== void 0) {
|
|
2746
2787
|
await memoryProvider.recordSessionSummary(summaryArgs);
|
|
2747
2788
|
} else {
|
|
2748
|
-
await
|
|
2789
|
+
await chunk5UOVYM3P_cjs.writeSessionSummary(summaryArgs);
|
|
2749
2790
|
}
|
|
2750
2791
|
if (!shouldUsePortMemoryPath()) {
|
|
2751
2792
|
void memoryGlue.syncIfReady();
|
|
2752
2793
|
}
|
|
2753
2794
|
} catch (cause) {
|
|
2754
2795
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2755
|
-
|
|
2796
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] session summary write failed (${result.id}): ${message}
|
|
2756
2797
|
`);
|
|
2757
2798
|
}
|
|
2758
2799
|
}
|
|
@@ -2765,7 +2806,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2765
2806
|
agentId,
|
|
2766
2807
|
runId: result.id
|
|
2767
2808
|
});
|
|
2768
|
-
await
|
|
2809
|
+
await chunk5BJV5UPY_cjs.flushSessionWrites();
|
|
2769
2810
|
}
|
|
2770
2811
|
async function safeConversation(run) {
|
|
2771
2812
|
try {
|
|
@@ -2840,7 +2881,7 @@ var warned = /* @__PURE__ */ new Set();
|
|
|
2840
2881
|
function warnDoubleReasoningOnce() {
|
|
2841
2882
|
if (warned.has("double-reasoning")) return;
|
|
2842
2883
|
warned.add("double-reasoning");
|
|
2843
|
-
|
|
2884
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2844
2885
|
"[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
2886
|
);
|
|
2846
2887
|
}
|
|
@@ -2873,9 +2914,9 @@ var SkillsManager = class {
|
|
|
2873
2914
|
}
|
|
2874
2915
|
async refresh() {
|
|
2875
2916
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
2876
|
-
const discovered = await
|
|
2917
|
+
const discovered = await chunk3YJNUKYN_cjs.discoverSkills(skillsRoot, {
|
|
2877
2918
|
onInvalidSkill: (info) => {
|
|
2878
|
-
|
|
2919
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
2879
2920
|
`);
|
|
2880
2921
|
}
|
|
2881
2922
|
});
|
|
@@ -2899,7 +2940,7 @@ var SkillsManager = class {
|
|
|
2899
2940
|
async get(name) {
|
|
2900
2941
|
const skill = this.skills.find((s) => s.name === name);
|
|
2901
2942
|
if (skill === void 0) return void 0;
|
|
2902
|
-
const instructions = typeof skill.instructions === "string" ? skill.instructions :
|
|
2943
|
+
const instructions = typeof skill.instructions === "string" ? skill.instructions : chunk3YJNUKYN_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
|
|
2903
2944
|
const references = skill.references;
|
|
2904
2945
|
return {
|
|
2905
2946
|
name: skill.name,
|
|
@@ -2985,7 +3026,7 @@ async function safeCall(fn, fallback, label = "safeCall") {
|
|
|
2985
3026
|
return await fn();
|
|
2986
3027
|
} catch (cause) {
|
|
2987
3028
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2988
|
-
|
|
3029
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] ${label} failed: ${message}
|
|
2989
3030
|
`);
|
|
2990
3031
|
return fallback;
|
|
2991
3032
|
}
|
|
@@ -2999,7 +3040,7 @@ var ActiveMemoryPromptProvider = class {
|
|
|
2999
3040
|
if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
|
|
3000
3041
|
return Promise.resolve(void 0);
|
|
3001
3042
|
}
|
|
3002
|
-
const body =
|
|
3043
|
+
const body = chunk3YJNUKYN_cjs.escapeBlockBody(ctx.activeMemorySummary);
|
|
3003
3044
|
return Promise.resolve(`<active-memory>
|
|
3004
3045
|
${body}
|
|
3005
3046
|
</active-memory>`);
|
|
@@ -3052,7 +3093,7 @@ function formatSource(name, tokens) {
|
|
|
3052
3093
|
if (tokens.length === 0) {
|
|
3053
3094
|
return ` <source name="${escapeAttribute(name)}" />`;
|
|
3054
3095
|
}
|
|
3055
|
-
const body =
|
|
3096
|
+
const body = chunk3YJNUKYN_cjs.escapeBlockBody(tokens.join(" "));
|
|
3056
3097
|
return ` <source name="${escapeAttribute(name)}">
|
|
3057
3098
|
${body}
|
|
3058
3099
|
</source>`;
|
|
@@ -3068,7 +3109,7 @@ var MemoryPromptProvider = class {
|
|
|
3068
3109
|
contribute(ctx) {
|
|
3069
3110
|
if (ctx.memoryAutoInject === false) return Promise.resolve(void 0);
|
|
3070
3111
|
if (ctx.memory.length === 0) return Promise.resolve(void 0);
|
|
3071
|
-
const lines = ctx.memory.map((fact) => ` - ${
|
|
3112
|
+
const lines = ctx.memory.map((fact) => ` - ${chunk3YJNUKYN_cjs.escapeBlockBody(fact.text)}`);
|
|
3072
3113
|
return Promise.resolve(`<memory>
|
|
3073
3114
|
${lines.join("\n")}
|
|
3074
3115
|
</memory>`);
|
|
@@ -3090,7 +3131,7 @@ var SkillsPromptProvider = class {
|
|
|
3090
3131
|
priority = 20;
|
|
3091
3132
|
contribute(ctx) {
|
|
3092
3133
|
if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
|
|
3093
|
-
return Promise.resolve(
|
|
3134
|
+
return Promise.resolve(chunk3YJNUKYN_cjs.buildSkillsBlock(ctx.skills));
|
|
3094
3135
|
}
|
|
3095
3136
|
};
|
|
3096
3137
|
|
|
@@ -3102,7 +3143,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
|
|
|
3102
3143
|
for (const p of providers) {
|
|
3103
3144
|
const key = `${p.priority}:${p.id}`;
|
|
3104
3145
|
if (seen.has(key)) {
|
|
3105
|
-
throw new
|
|
3146
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Duplicate system-prompt provider ${key}`, {
|
|
3106
3147
|
code: "pipeline_duplicate_provider"
|
|
3107
3148
|
});
|
|
3108
3149
|
}
|
|
@@ -3149,7 +3190,7 @@ function validateAgentOptions(options) {
|
|
|
3149
3190
|
ensureRuntimeShape(options);
|
|
3150
3191
|
if (options.local !== void 0) {
|
|
3151
3192
|
if (options.model === void 0) {
|
|
3152
|
-
throw new
|
|
3193
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError("Local agents require a model selection", {
|
|
3153
3194
|
code: "missing_model"
|
|
3154
3195
|
});
|
|
3155
3196
|
}
|
|
@@ -3173,7 +3214,7 @@ function validateCredentialPoolShape(options) {
|
|
|
3173
3214
|
([, arr]) => Array.isArray(arr) && arr.some((k) => typeof k === "string" && k.length > 0)
|
|
3174
3215
|
);
|
|
3175
3216
|
if (populated.length === 0) return;
|
|
3176
|
-
throw new
|
|
3217
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3177
3218
|
"Ambiguous credential configuration: use either `apiKey: '...'` (single-key, simplest) OR `apiKeys: { provider: [...] }` (multi-key pool), not both.",
|
|
3178
3219
|
{ code: "credential_pool_ambiguous" }
|
|
3179
3220
|
);
|
|
@@ -3182,7 +3223,7 @@ function validatePlugins(options) {
|
|
|
3182
3223
|
const plugins = options.plugins;
|
|
3183
3224
|
if (plugins?.paths === void 0) return;
|
|
3184
3225
|
if (options.cloud !== void 0 && plugins.paths.length > 0) {
|
|
3185
|
-
throw new
|
|
3226
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3186
3227
|
"Cloud agents require committed plugin manifests; local plugin paths are not supported",
|
|
3187
3228
|
{ code: "cloud_plugin_path_rejected" }
|
|
3188
3229
|
);
|
|
@@ -3190,7 +3231,7 @@ function validatePlugins(options) {
|
|
|
3190
3231
|
}
|
|
3191
3232
|
function ensureRuntimeShape(options) {
|
|
3192
3233
|
if (options.local !== void 0 && options.cloud !== void 0) {
|
|
3193
|
-
throw new
|
|
3234
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3194
3235
|
"Pass either local or cloud \u2014 they are mutually exclusive runtimes",
|
|
3195
3236
|
{ code: "runtime_exclusive" }
|
|
3196
3237
|
);
|
|
@@ -3198,7 +3239,7 @@ function ensureRuntimeShape(options) {
|
|
|
3198
3239
|
}
|
|
3199
3240
|
function rejectProgrammaticHooks(options) {
|
|
3200
3241
|
if (options.hooks !== void 0) {
|
|
3201
|
-
throw new
|
|
3242
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3202
3243
|
"Programmatic hooks are not supported \u2014 hooks are file-based only (.theokit/hooks.json)",
|
|
3203
3244
|
{ code: "programmatic_hooks_rejected" }
|
|
3204
3245
|
);
|
|
@@ -3208,7 +3249,7 @@ function validateCloud(cloud) {
|
|
|
3208
3249
|
if (cloud.envVars !== void 0) {
|
|
3209
3250
|
for (const key of Object.keys(cloud.envVars)) {
|
|
3210
3251
|
if (key.startsWith("THEOKIT_")) {
|
|
3211
|
-
throw new
|
|
3252
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3212
3253
|
`Cloud envVars cannot use the reserved THEOKIT_ prefix (got "${key}")`,
|
|
3213
3254
|
{ code: "reserved_env_prefix" }
|
|
3214
3255
|
);
|
|
@@ -3220,7 +3261,7 @@ function validateMcpServers(options) {
|
|
|
3220
3261
|
if (options.mcpServers === void 0) return;
|
|
3221
3262
|
for (const [name, config] of Object.entries(options.mcpServers)) {
|
|
3222
3263
|
if (options.cloud !== void 0 && isStdioWithCwd(config)) {
|
|
3223
|
-
throw new
|
|
3264
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3224
3265
|
`MCP server "${name}" uses stdio with cwd, which is rejected for cloud agents`,
|
|
3225
3266
|
{ code: "cloud_stdio_cwd_rejected" }
|
|
3226
3267
|
);
|
|
@@ -3239,12 +3280,12 @@ function validateSubagents(agents2) {
|
|
|
3239
3280
|
if (agents2 === void 0) return;
|
|
3240
3281
|
for (const [name, definition] of Object.entries(agents2)) {
|
|
3241
3282
|
if (typeof definition.description !== "string" || definition.description.length === 0) {
|
|
3242
|
-
throw new
|
|
3283
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty description`, {
|
|
3243
3284
|
code: "subagent_missing_description"
|
|
3244
3285
|
});
|
|
3245
3286
|
}
|
|
3246
3287
|
if (typeof definition.prompt !== "string" || definition.prompt.length === 0) {
|
|
3247
|
-
throw new
|
|
3288
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty prompt`, {
|
|
3248
3289
|
code: "subagent_missing_prompt"
|
|
3249
3290
|
});
|
|
3250
3291
|
}
|
|
@@ -3257,7 +3298,7 @@ function validateToolCatalog(tools) {
|
|
|
3257
3298
|
for (const tool of tools) {
|
|
3258
3299
|
validateSingleTool(tool);
|
|
3259
3300
|
if (seen.has(tool.name)) {
|
|
3260
|
-
throw new
|
|
3301
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Duplicate custom tool name "${tool.name}"`, {
|
|
3261
3302
|
code: "duplicate_tool_name"
|
|
3262
3303
|
});
|
|
3263
3304
|
}
|
|
@@ -3268,7 +3309,7 @@ function validateCustomTools(options) {
|
|
|
3268
3309
|
const tools = options.tools;
|
|
3269
3310
|
if (tools === void 0 || tools.length === 0) return;
|
|
3270
3311
|
if (options.cloud !== void 0) {
|
|
3271
|
-
throw new
|
|
3312
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3272
3313
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
3273
3314
|
{ code: "cloud_custom_tools_rejected" }
|
|
3274
3315
|
);
|
|
@@ -3280,25 +3321,25 @@ function validateSingleTool(tool) {
|
|
|
3280
3321
|
validateToolDescription(tool);
|
|
3281
3322
|
validateToolSchema(tool);
|
|
3282
3323
|
if (typeof tool.handler !== "function") {
|
|
3283
|
-
throw new
|
|
3324
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a handler function`, {
|
|
3284
3325
|
code: "tool_missing_handler"
|
|
3285
3326
|
});
|
|
3286
3327
|
}
|
|
3287
3328
|
}
|
|
3288
3329
|
function validateToolName(tool) {
|
|
3289
3330
|
if (typeof tool.name !== "string" || tool.name.length === 0) {
|
|
3290
|
-
throw new
|
|
3331
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError("Custom tool requires a non-empty name", {
|
|
3291
3332
|
code: "tool_missing_name"
|
|
3292
3333
|
});
|
|
3293
3334
|
}
|
|
3294
3335
|
if (!TOOL_NAME_PATTERN.test(tool.name)) {
|
|
3295
|
-
throw new
|
|
3336
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3296
3337
|
`Custom tool name "${tool.name}" must match /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/`,
|
|
3297
3338
|
{ code: "tool_invalid_name" }
|
|
3298
3339
|
);
|
|
3299
3340
|
}
|
|
3300
3341
|
if (RESERVED_TOOL_NAMES.has(tool.name) || tool.name.startsWith("mcp_")) {
|
|
3301
|
-
throw new
|
|
3342
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3302
3343
|
`Custom tool name "${tool.name}" collides with a reserved SDK tool name`,
|
|
3303
3344
|
{ code: "tool_reserved_name" }
|
|
3304
3345
|
);
|
|
@@ -3306,7 +3347,7 @@ function validateToolName(tool) {
|
|
|
3306
3347
|
}
|
|
3307
3348
|
function validateToolDescription(tool) {
|
|
3308
3349
|
if (typeof tool.description !== "string" || tool.description.length === 0) {
|
|
3309
|
-
throw new
|
|
3350
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a non-empty description`, {
|
|
3310
3351
|
code: "tool_missing_description"
|
|
3311
3352
|
});
|
|
3312
3353
|
}
|
|
@@ -3314,12 +3355,12 @@ function validateToolDescription(tool) {
|
|
|
3314
3355
|
function validateToolSchema(tool) {
|
|
3315
3356
|
const schema = tool.inputSchema;
|
|
3316
3357
|
if (schema === null || schema === void 0 || typeof schema !== "object") {
|
|
3317
|
-
throw new
|
|
3358
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires an inputSchema object`, {
|
|
3318
3359
|
code: "tool_missing_schema"
|
|
3319
3360
|
});
|
|
3320
3361
|
}
|
|
3321
3362
|
if (schema.type !== "object") {
|
|
3322
|
-
throw new
|
|
3363
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3323
3364
|
`Custom tool "${tool.name}" inputSchema must declare \`type: "object"\``,
|
|
3324
3365
|
{ code: "tool_invalid_schema_type" }
|
|
3325
3366
|
);
|
|
@@ -3330,7 +3371,7 @@ function validateMemory(options) {
|
|
|
3330
3371
|
if (memory?.storePath === void 0) return;
|
|
3331
3372
|
const storePath = memory.storePath;
|
|
3332
3373
|
if (storePath.includes("..") || storePath.startsWith("/") || /^[A-Z]:/i.test(storePath)) {
|
|
3333
|
-
throw new
|
|
3374
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3334
3375
|
`Memory storePath must stay inside the workspace; got "${storePath}"`,
|
|
3335
3376
|
{ code: "memory_path_traversal" }
|
|
3336
3377
|
);
|
|
@@ -3352,7 +3393,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3352
3393
|
};
|
|
3353
3394
|
function safeRequire(moduleName) {
|
|
3354
3395
|
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-
|
|
3396
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UFAO4T7Z.cjs', document.baseURI).href)));
|
|
3356
3397
|
return r(moduleName);
|
|
3357
3398
|
} catch {
|
|
3358
3399
|
return void 0;
|
|
@@ -3431,7 +3472,7 @@ var langfuseAdapter = {
|
|
|
3431
3472
|
}
|
|
3432
3473
|
}
|
|
3433
3474
|
if (lf.LangfuseSpanProcessor === void 0) {
|
|
3434
|
-
|
|
3475
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3435
3476
|
"[theokit-sdk] @langfuse/node detected but LangfuseSpanProcessor not found (v2?). Use Langfuse v3+ for auto-instrumentation.\n"
|
|
3436
3477
|
);
|
|
3437
3478
|
return;
|
|
@@ -3459,6 +3500,9 @@ var langsmithAdapter = {
|
|
|
3459
3500
|
|
|
3460
3501
|
// src/internal/telemetry/adapters/posthog.ts
|
|
3461
3502
|
var registeredHere6 = false;
|
|
3503
|
+
function presentEnv(value) {
|
|
3504
|
+
return value !== void 0 && value.trim().length > 0 ? value : void 0;
|
|
3505
|
+
}
|
|
3462
3506
|
var posthogAdapter = {
|
|
3463
3507
|
moduleName: "posthog-node",
|
|
3464
3508
|
displayName: "PostHog",
|
|
@@ -3468,12 +3512,12 @@ var posthogAdapter = {
|
|
|
3468
3512
|
const ph = safeRequire("posthog-node");
|
|
3469
3513
|
const otel = safeRequire("@opentelemetry/api");
|
|
3470
3514
|
if (ph === void 0 || otel === void 0) return;
|
|
3471
|
-
const key = process.env.POSTHOG_API_KEY ?? process.env.POSTHOG_PROJECT_API_KEY;
|
|
3515
|
+
const key = presentEnv(process.env.POSTHOG_API_KEY) ?? presentEnv(process.env.POSTHOG_PROJECT_API_KEY);
|
|
3472
3516
|
if (typeof key !== "string" || key.length === 0) {
|
|
3473
3517
|
return;
|
|
3474
3518
|
}
|
|
3475
3519
|
const client = new ph.PostHog(key, {
|
|
3476
|
-
host: process.env.POSTHOG_HOST ?? "https://us.i.posthog.com"
|
|
3520
|
+
host: presentEnv(process.env.POSTHOG_HOST) ?? "https://us.i.posthog.com"
|
|
3477
3521
|
});
|
|
3478
3522
|
const provider = otel.trace.getTracerProvider();
|
|
3479
3523
|
if (provider.addSpanProcessor === void 0) return;
|
|
@@ -3560,11 +3604,11 @@ function tryAutoRegisterAdapters(settings) {
|
|
|
3560
3604
|
try {
|
|
3561
3605
|
adapter.register();
|
|
3562
3606
|
registered.add(adapter.moduleName);
|
|
3563
|
-
|
|
3607
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] telemetry: ${adapter.displayName} auto-instrumented.
|
|
3564
3608
|
`);
|
|
3565
3609
|
} catch (cause) {
|
|
3566
3610
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3567
|
-
|
|
3611
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3568
3612
|
`[theokit-sdk] telemetry: ${adapter.displayName} detected but failed to register: ${message}
|
|
3569
3613
|
`
|
|
3570
3614
|
);
|
|
@@ -3577,7 +3621,7 @@ var cachedOtel;
|
|
|
3577
3621
|
function loadOtel() {
|
|
3578
3622
|
if (cachedOtel === void 0) {
|
|
3579
3623
|
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-
|
|
3624
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UFAO4T7Z.cjs', document.baseURI).href)));
|
|
3581
3625
|
const mod = r("@opentelemetry/api");
|
|
3582
3626
|
cachedOtel = mod;
|
|
3583
3627
|
} catch {
|
|
@@ -3620,7 +3664,7 @@ function safe(op, fallback) {
|
|
|
3620
3664
|
if (!warnedOnce) {
|
|
3621
3665
|
warnedOnce = true;
|
|
3622
3666
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3623
|
-
|
|
3667
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3624
3668
|
`[theokit-sdk] telemetry exporter error (suppressed; agent.send continues): ${message}
|
|
3625
3669
|
`
|
|
3626
3670
|
);
|
|
@@ -3634,7 +3678,7 @@ function createTelemetry(settings) {
|
|
|
3634
3678
|
if (otel === null) {
|
|
3635
3679
|
if (!warnedOnce) {
|
|
3636
3680
|
warnedOnce = true;
|
|
3637
|
-
|
|
3681
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3638
3682
|
"[theokit-sdk] telemetry.enabled = true but `@opentelemetry/api` is not installed; telemetry is a no-op.\n"
|
|
3639
3683
|
);
|
|
3640
3684
|
}
|
|
@@ -3728,12 +3772,12 @@ function wrapSpan(span, openSpans) {
|
|
|
3728
3772
|
}
|
|
3729
3773
|
function redactAttrValue(value) {
|
|
3730
3774
|
if (typeof value !== "string") return value;
|
|
3731
|
-
return
|
|
3775
|
+
return chunkJTB5Q42C_cjs.redactSecrets(value);
|
|
3732
3776
|
}
|
|
3733
3777
|
function redactAttrs(attrs) {
|
|
3734
3778
|
const out = {};
|
|
3735
3779
|
for (const [k, v] of Object.entries(attrs)) {
|
|
3736
|
-
out[k] = typeof v === "string" ?
|
|
3780
|
+
out[k] = typeof v === "string" ? chunkJTB5Q42C_cjs.redactSecrets(v) : v;
|
|
3737
3781
|
}
|
|
3738
3782
|
return out;
|
|
3739
3783
|
}
|
|
@@ -3751,10 +3795,11 @@ var ProvidersManagerImpl = class {
|
|
|
3751
3795
|
routes() {
|
|
3752
3796
|
const resolved = [];
|
|
3753
3797
|
const modelProvider = providerFromModel(this.model);
|
|
3798
|
+
const modelId = this.model?.id;
|
|
3754
3799
|
const seen = /* @__PURE__ */ new Set();
|
|
3755
3800
|
if (this.providers?.routes !== void 0) {
|
|
3756
3801
|
for (const route of this.providers.routes) {
|
|
3757
|
-
const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
|
|
3802
|
+
const resolvedRoute = resolveRoute(route, modelProvider, modelId, this.plugins);
|
|
3758
3803
|
if (!seen.has(route.capability)) {
|
|
3759
3804
|
seen.add(route.capability);
|
|
3760
3805
|
resolved.push(resolvedRoute);
|
|
@@ -3770,9 +3815,9 @@ function providerFromModel(model) {
|
|
|
3770
3815
|
if (id.includes(":")) return id.split(":")[0];
|
|
3771
3816
|
return void 0;
|
|
3772
3817
|
}
|
|
3773
|
-
function resolveRoute(route, modelProvider, plugins) {
|
|
3818
|
+
function resolveRoute(route, modelProvider, modelId, plugins) {
|
|
3774
3819
|
if (route.capability === "chat" && modelProvider === route.provider) {
|
|
3775
|
-
const modelName = extractModelName(modelProvider, route);
|
|
3820
|
+
const modelName = extractModelName(modelProvider, modelId, route);
|
|
3776
3821
|
const base = {
|
|
3777
3822
|
capability: route.capability,
|
|
3778
3823
|
provider: route.provider,
|
|
@@ -3794,13 +3839,11 @@ function resolveRoute(route, modelProvider, plugins) {
|
|
|
3794
3839
|
reason: "explicit-route"
|
|
3795
3840
|
};
|
|
3796
3841
|
}
|
|
3797
|
-
function extractModelName(prefix, route) {
|
|
3842
|
+
function extractModelName(prefix, modelId, route) {
|
|
3798
3843
|
if (route.model !== void 0) return route.model;
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
if (provider === "anthropic") return "claude-3-7-sonnet";
|
|
3803
|
-
return void 0;
|
|
3844
|
+
if (prefix !== route.provider || modelId === void 0) return void 0;
|
|
3845
|
+
const name = modelId.slice(modelId.indexOf(":") + 1);
|
|
3846
|
+
return name.length > 0 ? name : void 0;
|
|
3804
3847
|
}
|
|
3805
3848
|
var MAX_MD_FILE_BYTES = 1048576;
|
|
3806
3849
|
async function loadMarkdownEntities(opts) {
|
|
@@ -3815,10 +3858,10 @@ async function loadMarkdownEntities(opts) {
|
|
|
3815
3858
|
const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
|
|
3816
3859
|
if (raw === null) continue;
|
|
3817
3860
|
const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
|
|
3818
|
-
const fields =
|
|
3861
|
+
const fields = chunkIWBGCBR6_cjs.parseSimpleYaml(split.frontmatter);
|
|
3819
3862
|
const parsed = schema.safeParse(fields);
|
|
3820
3863
|
if (!parsed.success) {
|
|
3821
|
-
throw new
|
|
3864
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3822
3865
|
`Invalid frontmatter in ${resolved.source}: ${parsed.error.message}`,
|
|
3823
3866
|
{ code: `${errorCodePrefix}_frontmatter_invalid` }
|
|
3824
3867
|
);
|
|
@@ -3836,13 +3879,13 @@ async function assertFileSizeUnderCap(source, errorCodePrefix) {
|
|
|
3836
3879
|
try {
|
|
3837
3880
|
const info = await promises.stat(source);
|
|
3838
3881
|
if (info.size > MAX_MD_FILE_BYTES) {
|
|
3839
|
-
throw new
|
|
3882
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3840
3883
|
`Config file ${source} exceeds 1 MB size limit (${info.size} bytes). Reduce the file or split into multiple entities.`,
|
|
3841
3884
|
{ code: `${errorCodePrefix}_file_too_large` }
|
|
3842
3885
|
);
|
|
3843
3886
|
}
|
|
3844
3887
|
} catch (cause) {
|
|
3845
|
-
if (cause instanceof
|
|
3888
|
+
if (cause instanceof chunkK3FW2XZD_cjs.ConfigurationError) throw cause;
|
|
3846
3889
|
}
|
|
3847
3890
|
}
|
|
3848
3891
|
async function readDirSafe(dir, errorCodePrefix) {
|
|
@@ -3851,7 +3894,7 @@ async function readDirSafe(dir, errorCodePrefix) {
|
|
|
3851
3894
|
} catch (cause) {
|
|
3852
3895
|
const code = cause.code;
|
|
3853
3896
|
if (code === "ENOENT") return null;
|
|
3854
|
-
throw new
|
|
3897
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Failed to read ${dir}`, {
|
|
3855
3898
|
code: `${errorCodePrefix}_dir_read_error`,
|
|
3856
3899
|
cause
|
|
3857
3900
|
});
|
|
@@ -3868,7 +3911,7 @@ function resolveEntryPath(entry, pattern, dir) {
|
|
|
3868
3911
|
function splitFrontmatter(raw, source, errorCodePrefix) {
|
|
3869
3912
|
const match = /^---\s*\n([\s\S]*?)\n---\s*(?:\n|$)/.exec(raw);
|
|
3870
3913
|
if (match === null) {
|
|
3871
|
-
throw new
|
|
3914
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3872
3915
|
`Missing or malformed frontmatter in ${source} (expected \`---\` delimited block at file head)`,
|
|
3873
3916
|
{ code: `${errorCodePrefix}_missing_frontmatter` }
|
|
3874
3917
|
);
|
|
@@ -3897,7 +3940,7 @@ function applyAggregateCap(sources, maxTotal) {
|
|
|
3897
3940
|
}
|
|
3898
3941
|
const remaining = maxTotal - totalBytes;
|
|
3899
3942
|
if (remaining > 0) {
|
|
3900
|
-
const { finalContent } =
|
|
3943
|
+
const { finalContent } = chunkQ47R5E2X_cjs.truncateWithMarker(s.content, remaining);
|
|
3901
3944
|
kept.push({ ...s, content: finalContent, truncated: true });
|
|
3902
3945
|
totalBytes = maxTotal;
|
|
3903
3946
|
} else {
|
|
@@ -3971,9 +4014,9 @@ var FileContextManager = class {
|
|
|
3971
4014
|
this.lastScope = [...touchedFiles];
|
|
3972
4015
|
const config = await loadContextConfig(this.cwd);
|
|
3973
4016
|
const legacy = await loadSources(config, this.cwd);
|
|
3974
|
-
const maxBytesPerFile = this.settings.maxBytesPerFile ??
|
|
4017
|
+
const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkQ47R5E2X_cjs.DEFAULT_MAX_BYTES_PER_FILE;
|
|
3975
4018
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
3976
|
-
const discovered = await
|
|
4019
|
+
const discovered = await chunkQ47R5E2X_cjs.runDiscovery({
|
|
3977
4020
|
cwd: this.cwd,
|
|
3978
4021
|
maxBytesPerFile,
|
|
3979
4022
|
skipLegacyTheokitContext: true,
|
|
@@ -4042,7 +4085,7 @@ async function loadContextConfig(cwd) {
|
|
|
4042
4085
|
});
|
|
4043
4086
|
if (mdEntities.length > 0) {
|
|
4044
4087
|
if (fs.existsSync(jsonPath)) {
|
|
4045
|
-
|
|
4088
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4046
4089
|
"context-both-present",
|
|
4047
4090
|
"[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
|
|
4048
4091
|
);
|
|
@@ -4052,7 +4095,7 @@ async function loadContextConfig(cwd) {
|
|
|
4052
4095
|
};
|
|
4053
4096
|
}
|
|
4054
4097
|
if (!fs.existsSync(jsonPath)) return { sources: [] };
|
|
4055
|
-
|
|
4098
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4056
4099
|
"context-json-deprecated",
|
|
4057
4100
|
"[theokit-sdk] .theokit/context.json is deprecated; migrate to .theokit/context/<name>.md via theokit-migrate-config"
|
|
4058
4101
|
);
|
|
@@ -4060,7 +4103,7 @@ async function loadContextConfig(cwd) {
|
|
|
4060
4103
|
try {
|
|
4061
4104
|
raw = await promises.readFile(jsonPath, "utf8");
|
|
4062
4105
|
} catch (cause) {
|
|
4063
|
-
throw new
|
|
4106
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Failed to read context config: ${jsonPath}`, {
|
|
4064
4107
|
code: "context_read_error",
|
|
4065
4108
|
cause
|
|
4066
4109
|
});
|
|
@@ -4072,13 +4115,13 @@ function parseConfig(raw, configPath) {
|
|
|
4072
4115
|
try {
|
|
4073
4116
|
parsed = JSON.parse(raw);
|
|
4074
4117
|
} catch (cause) {
|
|
4075
|
-
throw new
|
|
4118
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Invalid JSON in context config: ${configPath}`, {
|
|
4076
4119
|
code: "context_json_invalid",
|
|
4077
4120
|
cause
|
|
4078
4121
|
});
|
|
4079
4122
|
}
|
|
4080
4123
|
if (!parsed || typeof parsed !== "object") {
|
|
4081
|
-
throw new
|
|
4124
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Context config must be an object: ${configPath}`, {
|
|
4082
4125
|
code: "context_config_shape"
|
|
4083
4126
|
});
|
|
4084
4127
|
}
|
|
@@ -4093,7 +4136,7 @@ function parseConfig(raw, configPath) {
|
|
|
4093
4136
|
}
|
|
4094
4137
|
function readSources(sourcesRaw, configPath) {
|
|
4095
4138
|
if (!Array.isArray(sourcesRaw)) {
|
|
4096
|
-
throw new
|
|
4139
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Context config sources must be an array: ${configPath}`, {
|
|
4097
4140
|
code: "context_sources_shape"
|
|
4098
4141
|
});
|
|
4099
4142
|
}
|
|
@@ -4118,7 +4161,6 @@ async function loadSources(config, cwd) {
|
|
|
4118
4161
|
continue;
|
|
4119
4162
|
}
|
|
4120
4163
|
try {
|
|
4121
|
-
await promises.stat(absolute);
|
|
4122
4164
|
const content = await promises.readFile(absolute, "utf8");
|
|
4123
4165
|
const tokens = tokenizeContent(content);
|
|
4124
4166
|
results.push({ ...source, status: "included", tokens });
|
|
@@ -4191,7 +4233,7 @@ var PluginsManager = class {
|
|
|
4191
4233
|
async refresh() {
|
|
4192
4234
|
this.plugins = [];
|
|
4193
4235
|
const pluginsRoot = path.join(this.cwd, ".theokit", "plugins");
|
|
4194
|
-
const entries = await
|
|
4236
|
+
const entries = await chunkIWBGCBR6_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
|
|
4195
4237
|
for (const entry of entries) {
|
|
4196
4238
|
if (!entry.isDirectory()) continue;
|
|
4197
4239
|
const folderName = entry.name;
|
|
@@ -4199,13 +4241,13 @@ var PluginsManager = class {
|
|
|
4199
4241
|
const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
|
|
4200
4242
|
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
|
|
4201
4243
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4202
|
-
|
|
4244
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4203
4245
|
`plugin-${folderName}-both`,
|
|
4204
4246
|
`[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
|
|
4205
4247
|
);
|
|
4206
4248
|
}
|
|
4207
4249
|
if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4208
|
-
|
|
4250
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4209
4251
|
"plugin-json-deprecated",
|
|
4210
4252
|
"[theokit-sdk] plugin.json manifests are deprecated; migrate to PLUGIN.md via theokit-migrate-config"
|
|
4211
4253
|
);
|
|
@@ -4223,20 +4265,35 @@ var PluginsManager = class {
|
|
|
4223
4265
|
const entry = metadata.entry;
|
|
4224
4266
|
if (entry === void 0) return;
|
|
4225
4267
|
const pluginRoot = path.join(this.cwd, ".theokit", "plugins", folderName);
|
|
4226
|
-
const entryPath =
|
|
4268
|
+
const entryPath = chunkR3UPQFKK_cjs.safePathJoin(pluginRoot, entry);
|
|
4227
4269
|
try {
|
|
4228
4270
|
await promises.readFile(entryPath, "utf8");
|
|
4229
4271
|
} catch (cause) {
|
|
4230
|
-
throw new
|
|
4272
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${metadata.name} entry file is missing: ${entry}`, {
|
|
4231
4273
|
code: "plugin_entry_missing",
|
|
4232
4274
|
cause
|
|
4233
4275
|
});
|
|
4234
4276
|
}
|
|
4235
4277
|
}
|
|
4278
|
+
/**
|
|
4279
|
+
* B-107 measured this guard as unreachable and it was REMOVED on 2026-08-20. The pre-push gate
|
|
4280
|
+
* caught the regression the same hour: `tests/contract/plugins.contract.test.ts:69` drives
|
|
4281
|
+
* `Agent.create` with `cloud` plus `plugins.paths` and requires a `ConfigurationError`.
|
|
4282
|
+
*
|
|
4283
|
+
* The measurement that said "unreachable" was a `tsc` probe returning TS2353 — `plugins.paths` is
|
|
4284
|
+
* not in the declared `AgentOptions`. That proves the option is undeclarable in TypeScript; it
|
|
4285
|
+
* does NOT prove the value cannot arrive. The contract test casts through a `ProposedAgentOptions`
|
|
4286
|
+
* shape it declares itself, which is exactly what a JavaScript caller, a JSON config or an `as`
|
|
4287
|
+
* cast does. Runtime boundary validation exists for values types cannot stop
|
|
4288
|
+
* (`rules/architecture.md` § 1) — so "the type system forbids it" is never on its own a reason to
|
|
4289
|
+
* delete a boundary check.
|
|
4290
|
+
*
|
|
4291
|
+
* Do not remove this again without making `tests/contract/plugins.contract.test.ts` go red first.
|
|
4292
|
+
*/
|
|
4236
4293
|
assertCloudRules() {
|
|
4237
4294
|
if (!this.cloud) return;
|
|
4238
4295
|
if (this.localPaths !== void 0 && this.localPaths.length > 0) {
|
|
4239
|
-
throw new
|
|
4296
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
4240
4297
|
"Cloud agents reject local plugin paths \u2014 plugins must come from committed repo files",
|
|
4241
4298
|
{ code: "cloud_plugin_path_rejected" }
|
|
4242
4299
|
);
|
|
@@ -4248,7 +4305,7 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4248
4305
|
try {
|
|
4249
4306
|
raw = await promises.readFile(manifestPath, "utf8");
|
|
4250
4307
|
} catch (cause) {
|
|
4251
|
-
throw new
|
|
4308
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} is missing plugin.json`, {
|
|
4252
4309
|
code: "plugin_missing_manifest",
|
|
4253
4310
|
cause
|
|
4254
4311
|
});
|
|
@@ -4257,13 +4314,13 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4257
4314
|
try {
|
|
4258
4315
|
parsed = JSON.parse(raw);
|
|
4259
4316
|
} catch (cause) {
|
|
4260
|
-
throw new
|
|
4317
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} manifest is invalid JSON`, {
|
|
4261
4318
|
code: "plugin_manifest_invalid",
|
|
4262
4319
|
cause
|
|
4263
4320
|
});
|
|
4264
4321
|
}
|
|
4265
4322
|
if (!parsed || typeof parsed !== "object") {
|
|
4266
|
-
throw new
|
|
4323
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} manifest must be an object`, {
|
|
4267
4324
|
code: "plugin_manifest_shape"
|
|
4268
4325
|
});
|
|
4269
4326
|
}
|
|
@@ -4282,7 +4339,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4282
4339
|
try {
|
|
4283
4340
|
raw = await promises.readFile(mdPath, "utf8");
|
|
4284
4341
|
} catch (cause) {
|
|
4285
|
-
throw new
|
|
4342
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} is missing PLUGIN.md`, {
|
|
4286
4343
|
code: "plugin_missing_manifest",
|
|
4287
4344
|
cause
|
|
4288
4345
|
});
|
|
@@ -4297,7 +4354,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4297
4354
|
});
|
|
4298
4355
|
const entity = entities.find((e) => e.slug === "PLUGIN");
|
|
4299
4356
|
if (entity === void 0) {
|
|
4300
|
-
throw new
|
|
4357
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} PLUGIN.md not parseable`, {
|
|
4301
4358
|
code: "plugin_missing_manifest"
|
|
4302
4359
|
});
|
|
4303
4360
|
}
|
|
@@ -4571,7 +4628,7 @@ function assertValidThresholds(soft, hard) {
|
|
|
4571
4628
|
["hardThreshold", hard]
|
|
4572
4629
|
]) {
|
|
4573
4630
|
if (!Number.isInteger(value) || value < 1) {
|
|
4574
|
-
throw new
|
|
4631
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
4575
4632
|
`doomLoop.${label} must be a positive integer (received ${value}).`,
|
|
4576
4633
|
{ code: "invalid_doom_loop_threshold" }
|
|
4577
4634
|
);
|
|
@@ -4880,13 +4937,19 @@ async function initLoopContext(inputs) {
|
|
|
4880
4937
|
}
|
|
4881
4938
|
async function safeListTools(client, serverName, sink) {
|
|
4882
4939
|
try {
|
|
4883
|
-
|
|
4940
|
+
const listed = await client.listTools();
|
|
4941
|
+
chunkNGESVVJN_cjs.emitRunEvent(sink, {
|
|
4942
|
+
type: "mcp_server_ready",
|
|
4943
|
+
serverName: serverName ?? "unknown",
|
|
4944
|
+
tools: listed.map((tool) => tool.name)
|
|
4945
|
+
});
|
|
4946
|
+
return listed;
|
|
4884
4947
|
} catch (cause) {
|
|
4885
4948
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
4886
4949
|
const server = serverName ?? "unknown";
|
|
4887
|
-
|
|
4950
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] mcp listTools failed (server=${server}): ${message}
|
|
4888
4951
|
`);
|
|
4889
|
-
|
|
4952
|
+
chunkNGESVVJN_cjs.emitRunEvent(sink, { type: "mcp_server_failed", serverName: server, message });
|
|
4890
4953
|
return [];
|
|
4891
4954
|
}
|
|
4892
4955
|
}
|
|
@@ -4954,7 +5017,7 @@ function emitLlmMetrics(inputs, result, startAt) {
|
|
|
4954
5017
|
inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.LLM_USAGE_MISSING, 1, {
|
|
4955
5018
|
provider: inputs.llm.name
|
|
4956
5019
|
});
|
|
4957
|
-
|
|
5020
|
+
chunkNUKRL3I6_cjs.diag(
|
|
4958
5021
|
`[theokit-sdk] llm usage missing from ${inputs.llm.name} finish \u2014 budget may undercount
|
|
4959
5022
|
`
|
|
4960
5023
|
);
|
|
@@ -5032,13 +5095,12 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
5032
5095
|
};
|
|
5033
5096
|
}
|
|
5034
5097
|
async function collectLlmEvents(generator, inputs, ctx) {
|
|
5035
|
-
let accumulatedText = "";
|
|
5036
5098
|
let errored = false;
|
|
5037
5099
|
let finishValue;
|
|
5038
5100
|
let thinking;
|
|
5101
|
+
const partial = { text: "" };
|
|
5039
5102
|
try {
|
|
5040
|
-
const result = await runCollectorLoop(generator, inputs, ctx);
|
|
5041
|
-
accumulatedText = result.accumulatedText;
|
|
5103
|
+
const result = await runCollectorLoop(generator, inputs, ctx, partial);
|
|
5042
5104
|
errored = result.errored;
|
|
5043
5105
|
finishValue = result.finishValue;
|
|
5044
5106
|
thinking = result.thinking;
|
|
@@ -5048,10 +5110,12 @@ async function collectLlmEvents(generator, inputs, ctx) {
|
|
|
5048
5110
|
ctx.events.push(buildAssistantEvent(inputs, "[aborted]"));
|
|
5049
5111
|
} else {
|
|
5050
5112
|
registerLoopError(ctx, cause);
|
|
5051
|
-
ctx.finalText =
|
|
5113
|
+
ctx.finalText = partial.text;
|
|
5114
|
+
if (partial.text !== "") ctx.events.push(buildAssistantEvent(inputs, partial.text));
|
|
5052
5115
|
}
|
|
5053
5116
|
errored = true;
|
|
5054
5117
|
}
|
|
5118
|
+
const accumulatedText = partial.text;
|
|
5055
5119
|
return {
|
|
5056
5120
|
accumulatedText,
|
|
5057
5121
|
errored,
|
|
@@ -5082,8 +5146,7 @@ async function consumeStreamEvent(inputs, reasoning, event) {
|
|
|
5082
5146
|
}
|
|
5083
5147
|
return "";
|
|
5084
5148
|
}
|
|
5085
|
-
async function runCollectorLoop(generator, inputs, ctx) {
|
|
5086
|
-
let accumulatedText = "";
|
|
5149
|
+
async function runCollectorLoop(generator, inputs, ctx, partial) {
|
|
5087
5150
|
const reasoning = { text: "", startedAt: void 0, signature: void 0 };
|
|
5088
5151
|
let errored = false;
|
|
5089
5152
|
let finishValue;
|
|
@@ -5097,16 +5160,16 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
5097
5160
|
}
|
|
5098
5161
|
if (next.value.type === "error") {
|
|
5099
5162
|
registerLoopError(ctx, next.value);
|
|
5100
|
-
ctx.finalText =
|
|
5163
|
+
ctx.finalText = partial.text;
|
|
5101
5164
|
errored = true;
|
|
5102
5165
|
break;
|
|
5103
5166
|
}
|
|
5104
|
-
|
|
5167
|
+
partial.text += await consumeStreamEvent(inputs, reasoning, next.value);
|
|
5105
5168
|
}
|
|
5106
5169
|
} finally {
|
|
5107
5170
|
thinking = await finalizeReasoning(inputs, ctx, reasoning);
|
|
5108
5171
|
}
|
|
5109
|
-
return {
|
|
5172
|
+
return { errored, finishValue, ...thinking !== void 0 ? { thinking } : {} };
|
|
5110
5173
|
}
|
|
5111
5174
|
async function consumeReasoningDelta(inputs, reasoning, delta) {
|
|
5112
5175
|
if (delta.signature !== void 0) reasoning.signature = delta.signature;
|
|
@@ -5250,7 +5313,7 @@ function coerceArgsToSchema(args, schema) {
|
|
|
5250
5313
|
}
|
|
5251
5314
|
|
|
5252
5315
|
// src/tool-error.ts
|
|
5253
|
-
var ToolError = class extends
|
|
5316
|
+
var ToolError = class extends chunkK3FW2XZD_cjs.TheokitAgentError {
|
|
5254
5317
|
name = "ToolError";
|
|
5255
5318
|
/** The error content surfaced to the model: a string, or text/image blocks. */
|
|
5256
5319
|
content;
|
|
@@ -5444,7 +5507,7 @@ function raceToolExecution(exec, opts) {
|
|
|
5444
5507
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
5445
5508
|
async function dispatchTools(inputs, tools, toolCalls, events, parentSpan) {
|
|
5446
5509
|
const maxConcurrent = inputs.maxConcurrentTools ?? 4;
|
|
5447
|
-
return
|
|
5510
|
+
return chunkILCGLTSA_cjs.mapWithConcurrency(
|
|
5448
5511
|
toolCalls,
|
|
5449
5512
|
maxConcurrent,
|
|
5450
5513
|
(call) => dispatchSingleCall(inputs, tools, call, events, parentSpan)
|
|
@@ -5472,7 +5535,7 @@ async function dispatchSingleCall(inputs, tools, call, events, parentSpan) {
|
|
|
5472
5535
|
toolSpan?.end();
|
|
5473
5536
|
return fileVeto;
|
|
5474
5537
|
}
|
|
5475
|
-
|
|
5538
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5476
5539
|
type: "tool_progress",
|
|
5477
5540
|
toolName: workingCall.name,
|
|
5478
5541
|
toolCallId: callId
|
|
@@ -5503,7 +5566,7 @@ function applyRepairAndExtractCall(tools, call) {
|
|
|
5503
5566
|
function vetoFromForkWhitelist(inputs, call, callId, events) {
|
|
5504
5567
|
const whitelistDecision = chunkVJ26EKGJ_cjs.checkToolWhitelist(call.name);
|
|
5505
5568
|
if (whitelistDecision.allowed) return void 0;
|
|
5506
|
-
|
|
5569
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5507
5570
|
type: "permission_denied",
|
|
5508
5571
|
toolName: call.name,
|
|
5509
5572
|
toolCallId: callId,
|
|
@@ -5548,7 +5611,7 @@ async function vetoFromPluginPreHook(inputs, call, callId, events) {
|
|
|
5548
5611
|
...inputs.permissionMode !== void 0 ? { permissionMode: inputs.permissionMode } : {}
|
|
5549
5612
|
});
|
|
5550
5613
|
if (pluginVeto === void 0) return void 0;
|
|
5551
|
-
|
|
5614
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5552
5615
|
type: "permission_denied",
|
|
5553
5616
|
toolName: call.name,
|
|
5554
5617
|
toolCallId: callId,
|
|
@@ -5577,7 +5640,7 @@ async function vetoFromFileHookPreDecision(inputs, call, callId, events) {
|
|
|
5577
5640
|
runId: inputs.runId
|
|
5578
5641
|
});
|
|
5579
5642
|
if (!preDecision.blocked) return void 0;
|
|
5580
|
-
|
|
5643
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5581
5644
|
type: "permission_denied",
|
|
5582
5645
|
toolName: call.name,
|
|
5583
5646
|
toolCallId: callId,
|
|
@@ -5678,7 +5741,7 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
|
|
|
5678
5741
|
agentId: inputs.agentId,
|
|
5679
5742
|
runId: inputs.runId
|
|
5680
5743
|
}).catch((err) => {
|
|
5681
|
-
|
|
5744
|
+
chunkNUKRL3I6_cjs.diag(
|
|
5682
5745
|
`[theokit-sdk] postToolUse hook error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5683
5746
|
`
|
|
5684
5747
|
);
|
|
@@ -5697,7 +5760,7 @@ async function emitToolLifecycleDelta(inputs, update) {
|
|
|
5697
5760
|
try {
|
|
5698
5761
|
await inputs.onDelta({ update });
|
|
5699
5762
|
} catch (err) {
|
|
5700
|
-
|
|
5763
|
+
chunkNUKRL3I6_cjs.diag(
|
|
5701
5764
|
`[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5702
5765
|
`
|
|
5703
5766
|
);
|
|
@@ -5709,7 +5772,7 @@ async function safeEmitToolHook(callback, event) {
|
|
|
5709
5772
|
await callback(event);
|
|
5710
5773
|
} catch (cause) {
|
|
5711
5774
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
5712
|
-
|
|
5775
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] tool lifecycle hook threw: ${msg}
|
|
5713
5776
|
`);
|
|
5714
5777
|
}
|
|
5715
5778
|
}
|
|
@@ -5776,7 +5839,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
5776
5839
|
(p) => (
|
|
5777
5840
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
5778
5841
|
// structured content); image blocks pass through untouched.
|
|
5779
|
-
p.type === "tool_result" ? { ...p, content:
|
|
5842
|
+
p.type === "tool_result" ? { ...p, content: chunkUNDROG5N_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
5780
5843
|
)
|
|
5781
5844
|
);
|
|
5782
5845
|
}
|
|
@@ -5928,7 +5991,7 @@ function stripDateSuffix(model) {
|
|
|
5928
5991
|
return model.replace(/-\d{4}-?\d{2}-?\d{2}$/, "");
|
|
5929
5992
|
}
|
|
5930
5993
|
function normalizeAnthropicDots(model) {
|
|
5931
|
-
return model.replace(/(
|
|
5994
|
+
return model.replace(/(?<=\d)\.(?=\d)/g, "-");
|
|
5932
5995
|
}
|
|
5933
5996
|
function stripOpenRouterPrefix(modelId) {
|
|
5934
5997
|
return modelId.startsWith("openrouter/") ? modelId.slice("openrouter/".length) : modelId;
|
|
@@ -5971,7 +6034,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
5971
6034
|
const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
|
|
5972
6035
|
if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
|
|
5973
6036
|
for (const key of candidates) {
|
|
5974
|
-
const info =
|
|
6037
|
+
const info = chunkRM7Y65IG_cjs.getCatalogModelInfo(key);
|
|
5975
6038
|
const cost = info?.cost;
|
|
5976
6039
|
if (cost === void 0) continue;
|
|
5977
6040
|
const [prov, ...modelParts] = key.split("/");
|
|
@@ -5983,7 +6046,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
5983
6046
|
...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
|
|
5984
6047
|
...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
|
|
5985
6048
|
// M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
|
|
5986
|
-
pricingVersion:
|
|
6049
|
+
pricingVersion: chunkRM7Y65IG_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
|
|
5987
6050
|
};
|
|
5988
6051
|
}
|
|
5989
6052
|
return void 0;
|
|
@@ -6109,7 +6172,7 @@ function accumulateUsage(usage, turn) {
|
|
|
6109
6172
|
function computeUsageCost(inputs, usage) {
|
|
6110
6173
|
const modelId = inputs.model.id;
|
|
6111
6174
|
if (modelId === void 0 || modelId === "auto") return void 0;
|
|
6112
|
-
const parsed =
|
|
6175
|
+
const parsed = chunk3EE6LVWT_cjs.parseModelId(modelId);
|
|
6113
6176
|
const provider = parsed.provider ?? inputs.llm.name;
|
|
6114
6177
|
const model = parsed.provider !== void 0 ? parsed.name : modelId;
|
|
6115
6178
|
return computeCost({ provider, model, usage });
|
|
@@ -6181,6 +6244,12 @@ async function runAgentLoop(inputs) {
|
|
|
6181
6244
|
}
|
|
6182
6245
|
if (budget.shouldContinue() === false && ctx.finalStatus === "finished" && ctx.finalText === "") {
|
|
6183
6246
|
ctx.finalStatus = "error";
|
|
6247
|
+
if (ctx.error === void 0) {
|
|
6248
|
+
ctx.error = {
|
|
6249
|
+
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.`,
|
|
6250
|
+
code: "iteration_limit_reached"
|
|
6251
|
+
};
|
|
6252
|
+
}
|
|
6184
6253
|
}
|
|
6185
6254
|
sendSpan?.setAttribute("status", ctx.finalStatus);
|
|
6186
6255
|
if (ctx.stoppedByDoomLoop === true) sendSpan?.setAttribute("stoppedByDoomLoop", true);
|
|
@@ -6436,15 +6505,15 @@ var FallbackLlmClient = class {
|
|
|
6436
6505
|
let lastError;
|
|
6437
6506
|
for (const client of this.clients) {
|
|
6438
6507
|
if (signal.aborted) throw abortError(signal);
|
|
6439
|
-
const attempt = await
|
|
6508
|
+
const attempt = await chunkUNDROG5N_cjs.tryFirstEvent(client, request, signal, true);
|
|
6440
6509
|
if (attempt.kind === "handshake_error") {
|
|
6441
6510
|
lastError = attempt.error;
|
|
6442
6511
|
continue;
|
|
6443
6512
|
}
|
|
6444
|
-
return yield*
|
|
6513
|
+
return yield* chunkUNDROG5N_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6445
6514
|
}
|
|
6446
6515
|
if (lastError !== void 0) throw lastError;
|
|
6447
|
-
throw new
|
|
6516
|
+
throw new chunkK3FW2XZD_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
6448
6517
|
code: "fallback_empty_chain"
|
|
6449
6518
|
});
|
|
6450
6519
|
}
|
|
@@ -6467,7 +6536,7 @@ function reconnectDelay(attempt) {
|
|
|
6467
6536
|
return ms <= 0 ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, ms));
|
|
6468
6537
|
}
|
|
6469
6538
|
function mcpTimeoutError(name, timeoutMs) {
|
|
6470
|
-
return new
|
|
6539
|
+
return new chunkK3FW2XZD_cjs.NetworkError(`MCP ${name} request timed out after ${timeoutMs}ms`, {
|
|
6471
6540
|
code: "mcp_timeout"
|
|
6472
6541
|
});
|
|
6473
6542
|
}
|
|
@@ -6550,7 +6619,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6550
6619
|
child.stdin.on("error", () => void 0);
|
|
6551
6620
|
child.on("error", () => {
|
|
6552
6621
|
this.rejectAllPending(
|
|
6553
|
-
new
|
|
6622
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} process crashed`, { code: "mcp_crashed" })
|
|
6554
6623
|
);
|
|
6555
6624
|
});
|
|
6556
6625
|
child.on("exit", () => {
|
|
@@ -6558,7 +6627,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6558
6627
|
this.child = void 0;
|
|
6559
6628
|
this.dropped = true;
|
|
6560
6629
|
this.rejectAllPending(
|
|
6561
|
-
new
|
|
6630
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6562
6631
|
);
|
|
6563
6632
|
});
|
|
6564
6633
|
}
|
|
@@ -6586,7 +6655,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6586
6655
|
if (this.child !== void 0) return Promise.resolve();
|
|
6587
6656
|
if (!this.dropped) {
|
|
6588
6657
|
return Promise.reject(
|
|
6589
|
-
new
|
|
6658
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6590
6659
|
);
|
|
6591
6660
|
}
|
|
6592
6661
|
this.reconnectPromise ??= this.reconnect().finally(() => {
|
|
@@ -6607,13 +6676,13 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6607
6676
|
lastErr = err;
|
|
6608
6677
|
}
|
|
6609
6678
|
}
|
|
6610
|
-
throw new
|
|
6679
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} reconnect exhausted`, {
|
|
6611
6680
|
code: "mcp_disconnected",
|
|
6612
6681
|
...lastErr instanceof Error ? { cause: lastErr } : {}
|
|
6613
6682
|
});
|
|
6614
6683
|
}
|
|
6615
6684
|
async close() {
|
|
6616
|
-
this.rejectAllPending(new
|
|
6685
|
+
this.rejectAllPending(new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
|
|
6617
6686
|
const child = this.child;
|
|
6618
6687
|
this.child = void 0;
|
|
6619
6688
|
this.dropped = false;
|
|
@@ -6632,7 +6701,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6632
6701
|
if (this.buffer.length > MAX_STDIO_BUFFER_BYTES) {
|
|
6633
6702
|
this.buffer = "";
|
|
6634
6703
|
this.rejectAllPending(
|
|
6635
|
-
new
|
|
6704
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} exceeded stdout buffer limit`, {
|
|
6636
6705
|
code: "mcp_buffer_overflow"
|
|
6637
6706
|
})
|
|
6638
6707
|
);
|
|
@@ -6667,7 +6736,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6667
6736
|
if (child !== void 0) return this.send(child, method, params);
|
|
6668
6737
|
if (this.dropped) return this.reconnectAndRequest(method, params);
|
|
6669
6738
|
return Promise.reject(
|
|
6670
|
-
new
|
|
6739
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6671
6740
|
);
|
|
6672
6741
|
}
|
|
6673
6742
|
/** M2 #59 — reconnect a dropped client, then send. Separate async path so the
|
|
@@ -6676,7 +6745,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6676
6745
|
await this.ensureConnected();
|
|
6677
6746
|
const child = this.child;
|
|
6678
6747
|
if (child === void 0) {
|
|
6679
|
-
throw new
|
|
6748
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" });
|
|
6680
6749
|
}
|
|
6681
6750
|
return this.send(child, method, params);
|
|
6682
6751
|
}
|
|
@@ -6693,7 +6762,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6693
6762
|
this.child = void 0;
|
|
6694
6763
|
this.dropped = true;
|
|
6695
6764
|
this.rejectAllPending(
|
|
6696
|
-
new
|
|
6765
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6697
6766
|
);
|
|
6698
6767
|
}, this.timeoutMs);
|
|
6699
6768
|
this.pending.set(id, { resolve, reject, timer });
|
|
@@ -6744,12 +6813,6 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6744
6813
|
...this.config.headers ?? {}
|
|
6745
6814
|
};
|
|
6746
6815
|
}
|
|
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
6816
|
/**
|
|
6754
6817
|
* Read one JSON-RPC response, in either encoding the server may choose.
|
|
6755
6818
|
*
|
|
@@ -6771,10 +6834,16 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6771
6834
|
if (payload === "") continue;
|
|
6772
6835
|
return JSON.parse(payload);
|
|
6773
6836
|
}
|
|
6774
|
-
throw new
|
|
6837
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
|
|
6775
6838
|
code: "mcp_http_error"
|
|
6776
6839
|
});
|
|
6777
6840
|
}
|
|
6841
|
+
/**
|
|
6842
|
+
* Capture the session on the FIRST response that carries it (the `initialize`).
|
|
6843
|
+
*
|
|
6844
|
+
* Never overwritten by a later one: a server that re-issues mid-session would otherwise split
|
|
6845
|
+
* the session in two, and the second half would not see the first half's state.
|
|
6846
|
+
*/
|
|
6778
6847
|
captureSession(response) {
|
|
6779
6848
|
if (this.sessionId !== void 0) return;
|
|
6780
6849
|
const issued = response.headers.get("mcp-session-id");
|
|
@@ -6799,7 +6868,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6799
6868
|
throw cause;
|
|
6800
6869
|
}
|
|
6801
6870
|
if (!response.ok) {
|
|
6802
|
-
throw new
|
|
6871
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} returned ${response.status}`, {
|
|
6803
6872
|
code: "mcp_http_error"
|
|
6804
6873
|
});
|
|
6805
6874
|
}
|
|
@@ -6815,14 +6884,14 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6815
6884
|
function resolveMcpCwd(configCwd) {
|
|
6816
6885
|
if (configCwd === void 0) return process.cwd();
|
|
6817
6886
|
if (path.isAbsolute(configCwd)) return configCwd;
|
|
6818
|
-
return
|
|
6887
|
+
return chunkR3UPQFKK_cjs.safePathJoin(process.cwd(), configCwd);
|
|
6819
6888
|
}
|
|
6820
6889
|
|
|
6821
6890
|
// src/internal/providers/register-plugin-providers.ts
|
|
6822
6891
|
function registerPluginProviderProfiles(entries) {
|
|
6823
6892
|
let registered2 = 0;
|
|
6824
6893
|
for (const entry of entries) {
|
|
6825
|
-
|
|
6894
|
+
chunkRM7Y65IG_cjs.registerProvider(entry.profile);
|
|
6826
6895
|
registered2 += 1;
|
|
6827
6896
|
}
|
|
6828
6897
|
return registered2;
|
|
@@ -6902,7 +6971,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
|
|
|
6902
6971
|
if (exposedSet.has(name)) continue;
|
|
6903
6972
|
const hint = suggestClosest(name, exposedSet);
|
|
6904
6973
|
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
|
-
|
|
6974
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
6906
6975
|
`personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
|
|
6907
6976
|
message
|
|
6908
6977
|
);
|
|
@@ -6944,7 +7013,7 @@ function levenshtein(a, b) {
|
|
|
6944
7013
|
// src/internal/local-agent/real-local-run-tools.ts
|
|
6945
7014
|
function declarativeSubagentTools(agents2, parentTools) {
|
|
6946
7015
|
if (agents2 === void 0 || Object.keys(agents2).length === 0) return [];
|
|
6947
|
-
return
|
|
7016
|
+
return chunk4O5TGQBW_cjs.subAgentToolsFromDefinitions(agents2, parentTools);
|
|
6948
7017
|
}
|
|
6949
7018
|
function resolveInheritedCredentials(agentOptions) {
|
|
6950
7019
|
const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
|
|
@@ -7011,25 +7080,26 @@ function createRealLocalRun(options) {
|
|
|
7011
7080
|
}
|
|
7012
7081
|
var pluginProvidersAnnounced = false;
|
|
7013
7082
|
function resolveRunProvider(options) {
|
|
7014
|
-
|
|
7083
|
+
chunkRM7Y65IG_cjs.registerBuiltins();
|
|
7015
7084
|
const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
|
|
7016
7085
|
const registered2 = registerPluginProviderProfiles(profiles);
|
|
7017
7086
|
if (registered2 > 0 && !pluginProvidersAnnounced) {
|
|
7018
7087
|
pluginProvidersAnnounced = true;
|
|
7019
7088
|
const names = profiles.map((e) => e.profile.name).join(", ");
|
|
7020
|
-
|
|
7089
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] registered ${registered2} plugin provider profile(s): ${names}
|
|
7021
7090
|
`);
|
|
7022
7091
|
}
|
|
7023
|
-
const parsedModel =
|
|
7024
|
-
const modelInferredProvider = parsedModel.provider !== void 0 &&
|
|
7025
|
-
const keyInferredProvider =
|
|
7026
|
-
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ??
|
|
7092
|
+
const parsedModel = chunk3EE6LVWT_cjs.parseModelId(options.model?.id);
|
|
7093
|
+
const modelInferredProvider = parsedModel.provider !== void 0 && chunkRM7Y65IG_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
|
|
7094
|
+
const keyInferredProvider = chunkUNDROG5N_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
|
|
7095
|
+
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkUNDROG5N_cjs.detectPrimaryProvider();
|
|
7096
|
+
chunkUNDROG5N_cjs.warnProviderPrecedenceOnce(modelInferredProvider, primary);
|
|
7027
7097
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7028
7098
|
return { primary, effectiveModelId };
|
|
7029
7099
|
}
|
|
7030
7100
|
function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
7031
7101
|
if (apiKey === void 0 || apiKey.length === 0) return pools;
|
|
7032
|
-
if (
|
|
7102
|
+
if (chunkUNDROG5N_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
|
|
7033
7103
|
const existing = pools?.[primary];
|
|
7034
7104
|
if (existing !== void 0 && existing.length > 0) return pools;
|
|
7035
7105
|
return { ...pools ?? {}, [primary]: [apiKey] };
|
|
@@ -7037,7 +7107,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
|
7037
7107
|
function buildLoopInputs(options, runId, userText, userImages) {
|
|
7038
7108
|
const maxIterations = options.sendOptions.maxIterations;
|
|
7039
7109
|
if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
|
|
7040
|
-
throw new
|
|
7110
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
7041
7111
|
`SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
|
|
7042
7112
|
{ code: "invalid_max_iterations" }
|
|
7043
7113
|
);
|
|
@@ -7052,14 +7122,16 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7052
7122
|
const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
|
|
7053
7123
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7054
7124
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7055
|
-
const
|
|
7125
|
+
const modelBaseUrl = options.model?.url;
|
|
7126
|
+
const chain = chunkUNDROG5N_cjs.resolveProviderChain({
|
|
7056
7127
|
primary,
|
|
7128
|
+
...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
|
|
7057
7129
|
...fallback !== void 0 ? { fallback } : {},
|
|
7058
7130
|
...apiKeys !== void 0 ? { apiKeys } : {},
|
|
7059
7131
|
...credentialPoolStrategy !== void 0 ? { credentialPoolStrategy } : {},
|
|
7060
7132
|
...extractToolCallsFromContent === true ? { extractToolCallsFromContent: true } : {},
|
|
7061
7133
|
...rateLimitSink !== void 0 ? {
|
|
7062
|
-
onRateLimit: (info) =>
|
|
7134
|
+
onRateLimit: (info) => chunkNGESVVJN_cjs.emitRunEvent(rateLimitSink, { type: "rate_limit", ...info })
|
|
7063
7135
|
} : {}
|
|
7064
7136
|
});
|
|
7065
7137
|
const llm = chain.length === 1 ? chain[0] : new FallbackLlmClient(chain);
|
|
@@ -7241,7 +7313,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7241
7313
|
};
|
|
7242
7314
|
try {
|
|
7243
7315
|
const runLoop = () => inputs.activeTools !== void 0 ? chunkVJ26EKGJ_cjs.withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : runAgentLoop(inputs);
|
|
7244
|
-
const output = await
|
|
7316
|
+
const output = await chunk4O5TGQBW_cjs.withInheritedSubAgentCredentials(this.inheritedCredentials, runLoop);
|
|
7245
7317
|
this.applyAgentLoopOutput(output);
|
|
7246
7318
|
this.transitionTo(output.finalStatus);
|
|
7247
7319
|
} catch (cause) {
|
|
@@ -7334,7 +7406,7 @@ function buildRealRunOptions(args) {
|
|
|
7334
7406
|
};
|
|
7335
7407
|
}
|
|
7336
7408
|
async function createFixtureRunHelper(args) {
|
|
7337
|
-
const sessionMessages =
|
|
7409
|
+
const sessionMessages = chunk5BJV5UPY_cjs.getSessionMessages(args.inputs.agentId);
|
|
7338
7410
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7339
7411
|
return createLocalRun({
|
|
7340
7412
|
agentId: args.inputs.agentId,
|
|
@@ -7352,8 +7424,8 @@ async function createFixtureRunHelper(args) {
|
|
|
7352
7424
|
});
|
|
7353
7425
|
}
|
|
7354
7426
|
async function dispatchLocalRun(args) {
|
|
7355
|
-
const apiKey =
|
|
7356
|
-
if (
|
|
7427
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(args.inputs.options.apiKey);
|
|
7428
|
+
if (chunkUNDROG5N_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7357
7429
|
return createRealLocalRun(
|
|
7358
7430
|
buildRealRunOptions({
|
|
7359
7431
|
inputs: args.inputs,
|
|
@@ -7388,20 +7460,20 @@ async function readProjectMcpServers(cwd) {
|
|
|
7388
7460
|
|
|
7389
7461
|
// src/internal/local-agent/local-agent-invalidate.ts
|
|
7390
7462
|
async function applyDeferredInvalidation(agentId, pending, refresh) {
|
|
7391
|
-
|
|
7463
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] applying deferred cache invalidation (${agentId}): ${pending.reason}
|
|
7392
7464
|
`);
|
|
7393
7465
|
try {
|
|
7394
7466
|
await refresh();
|
|
7395
7467
|
} catch (err) {
|
|
7396
7468
|
const msg = err instanceof Error ? err.message : String(err);
|
|
7397
|
-
|
|
7469
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] invalidateCache reload failed (continuing): ${msg}
|
|
7398
7470
|
`);
|
|
7399
7471
|
}
|
|
7400
7472
|
}
|
|
7401
7473
|
async function invalidateCacheImpl(agentId, reason, options, disposed, dispose, setPending) {
|
|
7402
7474
|
if (disposed) return;
|
|
7403
7475
|
if (options.applyNow === true) {
|
|
7404
|
-
|
|
7476
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] invalidateCache applyNow disposing agent (${agentId}): ${reason}
|
|
7405
7477
|
`);
|
|
7406
7478
|
await dispose();
|
|
7407
7479
|
return;
|
|
@@ -7462,7 +7534,7 @@ var LiveAgentRegistry = class {
|
|
|
7462
7534
|
const existing = this.#agents.get(id);
|
|
7463
7535
|
if (existing !== void 0 && existing.agent !== agent) {
|
|
7464
7536
|
void existing.agent.dispose().catch(() => {
|
|
7465
|
-
|
|
7537
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] dispose during overwrite failed (${id})
|
|
7466
7538
|
`);
|
|
7467
7539
|
});
|
|
7468
7540
|
}
|
|
@@ -7566,7 +7638,7 @@ var LiveAgentRegistry = class {
|
|
|
7566
7638
|
await agent.dispose();
|
|
7567
7639
|
} catch (cause) {
|
|
7568
7640
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7569
|
-
|
|
7641
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] dispose during eviction failed (${id}): ${msg}
|
|
7570
7642
|
`);
|
|
7571
7643
|
}
|
|
7572
7644
|
if (this.#onEvict !== void 0) {
|
|
@@ -7574,7 +7646,7 @@ var LiveAgentRegistry = class {
|
|
|
7574
7646
|
this.#onEvict(id, reason);
|
|
7575
7647
|
} catch (cause) {
|
|
7576
7648
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7577
|
-
|
|
7649
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] onEvict listener threw (${id}): ${msg}
|
|
7578
7650
|
`);
|
|
7579
7651
|
}
|
|
7580
7652
|
}
|
|
@@ -7590,7 +7662,7 @@ async function acquireLeaseIfPossible(store, agentId) {
|
|
|
7590
7662
|
await a.call(store, agentId);
|
|
7591
7663
|
} catch (err) {
|
|
7592
7664
|
if (err instanceof Error && err.name === "SessionBusyError") throw err;
|
|
7593
|
-
|
|
7665
|
+
chunkNUKRL3I6_cjs.diag(
|
|
7594
7666
|
`[theokit-sdk] writer lease unavailable for ${agentId} (${err instanceof Error ? err.message : String(err)}) \u2014 proceeding without single-writer protection
|
|
7595
7667
|
`
|
|
7596
7668
|
);
|
|
@@ -7607,18 +7679,18 @@ async function disposeSessionStore(store) {
|
|
|
7607
7679
|
async function disposeLocalAgentSession(agent) {
|
|
7608
7680
|
liveAgentRegistry.forget(agent.agentId);
|
|
7609
7681
|
agent.lifecycleAbortController.abort();
|
|
7610
|
-
await
|
|
7682
|
+
await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
7611
7683
|
disposeSessionMcpClients(agent.agentId);
|
|
7612
|
-
await
|
|
7684
|
+
await chunk5BJV5UPY_cjs.flushSessionWrites();
|
|
7613
7685
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
7614
7686
|
await disposeSessionStore(agent.sessionStore);
|
|
7615
|
-
|
|
7687
|
+
chunk5BJV5UPY_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
7616
7688
|
}
|
|
7617
7689
|
async function reloadLocalAgent(agent) {
|
|
7618
7690
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
7619
7691
|
if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
|
|
7620
7692
|
if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
|
|
7621
|
-
return await
|
|
7693
|
+
return await chunkHJBMA5MB_cjs.loadSubagents(
|
|
7622
7694
|
agent.workspaceCwd,
|
|
7623
7695
|
agent.settingSourcesIncludeProject,
|
|
7624
7696
|
agent.options.agents
|
|
@@ -7626,12 +7698,12 @@ async function reloadLocalAgent(agent) {
|
|
|
7626
7698
|
}
|
|
7627
7699
|
async function persistActiveMemoryTranscript(cwd, transcript) {
|
|
7628
7700
|
try {
|
|
7629
|
-
const dir = path.join(
|
|
7701
|
+
const dir = path.join(chunk5UOVYM3P_cjs.memoryDir(cwd), "transcripts", "active-memory");
|
|
7630
7702
|
const file = path.join(dir, `${transcript.runId}.json`);
|
|
7631
|
-
await
|
|
7703
|
+
await chunkI6TGFUCO_cjs.atomicWriteJson(file, transcript);
|
|
7632
7704
|
} catch (cause) {
|
|
7633
7705
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7634
|
-
|
|
7706
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] active-memory transcript persist failed: ${message}
|
|
7635
7707
|
`);
|
|
7636
7708
|
}
|
|
7637
7709
|
}
|
|
@@ -7752,7 +7824,7 @@ async function searchOnce(args, cfg, query, started) {
|
|
|
7752
7824
|
return { summary, durationMs: Date.now() - started, status: "ok", hits };
|
|
7753
7825
|
} catch (cause) {
|
|
7754
7826
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7755
|
-
|
|
7827
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] active-memory recall failed: ${message}
|
|
7756
7828
|
`);
|
|
7757
7829
|
return { summary: void 0, durationMs: Date.now() - started, status: "error", hits: [] };
|
|
7758
7830
|
}
|
|
@@ -7872,7 +7944,7 @@ var azureOpenAiMemoryEmbeddingProviderAdapter = {
|
|
|
7872
7944
|
transport: "remote",
|
|
7873
7945
|
authProviderId: "azure-openai",
|
|
7874
7946
|
autoSelectPriority: 25,
|
|
7875
|
-
create: (options) =>
|
|
7947
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7876
7948
|
{
|
|
7877
7949
|
id: "azure-openai",
|
|
7878
7950
|
defaultBaseUrl: "https://your-resource.openai.azure.com",
|
|
@@ -7908,7 +7980,7 @@ var cohereMemoryEmbeddingProviderAdapter = {
|
|
|
7908
7980
|
transport: "remote",
|
|
7909
7981
|
authProviderId: "cohere",
|
|
7910
7982
|
autoSelectPriority: 30,
|
|
7911
|
-
create: (options) =>
|
|
7983
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7912
7984
|
{
|
|
7913
7985
|
id: "cohere",
|
|
7914
7986
|
defaultBaseUrl: "https://api.cohere.com",
|
|
@@ -7954,7 +8026,7 @@ var deepinfraMemoryEmbeddingProviderAdapter = {
|
|
|
7954
8026
|
transport: "remote",
|
|
7955
8027
|
authProviderId: "deepinfra",
|
|
7956
8028
|
autoSelectPriority: 13,
|
|
7957
|
-
create: (options) =>
|
|
8029
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7958
8030
|
{
|
|
7959
8031
|
id: "deepinfra",
|
|
7960
8032
|
defaultBaseUrl: "https://api.deepinfra.com",
|
|
@@ -7980,7 +8052,7 @@ var geminiMemoryEmbeddingProviderAdapter = {
|
|
|
7980
8052
|
transport: "remote",
|
|
7981
8053
|
authProviderId: "gemini",
|
|
7982
8054
|
autoSelectPriority: 30,
|
|
7983
|
-
create: (options) =>
|
|
8055
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7984
8056
|
{
|
|
7985
8057
|
id: "gemini",
|
|
7986
8058
|
defaultBaseUrl: "https://generativelanguage.googleapis.com",
|
|
@@ -8008,7 +8080,7 @@ var jinaMemoryEmbeddingProviderAdapter = {
|
|
|
8008
8080
|
transport: "remote",
|
|
8009
8081
|
authProviderId: "jina",
|
|
8010
8082
|
autoSelectPriority: 35,
|
|
8011
|
-
create: (options) =>
|
|
8083
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8012
8084
|
{
|
|
8013
8085
|
id: "jina",
|
|
8014
8086
|
defaultBaseUrl: "https://api.jina.ai",
|
|
@@ -8031,7 +8103,7 @@ var mistralMemoryEmbeddingProviderAdapter = {
|
|
|
8031
8103
|
transport: "remote",
|
|
8032
8104
|
authProviderId: "mistral",
|
|
8033
8105
|
autoSelectPriority: 18,
|
|
8034
|
-
create: (options) =>
|
|
8106
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8035
8107
|
{
|
|
8036
8108
|
id: "mistral",
|
|
8037
8109
|
defaultBaseUrl: "https://api.mistral.ai",
|
|
@@ -8073,7 +8145,7 @@ var ollamaMemoryEmbeddingProviderAdapter = {
|
|
|
8073
8145
|
autoSelectPriority: 10,
|
|
8074
8146
|
create: (options) => {
|
|
8075
8147
|
const apiKey = options.apiKey ?? process.env.OLLAMA_API_KEY ?? OLLAMA_LOCAL_SENTINEL_KEY;
|
|
8076
|
-
return
|
|
8148
|
+
return chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8077
8149
|
{
|
|
8078
8150
|
id: "ollama",
|
|
8079
8151
|
defaultBaseUrl: "http://localhost:11434",
|
|
@@ -8100,7 +8172,7 @@ var openAiMemoryEmbeddingProviderAdapter = {
|
|
|
8100
8172
|
transport: "remote",
|
|
8101
8173
|
authProviderId: "openai",
|
|
8102
8174
|
autoSelectPriority: 20,
|
|
8103
|
-
create: (options) =>
|
|
8175
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8104
8176
|
{
|
|
8105
8177
|
id: "openai",
|
|
8106
8178
|
defaultBaseUrl: "https://api.openai.com",
|
|
@@ -8127,7 +8199,7 @@ var openRouterMemoryEmbeddingProviderAdapter = {
|
|
|
8127
8199
|
transport: "remote",
|
|
8128
8200
|
authProviderId: "openrouter",
|
|
8129
8201
|
autoSelectPriority: 15,
|
|
8130
|
-
create: (options) =>
|
|
8202
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8131
8203
|
{
|
|
8132
8204
|
id: "openrouter",
|
|
8133
8205
|
defaultBaseUrl: "https://openrouter.ai/api",
|
|
@@ -8155,7 +8227,7 @@ var voyageMemoryEmbeddingProviderAdapter = {
|
|
|
8155
8227
|
transport: "remote",
|
|
8156
8228
|
authProviderId: "voyage",
|
|
8157
8229
|
autoSelectPriority: 14,
|
|
8158
|
-
create: (options) =>
|
|
8230
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8159
8231
|
{
|
|
8160
8232
|
id: "voyage",
|
|
8161
8233
|
defaultBaseUrl: "https://api.voyageai.com",
|
|
@@ -8256,7 +8328,7 @@ function createMemorySearchTool(opts) {
|
|
|
8256
8328
|
};
|
|
8257
8329
|
}
|
|
8258
8330
|
function createMemoryGetTool(opts) {
|
|
8259
|
-
const memoryRoot = path.resolve(
|
|
8331
|
+
const memoryRoot = path.resolve(chunk5UOVYM3P_cjs.memoryDir(opts.cwd));
|
|
8260
8332
|
return {
|
|
8261
8333
|
name: "memory_get",
|
|
8262
8334
|
description: GET_DESCRIPTION,
|
|
@@ -8267,7 +8339,7 @@ function createMemoryGetTool(opts) {
|
|
|
8267
8339
|
const lines = readNumber(input.lines);
|
|
8268
8340
|
const resolved = path.resolve(memoryRoot, relPath);
|
|
8269
8341
|
if (!isPathInside(memoryRoot, resolved)) {
|
|
8270
|
-
throw new
|
|
8342
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8271
8343
|
`memory_get rejected path that escapes memory root: ${relPath}`,
|
|
8272
8344
|
{ code: "memory_path_escapes_root" }
|
|
8273
8345
|
);
|
|
@@ -8287,7 +8359,7 @@ function readString(value, errorIfMissing, allowUndefined = false) {
|
|
|
8287
8359
|
if (typeof value === "string") return value;
|
|
8288
8360
|
if (allowUndefined && (value === void 0 || value === null)) return "";
|
|
8289
8361
|
if (errorIfMissing !== void 0) {
|
|
8290
|
-
throw new
|
|
8362
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(errorIfMissing, { code: "memory_tool_bad_args" });
|
|
8291
8363
|
}
|
|
8292
8364
|
return "";
|
|
8293
8365
|
}
|
|
@@ -8362,7 +8434,7 @@ var LocalAgentMemory = class {
|
|
|
8362
8434
|
const openOpts = { cwd: this.workspaceCwd };
|
|
8363
8435
|
if (embedding !== void 0) openOpts.embedding = embedding;
|
|
8364
8436
|
if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
|
|
8365
|
-
this.index = await
|
|
8437
|
+
this.index = await chunk5UOVYM3P_cjs.IndexManager.open(openOpts);
|
|
8366
8438
|
await this.index.sync();
|
|
8367
8439
|
this.toolsCache = [
|
|
8368
8440
|
createMemorySearchTool({ index: this.index }),
|
|
@@ -8377,7 +8449,7 @@ var LocalAgentMemory = class {
|
|
|
8377
8449
|
const warned2 = g[sym];
|
|
8378
8450
|
if (!warned2.has(message)) {
|
|
8379
8451
|
warned2.add(message);
|
|
8380
|
-
|
|
8452
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] memory tools unavailable: ${message}
|
|
8381
8453
|
`);
|
|
8382
8454
|
}
|
|
8383
8455
|
return void 0;
|
|
@@ -8386,7 +8458,7 @@ var LocalAgentMemory = class {
|
|
|
8386
8458
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8387
8459
|
const cfg = this.options.memory?.activeRecall;
|
|
8388
8460
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8389
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8461
|
+
if (this.breaker === void 0) this.breaker = new chunkUNDROG5N_cjs.CircuitBreaker();
|
|
8390
8462
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8391
8463
|
const result = await runActiveMemory({
|
|
8392
8464
|
userText,
|
|
@@ -8436,7 +8508,7 @@ var LocalAgentMemory = class {
|
|
|
8436
8508
|
await this.index.sync();
|
|
8437
8509
|
} catch (cause) {
|
|
8438
8510
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8439
|
-
|
|
8511
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] session index sync failed: ${message}
|
|
8440
8512
|
`);
|
|
8441
8513
|
}
|
|
8442
8514
|
}
|
|
@@ -8449,7 +8521,7 @@ var LocalAgentMemory = class {
|
|
|
8449
8521
|
return await adapter.create(cfg.model !== void 0 ? { model: cfg.model } : {});
|
|
8450
8522
|
} catch (cause) {
|
|
8451
8523
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8452
|
-
|
|
8524
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] memory embedding ${cfg.provider} unavailable: ${message}
|
|
8453
8525
|
`);
|
|
8454
8526
|
return void 0;
|
|
8455
8527
|
}
|
|
@@ -8457,22 +8529,33 @@ var LocalAgentMemory = class {
|
|
|
8457
8529
|
};
|
|
8458
8530
|
|
|
8459
8531
|
// src/internal/local-agent/local-agent-memory-direct.ts
|
|
8532
|
+
async function createAvailableAdapters(entries, workspaceCwd) {
|
|
8533
|
+
const available = [];
|
|
8534
|
+
for (const entry of entries) {
|
|
8535
|
+
const instance = await entry.createProvider(workspaceCwd);
|
|
8536
|
+
if (instance.isAvailable() === false) {
|
|
8537
|
+
chunkNUKRL3I6_cjs.diag(
|
|
8538
|
+
`[theokit-sdk] memory adapter "${instance.id}" reports itself unavailable (plugin "${entry.pluginName}") \u2014 skipping it. Check its credentials.
|
|
8539
|
+
`
|
|
8540
|
+
);
|
|
8541
|
+
continue;
|
|
8542
|
+
}
|
|
8543
|
+
available.push(instance);
|
|
8544
|
+
}
|
|
8545
|
+
return available;
|
|
8546
|
+
}
|
|
8460
8547
|
function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
8461
8548
|
let resolved;
|
|
8462
8549
|
async function ensure() {
|
|
8463
8550
|
if (resolved !== void 0) return resolved;
|
|
8464
8551
|
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
|
-
}
|
|
8552
|
+
const created = await createAvailableAdapters(entries, workspaceCwd);
|
|
8470
8553
|
for (const adapter of created) {
|
|
8471
8554
|
if (adapter.initialize !== void 0) {
|
|
8472
8555
|
await adapter.initialize();
|
|
8473
8556
|
}
|
|
8474
8557
|
}
|
|
8475
|
-
resolved = { adapters: created, initialized: true };
|
|
8558
|
+
resolved = { adapters: created, initialized: true, registered: entries.length };
|
|
8476
8559
|
return resolved;
|
|
8477
8560
|
}
|
|
8478
8561
|
function mergeContext(partial) {
|
|
@@ -8485,7 +8568,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8485
8568
|
...partial?.metadata !== void 0 ? { metadata: partial.metadata } : defaultContext?.metadata !== void 0 ? { metadata: defaultContext.metadata } : {}
|
|
8486
8569
|
};
|
|
8487
8570
|
if (merged.userId === "") {
|
|
8488
|
-
throw new
|
|
8571
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8489
8572
|
"agent.memory requires a userId \u2014 either set AgentOptions.memoryContext.userId or pass ctx.userId at call time.",
|
|
8490
8573
|
{ code: "memory_context_missing_user_id" }
|
|
8491
8574
|
);
|
|
@@ -8495,8 +8578,8 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8495
8578
|
async function requireAdapters() {
|
|
8496
8579
|
const r = await ensure();
|
|
8497
8580
|
if (r.adapters.length === 0) {
|
|
8498
|
-
throw new
|
|
8499
|
-
"No memory adapter registered. Pass a memory plugin in AgentOptions.plugins (e.g. supermemoryMemory({...}))."
|
|
8581
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8582
|
+
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
8583
|
{ code: "no_memory_adapter" }
|
|
8501
8584
|
);
|
|
8502
8585
|
}
|
|
@@ -8536,7 +8619,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8536
8619
|
const prefix = id.split(":", 1)[0] ?? "";
|
|
8537
8620
|
const target = adapters.find((a) => a.id === prefix);
|
|
8538
8621
|
if (target === void 0) {
|
|
8539
|
-
throw new
|
|
8622
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8540
8623
|
`No adapter found for MemoryId prefix "${prefix}" (registered: ${adapters.map((a) => a.id).join(", ")}).`,
|
|
8541
8624
|
{ code: "no_memory_adapter" }
|
|
8542
8625
|
);
|
|
@@ -8609,7 +8692,7 @@ function createLocalAgentMemoryProvider(opts) {
|
|
|
8609
8692
|
return { facts: [], systemPromptAdditions: summary };
|
|
8610
8693
|
},
|
|
8611
8694
|
async recordSessionSummary(args) {
|
|
8612
|
-
await
|
|
8695
|
+
await chunk5UOVYM3P_cjs.writeSessionSummary(args);
|
|
8613
8696
|
},
|
|
8614
8697
|
async sync(handle) {
|
|
8615
8698
|
const state = handle[INTERNAL_LAM_KEY];
|
|
@@ -8687,19 +8770,19 @@ var PersonalityRegistry = class _PersonalityRegistry {
|
|
|
8687
8770
|
function addEntity(byName, entity, origin, collisionMap) {
|
|
8688
8771
|
const fm = entity.frontmatter;
|
|
8689
8772
|
if (PersonalityRegistry.isReservedClearSlug(fm.name)) {
|
|
8690
|
-
throw new
|
|
8773
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8691
8774
|
`Personality name "${fm.name}" is reserved (used to clear active preset)`,
|
|
8692
8775
|
{ code: "personality_reserved_name" }
|
|
8693
8776
|
);
|
|
8694
8777
|
}
|
|
8695
8778
|
if (entity.body.trim().length === 0) {
|
|
8696
|
-
throw new
|
|
8779
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8697
8780
|
`Personality "${fm.name}" has empty body (system prompt required)`,
|
|
8698
8781
|
{ code: "personality_empty_body" }
|
|
8699
8782
|
);
|
|
8700
8783
|
}
|
|
8701
8784
|
if (origin === "project" && collisionMap?.has(fm.name)) {
|
|
8702
|
-
|
|
8785
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
8703
8786
|
`personality-collision-${fm.name}`,
|
|
8704
8787
|
`[theokit-sdk] personality "${fm.name}" overridden by project preset`
|
|
8705
8788
|
);
|
|
@@ -8728,7 +8811,7 @@ async function performPersonalitySwitch(args) {
|
|
|
8728
8811
|
const preset = args.registry.get(args.requestedName);
|
|
8729
8812
|
if (preset === void 0) {
|
|
8730
8813
|
const available = args.registry.all().map((p) => p.name).join(", ") || "(none)";
|
|
8731
|
-
throw new
|
|
8814
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8732
8815
|
`Personality "${args.requestedName}" not found. Available: ${available}`,
|
|
8733
8816
|
{ code: "personality_not_found" }
|
|
8734
8817
|
);
|
|
@@ -8749,14 +8832,14 @@ async function performPersonalitySwitch(args) {
|
|
|
8749
8832
|
|
|
8750
8833
|
// src/internal/local-agent/local-agent-personality-extensions.ts
|
|
8751
8834
|
function resolveActivePersonalityPreset(args) {
|
|
8752
|
-
const forkCtx =
|
|
8835
|
+
const forkCtx = chunk53CBTBWO_cjs.currentPersonalityContext();
|
|
8753
8836
|
const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
|
|
8754
8837
|
if (slug === void 0) return void 0;
|
|
8755
8838
|
return args.personalityRegistry?.get(slug);
|
|
8756
8839
|
}
|
|
8757
8840
|
async function ensurePersonalityRegistryIfNeeded(args) {
|
|
8758
8841
|
if (args.personalityRegistry !== void 0) return args.personalityRegistry;
|
|
8759
|
-
const forkSlug =
|
|
8842
|
+
const forkSlug = chunk53CBTBWO_cjs.currentPersonalityContext()?.slug;
|
|
8760
8843
|
const ownSlug = args.personalityStore.active(args.agentId);
|
|
8761
8844
|
if (forkSlug === void 0 && ownSlug === void 0) return void 0;
|
|
8762
8845
|
return await PersonalityRegistry.load(args.workspaceCwd);
|
|
@@ -8770,8 +8853,8 @@ ${preset.systemPrompt}`;
|
|
|
8770
8853
|
}
|
|
8771
8854
|
async function localAgentUsePersonality(args) {
|
|
8772
8855
|
if (args.disposed) throw new Error("Agent has been disposed");
|
|
8773
|
-
if (
|
|
8774
|
-
|
|
8856
|
+
if (chunk53CBTBWO_cjs.currentPersonalityContext() !== void 0) {
|
|
8857
|
+
chunk53CBTBWO_cjs.warnPersonalitySwitchInsideFork(args.agentId);
|
|
8775
8858
|
return null;
|
|
8776
8859
|
}
|
|
8777
8860
|
let registry = args.personalityRegistry;
|
|
@@ -8779,7 +8862,7 @@ async function localAgentUsePersonality(args) {
|
|
|
8779
8862
|
registry = await PersonalityRegistry.load(args.workspaceCwd);
|
|
8780
8863
|
args.onRegistryLoaded(registry);
|
|
8781
8864
|
}
|
|
8782
|
-
return
|
|
8865
|
+
return chunkZF2LDKQQ_cjs.withCwdMutex(
|
|
8783
8866
|
`agent-send:${args.agentId}`,
|
|
8784
8867
|
() => performPersonalitySwitch({
|
|
8785
8868
|
agentId: args.agentId,
|
|
@@ -8788,8 +8871,8 @@ async function localAgentUsePersonality(args) {
|
|
|
8788
8871
|
registry,
|
|
8789
8872
|
store: args.personalityStore,
|
|
8790
8873
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
8791
|
-
appendSessionMessage: (msg) =>
|
|
8792
|
-
clearSession: () =>
|
|
8874
|
+
appendSessionMessage: (msg) => chunk5BJV5UPY_cjs.appendSessionMessage(args.agentId, msg),
|
|
8875
|
+
clearSession: () => chunk5BJV5UPY_cjs.clearSession(args.agentId),
|
|
8793
8876
|
opts: args.opts ?? {}
|
|
8794
8877
|
})
|
|
8795
8878
|
);
|
|
@@ -8800,7 +8883,7 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
8800
8883
|
async function* wrap() {
|
|
8801
8884
|
const { runUntilImpl } = await import('./run-until-U2B5FJJI.cjs');
|
|
8802
8885
|
const buildDeps = async () => {
|
|
8803
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
8886
|
+
const { judgeCallImpl } = await import('./judge-call-EGYRC2RE.cjs');
|
|
8804
8887
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
8805
8888
|
const create = getAgentFacade().create;
|
|
8806
8889
|
return {
|
|
@@ -8821,19 +8904,19 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
8821
8904
|
}
|
|
8822
8905
|
function localAgentRunToCompletion(agent, message, options) {
|
|
8823
8906
|
async function run() {
|
|
8824
|
-
const { runToCompletionImpl } = await import('./run-to-completion-
|
|
8907
|
+
const { runToCompletionImpl } = await import('./run-to-completion-X4OWM673.cjs');
|
|
8825
8908
|
return runToCompletionImpl({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
8826
8909
|
}
|
|
8827
8910
|
return run();
|
|
8828
8911
|
}
|
|
8829
8912
|
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
8830
|
-
const { streamToCompletionImpl } = await import('./stream-to-completion-
|
|
8913
|
+
const { streamToCompletionImpl } = await import('./stream-to-completion-SRISU5AB.cjs');
|
|
8831
8914
|
return yield* streamToCompletionImpl({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
8832
8915
|
}
|
|
8833
8916
|
async function localAgentFork(parent, options) {
|
|
8834
8917
|
const { forkAgentImpl } = await import('./fork-agent-Y2IK2RYU.cjs');
|
|
8835
8918
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
8836
|
-
const { withPersonalityContext } = await import('./context-
|
|
8919
|
+
const { withPersonalityContext } = await import('./context-VMIE4BMD.cjs');
|
|
8837
8920
|
const create = getAgentFacade().create;
|
|
8838
8921
|
return withPersonalityContext(
|
|
8839
8922
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
@@ -8893,7 +8976,7 @@ function wrapRunWithCompletionCheck(args) {
|
|
|
8893
8976
|
judgeOpts
|
|
8894
8977
|
);
|
|
8895
8978
|
const complete = !verdict.parseFailed && verdict.verdict === "done";
|
|
8896
|
-
|
|
8979
|
+
chunkNGESVVJN_cjs.emitRunEvent(args.onRunEvent, {
|
|
8897
8980
|
type: "completion_check",
|
|
8898
8981
|
complete,
|
|
8899
8982
|
reason: verdict.reason
|
|
@@ -9040,7 +9123,7 @@ function wrapRunWithOutputProcessors(args) {
|
|
|
9040
9123
|
if (result.status !== "finished" || result.result === void 0) return result;
|
|
9041
9124
|
const res = await runOutputProcessors(args.processors, result.result, args.agentId);
|
|
9042
9125
|
if (res.kind === "ok") return { ...result, result: res.value };
|
|
9043
|
-
|
|
9126
|
+
chunkNGESVVJN_cjs.emitRunEvent(args.onRunEvent, {
|
|
9044
9127
|
type: "tripwire",
|
|
9045
9128
|
reason: res.tripwire.reason,
|
|
9046
9129
|
processorId: res.tripwire.processorId
|
|
@@ -9083,6 +9166,15 @@ ${recalled}
|
|
|
9083
9166
|
${args.userText}`;
|
|
9084
9167
|
return typeof args.original === "string" ? wrapped : { ...args.original, text: wrapped };
|
|
9085
9168
|
}
|
|
9169
|
+
async function runCalledATool(run) {
|
|
9170
|
+
try {
|
|
9171
|
+
for await (const event of run.stream()) {
|
|
9172
|
+
if (event.type === "tool_call") return true;
|
|
9173
|
+
}
|
|
9174
|
+
} catch {
|
|
9175
|
+
}
|
|
9176
|
+
return false;
|
|
9177
|
+
}
|
|
9086
9178
|
function wrapRunWithPostReplyHook(args) {
|
|
9087
9179
|
const handlers = args.pluginManager.hooksFor("post_assistant_reply");
|
|
9088
9180
|
if (handlers.length === 0) return args.run;
|
|
@@ -9094,6 +9186,12 @@ function wrapRunWithPostReplyHook(args) {
|
|
|
9094
9186
|
reply: replyText,
|
|
9095
9187
|
agentId: args.agentId,
|
|
9096
9188
|
runId: result.id,
|
|
9189
|
+
// #358 — whether this reply is safely replayable. A consumer (the semantic cache) must not
|
|
9190
|
+
// re-serve an answer produced by a tool call, and had nothing to key on. The run knows:
|
|
9191
|
+
// `stream()` replays its buffered events after `wait()` (ADR 0006), so a `tool_call` among
|
|
9192
|
+
// them is the signal. Computed here, inside a path that only runs when a hook is registered
|
|
9193
|
+
// and is already fire-and-forget, so it never lands on the caller's critical path.
|
|
9194
|
+
usedTools: await runCalledATool(args.run),
|
|
9097
9195
|
...args.options.memoryContext !== void 0 ? { memoryContext: args.options.memoryContext } : {}
|
|
9098
9196
|
};
|
|
9099
9197
|
void args.pluginManager.runPostAssistantReplyHooks(ctx);
|
|
@@ -9115,7 +9213,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9115
9213
|
}
|
|
9116
9214
|
const res = await runInputProcessors(processors, rawUserText, inputs.agentId);
|
|
9117
9215
|
if (res.kind === "tripwire") {
|
|
9118
|
-
|
|
9216
|
+
chunkNGESVVJN_cjs.emitRunEvent(options.onRunEvent, {
|
|
9119
9217
|
type: "tripwire",
|
|
9120
9218
|
reason: res.tripwire.reason,
|
|
9121
9219
|
processorId: res.tripwire.processorId
|
|
@@ -9132,7 +9230,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9132
9230
|
return { userText: res.value, effectiveMessage };
|
|
9133
9231
|
}
|
|
9134
9232
|
async function executeSendLocked(inputs, message, options) {
|
|
9135
|
-
if (inputs.disposed) throw new
|
|
9233
|
+
if (inputs.disposed) throw new chunkK3FW2XZD_cjs.AgentDisposedError(inputs.agentId);
|
|
9136
9234
|
await consumePending(inputs.agentId, inputs.invalidationPending, inputs.clearInvalidation, inputs.reload);
|
|
9137
9235
|
const sendModel = normalizeModel(options.model);
|
|
9138
9236
|
inputs.applyModelOverride(sendModel);
|
|
@@ -9143,7 +9241,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9143
9241
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9144
9242
|
await inputs.options.onBeforeSend({
|
|
9145
9243
|
conversationId: inputs.agentId,
|
|
9146
|
-
previousMessageCount:
|
|
9244
|
+
previousMessageCount: chunk5BJV5UPY_cjs.getSessionMessages(inputs.agentId).length
|
|
9147
9245
|
});
|
|
9148
9246
|
}
|
|
9149
9247
|
await inputs.runPreHook(userText);
|
|
@@ -9155,8 +9253,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9155
9253
|
userText,
|
|
9156
9254
|
sendOptions: options
|
|
9157
9255
|
});
|
|
9158
|
-
const priorMessages = [...
|
|
9159
|
-
|
|
9256
|
+
const priorMessages = [...chunk5BJV5UPY_cjs.getSessionMessages(inputs.agentId)];
|
|
9257
|
+
chunk5BJV5UPY_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9160
9258
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9161
9259
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
|
|
9162
9260
|
const portPathActive = shouldUsePortMemoryPath();
|
|
@@ -9214,7 +9312,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9214
9312
|
function buildCompletionCheckDeps() {
|
|
9215
9313
|
return {
|
|
9216
9314
|
judge: async (ctx, opts) => {
|
|
9217
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9315
|
+
const { judgeCallImpl } = await import('./judge-call-EGYRC2RE.cjs');
|
|
9218
9316
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9219
9317
|
return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
|
|
9220
9318
|
}
|
|
@@ -9234,7 +9332,7 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
|
|
|
9234
9332
|
promptPreview: userText.slice(0, 120),
|
|
9235
9333
|
...opts.meta ?? {}
|
|
9236
9334
|
};
|
|
9237
|
-
void
|
|
9335
|
+
void chunkNGESVVJN_cjs.submit({
|
|
9238
9336
|
kind: "run",
|
|
9239
9337
|
work: async (ctx) => {
|
|
9240
9338
|
ctx.signal.addEventListener(
|
|
@@ -9319,7 +9417,7 @@ var LocalAgent = class {
|
|
|
9319
9417
|
this.options = options;
|
|
9320
9418
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
9321
9419
|
this.transcriptBaseDir = resolveSessionDir(options.local);
|
|
9322
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
9420
|
+
this.sessionStore = options.local?.sessionStore ?? new chunkYPJ5NH5N_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
9323
9421
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
9324
9422
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
9325
9423
|
const sub = bootstrapSubmanagers({
|
|
@@ -9362,14 +9460,14 @@ var LocalAgent = class {
|
|
|
9362
9460
|
if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
|
|
9363
9461
|
const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
|
|
9364
9462
|
await this.pluginManagerCode.initialize(codePlugins);
|
|
9365
|
-
this.resolvedSubagents = await
|
|
9463
|
+
this.resolvedSubagents = await chunkHJBMA5MB_cjs.loadSubagents(
|
|
9366
9464
|
this.workspaceCwd,
|
|
9367
9465
|
this.settingSourcesIncludeProject,
|
|
9368
9466
|
this.options.agents
|
|
9369
9467
|
);
|
|
9370
9468
|
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9371
9469
|
try {
|
|
9372
|
-
await
|
|
9470
|
+
await chunk5BJV5UPY_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9373
9471
|
await this.personalityStore.hydrate(this.agentId);
|
|
9374
9472
|
} catch (err) {
|
|
9375
9473
|
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
@@ -9398,7 +9496,7 @@ var LocalAgent = class {
|
|
|
9398
9496
|
...this.model?.id !== void 0 ? { model: this.model.id } : {}
|
|
9399
9497
|
});
|
|
9400
9498
|
return new Promise((resolve, reject) => {
|
|
9401
|
-
void
|
|
9499
|
+
void chunkZF2LDKQQ_cjs.withCwdMutex(
|
|
9402
9500
|
`agent-send:${this.agentId}`,
|
|
9403
9501
|
() => this.runLockedSendCycle(message, options, sendSpan, resolve, reject)
|
|
9404
9502
|
);
|
|
@@ -9518,7 +9616,7 @@ var LocalAgent = class {
|
|
|
9518
9616
|
agentId: this.agentId
|
|
9519
9617
|
});
|
|
9520
9618
|
if (preRun.blocked) {
|
|
9521
|
-
throw new
|
|
9619
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
9522
9620
|
`preRun hook denied execution: ${preRun.reason ?? "unspecified"}`,
|
|
9523
9621
|
{ code: "hook_denied" }
|
|
9524
9622
|
);
|
|
@@ -9599,7 +9697,7 @@ var LocalAgent = class {
|
|
|
9599
9697
|
}
|
|
9600
9698
|
// biome-ignore format: G8 budget — see listArtifacts.
|
|
9601
9699
|
downloadArtifact(_path) {
|
|
9602
|
-
return Promise.reject(new
|
|
9700
|
+
return Promise.reject(new chunkK3FW2XZD_cjs.UnsupportedRunOperationError("Artifacts are not supported for local agents", "downloadArtifact"));
|
|
9603
9701
|
}
|
|
9604
9702
|
// biome-ignore format: G8 budget — delegates to `local-agent-runtime-extensions.ts`; kept 1-line.
|
|
9605
9703
|
runUntil(goal, options) {
|
|
@@ -9644,7 +9742,7 @@ async function guardAgainstIdCollision(options) {
|
|
|
9644
9742
|
const persistenceCwd = resolveAgentPersistenceCwd(options);
|
|
9645
9743
|
await hydrateRegistryFromDisk(persistenceCwd);
|
|
9646
9744
|
if (getRegisteredAgent(options.agentId) !== void 0) {
|
|
9647
|
-
throw new
|
|
9745
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
9648
9746
|
`Agent "${options.agentId}" already exists. Use Agent.resume("${options.agentId}") to reattach, or pick a different agentId.`,
|
|
9649
9747
|
{ code: "agent_id_already_exists" }
|
|
9650
9748
|
);
|
|
@@ -9677,7 +9775,7 @@ async function maybeInjectHandoffTools(options) {
|
|
|
9677
9775
|
const spec = "@theokit/sdk-handoff/internal/tool-injector";
|
|
9678
9776
|
mod = await import(spec);
|
|
9679
9777
|
} catch (err) {
|
|
9680
|
-
throw new
|
|
9778
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
9681
9779
|
"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
9780
|
{ code: "handoff_package_missing", cause: err }
|
|
9683
9781
|
);
|
|
@@ -9694,47 +9792,57 @@ async function maybeInjectHandoffTools(options) {
|
|
|
9694
9792
|
tools: [...existingTools, ...handoffTools]
|
|
9695
9793
|
};
|
|
9696
9794
|
}
|
|
9795
|
+
function keyWillFlowToProvider(apiKey, provider) {
|
|
9796
|
+
if (chunkUNDROG5N_cjs.isFixtureApiKey(apiKey)) return false;
|
|
9797
|
+
if (chunkUNDROG5N_cjs.getConfiguredBaseUrl() !== void 0) return false;
|
|
9798
|
+
if (provider === void 0) return false;
|
|
9799
|
+
const profile = chunk3KGLRRFC_cjs.getProviderProfile(provider);
|
|
9800
|
+
if (profile === void 0) return false;
|
|
9801
|
+
return profile.authType !== "none";
|
|
9802
|
+
}
|
|
9803
|
+
function missingApiKeyMessage() {
|
|
9804
|
+
const present = chunkUNDROG5N_cjs.presentProviderCredentialEnvVars();
|
|
9805
|
+
const base = `Missing API key \u2014 set ${chunkJTB5Q42C_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
|
|
9806
|
+
if (present.length === 0) return `${base}.`;
|
|
9807
|
+
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]}, ... })\`.`;
|
|
9808
|
+
}
|
|
9697
9809
|
async function createLocalAgent(options) {
|
|
9698
|
-
const apiKey =
|
|
9810
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.apiKey);
|
|
9699
9811
|
if (apiKey === void 0) {
|
|
9700
|
-
throw new
|
|
9812
|
+
throw new chunkK3FW2XZD_cjs.AuthenticationError(missingApiKeyMessage(), { code: "missing_api_key" });
|
|
9701
9813
|
}
|
|
9702
|
-
const
|
|
9814
|
+
const provider = providerFromModelId(normalizeModel(options.model)?.id);
|
|
9815
|
+
const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
|
|
9703
9816
|
const shape = validateApiKeyShape(apiKey, {
|
|
9704
9817
|
strict: willFlowToProvider,
|
|
9705
9818
|
// `options.model` is already normalized by `runCreateUnderSpan`; `normalizeModel`
|
|
9706
9819
|
// here is the idempotent narrowing of the widened public type (`{id}` passes
|
|
9707
9820
|
// through by reference) — cleaner than an `as` cast.
|
|
9708
|
-
...willFlowToProvider ? { provider
|
|
9821
|
+
...willFlowToProvider ? { provider } : {}
|
|
9709
9822
|
});
|
|
9710
9823
|
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
|
-
});
|
|
9824
|
+
throw new chunkK3FW2XZD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
9717
9825
|
}
|
|
9718
9826
|
const agent = new LocalAgent(options);
|
|
9719
9827
|
await agent.initialize();
|
|
9720
9828
|
return agent;
|
|
9721
9829
|
}
|
|
9722
9830
|
async function createCloudAgent(options) {
|
|
9723
|
-
const apiKey =
|
|
9831
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.apiKey);
|
|
9724
9832
|
if (apiKey === void 0) {
|
|
9725
|
-
throw new
|
|
9833
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError("Missing API key for cloud agent", {
|
|
9726
9834
|
code: "missing_api_key"
|
|
9727
9835
|
});
|
|
9728
9836
|
}
|
|
9729
9837
|
const shape = validateApiKeyShape(apiKey);
|
|
9730
9838
|
if (shape.malformed) {
|
|
9731
|
-
throw new
|
|
9839
|
+
throw new chunkK3FW2XZD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
9732
9840
|
}
|
|
9733
|
-
const baseUrl =
|
|
9841
|
+
const baseUrl = chunkUNDROG5N_cjs.getConfiguredBaseUrl();
|
|
9734
9842
|
if (baseUrl === void 0) {
|
|
9735
9843
|
return new CloudAgent(options);
|
|
9736
9844
|
}
|
|
9737
|
-
const response = await
|
|
9845
|
+
const response = await chunkUNDROG5N_cjs.httpRequest("/v1/agents", {
|
|
9738
9846
|
apiKey,
|
|
9739
9847
|
method: "POST",
|
|
9740
9848
|
body: {
|
|
@@ -9759,7 +9867,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
9759
9867
|
return process.cwd();
|
|
9760
9868
|
}
|
|
9761
9869
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
9762
|
-
await
|
|
9870
|
+
await chunkUNDROG5N_cjs.discoverProviderPlugins();
|
|
9763
9871
|
await validateRehydratedAgent(agentId, existing);
|
|
9764
9872
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
9765
9873
|
const mergedOptions = {
|
|
@@ -9790,7 +9898,7 @@ async function validateRehydratedAgent(agentId, entry) {
|
|
|
9790
9898
|
throw new Error(`Workspace path is not a directory: ${candidate}`);
|
|
9791
9899
|
}
|
|
9792
9900
|
} catch (cause) {
|
|
9793
|
-
throw new
|
|
9901
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
9794
9902
|
`Agent "${agentId}" cannot be rehydrated \u2014 workspace cwd "${candidate}" is missing or inaccessible.`,
|
|
9795
9903
|
{ code: "agent_rehydration_failed", cause }
|
|
9796
9904
|
);
|
|
@@ -9835,17 +9943,33 @@ async function setAgentName(agentId, name) {
|
|
|
9835
9943
|
updateRegisteredAgent(agentId, { name });
|
|
9836
9944
|
await flushRegistrySaves();
|
|
9837
9945
|
}
|
|
9838
|
-
async function getRegisteredAgentOrThrow(agentId) {
|
|
9946
|
+
async function getRegisteredAgentOrThrow(agentId, cwd = process.cwd()) {
|
|
9839
9947
|
let agent = getRegisteredAgent(agentId);
|
|
9840
9948
|
if (agent === void 0) {
|
|
9841
|
-
await hydrateRegistryFromDisk(
|
|
9949
|
+
await hydrateRegistryFromDisk(cwd);
|
|
9842
9950
|
agent = getRegisteredAgent(agentId);
|
|
9843
9951
|
}
|
|
9844
9952
|
if (agent === void 0) {
|
|
9845
|
-
throw new
|
|
9953
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(`Agent ${agentId} not found`, { code: "unknown_agent" });
|
|
9846
9954
|
}
|
|
9847
9955
|
return agent;
|
|
9848
9956
|
}
|
|
9957
|
+
function paginateByKey(all, keyOf, limit, cursor, sortByKey) {
|
|
9958
|
+
if (limit === void 0) return { items: [...all] };
|
|
9959
|
+
const ordered = sortByKey ? [...all].sort((a, b) => {
|
|
9960
|
+
const ka = keyOf(a);
|
|
9961
|
+
const kb = keyOf(b);
|
|
9962
|
+
return ka < kb ? -1 : ka > kb ? 1 : 0;
|
|
9963
|
+
}) : [...all];
|
|
9964
|
+
const startIndex = cursor === void 0 ? 0 : ordered.findIndex((item) => keyOf(item) === cursor) + 1;
|
|
9965
|
+
const page = ordered.slice(startIndex, startIndex + limit);
|
|
9966
|
+
const hasMore = startIndex + limit < ordered.length;
|
|
9967
|
+
const last = page[page.length - 1];
|
|
9968
|
+
return {
|
|
9969
|
+
items: page,
|
|
9970
|
+
...hasMore && last !== void 0 ? { nextCursor: keyOf(last) } : {}
|
|
9971
|
+
};
|
|
9972
|
+
}
|
|
9849
9973
|
|
|
9850
9974
|
// src/agent.ts
|
|
9851
9975
|
var streamObjectImport;
|
|
@@ -9887,7 +10011,7 @@ var Agent = class _Agent {
|
|
|
9887
10011
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
9888
10012
|
});
|
|
9889
10013
|
try {
|
|
9890
|
-
await
|
|
10014
|
+
await chunkUNDROG5N_cjs.discoverProviderPlugins();
|
|
9891
10015
|
const agent = await runCreateUnderSpan(options, span);
|
|
9892
10016
|
return agent;
|
|
9893
10017
|
} catch (err) {
|
|
@@ -9928,8 +10052,8 @@ var Agent = class _Agent {
|
|
|
9928
10052
|
const run = await agent.send(message);
|
|
9929
10053
|
const result = await run.wait();
|
|
9930
10054
|
if (options.throwOnError === true && result.status === "error" && result.error !== void 0) {
|
|
9931
|
-
throw new
|
|
9932
|
-
code:
|
|
10055
|
+
throw new chunkK3FW2XZD_cjs.AgentRunError(result.error.message, {
|
|
10056
|
+
code: chunkK3FW2XZD_cjs.coerceToKnownAgentRunErrorCode(result.error.code),
|
|
9933
10057
|
cause: result.error.cause
|
|
9934
10058
|
});
|
|
9935
10059
|
}
|
|
@@ -9956,7 +10080,7 @@ var Agent = class _Agent {
|
|
|
9956
10080
|
if (existing !== void 0) {
|
|
9957
10081
|
return await rehydrateExistingAgent(agentId, existing, options);
|
|
9958
10082
|
}
|
|
9959
|
-
throw new
|
|
10083
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
9960
10084
|
`Agent "${agentId}" not found. Use Agent.create({ agentId, ... }) for first-time setup, or catch UnknownAgentError to branch resume-vs-create.`,
|
|
9961
10085
|
{ code: "unknown_agent" }
|
|
9962
10086
|
);
|
|
@@ -9985,7 +10109,7 @@ var Agent = class _Agent {
|
|
|
9985
10109
|
* @public
|
|
9986
10110
|
*/
|
|
9987
10111
|
static async generateObject(options) {
|
|
9988
|
-
const { generateObjectImpl } = await import('./generate-object-
|
|
10112
|
+
const { generateObjectImpl } = await import('./generate-object-PGSP5U7N.cjs');
|
|
9989
10113
|
return generateObjectImpl(options, {
|
|
9990
10114
|
create: (opts) => _Agent.create(opts),
|
|
9991
10115
|
delete: (agentId) => _Agent.delete(agentId)
|
|
@@ -10009,7 +10133,7 @@ var Agent = class _Agent {
|
|
|
10009
10133
|
delete: (agentId) => _Agent.delete(agentId)
|
|
10010
10134
|
};
|
|
10011
10135
|
async function* wrapper() {
|
|
10012
|
-
streamObjectImport ??= import('./stream-object-
|
|
10136
|
+
streamObjectImport ??= import('./stream-object-BUCF5PHO.cjs');
|
|
10013
10137
|
const { streamObjectImpl } = await streamObjectImport;
|
|
10014
10138
|
yield* streamObjectImpl(options, deps);
|
|
10015
10139
|
}
|
|
@@ -10033,7 +10157,7 @@ var Agent = class _Agent {
|
|
|
10033
10157
|
* @public
|
|
10034
10158
|
*/
|
|
10035
10159
|
static async batch(prompts, options) {
|
|
10036
|
-
const { batchImpl } = await import('./batch-
|
|
10160
|
+
const { batchImpl } = await import('./batch-ND32UKZS.cjs');
|
|
10037
10161
|
return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
|
|
10038
10162
|
}
|
|
10039
10163
|
/**
|
|
@@ -10077,34 +10201,57 @@ var Agent = class _Agent {
|
|
|
10077
10201
|
return fresh;
|
|
10078
10202
|
}
|
|
10079
10203
|
/**
|
|
10080
|
-
* List agents (local or cloud). M107 — `cwd` is READ
|
|
10081
|
-
* `limit`/`cursor`
|
|
10204
|
+
* List agents (local or cloud). M107 — `cwd` is READ, not ignored. B-115 (2026-08-19) —
|
|
10205
|
+
* `includeArchived` and `limit`/`cursor` are READ too now; see `ListAgentsOptions`'s doc for the
|
|
10206
|
+
* pagination contract and why the unlimited (no `limit`) case is unaffected.
|
|
10082
10207
|
*
|
|
10083
10208
|
* @public
|
|
10084
10209
|
*/
|
|
10085
10210
|
static async list(options = {}) {
|
|
10086
10211
|
const cwd = ("cwd" in options ? options.cwd : void 0) ?? process.cwd();
|
|
10087
10212
|
await hydrateRegistryFromDisk(cwd);
|
|
10088
|
-
const
|
|
10089
|
-
|
|
10213
|
+
const includeArchived = "includeArchived" in options ? options.includeArchived ?? false : false;
|
|
10214
|
+
const agents2 = listRegisteredAgents(options.runtime, cwd, includeArchived);
|
|
10215
|
+
const { items, nextCursor } = paginateByKey(
|
|
10216
|
+
agents2,
|
|
10217
|
+
(agent) => agent.agentId,
|
|
10218
|
+
options.limit,
|
|
10219
|
+
options.cursor,
|
|
10220
|
+
/* sortByKey */
|
|
10221
|
+
true
|
|
10222
|
+
);
|
|
10223
|
+
return {
|
|
10224
|
+
items: items.map((agent) => toAgentInfo(agent)),
|
|
10225
|
+
...nextCursor !== void 0 ? { nextCursor } : {}
|
|
10226
|
+
};
|
|
10090
10227
|
}
|
|
10091
10228
|
/**
|
|
10092
|
-
* Get metadata for a single agent.
|
|
10229
|
+
* Get metadata for a single agent. B-115 (2026-08-19) — `cwd` is READ now (see
|
|
10230
|
+
* `GetAgentOptions`'s doc); it used to be accepted and silently ignored.
|
|
10093
10231
|
*
|
|
10094
10232
|
* @public
|
|
10095
10233
|
*/
|
|
10096
|
-
static async get(agentId,
|
|
10097
|
-
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10234
|
+
static async get(agentId, options = {}) {
|
|
10235
|
+
const agent = await getRegisteredAgentOrThrow(agentId, options.cwd);
|
|
10098
10236
|
return toAgentInfo(agent);
|
|
10099
10237
|
}
|
|
10100
10238
|
/**
|
|
10101
|
-
* List runs for an agent.
|
|
10239
|
+
* List runs for an agent. B-115 (2026-08-19) — `cwd` and `limit`/`cursor` are READ now (see
|
|
10240
|
+
* `ListRunsOptions`'s doc); they used to be accepted and silently ignored.
|
|
10102
10241
|
*
|
|
10103
10242
|
* @public
|
|
10104
10243
|
*/
|
|
10105
|
-
static async listRuns(agentId,
|
|
10106
|
-
await getRegisteredAgentOrThrow(agentId);
|
|
10107
|
-
|
|
10244
|
+
static async listRuns(agentId, options = {}) {
|
|
10245
|
+
await getRegisteredAgentOrThrow(agentId, options.cwd);
|
|
10246
|
+
const { items, nextCursor } = paginateByKey(
|
|
10247
|
+
listRunsByAgent(agentId),
|
|
10248
|
+
(run) => run.id,
|
|
10249
|
+
options.limit,
|
|
10250
|
+
options.cursor,
|
|
10251
|
+
/* sortByKey */
|
|
10252
|
+
false
|
|
10253
|
+
);
|
|
10254
|
+
return { items, ...nextCursor !== void 0 ? { nextCursor } : {} };
|
|
10108
10255
|
}
|
|
10109
10256
|
/**
|
|
10110
10257
|
* Get a single run.
|
|
@@ -10113,14 +10260,14 @@ var Agent = class _Agent {
|
|
|
10113
10260
|
*/
|
|
10114
10261
|
static async getRun(runId, options = {}) {
|
|
10115
10262
|
if (options.runtime === "cloud") {
|
|
10116
|
-
throw new
|
|
10263
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
10117
10264
|
"Cloud runtime is pre-release. Theo PaaS endpoints are not wired yet \u2014 getRun({ runtime: 'cloud' }) will be enabled when the PaaS ships.",
|
|
10118
10265
|
{ code: "cloud_runtime_pre_release" }
|
|
10119
10266
|
);
|
|
10120
10267
|
}
|
|
10121
10268
|
const existing = getRun(runId);
|
|
10122
10269
|
if (existing !== void 0) return existing;
|
|
10123
|
-
throw new
|
|
10270
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10124
10271
|
`Run ${runId} is not in this process's registry. It may have been disposed, persisted in a previous process, or never created.`,
|
|
10125
10272
|
{ code: "run_not_found" }
|
|
10126
10273
|
);
|
|
@@ -10167,13 +10314,13 @@ var Agent = class _Agent {
|
|
|
10167
10314
|
reg = getRegisteredAgent(agentId);
|
|
10168
10315
|
}
|
|
10169
10316
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10170
|
-
throw new
|
|
10317
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10171
10318
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10172
10319
|
);
|
|
10173
10320
|
}
|
|
10174
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10321
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-YCT6JMBX.cjs');
|
|
10175
10322
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10176
|
-
return
|
|
10323
|
+
return chunk5BJV5UPY_cjs.enqueueSessionWrite(
|
|
10177
10324
|
cwd,
|
|
10178
10325
|
agentId,
|
|
10179
10326
|
() => compactSessionTranscript({
|
|
@@ -10203,11 +10350,11 @@ var Agent = class _Agent {
|
|
|
10203
10350
|
reg = getRegisteredAgent(agentId);
|
|
10204
10351
|
}
|
|
10205
10352
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10206
|
-
throw new
|
|
10353
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10207
10354
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10208
10355
|
);
|
|
10209
10356
|
}
|
|
10210
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10357
|
+
const { injectSessionTurn } = await import('./inject-session-XLO3KTBM.cjs');
|
|
10211
10358
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10212
10359
|
await injectSessionTurn({
|
|
10213
10360
|
store,
|
|
@@ -10242,11 +10389,11 @@ var Agent = class _Agent {
|
|
|
10242
10389
|
reg = getRegisteredAgent(agentId);
|
|
10243
10390
|
}
|
|
10244
10391
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10245
|
-
throw new
|
|
10392
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10246
10393
|
`No local agent "${agentId}" registered \u2014 transcript targets local sessions.`
|
|
10247
10394
|
);
|
|
10248
10395
|
}
|
|
10249
|
-
const { readSessionMessages } = await import('./agent-session-store-
|
|
10396
|
+
const { readSessionMessages } = await import('./agent-session-store-ZJ3JSRS4.cjs');
|
|
10250
10397
|
const { store } = await openLocalStore(reg);
|
|
10251
10398
|
return readSessionMessages(store, agentId);
|
|
10252
10399
|
}
|
|
@@ -10267,7 +10414,7 @@ var Agent = class _Agent {
|
|
|
10267
10414
|
*/
|
|
10268
10415
|
static async describe(agentId) {
|
|
10269
10416
|
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10270
|
-
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-
|
|
10417
|
+
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-AZIXJ7D3.cjs');
|
|
10271
10418
|
const settingSources = agent.options.local?.settingSources;
|
|
10272
10419
|
const subagents = await loadSubagents2(
|
|
10273
10420
|
agent.cwd ?? process.cwd(),
|
|
@@ -10311,12 +10458,12 @@ async function getOrCreateUncached(agentId, options) {
|
|
|
10311
10458
|
try {
|
|
10312
10459
|
return await Agent.resume(agentId, options);
|
|
10313
10460
|
} catch (err) {
|
|
10314
|
-
if (!(err instanceof
|
|
10461
|
+
if (!(err instanceof chunkK3FW2XZD_cjs.UnknownAgentError)) throw err;
|
|
10315
10462
|
}
|
|
10316
10463
|
try {
|
|
10317
10464
|
return await Agent.create({ ...options, agentId });
|
|
10318
10465
|
} catch (err) {
|
|
10319
|
-
if (err instanceof
|
|
10466
|
+
if (err instanceof chunkK3FW2XZD_cjs.ConfigurationError && err.code === "agent_id_already_exists") {
|
|
10320
10467
|
return await Agent.resume(agentId, options);
|
|
10321
10468
|
}
|
|
10322
10469
|
throw err;
|
|
@@ -10334,8 +10481,8 @@ async function openLocalStore(reg) {
|
|
|
10334
10481
|
const cwd = reg.cwd ?? process.cwd();
|
|
10335
10482
|
const optModel = reg.options.model;
|
|
10336
10483
|
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-
|
|
10484
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-3MOJQGP2.cjs');
|
|
10485
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-JXHFTB7G.cjs');
|
|
10339
10486
|
const configuredSessionDir = reg.options.local?.sessionDir ?? reg.options.local?.baseDir;
|
|
10340
10487
|
const baseDir = configuredSessionDir !== void 0 ? expandTilde2(configuredSessionDir) : defaultBaseDir2();
|
|
10341
10488
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
@@ -10352,5 +10499,5 @@ exports.computeCost = computeCost;
|
|
|
10352
10499
|
exports.generateCronId = generateCronId;
|
|
10353
10500
|
exports.getPricingEntry = getPricingEntry;
|
|
10354
10501
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10355
|
-
//# sourceMappingURL=chunk-
|
|
10356
|
-
//# sourceMappingURL=chunk-
|
|
10502
|
+
//# sourceMappingURL=chunk-UFAO4T7Z.cjs.map
|
|
10503
|
+
//# sourceMappingURL=chunk-UFAO4T7Z.cjs.map
|