@theokit/sdk 4.62.0 → 4.63.1
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 +97 -0
- package/dist/a2a/index.cjs +2 -2
- package/dist/a2a/index.js +1 -1
- package/dist/{agent-DIu6FooJ.d.ts → agent-BFno7Sfn.d.ts} +36 -21
- package/dist/agent-WK7MKIMH.cjs +66 -0
- package/dist/{agent-VYPUO4UB.cjs.map → agent-WK7MKIMH.cjs.map} +1 -1
- package/dist/{agent-D3Xr_-6Z.d.cts → agent-X0DKA943.d.cts} +36 -21
- package/dist/agent-YWMBM7LX.js +57 -0
- package/dist/{agent-NVBFTY5H.js.map → agent-YWMBM7LX.js.map} +1 -1
- package/dist/agent-session-store-6EL5NPA4.cjs +24 -0
- package/dist/{agent-session-store-WAKLOKWK.cjs.map → agent-session-store-6EL5NPA4.cjs.map} +1 -1
- package/dist/agent-session-store-OPGRB4XM.js +7 -0
- package/dist/{agent-session-store-G2BMUZQV.js.map → agent-session-store-OPGRB4XM.js.map} +1 -1
- package/dist/auth/index.cjs +18 -18
- package/dist/auth/index.js +6 -6
- package/dist/{batch-ND32UKZS.cjs → batch-BXYTW2DP.cjs} +27 -27
- package/dist/{batch-ND32UKZS.cjs.map → batch-BXYTW2DP.cjs.map} +1 -1
- package/dist/{batch-2TGJMNCJ.js → batch-L4ZXS46M.js} +10 -10
- package/dist/{batch-2TGJMNCJ.js.map → batch-L4ZXS46M.js.map} +1 -1
- package/dist/{chunk-VF7EWVDG.js → chunk-2GUYQR5P.js} +3 -3
- package/dist/{chunk-VF7EWVDG.js.map → chunk-2GUYQR5P.js.map} +1 -1
- package/dist/{chunk-J2UROOIG.cjs → chunk-2HVF2WJY.cjs} +8 -8
- package/dist/{chunk-J2UROOIG.cjs.map → chunk-2HVF2WJY.cjs.map} +1 -1
- package/dist/{chunk-44MBDIHG.js → chunk-2QDYBS2A.js} +3 -3
- package/dist/{chunk-44MBDIHG.js.map → chunk-2QDYBS2A.js.map} +1 -1
- package/dist/{chunk-NGESVVJN.cjs → chunk-3FFAEAUJ.cjs} +17 -17
- package/dist/{chunk-NGESVVJN.cjs.map → chunk-3FFAEAUJ.cjs.map} +1 -1
- package/dist/{chunk-GWC3HADL.cjs → chunk-3NSS2OIZ.cjs} +4 -4
- package/dist/{chunk-GWC3HADL.cjs.map → chunk-3NSS2OIZ.cjs.map} +1 -1
- package/dist/{chunk-CV7XMBHP.js → chunk-3O42QOMJ.js} +3 -3
- package/dist/{chunk-CV7XMBHP.js.map → chunk-3O42QOMJ.js.map} +1 -1
- package/dist/{chunk-IWBGCBR6.cjs → chunk-4CLOXP6H.cjs} +4 -4
- package/dist/{chunk-IWBGCBR6.cjs.map → chunk-4CLOXP6H.cjs.map} +1 -1
- package/dist/{chunk-YEXA3PGR.js → chunk-4FFBAUFS.js} +5 -5
- package/dist/{chunk-YEXA3PGR.js.map → chunk-4FFBAUFS.js.map} +1 -1
- package/dist/{chunk-HY57ULY2.cjs → chunk-4PYZ5AX3.cjs} +5 -5
- package/dist/{chunk-HY57ULY2.cjs.map → chunk-4PYZ5AX3.cjs.map} +1 -1
- package/dist/{chunk-OC4NTGMN.js → chunk-4QZSA2HJ.js} +3 -3
- package/dist/{chunk-OC4NTGMN.js.map → chunk-4QZSA2HJ.js.map} +1 -1
- package/dist/{chunk-K3FW2XZD.cjs → chunk-4ZHTIJNE.cjs} +9 -9
- package/dist/{chunk-K3FW2XZD.cjs.map → chunk-4ZHTIJNE.cjs.map} +1 -1
- package/dist/{chunk-BUIK7GUA.cjs → chunk-5HEG4CQH.cjs} +8 -8
- package/dist/{chunk-BUIK7GUA.cjs.map → chunk-5HEG4CQH.cjs.map} +1 -1
- package/dist/{chunk-SKXBJ2NU.cjs → chunk-5VB22SYX.cjs} +7 -54
- package/dist/chunk-5VB22SYX.cjs.map +1 -0
- package/dist/{chunk-5USCYPPI.cjs → chunk-6HKGLTJI.cjs} +8 -8
- package/dist/{chunk-5USCYPPI.cjs.map → chunk-6HKGLTJI.cjs.map} +1 -1
- package/dist/chunk-6RKUO7AW.cjs +864 -0
- package/dist/chunk-6RKUO7AW.cjs.map +1 -0
- package/dist/{chunk-5JLFFPCH.js → chunk-7YGCPMGB.js} +4 -4
- package/dist/{chunk-5JLFFPCH.js.map → chunk-7YGCPMGB.js.map} +1 -1
- package/dist/{chunk-SUKXXLWD.js → chunk-A46SWMIF.js} +6 -6
- package/dist/{chunk-SUKXXLWD.js.map → chunk-A46SWMIF.js.map} +1 -1
- package/dist/{chunk-F7AQV62G.js → chunk-A4JVILQU.js} +5 -5
- package/dist/{chunk-F7AQV62G.js.map → chunk-A4JVILQU.js.map} +1 -1
- package/dist/chunk-A4RAL2ER.cjs +51 -0
- package/dist/chunk-A4RAL2ER.cjs.map +1 -0
- package/dist/{chunk-44JAAH4X.js → chunk-B3IMEBOA.js} +3 -3
- package/dist/{chunk-44JAAH4X.js.map → chunk-B3IMEBOA.js.map} +1 -1
- package/dist/{chunk-QDED6YO6.cjs → chunk-B4EOJWOY.cjs} +5 -5
- package/dist/{chunk-QDED6YO6.cjs.map → chunk-B4EOJWOY.cjs.map} +1 -1
- package/dist/{chunk-YJDH3CKG.js → chunk-BP46RJ5X.js} +5 -5
- package/dist/{chunk-YJDH3CKG.js.map → chunk-BP46RJ5X.js.map} +1 -1
- package/dist/{chunk-QRSUA2CV.js → chunk-BU4KFWXF.js} +3 -3
- package/dist/{chunk-QRSUA2CV.js.map → chunk-BU4KFWXF.js.map} +1 -1
- package/dist/{chunk-IBYRA5PM.js → chunk-BVJJ3DRV.js} +6 -6
- package/dist/{chunk-IBYRA5PM.js.map → chunk-BVJJ3DRV.js.map} +1 -1
- package/dist/{chunk-AQLGBKNT.js → chunk-BZRFXJHA.js} +3 -3
- package/dist/{chunk-AQLGBKNT.js.map → chunk-BZRFXJHA.js.map} +1 -1
- package/dist/{chunk-UQGQFBRL.js → chunk-C3NT3PVE.js} +3 -3
- package/dist/{chunk-UQGQFBRL.js.map → chunk-C3NT3PVE.js.map} +1 -1
- package/dist/{chunk-UC3HT2S4.js → chunk-C72AZW7J.js} +3 -3
- package/dist/{chunk-UC3HT2S4.js.map → chunk-C72AZW7J.js.map} +1 -1
- package/dist/{chunk-WNTAPVU5.cjs → chunk-CQBXOJ6U.cjs} +13 -13
- package/dist/{chunk-WNTAPVU5.cjs.map → chunk-CQBXOJ6U.cjs.map} +1 -1
- package/dist/{chunk-T7XEKOVW.js → chunk-D4CUGAKZ.js} +3 -3
- package/dist/{chunk-T7XEKOVW.js.map → chunk-D4CUGAKZ.js.map} +1 -1
- package/dist/chunk-DKD3MH6A.js +194 -0
- package/dist/chunk-DKD3MH6A.js.map +1 -0
- package/dist/{chunk-YXGAW7BB.js → chunk-DN2PACRI.js} +10 -10
- package/dist/{chunk-YXGAW7BB.js.map → chunk-DN2PACRI.js.map} +1 -1
- package/dist/{chunk-XSX2UU6Y.cjs → chunk-DXGZ2NUG.cjs} +10 -10
- package/dist/{chunk-XSX2UU6Y.cjs.map → chunk-DXGZ2NUG.cjs.map} +1 -1
- package/dist/{chunk-NUKRL3I6.cjs → chunk-EG4QM7ZJ.cjs} +18 -2
- package/dist/chunk-EG4QM7ZJ.cjs.map +1 -0
- package/dist/chunk-GEEXBYFL.js +831 -0
- package/dist/chunk-GEEXBYFL.js.map +1 -0
- package/dist/chunk-GKEFRLU7.cjs +21 -0
- package/dist/chunk-GKEFRLU7.cjs.map +1 -0
- package/dist/{chunk-NIRE5CNO.cjs → chunk-HCZD23VS.cjs} +13 -13
- package/dist/{chunk-NIRE5CNO.cjs.map → chunk-HCZD23VS.cjs.map} +1 -1
- package/dist/chunk-HOXVQ5FR.cjs +201 -0
- package/dist/chunk-HOXVQ5FR.cjs.map +1 -0
- package/dist/{chunk-QARJGQSA.js → chunk-HS7AVXTF.js} +3 -3
- package/dist/{chunk-QARJGQSA.js.map → chunk-HS7AVXTF.js.map} +1 -1
- package/dist/{chunk-4I55V454.cjs → chunk-I6HGWHPU.cjs} +4 -4
- package/dist/{chunk-4I55V454.cjs.map → chunk-I6HGWHPU.cjs.map} +1 -1
- package/dist/{chunk-T73NA43R.js → chunk-IPYYKCRC.js} +3 -3
- package/dist/{chunk-T73NA43R.js.map → chunk-IPYYKCRC.js.map} +1 -1
- package/dist/{chunk-6OBIWHDR.cjs → chunk-ITYQ6VBP.cjs} +24 -365
- package/dist/chunk-ITYQ6VBP.cjs.map +1 -0
- package/dist/chunk-JPBKYL3B.cjs +18 -0
- package/dist/{chunk-6HTXPPHK.cjs.map → chunk-JPBKYL3B.cjs.map} +1 -1
- package/dist/{chunk-MZ2FGBLZ.js → chunk-K5OJUYSZ.js} +4 -4
- package/dist/{chunk-MZ2FGBLZ.js.map → chunk-K5OJUYSZ.js.map} +1 -1
- package/dist/{chunk-SKOCYA55.js → chunk-KIH6IZ43.js} +90 -88
- package/dist/chunk-KIH6IZ43.js.map +1 -0
- package/dist/{chunk-EI2Q7SJ5.cjs → chunk-KQ7TS7WW.cjs} +10 -10
- package/dist/{chunk-EI2Q7SJ5.cjs.map → chunk-KQ7TS7WW.cjs.map} +1 -1
- package/dist/{chunk-RUDY2GTT.js → chunk-KQRW2GPZ.js} +5 -5
- package/dist/{chunk-RUDY2GTT.js.map → chunk-KQRW2GPZ.js.map} +1 -1
- package/dist/{chunk-P5LCASTC.cjs → chunk-KYAJINUI.cjs} +125 -125
- package/dist/{chunk-P5LCASTC.cjs.map → chunk-KYAJINUI.cjs.map} +1 -1
- package/dist/{chunk-CQ2TQ32Y.js → chunk-LWGSI6M3.js} +5 -50
- package/dist/chunk-LWGSI6M3.js.map +1 -0
- package/dist/{chunk-ZHPWGIUX.js → chunk-LXI4XZEC.js} +5 -5
- package/dist/{chunk-ZHPWGIUX.js.map → chunk-LXI4XZEC.js.map} +1 -1
- package/dist/{chunk-AG5JPQIY.js → chunk-LXQ6HKPS.js} +3 -3
- package/dist/{chunk-AG5JPQIY.js.map → chunk-LXQ6HKPS.js.map} +1 -1
- package/dist/{chunk-ROYPRJH4.cjs → chunk-LYRDF5TQ.cjs} +9 -9
- package/dist/{chunk-ROYPRJH4.cjs.map → chunk-LYRDF5TQ.cjs.map} +1 -1
- package/dist/{chunk-G24KZRSA.js → chunk-N2U4AZGB.js} +3 -3
- package/dist/{chunk-G24KZRSA.js.map → chunk-N2U4AZGB.js.map} +1 -1
- package/dist/{chunk-4ERPXIVB.js → chunk-O73J46PV.js} +5 -5
- package/dist/{chunk-4ERPXIVB.js.map → chunk-O73J46PV.js.map} +1 -1
- package/dist/{chunk-F3YZMOAU.cjs → chunk-O7DK5PBJ.cjs} +4 -4
- package/dist/{chunk-F3YZMOAU.cjs.map → chunk-O7DK5PBJ.cjs.map} +1 -1
- package/dist/{chunk-Z4BCLVTI.cjs → chunk-O7LZFG6O.cjs} +5 -5
- package/dist/{chunk-Z4BCLVTI.cjs.map → chunk-O7LZFG6O.cjs.map} +1 -1
- package/dist/{chunk-3YJNUKYN.cjs → chunk-OHLDPWTA.cjs} +15 -15
- package/dist/{chunk-3YJNUKYN.cjs.map → chunk-OHLDPWTA.cjs.map} +1 -1
- package/dist/{chunk-FUL2I7G5.js → chunk-OSEG74VJ.js} +8 -8
- package/dist/{chunk-FUL2I7G5.js.map → chunk-OSEG74VJ.js.map} +1 -1
- package/dist/{chunk-UCBJBJ27.js → chunk-PUAEFLYK.js} +4 -4
- package/dist/{chunk-UCBJBJ27.js.map → chunk-PUAEFLYK.js.map} +1 -1
- package/dist/{chunk-CWHTMNNK.cjs → chunk-Q7LPTOD6.cjs} +24 -24
- package/dist/{chunk-CWHTMNNK.cjs.map → chunk-Q7LPTOD6.cjs.map} +1 -1
- package/dist/{chunk-2C72DXQF.cjs → chunk-RFMBZPOW.cjs} +9 -9
- package/dist/{chunk-2C72DXQF.cjs.map → chunk-RFMBZPOW.cjs.map} +1 -1
- package/dist/{chunk-NLTVXLGT.js → chunk-RFXWMRFC.js} +3 -3
- package/dist/{chunk-NLTVXLGT.js.map → chunk-RFXWMRFC.js.map} +1 -1
- package/dist/{chunk-2DG7KW4L.cjs → chunk-RMWTPV3M.cjs} +8 -8
- package/dist/{chunk-2DG7KW4L.cjs.map → chunk-RMWTPV3M.cjs.map} +1 -1
- package/dist/{chunk-P6A3M6VD.cjs → chunk-SZVR77EJ.cjs} +10 -10
- package/dist/{chunk-P6A3M6VD.cjs.map → chunk-SZVR77EJ.cjs.map} +1 -1
- package/dist/{chunk-3E77SX4H.js → chunk-TAZVKYWJ.js} +3 -3
- package/dist/{chunk-3E77SX4H.js.map → chunk-TAZVKYWJ.js.map} +1 -1
- package/dist/{chunk-WKRSH2VR.js → chunk-U6IFHFWK.js} +3 -3
- package/dist/{chunk-WKRSH2VR.js.map → chunk-U6IFHFWK.js.map} +1 -1
- package/dist/{chunk-I6TGFUCO.cjs → chunk-UALX2J2Q.cjs} +4 -4
- package/dist/{chunk-I6TGFUCO.cjs.map → chunk-UALX2J2Q.cjs.map} +1 -1
- package/dist/{chunk-XN7NOENA.js → chunk-UBDMVMBZ.js} +5 -5
- package/dist/{chunk-XN7NOENA.js.map → chunk-UBDMVMBZ.js.map} +1 -1
- package/dist/{chunk-QEKI3YKI.js → chunk-UEXIJTLC.js} +14 -349
- package/dist/chunk-UEXIJTLC.js.map +1 -0
- package/dist/{chunk-DQKERTND.cjs → chunk-UGT7GK7I.cjs} +11 -11
- package/dist/{chunk-DQKERTND.cjs.map → chunk-UGT7GK7I.cjs.map} +1 -1
- package/dist/{chunk-FKMUFNQE.js → chunk-UMP6OJIM.js} +4 -4
- package/dist/{chunk-FKMUFNQE.js.map → chunk-UMP6OJIM.js.map} +1 -1
- package/dist/{chunk-AEOZTXVW.js → chunk-UNYXQ4M5.js} +3 -3
- package/dist/{chunk-AEOZTXVW.js.map → chunk-UNYXQ4M5.js.map} +1 -1
- package/dist/{chunk-2BDH744Z.js → chunk-UTSRIDKZ.js} +3 -3
- package/dist/{chunk-2BDH744Z.js.map → chunk-UTSRIDKZ.js.map} +1 -1
- package/dist/{chunk-2ADR2GSO.cjs → chunk-UU36SHFY.cjs} +5 -5
- package/dist/{chunk-2ADR2GSO.cjs.map → chunk-UU36SHFY.cjs.map} +1 -1
- package/dist/{chunk-R3UPQFKK.cjs → chunk-V2BOS4WF.cjs} +9 -9
- package/dist/{chunk-R3UPQFKK.cjs.map → chunk-V2BOS4WF.cjs.map} +1 -1
- package/dist/chunk-WE22OXQA.js +48 -0
- package/dist/chunk-WE22OXQA.js.map +1 -0
- package/dist/{chunk-Q4CMI2LP.js → chunk-WLQNMXQE.js} +5 -5
- package/dist/{chunk-Q4CMI2LP.js.map → chunk-WLQNMXQE.js.map} +1 -1
- package/dist/{chunk-XWL6O3SW.cjs → chunk-WNO3C3N2.cjs} +4 -4
- package/dist/{chunk-XWL6O3SW.cjs.map → chunk-WNO3C3N2.cjs.map} +1 -1
- package/dist/{chunk-T7O6K6PX.js → chunk-XEQ3TM66.js} +18 -3
- package/dist/chunk-XEQ3TM66.js.map +1 -0
- package/dist/{chunk-BVZW2B5V.cjs → chunk-XJCXEKMD.cjs} +4 -4
- package/dist/{chunk-BVZW2B5V.cjs.map → chunk-XJCXEKMD.cjs.map} +1 -1
- package/dist/{chunk-JTB5Q42C.cjs → chunk-XL7Q7HB2.cjs} +4 -4
- package/dist/{chunk-JTB5Q42C.cjs.map → chunk-XL7Q7HB2.cjs.map} +1 -1
- package/dist/chunk-XO4SOZN6.js +19 -0
- package/dist/chunk-XO4SOZN6.js.map +1 -0
- package/dist/{chunk-CQGYNZ3K.cjs → chunk-XWTLIGO3.cjs} +4 -4
- package/dist/{chunk-CQGYNZ3K.cjs.map → chunk-XWTLIGO3.cjs.map} +1 -1
- package/dist/{chunk-6SBW4QR2.cjs → chunk-YML4ME27.cjs} +11 -11
- package/dist/{chunk-6SBW4QR2.cjs.map → chunk-YML4ME27.cjs.map} +1 -1
- package/dist/{chunk-P6H23T43.cjs → chunk-ZCIRZE37.cjs} +11 -11
- package/dist/{chunk-P6H23T43.cjs.map → chunk-ZCIRZE37.cjs.map} +1 -1
- package/dist/{chunk-QI7WE46I.cjs → chunk-ZLQSWSJ2.cjs} +11 -11
- package/dist/{chunk-QI7WE46I.cjs.map → chunk-ZLQSWSJ2.cjs.map} +1 -1
- package/dist/{chunk-AH6WD7JR.cjs → chunk-ZMRD5DZQ.cjs} +362 -360
- package/dist/chunk-ZMRD5DZQ.cjs.map +1 -0
- package/dist/{chunk-ILCGLTSA.cjs → chunk-ZSWPZ23K.cjs} +4 -4
- package/dist/{chunk-ILCGLTSA.cjs.map → chunk-ZSWPZ23K.cjs.map} +1 -1
- package/dist/{chunk-IDCKSLYH.js → chunk-ZZMZWBR6.js} +3 -3
- package/dist/{chunk-IDCKSLYH.js.map → chunk-ZZMZWBR6.js.map} +1 -1
- package/dist/compact-session-QV57KR66.cjs +59 -0
- package/dist/{compact-session-GJXJD73F.cjs.map → compact-session-QV57KR66.cjs.map} +1 -1
- package/dist/compact-session-RIGOWC4Y.js +22 -0
- package/dist/{compact-session-TSMQOIHO.js.map → compact-session-RIGOWC4Y.js.map} +1 -1
- package/dist/compaction.cjs +17 -17
- package/dist/compaction.js +4 -4
- package/dist/concurrency.cjs +7 -7
- package/dist/concurrency.js +5 -5
- package/dist/context-AGQ3DIZU.cjs +24 -0
- package/dist/{context-LCKNH2XI.cjs.map → context-AGQ3DIZU.cjs.map} +1 -1
- package/dist/context-GQRFBCLP.js +7 -0
- package/dist/{context-MZSKGKYR.js.map → context-GQRFBCLP.js.map} +1 -1
- package/dist/{cron-BcWmzWzT.d.cts → cron-BuiRPrvt.d.cts} +1 -1
- package/dist/{cron-De6hzWCF.d.ts → cron-C2SIi31n.d.ts} +1 -1
- package/dist/cron.cjs +37 -35
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +36 -34
- package/dist/errors.cjs +22 -22
- package/dist/errors.js +3 -3
- package/dist/eval.cjs +42 -40
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +36 -34
- package/dist/eval.js.map +1 -1
- package/dist/{executor-ZERJ3DGN.cjs → executor-6CYCA7MI.cjs} +25 -25
- package/dist/{executor-ZERJ3DGN.cjs.map → executor-6CYCA7MI.cjs.map} +1 -1
- package/dist/{executor-BMEHFOXZ.js → executor-QSEC3MRH.js} +8 -8
- package/dist/{executor-BMEHFOXZ.js.map → executor-QSEC3MRH.js.map} +1 -1
- package/dist/filesystem/index.cjs +8 -8
- package/dist/filesystem/index.js +4 -4
- package/dist/fs-session-store-4PIHT5UX.cjs +20 -0
- package/dist/{fs-session-store-XZ7ZTB3A.cjs.map → fs-session-store-4PIHT5UX.cjs.map} +1 -1
- package/dist/fs-session-store-NM6YSTE2.js +11 -0
- package/dist/{fs-session-store-4BHGIWRE.js.map → fs-session-store-NM6YSTE2.js.map} +1 -1
- package/dist/generate-object-GUNAUVBX.js +8 -0
- package/dist/{generate-object-N5MDZUJI.js.map → generate-object-GUNAUVBX.js.map} +1 -1
- package/dist/generate-object-R7HTMW7F.cjs +21 -0
- package/dist/{generate-object-PGSP5U7N.cjs.map → generate-object-R7HTMW7F.cjs.map} +1 -1
- package/dist/index-manager-RBDHP3PM.js +17 -0
- package/dist/{index-manager-AHAYJ33H.js.map → index-manager-RBDHP3PM.js.map} +1 -1
- package/dist/index-manager-UZBF22BJ.cjs +26 -0
- package/dist/{index-manager-RHPFVFSC.cjs.map → index-manager-UZBF22BJ.cjs.map} +1 -1
- package/dist/index.cjs +146 -319
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +62 -235
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-ZCQUB3IT.js → inject-session-DAR7OUCW.js} +8 -8
- package/dist/{inject-session-ZCQUB3IT.js.map → inject-session-DAR7OUCW.js.map} +1 -1
- package/dist/{inject-session-PPSO2IDD.cjs → inject-session-WQKMC3GR.cjs} +10 -10
- package/dist/{inject-session-PPSO2IDD.cjs.map → inject-session-WQKMC3GR.cjs.map} +1 -1
- package/dist/internal/memory/active-memory.d.ts +8 -1
- package/dist/internal/memory/adapters/index.cjs +9 -9
- package/dist/internal/memory/adapters/index.js +8 -8
- package/dist/internal/memory/dreaming/diary.d.ts +39 -2
- package/dist/internal/memory/index-db.d.ts +44 -1
- package/dist/internal/memory/index-manager-contract.d.ts +10 -0
- package/dist/internal/memory/index-manager-helpers.d.ts +20 -1
- package/dist/internal/memory/index-manager.d.ts +1 -1
- package/dist/internal/memory/lance-index.d.ts +15 -1
- package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +43 -0
- package/dist/internal/memory/storage/index.cjs +101 -18
- package/dist/internal/memory/storage/index.d.cts +11 -1
- package/dist/internal/memory/storage/index.d.ts +11 -1
- package/dist/internal/memory/storage/index.js +10 -7
- package/dist/internal/memory/storage/markdown-store.d.cts +13 -42
- package/dist/internal/memory/storage/markdown-store.d.ts +13 -42
- package/dist/internal/memory/storage/memory-root.d.cts +93 -0
- package/dist/internal/memory/storage/memory-root.d.ts +93 -0
- package/dist/internal/memory/storage/session-loader.d.cts +35 -1
- package/dist/internal/memory/storage/session-loader.d.ts +35 -1
- package/dist/internal/memory/storage/session-summary-writer.d.cts +50 -2
- package/dist/internal/memory/storage/session-summary-writer.d.ts +50 -2
- package/dist/internal/memory/storage/transcript-store.d.cts +38 -1
- package/dist/internal/memory/storage/transcript-store.d.ts +38 -1
- package/dist/internal/memory/storage/wiki-loader.d.cts +27 -2
- package/dist/internal/memory/storage/wiki-loader.d.ts +27 -2
- package/dist/internal/memory/tools.d.ts +8 -1
- package/dist/internal/memory/types.d.ts +5 -0
- package/dist/internal/persistence/index.cjs +29 -28
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.js +8 -7
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/persistence/session-dir.d.cts +0 -15
- package/dist/internal/persistence/session-dir.d.ts +0 -15
- package/dist/internal/runtime/memory/memory-store.d.ts +2 -2
- package/dist/internal/security/index.cjs +14 -14
- package/dist/internal/security/index.js +4 -4
- package/dist/judge-call-LAHMBJ57.cjs +23 -0
- package/dist/{judge-call-EGYRC2RE.cjs.map → judge-call-LAHMBJ57.cjs.map} +1 -1
- package/dist/judge-call-LVXABPS3.js +6 -0
- package/dist/{judge-call-DWHAJATE.js.map → judge-call-LVXABPS3.js.map} +1 -1
- package/dist/mcp-auth.cjs +15 -15
- package/dist/mcp-auth.js +5 -5
- package/dist/models.cjs +22 -22
- package/dist/models.js +7 -7
- package/dist/path-safety.cjs +11 -11
- package/dist/path-safety.js +4 -4
- package/dist/persistence.cjs +33 -32
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +10 -9
- package/dist/persistence.js.map +1 -1
- package/dist/project.cjs +6 -6
- package/dist/project.js +4 -4
- package/dist/providers.cjs +9 -9
- package/dist/providers.js +7 -7
- package/dist/registry-75W33OGL.js +10 -0
- package/dist/{registry-VFP3WWQP.js.map → registry-75W33OGL.js.map} +1 -1
- package/dist/registry-V7BDQ6QB.cjs +47 -0
- package/dist/{registry-VFKX7WOP.cjs.map → registry-V7BDQ6QB.cjs.map} +1 -1
- package/dist/retry.cjs +5 -5
- package/dist/retry.js +4 -4
- package/dist/sandbox/index.cjs +7 -7
- package/dist/sandbox/index.js +3 -3
- package/dist/server/errors-envelope.cjs +15 -15
- package/dist/server/errors-envelope.js +4 -4
- package/dist/session-transcript-6WNITKRE.cjs +63 -0
- package/dist/{session-transcript-HF5GEU5M.cjs.map → session-transcript-6WNITKRE.cjs.map} +1 -1
- package/dist/session-transcript-XAEKW6P7.js +6 -0
- package/dist/{session-transcript-P462ZRHX.js.map → session-transcript-XAEKW6P7.js.map} +1 -1
- package/dist/skills.cjs +8 -8
- package/dist/skills.js +6 -6
- package/dist/stream-object-UF4QRQRU.js +8 -0
- package/dist/{stream-object-L57K4OFS.js.map → stream-object-UF4QRQRU.js.map} +1 -1
- package/dist/stream-object-ZJTQNKY3.cjs +21 -0
- package/dist/{stream-object-BUCF5PHO.cjs.map → stream-object-ZJTQNKY3.cjs.map} +1 -1
- package/dist/subagents-loader-CRT5LLL3.js +8 -0
- package/dist/{subagents-loader-6ATCDEKN.js.map → subagents-loader-CRT5LLL3.js.map} +1 -1
- package/dist/subagents-loader-YEUFFPAL.cjs +17 -0
- package/dist/{subagents-loader-X5QKODCL.cjs.map → subagents-loader-YEUFFPAL.cjs.map} +1 -1
- package/dist/subagents-loader.cjs +7 -7
- package/dist/subagents-loader.d.cts +1 -1
- package/dist/subagents-loader.d.ts +1 -1
- package/dist/subagents-loader.js +5 -5
- package/dist/subscription/index.cjs +4 -4
- package/dist/subscription/index.js +3 -3
- package/dist/task-store.cjs +8 -8
- package/dist/task-store.js +5 -5
- package/dist/types/agent.d.ts +11 -0
- package/dist/types/memory-provider.d.ts +8 -0
- package/dist/workflow.cjs +28 -28
- package/dist/workflow.js +7 -7
- package/docs/error-codes.md +10 -9
- package/docs/harness-capability-map.md +57 -17
- package/docs/memory-decisions.md +44 -7
- package/package.json +1 -1
- package/dist/agent-NVBFTY5H.js +0 -55
- package/dist/agent-VYPUO4UB.cjs +0 -64
- package/dist/agent-session-store-G2BMUZQV.js +0 -7
- package/dist/agent-session-store-WAKLOKWK.cjs +0 -24
- package/dist/chunk-2UCFUSPW.cjs +0 -468
- package/dist/chunk-2UCFUSPW.cjs.map +0 -1
- package/dist/chunk-6HTXPPHK.cjs +0 -18
- package/dist/chunk-6OBIWHDR.cjs.map +0 -1
- package/dist/chunk-AH6WD7JR.cjs.map +0 -1
- package/dist/chunk-CQ2TQ32Y.js.map +0 -1
- package/dist/chunk-NUKRL3I6.cjs.map +0 -1
- package/dist/chunk-QEKI3YKI.js.map +0 -1
- package/dist/chunk-SKOCYA55.js.map +0 -1
- package/dist/chunk-SKXBJ2NU.cjs.map +0 -1
- package/dist/chunk-T7O6K6PX.js.map +0 -1
- package/dist/chunk-WCLDJSMY.js +0 -456
- package/dist/chunk-WCLDJSMY.js.map +0 -1
- package/dist/compact-session-GJXJD73F.cjs +0 -59
- package/dist/compact-session-TSMQOIHO.js +0 -22
- package/dist/context-LCKNH2XI.cjs +0 -24
- package/dist/context-MZSKGKYR.js +0 -7
- package/dist/fs-session-store-4BHGIWRE.js +0 -11
- package/dist/fs-session-store-XZ7ZTB3A.cjs +0 -20
- package/dist/generate-object-N5MDZUJI.js +0 -8
- package/dist/generate-object-PGSP5U7N.cjs +0 -21
- package/dist/index-manager-AHAYJ33H.js +0 -16
- package/dist/index-manager-RHPFVFSC.cjs +0 -25
- package/dist/judge-call-DWHAJATE.js +0 -6
- package/dist/judge-call-EGYRC2RE.cjs +0 -23
- package/dist/registry-VFKX7WOP.cjs +0 -47
- package/dist/registry-VFP3WWQP.js +0 -10
- package/dist/session-transcript-HF5GEU5M.cjs +0 -63
- package/dist/session-transcript-P462ZRHX.js +0 -6
- package/dist/stream-object-BUCF5PHO.cjs +0 -21
- package/dist/stream-object-L57K4OFS.js +0 -8
- package/dist/subagents-loader-6ATCDEKN.js +0 -8
- package/dist/subagents-loader-X5QKODCL.cjs +0 -17
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunk3FFAEAUJ_cjs = require('./chunk-3FFAEAUJ.cjs');
|
|
4
|
+
var chunkRMWTPV3M_cjs = require('./chunk-RMWTPV3M.cjs');
|
|
5
|
+
var chunkITYQ6VBP_cjs = require('./chunk-ITYQ6VBP.cjs');
|
|
6
|
+
var chunkZCIRZE37_cjs = require('./chunk-ZCIRZE37.cjs');
|
|
7
7
|
var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
8
|
+
var chunkKQ7TS7WW_cjs = require('./chunk-KQ7TS7WW.cjs');
|
|
9
|
+
var chunkGKEFRLU7_cjs = require('./chunk-GKEFRLU7.cjs');
|
|
10
|
+
var chunk6RKUO7AW_cjs = require('./chunk-6RKUO7AW.cjs');
|
|
11
|
+
var chunkZLQSWSJ2_cjs = require('./chunk-ZLQSWSJ2.cjs');
|
|
12
|
+
var chunkKYAJINUI_cjs = require('./chunk-KYAJINUI.cjs');
|
|
12
13
|
var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
|
|
13
14
|
var chunk7BG5UH3T_cjs = require('./chunk-7BG5UH3T.cjs');
|
|
14
|
-
var
|
|
15
|
+
var chunk2HVF2WJY_cjs = require('./chunk-2HVF2WJY.cjs');
|
|
15
16
|
var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
|
|
16
17
|
var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
|
|
17
18
|
var chunk4O5TGQBW_cjs = require('./chunk-4O5TGQBW.cjs');
|
|
18
19
|
var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
|
|
19
|
-
var
|
|
20
|
+
var chunkOHLDPWTA_cjs = require('./chunk-OHLDPWTA.cjs');
|
|
20
21
|
var chunkVJ26EKGJ_cjs = require('./chunk-VJ26EKGJ.cjs');
|
|
21
|
-
var
|
|
22
|
+
var chunkV2BOS4WF_cjs = require('./chunk-V2BOS4WF.cjs');
|
|
22
23
|
var chunkVKJ7V7EB_cjs = require('./chunk-VKJ7V7EB.cjs');
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var chunkZSWPZ23K_cjs = require('./chunk-ZSWPZ23K.cjs');
|
|
25
|
+
var chunk5HEG4CQH_cjs = require('./chunk-5HEG4CQH.cjs');
|
|
26
|
+
var chunkUU36SHFY_cjs = require('./chunk-UU36SHFY.cjs');
|
|
26
27
|
var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
|
|
27
|
-
var
|
|
28
|
-
var
|
|
28
|
+
var chunkUALX2J2Q_cjs = require('./chunk-UALX2J2Q.cjs');
|
|
29
|
+
var chunkCQBXOJ6U_cjs = require('./chunk-CQBXOJ6U.cjs');
|
|
29
30
|
var chunkAQO3NSRG_cjs = require('./chunk-AQO3NSRG.cjs');
|
|
30
|
-
var
|
|
31
|
-
var
|
|
31
|
+
var chunk4CLOXP6H_cjs = require('./chunk-4CLOXP6H.cjs');
|
|
32
|
+
var chunkDXGZ2NUG_cjs = require('./chunk-DXGZ2NUG.cjs');
|
|
32
33
|
var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
34
|
+
var chunkJPBKYL3B_cjs = require('./chunk-JPBKYL3B.cjs');
|
|
35
|
+
var chunkHCZD23VS_cjs = require('./chunk-HCZD23VS.cjs');
|
|
36
|
+
var chunk4ZHTIJNE_cjs = require('./chunk-4ZHTIJNE.cjs');
|
|
37
|
+
var chunkXL7Q7HB2_cjs = require('./chunk-XL7Q7HB2.cjs');
|
|
38
|
+
var chunkEG4QM7ZJ_cjs = require('./chunk-EG4QM7ZJ.cjs');
|
|
38
39
|
var promises = require('fs/promises');
|
|
39
40
|
var crypto = require('crypto');
|
|
40
41
|
var path = require('path');
|
|
@@ -230,7 +231,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
|
|
|
230
231
|
const { output, maxRetries, errorStrategy, ...sendOptions } = options;
|
|
231
232
|
const run = await agent.send(input, sendOptions);
|
|
232
233
|
const result = await run.wait();
|
|
233
|
-
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-
|
|
234
|
+
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-R7HTMW7F.cjs');
|
|
234
235
|
const answer = structurableAnswerOrThrow(result, GenerateObjectError);
|
|
235
236
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
236
237
|
const facade = getAgentFacade();
|
|
@@ -319,7 +320,7 @@ function normalizeModel(m) {
|
|
|
319
320
|
if (m === void 0 || typeof m !== "string") return m;
|
|
320
321
|
const id = m.trim();
|
|
321
322
|
if (id.length === 0) {
|
|
322
|
-
throw new
|
|
323
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
323
324
|
'model must be a non-empty "provider/model" id string or a ModelSelection object',
|
|
324
325
|
{ code: "invalid_model_selection" }
|
|
325
326
|
);
|
|
@@ -455,7 +456,7 @@ function registryPath(cwd) {
|
|
|
455
456
|
return path.join(cwd, REGISTRY_RELATIVE_PATH);
|
|
456
457
|
}
|
|
457
458
|
async function loadRegistry(cwd) {
|
|
458
|
-
return
|
|
459
|
+
return chunk2HVF2WJY_cjs.readVersionedJson({
|
|
459
460
|
path: registryPath(cwd),
|
|
460
461
|
currentVersion: SCHEMA_VERSION,
|
|
461
462
|
defaultValue: () => ({}),
|
|
@@ -479,7 +480,7 @@ async function saveRegistry(cwd, agents2) {
|
|
|
479
480
|
}
|
|
480
481
|
const path = registryPath(cwd);
|
|
481
482
|
await chunkZF2LDKQQ_cjs.withCwdMutex(`registry:${cwd}`, async () => {
|
|
482
|
-
await
|
|
483
|
+
await chunk2HVF2WJY_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
|
|
483
484
|
});
|
|
484
485
|
}
|
|
485
486
|
function toSerialized(agent) {
|
|
@@ -546,7 +547,7 @@ function scheduleSaveForCwd(cwd) {
|
|
|
546
547
|
}
|
|
547
548
|
} catch (cause) {
|
|
548
549
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
549
|
-
|
|
550
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] registry persist failed (${cwd}): ${msg}
|
|
550
551
|
`);
|
|
551
552
|
} finally {
|
|
552
553
|
pendingSaves.delete(cwd);
|
|
@@ -886,14 +887,14 @@ async function readLegacyFacts(jsonPath) {
|
|
|
886
887
|
}
|
|
887
888
|
async function writeMigratedFacts(cwd, jsonPath, facts) {
|
|
888
889
|
try {
|
|
889
|
-
for (const fact of facts) await
|
|
890
|
+
for (const fact of facts) await chunk6RKUO7AW_cjs.appendFactToMarkdown(cwd, fact);
|
|
890
891
|
await promises.unlink(jsonPath).catch(() => void 0);
|
|
891
|
-
|
|
892
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
|
|
892
893
|
`);
|
|
893
894
|
return { migrated: true, factCount: facts.length };
|
|
894
895
|
} catch (cause) {
|
|
895
896
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
896
|
-
|
|
897
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] memory migration failed (readonly fs?): ${message}
|
|
897
898
|
`);
|
|
898
899
|
return { migrated: false, factCount: 0, reason: "readonly-fs" };
|
|
899
900
|
}
|
|
@@ -903,12 +904,12 @@ async function migrateLegacyJson(cwd, config) {
|
|
|
903
904
|
const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
|
|
904
905
|
if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
|
|
905
906
|
migrationRun.add(key);
|
|
906
|
-
const jsonPath =
|
|
907
|
+
const jsonPath = chunk6RKUO7AW_cjs.legacyMemoryJsonPath(cwd, config);
|
|
907
908
|
if (!await fileExists(jsonPath)) {
|
|
908
909
|
return { migrated: false, factCount: 0, reason: "no-legacy-json" };
|
|
909
910
|
}
|
|
910
|
-
if (await fileExists(
|
|
911
|
-
|
|
911
|
+
if (await fileExists(chunk6RKUO7AW_cjs.memoryMdPath(chunk6RKUO7AW_cjs.resolveMemoryRoot(cwd, config)))) {
|
|
912
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
912
913
|
`[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
|
|
913
914
|
`
|
|
914
915
|
);
|
|
@@ -929,26 +930,35 @@ function extractMemoryFact(message) {
|
|
|
929
930
|
if (match === null || match[2] === void 0) return "";
|
|
930
931
|
return match[2].trim().replace(/\.$/, "");
|
|
931
932
|
}
|
|
933
|
+
var LOOKS_LIKE_A_CAPTURE = /^\s*(?:please\s+|can\s+you\s+|could\s+you\s+)?remember\b/i;
|
|
934
|
+
var QUOTED_MESSAGE_MAX = 120;
|
|
935
|
+
function unstoredRememberWarning(message) {
|
|
936
|
+
if (!LOOKS_LIKE_A_CAPTURE.test(message)) return void 0;
|
|
937
|
+
if (isMemoryWritePrompt(message) && extractMemoryFact(message).length > 0) return void 0;
|
|
938
|
+
const trimmed = message.trim();
|
|
939
|
+
const quoted = trimmed.length > QUOTED_MESSAGE_MAX ? `${trimmed.slice(0, QUOTED_MESSAGE_MAX)}\u2026` : trimmed;
|
|
940
|
+
return `[theokit-sdk] NOTHING WAS STORED \u2014 this message does not match the memory capture pattern: ${JSON.stringify(quoted)}. Supported: "Remember: <fact>" or "Remember (${chunk6RKUO7AW_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.`;
|
|
941
|
+
}
|
|
932
942
|
function extractMemoryKind(message) {
|
|
933
943
|
const match = REMEMBER_PATTERN.exec(message);
|
|
934
944
|
const declared = match?.[1];
|
|
935
945
|
if (declared === void 0) return void 0;
|
|
936
946
|
const lowered = declared.toLowerCase();
|
|
937
|
-
return
|
|
947
|
+
return chunk6RKUO7AW_cjs.MEMORY_KINDS.includes(lowered) ? lowered : void 0;
|
|
938
948
|
}
|
|
939
|
-
async function readMemoryFacts(cwd, config
|
|
949
|
+
async function readMemoryFacts(cwd, config) {
|
|
940
950
|
if (!config.enabled) return [];
|
|
941
951
|
await migrateLegacyJson(cwd, config);
|
|
942
|
-
return
|
|
952
|
+
return chunk6RKUO7AW_cjs.readFacts(cwd, config);
|
|
943
953
|
}
|
|
944
|
-
async function appendMemoryFact(cwd, config, fact
|
|
954
|
+
async function appendMemoryFact(cwd, config, fact) {
|
|
945
955
|
if (!config.enabled) return;
|
|
946
956
|
await migrateLegacyJson(cwd, config);
|
|
947
957
|
const sanitized = {
|
|
948
|
-
text:
|
|
958
|
+
text: chunkXL7Q7HB2_cjs.redactSecrets(fact.text),
|
|
949
959
|
...fact.kind === void 0 ? {} : { kind: fact.kind }
|
|
950
960
|
};
|
|
951
|
-
await
|
|
961
|
+
await chunk6RKUO7AW_cjs.appendFact(cwd, config, sanitized);
|
|
952
962
|
}
|
|
953
963
|
|
|
954
964
|
// src/internal/runtime/fixtures/fixture-scripts.ts
|
|
@@ -1296,7 +1306,7 @@ function redactScriptSecrets(script) {
|
|
|
1296
1306
|
function redactEventSecrets(event) {
|
|
1297
1307
|
const serialized = JSON.stringify(event);
|
|
1298
1308
|
const localStripped = serialized.replace(FIXTURE_SENTINEL, "***");
|
|
1299
|
-
const redacted =
|
|
1309
|
+
const redacted = chunkXL7Q7HB2_cjs.redactSecrets(localStripped);
|
|
1300
1310
|
if (redacted === serialized) return event;
|
|
1301
1311
|
return JSON.parse(redacted);
|
|
1302
1312
|
}
|
|
@@ -1618,8 +1628,8 @@ function createRealCloudRun(options) {
|
|
|
1618
1628
|
cancellable: false,
|
|
1619
1629
|
conversation: []
|
|
1620
1630
|
};
|
|
1621
|
-
const apiKey =
|
|
1622
|
-
const baseUrl =
|
|
1631
|
+
const apiKey = chunkXL7Q7HB2_cjs.resolveApiKey(options.agentOptions.apiKey);
|
|
1632
|
+
const baseUrl = chunkKYAJINUI_cjs.getConfiguredBaseUrl();
|
|
1623
1633
|
const handle = new RealCloudRun(
|
|
1624
1634
|
{
|
|
1625
1635
|
id,
|
|
@@ -1692,7 +1702,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1692
1702
|
});
|
|
1693
1703
|
if (!response.ok) {
|
|
1694
1704
|
const text = await response.text().catch(() => "");
|
|
1695
|
-
throw new
|
|
1705
|
+
throw new chunk4ZHTIJNE_cjs.NetworkError(
|
|
1696
1706
|
`Cloud Run endpoint returned ${response.status}: ${text.slice(0, 200)}`,
|
|
1697
1707
|
{ code: "cloud_run_http_error" }
|
|
1698
1708
|
);
|
|
@@ -1702,7 +1712,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1702
1712
|
async consumeStream(response) {
|
|
1703
1713
|
let finalStatus = "finished";
|
|
1704
1714
|
let finalText = "";
|
|
1705
|
-
for await (const record of
|
|
1715
|
+
for await (const record of chunkKYAJINUI_cjs.parseSseStream(response.body, this.controller.signal)) {
|
|
1706
1716
|
const parsed = safeParse(record.data);
|
|
1707
1717
|
if (parsed === void 0) continue;
|
|
1708
1718
|
const update = this.applyRecord(record.event, parsed);
|
|
@@ -1782,7 +1792,7 @@ function toWireStatus(token) {
|
|
|
1782
1792
|
const match = WIRE_STATUSES.find((candidate) => candidate === upper);
|
|
1783
1793
|
if (match !== void 0) return match;
|
|
1784
1794
|
}
|
|
1785
|
-
throw new
|
|
1795
|
+
throw new chunk4ZHTIJNE_cjs.NetworkError(
|
|
1786
1796
|
`Cloud Run stream reported an unrecognised status ${JSON.stringify(token)}; expected one of ${WIRE_STATUSES.join(", ")} (case-insensitive)`,
|
|
1787
1797
|
{ code: "cloud_run_unknown_status" }
|
|
1788
1798
|
);
|
|
@@ -1792,7 +1802,7 @@ function toRunStatus(token) {
|
|
|
1792
1802
|
const mapped = SERVER_STATUS_TO_RUN_STATUS[token.toLowerCase()];
|
|
1793
1803
|
if (mapped !== void 0) return mapped;
|
|
1794
1804
|
}
|
|
1795
|
-
throw new
|
|
1805
|
+
throw new chunk4ZHTIJNE_cjs.NetworkError(
|
|
1796
1806
|
`Cloud Run stream reported an unrecognised status ${JSON.stringify(token)}; expected one of ${Object.keys(SERVER_STATUS_TO_RUN_STATUS).join(", ")} (case-insensitive)`,
|
|
1797
1807
|
{ code: "cloud_run_unknown_status" }
|
|
1798
1808
|
);
|
|
@@ -1847,8 +1857,8 @@ var CloudAgent = class {
|
|
|
1847
1857
|
* cloud operations are pre-release and must surface explicit errors.
|
|
1848
1858
|
*/
|
|
1849
1859
|
isFixtureMode() {
|
|
1850
|
-
const apiKey =
|
|
1851
|
-
return
|
|
1860
|
+
const apiKey = chunkXL7Q7HB2_cjs.resolveApiKey(this.options.apiKey);
|
|
1861
|
+
return chunkKYAJINUI_cjs.isFixtureApiKey(apiKey) && chunkKYAJINUI_cjs.getConfiguredBaseUrl() === void 0;
|
|
1852
1862
|
}
|
|
1853
1863
|
// SE9 — integrated structured output; delegates to the shared helper.
|
|
1854
1864
|
generate(message, options) {
|
|
@@ -1862,9 +1872,9 @@ var CloudAgent = class {
|
|
|
1862
1872
|
);
|
|
1863
1873
|
}
|
|
1864
1874
|
async send(message, options = {}) {
|
|
1865
|
-
if (this.disposed) throw new
|
|
1875
|
+
if (this.disposed) throw new chunk4ZHTIJNE_cjs.AgentDisposedError(this.agentId);
|
|
1866
1876
|
if (options.tools !== void 0 && options.tools.length > 0) {
|
|
1867
|
-
throw new
|
|
1877
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
1868
1878
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
1869
1879
|
{ code: "cloud_custom_tools_rejected" }
|
|
1870
1880
|
);
|
|
@@ -1899,8 +1909,8 @@ var CloudAgent = class {
|
|
|
1899
1909
|
}
|
|
1900
1910
|
const userText = typeof message === "string" ? message : message.text;
|
|
1901
1911
|
const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
|
|
1902
|
-
const apiKey =
|
|
1903
|
-
const useRealRuntime = apiKey !== void 0 && !
|
|
1912
|
+
const apiKey = chunkXL7Q7HB2_cjs.resolveApiKey(this.options.apiKey);
|
|
1913
|
+
const useRealRuntime = apiKey !== void 0 && !chunkKYAJINUI_cjs.isFixtureApiKey(apiKey) && chunkKYAJINUI_cjs.getConfiguredBaseUrl() !== void 0;
|
|
1904
1914
|
return useRealRuntime ? createRealCloudRun({
|
|
1905
1915
|
agentId: this.agentId,
|
|
1906
1916
|
model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
|
|
@@ -1949,7 +1959,7 @@ var CloudAgent = class {
|
|
|
1949
1959
|
listArtifacts() {
|
|
1950
1960
|
if (!this.isFixtureMode()) {
|
|
1951
1961
|
return Promise.reject(
|
|
1952
|
-
new
|
|
1962
|
+
new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
1953
1963
|
"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).",
|
|
1954
1964
|
{ code: "cloud_runtime_pre_release" }
|
|
1955
1965
|
)
|
|
@@ -1959,11 +1969,11 @@ var CloudAgent = class {
|
|
|
1959
1969
|
}
|
|
1960
1970
|
downloadArtifact(path) {
|
|
1961
1971
|
try {
|
|
1962
|
-
|
|
1972
|
+
chunkV2BOS4WF_cjs.validateArtifactPath(path);
|
|
1963
1973
|
} catch (cause) {
|
|
1964
|
-
if (cause instanceof
|
|
1974
|
+
if (cause instanceof chunkV2BOS4WF_cjs.PathTraversalError) {
|
|
1965
1975
|
return Promise.reject(
|
|
1966
|
-
new
|
|
1976
|
+
new chunk4ZHTIJNE_cjs.ConfigurationError(`Artifact path must stay inside the workspace: ${path}`, {
|
|
1967
1977
|
code: "artifact_path_traversal",
|
|
1968
1978
|
cause
|
|
1969
1979
|
})
|
|
@@ -1973,7 +1983,7 @@ var CloudAgent = class {
|
|
|
1973
1983
|
}
|
|
1974
1984
|
if (!this.isFixtureMode()) {
|
|
1975
1985
|
return Promise.reject(
|
|
1976
|
-
new
|
|
1986
|
+
new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
1977
1987
|
"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).",
|
|
1978
1988
|
{ code: "cloud_runtime_pre_release" }
|
|
1979
1989
|
)
|
|
@@ -1982,7 +1992,7 @@ var CloudAgent = class {
|
|
|
1982
1992
|
const match = buildFixtureArtifacts().find((artifact) => artifact.path === path);
|
|
1983
1993
|
if (match === void 0) {
|
|
1984
1994
|
return Promise.reject(
|
|
1985
|
-
new
|
|
1995
|
+
new chunk4ZHTIJNE_cjs.UnknownAgentError(`Artifact ${path} not found`, { code: "unknown_artifact" })
|
|
1986
1996
|
);
|
|
1987
1997
|
}
|
|
1988
1998
|
return Promise.resolve(Buffer.from(`fixture artifact content for ${path}
|
|
@@ -1996,7 +2006,7 @@ var CloudAgent = class {
|
|
|
1996
2006
|
* @public
|
|
1997
2007
|
*/
|
|
1998
2008
|
runUntil() {
|
|
1999
|
-
throw new
|
|
2009
|
+
throw new chunk4ZHTIJNE_cjs.UnsupportedRunOperationError(
|
|
2000
2010
|
"Agent.runUntil() is not supported on cloud agents. Cloud runtime manages goal loops server-side. Use a local agent for autonomous Ralph loops.",
|
|
2001
2011
|
"runUntil"
|
|
2002
2012
|
);
|
|
@@ -2007,7 +2017,7 @@ var CloudAgent = class {
|
|
|
2007
2017
|
* @public
|
|
2008
2018
|
*/
|
|
2009
2019
|
fork() {
|
|
2010
|
-
throw new
|
|
2020
|
+
throw new chunk4ZHTIJNE_cjs.UnsupportedRunOperationError(
|
|
2011
2021
|
"Agent.fork() is not supported on cloud agents. Fork inheritance requires local credential + system-prompt access. Use a local agent.",
|
|
2012
2022
|
"fork"
|
|
2013
2023
|
);
|
|
@@ -2019,7 +2029,7 @@ var CloudAgent = class {
|
|
|
2019
2029
|
* @public
|
|
2020
2030
|
*/
|
|
2021
2031
|
runToCompletion() {
|
|
2022
|
-
throw new
|
|
2032
|
+
throw new chunk4ZHTIJNE_cjs.UnsupportedRunOperationError(
|
|
2023
2033
|
"Agent.runToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
2024
2034
|
"runToCompletion"
|
|
2025
2035
|
);
|
|
@@ -2031,7 +2041,7 @@ var CloudAgent = class {
|
|
|
2031
2041
|
* @public
|
|
2032
2042
|
*/
|
|
2033
2043
|
streamToCompletion() {
|
|
2034
|
-
throw new
|
|
2044
|
+
throw new chunk4ZHTIJNE_cjs.UnsupportedRunOperationError(
|
|
2035
2045
|
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
2036
2046
|
"streamToCompletion"
|
|
2037
2047
|
);
|
|
@@ -2045,7 +2055,7 @@ var CloudAgent = class {
|
|
|
2045
2055
|
*/
|
|
2046
2056
|
usePersonality() {
|
|
2047
2057
|
return Promise.reject(
|
|
2048
|
-
new
|
|
2058
|
+
new chunk4ZHTIJNE_cjs.UnsupportedRunOperationError(
|
|
2049
2059
|
"Agent.usePersonality() is not supported on cloud agents (pre-release). Use a local agent or wait for cloud GA.",
|
|
2050
2060
|
"usePersonality"
|
|
2051
2061
|
)
|
|
@@ -2073,7 +2083,7 @@ function validateCloudToolParity(options) {
|
|
|
2073
2083
|
function rejectProcessors(options) {
|
|
2074
2084
|
const hasProcessors = (options.inputProcessors?.length ?? 0) > 0 || (options.outputProcessors?.length ?? 0) > 0;
|
|
2075
2085
|
if (hasProcessors) {
|
|
2076
|
-
throw new
|
|
2086
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
2077
2087
|
"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.",
|
|
2078
2088
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2079
2089
|
);
|
|
@@ -2081,7 +2091,7 @@ function rejectProcessors(options) {
|
|
|
2081
2091
|
}
|
|
2082
2092
|
function rejectFunctionSystemPrompt(options) {
|
|
2083
2093
|
if (typeof options.systemPrompt === "function") {
|
|
2084
|
-
throw new
|
|
2094
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
2085
2095
|
"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.",
|
|
2086
2096
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2087
2097
|
);
|
|
@@ -2089,7 +2099,7 @@ function rejectFunctionSystemPrompt(options) {
|
|
|
2089
2099
|
}
|
|
2090
2100
|
function rejectFunctionSkills(options) {
|
|
2091
2101
|
if (typeof options.skills === "function") {
|
|
2092
|
-
throw new
|
|
2102
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
2093
2103
|
"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.",
|
|
2094
2104
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2095
2105
|
);
|
|
@@ -2101,7 +2111,7 @@ function rejectStdioMcpLocalPaths(options) {
|
|
|
2101
2111
|
if (!isStdioCommandConfig(config)) continue;
|
|
2102
2112
|
const command = config.command ?? "";
|
|
2103
2113
|
if (isLocalPath(command)) {
|
|
2104
|
-
throw new
|
|
2114
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
2105
2115
|
`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.`,
|
|
2106
2116
|
{ code: "cloud_incompatible_mcp_stdio_local" }
|
|
2107
2117
|
);
|
|
@@ -2121,23 +2131,19 @@ function isLocalPath(command) {
|
|
|
2121
2131
|
function resolveSessionDir(local) {
|
|
2122
2132
|
if (local?.sessionDir !== void 0) {
|
|
2123
2133
|
if (local.baseDir !== void 0) {
|
|
2124
|
-
|
|
2134
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
2125
2135
|
"[theokit-sdk] local.sessionDir and local.baseDir are both set; using sessionDir. baseDir is the deprecated name for the same option (#301)."
|
|
2126
2136
|
);
|
|
2127
2137
|
}
|
|
2128
|
-
return
|
|
2138
|
+
return chunk5HEG4CQH_cjs.expandTilde(local.sessionDir);
|
|
2129
2139
|
}
|
|
2130
2140
|
if (local?.baseDir !== void 0) {
|
|
2131
|
-
|
|
2141
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
2132
2142
|
"[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."
|
|
2133
2143
|
);
|
|
2134
|
-
return
|
|
2144
|
+
return chunk5HEG4CQH_cjs.expandTilde(local.baseDir);
|
|
2135
2145
|
}
|
|
2136
|
-
return
|
|
2137
|
-
}
|
|
2138
|
-
function explicitSessionDir(local) {
|
|
2139
|
-
if (local?.sessionDir === void 0 && local?.baseDir === void 0) return void 0;
|
|
2140
|
-
return resolveSessionDir(local);
|
|
2146
|
+
return chunk5HEG4CQH_cjs.defaultBaseDir();
|
|
2141
2147
|
}
|
|
2142
2148
|
var SCHEMA_VERSION2 = 1;
|
|
2143
2149
|
var FILE_NAME = "personality.json";
|
|
@@ -2164,14 +2170,14 @@ async function readState(filePath) {
|
|
|
2164
2170
|
try {
|
|
2165
2171
|
parsed = JSON.parse(raw);
|
|
2166
2172
|
} catch {
|
|
2167
|
-
|
|
2173
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
2168
2174
|
"personality-store-json-parse",
|
|
2169
2175
|
"[theokit-sdk] personality.json is malformed; treating as empty"
|
|
2170
2176
|
);
|
|
2171
2177
|
return emptyState();
|
|
2172
2178
|
}
|
|
2173
2179
|
if (!isStateV1(parsed)) {
|
|
2174
|
-
|
|
2180
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
2175
2181
|
"personality-store-bad-version",
|
|
2176
2182
|
`[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
|
|
2177
2183
|
);
|
|
@@ -2202,9 +2208,9 @@ var PersonalityStore = class {
|
|
|
2202
2208
|
try {
|
|
2203
2209
|
await this.#persist(agentId, slug);
|
|
2204
2210
|
} catch (err) {
|
|
2205
|
-
|
|
2211
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
2206
2212
|
`personality-store-persist-failure-${agentId}`,
|
|
2207
|
-
`[theokit-sdk] personality persist failed for ${
|
|
2213
|
+
`[theokit-sdk] personality persist failed for ${chunkXL7Q7HB2_cjs.redactSecrets(agentId)}: ${chunkXL7Q7HB2_cjs.redactSecrets(
|
|
2208
2214
|
err.message
|
|
2209
2215
|
)}`
|
|
2210
2216
|
);
|
|
@@ -2219,9 +2225,9 @@ var PersonalityStore = class {
|
|
|
2219
2225
|
try {
|
|
2220
2226
|
state = await readState(filePath);
|
|
2221
2227
|
} catch (err) {
|
|
2222
|
-
|
|
2228
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
2223
2229
|
`personality-store-hydrate-failure-${agentId}`,
|
|
2224
|
-
`[theokit-sdk] personality hydrate failed for ${
|
|
2230
|
+
`[theokit-sdk] personality hydrate failed for ${chunkXL7Q7HB2_cjs.redactSecrets(agentId)}: ${chunkXL7Q7HB2_cjs.redactSecrets(
|
|
2225
2231
|
err.message
|
|
2226
2232
|
)}`
|
|
2227
2233
|
);
|
|
@@ -2238,13 +2244,13 @@ var PersonalityStore = class {
|
|
|
2238
2244
|
async #persist(agentId, slug) {
|
|
2239
2245
|
const filePath = this.#filePath();
|
|
2240
2246
|
await promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
2241
|
-
await
|
|
2247
|
+
await chunkUU36SHFY_cjs.withFileLock(filePath, async () => {
|
|
2242
2248
|
const current = await readState(filePath);
|
|
2243
2249
|
const nextAgents = { ...current.agents };
|
|
2244
2250
|
if (slug === void 0) delete nextAgents[agentId];
|
|
2245
2251
|
else nextAgents[agentId] = slug;
|
|
2246
2252
|
const next = { version: SCHEMA_VERSION2, agents: nextAgents };
|
|
2247
|
-
await
|
|
2253
|
+
await chunkUALX2J2Q_cjs.atomicWriteJson(filePath, next);
|
|
2248
2254
|
});
|
|
2249
2255
|
}
|
|
2250
2256
|
#filePath() {
|
|
@@ -2271,7 +2277,7 @@ function createPluginContext() {
|
|
|
2271
2277
|
},
|
|
2272
2278
|
on(hook, handler) {
|
|
2273
2279
|
if (typeof handler !== "function") {
|
|
2274
|
-
|
|
2280
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] ignoring non-function handler for hook "${hook}"
|
|
2275
2281
|
`);
|
|
2276
2282
|
return;
|
|
2277
2283
|
}
|
|
@@ -2324,7 +2330,7 @@ var PluginManager = class {
|
|
|
2324
2330
|
const seen = /* @__PURE__ */ new Set();
|
|
2325
2331
|
for (const plugin of plugins) {
|
|
2326
2332
|
if (seen.has(plugin.name)) {
|
|
2327
|
-
|
|
2333
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
2328
2334
|
`[theokit-sdk] duplicate plugin name "${plugin.name}" \u2014 both will register independently
|
|
2329
2335
|
`
|
|
2330
2336
|
);
|
|
@@ -2351,7 +2357,7 @@ var PluginManager = class {
|
|
|
2351
2357
|
*/
|
|
2352
2358
|
async register(plugin) {
|
|
2353
2359
|
if (plugin.kind !== "general") {
|
|
2354
|
-
throw new
|
|
2360
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
2355
2361
|
`late register supports general plugins only (got "${plugin.kind}" for "${plugin.name}")`,
|
|
2356
2362
|
{ code: "plugin_late_register_kind" }
|
|
2357
2363
|
);
|
|
@@ -2408,7 +2414,7 @@ var PluginManager = class {
|
|
|
2408
2414
|
parts.push(result.recalledContext);
|
|
2409
2415
|
}
|
|
2410
2416
|
} catch (err) {
|
|
2411
|
-
|
|
2417
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
2412
2418
|
`[theokit-sdk] pre_user_send hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2413
2419
|
`
|
|
2414
2420
|
);
|
|
@@ -2436,7 +2442,7 @@ var PluginManager = class {
|
|
|
2436
2442
|
try {
|
|
2437
2443
|
await h(ctx);
|
|
2438
2444
|
} catch (err) {
|
|
2439
|
-
|
|
2445
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
2440
2446
|
`[theokit-sdk] post_assistant_reply hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2441
2447
|
`
|
|
2442
2448
|
);
|
|
@@ -2452,7 +2458,7 @@ var PluginManager = class {
|
|
|
2452
2458
|
try {
|
|
2453
2459
|
await h(ctx);
|
|
2454
2460
|
} catch (err) {
|
|
2455
|
-
|
|
2461
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
2456
2462
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2457
2463
|
`
|
|
2458
2464
|
);
|
|
@@ -2467,7 +2473,7 @@ var PluginManager = class {
|
|
|
2467
2473
|
const out = await h(current, ctx);
|
|
2468
2474
|
if (out !== void 0) current = out;
|
|
2469
2475
|
} catch (err) {
|
|
2470
|
-
|
|
2476
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
2471
2477
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2472
2478
|
`
|
|
2473
2479
|
);
|
|
@@ -2609,7 +2615,7 @@ var HooksExecutor = class {
|
|
|
2609
2615
|
this.config = {};
|
|
2610
2616
|
return;
|
|
2611
2617
|
}
|
|
2612
|
-
this.config = await
|
|
2618
|
+
this.config = await chunkZCIRZE37_cjs.loadHookConfig(this.cwd);
|
|
2613
2619
|
}
|
|
2614
2620
|
/** Fire every hook registered for `event` and aggregate the decisions. */
|
|
2615
2621
|
async run(payload) {
|
|
@@ -2718,11 +2724,11 @@ function sessionTranscriptAllowed(memory) {
|
|
|
2718
2724
|
}
|
|
2719
2725
|
function resolveWindowForRun(model, contextWindow) {
|
|
2720
2726
|
const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
|
|
2721
|
-
return
|
|
2727
|
+
return chunkDXGZ2NUG_cjs.resolveEffectiveContextWindow({
|
|
2722
2728
|
...override !== void 0 ? { override } : {},
|
|
2723
|
-
catalog:
|
|
2724
|
-
margin:
|
|
2725
|
-
floor:
|
|
2729
|
+
catalog: chunkHCZD23VS_cjs.getCatalogModelInfo(model)?.limit?.context,
|
|
2730
|
+
margin: chunkDXGZ2NUG_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2731
|
+
floor: chunkDXGZ2NUG_cjs.CONTEXT_WINDOW_FLOOR
|
|
2726
2732
|
});
|
|
2727
2733
|
}
|
|
2728
2734
|
async function runPostRunLifecycle(inputs) {
|
|
@@ -2746,32 +2752,32 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2746
2752
|
try {
|
|
2747
2753
|
const partial = await safeConversation(run);
|
|
2748
2754
|
if (partial !== void 0) {
|
|
2749
|
-
|
|
2755
|
+
chunkRMWTPV3M_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2750
2756
|
userText,
|
|
2751
2757
|
conversation: partial
|
|
2752
2758
|
});
|
|
2753
2759
|
}
|
|
2754
2760
|
} catch (cause) {
|
|
2755
2761
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2756
|
-
|
|
2762
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2757
2763
|
`);
|
|
2758
2764
|
}
|
|
2759
|
-
await
|
|
2765
|
+
await chunkRMWTPV3M_cjs.flushSessionWrites();
|
|
2760
2766
|
return;
|
|
2761
2767
|
}
|
|
2762
2768
|
if (result.result !== void 0) {
|
|
2763
|
-
|
|
2769
|
+
chunkRMWTPV3M_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2764
2770
|
}
|
|
2765
2771
|
const conversation = await safeConversation(run);
|
|
2766
2772
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2767
2773
|
const effectiveWindow = resolvedWindow.window;
|
|
2768
2774
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2769
2775
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2770
|
-
|
|
2776
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(onRunEvent, budgetEvent);
|
|
2771
2777
|
}
|
|
2772
2778
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2773
2779
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2774
|
-
|
|
2780
|
+
chunkRMWTPV3M_cjs.persistTurnToTranscript(
|
|
2775
2781
|
sessionStore,
|
|
2776
2782
|
{ cwd: workspaceCwd, agentId, model },
|
|
2777
2783
|
agentId,
|
|
@@ -2783,17 +2789,20 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2783
2789
|
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2784
2790
|
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2785
2791
|
contextWindow: effectiveWindow,
|
|
2786
|
-
summarize:
|
|
2792
|
+
summarize: chunkKYAJINUI_cjs.buildDefaultSummarizer({
|
|
2787
2793
|
agentModel: model,
|
|
2788
2794
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2789
2795
|
})
|
|
2790
2796
|
}
|
|
2791
2797
|
},
|
|
2792
|
-
onRunEvent !== void 0 ? () =>
|
|
2798
|
+
onRunEvent !== void 0 ? () => chunk3FFAEAUJ_cjs.emitRunEvent(onRunEvent, { type: "compact_boundary", trigger: "auto" }) : void 0
|
|
2793
2799
|
);
|
|
2794
2800
|
if (result.status === "finished" && result.result !== void 0 && sessionTranscriptAllowed(inputs.memory)) {
|
|
2795
2801
|
const summaryArgs = {
|
|
2796
2802
|
cwd: workspaceCwd,
|
|
2803
|
+
// Resolved once, here, and handed to both writers. Recomputing it inside either one is how
|
|
2804
|
+
// the summary ended up in a directory the indexer never scanned (#463).
|
|
2805
|
+
memoryRoot: chunk6RKUO7AW_cjs.resolveMemoryRoot(workspaceCwd, inputs.memory),
|
|
2797
2806
|
runId: result.id,
|
|
2798
2807
|
agentId,
|
|
2799
2808
|
userText,
|
|
@@ -2805,14 +2814,14 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2805
2814
|
if (memoryProvider?.recordSessionSummary !== void 0) {
|
|
2806
2815
|
await memoryProvider.recordSessionSummary(summaryArgs);
|
|
2807
2816
|
} else {
|
|
2808
|
-
await
|
|
2817
|
+
await chunk6RKUO7AW_cjs.writeSessionSummary(summaryArgs);
|
|
2809
2818
|
}
|
|
2810
2819
|
if (!shouldUsePortMemoryPath()) {
|
|
2811
2820
|
void memoryGlue.syncIfReady();
|
|
2812
2821
|
}
|
|
2813
2822
|
} catch (cause) {
|
|
2814
2823
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2815
|
-
|
|
2824
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] session summary write failed (${result.id}): ${message}
|
|
2816
2825
|
`);
|
|
2817
2826
|
}
|
|
2818
2827
|
}
|
|
@@ -2825,7 +2834,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2825
2834
|
agentId,
|
|
2826
2835
|
runId: result.id
|
|
2827
2836
|
});
|
|
2828
|
-
await
|
|
2837
|
+
await chunkRMWTPV3M_cjs.flushSessionWrites();
|
|
2829
2838
|
}
|
|
2830
2839
|
async function safeConversation(run) {
|
|
2831
2840
|
try {
|
|
@@ -2900,7 +2909,7 @@ var warned = /* @__PURE__ */ new Set();
|
|
|
2900
2909
|
function warnDoubleReasoningOnce() {
|
|
2901
2910
|
if (warned.has("double-reasoning")) return;
|
|
2902
2911
|
warned.add("double-reasoning");
|
|
2903
|
-
|
|
2912
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
2904
2913
|
"[theokit-sdk] `reasoning: true` skipped \u2014 a native reasoning model is configured (model.params thinking/reasoning); native reasoning wins. Remove one to silence.\n"
|
|
2905
2914
|
);
|
|
2906
2915
|
}
|
|
@@ -2934,14 +2943,14 @@ var SkillsManager = class {
|
|
|
2934
2943
|
async refresh() {
|
|
2935
2944
|
const roots = this.skillsDir === void 0 ? [
|
|
2936
2945
|
...chunkAQO3NSRG_cjs.projectConfigRoots(this.cwd).map((root) => path.join(root, "skills")),
|
|
2937
|
-
...(await
|
|
2946
|
+
...(await chunkCQBXOJ6U_cjs.pluginBundleDirs(this.cwd)).map((bundle) => path.join(bundle, "skills"))
|
|
2938
2947
|
] : [this.skillsDir];
|
|
2939
2948
|
const discovered = [];
|
|
2940
2949
|
const seen = /* @__PURE__ */ new Set();
|
|
2941
2950
|
for (const root of roots) {
|
|
2942
|
-
for (const skill of await
|
|
2951
|
+
for (const skill of await chunkOHLDPWTA_cjs.discoverSkills(root, {
|
|
2943
2952
|
onInvalidSkill: (info) => {
|
|
2944
|
-
|
|
2953
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
2945
2954
|
`);
|
|
2946
2955
|
}
|
|
2947
2956
|
})) {
|
|
@@ -2970,7 +2979,7 @@ var SkillsManager = class {
|
|
|
2970
2979
|
async get(name) {
|
|
2971
2980
|
const skill = this.skills.find((s) => s.name === name);
|
|
2972
2981
|
if (skill === void 0) return void 0;
|
|
2973
|
-
const instructions = typeof skill.instructions === "string" ? skill.instructions :
|
|
2982
|
+
const instructions = typeof skill.instructions === "string" ? skill.instructions : chunkOHLDPWTA_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
|
|
2974
2983
|
const references = skill.references;
|
|
2975
2984
|
return {
|
|
2976
2985
|
name: skill.name,
|
|
@@ -3056,7 +3065,7 @@ async function safeCall(fn, fallback, label = "safeCall") {
|
|
|
3056
3065
|
return await fn();
|
|
3057
3066
|
} catch (cause) {
|
|
3058
3067
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3059
|
-
|
|
3068
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] ${label} failed: ${message}
|
|
3060
3069
|
`);
|
|
3061
3070
|
return fallback;
|
|
3062
3071
|
}
|
|
@@ -3070,7 +3079,7 @@ var ActiveMemoryPromptProvider = class {
|
|
|
3070
3079
|
if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
|
|
3071
3080
|
return Promise.resolve(void 0);
|
|
3072
3081
|
}
|
|
3073
|
-
const body =
|
|
3082
|
+
const body = chunkOHLDPWTA_cjs.escapeBlockBody(ctx.activeMemorySummary);
|
|
3074
3083
|
return Promise.resolve(`<active-memory>
|
|
3075
3084
|
${body}
|
|
3076
3085
|
</active-memory>`);
|
|
@@ -3123,7 +3132,7 @@ function formatSource(name, tokens) {
|
|
|
3123
3132
|
if (tokens.length === 0) {
|
|
3124
3133
|
return ` <source name="${escapeAttribute(name)}" />`;
|
|
3125
3134
|
}
|
|
3126
|
-
const body =
|
|
3135
|
+
const body = chunkOHLDPWTA_cjs.escapeBlockBody(tokens.join(" "));
|
|
3127
3136
|
return ` <source name="${escapeAttribute(name)}">
|
|
3128
3137
|
${body}
|
|
3129
3138
|
</source>`;
|
|
@@ -3147,7 +3156,7 @@ var MemoryPromptProvider = class {
|
|
|
3147
3156
|
if (ctx.memory.length === 0) return Promise.resolve(void 0);
|
|
3148
3157
|
const lines = ctx.memory.map((fact) => {
|
|
3149
3158
|
const tag = fact.observations === 1 ? "[unconfirmed] " : "";
|
|
3150
|
-
return ` - ${tag}${
|
|
3159
|
+
return ` - ${tag}${chunkOHLDPWTA_cjs.escapeBlockBody(fact.text)}`;
|
|
3151
3160
|
});
|
|
3152
3161
|
return Promise.resolve(`${MEMORY_GUIDANCE}
|
|
3153
3162
|
<memory>
|
|
@@ -3171,7 +3180,7 @@ var SkillsPromptProvider = class {
|
|
|
3171
3180
|
priority = 20;
|
|
3172
3181
|
contribute(ctx) {
|
|
3173
3182
|
if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
|
|
3174
|
-
return Promise.resolve(
|
|
3183
|
+
return Promise.resolve(chunkOHLDPWTA_cjs.buildSkillsBlock(ctx.skills));
|
|
3175
3184
|
}
|
|
3176
3185
|
};
|
|
3177
3186
|
|
|
@@ -3183,7 +3192,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
|
|
|
3183
3192
|
for (const p of providers) {
|
|
3184
3193
|
const key = `${p.priority}:${p.id}`;
|
|
3185
3194
|
if (seen.has(key)) {
|
|
3186
|
-
throw new
|
|
3195
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Duplicate system-prompt provider ${key}`, {
|
|
3187
3196
|
code: "pipeline_duplicate_provider"
|
|
3188
3197
|
});
|
|
3189
3198
|
}
|
|
@@ -3230,7 +3239,7 @@ function validateAgentOptions(options) {
|
|
|
3230
3239
|
ensureRuntimeShape(options);
|
|
3231
3240
|
if (options.local !== void 0) {
|
|
3232
3241
|
if (options.model === void 0) {
|
|
3233
|
-
throw new
|
|
3242
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError("Local agents require a model selection", {
|
|
3234
3243
|
code: "missing_model"
|
|
3235
3244
|
});
|
|
3236
3245
|
}
|
|
@@ -3254,7 +3263,7 @@ function validateCredentialPoolShape(options) {
|
|
|
3254
3263
|
([, arr]) => Array.isArray(arr) && arr.some((k) => typeof k === "string" && k.length > 0)
|
|
3255
3264
|
);
|
|
3256
3265
|
if (populated.length === 0) return;
|
|
3257
|
-
throw new
|
|
3266
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3258
3267
|
"Ambiguous credential configuration: use either `apiKey: '...'` (single-key, simplest) OR `apiKeys: { provider: [...] }` (multi-key pool), not both.",
|
|
3259
3268
|
{ code: "credential_pool_ambiguous" }
|
|
3260
3269
|
);
|
|
@@ -3263,7 +3272,7 @@ function validatePlugins(options) {
|
|
|
3263
3272
|
const plugins = options.plugins;
|
|
3264
3273
|
if (plugins?.paths === void 0) return;
|
|
3265
3274
|
if (options.cloud !== void 0 && plugins.paths.length > 0) {
|
|
3266
|
-
throw new
|
|
3275
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3267
3276
|
"Cloud agents require committed plugin manifests; local plugin paths are not supported",
|
|
3268
3277
|
{ code: "cloud_plugin_path_rejected" }
|
|
3269
3278
|
);
|
|
@@ -3271,7 +3280,7 @@ function validatePlugins(options) {
|
|
|
3271
3280
|
}
|
|
3272
3281
|
function ensureRuntimeShape(options) {
|
|
3273
3282
|
if (options.local !== void 0 && options.cloud !== void 0) {
|
|
3274
|
-
throw new
|
|
3283
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3275
3284
|
"Pass either local or cloud \u2014 they are mutually exclusive runtimes",
|
|
3276
3285
|
{ code: "runtime_exclusive" }
|
|
3277
3286
|
);
|
|
@@ -3279,7 +3288,7 @@ function ensureRuntimeShape(options) {
|
|
|
3279
3288
|
}
|
|
3280
3289
|
function rejectProgrammaticHooks(options) {
|
|
3281
3290
|
if (options.hooks !== void 0) {
|
|
3282
|
-
throw new
|
|
3291
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3283
3292
|
"Programmatic hooks are not supported \u2014 hooks are file-based only (.theokit/hooks.json)",
|
|
3284
3293
|
{ code: "programmatic_hooks_rejected" }
|
|
3285
3294
|
);
|
|
@@ -3289,7 +3298,7 @@ function validateCloud(cloud) {
|
|
|
3289
3298
|
if (cloud.envVars !== void 0) {
|
|
3290
3299
|
for (const key of Object.keys(cloud.envVars)) {
|
|
3291
3300
|
if (key.startsWith("THEOKIT_")) {
|
|
3292
|
-
throw new
|
|
3301
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3293
3302
|
`Cloud envVars cannot use the reserved THEOKIT_ prefix (got "${key}")`,
|
|
3294
3303
|
{ code: "reserved_env_prefix" }
|
|
3295
3304
|
);
|
|
@@ -3301,7 +3310,7 @@ function validateMcpServers(options) {
|
|
|
3301
3310
|
if (options.mcpServers === void 0) return;
|
|
3302
3311
|
for (const [name, config] of Object.entries(options.mcpServers)) {
|
|
3303
3312
|
if (options.cloud !== void 0 && isStdioWithCwd(config)) {
|
|
3304
|
-
throw new
|
|
3313
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3305
3314
|
`MCP server "${name}" uses stdio with cwd, which is rejected for cloud agents`,
|
|
3306
3315
|
{ code: "cloud_stdio_cwd_rejected" }
|
|
3307
3316
|
);
|
|
@@ -3320,12 +3329,12 @@ function validateSubagents(agents2) {
|
|
|
3320
3329
|
if (agents2 === void 0) return;
|
|
3321
3330
|
for (const [name, definition] of Object.entries(agents2)) {
|
|
3322
3331
|
if (typeof definition.description !== "string" || definition.description.length === 0) {
|
|
3323
|
-
throw new
|
|
3332
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty description`, {
|
|
3324
3333
|
code: "subagent_missing_description"
|
|
3325
3334
|
});
|
|
3326
3335
|
}
|
|
3327
3336
|
if (typeof definition.prompt !== "string" || definition.prompt.length === 0) {
|
|
3328
|
-
throw new
|
|
3337
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty prompt`, {
|
|
3329
3338
|
code: "subagent_missing_prompt"
|
|
3330
3339
|
});
|
|
3331
3340
|
}
|
|
@@ -3344,7 +3353,7 @@ function validateToolCatalog(tools, withheldBuiltins) {
|
|
|
3344
3353
|
for (const tool of tools) {
|
|
3345
3354
|
validateSingleTool(tool, reserved);
|
|
3346
3355
|
if (seen.has(tool.name)) {
|
|
3347
|
-
throw new
|
|
3356
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Duplicate custom tool name "${tool.name}"`, {
|
|
3348
3357
|
code: "duplicate_tool_name"
|
|
3349
3358
|
});
|
|
3350
3359
|
}
|
|
@@ -3355,7 +3364,7 @@ function validateCustomTools(options) {
|
|
|
3355
3364
|
const tools = options.tools;
|
|
3356
3365
|
if (tools === void 0 || tools.length === 0) return;
|
|
3357
3366
|
if (options.cloud !== void 0) {
|
|
3358
|
-
throw new
|
|
3367
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3359
3368
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
3360
3369
|
{ code: "cloud_custom_tools_rejected" }
|
|
3361
3370
|
);
|
|
@@ -3367,25 +3376,25 @@ function validateSingleTool(tool, reserved) {
|
|
|
3367
3376
|
validateToolDescription(tool);
|
|
3368
3377
|
validateToolSchema(tool);
|
|
3369
3378
|
if (typeof tool.handler !== "function") {
|
|
3370
|
-
throw new
|
|
3379
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a handler function`, {
|
|
3371
3380
|
code: "tool_missing_handler"
|
|
3372
3381
|
});
|
|
3373
3382
|
}
|
|
3374
3383
|
}
|
|
3375
3384
|
function validateToolName(tool, reserved) {
|
|
3376
3385
|
if (typeof tool.name !== "string" || tool.name.length === 0) {
|
|
3377
|
-
throw new
|
|
3386
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError("Custom tool requires a non-empty name", {
|
|
3378
3387
|
code: "tool_missing_name"
|
|
3379
3388
|
});
|
|
3380
3389
|
}
|
|
3381
3390
|
if (!TOOL_NAME_PATTERN.test(tool.name)) {
|
|
3382
|
-
throw new
|
|
3391
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3383
3392
|
`Custom tool name "${tool.name}" must match /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/`,
|
|
3384
3393
|
{ code: "tool_invalid_name" }
|
|
3385
3394
|
);
|
|
3386
3395
|
}
|
|
3387
3396
|
if (reserved.has(tool.name) || tool.name.startsWith("mcp_")) {
|
|
3388
|
-
throw new
|
|
3397
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3389
3398
|
`Custom tool name "${tool.name}" collides with a reserved SDK tool name`,
|
|
3390
3399
|
{ code: "tool_reserved_name" }
|
|
3391
3400
|
);
|
|
@@ -3393,7 +3402,7 @@ function validateToolName(tool, reserved) {
|
|
|
3393
3402
|
}
|
|
3394
3403
|
function validateToolDescription(tool) {
|
|
3395
3404
|
if (typeof tool.description !== "string" || tool.description.length === 0) {
|
|
3396
|
-
throw new
|
|
3405
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a non-empty description`, {
|
|
3397
3406
|
code: "tool_missing_description"
|
|
3398
3407
|
});
|
|
3399
3408
|
}
|
|
@@ -3401,12 +3410,12 @@ function validateToolDescription(tool) {
|
|
|
3401
3410
|
function validateToolSchema(tool) {
|
|
3402
3411
|
const schema = tool.inputSchema;
|
|
3403
3412
|
if (schema === null || schema === void 0 || typeof schema !== "object") {
|
|
3404
|
-
throw new
|
|
3413
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Custom tool "${tool.name}" requires an inputSchema object`, {
|
|
3405
3414
|
code: "tool_missing_schema"
|
|
3406
3415
|
});
|
|
3407
3416
|
}
|
|
3408
3417
|
if (schema.type !== "object") {
|
|
3409
|
-
throw new
|
|
3418
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3410
3419
|
`Custom tool "${tool.name}" inputSchema must declare \`type: "object"\``,
|
|
3411
3420
|
{ code: "tool_invalid_schema_type" }
|
|
3412
3421
|
);
|
|
@@ -3417,7 +3426,7 @@ function validateMemory(options) {
|
|
|
3417
3426
|
if (memory?.storePath === void 0) return;
|
|
3418
3427
|
const storePath = memory.storePath;
|
|
3419
3428
|
if (storePath.includes("..") || storePath.startsWith("/") || /^[A-Z]:/i.test(storePath)) {
|
|
3420
|
-
throw new
|
|
3429
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3421
3430
|
`Memory storePath must stay inside the workspace; got "${storePath}"`,
|
|
3422
3431
|
{ code: "memory_path_traversal" }
|
|
3423
3432
|
);
|
|
@@ -3439,7 +3448,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3439
3448
|
};
|
|
3440
3449
|
function safeRequire(moduleName) {
|
|
3441
3450
|
try {
|
|
3442
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3451
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-ZMRD5DZQ.cjs', document.baseURI).href)));
|
|
3443
3452
|
return r(moduleName);
|
|
3444
3453
|
} catch {
|
|
3445
3454
|
return void 0;
|
|
@@ -3518,7 +3527,7 @@ var langfuseAdapter = {
|
|
|
3518
3527
|
}
|
|
3519
3528
|
}
|
|
3520
3529
|
if (lf.LangfuseSpanProcessor === void 0) {
|
|
3521
|
-
|
|
3530
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
3522
3531
|
"[theokit-sdk] @langfuse/node detected but LangfuseSpanProcessor not found (v2?). Use Langfuse v3+ for auto-instrumentation.\n"
|
|
3523
3532
|
);
|
|
3524
3533
|
return;
|
|
@@ -3650,11 +3659,11 @@ function tryAutoRegisterAdapters(settings) {
|
|
|
3650
3659
|
try {
|
|
3651
3660
|
adapter.register();
|
|
3652
3661
|
registered.add(adapter.moduleName);
|
|
3653
|
-
|
|
3662
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] telemetry: ${adapter.displayName} auto-instrumented.
|
|
3654
3663
|
`);
|
|
3655
3664
|
} catch (cause) {
|
|
3656
3665
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3657
|
-
|
|
3666
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
3658
3667
|
`[theokit-sdk] telemetry: ${adapter.displayName} detected but failed to register: ${message}
|
|
3659
3668
|
`
|
|
3660
3669
|
);
|
|
@@ -3667,7 +3676,7 @@ var cachedOtel;
|
|
|
3667
3676
|
function loadOtel() {
|
|
3668
3677
|
if (cachedOtel === void 0) {
|
|
3669
3678
|
try {
|
|
3670
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3679
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-ZMRD5DZQ.cjs', document.baseURI).href)));
|
|
3671
3680
|
const mod = r("@opentelemetry/api");
|
|
3672
3681
|
cachedOtel = mod;
|
|
3673
3682
|
} catch {
|
|
@@ -3710,7 +3719,7 @@ function safe(op, fallback) {
|
|
|
3710
3719
|
if (!warnedOnce) {
|
|
3711
3720
|
warnedOnce = true;
|
|
3712
3721
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3713
|
-
|
|
3722
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
3714
3723
|
`[theokit-sdk] telemetry exporter error (suppressed; agent.send continues): ${message}
|
|
3715
3724
|
`
|
|
3716
3725
|
);
|
|
@@ -3724,7 +3733,7 @@ function createTelemetry(settings) {
|
|
|
3724
3733
|
if (otel === null) {
|
|
3725
3734
|
if (!warnedOnce) {
|
|
3726
3735
|
warnedOnce = true;
|
|
3727
|
-
|
|
3736
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
3728
3737
|
"[theokit-sdk] telemetry.enabled = true but `@opentelemetry/api` is not installed; telemetry is a no-op.\n"
|
|
3729
3738
|
);
|
|
3730
3739
|
}
|
|
@@ -3818,12 +3827,12 @@ function wrapSpan(span, openSpans) {
|
|
|
3818
3827
|
}
|
|
3819
3828
|
function redactAttrValue(value) {
|
|
3820
3829
|
if (typeof value !== "string") return value;
|
|
3821
|
-
return
|
|
3830
|
+
return chunkXL7Q7HB2_cjs.redactSecrets(value);
|
|
3822
3831
|
}
|
|
3823
3832
|
function redactAttrs(attrs) {
|
|
3824
3833
|
const out = {};
|
|
3825
3834
|
for (const [k, v] of Object.entries(attrs)) {
|
|
3826
|
-
out[k] = typeof v === "string" ?
|
|
3835
|
+
out[k] = typeof v === "string" ? chunkXL7Q7HB2_cjs.redactSecrets(v) : v;
|
|
3827
3836
|
}
|
|
3828
3837
|
return out;
|
|
3829
3838
|
}
|
|
@@ -3904,10 +3913,10 @@ async function loadMarkdownEntities(opts) {
|
|
|
3904
3913
|
const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
|
|
3905
3914
|
if (raw === null) continue;
|
|
3906
3915
|
const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
|
|
3907
|
-
const fields =
|
|
3916
|
+
const fields = chunk4CLOXP6H_cjs.parseSimpleYaml(split.frontmatter);
|
|
3908
3917
|
const parsed = schema.safeParse(fields);
|
|
3909
3918
|
if (!parsed.success) {
|
|
3910
|
-
throw new
|
|
3919
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3911
3920
|
`Invalid frontmatter in ${resolved.source}: ${parsed.error.message}`,
|
|
3912
3921
|
{ code: `${errorCodePrefix}_frontmatter_invalid` }
|
|
3913
3922
|
);
|
|
@@ -3925,13 +3934,13 @@ async function assertFileSizeUnderCap(source, errorCodePrefix) {
|
|
|
3925
3934
|
try {
|
|
3926
3935
|
const info = await promises.stat(source);
|
|
3927
3936
|
if (info.size > MAX_MD_FILE_BYTES) {
|
|
3928
|
-
throw new
|
|
3937
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3929
3938
|
`Config file ${source} exceeds 1 MB size limit (${info.size} bytes). Reduce the file or split into multiple entities.`,
|
|
3930
3939
|
{ code: `${errorCodePrefix}_file_too_large` }
|
|
3931
3940
|
);
|
|
3932
3941
|
}
|
|
3933
3942
|
} catch (cause) {
|
|
3934
|
-
if (cause instanceof
|
|
3943
|
+
if (cause instanceof chunk4ZHTIJNE_cjs.ConfigurationError) throw cause;
|
|
3935
3944
|
}
|
|
3936
3945
|
}
|
|
3937
3946
|
async function readDirSafe(dir, errorCodePrefix) {
|
|
@@ -3940,7 +3949,7 @@ async function readDirSafe(dir, errorCodePrefix) {
|
|
|
3940
3949
|
} catch (cause) {
|
|
3941
3950
|
const code = cause.code;
|
|
3942
3951
|
if (code === "ENOENT") return null;
|
|
3943
|
-
throw new
|
|
3952
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Failed to read ${dir}`, {
|
|
3944
3953
|
code: `${errorCodePrefix}_dir_read_error`,
|
|
3945
3954
|
cause
|
|
3946
3955
|
});
|
|
@@ -3957,7 +3966,7 @@ function resolveEntryPath(entry, pattern, dir) {
|
|
|
3957
3966
|
function splitFrontmatter(raw, source, errorCodePrefix) {
|
|
3958
3967
|
const match = /^---\s*\n([\s\S]*?)\n---\s*(?:\n|$)/.exec(raw);
|
|
3959
3968
|
if (match === null) {
|
|
3960
|
-
throw new
|
|
3969
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
3961
3970
|
`Missing or malformed frontmatter in ${source} (expected \`---\` delimited block at file head)`,
|
|
3962
3971
|
{ code: `${errorCodePrefix}_missing_frontmatter` }
|
|
3963
3972
|
);
|
|
@@ -4131,7 +4140,7 @@ async function loadContextConfig(cwd) {
|
|
|
4131
4140
|
});
|
|
4132
4141
|
if (mdEntities.length > 0) {
|
|
4133
4142
|
if (fs.existsSync(jsonPath)) {
|
|
4134
|
-
|
|
4143
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
4135
4144
|
"context-both-present",
|
|
4136
4145
|
"[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
|
|
4137
4146
|
);
|
|
@@ -4141,7 +4150,7 @@ async function loadContextConfig(cwd) {
|
|
|
4141
4150
|
};
|
|
4142
4151
|
}
|
|
4143
4152
|
if (!fs.existsSync(jsonPath)) return { sources: [] };
|
|
4144
|
-
|
|
4153
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
4145
4154
|
"context-json-deprecated",
|
|
4146
4155
|
"[theokit-sdk] .theokit/context.json is deprecated; migrate to .theokit/context/<name>.md via theokit-migrate-config"
|
|
4147
4156
|
);
|
|
@@ -4149,7 +4158,7 @@ async function loadContextConfig(cwd) {
|
|
|
4149
4158
|
try {
|
|
4150
4159
|
raw = await promises.readFile(jsonPath, "utf8");
|
|
4151
4160
|
} catch (cause) {
|
|
4152
|
-
throw new
|
|
4161
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Failed to read context config: ${jsonPath}`, {
|
|
4153
4162
|
code: "context_read_error",
|
|
4154
4163
|
cause
|
|
4155
4164
|
});
|
|
@@ -4161,13 +4170,13 @@ function parseConfig(raw, configPath) {
|
|
|
4161
4170
|
try {
|
|
4162
4171
|
parsed = JSON.parse(raw);
|
|
4163
4172
|
} catch (cause) {
|
|
4164
|
-
throw new
|
|
4173
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Invalid JSON in context config: ${configPath}`, {
|
|
4165
4174
|
code: "context_json_invalid",
|
|
4166
4175
|
cause
|
|
4167
4176
|
});
|
|
4168
4177
|
}
|
|
4169
4178
|
if (!parsed || typeof parsed !== "object") {
|
|
4170
|
-
throw new
|
|
4179
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Context config must be an object: ${configPath}`, {
|
|
4171
4180
|
code: "context_config_shape"
|
|
4172
4181
|
});
|
|
4173
4182
|
}
|
|
@@ -4182,7 +4191,7 @@ function parseConfig(raw, configPath) {
|
|
|
4182
4191
|
}
|
|
4183
4192
|
function readSources(sourcesRaw, configPath) {
|
|
4184
4193
|
if (!Array.isArray(sourcesRaw)) {
|
|
4185
|
-
throw new
|
|
4194
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Context config sources must be an array: ${configPath}`, {
|
|
4186
4195
|
code: "context_sources_shape"
|
|
4187
4196
|
});
|
|
4188
4197
|
}
|
|
@@ -4283,7 +4292,7 @@ var PluginsManager = class {
|
|
|
4283
4292
|
}
|
|
4284
4293
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: MD-first + JSON fallback + CLI location + both-present detection per plugin folder — branch table is clearer inlined.
|
|
4285
4294
|
async refreshRoot(pluginsRoot) {
|
|
4286
|
-
const entries = await
|
|
4295
|
+
const entries = await chunk4CLOXP6H_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
|
|
4287
4296
|
for (const entry of entries) {
|
|
4288
4297
|
if (!entry.isDirectory()) continue;
|
|
4289
4298
|
const folderName = entry.name;
|
|
@@ -4299,13 +4308,13 @@ var PluginsManager = class {
|
|
|
4299
4308
|
const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
|
|
4300
4309
|
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
|
|
4301
4310
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4302
|
-
|
|
4311
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
4303
4312
|
`plugin-${folderName}-both`,
|
|
4304
4313
|
`[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
|
|
4305
4314
|
);
|
|
4306
4315
|
}
|
|
4307
4316
|
if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4308
|
-
|
|
4317
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
4309
4318
|
"plugin-json-deprecated",
|
|
4310
4319
|
"[theokit-sdk] plugin.json manifests are deprecated; migrate to PLUGIN.md via theokit-migrate-config"
|
|
4311
4320
|
);
|
|
@@ -4323,11 +4332,11 @@ var PluginsManager = class {
|
|
|
4323
4332
|
const entry = metadata.entry;
|
|
4324
4333
|
if (entry === void 0) return;
|
|
4325
4334
|
const pluginRoot = path.join(this.cwd, ".theokit", "plugins", folderName);
|
|
4326
|
-
const entryPath =
|
|
4335
|
+
const entryPath = chunkV2BOS4WF_cjs.safePathJoin(pluginRoot, entry);
|
|
4327
4336
|
try {
|
|
4328
4337
|
await promises.readFile(entryPath, "utf8");
|
|
4329
4338
|
} catch (cause) {
|
|
4330
|
-
throw new
|
|
4339
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Plugin ${metadata.name} entry file is missing: ${entry}`, {
|
|
4331
4340
|
code: "plugin_entry_missing",
|
|
4332
4341
|
cause
|
|
4333
4342
|
});
|
|
@@ -4351,7 +4360,7 @@ var PluginsManager = class {
|
|
|
4351
4360
|
assertCloudRules() {
|
|
4352
4361
|
if (!this.cloud) return;
|
|
4353
4362
|
if (this.localPaths !== void 0 && this.localPaths.length > 0) {
|
|
4354
|
-
throw new
|
|
4363
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
4355
4364
|
"Cloud agents reject local plugin paths \u2014 plugins must come from committed repo files",
|
|
4356
4365
|
{ code: "cloud_plugin_path_rejected" }
|
|
4357
4366
|
);
|
|
@@ -4363,7 +4372,7 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4363
4372
|
try {
|
|
4364
4373
|
raw = await promises.readFile(manifestPath, "utf8");
|
|
4365
4374
|
} catch (cause) {
|
|
4366
|
-
throw new
|
|
4375
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Plugin ${folderName} is missing plugin.json`, {
|
|
4367
4376
|
code: "plugin_missing_manifest",
|
|
4368
4377
|
cause
|
|
4369
4378
|
});
|
|
@@ -4372,13 +4381,13 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4372
4381
|
try {
|
|
4373
4382
|
parsed = JSON.parse(raw);
|
|
4374
4383
|
} catch (cause) {
|
|
4375
|
-
throw new
|
|
4384
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Plugin ${folderName} manifest is invalid JSON`, {
|
|
4376
4385
|
code: "plugin_manifest_invalid",
|
|
4377
4386
|
cause
|
|
4378
4387
|
});
|
|
4379
4388
|
}
|
|
4380
4389
|
if (!parsed || typeof parsed !== "object") {
|
|
4381
|
-
throw new
|
|
4390
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Plugin ${folderName} manifest must be an object`, {
|
|
4382
4391
|
code: "plugin_manifest_shape"
|
|
4383
4392
|
});
|
|
4384
4393
|
}
|
|
@@ -4397,7 +4406,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4397
4406
|
try {
|
|
4398
4407
|
raw = await promises.readFile(mdPath, "utf8");
|
|
4399
4408
|
} catch (cause) {
|
|
4400
|
-
throw new
|
|
4409
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Plugin ${folderName} is missing PLUGIN.md`, {
|
|
4401
4410
|
code: "plugin_missing_manifest",
|
|
4402
4411
|
cause
|
|
4403
4412
|
});
|
|
@@ -4412,7 +4421,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4412
4421
|
});
|
|
4413
4422
|
const entity = entities.find((e) => e.slug === "PLUGIN");
|
|
4414
4423
|
if (entity === void 0) {
|
|
4415
|
-
throw new
|
|
4424
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`Plugin ${folderName} PLUGIN.md not parseable`, {
|
|
4416
4425
|
code: "plugin_missing_manifest"
|
|
4417
4426
|
});
|
|
4418
4427
|
}
|
|
@@ -4686,7 +4695,7 @@ function assertValidThresholds(soft, hard) {
|
|
|
4686
4695
|
["hardThreshold", hard]
|
|
4687
4696
|
]) {
|
|
4688
4697
|
if (!Number.isInteger(value) || value < 1) {
|
|
4689
|
-
throw new
|
|
4698
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
4690
4699
|
`doomLoop.${label} must be a positive integer (received ${value}).`,
|
|
4691
4700
|
{ code: "invalid_doom_loop_threshold" }
|
|
4692
4701
|
);
|
|
@@ -4999,7 +5008,7 @@ async function initLoopContext(inputs) {
|
|
|
4999
5008
|
async function safeListTools(client, serverName, sink) {
|
|
5000
5009
|
try {
|
|
5001
5010
|
const listed = await client.listTools();
|
|
5002
|
-
|
|
5011
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(sink, {
|
|
5003
5012
|
type: "mcp_server_ready",
|
|
5004
5013
|
serverName: serverName ?? "unknown",
|
|
5005
5014
|
tools: listed.map((tool) => tool.name)
|
|
@@ -5008,9 +5017,9 @@ async function safeListTools(client, serverName, sink) {
|
|
|
5008
5017
|
} catch (cause) {
|
|
5009
5018
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
5010
5019
|
const server = serverName ?? "unknown";
|
|
5011
|
-
|
|
5020
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] mcp listTools failed (server=${server}): ${message}
|
|
5012
5021
|
`);
|
|
5013
|
-
|
|
5022
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(sink, { type: "mcp_server_failed", serverName: server, message });
|
|
5014
5023
|
return [];
|
|
5015
5024
|
}
|
|
5016
5025
|
}
|
|
@@ -5089,7 +5098,7 @@ function emitLlmMetrics(inputs, result, startAt) {
|
|
|
5089
5098
|
inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.LLM_USAGE_MISSING, 1, {
|
|
5090
5099
|
provider: inputs.llm.name
|
|
5091
5100
|
});
|
|
5092
|
-
|
|
5101
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
5093
5102
|
`[theokit-sdk] llm usage missing from ${inputs.llm.name} finish \u2014 budget may undercount
|
|
5094
5103
|
`
|
|
5095
5104
|
);
|
|
@@ -5395,7 +5404,7 @@ function coerceArgsToSchema(args, schema) {
|
|
|
5395
5404
|
}
|
|
5396
5405
|
|
|
5397
5406
|
// src/tool-error.ts
|
|
5398
|
-
var ToolError = class extends
|
|
5407
|
+
var ToolError = class extends chunk4ZHTIJNE_cjs.TheokitAgentError {
|
|
5399
5408
|
name = "ToolError";
|
|
5400
5409
|
/** The error content surfaced to the model: a string, or text/image blocks. */
|
|
5401
5410
|
content;
|
|
@@ -5589,7 +5598,7 @@ function raceToolExecution(exec, opts) {
|
|
|
5589
5598
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
5590
5599
|
async function dispatchTools(inputs, tools, toolCalls, events, parentSpan) {
|
|
5591
5600
|
const maxConcurrent = inputs.maxConcurrentTools ?? 4;
|
|
5592
|
-
return
|
|
5601
|
+
return chunkZSWPZ23K_cjs.mapWithConcurrency(
|
|
5593
5602
|
toolCalls,
|
|
5594
5603
|
maxConcurrent,
|
|
5595
5604
|
(call) => dispatchSingleCall(inputs, tools, call, events, parentSpan)
|
|
@@ -5617,7 +5626,7 @@ async function dispatchSingleCall(inputs, tools, call, events, parentSpan) {
|
|
|
5617
5626
|
toolSpan?.end();
|
|
5618
5627
|
return fileVeto;
|
|
5619
5628
|
}
|
|
5620
|
-
|
|
5629
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5621
5630
|
type: "tool_progress",
|
|
5622
5631
|
toolName: workingCall.name,
|
|
5623
5632
|
toolCallId: callId
|
|
@@ -5648,7 +5657,7 @@ function applyRepairAndExtractCall(tools, call) {
|
|
|
5648
5657
|
function vetoFromForkWhitelist(inputs, call, callId, events) {
|
|
5649
5658
|
const whitelistDecision = chunkVJ26EKGJ_cjs.checkToolWhitelist(call.name);
|
|
5650
5659
|
if (whitelistDecision.allowed) return void 0;
|
|
5651
|
-
|
|
5660
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5652
5661
|
type: "permission_denied",
|
|
5653
5662
|
toolName: call.name,
|
|
5654
5663
|
toolCallId: callId,
|
|
@@ -5693,7 +5702,7 @@ async function vetoFromPluginPreHook(inputs, call, callId, events) {
|
|
|
5693
5702
|
...inputs.permissionMode !== void 0 ? { permissionMode: inputs.permissionMode } : {}
|
|
5694
5703
|
});
|
|
5695
5704
|
if (pluginVeto === void 0) return void 0;
|
|
5696
|
-
|
|
5705
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5697
5706
|
type: "permission_denied",
|
|
5698
5707
|
toolName: call.name,
|
|
5699
5708
|
toolCallId: callId,
|
|
@@ -5722,7 +5731,7 @@ async function vetoFromFileHookPreDecision(inputs, call, callId, events) {
|
|
|
5722
5731
|
runId: inputs.runId
|
|
5723
5732
|
});
|
|
5724
5733
|
if (!preDecision.blocked) return void 0;
|
|
5725
|
-
|
|
5734
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5726
5735
|
type: "permission_denied",
|
|
5727
5736
|
toolName: call.name,
|
|
5728
5737
|
toolCallId: callId,
|
|
@@ -5823,7 +5832,7 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
|
|
|
5823
5832
|
agentId: inputs.agentId,
|
|
5824
5833
|
runId: inputs.runId
|
|
5825
5834
|
}).catch((err) => {
|
|
5826
|
-
|
|
5835
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
5827
5836
|
`[theokit-sdk] postToolUse hook error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5828
5837
|
`
|
|
5829
5838
|
);
|
|
@@ -5842,7 +5851,7 @@ async function emitToolLifecycleDelta(inputs, update) {
|
|
|
5842
5851
|
try {
|
|
5843
5852
|
await inputs.onDelta({ update });
|
|
5844
5853
|
} catch (err) {
|
|
5845
|
-
|
|
5854
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
5846
5855
|
`[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5847
5856
|
`
|
|
5848
5857
|
);
|
|
@@ -5854,7 +5863,7 @@ async function safeEmitToolHook(callback, event) {
|
|
|
5854
5863
|
await callback(event);
|
|
5855
5864
|
} catch (cause) {
|
|
5856
5865
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
5857
|
-
|
|
5866
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] tool lifecycle hook threw: ${msg}
|
|
5858
5867
|
`);
|
|
5859
5868
|
}
|
|
5860
5869
|
}
|
|
@@ -5921,7 +5930,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
5921
5930
|
(p) => (
|
|
5922
5931
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
5923
5932
|
// structured content); image blocks pass through untouched.
|
|
5924
|
-
p.type === "tool_result" ? { ...p, content:
|
|
5933
|
+
p.type === "tool_result" ? { ...p, content: chunkKYAJINUI_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
5925
5934
|
)
|
|
5926
5935
|
);
|
|
5927
5936
|
}
|
|
@@ -6116,7 +6125,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
6116
6125
|
const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
|
|
6117
6126
|
if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
|
|
6118
6127
|
for (const key of candidates) {
|
|
6119
|
-
const info =
|
|
6128
|
+
const info = chunkHCZD23VS_cjs.getCatalogModelInfo(key);
|
|
6120
6129
|
const cost = info?.cost;
|
|
6121
6130
|
if (cost === void 0) continue;
|
|
6122
6131
|
const [prov, ...modelParts] = key.split("/");
|
|
@@ -6128,7 +6137,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
6128
6137
|
...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
|
|
6129
6138
|
...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
|
|
6130
6139
|
// M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
|
|
6131
|
-
pricingVersion:
|
|
6140
|
+
pricingVersion: chunkHCZD23VS_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
|
|
6132
6141
|
};
|
|
6133
6142
|
}
|
|
6134
6143
|
return void 0;
|
|
@@ -6587,15 +6596,15 @@ var FallbackLlmClient = class {
|
|
|
6587
6596
|
let lastError;
|
|
6588
6597
|
for (const client of this.clients) {
|
|
6589
6598
|
if (signal.aborted) throw abortError(signal);
|
|
6590
|
-
const attempt = await
|
|
6599
|
+
const attempt = await chunkKYAJINUI_cjs.tryFirstEvent(client, request, signal, true);
|
|
6591
6600
|
if (attempt.kind === "handshake_error") {
|
|
6592
6601
|
lastError = attempt.error;
|
|
6593
6602
|
continue;
|
|
6594
6603
|
}
|
|
6595
|
-
return yield*
|
|
6604
|
+
return yield* chunkKYAJINUI_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6596
6605
|
}
|
|
6597
6606
|
if (lastError !== void 0) throw lastError;
|
|
6598
|
-
throw new
|
|
6607
|
+
throw new chunk4ZHTIJNE_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
6599
6608
|
code: "fallback_empty_chain"
|
|
6600
6609
|
});
|
|
6601
6610
|
}
|
|
@@ -6618,7 +6627,7 @@ function reconnectDelay(attempt) {
|
|
|
6618
6627
|
return ms <= 0 ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, ms));
|
|
6619
6628
|
}
|
|
6620
6629
|
function mcpTimeoutError(name, timeoutMs) {
|
|
6621
|
-
return new
|
|
6630
|
+
return new chunk4ZHTIJNE_cjs.NetworkError(`MCP ${name} request timed out after ${timeoutMs}ms`, {
|
|
6622
6631
|
code: "mcp_timeout"
|
|
6623
6632
|
});
|
|
6624
6633
|
}
|
|
@@ -6701,7 +6710,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6701
6710
|
child.stdin.on("error", () => void 0);
|
|
6702
6711
|
child.on("error", () => {
|
|
6703
6712
|
this.rejectAllPending(
|
|
6704
|
-
new
|
|
6713
|
+
new chunk4ZHTIJNE_cjs.NetworkError(`MCP ${this.name} process crashed`, { code: "mcp_crashed" })
|
|
6705
6714
|
);
|
|
6706
6715
|
});
|
|
6707
6716
|
child.on("exit", () => {
|
|
@@ -6709,7 +6718,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6709
6718
|
this.child = void 0;
|
|
6710
6719
|
this.dropped = true;
|
|
6711
6720
|
this.rejectAllPending(
|
|
6712
|
-
new
|
|
6721
|
+
new chunk4ZHTIJNE_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6713
6722
|
);
|
|
6714
6723
|
});
|
|
6715
6724
|
}
|
|
@@ -6737,7 +6746,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6737
6746
|
if (this.child !== void 0) return Promise.resolve();
|
|
6738
6747
|
if (!this.dropped) {
|
|
6739
6748
|
return Promise.reject(
|
|
6740
|
-
new
|
|
6749
|
+
new chunk4ZHTIJNE_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6741
6750
|
);
|
|
6742
6751
|
}
|
|
6743
6752
|
this.reconnectPromise ??= this.reconnect().finally(() => {
|
|
@@ -6758,13 +6767,13 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6758
6767
|
lastErr = err;
|
|
6759
6768
|
}
|
|
6760
6769
|
}
|
|
6761
|
-
throw new
|
|
6770
|
+
throw new chunk4ZHTIJNE_cjs.NetworkError(`MCP ${this.name} reconnect exhausted`, {
|
|
6762
6771
|
code: "mcp_disconnected",
|
|
6763
6772
|
...lastErr instanceof Error ? { cause: lastErr } : {}
|
|
6764
6773
|
});
|
|
6765
6774
|
}
|
|
6766
6775
|
async close() {
|
|
6767
|
-
this.rejectAllPending(new
|
|
6776
|
+
this.rejectAllPending(new chunk4ZHTIJNE_cjs.NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
|
|
6768
6777
|
const child = this.child;
|
|
6769
6778
|
this.child = void 0;
|
|
6770
6779
|
this.dropped = false;
|
|
@@ -6783,7 +6792,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6783
6792
|
if (this.buffer.length > MAX_STDIO_BUFFER_BYTES) {
|
|
6784
6793
|
this.buffer = "";
|
|
6785
6794
|
this.rejectAllPending(
|
|
6786
|
-
new
|
|
6795
|
+
new chunk4ZHTIJNE_cjs.NetworkError(`MCP ${this.name} exceeded stdout buffer limit`, {
|
|
6787
6796
|
code: "mcp_buffer_overflow"
|
|
6788
6797
|
})
|
|
6789
6798
|
);
|
|
@@ -6818,7 +6827,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6818
6827
|
if (child !== void 0) return this.send(child, method, params);
|
|
6819
6828
|
if (this.dropped) return this.reconnectAndRequest(method, params);
|
|
6820
6829
|
return Promise.reject(
|
|
6821
|
-
new
|
|
6830
|
+
new chunk4ZHTIJNE_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6822
6831
|
);
|
|
6823
6832
|
}
|
|
6824
6833
|
/** M2 #59 — reconnect a dropped client, then send. Separate async path so the
|
|
@@ -6827,7 +6836,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6827
6836
|
await this.ensureConnected();
|
|
6828
6837
|
const child = this.child;
|
|
6829
6838
|
if (child === void 0) {
|
|
6830
|
-
throw new
|
|
6839
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" });
|
|
6831
6840
|
}
|
|
6832
6841
|
return this.send(child, method, params);
|
|
6833
6842
|
}
|
|
@@ -6844,7 +6853,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6844
6853
|
this.child = void 0;
|
|
6845
6854
|
this.dropped = true;
|
|
6846
6855
|
this.rejectAllPending(
|
|
6847
|
-
new
|
|
6856
|
+
new chunk4ZHTIJNE_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6848
6857
|
);
|
|
6849
6858
|
}, this.timeoutMs);
|
|
6850
6859
|
this.pending.set(id, { resolve, reject, timer });
|
|
@@ -6916,7 +6925,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6916
6925
|
if (payload === "") continue;
|
|
6917
6926
|
return JSON.parse(payload);
|
|
6918
6927
|
}
|
|
6919
|
-
throw new
|
|
6928
|
+
throw new chunk4ZHTIJNE_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
|
|
6920
6929
|
code: "mcp_http_error"
|
|
6921
6930
|
});
|
|
6922
6931
|
}
|
|
@@ -6950,7 +6959,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6950
6959
|
throw cause;
|
|
6951
6960
|
}
|
|
6952
6961
|
if (!response.ok) {
|
|
6953
|
-
throw new
|
|
6962
|
+
throw new chunk4ZHTIJNE_cjs.NetworkError(`MCP ${this.name} returned ${response.status}`, {
|
|
6954
6963
|
code: "mcp_http_error"
|
|
6955
6964
|
});
|
|
6956
6965
|
}
|
|
@@ -6966,14 +6975,14 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6966
6975
|
function resolveMcpCwd(configCwd) {
|
|
6967
6976
|
if (configCwd === void 0) return process.cwd();
|
|
6968
6977
|
if (path.isAbsolute(configCwd)) return configCwd;
|
|
6969
|
-
return
|
|
6978
|
+
return chunkV2BOS4WF_cjs.safePathJoin(process.cwd(), configCwd);
|
|
6970
6979
|
}
|
|
6971
6980
|
|
|
6972
6981
|
// src/internal/providers/register-plugin-providers.ts
|
|
6973
6982
|
function registerPluginProviderProfiles(entries) {
|
|
6974
6983
|
let registered2 = 0;
|
|
6975
6984
|
for (const entry of entries) {
|
|
6976
|
-
|
|
6985
|
+
chunkHCZD23VS_cjs.registerProvider(entry.profile);
|
|
6977
6986
|
registered2 += 1;
|
|
6978
6987
|
}
|
|
6979
6988
|
return registered2;
|
|
@@ -7053,7 +7062,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
|
|
|
7053
7062
|
if (exposedSet.has(name)) continue;
|
|
7054
7063
|
const hint = suggestClosest(name, exposedSet);
|
|
7055
7064
|
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)`;
|
|
7056
|
-
|
|
7065
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
7057
7066
|
`personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
|
|
7058
7067
|
message
|
|
7059
7068
|
);
|
|
@@ -7168,26 +7177,26 @@ function createRealLocalRun(options) {
|
|
|
7168
7177
|
}
|
|
7169
7178
|
var pluginProvidersAnnounced = false;
|
|
7170
7179
|
function resolveRunProvider(options) {
|
|
7171
|
-
|
|
7180
|
+
chunkHCZD23VS_cjs.registerBuiltins();
|
|
7172
7181
|
const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
|
|
7173
7182
|
const registered2 = registerPluginProviderProfiles(profiles);
|
|
7174
7183
|
if (registered2 > 0 && !pluginProvidersAnnounced) {
|
|
7175
7184
|
pluginProvidersAnnounced = true;
|
|
7176
7185
|
const names = profiles.map((e) => e.profile.name).join(", ");
|
|
7177
|
-
|
|
7186
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] registered ${registered2} plugin provider profile(s): ${names}
|
|
7178
7187
|
`);
|
|
7179
7188
|
}
|
|
7180
7189
|
const parsedModel = chunk3EE6LVWT_cjs.parseModelId(options.model?.id);
|
|
7181
|
-
const modelInferredProvider = parsedModel.provider !== void 0 &&
|
|
7182
|
-
const keyInferredProvider =
|
|
7183
|
-
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ??
|
|
7184
|
-
|
|
7190
|
+
const modelInferredProvider = parsedModel.provider !== void 0 && chunkHCZD23VS_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
|
|
7191
|
+
const keyInferredProvider = chunkKYAJINUI_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
|
|
7192
|
+
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkKYAJINUI_cjs.detectPrimaryProvider();
|
|
7193
|
+
chunkKYAJINUI_cjs.warnProviderPrecedenceOnce(modelInferredProvider, primary);
|
|
7185
7194
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7186
7195
|
return { primary, effectiveModelId };
|
|
7187
7196
|
}
|
|
7188
7197
|
function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
7189
7198
|
if (apiKey === void 0 || apiKey.length === 0) return pools;
|
|
7190
|
-
if (
|
|
7199
|
+
if (chunkKYAJINUI_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
|
|
7191
7200
|
const existing = pools?.[primary];
|
|
7192
7201
|
if (existing !== void 0 && existing.length > 0) return pools;
|
|
7193
7202
|
return { ...pools ?? {}, [primary]: [apiKey] };
|
|
@@ -7195,7 +7204,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
|
7195
7204
|
function buildLoopInputs(options, runId, userText, userImages) {
|
|
7196
7205
|
const maxIterations = options.sendOptions.maxIterations;
|
|
7197
7206
|
if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
|
|
7198
|
-
throw new
|
|
7207
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
7199
7208
|
`SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
|
|
7200
7209
|
{ code: "invalid_max_iterations" }
|
|
7201
7210
|
);
|
|
@@ -7211,7 +7220,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7211
7220
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7212
7221
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7213
7222
|
const modelBaseUrl = options.model?.url;
|
|
7214
|
-
const chain =
|
|
7223
|
+
const chain = chunkKYAJINUI_cjs.resolveProviderChain({
|
|
7215
7224
|
primary,
|
|
7216
7225
|
...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
|
|
7217
7226
|
...fallback !== void 0 ? { fallback } : {},
|
|
@@ -7219,7 +7228,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7219
7228
|
...credentialPoolStrategy !== void 0 ? { credentialPoolStrategy } : {},
|
|
7220
7229
|
...extractToolCallsFromContent === true ? { extractToolCallsFromContent: true } : {},
|
|
7221
7230
|
...rateLimitSink !== void 0 ? {
|
|
7222
|
-
onRateLimit: (info) =>
|
|
7231
|
+
onRateLimit: (info) => chunk3FFAEAUJ_cjs.emitRunEvent(rateLimitSink, { type: "rate_limit", ...info })
|
|
7223
7232
|
} : {}
|
|
7224
7233
|
});
|
|
7225
7234
|
const llm = chain.length === 1 ? chain[0] : new FallbackLlmClient(chain);
|
|
@@ -7494,7 +7503,7 @@ function buildRealRunOptions(args) {
|
|
|
7494
7503
|
};
|
|
7495
7504
|
}
|
|
7496
7505
|
async function createFixtureRunHelper(args) {
|
|
7497
|
-
const sessionMessages =
|
|
7506
|
+
const sessionMessages = chunkRMWTPV3M_cjs.getSessionMessages(args.inputs.agentId);
|
|
7498
7507
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7499
7508
|
return createLocalRun({
|
|
7500
7509
|
agentId: args.inputs.agentId,
|
|
@@ -7512,8 +7521,8 @@ async function createFixtureRunHelper(args) {
|
|
|
7512
7521
|
});
|
|
7513
7522
|
}
|
|
7514
7523
|
async function dispatchLocalRun(args) {
|
|
7515
|
-
const apiKey =
|
|
7516
|
-
if (
|
|
7524
|
+
const apiKey = chunkXL7Q7HB2_cjs.resolveApiKey(args.inputs.options.apiKey);
|
|
7525
|
+
if (chunkKYAJINUI_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7517
7526
|
return createRealLocalRun(
|
|
7518
7527
|
buildRealRunOptions({
|
|
7519
7528
|
inputs: args.inputs,
|
|
@@ -7548,20 +7557,20 @@ async function readProjectMcpServers(cwd) {
|
|
|
7548
7557
|
|
|
7549
7558
|
// src/internal/local-agent/local-agent-invalidate.ts
|
|
7550
7559
|
async function applyDeferredInvalidation(agentId, pending, refresh) {
|
|
7551
|
-
|
|
7560
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] applying deferred cache invalidation (${agentId}): ${pending.reason}
|
|
7552
7561
|
`);
|
|
7553
7562
|
try {
|
|
7554
7563
|
await refresh();
|
|
7555
7564
|
} catch (err) {
|
|
7556
7565
|
const msg = err instanceof Error ? err.message : String(err);
|
|
7557
|
-
|
|
7566
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] invalidateCache reload failed (continuing): ${msg}
|
|
7558
7567
|
`);
|
|
7559
7568
|
}
|
|
7560
7569
|
}
|
|
7561
7570
|
async function invalidateCacheImpl(agentId, reason, options, disposed, dispose, setPending) {
|
|
7562
7571
|
if (disposed) return;
|
|
7563
7572
|
if (options.applyNow === true) {
|
|
7564
|
-
|
|
7573
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] invalidateCache applyNow disposing agent (${agentId}): ${reason}
|
|
7565
7574
|
`);
|
|
7566
7575
|
await dispose();
|
|
7567
7576
|
return;
|
|
@@ -7622,7 +7631,7 @@ var LiveAgentRegistry = class {
|
|
|
7622
7631
|
const existing = this.#agents.get(id);
|
|
7623
7632
|
if (existing !== void 0 && existing.agent !== agent) {
|
|
7624
7633
|
void existing.agent.dispose().catch(() => {
|
|
7625
|
-
|
|
7634
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] dispose during overwrite failed (${id})
|
|
7626
7635
|
`);
|
|
7627
7636
|
});
|
|
7628
7637
|
}
|
|
@@ -7726,7 +7735,7 @@ var LiveAgentRegistry = class {
|
|
|
7726
7735
|
await agent.dispose();
|
|
7727
7736
|
} catch (cause) {
|
|
7728
7737
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7729
|
-
|
|
7738
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] dispose during eviction failed (${id}): ${msg}
|
|
7730
7739
|
`);
|
|
7731
7740
|
}
|
|
7732
7741
|
if (this.#onEvict !== void 0) {
|
|
@@ -7734,7 +7743,7 @@ var LiveAgentRegistry = class {
|
|
|
7734
7743
|
this.#onEvict(id, reason);
|
|
7735
7744
|
} catch (cause) {
|
|
7736
7745
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7737
|
-
|
|
7746
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] onEvict listener threw (${id}): ${msg}
|
|
7738
7747
|
`);
|
|
7739
7748
|
}
|
|
7740
7749
|
}
|
|
@@ -7750,7 +7759,7 @@ async function acquireLeaseIfPossible(store, agentId) {
|
|
|
7750
7759
|
await a.call(store, agentId);
|
|
7751
7760
|
} catch (err) {
|
|
7752
7761
|
if (err instanceof Error && err.name === "SessionBusyError") throw err;
|
|
7753
|
-
|
|
7762
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
7754
7763
|
`[theokit-sdk] writer lease unavailable for ${agentId} (${err instanceof Error ? err.message : String(err)}) \u2014 proceeding without single-writer protection
|
|
7755
7764
|
`
|
|
7756
7765
|
);
|
|
@@ -7769,32 +7778,21 @@ async function disposeLocalAgentSession(agent) {
|
|
|
7769
7778
|
agent.lifecycleAbortController.abort();
|
|
7770
7779
|
await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
7771
7780
|
disposeSessionMcpClients(agent.agentId);
|
|
7772
|
-
await
|
|
7781
|
+
await chunkRMWTPV3M_cjs.flushSessionWrites();
|
|
7773
7782
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
7774
7783
|
await disposeSessionStore(agent.sessionStore);
|
|
7775
|
-
|
|
7784
|
+
chunkRMWTPV3M_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
7776
7785
|
}
|
|
7777
7786
|
async function reloadLocalAgent(agent) {
|
|
7778
7787
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
7779
7788
|
if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
|
|
7780
7789
|
if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
|
|
7781
|
-
return await
|
|
7790
|
+
return await chunkCQBXOJ6U_cjs.loadSubagents(
|
|
7782
7791
|
agent.workspaceCwd,
|
|
7783
7792
|
agent.settingSourcesIncludeProject,
|
|
7784
7793
|
agent.options.agents
|
|
7785
7794
|
);
|
|
7786
7795
|
}
|
|
7787
|
-
async function persistActiveMemoryTranscript(cwd, transcript) {
|
|
7788
|
-
try {
|
|
7789
|
-
const dir = path.join(chunk2UCFUSPW_cjs.memoryDir(cwd), "transcripts", "active-memory");
|
|
7790
|
-
const file = path.join(dir, `${transcript.runId}.json`);
|
|
7791
|
-
await chunkI6TGFUCO_cjs.atomicWriteJson(file, transcript);
|
|
7792
|
-
} catch (cause) {
|
|
7793
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7794
|
-
chunkNUKRL3I6_cjs.diag(`[theokit-sdk] active-memory transcript persist failed: ${message}
|
|
7795
|
-
`);
|
|
7796
|
-
}
|
|
7797
|
-
}
|
|
7798
7796
|
|
|
7799
7797
|
// src/internal/memory/active-memory.ts
|
|
7800
7798
|
var DEFAULTS = {
|
|
@@ -7912,7 +7910,7 @@ async function searchOnce(args, cfg, query, started) {
|
|
|
7912
7910
|
return { summary, durationMs: Date.now() - started, status: "ok", hits };
|
|
7913
7911
|
} catch (cause) {
|
|
7914
7912
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7915
|
-
|
|
7913
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] active-memory recall failed: ${message}
|
|
7916
7914
|
`);
|
|
7917
7915
|
return { summary: void 0, durationMs: Date.now() - started, status: "error", hits: [] };
|
|
7918
7916
|
}
|
|
@@ -7930,7 +7928,7 @@ async function finalize(args, queryMode, result) {
|
|
|
7930
7928
|
};
|
|
7931
7929
|
args.cache?.set(args.userText, queryMode, result, tenantCtx);
|
|
7932
7930
|
if (args.persistTranscripts === true && args.cwd !== void 0) {
|
|
7933
|
-
await persistActiveMemoryTranscript(args.cwd, {
|
|
7931
|
+
await chunkGKEFRLU7_cjs.persistActiveMemoryTranscript(args.memoryRoot ?? chunk6RKUO7AW_cjs.resolveMemoryRoot(args.cwd), {
|
|
7934
7932
|
runId: args.runId ?? `run-${Date.now()}`,
|
|
7935
7933
|
startedAtMs: Date.now() - result.durationMs,
|
|
7936
7934
|
userText: args.userText,
|
|
@@ -8032,7 +8030,7 @@ var azureOpenAiMemoryEmbeddingProviderAdapter = {
|
|
|
8032
8030
|
transport: "remote",
|
|
8033
8031
|
authProviderId: "azure-openai",
|
|
8034
8032
|
autoSelectPriority: 25,
|
|
8035
|
-
create: (options) =>
|
|
8033
|
+
create: (options) => chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8036
8034
|
{
|
|
8037
8035
|
id: "azure-openai",
|
|
8038
8036
|
defaultBaseUrl: "https://your-resource.openai.azure.com",
|
|
@@ -8068,7 +8066,7 @@ var cohereMemoryEmbeddingProviderAdapter = {
|
|
|
8068
8066
|
transport: "remote",
|
|
8069
8067
|
authProviderId: "cohere",
|
|
8070
8068
|
autoSelectPriority: 30,
|
|
8071
|
-
create: (options) =>
|
|
8069
|
+
create: (options) => chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8072
8070
|
{
|
|
8073
8071
|
id: "cohere",
|
|
8074
8072
|
defaultBaseUrl: "https://api.cohere.com",
|
|
@@ -8114,7 +8112,7 @@ var deepinfraMemoryEmbeddingProviderAdapter = {
|
|
|
8114
8112
|
transport: "remote",
|
|
8115
8113
|
authProviderId: "deepinfra",
|
|
8116
8114
|
autoSelectPriority: 13,
|
|
8117
|
-
create: (options) =>
|
|
8115
|
+
create: (options) => chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8118
8116
|
{
|
|
8119
8117
|
id: "deepinfra",
|
|
8120
8118
|
defaultBaseUrl: "https://api.deepinfra.com",
|
|
@@ -8140,7 +8138,7 @@ var geminiMemoryEmbeddingProviderAdapter = {
|
|
|
8140
8138
|
transport: "remote",
|
|
8141
8139
|
authProviderId: "gemini",
|
|
8142
8140
|
autoSelectPriority: 30,
|
|
8143
|
-
create: (options) =>
|
|
8141
|
+
create: (options) => chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8144
8142
|
{
|
|
8145
8143
|
id: "gemini",
|
|
8146
8144
|
defaultBaseUrl: "https://generativelanguage.googleapis.com",
|
|
@@ -8168,7 +8166,7 @@ var jinaMemoryEmbeddingProviderAdapter = {
|
|
|
8168
8166
|
transport: "remote",
|
|
8169
8167
|
authProviderId: "jina",
|
|
8170
8168
|
autoSelectPriority: 35,
|
|
8171
|
-
create: (options) =>
|
|
8169
|
+
create: (options) => chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8172
8170
|
{
|
|
8173
8171
|
id: "jina",
|
|
8174
8172
|
defaultBaseUrl: "https://api.jina.ai",
|
|
@@ -8191,7 +8189,7 @@ var mistralMemoryEmbeddingProviderAdapter = {
|
|
|
8191
8189
|
transport: "remote",
|
|
8192
8190
|
authProviderId: "mistral",
|
|
8193
8191
|
autoSelectPriority: 18,
|
|
8194
|
-
create: (options) =>
|
|
8192
|
+
create: (options) => chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8195
8193
|
{
|
|
8196
8194
|
id: "mistral",
|
|
8197
8195
|
defaultBaseUrl: "https://api.mistral.ai",
|
|
@@ -8233,7 +8231,7 @@ var ollamaMemoryEmbeddingProviderAdapter = {
|
|
|
8233
8231
|
autoSelectPriority: 10,
|
|
8234
8232
|
create: (options) => {
|
|
8235
8233
|
const apiKey = options.apiKey ?? process.env.OLLAMA_API_KEY ?? OLLAMA_LOCAL_SENTINEL_KEY;
|
|
8236
|
-
return
|
|
8234
|
+
return chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8237
8235
|
{
|
|
8238
8236
|
id: "ollama",
|
|
8239
8237
|
defaultBaseUrl: "http://localhost:11434",
|
|
@@ -8260,7 +8258,7 @@ var openAiMemoryEmbeddingProviderAdapter = {
|
|
|
8260
8258
|
transport: "remote",
|
|
8261
8259
|
authProviderId: "openai",
|
|
8262
8260
|
autoSelectPriority: 20,
|
|
8263
|
-
create: (options) =>
|
|
8261
|
+
create: (options) => chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8264
8262
|
{
|
|
8265
8263
|
id: "openai",
|
|
8266
8264
|
defaultBaseUrl: "https://api.openai.com",
|
|
@@ -8287,7 +8285,7 @@ var openRouterMemoryEmbeddingProviderAdapter = {
|
|
|
8287
8285
|
transport: "remote",
|
|
8288
8286
|
authProviderId: "openrouter",
|
|
8289
8287
|
autoSelectPriority: 15,
|
|
8290
|
-
create: (options) =>
|
|
8288
|
+
create: (options) => chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8291
8289
|
{
|
|
8292
8290
|
id: "openrouter",
|
|
8293
8291
|
defaultBaseUrl: "https://openrouter.ai/api",
|
|
@@ -8315,7 +8313,7 @@ var voyageMemoryEmbeddingProviderAdapter = {
|
|
|
8315
8313
|
transport: "remote",
|
|
8316
8314
|
authProviderId: "voyage",
|
|
8317
8315
|
autoSelectPriority: 14,
|
|
8318
|
-
create: (options) =>
|
|
8316
|
+
create: (options) => chunkKQ7TS7WW_cjs.createOpenAiCompatibleRuntime(
|
|
8319
8317
|
{
|
|
8320
8318
|
id: "voyage",
|
|
8321
8319
|
defaultBaseUrl: "https://api.voyageai.com",
|
|
@@ -8416,7 +8414,7 @@ function createMemorySearchTool(opts) {
|
|
|
8416
8414
|
};
|
|
8417
8415
|
}
|
|
8418
8416
|
function createMemoryGetTool(opts) {
|
|
8419
|
-
const memoryRoot = path.resolve(
|
|
8417
|
+
const memoryRoot = path.resolve(opts.root);
|
|
8420
8418
|
return {
|
|
8421
8419
|
name: "memory_get",
|
|
8422
8420
|
description: GET_DESCRIPTION,
|
|
@@ -8427,7 +8425,7 @@ function createMemoryGetTool(opts) {
|
|
|
8427
8425
|
const lines = readNumber(input.lines);
|
|
8428
8426
|
const resolved = path.resolve(memoryRoot, relPath);
|
|
8429
8427
|
if (!isPathInside(memoryRoot, resolved)) {
|
|
8430
|
-
throw new
|
|
8428
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
8431
8429
|
`memory_get rejected path that escapes memory root: ${relPath}`,
|
|
8432
8430
|
{ code: "memory_path_escapes_root" }
|
|
8433
8431
|
);
|
|
@@ -8447,7 +8445,7 @@ function readString(value, errorIfMissing, allowUndefined = false) {
|
|
|
8447
8445
|
if (typeof value === "string") return value;
|
|
8448
8446
|
if (allowUndefined && (value === void 0 || value === null)) return "";
|
|
8449
8447
|
if (errorIfMissing !== void 0) {
|
|
8450
|
-
throw new
|
|
8448
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(errorIfMissing, { code: "memory_tool_bad_args" });
|
|
8451
8449
|
}
|
|
8452
8450
|
return "";
|
|
8453
8451
|
}
|
|
@@ -8498,6 +8496,7 @@ var LocalAgentMemory = class {
|
|
|
8498
8496
|
toolsCache;
|
|
8499
8497
|
breaker;
|
|
8500
8498
|
cache;
|
|
8499
|
+
memoryRootCache;
|
|
8501
8500
|
/**
|
|
8502
8501
|
* Sync view of the tool cache (SDK 2.0 Phase 1 Stage 2b — iter 19+).
|
|
8503
8502
|
* Returns the cached MemoryToolSpec[] when `ensureTools()` has run
|
|
@@ -8519,14 +8518,15 @@ var LocalAgentMemory = class {
|
|
|
8519
8518
|
if (this.toolsCache !== void 0) return this.toolsCache;
|
|
8520
8519
|
try {
|
|
8521
8520
|
const embedding = await this.maybeCreateEmbeddingRuntime();
|
|
8522
|
-
const
|
|
8521
|
+
const memoryRoot = this.memoryRoot();
|
|
8522
|
+
const openOpts = { cwd: this.workspaceCwd, memoryRoot };
|
|
8523
8523
|
if (embedding !== void 0) openOpts.embedding = embedding;
|
|
8524
8524
|
if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
|
|
8525
|
-
this.index = await
|
|
8525
|
+
this.index = await chunkITYQ6VBP_cjs.IndexManager.open(openOpts);
|
|
8526
8526
|
await this.index.sync();
|
|
8527
8527
|
this.toolsCache = [
|
|
8528
8528
|
createMemorySearchTool({ index: this.index }),
|
|
8529
|
-
createMemoryGetTool({
|
|
8529
|
+
createMemoryGetTool({ root: memoryRoot })
|
|
8530
8530
|
];
|
|
8531
8531
|
return this.toolsCache;
|
|
8532
8532
|
} catch (cause) {
|
|
@@ -8537,7 +8537,7 @@ var LocalAgentMemory = class {
|
|
|
8537
8537
|
const warned2 = g[sym];
|
|
8538
8538
|
if (!warned2.has(message)) {
|
|
8539
8539
|
warned2.add(message);
|
|
8540
|
-
|
|
8540
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] memory tools unavailable: ${message}
|
|
8541
8541
|
`);
|
|
8542
8542
|
}
|
|
8543
8543
|
return void 0;
|
|
@@ -8546,7 +8546,7 @@ var LocalAgentMemory = class {
|
|
|
8546
8546
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8547
8547
|
const cfg = this.options.memory?.activeRecall;
|
|
8548
8548
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8549
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8549
|
+
if (this.breaker === void 0) this.breaker = new chunkKYAJINUI_cjs.CircuitBreaker();
|
|
8550
8550
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8551
8551
|
const result = await runActiveMemory({
|
|
8552
8552
|
userText,
|
|
@@ -8557,12 +8557,21 @@ var LocalAgentMemory = class {
|
|
|
8557
8557
|
cache: this.cache,
|
|
8558
8558
|
agentKey: this.agentId,
|
|
8559
8559
|
cwd: this.workspaceCwd,
|
|
8560
|
+
memoryRoot: this.memoryRoot(),
|
|
8560
8561
|
...cfg.persistTranscripts === true ? { persistTranscripts: true } : {},
|
|
8561
8562
|
runId: `${this.agentId}-${Date.now()}`,
|
|
8562
8563
|
...this.buildTelemetryRecallArgs(telemetry)
|
|
8563
8564
|
});
|
|
8564
8565
|
return result.summary;
|
|
8565
8566
|
}
|
|
8567
|
+
/**
|
|
8568
|
+
* Where this agent's memory lives — resolved once and shared by the index, the `memory_get` tool
|
|
8569
|
+
* and the active-memory transcript writer. Three separate resolutions is how they drifted (#463).
|
|
8570
|
+
*/
|
|
8571
|
+
memoryRoot() {
|
|
8572
|
+
this.memoryRootCache ??= chunk6RKUO7AW_cjs.resolveMemoryRoot(this.workspaceCwd, this.options.memory);
|
|
8573
|
+
return this.memoryRootCache;
|
|
8574
|
+
}
|
|
8566
8575
|
buildActiveMemoryOptions(cfg) {
|
|
8567
8576
|
if (cfg === void 0) return { enabled: true };
|
|
8568
8577
|
return {
|
|
@@ -8596,7 +8605,7 @@ var LocalAgentMemory = class {
|
|
|
8596
8605
|
await this.index.sync();
|
|
8597
8606
|
} catch (cause) {
|
|
8598
8607
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8599
|
-
|
|
8608
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] session index sync failed: ${message}
|
|
8600
8609
|
`);
|
|
8601
8610
|
}
|
|
8602
8611
|
}
|
|
@@ -8609,7 +8618,7 @@ var LocalAgentMemory = class {
|
|
|
8609
8618
|
return await adapter.create(cfg.model !== void 0 ? { model: cfg.model } : {});
|
|
8610
8619
|
} catch (cause) {
|
|
8611
8620
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8612
|
-
|
|
8621
|
+
chunkEG4QM7ZJ_cjs.diag(`[theokit-sdk] memory embedding ${cfg.provider} unavailable: ${message}
|
|
8613
8622
|
`);
|
|
8614
8623
|
return void 0;
|
|
8615
8624
|
}
|
|
@@ -8622,7 +8631,7 @@ async function createAvailableAdapters(entries, workspaceCwd) {
|
|
|
8622
8631
|
for (const entry of entries) {
|
|
8623
8632
|
const instance = await entry.createProvider(workspaceCwd);
|
|
8624
8633
|
if (instance.isAvailable() === false) {
|
|
8625
|
-
|
|
8634
|
+
chunkEG4QM7ZJ_cjs.diag(
|
|
8626
8635
|
`[theokit-sdk] memory adapter "${instance.id}" reports itself unavailable (plugin "${entry.pluginName}") \u2014 skipping it. Check its credentials.
|
|
8627
8636
|
`
|
|
8628
8637
|
);
|
|
@@ -8656,7 +8665,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8656
8665
|
...partial?.metadata !== void 0 ? { metadata: partial.metadata } : defaultContext?.metadata !== void 0 ? { metadata: defaultContext.metadata } : {}
|
|
8657
8666
|
};
|
|
8658
8667
|
if (merged.userId === "") {
|
|
8659
|
-
throw new
|
|
8668
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
8660
8669
|
"agent.memory requires a userId \u2014 either set AgentOptions.memoryContext.userId or pass ctx.userId at call time.",
|
|
8661
8670
|
{ code: "memory_context_missing_user_id" }
|
|
8662
8671
|
);
|
|
@@ -8666,7 +8675,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8666
8675
|
async function requireAdapters() {
|
|
8667
8676
|
const r = await ensure();
|
|
8668
8677
|
if (r.adapters.length === 0) {
|
|
8669
|
-
throw new
|
|
8678
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
8670
8679
|
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.`,
|
|
8671
8680
|
{ code: "no_memory_adapter" }
|
|
8672
8681
|
);
|
|
@@ -8707,7 +8716,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8707
8716
|
const prefix = id.split(":", 1)[0] ?? "";
|
|
8708
8717
|
const target = adapters.find((a) => a.id === prefix);
|
|
8709
8718
|
if (target === void 0) {
|
|
8710
|
-
throw new
|
|
8719
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
8711
8720
|
`No adapter found for MemoryId prefix "${prefix}" (registered: ${adapters.map((a) => a.id).join(", ")}).`,
|
|
8712
8721
|
{ code: "no_memory_adapter" }
|
|
8713
8722
|
);
|
|
@@ -8780,7 +8789,7 @@ function createLocalAgentMemoryProvider(opts) {
|
|
|
8780
8789
|
return { facts: [], systemPromptAdditions: summary };
|
|
8781
8790
|
},
|
|
8782
8791
|
async recordSessionSummary(args) {
|
|
8783
|
-
await
|
|
8792
|
+
await chunk6RKUO7AW_cjs.writeSessionSummary(args);
|
|
8784
8793
|
},
|
|
8785
8794
|
async sync(handle) {
|
|
8786
8795
|
const state = handle[INTERNAL_LAM_KEY];
|
|
@@ -8858,19 +8867,19 @@ var PersonalityRegistry = class _PersonalityRegistry {
|
|
|
8858
8867
|
function addEntity(byName, entity, origin, collisionMap) {
|
|
8859
8868
|
const fm = entity.frontmatter;
|
|
8860
8869
|
if (PersonalityRegistry.isReservedClearSlug(fm.name)) {
|
|
8861
|
-
throw new
|
|
8870
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
8862
8871
|
`Personality name "${fm.name}" is reserved (used to clear active preset)`,
|
|
8863
8872
|
{ code: "personality_reserved_name" }
|
|
8864
8873
|
);
|
|
8865
8874
|
}
|
|
8866
8875
|
if (entity.body.trim().length === 0) {
|
|
8867
|
-
throw new
|
|
8876
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
8868
8877
|
`Personality "${fm.name}" has empty body (system prompt required)`,
|
|
8869
8878
|
{ code: "personality_empty_body" }
|
|
8870
8879
|
);
|
|
8871
8880
|
}
|
|
8872
8881
|
if (origin === "project" && collisionMap?.has(fm.name)) {
|
|
8873
|
-
|
|
8882
|
+
chunkZCIRZE37_cjs.warnOnce(
|
|
8874
8883
|
`personality-collision-${fm.name}`,
|
|
8875
8884
|
`[theokit-sdk] personality "${fm.name}" overridden by project preset`
|
|
8876
8885
|
);
|
|
@@ -8899,7 +8908,7 @@ async function performPersonalitySwitch(args) {
|
|
|
8899
8908
|
const preset = args.registry.get(args.requestedName);
|
|
8900
8909
|
if (preset === void 0) {
|
|
8901
8910
|
const available = args.registry.all().map((p) => p.name).join(", ") || "(none)";
|
|
8902
|
-
throw new
|
|
8911
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
8903
8912
|
`Personality "${args.requestedName}" not found. Available: ${available}`,
|
|
8904
8913
|
{ code: "personality_not_found" }
|
|
8905
8914
|
);
|
|
@@ -8920,14 +8929,14 @@ async function performPersonalitySwitch(args) {
|
|
|
8920
8929
|
|
|
8921
8930
|
// src/internal/local-agent/local-agent-personality-extensions.ts
|
|
8922
8931
|
function resolveActivePersonalityPreset(args) {
|
|
8923
|
-
const forkCtx =
|
|
8932
|
+
const forkCtx = chunkZCIRZE37_cjs.currentPersonalityContext();
|
|
8924
8933
|
const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
|
|
8925
8934
|
if (slug === void 0) return void 0;
|
|
8926
8935
|
return args.personalityRegistry?.get(slug);
|
|
8927
8936
|
}
|
|
8928
8937
|
async function ensurePersonalityRegistryIfNeeded(args) {
|
|
8929
8938
|
if (args.personalityRegistry !== void 0) return args.personalityRegistry;
|
|
8930
|
-
const forkSlug =
|
|
8939
|
+
const forkSlug = chunkZCIRZE37_cjs.currentPersonalityContext()?.slug;
|
|
8931
8940
|
const ownSlug = args.personalityStore.active(args.agentId);
|
|
8932
8941
|
if (forkSlug === void 0 && ownSlug === void 0) return void 0;
|
|
8933
8942
|
return await PersonalityRegistry.load(args.workspaceCwd);
|
|
@@ -8941,8 +8950,8 @@ ${preset.systemPrompt}`;
|
|
|
8941
8950
|
}
|
|
8942
8951
|
async function localAgentUsePersonality(args) {
|
|
8943
8952
|
if (args.disposed) throw new Error("Agent has been disposed");
|
|
8944
|
-
if (
|
|
8945
|
-
|
|
8953
|
+
if (chunkZCIRZE37_cjs.currentPersonalityContext() !== void 0) {
|
|
8954
|
+
chunkZCIRZE37_cjs.warnPersonalitySwitchInsideFork(args.agentId);
|
|
8946
8955
|
return null;
|
|
8947
8956
|
}
|
|
8948
8957
|
let registry = args.personalityRegistry;
|
|
@@ -8959,8 +8968,8 @@ async function localAgentUsePersonality(args) {
|
|
|
8959
8968
|
registry,
|
|
8960
8969
|
store: args.personalityStore,
|
|
8961
8970
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
8962
|
-
appendSessionMessage: (msg) =>
|
|
8963
|
-
clearSession: () =>
|
|
8971
|
+
appendSessionMessage: (msg) => chunkRMWTPV3M_cjs.appendSessionMessage(args.agentId, msg),
|
|
8972
|
+
clearSession: () => chunkRMWTPV3M_cjs.clearSession(args.agentId),
|
|
8964
8973
|
opts: args.opts ?? {}
|
|
8965
8974
|
})
|
|
8966
8975
|
);
|
|
@@ -8971,7 +8980,7 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
8971
8980
|
async function* wrap() {
|
|
8972
8981
|
const { runUntilImpl } = await import('./run-until-U2B5FJJI.cjs');
|
|
8973
8982
|
const buildDeps = async () => {
|
|
8974
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
8983
|
+
const { judgeCallImpl } = await import('./judge-call-LAHMBJ57.cjs');
|
|
8975
8984
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
8976
8985
|
const create = getAgentFacade().create;
|
|
8977
8986
|
return {
|
|
@@ -9004,29 +9013,33 @@ async function* localAgentStreamToCompletion(agent, message, options) {
|
|
|
9004
9013
|
async function localAgentFork(parent, options) {
|
|
9005
9014
|
const { forkAgentImpl } = await import('./fork-agent-Y2IK2RYU.cjs');
|
|
9006
9015
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9007
|
-
const { withPersonalityContext } = await import('./context-
|
|
9016
|
+
const { withPersonalityContext } = await import('./context-AGQ3DIZU.cjs');
|
|
9008
9017
|
const create = getAgentFacade().create;
|
|
9009
9018
|
return withPersonalityContext(
|
|
9010
9019
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
9011
9020
|
() => forkAgentImpl(parent, options, { create })
|
|
9012
9021
|
);
|
|
9013
9022
|
}
|
|
9014
|
-
async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userText
|
|
9023
|
+
async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userText) {
|
|
9015
9024
|
if (memoryConfig?.enabled !== true) return;
|
|
9025
|
+
const unstored = unstoredRememberWarning(userText);
|
|
9026
|
+
if (unstored !== void 0) {
|
|
9027
|
+
chunkEG4QM7ZJ_cjs.diagFailure(unstored);
|
|
9028
|
+
return;
|
|
9029
|
+
}
|
|
9016
9030
|
if (!isMemoryWritePrompt(userText)) return;
|
|
9017
9031
|
const fact = extractMemoryFact(userText);
|
|
9018
9032
|
if (fact.length === 0) return;
|
|
9019
9033
|
const kind = extractMemoryKind(userText);
|
|
9020
|
-
|
|
9021
|
-
(
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
)
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
);
|
|
9034
|
+
try {
|
|
9035
|
+
await appendMemoryFact(workspaceCwd, memoryConfig, {
|
|
9036
|
+
text: fact,
|
|
9037
|
+
...kind === void 0 ? {} : { kind }
|
|
9038
|
+
});
|
|
9039
|
+
} catch (cause) {
|
|
9040
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
9041
|
+
chunkEG4QM7ZJ_cjs.diagFailure(`[theokit-sdk] memory write failed, nothing was stored: ${message}`);
|
|
9042
|
+
}
|
|
9030
9043
|
}
|
|
9031
9044
|
|
|
9032
9045
|
// src/internal/runtime/concurrency/abort-utils.ts
|
|
@@ -9070,7 +9083,7 @@ function wrapRunWithCompletionCheck(args) {
|
|
|
9070
9083
|
judgeOpts
|
|
9071
9084
|
);
|
|
9072
9085
|
const complete = !verdict.parseFailed && verdict.verdict === "done";
|
|
9073
|
-
|
|
9086
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(args.onRunEvent, {
|
|
9074
9087
|
type: "completion_check",
|
|
9075
9088
|
complete,
|
|
9076
9089
|
reason: verdict.reason
|
|
@@ -9387,7 +9400,7 @@ function wrapRunWithOutputProcessors(args) {
|
|
|
9387
9400
|
if (result.status !== "finished" || result.result === void 0) return result;
|
|
9388
9401
|
const res = await runOutputProcessors(args.processors, result.result, args.agentId);
|
|
9389
9402
|
if (res.kind === "ok") return { ...result, result: res.value };
|
|
9390
|
-
|
|
9403
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(args.onRunEvent, {
|
|
9391
9404
|
type: "tripwire",
|
|
9392
9405
|
reason: res.tripwire.reason,
|
|
9393
9406
|
processorId: res.tripwire.processorId
|
|
@@ -9477,7 +9490,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9477
9490
|
}
|
|
9478
9491
|
const res = await runInputProcessors(processors, rawUserText, inputs.agentId);
|
|
9479
9492
|
if (res.kind === "tripwire") {
|
|
9480
|
-
|
|
9493
|
+
chunk3FFAEAUJ_cjs.emitRunEvent(options.onRunEvent, {
|
|
9481
9494
|
type: "tripwire",
|
|
9482
9495
|
reason: res.tripwire.reason,
|
|
9483
9496
|
processorId: res.tripwire.processorId
|
|
@@ -9494,7 +9507,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9494
9507
|
return { userText: res.value, effectiveMessage };
|
|
9495
9508
|
}
|
|
9496
9509
|
async function executeSendLocked(inputs, message, options) {
|
|
9497
|
-
if (inputs.disposed) throw new
|
|
9510
|
+
if (inputs.disposed) throw new chunk4ZHTIJNE_cjs.AgentDisposedError(inputs.agentId);
|
|
9498
9511
|
await consumePending(inputs.agentId, inputs.invalidationPending, inputs.clearInvalidation, inputs.reload);
|
|
9499
9512
|
const sendModel = normalizeModel(options.model);
|
|
9500
9513
|
inputs.applyModelOverride(sendModel);
|
|
@@ -9505,7 +9518,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9505
9518
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9506
9519
|
await inputs.options.onBeforeSend({
|
|
9507
9520
|
conversationId: inputs.agentId,
|
|
9508
|
-
previousMessageCount:
|
|
9521
|
+
previousMessageCount: chunkRMWTPV3M_cjs.getSessionMessages(inputs.agentId).length
|
|
9509
9522
|
});
|
|
9510
9523
|
}
|
|
9511
9524
|
await inputs.runPreHook(userText);
|
|
@@ -9517,21 +9530,10 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9517
9530
|
userText,
|
|
9518
9531
|
sendOptions: options
|
|
9519
9532
|
});
|
|
9520
|
-
const priorMessages = [...
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
await
|
|
9524
|
-
inputs.workspaceCwd,
|
|
9525
|
-
inputs.options.memory,
|
|
9526
|
-
userText,
|
|
9527
|
-
memoryHome
|
|
9528
|
-
);
|
|
9529
|
-
const memoryFacts = await readMemoryForSend(
|
|
9530
|
-
inputs.workspaceCwd,
|
|
9531
|
-
inputs.options.memory,
|
|
9532
|
-
memoryHome,
|
|
9533
|
-
userText
|
|
9534
|
-
);
|
|
9533
|
+
const priorMessages = [...chunkRMWTPV3M_cjs.getSessionMessages(inputs.agentId)];
|
|
9534
|
+
chunkRMWTPV3M_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9535
|
+
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9536
|
+
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9535
9537
|
const portPathActive = shouldUsePortMemoryPath();
|
|
9536
9538
|
const legacyTools = portPathActive ? void 0 : await inputs.memoryGlue.ensureTools();
|
|
9537
9539
|
const legacySummary = portPathActive ? void 0 : await inputs.memoryGlue.runActiveMemoryIfEnabled(userText, priorMessages, inputs.telemetry);
|
|
@@ -9587,16 +9589,16 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9587
9589
|
function buildCompletionCheckDeps() {
|
|
9588
9590
|
return {
|
|
9589
9591
|
judge: async (ctx, opts) => {
|
|
9590
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9592
|
+
const { judgeCallImpl } = await import('./judge-call-LAHMBJ57.cjs');
|
|
9591
9593
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9592
9594
|
return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
|
|
9593
9595
|
}
|
|
9594
9596
|
};
|
|
9595
9597
|
}
|
|
9596
|
-
function readMemoryForSend(workspaceCwd, memoryConfig,
|
|
9598
|
+
function readMemoryForSend(workspaceCwd, memoryConfig, query) {
|
|
9597
9599
|
if (memoryConfig?.enabled !== true) return Promise.resolve([]);
|
|
9598
9600
|
return safeCall(
|
|
9599
|
-
async () => selectFactsForInjection(await readMemoryFacts(workspaceCwd, memoryConfig
|
|
9601
|
+
async () => selectFactsForInjection(await readMemoryFacts(workspaceCwd, memoryConfig), {
|
|
9600
9602
|
...query === void 0 ? {} : { query }
|
|
9601
9603
|
}),
|
|
9602
9604
|
[],
|
|
@@ -9613,7 +9615,7 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
|
|
|
9613
9615
|
promptPreview: userText.slice(0, 120),
|
|
9614
9616
|
...opts.meta ?? {}
|
|
9615
9617
|
};
|
|
9616
|
-
void
|
|
9618
|
+
void chunk3FFAEAUJ_cjs.submit({
|
|
9617
9619
|
kind: "run",
|
|
9618
9620
|
work: async (ctx) => {
|
|
9619
9621
|
ctx.signal.addEventListener(
|
|
@@ -9698,7 +9700,7 @@ var LocalAgent = class {
|
|
|
9698
9700
|
this.options = options;
|
|
9699
9701
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
9700
9702
|
this.transcriptBaseDir = resolveSessionDir(options.local);
|
|
9701
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
9703
|
+
this.sessionStore = options.local?.sessionStore ?? new chunkZLQSWSJ2_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
9702
9704
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
9703
9705
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
9704
9706
|
const sub = bootstrapSubmanagers({
|
|
@@ -9741,14 +9743,14 @@ var LocalAgent = class {
|
|
|
9741
9743
|
if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
|
|
9742
9744
|
const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
|
|
9743
9745
|
await this.pluginManagerCode.initialize(codePlugins);
|
|
9744
|
-
this.resolvedSubagents = await
|
|
9746
|
+
this.resolvedSubagents = await chunkCQBXOJ6U_cjs.loadSubagents(
|
|
9745
9747
|
this.workspaceCwd,
|
|
9746
9748
|
this.settingSourcesIncludeProject,
|
|
9747
9749
|
this.options.agents
|
|
9748
9750
|
);
|
|
9749
9751
|
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9750
9752
|
try {
|
|
9751
|
-
await
|
|
9753
|
+
await chunkRMWTPV3M_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9752
9754
|
await this.personalityStore.hydrate(this.agentId);
|
|
9753
9755
|
} catch (err) {
|
|
9754
9756
|
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
@@ -9899,7 +9901,7 @@ var LocalAgent = class {
|
|
|
9899
9901
|
agentId: this.agentId
|
|
9900
9902
|
});
|
|
9901
9903
|
if (preRun.blocked) {
|
|
9902
|
-
throw new
|
|
9904
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
9903
9905
|
`preRun hook denied execution: ${preRun.reason ?? "unspecified"}`,
|
|
9904
9906
|
{ code: "hook_denied" }
|
|
9905
9907
|
);
|
|
@@ -9980,7 +9982,7 @@ var LocalAgent = class {
|
|
|
9980
9982
|
}
|
|
9981
9983
|
// biome-ignore format: G8 budget — see listArtifacts.
|
|
9982
9984
|
downloadArtifact(_path) {
|
|
9983
|
-
return Promise.reject(new
|
|
9985
|
+
return Promise.reject(new chunk4ZHTIJNE_cjs.UnsupportedRunOperationError("Artifacts are not supported for local agents", "downloadArtifact"));
|
|
9984
9986
|
}
|
|
9985
9987
|
// biome-ignore format: G8 budget — delegates to `local-agent-runtime-extensions.ts`; kept 1-line.
|
|
9986
9988
|
runUntil(goal, options) {
|
|
@@ -10025,7 +10027,7 @@ async function guardAgainstIdCollision(options) {
|
|
|
10025
10027
|
const persistenceCwd = resolveAgentPersistenceCwd(options);
|
|
10026
10028
|
await hydrateRegistryFromDisk(persistenceCwd);
|
|
10027
10029
|
if (getRegisteredAgent(options.agentId) !== void 0) {
|
|
10028
|
-
throw new
|
|
10030
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
10029
10031
|
`Agent "${options.agentId}" already exists. Use Agent.resume("${options.agentId}") to reattach, or pick a different agentId.`,
|
|
10030
10032
|
{ code: "agent_id_already_exists" }
|
|
10031
10033
|
);
|
|
@@ -10058,7 +10060,7 @@ async function maybeInjectHandoffTools(options) {
|
|
|
10058
10060
|
const spec = "@theokit/sdk-handoff/internal/tool-injector";
|
|
10059
10061
|
mod = await import(spec);
|
|
10060
10062
|
} catch (err) {
|
|
10061
|
-
throw new
|
|
10063
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
10062
10064
|
"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).",
|
|
10063
10065
|
{ code: "handoff_package_missing", cause: err }
|
|
10064
10066
|
);
|
|
@@ -10076,31 +10078,31 @@ async function maybeInjectHandoffTools(options) {
|
|
|
10076
10078
|
};
|
|
10077
10079
|
}
|
|
10078
10080
|
function keyWillFlowToProvider(apiKey, provider) {
|
|
10079
|
-
if (
|
|
10080
|
-
if (
|
|
10081
|
+
if (chunkKYAJINUI_cjs.isFixtureApiKey(apiKey)) return false;
|
|
10082
|
+
if (chunkKYAJINUI_cjs.getConfiguredBaseUrl() !== void 0) return false;
|
|
10081
10083
|
if (provider === void 0) return false;
|
|
10082
|
-
const profile =
|
|
10084
|
+
const profile = chunkJPBKYL3B_cjs.getProviderProfile(provider);
|
|
10083
10085
|
if (profile === void 0) return false;
|
|
10084
10086
|
return profile.authType !== "none";
|
|
10085
10087
|
}
|
|
10086
10088
|
function missingApiKeyMessage() {
|
|
10087
|
-
const present =
|
|
10088
|
-
const base = `Missing API key \u2014 set ${
|
|
10089
|
+
const present = chunkKYAJINUI_cjs.presentProviderCredentialEnvVars();
|
|
10090
|
+
const base = `Missing API key \u2014 set ${chunkXL7Q7HB2_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
|
|
10089
10091
|
if (present.length === 0) return `${base}.`;
|
|
10090
10092
|
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]}, ... })\`.`;
|
|
10091
10093
|
}
|
|
10092
10094
|
function providerNeedsCallerKey(provider) {
|
|
10093
10095
|
if (provider === void 0) return true;
|
|
10094
|
-
const profile =
|
|
10096
|
+
const profile = chunkJPBKYL3B_cjs.getProviderProfile(provider);
|
|
10095
10097
|
if (profile === void 0) return true;
|
|
10096
10098
|
return profile.authType === "api_key";
|
|
10097
10099
|
}
|
|
10098
10100
|
async function createLocalAgent(options) {
|
|
10099
10101
|
const provider = providerFromModelId(normalizeModel(options.model)?.id);
|
|
10100
|
-
const apiKey =
|
|
10102
|
+
const apiKey = chunkXL7Q7HB2_cjs.resolveApiKey(options.apiKey);
|
|
10101
10103
|
if (apiKey === void 0) {
|
|
10102
10104
|
if (providerNeedsCallerKey(provider)) {
|
|
10103
|
-
throw new
|
|
10105
|
+
throw new chunk4ZHTIJNE_cjs.AuthenticationError(missingApiKeyMessage(), { code: "missing_api_key" });
|
|
10104
10106
|
}
|
|
10105
10107
|
} else {
|
|
10106
10108
|
const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
|
|
@@ -10109,7 +10111,7 @@ async function createLocalAgent(options) {
|
|
|
10109
10111
|
...willFlowToProvider ? { provider } : {}
|
|
10110
10112
|
});
|
|
10111
10113
|
if (shape.malformed) {
|
|
10112
|
-
throw new
|
|
10114
|
+
throw new chunk4ZHTIJNE_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10113
10115
|
}
|
|
10114
10116
|
}
|
|
10115
10117
|
const agent = new LocalAgent(options);
|
|
@@ -10117,21 +10119,21 @@ async function createLocalAgent(options) {
|
|
|
10117
10119
|
return agent;
|
|
10118
10120
|
}
|
|
10119
10121
|
async function createCloudAgent(options) {
|
|
10120
|
-
const apiKey =
|
|
10122
|
+
const apiKey = chunkXL7Q7HB2_cjs.resolveApiKey(options.apiKey);
|
|
10121
10123
|
if (apiKey === void 0) {
|
|
10122
|
-
throw new
|
|
10124
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError("Missing API key for cloud agent", {
|
|
10123
10125
|
code: "missing_api_key"
|
|
10124
10126
|
});
|
|
10125
10127
|
}
|
|
10126
10128
|
const shape = validateApiKeyShape(apiKey);
|
|
10127
10129
|
if (shape.malformed) {
|
|
10128
|
-
throw new
|
|
10130
|
+
throw new chunk4ZHTIJNE_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10129
10131
|
}
|
|
10130
|
-
const baseUrl =
|
|
10132
|
+
const baseUrl = chunkKYAJINUI_cjs.getConfiguredBaseUrl();
|
|
10131
10133
|
if (baseUrl === void 0) {
|
|
10132
10134
|
return new CloudAgent(options);
|
|
10133
10135
|
}
|
|
10134
|
-
const response = await
|
|
10136
|
+
const response = await chunkKYAJINUI_cjs.httpRequest("/v1/agents", {
|
|
10135
10137
|
apiKey,
|
|
10136
10138
|
method: "POST",
|
|
10137
10139
|
body: {
|
|
@@ -10156,7 +10158,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
10156
10158
|
return process.cwd();
|
|
10157
10159
|
}
|
|
10158
10160
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
10159
|
-
await
|
|
10161
|
+
await chunkKYAJINUI_cjs.discoverProviderPlugins();
|
|
10160
10162
|
await validateRehydratedAgent(agentId, existing);
|
|
10161
10163
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
10162
10164
|
const mergedOptions = {
|
|
@@ -10187,7 +10189,7 @@ async function validateRehydratedAgent(agentId, entry) {
|
|
|
10187
10189
|
throw new Error(`Workspace path is not a directory: ${candidate}`);
|
|
10188
10190
|
}
|
|
10189
10191
|
} catch (cause) {
|
|
10190
|
-
throw new
|
|
10192
|
+
throw new chunk4ZHTIJNE_cjs.UnknownAgentError(
|
|
10191
10193
|
`Agent "${agentId}" cannot be rehydrated \u2014 workspace cwd "${candidate}" is missing or inaccessible.`,
|
|
10192
10194
|
{ code: "agent_rehydration_failed", cause }
|
|
10193
10195
|
);
|
|
@@ -10239,7 +10241,7 @@ async function getRegisteredAgentOrThrow(agentId, cwd = process.cwd()) {
|
|
|
10239
10241
|
agent = getRegisteredAgent(agentId);
|
|
10240
10242
|
}
|
|
10241
10243
|
if (agent === void 0) {
|
|
10242
|
-
throw new
|
|
10244
|
+
throw new chunk4ZHTIJNE_cjs.UnknownAgentError(`Agent ${agentId} not found`, { code: "unknown_agent" });
|
|
10243
10245
|
}
|
|
10244
10246
|
return agent;
|
|
10245
10247
|
}
|
|
@@ -10300,7 +10302,7 @@ var Agent = class _Agent {
|
|
|
10300
10302
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
10301
10303
|
});
|
|
10302
10304
|
try {
|
|
10303
|
-
await
|
|
10305
|
+
await chunkKYAJINUI_cjs.discoverProviderPlugins();
|
|
10304
10306
|
const agent = await runCreateUnderSpan(options, span);
|
|
10305
10307
|
return agent;
|
|
10306
10308
|
} catch (err) {
|
|
@@ -10341,8 +10343,8 @@ var Agent = class _Agent {
|
|
|
10341
10343
|
const run = await agent.send(message);
|
|
10342
10344
|
const result = await run.wait();
|
|
10343
10345
|
if (options.throwOnError === true && result.status === "error" && result.error !== void 0) {
|
|
10344
|
-
throw new
|
|
10345
|
-
code:
|
|
10346
|
+
throw new chunk4ZHTIJNE_cjs.AgentRunError(result.error.message, {
|
|
10347
|
+
code: chunk4ZHTIJNE_cjs.coerceToKnownAgentRunErrorCode(result.error.code),
|
|
10346
10348
|
cause: result.error.cause
|
|
10347
10349
|
});
|
|
10348
10350
|
}
|
|
@@ -10369,7 +10371,7 @@ var Agent = class _Agent {
|
|
|
10369
10371
|
if (existing !== void 0) {
|
|
10370
10372
|
return await rehydrateExistingAgent(agentId, existing, options);
|
|
10371
10373
|
}
|
|
10372
|
-
throw new
|
|
10374
|
+
throw new chunk4ZHTIJNE_cjs.UnknownAgentError(
|
|
10373
10375
|
`Agent "${agentId}" not found. Use Agent.create({ agentId, ... }) for first-time setup, or catch UnknownAgentError to branch resume-vs-create.`,
|
|
10374
10376
|
{ code: "unknown_agent" }
|
|
10375
10377
|
);
|
|
@@ -10398,7 +10400,7 @@ var Agent = class _Agent {
|
|
|
10398
10400
|
* @public
|
|
10399
10401
|
*/
|
|
10400
10402
|
static async generateObject(options) {
|
|
10401
|
-
const { generateObjectImpl } = await import('./generate-object-
|
|
10403
|
+
const { generateObjectImpl } = await import('./generate-object-R7HTMW7F.cjs');
|
|
10402
10404
|
return generateObjectImpl(options, {
|
|
10403
10405
|
create: (opts) => _Agent.create(opts),
|
|
10404
10406
|
delete: (agentId) => _Agent.delete(agentId)
|
|
@@ -10422,7 +10424,7 @@ var Agent = class _Agent {
|
|
|
10422
10424
|
delete: (agentId) => _Agent.delete(agentId)
|
|
10423
10425
|
};
|
|
10424
10426
|
async function* wrapper() {
|
|
10425
|
-
streamObjectImport ??= import('./stream-object-
|
|
10427
|
+
streamObjectImport ??= import('./stream-object-ZJTQNKY3.cjs');
|
|
10426
10428
|
const { streamObjectImpl } = await streamObjectImport;
|
|
10427
10429
|
yield* streamObjectImpl(options, deps);
|
|
10428
10430
|
}
|
|
@@ -10446,7 +10448,7 @@ var Agent = class _Agent {
|
|
|
10446
10448
|
* @public
|
|
10447
10449
|
*/
|
|
10448
10450
|
static async batch(prompts, options) {
|
|
10449
|
-
const { batchImpl } = await import('./batch-
|
|
10451
|
+
const { batchImpl } = await import('./batch-BXYTW2DP.cjs');
|
|
10450
10452
|
return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
|
|
10451
10453
|
}
|
|
10452
10454
|
/**
|
|
@@ -10549,14 +10551,14 @@ var Agent = class _Agent {
|
|
|
10549
10551
|
*/
|
|
10550
10552
|
static async getRun(runId, options = {}) {
|
|
10551
10553
|
if (options.runtime === "cloud") {
|
|
10552
|
-
throw new
|
|
10554
|
+
throw new chunk4ZHTIJNE_cjs.ConfigurationError(
|
|
10553
10555
|
"Cloud runtime is pre-release. Theo PaaS endpoints are not wired yet \u2014 getRun({ runtime: 'cloud' }) will be enabled when the PaaS ships.",
|
|
10554
10556
|
{ code: "cloud_runtime_pre_release" }
|
|
10555
10557
|
);
|
|
10556
10558
|
}
|
|
10557
10559
|
const existing = getRun(runId);
|
|
10558
10560
|
if (existing !== void 0) return existing;
|
|
10559
|
-
throw new
|
|
10561
|
+
throw new chunk4ZHTIJNE_cjs.UnknownAgentError(
|
|
10560
10562
|
`Run ${runId} is not in this process's registry. It may have been disposed, persisted in a previous process, or never created.`,
|
|
10561
10563
|
{ code: "run_not_found" }
|
|
10562
10564
|
);
|
|
@@ -10603,13 +10605,13 @@ var Agent = class _Agent {
|
|
|
10603
10605
|
reg = getRegisteredAgent(agentId);
|
|
10604
10606
|
}
|
|
10605
10607
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10606
|
-
throw new
|
|
10608
|
+
throw new chunk4ZHTIJNE_cjs.UnknownAgentError(
|
|
10607
10609
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10608
10610
|
);
|
|
10609
10611
|
}
|
|
10610
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10612
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-QV57KR66.cjs');
|
|
10611
10613
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10612
|
-
return
|
|
10614
|
+
return chunkRMWTPV3M_cjs.enqueueSessionWrite(
|
|
10613
10615
|
cwd,
|
|
10614
10616
|
agentId,
|
|
10615
10617
|
() => compactSessionTranscript({
|
|
@@ -10639,11 +10641,11 @@ var Agent = class _Agent {
|
|
|
10639
10641
|
reg = getRegisteredAgent(agentId);
|
|
10640
10642
|
}
|
|
10641
10643
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10642
|
-
throw new
|
|
10644
|
+
throw new chunk4ZHTIJNE_cjs.UnknownAgentError(
|
|
10643
10645
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10644
10646
|
);
|
|
10645
10647
|
}
|
|
10646
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10648
|
+
const { injectSessionTurn } = await import('./inject-session-WQKMC3GR.cjs');
|
|
10647
10649
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10648
10650
|
await injectSessionTurn({
|
|
10649
10651
|
store,
|
|
@@ -10678,11 +10680,11 @@ var Agent = class _Agent {
|
|
|
10678
10680
|
reg = getRegisteredAgent(agentId);
|
|
10679
10681
|
}
|
|
10680
10682
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10681
|
-
throw new
|
|
10683
|
+
throw new chunk4ZHTIJNE_cjs.UnknownAgentError(
|
|
10682
10684
|
`No local agent "${agentId}" registered \u2014 transcript targets local sessions.`
|
|
10683
10685
|
);
|
|
10684
10686
|
}
|
|
10685
|
-
const { readSessionMessages } = await import('./agent-session-store-
|
|
10687
|
+
const { readSessionMessages } = await import('./agent-session-store-6EL5NPA4.cjs');
|
|
10686
10688
|
const { store } = await openLocalStore(reg);
|
|
10687
10689
|
return readSessionMessages(store, agentId);
|
|
10688
10690
|
}
|
|
@@ -10703,7 +10705,7 @@ var Agent = class _Agent {
|
|
|
10703
10705
|
*/
|
|
10704
10706
|
static async describe(agentId) {
|
|
10705
10707
|
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10706
|
-
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-
|
|
10708
|
+
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-YEUFFPAL.cjs');
|
|
10707
10709
|
const settingSources = agent.options.local?.settingSources;
|
|
10708
10710
|
const subagents = await loadSubagents2(
|
|
10709
10711
|
agent.cwd ?? process.cwd(),
|
|
@@ -10747,12 +10749,12 @@ async function getOrCreateUncached(agentId, options) {
|
|
|
10747
10749
|
try {
|
|
10748
10750
|
return await Agent.resume(agentId, options);
|
|
10749
10751
|
} catch (err) {
|
|
10750
|
-
if (!(err instanceof
|
|
10752
|
+
if (!(err instanceof chunk4ZHTIJNE_cjs.UnknownAgentError)) throw err;
|
|
10751
10753
|
}
|
|
10752
10754
|
try {
|
|
10753
10755
|
return await Agent.create({ ...options, agentId });
|
|
10754
10756
|
} catch (err) {
|
|
10755
|
-
if (err instanceof
|
|
10757
|
+
if (err instanceof chunk4ZHTIJNE_cjs.ConfigurationError && err.code === "agent_id_already_exists") {
|
|
10756
10758
|
return await Agent.resume(agentId, options);
|
|
10757
10759
|
}
|
|
10758
10760
|
throw err;
|
|
@@ -10770,8 +10772,8 @@ async function openLocalStore(reg) {
|
|
|
10770
10772
|
const cwd = reg.cwd ?? process.cwd();
|
|
10771
10773
|
const optModel = reg.options.model;
|
|
10772
10774
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
10773
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
10774
|
-
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-
|
|
10775
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-4PIHT5UX.cjs');
|
|
10776
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-6WNITKRE.cjs');
|
|
10775
10777
|
const configuredSessionDir = reg.options.local?.sessionDir ?? reg.options.local?.baseDir;
|
|
10776
10778
|
const baseDir = configuredSessionDir !== void 0 ? expandTilde2(configuredSessionDir) : defaultBaseDir2();
|
|
10777
10779
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
@@ -10788,5 +10790,5 @@ exports.computeCost = computeCost;
|
|
|
10788
10790
|
exports.generateCronId = generateCronId;
|
|
10789
10791
|
exports.getPricingEntry = getPricingEntry;
|
|
10790
10792
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10791
|
-
//# sourceMappingURL=chunk-
|
|
10792
|
-
//# sourceMappingURL=chunk-
|
|
10793
|
+
//# sourceMappingURL=chunk-ZMRD5DZQ.cjs.map
|
|
10794
|
+
//# sourceMappingURL=chunk-ZMRD5DZQ.cjs.map
|