@theokit/sdk 4.53.0 → 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 +1096 -8
- package/LICENSE +2 -2
- package/README.md +14 -9
- package/bin/theokit-migrate-config.mjs +11 -2
- 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-BiCINq25.d.ts → agent-CIUgz7cN.d.cts} +211 -858
- package/dist/{agent-Zta1kvGH.d.cts → agent-DSec-E0c.d.ts} +211 -858
- package/dist/agent-NOEGF4GI.cjs +61 -0
- package/dist/{agent-JX5SBYDE.cjs.map → agent-NOEGF4GI.cjs.map} +1 -1
- package/dist/agent-VGD5WL4N.js +52 -0
- package/dist/{agent-ZAGG6ZBS.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-JMU7ASDB.js.map → agent-session-store-P6V3FINW.js.map} +1 -1
- package/dist/agent-session-store-ZJ3JSRS4.cjs +24 -0
- package/dist/{agent-session-store-EPX2WQI4.cjs.map → agent-session-store-ZJ3JSRS4.cjs.map} +1 -1
- package/dist/agent.d.ts +25 -7
- package/dist/auth/index.cjs +53 -36
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +27 -10
- package/dist/auth/index.js.map +1 -1
- package/dist/{batch-NLIS4QTW.js → batch-2TGJMNCJ.js} +14 -13
- package/dist/batch-2TGJMNCJ.js.map +1 -0
- package/dist/{batch-WQ3AJCDV.cjs → batch-ND32UKZS.cjs} +31 -30
- package/dist/batch-ND32UKZS.cjs.map +1 -0
- package/dist/{chunk-TR4V2LHV.cjs → chunk-2ADR2GSO.cjs} +8 -8
- package/dist/chunk-2ADR2GSO.cjs.map +1 -0
- package/dist/{chunk-7HQVDLFI.cjs → chunk-2C72DXQF.cjs} +65 -27
- package/dist/chunk-2C72DXQF.cjs.map +1 -0
- package/dist/{chunk-DEZ75ET5.js → chunk-2D34UTDC.js} +21 -5
- package/dist/chunk-2D34UTDC.js.map +1 -0
- package/dist/{chunk-XGYI2KQH.js → chunk-2QKTVKH3.js} +4 -4
- package/dist/{chunk-XGYI2KQH.js.map → chunk-2QKTVKH3.js.map} +1 -1
- package/dist/{chunk-BBZYXVLZ.cjs → chunk-2ZPEDVLM.cjs} +2 -2
- package/dist/chunk-2ZPEDVLM.cjs.map +1 -0
- package/dist/{chunk-DHVNJYTO.js → chunk-3E77SX4H.js} +4 -4
- package/dist/{chunk-DHVNJYTO.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-FUASIT3E.cjs → chunk-3YJNUKYN.cjs} +15 -15
- package/dist/{chunk-FUASIT3E.cjs.map → chunk-3YJNUKYN.cjs.map} +1 -1
- package/dist/{chunk-R7TKOQMJ.js → chunk-44JAAH4X.js} +3 -3
- package/dist/chunk-44JAAH4X.js.map +1 -0
- package/dist/{chunk-XRI6DXPZ.js → chunk-44MBDIHG.js} +4 -4
- package/dist/chunk-44MBDIHG.js.map +1 -0
- package/dist/{chunk-BXVSBYGW.js → chunk-4ERPXIVB.js} +5 -5
- package/dist/{chunk-BXVSBYGW.js.map → chunk-4ERPXIVB.js.map} +1 -1
- package/dist/{chunk-T6QUCG7L.cjs → chunk-4I55V454.cjs} +4 -4
- package/dist/chunk-4I55V454.cjs.map +1 -0
- 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-3YYDHUNH.cjs → chunk-53CBTBWO.cjs} +11 -11
- package/dist/{chunk-3YYDHUNH.cjs.map → chunk-53CBTBWO.cjs.map} +1 -1
- package/dist/{chunk-2QMK627M.cjs → chunk-5BJV5UPY.cjs} +27 -27
- package/dist/chunk-5BJV5UPY.cjs.map +1 -0
- package/dist/{chunk-OZXPA3ME.js → chunk-5JLFFPCH.js} +4 -4
- package/dist/{chunk-OZXPA3ME.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-EQMLJ52C.cjs → chunk-5UOVYM3P.cjs} +36 -31
- package/dist/chunk-5UOVYM3P.cjs.map +1 -0
- package/dist/{chunk-33L2NVTJ.cjs → chunk-5USCYPPI.cjs} +15 -15
- package/dist/chunk-5USCYPPI.cjs.map +1 -0
- package/dist/{chunk-I732VEDW.js → chunk-AEOZTXVW.js} +3 -3
- package/dist/{chunk-I732VEDW.js.map → chunk-AEOZTXVW.js.map} +1 -1
- package/dist/{chunk-5XXUYU3M.js → chunk-AG5JPQIY.js} +3 -3
- package/dist/{chunk-5XXUYU3M.js.map → chunk-AG5JPQIY.js.map} +1 -1
- package/dist/{chunk-3SHW7XKK.js → chunk-AGSBJD2L.js} +27 -29
- package/dist/chunk-AGSBJD2L.js.map +1 -0
- package/dist/{chunk-KZBB4YKU.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-UJ3SXRZZ.js → chunk-BMAZLQQ4.js} +3 -3
- package/dist/{chunk-UJ3SXRZZ.js.map → chunk-BMAZLQQ4.js.map} +1 -1
- package/dist/{chunk-NUEL6RCZ.cjs → chunk-BVZW2B5V.cjs} +4 -4
- package/dist/chunk-BVZW2B5V.cjs.map +1 -0
- package/dist/{chunk-W4FV7JBH.js → chunk-CQ2TQ32Y.js} +4 -4
- package/dist/chunk-CQ2TQ32Y.js.map +1 -0
- package/dist/{chunk-NFATC6ZF.cjs → chunk-CQGYNZ3K.cjs} +4 -4
- package/dist/{chunk-NFATC6ZF.cjs.map → chunk-CQGYNZ3K.cjs.map} +1 -1
- package/dist/{chunk-3R4ZCQAZ.cjs → chunk-CTCGWIUD.cjs} +5 -5
- package/dist/{chunk-3R4ZCQAZ.cjs.map → chunk-CTCGWIUD.cjs.map} +1 -1
- package/dist/{chunk-HTK54K2J.js → chunk-CV7XMBHP.js} +4 -4
- package/dist/chunk-CV7XMBHP.js.map +1 -0
- package/dist/{chunk-NOS7PTKP.js → chunk-DAPSQZT4.js} +15 -10
- package/dist/chunk-DAPSQZT4.js.map +1 -0
- package/dist/{chunk-E3OCRJU6.cjs → chunk-DQKERTND.cjs} +11 -11
- package/dist/{chunk-E3OCRJU6.cjs.map → chunk-DQKERTND.cjs.map} +1 -1
- package/dist/{chunk-I5OTK2RP.js → chunk-DUIF54UP.js} +6 -6
- package/dist/chunk-DUIF54UP.js.map +1 -0
- package/dist/{chunk-C4EU627W.js → chunk-DZBSJX6J.js} +4 -4
- package/dist/{chunk-C4EU627W.js.map → chunk-DZBSJX6J.js.map} +1 -1
- package/dist/{chunk-ADVZIC43.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-RAACTJ7C.cjs → chunk-F3YZMOAU.cjs} +8 -8
- package/dist/{chunk-RAACTJ7C.cjs.map → chunk-F3YZMOAU.cjs.map} +1 -1
- package/dist/{chunk-KIX45IKP.js → chunk-F7AQV62G.js} +5 -4
- package/dist/chunk-F7AQV62G.js.map +1 -0
- package/dist/{chunk-2YWWPCGX.js → chunk-FXEUP75G.js} +10 -12
- 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-634YVZLU.js → chunk-GJ6RK75E.js} +5 -5
- package/dist/chunk-GJ6RK75E.js.map +1 -0
- package/dist/{chunk-Z5U2JGEK.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-BWGXYOBZ.cjs → chunk-GWC3HADL.cjs} +4 -4
- package/dist/{chunk-BWGXYOBZ.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-RTLUZKDL.cjs → chunk-HJBMA5MB.cjs} +11 -11
- package/dist/{chunk-RTLUZKDL.cjs.map → chunk-HJBMA5MB.cjs.map} +1 -1
- package/dist/{chunk-AM2CNBKE.js → chunk-HKCKOAIO.js} +2 -2
- package/dist/chunk-HKCKOAIO.js.map +1 -0
- package/dist/{chunk-PVBANCWU.cjs → chunk-HY57ULY2.cjs} +5 -5
- package/dist/{chunk-PVBANCWU.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-2CFEET3Y.cjs → chunk-I6TGFUCO.cjs} +4 -4
- package/dist/chunk-I6TGFUCO.cjs.map +1 -0
- package/dist/{chunk-HI4ZW62S.js → chunk-IDCKSLYH.js} +4 -4
- package/dist/chunk-IDCKSLYH.js.map +1 -0
- package/dist/{chunk-KNZU4YO5.cjs → chunk-ILCGLTSA.cjs} +4 -4
- package/dist/{chunk-KNZU4YO5.cjs.map → chunk-ILCGLTSA.cjs.map} +1 -1
- package/dist/{chunk-44IISBRZ.cjs → chunk-IWBGCBR6.cjs} +4 -4
- package/dist/{chunk-44IISBRZ.cjs.map → chunk-IWBGCBR6.cjs.map} +1 -1
- package/dist/{chunk-R3CKCRK3.cjs → chunk-J24VJOH3.cjs} +22 -6
- package/dist/chunk-J24VJOH3.cjs.map +1 -0
- package/dist/{chunk-ECPL5RV6.cjs → chunk-JHPGF3FP.cjs} +8 -8
- package/dist/{chunk-ECPL5RV6.cjs.map → chunk-JHPGF3FP.cjs.map} +1 -1
- package/dist/{chunk-SXSPMRSV.cjs → chunk-JTB5Q42C.cjs} +21 -19
- package/dist/chunk-JTB5Q42C.cjs.map +1 -0
- package/dist/{chunk-2YGIBOUH.cjs → chunk-K3FW2XZD.cjs} +9 -9
- package/dist/chunk-K3FW2XZD.cjs.map +1 -0
- package/dist/{chunk-6DCTL32L.cjs → chunk-NGESVVJN.cjs} +17 -17
- package/dist/chunk-NGESVVJN.cjs.map +1 -0
- package/dist/{chunk-MV4TOCUK.js → chunk-NLTVXLGT.js} +3 -3
- package/dist/{chunk-MV4TOCUK.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-ZSJPRPN7.js → chunk-OC4NTGMN.js} +3 -3
- package/dist/{chunk-ZSJPRPN7.js.map → chunk-OC4NTGMN.js.map} +1 -1
- package/dist/{chunk-K42QGAKM.cjs → chunk-P6A3M6VD.cjs} +10 -10
- package/dist/{chunk-K42QGAKM.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-XWCTBGYK.js → chunk-QARJGQSA.js} +16 -7
- package/dist/chunk-QARJGQSA.js.map +1 -0
- package/dist/{chunk-EUBGGYPH.cjs → chunk-QDED6YO6.cjs} +5 -5
- package/dist/{chunk-EUBGGYPH.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-PLUCC4N5.js → chunk-QRSUA2CV.js} +3 -3
- package/dist/{chunk-PLUCC4N5.js.map → chunk-QRSUA2CV.js.map} +1 -1
- package/dist/{chunk-YTO5BRBD.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-BC5EUG7R.cjs → chunk-RM7Y65IG.cjs} +18 -20
- 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-V45L2OYP.cjs → chunk-ROYPRJH4.cjs} +9 -9
- package/dist/{chunk-V45L2OYP.cjs.map → chunk-ROYPRJH4.cjs.map} +1 -1
- package/dist/{chunk-JJZ4NIAG.js → chunk-RUDY2GTT.js} +61 -24
- package/dist/chunk-RUDY2GTT.js.map +1 -0
- package/dist/{chunk-QLAWEGTZ.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-7TB5U7RK.js → chunk-SUKXXLWD.js} +6 -6
- package/dist/chunk-SUKXXLWD.js.map +1 -0
- package/dist/{chunk-N43XLTHZ.js → chunk-T73NA43R.js} +3 -3
- package/dist/{chunk-N43XLTHZ.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-4X3SBHPK.js → chunk-T7XEKOVW.js} +18 -17
- package/dist/chunk-T7XEKOVW.js.map +1 -0
- package/dist/{chunk-NZOR3N4E.js → chunk-TPTZA6NI.js} +293 -126
- package/dist/chunk-TPTZA6NI.js.map +1 -0
- package/dist/{chunk-QN5N3ZVT.cjs → chunk-TTHBHAJI.cjs} +44 -46
- package/dist/chunk-TTHBHAJI.cjs.map +1 -0
- package/dist/{chunk-CZHPR2G7.cjs → chunk-U2AC6JUP.cjs} +8 -8
- package/dist/chunk-U2AC6JUP.cjs.map +1 -0
- package/dist/{chunk-ITQ4NO4P.js → chunk-UC3HT2S4.js} +3 -3
- package/dist/{chunk-ITQ4NO4P.js.map → chunk-UC3HT2S4.js.map} +1 -1
- package/dist/{chunk-2VFZQEDW.cjs → chunk-UFAO4T7Z.cjs} +565 -399
- package/dist/chunk-UFAO4T7Z.cjs.map +1 -0
- package/dist/{chunk-DM6Y5B2G.cjs → chunk-UNDROG5N.cjs} +201 -154
- package/dist/chunk-UNDROG5N.cjs.map +1 -0
- package/dist/{chunk-L7EGRCKJ.js → chunk-UPRJR6IP.js} +4 -4
- package/dist/chunk-UPRJR6IP.js.map +1 -0
- package/dist/{chunk-23VZBRDQ.js → chunk-UQGQFBRL.js} +3 -3
- package/dist/chunk-UQGQFBRL.js.map +1 -0
- package/dist/{chunk-2Y5NO2SY.js → chunk-VDEWG5TV.js} +88 -43
- package/dist/chunk-VDEWG5TV.js.map +1 -0
- package/dist/{chunk-CHVSMEKM.js → chunk-VF7EWVDG.js} +3 -3
- package/dist/chunk-VF7EWVDG.js.map +1 -0
- package/dist/{chunk-PNVDQL5Y.cjs → chunk-VTYY7XL5.cjs} +2 -2
- package/dist/chunk-VTYY7XL5.cjs.map +1 -0
- package/dist/{chunk-E6T264NS.js → chunk-WKRSH2VR.js} +3 -3
- package/dist/{chunk-E6T264NS.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-EFXJ5C7X.js → chunk-XN7NOENA.js} +6 -6
- package/dist/chunk-XN7NOENA.js.map +1 -0
- package/dist/{chunk-AMYY3JHQ.cjs → chunk-XSX2UU6Y.cjs} +10 -9
- package/dist/chunk-XSX2UU6Y.cjs.map +1 -0
- package/dist/{chunk-6PTCKXD3.js → chunk-XV4IZNV4.js} +9 -9
- package/dist/chunk-XV4IZNV4.js.map +1 -0
- package/dist/{chunk-FBZMSLDC.cjs → chunk-XWL6O3SW.cjs} +4 -4
- package/dist/chunk-XWL6O3SW.cjs.map +1 -0
- package/dist/{chunk-OIBHY6JQ.js → chunk-YMA4S2WO.js} +4 -4
- package/dist/{chunk-OIBHY6JQ.js.map → chunk-YMA4S2WO.js.map} +1 -1
- package/dist/{chunk-T5ZWI3MC.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-EJ36VH5I.js.map → compact-session-K5LXTBPJ.js.map} +1 -1
- package/dist/compact-session-YCT6JMBX.cjs +59 -0
- package/dist/{compact-session-6GKIS4SD.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-DCECDKWN.js.map → context-FDOON2DB.js.map} +1 -1
- package/dist/context-VMIE4BMD.cjs +23 -0
- package/dist/{context-4HGPCOH6.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 +44 -42
- package/dist/cron.d.cts +5 -3
- package/dist/cron.d.ts +5 -3
- package/dist/cron.js +43 -41
- package/dist/define-tool.d.ts +14 -6
- package/dist/{errors-CHllybaU.d.ts → errors-BgJH9PHi.d.cts} +39 -24
- package/dist/{errors-BSoXcl3F.d.cts → 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 +62 -59
- 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 +52 -49
- package/dist/eval.js.map +1 -1
- package/dist/event-bus.d.ts +16 -0
- package/dist/{executor-3CGPLVJL.js → executor-BMEHFOXZ.js} +8 -7
- package/dist/executor-BMEHFOXZ.js.map +1 -0
- package/dist/{executor-4SW7QGZ4.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-VXXDIBGM.cjs.map → fs-session-store-3MOJQGP2.cjs.map} +1 -1
- package/dist/fs-session-store-IN7JTTXD.js +11 -0
- package/dist/{fs-session-store-LIKYT24K.js.map → fs-session-store-IN7JTTXD.js.map} +1 -1
- package/dist/generate-object-N5MDZUJI.js +8 -0
- package/dist/{generate-object-TVQCW2IZ.js.map → generate-object-N5MDZUJI.js.map} +1 -1
- package/dist/generate-object-PGSP5U7N.cjs +21 -0
- package/dist/{generate-object-E465DX5I.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-HGGL4DD5.cjs.map → index-manager-NG5YENWO.cjs.map} +1 -1
- package/dist/index-manager-ZMRJ6ZII.js +13 -0
- package/dist/{index-manager-EA6FGIQG.js.map → index-manager-ZMRJ6ZII.js.map} +1 -1
- package/dist/index.cjs +176 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +761 -57
- package/dist/index.d.ts +761 -57
- package/dist/index.js +62 -59
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-HO7FYVCX.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 +84 -2
- package/dist/internal/auth/credential-store.d.ts +34 -6
- package/dist/internal/auth/oauth-device.d.ts +2 -3
- 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/mcp-pool.d.ts +2 -4
- 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 +19 -1
- package/dist/internal/mcp/token-storage.d.ts +52 -1
- 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/atomic-write.d.cts +93 -0
- package/dist/internal/persistence/atomic-write.d.ts +93 -0
- 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 +41 -1
- package/dist/internal/persistence/file-lock.d.ts +41 -1
- 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 +29 -1
- package/dist/internal/persistence/fts5-sanitize.d.ts +29 -1
- 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-dir.d.cts +1 -0
- package/dist/internal/persistence/session-dir.d.ts +1 -0
- package/dist/internal/persistence/session-writer.d.cts +20 -7
- package/dist/internal/persistence/session-writer.d.ts +20 -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 +53 -0
- package/dist/internal/persistence/sqlite-wal.d.ts +53 -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/cerebras.d.ts +2 -2
- package/dist/internal/providers/builtin/deepinfra.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 +37 -1
- 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/env-policy.d.ts +1 -3
- 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 +107 -0
- package/dist/internal/security/path-guard.d.ts +107 -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/compact-session.d.ts +2 -2
- 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 +38 -0
- package/dist/job-queue.d.ts +18 -0
- package/dist/judge-call-DWHAJATE.js +6 -0
- package/dist/{judge-call-QMKGC2ZK.js.map → judge-call-DWHAJATE.js.map} +1 -1
- package/dist/judge-call-EGYRC2RE.cjs +23 -0
- package/dist/{judge-call-GVIJWQVE.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 +43 -28
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +26 -11
- 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-UBY26R4I.cjs.map → registry-VFKX7WOP.cjs.map} +1 -1
- package/dist/registry-VFP3WWQP.js +10 -0
- package/dist/{registry-GC7BQMSV.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.ts → run-BYSHf58D.d.cts} +185 -33
- package/dist/{run-C8FBAC8o.d.cts → 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 -14
- package/dist/sandbox/bwrap.d.ts +27 -14
- package/dist/sandbox/index.cjs +21 -20
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.js +6 -5
- 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-SKIRBEJE.js.map → session-transcript-AKDYYGXQ.js.map} +1 -1
- package/dist/session-transcript-JXHFTB7G.cjs +51 -0
- package/dist/{session-transcript-TNAJ4O3M.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-T4DAMNVB.cjs.map → stream-object-BUCF5PHO.cjs.map} +1 -1
- package/dist/stream-object-L57K4OFS.js +8 -0
- package/dist/{stream-object-QMNR3YFF.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-3CXBQWWY.cjs.map → subagents-loader-AZIXJ7D3.cjs.map} +1 -1
- package/dist/subagents-loader-J54ESLDV.js +7 -0
- package/dist/{subagents-loader-WN2SB6PV.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 +69 -17
- 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 +21 -2
- 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 +208 -172
- package/docs/harness-capability-map.md +1357 -304
- package/package.json +21 -8
- 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-JX5SBYDE.cjs +0 -59
- package/dist/agent-ZAGG6ZBS.js +0 -50
- package/dist/agent-session-store-EPX2WQI4.cjs +0 -23
- package/dist/agent-session-store-JMU7ASDB.js +0 -6
- package/dist/batch-NLIS4QTW.js.map +0 -1
- package/dist/batch-WQ3AJCDV.cjs.map +0 -1
- package/dist/chunk-23VZBRDQ.js.map +0 -1
- package/dist/chunk-2CFEET3Y.cjs.map +0 -1
- package/dist/chunk-2QMK627M.cjs.map +0 -1
- package/dist/chunk-2RW7K6FN.cjs.map +0 -1
- package/dist/chunk-2VFZQEDW.cjs.map +0 -1
- package/dist/chunk-2XLKLVVR.js.map +0 -1
- package/dist/chunk-2Y5NO2SY.js.map +0 -1
- package/dist/chunk-2YGIBOUH.cjs.map +0 -1
- package/dist/chunk-2YWWPCGX.js.map +0 -1
- package/dist/chunk-33L2NVTJ.cjs.map +0 -1
- package/dist/chunk-34XOCZJO.js.map +0 -1
- package/dist/chunk-3SHW7XKK.js.map +0 -1
- package/dist/chunk-4NAKHID5.js.map +0 -1
- package/dist/chunk-4X3SBHPK.js.map +0 -1
- package/dist/chunk-5NBUH3NO.js.map +0 -1
- package/dist/chunk-634YVZLU.js.map +0 -1
- package/dist/chunk-6DCTL32L.cjs.map +0 -1
- package/dist/chunk-6PTCKXD3.js.map +0 -1
- package/dist/chunk-7HQVDLFI.cjs.map +0 -1
- package/dist/chunk-7TB5U7RK.js.map +0 -1
- package/dist/chunk-7W7ZWMLQ.js.map +0 -1
- package/dist/chunk-ADVZIC43.cjs.map +0 -1
- package/dist/chunk-AM2CNBKE.js.map +0 -1
- package/dist/chunk-AMYY3JHQ.cjs.map +0 -1
- package/dist/chunk-B4YA6BRS.cjs.map +0 -1
- package/dist/chunk-BBZYXVLZ.cjs.map +0 -1
- package/dist/chunk-BC5EUG7R.cjs.map +0 -1
- package/dist/chunk-CAH3G4IS.js.map +0 -1
- package/dist/chunk-CHVSMEKM.js.map +0 -1
- package/dist/chunk-CZHPR2G7.cjs.map +0 -1
- package/dist/chunk-DEZ75ET5.js.map +0 -1
- package/dist/chunk-DM6Y5B2G.cjs.map +0 -1
- package/dist/chunk-EFXJ5C7X.js.map +0 -1
- package/dist/chunk-EQMLJ52C.cjs.map +0 -1
- package/dist/chunk-FBZMSLDC.cjs.map +0 -1
- package/dist/chunk-HI4ZW62S.js.map +0 -1
- package/dist/chunk-HTK54K2J.js.map +0 -1
- package/dist/chunk-I5OTK2RP.js.map +0 -1
- package/dist/chunk-JJZ4NIAG.js.map +0 -1
- package/dist/chunk-KIX45IKP.js.map +0 -1
- package/dist/chunk-KZBB4YKU.js.map +0 -1
- package/dist/chunk-L5YO6PWL.cjs.map +0 -1
- package/dist/chunk-L7EGRCKJ.js.map +0 -1
- package/dist/chunk-NOS7PTKP.js.map +0 -1
- package/dist/chunk-NUEL6RCZ.cjs.map +0 -1
- package/dist/chunk-NZOR3N4E.js.map +0 -1
- package/dist/chunk-OKLYRPKL.cjs.map +0 -1
- package/dist/chunk-OXNYIMZZ.js.map +0 -1
- package/dist/chunk-PNVDQL5Y.cjs.map +0 -1
- package/dist/chunk-QLAWEGTZ.cjs.map +0 -1
- package/dist/chunk-QN5N3ZVT.cjs.map +0 -1
- package/dist/chunk-R3CKCRK3.cjs.map +0 -1
- package/dist/chunk-R7TKOQMJ.js.map +0 -1
- package/dist/chunk-RP5HQVLD.js.map +0 -1
- package/dist/chunk-SXSPMRSV.cjs.map +0 -1
- package/dist/chunk-T5ZWI3MC.cjs.map +0 -1
- package/dist/chunk-T6QUCG7L.cjs.map +0 -1
- package/dist/chunk-TR4V2LHV.cjs.map +0 -1
- package/dist/chunk-VYCKUKPA.cjs.map +0 -1
- package/dist/chunk-VYHJZVL5.cjs.map +0 -1
- package/dist/chunk-W4FV7JBH.js.map +0 -1
- package/dist/chunk-X2FR4OIT.js.map +0 -1
- package/dist/chunk-XRI6DXPZ.js.map +0 -1
- package/dist/chunk-XWCTBGYK.js.map +0 -1
- package/dist/chunk-YLQQX5W2.cjs.map +0 -1
- package/dist/chunk-YTO5BRBD.cjs.map +0 -1
- package/dist/chunk-Z5U2JGEK.cjs.map +0 -1
- package/dist/compact-session-6GKIS4SD.cjs +0 -58
- package/dist/compact-session-EJ36VH5I.js +0 -21
- package/dist/context-4HGPCOH6.cjs +0 -22
- package/dist/context-DCECDKWN.js +0 -5
- package/dist/cron-DgHJnMAK.d.cts +0 -631
- package/dist/cron-DyWQsEG6.d.ts +0 -631
- package/dist/executor-3CGPLVJL.js.map +0 -1
- package/dist/executor-4SW7QGZ4.cjs.map +0 -1
- package/dist/fs-session-store-LIKYT24K.js +0 -10
- package/dist/fs-session-store-VXXDIBGM.cjs +0 -19
- package/dist/generate-object-E465DX5I.cjs +0 -20
- package/dist/generate-object-TVQCW2IZ.js +0 -7
- package/dist/index-manager-EA6FGIQG.js +0 -12
- package/dist/index-manager-HGGL4DD5.cjs +0 -21
- package/dist/inject-session-67SF65FC.cjs +0 -28
- package/dist/inject-session-67SF65FC.cjs.map +0 -1
- package/dist/inject-session-HO7FYVCX.js.map +0 -1
- package/dist/judge-call-GVIJWQVE.cjs +0 -22
- package/dist/judge-call-QMKGC2ZK.js +0 -5
- package/dist/oauth-transaction-store-7CKHPQRN.cjs +0 -32
- package/dist/oauth-transaction-store-W74I6EFD.js +0 -3
- package/dist/registry-GC7BQMSV.js +0 -9
- package/dist/registry-UBY26R4I.cjs +0 -46
- package/dist/session-transcript-SKIRBEJE.js +0 -5
- package/dist/session-transcript-TNAJ4O3M.cjs +0 -50
- package/dist/stream-object-QMNR3YFF.js +0 -7
- package/dist/stream-object-T4DAMNVB.cjs +0 -20
- package/dist/subagents-loader-3CXBQWWY.cjs +0 -15
- package/dist/subagents-loader-WN2SB6PV.js +0 -6
|
@@ -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
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
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');
|
|
11
|
+
var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
|
|
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 chunkECPL5RV6_cjs = require('./chunk-ECPL5RV6.cjs');
|
|
20
|
-
var chunkTR4V2LHV_cjs = require('./chunk-TR4V2LHV.cjs');
|
|
21
|
-
var chunkYLQQX5W2_cjs = require('./chunk-YLQQX5W2.cjs');
|
|
22
|
-
var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
|
|
23
|
-
var chunk2CFEET3Y_cjs = require('./chunk-2CFEET3Y.cjs');
|
|
24
|
-
var chunkRTLUZKDL_cjs = require('./chunk-RTLUZKDL.cjs');
|
|
25
|
-
var chunkAMYY3JHQ_cjs = require('./chunk-AMYY3JHQ.cjs');
|
|
26
|
-
var chunkVYHJZVL5_cjs = require('./chunk-VYHJZVL5.cjs');
|
|
27
|
-
var chunkBC5EUG7R_cjs = require('./chunk-BC5EUG7R.cjs');
|
|
28
|
-
var chunkFUASIT3E_cjs = require('./chunk-FUASIT3E.cjs');
|
|
29
|
-
var chunkYTO5BRBD_cjs = require('./chunk-YTO5BRBD.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();
|
|
@@ -280,19 +282,6 @@ function structurableAnswerOrThrow(result, GenerateObjectError) {
|
|
|
280
282
|
}
|
|
281
283
|
return answer;
|
|
282
284
|
}
|
|
283
|
-
|
|
284
|
-
// src/internal/env.ts
|
|
285
|
-
var API_KEY_ENV_VAR = "THEOKIT_API_KEY";
|
|
286
|
-
function resolveApiKey(explicit) {
|
|
287
|
-
if (explicit !== void 0 && explicit.length > 0) {
|
|
288
|
-
return explicit;
|
|
289
|
-
}
|
|
290
|
-
const fromEnv = process.env[API_KEY_ENV_VAR];
|
|
291
|
-
if (fromEnv !== void 0 && fromEnv.length > 0) {
|
|
292
|
-
return fromEnv;
|
|
293
|
-
}
|
|
294
|
-
return void 0;
|
|
295
|
-
}
|
|
296
285
|
var PREFIX = {
|
|
297
286
|
localAgent: "agent-",
|
|
298
287
|
cloudAgent: "bc-",
|
|
@@ -328,7 +317,7 @@ function normalizeModel(m) {
|
|
|
328
317
|
if (m === void 0 || typeof m !== "string") return m;
|
|
329
318
|
const id = m.trim();
|
|
330
319
|
if (id.length === 0) {
|
|
331
|
-
throw new
|
|
320
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
332
321
|
'model must be a non-empty "provider/model" id string or a ModelSelection object',
|
|
333
322
|
{ code: "invalid_model_selection" }
|
|
334
323
|
);
|
|
@@ -464,7 +453,7 @@ function registryPath(cwd) {
|
|
|
464
453
|
return path.join(cwd, REGISTRY_RELATIVE_PATH);
|
|
465
454
|
}
|
|
466
455
|
async function loadRegistry(cwd) {
|
|
467
|
-
return
|
|
456
|
+
return chunkU2AC6JUP_cjs.readVersionedJson({
|
|
468
457
|
path: registryPath(cwd),
|
|
469
458
|
currentVersion: SCHEMA_VERSION,
|
|
470
459
|
defaultValue: () => ({}),
|
|
@@ -487,8 +476,8 @@ async function saveRegistry(cwd, agents2) {
|
|
|
487
476
|
serialized[id] = toSerialized(agent);
|
|
488
477
|
}
|
|
489
478
|
const path = registryPath(cwd);
|
|
490
|
-
await
|
|
491
|
-
await
|
|
479
|
+
await chunkZF2LDKQQ_cjs.withCwdMutex(`registry:${cwd}`, async () => {
|
|
480
|
+
await chunkU2AC6JUP_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
|
|
492
481
|
});
|
|
493
482
|
}
|
|
494
483
|
function toSerialized(agent) {
|
|
@@ -555,7 +544,7 @@ function scheduleSaveForCwd(cwd) {
|
|
|
555
544
|
}
|
|
556
545
|
} catch (cause) {
|
|
557
546
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
558
|
-
|
|
547
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] registry persist failed (${cwd}): ${msg}
|
|
559
548
|
`);
|
|
560
549
|
} finally {
|
|
561
550
|
pendingSaves.delete(cwd);
|
|
@@ -571,10 +560,11 @@ function registerAgent(agent) {
|
|
|
571
560
|
function getRegisteredAgent(agentId) {
|
|
572
561
|
return agents.get(agentId);
|
|
573
562
|
}
|
|
574
|
-
function listRegisteredAgents(runtime, cwd) {
|
|
563
|
+
function listRegisteredAgents(runtime, cwd, includeArchived = false) {
|
|
575
564
|
let out = Array.from(agents.values());
|
|
576
565
|
if (runtime !== void 0) out = out.filter((agent) => agent.runtime === runtime);
|
|
577
566
|
if (cwd !== void 0) out = out.filter((agent) => resolveRegistryCwd(agent) === cwd);
|
|
567
|
+
if (!includeArchived) out = out.filter((agent) => !agent.archived);
|
|
578
568
|
return out;
|
|
579
569
|
}
|
|
580
570
|
function updateRegisteredAgent(agentId, update) {
|
|
@@ -894,14 +884,14 @@ async function readLegacyFacts(jsonPath) {
|
|
|
894
884
|
}
|
|
895
885
|
async function writeMigratedFacts(cwd, jsonPath, facts) {
|
|
896
886
|
try {
|
|
897
|
-
for (const fact of facts) await
|
|
887
|
+
for (const fact of facts) await chunk5UOVYM3P_cjs.appendFactToMarkdown(cwd, fact);
|
|
898
888
|
await promises.unlink(jsonPath).catch(() => void 0);
|
|
899
|
-
|
|
889
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
|
|
900
890
|
`);
|
|
901
891
|
return { migrated: true, factCount: facts.length };
|
|
902
892
|
} catch (cause) {
|
|
903
893
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
904
|
-
|
|
894
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] memory migration failed (readonly fs?): ${message}
|
|
905
895
|
`);
|
|
906
896
|
return { migrated: false, factCount: 0, reason: "readonly-fs" };
|
|
907
897
|
}
|
|
@@ -911,12 +901,12 @@ async function migrateLegacyJson(cwd, config) {
|
|
|
911
901
|
const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
|
|
912
902
|
if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
|
|
913
903
|
migrationRun.add(key);
|
|
914
|
-
const jsonPath =
|
|
904
|
+
const jsonPath = chunk5UOVYM3P_cjs.legacyMemoryJsonPath(cwd, config);
|
|
915
905
|
if (!await fileExists(jsonPath)) {
|
|
916
906
|
return { migrated: false, factCount: 0, reason: "no-legacy-json" };
|
|
917
907
|
}
|
|
918
|
-
if (await fileExists(
|
|
919
|
-
|
|
908
|
+
if (await fileExists(chunk5UOVYM3P_cjs.memoryMdPath(cwd))) {
|
|
909
|
+
chunkNUKRL3I6_cjs.diag(
|
|
920
910
|
`[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
|
|
921
911
|
`
|
|
922
912
|
);
|
|
@@ -940,13 +930,13 @@ function extractMemoryFact(message) {
|
|
|
940
930
|
async function readMemoryFacts(cwd, config) {
|
|
941
931
|
if (!config.enabled) return [];
|
|
942
932
|
await migrateLegacyJson(cwd, config);
|
|
943
|
-
return
|
|
933
|
+
return chunk5UOVYM3P_cjs.readFacts(cwd, config);
|
|
944
934
|
}
|
|
945
935
|
async function appendMemoryFact(cwd, config, fact) {
|
|
946
936
|
if (!config.enabled) return;
|
|
947
937
|
await migrateLegacyJson(cwd, config);
|
|
948
|
-
const sanitized = { text:
|
|
949
|
-
await
|
|
938
|
+
const sanitized = { text: chunkJTB5Q42C_cjs.redactSecrets(fact.text) };
|
|
939
|
+
await chunk5UOVYM3P_cjs.appendFact(cwd, config, sanitized);
|
|
950
940
|
}
|
|
951
941
|
|
|
952
942
|
// src/internal/runtime/fixtures/fixture-scripts.ts
|
|
@@ -1294,7 +1284,7 @@ function redactScriptSecrets(script) {
|
|
|
1294
1284
|
function redactEventSecrets(event) {
|
|
1295
1285
|
const serialized = JSON.stringify(event);
|
|
1296
1286
|
const localStripped = serialized.replace(FIXTURE_SENTINEL, "***");
|
|
1297
|
-
const redacted =
|
|
1287
|
+
const redacted = chunkJTB5Q42C_cjs.redactSecrets(localStripped);
|
|
1298
1288
|
if (redacted === serialized) return event;
|
|
1299
1289
|
return JSON.parse(redacted);
|
|
1300
1290
|
}
|
|
@@ -1616,8 +1606,8 @@ function createRealCloudRun(options) {
|
|
|
1616
1606
|
cancellable: false,
|
|
1617
1607
|
conversation: []
|
|
1618
1608
|
};
|
|
1619
|
-
const apiKey = resolveApiKey(options.agentOptions.apiKey);
|
|
1620
|
-
const baseUrl =
|
|
1609
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.agentOptions.apiKey);
|
|
1610
|
+
const baseUrl = chunkUNDROG5N_cjs.getConfiguredBaseUrl();
|
|
1621
1611
|
const handle = new RealCloudRun(
|
|
1622
1612
|
{
|
|
1623
1613
|
id,
|
|
@@ -1690,7 +1680,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1690
1680
|
});
|
|
1691
1681
|
if (!response.ok) {
|
|
1692
1682
|
const text = await response.text().catch(() => "");
|
|
1693
|
-
throw new
|
|
1683
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(
|
|
1694
1684
|
`Cloud Run endpoint returned ${response.status}: ${text.slice(0, 200)}`,
|
|
1695
1685
|
{ code: "cloud_run_http_error" }
|
|
1696
1686
|
);
|
|
@@ -1700,7 +1690,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1700
1690
|
async consumeStream(response) {
|
|
1701
1691
|
let finalStatus = "finished";
|
|
1702
1692
|
let finalText = "";
|
|
1703
|
-
for await (const record of
|
|
1693
|
+
for await (const record of chunkUNDROG5N_cjs.parseSseStream(response.body, this.controller.signal)) {
|
|
1704
1694
|
const parsed = safeParse(record.data);
|
|
1705
1695
|
if (parsed === void 0) continue;
|
|
1706
1696
|
const update = this.applyRecord(record.event, parsed);
|
|
@@ -1724,7 +1714,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1724
1714
|
}
|
|
1725
1715
|
if (eventName === "result") {
|
|
1726
1716
|
const update = {
|
|
1727
|
-
finalStatus: parsed.status
|
|
1717
|
+
finalStatus: parsed.status === void 0 ? "finished" : toRunStatus(parsed.status)
|
|
1728
1718
|
};
|
|
1729
1719
|
if (typeof parsed.result === "string") update.finalText = parsed.result;
|
|
1730
1720
|
return update;
|
|
@@ -1736,7 +1726,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1736
1726
|
type: "status",
|
|
1737
1727
|
agent_id: this.agentId,
|
|
1738
1728
|
run_id: this.id,
|
|
1739
|
-
status
|
|
1729
|
+
status: toWireStatus(status)
|
|
1740
1730
|
};
|
|
1741
1731
|
}
|
|
1742
1732
|
buildAssistantEvent(text) {
|
|
@@ -1758,6 +1748,43 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1758
1748
|
this.transitionTo("error");
|
|
1759
1749
|
}
|
|
1760
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
|
+
}
|
|
1761
1788
|
function safeParse(data2) {
|
|
1762
1789
|
try {
|
|
1763
1790
|
return JSON.parse(data2);
|
|
@@ -1808,8 +1835,8 @@ var CloudAgent = class {
|
|
|
1808
1835
|
* cloud operations are pre-release and must surface explicit errors.
|
|
1809
1836
|
*/
|
|
1810
1837
|
isFixtureMode() {
|
|
1811
|
-
const apiKey = resolveApiKey(this.options.apiKey);
|
|
1812
|
-
return
|
|
1838
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(this.options.apiKey);
|
|
1839
|
+
return chunkUNDROG5N_cjs.isFixtureApiKey(apiKey) && chunkUNDROG5N_cjs.getConfiguredBaseUrl() === void 0;
|
|
1813
1840
|
}
|
|
1814
1841
|
// SE9 — integrated structured output; delegates to the shared helper.
|
|
1815
1842
|
generate(message, options) {
|
|
@@ -1823,8 +1850,9 @@ var CloudAgent = class {
|
|
|
1823
1850
|
);
|
|
1824
1851
|
}
|
|
1825
1852
|
async send(message, options = {}) {
|
|
1853
|
+
if (this.disposed) throw new chunkK3FW2XZD_cjs.AgentDisposedError(this.agentId);
|
|
1826
1854
|
if (options.tools !== void 0 && options.tools.length > 0) {
|
|
1827
|
-
throw new
|
|
1855
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
1828
1856
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
1829
1857
|
{ code: "cloud_custom_tools_rejected" }
|
|
1830
1858
|
);
|
|
@@ -1834,7 +1862,7 @@ var CloudAgent = class {
|
|
|
1834
1862
|
throw new UnsupportedTaskOperationError("send", { cause: void 0 });
|
|
1835
1863
|
}
|
|
1836
1864
|
return new Promise((resolve, reject) => {
|
|
1837
|
-
void
|
|
1865
|
+
void chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${this.agentId}`, async () => {
|
|
1838
1866
|
let run;
|
|
1839
1867
|
try {
|
|
1840
1868
|
run = await this.sendLocked(message, options);
|
|
@@ -1859,8 +1887,8 @@ var CloudAgent = class {
|
|
|
1859
1887
|
}
|
|
1860
1888
|
const userText = typeof message === "string" ? message : message.text;
|
|
1861
1889
|
const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
|
|
1862
|
-
const apiKey = resolveApiKey(this.options.apiKey);
|
|
1863
|
-
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;
|
|
1864
1892
|
return useRealRuntime ? createRealCloudRun({
|
|
1865
1893
|
agentId: this.agentId,
|
|
1866
1894
|
model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
|
|
@@ -1909,7 +1937,7 @@ var CloudAgent = class {
|
|
|
1909
1937
|
listArtifacts() {
|
|
1910
1938
|
if (!this.isFixtureMode()) {
|
|
1911
1939
|
return Promise.reject(
|
|
1912
|
-
new
|
|
1940
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
1913
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).",
|
|
1914
1942
|
{ code: "cloud_runtime_pre_release" }
|
|
1915
1943
|
)
|
|
@@ -1919,11 +1947,11 @@ var CloudAgent = class {
|
|
|
1919
1947
|
}
|
|
1920
1948
|
downloadArtifact(path) {
|
|
1921
1949
|
try {
|
|
1922
|
-
|
|
1950
|
+
chunkR3UPQFKK_cjs.validateArtifactPath(path);
|
|
1923
1951
|
} catch (cause) {
|
|
1924
|
-
if (cause instanceof
|
|
1952
|
+
if (cause instanceof chunkR3UPQFKK_cjs.PathTraversalError) {
|
|
1925
1953
|
return Promise.reject(
|
|
1926
|
-
new
|
|
1954
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(`Artifact path must stay inside the workspace: ${path}`, {
|
|
1927
1955
|
code: "artifact_path_traversal",
|
|
1928
1956
|
cause
|
|
1929
1957
|
})
|
|
@@ -1933,7 +1961,7 @@ var CloudAgent = class {
|
|
|
1933
1961
|
}
|
|
1934
1962
|
if (!this.isFixtureMode()) {
|
|
1935
1963
|
return Promise.reject(
|
|
1936
|
-
new
|
|
1964
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
1937
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).",
|
|
1938
1966
|
{ code: "cloud_runtime_pre_release" }
|
|
1939
1967
|
)
|
|
@@ -1942,7 +1970,7 @@ var CloudAgent = class {
|
|
|
1942
1970
|
const match = buildFixtureArtifacts().find((artifact) => artifact.path === path);
|
|
1943
1971
|
if (match === void 0) {
|
|
1944
1972
|
return Promise.reject(
|
|
1945
|
-
new
|
|
1973
|
+
new chunkK3FW2XZD_cjs.UnknownAgentError(`Artifact ${path} not found`, { code: "unknown_artifact" })
|
|
1946
1974
|
);
|
|
1947
1975
|
}
|
|
1948
1976
|
return Promise.resolve(Buffer.from(`fixture artifact content for ${path}
|
|
@@ -1956,7 +1984,7 @@ var CloudAgent = class {
|
|
|
1956
1984
|
* @public
|
|
1957
1985
|
*/
|
|
1958
1986
|
runUntil() {
|
|
1959
|
-
throw new
|
|
1987
|
+
throw new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
1960
1988
|
"Agent.runUntil() is not supported on cloud agents. Cloud runtime manages goal loops server-side. Use a local agent for autonomous Ralph loops.",
|
|
1961
1989
|
"runUntil"
|
|
1962
1990
|
);
|
|
@@ -1967,7 +1995,7 @@ var CloudAgent = class {
|
|
|
1967
1995
|
* @public
|
|
1968
1996
|
*/
|
|
1969
1997
|
fork() {
|
|
1970
|
-
throw new
|
|
1998
|
+
throw new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
1971
1999
|
"Agent.fork() is not supported on cloud agents. Fork inheritance requires local credential + system-prompt access. Use a local agent.",
|
|
1972
2000
|
"fork"
|
|
1973
2001
|
);
|
|
@@ -1979,7 +2007,7 @@ var CloudAgent = class {
|
|
|
1979
2007
|
* @public
|
|
1980
2008
|
*/
|
|
1981
2009
|
runToCompletion() {
|
|
1982
|
-
throw new
|
|
2010
|
+
throw new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
1983
2011
|
"Agent.runToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
1984
2012
|
"runToCompletion"
|
|
1985
2013
|
);
|
|
@@ -1991,7 +2019,7 @@ var CloudAgent = class {
|
|
|
1991
2019
|
* @public
|
|
1992
2020
|
*/
|
|
1993
2021
|
streamToCompletion() {
|
|
1994
|
-
throw new
|
|
2022
|
+
throw new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
1995
2023
|
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
1996
2024
|
"streamToCompletion"
|
|
1997
2025
|
);
|
|
@@ -2005,7 +2033,7 @@ var CloudAgent = class {
|
|
|
2005
2033
|
*/
|
|
2006
2034
|
usePersonality() {
|
|
2007
2035
|
return Promise.reject(
|
|
2008
|
-
new
|
|
2036
|
+
new chunkK3FW2XZD_cjs.UnsupportedRunOperationError(
|
|
2009
2037
|
"Agent.usePersonality() is not supported on cloud agents (pre-release). Use a local agent or wait for cloud GA.",
|
|
2010
2038
|
"usePersonality"
|
|
2011
2039
|
)
|
|
@@ -2033,7 +2061,7 @@ function validateCloudToolParity(options) {
|
|
|
2033
2061
|
function rejectProcessors(options) {
|
|
2034
2062
|
const hasProcessors = (options.inputProcessors?.length ?? 0) > 0 || (options.outputProcessors?.length ?? 0) > 0;
|
|
2035
2063
|
if (hasProcessors) {
|
|
2036
|
-
throw new
|
|
2064
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2037
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.",
|
|
2038
2066
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2039
2067
|
);
|
|
@@ -2041,7 +2069,7 @@ function rejectProcessors(options) {
|
|
|
2041
2069
|
}
|
|
2042
2070
|
function rejectFunctionSystemPrompt(options) {
|
|
2043
2071
|
if (typeof options.systemPrompt === "function") {
|
|
2044
|
-
throw new
|
|
2072
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2045
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.",
|
|
2046
2074
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2047
2075
|
);
|
|
@@ -2049,7 +2077,7 @@ function rejectFunctionSystemPrompt(options) {
|
|
|
2049
2077
|
}
|
|
2050
2078
|
function rejectFunctionSkills(options) {
|
|
2051
2079
|
if (typeof options.skills === "function") {
|
|
2052
|
-
throw new
|
|
2080
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2053
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.",
|
|
2054
2082
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2055
2083
|
);
|
|
@@ -2061,7 +2089,7 @@ function rejectStdioMcpLocalPaths(options) {
|
|
|
2061
2089
|
if (!isStdioCommandConfig(config)) continue;
|
|
2062
2090
|
const command = config.command ?? "";
|
|
2063
2091
|
if (isLocalPath(command)) {
|
|
2064
|
-
throw new
|
|
2092
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2065
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.`,
|
|
2066
2094
|
{ code: "cloud_incompatible_mcp_stdio_local" }
|
|
2067
2095
|
);
|
|
@@ -2076,6 +2104,25 @@ function isStdioCommandConfig(config) {
|
|
|
2076
2104
|
function isLocalPath(command) {
|
|
2077
2105
|
return command.startsWith("/") || command.startsWith("~/") || command.startsWith("./") || command.startsWith("../");
|
|
2078
2106
|
}
|
|
2107
|
+
|
|
2108
|
+
// src/internal/persistence/session-dir.ts
|
|
2109
|
+
function resolveSessionDir(local) {
|
|
2110
|
+
if (local?.sessionDir !== void 0) {
|
|
2111
|
+
if (local.baseDir !== void 0) {
|
|
2112
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2113
|
+
"[theokit-sdk] local.sessionDir and local.baseDir are both set; using sessionDir. baseDir is the deprecated name for the same option (#301)."
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
return chunkJHPGF3FP_cjs.expandTilde(local.sessionDir);
|
|
2117
|
+
}
|
|
2118
|
+
if (local?.baseDir !== void 0) {
|
|
2119
|
+
chunkNUKRL3I6_cjs.diag(
|
|
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."
|
|
2121
|
+
);
|
|
2122
|
+
return chunkJHPGF3FP_cjs.expandTilde(local.baseDir);
|
|
2123
|
+
}
|
|
2124
|
+
return chunkJHPGF3FP_cjs.defaultBaseDir();
|
|
2125
|
+
}
|
|
2079
2126
|
var SCHEMA_VERSION2 = 1;
|
|
2080
2127
|
var FILE_NAME = "personality.json";
|
|
2081
2128
|
function emptyState() {
|
|
@@ -2101,14 +2148,14 @@ async function readState(filePath) {
|
|
|
2101
2148
|
try {
|
|
2102
2149
|
parsed = JSON.parse(raw);
|
|
2103
2150
|
} catch {
|
|
2104
|
-
|
|
2151
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
2105
2152
|
"personality-store-json-parse",
|
|
2106
2153
|
"[theokit-sdk] personality.json is malformed; treating as empty"
|
|
2107
2154
|
);
|
|
2108
2155
|
return emptyState();
|
|
2109
2156
|
}
|
|
2110
2157
|
if (!isStateV1(parsed)) {
|
|
2111
|
-
|
|
2158
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
2112
2159
|
"personality-store-bad-version",
|
|
2113
2160
|
`[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
|
|
2114
2161
|
);
|
|
@@ -2139,9 +2186,9 @@ var PersonalityStore = class {
|
|
|
2139
2186
|
try {
|
|
2140
2187
|
await this.#persist(agentId, slug);
|
|
2141
2188
|
} catch (err) {
|
|
2142
|
-
|
|
2189
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
2143
2190
|
`personality-store-persist-failure-${agentId}`,
|
|
2144
|
-
`[theokit-sdk] personality persist failed for ${
|
|
2191
|
+
`[theokit-sdk] personality persist failed for ${chunkJTB5Q42C_cjs.redactSecrets(agentId)}: ${chunkJTB5Q42C_cjs.redactSecrets(
|
|
2145
2192
|
err.message
|
|
2146
2193
|
)}`
|
|
2147
2194
|
);
|
|
@@ -2156,9 +2203,9 @@ var PersonalityStore = class {
|
|
|
2156
2203
|
try {
|
|
2157
2204
|
state = await readState(filePath);
|
|
2158
2205
|
} catch (err) {
|
|
2159
|
-
|
|
2206
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
2160
2207
|
`personality-store-hydrate-failure-${agentId}`,
|
|
2161
|
-
`[theokit-sdk] personality hydrate failed for ${
|
|
2208
|
+
`[theokit-sdk] personality hydrate failed for ${chunkJTB5Q42C_cjs.redactSecrets(agentId)}: ${chunkJTB5Q42C_cjs.redactSecrets(
|
|
2162
2209
|
err.message
|
|
2163
2210
|
)}`
|
|
2164
2211
|
);
|
|
@@ -2175,17 +2222,17 @@ var PersonalityStore = class {
|
|
|
2175
2222
|
async #persist(agentId, slug) {
|
|
2176
2223
|
const filePath = this.#filePath();
|
|
2177
2224
|
await promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
2178
|
-
await
|
|
2225
|
+
await chunk2ADR2GSO_cjs.withFileLock(filePath, async () => {
|
|
2179
2226
|
const current = await readState(filePath);
|
|
2180
2227
|
const nextAgents = { ...current.agents };
|
|
2181
2228
|
if (slug === void 0) delete nextAgents[agentId];
|
|
2182
2229
|
else nextAgents[agentId] = slug;
|
|
2183
2230
|
const next = { version: SCHEMA_VERSION2, agents: nextAgents };
|
|
2184
|
-
await
|
|
2231
|
+
await chunkI6TGFUCO_cjs.atomicWriteJson(filePath, next);
|
|
2185
2232
|
});
|
|
2186
2233
|
}
|
|
2187
2234
|
#filePath() {
|
|
2188
|
-
return path.join(
|
|
2235
|
+
return path.join(chunkU2AC6JUP_cjs.getTheokitHome(this.#cwd), FILE_NAME);
|
|
2189
2236
|
}
|
|
2190
2237
|
};
|
|
2191
2238
|
|
|
@@ -2208,7 +2255,7 @@ function createPluginContext() {
|
|
|
2208
2255
|
},
|
|
2209
2256
|
on(hook, handler) {
|
|
2210
2257
|
if (typeof handler !== "function") {
|
|
2211
|
-
|
|
2258
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] ignoring non-function handler for hook "${hook}"
|
|
2212
2259
|
`);
|
|
2213
2260
|
return;
|
|
2214
2261
|
}
|
|
@@ -2261,7 +2308,7 @@ var PluginManager = class {
|
|
|
2261
2308
|
const seen = /* @__PURE__ */ new Set();
|
|
2262
2309
|
for (const plugin of plugins) {
|
|
2263
2310
|
if (seen.has(plugin.name)) {
|
|
2264
|
-
|
|
2311
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2265
2312
|
`[theokit-sdk] duplicate plugin name "${plugin.name}" \u2014 both will register independently
|
|
2266
2313
|
`
|
|
2267
2314
|
);
|
|
@@ -2288,7 +2335,7 @@ var PluginManager = class {
|
|
|
2288
2335
|
*/
|
|
2289
2336
|
async register(plugin) {
|
|
2290
2337
|
if (plugin.kind !== "general") {
|
|
2291
|
-
throw new
|
|
2338
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
2292
2339
|
`late register supports general plugins only (got "${plugin.kind}" for "${plugin.name}")`,
|
|
2293
2340
|
{ code: "plugin_late_register_kind" }
|
|
2294
2341
|
);
|
|
@@ -2345,7 +2392,7 @@ var PluginManager = class {
|
|
|
2345
2392
|
parts.push(result.recalledContext);
|
|
2346
2393
|
}
|
|
2347
2394
|
} catch (err) {
|
|
2348
|
-
|
|
2395
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2349
2396
|
`[theokit-sdk] pre_user_send hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2350
2397
|
`
|
|
2351
2398
|
);
|
|
@@ -2373,7 +2420,7 @@ var PluginManager = class {
|
|
|
2373
2420
|
try {
|
|
2374
2421
|
await h(ctx);
|
|
2375
2422
|
} catch (err) {
|
|
2376
|
-
|
|
2423
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2377
2424
|
`[theokit-sdk] post_assistant_reply hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2378
2425
|
`
|
|
2379
2426
|
);
|
|
@@ -2389,7 +2436,7 @@ var PluginManager = class {
|
|
|
2389
2436
|
try {
|
|
2390
2437
|
await h(ctx);
|
|
2391
2438
|
} catch (err) {
|
|
2392
|
-
|
|
2439
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2393
2440
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2394
2441
|
`
|
|
2395
2442
|
);
|
|
@@ -2404,7 +2451,7 @@ var PluginManager = class {
|
|
|
2404
2451
|
const out = await h(current, ctx);
|
|
2405
2452
|
if (out !== void 0) current = out;
|
|
2406
2453
|
} catch (err) {
|
|
2407
|
-
|
|
2454
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2408
2455
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2409
2456
|
`
|
|
2410
2457
|
);
|
|
@@ -2494,7 +2541,7 @@ function spawnAndCollect(options) {
|
|
|
2494
2541
|
const spawnOptions = {
|
|
2495
2542
|
cwd: options.cwd,
|
|
2496
2543
|
// #54 — scrub secret-like parent env by default; `options.env` still wins.
|
|
2497
|
-
env:
|
|
2544
|
+
env: chunk2ZPEDVLM_cjs.resolveChildEnv({ policy: options.envPolicy, overrides: options.env })
|
|
2498
2545
|
};
|
|
2499
2546
|
const child = child_process.spawn(options.command, options.args ?? [], spawnOptions);
|
|
2500
2547
|
let stdout = "";
|
|
@@ -2546,7 +2593,7 @@ var HooksExecutor = class {
|
|
|
2546
2593
|
this.config = {};
|
|
2547
2594
|
return;
|
|
2548
2595
|
}
|
|
2549
|
-
this.config = await
|
|
2596
|
+
this.config = await chunk53CBTBWO_cjs.loadHookConfig(this.cwd);
|
|
2550
2597
|
}
|
|
2551
2598
|
/** Fire every hook registered for `event` and aggregate the decisions. */
|
|
2552
2599
|
async run(payload) {
|
|
@@ -2652,11 +2699,11 @@ function buildContextBudgetEvent(model, resolved) {
|
|
|
2652
2699
|
// src/internal/runtime/lifecycle/post-run-lifecycle.ts
|
|
2653
2700
|
function resolveWindowForRun(model, contextWindow) {
|
|
2654
2701
|
const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
|
|
2655
|
-
return
|
|
2702
|
+
return chunkXSX2UU6Y_cjs.resolveEffectiveContextWindow({
|
|
2656
2703
|
...override !== void 0 ? { override } : {},
|
|
2657
|
-
catalog:
|
|
2658
|
-
margin:
|
|
2659
|
-
floor:
|
|
2704
|
+
catalog: chunkRM7Y65IG_cjs.getCatalogModelInfo(model)?.limit?.context,
|
|
2705
|
+
margin: chunkXSX2UU6Y_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2706
|
+
floor: chunkXSX2UU6Y_cjs.CONTEXT_WINDOW_FLOOR
|
|
2660
2707
|
});
|
|
2661
2708
|
}
|
|
2662
2709
|
async function runPostRunLifecycle(inputs) {
|
|
@@ -2680,32 +2727,32 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2680
2727
|
try {
|
|
2681
2728
|
const partial = await safeConversation(run);
|
|
2682
2729
|
if (partial !== void 0) {
|
|
2683
|
-
|
|
2730
|
+
chunk5BJV5UPY_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2684
2731
|
userText,
|
|
2685
2732
|
conversation: partial
|
|
2686
2733
|
});
|
|
2687
2734
|
}
|
|
2688
2735
|
} catch (cause) {
|
|
2689
2736
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2690
|
-
|
|
2737
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2691
2738
|
`);
|
|
2692
2739
|
}
|
|
2693
|
-
await
|
|
2740
|
+
await chunk5BJV5UPY_cjs.flushSessionWrites();
|
|
2694
2741
|
return;
|
|
2695
2742
|
}
|
|
2696
2743
|
if (result.result !== void 0) {
|
|
2697
|
-
|
|
2744
|
+
chunk5BJV5UPY_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2698
2745
|
}
|
|
2699
2746
|
const conversation = await safeConversation(run);
|
|
2700
2747
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2701
2748
|
const effectiveWindow = resolvedWindow.window;
|
|
2702
2749
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2703
2750
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2704
|
-
|
|
2751
|
+
chunkNGESVVJN_cjs.emitRunEvent(onRunEvent, budgetEvent);
|
|
2705
2752
|
}
|
|
2706
2753
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2707
2754
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2708
|
-
|
|
2755
|
+
chunk5BJV5UPY_cjs.persistTurnToTranscript(
|
|
2709
2756
|
sessionStore,
|
|
2710
2757
|
{ cwd: workspaceCwd, agentId, model },
|
|
2711
2758
|
agentId,
|
|
@@ -2717,13 +2764,13 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2717
2764
|
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2718
2765
|
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2719
2766
|
contextWindow: effectiveWindow,
|
|
2720
|
-
summarize:
|
|
2767
|
+
summarize: chunkUNDROG5N_cjs.buildDefaultSummarizer({
|
|
2721
2768
|
agentModel: model,
|
|
2722
2769
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2723
2770
|
})
|
|
2724
2771
|
}
|
|
2725
2772
|
},
|
|
2726
|
-
onRunEvent !== void 0 ? () =>
|
|
2773
|
+
onRunEvent !== void 0 ? () => chunkNGESVVJN_cjs.emitRunEvent(onRunEvent, { type: "compact_boundary", trigger: "auto" }) : void 0
|
|
2727
2774
|
);
|
|
2728
2775
|
if (result.status === "finished" && result.result !== void 0) {
|
|
2729
2776
|
const summaryArgs = {
|
|
@@ -2739,14 +2786,14 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2739
2786
|
if (memoryProvider?.recordSessionSummary !== void 0) {
|
|
2740
2787
|
await memoryProvider.recordSessionSummary(summaryArgs);
|
|
2741
2788
|
} else {
|
|
2742
|
-
await
|
|
2789
|
+
await chunk5UOVYM3P_cjs.writeSessionSummary(summaryArgs);
|
|
2743
2790
|
}
|
|
2744
2791
|
if (!shouldUsePortMemoryPath()) {
|
|
2745
2792
|
void memoryGlue.syncIfReady();
|
|
2746
2793
|
}
|
|
2747
2794
|
} catch (cause) {
|
|
2748
2795
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2749
|
-
|
|
2796
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] session summary write failed (${result.id}): ${message}
|
|
2750
2797
|
`);
|
|
2751
2798
|
}
|
|
2752
2799
|
}
|
|
@@ -2759,7 +2806,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2759
2806
|
agentId,
|
|
2760
2807
|
runId: result.id
|
|
2761
2808
|
});
|
|
2762
|
-
await
|
|
2809
|
+
await chunk5BJV5UPY_cjs.flushSessionWrites();
|
|
2763
2810
|
}
|
|
2764
2811
|
async function safeConversation(run) {
|
|
2765
2812
|
try {
|
|
@@ -2834,7 +2881,7 @@ var warned = /* @__PURE__ */ new Set();
|
|
|
2834
2881
|
function warnDoubleReasoningOnce() {
|
|
2835
2882
|
if (warned.has("double-reasoning")) return;
|
|
2836
2883
|
warned.add("double-reasoning");
|
|
2837
|
-
|
|
2884
|
+
chunkNUKRL3I6_cjs.diag(
|
|
2838
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"
|
|
2839
2886
|
);
|
|
2840
2887
|
}
|
|
@@ -2867,9 +2914,9 @@ var SkillsManager = class {
|
|
|
2867
2914
|
}
|
|
2868
2915
|
async refresh() {
|
|
2869
2916
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
2870
|
-
const discovered = await
|
|
2917
|
+
const discovered = await chunk3YJNUKYN_cjs.discoverSkills(skillsRoot, {
|
|
2871
2918
|
onInvalidSkill: (info) => {
|
|
2872
|
-
|
|
2919
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
2873
2920
|
`);
|
|
2874
2921
|
}
|
|
2875
2922
|
});
|
|
@@ -2893,7 +2940,7 @@ var SkillsManager = class {
|
|
|
2893
2940
|
async get(name) {
|
|
2894
2941
|
const skill = this.skills.find((s) => s.name === name);
|
|
2895
2942
|
if (skill === void 0) return void 0;
|
|
2896
|
-
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"));
|
|
2897
2944
|
const references = skill.references;
|
|
2898
2945
|
return {
|
|
2899
2946
|
name: skill.name,
|
|
@@ -2979,7 +3026,7 @@ async function safeCall(fn, fallback, label = "safeCall") {
|
|
|
2979
3026
|
return await fn();
|
|
2980
3027
|
} catch (cause) {
|
|
2981
3028
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2982
|
-
|
|
3029
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] ${label} failed: ${message}
|
|
2983
3030
|
`);
|
|
2984
3031
|
return fallback;
|
|
2985
3032
|
}
|
|
@@ -2993,7 +3040,7 @@ var ActiveMemoryPromptProvider = class {
|
|
|
2993
3040
|
if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
|
|
2994
3041
|
return Promise.resolve(void 0);
|
|
2995
3042
|
}
|
|
2996
|
-
const body =
|
|
3043
|
+
const body = chunk3YJNUKYN_cjs.escapeBlockBody(ctx.activeMemorySummary);
|
|
2997
3044
|
return Promise.resolve(`<active-memory>
|
|
2998
3045
|
${body}
|
|
2999
3046
|
</active-memory>`);
|
|
@@ -3046,7 +3093,7 @@ function formatSource(name, tokens) {
|
|
|
3046
3093
|
if (tokens.length === 0) {
|
|
3047
3094
|
return ` <source name="${escapeAttribute(name)}" />`;
|
|
3048
3095
|
}
|
|
3049
|
-
const body =
|
|
3096
|
+
const body = chunk3YJNUKYN_cjs.escapeBlockBody(tokens.join(" "));
|
|
3050
3097
|
return ` <source name="${escapeAttribute(name)}">
|
|
3051
3098
|
${body}
|
|
3052
3099
|
</source>`;
|
|
@@ -3062,7 +3109,7 @@ var MemoryPromptProvider = class {
|
|
|
3062
3109
|
contribute(ctx) {
|
|
3063
3110
|
if (ctx.memoryAutoInject === false) return Promise.resolve(void 0);
|
|
3064
3111
|
if (ctx.memory.length === 0) return Promise.resolve(void 0);
|
|
3065
|
-
const lines = ctx.memory.map((fact) => ` - ${
|
|
3112
|
+
const lines = ctx.memory.map((fact) => ` - ${chunk3YJNUKYN_cjs.escapeBlockBody(fact.text)}`);
|
|
3066
3113
|
return Promise.resolve(`<memory>
|
|
3067
3114
|
${lines.join("\n")}
|
|
3068
3115
|
</memory>`);
|
|
@@ -3084,7 +3131,7 @@ var SkillsPromptProvider = class {
|
|
|
3084
3131
|
priority = 20;
|
|
3085
3132
|
contribute(ctx) {
|
|
3086
3133
|
if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
|
|
3087
|
-
return Promise.resolve(
|
|
3134
|
+
return Promise.resolve(chunk3YJNUKYN_cjs.buildSkillsBlock(ctx.skills));
|
|
3088
3135
|
}
|
|
3089
3136
|
};
|
|
3090
3137
|
|
|
@@ -3096,7 +3143,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
|
|
|
3096
3143
|
for (const p of providers) {
|
|
3097
3144
|
const key = `${p.priority}:${p.id}`;
|
|
3098
3145
|
if (seen.has(key)) {
|
|
3099
|
-
throw new
|
|
3146
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Duplicate system-prompt provider ${key}`, {
|
|
3100
3147
|
code: "pipeline_duplicate_provider"
|
|
3101
3148
|
});
|
|
3102
3149
|
}
|
|
@@ -3143,7 +3190,7 @@ function validateAgentOptions(options) {
|
|
|
3143
3190
|
ensureRuntimeShape(options);
|
|
3144
3191
|
if (options.local !== void 0) {
|
|
3145
3192
|
if (options.model === void 0) {
|
|
3146
|
-
throw new
|
|
3193
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError("Local agents require a model selection", {
|
|
3147
3194
|
code: "missing_model"
|
|
3148
3195
|
});
|
|
3149
3196
|
}
|
|
@@ -3167,7 +3214,7 @@ function validateCredentialPoolShape(options) {
|
|
|
3167
3214
|
([, arr]) => Array.isArray(arr) && arr.some((k) => typeof k === "string" && k.length > 0)
|
|
3168
3215
|
);
|
|
3169
3216
|
if (populated.length === 0) return;
|
|
3170
|
-
throw new
|
|
3217
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3171
3218
|
"Ambiguous credential configuration: use either `apiKey: '...'` (single-key, simplest) OR `apiKeys: { provider: [...] }` (multi-key pool), not both.",
|
|
3172
3219
|
{ code: "credential_pool_ambiguous" }
|
|
3173
3220
|
);
|
|
@@ -3176,7 +3223,7 @@ function validatePlugins(options) {
|
|
|
3176
3223
|
const plugins = options.plugins;
|
|
3177
3224
|
if (plugins?.paths === void 0) return;
|
|
3178
3225
|
if (options.cloud !== void 0 && plugins.paths.length > 0) {
|
|
3179
|
-
throw new
|
|
3226
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3180
3227
|
"Cloud agents require committed plugin manifests; local plugin paths are not supported",
|
|
3181
3228
|
{ code: "cloud_plugin_path_rejected" }
|
|
3182
3229
|
);
|
|
@@ -3184,7 +3231,7 @@ function validatePlugins(options) {
|
|
|
3184
3231
|
}
|
|
3185
3232
|
function ensureRuntimeShape(options) {
|
|
3186
3233
|
if (options.local !== void 0 && options.cloud !== void 0) {
|
|
3187
|
-
throw new
|
|
3234
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3188
3235
|
"Pass either local or cloud \u2014 they are mutually exclusive runtimes",
|
|
3189
3236
|
{ code: "runtime_exclusive" }
|
|
3190
3237
|
);
|
|
@@ -3192,7 +3239,7 @@ function ensureRuntimeShape(options) {
|
|
|
3192
3239
|
}
|
|
3193
3240
|
function rejectProgrammaticHooks(options) {
|
|
3194
3241
|
if (options.hooks !== void 0) {
|
|
3195
|
-
throw new
|
|
3242
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3196
3243
|
"Programmatic hooks are not supported \u2014 hooks are file-based only (.theokit/hooks.json)",
|
|
3197
3244
|
{ code: "programmatic_hooks_rejected" }
|
|
3198
3245
|
);
|
|
@@ -3202,7 +3249,7 @@ function validateCloud(cloud) {
|
|
|
3202
3249
|
if (cloud.envVars !== void 0) {
|
|
3203
3250
|
for (const key of Object.keys(cloud.envVars)) {
|
|
3204
3251
|
if (key.startsWith("THEOKIT_")) {
|
|
3205
|
-
throw new
|
|
3252
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3206
3253
|
`Cloud envVars cannot use the reserved THEOKIT_ prefix (got "${key}")`,
|
|
3207
3254
|
{ code: "reserved_env_prefix" }
|
|
3208
3255
|
);
|
|
@@ -3214,7 +3261,7 @@ function validateMcpServers(options) {
|
|
|
3214
3261
|
if (options.mcpServers === void 0) return;
|
|
3215
3262
|
for (const [name, config] of Object.entries(options.mcpServers)) {
|
|
3216
3263
|
if (options.cloud !== void 0 && isStdioWithCwd(config)) {
|
|
3217
|
-
throw new
|
|
3264
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3218
3265
|
`MCP server "${name}" uses stdio with cwd, which is rejected for cloud agents`,
|
|
3219
3266
|
{ code: "cloud_stdio_cwd_rejected" }
|
|
3220
3267
|
);
|
|
@@ -3233,12 +3280,12 @@ function validateSubagents(agents2) {
|
|
|
3233
3280
|
if (agents2 === void 0) return;
|
|
3234
3281
|
for (const [name, definition] of Object.entries(agents2)) {
|
|
3235
3282
|
if (typeof definition.description !== "string" || definition.description.length === 0) {
|
|
3236
|
-
throw new
|
|
3283
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty description`, {
|
|
3237
3284
|
code: "subagent_missing_description"
|
|
3238
3285
|
});
|
|
3239
3286
|
}
|
|
3240
3287
|
if (typeof definition.prompt !== "string" || definition.prompt.length === 0) {
|
|
3241
|
-
throw new
|
|
3288
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty prompt`, {
|
|
3242
3289
|
code: "subagent_missing_prompt"
|
|
3243
3290
|
});
|
|
3244
3291
|
}
|
|
@@ -3251,7 +3298,7 @@ function validateToolCatalog(tools) {
|
|
|
3251
3298
|
for (const tool of tools) {
|
|
3252
3299
|
validateSingleTool(tool);
|
|
3253
3300
|
if (seen.has(tool.name)) {
|
|
3254
|
-
throw new
|
|
3301
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Duplicate custom tool name "${tool.name}"`, {
|
|
3255
3302
|
code: "duplicate_tool_name"
|
|
3256
3303
|
});
|
|
3257
3304
|
}
|
|
@@ -3262,7 +3309,7 @@ function validateCustomTools(options) {
|
|
|
3262
3309
|
const tools = options.tools;
|
|
3263
3310
|
if (tools === void 0 || tools.length === 0) return;
|
|
3264
3311
|
if (options.cloud !== void 0) {
|
|
3265
|
-
throw new
|
|
3312
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3266
3313
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
3267
3314
|
{ code: "cloud_custom_tools_rejected" }
|
|
3268
3315
|
);
|
|
@@ -3274,25 +3321,25 @@ function validateSingleTool(tool) {
|
|
|
3274
3321
|
validateToolDescription(tool);
|
|
3275
3322
|
validateToolSchema(tool);
|
|
3276
3323
|
if (typeof tool.handler !== "function") {
|
|
3277
|
-
throw new
|
|
3324
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a handler function`, {
|
|
3278
3325
|
code: "tool_missing_handler"
|
|
3279
3326
|
});
|
|
3280
3327
|
}
|
|
3281
3328
|
}
|
|
3282
3329
|
function validateToolName(tool) {
|
|
3283
3330
|
if (typeof tool.name !== "string" || tool.name.length === 0) {
|
|
3284
|
-
throw new
|
|
3331
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError("Custom tool requires a non-empty name", {
|
|
3285
3332
|
code: "tool_missing_name"
|
|
3286
3333
|
});
|
|
3287
3334
|
}
|
|
3288
3335
|
if (!TOOL_NAME_PATTERN.test(tool.name)) {
|
|
3289
|
-
throw new
|
|
3336
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3290
3337
|
`Custom tool name "${tool.name}" must match /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/`,
|
|
3291
3338
|
{ code: "tool_invalid_name" }
|
|
3292
3339
|
);
|
|
3293
3340
|
}
|
|
3294
3341
|
if (RESERVED_TOOL_NAMES.has(tool.name) || tool.name.startsWith("mcp_")) {
|
|
3295
|
-
throw new
|
|
3342
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3296
3343
|
`Custom tool name "${tool.name}" collides with a reserved SDK tool name`,
|
|
3297
3344
|
{ code: "tool_reserved_name" }
|
|
3298
3345
|
);
|
|
@@ -3300,7 +3347,7 @@ function validateToolName(tool) {
|
|
|
3300
3347
|
}
|
|
3301
3348
|
function validateToolDescription(tool) {
|
|
3302
3349
|
if (typeof tool.description !== "string" || tool.description.length === 0) {
|
|
3303
|
-
throw new
|
|
3350
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a non-empty description`, {
|
|
3304
3351
|
code: "tool_missing_description"
|
|
3305
3352
|
});
|
|
3306
3353
|
}
|
|
@@ -3308,12 +3355,12 @@ function validateToolDescription(tool) {
|
|
|
3308
3355
|
function validateToolSchema(tool) {
|
|
3309
3356
|
const schema = tool.inputSchema;
|
|
3310
3357
|
if (schema === null || schema === void 0 || typeof schema !== "object") {
|
|
3311
|
-
throw new
|
|
3358
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires an inputSchema object`, {
|
|
3312
3359
|
code: "tool_missing_schema"
|
|
3313
3360
|
});
|
|
3314
3361
|
}
|
|
3315
3362
|
if (schema.type !== "object") {
|
|
3316
|
-
throw new
|
|
3363
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3317
3364
|
`Custom tool "${tool.name}" inputSchema must declare \`type: "object"\``,
|
|
3318
3365
|
{ code: "tool_invalid_schema_type" }
|
|
3319
3366
|
);
|
|
@@ -3324,7 +3371,7 @@ function validateMemory(options) {
|
|
|
3324
3371
|
if (memory?.storePath === void 0) return;
|
|
3325
3372
|
const storePath = memory.storePath;
|
|
3326
3373
|
if (storePath.includes("..") || storePath.startsWith("/") || /^[A-Z]:/i.test(storePath)) {
|
|
3327
|
-
throw new
|
|
3374
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3328
3375
|
`Memory storePath must stay inside the workspace; got "${storePath}"`,
|
|
3329
3376
|
{ code: "memory_path_traversal" }
|
|
3330
3377
|
);
|
|
@@ -3346,7 +3393,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3346
3393
|
};
|
|
3347
3394
|
function safeRequire(moduleName) {
|
|
3348
3395
|
try {
|
|
3349
|
-
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)));
|
|
3350
3397
|
return r(moduleName);
|
|
3351
3398
|
} catch {
|
|
3352
3399
|
return void 0;
|
|
@@ -3425,7 +3472,7 @@ var langfuseAdapter = {
|
|
|
3425
3472
|
}
|
|
3426
3473
|
}
|
|
3427
3474
|
if (lf.LangfuseSpanProcessor === void 0) {
|
|
3428
|
-
|
|
3475
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3429
3476
|
"[theokit-sdk] @langfuse/node detected but LangfuseSpanProcessor not found (v2?). Use Langfuse v3+ for auto-instrumentation.\n"
|
|
3430
3477
|
);
|
|
3431
3478
|
return;
|
|
@@ -3453,6 +3500,9 @@ var langsmithAdapter = {
|
|
|
3453
3500
|
|
|
3454
3501
|
// src/internal/telemetry/adapters/posthog.ts
|
|
3455
3502
|
var registeredHere6 = false;
|
|
3503
|
+
function presentEnv(value) {
|
|
3504
|
+
return value !== void 0 && value.trim().length > 0 ? value : void 0;
|
|
3505
|
+
}
|
|
3456
3506
|
var posthogAdapter = {
|
|
3457
3507
|
moduleName: "posthog-node",
|
|
3458
3508
|
displayName: "PostHog",
|
|
@@ -3462,12 +3512,12 @@ var posthogAdapter = {
|
|
|
3462
3512
|
const ph = safeRequire("posthog-node");
|
|
3463
3513
|
const otel = safeRequire("@opentelemetry/api");
|
|
3464
3514
|
if (ph === void 0 || otel === void 0) return;
|
|
3465
|
-
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);
|
|
3466
3516
|
if (typeof key !== "string" || key.length === 0) {
|
|
3467
3517
|
return;
|
|
3468
3518
|
}
|
|
3469
3519
|
const client = new ph.PostHog(key, {
|
|
3470
|
-
host: process.env.POSTHOG_HOST ?? "https://us.i.posthog.com"
|
|
3520
|
+
host: presentEnv(process.env.POSTHOG_HOST) ?? "https://us.i.posthog.com"
|
|
3471
3521
|
});
|
|
3472
3522
|
const provider = otel.trace.getTracerProvider();
|
|
3473
3523
|
if (provider.addSpanProcessor === void 0) return;
|
|
@@ -3554,11 +3604,11 @@ function tryAutoRegisterAdapters(settings) {
|
|
|
3554
3604
|
try {
|
|
3555
3605
|
adapter.register();
|
|
3556
3606
|
registered.add(adapter.moduleName);
|
|
3557
|
-
|
|
3607
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] telemetry: ${adapter.displayName} auto-instrumented.
|
|
3558
3608
|
`);
|
|
3559
3609
|
} catch (cause) {
|
|
3560
3610
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3561
|
-
|
|
3611
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3562
3612
|
`[theokit-sdk] telemetry: ${adapter.displayName} detected but failed to register: ${message}
|
|
3563
3613
|
`
|
|
3564
3614
|
);
|
|
@@ -3571,7 +3621,7 @@ var cachedOtel;
|
|
|
3571
3621
|
function loadOtel() {
|
|
3572
3622
|
if (cachedOtel === void 0) {
|
|
3573
3623
|
try {
|
|
3574
|
-
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)));
|
|
3575
3625
|
const mod = r("@opentelemetry/api");
|
|
3576
3626
|
cachedOtel = mod;
|
|
3577
3627
|
} catch {
|
|
@@ -3614,7 +3664,7 @@ function safe(op, fallback) {
|
|
|
3614
3664
|
if (!warnedOnce) {
|
|
3615
3665
|
warnedOnce = true;
|
|
3616
3666
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3617
|
-
|
|
3667
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3618
3668
|
`[theokit-sdk] telemetry exporter error (suppressed; agent.send continues): ${message}
|
|
3619
3669
|
`
|
|
3620
3670
|
);
|
|
@@ -3628,7 +3678,7 @@ function createTelemetry(settings) {
|
|
|
3628
3678
|
if (otel === null) {
|
|
3629
3679
|
if (!warnedOnce) {
|
|
3630
3680
|
warnedOnce = true;
|
|
3631
|
-
|
|
3681
|
+
chunkNUKRL3I6_cjs.diag(
|
|
3632
3682
|
"[theokit-sdk] telemetry.enabled = true but `@opentelemetry/api` is not installed; telemetry is a no-op.\n"
|
|
3633
3683
|
);
|
|
3634
3684
|
}
|
|
@@ -3722,12 +3772,12 @@ function wrapSpan(span, openSpans) {
|
|
|
3722
3772
|
}
|
|
3723
3773
|
function redactAttrValue(value) {
|
|
3724
3774
|
if (typeof value !== "string") return value;
|
|
3725
|
-
return
|
|
3775
|
+
return chunkJTB5Q42C_cjs.redactSecrets(value);
|
|
3726
3776
|
}
|
|
3727
3777
|
function redactAttrs(attrs) {
|
|
3728
3778
|
const out = {};
|
|
3729
3779
|
for (const [k, v] of Object.entries(attrs)) {
|
|
3730
|
-
out[k] = typeof v === "string" ?
|
|
3780
|
+
out[k] = typeof v === "string" ? chunkJTB5Q42C_cjs.redactSecrets(v) : v;
|
|
3731
3781
|
}
|
|
3732
3782
|
return out;
|
|
3733
3783
|
}
|
|
@@ -3745,10 +3795,11 @@ var ProvidersManagerImpl = class {
|
|
|
3745
3795
|
routes() {
|
|
3746
3796
|
const resolved = [];
|
|
3747
3797
|
const modelProvider = providerFromModel(this.model);
|
|
3798
|
+
const modelId = this.model?.id;
|
|
3748
3799
|
const seen = /* @__PURE__ */ new Set();
|
|
3749
3800
|
if (this.providers?.routes !== void 0) {
|
|
3750
3801
|
for (const route of this.providers.routes) {
|
|
3751
|
-
const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
|
|
3802
|
+
const resolvedRoute = resolveRoute(route, modelProvider, modelId, this.plugins);
|
|
3752
3803
|
if (!seen.has(route.capability)) {
|
|
3753
3804
|
seen.add(route.capability);
|
|
3754
3805
|
resolved.push(resolvedRoute);
|
|
@@ -3764,9 +3815,9 @@ function providerFromModel(model) {
|
|
|
3764
3815
|
if (id.includes(":")) return id.split(":")[0];
|
|
3765
3816
|
return void 0;
|
|
3766
3817
|
}
|
|
3767
|
-
function resolveRoute(route, modelProvider, plugins) {
|
|
3818
|
+
function resolveRoute(route, modelProvider, modelId, plugins) {
|
|
3768
3819
|
if (route.capability === "chat" && modelProvider === route.provider) {
|
|
3769
|
-
const modelName = extractModelName(modelProvider, route);
|
|
3820
|
+
const modelName = extractModelName(modelProvider, modelId, route);
|
|
3770
3821
|
const base = {
|
|
3771
3822
|
capability: route.capability,
|
|
3772
3823
|
provider: route.provider,
|
|
@@ -3788,13 +3839,11 @@ function resolveRoute(route, modelProvider, plugins) {
|
|
|
3788
3839
|
reason: "explicit-route"
|
|
3789
3840
|
};
|
|
3790
3841
|
}
|
|
3791
|
-
function extractModelName(prefix, route) {
|
|
3842
|
+
function extractModelName(prefix, modelId, route) {
|
|
3792
3843
|
if (route.model !== void 0) return route.model;
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
if (provider === "anthropic") return "claude-3-7-sonnet";
|
|
3797
|
-
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;
|
|
3798
3847
|
}
|
|
3799
3848
|
var MAX_MD_FILE_BYTES = 1048576;
|
|
3800
3849
|
async function loadMarkdownEntities(opts) {
|
|
@@ -3809,10 +3858,10 @@ async function loadMarkdownEntities(opts) {
|
|
|
3809
3858
|
const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
|
|
3810
3859
|
if (raw === null) continue;
|
|
3811
3860
|
const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
|
|
3812
|
-
const fields =
|
|
3861
|
+
const fields = chunkIWBGCBR6_cjs.parseSimpleYaml(split.frontmatter);
|
|
3813
3862
|
const parsed = schema.safeParse(fields);
|
|
3814
3863
|
if (!parsed.success) {
|
|
3815
|
-
throw new
|
|
3864
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3816
3865
|
`Invalid frontmatter in ${resolved.source}: ${parsed.error.message}`,
|
|
3817
3866
|
{ code: `${errorCodePrefix}_frontmatter_invalid` }
|
|
3818
3867
|
);
|
|
@@ -3830,13 +3879,13 @@ async function assertFileSizeUnderCap(source, errorCodePrefix) {
|
|
|
3830
3879
|
try {
|
|
3831
3880
|
const info = await promises.stat(source);
|
|
3832
3881
|
if (info.size > MAX_MD_FILE_BYTES) {
|
|
3833
|
-
throw new
|
|
3882
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3834
3883
|
`Config file ${source} exceeds 1 MB size limit (${info.size} bytes). Reduce the file or split into multiple entities.`,
|
|
3835
3884
|
{ code: `${errorCodePrefix}_file_too_large` }
|
|
3836
3885
|
);
|
|
3837
3886
|
}
|
|
3838
3887
|
} catch (cause) {
|
|
3839
|
-
if (cause instanceof
|
|
3888
|
+
if (cause instanceof chunkK3FW2XZD_cjs.ConfigurationError) throw cause;
|
|
3840
3889
|
}
|
|
3841
3890
|
}
|
|
3842
3891
|
async function readDirSafe(dir, errorCodePrefix) {
|
|
@@ -3845,7 +3894,7 @@ async function readDirSafe(dir, errorCodePrefix) {
|
|
|
3845
3894
|
} catch (cause) {
|
|
3846
3895
|
const code = cause.code;
|
|
3847
3896
|
if (code === "ENOENT") return null;
|
|
3848
|
-
throw new
|
|
3897
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Failed to read ${dir}`, {
|
|
3849
3898
|
code: `${errorCodePrefix}_dir_read_error`,
|
|
3850
3899
|
cause
|
|
3851
3900
|
});
|
|
@@ -3862,7 +3911,7 @@ function resolveEntryPath(entry, pattern, dir) {
|
|
|
3862
3911
|
function splitFrontmatter(raw, source, errorCodePrefix) {
|
|
3863
3912
|
const match = /^---\s*\n([\s\S]*?)\n---\s*(?:\n|$)/.exec(raw);
|
|
3864
3913
|
if (match === null) {
|
|
3865
|
-
throw new
|
|
3914
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
3866
3915
|
`Missing or malformed frontmatter in ${source} (expected \`---\` delimited block at file head)`,
|
|
3867
3916
|
{ code: `${errorCodePrefix}_missing_frontmatter` }
|
|
3868
3917
|
);
|
|
@@ -3891,7 +3940,7 @@ function applyAggregateCap(sources, maxTotal) {
|
|
|
3891
3940
|
}
|
|
3892
3941
|
const remaining = maxTotal - totalBytes;
|
|
3893
3942
|
if (remaining > 0) {
|
|
3894
|
-
const { finalContent } =
|
|
3943
|
+
const { finalContent } = chunkQ47R5E2X_cjs.truncateWithMarker(s.content, remaining);
|
|
3895
3944
|
kept.push({ ...s, content: finalContent, truncated: true });
|
|
3896
3945
|
totalBytes = maxTotal;
|
|
3897
3946
|
} else {
|
|
@@ -3965,9 +4014,9 @@ var FileContextManager = class {
|
|
|
3965
4014
|
this.lastScope = [...touchedFiles];
|
|
3966
4015
|
const config = await loadContextConfig(this.cwd);
|
|
3967
4016
|
const legacy = await loadSources(config, this.cwd);
|
|
3968
|
-
const maxBytesPerFile = this.settings.maxBytesPerFile ??
|
|
4017
|
+
const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkQ47R5E2X_cjs.DEFAULT_MAX_BYTES_PER_FILE;
|
|
3969
4018
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
3970
|
-
const discovered = await
|
|
4019
|
+
const discovered = await chunkQ47R5E2X_cjs.runDiscovery({
|
|
3971
4020
|
cwd: this.cwd,
|
|
3972
4021
|
maxBytesPerFile,
|
|
3973
4022
|
skipLegacyTheokitContext: true,
|
|
@@ -4036,7 +4085,7 @@ async function loadContextConfig(cwd) {
|
|
|
4036
4085
|
});
|
|
4037
4086
|
if (mdEntities.length > 0) {
|
|
4038
4087
|
if (fs.existsSync(jsonPath)) {
|
|
4039
|
-
|
|
4088
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4040
4089
|
"context-both-present",
|
|
4041
4090
|
"[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
|
|
4042
4091
|
);
|
|
@@ -4046,7 +4095,7 @@ async function loadContextConfig(cwd) {
|
|
|
4046
4095
|
};
|
|
4047
4096
|
}
|
|
4048
4097
|
if (!fs.existsSync(jsonPath)) return { sources: [] };
|
|
4049
|
-
|
|
4098
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4050
4099
|
"context-json-deprecated",
|
|
4051
4100
|
"[theokit-sdk] .theokit/context.json is deprecated; migrate to .theokit/context/<name>.md via theokit-migrate-config"
|
|
4052
4101
|
);
|
|
@@ -4054,7 +4103,7 @@ async function loadContextConfig(cwd) {
|
|
|
4054
4103
|
try {
|
|
4055
4104
|
raw = await promises.readFile(jsonPath, "utf8");
|
|
4056
4105
|
} catch (cause) {
|
|
4057
|
-
throw new
|
|
4106
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Failed to read context config: ${jsonPath}`, {
|
|
4058
4107
|
code: "context_read_error",
|
|
4059
4108
|
cause
|
|
4060
4109
|
});
|
|
@@ -4066,13 +4115,13 @@ function parseConfig(raw, configPath) {
|
|
|
4066
4115
|
try {
|
|
4067
4116
|
parsed = JSON.parse(raw);
|
|
4068
4117
|
} catch (cause) {
|
|
4069
|
-
throw new
|
|
4118
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Invalid JSON in context config: ${configPath}`, {
|
|
4070
4119
|
code: "context_json_invalid",
|
|
4071
4120
|
cause
|
|
4072
4121
|
});
|
|
4073
4122
|
}
|
|
4074
4123
|
if (!parsed || typeof parsed !== "object") {
|
|
4075
|
-
throw new
|
|
4124
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Context config must be an object: ${configPath}`, {
|
|
4076
4125
|
code: "context_config_shape"
|
|
4077
4126
|
});
|
|
4078
4127
|
}
|
|
@@ -4087,7 +4136,7 @@ function parseConfig(raw, configPath) {
|
|
|
4087
4136
|
}
|
|
4088
4137
|
function readSources(sourcesRaw, configPath) {
|
|
4089
4138
|
if (!Array.isArray(sourcesRaw)) {
|
|
4090
|
-
throw new
|
|
4139
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Context config sources must be an array: ${configPath}`, {
|
|
4091
4140
|
code: "context_sources_shape"
|
|
4092
4141
|
});
|
|
4093
4142
|
}
|
|
@@ -4112,7 +4161,6 @@ async function loadSources(config, cwd) {
|
|
|
4112
4161
|
continue;
|
|
4113
4162
|
}
|
|
4114
4163
|
try {
|
|
4115
|
-
await promises.stat(absolute);
|
|
4116
4164
|
const content = await promises.readFile(absolute, "utf8");
|
|
4117
4165
|
const tokens = tokenizeContent(content);
|
|
4118
4166
|
results.push({ ...source, status: "included", tokens });
|
|
@@ -4185,7 +4233,7 @@ var PluginsManager = class {
|
|
|
4185
4233
|
async refresh() {
|
|
4186
4234
|
this.plugins = [];
|
|
4187
4235
|
const pluginsRoot = path.join(this.cwd, ".theokit", "plugins");
|
|
4188
|
-
const entries = await
|
|
4236
|
+
const entries = await chunkIWBGCBR6_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
|
|
4189
4237
|
for (const entry of entries) {
|
|
4190
4238
|
if (!entry.isDirectory()) continue;
|
|
4191
4239
|
const folderName = entry.name;
|
|
@@ -4193,13 +4241,13 @@ var PluginsManager = class {
|
|
|
4193
4241
|
const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
|
|
4194
4242
|
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
|
|
4195
4243
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4196
|
-
|
|
4244
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4197
4245
|
`plugin-${folderName}-both`,
|
|
4198
4246
|
`[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
|
|
4199
4247
|
);
|
|
4200
4248
|
}
|
|
4201
4249
|
if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4202
|
-
|
|
4250
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
4203
4251
|
"plugin-json-deprecated",
|
|
4204
4252
|
"[theokit-sdk] plugin.json manifests are deprecated; migrate to PLUGIN.md via theokit-migrate-config"
|
|
4205
4253
|
);
|
|
@@ -4217,20 +4265,35 @@ var PluginsManager = class {
|
|
|
4217
4265
|
const entry = metadata.entry;
|
|
4218
4266
|
if (entry === void 0) return;
|
|
4219
4267
|
const pluginRoot = path.join(this.cwd, ".theokit", "plugins", folderName);
|
|
4220
|
-
const entryPath =
|
|
4268
|
+
const entryPath = chunkR3UPQFKK_cjs.safePathJoin(pluginRoot, entry);
|
|
4221
4269
|
try {
|
|
4222
4270
|
await promises.readFile(entryPath, "utf8");
|
|
4223
4271
|
} catch (cause) {
|
|
4224
|
-
throw new
|
|
4272
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${metadata.name} entry file is missing: ${entry}`, {
|
|
4225
4273
|
code: "plugin_entry_missing",
|
|
4226
4274
|
cause
|
|
4227
4275
|
});
|
|
4228
4276
|
}
|
|
4229
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
|
+
*/
|
|
4230
4293
|
assertCloudRules() {
|
|
4231
4294
|
if (!this.cloud) return;
|
|
4232
4295
|
if (this.localPaths !== void 0 && this.localPaths.length > 0) {
|
|
4233
|
-
throw new
|
|
4296
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
4234
4297
|
"Cloud agents reject local plugin paths \u2014 plugins must come from committed repo files",
|
|
4235
4298
|
{ code: "cloud_plugin_path_rejected" }
|
|
4236
4299
|
);
|
|
@@ -4242,7 +4305,7 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4242
4305
|
try {
|
|
4243
4306
|
raw = await promises.readFile(manifestPath, "utf8");
|
|
4244
4307
|
} catch (cause) {
|
|
4245
|
-
throw new
|
|
4308
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} is missing plugin.json`, {
|
|
4246
4309
|
code: "plugin_missing_manifest",
|
|
4247
4310
|
cause
|
|
4248
4311
|
});
|
|
@@ -4251,13 +4314,13 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4251
4314
|
try {
|
|
4252
4315
|
parsed = JSON.parse(raw);
|
|
4253
4316
|
} catch (cause) {
|
|
4254
|
-
throw new
|
|
4317
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} manifest is invalid JSON`, {
|
|
4255
4318
|
code: "plugin_manifest_invalid",
|
|
4256
4319
|
cause
|
|
4257
4320
|
});
|
|
4258
4321
|
}
|
|
4259
4322
|
if (!parsed || typeof parsed !== "object") {
|
|
4260
|
-
throw new
|
|
4323
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} manifest must be an object`, {
|
|
4261
4324
|
code: "plugin_manifest_shape"
|
|
4262
4325
|
});
|
|
4263
4326
|
}
|
|
@@ -4276,7 +4339,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4276
4339
|
try {
|
|
4277
4340
|
raw = await promises.readFile(mdPath, "utf8");
|
|
4278
4341
|
} catch (cause) {
|
|
4279
|
-
throw new
|
|
4342
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} is missing PLUGIN.md`, {
|
|
4280
4343
|
code: "plugin_missing_manifest",
|
|
4281
4344
|
cause
|
|
4282
4345
|
});
|
|
@@ -4291,7 +4354,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4291
4354
|
});
|
|
4292
4355
|
const entity = entities.find((e) => e.slug === "PLUGIN");
|
|
4293
4356
|
if (entity === void 0) {
|
|
4294
|
-
throw new
|
|
4357
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`Plugin ${folderName} PLUGIN.md not parseable`, {
|
|
4295
4358
|
code: "plugin_missing_manifest"
|
|
4296
4359
|
});
|
|
4297
4360
|
}
|
|
@@ -4565,7 +4628,7 @@ function assertValidThresholds(soft, hard) {
|
|
|
4565
4628
|
["hardThreshold", hard]
|
|
4566
4629
|
]) {
|
|
4567
4630
|
if (!Number.isInteger(value) || value < 1) {
|
|
4568
|
-
throw new
|
|
4631
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
4569
4632
|
`doomLoop.${label} must be a positive integer (received ${value}).`,
|
|
4570
4633
|
{ code: "invalid_doom_loop_threshold" }
|
|
4571
4634
|
);
|
|
@@ -4874,13 +4937,19 @@ async function initLoopContext(inputs) {
|
|
|
4874
4937
|
}
|
|
4875
4938
|
async function safeListTools(client, serverName, sink) {
|
|
4876
4939
|
try {
|
|
4877
|
-
|
|
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;
|
|
4878
4947
|
} catch (cause) {
|
|
4879
4948
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
4880
4949
|
const server = serverName ?? "unknown";
|
|
4881
|
-
|
|
4950
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] mcp listTools failed (server=${server}): ${message}
|
|
4882
4951
|
`);
|
|
4883
|
-
|
|
4952
|
+
chunkNGESVVJN_cjs.emitRunEvent(sink, { type: "mcp_server_failed", serverName: server, message });
|
|
4884
4953
|
return [];
|
|
4885
4954
|
}
|
|
4886
4955
|
}
|
|
@@ -4948,7 +5017,7 @@ function emitLlmMetrics(inputs, result, startAt) {
|
|
|
4948
5017
|
inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.LLM_USAGE_MISSING, 1, {
|
|
4949
5018
|
provider: inputs.llm.name
|
|
4950
5019
|
});
|
|
4951
|
-
|
|
5020
|
+
chunkNUKRL3I6_cjs.diag(
|
|
4952
5021
|
`[theokit-sdk] llm usage missing from ${inputs.llm.name} finish \u2014 budget may undercount
|
|
4953
5022
|
`
|
|
4954
5023
|
);
|
|
@@ -5026,13 +5095,12 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
5026
5095
|
};
|
|
5027
5096
|
}
|
|
5028
5097
|
async function collectLlmEvents(generator, inputs, ctx) {
|
|
5029
|
-
let accumulatedText = "";
|
|
5030
5098
|
let errored = false;
|
|
5031
5099
|
let finishValue;
|
|
5032
5100
|
let thinking;
|
|
5101
|
+
const partial = { text: "" };
|
|
5033
5102
|
try {
|
|
5034
|
-
const result = await runCollectorLoop(generator, inputs, ctx);
|
|
5035
|
-
accumulatedText = result.accumulatedText;
|
|
5103
|
+
const result = await runCollectorLoop(generator, inputs, ctx, partial);
|
|
5036
5104
|
errored = result.errored;
|
|
5037
5105
|
finishValue = result.finishValue;
|
|
5038
5106
|
thinking = result.thinking;
|
|
@@ -5042,10 +5110,12 @@ async function collectLlmEvents(generator, inputs, ctx) {
|
|
|
5042
5110
|
ctx.events.push(buildAssistantEvent(inputs, "[aborted]"));
|
|
5043
5111
|
} else {
|
|
5044
5112
|
registerLoopError(ctx, cause);
|
|
5045
|
-
ctx.finalText =
|
|
5113
|
+
ctx.finalText = partial.text;
|
|
5114
|
+
if (partial.text !== "") ctx.events.push(buildAssistantEvent(inputs, partial.text));
|
|
5046
5115
|
}
|
|
5047
5116
|
errored = true;
|
|
5048
5117
|
}
|
|
5118
|
+
const accumulatedText = partial.text;
|
|
5049
5119
|
return {
|
|
5050
5120
|
accumulatedText,
|
|
5051
5121
|
errored,
|
|
@@ -5076,8 +5146,7 @@ async function consumeStreamEvent(inputs, reasoning, event) {
|
|
|
5076
5146
|
}
|
|
5077
5147
|
return "";
|
|
5078
5148
|
}
|
|
5079
|
-
async function runCollectorLoop(generator, inputs, ctx) {
|
|
5080
|
-
let accumulatedText = "";
|
|
5149
|
+
async function runCollectorLoop(generator, inputs, ctx, partial) {
|
|
5081
5150
|
const reasoning = { text: "", startedAt: void 0, signature: void 0 };
|
|
5082
5151
|
let errored = false;
|
|
5083
5152
|
let finishValue;
|
|
@@ -5091,16 +5160,16 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
5091
5160
|
}
|
|
5092
5161
|
if (next.value.type === "error") {
|
|
5093
5162
|
registerLoopError(ctx, next.value);
|
|
5094
|
-
ctx.finalText =
|
|
5163
|
+
ctx.finalText = partial.text;
|
|
5095
5164
|
errored = true;
|
|
5096
5165
|
break;
|
|
5097
5166
|
}
|
|
5098
|
-
|
|
5167
|
+
partial.text += await consumeStreamEvent(inputs, reasoning, next.value);
|
|
5099
5168
|
}
|
|
5100
5169
|
} finally {
|
|
5101
5170
|
thinking = await finalizeReasoning(inputs, ctx, reasoning);
|
|
5102
5171
|
}
|
|
5103
|
-
return {
|
|
5172
|
+
return { errored, finishValue, ...thinking !== void 0 ? { thinking } : {} };
|
|
5104
5173
|
}
|
|
5105
5174
|
async function consumeReasoningDelta(inputs, reasoning, delta) {
|
|
5106
5175
|
if (delta.signature !== void 0) reasoning.signature = delta.signature;
|
|
@@ -5244,7 +5313,7 @@ function coerceArgsToSchema(args, schema) {
|
|
|
5244
5313
|
}
|
|
5245
5314
|
|
|
5246
5315
|
// src/tool-error.ts
|
|
5247
|
-
var ToolError = class extends
|
|
5316
|
+
var ToolError = class extends chunkK3FW2XZD_cjs.TheokitAgentError {
|
|
5248
5317
|
name = "ToolError";
|
|
5249
5318
|
/** The error content surfaced to the model: a string, or text/image blocks. */
|
|
5250
5319
|
content;
|
|
@@ -5438,7 +5507,7 @@ function raceToolExecution(exec, opts) {
|
|
|
5438
5507
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
5439
5508
|
async function dispatchTools(inputs, tools, toolCalls, events, parentSpan) {
|
|
5440
5509
|
const maxConcurrent = inputs.maxConcurrentTools ?? 4;
|
|
5441
|
-
return
|
|
5510
|
+
return chunkILCGLTSA_cjs.mapWithConcurrency(
|
|
5442
5511
|
toolCalls,
|
|
5443
5512
|
maxConcurrent,
|
|
5444
5513
|
(call) => dispatchSingleCall(inputs, tools, call, events, parentSpan)
|
|
@@ -5466,7 +5535,7 @@ async function dispatchSingleCall(inputs, tools, call, events, parentSpan) {
|
|
|
5466
5535
|
toolSpan?.end();
|
|
5467
5536
|
return fileVeto;
|
|
5468
5537
|
}
|
|
5469
|
-
|
|
5538
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5470
5539
|
type: "tool_progress",
|
|
5471
5540
|
toolName: workingCall.name,
|
|
5472
5541
|
toolCallId: callId
|
|
@@ -5497,7 +5566,7 @@ function applyRepairAndExtractCall(tools, call) {
|
|
|
5497
5566
|
function vetoFromForkWhitelist(inputs, call, callId, events) {
|
|
5498
5567
|
const whitelistDecision = chunkVJ26EKGJ_cjs.checkToolWhitelist(call.name);
|
|
5499
5568
|
if (whitelistDecision.allowed) return void 0;
|
|
5500
|
-
|
|
5569
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5501
5570
|
type: "permission_denied",
|
|
5502
5571
|
toolName: call.name,
|
|
5503
5572
|
toolCallId: callId,
|
|
@@ -5542,7 +5611,7 @@ async function vetoFromPluginPreHook(inputs, call, callId, events) {
|
|
|
5542
5611
|
...inputs.permissionMode !== void 0 ? { permissionMode: inputs.permissionMode } : {}
|
|
5543
5612
|
});
|
|
5544
5613
|
if (pluginVeto === void 0) return void 0;
|
|
5545
|
-
|
|
5614
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5546
5615
|
type: "permission_denied",
|
|
5547
5616
|
toolName: call.name,
|
|
5548
5617
|
toolCallId: callId,
|
|
@@ -5571,7 +5640,7 @@ async function vetoFromFileHookPreDecision(inputs, call, callId, events) {
|
|
|
5571
5640
|
runId: inputs.runId
|
|
5572
5641
|
});
|
|
5573
5642
|
if (!preDecision.blocked) return void 0;
|
|
5574
|
-
|
|
5643
|
+
chunkNGESVVJN_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5575
5644
|
type: "permission_denied",
|
|
5576
5645
|
toolName: call.name,
|
|
5577
5646
|
toolCallId: callId,
|
|
@@ -5672,7 +5741,7 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
|
|
|
5672
5741
|
agentId: inputs.agentId,
|
|
5673
5742
|
runId: inputs.runId
|
|
5674
5743
|
}).catch((err) => {
|
|
5675
|
-
|
|
5744
|
+
chunkNUKRL3I6_cjs.diag(
|
|
5676
5745
|
`[theokit-sdk] postToolUse hook error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5677
5746
|
`
|
|
5678
5747
|
);
|
|
@@ -5691,7 +5760,7 @@ async function emitToolLifecycleDelta(inputs, update) {
|
|
|
5691
5760
|
try {
|
|
5692
5761
|
await inputs.onDelta({ update });
|
|
5693
5762
|
} catch (err) {
|
|
5694
|
-
|
|
5763
|
+
chunkNUKRL3I6_cjs.diag(
|
|
5695
5764
|
`[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5696
5765
|
`
|
|
5697
5766
|
);
|
|
@@ -5703,7 +5772,7 @@ async function safeEmitToolHook(callback, event) {
|
|
|
5703
5772
|
await callback(event);
|
|
5704
5773
|
} catch (cause) {
|
|
5705
5774
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
5706
|
-
|
|
5775
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] tool lifecycle hook threw: ${msg}
|
|
5707
5776
|
`);
|
|
5708
5777
|
}
|
|
5709
5778
|
}
|
|
@@ -5770,7 +5839,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
5770
5839
|
(p) => (
|
|
5771
5840
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
5772
5841
|
// structured content); image blocks pass through untouched.
|
|
5773
|
-
p.type === "tool_result" ? { ...p, content:
|
|
5842
|
+
p.type === "tool_result" ? { ...p, content: chunkUNDROG5N_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
5774
5843
|
)
|
|
5775
5844
|
);
|
|
5776
5845
|
}
|
|
@@ -5922,7 +5991,7 @@ function stripDateSuffix(model) {
|
|
|
5922
5991
|
return model.replace(/-\d{4}-?\d{2}-?\d{2}$/, "");
|
|
5923
5992
|
}
|
|
5924
5993
|
function normalizeAnthropicDots(model) {
|
|
5925
|
-
return model.replace(/(
|
|
5994
|
+
return model.replace(/(?<=\d)\.(?=\d)/g, "-");
|
|
5926
5995
|
}
|
|
5927
5996
|
function stripOpenRouterPrefix(modelId) {
|
|
5928
5997
|
return modelId.startsWith("openrouter/") ? modelId.slice("openrouter/".length) : modelId;
|
|
@@ -5965,7 +6034,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
5965
6034
|
const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
|
|
5966
6035
|
if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
|
|
5967
6036
|
for (const key of candidates) {
|
|
5968
|
-
const info =
|
|
6037
|
+
const info = chunkRM7Y65IG_cjs.getCatalogModelInfo(key);
|
|
5969
6038
|
const cost = info?.cost;
|
|
5970
6039
|
if (cost === void 0) continue;
|
|
5971
6040
|
const [prov, ...modelParts] = key.split("/");
|
|
@@ -5977,7 +6046,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
5977
6046
|
...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
|
|
5978
6047
|
...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
|
|
5979
6048
|
// M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
|
|
5980
|
-
pricingVersion:
|
|
6049
|
+
pricingVersion: chunkRM7Y65IG_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
|
|
5981
6050
|
};
|
|
5982
6051
|
}
|
|
5983
6052
|
return void 0;
|
|
@@ -6103,7 +6172,7 @@ function accumulateUsage(usage, turn) {
|
|
|
6103
6172
|
function computeUsageCost(inputs, usage) {
|
|
6104
6173
|
const modelId = inputs.model.id;
|
|
6105
6174
|
if (modelId === void 0 || modelId === "auto") return void 0;
|
|
6106
|
-
const parsed =
|
|
6175
|
+
const parsed = chunk3EE6LVWT_cjs.parseModelId(modelId);
|
|
6107
6176
|
const provider = parsed.provider ?? inputs.llm.name;
|
|
6108
6177
|
const model = parsed.provider !== void 0 ? parsed.name : modelId;
|
|
6109
6178
|
return computeCost({ provider, model, usage });
|
|
@@ -6175,6 +6244,12 @@ async function runAgentLoop(inputs) {
|
|
|
6175
6244
|
}
|
|
6176
6245
|
if (budget.shouldContinue() === false && ctx.finalStatus === "finished" && ctx.finalText === "") {
|
|
6177
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
|
+
}
|
|
6178
6253
|
}
|
|
6179
6254
|
sendSpan?.setAttribute("status", ctx.finalStatus);
|
|
6180
6255
|
if (ctx.stoppedByDoomLoop === true) sendSpan?.setAttribute("stoppedByDoomLoop", true);
|
|
@@ -6430,15 +6505,15 @@ var FallbackLlmClient = class {
|
|
|
6430
6505
|
let lastError;
|
|
6431
6506
|
for (const client of this.clients) {
|
|
6432
6507
|
if (signal.aborted) throw abortError(signal);
|
|
6433
|
-
const attempt = await
|
|
6508
|
+
const attempt = await chunkUNDROG5N_cjs.tryFirstEvent(client, request, signal, true);
|
|
6434
6509
|
if (attempt.kind === "handshake_error") {
|
|
6435
6510
|
lastError = attempt.error;
|
|
6436
6511
|
continue;
|
|
6437
6512
|
}
|
|
6438
|
-
return yield*
|
|
6513
|
+
return yield* chunkUNDROG5N_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6439
6514
|
}
|
|
6440
6515
|
if (lastError !== void 0) throw lastError;
|
|
6441
|
-
throw new
|
|
6516
|
+
throw new chunkK3FW2XZD_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
6442
6517
|
code: "fallback_empty_chain"
|
|
6443
6518
|
});
|
|
6444
6519
|
}
|
|
@@ -6461,7 +6536,7 @@ function reconnectDelay(attempt) {
|
|
|
6461
6536
|
return ms <= 0 ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, ms));
|
|
6462
6537
|
}
|
|
6463
6538
|
function mcpTimeoutError(name, timeoutMs) {
|
|
6464
|
-
return new
|
|
6539
|
+
return new chunkK3FW2XZD_cjs.NetworkError(`MCP ${name} request timed out after ${timeoutMs}ms`, {
|
|
6465
6540
|
code: "mcp_timeout"
|
|
6466
6541
|
});
|
|
6467
6542
|
}
|
|
@@ -6536,7 +6611,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6536
6611
|
cwd: resolvedCwd,
|
|
6537
6612
|
// #54 (F-H1) — a third-party MCP server binary must not inherit host
|
|
6538
6613
|
// secrets. Scrub secret-like vars by default; `config.env` still wins.
|
|
6539
|
-
env:
|
|
6614
|
+
env: chunk2ZPEDVLM_cjs.resolveChildEnv({ policy: this.config.envPolicy, overrides: this.config.env })
|
|
6540
6615
|
});
|
|
6541
6616
|
this.child = child;
|
|
6542
6617
|
child.stdout.on("data", (chunk) => this.consume(chunk));
|
|
@@ -6544,7 +6619,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6544
6619
|
child.stdin.on("error", () => void 0);
|
|
6545
6620
|
child.on("error", () => {
|
|
6546
6621
|
this.rejectAllPending(
|
|
6547
|
-
new
|
|
6622
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} process crashed`, { code: "mcp_crashed" })
|
|
6548
6623
|
);
|
|
6549
6624
|
});
|
|
6550
6625
|
child.on("exit", () => {
|
|
@@ -6552,7 +6627,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6552
6627
|
this.child = void 0;
|
|
6553
6628
|
this.dropped = true;
|
|
6554
6629
|
this.rejectAllPending(
|
|
6555
|
-
new
|
|
6630
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6556
6631
|
);
|
|
6557
6632
|
});
|
|
6558
6633
|
}
|
|
@@ -6580,7 +6655,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6580
6655
|
if (this.child !== void 0) return Promise.resolve();
|
|
6581
6656
|
if (!this.dropped) {
|
|
6582
6657
|
return Promise.reject(
|
|
6583
|
-
new
|
|
6658
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6584
6659
|
);
|
|
6585
6660
|
}
|
|
6586
6661
|
this.reconnectPromise ??= this.reconnect().finally(() => {
|
|
@@ -6601,13 +6676,13 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6601
6676
|
lastErr = err;
|
|
6602
6677
|
}
|
|
6603
6678
|
}
|
|
6604
|
-
throw new
|
|
6679
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} reconnect exhausted`, {
|
|
6605
6680
|
code: "mcp_disconnected",
|
|
6606
6681
|
...lastErr instanceof Error ? { cause: lastErr } : {}
|
|
6607
6682
|
});
|
|
6608
6683
|
}
|
|
6609
6684
|
async close() {
|
|
6610
|
-
this.rejectAllPending(new
|
|
6685
|
+
this.rejectAllPending(new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
|
|
6611
6686
|
const child = this.child;
|
|
6612
6687
|
this.child = void 0;
|
|
6613
6688
|
this.dropped = false;
|
|
@@ -6626,7 +6701,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6626
6701
|
if (this.buffer.length > MAX_STDIO_BUFFER_BYTES) {
|
|
6627
6702
|
this.buffer = "";
|
|
6628
6703
|
this.rejectAllPending(
|
|
6629
|
-
new
|
|
6704
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} exceeded stdout buffer limit`, {
|
|
6630
6705
|
code: "mcp_buffer_overflow"
|
|
6631
6706
|
})
|
|
6632
6707
|
);
|
|
@@ -6661,7 +6736,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6661
6736
|
if (child !== void 0) return this.send(child, method, params);
|
|
6662
6737
|
if (this.dropped) return this.reconnectAndRequest(method, params);
|
|
6663
6738
|
return Promise.reject(
|
|
6664
|
-
new
|
|
6739
|
+
new chunkK3FW2XZD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6665
6740
|
);
|
|
6666
6741
|
}
|
|
6667
6742
|
/** M2 #59 — reconnect a dropped client, then send. Separate async path so the
|
|
@@ -6670,7 +6745,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6670
6745
|
await this.ensureConnected();
|
|
6671
6746
|
const child = this.child;
|
|
6672
6747
|
if (child === void 0) {
|
|
6673
|
-
throw new
|
|
6748
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" });
|
|
6674
6749
|
}
|
|
6675
6750
|
return this.send(child, method, params);
|
|
6676
6751
|
}
|
|
@@ -6687,7 +6762,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6687
6762
|
this.child = void 0;
|
|
6688
6763
|
this.dropped = true;
|
|
6689
6764
|
this.rejectAllPending(
|
|
6690
|
-
new
|
|
6765
|
+
new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6691
6766
|
);
|
|
6692
6767
|
}, this.timeoutMs);
|
|
6693
6768
|
this.pending.set(id, { resolve, reject, timer });
|
|
@@ -6738,12 +6813,6 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6738
6813
|
...this.config.headers ?? {}
|
|
6739
6814
|
};
|
|
6740
6815
|
}
|
|
6741
|
-
/**
|
|
6742
|
-
* Capture the session on the FIRST response that carries it (the `initialize`).
|
|
6743
|
-
*
|
|
6744
|
-
* Never overwritten by a later one: a server that re-issues mid-session would otherwise split
|
|
6745
|
-
* the session in two, and the second half would not see the first half's state.
|
|
6746
|
-
*/
|
|
6747
6816
|
/**
|
|
6748
6817
|
* Read one JSON-RPC response, in either encoding the server may choose.
|
|
6749
6818
|
*
|
|
@@ -6765,10 +6834,16 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6765
6834
|
if (payload === "") continue;
|
|
6766
6835
|
return JSON.parse(payload);
|
|
6767
6836
|
}
|
|
6768
|
-
throw new
|
|
6837
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
|
|
6769
6838
|
code: "mcp_http_error"
|
|
6770
6839
|
});
|
|
6771
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
|
+
*/
|
|
6772
6847
|
captureSession(response) {
|
|
6773
6848
|
if (this.sessionId !== void 0) return;
|
|
6774
6849
|
const issued = response.headers.get("mcp-session-id");
|
|
@@ -6793,7 +6868,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6793
6868
|
throw cause;
|
|
6794
6869
|
}
|
|
6795
6870
|
if (!response.ok) {
|
|
6796
|
-
throw new
|
|
6871
|
+
throw new chunkK3FW2XZD_cjs.NetworkError(`MCP ${this.name} returned ${response.status}`, {
|
|
6797
6872
|
code: "mcp_http_error"
|
|
6798
6873
|
});
|
|
6799
6874
|
}
|
|
@@ -6809,14 +6884,14 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6809
6884
|
function resolveMcpCwd(configCwd) {
|
|
6810
6885
|
if (configCwd === void 0) return process.cwd();
|
|
6811
6886
|
if (path.isAbsolute(configCwd)) return configCwd;
|
|
6812
|
-
return
|
|
6887
|
+
return chunkR3UPQFKK_cjs.safePathJoin(process.cwd(), configCwd);
|
|
6813
6888
|
}
|
|
6814
6889
|
|
|
6815
6890
|
// src/internal/providers/register-plugin-providers.ts
|
|
6816
6891
|
function registerPluginProviderProfiles(entries) {
|
|
6817
6892
|
let registered2 = 0;
|
|
6818
6893
|
for (const entry of entries) {
|
|
6819
|
-
|
|
6894
|
+
chunkRM7Y65IG_cjs.registerProvider(entry.profile);
|
|
6820
6895
|
registered2 += 1;
|
|
6821
6896
|
}
|
|
6822
6897
|
return registered2;
|
|
@@ -6896,7 +6971,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
|
|
|
6896
6971
|
if (exposedSet.has(name)) continue;
|
|
6897
6972
|
const hint = suggestClosest(name, exposedSet);
|
|
6898
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)`;
|
|
6899
|
-
|
|
6974
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
6900
6975
|
`personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
|
|
6901
6976
|
message
|
|
6902
6977
|
);
|
|
@@ -6938,7 +7013,7 @@ function levenshtein(a, b) {
|
|
|
6938
7013
|
// src/internal/local-agent/real-local-run-tools.ts
|
|
6939
7014
|
function declarativeSubagentTools(agents2, parentTools) {
|
|
6940
7015
|
if (agents2 === void 0 || Object.keys(agents2).length === 0) return [];
|
|
6941
|
-
return
|
|
7016
|
+
return chunk4O5TGQBW_cjs.subAgentToolsFromDefinitions(agents2, parentTools);
|
|
6942
7017
|
}
|
|
6943
7018
|
function resolveInheritedCredentials(agentOptions) {
|
|
6944
7019
|
const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
|
|
@@ -7005,25 +7080,26 @@ function createRealLocalRun(options) {
|
|
|
7005
7080
|
}
|
|
7006
7081
|
var pluginProvidersAnnounced = false;
|
|
7007
7082
|
function resolveRunProvider(options) {
|
|
7008
|
-
|
|
7083
|
+
chunkRM7Y65IG_cjs.registerBuiltins();
|
|
7009
7084
|
const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
|
|
7010
7085
|
const registered2 = registerPluginProviderProfiles(profiles);
|
|
7011
7086
|
if (registered2 > 0 && !pluginProvidersAnnounced) {
|
|
7012
7087
|
pluginProvidersAnnounced = true;
|
|
7013
7088
|
const names = profiles.map((e) => e.profile.name).join(", ");
|
|
7014
|
-
|
|
7089
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] registered ${registered2} plugin provider profile(s): ${names}
|
|
7015
7090
|
`);
|
|
7016
7091
|
}
|
|
7017
|
-
const parsedModel =
|
|
7018
|
-
const modelInferredProvider = parsedModel.provider !== void 0 &&
|
|
7019
|
-
const keyInferredProvider =
|
|
7020
|
-
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);
|
|
7021
7097
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7022
7098
|
return { primary, effectiveModelId };
|
|
7023
7099
|
}
|
|
7024
7100
|
function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
7025
7101
|
if (apiKey === void 0 || apiKey.length === 0) return pools;
|
|
7026
|
-
if (
|
|
7102
|
+
if (chunkUNDROG5N_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
|
|
7027
7103
|
const existing = pools?.[primary];
|
|
7028
7104
|
if (existing !== void 0 && existing.length > 0) return pools;
|
|
7029
7105
|
return { ...pools ?? {}, [primary]: [apiKey] };
|
|
@@ -7031,7 +7107,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
|
7031
7107
|
function buildLoopInputs(options, runId, userText, userImages) {
|
|
7032
7108
|
const maxIterations = options.sendOptions.maxIterations;
|
|
7033
7109
|
if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
|
|
7034
|
-
throw new
|
|
7110
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
7035
7111
|
`SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
|
|
7036
7112
|
{ code: "invalid_max_iterations" }
|
|
7037
7113
|
);
|
|
@@ -7046,14 +7122,16 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7046
7122
|
const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
|
|
7047
7123
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7048
7124
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7049
|
-
const
|
|
7125
|
+
const modelBaseUrl = options.model?.url;
|
|
7126
|
+
const chain = chunkUNDROG5N_cjs.resolveProviderChain({
|
|
7050
7127
|
primary,
|
|
7128
|
+
...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
|
|
7051
7129
|
...fallback !== void 0 ? { fallback } : {},
|
|
7052
7130
|
...apiKeys !== void 0 ? { apiKeys } : {},
|
|
7053
7131
|
...credentialPoolStrategy !== void 0 ? { credentialPoolStrategy } : {},
|
|
7054
7132
|
...extractToolCallsFromContent === true ? { extractToolCallsFromContent: true } : {},
|
|
7055
7133
|
...rateLimitSink !== void 0 ? {
|
|
7056
|
-
onRateLimit: (info) =>
|
|
7134
|
+
onRateLimit: (info) => chunkNGESVVJN_cjs.emitRunEvent(rateLimitSink, { type: "rate_limit", ...info })
|
|
7057
7135
|
} : {}
|
|
7058
7136
|
});
|
|
7059
7137
|
const llm = chain.length === 1 ? chain[0] : new FallbackLlmClient(chain);
|
|
@@ -7235,7 +7313,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7235
7313
|
};
|
|
7236
7314
|
try {
|
|
7237
7315
|
const runLoop = () => inputs.activeTools !== void 0 ? chunkVJ26EKGJ_cjs.withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : runAgentLoop(inputs);
|
|
7238
|
-
const output = await
|
|
7316
|
+
const output = await chunk4O5TGQBW_cjs.withInheritedSubAgentCredentials(this.inheritedCredentials, runLoop);
|
|
7239
7317
|
this.applyAgentLoopOutput(output);
|
|
7240
7318
|
this.transitionTo(output.finalStatus);
|
|
7241
7319
|
} catch (cause) {
|
|
@@ -7328,7 +7406,7 @@ function buildRealRunOptions(args) {
|
|
|
7328
7406
|
};
|
|
7329
7407
|
}
|
|
7330
7408
|
async function createFixtureRunHelper(args) {
|
|
7331
|
-
const sessionMessages =
|
|
7409
|
+
const sessionMessages = chunk5BJV5UPY_cjs.getSessionMessages(args.inputs.agentId);
|
|
7332
7410
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7333
7411
|
return createLocalRun({
|
|
7334
7412
|
agentId: args.inputs.agentId,
|
|
@@ -7346,8 +7424,8 @@ async function createFixtureRunHelper(args) {
|
|
|
7346
7424
|
});
|
|
7347
7425
|
}
|
|
7348
7426
|
async function dispatchLocalRun(args) {
|
|
7349
|
-
const apiKey = resolveApiKey(args.inputs.options.apiKey);
|
|
7350
|
-
if (
|
|
7427
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(args.inputs.options.apiKey);
|
|
7428
|
+
if (chunkUNDROG5N_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7351
7429
|
return createRealLocalRun(
|
|
7352
7430
|
buildRealRunOptions({
|
|
7353
7431
|
inputs: args.inputs,
|
|
@@ -7382,20 +7460,20 @@ async function readProjectMcpServers(cwd) {
|
|
|
7382
7460
|
|
|
7383
7461
|
// src/internal/local-agent/local-agent-invalidate.ts
|
|
7384
7462
|
async function applyDeferredInvalidation(agentId, pending, refresh) {
|
|
7385
|
-
|
|
7463
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] applying deferred cache invalidation (${agentId}): ${pending.reason}
|
|
7386
7464
|
`);
|
|
7387
7465
|
try {
|
|
7388
7466
|
await refresh();
|
|
7389
7467
|
} catch (err) {
|
|
7390
7468
|
const msg = err instanceof Error ? err.message : String(err);
|
|
7391
|
-
|
|
7469
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] invalidateCache reload failed (continuing): ${msg}
|
|
7392
7470
|
`);
|
|
7393
7471
|
}
|
|
7394
7472
|
}
|
|
7395
7473
|
async function invalidateCacheImpl(agentId, reason, options, disposed, dispose, setPending) {
|
|
7396
7474
|
if (disposed) return;
|
|
7397
7475
|
if (options.applyNow === true) {
|
|
7398
|
-
|
|
7476
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] invalidateCache applyNow disposing agent (${agentId}): ${reason}
|
|
7399
7477
|
`);
|
|
7400
7478
|
await dispose();
|
|
7401
7479
|
return;
|
|
@@ -7456,7 +7534,7 @@ var LiveAgentRegistry = class {
|
|
|
7456
7534
|
const existing = this.#agents.get(id);
|
|
7457
7535
|
if (existing !== void 0 && existing.agent !== agent) {
|
|
7458
7536
|
void existing.agent.dispose().catch(() => {
|
|
7459
|
-
|
|
7537
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] dispose during overwrite failed (${id})
|
|
7460
7538
|
`);
|
|
7461
7539
|
});
|
|
7462
7540
|
}
|
|
@@ -7560,7 +7638,7 @@ var LiveAgentRegistry = class {
|
|
|
7560
7638
|
await agent.dispose();
|
|
7561
7639
|
} catch (cause) {
|
|
7562
7640
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7563
|
-
|
|
7641
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] dispose during eviction failed (${id}): ${msg}
|
|
7564
7642
|
`);
|
|
7565
7643
|
}
|
|
7566
7644
|
if (this.#onEvict !== void 0) {
|
|
@@ -7568,7 +7646,7 @@ var LiveAgentRegistry = class {
|
|
|
7568
7646
|
this.#onEvict(id, reason);
|
|
7569
7647
|
} catch (cause) {
|
|
7570
7648
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7571
|
-
|
|
7649
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] onEvict listener threw (${id}): ${msg}
|
|
7572
7650
|
`);
|
|
7573
7651
|
}
|
|
7574
7652
|
}
|
|
@@ -7584,7 +7662,7 @@ async function acquireLeaseIfPossible(store, agentId) {
|
|
|
7584
7662
|
await a.call(store, agentId);
|
|
7585
7663
|
} catch (err) {
|
|
7586
7664
|
if (err instanceof Error && err.name === "SessionBusyError") throw err;
|
|
7587
|
-
|
|
7665
|
+
chunkNUKRL3I6_cjs.diag(
|
|
7588
7666
|
`[theokit-sdk] writer lease unavailable for ${agentId} (${err instanceof Error ? err.message : String(err)}) \u2014 proceeding without single-writer protection
|
|
7589
7667
|
`
|
|
7590
7668
|
);
|
|
@@ -7601,18 +7679,18 @@ async function disposeSessionStore(store) {
|
|
|
7601
7679
|
async function disposeLocalAgentSession(agent) {
|
|
7602
7680
|
liveAgentRegistry.forget(agent.agentId);
|
|
7603
7681
|
agent.lifecycleAbortController.abort();
|
|
7604
|
-
await
|
|
7682
|
+
await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
7605
7683
|
disposeSessionMcpClients(agent.agentId);
|
|
7606
|
-
await
|
|
7684
|
+
await chunk5BJV5UPY_cjs.flushSessionWrites();
|
|
7607
7685
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
7608
7686
|
await disposeSessionStore(agent.sessionStore);
|
|
7609
|
-
|
|
7687
|
+
chunk5BJV5UPY_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
7610
7688
|
}
|
|
7611
7689
|
async function reloadLocalAgent(agent) {
|
|
7612
7690
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
7613
7691
|
if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
|
|
7614
7692
|
if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
|
|
7615
|
-
return await
|
|
7693
|
+
return await chunkHJBMA5MB_cjs.loadSubagents(
|
|
7616
7694
|
agent.workspaceCwd,
|
|
7617
7695
|
agent.settingSourcesIncludeProject,
|
|
7618
7696
|
agent.options.agents
|
|
@@ -7620,12 +7698,12 @@ async function reloadLocalAgent(agent) {
|
|
|
7620
7698
|
}
|
|
7621
7699
|
async function persistActiveMemoryTranscript(cwd, transcript) {
|
|
7622
7700
|
try {
|
|
7623
|
-
const dir = path.join(
|
|
7701
|
+
const dir = path.join(chunk5UOVYM3P_cjs.memoryDir(cwd), "transcripts", "active-memory");
|
|
7624
7702
|
const file = path.join(dir, `${transcript.runId}.json`);
|
|
7625
|
-
await
|
|
7703
|
+
await chunkI6TGFUCO_cjs.atomicWriteJson(file, transcript);
|
|
7626
7704
|
} catch (cause) {
|
|
7627
7705
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7628
|
-
|
|
7706
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] active-memory transcript persist failed: ${message}
|
|
7629
7707
|
`);
|
|
7630
7708
|
}
|
|
7631
7709
|
}
|
|
@@ -7746,7 +7824,7 @@ async function searchOnce(args, cfg, query, started) {
|
|
|
7746
7824
|
return { summary, durationMs: Date.now() - started, status: "ok", hits };
|
|
7747
7825
|
} catch (cause) {
|
|
7748
7826
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7749
|
-
|
|
7827
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] active-memory recall failed: ${message}
|
|
7750
7828
|
`);
|
|
7751
7829
|
return { summary: void 0, durationMs: Date.now() - started, status: "error", hits: [] };
|
|
7752
7830
|
}
|
|
@@ -7866,7 +7944,7 @@ var azureOpenAiMemoryEmbeddingProviderAdapter = {
|
|
|
7866
7944
|
transport: "remote",
|
|
7867
7945
|
authProviderId: "azure-openai",
|
|
7868
7946
|
autoSelectPriority: 25,
|
|
7869
|
-
create: (options) =>
|
|
7947
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7870
7948
|
{
|
|
7871
7949
|
id: "azure-openai",
|
|
7872
7950
|
defaultBaseUrl: "https://your-resource.openai.azure.com",
|
|
@@ -7902,7 +7980,7 @@ var cohereMemoryEmbeddingProviderAdapter = {
|
|
|
7902
7980
|
transport: "remote",
|
|
7903
7981
|
authProviderId: "cohere",
|
|
7904
7982
|
autoSelectPriority: 30,
|
|
7905
|
-
create: (options) =>
|
|
7983
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7906
7984
|
{
|
|
7907
7985
|
id: "cohere",
|
|
7908
7986
|
defaultBaseUrl: "https://api.cohere.com",
|
|
@@ -7948,7 +8026,7 @@ var deepinfraMemoryEmbeddingProviderAdapter = {
|
|
|
7948
8026
|
transport: "remote",
|
|
7949
8027
|
authProviderId: "deepinfra",
|
|
7950
8028
|
autoSelectPriority: 13,
|
|
7951
|
-
create: (options) =>
|
|
8029
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7952
8030
|
{
|
|
7953
8031
|
id: "deepinfra",
|
|
7954
8032
|
defaultBaseUrl: "https://api.deepinfra.com",
|
|
@@ -7974,7 +8052,7 @@ var geminiMemoryEmbeddingProviderAdapter = {
|
|
|
7974
8052
|
transport: "remote",
|
|
7975
8053
|
authProviderId: "gemini",
|
|
7976
8054
|
autoSelectPriority: 30,
|
|
7977
|
-
create: (options) =>
|
|
8055
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
7978
8056
|
{
|
|
7979
8057
|
id: "gemini",
|
|
7980
8058
|
defaultBaseUrl: "https://generativelanguage.googleapis.com",
|
|
@@ -8002,7 +8080,7 @@ var jinaMemoryEmbeddingProviderAdapter = {
|
|
|
8002
8080
|
transport: "remote",
|
|
8003
8081
|
authProviderId: "jina",
|
|
8004
8082
|
autoSelectPriority: 35,
|
|
8005
|
-
create: (options) =>
|
|
8083
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8006
8084
|
{
|
|
8007
8085
|
id: "jina",
|
|
8008
8086
|
defaultBaseUrl: "https://api.jina.ai",
|
|
@@ -8025,7 +8103,7 @@ var mistralMemoryEmbeddingProviderAdapter = {
|
|
|
8025
8103
|
transport: "remote",
|
|
8026
8104
|
authProviderId: "mistral",
|
|
8027
8105
|
autoSelectPriority: 18,
|
|
8028
|
-
create: (options) =>
|
|
8106
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8029
8107
|
{
|
|
8030
8108
|
id: "mistral",
|
|
8031
8109
|
defaultBaseUrl: "https://api.mistral.ai",
|
|
@@ -8067,7 +8145,7 @@ var ollamaMemoryEmbeddingProviderAdapter = {
|
|
|
8067
8145
|
autoSelectPriority: 10,
|
|
8068
8146
|
create: (options) => {
|
|
8069
8147
|
const apiKey = options.apiKey ?? process.env.OLLAMA_API_KEY ?? OLLAMA_LOCAL_SENTINEL_KEY;
|
|
8070
|
-
return
|
|
8148
|
+
return chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8071
8149
|
{
|
|
8072
8150
|
id: "ollama",
|
|
8073
8151
|
defaultBaseUrl: "http://localhost:11434",
|
|
@@ -8094,7 +8172,7 @@ var openAiMemoryEmbeddingProviderAdapter = {
|
|
|
8094
8172
|
transport: "remote",
|
|
8095
8173
|
authProviderId: "openai",
|
|
8096
8174
|
autoSelectPriority: 20,
|
|
8097
|
-
create: (options) =>
|
|
8175
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8098
8176
|
{
|
|
8099
8177
|
id: "openai",
|
|
8100
8178
|
defaultBaseUrl: "https://api.openai.com",
|
|
@@ -8121,7 +8199,7 @@ var openRouterMemoryEmbeddingProviderAdapter = {
|
|
|
8121
8199
|
transport: "remote",
|
|
8122
8200
|
authProviderId: "openrouter",
|
|
8123
8201
|
autoSelectPriority: 15,
|
|
8124
|
-
create: (options) =>
|
|
8202
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8125
8203
|
{
|
|
8126
8204
|
id: "openrouter",
|
|
8127
8205
|
defaultBaseUrl: "https://openrouter.ai/api",
|
|
@@ -8149,7 +8227,7 @@ var voyageMemoryEmbeddingProviderAdapter = {
|
|
|
8149
8227
|
transport: "remote",
|
|
8150
8228
|
authProviderId: "voyage",
|
|
8151
8229
|
autoSelectPriority: 14,
|
|
8152
|
-
create: (options) =>
|
|
8230
|
+
create: (options) => chunkEI2Q7SJ5_cjs.createOpenAiCompatibleRuntime(
|
|
8153
8231
|
{
|
|
8154
8232
|
id: "voyage",
|
|
8155
8233
|
defaultBaseUrl: "https://api.voyageai.com",
|
|
@@ -8250,7 +8328,7 @@ function createMemorySearchTool(opts) {
|
|
|
8250
8328
|
};
|
|
8251
8329
|
}
|
|
8252
8330
|
function createMemoryGetTool(opts) {
|
|
8253
|
-
const memoryRoot = path.resolve(
|
|
8331
|
+
const memoryRoot = path.resolve(chunk5UOVYM3P_cjs.memoryDir(opts.cwd));
|
|
8254
8332
|
return {
|
|
8255
8333
|
name: "memory_get",
|
|
8256
8334
|
description: GET_DESCRIPTION,
|
|
@@ -8261,7 +8339,7 @@ function createMemoryGetTool(opts) {
|
|
|
8261
8339
|
const lines = readNumber(input.lines);
|
|
8262
8340
|
const resolved = path.resolve(memoryRoot, relPath);
|
|
8263
8341
|
if (!isPathInside(memoryRoot, resolved)) {
|
|
8264
|
-
throw new
|
|
8342
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8265
8343
|
`memory_get rejected path that escapes memory root: ${relPath}`,
|
|
8266
8344
|
{ code: "memory_path_escapes_root" }
|
|
8267
8345
|
);
|
|
@@ -8281,7 +8359,7 @@ function readString(value, errorIfMissing, allowUndefined = false) {
|
|
|
8281
8359
|
if (typeof value === "string") return value;
|
|
8282
8360
|
if (allowUndefined && (value === void 0 || value === null)) return "";
|
|
8283
8361
|
if (errorIfMissing !== void 0) {
|
|
8284
|
-
throw new
|
|
8362
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(errorIfMissing, { code: "memory_tool_bad_args" });
|
|
8285
8363
|
}
|
|
8286
8364
|
return "";
|
|
8287
8365
|
}
|
|
@@ -8356,7 +8434,7 @@ var LocalAgentMemory = class {
|
|
|
8356
8434
|
const openOpts = { cwd: this.workspaceCwd };
|
|
8357
8435
|
if (embedding !== void 0) openOpts.embedding = embedding;
|
|
8358
8436
|
if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
|
|
8359
|
-
this.index = await
|
|
8437
|
+
this.index = await chunk5UOVYM3P_cjs.IndexManager.open(openOpts);
|
|
8360
8438
|
await this.index.sync();
|
|
8361
8439
|
this.toolsCache = [
|
|
8362
8440
|
createMemorySearchTool({ index: this.index }),
|
|
@@ -8371,7 +8449,7 @@ var LocalAgentMemory = class {
|
|
|
8371
8449
|
const warned2 = g[sym];
|
|
8372
8450
|
if (!warned2.has(message)) {
|
|
8373
8451
|
warned2.add(message);
|
|
8374
|
-
|
|
8452
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] memory tools unavailable: ${message}
|
|
8375
8453
|
`);
|
|
8376
8454
|
}
|
|
8377
8455
|
return void 0;
|
|
@@ -8380,7 +8458,7 @@ var LocalAgentMemory = class {
|
|
|
8380
8458
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8381
8459
|
const cfg = this.options.memory?.activeRecall;
|
|
8382
8460
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8383
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8461
|
+
if (this.breaker === void 0) this.breaker = new chunkUNDROG5N_cjs.CircuitBreaker();
|
|
8384
8462
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8385
8463
|
const result = await runActiveMemory({
|
|
8386
8464
|
userText,
|
|
@@ -8430,7 +8508,7 @@ var LocalAgentMemory = class {
|
|
|
8430
8508
|
await this.index.sync();
|
|
8431
8509
|
} catch (cause) {
|
|
8432
8510
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8433
|
-
|
|
8511
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] session index sync failed: ${message}
|
|
8434
8512
|
`);
|
|
8435
8513
|
}
|
|
8436
8514
|
}
|
|
@@ -8443,7 +8521,7 @@ var LocalAgentMemory = class {
|
|
|
8443
8521
|
return await adapter.create(cfg.model !== void 0 ? { model: cfg.model } : {});
|
|
8444
8522
|
} catch (cause) {
|
|
8445
8523
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8446
|
-
|
|
8524
|
+
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] memory embedding ${cfg.provider} unavailable: ${message}
|
|
8447
8525
|
`);
|
|
8448
8526
|
return void 0;
|
|
8449
8527
|
}
|
|
@@ -8451,22 +8529,33 @@ var LocalAgentMemory = class {
|
|
|
8451
8529
|
};
|
|
8452
8530
|
|
|
8453
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
|
+
}
|
|
8454
8547
|
function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
8455
8548
|
let resolved;
|
|
8456
8549
|
async function ensure() {
|
|
8457
8550
|
if (resolved !== void 0) return resolved;
|
|
8458
8551
|
const entries = pluginManager.aggregated.memoryProviders;
|
|
8459
|
-
const created =
|
|
8460
|
-
for (const entry of entries) {
|
|
8461
|
-
const instance = await entry.createProvider(workspaceCwd);
|
|
8462
|
-
created.push(instance);
|
|
8463
|
-
}
|
|
8552
|
+
const created = await createAvailableAdapters(entries, workspaceCwd);
|
|
8464
8553
|
for (const adapter of created) {
|
|
8465
8554
|
if (adapter.initialize !== void 0) {
|
|
8466
8555
|
await adapter.initialize();
|
|
8467
8556
|
}
|
|
8468
8557
|
}
|
|
8469
|
-
resolved = { adapters: created, initialized: true };
|
|
8558
|
+
resolved = { adapters: created, initialized: true, registered: entries.length };
|
|
8470
8559
|
return resolved;
|
|
8471
8560
|
}
|
|
8472
8561
|
function mergeContext(partial) {
|
|
@@ -8479,7 +8568,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8479
8568
|
...partial?.metadata !== void 0 ? { metadata: partial.metadata } : defaultContext?.metadata !== void 0 ? { metadata: defaultContext.metadata } : {}
|
|
8480
8569
|
};
|
|
8481
8570
|
if (merged.userId === "") {
|
|
8482
|
-
throw new
|
|
8571
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8483
8572
|
"agent.memory requires a userId \u2014 either set AgentOptions.memoryContext.userId or pass ctx.userId at call time.",
|
|
8484
8573
|
{ code: "memory_context_missing_user_id" }
|
|
8485
8574
|
);
|
|
@@ -8489,8 +8578,8 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8489
8578
|
async function requireAdapters() {
|
|
8490
8579
|
const r = await ensure();
|
|
8491
8580
|
if (r.adapters.length === 0) {
|
|
8492
|
-
throw new
|
|
8493
|
-
"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.`,
|
|
8494
8583
|
{ code: "no_memory_adapter" }
|
|
8495
8584
|
);
|
|
8496
8585
|
}
|
|
@@ -8530,7 +8619,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8530
8619
|
const prefix = id.split(":", 1)[0] ?? "";
|
|
8531
8620
|
const target = adapters.find((a) => a.id === prefix);
|
|
8532
8621
|
if (target === void 0) {
|
|
8533
|
-
throw new
|
|
8622
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8534
8623
|
`No adapter found for MemoryId prefix "${prefix}" (registered: ${adapters.map((a) => a.id).join(", ")}).`,
|
|
8535
8624
|
{ code: "no_memory_adapter" }
|
|
8536
8625
|
);
|
|
@@ -8603,7 +8692,7 @@ function createLocalAgentMemoryProvider(opts) {
|
|
|
8603
8692
|
return { facts: [], systemPromptAdditions: summary };
|
|
8604
8693
|
},
|
|
8605
8694
|
async recordSessionSummary(args) {
|
|
8606
|
-
await
|
|
8695
|
+
await chunk5UOVYM3P_cjs.writeSessionSummary(args);
|
|
8607
8696
|
},
|
|
8608
8697
|
async sync(handle) {
|
|
8609
8698
|
const state = handle[INTERNAL_LAM_KEY];
|
|
@@ -8681,19 +8770,19 @@ var PersonalityRegistry = class _PersonalityRegistry {
|
|
|
8681
8770
|
function addEntity(byName, entity, origin, collisionMap) {
|
|
8682
8771
|
const fm = entity.frontmatter;
|
|
8683
8772
|
if (PersonalityRegistry.isReservedClearSlug(fm.name)) {
|
|
8684
|
-
throw new
|
|
8773
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8685
8774
|
`Personality name "${fm.name}" is reserved (used to clear active preset)`,
|
|
8686
8775
|
{ code: "personality_reserved_name" }
|
|
8687
8776
|
);
|
|
8688
8777
|
}
|
|
8689
8778
|
if (entity.body.trim().length === 0) {
|
|
8690
|
-
throw new
|
|
8779
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8691
8780
|
`Personality "${fm.name}" has empty body (system prompt required)`,
|
|
8692
8781
|
{ code: "personality_empty_body" }
|
|
8693
8782
|
);
|
|
8694
8783
|
}
|
|
8695
8784
|
if (origin === "project" && collisionMap?.has(fm.name)) {
|
|
8696
|
-
|
|
8785
|
+
chunk53CBTBWO_cjs.warnOnce(
|
|
8697
8786
|
`personality-collision-${fm.name}`,
|
|
8698
8787
|
`[theokit-sdk] personality "${fm.name}" overridden by project preset`
|
|
8699
8788
|
);
|
|
@@ -8722,7 +8811,7 @@ async function performPersonalitySwitch(args) {
|
|
|
8722
8811
|
const preset = args.registry.get(args.requestedName);
|
|
8723
8812
|
if (preset === void 0) {
|
|
8724
8813
|
const available = args.registry.all().map((p) => p.name).join(", ") || "(none)";
|
|
8725
|
-
throw new
|
|
8814
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
8726
8815
|
`Personality "${args.requestedName}" not found. Available: ${available}`,
|
|
8727
8816
|
{ code: "personality_not_found" }
|
|
8728
8817
|
);
|
|
@@ -8743,14 +8832,14 @@ async function performPersonalitySwitch(args) {
|
|
|
8743
8832
|
|
|
8744
8833
|
// src/internal/local-agent/local-agent-personality-extensions.ts
|
|
8745
8834
|
function resolveActivePersonalityPreset(args) {
|
|
8746
|
-
const forkCtx =
|
|
8835
|
+
const forkCtx = chunk53CBTBWO_cjs.currentPersonalityContext();
|
|
8747
8836
|
const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
|
|
8748
8837
|
if (slug === void 0) return void 0;
|
|
8749
8838
|
return args.personalityRegistry?.get(slug);
|
|
8750
8839
|
}
|
|
8751
8840
|
async function ensurePersonalityRegistryIfNeeded(args) {
|
|
8752
8841
|
if (args.personalityRegistry !== void 0) return args.personalityRegistry;
|
|
8753
|
-
const forkSlug =
|
|
8842
|
+
const forkSlug = chunk53CBTBWO_cjs.currentPersonalityContext()?.slug;
|
|
8754
8843
|
const ownSlug = args.personalityStore.active(args.agentId);
|
|
8755
8844
|
if (forkSlug === void 0 && ownSlug === void 0) return void 0;
|
|
8756
8845
|
return await PersonalityRegistry.load(args.workspaceCwd);
|
|
@@ -8764,8 +8853,8 @@ ${preset.systemPrompt}`;
|
|
|
8764
8853
|
}
|
|
8765
8854
|
async function localAgentUsePersonality(args) {
|
|
8766
8855
|
if (args.disposed) throw new Error("Agent has been disposed");
|
|
8767
|
-
if (
|
|
8768
|
-
|
|
8856
|
+
if (chunk53CBTBWO_cjs.currentPersonalityContext() !== void 0) {
|
|
8857
|
+
chunk53CBTBWO_cjs.warnPersonalitySwitchInsideFork(args.agentId);
|
|
8769
8858
|
return null;
|
|
8770
8859
|
}
|
|
8771
8860
|
let registry = args.personalityRegistry;
|
|
@@ -8773,7 +8862,7 @@ async function localAgentUsePersonality(args) {
|
|
|
8773
8862
|
registry = await PersonalityRegistry.load(args.workspaceCwd);
|
|
8774
8863
|
args.onRegistryLoaded(registry);
|
|
8775
8864
|
}
|
|
8776
|
-
return
|
|
8865
|
+
return chunkZF2LDKQQ_cjs.withCwdMutex(
|
|
8777
8866
|
`agent-send:${args.agentId}`,
|
|
8778
8867
|
() => performPersonalitySwitch({
|
|
8779
8868
|
agentId: args.agentId,
|
|
@@ -8782,8 +8871,8 @@ async function localAgentUsePersonality(args) {
|
|
|
8782
8871
|
registry,
|
|
8783
8872
|
store: args.personalityStore,
|
|
8784
8873
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
8785
|
-
appendSessionMessage: (msg) =>
|
|
8786
|
-
clearSession: () =>
|
|
8874
|
+
appendSessionMessage: (msg) => chunk5BJV5UPY_cjs.appendSessionMessage(args.agentId, msg),
|
|
8875
|
+
clearSession: () => chunk5BJV5UPY_cjs.clearSession(args.agentId),
|
|
8787
8876
|
opts: args.opts ?? {}
|
|
8788
8877
|
})
|
|
8789
8878
|
);
|
|
@@ -8794,7 +8883,7 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
8794
8883
|
async function* wrap() {
|
|
8795
8884
|
const { runUntilImpl } = await import('./run-until-U2B5FJJI.cjs');
|
|
8796
8885
|
const buildDeps = async () => {
|
|
8797
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
8886
|
+
const { judgeCallImpl } = await import('./judge-call-EGYRC2RE.cjs');
|
|
8798
8887
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
8799
8888
|
const create = getAgentFacade().create;
|
|
8800
8889
|
return {
|
|
@@ -8815,19 +8904,19 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
8815
8904
|
}
|
|
8816
8905
|
function localAgentRunToCompletion(agent, message, options) {
|
|
8817
8906
|
async function run() {
|
|
8818
|
-
const { runToCompletionImpl } = await import('./run-to-completion-
|
|
8907
|
+
const { runToCompletionImpl } = await import('./run-to-completion-X4OWM673.cjs');
|
|
8819
8908
|
return runToCompletionImpl({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
8820
8909
|
}
|
|
8821
8910
|
return run();
|
|
8822
8911
|
}
|
|
8823
8912
|
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
8824
|
-
const { streamToCompletionImpl } = await import('./stream-to-completion-
|
|
8913
|
+
const { streamToCompletionImpl } = await import('./stream-to-completion-SRISU5AB.cjs');
|
|
8825
8914
|
return yield* streamToCompletionImpl({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
8826
8915
|
}
|
|
8827
8916
|
async function localAgentFork(parent, options) {
|
|
8828
8917
|
const { forkAgentImpl } = await import('./fork-agent-Y2IK2RYU.cjs');
|
|
8829
8918
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
8830
|
-
const { withPersonalityContext } = await import('./context-
|
|
8919
|
+
const { withPersonalityContext } = await import('./context-VMIE4BMD.cjs');
|
|
8831
8920
|
const create = getAgentFacade().create;
|
|
8832
8921
|
return withPersonalityContext(
|
|
8833
8922
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
@@ -8887,7 +8976,7 @@ function wrapRunWithCompletionCheck(args) {
|
|
|
8887
8976
|
judgeOpts
|
|
8888
8977
|
);
|
|
8889
8978
|
const complete = !verdict.parseFailed && verdict.verdict === "done";
|
|
8890
|
-
|
|
8979
|
+
chunkNGESVVJN_cjs.emitRunEvent(args.onRunEvent, {
|
|
8891
8980
|
type: "completion_check",
|
|
8892
8981
|
complete,
|
|
8893
8982
|
reason: verdict.reason
|
|
@@ -9034,7 +9123,7 @@ function wrapRunWithOutputProcessors(args) {
|
|
|
9034
9123
|
if (result.status !== "finished" || result.result === void 0) return result;
|
|
9035
9124
|
const res = await runOutputProcessors(args.processors, result.result, args.agentId);
|
|
9036
9125
|
if (res.kind === "ok") return { ...result, result: res.value };
|
|
9037
|
-
|
|
9126
|
+
chunkNGESVVJN_cjs.emitRunEvent(args.onRunEvent, {
|
|
9038
9127
|
type: "tripwire",
|
|
9039
9128
|
reason: res.tripwire.reason,
|
|
9040
9129
|
processorId: res.tripwire.processorId
|
|
@@ -9077,6 +9166,15 @@ ${recalled}
|
|
|
9077
9166
|
${args.userText}`;
|
|
9078
9167
|
return typeof args.original === "string" ? wrapped : { ...args.original, text: wrapped };
|
|
9079
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
|
+
}
|
|
9080
9178
|
function wrapRunWithPostReplyHook(args) {
|
|
9081
9179
|
const handlers = args.pluginManager.hooksFor("post_assistant_reply");
|
|
9082
9180
|
if (handlers.length === 0) return args.run;
|
|
@@ -9088,6 +9186,12 @@ function wrapRunWithPostReplyHook(args) {
|
|
|
9088
9186
|
reply: replyText,
|
|
9089
9187
|
agentId: args.agentId,
|
|
9090
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),
|
|
9091
9195
|
...args.options.memoryContext !== void 0 ? { memoryContext: args.options.memoryContext } : {}
|
|
9092
9196
|
};
|
|
9093
9197
|
void args.pluginManager.runPostAssistantReplyHooks(ctx);
|
|
@@ -9109,7 +9213,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9109
9213
|
}
|
|
9110
9214
|
const res = await runInputProcessors(processors, rawUserText, inputs.agentId);
|
|
9111
9215
|
if (res.kind === "tripwire") {
|
|
9112
|
-
|
|
9216
|
+
chunkNGESVVJN_cjs.emitRunEvent(options.onRunEvent, {
|
|
9113
9217
|
type: "tripwire",
|
|
9114
9218
|
reason: res.tripwire.reason,
|
|
9115
9219
|
processorId: res.tripwire.processorId
|
|
@@ -9126,7 +9230,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9126
9230
|
return { userText: res.value, effectiveMessage };
|
|
9127
9231
|
}
|
|
9128
9232
|
async function executeSendLocked(inputs, message, options) {
|
|
9129
|
-
if (inputs.disposed) throw new
|
|
9233
|
+
if (inputs.disposed) throw new chunkK3FW2XZD_cjs.AgentDisposedError(inputs.agentId);
|
|
9130
9234
|
await consumePending(inputs.agentId, inputs.invalidationPending, inputs.clearInvalidation, inputs.reload);
|
|
9131
9235
|
const sendModel = normalizeModel(options.model);
|
|
9132
9236
|
inputs.applyModelOverride(sendModel);
|
|
@@ -9137,7 +9241,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9137
9241
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9138
9242
|
await inputs.options.onBeforeSend({
|
|
9139
9243
|
conversationId: inputs.agentId,
|
|
9140
|
-
previousMessageCount:
|
|
9244
|
+
previousMessageCount: chunk5BJV5UPY_cjs.getSessionMessages(inputs.agentId).length
|
|
9141
9245
|
});
|
|
9142
9246
|
}
|
|
9143
9247
|
await inputs.runPreHook(userText);
|
|
@@ -9149,8 +9253,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9149
9253
|
userText,
|
|
9150
9254
|
sendOptions: options
|
|
9151
9255
|
});
|
|
9152
|
-
const priorMessages = [...
|
|
9153
|
-
|
|
9256
|
+
const priorMessages = [...chunk5BJV5UPY_cjs.getSessionMessages(inputs.agentId)];
|
|
9257
|
+
chunk5BJV5UPY_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9154
9258
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9155
9259
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
|
|
9156
9260
|
const portPathActive = shouldUsePortMemoryPath();
|
|
@@ -9208,7 +9312,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9208
9312
|
function buildCompletionCheckDeps() {
|
|
9209
9313
|
return {
|
|
9210
9314
|
judge: async (ctx, opts) => {
|
|
9211
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9315
|
+
const { judgeCallImpl } = await import('./judge-call-EGYRC2RE.cjs');
|
|
9212
9316
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9213
9317
|
return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
|
|
9214
9318
|
}
|
|
@@ -9228,7 +9332,7 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
|
|
|
9228
9332
|
promptPreview: userText.slice(0, 120),
|
|
9229
9333
|
...opts.meta ?? {}
|
|
9230
9334
|
};
|
|
9231
|
-
void
|
|
9335
|
+
void chunkNGESVVJN_cjs.submit({
|
|
9232
9336
|
kind: "run",
|
|
9233
9337
|
work: async (ctx) => {
|
|
9234
9338
|
ctx.signal.addEventListener(
|
|
@@ -9260,8 +9364,9 @@ var LocalAgent = class {
|
|
|
9260
9364
|
options;
|
|
9261
9365
|
workspaceCwd;
|
|
9262
9366
|
/**
|
|
9263
|
-
*
|
|
9264
|
-
* `~/.theokit`; set `local.
|
|
9367
|
+
* Directory for the native Claude-shaped session transcript. Default
|
|
9368
|
+
* `~/.theokit`; set `local.sessionDir: "~/.claude"` for Claude Code CLI interop.
|
|
9369
|
+
* (`local.baseDir` is the deprecated name for the same option — #301.)
|
|
9265
9370
|
*/
|
|
9266
9371
|
transcriptBaseDir;
|
|
9267
9372
|
/**
|
|
@@ -9311,8 +9416,8 @@ var LocalAgent = class {
|
|
|
9311
9416
|
this.model = normalizeModel(options.model);
|
|
9312
9417
|
this.options = options;
|
|
9313
9418
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
9314
|
-
this.transcriptBaseDir =
|
|
9315
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
9419
|
+
this.transcriptBaseDir = resolveSessionDir(options.local);
|
|
9420
|
+
this.sessionStore = options.local?.sessionStore ?? new chunkYPJ5NH5N_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
9316
9421
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
9317
9422
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
9318
9423
|
const sub = bootstrapSubmanagers({
|
|
@@ -9355,14 +9460,14 @@ var LocalAgent = class {
|
|
|
9355
9460
|
if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
|
|
9356
9461
|
const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
|
|
9357
9462
|
await this.pluginManagerCode.initialize(codePlugins);
|
|
9358
|
-
this.resolvedSubagents = await
|
|
9463
|
+
this.resolvedSubagents = await chunkHJBMA5MB_cjs.loadSubagents(
|
|
9359
9464
|
this.workspaceCwd,
|
|
9360
9465
|
this.settingSourcesIncludeProject,
|
|
9361
9466
|
this.options.agents
|
|
9362
9467
|
);
|
|
9363
9468
|
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9364
9469
|
try {
|
|
9365
|
-
await
|
|
9470
|
+
await chunk5BJV5UPY_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9366
9471
|
await this.personalityStore.hydrate(this.agentId);
|
|
9367
9472
|
} catch (err) {
|
|
9368
9473
|
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
@@ -9391,7 +9496,7 @@ var LocalAgent = class {
|
|
|
9391
9496
|
...this.model?.id !== void 0 ? { model: this.model.id } : {}
|
|
9392
9497
|
});
|
|
9393
9498
|
return new Promise((resolve, reject) => {
|
|
9394
|
-
void
|
|
9499
|
+
void chunkZF2LDKQQ_cjs.withCwdMutex(
|
|
9395
9500
|
`agent-send:${this.agentId}`,
|
|
9396
9501
|
() => this.runLockedSendCycle(message, options, sendSpan, resolve, reject)
|
|
9397
9502
|
);
|
|
@@ -9511,7 +9616,7 @@ var LocalAgent = class {
|
|
|
9511
9616
|
agentId: this.agentId
|
|
9512
9617
|
});
|
|
9513
9618
|
if (preRun.blocked) {
|
|
9514
|
-
throw new
|
|
9619
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
9515
9620
|
`preRun hook denied execution: ${preRun.reason ?? "unspecified"}`,
|
|
9516
9621
|
{ code: "hook_denied" }
|
|
9517
9622
|
);
|
|
@@ -9592,7 +9697,7 @@ var LocalAgent = class {
|
|
|
9592
9697
|
}
|
|
9593
9698
|
// biome-ignore format: G8 budget — see listArtifacts.
|
|
9594
9699
|
downloadArtifact(_path) {
|
|
9595
|
-
return Promise.reject(new
|
|
9700
|
+
return Promise.reject(new chunkK3FW2XZD_cjs.UnsupportedRunOperationError("Artifacts are not supported for local agents", "downloadArtifact"));
|
|
9596
9701
|
}
|
|
9597
9702
|
// biome-ignore format: G8 budget — delegates to `local-agent-runtime-extensions.ts`; kept 1-line.
|
|
9598
9703
|
runUntil(goal, options) {
|
|
@@ -9614,9 +9719,6 @@ var LocalAgent = class {
|
|
|
9614
9719
|
function resolveCwd(cwd) {
|
|
9615
9720
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|
|
9616
9721
|
}
|
|
9617
|
-
function resolveBaseDir(baseDir) {
|
|
9618
|
-
return baseDir === void 0 ? chunkECPL5RV6_cjs.defaultBaseDir() : chunkECPL5RV6_cjs.expandTilde(baseDir);
|
|
9619
|
-
}
|
|
9620
9722
|
function includesSetting(options, source) {
|
|
9621
9723
|
const sources = options.local?.settingSources;
|
|
9622
9724
|
return sources !== void 0 && (sources.includes(source) || sources.includes("all"));
|
|
@@ -9640,7 +9742,7 @@ async function guardAgainstIdCollision(options) {
|
|
|
9640
9742
|
const persistenceCwd = resolveAgentPersistenceCwd(options);
|
|
9641
9743
|
await hydrateRegistryFromDisk(persistenceCwd);
|
|
9642
9744
|
if (getRegisteredAgent(options.agentId) !== void 0) {
|
|
9643
|
-
throw new
|
|
9745
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
9644
9746
|
`Agent "${options.agentId}" already exists. Use Agent.resume("${options.agentId}") to reattach, or pick a different agentId.`,
|
|
9645
9747
|
{ code: "agent_id_already_exists" }
|
|
9646
9748
|
);
|
|
@@ -9673,7 +9775,7 @@ async function maybeInjectHandoffTools(options) {
|
|
|
9673
9775
|
const spec = "@theokit/sdk-handoff/internal/tool-injector";
|
|
9674
9776
|
mod = await import(spec);
|
|
9675
9777
|
} catch (err) {
|
|
9676
|
-
throw new
|
|
9778
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
9677
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).",
|
|
9678
9780
|
{ code: "handoff_package_missing", cause: err }
|
|
9679
9781
|
);
|
|
@@ -9690,47 +9792,57 @@ async function maybeInjectHandoffTools(options) {
|
|
|
9690
9792
|
tools: [...existingTools, ...handoffTools]
|
|
9691
9793
|
};
|
|
9692
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
|
+
}
|
|
9693
9809
|
async function createLocalAgent(options) {
|
|
9694
|
-
const apiKey = resolveApiKey(options.apiKey);
|
|
9810
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.apiKey);
|
|
9695
9811
|
if (apiKey === void 0) {
|
|
9696
|
-
throw new
|
|
9812
|
+
throw new chunkK3FW2XZD_cjs.AuthenticationError(missingApiKeyMessage(), { code: "missing_api_key" });
|
|
9697
9813
|
}
|
|
9698
|
-
const
|
|
9814
|
+
const provider = providerFromModelId(normalizeModel(options.model)?.id);
|
|
9815
|
+
const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
|
|
9699
9816
|
const shape = validateApiKeyShape(apiKey, {
|
|
9700
9817
|
strict: willFlowToProvider,
|
|
9701
9818
|
// `options.model` is already normalized by `runCreateUnderSpan`; `normalizeModel`
|
|
9702
9819
|
// here is the idempotent narrowing of the widened public type (`{id}` passes
|
|
9703
9820
|
// through by reference) — cleaner than an `as` cast.
|
|
9704
|
-
...willFlowToProvider ? { provider
|
|
9821
|
+
...willFlowToProvider ? { provider } : {}
|
|
9705
9822
|
});
|
|
9706
9823
|
if (shape.malformed) {
|
|
9707
|
-
throw new
|
|
9708
|
-
}
|
|
9709
|
-
if (!chunkDM6Y5B2G_cjs.isFixtureApiKey(apiKey) && chunkDM6Y5B2G_cjs.getConfiguredBaseUrl() === void 0 && !chunkDM6Y5B2G_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
9710
|
-
throw new chunk2YGIBOUH_cjs.AuthenticationError("Invalid API key", {
|
|
9711
|
-
code: "authentication_error"
|
|
9712
|
-
});
|
|
9824
|
+
throw new chunkK3FW2XZD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
9713
9825
|
}
|
|
9714
9826
|
const agent = new LocalAgent(options);
|
|
9715
9827
|
await agent.initialize();
|
|
9716
9828
|
return agent;
|
|
9717
9829
|
}
|
|
9718
9830
|
async function createCloudAgent(options) {
|
|
9719
|
-
const apiKey = resolveApiKey(options.apiKey);
|
|
9831
|
+
const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.apiKey);
|
|
9720
9832
|
if (apiKey === void 0) {
|
|
9721
|
-
throw new
|
|
9833
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError("Missing API key for cloud agent", {
|
|
9722
9834
|
code: "missing_api_key"
|
|
9723
9835
|
});
|
|
9724
9836
|
}
|
|
9725
9837
|
const shape = validateApiKeyShape(apiKey);
|
|
9726
9838
|
if (shape.malformed) {
|
|
9727
|
-
throw new
|
|
9839
|
+
throw new chunkK3FW2XZD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
9728
9840
|
}
|
|
9729
|
-
const baseUrl =
|
|
9841
|
+
const baseUrl = chunkUNDROG5N_cjs.getConfiguredBaseUrl();
|
|
9730
9842
|
if (baseUrl === void 0) {
|
|
9731
9843
|
return new CloudAgent(options);
|
|
9732
9844
|
}
|
|
9733
|
-
const response = await
|
|
9845
|
+
const response = await chunkUNDROG5N_cjs.httpRequest("/v1/agents", {
|
|
9734
9846
|
apiKey,
|
|
9735
9847
|
method: "POST",
|
|
9736
9848
|
body: {
|
|
@@ -9755,7 +9867,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
9755
9867
|
return process.cwd();
|
|
9756
9868
|
}
|
|
9757
9869
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
9758
|
-
await
|
|
9870
|
+
await chunkUNDROG5N_cjs.discoverProviderPlugins();
|
|
9759
9871
|
await validateRehydratedAgent(agentId, existing);
|
|
9760
9872
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
9761
9873
|
const mergedOptions = {
|
|
@@ -9786,7 +9898,7 @@ async function validateRehydratedAgent(agentId, entry) {
|
|
|
9786
9898
|
throw new Error(`Workspace path is not a directory: ${candidate}`);
|
|
9787
9899
|
}
|
|
9788
9900
|
} catch (cause) {
|
|
9789
|
-
throw new
|
|
9901
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
9790
9902
|
`Agent "${agentId}" cannot be rehydrated \u2014 workspace cwd "${candidate}" is missing or inaccessible.`,
|
|
9791
9903
|
{ code: "agent_rehydration_failed", cause }
|
|
9792
9904
|
);
|
|
@@ -9831,17 +9943,33 @@ async function setAgentName(agentId, name) {
|
|
|
9831
9943
|
updateRegisteredAgent(agentId, { name });
|
|
9832
9944
|
await flushRegistrySaves();
|
|
9833
9945
|
}
|
|
9834
|
-
async function getRegisteredAgentOrThrow(agentId) {
|
|
9946
|
+
async function getRegisteredAgentOrThrow(agentId, cwd = process.cwd()) {
|
|
9835
9947
|
let agent = getRegisteredAgent(agentId);
|
|
9836
9948
|
if (agent === void 0) {
|
|
9837
|
-
await hydrateRegistryFromDisk(
|
|
9949
|
+
await hydrateRegistryFromDisk(cwd);
|
|
9838
9950
|
agent = getRegisteredAgent(agentId);
|
|
9839
9951
|
}
|
|
9840
9952
|
if (agent === void 0) {
|
|
9841
|
-
throw new
|
|
9953
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(`Agent ${agentId} not found`, { code: "unknown_agent" });
|
|
9842
9954
|
}
|
|
9843
9955
|
return agent;
|
|
9844
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
|
+
}
|
|
9845
9973
|
|
|
9846
9974
|
// src/agent.ts
|
|
9847
9975
|
var streamObjectImport;
|
|
@@ -9883,7 +10011,7 @@ var Agent = class _Agent {
|
|
|
9883
10011
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
9884
10012
|
});
|
|
9885
10013
|
try {
|
|
9886
|
-
await
|
|
10014
|
+
await chunkUNDROG5N_cjs.discoverProviderPlugins();
|
|
9887
10015
|
const agent = await runCreateUnderSpan(options, span);
|
|
9888
10016
|
return agent;
|
|
9889
10017
|
} catch (err) {
|
|
@@ -9895,7 +10023,22 @@ var Agent = class _Agent {
|
|
|
9895
10023
|
}
|
|
9896
10024
|
}
|
|
9897
10025
|
/**
|
|
9898
|
-
* One-shot prompt: create an agent, send a single message, wait, dispose
|
|
10026
|
+
* One-shot prompt: create an agent, send a single message, wait, **dispose**.
|
|
10027
|
+
*
|
|
10028
|
+
* `Agent.prompt` is STATIC and owns the agent's whole lifecycle. To send to an
|
|
10029
|
+
* agent you already hold, use the instance method — `agent.send(message)` —
|
|
10030
|
+
* which keeps the conversation and does not dispose anything:
|
|
10031
|
+
*
|
|
10032
|
+
* ```ts
|
|
10033
|
+
* const agent = await Agent.create({ ... });
|
|
10034
|
+
* const run = await agent.send("first"); // NOT agent.prompt(...)
|
|
10035
|
+
* const run2 = await agent.send("follow-up"); // full context retained
|
|
10036
|
+
* ```
|
|
10037
|
+
*
|
|
10038
|
+
* There is no `agent.prompt()` (#302). The natural sentence for the second
|
|
10039
|
+
* operation is "prompt the agent", so it is the method people reach for; the
|
|
10040
|
+
* two differ in whether the agent survives the call, which is why they do not
|
|
10041
|
+
* share a name.
|
|
9899
10042
|
*
|
|
9900
10043
|
* When `options.throwOnError === true`, rejects with `AgentRunError` if
|
|
9901
10044
|
* the run terminates with `status: 'error'` (instead of resolving with the
|
|
@@ -9909,8 +10052,8 @@ var Agent = class _Agent {
|
|
|
9909
10052
|
const run = await agent.send(message);
|
|
9910
10053
|
const result = await run.wait();
|
|
9911
10054
|
if (options.throwOnError === true && result.status === "error" && result.error !== void 0) {
|
|
9912
|
-
throw new
|
|
9913
|
-
code:
|
|
10055
|
+
throw new chunkK3FW2XZD_cjs.AgentRunError(result.error.message, {
|
|
10056
|
+
code: chunkK3FW2XZD_cjs.coerceToKnownAgentRunErrorCode(result.error.code),
|
|
9914
10057
|
cause: result.error.cause
|
|
9915
10058
|
});
|
|
9916
10059
|
}
|
|
@@ -9937,7 +10080,7 @@ var Agent = class _Agent {
|
|
|
9937
10080
|
if (existing !== void 0) {
|
|
9938
10081
|
return await rehydrateExistingAgent(agentId, existing, options);
|
|
9939
10082
|
}
|
|
9940
|
-
throw new
|
|
10083
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
9941
10084
|
`Agent "${agentId}" not found. Use Agent.create({ agentId, ... }) for first-time setup, or catch UnknownAgentError to branch resume-vs-create.`,
|
|
9942
10085
|
{ code: "unknown_agent" }
|
|
9943
10086
|
);
|
|
@@ -9966,7 +10109,7 @@ var Agent = class _Agent {
|
|
|
9966
10109
|
* @public
|
|
9967
10110
|
*/
|
|
9968
10111
|
static async generateObject(options) {
|
|
9969
|
-
const { generateObjectImpl } = await import('./generate-object-
|
|
10112
|
+
const { generateObjectImpl } = await import('./generate-object-PGSP5U7N.cjs');
|
|
9970
10113
|
return generateObjectImpl(options, {
|
|
9971
10114
|
create: (opts) => _Agent.create(opts),
|
|
9972
10115
|
delete: (agentId) => _Agent.delete(agentId)
|
|
@@ -9990,7 +10133,7 @@ var Agent = class _Agent {
|
|
|
9990
10133
|
delete: (agentId) => _Agent.delete(agentId)
|
|
9991
10134
|
};
|
|
9992
10135
|
async function* wrapper() {
|
|
9993
|
-
streamObjectImport ??= import('./stream-object-
|
|
10136
|
+
streamObjectImport ??= import('./stream-object-BUCF5PHO.cjs');
|
|
9994
10137
|
const { streamObjectImpl } = await streamObjectImport;
|
|
9995
10138
|
yield* streamObjectImpl(options, deps);
|
|
9996
10139
|
}
|
|
@@ -10014,7 +10157,7 @@ var Agent = class _Agent {
|
|
|
10014
10157
|
* @public
|
|
10015
10158
|
*/
|
|
10016
10159
|
static async batch(prompts, options) {
|
|
10017
|
-
const { batchImpl } = await import('./batch-
|
|
10160
|
+
const { batchImpl } = await import('./batch-ND32UKZS.cjs');
|
|
10018
10161
|
return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
|
|
10019
10162
|
}
|
|
10020
10163
|
/**
|
|
@@ -10058,34 +10201,57 @@ var Agent = class _Agent {
|
|
|
10058
10201
|
return fresh;
|
|
10059
10202
|
}
|
|
10060
10203
|
/**
|
|
10061
|
-
* List agents (local or cloud). M107 — `cwd` is READ
|
|
10062
|
-
* `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.
|
|
10063
10207
|
*
|
|
10064
10208
|
* @public
|
|
10065
10209
|
*/
|
|
10066
10210
|
static async list(options = {}) {
|
|
10067
10211
|
const cwd = ("cwd" in options ? options.cwd : void 0) ?? process.cwd();
|
|
10068
10212
|
await hydrateRegistryFromDisk(cwd);
|
|
10069
|
-
const
|
|
10070
|
-
|
|
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
|
+
};
|
|
10071
10227
|
}
|
|
10072
10228
|
/**
|
|
10073
|
-
* 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.
|
|
10074
10231
|
*
|
|
10075
10232
|
* @public
|
|
10076
10233
|
*/
|
|
10077
|
-
static async get(agentId,
|
|
10078
|
-
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10234
|
+
static async get(agentId, options = {}) {
|
|
10235
|
+
const agent = await getRegisteredAgentOrThrow(agentId, options.cwd);
|
|
10079
10236
|
return toAgentInfo(agent);
|
|
10080
10237
|
}
|
|
10081
10238
|
/**
|
|
10082
|
-
* 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.
|
|
10083
10241
|
*
|
|
10084
10242
|
* @public
|
|
10085
10243
|
*/
|
|
10086
|
-
static async listRuns(agentId,
|
|
10087
|
-
await getRegisteredAgentOrThrow(agentId);
|
|
10088
|
-
|
|
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 } : {} };
|
|
10089
10255
|
}
|
|
10090
10256
|
/**
|
|
10091
10257
|
* Get a single run.
|
|
@@ -10094,14 +10260,14 @@ var Agent = class _Agent {
|
|
|
10094
10260
|
*/
|
|
10095
10261
|
static async getRun(runId, options = {}) {
|
|
10096
10262
|
if (options.runtime === "cloud") {
|
|
10097
|
-
throw new
|
|
10263
|
+
throw new chunkK3FW2XZD_cjs.ConfigurationError(
|
|
10098
10264
|
"Cloud runtime is pre-release. Theo PaaS endpoints are not wired yet \u2014 getRun({ runtime: 'cloud' }) will be enabled when the PaaS ships.",
|
|
10099
10265
|
{ code: "cloud_runtime_pre_release" }
|
|
10100
10266
|
);
|
|
10101
10267
|
}
|
|
10102
10268
|
const existing = getRun(runId);
|
|
10103
10269
|
if (existing !== void 0) return existing;
|
|
10104
|
-
throw new
|
|
10270
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10105
10271
|
`Run ${runId} is not in this process's registry. It may have been disposed, persisted in a previous process, or never created.`,
|
|
10106
10272
|
{ code: "run_not_found" }
|
|
10107
10273
|
);
|
|
@@ -10148,13 +10314,13 @@ var Agent = class _Agent {
|
|
|
10148
10314
|
reg = getRegisteredAgent(agentId);
|
|
10149
10315
|
}
|
|
10150
10316
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10151
|
-
throw new
|
|
10317
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10152
10318
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10153
10319
|
);
|
|
10154
10320
|
}
|
|
10155
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10321
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-YCT6JMBX.cjs');
|
|
10156
10322
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10157
|
-
return
|
|
10323
|
+
return chunk5BJV5UPY_cjs.enqueueSessionWrite(
|
|
10158
10324
|
cwd,
|
|
10159
10325
|
agentId,
|
|
10160
10326
|
() => compactSessionTranscript({
|
|
@@ -10184,11 +10350,11 @@ var Agent = class _Agent {
|
|
|
10184
10350
|
reg = getRegisteredAgent(agentId);
|
|
10185
10351
|
}
|
|
10186
10352
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10187
|
-
throw new
|
|
10353
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10188
10354
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10189
10355
|
);
|
|
10190
10356
|
}
|
|
10191
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10357
|
+
const { injectSessionTurn } = await import('./inject-session-XLO3KTBM.cjs');
|
|
10192
10358
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10193
10359
|
await injectSessionTurn({
|
|
10194
10360
|
store,
|
|
@@ -10223,11 +10389,11 @@ var Agent = class _Agent {
|
|
|
10223
10389
|
reg = getRegisteredAgent(agentId);
|
|
10224
10390
|
}
|
|
10225
10391
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10226
|
-
throw new
|
|
10392
|
+
throw new chunkK3FW2XZD_cjs.UnknownAgentError(
|
|
10227
10393
|
`No local agent "${agentId}" registered \u2014 transcript targets local sessions.`
|
|
10228
10394
|
);
|
|
10229
10395
|
}
|
|
10230
|
-
const { readSessionMessages } = await import('./agent-session-store-
|
|
10396
|
+
const { readSessionMessages } = await import('./agent-session-store-ZJ3JSRS4.cjs');
|
|
10231
10397
|
const { store } = await openLocalStore(reg);
|
|
10232
10398
|
return readSessionMessages(store, agentId);
|
|
10233
10399
|
}
|
|
@@ -10248,7 +10414,7 @@ var Agent = class _Agent {
|
|
|
10248
10414
|
*/
|
|
10249
10415
|
static async describe(agentId) {
|
|
10250
10416
|
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10251
|
-
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-
|
|
10417
|
+
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-AZIXJ7D3.cjs');
|
|
10252
10418
|
const settingSources = agent.options.local?.settingSources;
|
|
10253
10419
|
const subagents = await loadSubagents2(
|
|
10254
10420
|
agent.cwd ?? process.cwd(),
|
|
@@ -10292,12 +10458,12 @@ async function getOrCreateUncached(agentId, options) {
|
|
|
10292
10458
|
try {
|
|
10293
10459
|
return await Agent.resume(agentId, options);
|
|
10294
10460
|
} catch (err) {
|
|
10295
|
-
if (!(err instanceof
|
|
10461
|
+
if (!(err instanceof chunkK3FW2XZD_cjs.UnknownAgentError)) throw err;
|
|
10296
10462
|
}
|
|
10297
10463
|
try {
|
|
10298
10464
|
return await Agent.create({ ...options, agentId });
|
|
10299
10465
|
} catch (err) {
|
|
10300
|
-
if (err instanceof
|
|
10466
|
+
if (err instanceof chunkK3FW2XZD_cjs.ConfigurationError && err.code === "agent_id_already_exists") {
|
|
10301
10467
|
return await Agent.resume(agentId, options);
|
|
10302
10468
|
}
|
|
10303
10469
|
throw err;
|
|
@@ -10315,9 +10481,10 @@ async function openLocalStore(reg) {
|
|
|
10315
10481
|
const cwd = reg.cwd ?? process.cwd();
|
|
10316
10482
|
const optModel = reg.options.model;
|
|
10317
10483
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
10318
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
10319
|
-
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-
|
|
10320
|
-
const
|
|
10484
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-3MOJQGP2.cjs');
|
|
10485
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-JXHFTB7G.cjs');
|
|
10486
|
+
const configuredSessionDir = reg.options.local?.sessionDir ?? reg.options.local?.baseDir;
|
|
10487
|
+
const baseDir = configuredSessionDir !== void 0 ? expandTilde2(configuredSessionDir) : defaultBaseDir2();
|
|
10321
10488
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
10322
10489
|
}
|
|
10323
10490
|
|
|
@@ -10332,6 +10499,5 @@ exports.computeCost = computeCost;
|
|
|
10332
10499
|
exports.generateCronId = generateCronId;
|
|
10333
10500
|
exports.getPricingEntry = getPricingEntry;
|
|
10334
10501
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10335
|
-
|
|
10336
|
-
//# sourceMappingURL=chunk-
|
|
10337
|
-
//# sourceMappingURL=chunk-2VFZQEDW.cjs.map
|
|
10502
|
+
//# sourceMappingURL=chunk-UFAO4T7Z.cjs.map
|
|
10503
|
+
//# sourceMappingURL=chunk-UFAO4T7Z.cjs.map
|