@theokit/sdk 4.37.2 → 4.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/CHANGELOG.md +309 -72
  2. package/dist/a2a/index.cjs +3 -3
  3. package/dist/a2a/index.js +1 -1
  4. package/dist/a2a/subagent.d.cts +1 -0
  5. package/dist/a2a/subagent.d.ts +1 -0
  6. package/dist/{agent-SmxntivO.d.ts → agent-D7bRK9Kg.d.cts} +108 -41
  7. package/dist/agent-I3EZZR6S.cjs +55 -0
  8. package/dist/{agent-IE6IE4NW.cjs.map → agent-I3EZZR6S.cjs.map} +1 -1
  9. package/dist/agent-KKZYLY5D.js +46 -0
  10. package/dist/{agent-DW2J37IH.js.map → agent-KKZYLY5D.js.map} +1 -1
  11. package/dist/{agent-DGv1-d81.d.cts → agent-ZCZa7YQv.d.ts} +108 -41
  12. package/dist/agent-session-store-N4TVKHBU.cjs +23 -0
  13. package/dist/agent-session-store-N4TVKHBU.cjs.map +1 -0
  14. package/dist/agent-session-store-RHMHP5DG.js +6 -0
  15. package/dist/agent-session-store-RHMHP5DG.js.map +1 -0
  16. package/dist/agent.d.ts +38 -2
  17. package/dist/auth/index.cjs +15 -15
  18. package/dist/auth/index.js +4 -4
  19. package/dist/{batch-SY5GZLFD.js → batch-6KQM3EBA.js} +12 -12
  20. package/dist/batch-6KQM3EBA.js.map +1 -0
  21. package/dist/{batch-3SEPDXCU.cjs → batch-X6JKGDPK.cjs} +26 -26
  22. package/dist/batch-X6JKGDPK.cjs.map +1 -0
  23. package/dist/chunk-2RW7K6FN.cjs +34 -0
  24. package/dist/chunk-2RW7K6FN.cjs.map +1 -0
  25. package/dist/chunk-3I4B3OIX.js +105 -0
  26. package/dist/chunk-3I4B3OIX.js.map +1 -0
  27. package/dist/{chunk-2WFB5ZOX.js → chunk-42IFCKQZ.js} +5 -5
  28. package/dist/{chunk-2WFB5ZOX.js.map → chunk-42IFCKQZ.js.map} +1 -1
  29. package/dist/{chunk-DCJ5MCJ3.js → chunk-4F7JQZOX.js} +9 -36
  30. package/dist/chunk-4F7JQZOX.js.map +1 -0
  31. package/dist/{chunk-JNIWFCKI.js → chunk-4JSZYSGW.js} +3 -3
  32. package/dist/{chunk-JNIWFCKI.js.map → chunk-4JSZYSGW.js.map} +1 -1
  33. package/dist/{chunk-EEZ7CFMM.js → chunk-5KOW3GLE.js} +2 -2
  34. package/dist/chunk-5KOW3GLE.js.map +1 -0
  35. package/dist/{chunk-6VP3XGEK.js → chunk-65ONFZWM.js} +12 -11
  36. package/dist/chunk-65ONFZWM.js.map +1 -0
  37. package/dist/{chunk-CSZRJ4RE.js → chunk-6EEYRFJC.js} +5 -5
  38. package/dist/{chunk-CSZRJ4RE.js.map → chunk-6EEYRFJC.js.map} +1 -1
  39. package/dist/{chunk-FAY3QDGC.cjs → chunk-6LGQECT7.cjs} +11 -11
  40. package/dist/{chunk-FAY3QDGC.cjs.map → chunk-6LGQECT7.cjs.map} +1 -1
  41. package/dist/{chunk-PAEJPLVN.cjs → chunk-6NEHIHFU.cjs} +4 -4
  42. package/dist/{chunk-PAEJPLVN.cjs.map → chunk-6NEHIHFU.cjs.map} +1 -1
  43. package/dist/chunk-6YNYA7GD.cjs +103 -0
  44. package/dist/chunk-6YNYA7GD.cjs.map +1 -0
  45. package/dist/chunk-74D7KSBP.cjs +112 -0
  46. package/dist/chunk-74D7KSBP.cjs.map +1 -0
  47. package/dist/{chunk-FK4EJD2I.cjs → chunk-75DSEWTJ.cjs} +7 -7
  48. package/dist/{chunk-FK4EJD2I.cjs.map → chunk-75DSEWTJ.cjs.map} +1 -1
  49. package/dist/{chunk-SWIBQFPH.cjs → chunk-7OLG7VI4.cjs} +4 -4
  50. package/dist/{chunk-SWIBQFPH.cjs.map → chunk-7OLG7VI4.cjs.map} +1 -1
  51. package/dist/chunk-7U2HAAWB.cjs +199 -0
  52. package/dist/chunk-7U2HAAWB.cjs.map +1 -0
  53. package/dist/{chunk-YBFDBOUN.cjs → chunk-7YBJZS5P.cjs} +8 -8
  54. package/dist/{chunk-YBFDBOUN.cjs.map → chunk-7YBJZS5P.cjs.map} +1 -1
  55. package/dist/{chunk-GLUWH6JO.js → chunk-AECV3G5Z.js} +4 -4
  56. package/dist/{chunk-GLUWH6JO.js.map → chunk-AECV3G5Z.js.map} +1 -1
  57. package/dist/{chunk-UQPDFW4E.js → chunk-AR5MQZ3J.js} +3 -3
  58. package/dist/{chunk-UQPDFW4E.js.map → chunk-AR5MQZ3J.js.map} +1 -1
  59. package/dist/{chunk-G2F67XUR.cjs → chunk-B4YA6BRS.cjs} +13 -14
  60. package/dist/chunk-B4YA6BRS.cjs.map +1 -0
  61. package/dist/{chunk-LTCOPATU.cjs → chunk-BCQ3E2ZG.cjs} +12 -3
  62. package/dist/chunk-BCQ3E2ZG.cjs.map +1 -0
  63. package/dist/{chunk-ALU3KC4G.cjs → chunk-BPN5ONSW.cjs} +223 -277
  64. package/dist/chunk-BPN5ONSW.cjs.map +1 -0
  65. package/dist/{chunk-YHZXBDAW.js → chunk-BQDUEG4C.js} +16 -16
  66. package/dist/{chunk-YHZXBDAW.js.map → chunk-BQDUEG4C.js.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-BJMKQOY2.cjs → chunk-C7OP3FAK.cjs} +47 -11
  70. package/dist/chunk-C7OP3FAK.cjs.map +1 -0
  71. package/dist/{chunk-XAYVHS2B.cjs → chunk-CEIHCKTO.cjs} +4 -4
  72. package/dist/chunk-CEIHCKTO.cjs.map +1 -0
  73. package/dist/{chunk-2423XDPT.cjs → chunk-CN6UX5EV.cjs} +28 -56
  74. package/dist/chunk-CN6UX5EV.cjs.map +1 -0
  75. package/dist/{chunk-VNNK6AKU.js → chunk-D7IULBF2.js} +3 -3
  76. package/dist/chunk-D7IULBF2.js.map +1 -0
  77. package/dist/chunk-DCXRHCZJ.cjs +118 -0
  78. package/dist/chunk-DCXRHCZJ.cjs.map +1 -0
  79. package/dist/{chunk-ICYBIC6N.cjs → chunk-DGLLVCNB.cjs} +4 -4
  80. package/dist/chunk-DGLLVCNB.cjs.map +1 -0
  81. package/dist/{chunk-I35DI7ES.js → chunk-DKFGUOWL.js} +3 -3
  82. package/dist/{chunk-I35DI7ES.js.map → chunk-DKFGUOWL.js.map} +1 -1
  83. package/dist/{chunk-TQI3KRXZ.cjs → chunk-DMTZ3FII.cjs} +18 -18
  84. package/dist/{chunk-TQI3KRXZ.cjs.map → chunk-DMTZ3FII.cjs.map} +1 -1
  85. package/dist/{chunk-QFMXXUUT.js → chunk-DU7DE543.js} +3 -3
  86. package/dist/{chunk-QFMXXUUT.js.map → chunk-DU7DE543.js.map} +1 -1
  87. package/dist/{chunk-W4QN5CMG.cjs → chunk-DWY25VLP.cjs} +9 -9
  88. package/dist/{chunk-W4QN5CMG.cjs.map → chunk-DWY25VLP.cjs.map} +1 -1
  89. package/dist/chunk-E2FFG33C.js +109 -0
  90. package/dist/chunk-E2FFG33C.js.map +1 -0
  91. package/dist/{chunk-QUFSDDNU.cjs → chunk-E4IUN3JB.cjs} +15 -15
  92. package/dist/{chunk-QUFSDDNU.cjs.map → chunk-E4IUN3JB.cjs.map} +1 -1
  93. package/dist/{chunk-THEYGCYS.cjs → chunk-ECHGWE47.cjs} +4 -4
  94. package/dist/chunk-ECHGWE47.cjs.map +1 -0
  95. package/dist/{chunk-U2WLFOA3.cjs → chunk-ECW2MLEW.cjs} +4 -4
  96. package/dist/{chunk-U2WLFOA3.cjs.map → chunk-ECW2MLEW.cjs.map} +1 -1
  97. package/dist/{chunk-MXSMAGDU.js → chunk-ET6PHZRX.js} +33 -26
  98. package/dist/chunk-ET6PHZRX.js.map +1 -0
  99. package/dist/{chunk-G6AASL5T.cjs → chunk-FRUBE44B.cjs} +24 -24
  100. package/dist/{chunk-G6AASL5T.cjs.map → chunk-FRUBE44B.cjs.map} +1 -1
  101. package/dist/{chunk-3ILFUXNE.cjs → chunk-FWBSDQZ7.cjs} +5 -5
  102. package/dist/{chunk-3ILFUXNE.cjs.map → chunk-FWBSDQZ7.cjs.map} +1 -1
  103. package/dist/{chunk-7DXLNNKH.cjs → chunk-G2Q3ZC6C.cjs} +4 -4
  104. package/dist/{chunk-7DXLNNKH.cjs.map → chunk-G2Q3ZC6C.cjs.map} +1 -1
  105. package/dist/{chunk-56ZM6P7Z.cjs → chunk-G4XUXSRN.cjs} +12 -12
  106. package/dist/chunk-G4XUXSRN.cjs.map +1 -0
  107. package/dist/{chunk-VYJSHGAY.js → chunk-GIRD3RWH.js} +422 -295
  108. package/dist/chunk-GIRD3RWH.js.map +1 -0
  109. package/dist/{chunk-NQ4AC2U4.cjs → chunk-HIQFVHC6.cjs} +9 -9
  110. package/dist/{chunk-NQ4AC2U4.cjs.map → chunk-HIQFVHC6.cjs.map} +1 -1
  111. package/dist/{chunk-EXQV452X.js → chunk-HWNVAUK4.js} +3 -3
  112. package/dist/{chunk-EXQV452X.js.map → chunk-HWNVAUK4.js.map} +1 -1
  113. package/dist/{chunk-P34DHHYQ.cjs → chunk-I53ZQHU6.cjs} +34 -27
  114. package/dist/chunk-I53ZQHU6.cjs.map +1 -0
  115. package/dist/{chunk-MHCKWQR3.cjs → chunk-IHFNRNTJ.cjs} +8 -8
  116. package/dist/{chunk-MHCKWQR3.cjs.map → chunk-IHFNRNTJ.cjs.map} +1 -1
  117. package/dist/{chunk-W52DKZBR.cjs → chunk-INSFS5GT.cjs} +680 -553
  118. package/dist/chunk-INSFS5GT.cjs.map +1 -0
  119. package/dist/{chunk-TAPQWDW2.js → chunk-IVSD7L22.js} +12 -4
  120. package/dist/chunk-IVSD7L22.js.map +1 -0
  121. package/dist/{chunk-WDGCZDRG.js → chunk-J3UK2GMN.js} +3 -3
  122. package/dist/{chunk-WDGCZDRG.js.map → chunk-J3UK2GMN.js.map} +1 -1
  123. package/dist/{chunk-4YB7B3RP.cjs → chunk-J6T5LWJ4.cjs} +15 -14
  124. package/dist/chunk-J6T5LWJ4.cjs.map +1 -0
  125. package/dist/{chunk-XAEAMI5H.js → chunk-JRLXEYR4.js} +21 -5
  126. package/dist/chunk-JRLXEYR4.js.map +1 -0
  127. package/dist/{chunk-ZJN6NTHE.js → chunk-JZUPMTJY.js} +3 -3
  128. package/dist/{chunk-ZJN6NTHE.js.map → chunk-JZUPMTJY.js.map} +1 -1
  129. package/dist/{chunk-M5ZQBOIZ.js → chunk-KE6XKRLQ.js} +3 -3
  130. package/dist/{chunk-M5ZQBOIZ.js.map → chunk-KE6XKRLQ.js.map} +1 -1
  131. package/dist/chunk-KGRIHEDT.js +110 -0
  132. package/dist/chunk-KGRIHEDT.js.map +1 -0
  133. package/dist/{chunk-T4QWDOG6.js → chunk-KWUNN5J2.js} +5 -5
  134. package/dist/{chunk-T4QWDOG6.js.map → chunk-KWUNN5J2.js.map} +1 -1
  135. package/dist/{chunk-56OXYUZE.js → chunk-KX7JV5KM.js} +3 -3
  136. package/dist/chunk-KX7JV5KM.js.map +1 -0
  137. package/dist/{chunk-D4ZUJTFB.cjs → chunk-LALG2K33.cjs} +8 -8
  138. package/dist/{chunk-D4ZUJTFB.cjs.map → chunk-LALG2K33.cjs.map} +1 -1
  139. package/dist/{chunk-QGDKZDPN.js → chunk-LGILIGV3.js} +3 -3
  140. package/dist/{chunk-QGDKZDPN.js.map → chunk-LGILIGV3.js.map} +1 -1
  141. package/dist/{chunk-HEN5WXXI.js → chunk-LJX2SQV2.js} +6 -6
  142. package/dist/{chunk-HEN5WXXI.js.map → chunk-LJX2SQV2.js.map} +1 -1
  143. package/dist/{chunk-SDIBMLL5.js → chunk-MC5EINBV.js} +44 -8
  144. package/dist/chunk-MC5EINBV.js.map +1 -0
  145. package/dist/{chunk-F6Y4IEQM.js → chunk-ML5A5DOJ.js} +4 -4
  146. package/dist/{chunk-F6Y4IEQM.js.map → chunk-ML5A5DOJ.js.map} +1 -1
  147. package/dist/{chunk-6EDQBX7U.cjs → chunk-N475ETD6.cjs} +17 -17
  148. package/dist/{chunk-6EDQBX7U.cjs.map → chunk-N475ETD6.cjs.map} +1 -1
  149. package/dist/{chunk-YPQF26X7.cjs → chunk-OBA6YK2R.cjs} +2 -2
  150. package/dist/chunk-OBA6YK2R.cjs.map +1 -0
  151. package/dist/chunk-OXNYIMZZ.js +31 -0
  152. package/dist/chunk-OXNYIMZZ.js.map +1 -0
  153. package/dist/{chunk-NFCKEBHI.js → chunk-PI4RO4GR.js} +3 -3
  154. package/dist/{chunk-NFCKEBHI.js.map → chunk-PI4RO4GR.js.map} +1 -1
  155. package/dist/{chunk-2ONFGMBV.js → chunk-PY2RQOA7.js} +2 -2
  156. package/dist/chunk-PY2RQOA7.js.map +1 -0
  157. package/dist/chunk-QKE556YD.js +197 -0
  158. package/dist/chunk-QKE556YD.js.map +1 -0
  159. package/dist/{chunk-FV3YEMQ7.js → chunk-RP5HQVLD.js} +13 -14
  160. package/dist/chunk-RP5HQVLD.js.map +1 -0
  161. package/dist/chunk-SCFW5MJZ.js +100 -0
  162. package/dist/chunk-SCFW5MJZ.js.map +1 -0
  163. package/dist/{chunk-CD73YHEH.js → chunk-SG5ZWT6C.js} +3 -3
  164. package/dist/{chunk-CD73YHEH.js.map → chunk-SG5ZWT6C.js.map} +1 -1
  165. package/dist/{chunk-MRODLUGY.cjs → chunk-TIMPJL5V.cjs} +4 -4
  166. package/dist/{chunk-MRODLUGY.cjs.map → chunk-TIMPJL5V.cjs.map} +1 -1
  167. package/dist/{chunk-77WHPVXE.js → chunk-TOTP24P6.js} +4 -4
  168. package/dist/chunk-TOTP24P6.js.map +1 -0
  169. package/dist/{chunk-3O2ELBST.cjs → chunk-USZTVNUQ.cjs} +5 -5
  170. package/dist/{chunk-3O2ELBST.cjs.map → chunk-USZTVNUQ.cjs.map} +1 -1
  171. package/dist/{chunk-YDLNI7J6.js → chunk-V2RBCCN5.js} +3 -3
  172. package/dist/chunk-V2RBCCN5.js.map +1 -0
  173. package/dist/{chunk-NNSKJCBM.cjs → chunk-VJYSQXN6.cjs} +10 -10
  174. package/dist/{chunk-NNSKJCBM.cjs.map → chunk-VJYSQXN6.cjs.map} +1 -1
  175. package/dist/{chunk-GM7QDQ24.cjs → chunk-W4WKVOOQ.cjs} +11 -11
  176. package/dist/{chunk-GM7QDQ24.cjs.map → chunk-W4WKVOOQ.cjs.map} +1 -1
  177. package/dist/chunk-XYOHKCYG.cjs +109 -0
  178. package/dist/chunk-XYOHKCYG.cjs.map +1 -0
  179. package/dist/{chunk-ZW345YOI.js → chunk-YP67XZES.js} +4 -4
  180. package/dist/{chunk-ZW345YOI.js.map → chunk-YP67XZES.js.map} +1 -1
  181. package/dist/{chunk-YCXMSDSP.js → chunk-YRXY2A5L.js} +4 -4
  182. package/dist/{chunk-YCXMSDSP.js.map → chunk-YRXY2A5L.js.map} +1 -1
  183. package/dist/{chunk-IEUDKUPM.cjs → chunk-Z2CUEBXV.cjs} +25 -9
  184. package/dist/chunk-Z2CUEBXV.cjs.map +1 -0
  185. package/dist/{chunk-GL7CFBVC.js → chunk-ZYB6B7QJ.js} +112 -165
  186. package/dist/chunk-ZYB6B7QJ.js.map +1 -0
  187. package/dist/compact-session-PYEC3NZV.js +18 -0
  188. package/dist/{compact-session-WNKKIIDW.js.map → compact-session-PYEC3NZV.js.map} +1 -1
  189. package/dist/compact-session-VVT6IBJG.cjs +55 -0
  190. package/dist/{compact-session-H5TKLD55.cjs.map → compact-session-VVT6IBJG.cjs.map} +1 -1
  191. package/dist/compaction.cjs +19 -19
  192. package/dist/compaction.d.cts +9 -9
  193. package/dist/compaction.d.ts +9 -9
  194. package/dist/compaction.js +3 -3
  195. package/dist/concurrency.cjs +6 -6
  196. package/dist/concurrency.js +4 -4
  197. package/dist/context-2FZSC6VQ.cjs +22 -0
  198. package/dist/{context-ZV33V4DC.cjs.map → context-2FZSC6VQ.cjs.map} +1 -1
  199. package/dist/context-ATJJAFOS.js +5 -0
  200. package/dist/{context-VAYLPT4O.js.map → context-ATJJAFOS.js.map} +1 -1
  201. package/dist/{cron-Dx7B-3WB.d.ts → cron-Bx7tzm5R.d.ts} +54 -2
  202. package/dist/{cron-BiK_aNJI.d.cts → cron-D-DVjGQe.d.cts} +54 -2
  203. package/dist/cron.cjs +34 -30
  204. package/dist/cron.d.cts +3 -3
  205. package/dist/cron.d.ts +3 -3
  206. package/dist/cron.js +33 -29
  207. package/dist/{errors-DyVbXdR4.d.cts → errors-DMY-gLSK.d.cts} +1 -1
  208. package/dist/{errors-Cua4WC9H.d.ts → errors-DjBQ4Tn8.d.ts} +1 -1
  209. package/dist/errors.cjs +21 -21
  210. package/dist/errors.d.cts +2 -2
  211. package/dist/errors.d.ts +2 -2
  212. package/dist/errors.js +2 -2
  213. package/dist/eval.cjs +42 -37
  214. package/dist/eval.cjs.map +1 -1
  215. package/dist/eval.js +38 -33
  216. package/dist/eval.js.map +1 -1
  217. package/dist/{executor-OZSYXDKF.cjs → executor-BMRICN46.cjs} +26 -25
  218. package/dist/executor-BMRICN46.cjs.map +1 -0
  219. package/dist/{executor-PAH72CB5.js → executor-T65PPOPT.js} +10 -9
  220. package/dist/executor-T65PPOPT.js.map +1 -0
  221. package/dist/filesystem/index.cjs +7 -7
  222. package/dist/filesystem/index.js +3 -3
  223. package/dist/fs-session-store-J5MCFFUM.cjs +19 -0
  224. package/dist/{fs-session-store-7E7UPLF2.cjs.map → fs-session-store-J5MCFFUM.cjs.map} +1 -1
  225. package/dist/fs-session-store-O6FNHECD.js +10 -0
  226. package/dist/{fs-session-store-6MY7PNI2.js.map → fs-session-store-O6FNHECD.js.map} +1 -1
  227. package/dist/generate-object-UF6WIZLF.cjs +20 -0
  228. package/dist/{generate-object-5SCEH2EE.cjs.map → generate-object-UF6WIZLF.cjs.map} +1 -1
  229. package/dist/generate-object-XDCBYVK3.js +7 -0
  230. package/dist/{generate-object-I7UD4NWN.js.map → generate-object-XDCBYVK3.js.map} +1 -1
  231. package/dist/index-manager-N7RQYUKT.cjs +20 -0
  232. package/dist/{index-manager-R6ZJFEZF.cjs.map → index-manager-N7RQYUKT.cjs.map} +1 -1
  233. package/dist/index-manager-ZVZUHPP7.js +11 -0
  234. package/dist/{index-manager-KKAK7NT3.js.map → index-manager-ZVZUHPP7.js.map} +1 -1
  235. package/dist/index.cjs +154 -148
  236. package/dist/index.cjs.map +1 -1
  237. package/dist/index.d.cts +201 -43
  238. package/dist/index.d.ts +201 -43
  239. package/dist/index.js +62 -59
  240. package/dist/index.js.map +1 -1
  241. package/dist/{inject-session-UXNJQTZ6.js → inject-session-GQMTDZUN.js} +8 -7
  242. package/dist/inject-session-GQMTDZUN.js.map +1 -0
  243. package/dist/{inject-session-DM4SKTZO.cjs → inject-session-LFCYVSLJ.cjs} +11 -10
  244. package/dist/inject-session-LFCYVSLJ.cjs.map +1 -0
  245. package/dist/internal/agent-loop/live-events.d.ts +46 -0
  246. package/dist/internal/agent-loop/loop-thinking-steps.d.ts +28 -0
  247. package/dist/internal/agent-loop/message-builders.d.ts +12 -3
  248. package/dist/internal/budget/compute-cost.d.ts +1 -1
  249. package/dist/internal/diagnostics.d.ts +46 -31
  250. package/dist/internal/error-mappers/anthropic.d.ts +1 -1
  251. package/dist/internal/global-singleton.d.ts +7 -7
  252. package/dist/internal/judge/judge-call.d.ts +14 -14
  253. package/dist/internal/llm/anthropic-shared.d.ts +4 -4
  254. package/dist/internal/llm/retrying-client.d.ts +29 -29
  255. package/dist/internal/llm/transport-error.d.ts +2 -2
  256. package/dist/internal/llm/types.d.ts +49 -9
  257. package/dist/internal/local-agent/mcp-pool.d.ts +7 -3
  258. package/dist/internal/memory/adapters/azure-openai-embedding.d.cts +2 -0
  259. package/dist/internal/memory/adapters/catalog.d.cts +1 -0
  260. package/dist/internal/memory/adapters/cohere-embedding.d.cts +2 -0
  261. package/dist/internal/memory/adapters/deepinfra-embedding.d.cts +2 -0
  262. package/dist/internal/memory/adapters/gemini-embedding.d.cts +2 -0
  263. package/dist/internal/memory/adapters/index.cjs +28 -0
  264. package/dist/internal/memory/adapters/index.cjs.map +1 -0
  265. package/dist/internal/memory/adapters/index.d.cts +16 -0
  266. package/dist/internal/memory/adapters/index.d.ts +16 -0
  267. package/dist/internal/memory/adapters/index.js +11 -0
  268. package/dist/internal/memory/adapters/index.js.map +1 -0
  269. package/dist/internal/memory/adapters/jina-embedding.d.cts +2 -0
  270. package/dist/internal/memory/adapters/mistral-embedding.d.cts +2 -0
  271. package/dist/internal/memory/adapters/ollama-embedding.d.cts +34 -0
  272. package/dist/internal/memory/adapters/openai-compatible.d.cts +51 -0
  273. package/dist/internal/memory/adapters/openai-compatible.d.ts +28 -0
  274. package/dist/internal/memory/adapters/openai-embedding.d.cts +2 -0
  275. package/dist/internal/memory/adapters/openrouter-embedding.d.cts +2 -0
  276. package/dist/internal/memory/adapters/voyage-embedding.d.cts +2 -0
  277. package/dist/internal/memory/dreaming/diary.d.ts +4 -0
  278. package/dist/internal/memory/dreaming/phases.d.ts +15 -0
  279. package/dist/internal/memory/dreaming/run.d.ts +10 -0
  280. package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +15 -0
  281. package/dist/internal/memory/sdk-memory-peer-loader.d.ts +21 -0
  282. package/dist/internal/persistence/exclusive-create.d.cts +2 -2
  283. package/dist/internal/persistence/exclusive-create.d.ts +2 -2
  284. package/dist/internal/persistence/fs-session-store.d.cts +18 -18
  285. package/dist/internal/persistence/fs-session-store.d.ts +18 -18
  286. package/dist/internal/persistence/index.cjs +25 -25
  287. package/dist/internal/persistence/index.cjs.map +1 -1
  288. package/dist/internal/persistence/index.js +6 -6
  289. package/dist/internal/persistence/index.js.map +1 -1
  290. package/dist/internal/persistence/paths.d.cts +7 -7
  291. package/dist/internal/persistence/paths.d.ts +7 -7
  292. package/dist/internal/persistence/session-transcript.d.cts +13 -7
  293. package/dist/internal/persistence/session-transcript.d.ts +13 -7
  294. package/dist/internal/persistence/session-writer.d.cts +30 -13
  295. package/dist/internal/persistence/session-writer.d.ts +30 -13
  296. package/dist/internal/runtime/concurrency/subagent-credentials.d.ts +35 -0
  297. package/dist/internal/runtime/fixtures/fixture-run-base.d.ts +45 -13
  298. package/dist/internal/runtime/lifecycle/goal-marker.d.ts +8 -8
  299. package/dist/internal/security/index.cjs +13 -13
  300. package/dist/internal/security/index.js +3 -3
  301. package/dist/internal/session/agent-session-store.d.ts +1 -0
  302. package/dist/internal/session/agent-session.d.ts +14 -14
  303. package/dist/internal/session/session-cache.d.ts +9 -9
  304. package/dist/internal/session/session-types.d.ts +6 -1
  305. package/dist/judge-call-NA2G6ZMJ.js +5 -0
  306. package/dist/{judge-call-TAEIXMYG.js.map → judge-call-NA2G6ZMJ.js.map} +1 -1
  307. package/dist/judge-call-U2D33JOW.cjs +22 -0
  308. package/dist/{judge-call-SP3G3X2Y.cjs.map → judge-call-U2D33JOW.cjs.map} +1 -1
  309. package/dist/models.cjs +20 -20
  310. package/dist/models.cjs.map +1 -1
  311. package/dist/models.js +5 -5
  312. package/dist/models.js.map +1 -1
  313. package/dist/path-safety.cjs +10 -10
  314. package/dist/path-safety.js +3 -3
  315. package/dist/persistence.cjs +43 -43
  316. package/dist/persistence.cjs.map +1 -1
  317. package/dist/persistence.d.cts +1 -1
  318. package/dist/persistence.d.ts +1 -1
  319. package/dist/persistence.js +14 -14
  320. package/dist/persistence.js.map +1 -1
  321. package/dist/project.cjs +5 -5
  322. package/dist/project.js +3 -3
  323. package/dist/registry-CAS6Y5ZY.js +9 -0
  324. package/dist/{registry-SOXE4RY6.js.map → registry-CAS6Y5ZY.js.map} +1 -1
  325. package/dist/registry-JSDI4WKA.cjs +46 -0
  326. package/dist/{registry-N3GTKYCI.cjs.map → registry-JSDI4WKA.cjs.map} +1 -1
  327. package/dist/retry.cjs +4 -4
  328. package/dist/retry.js +3 -3
  329. package/dist/{run-CwEJtLPE.d.ts → run-i2-fUohR.d.cts} +217 -174
  330. package/dist/{run-CwEJtLPE.d.cts → run-i2-fUohR.d.ts} +217 -174
  331. package/dist/{run-until-YZ2ODWOF.js → run-until-BK56WG4P.js} +3 -3
  332. package/dist/{run-until-YZ2ODWOF.js.map → run-until-BK56WG4P.js.map} +1 -1
  333. package/dist/{run-until-ZZ2JLPJM.cjs → run-until-L5KQD3PV.cjs} +4 -4
  334. package/dist/{run-until-ZZ2JLPJM.cjs.map → run-until-L5KQD3PV.cjs.map} +1 -1
  335. package/dist/sandbox/bwrap.d.cts +20 -20
  336. package/dist/sandbox/bwrap.d.ts +20 -20
  337. package/dist/sandbox/index.cjs +39 -39
  338. package/dist/sandbox/index.cjs.map +1 -1
  339. package/dist/sandbox/index.d.cts +1 -1
  340. package/dist/sandbox/index.d.ts +1 -1
  341. package/dist/sandbox/index.js +35 -35
  342. package/dist/sandbox/index.js.map +1 -1
  343. package/dist/sandbox/linux-sandbox.d.cts +26 -21
  344. package/dist/sandbox/linux-sandbox.d.ts +26 -21
  345. package/dist/server/auth/index.cjs.map +1 -1
  346. package/dist/server/auth/index.d.cts +6 -6
  347. package/dist/server/auth/index.d.ts +6 -6
  348. package/dist/server/auth/index.js.map +1 -1
  349. package/dist/server/auth/orchestrator.d.cts +2 -2
  350. package/dist/server/auth/orchestrator.d.ts +2 -2
  351. package/dist/server/auth/types.d.cts +4 -4
  352. package/dist/server/auth/types.d.ts +4 -4
  353. package/dist/server/errors-envelope.cjs +14 -14
  354. package/dist/server/errors-envelope.d.cts +3 -3
  355. package/dist/server/errors-envelope.d.ts +3 -3
  356. package/dist/server/errors-envelope.js +3 -3
  357. package/dist/session-transcript-3B52DKTG.js +5 -0
  358. package/dist/{session-transcript-6WKLYIN4.js.map → session-transcript-3B52DKTG.js.map} +1 -1
  359. package/dist/session-transcript-H7NUFXXM.cjs +50 -0
  360. package/dist/{session-transcript-EAKR4D2W.cjs.map → session-transcript-H7NUFXXM.cjs.map} +1 -1
  361. package/dist/skills.cjs +7 -7
  362. package/dist/skills.js +5 -5
  363. package/dist/stream-object-4FDU76YW.cjs +20 -0
  364. package/dist/{stream-object-Y7YCX3BI.cjs.map → stream-object-4FDU76YW.cjs.map} +1 -1
  365. package/dist/stream-object-HWDEEQN4.js +7 -0
  366. package/dist/{stream-object-OFM66VUT.js.map → stream-object-HWDEEQN4.js.map} +1 -1
  367. package/dist/subagents-loader-A4W6C3QP.cjs +15 -0
  368. package/dist/subagents-loader-A4W6C3QP.cjs.map +1 -0
  369. package/dist/subagents-loader-X33KH2SZ.js +6 -0
  370. package/dist/subagents-loader-X33KH2SZ.js.map +1 -0
  371. package/dist/subagents-loader.cjs +6 -6
  372. package/dist/subagents-loader.d.cts +2 -2
  373. package/dist/subagents-loader.d.ts +2 -2
  374. package/dist/subagents-loader.js +4 -4
  375. package/dist/subscription/index.cjs +3 -3
  376. package/dist/subscription/index.js +2 -2
  377. package/dist/task-store.cjs +7 -7
  378. package/dist/task-store.js +4 -4
  379. package/dist/types/agent-prims.d.ts +4 -4
  380. package/dist/types/agent.d.ts +68 -3
  381. package/dist/types/conversation.d.ts +7 -0
  382. package/dist/types/goal-events.d.ts +24 -23
  383. package/dist/types/messages.d.ts +9 -0
  384. package/dist/types/run.d.ts +27 -0
  385. package/dist/types/session-message.d.ts +59 -0
  386. package/dist/types/session-record.d.ts +14 -13
  387. package/dist/types/workflow.d.ts +36 -0
  388. package/dist/workflow.cjs +27 -27
  389. package/dist/workflow.d.cts +17 -1
  390. package/dist/workflow.d.ts +17 -1
  391. package/dist/workflow.js +6 -6
  392. package/docs/harness-capability-map.md +22 -0
  393. package/package.json +22 -13
  394. package/dist/agent-DW2J37IH.js +0 -42
  395. package/dist/agent-IE6IE4NW.cjs +0 -51
  396. package/dist/batch-3SEPDXCU.cjs.map +0 -1
  397. package/dist/batch-SY5GZLFD.js.map +0 -1
  398. package/dist/chunk-2423XDPT.cjs.map +0 -1
  399. package/dist/chunk-2ONFGMBV.js.map +0 -1
  400. package/dist/chunk-4YB7B3RP.cjs.map +0 -1
  401. package/dist/chunk-56OXYUZE.js.map +0 -1
  402. package/dist/chunk-56ZM6P7Z.cjs.map +0 -1
  403. package/dist/chunk-5SB4V74H.js +0 -176
  404. package/dist/chunk-5SB4V74H.js.map +0 -1
  405. package/dist/chunk-6VP3XGEK.js.map +0 -1
  406. package/dist/chunk-77WHPVXE.js.map +0 -1
  407. package/dist/chunk-ALU3KC4G.cjs.map +0 -1
  408. package/dist/chunk-BJMKQOY2.cjs.map +0 -1
  409. package/dist/chunk-DCJ5MCJ3.js.map +0 -1
  410. package/dist/chunk-EEZ7CFMM.js.map +0 -1
  411. package/dist/chunk-FV3YEMQ7.js.map +0 -1
  412. package/dist/chunk-G2F67XUR.cjs.map +0 -1
  413. package/dist/chunk-GL7CFBVC.js.map +0 -1
  414. package/dist/chunk-H5YVJB4K.cjs +0 -185
  415. package/dist/chunk-H5YVJB4K.cjs.map +0 -1
  416. package/dist/chunk-ICYBIC6N.cjs.map +0 -1
  417. package/dist/chunk-IEUDKUPM.cjs.map +0 -1
  418. package/dist/chunk-IT3PWBW4.cjs.map +0 -1
  419. package/dist/chunk-ITLS5LRF.cjs +0 -105
  420. package/dist/chunk-ITLS5LRF.cjs.map +0 -1
  421. package/dist/chunk-LTCOPATU.cjs.map +0 -1
  422. package/dist/chunk-MXSMAGDU.js.map +0 -1
  423. package/dist/chunk-P34DHHYQ.cjs.map +0 -1
  424. package/dist/chunk-SDIBMLL5.js.map +0 -1
  425. package/dist/chunk-TAPQWDW2.js.map +0 -1
  426. package/dist/chunk-THEYGCYS.cjs.map +0 -1
  427. package/dist/chunk-VNNK6AKU.js.map +0 -1
  428. package/dist/chunk-VYJSHGAY.js.map +0 -1
  429. package/dist/chunk-W52DKZBR.cjs.map +0 -1
  430. package/dist/chunk-XAEAMI5H.js.map +0 -1
  431. package/dist/chunk-XAYVHS2B.cjs.map +0 -1
  432. package/dist/chunk-YDLNI7J6.js.map +0 -1
  433. package/dist/chunk-YPQF26X7.cjs.map +0 -1
  434. package/dist/chunk-YVTNFKZO.js +0 -103
  435. package/dist/chunk-YVTNFKZO.js.map +0 -1
  436. package/dist/compact-session-H5TKLD55.cjs +0 -54
  437. package/dist/compact-session-WNKKIIDW.js +0 -17
  438. package/dist/context-VAYLPT4O.js +0 -5
  439. package/dist/context-ZV33V4DC.cjs +0 -22
  440. package/dist/executor-OZSYXDKF.cjs.map +0 -1
  441. package/dist/executor-PAH72CB5.js.map +0 -1
  442. package/dist/fs-session-store-6MY7PNI2.js +0 -10
  443. package/dist/fs-session-store-7E7UPLF2.cjs +0 -19
  444. package/dist/generate-object-5SCEH2EE.cjs +0 -20
  445. package/dist/generate-object-I7UD4NWN.js +0 -7
  446. package/dist/index-manager-KKAK7NT3.js +0 -10
  447. package/dist/index-manager-R6ZJFEZF.cjs +0 -19
  448. package/dist/inject-session-DM4SKTZO.cjs.map +0 -1
  449. package/dist/inject-session-UXNJQTZ6.js.map +0 -1
  450. package/dist/judge-call-SP3G3X2Y.cjs +0 -22
  451. package/dist/judge-call-TAEIXMYG.js +0 -5
  452. package/dist/registry-N3GTKYCI.cjs +0 -46
  453. package/dist/registry-SOXE4RY6.js +0 -9
  454. package/dist/session-transcript-6WKLYIN4.js +0 -5
  455. package/dist/session-transcript-EAKR4D2W.cjs +0 -50
  456. package/dist/stream-object-OFM66VUT.js +0 -7
  457. package/dist/stream-object-Y7YCX3BI.cjs +0 -20
