@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,32 +1,32 @@
1
1
  import { extractCodePlugins } from './chunk-2SFBB54R.js';
2
- import { submit, emitRunEvent } from './chunk-HEN5WXXI.js';
3
- import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, descartarSessao, clearSession } from './chunk-5SB4V74H.js';
4
- import { FsSessionStore } from './chunk-YVTNFKZO.js';
5
- import { discoverProviderPlugins, getConfiguredBaseUrl, httpRequest, isFixtureApiKey, shouldUseRealLocalRuntime, CircuitBreaker, buildDefaultSummarizer, parseSseStream, resolveProviderChain, inferProviderFromApiKey, detectPrimaryProvider, tryFirstEvent, relayStream, mapOpenAICompatibleError, renderToolResultContentText } from './chunk-GL7CFBVC.js';
6
- import { IndexManager, writeSessionSummary, memoryDir, globalEmbeddingCache, appendFact, readFacts, legacyMemoryJsonPath, memoryMdPath, appendFactToMarkdown } from './chunk-DCJ5MCJ3.js';
7
- import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-F6Y4IEQM.js';
2
+ import { submit, emitRunEvent } from './chunk-7QDTZJRV.js';
3
+ import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, discardSession, clearSession } from './chunk-A4XXV2C6.js';
4
+ import { FsSessionStore } from './chunk-4NVV3GRU.js';
5
+ import { discoverProviderPlugins, getConfiguredBaseUrl, httpRequest, isFixtureApiKey, shouldUseRealLocalRuntime, CircuitBreaker, buildDefaultSummarizer, parseSseStream, resolveProviderChain, inferProviderFromApiKey, detectPrimaryProvider, tryFirstEvent, relayStream, mapOpenAICompatibleError, renderToolResultContentText } from './chunk-HI6G3SNY.js';
6
+ import { IndexManager, writeSessionSummary, memoryDir, globalEmbeddingCache, appendFact, readFacts, legacyMemoryJsonPath, memoryMdPath, appendFactToMarkdown } from './chunk-4APWS2YF.js';
7
+ import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-M6UUTNDT.js';
8
8
  import { resolveChildEnv } from './chunk-7GFX45DD.js';
9
- import { readVersionedJson, getTheokitHome, writeVersionedJson } from './chunk-ZW345YOI.js';
9
+ import { readVersionedJson, getTheokitHome, writeVersionedJson } from './chunk-UD2T7ISG.js';
10
10
  import { sanitizeToolInput } from './chunk-U54XCYG3.js';
11
11
  import { subAgentToolsFromDefinitions, inheritSubAgentCredentials } from './chunk-FV3YEMQ7.js';
12
12
  import { setAgentFacade } from './chunk-6X6ID4MO.js';
13
13
  import { findGitRoot, DEFAULT_DISCOVERY_SPECS, walkUpForFile, walkUpForGlob } from './chunk-UJ7IQJAG.js';
14
14
  import { withToolWhitelist, checkToolWhitelist } from './chunk-7AD3ZTZL.js';
15
- import { mapWithConcurrency } from './chunk-QGDKZDPN.js';
16
- import { withFileLock } from './chunk-YHZXBDAW.js';
15
+ import { mapWithConcurrency } from './chunk-4WIJSKFA.js';
16
+ import { withFileLock } from './chunk-XJ5TMOGA.js';
17
17
  import { withCwdMutex } from './chunk-2XLKLVVR.js';
18
- import { defaultBaseDir, expandTilde } from './chunk-XAEAMI5H.js';
18
+ import { defaultBaseDir, expandTilde } from './chunk-AOZYORH7.js';
19
19
  import { toJsonSchema } from './chunk-4VPXM6UU.js';
20
- import { atomicWriteJson } from './chunk-56OXYUZE.js';
21
- import { loadSubagents } from './chunk-YCXMSDSP.js';
22
- import { resolveEffectiveContextWindow, CONTEXT_WINDOW_FLOOR, CONTEXT_WINDOW_MARGIN } from './chunk-6VP3XGEK.js';
20
+ import { atomicWriteJson } from './chunk-LGCEYEU2.js';
21
+ import { loadSubagents } from './chunk-HHUDNTZC.js';
22
+ import { resolveEffectiveContextWindow, CONTEXT_WINDOW_FLOOR, CONTEXT_WINDOW_MARGIN } from './chunk-A6GXYF2Q.js';
23
23
  import { parseModelId } from './chunk-X2FR4OIT.js';
