@theokit/sdk 4.37.1 → 4.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -71
- package/dist/agent-2GZC4W2A.cjs +51 -0
- package/dist/{agent-4MHQUGO5.cjs.map → agent-2GZC4W2A.cjs.map} +1 -1
- package/dist/agent-3H3UKD6U.js +42 -0
- package/dist/{agent-GV36S2CF.js.map → agent-3H3UKD6U.js.map} +1 -1
- package/dist/{agent-SmxntivO.d.ts → agent-C3AEtM-W.d.ts} +39 -37
- package/dist/{agent-DGv1-d81.d.cts → agent-U3lBX-5t.d.cts} +39 -37
- package/dist/agent.d.ts +1 -1
- package/dist/auth/index.cjs +15 -15
- package/dist/auth/index.js +4 -4
- package/dist/{batch-SY5GZLFD.js → batch-LXSALQC3.js} +9 -9
- package/dist/{batch-SY5GZLFD.js.map → batch-LXSALQC3.js.map} +1 -1
- package/dist/{batch-3SEPDXCU.cjs → batch-NZGN6SFV.cjs} +23 -23
- package/dist/{batch-3SEPDXCU.cjs.map → batch-NZGN6SFV.cjs.map} +1 -1
- package/dist/{chunk-D4ZUJTFB.cjs → chunk-2K7PRHDB.cjs} +8 -8
- package/dist/{chunk-D4ZUJTFB.cjs.map → chunk-2K7PRHDB.cjs.map} +1 -1
- package/dist/chunk-2R6NBT5F.cjs +112 -0
- package/dist/chunk-2R6NBT5F.cjs.map +1 -0
- package/dist/{chunk-2423XDPT.cjs → chunk-3BSP7LSG.cjs} +26 -26
- package/dist/{chunk-2423XDPT.cjs.map → chunk-3BSP7LSG.cjs.map} +1 -1
- package/dist/{chunk-6EDQBX7U.cjs → chunk-3MUIYMUG.cjs} +17 -17
- package/dist/{chunk-6EDQBX7U.cjs.map → chunk-3MUIYMUG.cjs.map} +1 -1
- package/dist/{chunk-P34DHHYQ.cjs → chunk-3VKTDQMX.cjs} +34 -27
- package/dist/chunk-3VKTDQMX.cjs.map +1 -0
- package/dist/{chunk-77WHPVXE.js → chunk-3XKVRLR2.js} +4 -4
- package/dist/chunk-3XKVRLR2.js.map +1 -0
- package/dist/{chunk-SWIBQFPH.cjs → chunk-3XRXORBS.cjs} +4 -4
- package/dist/{chunk-SWIBQFPH.cjs.map → chunk-3XRXORBS.cjs.map} +1 -1
- package/dist/{chunk-DCJ5MCJ3.js → chunk-4APWS2YF.js} +7 -7
- package/dist/{chunk-DCJ5MCJ3.js.map → chunk-4APWS2YF.js.map} +1 -1
- package/dist/{chunk-56ZM6P7Z.cjs → chunk-4MWBKBS4.cjs} +12 -12
- package/dist/chunk-4MWBKBS4.cjs.map +1 -0
- package/dist/chunk-4NVV3GRU.js +110 -0
- package/dist/chunk-4NVV3GRU.js.map +1 -0
- package/dist/{chunk-QGDKZDPN.js → chunk-4WIJSKFA.js} +3 -3
- package/dist/{chunk-QGDKZDPN.js.map → chunk-4WIJSKFA.js.map} +1 -1
- package/dist/{chunk-VNNK6AKU.js → chunk-5BVBNE2F.js} +3 -3
- package/dist/chunk-5BVBNE2F.js.map +1 -0
- package/dist/{chunk-EEZ7CFMM.js → chunk-5KOW3GLE.js} +2 -2
- package/dist/chunk-5KOW3GLE.js.map +1 -0
- package/dist/{chunk-FK4EJD2I.cjs → chunk-6OIO4FYX.cjs} +7 -7
- package/dist/{chunk-FK4EJD2I.cjs.map → chunk-6OIO4FYX.cjs.map} +1 -1
- package/dist/{chunk-IEUDKUPM.cjs → chunk-6OKPJZMX.cjs} +8 -8
- package/dist/{chunk-IEUDKUPM.cjs.map → chunk-6OKPJZMX.cjs.map} +1 -1
- package/dist/{chunk-QFMXXUUT.js → chunk-6XZBKFQ7.js} +3 -3
- package/dist/{chunk-QFMXXUUT.js.map → chunk-6XZBKFQ7.js.map} +1 -1
- package/dist/{chunk-H5YVJB4K.cjs → chunk-6ZGD7R27.cjs} +37 -37
- package/dist/chunk-6ZGD7R27.cjs.map +1 -0
- package/dist/{chunk-HEN5WXXI.js → chunk-7QDTZJRV.js} +6 -6
- package/dist/{chunk-HEN5WXXI.js.map → chunk-7QDTZJRV.js.map} +1 -1
- package/dist/{chunk-MHCKWQR3.cjs → chunk-A3MHE2MQ.cjs} +8 -8
- package/dist/{chunk-MHCKWQR3.cjs.map → chunk-A3MHE2MQ.cjs.map} +1 -1
- package/dist/{chunk-5SB4V74H.js → chunk-A4XXV2C6.js} +18 -18
- package/dist/chunk-A4XXV2C6.js.map +1 -0
- package/dist/{chunk-6VP3XGEK.js → chunk-A6GXYF2Q.js} +9 -9
- package/dist/{chunk-6VP3XGEK.js.map → chunk-A6GXYF2Q.js.map} +1 -1
- package/dist/{chunk-SDIBMLL5.js → chunk-ACHGT3D2.js} +8 -8
- package/dist/{chunk-SDIBMLL5.js.map → chunk-ACHGT3D2.js.map} +1 -1
- package/dist/{chunk-XAEAMI5H.js → chunk-AOZYORH7.js} +4 -4
- package/dist/chunk-AOZYORH7.js.map +1 -0
- package/dist/{chunk-LTCOPATU.cjs → chunk-BE3W4HYV.cjs} +2 -2
- package/dist/chunk-BE3W4HYV.cjs.map +1 -0
- package/dist/{chunk-NQ4AC2U4.cjs → chunk-BT6DFWZB.cjs} +9 -9
- package/dist/{chunk-NQ4AC2U4.cjs.map → chunk-BT6DFWZB.cjs.map} +1 -1
- package/dist/{chunk-XAYVHS2B.cjs → chunk-BUGVDCI5.cjs} +4 -4
- package/dist/{chunk-XAYVHS2B.cjs.map → chunk-BUGVDCI5.cjs.map} +1 -1
- package/dist/{chunk-IT3PWBW4.cjs → chunk-BURYFNOM.cjs} +2 -2
- package/dist/chunk-BURYFNOM.cjs.map +1 -0
- package/dist/{chunk-NNSKJCBM.cjs → chunk-D3SJLXYZ.cjs} +10 -10
- package/dist/{chunk-NNSKJCBM.cjs.map → chunk-D3SJLXYZ.cjs.map} +1 -1
- package/dist/{chunk-MRODLUGY.cjs → chunk-ED7ANP6W.cjs} +4 -4
- package/dist/{chunk-MRODLUGY.cjs.map → chunk-ED7ANP6W.cjs.map} +1 -1
- package/dist/{chunk-MXSMAGDU.js → chunk-EDI7DBWO.js} +33 -26
- package/dist/chunk-EDI7DBWO.js.map +1 -0
- package/dist/{chunk-SSH2ZAZF.js → chunk-EE24WJJR.js} +5 -5
- package/dist/{chunk-SSH2ZAZF.js.map → chunk-EE24WJJR.js.map} +1 -1
- package/dist/{chunk-ZJN6NTHE.js → chunk-EUB7YLU2.js} +3 -3
- package/dist/{chunk-ZJN6NTHE.js.map → chunk-EUB7YLU2.js.map} +1 -1
- package/dist/{chunk-ALU3KC4G.cjs → chunk-G7X2Y7Y2.cjs} +156 -156
- package/dist/chunk-G7X2Y7Y2.cjs.map +1 -0
- package/dist/{chunk-YCXMSDSP.js → chunk-HHUDNTZC.js} +4 -4
- package/dist/{chunk-YCXMSDSP.js.map → chunk-HHUDNTZC.js.map} +1 -1
- package/dist/{chunk-GL7CFBVC.js → chunk-HI6G3SNY.js} +48 -48
- package/dist/chunk-HI6G3SNY.js.map +1 -0
- package/dist/{chunk-KDDL5HKQ.cjs → chunk-HLK35TD7.cjs} +24 -24
- package/dist/{chunk-KDDL5HKQ.cjs.map → chunk-HLK35TD7.cjs.map} +1 -1
- package/dist/{chunk-4YB7B3RP.cjs → chunk-IBDE4R5L.cjs} +13 -13
- package/dist/{chunk-4YB7B3RP.cjs.map → chunk-IBDE4R5L.cjs.map} +1 -1
- package/dist/{chunk-WDGCZDRG.js → chunk-JCXIDFRI.js} +3 -3
- package/dist/{chunk-WDGCZDRG.js.map → chunk-JCXIDFRI.js.map} +1 -1
- package/dist/{chunk-I35DI7ES.js → chunk-JI34KBNC.js} +3 -3
- package/dist/{chunk-I35DI7ES.js.map → chunk-JI34KBNC.js.map} +1 -1
- package/dist/{chunk-TAPQWDW2.js → chunk-KCZW75PI.js} +2 -2
- package/dist/chunk-KCZW75PI.js.map +1 -0
- package/dist/{chunk-U2WLFOA3.cjs → chunk-KL7E244K.cjs} +4 -4
- package/dist/{chunk-U2WLFOA3.cjs.map → chunk-KL7E244K.cjs.map} +1 -1
- package/dist/{chunk-PAEJPLVN.cjs → chunk-KTXOHCAE.cjs} +4 -4
- package/dist/{chunk-PAEJPLVN.cjs.map → chunk-KTXOHCAE.cjs.map} +1 -1
- package/dist/{chunk-2WFB5ZOX.js → chunk-KWXC6ERT.js} +5 -5
- package/dist/{chunk-2WFB5ZOX.js.map → chunk-KWXC6ERT.js.map} +1 -1
- package/dist/{chunk-56OXYUZE.js → chunk-LGCEYEU2.js} +3 -3
- package/dist/chunk-LGCEYEU2.js.map +1 -0
- package/dist/{chunk-FAY3QDGC.cjs → chunk-M4OGSS66.cjs} +11 -11
- package/dist/{chunk-FAY3QDGC.cjs.map → chunk-M4OGSS66.cjs.map} +1 -1
- package/dist/{chunk-F6Y4IEQM.js → chunk-M6UUTNDT.js} +4 -4
- package/dist/{chunk-F6Y4IEQM.js.map → chunk-M6UUTNDT.js.map} +1 -1
- package/dist/{chunk-GM7QDQ24.cjs → chunk-MXRBNJ6D.cjs} +11 -11
- package/dist/{chunk-GM7QDQ24.cjs.map → chunk-MXRBNJ6D.cjs.map} +1 -1
- package/dist/{chunk-YPQF26X7.cjs → chunk-OBA6YK2R.cjs} +2 -2
- package/dist/chunk-OBA6YK2R.cjs.map +1 -0
- package/dist/{chunk-BJMKQOY2.cjs → chunk-OFWU6UKF.cjs} +11 -11
- package/dist/{chunk-BJMKQOY2.cjs.map → chunk-OFWU6UKF.cjs.map} +1 -1
- package/dist/{chunk-3O2ELBST.cjs → chunk-PG3QQLWS.cjs} +5 -5
- package/dist/{chunk-3O2ELBST.cjs.map → chunk-PG3QQLWS.cjs.map} +1 -1
- package/dist/{chunk-2ONFGMBV.js → chunk-PY2RQOA7.js} +2 -2
- package/dist/chunk-PY2RQOA7.js.map +1 -0
- package/dist/{chunk-UQPDFW4E.js → chunk-QFWQLXCL.js} +3 -3
- package/dist/{chunk-UQPDFW4E.js.map → chunk-QFWQLXCL.js.map} +1 -1
- package/dist/{chunk-YBFDBOUN.cjs → chunk-QJQ2MAZF.cjs} +8 -8
- package/dist/{chunk-YBFDBOUN.cjs.map → chunk-QJQ2MAZF.cjs.map} +1 -1
- package/dist/{chunk-QUFSDDNU.cjs → chunk-R4AMI7KD.cjs} +15 -15
- package/dist/{chunk-QUFSDDNU.cjs.map → chunk-R4AMI7KD.cjs.map} +1 -1
- package/dist/{chunk-CSZRJ4RE.js → chunk-SGTMDQ4O.js} +5 -5
- package/dist/{chunk-CSZRJ4RE.js.map → chunk-SGTMDQ4O.js.map} +1 -1
- package/dist/{chunk-3ILFUXNE.cjs → chunk-SRIF7HMN.cjs} +5 -5
- package/dist/{chunk-3ILFUXNE.cjs.map → chunk-SRIF7HMN.cjs.map} +1 -1
- package/dist/{chunk-THEYGCYS.cjs → chunk-TKDWD3MU.cjs} +4 -4
- package/dist/chunk-TKDWD3MU.cjs.map +1 -0
- package/dist/{chunk-ZW345YOI.js → chunk-UD2T7ISG.js} +4 -4
- package/dist/{chunk-ZW345YOI.js.map → chunk-UD2T7ISG.js.map} +1 -1
- package/dist/{chunk-EXQV452X.js → chunk-UWEALKAN.js} +3 -3
- package/dist/{chunk-EXQV452X.js.map → chunk-UWEALKAN.js.map} +1 -1
- package/dist/{chunk-S3WZ7NHF.cjs → chunk-UZBA6YYP.cjs} +472 -326
- package/dist/chunk-UZBA6YYP.cjs.map +1 -0
- package/dist/{chunk-XJLGRJ7K.js → chunk-VUDH4D2M.js} +221 -75
- package/dist/chunk-VUDH4D2M.js.map +1 -0
- package/dist/{chunk-W4QN5CMG.cjs → chunk-VVMLMKYZ.cjs} +9 -9
- package/dist/{chunk-W4QN5CMG.cjs.map → chunk-VVMLMKYZ.cjs.map} +1 -1
- package/dist/{chunk-JNIWFCKI.js → chunk-VYD6BGKK.js} +3 -3
- package/dist/{chunk-JNIWFCKI.js.map → chunk-VYD6BGKK.js.map} +1 -1
- package/dist/{chunk-YHZXBDAW.js → chunk-XJ5TMOGA.js} +16 -16
- package/dist/{chunk-YHZXBDAW.js.map → chunk-XJ5TMOGA.js.map} +1 -1
- package/dist/{chunk-7DXLNNKH.cjs → chunk-XKBJT7WI.cjs} +4 -4
- package/dist/{chunk-7DXLNNKH.cjs.map → chunk-XKBJT7WI.cjs.map} +1 -1
- package/dist/{chunk-YDLNI7J6.js → chunk-XS7SKY2F.js} +3 -3
- package/dist/{chunk-YDLNI7J6.js.map → chunk-XS7SKY2F.js.map} +1 -1
- package/dist/{chunk-NFCKEBHI.js → chunk-YCHC45BY.js} +3 -3
- package/dist/{chunk-NFCKEBHI.js.map → chunk-YCHC45BY.js.map} +1 -1
- package/dist/{chunk-ICYBIC6N.cjs → chunk-YVI4YPUP.cjs} +4 -4
- package/dist/chunk-YVI4YPUP.cjs.map +1 -0
- package/dist/{chunk-TQI3KRXZ.cjs → chunk-ZET34IZE.cjs} +18 -18
- package/dist/{chunk-TQI3KRXZ.cjs.map → chunk-ZET34IZE.cjs.map} +1 -1
- package/dist/{chunk-GLUWH6JO.js → chunk-ZFZYPLQI.js} +4 -4
- package/dist/{chunk-GLUWH6JO.js.map → chunk-ZFZYPLQI.js.map} +1 -1
- package/dist/{chunk-M5ZQBOIZ.js → chunk-ZK3BJ4XQ.js} +3 -3
- package/dist/{chunk-M5ZQBOIZ.js.map → chunk-ZK3BJ4XQ.js.map} +1 -1
- package/dist/{chunk-CD73YHEH.js → chunk-ZYOHF37V.js} +3 -3
- package/dist/{chunk-CD73YHEH.js.map → chunk-ZYOHF37V.js.map} +1 -1
- package/dist/compact-session-RR3ILTES.js +17 -0
- package/dist/{compact-session-WNKKIIDW.js.map → compact-session-RR3ILTES.js.map} +1 -1
- package/dist/compact-session-YOWJJPPB.cjs +54 -0
- package/dist/{compact-session-H5TKLD55.cjs.map → compact-session-YOWJJPPB.cjs.map} +1 -1
- package/dist/compaction.cjs +19 -19
- package/dist/compaction.d.cts +9 -9
- package/dist/compaction.d.ts +9 -9
- package/dist/compaction.js +3 -3
- package/dist/concurrency.cjs +6 -6
- package/dist/concurrency.js +4 -4
- package/dist/context-Q6ISOCN2.cjs +22 -0
- package/dist/{context-ZV33V4DC.cjs.map → context-Q6ISOCN2.cjs.map} +1 -1
- package/dist/context-ZDBBPIHY.js +5 -0
- package/dist/{context-VAYLPT4O.js.map → context-ZDBBPIHY.js.map} +1 -1
- package/dist/{cron-BiK_aNJI.d.cts → cron-BdXOZco9.d.cts} +2 -2
- package/dist/{cron-Dx7B-3WB.d.ts → cron-ChQ6zcW2.d.ts} +2 -2
- package/dist/cron.cjs +29 -29
- package/dist/cron.d.cts +3 -3
- package/dist/cron.d.ts +3 -3
- package/dist/cron.js +28 -28
- package/dist/{errors-DyVbXdR4.d.cts → errors-BUVjJGJA.d.cts} +1 -1
- package/dist/{errors-Cua4WC9H.d.ts → errors-CZIUKLHt.d.ts} +1 -1
- package/dist/errors.cjs +21 -21
- package/dist/errors.d.cts +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +2 -2
- package/dist/eval.cjs +32 -32
- package/dist/eval.js +28 -28
- package/dist/{executor-PAH72CB5.js → executor-ASDDIM2X.js} +7 -7
- package/dist/{executor-PAH72CB5.js.map → executor-ASDDIM2X.js.map} +1 -1
- package/dist/{executor-OZSYXDKF.cjs → executor-DPCBSI35.cjs} +23 -23
- package/dist/{executor-OZSYXDKF.cjs.map → executor-DPCBSI35.cjs.map} +1 -1
- package/dist/filesystem/index.cjs +7 -7
- package/dist/filesystem/index.js +3 -3
- package/dist/fs-session-store-K5QUPNJZ.js +10 -0
- package/dist/{fs-session-store-6MY7PNI2.js.map → fs-session-store-K5QUPNJZ.js.map} +1 -1
- package/dist/fs-session-store-T5ZLQX42.cjs +19 -0
- package/dist/{fs-session-store-7E7UPLF2.cjs.map → fs-session-store-T5ZLQX42.cjs.map} +1 -1
- package/dist/generate-object-F56VIZ6U.cjs +20 -0
- package/dist/{generate-object-5SCEH2EE.cjs.map → generate-object-F56VIZ6U.cjs.map} +1 -1
- package/dist/generate-object-LPSO6GVW.js +7 -0
- package/dist/{generate-object-I7UD4NWN.js.map → generate-object-LPSO6GVW.js.map} +1 -1
- package/dist/index-manager-DBJ55ZSO.cjs +19 -0
- package/dist/{index-manager-R6ZJFEZF.cjs.map → index-manager-DBJ55ZSO.cjs.map} +1 -1
- package/dist/index-manager-F2H2RCZU.js +10 -0
- package/dist/{index-manager-KKAK7NT3.js.map → index-manager-F2H2RCZU.js.map} +1 -1
- package/dist/index.cjs +140 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -42
- package/dist/index.d.ts +42 -42
- package/dist/index.js +54 -54
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-DM4SKTZO.cjs → inject-session-25EC74WV.cjs} +10 -10
- package/dist/{inject-session-DM4SKTZO.cjs.map → inject-session-25EC74WV.cjs.map} +1 -1
- package/dist/{inject-session-UXNJQTZ6.js → inject-session-RKNLUE72.js} +7 -7
- package/dist/{inject-session-UXNJQTZ6.js.map → inject-session-RKNLUE72.js.map} +1 -1
- package/dist/internal/agent-loop/live-events.d.ts +46 -0
- package/dist/internal/budget/compute-cost.d.ts +1 -1
- package/dist/internal/diagnostics.d.ts +31 -29
- package/dist/internal/error-mappers/anthropic.d.ts +1 -1
- package/dist/internal/global-singleton.d.ts +7 -7
- package/dist/internal/judge/judge-call.d.ts +14 -14
- package/dist/internal/llm/retrying-client.d.ts +29 -29
- package/dist/internal/llm/transport-error.d.ts +2 -2
- package/dist/internal/persistence/exclusive-create.d.cts +2 -2
- package/dist/internal/persistence/exclusive-create.d.ts +2 -2
- package/dist/internal/persistence/fs-session-store.d.cts +18 -18
- package/dist/internal/persistence/fs-session-store.d.ts +18 -18
- package/dist/internal/persistence/index.cjs +25 -25
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.js +6 -6
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/persistence/paths.d.cts +7 -7
- package/dist/internal/persistence/paths.d.ts +7 -7
- package/dist/internal/persistence/session-transcript.d.cts +7 -7
- package/dist/internal/persistence/session-transcript.d.ts +7 -7
- package/dist/internal/persistence/session-writer.d.cts +30 -13
- package/dist/internal/persistence/session-writer.d.ts +30 -13
- package/dist/internal/runtime/fixtures/fixture-run-base.d.ts +45 -13
- package/dist/internal/runtime/lifecycle/goal-marker.d.ts +8 -8
- package/dist/internal/security/index.cjs +13 -13
- package/dist/internal/security/index.js +3 -3
- package/dist/internal/session/agent-session.d.ts +14 -14
- package/dist/internal/session/session-cache.d.ts +9 -9
- package/dist/judge-call-3S3T6O2Z.js +5 -0
- package/dist/{judge-call-TAEIXMYG.js.map → judge-call-3S3T6O2Z.js.map} +1 -1
- package/dist/judge-call-XIQJ5GIE.cjs +22 -0
- package/dist/{judge-call-SP3G3X2Y.cjs.map → judge-call-XIQJ5GIE.cjs.map} +1 -1
- package/dist/models.cjs +20 -20
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +5 -5
- package/dist/models.js.map +1 -1
- package/dist/path-safety.cjs +10 -10
- package/dist/path-safety.js +3 -3
- package/dist/persistence.cjs +34 -34
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.d.cts +1 -1
- package/dist/persistence.d.ts +1 -1
- package/dist/persistence.js +14 -14
- package/dist/persistence.js.map +1 -1
- package/dist/project.cjs +5 -5
- package/dist/project.js +3 -3
- package/dist/registry-BA3SLAN7.cjs +46 -0
- package/dist/{registry-N3GTKYCI.cjs.map → registry-BA3SLAN7.cjs.map} +1 -1
- package/dist/registry-KMI5RA22.js +9 -0
- package/dist/{registry-SOXE4RY6.js.map → registry-KMI5RA22.js.map} +1 -1
- package/dist/retry.cjs +4 -4
- package/dist/retry.js +3 -3
- package/dist/{run-until-YZ2ODWOF.js → run-until-BK56WG4P.js} +3 -3
- package/dist/{run-until-YZ2ODWOF.js.map → run-until-BK56WG4P.js.map} +1 -1
- package/dist/{run-until-ZZ2JLPJM.cjs → run-until-L5KQD3PV.cjs} +4 -4
- package/dist/{run-until-ZZ2JLPJM.cjs.map → run-until-L5KQD3PV.cjs.map} +1 -1
- package/dist/{run-CwEJtLPE.d.ts → run-vJHg2eGw.d.cts} +201 -174
- package/dist/{run-CwEJtLPE.d.cts → run-vJHg2eGw.d.ts} +201 -174
- package/dist/sandbox/bwrap.d.cts +20 -20
- package/dist/sandbox/bwrap.d.ts +20 -20
- package/dist/sandbox/index.cjs +39 -39
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.d.cts +1 -1
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +35 -35
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/linux-sandbox.d.cts +26 -21
- package/dist/sandbox/linux-sandbox.d.ts +26 -21
- package/dist/server/auth/index.cjs.map +1 -1
- package/dist/server/auth/index.d.cts +6 -6
- package/dist/server/auth/index.d.ts +6 -6
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/orchestrator.d.cts +2 -2
- package/dist/server/auth/orchestrator.d.ts +2 -2
- package/dist/server/auth/types.d.cts +4 -4
- package/dist/server/auth/types.d.ts +4 -4
- package/dist/server/errors-envelope.cjs +14 -14
- package/dist/server/errors-envelope.d.cts +3 -3
- package/dist/server/errors-envelope.d.ts +3 -3
- package/dist/server/errors-envelope.js +3 -3
- package/dist/session-transcript-DFGX6WNL.cjs +50 -0
- package/dist/{session-transcript-EAKR4D2W.cjs.map → session-transcript-DFGX6WNL.cjs.map} +1 -1
- package/dist/session-transcript-MMPWCESR.js +5 -0
- package/dist/{session-transcript-6WKLYIN4.js.map → session-transcript-MMPWCESR.js.map} +1 -1
- package/dist/skills.cjs +7 -7
- package/dist/skills.js +5 -5
- package/dist/stream-object-AFERZU63.js +7 -0
- package/dist/{stream-object-OFM66VUT.js.map → stream-object-AFERZU63.js.map} +1 -1
- package/dist/stream-object-YPXZ4F5P.cjs +20 -0
- package/dist/{stream-object-Y7YCX3BI.cjs.map → stream-object-YPXZ4F5P.cjs.map} +1 -1
- package/dist/subagents-loader.cjs +6 -6
- package/dist/subagents-loader.d.cts +2 -2
- package/dist/subagents-loader.d.ts +2 -2
- package/dist/subagents-loader.js +4 -4
- package/dist/subscription/index.cjs +3 -3
- package/dist/subscription/index.js +2 -2
- package/dist/task-store.cjs +7 -7
- package/dist/task-store.js +4 -4
- package/dist/types/agent-prims.d.ts +4 -4
- package/dist/types/goal-events.d.ts +24 -23
- package/dist/types/run.d.ts +27 -0
- package/dist/types/session-record.d.ts +14 -13
- package/dist/workflow.cjs +27 -27
- package/dist/workflow.js +6 -6
- package/package.json +12 -13
- package/dist/agent-4MHQUGO5.cjs +0 -51
- package/dist/agent-GV36S2CF.js +0 -42
- package/dist/chunk-2ONFGMBV.js.map +0 -1
- package/dist/chunk-56OXYUZE.js.map +0 -1
- package/dist/chunk-56ZM6P7Z.cjs.map +0 -1
- package/dist/chunk-5SB4V74H.js.map +0 -1
- package/dist/chunk-77WHPVXE.js.map +0 -1
- package/dist/chunk-ALU3KC4G.cjs.map +0 -1
- package/dist/chunk-EEZ7CFMM.js.map +0 -1
- package/dist/chunk-GL7CFBVC.js.map +0 -1
- package/dist/chunk-H5YVJB4K.cjs.map +0 -1
- package/dist/chunk-ICYBIC6N.cjs.map +0 -1
- package/dist/chunk-IT3PWBW4.cjs.map +0 -1
- package/dist/chunk-ITLS5LRF.cjs +0 -105
- package/dist/chunk-ITLS5LRF.cjs.map +0 -1
- package/dist/chunk-LTCOPATU.cjs.map +0 -1
- package/dist/chunk-MXSMAGDU.js.map +0 -1
- package/dist/chunk-P34DHHYQ.cjs.map +0 -1
- package/dist/chunk-S3WZ7NHF.cjs.map +0 -1
- package/dist/chunk-TAPQWDW2.js.map +0 -1
- package/dist/chunk-THEYGCYS.cjs.map +0 -1
- package/dist/chunk-VNNK6AKU.js.map +0 -1
- package/dist/chunk-XAEAMI5H.js.map +0 -1
- package/dist/chunk-XJLGRJ7K.js.map +0 -1
- package/dist/chunk-YPQF26X7.cjs.map +0 -1
- package/dist/chunk-YVTNFKZO.js +0 -103
- package/dist/chunk-YVTNFKZO.js.map +0 -1
- package/dist/compact-session-H5TKLD55.cjs +0 -54
- package/dist/compact-session-WNKKIIDW.js +0 -17
- package/dist/context-VAYLPT4O.js +0 -5
- package/dist/context-ZV33V4DC.cjs +0 -22
- package/dist/fs-session-store-6MY7PNI2.js +0 -10
- package/dist/fs-session-store-7E7UPLF2.cjs +0 -19
- package/dist/generate-object-5SCEH2EE.cjs +0 -20
- package/dist/generate-object-I7UD4NWN.js +0 -7
- package/dist/index-manager-KKAK7NT3.js +0 -10
- package/dist/index-manager-R6ZJFEZF.cjs +0 -19
- package/dist/judge-call-SP3G3X2Y.cjs +0 -22
- package/dist/judge-call-TAEIXMYG.js +0 -5
- package/dist/registry-N3GTKYCI.cjs +0 -46
- package/dist/registry-SOXE4RY6.js +0 -9
- package/dist/session-transcript-6WKLYIN4.js +0 -5
- package/dist/session-transcript-EAKR4D2W.cjs +0 -50
- package/dist/stream-object-OFM66VUT.js +0 -7
- package/dist/stream-object-Y7YCX3BI.cjs +0 -20
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
4
|
+
var chunk3MUIYMUG_cjs = require('./chunk-3MUIYMUG.cjs');
|
|
5
|
+
var chunk6ZGD7R27_cjs = require('./chunk-6ZGD7R27.cjs');
|
|
6
|
+
var chunk2R6NBT5F_cjs = require('./chunk-2R6NBT5F.cjs');
|
|
7
|
+
var chunkG7X2Y7Y2_cjs = require('./chunk-G7X2Y7Y2.cjs');
|
|
8
|
+
var chunk3BSP7LSG_cjs = require('./chunk-3BSP7LSG.cjs');
|
|
9
|
+
var chunkM4OGSS66_cjs = require('./chunk-M4OGSS66.cjs');
|
|
10
10
|
var chunkWPZTYOUX_cjs = require('./chunk-WPZTYOUX.cjs');
|
|
11
|
-
var
|
|
11
|
+
var chunk2K7PRHDB_cjs = require('./chunk-2K7PRHDB.cjs');
|
|
12
12
|
var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
|
|
13
13
|
var chunkG2F67XUR_cjs = require('./chunk-G2F67XUR.cjs');
|
|
14
14
|
var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
|
|
15
15
|
var chunkYPEPCZHF_cjs = require('./chunk-YPEPCZHF.cjs');
|
|
16
16
|
var chunkVJ26EKGJ_cjs = require('./chunk-VJ26EKGJ.cjs');
|
|
17
|
-
var
|
|
18
|
-
var
|
|
17
|
+
var chunk3XRXORBS_cjs = require('./chunk-3XRXORBS.cjs');
|
|
18
|
+
var chunkZET34IZE_cjs = require('./chunk-ZET34IZE.cjs');
|
|
19
19
|
var chunkYLQQX5W2_cjs = require('./chunk-YLQQX5W2.cjs');
|
|
20
|
-
var
|
|
20
|
+
var chunk6OKPJZMX_cjs = require('./chunk-6OKPJZMX.cjs');
|
|
21
21
|
var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
22
|
+
var chunkYVI4YPUP_cjs = require('./chunk-YVI4YPUP.cjs');
|
|
23
|
+
var chunkMXRBNJ6D_cjs = require('./chunk-MXRBNJ6D.cjs');
|
|
24
|
+
var chunkIBDE4R5L_cjs = require('./chunk-IBDE4R5L.cjs');
|
|
25
25
|
var chunkVYHJZVL5_cjs = require('./chunk-VYHJZVL5.cjs');
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
26
|
+
var chunk4MWBKBS4_cjs = require('./chunk-4MWBKBS4.cjs');
|
|
27
|
+
var chunkR4AMI7KD_cjs = require('./chunk-R4AMI7KD.cjs');
|
|
28
|
+
var chunkQJQ2MAZF_cjs = require('./chunk-QJQ2MAZF.cjs');
|
|
29
|
+
var chunkXKBJT7WI_cjs = require('./chunk-XKBJT7WI.cjs');
|
|
30
|
+
var chunkA3MHE2MQ_cjs = require('./chunk-A3MHE2MQ.cjs');
|
|
31
|
+
var chunkBE3W4HYV_cjs = require('./chunk-BE3W4HYV.cjs');
|
|
32
32
|
var promises = require('fs/promises');
|
|
33
33
|
var crypto = require('crypto');
|
|
34
34
|
var path = require('path');
|
|
@@ -224,7 +224,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
|
|
|
224
224
|
const { output, maxRetries, errorStrategy, ...sendOptions } = options;
|
|
225
225
|
const run = await agent.send(input, sendOptions);
|
|
226
226
|
const result = await run.wait();
|
|
227
|
-
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-
|
|
227
|
+
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-F56VIZ6U.cjs');
|
|
228
228
|
const answer = structurableAnswerOrThrow(result, GenerateObjectError);
|
|
229
229
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
230
230
|
const facade = getAgentFacade();
|
|
@@ -326,7 +326,7 @@ function normalizeModel(m) {
|
|
|
326
326
|
if (m === void 0 || typeof m !== "string") return m;
|
|
327
327
|
const id = m.trim();
|
|
328
328
|
if (id.length === 0) {
|
|
329
|
-
throw new
|
|
329
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
330
330
|
'model must be a non-empty "provider/model" id string or a ModelSelection object',
|
|
331
331
|
{ code: "invalid_model_selection" }
|
|
332
332
|
);
|
|
@@ -462,7 +462,7 @@ function registryPath(cwd) {
|
|
|
462
462
|
return path.join(cwd, REGISTRY_RELATIVE_PATH);
|
|
463
463
|
}
|
|
464
464
|
async function loadRegistry(cwd) {
|
|
465
|
-
return
|
|
465
|
+
return chunk2K7PRHDB_cjs.readVersionedJson({
|
|
466
466
|
path: registryPath(cwd),
|
|
467
467
|
currentVersion: SCHEMA_VERSION,
|
|
468
468
|
defaultValue: () => ({}),
|
|
@@ -486,7 +486,7 @@ async function saveRegistry(cwd, agents2) {
|
|
|
486
486
|
}
|
|
487
487
|
const path = registryPath(cwd);
|
|
488
488
|
await chunkYLQQX5W2_cjs.withCwdMutex(`registry:${cwd}`, async () => {
|
|
489
|
-
await
|
|
489
|
+
await chunk2K7PRHDB_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
|
|
490
490
|
});
|
|
491
491
|
}
|
|
492
492
|
function toSerialized(agent) {
|
|
@@ -553,7 +553,7 @@ function scheduleSaveForCwd(cwd) {
|
|
|
553
553
|
}
|
|
554
554
|
} catch (cause) {
|
|
555
555
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
556
|
-
|
|
556
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] registry persist failed (${cwd}): ${msg}
|
|
557
557
|
`);
|
|
558
558
|
} finally {
|
|
559
559
|
pendingSaves.delete(cwd);
|
|
@@ -892,14 +892,14 @@ async function readLegacyFacts(jsonPath) {
|
|
|
892
892
|
}
|
|
893
893
|
async function writeMigratedFacts(cwd, jsonPath, facts) {
|
|
894
894
|
try {
|
|
895
|
-
for (const fact of facts) await
|
|
895
|
+
for (const fact of facts) await chunk3BSP7LSG_cjs.appendFactToMarkdown(cwd, fact);
|
|
896
896
|
await promises.unlink(jsonPath).catch(() => void 0);
|
|
897
|
-
|
|
897
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
|
|
898
898
|
`);
|
|
899
899
|
return { migrated: true, factCount: facts.length };
|
|
900
900
|
} catch (cause) {
|
|
901
901
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
902
|
-
|
|
902
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] memory migration failed (readonly fs?): ${message}
|
|
903
903
|
`);
|
|
904
904
|
return { migrated: false, factCount: 0, reason: "readonly-fs" };
|
|
905
905
|
}
|
|
@@ -909,12 +909,12 @@ async function migrateLegacyJson(cwd, config) {
|
|
|
909
909
|
const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
|
|
910
910
|
if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
|
|
911
911
|
migrationRun.add(key);
|
|
912
|
-
const jsonPath =
|
|
912
|
+
const jsonPath = chunk3BSP7LSG_cjs.legacyMemoryJsonPath(cwd, config);
|
|
913
913
|
if (!await fileExists(jsonPath)) {
|
|
914
914
|
return { migrated: false, factCount: 0, reason: "no-legacy-json" };
|
|
915
915
|
}
|
|
916
|
-
if (await fileExists(
|
|
917
|
-
|
|
916
|
+
if (await fileExists(chunk3BSP7LSG_cjs.memoryMdPath(cwd))) {
|
|
917
|
+
chunkBE3W4HYV_cjs.diag(
|
|
918
918
|
`[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
|
|
919
919
|
`
|
|
920
920
|
);
|
|
@@ -938,13 +938,13 @@ function extractMemoryFact(message) {
|
|
|
938
938
|
async function readMemoryFacts(cwd, config) {
|
|
939
939
|
if (!config.enabled) return [];
|
|
940
940
|
await migrateLegacyJson(cwd, config);
|
|
941
|
-
return
|
|
941
|
+
return chunk3BSP7LSG_cjs.readFacts(cwd, config);
|
|
942
942
|
}
|
|
943
943
|
async function appendMemoryFact(cwd, config, fact) {
|
|
944
944
|
if (!config.enabled) return;
|
|
945
945
|
await migrateLegacyJson(cwd, config);
|
|
946
|
-
const sanitized = { text:
|
|
947
|
-
await
|
|
946
|
+
const sanitized = { text: chunkBE3W4HYV_cjs.redactSecrets(fact.text) };
|
|
947
|
+
await chunk3BSP7LSG_cjs.appendFact(cwd, config, sanitized);
|
|
948
948
|
}
|
|
949
949
|
|
|
950
950
|
// src/internal/runtime/fixtures/fixture-scripts.ts
|
|
@@ -1292,7 +1292,7 @@ function redactScriptSecrets(script) {
|
|
|
1292
1292
|
function redactEventSecrets(event) {
|
|
1293
1293
|
const serialized = JSON.stringify(event);
|
|
1294
1294
|
const localStripped = serialized.replace(FIXTURE_SENTINEL, "***");
|
|
1295
|
-
const redacted =
|
|
1295
|
+
const redacted = chunkBE3W4HYV_cjs.redactSecrets(localStripped);
|
|
1296
1296
|
if (redacted === serialized) return event;
|
|
1297
1297
|
return JSON.parse(redacted);
|
|
1298
1298
|
}
|
|
@@ -1323,6 +1323,16 @@ var FixtureRunBase = class {
|
|
|
1323
1323
|
resolveTermination;
|
|
1324
1324
|
terminated = false;
|
|
1325
1325
|
eventNotifier;
|
|
1326
|
+
/**
|
|
1327
|
+
* theokit#140 - the run's single ordered timeline: structural events and live token/tool deltas,
|
|
1328
|
+
* in the order they actually occurred.
|
|
1329
|
+
*
|
|
1330
|
+
* Kept alongside `script.events` rather than replacing it. `stream()` is the SDKMessage view and
|
|
1331
|
+
* stays byte-identical for every existing consumer; this is the complete view, and a consumer
|
|
1332
|
+
* picks one. Merging them would have changed `stream()`'s element type - a breaking change for
|
|
1333
|
+
* an additive feature.
|
|
1334
|
+
*/
|
|
1335
|
+
timeline = [];
|
|
1326
1336
|
constructor(options) {
|
|
1327
1337
|
this.id = options.id;
|
|
1328
1338
|
this.agentId = options.agentId;
|
|
@@ -1346,6 +1356,46 @@ var FixtureRunBase = class {
|
|
|
1346
1356
|
this.eventNotifier = makeNotifier();
|
|
1347
1357
|
current.resolve();
|
|
1348
1358
|
}
|
|
1359
|
+
/**
|
|
1360
|
+
* theokit#140 - every event of this run, in true order, from ONE source.
|
|
1361
|
+
*
|
|
1362
|
+
* ## The defect this replaces
|
|
1363
|
+
*
|
|
1364
|
+
* A consumer that needed tool calls interleaved with tokens had to fuse two surfaces by hand:
|
|
1365
|
+
* `stream()`, which was batched and post-completion, and `SendOptions.onDelta`, which was live.
|
|
1366
|
+
* Neither was complete alone - `onDelta` has no `run_started`/`system`, and `stream()` had no
|
|
1367
|
+
* token granularity - so the entire reconciliation, including its dedup, lived in the consumer.
|
|
1368
|
+
* `@theokit/agents` carried ~200 lines of exactly that, and it is the documented root of its
|
|
1369
|
+
* ordering bug (theokit#47), its namespace-dedup bug (#138) and its missing terminal frame (#142).
|
|
1370
|
+
*
|
|
1371
|
+
* The ordering is not reconstructed here. Both kinds are appended by the loop AS THEY HAPPEN, so
|
|
1372
|
+
* arrival order IS model order - there is nothing to sort, and no timestamp heuristic to get
|
|
1373
|
+
* wrong.
|
|
1374
|
+
*
|
|
1375
|
+
* `callId` is whatever the SDK's own `tool_call` events carry, so a consumer no longer holds two
|
|
1376
|
+
* id namespaces and no longer has to correlate them.
|
|
1377
|
+
*/
|
|
1378
|
+
async *events() {
|
|
1379
|
+
let index = 0;
|
|
1380
|
+
while (!this.terminated) {
|
|
1381
|
+
while (index < this.timeline.length) {
|
|
1382
|
+
yield this.timeline[index++];
|
|
1383
|
+
}
|
|
1384
|
+
if (this.terminated) break;
|
|
1385
|
+
await Promise.race([this.eventNotifier.promise, this.terminationPromise]);
|
|
1386
|
+
}
|
|
1387
|
+
while (index < this.timeline.length) {
|
|
1388
|
+
yield this.timeline[index++];
|
|
1389
|
+
}
|
|
1390
|
+
for await (const message of this.terminalErrorEvent()) {
|
|
1391
|
+
yield { kind: "message", message };
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
/** theokit#140 - append to the timeline and wake `events()`. */
|
|
1395
|
+
pushTimeline(event) {
|
|
1396
|
+
this.timeline.push(event);
|
|
1397
|
+
this.notifyNewEvents();
|
|
1398
|
+
}
|
|
1349
1399
|
async *stream() {
|
|
1350
1400
|
let index = 0;
|
|
1351
1401
|
while (!this.terminated) {
|
|
@@ -1361,22 +1411,22 @@ var FixtureRunBase = class {
|
|
|
1361
1411
|
yield* this.terminalErrorEvent();
|
|
1362
1412
|
}
|
|
1363
1413
|
/**
|
|
1364
|
-
* theokit#101 —
|
|
1414
|
+
* theokit#101 — when the run ends in error, `stream()` has to SAY SO.
|
|
1365
1415
|
*
|
|
1366
|
-
*
|
|
1367
|
-
* `status: 'error'`
|
|
1368
|
-
* `script.events`
|
|
1369
|
-
*
|
|
1416
|
+
* The error always existed: the loop records it in `ctx.error` and `wait()` returns
|
|
1417
|
+
* `status: 'error'` with the message. Only `stream()` failed to mention it — it drains
|
|
1418
|
+
* `script.events` and stops. A provider failure (404 "No endpoints found", auth, timeout)
|
|
1419
|
+
* produced a turn that looked successful and empty, on EVERY surface consuming the
|
|
1370
1420
|
* stream: HTTP web, MCP, stdio, TUI in-process.
|
|
1371
1421
|
*
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1374
|
-
*
|
|
1422
|
+
* A silent error is the worst kind (Unbreakable Rule 8). And the asymmetry was what made it
|
|
1423
|
+
* hard to diagnose: anyone debugging via `wait()` saw the error and would not reproduce the
|
|
1424
|
+
* report of anyone debugging via the stream.
|
|
1375
1425
|
*
|
|
1376
|
-
*
|
|
1377
|
-
*
|
|
1378
|
-
*
|
|
1379
|
-
*
|
|
1426
|
+
* It emits `SDKStatusMessage` with `status: "ERROR"` — the type ALREADY EXISTS in the `SDKMessage` union
|
|
1427
|
+
* and is already expected by consumers. A new type would be breaking for every consumer doing
|
|
1428
|
+
* an exhaustive switch; this one is additive, and a consumer ignoring `status` simply
|
|
1429
|
+
* behaves as before — never worse than today.
|
|
1380
1430
|
*/
|
|
1381
1431
|
*terminalErrorEvent() {
|
|
1382
1432
|
if (this.status !== "error") return;
|
|
@@ -1386,7 +1436,7 @@ var FixtureRunBase = class {
|
|
|
1386
1436
|
agent_id: this.agentId,
|
|
1387
1437
|
run_id: this.id,
|
|
1388
1438
|
status: "ERROR",
|
|
1389
|
-
//
|
|
1439
|
+
// Without a message, the consumer knows THAT it failed and not WHAT — which is half the defect.
|
|
1390
1440
|
...detail?.message !== void 0 ? { message: detail.message } : {}
|
|
1391
1441
|
};
|
|
1392
1442
|
}
|
|
@@ -1565,7 +1615,7 @@ function createRealCloudRun(options) {
|
|
|
1565
1615
|
conversation: []
|
|
1566
1616
|
};
|
|
1567
1617
|
const apiKey = resolveApiKey(options.agentOptions.apiKey);
|
|
1568
|
-
const baseUrl =
|
|
1618
|
+
const baseUrl = chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl();
|
|
1569
1619
|
const handle = new RealCloudRun(
|
|
1570
1620
|
{
|
|
1571
1621
|
id,
|
|
@@ -1638,7 +1688,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1638
1688
|
});
|
|
1639
1689
|
if (!response.ok) {
|
|
1640
1690
|
const text = await response.text().catch(() => "");
|
|
1641
|
-
throw new
|
|
1691
|
+
throw new chunkA3MHE2MQ_cjs.NetworkError(
|
|
1642
1692
|
`Cloud Run endpoint returned ${response.status}: ${text.slice(0, 200)}`,
|
|
1643
1693
|
{ code: "cloud_run_http_error" }
|
|
1644
1694
|
);
|
|
@@ -1648,7 +1698,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1648
1698
|
async consumeStream(response) {
|
|
1649
1699
|
let finalStatus = "finished";
|
|
1650
1700
|
let finalText = "";
|
|
1651
|
-
for await (const record of
|
|
1701
|
+
for await (const record of chunkG7X2Y7Y2_cjs.parseSseStream(response.body, this.controller.signal)) {
|
|
1652
1702
|
const parsed = safeParse(record.data);
|
|
1653
1703
|
if (parsed === void 0) continue;
|
|
1654
1704
|
const update = this.applyRecord(record.event, parsed);
|
|
@@ -1757,7 +1807,7 @@ var CloudAgent = class {
|
|
|
1757
1807
|
*/
|
|
1758
1808
|
isFixtureMode() {
|
|
1759
1809
|
const apiKey = resolveApiKey(this.options.apiKey);
|
|
1760
|
-
return
|
|
1810
|
+
return chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) && chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl() === void 0;
|
|
1761
1811
|
}
|
|
1762
1812
|
// SE9 — integrated structured output; delegates to the shared helper.
|
|
1763
1813
|
generate(message, options) {
|
|
@@ -1772,7 +1822,7 @@ var CloudAgent = class {
|
|
|
1772
1822
|
}
|
|
1773
1823
|
async send(message, options = {}) {
|
|
1774
1824
|
if (options.tools !== void 0 && options.tools.length > 0) {
|
|
1775
|
-
throw new
|
|
1825
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
1776
1826
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
1777
1827
|
{ code: "cloud_custom_tools_rejected" }
|
|
1778
1828
|
);
|
|
@@ -1808,7 +1858,7 @@ var CloudAgent = class {
|
|
|
1808
1858
|
const userText = typeof message === "string" ? message : message.text;
|
|
1809
1859
|
const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
|
|
1810
1860
|
const apiKey = resolveApiKey(this.options.apiKey);
|
|
1811
|
-
const useRealRuntime = apiKey !== void 0 && !
|
|
1861
|
+
const useRealRuntime = apiKey !== void 0 && !chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) && chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl() !== void 0;
|
|
1812
1862
|
return useRealRuntime ? createRealCloudRun({
|
|
1813
1863
|
agentId: this.agentId,
|
|
1814
1864
|
model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
|
|
@@ -1857,7 +1907,7 @@ var CloudAgent = class {
|
|
|
1857
1907
|
listArtifacts() {
|
|
1858
1908
|
if (!this.isFixtureMode()) {
|
|
1859
1909
|
return Promise.reject(
|
|
1860
|
-
new
|
|
1910
|
+
new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
1861
1911
|
"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).",
|
|
1862
1912
|
{ code: "cloud_runtime_pre_release" }
|
|
1863
1913
|
)
|
|
@@ -1867,11 +1917,11 @@ var CloudAgent = class {
|
|
|
1867
1917
|
}
|
|
1868
1918
|
downloadArtifact(path) {
|
|
1869
1919
|
try {
|
|
1870
|
-
|
|
1920
|
+
chunkQJQ2MAZF_cjs.validateArtifactPath(path);
|
|
1871
1921
|
} catch (cause) {
|
|
1872
|
-
if (cause instanceof
|
|
1922
|
+
if (cause instanceof chunkQJQ2MAZF_cjs.PathTraversalError) {
|
|
1873
1923
|
return Promise.reject(
|
|
1874
|
-
new
|
|
1924
|
+
new chunkA3MHE2MQ_cjs.ConfigurationError(`Artifact path must stay inside the workspace: ${path}`, {
|
|
1875
1925
|
code: "artifact_path_traversal",
|
|
1876
1926
|
cause
|
|
1877
1927
|
})
|
|
@@ -1881,7 +1931,7 @@ var CloudAgent = class {
|
|
|
1881
1931
|
}
|
|
1882
1932
|
if (!this.isFixtureMode()) {
|
|
1883
1933
|
return Promise.reject(
|
|
1884
|
-
new
|
|
1934
|
+
new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
1885
1935
|
"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).",
|
|
1886
1936
|
{ code: "cloud_runtime_pre_release" }
|
|
1887
1937
|
)
|
|
@@ -1890,7 +1940,7 @@ var CloudAgent = class {
|
|
|
1890
1940
|
const match = buildFixtureArtifacts().find((artifact) => artifact.path === path);
|
|
1891
1941
|
if (match === void 0) {
|
|
1892
1942
|
return Promise.reject(
|
|
1893
|
-
new
|
|
1943
|
+
new chunkA3MHE2MQ_cjs.UnknownAgentError(`Artifact ${path} not found`, { code: "unknown_artifact" })
|
|
1894
1944
|
);
|
|
1895
1945
|
}
|
|
1896
1946
|
return Promise.resolve(Buffer.from(`fixture artifact content for ${path}
|
|
@@ -1904,7 +1954,7 @@ var CloudAgent = class {
|
|
|
1904
1954
|
* @public
|
|
1905
1955
|
*/
|
|
1906
1956
|
runUntil() {
|
|
1907
|
-
throw new
|
|
1957
|
+
throw new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
|
|
1908
1958
|
"Agent.runUntil() is not supported on cloud agents. Cloud runtime manages goal loops server-side. Use a local agent for autonomous Ralph loops.",
|
|
1909
1959
|
"runUntil"
|
|
1910
1960
|
);
|
|
@@ -1915,7 +1965,7 @@ var CloudAgent = class {
|
|
|
1915
1965
|
* @public
|
|
1916
1966
|
*/
|
|
1917
1967
|
fork() {
|
|
1918
|
-
throw new
|
|
1968
|
+
throw new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
|
|
1919
1969
|
"Agent.fork() is not supported on cloud agents. Fork inheritance requires local credential + system-prompt access. Use a local agent.",
|
|
1920
1970
|
"fork"
|
|
1921
1971
|
);
|
|
@@ -1927,7 +1977,7 @@ var CloudAgent = class {
|
|
|
1927
1977
|
* @public
|
|
1928
1978
|
*/
|
|
1929
1979
|
runToCompletion() {
|
|
1930
|
-
throw new
|
|
1980
|
+
throw new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
|
|
1931
1981
|
"Agent.runToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
1932
1982
|
"runToCompletion"
|
|
1933
1983
|
);
|
|
@@ -1939,7 +1989,7 @@ var CloudAgent = class {
|
|
|
1939
1989
|
* @public
|
|
1940
1990
|
*/
|
|
1941
1991
|
streamToCompletion() {
|
|
1942
|
-
throw new
|
|
1992
|
+
throw new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
|
|
1943
1993
|
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
1944
1994
|
"streamToCompletion"
|
|
1945
1995
|
);
|
|
@@ -1953,7 +2003,7 @@ var CloudAgent = class {
|
|
|
1953
2003
|
*/
|
|
1954
2004
|
usePersonality() {
|
|
1955
2005
|
return Promise.reject(
|
|
1956
|
-
new
|
|
2006
|
+
new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
|
|
1957
2007
|
"Agent.usePersonality() is not supported on cloud agents (pre-release). Use a local agent or wait for cloud GA.",
|
|
1958
2008
|
"usePersonality"
|
|
1959
2009
|
)
|
|
@@ -1981,7 +2031,7 @@ function validateCloudToolParity(options) {
|
|
|
1981
2031
|
function rejectProcessors(options) {
|
|
1982
2032
|
const hasProcessors = (options.inputProcessors?.length ?? 0) > 0 || (options.outputProcessors?.length ?? 0) > 0;
|
|
1983
2033
|
if (hasProcessors) {
|
|
1984
|
-
throw new
|
|
2034
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
1985
2035
|
"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.",
|
|
1986
2036
|
{ code: "cloud_incompatible_function_resolver" }
|
|
1987
2037
|
);
|
|
@@ -1989,7 +2039,7 @@ function rejectProcessors(options) {
|
|
|
1989
2039
|
}
|
|
1990
2040
|
function rejectFunctionSystemPrompt(options) {
|
|
1991
2041
|
if (typeof options.systemPrompt === "function") {
|
|
1992
|
-
throw new
|
|
2042
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
1993
2043
|
"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.",
|
|
1994
2044
|
{ code: "cloud_incompatible_function_resolver" }
|
|
1995
2045
|
);
|
|
@@ -1997,7 +2047,7 @@ function rejectFunctionSystemPrompt(options) {
|
|
|
1997
2047
|
}
|
|
1998
2048
|
function rejectFunctionSkills(options) {
|
|
1999
2049
|
if (typeof options.skills === "function") {
|
|
2000
|
-
throw new
|
|
2050
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
2001
2051
|
"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.",
|
|
2002
2052
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2003
2053
|
);
|
|
@@ -2009,7 +2059,7 @@ function rejectStdioMcpLocalPaths(options) {
|
|
|
2009
2059
|
if (!isStdioCommandConfig(config)) continue;
|
|
2010
2060
|
const command = config.command ?? "";
|
|
2011
2061
|
if (isLocalPath(command)) {
|
|
2012
|
-
throw new
|
|
2062
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
2013
2063
|
`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.`,
|
|
2014
2064
|
{ code: "cloud_incompatible_mcp_stdio_local" }
|
|
2015
2065
|
);
|
|
@@ -2049,14 +2099,14 @@ async function readState(filePath) {
|
|
|
2049
2099
|
try {
|
|
2050
2100
|
parsed = JSON.parse(raw);
|
|
2051
2101
|
} catch {
|
|
2052
|
-
|
|
2102
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
2053
2103
|
"personality-store-json-parse",
|
|
2054
2104
|
"[theokit-sdk] personality.json is malformed; treating as empty"
|
|
2055
2105
|
);
|
|
2056
2106
|
return emptyState();
|
|
2057
2107
|
}
|
|
2058
2108
|
if (!isStateV1(parsed)) {
|
|
2059
|
-
|
|
2109
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
2060
2110
|
"personality-store-bad-version",
|
|
2061
2111
|
`[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
|
|
2062
2112
|
);
|
|
@@ -2087,9 +2137,9 @@ var PersonalityStore = class {
|
|
|
2087
2137
|
try {
|
|
2088
2138
|
await this.#persist(agentId, slug);
|
|
2089
2139
|
} catch (err) {
|
|
2090
|
-
|
|
2140
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
2091
2141
|
`personality-store-persist-failure-${agentId}`,
|
|
2092
|
-
`[theokit-sdk] personality persist failed for ${
|
|
2142
|
+
`[theokit-sdk] personality persist failed for ${chunkBE3W4HYV_cjs.redactSecrets(agentId)}: ${chunkBE3W4HYV_cjs.redactSecrets(
|
|
2093
2143
|
err.message
|
|
2094
2144
|
)}`
|
|
2095
2145
|
);
|
|
@@ -2104,9 +2154,9 @@ var PersonalityStore = class {
|
|
|
2104
2154
|
try {
|
|
2105
2155
|
state = await readState(filePath);
|
|
2106
2156
|
} catch (err) {
|
|
2107
|
-
|
|
2157
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
2108
2158
|
`personality-store-hydrate-failure-${agentId}`,
|
|
2109
|
-
`[theokit-sdk] personality hydrate failed for ${
|
|
2159
|
+
`[theokit-sdk] personality hydrate failed for ${chunkBE3W4HYV_cjs.redactSecrets(agentId)}: ${chunkBE3W4HYV_cjs.redactSecrets(
|
|
2110
2160
|
err.message
|
|
2111
2161
|
)}`
|
|
2112
2162
|
);
|
|
@@ -2123,17 +2173,17 @@ var PersonalityStore = class {
|
|
|
2123
2173
|
async #persist(agentId, slug) {
|
|
2124
2174
|
const filePath = this.#filePath();
|
|
2125
2175
|
await promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
2126
|
-
await
|
|
2176
|
+
await chunkZET34IZE_cjs.withFileLock(filePath, async () => {
|
|
2127
2177
|
const current = await readState(filePath);
|
|
2128
2178
|
const nextAgents = { ...current.agents };
|
|
2129
2179
|
if (slug === void 0) delete nextAgents[agentId];
|
|
2130
2180
|
else nextAgents[agentId] = slug;
|
|
2131
2181
|
const next = { version: SCHEMA_VERSION2, agents: nextAgents };
|
|
2132
|
-
await
|
|
2182
|
+
await chunkYVI4YPUP_cjs.atomicWriteJson(filePath, next);
|
|
2133
2183
|
});
|
|
2134
2184
|
}
|
|
2135
2185
|
#filePath() {
|
|
2136
|
-
return path.join(
|
|
2186
|
+
return path.join(chunk2K7PRHDB_cjs.getTheokitHome(this.#cwd), FILE_NAME);
|
|
2137
2187
|
}
|
|
2138
2188
|
};
|
|
2139
2189
|
|
|
@@ -2156,7 +2206,7 @@ function createPluginContext() {
|
|
|
2156
2206
|
},
|
|
2157
2207
|
on(hook, handler) {
|
|
2158
2208
|
if (typeof handler !== "function") {
|
|
2159
|
-
|
|
2209
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] ignoring non-function handler for hook "${hook}"
|
|
2160
2210
|
`);
|
|
2161
2211
|
return;
|
|
2162
2212
|
}
|
|
@@ -2209,7 +2259,7 @@ var PluginManager = class {
|
|
|
2209
2259
|
const seen = /* @__PURE__ */ new Set();
|
|
2210
2260
|
for (const plugin of plugins) {
|
|
2211
2261
|
if (seen.has(plugin.name)) {
|
|
2212
|
-
|
|
2262
|
+
chunkBE3W4HYV_cjs.diag(
|
|
2213
2263
|
`[theokit-sdk] duplicate plugin name "${plugin.name}" \u2014 both will register independently
|
|
2214
2264
|
`
|
|
2215
2265
|
);
|
|
@@ -2236,7 +2286,7 @@ var PluginManager = class {
|
|
|
2236
2286
|
*/
|
|
2237
2287
|
async register(plugin) {
|
|
2238
2288
|
if (plugin.kind !== "general") {
|
|
2239
|
-
throw new
|
|
2289
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
2240
2290
|
`late register supports general plugins only (got "${plugin.kind}" for "${plugin.name}")`,
|
|
2241
2291
|
{ code: "plugin_late_register_kind" }
|
|
2242
2292
|
);
|
|
@@ -2293,7 +2343,7 @@ var PluginManager = class {
|
|
|
2293
2343
|
parts.push(result.recalledContext);
|
|
2294
2344
|
}
|
|
2295
2345
|
} catch (err) {
|
|
2296
|
-
|
|
2346
|
+
chunkBE3W4HYV_cjs.diag(
|
|
2297
2347
|
`[theokit-sdk] pre_user_send hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2298
2348
|
`
|
|
2299
2349
|
);
|
|
@@ -2321,7 +2371,7 @@ var PluginManager = class {
|
|
|
2321
2371
|
try {
|
|
2322
2372
|
await h(ctx);
|
|
2323
2373
|
} catch (err) {
|
|
2324
|
-
|
|
2374
|
+
chunkBE3W4HYV_cjs.diag(
|
|
2325
2375
|
`[theokit-sdk] post_assistant_reply hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2326
2376
|
`
|
|
2327
2377
|
);
|
|
@@ -2337,7 +2387,7 @@ var PluginManager = class {
|
|
|
2337
2387
|
try {
|
|
2338
2388
|
await h(ctx);
|
|
2339
2389
|
} catch (err) {
|
|
2340
|
-
|
|
2390
|
+
chunkBE3W4HYV_cjs.diag(
|
|
2341
2391
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2342
2392
|
`
|
|
2343
2393
|
);
|
|
@@ -2352,7 +2402,7 @@ var PluginManager = class {
|
|
|
2352
2402
|
const out = await h(current, ctx);
|
|
2353
2403
|
if (out !== void 0) current = out;
|
|
2354
2404
|
} catch (err) {
|
|
2355
|
-
|
|
2405
|
+
chunkBE3W4HYV_cjs.diag(
|
|
2356
2406
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2357
2407
|
`
|
|
2358
2408
|
);
|
|
@@ -2494,7 +2544,7 @@ var HooksExecutor = class {
|
|
|
2494
2544
|
this.config = {};
|
|
2495
2545
|
return;
|
|
2496
2546
|
}
|
|
2497
|
-
this.config = await
|
|
2547
|
+
this.config = await chunkM4OGSS66_cjs.loadHookConfig(this.cwd);
|
|
2498
2548
|
}
|
|
2499
2549
|
/** Fire every hook registered for `event` and aggregate the decisions. */
|
|
2500
2550
|
async run(payload) {
|
|
@@ -2600,11 +2650,11 @@ function buildContextBudgetEvent(model, resolved) {
|
|
|
2600
2650
|
// src/internal/runtime/lifecycle/post-run-lifecycle.ts
|
|
2601
2651
|
function resolveWindowForRun(model, contextWindow) {
|
|
2602
2652
|
const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
|
|
2603
|
-
return
|
|
2653
|
+
return chunkIBDE4R5L_cjs.resolveEffectiveContextWindow({
|
|
2604
2654
|
...override !== void 0 ? { override } : {},
|
|
2605
|
-
catalog:
|
|
2606
|
-
margin:
|
|
2607
|
-
floor:
|
|
2655
|
+
catalog: chunk4MWBKBS4_cjs.getCatalogModelInfo(model)?.limit?.context,
|
|
2656
|
+
margin: chunkIBDE4R5L_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2657
|
+
floor: chunkIBDE4R5L_cjs.CONTEXT_WINDOW_FLOOR
|
|
2608
2658
|
});
|
|
2609
2659
|
}
|
|
2610
2660
|
async function runPostRunLifecycle(inputs) {
|
|
@@ -2628,32 +2678,32 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2628
2678
|
try {
|
|
2629
2679
|
const parcial = await safeConversation(run);
|
|
2630
2680
|
if (parcial !== void 0) {
|
|
2631
|
-
|
|
2681
|
+
chunk6ZGD7R27_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2632
2682
|
userText,
|
|
2633
2683
|
conversation: parcial
|
|
2634
2684
|
});
|
|
2635
2685
|
}
|
|
2636
2686
|
} catch (cause) {
|
|
2637
2687
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2638
|
-
|
|
2688
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2639
2689
|
`);
|
|
2640
2690
|
}
|
|
2641
|
-
await
|
|
2691
|
+
await chunk6ZGD7R27_cjs.flushSessionWrites();
|
|
2642
2692
|
return;
|
|
2643
2693
|
}
|
|
2644
2694
|
if (result.result !== void 0) {
|
|
2645
|
-
|
|
2695
|
+
chunk6ZGD7R27_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2646
2696
|
}
|
|
2647
2697
|
const conversation = await safeConversation(run);
|
|
2648
2698
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2649
|
-
const
|
|
2699
|
+
const effectiveWindow = resolvedWindow.window;
|
|
2650
2700
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2651
2701
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2652
|
-
|
|
2702
|
+
chunk3MUIYMUG_cjs.emitRunEvent(onRunEvent, budgetEvent);
|
|
2653
2703
|
}
|
|
2654
2704
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2655
2705
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2656
|
-
|
|
2706
|
+
chunk6ZGD7R27_cjs.persistTurnToTranscript(
|
|
2657
2707
|
sessionStore,
|
|
2658
2708
|
{ cwd: workspaceCwd, agentId, model },
|
|
2659
2709
|
agentId,
|
|
@@ -2662,16 +2712,16 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2662
2712
|
conversation,
|
|
2663
2713
|
autoCompact: {
|
|
2664
2714
|
usageTotal: usageForTrigger,
|
|
2665
|
-
//
|
|
2666
|
-
// `contextWindow`
|
|
2667
|
-
contextWindow:
|
|
2668
|
-
summarize:
|
|
2715
|
+
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2716
|
+
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2717
|
+
contextWindow: effectiveWindow,
|
|
2718
|
+
summarize: chunkG7X2Y7Y2_cjs.buildDefaultSummarizer({
|
|
2669
2719
|
agentModel: model,
|
|
2670
2720
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2671
2721
|
})
|
|
2672
2722
|
}
|
|
2673
2723
|
},
|
|
2674
|
-
onRunEvent !== void 0 ? () =>
|
|
2724
|
+
onRunEvent !== void 0 ? () => chunk3MUIYMUG_cjs.emitRunEvent(onRunEvent, { type: "compact_boundary", trigger: "auto" }) : void 0
|
|
2675
2725
|
);
|
|
2676
2726
|
if (result.status === "finished" && result.result !== void 0) {
|
|
2677
2727
|
const summaryArgs = {
|
|
@@ -2687,14 +2737,14 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2687
2737
|
if (memoryProvider?.recordSessionSummary !== void 0) {
|
|
2688
2738
|
await memoryProvider.recordSessionSummary(summaryArgs);
|
|
2689
2739
|
} else {
|
|
2690
|
-
await
|
|
2740
|
+
await chunk3BSP7LSG_cjs.writeSessionSummary(summaryArgs);
|
|
2691
2741
|
}
|
|
2692
2742
|
if (!shouldUsePortMemoryPath()) {
|
|
2693
2743
|
void memoryGlue.syncIfReady();
|
|
2694
2744
|
}
|
|
2695
2745
|
} catch (cause) {
|
|
2696
2746
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2697
|
-
|
|
2747
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] session summary write failed (${result.id}): ${message}
|
|
2698
2748
|
`);
|
|
2699
2749
|
}
|
|
2700
2750
|
}
|
|
@@ -2707,7 +2757,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2707
2757
|
agentId,
|
|
2708
2758
|
runId: result.id
|
|
2709
2759
|
});
|
|
2710
|
-
await
|
|
2760
|
+
await chunk6ZGD7R27_cjs.flushSessionWrites();
|
|
2711
2761
|
}
|
|
2712
2762
|
async function safeConversation(run) {
|
|
2713
2763
|
try {
|
|
@@ -2782,7 +2832,7 @@ var warned = /* @__PURE__ */ new Set();
|
|
|
2782
2832
|
function warnDoubleReasoningOnce() {
|
|
2783
2833
|
if (warned.has("double-reasoning")) return;
|
|
2784
2834
|
warned.add("double-reasoning");
|
|
2785
|
-
|
|
2835
|
+
chunkBE3W4HYV_cjs.diag(
|
|
2786
2836
|
"[theokit-sdk] `reasoning: true` skipped \u2014 a native reasoning model is configured (model.params thinking/reasoning); native reasoning wins. Remove one to silence.\n"
|
|
2787
2837
|
);
|
|
2788
2838
|
}
|
|
@@ -2815,9 +2865,9 @@ var SkillsManager = class {
|
|
|
2815
2865
|
}
|
|
2816
2866
|
async refresh() {
|
|
2817
2867
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
2818
|
-
const discovered = await
|
|
2868
|
+
const discovered = await chunkR4AMI7KD_cjs.discoverSkills(skillsRoot, {
|
|
2819
2869
|
onInvalidSkill: (info) => {
|
|
2820
|
-
|
|
2870
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
2821
2871
|
`);
|
|
2822
2872
|
}
|
|
2823
2873
|
});
|
|
@@ -2841,7 +2891,7 @@ var SkillsManager = class {
|
|
|
2841
2891
|
async get(name) {
|
|
2842
2892
|
const skill = this.skills.find((s) => s.name === name);
|
|
2843
2893
|
if (skill === void 0) return void 0;
|
|
2844
|
-
const instructions = typeof skill.instructions === "string" ? skill.instructions :
|
|
2894
|
+
const instructions = typeof skill.instructions === "string" ? skill.instructions : chunkR4AMI7KD_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
|
|
2845
2895
|
const references = skill.references;
|
|
2846
2896
|
return {
|
|
2847
2897
|
name: skill.name,
|
|
@@ -2927,7 +2977,7 @@ async function safeCall(fn, fallback, label = "safeCall") {
|
|
|
2927
2977
|
return await fn();
|
|
2928
2978
|
} catch (cause) {
|
|
2929
2979
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2930
|
-
|
|
2980
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] ${label} failed: ${message}
|
|
2931
2981
|
`);
|
|
2932
2982
|
return fallback;
|
|
2933
2983
|
}
|
|
@@ -2941,7 +2991,7 @@ var ActiveMemoryPromptProvider = class {
|
|
|
2941
2991
|
if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
|
|
2942
2992
|
return Promise.resolve(void 0);
|
|
2943
2993
|
}
|
|
2944
|
-
const body =
|
|
2994
|
+
const body = chunkR4AMI7KD_cjs.escapeBlockBody(ctx.activeMemorySummary);
|
|
2945
2995
|
return Promise.resolve(`<active-memory>
|
|
2946
2996
|
${body}
|
|
2947
2997
|
</active-memory>`);
|
|
@@ -2994,7 +3044,7 @@ function formatSource(name, tokens) {
|
|
|
2994
3044
|
if (tokens.length === 0) {
|
|
2995
3045
|
return ` <source name="${escapeAttribute(name)}" />`;
|
|
2996
3046
|
}
|
|
2997
|
-
const body =
|
|
3047
|
+
const body = chunkR4AMI7KD_cjs.escapeBlockBody(tokens.join(" "));
|
|
2998
3048
|
return ` <source name="${escapeAttribute(name)}">
|
|
2999
3049
|
${body}
|
|
3000
3050
|
</source>`;
|
|
@@ -3010,7 +3060,7 @@ var MemoryPromptProvider = class {
|
|
|
3010
3060
|
contribute(ctx) {
|
|
3011
3061
|
if (ctx.memoryAutoInject === false) return Promise.resolve(void 0);
|
|
3012
3062
|
if (ctx.memory.length === 0) return Promise.resolve(void 0);
|
|
3013
|
-
const lines = ctx.memory.map((fact) => ` - ${
|
|
3063
|
+
const lines = ctx.memory.map((fact) => ` - ${chunkR4AMI7KD_cjs.escapeBlockBody(fact.text)}`);
|
|
3014
3064
|
return Promise.resolve(`<memory>
|
|
3015
3065
|
${lines.join("\n")}
|
|
3016
3066
|
</memory>`);
|
|
@@ -3032,7 +3082,7 @@ var SkillsPromptProvider = class {
|
|
|
3032
3082
|
priority = 20;
|
|
3033
3083
|
contribute(ctx) {
|
|
3034
3084
|
if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
|
|
3035
|
-
return Promise.resolve(
|
|
3085
|
+
return Promise.resolve(chunkR4AMI7KD_cjs.buildSkillsBlock(ctx.skills));
|
|
3036
3086
|
}
|
|
3037
3087
|
};
|
|
3038
3088
|
|
|
@@ -3044,7 +3094,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
|
|
|
3044
3094
|
for (const p of providers) {
|
|
3045
3095
|
const key = `${p.priority}:${p.id}`;
|
|
3046
3096
|
if (seen.has(key)) {
|
|
3047
|
-
throw new
|
|
3097
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Duplicate system-prompt provider ${key}`, {
|
|
3048
3098
|
code: "pipeline_duplicate_provider"
|
|
3049
3099
|
});
|
|
3050
3100
|
}
|
|
@@ -3091,7 +3141,7 @@ function validateAgentOptions(options) {
|
|
|
3091
3141
|
ensureRuntimeShape(options);
|
|
3092
3142
|
if (options.local !== void 0) {
|
|
3093
3143
|
if (options.model === void 0) {
|
|
3094
|
-
throw new
|
|
3144
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError("Local agents require a model selection", {
|
|
3095
3145
|
code: "missing_model"
|
|
3096
3146
|
});
|
|
3097
3147
|
}
|
|
@@ -3115,7 +3165,7 @@ function validateCredentialPoolShape(options) {
|
|
|
3115
3165
|
([, arr]) => Array.isArray(arr) && arr.some((k) => typeof k === "string" && k.length > 0)
|
|
3116
3166
|
);
|
|
3117
3167
|
if (populated.length === 0) return;
|
|
3118
|
-
throw new
|
|
3168
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3119
3169
|
"Ambiguous credential configuration: use either `apiKey: '...'` (single-key, simplest) OR `apiKeys: { provider: [...] }` (multi-key pool), not both.",
|
|
3120
3170
|
{ code: "credential_pool_ambiguous" }
|
|
3121
3171
|
);
|
|
@@ -3124,7 +3174,7 @@ function validatePlugins(options) {
|
|
|
3124
3174
|
const plugins = options.plugins;
|
|
3125
3175
|
if (plugins?.paths === void 0) return;
|
|
3126
3176
|
if (options.cloud !== void 0 && plugins.paths.length > 0) {
|
|
3127
|
-
throw new
|
|
3177
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3128
3178
|
"Cloud agents require committed plugin manifests; local plugin paths are not supported",
|
|
3129
3179
|
{ code: "cloud_plugin_path_rejected" }
|
|
3130
3180
|
);
|
|
@@ -3132,7 +3182,7 @@ function validatePlugins(options) {
|
|
|
3132
3182
|
}
|
|
3133
3183
|
function ensureRuntimeShape(options) {
|
|
3134
3184
|
if (options.local !== void 0 && options.cloud !== void 0) {
|
|
3135
|
-
throw new
|
|
3185
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3136
3186
|
"Pass either local or cloud \u2014 they are mutually exclusive runtimes",
|
|
3137
3187
|
{ code: "runtime_exclusive" }
|
|
3138
3188
|
);
|
|
@@ -3140,7 +3190,7 @@ function ensureRuntimeShape(options) {
|
|
|
3140
3190
|
}
|
|
3141
3191
|
function rejectProgrammaticHooks(options) {
|
|
3142
3192
|
if (options.hooks !== void 0) {
|
|
3143
|
-
throw new
|
|
3193
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3144
3194
|
"Programmatic hooks are not supported \u2014 hooks are file-based only (.theokit/hooks.json)",
|
|
3145
3195
|
{ code: "programmatic_hooks_rejected" }
|
|
3146
3196
|
);
|
|
@@ -3150,7 +3200,7 @@ function validateCloud(cloud) {
|
|
|
3150
3200
|
if (cloud.envVars !== void 0) {
|
|
3151
3201
|
for (const key of Object.keys(cloud.envVars)) {
|
|
3152
3202
|
if (key.startsWith("THEOKIT_")) {
|
|
3153
|
-
throw new
|
|
3203
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3154
3204
|
`Cloud envVars cannot use the reserved THEOKIT_ prefix (got "${key}")`,
|
|
3155
3205
|
{ code: "reserved_env_prefix" }
|
|
3156
3206
|
);
|
|
@@ -3162,7 +3212,7 @@ function validateMcpServers(options) {
|
|
|
3162
3212
|
if (options.mcpServers === void 0) return;
|
|
3163
3213
|
for (const [name, config] of Object.entries(options.mcpServers)) {
|
|
3164
3214
|
if (options.cloud !== void 0 && isStdioWithCwd(config)) {
|
|
3165
|
-
throw new
|
|
3215
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3166
3216
|
`MCP server "${name}" uses stdio with cwd, which is rejected for cloud agents`,
|
|
3167
3217
|
{ code: "cloud_stdio_cwd_rejected" }
|
|
3168
3218
|
);
|
|
@@ -3181,12 +3231,12 @@ function validateSubagents(agents2) {
|
|
|
3181
3231
|
if (agents2 === void 0) return;
|
|
3182
3232
|
for (const [name, definition] of Object.entries(agents2)) {
|
|
3183
3233
|
if (typeof definition.description !== "string" || definition.description.length === 0) {
|
|
3184
|
-
throw new
|
|
3234
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty description`, {
|
|
3185
3235
|
code: "subagent_missing_description"
|
|
3186
3236
|
});
|
|
3187
3237
|
}
|
|
3188
3238
|
if (typeof definition.prompt !== "string" || definition.prompt.length === 0) {
|
|
3189
|
-
throw new
|
|
3239
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty prompt`, {
|
|
3190
3240
|
code: "subagent_missing_prompt"
|
|
3191
3241
|
});
|
|
3192
3242
|
}
|
|
@@ -3199,7 +3249,7 @@ function validateToolCatalog(tools) {
|
|
|
3199
3249
|
for (const tool of tools) {
|
|
3200
3250
|
validateSingleTool(tool);
|
|
3201
3251
|
if (seen.has(tool.name)) {
|
|
3202
|
-
throw new
|
|
3252
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Duplicate custom tool name "${tool.name}"`, {
|
|
3203
3253
|
code: "duplicate_tool_name"
|
|
3204
3254
|
});
|
|
3205
3255
|
}
|
|
@@ -3210,7 +3260,7 @@ function validateCustomTools(options) {
|
|
|
3210
3260
|
const tools = options.tools;
|
|
3211
3261
|
if (tools === void 0 || tools.length === 0) return;
|
|
3212
3262
|
if (options.cloud !== void 0) {
|
|
3213
|
-
throw new
|
|
3263
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3214
3264
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
3215
3265
|
{ code: "cloud_custom_tools_rejected" }
|
|
3216
3266
|
);
|
|
@@ -3222,25 +3272,25 @@ function validateSingleTool(tool) {
|
|
|
3222
3272
|
validateToolDescription(tool);
|
|
3223
3273
|
validateToolSchema(tool);
|
|
3224
3274
|
if (typeof tool.handler !== "function") {
|
|
3225
|
-
throw new
|
|
3275
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a handler function`, {
|
|
3226
3276
|
code: "tool_missing_handler"
|
|
3227
3277
|
});
|
|
3228
3278
|
}
|
|
3229
3279
|
}
|
|
3230
3280
|
function validateToolName(tool) {
|
|
3231
3281
|
if (typeof tool.name !== "string" || tool.name.length === 0) {
|
|
3232
|
-
throw new
|
|
3282
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError("Custom tool requires a non-empty name", {
|
|
3233
3283
|
code: "tool_missing_name"
|
|
3234
3284
|
});
|
|
3235
3285
|
}
|
|
3236
3286
|
if (!TOOL_NAME_PATTERN.test(tool.name)) {
|
|
3237
|
-
throw new
|
|
3287
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3238
3288
|
`Custom tool name "${tool.name}" must match /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/`,
|
|
3239
3289
|
{ code: "tool_invalid_name" }
|
|
3240
3290
|
);
|
|
3241
3291
|
}
|
|
3242
3292
|
if (RESERVED_TOOL_NAMES.has(tool.name) || tool.name.startsWith("mcp_")) {
|
|
3243
|
-
throw new
|
|
3293
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3244
3294
|
`Custom tool name "${tool.name}" collides with a reserved SDK tool name`,
|
|
3245
3295
|
{ code: "tool_reserved_name" }
|
|
3246
3296
|
);
|
|
@@ -3248,7 +3298,7 @@ function validateToolName(tool) {
|
|
|
3248
3298
|
}
|
|
3249
3299
|
function validateToolDescription(tool) {
|
|
3250
3300
|
if (typeof tool.description !== "string" || tool.description.length === 0) {
|
|
3251
|
-
throw new
|
|
3301
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a non-empty description`, {
|
|
3252
3302
|
code: "tool_missing_description"
|
|
3253
3303
|
});
|
|
3254
3304
|
}
|
|
@@ -3256,12 +3306,12 @@ function validateToolDescription(tool) {
|
|
|
3256
3306
|
function validateToolSchema(tool) {
|
|
3257
3307
|
const schema = tool.inputSchema;
|
|
3258
3308
|
if (schema === null || schema === void 0 || typeof schema !== "object") {
|
|
3259
|
-
throw new
|
|
3309
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Custom tool "${tool.name}" requires an inputSchema object`, {
|
|
3260
3310
|
code: "tool_missing_schema"
|
|
3261
3311
|
});
|
|
3262
3312
|
}
|
|
3263
3313
|
if (schema.type !== "object") {
|
|
3264
|
-
throw new
|
|
3314
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3265
3315
|
`Custom tool "${tool.name}" inputSchema must declare \`type: "object"\``,
|
|
3266
3316
|
{ code: "tool_invalid_schema_type" }
|
|
3267
3317
|
);
|
|
@@ -3272,7 +3322,7 @@ function validateMemory(options) {
|
|
|
3272
3322
|
if (memory?.storePath === void 0) return;
|
|
3273
3323
|
const storePath = memory.storePath;
|
|
3274
3324
|
if (storePath.includes("..") || storePath.startsWith("/") || /^[A-Z]:/i.test(storePath)) {
|
|
3275
|
-
throw new
|
|
3325
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3276
3326
|
`Memory storePath must stay inside the workspace; got "${storePath}"`,
|
|
3277
3327
|
{ code: "memory_path_traversal" }
|
|
3278
3328
|
);
|
|
@@ -3294,7 +3344,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3294
3344
|
};
|
|
3295
3345
|
function safeRequire(moduleName) {
|
|
3296
3346
|
try {
|
|
3297
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3347
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UZBA6YYP.cjs', document.baseURI).href)));
|
|
3298
3348
|
return r(moduleName);
|
|
3299
3349
|
} catch {
|
|
3300
3350
|
return void 0;
|
|
@@ -3373,7 +3423,7 @@ var langfuseAdapter = {
|
|
|
3373
3423
|
}
|
|
3374
3424
|
}
|
|
3375
3425
|
if (lf.LangfuseSpanProcessor === void 0) {
|
|
3376
|
-
|
|
3426
|
+
chunkBE3W4HYV_cjs.diag(
|
|
3377
3427
|
"[theokit-sdk] @langfuse/node detected but LangfuseSpanProcessor not found (v2?). Use Langfuse v3+ for auto-instrumentation.\n"
|
|
3378
3428
|
);
|
|
3379
3429
|
return;
|
|
@@ -3502,11 +3552,11 @@ function tryAutoRegisterAdapters(settings) {
|
|
|
3502
3552
|
try {
|
|
3503
3553
|
adapter.register();
|
|
3504
3554
|
registered.add(adapter.moduleName);
|
|
3505
|
-
|
|
3555
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] telemetry: ${adapter.displayName} auto-instrumented.
|
|
3506
3556
|
`);
|
|
3507
3557
|
} catch (cause) {
|
|
3508
3558
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3509
|
-
|
|
3559
|
+
chunkBE3W4HYV_cjs.diag(
|
|
3510
3560
|
`[theokit-sdk] telemetry: ${adapter.displayName} detected but failed to register: ${message}
|
|
3511
3561
|
`
|
|
3512
3562
|
);
|
|
@@ -3519,7 +3569,7 @@ var cachedOtel;
|
|
|
3519
3569
|
function loadOtel() {
|
|
3520
3570
|
if (cachedOtel === void 0) {
|
|
3521
3571
|
try {
|
|
3522
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3572
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UZBA6YYP.cjs', document.baseURI).href)));
|
|
3523
3573
|
const mod = r("@opentelemetry/api");
|
|
3524
3574
|
cachedOtel = mod;
|
|
3525
3575
|
} catch {
|
|
@@ -3562,7 +3612,7 @@ function safe(op, fallback) {
|
|
|
3562
3612
|
if (!warnedOnce) {
|
|
3563
3613
|
warnedOnce = true;
|
|
3564
3614
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3565
|
-
|
|
3615
|
+
chunkBE3W4HYV_cjs.diag(
|
|
3566
3616
|
`[theokit-sdk] telemetry exporter error (suppressed; agent.send continues): ${message}
|
|
3567
3617
|
`
|
|
3568
3618
|
);
|
|
@@ -3576,7 +3626,7 @@ function createTelemetry(settings) {
|
|
|
3576
3626
|
if (otel === null) {
|
|
3577
3627
|
if (!warnedOnce) {
|
|
3578
3628
|
warnedOnce = true;
|
|
3579
|
-
|
|
3629
|
+
chunkBE3W4HYV_cjs.diag(
|
|
3580
3630
|
"[theokit-sdk] telemetry.enabled = true but `@opentelemetry/api` is not installed; telemetry is a no-op.\n"
|
|
3581
3631
|
);
|
|
3582
3632
|
}
|
|
@@ -3670,12 +3720,12 @@ function wrapSpan(span, openSpans) {
|
|
|
3670
3720
|
}
|
|
3671
3721
|
function redactAttrValue(value) {
|
|
3672
3722
|
if (typeof value !== "string") return value;
|
|
3673
|
-
return
|
|
3723
|
+
return chunkBE3W4HYV_cjs.redactSecrets(value);
|
|
3674
3724
|
}
|
|
3675
3725
|
function redactAttrs(attrs) {
|
|
3676
3726
|
const out = {};
|
|
3677
3727
|
for (const [k, v] of Object.entries(attrs)) {
|
|
3678
|
-
out[k] = typeof v === "string" ?
|
|
3728
|
+
out[k] = typeof v === "string" ? chunkBE3W4HYV_cjs.redactSecrets(v) : v;
|
|
3679
3729
|
}
|
|
3680
3730
|
return out;
|
|
3681
3731
|
}
|
|
@@ -3757,10 +3807,10 @@ async function loadMarkdownEntities(opts) {
|
|
|
3757
3807
|
const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
|
|
3758
3808
|
if (raw === null) continue;
|
|
3759
3809
|
const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
|
|
3760
|
-
const fields =
|
|
3810
|
+
const fields = chunkXKBJT7WI_cjs.parseSimpleYaml(split.frontmatter);
|
|
3761
3811
|
const parsed = schema.safeParse(fields);
|
|
3762
3812
|
if (!parsed.success) {
|
|
3763
|
-
throw new
|
|
3813
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3764
3814
|
`Invalid frontmatter in ${resolved.source}: ${parsed.error.message}`,
|
|
3765
3815
|
{ code: `${errorCodePrefix}_frontmatter_invalid` }
|
|
3766
3816
|
);
|
|
@@ -3778,13 +3828,13 @@ async function assertFileSizeUnderCap(source, errorCodePrefix) {
|
|
|
3778
3828
|
try {
|
|
3779
3829
|
const info = await promises.stat(source);
|
|
3780
3830
|
if (info.size > MAX_MD_FILE_BYTES) {
|
|
3781
|
-
throw new
|
|
3831
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3782
3832
|
`Config file ${source} exceeds 1 MB size limit (${info.size} bytes). Reduce the file or split into multiple entities.`,
|
|
3783
3833
|
{ code: `${errorCodePrefix}_file_too_large` }
|
|
3784
3834
|
);
|
|
3785
3835
|
}
|
|
3786
3836
|
} catch (cause) {
|
|
3787
|
-
if (cause instanceof
|
|
3837
|
+
if (cause instanceof chunkA3MHE2MQ_cjs.ConfigurationError) throw cause;
|
|
3788
3838
|
}
|
|
3789
3839
|
}
|
|
3790
3840
|
async function readDirSafe(dir, errorCodePrefix) {
|
|
@@ -3793,7 +3843,7 @@ async function readDirSafe(dir, errorCodePrefix) {
|
|
|
3793
3843
|
} catch (cause) {
|
|
3794
3844
|
const code = cause.code;
|
|
3795
3845
|
if (code === "ENOENT") return null;
|
|
3796
|
-
throw new
|
|
3846
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Failed to read ${dir}`, {
|
|
3797
3847
|
code: `${errorCodePrefix}_dir_read_error`,
|
|
3798
3848
|
cause
|
|
3799
3849
|
});
|
|
@@ -3810,7 +3860,7 @@ function resolveEntryPath(entry, pattern, dir) {
|
|
|
3810
3860
|
function splitFrontmatter(raw, source, errorCodePrefix) {
|
|
3811
3861
|
const match = /^---\s*\n([\s\S]*?)\n---\s*(?:\n|$)/.exec(raw);
|
|
3812
3862
|
if (match === null) {
|
|
3813
|
-
throw new
|
|
3863
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
3814
3864
|
`Missing or malformed frontmatter in ${source} (expected \`---\` delimited block at file head)`,
|
|
3815
3865
|
{ code: `${errorCodePrefix}_missing_frontmatter` }
|
|
3816
3866
|
);
|
|
@@ -4294,7 +4344,7 @@ async function loadContextConfig(cwd) {
|
|
|
4294
4344
|
});
|
|
4295
4345
|
if (mdEntities.length > 0) {
|
|
4296
4346
|
if (fs.existsSync(jsonPath)) {
|
|
4297
|
-
|
|
4347
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
4298
4348
|
"context-both-present",
|
|
4299
4349
|
"[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
|
|
4300
4350
|
);
|
|
@@ -4304,7 +4354,7 @@ async function loadContextConfig(cwd) {
|
|
|
4304
4354
|
};
|
|
4305
4355
|
}
|
|
4306
4356
|
if (!fs.existsSync(jsonPath)) return { sources: [] };
|
|
4307
|
-
|
|
4357
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
4308
4358
|
"context-json-deprecated",
|
|
4309
4359
|
"[theokit-sdk] .theokit/context.json is deprecated; migrate to .theokit/context/<name>.md via theokit-migrate-config"
|
|
4310
4360
|
);
|
|
@@ -4312,7 +4362,7 @@ async function loadContextConfig(cwd) {
|
|
|
4312
4362
|
try {
|
|
4313
4363
|
raw = await promises.readFile(jsonPath, "utf8");
|
|
4314
4364
|
} catch (cause) {
|
|
4315
|
-
throw new
|
|
4365
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Failed to read context config: ${jsonPath}`, {
|
|
4316
4366
|
code: "context_read_error",
|
|
4317
4367
|
cause
|
|
4318
4368
|
});
|
|
@@ -4324,13 +4374,13 @@ function parseConfig(raw, configPath) {
|
|
|
4324
4374
|
try {
|
|
4325
4375
|
parsed = JSON.parse(raw);
|
|
4326
4376
|
} catch (cause) {
|
|
4327
|
-
throw new
|
|
4377
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Invalid JSON in context config: ${configPath}`, {
|
|
4328
4378
|
code: "context_json_invalid",
|
|
4329
4379
|
cause
|
|
4330
4380
|
});
|
|
4331
4381
|
}
|
|
4332
4382
|
if (!parsed || typeof parsed !== "object") {
|
|
4333
|
-
throw new
|
|
4383
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Context config must be an object: ${configPath}`, {
|
|
4334
4384
|
code: "context_config_shape"
|
|
4335
4385
|
});
|
|
4336
4386
|
}
|
|
@@ -4345,7 +4395,7 @@ function parseConfig(raw, configPath) {
|
|
|
4345
4395
|
}
|
|
4346
4396
|
function readSources(sourcesRaw, configPath) {
|
|
4347
4397
|
if (!Array.isArray(sourcesRaw)) {
|
|
4348
|
-
throw new
|
|
4398
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Context config sources must be an array: ${configPath}`, {
|
|
4349
4399
|
code: "context_sources_shape"
|
|
4350
4400
|
});
|
|
4351
4401
|
}
|
|
@@ -4443,7 +4493,7 @@ var PluginsManager = class {
|
|
|
4443
4493
|
async refresh() {
|
|
4444
4494
|
this.plugins = [];
|
|
4445
4495
|
const pluginsRoot = path.join(this.cwd, ".theokit", "plugins");
|
|
4446
|
-
const entries = await
|
|
4496
|
+
const entries = await chunkXKBJT7WI_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
|
|
4447
4497
|
for (const entry of entries) {
|
|
4448
4498
|
if (!entry.isDirectory()) continue;
|
|
4449
4499
|
const folderName = entry.name;
|
|
@@ -4451,13 +4501,13 @@ var PluginsManager = class {
|
|
|
4451
4501
|
const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
|
|
4452
4502
|
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
|
|
4453
4503
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4454
|
-
|
|
4504
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
4455
4505
|
`plugin-${folderName}-both`,
|
|
4456
4506
|
`[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
|
|
4457
4507
|
);
|
|
4458
4508
|
}
|
|
4459
4509
|
if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4460
|
-
|
|
4510
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
4461
4511
|
"plugin-json-deprecated",
|
|
4462
4512
|
"[theokit-sdk] plugin.json manifests are deprecated; migrate to PLUGIN.md via theokit-migrate-config"
|
|
4463
4513
|
);
|
|
@@ -4475,11 +4525,11 @@ var PluginsManager = class {
|
|
|
4475
4525
|
const entry = metadata.entry;
|
|
4476
4526
|
if (entry === void 0) return;
|
|
4477
4527
|
const pluginRoot = path.join(this.cwd, ".theokit", "plugins", folderName);
|
|
4478
|
-
const entryPath =
|
|
4528
|
+
const entryPath = chunkQJQ2MAZF_cjs.safePathJoin(pluginRoot, entry);
|
|
4479
4529
|
try {
|
|
4480
4530
|
await promises.readFile(entryPath, "utf8");
|
|
4481
4531
|
} catch (cause) {
|
|
4482
|
-
throw new
|
|
4532
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${metadata.name} entry file is missing: ${entry}`, {
|
|
4483
4533
|
code: "plugin_entry_missing",
|
|
4484
4534
|
cause
|
|
4485
4535
|
});
|
|
@@ -4488,7 +4538,7 @@ var PluginsManager = class {
|
|
|
4488
4538
|
assertCloudRules() {
|
|
4489
4539
|
if (!this.cloud) return;
|
|
4490
4540
|
if (this.localPaths !== void 0 && this.localPaths.length > 0) {
|
|
4491
|
-
throw new
|
|
4541
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
4492
4542
|
"Cloud agents reject local plugin paths \u2014 plugins must come from committed repo files",
|
|
4493
4543
|
{ code: "cloud_plugin_path_rejected" }
|
|
4494
4544
|
);
|
|
@@ -4500,7 +4550,7 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4500
4550
|
try {
|
|
4501
4551
|
raw = await promises.readFile(manifestPath, "utf8");
|
|
4502
4552
|
} catch (cause) {
|
|
4503
|
-
throw new
|
|
4553
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} is missing plugin.json`, {
|
|
4504
4554
|
code: "plugin_missing_manifest",
|
|
4505
4555
|
cause
|
|
4506
4556
|
});
|
|
@@ -4509,13 +4559,13 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4509
4559
|
try {
|
|
4510
4560
|
parsed = JSON.parse(raw);
|
|
4511
4561
|
} catch (cause) {
|
|
4512
|
-
throw new
|
|
4562
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} manifest is invalid JSON`, {
|
|
4513
4563
|
code: "plugin_manifest_invalid",
|
|
4514
4564
|
cause
|
|
4515
4565
|
});
|
|
4516
4566
|
}
|
|
4517
4567
|
if (!parsed || typeof parsed !== "object") {
|
|
4518
|
-
throw new
|
|
4568
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} manifest must be an object`, {
|
|
4519
4569
|
code: "plugin_manifest_shape"
|
|
4520
4570
|
});
|
|
4521
4571
|
}
|
|
@@ -4534,7 +4584,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4534
4584
|
try {
|
|
4535
4585
|
raw = await promises.readFile(mdPath, "utf8");
|
|
4536
4586
|
} catch (cause) {
|
|
4537
|
-
throw new
|
|
4587
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} is missing PLUGIN.md`, {
|
|
4538
4588
|
code: "plugin_missing_manifest",
|
|
4539
4589
|
cause
|
|
4540
4590
|
});
|
|
@@ -4549,7 +4599,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4549
4599
|
});
|
|
4550
4600
|
const entity = entities.find((e) => e.slug === "PLUGIN");
|
|
4551
4601
|
if (entity === void 0) {
|
|
4552
|
-
throw new
|
|
4602
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} PLUGIN.md not parseable`, {
|
|
4553
4603
|
code: "plugin_missing_manifest"
|
|
4554
4604
|
});
|
|
4555
4605
|
}
|
|
@@ -4823,7 +4873,7 @@ function assertValidThresholds(soft, hard) {
|
|
|
4823
4873
|
["hardThreshold", hard]
|
|
4824
4874
|
]) {
|
|
4825
4875
|
if (!Number.isInteger(value) || value < 1) {
|
|
4826
|
-
throw new
|
|
4876
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
4827
4877
|
`doomLoop.${label} must be a positive integer (received ${value}).`,
|
|
4828
4878
|
{ code: "invalid_doom_loop_threshold" }
|
|
4829
4879
|
);
|
|
@@ -4988,6 +5038,35 @@ function buildAssistantTurn(text, toolCalls) {
|
|
|
4988
5038
|
return { role: "assistant", content };
|
|
4989
5039
|
}
|
|
4990
5040
|
|
|
5041
|
+
// src/internal/agent-loop/live-events.ts
|
|
5042
|
+
var LiveEventLog = class extends Array {
|
|
5043
|
+
/**
|
|
5044
|
+
* Not readonly, and not a constructor parameter — `Array` subclasses are re-instantiated by
|
|
5045
|
+
* `map`/`filter`/`slice` with a length argument, so a constructor with a different signature
|
|
5046
|
+
* breaks those. The sink is attached after construction instead.
|
|
5047
|
+
*/
|
|
5048
|
+
#sink;
|
|
5049
|
+
/** Attach the live subscriber. One sink: the run that owns this loop. */
|
|
5050
|
+
subscribe(sink) {
|
|
5051
|
+
this.#sink = sink;
|
|
5052
|
+
}
|
|
5053
|
+
push(...events) {
|
|
5054
|
+
const length = super.push(...events);
|
|
5055
|
+
for (const event of events) {
|
|
5056
|
+
try {
|
|
5057
|
+
this.#sink?.(event);
|
|
5058
|
+
} catch {
|
|
5059
|
+
}
|
|
5060
|
+
}
|
|
5061
|
+
return length;
|
|
5062
|
+
}
|
|
5063
|
+
};
|
|
5064
|
+
function createEventLog(seed) {
|
|
5065
|
+
const log = new LiveEventLog();
|
|
5066
|
+
log.push(...seed);
|
|
5067
|
+
return log;
|
|
5068
|
+
}
|
|
5069
|
+
|
|
4991
5070
|
// src/internal/agent-loop/loop-context-init.ts
|
|
4992
5071
|
function buildUserContent(text, images) {
|
|
4993
5072
|
const content = [{ type: "text", text }];
|
|
@@ -5051,13 +5130,14 @@ async function initLoopContext(inputs) {
|
|
|
5051
5130
|
});
|
|
5052
5131
|
}
|
|
5053
5132
|
}
|
|
5054
|
-
const events = [
|
|
5133
|
+
const events = createEventLog([
|
|
5055
5134
|
buildSystemEvent(
|
|
5056
5135
|
inputs,
|
|
5057
5136
|
tools.map((t) => t.name)
|
|
5058
5137
|
),
|
|
5059
5138
|
buildUserEvent(inputs)
|
|
5060
|
-
];
|
|
5139
|
+
]);
|
|
5140
|
+
if (inputs.onLoopEvent !== void 0) events.subscribe(inputs.onLoopEvent);
|
|
5061
5141
|
const priorMessages = (inputs.priorMessages ?? []).map((msg) => ({
|
|
5062
5142
|
role: msg.role,
|
|
5063
5143
|
content: [{ type: "text", text: msg.text }]
|
|
@@ -5104,7 +5184,7 @@ async function safeListTools(client, serverName) {
|
|
|
5104
5184
|
} catch (cause) {
|
|
5105
5185
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
5106
5186
|
const server = serverName ?? "unknown";
|
|
5107
|
-
|
|
5187
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] mcp listTools failed (server=${server}): ${message}
|
|
5108
5188
|
`);
|
|
5109
5189
|
return [];
|
|
5110
5190
|
}
|
|
@@ -5173,7 +5253,7 @@ function emitLlmMetrics(inputs, result, startAt) {
|
|
|
5173
5253
|
inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.LLM_USAGE_MISSING, 1, {
|
|
5174
5254
|
provider: inputs.llm.name
|
|
5175
5255
|
});
|
|
5176
|
-
|
|
5256
|
+
chunkBE3W4HYV_cjs.diag(
|
|
5177
5257
|
`[theokit-sdk] llm usage missing from ${inputs.llm.name} finish \u2014 budget may undercount
|
|
5178
5258
|
`
|
|
5179
5259
|
);
|
|
@@ -5422,7 +5502,7 @@ function coerceArgsToSchema(args, schema) {
|
|
|
5422
5502
|
}
|
|
5423
5503
|
|
|
5424
5504
|
// src/tool-error.ts
|
|
5425
|
-
var ToolError = class extends
|
|
5505
|
+
var ToolError = class extends chunkA3MHE2MQ_cjs.TheokitAgentError {
|
|
5426
5506
|
name = "ToolError";
|
|
5427
5507
|
/** The error content surfaced to the model: a string, or text/image blocks. */
|
|
5428
5508
|
content;
|
|
@@ -5616,7 +5696,7 @@ function raceToolExecution(exec, opts) {
|
|
|
5616
5696
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
5617
5697
|
async function dispatchTools(inputs, tools, toolCalls, events, parentSpan) {
|
|
5618
5698
|
const maxConcurrent = inputs.maxConcurrentTools ?? 4;
|
|
5619
|
-
return
|
|
5699
|
+
return chunk3XRXORBS_cjs.mapWithConcurrency(
|
|
5620
5700
|
toolCalls,
|
|
5621
5701
|
maxConcurrent,
|
|
5622
5702
|
(call) => dispatchSingleCall(inputs, tools, call, events, parentSpan)
|
|
@@ -5644,7 +5724,7 @@ async function dispatchSingleCall(inputs, tools, call, events, parentSpan) {
|
|
|
5644
5724
|
toolSpan?.end();
|
|
5645
5725
|
return fileVeto;
|
|
5646
5726
|
}
|
|
5647
|
-
|
|
5727
|
+
chunk3MUIYMUG_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5648
5728
|
type: "tool_progress",
|
|
5649
5729
|
toolName: workingCall.name,
|
|
5650
5730
|
toolCallId: callId
|
|
@@ -5675,7 +5755,7 @@ function applyRepairAndExtractCall(tools, call) {
|
|
|
5675
5755
|
function vetoFromForkWhitelist(inputs, call, callId, events) {
|
|
5676
5756
|
const whitelistDecision = chunkVJ26EKGJ_cjs.checkToolWhitelist(call.name);
|
|
5677
5757
|
if (whitelistDecision.allowed) return void 0;
|
|
5678
|
-
|
|
5758
|
+
chunk3MUIYMUG_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5679
5759
|
type: "permission_denied",
|
|
5680
5760
|
toolName: call.name,
|
|
5681
5761
|
toolCallId: callId,
|
|
@@ -5720,7 +5800,7 @@ async function vetoFromPluginPreHook(inputs, call, callId, events) {
|
|
|
5720
5800
|
...inputs.permissionMode !== void 0 ? { permissionMode: inputs.permissionMode } : {}
|
|
5721
5801
|
});
|
|
5722
5802
|
if (pluginVeto === void 0) return void 0;
|
|
5723
|
-
|
|
5803
|
+
chunk3MUIYMUG_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5724
5804
|
type: "permission_denied",
|
|
5725
5805
|
toolName: call.name,
|
|
5726
5806
|
toolCallId: callId,
|
|
@@ -5749,7 +5829,7 @@ async function vetoFromFileHookPreDecision(inputs, call, callId, events) {
|
|
|
5749
5829
|
runId: inputs.runId
|
|
5750
5830
|
});
|
|
5751
5831
|
if (!preDecision.blocked) return void 0;
|
|
5752
|
-
|
|
5832
|
+
chunk3MUIYMUG_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5753
5833
|
type: "permission_denied",
|
|
5754
5834
|
toolName: call.name,
|
|
5755
5835
|
toolCallId: callId,
|
|
@@ -5850,7 +5930,7 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
|
|
|
5850
5930
|
agentId: inputs.agentId,
|
|
5851
5931
|
runId: inputs.runId
|
|
5852
5932
|
}).catch((err) => {
|
|
5853
|
-
|
|
5933
|
+
chunkBE3W4HYV_cjs.diag(
|
|
5854
5934
|
`[theokit-sdk] postToolUse hook error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5855
5935
|
`
|
|
5856
5936
|
);
|
|
@@ -5869,7 +5949,7 @@ async function emitToolLifecycleDelta(inputs, update) {
|
|
|
5869
5949
|
try {
|
|
5870
5950
|
await inputs.onDelta({ update });
|
|
5871
5951
|
} catch (err) {
|
|
5872
|
-
|
|
5952
|
+
chunkBE3W4HYV_cjs.diag(
|
|
5873
5953
|
`[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5874
5954
|
`
|
|
5875
5955
|
);
|
|
@@ -5881,7 +5961,7 @@ async function safeEmitToolHook(callback, event) {
|
|
|
5881
5961
|
await callback(event);
|
|
5882
5962
|
} catch (cause) {
|
|
5883
5963
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
5884
|
-
|
|
5964
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] tool lifecycle hook threw: ${msg}
|
|
5885
5965
|
`);
|
|
5886
5966
|
}
|
|
5887
5967
|
}
|
|
@@ -5948,7 +6028,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
5948
6028
|
(p) => (
|
|
5949
6029
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
5950
6030
|
// structured content); image blocks pass through untouched.
|
|
5951
|
-
p.type === "tool_result" ? { ...p, content:
|
|
6031
|
+
p.type === "tool_result" ? { ...p, content: chunkG7X2Y7Y2_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
5952
6032
|
)
|
|
5953
6033
|
);
|
|
5954
6034
|
}
|
|
@@ -6143,7 +6223,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
6143
6223
|
const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
|
|
6144
6224
|
if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
|
|
6145
6225
|
for (const key of candidates) {
|
|
6146
|
-
const info =
|
|
6226
|
+
const info = chunk4MWBKBS4_cjs.getCatalogModelInfo(key);
|
|
6147
6227
|
const cost = info?.cost;
|
|
6148
6228
|
if (cost === void 0) continue;
|
|
6149
6229
|
const [prov, ...modelParts] = key.split("/");
|
|
@@ -6155,7 +6235,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
6155
6235
|
...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
|
|
6156
6236
|
...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
|
|
6157
6237
|
// M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
|
|
6158
|
-
pricingVersion:
|
|
6238
|
+
pricingVersion: chunk4MWBKBS4_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
|
|
6159
6239
|
};
|
|
6160
6240
|
}
|
|
6161
6241
|
return void 0;
|
|
@@ -6603,15 +6683,15 @@ var FallbackLlmClient = class {
|
|
|
6603
6683
|
let lastError;
|
|
6604
6684
|
for (const client of this.clients) {
|
|
6605
6685
|
if (signal.aborted) throw abortError(signal);
|
|
6606
|
-
const attempt = await
|
|
6686
|
+
const attempt = await chunkG7X2Y7Y2_cjs.tryFirstEvent(client, request, signal, true);
|
|
6607
6687
|
if (attempt.kind === "handshake_error") {
|
|
6608
6688
|
lastError = attempt.error;
|
|
6609
6689
|
continue;
|
|
6610
6690
|
}
|
|
6611
|
-
return yield*
|
|
6691
|
+
return yield* chunkG7X2Y7Y2_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6612
6692
|
}
|
|
6613
6693
|
if (lastError !== void 0) throw lastError;
|
|
6614
|
-
throw new
|
|
6694
|
+
throw new chunkA3MHE2MQ_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
6615
6695
|
code: "fallback_empty_chain"
|
|
6616
6696
|
});
|
|
6617
6697
|
}
|
|
@@ -6634,7 +6714,7 @@ function reconnectDelay(attempt) {
|
|
|
6634
6714
|
return ms <= 0 ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, ms));
|
|
6635
6715
|
}
|
|
6636
6716
|
function mcpTimeoutError(name, timeoutMs) {
|
|
6637
|
-
return new
|
|
6717
|
+
return new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${name} request timed out after ${timeoutMs}ms`, {
|
|
6638
6718
|
code: "mcp_timeout"
|
|
6639
6719
|
});
|
|
6640
6720
|
}
|
|
@@ -6717,7 +6797,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6717
6797
|
child.stdin.on("error", () => void 0);
|
|
6718
6798
|
child.on("error", () => {
|
|
6719
6799
|
this.rejectAllPending(
|
|
6720
|
-
new
|
|
6800
|
+
new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} process crashed`, { code: "mcp_crashed" })
|
|
6721
6801
|
);
|
|
6722
6802
|
});
|
|
6723
6803
|
child.on("exit", () => {
|
|
@@ -6725,7 +6805,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6725
6805
|
this.child = void 0;
|
|
6726
6806
|
this.dropped = true;
|
|
6727
6807
|
this.rejectAllPending(
|
|
6728
|
-
new
|
|
6808
|
+
new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6729
6809
|
);
|
|
6730
6810
|
});
|
|
6731
6811
|
}
|
|
@@ -6740,7 +6820,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6740
6820
|
if (this.child !== void 0) return Promise.resolve();
|
|
6741
6821
|
if (!this.dropped) {
|
|
6742
6822
|
return Promise.reject(
|
|
6743
|
-
new
|
|
6823
|
+
new chunkA3MHE2MQ_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6744
6824
|
);
|
|
6745
6825
|
}
|
|
6746
6826
|
this.reconnectPromise ??= this.reconnect().finally(() => {
|
|
@@ -6761,13 +6841,13 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6761
6841
|
lastErr = err;
|
|
6762
6842
|
}
|
|
6763
6843
|
}
|
|
6764
|
-
throw new
|
|
6844
|
+
throw new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} reconnect exhausted`, {
|
|
6765
6845
|
code: "mcp_disconnected",
|
|
6766
6846
|
...lastErr instanceof Error ? { cause: lastErr } : {}
|
|
6767
6847
|
});
|
|
6768
6848
|
}
|
|
6769
6849
|
async close() {
|
|
6770
|
-
this.rejectAllPending(new
|
|
6850
|
+
this.rejectAllPending(new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
|
|
6771
6851
|
const child = this.child;
|
|
6772
6852
|
this.child = void 0;
|
|
6773
6853
|
this.dropped = false;
|
|
@@ -6786,7 +6866,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6786
6866
|
if (this.buffer.length > MAX_STDIO_BUFFER_BYTES) {
|
|
6787
6867
|
this.buffer = "";
|
|
6788
6868
|
this.rejectAllPending(
|
|
6789
|
-
new
|
|
6869
|
+
new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} exceeded stdout buffer limit`, {
|
|
6790
6870
|
code: "mcp_buffer_overflow"
|
|
6791
6871
|
})
|
|
6792
6872
|
);
|
|
@@ -6821,7 +6901,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6821
6901
|
if (child !== void 0) return this.send(child, method, params);
|
|
6822
6902
|
if (this.dropped) return this.reconnectAndRequest(method, params);
|
|
6823
6903
|
return Promise.reject(
|
|
6824
|
-
new
|
|
6904
|
+
new chunkA3MHE2MQ_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6825
6905
|
);
|
|
6826
6906
|
}
|
|
6827
6907
|
/** M2 #59 — reconnect a dropped client, then send. Separate async path so the
|
|
@@ -6830,7 +6910,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6830
6910
|
await this.ensureConnected();
|
|
6831
6911
|
const child = this.child;
|
|
6832
6912
|
if (child === void 0) {
|
|
6833
|
-
throw new
|
|
6913
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" });
|
|
6834
6914
|
}
|
|
6835
6915
|
return this.send(child, method, params);
|
|
6836
6916
|
}
|
|
@@ -6847,7 +6927,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6847
6927
|
this.child = void 0;
|
|
6848
6928
|
this.dropped = true;
|
|
6849
6929
|
this.rejectAllPending(
|
|
6850
|
-
new
|
|
6930
|
+
new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6851
6931
|
);
|
|
6852
6932
|
}, this.timeoutMs);
|
|
6853
6933
|
this.pending.set(id, { resolve, reject, timer });
|
|
@@ -6904,6 +6984,31 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6904
6984
|
* Never overwritten by a later one: a server that re-issues mid-session would otherwise split
|
|
6905
6985
|
* the session in two, and the second half would not see the first half's state.
|
|
6906
6986
|
*/
|
|
6987
|
+
/**
|
|
6988
|
+
* Read one JSON-RPC response, in either encoding the server may choose.
|
|
6989
|
+
*
|
|
6990
|
+
* Streamable HTTP lets the server answer a POST with `application/json` OR `text/event-stream`,
|
|
6991
|
+
* and the client advertises both. Reading the body with `response.json()` unconditionally is what
|
|
6992
|
+
* turned a working server into `Unexpected token 'e', "event: mes"... is not valid JSON` the
|
|
6993
|
+
* moment the Accept header started asking for SSE — measured against a real server, not imagined.
|
|
6994
|
+
*
|
|
6995
|
+
* Only the `data:` payload is JSON; `event:` / `id:` / `retry:` lines and comments are framing.
|
|
6996
|
+
* A single JSON-RPC reply arrives as one event, so the FIRST parseable `data:` is the answer.
|
|
6997
|
+
*/
|
|
6998
|
+
async readBody(response) {
|
|
6999
|
+
const tipo = response.headers.get("content-type") ?? "";
|
|
7000
|
+
if (!tipo.includes("text/event-stream")) return await response.json();
|
|
7001
|
+
const text = await response.text();
|
|
7002
|
+
for (const line of text.split(/\r?\n/)) {
|
|
7003
|
+
if (!line.startsWith("data:")) continue;
|
|
7004
|
+
const payload = line.slice(5).trim();
|
|
7005
|
+
if (payload === "") continue;
|
|
7006
|
+
return JSON.parse(payload);
|
|
7007
|
+
}
|
|
7008
|
+
throw new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
|
|
7009
|
+
code: "mcp_http_error"
|
|
7010
|
+
});
|
|
7011
|
+
}
|
|
6907
7012
|
captureSession(response) {
|
|
6908
7013
|
if (this.sessionId !== void 0) return;
|
|
6909
7014
|
const issued = response.headers.get("mcp-session-id");
|
|
@@ -6928,13 +7033,13 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6928
7033
|
throw cause;
|
|
6929
7034
|
}
|
|
6930
7035
|
if (!response.ok) {
|
|
6931
|
-
throw new
|
|
7036
|
+
throw new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} returned ${response.status}`, {
|
|
6932
7037
|
code: "mcp_http_error"
|
|
6933
7038
|
});
|
|
6934
7039
|
}
|
|
6935
7040
|
this.captureSession(response);
|
|
6936
7041
|
try {
|
|
6937
|
-
return await
|
|
7042
|
+
return await this.readBody(response);
|
|
6938
7043
|
} catch (cause) {
|
|
6939
7044
|
if (isAbortLike(cause)) throw mcpTimeoutError(this.name, timeoutMs);
|
|
6940
7045
|
throw cause;
|
|
@@ -6944,14 +7049,14 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6944
7049
|
function resolveMcpCwd(configCwd) {
|
|
6945
7050
|
if (configCwd === void 0) return process.cwd();
|
|
6946
7051
|
if (path.isAbsolute(configCwd)) return configCwd;
|
|
6947
|
-
return
|
|
7052
|
+
return chunkQJQ2MAZF_cjs.safePathJoin(process.cwd(), configCwd);
|
|
6948
7053
|
}
|
|
6949
7054
|
|
|
6950
7055
|
// src/internal/providers/register-plugin-providers.ts
|
|
6951
7056
|
function registerPluginProviderProfiles(entries) {
|
|
6952
7057
|
let registered2 = 0;
|
|
6953
7058
|
for (const entry of entries) {
|
|
6954
|
-
|
|
7059
|
+
chunk4MWBKBS4_cjs.registerProvider(entry.profile);
|
|
6955
7060
|
registered2 += 1;
|
|
6956
7061
|
}
|
|
6957
7062
|
return registered2;
|
|
@@ -7031,7 +7136,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
|
|
|
7031
7136
|
if (exposedSet.has(name)) continue;
|
|
7032
7137
|
const hint = suggestClosest(name, exposedSet);
|
|
7033
7138
|
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)`;
|
|
7034
|
-
|
|
7139
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
7035
7140
|
`personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
|
|
7036
7141
|
message
|
|
7037
7142
|
);
|
|
@@ -7140,25 +7245,25 @@ function createRealLocalRun(options) {
|
|
|
7140
7245
|
}
|
|
7141
7246
|
var pluginProvidersAnnounced = false;
|
|
7142
7247
|
function resolveRunProvider(options) {
|
|
7143
|
-
|
|
7248
|
+
chunk4MWBKBS4_cjs.registerBuiltins();
|
|
7144
7249
|
const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
|
|
7145
7250
|
const registered2 = registerPluginProviderProfiles(profiles);
|
|
7146
7251
|
if (registered2 > 0 && !pluginProvidersAnnounced) {
|
|
7147
7252
|
pluginProvidersAnnounced = true;
|
|
7148
7253
|
const names = profiles.map((e) => e.profile.name).join(", ");
|
|
7149
|
-
|
|
7254
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] registered ${registered2} plugin provider profile(s): ${names}
|
|
7150
7255
|
`);
|
|
7151
7256
|
}
|
|
7152
7257
|
const parsedModel = chunkVYHJZVL5_cjs.parseModelId(options.model?.id);
|
|
7153
|
-
const modelInferredProvider = parsedModel.provider !== void 0 &&
|
|
7154
|
-
const keyInferredProvider =
|
|
7155
|
-
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ??
|
|
7258
|
+
const modelInferredProvider = parsedModel.provider !== void 0 && chunk4MWBKBS4_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
|
|
7259
|
+
const keyInferredProvider = chunkG7X2Y7Y2_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
|
|
7260
|
+
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkG7X2Y7Y2_cjs.detectPrimaryProvider();
|
|
7156
7261
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7157
7262
|
return { primary, effectiveModelId };
|
|
7158
7263
|
}
|
|
7159
7264
|
function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
7160
7265
|
if (apiKey === void 0 || apiKey.length === 0) return pools;
|
|
7161
|
-
if (
|
|
7266
|
+
if (chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
|
|
7162
7267
|
const existing = pools?.[primary];
|
|
7163
7268
|
if (existing !== void 0 && existing.length > 0) return pools;
|
|
7164
7269
|
return { ...pools ?? {}, [primary]: [apiKey] };
|
|
@@ -7166,7 +7271,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
|
7166
7271
|
function buildLoopInputs(options, runId, userText, userImages) {
|
|
7167
7272
|
const maxIterations = options.sendOptions.maxIterations;
|
|
7168
7273
|
if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
|
|
7169
|
-
throw new
|
|
7274
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
7170
7275
|
`SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
|
|
7171
7276
|
{ code: "invalid_max_iterations" }
|
|
7172
7277
|
);
|
|
@@ -7181,14 +7286,14 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7181
7286
|
const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
|
|
7182
7287
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7183
7288
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7184
|
-
const chain =
|
|
7289
|
+
const chain = chunkG7X2Y7Y2_cjs.resolveProviderChain({
|
|
7185
7290
|
primary,
|
|
7186
7291
|
...fallback !== void 0 ? { fallback } : {},
|
|
7187
7292
|
...apiKeys !== void 0 ? { apiKeys } : {},
|
|
7188
7293
|
...credentialPoolStrategy !== void 0 ? { credentialPoolStrategy } : {},
|
|
7189
7294
|
...extractToolCallsFromContent === true ? { extractToolCallsFromContent: true } : {},
|
|
7190
7295
|
...rateLimitSink !== void 0 ? {
|
|
7191
|
-
onRateLimit: (info) =>
|
|
7296
|
+
onRateLimit: (info) => chunk3MUIYMUG_cjs.emitRunEvent(rateLimitSink, { type: "rate_limit", ...info })
|
|
7192
7297
|
} : {}
|
|
7193
7298
|
});
|
|
7194
7299
|
const llm = chain.length === 1 ? chain[0] : new FallbackLlmClient(chain);
|
|
@@ -7329,7 +7434,26 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7329
7434
|
}
|
|
7330
7435
|
}
|
|
7331
7436
|
}
|
|
7437
|
+
/**
|
|
7438
|
+
* theokit#140 - events already handed to stream() by the live subscriber.
|
|
7439
|
+
*
|
|
7440
|
+
* The loop still RETURNS its full event list, and that batch path is deliberately kept: it is the
|
|
7441
|
+
* fallback if a live event is ever lost, and removing it would make the live channel a single
|
|
7442
|
+
* point of failure for the whole transcript.
|
|
7443
|
+
*/
|
|
7444
|
+
liveDelivered = /* @__PURE__ */ new Set();
|
|
7332
7445
|
async executeAgentLoop(inputs) {
|
|
7446
|
+
inputs.onLoopEvent = (event) => {
|
|
7447
|
+
this.liveDelivered.add(event);
|
|
7448
|
+
this.script.events.push(event);
|
|
7449
|
+
this.pushTimeline({ kind: "message", message: event });
|
|
7450
|
+
this.notifyNewEvents();
|
|
7451
|
+
};
|
|
7452
|
+
const callerOnDelta = inputs.onDelta;
|
|
7453
|
+
inputs.onDelta = (delta) => {
|
|
7454
|
+
callerOnDelta?.(delta);
|
|
7455
|
+
this.pushTimeline({ kind: "delta", update: delta.update });
|
|
7456
|
+
};
|
|
7333
7457
|
try {
|
|
7334
7458
|
const output = inputs.activeTools !== void 0 ? await chunkVJ26EKGJ_cjs.withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : await runAgentLoop(inputs);
|
|
7335
7459
|
this.applyAgentLoopOutput(output);
|
|
@@ -7352,10 +7476,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7352
7476
|
* Finding-B fix (sdk-error-packaging v1.1): set-once errorDetail copy.
|
|
7353
7477
|
*/
|
|
7354
7478
|
applyAgentLoopOutput(output) {
|
|
7355
|
-
|
|
7356
|
-
this.script.events.push(event);
|
|
7357
|
-
this.notifyNewEvents();
|
|
7358
|
-
}
|
|
7479
|
+
this.deliverUndeliveredEvents(output.events);
|
|
7359
7480
|
this.script.conversation.push(...output.conversation);
|
|
7360
7481
|
if (output.result.length > 0) this.script.result = output.result;
|
|
7361
7482
|
if (output.usage !== void 0) this.script.usage = output.usage;
|
|
@@ -7370,6 +7491,25 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7370
7491
|
};
|
|
7371
7492
|
}
|
|
7372
7493
|
}
|
|
7494
|
+
/**
|
|
7495
|
+
* theokit#140 - deliver only what the live subscriber has NOT already handed to `stream()`.
|
|
7496
|
+
*
|
|
7497
|
+
* The loop now reports each event as it happens, so this batch is the SAME list, replayed.
|
|
7498
|
+
* Without the guard every event would reach `stream()` twice: once live, once here.
|
|
7499
|
+
*
|
|
7500
|
+
* Identity, not deep equality: these are the very objects the live sink saw, and two genuinely
|
|
7501
|
+
* distinct events can be structurally identical (the same tool called twice with the same args
|
|
7502
|
+
* is not a duplicate).
|
|
7503
|
+
*
|
|
7504
|
+
* Extracted because the guard pushed `applyAgentLoopOutput` past the cognitive-complexity cap.
|
|
7505
|
+
*/
|
|
7506
|
+
deliverUndeliveredEvents(events) {
|
|
7507
|
+
for (const event of events) {
|
|
7508
|
+
if (this.liveDelivered.has(event)) continue;
|
|
7509
|
+
this.script.events.push(event);
|
|
7510
|
+
this.notifyNewEvents();
|
|
7511
|
+
}
|
|
7512
|
+
}
|
|
7373
7513
|
emitErrorEvent(cause, fallback, prefix = "", code) {
|
|
7374
7514
|
if (this.script.errorDetail === void 0) {
|
|
7375
7515
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
@@ -7406,7 +7546,7 @@ function buildRealRunOptions(args) {
|
|
|
7406
7546
|
};
|
|
7407
7547
|
}
|
|
7408
7548
|
async function createFixtureRunHelper(args) {
|
|
7409
|
-
const sessionMessages =
|
|
7549
|
+
const sessionMessages = chunk6ZGD7R27_cjs.getSessionMessages(args.inputs.agentId);
|
|
7410
7550
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7411
7551
|
return createLocalRun({
|
|
7412
7552
|
agentId: args.inputs.agentId,
|
|
@@ -7425,7 +7565,7 @@ async function createFixtureRunHelper(args) {
|
|
|
7425
7565
|
}
|
|
7426
7566
|
async function dispatchLocalRun(args) {
|
|
7427
7567
|
const apiKey = resolveApiKey(args.inputs.options.apiKey);
|
|
7428
|
-
if (
|
|
7568
|
+
if (chunkG7X2Y7Y2_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7429
7569
|
return createRealLocalRun(
|
|
7430
7570
|
buildRealRunOptions({
|
|
7431
7571
|
inputs: args.inputs,
|
|
@@ -7460,20 +7600,20 @@ async function readProjectMcpServers(cwd) {
|
|
|
7460
7600
|
|
|
7461
7601
|
// src/internal/local-agent/local-agent-invalidate.ts
|
|
7462
7602
|
async function applyDeferredInvalidation(agentId, pending, refresh) {
|
|
7463
|
-
|
|
7603
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] applying deferred cache invalidation (${agentId}): ${pending.reason}
|
|
7464
7604
|
`);
|
|
7465
7605
|
try {
|
|
7466
7606
|
await refresh();
|
|
7467
7607
|
} catch (err) {
|
|
7468
7608
|
const msg = err instanceof Error ? err.message : String(err);
|
|
7469
|
-
|
|
7609
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] invalidateCache reload failed (continuing): ${msg}
|
|
7470
7610
|
`);
|
|
7471
7611
|
}
|
|
7472
7612
|
}
|
|
7473
7613
|
async function invalidateCacheImpl(agentId, reason, options, disposed, dispose, setPending) {
|
|
7474
7614
|
if (disposed) return;
|
|
7475
7615
|
if (options.applyNow === true) {
|
|
7476
|
-
|
|
7616
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] invalidateCache applyNow disposing agent (${agentId}): ${reason}
|
|
7477
7617
|
`);
|
|
7478
7618
|
await dispose();
|
|
7479
7619
|
return;
|
|
@@ -7534,7 +7674,7 @@ var LiveAgentRegistry = class {
|
|
|
7534
7674
|
const existing = this.#agents.get(id);
|
|
7535
7675
|
if (existing !== void 0 && existing.agent !== agent) {
|
|
7536
7676
|
void existing.agent.dispose().catch(() => {
|
|
7537
|
-
|
|
7677
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] dispose during overwrite failed (${id})
|
|
7538
7678
|
`);
|
|
7539
7679
|
});
|
|
7540
7680
|
}
|
|
@@ -7638,7 +7778,7 @@ var LiveAgentRegistry = class {
|
|
|
7638
7778
|
await agent.dispose();
|
|
7639
7779
|
} catch (cause) {
|
|
7640
7780
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7641
|
-
|
|
7781
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] dispose during eviction failed (${id}): ${msg}
|
|
7642
7782
|
`);
|
|
7643
7783
|
}
|
|
7644
7784
|
if (this.#onEvict !== void 0) {
|
|
@@ -7646,7 +7786,7 @@ var LiveAgentRegistry = class {
|
|
|
7646
7786
|
this.#onEvict(id, reason);
|
|
7647
7787
|
} catch (cause) {
|
|
7648
7788
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7649
|
-
|
|
7789
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] onEvict listener threw (${id}): ${msg}
|
|
7650
7790
|
`);
|
|
7651
7791
|
}
|
|
7652
7792
|
}
|
|
@@ -7655,20 +7795,20 @@ var LiveAgentRegistry = class {
|
|
|
7655
7795
|
var liveAgentRegistry = new LiveAgentRegistry();
|
|
7656
7796
|
|
|
7657
7797
|
// src/internal/local-agent/local-agent-lifecycle.ts
|
|
7658
|
-
async function
|
|
7798
|
+
async function acquireLeaseIfPossible(store, agentId) {
|
|
7659
7799
|
const a = store.acquire;
|
|
7660
7800
|
if (typeof a !== "function") return;
|
|
7661
7801
|
try {
|
|
7662
7802
|
await a.call(store, agentId);
|
|
7663
7803
|
} catch (err) {
|
|
7664
7804
|
if (err instanceof Error && err.name === "SessionBusyError") throw err;
|
|
7665
|
-
|
|
7805
|
+
chunkBE3W4HYV_cjs.diag(
|
|
7666
7806
|
`[theokit-sdk] writer lease unavailable for ${agentId} (${err instanceof Error ? err.message : String(err)}) \u2014 proceeding without single-writer protection
|
|
7667
7807
|
`
|
|
7668
7808
|
);
|
|
7669
7809
|
}
|
|
7670
7810
|
}
|
|
7671
|
-
async function
|
|
7811
|
+
async function releaseLeaseIfPossible(store, agentId) {
|
|
7672
7812
|
const r = store.release;
|
|
7673
7813
|
if (typeof r === "function") await r.call(store, agentId);
|
|
7674
7814
|
}
|
|
@@ -7681,16 +7821,16 @@ async function disposeLocalAgentSession(agent) {
|
|
|
7681
7821
|
agent.lifecycleAbortController.abort();
|
|
7682
7822
|
await chunkYLQQX5W2_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
7683
7823
|
disposeSessionMcpClients(agent.agentId);
|
|
7684
|
-
await
|
|
7824
|
+
await chunk6ZGD7R27_cjs.flushSessionWrites();
|
|
7685
7825
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
7686
7826
|
await disposeSessionStore(agent.sessionStore);
|
|
7687
|
-
|
|
7827
|
+
chunk6ZGD7R27_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
7688
7828
|
}
|
|
7689
7829
|
async function reloadLocalAgent(agent) {
|
|
7690
7830
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
7691
7831
|
if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
|
|
7692
7832
|
if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
|
|
7693
|
-
return await
|
|
7833
|
+
return await chunkMXRBNJ6D_cjs.loadSubagents(
|
|
7694
7834
|
agent.workspaceCwd,
|
|
7695
7835
|
agent.settingSourcesIncludeProject,
|
|
7696
7836
|
agent.options.agents
|
|
@@ -7698,12 +7838,12 @@ async function reloadLocalAgent(agent) {
|
|
|
7698
7838
|
}
|
|
7699
7839
|
async function persistActiveMemoryTranscript(cwd, transcript) {
|
|
7700
7840
|
try {
|
|
7701
|
-
const dir = path.join(
|
|
7841
|
+
const dir = path.join(chunk3BSP7LSG_cjs.memoryDir(cwd), "transcripts", "active-memory");
|
|
7702
7842
|
const file = path.join(dir, `${transcript.runId}.json`);
|
|
7703
|
-
await
|
|
7843
|
+
await chunkYVI4YPUP_cjs.atomicWriteJson(file, transcript);
|
|
7704
7844
|
} catch (cause) {
|
|
7705
7845
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7706
|
-
|
|
7846
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] active-memory transcript persist failed: ${message}
|
|
7707
7847
|
`);
|
|
7708
7848
|
}
|
|
7709
7849
|
}
|
|
@@ -7824,7 +7964,7 @@ async function searchOnce(args, cfg, query, started) {
|
|
|
7824
7964
|
return { summary, durationMs: Date.now() - started, status: "ok", hits };
|
|
7825
7965
|
} catch (cause) {
|
|
7826
7966
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7827
|
-
|
|
7967
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] active-memory recall failed: ${message}
|
|
7828
7968
|
`);
|
|
7829
7969
|
return { summary: void 0, durationMs: Date.now() - started, status: "error", hits: [] };
|
|
7830
7970
|
}
|
|
@@ -7936,17 +8076,17 @@ async function createOpenAiCompatibleRuntime(cfg, options) {
|
|
|
7936
8076
|
const model = options.model ?? cfg.defaultModel;
|
|
7937
8077
|
const apiKey = options.apiKey ?? process.env[cfg.apiKeyEnv];
|
|
7938
8078
|
if (apiKey === void 0 || apiKey.length === 0) {
|
|
7939
|
-
throw new
|
|
8079
|
+
throw new chunkA3MHE2MQ_cjs.AuthenticationError(`${cfg.apiKeyEnv} missing`, {
|
|
7940
8080
|
code: "embedding_missing_api_key"
|
|
7941
8081
|
});
|
|
7942
8082
|
}
|
|
7943
8083
|
const envBaseUrl = cfg.baseUrlEnv !== void 0 ? process.env[cfg.baseUrlEnv] : void 0;
|
|
7944
8084
|
const baseUrl = options.baseUrl ?? envBaseUrl ?? cfg.defaultBaseUrl;
|
|
7945
8085
|
const fetchImpl = options.fetch ?? fetch;
|
|
7946
|
-
const cache = options.cache ??
|
|
8086
|
+
const cache = options.cache ?? chunk3BSP7LSG_cjs.globalEmbeddingCache;
|
|
7947
8087
|
const dimension = cfg.dimensionByModel[model];
|
|
7948
8088
|
if (dimension === void 0) {
|
|
7949
|
-
throw new
|
|
8089
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
7950
8090
|
`${cfg.id} adapter: model "${model}" is not in the dimension table. Use one of: ${Object.keys(cfg.dimensionByModel).join(", ")}. To add it, update dimensionByModel in the adapter source.`,
|
|
7951
8091
|
{ code: "embedding_unknown_model" }
|
|
7952
8092
|
);
|
|
@@ -8017,7 +8157,7 @@ async function embedInBoundedBatches(input, pending, results) {
|
|
|
8017
8157
|
for (let offset = 0; offset < pending.length; offset += MAX_BATCH) {
|
|
8018
8158
|
batches.push(pending.slice(offset, offset + MAX_BATCH));
|
|
8019
8159
|
}
|
|
8020
|
-
await
|
|
8160
|
+
await chunk3XRXORBS_cjs.mapWithConcurrency(
|
|
8021
8161
|
batches,
|
|
8022
8162
|
MAX_CONCURRENT_BATCHES,
|
|
8023
8163
|
(batch) => processBatch(input, batch, results)
|
|
@@ -8062,7 +8202,7 @@ async function embedBatch(opts) {
|
|
|
8062
8202
|
body = JSON.parse(text);
|
|
8063
8203
|
} catch {
|
|
8064
8204
|
}
|
|
8065
|
-
throw
|
|
8205
|
+
throw chunkG7X2Y7Y2_cjs.mapOpenAICompatibleError({
|
|
8066
8206
|
providerId: opts.providerId,
|
|
8067
8207
|
status: response.status,
|
|
8068
8208
|
body,
|
|
@@ -8084,7 +8224,7 @@ async function postEmbedRequest(opts, url) {
|
|
|
8084
8224
|
async function parseEmbedResponse(response, providerId, endpoint) {
|
|
8085
8225
|
const json = await response.json();
|
|
8086
8226
|
if (!Array.isArray(json.data)) {
|
|
8087
|
-
throw new
|
|
8227
|
+
throw new chunkA3MHE2MQ_cjs.NetworkError(`${providerId} ${endpoint} returned no data`, {
|
|
8088
8228
|
code: "embedding_invalid_response",
|
|
8089
8229
|
metadata: {
|
|
8090
8230
|
provider: providerId,
|
|
@@ -8482,7 +8622,7 @@ function createMemorySearchTool(opts) {
|
|
|
8482
8622
|
};
|
|
8483
8623
|
}
|
|
8484
8624
|
function createMemoryGetTool(opts) {
|
|
8485
|
-
const memoryRoot = path.resolve(
|
|
8625
|
+
const memoryRoot = path.resolve(chunk3BSP7LSG_cjs.memoryDir(opts.cwd));
|
|
8486
8626
|
return {
|
|
8487
8627
|
name: "memory_get",
|
|
8488
8628
|
description: GET_DESCRIPTION,
|
|
@@ -8493,7 +8633,7 @@ function createMemoryGetTool(opts) {
|
|
|
8493
8633
|
const lines = readNumber(input.lines);
|
|
8494
8634
|
const resolved = path.resolve(memoryRoot, relPath);
|
|
8495
8635
|
if (!isPathInside(memoryRoot, resolved)) {
|
|
8496
|
-
throw new
|
|
8636
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
8497
8637
|
`memory_get rejected path that escapes memory root: ${relPath}`,
|
|
8498
8638
|
{ code: "memory_path_escapes_root" }
|
|
8499
8639
|
);
|
|
@@ -8513,7 +8653,7 @@ function readString(value, errorIfMissing, allowUndefined = false) {
|
|
|
8513
8653
|
if (typeof value === "string") return value;
|
|
8514
8654
|
if (allowUndefined && (value === void 0 || value === null)) return "";
|
|
8515
8655
|
if (errorIfMissing !== void 0) {
|
|
8516
|
-
throw new
|
|
8656
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(errorIfMissing, { code: "memory_tool_bad_args" });
|
|
8517
8657
|
}
|
|
8518
8658
|
return "";
|
|
8519
8659
|
}
|
|
@@ -8589,7 +8729,7 @@ var LocalAgentMemory = class {
|
|
|
8589
8729
|
const openOpts = { cwd: this.workspaceCwd };
|
|
8590
8730
|
if (embedding !== void 0) openOpts.embedding = embedding;
|
|
8591
8731
|
if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
|
|
8592
|
-
this.index = await
|
|
8732
|
+
this.index = await chunk3BSP7LSG_cjs.IndexManager.open(openOpts);
|
|
8593
8733
|
await this.index.sync();
|
|
8594
8734
|
this.toolsCache = [
|
|
8595
8735
|
createMemorySearchTool({ index: this.index }),
|
|
@@ -8604,7 +8744,7 @@ var LocalAgentMemory = class {
|
|
|
8604
8744
|
const warned2 = g[sym];
|
|
8605
8745
|
if (!warned2.has(message)) {
|
|
8606
8746
|
warned2.add(message);
|
|
8607
|
-
|
|
8747
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] memory tools unavailable: ${message}
|
|
8608
8748
|
`);
|
|
8609
8749
|
}
|
|
8610
8750
|
return void 0;
|
|
@@ -8613,7 +8753,7 @@ var LocalAgentMemory = class {
|
|
|
8613
8753
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8614
8754
|
const cfg = this.options.memory?.activeRecall;
|
|
8615
8755
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8616
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8756
|
+
if (this.breaker === void 0) this.breaker = new chunkG7X2Y7Y2_cjs.CircuitBreaker();
|
|
8617
8757
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8618
8758
|
const result = await runActiveMemory({
|
|
8619
8759
|
userText,
|
|
@@ -8663,7 +8803,7 @@ var LocalAgentMemory = class {
|
|
|
8663
8803
|
await this.index.sync();
|
|
8664
8804
|
} catch (cause) {
|
|
8665
8805
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8666
|
-
|
|
8806
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] session index sync failed: ${message}
|
|
8667
8807
|
`);
|
|
8668
8808
|
}
|
|
8669
8809
|
}
|
|
@@ -8676,7 +8816,7 @@ var LocalAgentMemory = class {
|
|
|
8676
8816
|
return await adapter.create(cfg.model !== void 0 ? { model: cfg.model } : {});
|
|
8677
8817
|
} catch (cause) {
|
|
8678
8818
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8679
|
-
|
|
8819
|
+
chunkBE3W4HYV_cjs.diag(`[theokit-sdk] memory embedding ${cfg.provider} unavailable: ${message}
|
|
8680
8820
|
`);
|
|
8681
8821
|
return void 0;
|
|
8682
8822
|
}
|
|
@@ -8712,7 +8852,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8712
8852
|
...partial?.metadata !== void 0 ? { metadata: partial.metadata } : defaultContext?.metadata !== void 0 ? { metadata: defaultContext.metadata } : {}
|
|
8713
8853
|
};
|
|
8714
8854
|
if (merged.userId === "") {
|
|
8715
|
-
throw new
|
|
8855
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
8716
8856
|
"agent.memory requires a userId \u2014 either set AgentOptions.memoryContext.userId or pass ctx.userId at call time.",
|
|
8717
8857
|
{ code: "memory_context_missing_user_id" }
|
|
8718
8858
|
);
|
|
@@ -8722,7 +8862,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8722
8862
|
async function requireAdapters() {
|
|
8723
8863
|
const r = await ensure();
|
|
8724
8864
|
if (r.adapters.length === 0) {
|
|
8725
|
-
throw new
|
|
8865
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
8726
8866
|
"No memory adapter registered. Pass a memory plugin in AgentOptions.plugins (e.g. supermemoryMemory({...})).",
|
|
8727
8867
|
{ code: "no_memory_adapter" }
|
|
8728
8868
|
);
|
|
@@ -8763,7 +8903,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8763
8903
|
const prefix = id.split(":", 1)[0] ?? "";
|
|
8764
8904
|
const target = adapters.find((a) => a.id === prefix);
|
|
8765
8905
|
if (target === void 0) {
|
|
8766
|
-
throw new
|
|
8906
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
8767
8907
|
`No adapter found for MemoryId prefix "${prefix}" (registered: ${adapters.map((a) => a.id).join(", ")}).`,
|
|
8768
8908
|
{ code: "no_memory_adapter" }
|
|
8769
8909
|
);
|
|
@@ -8836,7 +8976,7 @@ function createLocalAgentMemoryProvider(opts) {
|
|
|
8836
8976
|
return { facts: [], systemPromptAdditions: summary };
|
|
8837
8977
|
},
|
|
8838
8978
|
async recordSessionSummary(args) {
|
|
8839
|
-
await
|
|
8979
|
+
await chunk3BSP7LSG_cjs.writeSessionSummary(args);
|
|
8840
8980
|
},
|
|
8841
8981
|
async sync(handle) {
|
|
8842
8982
|
const state = handle[INTERNAL_LAM_KEY];
|
|
@@ -8914,19 +9054,19 @@ var PersonalityRegistry = class _PersonalityRegistry {
|
|
|
8914
9054
|
function addEntity(byName, entity, origin, collisionMap) {
|
|
8915
9055
|
const fm = entity.frontmatter;
|
|
8916
9056
|
if (PersonalityRegistry.isReservedClearSlug(fm.name)) {
|
|
8917
|
-
throw new
|
|
9057
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
8918
9058
|
`Personality name "${fm.name}" is reserved (used to clear active preset)`,
|
|
8919
9059
|
{ code: "personality_reserved_name" }
|
|
8920
9060
|
);
|
|
8921
9061
|
}
|
|
8922
9062
|
if (entity.body.trim().length === 0) {
|
|
8923
|
-
throw new
|
|
9063
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
8924
9064
|
`Personality "${fm.name}" has empty body (system prompt required)`,
|
|
8925
9065
|
{ code: "personality_empty_body" }
|
|
8926
9066
|
);
|
|
8927
9067
|
}
|
|
8928
9068
|
if (origin === "project" && collisionMap?.has(fm.name)) {
|
|
8929
|
-
|
|
9069
|
+
chunkM4OGSS66_cjs.warnOnce(
|
|
8930
9070
|
`personality-collision-${fm.name}`,
|
|
8931
9071
|
`[theokit-sdk] personality "${fm.name}" overridden by project preset`
|
|
8932
9072
|
);
|
|
@@ -8955,7 +9095,7 @@ async function performPersonalitySwitch(args) {
|
|
|
8955
9095
|
const preset = args.registry.get(args.requestedName);
|
|
8956
9096
|
if (preset === void 0) {
|
|
8957
9097
|
const available = args.registry.all().map((p) => p.name).join(", ") || "(none)";
|
|
8958
|
-
throw new
|
|
9098
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
8959
9099
|
`Personality "${args.requestedName}" not found. Available: ${available}`,
|
|
8960
9100
|
{ code: "personality_not_found" }
|
|
8961
9101
|
);
|
|
@@ -8976,14 +9116,14 @@ async function performPersonalitySwitch(args) {
|
|
|
8976
9116
|
|
|
8977
9117
|
// src/internal/local-agent/local-agent-personality-extensions.ts
|
|
8978
9118
|
function resolveActivePersonalityPreset(args) {
|
|
8979
|
-
const forkCtx =
|
|
9119
|
+
const forkCtx = chunkM4OGSS66_cjs.currentPersonalityContext();
|
|
8980
9120
|
const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
|
|
8981
9121
|
if (slug === void 0) return void 0;
|
|
8982
9122
|
return args.personalityRegistry?.get(slug);
|
|
8983
9123
|
}
|
|
8984
9124
|
async function ensurePersonalityRegistryIfNeeded(args) {
|
|
8985
9125
|
if (args.personalityRegistry !== void 0) return args.personalityRegistry;
|
|
8986
|
-
const forkSlug =
|
|
9126
|
+
const forkSlug = chunkM4OGSS66_cjs.currentPersonalityContext()?.slug;
|
|
8987
9127
|
const ownSlug = args.personalityStore.active(args.agentId);
|
|
8988
9128
|
if (forkSlug === void 0 && ownSlug === void 0) return void 0;
|
|
8989
9129
|
return await PersonalityRegistry.load(args.workspaceCwd);
|
|
@@ -8997,8 +9137,8 @@ ${preset.systemPrompt}`;
|
|
|
8997
9137
|
}
|
|
8998
9138
|
async function localAgentUsePersonality(args) {
|
|
8999
9139
|
if (args.disposed) throw new Error("Agent has been disposed");
|
|
9000
|
-
if (
|
|
9001
|
-
|
|
9140
|
+
if (chunkM4OGSS66_cjs.currentPersonalityContext() !== void 0) {
|
|
9141
|
+
chunkM4OGSS66_cjs.warnPersonalitySwitchInsideFork(args.agentId);
|
|
9002
9142
|
return null;
|
|
9003
9143
|
}
|
|
9004
9144
|
let registry = args.personalityRegistry;
|
|
@@ -9015,8 +9155,8 @@ async function localAgentUsePersonality(args) {
|
|
|
9015
9155
|
registry,
|
|
9016
9156
|
store: args.personalityStore,
|
|
9017
9157
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
9018
|
-
appendSessionMessage: (msg) =>
|
|
9019
|
-
clearSession: () =>
|
|
9158
|
+
appendSessionMessage: (msg) => chunk6ZGD7R27_cjs.appendSessionMessage(args.agentId, msg),
|
|
9159
|
+
clearSession: () => chunk6ZGD7R27_cjs.clearSession(args.agentId),
|
|
9020
9160
|
opts: args.opts ?? {}
|
|
9021
9161
|
})
|
|
9022
9162
|
);
|
|
@@ -9025,9 +9165,9 @@ async function localAgentUsePersonality(args) {
|
|
|
9025
9165
|
// src/internal/local-agent/local-agent-runtime-extensions.ts
|
|
9026
9166
|
function localAgentRunUntil(agent, goal, options) {
|
|
9027
9167
|
async function* wrap() {
|
|
9028
|
-
const { runUntilImpl } = await import('./run-until-
|
|
9168
|
+
const { runUntilImpl } = await import('./run-until-L5KQD3PV.cjs');
|
|
9029
9169
|
const buildDeps = async () => {
|
|
9030
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9170
|
+
const { judgeCallImpl } = await import('./judge-call-XIQJ5GIE.cjs');
|
|
9031
9171
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9032
9172
|
const create = getAgentFacade().create;
|
|
9033
9173
|
return {
|
|
@@ -9060,7 +9200,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
|
|
|
9060
9200
|
async function localAgentFork(parent, options) {
|
|
9061
9201
|
const { forkAgentImpl } = await import('./fork-agent-Y2IK2RYU.cjs');
|
|
9062
9202
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9063
|
-
const { withPersonalityContext } = await import('./context-
|
|
9203
|
+
const { withPersonalityContext } = await import('./context-Q6ISOCN2.cjs');
|
|
9064
9204
|
const create = getAgentFacade().create;
|
|
9065
9205
|
return withPersonalityContext(
|
|
9066
9206
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
@@ -9120,7 +9260,7 @@ function wrapRunWithCompletionCheck(args) {
|
|
|
9120
9260
|
judgeOpts
|
|
9121
9261
|
);
|
|
9122
9262
|
const complete = !verdict.parseFailed && verdict.verdict === "done";
|
|
9123
|
-
|
|
9263
|
+
chunk3MUIYMUG_cjs.emitRunEvent(args.onRunEvent, {
|
|
9124
9264
|
type: "completion_check",
|
|
9125
9265
|
complete,
|
|
9126
9266
|
reason: verdict.reason
|
|
@@ -9216,6 +9356,9 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
9216
9356
|
"cancel",
|
|
9217
9357
|
"conversation"
|
|
9218
9358
|
]);
|
|
9359
|
+
function emptyTimeline() {
|
|
9360
|
+
return emptyStream();
|
|
9361
|
+
}
|
|
9219
9362
|
function emptyStream() {
|
|
9220
9363
|
return {
|
|
9221
9364
|
next: () => Promise.resolve({ done: true, value: void 0 }),
|
|
@@ -9240,6 +9383,9 @@ function createTripwireRun(args) {
|
|
|
9240
9383
|
status: "cancelled",
|
|
9241
9384
|
...args.model !== void 0 ? { model: args.model } : {},
|
|
9242
9385
|
stream: () => emptyStream(),
|
|
9386
|
+
// theokit#140 - a tripwire run never executed, so its timeline is empty by construction, the
|
|
9387
|
+
// same reason `stream()` is. Both are empty for the same fact, not by coincidence.
|
|
9388
|
+
events: () => emptyTimeline(),
|
|
9243
9389
|
wait: () => Promise.resolve(result),
|
|
9244
9390
|
cancel: () => Promise.resolve(),
|
|
9245
9391
|
conversation: () => Promise.resolve([]),
|
|
@@ -9261,7 +9407,7 @@ function wrapRunWithOutputProcessors(args) {
|
|
|
9261
9407
|
if (result.status !== "finished" || result.result === void 0) return result;
|
|
9262
9408
|
const res = await runOutputProcessors(args.processors, result.result, args.agentId);
|
|
9263
9409
|
if (res.kind === "ok") return { ...result, result: res.value };
|
|
9264
|
-
|
|
9410
|
+
chunk3MUIYMUG_cjs.emitRunEvent(args.onRunEvent, {
|
|
9265
9411
|
type: "tripwire",
|
|
9266
9412
|
reason: res.tripwire.reason,
|
|
9267
9413
|
processorId: res.tripwire.processorId
|
|
@@ -9336,7 +9482,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9336
9482
|
}
|
|
9337
9483
|
const res = await runInputProcessors(processors, rawUserText, inputs.agentId);
|
|
9338
9484
|
if (res.kind === "tripwire") {
|
|
9339
|
-
|
|
9485
|
+
chunk3MUIYMUG_cjs.emitRunEvent(options.onRunEvent, {
|
|
9340
9486
|
type: "tripwire",
|
|
9341
9487
|
reason: res.tripwire.reason,
|
|
9342
9488
|
processorId: res.tripwire.processorId
|
|
@@ -9353,7 +9499,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9353
9499
|
return { userText: res.value, effectiveMessage };
|
|
9354
9500
|
}
|
|
9355
9501
|
async function executeSendLocked(inputs, message, options) {
|
|
9356
|
-
if (inputs.disposed) throw new
|
|
9502
|
+
if (inputs.disposed) throw new chunkA3MHE2MQ_cjs.AgentDisposedError(inputs.agentId);
|
|
9357
9503
|
await consumePending(inputs.agentId, inputs.invalidationPending, inputs.clearInvalidation, inputs.reload);
|
|
9358
9504
|
const sendModel = normalizeModel(options.model);
|
|
9359
9505
|
inputs.applyModelOverride(sendModel);
|
|
@@ -9364,7 +9510,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9364
9510
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9365
9511
|
await inputs.options.onBeforeSend({
|
|
9366
9512
|
conversationId: inputs.agentId,
|
|
9367
|
-
previousMessageCount:
|
|
9513
|
+
previousMessageCount: chunk6ZGD7R27_cjs.getSessionMessages(inputs.agentId).length
|
|
9368
9514
|
});
|
|
9369
9515
|
}
|
|
9370
9516
|
await inputs.runPreHook(userText);
|
|
@@ -9376,8 +9522,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9376
9522
|
userText,
|
|
9377
9523
|
sendOptions: options
|
|
9378
9524
|
});
|
|
9379
|
-
const priorMessages = [...
|
|
9380
|
-
|
|
9525
|
+
const priorMessages = [...chunk6ZGD7R27_cjs.getSessionMessages(inputs.agentId)];
|
|
9526
|
+
chunk6ZGD7R27_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9381
9527
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9382
9528
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
|
|
9383
9529
|
const portPathActive = shouldUsePortMemoryPath();
|
|
@@ -9435,7 +9581,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9435
9581
|
function buildCompletionCheckDeps() {
|
|
9436
9582
|
return {
|
|
9437
9583
|
judge: async (ctx, opts) => {
|
|
9438
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9584
|
+
const { judgeCallImpl } = await import('./judge-call-XIQJ5GIE.cjs');
|
|
9439
9585
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9440
9586
|
return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
|
|
9441
9587
|
}
|
|
@@ -9455,7 +9601,7 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
|
|
|
9455
9601
|
promptPreview: userText.slice(0, 120),
|
|
9456
9602
|
...opts.meta ?? {}
|
|
9457
9603
|
};
|
|
9458
|
-
void
|
|
9604
|
+
void chunk3MUIYMUG_cjs.submit({
|
|
9459
9605
|
kind: "run",
|
|
9460
9606
|
work: async (ctx) => {
|
|
9461
9607
|
ctx.signal.addEventListener(
|
|
@@ -9539,7 +9685,7 @@ var LocalAgent = class {
|
|
|
9539
9685
|
this.options = options;
|
|
9540
9686
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
9541
9687
|
this.transcriptBaseDir = resolveBaseDir(options.local?.baseDir);
|
|
9542
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
9688
|
+
this.sessionStore = options.local?.sessionStore ?? new chunk2R6NBT5F_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
9543
9689
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
9544
9690
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
9545
9691
|
const sub = bootstrapSubmanagers({
|
|
@@ -9582,17 +9728,17 @@ var LocalAgent = class {
|
|
|
9582
9728
|
if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
|
|
9583
9729
|
const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
|
|
9584
9730
|
await this.pluginManagerCode.initialize(codePlugins);
|
|
9585
|
-
this.resolvedSubagents = await
|
|
9731
|
+
this.resolvedSubagents = await chunkMXRBNJ6D_cjs.loadSubagents(
|
|
9586
9732
|
this.workspaceCwd,
|
|
9587
9733
|
this.settingSourcesIncludeProject,
|
|
9588
9734
|
this.options.agents
|
|
9589
9735
|
);
|
|
9590
|
-
await
|
|
9736
|
+
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9591
9737
|
try {
|
|
9592
|
-
await
|
|
9738
|
+
await chunk6ZGD7R27_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9593
9739
|
await this.personalityStore.hydrate(this.agentId);
|
|
9594
9740
|
} catch (err) {
|
|
9595
|
-
await
|
|
9741
|
+
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9596
9742
|
throw err;
|
|
9597
9743
|
}
|
|
9598
9744
|
}
|
|
@@ -9625,16 +9771,16 @@ var LocalAgent = class {
|
|
|
9625
9771
|
});
|
|
9626
9772
|
}
|
|
9627
9773
|
/**
|
|
9628
|
-
*
|
|
9774
|
+
* The context window declared on the model selection, in conditional-spread form.
|
|
9629
9775
|
*
|
|
9630
|
-
* M94 —
|
|
9631
|
-
* call site
|
|
9632
|
-
*
|
|
9633
|
-
*
|
|
9776
|
+
* M94 — without this, `resolveEffectiveContextWindow`'s `override` had existed since M77 and no
|
|
9777
|
+
* production call site passed it: a 400k model with no catalog entry was budgeted against the
|
|
9778
|
+
* 128k floor. Its own method because the inline spread pushed `runLockedSendCycle` past the
|
|
9779
|
+
* project's cognitive-complexity ceiling.
|
|
9634
9780
|
*/
|
|
9635
|
-
#
|
|
9636
|
-
const
|
|
9637
|
-
return
|
|
9781
|
+
#declaredWindow() {
|
|
9782
|
+
const declared = this.model?.contextWindow;
|
|
9783
|
+
return declared !== void 0 ? { contextWindow: declared } : {};
|
|
9638
9784
|
}
|
|
9639
9785
|
async runLockedSendCycle(message, options, sendSpan, resolve, reject) {
|
|
9640
9786
|
const userText = typeof message === "string" ? message : message.text;
|
|
@@ -9663,7 +9809,7 @@ var LocalAgent = class {
|
|
|
9663
9809
|
workspaceCwd: this.workspaceCwd,
|
|
9664
9810
|
sessionStore: this.sessionStore,
|
|
9665
9811
|
model: this.model?.id ?? "unknown",
|
|
9666
|
-
...this.#
|
|
9812
|
+
...this.#declaredWindow(),
|
|
9667
9813
|
// M50 — the auto-compaction summarizer resolves credentials like the run itself.
|
|
9668
9814
|
...this.options.apiKey !== void 0 ? { apiKey: this.options.apiKey } : {},
|
|
9669
9815
|
...options.onRunEvent !== void 0 ? { onRunEvent: options.onRunEvent } : {},
|
|
@@ -9738,7 +9884,7 @@ var LocalAgent = class {
|
|
|
9738
9884
|
agentId: this.agentId
|
|
9739
9885
|
});
|
|
9740
9886
|
if (preRun.blocked) {
|
|
9741
|
-
throw new
|
|
9887
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
9742
9888
|
`preRun hook denied execution: ${preRun.reason ?? "unspecified"}`,
|
|
9743
9889
|
{ code: "hook_denied" }
|
|
9744
9890
|
);
|
|
@@ -9819,7 +9965,7 @@ var LocalAgent = class {
|
|
|
9819
9965
|
}
|
|
9820
9966
|
// biome-ignore format: G8 budget — see listArtifacts.
|
|
9821
9967
|
downloadArtifact(_path) {
|
|
9822
|
-
return Promise.reject(new
|
|
9968
|
+
return Promise.reject(new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError("Artifacts are not supported for local agents", "downloadArtifact"));
|
|
9823
9969
|
}
|
|
9824
9970
|
// biome-ignore format: G8 budget — delegates to `local-agent-runtime-extensions.ts`; kept 1-line.
|
|
9825
9971
|
runUntil(goal, options) {
|
|
@@ -9842,7 +9988,7 @@ function resolveCwd(cwd) {
|
|
|
9842
9988
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|
|
9843
9989
|
}
|
|
9844
9990
|
function resolveBaseDir(baseDir) {
|
|
9845
|
-
return baseDir === void 0 ?
|
|
9991
|
+
return baseDir === void 0 ? chunk6OKPJZMX_cjs.defaultBaseDir() : chunk6OKPJZMX_cjs.expandTilde(baseDir);
|
|
9846
9992
|
}
|
|
9847
9993
|
function includesSetting(options, source) {
|
|
9848
9994
|
const sources = options.local?.settingSources;
|
|
@@ -9867,7 +10013,7 @@ async function guardAgainstIdCollision(options) {
|
|
|
9867
10013
|
const persistenceCwd = resolveAgentPersistenceCwd(options);
|
|
9868
10014
|
await hydrateRegistryFromDisk(persistenceCwd);
|
|
9869
10015
|
if (getRegisteredAgent(options.agentId) !== void 0) {
|
|
9870
|
-
throw new
|
|
10016
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
9871
10017
|
`Agent "${options.agentId}" already exists. Use Agent.resume("${options.agentId}") to reattach, or pick a different agentId.`,
|
|
9872
10018
|
{ code: "agent_id_already_exists" }
|
|
9873
10019
|
);
|
|
@@ -9900,7 +10046,7 @@ async function maybeInjectHandoffTools(options) {
|
|
|
9900
10046
|
const spec = "@theokit/sdk-handoff/internal/tool-injector";
|
|
9901
10047
|
mod = await import(spec);
|
|
9902
10048
|
} catch (err) {
|
|
9903
|
-
throw new
|
|
10049
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
9904
10050
|
"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).",
|
|
9905
10051
|
{ code: "handoff_package_missing", cause: err }
|
|
9906
10052
|
);
|
|
@@ -9920,9 +10066,9 @@ async function maybeInjectHandoffTools(options) {
|
|
|
9920
10066
|
async function createLocalAgent(options) {
|
|
9921
10067
|
const apiKey = resolveApiKey(options.apiKey);
|
|
9922
10068
|
if (apiKey === void 0) {
|
|
9923
|
-
throw new
|
|
10069
|
+
throw new chunkA3MHE2MQ_cjs.AuthenticationError("Missing API key", { code: "missing_api_key" });
|
|
9924
10070
|
}
|
|
9925
|
-
const willFlowToProvider = !
|
|
10071
|
+
const willFlowToProvider = !chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) && !chunkG7X2Y7Y2_cjs.shouldUseRealLocalRuntime(apiKey);
|
|
9926
10072
|
const shape = validateApiKeyShape(apiKey, {
|
|
9927
10073
|
strict: willFlowToProvider,
|
|
9928
10074
|
// `options.model` is already normalized by `runCreateUnderSpan`; `normalizeModel`
|
|
@@ -9931,10 +10077,10 @@ async function createLocalAgent(options) {
|
|
|
9931
10077
|
...willFlowToProvider ? { provider: providerFromModelId(normalizeModel(options.model)?.id) } : {}
|
|
9932
10078
|
});
|
|
9933
10079
|
if (shape.malformed) {
|
|
9934
|
-
throw new
|
|
10080
|
+
throw new chunkA3MHE2MQ_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
9935
10081
|
}
|
|
9936
|
-
if (!
|
|
9937
|
-
throw new
|
|
10082
|
+
if (!chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) && chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl() === void 0 && !chunkG7X2Y7Y2_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
10083
|
+
throw new chunkA3MHE2MQ_cjs.AuthenticationError("Invalid API key", {
|
|
9938
10084
|
code: "authentication_error"
|
|
9939
10085
|
});
|
|
9940
10086
|
}
|
|
@@ -9945,19 +10091,19 @@ async function createLocalAgent(options) {
|
|
|
9945
10091
|
async function createCloudAgent(options) {
|
|
9946
10092
|
const apiKey = resolveApiKey(options.apiKey);
|
|
9947
10093
|
if (apiKey === void 0) {
|
|
9948
|
-
throw new
|
|
10094
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError("Missing API key for cloud agent", {
|
|
9949
10095
|
code: "missing_api_key"
|
|
9950
10096
|
});
|
|
9951
10097
|
}
|
|
9952
10098
|
const shape = validateApiKeyShape(apiKey);
|
|
9953
10099
|
if (shape.malformed) {
|
|
9954
|
-
throw new
|
|
10100
|
+
throw new chunkA3MHE2MQ_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
9955
10101
|
}
|
|
9956
|
-
const baseUrl =
|
|
10102
|
+
const baseUrl = chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl();
|
|
9957
10103
|
if (baseUrl === void 0) {
|
|
9958
10104
|
return new CloudAgent(options);
|
|
9959
10105
|
}
|
|
9960
|
-
const response = await
|
|
10106
|
+
const response = await chunkG7X2Y7Y2_cjs.httpRequest("/v1/agents", {
|
|
9961
10107
|
apiKey,
|
|
9962
10108
|
method: "POST",
|
|
9963
10109
|
body: {
|
|
@@ -9982,7 +10128,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
9982
10128
|
return process.cwd();
|
|
9983
10129
|
}
|
|
9984
10130
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
9985
|
-
await
|
|
10131
|
+
await chunkG7X2Y7Y2_cjs.discoverProviderPlugins();
|
|
9986
10132
|
await validateRehydratedAgent(agentId, existing);
|
|
9987
10133
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
9988
10134
|
const mergedOptions = {
|
|
@@ -10013,7 +10159,7 @@ async function validateRehydratedAgent(agentId, entry) {
|
|
|
10013
10159
|
throw new Error(`Workspace path is not a directory: ${candidate}`);
|
|
10014
10160
|
}
|
|
10015
10161
|
} catch (cause) {
|
|
10016
|
-
throw new
|
|
10162
|
+
throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
|
|
10017
10163
|
`Agent "${agentId}" cannot be rehydrated \u2014 workspace cwd "${candidate}" is missing or inaccessible.`,
|
|
10018
10164
|
{ code: "agent_rehydration_failed", cause }
|
|
10019
10165
|
);
|
|
@@ -10065,7 +10211,7 @@ async function getRegisteredAgentOrThrow(agentId) {
|
|
|
10065
10211
|
agent = getRegisteredAgent(agentId);
|
|
10066
10212
|
}
|
|
10067
10213
|
if (agent === void 0) {
|
|
10068
|
-
throw new
|
|
10214
|
+
throw new chunkA3MHE2MQ_cjs.UnknownAgentError(`Agent ${agentId} not found`, { code: "unknown_agent" });
|
|
10069
10215
|
}
|
|
10070
10216
|
return agent;
|
|
10071
10217
|
}
|
|
@@ -10110,7 +10256,7 @@ var Agent = class _Agent {
|
|
|
10110
10256
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
10111
10257
|
});
|
|
10112
10258
|
try {
|
|
10113
|
-
await
|
|
10259
|
+
await chunkG7X2Y7Y2_cjs.discoverProviderPlugins();
|
|
10114
10260
|
const agent = await runCreateUnderSpan(options, span);
|
|
10115
10261
|
return agent;
|
|
10116
10262
|
} catch (err) {
|
|
@@ -10136,8 +10282,8 @@ var Agent = class _Agent {
|
|
|
10136
10282
|
const run = await agent.send(message);
|
|
10137
10283
|
const result = await run.wait();
|
|
10138
10284
|
if (options.throwOnError === true && result.status === "error" && result.error !== void 0) {
|
|
10139
|
-
throw new
|
|
10140
|
-
code:
|
|
10285
|
+
throw new chunkA3MHE2MQ_cjs.AgentRunError(result.error.message, {
|
|
10286
|
+
code: chunkA3MHE2MQ_cjs.coerceToKnownAgentRunErrorCode(result.error.code),
|
|
10141
10287
|
cause: result.error.cause
|
|
10142
10288
|
});
|
|
10143
10289
|
}
|
|
@@ -10164,7 +10310,7 @@ var Agent = class _Agent {
|
|
|
10164
10310
|
if (existing !== void 0) {
|
|
10165
10311
|
return await rehydrateExistingAgent(agentId, existing, options);
|
|
10166
10312
|
}
|
|
10167
|
-
throw new
|
|
10313
|
+
throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
|
|
10168
10314
|
`Agent "${agentId}" not found. Use Agent.create({ agentId, ... }) for first-time setup, or catch UnknownAgentError to branch resume-vs-create.`,
|
|
10169
10315
|
{ code: "unknown_agent" }
|
|
10170
10316
|
);
|
|
@@ -10193,7 +10339,7 @@ var Agent = class _Agent {
|
|
|
10193
10339
|
* @public
|
|
10194
10340
|
*/
|
|
10195
10341
|
static async generateObject(options) {
|
|
10196
|
-
const { generateObjectImpl } = await import('./generate-object-
|
|
10342
|
+
const { generateObjectImpl } = await import('./generate-object-F56VIZ6U.cjs');
|
|
10197
10343
|
return generateObjectImpl(options, {
|
|
10198
10344
|
create: (opts) => _Agent.create(opts),
|
|
10199
10345
|
delete: (agentId) => _Agent.delete(agentId)
|
|
@@ -10217,7 +10363,7 @@ var Agent = class _Agent {
|
|
|
10217
10363
|
delete: (agentId) => _Agent.delete(agentId)
|
|
10218
10364
|
};
|
|
10219
10365
|
async function* wrapper() {
|
|
10220
|
-
streamObjectImport ??= import('./stream-object-
|
|
10366
|
+
streamObjectImport ??= import('./stream-object-YPXZ4F5P.cjs');
|
|
10221
10367
|
const { streamObjectImpl } = await streamObjectImport;
|
|
10222
10368
|
yield* streamObjectImpl(options, deps);
|
|
10223
10369
|
}
|
|
@@ -10241,7 +10387,7 @@ var Agent = class _Agent {
|
|
|
10241
10387
|
* @public
|
|
10242
10388
|
*/
|
|
10243
10389
|
static async batch(prompts, options) {
|
|
10244
|
-
const { batchImpl } = await import('./batch-
|
|
10390
|
+
const { batchImpl } = await import('./batch-NZGN6SFV.cjs');
|
|
10245
10391
|
return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
|
|
10246
10392
|
}
|
|
10247
10393
|
/**
|
|
@@ -10265,7 +10411,7 @@ var Agent = class _Agent {
|
|
|
10265
10411
|
*
|
|
10266
10412
|
* This bullet used to say the opposite ("Disposed agents are NOT auto-deleted...
|
|
10267
10413
|
* call `Agent.delete(agentId)` first"). It was measured false in M91:
|
|
10268
|
-
* `tests/m91-getorcreate-
|
|
10414
|
+
* `tests/m91-getorcreate-after-dispose.test.ts` builds an agent, disposes it, and
|
|
10269
10415
|
* gets a different instance back. The claim was about the PERSISTENT registry and
|
|
10270
10416
|
* read as being about the live cache — and consumers built around the wrong half.
|
|
10271
10417
|
* The agent-builder's M85 interrupt rotates the session id to work around a
|
|
@@ -10321,14 +10467,14 @@ var Agent = class _Agent {
|
|
|
10321
10467
|
*/
|
|
10322
10468
|
static async getRun(runId, options = {}) {
|
|
10323
10469
|
if (options.runtime === "cloud") {
|
|
10324
|
-
throw new
|
|
10470
|
+
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
10325
10471
|
"Cloud runtime is pre-release. Theo PaaS endpoints are not wired yet \u2014 getRun({ runtime: 'cloud' }) will be enabled when the PaaS ships.",
|
|
10326
10472
|
{ code: "cloud_runtime_pre_release" }
|
|
10327
10473
|
);
|
|
10328
10474
|
}
|
|
10329
10475
|
const existing = getRun(runId);
|
|
10330
10476
|
if (existing !== void 0) return existing;
|
|
10331
|
-
throw new
|
|
10477
|
+
throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
|
|
10332
10478
|
`Run ${runId} is not in this process's registry. It may have been disposed, persisted in a previous process, or never created.`,
|
|
10333
10479
|
{ code: "run_not_found" }
|
|
10334
10480
|
);
|
|
@@ -10375,13 +10521,13 @@ var Agent = class _Agent {
|
|
|
10375
10521
|
reg = getRegisteredAgent(agentId);
|
|
10376
10522
|
}
|
|
10377
10523
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10378
|
-
throw new
|
|
10524
|
+
throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
|
|
10379
10525
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10380
10526
|
);
|
|
10381
10527
|
}
|
|
10382
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10383
|
-
const { cwd, model, store } = await
|
|
10384
|
-
return
|
|
10528
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-YOWJJPPB.cjs');
|
|
10529
|
+
const { cwd, model, store } = await openLocalStore(reg);
|
|
10530
|
+
return chunk6ZGD7R27_cjs.enqueueSessionWrite(
|
|
10385
10531
|
cwd,
|
|
10386
10532
|
agentId,
|
|
10387
10533
|
() => compactSessionTranscript({
|
|
@@ -10411,12 +10557,12 @@ var Agent = class _Agent {
|
|
|
10411
10557
|
reg = getRegisteredAgent(agentId);
|
|
10412
10558
|
}
|
|
10413
10559
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10414
|
-
throw new
|
|
10560
|
+
throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
|
|
10415
10561
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10416
10562
|
);
|
|
10417
10563
|
}
|
|
10418
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10419
|
-
const { cwd, model, store } = await
|
|
10564
|
+
const { injectSessionTurn } = await import('./inject-session-25EC74WV.cjs');
|
|
10565
|
+
const { cwd, model, store } = await openLocalStore(reg);
|
|
10420
10566
|
await injectSessionTurn({
|
|
10421
10567
|
store,
|
|
10422
10568
|
loc: { cwd, agentId, model },
|
|
@@ -10439,12 +10585,12 @@ async function getOrCreateUncached(agentId, options) {
|
|
|
10439
10585
|
try {
|
|
10440
10586
|
return await Agent.resume(agentId, options);
|
|
10441
10587
|
} catch (err) {
|
|
10442
|
-
if (!(err instanceof
|
|
10588
|
+
if (!(err instanceof chunkA3MHE2MQ_cjs.UnknownAgentError)) throw err;
|
|
10443
10589
|
}
|
|
10444
10590
|
try {
|
|
10445
10591
|
return await Agent.create({ ...options, agentId });
|
|
10446
10592
|
} catch (err) {
|
|
10447
|
-
if (err instanceof
|
|
10593
|
+
if (err instanceof chunkA3MHE2MQ_cjs.ConfigurationError && err.code === "agent_id_already_exists") {
|
|
10448
10594
|
return await Agent.resume(agentId, options);
|
|
10449
10595
|
}
|
|
10450
10596
|
throw err;
|
|
@@ -10458,12 +10604,12 @@ chunkNINIJCHU_cjs.setAgentFacade({
|
|
|
10458
10604
|
resume: (agentId, options) => Agent.resume(agentId, options),
|
|
10459
10605
|
batch: (prompts, options) => Agent.batch(prompts, options)
|
|
10460
10606
|
});
|
|
10461
|
-
async function
|
|
10607
|
+
async function openLocalStore(reg) {
|
|
10462
10608
|
const cwd = reg.cwd ?? process.cwd();
|
|
10463
10609
|
const optModel = reg.options.model;
|
|
10464
10610
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
10465
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
10466
|
-
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-
|
|
10611
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-T5ZLQX42.cjs');
|
|
10612
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-DFGX6WNL.cjs');
|
|
10467
10613
|
const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
|
|
10468
10614
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
10469
10615
|
}
|
|
@@ -10480,5 +10626,5 @@ exports.generateCronId = generateCronId;
|
|
|
10480
10626
|
exports.getPricingEntry = getPricingEntry;
|
|
10481
10627
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10482
10628
|
exports.resolveApiKey = resolveApiKey;
|
|
10483
|
-
//# sourceMappingURL=chunk-
|
|
10484
|
-
//# sourceMappingURL=chunk-
|
|
10629
|
+
//# sourceMappingURL=chunk-UZBA6YYP.cjs.map
|
|
10630
|
+
//# sourceMappingURL=chunk-UZBA6YYP.cjs.map
|