@theokit/sdk 4.37.2 → 4.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/CHANGELOG.md +72 -72
  2. package/dist/agent-2GZC4W2A.cjs +51 -0
  3. package/dist/{agent-IE6IE4NW.cjs.map → agent-2GZC4W2A.cjs.map} +1 -1
  4. package/dist/agent-3H3UKD6U.js +42 -0
  5. package/dist/{agent-DW2J37IH.js.map → agent-3H3UKD6U.js.map} +1 -1
  6. package/dist/{agent-SmxntivO.d.ts → agent-C3AEtM-W.d.ts} +39 -37
  7. package/dist/{agent-DGv1-d81.d.cts → agent-U3lBX-5t.d.cts} +39 -37
  8. package/dist/agent.d.ts +1 -1
  9. package/dist/auth/index.cjs +15 -15
  10. package/dist/auth/index.js +4 -4
  11. package/dist/{batch-SY5GZLFD.js → batch-LXSALQC3.js} +9 -9
  12. package/dist/{batch-SY5GZLFD.js.map → batch-LXSALQC3.js.map} +1 -1
  13. package/dist/{batch-3SEPDXCU.cjs → batch-NZGN6SFV.cjs} +23 -23
  14. package/dist/{batch-3SEPDXCU.cjs.map → batch-NZGN6SFV.cjs.map} +1 -1
  15. package/dist/{chunk-D4ZUJTFB.cjs → chunk-2K7PRHDB.cjs} +8 -8
  16. package/dist/{chunk-D4ZUJTFB.cjs.map → chunk-2K7PRHDB.cjs.map} +1 -1
  17. package/dist/chunk-2R6NBT5F.cjs +112 -0
  18. package/dist/chunk-2R6NBT5F.cjs.map +1 -0
  19. package/dist/{chunk-2423XDPT.cjs → chunk-3BSP7LSG.cjs} +26 -26
  20. package/dist/{chunk-2423XDPT.cjs.map → chunk-3BSP7LSG.cjs.map} +1 -1
  21. package/dist/{chunk-6EDQBX7U.cjs → chunk-3MUIYMUG.cjs} +17 -17
  22. package/dist/{chunk-6EDQBX7U.cjs.map → chunk-3MUIYMUG.cjs.map} +1 -1
  23. package/dist/{chunk-P34DHHYQ.cjs → chunk-3VKTDQMX.cjs} +34 -27
  24. package/dist/chunk-3VKTDQMX.cjs.map +1 -0
  25. package/dist/{chunk-77WHPVXE.js → chunk-3XKVRLR2.js} +4 -4
  26. package/dist/chunk-3XKVRLR2.js.map +1 -0
  27. package/dist/{chunk-SWIBQFPH.cjs → chunk-3XRXORBS.cjs} +4 -4
  28. package/dist/{chunk-SWIBQFPH.cjs.map → chunk-3XRXORBS.cjs.map} +1 -1
  29. package/dist/{chunk-DCJ5MCJ3.js → chunk-4APWS2YF.js} +7 -7
  30. package/dist/{chunk-DCJ5MCJ3.js.map → chunk-4APWS2YF.js.map} +1 -1
  31. package/dist/{chunk-56ZM6P7Z.cjs → chunk-4MWBKBS4.cjs} +12 -12
  32. package/dist/chunk-4MWBKBS4.cjs.map +1 -0
  33. package/dist/chunk-4NVV3GRU.js +110 -0
  34. package/dist/chunk-4NVV3GRU.js.map +1 -0
  35. package/dist/{chunk-QGDKZDPN.js → chunk-4WIJSKFA.js} +3 -3
  36. package/dist/{chunk-QGDKZDPN.js.map → chunk-4WIJSKFA.js.map} +1 -1
  37. package/dist/{chunk-VNNK6AKU.js → chunk-5BVBNE2F.js} +3 -3
  38. package/dist/chunk-5BVBNE2F.js.map +1 -0
  39. package/dist/{chunk-EEZ7CFMM.js → chunk-5KOW3GLE.js} +2 -2
  40. package/dist/chunk-5KOW3GLE.js.map +1 -0
  41. package/dist/{chunk-FK4EJD2I.cjs → chunk-6OIO4FYX.cjs} +7 -7
  42. package/dist/{chunk-FK4EJD2I.cjs.map → chunk-6OIO4FYX.cjs.map} +1 -1
  43. package/dist/{chunk-IEUDKUPM.cjs → chunk-6OKPJZMX.cjs} +8 -8
  44. package/dist/{chunk-IEUDKUPM.cjs.map → chunk-6OKPJZMX.cjs.map} +1 -1
  45. package/dist/{chunk-QFMXXUUT.js → chunk-6XZBKFQ7.js} +3 -3
  46. package/dist/{chunk-QFMXXUUT.js.map → chunk-6XZBKFQ7.js.map} +1 -1
  47. package/dist/{chunk-H5YVJB4K.cjs → chunk-6ZGD7R27.cjs} +37 -37
  48. package/dist/chunk-6ZGD7R27.cjs.map +1 -0
  49. package/dist/{chunk-HEN5WXXI.js → chunk-7QDTZJRV.js} +6 -6
  50. package/dist/{chunk-HEN5WXXI.js.map → chunk-7QDTZJRV.js.map} +1 -1
  51. package/dist/{chunk-MHCKWQR3.cjs → chunk-A3MHE2MQ.cjs} +8 -8
  52. package/dist/{chunk-MHCKWQR3.cjs.map → chunk-A3MHE2MQ.cjs.map} +1 -1
  53. package/dist/{chunk-5SB4V74H.js → chunk-A4XXV2C6.js} +18 -18
  54. package/dist/chunk-A4XXV2C6.js.map +1 -0
  55. package/dist/{chunk-6VP3XGEK.js → chunk-A6GXYF2Q.js} +9 -9
  56. package/dist/{chunk-6VP3XGEK.js.map → chunk-A6GXYF2Q.js.map} +1 -1
  57. package/dist/{chunk-SDIBMLL5.js → chunk-ACHGT3D2.js} +8 -8
  58. package/dist/{chunk-SDIBMLL5.js.map → chunk-ACHGT3D2.js.map} +1 -1
  59. package/dist/{chunk-XAEAMI5H.js → chunk-AOZYORH7.js} +4 -4
  60. package/dist/chunk-AOZYORH7.js.map +1 -0
  61. package/dist/{chunk-LTCOPATU.cjs → chunk-BE3W4HYV.cjs} +2 -2
  62. package/dist/chunk-BE3W4HYV.cjs.map +1 -0
  63. package/dist/{chunk-NQ4AC2U4.cjs → chunk-BT6DFWZB.cjs} +9 -9
  64. package/dist/{chunk-NQ4AC2U4.cjs.map → chunk-BT6DFWZB.cjs.map} +1 -1
  65. package/dist/{chunk-XAYVHS2B.cjs → chunk-BUGVDCI5.cjs} +4 -4
  66. package/dist/{chunk-XAYVHS2B.cjs.map → chunk-BUGVDCI5.cjs.map} +1 -1
  67. package/dist/{chunk-IT3PWBW4.cjs → chunk-BURYFNOM.cjs} +2 -2
  68. package/dist/chunk-BURYFNOM.cjs.map +1 -0
  69. package/dist/{chunk-NNSKJCBM.cjs → chunk-D3SJLXYZ.cjs} +10 -10
  70. package/dist/{chunk-NNSKJCBM.cjs.map → chunk-D3SJLXYZ.cjs.map} +1 -1
  71. package/dist/{chunk-MRODLUGY.cjs → chunk-ED7ANP6W.cjs} +4 -4
  72. package/dist/{chunk-MRODLUGY.cjs.map → chunk-ED7ANP6W.cjs.map} +1 -1
  73. package/dist/{chunk-MXSMAGDU.js → chunk-EDI7DBWO.js} +33 -26
  74. package/dist/chunk-EDI7DBWO.js.map +1 -0
  75. package/dist/{chunk-T4QWDOG6.js → chunk-EE24WJJR.js} +5 -5
  76. package/dist/{chunk-T4QWDOG6.js.map → chunk-EE24WJJR.js.map} +1 -1
  77. package/dist/{chunk-ZJN6NTHE.js → chunk-EUB7YLU2.js} +3 -3
  78. package/dist/{chunk-ZJN6NTHE.js.map → chunk-EUB7YLU2.js.map} +1 -1
  79. package/dist/{chunk-ALU3KC4G.cjs → chunk-G7X2Y7Y2.cjs} +156 -156
  80. package/dist/chunk-G7X2Y7Y2.cjs.map +1 -0
  81. package/dist/{chunk-YCXMSDSP.js → chunk-HHUDNTZC.js} +4 -4
  82. package/dist/{chunk-YCXMSDSP.js.map → chunk-HHUDNTZC.js.map} +1 -1
  83. package/dist/{chunk-GL7CFBVC.js → chunk-HI6G3SNY.js} +48 -48
  84. package/dist/chunk-HI6G3SNY.js.map +1 -0
  85. package/dist/{chunk-G6AASL5T.cjs → chunk-HLK35TD7.cjs} +24 -24
  86. package/dist/{chunk-G6AASL5T.cjs.map → chunk-HLK35TD7.cjs.map} +1 -1
  87. package/dist/{chunk-4YB7B3RP.cjs → chunk-IBDE4R5L.cjs} +13 -13
  88. package/dist/{chunk-4YB7B3RP.cjs.map → chunk-IBDE4R5L.cjs.map} +1 -1
  89. package/dist/{chunk-WDGCZDRG.js → chunk-JCXIDFRI.js} +3 -3
  90. package/dist/{chunk-WDGCZDRG.js.map → chunk-JCXIDFRI.js.map} +1 -1
  91. package/dist/{chunk-I35DI7ES.js → chunk-JI34KBNC.js} +3 -3
  92. package/dist/{chunk-I35DI7ES.js.map → chunk-JI34KBNC.js.map} +1 -1
  93. package/dist/{chunk-TAPQWDW2.js → chunk-KCZW75PI.js} +2 -2
  94. package/dist/chunk-KCZW75PI.js.map +1 -0
  95. package/dist/{chunk-U2WLFOA3.cjs → chunk-KL7E244K.cjs} +4 -4
  96. package/dist/{chunk-U2WLFOA3.cjs.map → chunk-KL7E244K.cjs.map} +1 -1
  97. package/dist/{chunk-PAEJPLVN.cjs → chunk-KTXOHCAE.cjs} +4 -4
  98. package/dist/{chunk-PAEJPLVN.cjs.map → chunk-KTXOHCAE.cjs.map} +1 -1
  99. package/dist/{chunk-2WFB5ZOX.js → chunk-KWXC6ERT.js} +5 -5
  100. package/dist/{chunk-2WFB5ZOX.js.map → chunk-KWXC6ERT.js.map} +1 -1
  101. package/dist/{chunk-56OXYUZE.js → chunk-LGCEYEU2.js} +3 -3
  102. package/dist/chunk-LGCEYEU2.js.map +1 -0
  103. package/dist/{chunk-FAY3QDGC.cjs → chunk-M4OGSS66.cjs} +11 -11
  104. package/dist/{chunk-FAY3QDGC.cjs.map → chunk-M4OGSS66.cjs.map} +1 -1
  105. package/dist/{chunk-F6Y4IEQM.js → chunk-M6UUTNDT.js} +4 -4
  106. package/dist/{chunk-F6Y4IEQM.js.map → chunk-M6UUTNDT.js.map} +1 -1
  107. package/dist/{chunk-GM7QDQ24.cjs → chunk-MXRBNJ6D.cjs} +11 -11
  108. package/dist/{chunk-GM7QDQ24.cjs.map → chunk-MXRBNJ6D.cjs.map} +1 -1
  109. package/dist/{chunk-YPQF26X7.cjs → chunk-OBA6YK2R.cjs} +2 -2
  110. package/dist/chunk-OBA6YK2R.cjs.map +1 -0
  111. package/dist/{chunk-BJMKQOY2.cjs → chunk-OFWU6UKF.cjs} +11 -11
  112. package/dist/{chunk-BJMKQOY2.cjs.map → chunk-OFWU6UKF.cjs.map} +1 -1
  113. package/dist/{chunk-3O2ELBST.cjs → chunk-PG3QQLWS.cjs} +5 -5
  114. package/dist/{chunk-3O2ELBST.cjs.map → chunk-PG3QQLWS.cjs.map} +1 -1
  115. package/dist/{chunk-2ONFGMBV.js → chunk-PY2RQOA7.js} +2 -2
  116. package/dist/chunk-PY2RQOA7.js.map +1 -0
  117. package/dist/{chunk-UQPDFW4E.js → chunk-QFWQLXCL.js} +3 -3
  118. package/dist/{chunk-UQPDFW4E.js.map → chunk-QFWQLXCL.js.map} +1 -1
  119. package/dist/{chunk-YBFDBOUN.cjs → chunk-QJQ2MAZF.cjs} +8 -8
  120. package/dist/{chunk-YBFDBOUN.cjs.map → chunk-QJQ2MAZF.cjs.map} +1 -1
  121. package/dist/{chunk-QUFSDDNU.cjs → chunk-R4AMI7KD.cjs} +15 -15
  122. package/dist/{chunk-QUFSDDNU.cjs.map → chunk-R4AMI7KD.cjs.map} +1 -1
  123. package/dist/{chunk-CSZRJ4RE.js → chunk-SGTMDQ4O.js} +5 -5
  124. package/dist/{chunk-CSZRJ4RE.js.map → chunk-SGTMDQ4O.js.map} +1 -1
  125. package/dist/{chunk-3ILFUXNE.cjs → chunk-SRIF7HMN.cjs} +5 -5
  126. package/dist/{chunk-3ILFUXNE.cjs.map → chunk-SRIF7HMN.cjs.map} +1 -1
  127. package/dist/{chunk-THEYGCYS.cjs → chunk-TKDWD3MU.cjs} +4 -4
  128. package/dist/chunk-TKDWD3MU.cjs.map +1 -0
  129. package/dist/{chunk-ZW345YOI.js → chunk-UD2T7ISG.js} +4 -4
  130. package/dist/{chunk-ZW345YOI.js.map → chunk-UD2T7ISG.js.map} +1 -1
  131. package/dist/{chunk-EXQV452X.js → chunk-UWEALKAN.js} +3 -3
  132. package/dist/{chunk-EXQV452X.js.map → chunk-UWEALKAN.js.map} +1 -1
  133. package/dist/{chunk-W52DKZBR.cjs → chunk-UZBA6YYP.cjs} +454 -333
  134. package/dist/chunk-UZBA6YYP.cjs.map +1 -0
  135. package/dist/{chunk-VYJSHGAY.js → chunk-VUDH4D2M.js} +201 -80
  136. package/dist/chunk-VUDH4D2M.js.map +1 -0
  137. package/dist/{chunk-W4QN5CMG.cjs → chunk-VVMLMKYZ.cjs} +9 -9
  138. package/dist/{chunk-W4QN5CMG.cjs.map → chunk-VVMLMKYZ.cjs.map} +1 -1
  139. package/dist/{chunk-JNIWFCKI.js → chunk-VYD6BGKK.js} +3 -3
  140. package/dist/{chunk-JNIWFCKI.js.map → chunk-VYD6BGKK.js.map} +1 -1
  141. package/dist/{chunk-YHZXBDAW.js → chunk-XJ5TMOGA.js} +16 -16
  142. package/dist/{chunk-YHZXBDAW.js.map → chunk-XJ5TMOGA.js.map} +1 -1
  143. package/dist/{chunk-7DXLNNKH.cjs → chunk-XKBJT7WI.cjs} +4 -4
  144. package/dist/{chunk-7DXLNNKH.cjs.map → chunk-XKBJT7WI.cjs.map} +1 -1
  145. package/dist/{chunk-YDLNI7J6.js → chunk-XS7SKY2F.js} +3 -3
  146. package/dist/{chunk-YDLNI7J6.js.map → chunk-XS7SKY2F.js.map} +1 -1
  147. package/dist/{chunk-NFCKEBHI.js → chunk-YCHC45BY.js} +3 -3
  148. package/dist/{chunk-NFCKEBHI.js.map → chunk-YCHC45BY.js.map} +1 -1
  149. package/dist/{chunk-ICYBIC6N.cjs → chunk-YVI4YPUP.cjs} +4 -4
  150. package/dist/chunk-YVI4YPUP.cjs.map +1 -0
  151. package/dist/{chunk-TQI3KRXZ.cjs → chunk-ZET34IZE.cjs} +18 -18
  152. package/dist/{chunk-TQI3KRXZ.cjs.map → chunk-ZET34IZE.cjs.map} +1 -1
  153. package/dist/{chunk-GLUWH6JO.js → chunk-ZFZYPLQI.js} +4 -4
  154. package/dist/{chunk-GLUWH6JO.js.map → chunk-ZFZYPLQI.js.map} +1 -1
  155. package/dist/{chunk-M5ZQBOIZ.js → chunk-ZK3BJ4XQ.js} +3 -3
  156. package/dist/{chunk-M5ZQBOIZ.js.map → chunk-ZK3BJ4XQ.js.map} +1 -1
  157. package/dist/{chunk-CD73YHEH.js → chunk-ZYOHF37V.js} +3 -3
  158. package/dist/{chunk-CD73YHEH.js.map → chunk-ZYOHF37V.js.map} +1 -1
  159. package/dist/compact-session-RR3ILTES.js +17 -0
  160. package/dist/{compact-session-WNKKIIDW.js.map → compact-session-RR3ILTES.js.map} +1 -1
  161. package/dist/compact-session-YOWJJPPB.cjs +54 -0
  162. package/dist/{compact-session-H5TKLD55.cjs.map → compact-session-YOWJJPPB.cjs.map} +1 -1
  163. package/dist/compaction.cjs +19 -19
  164. package/dist/compaction.d.cts +9 -9
  165. package/dist/compaction.d.ts +9 -9
  166. package/dist/compaction.js +3 -3
  167. package/dist/concurrency.cjs +6 -6
  168. package/dist/concurrency.js +4 -4
  169. package/dist/context-Q6ISOCN2.cjs +22 -0
  170. package/dist/{context-ZV33V4DC.cjs.map → context-Q6ISOCN2.cjs.map} +1 -1
  171. package/dist/context-ZDBBPIHY.js +5 -0
  172. package/dist/{context-VAYLPT4O.js.map → context-ZDBBPIHY.js.map} +1 -1
  173. package/dist/{cron-BiK_aNJI.d.cts → cron-BdXOZco9.d.cts} +2 -2
  174. package/dist/{cron-Dx7B-3WB.d.ts → cron-ChQ6zcW2.d.ts} +2 -2
  175. package/dist/cron.cjs +29 -29
  176. package/dist/cron.d.cts +3 -3
  177. package/dist/cron.d.ts +3 -3
  178. package/dist/cron.js +28 -28
  179. package/dist/{errors-DyVbXdR4.d.cts → errors-BUVjJGJA.d.cts} +1 -1
  180. package/dist/{errors-Cua4WC9H.d.ts → errors-CZIUKLHt.d.ts} +1 -1
  181. package/dist/errors.cjs +21 -21
  182. package/dist/errors.d.cts +2 -2
  183. package/dist/errors.d.ts +2 -2
  184. package/dist/errors.js +2 -2
  185. package/dist/eval.cjs +32 -32
  186. package/dist/eval.js +28 -28
  187. package/dist/{executor-PAH72CB5.js → executor-ASDDIM2X.js} +7 -7
  188. package/dist/{executor-PAH72CB5.js.map → executor-ASDDIM2X.js.map} +1 -1
  189. package/dist/{executor-OZSYXDKF.cjs → executor-DPCBSI35.cjs} +23 -23
  190. package/dist/{executor-OZSYXDKF.cjs.map → executor-DPCBSI35.cjs.map} +1 -1
  191. package/dist/filesystem/index.cjs +7 -7
  192. package/dist/filesystem/index.js +3 -3
  193. package/dist/fs-session-store-K5QUPNJZ.js +10 -0
  194. package/dist/{fs-session-store-6MY7PNI2.js.map → fs-session-store-K5QUPNJZ.js.map} +1 -1
  195. package/dist/fs-session-store-T5ZLQX42.cjs +19 -0
  196. package/dist/{fs-session-store-7E7UPLF2.cjs.map → fs-session-store-T5ZLQX42.cjs.map} +1 -1
  197. package/dist/generate-object-F56VIZ6U.cjs +20 -0
  198. package/dist/{generate-object-5SCEH2EE.cjs.map → generate-object-F56VIZ6U.cjs.map} +1 -1
  199. package/dist/generate-object-LPSO6GVW.js +7 -0
  200. package/dist/{generate-object-I7UD4NWN.js.map → generate-object-LPSO6GVW.js.map} +1 -1
  201. package/dist/index-manager-DBJ55ZSO.cjs +19 -0
  202. package/dist/{index-manager-R6ZJFEZF.cjs.map → index-manager-DBJ55ZSO.cjs.map} +1 -1
  203. package/dist/index-manager-F2H2RCZU.js +10 -0
  204. package/dist/{index-manager-KKAK7NT3.js.map → index-manager-F2H2RCZU.js.map} +1 -1
  205. package/dist/index.cjs +140 -140
  206. package/dist/index.cjs.map +1 -1
  207. package/dist/index.d.cts +42 -42
  208. package/dist/index.d.ts +42 -42
  209. package/dist/index.js +54 -54
  210. package/dist/index.js.map +1 -1
  211. package/dist/{inject-session-DM4SKTZO.cjs → inject-session-25EC74WV.cjs} +10 -10
  212. package/dist/{inject-session-DM4SKTZO.cjs.map → inject-session-25EC74WV.cjs.map} +1 -1
  213. package/dist/{inject-session-UXNJQTZ6.js → inject-session-RKNLUE72.js} +7 -7
  214. package/dist/{inject-session-UXNJQTZ6.js.map → inject-session-RKNLUE72.js.map} +1 -1
  215. package/dist/internal/agent-loop/live-events.d.ts +46 -0
  216. package/dist/internal/budget/compute-cost.d.ts +1 -1
  217. package/dist/internal/diagnostics.d.ts +31 -29
  218. package/dist/internal/error-mappers/anthropic.d.ts +1 -1
  219. package/dist/internal/global-singleton.d.ts +7 -7
  220. package/dist/internal/judge/judge-call.d.ts +14 -14
  221. package/dist/internal/llm/retrying-client.d.ts +29 -29
  222. package/dist/internal/llm/transport-error.d.ts +2 -2
  223. package/dist/internal/persistence/exclusive-create.d.cts +2 -2
  224. package/dist/internal/persistence/exclusive-create.d.ts +2 -2
  225. package/dist/internal/persistence/fs-session-store.d.cts +18 -18
  226. package/dist/internal/persistence/fs-session-store.d.ts +18 -18
  227. package/dist/internal/persistence/index.cjs +25 -25
  228. package/dist/internal/persistence/index.cjs.map +1 -1
  229. package/dist/internal/persistence/index.js +6 -6
  230. package/dist/internal/persistence/index.js.map +1 -1
  231. package/dist/internal/persistence/paths.d.cts +7 -7
  232. package/dist/internal/persistence/paths.d.ts +7 -7
  233. package/dist/internal/persistence/session-transcript.d.cts +7 -7
  234. package/dist/internal/persistence/session-transcript.d.ts +7 -7
  235. package/dist/internal/persistence/session-writer.d.cts +30 -13
  236. package/dist/internal/persistence/session-writer.d.ts +30 -13
  237. package/dist/internal/runtime/fixtures/fixture-run-base.d.ts +45 -13
  238. package/dist/internal/runtime/lifecycle/goal-marker.d.ts +8 -8
  239. package/dist/internal/security/index.cjs +13 -13
  240. package/dist/internal/security/index.js +3 -3
  241. package/dist/internal/session/agent-session.d.ts +14 -14
  242. package/dist/internal/session/session-cache.d.ts +9 -9
  243. package/dist/judge-call-3S3T6O2Z.js +5 -0
  244. package/dist/{judge-call-TAEIXMYG.js.map → judge-call-3S3T6O2Z.js.map} +1 -1
  245. package/dist/judge-call-XIQJ5GIE.cjs +22 -0
  246. package/dist/{judge-call-SP3G3X2Y.cjs.map → judge-call-XIQJ5GIE.cjs.map} +1 -1
  247. package/dist/models.cjs +20 -20
  248. package/dist/models.cjs.map +1 -1
  249. package/dist/models.js +5 -5
  250. package/dist/models.js.map +1 -1
  251. package/dist/path-safety.cjs +10 -10
  252. package/dist/path-safety.js +3 -3
  253. package/dist/persistence.cjs +34 -34
  254. package/dist/persistence.cjs.map +1 -1
  255. package/dist/persistence.d.cts +1 -1
  256. package/dist/persistence.d.ts +1 -1
  257. package/dist/persistence.js +14 -14
  258. package/dist/persistence.js.map +1 -1
  259. package/dist/project.cjs +5 -5
  260. package/dist/project.js +3 -3
  261. package/dist/registry-BA3SLAN7.cjs +46 -0
  262. package/dist/{registry-N3GTKYCI.cjs.map → registry-BA3SLAN7.cjs.map} +1 -1
  263. package/dist/registry-KMI5RA22.js +9 -0
  264. package/dist/{registry-SOXE4RY6.js.map → registry-KMI5RA22.js.map} +1 -1
  265. package/dist/retry.cjs +4 -4
  266. package/dist/retry.js +3 -3
  267. package/dist/{run-until-YZ2ODWOF.js → run-until-BK56WG4P.js} +3 -3
  268. package/dist/{run-until-YZ2ODWOF.js.map → run-until-BK56WG4P.js.map} +1 -1
  269. package/dist/{run-until-ZZ2JLPJM.cjs → run-until-L5KQD3PV.cjs} +4 -4
  270. package/dist/{run-until-ZZ2JLPJM.cjs.map → run-until-L5KQD3PV.cjs.map} +1 -1
  271. package/dist/{run-CwEJtLPE.d.ts → run-vJHg2eGw.d.cts} +201 -174
  272. package/dist/{run-CwEJtLPE.d.cts → run-vJHg2eGw.d.ts} +201 -174
  273. package/dist/sandbox/bwrap.d.cts +20 -20
  274. package/dist/sandbox/bwrap.d.ts +20 -20
  275. package/dist/sandbox/index.cjs +39 -39
  276. package/dist/sandbox/index.cjs.map +1 -1
  277. package/dist/sandbox/index.d.cts +1 -1
  278. package/dist/sandbox/index.d.ts +1 -1
  279. package/dist/sandbox/index.js +35 -35
  280. package/dist/sandbox/index.js.map +1 -1
  281. package/dist/sandbox/linux-sandbox.d.cts +26 -21
  282. package/dist/sandbox/linux-sandbox.d.ts +26 -21
  283. package/dist/server/auth/index.cjs.map +1 -1
  284. package/dist/server/auth/index.d.cts +6 -6
  285. package/dist/server/auth/index.d.ts +6 -6
  286. package/dist/server/auth/index.js.map +1 -1
  287. package/dist/server/auth/orchestrator.d.cts +2 -2
  288. package/dist/server/auth/orchestrator.d.ts +2 -2
  289. package/dist/server/auth/types.d.cts +4 -4
  290. package/dist/server/auth/types.d.ts +4 -4
  291. package/dist/server/errors-envelope.cjs +14 -14
  292. package/dist/server/errors-envelope.d.cts +3 -3
  293. package/dist/server/errors-envelope.d.ts +3 -3
  294. package/dist/server/errors-envelope.js +3 -3
  295. package/dist/session-transcript-DFGX6WNL.cjs +50 -0
  296. package/dist/{session-transcript-EAKR4D2W.cjs.map → session-transcript-DFGX6WNL.cjs.map} +1 -1
  297. package/dist/session-transcript-MMPWCESR.js +5 -0
  298. package/dist/{session-transcript-6WKLYIN4.js.map → session-transcript-MMPWCESR.js.map} +1 -1
  299. package/dist/skills.cjs +7 -7
  300. package/dist/skills.js +5 -5
  301. package/dist/stream-object-AFERZU63.js +7 -0
  302. package/dist/{stream-object-OFM66VUT.js.map → stream-object-AFERZU63.js.map} +1 -1
  303. package/dist/stream-object-YPXZ4F5P.cjs +20 -0
  304. package/dist/{stream-object-Y7YCX3BI.cjs.map → stream-object-YPXZ4F5P.cjs.map} +1 -1
  305. package/dist/subagents-loader.cjs +6 -6
  306. package/dist/subagents-loader.d.cts +2 -2
  307. package/dist/subagents-loader.d.ts +2 -2
  308. package/dist/subagents-loader.js +4 -4
  309. package/dist/subscription/index.cjs +3 -3
  310. package/dist/subscription/index.js +2 -2
  311. package/dist/task-store.cjs +7 -7
  312. package/dist/task-store.js +4 -4
  313. package/dist/types/agent-prims.d.ts +4 -4
  314. package/dist/types/goal-events.d.ts +24 -23
  315. package/dist/types/run.d.ts +27 -0
  316. package/dist/types/session-record.d.ts +14 -13
  317. package/dist/workflow.cjs +27 -27
  318. package/dist/workflow.js +6 -6
  319. package/package.json +12 -13
  320. package/dist/agent-DW2J37IH.js +0 -42
  321. package/dist/agent-IE6IE4NW.cjs +0 -51
  322. package/dist/chunk-2ONFGMBV.js.map +0 -1
  323. package/dist/chunk-56OXYUZE.js.map +0 -1
  324. package/dist/chunk-56ZM6P7Z.cjs.map +0 -1
  325. package/dist/chunk-5SB4V74H.js.map +0 -1
  326. package/dist/chunk-77WHPVXE.js.map +0 -1
  327. package/dist/chunk-ALU3KC4G.cjs.map +0 -1
  328. package/dist/chunk-EEZ7CFMM.js.map +0 -1
  329. package/dist/chunk-GL7CFBVC.js.map +0 -1
  330. package/dist/chunk-H5YVJB4K.cjs.map +0 -1
  331. package/dist/chunk-ICYBIC6N.cjs.map +0 -1
  332. package/dist/chunk-IT3PWBW4.cjs.map +0 -1
  333. package/dist/chunk-ITLS5LRF.cjs +0 -105
  334. package/dist/chunk-ITLS5LRF.cjs.map +0 -1
  335. package/dist/chunk-LTCOPATU.cjs.map +0 -1
  336. package/dist/chunk-MXSMAGDU.js.map +0 -1
  337. package/dist/chunk-P34DHHYQ.cjs.map +0 -1
  338. package/dist/chunk-TAPQWDW2.js.map +0 -1
  339. package/dist/chunk-THEYGCYS.cjs.map +0 -1
  340. package/dist/chunk-VNNK6AKU.js.map +0 -1
  341. package/dist/chunk-VYJSHGAY.js.map +0 -1
  342. package/dist/chunk-W52DKZBR.cjs.map +0 -1
  343. package/dist/chunk-XAEAMI5H.js.map +0 -1
  344. package/dist/chunk-YPQF26X7.cjs.map +0 -1
  345. package/dist/chunk-YVTNFKZO.js +0 -103
  346. package/dist/chunk-YVTNFKZO.js.map +0 -1
  347. package/dist/compact-session-H5TKLD55.cjs +0 -54
  348. package/dist/compact-session-WNKKIIDW.js +0 -17
  349. package/dist/context-VAYLPT4O.js +0 -5
  350. package/dist/context-ZV33V4DC.cjs +0 -22
  351. package/dist/fs-session-store-6MY7PNI2.js +0 -10
  352. package/dist/fs-session-store-7E7UPLF2.cjs +0 -19
  353. package/dist/generate-object-5SCEH2EE.cjs +0 -20
  354. package/dist/generate-object-I7UD4NWN.js +0 -7
  355. package/dist/index-manager-KKAK7NT3.js +0 -10
  356. package/dist/index-manager-R6ZJFEZF.cjs +0 -19
  357. package/dist/judge-call-SP3G3X2Y.cjs +0 -22
  358. package/dist/judge-call-TAEIXMYG.js +0 -5
  359. package/dist/registry-N3GTKYCI.cjs +0 -46
  360. package/dist/registry-SOXE4RY6.js +0 -9
  361. package/dist/session-transcript-6WKLYIN4.js +0 -5
  362. package/dist/session-transcript-EAKR4D2W.cjs +0 -50
  363. package/dist/stream-object-OFM66VUT.js +0 -7
  364. package/dist/stream-object-Y7YCX3BI.cjs +0 -20