24
- import { getCatalogModelInfo, registerBuiltins, getProviderProfile, registerProvider, isPatchedModelKey } from './chunk-77WHPVXE.js';
25
- import { escapeBlockBody, buildSkillsBlock, discoverSkills, stripSkillFrontmatter } from './chunk-2WFB5ZOX.js';
26
- import { validateArtifactPath, PathTraversalError, safePathJoin } from './chunk-WDGCZDRG.js';
27
- import { readWorkspaceDir, parseSimpleYaml } from './chunk-UQPDFW4E.js';
28
- import { AgentRunError, coerceToKnownAgentRunErrorCode, UnknownAgentError, ConfigurationError, AuthenticationError, UnsupportedRunOperationError, AgentDisposedError, NetworkError, TheokitAgentError } from './chunk-CD73YHEH.js';
29
- import { diag, redactSecrets } from './chunk-TAPQWDW2.js';
24
+ import { getCatalogModelInfo, registerBuiltins, getProviderProfile, registerProvider, isPatchedModelKey } from './chunk-3XKVRLR2.js';
25
+ import { escapeBlockBody, buildSkillsBlock, discoverSkills, stripSkillFrontmatter } from './chunk-KWXC6ERT.js';
26
+ import { validateArtifactPath, PathTraversalError, safePathJoin } from './chunk-JCXIDFRI.js';
27
+ import { readWorkspaceDir, parseSimpleYaml } from './chunk-QFWQLXCL.js';
28
+ import { AgentRunError, coerceToKnownAgentRunErrorCode, UnknownAgentError, ConfigurationError, AuthenticationError, UnsupportedRunOperationError, AgentDisposedError, NetworkError, TheokitAgentError } from './chunk-ZYOHF37V.js';
29
+ import { diag, redactSecrets } from './chunk-KCZW75PI.js';
30
30
  import { stat, mkdir, readFile, readdir, access, unlink } from 'fs/promises';
31
31
  import { randomUUID, createHash } from 'crypto';
32
32
  import { join, dirname, resolve, relative, isAbsolute } from 'path';
@@ -221,7 +221,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
221
221
  const { output, maxRetries, errorStrategy, ...sendOptions } = options;
222
222
  const run = await agent.send(input, sendOptions);
223
223
  const result = await run.wait();
224
- const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-I7UD4NWN.js');
224
+ const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-LPSO6GVW.js');
225
225
  const answer = structurableAnswerOrThrow(result, GenerateObjectError);
226
226
  const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
227
227
  const facade = getAgentFacade();