@@ -1,8 +1,9 @@
1
- import { enqueueSessionWrite } from './chunk-5SB4V74H.js';
2
- import { invalidateSessionCache } from './chunk-EEZ7CFMM.js';
3
- import { SessionTranscript } from './chunk-XAEAMI5H.js';
4
- import './chunk-56OXYUZE.js';
5
- import './chunk-TAPQWDW2.js';
1
+ import { enqueueSessionWrite } from './chunk-E2FFG33C.js';
2
+ import { invalidateSessionCache } from './chunk-5KOW3GLE.js';
3
+ import './chunk-3I4B3OIX.js';
4
+ import { SessionTranscript } from './chunk-JRLXEYR4.js';
5
+ import './chunk-KX7JV5KM.js';
6
+ import './chunk-IVSD7L22.js';
6
7
 
7
8
  // src/internal/session/inject-session.ts
8
9
  async function injectSessionTurn(opts) {
@@ -21,5 +22,5 @@ async function injectSessionTurn(opts) {
21
22
  }
22
23
 
23
24
  export { injectSessionTurn };
24
- //# sourceMappingURL=inject-session-UXNJQTZ6.js.map
25
- //# sourceMappingURL=inject-session-UXNJQTZ6.js.map
25
+ //# sourceMappingURL=inject-session-GQMTDZUN.js.map
26
+ //# sourceMappingURL=inject-session-GQMTDZUN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":[],"mappings":";;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAM,oBAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAa,iBAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAA,sBAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-GQMTDZUN.js","sourcesContent":["/**\n * M51 (agent-builder) — inject a SYNTHETIC user+assistant pair into a session's persisted transcript\n * WITHOUT running an LLM turn. This is the Codex review-exit mechanism (`exit_success.xml` appended to\n * the parent thread history so follow-ups like \"fix finding 2\" work): the pair chains onto the DAG\n * leaf (M50 pattern) and the in-memory cache is invalidated so the NEXT send re-hydrates with it.\n */\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { SessionTranscript } from \"../persistence/session-transcript.js\";\nimport { enqueueSessionWrite, invalidateSessionCache } from \"./agent-session.js\";\nimport type { CompactLocation } from \"./compact-session.js\";\n\nexport async function injectSessionTurn(opts: {\n store: SessionStore;\n loc: CompactLocation;\n sessionId: string;\n userText: string;\n assistantText: string;\n}): Promise<void> {\n await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {\n const prior = await opts.store.readRecords(opts.loc.agentId);\n const transcript = SessionTranscript.fromRecords(prior, {\n cwd: opts.loc.cwd,\n sessionId: opts.sessionId,\n model: opts.loc.model ?? \"unknown\",\n });\n transcript.appendUserTurn(opts.userText);\n transcript.appendAssistantTurn({ text: opts.assistantText });\n await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));\n invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);\n });\n}\n"]}
@@ -1,16 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkH5YVJB4K_cjs = require('./chunk-H5YVJB4K.cjs');
4
- var chunkIT3PWBW4_cjs = require('./chunk-IT3PWBW4.cjs');
5
- var chunkIEUDKUPM_cjs = require('./chunk-IEUDKUPM.cjs');
6
- require('./chunk-ICYBIC6N.cjs');
7
- require('./chunk-LTCOPATU.cjs');
3
+ var chunkDCXRHCZJ_cjs = require('./chunk-DCXRHCZJ.cjs');
4
+ var chunkBURYFNOM_cjs = require('./chunk-BURYFNOM.cjs');
5
+ require('./chunk-XYOHKCYG.cjs');
6
+ var chunkZ2CUEBXV_cjs = require('./chunk-Z2CUEBXV.cjs');
7
+ require('./chunk-DGLLVCNB.cjs');
8
+ require('./chunk-BCQ3E2ZG.cjs');
8
9
 
9
10
  // src/internal/session/inject-session.ts
10
11
  async function injectSessionTurn(opts) {
11
- await chunkH5YVJB4K_cjs.enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {
12
+ await chunkDCXRHCZJ_cjs.enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {
12
13
  const prior = await opts.store.readRecords(opts.loc.agentId);
13
- const transcript = chunkIEUDKUPM_cjs.SessionTranscript.fromRecords(prior, {
14
+ const transcript = chunkZ2CUEBXV_cjs.SessionTranscript.fromRecords(prior, {
14
15
  cwd: opts.loc.cwd,
15
16
  sessionId: opts.sessionId,
16
17
  model: opts.loc.model ?? "unknown"
@@ -18,10 +19,10 @@ async function injectSessionTurn(opts) {
18
19
  transcript.appendUserTurn(opts.userText);
19
20
  transcript.appendAssistantTurn({ text: opts.assistantText });
20
21
  await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));
21
- chunkIT3PWBW4_cjs.invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);
22
+ chunkBURYFNOM_cjs.invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);
22
23
  });
23
24
  }
24
25
 
25
26
  exports.injectSessionTurn = injectSessionTurn;
26
- //# sourceMappingURL=inject-session-DM4SKTZO.cjs.map
27
- //# sourceMappingURL=inject-session-DM4SKTZO.cjs.map
27
+ //# sourceMappingURL=inject-session-LFCYVSLJ.cjs.map
28
+ //# sourceMappingURL=inject-session-LFCYVSLJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":["enqueueSessionWrite","SessionTranscript","invalidateSessionCache"],"mappings":";;;;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAMA,sCAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAaC,mCAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAAC,wCAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-LFCYVSLJ.cjs","sourcesContent":["/**\n * M51 (agent-builder) — inject a SYNTHETIC user+assistant pair into a session's persisted transcript\n * WITHOUT running an LLM turn. This is the Codex review-exit mechanism (`exit_success.xml` appended to\n * the parent thread history so follow-ups like \"fix finding 2\" work): the pair chains onto the DAG\n * leaf (M50 pattern) and the in-memory cache is invalidated so the NEXT send re-hydrates with it.\n */\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { SessionTranscript } from \"../persistence/session-transcript.js\";\nimport { enqueueSessionWrite, invalidateSessionCache } from \"./agent-session.js\";\nimport type { CompactLocation } from \"./compact-session.js\";\n\nexport async function injectSessionTurn(opts: {\n store: SessionStore;\n loc: CompactLocation;\n sessionId: string;\n userText: string;\n assistantText: string;\n}): Promise<void> {\n await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {\n const prior = await opts.store.readRecords(opts.loc.agentId);\n const transcript = SessionTranscript.fromRecords(prior, {\n cwd: opts.loc.cwd,\n sessionId: opts.sessionId,\n model: opts.loc.model ?? \"unknown\",\n });\n transcript.appendUserTurn(opts.userText);\n transcript.appendAssistantTurn({ text: opts.assistantText });\n await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));\n invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);\n });\n}\n"]}
@@ -0,0 +1,46 @@
1
+ import type { SDKMessage } from "../../types/messages.js";
2
+ /**
3
+ * theokit#140 — the loop's event log, reporting each event AS IT HAPPENS.
4
+ *
5
+ * ## The defect this closes
6
+ *
7
+ * `runAgentLoop` collected events into a plain array and returned it, so nothing reached the run
8
+ * until the loop had finished. `RealLocalRun.applyAgentLoopOutput` then copied the whole batch in
9
+ * one pass. Meanwhile `SendOptions.onDelta` fired live from inside that same loop.
10
+ *
11
+ * Two clocks, one of which does not start until the other has stopped. A consumer that wanted tool
12
+ * calls interleaved with tokens in true order had to fuse both surfaces itself — which is exactly
13
+ * what `@theokit/agents` was doing, and the documented root of its ordering bug (theokit#47), its
14
+ * namespace-dedup bug (theokit#138) and its missing terminal frame (theokit#142).
15
+ *
16
+ * ## Why a subclass, and not a callback threaded through nine call sites
17
+ *
18
+ * The events are appended from nine places across `loop.ts`, `loop-llm-stream.ts` and
19
+ * `tool-dispatch.ts`. Threading an `onEvent` parameter to each would touch every one of them and,
20
+ * worse, would leave the NEXT `events.push(...)` silently un-notified — a defect that reintroduces
21
+ * itself by omission, which is the failure mode this whole issue is about.
22
+ *
23
+ * Extending `Array` moves the decision to the single place the log is CREATED. Every existing push
24
+ * becomes live with no call-site change, and any push added later is live for free.
25
+ *
26
+ * It stays a real `Array`: `AgentLoopOutput.events` is still `SDKMessage[]`, `instanceof Array`
27
+ * still holds, and every downstream consumer — including the batch copy in `applyAgentLoopOutput` —
28
+ * is unchanged. This is additive; nothing that worked before observes a difference.
29
+ *
30
+ * `push` is the only override, deliberately. The loop only ever appends; overriding the rest of the
31
+ * mutation surface would be guarding against callers that do not exist (YAGNI), and a subscriber
32
+ * that must reason about splices is a worse contract than one that receives appends.
33
+ */
34
+ export declare class LiveEventLog extends Array<SDKMessage> {
35
+ #private;
36
+ /** Attach the live subscriber. One sink: the run that owns this loop. */
37
+ subscribe(sink: (event: SDKMessage) => void): void;
38
+ push(...events: SDKMessage[]): number;
39
+ }
40
+ /**
41
+ * Build the loop's event log, seeded with the events that exist before the loop starts.
42
+ *
43
+ * `LiveEventLog.from` rather than `new LiveEventLog(...seed)`: the `Array` constructor treats a
44
+ * single numeric argument as a length, and a seed is a list of events, never a count.
45
+ */
46
+ export declare function createEventLog(seed: readonly SDKMessage[]): LiveEventLog;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * theokit#122 — where a round's thinking block becomes a conversation step.
3
+ *
4
+ * Extracted from `loop.ts` when it crossed the G8 400-LoC cap. These two belong together: both
5
+ * answer "the round produced a thinking block — where does it land in the persisted conversation",
6
+ * and the answer differs by which path closes the round.
7
+ *
8
+ * @internal
9
+ */
10
+ import type { LlmThinkingPart } from "../llm/types.js";
11
+ import type { LoopContext } from "./loop-context-init.js";
12
+ /**
13
+ * theokit#122 — the round's thinking block as a conversation step.
14
+ *
15
+ * Shared by the two paths that can close a round: the assistant-text path and the tool_use path.
16
+ * The tool_use path is the one that matters — a round of thinking + a tool call with NO preamble
17
+ * text is the common Anthropic shape, and it is exactly the case the first version of this fix
18
+ * dropped (the block stayed on the context and was persisted against the NEXT round's text).
19
+ */
20
+ export declare function thinkingStep(thinking: LlmThinkingPart): ConversationStep;
21
+ /**
22
+ * theokit#122 — persist the block for a round that called a tool and said nothing.
23
+ *
24
+ * Such a round emits no assistant-text step, so without this the block is never recorded for it —
25
+ * which is exactly how the first version of this fix let round N's signature reach round N+1.
26
+ * No-op when the round had text (the text path already recorded it) or produced no thinking.
27
+ */
28
+ export declare function recordThinkingOnSilentToolRound(ctx: LoopContext, text: string, thinking: LlmThinkingPart | undefined): void;
@@ -1,5 +1,5 @@
1
1
  import type { SDKAssistantMessage, SDKThinkingMessage, SDKUserMessageEvent } from "../../types/messages.js";
2
- import type { LlmMessage, LlmToolCallPart } from "../llm/types.js";
2
+ import type { LlmMessage, LlmThinkingPart, LlmToolCallPart } from "../llm/types.js";
3
3
  import type { AgentLoopInputs } from "./loop-types.js";
4
4
  export declare function buildUserEvent(inputs: AgentLoopInputs): SDKUserMessageEvent;
5
5
  export declare function buildAssistantEvent(inputs: AgentLoopInputs, text: string): SDKAssistantMessage;
@@ -8,5 +8,14 @@ export declare function buildAssistantEvent(inputs: AgentLoopInputs, text: strin
8
8
  * issue #48: when the reasoning duration was measured, carry it as `thinking_duration_ms`
9
9
  * so a `Run.stream()` replay can render how long the model reasoned.
10
10
  */
11
- export declare function buildThinkingEvent(inputs: AgentLoopInputs, text: string, thinkingDurationMs?: number): SDKThinkingMessage;
12
- export declare function buildAssistantTurn(text: string, toolCalls: LlmToolCallPart[]): LlmMessage;
11
+ export declare function buildThinkingEvent(inputs: AgentLoopInputs, text: string, thinkingDurationMs?: number, signature?: string): SDKThinkingMessage;
12
+ /**
13
+ * theokit#122 — `thinking` is FIRST, and that ordering is a provider requirement, not a preference.
14
+ *
15
+ * Anthropic verifies the signed block on the next request and requires it to lead the assistant
16
+ * message it belongs to. Omitting it (which this builder did until theokit#122's follow-up) makes
17
+ * round 2 of any thinking + tools run fail with `400 "thinking blocks cannot be modified"` — the
18
+ * exact failure the issue exists to remove. An unsigned block is passed through here and dropped at
19
+ * the wire by `thinkingToWireBlock`, which is where that policy belongs.
20
+ */
21
+ export declare function buildAssistantTurn(text: string, toolCalls: LlmToolCallPart[], thinking?: LlmThinkingPart): LlmMessage;
@@ -10,7 +10,7 @@
10
10
  * - "subscription_included" routes (Codex CLI, future Claude Pro) →
11
11
  * return $0 with status="included".
12
12
  * - Provider unknown / pricing missing → status="unknown" with
13
- * undefined amountUsd (NÃO retorna 0 falso).
13
+ * undefined amountUsd (does NOT return a false 0).
14
14
  *
15
15
  * @internal
16
16
  */
@@ -1,54 +1,69 @@
1
1
  /**
2
- * Canal único de diagnóstico da biblioteca silencioso por padrão (#147).
2
+ * The library's single diagnostics channelsilent by default (#147).
3
3
  *
4
4
  * ## O problema
5
5
  *
6
- * O SDK escrevia diagnósticos direto em `process.stderr` a partir de caminhos quentes
7
- * 92 sítios em 51 arquivos sob `internal/`. Numa host de TUI (Ink, alternate screen), essas
8
- * escritas se intercalam com o render e **corrompem o frame**. E o host não tinha como
9
- * interceptá-las: não havia logger injetável. Um consumidor chegou a instalar
10
- * `proper-lockfile` só para calar UMA delas.
6
+ * The SDK wrote diagnostics straight to `process.stderr` from hot paths 92 sites across 51
7
+ * files under `internal/`. In a TUI host (Ink, alternate screen), those writes interleave with the
8
+ * render and **corrupt the frame**. And the host had no way to intercept them: there was no
9
+ * injectable logger. One consumer went as far as installing `proper-lockfile` just to silence ONE
10
+ * of them.
11
11
  *
12
- * Uma biblioteca não pode assumir que `stdout`/`stderr` são sinks livres. Quem é dono do
13
- * terminal é a aplicação, não a dependência.
12
+ * A library cannot assume `stdout`/`stderr` are free sinks. The application owns the terminal, not
13
+ * the dependency.
14
14
  *
15
15
  * ## O contrato
16
16
  *
17
- * - **`setDiagnosticsSink(fn)`** entrega as mensagens à aplicação, que decide onde colocá-las
18
- * (uma linha de status, um arquivo, um painel). É o que faltava para uma TUI conviver com o SDK.
19
- * - **Sem sink, vai para o `stderr`** exatamente como antes desta mudança.
17
+ * - **`setDiagnosticsSink(fn)`** hands the messages to the application, which decides where to put
18
+ * them (a status line, a file, a panel). It is what was missing for a TUI to coexist with the SDK.
19
+ * - **With no sink, nothing is emitted.** A library does not own the host's terminal.
20
20
  *
21
- * ## Por que o padrão NÃO mudou (ainda), e isso é deliberado
21
+ * ## Silent by default, and how 36 suites survived the flip
22
22
  *
23
- * A #147 pede silêncio por padrão, e é o alvo certo. Mas **58 arquivos de teste** asseram hoje
24
- * que estes diagnósticos chegam ao `stderr` eles codificam o contrato "o aviso É emitido", que
25
- * continua valendo e não deve ser perdido. Virar o padrão sem migrá-los reprovaria ~53 testes, e
26
- * migrá-los às pressas, em quatro formas diferentes de espionar o `stderr`, é a receita para
27
- * enfraquecer 58 suítes de uma vez.
23
+ * The default WAS `stderr`, and 36 test files spy on `process.stderr.write` to assert a given
24
+ * warning is emitted. That contract is real and had to survive; migrating all 36 by hand, across
25
+ * four different spy styles, is how you weaken 36 suites in one commit.
28
26
  *
29
- * Então esta mudança entrega a metade que DESTRAVA o consumidor o host de TUI agora consegue
30
- * interceptar, que era o bloqueio relatado ("no way to intercept these; no injectable logger") e
31
- * deixa a virada do padrão como migração própria, com custo medido. Um host que quer silêncio
32
- * hoje instala `setDiagnosticsSink(() => {})`.
27
+ * So the flip happened at the default, and `vitest.setup.ts` installs a sink that FORWARDS to
28
+ * `stderr` for the duration of every test. Those assertions still test what they always tested
29
+ * "this condition emits a diagnostic" through the channel a host would use, while production
30
+ * emits nothing unless asked.
33
31
  *
34
- * ## O que isto NÃO é
32
+ * The cost is stated rather than hidden: no test observes the production default by accident, so
33
+ * `tests/diagnostics-public-entry.test.ts` pins it explicitly by clearing the sink first.
35
34
  *
36
- * Não é um logger com níveis, formatação ou destinos múltiplos. É o mínimo que resolve o
37
- * bloqueio relatado; um logger completo aqui seria inventar requisito que ninguém pediu.
35
+ * ## Coverage is the whole guarantee
36
+ *
37
+ * The first sweep migrated the 92 sites under `internal/` and left `src/`'s own modules —
38
+ * `event-bus.ts`, `batch.ts`, `compaction.ts`, `internal/workflow/step-branch.ts`. A host could
39
+ * therefore install a sink and still have its frame corrupted by a batch run, which is the reported
40
+ * defect with a smaller blast radius. Those are routed here too, and
41
+ * `tests/lint/no-direct-terminal-write.test.ts` is what keeps the next hot path from
42
+ * reintroducing one. "Mostly interceptable" is not interceptable.
43
+ *
44
+ * The remaining direct writers are allowlisted there with a reason, and every one of them is a seam
45
+ * whose destination the CALLER already chooses (`opts.warn`, `opts.logger`, the Workflow logger).
46
+ *
47
+ * ## What this is NOT
48
+ *
49
+ * It is not a logger with levels, formatting or multiple destinations. It is the minimum that
50
+ * resolves the reported blocker; a full logger here would be inventing a requirement nobody asked
51
+ * for.
38
52
  */
39
- /** Recebe cada mensagem de diagnóstico já formatada, com o `\n` final. */
53
+ /** Receives each diagnostic message already formatted, with the trailing `\n`. */
40
54
  export type DiagnosticsSink = (message: string) => void;
41
55
  /**
42
- * Instala (ou remove, passando `undefined`) o destino dos diagnósticos.
56
+ * Installs (or removes, by passing `undefined`) the diagnostics destination.
43
57
  *
44
- * Quando sink, ele é o ÚNICO destinoo `stderr` não recebe cópia. Duplicar destinos
45
- * devolveria o problema à TUI que instalou o sink justamente para tirar as mensagens do terminal.
58
+ * When a sink is present it is the ONLY destination — `stderr` gets no copy. Duplicating
59
+ * destinations would hand the problem back to the TUI that installed the sink precisely to get the
60
+ * messages out of the terminal.
46
61
  */
47
62
  export declare function setDiagnosticsSink(next: DiagnosticsSink | undefined): void;
48
63
  /**
49
- * Emite uma mensagem de diagnóstico da biblioteca.
64
+ * Emits a library diagnostic message.
50
65
  *
51
- * Substitui `process.stderr.write` nos caminhos internos. Nunca lança: um sink defeituoso não
52
- * pode derrubar o run que ele apenas observa.
66
+ * Replaces `process.stderr.write` on internal paths. Never throws: a faulty sink must not
67
+ * must not take down the run it merely observes.
53
68
  */
54
69
  export declare function diag(message: string): void;
@@ -12,7 +12,7 @@
12
12
  * `"content_filtered"` for policy.)
13
13
  * 408 → `NetworkError` (`code: "timeout"`)
14
14
  * 5xx → `NetworkError` (`code: "server_error"` — covers 529
15
- * overloaded_error common em horário
15
+ * overloaded_error common at peak
16
16
  * de pico)
17
17
  * other → `UnknownAgentError` (`code: "unknown"`)
18
18
  *
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Singleton por realm, chaveado por `Symbol.for`.
3
3
  *
4
- * Existe porque um pacote pode ser carregado mais de uma vez no mesmo processo (duas cópias em
5
- * `node_modules`, ESM e CJS lado a lado, monorepo com versões distintas) — e `const x = new Map()`
6
- * a nível de módulo produz DUAS caches que não se enxergam. `Symbol.for` usa o registro global de
7
- * símbolos, que é do realm e não do módulo, então todas as cópias convergem para a mesma instância.
4
+ * It exists because a package can be loaded more than once in the same process (two copies in
5
+ * `node_modules`, ESM and CJS side by side, a monorepo with distinct versions) — and then a module-level
6
+ * `const x = new Map()` produces TWO caches that cannot see each other. `Symbol.for` uses the global
7
+ * symbol registry, which belongs to the realm and not the module, so every copy converges on one instance.
8
8
  *
9
- * Estava copiado verbatim em `providers/discovery.ts` e `providers/catalog-loader.ts`. Isso é
10
- * duplicação de CONHECIMENTO, não coincidência de forma: as duas cópias precisam concordar sobre o
11
- * mecanismo, e uma corrigida sem a outra produz exatamente o bug que a função existe para evitar.
9
+ * It was copied verbatim into `providers/discovery.ts` and `providers/catalog-loader.ts`. That is
10
+ * duplicated KNOWLEDGE, not a coincidence of shape: the two copies have to agree on the
11
+ * mechanism, and one fixed without the other produces exactly the bug the function exists to avoid.
12
12
  */
13
13
  export declare function globalSingleton<T>(key: string, create: () => T): T;
@@ -8,32 +8,32 @@ export interface JudgeContext {
8
8
  /** Caller-supplied tuning knobs for the judge call. */
9
9
  export interface JudgeOptions {
10
10
  /**
11
- * Judge model identifier. Quando ausente, DERIVA de {@link agentModel} — e cai no literal
12
- * `"openai/gpt-4o-mini"` se nem esse for informado.
11
+ * Judge model identifier. When absent, it DERIVES from {@link agentModel} — and only falls back to the literal
12
+ * `"openai/gpt-4o-mini"` when neither is provided.
13
13
  *
14
- * M80 — o default fixo era provider-cego: ele resolve em OpenRouter. Com chave Anthropic
15
- * 404, com bearer OAuth 401, e em ambos o goal queimava 3 turnos inteiros antes de falhar com
16
- * razão enganosa. O agent-builder contornava isso derivando por conta própria; o conhecimento
17
- * pertence aqui.
14
+ * M80 — the fixed default was provider-blind: it only resolves on OpenRouter. With an Anthropic key it gives
15
+ * 404, with an OAuth bearer it gives 401, and in both the goal burned 3 whole turns before failing with
16
+ * a misleading reason. The agent-builder already worked around this by deriving on its own; the knowledge
17
+ * belongs here.
18
18
  */
19
19
  judgeModel?: string;
20
20
  /**
21
- * M80 — o modelo do agente CONDUZIDO. É a base da derivação: um judge que roda no mesmo modelo do
22
- * chat funciona onde o chat funciona.
21
+ * M80 — the DRIVEN agent's model. It is the basis of the derivation: a judge running on the same model as the
22
+ * chat works wherever chat works.
23
23
  */
24
24
  agentModel?: string;
25
25
  /** Override env. Default `process.env.OPENROUTER_API_KEY` (EC-A). */
26
26
  apiKey?: string;
27
27
  }
28
28
  /**
29
- * M80 — a credencial ou o modelo do judge não servem: 401/404.
29
+ * M80 — the judge's credential or model does not work: 401/404.
30
30
  *
31
- * Falha RÁPIDA por design. `rules/error-handling.md § 2` separa recuperável de irrecuperável, e um
32
- * modelo inexistente não passa a existir no retry — dobrar isso em `{parseFailed: true}` fazia o loop
33
- * tentar três vezes e reportar "failed" por limite de falhas consecutivas, escondendo que a causa era
34
- * credencial. Falha lenta e opaca trocada por rápida e clara.
31
+ * Fails FAST by design. `rules/error-handling.md` § 2 separates recoverable from unrecoverable, and a
32
+ * nonexistent model does not start existing on retry — folding that into `{parseFailed: true}` made the loop
33
+ * try three times and report "failed" on a consecutive-failure limit, hiding that the cause was the
34
+ * credential. A slow, opaque failure traded for a fast, clear one.
35
35
  *
36
- * Falha de PARSE e erro de rede continuam dobrados: são recuperáveis, e o loop decide por falhas
36
+ * PARSE failures and network errors stay folded: they are recoverable, and the loop already decides on
37
37
  * consecutivas.
38
38
  */
39
39
  export declare class JudgeCredentialError extends TheokitAgentError {
@@ -25,10 +25,6 @@ export interface AnthropicResponseLike {
25
25
  export declare function extractAnthropicText(response: AnthropicResponseLike): string;
26
26
  export declare function extractAnthropicToolCalls(response: AnthropicResponseLike): LlmToolCallPart[];
27
27
  export declare function mapAnthropicStopReason(reason: string | null): LlmStopReason;
28
- /**
29
- * Convert an SDK `LlmMessage` to the Anthropic Messages wire shape.
30
- * Identical across the three Anthropic-compatible clients (D289/D292).
31
- */
32
28
  export declare function toAnthropicWireMessage(message: LlmMessage): Record<string, unknown>;
33
29
  /**
34
30
  * Build the common body shape for Anthropic Messages requests. Caller
@@ -93,4 +89,8 @@ export declare function buildAnthropicCommonBody(request: LlmRequest): {
93
89
  description: string;
94
90
  input_schema: unknown;
95
91
  }>;
92
+ thinking?: {
93
+ type: "enabled";
94
+ budget_tokens: number;
95
+ };
96
96
  };
@@ -1,40 +1,40 @@
1
1
  import type { LlmClient, LlmEvent, LlmFinish, LlmRequest } from "./types.js";
2
- /** Teto de tentativas. Fixo em 3 — o DoD do M93 nomeia o número. */
3
- export declare const MAX_TENTATIVAS = 3;
2
+ /** Attempt ceiling. Fixed at 3 — M93's DoD names the number. */
3
+ export declare const MAX_ATTEMPTS = 3;
4
4
  /**
5
- * O erro é transitório, isto é: reexecutar pode mudar o resultado?
5
+ * Is the error transient that is, can retrying change the outcome?
6
6
  *
7
- * ## Delega para `isTransientError`, e diz o que subtrai
7
+ * ## Delegates to `isTransientError`, and states what it subtracts
8
8
  *
9
- * O SDK **já** publica `isTransientError` — documentado como "a single source of truth rather than
10
- * a re-derivation", e com o aviso explícito de que "It never inspects `err.message`". A primeira
11
- * versão desta função ignorou as duas coisas: derivou de novo, por regex sobre a mensagem
12
- * (`/\b4\d\d\b/`). A revisão adversarial mediu o custo — `connect ECONNREFUSED 127.0.0.1:443`
13
- * era classificado como NÃO transitório, porque a **porta** casa a regex. Os erros de rede para os
14
- * quais o retry existe eram exatamente os excluídos.
9
+ * The SDK **already** publishes `isTransientError` — documented as "a single source of truth rather
10
+ * than a re-derivation", with the explicit warning that "It never inspects `err.message`". The first
11
+ * version of this function ignored both: it re-derived, by regex over the message (`/\b4\d\d\b/`).
12
+ * Adversarial review measured the cost — `connect ECONNREFUSED 127.0.0.1:443` was classified as NOT
13
+ * transient, because the **port** matches the regex. The network errors retry exists for were
14
+ * exactly the ones excluded.
15
15
  *
16
- * Reinventar aqui foi violação da rung 4 da parcimônia com a peça pronta à mão. O que sobra desta
17
- * função são **três subtrações** do veredito do dono, cada uma com razão:
16
+ * Reinventing here violated parsimony rung 4 with the part already at hand. What remains of this
17
+ * function are **three subtractions** from the owner's verdict, each with a reason:
18
18
  *
19
- * | Subtração | Por quê |
19
+ * | Subtraction | Why |
20
20
  * |---|---|
21
- * | `CredentialPoolExhaustedError` | o pool gastou o próprio orçamento de tentativas e rotação; o `nextRetryAt` está em dezenas de segundos. Reexecutar multiplicaria a espera por `MAX_TENTATIVAS` sem chance de sucesso. |
22
- * | `code === "circuit_open"` | o breaker existe **para** falhar rápido; envolvê-lo num retry desfaz de fora a decisão que ele acabou de tomar. |
23
- * | `RateLimitError` com 402 | cota de faturamento não se resolve em milissegundosé por isso que o `classifyAndDecide` do pool rotaciona em vez de esperar. |
21
+ * | `CredentialPoolExhaustedError` | the pool already spent its own attempt and rotation budget; `nextRetryAt` is tens of seconds out. Retrying would multiply the wait by `MAX_ATTEMPTS` with no chance of success. |
22
+ * | `code === "circuit_open"` | the breaker exists **in order to** fail fast; wrapping it in a retry undoes from outside the decision it just made. |
23
+ * | `RateLimitError` with 402 | a billing quota does not resolve in millisecondswhich is why the pool's `classifyAndDecide` rotates instead of waiting. |
24
24
  *
25
- * As duas primeiras vieram da medição da revisão: com elas transitórias, o pool inteiro era
26
- * reexecutado 3×, e uma espera de 30 s virava ~90 s.
25
+ * The first two came out of the review's measurements: with them treated as transient, the entire
26
+ * pool was retried 3x, and a 30 s wait became ~90 s.
27
27
  */
28
- export declare function ehTransitorio(err: unknown): boolean;
28
+ export declare function isRetriableError(err: unknown): boolean;
29
29
  /**
30
- * ## Por que NÃO circuit breaker aqui
30
+ * ## Why there is NO circuit breaker here
31
31
  *
32
- * O `CircuitBreaker` do pacote é **chaveado por credencial** (`recordSuccess(key)` /
33
- * `recordTimeout(key)`): existe para o pool marcar uma chave como insalubre e **pular** para outra. Com
34
- * uma chave não para onde pular, então um breaker aqui registraria estado que ninguém consulta.
32
+ * The package's `CircuitBreaker` is **keyed by credential** (`recordSuccess(key)` /
33
+ * `recordTimeout(key)`): it exists so the pool can mark a key unhealthy and **skip** to another.
34
+ * With a single key there is nowhere to skip to, so a breaker here would record state nobody reads.
35
35
  *
36
- * Rung 1 da parcimônia — "isto precisa existir?". Não: seria cerimônia com nome de resiliência. O que
37
- * protege o caminho de chave única é o teto de tentativas e o backoff, e os dois estão abaixo.
36
+ * Parsimony rung 1 — "does this need to exist?". No: it would be ceremony with resilience's name on
37
+ * it. What protects the single-key path is the attempt ceiling and the backoff, and both are below.
38
38
  */
39
39
  export declare class RetryingLlmClient implements LlmClient {
40
40
  #private;
@@ -42,10 +42,10 @@ export declare class RetryingLlmClient implements LlmClient {
42
42
  rng?: () => number;
43
43
  });
44
44
  /**
45
- * O cliente decorado. Público pela mesma convenção de `FaultInjectingLlmClient.inner`: os testes
46
- * de fiação do router afirmam `instanceof PoolAwareLlmClient` e precisam enxergar através dos
47
- * decorators. Sem isto, adicionar um decorator quebra testes cuja intenção continua válidaque
48
- * foi exatamente o que o M93 fez com 4 testes pré-existentes.
45
+ * The decorated client. Public by the same convention as `FaultInjectingLlmClient.inner`: the
46
+ * router's wiring tests assert `instanceof PoolAwareLlmClient` and need to see through the
47
+ * decorators. Without this, adding a decorator breaks tests whose intent is still valid which is
48
+ * exactly what M93 did to 4 pre-existing tests.
49
49
  */
50
50
  get inner(): LlmClient;
51
51
  get name(): string;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Envolve uma falha de socket num {@link NetworkError}, preservando a causa.
2
+ * Wraps a socket failure in a {@link NetworkError}, preserving the cause.
3
3
  *
4
- * Devolve o erro original — sem envolver quando ele é um abort ou é um erro do SDK.
4
+ * Returns the original error unwrappedwhen it is an abort or already an SDK error.
5
5
  */
6
6
  export declare function wrapTransportError(err: unknown, ctx: {
7
7
  providerId: string;
@@ -43,7 +43,24 @@ export interface LlmImagePart {
43
43
  url: string;
44
44
  };
45
45
  }
46
- export type LlmContentPart = LlmTextPart | LlmToolCallPart | LlmToolResultPart | LlmImagePart;
46
+ /**
47
+ * theokit#122 — an extended-thinking block, carried WITH its provider-issued signature.
48
+ *
49
+ * The signature is the whole reason this part exists. Anthropic requires a resumed conversation to
50
+ * replay each `thinking` block byte-identically, signature included; replaying the text alone is
51
+ * rejected with `400 "thinking blocks cannot be modified"` (anthropics/claude-code#63147). So a
52
+ * session that used extended thinking could be persisted but never resumed.
53
+ *
54
+ * `signature` is optional because not every provider issues one — the OpenAI-compatible reasoning
55
+ * channel streams `reasoning`/`reasoning_content` text with no signature at all. A part without a
56
+ * signature is display-only history; it must not be replayed to Anthropic as a thinking block.
57
+ */
58
+ export interface LlmThinkingPart {
59
+ type: "thinking";
60
+ text: string;
61
+ signature?: string;
62
+ }
63
+ export type LlmContentPart = LlmTextPart | LlmToolCallPart | LlmToolResultPart | LlmImagePart | LlmThinkingPart;
47
64
  export interface LlmMessage {
48
65
  role: "system" | "user" | "assistant";
49
66
  content: LlmContentPart[];
@@ -122,20 +139,36 @@ export interface LlmRequest {
122
139
  */
123
140
  toolChoice?: "auto" | "none" | "required";
124
141
  }
142
+ /**
143
+ * What a provider stream reports WHILE it is running. Tool calls are deliberately absent.
144
+ *
145
+ * theokit#144: this union used to declare `tool_use` and `stop` variants. Only two providers ever
146
+ * yielded them (`responses.ts`, `fault-injection.ts`), the loop's collector
147
+ * (`loop-llm-stream.ts`) never read them, and the tool calls they carried were duplicates of what
148
+ * `LlmFinish.toolCalls` already returned. So they were not a live tool channel — they were a
149
+ * declaration of one, which is worse: it told implementers a provider-level channel existed and
150
+ * cost `@theokit/agents` a workaround (holding every `text_delta` until the stream drained, which
151
+ * broke live token streaming on text-only turns — issue #47).
152
+ *
153
+ * Wiring them instead of deleting them was rejected: `openai.ts` and `anthropic.ts` cannot produce
154
+ * them at all (their tool calls only resolve at completion), so a live provider-level channel would
155
+ * exist on some providers and not others — a worse contract than a uniform one.
156
+ *
157
+ * **The canonical live tool channel is `onDelta`**: `tool-call-started` / `tool-call-completed`
158
+ * `InteractionUpdate`s, emitted by `runToolWithLifecycle` (`agent-loop/tool-dispatch.ts`) between
159
+ * LLM rounds. It is uniform across providers, carries a `callId` correlating the two ends, and
160
+ * fires before the post-tool answer text. `Run.events()` (theokit#140) merges it with the
161
+ * structural `SDKMessage`s into one ordered timeline.
162
+ *
163
+ * The stop reason is not an event either — it is returned once, on `LlmFinish.stopReason`.
164
+ */
125
165
  export type LlmEvent = {
126
166
  type: "text_delta";
127
167
  text: string;
128
168
  } | {
129
169
  type: "reasoning_delta";
130
170
  text: string;
131
- } | {
132
- type: "tool_use";
133
- id: string;
134
- name: string;
135
- input: Record<string, unknown>;
136
- } | {
137
- type: "stop";
138
- reason: LlmStopReason;
171
+ signature?: string;
139
172
  } | {
140
173
  type: "error";
141
174
  message: string;
@@ -153,6 +186,13 @@ export interface LlmFinish {
153
186
  cacheWriteTokens?: number;
154
187
  /** Reasoning tokens (OpenAI o-series). ADR D376. */
155
188
  reasoningTokens?: number;
189
+ /**
190
+ * theokit#122 — the turn's extended-thinking block, with the provider's signature when it issued
191
+ * one. Returned on the finish value rather than reconstructed from the `reasoning_delta` text,
192
+ * because the signature arrives once for the whole block and only the provider adapter knows
193
+ * which block it belongs to.
194
+ */
195
+ thinking?: LlmThinkingPart;
156
196
  }
157
197
  export interface LlmClient {
158
198
  readonly name: string;
@@ -3,9 +3,13 @@
3
3
  *
4
4
  * `buildMcpMap` (`real-local-run.ts`) builds a fresh `McpClient` on every run, so each `send` pays
5
5
  * spawn + handshake again: 193 / 138 / 134 ms per turn, measured. The reference anchors this at the
6
- * session — Codex keeps its `McpConnectionManager` in `SessionServices`
7
- * (`core/src/state/service.rs:116`), next to a field commented *"Session-scoped model client shared
8
- * across turns"*, and REPLACES the runtime rather than rebuilding it.
6
+ * session — Codex keeps its `mcp_runtime: Arc<McpRuntime>` in `SessionServices`
7
+ * (`codex-rs/core/src/state/service.rs:51-58`), next to a field commented *"Session-scoped model
8
+ * client shared across turns"*, and REPLACES the runtime rather than rebuilding it.
9
+ *
10
+ * theokit#155: pooling the client OBJECT was never enough — the turn also has to stop closing what
11
+ * it does not own. See `runOwnsMcpClients` (`real-local-run.ts`) and the idempotent
12
+ * `StdioMcpClient.initialize()`.
9
13
  *
10
14
  * Generic over the client type on purpose: this file knows about keys, reuse and idleness, and
11
15
  * nothing about MCP. That keeps it unit-testable without spawning a server, and keeps `McpClient`'s