@@ -1,34 +1,34 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
4
- var chunk6EDQBX7U_cjs = require('./chunk-6EDQBX7U.cjs');
5
- var chunkH5YVJB4K_cjs = require('./chunk-H5YVJB4K.cjs');
6
- var chunkITLS5LRF_cjs = require('./chunk-ITLS5LRF.cjs');
7
- var chunkALU3KC4G_cjs = require('./chunk-ALU3KC4G.cjs');
8
- var chunk2423XDPT_cjs = require('./chunk-2423XDPT.cjs');
9
- var chunkFAY3QDGC_cjs = require('./chunk-FAY3QDGC.cjs');
4
+ var chunk3MUIYMUG_cjs = require('./chunk-3MUIYMUG.cjs');
5
+ var chunk6ZGD7R27_cjs = require('./chunk-6ZGD7R27.cjs');
6
+ var chunk2R6NBT5F_cjs = require('./chunk-2R6NBT5F.cjs');
7
+ var chunkG7X2Y7Y2_cjs = require('./chunk-G7X2Y7Y2.cjs');
8
+ var chunk3BSP7LSG_cjs = require('./chunk-3BSP7LSG.cjs');
9
+ var chunkM4OGSS66_cjs = require('./chunk-M4OGSS66.cjs');
10
10
  var chunkWPZTYOUX_cjs = require('./chunk-WPZTYOUX.cjs');
11
- var chunkD4ZUJTFB_cjs = require('./chunk-D4ZUJTFB.cjs');
11
+ var chunk2K7PRHDB_cjs = require('./chunk-2K7PRHDB.cjs');
12
12
  var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
13
13
  var chunkG2F67XUR_cjs = require('./chunk-G2F67XUR.cjs');
14
14
  var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
15
15
  var chunkYPEPCZHF_cjs = require('./chunk-YPEPCZHF.cjs');
16
16
  var chunkVJ26EKGJ_cjs = require('./chunk-VJ26EKGJ.cjs');
17
- var chunkSWIBQFPH_cjs = require('./chunk-SWIBQFPH.cjs');
18
- var chunkTQI3KRXZ_cjs = require('./chunk-TQI3KRXZ.cjs');
17
+ var chunk3XRXORBS_cjs = require('./chunk-3XRXORBS.cjs');
18
+ var chunkZET34IZE_cjs = require('./chunk-ZET34IZE.cjs');
19
19
  var chunkYLQQX5W2_cjs = require('./chunk-YLQQX5W2.cjs');
20
- var chunkIEUDKUPM_cjs = require('./chunk-IEUDKUPM.cjs');
20
+ var chunk6OKPJZMX_cjs = require('./chunk-6OKPJZMX.cjs');
21
21
  var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
22
- var chunkICYBIC6N_cjs = require('./chunk-ICYBIC6N.cjs');
23
- var chunkGM7QDQ24_cjs = require('./chunk-GM7QDQ24.cjs');
24
- var chunk4YB7B3RP_cjs = require('./chunk-4YB7B3RP.cjs');
22
+ var chunkYVI4YPUP_cjs = require('./chunk-YVI4YPUP.cjs');
23
+ var chunkMXRBNJ6D_cjs = require('./chunk-MXRBNJ6D.cjs');
24
+ var chunkIBDE4R5L_cjs = require('./chunk-IBDE4R5L.cjs');
25
25
  var chunkVYHJZVL5_cjs = require('./chunk-VYHJZVL5.cjs');
26
- var chunk56ZM6P7Z_cjs = require('./chunk-56ZM6P7Z.cjs');
27
- var chunkQUFSDDNU_cjs = require('./chunk-QUFSDDNU.cjs');
28
- var chunkYBFDBOUN_cjs = require('./chunk-YBFDBOUN.cjs');
29
- var chunk7DXLNNKH_cjs = require('./chunk-7DXLNNKH.cjs');
30
- var chunkMHCKWQR3_cjs = require('./chunk-MHCKWQR3.cjs');
31
- var chunkLTCOPATU_cjs = require('./chunk-LTCOPATU.cjs');
26
+ var chunk4MWBKBS4_cjs = require('./chunk-4MWBKBS4.cjs');
27
+ var chunkR4AMI7KD_cjs = require('./chunk-R4AMI7KD.cjs');
28
+ var chunkQJQ2MAZF_cjs = require('./chunk-QJQ2MAZF.cjs');
29
+ var chunkXKBJT7WI_cjs = require('./chunk-XKBJT7WI.cjs');
30
+ var chunkA3MHE2MQ_cjs = require('./chunk-A3MHE2MQ.cjs');
31
+ var chunkBE3W4HYV_cjs = require('./chunk-BE3W4HYV.cjs');
32
32
  var promises = require('fs/promises');
33
33
  var crypto = require('crypto');
34
34
  var path = require('path');
@@ -224,7 +224,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
224
224
  const { output, maxRetries, errorStrategy, ...sendOptions } = options;
225
225
  const run = await agent.send(input, sendOptions);
226
226
  const result = await run.wait();
227
- const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-5SCEH2EE.cjs');
227
+ const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-F56VIZ6U.cjs');
228
228
  const answer = structurableAnswerOrThrow(result, GenerateObjectError);
229
229
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
230
230
  const facade = getAgentFacade();