@@ -1320,6 +1320,16 @@ var FixtureRunBase = class {
1320
1320
  resolveTermination;
1321
1321
  terminated = false;
1322
1322
  eventNotifier;
1323
+ /**
1324
+ * theokit#140 - the run's single ordered timeline: structural events and live token/tool deltas,
1325
+ * in the order they actually occurred.
1326
+ *
1327
+ * Kept alongside `script.events` rather than replacing it. `stream()` is the SDKMessage view and
1328
+ * stays byte-identical for every existing consumer; this is the complete view, and a consumer
1329
+ * picks one. Merging them would have changed `stream()`'s element type - a breaking change for
1330
+ * an additive feature.
1331
+ */
1332
+ timeline = [];
1323
1333
  constructor(options) {
1324
1334
  this.id = options.id;
1325
1335
  this.agentId = options.agentId;
@@ -1343,6 +1353,46 @@ var FixtureRunBase = class {
1343
1353
  this.eventNotifier = makeNotifier();
1344
1354
  current.resolve();
1345
1355
  }
1356
+ /**
1357
+ * theokit#140 - every event of this run, in true order, from ONE source.
1358
+ *
1359
+ * ## The defect this replaces
1360
+ *
1361
+ * A consumer that needed tool calls interleaved with tokens had to fuse two surfaces by hand:
1362
+ * `stream()`, which was batched and post-completion, and `SendOptions.onDelta`, which was live.
1363
+ * Neither was complete alone - `onDelta` has no `run_started`/`system`, and `stream()` had no
1364
+ * token granularity - so the entire reconciliation, including its dedup, lived in the consumer.
1365
+ * `@theokit/agents` carried ~200 lines of exactly that, and it is the documented root of its
1366
+ * ordering bug (theokit#47), its namespace-dedup bug (#138) and its missing terminal frame (#142).
1367
+ *
1368
+ * The ordering is not reconstructed here. Both kinds are appended by the loop AS THEY HAPPEN, so
1369
+ * arrival order IS model order - there is nothing to sort, and no timestamp heuristic to get
1370
+ * wrong.
1371
+ *
1372
+ * `callId` is whatever the SDK's own `tool_call` events carry, so a consumer no longer holds two
1373
+ * id namespaces and no longer has to correlate them.
1374
+ */
1375
+ async *events() {
1376
+ let index = 0;
1377
+ while (!this.terminated) {
1378
+ while (index < this.timeline.length) {
1379
+ yield this.timeline[index++];
1380
+ }
1381
+ if (this.terminated) break;
1382
+ await Promise.race([this.eventNotifier.promise, this.terminationPromise]);
1383
+ }
1384
+ while (index < this.timeline.length) {
1385
+ yield this.timeline[index++];
1386
+ }
1387
+ for await (const message of this.terminalErrorEvent()) {
1388
+ yield { kind: "message", message };
1389
+ }
1390
+ }
1391
+ /** theokit#140 - append to the timeline and wake `events()`. */
1392
+ pushTimeline(event) {
1393
+ this.timeline.push(event);
1394
+ this.notifyNewEvents();
1395
+ }
1346
1396
  async *stream() {
1347
1397
  let index = 0;
1348
1398
  while (!this.terminated) {
@@ -1358,22 +1408,22 @@ var FixtureRunBase = class {
1358
1408
  yield* this.terminalErrorEvent();
1359
1409
  }
1360
1410
  /**
1361
- * theokit#101 — quando o run termina em erro, `stream()` tem de DIZER.
1411
+ * theokit#101 — when the run ends in error, `stream()` has to SAY SO.
1362
1412
  *
1363
- * O erro sempre existiu: o loop o registra em `ctx.error` e `wait()` devolve
1364
- * `status: 'error'` com a mensagem. o `stream()` não o mencionavaele drena
1365
- * `script.events` e para. Uma falha de provider (404 "No endpoints found", auth, timeout)
1366
- * produzia um turno que parecia bem-sucedido e vazio, em TODA superfície que consome o
1413
+ * The error always existed: the loop records it in `ctx.error` and `wait()` returns
1414
+ * `status: 'error'` with the message. Only `stream()` failed to mention it it drains
1415
+ * `script.events` and stops. A provider failure (404 "No endpoints found", auth, timeout)
1416
+ * produced a turn that looked successful and empty, on EVERY surface consuming the
1367
1417
  * stream: HTTP web, MCP, stdio, TUI in-process.
1368
1418
  *
1369
- * Erro silencioso é o pior tipo (Regra Inquebrável 8). E a assimetria era o que o tornava
1370
- * difícil de diagnosticar: quem depurasse por `wait()` via o erro e não reproduziria o
1371
- * relato de quem depurava pelo stream.
1419
+ * A silent error is the worst kind (Unbreakable Rule 8). And the asymmetry was what made it
1420
+ * hard to diagnose: anyone debugging via `wait()` saw the error and would not reproduce the
1421
+ * report of anyone debugging via the stream.
1372
1422
  *
1373
- * Emite `SDKStatusMessage` com `status: "ERROR"` — o tipo EXISTE na união `SDKMessage`
1374
- * e é esperado por quem consome. Um tipo novo seria breaking para todo consumidor que
1375
- * faz switch exaustivo; este é aditivo, e um consumidor que ignore `status` simplesmente
1376
- * segue como antesnunca pior que hoje.
1423
+ * It emits `SDKStatusMessage` with `status: "ERROR"` — the type ALREADY EXISTS in the `SDKMessage` union
1424
+ * and is already expected by consumers. A new type would be breaking for every consumer doing
1425
+ * an exhaustive switch; this one is additive, and a consumer ignoring `status` simply
1426
+ * behaves as beforenever worse than today.
1377
1427
  */
1378
1428
  *terminalErrorEvent() {
1379
1429
  if (this.status !== "error") return;
@@ -1383,7 +1433,7 @@ var FixtureRunBase = class {
1383
1433
  agent_id: this.agentId,
1384
1434
  run_id: this.id,
1385
1435
  status: "ERROR",
1386
- // Sem mensagem, o consumidor sabe QUE falhou e não O QUÊque é metade do defeito.
1436
+ // Without a message, the consumer knows THAT it failed and not WHATwhich is half the defect.
1387
1437
  ...detail?.message !== void 0 ? { message: detail.message } : {}
1388
1438
  };
1389
1439
  }
@@ -2643,7 +2693,7 @@ async function runPostRunLifecycle(inputs) {
2643
2693
  }
2644
2694
  const conversation = await safeConversation(run);
2645
2695
  const resolvedWindow = resolveWindowForRun(model, contextWindow);
2646
- const janelaEfetiva = resolvedWindow.window;
2696
+ const effectiveWindow = resolvedWindow.window;
2647
2697
  const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
2648
2698
  if (budgetEvent !== void 0 && onRunEvent !== void 0) {
2649
2699
  emitRunEvent(onRunEvent, budgetEvent);
@@ -2659,9 +2709,9 @@ async function runPostRunLifecycle(inputs) {
2659
2709
  conversation,
2660
2710
  autoCompact: {
2661
2711
  usageTotal: usageForTrigger,
2662
- // A janela EFETIVA (após override, clamp e margem) — não a declarada. Trocar por
2663
- // `contextWindow` aqui orçaria contra um número que o clamp rejeitou.
2664
- contextWindow: janelaEfetiva,
2712
+ // The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
2713
+ // `contextWindow` here would budget against a number the clamp already rejected.
2714
+ contextWindow: effectiveWindow,
2665
2715
  summarize: buildDefaultSummarizer({
2666
2716
  agentModel: model,
2667
2717
  ...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
@@ -4985,6 +5035,35 @@ function buildAssistantTurn(text, toolCalls) {
4985
5035
  return { role: "assistant", content };
4986
5036
  }
4987
5037
 
5038
+ // src/internal/agent-loop/live-events.ts
5039
+ var LiveEventLog = class extends Array {
5040
+ /**
5041
+ * Not readonly, and not a constructor parameter — `Array` subclasses are re-instantiated by
5042
+ * `map`/`filter`/`slice` with a length argument, so a constructor with a different signature
5043
+ * breaks those. The sink is attached after construction instead.
5044
+ */
5045
+ #sink;
5046
+ /** Attach the live subscriber. One sink: the run that owns this loop. */
5047
+ subscribe(sink) {
5048
+ this.#sink = sink;
5049
+ }
5050
+ push(...events) {
5051
+ const length = super.push(...events);
5052
+ for (const event of events) {
5053
+ try {
5054
+ this.#sink?.(event);
5055
+ } catch {
5056
+ }
5057
+ }
5058
+ return length;
5059
+ }
5060
+ };
5061
+ function createEventLog(seed) {
5062
+ const log = new LiveEventLog();
5063
+ log.push(...seed);
5064
+ return log;
5065
+ }
5066
+
4988
5067
  // src/internal/agent-loop/loop-context-init.ts
4989
5068
  function buildUserContent(text, images) {
4990
5069
  const content = [{ type: "text", text }];
@@ -5048,13 +5127,14 @@ async function initLoopContext(inputs) {
5048
5127
  });
5049
5128
  }
5050
5129
  }
5051
- const events = [
5130
+ const events = createEventLog([
5052
5131
  buildSystemEvent(
5053
5132
  inputs,
5054
5133
  tools.map((t) => t.name)
5055
5134
  ),
5056
5135
  buildUserEvent(inputs)
5057
- ];
5136
+ ]);
5137
+ if (inputs.onLoopEvent !== void 0) events.subscribe(inputs.onLoopEvent);
5058
5138
  const priorMessages = (inputs.priorMessages ?? []).map((msg) => ({
5059
5139
  role: msg.role,
5060
5140
  content: [{ type: "text", text: msg.text }]
@@ -6915,12 +6995,12 @@ var HttpMcpClient = class extends BaseMcpClient {
6915
6995
  async readBody(response) {
6916
6996
  const tipo = response.headers.get("content-type") ?? "";
6917
6997
  if (!tipo.includes("text/event-stream")) return await response.json();
6918
- const texto = await response.text();
6919
- for (const linha of texto.split(/\r?\n/)) {
6920
- if (!linha.startsWith("data:")) continue;
6921
- const carga = linha.slice(5).trim();
6922
- if (carga === "") continue;
6923
- return JSON.parse(carga);
6998
+ const text = await response.text();
6999
+ for (const line of text.split(/\r?\n/)) {
7000
+ if (!line.startsWith("data:")) continue;
7001
+ const payload = line.slice(5).trim();
7002
+ if (payload === "") continue;
7003
+ return JSON.parse(payload);
6924
7004
  }
6925
7005
  throw new NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
6926
7006
  code: "mcp_http_error"
@@ -7351,7 +7431,26 @@ var RealLocalRun = class extends FixtureRunBase {
7351
7431
  }
7352
7432
  }
7353
7433
  }
7434
+ /**
7435
+ * theokit#140 - events already handed to stream() by the live subscriber.
7436
+ *
7437
+ * The loop still RETURNS its full event list, and that batch path is deliberately kept: it is the
7438
+ * fallback if a live event is ever lost, and removing it would make the live channel a single
7439
+ * point of failure for the whole transcript.
7440
+ */
7441
+ liveDelivered = /* @__PURE__ */ new Set();
7354
7442
  async executeAgentLoop(inputs) {
7443
+ inputs.onLoopEvent = (event) => {
7444
+ this.liveDelivered.add(event);
7445
+ this.script.events.push(event);
7446
+ this.pushTimeline({ kind: "message", message: event });
7447
+ this.notifyNewEvents();
7448
+ };
7449
+ const callerOnDelta = inputs.onDelta;
7450
+ inputs.onDelta = (delta) => {
7451
+ callerOnDelta?.(delta);
7452
+ this.pushTimeline({ kind: "delta", update: delta.update });
7453
+ };
7355
7454
  try {
7356
7455
  const output = inputs.activeTools !== void 0 ? await withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : await runAgentLoop(inputs);
7357
7456
  this.applyAgentLoopOutput(output);
@@ -7374,10 +7473,7 @@ var RealLocalRun = class extends FixtureRunBase {
7374
7473
  * Finding-B fix (sdk-error-packaging v1.1): set-once errorDetail copy.
7375
7474
  */
7376
7475
  applyAgentLoopOutput(output) {
7377
- for (const event of output.events) {
7378
- this.script.events.push(event);
7379
- this.notifyNewEvents();
7380
- }
7476
+ this.deliverUndeliveredEvents(output.events);
7381
7477
  this.script.conversation.push(...output.conversation);
7382
7478
  if (output.result.length > 0) this.script.result = output.result;
7383
7479
  if (output.usage !== void 0) this.script.usage = output.usage;
@@ -7392,6 +7488,25 @@ var RealLocalRun = class extends FixtureRunBase {
7392
7488
  };
7393
7489
  }
7394
7490
  }
7491
+ /**
7492
+ * theokit#140 - deliver only what the live subscriber has NOT already handed to `stream()`.
7493
+ *
7494
+ * The loop now reports each event as it happens, so this batch is the SAME list, replayed.
7495
+ * Without the guard every event would reach `stream()` twice: once live, once here.
7496
+ *
7497
+ * Identity, not deep equality: these are the very objects the live sink saw, and two genuinely
7498
+ * distinct events can be structurally identical (the same tool called twice with the same args
7499
+ * is not a duplicate).
7500
+ *
7501
+ * Extracted because the guard pushed `applyAgentLoopOutput` past the cognitive-complexity cap.
7502
+ */
7503
+ deliverUndeliveredEvents(events) {
7504
+ for (const event of events) {
7505
+ if (this.liveDelivered.has(event)) continue;
7506
+ this.script.events.push(event);
7507
+ this.notifyNewEvents();
7508
+ }
7509
+ }
7395
7510
  emitErrorEvent(cause, fallback, prefix = "", code) {
7396
7511
  if (this.script.errorDetail === void 0) {
7397
7512
  const message = cause instanceof Error ? cause.message : String(cause);
@@ -7677,7 +7792,7 @@ var LiveAgentRegistry = class {
7677
7792
  var liveAgentRegistry = new LiveAgentRegistry();
7678
7793
 
7679
7794
  // src/internal/local-agent/local-agent-lifecycle.ts
7680
- async function adquirirLeaseSePossivel(store, agentId) {
7795
+ async function acquireLeaseIfPossible(store, agentId) {
7681
7796
  const a = store.acquire;
7682
7797
  if (typeof a !== "function") return;
7683
7798
  try {
@@ -7690,7 +7805,7 @@ async function adquirirLeaseSePossivel(store, agentId) {
7690
7805
  );
7691
7806
  }
7692
7807
  }
7693
- async function soltarLeaseSePossivel(store, agentId) {
7808
+ async function releaseLeaseIfPossible(store, agentId) {
7694
7809
  const r = store.release;
7695
7810
  if (typeof r === "function") await r.call(store, agentId);
7696
7811
  }
@@ -7706,7 +7821,7 @@ async function disposeLocalAgentSession(agent) {
7706
7821
  await flushSessionWrites();
7707
7822
  await flushRegistrySaves(agent.workspaceCwd);
7708
7823
  await disposeSessionStore(agent.sessionStore);
7709
- descartarSessao(agent.workspaceCwd, agent.agentId);
7824
+ discardSession(agent.workspaceCwd, agent.agentId);
7710
7825
  }
7711
7826
  async function reloadLocalAgent(agent) {
7712
7827
  if (agent.context !== void 0) await agent.context.refresh();
@@ -9047,9 +9162,9 @@ async function localAgentUsePersonality(args) {
9047
9162
  // src/internal/local-agent/local-agent-runtime-extensions.ts
9048
9163
  function localAgentRunUntil(agent, goal, options) {
9049
9164
  async function* wrap() {
9050
- const { runUntilImpl } = await import('./run-until-YZ2ODWOF.js');
9165
+ const { runUntilImpl } = await import('./run-until-BK56WG4P.js');
9051
9166
  const buildDeps = async () => {
9052
- const { judgeCallImpl } = await import('./judge-call-TAEIXMYG.js');
9167
+ const { judgeCallImpl } = await import('./judge-call-3S3T6O2Z.js');
9053
9168
  const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
9054
9169
  const create = getAgentFacade().create;
9055
9170
  return {
@@ -9082,7 +9197,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
9082
9197
  async function localAgentFork(parent, options) {
9083
9198
  const { forkAgentImpl } = await import('./fork-agent-RSV4E3EA.js');
9084
9199
  const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
9085
- const { withPersonalityContext } = await import('./context-VAYLPT4O.js');
9200
+ const { withPersonalityContext } = await import('./context-ZDBBPIHY.js');
9086
9201
  const create = getAgentFacade().create;
9087
9202
  return withPersonalityContext(
9088
9203
  { slug: parent.personalitySlugSnapshot, isFork: true },
@@ -9238,6 +9353,9 @@ var SUPPORTED = /* @__PURE__ */ new Set([
9238
9353
  "cancel",
9239
9354
  "conversation"
9240
9355
  ]);
9356
+ function emptyTimeline() {
9357
+ return emptyStream();
9358
+ }
9241
9359
  function emptyStream() {
9242
9360
  return {
9243
9361
  next: () => Promise.resolve({ done: true, value: void 0 }),
@@ -9262,6 +9380,9 @@ function createTripwireRun(args) {
9262
9380
  status: "cancelled",
9263
9381
  ...args.model !== void 0 ? { model: args.model } : {},
9264
9382
  stream: () => emptyStream(),
9383
+ // theokit#140 - a tripwire run never executed, so its timeline is empty by construction, the
9384
+ // same reason `stream()` is. Both are empty for the same fact, not by coincidence.
9385
+ events: () => emptyTimeline(),
9265
9386
  wait: () => Promise.resolve(result),
9266
9387
  cancel: () => Promise.resolve(),
9267
9388
  conversation: () => Promise.resolve([]),
@@ -9457,7 +9578,7 @@ async function executeSendLocked(inputs, message, options) {
9457
9578
  function buildCompletionCheckDeps() {
9458
9579
  return {
9459
9580
  judge: async (ctx, opts) => {
9460
- const { judgeCallImpl } = await import('./judge-call-TAEIXMYG.js');
9581
+ const { judgeCallImpl } = await import('./judge-call-3S3T6O2Z.js');
9461
9582
  const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
9462
9583
  return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
9463
9584
  }
@@ -9609,12 +9730,12 @@ var LocalAgent = class {
9609
9730
  this.settingSourcesIncludeProject,
9610
9731
  this.options.agents
9611
9732
  );
9612
- await adquirirLeaseSePossivel(this.sessionStore, this.agentId);
9733
+ await acquireLeaseIfPossible(this.sessionStore, this.agentId);
9613
9734
  try {
9614
9735
  await hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9615
9736
  await this.personalityStore.hydrate(this.agentId);
9616
9737
  } catch (err) {
9617
- await soltarLeaseSePossivel(this.sessionStore, this.agentId);
9738
+ await releaseLeaseIfPossible(this.sessionStore, this.agentId);
9618
9739
  throw err;
9619
9740
  }
9620
9741
  }
@@ -9647,16 +9768,16 @@ var LocalAgent = class {
9647
9768
  });
9648
9769
  }
9649
9770
  /**
9650
- * A janela de contexto declarada na seleção de modelo, no formato de spread condicional.
9771
+ * The context window declared on the model selection, in conditional-spread form.
9651
9772
  *
9652
- * M94 — sem isto, o `override` de `resolveEffectiveContextWindow` existia desde o M77 e nenhum
9653
- * call site de produção o passava: um modelo de 400k sem entrada de catálogo era orçado contra o
9654
- * piso de 128k. Método próprio porque o spread inline empurrava `runLockedSendCycle` para além do
9655
- * teto de complexidade cognitiva do projeto.
9773
+ * M94 — without this, `resolveEffectiveContextWindow`'s `override` had existed since M77 and no
9774
+ * production call site passed it: a 400k model with no catalog entry was budgeted against the
9775
+ * 128k floor. Its own method because the inline spread pushed `runLockedSendCycle` past the
9776
+ * project's cognitive-complexity ceiling.
9656
9777
  */
9657
- #janelaDeclarada() {
9658
- const declarada = this.model?.contextWindow;
9659
- return declarada !== void 0 ? { contextWindow: declarada } : {};
9778
+ #declaredWindow() {
9779
+ const declared = this.model?.contextWindow;
9780
+ return declared !== void 0 ? { contextWindow: declared } : {};
9660
9781
  }
9661
9782
  async runLockedSendCycle(message, options, sendSpan, resolve, reject) {
9662
9783
  const userText = typeof message === "string" ? message : message.text;
@@ -9685,7 +9806,7 @@ var LocalAgent = class {
9685
9806
  workspaceCwd: this.workspaceCwd,
9686
9807
  sessionStore: this.sessionStore,
9687
9808
  model: this.model?.id ?? "unknown",
9688
- ...this.#janelaDeclarada(),
9809
+ ...this.#declaredWindow(),
9689
9810
  // M50 — the auto-compaction summarizer resolves credentials like the run itself.
9690
9811
  ...this.options.apiKey !== void 0 ? { apiKey: this.options.apiKey } : {},
9691
9812
  ...options.onRunEvent !== void 0 ? { onRunEvent: options.onRunEvent } : {},
@@ -10215,7 +10336,7 @@ var Agent = class _Agent {
10215
10336
  * @public
10216
10337
  */
10217
10338
  static async generateObject(options) {
10218
- const { generateObjectImpl } = await import('./generate-object-I7UD4NWN.js');
10339
+ const { generateObjectImpl } = await import('./generate-object-LPSO6GVW.js');
10219
10340
  return generateObjectImpl(options, {
10220
10341
  create: (opts) => _Agent.create(opts),
10221
10342
  delete: (agentId) => _Agent.delete(agentId)
@@ -10239,7 +10360,7 @@ var Agent = class _Agent {
10239
10360
  delete: (agentId) => _Agent.delete(agentId)
10240
10361
  };
10241
10362
  async function* wrapper() {
10242
- streamObjectImport ??= import('./stream-object-OFM66VUT.js');
10363
+ streamObjectImport ??= import('./stream-object-AFERZU63.js');
10243
10364
  const { streamObjectImpl } = await streamObjectImport;
10244
10365
  yield* streamObjectImpl(options, deps);
10245
10366
  }
@@ -10263,7 +10384,7 @@ var Agent = class _Agent {
10263
10384
  * @public
10264
10385
  */
10265
10386
  static async batch(prompts, options) {
10266
- const { batchImpl } = await import('./batch-SY5GZLFD.js');
10387
+ const { batchImpl } = await import('./batch-LXSALQC3.js');
10267
10388
  return batchImpl(prompts, options, { create: (opts) => _Agent.create(opts) });
10268
10389
  }
10269
10390
  /**
@@ -10287,7 +10408,7 @@ var Agent = class _Agent {
10287
10408
  *
10288
10409
  * This bullet used to say the opposite ("Disposed agents are NOT auto-deleted...
10289
10410
  * call `Agent.delete(agentId)` first"). It was measured false in M91:
10290
- * `tests/m91-getorcreate-apos-dispose.test.ts` builds an agent, disposes it, and
10411
+ * `tests/m91-getorcreate-after-dispose.test.ts` builds an agent, disposes it, and
10291
10412
  * gets a different instance back. The claim was about the PERSISTENT registry and
10292
10413
  * read as being about the live cache — and consumers built around the wrong half.
10293
10414
  * The agent-builder's M85 interrupt rotates the session id to work around a
@@ -10401,8 +10522,8 @@ var Agent = class _Agent {
10401
10522
  `No local agent "${agentId}" registered \u2014 compact targets local sessions.`
10402
10523
  );
10403
10524
  }
10404
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-WNKKIIDW.js');
10405
- const { cwd, model, store } = await abrirStoreLocal(reg);
10525
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-RR3ILTES.js');
10526
+ const { cwd, model, store } = await openLocalStore(reg);
10406
10527
  return enqueueSessionWrite(
10407
10528
  cwd,
10408
10529
  agentId,
@@ -10437,8 +10558,8 @@ var Agent = class _Agent {
10437
10558
  `No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
10438
10559
  );
10439
10560
  }
10440
- const { injectSessionTurn } = await import('./inject-session-UXNJQTZ6.js');
10441
- const { cwd, model, store } = await abrirStoreLocal(reg);
10561
+ const { injectSessionTurn } = await import('./inject-session-RKNLUE72.js');
10562
+ const { cwd, model, store } = await openLocalStore(reg);
10442
10563
  await injectSessionTurn({
10443
10564
  store,
10444
10565
  loc: { cwd, agentId, model },
@@ -10480,16 +10601,16 @@ setAgentFacade({
10480
10601
  resume: (agentId, options) => Agent.resume(agentId, options),
10481
10602
  batch: (prompts, options) => Agent.batch(prompts, options)
10482
10603
  });
10483
- async function abrirStoreLocal(reg) {
10604
+ async function openLocalStore(reg) {
10484
10605
  const cwd = reg.cwd ?? process.cwd();
10485
10606
  const optModel = reg.options.model;
10486
10607
  const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
10487
- const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-6MY7PNI2.js');
10488
- const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-6WKLYIN4.js');
10608
+ const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-K5QUPNJZ.js');
10609
+ const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-MMPWCESR.js');
10489
10610
  const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
10490
10611
  return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
10491
10612
  }
10492
10613
 
10493
10614
  export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, openRouterMemoryEmbeddingProviderAdapter, resolveApiKey };
10494
- //# sourceMappingURL=chunk-VYJSHGAY.js.map
10495
- //# sourceMappingURL=chunk-VYJSHGAY.js.map
10615
+ //# sourceMappingURL=chunk-VUDH4D2M.js.map
10616
+ //# sourceMappingURL=chunk-VUDH4D2M.js.map