@theokit/sdk 4.38.0 → 4.39.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 +237 -0
- package/dist/a2a/index.cjs +3 -3
- package/dist/a2a/index.js +1 -1
- package/dist/a2a/subagent.d.cts +1 -0
- package/dist/a2a/subagent.d.ts +1 -0
- package/dist/{agent-U3lBX-5t.d.cts → agent-D7bRK9Kg.d.cts} +70 -5
- package/dist/agent-I3EZZR6S.cjs +55 -0
- package/dist/{agent-2GZC4W2A.cjs.map → agent-I3EZZR6S.cjs.map} +1 -1
- package/dist/agent-KKZYLY5D.js +46 -0
- package/dist/{agent-3H3UKD6U.js.map → agent-KKZYLY5D.js.map} +1 -1
- package/dist/{agent-C3AEtM-W.d.ts → agent-ZCZa7YQv.d.ts} +70 -5
- package/dist/agent-session-store-N4TVKHBU.cjs +23 -0
- package/dist/agent-session-store-N4TVKHBU.cjs.map +1 -0
- package/dist/agent-session-store-RHMHP5DG.js +6 -0
- package/dist/agent-session-store-RHMHP5DG.js.map +1 -0
- package/dist/agent.d.ts +37 -1
- package/dist/auth/index.cjs +15 -15
- package/dist/auth/index.js +4 -4
- package/dist/{batch-LXSALQC3.js → batch-6KQM3EBA.js} +12 -12
- package/dist/batch-6KQM3EBA.js.map +1 -0
- package/dist/{batch-NZGN6SFV.cjs → batch-X6JKGDPK.cjs} +26 -26
- package/dist/batch-X6JKGDPK.cjs.map +1 -0
- package/dist/chunk-2RW7K6FN.cjs +34 -0
- package/dist/chunk-2RW7K6FN.cjs.map +1 -0
- package/dist/chunk-3I4B3OIX.js +105 -0
- package/dist/chunk-3I4B3OIX.js.map +1 -0
- package/dist/{chunk-KWXC6ERT.js → chunk-42IFCKQZ.js} +5 -5
- package/dist/{chunk-KWXC6ERT.js.map → chunk-42IFCKQZ.js.map} +1 -1
- package/dist/{chunk-4APWS2YF.js → chunk-4F7JQZOX.js} +9 -36
- package/dist/chunk-4F7JQZOX.js.map +1 -0
- package/dist/{chunk-VYD6BGKK.js → chunk-4JSZYSGW.js} +3 -3
- package/dist/{chunk-VYD6BGKK.js.map → chunk-4JSZYSGW.js.map} +1 -1
- package/dist/{chunk-A6GXYF2Q.js → chunk-65ONFZWM.js} +7 -6
- package/dist/chunk-65ONFZWM.js.map +1 -0
- package/dist/{chunk-SGTMDQ4O.js → chunk-6EEYRFJC.js} +5 -5
- package/dist/{chunk-SGTMDQ4O.js.map → chunk-6EEYRFJC.js.map} +1 -1
- package/dist/{chunk-M4OGSS66.cjs → chunk-6LGQECT7.cjs} +11 -11
- package/dist/{chunk-M4OGSS66.cjs.map → chunk-6LGQECT7.cjs.map} +1 -1
- package/dist/{chunk-KTXOHCAE.cjs → chunk-6NEHIHFU.cjs} +4 -4
- package/dist/{chunk-KTXOHCAE.cjs.map → chunk-6NEHIHFU.cjs.map} +1 -1
- package/dist/chunk-6YNYA7GD.cjs +103 -0
- package/dist/chunk-6YNYA7GD.cjs.map +1 -0
- package/dist/{chunk-2R6NBT5F.cjs → chunk-74D7KSBP.cjs} +11 -11
- package/dist/{chunk-2R6NBT5F.cjs.map → chunk-74D7KSBP.cjs.map} +1 -1
- package/dist/{chunk-6OIO4FYX.cjs → chunk-75DSEWTJ.cjs} +7 -7
- package/dist/{chunk-6OIO4FYX.cjs.map → chunk-75DSEWTJ.cjs.map} +1 -1
- package/dist/{chunk-3XRXORBS.cjs → chunk-7OLG7VI4.cjs} +4 -4
- package/dist/{chunk-3XRXORBS.cjs.map → chunk-7OLG7VI4.cjs.map} +1 -1
- package/dist/chunk-7U2HAAWB.cjs +199 -0
- package/dist/chunk-7U2HAAWB.cjs.map +1 -0
- package/dist/{chunk-QJQ2MAZF.cjs → chunk-7YBJZS5P.cjs} +8 -8
- package/dist/{chunk-QJQ2MAZF.cjs.map → chunk-7YBJZS5P.cjs.map} +1 -1
- package/dist/{chunk-ZFZYPLQI.js → chunk-AECV3G5Z.js} +4 -4
- package/dist/{chunk-ZFZYPLQI.js.map → chunk-AECV3G5Z.js.map} +1 -1
- package/dist/{chunk-QFWQLXCL.js → chunk-AR5MQZ3J.js} +3 -3
- package/dist/{chunk-QFWQLXCL.js.map → chunk-AR5MQZ3J.js.map} +1 -1
- package/dist/{chunk-G2F67XUR.cjs → chunk-B4YA6BRS.cjs} +13 -14
- package/dist/chunk-B4YA6BRS.cjs.map +1 -0
- package/dist/{chunk-BE3W4HYV.cjs → chunk-BCQ3E2ZG.cjs} +12 -3
- package/dist/chunk-BCQ3E2ZG.cjs.map +1 -0
- package/dist/{chunk-G7X2Y7Y2.cjs → chunk-BPN5ONSW.cjs} +182 -236
- package/dist/chunk-BPN5ONSW.cjs.map +1 -0
- package/dist/{chunk-XJ5TMOGA.js → chunk-BQDUEG4C.js} +3 -3
- package/dist/{chunk-XJ5TMOGA.js.map → chunk-BQDUEG4C.js.map} +1 -1
- package/dist/{chunk-OFWU6UKF.cjs → chunk-C7OP3FAK.cjs} +47 -11
- package/dist/chunk-C7OP3FAK.cjs.map +1 -0
- package/dist/{chunk-BUGVDCI5.cjs → chunk-CEIHCKTO.cjs} +4 -4
- package/dist/chunk-CEIHCKTO.cjs.map +1 -0
- package/dist/{chunk-3BSP7LSG.cjs → chunk-CN6UX5EV.cjs} +28 -56
- package/dist/chunk-CN6UX5EV.cjs.map +1 -0
- package/dist/{chunk-5BVBNE2F.js → chunk-D7IULBF2.js} +3 -3
- package/dist/{chunk-5BVBNE2F.js.map → chunk-D7IULBF2.js.map} +1 -1
- package/dist/{chunk-6ZGD7R27.cjs → chunk-DCXRHCZJ.cjs} +8 -75
- package/dist/chunk-DCXRHCZJ.cjs.map +1 -0
- package/dist/{chunk-YVI4YPUP.cjs → chunk-DGLLVCNB.cjs} +4 -4
- package/dist/{chunk-YVI4YPUP.cjs.map → chunk-DGLLVCNB.cjs.map} +1 -1
- package/dist/{chunk-JI34KBNC.js → chunk-DKFGUOWL.js} +3 -3
- package/dist/{chunk-JI34KBNC.js.map → chunk-DKFGUOWL.js.map} +1 -1
- package/dist/{chunk-ZET34IZE.cjs → chunk-DMTZ3FII.cjs} +5 -5
- package/dist/{chunk-ZET34IZE.cjs.map → chunk-DMTZ3FII.cjs.map} +1 -1
- package/dist/{chunk-6XZBKFQ7.js → chunk-DU7DE543.js} +3 -3
- package/dist/{chunk-6XZBKFQ7.js.map → chunk-DU7DE543.js.map} +1 -1
- package/dist/{chunk-VVMLMKYZ.cjs → chunk-DWY25VLP.cjs} +9 -9
- package/dist/{chunk-VVMLMKYZ.cjs.map → chunk-DWY25VLP.cjs.map} +1 -1
- package/dist/{chunk-A4XXV2C6.js → chunk-E2FFG33C.js} +5 -72
- package/dist/chunk-E2FFG33C.js.map +1 -0
- package/dist/{chunk-R4AMI7KD.cjs → chunk-E4IUN3JB.cjs} +15 -15
- package/dist/{chunk-R4AMI7KD.cjs.map → chunk-E4IUN3JB.cjs.map} +1 -1
- package/dist/{chunk-TKDWD3MU.cjs → chunk-ECHGWE47.cjs} +4 -4
- package/dist/{chunk-TKDWD3MU.cjs.map → chunk-ECHGWE47.cjs.map} +1 -1
- package/dist/{chunk-KL7E244K.cjs → chunk-ECW2MLEW.cjs} +4 -4
- package/dist/{chunk-KL7E244K.cjs.map → chunk-ECW2MLEW.cjs.map} +1 -1
- package/dist/{chunk-EDI7DBWO.js → chunk-ET6PHZRX.js} +3 -3
- package/dist/{chunk-EDI7DBWO.js.map → chunk-ET6PHZRX.js.map} +1 -1
- package/dist/{chunk-HLK35TD7.cjs → chunk-FRUBE44B.cjs} +24 -24
- package/dist/{chunk-HLK35TD7.cjs.map → chunk-FRUBE44B.cjs.map} +1 -1
- package/dist/{chunk-SRIF7HMN.cjs → chunk-FWBSDQZ7.cjs} +5 -5
- package/dist/{chunk-SRIF7HMN.cjs.map → chunk-FWBSDQZ7.cjs.map} +1 -1
- package/dist/{chunk-XKBJT7WI.cjs → chunk-G2Q3ZC6C.cjs} +4 -4
- package/dist/{chunk-XKBJT7WI.cjs.map → chunk-G2Q3ZC6C.cjs.map} +1 -1
- package/dist/{chunk-4MWBKBS4.cjs → chunk-G4XUXSRN.cjs} +12 -12
- package/dist/{chunk-4MWBKBS4.cjs.map → chunk-G4XUXSRN.cjs.map} +1 -1
- package/dist/{chunk-VUDH4D2M.js → chunk-GIRD3RWH.js} +282 -276
- package/dist/chunk-GIRD3RWH.js.map +1 -0
- package/dist/{chunk-BT6DFWZB.cjs → chunk-HIQFVHC6.cjs} +9 -9
- package/dist/{chunk-BT6DFWZB.cjs.map → chunk-HIQFVHC6.cjs.map} +1 -1
- package/dist/{chunk-UWEALKAN.js → chunk-HWNVAUK4.js} +3 -3
- package/dist/{chunk-UWEALKAN.js.map → chunk-HWNVAUK4.js.map} +1 -1
- package/dist/{chunk-3VKTDQMX.cjs → chunk-I53ZQHU6.cjs} +4 -4
- package/dist/{chunk-3VKTDQMX.cjs.map → chunk-I53ZQHU6.cjs.map} +1 -1
- package/dist/{chunk-A3MHE2MQ.cjs → chunk-IHFNRNTJ.cjs} +8 -8
- package/dist/{chunk-A3MHE2MQ.cjs.map → chunk-IHFNRNTJ.cjs.map} +1 -1
- package/dist/{chunk-UZBA6YYP.cjs → chunk-INSFS5GT.cjs} +540 -534
- package/dist/chunk-INSFS5GT.cjs.map +1 -0
- package/dist/{chunk-KCZW75PI.js → chunk-IVSD7L22.js} +12 -4
- package/dist/chunk-IVSD7L22.js.map +1 -0
- package/dist/{chunk-JCXIDFRI.js → chunk-J3UK2GMN.js} +3 -3
- package/dist/{chunk-JCXIDFRI.js.map → chunk-J3UK2GMN.js.map} +1 -1
- package/dist/{chunk-IBDE4R5L.cjs → chunk-J6T5LWJ4.cjs} +10 -9
- package/dist/chunk-J6T5LWJ4.cjs.map +1 -0
- package/dist/{chunk-AOZYORH7.js → chunk-JRLXEYR4.js} +21 -5
- package/dist/chunk-JRLXEYR4.js.map +1 -0
- package/dist/{chunk-EUB7YLU2.js → chunk-JZUPMTJY.js} +3 -3
- package/dist/{chunk-EUB7YLU2.js.map → chunk-JZUPMTJY.js.map} +1 -1
- package/dist/{chunk-ZK3BJ4XQ.js → chunk-KE6XKRLQ.js} +3 -3
- package/dist/{chunk-ZK3BJ4XQ.js.map → chunk-KE6XKRLQ.js.map} +1 -1
- package/dist/{chunk-4NVV3GRU.js → chunk-KGRIHEDT.js} +5 -5
- package/dist/{chunk-4NVV3GRU.js.map → chunk-KGRIHEDT.js.map} +1 -1
- package/dist/{chunk-EE24WJJR.js → chunk-KWUNN5J2.js} +5 -5
- package/dist/{chunk-EE24WJJR.js.map → chunk-KWUNN5J2.js.map} +1 -1
- package/dist/{chunk-LGCEYEU2.js → chunk-KX7JV5KM.js} +3 -3
- package/dist/{chunk-LGCEYEU2.js.map → chunk-KX7JV5KM.js.map} +1 -1
- package/dist/{chunk-2K7PRHDB.cjs → chunk-LALG2K33.cjs} +8 -8
- package/dist/{chunk-2K7PRHDB.cjs.map → chunk-LALG2K33.cjs.map} +1 -1
- package/dist/{chunk-4WIJSKFA.js → chunk-LGILIGV3.js} +3 -3
- package/dist/{chunk-4WIJSKFA.js.map → chunk-LGILIGV3.js.map} +1 -1
- package/dist/{chunk-7QDTZJRV.js → chunk-LJX2SQV2.js} +6 -6
- package/dist/{chunk-7QDTZJRV.js.map → chunk-LJX2SQV2.js.map} +1 -1
- package/dist/{chunk-ACHGT3D2.js → chunk-MC5EINBV.js} +44 -8
- package/dist/chunk-MC5EINBV.js.map +1 -0
- package/dist/{chunk-M6UUTNDT.js → chunk-ML5A5DOJ.js} +4 -4
- package/dist/{chunk-M6UUTNDT.js.map → chunk-ML5A5DOJ.js.map} +1 -1
- package/dist/{chunk-3MUIYMUG.cjs → chunk-N475ETD6.cjs} +17 -17
- package/dist/{chunk-3MUIYMUG.cjs.map → chunk-N475ETD6.cjs.map} +1 -1
- package/dist/chunk-OXNYIMZZ.js +31 -0
- package/dist/chunk-OXNYIMZZ.js.map +1 -0
- package/dist/{chunk-YCHC45BY.js → chunk-PI4RO4GR.js} +3 -3
- package/dist/{chunk-YCHC45BY.js.map → chunk-PI4RO4GR.js.map} +1 -1
- package/dist/chunk-QKE556YD.js +197 -0
- package/dist/chunk-QKE556YD.js.map +1 -0
- package/dist/{chunk-FV3YEMQ7.js → chunk-RP5HQVLD.js} +13 -14
- package/dist/chunk-RP5HQVLD.js.map +1 -0
- package/dist/chunk-SCFW5MJZ.js +100 -0
- package/dist/chunk-SCFW5MJZ.js.map +1 -0
- package/dist/{chunk-ZYOHF37V.js → chunk-SG5ZWT6C.js} +3 -3
- package/dist/{chunk-ZYOHF37V.js.map → chunk-SG5ZWT6C.js.map} +1 -1
- package/dist/{chunk-ED7ANP6W.cjs → chunk-TIMPJL5V.cjs} +4 -4
- package/dist/{chunk-ED7ANP6W.cjs.map → chunk-TIMPJL5V.cjs.map} +1 -1
- package/dist/{chunk-3XKVRLR2.js → chunk-TOTP24P6.js} +4 -4
- package/dist/{chunk-3XKVRLR2.js.map → chunk-TOTP24P6.js.map} +1 -1
- package/dist/{chunk-PG3QQLWS.cjs → chunk-USZTVNUQ.cjs} +5 -5
- package/dist/{chunk-PG3QQLWS.cjs.map → chunk-USZTVNUQ.cjs.map} +1 -1
- package/dist/{chunk-XS7SKY2F.js → chunk-V2RBCCN5.js} +3 -3
- package/dist/chunk-V2RBCCN5.js.map +1 -0
- package/dist/{chunk-D3SJLXYZ.cjs → chunk-VJYSQXN6.cjs} +10 -10
- package/dist/{chunk-D3SJLXYZ.cjs.map → chunk-VJYSQXN6.cjs.map} +1 -1
- package/dist/{chunk-MXRBNJ6D.cjs → chunk-W4WKVOOQ.cjs} +11 -11
- package/dist/{chunk-MXRBNJ6D.cjs.map → chunk-W4WKVOOQ.cjs.map} +1 -1
- package/dist/chunk-XYOHKCYG.cjs +109 -0
- package/dist/chunk-XYOHKCYG.cjs.map +1 -0
- package/dist/{chunk-UD2T7ISG.js → chunk-YP67XZES.js} +4 -4
- package/dist/{chunk-UD2T7ISG.js.map → chunk-YP67XZES.js.map} +1 -1
- package/dist/{chunk-HHUDNTZC.js → chunk-YRXY2A5L.js} +4 -4
- package/dist/{chunk-HHUDNTZC.js.map → chunk-YRXY2A5L.js.map} +1 -1
- package/dist/{chunk-6OKPJZMX.cjs → chunk-Z2CUEBXV.cjs} +25 -9
- package/dist/chunk-Z2CUEBXV.cjs.map +1 -0
- package/dist/{chunk-HI6G3SNY.js → chunk-ZYB6B7QJ.js} +72 -125
- package/dist/chunk-ZYB6B7QJ.js.map +1 -0
- package/dist/compact-session-PYEC3NZV.js +18 -0
- package/dist/{compact-session-RR3ILTES.js.map → compact-session-PYEC3NZV.js.map} +1 -1
- package/dist/compact-session-VVT6IBJG.cjs +55 -0
- package/dist/{compact-session-YOWJJPPB.cjs.map → compact-session-VVT6IBJG.cjs.map} +1 -1
- package/dist/compaction.cjs +16 -16
- package/dist/compaction.js +3 -3
- package/dist/concurrency.cjs +6 -6
- package/dist/concurrency.js +4 -4
- package/dist/context-2FZSC6VQ.cjs +22 -0
- package/dist/{context-Q6ISOCN2.cjs.map → context-2FZSC6VQ.cjs.map} +1 -1
- package/dist/context-ATJJAFOS.js +5 -0
- package/dist/{context-ZDBBPIHY.js.map → context-ATJJAFOS.js.map} +1 -1
- package/dist/{cron-ChQ6zcW2.d.ts → cron-Bx7tzm5R.d.ts} +54 -2
- package/dist/{cron-BdXOZco9.d.cts → cron-D-DVjGQe.d.cts} +54 -2
- package/dist/cron.cjs +33 -29
- package/dist/cron.d.cts +3 -3
- package/dist/cron.d.ts +3 -3
- package/dist/cron.js +32 -28
- package/dist/{errors-BUVjJGJA.d.cts → errors-DMY-gLSK.d.cts} +1 -1
- package/dist/{errors-CZIUKLHt.d.ts → errors-DjBQ4Tn8.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 +41 -36
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +37 -32
- package/dist/eval.js.map +1 -1
- package/dist/{executor-DPCBSI35.cjs → executor-BMRICN46.cjs} +26 -25
- package/dist/executor-BMRICN46.cjs.map +1 -0
- package/dist/{executor-ASDDIM2X.js → executor-T65PPOPT.js} +10 -9
- package/dist/executor-T65PPOPT.js.map +1 -0
- package/dist/filesystem/index.cjs +7 -7
- package/dist/filesystem/index.js +3 -3
- package/dist/fs-session-store-J5MCFFUM.cjs +19 -0
- package/dist/{fs-session-store-T5ZLQX42.cjs.map → fs-session-store-J5MCFFUM.cjs.map} +1 -1
- package/dist/fs-session-store-O6FNHECD.js +10 -0
- package/dist/{fs-session-store-K5QUPNJZ.js.map → fs-session-store-O6FNHECD.js.map} +1 -1
- package/dist/generate-object-UF6WIZLF.cjs +20 -0
- package/dist/{generate-object-F56VIZ6U.cjs.map → generate-object-UF6WIZLF.cjs.map} +1 -1
- package/dist/generate-object-XDCBYVK3.js +7 -0
- package/dist/{generate-object-LPSO6GVW.js.map → generate-object-XDCBYVK3.js.map} +1 -1
- package/dist/index-manager-N7RQYUKT.cjs +20 -0
- package/dist/{index-manager-DBJ55ZSO.cjs.map → index-manager-N7RQYUKT.cjs.map} +1 -1
- package/dist/index-manager-ZVZUHPP7.js +11 -0
- package/dist/{index-manager-F2H2RCZU.js.map → index-manager-ZVZUHPP7.js.map} +1 -1
- package/dist/index.cjs +138 -132
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +167 -9
- package/dist/index.d.ts +167 -9
- package/dist/index.js +47 -44
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-RKNLUE72.js → inject-session-GQMTDZUN.js} +7 -6
- package/dist/inject-session-GQMTDZUN.js.map +1 -0
- package/dist/{inject-session-25EC74WV.cjs → inject-session-LFCYVSLJ.cjs} +9 -8
- package/dist/inject-session-LFCYVSLJ.cjs.map +1 -0
- package/dist/internal/agent-loop/loop-thinking-steps.d.ts +28 -0
- package/dist/internal/agent-loop/message-builders.d.ts +12 -3
- package/dist/internal/diagnostics.d.ts +24 -11
- package/dist/internal/llm/anthropic-shared.d.ts +4 -4
- package/dist/internal/llm/types.d.ts +49 -9
- package/dist/internal/local-agent/mcp-pool.d.ts +7 -3
- package/dist/internal/memory/adapters/azure-openai-embedding.d.cts +2 -0
- package/dist/internal/memory/adapters/catalog.d.cts +1 -0
- package/dist/internal/memory/adapters/cohere-embedding.d.cts +2 -0
- package/dist/internal/memory/adapters/deepinfra-embedding.d.cts +2 -0
- package/dist/internal/memory/adapters/gemini-embedding.d.cts +2 -0
- package/dist/internal/memory/adapters/index.cjs +28 -0
- package/dist/internal/memory/adapters/index.cjs.map +1 -0
- package/dist/internal/memory/adapters/index.d.cts +16 -0
- package/dist/internal/memory/adapters/index.d.ts +16 -0
- package/dist/internal/memory/adapters/index.js +11 -0
- package/dist/internal/memory/adapters/index.js.map +1 -0
- package/dist/internal/memory/adapters/jina-embedding.d.cts +2 -0
- package/dist/internal/memory/adapters/mistral-embedding.d.cts +2 -0
- package/dist/internal/memory/adapters/ollama-embedding.d.cts +34 -0
- package/dist/internal/memory/adapters/openai-compatible.d.cts +51 -0
- package/dist/internal/memory/adapters/openai-compatible.d.ts +28 -0
- package/dist/internal/memory/adapters/openai-embedding.d.cts +2 -0
- package/dist/internal/memory/adapters/openrouter-embedding.d.cts +2 -0
- package/dist/internal/memory/adapters/voyage-embedding.d.cts +2 -0
- package/dist/internal/memory/dreaming/diary.d.ts +4 -0
- package/dist/internal/memory/dreaming/phases.d.ts +15 -0
- package/dist/internal/memory/dreaming/run.d.ts +10 -0
- package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +15 -0
- package/dist/internal/memory/sdk-memory-peer-loader.d.ts +21 -0
- package/dist/internal/persistence/index.cjs +25 -25
- package/dist/internal/persistence/index.js +6 -6
- package/dist/internal/persistence/session-transcript.d.cts +6 -0
- package/dist/internal/persistence/session-transcript.d.ts +6 -0
- package/dist/internal/runtime/concurrency/subagent-credentials.d.ts +35 -0
- package/dist/internal/security/index.cjs +13 -13
- package/dist/internal/security/index.js +3 -3
- package/dist/internal/session/agent-session-store.d.ts +1 -0
- package/dist/internal/session/session-types.d.ts +6 -1
- package/dist/judge-call-NA2G6ZMJ.js +5 -0
- package/dist/{judge-call-3S3T6O2Z.js.map → judge-call-NA2G6ZMJ.js.map} +1 -1
- package/dist/judge-call-U2D33JOW.cjs +22 -0
- package/dist/{judge-call-XIQJ5GIE.cjs.map → judge-call-U2D33JOW.cjs.map} +1 -1
- package/dist/models.cjs +20 -20
- package/dist/models.js +5 -5
- package/dist/path-safety.cjs +10 -10
- package/dist/path-safety.js +3 -3
- package/dist/persistence.cjs +35 -35
- package/dist/persistence.js +7 -7
- package/dist/project.cjs +5 -5
- package/dist/project.js +3 -3
- package/dist/registry-CAS6Y5ZY.js +9 -0
- package/dist/{registry-KMI5RA22.js.map → registry-CAS6Y5ZY.js.map} +1 -1
- package/dist/registry-JSDI4WKA.cjs +46 -0
- package/dist/{registry-BA3SLAN7.cjs.map → registry-JSDI4WKA.cjs.map} +1 -1
- package/dist/retry.cjs +4 -4
- package/dist/retry.js +3 -3
- package/dist/{run-vJHg2eGw.d.cts → run-i2-fUohR.d.cts} +16 -0
- package/dist/{run-vJHg2eGw.d.ts → run-i2-fUohR.d.ts} +16 -0
- package/dist/sandbox/index.cjs +6 -6
- package/dist/sandbox/index.js +2 -2
- 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-3B52DKTG.js +5 -0
- package/dist/{session-transcript-MMPWCESR.js.map → session-transcript-3B52DKTG.js.map} +1 -1
- package/dist/session-transcript-H7NUFXXM.cjs +50 -0
- package/dist/{session-transcript-DFGX6WNL.cjs.map → session-transcript-H7NUFXXM.cjs.map} +1 -1
- package/dist/skills.cjs +7 -7
- package/dist/skills.js +5 -5
- package/dist/stream-object-4FDU76YW.cjs +20 -0
- package/dist/{stream-object-YPXZ4F5P.cjs.map → stream-object-4FDU76YW.cjs.map} +1 -1
- package/dist/stream-object-HWDEEQN4.js +7 -0
- package/dist/{stream-object-AFERZU63.js.map → stream-object-HWDEEQN4.js.map} +1 -1
- package/dist/subagents-loader-A4W6C3QP.cjs +15 -0
- package/dist/subagents-loader-A4W6C3QP.cjs.map +1 -0
- package/dist/subagents-loader-X33KH2SZ.js +6 -0
- package/dist/subagents-loader-X33KH2SZ.js.map +1 -0
- 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.d.ts +68 -3
- package/dist/types/conversation.d.ts +7 -0
- package/dist/types/messages.d.ts +9 -0
- package/dist/types/session-message.d.ts +59 -0
- package/dist/types/workflow.d.ts +36 -0
- package/dist/workflow.cjs +27 -27
- package/dist/workflow.d.cts +17 -1
- package/dist/workflow.d.ts +17 -1
- package/dist/workflow.js +6 -6
- package/docs/harness-capability-map.md +22 -0
- package/package.json +11 -1
- package/dist/agent-2GZC4W2A.cjs +0 -51
- package/dist/agent-3H3UKD6U.js +0 -42
- package/dist/batch-LXSALQC3.js.map +0 -1
- package/dist/batch-NZGN6SFV.cjs.map +0 -1
- package/dist/chunk-3BSP7LSG.cjs.map +0 -1
- package/dist/chunk-4APWS2YF.js.map +0 -1
- package/dist/chunk-6OKPJZMX.cjs.map +0 -1
- package/dist/chunk-6ZGD7R27.cjs.map +0 -1
- package/dist/chunk-A4XXV2C6.js.map +0 -1
- package/dist/chunk-A6GXYF2Q.js.map +0 -1
- package/dist/chunk-ACHGT3D2.js.map +0 -1
- package/dist/chunk-AOZYORH7.js.map +0 -1
- package/dist/chunk-BE3W4HYV.cjs.map +0 -1
- package/dist/chunk-BUGVDCI5.cjs.map +0 -1
- package/dist/chunk-FV3YEMQ7.js.map +0 -1
- package/dist/chunk-G2F67XUR.cjs.map +0 -1
- package/dist/chunk-G7X2Y7Y2.cjs.map +0 -1
- package/dist/chunk-HI6G3SNY.js.map +0 -1
- package/dist/chunk-IBDE4R5L.cjs.map +0 -1
- package/dist/chunk-KCZW75PI.js.map +0 -1
- package/dist/chunk-OFWU6UKF.cjs.map +0 -1
- package/dist/chunk-UZBA6YYP.cjs.map +0 -1
- package/dist/chunk-VUDH4D2M.js.map +0 -1
- package/dist/chunk-XS7SKY2F.js.map +0 -1
- package/dist/compact-session-RR3ILTES.js +0 -17
- package/dist/compact-session-YOWJJPPB.cjs +0 -54
- package/dist/context-Q6ISOCN2.cjs +0 -22
- package/dist/context-ZDBBPIHY.js +0 -5
- package/dist/executor-ASDDIM2X.js.map +0 -1
- package/dist/executor-DPCBSI35.cjs.map +0 -1
- package/dist/fs-session-store-K5QUPNJZ.js +0 -10
- package/dist/fs-session-store-T5ZLQX42.cjs +0 -19
- package/dist/generate-object-F56VIZ6U.cjs +0 -20
- package/dist/generate-object-LPSO6GVW.js +0 -7
- package/dist/index-manager-DBJ55ZSO.cjs +0 -19
- package/dist/index-manager-F2H2RCZU.js +0 -10
- package/dist/inject-session-25EC74WV.cjs.map +0 -1
- package/dist/inject-session-RKNLUE72.js.map +0 -1
- package/dist/judge-call-3S3T6O2Z.js +0 -5
- package/dist/judge-call-XIQJ5GIE.cjs +0 -22
- package/dist/registry-BA3SLAN7.cjs +0 -46
- package/dist/registry-KMI5RA22.js +0 -9
- package/dist/session-transcript-DFGX6WNL.cjs +0 -50
- package/dist/session-transcript-MMPWCESR.js +0 -5
- package/dist/stream-object-AFERZU63.js +0 -7
- package/dist/stream-object-YPXZ4F5P.cjs +0 -20
|
@@ -1,34 +1,35 @@
|
|
|
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 chunkN475ETD6_cjs = require('./chunk-N475ETD6.cjs');
|
|
5
|
+
var chunkDCXRHCZJ_cjs = require('./chunk-DCXRHCZJ.cjs');
|
|
6
|
+
var chunk74D7KSBP_cjs = require('./chunk-74D7KSBP.cjs');
|
|
7
|
+
var chunkBPN5ONSW_cjs = require('./chunk-BPN5ONSW.cjs');
|
|
8
|
+
var chunkCN6UX5EV_cjs = require('./chunk-CN6UX5EV.cjs');
|
|
9
|
+
var chunk6LGQECT7_cjs = require('./chunk-6LGQECT7.cjs');
|
|
10
10
|
var chunkWPZTYOUX_cjs = require('./chunk-WPZTYOUX.cjs');
|
|
11
|
-
var
|
|
11
|
+
var chunkLALG2K33_cjs = require('./chunk-LALG2K33.cjs');
|
|
12
|
+
var chunk7U2HAAWB_cjs = require('./chunk-7U2HAAWB.cjs');
|
|
12
13
|
var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
|
|
13
|
-
var
|
|
14
|
+
var chunkB4YA6BRS_cjs = require('./chunk-B4YA6BRS.cjs');
|
|
14
15
|
var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
|
|
15
16
|
var chunkYPEPCZHF_cjs = require('./chunk-YPEPCZHF.cjs');
|
|
16
17
|
var chunkVJ26EKGJ_cjs = require('./chunk-VJ26EKGJ.cjs');
|
|
17
|
-
var
|
|
18
|
-
var
|
|
18
|
+
var chunk7OLG7VI4_cjs = require('./chunk-7OLG7VI4.cjs');
|
|
19
|
+
var chunkZ2CUEBXV_cjs = require('./chunk-Z2CUEBXV.cjs');
|
|
20
|
+
var chunkDMTZ3FII_cjs = require('./chunk-DMTZ3FII.cjs');
|
|
19
21
|
var chunkYLQQX5W2_cjs = require('./chunk-YLQQX5W2.cjs');
|
|
20
|
-
var chunk6OKPJZMX_cjs = require('./chunk-6OKPJZMX.cjs');
|
|
21
22
|
var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
23
|
+
var chunkDGLLVCNB_cjs = require('./chunk-DGLLVCNB.cjs');
|
|
24
|
+
var chunkW4WKVOOQ_cjs = require('./chunk-W4WKVOOQ.cjs');
|
|
25
|
+
var chunkJ6T5LWJ4_cjs = require('./chunk-J6T5LWJ4.cjs');
|
|
25
26
|
var chunkVYHJZVL5_cjs = require('./chunk-VYHJZVL5.cjs');
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
27
|
+
var chunkG4XUXSRN_cjs = require('./chunk-G4XUXSRN.cjs');
|
|
28
|
+
var chunkE4IUN3JB_cjs = require('./chunk-E4IUN3JB.cjs');
|
|
29
|
+
var chunk7YBJZS5P_cjs = require('./chunk-7YBJZS5P.cjs');
|
|
30
|
+
var chunkG2Q3ZC6C_cjs = require('./chunk-G2Q3ZC6C.cjs');
|
|
31
|
+
var chunkIHFNRNTJ_cjs = require('./chunk-IHFNRNTJ.cjs');
|
|
32
|
+
var chunkBCQ3E2ZG_cjs = require('./chunk-BCQ3E2ZG.cjs');
|
|
32
33
|
var promises = require('fs/promises');
|
|
33
34
|
var crypto = require('crypto');
|
|
34
35
|
var path = require('path');
|
|
@@ -224,7 +225,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
|
|
|
224
225
|
const { output, maxRetries, errorStrategy, ...sendOptions } = options;
|
|
225
226
|
const run = await agent.send(input, sendOptions);
|
|
226
227
|
const result = await run.wait();
|
|
227
|
-
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-
|
|
228
|
+
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-UF6WIZLF.cjs');
|
|
228
229
|
const answer = structurableAnswerOrThrow(result, GenerateObjectError);
|
|
229
230
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
230
231
|
const facade = getAgentFacade();
|
|
@@ -326,7 +327,7 @@ function normalizeModel(m) {
|
|
|
326
327
|
if (m === void 0 || typeof m !== "string") return m;
|
|
327
328
|
const id = m.trim();
|
|
328
329
|
if (id.length === 0) {
|
|
329
|
-
throw new
|
|
330
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
330
331
|
'model must be a non-empty "provider/model" id string or a ModelSelection object',
|
|
331
332
|
{ code: "invalid_model_selection" }
|
|
332
333
|
);
|
|
@@ -462,7 +463,7 @@ function registryPath(cwd) {
|
|
|
462
463
|
return path.join(cwd, REGISTRY_RELATIVE_PATH);
|
|
463
464
|
}
|
|
464
465
|
async function loadRegistry(cwd) {
|
|
465
|
-
return
|
|
466
|
+
return chunkLALG2K33_cjs.readVersionedJson({
|
|
466
467
|
path: registryPath(cwd),
|
|
467
468
|
currentVersion: SCHEMA_VERSION,
|
|
468
469
|
defaultValue: () => ({}),
|
|
@@ -486,7 +487,7 @@ async function saveRegistry(cwd, agents2) {
|
|
|
486
487
|
}
|
|
487
488
|
const path = registryPath(cwd);
|
|
488
489
|
await chunkYLQQX5W2_cjs.withCwdMutex(`registry:${cwd}`, async () => {
|
|
489
|
-
await
|
|
490
|
+
await chunkLALG2K33_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
|
|
490
491
|
});
|
|
491
492
|
}
|
|
492
493
|
function toSerialized(agent) {
|
|
@@ -553,7 +554,7 @@ function scheduleSaveForCwd(cwd) {
|
|
|
553
554
|
}
|
|
554
555
|
} catch (cause) {
|
|
555
556
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
556
|
-
|
|
557
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] registry persist failed (${cwd}): ${msg}
|
|
557
558
|
`);
|
|
558
559
|
} finally {
|
|
559
560
|
pendingSaves.delete(cwd);
|
|
@@ -892,14 +893,14 @@ async function readLegacyFacts(jsonPath) {
|
|
|
892
893
|
}
|
|
893
894
|
async function writeMigratedFacts(cwd, jsonPath, facts) {
|
|
894
895
|
try {
|
|
895
|
-
for (const fact of facts) await
|
|
896
|
+
for (const fact of facts) await chunkCN6UX5EV_cjs.appendFactToMarkdown(cwd, fact);
|
|
896
897
|
await promises.unlink(jsonPath).catch(() => void 0);
|
|
897
|
-
|
|
898
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
|
|
898
899
|
`);
|
|
899
900
|
return { migrated: true, factCount: facts.length };
|
|
900
901
|
} catch (cause) {
|
|
901
902
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
902
|
-
|
|
903
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] memory migration failed (readonly fs?): ${message}
|
|
903
904
|
`);
|
|
904
905
|
return { migrated: false, factCount: 0, reason: "readonly-fs" };
|
|
905
906
|
}
|
|
@@ -909,12 +910,12 @@ async function migrateLegacyJson(cwd, config) {
|
|
|
909
910
|
const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
|
|
910
911
|
if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
|
|
911
912
|
migrationRun.add(key);
|
|
912
|
-
const jsonPath =
|
|
913
|
+
const jsonPath = chunkCN6UX5EV_cjs.legacyMemoryJsonPath(cwd, config);
|
|
913
914
|
if (!await fileExists(jsonPath)) {
|
|
914
915
|
return { migrated: false, factCount: 0, reason: "no-legacy-json" };
|
|
915
916
|
}
|
|
916
|
-
if (await fileExists(
|
|
917
|
-
|
|
917
|
+
if (await fileExists(chunkCN6UX5EV_cjs.memoryMdPath(cwd))) {
|
|
918
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
918
919
|
`[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
|
|
919
920
|
`
|
|
920
921
|
);
|
|
@@ -938,13 +939,13 @@ function extractMemoryFact(message) {
|
|
|
938
939
|
async function readMemoryFacts(cwd, config) {
|
|
939
940
|
if (!config.enabled) return [];
|
|
940
941
|
await migrateLegacyJson(cwd, config);
|
|
941
|
-
return
|
|
942
|
+
return chunkCN6UX5EV_cjs.readFacts(cwd, config);
|
|
942
943
|
}
|
|
943
944
|
async function appendMemoryFact(cwd, config, fact) {
|
|
944
945
|
if (!config.enabled) return;
|
|
945
946
|
await migrateLegacyJson(cwd, config);
|
|
946
|
-
const sanitized = { text:
|
|
947
|
-
await
|
|
947
|
+
const sanitized = { text: chunkBCQ3E2ZG_cjs.redactSecrets(fact.text) };
|
|
948
|
+
await chunkCN6UX5EV_cjs.appendFact(cwd, config, sanitized);
|
|
948
949
|
}
|
|
949
950
|
|
|
950
951
|
// src/internal/runtime/fixtures/fixture-scripts.ts
|
|
@@ -1292,7 +1293,7 @@ function redactScriptSecrets(script) {
|
|
|
1292
1293
|
function redactEventSecrets(event) {
|
|
1293
1294
|
const serialized = JSON.stringify(event);
|
|
1294
1295
|
const localStripped = serialized.replace(FIXTURE_SENTINEL, "***");
|
|
1295
|
-
const redacted =
|
|
1296
|
+
const redacted = chunkBCQ3E2ZG_cjs.redactSecrets(localStripped);
|
|
1296
1297
|
if (redacted === serialized) return event;
|
|
1297
1298
|
return JSON.parse(redacted);
|
|
1298
1299
|
}
|
|
@@ -1615,7 +1616,7 @@ function createRealCloudRun(options) {
|
|
|
1615
1616
|
conversation: []
|
|
1616
1617
|
};
|
|
1617
1618
|
const apiKey = resolveApiKey(options.agentOptions.apiKey);
|
|
1618
|
-
const baseUrl =
|
|
1619
|
+
const baseUrl = chunkBPN5ONSW_cjs.getConfiguredBaseUrl();
|
|
1619
1620
|
const handle = new RealCloudRun(
|
|
1620
1621
|
{
|
|
1621
1622
|
id,
|
|
@@ -1688,7 +1689,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1688
1689
|
});
|
|
1689
1690
|
if (!response.ok) {
|
|
1690
1691
|
const text = await response.text().catch(() => "");
|
|
1691
|
-
throw new
|
|
1692
|
+
throw new chunkIHFNRNTJ_cjs.NetworkError(
|
|
1692
1693
|
`Cloud Run endpoint returned ${response.status}: ${text.slice(0, 200)}`,
|
|
1693
1694
|
{ code: "cloud_run_http_error" }
|
|
1694
1695
|
);
|
|
@@ -1698,7 +1699,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1698
1699
|
async consumeStream(response) {
|
|
1699
1700
|
let finalStatus = "finished";
|
|
1700
1701
|
let finalText = "";
|
|
1701
|
-
for await (const record of
|
|
1702
|
+
for await (const record of chunkBPN5ONSW_cjs.parseSseStream(response.body, this.controller.signal)) {
|
|
1702
1703
|
const parsed = safeParse(record.data);
|
|
1703
1704
|
if (parsed === void 0) continue;
|
|
1704
1705
|
const update = this.applyRecord(record.event, parsed);
|
|
@@ -1807,7 +1808,7 @@ var CloudAgent = class {
|
|
|
1807
1808
|
*/
|
|
1808
1809
|
isFixtureMode() {
|
|
1809
1810
|
const apiKey = resolveApiKey(this.options.apiKey);
|
|
1810
|
-
return
|
|
1811
|
+
return chunkBPN5ONSW_cjs.isFixtureApiKey(apiKey) && chunkBPN5ONSW_cjs.getConfiguredBaseUrl() === void 0;
|
|
1811
1812
|
}
|
|
1812
1813
|
// SE9 — integrated structured output; delegates to the shared helper.
|
|
1813
1814
|
generate(message, options) {
|
|
@@ -1822,7 +1823,7 @@ var CloudAgent = class {
|
|
|
1822
1823
|
}
|
|
1823
1824
|
async send(message, options = {}) {
|
|
1824
1825
|
if (options.tools !== void 0 && options.tools.length > 0) {
|
|
1825
|
-
throw new
|
|
1826
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
1826
1827
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
1827
1828
|
{ code: "cloud_custom_tools_rejected" }
|
|
1828
1829
|
);
|
|
@@ -1858,7 +1859,7 @@ var CloudAgent = class {
|
|
|
1858
1859
|
const userText = typeof message === "string" ? message : message.text;
|
|
1859
1860
|
const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
|
|
1860
1861
|
const apiKey = resolveApiKey(this.options.apiKey);
|
|
1861
|
-
const useRealRuntime = apiKey !== void 0 && !
|
|
1862
|
+
const useRealRuntime = apiKey !== void 0 && !chunkBPN5ONSW_cjs.isFixtureApiKey(apiKey) && chunkBPN5ONSW_cjs.getConfiguredBaseUrl() !== void 0;
|
|
1862
1863
|
return useRealRuntime ? createRealCloudRun({
|
|
1863
1864
|
agentId: this.agentId,
|
|
1864
1865
|
model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
|
|
@@ -1907,7 +1908,7 @@ var CloudAgent = class {
|
|
|
1907
1908
|
listArtifacts() {
|
|
1908
1909
|
if (!this.isFixtureMode()) {
|
|
1909
1910
|
return Promise.reject(
|
|
1910
|
-
new
|
|
1911
|
+
new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
1911
1912
|
"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).",
|
|
1912
1913
|
{ code: "cloud_runtime_pre_release" }
|
|
1913
1914
|
)
|
|
@@ -1917,11 +1918,11 @@ var CloudAgent = class {
|
|
|
1917
1918
|
}
|
|
1918
1919
|
downloadArtifact(path) {
|
|
1919
1920
|
try {
|
|
1920
|
-
|
|
1921
|
+
chunk7YBJZS5P_cjs.validateArtifactPath(path);
|
|
1921
1922
|
} catch (cause) {
|
|
1922
|
-
if (cause instanceof
|
|
1923
|
+
if (cause instanceof chunk7YBJZS5P_cjs.PathTraversalError) {
|
|
1923
1924
|
return Promise.reject(
|
|
1924
|
-
new
|
|
1925
|
+
new chunkIHFNRNTJ_cjs.ConfigurationError(`Artifact path must stay inside the workspace: ${path}`, {
|
|
1925
1926
|
code: "artifact_path_traversal",
|
|
1926
1927
|
cause
|
|
1927
1928
|
})
|
|
@@ -1931,7 +1932,7 @@ var CloudAgent = class {
|
|
|
1931
1932
|
}
|
|
1932
1933
|
if (!this.isFixtureMode()) {
|
|
1933
1934
|
return Promise.reject(
|
|
1934
|
-
new
|
|
1935
|
+
new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
1935
1936
|
"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).",
|
|
1936
1937
|
{ code: "cloud_runtime_pre_release" }
|
|
1937
1938
|
)
|
|
@@ -1940,7 +1941,7 @@ var CloudAgent = class {
|
|
|
1940
1941
|
const match = buildFixtureArtifacts().find((artifact) => artifact.path === path);
|
|
1941
1942
|
if (match === void 0) {
|
|
1942
1943
|
return Promise.reject(
|
|
1943
|
-
new
|
|
1944
|
+
new chunkIHFNRNTJ_cjs.UnknownAgentError(`Artifact ${path} not found`, { code: "unknown_artifact" })
|
|
1944
1945
|
);
|
|
1945
1946
|
}
|
|
1946
1947
|
return Promise.resolve(Buffer.from(`fixture artifact content for ${path}
|
|
@@ -1954,7 +1955,7 @@ var CloudAgent = class {
|
|
|
1954
1955
|
* @public
|
|
1955
1956
|
*/
|
|
1956
1957
|
runUntil() {
|
|
1957
|
-
throw new
|
|
1958
|
+
throw new chunkIHFNRNTJ_cjs.UnsupportedRunOperationError(
|
|
1958
1959
|
"Agent.runUntil() is not supported on cloud agents. Cloud runtime manages goal loops server-side. Use a local agent for autonomous Ralph loops.",
|
|
1959
1960
|
"runUntil"
|
|
1960
1961
|
);
|
|
@@ -1965,7 +1966,7 @@ var CloudAgent = class {
|
|
|
1965
1966
|
* @public
|
|
1966
1967
|
*/
|
|
1967
1968
|
fork() {
|
|
1968
|
-
throw new
|
|
1969
|
+
throw new chunkIHFNRNTJ_cjs.UnsupportedRunOperationError(
|
|
1969
1970
|
"Agent.fork() is not supported on cloud agents. Fork inheritance requires local credential + system-prompt access. Use a local agent.",
|
|
1970
1971
|
"fork"
|
|
1971
1972
|
);
|
|
@@ -1977,7 +1978,7 @@ var CloudAgent = class {
|
|
|
1977
1978
|
* @public
|
|
1978
1979
|
*/
|
|
1979
1980
|
runToCompletion() {
|
|
1980
|
-
throw new
|
|
1981
|
+
throw new chunkIHFNRNTJ_cjs.UnsupportedRunOperationError(
|
|
1981
1982
|
"Agent.runToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
1982
1983
|
"runToCompletion"
|
|
1983
1984
|
);
|
|
@@ -1989,7 +1990,7 @@ var CloudAgent = class {
|
|
|
1989
1990
|
* @public
|
|
1990
1991
|
*/
|
|
1991
1992
|
streamToCompletion() {
|
|
1992
|
-
throw new
|
|
1993
|
+
throw new chunkIHFNRNTJ_cjs.UnsupportedRunOperationError(
|
|
1993
1994
|
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
1994
1995
|
"streamToCompletion"
|
|
1995
1996
|
);
|
|
@@ -2003,7 +2004,7 @@ var CloudAgent = class {
|
|
|
2003
2004
|
*/
|
|
2004
2005
|
usePersonality() {
|
|
2005
2006
|
return Promise.reject(
|
|
2006
|
-
new
|
|
2007
|
+
new chunkIHFNRNTJ_cjs.UnsupportedRunOperationError(
|
|
2007
2008
|
"Agent.usePersonality() is not supported on cloud agents (pre-release). Use a local agent or wait for cloud GA.",
|
|
2008
2009
|
"usePersonality"
|
|
2009
2010
|
)
|
|
@@ -2031,7 +2032,7 @@ function validateCloudToolParity(options) {
|
|
|
2031
2032
|
function rejectProcessors(options) {
|
|
2032
2033
|
const hasProcessors = (options.inputProcessors?.length ?? 0) > 0 || (options.outputProcessors?.length ?? 0) > 0;
|
|
2033
2034
|
if (hasProcessors) {
|
|
2034
|
-
throw new
|
|
2035
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
2035
2036
|
"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.",
|
|
2036
2037
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2037
2038
|
);
|
|
@@ -2039,7 +2040,7 @@ function rejectProcessors(options) {
|
|
|
2039
2040
|
}
|
|
2040
2041
|
function rejectFunctionSystemPrompt(options) {
|
|
2041
2042
|
if (typeof options.systemPrompt === "function") {
|
|
2042
|
-
throw new
|
|
2043
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
2043
2044
|
"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.",
|
|
2044
2045
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2045
2046
|
);
|
|
@@ -2047,7 +2048,7 @@ function rejectFunctionSystemPrompt(options) {
|
|
|
2047
2048
|
}
|
|
2048
2049
|
function rejectFunctionSkills(options) {
|
|
2049
2050
|
if (typeof options.skills === "function") {
|
|
2050
|
-
throw new
|
|
2051
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
2051
2052
|
"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.",
|
|
2052
2053
|
{ code: "cloud_incompatible_function_resolver" }
|
|
2053
2054
|
);
|
|
@@ -2059,7 +2060,7 @@ function rejectStdioMcpLocalPaths(options) {
|
|
|
2059
2060
|
if (!isStdioCommandConfig(config)) continue;
|
|
2060
2061
|
const command = config.command ?? "";
|
|
2061
2062
|
if (isLocalPath(command)) {
|
|
2062
|
-
throw new
|
|
2063
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
2063
2064
|
`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.`,
|
|
2064
2065
|
{ code: "cloud_incompatible_mcp_stdio_local" }
|
|
2065
2066
|
);
|
|
@@ -2099,14 +2100,14 @@ async function readState(filePath) {
|
|
|
2099
2100
|
try {
|
|
2100
2101
|
parsed = JSON.parse(raw);
|
|
2101
2102
|
} catch {
|
|
2102
|
-
|
|
2103
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
2103
2104
|
"personality-store-json-parse",
|
|
2104
2105
|
"[theokit-sdk] personality.json is malformed; treating as empty"
|
|
2105
2106
|
);
|
|
2106
2107
|
return emptyState();
|
|
2107
2108
|
}
|
|
2108
2109
|
if (!isStateV1(parsed)) {
|
|
2109
|
-
|
|
2110
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
2110
2111
|
"personality-store-bad-version",
|
|
2111
2112
|
`[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
|
|
2112
2113
|
);
|
|
@@ -2137,9 +2138,9 @@ var PersonalityStore = class {
|
|
|
2137
2138
|
try {
|
|
2138
2139
|
await this.#persist(agentId, slug);
|
|
2139
2140
|
} catch (err) {
|
|
2140
|
-
|
|
2141
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
2141
2142
|
`personality-store-persist-failure-${agentId}`,
|
|
2142
|
-
`[theokit-sdk] personality persist failed for ${
|
|
2143
|
+
`[theokit-sdk] personality persist failed for ${chunkBCQ3E2ZG_cjs.redactSecrets(agentId)}: ${chunkBCQ3E2ZG_cjs.redactSecrets(
|
|
2143
2144
|
err.message
|
|
2144
2145
|
)}`
|
|
2145
2146
|
);
|
|
@@ -2154,9 +2155,9 @@ var PersonalityStore = class {
|
|
|
2154
2155
|
try {
|
|
2155
2156
|
state = await readState(filePath);
|
|
2156
2157
|
} catch (err) {
|
|
2157
|
-
|
|
2158
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
2158
2159
|
`personality-store-hydrate-failure-${agentId}`,
|
|
2159
|
-
`[theokit-sdk] personality hydrate failed for ${
|
|
2160
|
+
`[theokit-sdk] personality hydrate failed for ${chunkBCQ3E2ZG_cjs.redactSecrets(agentId)}: ${chunkBCQ3E2ZG_cjs.redactSecrets(
|
|
2160
2161
|
err.message
|
|
2161
2162
|
)}`
|
|
2162
2163
|
);
|
|
@@ -2173,17 +2174,17 @@ var PersonalityStore = class {
|
|
|
2173
2174
|
async #persist(agentId, slug) {
|
|
2174
2175
|
const filePath = this.#filePath();
|
|
2175
2176
|
await promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
2176
|
-
await
|
|
2177
|
+
await chunkDMTZ3FII_cjs.withFileLock(filePath, async () => {
|
|
2177
2178
|
const current = await readState(filePath);
|
|
2178
2179
|
const nextAgents = { ...current.agents };
|
|
2179
2180
|
if (slug === void 0) delete nextAgents[agentId];
|
|
2180
2181
|
else nextAgents[agentId] = slug;
|
|
2181
2182
|
const next = { version: SCHEMA_VERSION2, agents: nextAgents };
|
|
2182
|
-
await
|
|
2183
|
+
await chunkDGLLVCNB_cjs.atomicWriteJson(filePath, next);
|
|
2183
2184
|
});
|
|
2184
2185
|
}
|
|
2185
2186
|
#filePath() {
|
|
2186
|
-
return path.join(
|
|
2187
|
+
return path.join(chunkLALG2K33_cjs.getTheokitHome(this.#cwd), FILE_NAME);
|
|
2187
2188
|
}
|
|
2188
2189
|
};
|
|
2189
2190
|
|
|
@@ -2206,7 +2207,7 @@ function createPluginContext() {
|
|
|
2206
2207
|
},
|
|
2207
2208
|
on(hook, handler) {
|
|
2208
2209
|
if (typeof handler !== "function") {
|
|
2209
|
-
|
|
2210
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] ignoring non-function handler for hook "${hook}"
|
|
2210
2211
|
`);
|
|
2211
2212
|
return;
|
|
2212
2213
|
}
|
|
@@ -2259,7 +2260,7 @@ var PluginManager = class {
|
|
|
2259
2260
|
const seen = /* @__PURE__ */ new Set();
|
|
2260
2261
|
for (const plugin of plugins) {
|
|
2261
2262
|
if (seen.has(plugin.name)) {
|
|
2262
|
-
|
|
2263
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
2263
2264
|
`[theokit-sdk] duplicate plugin name "${plugin.name}" \u2014 both will register independently
|
|
2264
2265
|
`
|
|
2265
2266
|
);
|
|
@@ -2286,7 +2287,7 @@ var PluginManager = class {
|
|
|
2286
2287
|
*/
|
|
2287
2288
|
async register(plugin) {
|
|
2288
2289
|
if (plugin.kind !== "general") {
|
|
2289
|
-
throw new
|
|
2290
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
2290
2291
|
`late register supports general plugins only (got "${plugin.kind}" for "${plugin.name}")`,
|
|
2291
2292
|
{ code: "plugin_late_register_kind" }
|
|
2292
2293
|
);
|
|
@@ -2343,7 +2344,7 @@ var PluginManager = class {
|
|
|
2343
2344
|
parts.push(result.recalledContext);
|
|
2344
2345
|
}
|
|
2345
2346
|
} catch (err) {
|
|
2346
|
-
|
|
2347
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
2347
2348
|
`[theokit-sdk] pre_user_send hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2348
2349
|
`
|
|
2349
2350
|
);
|
|
@@ -2371,7 +2372,7 @@ var PluginManager = class {
|
|
|
2371
2372
|
try {
|
|
2372
2373
|
await h(ctx);
|
|
2373
2374
|
} catch (err) {
|
|
2374
|
-
|
|
2375
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
2375
2376
|
`[theokit-sdk] post_assistant_reply hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2376
2377
|
`
|
|
2377
2378
|
);
|
|
@@ -2387,7 +2388,7 @@ var PluginManager = class {
|
|
|
2387
2388
|
try {
|
|
2388
2389
|
await h(ctx);
|
|
2389
2390
|
} catch (err) {
|
|
2390
|
-
|
|
2391
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
2391
2392
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2392
2393
|
`
|
|
2393
2394
|
);
|
|
@@ -2402,7 +2403,7 @@ var PluginManager = class {
|
|
|
2402
2403
|
const out = await h(current, ctx);
|
|
2403
2404
|
if (out !== void 0) current = out;
|
|
2404
2405
|
} catch (err) {
|
|
2405
|
-
|
|
2406
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
2406
2407
|
`[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
|
|
2407
2408
|
`
|
|
2408
2409
|
);
|
|
@@ -2544,7 +2545,7 @@ var HooksExecutor = class {
|
|
|
2544
2545
|
this.config = {};
|
|
2545
2546
|
return;
|
|
2546
2547
|
}
|
|
2547
|
-
this.config = await
|
|
2548
|
+
this.config = await chunk6LGQECT7_cjs.loadHookConfig(this.cwd);
|
|
2548
2549
|
}
|
|
2549
2550
|
/** Fire every hook registered for `event` and aggregate the decisions. */
|
|
2550
2551
|
async run(payload) {
|
|
@@ -2650,11 +2651,11 @@ function buildContextBudgetEvent(model, resolved) {
|
|
|
2650
2651
|
// src/internal/runtime/lifecycle/post-run-lifecycle.ts
|
|
2651
2652
|
function resolveWindowForRun(model, contextWindow) {
|
|
2652
2653
|
const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
|
|
2653
|
-
return
|
|
2654
|
+
return chunkJ6T5LWJ4_cjs.resolveEffectiveContextWindow({
|
|
2654
2655
|
...override !== void 0 ? { override } : {},
|
|
2655
|
-
catalog:
|
|
2656
|
-
margin:
|
|
2657
|
-
floor:
|
|
2656
|
+
catalog: chunkG4XUXSRN_cjs.getCatalogModelInfo(model)?.limit?.context,
|
|
2657
|
+
margin: chunkJ6T5LWJ4_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2658
|
+
floor: chunkJ6T5LWJ4_cjs.CONTEXT_WINDOW_FLOOR
|
|
2658
2659
|
});
|
|
2659
2660
|
}
|
|
2660
2661
|
async function runPostRunLifecycle(inputs) {
|
|
@@ -2678,32 +2679,32 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2678
2679
|
try {
|
|
2679
2680
|
const parcial = await safeConversation(run);
|
|
2680
2681
|
if (parcial !== void 0) {
|
|
2681
|
-
|
|
2682
|
+
chunkDCXRHCZJ_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2682
2683
|
userText,
|
|
2683
2684
|
conversation: parcial
|
|
2684
2685
|
});
|
|
2685
2686
|
}
|
|
2686
2687
|
} catch (cause) {
|
|
2687
2688
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2688
|
-
|
|
2689
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2689
2690
|
`);
|
|
2690
2691
|
}
|
|
2691
|
-
await
|
|
2692
|
+
await chunkDCXRHCZJ_cjs.flushSessionWrites();
|
|
2692
2693
|
return;
|
|
2693
2694
|
}
|
|
2694
2695
|
if (result.result !== void 0) {
|
|
2695
|
-
|
|
2696
|
+
chunkDCXRHCZJ_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2696
2697
|
}
|
|
2697
2698
|
const conversation = await safeConversation(run);
|
|
2698
2699
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2699
2700
|
const effectiveWindow = resolvedWindow.window;
|
|
2700
2701
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2701
2702
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2702
|
-
|
|
2703
|
+
chunkN475ETD6_cjs.emitRunEvent(onRunEvent, budgetEvent);
|
|
2703
2704
|
}
|
|
2704
2705
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2705
2706
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2706
|
-
|
|
2707
|
+
chunkDCXRHCZJ_cjs.persistTurnToTranscript(
|
|
2707
2708
|
sessionStore,
|
|
2708
2709
|
{ cwd: workspaceCwd, agentId, model },
|
|
2709
2710
|
agentId,
|
|
@@ -2715,13 +2716,13 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2715
2716
|
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2716
2717
|
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2717
2718
|
contextWindow: effectiveWindow,
|
|
2718
|
-
summarize:
|
|
2719
|
+
summarize: chunkBPN5ONSW_cjs.buildDefaultSummarizer({
|
|
2719
2720
|
agentModel: model,
|
|
2720
2721
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2721
2722
|
})
|
|
2722
2723
|
}
|
|
2723
2724
|
},
|
|
2724
|
-
onRunEvent !== void 0 ? () =>
|
|
2725
|
+
onRunEvent !== void 0 ? () => chunkN475ETD6_cjs.emitRunEvent(onRunEvent, { type: "compact_boundary", trigger: "auto" }) : void 0
|
|
2725
2726
|
);
|
|
2726
2727
|
if (result.status === "finished" && result.result !== void 0) {
|
|
2727
2728
|
const summaryArgs = {
|
|
@@ -2737,14 +2738,14 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2737
2738
|
if (memoryProvider?.recordSessionSummary !== void 0) {
|
|
2738
2739
|
await memoryProvider.recordSessionSummary(summaryArgs);
|
|
2739
2740
|
} else {
|
|
2740
|
-
await
|
|
2741
|
+
await chunkCN6UX5EV_cjs.writeSessionSummary(summaryArgs);
|
|
2741
2742
|
}
|
|
2742
2743
|
if (!shouldUsePortMemoryPath()) {
|
|
2743
2744
|
void memoryGlue.syncIfReady();
|
|
2744
2745
|
}
|
|
2745
2746
|
} catch (cause) {
|
|
2746
2747
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2747
|
-
|
|
2748
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] session summary write failed (${result.id}): ${message}
|
|
2748
2749
|
`);
|
|
2749
2750
|
}
|
|
2750
2751
|
}
|
|
@@ -2757,7 +2758,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2757
2758
|
agentId,
|
|
2758
2759
|
runId: result.id
|
|
2759
2760
|
});
|
|
2760
|
-
await
|
|
2761
|
+
await chunkDCXRHCZJ_cjs.flushSessionWrites();
|
|
2761
2762
|
}
|
|
2762
2763
|
async function safeConversation(run) {
|
|
2763
2764
|
try {
|
|
@@ -2832,7 +2833,7 @@ var warned = /* @__PURE__ */ new Set();
|
|
|
2832
2833
|
function warnDoubleReasoningOnce() {
|
|
2833
2834
|
if (warned.has("double-reasoning")) return;
|
|
2834
2835
|
warned.add("double-reasoning");
|
|
2835
|
-
|
|
2836
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
2836
2837
|
"[theokit-sdk] `reasoning: true` skipped \u2014 a native reasoning model is configured (model.params thinking/reasoning); native reasoning wins. Remove one to silence.\n"
|
|
2837
2838
|
);
|
|
2838
2839
|
}
|
|
@@ -2865,9 +2866,9 @@ var SkillsManager = class {
|
|
|
2865
2866
|
}
|
|
2866
2867
|
async refresh() {
|
|
2867
2868
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
2868
|
-
const discovered = await
|
|
2869
|
+
const discovered = await chunkE4IUN3JB_cjs.discoverSkills(skillsRoot, {
|
|
2869
2870
|
onInvalidSkill: (info) => {
|
|
2870
|
-
|
|
2871
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
2871
2872
|
`);
|
|
2872
2873
|
}
|
|
2873
2874
|
});
|
|
@@ -2891,7 +2892,7 @@ var SkillsManager = class {
|
|
|
2891
2892
|
async get(name) {
|
|
2892
2893
|
const skill = this.skills.find((s) => s.name === name);
|
|
2893
2894
|
if (skill === void 0) return void 0;
|
|
2894
|
-
const instructions = typeof skill.instructions === "string" ? skill.instructions :
|
|
2895
|
+
const instructions = typeof skill.instructions === "string" ? skill.instructions : chunkE4IUN3JB_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
|
|
2895
2896
|
const references = skill.references;
|
|
2896
2897
|
return {
|
|
2897
2898
|
name: skill.name,
|
|
@@ -2977,7 +2978,7 @@ async function safeCall(fn, fallback, label = "safeCall") {
|
|
|
2977
2978
|
return await fn();
|
|
2978
2979
|
} catch (cause) {
|
|
2979
2980
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2980
|
-
|
|
2981
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] ${label} failed: ${message}
|
|
2981
2982
|
`);
|
|
2982
2983
|
return fallback;
|
|
2983
2984
|
}
|
|
@@ -2991,7 +2992,7 @@ var ActiveMemoryPromptProvider = class {
|
|
|
2991
2992
|
if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
|
|
2992
2993
|
return Promise.resolve(void 0);
|
|
2993
2994
|
}
|
|
2994
|
-
const body =
|
|
2995
|
+
const body = chunkE4IUN3JB_cjs.escapeBlockBody(ctx.activeMemorySummary);
|
|
2995
2996
|
return Promise.resolve(`<active-memory>
|
|
2996
2997
|
${body}
|
|
2997
2998
|
</active-memory>`);
|
|
@@ -3044,7 +3045,7 @@ function formatSource(name, tokens) {
|
|
|
3044
3045
|
if (tokens.length === 0) {
|
|
3045
3046
|
return ` <source name="${escapeAttribute(name)}" />`;
|
|
3046
3047
|
}
|
|
3047
|
-
const body =
|
|
3048
|
+
const body = chunkE4IUN3JB_cjs.escapeBlockBody(tokens.join(" "));
|
|
3048
3049
|
return ` <source name="${escapeAttribute(name)}">
|
|
3049
3050
|
${body}
|
|
3050
3051
|
</source>`;
|
|
@@ -3060,7 +3061,7 @@ var MemoryPromptProvider = class {
|
|
|
3060
3061
|
contribute(ctx) {
|
|
3061
3062
|
if (ctx.memoryAutoInject === false) return Promise.resolve(void 0);
|
|
3062
3063
|
if (ctx.memory.length === 0) return Promise.resolve(void 0);
|
|
3063
|
-
const lines = ctx.memory.map((fact) => ` - ${
|
|
3064
|
+
const lines = ctx.memory.map((fact) => ` - ${chunkE4IUN3JB_cjs.escapeBlockBody(fact.text)}`);
|
|
3064
3065
|
return Promise.resolve(`<memory>
|
|
3065
3066
|
${lines.join("\n")}
|
|
3066
3067
|
</memory>`);
|
|
@@ -3082,7 +3083,7 @@ var SkillsPromptProvider = class {
|
|
|
3082
3083
|
priority = 20;
|
|
3083
3084
|
contribute(ctx) {
|
|
3084
3085
|
if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
|
|
3085
|
-
return Promise.resolve(
|
|
3086
|
+
return Promise.resolve(chunkE4IUN3JB_cjs.buildSkillsBlock(ctx.skills));
|
|
3086
3087
|
}
|
|
3087
3088
|
};
|
|
3088
3089
|
|
|
@@ -3094,7 +3095,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
|
|
|
3094
3095
|
for (const p of providers) {
|
|
3095
3096
|
const key = `${p.priority}:${p.id}`;
|
|
3096
3097
|
if (seen.has(key)) {
|
|
3097
|
-
throw new
|
|
3098
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Duplicate system-prompt provider ${key}`, {
|
|
3098
3099
|
code: "pipeline_duplicate_provider"
|
|
3099
3100
|
});
|
|
3100
3101
|
}
|
|
@@ -3141,7 +3142,7 @@ function validateAgentOptions(options) {
|
|
|
3141
3142
|
ensureRuntimeShape(options);
|
|
3142
3143
|
if (options.local !== void 0) {
|
|
3143
3144
|
if (options.model === void 0) {
|
|
3144
|
-
throw new
|
|
3145
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError("Local agents require a model selection", {
|
|
3145
3146
|
code: "missing_model"
|
|
3146
3147
|
});
|
|
3147
3148
|
}
|
|
@@ -3165,7 +3166,7 @@ function validateCredentialPoolShape(options) {
|
|
|
3165
3166
|
([, arr]) => Array.isArray(arr) && arr.some((k) => typeof k === "string" && k.length > 0)
|
|
3166
3167
|
);
|
|
3167
3168
|
if (populated.length === 0) return;
|
|
3168
|
-
throw new
|
|
3169
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3169
3170
|
"Ambiguous credential configuration: use either `apiKey: '...'` (single-key, simplest) OR `apiKeys: { provider: [...] }` (multi-key pool), not both.",
|
|
3170
3171
|
{ code: "credential_pool_ambiguous" }
|
|
3171
3172
|
);
|
|
@@ -3174,7 +3175,7 @@ function validatePlugins(options) {
|
|
|
3174
3175
|
const plugins = options.plugins;
|
|
3175
3176
|
if (plugins?.paths === void 0) return;
|
|
3176
3177
|
if (options.cloud !== void 0 && plugins.paths.length > 0) {
|
|
3177
|
-
throw new
|
|
3178
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3178
3179
|
"Cloud agents require committed plugin manifests; local plugin paths are not supported",
|
|
3179
3180
|
{ code: "cloud_plugin_path_rejected" }
|
|
3180
3181
|
);
|
|
@@ -3182,7 +3183,7 @@ function validatePlugins(options) {
|
|
|
3182
3183
|
}
|
|
3183
3184
|
function ensureRuntimeShape(options) {
|
|
3184
3185
|
if (options.local !== void 0 && options.cloud !== void 0) {
|
|
3185
|
-
throw new
|
|
3186
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3186
3187
|
"Pass either local or cloud \u2014 they are mutually exclusive runtimes",
|
|
3187
3188
|
{ code: "runtime_exclusive" }
|
|
3188
3189
|
);
|
|
@@ -3190,7 +3191,7 @@ function ensureRuntimeShape(options) {
|
|
|
3190
3191
|
}
|
|
3191
3192
|
function rejectProgrammaticHooks(options) {
|
|
3192
3193
|
if (options.hooks !== void 0) {
|
|
3193
|
-
throw new
|
|
3194
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3194
3195
|
"Programmatic hooks are not supported \u2014 hooks are file-based only (.theokit/hooks.json)",
|
|
3195
3196
|
{ code: "programmatic_hooks_rejected" }
|
|
3196
3197
|
);
|
|
@@ -3200,7 +3201,7 @@ function validateCloud(cloud) {
|
|
|
3200
3201
|
if (cloud.envVars !== void 0) {
|
|
3201
3202
|
for (const key of Object.keys(cloud.envVars)) {
|
|
3202
3203
|
if (key.startsWith("THEOKIT_")) {
|
|
3203
|
-
throw new
|
|
3204
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3204
3205
|
`Cloud envVars cannot use the reserved THEOKIT_ prefix (got "${key}")`,
|
|
3205
3206
|
{ code: "reserved_env_prefix" }
|
|
3206
3207
|
);
|
|
@@ -3212,7 +3213,7 @@ function validateMcpServers(options) {
|
|
|
3212
3213
|
if (options.mcpServers === void 0) return;
|
|
3213
3214
|
for (const [name, config] of Object.entries(options.mcpServers)) {
|
|
3214
3215
|
if (options.cloud !== void 0 && isStdioWithCwd(config)) {
|
|
3215
|
-
throw new
|
|
3216
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3216
3217
|
`MCP server "${name}" uses stdio with cwd, which is rejected for cloud agents`,
|
|
3217
3218
|
{ code: "cloud_stdio_cwd_rejected" }
|
|
3218
3219
|
);
|
|
@@ -3231,12 +3232,12 @@ function validateSubagents(agents2) {
|
|
|
3231
3232
|
if (agents2 === void 0) return;
|
|
3232
3233
|
for (const [name, definition] of Object.entries(agents2)) {
|
|
3233
3234
|
if (typeof definition.description !== "string" || definition.description.length === 0) {
|
|
3234
|
-
throw new
|
|
3235
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty description`, {
|
|
3235
3236
|
code: "subagent_missing_description"
|
|
3236
3237
|
});
|
|
3237
3238
|
}
|
|
3238
3239
|
if (typeof definition.prompt !== "string" || definition.prompt.length === 0) {
|
|
3239
|
-
throw new
|
|
3240
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty prompt`, {
|
|
3240
3241
|
code: "subagent_missing_prompt"
|
|
3241
3242
|
});
|
|
3242
3243
|
}
|
|
@@ -3249,7 +3250,7 @@ function validateToolCatalog(tools) {
|
|
|
3249
3250
|
for (const tool of tools) {
|
|
3250
3251
|
validateSingleTool(tool);
|
|
3251
3252
|
if (seen.has(tool.name)) {
|
|
3252
|
-
throw new
|
|
3253
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Duplicate custom tool name "${tool.name}"`, {
|
|
3253
3254
|
code: "duplicate_tool_name"
|
|
3254
3255
|
});
|
|
3255
3256
|
}
|
|
@@ -3260,7 +3261,7 @@ function validateCustomTools(options) {
|
|
|
3260
3261
|
const tools = options.tools;
|
|
3261
3262
|
if (tools === void 0 || tools.length === 0) return;
|
|
3262
3263
|
if (options.cloud !== void 0) {
|
|
3263
|
-
throw new
|
|
3264
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3264
3265
|
"Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
|
|
3265
3266
|
{ code: "cloud_custom_tools_rejected" }
|
|
3266
3267
|
);
|
|
@@ -3272,25 +3273,25 @@ function validateSingleTool(tool) {
|
|
|
3272
3273
|
validateToolDescription(tool);
|
|
3273
3274
|
validateToolSchema(tool);
|
|
3274
3275
|
if (typeof tool.handler !== "function") {
|
|
3275
|
-
throw new
|
|
3276
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a handler function`, {
|
|
3276
3277
|
code: "tool_missing_handler"
|
|
3277
3278
|
});
|
|
3278
3279
|
}
|
|
3279
3280
|
}
|
|
3280
3281
|
function validateToolName(tool) {
|
|
3281
3282
|
if (typeof tool.name !== "string" || tool.name.length === 0) {
|
|
3282
|
-
throw new
|
|
3283
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError("Custom tool requires a non-empty name", {
|
|
3283
3284
|
code: "tool_missing_name"
|
|
3284
3285
|
});
|
|
3285
3286
|
}
|
|
3286
3287
|
if (!TOOL_NAME_PATTERN.test(tool.name)) {
|
|
3287
|
-
throw new
|
|
3288
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3288
3289
|
`Custom tool name "${tool.name}" must match /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/`,
|
|
3289
3290
|
{ code: "tool_invalid_name" }
|
|
3290
3291
|
);
|
|
3291
3292
|
}
|
|
3292
3293
|
if (RESERVED_TOOL_NAMES.has(tool.name) || tool.name.startsWith("mcp_")) {
|
|
3293
|
-
throw new
|
|
3294
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3294
3295
|
`Custom tool name "${tool.name}" collides with a reserved SDK tool name`,
|
|
3295
3296
|
{ code: "tool_reserved_name" }
|
|
3296
3297
|
);
|
|
@@ -3298,7 +3299,7 @@ function validateToolName(tool) {
|
|
|
3298
3299
|
}
|
|
3299
3300
|
function validateToolDescription(tool) {
|
|
3300
3301
|
if (typeof tool.description !== "string" || tool.description.length === 0) {
|
|
3301
|
-
throw new
|
|
3302
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a non-empty description`, {
|
|
3302
3303
|
code: "tool_missing_description"
|
|
3303
3304
|
});
|
|
3304
3305
|
}
|
|
@@ -3306,12 +3307,12 @@ function validateToolDescription(tool) {
|
|
|
3306
3307
|
function validateToolSchema(tool) {
|
|
3307
3308
|
const schema = tool.inputSchema;
|
|
3308
3309
|
if (schema === null || schema === void 0 || typeof schema !== "object") {
|
|
3309
|
-
throw new
|
|
3310
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Custom tool "${tool.name}" requires an inputSchema object`, {
|
|
3310
3311
|
code: "tool_missing_schema"
|
|
3311
3312
|
});
|
|
3312
3313
|
}
|
|
3313
3314
|
if (schema.type !== "object") {
|
|
3314
|
-
throw new
|
|
3315
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3315
3316
|
`Custom tool "${tool.name}" inputSchema must declare \`type: "object"\``,
|
|
3316
3317
|
{ code: "tool_invalid_schema_type" }
|
|
3317
3318
|
);
|
|
@@ -3322,7 +3323,7 @@ function validateMemory(options) {
|
|
|
3322
3323
|
if (memory?.storePath === void 0) return;
|
|
3323
3324
|
const storePath = memory.storePath;
|
|
3324
3325
|
if (storePath.includes("..") || storePath.startsWith("/") || /^[A-Z]:/i.test(storePath)) {
|
|
3325
|
-
throw new
|
|
3326
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3326
3327
|
`Memory storePath must stay inside the workspace; got "${storePath}"`,
|
|
3327
3328
|
{ code: "memory_path_traversal" }
|
|
3328
3329
|
);
|
|
@@ -3344,7 +3345,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3344
3345
|
};
|
|
3345
3346
|
function safeRequire(moduleName) {
|
|
3346
3347
|
try {
|
|
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-
|
|
3348
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-INSFS5GT.cjs', document.baseURI).href)));
|
|
3348
3349
|
return r(moduleName);
|
|
3349
3350
|
} catch {
|
|
3350
3351
|
return void 0;
|
|
@@ -3423,7 +3424,7 @@ var langfuseAdapter = {
|
|
|
3423
3424
|
}
|
|
3424
3425
|
}
|
|
3425
3426
|
if (lf.LangfuseSpanProcessor === void 0) {
|
|
3426
|
-
|
|
3427
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
3427
3428
|
"[theokit-sdk] @langfuse/node detected but LangfuseSpanProcessor not found (v2?). Use Langfuse v3+ for auto-instrumentation.\n"
|
|
3428
3429
|
);
|
|
3429
3430
|
return;
|
|
@@ -3552,11 +3553,11 @@ function tryAutoRegisterAdapters(settings) {
|
|
|
3552
3553
|
try {
|
|
3553
3554
|
adapter.register();
|
|
3554
3555
|
registered.add(adapter.moduleName);
|
|
3555
|
-
|
|
3556
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] telemetry: ${adapter.displayName} auto-instrumented.
|
|
3556
3557
|
`);
|
|
3557
3558
|
} catch (cause) {
|
|
3558
3559
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3559
|
-
|
|
3560
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
3560
3561
|
`[theokit-sdk] telemetry: ${adapter.displayName} detected but failed to register: ${message}
|
|
3561
3562
|
`
|
|
3562
3563
|
);
|
|
@@ -3569,7 +3570,7 @@ var cachedOtel;
|
|
|
3569
3570
|
function loadOtel() {
|
|
3570
3571
|
if (cachedOtel === void 0) {
|
|
3571
3572
|
try {
|
|
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-
|
|
3573
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-INSFS5GT.cjs', document.baseURI).href)));
|
|
3573
3574
|
const mod = r("@opentelemetry/api");
|
|
3574
3575
|
cachedOtel = mod;
|
|
3575
3576
|
} catch {
|
|
@@ -3612,7 +3613,7 @@ function safe(op, fallback) {
|
|
|
3612
3613
|
if (!warnedOnce) {
|
|
3613
3614
|
warnedOnce = true;
|
|
3614
3615
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3615
|
-
|
|
3616
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
3616
3617
|
`[theokit-sdk] telemetry exporter error (suppressed; agent.send continues): ${message}
|
|
3617
3618
|
`
|
|
3618
3619
|
);
|
|
@@ -3626,7 +3627,7 @@ function createTelemetry(settings) {
|
|
|
3626
3627
|
if (otel === null) {
|
|
3627
3628
|
if (!warnedOnce) {
|
|
3628
3629
|
warnedOnce = true;
|
|
3629
|
-
|
|
3630
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
3630
3631
|
"[theokit-sdk] telemetry.enabled = true but `@opentelemetry/api` is not installed; telemetry is a no-op.\n"
|
|
3631
3632
|
);
|
|
3632
3633
|
}
|
|
@@ -3720,12 +3721,12 @@ function wrapSpan(span, openSpans) {
|
|
|
3720
3721
|
}
|
|
3721
3722
|
function redactAttrValue(value) {
|
|
3722
3723
|
if (typeof value !== "string") return value;
|
|
3723
|
-
return
|
|
3724
|
+
return chunkBCQ3E2ZG_cjs.redactSecrets(value);
|
|
3724
3725
|
}
|
|
3725
3726
|
function redactAttrs(attrs) {
|
|
3726
3727
|
const out = {};
|
|
3727
3728
|
for (const [k, v] of Object.entries(attrs)) {
|
|
3728
|
-
out[k] = typeof v === "string" ?
|
|
3729
|
+
out[k] = typeof v === "string" ? chunkBCQ3E2ZG_cjs.redactSecrets(v) : v;
|
|
3729
3730
|
}
|
|
3730
3731
|
return out;
|
|
3731
3732
|
}
|
|
@@ -3807,10 +3808,10 @@ async function loadMarkdownEntities(opts) {
|
|
|
3807
3808
|
const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
|
|
3808
3809
|
if (raw === null) continue;
|
|
3809
3810
|
const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
|
|
3810
|
-
const fields =
|
|
3811
|
+
const fields = chunkG2Q3ZC6C_cjs.parseSimpleYaml(split.frontmatter);
|
|
3811
3812
|
const parsed = schema.safeParse(fields);
|
|
3812
3813
|
if (!parsed.success) {
|
|
3813
|
-
throw new
|
|
3814
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3814
3815
|
`Invalid frontmatter in ${resolved.source}: ${parsed.error.message}`,
|
|
3815
3816
|
{ code: `${errorCodePrefix}_frontmatter_invalid` }
|
|
3816
3817
|
);
|
|
@@ -3828,13 +3829,13 @@ async function assertFileSizeUnderCap(source, errorCodePrefix) {
|
|
|
3828
3829
|
try {
|
|
3829
3830
|
const info = await promises.stat(source);
|
|
3830
3831
|
if (info.size > MAX_MD_FILE_BYTES) {
|
|
3831
|
-
throw new
|
|
3832
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3832
3833
|
`Config file ${source} exceeds 1 MB size limit (${info.size} bytes). Reduce the file or split into multiple entities.`,
|
|
3833
3834
|
{ code: `${errorCodePrefix}_file_too_large` }
|
|
3834
3835
|
);
|
|
3835
3836
|
}
|
|
3836
3837
|
} catch (cause) {
|
|
3837
|
-
if (cause instanceof
|
|
3838
|
+
if (cause instanceof chunkIHFNRNTJ_cjs.ConfigurationError) throw cause;
|
|
3838
3839
|
}
|
|
3839
3840
|
}
|
|
3840
3841
|
async function readDirSafe(dir, errorCodePrefix) {
|
|
@@ -3843,7 +3844,7 @@ async function readDirSafe(dir, errorCodePrefix) {
|
|
|
3843
3844
|
} catch (cause) {
|
|
3844
3845
|
const code = cause.code;
|
|
3845
3846
|
if (code === "ENOENT") return null;
|
|
3846
|
-
throw new
|
|
3847
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Failed to read ${dir}`, {
|
|
3847
3848
|
code: `${errorCodePrefix}_dir_read_error`,
|
|
3848
3849
|
cause
|
|
3849
3850
|
});
|
|
@@ -3860,7 +3861,7 @@ function resolveEntryPath(entry, pattern, dir) {
|
|
|
3860
3861
|
function splitFrontmatter(raw, source, errorCodePrefix) {
|
|
3861
3862
|
const match = /^---\s*\n([\s\S]*?)\n---\s*(?:\n|$)/.exec(raw);
|
|
3862
3863
|
if (match === null) {
|
|
3863
|
-
throw new
|
|
3864
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
3864
3865
|
`Missing or malformed frontmatter in ${source} (expected \`---\` delimited block at file head)`,
|
|
3865
3866
|
{ code: `${errorCodePrefix}_missing_frontmatter` }
|
|
3866
3867
|
);
|
|
@@ -4344,7 +4345,7 @@ async function loadContextConfig(cwd) {
|
|
|
4344
4345
|
});
|
|
4345
4346
|
if (mdEntities.length > 0) {
|
|
4346
4347
|
if (fs.existsSync(jsonPath)) {
|
|
4347
|
-
|
|
4348
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
4348
4349
|
"context-both-present",
|
|
4349
4350
|
"[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
|
|
4350
4351
|
);
|
|
@@ -4354,7 +4355,7 @@ async function loadContextConfig(cwd) {
|
|
|
4354
4355
|
};
|
|
4355
4356
|
}
|
|
4356
4357
|
if (!fs.existsSync(jsonPath)) return { sources: [] };
|
|
4357
|
-
|
|
4358
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
4358
4359
|
"context-json-deprecated",
|
|
4359
4360
|
"[theokit-sdk] .theokit/context.json is deprecated; migrate to .theokit/context/<name>.md via theokit-migrate-config"
|
|
4360
4361
|
);
|
|
@@ -4362,7 +4363,7 @@ async function loadContextConfig(cwd) {
|
|
|
4362
4363
|
try {
|
|
4363
4364
|
raw = await promises.readFile(jsonPath, "utf8");
|
|
4364
4365
|
} catch (cause) {
|
|
4365
|
-
throw new
|
|
4366
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Failed to read context config: ${jsonPath}`, {
|
|
4366
4367
|
code: "context_read_error",
|
|
4367
4368
|
cause
|
|
4368
4369
|
});
|
|
@@ -4374,13 +4375,13 @@ function parseConfig(raw, configPath) {
|
|
|
4374
4375
|
try {
|
|
4375
4376
|
parsed = JSON.parse(raw);
|
|
4376
4377
|
} catch (cause) {
|
|
4377
|
-
throw new
|
|
4378
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Invalid JSON in context config: ${configPath}`, {
|
|
4378
4379
|
code: "context_json_invalid",
|
|
4379
4380
|
cause
|
|
4380
4381
|
});
|
|
4381
4382
|
}
|
|
4382
4383
|
if (!parsed || typeof parsed !== "object") {
|
|
4383
|
-
throw new
|
|
4384
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Context config must be an object: ${configPath}`, {
|
|
4384
4385
|
code: "context_config_shape"
|
|
4385
4386
|
});
|
|
4386
4387
|
}
|
|
@@ -4395,7 +4396,7 @@ function parseConfig(raw, configPath) {
|
|
|
4395
4396
|
}
|
|
4396
4397
|
function readSources(sourcesRaw, configPath) {
|
|
4397
4398
|
if (!Array.isArray(sourcesRaw)) {
|
|
4398
|
-
throw new
|
|
4399
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Context config sources must be an array: ${configPath}`, {
|
|
4399
4400
|
code: "context_sources_shape"
|
|
4400
4401
|
});
|
|
4401
4402
|
}
|
|
@@ -4493,7 +4494,7 @@ var PluginsManager = class {
|
|
|
4493
4494
|
async refresh() {
|
|
4494
4495
|
this.plugins = [];
|
|
4495
4496
|
const pluginsRoot = path.join(this.cwd, ".theokit", "plugins");
|
|
4496
|
-
const entries = await
|
|
4497
|
+
const entries = await chunkG2Q3ZC6C_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
|
|
4497
4498
|
for (const entry of entries) {
|
|
4498
4499
|
if (!entry.isDirectory()) continue;
|
|
4499
4500
|
const folderName = entry.name;
|
|
@@ -4501,13 +4502,13 @@ var PluginsManager = class {
|
|
|
4501
4502
|
const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
|
|
4502
4503
|
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
|
|
4503
4504
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4504
|
-
|
|
4505
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
4505
4506
|
`plugin-${folderName}-both`,
|
|
4506
4507
|
`[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
|
|
4507
4508
|
);
|
|
4508
4509
|
}
|
|
4509
4510
|
if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
4510
|
-
|
|
4511
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
4511
4512
|
"plugin-json-deprecated",
|
|
4512
4513
|
"[theokit-sdk] plugin.json manifests are deprecated; migrate to PLUGIN.md via theokit-migrate-config"
|
|
4513
4514
|
);
|
|
@@ -4525,11 +4526,11 @@ var PluginsManager = class {
|
|
|
4525
4526
|
const entry = metadata.entry;
|
|
4526
4527
|
if (entry === void 0) return;
|
|
4527
4528
|
const pluginRoot = path.join(this.cwd, ".theokit", "plugins", folderName);
|
|
4528
|
-
const entryPath =
|
|
4529
|
+
const entryPath = chunk7YBJZS5P_cjs.safePathJoin(pluginRoot, entry);
|
|
4529
4530
|
try {
|
|
4530
4531
|
await promises.readFile(entryPath, "utf8");
|
|
4531
4532
|
} catch (cause) {
|
|
4532
|
-
throw new
|
|
4533
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Plugin ${metadata.name} entry file is missing: ${entry}`, {
|
|
4533
4534
|
code: "plugin_entry_missing",
|
|
4534
4535
|
cause
|
|
4535
4536
|
});
|
|
@@ -4538,7 +4539,7 @@ var PluginsManager = class {
|
|
|
4538
4539
|
assertCloudRules() {
|
|
4539
4540
|
if (!this.cloud) return;
|
|
4540
4541
|
if (this.localPaths !== void 0 && this.localPaths.length > 0) {
|
|
4541
|
-
throw new
|
|
4542
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
4542
4543
|
"Cloud agents reject local plugin paths \u2014 plugins must come from committed repo files",
|
|
4543
4544
|
{ code: "cloud_plugin_path_rejected" }
|
|
4544
4545
|
);
|
|
@@ -4550,7 +4551,7 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4550
4551
|
try {
|
|
4551
4552
|
raw = await promises.readFile(manifestPath, "utf8");
|
|
4552
4553
|
} catch (cause) {
|
|
4553
|
-
throw new
|
|
4554
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Plugin ${folderName} is missing plugin.json`, {
|
|
4554
4555
|
code: "plugin_missing_manifest",
|
|
4555
4556
|
cause
|
|
4556
4557
|
});
|
|
@@ -4559,13 +4560,13 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
4559
4560
|
try {
|
|
4560
4561
|
parsed = JSON.parse(raw);
|
|
4561
4562
|
} catch (cause) {
|
|
4562
|
-
throw new
|
|
4563
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Plugin ${folderName} manifest is invalid JSON`, {
|
|
4563
4564
|
code: "plugin_manifest_invalid",
|
|
4564
4565
|
cause
|
|
4565
4566
|
});
|
|
4566
4567
|
}
|
|
4567
4568
|
if (!parsed || typeof parsed !== "object") {
|
|
4568
|
-
throw new
|
|
4569
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Plugin ${folderName} manifest must be an object`, {
|
|
4569
4570
|
code: "plugin_manifest_shape"
|
|
4570
4571
|
});
|
|
4571
4572
|
}
|
|
@@ -4584,7 +4585,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4584
4585
|
try {
|
|
4585
4586
|
raw = await promises.readFile(mdPath, "utf8");
|
|
4586
4587
|
} catch (cause) {
|
|
4587
|
-
throw new
|
|
4588
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Plugin ${folderName} is missing PLUGIN.md`, {
|
|
4588
4589
|
code: "plugin_missing_manifest",
|
|
4589
4590
|
cause
|
|
4590
4591
|
});
|
|
@@ -4599,7 +4600,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
4599
4600
|
});
|
|
4600
4601
|
const entity = entities.find((e) => e.slug === "PLUGIN");
|
|
4601
4602
|
if (entity === void 0) {
|
|
4602
|
-
throw new
|
|
4603
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`Plugin ${folderName} PLUGIN.md not parseable`, {
|
|
4603
4604
|
code: "plugin_missing_manifest"
|
|
4604
4605
|
});
|
|
4605
4606
|
}
|
|
@@ -4873,7 +4874,7 @@ function assertValidThresholds(soft, hard) {
|
|
|
4873
4874
|
["hardThreshold", hard]
|
|
4874
4875
|
]) {
|
|
4875
4876
|
if (!Number.isInteger(value) || value < 1) {
|
|
4876
|
-
throw new
|
|
4877
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
4877
4878
|
`doomLoop.${label} must be a positive integer (received ${value}).`,
|
|
4878
4879
|
{ code: "invalid_doom_loop_threshold" }
|
|
4879
4880
|
);
|
|
@@ -4992,6 +4993,35 @@ var UsageAccumulator = class {
|
|
|
4992
4993
|
}
|
|
4993
4994
|
};
|
|
4994
4995
|
|
|
4996
|
+
// src/internal/agent-loop/live-events.ts
|
|
4997
|
+
var LiveEventLog = class extends Array {
|
|
4998
|
+
/**
|
|
4999
|
+
* Not readonly, and not a constructor parameter — `Array` subclasses are re-instantiated by
|
|
5000
|
+
* `map`/`filter`/`slice` with a length argument, so a constructor with a different signature
|
|
5001
|
+
* breaks those. The sink is attached after construction instead.
|
|
5002
|
+
*/
|
|
5003
|
+
#sink;
|
|
5004
|
+
/** Attach the live subscriber. One sink: the run that owns this loop. */
|
|
5005
|
+
subscribe(sink) {
|
|
5006
|
+
this.#sink = sink;
|
|
5007
|
+
}
|
|
5008
|
+
push(...events) {
|
|
5009
|
+
const length = super.push(...events);
|
|
5010
|
+
for (const event of events) {
|
|
5011
|
+
try {
|
|
5012
|
+
this.#sink?.(event);
|
|
5013
|
+
} catch {
|
|
5014
|
+
}
|
|
5015
|
+
}
|
|
5016
|
+
return length;
|
|
5017
|
+
}
|
|
5018
|
+
};
|
|
5019
|
+
function createEventLog(seed) {
|
|
5020
|
+
const log = new LiveEventLog();
|
|
5021
|
+
log.push(...seed);
|
|
5022
|
+
return log;
|
|
5023
|
+
}
|
|
5024
|
+
|
|
4995
5025
|
// src/internal/agent-loop/message-builders.ts
|
|
4996
5026
|
function buildSystemEvent(inputs, toolNames) {
|
|
4997
5027
|
return {
|
|
@@ -5019,7 +5049,7 @@ function buildAssistantEvent(inputs, text) {
|
|
|
5019
5049
|
message: { role: "assistant", content: [{ type: "text", text }] }
|
|
5020
5050
|
};
|
|
5021
5051
|
}
|
|
5022
|
-
function buildThinkingEvent(inputs, text, thinkingDurationMs) {
|
|
5052
|
+
function buildThinkingEvent(inputs, text, thinkingDurationMs, signature) {
|
|
5023
5053
|
const event = {
|
|
5024
5054
|
type: "thinking",
|
|
5025
5055
|
agent_id: inputs.agentId,
|
|
@@ -5029,44 +5059,17 @@ function buildThinkingEvent(inputs, text, thinkingDurationMs) {
|
|
|
5029
5059
|
if (thinkingDurationMs !== void 0 && thinkingDurationMs >= 0) {
|
|
5030
5060
|
event.thinking_duration_ms = thinkingDurationMs;
|
|
5031
5061
|
}
|
|
5062
|
+
if (signature !== void 0) event.signature = signature;
|
|
5032
5063
|
return event;
|
|
5033
5064
|
}
|
|
5034
|
-
function buildAssistantTurn(text, toolCalls) {
|
|
5065
|
+
function buildAssistantTurn(text, toolCalls, thinking) {
|
|
5035
5066
|
const content = [];
|
|
5067
|
+
if (thinking !== void 0) content.push(thinking);
|
|
5036
5068
|
if (text.length > 0) content.push({ type: "text", text });
|
|
5037
5069
|
for (const call of toolCalls) content.push(call);
|
|
5038
5070
|
return { role: "assistant", content };
|
|
5039
5071
|
}
|
|
5040
5072
|
|
|
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
|
-
|
|
5070
5073
|
// src/internal/agent-loop/loop-context-init.ts
|
|
5071
5074
|
function buildUserContent(text, images) {
|
|
5072
5075
|
const content = [{ type: "text", text }];
|
|
@@ -5184,7 +5187,7 @@ async function safeListTools(client, serverName) {
|
|
|
5184
5187
|
} catch (cause) {
|
|
5185
5188
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
5186
5189
|
const server = serverName ?? "unknown";
|
|
5187
|
-
|
|
5190
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] mcp listTools failed (server=${server}): ${message}
|
|
5188
5191
|
`);
|
|
5189
5192
|
return [];
|
|
5190
5193
|
}
|
|
@@ -5253,7 +5256,7 @@ function emitLlmMetrics(inputs, result, startAt) {
|
|
|
5253
5256
|
inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.LLM_USAGE_MISSING, 1, {
|
|
5254
5257
|
provider: inputs.llm.name
|
|
5255
5258
|
});
|
|
5256
|
-
|
|
5259
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
5257
5260
|
`[theokit-sdk] llm usage missing from ${inputs.llm.name} finish \u2014 budget may undercount
|
|
5258
5261
|
`
|
|
5259
5262
|
);
|
|
@@ -5316,6 +5319,7 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
5316
5319
|
emitLlmMetrics(inputs, result, startAt);
|
|
5317
5320
|
llmSpan?.end();
|
|
5318
5321
|
const stripped = stripThinkBlocks(collected.accumulatedText);
|
|
5322
|
+
const thinking = result.thinking ?? collected.thinking;
|
|
5319
5323
|
return {
|
|
5320
5324
|
text: stripped.visible,
|
|
5321
5325
|
toolCalls: result.toolCalls,
|
|
@@ -5325,18 +5329,21 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
5325
5329
|
outputTokens: result.outputTokens,
|
|
5326
5330
|
cacheReadTokens: result.cacheReadTokens,
|
|
5327
5331
|
cacheWriteTokens: result.cacheWriteTokens,
|
|
5328
|
-
reasoningTokens: result.reasoningTokens
|
|
5332
|
+
reasoningTokens: result.reasoningTokens,
|
|
5333
|
+
...thinking !== void 0 ? { thinking } : {}
|
|
5329
5334
|
};
|
|
5330
5335
|
}
|
|
5331
5336
|
async function collectLlmEvents(generator, inputs, ctx) {
|
|
5332
5337
|
let accumulatedText = "";
|
|
5333
5338
|
let errored = false;
|
|
5334
5339
|
let finishValue;
|
|
5340
|
+
let thinking;
|
|
5335
5341
|
try {
|
|
5336
5342
|
const result = await runCollectorLoop(generator, inputs, ctx);
|
|
5337
5343
|
accumulatedText = result.accumulatedText;
|
|
5338
5344
|
errored = result.errored;
|
|
5339
5345
|
finishValue = result.finishValue;
|
|
5346
|
+
thinking = result.thinking;
|
|
5340
5347
|
} catch (cause) {
|
|
5341
5348
|
if (inputs.signal?.aborted === true) {
|
|
5342
5349
|
ctx.finalText = "[aborted]";
|
|
@@ -5347,7 +5354,12 @@ async function collectLlmEvents(generator, inputs, ctx) {
|
|
|
5347
5354
|
}
|
|
5348
5355
|
errored = true;
|
|
5349
5356
|
}
|
|
5350
|
-
return {
|
|
5357
|
+
return {
|
|
5358
|
+
accumulatedText,
|
|
5359
|
+
errored,
|
|
5360
|
+
finishValue,
|
|
5361
|
+
...thinking !== void 0 ? { thinking } : {}
|
|
5362
|
+
};
|
|
5351
5363
|
}
|
|
5352
5364
|
function registerLoopError(ctx, cause) {
|
|
5353
5365
|
if (ctx.error !== void 0) return;
|
|
@@ -5358,11 +5370,26 @@ function registerLoopError(ctx, cause) {
|
|
|
5358
5370
|
const code = typeof metaCode === "string" ? metaCode : typeof rawCode === "string" ? rawCode : void 0;
|
|
5359
5371
|
ctx.error = code !== void 0 ? { message, code, cause } : { message, cause };
|
|
5360
5372
|
}
|
|
5373
|
+
async function consumeStreamEvent(inputs, reasoning, event) {
|
|
5374
|
+
if (event.type === "text_delta") {
|
|
5375
|
+
const text = event.text ?? "";
|
|
5376
|
+
await emitTextDeltaCallback(inputs, text);
|
|
5377
|
+
return text;
|
|
5378
|
+
}
|
|
5379
|
+
if (event.type === "reasoning_delta") {
|
|
5380
|
+
await consumeReasoningDelta(inputs, reasoning, {
|
|
5381
|
+
text: event.text ?? "",
|
|
5382
|
+
...event.signature !== void 0 ? { signature: event.signature } : {}
|
|
5383
|
+
});
|
|
5384
|
+
}
|
|
5385
|
+
return "";
|
|
5386
|
+
}
|
|
5361
5387
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
5362
5388
|
let accumulatedText = "";
|
|
5363
|
-
const reasoning = { text: "", startedAt: void 0 };
|
|
5389
|
+
const reasoning = { text: "", startedAt: void 0, signature: void 0 };
|
|
5364
5390
|
let errored = false;
|
|
5365
5391
|
let finishValue;
|
|
5392
|
+
let thinking;
|
|
5366
5393
|
try {
|
|
5367
5394
|
while (true) {
|
|
5368
5395
|
const next = await generator.next();
|
|
@@ -5370,24 +5397,22 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
5370
5397
|
finishValue = next;
|
|
5371
5398
|
break;
|
|
5372
5399
|
}
|
|
5373
|
-
if (next.value.type === "text_delta") {
|
|
5374
|
-
accumulatedText += next.value.text;
|
|
5375
|
-
await emitTextDeltaCallback(inputs, next.value.text);
|
|
5376
|
-
}
|
|
5377
|
-
if (next.value.type === "reasoning_delta") {
|
|
5378
|
-
await accumulateReasoning(inputs, reasoning, next.value.text);
|
|
5379
|
-
}
|
|
5380
5400
|
if (next.value.type === "error") {
|
|
5381
5401
|
registerLoopError(ctx, next.value);
|
|
5382
5402
|
ctx.finalText = "";
|
|
5383
5403
|
errored = true;
|
|
5384
5404
|
break;
|
|
5385
5405
|
}
|
|
5406
|
+
accumulatedText += await consumeStreamEvent(inputs, reasoning, next.value);
|
|
5386
5407
|
}
|
|
5387
5408
|
} finally {
|
|
5388
|
-
await finalizeReasoning(inputs, ctx, reasoning);
|
|
5409
|
+
thinking = await finalizeReasoning(inputs, ctx, reasoning);
|
|
5389
5410
|
}
|
|
5390
|
-
return { accumulatedText, errored, finishValue };
|
|
5411
|
+
return { accumulatedText, errored, finishValue, ...thinking !== void 0 ? { thinking } : {} };
|
|
5412
|
+
}
|
|
5413
|
+
async function consumeReasoningDelta(inputs, reasoning, delta) {
|
|
5414
|
+
if (delta.signature !== void 0) reasoning.signature = delta.signature;
|
|
5415
|
+
await accumulateReasoning(inputs, reasoning, delta.text);
|
|
5391
5416
|
}
|
|
5392
5417
|
async function accumulateReasoning(inputs, reasoning, text) {
|
|
5393
5418
|
if (reasoning.startedAt === void 0) reasoning.startedAt = Date.now();
|
|
@@ -5395,10 +5420,17 @@ async function accumulateReasoning(inputs, reasoning, text) {
|
|
|
5395
5420
|
await emitReasoningDeltaCallback(inputs, text);
|
|
5396
5421
|
}
|
|
5397
5422
|
async function finalizeReasoning(inputs, ctx, reasoning) {
|
|
5398
|
-
if (reasoning.text.length === 0) return;
|
|
5423
|
+
if (reasoning.text.length === 0) return void 0;
|
|
5399
5424
|
const thinkingDurationMs = reasoning.startedAt === void 0 ? 0 : Date.now() - reasoning.startedAt;
|
|
5400
|
-
ctx.events.push(
|
|
5425
|
+
ctx.events.push(
|
|
5426
|
+
buildThinkingEvent(inputs, reasoning.text, thinkingDurationMs, reasoning.signature)
|
|
5427
|
+
);
|
|
5401
5428
|
await emitThinkingCompletedCallback(inputs, thinkingDurationMs);
|
|
5429
|
+
return {
|
|
5430
|
+
type: "thinking",
|
|
5431
|
+
text: reasoning.text,
|
|
5432
|
+
...reasoning.signature !== void 0 ? { signature: reasoning.signature } : {}
|
|
5433
|
+
};
|
|
5402
5434
|
}
|
|
5403
5435
|
async function emitTextDeltaCallback(inputs, text) {
|
|
5404
5436
|
if (inputs.onDelta === void 0) return;
|
|
@@ -5428,6 +5460,24 @@ async function emitThinkingCompletedCallback(inputs, thinkingDurationMs) {
|
|
|
5428
5460
|
);
|
|
5429
5461
|
}
|
|
5430
5462
|
|
|
5463
|
+
// src/internal/agent-loop/loop-thinking-steps.ts
|
|
5464
|
+
function thinkingStep(thinking) {
|
|
5465
|
+
return {
|
|
5466
|
+
type: "thinkingMessage",
|
|
5467
|
+
message: {
|
|
5468
|
+
text: thinking.text,
|
|
5469
|
+
...thinking.signature !== void 0 ? { signature: thinking.signature } : {}
|
|
5470
|
+
}
|
|
5471
|
+
};
|
|
5472
|
+
}
|
|
5473
|
+
function recordThinkingOnSilentToolRound(ctx, text, thinking) {
|
|
5474
|
+
if (text.length > 0 || thinking === void 0) return;
|
|
5475
|
+
ctx.conversation.push({
|
|
5476
|
+
type: "agentConversationTurn",
|
|
5477
|
+
turn: { steps: [thinkingStep(thinking)] }
|
|
5478
|
+
});
|
|
5479
|
+
}
|
|
5480
|
+
|
|
5431
5481
|
// src/internal/tool-dispatch/repair-middleware.ts
|
|
5432
5482
|
var DECIMAL_RE = /^-?\d+(\.\d+)?$/;
|
|
5433
5483
|
function repairToolCall(raw, registry) {
|
|
@@ -5502,7 +5552,7 @@ function coerceArgsToSchema(args, schema) {
|
|
|
5502
5552
|
}
|
|
5503
5553
|
|
|
5504
5554
|
// src/tool-error.ts
|
|
5505
|
-
var ToolError = class extends
|
|
5555
|
+
var ToolError = class extends chunkIHFNRNTJ_cjs.TheokitAgentError {
|
|
5506
5556
|
name = "ToolError";
|
|
5507
5557
|
/** The error content surfaced to the model: a string, or text/image blocks. */
|
|
5508
5558
|
content;
|
|
@@ -5696,7 +5746,7 @@ function raceToolExecution(exec, opts) {
|
|
|
5696
5746
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
5697
5747
|
async function dispatchTools(inputs, tools, toolCalls, events, parentSpan) {
|
|
5698
5748
|
const maxConcurrent = inputs.maxConcurrentTools ?? 4;
|
|
5699
|
-
return
|
|
5749
|
+
return chunk7OLG7VI4_cjs.mapWithConcurrency(
|
|
5700
5750
|
toolCalls,
|
|
5701
5751
|
maxConcurrent,
|
|
5702
5752
|
(call) => dispatchSingleCall(inputs, tools, call, events, parentSpan)
|
|
@@ -5724,7 +5774,7 @@ async function dispatchSingleCall(inputs, tools, call, events, parentSpan) {
|
|
|
5724
5774
|
toolSpan?.end();
|
|
5725
5775
|
return fileVeto;
|
|
5726
5776
|
}
|
|
5727
|
-
|
|
5777
|
+
chunkN475ETD6_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5728
5778
|
type: "tool_progress",
|
|
5729
5779
|
toolName: workingCall.name,
|
|
5730
5780
|
toolCallId: callId
|
|
@@ -5755,7 +5805,7 @@ function applyRepairAndExtractCall(tools, call) {
|
|
|
5755
5805
|
function vetoFromForkWhitelist(inputs, call, callId, events) {
|
|
5756
5806
|
const whitelistDecision = chunkVJ26EKGJ_cjs.checkToolWhitelist(call.name);
|
|
5757
5807
|
if (whitelistDecision.allowed) return void 0;
|
|
5758
|
-
|
|
5808
|
+
chunkN475ETD6_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5759
5809
|
type: "permission_denied",
|
|
5760
5810
|
toolName: call.name,
|
|
5761
5811
|
toolCallId: callId,
|
|
@@ -5800,7 +5850,7 @@ async function vetoFromPluginPreHook(inputs, call, callId, events) {
|
|
|
5800
5850
|
...inputs.permissionMode !== void 0 ? { permissionMode: inputs.permissionMode } : {}
|
|
5801
5851
|
});
|
|
5802
5852
|
if (pluginVeto === void 0) return void 0;
|
|
5803
|
-
|
|
5853
|
+
chunkN475ETD6_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5804
5854
|
type: "permission_denied",
|
|
5805
5855
|
toolName: call.name,
|
|
5806
5856
|
toolCallId: callId,
|
|
@@ -5829,7 +5879,7 @@ async function vetoFromFileHookPreDecision(inputs, call, callId, events) {
|
|
|
5829
5879
|
runId: inputs.runId
|
|
5830
5880
|
});
|
|
5831
5881
|
if (!preDecision.blocked) return void 0;
|
|
5832
|
-
|
|
5882
|
+
chunkN475ETD6_cjs.emitRunEvent(inputs.runEventSink, {
|
|
5833
5883
|
type: "permission_denied",
|
|
5834
5884
|
toolName: call.name,
|
|
5835
5885
|
toolCallId: callId,
|
|
@@ -5930,7 +5980,7 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
|
|
|
5930
5980
|
agentId: inputs.agentId,
|
|
5931
5981
|
runId: inputs.runId
|
|
5932
5982
|
}).catch((err) => {
|
|
5933
|
-
|
|
5983
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
5934
5984
|
`[theokit-sdk] postToolUse hook error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5935
5985
|
`
|
|
5936
5986
|
);
|
|
@@ -5949,7 +5999,7 @@ async function emitToolLifecycleDelta(inputs, update) {
|
|
|
5949
5999
|
try {
|
|
5950
6000
|
await inputs.onDelta({ update });
|
|
5951
6001
|
} catch (err) {
|
|
5952
|
-
|
|
6002
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
5953
6003
|
`[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
5954
6004
|
`
|
|
5955
6005
|
);
|
|
@@ -5961,7 +6011,7 @@ async function safeEmitToolHook(callback, event) {
|
|
|
5961
6011
|
await callback(event);
|
|
5962
6012
|
} catch (cause) {
|
|
5963
6013
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
5964
|
-
|
|
6014
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] tool lifecycle hook threw: ${msg}
|
|
5965
6015
|
`);
|
|
5966
6016
|
}
|
|
5967
6017
|
}
|
|
@@ -6028,7 +6078,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
6028
6078
|
(p) => (
|
|
6029
6079
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
6030
6080
|
// structured content); image blocks pass through untouched.
|
|
6031
|
-
p.type === "tool_result" ? { ...p, content:
|
|
6081
|
+
p.type === "tool_result" ? { ...p, content: chunkBPN5ONSW_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
6032
6082
|
)
|
|
6033
6083
|
);
|
|
6034
6084
|
}
|
|
@@ -6223,7 +6273,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
6223
6273
|
const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
|
|
6224
6274
|
if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
|
|
6225
6275
|
for (const key of candidates) {
|
|
6226
|
-
const info =
|
|
6276
|
+
const info = chunkG4XUXSRN_cjs.getCatalogModelInfo(key);
|
|
6227
6277
|
const cost = info?.cost;
|
|
6228
6278
|
if (cost === void 0) continue;
|
|
6229
6279
|
const [prov, ...modelParts] = key.split("/");
|
|
@@ -6235,7 +6285,7 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
6235
6285
|
...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
|
|
6236
6286
|
...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
|
|
6237
6287
|
// M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
|
|
6238
|
-
pricingVersion:
|
|
6288
|
+
pricingVersion: chunkG4XUXSRN_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
|
|
6239
6289
|
};
|
|
6240
6290
|
}
|
|
6241
6291
|
return void 0;
|
|
@@ -6479,12 +6529,13 @@ async function runAgentLoop(inputs) {
|
|
|
6479
6529
|
sendSpan?.end();
|
|
6480
6530
|
}
|
|
6481
6531
|
}
|
|
6482
|
-
async function emitAssistantTextStep(inputs, ctx, text) {
|
|
6532
|
+
async function emitAssistantTextStep(inputs, ctx, text, thinking) {
|
|
6483
6533
|
ctx.events.push(buildAssistantEvent(inputs, text));
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6534
|
+
const steps = [
|
|
6535
|
+
...thinking !== void 0 ? [thinkingStep(thinking)] : [],
|
|
6536
|
+
{ type: "assistantMessage", message: { text } }
|
|
6537
|
+
];
|
|
6538
|
+
ctx.conversation.push({ type: "agentConversationTurn", turn: { steps } });
|
|
6488
6539
|
ctx.finalText = text;
|
|
6489
6540
|
if (inputs.onStep === void 0) return;
|
|
6490
6541
|
const cb = inputs.onStep;
|
|
@@ -6620,13 +6671,15 @@ async function continueOrTerminate(inputs, ctx, llmOutput) {
|
|
|
6620
6671
|
if (llmOutput.errored) return "error";
|
|
6621
6672
|
const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
|
|
6622
6673
|
const text = llmOutput.text.length > 0 ? await transformLlmOutputText(inputs, llmOutput.text, tCtx) : llmOutput.text;
|
|
6674
|
+
const thinking = llmOutput.thinking;
|
|
6623
6675
|
if (text.length > 0) {
|
|
6624
|
-
await emitAssistantTextStep(inputs, ctx, text);
|
|
6676
|
+
await emitAssistantTextStep(inputs, ctx, text, thinking);
|
|
6625
6677
|
}
|
|
6626
6678
|
if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
|
|
6627
6679
|
return finishOrReflect(inputs, ctx, llmOutput);
|
|
6628
6680
|
}
|
|
6629
|
-
ctx
|
|
6681
|
+
recordThinkingOnSilentToolRound(ctx, text, thinking);
|
|
6682
|
+
ctx.messages.push(buildAssistantTurn(text, llmOutput.toolCalls, thinking));
|
|
6630
6683
|
const rawResults = await dispatchTools(
|
|
6631
6684
|
// SE12 — forward a read-only text projection of the transcript-so-far to tool
|
|
6632
6685
|
// handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
|
|
@@ -6662,7 +6715,9 @@ async function inspectDoomLoop(inputs, ctx, toolCalls) {
|
|
|
6662
6715
|
await emitAssistantTextStep(
|
|
6663
6716
|
inputs,
|
|
6664
6717
|
ctx,
|
|
6665
|
-
verdict.message ?? "Stopped: repeated identical tool calls made no progress."
|
|
6718
|
+
verdict.message ?? "Stopped: repeated identical tool calls made no progress.",
|
|
6719
|
+
// The doom-loop stop message is the SDK's own text, not a model turn — it has no thinking.
|
|
6720
|
+
void 0
|
|
6666
6721
|
);
|
|
6667
6722
|
return "stop";
|
|
6668
6723
|
}
|
|
@@ -6683,15 +6738,15 @@ var FallbackLlmClient = class {
|
|
|
6683
6738
|
let lastError;
|
|
6684
6739
|
for (const client of this.clients) {
|
|
6685
6740
|
if (signal.aborted) throw abortError(signal);
|
|
6686
|
-
const attempt = await
|
|
6741
|
+
const attempt = await chunkBPN5ONSW_cjs.tryFirstEvent(client, request, signal, true);
|
|
6687
6742
|
if (attempt.kind === "handshake_error") {
|
|
6688
6743
|
lastError = attempt.error;
|
|
6689
6744
|
continue;
|
|
6690
6745
|
}
|
|
6691
|
-
return yield*
|
|
6746
|
+
return yield* chunkBPN5ONSW_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6692
6747
|
}
|
|
6693
6748
|
if (lastError !== void 0) throw lastError;
|
|
6694
|
-
throw new
|
|
6749
|
+
throw new chunkIHFNRNTJ_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
6695
6750
|
code: "fallback_empty_chain"
|
|
6696
6751
|
});
|
|
6697
6752
|
}
|
|
@@ -6714,7 +6769,7 @@ function reconnectDelay(attempt) {
|
|
|
6714
6769
|
return ms <= 0 ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, ms));
|
|
6715
6770
|
}
|
|
6716
6771
|
function mcpTimeoutError(name, timeoutMs) {
|
|
6717
|
-
return new
|
|
6772
|
+
return new chunkIHFNRNTJ_cjs.NetworkError(`MCP ${name} request timed out after ${timeoutMs}ms`, {
|
|
6718
6773
|
code: "mcp_timeout"
|
|
6719
6774
|
});
|
|
6720
6775
|
}
|
|
@@ -6797,7 +6852,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6797
6852
|
child.stdin.on("error", () => void 0);
|
|
6798
6853
|
child.on("error", () => {
|
|
6799
6854
|
this.rejectAllPending(
|
|
6800
|
-
new
|
|
6855
|
+
new chunkIHFNRNTJ_cjs.NetworkError(`MCP ${this.name} process crashed`, { code: "mcp_crashed" })
|
|
6801
6856
|
);
|
|
6802
6857
|
});
|
|
6803
6858
|
child.on("exit", () => {
|
|
@@ -6805,11 +6860,24 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6805
6860
|
this.child = void 0;
|
|
6806
6861
|
this.dropped = true;
|
|
6807
6862
|
this.rejectAllPending(
|
|
6808
|
-
new
|
|
6863
|
+
new chunkIHFNRNTJ_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6809
6864
|
);
|
|
6810
6865
|
});
|
|
6811
6866
|
}
|
|
6867
|
+
/**
|
|
6868
|
+
* theokit#155 — idempotent while the child is LIVE.
|
|
6869
|
+
*
|
|
6870
|
+
* Under `mcpLifecycle: 'session'` the pool hands the same client back on the next turn, and
|
|
6871
|
+
* `initializeMcp` runs every turn. An unconditional `spawnChild()` would overwrite `this.child`,
|
|
6872
|
+
* orphaning a healthy process (its `exit` handler is skipped by the `this.child === child` guard)
|
|
6873
|
+
* and paying the ~146 ms spawn + handshake the option exists to avoid.
|
|
6874
|
+
*
|
|
6875
|
+
* This does NOT touch the #59 reconnect path: `reconnect()` calls `spawnChild()` and
|
|
6876
|
+
* `super.initialize()` directly, so it re-spawns exactly as before. After `close()` — or after a
|
|
6877
|
+
* drop, which clears `child` — this method spawns again, as it must.
|
|
6878
|
+
*/
|
|
6812
6879
|
async initialize() {
|
|
6880
|
+
if (this.child !== void 0) return;
|
|
6813
6881
|
this.spawnChild();
|
|
6814
6882
|
await super.initialize();
|
|
6815
6883
|
}
|
|
@@ -6820,7 +6888,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6820
6888
|
if (this.child !== void 0) return Promise.resolve();
|
|
6821
6889
|
if (!this.dropped) {
|
|
6822
6890
|
return Promise.reject(
|
|
6823
|
-
new
|
|
6891
|
+
new chunkIHFNRNTJ_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6824
6892
|
);
|
|
6825
6893
|
}
|
|
6826
6894
|
this.reconnectPromise ??= this.reconnect().finally(() => {
|
|
@@ -6841,13 +6909,13 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6841
6909
|
lastErr = err;
|
|
6842
6910
|
}
|
|
6843
6911
|
}
|
|
6844
|
-
throw new
|
|
6912
|
+
throw new chunkIHFNRNTJ_cjs.NetworkError(`MCP ${this.name} reconnect exhausted`, {
|
|
6845
6913
|
code: "mcp_disconnected",
|
|
6846
6914
|
...lastErr instanceof Error ? { cause: lastErr } : {}
|
|
6847
6915
|
});
|
|
6848
6916
|
}
|
|
6849
6917
|
async close() {
|
|
6850
|
-
this.rejectAllPending(new
|
|
6918
|
+
this.rejectAllPending(new chunkIHFNRNTJ_cjs.NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
|
|
6851
6919
|
const child = this.child;
|
|
6852
6920
|
this.child = void 0;
|
|
6853
6921
|
this.dropped = false;
|
|
@@ -6866,7 +6934,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6866
6934
|
if (this.buffer.length > MAX_STDIO_BUFFER_BYTES) {
|
|
6867
6935
|
this.buffer = "";
|
|
6868
6936
|
this.rejectAllPending(
|
|
6869
|
-
new
|
|
6937
|
+
new chunkIHFNRNTJ_cjs.NetworkError(`MCP ${this.name} exceeded stdout buffer limit`, {
|
|
6870
6938
|
code: "mcp_buffer_overflow"
|
|
6871
6939
|
})
|
|
6872
6940
|
);
|
|
@@ -6901,7 +6969,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6901
6969
|
if (child !== void 0) return this.send(child, method, params);
|
|
6902
6970
|
if (this.dropped) return this.reconnectAndRequest(method, params);
|
|
6903
6971
|
return Promise.reject(
|
|
6904
|
-
new
|
|
6972
|
+
new chunkIHFNRNTJ_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
|
|
6905
6973
|
);
|
|
6906
6974
|
}
|
|
6907
6975
|
/** M2 #59 — reconnect a dropped client, then send. Separate async path so the
|
|
@@ -6910,7 +6978,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6910
6978
|
await this.ensureConnected();
|
|
6911
6979
|
const child = this.child;
|
|
6912
6980
|
if (child === void 0) {
|
|
6913
|
-
throw new
|
|
6981
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" });
|
|
6914
6982
|
}
|
|
6915
6983
|
return this.send(child, method, params);
|
|
6916
6984
|
}
|
|
@@ -6927,7 +6995,7 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6927
6995
|
this.child = void 0;
|
|
6928
6996
|
this.dropped = true;
|
|
6929
6997
|
this.rejectAllPending(
|
|
6930
|
-
new
|
|
6998
|
+
new chunkIHFNRNTJ_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
|
|
6931
6999
|
);
|
|
6932
7000
|
}, this.timeoutMs);
|
|
6933
7001
|
this.pending.set(id, { resolve, reject, timer });
|
|
@@ -7005,7 +7073,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
7005
7073
|
if (payload === "") continue;
|
|
7006
7074
|
return JSON.parse(payload);
|
|
7007
7075
|
}
|
|
7008
|
-
throw new
|
|
7076
|
+
throw new chunkIHFNRNTJ_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
|
|
7009
7077
|
code: "mcp_http_error"
|
|
7010
7078
|
});
|
|
7011
7079
|
}
|
|
@@ -7033,7 +7101,7 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
7033
7101
|
throw cause;
|
|
7034
7102
|
}
|
|
7035
7103
|
if (!response.ok) {
|
|
7036
|
-
throw new
|
|
7104
|
+
throw new chunkIHFNRNTJ_cjs.NetworkError(`MCP ${this.name} returned ${response.status}`, {
|
|
7037
7105
|
code: "mcp_http_error"
|
|
7038
7106
|
});
|
|
7039
7107
|
}
|
|
@@ -7049,14 +7117,14 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
7049
7117
|
function resolveMcpCwd(configCwd) {
|
|
7050
7118
|
if (configCwd === void 0) return process.cwd();
|
|
7051
7119
|
if (path.isAbsolute(configCwd)) return configCwd;
|
|
7052
|
-
return
|
|
7120
|
+
return chunk7YBJZS5P_cjs.safePathJoin(process.cwd(), configCwd);
|
|
7053
7121
|
}
|
|
7054
7122
|
|
|
7055
7123
|
// src/internal/providers/register-plugin-providers.ts
|
|
7056
7124
|
function registerPluginProviderProfiles(entries) {
|
|
7057
7125
|
let registered2 = 0;
|
|
7058
7126
|
for (const entry of entries) {
|
|
7059
|
-
|
|
7127
|
+
chunkG4XUXSRN_cjs.registerProvider(entry.profile);
|
|
7060
7128
|
registered2 += 1;
|
|
7061
7129
|
}
|
|
7062
7130
|
return registered2;
|
|
@@ -7136,7 +7204,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
|
|
|
7136
7204
|
if (exposedSet.has(name)) continue;
|
|
7137
7205
|
const hint = suggestClosest(name, exposedSet);
|
|
7138
7206
|
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)`;
|
|
7139
|
-
|
|
7207
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
7140
7208
|
`personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
|
|
7141
7209
|
message
|
|
7142
7210
|
);
|
|
@@ -7178,18 +7246,17 @@ function levenshtein(a, b) {
|
|
|
7178
7246
|
// src/internal/local-agent/real-local-run-tools.ts
|
|
7179
7247
|
function declarativeSubagentTools(agents2, parentTools) {
|
|
7180
7248
|
if (agents2 === void 0 || Object.keys(agents2).length === 0) return [];
|
|
7181
|
-
return
|
|
7249
|
+
return chunkB4YA6BRS_cjs.subAgentToolsFromDefinitions(agents2, parentTools);
|
|
7182
7250
|
}
|
|
7183
|
-
function
|
|
7251
|
+
function resolveInheritedCredentials(agentOptions) {
|
|
7184
7252
|
const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
|
|
7185
7253
|
const parentSandbox = agentOptions.local?.sandboxOptions?.enabled;
|
|
7186
|
-
|
|
7254
|
+
return {
|
|
7187
7255
|
...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
|
|
7188
7256
|
...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
|
|
7189
7257
|
...parentPlugins !== void 0 ? { plugins: parentPlugins } : {},
|
|
7190
7258
|
...parentSandbox !== void 0 ? { sandbox: parentSandbox } : {}
|
|
7191
7259
|
};
|
|
7192
|
-
for (const tool of tools) chunkG2F67XUR_cjs.inheritSubAgentCredentials(tool, credentials);
|
|
7193
7260
|
}
|
|
7194
7261
|
function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, personalityToolWhitelist, agentId, personalityName, subagents, effectiveModel) {
|
|
7195
7262
|
const baseTools = sendOptions?.tools ?? agentOptions.tools ?? [];
|
|
@@ -7201,7 +7268,6 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
|
|
|
7201
7268
|
return {};
|
|
7202
7269
|
}
|
|
7203
7270
|
const allTools = [...baseTools, ...subagentTools, ...pluginTools, ...reasoningTools];
|
|
7204
|
-
bindParentCredentials(allTools, agentOptions);
|
|
7205
7271
|
const merged = allTools.map((tool) => ({
|
|
7206
7272
|
name: tool.name,
|
|
7207
7273
|
description: tool.description,
|
|
@@ -7237,7 +7303,9 @@ function createRealLocalRun(options) {
|
|
|
7237
7303
|
supportedOps: supported,
|
|
7238
7304
|
startTime
|
|
7239
7305
|
},
|
|
7240
|
-
() => buildLoopInputs(options, id, userText, userImages)
|
|
7306
|
+
() => buildLoopInputs(options, id, userText, userImages),
|
|
7307
|
+
runOwnsMcpClients(options.agentOptions),
|
|
7308
|
+
resolveInheritedCredentials(options.agentOptions)
|
|
7241
7309
|
);
|
|
7242
7310
|
handle.bootstrap();
|
|
7243
7311
|
registerRun(handle);
|
|
@@ -7245,25 +7313,25 @@ function createRealLocalRun(options) {
|
|
|
7245
7313
|
}
|
|
7246
7314
|
var pluginProvidersAnnounced = false;
|
|
7247
7315
|
function resolveRunProvider(options) {
|
|
7248
|
-
|
|
7316
|
+
chunkG4XUXSRN_cjs.registerBuiltins();
|
|
7249
7317
|
const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
|
|
7250
7318
|
const registered2 = registerPluginProviderProfiles(profiles);
|
|
7251
7319
|
if (registered2 > 0 && !pluginProvidersAnnounced) {
|
|
7252
7320
|
pluginProvidersAnnounced = true;
|
|
7253
7321
|
const names = profiles.map((e) => e.profile.name).join(", ");
|
|
7254
|
-
|
|
7322
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] registered ${registered2} plugin provider profile(s): ${names}
|
|
7255
7323
|
`);
|
|
7256
7324
|
}
|
|
7257
7325
|
const parsedModel = chunkVYHJZVL5_cjs.parseModelId(options.model?.id);
|
|
7258
|
-
const modelInferredProvider = parsedModel.provider !== void 0 &&
|
|
7259
|
-
const keyInferredProvider =
|
|
7260
|
-
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ??
|
|
7326
|
+
const modelInferredProvider = parsedModel.provider !== void 0 && chunkG4XUXSRN_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
|
|
7327
|
+
const keyInferredProvider = chunkBPN5ONSW_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
|
|
7328
|
+
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkBPN5ONSW_cjs.detectPrimaryProvider();
|
|
7261
7329
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7262
7330
|
return { primary, effectiveModelId };
|
|
7263
7331
|
}
|
|
7264
7332
|
function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
7265
7333
|
if (apiKey === void 0 || apiKey.length === 0) return pools;
|
|
7266
|
-
if (
|
|
7334
|
+
if (chunkBPN5ONSW_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
|
|
7267
7335
|
const existing = pools?.[primary];
|
|
7268
7336
|
if (existing !== void 0 && existing.length > 0) return pools;
|
|
7269
7337
|
return { ...pools ?? {}, [primary]: [apiKey] };
|
|
@@ -7271,7 +7339,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
|
7271
7339
|
function buildLoopInputs(options, runId, userText, userImages) {
|
|
7272
7340
|
const maxIterations = options.sendOptions.maxIterations;
|
|
7273
7341
|
if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
|
|
7274
|
-
throw new
|
|
7342
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
7275
7343
|
`SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
|
|
7276
7344
|
{ code: "invalid_max_iterations" }
|
|
7277
7345
|
);
|
|
@@ -7286,14 +7354,14 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7286
7354
|
const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
|
|
7287
7355
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7288
7356
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7289
|
-
const chain =
|
|
7357
|
+
const chain = chunkBPN5ONSW_cjs.resolveProviderChain({
|
|
7290
7358
|
primary,
|
|
7291
7359
|
...fallback !== void 0 ? { fallback } : {},
|
|
7292
7360
|
...apiKeys !== void 0 ? { apiKeys } : {},
|
|
7293
7361
|
...credentialPoolStrategy !== void 0 ? { credentialPoolStrategy } : {},
|
|
7294
7362
|
...extractToolCallsFromContent === true ? { extractToolCallsFromContent: true } : {},
|
|
7295
7363
|
...rateLimitSink !== void 0 ? {
|
|
7296
|
-
onRateLimit: (info) =>
|
|
7364
|
+
onRateLimit: (info) => chunkN475ETD6_cjs.emitRunEvent(rateLimitSink, { type: "rate_limit", ...info })
|
|
7297
7365
|
} : {}
|
|
7298
7366
|
});
|
|
7299
7367
|
const llm = chain.length === 1 ? chain[0] : new FallbackLlmClient(chain);
|
|
@@ -7376,11 +7444,14 @@ function disposeSessionMcpClients(agentId) {
|
|
|
7376
7444
|
void client.close();
|
|
7377
7445
|
});
|
|
7378
7446
|
}
|
|
7447
|
+
function runOwnsMcpClients(agentOptions) {
|
|
7448
|
+
return agentOptions.mcpLifecycle !== "session";
|
|
7449
|
+
}
|
|
7379
7450
|
function buildMcpMap(options) {
|
|
7380
7451
|
const map = /* @__PURE__ */ new Map();
|
|
7381
7452
|
const inline = options.sendOptions.mcpServers ?? options.agentOptions.mcpServers;
|
|
7382
7453
|
if (inline === void 0) return map;
|
|
7383
|
-
const pooled = options.agentOptions
|
|
7454
|
+
const pooled = !runOwnsMcpClients(options.agentOptions);
|
|
7384
7455
|
if (pooled) sessionMcpPool.reapIdle((c) => void c.close());
|
|
7385
7456
|
for (const [name, config] of Object.entries(inline)) {
|
|
7386
7457
|
map.set(
|
|
@@ -7392,9 +7463,15 @@ function buildMcpMap(options) {
|
|
|
7392
7463
|
}
|
|
7393
7464
|
var RealLocalRun = class extends FixtureRunBase {
|
|
7394
7465
|
buildInputs;
|
|
7395
|
-
|
|
7466
|
+
/** theokit#155 — whether this turn releases its MCP clients, or the session pool does. */
|
|
7467
|
+
ownsMcpClients;
|
|
7468
|
+
/** theokit#148 — what a delegated child inherits from this parent, scoped to the loop. */
|
|
7469
|
+
inheritedCredentials;
|
|
7470
|
+
constructor(options, buildInputs, ownsMcpClients, inheritedCredentials) {
|
|
7396
7471
|
super(options);
|
|
7397
7472
|
this.buildInputs = buildInputs;
|
|
7473
|
+
this.ownsMcpClients = ownsMcpClients;
|
|
7474
|
+
this.inheritedCredentials = inheritedCredentials;
|
|
7398
7475
|
}
|
|
7399
7476
|
bootstrap() {
|
|
7400
7477
|
setTimeout(() => {
|
|
@@ -7455,15 +7532,18 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7455
7532
|
this.pushTimeline({ kind: "delta", update: delta.update });
|
|
7456
7533
|
};
|
|
7457
7534
|
try {
|
|
7458
|
-
const
|
|
7535
|
+
const runLoop = () => inputs.activeTools !== void 0 ? chunkVJ26EKGJ_cjs.withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : runAgentLoop(inputs);
|
|
7536
|
+
const output = await chunkB4YA6BRS_cjs.withInheritedSubAgentCredentials(this.inheritedCredentials, runLoop);
|
|
7459
7537
|
this.applyAgentLoopOutput(output);
|
|
7460
7538
|
this.transitionTo(output.finalStatus);
|
|
7461
7539
|
} catch (cause) {
|
|
7462
7540
|
this.emitErrorEvent(cause, "Agent loop failed", "", "agent_loop_failed");
|
|
7463
7541
|
this.transitionTo("error");
|
|
7464
7542
|
} finally {
|
|
7465
|
-
|
|
7466
|
-
|
|
7543
|
+
if (this.ownsMcpClients) {
|
|
7544
|
+
for (const client of inputs.mcp.values()) {
|
|
7545
|
+
await client.close().catch(() => void 0);
|
|
7546
|
+
}
|
|
7467
7547
|
}
|
|
7468
7548
|
}
|
|
7469
7549
|
}
|
|
@@ -7546,7 +7626,7 @@ function buildRealRunOptions(args) {
|
|
|
7546
7626
|
};
|
|
7547
7627
|
}
|
|
7548
7628
|
async function createFixtureRunHelper(args) {
|
|
7549
|
-
const sessionMessages =
|
|
7629
|
+
const sessionMessages = chunkDCXRHCZJ_cjs.getSessionMessages(args.inputs.agentId);
|
|
7550
7630
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7551
7631
|
return createLocalRun({
|
|
7552
7632
|
agentId: args.inputs.agentId,
|
|
@@ -7565,7 +7645,7 @@ async function createFixtureRunHelper(args) {
|
|
|
7565
7645
|
}
|
|
7566
7646
|
async function dispatchLocalRun(args) {
|
|
7567
7647
|
const apiKey = resolveApiKey(args.inputs.options.apiKey);
|
|
7568
|
-
if (
|
|
7648
|
+
if (chunkBPN5ONSW_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7569
7649
|
return createRealLocalRun(
|
|
7570
7650
|
buildRealRunOptions({
|
|
7571
7651
|
inputs: args.inputs,
|
|
@@ -7600,20 +7680,20 @@ async function readProjectMcpServers(cwd) {
|
|
|
7600
7680
|
|
|
7601
7681
|
// src/internal/local-agent/local-agent-invalidate.ts
|
|
7602
7682
|
async function applyDeferredInvalidation(agentId, pending, refresh) {
|
|
7603
|
-
|
|
7683
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] applying deferred cache invalidation (${agentId}): ${pending.reason}
|
|
7604
7684
|
`);
|
|
7605
7685
|
try {
|
|
7606
7686
|
await refresh();
|
|
7607
7687
|
} catch (err) {
|
|
7608
7688
|
const msg = err instanceof Error ? err.message : String(err);
|
|
7609
|
-
|
|
7689
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] invalidateCache reload failed (continuing): ${msg}
|
|
7610
7690
|
`);
|
|
7611
7691
|
}
|
|
7612
7692
|
}
|
|
7613
7693
|
async function invalidateCacheImpl(agentId, reason, options, disposed, dispose, setPending) {
|
|
7614
7694
|
if (disposed) return;
|
|
7615
7695
|
if (options.applyNow === true) {
|
|
7616
|
-
|
|
7696
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] invalidateCache applyNow disposing agent (${agentId}): ${reason}
|
|
7617
7697
|
`);
|
|
7618
7698
|
await dispose();
|
|
7619
7699
|
return;
|
|
@@ -7674,7 +7754,7 @@ var LiveAgentRegistry = class {
|
|
|
7674
7754
|
const existing = this.#agents.get(id);
|
|
7675
7755
|
if (existing !== void 0 && existing.agent !== agent) {
|
|
7676
7756
|
void existing.agent.dispose().catch(() => {
|
|
7677
|
-
|
|
7757
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] dispose during overwrite failed (${id})
|
|
7678
7758
|
`);
|
|
7679
7759
|
});
|
|
7680
7760
|
}
|
|
@@ -7778,7 +7858,7 @@ var LiveAgentRegistry = class {
|
|
|
7778
7858
|
await agent.dispose();
|
|
7779
7859
|
} catch (cause) {
|
|
7780
7860
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7781
|
-
|
|
7861
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] dispose during eviction failed (${id}): ${msg}
|
|
7782
7862
|
`);
|
|
7783
7863
|
}
|
|
7784
7864
|
if (this.#onEvict !== void 0) {
|
|
@@ -7786,7 +7866,7 @@ var LiveAgentRegistry = class {
|
|
|
7786
7866
|
this.#onEvict(id, reason);
|
|
7787
7867
|
} catch (cause) {
|
|
7788
7868
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
7789
|
-
|
|
7869
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] onEvict listener threw (${id}): ${msg}
|
|
7790
7870
|
`);
|
|
7791
7871
|
}
|
|
7792
7872
|
}
|
|
@@ -7802,7 +7882,7 @@ async function acquireLeaseIfPossible(store, agentId) {
|
|
|
7802
7882
|
await a.call(store, agentId);
|
|
7803
7883
|
} catch (err) {
|
|
7804
7884
|
if (err instanceof Error && err.name === "SessionBusyError") throw err;
|
|
7805
|
-
|
|
7885
|
+
chunkBCQ3E2ZG_cjs.diag(
|
|
7806
7886
|
`[theokit-sdk] writer lease unavailable for ${agentId} (${err instanceof Error ? err.message : String(err)}) \u2014 proceeding without single-writer protection
|
|
7807
7887
|
`
|
|
7808
7888
|
);
|
|
@@ -7821,16 +7901,16 @@ async function disposeLocalAgentSession(agent) {
|
|
|
7821
7901
|
agent.lifecycleAbortController.abort();
|
|
7822
7902
|
await chunkYLQQX5W2_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
7823
7903
|
disposeSessionMcpClients(agent.agentId);
|
|
7824
|
-
await
|
|
7904
|
+
await chunkDCXRHCZJ_cjs.flushSessionWrites();
|
|
7825
7905
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
7826
7906
|
await disposeSessionStore(agent.sessionStore);
|
|
7827
|
-
|
|
7907
|
+
chunkDCXRHCZJ_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
7828
7908
|
}
|
|
7829
7909
|
async function reloadLocalAgent(agent) {
|
|
7830
7910
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
7831
7911
|
if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
|
|
7832
7912
|
if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
|
|
7833
|
-
return await
|
|
7913
|
+
return await chunkW4WKVOOQ_cjs.loadSubagents(
|
|
7834
7914
|
agent.workspaceCwd,
|
|
7835
7915
|
agent.settingSourcesIncludeProject,
|
|
7836
7916
|
agent.options.agents
|
|
@@ -7838,12 +7918,12 @@ async function reloadLocalAgent(agent) {
|
|
|
7838
7918
|
}
|
|
7839
7919
|
async function persistActiveMemoryTranscript(cwd, transcript) {
|
|
7840
7920
|
try {
|
|
7841
|
-
const dir = path.join(
|
|
7921
|
+
const dir = path.join(chunkCN6UX5EV_cjs.memoryDir(cwd), "transcripts", "active-memory");
|
|
7842
7922
|
const file = path.join(dir, `${transcript.runId}.json`);
|
|
7843
|
-
await
|
|
7923
|
+
await chunkDGLLVCNB_cjs.atomicWriteJson(file, transcript);
|
|
7844
7924
|
} catch (cause) {
|
|
7845
7925
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7846
|
-
|
|
7926
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] active-memory transcript persist failed: ${message}
|
|
7847
7927
|
`);
|
|
7848
7928
|
}
|
|
7849
7929
|
}
|
|
@@ -7964,7 +8044,7 @@ async function searchOnce(args, cfg, query, started) {
|
|
|
7964
8044
|
return { summary, durationMs: Date.now() - started, status: "ok", hits };
|
|
7965
8045
|
} catch (cause) {
|
|
7966
8046
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7967
|
-
|
|
8047
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] active-memory recall failed: ${message}
|
|
7968
8048
|
`);
|
|
7969
8049
|
return { summary: void 0, durationMs: Date.now() - started, status: "error", hits: [] };
|
|
7970
8050
|
}
|
|
@@ -8070,184 +8150,6 @@ function cacheKey(userText, queryMode, ctx) {
|
|
|
8070
8150
|
const parts = [queryMode, ctx?.namespace ?? "", ctx?.userId ?? "", ctx?.scope ?? "", userText];
|
|
8071
8151
|
return crypto.createHash("sha256").update(parts.join("\0")).digest("hex");
|
|
8072
8152
|
}
|
|
8073
|
-
var MAX_BATCH = 100;
|
|
8074
|
-
var MAX_RETRIES = 2;
|
|
8075
|
-
async function createOpenAiCompatibleRuntime(cfg, options) {
|
|
8076
|
-
const model = options.model ?? cfg.defaultModel;
|
|
8077
|
-
const apiKey = options.apiKey ?? process.env[cfg.apiKeyEnv];
|
|
8078
|
-
if (apiKey === void 0 || apiKey.length === 0) {
|
|
8079
|
-
throw new chunkA3MHE2MQ_cjs.AuthenticationError(`${cfg.apiKeyEnv} missing`, {
|
|
8080
|
-
code: "embedding_missing_api_key"
|
|
8081
|
-
});
|
|
8082
|
-
}
|
|
8083
|
-
const envBaseUrl = cfg.baseUrlEnv !== void 0 ? process.env[cfg.baseUrlEnv] : void 0;
|
|
8084
|
-
const baseUrl = options.baseUrl ?? envBaseUrl ?? cfg.defaultBaseUrl;
|
|
8085
|
-
const fetchImpl = options.fetch ?? fetch;
|
|
8086
|
-
const cache = options.cache ?? chunk3BSP7LSG_cjs.globalEmbeddingCache;
|
|
8087
|
-
const dimension = cfg.dimensionByModel[model];
|
|
8088
|
-
if (dimension === void 0) {
|
|
8089
|
-
throw new chunkA3MHE2MQ_cjs.ConfigurationError(
|
|
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.`,
|
|
8091
|
-
{ code: "embedding_unknown_model" }
|
|
8092
|
-
);
|
|
8093
|
-
}
|
|
8094
|
-
const embeddingsPath = cfg.embeddingsPath ?? "/v1/embeddings";
|
|
8095
|
-
const stats = {
|
|
8096
|
-
cacheHits: 0,
|
|
8097
|
-
cacheMisses: 0,
|
|
8098
|
-
httpCalls: 0,
|
|
8099
|
-
retries: 0
|
|
8100
|
-
};
|
|
8101
|
-
return {
|
|
8102
|
-
id: cfg.id,
|
|
8103
|
-
model,
|
|
8104
|
-
dimension,
|
|
8105
|
-
stats: () => ({ ...stats }),
|
|
8106
|
-
embed: (texts) => embedTexts({
|
|
8107
|
-
texts,
|
|
8108
|
-
cache,
|
|
8109
|
-
stats,
|
|
8110
|
-
model,
|
|
8111
|
-
dimension,
|
|
8112
|
-
apiKey,
|
|
8113
|
-
baseUrl,
|
|
8114
|
-
embeddingsPath,
|
|
8115
|
-
fetchImpl,
|
|
8116
|
-
providerId: cfg.id
|
|
8117
|
-
})
|
|
8118
|
-
};
|
|
8119
|
-
}
|
|
8120
|
-
async function embedTexts(input) {
|
|
8121
|
-
const { texts, cache, stats, model, dimension } = input;
|
|
8122
|
-
const results = new Array(texts.length);
|
|
8123
|
-
const pending = [];
|
|
8124
|
-
for (let i = 0; i < texts.length; i++) {
|
|
8125
|
-
classifyEntry({
|
|
8126
|
-
index: i,
|
|
8127
|
-
text: texts[i] ?? "",
|
|
8128
|
-
model,
|
|
8129
|
-
dimension,
|
|
8130
|
-
cache,
|
|
8131
|
-
stats,
|
|
8132
|
-
results,
|
|
8133
|
-
pending
|
|
8134
|
-
});
|
|
8135
|
-
}
|
|
8136
|
-
await embedInBoundedBatches(input, pending, results);
|
|
8137
|
-
return results.map((v) => v ?? new Array(dimension).fill(0));
|
|
8138
|
-
}
|
|
8139
|
-
function classifyEntry(args) {
|
|
8140
|
-
if (args.text.trim().length === 0) {
|
|
8141
|
-
args.results[args.index] = new Array(args.dimension).fill(0);
|
|
8142
|
-
return;
|
|
8143
|
-
}
|
|
8144
|
-
const key = hashKey(args.model, args.text);
|
|
8145
|
-
const cached = args.cache.get(key);
|
|
8146
|
-
if (cached !== void 0) {
|
|
8147
|
-
args.stats.cacheHits += 1;
|
|
8148
|
-
args.results[args.index] = cached;
|
|
8149
|
-
return;
|
|
8150
|
-
}
|
|
8151
|
-
args.stats.cacheMisses += 1;
|
|
8152
|
-
args.pending.push({ index: args.index, text: args.text, key });
|
|
8153
|
-
}
|
|
8154
|
-
var MAX_CONCURRENT_BATCHES = 3;
|
|
8155
|
-
async function embedInBoundedBatches(input, pending, results) {
|
|
8156
|
-
const batches = [];
|
|
8157
|
-
for (let offset = 0; offset < pending.length; offset += MAX_BATCH) {
|
|
8158
|
-
batches.push(pending.slice(offset, offset + MAX_BATCH));
|
|
8159
|
-
}
|
|
8160
|
-
await chunk3XRXORBS_cjs.mapWithConcurrency(
|
|
8161
|
-
batches,
|
|
8162
|
-
MAX_CONCURRENT_BATCHES,
|
|
8163
|
-
(batch) => processBatch(input, batch, results)
|
|
8164
|
-
);
|
|
8165
|
-
}
|
|
8166
|
-
async function processBatch(input, batch, results) {
|
|
8167
|
-
const vectors = await embedBatch({
|
|
8168
|
-
apiKey: input.apiKey,
|
|
8169
|
-
baseUrl: input.baseUrl,
|
|
8170
|
-
embeddingsPath: input.embeddingsPath,
|
|
8171
|
-
model: input.model,
|
|
8172
|
-
inputs: batch.map((b) => b.text),
|
|
8173
|
-
fetchImpl: input.fetchImpl,
|
|
8174
|
-
stats: input.stats,
|
|
8175
|
-
providerId: input.providerId
|
|
8176
|
-
});
|
|
8177
|
-
for (let j = 0; j < batch.length; j++) {
|
|
8178
|
-
const slot = batch[j];
|
|
8179
|
-
const vector = vectors[j];
|
|
8180
|
-
if (slot === void 0 || vector === void 0) continue;
|
|
8181
|
-
results[slot.index] = vector;
|
|
8182
|
-
input.cache.set(slot.key, vector);
|
|
8183
|
-
}
|
|
8184
|
-
}
|
|
8185
|
-
async function embedBatch(opts) {
|
|
8186
|
-
const url = `${opts.baseUrl.replace(/\/$/, "")}${opts.embeddingsPath}`;
|
|
8187
|
-
let attempt = 0;
|
|
8188
|
-
while (true) {
|
|
8189
|
-
opts.stats.httpCalls += 1;
|
|
8190
|
-
const response = await postEmbedRequest(opts, url);
|
|
8191
|
-
if (response.ok)
|
|
8192
|
-
return await parseEmbedResponse(response, opts.providerId, opts.embeddingsPath);
|
|
8193
|
-
if (isRetryable(response.status) && attempt < MAX_RETRIES) {
|
|
8194
|
-
attempt += 1;
|
|
8195
|
-
opts.stats.retries += 1;
|
|
8196
|
-
await sleep(linearBackoffMs(attempt));
|
|
8197
|
-
continue;
|
|
8198
|
-
}
|
|
8199
|
-
const text = await response.text().catch(() => "");
|
|
8200
|
-
let body = text;
|
|
8201
|
-
try {
|
|
8202
|
-
body = JSON.parse(text);
|
|
8203
|
-
} catch {
|
|
8204
|
-
}
|
|
8205
|
-
throw chunkG7X2Y7Y2_cjs.mapOpenAICompatibleError({
|
|
8206
|
-
providerId: opts.providerId,
|
|
8207
|
-
status: response.status,
|
|
8208
|
-
body,
|
|
8209
|
-
headers: response.headers,
|
|
8210
|
-
endpoint: opts.embeddingsPath
|
|
8211
|
-
});
|
|
8212
|
-
}
|
|
8213
|
-
}
|
|
8214
|
-
async function postEmbedRequest(opts, url) {
|
|
8215
|
-
return opts.fetchImpl(url, {
|
|
8216
|
-
method: "POST",
|
|
8217
|
-
headers: {
|
|
8218
|
-
"content-type": "application/json",
|
|
8219
|
-
authorization: `Bearer ${opts.apiKey}`
|
|
8220
|
-
},
|
|
8221
|
-
body: JSON.stringify({ model: opts.model, input: opts.inputs })
|
|
8222
|
-
});
|
|
8223
|
-
}
|
|
8224
|
-
async function parseEmbedResponse(response, providerId, endpoint) {
|
|
8225
|
-
const json = await response.json();
|
|
8226
|
-
if (!Array.isArray(json.data)) {
|
|
8227
|
-
throw new chunkA3MHE2MQ_cjs.NetworkError(`${providerId} ${endpoint} returned no data`, {
|
|
8228
|
-
code: "embedding_invalid_response",
|
|
8229
|
-
metadata: {
|
|
8230
|
-
provider: providerId,
|
|
8231
|
-
endpoint,
|
|
8232
|
-
code: "invalid_request",
|
|
8233
|
-
raw: json
|
|
8234
|
-
}
|
|
8235
|
-
});
|
|
8236
|
-
}
|
|
8237
|
-
return json.data.map((d) => d.embedding);
|
|
8238
|
-
}
|
|
8239
|
-
function isRetryable(status) {
|
|
8240
|
-
return status === 429 || status >= 500 && status < 600;
|
|
8241
|
-
}
|
|
8242
|
-
function hashKey(model, text) {
|
|
8243
|
-
return crypto.createHash("sha256").update(`${model} ${text}`).digest("hex");
|
|
8244
|
-
}
|
|
8245
|
-
function linearBackoffMs(attempt) {
|
|
8246
|
-
return 50 * attempt;
|
|
8247
|
-
}
|
|
8248
|
-
function sleep(ms) {
|
|
8249
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
8250
|
-
}
|
|
8251
8153
|
|
|
8252
8154
|
// src/internal/memory/adapters/azure-openai-embedding.ts
|
|
8253
8155
|
var DEFAULT_AZURE_OPENAI_EMBEDDING_MODEL = "text-embedding-3-small";
|
|
@@ -8262,7 +8164,7 @@ var azureOpenAiMemoryEmbeddingProviderAdapter = {
|
|
|
8262
8164
|
transport: "remote",
|
|
8263
8165
|
authProviderId: "azure-openai",
|
|
8264
8166
|
autoSelectPriority: 25,
|
|
8265
|
-
create: (options) => createOpenAiCompatibleRuntime(
|
|
8167
|
+
create: (options) => chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8266
8168
|
{
|
|
8267
8169
|
id: "azure-openai",
|
|
8268
8170
|
defaultBaseUrl: "https://your-resource.openai.azure.com",
|
|
@@ -8270,7 +8172,15 @@ var azureOpenAiMemoryEmbeddingProviderAdapter = {
|
|
|
8270
8172
|
baseUrlEnv: "AZURE_OPENAI_ENDPOINT",
|
|
8271
8173
|
defaultModel: DEFAULT_AZURE_OPENAI_EMBEDDING_MODEL,
|
|
8272
8174
|
embeddingsPath: "/openai/deployments/{model}/embeddings?api-version=2024-02-01",
|
|
8273
|
-
dimensionByModel: DIMENSION_BY_MODEL
|
|
8175
|
+
dimensionByModel: DIMENSION_BY_MODEL,
|
|
8176
|
+
// theokit#159 — Azure is NOT OpenAI on the wire, despite the name. It authenticates an API
|
|
8177
|
+
// key with the `api-key` header (`Authorization: Bearer` is for Entra ID tokens, not for
|
|
8178
|
+
// AZURE_OPENAI_API_KEY), and the deployment already rides in the path, so `model` has no
|
|
8179
|
+
// place in the body. Sending the OpenAI shape meant every request was rejected.
|
|
8180
|
+
dialect: {
|
|
8181
|
+
authHeaders: (apiKey) => ({ "api-key": apiKey }),
|
|
8182
|
+
body: (_model, inputs) => ({ input: inputs })
|
|
8183
|
+
}
|
|
8274
8184
|
},
|
|
8275
8185
|
options
|
|
8276
8186
|
)
|
|
@@ -8290,14 +8200,27 @@ var cohereMemoryEmbeddingProviderAdapter = {
|
|
|
8290
8200
|
transport: "remote",
|
|
8291
8201
|
authProviderId: "cohere",
|
|
8292
8202
|
autoSelectPriority: 30,
|
|
8293
|
-
create: (options) => createOpenAiCompatibleRuntime(
|
|
8203
|
+
create: (options) => chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8294
8204
|
{
|
|
8295
8205
|
id: "cohere",
|
|
8296
8206
|
defaultBaseUrl: "https://api.cohere.com",
|
|
8297
8207
|
apiKeyEnv: "COHERE_API_KEY",
|
|
8298
8208
|
defaultModel: DEFAULT_COHERE_EMBEDDING_MODEL,
|
|
8299
8209
|
embeddingsPath: "/v2/embed",
|
|
8300
|
-
dimensionByModel: DIMENSION_BY_MODEL2
|
|
8210
|
+
dimensionByModel: DIMENSION_BY_MODEL2,
|
|
8211
|
+
// theokit#159 — `/v2/embed` diverges in BOTH directions: it names the payload `texts`, requires
|
|
8212
|
+
// `input_type`, and answers `{embeddings:{float:[[...]]}}` rather than `{data:[{embedding}]}`.
|
|
8213
|
+
// `search_document` is the right default here because this runtime embeds material for
|
|
8214
|
+
// storage; a query-side embedder would use `search_query`.
|
|
8215
|
+
dialect: {
|
|
8216
|
+
body: (model, inputs) => ({
|
|
8217
|
+
model,
|
|
8218
|
+
texts: [...inputs],
|
|
8219
|
+
input_type: "search_document",
|
|
8220
|
+
embedding_types: ["float"]
|
|
8221
|
+
}),
|
|
8222
|
+
vectors: (json) => json.embeddings?.float
|
|
8223
|
+
}
|
|
8301
8224
|
},
|
|
8302
8225
|
options
|
|
8303
8226
|
)
|
|
@@ -8323,7 +8246,7 @@ var deepinfraMemoryEmbeddingProviderAdapter = {
|
|
|
8323
8246
|
transport: "remote",
|
|
8324
8247
|
authProviderId: "deepinfra",
|
|
8325
8248
|
autoSelectPriority: 13,
|
|
8326
|
-
create: (options) => createOpenAiCompatibleRuntime(
|
|
8249
|
+
create: (options) => chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8327
8250
|
{
|
|
8328
8251
|
id: "deepinfra",
|
|
8329
8252
|
defaultBaseUrl: "https://api.deepinfra.com",
|
|
@@ -8349,12 +8272,15 @@ var geminiMemoryEmbeddingProviderAdapter = {
|
|
|
8349
8272
|
transport: "remote",
|
|
8350
8273
|
authProviderId: "gemini",
|
|
8351
8274
|
autoSelectPriority: 30,
|
|
8352
|
-
create: (options) => createOpenAiCompatibleRuntime(
|
|
8275
|
+
create: (options) => chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8353
8276
|
{
|
|
8354
8277
|
id: "gemini",
|
|
8355
8278
|
defaultBaseUrl: "https://generativelanguage.googleapis.com",
|
|
8356
8279
|
apiKeyEnv: "GEMINI_API_KEY",
|
|
8357
8280
|
defaultModel: DEFAULT_GEMINI_EMBEDDING_MODEL,
|
|
8281
|
+
// theokit#159 — the compat surface is under `/v1beta/openai/`, not the default
|
|
8282
|
+
// `/v1/embeddings`; the previous path 404'd on every call.
|
|
8283
|
+
embeddingsPath: "/v1beta/openai/embeddings",
|
|
8358
8284
|
dimensionByModel: DIMENSION_BY_MODEL4
|
|
8359
8285
|
},
|
|
8360
8286
|
options
|
|
@@ -8374,7 +8300,7 @@ var jinaMemoryEmbeddingProviderAdapter = {
|
|
|
8374
8300
|
transport: "remote",
|
|
8375
8301
|
authProviderId: "jina",
|
|
8376
8302
|
autoSelectPriority: 35,
|
|
8377
|
-
create: (options) => createOpenAiCompatibleRuntime(
|
|
8303
|
+
create: (options) => chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8378
8304
|
{
|
|
8379
8305
|
id: "jina",
|
|
8380
8306
|
defaultBaseUrl: "https://api.jina.ai",
|
|
@@ -8397,7 +8323,7 @@ var mistralMemoryEmbeddingProviderAdapter = {
|
|
|
8397
8323
|
transport: "remote",
|
|
8398
8324
|
authProviderId: "mistral",
|
|
8399
8325
|
autoSelectPriority: 18,
|
|
8400
|
-
create: (options) => createOpenAiCompatibleRuntime(
|
|
8326
|
+
create: (options) => chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8401
8327
|
{
|
|
8402
8328
|
id: "mistral",
|
|
8403
8329
|
defaultBaseUrl: "https://api.mistral.ai",
|
|
@@ -8439,7 +8365,7 @@ var ollamaMemoryEmbeddingProviderAdapter = {
|
|
|
8439
8365
|
autoSelectPriority: 10,
|
|
8440
8366
|
create: (options) => {
|
|
8441
8367
|
const apiKey = options.apiKey ?? process.env.OLLAMA_API_KEY ?? OLLAMA_LOCAL_SENTINEL_KEY;
|
|
8442
|
-
return createOpenAiCompatibleRuntime(
|
|
8368
|
+
return chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8443
8369
|
{
|
|
8444
8370
|
id: "ollama",
|
|
8445
8371
|
defaultBaseUrl: "http://localhost:11434",
|
|
@@ -8466,7 +8392,7 @@ var openAiMemoryEmbeddingProviderAdapter = {
|
|
|
8466
8392
|
transport: "remote",
|
|
8467
8393
|
authProviderId: "openai",
|
|
8468
8394
|
autoSelectPriority: 20,
|
|
8469
|
-
create: (options) => createOpenAiCompatibleRuntime(
|
|
8395
|
+
create: (options) => chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8470
8396
|
{
|
|
8471
8397
|
id: "openai",
|
|
8472
8398
|
defaultBaseUrl: "https://api.openai.com",
|
|
@@ -8493,7 +8419,7 @@ var openRouterMemoryEmbeddingProviderAdapter = {
|
|
|
8493
8419
|
transport: "remote",
|
|
8494
8420
|
authProviderId: "openrouter",
|
|
8495
8421
|
autoSelectPriority: 15,
|
|
8496
|
-
create: (options) => createOpenAiCompatibleRuntime(
|
|
8422
|
+
create: (options) => chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8497
8423
|
{
|
|
8498
8424
|
id: "openrouter",
|
|
8499
8425
|
defaultBaseUrl: "https://openrouter.ai/api",
|
|
@@ -8521,7 +8447,7 @@ var voyageMemoryEmbeddingProviderAdapter = {
|
|
|
8521
8447
|
transport: "remote",
|
|
8522
8448
|
authProviderId: "voyage",
|
|
8523
8449
|
autoSelectPriority: 14,
|
|
8524
|
-
create: (options) => createOpenAiCompatibleRuntime(
|
|
8450
|
+
create: (options) => chunk7U2HAAWB_cjs.createOpenAiCompatibleRuntime(
|
|
8525
8451
|
{
|
|
8526
8452
|
id: "voyage",
|
|
8527
8453
|
defaultBaseUrl: "https://api.voyageai.com",
|
|
@@ -8622,7 +8548,7 @@ function createMemorySearchTool(opts) {
|
|
|
8622
8548
|
};
|
|
8623
8549
|
}
|
|
8624
8550
|
function createMemoryGetTool(opts) {
|
|
8625
|
-
const memoryRoot = path.resolve(
|
|
8551
|
+
const memoryRoot = path.resolve(chunkCN6UX5EV_cjs.memoryDir(opts.cwd));
|
|
8626
8552
|
return {
|
|
8627
8553
|
name: "memory_get",
|
|
8628
8554
|
description: GET_DESCRIPTION,
|
|
@@ -8633,7 +8559,7 @@ function createMemoryGetTool(opts) {
|
|
|
8633
8559
|
const lines = readNumber(input.lines);
|
|
8634
8560
|
const resolved = path.resolve(memoryRoot, relPath);
|
|
8635
8561
|
if (!isPathInside(memoryRoot, resolved)) {
|
|
8636
|
-
throw new
|
|
8562
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
8637
8563
|
`memory_get rejected path that escapes memory root: ${relPath}`,
|
|
8638
8564
|
{ code: "memory_path_escapes_root" }
|
|
8639
8565
|
);
|
|
@@ -8653,7 +8579,7 @@ function readString(value, errorIfMissing, allowUndefined = false) {
|
|
|
8653
8579
|
if (typeof value === "string") return value;
|
|
8654
8580
|
if (allowUndefined && (value === void 0 || value === null)) return "";
|
|
8655
8581
|
if (errorIfMissing !== void 0) {
|
|
8656
|
-
throw new
|
|
8582
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(errorIfMissing, { code: "memory_tool_bad_args" });
|
|
8657
8583
|
}
|
|
8658
8584
|
return "";
|
|
8659
8585
|
}
|
|
@@ -8729,7 +8655,7 @@ var LocalAgentMemory = class {
|
|
|
8729
8655
|
const openOpts = { cwd: this.workspaceCwd };
|
|
8730
8656
|
if (embedding !== void 0) openOpts.embedding = embedding;
|
|
8731
8657
|
if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
|
|
8732
|
-
this.index = await
|
|
8658
|
+
this.index = await chunkCN6UX5EV_cjs.IndexManager.open(openOpts);
|
|
8733
8659
|
await this.index.sync();
|
|
8734
8660
|
this.toolsCache = [
|
|
8735
8661
|
createMemorySearchTool({ index: this.index }),
|
|
@@ -8744,7 +8670,7 @@ var LocalAgentMemory = class {
|
|
|
8744
8670
|
const warned2 = g[sym];
|
|
8745
8671
|
if (!warned2.has(message)) {
|
|
8746
8672
|
warned2.add(message);
|
|
8747
|
-
|
|
8673
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] memory tools unavailable: ${message}
|
|
8748
8674
|
`);
|
|
8749
8675
|
}
|
|
8750
8676
|
return void 0;
|
|
@@ -8753,7 +8679,7 @@ var LocalAgentMemory = class {
|
|
|
8753
8679
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8754
8680
|
const cfg = this.options.memory?.activeRecall;
|
|
8755
8681
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8756
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8682
|
+
if (this.breaker === void 0) this.breaker = new chunkBPN5ONSW_cjs.CircuitBreaker();
|
|
8757
8683
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8758
8684
|
const result = await runActiveMemory({
|
|
8759
8685
|
userText,
|
|
@@ -8803,7 +8729,7 @@ var LocalAgentMemory = class {
|
|
|
8803
8729
|
await this.index.sync();
|
|
8804
8730
|
} catch (cause) {
|
|
8805
8731
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8806
|
-
|
|
8732
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] session index sync failed: ${message}
|
|
8807
8733
|
`);
|
|
8808
8734
|
}
|
|
8809
8735
|
}
|
|
@@ -8816,7 +8742,7 @@ var LocalAgentMemory = class {
|
|
|
8816
8742
|
return await adapter.create(cfg.model !== void 0 ? { model: cfg.model } : {});
|
|
8817
8743
|
} catch (cause) {
|
|
8818
8744
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8819
|
-
|
|
8745
|
+
chunkBCQ3E2ZG_cjs.diag(`[theokit-sdk] memory embedding ${cfg.provider} unavailable: ${message}
|
|
8820
8746
|
`);
|
|
8821
8747
|
return void 0;
|
|
8822
8748
|
}
|
|
@@ -8852,7 +8778,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8852
8778
|
...partial?.metadata !== void 0 ? { metadata: partial.metadata } : defaultContext?.metadata !== void 0 ? { metadata: defaultContext.metadata } : {}
|
|
8853
8779
|
};
|
|
8854
8780
|
if (merged.userId === "") {
|
|
8855
|
-
throw new
|
|
8781
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
8856
8782
|
"agent.memory requires a userId \u2014 either set AgentOptions.memoryContext.userId or pass ctx.userId at call time.",
|
|
8857
8783
|
{ code: "memory_context_missing_user_id" }
|
|
8858
8784
|
);
|
|
@@ -8862,7 +8788,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8862
8788
|
async function requireAdapters() {
|
|
8863
8789
|
const r = await ensure();
|
|
8864
8790
|
if (r.adapters.length === 0) {
|
|
8865
|
-
throw new
|
|
8791
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
8866
8792
|
"No memory adapter registered. Pass a memory plugin in AgentOptions.plugins (e.g. supermemoryMemory({...})).",
|
|
8867
8793
|
{ code: "no_memory_adapter" }
|
|
8868
8794
|
);
|
|
@@ -8903,7 +8829,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
|
|
|
8903
8829
|
const prefix = id.split(":", 1)[0] ?? "";
|
|
8904
8830
|
const target = adapters.find((a) => a.id === prefix);
|
|
8905
8831
|
if (target === void 0) {
|
|
8906
|
-
throw new
|
|
8832
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
8907
8833
|
`No adapter found for MemoryId prefix "${prefix}" (registered: ${adapters.map((a) => a.id).join(", ")}).`,
|
|
8908
8834
|
{ code: "no_memory_adapter" }
|
|
8909
8835
|
);
|
|
@@ -8976,7 +8902,7 @@ function createLocalAgentMemoryProvider(opts) {
|
|
|
8976
8902
|
return { facts: [], systemPromptAdditions: summary };
|
|
8977
8903
|
},
|
|
8978
8904
|
async recordSessionSummary(args) {
|
|
8979
|
-
await
|
|
8905
|
+
await chunkCN6UX5EV_cjs.writeSessionSummary(args);
|
|
8980
8906
|
},
|
|
8981
8907
|
async sync(handle) {
|
|
8982
8908
|
const state = handle[INTERNAL_LAM_KEY];
|
|
@@ -9054,19 +8980,19 @@ var PersonalityRegistry = class _PersonalityRegistry {
|
|
|
9054
8980
|
function addEntity(byName, entity, origin, collisionMap) {
|
|
9055
8981
|
const fm = entity.frontmatter;
|
|
9056
8982
|
if (PersonalityRegistry.isReservedClearSlug(fm.name)) {
|
|
9057
|
-
throw new
|
|
8983
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
9058
8984
|
`Personality name "${fm.name}" is reserved (used to clear active preset)`,
|
|
9059
8985
|
{ code: "personality_reserved_name" }
|
|
9060
8986
|
);
|
|
9061
8987
|
}
|
|
9062
8988
|
if (entity.body.trim().length === 0) {
|
|
9063
|
-
throw new
|
|
8989
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
9064
8990
|
`Personality "${fm.name}" has empty body (system prompt required)`,
|
|
9065
8991
|
{ code: "personality_empty_body" }
|
|
9066
8992
|
);
|
|
9067
8993
|
}
|
|
9068
8994
|
if (origin === "project" && collisionMap?.has(fm.name)) {
|
|
9069
|
-
|
|
8995
|
+
chunk6LGQECT7_cjs.warnOnce(
|
|
9070
8996
|
`personality-collision-${fm.name}`,
|
|
9071
8997
|
`[theokit-sdk] personality "${fm.name}" overridden by project preset`
|
|
9072
8998
|
);
|
|
@@ -9095,7 +9021,7 @@ async function performPersonalitySwitch(args) {
|
|
|
9095
9021
|
const preset = args.registry.get(args.requestedName);
|
|
9096
9022
|
if (preset === void 0) {
|
|
9097
9023
|
const available = args.registry.all().map((p) => p.name).join(", ") || "(none)";
|
|
9098
|
-
throw new
|
|
9024
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
9099
9025
|
`Personality "${args.requestedName}" not found. Available: ${available}`,
|
|
9100
9026
|
{ code: "personality_not_found" }
|
|
9101
9027
|
);
|
|
@@ -9116,14 +9042,14 @@ async function performPersonalitySwitch(args) {
|
|
|
9116
9042
|
|
|
9117
9043
|
// src/internal/local-agent/local-agent-personality-extensions.ts
|
|
9118
9044
|
function resolveActivePersonalityPreset(args) {
|
|
9119
|
-
const forkCtx =
|
|
9045
|
+
const forkCtx = chunk6LGQECT7_cjs.currentPersonalityContext();
|
|
9120
9046
|
const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
|
|
9121
9047
|
if (slug === void 0) return void 0;
|
|
9122
9048
|
return args.personalityRegistry?.get(slug);
|
|
9123
9049
|
}
|
|
9124
9050
|
async function ensurePersonalityRegistryIfNeeded(args) {
|
|
9125
9051
|
if (args.personalityRegistry !== void 0) return args.personalityRegistry;
|
|
9126
|
-
const forkSlug =
|
|
9052
|
+
const forkSlug = chunk6LGQECT7_cjs.currentPersonalityContext()?.slug;
|
|
9127
9053
|
const ownSlug = args.personalityStore.active(args.agentId);
|
|
9128
9054
|
if (forkSlug === void 0 && ownSlug === void 0) return void 0;
|
|
9129
9055
|
return await PersonalityRegistry.load(args.workspaceCwd);
|
|
@@ -9137,8 +9063,8 @@ ${preset.systemPrompt}`;
|
|
|
9137
9063
|
}
|
|
9138
9064
|
async function localAgentUsePersonality(args) {
|
|
9139
9065
|
if (args.disposed) throw new Error("Agent has been disposed");
|
|
9140
|
-
if (
|
|
9141
|
-
|
|
9066
|
+
if (chunk6LGQECT7_cjs.currentPersonalityContext() !== void 0) {
|
|
9067
|
+
chunk6LGQECT7_cjs.warnPersonalitySwitchInsideFork(args.agentId);
|
|
9142
9068
|
return null;
|
|
9143
9069
|
}
|
|
9144
9070
|
let registry = args.personalityRegistry;
|
|
@@ -9155,8 +9081,8 @@ async function localAgentUsePersonality(args) {
|
|
|
9155
9081
|
registry,
|
|
9156
9082
|
store: args.personalityStore,
|
|
9157
9083
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
9158
|
-
appendSessionMessage: (msg) =>
|
|
9159
|
-
clearSession: () =>
|
|
9084
|
+
appendSessionMessage: (msg) => chunkDCXRHCZJ_cjs.appendSessionMessage(args.agentId, msg),
|
|
9085
|
+
clearSession: () => chunkDCXRHCZJ_cjs.clearSession(args.agentId),
|
|
9160
9086
|
opts: args.opts ?? {}
|
|
9161
9087
|
})
|
|
9162
9088
|
);
|
|
@@ -9167,7 +9093,7 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
9167
9093
|
async function* wrap() {
|
|
9168
9094
|
const { runUntilImpl } = await import('./run-until-L5KQD3PV.cjs');
|
|
9169
9095
|
const buildDeps = async () => {
|
|
9170
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9096
|
+
const { judgeCallImpl } = await import('./judge-call-U2D33JOW.cjs');
|
|
9171
9097
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9172
9098
|
const create = getAgentFacade().create;
|
|
9173
9099
|
return {
|
|
@@ -9200,7 +9126,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
|
|
|
9200
9126
|
async function localAgentFork(parent, options) {
|
|
9201
9127
|
const { forkAgentImpl } = await import('./fork-agent-Y2IK2RYU.cjs');
|
|
9202
9128
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9203
|
-
const { withPersonalityContext } = await import('./context-
|
|
9129
|
+
const { withPersonalityContext } = await import('./context-2FZSC6VQ.cjs');
|
|
9204
9130
|
const create = getAgentFacade().create;
|
|
9205
9131
|
return withPersonalityContext(
|
|
9206
9132
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
@@ -9260,7 +9186,7 @@ function wrapRunWithCompletionCheck(args) {
|
|
|
9260
9186
|
judgeOpts
|
|
9261
9187
|
);
|
|
9262
9188
|
const complete = !verdict.parseFailed && verdict.verdict === "done";
|
|
9263
|
-
|
|
9189
|
+
chunkN475ETD6_cjs.emitRunEvent(args.onRunEvent, {
|
|
9264
9190
|
type: "completion_check",
|
|
9265
9191
|
complete,
|
|
9266
9192
|
reason: verdict.reason
|
|
@@ -9407,7 +9333,7 @@ function wrapRunWithOutputProcessors(args) {
|
|
|
9407
9333
|
if (result.status !== "finished" || result.result === void 0) return result;
|
|
9408
9334
|
const res = await runOutputProcessors(args.processors, result.result, args.agentId);
|
|
9409
9335
|
if (res.kind === "ok") return { ...result, result: res.value };
|
|
9410
|
-
|
|
9336
|
+
chunkN475ETD6_cjs.emitRunEvent(args.onRunEvent, {
|
|
9411
9337
|
type: "tripwire",
|
|
9412
9338
|
reason: res.tripwire.reason,
|
|
9413
9339
|
processorId: res.tripwire.processorId
|
|
@@ -9482,7 +9408,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9482
9408
|
}
|
|
9483
9409
|
const res = await runInputProcessors(processors, rawUserText, inputs.agentId);
|
|
9484
9410
|
if (res.kind === "tripwire") {
|
|
9485
|
-
|
|
9411
|
+
chunkN475ETD6_cjs.emitRunEvent(options.onRunEvent, {
|
|
9486
9412
|
type: "tripwire",
|
|
9487
9413
|
reason: res.tripwire.reason,
|
|
9488
9414
|
processorId: res.tripwire.processorId
|
|
@@ -9499,7 +9425,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
|
|
|
9499
9425
|
return { userText: res.value, effectiveMessage };
|
|
9500
9426
|
}
|
|
9501
9427
|
async function executeSendLocked(inputs, message, options) {
|
|
9502
|
-
if (inputs.disposed) throw new
|
|
9428
|
+
if (inputs.disposed) throw new chunkIHFNRNTJ_cjs.AgentDisposedError(inputs.agentId);
|
|
9503
9429
|
await consumePending(inputs.agentId, inputs.invalidationPending, inputs.clearInvalidation, inputs.reload);
|
|
9504
9430
|
const sendModel = normalizeModel(options.model);
|
|
9505
9431
|
inputs.applyModelOverride(sendModel);
|
|
@@ -9510,7 +9436,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9510
9436
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9511
9437
|
await inputs.options.onBeforeSend({
|
|
9512
9438
|
conversationId: inputs.agentId,
|
|
9513
|
-
previousMessageCount:
|
|
9439
|
+
previousMessageCount: chunkDCXRHCZJ_cjs.getSessionMessages(inputs.agentId).length
|
|
9514
9440
|
});
|
|
9515
9441
|
}
|
|
9516
9442
|
await inputs.runPreHook(userText);
|
|
@@ -9522,8 +9448,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9522
9448
|
userText,
|
|
9523
9449
|
sendOptions: options
|
|
9524
9450
|
});
|
|
9525
|
-
const priorMessages = [...
|
|
9526
|
-
|
|
9451
|
+
const priorMessages = [...chunkDCXRHCZJ_cjs.getSessionMessages(inputs.agentId)];
|
|
9452
|
+
chunkDCXRHCZJ_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9527
9453
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9528
9454
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
|
|
9529
9455
|
const portPathActive = shouldUsePortMemoryPath();
|
|
@@ -9581,7 +9507,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9581
9507
|
function buildCompletionCheckDeps() {
|
|
9582
9508
|
return {
|
|
9583
9509
|
judge: async (ctx, opts) => {
|
|
9584
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9510
|
+
const { judgeCallImpl } = await import('./judge-call-U2D33JOW.cjs');
|
|
9585
9511
|
const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
|
|
9586
9512
|
return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
|
|
9587
9513
|
}
|
|
@@ -9601,7 +9527,7 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
|
|
|
9601
9527
|
promptPreview: userText.slice(0, 120),
|
|
9602
9528
|
...opts.meta ?? {}
|
|
9603
9529
|
};
|
|
9604
|
-
void
|
|
9530
|
+
void chunkN475ETD6_cjs.submit({
|
|
9605
9531
|
kind: "run",
|
|
9606
9532
|
work: async (ctx) => {
|
|
9607
9533
|
ctx.signal.addEventListener(
|
|
@@ -9685,7 +9611,7 @@ var LocalAgent = class {
|
|
|
9685
9611
|
this.options = options;
|
|
9686
9612
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
9687
9613
|
this.transcriptBaseDir = resolveBaseDir(options.local?.baseDir);
|
|
9688
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
9614
|
+
this.sessionStore = options.local?.sessionStore ?? new chunk74D7KSBP_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
9689
9615
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
9690
9616
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
9691
9617
|
const sub = bootstrapSubmanagers({
|
|
@@ -9728,14 +9654,14 @@ var LocalAgent = class {
|
|
|
9728
9654
|
if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
|
|
9729
9655
|
const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
|
|
9730
9656
|
await this.pluginManagerCode.initialize(codePlugins);
|
|
9731
|
-
this.resolvedSubagents = await
|
|
9657
|
+
this.resolvedSubagents = await chunkW4WKVOOQ_cjs.loadSubagents(
|
|
9732
9658
|
this.workspaceCwd,
|
|
9733
9659
|
this.settingSourcesIncludeProject,
|
|
9734
9660
|
this.options.agents
|
|
9735
9661
|
);
|
|
9736
9662
|
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9737
9663
|
try {
|
|
9738
|
-
await
|
|
9664
|
+
await chunkDCXRHCZJ_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9739
9665
|
await this.personalityStore.hydrate(this.agentId);
|
|
9740
9666
|
} catch (err) {
|
|
9741
9667
|
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
@@ -9884,7 +9810,7 @@ var LocalAgent = class {
|
|
|
9884
9810
|
agentId: this.agentId
|
|
9885
9811
|
});
|
|
9886
9812
|
if (preRun.blocked) {
|
|
9887
|
-
throw new
|
|
9813
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
9888
9814
|
`preRun hook denied execution: ${preRun.reason ?? "unspecified"}`,
|
|
9889
9815
|
{ code: "hook_denied" }
|
|
9890
9816
|
);
|
|
@@ -9965,7 +9891,7 @@ var LocalAgent = class {
|
|
|
9965
9891
|
}
|
|
9966
9892
|
// biome-ignore format: G8 budget — see listArtifacts.
|
|
9967
9893
|
downloadArtifact(_path) {
|
|
9968
|
-
return Promise.reject(new
|
|
9894
|
+
return Promise.reject(new chunkIHFNRNTJ_cjs.UnsupportedRunOperationError("Artifacts are not supported for local agents", "downloadArtifact"));
|
|
9969
9895
|
}
|
|
9970
9896
|
// biome-ignore format: G8 budget — delegates to `local-agent-runtime-extensions.ts`; kept 1-line.
|
|
9971
9897
|
runUntil(goal, options) {
|
|
@@ -9988,7 +9914,7 @@ function resolveCwd(cwd) {
|
|
|
9988
9914
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|
|
9989
9915
|
}
|
|
9990
9916
|
function resolveBaseDir(baseDir) {
|
|
9991
|
-
return baseDir === void 0 ?
|
|
9917
|
+
return baseDir === void 0 ? chunkZ2CUEBXV_cjs.defaultBaseDir() : chunkZ2CUEBXV_cjs.expandTilde(baseDir);
|
|
9992
9918
|
}
|
|
9993
9919
|
function includesSetting(options, source) {
|
|
9994
9920
|
const sources = options.local?.settingSources;
|
|
@@ -10013,7 +9939,7 @@ async function guardAgainstIdCollision(options) {
|
|
|
10013
9939
|
const persistenceCwd = resolveAgentPersistenceCwd(options);
|
|
10014
9940
|
await hydrateRegistryFromDisk(persistenceCwd);
|
|
10015
9941
|
if (getRegisteredAgent(options.agentId) !== void 0) {
|
|
10016
|
-
throw new
|
|
9942
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
10017
9943
|
`Agent "${options.agentId}" already exists. Use Agent.resume("${options.agentId}") to reattach, or pick a different agentId.`,
|
|
10018
9944
|
{ code: "agent_id_already_exists" }
|
|
10019
9945
|
);
|
|
@@ -10046,7 +9972,7 @@ async function maybeInjectHandoffTools(options) {
|
|
|
10046
9972
|
const spec = "@theokit/sdk-handoff/internal/tool-injector";
|
|
10047
9973
|
mod = await import(spec);
|
|
10048
9974
|
} catch (err) {
|
|
10049
|
-
throw new
|
|
9975
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
10050
9976
|
"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).",
|
|
10051
9977
|
{ code: "handoff_package_missing", cause: err }
|
|
10052
9978
|
);
|
|
@@ -10066,9 +9992,9 @@ async function maybeInjectHandoffTools(options) {
|
|
|
10066
9992
|
async function createLocalAgent(options) {
|
|
10067
9993
|
const apiKey = resolveApiKey(options.apiKey);
|
|
10068
9994
|
if (apiKey === void 0) {
|
|
10069
|
-
throw new
|
|
9995
|
+
throw new chunkIHFNRNTJ_cjs.AuthenticationError("Missing API key", { code: "missing_api_key" });
|
|
10070
9996
|
}
|
|
10071
|
-
const willFlowToProvider = !
|
|
9997
|
+
const willFlowToProvider = !chunkBPN5ONSW_cjs.isFixtureApiKey(apiKey) && !chunkBPN5ONSW_cjs.shouldUseRealLocalRuntime(apiKey);
|
|
10072
9998
|
const shape = validateApiKeyShape(apiKey, {
|
|
10073
9999
|
strict: willFlowToProvider,
|
|
10074
10000
|
// `options.model` is already normalized by `runCreateUnderSpan`; `normalizeModel`
|
|
@@ -10077,10 +10003,10 @@ async function createLocalAgent(options) {
|
|
|
10077
10003
|
...willFlowToProvider ? { provider: providerFromModelId(normalizeModel(options.model)?.id) } : {}
|
|
10078
10004
|
});
|
|
10079
10005
|
if (shape.malformed) {
|
|
10080
|
-
throw new
|
|
10006
|
+
throw new chunkIHFNRNTJ_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10081
10007
|
}
|
|
10082
|
-
if (!
|
|
10083
|
-
throw new
|
|
10008
|
+
if (!chunkBPN5ONSW_cjs.isFixtureApiKey(apiKey) && chunkBPN5ONSW_cjs.getConfiguredBaseUrl() === void 0 && !chunkBPN5ONSW_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
10009
|
+
throw new chunkIHFNRNTJ_cjs.AuthenticationError("Invalid API key", {
|
|
10084
10010
|
code: "authentication_error"
|
|
10085
10011
|
});
|
|
10086
10012
|
}
|
|
@@ -10091,19 +10017,19 @@ async function createLocalAgent(options) {
|
|
|
10091
10017
|
async function createCloudAgent(options) {
|
|
10092
10018
|
const apiKey = resolveApiKey(options.apiKey);
|
|
10093
10019
|
if (apiKey === void 0) {
|
|
10094
|
-
throw new
|
|
10020
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError("Missing API key for cloud agent", {
|
|
10095
10021
|
code: "missing_api_key"
|
|
10096
10022
|
});
|
|
10097
10023
|
}
|
|
10098
10024
|
const shape = validateApiKeyShape(apiKey);
|
|
10099
10025
|
if (shape.malformed) {
|
|
10100
|
-
throw new
|
|
10026
|
+
throw new chunkIHFNRNTJ_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10101
10027
|
}
|
|
10102
|
-
const baseUrl =
|
|
10028
|
+
const baseUrl = chunkBPN5ONSW_cjs.getConfiguredBaseUrl();
|
|
10103
10029
|
if (baseUrl === void 0) {
|
|
10104
10030
|
return new CloudAgent(options);
|
|
10105
10031
|
}
|
|
10106
|
-
const response = await
|
|
10032
|
+
const response = await chunkBPN5ONSW_cjs.httpRequest("/v1/agents", {
|
|
10107
10033
|
apiKey,
|
|
10108
10034
|
method: "POST",
|
|
10109
10035
|
body: {
|
|
@@ -10128,7 +10054,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
10128
10054
|
return process.cwd();
|
|
10129
10055
|
}
|
|
10130
10056
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
10131
|
-
await
|
|
10057
|
+
await chunkBPN5ONSW_cjs.discoverProviderPlugins();
|
|
10132
10058
|
await validateRehydratedAgent(agentId, existing);
|
|
10133
10059
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
10134
10060
|
const mergedOptions = {
|
|
@@ -10159,7 +10085,7 @@ async function validateRehydratedAgent(agentId, entry) {
|
|
|
10159
10085
|
throw new Error(`Workspace path is not a directory: ${candidate}`);
|
|
10160
10086
|
}
|
|
10161
10087
|
} catch (cause) {
|
|
10162
|
-
throw new
|
|
10088
|
+
throw new chunkIHFNRNTJ_cjs.UnknownAgentError(
|
|
10163
10089
|
`Agent "${agentId}" cannot be rehydrated \u2014 workspace cwd "${candidate}" is missing or inaccessible.`,
|
|
10164
10090
|
{ code: "agent_rehydration_failed", cause }
|
|
10165
10091
|
);
|
|
@@ -10211,7 +10137,7 @@ async function getRegisteredAgentOrThrow(agentId) {
|
|
|
10211
10137
|
agent = getRegisteredAgent(agentId);
|
|
10212
10138
|
}
|
|
10213
10139
|
if (agent === void 0) {
|
|
10214
|
-
throw new
|
|
10140
|
+
throw new chunkIHFNRNTJ_cjs.UnknownAgentError(`Agent ${agentId} not found`, { code: "unknown_agent" });
|
|
10215
10141
|
}
|
|
10216
10142
|
return agent;
|
|
10217
10143
|
}
|
|
@@ -10256,7 +10182,7 @@ var Agent = class _Agent {
|
|
|
10256
10182
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
10257
10183
|
});
|
|
10258
10184
|
try {
|
|
10259
|
-
await
|
|
10185
|
+
await chunkBPN5ONSW_cjs.discoverProviderPlugins();
|
|
10260
10186
|
const agent = await runCreateUnderSpan(options, span);
|
|
10261
10187
|
return agent;
|
|
10262
10188
|
} catch (err) {
|
|
@@ -10282,8 +10208,8 @@ var Agent = class _Agent {
|
|
|
10282
10208
|
const run = await agent.send(message);
|
|
10283
10209
|
const result = await run.wait();
|
|
10284
10210
|
if (options.throwOnError === true && result.status === "error" && result.error !== void 0) {
|
|
10285
|
-
throw new
|
|
10286
|
-
code:
|
|
10211
|
+
throw new chunkIHFNRNTJ_cjs.AgentRunError(result.error.message, {
|
|
10212
|
+
code: chunkIHFNRNTJ_cjs.coerceToKnownAgentRunErrorCode(result.error.code),
|
|
10287
10213
|
cause: result.error.cause
|
|
10288
10214
|
});
|
|
10289
10215
|
}
|
|
@@ -10310,7 +10236,7 @@ var Agent = class _Agent {
|
|
|
10310
10236
|
if (existing !== void 0) {
|
|
10311
10237
|
return await rehydrateExistingAgent(agentId, existing, options);
|
|
10312
10238
|
}
|
|
10313
|
-
throw new
|
|
10239
|
+
throw new chunkIHFNRNTJ_cjs.UnknownAgentError(
|
|
10314
10240
|
`Agent "${agentId}" not found. Use Agent.create({ agentId, ... }) for first-time setup, or catch UnknownAgentError to branch resume-vs-create.`,
|
|
10315
10241
|
{ code: "unknown_agent" }
|
|
10316
10242
|
);
|
|
@@ -10339,7 +10265,7 @@ var Agent = class _Agent {
|
|
|
10339
10265
|
* @public
|
|
10340
10266
|
*/
|
|
10341
10267
|
static async generateObject(options) {
|
|
10342
|
-
const { generateObjectImpl } = await import('./generate-object-
|
|
10268
|
+
const { generateObjectImpl } = await import('./generate-object-UF6WIZLF.cjs');
|
|
10343
10269
|
return generateObjectImpl(options, {
|
|
10344
10270
|
create: (opts) => _Agent.create(opts),
|
|
10345
10271
|
delete: (agentId) => _Agent.delete(agentId)
|
|
@@ -10363,7 +10289,7 @@ var Agent = class _Agent {
|
|
|
10363
10289
|
delete: (agentId) => _Agent.delete(agentId)
|
|
10364
10290
|
};
|
|
10365
10291
|
async function* wrapper() {
|
|
10366
|
-
streamObjectImport ??= import('./stream-object-
|
|
10292
|
+
streamObjectImport ??= import('./stream-object-4FDU76YW.cjs');
|
|
10367
10293
|
const { streamObjectImpl } = await streamObjectImport;
|
|
10368
10294
|
yield* streamObjectImpl(options, deps);
|
|
10369
10295
|
}
|
|
@@ -10387,7 +10313,7 @@ var Agent = class _Agent {
|
|
|
10387
10313
|
* @public
|
|
10388
10314
|
*/
|
|
10389
10315
|
static async batch(prompts, options) {
|
|
10390
|
-
const { batchImpl } = await import('./batch-
|
|
10316
|
+
const { batchImpl } = await import('./batch-X6JKGDPK.cjs');
|
|
10391
10317
|
return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
|
|
10392
10318
|
}
|
|
10393
10319
|
/**
|
|
@@ -10467,14 +10393,14 @@ var Agent = class _Agent {
|
|
|
10467
10393
|
*/
|
|
10468
10394
|
static async getRun(runId, options = {}) {
|
|
10469
10395
|
if (options.runtime === "cloud") {
|
|
10470
|
-
throw new
|
|
10396
|
+
throw new chunkIHFNRNTJ_cjs.ConfigurationError(
|
|
10471
10397
|
"Cloud runtime is pre-release. Theo PaaS endpoints are not wired yet \u2014 getRun({ runtime: 'cloud' }) will be enabled when the PaaS ships.",
|
|
10472
10398
|
{ code: "cloud_runtime_pre_release" }
|
|
10473
10399
|
);
|
|
10474
10400
|
}
|
|
10475
10401
|
const existing = getRun(runId);
|
|
10476
10402
|
if (existing !== void 0) return existing;
|
|
10477
|
-
throw new
|
|
10403
|
+
throw new chunkIHFNRNTJ_cjs.UnknownAgentError(
|
|
10478
10404
|
`Run ${runId} is not in this process's registry. It may have been disposed, persisted in a previous process, or never created.`,
|
|
10479
10405
|
{ code: "run_not_found" }
|
|
10480
10406
|
);
|
|
@@ -10521,13 +10447,13 @@ var Agent = class _Agent {
|
|
|
10521
10447
|
reg = getRegisteredAgent(agentId);
|
|
10522
10448
|
}
|
|
10523
10449
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10524
|
-
throw new
|
|
10450
|
+
throw new chunkIHFNRNTJ_cjs.UnknownAgentError(
|
|
10525
10451
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10526
10452
|
);
|
|
10527
10453
|
}
|
|
10528
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10454
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-VVT6IBJG.cjs');
|
|
10529
10455
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10530
|
-
return
|
|
10456
|
+
return chunkDCXRHCZJ_cjs.enqueueSessionWrite(
|
|
10531
10457
|
cwd,
|
|
10532
10458
|
agentId,
|
|
10533
10459
|
() => compactSessionTranscript({
|
|
@@ -10557,11 +10483,11 @@ var Agent = class _Agent {
|
|
|
10557
10483
|
reg = getRegisteredAgent(agentId);
|
|
10558
10484
|
}
|
|
10559
10485
|
if (reg === void 0 || reg.runtime !== "local") {
|
|
10560
|
-
throw new
|
|
10486
|
+
throw new chunkIHFNRNTJ_cjs.UnknownAgentError(
|
|
10561
10487
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10562
10488
|
);
|
|
10563
10489
|
}
|
|
10564
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10490
|
+
const { injectSessionTurn } = await import('./inject-session-LFCYVSLJ.cjs');
|
|
10565
10491
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10566
10492
|
await injectSessionTurn({
|
|
10567
10493
|
store,
|
|
@@ -10571,6 +10497,86 @@ var Agent = class _Agent {
|
|
|
10571
10497
|
assistantText: turn.assistantText
|
|
10572
10498
|
});
|
|
10573
10499
|
}
|
|
10500
|
+
/**
|
|
10501
|
+
* theokit#146 — read a LOCAL agent's persisted transcript as STRUCTURE, for rendering.
|
|
10502
|
+
*
|
|
10503
|
+
* A resumed session already replays correctly to the model, but a host had no way to draw it:
|
|
10504
|
+
* the only projection available folded a tool call to the string `[tool call] NAME`, dropping the
|
|
10505
|
+
* call id and every argument. A card UI got prose, so cross-restart resume was worth less than
|
|
10506
|
+
* starting fresh — which is what at least one consumer did.
|
|
10507
|
+
*
|
|
10508
|
+
* Each returned message carries both projections: `text` (unchanged, what the model replay uses)
|
|
10509
|
+
* and `parts` (`text` / `tool_use` / `tool_result` with ids, names, arguments and the
|
|
10510
|
+
* `toolUseId` that correlates a result back to its call).
|
|
10511
|
+
*
|
|
10512
|
+
* Read-only and local-only: it opens the agent's session store and walks the transcript, exactly
|
|
10513
|
+
* as {@link Agent.compact} and {@link Agent.injectSessionTurn} do. It appends nothing.
|
|
10514
|
+
*
|
|
10515
|
+
* @throws UnknownAgentError when `agentId` names no local agent.
|
|
10516
|
+
* @public
|
|
10517
|
+
*/
|
|
10518
|
+
static async transcript(agentId) {
|
|
10519
|
+
let reg = getRegisteredAgent(agentId);
|
|
10520
|
+
if (reg === void 0) {
|
|
10521
|
+
await hydrateRegistryFromDisk(process.cwd());
|
|
10522
|
+
reg = getRegisteredAgent(agentId);
|
|
10523
|
+
}
|
|
10524
|
+
if (reg === void 0 || reg.runtime !== "local") {
|
|
10525
|
+
throw new chunkIHFNRNTJ_cjs.UnknownAgentError(
|
|
10526
|
+
`No local agent "${agentId}" registered \u2014 transcript targets local sessions.`
|
|
10527
|
+
);
|
|
10528
|
+
}
|
|
10529
|
+
const { readSessionMessages } = await import('./agent-session-store-N4TVKHBU.cjs');
|
|
10530
|
+
const { store } = await openLocalStore(reg);
|
|
10531
|
+
return readSessionMessages(store, agentId);
|
|
10532
|
+
}
|
|
10533
|
+
/**
|
|
10534
|
+
* theokit#123 — read-only introspection of a registered agent's tools and subagents.
|
|
10535
|
+
*
|
|
10536
|
+
* `Agent.list()` / `Agent.get()` enumerate agents and `agent.skills.list()` covers skills, but
|
|
10537
|
+
* tools and subagents lived only on `RegisteredAgent.options` — an internal contract. A
|
|
10538
|
+
* reflection endpoint (theokit-studio's `theokit dev`) therefore had to report empty lists for
|
|
10539
|
+
* both, and say so with an `unavailable_reason`.
|
|
10540
|
+
*
|
|
10541
|
+
* A PROJECTION, not the options object. Tool handlers and subagent prompts are stripped: a
|
|
10542
|
+
* handler is an executable that cannot cross a process boundary, and a prompt is the agent's
|
|
10543
|
+
* instructions rather than its signature — a reflection endpoint serializes what it is handed.
|
|
10544
|
+
*
|
|
10545
|
+
* @throws UnknownAgentError when `agentId` names no registered agent.
|
|
10546
|
+
* @public
|
|
10547
|
+
*/
|
|
10548
|
+
static async describe(agentId) {
|
|
10549
|
+
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10550
|
+
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-A4W6C3QP.cjs');
|
|
10551
|
+
const settingSources = agent.options.local?.settingSources;
|
|
10552
|
+
const subagents = await loadSubagents2(
|
|
10553
|
+
agent.cwd ?? process.cwd(),
|
|
10554
|
+
settingSources === void 0 || settingSources.includes("project"),
|
|
10555
|
+
agent.options.agents
|
|
10556
|
+
);
|
|
10557
|
+
return {
|
|
10558
|
+
agentId: agent.agentId,
|
|
10559
|
+
runtime: agent.runtime,
|
|
10560
|
+
...agent.model !== void 0 ? { model: agent.model } : {},
|
|
10561
|
+
// Always arrays, so a caller can tell "this agent has none" from "the SDK did not say".
|
|
10562
|
+
//
|
|
10563
|
+
// Honest limit, stated because the alternative is an implied claim: `tools` is still the
|
|
10564
|
+
// DECLARED catalog. Plugin tools and the reasoning `think` tool are assembled per run by
|
|
10565
|
+
// `buildCustomToolsInput`, so they are not knowable from the registry alone. Documented on
|
|
10566
|
+
// `AgentDescription.tools`.
|
|
10567
|
+
tools: (agent.options.tools ?? []).map((tool) => ({
|
|
10568
|
+
name: tool.name,
|
|
10569
|
+
description: tool.description,
|
|
10570
|
+
inputSchema: tool.inputSchema
|
|
10571
|
+
})),
|
|
10572
|
+
subagents: Object.entries(subagents).map(([name, def]) => ({
|
|
10573
|
+
name,
|
|
10574
|
+
description: def.description,
|
|
10575
|
+
...def.model !== void 0 ? { model: def.model } : {},
|
|
10576
|
+
...def.tools !== void 0 ? { tools: def.tools } : {}
|
|
10577
|
+
}))
|
|
10578
|
+
};
|
|
10579
|
+
}
|
|
10574
10580
|
/**
|
|
10575
10581
|
* Permanently delete a cloud agent.
|
|
10576
10582
|
*
|
|
@@ -10585,12 +10591,12 @@ async function getOrCreateUncached(agentId, options) {
|
|
|
10585
10591
|
try {
|
|
10586
10592
|
return await Agent.resume(agentId, options);
|
|
10587
10593
|
} catch (err) {
|
|
10588
|
-
if (!(err instanceof
|
|
10594
|
+
if (!(err instanceof chunkIHFNRNTJ_cjs.UnknownAgentError)) throw err;
|
|
10589
10595
|
}
|
|
10590
10596
|
try {
|
|
10591
10597
|
return await Agent.create({ ...options, agentId });
|
|
10592
10598
|
} catch (err) {
|
|
10593
|
-
if (err instanceof
|
|
10599
|
+
if (err instanceof chunkIHFNRNTJ_cjs.ConfigurationError && err.code === "agent_id_already_exists") {
|
|
10594
10600
|
return await Agent.resume(agentId, options);
|
|
10595
10601
|
}
|
|
10596
10602
|
throw err;
|
|
@@ -10608,8 +10614,8 @@ async function openLocalStore(reg) {
|
|
|
10608
10614
|
const cwd = reg.cwd ?? process.cwd();
|
|
10609
10615
|
const optModel = reg.options.model;
|
|
10610
10616
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
10611
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
10612
|
-
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-
|
|
10617
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-J5MCFFUM.cjs');
|
|
10618
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-H7NUFXXM.cjs');
|
|
10613
10619
|
const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
|
|
10614
10620
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
10615
10621
|
}
|
|
@@ -10626,5 +10632,5 @@ exports.generateCronId = generateCronId;
|
|
|
10626
10632
|
exports.getPricingEntry = getPricingEntry;
|
|
10627
10633
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10628
10634
|
exports.resolveApiKey = resolveApiKey;
|
|
10629
|
-
//# sourceMappingURL=chunk-
|
|
10630
|
-
//# sourceMappingURL=chunk-
|
|
10635
|
+
//# sourceMappingURL=chunk-INSFS5GT.cjs.map
|
|
10636
|
+
//# sourceMappingURL=chunk-INSFS5GT.cjs.map
|