@@ -326,7 +326,7 @@ function normalizeModel(m) {
326
326
  if (m === void 0 || typeof m !== "string") return m;
327
327
  const id = m.trim();
328
328
  if (id.length === 0) {
329
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
329
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
330
330
  'model must be a non-empty "provider/model" id string or a ModelSelection object',
331
331
  { code: "invalid_model_selection" }
332
332
  );
@@ -462,7 +462,7 @@ function registryPath(cwd) {
462
462
  return path.join(cwd, REGISTRY_RELATIVE_PATH);
463
463
  }
464
464
  async function loadRegistry(cwd) {
465
- return chunkD4ZUJTFB_cjs.readVersionedJson({
465
+ return chunk2K7PRHDB_cjs.readVersionedJson({
466
466
  path: registryPath(cwd),
467
467
  currentVersion: SCHEMA_VERSION,
468
468
  defaultValue: () => ({}),
@@ -486,7 +486,7 @@ async function saveRegistry(cwd, agents2) {
486
486
  }
487
487
  const path = registryPath(cwd);
488
488
  await chunkYLQQX5W2_cjs.withCwdMutex(`registry:${cwd}`, async () => {
489
- await chunkD4ZUJTFB_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
489
+ await chunk2K7PRHDB_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
490
490
  });
491
491
  }
492
492
  function toSerialized(agent) {
@@ -553,7 +553,7 @@ function scheduleSaveForCwd(cwd) {
553
553
  }
554
554
  } catch (cause) {
555
555
  const msg = cause instanceof Error ? cause.message : String(cause);
556
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] registry persist failed (${cwd}): ${msg}
556
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] registry persist failed (${cwd}): ${msg}
557
557
  `);
558
558
  } finally {
559
559
  pendingSaves.delete(cwd);
@@ -892,14 +892,14 @@ async function readLegacyFacts(jsonPath) {
892
892
  }
893
893
  async function writeMigratedFacts(cwd, jsonPath, facts) {
894
894
  try {
895
- for (const fact of facts) await chunk2423XDPT_cjs.appendFactToMarkdown(cwd, fact);
895
+ for (const fact of facts) await chunk3BSP7LSG_cjs.appendFactToMarkdown(cwd, fact);
896
896
  await promises.unlink(jsonPath).catch(() => void 0);
897
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
897
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
898
898
  `);
899
899
  return { migrated: true, factCount: facts.length };
900
900
  } catch (cause) {
901
901
  const message = cause instanceof Error ? cause.message : String(cause);
902
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] memory migration failed (readonly fs?): ${message}
902
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] memory migration failed (readonly fs?): ${message}
903
903
  `);
904
904
  return { migrated: false, factCount: 0, reason: "readonly-fs" };
905
905
  }
@@ -909,12 +909,12 @@ async function migrateLegacyJson(cwd, config) {
909
909
  const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
910
910
  if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
911
911
  migrationRun.add(key);
912
- const jsonPath = chunk2423XDPT_cjs.legacyMemoryJsonPath(cwd, config);
912
+ const jsonPath = chunk3BSP7LSG_cjs.legacyMemoryJsonPath(cwd, config);
913
913
  if (!await fileExists(jsonPath)) {
914
914
  return { migrated: false, factCount: 0, reason: "no-legacy-json" };
915
915
  }
916
- if (await fileExists(chunk2423XDPT_cjs.memoryMdPath(cwd))) {
917
- chunkLTCOPATU_cjs.diag(
916
+ if (await fileExists(chunk3BSP7LSG_cjs.memoryMdPath(cwd))) {
917
+ chunkBE3W4HYV_cjs.diag(
918
918
  `[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
919
919
  `
920
920
  );
@@ -938,13 +938,13 @@ function extractMemoryFact(message) {
938
938
  async function readMemoryFacts(cwd, config) {
939
939
  if (!config.enabled) return [];
940
940
  await migrateLegacyJson(cwd, config);
941
- return chunk2423XDPT_cjs.readFacts(cwd, config);
941
+ return chunk3BSP7LSG_cjs.readFacts(cwd, config);
942
942
  }
943
943
  async function appendMemoryFact(cwd, config, fact) {
944
944
  if (!config.enabled) return;
945
945
  await migrateLegacyJson(cwd, config);
946
- const sanitized = { text: chunkLTCOPATU_cjs.redactSecrets(fact.text) };
947
- await chunk2423XDPT_cjs.appendFact(cwd, config, sanitized);
946
+ const sanitized = { text: chunkBE3W4HYV_cjs.redactSecrets(fact.text) };
947
+ await chunk3BSP7LSG_cjs.appendFact(cwd, config, sanitized);
948
948
  }
949
949
 
950
950
  // src/internal/runtime/fixtures/fixture-scripts.ts
@@ -1292,7 +1292,7 @@ function redactScriptSecrets(script) {
1292
1292
  function redactEventSecrets(event) {
1293
1293
  const serialized = JSON.stringify(event);
1294
1294
  const localStripped = serialized.replace(FIXTURE_SENTINEL, "***");
1295
- const redacted = chunkLTCOPATU_cjs.redactSecrets(localStripped);
1295
+ const redacted = chunkBE3W4HYV_cjs.redactSecrets(localStripped);
1296
1296
  if (redacted === serialized) return event;
1297
1297
  return JSON.parse(redacted);
1298
1298
  }
@@ -1323,6 +1323,16 @@ var FixtureRunBase = class {
1323
1323
  resolveTermination;
1324
1324
  terminated = false;
1325
1325
  eventNotifier;
1326
+ /**
1327
+ * theokit#140 - the run's single ordered timeline: structural events and live token/tool deltas,
1328
+ * in the order they actually occurred.
1329
+ *
1330
+ * Kept alongside `script.events` rather than replacing it. `stream()` is the SDKMessage view and
1331
+ * stays byte-identical for every existing consumer; this is the complete view, and a consumer
1332
+ * picks one. Merging them would have changed `stream()`'s element type - a breaking change for
1333
+ * an additive feature.
1334
+ */
1335
+ timeline = [];
1326
1336
  constructor(options) {
1327
1337
  this.id = options.id;
1328
1338
  this.agentId = options.agentId;
@@ -1346,6 +1356,46 @@ var FixtureRunBase = class {
1346
1356
  this.eventNotifier = makeNotifier();
1347
1357
  current.resolve();
1348
1358
  }
1359
+ /**
1360
+ * theokit#140 - every event of this run, in true order, from ONE source.
1361
+ *
1362
+ * ## The defect this replaces
1363
+ *
1364
+ * A consumer that needed tool calls interleaved with tokens had to fuse two surfaces by hand:
1365
+ * `stream()`, which was batched and post-completion, and `SendOptions.onDelta`, which was live.
1366
+ * Neither was complete alone - `onDelta` has no `run_started`/`system`, and `stream()` had no
1367
+ * token granularity - so the entire reconciliation, including its dedup, lived in the consumer.
1368
+ * `@theokit/agents` carried ~200 lines of exactly that, and it is the documented root of its
1369
+ * ordering bug (theokit#47), its namespace-dedup bug (#138) and its missing terminal frame (#142).
1370
+ *
1371
+ * The ordering is not reconstructed here. Both kinds are appended by the loop AS THEY HAPPEN, so
1372
+ * arrival order IS model order - there is nothing to sort, and no timestamp heuristic to get
1373
+ * wrong.
1374
+ *
1375
+ * `callId` is whatever the SDK's own `tool_call` events carry, so a consumer no longer holds two
1376
+ * id namespaces and no longer has to correlate them.
1377
+ */
1378
+ async *events() {
1379
+ let index = 0;
1380
+ while (!this.terminated) {
1381
+ while (index < this.timeline.length) {
1382
+ yield this.timeline[index++];
1383
+ }
1384
+ if (this.terminated) break;
1385
+ await Promise.race([this.eventNotifier.promise, this.terminationPromise]);
1386
+ }
1387
+ while (index < this.timeline.length) {
1388
+ yield this.timeline[index++];
1389
+ }
1390
+ for await (const message of this.terminalErrorEvent()) {
1391
+ yield { kind: "message", message };
1392
+ }
1393
+ }
1394
+ /** theokit#140 - append to the timeline and wake `events()`. */
1395
+ pushTimeline(event) {
1396
+ this.timeline.push(event);
1397
+ this.notifyNewEvents();
1398
+ }
1349
1399
  async *stream() {
1350
1400
  let index = 0;
1351
1401
  while (!this.terminated) {
@@ -1361,22 +1411,22 @@ var FixtureRunBase = class {
1361
1411
  yield* this.terminalErrorEvent();
1362
1412
  }
1363
1413
  /**
1364
- * theokit#101 — quando o run termina em erro, `stream()` tem de DIZER.
1414
+ * theokit#101 — when the run ends in error, `stream()` has to SAY SO.
1365
1415
  *
1366
- * O erro sempre existiu: o loop o registra em `ctx.error` e `wait()` devolve
1367
- * `status: 'error'` com a mensagem. o `stream()` não o mencionavaele drena
1368
- * `script.events` e para. Uma falha de provider (404 "No endpoints found", auth, timeout)
1369
- * produzia um turno que parecia bem-sucedido e vazio, em TODA superfície que consome o
1416
+ * The error always existed: the loop records it in `ctx.error` and `wait()` returns
1417
+ * `status: 'error'` with the message. Only `stream()` failed to mention it it drains
1418
+ * `script.events` and stops. A provider failure (404 "No endpoints found", auth, timeout)
1419
+ * produced a turn that looked successful and empty, on EVERY surface consuming the
1370
1420
  * stream: HTTP web, MCP, stdio, TUI in-process.
1371
1421
  *
1372
- * Erro silencioso é o pior tipo (Regra Inquebrável 8). E a assimetria era o que o tornava
1373
- * difícil de diagnosticar: quem depurasse por `wait()` via o erro e não reproduziria o
1374
- * relato de quem depurava pelo stream.
1422
+ * A silent error is the worst kind (Unbreakable Rule 8). And the asymmetry was what made it
1423
+ * hard to diagnose: anyone debugging via `wait()` saw the error and would not reproduce the
1424
+ * report of anyone debugging via the stream.
1375
1425
  *
1376
- * Emite `SDKStatusMessage` com `status: "ERROR"` — o tipo EXISTE na união `SDKMessage`
1377
- * e é esperado por quem consome. Um tipo novo seria breaking para todo consumidor que
1378
- * faz switch exaustivo; este é aditivo, e um consumidor que ignore `status` simplesmente
1379
- * segue como antesnunca pior que hoje.
1426
+ * It emits `SDKStatusMessage` with `status: "ERROR"` — the type ALREADY EXISTS in the `SDKMessage` union
1427
+ * and is already expected by consumers. A new type would be breaking for every consumer doing
1428
+ * an exhaustive switch; this one is additive, and a consumer ignoring `status` simply
1429
+ * behaves as beforenever worse than today.
1380
1430
  */
1381
1431
  *terminalErrorEvent() {
1382
1432
  if (this.status !== "error") return;
@@ -1386,7 +1436,7 @@ var FixtureRunBase = class {
1386
1436
  agent_id: this.agentId,
1387
1437
  run_id: this.id,
1388
1438
  status: "ERROR",
1389
- // Sem mensagem, o consumidor sabe QUE falhou e não O QUÊque é metade do defeito.
1439
+ // Without a message, the consumer knows THAT it failed and not WHATwhich is half the defect.
1390
1440
  ...detail?.message !== void 0 ? { message: detail.message } : {}
1391
1441
  };
1392
1442
  }
@@ -1565,7 +1615,7 @@ function createRealCloudRun(options) {
1565
1615
  conversation: []
1566
1616
  };
1567
1617
  const apiKey = resolveApiKey(options.agentOptions.apiKey);
1568
- const baseUrl = chunkALU3KC4G_cjs.getConfiguredBaseUrl();
1618
+ const baseUrl = chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl();
1569
1619
  const handle = new RealCloudRun(
1570
1620
  {
1571
1621
  id,
@@ -1638,7 +1688,7 @@ var RealCloudRun = class extends FixtureRunBase {
1638
1688
  });
1639
1689
  if (!response.ok) {
1640
1690
  const text = await response.text().catch(() => "");
1641
- throw new chunkMHCKWQR3_cjs.NetworkError(
1691
+ throw new chunkA3MHE2MQ_cjs.NetworkError(
1642
1692
  `Cloud Run endpoint returned ${response.status}: ${text.slice(0, 200)}`,
1643
1693
  { code: "cloud_run_http_error" }
1644
1694
  );
@@ -1648,7 +1698,7 @@ var RealCloudRun = class extends FixtureRunBase {
1648
1698
  async consumeStream(response) {
1649
1699
  let finalStatus = "finished";
1650
1700
  let finalText = "";
1651
- for await (const record of chunkALU3KC4G_cjs.parseSseStream(response.body, this.controller.signal)) {
1701
+ for await (const record of chunkG7X2Y7Y2_cjs.parseSseStream(response.body, this.controller.signal)) {
1652
1702
  const parsed = safeParse(record.data);
1653
1703
  if (parsed === void 0) continue;
1654
1704
  const update = this.applyRecord(record.event, parsed);
@@ -1757,7 +1807,7 @@ var CloudAgent = class {
1757
1807
  */
1758
1808
  isFixtureMode() {
1759
1809
  const apiKey = resolveApiKey(this.options.apiKey);
1760
- return chunkALU3KC4G_cjs.isFixtureApiKey(apiKey) && chunkALU3KC4G_cjs.getConfiguredBaseUrl() === void 0;
1810
+ return chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) && chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl() === void 0;
1761
1811
  }
1762
1812
  // SE9 — integrated structured output; delegates to the shared helper.
1763
1813
  generate(message, options) {
@@ -1772,7 +1822,7 @@ var CloudAgent = class {
1772
1822
  }
1773
1823
  async send(message, options = {}) {
1774
1824
  if (options.tools !== void 0 && options.tools.length > 0) {
1775
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
1825
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
1776
1826
  "Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
1777
1827
  { code: "cloud_custom_tools_rejected" }
1778
1828
  );
@@ -1808,7 +1858,7 @@ var CloudAgent = class {
1808
1858
  const userText = typeof message === "string" ? message : message.text;
1809
1859
  const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
1810
1860
  const apiKey = resolveApiKey(this.options.apiKey);
1811
- const useRealRuntime = apiKey !== void 0 && !chunkALU3KC4G_cjs.isFixtureApiKey(apiKey) && chunkALU3KC4G_cjs.getConfiguredBaseUrl() !== void 0;
1861
+ const useRealRuntime = apiKey !== void 0 && !chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) && chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl() !== void 0;
1812
1862
  return useRealRuntime ? createRealCloudRun({
1813
1863
  agentId: this.agentId,
1814
1864
  model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
@@ -1857,7 +1907,7 @@ var CloudAgent = class {
1857
1907
  listArtifacts() {
1858
1908
  if (!this.isFixtureMode()) {
1859
1909
  return Promise.reject(
1860
- new chunkMHCKWQR3_cjs.ConfigurationError(
1910
+ new chunkA3MHE2MQ_cjs.ConfigurationError(
1861
1911
  "Cloud runtime is pre-release. listArtifacts() will return real artifacts when Theo PaaS ships; today it is only available in fixture mode (theo_test_* keys).",
1862
1912
  { code: "cloud_runtime_pre_release" }
1863
1913
  )
@@ -1867,11 +1917,11 @@ var CloudAgent = class {
1867
1917
  }
1868
1918
  downloadArtifact(path) {
1869
1919
  try {
1870
- chunkYBFDBOUN_cjs.validateArtifactPath(path);
1920
+ chunkQJQ2MAZF_cjs.validateArtifactPath(path);
1871
1921
  } catch (cause) {
1872
- if (cause instanceof chunkYBFDBOUN_cjs.PathTraversalError) {
1922
+ if (cause instanceof chunkQJQ2MAZF_cjs.PathTraversalError) {
1873
1923
  return Promise.reject(
1874
- new chunkMHCKWQR3_cjs.ConfigurationError(`Artifact path must stay inside the workspace: ${path}`, {
1924
+ new chunkA3MHE2MQ_cjs.ConfigurationError(`Artifact path must stay inside the workspace: ${path}`, {
1875
1925
  code: "artifact_path_traversal",
1876
1926
  cause
1877
1927
  })
@@ -1881,7 +1931,7 @@ var CloudAgent = class {
1881
1931
  }
1882
1932
  if (!this.isFixtureMode()) {
1883
1933
  return Promise.reject(
1884
- new chunkMHCKWQR3_cjs.ConfigurationError(
1934
+ new chunkA3MHE2MQ_cjs.ConfigurationError(
1885
1935
  "Cloud runtime is pre-release. downloadArtifact() will fetch real PaaS artifacts when the cloud runtime ships; today it is only available in fixture mode (theo_test_* keys).",
1886
1936
  { code: "cloud_runtime_pre_release" }
1887
1937
  )
@@ -1890,7 +1940,7 @@ var CloudAgent = class {
1890
1940
  const match = buildFixtureArtifacts().find((artifact) => artifact.path === path);
1891
1941
  if (match === void 0) {
1892
1942
  return Promise.reject(
1893
- new chunkMHCKWQR3_cjs.UnknownAgentError(`Artifact ${path} not found`, { code: "unknown_artifact" })
1943
+ new chunkA3MHE2MQ_cjs.UnknownAgentError(`Artifact ${path} not found`, { code: "unknown_artifact" })
1894
1944
  );
1895
1945
  }
1896
1946
  return Promise.resolve(Buffer.from(`fixture artifact content for ${path}
@@ -1904,7 +1954,7 @@ var CloudAgent = class {
1904
1954
  * @public
1905
1955
  */
1906
1956
  runUntil() {
1907
- throw new chunkMHCKWQR3_cjs.UnsupportedRunOperationError(
1957
+ throw new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
1908
1958
  "Agent.runUntil() is not supported on cloud agents. Cloud runtime manages goal loops server-side. Use a local agent for autonomous Ralph loops.",
1909
1959
  "runUntil"
1910
1960
  );
@@ -1915,7 +1965,7 @@ var CloudAgent = class {
1915
1965
  * @public
1916
1966
  */
1917
1967
  fork() {
1918
- throw new chunkMHCKWQR3_cjs.UnsupportedRunOperationError(
1968
+ throw new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
1919
1969
  "Agent.fork() is not supported on cloud agents. Fork inheritance requires local credential + system-prompt access. Use a local agent.",
1920
1970
  "fork"
1921
1971
  );
@@ -1927,7 +1977,7 @@ var CloudAgent = class {
1927
1977
  * @public
1928
1978
  */
1929
1979
  runToCompletion() {
1930
- throw new chunkMHCKWQR3_cjs.UnsupportedRunOperationError(
1980
+ throw new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
1931
1981
  "Agent.runToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
1932
1982
  "runToCompletion"
1933
1983
  );
@@ -1939,7 +1989,7 @@ var CloudAgent = class {
1939
1989
  * @public
1940
1990
  */
1941
1991
  streamToCompletion() {
1942
- throw new chunkMHCKWQR3_cjs.UnsupportedRunOperationError(
1992
+ throw new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
1943
1993
  "Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
1944
1994
  "streamToCompletion"
1945
1995
  );
@@ -1953,7 +2003,7 @@ var CloudAgent = class {
1953
2003
  */
1954
2004
  usePersonality() {
1955
2005
  return Promise.reject(
1956
- new chunkMHCKWQR3_cjs.UnsupportedRunOperationError(
2006
+ new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError(
1957
2007
  "Agent.usePersonality() is not supported on cloud agents (pre-release). Use a local agent or wait for cloud GA.",
1958
2008
  "usePersonality"
1959
2009
  )
@@ -1981,7 +2031,7 @@ function validateCloudToolParity(options) {
1981
2031
  function rejectProcessors(options) {
1982
2032
  const hasProcessors = (options.inputProcessors?.length ?? 0) > 0 || (options.outputProcessors?.length ?? 0) > 0;
1983
2033
  if (hasProcessors) {
1984
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
2034
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
1985
2035
  "Cloud agents can't run guardrail processors \u2014 a Processor carries function handlers that don't survive serialization to PaaS. Run processors on a local agent, or move the guardrail into a server-side gateway in front of TheoCloud.",
1986
2036
  { code: "cloud_incompatible_function_resolver" }
1987
2037
  );
@@ -1989,7 +2039,7 @@ function rejectProcessors(options) {
1989
2039
  }
1990
2040
  function rejectFunctionSystemPrompt(options) {
1991
2041
  if (typeof options.systemPrompt === "function") {
1992
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
2042
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
1993
2043
  "Cloud agents require systemPrompt as a serializable string. SystemPromptResolver functions can't run on PaaS \u2014 resolve to a string before Agent.create() or move the dynamic logic into a hook rule.",
1994
2044
  { code: "cloud_incompatible_function_resolver" }
1995
2045
  );
@@ -1997,7 +2047,7 @@ function rejectFunctionSystemPrompt(options) {
1997
2047
  }
1998
2048
  function rejectFunctionSkills(options) {
1999
2049
  if (typeof options.skills === "function") {
2000
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
2050
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
2001
2051
  "Cloud agents require skills as a static settings object. SkillsResolver functions can't run on PaaS \u2014 resolve to a SkillsSettings object before Agent.create() or move the dynamic logic into a hook rule.",
2002
2052
  { code: "cloud_incompatible_function_resolver" }
2003
2053
  );
@@ -2009,7 +2059,7 @@ function rejectStdioMcpLocalPaths(options) {
2009
2059
  if (!isStdioCommandConfig(config)) continue;
2010
2060
  const command = config.command ?? "";
2011
2061
  if (isLocalPath(command)) {
2012
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
2062
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
2013
2063
  `MCP server "${name}" uses a local-FS command path (${command}). Cloud agents can't reach local binaries \u2014 use a bare command (npx, uvx, node, \u2026) that the PaaS VM image provides, or switch to an HTTP MCP server.`,
2014
2064
  { code: "cloud_incompatible_mcp_stdio_local" }
2015
2065
  );
@@ -2049,14 +2099,14 @@ async function readState(filePath) {
2049
2099
  try {
2050
2100
  parsed = JSON.parse(raw);
2051
2101
  } catch {
2052
- chunkFAY3QDGC_cjs.warnOnce(
2102
+ chunkM4OGSS66_cjs.warnOnce(
2053
2103
  "personality-store-json-parse",
2054
2104
  "[theokit-sdk] personality.json is malformed; treating as empty"
2055
2105
  );
2056
2106
  return emptyState();
2057
2107
  }
2058
2108
  if (!isStateV1(parsed)) {
2059
- chunkFAY3QDGC_cjs.warnOnce(
2109
+ chunkM4OGSS66_cjs.warnOnce(
2060
2110
  "personality-store-bad-version",
2061
2111
  `[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
2062
2112
  );
@@ -2087,9 +2137,9 @@ var PersonalityStore = class {
2087
2137
  try {
2088
2138
  await this.#persist(agentId, slug);
2089
2139
  } catch (err) {
2090
- chunkFAY3QDGC_cjs.warnOnce(
2140
+ chunkM4OGSS66_cjs.warnOnce(
2091
2141
  `personality-store-persist-failure-${agentId}`,
2092
- `[theokit-sdk] personality persist failed for ${chunkLTCOPATU_cjs.redactSecrets(agentId)}: ${chunkLTCOPATU_cjs.redactSecrets(
2142
+ `[theokit-sdk] personality persist failed for ${chunkBE3W4HYV_cjs.redactSecrets(agentId)}: ${chunkBE3W4HYV_cjs.redactSecrets(
2093
2143
  err.message
2094
2144
  )}`
2095
2145
  );
@@ -2104,9 +2154,9 @@ var PersonalityStore = class {
2104
2154
  try {
2105
2155
  state = await readState(filePath);
2106
2156
  } catch (err) {
2107
- chunkFAY3QDGC_cjs.warnOnce(
2157
+ chunkM4OGSS66_cjs.warnOnce(
2108
2158
  `personality-store-hydrate-failure-${agentId}`,
2109
- `[theokit-sdk] personality hydrate failed for ${chunkLTCOPATU_cjs.redactSecrets(agentId)}: ${chunkLTCOPATU_cjs.redactSecrets(
2159
+ `[theokit-sdk] personality hydrate failed for ${chunkBE3W4HYV_cjs.redactSecrets(agentId)}: ${chunkBE3W4HYV_cjs.redactSecrets(
2110
2160
  err.message
2111
2161
  )}`
2112
2162
  );
@@ -2123,17 +2173,17 @@ var PersonalityStore = class {
2123
2173
  async #persist(agentId, slug) {
2124
2174
  const filePath = this.#filePath();
2125
2175
  await promises.mkdir(path.dirname(filePath), { recursive: true });
2126
- await chunkTQI3KRXZ_cjs.withFileLock(filePath, async () => {
2176
+ await chunkZET34IZE_cjs.withFileLock(filePath, async () => {
2127
2177
  const current = await readState(filePath);
2128
2178
  const nextAgents = { ...current.agents };
2129
2179
  if (slug === void 0) delete nextAgents[agentId];
2130
2180
  else nextAgents[agentId] = slug;
2131
2181
  const next = { version: SCHEMA_VERSION2, agents: nextAgents };
2132
- await chunkICYBIC6N_cjs.atomicWriteJson(filePath, next);
2182
+ await chunkYVI4YPUP_cjs.atomicWriteJson(filePath, next);
2133
2183
  });
2134
2184
  }
2135
2185
  #filePath() {
2136
- return path.join(chunkD4ZUJTFB_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2186
+ return path.join(chunk2K7PRHDB_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2137
2187
  }
2138
2188
  };
2139
2189
 
@@ -2156,7 +2206,7 @@ function createPluginContext() {
2156
2206
  },
2157
2207
  on(hook, handler) {
2158
2208
  if (typeof handler !== "function") {
2159
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] ignoring non-function handler for hook "${hook}"
2209
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] ignoring non-function handler for hook "${hook}"
2160
2210
  `);
2161
2211
  return;
2162
2212
  }
@@ -2209,7 +2259,7 @@ var PluginManager = class {
2209
2259
  const seen = /* @__PURE__ */ new Set();
2210
2260
  for (const plugin of plugins) {
2211
2261
  if (seen.has(plugin.name)) {
2212
- chunkLTCOPATU_cjs.diag(
2262
+ chunkBE3W4HYV_cjs.diag(
2213
2263
  `[theokit-sdk] duplicate plugin name "${plugin.name}" \u2014 both will register independently
2214
2264
  `
2215
2265
  );
@@ -2236,7 +2286,7 @@ var PluginManager = class {
2236
2286
  */
2237
2287
  async register(plugin) {
2238
2288
  if (plugin.kind !== "general") {
2239
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
2289
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
2240
2290
  `late register supports general plugins only (got "${plugin.kind}" for "${plugin.name}")`,
2241
2291
  { code: "plugin_late_register_kind" }
2242
2292
  );
@@ -2293,7 +2343,7 @@ var PluginManager = class {
2293
2343
  parts.push(result.recalledContext);
2294
2344
  }
2295
2345
  } catch (err) {
2296
- chunkLTCOPATU_cjs.diag(
2346
+ chunkBE3W4HYV_cjs.diag(
2297
2347
  `[theokit-sdk] pre_user_send hook failed: ${err instanceof Error ? err.message : String(err)}
2298
2348
  `
2299
2349
  );
@@ -2321,7 +2371,7 @@ var PluginManager = class {
2321
2371
  try {
2322
2372
  await h(ctx);
2323
2373
  } catch (err) {
2324
- chunkLTCOPATU_cjs.diag(
2374
+ chunkBE3W4HYV_cjs.diag(
2325
2375
  `[theokit-sdk] post_assistant_reply hook failed: ${err instanceof Error ? err.message : String(err)}
2326
2376
  `
2327
2377
  );
@@ -2337,7 +2387,7 @@ var PluginManager = class {
2337
2387
  try {
2338
2388
  await h(ctx);
2339
2389
  } catch (err) {
2340
- chunkLTCOPATU_cjs.diag(
2390
+ chunkBE3W4HYV_cjs.diag(
2341
2391
  `[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
2342
2392
  `
2343
2393
  );
@@ -2352,7 +2402,7 @@ var PluginManager = class {
2352
2402
  const out = await h(current, ctx);
2353
2403
  if (out !== void 0) current = out;
2354
2404
  } catch (err) {
2355
- chunkLTCOPATU_cjs.diag(
2405
+ chunkBE3W4HYV_cjs.diag(
2356
2406
  `[theokit-sdk] ${name} hook failed: ${err instanceof Error ? err.message : String(err)}
2357
2407
  `
2358
2408
  );
@@ -2494,7 +2544,7 @@ var HooksExecutor = class {
2494
2544
  this.config = {};
2495
2545
  return;
2496
2546
  }
2497
- this.config = await chunkFAY3QDGC_cjs.loadHookConfig(this.cwd);
2547
+ this.config = await chunkM4OGSS66_cjs.loadHookConfig(this.cwd);
2498
2548
  }
2499
2549
  /** Fire every hook registered for `event` and aggregate the decisions. */
2500
2550
  async run(payload) {
@@ -2600,11 +2650,11 @@ function buildContextBudgetEvent(model, resolved) {
2600
2650
  // src/internal/runtime/lifecycle/post-run-lifecycle.ts
2601
2651
  function resolveWindowForRun(model, contextWindow) {
2602
2652
  const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
2603
- return chunk4YB7B3RP_cjs.resolveEffectiveContextWindow({
2653
+ return chunkIBDE4R5L_cjs.resolveEffectiveContextWindow({
2604
2654
  ...override !== void 0 ? { override } : {},
2605
- catalog: chunk56ZM6P7Z_cjs.getCatalogModelInfo(model)?.limit?.context,
2606
- margin: chunk4YB7B3RP_cjs.CONTEXT_WINDOW_MARGIN,
2607
- floor: chunk4YB7B3RP_cjs.CONTEXT_WINDOW_FLOOR
2655
+ catalog: chunk4MWBKBS4_cjs.getCatalogModelInfo(model)?.limit?.context,
2656
+ margin: chunkIBDE4R5L_cjs.CONTEXT_WINDOW_MARGIN,
2657
+ floor: chunkIBDE4R5L_cjs.CONTEXT_WINDOW_FLOOR
2608
2658
  });
2609
2659
  }
2610
2660
  async function runPostRunLifecycle(inputs) {
@@ -2628,32 +2678,32 @@ async function runPostRunLifecycle(inputs) {
2628
2678
  try {
2629
2679
  const parcial = await safeConversation(run);
2630
2680
  if (parcial !== void 0) {
2631
- chunkH5YVJB4K_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2681
+ chunk6ZGD7R27_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2632
2682
  userText,
2633
2683
  conversation: parcial
2634
2684
  });
2635
2685
  }
2636
2686
  } catch (cause) {
2637
2687
  const msg = cause instanceof Error ? cause.message : String(cause);
2638
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
2688
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
2639
2689
  `);
2640
2690
  }
2641
- await chunkH5YVJB4K_cjs.flushSessionWrites();
2691
+ await chunk6ZGD7R27_cjs.flushSessionWrites();
2642
2692
  return;
2643
2693
  }
2644
2694
  if (result.result !== void 0) {
2645
- chunkH5YVJB4K_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2695
+ chunk6ZGD7R27_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2646
2696
  }
2647
2697
  const conversation = await safeConversation(run);
2648
2698
  const resolvedWindow = resolveWindowForRun(model, contextWindow);
2649
- const janelaEfetiva = resolvedWindow.window;
2699
+ const effectiveWindow = resolvedWindow.window;
2650
2700
  const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
2651
2701
  if (budgetEvent !== void 0 && onRunEvent !== void 0) {
2652
- chunk6EDQBX7U_cjs.emitRunEvent(onRunEvent, budgetEvent);
2702
+ chunk3MUIYMUG_cjs.emitRunEvent(onRunEvent, budgetEvent);
2653
2703
  }
2654
2704
  const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
2655
2705
  const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
2656
- chunkH5YVJB4K_cjs.persistTurnToTranscript(
2706
+ chunk6ZGD7R27_cjs.persistTurnToTranscript(
2657
2707
  sessionStore,
2658
2708
  { cwd: workspaceCwd, agentId, model },
2659
2709
  agentId,
@@ -2662,16 +2712,16 @@ async function runPostRunLifecycle(inputs) {
2662
2712
  conversation,
2663
2713
  autoCompact: {
2664
2714
  usageTotal: usageForTrigger,
2665
- // A janela EFETIVA (após override, clamp e margem) — não a declarada. Trocar por
2666
- // `contextWindow` aqui orçaria contra um número que o clamp rejeitou.
2667
- contextWindow: janelaEfetiva,
2668
- summarize: chunkALU3KC4G_cjs.buildDefaultSummarizer({
2715
+ // The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
2716
+ // `contextWindow` here would budget against a number the clamp already rejected.
2717
+ contextWindow: effectiveWindow,
2718
+ summarize: chunkG7X2Y7Y2_cjs.buildDefaultSummarizer({
2669
2719
  agentModel: model,
2670
2720
  ...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
2671
2721
  })
2672
2722
  }
2673
2723
  },
2674
- onRunEvent !== void 0 ? () => chunk6EDQBX7U_cjs.emitRunEvent(onRunEvent, { type: "compact_boundary", trigger: "auto" }) : void 0
2724
+ onRunEvent !== void 0 ? () => chunk3MUIYMUG_cjs.emitRunEvent(onRunEvent, { type: "compact_boundary", trigger: "auto" }) : void 0
2675
2725
  );
2676
2726
  if (result.status === "finished" && result.result !== void 0) {
2677
2727
  const summaryArgs = {
@@ -2687,14 +2737,14 @@ async function runPostRunLifecycle(inputs) {
2687
2737
  if (memoryProvider?.recordSessionSummary !== void 0) {
2688
2738
  await memoryProvider.recordSessionSummary(summaryArgs);
2689
2739
  } else {
2690
- await chunk2423XDPT_cjs.writeSessionSummary(summaryArgs);
2740
+ await chunk3BSP7LSG_cjs.writeSessionSummary(summaryArgs);
2691
2741
  }
2692
2742
  if (!shouldUsePortMemoryPath()) {
2693
2743
  void memoryGlue.syncIfReady();
2694
2744
  }
2695
2745
  } catch (cause) {
2696
2746
  const message = cause instanceof Error ? cause.message : String(cause);
2697
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] session summary write failed (${result.id}): ${message}
2747
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] session summary write failed (${result.id}): ${message}
2698
2748
  `);
2699
2749
  }
2700
2750
  }
@@ -2707,7 +2757,7 @@ async function runPostRunLifecycle(inputs) {
2707
2757
  agentId,
2708
2758
  runId: result.id
2709
2759
  });
2710
- await chunkH5YVJB4K_cjs.flushSessionWrites();
2760
+ await chunk6ZGD7R27_cjs.flushSessionWrites();
2711
2761
  }
2712
2762
  async function safeConversation(run) {
2713
2763
  try {
@@ -2782,7 +2832,7 @@ var warned = /* @__PURE__ */ new Set();
2782
2832
  function warnDoubleReasoningOnce() {
2783
2833
  if (warned.has("double-reasoning")) return;
2784
2834
  warned.add("double-reasoning");
2785
- chunkLTCOPATU_cjs.diag(
2835
+ chunkBE3W4HYV_cjs.diag(
2786
2836
  "[theokit-sdk] `reasoning: true` skipped \u2014 a native reasoning model is configured (model.params thinking/reasoning); native reasoning wins. Remove one to silence.\n"
2787
2837
  );
2788
2838
  }
@@ -2815,9 +2865,9 @@ var SkillsManager = class {
2815
2865
  }
2816
2866
  async refresh() {
2817
2867
  const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
2818
- const discovered = await chunkQUFSDDNU_cjs.discoverSkills(skillsRoot, {
2868
+ const discovered = await chunkR4AMI7KD_cjs.discoverSkills(skillsRoot, {
2819
2869
  onInvalidSkill: (info) => {
2820
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
2870
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
2821
2871
  `);
2822
2872
  }
2823
2873
  });
@@ -2841,7 +2891,7 @@ var SkillsManager = class {
2841
2891
  async get(name) {
2842
2892
  const skill = this.skills.find((s) => s.name === name);
2843
2893
  if (skill === void 0) return void 0;
2844
- const instructions = typeof skill.instructions === "string" ? skill.instructions : chunkQUFSDDNU_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
2894
+ const instructions = typeof skill.instructions === "string" ? skill.instructions : chunkR4AMI7KD_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
2845
2895
  const references = skill.references;
2846
2896
  return {
2847
2897
  name: skill.name,
@@ -2927,7 +2977,7 @@ async function safeCall(fn, fallback, label = "safeCall") {
2927
2977
  return await fn();
2928
2978
  } catch (cause) {
2929
2979
  const message = cause instanceof Error ? cause.message : String(cause);
2930
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] ${label} failed: ${message}
2980
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] ${label} failed: ${message}
2931
2981
  `);
2932
2982
  return fallback;
2933
2983
  }
@@ -2941,7 +2991,7 @@ var ActiveMemoryPromptProvider = class {
2941
2991
  if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
2942
2992
  return Promise.resolve(void 0);
2943
2993
  }
2944
- const body = chunkQUFSDDNU_cjs.escapeBlockBody(ctx.activeMemorySummary);
2994
+ const body = chunkR4AMI7KD_cjs.escapeBlockBody(ctx.activeMemorySummary);
2945
2995
  return Promise.resolve(`<active-memory>
2946
2996
  ${body}
2947
2997
  </active-memory>`);
@@ -2994,7 +3044,7 @@ function formatSource(name, tokens) {
2994
3044
  if (tokens.length === 0) {
2995
3045
  return ` <source name="${escapeAttribute(name)}" />`;
2996
3046
  }
2997
- const body = chunkQUFSDDNU_cjs.escapeBlockBody(tokens.join(" "));
3047
+ const body = chunkR4AMI7KD_cjs.escapeBlockBody(tokens.join(" "));
2998
3048
  return ` <source name="${escapeAttribute(name)}">
2999
3049
  ${body}
3000
3050
  </source>`;
@@ -3010,7 +3060,7 @@ var MemoryPromptProvider = class {
3010
3060
  contribute(ctx) {
3011
3061
  if (ctx.memoryAutoInject === false) return Promise.resolve(void 0);
3012
3062
  if (ctx.memory.length === 0) return Promise.resolve(void 0);
3013
- const lines = ctx.memory.map((fact) => ` - ${chunkQUFSDDNU_cjs.escapeBlockBody(fact.text)}`);
3063
+ const lines = ctx.memory.map((fact) => ` - ${chunkR4AMI7KD_cjs.escapeBlockBody(fact.text)}`);
3014
3064
  return Promise.resolve(`<memory>
3015
3065
  ${lines.join("\n")}
3016
3066
  </memory>`);
@@ -3032,7 +3082,7 @@ var SkillsPromptProvider = class {
3032
3082
  priority = 20;
3033
3083
  contribute(ctx) {
3034
3084
  if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
3035
- return Promise.resolve(chunkQUFSDDNU_cjs.buildSkillsBlock(ctx.skills));
3085
+ return Promise.resolve(chunkR4AMI7KD_cjs.buildSkillsBlock(ctx.skills));
3036
3086
  }
3037
3087
  };
3038
3088
 
@@ -3044,7 +3094,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
3044
3094
  for (const p of providers) {
3045
3095
  const key = `${p.priority}:${p.id}`;
3046
3096
  if (seen.has(key)) {
3047
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Duplicate system-prompt provider ${key}`, {
3097
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Duplicate system-prompt provider ${key}`, {
3048
3098
  code: "pipeline_duplicate_provider"
3049
3099
  });
3050
3100
  }
@@ -3091,7 +3141,7 @@ function validateAgentOptions(options) {
3091
3141
  ensureRuntimeShape(options);
3092
3142
  if (options.local !== void 0) {
3093
3143
  if (options.model === void 0) {
3094
- throw new chunkMHCKWQR3_cjs.ConfigurationError("Local agents require a model selection", {
3144
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError("Local agents require a model selection", {
3095
3145
  code: "missing_model"
3096
3146
  });
3097
3147
  }
@@ -3115,7 +3165,7 @@ function validateCredentialPoolShape(options) {
3115
3165
  ([, arr]) => Array.isArray(arr) && arr.some((k) => typeof k === "string" && k.length > 0)
3116
3166
  );
3117
3167
  if (populated.length === 0) return;
3118
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3168
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3119
3169
  "Ambiguous credential configuration: use either `apiKey: '...'` (single-key, simplest) OR `apiKeys: { provider: [...] }` (multi-key pool), not both.",
3120
3170
  { code: "credential_pool_ambiguous" }
3121
3171
  );
@@ -3124,7 +3174,7 @@ function validatePlugins(options) {
3124
3174
  const plugins = options.plugins;
3125
3175
  if (plugins?.paths === void 0) return;
3126
3176
  if (options.cloud !== void 0 && plugins.paths.length > 0) {
3127
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3177
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3128
3178
  "Cloud agents require committed plugin manifests; local plugin paths are not supported",
3129
3179
  { code: "cloud_plugin_path_rejected" }
3130
3180
  );
@@ -3132,7 +3182,7 @@ function validatePlugins(options) {
3132
3182
  }
3133
3183
  function ensureRuntimeShape(options) {
3134
3184
  if (options.local !== void 0 && options.cloud !== void 0) {
3135
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3185
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3136
3186
  "Pass either local or cloud \u2014 they are mutually exclusive runtimes",
3137
3187
  { code: "runtime_exclusive" }
3138
3188
  );
@@ -3140,7 +3190,7 @@ function ensureRuntimeShape(options) {
3140
3190
  }
3141
3191
  function rejectProgrammaticHooks(options) {
3142
3192
  if (options.hooks !== void 0) {
3143
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3193
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3144
3194
  "Programmatic hooks are not supported \u2014 hooks are file-based only (.theokit/hooks.json)",
3145
3195
  { code: "programmatic_hooks_rejected" }
3146
3196
  );
@@ -3150,7 +3200,7 @@ function validateCloud(cloud) {
3150
3200
  if (cloud.envVars !== void 0) {
3151
3201
  for (const key of Object.keys(cloud.envVars)) {
3152
3202
  if (key.startsWith("THEOKIT_")) {
3153
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3203
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3154
3204
  `Cloud envVars cannot use the reserved THEOKIT_ prefix (got "${key}")`,
3155
3205
  { code: "reserved_env_prefix" }
3156
3206
  );
@@ -3162,7 +3212,7 @@ function validateMcpServers(options) {
3162
3212
  if (options.mcpServers === void 0) return;
3163
3213
  for (const [name, config] of Object.entries(options.mcpServers)) {
3164
3214
  if (options.cloud !== void 0 && isStdioWithCwd(config)) {
3165
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3215
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3166
3216
  `MCP server "${name}" uses stdio with cwd, which is rejected for cloud agents`,
3167
3217
  { code: "cloud_stdio_cwd_rejected" }
3168
3218
  );
@@ -3181,12 +3231,12 @@ function validateSubagents(agents2) {
3181
3231
  if (agents2 === void 0) return;
3182
3232
  for (const [name, definition] of Object.entries(agents2)) {
3183
3233
  if (typeof definition.description !== "string" || definition.description.length === 0) {
3184
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty description`, {
3234
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty description`, {
3185
3235
  code: "subagent_missing_description"
3186
3236
  });
3187
3237
  }
3188
3238
  if (typeof definition.prompt !== "string" || definition.prompt.length === 0) {
3189
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty prompt`, {
3239
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Subagent "${name}" requires a non-empty prompt`, {
3190
3240
  code: "subagent_missing_prompt"
3191
3241
  });
3192
3242
  }
@@ -3199,7 +3249,7 @@ function validateToolCatalog(tools) {
3199
3249
  for (const tool of tools) {
3200
3250
  validateSingleTool(tool);
3201
3251
  if (seen.has(tool.name)) {
3202
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Duplicate custom tool name "${tool.name}"`, {
3252
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Duplicate custom tool name "${tool.name}"`, {
3203
3253
  code: "duplicate_tool_name"
3204
3254
  });
3205
3255
  }
@@ -3210,7 +3260,7 @@ function validateCustomTools(options) {
3210
3260
  const tools = options.tools;
3211
3261
  if (tools === void 0 || tools.length === 0) return;
3212
3262
  if (options.cloud !== void 0) {
3213
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3263
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3214
3264
  "Custom inline tools are local-only in SDK v1.0 \u2014 cloud agents cannot serialize handler functions",
3215
3265
  { code: "cloud_custom_tools_rejected" }
3216
3266
  );
@@ -3222,25 +3272,25 @@ function validateSingleTool(tool) {
3222
3272
  validateToolDescription(tool);
3223
3273
  validateToolSchema(tool);
3224
3274
  if (typeof tool.handler !== "function") {
3225
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a handler function`, {
3275
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a handler function`, {
3226
3276
  code: "tool_missing_handler"
3227
3277
  });
3228
3278
  }
3229
3279
  }
3230
3280
  function validateToolName(tool) {
3231
3281
  if (typeof tool.name !== "string" || tool.name.length === 0) {
3232
- throw new chunkMHCKWQR3_cjs.ConfigurationError("Custom tool requires a non-empty name", {
3282
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError("Custom tool requires a non-empty name", {
3233
3283
  code: "tool_missing_name"
3234
3284
  });
3235
3285
  }
3236
3286
  if (!TOOL_NAME_PATTERN.test(tool.name)) {
3237
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3287
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3238
3288
  `Custom tool name "${tool.name}" must match /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/`,
3239
3289
  { code: "tool_invalid_name" }
3240
3290
  );
3241
3291
  }
3242
3292
  if (RESERVED_TOOL_NAMES.has(tool.name) || tool.name.startsWith("mcp_")) {
3243
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3293
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3244
3294
  `Custom tool name "${tool.name}" collides with a reserved SDK tool name`,
3245
3295
  { code: "tool_reserved_name" }
3246
3296
  );
@@ -3248,7 +3298,7 @@ function validateToolName(tool) {
3248
3298
  }
3249
3299
  function validateToolDescription(tool) {
3250
3300
  if (typeof tool.description !== "string" || tool.description.length === 0) {
3251
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a non-empty description`, {
3301
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Custom tool "${tool.name}" requires a non-empty description`, {
3252
3302
  code: "tool_missing_description"
3253
3303
  });
3254
3304
  }
@@ -3256,12 +3306,12 @@ function validateToolDescription(tool) {
3256
3306
  function validateToolSchema(tool) {
3257
3307
  const schema = tool.inputSchema;
3258
3308
  if (schema === null || schema === void 0 || typeof schema !== "object") {
3259
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Custom tool "${tool.name}" requires an inputSchema object`, {
3309
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Custom tool "${tool.name}" requires an inputSchema object`, {
3260
3310
  code: "tool_missing_schema"
3261
3311
  });
3262
3312
  }
3263
3313
  if (schema.type !== "object") {
3264
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3314
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3265
3315
  `Custom tool "${tool.name}" inputSchema must declare \`type: "object"\``,
3266
3316
  { code: "tool_invalid_schema_type" }
3267
3317
  );
@@ -3272,7 +3322,7 @@ function validateMemory(options) {
3272
3322
  if (memory?.storePath === void 0) return;
3273
3323
  const storePath = memory.storePath;
3274
3324
  if (storePath.includes("..") || storePath.startsWith("/") || /^[A-Z]:/i.test(storePath)) {
3275
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3325
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3276
3326
  `Memory storePath must stay inside the workspace; got "${storePath}"`,
3277
3327
  { code: "memory_path_traversal" }
3278
3328
  );
@@ -3294,7 +3344,7 @@ var HISTOGRAM_NAMES = {
3294
3344
  };
3295
3345
  function safeRequire(moduleName) {
3296
3346
  try {
3297
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-W52DKZBR.cjs', document.baseURI).href)));
3347
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UZBA6YYP.cjs', document.baseURI).href)));
3298
3348
  return r(moduleName);
3299
3349
  } catch {
3300
3350
  return void 0;
@@ -3373,7 +3423,7 @@ var langfuseAdapter = {
3373
3423
  }
3374
3424
  }
3375
3425
  if (lf.LangfuseSpanProcessor === void 0) {
3376
- chunkLTCOPATU_cjs.diag(
3426
+ chunkBE3W4HYV_cjs.diag(
3377
3427
  "[theokit-sdk] @langfuse/node detected but LangfuseSpanProcessor not found (v2?). Use Langfuse v3+ for auto-instrumentation.\n"
3378
3428
  );
3379
3429
  return;
@@ -3502,11 +3552,11 @@ function tryAutoRegisterAdapters(settings) {
3502
3552
  try {
3503
3553
  adapter.register();
3504
3554
  registered.add(adapter.moduleName);
3505
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] telemetry: ${adapter.displayName} auto-instrumented.
3555
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] telemetry: ${adapter.displayName} auto-instrumented.
3506
3556
  `);
3507
3557
  } catch (cause) {
3508
3558
  const message = cause instanceof Error ? cause.message : String(cause);
3509
- chunkLTCOPATU_cjs.diag(
3559
+ chunkBE3W4HYV_cjs.diag(
3510
3560
  `[theokit-sdk] telemetry: ${adapter.displayName} detected but failed to register: ${message}
3511
3561
  `
3512
3562
  );
@@ -3519,7 +3569,7 @@ var cachedOtel;
3519
3569
  function loadOtel() {
3520
3570
  if (cachedOtel === void 0) {
3521
3571
  try {
3522
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-W52DKZBR.cjs', document.baseURI).href)));
3572
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UZBA6YYP.cjs', document.baseURI).href)));
3523
3573
  const mod = r("@opentelemetry/api");
3524
3574
  cachedOtel = mod;
3525
3575
  } catch {
@@ -3562,7 +3612,7 @@ function safe(op, fallback) {
3562
3612
  if (!warnedOnce) {
3563
3613
  warnedOnce = true;
3564
3614
  const message = cause instanceof Error ? cause.message : String(cause);
3565
- chunkLTCOPATU_cjs.diag(
3615
+ chunkBE3W4HYV_cjs.diag(
3566
3616
  `[theokit-sdk] telemetry exporter error (suppressed; agent.send continues): ${message}
3567
3617
  `
3568
3618
  );
@@ -3576,7 +3626,7 @@ function createTelemetry(settings) {
3576
3626
  if (otel === null) {
3577
3627
  if (!warnedOnce) {
3578
3628
  warnedOnce = true;
3579
- chunkLTCOPATU_cjs.diag(
3629
+ chunkBE3W4HYV_cjs.diag(
3580
3630
  "[theokit-sdk] telemetry.enabled = true but `@opentelemetry/api` is not installed; telemetry is a no-op.\n"
3581
3631
  );
3582
3632
  }
@@ -3670,12 +3720,12 @@ function wrapSpan(span, openSpans) {
3670
3720
  }
3671
3721
  function redactAttrValue(value) {
3672
3722
  if (typeof value !== "string") return value;
3673
- return chunkLTCOPATU_cjs.redactSecrets(value);
3723
+ return chunkBE3W4HYV_cjs.redactSecrets(value);
3674
3724
  }
3675
3725
  function redactAttrs(attrs) {
3676
3726
  const out = {};
3677
3727
  for (const [k, v] of Object.entries(attrs)) {
3678
- out[k] = typeof v === "string" ? chunkLTCOPATU_cjs.redactSecrets(v) : v;
3728
+ out[k] = typeof v === "string" ? chunkBE3W4HYV_cjs.redactSecrets(v) : v;
3679
3729
  }
3680
3730
  return out;
3681
3731
  }
@@ -3757,10 +3807,10 @@ async function loadMarkdownEntities(opts) {
3757
3807
  const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
3758
3808
  if (raw === null) continue;
3759
3809
  const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
3760
- const fields = chunk7DXLNNKH_cjs.parseSimpleYaml(split.frontmatter);
3810
+ const fields = chunkXKBJT7WI_cjs.parseSimpleYaml(split.frontmatter);
3761
3811
  const parsed = schema.safeParse(fields);
3762
3812
  if (!parsed.success) {
3763
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3813
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3764
3814
  `Invalid frontmatter in ${resolved.source}: ${parsed.error.message}`,
3765
3815
  { code: `${errorCodePrefix}_frontmatter_invalid` }
3766
3816
  );
@@ -3778,13 +3828,13 @@ async function assertFileSizeUnderCap(source, errorCodePrefix) {
3778
3828
  try {
3779
3829
  const info = await promises.stat(source);
3780
3830
  if (info.size > MAX_MD_FILE_BYTES) {
3781
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3831
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3782
3832
  `Config file ${source} exceeds 1 MB size limit (${info.size} bytes). Reduce the file or split into multiple entities.`,
3783
3833
  { code: `${errorCodePrefix}_file_too_large` }
3784
3834
  );
3785
3835
  }
3786
3836
  } catch (cause) {
3787
- if (cause instanceof chunkMHCKWQR3_cjs.ConfigurationError) throw cause;
3837
+ if (cause instanceof chunkA3MHE2MQ_cjs.ConfigurationError) throw cause;
3788
3838
  }
3789
3839
  }
3790
3840
  async function readDirSafe(dir, errorCodePrefix) {
@@ -3793,7 +3843,7 @@ async function readDirSafe(dir, errorCodePrefix) {
3793
3843
  } catch (cause) {
3794
3844
  const code = cause.code;
3795
3845
  if (code === "ENOENT") return null;
3796
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Failed to read ${dir}`, {
3846
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Failed to read ${dir}`, {
3797
3847
  code: `${errorCodePrefix}_dir_read_error`,
3798
3848
  cause
3799
3849
  });
@@ -3810,7 +3860,7 @@ function resolveEntryPath(entry, pattern, dir) {
3810
3860
  function splitFrontmatter(raw, source, errorCodePrefix) {
3811
3861
  const match = /^---\s*\n([\s\S]*?)\n---\s*(?:\n|$)/.exec(raw);
3812
3862
  if (match === null) {
3813
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
3863
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
3814
3864
  `Missing or malformed frontmatter in ${source} (expected \`---\` delimited block at file head)`,
3815
3865
  { code: `${errorCodePrefix}_missing_frontmatter` }
3816
3866
  );
@@ -4294,7 +4344,7 @@ async function loadContextConfig(cwd) {
4294
4344
  });
4295
4345
  if (mdEntities.length > 0) {
4296
4346
  if (fs.existsSync(jsonPath)) {
4297
- chunkFAY3QDGC_cjs.warnOnce(
4347
+ chunkM4OGSS66_cjs.warnOnce(
4298
4348
  "context-both-present",
4299
4349
  "[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
4300
4350
  );
@@ -4304,7 +4354,7 @@ async function loadContextConfig(cwd) {
4304
4354
  };
4305
4355
  }
4306
4356
  if (!fs.existsSync(jsonPath)) return { sources: [] };
4307
- chunkFAY3QDGC_cjs.warnOnce(
4357
+ chunkM4OGSS66_cjs.warnOnce(
4308
4358
  "context-json-deprecated",
4309
4359
  "[theokit-sdk] .theokit/context.json is deprecated; migrate to .theokit/context/<name>.md via theokit-migrate-config"
4310
4360
  );
@@ -4312,7 +4362,7 @@ async function loadContextConfig(cwd) {
4312
4362
  try {
4313
4363
  raw = await promises.readFile(jsonPath, "utf8");
4314
4364
  } catch (cause) {
4315
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Failed to read context config: ${jsonPath}`, {
4365
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Failed to read context config: ${jsonPath}`, {
4316
4366
  code: "context_read_error",
4317
4367
  cause
4318
4368
  });
@@ -4324,13 +4374,13 @@ function parseConfig(raw, configPath) {
4324
4374
  try {
4325
4375
  parsed = JSON.parse(raw);
4326
4376
  } catch (cause) {
4327
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Invalid JSON in context config: ${configPath}`, {
4377
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Invalid JSON in context config: ${configPath}`, {
4328
4378
  code: "context_json_invalid",
4329
4379
  cause
4330
4380
  });
4331
4381
  }
4332
4382
  if (!parsed || typeof parsed !== "object") {
4333
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Context config must be an object: ${configPath}`, {
4383
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Context config must be an object: ${configPath}`, {
4334
4384
  code: "context_config_shape"
4335
4385
  });
4336
4386
  }
@@ -4345,7 +4395,7 @@ function parseConfig(raw, configPath) {
4345
4395
  }
4346
4396
  function readSources(sourcesRaw, configPath) {
4347
4397
  if (!Array.isArray(sourcesRaw)) {
4348
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Context config sources must be an array: ${configPath}`, {
4398
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Context config sources must be an array: ${configPath}`, {
4349
4399
  code: "context_sources_shape"
4350
4400
  });
4351
4401
  }
@@ -4443,7 +4493,7 @@ var PluginsManager = class {
4443
4493
  async refresh() {
4444
4494
  this.plugins = [];
4445
4495
  const pluginsRoot = path.join(this.cwd, ".theokit", "plugins");
4446
- const entries = await chunk7DXLNNKH_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
4496
+ const entries = await chunkXKBJT7WI_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
4447
4497
  for (const entry of entries) {
4448
4498
  if (!entry.isDirectory()) continue;
4449
4499
  const folderName = entry.name;
@@ -4451,13 +4501,13 @@ var PluginsManager = class {
4451
4501
  const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
4452
4502
  const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
4453
4503
  if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4454
- chunkFAY3QDGC_cjs.warnOnce(
4504
+ chunkM4OGSS66_cjs.warnOnce(
4455
4505
  `plugin-${folderName}-both`,
4456
4506
  `[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
4457
4507
  );
4458
4508
  }
4459
4509
  if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4460
- chunkFAY3QDGC_cjs.warnOnce(
4510
+ chunkM4OGSS66_cjs.warnOnce(
4461
4511
  "plugin-json-deprecated",
4462
4512
  "[theokit-sdk] plugin.json manifests are deprecated; migrate to PLUGIN.md via theokit-migrate-config"
4463
4513
  );
@@ -4475,11 +4525,11 @@ var PluginsManager = class {
4475
4525
  const entry = metadata.entry;
4476
4526
  if (entry === void 0) return;
4477
4527
  const pluginRoot = path.join(this.cwd, ".theokit", "plugins", folderName);
4478
- const entryPath = chunkYBFDBOUN_cjs.safePathJoin(pluginRoot, entry);
4528
+ const entryPath = chunkQJQ2MAZF_cjs.safePathJoin(pluginRoot, entry);
4479
4529
  try {
4480
4530
  await promises.readFile(entryPath, "utf8");
4481
4531
  } catch (cause) {
4482
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Plugin ${metadata.name} entry file is missing: ${entry}`, {
4532
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${metadata.name} entry file is missing: ${entry}`, {
4483
4533
  code: "plugin_entry_missing",
4484
4534
  cause
4485
4535
  });
@@ -4488,7 +4538,7 @@ var PluginsManager = class {
4488
4538
  assertCloudRules() {
4489
4539
  if (!this.cloud) return;
4490
4540
  if (this.localPaths !== void 0 && this.localPaths.length > 0) {
4491
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
4541
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
4492
4542
  "Cloud agents reject local plugin paths \u2014 plugins must come from committed repo files",
4493
4543
  { code: "cloud_plugin_path_rejected" }
4494
4544
  );
@@ -4500,7 +4550,7 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
4500
4550
  try {
4501
4551
  raw = await promises.readFile(manifestPath, "utf8");
4502
4552
  } catch (cause) {
4503
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Plugin ${folderName} is missing plugin.json`, {
4553
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} is missing plugin.json`, {
4504
4554
  code: "plugin_missing_manifest",
4505
4555
  cause
4506
4556
  });
@@ -4509,13 +4559,13 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
4509
4559
  try {
4510
4560
  parsed = JSON.parse(raw);
4511
4561
  } catch (cause) {
4512
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Plugin ${folderName} manifest is invalid JSON`, {
4562
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} manifest is invalid JSON`, {
4513
4563
  code: "plugin_manifest_invalid",
4514
4564
  cause
4515
4565
  });
4516
4566
  }
4517
4567
  if (!parsed || typeof parsed !== "object") {
4518
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Plugin ${folderName} manifest must be an object`, {
4568
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} manifest must be an object`, {
4519
4569
  code: "plugin_manifest_shape"
4520
4570
  });
4521
4571
  }
@@ -4534,7 +4584,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
4534
4584
  try {
4535
4585
  raw = await promises.readFile(mdPath, "utf8");
4536
4586
  } catch (cause) {
4537
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Plugin ${folderName} is missing PLUGIN.md`, {
4587
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} is missing PLUGIN.md`, {
4538
4588
  code: "plugin_missing_manifest",
4539
4589
  cause
4540
4590
  });
@@ -4549,7 +4599,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
4549
4599
  });
4550
4600
  const entity = entities.find((e) => e.slug === "PLUGIN");
4551
4601
  if (entity === void 0) {
4552
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`Plugin ${folderName} PLUGIN.md not parseable`, {
4602
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`Plugin ${folderName} PLUGIN.md not parseable`, {
4553
4603
  code: "plugin_missing_manifest"
4554
4604
  });
4555
4605
  }
@@ -4823,7 +4873,7 @@ function assertValidThresholds(soft, hard) {
4823
4873
  ["hardThreshold", hard]
4824
4874
  ]) {
4825
4875
  if (!Number.isInteger(value) || value < 1) {
4826
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
4876
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
4827
4877
  `doomLoop.${label} must be a positive integer (received ${value}).`,
4828
4878
  { code: "invalid_doom_loop_threshold" }
4829
4879
  );
@@ -4988,6 +5038,35 @@ function buildAssistantTurn(text, toolCalls) {
4988
5038
  return { role: "assistant", content };
4989
5039
  }
4990
5040
 
5041
+ // src/internal/agent-loop/live-events.ts
5042
+ var LiveEventLog = class extends Array {
5043
+ /**
5044
+ * Not readonly, and not a constructor parameter — `Array` subclasses are re-instantiated by
5045
+ * `map`/`filter`/`slice` with a length argument, so a constructor with a different signature
5046
+ * breaks those. The sink is attached after construction instead.
5047
+ */
5048
+ #sink;
5049
+ /** Attach the live subscriber. One sink: the run that owns this loop. */
5050
+ subscribe(sink) {
5051
+ this.#sink = sink;
5052
+ }
5053
+ push(...events) {
5054
+ const length = super.push(...events);
5055
+ for (const event of events) {
5056
+ try {
5057
+ this.#sink?.(event);
5058
+ } catch {
5059
+ }
5060
+ }
5061
+ return length;
5062
+ }
5063
+ };
5064
+ function createEventLog(seed) {
5065
+ const log = new LiveEventLog();
5066
+ log.push(...seed);
5067
+ return log;
5068
+ }
5069
+
4991
5070
  // src/internal/agent-loop/loop-context-init.ts
4992
5071
  function buildUserContent(text, images) {
4993
5072
  const content = [{ type: "text", text }];
@@ -5051,13 +5130,14 @@ async function initLoopContext(inputs) {
5051
5130
  });
5052
5131
  }
5053
5132
  }
5054
- const events = [
5133
+ const events = createEventLog([
5055
5134
  buildSystemEvent(
5056
5135
  inputs,
5057
5136
  tools.map((t) => t.name)
5058
5137
  ),
5059
5138
  buildUserEvent(inputs)
5060
- ];
5139
+ ]);
5140
+ if (inputs.onLoopEvent !== void 0) events.subscribe(inputs.onLoopEvent);
5061
5141
  const priorMessages = (inputs.priorMessages ?? []).map((msg) => ({
5062
5142
  role: msg.role,
5063
5143
  content: [{ type: "text", text: msg.text }]
@@ -5104,7 +5184,7 @@ async function safeListTools(client, serverName) {
5104
5184
  } catch (cause) {
5105
5185
  const message = cause instanceof Error ? cause.message : String(cause);
5106
5186
  const server = serverName ?? "unknown";
5107
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] mcp listTools failed (server=${server}): ${message}
5187
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] mcp listTools failed (server=${server}): ${message}
5108
5188
  `);
5109
5189
  return [];
5110
5190
  }
@@ -5173,7 +5253,7 @@ function emitLlmMetrics(inputs, result, startAt) {
5173
5253
  inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.LLM_USAGE_MISSING, 1, {
5174
5254
  provider: inputs.llm.name
5175
5255
  });
5176
- chunkLTCOPATU_cjs.diag(
5256
+ chunkBE3W4HYV_cjs.diag(
5177
5257
  `[theokit-sdk] llm usage missing from ${inputs.llm.name} finish \u2014 budget may undercount
5178
5258
  `
5179
5259
  );
@@ -5422,7 +5502,7 @@ function coerceArgsToSchema(args, schema) {
5422
5502
  }
5423
5503
 
5424
5504
  // src/tool-error.ts
5425
- var ToolError = class extends chunkMHCKWQR3_cjs.TheokitAgentError {
5505
+ var ToolError = class extends chunkA3MHE2MQ_cjs.TheokitAgentError {
5426
5506
  name = "ToolError";
5427
5507
  /** The error content surfaced to the model: a string, or text/image blocks. */
5428
5508
  content;
@@ -5616,7 +5696,7 @@ function raceToolExecution(exec, opts) {
5616
5696
  // src/internal/agent-loop/tool-dispatch.ts
5617
5697
  async function dispatchTools(inputs, tools, toolCalls, events, parentSpan) {
5618
5698
  const maxConcurrent = inputs.maxConcurrentTools ?? 4;
5619
- return chunkSWIBQFPH_cjs.mapWithConcurrency(
5699
+ return chunk3XRXORBS_cjs.mapWithConcurrency(
5620
5700
  toolCalls,
5621
5701
  maxConcurrent,
5622
5702
  (call) => dispatchSingleCall(inputs, tools, call, events, parentSpan)
@@ -5644,7 +5724,7 @@ async function dispatchSingleCall(inputs, tools, call, events, parentSpan) {
5644
5724
  toolSpan?.end();
5645
5725
  return fileVeto;
5646
5726
  }
5647
- chunk6EDQBX7U_cjs.emitRunEvent(inputs.runEventSink, {
5727
+ chunk3MUIYMUG_cjs.emitRunEvent(inputs.runEventSink, {
5648
5728
  type: "tool_progress",
5649
5729
  toolName: workingCall.name,
5650
5730
  toolCallId: callId
@@ -5675,7 +5755,7 @@ function applyRepairAndExtractCall(tools, call) {
5675
5755
  function vetoFromForkWhitelist(inputs, call, callId, events) {
5676
5756
  const whitelistDecision = chunkVJ26EKGJ_cjs.checkToolWhitelist(call.name);
5677
5757
  if (whitelistDecision.allowed) return void 0;
5678
- chunk6EDQBX7U_cjs.emitRunEvent(inputs.runEventSink, {
5758
+ chunk3MUIYMUG_cjs.emitRunEvent(inputs.runEventSink, {
5679
5759
  type: "permission_denied",
5680
5760
  toolName: call.name,
5681
5761
  toolCallId: callId,
@@ -5720,7 +5800,7 @@ async function vetoFromPluginPreHook(inputs, call, callId, events) {
5720
5800
  ...inputs.permissionMode !== void 0 ? { permissionMode: inputs.permissionMode } : {}
5721
5801
  });
5722
5802
  if (pluginVeto === void 0) return void 0;
5723
- chunk6EDQBX7U_cjs.emitRunEvent(inputs.runEventSink, {
5803
+ chunk3MUIYMUG_cjs.emitRunEvent(inputs.runEventSink, {
5724
5804
  type: "permission_denied",
5725
5805
  toolName: call.name,
5726
5806
  toolCallId: callId,
@@ -5749,7 +5829,7 @@ async function vetoFromFileHookPreDecision(inputs, call, callId, events) {
5749
5829
  runId: inputs.runId
5750
5830
  });
5751
5831
  if (!preDecision.blocked) return void 0;
5752
- chunk6EDQBX7U_cjs.emitRunEvent(inputs.runEventSink, {
5832
+ chunk3MUIYMUG_cjs.emitRunEvent(inputs.runEventSink, {
5753
5833
  type: "permission_denied",
5754
5834
  toolName: call.name,
5755
5835
  toolCallId: callId,
@@ -5850,7 +5930,7 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
5850
5930
  agentId: inputs.agentId,
5851
5931
  runId: inputs.runId
5852
5932
  }).catch((err) => {
5853
- chunkLTCOPATU_cjs.diag(
5933
+ chunkBE3W4HYV_cjs.diag(
5854
5934
  `[theokit-sdk] postToolUse hook error (swallowed): ${err instanceof Error ? err.message : String(err)}
5855
5935
  `
5856
5936
  );
@@ -5869,7 +5949,7 @@ async function emitToolLifecycleDelta(inputs, update) {
5869
5949
  try {
5870
5950
  await inputs.onDelta({ update });
5871
5951
  } catch (err) {
5872
- chunkLTCOPATU_cjs.diag(
5952
+ chunkBE3W4HYV_cjs.diag(
5873
5953
  `[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
5874
5954
  `
5875
5955
  );
@@ -5881,7 +5961,7 @@ async function safeEmitToolHook(callback, event) {
5881
5961
  await callback(event);
5882
5962
  } catch (cause) {
5883
5963
  const msg = cause instanceof Error ? cause.message : String(cause);
5884
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] tool lifecycle hook threw: ${msg}
5964
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] tool lifecycle hook threw: ${msg}
5885
5965
  `);
5886
5966
  }
5887
5967
  }
@@ -5948,7 +6028,7 @@ function applyToolResultGuard(parts, opts) {
5948
6028
  (p) => (
5949
6029
  // SE7 — guard the TEXT of a tool result (string or the text blocks of a
5950
6030
  // structured content); image blocks pass through untouched.
5951
- p.type === "tool_result" ? { ...p, content: chunkALU3KC4G_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6031
+ p.type === "tool_result" ? { ...p, content: chunkG7X2Y7Y2_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
5952
6032
  )
5953
6033
  );
5954
6034
  }
@@ -6143,7 +6223,7 @@ function catalogCostFallback(provider, cleanedModel) {
6143
6223
  const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
6144
6224
  if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
6145
6225
  for (const key of candidates) {
6146
- const info = chunk56ZM6P7Z_cjs.getCatalogModelInfo(key);
6226
+ const info = chunk4MWBKBS4_cjs.getCatalogModelInfo(key);
6147
6227
  const cost = info?.cost;
6148
6228
  if (cost === void 0) continue;
6149
6229
  const [prov, ...modelParts] = key.split("/");
@@ -6155,7 +6235,7 @@ function catalogCostFallback(provider, cleanedModel) {
6155
6235
  ...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
6156
6236
  ...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
6157
6237
  // M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
6158
- pricingVersion: chunk56ZM6P7Z_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
6238
+ pricingVersion: chunk4MWBKBS4_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
6159
6239
  };
6160
6240
  }
6161
6241
  return void 0;
@@ -6603,15 +6683,15 @@ var FallbackLlmClient = class {
6603
6683
  let lastError;
6604
6684
  for (const client of this.clients) {
6605
6685
  if (signal.aborted) throw abortError(signal);
6606
- const attempt = await chunkALU3KC4G_cjs.tryFirstEvent(client, request, signal, true);
6686
+ const attempt = await chunkG7X2Y7Y2_cjs.tryFirstEvent(client, request, signal, true);
6607
6687
  if (attempt.kind === "handshake_error") {
6608
6688
  lastError = attempt.error;
6609
6689
  continue;
6610
6690
  }
6611
- return yield* chunkALU3KC4G_cjs.relayStream(attempt.generator, attempt.firstResult);
6691
+ return yield* chunkG7X2Y7Y2_cjs.relayStream(attempt.generator, attempt.firstResult);
6612
6692
  }
6613
6693
  if (lastError !== void 0) throw lastError;
6614
- throw new chunkMHCKWQR3_cjs.NetworkError("FallbackLlmClient has no providers configured", {
6694
+ throw new chunkA3MHE2MQ_cjs.NetworkError("FallbackLlmClient has no providers configured", {
6615
6695
  code: "fallback_empty_chain"
6616
6696
  });
6617
6697
  }
@@ -6634,7 +6714,7 @@ function reconnectDelay(attempt) {
6634
6714
  return ms <= 0 ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, ms));
6635
6715
  }
6636
6716
  function mcpTimeoutError(name, timeoutMs) {
6637
- return new chunkMHCKWQR3_cjs.NetworkError(`MCP ${name} request timed out after ${timeoutMs}ms`, {
6717
+ return new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${name} request timed out after ${timeoutMs}ms`, {
6638
6718
  code: "mcp_timeout"
6639
6719
  });
6640
6720
  }
@@ -6717,7 +6797,7 @@ var StdioMcpClient = class extends BaseMcpClient {
6717
6797
  child.stdin.on("error", () => void 0);
6718
6798
  child.on("error", () => {
6719
6799
  this.rejectAllPending(
6720
- new chunkMHCKWQR3_cjs.NetworkError(`MCP ${this.name} process crashed`, { code: "mcp_crashed" })
6800
+ new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} process crashed`, { code: "mcp_crashed" })
6721
6801
  );
6722
6802
  });
6723
6803
  child.on("exit", () => {
@@ -6725,7 +6805,7 @@ var StdioMcpClient = class extends BaseMcpClient {
6725
6805
  this.child = void 0;
6726
6806
  this.dropped = true;
6727
6807
  this.rejectAllPending(
6728
- new chunkMHCKWQR3_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
6808
+ new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
6729
6809
  );
6730
6810
  });
6731
6811
  }
@@ -6740,7 +6820,7 @@ var StdioMcpClient = class extends BaseMcpClient {
6740
6820
  if (this.child !== void 0) return Promise.resolve();
6741
6821
  if (!this.dropped) {
6742
6822
  return Promise.reject(
6743
- new chunkMHCKWQR3_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
6823
+ new chunkA3MHE2MQ_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
6744
6824
  );
6745
6825
  }
6746
6826
  this.reconnectPromise ??= this.reconnect().finally(() => {
@@ -6761,13 +6841,13 @@ var StdioMcpClient = class extends BaseMcpClient {
6761
6841
  lastErr = err;
6762
6842
  }
6763
6843
  }
6764
- throw new chunkMHCKWQR3_cjs.NetworkError(`MCP ${this.name} reconnect exhausted`, {
6844
+ throw new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} reconnect exhausted`, {
6765
6845
  code: "mcp_disconnected",
6766
6846
  ...lastErr instanceof Error ? { cause: lastErr } : {}
6767
6847
  });
6768
6848
  }
6769
6849
  async close() {
6770
- this.rejectAllPending(new chunkMHCKWQR3_cjs.NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
6850
+ this.rejectAllPending(new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} closed`, { code: "mcp_closed" }));
6771
6851
  const child = this.child;
6772
6852
  this.child = void 0;
6773
6853
  this.dropped = false;
@@ -6786,7 +6866,7 @@ var StdioMcpClient = class extends BaseMcpClient {
6786
6866
  if (this.buffer.length > MAX_STDIO_BUFFER_BYTES) {
6787
6867
  this.buffer = "";
6788
6868
  this.rejectAllPending(
6789
- new chunkMHCKWQR3_cjs.NetworkError(`MCP ${this.name} exceeded stdout buffer limit`, {
6869
+ new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} exceeded stdout buffer limit`, {
6790
6870
  code: "mcp_buffer_overflow"
6791
6871
  })
6792
6872
  );
@@ -6821,7 +6901,7 @@ var StdioMcpClient = class extends BaseMcpClient {
6821
6901
  if (child !== void 0) return this.send(child, method, params);
6822
6902
  if (this.dropped) return this.reconnectAndRequest(method, params);
6823
6903
  return Promise.reject(
6824
- new chunkMHCKWQR3_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
6904
+ new chunkA3MHE2MQ_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" })
6825
6905
  );
6826
6906
  }
6827
6907
  /** M2 #59 — reconnect a dropped client, then send. Separate async path so the
@@ -6830,7 +6910,7 @@ var StdioMcpClient = class extends BaseMcpClient {
6830
6910
  await this.ensureConnected();
6831
6911
  const child = this.child;
6832
6912
  if (child === void 0) {
6833
- throw new chunkMHCKWQR3_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" });
6913
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(`MCP ${this.name} is not initialized`, { code: "mcp_not_init" });
6834
6914
  }
6835
6915
  return this.send(child, method, params);
6836
6916
  }
@@ -6847,7 +6927,7 @@ var StdioMcpClient = class extends BaseMcpClient {
6847
6927
  this.child = void 0;
6848
6928
  this.dropped = true;
6849
6929
  this.rejectAllPending(
6850
- new chunkMHCKWQR3_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
6930
+ new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} disconnected`, { code: "mcp_disconnected" })
6851
6931
  );
6852
6932
  }, this.timeoutMs);
6853
6933
  this.pending.set(id, { resolve, reject, timer });
@@ -6918,14 +6998,14 @@ var HttpMcpClient = class extends BaseMcpClient {
6918
6998
  async readBody(response) {
6919
6999
  const tipo = response.headers.get("content-type") ?? "";
6920
7000
  if (!tipo.includes("text/event-stream")) return await response.json();
6921
- const texto = await response.text();
6922
- for (const linha of texto.split(/\r?\n/)) {
6923
- if (!linha.startsWith("data:")) continue;
6924
- const carga = linha.slice(5).trim();
6925
- if (carga === "") continue;
6926
- return JSON.parse(carga);
6927
- }
6928
- throw new chunkMHCKWQR3_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
7001
+ const text = await response.text();
7002
+ for (const line of text.split(/\r?\n/)) {
7003
+ if (!line.startsWith("data:")) continue;
7004
+ const payload = line.slice(5).trim();
7005
+ if (payload === "") continue;
7006
+ return JSON.parse(payload);
7007
+ }
7008
+ throw new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
6929
7009
  code: "mcp_http_error"
6930
7010
  });
6931
7011
  }
@@ -6953,7 +7033,7 @@ var HttpMcpClient = class extends BaseMcpClient {
6953
7033
  throw cause;
6954
7034
  }
6955
7035
  if (!response.ok) {
6956
- throw new chunkMHCKWQR3_cjs.NetworkError(`MCP ${this.name} returned ${response.status}`, {
7036
+ throw new chunkA3MHE2MQ_cjs.NetworkError(`MCP ${this.name} returned ${response.status}`, {
6957
7037
  code: "mcp_http_error"
6958
7038
  });
6959
7039
  }
@@ -6969,14 +7049,14 @@ var HttpMcpClient = class extends BaseMcpClient {
6969
7049
  function resolveMcpCwd(configCwd) {
6970
7050
  if (configCwd === void 0) return process.cwd();
6971
7051
  if (path.isAbsolute(configCwd)) return configCwd;
6972
- return chunkYBFDBOUN_cjs.safePathJoin(process.cwd(), configCwd);
7052
+ return chunkQJQ2MAZF_cjs.safePathJoin(process.cwd(), configCwd);
6973
7053
  }
6974
7054
 
6975
7055
  // src/internal/providers/register-plugin-providers.ts
6976
7056
  function registerPluginProviderProfiles(entries) {
6977
7057
  let registered2 = 0;
6978
7058
  for (const entry of entries) {
6979
- chunk56ZM6P7Z_cjs.registerProvider(entry.profile);
7059
+ chunk4MWBKBS4_cjs.registerProvider(entry.profile);
6980
7060
  registered2 += 1;
6981
7061
  }
6982
7062
  return registered2;
@@ -7056,7 +7136,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
7056
7136
  if (exposedSet.has(name)) continue;
7057
7137
  const hint = suggestClosest(name, exposedSet);
7058
7138
  const message = hint !== void 0 ? `[theokit-sdk] personality "${opts?.personalityName ?? "?"}" references unknown tool "${name}"; did you mean "${hint}"?` : `[theokit-sdk] personality "${opts?.personalityName ?? "?"}" references unknown tool "${name}" (not exposed)`;
7059
- chunkFAY3QDGC_cjs.warnOnce(
7139
+ chunkM4OGSS66_cjs.warnOnce(
7060
7140
  `personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
7061
7141
  message
7062
7142
  );
@@ -7165,25 +7245,25 @@ function createRealLocalRun(options) {
7165
7245
  }
7166
7246
  var pluginProvidersAnnounced = false;
7167
7247
  function resolveRunProvider(options) {
7168
- chunk56ZM6P7Z_cjs.registerBuiltins();
7248
+ chunk4MWBKBS4_cjs.registerBuiltins();
7169
7249
  const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
7170
7250
  const registered2 = registerPluginProviderProfiles(profiles);
7171
7251
  if (registered2 > 0 && !pluginProvidersAnnounced) {
7172
7252
  pluginProvidersAnnounced = true;
7173
7253
  const names = profiles.map((e) => e.profile.name).join(", ");
7174
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] registered ${registered2} plugin provider profile(s): ${names}
7254
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] registered ${registered2} plugin provider profile(s): ${names}
7175
7255
  `);
7176
7256
  }
7177
7257
  const parsedModel = chunkVYHJZVL5_cjs.parseModelId(options.model?.id);
7178
- const modelInferredProvider = parsedModel.provider !== void 0 && chunk56ZM6P7Z_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
7179
- const keyInferredProvider = chunkALU3KC4G_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
7180
- const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkALU3KC4G_cjs.detectPrimaryProvider();
7258
+ const modelInferredProvider = parsedModel.provider !== void 0 && chunk4MWBKBS4_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
7259
+ const keyInferredProvider = chunkG7X2Y7Y2_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
7260
+ const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkG7X2Y7Y2_cjs.detectPrimaryProvider();
7181
7261
  const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
7182
7262
  return { primary, effectiveModelId };
7183
7263
  }
7184
7264
  function mergeExplicitApiKey(pools, primary, apiKey) {
7185
7265
  if (apiKey === void 0 || apiKey.length === 0) return pools;
7186
- if (chunkALU3KC4G_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
7266
+ if (chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
7187
7267
  const existing = pools?.[primary];
7188
7268
  if (existing !== void 0 && existing.length > 0) return pools;
7189
7269
  return { ...pools ?? {}, [primary]: [apiKey] };
@@ -7191,7 +7271,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
7191
7271
  function buildLoopInputs(options, runId, userText, userImages) {
7192
7272
  const maxIterations = options.sendOptions.maxIterations;
7193
7273
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
7194
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
7274
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
7195
7275
  `SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
7196
7276
  { code: "invalid_max_iterations" }
7197
7277
  );
@@ -7206,14 +7286,14 @@ function buildLoopInputs(options, runId, userText, userImages) {
7206
7286
  const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
7207
7287
  const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
7208
7288
  const rateLimitSink = options.sendOptions.onRunEvent;
7209
- const chain = chunkALU3KC4G_cjs.resolveProviderChain({
7289
+ const chain = chunkG7X2Y7Y2_cjs.resolveProviderChain({
7210
7290
  primary,
7211
7291
  ...fallback !== void 0 ? { fallback } : {},
7212
7292
  ...apiKeys !== void 0 ? { apiKeys } : {},
7213
7293
  ...credentialPoolStrategy !== void 0 ? { credentialPoolStrategy } : {},
7214
7294
  ...extractToolCallsFromContent === true ? { extractToolCallsFromContent: true } : {},
7215
7295
  ...rateLimitSink !== void 0 ? {
7216
- onRateLimit: (info) => chunk6EDQBX7U_cjs.emitRunEvent(rateLimitSink, { type: "rate_limit", ...info })
7296
+ onRateLimit: (info) => chunk3MUIYMUG_cjs.emitRunEvent(rateLimitSink, { type: "rate_limit", ...info })
7217
7297
  } : {}
7218
7298
  });
7219
7299
  const llm = chain.length === 1 ? chain[0] : new FallbackLlmClient(chain);
@@ -7354,7 +7434,26 @@ var RealLocalRun = class extends FixtureRunBase {
7354
7434
  }
7355
7435
  }
7356
7436
  }
7437
+ /**
7438
+ * theokit#140 - events already handed to stream() by the live subscriber.
7439
+ *
7440
+ * The loop still RETURNS its full event list, and that batch path is deliberately kept: it is the
7441
+ * fallback if a live event is ever lost, and removing it would make the live channel a single
7442
+ * point of failure for the whole transcript.
7443
+ */
7444
+ liveDelivered = /* @__PURE__ */ new Set();
7357
7445
  async executeAgentLoop(inputs) {
7446
+ inputs.onLoopEvent = (event) => {
7447
+ this.liveDelivered.add(event);
7448
+ this.script.events.push(event);
7449
+ this.pushTimeline({ kind: "message", message: event });
7450
+ this.notifyNewEvents();
7451
+ };
7452
+ const callerOnDelta = inputs.onDelta;
7453
+ inputs.onDelta = (delta) => {
7454
+ callerOnDelta?.(delta);
7455
+ this.pushTimeline({ kind: "delta", update: delta.update });
7456
+ };
7358
7457
  try {
7359
7458
  const output = inputs.activeTools !== void 0 ? await chunkVJ26EKGJ_cjs.withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : await runAgentLoop(inputs);
7360
7459
  this.applyAgentLoopOutput(output);
@@ -7377,10 +7476,7 @@ var RealLocalRun = class extends FixtureRunBase {
7377
7476
  * Finding-B fix (sdk-error-packaging v1.1): set-once errorDetail copy.
7378
7477
  */
7379
7478
  applyAgentLoopOutput(output) {
7380
- for (const event of output.events) {
7381
- this.script.events.push(event);
7382
- this.notifyNewEvents();
7383
- }
7479
+ this.deliverUndeliveredEvents(output.events);
7384
7480
  this.script.conversation.push(...output.conversation);
7385
7481
  if (output.result.length > 0) this.script.result = output.result;
7386
7482
  if (output.usage !== void 0) this.script.usage = output.usage;
@@ -7395,6 +7491,25 @@ var RealLocalRun = class extends FixtureRunBase {
7395
7491
  };
7396
7492
  }
7397
7493
  }
7494
+ /**
7495
+ * theokit#140 - deliver only what the live subscriber has NOT already handed to `stream()`.
7496
+ *
7497
+ * The loop now reports each event as it happens, so this batch is the SAME list, replayed.
7498
+ * Without the guard every event would reach `stream()` twice: once live, once here.
7499
+ *
7500
+ * Identity, not deep equality: these are the very objects the live sink saw, and two genuinely
7501
+ * distinct events can be structurally identical (the same tool called twice with the same args
7502
+ * is not a duplicate).
7503
+ *
7504
+ * Extracted because the guard pushed `applyAgentLoopOutput` past the cognitive-complexity cap.
7505
+ */
7506
+ deliverUndeliveredEvents(events) {
7507
+ for (const event of events) {
7508
+ if (this.liveDelivered.has(event)) continue;
7509
+ this.script.events.push(event);
7510
+ this.notifyNewEvents();
7511
+ }
7512
+ }
7398
7513
  emitErrorEvent(cause, fallback, prefix = "", code) {
7399
7514
  if (this.script.errorDetail === void 0) {
7400
7515
  const message = cause instanceof Error ? cause.message : String(cause);
@@ -7431,7 +7546,7 @@ function buildRealRunOptions(args) {
7431
7546
  };
7432
7547
  }
7433
7548
  async function createFixtureRunHelper(args) {
7434
- const sessionMessages = chunkH5YVJB4K_cjs.getSessionMessages(args.inputs.agentId);
7549
+ const sessionMessages = chunk6ZGD7R27_cjs.getSessionMessages(args.inputs.agentId);
7435
7550
  const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
7436
7551
  return createLocalRun({
7437
7552
  agentId: args.inputs.agentId,
@@ -7450,7 +7565,7 @@ async function createFixtureRunHelper(args) {
7450
7565
  }
7451
7566
  async function dispatchLocalRun(args) {
7452
7567
  const apiKey = resolveApiKey(args.inputs.options.apiKey);
7453
- if (chunkALU3KC4G_cjs.shouldUseRealLocalRuntime(apiKey)) {
7568
+ if (chunkG7X2Y7Y2_cjs.shouldUseRealLocalRuntime(apiKey)) {
7454
7569
  return createRealLocalRun(
7455
7570
  buildRealRunOptions({
7456
7571
  inputs: args.inputs,
@@ -7485,20 +7600,20 @@ async function readProjectMcpServers(cwd) {
7485
7600
 
7486
7601
  // src/internal/local-agent/local-agent-invalidate.ts
7487
7602
  async function applyDeferredInvalidation(agentId, pending, refresh) {
7488
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] applying deferred cache invalidation (${agentId}): ${pending.reason}
7603
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] applying deferred cache invalidation (${agentId}): ${pending.reason}
7489
7604
  `);
7490
7605
  try {
7491
7606
  await refresh();
7492
7607
  } catch (err) {
7493
7608
  const msg = err instanceof Error ? err.message : String(err);
7494
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] invalidateCache reload failed (continuing): ${msg}
7609
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] invalidateCache reload failed (continuing): ${msg}
7495
7610
  `);
7496
7611
  }
7497
7612
  }
7498
7613
  async function invalidateCacheImpl(agentId, reason, options, disposed, dispose, setPending) {
7499
7614
  if (disposed) return;
7500
7615
  if (options.applyNow === true) {
7501
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] invalidateCache applyNow disposing agent (${agentId}): ${reason}
7616
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] invalidateCache applyNow disposing agent (${agentId}): ${reason}
7502
7617
  `);
7503
7618
  await dispose();
7504
7619
  return;
@@ -7559,7 +7674,7 @@ var LiveAgentRegistry = class {
7559
7674
  const existing = this.#agents.get(id);
7560
7675
  if (existing !== void 0 && existing.agent !== agent) {
7561
7676
  void existing.agent.dispose().catch(() => {
7562
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] dispose during overwrite failed (${id})
7677
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] dispose during overwrite failed (${id})
7563
7678
  `);
7564
7679
  });
7565
7680
  }
@@ -7663,7 +7778,7 @@ var LiveAgentRegistry = class {
7663
7778
  await agent.dispose();
7664
7779
  } catch (cause) {
7665
7780
  const msg = cause instanceof Error ? cause.message : String(cause);
7666
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] dispose during eviction failed (${id}): ${msg}
7781
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] dispose during eviction failed (${id}): ${msg}
7667
7782
  `);
7668
7783
  }
7669
7784
  if (this.#onEvict !== void 0) {
@@ -7671,7 +7786,7 @@ var LiveAgentRegistry = class {
7671
7786
  this.#onEvict(id, reason);
7672
7787
  } catch (cause) {
7673
7788
  const msg = cause instanceof Error ? cause.message : String(cause);
7674
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] onEvict listener threw (${id}): ${msg}
7789
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] onEvict listener threw (${id}): ${msg}
7675
7790
  `);
7676
7791
  }
7677
7792
  }
@@ -7680,20 +7795,20 @@ var LiveAgentRegistry = class {
7680
7795
  var liveAgentRegistry = new LiveAgentRegistry();
7681
7796
 
7682
7797
  // src/internal/local-agent/local-agent-lifecycle.ts
7683
- async function adquirirLeaseSePossivel(store, agentId) {
7798
+ async function acquireLeaseIfPossible(store, agentId) {
7684
7799
  const a = store.acquire;
7685
7800
  if (typeof a !== "function") return;
7686
7801
  try {
7687
7802
  await a.call(store, agentId);
7688
7803
  } catch (err) {
7689
7804
  if (err instanceof Error && err.name === "SessionBusyError") throw err;
7690
- chunkLTCOPATU_cjs.diag(
7805
+ chunkBE3W4HYV_cjs.diag(
7691
7806
  `[theokit-sdk] writer lease unavailable for ${agentId} (${err instanceof Error ? err.message : String(err)}) \u2014 proceeding without single-writer protection
7692
7807
  `
7693
7808
  );
7694
7809
  }
7695
7810
  }
7696
- async function soltarLeaseSePossivel(store, agentId) {
7811
+ async function releaseLeaseIfPossible(store, agentId) {
7697
7812
  const r = store.release;
7698
7813
  if (typeof r === "function") await r.call(store, agentId);
7699
7814
  }
@@ -7706,16 +7821,16 @@ async function disposeLocalAgentSession(agent) {
7706
7821
  agent.lifecycleAbortController.abort();
7707
7822
  await chunkYLQQX5W2_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
7708
7823
  disposeSessionMcpClients(agent.agentId);
7709
- await chunkH5YVJB4K_cjs.flushSessionWrites();
7824
+ await chunk6ZGD7R27_cjs.flushSessionWrites();
7710
7825
  await flushRegistrySaves(agent.workspaceCwd);
7711
7826
  await disposeSessionStore(agent.sessionStore);
7712
- chunkH5YVJB4K_cjs.descartarSessao(agent.workspaceCwd, agent.agentId);
7827
+ chunk6ZGD7R27_cjs.discardSession(agent.workspaceCwd, agent.agentId);
7713
7828
  }
7714
7829
  async function reloadLocalAgent(agent) {
7715
7830
  if (agent.context !== void 0) await agent.context.refresh();
7716
7831
  if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
7717
7832
  if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
7718
- return await chunkGM7QDQ24_cjs.loadSubagents(
7833
+ return await chunkMXRBNJ6D_cjs.loadSubagents(
7719
7834
  agent.workspaceCwd,
7720
7835
  agent.settingSourcesIncludeProject,
7721
7836
  agent.options.agents
@@ -7723,12 +7838,12 @@ async function reloadLocalAgent(agent) {
7723
7838
  }
7724
7839
  async function persistActiveMemoryTranscript(cwd, transcript) {
7725
7840
  try {
7726
- const dir = path.join(chunk2423XDPT_cjs.memoryDir(cwd), "transcripts", "active-memory");
7841
+ const dir = path.join(chunk3BSP7LSG_cjs.memoryDir(cwd), "transcripts", "active-memory");
7727
7842
  const file = path.join(dir, `${transcript.runId}.json`);
7728
- await chunkICYBIC6N_cjs.atomicWriteJson(file, transcript);
7843
+ await chunkYVI4YPUP_cjs.atomicWriteJson(file, transcript);
7729
7844
  } catch (cause) {
7730
7845
  const message = cause instanceof Error ? cause.message : String(cause);
7731
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] active-memory transcript persist failed: ${message}
7846
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] active-memory transcript persist failed: ${message}
7732
7847
  `);
7733
7848
  }
7734
7849
  }
@@ -7849,7 +7964,7 @@ async function searchOnce(args, cfg, query, started) {
7849
7964
  return { summary, durationMs: Date.now() - started, status: "ok", hits };
7850
7965
  } catch (cause) {
7851
7966
  const message = cause instanceof Error ? cause.message : String(cause);
7852
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] active-memory recall failed: ${message}
7967
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] active-memory recall failed: ${message}
7853
7968
  `);
7854
7969
  return { summary: void 0, durationMs: Date.now() - started, status: "error", hits: [] };
7855
7970
  }
@@ -7961,17 +8076,17 @@ async function createOpenAiCompatibleRuntime(cfg, options) {
7961
8076
  const model = options.model ?? cfg.defaultModel;
7962
8077
  const apiKey = options.apiKey ?? process.env[cfg.apiKeyEnv];
7963
8078
  if (apiKey === void 0 || apiKey.length === 0) {
7964
- throw new chunkMHCKWQR3_cjs.AuthenticationError(`${cfg.apiKeyEnv} missing`, {
8079
+ throw new chunkA3MHE2MQ_cjs.AuthenticationError(`${cfg.apiKeyEnv} missing`, {
7965
8080
  code: "embedding_missing_api_key"
7966
8081
  });
7967
8082
  }
7968
8083
  const envBaseUrl = cfg.baseUrlEnv !== void 0 ? process.env[cfg.baseUrlEnv] : void 0;
7969
8084
  const baseUrl = options.baseUrl ?? envBaseUrl ?? cfg.defaultBaseUrl;
7970
8085
  const fetchImpl = options.fetch ?? fetch;
7971
- const cache = options.cache ?? chunk2423XDPT_cjs.globalEmbeddingCache;
8086
+ const cache = options.cache ?? chunk3BSP7LSG_cjs.globalEmbeddingCache;
7972
8087
  const dimension = cfg.dimensionByModel[model];
7973
8088
  if (dimension === void 0) {
7974
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
8089
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
7975
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.`,
7976
8091
  { code: "embedding_unknown_model" }
7977
8092
  );
@@ -8042,7 +8157,7 @@ async function embedInBoundedBatches(input, pending, results) {
8042
8157
  for (let offset = 0; offset < pending.length; offset += MAX_BATCH) {
8043
8158
  batches.push(pending.slice(offset, offset + MAX_BATCH));
8044
8159
  }
8045
- await chunkSWIBQFPH_cjs.mapWithConcurrency(
8160
+ await chunk3XRXORBS_cjs.mapWithConcurrency(
8046
8161
  batches,
8047
8162
  MAX_CONCURRENT_BATCHES,
8048
8163
  (batch) => processBatch(input, batch, results)
@@ -8087,7 +8202,7 @@ async function embedBatch(opts) {
8087
8202
  body = JSON.parse(text);
8088
8203
  } catch {
8089
8204
  }
8090
- throw chunkALU3KC4G_cjs.mapOpenAICompatibleError({
8205
+ throw chunkG7X2Y7Y2_cjs.mapOpenAICompatibleError({
8091
8206
  providerId: opts.providerId,
8092
8207
  status: response.status,
8093
8208
  body,
@@ -8109,7 +8224,7 @@ async function postEmbedRequest(opts, url) {
8109
8224
  async function parseEmbedResponse(response, providerId, endpoint) {
8110
8225
  const json = await response.json();
8111
8226
  if (!Array.isArray(json.data)) {
8112
- throw new chunkMHCKWQR3_cjs.NetworkError(`${providerId} ${endpoint} returned no data`, {
8227
+ throw new chunkA3MHE2MQ_cjs.NetworkError(`${providerId} ${endpoint} returned no data`, {
8113
8228
  code: "embedding_invalid_response",
8114
8229
  metadata: {
8115
8230
  provider: providerId,
@@ -8507,7 +8622,7 @@ function createMemorySearchTool(opts) {
8507
8622
  };
8508
8623
  }
8509
8624
  function createMemoryGetTool(opts) {
8510
- const memoryRoot = path.resolve(chunk2423XDPT_cjs.memoryDir(opts.cwd));
8625
+ const memoryRoot = path.resolve(chunk3BSP7LSG_cjs.memoryDir(opts.cwd));
8511
8626
  return {
8512
8627
  name: "memory_get",
8513
8628
  description: GET_DESCRIPTION,
@@ -8518,7 +8633,7 @@ function createMemoryGetTool(opts) {
8518
8633
  const lines = readNumber(input.lines);
8519
8634
  const resolved = path.resolve(memoryRoot, relPath);
8520
8635
  if (!isPathInside(memoryRoot, resolved)) {
8521
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
8636
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
8522
8637
  `memory_get rejected path that escapes memory root: ${relPath}`,
8523
8638
  { code: "memory_path_escapes_root" }
8524
8639
  );
@@ -8538,7 +8653,7 @@ function readString(value, errorIfMissing, allowUndefined = false) {
8538
8653
  if (typeof value === "string") return value;
8539
8654
  if (allowUndefined && (value === void 0 || value === null)) return "";
8540
8655
  if (errorIfMissing !== void 0) {
8541
- throw new chunkMHCKWQR3_cjs.ConfigurationError(errorIfMissing, { code: "memory_tool_bad_args" });
8656
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(errorIfMissing, { code: "memory_tool_bad_args" });
8542
8657
  }
8543
8658
  return "";
8544
8659
  }
@@ -8614,7 +8729,7 @@ var LocalAgentMemory = class {
8614
8729
  const openOpts = { cwd: this.workspaceCwd };
8615
8730
  if (embedding !== void 0) openOpts.embedding = embedding;
8616
8731
  if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
8617
- this.index = await chunk2423XDPT_cjs.IndexManager.open(openOpts);
8732
+ this.index = await chunk3BSP7LSG_cjs.IndexManager.open(openOpts);
8618
8733
  await this.index.sync();
8619
8734
  this.toolsCache = [
8620
8735
  createMemorySearchTool({ index: this.index }),
@@ -8629,7 +8744,7 @@ var LocalAgentMemory = class {
8629
8744
  const warned2 = g[sym];
8630
8745
  if (!warned2.has(message)) {
8631
8746
  warned2.add(message);
8632
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] memory tools unavailable: ${message}
8747
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] memory tools unavailable: ${message}
8633
8748
  `);
8634
8749
  }
8635
8750
  return void 0;
@@ -8638,7 +8753,7 @@ var LocalAgentMemory = class {
8638
8753
  async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
8639
8754
  const cfg = this.options.memory?.activeRecall;
8640
8755
  if (cfg?.enabled !== true || this.index === void 0) return void 0;
8641
- if (this.breaker === void 0) this.breaker = new chunkALU3KC4G_cjs.CircuitBreaker();
8756
+ if (this.breaker === void 0) this.breaker = new chunkG7X2Y7Y2_cjs.CircuitBreaker();
8642
8757
  if (this.cache === void 0) this.cache = new ActiveMemoryCache();
8643
8758
  const result = await runActiveMemory({
8644
8759
  userText,
@@ -8688,7 +8803,7 @@ var LocalAgentMemory = class {
8688
8803
  await this.index.sync();
8689
8804
  } catch (cause) {
8690
8805
  const message = cause instanceof Error ? cause.message : String(cause);
8691
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] session index sync failed: ${message}
8806
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] session index sync failed: ${message}
8692
8807
  `);
8693
8808
  }
8694
8809
  }
@@ -8701,7 +8816,7 @@ var LocalAgentMemory = class {
8701
8816
  return await adapter.create(cfg.model !== void 0 ? { model: cfg.model } : {});
8702
8817
  } catch (cause) {
8703
8818
  const message = cause instanceof Error ? cause.message : String(cause);
8704
- chunkLTCOPATU_cjs.diag(`[theokit-sdk] memory embedding ${cfg.provider} unavailable: ${message}
8819
+ chunkBE3W4HYV_cjs.diag(`[theokit-sdk] memory embedding ${cfg.provider} unavailable: ${message}
8705
8820
  `);
8706
8821
  return void 0;
8707
8822
  }
@@ -8737,7 +8852,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
8737
8852
  ...partial?.metadata !== void 0 ? { metadata: partial.metadata } : defaultContext?.metadata !== void 0 ? { metadata: defaultContext.metadata } : {}
8738
8853
  };
8739
8854
  if (merged.userId === "") {
8740
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
8855
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
8741
8856
  "agent.memory requires a userId \u2014 either set AgentOptions.memoryContext.userId or pass ctx.userId at call time.",
8742
8857
  { code: "memory_context_missing_user_id" }
8743
8858
  );
@@ -8747,7 +8862,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
8747
8862
  async function requireAdapters() {
8748
8863
  const r = await ensure();
8749
8864
  if (r.adapters.length === 0) {
8750
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
8865
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
8751
8866
  "No memory adapter registered. Pass a memory plugin in AgentOptions.plugins (e.g. supermemoryMemory({...})).",
8752
8867
  { code: "no_memory_adapter" }
8753
8868
  );
@@ -8788,7 +8903,7 @@ function buildAgentMemory(pluginManager, workspaceCwd, defaultContext) {
8788
8903
  const prefix = id.split(":", 1)[0] ?? "";
8789
8904
  const target = adapters.find((a) => a.id === prefix);
8790
8905
  if (target === void 0) {
8791
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
8906
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
8792
8907
  `No adapter found for MemoryId prefix "${prefix}" (registered: ${adapters.map((a) => a.id).join(", ")}).`,
8793
8908
  { code: "no_memory_adapter" }
8794
8909
  );
@@ -8861,7 +8976,7 @@ function createLocalAgentMemoryProvider(opts) {
8861
8976
  return { facts: [], systemPromptAdditions: summary };
8862
8977
  },
8863
8978
  async recordSessionSummary(args) {
8864
- await chunk2423XDPT_cjs.writeSessionSummary(args);
8979
+ await chunk3BSP7LSG_cjs.writeSessionSummary(args);
8865
8980
  },
8866
8981
  async sync(handle) {
8867
8982
  const state = handle[INTERNAL_LAM_KEY];
@@ -8939,19 +9054,19 @@ var PersonalityRegistry = class _PersonalityRegistry {
8939
9054
  function addEntity(byName, entity, origin, collisionMap) {
8940
9055
  const fm = entity.frontmatter;
8941
9056
  if (PersonalityRegistry.isReservedClearSlug(fm.name)) {
8942
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
9057
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
8943
9058
  `Personality name "${fm.name}" is reserved (used to clear active preset)`,
8944
9059
  { code: "personality_reserved_name" }
8945
9060
  );
8946
9061
  }
8947
9062
  if (entity.body.trim().length === 0) {
8948
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
9063
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
8949
9064
  `Personality "${fm.name}" has empty body (system prompt required)`,
8950
9065
  { code: "personality_empty_body" }
8951
9066
  );
8952
9067
  }
8953
9068
  if (origin === "project" && collisionMap?.has(fm.name)) {
8954
- chunkFAY3QDGC_cjs.warnOnce(
9069
+ chunkM4OGSS66_cjs.warnOnce(
8955
9070
  `personality-collision-${fm.name}`,
8956
9071
  `[theokit-sdk] personality "${fm.name}" overridden by project preset`
8957
9072
  );
@@ -8980,7 +9095,7 @@ async function performPersonalitySwitch(args) {
8980
9095
  const preset = args.registry.get(args.requestedName);
8981
9096
  if (preset === void 0) {
8982
9097
  const available = args.registry.all().map((p) => p.name).join(", ") || "(none)";
8983
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
9098
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
8984
9099
  `Personality "${args.requestedName}" not found. Available: ${available}`,
8985
9100
  { code: "personality_not_found" }
8986
9101
  );
@@ -9001,14 +9116,14 @@ async function performPersonalitySwitch(args) {
9001
9116
 
9002
9117
  // src/internal/local-agent/local-agent-personality-extensions.ts
9003
9118
  function resolveActivePersonalityPreset(args) {
9004
- const forkCtx = chunkFAY3QDGC_cjs.currentPersonalityContext();
9119
+ const forkCtx = chunkM4OGSS66_cjs.currentPersonalityContext();
9005
9120
  const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
9006
9121
  if (slug === void 0) return void 0;
9007
9122
  return args.personalityRegistry?.get(slug);
9008
9123
  }
9009
9124
  async function ensurePersonalityRegistryIfNeeded(args) {
9010
9125
  if (args.personalityRegistry !== void 0) return args.personalityRegistry;
9011
- const forkSlug = chunkFAY3QDGC_cjs.currentPersonalityContext()?.slug;
9126
+ const forkSlug = chunkM4OGSS66_cjs.currentPersonalityContext()?.slug;
9012
9127
  const ownSlug = args.personalityStore.active(args.agentId);
9013
9128
  if (forkSlug === void 0 && ownSlug === void 0) return void 0;
9014
9129
  return await PersonalityRegistry.load(args.workspaceCwd);
@@ -9022,8 +9137,8 @@ ${preset.systemPrompt}`;
9022
9137
  }
9023
9138
  async function localAgentUsePersonality(args) {
9024
9139
  if (args.disposed) throw new Error("Agent has been disposed");
9025
- if (chunkFAY3QDGC_cjs.currentPersonalityContext() !== void 0) {
9026
- chunkFAY3QDGC_cjs.warnPersonalitySwitchInsideFork(args.agentId);
9140
+ if (chunkM4OGSS66_cjs.currentPersonalityContext() !== void 0) {
9141
+ chunkM4OGSS66_cjs.warnPersonalitySwitchInsideFork(args.agentId);
9027
9142
  return null;
9028
9143
  }
9029
9144
  let registry = args.personalityRegistry;
@@ -9040,8 +9155,8 @@ async function localAgentUsePersonality(args) {
9040
9155
  registry,
9041
9156
  store: args.personalityStore,
9042
9157
  invalidateCache: (reason) => args.invalidateCache(reason),
9043
- appendSessionMessage: (msg) => chunkH5YVJB4K_cjs.appendSessionMessage(args.agentId, msg),
9044
- clearSession: () => chunkH5YVJB4K_cjs.clearSession(args.agentId),
9158
+ appendSessionMessage: (msg) => chunk6ZGD7R27_cjs.appendSessionMessage(args.agentId, msg),
9159
+ clearSession: () => chunk6ZGD7R27_cjs.clearSession(args.agentId),
9045
9160
  opts: args.opts ?? {}
9046
9161
  })
9047
9162
  );
@@ -9050,9 +9165,9 @@ async function localAgentUsePersonality(args) {
9050
9165
  // src/internal/local-agent/local-agent-runtime-extensions.ts
9051
9166
  function localAgentRunUntil(agent, goal, options) {
9052
9167
  async function* wrap() {
9053
- const { runUntilImpl } = await import('./run-until-ZZ2JLPJM.cjs');
9168
+ const { runUntilImpl } = await import('./run-until-L5KQD3PV.cjs');
9054
9169
  const buildDeps = async () => {
9055
- const { judgeCallImpl } = await import('./judge-call-SP3G3X2Y.cjs');
9170
+ const { judgeCallImpl } = await import('./judge-call-XIQJ5GIE.cjs');
9056
9171
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
9057
9172
  const create = getAgentFacade().create;
9058
9173
  return {
@@ -9085,7 +9200,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
9085
9200
  async function localAgentFork(parent, options) {
9086
9201
  const { forkAgentImpl } = await import('./fork-agent-Y2IK2RYU.cjs');
9087
9202
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
9088
- const { withPersonalityContext } = await import('./context-ZV33V4DC.cjs');
9203
+ const { withPersonalityContext } = await import('./context-Q6ISOCN2.cjs');
9089
9204
  const create = getAgentFacade().create;
9090
9205
  return withPersonalityContext(
9091
9206
  { slug: parent.personalitySlugSnapshot, isFork: true },
@@ -9145,7 +9260,7 @@ function wrapRunWithCompletionCheck(args) {
9145
9260
  judgeOpts
9146
9261
  );
9147
9262
  const complete = !verdict.parseFailed && verdict.verdict === "done";
9148
- chunk6EDQBX7U_cjs.emitRunEvent(args.onRunEvent, {
9263
+ chunk3MUIYMUG_cjs.emitRunEvent(args.onRunEvent, {
9149
9264
  type: "completion_check",
9150
9265
  complete,
9151
9266
  reason: verdict.reason
@@ -9241,6 +9356,9 @@ var SUPPORTED = /* @__PURE__ */ new Set([
9241
9356
  "cancel",
9242
9357
  "conversation"
9243
9358
  ]);
9359
+ function emptyTimeline() {
9360
+ return emptyStream();
9361
+ }
9244
9362
  function emptyStream() {
9245
9363
  return {
9246
9364
  next: () => Promise.resolve({ done: true, value: void 0 }),
@@ -9265,6 +9383,9 @@ function createTripwireRun(args) {
9265
9383
  status: "cancelled",
9266
9384
  ...args.model !== void 0 ? { model: args.model } : {},
9267
9385
  stream: () => emptyStream(),
9386
+ // theokit#140 - a tripwire run never executed, so its timeline is empty by construction, the
9387
+ // same reason `stream()` is. Both are empty for the same fact, not by coincidence.
9388
+ events: () => emptyTimeline(),
9268
9389
  wait: () => Promise.resolve(result),
9269
9390
  cancel: () => Promise.resolve(),
9270
9391
  conversation: () => Promise.resolve([]),
@@ -9286,7 +9407,7 @@ function wrapRunWithOutputProcessors(args) {
9286
9407
  if (result.status !== "finished" || result.result === void 0) return result;
9287
9408
  const res = await runOutputProcessors(args.processors, result.result, args.agentId);
9288
9409
  if (res.kind === "ok") return { ...result, result: res.value };
9289
- chunk6EDQBX7U_cjs.emitRunEvent(args.onRunEvent, {
9410
+ chunk3MUIYMUG_cjs.emitRunEvent(args.onRunEvent, {
9290
9411
  type: "tripwire",
9291
9412
  reason: res.tripwire.reason,
9292
9413
  processorId: res.tripwire.processorId
@@ -9361,7 +9482,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
9361
9482
  }
9362
9483
  const res = await runInputProcessors(processors, rawUserText, inputs.agentId);
9363
9484
  if (res.kind === "tripwire") {
9364
- chunk6EDQBX7U_cjs.emitRunEvent(options.onRunEvent, {
9485
+ chunk3MUIYMUG_cjs.emitRunEvent(options.onRunEvent, {
9365
9486
  type: "tripwire",
9366
9487
  reason: res.tripwire.reason,
9367
9488
  processorId: res.tripwire.processorId
@@ -9378,7 +9499,7 @@ async function applyInputProcessors(inputs, message, rawUserText, options, sendM
9378
9499
  return { userText: res.value, effectiveMessage };
9379
9500
  }
9380
9501
  async function executeSendLocked(inputs, message, options) {
9381
- if (inputs.disposed) throw new chunkMHCKWQR3_cjs.AgentDisposedError(inputs.agentId);
9502
+ if (inputs.disposed) throw new chunkA3MHE2MQ_cjs.AgentDisposedError(inputs.agentId);
9382
9503
  await consumePending(inputs.agentId, inputs.invalidationPending, inputs.clearInvalidation, inputs.reload);
9383
9504
  const sendModel = normalizeModel(options.model);
9384
9505
  inputs.applyModelOverride(sendModel);
@@ -9389,7 +9510,7 @@ async function executeSendLocked(inputs, message, options) {
9389
9510
  if (inputs.options.onBeforeSend !== void 0) {
9390
9511
  await inputs.options.onBeforeSend({
9391
9512
  conversationId: inputs.agentId,
9392
- previousMessageCount: chunkH5YVJB4K_cjs.getSessionMessages(inputs.agentId).length
9513
+ previousMessageCount: chunk6ZGD7R27_cjs.getSessionMessages(inputs.agentId).length
9393
9514
  });
9394
9515
  }
9395
9516
  await inputs.runPreHook(userText);
@@ -9401,8 +9522,8 @@ async function executeSendLocked(inputs, message, options) {
9401
9522
  userText,
9402
9523
  sendOptions: options
9403
9524
  });
9404
- const priorMessages = [...chunkH5YVJB4K_cjs.getSessionMessages(inputs.agentId)];
9405
- chunkH5YVJB4K_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9525
+ const priorMessages = [...chunk6ZGD7R27_cjs.getSessionMessages(inputs.agentId)];
9526
+ chunk6ZGD7R27_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9406
9527
  await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
9407
9528
  const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
9408
9529
  const portPathActive = shouldUsePortMemoryPath();
@@ -9460,7 +9581,7 @@ async function executeSendLocked(inputs, message, options) {
9460
9581
  function buildCompletionCheckDeps() {
9461
9582
  return {
9462
9583
  judge: async (ctx, opts) => {
9463
- const { judgeCallImpl } = await import('./judge-call-SP3G3X2Y.cjs');
9584
+ const { judgeCallImpl } = await import('./judge-call-XIQJ5GIE.cjs');
9464
9585
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
9465
9586
  return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
9466
9587
  }
@@ -9480,7 +9601,7 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
9480
9601
  promptPreview: userText.slice(0, 120),
9481
9602
  ...opts.meta ?? {}
9482
9603
  };
9483
- void chunk6EDQBX7U_cjs.submit({
9604
+ void chunk3MUIYMUG_cjs.submit({
9484
9605
  kind: "run",
9485
9606
  work: async (ctx) => {
9486
9607
  ctx.signal.addEventListener(
@@ -9564,7 +9685,7 @@ var LocalAgent = class {
9564
9685
  this.options = options;
9565
9686
  this.workspaceCwd = resolveCwd(options.local?.cwd);
9566
9687
  this.transcriptBaseDir = resolveBaseDir(options.local?.baseDir);
9567
- this.sessionStore = options.local?.sessionStore ?? new chunkITLS5LRF_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
9688
+ this.sessionStore = options.local?.sessionStore ?? new chunk2R6NBT5F_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
9568
9689
  this.settingSourcesIncludeProject = includesSetting(options, "project");
9569
9690
  this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
9570
9691
  const sub = bootstrapSubmanagers({
@@ -9607,17 +9728,17 @@ var LocalAgent = class {
9607
9728
  if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
9608
9729
  const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
9609
9730
  await this.pluginManagerCode.initialize(codePlugins);
9610
- this.resolvedSubagents = await chunkGM7QDQ24_cjs.loadSubagents(
9731
+ this.resolvedSubagents = await chunkMXRBNJ6D_cjs.loadSubagents(
9611
9732
  this.workspaceCwd,
9612
9733
  this.settingSourcesIncludeProject,
9613
9734
  this.options.agents
9614
9735
  );
9615
- await adquirirLeaseSePossivel(this.sessionStore, this.agentId);
9736
+ await acquireLeaseIfPossible(this.sessionStore, this.agentId);
9616
9737
  try {
9617
- await chunkH5YVJB4K_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9738
+ await chunk6ZGD7R27_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9618
9739
  await this.personalityStore.hydrate(this.agentId);
9619
9740
  } catch (err) {
9620
- await soltarLeaseSePossivel(this.sessionStore, this.agentId);
9741
+ await releaseLeaseIfPossible(this.sessionStore, this.agentId);
9621
9742
  throw err;
9622
9743
  }
9623
9744
  }
@@ -9650,16 +9771,16 @@ var LocalAgent = class {
9650
9771
  });
9651
9772
  }
9652
9773
  /**
9653
- * A janela de contexto declarada na seleção de modelo, no formato de spread condicional.
9774
+ * The context window declared on the model selection, in conditional-spread form.
9654
9775
  *
9655
- * M94 — sem isto, o `override` de `resolveEffectiveContextWindow` existia desde o M77 e nenhum
9656
- * call site de produção o passava: um modelo de 400k sem entrada de catálogo era orçado contra o
9657
- * piso de 128k. Método próprio porque o spread inline empurrava `runLockedSendCycle` para além do
9658
- * teto de complexidade cognitiva do projeto.
9776
+ * M94 — without this, `resolveEffectiveContextWindow`'s `override` had existed since M77 and no
9777
+ * production call site passed it: a 400k model with no catalog entry was budgeted against the
9778
+ * 128k floor. Its own method because the inline spread pushed `runLockedSendCycle` past the
9779
+ * project's cognitive-complexity ceiling.
9659
9780
  */
9660
- #janelaDeclarada() {
9661
- const declarada = this.model?.contextWindow;
9662
- return declarada !== void 0 ? { contextWindow: declarada } : {};
9781
+ #declaredWindow() {
9782
+ const declared = this.model?.contextWindow;
9783
+ return declared !== void 0 ? { contextWindow: declared } : {};
9663
9784
  }
9664
9785
  async runLockedSendCycle(message, options, sendSpan, resolve, reject) {
9665
9786
  const userText = typeof message === "string" ? message : message.text;
@@ -9688,7 +9809,7 @@ var LocalAgent = class {
9688
9809
  workspaceCwd: this.workspaceCwd,
9689
9810
  sessionStore: this.sessionStore,
9690
9811
  model: this.model?.id ?? "unknown",
9691
- ...this.#janelaDeclarada(),
9812
+ ...this.#declaredWindow(),
9692
9813
  // M50 — the auto-compaction summarizer resolves credentials like the run itself.
9693
9814
  ...this.options.apiKey !== void 0 ? { apiKey: this.options.apiKey } : {},
9694
9815
  ...options.onRunEvent !== void 0 ? { onRunEvent: options.onRunEvent } : {},
@@ -9763,7 +9884,7 @@ var LocalAgent = class {
9763
9884
  agentId: this.agentId
9764
9885
  });
9765
9886
  if (preRun.blocked) {
9766
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
9887
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
9767
9888
  `preRun hook denied execution: ${preRun.reason ?? "unspecified"}`,
9768
9889
  { code: "hook_denied" }
9769
9890
  );
@@ -9844,7 +9965,7 @@ var LocalAgent = class {
9844
9965
  }
9845
9966
  // biome-ignore format: G8 budget — see listArtifacts.
9846
9967
  downloadArtifact(_path) {
9847
- return Promise.reject(new chunkMHCKWQR3_cjs.UnsupportedRunOperationError("Artifacts are not supported for local agents", "downloadArtifact"));
9968
+ return Promise.reject(new chunkA3MHE2MQ_cjs.UnsupportedRunOperationError("Artifacts are not supported for local agents", "downloadArtifact"));
9848
9969
  }
9849
9970
  // biome-ignore format: G8 budget — delegates to `local-agent-runtime-extensions.ts`; kept 1-line.
9850
9971
  runUntil(goal, options) {
@@ -9867,7 +9988,7 @@ function resolveCwd(cwd) {
9867
9988
  return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
9868
9989
  }
9869
9990
  function resolveBaseDir(baseDir) {
9870
- return baseDir === void 0 ? chunkIEUDKUPM_cjs.defaultBaseDir() : chunkIEUDKUPM_cjs.expandTilde(baseDir);
9991
+ return baseDir === void 0 ? chunk6OKPJZMX_cjs.defaultBaseDir() : chunk6OKPJZMX_cjs.expandTilde(baseDir);
9871
9992
  }
9872
9993
  function includesSetting(options, source) {
9873
9994
  const sources = options.local?.settingSources;
@@ -9892,7 +10013,7 @@ async function guardAgainstIdCollision(options) {
9892
10013
  const persistenceCwd = resolveAgentPersistenceCwd(options);
9893
10014
  await hydrateRegistryFromDisk(persistenceCwd);
9894
10015
  if (getRegisteredAgent(options.agentId) !== void 0) {
9895
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
10016
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
9896
10017
  `Agent "${options.agentId}" already exists. Use Agent.resume("${options.agentId}") to reattach, or pick a different agentId.`,
9897
10018
  { code: "agent_id_already_exists" }
9898
10019
  );
@@ -9925,7 +10046,7 @@ async function maybeInjectHandoffTools(options) {
9925
10046
  const spec = "@theokit/sdk-handoff/internal/tool-injector";
9926
10047
  mod = await import(spec);
9927
10048
  } catch (err) {
9928
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
10049
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
9929
10050
  "Agent.create({ handoffs: [...] }) requires @theokit/sdk-handoff. Install it: pnpm add @theokit/sdk-handoff. Or migrate to the preferred plugin pattern: plugins: [Handoff.asPlugin({ targets: [...] })] (see docs/migration/1-x-to-2-0.md#handoff).",
9930
10051
  { code: "handoff_package_missing", cause: err }
9931
10052
  );
@@ -9945,9 +10066,9 @@ async function maybeInjectHandoffTools(options) {
9945
10066
  async function createLocalAgent(options) {
9946
10067
  const apiKey = resolveApiKey(options.apiKey);
9947
10068
  if (apiKey === void 0) {
9948
- throw new chunkMHCKWQR3_cjs.AuthenticationError("Missing API key", { code: "missing_api_key" });
10069
+ throw new chunkA3MHE2MQ_cjs.AuthenticationError("Missing API key", { code: "missing_api_key" });
9949
10070
  }
9950
- const willFlowToProvider = !chunkALU3KC4G_cjs.isFixtureApiKey(apiKey) && !chunkALU3KC4G_cjs.shouldUseRealLocalRuntime(apiKey);
10071
+ const willFlowToProvider = !chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) && !chunkG7X2Y7Y2_cjs.shouldUseRealLocalRuntime(apiKey);
9951
10072
  const shape = validateApiKeyShape(apiKey, {
9952
10073
  strict: willFlowToProvider,
9953
10074
  // `options.model` is already normalized by `runCreateUnderSpan`; `normalizeModel`
@@ -9956,10 +10077,10 @@ async function createLocalAgent(options) {
9956
10077
  ...willFlowToProvider ? { provider: providerFromModelId(normalizeModel(options.model)?.id) } : {}
9957
10078
  });
9958
10079
  if (shape.malformed) {
9959
- throw new chunkMHCKWQR3_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
10080
+ throw new chunkA3MHE2MQ_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
9960
10081
  }
9961
- if (!chunkALU3KC4G_cjs.isFixtureApiKey(apiKey) && chunkALU3KC4G_cjs.getConfiguredBaseUrl() === void 0 && !chunkALU3KC4G_cjs.shouldUseRealLocalRuntime(apiKey)) {
9962
- throw new chunkMHCKWQR3_cjs.AuthenticationError("Invalid API key", {
10082
+ if (!chunkG7X2Y7Y2_cjs.isFixtureApiKey(apiKey) && chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl() === void 0 && !chunkG7X2Y7Y2_cjs.shouldUseRealLocalRuntime(apiKey)) {
10083
+ throw new chunkA3MHE2MQ_cjs.AuthenticationError("Invalid API key", {
9963
10084
  code: "authentication_error"
9964
10085
  });
9965
10086
  }
@@ -9970,19 +10091,19 @@ async function createLocalAgent(options) {
9970
10091
  async function createCloudAgent(options) {
9971
10092
  const apiKey = resolveApiKey(options.apiKey);
9972
10093
  if (apiKey === void 0) {
9973
- throw new chunkMHCKWQR3_cjs.ConfigurationError("Missing API key for cloud agent", {
10094
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError("Missing API key for cloud agent", {
9974
10095
  code: "missing_api_key"
9975
10096
  });
9976
10097
  }
9977
10098
  const shape = validateApiKeyShape(apiKey);
9978
10099
  if (shape.malformed) {
9979
- throw new chunkMHCKWQR3_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
10100
+ throw new chunkA3MHE2MQ_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
9980
10101
  }
9981
- const baseUrl = chunkALU3KC4G_cjs.getConfiguredBaseUrl();
10102
+ const baseUrl = chunkG7X2Y7Y2_cjs.getConfiguredBaseUrl();
9982
10103
  if (baseUrl === void 0) {
9983
10104
  return new CloudAgent(options);
9984
10105
  }
9985
- const response = await chunkALU3KC4G_cjs.httpRequest("/v1/agents", {
10106
+ const response = await chunkG7X2Y7Y2_cjs.httpRequest("/v1/agents", {
9986
10107
  apiKey,
9987
10108
  method: "POST",
9988
10109
  body: {
@@ -10007,7 +10128,7 @@ function resolveAgentPersistenceCwd(options) {
10007
10128
  return process.cwd();
10008
10129
  }
10009
10130
  async function rehydrateExistingAgent(agentId, existing, options) {
10010
- await chunkALU3KC4G_cjs.discoverProviderPlugins();
10131
+ await chunkG7X2Y7Y2_cjs.discoverProviderPlugins();
10011
10132
  await validateRehydratedAgent(agentId, existing);
10012
10133
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
10013
10134
  const mergedOptions = {
@@ -10038,7 +10159,7 @@ async function validateRehydratedAgent(agentId, entry) {
10038
10159
  throw new Error(`Workspace path is not a directory: ${candidate}`);
10039
10160
  }
10040
10161
  } catch (cause) {
10041
- throw new chunkMHCKWQR3_cjs.UnknownAgentError(
10162
+ throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
10042
10163
  `Agent "${agentId}" cannot be rehydrated \u2014 workspace cwd "${candidate}" is missing or inaccessible.`,
10043
10164
  { code: "agent_rehydration_failed", cause }
10044
10165
  );
@@ -10090,7 +10211,7 @@ async function getRegisteredAgentOrThrow(agentId) {
10090
10211
  agent = getRegisteredAgent(agentId);
10091
10212
  }
10092
10213
  if (agent === void 0) {
10093
- throw new chunkMHCKWQR3_cjs.UnknownAgentError(`Agent ${agentId} not found`, { code: "unknown_agent" });
10214
+ throw new chunkA3MHE2MQ_cjs.UnknownAgentError(`Agent ${agentId} not found`, { code: "unknown_agent" });
10094
10215
  }
10095
10216
  return agent;
10096
10217
  }
@@ -10135,7 +10256,7 @@ var Agent = class _Agent {
10135
10256
  pluginCount: enabledPluginNames(options.plugins).length
10136
10257
  });
10137
10258
  try {
10138
- await chunkALU3KC4G_cjs.discoverProviderPlugins();
10259
+ await chunkG7X2Y7Y2_cjs.discoverProviderPlugins();
10139
10260
  const agent = await runCreateUnderSpan(options, span);
10140
10261
  return agent;
10141
10262
  } catch (err) {
@@ -10161,8 +10282,8 @@ var Agent = class _Agent {
10161
10282
  const run = await agent.send(message);
10162
10283
  const result = await run.wait();
10163
10284
  if (options.throwOnError === true && result.status === "error" && result.error !== void 0) {
10164
- throw new chunkMHCKWQR3_cjs.AgentRunError(result.error.message, {
10165
- code: chunkMHCKWQR3_cjs.coerceToKnownAgentRunErrorCode(result.error.code),
10285
+ throw new chunkA3MHE2MQ_cjs.AgentRunError(result.error.message, {
10286
+ code: chunkA3MHE2MQ_cjs.coerceToKnownAgentRunErrorCode(result.error.code),
10166
10287
  cause: result.error.cause
10167
10288
  });
10168
10289
  }
@@ -10189,7 +10310,7 @@ var Agent = class _Agent {
10189
10310
  if (existing !== void 0) {
10190
10311
  return await rehydrateExistingAgent(agentId, existing, options);
10191
10312
  }
10192
- throw new chunkMHCKWQR3_cjs.UnknownAgentError(
10313
+ throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
10193
10314
  `Agent "${agentId}" not found. Use Agent.create({ agentId, ... }) for first-time setup, or catch UnknownAgentError to branch resume-vs-create.`,
10194
10315
  { code: "unknown_agent" }
10195
10316
  );
@@ -10218,7 +10339,7 @@ var Agent = class _Agent {
10218
10339
  * @public
10219
10340
  */
10220
10341
  static async generateObject(options) {
10221
- const { generateObjectImpl } = await import('./generate-object-5SCEH2EE.cjs');
10342
+ const { generateObjectImpl } = await import('./generate-object-F56VIZ6U.cjs');
10222
10343
  return generateObjectImpl(options, {
10223
10344
  create: (opts) => _Agent.create(opts),
10224
10345
  delete: (agentId) => _Agent.delete(agentId)
@@ -10242,7 +10363,7 @@ var Agent = class _Agent {
10242
10363
  delete: (agentId) => _Agent.delete(agentId)
10243
10364
  };
10244
10365
  async function* wrapper() {
10245
- streamObjectImport ??= import('./stream-object-Y7YCX3BI.cjs');
10366
+ streamObjectImport ??= import('./stream-object-YPXZ4F5P.cjs');
10246
10367
  const { streamObjectImpl } = await streamObjectImport;
10247
10368
  yield* streamObjectImpl(options, deps);
10248
10369
  }
@@ -10266,7 +10387,7 @@ var Agent = class _Agent {
10266
10387
  * @public
10267
10388
  */
10268
10389
  static async batch(prompts, options) {
10269
- const { batchImpl } = await import('./batch-3SEPDXCU.cjs');
10390
+ const { batchImpl } = await import('./batch-NZGN6SFV.cjs');
10270
10391
  return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
10271
10392
  }
10272
10393
  /**
@@ -10290,7 +10411,7 @@ var Agent = class _Agent {
10290
10411
  *
10291
10412
  * This bullet used to say the opposite ("Disposed agents are NOT auto-deleted...
10292
10413
  * call `Agent.delete(agentId)` first"). It was measured false in M91:
10293
- * `tests/m91-getorcreate-apos-dispose.test.ts` builds an agent, disposes it, and
10414
+ * `tests/m91-getorcreate-after-dispose.test.ts` builds an agent, disposes it, and
10294
10415
  * gets a different instance back. The claim was about the PERSISTENT registry and
10295
10416
  * read as being about the live cache — and consumers built around the wrong half.
10296
10417
  * The agent-builder's M85 interrupt rotates the session id to work around a
@@ -10346,14 +10467,14 @@ var Agent = class _Agent {
10346
10467
  */
10347
10468
  static async getRun(runId, options = {}) {
10348
10469
  if (options.runtime === "cloud") {
10349
- throw new chunkMHCKWQR3_cjs.ConfigurationError(
10470
+ throw new chunkA3MHE2MQ_cjs.ConfigurationError(
10350
10471
  "Cloud runtime is pre-release. Theo PaaS endpoints are not wired yet \u2014 getRun({ runtime: 'cloud' }) will be enabled when the PaaS ships.",
10351
10472
  { code: "cloud_runtime_pre_release" }
10352
10473
  );
10353
10474
  }
10354
10475
  const existing = getRun(runId);
10355
10476
  if (existing !== void 0) return existing;
10356
- throw new chunkMHCKWQR3_cjs.UnknownAgentError(
10477
+ throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
10357
10478
  `Run ${runId} is not in this process's registry. It may have been disposed, persisted in a previous process, or never created.`,
10358
10479
  { code: "run_not_found" }
10359
10480
  );
@@ -10400,13 +10521,13 @@ var Agent = class _Agent {
10400
10521
  reg = getRegisteredAgent(agentId);
10401
10522
  }
10402
10523
  if (reg === void 0 || reg.runtime !== "local") {
10403
- throw new chunkMHCKWQR3_cjs.UnknownAgentError(
10524
+ throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
10404
10525
  `No local agent "${agentId}" registered \u2014 compact targets local sessions.`
10405
10526
  );
10406
10527
  }
10407
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-H5TKLD55.cjs');
10408
- const { cwd, model, store } = await abrirStoreLocal(reg);
10409
- return chunkH5YVJB4K_cjs.enqueueSessionWrite(
10528
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-YOWJJPPB.cjs');
10529
+ const { cwd, model, store } = await openLocalStore(reg);
10530
+ return chunk6ZGD7R27_cjs.enqueueSessionWrite(
10410
10531
  cwd,
10411
10532
  agentId,
10412
10533
  () => compactSessionTranscript({
@@ -10436,12 +10557,12 @@ var Agent = class _Agent {
10436
10557
  reg = getRegisteredAgent(agentId);
10437
10558
  }
10438
10559
  if (reg === void 0 || reg.runtime !== "local") {
10439
- throw new chunkMHCKWQR3_cjs.UnknownAgentError(
10560
+ throw new chunkA3MHE2MQ_cjs.UnknownAgentError(
10440
10561
  `No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
10441
10562
  );
10442
10563
  }
10443
- const { injectSessionTurn } = await import('./inject-session-DM4SKTZO.cjs');
10444
- const { cwd, model, store } = await abrirStoreLocal(reg);
10564
+ const { injectSessionTurn } = await import('./inject-session-25EC74WV.cjs');
10565
+ const { cwd, model, store } = await openLocalStore(reg);
10445
10566
  await injectSessionTurn({
10446
10567
  store,
10447
10568
  loc: { cwd, agentId, model },
@@ -10464,12 +10585,12 @@ async function getOrCreateUncached(agentId, options) {
10464
10585
  try {
10465
10586
  return await Agent.resume(agentId, options);
10466
10587
  } catch (err) {
10467
- if (!(err instanceof chunkMHCKWQR3_cjs.UnknownAgentError)) throw err;
10588
+ if (!(err instanceof chunkA3MHE2MQ_cjs.UnknownAgentError)) throw err;
10468
10589
  }
10469
10590
  try {
10470
10591
  return await Agent.create({ ...options, agentId });
10471
10592
  } catch (err) {
10472
- if (err instanceof chunkMHCKWQR3_cjs.ConfigurationError && err.code === "agent_id_already_exists") {
10593
+ if (err instanceof chunkA3MHE2MQ_cjs.ConfigurationError && err.code === "agent_id_already_exists") {
10473
10594
  return await Agent.resume(agentId, options);
10474
10595
  }
10475
10596
  throw err;
@@ -10483,12 +10604,12 @@ chunkNINIJCHU_cjs.setAgentFacade({
10483
10604
  resume: (agentId, options) => Agent.resume(agentId, options),
10484
10605
  batch: (prompts, options) => Agent.batch(prompts, options)
10485
10606
  });
10486
- async function abrirStoreLocal(reg) {
10607
+ async function openLocalStore(reg) {
10487
10608
  const cwd = reg.cwd ?? process.cwd();
10488
10609
  const optModel = reg.options.model;
10489
10610
  const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
10490
- const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-7E7UPLF2.cjs');
10491
- const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-EAKR4D2W.cjs');
10611
+ const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-T5ZLQX42.cjs');
10612
+ const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-DFGX6WNL.cjs');
10492
10613
  const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
10493
10614
  return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
10494
10615
  }
@@ -10505,5 +10626,5 @@ exports.generateCronId = generateCronId;
10505
10626
  exports.getPricingEntry = getPricingEntry;
10506
10627
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
10507
10628
  exports.resolveApiKey = resolveApiKey;
10508
- //# sourceMappingURL=chunk-W52DKZBR.cjs.map
10509
- //# sourceMappingURL=chunk-W52DKZBR.cjs.map
10629
+ //# sourceMappingURL=chunk-UZBA6YYP.cjs.map
10630
+ //# sourceMappingURL=chunk-UZBA6YYP.cjs.map