@theokit/sdk 4.37.2 → 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 +309 -72
- 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-SmxntivO.d.ts → agent-D7bRK9Kg.d.cts} +108 -41
- package/dist/agent-I3EZZR6S.cjs +55 -0
- package/dist/{agent-IE6IE4NW.cjs.map → agent-I3EZZR6S.cjs.map} +1 -1
- package/dist/agent-KKZYLY5D.js +46 -0
- package/dist/{agent-DW2J37IH.js.map → agent-KKZYLY5D.js.map} +1 -1
- package/dist/{agent-DGv1-d81.d.cts → agent-ZCZa7YQv.d.ts} +108 -41
- 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 +38 -2
- package/dist/auth/index.cjs +15 -15
- package/dist/auth/index.js +4 -4
- package/dist/{batch-SY5GZLFD.js → batch-6KQM3EBA.js} +12 -12
- package/dist/batch-6KQM3EBA.js.map +1 -0
- package/dist/{batch-3SEPDXCU.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-2WFB5ZOX.js → chunk-42IFCKQZ.js} +5 -5
- package/dist/{chunk-2WFB5ZOX.js.map → chunk-42IFCKQZ.js.map} +1 -1
- package/dist/{chunk-DCJ5MCJ3.js → chunk-4F7JQZOX.js} +9 -36
- package/dist/chunk-4F7JQZOX.js.map +1 -0
- package/dist/{chunk-JNIWFCKI.js → chunk-4JSZYSGW.js} +3 -3
- package/dist/{chunk-JNIWFCKI.js.map → chunk-4JSZYSGW.js.map} +1 -1
- package/dist/{chunk-EEZ7CFMM.js → chunk-5KOW3GLE.js} +2 -2
- package/dist/chunk-5KOW3GLE.js.map +1 -0
- package/dist/{chunk-6VP3XGEK.js → chunk-65ONFZWM.js} +12 -11
- package/dist/chunk-65ONFZWM.js.map +1 -0
- package/dist/{chunk-CSZRJ4RE.js → chunk-6EEYRFJC.js} +5 -5
- package/dist/{chunk-CSZRJ4RE.js.map → chunk-6EEYRFJC.js.map} +1 -1
- package/dist/{chunk-FAY3QDGC.cjs → chunk-6LGQECT7.cjs} +11 -11
- package/dist/{chunk-FAY3QDGC.cjs.map → chunk-6LGQECT7.cjs.map} +1 -1
- package/dist/{chunk-PAEJPLVN.cjs → chunk-6NEHIHFU.cjs} +4 -4
- package/dist/{chunk-PAEJPLVN.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-74D7KSBP.cjs +112 -0
- package/dist/chunk-74D7KSBP.cjs.map +1 -0
- package/dist/{chunk-FK4EJD2I.cjs → chunk-75DSEWTJ.cjs} +7 -7
- package/dist/{chunk-FK4EJD2I.cjs.map → chunk-75DSEWTJ.cjs.map} +1 -1
- package/dist/{chunk-SWIBQFPH.cjs → chunk-7OLG7VI4.cjs} +4 -4
- package/dist/{chunk-SWIBQFPH.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-YBFDBOUN.cjs → chunk-7YBJZS5P.cjs} +8 -8
- package/dist/{chunk-YBFDBOUN.cjs.map → chunk-7YBJZS5P.cjs.map} +1 -1
- package/dist/{chunk-GLUWH6JO.js → chunk-AECV3G5Z.js} +4 -4
- package/dist/{chunk-GLUWH6JO.js.map → chunk-AECV3G5Z.js.map} +1 -1
- package/dist/{chunk-UQPDFW4E.js → chunk-AR5MQZ3J.js} +3 -3
- package/dist/{chunk-UQPDFW4E.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-LTCOPATU.cjs → chunk-BCQ3E2ZG.cjs} +12 -3
- package/dist/chunk-BCQ3E2ZG.cjs.map +1 -0
- package/dist/{chunk-ALU3KC4G.cjs → chunk-BPN5ONSW.cjs} +223 -277
- package/dist/chunk-BPN5ONSW.cjs.map +1 -0
- package/dist/{chunk-YHZXBDAW.js → chunk-BQDUEG4C.js} +16 -16
- package/dist/{chunk-YHZXBDAW.js.map → chunk-BQDUEG4C.js.map} +1 -1
- package/dist/{chunk-IT3PWBW4.cjs → chunk-BURYFNOM.cjs} +2 -2
- package/dist/chunk-BURYFNOM.cjs.map +1 -0
- package/dist/{chunk-BJMKQOY2.cjs → chunk-C7OP3FAK.cjs} +47 -11
- package/dist/chunk-C7OP3FAK.cjs.map +1 -0
- package/dist/{chunk-XAYVHS2B.cjs → chunk-CEIHCKTO.cjs} +4 -4
- package/dist/chunk-CEIHCKTO.cjs.map +1 -0
- package/dist/{chunk-2423XDPT.cjs → chunk-CN6UX5EV.cjs} +28 -56
- package/dist/chunk-CN6UX5EV.cjs.map +1 -0
- package/dist/{chunk-VNNK6AKU.js → chunk-D7IULBF2.js} +3 -3
- package/dist/chunk-D7IULBF2.js.map +1 -0
- package/dist/chunk-DCXRHCZJ.cjs +118 -0
- package/dist/chunk-DCXRHCZJ.cjs.map +1 -0
- package/dist/{chunk-ICYBIC6N.cjs → chunk-DGLLVCNB.cjs} +4 -4
- package/dist/chunk-DGLLVCNB.cjs.map +1 -0
- package/dist/{chunk-I35DI7ES.js → chunk-DKFGUOWL.js} +3 -3
- package/dist/{chunk-I35DI7ES.js.map → chunk-DKFGUOWL.js.map} +1 -1
- package/dist/{chunk-TQI3KRXZ.cjs → chunk-DMTZ3FII.cjs} +18 -18
- package/dist/{chunk-TQI3KRXZ.cjs.map → chunk-DMTZ3FII.cjs.map} +1 -1
- package/dist/{chunk-QFMXXUUT.js → chunk-DU7DE543.js} +3 -3
- package/dist/{chunk-QFMXXUUT.js.map → chunk-DU7DE543.js.map} +1 -1
- package/dist/{chunk-W4QN5CMG.cjs → chunk-DWY25VLP.cjs} +9 -9
- package/dist/{chunk-W4QN5CMG.cjs.map → chunk-DWY25VLP.cjs.map} +1 -1
- package/dist/chunk-E2FFG33C.js +109 -0
- package/dist/chunk-E2FFG33C.js.map +1 -0
- package/dist/{chunk-QUFSDDNU.cjs → chunk-E4IUN3JB.cjs} +15 -15
- package/dist/{chunk-QUFSDDNU.cjs.map → chunk-E4IUN3JB.cjs.map} +1 -1
- package/dist/{chunk-THEYGCYS.cjs → chunk-ECHGWE47.cjs} +4 -4
- package/dist/chunk-ECHGWE47.cjs.map +1 -0
- package/dist/{chunk-U2WLFOA3.cjs → chunk-ECW2MLEW.cjs} +4 -4
- package/dist/{chunk-U2WLFOA3.cjs.map → chunk-ECW2MLEW.cjs.map} +1 -1
- package/dist/{chunk-MXSMAGDU.js → chunk-ET6PHZRX.js} +33 -26
- package/dist/chunk-ET6PHZRX.js.map +1 -0
- package/dist/{chunk-G6AASL5T.cjs → chunk-FRUBE44B.cjs} +24 -24
- package/dist/{chunk-G6AASL5T.cjs.map → chunk-FRUBE44B.cjs.map} +1 -1
- package/dist/{chunk-3ILFUXNE.cjs → chunk-FWBSDQZ7.cjs} +5 -5
- package/dist/{chunk-3ILFUXNE.cjs.map → chunk-FWBSDQZ7.cjs.map} +1 -1
- package/dist/{chunk-7DXLNNKH.cjs → chunk-G2Q3ZC6C.cjs} +4 -4
- package/dist/{chunk-7DXLNNKH.cjs.map → chunk-G2Q3ZC6C.cjs.map} +1 -1
- package/dist/{chunk-56ZM6P7Z.cjs → chunk-G4XUXSRN.cjs} +12 -12
- package/dist/chunk-G4XUXSRN.cjs.map +1 -0
- package/dist/{chunk-VYJSHGAY.js → chunk-GIRD3RWH.js} +422 -295
- package/dist/chunk-GIRD3RWH.js.map +1 -0
- package/dist/{chunk-NQ4AC2U4.cjs → chunk-HIQFVHC6.cjs} +9 -9
- package/dist/{chunk-NQ4AC2U4.cjs.map → chunk-HIQFVHC6.cjs.map} +1 -1
- package/dist/{chunk-EXQV452X.js → chunk-HWNVAUK4.js} +3 -3
- package/dist/{chunk-EXQV452X.js.map → chunk-HWNVAUK4.js.map} +1 -1
- package/dist/{chunk-P34DHHYQ.cjs → chunk-I53ZQHU6.cjs} +34 -27
- package/dist/chunk-I53ZQHU6.cjs.map +1 -0
- package/dist/{chunk-MHCKWQR3.cjs → chunk-IHFNRNTJ.cjs} +8 -8
- package/dist/{chunk-MHCKWQR3.cjs.map → chunk-IHFNRNTJ.cjs.map} +1 -1
- package/dist/{chunk-W52DKZBR.cjs → chunk-INSFS5GT.cjs} +680 -553
- package/dist/chunk-INSFS5GT.cjs.map +1 -0
- package/dist/{chunk-TAPQWDW2.js → chunk-IVSD7L22.js} +12 -4
- package/dist/chunk-IVSD7L22.js.map +1 -0
- package/dist/{chunk-WDGCZDRG.js → chunk-J3UK2GMN.js} +3 -3
- package/dist/{chunk-WDGCZDRG.js.map → chunk-J3UK2GMN.js.map} +1 -1
- package/dist/{chunk-4YB7B3RP.cjs → chunk-J6T5LWJ4.cjs} +15 -14
- package/dist/chunk-J6T5LWJ4.cjs.map +1 -0
- package/dist/{chunk-XAEAMI5H.js → chunk-JRLXEYR4.js} +21 -5
- package/dist/chunk-JRLXEYR4.js.map +1 -0
- package/dist/{chunk-ZJN6NTHE.js → chunk-JZUPMTJY.js} +3 -3
- package/dist/{chunk-ZJN6NTHE.js.map → chunk-JZUPMTJY.js.map} +1 -1
- package/dist/{chunk-M5ZQBOIZ.js → chunk-KE6XKRLQ.js} +3 -3
- package/dist/{chunk-M5ZQBOIZ.js.map → chunk-KE6XKRLQ.js.map} +1 -1
- package/dist/chunk-KGRIHEDT.js +110 -0
- package/dist/chunk-KGRIHEDT.js.map +1 -0
- package/dist/{chunk-T4QWDOG6.js → chunk-KWUNN5J2.js} +5 -5
- package/dist/{chunk-T4QWDOG6.js.map → chunk-KWUNN5J2.js.map} +1 -1
- package/dist/{chunk-56OXYUZE.js → chunk-KX7JV5KM.js} +3 -3
- package/dist/chunk-KX7JV5KM.js.map +1 -0
- package/dist/{chunk-D4ZUJTFB.cjs → chunk-LALG2K33.cjs} +8 -8
- package/dist/{chunk-D4ZUJTFB.cjs.map → chunk-LALG2K33.cjs.map} +1 -1
- package/dist/{chunk-QGDKZDPN.js → chunk-LGILIGV3.js} +3 -3
- package/dist/{chunk-QGDKZDPN.js.map → chunk-LGILIGV3.js.map} +1 -1
- package/dist/{chunk-HEN5WXXI.js → chunk-LJX2SQV2.js} +6 -6
- package/dist/{chunk-HEN5WXXI.js.map → chunk-LJX2SQV2.js.map} +1 -1
- package/dist/{chunk-SDIBMLL5.js → chunk-MC5EINBV.js} +44 -8
- package/dist/chunk-MC5EINBV.js.map +1 -0
- package/dist/{chunk-F6Y4IEQM.js → chunk-ML5A5DOJ.js} +4 -4
- package/dist/{chunk-F6Y4IEQM.js.map → chunk-ML5A5DOJ.js.map} +1 -1
- package/dist/{chunk-6EDQBX7U.cjs → chunk-N475ETD6.cjs} +17 -17
- package/dist/{chunk-6EDQBX7U.cjs.map → chunk-N475ETD6.cjs.map} +1 -1
- package/dist/{chunk-YPQF26X7.cjs → chunk-OBA6YK2R.cjs} +2 -2
- package/dist/chunk-OBA6YK2R.cjs.map +1 -0
- package/dist/chunk-OXNYIMZZ.js +31 -0
- package/dist/chunk-OXNYIMZZ.js.map +1 -0
- package/dist/{chunk-NFCKEBHI.js → chunk-PI4RO4GR.js} +3 -3
- package/dist/{chunk-NFCKEBHI.js.map → chunk-PI4RO4GR.js.map} +1 -1
- package/dist/{chunk-2ONFGMBV.js → chunk-PY2RQOA7.js} +2 -2
- package/dist/chunk-PY2RQOA7.js.map +1 -0
- 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-CD73YHEH.js → chunk-SG5ZWT6C.js} +3 -3
- package/dist/{chunk-CD73YHEH.js.map → chunk-SG5ZWT6C.js.map} +1 -1
- package/dist/{chunk-MRODLUGY.cjs → chunk-TIMPJL5V.cjs} +4 -4
- package/dist/{chunk-MRODLUGY.cjs.map → chunk-TIMPJL5V.cjs.map} +1 -1
- package/dist/{chunk-77WHPVXE.js → chunk-TOTP24P6.js} +4 -4
- package/dist/chunk-TOTP24P6.js.map +1 -0
- package/dist/{chunk-3O2ELBST.cjs → chunk-USZTVNUQ.cjs} +5 -5
- package/dist/{chunk-3O2ELBST.cjs.map → chunk-USZTVNUQ.cjs.map} +1 -1
- package/dist/{chunk-YDLNI7J6.js → chunk-V2RBCCN5.js} +3 -3
- package/dist/chunk-V2RBCCN5.js.map +1 -0
- package/dist/{chunk-NNSKJCBM.cjs → chunk-VJYSQXN6.cjs} +10 -10
- package/dist/{chunk-NNSKJCBM.cjs.map → chunk-VJYSQXN6.cjs.map} +1 -1
- package/dist/{chunk-GM7QDQ24.cjs → chunk-W4WKVOOQ.cjs} +11 -11
- package/dist/{chunk-GM7QDQ24.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-ZW345YOI.js → chunk-YP67XZES.js} +4 -4
- package/dist/{chunk-ZW345YOI.js.map → chunk-YP67XZES.js.map} +1 -1
- package/dist/{chunk-YCXMSDSP.js → chunk-YRXY2A5L.js} +4 -4
- package/dist/{chunk-YCXMSDSP.js.map → chunk-YRXY2A5L.js.map} +1 -1
- package/dist/{chunk-IEUDKUPM.cjs → chunk-Z2CUEBXV.cjs} +25 -9
- package/dist/chunk-Z2CUEBXV.cjs.map +1 -0
- package/dist/{chunk-GL7CFBVC.js → chunk-ZYB6B7QJ.js} +112 -165
- package/dist/chunk-ZYB6B7QJ.js.map +1 -0
- package/dist/compact-session-PYEC3NZV.js +18 -0
- package/dist/{compact-session-WNKKIIDW.js.map → compact-session-PYEC3NZV.js.map} +1 -1
- package/dist/compact-session-VVT6IBJG.cjs +55 -0
- package/dist/{compact-session-H5TKLD55.cjs.map → compact-session-VVT6IBJG.cjs.map} +1 -1
- package/dist/compaction.cjs +19 -19
- package/dist/compaction.d.cts +9 -9
- package/dist/compaction.d.ts +9 -9
- package/dist/compaction.js +3 -3
- package/dist/concurrency.cjs +6 -6
- package/dist/concurrency.js +4 -4
- package/dist/context-2FZSC6VQ.cjs +22 -0
- package/dist/{context-ZV33V4DC.cjs.map → context-2FZSC6VQ.cjs.map} +1 -1
- package/dist/context-ATJJAFOS.js +5 -0
- package/dist/{context-VAYLPT4O.js.map → context-ATJJAFOS.js.map} +1 -1
- package/dist/{cron-Dx7B-3WB.d.ts → cron-Bx7tzm5R.d.ts} +54 -2
- package/dist/{cron-BiK_aNJI.d.cts → cron-D-DVjGQe.d.cts} +54 -2
- package/dist/cron.cjs +34 -30
- package/dist/cron.d.cts +3 -3
- package/dist/cron.d.ts +3 -3
- package/dist/cron.js +33 -29
- package/dist/{errors-DyVbXdR4.d.cts → errors-DMY-gLSK.d.cts} +1 -1
- package/dist/{errors-Cua4WC9H.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 +42 -37
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +38 -33
- package/dist/eval.js.map +1 -1
- package/dist/{executor-OZSYXDKF.cjs → executor-BMRICN46.cjs} +26 -25
- package/dist/executor-BMRICN46.cjs.map +1 -0
- package/dist/{executor-PAH72CB5.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-7E7UPLF2.cjs.map → fs-session-store-J5MCFFUM.cjs.map} +1 -1
- package/dist/fs-session-store-O6FNHECD.js +10 -0
- package/dist/{fs-session-store-6MY7PNI2.js.map → fs-session-store-O6FNHECD.js.map} +1 -1
- package/dist/generate-object-UF6WIZLF.cjs +20 -0
- package/dist/{generate-object-5SCEH2EE.cjs.map → generate-object-UF6WIZLF.cjs.map} +1 -1
- package/dist/generate-object-XDCBYVK3.js +7 -0
- package/dist/{generate-object-I7UD4NWN.js.map → generate-object-XDCBYVK3.js.map} +1 -1
- package/dist/index-manager-N7RQYUKT.cjs +20 -0
- package/dist/{index-manager-R6ZJFEZF.cjs.map → index-manager-N7RQYUKT.cjs.map} +1 -1
- package/dist/index-manager-ZVZUHPP7.js +11 -0
- package/dist/{index-manager-KKAK7NT3.js.map → index-manager-ZVZUHPP7.js.map} +1 -1
- package/dist/index.cjs +154 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +201 -43
- package/dist/index.d.ts +201 -43
- package/dist/index.js +62 -59
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-UXNJQTZ6.js → inject-session-GQMTDZUN.js} +8 -7
- package/dist/inject-session-GQMTDZUN.js.map +1 -0
- package/dist/{inject-session-DM4SKTZO.cjs → inject-session-LFCYVSLJ.cjs} +11 -10
- package/dist/inject-session-LFCYVSLJ.cjs.map +1 -0
- package/dist/internal/agent-loop/live-events.d.ts +46 -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/budget/compute-cost.d.ts +1 -1
- package/dist/internal/diagnostics.d.ts +46 -31
- package/dist/internal/error-mappers/anthropic.d.ts +1 -1
- package/dist/internal/global-singleton.d.ts +7 -7
- package/dist/internal/judge/judge-call.d.ts +14 -14
- package/dist/internal/llm/anthropic-shared.d.ts +4 -4
- package/dist/internal/llm/retrying-client.d.ts +29 -29
- package/dist/internal/llm/transport-error.d.ts +2 -2
- 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/exclusive-create.d.cts +2 -2
- package/dist/internal/persistence/exclusive-create.d.ts +2 -2
- package/dist/internal/persistence/fs-session-store.d.cts +18 -18
- package/dist/internal/persistence/fs-session-store.d.ts +18 -18
- package/dist/internal/persistence/index.cjs +25 -25
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.js +6 -6
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/persistence/paths.d.cts +7 -7
- package/dist/internal/persistence/paths.d.ts +7 -7
- package/dist/internal/persistence/session-transcript.d.cts +13 -7
- package/dist/internal/persistence/session-transcript.d.ts +13 -7
- package/dist/internal/persistence/session-writer.d.cts +30 -13
- package/dist/internal/persistence/session-writer.d.ts +30 -13
- package/dist/internal/runtime/concurrency/subagent-credentials.d.ts +35 -0
- package/dist/internal/runtime/fixtures/fixture-run-base.d.ts +45 -13
- package/dist/internal/runtime/lifecycle/goal-marker.d.ts +8 -8
- package/dist/internal/security/index.cjs +13 -13
- package/dist/internal/security/index.js +3 -3
- package/dist/internal/session/agent-session-store.d.ts +1 -0
- package/dist/internal/session/agent-session.d.ts +14 -14
- package/dist/internal/session/session-cache.d.ts +9 -9
- package/dist/internal/session/session-types.d.ts +6 -1
- package/dist/judge-call-NA2G6ZMJ.js +5 -0
- package/dist/{judge-call-TAEIXMYG.js.map → judge-call-NA2G6ZMJ.js.map} +1 -1
- package/dist/judge-call-U2D33JOW.cjs +22 -0
- package/dist/{judge-call-SP3G3X2Y.cjs.map → judge-call-U2D33JOW.cjs.map} +1 -1
- package/dist/models.cjs +20 -20
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +5 -5
- package/dist/models.js.map +1 -1
- package/dist/path-safety.cjs +10 -10
- package/dist/path-safety.js +3 -3
- package/dist/persistence.cjs +43 -43
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.d.cts +1 -1
- package/dist/persistence.d.ts +1 -1
- package/dist/persistence.js +14 -14
- package/dist/persistence.js.map +1 -1
- package/dist/project.cjs +5 -5
- package/dist/project.js +3 -3
- package/dist/registry-CAS6Y5ZY.js +9 -0
- package/dist/{registry-SOXE4RY6.js.map → registry-CAS6Y5ZY.js.map} +1 -1
- package/dist/registry-JSDI4WKA.cjs +46 -0
- package/dist/{registry-N3GTKYCI.cjs.map → registry-JSDI4WKA.cjs.map} +1 -1
- package/dist/retry.cjs +4 -4
- package/dist/retry.js +3 -3
- package/dist/{run-CwEJtLPE.d.ts → run-i2-fUohR.d.cts} +217 -174
- package/dist/{run-CwEJtLPE.d.cts → run-i2-fUohR.d.ts} +217 -174
- package/dist/{run-until-YZ2ODWOF.js → run-until-BK56WG4P.js} +3 -3
- package/dist/{run-until-YZ2ODWOF.js.map → run-until-BK56WG4P.js.map} +1 -1
- package/dist/{run-until-ZZ2JLPJM.cjs → run-until-L5KQD3PV.cjs} +4 -4
- package/dist/{run-until-ZZ2JLPJM.cjs.map → run-until-L5KQD3PV.cjs.map} +1 -1
- package/dist/sandbox/bwrap.d.cts +20 -20
- package/dist/sandbox/bwrap.d.ts +20 -20
- package/dist/sandbox/index.cjs +39 -39
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.d.cts +1 -1
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +35 -35
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/linux-sandbox.d.cts +26 -21
- package/dist/sandbox/linux-sandbox.d.ts +26 -21
- package/dist/server/auth/index.cjs.map +1 -1
- package/dist/server/auth/index.d.cts +6 -6
- package/dist/server/auth/index.d.ts +6 -6
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/orchestrator.d.cts +2 -2
- package/dist/server/auth/orchestrator.d.ts +2 -2
- package/dist/server/auth/types.d.cts +4 -4
- package/dist/server/auth/types.d.ts +4 -4
- package/dist/server/errors-envelope.cjs +14 -14
- package/dist/server/errors-envelope.d.cts +3 -3
- package/dist/server/errors-envelope.d.ts +3 -3
- package/dist/server/errors-envelope.js +3 -3
- package/dist/session-transcript-3B52DKTG.js +5 -0
- package/dist/{session-transcript-6WKLYIN4.js.map → session-transcript-3B52DKTG.js.map} +1 -1
- package/dist/session-transcript-H7NUFXXM.cjs +50 -0
- package/dist/{session-transcript-EAKR4D2W.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-Y7YCX3BI.cjs.map → stream-object-4FDU76YW.cjs.map} +1 -1
- package/dist/stream-object-HWDEEQN4.js +7 -0
- package/dist/{stream-object-OFM66VUT.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-prims.d.ts +4 -4
- package/dist/types/agent.d.ts +68 -3
- package/dist/types/conversation.d.ts +7 -0
- package/dist/types/goal-events.d.ts +24 -23
- package/dist/types/messages.d.ts +9 -0
- package/dist/types/run.d.ts +27 -0
- package/dist/types/session-message.d.ts +59 -0
- package/dist/types/session-record.d.ts +14 -13
- 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 +22 -13
- package/dist/agent-DW2J37IH.js +0 -42
- package/dist/agent-IE6IE4NW.cjs +0 -51
- package/dist/batch-3SEPDXCU.cjs.map +0 -1
- package/dist/batch-SY5GZLFD.js.map +0 -1
- package/dist/chunk-2423XDPT.cjs.map +0 -1
- package/dist/chunk-2ONFGMBV.js.map +0 -1
- package/dist/chunk-4YB7B3RP.cjs.map +0 -1
- package/dist/chunk-56OXYUZE.js.map +0 -1
- package/dist/chunk-56ZM6P7Z.cjs.map +0 -1
- package/dist/chunk-5SB4V74H.js +0 -176
- package/dist/chunk-5SB4V74H.js.map +0 -1
- package/dist/chunk-6VP3XGEK.js.map +0 -1
- package/dist/chunk-77WHPVXE.js.map +0 -1
- package/dist/chunk-ALU3KC4G.cjs.map +0 -1
- package/dist/chunk-BJMKQOY2.cjs.map +0 -1
- package/dist/chunk-DCJ5MCJ3.js.map +0 -1
- package/dist/chunk-EEZ7CFMM.js.map +0 -1
- package/dist/chunk-FV3YEMQ7.js.map +0 -1
- package/dist/chunk-G2F67XUR.cjs.map +0 -1
- package/dist/chunk-GL7CFBVC.js.map +0 -1
- package/dist/chunk-H5YVJB4K.cjs +0 -185
- package/dist/chunk-H5YVJB4K.cjs.map +0 -1
- package/dist/chunk-ICYBIC6N.cjs.map +0 -1
- package/dist/chunk-IEUDKUPM.cjs.map +0 -1
- package/dist/chunk-IT3PWBW4.cjs.map +0 -1
- package/dist/chunk-ITLS5LRF.cjs +0 -105
- package/dist/chunk-ITLS5LRF.cjs.map +0 -1
- package/dist/chunk-LTCOPATU.cjs.map +0 -1
- package/dist/chunk-MXSMAGDU.js.map +0 -1
- package/dist/chunk-P34DHHYQ.cjs.map +0 -1
- package/dist/chunk-SDIBMLL5.js.map +0 -1
- package/dist/chunk-TAPQWDW2.js.map +0 -1
- package/dist/chunk-THEYGCYS.cjs.map +0 -1
- package/dist/chunk-VNNK6AKU.js.map +0 -1
- package/dist/chunk-VYJSHGAY.js.map +0 -1
- package/dist/chunk-W52DKZBR.cjs.map +0 -1
- package/dist/chunk-XAEAMI5H.js.map +0 -1
- package/dist/chunk-XAYVHS2B.cjs.map +0 -1
- package/dist/chunk-YDLNI7J6.js.map +0 -1
- package/dist/chunk-YPQF26X7.cjs.map +0 -1
- package/dist/chunk-YVTNFKZO.js +0 -103
- package/dist/chunk-YVTNFKZO.js.map +0 -1
- package/dist/compact-session-H5TKLD55.cjs +0 -54
- package/dist/compact-session-WNKKIIDW.js +0 -17
- package/dist/context-VAYLPT4O.js +0 -5
- package/dist/context-ZV33V4DC.cjs +0 -22
- package/dist/executor-OZSYXDKF.cjs.map +0 -1
- package/dist/executor-PAH72CB5.js.map +0 -1
- package/dist/fs-session-store-6MY7PNI2.js +0 -10
- package/dist/fs-session-store-7E7UPLF2.cjs +0 -19
- package/dist/generate-object-5SCEH2EE.cjs +0 -20
- package/dist/generate-object-I7UD4NWN.js +0 -7
- package/dist/index-manager-KKAK7NT3.js +0 -10
- package/dist/index-manager-R6ZJFEZF.cjs +0 -19
- package/dist/inject-session-DM4SKTZO.cjs.map +0 -1
- package/dist/inject-session-UXNJQTZ6.js.map +0 -1
- package/dist/judge-call-SP3G3X2Y.cjs +0 -22
- package/dist/judge-call-TAEIXMYG.js +0 -5
- package/dist/registry-N3GTKYCI.cjs +0 -46
- package/dist/registry-SOXE4RY6.js +0 -9
- package/dist/session-transcript-6WKLYIN4.js +0 -5
- package/dist/session-transcript-EAKR4D2W.cjs +0 -50
- package/dist/stream-object-OFM66VUT.js +0 -7
- package/dist/stream-object-Y7YCX3BI.cjs +0 -20
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { extractCodePlugins } from './chunk-2SFBB54R.js';
|
|
2
|
-
import { submit, emitRunEvent } from './chunk-
|
|
3
|
-
import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages,
|
|
4
|
-
import { FsSessionStore } from './chunk-
|
|
5
|
-
import { discoverProviderPlugins, getConfiguredBaseUrl, httpRequest, isFixtureApiKey, shouldUseRealLocalRuntime, CircuitBreaker, buildDefaultSummarizer, parseSseStream, resolveProviderChain, inferProviderFromApiKey, detectPrimaryProvider, tryFirstEvent, relayStream,
|
|
6
|
-
import { IndexManager, writeSessionSummary, memoryDir,
|
|
7
|
-
import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-
|
|
2
|
+
import { submit, emitRunEvent } from './chunk-LJX2SQV2.js';
|
|
3
|
+
import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, discardSession, clearSession } from './chunk-E2FFG33C.js';
|
|
4
|
+
import { FsSessionStore } from './chunk-KGRIHEDT.js';
|
|
5
|
+
import { discoverProviderPlugins, getConfiguredBaseUrl, httpRequest, isFixtureApiKey, shouldUseRealLocalRuntime, CircuitBreaker, buildDefaultSummarizer, parseSseStream, resolveProviderChain, inferProviderFromApiKey, detectPrimaryProvider, tryFirstEvent, relayStream, renderToolResultContentText } from './chunk-ZYB6B7QJ.js';
|
|
6
|
+
import { IndexManager, writeSessionSummary, memoryDir, appendFact, readFacts, legacyMemoryJsonPath, memoryMdPath, appendFactToMarkdown } from './chunk-4F7JQZOX.js';
|
|
7
|
+
import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-ML5A5DOJ.js';
|
|
8
8
|
import { resolveChildEnv } from './chunk-7GFX45DD.js';
|
|
9
|
-
import { readVersionedJson, getTheokitHome, writeVersionedJson } from './chunk-
|
|
9
|
+
import { readVersionedJson, getTheokitHome, writeVersionedJson } from './chunk-YP67XZES.js';
|
|
10
|
+
import { createOpenAiCompatibleRuntime } from './chunk-QKE556YD.js';
|
|
10
11
|
import { sanitizeToolInput } from './chunk-U54XCYG3.js';
|
|
11
|
-
import {
|
|
12
|
+
import { withInheritedSubAgentCredentials, subAgentToolsFromDefinitions } from './chunk-RP5HQVLD.js';
|
|
12
13
|
import { setAgentFacade } from './chunk-6X6ID4MO.js';
|
|
13
14
|
import { findGitRoot, DEFAULT_DISCOVERY_SPECS, walkUpForFile, walkUpForGlob } from './chunk-UJ7IQJAG.js';
|
|
14
15
|
import { withToolWhitelist, checkToolWhitelist } from './chunk-7AD3ZTZL.js';
|
|
15
|
-
import { mapWithConcurrency } from './chunk-
|
|
16
|
-
import {
|
|
16
|
+
import { mapWithConcurrency } from './chunk-LGILIGV3.js';
|
|
17
|
+
import { defaultBaseDir, expandTilde } from './chunk-JRLXEYR4.js';
|
|
18
|
+
import { withFileLock } from './chunk-BQDUEG4C.js';
|
|
17
19
|
import { withCwdMutex } from './chunk-2XLKLVVR.js';
|
|
18
|
-
import { defaultBaseDir, expandTilde } from './chunk-XAEAMI5H.js';
|
|
19
20
|
import { toJsonSchema } from './chunk-4VPXM6UU.js';
|
|
20
|
-
import { atomicWriteJson } from './chunk-
|
|
21
|
-
import { loadSubagents } from './chunk-
|
|
22
|
-
import { resolveEffectiveContextWindow, CONTEXT_WINDOW_FLOOR, CONTEXT_WINDOW_MARGIN } from './chunk-
|
|
21
|
+
import { atomicWriteJson } from './chunk-KX7JV5KM.js';
|
|
22
|
+
import { loadSubagents } from './chunk-YRXY2A5L.js';
|
|
23
|
+
import { resolveEffectiveContextWindow, CONTEXT_WINDOW_FLOOR, CONTEXT_WINDOW_MARGIN } from './chunk-65ONFZWM.js';
|
|
23
24
|
import { parseModelId } from './chunk-X2FR4OIT.js';
|
|
24
|
-
import { getCatalogModelInfo, registerBuiltins, getProviderProfile, registerProvider, isPatchedModelKey } from './chunk-
|
|
25
|
-
import { escapeBlockBody, buildSkillsBlock, discoverSkills, stripSkillFrontmatter } from './chunk-
|
|
26
|
-
import { validateArtifactPath, PathTraversalError, safePathJoin } from './chunk-
|
|
27
|
-
import { readWorkspaceDir, parseSimpleYaml } from './chunk-
|
|
28
|
-
import { AgentRunError, coerceToKnownAgentRunErrorCode, UnknownAgentError, ConfigurationError, AuthenticationError, UnsupportedRunOperationError, AgentDisposedError, NetworkError, TheokitAgentError } from './chunk-
|
|
29
|
-
import { diag, redactSecrets } from './chunk-
|
|
25
|
+
import { getCatalogModelInfo, registerBuiltins, getProviderProfile, registerProvider, isPatchedModelKey } from './chunk-TOTP24P6.js';
|
|
26
|
+
import { escapeBlockBody, buildSkillsBlock, discoverSkills, stripSkillFrontmatter } from './chunk-42IFCKQZ.js';
|
|
27
|
+
import { validateArtifactPath, PathTraversalError, safePathJoin } from './chunk-J3UK2GMN.js';
|
|
28
|
+
import { readWorkspaceDir, parseSimpleYaml } from './chunk-AR5MQZ3J.js';
|
|
29
|
+
import { AgentRunError, coerceToKnownAgentRunErrorCode, UnknownAgentError, ConfigurationError, AuthenticationError, UnsupportedRunOperationError, AgentDisposedError, NetworkError, TheokitAgentError } from './chunk-SG5ZWT6C.js';
|
|
30
|
+
import { diag, redactSecrets } from './chunk-IVSD7L22.js';
|
|
30
31
|
import { stat, mkdir, readFile, readdir, access, unlink } from 'fs/promises';
|
|
31
32
|
import { randomUUID, createHash } from 'crypto';
|
|
32
33
|
import { join, dirname, resolve, relative, isAbsolute } from 'path';
|
|
@@ -221,7 +222,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
|
|
|
221
222
|
const { output, maxRetries, errorStrategy, ...sendOptions } = options;
|
|
222
223
|
const run = await agent.send(input, sendOptions);
|
|
223
224
|
const result = await run.wait();
|
|
224
|
-
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-
|
|
225
|
+
const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-XDCBYVK3.js');
|
|
225
226
|
const answer = structurableAnswerOrThrow(result, GenerateObjectError);
|
|
226
227
|
const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
|
|
227
228
|
const facade = getAgentFacade();
|
|
@@ -1320,6 +1321,16 @@ var FixtureRunBase = class {
|
|
|
1320
1321
|
resolveTermination;
|
|
1321
1322
|
terminated = false;
|
|
1322
1323
|
eventNotifier;
|
|
1324
|
+
/**
|
|
1325
|
+
* theokit#140 - the run's single ordered timeline: structural events and live token/tool deltas,
|
|
1326
|
+
* in the order they actually occurred.
|
|
1327
|
+
*
|
|
1328
|
+
* Kept alongside `script.events` rather than replacing it. `stream()` is the SDKMessage view and
|
|
1329
|
+
* stays byte-identical for every existing consumer; this is the complete view, and a consumer
|
|
1330
|
+
* picks one. Merging them would have changed `stream()`'s element type - a breaking change for
|
|
1331
|
+
* an additive feature.
|
|
1332
|
+
*/
|
|
1333
|
+
timeline = [];
|
|
1323
1334
|
constructor(options) {
|
|
1324
1335
|
this.id = options.id;
|
|
1325
1336
|
this.agentId = options.agentId;
|
|
@@ -1343,6 +1354,46 @@ var FixtureRunBase = class {
|
|
|
1343
1354
|
this.eventNotifier = makeNotifier();
|
|
1344
1355
|
current.resolve();
|
|
1345
1356
|
}
|
|
1357
|
+
/**
|
|
1358
|
+
* theokit#140 - every event of this run, in true order, from ONE source.
|
|
1359
|
+
*
|
|
1360
|
+
* ## The defect this replaces
|
|
1361
|
+
*
|
|
1362
|
+
* A consumer that needed tool calls interleaved with tokens had to fuse two surfaces by hand:
|
|
1363
|
+
* `stream()`, which was batched and post-completion, and `SendOptions.onDelta`, which was live.
|
|
1364
|
+
* Neither was complete alone - `onDelta` has no `run_started`/`system`, and `stream()` had no
|
|
1365
|
+
* token granularity - so the entire reconciliation, including its dedup, lived in the consumer.
|
|
1366
|
+
* `@theokit/agents` carried ~200 lines of exactly that, and it is the documented root of its
|
|
1367
|
+
* ordering bug (theokit#47), its namespace-dedup bug (#138) and its missing terminal frame (#142).
|
|
1368
|
+
*
|
|
1369
|
+
* The ordering is not reconstructed here. Both kinds are appended by the loop AS THEY HAPPEN, so
|
|
1370
|
+
* arrival order IS model order - there is nothing to sort, and no timestamp heuristic to get
|
|
1371
|
+
* wrong.
|
|
1372
|
+
*
|
|
1373
|
+
* `callId` is whatever the SDK's own `tool_call` events carry, so a consumer no longer holds two
|
|
1374
|
+
* id namespaces and no longer has to correlate them.
|
|
1375
|
+
*/
|
|
1376
|
+
async *events() {
|
|
1377
|
+
let index = 0;
|
|
1378
|
+
while (!this.terminated) {
|
|
1379
|
+
while (index < this.timeline.length) {
|
|
1380
|
+
yield this.timeline[index++];
|
|
1381
|
+
}
|
|
1382
|
+
if (this.terminated) break;
|
|
1383
|
+
await Promise.race([this.eventNotifier.promise, this.terminationPromise]);
|
|
1384
|
+
}
|
|
1385
|
+
while (index < this.timeline.length) {
|
|
1386
|
+
yield this.timeline[index++];
|
|
1387
|
+
}
|
|
1388
|
+
for await (const message of this.terminalErrorEvent()) {
|
|
1389
|
+
yield { kind: "message", message };
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
/** theokit#140 - append to the timeline and wake `events()`. */
|
|
1393
|
+
pushTimeline(event) {
|
|
1394
|
+
this.timeline.push(event);
|
|
1395
|
+
this.notifyNewEvents();
|
|
1396
|
+
}
|
|
1346
1397
|
async *stream() {
|
|
1347
1398
|
let index = 0;
|
|
1348
1399
|
while (!this.terminated) {
|
|
@@ -1358,22 +1409,22 @@ var FixtureRunBase = class {
|
|
|
1358
1409
|
yield* this.terminalErrorEvent();
|
|
1359
1410
|
}
|
|
1360
1411
|
/**
|
|
1361
|
-
* theokit#101 —
|
|
1412
|
+
* theokit#101 — when the run ends in error, `stream()` has to SAY SO.
|
|
1362
1413
|
*
|
|
1363
|
-
*
|
|
1364
|
-
* `status: 'error'`
|
|
1365
|
-
* `script.events`
|
|
1366
|
-
*
|
|
1414
|
+
* The error always existed: the loop records it in `ctx.error` and `wait()` returns
|
|
1415
|
+
* `status: 'error'` with the message. Only `stream()` failed to mention it — it drains
|
|
1416
|
+
* `script.events` and stops. A provider failure (404 "No endpoints found", auth, timeout)
|
|
1417
|
+
* produced a turn that looked successful and empty, on EVERY surface consuming the
|
|
1367
1418
|
* stream: HTTP web, MCP, stdio, TUI in-process.
|
|
1368
1419
|
*
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1371
|
-
*
|
|
1420
|
+
* A silent error is the worst kind (Unbreakable Rule 8). And the asymmetry was what made it
|
|
1421
|
+
* hard to diagnose: anyone debugging via `wait()` saw the error and would not reproduce the
|
|
1422
|
+
* report of anyone debugging via the stream.
|
|
1372
1423
|
*
|
|
1373
|
-
*
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1424
|
+
* It emits `SDKStatusMessage` with `status: "ERROR"` — the type ALREADY EXISTS in the `SDKMessage` union
|
|
1425
|
+
* and is already expected by consumers. A new type would be breaking for every consumer doing
|
|
1426
|
+
* an exhaustive switch; this one is additive, and a consumer ignoring `status` simply
|
|
1427
|
+
* behaves as before — never worse than today.
|
|
1377
1428
|
*/
|
|
1378
1429
|
*terminalErrorEvent() {
|
|
1379
1430
|
if (this.status !== "error") return;
|
|
@@ -1383,7 +1434,7 @@ var FixtureRunBase = class {
|
|
|
1383
1434
|
agent_id: this.agentId,
|
|
1384
1435
|
run_id: this.id,
|
|
1385
1436
|
status: "ERROR",
|
|
1386
|
-
//
|
|
1437
|
+
// Without a message, the consumer knows THAT it failed and not WHAT — which is half the defect.
|
|
1387
1438
|
...detail?.message !== void 0 ? { message: detail.message } : {}
|
|
1388
1439
|
};
|
|
1389
1440
|
}
|
|
@@ -2643,7 +2694,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2643
2694
|
}
|
|
2644
2695
|
const conversation = await safeConversation(run);
|
|
2645
2696
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2646
|
-
const
|
|
2697
|
+
const effectiveWindow = resolvedWindow.window;
|
|
2647
2698
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2648
2699
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2649
2700
|
emitRunEvent(onRunEvent, budgetEvent);
|
|
@@ -2659,9 +2710,9 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2659
2710
|
conversation,
|
|
2660
2711
|
autoCompact: {
|
|
2661
2712
|
usageTotal: usageForTrigger,
|
|
2662
|
-
//
|
|
2663
|
-
// `contextWindow`
|
|
2664
|
-
contextWindow:
|
|
2713
|
+
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2714
|
+
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2715
|
+
contextWindow: effectiveWindow,
|
|
2665
2716
|
summarize: buildDefaultSummarizer({
|
|
2666
2717
|
agentModel: model,
|
|
2667
2718
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
@@ -4939,6 +4990,35 @@ var UsageAccumulator = class {
|
|
|
4939
4990
|
}
|
|
4940
4991
|
};
|
|
4941
4992
|
|
|
4993
|
+
// src/internal/agent-loop/live-events.ts
|
|
4994
|
+
var LiveEventLog = class extends Array {
|
|
4995
|
+
/**
|
|
4996
|
+
* Not readonly, and not a constructor parameter — `Array` subclasses are re-instantiated by
|
|
4997
|
+
* `map`/`filter`/`slice` with a length argument, so a constructor with a different signature
|
|
4998
|
+
* breaks those. The sink is attached after construction instead.
|
|
4999
|
+
*/
|
|
5000
|
+
#sink;
|
|
5001
|
+
/** Attach the live subscriber. One sink: the run that owns this loop. */
|
|
5002
|
+
subscribe(sink) {
|
|
5003
|
+
this.#sink = sink;
|
|
5004
|
+
}
|
|
5005
|
+
push(...events) {
|
|
5006
|
+
const length = super.push(...events);
|
|
5007
|
+
for (const event of events) {
|
|
5008
|
+
try {
|
|
5009
|
+
this.#sink?.(event);
|
|
5010
|
+
} catch {
|
|
5011
|
+
}
|
|
5012
|
+
}
|
|
5013
|
+
return length;
|
|
5014
|
+
}
|
|
5015
|
+
};
|
|
5016
|
+
function createEventLog(seed) {
|
|
5017
|
+
const log = new LiveEventLog();
|
|
5018
|
+
log.push(...seed);
|
|
5019
|
+
return log;
|
|
5020
|
+
}
|
|
5021
|
+
|
|
4942
5022
|
// src/internal/agent-loop/message-builders.ts
|
|
4943
5023
|
function buildSystemEvent(inputs, toolNames) {
|
|
4944
5024
|
return {
|
|
@@ -4966,7 +5046,7 @@ function buildAssistantEvent(inputs, text) {
|
|
|
4966
5046
|
message: { role: "assistant", content: [{ type: "text", text }] }
|
|
4967
5047
|
};
|
|
4968
5048
|
}
|
|
4969
|
-
function buildThinkingEvent(inputs, text, thinkingDurationMs) {
|
|
5049
|
+
function buildThinkingEvent(inputs, text, thinkingDurationMs, signature) {
|
|
4970
5050
|
const event = {
|
|
4971
5051
|
type: "thinking",
|
|
4972
5052
|
agent_id: inputs.agentId,
|
|
@@ -4976,10 +5056,12 @@ function buildThinkingEvent(inputs, text, thinkingDurationMs) {
|
|
|
4976
5056
|
if (thinkingDurationMs !== void 0 && thinkingDurationMs >= 0) {
|
|
4977
5057
|
event.thinking_duration_ms = thinkingDurationMs;
|
|
4978
5058
|
}
|
|
5059
|
+
if (signature !== void 0) event.signature = signature;
|
|
4979
5060
|
return event;
|
|
4980
5061
|
}
|
|
4981
|
-
function buildAssistantTurn(text, toolCalls) {
|
|
5062
|
+
function buildAssistantTurn(text, toolCalls, thinking) {
|
|
4982
5063
|
const content = [];
|
|
5064
|
+
if (thinking !== void 0) content.push(thinking);
|
|
4983
5065
|
if (text.length > 0) content.push({ type: "text", text });
|
|
4984
5066
|
for (const call of toolCalls) content.push(call);
|
|
4985
5067
|
return { role: "assistant", content };
|
|
@@ -5048,13 +5130,14 @@ async function initLoopContext(inputs) {
|
|
|
5048
5130
|
});
|
|
5049
5131
|
}
|
|
5050
5132
|
}
|
|
5051
|
-
const events = [
|
|
5133
|
+
const events = createEventLog([
|
|
5052
5134
|
buildSystemEvent(
|
|
5053
5135
|
inputs,
|
|
5054
5136
|
tools.map((t) => t.name)
|
|
5055
5137
|
),
|
|
5056
5138
|
buildUserEvent(inputs)
|
|
5057
|
-
];
|
|
5139
|
+
]);
|
|
5140
|
+
if (inputs.onLoopEvent !== void 0) events.subscribe(inputs.onLoopEvent);
|
|
5058
5141
|
const priorMessages = (inputs.priorMessages ?? []).map((msg) => ({
|
|
5059
5142
|
role: msg.role,
|
|
5060
5143
|
content: [{ type: "text", text: msg.text }]
|
|
@@ -5233,6 +5316,7 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
5233
5316
|
emitLlmMetrics(inputs, result, startAt);
|
|
5234
5317
|
llmSpan?.end();
|
|
5235
5318
|
const stripped = stripThinkBlocks(collected.accumulatedText);
|
|
5319
|
+
const thinking = result.thinking ?? collected.thinking;
|
|
5236
5320
|
return {
|
|
5237
5321
|
text: stripped.visible,
|
|
5238
5322
|
toolCalls: result.toolCalls,
|
|
@@ -5242,18 +5326,21 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
5242
5326
|
outputTokens: result.outputTokens,
|
|
5243
5327
|
cacheReadTokens: result.cacheReadTokens,
|
|
5244
5328
|
cacheWriteTokens: result.cacheWriteTokens,
|
|
5245
|
-
reasoningTokens: result.reasoningTokens
|
|
5329
|
+
reasoningTokens: result.reasoningTokens,
|
|
5330
|
+
...thinking !== void 0 ? { thinking } : {}
|
|
5246
5331
|
};
|
|
5247
5332
|
}
|
|
5248
5333
|
async function collectLlmEvents(generator, inputs, ctx) {
|
|
5249
5334
|
let accumulatedText = "";
|
|
5250
5335
|
let errored = false;
|
|
5251
5336
|
let finishValue;
|
|
5337
|
+
let thinking;
|
|
5252
5338
|
try {
|
|
5253
5339
|
const result = await runCollectorLoop(generator, inputs, ctx);
|
|
5254
5340
|
accumulatedText = result.accumulatedText;
|
|
5255
5341
|
errored = result.errored;
|
|
5256
5342
|
finishValue = result.finishValue;
|
|
5343
|
+
thinking = result.thinking;
|
|
5257
5344
|
} catch (cause) {
|
|
5258
5345
|
if (inputs.signal?.aborted === true) {
|
|
5259
5346
|
ctx.finalText = "[aborted]";
|
|
@@ -5264,7 +5351,12 @@ async function collectLlmEvents(generator, inputs, ctx) {
|
|
|
5264
5351
|
}
|
|
5265
5352
|
errored = true;
|
|
5266
5353
|
}
|
|
5267
|
-
return {
|
|
5354
|
+
return {
|
|
5355
|
+
accumulatedText,
|
|
5356
|
+
errored,
|
|
5357
|
+
finishValue,
|
|
5358
|
+
...thinking !== void 0 ? { thinking } : {}
|
|
5359
|
+
};
|
|
5268
5360
|
}
|
|
5269
5361
|
function registerLoopError(ctx, cause) {
|
|
5270
5362
|
if (ctx.error !== void 0) return;
|
|
@@ -5275,11 +5367,26 @@ function registerLoopError(ctx, cause) {
|
|
|
5275
5367
|
const code = typeof metaCode === "string" ? metaCode : typeof rawCode === "string" ? rawCode : void 0;
|
|
5276
5368
|
ctx.error = code !== void 0 ? { message, code, cause } : { message, cause };
|
|
5277
5369
|
}
|
|
5370
|
+
async function consumeStreamEvent(inputs, reasoning, event) {
|
|
5371
|
+
if (event.type === "text_delta") {
|
|
5372
|
+
const text = event.text ?? "";
|
|
5373
|
+
await emitTextDeltaCallback(inputs, text);
|
|
5374
|
+
return text;
|
|
5375
|
+
}
|
|
5376
|
+
if (event.type === "reasoning_delta") {
|
|
5377
|
+
await consumeReasoningDelta(inputs, reasoning, {
|
|
5378
|
+
text: event.text ?? "",
|
|
5379
|
+
...event.signature !== void 0 ? { signature: event.signature } : {}
|
|
5380
|
+
});
|
|
5381
|
+
}
|
|
5382
|
+
return "";
|
|
5383
|
+
}
|
|
5278
5384
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
5279
5385
|
let accumulatedText = "";
|
|
5280
|
-
const reasoning = { text: "", startedAt: void 0 };
|
|
5386
|
+
const reasoning = { text: "", startedAt: void 0, signature: void 0 };
|
|
5281
5387
|
let errored = false;
|
|
5282
5388
|
let finishValue;
|
|
5389
|
+
let thinking;
|
|
5283
5390
|
try {
|
|
5284
5391
|
while (true) {
|
|
5285
5392
|
const next = await generator.next();
|
|
@@ -5287,24 +5394,22 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
5287
5394
|
finishValue = next;
|
|
5288
5395
|
break;
|
|
5289
5396
|
}
|
|
5290
|
-
if (next.value.type === "text_delta") {
|
|
5291
|
-
accumulatedText += next.value.text;
|
|
5292
|
-
await emitTextDeltaCallback(inputs, next.value.text);
|
|
5293
|
-
}
|
|
5294
|
-
if (next.value.type === "reasoning_delta") {
|
|
5295
|
-
await accumulateReasoning(inputs, reasoning, next.value.text);
|
|
5296
|
-
}
|
|
5297
5397
|
if (next.value.type === "error") {
|
|
5298
5398
|
registerLoopError(ctx, next.value);
|
|
5299
5399
|
ctx.finalText = "";
|
|
5300
5400
|
errored = true;
|
|
5301
5401
|
break;
|
|
5302
5402
|
}
|
|
5403
|
+
accumulatedText += await consumeStreamEvent(inputs, reasoning, next.value);
|
|
5303
5404
|
}
|
|
5304
5405
|
} finally {
|
|
5305
|
-
await finalizeReasoning(inputs, ctx, reasoning);
|
|
5406
|
+
thinking = await finalizeReasoning(inputs, ctx, reasoning);
|
|
5306
5407
|
}
|
|
5307
|
-
return { accumulatedText, errored, finishValue };
|
|
5408
|
+
return { accumulatedText, errored, finishValue, ...thinking !== void 0 ? { thinking } : {} };
|
|
5409
|
+
}
|
|
5410
|
+
async function consumeReasoningDelta(inputs, reasoning, delta) {
|
|
5411
|
+
if (delta.signature !== void 0) reasoning.signature = delta.signature;
|
|
5412
|
+
await accumulateReasoning(inputs, reasoning, delta.text);
|
|
5308
5413
|
}
|
|
5309
5414
|
async function accumulateReasoning(inputs, reasoning, text) {
|
|
5310
5415
|
if (reasoning.startedAt === void 0) reasoning.startedAt = Date.now();
|
|
@@ -5312,10 +5417,17 @@ async function accumulateReasoning(inputs, reasoning, text) {
|
|
|
5312
5417
|
await emitReasoningDeltaCallback(inputs, text);
|
|
5313
5418
|
}
|
|
5314
5419
|
async function finalizeReasoning(inputs, ctx, reasoning) {
|
|
5315
|
-
if (reasoning.text.length === 0) return;
|
|
5420
|
+
if (reasoning.text.length === 0) return void 0;
|
|
5316
5421
|
const thinkingDurationMs = reasoning.startedAt === void 0 ? 0 : Date.now() - reasoning.startedAt;
|
|
5317
|
-
ctx.events.push(
|
|
5422
|
+
ctx.events.push(
|
|
5423
|
+
buildThinkingEvent(inputs, reasoning.text, thinkingDurationMs, reasoning.signature)
|
|
5424
|
+
);
|
|
5318
5425
|
await emitThinkingCompletedCallback(inputs, thinkingDurationMs);
|
|
5426
|
+
return {
|
|
5427
|
+
type: "thinking",
|
|
5428
|
+
text: reasoning.text,
|
|
5429
|
+
...reasoning.signature !== void 0 ? { signature: reasoning.signature } : {}
|
|
5430
|
+
};
|
|
5319
5431
|
}
|
|
5320
5432
|
async function emitTextDeltaCallback(inputs, text) {
|
|
5321
5433
|
if (inputs.onDelta === void 0) return;
|
|
@@ -5345,6 +5457,24 @@ async function emitThinkingCompletedCallback(inputs, thinkingDurationMs) {
|
|
|
5345
5457
|
);
|
|
5346
5458
|
}
|
|
5347
5459
|
|
|
5460
|
+
// src/internal/agent-loop/loop-thinking-steps.ts
|
|
5461
|
+
function thinkingStep(thinking) {
|
|
5462
|
+
return {
|
|
5463
|
+
type: "thinkingMessage",
|
|
5464
|
+
message: {
|
|
5465
|
+
text: thinking.text,
|
|
5466
|
+
...thinking.signature !== void 0 ? { signature: thinking.signature } : {}
|
|
5467
|
+
}
|
|
5468
|
+
};
|
|
5469
|
+
}
|
|
5470
|
+
function recordThinkingOnSilentToolRound(ctx, text, thinking) {
|
|
5471
|
+
if (text.length > 0 || thinking === void 0) return;
|
|
5472
|
+
ctx.conversation.push({
|
|
5473
|
+
type: "agentConversationTurn",
|
|
5474
|
+
turn: { steps: [thinkingStep(thinking)] }
|
|
5475
|
+
});
|
|
5476
|
+
}
|
|
5477
|
+
|
|
5348
5478
|
// src/internal/tool-dispatch/repair-middleware.ts
|
|
5349
5479
|
var DECIMAL_RE = /^-?\d+(\.\d+)?$/;
|
|
5350
5480
|
function repairToolCall(raw, registry) {
|
|
@@ -6396,12 +6526,13 @@ async function runAgentLoop(inputs) {
|
|
|
6396
6526
|
sendSpan?.end();
|
|
6397
6527
|
}
|
|
6398
6528
|
}
|
|
6399
|
-
async function emitAssistantTextStep(inputs, ctx, text) {
|
|
6529
|
+
async function emitAssistantTextStep(inputs, ctx, text, thinking) {
|
|
6400
6530
|
ctx.events.push(buildAssistantEvent(inputs, text));
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6531
|
+
const steps = [
|
|
6532
|
+
...thinking !== void 0 ? [thinkingStep(thinking)] : [],
|
|
6533
|
+
{ type: "assistantMessage", message: { text } }
|
|
6534
|
+
];
|
|
6535
|
+
ctx.conversation.push({ type: "agentConversationTurn", turn: { steps } });
|
|
6405
6536
|
ctx.finalText = text;
|
|
6406
6537
|
if (inputs.onStep === void 0) return;
|
|
6407
6538
|
const cb = inputs.onStep;
|
|
@@ -6537,13 +6668,15 @@ async function continueOrTerminate(inputs, ctx, llmOutput) {
|
|
|
6537
6668
|
if (llmOutput.errored) return "error";
|
|
6538
6669
|
const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
|
|
6539
6670
|
const text = llmOutput.text.length > 0 ? await transformLlmOutputText(inputs, llmOutput.text, tCtx) : llmOutput.text;
|
|
6671
|
+
const thinking = llmOutput.thinking;
|
|
6540
6672
|
if (text.length > 0) {
|
|
6541
|
-
await emitAssistantTextStep(inputs, ctx, text);
|
|
6673
|
+
await emitAssistantTextStep(inputs, ctx, text, thinking);
|
|
6542
6674
|
}
|
|
6543
6675
|
if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
|
|
6544
6676
|
return finishOrReflect(inputs, ctx, llmOutput);
|
|
6545
6677
|
}
|
|
6546
|
-
ctx
|
|
6678
|
+
recordThinkingOnSilentToolRound(ctx, text, thinking);
|
|
6679
|
+
ctx.messages.push(buildAssistantTurn(text, llmOutput.toolCalls, thinking));
|
|
6547
6680
|
const rawResults = await dispatchTools(
|
|
6548
6681
|
// SE12 — forward a read-only text projection of the transcript-so-far to tool
|
|
6549
6682
|
// handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
|
|
@@ -6579,7 +6712,9 @@ async function inspectDoomLoop(inputs, ctx, toolCalls) {
|
|
|
6579
6712
|
await emitAssistantTextStep(
|
|
6580
6713
|
inputs,
|
|
6581
6714
|
ctx,
|
|
6582
|
-
verdict.message ?? "Stopped: repeated identical tool calls made no progress."
|
|
6715
|
+
verdict.message ?? "Stopped: repeated identical tool calls made no progress.",
|
|
6716
|
+
// The doom-loop stop message is the SDK's own text, not a model turn — it has no thinking.
|
|
6717
|
+
void 0
|
|
6583
6718
|
);
|
|
6584
6719
|
return "stop";
|
|
6585
6720
|
}
|
|
@@ -6726,7 +6861,20 @@ var StdioMcpClient = class extends BaseMcpClient {
|
|
|
6726
6861
|
);
|
|
6727
6862
|
});
|
|
6728
6863
|
}
|
|
6864
|
+
/**
|
|
6865
|
+
* theokit#155 — idempotent while the child is LIVE.
|
|
6866
|
+
*
|
|
6867
|
+
* Under `mcpLifecycle: 'session'` the pool hands the same client back on the next turn, and
|
|
6868
|
+
* `initializeMcp` runs every turn. An unconditional `spawnChild()` would overwrite `this.child`,
|
|
6869
|
+
* orphaning a healthy process (its `exit` handler is skipped by the `this.child === child` guard)
|
|
6870
|
+
* and paying the ~146 ms spawn + handshake the option exists to avoid.
|
|
6871
|
+
*
|
|
6872
|
+
* This does NOT touch the #59 reconnect path: `reconnect()` calls `spawnChild()` and
|
|
6873
|
+
* `super.initialize()` directly, so it re-spawns exactly as before. After `close()` — or after a
|
|
6874
|
+
* drop, which clears `child` — this method spawns again, as it must.
|
|
6875
|
+
*/
|
|
6729
6876
|
async initialize() {
|
|
6877
|
+
if (this.child !== void 0) return;
|
|
6730
6878
|
this.spawnChild();
|
|
6731
6879
|
await super.initialize();
|
|
6732
6880
|
}
|
|
@@ -6915,12 +7063,12 @@ var HttpMcpClient = class extends BaseMcpClient {
|
|
|
6915
7063
|
async readBody(response) {
|
|
6916
7064
|
const tipo = response.headers.get("content-type") ?? "";
|
|
6917
7065
|
if (!tipo.includes("text/event-stream")) return await response.json();
|
|
6918
|
-
const
|
|
6919
|
-
for (const
|
|
6920
|
-
if (!
|
|
6921
|
-
const
|
|
6922
|
-
if (
|
|
6923
|
-
return JSON.parse(
|
|
7066
|
+
const text = await response.text();
|
|
7067
|
+
for (const line of text.split(/\r?\n/)) {
|
|
7068
|
+
if (!line.startsWith("data:")) continue;
|
|
7069
|
+
const payload = line.slice(5).trim();
|
|
7070
|
+
if (payload === "") continue;
|
|
7071
|
+
return JSON.parse(payload);
|
|
6924
7072
|
}
|
|
6925
7073
|
throw new NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
|
|
6926
7074
|
code: "mcp_http_error"
|
|
@@ -7097,16 +7245,15 @@ function declarativeSubagentTools(agents2, parentTools) {
|
|
|
7097
7245
|
if (agents2 === void 0 || Object.keys(agents2).length === 0) return [];
|
|
7098
7246
|
return subAgentToolsFromDefinitions(agents2, parentTools);
|
|
7099
7247
|
}
|
|
7100
|
-
function
|
|
7248
|
+
function resolveInheritedCredentials(agentOptions) {
|
|
7101
7249
|
const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
|
|
7102
7250
|
const parentSandbox = agentOptions.local?.sandboxOptions?.enabled;
|
|
7103
|
-
|
|
7251
|
+
return {
|
|
7104
7252
|
...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
|
|
7105
7253
|
...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
|
|
7106
7254
|
...parentPlugins !== void 0 ? { plugins: parentPlugins } : {},
|
|
7107
7255
|
...parentSandbox !== void 0 ? { sandbox: parentSandbox } : {}
|
|
7108
7256
|
};
|
|
7109
|
-
for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
|
|
7110
7257
|
}
|
|
7111
7258
|
function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, personalityToolWhitelist, agentId, personalityName, subagents, effectiveModel) {
|
|
7112
7259
|
const baseTools = sendOptions?.tools ?? agentOptions.tools ?? [];
|
|
@@ -7118,7 +7265,6 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
|
|
|
7118
7265
|
return {};
|
|
7119
7266
|
}
|
|
7120
7267
|
const allTools = [...baseTools, ...subagentTools, ...pluginTools, ...reasoningTools];
|
|
7121
|
-
bindParentCredentials(allTools, agentOptions);
|
|
7122
7268
|
const merged = allTools.map((tool) => ({
|
|
7123
7269
|
name: tool.name,
|
|
7124
7270
|
description: tool.description,
|
|
@@ -7154,7 +7300,9 @@ function createRealLocalRun(options) {
|
|
|
7154
7300
|
supportedOps: supported,
|
|
7155
7301
|
startTime
|
|
7156
7302
|
},
|
|
7157
|
-
() => buildLoopInputs(options, id, userText, userImages)
|
|
7303
|
+
() => buildLoopInputs(options, id, userText, userImages),
|
|
7304
|
+
runOwnsMcpClients(options.agentOptions),
|
|
7305
|
+
resolveInheritedCredentials(options.agentOptions)
|
|
7158
7306
|
);
|
|
7159
7307
|
handle.bootstrap();
|
|
7160
7308
|
registerRun(handle);
|
|
@@ -7293,11 +7441,14 @@ function disposeSessionMcpClients(agentId) {
|
|
|
7293
7441
|
void client.close();
|
|
7294
7442
|
});
|
|
7295
7443
|
}
|
|
7444
|
+
function runOwnsMcpClients(agentOptions) {
|
|
7445
|
+
return agentOptions.mcpLifecycle !== "session";
|
|
7446
|
+
}
|
|
7296
7447
|
function buildMcpMap(options) {
|
|
7297
7448
|
const map = /* @__PURE__ */ new Map();
|
|
7298
7449
|
const inline = options.sendOptions.mcpServers ?? options.agentOptions.mcpServers;
|
|
7299
7450
|
if (inline === void 0) return map;
|
|
7300
|
-
const pooled = options.agentOptions
|
|
7451
|
+
const pooled = !runOwnsMcpClients(options.agentOptions);
|
|
7301
7452
|
if (pooled) sessionMcpPool.reapIdle((c) => void c.close());
|
|
7302
7453
|
for (const [name, config] of Object.entries(inline)) {
|
|
7303
7454
|
map.set(
|
|
@@ -7309,9 +7460,15 @@ function buildMcpMap(options) {
|
|
|
7309
7460
|
}
|
|
7310
7461
|
var RealLocalRun = class extends FixtureRunBase {
|
|
7311
7462
|
buildInputs;
|
|
7312
|
-
|
|
7463
|
+
/** theokit#155 — whether this turn releases its MCP clients, or the session pool does. */
|
|
7464
|
+
ownsMcpClients;
|
|
7465
|
+
/** theokit#148 — what a delegated child inherits from this parent, scoped to the loop. */
|
|
7466
|
+
inheritedCredentials;
|
|
7467
|
+
constructor(options, buildInputs, ownsMcpClients, inheritedCredentials) {
|
|
7313
7468
|
super(options);
|
|
7314
7469
|
this.buildInputs = buildInputs;
|
|
7470
|
+
this.ownsMcpClients = ownsMcpClients;
|
|
7471
|
+
this.inheritedCredentials = inheritedCredentials;
|
|
7315
7472
|
}
|
|
7316
7473
|
bootstrap() {
|
|
7317
7474
|
setTimeout(() => {
|
|
@@ -7351,17 +7508,39 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7351
7508
|
}
|
|
7352
7509
|
}
|
|
7353
7510
|
}
|
|
7511
|
+
/**
|
|
7512
|
+
* theokit#140 - events already handed to stream() by the live subscriber.
|
|
7513
|
+
*
|
|
7514
|
+
* The loop still RETURNS its full event list, and that batch path is deliberately kept: it is the
|
|
7515
|
+
* fallback if a live event is ever lost, and removing it would make the live channel a single
|
|
7516
|
+
* point of failure for the whole transcript.
|
|
7517
|
+
*/
|
|
7518
|
+
liveDelivered = /* @__PURE__ */ new Set();
|
|
7354
7519
|
async executeAgentLoop(inputs) {
|
|
7520
|
+
inputs.onLoopEvent = (event) => {
|
|
7521
|
+
this.liveDelivered.add(event);
|
|
7522
|
+
this.script.events.push(event);
|
|
7523
|
+
this.pushTimeline({ kind: "message", message: event });
|
|
7524
|
+
this.notifyNewEvents();
|
|
7525
|
+
};
|
|
7526
|
+
const callerOnDelta = inputs.onDelta;
|
|
7527
|
+
inputs.onDelta = (delta) => {
|
|
7528
|
+
callerOnDelta?.(delta);
|
|
7529
|
+
this.pushTimeline({ kind: "delta", update: delta.update });
|
|
7530
|
+
};
|
|
7355
7531
|
try {
|
|
7356
|
-
const
|
|
7532
|
+
const runLoop = () => inputs.activeTools !== void 0 ? withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : runAgentLoop(inputs);
|
|
7533
|
+
const output = await withInheritedSubAgentCredentials(this.inheritedCredentials, runLoop);
|
|
7357
7534
|
this.applyAgentLoopOutput(output);
|
|
7358
7535
|
this.transitionTo(output.finalStatus);
|
|
7359
7536
|
} catch (cause) {
|
|
7360
7537
|
this.emitErrorEvent(cause, "Agent loop failed", "", "agent_loop_failed");
|
|
7361
7538
|
this.transitionTo("error");
|
|
7362
7539
|
} finally {
|
|
7363
|
-
|
|
7364
|
-
|
|
7540
|
+
if (this.ownsMcpClients) {
|
|
7541
|
+
for (const client of inputs.mcp.values()) {
|
|
7542
|
+
await client.close().catch(() => void 0);
|
|
7543
|
+
}
|
|
7365
7544
|
}
|
|
7366
7545
|
}
|
|
7367
7546
|
}
|
|
@@ -7374,10 +7553,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7374
7553
|
* Finding-B fix (sdk-error-packaging v1.1): set-once errorDetail copy.
|
|
7375
7554
|
*/
|
|
7376
7555
|
applyAgentLoopOutput(output) {
|
|
7377
|
-
|
|
7378
|
-
this.script.events.push(event);
|
|
7379
|
-
this.notifyNewEvents();
|
|
7380
|
-
}
|
|
7556
|
+
this.deliverUndeliveredEvents(output.events);
|
|
7381
7557
|
this.script.conversation.push(...output.conversation);
|
|
7382
7558
|
if (output.result.length > 0) this.script.result = output.result;
|
|
7383
7559
|
if (output.usage !== void 0) this.script.usage = output.usage;
|
|
@@ -7392,6 +7568,25 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
7392
7568
|
};
|
|
7393
7569
|
}
|
|
7394
7570
|
}
|
|
7571
|
+
/**
|
|
7572
|
+
* theokit#140 - deliver only what the live subscriber has NOT already handed to `stream()`.
|
|
7573
|
+
*
|
|
7574
|
+
* The loop now reports each event as it happens, so this batch is the SAME list, replayed.
|
|
7575
|
+
* Without the guard every event would reach `stream()` twice: once live, once here.
|
|
7576
|
+
*
|
|
7577
|
+
* Identity, not deep equality: these are the very objects the live sink saw, and two genuinely
|
|
7578
|
+
* distinct events can be structurally identical (the same tool called twice with the same args
|
|
7579
|
+
* is not a duplicate).
|
|
7580
|
+
*
|
|
7581
|
+
* Extracted because the guard pushed `applyAgentLoopOutput` past the cognitive-complexity cap.
|
|
7582
|
+
*/
|
|
7583
|
+
deliverUndeliveredEvents(events) {
|
|
7584
|
+
for (const event of events) {
|
|
7585
|
+
if (this.liveDelivered.has(event)) continue;
|
|
7586
|
+
this.script.events.push(event);
|
|
7587
|
+
this.notifyNewEvents();
|
|
7588
|
+
}
|
|
7589
|
+
}
|
|
7395
7590
|
emitErrorEvent(cause, fallback, prefix = "", code) {
|
|
7396
7591
|
if (this.script.errorDetail === void 0) {
|
|
7397
7592
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
@@ -7677,7 +7872,7 @@ var LiveAgentRegistry = class {
|
|
|
7677
7872
|
var liveAgentRegistry = new LiveAgentRegistry();
|
|
7678
7873
|
|
|
7679
7874
|
// src/internal/local-agent/local-agent-lifecycle.ts
|
|
7680
|
-
async function
|
|
7875
|
+
async function acquireLeaseIfPossible(store, agentId) {
|
|
7681
7876
|
const a = store.acquire;
|
|
7682
7877
|
if (typeof a !== "function") return;
|
|
7683
7878
|
try {
|
|
@@ -7690,7 +7885,7 @@ async function adquirirLeaseSePossivel(store, agentId) {
|
|
|
7690
7885
|
);
|
|
7691
7886
|
}
|
|
7692
7887
|
}
|
|
7693
|
-
async function
|
|
7888
|
+
async function releaseLeaseIfPossible(store, agentId) {
|
|
7694
7889
|
const r = store.release;
|
|
7695
7890
|
if (typeof r === "function") await r.call(store, agentId);
|
|
7696
7891
|
}
|
|
@@ -7706,7 +7901,7 @@ async function disposeLocalAgentSession(agent) {
|
|
|
7706
7901
|
await flushSessionWrites();
|
|
7707
7902
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
7708
7903
|
await disposeSessionStore(agent.sessionStore);
|
|
7709
|
-
|
|
7904
|
+
discardSession(agent.workspaceCwd, agent.agentId);
|
|
7710
7905
|
}
|
|
7711
7906
|
async function reloadLocalAgent(agent) {
|
|
7712
7907
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
@@ -7952,184 +8147,6 @@ function cacheKey(userText, queryMode, ctx) {
|
|
|
7952
8147
|
const parts = [queryMode, ctx?.namespace ?? "", ctx?.userId ?? "", ctx?.scope ?? "", userText];
|
|
7953
8148
|
return createHash("sha256").update(parts.join("\0")).digest("hex");
|
|
7954
8149
|
}
|
|
7955
|
-
var MAX_BATCH = 100;
|
|
7956
|
-
var MAX_RETRIES = 2;
|
|
7957
|
-
async function createOpenAiCompatibleRuntime(cfg, options) {
|
|
7958
|
-
const model = options.model ?? cfg.defaultModel;
|
|
7959
|
-
const apiKey = options.apiKey ?? process.env[cfg.apiKeyEnv];
|
|
7960
|
-
if (apiKey === void 0 || apiKey.length === 0) {
|
|
7961
|
-
throw new AuthenticationError(`${cfg.apiKeyEnv} missing`, {
|
|
7962
|
-
code: "embedding_missing_api_key"
|
|
7963
|
-
});
|
|
7964
|
-
}
|
|
7965
|
-
const envBaseUrl = cfg.baseUrlEnv !== void 0 ? process.env[cfg.baseUrlEnv] : void 0;
|
|
7966
|
-
const baseUrl = options.baseUrl ?? envBaseUrl ?? cfg.defaultBaseUrl;
|
|
7967
|
-
const fetchImpl = options.fetch ?? fetch;
|
|
7968
|
-
const cache = options.cache ?? globalEmbeddingCache;
|
|
7969
|
-
const dimension = cfg.dimensionByModel[model];
|
|
7970
|
-
if (dimension === void 0) {
|
|
7971
|
-
throw new ConfigurationError(
|
|
7972
|
-
`${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.`,
|
|
7973
|
-
{ code: "embedding_unknown_model" }
|
|
7974
|
-
);
|
|
7975
|
-
}
|
|
7976
|
-
const embeddingsPath = cfg.embeddingsPath ?? "/v1/embeddings";
|
|
7977
|
-
const stats = {
|
|
7978
|
-
cacheHits: 0,
|
|
7979
|
-
cacheMisses: 0,
|
|
7980
|
-
httpCalls: 0,
|
|
7981
|
-
retries: 0
|
|
7982
|
-
};
|
|
7983
|
-
return {
|
|
7984
|
-
id: cfg.id,
|
|
7985
|
-
model,
|
|
7986
|
-
dimension,
|
|
7987
|
-
stats: () => ({ ...stats }),
|
|
7988
|
-
embed: (texts) => embedTexts({
|
|
7989
|
-
texts,
|
|
7990
|
-
cache,
|
|
7991
|
-
stats,
|
|
7992
|
-
model,
|
|
7993
|
-
dimension,
|
|
7994
|
-
apiKey,
|
|
7995
|
-
baseUrl,
|
|
7996
|
-
embeddingsPath,
|
|
7997
|
-
fetchImpl,
|
|
7998
|
-
providerId: cfg.id
|
|
7999
|
-
})
|
|
8000
|
-
};
|
|
8001
|
-
}
|
|
8002
|
-
async function embedTexts(input) {
|
|
8003
|
-
const { texts, cache, stats, model, dimension } = input;
|
|
8004
|
-
const results = new Array(texts.length);
|
|
8005
|
-
const pending = [];
|
|
8006
|
-
for (let i = 0; i < texts.length; i++) {
|
|
8007
|
-
classifyEntry({
|
|
8008
|
-
index: i,
|
|
8009
|
-
text: texts[i] ?? "",
|
|
8010
|
-
model,
|
|
8011
|
-
dimension,
|
|
8012
|
-
cache,
|
|
8013
|
-
stats,
|
|
8014
|
-
results,
|
|
8015
|
-
pending
|
|
8016
|
-
});
|
|
8017
|
-
}
|
|
8018
|
-
await embedInBoundedBatches(input, pending, results);
|
|
8019
|
-
return results.map((v) => v ?? new Array(dimension).fill(0));
|
|
8020
|
-
}
|
|
8021
|
-
function classifyEntry(args) {
|
|
8022
|
-
if (args.text.trim().length === 0) {
|
|
8023
|
-
args.results[args.index] = new Array(args.dimension).fill(0);
|
|
8024
|
-
return;
|
|
8025
|
-
}
|
|
8026
|
-
const key = hashKey(args.model, args.text);
|
|
8027
|
-
const cached = args.cache.get(key);
|
|
8028
|
-
if (cached !== void 0) {
|
|
8029
|
-
args.stats.cacheHits += 1;
|
|
8030
|
-
args.results[args.index] = cached;
|
|
8031
|
-
return;
|
|
8032
|
-
}
|
|
8033
|
-
args.stats.cacheMisses += 1;
|
|
8034
|
-
args.pending.push({ index: args.index, text: args.text, key });
|
|
8035
|
-
}
|
|
8036
|
-
var MAX_CONCURRENT_BATCHES = 3;
|
|
8037
|
-
async function embedInBoundedBatches(input, pending, results) {
|
|
8038
|
-
const batches = [];
|
|
8039
|
-
for (let offset = 0; offset < pending.length; offset += MAX_BATCH) {
|
|
8040
|
-
batches.push(pending.slice(offset, offset + MAX_BATCH));
|
|
8041
|
-
}
|
|
8042
|
-
await mapWithConcurrency(
|
|
8043
|
-
batches,
|
|
8044
|
-
MAX_CONCURRENT_BATCHES,
|
|
8045
|
-
(batch) => processBatch(input, batch, results)
|
|
8046
|
-
);
|
|
8047
|
-
}
|
|
8048
|
-
async function processBatch(input, batch, results) {
|
|
8049
|
-
const vectors = await embedBatch({
|
|
8050
|
-
apiKey: input.apiKey,
|
|
8051
|
-
baseUrl: input.baseUrl,
|
|
8052
|
-
embeddingsPath: input.embeddingsPath,
|
|
8053
|
-
model: input.model,
|
|
8054
|
-
inputs: batch.map((b) => b.text),
|
|
8055
|
-
fetchImpl: input.fetchImpl,
|
|
8056
|
-
stats: input.stats,
|
|
8057
|
-
providerId: input.providerId
|
|
8058
|
-
});
|
|
8059
|
-
for (let j = 0; j < batch.length; j++) {
|
|
8060
|
-
const slot = batch[j];
|
|
8061
|
-
const vector = vectors[j];
|
|
8062
|
-
if (slot === void 0 || vector === void 0) continue;
|
|
8063
|
-
results[slot.index] = vector;
|
|
8064
|
-
input.cache.set(slot.key, vector);
|
|
8065
|
-
}
|
|
8066
|
-
}
|
|
8067
|
-
async function embedBatch(opts) {
|
|
8068
|
-
const url = `${opts.baseUrl.replace(/\/$/, "")}${opts.embeddingsPath}`;
|
|
8069
|
-
let attempt = 0;
|
|
8070
|
-
while (true) {
|
|
8071
|
-
opts.stats.httpCalls += 1;
|
|
8072
|
-
const response = await postEmbedRequest(opts, url);
|
|
8073
|
-
if (response.ok)
|
|
8074
|
-
return await parseEmbedResponse(response, opts.providerId, opts.embeddingsPath);
|
|
8075
|
-
if (isRetryable(response.status) && attempt < MAX_RETRIES) {
|
|
8076
|
-
attempt += 1;
|
|
8077
|
-
opts.stats.retries += 1;
|
|
8078
|
-
await sleep(linearBackoffMs(attempt));
|
|
8079
|
-
continue;
|
|
8080
|
-
}
|
|
8081
|
-
const text = await response.text().catch(() => "");
|
|
8082
|
-
let body = text;
|
|
8083
|
-
try {
|
|
8084
|
-
body = JSON.parse(text);
|
|
8085
|
-
} catch {
|
|
8086
|
-
}
|
|
8087
|
-
throw mapOpenAICompatibleError({
|
|
8088
|
-
providerId: opts.providerId,
|
|
8089
|
-
status: response.status,
|
|
8090
|
-
body,
|
|
8091
|
-
headers: response.headers,
|
|
8092
|
-
endpoint: opts.embeddingsPath
|
|
8093
|
-
});
|
|
8094
|
-
}
|
|
8095
|
-
}
|
|
8096
|
-
async function postEmbedRequest(opts, url) {
|
|
8097
|
-
return opts.fetchImpl(url, {
|
|
8098
|
-
method: "POST",
|
|
8099
|
-
headers: {
|
|
8100
|
-
"content-type": "application/json",
|
|
8101
|
-
authorization: `Bearer ${opts.apiKey}`
|
|
8102
|
-
},
|
|
8103
|
-
body: JSON.stringify({ model: opts.model, input: opts.inputs })
|
|
8104
|
-
});
|
|
8105
|
-
}
|
|
8106
|
-
async function parseEmbedResponse(response, providerId, endpoint) {
|
|
8107
|
-
const json = await response.json();
|
|
8108
|
-
if (!Array.isArray(json.data)) {
|
|
8109
|
-
throw new NetworkError(`${providerId} ${endpoint} returned no data`, {
|
|
8110
|
-
code: "embedding_invalid_response",
|
|
8111
|
-
metadata: {
|
|
8112
|
-
provider: providerId,
|
|
8113
|
-
endpoint,
|
|
8114
|
-
code: "invalid_request",
|
|
8115
|
-
raw: json
|
|
8116
|
-
}
|
|
8117
|
-
});
|
|
8118
|
-
}
|
|
8119
|
-
return json.data.map((d) => d.embedding);
|
|
8120
|
-
}
|
|
8121
|
-
function isRetryable(status) {
|
|
8122
|
-
return status === 429 || status >= 500 && status < 600;
|
|
8123
|
-
}
|
|
8124
|
-
function hashKey(model, text) {
|
|
8125
|
-
return createHash("sha256").update(`${model} ${text}`).digest("hex");
|
|
8126
|
-
}
|
|
8127
|
-
function linearBackoffMs(attempt) {
|
|
8128
|
-
return 50 * attempt;
|
|
8129
|
-
}
|
|
8130
|
-
function sleep(ms) {
|
|
8131
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
8132
|
-
}
|
|
8133
8150
|
|
|
8134
8151
|
// src/internal/memory/adapters/azure-openai-embedding.ts
|
|
8135
8152
|
var DEFAULT_AZURE_OPENAI_EMBEDDING_MODEL = "text-embedding-3-small";
|
|
@@ -8152,7 +8169,15 @@ var azureOpenAiMemoryEmbeddingProviderAdapter = {
|
|
|
8152
8169
|
baseUrlEnv: "AZURE_OPENAI_ENDPOINT",
|
|
8153
8170
|
defaultModel: DEFAULT_AZURE_OPENAI_EMBEDDING_MODEL,
|
|
8154
8171
|
embeddingsPath: "/openai/deployments/{model}/embeddings?api-version=2024-02-01",
|
|
8155
|
-
dimensionByModel: DIMENSION_BY_MODEL
|
|
8172
|
+
dimensionByModel: DIMENSION_BY_MODEL,
|
|
8173
|
+
// theokit#159 — Azure is NOT OpenAI on the wire, despite the name. It authenticates an API
|
|
8174
|
+
// key with the `api-key` header (`Authorization: Bearer` is for Entra ID tokens, not for
|
|
8175
|
+
// AZURE_OPENAI_API_KEY), and the deployment already rides in the path, so `model` has no
|
|
8176
|
+
// place in the body. Sending the OpenAI shape meant every request was rejected.
|
|
8177
|
+
dialect: {
|
|
8178
|
+
authHeaders: (apiKey) => ({ "api-key": apiKey }),
|
|
8179
|
+
body: (_model, inputs) => ({ input: inputs })
|
|
8180
|
+
}
|
|
8156
8181
|
},
|
|
8157
8182
|
options
|
|
8158
8183
|
)
|
|
@@ -8179,7 +8204,20 @@ var cohereMemoryEmbeddingProviderAdapter = {
|
|
|
8179
8204
|
apiKeyEnv: "COHERE_API_KEY",
|
|
8180
8205
|
defaultModel: DEFAULT_COHERE_EMBEDDING_MODEL,
|
|
8181
8206
|
embeddingsPath: "/v2/embed",
|
|
8182
|
-
dimensionByModel: DIMENSION_BY_MODEL2
|
|
8207
|
+
dimensionByModel: DIMENSION_BY_MODEL2,
|
|
8208
|
+
// theokit#159 — `/v2/embed` diverges in BOTH directions: it names the payload `texts`, requires
|
|
8209
|
+
// `input_type`, and answers `{embeddings:{float:[[...]]}}` rather than `{data:[{embedding}]}`.
|
|
8210
|
+
// `search_document` is the right default here because this runtime embeds material for
|
|
8211
|
+
// storage; a query-side embedder would use `search_query`.
|
|
8212
|
+
dialect: {
|
|
8213
|
+
body: (model, inputs) => ({
|
|
8214
|
+
model,
|
|
8215
|
+
texts: [...inputs],
|
|
8216
|
+
input_type: "search_document",
|
|
8217
|
+
embedding_types: ["float"]
|
|
8218
|
+
}),
|
|
8219
|
+
vectors: (json) => json.embeddings?.float
|
|
8220
|
+
}
|
|
8183
8221
|
},
|
|
8184
8222
|
options
|
|
8185
8223
|
)
|
|
@@ -8237,6 +8275,9 @@ var geminiMemoryEmbeddingProviderAdapter = {
|
|
|
8237
8275
|
defaultBaseUrl: "https://generativelanguage.googleapis.com",
|
|
8238
8276
|
apiKeyEnv: "GEMINI_API_KEY",
|
|
8239
8277
|
defaultModel: DEFAULT_GEMINI_EMBEDDING_MODEL,
|
|
8278
|
+
// theokit#159 — the compat surface is under `/v1beta/openai/`, not the default
|
|
8279
|
+
// `/v1/embeddings`; the previous path 404'd on every call.
|
|
8280
|
+
embeddingsPath: "/v1beta/openai/embeddings",
|
|
8240
8281
|
dimensionByModel: DIMENSION_BY_MODEL4
|
|
8241
8282
|
},
|
|
8242
8283
|
options
|
|
@@ -9047,9 +9088,9 @@ async function localAgentUsePersonality(args) {
|
|
|
9047
9088
|
// src/internal/local-agent/local-agent-runtime-extensions.ts
|
|
9048
9089
|
function localAgentRunUntil(agent, goal, options) {
|
|
9049
9090
|
async function* wrap() {
|
|
9050
|
-
const { runUntilImpl } = await import('./run-until-
|
|
9091
|
+
const { runUntilImpl } = await import('./run-until-BK56WG4P.js');
|
|
9051
9092
|
const buildDeps = async () => {
|
|
9052
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9093
|
+
const { judgeCallImpl } = await import('./judge-call-NA2G6ZMJ.js');
|
|
9053
9094
|
const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
|
|
9054
9095
|
const create = getAgentFacade().create;
|
|
9055
9096
|
return {
|
|
@@ -9082,7 +9123,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
|
|
|
9082
9123
|
async function localAgentFork(parent, options) {
|
|
9083
9124
|
const { forkAgentImpl } = await import('./fork-agent-RSV4E3EA.js');
|
|
9084
9125
|
const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
|
|
9085
|
-
const { withPersonalityContext } = await import('./context-
|
|
9126
|
+
const { withPersonalityContext } = await import('./context-ATJJAFOS.js');
|
|
9086
9127
|
const create = getAgentFacade().create;
|
|
9087
9128
|
return withPersonalityContext(
|
|
9088
9129
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
@@ -9238,6 +9279,9 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
9238
9279
|
"cancel",
|
|
9239
9280
|
"conversation"
|
|
9240
9281
|
]);
|
|
9282
|
+
function emptyTimeline() {
|
|
9283
|
+
return emptyStream();
|
|
9284
|
+
}
|
|
9241
9285
|
function emptyStream() {
|
|
9242
9286
|
return {
|
|
9243
9287
|
next: () => Promise.resolve({ done: true, value: void 0 }),
|
|
@@ -9262,6 +9306,9 @@ function createTripwireRun(args) {
|
|
|
9262
9306
|
status: "cancelled",
|
|
9263
9307
|
...args.model !== void 0 ? { model: args.model } : {},
|
|
9264
9308
|
stream: () => emptyStream(),
|
|
9309
|
+
// theokit#140 - a tripwire run never executed, so its timeline is empty by construction, the
|
|
9310
|
+
// same reason `stream()` is. Both are empty for the same fact, not by coincidence.
|
|
9311
|
+
events: () => emptyTimeline(),
|
|
9265
9312
|
wait: () => Promise.resolve(result),
|
|
9266
9313
|
cancel: () => Promise.resolve(),
|
|
9267
9314
|
conversation: () => Promise.resolve([]),
|
|
@@ -9457,7 +9504,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9457
9504
|
function buildCompletionCheckDeps() {
|
|
9458
9505
|
return {
|
|
9459
9506
|
judge: async (ctx, opts) => {
|
|
9460
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9507
|
+
const { judgeCallImpl } = await import('./judge-call-NA2G6ZMJ.js');
|
|
9461
9508
|
const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
|
|
9462
9509
|
return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
|
|
9463
9510
|
}
|
|
@@ -9609,12 +9656,12 @@ var LocalAgent = class {
|
|
|
9609
9656
|
this.settingSourcesIncludeProject,
|
|
9610
9657
|
this.options.agents
|
|
9611
9658
|
);
|
|
9612
|
-
await
|
|
9659
|
+
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9613
9660
|
try {
|
|
9614
9661
|
await hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9615
9662
|
await this.personalityStore.hydrate(this.agentId);
|
|
9616
9663
|
} catch (err) {
|
|
9617
|
-
await
|
|
9664
|
+
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9618
9665
|
throw err;
|
|
9619
9666
|
}
|
|
9620
9667
|
}
|
|
@@ -9647,16 +9694,16 @@ var LocalAgent = class {
|
|
|
9647
9694
|
});
|
|
9648
9695
|
}
|
|
9649
9696
|
/**
|
|
9650
|
-
*
|
|
9697
|
+
* The context window declared on the model selection, in conditional-spread form.
|
|
9651
9698
|
*
|
|
9652
|
-
* M94 —
|
|
9653
|
-
* call site
|
|
9654
|
-
*
|
|
9655
|
-
*
|
|
9699
|
+
* M94 — without this, `resolveEffectiveContextWindow`'s `override` had existed since M77 and no
|
|
9700
|
+
* production call site passed it: a 400k model with no catalog entry was budgeted against the
|
|
9701
|
+
* 128k floor. Its own method because the inline spread pushed `runLockedSendCycle` past the
|
|
9702
|
+
* project's cognitive-complexity ceiling.
|
|
9656
9703
|
*/
|
|
9657
|
-
#
|
|
9658
|
-
const
|
|
9659
|
-
return
|
|
9704
|
+
#declaredWindow() {
|
|
9705
|
+
const declared = this.model?.contextWindow;
|
|
9706
|
+
return declared !== void 0 ? { contextWindow: declared } : {};
|
|
9660
9707
|
}
|
|
9661
9708
|
async runLockedSendCycle(message, options, sendSpan, resolve, reject) {
|
|
9662
9709
|
const userText = typeof message === "string" ? message : message.text;
|
|
@@ -9685,7 +9732,7 @@ var LocalAgent = class {
|
|
|
9685
9732
|
workspaceCwd: this.workspaceCwd,
|
|
9686
9733
|
sessionStore: this.sessionStore,
|
|
9687
9734
|
model: this.model?.id ?? "unknown",
|
|
9688
|
-
...this.#
|
|
9735
|
+
...this.#declaredWindow(),
|
|
9689
9736
|
// M50 — the auto-compaction summarizer resolves credentials like the run itself.
|
|
9690
9737
|
...this.options.apiKey !== void 0 ? { apiKey: this.options.apiKey } : {},
|
|
9691
9738
|
...options.onRunEvent !== void 0 ? { onRunEvent: options.onRunEvent } : {},
|
|
@@ -10215,7 +10262,7 @@ var Agent = class _Agent {
|
|
|
10215
10262
|
* @public
|
|
10216
10263
|
*/
|
|
10217
10264
|
static async generateObject(options) {
|
|
10218
|
-
const { generateObjectImpl } = await import('./generate-object-
|
|
10265
|
+
const { generateObjectImpl } = await import('./generate-object-XDCBYVK3.js');
|
|
10219
10266
|
return generateObjectImpl(options, {
|
|
10220
10267
|
create: (opts) => _Agent.create(opts),
|
|
10221
10268
|
delete: (agentId) => _Agent.delete(agentId)
|
|
@@ -10239,7 +10286,7 @@ var Agent = class _Agent {
|
|
|
10239
10286
|
delete: (agentId) => _Agent.delete(agentId)
|
|
10240
10287
|
};
|
|
10241
10288
|
async function* wrapper() {
|
|
10242
|
-
streamObjectImport ??= import('./stream-object-
|
|
10289
|
+
streamObjectImport ??= import('./stream-object-HWDEEQN4.js');
|
|
10243
10290
|
const { streamObjectImpl } = await streamObjectImport;
|
|
10244
10291
|
yield* streamObjectImpl(options, deps);
|
|
10245
10292
|
}
|
|
@@ -10263,7 +10310,7 @@ var Agent = class _Agent {
|
|
|
10263
10310
|
* @public
|
|
10264
10311
|
*/
|
|
10265
10312
|
static async batch(prompts, options) {
|
|
10266
|
-
const { batchImpl } = await import('./batch-
|
|
10313
|
+
const { batchImpl } = await import('./batch-6KQM3EBA.js');
|
|
10267
10314
|
return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
|
|
10268
10315
|
}
|
|
10269
10316
|
/**
|
|
@@ -10287,7 +10334,7 @@ var Agent = class _Agent {
|
|
|
10287
10334
|
*
|
|
10288
10335
|
* This bullet used to say the opposite ("Disposed agents are NOT auto-deleted...
|
|
10289
10336
|
* call `Agent.delete(agentId)` first"). It was measured false in M91:
|
|
10290
|
-
* `tests/m91-getorcreate-
|
|
10337
|
+
* `tests/m91-getorcreate-after-dispose.test.ts` builds an agent, disposes it, and
|
|
10291
10338
|
* gets a different instance back. The claim was about the PERSISTENT registry and
|
|
10292
10339
|
* read as being about the live cache — and consumers built around the wrong half.
|
|
10293
10340
|
* The agent-builder's M85 interrupt rotates the session id to work around a
|
|
@@ -10401,8 +10448,8 @@ var Agent = class _Agent {
|
|
|
10401
10448
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10402
10449
|
);
|
|
10403
10450
|
}
|
|
10404
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10405
|
-
const { cwd, model, store } = await
|
|
10451
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-PYEC3NZV.js');
|
|
10452
|
+
const { cwd, model, store } = await openLocalStore(reg);
|
|
10406
10453
|
return enqueueSessionWrite(
|
|
10407
10454
|
cwd,
|
|
10408
10455
|
agentId,
|
|
@@ -10437,8 +10484,8 @@ var Agent = class _Agent {
|
|
|
10437
10484
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10438
10485
|
);
|
|
10439
10486
|
}
|
|
10440
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10441
|
-
const { cwd, model, store } = await
|
|
10487
|
+
const { injectSessionTurn } = await import('./inject-session-GQMTDZUN.js');
|
|
10488
|
+
const { cwd, model, store } = await openLocalStore(reg);
|
|
10442
10489
|
await injectSessionTurn({
|
|
10443
10490
|
store,
|
|
10444
10491
|
loc: { cwd, agentId, model },
|
|
@@ -10447,6 +10494,86 @@ var Agent = class _Agent {
|
|
|
10447
10494
|
assistantText: turn.assistantText
|
|
10448
10495
|
});
|
|
10449
10496
|
}
|
|
10497
|
+
/**
|
|
10498
|
+
* theokit#146 — read a LOCAL agent's persisted transcript as STRUCTURE, for rendering.
|
|
10499
|
+
*
|
|
10500
|
+
* A resumed session already replays correctly to the model, but a host had no way to draw it:
|
|
10501
|
+
* the only projection available folded a tool call to the string `[tool call] NAME`, dropping the
|
|
10502
|
+
* call id and every argument. A card UI got prose, so cross-restart resume was worth less than
|
|
10503
|
+
* starting fresh — which is what at least one consumer did.
|
|
10504
|
+
*
|
|
10505
|
+
* Each returned message carries both projections: `text` (unchanged, what the model replay uses)
|
|
10506
|
+
* and `parts` (`text` / `tool_use` / `tool_result` with ids, names, arguments and the
|
|
10507
|
+
* `toolUseId` that correlates a result back to its call).
|
|
10508
|
+
*
|
|
10509
|
+
* Read-only and local-only: it opens the agent's session store and walks the transcript, exactly
|
|
10510
|
+
* as {@link Agent.compact} and {@link Agent.injectSessionTurn} do. It appends nothing.
|
|
10511
|
+
*
|
|
10512
|
+
* @throws UnknownAgentError when `agentId` names no local agent.
|
|
10513
|
+
* @public
|
|
10514
|
+
*/
|
|
10515
|
+
static async transcript(agentId) {
|
|
10516
|
+
let reg = getRegisteredAgent(agentId);
|
|
10517
|
+
if (reg === void 0) {
|
|
10518
|
+
await hydrateRegistryFromDisk(process.cwd());
|
|
10519
|
+
reg = getRegisteredAgent(agentId);
|
|
10520
|
+
}
|
|
10521
|
+
if (reg === void 0 || reg.runtime !== "local") {
|
|
10522
|
+
throw new UnknownAgentError(
|
|
10523
|
+
`No local agent "${agentId}" registered \u2014 transcript targets local sessions.`
|
|
10524
|
+
);
|
|
10525
|
+
}
|
|
10526
|
+
const { readSessionMessages } = await import('./agent-session-store-RHMHP5DG.js');
|
|
10527
|
+
const { store } = await openLocalStore(reg);
|
|
10528
|
+
return readSessionMessages(store, agentId);
|
|
10529
|
+
}
|
|
10530
|
+
/**
|
|
10531
|
+
* theokit#123 — read-only introspection of a registered agent's tools and subagents.
|
|
10532
|
+
*
|
|
10533
|
+
* `Agent.list()` / `Agent.get()` enumerate agents and `agent.skills.list()` covers skills, but
|
|
10534
|
+
* tools and subagents lived only on `RegisteredAgent.options` — an internal contract. A
|
|
10535
|
+
* reflection endpoint (theokit-studio's `theokit dev`) therefore had to report empty lists for
|
|
10536
|
+
* both, and say so with an `unavailable_reason`.
|
|
10537
|
+
*
|
|
10538
|
+
* A PROJECTION, not the options object. Tool handlers and subagent prompts are stripped: a
|
|
10539
|
+
* handler is an executable that cannot cross a process boundary, and a prompt is the agent's
|
|
10540
|
+
* instructions rather than its signature — a reflection endpoint serializes what it is handed.
|
|
10541
|
+
*
|
|
10542
|
+
* @throws UnknownAgentError when `agentId` names no registered agent.
|
|
10543
|
+
* @public
|
|
10544
|
+
*/
|
|
10545
|
+
static async describe(agentId) {
|
|
10546
|
+
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10547
|
+
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-X33KH2SZ.js');
|
|
10548
|
+
const settingSources = agent.options.local?.settingSources;
|
|
10549
|
+
const subagents = await loadSubagents2(
|
|
10550
|
+
agent.cwd ?? process.cwd(),
|
|
10551
|
+
settingSources === void 0 || settingSources.includes("project"),
|
|
10552
|
+
agent.options.agents
|
|
10553
|
+
);
|
|
10554
|
+
return {
|
|
10555
|
+
agentId: agent.agentId,
|
|
10556
|
+
runtime: agent.runtime,
|
|
10557
|
+
...agent.model !== void 0 ? { model: agent.model } : {},
|
|
10558
|
+
// Always arrays, so a caller can tell "this agent has none" from "the SDK did not say".
|
|
10559
|
+
//
|
|
10560
|
+
// Honest limit, stated because the alternative is an implied claim: `tools` is still the
|
|
10561
|
+
// DECLARED catalog. Plugin tools and the reasoning `think` tool are assembled per run by
|
|
10562
|
+
// `buildCustomToolsInput`, so they are not knowable from the registry alone. Documented on
|
|
10563
|
+
// `AgentDescription.tools`.
|
|
10564
|
+
tools: (agent.options.tools ?? []).map((tool) => ({
|
|
10565
|
+
name: tool.name,
|
|
10566
|
+
description: tool.description,
|
|
10567
|
+
inputSchema: tool.inputSchema
|
|
10568
|
+
})),
|
|
10569
|
+
subagents: Object.entries(subagents).map(([name, def]) => ({
|
|
10570
|
+
name,
|
|
10571
|
+
description: def.description,
|
|
10572
|
+
...def.model !== void 0 ? { model: def.model } : {},
|
|
10573
|
+
...def.tools !== void 0 ? { tools: def.tools } : {}
|
|
10574
|
+
}))
|
|
10575
|
+
};
|
|
10576
|
+
}
|
|
10450
10577
|
/**
|
|
10451
10578
|
* Permanently delete a cloud agent.
|
|
10452
10579
|
*
|
|
@@ -10480,16 +10607,16 @@ setAgentFacade({
|
|
|
10480
10607
|
resume: (agentId, options) => Agent.resume(agentId, options),
|
|
10481
10608
|
batch: (prompts, options) => Agent.batch(prompts, options)
|
|
10482
10609
|
});
|
|
10483
|
-
async function
|
|
10610
|
+
async function openLocalStore(reg) {
|
|
10484
10611
|
const cwd = reg.cwd ?? process.cwd();
|
|
10485
10612
|
const optModel = reg.options.model;
|
|
10486
10613
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
10487
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
10488
|
-
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-
|
|
10614
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-O6FNHECD.js');
|
|
10615
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-3B52DKTG.js');
|
|
10489
10616
|
const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
|
|
10490
10617
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
10491
10618
|
}
|
|
10492
10619
|
|
|
10493
10620
|
export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, openRouterMemoryEmbeddingProviderAdapter, resolveApiKey };
|
|
10494
|
-
//# sourceMappingURL=chunk-
|
|
10495
|
-
//# sourceMappingURL=chunk-
|
|
10621
|
+
//# sourceMappingURL=chunk-GIRD3RWH.js.map
|
|
10622
|
+
//# sourceMappingURL=chunk-GIRD3RWH.js.map
|