@theokit/sdk 5.11.1 → 5.12.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 +87 -0
- package/dist/a2a/index.cjs +8 -8
- package/dist/a2a/index.js +3 -3
- package/dist/agent-BVKIUP7F.cjs +71 -0
- package/dist/{agent-OKP4LHG2.cjs.map → agent-BVKIUP7F.cjs.map} +1 -1
- package/dist/{agent-CmKwSyyD.d.ts → agent-CVzDy_Oj.d.ts} +17 -8
- package/dist/{agent-XMkGzff_.d.cts → agent-Cn0sphpA.d.cts} +17 -8
- package/dist/agent-IG7BP6GN.js +62 -0
- package/dist/{agent-DFV52V6E.js.map → agent-IG7BP6GN.js.map} +1 -1
- package/dist/agent-prims-CZyxfCmS.d.cts +206 -0
- package/dist/agent-prims-CZyxfCmS.d.ts +206 -0
- package/dist/agent-session-store-22GKA7O4.js +6 -0
- package/dist/{agent-session-store-ODD3IZCW.js.map → agent-session-store-22GKA7O4.js.map} +1 -1
- package/dist/agent-session-store-WP6NGDVX.cjs +23 -0
- package/dist/{agent-session-store-SVEJHSUA.cjs.map → agent-session-store-WP6NGDVX.cjs.map} +1 -1
- package/dist/auth/index.cjs +33 -33
- package/dist/auth/index.js +6 -6
- package/dist/{batch-427O54FQ.js → batch-EP3FCL6D.js} +9 -9
- package/dist/{batch-427O54FQ.js.map → batch-EP3FCL6D.js.map} +1 -1
- package/dist/{batch-U4SO4RLX.cjs → batch-IZ5EDKJ5.cjs} +29 -29
- package/dist/{batch-U4SO4RLX.cjs.map → batch-IZ5EDKJ5.cjs.map} +1 -1
- package/dist/{chunk-IIYJMXYW.cjs → chunk-27V5I2WW.cjs} +4 -4
- package/dist/{chunk-IIYJMXYW.cjs.map → chunk-27V5I2WW.cjs.map} +1 -1
- package/dist/{chunk-DPY2M74T.js → chunk-2C24NSNV.js} +5 -5
- package/dist/{chunk-DPY2M74T.js.map → chunk-2C24NSNV.js.map} +1 -1
- package/dist/{chunk-7F7XE6CM.js → chunk-2S4HQCDF.js} +3 -3
- package/dist/{chunk-7F7XE6CM.js.map → chunk-2S4HQCDF.js.map} +1 -1
- package/dist/{chunk-LZJXEPEQ.js → chunk-2SFLLOMN.js} +3 -3
- package/dist/{chunk-LZJXEPEQ.js.map → chunk-2SFLLOMN.js.map} +1 -1
- package/dist/{chunk-RGQICWFU.js → chunk-354F3OF5.js} +3 -3
- package/dist/{chunk-RGQICWFU.js.map → chunk-354F3OF5.js.map} +1 -1
- package/dist/{chunk-TX56N7FR.js → chunk-3FSBE4PS.js} +4 -4
- package/dist/{chunk-TX56N7FR.js.map → chunk-3FSBE4PS.js.map} +1 -1
- package/dist/{chunk-RQMCOFAI.cjs → chunk-3HA7N2BB.cjs} +8 -8
- package/dist/{chunk-RQMCOFAI.cjs.map → chunk-3HA7N2BB.cjs.map} +1 -1
- package/dist/{chunk-GM54F4FE.cjs → chunk-3KIUY67P.cjs} +9 -9
- package/dist/{chunk-GM54F4FE.cjs.map → chunk-3KIUY67P.cjs.map} +1 -1
- package/dist/{chunk-CZJ6Q7CW.js → chunk-3OY6H3I7.js} +66 -7
- package/dist/chunk-3OY6H3I7.js.map +1 -0
- package/dist/{chunk-ZWACQM5U.cjs → chunk-3WKWBYPO.cjs} +9 -9
- package/dist/{chunk-ZWACQM5U.cjs.map → chunk-3WKWBYPO.cjs.map} +1 -1
- package/dist/{chunk-Q34EBNYG.js → chunk-4GUFNDZR.js} +5 -5
- package/dist/{chunk-Q34EBNYG.js.map → chunk-4GUFNDZR.js.map} +1 -1
- package/dist/{chunk-XDUGSTYJ.cjs → chunk-4YD2WI57.cjs} +15 -15
- package/dist/{chunk-XDUGSTYJ.cjs.map → chunk-4YD2WI57.cjs.map} +1 -1
- package/dist/{chunk-SKDNCTXG.cjs → chunk-5A4UFBHW.cjs} +15 -15
- package/dist/{chunk-SKDNCTXG.cjs.map → chunk-5A4UFBHW.cjs.map} +1 -1
- package/dist/{chunk-SUVCHX4L.js → chunk-5AR6O7GW.js} +3 -3
- package/dist/{chunk-SUVCHX4L.js.map → chunk-5AR6O7GW.js.map} +1 -1
- package/dist/{chunk-SVCPJRUB.js → chunk-5HSMH2ZZ.js} +6 -6
- package/dist/{chunk-SVCPJRUB.js.map → chunk-5HSMH2ZZ.js.map} +1 -1
- package/dist/{chunk-GTX6FEDP.js → chunk-5IRDK5BC.js} +3 -3
- package/dist/{chunk-GTX6FEDP.js.map → chunk-5IRDK5BC.js.map} +1 -1
- package/dist/{chunk-H3CVJSFC.js → chunk-5IUDICRK.js} +3 -3
- package/dist/{chunk-H3CVJSFC.js.map → chunk-5IUDICRK.js.map} +1 -1
- package/dist/{chunk-FYEHYQ7T.cjs → chunk-6CXRYPG7.cjs} +15 -15
- package/dist/{chunk-FYEHYQ7T.cjs.map → chunk-6CXRYPG7.cjs.map} +1 -1
- package/dist/{chunk-NQVWSSX2.cjs → chunk-6OCJWGVD.cjs} +12 -12
- package/dist/{chunk-NQVWSSX2.cjs.map → chunk-6OCJWGVD.cjs.map} +1 -1
- package/dist/{chunk-MPR2ISL2.cjs → chunk-6XQLTQB6.cjs} +4 -4
- package/dist/{chunk-MPR2ISL2.cjs.map → chunk-6XQLTQB6.cjs.map} +1 -1
- package/dist/{chunk-72CPLZPC.cjs → chunk-7INPXUJI.cjs} +5 -5
- package/dist/{chunk-72CPLZPC.cjs.map → chunk-7INPXUJI.cjs.map} +1 -1
- package/dist/{chunk-HG5LKFG7.cjs → chunk-7WARNHWW.cjs} +16 -16
- package/dist/{chunk-HG5LKFG7.cjs.map → chunk-7WARNHWW.cjs.map} +1 -1
- package/dist/{chunk-KIKKTW5O.cjs → chunk-7YUPSBDV.cjs} +4 -4
- package/dist/{chunk-KIKKTW5O.cjs.map → chunk-7YUPSBDV.cjs.map} +1 -1
- package/dist/{chunk-IZDDSLL2.js → chunk-AB4OPJLD.js} +6 -6
- package/dist/{chunk-IZDDSLL2.js.map → chunk-AB4OPJLD.js.map} +1 -1
- package/dist/{chunk-XERM7PDQ.js → chunk-AGO5S5WD.js} +3 -3
- package/dist/{chunk-XERM7PDQ.js.map → chunk-AGO5S5WD.js.map} +1 -1
- package/dist/{chunk-ZWFTECOE.js → chunk-AHKS3DKI.js} +3 -3
- package/dist/{chunk-ZWFTECOE.js.map → chunk-AHKS3DKI.js.map} +1 -1
- package/dist/{chunk-ECD6ER3E.cjs → chunk-AIZ6WXSL.cjs} +4 -4
- package/dist/{chunk-ECD6ER3E.cjs.map → chunk-AIZ6WXSL.cjs.map} +1 -1
- package/dist/{chunk-KO6SHCEH.js → chunk-AQW54OWQ.js} +3 -3
- package/dist/{chunk-KO6SHCEH.js.map → chunk-AQW54OWQ.js.map} +1 -1
- package/dist/{chunk-P22BZE7G.cjs → chunk-AT2PESXB.cjs} +7 -7
- package/dist/{chunk-P22BZE7G.cjs.map → chunk-AT2PESXB.cjs.map} +1 -1
- package/dist/{chunk-MHIBYKWA.js → chunk-BJ7BPLQK.js} +131 -72
- package/dist/chunk-BJ7BPLQK.js.map +1 -0
- package/dist/{chunk-HV4V63CO.js → chunk-BO3PV3OP.js} +4 -4
- package/dist/{chunk-HV4V63CO.js.map → chunk-BO3PV3OP.js.map} +1 -1
- package/dist/{chunk-7NQ7HJ3E.cjs → chunk-BRWI4HLK.cjs} +6 -6
- package/dist/{chunk-7NQ7HJ3E.cjs.map → chunk-BRWI4HLK.cjs.map} +1 -1
- package/dist/{chunk-GHHIJEFX.cjs → chunk-BWYC7RZG.cjs} +9 -9
- package/dist/{chunk-GHHIJEFX.cjs.map → chunk-BWYC7RZG.cjs.map} +1 -1
- package/dist/{chunk-UNFBHV46.cjs → chunk-CEGU5AVD.cjs} +9 -9
- package/dist/chunk-CEGU5AVD.cjs.map +1 -0
- package/dist/{chunk-JV7JA7BM.cjs → chunk-CGH4BCIY.cjs} +11 -11
- package/dist/{chunk-JV7JA7BM.cjs.map → chunk-CGH4BCIY.cjs.map} +1 -1
- package/dist/{chunk-L3C6CCBG.cjs → chunk-CWQPQTUZ.cjs} +21 -21
- package/dist/{chunk-L3C6CCBG.cjs.map → chunk-CWQPQTUZ.cjs.map} +1 -1
- package/dist/{chunk-X3LOJJMO.js → chunk-DF77RBF4.js} +9 -9
- package/dist/{chunk-X3LOJJMO.js.map → chunk-DF77RBF4.js.map} +1 -1
- package/dist/{chunk-GMSRRJ53.js → chunk-EEK7S77K.js} +3 -3
- package/dist/{chunk-GMSRRJ53.js.map → chunk-EEK7S77K.js.map} +1 -1
- package/dist/{chunk-NKIQTLFA.cjs → chunk-EQ5IDL6W.cjs} +4 -4
- package/dist/{chunk-NKIQTLFA.cjs.map → chunk-EQ5IDL6W.cjs.map} +1 -1
- package/dist/{chunk-D5KXKBEN.cjs → chunk-FEAWEBWN.cjs} +5 -5
- package/dist/{chunk-D5KXKBEN.cjs.map → chunk-FEAWEBWN.cjs.map} +1 -1
- package/dist/{chunk-NJSIAJEK.cjs → chunk-FLDMPVUC.cjs} +4 -4
- package/dist/{chunk-NJSIAJEK.cjs.map → chunk-FLDMPVUC.cjs.map} +1 -1
- package/dist/{chunk-ASK2OQM5.cjs → chunk-G7XBVM3T.cjs} +5 -5
- package/dist/{chunk-ASK2OQM5.cjs.map → chunk-G7XBVM3T.cjs.map} +1 -1
- package/dist/{chunk-U27XHOEF.js → chunk-H7G65PNI.js} +5 -5
- package/dist/{chunk-U27XHOEF.js.map → chunk-H7G65PNI.js.map} +1 -1
- package/dist/{chunk-JW3GVLM6.cjs → chunk-H7HD6RXO.cjs} +4 -4
- package/dist/{chunk-JW3GVLM6.cjs.map → chunk-H7HD6RXO.cjs.map} +1 -1
- package/dist/{chunk-ZHWKT2NI.js → chunk-HJ2LV464.js} +3 -3
- package/dist/{chunk-ZHWKT2NI.js.map → chunk-HJ2LV464.js.map} +1 -1
- package/dist/{chunk-KGZ66JVZ.cjs → chunk-HN4IKB6X.cjs} +14 -14
- package/dist/{chunk-KGZ66JVZ.cjs.map → chunk-HN4IKB6X.cjs.map} +1 -1
- package/dist/{chunk-XKMVJ443.js → chunk-HWMGR3HA.js} +6 -6
- package/dist/{chunk-XKMVJ443.js.map → chunk-HWMGR3HA.js.map} +1 -1
- package/dist/{chunk-EQ5NCH2Y.cjs → chunk-IO4RI5ZJ.cjs} +24 -24
- package/dist/{chunk-EQ5NCH2Y.cjs.map → chunk-IO4RI5ZJ.cjs.map} +1 -1
- package/dist/{chunk-OLSEWLK5.cjs → chunk-IOFMRS6T.cjs} +6 -6
- package/dist/{chunk-OLSEWLK5.cjs.map → chunk-IOFMRS6T.cjs.map} +1 -1
- package/dist/{chunk-7QJYKVP6.js → chunk-KCM3RMKR.js} +3 -3
- package/dist/{chunk-7QJYKVP6.js.map → chunk-KCM3RMKR.js.map} +1 -1
- package/dist/{chunk-7KIN3L2S.js → chunk-KU5O7WPK.js} +3 -3
- package/dist/{chunk-7KIN3L2S.js.map → chunk-KU5O7WPK.js.map} +1 -1
- package/dist/{chunk-J5623RIV.cjs → chunk-KX5QXLBS.cjs} +10 -10
- package/dist/{chunk-J5623RIV.cjs.map → chunk-KX5QXLBS.cjs.map} +1 -1
- package/dist/{chunk-J6GXS5A2.cjs → chunk-L7JPXZ2C.cjs} +17 -17
- package/dist/{chunk-J6GXS5A2.cjs.map → chunk-L7JPXZ2C.cjs.map} +1 -1
- package/dist/{chunk-P7NNKEWO.cjs → chunk-L7V4DDIE.cjs} +4 -4
- package/dist/{chunk-P7NNKEWO.cjs.map → chunk-L7V4DDIE.cjs.map} +1 -1
- package/dist/chunk-LO6LIUZ6.cjs +18 -0
- package/dist/{chunk-SGC7LSHF.cjs.map → chunk-LO6LIUZ6.cjs.map} +1 -1
- package/dist/{chunk-P5N3Q2NH.cjs → chunk-LSWHDOCL.cjs} +192 -148
- package/dist/chunk-LSWHDOCL.cjs.map +1 -0
- package/dist/{chunk-3JHIFQ4I.js → chunk-M4U24U6G.js} +3 -3
- package/dist/{chunk-3JHIFQ4I.js.map → chunk-M4U24U6G.js.map} +1 -1
- package/dist/{chunk-GGRPAQ3B.js → chunk-MLGETTYX.js} +5 -5
- package/dist/{chunk-GGRPAQ3B.js.map → chunk-MLGETTYX.js.map} +1 -1
- package/dist/{chunk-XZHJYSPB.js → chunk-MLJDW2YK.js} +4 -4
- package/dist/{chunk-XZHJYSPB.js.map → chunk-MLJDW2YK.js.map} +1 -1
- package/dist/{chunk-5Q4RTLMP.js → chunk-MS3TQSXU.js} +3 -3
- package/dist/{chunk-5Q4RTLMP.js.map → chunk-MS3TQSXU.js.map} +1 -1
- package/dist/{chunk-W2ZVTEOD.js → chunk-MSEL5E5P.js} +6 -6
- package/dist/{chunk-W2ZVTEOD.js.map → chunk-MSEL5E5P.js.map} +1 -1
- package/dist/{chunk-ZAM7BJXJ.cjs → chunk-MSW7LB2V.cjs} +5 -5
- package/dist/{chunk-ZAM7BJXJ.cjs.map → chunk-MSW7LB2V.cjs.map} +1 -1
- package/dist/{chunk-7HUCU3KK.js → chunk-NHOEXFZT.js} +5 -5
- package/dist/{chunk-7HUCU3KK.js.map → chunk-NHOEXFZT.js.map} +1 -1
- package/dist/{chunk-6G4IRQUD.js → chunk-NJBJ3CUG.js} +6 -6
- package/dist/{chunk-6G4IRQUD.js.map → chunk-NJBJ3CUG.js.map} +1 -1
- package/dist/{chunk-I2ORT6QD.js → chunk-NKQVLWDF.js} +3 -3
- package/dist/{chunk-I2ORT6QD.js.map → chunk-NKQVLWDF.js.map} +1 -1
- package/dist/{chunk-N7KS3TIR.cjs → chunk-NP362THY.cjs} +28 -15
- package/dist/chunk-NP362THY.cjs.map +1 -0
- package/dist/{chunk-NWS2CS3Y.cjs → chunk-NWWTYBD3.cjs} +5 -5
- package/dist/{chunk-NWS2CS3Y.cjs.map → chunk-NWWTYBD3.cjs.map} +1 -1
- package/dist/{chunk-SVQIW5RJ.js → chunk-OLJOI4LK.js} +4 -4
- package/dist/{chunk-SVQIW5RJ.js.map → chunk-OLJOI4LK.js.map} +1 -1
- package/dist/{chunk-7JAKO3NM.js → chunk-ORLTGPOS.js} +3 -3
- package/dist/{chunk-7JAKO3NM.js.map → chunk-ORLTGPOS.js.map} +1 -1
- package/dist/{chunk-5DD4NJN3.js → chunk-PKRPV3R7.js} +3 -3
- package/dist/{chunk-5DD4NJN3.js.map → chunk-PKRPV3R7.js.map} +1 -1
- package/dist/{chunk-R5YPDAKD.cjs → chunk-POBZXULR.cjs} +4 -4
- package/dist/{chunk-R5YPDAKD.cjs.map → chunk-POBZXULR.cjs.map} +1 -1
- package/dist/{chunk-35KBC4BX.cjs → chunk-Q6WT5535.cjs} +446 -387
- package/dist/chunk-Q6WT5535.cjs.map +1 -0
- package/dist/{chunk-MQGSOKR3.js → chunk-Q7UG242V.js} +3 -3
- package/dist/{chunk-MQGSOKR3.js.map → chunk-Q7UG242V.js.map} +1 -1
- package/dist/{chunk-XKZFIP7Z.cjs → chunk-QG4SXZ2A.cjs} +4 -4
- package/dist/{chunk-XKZFIP7Z.cjs.map → chunk-QG4SXZ2A.cjs.map} +1 -1
- package/dist/{chunk-NAGPKWOD.cjs → chunk-QISSETTG.cjs} +4 -4
- package/dist/{chunk-NAGPKWOD.cjs.map → chunk-QISSETTG.cjs.map} +1 -1
- package/dist/{chunk-OR6XIWLB.js → chunk-QK2ERTO3.js} +4 -4
- package/dist/{chunk-OR6XIWLB.js.map → chunk-QK2ERTO3.js.map} +1 -1
- package/dist/{chunk-ZDYDBXSD.js → chunk-RN3XDZGS.js} +6 -6
- package/dist/{chunk-ZDYDBXSD.js.map → chunk-RN3XDZGS.js.map} +1 -1
- package/dist/{chunk-6LHQPOMI.cjs → chunk-RNXXYF22.cjs} +66 -7
- package/dist/chunk-RNXXYF22.cjs.map +1 -0
- package/dist/{chunk-TMKTSYDS.cjs → chunk-RS7YQR4X.cjs} +6 -6
- package/dist/{chunk-TMKTSYDS.cjs.map → chunk-RS7YQR4X.cjs.map} +1 -1
- package/dist/{chunk-HU666T3Q.cjs → chunk-S46WJTDL.cjs} +14 -14
- package/dist/{chunk-HU666T3Q.cjs.map → chunk-S46WJTDL.cjs.map} +1 -1
- package/dist/{chunk-ZD66GFH5.cjs → chunk-SDZ4XDWS.cjs} +35 -35
- package/dist/{chunk-ZD66GFH5.cjs.map → chunk-SDZ4XDWS.cjs.map} +1 -1
- package/dist/{chunk-ZJZ7LV3A.js → chunk-SV63WTA2.js} +3 -3
- package/dist/{chunk-ZJZ7LV3A.js.map → chunk-SV63WTA2.js.map} +1 -1
- package/dist/{chunk-CQYBJOB2.cjs → chunk-SXH37C7X.cjs} +4 -4
- package/dist/{chunk-CQYBJOB2.cjs.map → chunk-SXH37C7X.cjs.map} +1 -1
- package/dist/{chunk-GMRFAX4I.js → chunk-SZQFCHU6.js} +4 -4
- package/dist/{chunk-GMRFAX4I.js.map → chunk-SZQFCHU6.js.map} +1 -1
- package/dist/{chunk-6PB5AQCY.cjs → chunk-TLVI2OQK.cjs} +16 -16
- package/dist/{chunk-6PB5AQCY.cjs.map → chunk-TLVI2OQK.cjs.map} +1 -1
- package/dist/{chunk-B5MHRQJZ.js → chunk-TNFOU6SB.js} +3 -3
- package/dist/chunk-TNFOU6SB.js.map +1 -0
- package/dist/{chunk-N6OEX5TN.cjs → chunk-UDAKAE4Z.cjs} +16 -16
- package/dist/{chunk-N6OEX5TN.cjs.map → chunk-UDAKAE4Z.cjs.map} +1 -1
- package/dist/{chunk-26NEAJ6T.js → chunk-VVGFZQZC.js} +4 -4
- package/dist/{chunk-26NEAJ6T.js.map → chunk-VVGFZQZC.js.map} +1 -1
- package/dist/{chunk-XCQ432OX.js → chunk-VZGE7NAI.js} +3 -3
- package/dist/{chunk-XCQ432OX.js.map → chunk-VZGE7NAI.js.map} +1 -1
- package/dist/{chunk-C7GKRGKN.cjs → chunk-WDVG5R2Q.cjs} +19 -19
- package/dist/{chunk-C7GKRGKN.cjs.map → chunk-WDVG5R2Q.cjs.map} +1 -1
- package/dist/{chunk-FTZTZBCU.js → chunk-XESYJ4JC.js} +4 -4
- package/dist/{chunk-FTZTZBCU.js.map → chunk-XESYJ4JC.js.map} +1 -1
- package/dist/{chunk-OPAKPEPG.js → chunk-XJ3WU5CZ.js} +5 -5
- package/dist/{chunk-OPAKPEPG.js.map → chunk-XJ3WU5CZ.js.map} +1 -1
- package/dist/{chunk-BBJ77S62.js → chunk-XJ4C4NFX.js} +64 -20
- package/dist/chunk-XJ4C4NFX.js.map +1 -0
- package/dist/{chunk-AY43232P.js → chunk-XRPMZ7TO.js} +4 -4
- package/dist/{chunk-AY43232P.js.map → chunk-XRPMZ7TO.js.map} +1 -1
- package/dist/{chunk-X6DUEDAF.js → chunk-XZKIAENA.js} +3 -3
- package/dist/{chunk-X6DUEDAF.js.map → chunk-XZKIAENA.js.map} +1 -1
- package/dist/{chunk-X7EUUHXU.js → chunk-YMVTUV5K.js} +3 -3
- package/dist/{chunk-X7EUUHXU.js.map → chunk-YMVTUV5K.js.map} +1 -1
- package/dist/{chunk-3JANYJYS.cjs → chunk-YOVZMN4P.cjs} +8 -8
- package/dist/{chunk-3JANYJYS.cjs.map → chunk-YOVZMN4P.cjs.map} +1 -1
- package/dist/{chunk-TY56BKSK.cjs → chunk-YQ3XC6C2.cjs} +4 -4
- package/dist/{chunk-TY56BKSK.cjs.map → chunk-YQ3XC6C2.cjs.map} +1 -1
- package/dist/{chunk-JLIRFWUG.js → chunk-ZJAYFSVI.js} +22 -9
- package/dist/chunk-ZJAYFSVI.js.map +1 -0
- package/dist/{chunk-MU7IAA7G.js → chunk-ZLFFDPXC.js} +9 -9
- package/dist/{chunk-MU7IAA7G.js.map → chunk-ZLFFDPXC.js.map} +1 -1
- package/dist/{chunk-JLRLCBJ4.cjs → chunk-ZOFRNNZD.cjs} +4 -4
- package/dist/{chunk-JLRLCBJ4.cjs.map → chunk-ZOFRNNZD.cjs.map} +1 -1
- package/dist/{chunk-MPQJE3G4.cjs → chunk-ZWLFHSON.cjs} +15 -15
- package/dist/{chunk-MPQJE3G4.cjs.map → chunk-ZWLFHSON.cjs.map} +1 -1
- package/dist/compact-session-3U2JYTVG.js +25 -0
- package/dist/{compact-session-4HAUP3HK.js.map → compact-session-3U2JYTVG.js.map} +1 -1
- package/dist/{compact-session-Y56D3S57.cjs → compact-session-NM56BREJ.cjs} +24 -24
- package/dist/{compact-session-Y56D3S57.cjs.map → compact-session-NM56BREJ.cjs.map} +1 -1
- package/dist/compaction.cjs +18 -18
- package/dist/compaction.js +3 -3
- package/dist/concurrency.cjs +6 -6
- package/dist/concurrency.js +4 -4
- package/dist/context/index.cjs +9 -9
- package/dist/context/index.js +6 -6
- package/dist/context-4RSI3AXT.cjs +24 -0
- package/dist/{context-B5J4GX2F.cjs.map → context-4RSI3AXT.cjs.map} +1 -1
- package/dist/context-7EBZST3L.js +7 -0
- package/dist/{context-3FZRAO5K.js.map → context-7EBZST3L.js.map} +1 -1
- package/dist/{cron-Blj6wMYg.d.cts → cron-BWDYetbq.d.cts} +2 -2
- package/dist/{cron-BPccQCO8.d.ts → cron-CHn-F0fC.d.ts} +2 -2
- package/dist/cron.cjs +42 -42
- package/dist/cron.d.cts +4 -4
- package/dist/cron.d.ts +4 -4
- package/dist/cron.js +41 -41
- package/dist/{errors-BWOJeWTZ.d.cts → errors-BiDQFWTG.d.cts} +10 -7
- package/dist/{errors-DDvG18IB.d.ts → errors-Pf22PJJ-.d.ts} +10 -7
- package/dist/errors.cjs +23 -23
- package/dist/errors.d.cts +2 -3
- package/dist/errors.d.ts +2 -3
- package/dist/errors.js +2 -2
- package/dist/eval.cjs +54 -54
- package/dist/eval.js +42 -42
- package/dist/{executor-3NI7KNL4.js → executor-3D2UDJHW.js} +8 -8
- package/dist/{executor-3NI7KNL4.js.map → executor-3D2UDJHW.js.map} +1 -1
- package/dist/{executor-2SUGI3ZT.cjs → executor-HKHT4CWS.cjs} +26 -26
- package/dist/{executor-2SUGI3ZT.cjs.map → executor-HKHT4CWS.cjs.map} +1 -1
- package/dist/filesystem/index.cjs +12 -12
- package/dist/filesystem/index.js +3 -3
- package/dist/fs-session-store-6ZCCJX3K.js +11 -0
- package/dist/{fs-session-store-3VI4CPTX.js.map → fs-session-store-6ZCCJX3K.js.map} +1 -1
- package/dist/fs-session-store-S2AXVJIX.cjs +20 -0
- package/dist/{fs-session-store-IQ6PEHYF.cjs.map → fs-session-store-S2AXVJIX.cjs.map} +1 -1
- package/dist/generate-object-S7MNVF2V.js +7 -0
- package/dist/{generate-object-NTKAWE7D.js.map → generate-object-S7MNVF2V.js.map} +1 -1
- package/dist/generate-object-XBWD2PU7.cjs +20 -0
- package/dist/{generate-object-YHTWG5DB.cjs.map → generate-object-XBWD2PU7.cjs.map} +1 -1
- package/dist/index-manager-HO456AVW.cjs +27 -0
- package/dist/{index-manager-YGXRFJMZ.cjs.map → index-manager-HO456AVW.cjs.map} +1 -1
- package/dist/index-manager-QDH56FER.js +18 -0
- package/dist/{index-manager-JVYIVTZG.js.map → index-manager-QDH56FER.js.map} +1 -1
- package/dist/index.cjs +172 -172
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +59 -59
- package/dist/{inject-session-R73PRM7B.cjs → inject-session-JVTZNQF6.cjs} +9 -9
- package/dist/{inject-session-R73PRM7B.cjs.map → inject-session-JVTZNQF6.cjs.map} +1 -1
- package/dist/{inject-session-LJX5JGV5.js → inject-session-THABTKJY.js} +7 -7
- package/dist/{inject-session-LJX5JGV5.js.map → inject-session-THABTKJY.js.map} +1 -1
- package/dist/interactive/index.cjs +4 -4
- package/dist/interactive/index.js +2 -2
- package/dist/internal/budget/normalize-usage.d.ts +5 -1
- package/dist/internal/error-mappers/openai-compatible.d.ts +3 -1
- package/dist/internal/memory/adapters/index.cjs +8 -8
- package/dist/internal/memory/adapters/index.js +7 -7
- package/dist/internal/memory/storage/index.cjs +42 -42
- package/dist/internal/memory/storage/index.js +10 -10
- package/dist/internal/persistence/index.cjs +25 -25
- package/dist/internal/persistence/index.js +8 -8
- package/dist/internal/providers/catalog-schema.d.ts +1 -1
- package/dist/internal/runtime/lifecycle/throw-on-error-run.d.ts +18 -0
- package/dist/internal/runtime/model-selection.d.ts +1 -1
- package/dist/internal/runtime/system-prompt/native-reasoning.d.ts +2 -2
- package/dist/internal/runtime/typed-run-error.d.ts +16 -0
- package/dist/internal/security/index.cjs +13 -13
- package/dist/internal/security/index.js +3 -3
- package/dist/judge-call-4LR4IFVT.js +5 -0
- package/dist/{judge-call-LOL5FQEX.js.map → judge-call-4LR4IFVT.js.map} +1 -1
- package/dist/judge-call-ZTUQMQRL.cjs +22 -0
- package/dist/{judge-call-AQQYK6VT.cjs.map → judge-call-ZTUQMQRL.cjs.map} +1 -1
- package/dist/mcp-auth.cjs +14 -14
- package/dist/mcp-auth.js +4 -4
- package/dist/models.cjs +22 -22
- package/dist/models.js +8 -8
- package/dist/oauth-transaction-store-OMX436YB.cjs +38 -0
- package/dist/{oauth-transaction-store-ZINDV7AF.cjs.map → oauth-transaction-store-OMX436YB.cjs.map} +1 -1
- package/dist/oauth-transaction-store-U34YLEGP.js +5 -0
- package/dist/{oauth-transaction-store-NP2YHZ6D.js.map → oauth-transaction-store-U34YLEGP.js.map} +1 -1
- package/dist/path-safety.cjs +10 -10
- package/dist/path-safety.js +3 -3
- package/dist/persistence.cjs +31 -31
- package/dist/persistence.js +10 -10
- package/dist/project.cjs +5 -5
- package/dist/project.js +3 -3
- package/dist/providers.cjs +9 -9
- package/dist/providers.js +7 -7
- package/dist/registry-5TDAF7RK.js +9 -0
- package/dist/{registry-5FK42CRV.js.map → registry-5TDAF7RK.js.map} +1 -1
- package/dist/registry-W7TSCLQO.cjs +46 -0
- package/dist/{registry-BVTNO73E.cjs.map → registry-W7TSCLQO.cjs.map} +1 -1
- package/dist/retry.cjs +4 -4
- package/dist/retry.js +3 -3
- package/dist/{run-until-DG2KXWB2.cjs → run-until-4KHVF7YC.cjs} +8 -4
- package/dist/run-until-4KHVF7YC.cjs.map +1 -0
- package/dist/{run-until-6D6TQ4JN.js → run-until-G6BW2DWM.js} +8 -4
- package/dist/run-until-G6BW2DWM.js.map +1 -0
- package/dist/sandbox/index.cjs +22 -22
- package/dist/sandbox/index.js +4 -4
- package/dist/{run-DsA5Ip2i.d.cts → sdk-agent-4-dXI2GS.d.cts} +1500 -753
- package/dist/{run-DsA5Ip2i.d.ts → sdk-agent-CTOJlWA_.d.ts} +1500 -753
- package/dist/server/auth/index.cjs +22 -22
- package/dist/server/auth/index.js +7 -7
- package/dist/server/errors-envelope.cjs +14 -14
- package/dist/server/errors-envelope.d.cts +2 -3
- package/dist/server/errors-envelope.d.ts +2 -3
- package/dist/server/errors-envelope.js +3 -3
- package/dist/session-transcript-7TZ6HXSX.cjs +62 -0
- package/dist/{session-transcript-RACG7BK2.cjs.map → session-transcript-7TZ6HXSX.cjs.map} +1 -1
- package/dist/session-transcript-BSHZYYY6.js +5 -0
- package/dist/{session-transcript-AR7IBICT.js.map → session-transcript-BSHZYYY6.js.map} +1 -1
- package/dist/skills.cjs +8 -8
- package/dist/skills.js +5 -5
- package/dist/stream-object-R6SMYV4R.js +7 -0
- package/dist/{stream-object-QAEHG4YO.js.map → stream-object-R6SMYV4R.js.map} +1 -1
- package/dist/stream-object-TEEK3CAX.cjs +20 -0
- package/dist/{stream-object-TKVGGA54.cjs.map → stream-object-TEEK3CAX.cjs.map} +1 -1
- package/dist/subagents-loader-TXOA5EJJ.cjs +16 -0
- package/dist/{subagents-loader-5TZCAIYQ.cjs.map → subagents-loader-TXOA5EJJ.cjs.map} +1 -1
- package/dist/subagents-loader-Z744TAKD.js +7 -0
- package/dist/{subagents-loader-PEV3PD4Q.js.map → subagents-loader-Z744TAKD.js.map} +1 -1
- package/dist/subagents-loader.cjs +7 -7
- package/dist/subagents-loader.d.cts +4 -3
- package/dist/subagents-loader.d.ts +4 -3
- package/dist/subagents-loader.js +5 -5
- package/dist/subscription/index.cjs +3 -3
- package/dist/subscription/index.js +2 -2
- package/dist/task-store.cjs +7 -7
- package/dist/task-store.js +4 -4
- package/dist/types/agent-prims.d.ts +16 -0
- package/dist/types/agent.d.ts +15 -6
- package/dist/types/run.d.ts +14 -14
- package/dist/workflow.cjs +27 -27
- package/dist/workflow.d.cts +2 -2
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +6 -6
- package/docs/error-codes.md +24 -23
- package/docs/harness-capability-map.md +4 -4
- package/package.json +1 -1
- package/dist/agent-DFV52V6E.js +0 -62
- package/dist/agent-OKP4LHG2.cjs +0 -71
- package/dist/agent-session-store-ODD3IZCW.js +0 -6
- package/dist/agent-session-store-SVEJHSUA.cjs +0 -23
- package/dist/chunk-35KBC4BX.cjs.map +0 -1
- package/dist/chunk-6LHQPOMI.cjs.map +0 -1
- package/dist/chunk-B5MHRQJZ.js.map +0 -1
- package/dist/chunk-BBJ77S62.js.map +0 -1
- package/dist/chunk-CZJ6Q7CW.js.map +0 -1
- package/dist/chunk-JLIRFWUG.js.map +0 -1
- package/dist/chunk-MHIBYKWA.js.map +0 -1
- package/dist/chunk-N7KS3TIR.cjs.map +0 -1
- package/dist/chunk-P5N3Q2NH.cjs.map +0 -1
- package/dist/chunk-SGC7LSHF.cjs +0 -18
- package/dist/chunk-UNFBHV46.cjs.map +0 -1
- package/dist/compact-session-4HAUP3HK.js +0 -25
- package/dist/context-3FZRAO5K.js +0 -7
- package/dist/context-B5J4GX2F.cjs +0 -24
- package/dist/fs-session-store-3VI4CPTX.js +0 -11
- package/dist/fs-session-store-IQ6PEHYF.cjs +0 -20
- package/dist/generate-object-NTKAWE7D.js +0 -7
- package/dist/generate-object-YHTWG5DB.cjs +0 -20
- package/dist/index-manager-JVYIVTZG.js +0 -18
- package/dist/index-manager-YGXRFJMZ.cjs +0 -27
- package/dist/judge-call-AQQYK6VT.cjs +0 -22
- package/dist/judge-call-LOL5FQEX.js +0 -5
- package/dist/oauth-transaction-store-NP2YHZ6D.js +0 -5
- package/dist/oauth-transaction-store-ZINDV7AF.cjs +0 -38
- package/dist/registry-5FK42CRV.js +0 -9
- package/dist/registry-BVTNO73E.cjs +0 -46
- package/dist/run-until-6D6TQ4JN.js.map +0 -1
- package/dist/run-until-DG2KXWB2.cjs.map +0 -1
- package/dist/sdk-agent-dNwjwCt5.d.cts +0 -940
- package/dist/sdk-agent-wEOLXD3F.d.ts +0 -940
- package/dist/session-transcript-AR7IBICT.js +0 -5
- package/dist/session-transcript-RACG7BK2.cjs +0 -62
- package/dist/stream-object-QAEHG4YO.js +0 -7
- package/dist/stream-object-TKVGGA54.cjs +0 -20
- package/dist/subagents-loader-5TZCAIYQ.cjs +0 -16
- package/dist/subagents-loader-PEV3PD4Q.js +0 -7
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkL7JPXZ2C_cjs = require('./chunk-L7JPXZ2C.cjs');
|
|
4
|
+
var chunkYOVZMN4P_cjs = require('./chunk-YOVZMN4P.cjs');
|
|
5
|
+
var chunkCWQPQTUZ_cjs = require('./chunk-CWQPQTUZ.cjs');
|
|
6
|
+
var chunk7YUPSBDV_cjs = require('./chunk-7YUPSBDV.cjs');
|
|
7
7
|
var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
8
|
+
var chunkCGH4BCIY_cjs = require('./chunk-CGH4BCIY.cjs');
|
|
9
|
+
var chunkRS7YQR4X_cjs = require('./chunk-RS7YQR4X.cjs');
|
|
10
|
+
var chunkSDZ4XDWS_cjs = require('./chunk-SDZ4XDWS.cjs');
|
|
11
|
+
var chunk6OCJWGVD_cjs = require('./chunk-6OCJWGVD.cjs');
|
|
12
|
+
var chunkLSWHDOCL_cjs = require('./chunk-LSWHDOCL.cjs');
|
|
13
13
|
var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
14
|
+
var chunkQG4SXZ2A_cjs = require('./chunk-QG4SXZ2A.cjs');
|
|
15
|
+
var chunkUDAKAE4Z_cjs = require('./chunk-UDAKAE4Z.cjs');
|
|
16
|
+
var chunk3HA7N2BB_cjs = require('./chunk-3HA7N2BB.cjs');
|
|
17
17
|
var chunkAA27GEYS_cjs = require('./chunk-AA27GEYS.cjs');
|
|
18
18
|
var chunkYSTXFWQE_cjs = require('./chunk-YSTXFWQE.cjs');
|
|
19
|
-
var
|
|
19
|
+
var chunkH7HD6RXO_cjs = require('./chunk-H7HD6RXO.cjs');
|
|
20
20
|
var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
|
|
21
|
-
var
|
|
21
|
+
var chunk7WARNHWW_cjs = require('./chunk-7WARNHWW.cjs');
|
|
22
22
|
var chunkIJ7M6GOG_cjs = require('./chunk-IJ7M6GOG.cjs');
|
|
23
|
-
var
|
|
23
|
+
var chunk3KIUY67P_cjs = require('./chunk-3KIUY67P.cjs');
|
|
24
24
|
var chunkSA6K24NB_cjs = require('./chunk-SA6K24NB.cjs');
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
25
|
+
var chunk27V5I2WW_cjs = require('./chunk-27V5I2WW.cjs');
|
|
26
|
+
var chunk3WKWBYPO_cjs = require('./chunk-3WKWBYPO.cjs');
|
|
27
|
+
var chunkG7XBVM3T_cjs = require('./chunk-G7XBVM3T.cjs');
|
|
28
28
|
var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
29
|
+
var chunkZOFRNNZD_cjs = require('./chunk-ZOFRNNZD.cjs');
|
|
30
|
+
var chunkWDVG5R2Q_cjs = require('./chunk-WDVG5R2Q.cjs');
|
|
31
|
+
var chunkYQ3XC6C2_cjs = require('./chunk-YQ3XC6C2.cjs');
|
|
32
|
+
var chunk6XQLTQB6_cjs = require('./chunk-6XQLTQB6.cjs');
|
|
33
|
+
var chunkKX5QXLBS_cjs = require('./chunk-KX5QXLBS.cjs');
|
|
34
|
+
var chunkNWWTYBD3_cjs = require('./chunk-NWWTYBD3.cjs');
|
|
35
35
|
var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var chunkLO6LIUZ6_cjs = require('./chunk-LO6LIUZ6.cjs');
|
|
37
|
+
var chunkS46WJTDL_cjs = require('./chunk-S46WJTDL.cjs');
|
|
38
38
|
var chunkNVXXWAU7_cjs = require('./chunk-NVXXWAU7.cjs');
|
|
39
39
|
var chunkEHD25JBZ_cjs = require('./chunk-EHD25JBZ.cjs');
|
|
40
|
-
var
|
|
41
|
-
var
|
|
40
|
+
var chunkCEGU5AVD_cjs = require('./chunk-CEGU5AVD.cjs');
|
|
41
|
+
var chunkRNXXYF22_cjs = require('./chunk-RNXXYF22.cjs');
|
|
42
42
|
var promises = require('fs/promises');
|
|
43
43
|
var crypto = require('crypto');
|
|
44
44
|
var path = require('path');
|
|
@@ -164,7 +164,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
|
|
|
164
164
|
const { output, maxRetries, errorStrategy, ...sendOptions } = options;
|
|
165
165
|
const run = await agent.send(input, sendOptions);
|
|
166
166
|
const result = await run.wait();
|
|
167
|
-
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-
|
|
167
|
+
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-XBWD2PU7.cjs');
|
|
168
168
|
const answer = structurableAnswerOrThrow(result, GenerateObjectError);
|
|
169
169
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
170
170
|
const facade = getAgentFacade();
|
|
@@ -248,18 +248,59 @@ function isLocalAgentId(id) {
|
|
|
248
248
|
return id.startsWith(PREFIX.localAgent);
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
// src/internal/runtime/lifecycle/throw-on-error-run.ts
|
|
252
|
+
var innerRuns = /* @__PURE__ */ new WeakMap();
|
|
253
|
+
function wrapRunWithThrowOnError(run) {
|
|
254
|
+
let settled;
|
|
255
|
+
const rejectingWait = () => {
|
|
256
|
+
settled ??= run.wait().then(rejectOnTypedFailure);
|
|
257
|
+
return settled;
|
|
258
|
+
};
|
|
259
|
+
const view = new Proxy(run, {
|
|
260
|
+
get(target, prop, receiver) {
|
|
261
|
+
if (prop === "wait") return rejectingWait;
|
|
262
|
+
return Reflect.get(target, prop, receiver);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
innerRuns.set(view, run);
|
|
266
|
+
return view;
|
|
267
|
+
}
|
|
268
|
+
function readRunResolving(run) {
|
|
269
|
+
return (innerRuns.get(run) ?? run).wait();
|
|
270
|
+
}
|
|
271
|
+
function rejectOnTypedFailure(result) {
|
|
272
|
+
const cause = result.status === "error" ? result.error?.cause : void 0;
|
|
273
|
+
if (cause !== void 0) throw cause;
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
|
|
251
277
|
// src/internal/runtime/model-selection.ts
|
|
252
278
|
function normalizeModel(m) {
|
|
253
|
-
if (m === void 0
|
|
279
|
+
if (m === void 0) return m;
|
|
280
|
+
if (typeof m !== "string") {
|
|
281
|
+
refuseEmptyThinkingParam(m);
|
|
282
|
+
return m;
|
|
283
|
+
}
|
|
254
284
|
const id = m.trim();
|
|
255
285
|
if (id.length === 0) {
|
|
256
|
-
throw new
|
|
286
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
257
287
|
'model must be a non-empty "provider/model" id string or a ModelSelection object',
|
|
258
288
|
{ code: "invalid_model_selection" }
|
|
259
289
|
);
|
|
260
290
|
}
|
|
261
291
|
return { id };
|
|
262
292
|
}
|
|
293
|
+
function refuseEmptyThinkingParam(selection) {
|
|
294
|
+
for (const param of selection.params ?? []) {
|
|
295
|
+
const value = param.value;
|
|
296
|
+
if (param.id === "thinking" && (typeof value !== "string" || value.trim().length === 0)) {
|
|
297
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
298
|
+
'model.params "thinking" needs a non-empty reasoning effort (for example "low" or "high"); leave the param out to request no reasoning',
|
|
299
|
+
{ code: "invalid_model_param" }
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
263
304
|
|
|
264
305
|
// src/internal/plugins/enabled-names.ts
|
|
265
306
|
function isPluginArray(plugins) {
|
|
@@ -389,11 +430,11 @@ function serializeAgents(agents2) {
|
|
|
389
430
|
return out;
|
|
390
431
|
}
|
|
391
432
|
function registryPath(cwd) {
|
|
392
|
-
return path.join(
|
|
433
|
+
return path.join(chunkYQ3XC6C2_cjs.theokitConfigRoot(cwd), REGISTRY_RELATIVE_SUFFIX);
|
|
393
434
|
}
|
|
394
435
|
async function loadRegistry(cwd) {
|
|
395
|
-
void
|
|
396
|
-
return
|
|
436
|
+
void chunkZOFRNNZD_cjs.sweepStaleAtomicTemps(registryPath(cwd)).catch(() => void 0);
|
|
437
|
+
return chunk3HA7N2BB_cjs.readVersionedJson({
|
|
397
438
|
path: registryPath(cwd),
|
|
398
439
|
currentVersion: SCHEMA_VERSION,
|
|
399
440
|
defaultValue: () => ({}),
|
|
@@ -417,7 +458,7 @@ async function saveRegistry(cwd, agents2) {
|
|
|
417
458
|
}
|
|
418
459
|
const path = registryPath(cwd);
|
|
419
460
|
await chunkZF2LDKQQ_cjs.withCwdMutex(`registry:${cwd}`, async () => {
|
|
420
|
-
await
|
|
461
|
+
await chunk3HA7N2BB_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
|
|
421
462
|
});
|
|
422
463
|
}
|
|
423
464
|
function toSerialized(agent) {
|
|
@@ -484,7 +525,7 @@ function scheduleSaveForCwd(cwd) {
|
|
|
484
525
|
}
|
|
485
526
|
} catch (cause) {
|
|
486
527
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
487
|
-
|
|
528
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] registry persist failed (${cwd}): ${msg}
|
|
488
529
|
`);
|
|
489
530
|
} finally {
|
|
490
531
|
pendingSaves.delete(cwd);
|
|
@@ -824,14 +865,14 @@ async function readLegacyFacts(jsonPath) {
|
|
|
824
865
|
}
|
|
825
866
|
async function writeMigratedFacts(cwd, jsonPath, facts) {
|
|
826
867
|
try {
|
|
827
|
-
for (const fact of facts) await
|
|
868
|
+
for (const fact of facts) await chunkSDZ4XDWS_cjs.appendFactToMarkdown(cwd, fact);
|
|
828
869
|
await promises.unlink(jsonPath).catch(() => void 0);
|
|
829
|
-
|
|
870
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
|
|
830
871
|
`);
|
|
831
872
|
return { migrated: true, factCount: facts.length };
|
|
832
873
|
} catch (cause) {
|
|
833
874
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
834
|
-
|
|
875
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] memory migration failed (readonly fs?): ${message}
|
|
835
876
|
`);
|
|
836
877
|
return { migrated: false, factCount: 0, reason: "readonly-fs" };
|
|
837
878
|
}
|
|
@@ -841,12 +882,12 @@ async function migrateLegacyJson(cwd, config) {
|
|
|
841
882
|
const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
|
|
842
883
|
if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
|
|
843
884
|
migrationRun.add(key);
|
|
844
|
-
const jsonPath =
|
|
885
|
+
const jsonPath = chunkSDZ4XDWS_cjs.legacyMemoryJsonPath(cwd, config);
|
|
845
886
|
if (!await fileExists(jsonPath)) {
|
|
846
887
|
return { migrated: false, factCount: 0, reason: "no-legacy-json" };
|
|
847
888
|
}
|
|
848
|
-
if (await fileExists(
|
|
849
|
-
|
|
889
|
+
if (await fileExists(chunkSDZ4XDWS_cjs.memoryMdPath(chunkSDZ4XDWS_cjs.resolveMemoryRoot(cwd, config)))) {
|
|
890
|
+
chunkRNXXYF22_cjs.diag(
|
|
850
891
|
`[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
|
|
851
892
|
`
|
|
852
893
|
);
|
|
@@ -874,29 +915,29 @@ function unstoredRememberWarning(message) {
|
|
|
874
915
|
if (isMemoryWritePrompt(message) && extractMemoryFact(message).length > 0) return void 0;
|
|
875
916
|
const trimmed = message.trim();
|
|
876
917
|
const quoted = trimmed.length > QUOTED_MESSAGE_MAX ? `${trimmed.slice(0, QUOTED_MESSAGE_MAX)}\u2026` : trimmed;
|
|
877
|
-
return `[theokit-sdk] NOTHING WAS STORED \u2014 this message does not match the memory capture pattern: ${JSON.stringify(quoted)}. Supported: "Remember: <fact>" or "Remember (${
|
|
918
|
+
return `[theokit-sdk] NOTHING WAS STORED \u2014 this message does not match the memory capture pattern: ${JSON.stringify(quoted)}. Supported: "Remember: <fact>" or "Remember (${chunkSDZ4XDWS_cjs.MEMORY_KINDS.join("|")}): <fact>". It still reaches the session transcript, so a follow-up may answer from it \u2014 that is search over transcripts, not a durable memory.`;
|
|
878
919
|
}
|
|
879
920
|
function extractMemoryKind(message) {
|
|
880
921
|
const match = REMEMBER_PATTERN.exec(message);
|
|
881
922
|
const declared = match?.[1];
|
|
882
923
|
if (declared === void 0) return void 0;
|
|
883
924
|
const lowered = declared.toLowerCase();
|
|
884
|
-
return
|
|
925
|
+
return chunkSDZ4XDWS_cjs.MEMORY_KINDS.includes(lowered) ? lowered : void 0;
|
|
885
926
|
}
|
|
886
927
|
async function readMemoryFacts(cwd, config) {
|
|
887
928
|
if (!config.enabled) return [];
|
|
888
929
|
await migrateLegacyJson(cwd, config);
|
|
889
|
-
return
|
|
930
|
+
return chunkSDZ4XDWS_cjs.readFacts(cwd, config);
|
|
890
931
|
}
|
|
891
932
|
async function appendMemoryFact(cwd, config, fact) {
|
|
892
933
|
if (!config.enabled) return;
|
|
893
|
-
|
|
934
|
+
chunkSDZ4XDWS_cjs.resolveMaxFacts(config.maxFacts);
|
|
894
935
|
await migrateLegacyJson(cwd, config);
|
|
895
936
|
const sanitized = {
|
|
896
|
-
text:
|
|
937
|
+
text: chunkRNXXYF22_cjs.redactSecrets(fact.text),
|
|
897
938
|
...fact.kind === void 0 ? {} : { kind: fact.kind }
|
|
898
939
|
};
|
|
899
|
-
await
|
|
940
|
+
await chunkSDZ4XDWS_cjs.appendFact(cwd, config, sanitized);
|
|
900
941
|
}
|
|
901
942
|
|
|
902
943
|
// src/internal/runtime/fixtures/fixture-scripts.ts
|
|
@@ -1244,7 +1285,7 @@ function redactScriptSecrets(script) {
|
|
|
1244
1285
|
function redactEventSecrets(event) {
|
|
1245
1286
|
const serialized = JSON.stringify(event);
|
|
1246
1287
|
const localStripped = serialized.replace(FIXTURE_SENTINEL, "***");
|
|
1247
|
-
const redacted =
|
|
1288
|
+
const redacted = chunkRNXXYF22_cjs.redactSecrets(localStripped);
|
|
1248
1289
|
if (redacted === serialized) return event;
|
|
1249
1290
|
return JSON.parse(redacted);
|
|
1250
1291
|
}
|
|
@@ -1253,6 +1294,21 @@ function applyExtraRunFields(base, script) {
|
|
|
1253
1294
|
return { ...base, ...script.extraRunFields };
|
|
1254
1295
|
}
|
|
1255
1296
|
|
|
1297
|
+
// src/internal/runtime/typed-run-error.ts
|
|
1298
|
+
function toTypedRunErrorDetail(detail) {
|
|
1299
|
+
if (detail === void 0) return void 0;
|
|
1300
|
+
if (hasTypedCause(detail)) return detail;
|
|
1301
|
+
const { cause } = detail;
|
|
1302
|
+
const wrapped = new chunkCEGU5AVD_cjs.UnknownAgentError(detail.message, {
|
|
1303
|
+
...detail.code !== void 0 ? { code: detail.code } : {},
|
|
1304
|
+
...cause !== void 0 ? { cause } : {}
|
|
1305
|
+
});
|
|
1306
|
+
return { ...detail, cause: wrapped };
|
|
1307
|
+
}
|
|
1308
|
+
function hasTypedCause(detail) {
|
|
1309
|
+
return detail.cause instanceof chunkCEGU5AVD_cjs.TheokitAgentError;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1256
1312
|
// src/internal/runtime/fixtures/fixture-run-base.ts
|
|
1257
1313
|
function prepareRunContext(message) {
|
|
1258
1314
|
const userText = typeof message === "string" ? message : message.text;
|
|
@@ -1439,7 +1495,7 @@ var FixtureRunBase = class {
|
|
|
1439
1495
|
base.result = this.script.result;
|
|
1440
1496
|
}
|
|
1441
1497
|
if (status === "error" && this.script.errorDetail !== void 0) {
|
|
1442
|
-
base.error = this.script.errorDetail;
|
|
1498
|
+
base.error = toTypedRunErrorDetail(this.script.errorDetail);
|
|
1443
1499
|
}
|
|
1444
1500
|
applyScriptMetrics(base, this.script);
|
|
1445
1501
|
return this.extendRunResult(applyExtraRunFields(base, this.script));
|
|
@@ -1566,8 +1622,8 @@ function createRealCloudRun(options) {
|
|
|
1566
1622
|
cancellable: false,
|
|
1567
1623
|
conversation: []
|
|
1568
1624
|
};
|
|
1569
|
-
const apiKey =
|
|
1570
|
-
const baseUrl =
|
|
1625
|
+
const apiKey = chunkRNXXYF22_cjs.resolveApiKey(options.agentOptions.apiKey);
|
|
1626
|
+
const baseUrl = chunkLSWHDOCL_cjs.getConfiguredBaseUrl();
|
|
1571
1627
|
const handle = new RealCloudRun(
|
|
1572
1628
|
{
|
|
1573
1629
|
id,
|
|
@@ -1640,7 +1696,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1640
1696
|
});
|
|
1641
1697
|
if (!response.ok) {
|
|
1642
1698
|
const text = await response.text().catch(() => "");
|
|
1643
|
-
throw new
|
|
1699
|
+
throw new chunkCEGU5AVD_cjs.NetworkError(
|
|
1644
1700
|
`Cloud Run endpoint returned ${response.status}: ${text.slice(0, 200)}`,
|
|
1645
1701
|
{ code: "cloud_run_http_error" }
|
|
1646
1702
|
);
|
|
@@ -1650,7 +1706,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1650
1706
|
async consumeStream(response) {
|
|
1651
1707
|
let finalStatus = "finished";
|
|
1652
1708
|
let finalText = "";
|
|
1653
|
-
for await (const record of
|
|
1709
|
+
for await (const record of chunkLSWHDOCL_cjs.parseSseStream(response.body, this.controller.signal)) {
|
|
1654
1710
|
const parsed = safeParse(record.data);
|
|
1655
1711
|
if (parsed === void 0) continue;
|
|
1656
1712
|
const update = this.applyRecord(record.event, parsed);
|
|
@@ -1730,7 +1786,7 @@ function toWireStatus(token) {
|
|
|
1730
1786
|
const match = WIRE_STATUSES.find((candidate) => candidate === upper);
|
|
1731
1787
|
if (match !== void 0) return match;
|
|
1732
1788
|
}
|
|
1733
|
-
throw new
|
|
1789
|
+
throw new chunkCEGU5AVD_cjs.NetworkError(
|
|
1734
1790
|
`Cloud Run stream reported an unrecognised status ${JSON.stringify(token)}; expected one of ${WIRE_STATUSES.join(", ")} (case-insensitive)`,
|
|
1735
1791
|
{ code: "cloud_run_unknown_status" }
|
|
1736
1792
|
);
|
|
@@ -1740,7 +1796,7 @@ function toRunStatus(token) {
|
|
|
1740
1796
|
const mapped = SERVER_STATUS_TO_RUN_STATUS[token.toLowerCase()];
|
|
1741
1797
|
if (mapped !== void 0) return mapped;
|
|
1742
1798
|
}
|
|
1743
|
-
throw new
|
|
1799
|
+
throw new chunkCEGU5AVD_cjs.NetworkError(
|
|
1744
1800
|
`Cloud Run stream reported an unrecognised status ${JSON.stringify(token)}; expected one of ${Object.keys(SERVER_STATUS_TO_RUN_STATUS).join(", ")} (case-insensitive)`,
|
|
1745
1801
|
{ code: "cloud_run_unknown_status" }
|
|
1746
1802
|
);
|
|
@@ -1816,8 +1872,8 @@ var CloudAgent = class _CloudAgent {
|
|
|
1816
1872
|
* cloud operations are pre-release and must surface explicit errors.
|
|
1817
1873
|
*/
|
|
1818
1874
|
isFixtureMode() {
|
|
1819
|
-
const apiKey =
|
|
1820
|
-
return
|
|
1875
|
+
const apiKey = chunkRNXXYF22_cjs.resolveApiKey(this.options.apiKey);
|
|
1876
|
+
return chunkLSWHDOCL_cjs.isFixtureApiKey(apiKey) && chunkLSWHDOCL_cjs.getConfiguredBaseUrl() === void 0;
|
|
1821
1877
|
}
|
|
1822
1878
|
// SE9 — integrated structured output; delegates to the shared helper.
|
|
1823
1879
|
generate(message, options) {
|
|
@@ -1831,9 +1887,9 @@ var CloudAgent = class _CloudAgent {
|
|
|
1831
1887
|
);
|
|
1832
1888
|
}
|
|
1833
1889
|
async send(message, options = {}) {
|
|
1834
|
-
if (this.disposed) throw new
|
|
1890
|
+
if (this.disposed) throw new chunkCEGU5AVD_cjs.AgentDisposedError(this.agentId);
|
|
1835
1891
|
if (options.tools !== void 0 && options.tools.length > 0) {
|
|
1836
|
-
throw new
|
|
1892
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
1837
1893
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
1838
1894
|
{ code: "cloud_custom_tools_rejected" }
|
|
1839
1895
|
);
|
|
@@ -1851,10 +1907,13 @@ var CloudAgent = class _CloudAgent {
|
|
|
1851
1907
|
reject(err);
|
|
1852
1908
|
return;
|
|
1853
1909
|
}
|
|
1854
|
-
resolve(run);
|
|
1910
|
+
resolve(this.options.throwOnError === true ? wrapRunWithThrowOnError(run) : run);
|
|
1855
1911
|
const mutexTimeoutMs = Number(process.env.THEOKIT_CLOUD_SEND_MUTEX_TIMEOUT_MS) || 3e5;
|
|
1856
1912
|
try {
|
|
1857
|
-
await Promise.race([
|
|
1913
|
+
await Promise.race([
|
|
1914
|
+
readRunResolving(run),
|
|
1915
|
+
new Promise((r) => setTimeout(r, mutexTimeoutMs))
|
|
1916
|
+
]);
|
|
1858
1917
|
} catch {
|
|
1859
1918
|
}
|
|
1860
1919
|
});
|
|
@@ -1868,8 +1927,8 @@ var CloudAgent = class _CloudAgent {
|
|
|
1868
1927
|
}
|
|
1869
1928
|
const userText = typeof message === "string" ? message : message.text;
|
|
1870
1929
|
const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
|
|
1871
|
-
const apiKey =
|
|
1872
|
-
const useRealRuntime = apiKey !== void 0 && !
|
|
1930
|
+
const apiKey = chunkRNXXYF22_cjs.resolveApiKey(this.options.apiKey);
|
|
1931
|
+
const useRealRuntime = apiKey !== void 0 && !chunkLSWHDOCL_cjs.isFixtureApiKey(apiKey) && chunkLSWHDOCL_cjs.getConfiguredBaseUrl() !== void 0;
|
|
1873
1932
|
return useRealRuntime ? createRealCloudRun({
|
|
1874
1933
|
agentId: this.agentId,
|
|
1875
1934
|
model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
|
|
@@ -1918,7 +1977,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
1918
1977
|
listArtifacts() {
|
|
1919
1978
|
if (!this.isFixtureMode()) {
|
|
1920
1979
|
return Promise.reject(
|
|
1921
|
-
new
|
|
1980
|
+
new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
1922
1981
|
"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).",
|
|
1923
1982
|
{ code: "cloud_runtime_pre_release" }
|
|
1924
1983
|
)
|
|
@@ -1928,11 +1987,11 @@ var CloudAgent = class _CloudAgent {
|
|
|
1928
1987
|
}
|
|
1929
1988
|
downloadArtifact(path) {
|
|
1930
1989
|
try {
|
|
1931
|
-
|
|
1990
|
+
chunk3KIUY67P_cjs.validateArtifactPath(path);
|
|
1932
1991
|
} catch (cause) {
|
|
1933
|
-
if (cause instanceof
|
|
1992
|
+
if (cause instanceof chunk3KIUY67P_cjs.PathTraversalError) {
|
|
1934
1993
|
return Promise.reject(
|
|
1935
|
-
new
|
|
1994
|
+
new chunkCEGU5AVD_cjs.ConfigurationError(`Artifact path must stay inside the workspace: ${path}`, {
|
|
1936
1995
|
code: "artifact_path_traversal",
|
|
1937
1996
|
cause
|
|
1938
1997
|
})
|
|
@@ -1942,7 +2001,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
1942
2001
|
}
|
|
1943
2002
|
if (!this.isFixtureMode()) {
|
|
1944
2003
|
return Promise.reject(
|
|
1945
|
-
new
|
|
2004
|
+
new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
1946
2005
|
"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).",
|
|
1947
2006
|
{ code: "cloud_runtime_pre_release" }
|
|
1948
2007
|
)
|
|
@@ -1951,7 +2010,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
1951
2010
|
const match = buildFixtureArtifacts().find((artifact) => artifact.path === path);
|
|
1952
2011
|
if (match === void 0) {
|
|
1953
2012
|
return Promise.reject(
|
|
1954
|
-
new
|
|
2013
|
+
new chunkCEGU5AVD_cjs.UnknownAgentError(`Artifact ${path} not found`, { code: "unknown_artifact" })
|
|
1955
2014
|
);
|
|
1956
2015
|
}
|
|
1957
2016
|
return Promise.resolve(Buffer.from(`fixture artifact content for ${path}
|
|
@@ -1965,7 +2024,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
1965
2024
|
* @public
|
|
1966
2025
|
*/
|
|
1967
2026
|
runUntil() {
|
|
1968
|
-
throw new
|
|
2027
|
+
throw new chunkCEGU5AVD_cjs.UnsupportedRunOperationError(
|
|
1969
2028
|
"Agent.runUntil() is not supported on cloud agents. Cloud runtime manages goal loops server-side. Use a local agent for autonomous Ralph loops.",
|
|
1970
2029
|
"runUntil"
|
|
1971
2030
|
);
|
|
@@ -1976,7 +2035,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
1976
2035
|
* @public
|
|
1977
2036
|
*/
|
|
1978
2037
|
fork() {
|
|
1979
|
-
throw new
|
|
2038
|
+
throw new chunkCEGU5AVD_cjs.UnsupportedRunOperationError(
|
|
1980
2039
|
"Agent.fork() is not supported on cloud agents. Fork inheritance requires local credential + system-prompt access. Use a local agent.",
|
|
1981
2040
|
"fork"
|
|
1982
2041
|
);
|
|
@@ -1988,7 +2047,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
1988
2047
|
* @public
|
|
1989
2048
|
*/
|
|
1990
2049
|
runToCompletion() {
|
|
1991
|
-
throw new
|
|
2050
|
+
throw new chunkCEGU5AVD_cjs.UnsupportedRunOperationError(
|
|
1992
2051
|
"Agent.runToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
1993
2052
|
"runToCompletion"
|
|
1994
2053
|
);
|
|
@@ -2000,7 +2059,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
2000
2059
|
* @public
|
|
2001
2060
|
*/
|
|
2002
2061
|
streamToCompletion() {
|
|
2003
|
-
throw new
|
|
2062
|
+
throw new chunkCEGU5AVD_cjs.UnsupportedRunOperationError(
|
|
2004
2063
|
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
2005
2064
|
"streamToCompletion"
|
|
2006
2065
|
);
|
|
@@ -2014,7 +2073,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
2014
2073
|
*/
|
|
2015
2074
|
usePersonality() {
|
|
2016
2075
|
return Promise.reject(
|
|
2017
|
-
new
|
|
2076
|
+
new chunkCEGU5AVD_cjs.UnsupportedRunOperationError(
|
|
2018
2077
|
"Agent.usePersonality() is not supported on cloud agents (pre-release). Use a local agent or wait for cloud GA.",
|
|
2019
2078
|
"usePersonality"
|
|
2020
2079
|
)
|
|
@@ -2042,7 +2101,7 @@ function validateCloudToolParity(options) {
|
|
|
2042
2101
|
function rejectProcessors(options) {
|
|
2043
2102
|
const hasProcessors = (options.inputProcessors?.length ?? 0) > 0 || (options.outputProcessors?.length ?? 0) > 0;
|
|
2044
2103
|
if (hasProcessors) {
|
|
2045
|
-
throw new
|
|
2104
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
2046
2105
|
"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.",
|
|
2047
2106
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2048
2107
|
);
|
|
@@ -2050,7 +2109,7 @@ function rejectProcessors(options) {
|
|
|
2050
2109
|
}
|
|
2051
2110
|
function rejectFunctionSystemPrompt(options) {
|
|
2052
2111
|
if (typeof options.systemPrompt === "function") {
|
|
2053
|
-
throw new
|
|
2112
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
2054
2113
|
"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.",
|
|
2055
2114
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2056
2115
|
);
|
|
@@ -2058,7 +2117,7 @@ function rejectFunctionSystemPrompt(options) {
|
|
|
2058
2117
|
}
|
|
2059
2118
|
function rejectFunctionSkills(options) {
|
|
2060
2119
|
if (typeof options.skills === "function") {
|
|
2061
|
-
throw new
|
|
2120
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
2062
2121
|
"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.",
|
|
2063
2122
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2064
2123
|
);
|
|
@@ -2070,7 +2129,7 @@ function rejectStdioMcpLocalPaths(options) {
|
|
|
2070
2129
|
if (!isStdioCommandConfig(config)) continue;
|
|
2071
2130
|
const command = config.command ?? "";
|
|
2072
2131
|
if (isLocalPath(command)) {
|
|
2073
|
-
throw new
|
|
2132
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
2074
2133
|
`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.`,
|
|
2075
2134
|
{ code: "cloud_incompatible_mcp_stdio_local" }
|
|
2076
2135
|
);
|
|
@@ -2090,19 +2149,19 @@ function isLocalPath(command) {
|
|
|
2090
2149
|
function resolveSessionDir(local) {
|
|
2091
2150
|
if (local?.sessionDir !== void 0) {
|
|
2092
2151
|
if (local.baseDir !== void 0) {
|
|
2093
|
-
|
|
2152
|
+
chunkRNXXYF22_cjs.diag(
|
|
2094
2153
|
"[theokit-sdk] local.sessionDir and local.baseDir are both set; using sessionDir. baseDir is the deprecated name for the same option (#301)."
|
|
2095
2154
|
);
|
|
2096
2155
|
}
|
|
2097
|
-
return
|
|
2156
|
+
return chunk3WKWBYPO_cjs.expandTilde(local.sessionDir);
|
|
2098
2157
|
}
|
|
2099
2158
|
if (local?.baseDir !== void 0) {
|
|
2100
|
-
|
|
2159
|
+
chunkRNXXYF22_cjs.diag(
|
|
2101
2160
|
"[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."
|
|
2102
2161
|
);
|
|
2103
|
-
return
|
|
2162
|
+
return chunk3WKWBYPO_cjs.expandTilde(local.baseDir);
|
|
2104
2163
|
}
|
|
2105
|
-
return
|
|
2164
|
+
return chunk3WKWBYPO_cjs.defaultBaseDir();
|
|
2106
2165
|
}
|
|
2107
2166
|
var SCHEMA_VERSION2 = 1;
|
|
2108
2167
|
var FILE_NAME = "personality.json";
|
|
@@ -2129,14 +2188,14 @@ async function readState(filePath) {
|
|
|
2129
2188
|
try {
|
|
2130
2189
|
parsed = JSON.parse(raw);
|
|
2131
2190
|
} catch {
|
|
2132
|
-
|
|
2191
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
2133
2192
|
"personality-store-json-parse",
|
|
2134
2193
|
"[theokit-sdk] personality.json is malformed; treating as empty"
|
|
2135
2194
|
);
|
|
2136
2195
|
return emptyState();
|
|
2137
2196
|
}
|
|
2138
2197
|
if (!isStateV1(parsed)) {
|
|
2139
|
-
|
|
2198
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
2140
2199
|
"personality-store-bad-version",
|
|
2141
2200
|
`[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
|
|
2142
2201
|
);
|
|
@@ -2167,9 +2226,9 @@ var PersonalityStore = class {
|
|
|
2167
2226
|
try {
|
|
2168
2227
|
await this.#persist(agentId, slug);
|
|
2169
2228
|
} catch (err) {
|
|
2170
|
-
|
|
2229
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
2171
2230
|
`personality-store-persist-failure-${agentId}`,
|
|
2172
|
-
`[theokit-sdk] personality persist failed for ${
|
|
2231
|
+
`[theokit-sdk] personality persist failed for ${chunkRNXXYF22_cjs.redactSecrets(agentId)}: ${chunkRNXXYF22_cjs.redactSecrets(
|
|
2173
2232
|
err.message
|
|
2174
2233
|
)}`
|
|
2175
2234
|
);
|
|
@@ -2184,9 +2243,9 @@ var PersonalityStore = class {
|
|
|
2184
2243
|
try {
|
|
2185
2244
|
state = await readState(filePath);
|
|
2186
2245
|
} catch (err) {
|
|
2187
|
-
|
|
2246
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
2188
2247
|
`personality-store-hydrate-failure-${agentId}`,
|
|
2189
|
-
`[theokit-sdk] personality hydrate failed for ${
|
|
2248
|
+
`[theokit-sdk] personality hydrate failed for ${chunkRNXXYF22_cjs.redactSecrets(agentId)}: ${chunkRNXXYF22_cjs.redactSecrets(
|
|
2190
2249
|
err.message
|
|
2191
2250
|
)}`
|
|
2192
2251
|
);
|
|
@@ -2203,17 +2262,17 @@ var PersonalityStore = class {
|
|
|
2203
2262
|
async #persist(agentId, slug) {
|
|
2204
2263
|
const filePath = this.#filePath();
|
|
2205
2264
|
await promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
2206
|
-
await
|
|
2265
|
+
await chunkG7XBVM3T_cjs.withFileLock(filePath, async () => {
|
|
2207
2266
|
const current = await readState(filePath);
|
|
2208
2267
|
const nextAgents = { ...current.agents };
|
|
2209
2268
|
if (slug === void 0) delete nextAgents[agentId];
|
|
2210
2269
|
else nextAgents[agentId] = slug;
|
|
2211
2270
|
const next = { version: SCHEMA_VERSION2, agents: nextAgents };
|
|
2212
|
-
await
|
|
2271
|
+
await chunkZOFRNNZD_cjs.atomicWriteJson(filePath, next);
|
|
2213
2272
|
});
|
|
2214
2273
|
}
|
|
2215
2274
|
#filePath() {
|
|
2216
|
-
return path.join(
|
|
2275
|
+
return path.join(chunkYQ3XC6C2_cjs.getTheokitHome(this.#cwd), FILE_NAME);
|
|
2217
2276
|
}
|
|
2218
2277
|
};
|
|
2219
2278
|
|
|
@@ -2248,7 +2307,7 @@ function createPluginContext() {
|
|
|
2248
2307
|
},
|
|
2249
2308
|
on(hook, handler) {
|
|
2250
2309
|
if (typeof handler !== "function") {
|
|
2251
|
-
|
|
2310
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] ignoring non-function handler for hook "${hook}"
|
|
2252
2311
|
`);
|
|
2253
2312
|
return () => void 0;
|
|
2254
2313
|
}
|
|
@@ -2302,7 +2361,7 @@ var PluginManager = class {
|
|
|
2302
2361
|
const seen = /* @__PURE__ */ new Set();
|
|
2303
2362
|
for (const plugin of plugins) {
|
|
2304
2363
|
if (seen.has(plugin.name)) {
|
|
2305
|
-
|
|
2364
|
+
chunkRNXXYF22_cjs.diag(
|
|
2306
2365
|
`[theokit-sdk] duplicate plugin name "${plugin.name}" \u2014 both will register independently
|
|
2307
2366
|
`
|
|
2308
2367
|
);
|
|
@@ -2329,7 +2388,7 @@ var PluginManager = class {
|
|
|
2329
2388
|
*/
|
|
2330
2389
|
async register(plugin) {
|
|
2331
2390
|
if (plugin.kind !== "general") {
|
|
2332
|
-
throw new
|
|
2391
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
2333
2392
|
`late register supports general plugins only (got "${plugin.kind}" for "${plugin.name}")`,
|
|
2334
2393
|
{ code: "plugin_late_register_kind" }
|
|
2335
2394
|
);
|
|
@@ -2386,7 +2445,7 @@ var PluginManager = class {
|
|
|
2386
2445
|
parts.push(result.recalledContext);
|
|
2387
2446
|
}
|
|
2388
2447
|
} catch (err) {
|
|
2389
|
-
|
|
2448
|
+
chunkRNXXYF22_cjs.diag(
|
|
2390
2449
|
`[theokit-sdk] pre_user_send hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2391
2450
|
`
|
|
2392
2451
|
);
|
|
@@ -2414,7 +2473,7 @@ var PluginManager = class {
|
|
|
2414
2473
|
try {
|
|
2415
2474
|
await h(ctx);
|
|
2416
2475
|
} catch (err) {
|
|
2417
|
-
|
|
2476
|
+
chunkRNXXYF22_cjs.diag(
|
|
2418
2477
|
`[theokit-sdk] post_assistant_reply hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2419
2478
|
`
|
|
2420
2479
|
);
|
|
@@ -2430,7 +2489,7 @@ var PluginManager = class {
|
|
|
2430
2489
|
try {
|
|
2431
2490
|
await h(ctx);
|
|
2432
2491
|
} catch (err) {
|
|
2433
|
-
|
|
2492
|
+
chunkRNXXYF22_cjs.diag(
|
|
2434
2493
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2435
2494
|
`
|
|
2436
2495
|
);
|
|
@@ -2445,7 +2504,7 @@ var PluginManager = class {
|
|
|
2445
2504
|
const out = await h(current, ctx);
|
|
2446
2505
|
if (out !== void 0) current = out;
|
|
2447
2506
|
} catch (err) {
|
|
2448
|
-
|
|
2507
|
+
chunkRNXXYF22_cjs.diag(
|
|
2449
2508
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2450
2509
|
`
|
|
2451
2510
|
);
|
|
@@ -2530,7 +2589,7 @@ function removeAll(arr, toRemove) {
|
|
|
2530
2589
|
}
|
|
2531
2590
|
}
|
|
2532
2591
|
function readCompatConfigFile(cwd) {
|
|
2533
|
-
const path$1 = path.join(
|
|
2592
|
+
const path$1 = path.join(chunkYQ3XC6C2_cjs.theokitConfigRoot(cwd), "config.json");
|
|
2534
2593
|
if (!fs.existsSync(path$1)) return [];
|
|
2535
2594
|
let raw;
|
|
2536
2595
|
try {
|
|
@@ -2542,7 +2601,7 @@ function readCompatConfigFile(cwd) {
|
|
|
2542
2601
|
try {
|
|
2543
2602
|
parsed = JSON.parse(raw);
|
|
2544
2603
|
} catch (cause) {
|
|
2545
|
-
|
|
2604
|
+
chunkRNXXYF22_cjs.diag(
|
|
2546
2605
|
`[theokit] ${path$1} is not valid JSON \u2014 ignoring its "compat.adapters" (${cause.message}).
|
|
2547
2606
|
`
|
|
2548
2607
|
);
|
|
@@ -2551,7 +2610,7 @@ function readCompatConfigFile(cwd) {
|
|
|
2551
2610
|
const adapters = parsed.compat?.adapters;
|
|
2552
2611
|
if (adapters === void 0) return [];
|
|
2553
2612
|
if (!Array.isArray(adapters)) {
|
|
2554
|
-
|
|
2613
|
+
chunkRNXXYF22_cjs.diag(`[theokit] ${path$1}: "compat.adapters" must be an array \u2014 ignoring it.
|
|
2555
2614
|
`);
|
|
2556
2615
|
return [];
|
|
2557
2616
|
}
|
|
@@ -2593,7 +2652,7 @@ function readPolicyDocument(path) {
|
|
|
2593
2652
|
try {
|
|
2594
2653
|
raw = fs.readFileSync(path, "utf8");
|
|
2595
2654
|
} catch (cause) {
|
|
2596
|
-
|
|
2655
|
+
chunkRNXXYF22_cjs.diagFailure(
|
|
2597
2656
|
`[theokit-sdk] ${path} exists and could not be read (${cause.message}) \u2014 NO operator policy is being applied. Fix the permissions or remove the file.
|
|
2598
2657
|
`
|
|
2599
2658
|
);
|
|
@@ -2603,14 +2662,14 @@ function readPolicyDocument(path) {
|
|
|
2603
2662
|
try {
|
|
2604
2663
|
parsed = JSON.parse(raw);
|
|
2605
2664
|
} catch (cause) {
|
|
2606
|
-
|
|
2665
|
+
chunkRNXXYF22_cjs.diagFailure(
|
|
2607
2666
|
`[theokit-sdk] ${path} is not valid JSON (${cause.message}) \u2014 NO operator policy is being applied.
|
|
2608
2667
|
`
|
|
2609
2668
|
);
|
|
2610
2669
|
return void 0;
|
|
2611
2670
|
}
|
|
2612
2671
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
2613
|
-
|
|
2672
|
+
chunkRNXXYF22_cjs.diagFailure(
|
|
2614
2673
|
`[theokit-sdk] ${path} is not a JSON object \u2014 NO operator policy is being applied.
|
|
2615
2674
|
`
|
|
2616
2675
|
);
|
|
@@ -2640,7 +2699,7 @@ function applyPolicyKey(out, key, value, path) {
|
|
|
2640
2699
|
if (key === "disableSkillShellExecution") out.disableSkillShellExecution = flag;
|
|
2641
2700
|
}
|
|
2642
2701
|
function decline(path, key, reason) {
|
|
2643
|
-
|
|
2702
|
+
chunkRNXXYF22_cjs.diagFailure(`[theokit-sdk] ${path} declares "${key}" \u2014 ${reason}. It is NOT being applied.
|
|
2644
2703
|
`);
|
|
2645
2704
|
}
|
|
2646
2705
|
function readMode(value, path) {
|
|
@@ -2733,7 +2792,7 @@ var HooksExecutor = class {
|
|
|
2733
2792
|
config = {};
|
|
2734
2793
|
async initialize(settingSourcesIncludeProject) {
|
|
2735
2794
|
if (readManagedSettings(this.policy.managedSettingsRoot).disableAllHooks === true) {
|
|
2736
|
-
|
|
2795
|
+
chunkUDAKAE4Z_cjs.warnFailureOnce(
|
|
2737
2796
|
"hooks-disabled-by-policy",
|
|
2738
2797
|
"[theokit-sdk] hooks: an operator policy (managed-settings.json) declares disableAllHooks \u2014 NO hook will run, including any this project declared."
|
|
2739
2798
|
);
|
|
@@ -2744,7 +2803,7 @@ var HooksExecutor = class {
|
|
|
2744
2803
|
this.config = {};
|
|
2745
2804
|
return;
|
|
2746
2805
|
}
|
|
2747
|
-
this.config = await
|
|
2806
|
+
this.config = await chunkUDAKAE4Z_cjs.loadHookConfig(this.cwd, this.compatSources);
|
|
2748
2807
|
}
|
|
2749
2808
|
/** Fire every hook registered for `event` and aggregate the decisions. */
|
|
2750
2809
|
async run(payload) {
|
|
@@ -2839,7 +2898,7 @@ var HooksExecutor = class {
|
|
|
2839
2898
|
if (result.exitCode === 0) return void 0;
|
|
2840
2899
|
const stderr = result.stderr.trim();
|
|
2841
2900
|
const base = stderr.length > 0 ? stderr : `Hook exited with code ${result.exitCode}`;
|
|
2842
|
-
const missing =
|
|
2901
|
+
const missing = chunkYQ3XC6C2_cjs.undefinedVariablesIn(command.command, env);
|
|
2843
2902
|
if (missing.length === 0) return { decision: "deny", reason: base };
|
|
2844
2903
|
return {
|
|
2845
2904
|
decision: "deny",
|
|
@@ -2859,7 +2918,7 @@ function stdinPayloadFor(payload, command, cwd) {
|
|
|
2859
2918
|
}
|
|
2860
2919
|
function runtimeEnvFor(sourcePath, cwd) {
|
|
2861
2920
|
if (sourcePath === void 0) return {};
|
|
2862
|
-
return
|
|
2921
|
+
return chunkYQ3XC6C2_cjs.adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
|
|
2863
2922
|
}
|
|
2864
2923
|
function parseDecisionFromStdout(stdout) {
|
|
2865
2924
|
const trimmed = stdout.trim();
|
|
@@ -2907,11 +2966,11 @@ function sessionTranscriptAllowed(memory) {
|
|
|
2907
2966
|
}
|
|
2908
2967
|
function resolveWindowForRun(model, contextWindow) {
|
|
2909
2968
|
const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
|
|
2910
|
-
return
|
|
2969
|
+
return chunkKX5QXLBS_cjs.resolveEffectiveContextWindow({
|
|
2911
2970
|
...override !== void 0 ? { override } : {},
|
|
2912
|
-
catalog:
|
|
2913
|
-
margin:
|
|
2914
|
-
floor:
|
|
2971
|
+
catalog: chunkS46WJTDL_cjs.getCatalogModelInfo(model)?.limit?.context,
|
|
2972
|
+
margin: chunkKX5QXLBS_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2973
|
+
floor: chunkKX5QXLBS_cjs.CONTEXT_WINDOW_FLOOR
|
|
2915
2974
|
});
|
|
2916
2975
|
}
|
|
2917
2976
|
async function runPostRunLifecycle(inputs) {
|
|
@@ -2929,37 +2988,37 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2929
2988
|
} = inputs;
|
|
2930
2989
|
let result;
|
|
2931
2990
|
try {
|
|
2932
|
-
result = await run
|
|
2991
|
+
result = await readRunResolving(run);
|
|
2933
2992
|
} catch {
|
|
2934
2993
|
try {
|
|
2935
2994
|
const partial = await safeConversation(run);
|
|
2936
2995
|
if (partial !== void 0) {
|
|
2937
|
-
|
|
2996
|
+
chunkYOVZMN4P_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2938
2997
|
userText,
|
|
2939
2998
|
conversation: partial
|
|
2940
2999
|
});
|
|
2941
3000
|
}
|
|
2942
3001
|
} catch (cause) {
|
|
2943
3002
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2944
|
-
|
|
3003
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2945
3004
|
`);
|
|
2946
3005
|
}
|
|
2947
|
-
await
|
|
3006
|
+
await chunkYOVZMN4P_cjs.flushSessionWrites();
|
|
2948
3007
|
return;
|
|
2949
3008
|
}
|
|
2950
3009
|
if (result.result !== void 0) {
|
|
2951
|
-
|
|
3010
|
+
chunkYOVZMN4P_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2952
3011
|
}
|
|
2953
3012
|
const conversation = await safeConversation(run);
|
|
2954
3013
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2955
3014
|
const effectiveWindow = resolvedWindow.window;
|
|
2956
3015
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2957
3016
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2958
|
-
|
|
3017
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(onRunEvent, budgetEvent);
|
|
2959
3018
|
}
|
|
2960
3019
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2961
3020
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2962
|
-
|
|
3021
|
+
chunkYOVZMN4P_cjs.persistTurnToTranscript(
|
|
2963
3022
|
sessionStore,
|
|
2964
3023
|
{ cwd: workspaceCwd, agentId, model },
|
|
2965
3024
|
agentId,
|
|
@@ -2971,20 +3030,20 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2971
3030
|
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2972
3031
|
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2973
3032
|
contextWindow: effectiveWindow,
|
|
2974
|
-
summarize:
|
|
3033
|
+
summarize: chunkLSWHDOCL_cjs.buildDefaultSummarizer({
|
|
2975
3034
|
agentModel: model,
|
|
2976
3035
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2977
3036
|
})
|
|
2978
3037
|
}
|
|
2979
3038
|
},
|
|
2980
|
-
onRunEvent !== void 0 ? () =>
|
|
3039
|
+
onRunEvent !== void 0 ? () => chunkL7JPXZ2C_cjs.emitRunEvent(onRunEvent, { type: "compact_boundary", trigger: "auto" }) : void 0
|
|
2981
3040
|
);
|
|
2982
3041
|
if (result.status === "finished" && result.result !== void 0 && sessionTranscriptAllowed(inputs.memory)) {
|
|
2983
3042
|
const summaryArgs = {
|
|
2984
3043
|
cwd: workspaceCwd,
|
|
2985
3044
|
// Resolved once, here, and handed to both writers. Recomputing it inside either one is how
|
|
2986
3045
|
// the summary ended up in a directory the indexer never scanned (#463).
|
|
2987
|
-
memoryRoot:
|
|
3046
|
+
memoryRoot: chunkSDZ4XDWS_cjs.resolveMemoryRoot(workspaceCwd, inputs.memory),
|
|
2988
3047
|
runId: result.id,
|
|
2989
3048
|
agentId,
|
|
2990
3049
|
userText,
|
|
@@ -2996,11 +3055,11 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2996
3055
|
if (memoryProvider?.recordSessionSummary !== void 0) {
|
|
2997
3056
|
await memoryProvider.recordSessionSummary(summaryArgs);
|
|
2998
3057
|
} else {
|
|
2999
|
-
await
|
|
3058
|
+
await chunkSDZ4XDWS_cjs.writeSessionSummary(summaryArgs);
|
|
3000
3059
|
}
|
|
3001
3060
|
} catch (cause) {
|
|
3002
3061
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3003
|
-
|
|
3062
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] session summary write failed (${result.id}): ${message}
|
|
3004
3063
|
`);
|
|
3005
3064
|
}
|
|
3006
3065
|
}
|
|
@@ -3013,14 +3072,14 @@ async function runPostRunLifecycle(inputs) {
|
|
|
3013
3072
|
agentId,
|
|
3014
3073
|
runId: result.id
|
|
3015
3074
|
});
|
|
3016
|
-
await
|
|
3075
|
+
await chunkYOVZMN4P_cjs.flushSessionWrites();
|
|
3017
3076
|
}
|
|
3018
3077
|
async function safeConversation(run) {
|
|
3019
3078
|
try {
|
|
3020
3079
|
return await run.conversation();
|
|
3021
3080
|
} catch (cause) {
|
|
3022
3081
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
3023
|
-
|
|
3082
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] conversation() failed; persisting the user turn only: ${msg}
|
|
3024
3083
|
`);
|
|
3025
3084
|
return [];
|
|
3026
3085
|
}
|
|
@@ -3048,17 +3107,17 @@ var SkillsManager = class {
|
|
|
3048
3107
|
}
|
|
3049
3108
|
async refresh() {
|
|
3050
3109
|
const roots = this.skillsDir === void 0 ? [
|
|
3051
|
-
...
|
|
3110
|
+
...chunkYQ3XC6C2_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
|
|
3052
3111
|
(root) => path.join(root, "skills")
|
|
3053
3112
|
),
|
|
3054
|
-
...(await
|
|
3113
|
+
...(await chunkWDVG5R2Q_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
|
|
3055
3114
|
] : [this.skillsDir];
|
|
3056
3115
|
const discovered = [];
|
|
3057
3116
|
const seen = /* @__PURE__ */ new Set();
|
|
3058
3117
|
for (const root of roots) {
|
|
3059
|
-
for (const skill of await
|
|
3118
|
+
for (const skill of await chunk7WARNHWW_cjs.discoverSkills(root, {
|
|
3060
3119
|
onInvalidSkill: (info) => {
|
|
3061
|
-
|
|
3120
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
3062
3121
|
`);
|
|
3063
3122
|
}
|
|
3064
3123
|
})) {
|
|
@@ -3087,7 +3146,7 @@ var SkillsManager = class {
|
|
|
3087
3146
|
async get(name) {
|
|
3088
3147
|
const skill = this.skills.find((s) => s.name === name);
|
|
3089
3148
|
if (skill === void 0) return void 0;
|
|
3090
|
-
const instructions = typeof skill.instructions === "string" ? skill.instructions :
|
|
3149
|
+
const instructions = typeof skill.instructions === "string" ? skill.instructions : chunk7WARNHWW_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
|
|
3091
3150
|
const references = skill.references;
|
|
3092
3151
|
return {
|
|
3093
3152
|
name: skill.name,
|
|
@@ -3143,7 +3202,7 @@ function defineTool(spec) {
|
|
|
3143
3202
|
}
|
|
3144
3203
|
|
|
3145
3204
|
// src/internal/runtime/system-prompt/native-reasoning.ts
|
|
3146
|
-
var NATIVE_REASONING_PARAM_IDS = /* @__PURE__ */ new Set(["thinking"
|
|
3205
|
+
var NATIVE_REASONING_PARAM_IDS = /* @__PURE__ */ new Set(["thinking"]);
|
|
3147
3206
|
var REASONING_PREAMBLE = "Think step by step before answering: use the `think` tool to reason through each step, validate your work, then answer. Reason about magnitude before comparing numbers.";
|
|
3148
3207
|
function createThinkTool() {
|
|
3149
3208
|
return Tool.create({
|
|
@@ -3163,8 +3222,8 @@ var warned = /* @__PURE__ */ new Set();
|
|
|
3163
3222
|
function warnDoubleReasoningOnce() {
|
|
3164
3223
|
if (warned.has("double-reasoning")) return;
|
|
3165
3224
|
warned.add("double-reasoning");
|
|
3166
|
-
|
|
3167
|
-
"[theokit-sdk] `reasoning: true` skipped \u2014 a native reasoning model is configured (model.params thinking
|
|
3225
|
+
chunkRNXXYF22_cjs.diag(
|
|
3226
|
+
"[theokit-sdk] `reasoning: true` skipped \u2014 a native reasoning model is configured (model.params thinking); native reasoning wins. Remove one to silence.\n"
|
|
3168
3227
|
);
|
|
3169
3228
|
}
|
|
3170
3229
|
function reasoningActive(reasoning, model) {
|
|
@@ -3260,7 +3319,7 @@ async function safeCall(fn, fallback, label = "safeCall") {
|
|
|
3260
3319
|
return await fn();
|
|
3261
3320
|
} catch (cause) {
|
|
3262
3321
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3263
|
-
|
|
3322
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] ${label} failed: ${message}
|
|
3264
3323
|
`);
|
|
3265
3324
|
return fallback;
|
|
3266
3325
|
}
|
|
@@ -3274,7 +3333,7 @@ var ActiveMemoryPromptProvider = class {
|
|
|
3274
3333
|
if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
|
|
3275
3334
|
return Promise.resolve(void 0);
|
|
3276
3335
|
}
|
|
3277
|
-
const body =
|
|
3336
|
+
const body = chunk7WARNHWW_cjs.escapeBlockBody(ctx.activeMemorySummary);
|
|
3278
3337
|
return Promise.resolve(`<active-memory>
|
|
3279
3338
|
${body}
|
|
3280
3339
|
</active-memory>`);
|
|
@@ -3327,7 +3386,7 @@ function formatSource(name, tokens) {
|
|
|
3327
3386
|
if (tokens.length === 0) {
|
|
3328
3387
|
return ` <source name="${escapeAttribute(name)}" />`;
|
|
3329
3388
|
}
|
|
3330
|
-
const body =
|
|
3389
|
+
const body = chunk7WARNHWW_cjs.escapeBlockBody(tokens.join(" "));
|
|
3331
3390
|
return ` <source name="${escapeAttribute(name)}">
|
|
3332
3391
|
${body}
|
|
3333
3392
|
</source>`;
|
|
@@ -3351,7 +3410,7 @@ var MemoryPromptProvider = class {
|
|
|
3351
3410
|
if (ctx.memory.length === 0) return Promise.resolve(void 0);
|
|
3352
3411
|
const lines = ctx.memory.map((fact) => {
|
|
3353
3412
|
const tag = fact.observations === 1 ? "[unconfirmed] " : "";
|
|
3354
|
-
return ` - ${tag}${
|
|
3413
|
+
return ` - ${tag}${chunk7WARNHWW_cjs.escapeBlockBody(fact.text)}`;
|
|
3355
3414
|
});
|
|
3356
3415
|
return Promise.resolve(`${MEMORY_GUIDANCE}
|
|
3357
3416
|
<memory>
|
|
@@ -3375,7 +3434,7 @@ var SkillsPromptProvider = class {
|
|
|
3375
3434
|
priority = 20;
|
|
3376
3435
|
contribute(ctx) {
|
|
3377
3436
|
if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
|
|
3378
|
-
return Promise.resolve(
|
|
3437
|
+
return Promise.resolve(chunk7WARNHWW_cjs.buildSkillsBlock(ctx.skills));
|
|
3379
3438
|
}
|
|
3380
3439
|
};
|
|
3381
3440
|
|
|
@@ -3387,7 +3446,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
|
|
|
3387
3446
|
for (const p of providers) {
|
|
3388
3447
|
const key = `${p.priority}:${p.id}`;
|
|
3389
3448
|
if (seen.has(key)) {
|
|
3390
|
-
throw new
|
|
3449
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Duplicate system-prompt provider ${key}`, {
|
|
3391
3450
|
code: "pipeline_duplicate_provider"
|
|
3392
3451
|
});
|
|
3393
3452
|
}
|
|
@@ -3434,7 +3493,7 @@ function validateAgentOptions(options) {
|
|
|
3434
3493
|
ensureRuntimeShape(options);
|
|
3435
3494
|
if (options.local !== void 0) {
|
|
3436
3495
|
if (options.model === void 0) {
|
|
3437
|
-
throw new
|
|
3496
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError("Local agents require a model selection", {
|
|
3438
3497
|
code: "missing_model"
|
|
3439
3498
|
});
|
|
3440
3499
|
}
|
|
@@ -3458,7 +3517,7 @@ function validateCredentialPoolShape(options) {
|
|
|
3458
3517
|
([, arr]) => Array.isArray(arr) && arr.some((k) => typeof k === "string" && k.length > 0)
|
|
3459
3518
|
);
|
|
3460
3519
|
if (populated.length === 0) return;
|
|
3461
|
-
throw new
|
|
3520
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3462
3521
|
"Ambiguous credential configuration: use either `apiKey: '...'` (single-key, simplest) OR `apiKeys: { provider: [...] }` (multi-key pool), not both.",
|
|
3463
3522
|
{ code: "credential_pool_ambiguous" }
|
|
3464
3523
|
);
|
|
@@ -3467,7 +3526,7 @@ function validatePlugins(options) {
|
|
|
3467
3526
|
const plugins = options.plugins;
|
|
3468
3527
|
if (plugins?.paths === void 0) return;
|
|
3469
3528
|
if (options.cloud !== void 0 && plugins.paths.length > 0) {
|
|
3470
|
-
throw new
|
|
3529
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3471
3530
|
"Cloud agents require committed plugin manifests; local plugin paths are not supported",
|
|
3472
3531
|
{ code: "cloud_plugin_path_rejected" }
|
|
3473
3532
|
);
|
|
@@ -3475,7 +3534,7 @@ function validatePlugins(options) {
|
|
|
3475
3534
|
}
|
|
3476
3535
|
function ensureRuntimeShape(options) {
|
|
3477
3536
|
if (options.local !== void 0 && options.cloud !== void 0) {
|
|
3478
|
-
throw new
|
|
3537
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3479
3538
|
"Pass either local or cloud \u2014 they are mutually exclusive runtimes",
|
|
3480
3539
|
{ code: "runtime_exclusive" }
|
|
3481
3540
|
);
|
|
@@ -3483,7 +3542,7 @@ function ensureRuntimeShape(options) {
|
|
|
3483
3542
|
}
|
|
3484
3543
|
function rejectProgrammaticHooks(options) {
|
|
3485
3544
|
if (options.hooks !== void 0) {
|
|
3486
|
-
throw new
|
|
3545
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3487
3546
|
"Programmatic hooks are not supported \u2014 hooks are file-based only (.theokit/hooks.json)",
|
|
3488
3547
|
{ code: "programmatic_hooks_rejected" }
|
|
3489
3548
|
);
|
|
@@ -3493,7 +3552,7 @@ function validateCloud(cloud) {
|
|
|
3493
3552
|
if (cloud.envVars !== void 0) {
|
|
3494
3553
|
for (const key of Object.keys(cloud.envVars)) {
|
|
3495
3554
|
if (key.startsWith("THEOKIT_")) {
|
|
3496
|
-
throw new
|
|
3555
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3497
3556
|
`Cloud envVars cannot use the reserved THEOKIT_ prefix (got "${key}")`,
|
|
3498
3557
|
{ code: "reserved_env_prefix" }
|
|
3499
3558
|
);
|
|
@@ -3505,7 +3564,7 @@ function validateMcpServers(options) {
|
|
|
3505
3564
|
if (options.mcpServers === void 0) return;
|
|
3506
3565
|
for (const [name, config] of Object.entries(options.mcpServers)) {
|
|
3507
3566
|
if (options.cloud !== void 0 && isStdioWithCwd(config)) {
|
|
3508
|
-
throw new
|
|
3567
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3509
3568
|
`MCP server "${name}" uses stdio with cwd, which is rejected for cloud agents`,
|
|
3510
3569
|
{ code: "cloud_stdio_cwd_rejected" }
|
|
3511
3570
|
);
|
|
@@ -3524,12 +3583,12 @@ function validateSubagents(agents2) {
|
|
|
3524
3583
|
if (agents2 === void 0) return;
|
|
3525
3584
|
for (const [name, definition] of Object.entries(agents2)) {
|
|
3526
3585
|
if (typeof definition.description !== "string" || definition.description.length === 0) {
|
|
3527
|
-
throw new
|
|
3586
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty description`, {
|
|
3528
3587
|
code: "subagent_missing_description"
|
|
3529
3588
|
});
|
|
3530
3589
|
}
|
|
3531
3590
|
if (typeof definition.prompt !== "string" || definition.prompt.length === 0) {
|
|
3532
|
-
throw new
|
|
3591
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty prompt`, {
|
|
3533
3592
|
code: "subagent_missing_prompt"
|
|
3534
3593
|
});
|
|
3535
3594
|
}
|
|
@@ -3548,7 +3607,7 @@ function validateToolCatalog(tools, withheldBuiltins) {
|
|
|
3548
3607
|
for (const tool of tools) {
|
|
3549
3608
|
validateSingleTool(tool, reserved);
|
|
3550
3609
|
if (seen.has(tool.name)) {
|
|
3551
|
-
throw new
|
|
3610
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Duplicate custom tool name "${tool.name}"`, {
|
|
3552
3611
|
code: "duplicate_tool_name"
|
|
3553
3612
|
});
|
|
3554
3613
|
}
|
|
@@ -3559,7 +3618,7 @@ function validateCustomTools(options) {
|
|
|
3559
3618
|
const tools = options.tools;
|
|
3560
3619
|
if (tools === void 0 || tools.length === 0) return;
|
|
3561
3620
|
if (options.cloud !== void 0) {
|
|
3562
|
-
throw new
|
|
3621
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3563
3622
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
3564
3623
|
{ code: "cloud_custom_tools_rejected" }
|
|
3565
3624
|
);
|
|
@@ -3571,25 +3630,25 @@ function validateSingleTool(tool, reserved) {
|
|
|
3571
3630
|
validateToolDescription(tool);
|
|
3572
3631
|
validateToolSchema(tool);
|
|
3573
3632
|
if (typeof tool.handler !== "function") {
|
|
3574
|
-
throw new
|
|
3633
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a handler function`, {
|
|
3575
3634
|
code: "tool_missing_handler"
|
|
3576
3635
|
});
|
|
3577
3636
|
}
|
|
3578
3637
|
}
|
|
3579
3638
|
function validateToolName(tool, reserved) {
|
|
3580
3639
|
if (typeof tool.name !== "string" || tool.name.length === 0) {
|
|
3581
|
-
throw new
|
|
3640
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError("Custom tool requires a non-empty name", {
|
|
3582
3641
|
code: "tool_missing_name"
|
|
3583
3642
|
});
|
|
3584
3643
|
}
|
|
3585
3644
|
if (!TOOL_NAME_PATTERN.test(tool.name)) {
|
|
3586
|
-
throw new
|
|
3645
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3587
3646
|
`Custom tool name "${tool.name}" must match /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/`,
|
|
3588
3647
|
{ code: "tool_invalid_name" }
|
|
3589
3648
|
);
|
|
3590
3649
|
}
|
|
3591
3650
|
if (reserved.has(tool.name) || tool.name.startsWith("mcp_")) {
|
|
3592
|
-
throw new
|
|
3651
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3593
3652
|
`Custom tool name "${tool.name}" collides with a reserved SDK tool name`,
|
|
3594
3653
|
{ code: "tool_reserved_name" }
|
|
3595
3654
|
);
|
|
@@ -3597,7 +3656,7 @@ function validateToolName(tool, reserved) {
|
|
|
3597
3656
|
}
|
|
3598
3657
|
function validateToolDescription(tool) {
|
|
3599
3658
|
if (typeof tool.description !== "string" || tool.description.length === 0) {
|
|
3600
|
-
throw new
|
|
3659
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a non-empty description`, {
|
|
3601
3660
|
code: "tool_missing_description"
|
|
3602
3661
|
});
|
|
3603
3662
|
}
|
|
@@ -3605,12 +3664,12 @@ function validateToolDescription(tool) {
|
|
|
3605
3664
|
function validateToolSchema(tool) {
|
|
3606
3665
|
const schema = tool.inputSchema;
|
|
3607
3666
|
if (schema === null || schema === void 0 || typeof schema !== "object") {
|
|
3608
|
-
throw new
|
|
3667
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Custom tool "${tool.name}" requires an inputSchema object`, {
|
|
3609
3668
|
code: "tool_missing_schema"
|
|
3610
3669
|
});
|
|
3611
3670
|
}
|
|
3612
3671
|
if (schema.type !== "object") {
|
|
3613
|
-
throw new
|
|
3672
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3614
3673
|
`Custom tool "${tool.name}" inputSchema must declare \`type: "object"\``,
|
|
3615
3674
|
{ code: "tool_invalid_schema_type" }
|
|
3616
3675
|
);
|
|
@@ -3618,11 +3677,11 @@ function validateToolSchema(tool) {
|
|
|
3618
3677
|
}
|
|
3619
3678
|
function validateMemory(options) {
|
|
3620
3679
|
const memory = options.memory;
|
|
3621
|
-
|
|
3680
|
+
chunkSDZ4XDWS_cjs.resolveMaxFacts(memory?.maxFacts);
|
|
3622
3681
|
if (memory?.storePath === void 0) return;
|
|
3623
3682
|
const storePath = memory.storePath;
|
|
3624
3683
|
if (storePath.includes("..") || storePath.startsWith("/") || /^[A-Z]:/i.test(storePath)) {
|
|
3625
|
-
throw new
|
|
3684
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
3626
3685
|
`Memory storePath must stay inside the workspace; got "${storePath}"`,
|
|
3627
3686
|
{ code: "memory_path_traversal" }
|
|
3628
3687
|
);
|
|
@@ -3644,7 +3703,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3644
3703
|
};
|
|
3645
3704
|
function safeRequire(moduleName) {
|
|
3646
3705
|
try {
|
|
3647
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3706
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-Q6WT5535.cjs', document.baseURI).href)));
|
|
3648
3707
|
return r(moduleName);
|
|
3649
3708
|
} catch {
|
|
3650
3709
|
return void 0;
|
|
@@ -3726,7 +3785,7 @@ var langfuseAdapter = {
|
|
|
3726
3785
|
}
|
|
3727
3786
|
}
|
|
3728
3787
|
if (lf.LangfuseSpanProcessor === void 0) {
|
|
3729
|
-
|
|
3788
|
+
chunkRNXXYF22_cjs.diag(
|
|
3730
3789
|
"[theokit-sdk] @langfuse/node detected but LangfuseSpanProcessor not found (v2?). Use Langfuse v3+ for auto-instrumentation.\n"
|
|
3731
3790
|
);
|
|
3732
3791
|
return "not-wired";
|
|
@@ -3871,11 +3930,11 @@ function registerOne(adapter) {
|
|
|
3871
3930
|
try {
|
|
3872
3931
|
const wiring = adapter.register();
|
|
3873
3932
|
registered.set(adapter.moduleName, wiring);
|
|
3874
|
-
|
|
3933
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] telemetry: ${adapter.displayName} ${WIRING_PROSE[wiring]}.
|
|
3875
3934
|
`);
|
|
3876
3935
|
} catch (cause) {
|
|
3877
3936
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3878
|
-
|
|
3937
|
+
chunkRNXXYF22_cjs.diag(
|
|
3879
3938
|
`[theokit-sdk] telemetry: ${adapter.displayName} detected but failed to register: ${message}
|
|
3880
3939
|
`
|
|
3881
3940
|
);
|
|
@@ -3887,7 +3946,7 @@ var cachedOtel;
|
|
|
3887
3946
|
function loadOtel() {
|
|
3888
3947
|
if (cachedOtel === void 0) {
|
|
3889
3948
|
try {
|
|
3890
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3949
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-Q6WT5535.cjs', document.baseURI).href)));
|
|
3891
3950
|
const mod = r("@opentelemetry/api");
|
|
3892
3951
|
cachedOtel = mod;
|
|
3893
3952
|
} catch {
|
|
@@ -3930,7 +3989,7 @@ function safe(op, fallback) {
|
|
|
3930
3989
|
if (!warnedOnce) {
|
|
3931
3990
|
warnedOnce = true;
|
|
3932
3991
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3933
|
-
|
|
3992
|
+
chunkRNXXYF22_cjs.diag(
|
|
3934
3993
|
`[theokit-sdk] telemetry exporter error (suppressed; agent.send continues): ${message}
|
|
3935
3994
|
`
|
|
3936
3995
|
);
|
|
@@ -3944,7 +4003,7 @@ function createTelemetry(settings) {
|
|
|
3944
4003
|
if (otel === null) {
|
|
3945
4004
|
if (!warnedOnce) {
|
|
3946
4005
|
warnedOnce = true;
|
|
3947
|
-
|
|
4006
|
+
chunkRNXXYF22_cjs.diag(
|
|
3948
4007
|
"[theokit-sdk] telemetry.enabled = true but `@opentelemetry/api` is not installed; telemetry is a no-op.\n"
|
|
3949
4008
|
);
|
|
3950
4009
|
}
|
|
@@ -4038,12 +4097,12 @@ function wrapSpan(span, openSpans) {
|
|
|
4038
4097
|
}
|
|
4039
4098
|
function redactAttrValue(value) {
|
|
4040
4099
|
if (typeof value !== "string") return value;
|
|
4041
|
-
return
|
|
4100
|
+
return chunkRNXXYF22_cjs.redactSecrets(value);
|
|
4042
4101
|
}
|
|
4043
4102
|
function redactAttrs(attrs) {
|
|
4044
4103
|
const out = {};
|
|
4045
4104
|
for (const [k, v] of Object.entries(attrs)) {
|
|
4046
|
-
out[k] = typeof v === "string" ?
|
|
4105
|
+
out[k] = typeof v === "string" ? chunkRNXXYF22_cjs.redactSecrets(v) : v;
|
|
4047
4106
|
}
|
|
4048
4107
|
return out;
|
|
4049
4108
|
}
|
|
@@ -4124,10 +4183,10 @@ async function loadMarkdownEntities(opts) {
|
|
|
4124
4183
|
const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
|
|
4125
4184
|
if (raw === null) continue;
|
|
4126
4185
|
const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
|
|
4127
|
-
const fields =
|
|
4186
|
+
const fields = chunk6XQLTQB6_cjs.parseSimpleYaml(split.frontmatter);
|
|
4128
4187
|
const parsed = schema.safeParse(fields);
|
|
4129
4188
|
if (!parsed.success) {
|
|
4130
|
-
throw new
|
|
4189
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
4131
4190
|
`Invalid frontmatter in ${resolved.source}: ${parsed.error.message}`,
|
|
4132
4191
|
{ code: `${errorCodePrefix}_frontmatter_invalid` }
|
|
4133
4192
|
);
|
|
@@ -4145,13 +4204,13 @@ async function assertFileSizeUnderCap(source, errorCodePrefix) {
|
|
|
4145
4204
|
try {
|
|
4146
4205
|
const info = await promises.stat(source);
|
|
4147
4206
|
if (info.size > MAX_MD_FILE_BYTES) {
|
|
4148
|
-
throw new
|
|
4207
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
4149
4208
|
`Config file ${source} exceeds 1 MB size limit (${info.size} bytes). Reduce the file or split into multiple entities.`,
|
|
4150
4209
|
{ code: `${errorCodePrefix}_file_too_large` }
|
|
4151
4210
|
);
|
|
4152
4211
|
}
|
|
4153
4212
|
} catch (cause) {
|
|
4154
|
-
if (cause instanceof
|
|
4213
|
+
if (cause instanceof chunkCEGU5AVD_cjs.ConfigurationError) throw cause;
|
|
4155
4214
|
}
|
|
4156
4215
|
}
|
|
4157
4216
|
async function readDirSafe(dir, errorCodePrefix) {
|
|
@@ -4160,7 +4219,7 @@ async function readDirSafe(dir, errorCodePrefix) {
|
|
|
4160
4219
|
} catch (cause) {
|
|
4161
4220
|
const code = cause.code;
|
|
4162
4221
|
if (code === "ENOENT") return null;
|
|
4163
|
-
throw new
|
|
4222
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Failed to read ${dir}`, {
|
|
4164
4223
|
code: `${errorCodePrefix}_dir_read_error`,
|
|
4165
4224
|
cause
|
|
4166
4225
|
});
|
|
@@ -4177,7 +4236,7 @@ function resolveEntryPath(entry, pattern, dir) {
|
|
|
4177
4236
|
function splitFrontmatter(raw, source, errorCodePrefix) {
|
|
4178
4237
|
const match = /^---\s*\n([\s\S]*?)\n---\s*(?:\n|$)/.exec(raw);
|
|
4179
4238
|
if (match === null) {
|
|
4180
|
-
throw new
|
|
4239
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
4181
4240
|
`Missing or malformed frontmatter in ${source} (expected \`---\` delimited block at file head)`,
|
|
4182
4241
|
{ code: `${errorCodePrefix}_missing_frontmatter` }
|
|
4183
4242
|
);
|
|
@@ -4206,7 +4265,7 @@ function applyAggregateCap(sources, maxTotal) {
|
|
|
4206
4265
|
}
|
|
4207
4266
|
const remaining = maxTotal - totalBytes;
|
|
4208
4267
|
if (remaining > 0) {
|
|
4209
|
-
const { finalContent } =
|
|
4268
|
+
const { finalContent } = chunkQG4SXZ2A_cjs.truncateWithMarker(s.content, remaining);
|
|
4210
4269
|
kept.push({ ...s, content: finalContent, truncated: true });
|
|
4211
4270
|
totalBytes = maxTotal;
|
|
4212
4271
|
} else {
|
|
@@ -4276,7 +4335,7 @@ var FileContextManager = class {
|
|
|
4276
4335
|
*/
|
|
4277
4336
|
grantedContextDialects() {
|
|
4278
4337
|
if (this.compatSources === void 0) return void 0;
|
|
4279
|
-
return
|
|
4338
|
+
return chunkYQ3XC6C2_cjs.adaptersForSurface(this.compatSources, "context").map((a) => a.kind);
|
|
4280
4339
|
}
|
|
4281
4340
|
async initialize() {
|
|
4282
4341
|
if (!this.settingSourcesIncludeProject && this.settings.manager !== "file") {
|
|
@@ -4303,10 +4362,10 @@ var FileContextManager = class {
|
|
|
4303
4362
|
this.lastScope = [...touchedFiles];
|
|
4304
4363
|
const config = await loadContextConfig(this.cwd);
|
|
4305
4364
|
const legacy = await loadSources(config, this.cwd);
|
|
4306
|
-
const maxBytesPerFile = this.settings.maxBytesPerFile ??
|
|
4365
|
+
const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkQG4SXZ2A_cjs.DEFAULT_MAX_BYTES_PER_FILE;
|
|
4307
4366
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
4308
4367
|
const granted = this.grantedContextDialects();
|
|
4309
|
-
const discovered = await
|
|
4368
|
+
const discovered = await chunkQG4SXZ2A_cjs.runDiscovery({
|
|
4310
4369
|
cwd: this.cwd,
|
|
4311
4370
|
maxBytesPerFile,
|
|
4312
4371
|
skipLegacyTheokitContext: true,
|
|
@@ -4369,8 +4428,8 @@ var FileContextManager = class {
|
|
|
4369
4428
|
}
|
|
4370
4429
|
};
|
|
4371
4430
|
async function loadContextConfig(cwd) {
|
|
4372
|
-
const mdDir = path.join(
|
|
4373
|
-
const jsonPath = path.join(
|
|
4431
|
+
const mdDir = path.join(chunkYQ3XC6C2_cjs.theokitConfigRoot(cwd), "context");
|
|
4432
|
+
const jsonPath = path.join(chunkYQ3XC6C2_cjs.theokitConfigRoot(cwd), "context.json");
|
|
4374
4433
|
const mdEntities = await loadMarkdownEntities({
|
|
4375
4434
|
dir: mdDir,
|
|
4376
4435
|
schema: ContextSourceFrontmatterSchema,
|
|
@@ -4379,7 +4438,7 @@ async function loadContextConfig(cwd) {
|
|
|
4379
4438
|
});
|
|
4380
4439
|
if (mdEntities.length > 0) {
|
|
4381
4440
|
if (fs.existsSync(jsonPath)) {
|
|
4382
|
-
|
|
4441
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
4383
4442
|
"context-both-present",
|
|
4384
4443
|
"[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
|
|
4385
4444
|
);
|
|
@@ -4389,7 +4448,7 @@ async function loadContextConfig(cwd) {
|
|
|
4389
4448
|
};
|
|
4390
4449
|
}
|
|
4391
4450
|
if (!fs.existsSync(jsonPath)) return { sources: [] };
|
|
4392
|
-
|
|
4451
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
4393
4452
|
"context-json-deprecated",
|
|
4394
4453
|
// Names no command: `theokit-migrate-config` was unpublished with the `bin` entry, and a warning
|
|
4395
4454
|
// that tells you to run something the package does not ship is worse than one that tells you
|
|
@@ -4400,7 +4459,7 @@ async function loadContextConfig(cwd) {
|
|
|
4400
4459
|
try {
|
|
4401
4460
|
raw = await promises.readFile(jsonPath, "utf8");
|
|
4402
4461
|
} catch (cause) {
|
|
4403
|
-
throw new
|
|
4462
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Failed to read context config: ${jsonPath}`, {
|
|
4404
4463
|
code: "context_read_error",
|
|
4405
4464
|
cause
|
|
4406
4465
|
});
|
|
@@ -4412,13 +4471,13 @@ function parseConfig(raw, configPath) {
|
|
|
4412
4471
|
try {
|
|
4413
4472
|
parsed = JSON.parse(raw);
|
|
4414
4473
|
} catch (cause) {
|
|
4415
|
-
throw new
|
|
4474
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Invalid JSON in context config: ${configPath}`, {
|
|
4416
4475
|
code: "context_json_invalid",
|
|
4417
4476
|
cause
|
|
4418
4477
|
});
|
|
4419
4478
|
}
|
|
4420
4479
|
if (!parsed || typeof parsed !== "object") {
|
|
4421
|
-
throw new
|
|
4480
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Context config must be an object: ${configPath}`, {
|
|
4422
4481
|
code: "context_config_shape"
|
|
4423
4482
|
});
|
|
4424
4483
|
}
|
|
@@ -4433,7 +4492,7 @@ function parseConfig(raw, configPath) {
|
|
|
4433
4492
|
}
|
|
4434
4493
|
function readSources(sourcesRaw, configPath) {
|
|
4435
4494
|
if (!Array.isArray(sourcesRaw)) {
|
|
4436
|
-
throw new
|
|
4495
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Context config sources must be an array: ${configPath}`, {
|
|
4437
4496
|
code: "context_sources_shape"
|
|
4438
4497
|
});
|
|
4439
4498
|
}
|
|
@@ -4530,13 +4589,13 @@ var PluginsManager = class {
|
|
|
4530
4589
|
}
|
|
4531
4590
|
async refresh() {
|
|
4532
4591
|
this.plugins = [];
|
|
4533
|
-
for (const pluginsRoot of
|
|
4592
|
+
for (const pluginsRoot of chunkYQ3XC6C2_cjs.pluginBundleRoots(this.cwd, this.compatSources)) {
|
|
4534
4593
|
await this.refreshRoot(pluginsRoot);
|
|
4535
4594
|
}
|
|
4536
4595
|
}
|
|
4537
4596
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: MD-first + JSON fallback + CLI location + both-present detection per plugin folder — branch table is clearer inlined.
|
|
4538
4597
|
async refreshRoot(pluginsRoot) {
|
|
4539
|
-
const entries = await
|
|
4598
|
+
const entries = await chunk6XQLTQB6_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
|
|
4540
4599
|
for (const entry of entries) {
|
|
4541
4600
|
if (!entry.isDirectory()) continue;
|
|
4542
4601
|
const folderName = entry.name;
|
|
@@ -4552,13 +4611,13 @@ var PluginsManager = class {
|
|
|
4552
4611
|
const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
|
|
4553
4612
|
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(this.cwd, pluginsRoot, folderName) : await loadPluginManifestFromJson(this.cwd, jsonPath, folderName);
|
|
4554
4613
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4555
|
-
|
|
4614
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
4556
4615
|
`plugin-${folderName}-both`,
|
|
4557
4616
|
`[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
|
|
4558
4617
|
);
|
|
4559
4618
|
}
|
|
4560
4619
|
if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4561
|
-
|
|
4620
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
4562
4621
|
"plugin-json-deprecated",
|
|
4563
4622
|
// Same reason as the context.json warning: the CLI it used to name is no longer published.
|
|
4564
4623
|
"[theokit-sdk] plugin.json manifests are deprecated; replace each with a PLUGIN.md"
|
|
@@ -4577,11 +4636,11 @@ var PluginsManager = class {
|
|
|
4577
4636
|
const entry = metadata.entry;
|
|
4578
4637
|
if (entry === void 0) return;
|
|
4579
4638
|
const pluginRoot = path.join(pluginsRoot, folderName);
|
|
4580
|
-
const entryPath =
|
|
4639
|
+
const entryPath = chunk3KIUY67P_cjs.safePathJoin(pluginRoot, entry);
|
|
4581
4640
|
try {
|
|
4582
4641
|
await promises.readFile(entryPath, "utf8");
|
|
4583
4642
|
} catch (cause) {
|
|
4584
|
-
throw new
|
|
4643
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Plugin ${metadata.name} entry file is missing: ${entry}`, {
|
|
4585
4644
|
code: "plugin_entry_missing",
|
|
4586
4645
|
cause
|
|
4587
4646
|
});
|
|
@@ -4605,7 +4664,7 @@ var PluginsManager = class {
|
|
|
4605
4664
|
assertCloudRules() {
|
|
4606
4665
|
if (!this.cloud) return;
|
|
4607
4666
|
if (this.localPaths !== void 0 && this.localPaths.length > 0) {
|
|
4608
|
-
throw new
|
|
4667
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
4609
4668
|
"Cloud agents reject local plugin paths \u2014 plugins must come from committed repo files",
|
|
4610
4669
|
{ code: "cloud_plugin_path_rejected" }
|
|
4611
4670
|
);
|
|
@@ -4617,7 +4676,7 @@ async function loadPluginManifestFromJson(cwd, manifestPath, folderName) {
|
|
|
4617
4676
|
try {
|
|
4618
4677
|
raw = await promises.readFile(manifestPath, "utf8");
|
|
4619
4678
|
} catch (cause) {
|
|
4620
|
-
throw new
|
|
4679
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Plugin ${folderName} is missing plugin.json`, {
|
|
4621
4680
|
code: "plugin_missing_manifest",
|
|
4622
4681
|
cause
|
|
4623
4682
|
});
|
|
@@ -4626,13 +4685,13 @@ async function loadPluginManifestFromJson(cwd, manifestPath, folderName) {
|
|
|
4626
4685
|
try {
|
|
4627
4686
|
parsed = JSON.parse(raw);
|
|
4628
4687
|
} catch (cause) {
|
|
4629
|
-
throw new
|
|
4688
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Plugin ${folderName} manifest is invalid JSON`, {
|
|
4630
4689
|
code: "plugin_manifest_invalid",
|
|
4631
4690
|
cause
|
|
4632
4691
|
});
|
|
4633
4692
|
}
|
|
4634
4693
|
if (!parsed || typeof parsed !== "object") {
|
|
4635
|
-
throw new
|
|
4694
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Plugin ${folderName} manifest must be an object`, {
|
|
4636
4695
|
code: "plugin_manifest_shape"
|
|
4637
4696
|
});
|
|
4638
4697
|
}
|
|
@@ -4651,7 +4710,7 @@ async function loadPluginManifestFromMarkdown(cwd, pluginsRoot, folderName) {
|
|
|
4651
4710
|
try {
|
|
4652
4711
|
raw = await promises.readFile(mdPath, "utf8");
|
|
4653
4712
|
} catch (cause) {
|
|
4654
|
-
throw new
|
|
4713
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Plugin ${folderName} is missing PLUGIN.md`, {
|
|
4655
4714
|
code: "plugin_missing_manifest",
|
|
4656
4715
|
cause
|
|
4657
4716
|
});
|
|
@@ -4666,7 +4725,7 @@ async function loadPluginManifestFromMarkdown(cwd, pluginsRoot, folderName) {
|
|
|
4666
4725
|
});
|
|
4667
4726
|
const entity = entities.find((e) => e.slug === "PLUGIN");
|
|
4668
4727
|
if (entity === void 0) {
|
|
4669
|
-
throw new
|
|
4728
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`Plugin ${folderName} PLUGIN.md not parseable`, {
|
|
4670
4729
|
code: "plugin_missing_manifest"
|
|
4671
4730
|
});
|
|
4672
4731
|
}
|
|
@@ -4792,7 +4851,7 @@ function localAgentListArtifacts() {
|
|
|
4792
4851
|
}
|
|
4793
4852
|
function localAgentDownloadArtifact() {
|
|
4794
4853
|
return Promise.reject(
|
|
4795
|
-
new
|
|
4854
|
+
new chunkCEGU5AVD_cjs.UnsupportedRunOperationError(
|
|
4796
4855
|
"Artifacts are not supported for local agents",
|
|
4797
4856
|
"downloadArtifact"
|
|
4798
4857
|
)
|
|
@@ -4995,7 +5054,7 @@ function assertValidThresholds(soft, hard) {
|
|
|
4995
5054
|
["hardThreshold", hard]
|
|
4996
5055
|
]) {
|
|
4997
5056
|
if (!Number.isInteger(value) || value < 1) {
|
|
4998
|
-
throw new
|
|
5057
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
4999
5058
|
`doomLoop.${label} must be a positive integer (received ${value}).`,
|
|
5000
5059
|
{ code: "invalid_doom_loop_threshold" }
|
|
5001
5060
|
);
|
|
@@ -5342,14 +5401,14 @@ async function initLoopContext(inputs) {
|
|
|
5342
5401
|
}
|
|
5343
5402
|
function reportMemoryDegraded(stage, cause, sink) {
|
|
5344
5403
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
5345
|
-
|
|
5404
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] memory ${stage} failed \u2014 continuing without it: ${message}
|
|
5346
5405
|
`);
|
|
5347
|
-
|
|
5406
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(sink, { type: "memory_degraded", stage, message });
|
|
5348
5407
|
}
|
|
5349
5408
|
async function safeListTools(client, serverName, sink) {
|
|
5350
5409
|
try {
|
|
5351
5410
|
const listed = await client.listTools();
|
|
5352
|
-
|
|
5411
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(sink, {
|
|
5353
5412
|
type: "mcp_server_ready",
|
|
5354
5413
|
serverName: serverName ?? "unknown",
|
|
5355
5414
|
tools: listed.map((tool) => tool.name)
|
|
@@ -5358,9 +5417,9 @@ async function safeListTools(client, serverName, sink) {
|
|
|
5358
5417
|
} catch (cause) {
|
|
5359
5418
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
5360
5419
|
const server = serverName ?? "unknown";
|
|
5361
|
-
|
|
5420
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] mcp listTools failed (server=${server}): ${message}
|
|
5362
5421
|
`);
|
|
5363
|
-
|
|
5422
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(sink, { type: "mcp_server_failed", serverName: server, message });
|
|
5364
5423
|
return [];
|
|
5365
5424
|
}
|
|
5366
5425
|
}
|
|
@@ -5590,7 +5649,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
5590
5649
|
const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
|
|
5591
5650
|
if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
|
|
5592
5651
|
for (const key of candidates) {
|
|
5593
|
-
const info =
|
|
5652
|
+
const info = chunkS46WJTDL_cjs.getCatalogModelInfo(key);
|
|
5594
5653
|
const cost = info?.cost;
|
|
5595
5654
|
if (cost === void 0) continue;
|
|
5596
5655
|
const [prov, ...modelParts] = key.split("/");
|
|
@@ -5602,7 +5661,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
5602
5661
|
...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
|
|
5603
5662
|
...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
|
|
5604
5663
|
// M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
|
|
5605
|
-
pricingVersion:
|
|
5664
|
+
pricingVersion: chunkS46WJTDL_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
|
|
5606
5665
|
};
|
|
5607
5666
|
}
|
|
5608
5667
|
return void 0;
|
|
@@ -5816,11 +5875,11 @@ ${systemPrompt}`;
|
|
|
5816
5875
|
}
|
|
5817
5876
|
function activeMemoryBlock(additions) {
|
|
5818
5877
|
return `<active-memory>
|
|
5819
|
-
${
|
|
5878
|
+
${chunk7WARNHWW_cjs.escapeBlockBody(additions)}
|
|
5820
5879
|
</active-memory>`;
|
|
5821
5880
|
}
|
|
5822
5881
|
function buildLoopSystem(systemPrompt, additions, modelId) {
|
|
5823
|
-
if (!
|
|
5882
|
+
if (!chunkNWWTYBD3_cjs.isAnthropicFamilyModel(modelId) || systemPrompt === void 0 || systemPrompt.length === 0) {
|
|
5824
5883
|
return resolveSystemPromptWithMemoryAdditions(systemPrompt, additions);
|
|
5825
5884
|
}
|
|
5826
5885
|
const blocks = [{ text: systemPrompt, cacheable: true }];
|
|
@@ -5844,7 +5903,7 @@ function emitLlmMetrics(inputs, result, startAt) {
|
|
|
5844
5903
|
inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.LLM_USAGE_MISSING, 1, {
|
|
5845
5904
|
provider: inputs.llm.name
|
|
5846
5905
|
});
|
|
5847
|
-
|
|
5906
|
+
chunkRNXXYF22_cjs.diag(
|
|
5848
5907
|
`[theokit-sdk] llm usage missing from ${inputs.llm.name} finish \u2014 budget may undercount
|
|
5849
5908
|
`
|
|
5850
5909
|
);
|
|
@@ -6166,7 +6225,7 @@ function coerceArgsToSchema(args, schema) {
|
|
|
6166
6225
|
}
|
|
6167
6226
|
|
|
6168
6227
|
// src/tool-error.ts
|
|
6169
|
-
var ToolError = class extends
|
|
6228
|
+
var ToolError = class extends chunkCEGU5AVD_cjs.TheokitAgentError {
|
|
6170
6229
|
name = "ToolError";
|
|
6171
6230
|
/** The error content surfaced to the model: a string, or text/image blocks. */
|
|
6172
6231
|
content;
|
|
@@ -6340,7 +6399,7 @@ function raceToolExecution(exec, opts) {
|
|
|
6340
6399
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
6341
6400
|
async function dispatchTools(inputs, tools, toolCalls, events, parentSpan) {
|
|
6342
6401
|
const maxConcurrent = inputs.maxConcurrentTools ?? 4;
|
|
6343
|
-
return
|
|
6402
|
+
return chunk27V5I2WW_cjs.mapWithConcurrency(
|
|
6344
6403
|
toolCalls,
|
|
6345
6404
|
maxConcurrent,
|
|
6346
6405
|
(call) => dispatchSingleCall(inputs, tools, call, events, parentSpan)
|
|
@@ -6374,7 +6433,7 @@ async function dispatchSingleCall(inputs, tools, call, events, parentSpan) {
|
|
|
6374
6433
|
toolSpan?.end();
|
|
6375
6434
|
return fileVeto;
|
|
6376
6435
|
}
|
|
6377
|
-
|
|
6436
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(inputs.runEventSink, {
|
|
6378
6437
|
type: "tool_progress",
|
|
6379
6438
|
toolName: workingCall.name,
|
|
6380
6439
|
toolCallId: dc.callId
|
|
@@ -6406,7 +6465,7 @@ function vetoFromForkWhitelist(dc) {
|
|
|
6406
6465
|
const { inputs, call, callId, events } = dc;
|
|
6407
6466
|
const whitelistDecision = chunkIJ7M6GOG_cjs.checkToolWhitelist(call.name);
|
|
6408
6467
|
if (whitelistDecision.allowed) return void 0;
|
|
6409
|
-
|
|
6468
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(inputs.runEventSink, {
|
|
6410
6469
|
type: "permission_denied",
|
|
6411
6470
|
toolName: call.name,
|
|
6412
6471
|
toolCallId: callId,
|
|
@@ -6453,7 +6512,7 @@ async function vetoFromPluginPreHook(dc) {
|
|
|
6453
6512
|
...inputs.permissionMode !== void 0 ? { permissionMode: inputs.permissionMode } : {}
|
|
6454
6513
|
});
|
|
6455
6514
|
if (pluginVeto === void 0) return void 0;
|
|
6456
|
-
|
|
6515
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(inputs.runEventSink, {
|
|
6457
6516
|
type: "permission_denied",
|
|
6458
6517
|
toolName: call.name,
|
|
6459
6518
|
toolCallId: callId,
|
|
@@ -6483,7 +6542,7 @@ async function vetoFromFileHookPreDecision(dc) {
|
|
|
6483
6542
|
runId: inputs.runId
|
|
6484
6543
|
});
|
|
6485
6544
|
if (!preDecision.blocked) return void 0;
|
|
6486
|
-
|
|
6545
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(inputs.runEventSink, {
|
|
6487
6546
|
type: "permission_denied",
|
|
6488
6547
|
toolName: call.name,
|
|
6489
6548
|
toolCallId: callId,
|
|
@@ -6586,7 +6645,7 @@ function finalizeSpanAndPostHook(dc, result, toolSpan) {
|
|
|
6586
6645
|
agentId: inputs.agentId,
|
|
6587
6646
|
runId: inputs.runId
|
|
6588
6647
|
}).catch((err) => {
|
|
6589
|
-
|
|
6648
|
+
chunkRNXXYF22_cjs.diag(
|
|
6590
6649
|
`[theokit-sdk] postToolUse hook error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
6591
6650
|
`
|
|
6592
6651
|
);
|
|
@@ -6605,7 +6664,7 @@ async function emitToolLifecycleDelta(inputs, update) {
|
|
|
6605
6664
|
try {
|
|
6606
6665
|
await inputs.onDelta({ update });
|
|
6607
6666
|
} catch (err) {
|
|
6608
|
-
|
|
6667
|
+
chunkRNXXYF22_cjs.diag(
|
|
6609
6668
|
`[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
6610
6669
|
`
|
|
6611
6670
|
);
|
|
@@ -6617,7 +6676,7 @@ async function safeEmitToolHook(callback, event) {
|
|
|
6617
6676
|
await callback(event);
|
|
6618
6677
|
} catch (cause) {
|
|
6619
6678
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
6620
|
-
|
|
6679
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] tool lifecycle hook threw: ${msg}
|
|
6621
6680
|
`);
|
|
6622
6681
|
}
|
|
6623
6682
|
}
|
|
@@ -6684,7 +6743,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
6684
6743
|
(p) => (
|
|
6685
6744
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
6686
6745
|
// structured content); image blocks pass through untouched.
|
|
6687
|
-
p.type === "tool_result" ? { ...p, content:
|
|
6746
|
+
p.type === "tool_result" ? { ...p, content: chunkLSWHDOCL_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
6688
6747
|
)
|
|
6689
6748
|
);
|
|
6690
6749
|
}
|
|
@@ -6878,25 +6937,22 @@ async function runIteration(inputs, ctx) {
|
|
|
6878
6937
|
function trackTurnUsage(inputs, llmOutput) {
|
|
6879
6938
|
const tracker = inputs.budgetTracker;
|
|
6880
6939
|
if (tracker === void 0) return;
|
|
6881
|
-
const
|
|
6882
|
-
|
|
6883
|
-
|
|
6940
|
+
const model = inputs.model.id ?? "auto";
|
|
6941
|
+
trackEvent(tracker, { tokens: promptTokens(llmOutput), model, type: "input" });
|
|
6942
|
+
trackEvent(tracker, { tokens: llmOutput.outputTokens ?? 0, model, type: "output" });
|
|
6943
|
+
}
|
|
6944
|
+
function promptTokens(llmOutput) {
|
|
6945
|
+
return (llmOutput.inputTokens ?? 0) + (llmOutput.cacheReadTokens ?? 0) + (llmOutput.cacheWriteTokens ?? 0);
|
|
6946
|
+
}
|
|
6947
|
+
function trackEvent(tracker, event) {
|
|
6948
|
+
if (event.tokens <= 0) return;
|
|
6884
6949
|
try {
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
}
|
|
6892
|
-
if (outputT > 0) {
|
|
6893
|
-
tracker.track({
|
|
6894
|
-
tokens: outputT,
|
|
6895
|
-
model: modelId,
|
|
6896
|
-
type: "output"
|
|
6897
|
-
});
|
|
6898
|
-
}
|
|
6899
|
-
} catch {
|
|
6950
|
+
tracker.track(event);
|
|
6951
|
+
} catch (err) {
|
|
6952
|
+
const why = err instanceof Error ? err.message : String(err);
|
|
6953
|
+
chunkRNXXYF22_cjs.diagFailure(
|
|
6954
|
+
`[theokit-sdk] BudgetTracker.track threw (type=${event.type}, model=${event.model}, tokens=${event.tokens}): ${why}`
|
|
6955
|
+
);
|
|
6900
6956
|
}
|
|
6901
6957
|
}
|
|
6902
6958
|
async function transformLlmOutputText(inputs, text, ctx) {
|
|
@@ -7005,16 +7061,16 @@ var FallbackLlmClient = class {
|
|
|
7005
7061
|
async *stream(request, signal) {
|
|
7006
7062
|
let lastError;
|
|
7007
7063
|
for (const client of this.clients) {
|
|
7008
|
-
if (signal.aborted) throw
|
|
7009
|
-
const attempt = await
|
|
7064
|
+
if (signal.aborted) throw chunkLSWHDOCL_cjs.abortError(signal);
|
|
7065
|
+
const attempt = await chunkLSWHDOCL_cjs.tryFirstEvent(client, request, signal, true);
|
|
7010
7066
|
if (attempt.kind === "handshake_error") {
|
|
7011
7067
|
lastError = attempt.error;
|
|
7012
7068
|
continue;
|
|
7013
7069
|
}
|
|
7014
|
-
return yield*
|
|
7070
|
+
return yield* chunkLSWHDOCL_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
7015
7071
|
}
|
|
7016
7072
|
if (lastError !== void 0) throw lastError;
|
|
7017
|
-
throw new
|
|
7073
|
+
throw new chunkCEGU5AVD_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
7018
7074
|
code: "fallback_empty_chain"
|
|
7019
7075
|
});
|
|
7020
7076
|
}
|
|
@@ -7042,7 +7098,7 @@ function reconnectDelay(attempt) {
|
|
|
7042
7098
|
return ms <= 0 ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, ms));
|
|
7043
7099
|
}
|
|
7044
7100
|
function mcpTimeoutError(name, timeoutMs) {
|
|
7045
|
-
return new
|
|
7101
|
+
return new chunkCEGU5AVD_cjs.NetworkError(`MCP ${name} request timed out after ${timeoutMs}ms`, {
|
|
7046
7102
|
code: "mcp_timeout"
|
|
7047
7103
|
});
|
|
7048
7104
|
}
|
|
@@ -7140,7 +7196,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
7140
7196
|
child.stdin.on("error", () => void 0);
|
|
7141
7197
|
child.on("error", () => {
|
|
7142
7198
|
this.rejectAllPending(
|
|
7143
|
-
new
|
|
7199
|
+
new chunkCEGU5AVD_cjs.NetworkError(`MCP ${this.name} process crashed`, { code: "mcp_crashed" })
|
|
7144
7200
|
);
|
|
7145
7201
|
});
|
|
7146
7202
|
child.on("exit", () => {
|
|
@@ -7148,7 +7204,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
7148
7204
|
this.child = void 0;
|
|
7149
7205
|
this.dropped = true;
|
|
7150
7206
|
this.rejectAllPending(
|
|
7151
|
-
new
|
|
7207
|
+
new chunkCEGU5AVD_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
7152
7208
|
);
|
|
7153
7209
|
});
|
|
7154
7210
|
}
|
|
@@ -7176,7 +7232,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
7176
7232
|
if (this.child !== void 0) return Promise.resolve();
|
|
7177
7233
|
if (!this.dropped) {
|
|
7178
7234
|
return Promise.reject(
|
|
7179
|
-
new
|
|
7235
|
+
new chunkCEGU5AVD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
7180
7236
|
);
|
|
7181
7237
|
}
|
|
7182
7238
|
this.reconnectPromise ??= this.reconnect().finally(() => {
|
|
@@ -7200,13 +7256,13 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
7200
7256
|
this.reconnecting = false;
|
|
7201
7257
|
}
|
|
7202
7258
|
}
|
|
7203
|
-
throw new
|
|
7259
|
+
throw new chunkCEGU5AVD_cjs.NetworkError(`MCP ${this.name} reconnect exhausted`, {
|
|
7204
7260
|
code: "mcp_disconnected",
|
|
7205
7261
|
...lastErr instanceof Error ? { cause: lastErr } : {}
|
|
7206
7262
|
});
|
|
7207
7263
|
}
|
|
7208
7264
|
async close() {
|
|
7209
|
-
this.rejectAllPending(new
|
|
7265
|
+
this.rejectAllPending(new chunkCEGU5AVD_cjs.NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
|
|
7210
7266
|
const child = this.child;
|
|
7211
7267
|
this.child = void 0;
|
|
7212
7268
|
this.dropped = false;
|
|
@@ -7225,7 +7281,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
7225
7281
|
if (this.buffer.length > MAX_STDIO_BUFFER_BYTES) {
|
|
7226
7282
|
this.buffer = "";
|
|
7227
7283
|
this.rejectAllPending(
|
|
7228
|
-
new
|
|
7284
|
+
new chunkCEGU5AVD_cjs.NetworkError(`MCP ${this.name} exceeded stdout buffer limit`, {
|
|
7229
7285
|
code: "mcp_buffer_overflow"
|
|
7230
7286
|
})
|
|
7231
7287
|
);
|
|
@@ -7260,7 +7316,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
7260
7316
|
if (child !== void 0) return this.send(child, method, params);
|
|
7261
7317
|
if (this.dropped) return this.reconnectAndRequest(method, params);
|
|
7262
7318
|
return Promise.reject(
|
|
7263
|
-
new
|
|
7319
|
+
new chunkCEGU5AVD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
7264
7320
|
);
|
|
7265
7321
|
}
|
|
7266
7322
|
/** M2 #59 — reconnect a dropped client, then send. Separate async path so the
|
|
@@ -7269,7 +7325,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
7269
7325
|
await this.ensureConnected();
|
|
7270
7326
|
const child = this.child;
|
|
7271
7327
|
if (child === void 0) {
|
|
7272
|
-
throw new
|
|
7328
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" });
|
|
7273
7329
|
}
|
|
7274
7330
|
return this.send(child, method, params);
|
|
7275
7331
|
}
|
|
@@ -7287,7 +7343,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
7287
7343
|
this.child = void 0;
|
|
7288
7344
|
this.dropped = true;
|
|
7289
7345
|
this.rejectAllPending(
|
|
7290
|
-
new
|
|
7346
|
+
new chunkCEGU5AVD_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
7291
7347
|
);
|
|
7292
7348
|
}, budget);
|
|
7293
7349
|
this.pending.set(id, { resolve, reject, timer });
|
|
@@ -7359,7 +7415,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
7359
7415
|
if (payload === "") continue;
|
|
7360
7416
|
return JSON.parse(payload);
|
|
7361
7417
|
}
|
|
7362
|
-
throw new
|
|
7418
|
+
throw new chunkCEGU5AVD_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
|
|
7363
7419
|
code: "mcp_http_error"
|
|
7364
7420
|
});
|
|
7365
7421
|
}
|
|
@@ -7393,7 +7449,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
7393
7449
|
throw cause;
|
|
7394
7450
|
}
|
|
7395
7451
|
if (!response.ok) {
|
|
7396
|
-
throw new
|
|
7452
|
+
throw new chunkCEGU5AVD_cjs.NetworkError(`MCP ${this.name} returned ${response.status}`, {
|
|
7397
7453
|
code: "mcp_http_error"
|
|
7398
7454
|
});
|
|
7399
7455
|
}
|
|
@@ -7409,7 +7465,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
7409
7465
|
function resolveMcpCwd(configCwd) {
|
|
7410
7466
|
if (configCwd === void 0) return process.cwd();
|
|
7411
7467
|
if (path.isAbsolute(configCwd)) return configCwd;
|
|
7412
|
-
return
|
|
7468
|
+
return chunk3KIUY67P_cjs.safePathJoin(process.cwd(), configCwd);
|
|
7413
7469
|
}
|
|
7414
7470
|
|
|
7415
7471
|
// src/internal/local-agent/mcp-pool.ts
|
|
@@ -7511,7 +7567,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
|
|
|
7511
7567
|
if (exposedSet.has(name)) continue;
|
|
7512
7568
|
const hint = suggestClosest(name, exposedSet);
|
|
7513
7569
|
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)`;
|
|
7514
|
-
|
|
7570
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
7515
7571
|
`personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
|
|
7516
7572
|
message
|
|
7517
7573
|
);
|
|
@@ -7553,7 +7609,7 @@ function levenshtein(a, b) {
|
|
|
7553
7609
|
// src/internal/local-agent/real-local-run-tools.ts
|
|
7554
7610
|
function declarativeSubagentTools(agents2, parentTools) {
|
|
7555
7611
|
if (agents2 === void 0 || Object.keys(agents2).length === 0) return [];
|
|
7556
|
-
return
|
|
7612
|
+
return chunkH7HD6RXO_cjs.subAgentToolsFromDefinitions(agents2, parentTools);
|
|
7557
7613
|
}
|
|
7558
7614
|
function resolveInheritedCredentials(agentOptions) {
|
|
7559
7615
|
const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
|
|
@@ -7642,14 +7698,14 @@ function createRealLocalRun(options) {
|
|
|
7642
7698
|
function buildLoopInputs(options, runId, userText, userImages) {
|
|
7643
7699
|
const maxIterations = options.sendOptions.maxIterations;
|
|
7644
7700
|
if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
|
|
7645
|
-
throw new
|
|
7701
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
7646
7702
|
`SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
|
|
7647
7703
|
{ code: "invalid_max_iterations" }
|
|
7648
7704
|
);
|
|
7649
7705
|
}
|
|
7650
|
-
const { primary, effectiveModelId } =
|
|
7706
|
+
const { primary, effectiveModelId } = chunkLSWHDOCL_cjs.resolveRunProvider(options);
|
|
7651
7707
|
const fallback = options.agentOptions.providers?.fallback;
|
|
7652
|
-
const apiKeys =
|
|
7708
|
+
const apiKeys = chunkLSWHDOCL_cjs.mergeExplicitApiKey(
|
|
7653
7709
|
options.agentOptions.providers?.apiKeys,
|
|
7654
7710
|
primary,
|
|
7655
7711
|
options.agentOptions.apiKey
|
|
@@ -7658,7 +7714,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7658
7714
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7659
7715
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7660
7716
|
const modelBaseUrl = options.model?.url;
|
|
7661
|
-
const chain =
|
|
7717
|
+
const chain = chunkLSWHDOCL_cjs.resolveProviderChain({
|
|
7662
7718
|
primary,
|
|
7663
7719
|
...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
|
|
7664
7720
|
...fallback !== void 0 ? { fallback } : {},
|
|
@@ -7666,7 +7722,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7666
7722
|
...credentialPoolStrategy !== void 0 ? { credentialPoolStrategy } : {},
|
|
7667
7723
|
...extractToolCallsFromContent === true ? { extractToolCallsFromContent: true } : {},
|
|
7668
7724
|
...rateLimitSink !== void 0 ? {
|
|
7669
|
-
onRateLimit: (info) =>
|
|
7725
|
+
onRateLimit: (info) => chunkL7JPXZ2C_cjs.emitRunEvent(rateLimitSink, { type: "rate_limit", ...info })
|
|
7670
7726
|
} : {}
|
|
7671
7727
|
});
|
|
7672
7728
|
const llm = chain.length === 1 ? chain[0] : new FallbackLlmClient(chain);
|
|
@@ -7841,7 +7897,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7841
7897
|
try {
|
|
7842
7898
|
if (this.terminated) return;
|
|
7843
7899
|
const runLoop = () => inputs.activeTools !== void 0 ? chunkIJ7M6GOG_cjs.withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : runAgentLoop(inputs);
|
|
7844
|
-
const output = await
|
|
7900
|
+
const output = await chunkH7HD6RXO_cjs.withInheritedSubAgentCredentials(this.inheritedCredentials, runLoop);
|
|
7845
7901
|
this.applyAgentLoopOutput(output);
|
|
7846
7902
|
this.transitionTo(output.finalStatus);
|
|
7847
7903
|
} catch (cause) {
|
|
@@ -7914,7 +7970,7 @@ async function closeOwnedMcpClients(inputs) {
|
|
|
7914
7970
|
await client.close();
|
|
7915
7971
|
} catch (cause) {
|
|
7916
7972
|
const why = cause instanceof Error ? cause.message : String(cause);
|
|
7917
|
-
|
|
7973
|
+
chunkRNXXYF22_cjs.diagFailure(
|
|
7918
7974
|
`[theokit-sdk] MCP server ${name} failed to close; its process may still be running: ${why}`
|
|
7919
7975
|
);
|
|
7920
7976
|
}
|
|
@@ -7943,7 +7999,7 @@ function buildRealRunOptions(args) {
|
|
|
7943
7999
|
};
|
|
7944
8000
|
}
|
|
7945
8001
|
async function createFixtureRunHelper(args) {
|
|
7946
|
-
const sessionMessages =
|
|
8002
|
+
const sessionMessages = chunkYOVZMN4P_cjs.getSessionMessages(args.inputs.agentId);
|
|
7947
8003
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7948
8004
|
return createLocalRun({
|
|
7949
8005
|
agentId: args.inputs.agentId,
|
|
@@ -7961,8 +8017,8 @@ async function createFixtureRunHelper(args) {
|
|
|
7961
8017
|
});
|
|
7962
8018
|
}
|
|
7963
8019
|
async function dispatchLocalRun(args) {
|
|
7964
|
-
const apiKey =
|
|
7965
|
-
if (
|
|
8020
|
+
const apiKey = chunkRNXXYF22_cjs.resolveApiKey(args.inputs.options.apiKey);
|
|
8021
|
+
if (chunkLSWHDOCL_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7966
8022
|
return createRealLocalRun(
|
|
7967
8023
|
buildRealRunOptions({
|
|
7968
8024
|
inputs: args.inputs,
|
|
@@ -7985,7 +8041,7 @@ async function dispatchLocalRun(args) {
|
|
|
7985
8041
|
});
|
|
7986
8042
|
}
|
|
7987
8043
|
async function readProjectMcpServers(cwd) {
|
|
7988
|
-
const path$1 = path.join(
|
|
8044
|
+
const path$1 = path.join(chunkYQ3XC6C2_cjs.theokitConfigRoot(cwd), "mcp.json");
|
|
7989
8045
|
try {
|
|
7990
8046
|
const raw = await promises.readFile(path$1, "utf8");
|
|
7991
8047
|
const parsed = JSON.parse(raw);
|
|
@@ -7997,20 +8053,20 @@ async function readProjectMcpServers(cwd) {
|
|
|
7997
8053
|
|
|
7998
8054
|
// src/internal/local-agent/local-agent-invalidate.ts
|
|
7999
8055
|
async function applyDeferredInvalidation(agentId, pending, refresh) {
|
|
8000
|
-
|
|
8056
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] applying deferred cache invalidation (${agentId}): ${pending.reason}
|
|
8001
8057
|
`);
|
|
8002
8058
|
try {
|
|
8003
8059
|
await refresh();
|
|
8004
8060
|
} catch (err) {
|
|
8005
8061
|
const msg = err instanceof Error ? err.message : String(err);
|
|
8006
|
-
|
|
8062
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] invalidateCache reload failed (continuing): ${msg}
|
|
8007
8063
|
`);
|
|
8008
8064
|
}
|
|
8009
8065
|
}
|
|
8010
8066
|
async function invalidateCacheImpl(agentId, reason, options, disposed, dispose, setPending) {
|
|
8011
8067
|
if (disposed) return;
|
|
8012
8068
|
if (options.applyNow === true) {
|
|
8013
|
-
|
|
8069
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] invalidateCache applyNow disposing agent (${agentId}): ${reason}
|
|
8014
8070
|
`);
|
|
8015
8071
|
await dispose();
|
|
8016
8072
|
return;
|
|
@@ -8071,7 +8127,7 @@ var LiveAgentRegistry = class {
|
|
|
8071
8127
|
const existing = this.#agents.get(id);
|
|
8072
8128
|
if (existing !== void 0 && existing.agent !== agent) {
|
|
8073
8129
|
void existing.agent.dispose().catch(() => {
|
|
8074
|
-
|
|
8130
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] dispose during overwrite failed (${id})
|
|
8075
8131
|
`);
|
|
8076
8132
|
});
|
|
8077
8133
|
}
|
|
@@ -8175,7 +8231,7 @@ var LiveAgentRegistry = class {
|
|
|
8175
8231
|
await agent.dispose();
|
|
8176
8232
|
} catch (cause) {
|
|
8177
8233
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
8178
|
-
|
|
8234
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] dispose during eviction failed (${id}): ${msg}
|
|
8179
8235
|
`);
|
|
8180
8236
|
}
|
|
8181
8237
|
if (this.#onEvict !== void 0) {
|
|
@@ -8183,7 +8239,7 @@ var LiveAgentRegistry = class {
|
|
|
8183
8239
|
this.#onEvict(id, reason);
|
|
8184
8240
|
} catch (cause) {
|
|
8185
8241
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
8186
|
-
|
|
8242
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] onEvict listener threw (${id}): ${msg}
|
|
8187
8243
|
`);
|
|
8188
8244
|
}
|
|
8189
8245
|
}
|
|
@@ -8201,7 +8257,7 @@ async function acquireLeaseIfPossible(store, agentId) {
|
|
|
8201
8257
|
await store.acquire(agentId);
|
|
8202
8258
|
} catch (err) {
|
|
8203
8259
|
if (err instanceof Error && err.name === "SessionBusyError") throw err;
|
|
8204
|
-
|
|
8260
|
+
chunkRNXXYF22_cjs.diag(
|
|
8205
8261
|
`[theokit-sdk] writer lease unavailable for ${agentId} (${err instanceof Error ? err.message : String(err)}) \u2014 proceeding without single-writer protection
|
|
8206
8262
|
`
|
|
8207
8263
|
);
|
|
@@ -8218,16 +8274,16 @@ async function disposeLocalAgentSession(agent) {
|
|
|
8218
8274
|
agent.lifecycleAbortController.abort();
|
|
8219
8275
|
await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
8220
8276
|
disposeSessionMcpClients(agent.agentId);
|
|
8221
|
-
await
|
|
8277
|
+
await chunkYOVZMN4P_cjs.flushSessionWrites();
|
|
8222
8278
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
8223
8279
|
await disposeSessionStore(agent.sessionStore);
|
|
8224
|
-
|
|
8280
|
+
chunkYOVZMN4P_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
8225
8281
|
}
|
|
8226
8282
|
async function reloadLocalAgent(agent) {
|
|
8227
8283
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
8228
8284
|
if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
|
|
8229
8285
|
if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
|
|
8230
|
-
return await
|
|
8286
|
+
return await chunkWDVG5R2Q_cjs.loadSubagents(
|
|
8231
8287
|
agent.workspaceCwd,
|
|
8232
8288
|
agent.settingSourcesIncludeProject,
|
|
8233
8289
|
agent.options.agents
|
|
@@ -8240,7 +8296,7 @@ async function createAvailableAdapters(entries, workspaceCwd) {
|
|
|
8240
8296
|
for (const entry of entries) {
|
|
8241
8297
|
const instance = await entry.createProvider(workspaceCwd);
|
|
8242
8298
|
if (instance.isAvailable() === false) {
|
|
8243
|
-
|
|
8299
|
+
chunkRNXXYF22_cjs.diag(
|
|
8244
8300
|
`[theokit-sdk] memory adapter "${instance.id}" reports itself unavailable (plugin "${entry.pluginName}") \u2014 skipping it. Check its credentials.
|
|
8245
8301
|
`
|
|
8246
8302
|
);
|
|
@@ -8274,7 +8330,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8274
8330
|
...partial?.metadata !== void 0 ? { metadata: partial.metadata } : defaultContext?.metadata !== void 0 ? { metadata: defaultContext.metadata } : {}
|
|
8275
8331
|
};
|
|
8276
8332
|
if (merged.userId === "") {
|
|
8277
|
-
throw new
|
|
8333
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
8278
8334
|
"agent.memory requires a userId \u2014 either set AgentOptions.memoryContext.userId or pass ctx.userId at call time.",
|
|
8279
8335
|
{ code: "memory_context_missing_user_id" }
|
|
8280
8336
|
);
|
|
@@ -8284,7 +8340,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8284
8340
|
async function requireAdapters() {
|
|
8285
8341
|
const r = await ensure();
|
|
8286
8342
|
if (r.adapters.length === 0) {
|
|
8287
|
-
throw new
|
|
8343
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
8288
8344
|
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.`,
|
|
8289
8345
|
{ code: "no_memory_adapter" }
|
|
8290
8346
|
);
|
|
@@ -8325,7 +8381,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8325
8381
|
const prefix = id.split(":", 1)[0] ?? "";
|
|
8326
8382
|
const target = adapters.find((a) => a.id === prefix);
|
|
8327
8383
|
if (target === void 0) {
|
|
8328
|
-
throw new
|
|
8384
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
8329
8385
|
`No adapter found for MemoryId prefix "${prefix}" (registered: ${adapters.map((a) => a.id).join(", ")}).`,
|
|
8330
8386
|
{ code: "no_memory_adapter" }
|
|
8331
8387
|
);
|
|
@@ -8455,7 +8511,7 @@ async function searchOnce(args, cfg, query, started) {
|
|
|
8455
8511
|
return { summary, durationMs: Date.now() - started, status: "ok", hits };
|
|
8456
8512
|
} catch (cause) {
|
|
8457
8513
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8458
|
-
|
|
8514
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] active-memory recall failed: ${message}
|
|
8459
8515
|
`);
|
|
8460
8516
|
return { summary: void 0, durationMs: Date.now() - started, status: "error", hits: [] };
|
|
8461
8517
|
}
|
|
@@ -8473,7 +8529,7 @@ async function finalize(args, queryMode, result) {
|
|
|
8473
8529
|
};
|
|
8474
8530
|
args.cache?.set(args.userText, queryMode, result, tenantCtx);
|
|
8475
8531
|
if (args.persistTranscripts === true && args.cwd !== void 0) {
|
|
8476
|
-
await
|
|
8532
|
+
await chunkRS7YQR4X_cjs.persistActiveMemoryTranscript(args.memoryRoot ?? chunkSDZ4XDWS_cjs.resolveMemoryRoot(args.cwd), {
|
|
8477
8533
|
runId: args.runId ?? `run-${Date.now()}`,
|
|
8478
8534
|
startedAtMs: Date.now() - result.durationMs,
|
|
8479
8535
|
userText: args.userText,
|
|
@@ -8576,7 +8632,7 @@ var openAiMemoryEmbeddingProviderAdapter = {
|
|
|
8576
8632
|
transport: "remote",
|
|
8577
8633
|
authProviderId: "openai",
|
|
8578
8634
|
autoSelectPriority: 20,
|
|
8579
|
-
create: (options) =>
|
|
8635
|
+
create: (options) => chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8580
8636
|
{
|
|
8581
8637
|
id: "openai",
|
|
8582
8638
|
defaultBaseUrl: "https://api.openai.com",
|
|
@@ -8598,7 +8654,7 @@ var azureOpenAiMemoryEmbeddingProviderAdapter = {
|
|
|
8598
8654
|
transport: "remote",
|
|
8599
8655
|
authProviderId: "azure-openai",
|
|
8600
8656
|
autoSelectPriority: 25,
|
|
8601
|
-
create: (options) =>
|
|
8657
|
+
create: (options) => chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8602
8658
|
{
|
|
8603
8659
|
id: "azure-openai",
|
|
8604
8660
|
defaultBaseUrl: "https://your-resource.openai.azure.com",
|
|
@@ -8634,7 +8690,7 @@ var cohereMemoryEmbeddingProviderAdapter = {
|
|
|
8634
8690
|
transport: "remote",
|
|
8635
8691
|
authProviderId: "cohere",
|
|
8636
8692
|
autoSelectPriority: 30,
|
|
8637
|
-
create: (options) =>
|
|
8693
|
+
create: (options) => chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8638
8694
|
{
|
|
8639
8695
|
id: "cohere",
|
|
8640
8696
|
defaultBaseUrl: "https://api.cohere.com",
|
|
@@ -8680,7 +8736,7 @@ var deepinfraMemoryEmbeddingProviderAdapter = {
|
|
|
8680
8736
|
transport: "remote",
|
|
8681
8737
|
authProviderId: "deepinfra",
|
|
8682
8738
|
autoSelectPriority: 13,
|
|
8683
|
-
create: (options) =>
|
|
8739
|
+
create: (options) => chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8684
8740
|
{
|
|
8685
8741
|
id: "deepinfra",
|
|
8686
8742
|
defaultBaseUrl: "https://api.deepinfra.com",
|
|
@@ -8706,7 +8762,7 @@ var geminiMemoryEmbeddingProviderAdapter = {
|
|
|
8706
8762
|
transport: "remote",
|
|
8707
8763
|
authProviderId: "gemini",
|
|
8708
8764
|
autoSelectPriority: 30,
|
|
8709
|
-
create: (options) =>
|
|
8765
|
+
create: (options) => chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8710
8766
|
{
|
|
8711
8767
|
id: "gemini",
|
|
8712
8768
|
defaultBaseUrl: "https://generativelanguage.googleapis.com",
|
|
@@ -8734,7 +8790,7 @@ var jinaMemoryEmbeddingProviderAdapter = {
|
|
|
8734
8790
|
transport: "remote",
|
|
8735
8791
|
authProviderId: "jina",
|
|
8736
8792
|
autoSelectPriority: 35,
|
|
8737
|
-
create: (options) =>
|
|
8793
|
+
create: (options) => chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8738
8794
|
{
|
|
8739
8795
|
id: "jina",
|
|
8740
8796
|
defaultBaseUrl: "https://api.jina.ai",
|
|
@@ -8757,7 +8813,7 @@ var mistralMemoryEmbeddingProviderAdapter = {
|
|
|
8757
8813
|
transport: "remote",
|
|
8758
8814
|
authProviderId: "mistral",
|
|
8759
8815
|
autoSelectPriority: 18,
|
|
8760
|
-
create: (options) =>
|
|
8816
|
+
create: (options) => chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8761
8817
|
{
|
|
8762
8818
|
id: "mistral",
|
|
8763
8819
|
defaultBaseUrl: "https://api.mistral.ai",
|
|
@@ -8799,7 +8855,7 @@ var ollamaMemoryEmbeddingProviderAdapter = {
|
|
|
8799
8855
|
autoSelectPriority: 10,
|
|
8800
8856
|
create: (options) => {
|
|
8801
8857
|
const apiKey = options.apiKey ?? process.env.OLLAMA_API_KEY ?? OLLAMA_LOCAL_SENTINEL_KEY;
|
|
8802
|
-
return
|
|
8858
|
+
return chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8803
8859
|
{
|
|
8804
8860
|
id: "ollama",
|
|
8805
8861
|
defaultBaseUrl: "http://localhost:11434",
|
|
@@ -8827,7 +8883,7 @@ var openRouterMemoryEmbeddingProviderAdapter = {
|
|
|
8827
8883
|
transport: "remote",
|
|
8828
8884
|
authProviderId: "openrouter",
|
|
8829
8885
|
autoSelectPriority: 15,
|
|
8830
|
-
create: (options) =>
|
|
8886
|
+
create: (options) => chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8831
8887
|
{
|
|
8832
8888
|
id: "openrouter",
|
|
8833
8889
|
defaultBaseUrl: "https://openrouter.ai/api",
|
|
@@ -8855,7 +8911,7 @@ var voyageMemoryEmbeddingProviderAdapter = {
|
|
|
8855
8911
|
transport: "remote",
|
|
8856
8912
|
authProviderId: "voyage",
|
|
8857
8913
|
autoSelectPriority: 14,
|
|
8858
|
-
create: (options) =>
|
|
8914
|
+
create: (options) => chunkCGH4BCIY_cjs.createOpenAiCompatibleRuntime(
|
|
8859
8915
|
{
|
|
8860
8916
|
id: "voyage",
|
|
8861
8917
|
defaultBaseUrl: "https://api.voyageai.com",
|
|
@@ -8967,7 +9023,7 @@ function createMemoryGetTool(opts) {
|
|
|
8967
9023
|
const lines = readNumber(input.lines);
|
|
8968
9024
|
const resolved = path.resolve(memoryRoot, relPath);
|
|
8969
9025
|
if (!isPathInside(memoryRoot, resolved)) {
|
|
8970
|
-
throw new
|
|
9026
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
8971
9027
|
`memory_get rejected path that escapes memory root: ${relPath}`,
|
|
8972
9028
|
{ code: "memory_path_escapes_root" }
|
|
8973
9029
|
);
|
|
@@ -8987,7 +9043,7 @@ function readString(value, errorIfMissing, allowUndefined = false) {
|
|
|
8987
9043
|
if (typeof value === "string") return value;
|
|
8988
9044
|
if (allowUndefined && (value === void 0 || value === null)) return "";
|
|
8989
9045
|
if (errorIfMissing !== void 0) {
|
|
8990
|
-
throw new
|
|
9046
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(errorIfMissing, { code: "memory_tool_bad_args" });
|
|
8991
9047
|
}
|
|
8992
9048
|
return "";
|
|
8993
9049
|
}
|
|
@@ -9064,7 +9120,7 @@ var LocalAgentMemory = class {
|
|
|
9064
9120
|
const openOpts = { cwd: this.workspaceCwd, memoryRoot };
|
|
9065
9121
|
if (embedding !== void 0) openOpts.embedding = embedding;
|
|
9066
9122
|
if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
|
|
9067
|
-
this.index = await
|
|
9123
|
+
this.index = await chunkCWQPQTUZ_cjs.IndexManager.open(openOpts);
|
|
9068
9124
|
await this.index.sync();
|
|
9069
9125
|
this.toolsCache = [
|
|
9070
9126
|
createMemorySearchTool({ index: this.index }),
|
|
@@ -9076,7 +9132,7 @@ var LocalAgentMemory = class {
|
|
|
9076
9132
|
const warned2 = chunkNVXXWAU7_cjs.globalSingleton("theokit-sdk.memory.warned", () => /* @__PURE__ */ new Set());
|
|
9077
9133
|
if (!warned2.has(message)) {
|
|
9078
9134
|
warned2.add(message);
|
|
9079
|
-
|
|
9135
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] memory tools unavailable: ${message}
|
|
9080
9136
|
`);
|
|
9081
9137
|
}
|
|
9082
9138
|
return void 0;
|
|
@@ -9085,7 +9141,7 @@ var LocalAgentMemory = class {
|
|
|
9085
9141
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
9086
9142
|
const cfg = this.options.memory?.activeRecall;
|
|
9087
9143
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
9088
|
-
if (this.breaker === void 0) this.breaker = new
|
|
9144
|
+
if (this.breaker === void 0) this.breaker = new chunkLSWHDOCL_cjs.CircuitBreaker();
|
|
9089
9145
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
9090
9146
|
const result = await runActiveMemory({
|
|
9091
9147
|
userText,
|
|
@@ -9108,7 +9164,7 @@ var LocalAgentMemory = class {
|
|
|
9108
9164
|
* and the active-memory transcript writer. Three separate resolutions is how they drifted (#463).
|
|
9109
9165
|
*/
|
|
9110
9166
|
memoryRoot() {
|
|
9111
|
-
this.memoryRootCache ??=
|
|
9167
|
+
this.memoryRootCache ??= chunkSDZ4XDWS_cjs.resolveMemoryRoot(this.workspaceCwd, this.options.memory);
|
|
9112
9168
|
return this.memoryRootCache;
|
|
9113
9169
|
}
|
|
9114
9170
|
buildActiveMemoryOptions(cfg) {
|
|
@@ -9144,7 +9200,7 @@ var LocalAgentMemory = class {
|
|
|
9144
9200
|
await this.index.sync();
|
|
9145
9201
|
} catch (cause) {
|
|
9146
9202
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
9147
|
-
|
|
9203
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] session index sync failed: ${message}
|
|
9148
9204
|
`);
|
|
9149
9205
|
}
|
|
9150
9206
|
}
|
|
@@ -9157,7 +9213,7 @@ var LocalAgentMemory = class {
|
|
|
9157
9213
|
return await adapter.create(cfg.model !== void 0 ? { model: cfg.model } : {});
|
|
9158
9214
|
} catch (cause) {
|
|
9159
9215
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
9160
|
-
|
|
9216
|
+
chunkRNXXYF22_cjs.diag(`[theokit-sdk] memory embedding ${cfg.provider} unavailable: ${message}
|
|
9161
9217
|
`);
|
|
9162
9218
|
return void 0;
|
|
9163
9219
|
}
|
|
@@ -9223,7 +9279,7 @@ function createLocalAgentMemoryProvider(opts) {
|
|
|
9223
9279
|
return { facts: [], systemPromptAdditions: summary };
|
|
9224
9280
|
},
|
|
9225
9281
|
async recordSessionSummary(args) {
|
|
9226
|
-
await
|
|
9282
|
+
await chunkSDZ4XDWS_cjs.writeSessionSummary(args);
|
|
9227
9283
|
},
|
|
9228
9284
|
async sync(handle) {
|
|
9229
9285
|
const state = handle[INTERNAL_LAM_KEY];
|
|
@@ -9261,7 +9317,7 @@ var PersonalityRegistry = class _PersonalityRegistry {
|
|
|
9261
9317
|
* @internal
|
|
9262
9318
|
*/
|
|
9263
9319
|
static async load(cwd) {
|
|
9264
|
-
const projectDir = path.join(
|
|
9320
|
+
const projectDir = path.join(chunkYQ3XC6C2_cjs.theokitConfigRoot(cwd), PERSONALITIES_SUFFIX);
|
|
9265
9321
|
const userDir = path.join(os.homedir(), USER_SUBDIR);
|
|
9266
9322
|
const [userEntities, projectEntities] = await Promise.all([
|
|
9267
9323
|
loadMarkdownEntities({
|
|
@@ -9301,19 +9357,19 @@ var PersonalityRegistry = class _PersonalityRegistry {
|
|
|
9301
9357
|
function addEntity(byName, entity, origin, collisionMap) {
|
|
9302
9358
|
const fm = entity.frontmatter;
|
|
9303
9359
|
if (PersonalityRegistry.isReservedClearSlug(fm.name)) {
|
|
9304
|
-
throw new
|
|
9360
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
9305
9361
|
`Personality name "${fm.name}" is reserved (used to clear active preset)`,
|
|
9306
9362
|
{ code: "personality_reserved_name" }
|
|
9307
9363
|
);
|
|
9308
9364
|
}
|
|
9309
9365
|
if (entity.body.trim().length === 0) {
|
|
9310
|
-
throw new
|
|
9366
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
9311
9367
|
`Personality "${fm.name}" has empty body (system prompt required)`,
|
|
9312
9368
|
{ code: "personality_empty_body" }
|
|
9313
9369
|
);
|
|
9314
9370
|
}
|
|
9315
9371
|
if (origin === "project" && collisionMap?.has(fm.name)) {
|
|
9316
|
-
|
|
9372
|
+
chunkUDAKAE4Z_cjs.warnOnce(
|
|
9317
9373
|
`personality-collision-${fm.name}`,
|
|
9318
9374
|
`[theokit-sdk] personality "${fm.name}" overridden by project preset`
|
|
9319
9375
|
);
|
|
@@ -9342,7 +9398,7 @@ async function performPersonalitySwitch(args) {
|
|
|
9342
9398
|
const preset = args.registry.get(args.requestedName);
|
|
9343
9399
|
if (preset === void 0) {
|
|
9344
9400
|
const available = args.registry.all().map((p) => p.name).join(", ") || "(none)";
|
|
9345
|
-
throw new
|
|
9401
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
9346
9402
|
`Personality "${args.requestedName}" not found. Available: ${available}`,
|
|
9347
9403
|
{ code: "personality_not_found" }
|
|
9348
9404
|
);
|
|
@@ -9363,14 +9419,14 @@ async function performPersonalitySwitch(args) {
|
|
|
9363
9419
|
|
|
9364
9420
|
// src/internal/local-agent/local-agent-personality-extensions.ts
|
|
9365
9421
|
function resolveActivePersonalityPreset(args) {
|
|
9366
|
-
const forkCtx =
|
|
9422
|
+
const forkCtx = chunk7YUPSBDV_cjs.currentPersonalityContext();
|
|
9367
9423
|
const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
|
|
9368
9424
|
if (slug === void 0) return void 0;
|
|
9369
9425
|
return args.personalityRegistry?.get(slug);
|
|
9370
9426
|
}
|
|
9371
9427
|
async function ensurePersonalityRegistryIfNeeded(args) {
|
|
9372
9428
|
if (args.personalityRegistry !== void 0) return args.personalityRegistry;
|
|
9373
|
-
const forkSlug =
|
|
9429
|
+
const forkSlug = chunk7YUPSBDV_cjs.currentPersonalityContext()?.slug;
|
|
9374
9430
|
const ownSlug = args.personalityStore.active(args.agentId);
|
|
9375
9431
|
if (forkSlug === void 0 && ownSlug === void 0) return void 0;
|
|
9376
9432
|
return await PersonalityRegistry.load(args.workspaceCwd);
|
|
@@ -9383,8 +9439,8 @@ function applyPersonalityOverlay(preset, base) {
|
|
|
9383
9439
|
${preset.systemPrompt}`;
|
|
9384
9440
|
}
|
|
9385
9441
|
async function localAgentUsePersonality(agent, name, opts) {
|
|
9386
|
-
if (
|
|
9387
|
-
|
|
9442
|
+
if (chunk7YUPSBDV_cjs.currentPersonalityContext() !== void 0) {
|
|
9443
|
+
chunk7YUPSBDV_cjs.warnPersonalitySwitchInsideFork(agent.agentId);
|
|
9388
9444
|
return null;
|
|
9389
9445
|
}
|
|
9390
9446
|
if (agent.personalityRegistry === void 0) {
|
|
@@ -9400,8 +9456,8 @@ async function localAgentUsePersonality(agent, name, opts) {
|
|
|
9400
9456
|
registry,
|
|
9401
9457
|
store: agent.personalityStore,
|
|
9402
9458
|
invalidateCache: (reason) => agent.invalidateCache(reason),
|
|
9403
|
-
appendSessionMessage: (msg) =>
|
|
9404
|
-
clearSession: () =>
|
|
9459
|
+
appendSessionMessage: (msg) => chunkYOVZMN4P_cjs.appendSessionMessage(agent.agentId, msg),
|
|
9460
|
+
clearSession: () => chunkYOVZMN4P_cjs.clearSession(agent.agentId),
|
|
9405
9461
|
opts: opts ?? {}
|
|
9406
9462
|
})
|
|
9407
9463
|
);
|
|
@@ -9410,9 +9466,9 @@ async function localAgentUsePersonality(agent, name, opts) {
|
|
|
9410
9466
|
// src/internal/local-agent/local-agent-runtime-extensions.ts
|
|
9411
9467
|
function localAgentRunUntil(agent, goal, options) {
|
|
9412
9468
|
async function* wrap() {
|
|
9413
|
-
const { runUntilImpl } = await import('./run-until-
|
|
9469
|
+
const { runUntilImpl } = await import('./run-until-4KHVF7YC.cjs');
|
|
9414
9470
|
const buildDeps = async () => {
|
|
9415
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9471
|
+
const { judgeCallImpl } = await import('./judge-call-ZTUQMQRL.cjs');
|
|
9416
9472
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9417
9473
|
const create = getAgentFacade().create;
|
|
9418
9474
|
return {
|
|
@@ -9445,7 +9501,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
|
|
|
9445
9501
|
async function localAgentFork(parent, options) {
|
|
9446
9502
|
const { forkAgentImpl } = await import('./fork-agent-WAEQI2DL.cjs');
|
|
9447
9503
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9448
|
-
const { withPersonalityContext } = await import('./context-
|
|
9504
|
+
const { withPersonalityContext } = await import('./context-4RSI3AXT.cjs');
|
|
9449
9505
|
const create = getAgentFacade().create;
|
|
9450
9506
|
return withPersonalityContext(
|
|
9451
9507
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
@@ -9456,7 +9512,7 @@ async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userTe
|
|
|
9456
9512
|
if (memoryConfig?.enabled !== true) return;
|
|
9457
9513
|
const unstored = unstoredRememberWarning(userText);
|
|
9458
9514
|
if (unstored !== void 0) {
|
|
9459
|
-
|
|
9515
|
+
chunkRNXXYF22_cjs.diagFailure(unstored);
|
|
9460
9516
|
return;
|
|
9461
9517
|
}
|
|
9462
9518
|
if (!isMemoryWritePrompt(userText)) return;
|
|
@@ -9470,7 +9526,7 @@ async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userTe
|
|
|
9470
9526
|
});
|
|
9471
9527
|
} catch (cause) {
|
|
9472
9528
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
9473
|
-
|
|
9529
|
+
chunkRNXXYF22_cjs.diagFailure(`[theokit-sdk] memory write failed, nothing was stored: ${message}`);
|
|
9474
9530
|
}
|
|
9475
9531
|
}
|
|
9476
9532
|
|
|
@@ -9489,7 +9545,7 @@ function wrapRunWithCompletionCheck(args) {
|
|
|
9489
9545
|
judgeOpts
|
|
9490
9546
|
);
|
|
9491
9547
|
const complete = !verdict.parseFailed && verdict.verdict === "done";
|
|
9492
|
-
|
|
9548
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(args.onRunEvent, {
|
|
9493
9549
|
type: "completion_check",
|
|
9494
9550
|
complete,
|
|
9495
9551
|
reason: verdict.reason
|
|
@@ -9806,7 +9862,7 @@ function wrapRunWithOutputProcessors(args) {
|
|
|
9806
9862
|
if (result.status !== "finished" || result.result === void 0) return result;
|
|
9807
9863
|
const res = await runOutputProcessors(args.processors, result.result, args.agentId);
|
|
9808
9864
|
if (res.kind === "ok") return { ...result, result: res.value };
|
|
9809
|
-
|
|
9865
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(args.onRunEvent, {
|
|
9810
9866
|
type: "tripwire",
|
|
9811
9867
|
reason: res.tripwire.reason,
|
|
9812
9868
|
processorId: res.tripwire.processorId
|
|
@@ -9896,7 +9952,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9896
9952
|
}
|
|
9897
9953
|
const res = await runInputProcessors(processors, rawUserText, inputs.agentId);
|
|
9898
9954
|
if (res.kind === "tripwire") {
|
|
9899
|
-
|
|
9955
|
+
chunkL7JPXZ2C_cjs.emitRunEvent(options.onRunEvent, {
|
|
9900
9956
|
type: "tripwire",
|
|
9901
9957
|
reason: res.tripwire.reason,
|
|
9902
9958
|
processorId: res.tripwire.processorId
|
|
@@ -9913,7 +9969,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9913
9969
|
return { userText: res.value, effectiveMessage };
|
|
9914
9970
|
}
|
|
9915
9971
|
async function executeSendLocked(inputs, message, options) {
|
|
9916
|
-
if (inputs.disposed) throw new
|
|
9972
|
+
if (inputs.disposed) throw new chunkCEGU5AVD_cjs.AgentDisposedError(inputs.agentId);
|
|
9917
9973
|
await consumePending(
|
|
9918
9974
|
inputs.agentId,
|
|
9919
9975
|
inputs.invalidationPending,
|
|
@@ -9929,7 +9985,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9929
9985
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9930
9986
|
await inputs.options.onBeforeSend({
|
|
9931
9987
|
conversationId: inputs.agentId,
|
|
9932
|
-
previousMessageCount:
|
|
9988
|
+
previousMessageCount: chunkYOVZMN4P_cjs.getSessionMessages(inputs.agentId).length
|
|
9933
9989
|
});
|
|
9934
9990
|
}
|
|
9935
9991
|
await inputs.runPreHook(userText);
|
|
@@ -9941,8 +9997,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9941
9997
|
userText,
|
|
9942
9998
|
sendOptions: options
|
|
9943
9999
|
});
|
|
9944
|
-
const priorMessages = [...
|
|
9945
|
-
|
|
10000
|
+
const priorMessages = [...chunkYOVZMN4P_cjs.getSessionMessages(inputs.agentId)];
|
|
10001
|
+
chunkYOVZMN4P_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9946
10002
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9947
10003
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9948
10004
|
const memoryTools = void 0;
|
|
@@ -9993,7 +10049,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9993
10049
|
function buildCompletionCheckDeps() {
|
|
9994
10050
|
return {
|
|
9995
10051
|
judge: async (ctx, opts) => {
|
|
9996
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
10052
|
+
const { judgeCallImpl } = await import('./judge-call-ZTUQMQRL.cjs');
|
|
9997
10053
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9998
10054
|
return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
|
|
9999
10055
|
}
|
|
@@ -10004,7 +10060,7 @@ function reportRefusedMemoryDirectoryOnce(workspaceCwd, directory, message) {
|
|
|
10004
10060
|
const key = `${workspaceCwd}\0${directory ?? ""}`;
|
|
10005
10061
|
if (reportedRefusedDirectories.has(key)) return;
|
|
10006
10062
|
reportedRefusedDirectories.add(key);
|
|
10007
|
-
|
|
10063
|
+
chunkRNXXYF22_cjs.diagFailure(
|
|
10008
10064
|
`[theokit-sdk] memory is enabled but its directory was refused, so recall is empty on every turn and nothing is stored: ${message}`
|
|
10009
10065
|
);
|
|
10010
10066
|
}
|
|
@@ -10017,7 +10073,7 @@ function readMemoryForSend(workspaceCwd, memoryConfig, query) {
|
|
|
10017
10073
|
...query === void 0 ? {} : { query }
|
|
10018
10074
|
});
|
|
10019
10075
|
} catch (cause) {
|
|
10020
|
-
if (!(cause instanceof
|
|
10076
|
+
if (!(cause instanceof chunkCEGU5AVD_cjs.ConfigurationError)) throw cause;
|
|
10021
10077
|
reportRefusedMemoryDirectoryOnce(workspaceCwd, memoryConfig?.directory, cause.message);
|
|
10022
10078
|
return [];
|
|
10023
10079
|
}
|
|
@@ -10036,7 +10092,7 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
|
|
|
10036
10092
|
promptPreview: userText.slice(0, 120),
|
|
10037
10093
|
...opts.meta ?? {}
|
|
10038
10094
|
};
|
|
10039
|
-
void
|
|
10095
|
+
void chunkL7JPXZ2C_cjs.submit({
|
|
10040
10096
|
kind: "run",
|
|
10041
10097
|
work: async (ctx) => {
|
|
10042
10098
|
ctx.signal.addEventListener(
|
|
@@ -10047,7 +10103,7 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
|
|
|
10047
10103
|
},
|
|
10048
10104
|
{ once: true }
|
|
10049
10105
|
);
|
|
10050
|
-
const result = await run
|
|
10106
|
+
const result = await readRunResolving(run);
|
|
10051
10107
|
ctx.emit({ status: result.status, runId: run.id });
|
|
10052
10108
|
return { status: result.status, result: result.result };
|
|
10053
10109
|
},
|
|
@@ -10104,7 +10160,7 @@ function reportUnknownLocalOptions(local) {
|
|
|
10104
10160
|
reported.add(key);
|
|
10105
10161
|
const guess = nearest(key);
|
|
10106
10162
|
const hint = guess === void 0 ? "" : ` Did you mean \`${guess}\`?`;
|
|
10107
|
-
|
|
10163
|
+
chunkRNXXYF22_cjs.diag(
|
|
10108
10164
|
`[theokit] \`local.${key}\` is not an option this SDK version knows, so it was ignored.${hint}
|
|
10109
10165
|
`
|
|
10110
10166
|
);
|
|
@@ -10195,7 +10251,7 @@ var LocalAgent = class {
|
|
|
10195
10251
|
this.options = options;
|
|
10196
10252
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
10197
10253
|
this.transcriptBaseDir = resolveSessionDir(options.local);
|
|
10198
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
10254
|
+
this.sessionStore = options.local?.sessionStore ?? new chunk6OCJWGVD_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
10199
10255
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
10200
10256
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
10201
10257
|
const sub = bootstrapSubmanagers({
|
|
@@ -10212,7 +10268,7 @@ var LocalAgent = class {
|
|
|
10212
10268
|
if (sub.plugins !== void 0) this.plugins = sub.plugins;
|
|
10213
10269
|
reportUnknownLocalOptions(options.local);
|
|
10214
10270
|
const compatSources = resolveCompatSources(options, this.workspaceCwd);
|
|
10215
|
-
|
|
10271
|
+
chunkYQ3XC6C2_cjs.reportUndeclaredSources(this.workspaceCwd, compatSources);
|
|
10216
10272
|
this.hooksExecutor = new HooksExecutor(this.workspaceCwd, compatSources, options.local?.hooks);
|
|
10217
10273
|
this.defaultMemoryProviderForLoop = createLocalAgentMemoryProvider({
|
|
10218
10274
|
agentOptions: options,
|
|
@@ -10240,7 +10296,7 @@ var LocalAgent = class {
|
|
|
10240
10296
|
if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
|
|
10241
10297
|
const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
|
|
10242
10298
|
await this.pluginManagerCode.initialize(codePlugins);
|
|
10243
|
-
this.resolvedSubagents = await
|
|
10299
|
+
this.resolvedSubagents = await chunkWDVG5R2Q_cjs.loadSubagents(
|
|
10244
10300
|
this.workspaceCwd,
|
|
10245
10301
|
this.settingSourcesIncludeProject,
|
|
10246
10302
|
this.options.agents,
|
|
@@ -10248,7 +10304,7 @@ var LocalAgent = class {
|
|
|
10248
10304
|
);
|
|
10249
10305
|
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
10250
10306
|
try {
|
|
10251
|
-
await
|
|
10307
|
+
await chunkYOVZMN4P_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
10252
10308
|
await this.personalityStore.hydrate(this.agentId);
|
|
10253
10309
|
} catch (err) {
|
|
10254
10310
|
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
@@ -10308,7 +10364,7 @@ var LocalAgent = class {
|
|
|
10308
10364
|
return;
|
|
10309
10365
|
}
|
|
10310
10366
|
if (options.task !== void 0) registerRunAsTask(run, this.agentId, options.task, userText);
|
|
10311
|
-
resolve(run);
|
|
10367
|
+
resolve(callerView(run, this.options.throwOnError));
|
|
10312
10368
|
try {
|
|
10313
10369
|
await runPostRunLifecycle({
|
|
10314
10370
|
run,
|
|
@@ -10406,7 +10462,7 @@ var LocalAgent = class {
|
|
|
10406
10462
|
agentId: this.agentId
|
|
10407
10463
|
});
|
|
10408
10464
|
if (preRun.blocked) {
|
|
10409
|
-
throw new
|
|
10465
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
10410
10466
|
`preRun hook denied execution: ${preRun.reason ?? "unspecified"}`,
|
|
10411
10467
|
{ code: "hook_denied" }
|
|
10412
10468
|
);
|
|
@@ -10512,6 +10568,9 @@ var LocalAgent = class {
|
|
|
10512
10568
|
return localAgentStreamToCompletion(this, message, options);
|
|
10513
10569
|
}
|
|
10514
10570
|
};
|
|
10571
|
+
function callerView(run, throwOnError) {
|
|
10572
|
+
return throwOnError === true ? wrapRunWithThrowOnError(run) : run;
|
|
10573
|
+
}
|
|
10515
10574
|
function resolveCwd(cwd) {
|
|
10516
10575
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|
|
10517
10576
|
}
|
|
@@ -10538,7 +10597,7 @@ async function guardAgainstIdCollision(options) {
|
|
|
10538
10597
|
const persistenceCwd = resolveAgentPersistenceCwd(options);
|
|
10539
10598
|
await hydrateRegistryFromDisk(persistenceCwd);
|
|
10540
10599
|
if (getRegisteredAgent(options.agentId) !== void 0) {
|
|
10541
|
-
throw new
|
|
10600
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
10542
10601
|
`Agent "${options.agentId}" already exists. Use Agent.resume("${options.agentId}") to reattach, or pick a different agentId.`,
|
|
10543
10602
|
{ code: "agent_id_already_exists" }
|
|
10544
10603
|
);
|
|
@@ -10571,7 +10630,7 @@ async function maybeInjectHandoffTools(options) {
|
|
|
10571
10630
|
const spec = "@theokit/sdk-handoff/internal/tool-injector";
|
|
10572
10631
|
mod = await import(spec);
|
|
10573
10632
|
} catch (err) {
|
|
10574
|
-
throw new
|
|
10633
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
10575
10634
|
"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).",
|
|
10576
10635
|
{ code: "handoff_package_missing", cause: err }
|
|
10577
10636
|
);
|
|
@@ -10589,40 +10648,40 @@ async function maybeInjectHandoffTools(options) {
|
|
|
10589
10648
|
};
|
|
10590
10649
|
}
|
|
10591
10650
|
function keyWillFlowToProvider(apiKey, provider) {
|
|
10592
|
-
if (
|
|
10593
|
-
if (
|
|
10651
|
+
if (chunkLSWHDOCL_cjs.isFixtureApiKey(apiKey)) return false;
|
|
10652
|
+
if (chunkLSWHDOCL_cjs.getConfiguredBaseUrl() !== void 0) return false;
|
|
10594
10653
|
if (provider === void 0) return false;
|
|
10595
|
-
const profile =
|
|
10654
|
+
const profile = chunkLO6LIUZ6_cjs.getProviderProfile(provider);
|
|
10596
10655
|
if (profile === void 0) return false;
|
|
10597
10656
|
return profile.authType !== "none";
|
|
10598
10657
|
}
|
|
10599
10658
|
function missingApiKeyMessage() {
|
|
10600
|
-
const present =
|
|
10601
|
-
const base = `Missing API key \u2014 set ${
|
|
10659
|
+
const present = chunkLSWHDOCL_cjs.presentProviderCredentialEnvVars();
|
|
10660
|
+
const base = `Missing API key \u2014 set ${chunkRNXXYF22_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
|
|
10602
10661
|
if (present.length === 0) return `${base}.`;
|
|
10603
10662
|
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]}, ... })\`.`;
|
|
10604
10663
|
}
|
|
10605
10664
|
function providerNeedsCallerKey(provider) {
|
|
10606
10665
|
if (provider === void 0) return true;
|
|
10607
|
-
const profile =
|
|
10666
|
+
const profile = chunkLO6LIUZ6_cjs.getProviderProfile(provider);
|
|
10608
10667
|
if (profile === void 0) return true;
|
|
10609
10668
|
return profile.authType === "api_key";
|
|
10610
10669
|
}
|
|
10611
10670
|
async function createLocalAgent(options) {
|
|
10612
10671
|
const provider = providerFromModelId(normalizeModel(options.model)?.id);
|
|
10613
|
-
const apiKey =
|
|
10672
|
+
const apiKey = chunkRNXXYF22_cjs.resolveApiKey(options.apiKey);
|
|
10614
10673
|
if (apiKey === void 0) {
|
|
10615
10674
|
if (providerNeedsCallerKey(provider)) {
|
|
10616
|
-
throw new
|
|
10675
|
+
throw new chunkCEGU5AVD_cjs.AuthenticationError(missingApiKeyMessage(), { code: "missing_api_key" });
|
|
10617
10676
|
}
|
|
10618
10677
|
} else {
|
|
10619
10678
|
const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
|
|
10620
|
-
const shape =
|
|
10679
|
+
const shape = chunkLSWHDOCL_cjs.validateApiKeyShape(apiKey, {
|
|
10621
10680
|
strict: willFlowToProvider,
|
|
10622
10681
|
...willFlowToProvider ? { provider } : {}
|
|
10623
10682
|
});
|
|
10624
10683
|
if (shape.malformed) {
|
|
10625
|
-
throw new
|
|
10684
|
+
throw new chunkCEGU5AVD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10626
10685
|
}
|
|
10627
10686
|
}
|
|
10628
10687
|
const agent = new LocalAgent(options);
|
|
@@ -10630,21 +10689,21 @@ async function createLocalAgent(options) {
|
|
|
10630
10689
|
return agent;
|
|
10631
10690
|
}
|
|
10632
10691
|
async function createCloudAgent(options) {
|
|
10633
|
-
const apiKey =
|
|
10692
|
+
const apiKey = chunkRNXXYF22_cjs.resolveApiKey(options.apiKey);
|
|
10634
10693
|
if (apiKey === void 0) {
|
|
10635
|
-
throw new
|
|
10694
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError("Missing API key for cloud agent", {
|
|
10636
10695
|
code: "missing_api_key"
|
|
10637
10696
|
});
|
|
10638
10697
|
}
|
|
10639
|
-
const shape =
|
|
10698
|
+
const shape = chunkLSWHDOCL_cjs.validateApiKeyShape(apiKey);
|
|
10640
10699
|
if (shape.malformed) {
|
|
10641
|
-
throw new
|
|
10700
|
+
throw new chunkCEGU5AVD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10642
10701
|
}
|
|
10643
|
-
const baseUrl =
|
|
10702
|
+
const baseUrl = chunkLSWHDOCL_cjs.getConfiguredBaseUrl();
|
|
10644
10703
|
if (baseUrl === void 0) {
|
|
10645
10704
|
return new CloudAgent(options);
|
|
10646
10705
|
}
|
|
10647
|
-
const response = await
|
|
10706
|
+
const response = await chunkLSWHDOCL_cjs.httpRequest("/v1/agents", {
|
|
10648
10707
|
apiKey,
|
|
10649
10708
|
method: "POST",
|
|
10650
10709
|
body: {
|
|
@@ -10669,7 +10728,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
10669
10728
|
return process.cwd();
|
|
10670
10729
|
}
|
|
10671
10730
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
10672
|
-
await
|
|
10731
|
+
await chunkLSWHDOCL_cjs.discoverProviderPlugins();
|
|
10673
10732
|
await validateRehydratedAgent(agentId, existing);
|
|
10674
10733
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
10675
10734
|
const mergedMemory = mergeResumedMemory(existing.options.memory, options.memory);
|
|
@@ -10685,7 +10744,7 @@ async function rehydrateExistingAgent(agentId, existing, options) {
|
|
|
10685
10744
|
mcpServers: void 0,
|
|
10686
10745
|
agentId
|
|
10687
10746
|
};
|
|
10688
|
-
|
|
10747
|
+
chunkSDZ4XDWS_cjs.resolveMaxFacts(mergedOptions.memory?.maxFacts);
|
|
10689
10748
|
if (existing.runtime === "cloud") {
|
|
10690
10749
|
return new CloudAgent(mergedOptions, agentId);
|
|
10691
10750
|
}
|
|
@@ -10707,13 +10766,13 @@ async function validateRehydratedAgent(agentId, entry) {
|
|
|
10707
10766
|
try {
|
|
10708
10767
|
info = await promises.stat(candidate);
|
|
10709
10768
|
} catch (cause) {
|
|
10710
|
-
throw new
|
|
10769
|
+
throw new chunkCEGU5AVD_cjs.UnknownAgentError(
|
|
10711
10770
|
`Agent "${agentId}" cannot be rehydrated \u2014 workspace cwd "${candidate}" is missing or inaccessible.`,
|
|
10712
10771
|
{ code: "agent_rehydration_failed", cause }
|
|
10713
10772
|
);
|
|
10714
10773
|
}
|
|
10715
10774
|
if (!info.isDirectory()) {
|
|
10716
|
-
throw new
|
|
10775
|
+
throw new chunkCEGU5AVD_cjs.UnknownAgentError(
|
|
10717
10776
|
`Agent "${agentId}" cannot be rehydrated \u2014 workspace cwd "${candidate}" exists but is not a directory.`,
|
|
10718
10777
|
{ code: "agent_rehydration_failed" }
|
|
10719
10778
|
);
|
|
@@ -10768,7 +10827,7 @@ async function getRegisteredAgentOrThrow(agentId, cwd = process.cwd()) {
|
|
|
10768
10827
|
agent = getRegisteredAgent(agentId);
|
|
10769
10828
|
}
|
|
10770
10829
|
if (agent === void 0) {
|
|
10771
|
-
throw new
|
|
10830
|
+
throw new chunkCEGU5AVD_cjs.UnknownAgentError(`Agent ${agentId} not found`, { code: "unknown_agent" });
|
|
10772
10831
|
}
|
|
10773
10832
|
return agent;
|
|
10774
10833
|
}
|
|
@@ -10829,7 +10888,7 @@ var Agent = class _Agent {
|
|
|
10829
10888
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
10830
10889
|
});
|
|
10831
10890
|
try {
|
|
10832
|
-
await
|
|
10891
|
+
await chunkLSWHDOCL_cjs.discoverProviderPlugins();
|
|
10833
10892
|
const agent = await runCreateUnderSpan(options, span);
|
|
10834
10893
|
return agent;
|
|
10835
10894
|
} catch (err) {
|
|
@@ -10865,13 +10924,13 @@ var Agent = class _Agent {
|
|
|
10865
10924
|
* @public
|
|
10866
10925
|
*/
|
|
10867
10926
|
static async prompt(message, options) {
|
|
10868
|
-
const agent = await _Agent.create(options);
|
|
10927
|
+
const agent = await _Agent.create({ ...options, throwOnError: false });
|
|
10869
10928
|
try {
|
|
10870
10929
|
const run = await agent.send(message);
|
|
10871
10930
|
const result = await run.wait();
|
|
10872
10931
|
if (options.throwOnError === true && result.status === "error" && result.error !== void 0) {
|
|
10873
|
-
throw new
|
|
10874
|
-
code:
|
|
10932
|
+
throw new chunkCEGU5AVD_cjs.AgentRunError(result.error.message, {
|
|
10933
|
+
code: chunkCEGU5AVD_cjs.coerceToKnownAgentRunErrorCode(result.error.code),
|
|
10875
10934
|
cause: result.error.cause
|
|
10876
10935
|
});
|
|
10877
10936
|
}
|
|
@@ -10898,7 +10957,7 @@ var Agent = class _Agent {
|
|
|
10898
10957
|
if (existing !== void 0) {
|
|
10899
10958
|
return await rehydrateExistingAgent(agentId, existing, options);
|
|
10900
10959
|
}
|
|
10901
|
-
throw new
|
|
10960
|
+
throw new chunkCEGU5AVD_cjs.UnknownAgentError(
|
|
10902
10961
|
`Agent "${agentId}" not found. Use Agent.create({ agentId, ... }) for first-time setup, or catch UnknownAgentError to branch resume-vs-create.`,
|
|
10903
10962
|
{ code: "unknown_agent" }
|
|
10904
10963
|
);
|
|
@@ -10927,7 +10986,7 @@ var Agent = class _Agent {
|
|
|
10927
10986
|
* @public
|
|
10928
10987
|
*/
|
|
10929
10988
|
static async generateObject(options) {
|
|
10930
|
-
const { generateObjectImpl } = await import('./generate-object-
|
|
10989
|
+
const { generateObjectImpl } = await import('./generate-object-XBWD2PU7.cjs');
|
|
10931
10990
|
return generateObjectImpl(options, {
|
|
10932
10991
|
create: (opts) => _Agent.create(opts),
|
|
10933
10992
|
delete: (agentId) => _Agent.delete(agentId)
|
|
@@ -10951,7 +11010,7 @@ var Agent = class _Agent {
|
|
|
10951
11010
|
delete: (agentId) => _Agent.delete(agentId)
|
|
10952
11011
|
};
|
|
10953
11012
|
async function* wrapper() {
|
|
10954
|
-
streamObjectImport ??= import('./stream-object-
|
|
11013
|
+
streamObjectImport ??= import('./stream-object-TEEK3CAX.cjs');
|
|
10955
11014
|
const { streamObjectImpl } = await streamObjectImport;
|
|
10956
11015
|
yield* streamObjectImpl(options, deps);
|
|
10957
11016
|
}
|
|
@@ -10975,7 +11034,7 @@ var Agent = class _Agent {
|
|
|
10975
11034
|
* @public
|
|
10976
11035
|
*/
|
|
10977
11036
|
static async batch(prompts, options) {
|
|
10978
|
-
const { batchImpl } = await import('./batch-
|
|
11037
|
+
const { batchImpl } = await import('./batch-IZ5EDKJ5.cjs');
|
|
10979
11038
|
return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
|
|
10980
11039
|
}
|
|
10981
11040
|
/**
|
|
@@ -11078,14 +11137,14 @@ var Agent = class _Agent {
|
|
|
11078
11137
|
*/
|
|
11079
11138
|
static async getRun(runId, options = {}) {
|
|
11080
11139
|
if (options.runtime === "cloud") {
|
|
11081
|
-
throw new
|
|
11140
|
+
throw new chunkCEGU5AVD_cjs.ConfigurationError(
|
|
11082
11141
|
"Cloud runtime is pre-release. Theo PaaS endpoints are not wired yet \u2014 getRun({ runtime: 'cloud' }) will be enabled when the PaaS ships.",
|
|
11083
11142
|
{ code: "cloud_runtime_pre_release" }
|
|
11084
11143
|
);
|
|
11085
11144
|
}
|
|
11086
11145
|
const existing = getRun(runId);
|
|
11087
11146
|
if (existing !== void 0) return existing;
|
|
11088
|
-
throw new
|
|
11147
|
+
throw new chunkCEGU5AVD_cjs.UnknownAgentError(
|
|
11089
11148
|
`Run ${runId} is not in this process's registry. It may have been disposed, persisted in a previous process, or never created.`,
|
|
11090
11149
|
{ code: "run_not_found" }
|
|
11091
11150
|
);
|
|
@@ -11127,9 +11186,9 @@ var Agent = class _Agent {
|
|
|
11127
11186
|
*/
|
|
11128
11187
|
static async compact(agentId, options = {}) {
|
|
11129
11188
|
const reg = await requireLocalAgent(agentId, "compact");
|
|
11130
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
11189
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-NM56BREJ.cjs');
|
|
11131
11190
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
11132
|
-
return
|
|
11191
|
+
return chunkYOVZMN4P_cjs.enqueueSessionWrite(
|
|
11133
11192
|
cwd,
|
|
11134
11193
|
agentId,
|
|
11135
11194
|
() => compactSessionTranscript({
|
|
@@ -11157,7 +11216,7 @@ var Agent = class _Agent {
|
|
|
11157
11216
|
*/
|
|
11158
11217
|
static async injectSessionTurn(agentId, turn) {
|
|
11159
11218
|
const reg = await requireLocalAgent(agentId, "injectSessionTurn");
|
|
11160
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
11219
|
+
const { injectSessionTurn } = await import('./inject-session-JVTZNQF6.cjs');
|
|
11161
11220
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
11162
11221
|
await injectSessionTurn({
|
|
11163
11222
|
store,
|
|
@@ -11187,7 +11246,7 @@ var Agent = class _Agent {
|
|
|
11187
11246
|
*/
|
|
11188
11247
|
static async transcript(agentId) {
|
|
11189
11248
|
const reg = await requireLocalAgent(agentId, "transcript");
|
|
11190
|
-
const { readSessionMessages } = await import('./agent-session-store-
|
|
11249
|
+
const { readSessionMessages } = await import('./agent-session-store-WP6NGDVX.cjs');
|
|
11191
11250
|
const { store } = await openLocalStore(reg);
|
|
11192
11251
|
return readSessionMessages(store, agentId);
|
|
11193
11252
|
}
|
|
@@ -11208,7 +11267,7 @@ var Agent = class _Agent {
|
|
|
11208
11267
|
*/
|
|
11209
11268
|
static async describe(agentId) {
|
|
11210
11269
|
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
11211
|
-
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-
|
|
11270
|
+
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-TXOA5EJJ.cjs');
|
|
11212
11271
|
const settingSources = agent.options.local?.settingSources;
|
|
11213
11272
|
const subagents = await loadSubagents2(
|
|
11214
11273
|
agent.cwd ?? process.cwd(),
|
|
@@ -11271,12 +11330,12 @@ async function getOrCreateUncached(agentId, options) {
|
|
|
11271
11330
|
try {
|
|
11272
11331
|
return await Agent.resume(agentId, options);
|
|
11273
11332
|
} catch (err) {
|
|
11274
|
-
if (!(err instanceof
|
|
11333
|
+
if (!(err instanceof chunkCEGU5AVD_cjs.UnknownAgentError)) throw err;
|
|
11275
11334
|
}
|
|
11276
11335
|
try {
|
|
11277
11336
|
return await Agent.create({ ...options, agentId });
|
|
11278
11337
|
} catch (err) {
|
|
11279
|
-
if (err instanceof
|
|
11338
|
+
if (err instanceof chunkCEGU5AVD_cjs.ConfigurationError && err.code === "agent_id_already_exists") {
|
|
11280
11339
|
return await Agent.resume(agentId, options);
|
|
11281
11340
|
}
|
|
11282
11341
|
throw err;
|
|
@@ -11297,7 +11356,7 @@ async function requireLocalAgent(agentId, operation) {
|
|
|
11297
11356
|
reg = getRegisteredAgent(agentId);
|
|
11298
11357
|
}
|
|
11299
11358
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
11300
|
-
throw new
|
|
11359
|
+
throw new chunkCEGU5AVD_cjs.UnknownAgentError(
|
|
11301
11360
|
`No local agent "${agentId}" registered \u2014 ${operation} targets local sessions.`
|
|
11302
11361
|
);
|
|
11303
11362
|
}
|
|
@@ -11307,8 +11366,8 @@ async function openLocalStore(reg) {
|
|
|
11307
11366
|
const cwd = reg.cwd ?? process.cwd();
|
|
11308
11367
|
const optModel = reg.options.model;
|
|
11309
11368
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
11310
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
11311
|
-
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-
|
|
11369
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-S2AXVJIX.cjs');
|
|
11370
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-7TZ6HXSX.cjs');
|
|
11312
11371
|
const configuredSessionDir = reg.options.local?.sessionDir ?? reg.options.local?.baseDir;
|
|
11313
11372
|
const baseDir = configuredSessionDir !== void 0 ? expandTilde2(configuredSessionDir) : defaultBaseDir2();
|
|
11314
11373
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
@@ -11328,5 +11387,5 @@ exports.managedSettingsPathFor = managedSettingsPathFor;
|
|
|
11328
11387
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
11329
11388
|
exports.readManagedSettings = readManagedSettings;
|
|
11330
11389
|
exports.resolveSessionDir = resolveSessionDir;
|
|
11331
|
-
//# sourceMappingURL=chunk-
|
|
11332
|
-
//# sourceMappingURL=chunk-
|
|
11390
|
+
//# sourceMappingURL=chunk-Q6WT5535.cjs.map
|
|
11391
|
+
//# sourceMappingURL=chunk-Q6WT5535.cjs.map
|