@theokit/sdk 4.63.4 → 5.0.0-next.2

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 (786) hide show
  1. package/CHANGELOG.md +847 -23
  2. package/dist/a2a/index.cjs +29 -13
  3. package/dist/a2a/index.cjs.map +1 -1
  4. package/dist/a2a/index.d.cts +1 -1
  5. package/dist/a2a/index.d.ts +1 -1
  6. package/dist/a2a/index.js +26 -11
  7. package/dist/a2a/index.js.map +1 -1
  8. package/dist/a2a/message-bus.d.cts +26 -3
  9. package/dist/a2a/message-bus.d.ts +26 -3
  10. package/dist/a2a/subagent.d.cts +8 -3
  11. package/dist/a2a/subagent.d.ts +8 -3
  12. package/dist/{agent-X0DKA943.d.cts → agent-C3KO5LKm.d.cts} +251 -36
  13. package/dist/{agent-BFno7Sfn.d.ts → agent-CvmTR9uf.d.ts} +251 -36
  14. package/dist/agent-GPV2JWZG.cjs +67 -0
  15. package/dist/{agent-UX7WFI6B.cjs.map → agent-GPV2JWZG.cjs.map} +1 -1
  16. package/dist/agent-Y24I5JBM.js +58 -0
  17. package/dist/{agent-A5XMIVNP.js.map → agent-Y24I5JBM.js.map} +1 -1
  18. package/dist/agent-session-store-AFML3AXC.js +6 -0
  19. package/dist/{agent-session-store-OPGRB4XM.js.map → agent-session-store-AFML3AXC.js.map} +1 -1
  20. package/dist/agent-session-store-MTSIY3MH.cjs +23 -0
  21. package/dist/{agent-session-store-6EL5NPA4.cjs.map → agent-session-store-MTSIY3MH.cjs.map} +1 -1
  22. package/dist/agent.d.ts +1 -1
  23. package/dist/auth/index.cjs +33 -34
  24. package/dist/auth/index.cjs.map +1 -1
  25. package/dist/auth/index.d.cts +1 -1
  26. package/dist/auth/index.d.ts +1 -1
  27. package/dist/auth/index.js +6 -7
  28. package/dist/auth/index.js.map +1 -1
  29. package/dist/{batch-BXYTW2DP.cjs → batch-I6T6MXZO.cjs} +58 -40
  30. package/dist/batch-I6T6MXZO.cjs.map +1 -0
  31. package/dist/{batch-L4ZXS46M.js → batch-US4F6WPK.js} +42 -24
  32. package/dist/batch-US4F6WPK.js.map +1 -0
  33. package/dist/chunk-24MGQDK3.js +31 -0
  34. package/dist/chunk-24MGQDK3.js.map +1 -0
  35. package/dist/{chunk-UGT7GK7I.cjs → chunk-24SYBZPL.cjs} +36 -18
  36. package/dist/chunk-24SYBZPL.cjs.map +1 -0
  37. package/dist/{chunk-KYAJINUI.cjs → chunk-2HPNT6HH.cjs} +581 -401
  38. package/dist/chunk-2HPNT6HH.cjs.map +1 -0
  39. package/dist/{chunk-VLVVJLDH.cjs → chunk-2NE7DTOK.cjs} +234 -193
  40. package/dist/chunk-2NE7DTOK.cjs.map +1 -0
  41. package/dist/{chunk-N2U4AZGB.js → chunk-2WXHA33T.js} +3 -3
  42. package/dist/chunk-2WXHA33T.js.map +1 -0
  43. package/dist/chunk-2XC6KDJM.js +22 -0
  44. package/dist/chunk-2XC6KDJM.js.map +1 -0
  45. package/dist/{chunk-L3MTL4NA.js → chunk-2ZLVT7H3.js} +223 -182
  46. package/dist/chunk-2ZLVT7H3.js.map +1 -0
  47. package/dist/{chunk-2GUYQR5P.js → chunk-3JHIFQ4I.js} +39 -13
  48. package/dist/chunk-3JHIFQ4I.js.map +1 -0
  49. package/dist/{chunk-BU4KFWXF.js → chunk-44I6UYVH.js} +8 -17
  50. package/dist/chunk-44I6UYVH.js.map +1 -0
  51. package/dist/{chunk-UNYXQ4M5.js → chunk-47TF32NQ.js} +10 -5
  52. package/dist/chunk-47TF32NQ.js.map +1 -0
  53. package/dist/{chunk-WNO3C3N2.cjs → chunk-4A3SKJ53.cjs} +56 -27
  54. package/dist/chunk-4A3SKJ53.cjs.map +1 -0
  55. package/dist/{chunk-YML4ME27.cjs → chunk-4HS6FFGL.cjs} +55 -46
  56. package/dist/chunk-4HS6FFGL.cjs.map +1 -0
  57. package/dist/{chunk-C72AZW7J.js → chunk-4MMWFSCD.js} +4 -4
  58. package/dist/chunk-4MMWFSCD.js.map +1 -0
  59. package/dist/{chunk-6HKGLTJI.cjs → chunk-4NLCWGH7.cjs} +15 -15
  60. package/dist/chunk-4NLCWGH7.cjs.map +1 -0
  61. package/dist/{chunk-LKBEROHN.js → chunk-4S5TWFIZ.js} +14 -14
  62. package/dist/chunk-4S5TWFIZ.js.map +1 -0
  63. package/dist/{chunk-UBDMVMBZ.js → chunk-55GB6JYQ.js} +33 -22
  64. package/dist/chunk-55GB6JYQ.js.map +1 -0
  65. package/dist/{chunk-U6IFHFWK.js → chunk-5WKQDIGO.js} +8 -17
  66. package/dist/chunk-5WKQDIGO.js.map +1 -0
  67. package/dist/chunk-67ADYSTW.js +120 -0
  68. package/dist/chunk-67ADYSTW.js.map +1 -0
  69. package/dist/{chunk-XL7Q7HB2.cjs → chunk-6LHQPOMI.cjs} +39 -6
  70. package/dist/chunk-6LHQPOMI.cjs.map +1 -0
  71. package/dist/{chunk-A4JVILQU.js → chunk-6M2OIS4Y.js} +7 -7
  72. package/dist/chunk-6M2OIS4Y.js.map +1 -0
  73. package/dist/{chunk-LWGSI6M3.js → chunk-6PWOWXMC.js} +4 -4
  74. package/dist/{chunk-LWGSI6M3.js.map → chunk-6PWOWXMC.js.map} +1 -1
  75. package/dist/{chunk-RNB4APBZ.js → chunk-6WAKKTBO.js} +9 -5
  76. package/dist/chunk-6WAKKTBO.js.map +1 -0
  77. package/dist/{chunk-V2BOS4WF.cjs → chunk-7A6535RA.cjs} +11 -11
  78. package/dist/chunk-7A6535RA.cjs.map +1 -0
  79. package/dist/{chunk-ZLQSWSJ2.cjs → chunk-7FDKWDA2.cjs} +11 -11
  80. package/dist/{chunk-ZLQSWSJ2.cjs.map → chunk-7FDKWDA2.cjs.map} +1 -1
  81. package/dist/{chunk-4VPXM6UU.js → chunk-7I5Z3UBJ.js} +3 -3
  82. package/dist/{chunk-4VPXM6UU.js.map → chunk-7I5Z3UBJ.js.map} +1 -1
  83. package/dist/{chunk-B4EOJWOY.cjs → chunk-7JJ3A6AT.cjs} +13 -7
  84. package/dist/chunk-7JJ3A6AT.cjs.map +1 -0
  85. package/dist/{chunk-WJVHMTKB.cjs → chunk-AA27GEYS.cjs} +3 -3
  86. package/dist/{chunk-WJVHMTKB.cjs.map → chunk-AA27GEYS.cjs.map} +1 -1
  87. package/dist/{chunk-BP46RJ5X.js → chunk-AAEZSPTC.js} +5 -5
  88. package/dist/{chunk-BP46RJ5X.js.map → chunk-AAEZSPTC.js.map} +1 -1
  89. package/dist/chunk-AGACYRJ2.js +11 -0
  90. package/dist/chunk-AGACYRJ2.js.map +1 -0
  91. package/dist/{chunk-ZZMZWBR6.js → chunk-ALUN2B4W.js} +81 -58
  92. package/dist/chunk-ALUN2B4W.js.map +1 -0
  93. package/dist/chunk-ANMJJD6D.cjs +18 -0
  94. package/dist/chunk-ANMJJD6D.cjs.map +1 -0
  95. package/dist/{chunk-DXGZ2NUG.cjs → chunk-ATT276RD.cjs} +12 -11
  96. package/dist/chunk-ATT276RD.cjs.map +1 -0
  97. package/dist/{chunk-4FFBAUFS.js → chunk-AWINL3ZC.js} +6 -6
  98. package/dist/chunk-AWINL3ZC.js.map +1 -0
  99. package/dist/{chunk-UU36SHFY.cjs → chunk-BJUJT5ED.cjs} +9 -8
  100. package/dist/chunk-BJUJT5ED.cjs.map +1 -0
  101. package/dist/{chunk-D4CUGAKZ.js → chunk-CZJ6Q7CW.js} +36 -6
  102. package/dist/chunk-CZJ6Q7CW.js.map +1 -0
  103. package/dist/{chunk-KQ7TS7WW.cjs → chunk-D6POWE7E.cjs} +37 -26
  104. package/dist/chunk-D6POWE7E.cjs.map +1 -0
  105. package/dist/{chunk-AWO27VRZ.js → chunk-DMRT67Y6.js} +6 -5
  106. package/dist/chunk-DMRT67Y6.js.map +1 -0
  107. package/dist/{chunk-5VB22SYX.cjs → chunk-DQZU7JK6.cjs} +7 -7
  108. package/dist/{chunk-5VB22SYX.cjs.map → chunk-DQZU7JK6.cjs.map} +1 -1
  109. package/dist/{chunk-3NSS2OIZ.cjs → chunk-DRL7URI4.cjs} +6 -6
  110. package/dist/{chunk-3NSS2OIZ.cjs.map → chunk-DRL7URI4.cjs.map} +1 -1
  111. package/dist/{chunk-RFXWMRFC.js → chunk-EFMFILPG.js} +14 -6
  112. package/dist/chunk-EFMFILPG.js.map +1 -0
  113. package/dist/{chunk-HS7AVXTF.js → chunk-EH6XD3FY.js} +4 -4
  114. package/dist/chunk-EH6XD3FY.js.map +1 -0
  115. package/dist/{chunk-KQRW2GPZ.js → chunk-EIQFAOFD.js} +6 -6
  116. package/dist/chunk-EIQFAOFD.js.map +1 -0
  117. package/dist/{chunk-XJCXEKMD.cjs → chunk-EXTRW7GW.cjs} +4 -4
  118. package/dist/chunk-EXTRW7GW.cjs.map +1 -0
  119. package/dist/{chunk-U54XCYG3.js → chunk-FJWQP6EE.js} +12 -6
  120. package/dist/chunk-FJWQP6EE.js.map +1 -0
  121. package/dist/{chunk-O7DK5PBJ.cjs → chunk-FUSDYC2B.cjs} +26 -42
  122. package/dist/chunk-FUSDYC2B.cjs.map +1 -0
  123. package/dist/{chunk-4QZSA2HJ.js → chunk-G7BLGBRN.js} +4 -4
  124. package/dist/chunk-G7BLGBRN.js.map +1 -0
  125. package/dist/{chunk-BZRFXJHA.js → chunk-GBCVPKHE.js} +55 -26
  126. package/dist/chunk-GBCVPKHE.js.map +1 -0
  127. package/dist/chunk-GGZ5GPE3.cjs +130 -0
  128. package/dist/chunk-GGZ5GPE3.cjs.map +1 -0
  129. package/dist/{chunk-5HEG4CQH.cjs → chunk-GZV6AVRL.cjs} +8 -8
  130. package/dist/{chunk-5HEG4CQH.cjs.map → chunk-GZV6AVRL.cjs.map} +1 -1
  131. package/dist/{chunk-VCLBZAZU.cjs → chunk-H6YM3PV6.cjs} +17 -17
  132. package/dist/chunk-H6YM3PV6.cjs.map +1 -0
  133. package/dist/{chunk-RFMBZPOW.cjs → chunk-HCT4HPCL.cjs} +10 -10
  134. package/dist/chunk-HCT4HPCL.cjs.map +1 -0
  135. package/dist/{chunk-OSEG74VJ.js → chunk-HFEJE7AC.js} +52 -43
  136. package/dist/chunk-HFEJE7AC.js.map +1 -0
  137. package/dist/{chunk-52NKC5HT.cjs → chunk-HUFSABUZ.cjs} +12 -8
  138. package/dist/chunk-HUFSABUZ.cjs.map +1 -0
  139. package/dist/{chunk-4CLOXP6H.cjs → chunk-HW7SEELD.cjs} +4 -4
  140. package/dist/{chunk-4CLOXP6H.cjs.map → chunk-HW7SEELD.cjs.map} +1 -1
  141. package/dist/{chunk-ZSWPZ23K.cjs → chunk-I2PWY7VM.cjs} +5 -5
  142. package/dist/chunk-I2PWY7VM.cjs.map +1 -0
  143. package/dist/{chunk-VJ26EKGJ.cjs → chunk-IJ7M6GOG.cjs} +3 -3
  144. package/dist/chunk-IJ7M6GOG.cjs.map +1 -0
  145. package/dist/{chunk-SAVIWMZB.js → chunk-ILGZ2ZZV.js} +3 -3
  146. package/dist/chunk-ILGZ2ZZV.js.map +1 -0
  147. package/dist/{chunk-4ZHTIJNE.cjs → chunk-J7J7J2GN.cjs} +87 -63
  148. package/dist/chunk-J7J7J2GN.cjs.map +1 -0
  149. package/dist/{chunk-UALX2J2Q.cjs → chunk-JLRLCBJ4.cjs} +38 -11
  150. package/dist/chunk-JLRLCBJ4.cjs.map +1 -0
  151. package/dist/{chunk-2QDYBS2A.js → chunk-JMDDYA22.js} +4 -4
  152. package/dist/chunk-JMDDYA22.js.map +1 -0
  153. package/dist/{chunk-LXQ6HKPS.js → chunk-JNAA4G4H.js} +3 -3
  154. package/dist/{chunk-LXQ6HKPS.js.map → chunk-JNAA4G4H.js.map} +1 -1
  155. package/dist/{chunk-UMP6OJIM.js → chunk-JOFVLOFY.js} +4 -4
  156. package/dist/{chunk-UMP6OJIM.js.map → chunk-JOFVLOFY.js.map} +1 -1
  157. package/dist/{chunk-A46SWMIF.js → chunk-K2VMFZQ5.js} +7 -7
  158. package/dist/chunk-K2VMFZQ5.js.map +1 -0
  159. package/dist/{chunk-DN2PACRI.js → chunk-K3NH62DG.js} +461 -282
  160. package/dist/chunk-K3NH62DG.js.map +1 -0
  161. package/dist/{chunk-LYTOXSRH.js → chunk-KDR53EO7.js} +1939 -1864
  162. package/dist/chunk-KDR53EO7.js.map +1 -0
  163. package/dist/{chunk-XWTLIGO3.cjs → chunk-KTTHHYEW.cjs} +5 -5
  164. package/dist/chunk-KTTHHYEW.cjs.map +1 -0
  165. package/dist/{chunk-3FFAEAUJ.cjs → chunk-KVSAY6NZ.cjs} +18 -18
  166. package/dist/chunk-KVSAY6NZ.cjs.map +1 -0
  167. package/dist/{chunk-IAHZCGBE.cjs → chunk-LHSWHYF3.cjs} +120 -146
  168. package/dist/chunk-LHSWHYF3.cjs.map +1 -0
  169. package/dist/{chunk-3OR54XG4.js → chunk-NJWYQWDL.js} +12 -8
  170. package/dist/chunk-NJWYQWDL.js.map +1 -0
  171. package/dist/chunk-NVXXWAU7.cjs +13 -0
  172. package/dist/chunk-NVXXWAU7.cjs.map +1 -0
  173. package/dist/{chunk-2D34UTDC.js → chunk-O6USDERH.js} +31 -11
  174. package/dist/chunk-O6USDERH.js.map +1 -0
  175. package/dist/{chunk-XO4SOZN6.js → chunk-OR6XIWLB.js} +4 -4
  176. package/dist/{chunk-XO4SOZN6.js.map → chunk-OR6XIWLB.js.map} +1 -1
  177. package/dist/{chunk-4PYZ5AX3.cjs → chunk-PRZ3BES7.cjs} +16 -8
  178. package/dist/chunk-PRZ3BES7.cjs.map +1 -0
  179. package/dist/{chunk-HCZD23VS.cjs → chunk-QC55H6RJ.cjs} +65 -39
  180. package/dist/chunk-QC55H6RJ.cjs.map +1 -0
  181. package/dist/{chunk-4O5TGQBW.cjs → chunk-QME6FDFG.cjs} +9 -5
  182. package/dist/chunk-QME6FDFG.cjs.map +1 -0
  183. package/dist/chunk-QOGNZMHD.cjs +34 -0
  184. package/dist/chunk-QOGNZMHD.cjs.map +1 -0
  185. package/dist/{chunk-7VT4P3Z4.cjs → chunk-QUAEOKDW.cjs} +1642 -1567
  186. package/dist/chunk-QUAEOKDW.cjs.map +1 -0
  187. package/dist/{chunk-B2J4ZMZL.cjs → chunk-QWD3CZWE.cjs} +6 -5
  188. package/dist/chunk-QWD3CZWE.cjs.map +1 -0
  189. package/dist/{chunk-SZVR77EJ.cjs → chunk-QWD4RDZ3.cjs} +15 -24
  190. package/dist/chunk-QWD4RDZ3.cjs.map +1 -0
  191. package/dist/{chunk-7BG5UH3T.cjs → chunk-RHZ6HP23.cjs} +4 -4
  192. package/dist/chunk-RHZ6HP23.cjs.map +1 -0
  193. package/dist/{chunk-2HVF2WJY.cjs → chunk-RQMCOFAI.cjs} +8 -8
  194. package/dist/{chunk-2HVF2WJY.cjs.map → chunk-RQMCOFAI.cjs.map} +1 -1
  195. package/dist/{chunk-VKJ7V7EB.cjs → chunk-SA6K24NB.cjs} +3 -3
  196. package/dist/chunk-SA6K24NB.cjs.map +1 -0
  197. package/dist/{chunk-7AD3ZTZL.js → chunk-SAGRF4IB.js} +3 -3
  198. package/dist/chunk-SAGRF4IB.js.map +1 -0
  199. package/dist/{chunk-PUAEFLYK.js → chunk-SVQIW5RJ.js} +4 -4
  200. package/dist/{chunk-PUAEFLYK.js.map → chunk-SVQIW5RJ.js.map} +1 -1
  201. package/dist/{chunk-43ZQRWAP.cjs → chunk-SYVWE64W.cjs} +22 -22
  202. package/dist/chunk-SYVWE64W.cjs.map +1 -0
  203. package/dist/{chunk-3O42QOMJ.js → chunk-TA3K7SBK.js} +7 -6
  204. package/dist/chunk-TA3K7SBK.js.map +1 -0
  205. package/dist/{chunk-LYRDF5TQ.cjs → chunk-TFG5IBZS.cjs} +14 -23
  206. package/dist/chunk-TFG5IBZS.cjs.map +1 -0
  207. package/dist/{chunk-GKEFRLU7.cjs → chunk-TMKTSYDS.cjs} +6 -6
  208. package/dist/{chunk-GKEFRLU7.cjs.map → chunk-TMKTSYDS.cjs.map} +1 -1
  209. package/dist/{chunk-J24VJOH3.cjs → chunk-UADQJBHR.cjs} +31 -11
  210. package/dist/chunk-UADQJBHR.cjs.map +1 -0
  211. package/dist/{chunk-TAZVKYWJ.js → chunk-UBR5PWD7.js} +26 -40
  212. package/dist/chunk-UBR5PWD7.js.map +1 -0
  213. package/dist/{chunk-IPYYKCRC.js → chunk-UFPUHJWS.js} +5 -5
  214. package/dist/{chunk-IPYYKCRC.js.map → chunk-UFPUHJWS.js.map} +1 -1
  215. package/dist/{chunk-OHLDPWTA.cjs → chunk-UGRS7ZA7.cjs} +15 -15
  216. package/dist/{chunk-OHLDPWTA.cjs.map → chunk-UGRS7ZA7.cjs.map} +1 -1
  217. package/dist/{chunk-RIAM53CP.js → chunk-UKMBRMGT.js} +3 -3
  218. package/dist/chunk-UKMBRMGT.js.map +1 -0
  219. package/dist/{chunk-L4BDVXIM.js → chunk-UNK4HNJH.js} +97 -123
  220. package/dist/chunk-UNK4HNJH.js.map +1 -0
  221. package/dist/{chunk-C3NT3PVE.js → chunk-V22DZIXO.js} +3 -3
  222. package/dist/chunk-V22DZIXO.js.map +1 -0
  223. package/dist/{chunk-OFRFZRQ4.cjs → chunk-V6ZY4AX6.cjs} +24 -14
  224. package/dist/chunk-V6ZY4AX6.cjs.map +1 -0
  225. package/dist/{chunk-B3IMEBOA.js → chunk-VE6DFSKU.js} +3 -3
  226. package/dist/{chunk-B3IMEBOA.js.map → chunk-VE6DFSKU.js.map} +1 -1
  227. package/dist/{chunk-WLQNMXQE.js → chunk-VWUXIVEI.js} +53 -26
  228. package/dist/chunk-VWUXIVEI.js.map +1 -0
  229. package/dist/{chunk-GMLBYDW4.cjs → chunk-VXDEKILY.cjs} +108 -109
  230. package/dist/chunk-VXDEKILY.cjs.map +1 -0
  231. package/dist/{chunk-ACDLHN3W.js → chunk-WJXOICRC.js} +16 -6
  232. package/dist/chunk-WJXOICRC.js.map +1 -0
  233. package/dist/{chunk-7YGCPMGB.js → chunk-XB4GI5RZ.js} +27 -12
  234. package/dist/chunk-XB4GI5RZ.js.map +1 -0
  235. package/dist/{chunk-O73J46PV.js → chunk-XDANGA2C.js} +5 -5
  236. package/dist/{chunk-O73J46PV.js.map → chunk-XDANGA2C.js.map} +1 -1
  237. package/dist/{chunk-NDGGJQTZ.js → chunk-XJZEBGXD.js} +10 -10
  238. package/dist/chunk-XJZEBGXD.js.map +1 -0
  239. package/dist/{chunk-UTSRIDKZ.js → chunk-XYFGKVZ7.js} +3 -3
  240. package/dist/chunk-XYFGKVZ7.js.map +1 -0
  241. package/dist/{chunk-RMWTPV3M.cjs → chunk-Y2KYR2ED.cjs} +27 -27
  242. package/dist/chunk-Y2KYR2ED.cjs.map +1 -0
  243. package/dist/{chunk-O7LZFG6O.cjs → chunk-YIFFF23U.cjs} +5 -5
  244. package/dist/chunk-YIFFF23U.cjs.map +1 -0
  245. package/dist/{chunk-4OTIXDMU.cjs → chunk-YJNYDJ2T.cjs} +12 -4
  246. package/dist/chunk-YJNYDJ2T.cjs.map +1 -0
  247. package/dist/{chunk-6JSIEDKL.cjs → chunk-YSTXFWQE.cjs} +13 -7
  248. package/dist/chunk-YSTXFWQE.cjs.map +1 -0
  249. package/dist/{chunk-I6HGWHPU.cjs → chunk-Z3NTRKIC.cjs} +4 -4
  250. package/dist/{chunk-I6HGWHPU.cjs.map → chunk-Z3NTRKIC.cjs.map} +1 -1
  251. package/dist/{chunk-32WTYBUH.js → chunk-ZH26RNQA.js} +91 -92
  252. package/dist/chunk-ZH26RNQA.js.map +1 -0
  253. package/dist/compact-session-BHTPCIHA.cjs +61 -0
  254. package/dist/{compact-session-QV57KR66.cjs.map → compact-session-BHTPCIHA.cjs.map} +1 -1
  255. package/dist/compact-session-W4WLJTHA.js +24 -0
  256. package/dist/{compact-session-RIGOWC4Y.js.map → compact-session-W4WLJTHA.js.map} +1 -1
  257. package/dist/compaction.cjs +20 -17
  258. package/dist/compaction.d.cts +15 -1
  259. package/dist/compaction.d.ts +15 -1
  260. package/dist/compaction.js +3 -4
  261. package/dist/concurrency.cjs +6 -7
  262. package/dist/concurrency.cjs.map +1 -1
  263. package/dist/concurrency.d.cts +6 -3
  264. package/dist/concurrency.d.ts +6 -3
  265. package/dist/concurrency.js +4 -5
  266. package/dist/concurrency.js.map +1 -1
  267. package/dist/context/index.cjs +6 -6
  268. package/dist/context/index.js +3 -3
  269. package/dist/context-NI33FS2R.cjs +23 -0
  270. package/dist/{context-WFLTTMK3.cjs.map → context-NI33FS2R.cjs.map} +1 -1
  271. package/dist/context-Y7B7SI5X.js +6 -0
  272. package/dist/{context-WI2DFG7V.js.map → context-Y7B7SI5X.js.map} +1 -1
  273. package/dist/create-skill.d.ts +4 -1
  274. package/dist/{cron-BuiRPrvt.d.cts → cron-C3PhZED0.d.cts} +8 -2
  275. package/dist/{cron-C2SIi31n.d.ts → cron-crfMMdAw.d.ts} +8 -2
  276. package/dist/cron.cjs +46 -45
  277. package/dist/cron.d.cts +5 -4
  278. package/dist/cron.d.ts +5 -4
  279. package/dist/cron.js +45 -44
  280. package/dist/{errors-BgJH9PHi.d.cts → errors-CLOAyuiv.d.ts} +133 -95
  281. package/dist/{errors-C5fJUqLk.d.ts → errors-DrDEgyz1.d.cts} +133 -95
  282. package/dist/errors-base-B5g01neU.d.cts +75 -0
  283. package/dist/errors-base-B5g01neU.d.ts +75 -0
  284. package/dist/errors-base.d.ts +73 -0
  285. package/dist/errors.cjs +25 -22
  286. package/dist/errors.d.cts +3 -2
  287. package/dist/errors.d.ts +3 -2
  288. package/dist/errors.js +2 -3
  289. package/dist/eval.cjs +74 -78
  290. package/dist/eval.cjs.map +1 -1
  291. package/dist/eval.js +64 -68
  292. package/dist/eval.js.map +1 -1
  293. package/dist/{executor-6CYCA7MI.cjs → executor-XQAOQOHD.cjs} +60 -54
  294. package/dist/executor-XQAOQOHD.cjs.map +1 -0
  295. package/dist/{executor-QSEC3MRH.js → executor-ZNDQDX6Q.js} +43 -37
  296. package/dist/executor-ZNDQDX6Q.js.map +1 -0
  297. package/dist/filesystem/index.cjs +24 -26
  298. package/dist/filesystem/index.cjs.map +1 -1
  299. package/dist/filesystem/index.js +20 -22
  300. package/dist/filesystem/index.js.map +1 -1
  301. package/dist/filesystem/types.d.cts +11 -5
  302. package/dist/filesystem/types.d.ts +11 -5
  303. package/dist/{fork-agent-RSV4E3EA.js → fork-agent-S2EPIML7.js} +3 -3
  304. package/dist/fork-agent-S2EPIML7.js.map +1 -0
  305. package/dist/{fork-agent-Y2IK2RYU.cjs → fork-agent-WAEQI2DL.cjs} +4 -4
  306. package/dist/fork-agent-WAEQI2DL.cjs.map +1 -0
  307. package/dist/fs-session-store-77JU46UZ.js +10 -0
  308. package/dist/{fs-session-store-NM6YSTE2.js.map → fs-session-store-77JU46UZ.js.map} +1 -1
  309. package/dist/fs-session-store-E4U3P56L.cjs +19 -0
  310. package/dist/{fs-session-store-4PIHT5UX.cjs.map → fs-session-store-E4U3P56L.cjs.map} +1 -1
  311. package/dist/generate-object-BXV7BZRP.js +7 -0
  312. package/dist/{generate-object-GUNAUVBX.js.map → generate-object-BXV7BZRP.js.map} +1 -1
  313. package/dist/generate-object-YBI2TDJ3.cjs +20 -0
  314. package/dist/{generate-object-R7HTMW7F.cjs.map → generate-object-YBI2TDJ3.cjs.map} +1 -1
  315. package/dist/generate-object.d.ts +2 -4
  316. package/dist/index-manager-DXR2RSFI.cjs +26 -0
  317. package/dist/{index-manager-2SRX45WJ.cjs.map → index-manager-DXR2RSFI.cjs.map} +1 -1
  318. package/dist/index-manager-QH6OXEV5.js +17 -0
  319. package/dist/{index-manager-SP4ISSDX.js.map → index-manager-QH6OXEV5.js.map} +1 -1
  320. package/dist/index.cjs +234 -194
  321. package/dist/index.cjs.map +1 -1
  322. package/dist/index.d.cts +243 -41
  323. package/dist/index.d.ts +243 -41
  324. package/dist/index.js +140 -102
  325. package/dist/index.js.map +1 -1
  326. package/dist/{inject-session-DAR7OUCW.js → inject-session-SUM6TDJF.js} +9 -9
  327. package/dist/{inject-session-DAR7OUCW.js.map → inject-session-SUM6TDJF.js.map} +1 -1
  328. package/dist/inject-session-W6A46J3E.cjs +29 -0
  329. package/dist/{inject-session-WQKMC3GR.cjs.map → inject-session-W6A46J3E.cjs.map} +1 -1
  330. package/dist/interactive/index.cjs +12 -6
  331. package/dist/interactive/index.cjs.map +1 -1
  332. package/dist/interactive/index.js +12 -6
  333. package/dist/interactive/index.js.map +1 -1
  334. package/dist/interactive/types.d.cts +14 -4
  335. package/dist/interactive/types.d.ts +14 -4
  336. package/dist/internal/agent-loop/loop-context-init.d.ts +1 -1
  337. package/dist/internal/agent-loop/loop-finalize.d.ts +25 -0
  338. package/dist/internal/agent-loop/loop.d.ts +1 -1
  339. package/dist/internal/agent-loop/message-builders.d.ts +1 -1
  340. package/dist/internal/agent-loop/tool-dispatch.d.ts +2 -2
  341. package/dist/internal/agent-loop/usage-and-cost.d.ts +1 -1
  342. package/dist/internal/auth/credential-availability.d.ts +61 -0
  343. package/dist/internal/auth/credential-store.d.ts +1 -1
  344. package/dist/internal/auth/oauth-device.d.ts +1 -1
  345. package/dist/internal/auth/oauth-engine.d.ts +1 -1
  346. package/dist/internal/auth/resolve-credential.d.ts +1 -1
  347. package/dist/internal/base-url.d.ts +14 -0
  348. package/dist/internal/cloud-agent/cloud-config-serializer.d.ts +1 -1
  349. package/dist/internal/{runtime/concurrency → concurrency}/subagent-credentials.d.ts +2 -2
  350. package/dist/internal/emit-run-event.d.ts +16 -0
  351. package/dist/internal/error-mappers/shared.d.ts +14 -1
  352. package/dist/internal/eval/assert.d.ts +2 -1
  353. package/dist/internal/eval/single-flight.d.ts +2 -1
  354. package/dist/internal/global-singleton.d.ts +6 -3
  355. package/dist/internal/llm/responses.d.ts +10 -0
  356. package/dist/internal/local-agent/local-agent-bootstrap.d.ts +5 -3
  357. package/dist/internal/local-agent/local-agent-capabilities.d.ts +38 -0
  358. package/dist/internal/local-agent/local-agent-dispatch.d.ts +2 -2
  359. package/dist/internal/local-agent/local-agent-memory-provider.d.ts +1 -1
  360. package/dist/internal/local-agent/local-agent-personality-extensions.d.ts +25 -1
  361. package/dist/internal/local-agent/local-agent-send.d.ts +42 -1
  362. package/dist/internal/local-agent/real-local-run-mcp.d.ts +26 -0
  363. package/dist/internal/local-agent/real-local-run-options.d.ts +26 -0
  364. package/dist/internal/local-agent/real-local-run-tools.d.ts +21 -4
  365. package/dist/internal/local-agent/real-local-run.d.ts +2 -2
  366. package/dist/internal/mcp/handshake-timeout.d.ts +53 -0
  367. package/dist/internal/memory/active-memory.d.ts +1 -1
  368. package/dist/internal/memory/adapters/index.cjs +10 -10
  369. package/dist/internal/memory/adapters/index.js +9 -9
  370. package/dist/internal/memory/adapters/openai-embedding.d.cts +10 -0
  371. package/dist/internal/memory/adapters/openai-embedding.d.ts +10 -0
  372. package/dist/internal/memory/corpus-sync.d.ts +23 -0
  373. package/dist/internal/memory/index-db.d.ts +15 -1
  374. package/dist/internal/memory/index-manager-contract.d.ts +12 -0
  375. package/dist/internal/memory/index-manager.d.ts +4 -10
  376. package/dist/internal/memory/index-repository.d.ts +58 -0
  377. package/dist/internal/memory/lance-memory-adapter.d.ts +16 -14
  378. package/dist/internal/memory/memory-index.d.ts +15 -0
  379. package/dist/internal/memory/sdk-memory-peer-loader.d.ts +54 -1
  380. package/dist/internal/memory/storage/index.cjs +39 -40
  381. package/dist/internal/memory/storage/index.js +10 -11
  382. package/dist/internal/memory/storage/memory-root.d.cts +2 -3
  383. package/dist/internal/memory/storage/memory-root.d.ts +2 -3
  384. package/dist/internal/persistence/atomic-write.d.cts +4 -4
  385. package/dist/internal/persistence/atomic-write.d.ts +4 -4
  386. package/dist/internal/persistence/index.cjs +24 -25
  387. package/dist/internal/persistence/index.cjs.map +1 -1
  388. package/dist/internal/persistence/index.js +7 -8
  389. package/dist/internal/persistence/index.js.map +1 -1
  390. package/dist/internal/persistence/jsonl.d.cts +3 -1
  391. package/dist/internal/persistence/jsonl.d.ts +3 -1
  392. package/dist/internal/persistence/paths.d.cts +25 -12
  393. package/dist/internal/persistence/paths.d.ts +25 -12
  394. package/dist/internal/persistence/transcript-ops.d.cts +11 -2
  395. package/dist/internal/persistence/transcript-ops.d.ts +11 -2
  396. package/dist/internal/plugins/context.d.cts +0 -10
  397. package/dist/internal/plugins/context.d.ts +0 -10
  398. package/dist/internal/plugins/types.d.cts +1 -1
  399. package/dist/internal/plugins/types.d.ts +1 -1
  400. package/dist/internal/providers/catalog-schema.d.ts +94 -0
  401. package/dist/internal/providers/catalog-source-models-dev.d.ts +11 -0
  402. package/dist/internal/runtime/compat/compat-config-file.d.ts +31 -0
  403. package/dist/internal/runtime/compat/foreign-config-sources.d.ts +58 -34
  404. package/dist/internal/runtime/compression/compression-model-registry.d.ts +1 -1
  405. package/dist/internal/runtime/compression/compression-summarizer.d.ts +5 -1
  406. package/dist/internal/runtime/fixtures/fixture-events.d.ts +1 -1
  407. package/dist/internal/runtime/fixtures/fixture-mode.d.ts +8 -14
  408. package/dist/internal/runtime/fixtures/fixture-run-base.d.ts +1 -1
  409. package/dist/internal/runtime/fixtures/fixture-scripts.d.ts +2 -2
  410. package/dist/internal/runtime/hooks/hooks-executor.d.ts +6 -1
  411. package/dist/internal/runtime/lifecycle/wrap-completion-check-run.d.ts +1 -1
  412. package/dist/internal/runtime/{memory → memory-glue}/memory-provider.d.ts +1 -1
  413. package/dist/internal/runtime/{plugins → plugin-loader}/plugin-bundles.d.ts +4 -1
  414. package/dist/internal/runtime/processors/wrap-output-run.d.ts +1 -1
  415. package/dist/internal/runtime/registry/live-agent-registry.d.ts +9 -1
  416. package/dist/internal/runtime/system-prompt/local-assembly.d.ts +2 -1
  417. package/dist/internal/scorers/llm-judge.d.ts +12 -0
  418. package/dist/internal/security/index.cjs +14 -15
  419. package/dist/internal/security/index.d.cts +6 -1
  420. package/dist/internal/security/index.d.ts +6 -1
  421. package/dist/internal/security/index.js +4 -5
  422. package/dist/internal/security/path-containment.d.ts +24 -0
  423. package/dist/internal/session/agent-session-store.d.ts +1 -1
  424. package/dist/internal/session/agent-session.d.ts +1 -1
  425. package/dist/internal/session/index.d.ts +1 -1
  426. package/dist/internal/session/session-cache.d.ts +9 -3
  427. package/dist/internal/task/registry.d.ts +1 -1
  428. package/dist/internal/task/store.d.ts +1 -1
  429. package/dist/internal/task/subscribe.d.ts +1 -1
  430. package/dist/internal/task/task-id.d.ts +22 -0
  431. package/dist/internal/telemetry/adapter-registry.d.ts +12 -2
  432. package/dist/internal/telemetry/adapters/braintrust.d.ts +6 -1
  433. package/dist/internal/telemetry/adapters/langsmith.d.ts +6 -1
  434. package/dist/internal/workflow/executor.d.ts +2 -1
  435. package/dist/internal/workflow/snapshot-store.d.ts +1 -1
  436. package/dist/internal/workflow/step-branch.d.ts +2 -2
  437. package/dist/internal/workflow/step-dowhile.d.ts +2 -2
  438. package/dist/internal/workflow/step-execution.d.ts +25 -0
  439. package/dist/internal/workflow/step-foreach.d.ts +2 -2
  440. package/dist/internal/workflow/step-parallel.d.ts +2 -2
  441. package/dist/judge-call-6MVARKU2.js +5 -0
  442. package/dist/{judge-call-LVXABPS3.js.map → judge-call-6MVARKU2.js.map} +1 -1
  443. package/dist/judge-call-I3P4D5QR.cjs +22 -0
  444. package/dist/{judge-call-LAHMBJ57.cjs.map → judge-call-I3P4D5QR.cjs.map} +1 -1
  445. package/dist/mcp-auth.cjs +14 -15
  446. package/dist/mcp-auth.cjs.map +1 -1
  447. package/dist/mcp-auth.d.cts +2 -0
  448. package/dist/mcp-auth.d.ts +2 -0
  449. package/dist/mcp-auth.js +4 -5
  450. package/dist/mcp-auth.js.map +1 -1
  451. package/dist/models.cjs +52 -42
  452. package/dist/models.cjs.map +1 -1
  453. package/dist/models.js +39 -29
  454. package/dist/models.js.map +1 -1
  455. package/dist/oauth-transaction-store-5RIR6D5C.js +5 -0
  456. package/dist/{oauth-transaction-store-W52KVHQ4.js.map → oauth-transaction-store-5RIR6D5C.js.map} +1 -1
  457. package/dist/oauth-transaction-store-SXIE57OD.cjs +38 -0
  458. package/dist/{oauth-transaction-store-BT4GLTLK.cjs.map → oauth-transaction-store-SXIE57OD.cjs.map} +1 -1
  459. package/dist/path-safety.cjs +11 -12
  460. package/dist/path-safety.d.cts +2 -0
  461. package/dist/path-safety.d.ts +2 -0
  462. package/dist/path-safety.js +4 -5
  463. package/dist/permission-engine.d.ts +10 -17
  464. package/dist/persistence.cjs +31 -31
  465. package/dist/persistence.cjs.map +1 -1
  466. package/dist/persistence.d.cts +9 -1
  467. package/dist/persistence.d.ts +9 -1
  468. package/dist/persistence.js +12 -13
  469. package/dist/persistence.js.map +1 -1
  470. package/dist/project.cjs +5 -6
  471. package/dist/project.cjs.map +1 -1
  472. package/dist/project.js +3 -4
  473. package/dist/project.js.map +1 -1
  474. package/dist/providers.cjs +10 -10
  475. package/dist/providers.d.cts +2 -0
  476. package/dist/providers.d.ts +2 -0
  477. package/dist/providers.js +8 -8
  478. package/dist/registry-BZQFYRTL.cjs +46 -0
  479. package/dist/{registry-V7BDQ6QB.cjs.map → registry-BZQFYRTL.cjs.map} +1 -1
  480. package/dist/registry-DMWCJKRF.js +9 -0
  481. package/dist/{registry-75W33OGL.js.map → registry-DMWCJKRF.js.map} +1 -1
  482. package/dist/retry.cjs +4 -5
  483. package/dist/retry.d.cts +20 -5
  484. package/dist/retry.d.ts +20 -5
  485. package/dist/retry.js +3 -4
  486. package/dist/{run-BYSHf58D.d.ts → run-CTAdRU3U.d.cts} +120 -152
  487. package/dist/{run-BYSHf58D.d.cts → run-CTAdRU3U.d.ts} +120 -152
  488. package/dist/{run-until-HEQOUVU6.js → run-until-6D6TQ4JN.js} +27 -59
  489. package/dist/run-until-6D6TQ4JN.js.map +1 -0
  490. package/dist/{run-until-U2B5FJJI.cjs → run-until-DG2KXWB2.cjs} +27 -59
  491. package/dist/run-until-DG2KXWB2.cjs.map +1 -0
  492. package/dist/sandbox/bwrap.d.cts +11 -1
  493. package/dist/sandbox/bwrap.d.ts +11 -1
  494. package/dist/sandbox/index.cjs +26 -30
  495. package/dist/sandbox/index.cjs.map +1 -1
  496. package/dist/sandbox/index.d.cts +8 -1
  497. package/dist/sandbox/index.d.ts +8 -1
  498. package/dist/sandbox/index.js +10 -14
  499. package/dist/sandbox/index.js.map +1 -1
  500. package/dist/sandbox/linux-sandbox.d.cts +20 -4
  501. package/dist/sandbox/linux-sandbox.d.ts +20 -4
  502. package/dist/sandbox/types.d.cts +18 -2
  503. package/dist/sandbox/types.d.ts +18 -2
  504. package/dist/sanitize/index.cjs +2 -2
  505. package/dist/sanitize/index.js +1 -1
  506. package/dist/sanitize/types.d.cts +15 -2
  507. package/dist/sanitize/types.d.ts +15 -2
  508. package/dist/{sdk-agent-D8qJVkuV.d.ts → sdk-agent-BOiKqOgL.d.cts} +197 -117
  509. package/dist/{sdk-agent-DEoKhA8a.d.cts → sdk-agent-D4a_BR_6.d.ts} +197 -117
  510. package/dist/server/auth/errors.d.cts +4 -3
  511. package/dist/server/auth/errors.d.ts +4 -3
  512. package/dist/server/auth/index.cjs +28 -28
  513. package/dist/server/auth/index.cjs.map +1 -1
  514. package/dist/server/auth/index.d.cts +28 -5
  515. package/dist/server/auth/index.d.ts +28 -5
  516. package/dist/server/auth/index.js +13 -13
  517. package/dist/server/auth/index.js.map +1 -1
  518. package/dist/server/auth/oauth-transaction-store.d.cts +2 -1
  519. package/dist/server/auth/oauth-transaction-store.d.ts +2 -1
  520. package/dist/server/auth/orchestrator.d.cts +4 -1
  521. package/dist/server/auth/orchestrator.d.ts +4 -1
  522. package/dist/server/auth/types.d.cts +18 -0
  523. package/dist/server/auth/types.d.ts +18 -0
  524. package/dist/server/errors-envelope.cjs +14 -15
  525. package/dist/server/errors-envelope.cjs.map +1 -1
  526. package/dist/server/errors-envelope.d.cts +3 -3
  527. package/dist/server/errors-envelope.d.ts +3 -3
  528. package/dist/server/errors-envelope.js +3 -4
  529. package/dist/server/errors-envelope.js.map +1 -1
  530. package/dist/session-transcript-LGHSNVY5.cjs +62 -0
  531. package/dist/{session-transcript-6WNITKRE.cjs.map → session-transcript-LGHSNVY5.cjs.map} +1 -1
  532. package/dist/session-transcript-VTBTCGQX.js +5 -0
  533. package/dist/{session-transcript-XAEKW6P7.js.map → session-transcript-VTBTCGQX.js.map} +1 -1
  534. package/dist/skills.cjs +8 -9
  535. package/dist/skills.js +6 -7
  536. package/dist/stream-object-HBFMIZLD.js +7 -0
  537. package/dist/{stream-object-UF4QRQRU.js.map → stream-object-HBFMIZLD.js.map} +1 -1
  538. package/dist/stream-object-QSKHISDJ.cjs +20 -0
  539. package/dist/{stream-object-ZJTQNKY3.cjs.map → stream-object-QSKHISDJ.cjs.map} +1 -1
  540. package/dist/stream-object.d.ts +2 -4
  541. package/dist/subagents-loader-TPZLTXYZ.cjs +16 -0
  542. package/dist/{subagents-loader-UCNO7FUH.cjs.map → subagents-loader-TPZLTXYZ.cjs.map} +1 -1
  543. package/dist/subagents-loader-Y6JFYXAY.js +7 -0
  544. package/dist/{subagents-loader-XP5ERVDZ.js.map → subagents-loader-Y6JFYXAY.js.map} +1 -1
  545. package/dist/subagents-loader.cjs +7 -8
  546. package/dist/subagents-loader.cjs.map +1 -1
  547. package/dist/subagents-loader.d.cts +5 -3
  548. package/dist/subagents-loader.d.ts +5 -3
  549. package/dist/subagents-loader.js +5 -6
  550. package/dist/subagents-loader.js.map +1 -1
  551. package/dist/subagents.cjs +2 -2
  552. package/dist/subagents.cjs.map +1 -1
  553. package/dist/subagents.js +1 -1
  554. package/dist/subagents.js.map +1 -1
  555. package/dist/subscription/define-subscription.d.cts +4 -1
  556. package/dist/subscription/define-subscription.d.ts +4 -1
  557. package/dist/subscription/index.cjs +4 -5
  558. package/dist/subscription/index.cjs.map +1 -1
  559. package/dist/subscription/index.d.cts +2 -0
  560. package/dist/subscription/index.d.ts +2 -0
  561. package/dist/subscription/index.js +3 -4
  562. package/dist/subscription/index.js.map +1 -1
  563. package/dist/subscription/internal/server-integration.d.cts +5 -0
  564. package/dist/subscription/internal/server-integration.d.ts +5 -0
  565. package/dist/subscription/internal/subscription-runtime.d.cts +13 -1
  566. package/dist/subscription/internal/subscription-runtime.d.ts +13 -1
  567. package/dist/task-errors.d.ts +58 -0
  568. package/dist/task-store.cjs +7 -8
  569. package/dist/task-store.d.cts +2 -0
  570. package/dist/task-store.d.ts +2 -0
  571. package/dist/task-store.js +4 -5
  572. package/dist/types/agent-prims.d.ts +21 -0
  573. package/dist/types/agent.d.ts +109 -15
  574. package/dist/types/batch.d.ts +3 -0
  575. package/dist/types/budget-tracker.d.ts +3 -0
  576. package/dist/types/budget.d.ts +12 -3
  577. package/dist/types/content-blocks.d.ts +3 -0
  578. package/dist/types/context.d.ts +3 -0
  579. package/dist/types/conversation.d.ts +5 -0
  580. package/dist/types/cron.d.ts +5 -0
  581. package/dist/types/env-policy.d.ts +3 -0
  582. package/dist/types/eval.d.ts +3 -0
  583. package/dist/types/fork.d.ts +3 -0
  584. package/dist/types/goal-events.d.ts +3 -0
  585. package/dist/types/mcp.d.ts +5 -0
  586. package/dist/types/memory-adapter.d.ts +3 -0
  587. package/dist/types/memory-provider.d.ts +44 -5
  588. package/dist/types/messages-base.d.ts +4 -0
  589. package/dist/types/messages.d.ts +5 -0
  590. package/dist/types/plugin.d.ts +32 -4
  591. package/dist/types/processors.d.ts +3 -0
  592. package/dist/types/provider-profile.d.ts +3 -0
  593. package/dist/types/providers.d.ts +3 -0
  594. package/dist/types/run-events.d.ts +36 -9
  595. package/dist/types/run.d.ts +29 -2
  596. package/dist/types/sdk-agent.d.ts +71 -1
  597. package/dist/types/session-message.d.ts +3 -0
  598. package/dist/types/session-record.d.ts +3 -0
  599. package/dist/types/session-store.d.ts +45 -0
  600. package/dist/types/task.d.ts +3 -11
  601. package/dist/types/theokit.d.ts +3 -0
  602. package/dist/types/trajectory.d.ts +3 -0
  603. package/dist/types/updates.d.ts +5 -0
  604. package/dist/types/usage.d.ts +4 -1
  605. package/dist/types/workflow.d.ts +13 -135
  606. package/dist/workflow-as-tool.d.ts +66 -0
  607. package/dist/workflow-errors.d.ts +164 -0
  608. package/dist/workflow.cjs +29 -30
  609. package/dist/workflow.d.cts +135 -74
  610. package/dist/workflow.d.ts +135 -74
  611. package/dist/workflow.js +8 -9
  612. package/docs/adr/README.md +2604 -0
  613. package/docs/error-codes.md +139 -105
  614. package/docs/harness-capability-map.md +32 -20
  615. package/docs/memory-decisions.md +1 -1
  616. package/package.json +3 -7
  617. package/bin/theokit-migrate-config.mjs +0 -278
  618. package/bin/theokit-migrate-memory.mjs +0 -116
  619. package/dist/agent-A5XMIVNP.js +0 -57
  620. package/dist/agent-UX7WFI6B.cjs +0 -66
  621. package/dist/agent-session-store-6EL5NPA4.cjs +0 -24
  622. package/dist/agent-session-store-OPGRB4XM.js +0 -7
  623. package/dist/batch-BXYTW2DP.cjs.map +0 -1
  624. package/dist/batch-L4ZXS46M.js.map +0 -1
  625. package/dist/chunk-247ZTLNU.js +0 -73
  626. package/dist/chunk-247ZTLNU.js.map +0 -1
  627. package/dist/chunk-2D34UTDC.js.map +0 -1
  628. package/dist/chunk-2GUYQR5P.js.map +0 -1
  629. package/dist/chunk-2QDYBS2A.js.map +0 -1
  630. package/dist/chunk-32WTYBUH.js.map +0 -1
  631. package/dist/chunk-3FFAEAUJ.cjs.map +0 -1
  632. package/dist/chunk-3O42QOMJ.js.map +0 -1
  633. package/dist/chunk-3OR54XG4.js.map +0 -1
  634. package/dist/chunk-43ZQRWAP.cjs.map +0 -1
  635. package/dist/chunk-4FFBAUFS.js.map +0 -1
  636. package/dist/chunk-4O5TGQBW.cjs.map +0 -1
  637. package/dist/chunk-4OTIXDMU.cjs.map +0 -1
  638. package/dist/chunk-4PYZ5AX3.cjs.map +0 -1
  639. package/dist/chunk-4QZSA2HJ.js.map +0 -1
  640. package/dist/chunk-4ZHTIJNE.cjs.map +0 -1
  641. package/dist/chunk-52NKC5HT.cjs.map +0 -1
  642. package/dist/chunk-6HKGLTJI.cjs.map +0 -1
  643. package/dist/chunk-6JSIEDKL.cjs.map +0 -1
  644. package/dist/chunk-7AD3ZTZL.js.map +0 -1
  645. package/dist/chunk-7BG5UH3T.cjs.map +0 -1
  646. package/dist/chunk-7VT4P3Z4.cjs.map +0 -1
  647. package/dist/chunk-7YGCPMGB.js.map +0 -1
  648. package/dist/chunk-A46SWMIF.js.map +0 -1
  649. package/dist/chunk-A4JVILQU.js.map +0 -1
  650. package/dist/chunk-ACDLHN3W.js.map +0 -1
  651. package/dist/chunk-AKJP2STZ.cjs +0 -81
  652. package/dist/chunk-AKJP2STZ.cjs.map +0 -1
  653. package/dist/chunk-AWO27VRZ.js.map +0 -1
  654. package/dist/chunk-B2J4ZMZL.cjs.map +0 -1
  655. package/dist/chunk-B4EOJWOY.cjs.map +0 -1
  656. package/dist/chunk-BU4KFWXF.js.map +0 -1
  657. package/dist/chunk-BZRFXJHA.js.map +0 -1
  658. package/dist/chunk-C3NT3PVE.js.map +0 -1
  659. package/dist/chunk-C72AZW7J.js.map +0 -1
  660. package/dist/chunk-D4CUGAKZ.js.map +0 -1
  661. package/dist/chunk-DN2PACRI.js.map +0 -1
  662. package/dist/chunk-DXGZ2NUG.cjs.map +0 -1
  663. package/dist/chunk-EG4QM7ZJ.cjs +0 -39
  664. package/dist/chunk-EG4QM7ZJ.cjs.map +0 -1
  665. package/dist/chunk-GMLBYDW4.cjs.map +0 -1
  666. package/dist/chunk-HCZD23VS.cjs.map +0 -1
  667. package/dist/chunk-HS7AVXTF.js.map +0 -1
  668. package/dist/chunk-IAHZCGBE.cjs.map +0 -1
  669. package/dist/chunk-J24VJOH3.cjs.map +0 -1
  670. package/dist/chunk-JPBKYL3B.cjs +0 -18
  671. package/dist/chunk-JPBKYL3B.cjs.map +0 -1
  672. package/dist/chunk-KQ7TS7WW.cjs.map +0 -1
  673. package/dist/chunk-KQRW2GPZ.js.map +0 -1
  674. package/dist/chunk-KYAJINUI.cjs.map +0 -1
  675. package/dist/chunk-L3MTL4NA.js.map +0 -1
  676. package/dist/chunk-L4BDVXIM.js.map +0 -1
  677. package/dist/chunk-LKBEROHN.js.map +0 -1
  678. package/dist/chunk-LYRDF5TQ.cjs.map +0 -1
  679. package/dist/chunk-LYTOXSRH.js.map +0 -1
  680. package/dist/chunk-N2U4AZGB.js.map +0 -1
  681. package/dist/chunk-NDGGJQTZ.js.map +0 -1
  682. package/dist/chunk-O7DK5PBJ.cjs.map +0 -1
  683. package/dist/chunk-O7LZFG6O.cjs.map +0 -1
  684. package/dist/chunk-OFRFZRQ4.cjs.map +0 -1
  685. package/dist/chunk-OSEG74VJ.js.map +0 -1
  686. package/dist/chunk-RFMBZPOW.cjs.map +0 -1
  687. package/dist/chunk-RFXWMRFC.js.map +0 -1
  688. package/dist/chunk-RIAM53CP.js.map +0 -1
  689. package/dist/chunk-RMWTPV3M.cjs.map +0 -1
  690. package/dist/chunk-RNB4APBZ.js.map +0 -1
  691. package/dist/chunk-SAVIWMZB.js.map +0 -1
  692. package/dist/chunk-SZVR77EJ.cjs.map +0 -1
  693. package/dist/chunk-TAZVKYWJ.js.map +0 -1
  694. package/dist/chunk-U54XCYG3.js.map +0 -1
  695. package/dist/chunk-U6IFHFWK.js.map +0 -1
  696. package/dist/chunk-UALX2J2Q.cjs.map +0 -1
  697. package/dist/chunk-UBDMVMBZ.js.map +0 -1
  698. package/dist/chunk-UGT7GK7I.cjs.map +0 -1
  699. package/dist/chunk-UNYXQ4M5.js.map +0 -1
  700. package/dist/chunk-UTSRIDKZ.js.map +0 -1
  701. package/dist/chunk-UU36SHFY.cjs.map +0 -1
  702. package/dist/chunk-V2BOS4WF.cjs.map +0 -1
  703. package/dist/chunk-VCLBZAZU.cjs.map +0 -1
  704. package/dist/chunk-VJ26EKGJ.cjs.map +0 -1
  705. package/dist/chunk-VKJ7V7EB.cjs.map +0 -1
  706. package/dist/chunk-VLVVJLDH.cjs.map +0 -1
  707. package/dist/chunk-WLQNMXQE.js.map +0 -1
  708. package/dist/chunk-WNO3C3N2.cjs.map +0 -1
  709. package/dist/chunk-WTMU7J4U.js +0 -14
  710. package/dist/chunk-WTMU7J4U.js.map +0 -1
  711. package/dist/chunk-XEQ3TM66.js +0 -35
  712. package/dist/chunk-XEQ3TM66.js.map +0 -1
  713. package/dist/chunk-XJCXEKMD.cjs.map +0 -1
  714. package/dist/chunk-XL7Q7HB2.cjs.map +0 -1
  715. package/dist/chunk-XWTLIGO3.cjs.map +0 -1
  716. package/dist/chunk-YML4ME27.cjs.map +0 -1
  717. package/dist/chunk-ZSWPZ23K.cjs.map +0 -1
  718. package/dist/chunk-ZZMZWBR6.js.map +0 -1
  719. package/dist/compact-session-QV57KR66.cjs +0 -59
  720. package/dist/compact-session-RIGOWC4Y.js +0 -22
  721. package/dist/context-WFLTTMK3.cjs +0 -24
  722. package/dist/context-WI2DFG7V.js +0 -7
  723. package/dist/executor-6CYCA7MI.cjs.map +0 -1
  724. package/dist/executor-QSEC3MRH.js.map +0 -1
  725. package/dist/fork-agent-RSV4E3EA.js.map +0 -1
  726. package/dist/fork-agent-Y2IK2RYU.cjs.map +0 -1
  727. package/dist/fs-session-store-4PIHT5UX.cjs +0 -20
  728. package/dist/fs-session-store-NM6YSTE2.js +0 -11
  729. package/dist/generate-object-GUNAUVBX.js +0 -8
  730. package/dist/generate-object-R7HTMW7F.cjs +0 -21
  731. package/dist/index-manager-2SRX45WJ.cjs +0 -27
  732. package/dist/index-manager-SP4ISSDX.js +0 -18
  733. package/dist/inject-session-WQKMC3GR.cjs +0 -29
  734. package/dist/internal/persistence/credential-pool-store.d.cts +0 -32
  735. package/dist/internal/persistence/credential-pool-store.d.ts +0 -32
  736. package/dist/internal/runtime/memory/memory-path-selector.d.ts +0 -73
  737. package/dist/judge-call-LAHMBJ57.cjs +0 -23
  738. package/dist/judge-call-LVXABPS3.js +0 -6
  739. package/dist/oauth-transaction-store-BT4GLTLK.cjs +0 -36
  740. package/dist/oauth-transaction-store-W52KVHQ4.js +0 -3
  741. package/dist/registry-75W33OGL.js +0 -10
  742. package/dist/registry-V7BDQ6QB.cjs +0 -47
  743. package/dist/run-until-HEQOUVU6.js.map +0 -1
  744. package/dist/run-until-U2B5FJJI.cjs.map +0 -1
  745. package/dist/server/adapter/express.d.cts +0 -9
  746. package/dist/server/adapter/express.d.ts +0 -9
  747. package/dist/server/adapter/fastify.d.cts +0 -9
  748. package/dist/server/adapter/fastify.d.ts +0 -9
  749. package/dist/server/adapter/hono.d.cts +0 -9
  750. package/dist/server/adapter/hono.d.ts +0 -9
  751. package/dist/server/adapter/shared-handler.d.cts +0 -9
  752. package/dist/server/adapter/shared-handler.d.ts +0 -9
  753. package/dist/server/adapter/types.d.cts +0 -33
  754. package/dist/server/adapter/types.d.ts +0 -33
  755. package/dist/session-transcript-6WNITKRE.cjs +0 -63
  756. package/dist/session-transcript-XAEKW6P7.js +0 -6
  757. package/dist/stream-object-UF4QRQRU.js +0 -8
  758. package/dist/stream-object-ZJTQNKY3.cjs +0 -21
  759. package/dist/subagents-loader-UCNO7FUH.cjs +0 -17
  760. package/dist/subagents-loader-XP5ERVDZ.js +0 -8
  761. /package/dist/{batch.d.ts → internal/agent/batch.d.ts} +0 -0
  762. /package/dist/{agent-helpers.d.ts → internal/agent/helpers.d.ts} +0 -0
  763. /package/dist/internal/agent-loop/{loop-types.d.ts → types.d.ts} +0 -0
  764. /package/dist/internal/auth/{auth-types.d.ts → types.d.ts} +0 -0
  765. /package/dist/internal/cloud-agent/{cloud-payload-types.d.ts → types.d.ts} +0 -0
  766. /package/dist/internal/{runtime/concurrency → concurrency}/abort-utils.d.ts +0 -0
  767. /package/dist/internal/{runtime/concurrency → concurrency}/async-local-storage.d.ts +0 -0
  768. /package/dist/internal/{runtime/concurrency → concurrency}/async-semaphore.d.ts +0 -0
  769. /package/dist/internal/{runtime/concurrency → concurrency}/delegation-depth.d.ts +0 -0
  770. /package/dist/internal/{runtime/concurrency → concurrency}/map-with-concurrency.d.ts +0 -0
  771. /package/dist/internal/{runtime/retry → error-mappers}/default-retriable.d.ts +0 -0
  772. /package/dist/internal/{runtime/fixtures/fixture-types.d.ts → memory/storage/list-markdown.d.cts} +0 -0
  773. /package/dist/internal/{runtime/plugins/plugins-manager.d.ts → memory/storage/list-markdown.d.ts} +0 -0
  774. /package/dist/internal/{resilience → retry}/circuit-breaker.d.ts +0 -0
  775. /package/dist/internal/{runtime/retry → retry}/with-retry.d.ts +0 -0
  776. /package/dist/internal/{security/secret-redactor.d.cts → runtime/fixtures/types.d.ts} +0 -0
  777. /package/dist/internal/runtime/{memory → memory-glue}/memory-store.d.ts +0 -0
  778. /package/dist/internal/runtime/{memory → memory-glue}/select-facts.d.ts +0 -0
  779. /package/dist/internal/runtime/{plugins → plugin-loader}/plugin-frontmatter.d.ts +0 -0
  780. /package/dist/internal/{security/secret-redactor.d.ts → runtime/plugin-loader/plugins-manager.d.ts} +0 -0
  781. /package/dist/internal/runtime/{reasoning → system-prompt}/native-reasoning.d.ts +0 -0
  782. /package/dist/internal/{runtime/context/path-containment.d.ts → security/path-containment.d.cts} +0 -0
  783. /package/dist/internal/session/{session-types.d.ts → types.d.ts} +0 -0
  784. /package/dist/internal/{zod/to-json-schema.d.ts → zod-to-json-schema.d.ts} +0 -0
  785. /package/dist/subscription/internal/{adapter-types.d.cts → types.d.cts} +0 -0
  786. /package/dist/subscription/internal/{adapter-types.d.ts → types.d.ts} +0 -0
@@ -1,14 +1,17 @@
1
- import { currentCredentialPool, computeBackoffMs, sleepWithAbort, newPooledCredential, CredentialPool } from './chunk-TAZVKYWJ.js';
2
- import { invalidateSessionCache } from './chunk-WTMU7J4U.js';
3
- import { buildErrorMetadata, mapOpenAICompatibleError } from './chunk-7YGCPMGB.js';
4
- import { tryJson, isPlainObject, sanitizeToolInput } from './chunk-U54XCYG3.js';
1
+ import { currentCredentialPool, newPooledCredential, CredentialPool } from './chunk-UBR5PWD7.js';
2
+ import { invalidateSessionCache } from './chunk-2XC6KDJM.js';
3
+ import { buildErrorMetadata, mapOpenAICompatibleError, parseErrorBody, httpStatusToErrorCode } from './chunk-XB4GI5RZ.js';
4
+ import { computeBackoffMs, sleepWithAbort } from './chunk-24MGQDK3.js';
5
+ import { tryJson, isPlainObject, sanitizeToolInput } from './chunk-FJWQP6EE.js';
5
6
  import { providerFromApiKeyPrefix } from './chunk-NAF4L3T6.js';
6
- import { reconstructMessages, SessionTranscript } from './chunk-UMP6OJIM.js';
7
- import { estimateTokens } from './chunk-A4JVILQU.js';
8
- import { globalSingleton, registerProvider, registerBuiltins, getProviderProfile, inferModelDialect, inferRegionFromModelId, stripBedrockPrefix, resolveBedrockBaseUrl, resolveVertexBaseUrl, stripVertexPrefix } from './chunk-WLQNMXQE.js';
9
- import { readStoredOAuth } from './chunk-C3NT3PVE.js';
10
- import { NetworkError, ConfigurationError, IntegrationNotConnectedError, AuthenticationError, RateLimitError, UnknownAgentError, CredentialPoolExhaustedError, isTransientError, TheokitAgentError } from './chunk-ZZMZWBR6.js';
11
- import { diag } from './chunk-XEQ3TM66.js';
7
+ import { reconstructMessages, SessionTranscript } from './chunk-JOFVLOFY.js';
8
+ import { estimateTokens } from './chunk-6M2OIS4Y.js';
9
+ import { parseModelId } from './chunk-R7WIIPUR.js';
10
+ import { registerProvider, registerBuiltins, getProviderProfile, inferModelDialect, inferRegionFromModelId, stripBedrockPrefix, resolveBedrockBaseUrl, resolveVertexBaseUrl, stripVertexPrefix } from './chunk-VWUXIVEI.js';
11
+ import { globalSingleton } from './chunk-AGACYRJ2.js';
12
+ import { readStoredOAuth } from './chunk-V22DZIXO.js';
13
+ import { NetworkError, ConfigurationError, IntegrationNotConnectedError, AuthenticationError, RateLimitError, UnknownAgentError, TheokitAgentError, CredentialPoolExhaustedError, isTransientError } from './chunk-ALUN2B4W.js';
14
+ import { diag } from './chunk-CZJ6Q7CW.js';
12
15
  import { existsSync, readFileSync } from 'fs';
13
16
  import { readdir } from 'fs/promises';
14
17
  import { homedir } from 'os';
@@ -142,9 +145,6 @@ function mapAnthropicError(args) {
142
145
  return new UnknownAgentError(message, { code: "anthropic_unknown", metadata });
143
146
  }
144
147
  function mapAnthropicStatusToCode(status, body) {
145
- if (status === 401 || status === 403) return "auth_failed";
146
- if (status === 429) return "rate_limit";
147
- if (status === 408) return "timeout";
148
148
  if (status === 400) {
149
149
  const text = JSON.stringify(body ?? "").toLowerCase();
150
150
  if (text.includes("context") && (text.includes("too long") || text.includes("too_long") || text.includes("length"))) {
@@ -155,8 +155,7 @@ function mapAnthropicStatusToCode(status, body) {
155
155
  }
156
156
  return "invalid_request";
157
157
  }
158
- if (status >= 500 && status < 600) return "server_error";
159
- return "unknown";
158
+ return httpStatusToErrorCode(status);
160
159
  }
161
160
  function formatMessage(status, code) {
162
161
  return `Anthropic API error: ${code} (HTTP ${status})`;
@@ -476,13 +475,13 @@ function releaseReader(reader) {
476
475
  }
477
476
 
478
477
  // src/internal/llm/transport-error.ts
479
- function ehAbort(err) {
478
+ function isAbortError(err) {
480
479
  if (typeof err !== "object" || err === null) return false;
481
- const nome = err.name;
482
- return nome === "AbortError" || nome === "TimeoutError";
480
+ const name = err.name;
481
+ return name === "AbortError" || name === "TimeoutError";
483
482
  }
484
483
  function wrapTransportError(err, ctx) {
485
- if (ehAbort(err)) return err;
484
+ if (isAbortError(err)) return err;
486
485
  if (err instanceof TheokitAgentError) return err;
487
486
  const detail = err instanceof Error ? err.message : String(err);
488
487
  return new NetworkError(`${ctx.providerId} transport failure on ${ctx.endpoint}: ${detail}`, {
@@ -688,18 +687,17 @@ function buildAnthropicBody(request) {
688
687
 
689
688
  // src/internal/error-mappers/bedrock.ts
690
689
  function classifyBedrockError(args, awsType, message) {
691
- if (args.status === 429 || awsType.includes("Throttling") || awsType.includes("TooManyRequests")) {
690
+ if (awsType.includes("Throttling") || awsType.includes("TooManyRequests")) {
692
691
  return "rate_limit";
693
692
  }
694
- if (args.status === 401 || args.status === 403 || awsType.includes("AccessDenied") || awsType.includes("UnauthorizedOperation")) {
693
+ if (awsType.includes("AccessDenied") || awsType.includes("UnauthorizedOperation")) {
695
694
  return "auth_failed";
696
695
  }
697
- if (args.status === 400 || args.status === 404 || awsType.includes("ValidationException") || awsType.includes("ResourceNotFound") || message.includes("use case details")) {
696
+ if (args.status === 404 || awsType.includes("ValidationException") || awsType.includes("ResourceNotFound") || message.includes("use case details")) {
698
697
  return "invalid_request";
699
698
  }
700
- if (args.status === 408 || awsType.includes("Timeout")) return "timeout";
701
- if (args.status >= 500) return "server_error";
702
- return "unknown";
699
+ if (awsType.includes("Timeout")) return "timeout";
700
+ return httpStatusToErrorCode(args.status);
703
701
  }
704
702
  function buildBedrockMetadata(args, code) {
705
703
  return buildErrorMetadata({
@@ -712,7 +710,7 @@ function buildBedrockMetadata(args, code) {
712
710
  });
713
711
  }
714
712
  function mapBedrockError(args) {
715
- const parsed = parseBody(args.body);
713
+ const parsed = parseErrorBody(args.body);
716
714
  const awsType = parsed.__type ?? "";
717
715
  const message = parsed.message ?? parsed.Message ?? "Bedrock request failed";
718
716
  const code = classifyBedrockError(args, awsType, message);
@@ -726,6 +724,8 @@ function mapBedrockError(args) {
726
724
  const friendly = message.includes("use case details") ? `Bedrock account setup required: ${message} (AWS Console \u2192 Bedrock \u2192 Model access \u2192 Anthropic \u2192 Submit use case form, then retry in 15 min.)` : `Bedrock validation: ${message}`;
727
725
  return new ConfigurationError(friendly, { metadata });
728
726
  }
727
+ case "quota_exceeded":
728
+ return new RateLimitError(`Bedrock quota exceeded: ${message}`, { metadata });
729
729
  case "timeout":
730
730
  return new NetworkError(`Bedrock timeout: ${message}`, { metadata });
731
731
  case "server_error":
@@ -734,17 +734,6 @@ function mapBedrockError(args) {
734
734
  return new UnknownAgentError(`Bedrock unknown: ${message}`, { metadata });
735
735
  }
736
736
  }
737
- function parseBody(body) {
738
- if (body !== null && typeof body === "object") return body;
739
- if (typeof body === "string") {
740
- try {
741
- return JSON.parse(body);
742
- } catch {
743
- return {};
744
- }
745
- }
746
- return {};
747
- }
748
737
  var cachedToken = null;
749
738
  var CACHE_TTL_MS = 90 * 60 * 1e3;
750
739
  async function resolveBedrockToken(region) {
@@ -1025,7 +1014,7 @@ var OllamaNativeClient = class {
1025
1014
  endpoint: "/api/chat"
1026
1015
  });
1027
1016
  if (mapped !== void 0) throw mapped;
1028
- throw fetchErr;
1017
+ throw wrapTransportError(fetchErr, { providerId: "ollama", endpoint: "/api/chat" });
1029
1018
  }
1030
1019
  if (!response.ok) {
1031
1020
  const text = await response.text().catch(() => "");
@@ -1042,7 +1031,13 @@ var OllamaNativeClient = class {
1042
1031
  endpoint: "/api/chat"
1043
1032
  });
1044
1033
  if (mapped !== void 0) throw mapped;
1045
- throw new Error(`Ollama /api/chat HTTP ${response.status}: ${text.slice(0, 200)}`);
1034
+ throw mapOpenAICompatibleError({
1035
+ providerId: "ollama",
1036
+ status: response.status,
1037
+ body: bodyJson,
1038
+ headers: response.headers,
1039
+ endpoint: "/api/chat"
1040
+ });
1046
1041
  }
1047
1042
  const accumulator = new OllamaStreamAccumulator();
1048
1043
  if (response.body === null) {
@@ -1231,83 +1226,13 @@ function toOllamaTools(tools) {
1231
1226
  }
1232
1227
  }));
1233
1228
  }
1234
- var FIXTURE_API_KEY_PREFIX = "theo_test_";
1235
- function isFixtureApiKey(apiKey) {
1236
- if (apiKey === void 0) return false;
1237
- return apiKey.startsWith(FIXTURE_API_KEY_PREFIX);
1238
- }
1229
+
1230
+ // src/internal/base-url.ts
1239
1231
  function getConfiguredBaseUrl() {
1240
1232
  const value = process.env.THEOKIT_API_BASE_URL;
1241
1233
  if (value === void 0 || value.length === 0) return void 0;
1242
1234
  return value;
1243
1235
  }
1244
- function shouldUseFixtureMode(apiKey) {
1245
- if (getConfiguredBaseUrl() !== void 0) return false;
1246
- return isFixtureApiKey(apiKey);
1247
- }
1248
- var PROVIDER_CREDENTIAL_ENV_VARS = [
1249
- "ANTHROPIC_API_KEY",
1250
- "OPENAI_API_KEY",
1251
- "OPENROUTER_API_KEY"
1252
- ];
1253
- function presentProviderCredentialEnvVars() {
1254
- return PROVIDER_CREDENTIAL_ENV_VARS.filter((name) => {
1255
- const value = process.env[name];
1256
- return typeof value === "string" && value.length > 0;
1257
- });
1258
- }
1259
- function shouldUseRealLocalRuntime(apiKey) {
1260
- if (isFixtureApiKey(apiKey)) return false;
1261
- if (isStoredOAuthAvailable()) return true;
1262
- if (apiKey === void 0 || apiKey.length === 0) return false;
1263
- return presentProviderCredentialEnvVars().length > 0 || isAwsBedrockAuthAvailable() || isGcpVertexAuthAvailable() || isLocalNoAuthProviderAvailable();
1264
- }
1265
- var AMBIENT_STORE = {
1266
- home: homedir(),
1267
- dirName: ".theokit",
1268
- fileName: "auth.json",
1269
- homeEnvVar: "THEOKIT_AUTH_HOME"
1270
- };
1271
- function isStoredOAuthAvailable(env = process.env) {
1272
- try {
1273
- return readStoredOAuth(AMBIENT_STORE, env) !== void 0;
1274
- } catch {
1275
- return false;
1276
- }
1277
- }
1278
- function isAwsBedrockAuthAvailable() {
1279
- if (typeof process.env.AWS_BEARER_TOKEN_BEDROCK === "string" && process.env.AWS_BEARER_TOKEN_BEDROCK.length > 0) {
1280
- return true;
1281
- }
1282
- if (typeof process.env.AWS_ACCESS_KEY_ID === "string" && process.env.AWS_ACCESS_KEY_ID.length > 0) {
1283
- return true;
1284
- }
1285
- if (typeof process.env.AWS_PROFILE === "string" && process.env.AWS_PROFILE.length > 0) {
1286
- return true;
1287
- }
1288
- return awsCredentialsFileExists();
1289
- }
1290
- function awsCredentialsFileExists() {
1291
- try {
1292
- const home = process.env.HOME ?? process.env.USERPROFILE;
1293
- if (home === void 0 || home.length === 0) return false;
1294
- return existsSync(`${home}/.aws/credentials`) || existsSync(`${home}/.aws/config`);
1295
- } catch {
1296
- return false;
1297
- }
1298
- }
1299
- function isGcpVertexAuthAvailable() {
1300
- if (typeof process.env.GOOGLE_APPLICATION_CREDENTIALS === "string" && process.env.GOOGLE_APPLICATION_CREDENTIALS.length > 0) {
1301
- return true;
1302
- }
1303
- if (typeof process.env.GOOGLE_CLOUD_PROJECT === "string" && process.env.GOOGLE_CLOUD_PROJECT.length > 0) {
1304
- return true;
1305
- }
1306
- return false;
1307
- }
1308
- function isLocalNoAuthProviderAvailable() {
1309
- return true;
1310
- }
1311
1236
 
1312
1237
  // src/internal/http.ts
1313
1238
  var DEFAULT_BASE_URL = "https://api.usetheo.dev";
@@ -1372,12 +1297,18 @@ function mapHttpStatusToError(status, body) {
1372
1297
  cause: body
1373
1298
  });
1374
1299
  }
1300
+ return statusToError(status, message, errorOptions);
1301
+ }
1302
+ function statusToError(status, message, errorOptions) {
1375
1303
  if (status === 401 || status === 403) {
1376
1304
  return new AuthenticationError(message, errorOptions);
1377
1305
  }
1378
1306
  if (status === 429) {
1379
1307
  return new RateLimitError(message, errorOptions);
1380
1308
  }
1309
+ if (status === 408) {
1310
+ return new NetworkError(message, { ...errorOptions, code: errorOptions.code ?? "timeout" });
1311
+ }
1381
1312
  if (status >= 400 && status < 500) {
1382
1313
  return new ConfigurationError(message, errorOptions);
1383
1314
  }
@@ -1897,7 +1828,7 @@ function encodeOpenAIResponseFormat(rf) {
1897
1828
  };
1898
1829
  }
1899
1830
 
1900
- // src/internal/resilience/circuit-breaker.ts
1831
+ // src/internal/retry/circuit-breaker.ts
1901
1832
  var DEFAULT_MAX_TIMEOUTS = 3;
1902
1833
  var DEFAULT_COOLDOWN_MS = 6e4;
1903
1834
  var CircuitBreaker = class {
@@ -1939,6 +1870,12 @@ var CircuitBreaker = class {
1939
1870
  }
1940
1871
  };
1941
1872
 
1873
+ // src/internal/llm/abort-error.ts
1874
+ function abortError(signal) {
1875
+ if (signal.reason instanceof Error) return signal.reason;
1876
+ return new Error(signal.reason !== void 0 ? String(signal.reason) : "aborted");
1877
+ }
1878
+
1942
1879
  // src/internal/llm/stream-relay.ts
1943
1880
  async function tryFirstEvent(client, request, signal, logFallback = false) {
1944
1881
  const generator = client.stream(request, signal);
@@ -2082,10 +2019,6 @@ function inferStatusCode(error) {
2082
2019
  if (error instanceof RateLimitError) return 429;
2083
2020
  return 0;
2084
2021
  }
2085
- function abortError(signal) {
2086
- if (signal.reason instanceof Error) return signal.reason;
2087
- return new Error("AbortError");
2088
- }
2089
2022
 
2090
2023
  // src/internal/llm/responses.ts
2091
2024
  function messageToInputItems(message, reasoningByCallId) {
@@ -2172,6 +2105,142 @@ function applyPromptCachingFields(body, request, options) {
2172
2105
  if (carryReasoning) body.include = ["reasoning.encrypted_content"];
2173
2106
  if (request.promptCacheKey !== void 0) body.prompt_cache_key = request.promptCacheKey;
2174
2107
  }
2108
+ var ResponsesStreamAccumulator = class {
2109
+ constructor(rememberReasoning) {
2110
+ this.rememberReasoning = rememberReasoning;
2111
+ }
2112
+ rememberReasoning;
2113
+ text = "";
2114
+ toolCalls = [];
2115
+ stopReason = "end_turn";
2116
+ inputTokens;
2117
+ outputTokens;
2118
+ reasoningTokens;
2119
+ cacheReadTokens;
2120
+ cacheWriteTokens;
2121
+ /** Function-call accumulation keyed by the streamed output-item id. */
2122
+ pending = {};
2123
+ /**
2124
+ * usetheokit/theokit-sdk#383 — reasoning items seen so far in THIS response and not yet claimed
2125
+ * by a tool call. Claimed (and cleared) when the next `function_call` completes, which is what
2126
+ * binds each batch to the call it produced.
2127
+ */
2128
+ unclaimedReasoning = [];
2129
+ /** The message of a terminal failure event, or `undefined` when this is not one. */
2130
+ static failureMessage(event) {
2131
+ if (event.type !== "response.failed" && event.type !== "error") return void 0;
2132
+ return event.response?.error?.message ?? event.message ?? "responses stream failed";
2133
+ }
2134
+ consume(event) {
2135
+ return this.applyDelta(event) ?? this.applyStructural(event) ?? [];
2136
+ }
2137
+ /** The three event kinds that produce an event for the consumer. */
2138
+ applyDelta(event) {
2139
+ const t = event.type;
2140
+ if (t === "response.output_text.delta") {
2141
+ const d = event.delta ?? "";
2142
+ if (d.length === 0) return [];
2143
+ this.text += d;
2144
+ return [{ type: "text_delta", text: d }];
2145
+ }
2146
+ if (t === "response.reasoning_summary_text.delta" || t === "response.reasoning_text.delta") {
2147
+ const d = event.delta ?? "";
2148
+ return d.length > 0 ? [{ type: "reasoning_delta", text: d }] : [];
2149
+ }
2150
+ return void 0;
2151
+ }
2152
+ /** The event kinds that only move accumulator state. Routing only — each arm is its own method. */
2153
+ applyStructural(event) {
2154
+ const t = event.type;
2155
+ if (t === "response.output_item.added" || t === "response.output_item.done") {
2156
+ this.applyOutputItem(t, event);
2157
+ return [];
2158
+ }
2159
+ if (t === "response.function_call_arguments.delta") {
2160
+ this.appendArguments(event);
2161
+ return [];
2162
+ }
2163
+ if (t === "response.completed" || t === "response.incomplete") {
2164
+ this.applyTerminal(t, event);
2165
+ return [];
2166
+ }
2167
+ return void 0;
2168
+ }
2169
+ appendArguments(event) {
2170
+ const c = event.item_id !== void 0 ? this.pending[event.item_id] : void 0;
2171
+ if (c !== void 0) c.args += event.delta ?? "";
2172
+ }
2173
+ applyTerminal(t, event) {
2174
+ this.applyUsage(event.response?.usage);
2175
+ this.stopReason = t === "response.incomplete" ? "max_tokens" : "end_turn";
2176
+ }
2177
+ finish() {
2178
+ const stopReason = this.toolCalls.length > 0 && this.stopReason === "end_turn" ? "tool_use" : this.stopReason;
2179
+ return makeLlmFinish({
2180
+ stopReason,
2181
+ text: this.text,
2182
+ toolCalls: this.toolCalls,
2183
+ inputTokens: this.inputTokens,
2184
+ outputTokens: this.outputTokens,
2185
+ reasoningTokens: this.reasoningTokens,
2186
+ cacheReadTokens: this.cacheReadTokens,
2187
+ cacheWriteTokens: this.cacheWriteTokens
2188
+ });
2189
+ }
2190
+ applyOutputItem(t, event) {
2191
+ const item = event.item;
2192
+ if (item === void 0) return;
2193
+ if (t === "response.output_item.added") {
2194
+ if (item.type === "function_call") this.beginFunctionCall(item);
2195
+ return;
2196
+ }
2197
+ if (item.type === "reasoning") this.applyReasoningItem(item);
2198
+ else if (item.type === "function_call") this.applyFunctionCallDone(item);
2199
+ }
2200
+ beginFunctionCall(item) {
2201
+ const id = item.id ?? item.call_id ?? "call-0";
2202
+ this.pending[id] = {
2203
+ callId: item.call_id ?? id,
2204
+ name: item.name ?? "",
2205
+ args: item.arguments ?? ""
2206
+ };
2207
+ }
2208
+ applyReasoningItem(item) {
2209
+ const id = item.id;
2210
+ const encrypted = item.encrypted_content;
2211
+ if (id !== void 0 && encrypted !== void 0 && encrypted.length > 0) {
2212
+ this.unclaimedReasoning.push({ id, encrypted_content: encrypted });
2213
+ }
2214
+ }
2215
+ applyFunctionCallDone(item) {
2216
+ const id = item.id ?? item.call_id ?? "call-0";
2217
+ const c = this.pending[id] ?? {
2218
+ callId: item.call_id ?? id,
2219
+ name: item.name ?? "",
2220
+ args: item.arguments ?? ""
2221
+ };
2222
+ const call = {
2223
+ type: "tool_use",
2224
+ id: c.callId,
2225
+ name: c.name.length > 0 ? c.name : item.name ?? "",
2226
+ input: parseToolArguments(item.arguments ?? c.args)
2227
+ };
2228
+ this.toolCalls.push(call);
2229
+ if (this.unclaimedReasoning.length > 0) {
2230
+ this.rememberReasoning(call.id, this.unclaimedReasoning);
2231
+ this.unclaimedReasoning = [];
2232
+ }
2233
+ delete this.pending[id];
2234
+ }
2235
+ applyUsage(usage) {
2236
+ if (usage === void 0) return;
2237
+ this.inputTokens = usage.input_tokens;
2238
+ this.outputTokens = usage.output_tokens;
2239
+ this.reasoningTokens = usage.output_tokens_details?.reasoning_tokens;
2240
+ this.cacheReadTokens = usage.input_tokens_details?.cached_tokens;
2241
+ this.cacheWriteTokens = usage.input_tokens_details?.cache_write_tokens;
2242
+ }
2243
+ };
2175
2244
  var MAX_REMEMBERED_REASONING_CALLS = 256;
2176
2245
  var ResponsesApiClient = class {
2177
2246
  constructor(options) {
@@ -2204,20 +2273,17 @@ var ResponsesApiClient = class {
2204
2273
  this.reasoningByCallId.delete(oldest.value);
2205
2274
  }
2206
2275
  }
2207
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: the SSE dispatch (text / reasoning / tool-call add+delta+done / terminal+usage / error) is one cohesive state machine, mirroring OpenAIStreamAccumulator.consume.
2208
- async *stream(request, signal) {
2209
- const providerId = this.options.providerName ?? "openai";
2210
- const headers = {
2211
- "content-type": "application/json",
2212
- accept: "text/event-stream",
2213
- authorization: `Bearer ${this.options.apiKey}`,
2214
- ...this.options.extraHeaders ?? {}
2215
- };
2216
- const url = `${this.baseUrl}/responses`;
2217
- const response = await this.fetchImpl(url, {
2276
+ /** Issues the streaming request. Separated so `stream()` reads as fetch check consume. */
2277
+ async post(request, signal) {
2278
+ return await this.fetchImpl(`${this.baseUrl}/responses`, {
2218
2279
  method: "POST",
2219
2280
  signal,
2220
- headers,
2281
+ headers: {
2282
+ "content-type": "application/json",
2283
+ accept: "text/event-stream",
2284
+ authorization: `Bearer ${this.options.apiKey}`,
2285
+ ...this.options.extraHeaders ?? {}
2286
+ },
2221
2287
  body: JSON.stringify(
2222
2288
  // Both options ride the SAME flag on purpose: a provider that never declared support gets
2223
2289
  // the byte-identical pre-#383 body, even in the impossible case where it returned ciphertext
@@ -2228,129 +2294,67 @@ var ResponsesApiClient = class {
2228
2294
  )
2229
2295
  )
2230
2296
  });
2231
- if (!response.ok) {
2232
- const text2 = await response.text().catch(() => "");
2233
- let body = text2;
2297
+ }
2298
+ /** Maps a non-2xx response to a typed error. Returns it rather than throwing, so the caller's
2299
+ * control flow stays visible at the call site. */
2300
+ async errorFor(response, providerId) {
2301
+ const text = await response.text().catch(() => "");
2302
+ let body = text;
2303
+ try {
2304
+ body = JSON.parse(text);
2305
+ } catch {
2306
+ }
2307
+ return mapOpenAICompatibleError({
2308
+ providerId,
2309
+ status: response.status,
2310
+ body,
2311
+ headers: response.headers,
2312
+ endpoint: "/responses"
2313
+ });
2314
+ }
2315
+ /**
2316
+ * SSE frames → parsed events, stopping at `[DONE]`. A frame that is not JSON is skipped rather
2317
+ * than fatal: a provider that emits a keep-alive or a comment frame must not end the response.
2318
+ */
2319
+ async *decode(body, signal) {
2320
+ for await (const record of parseSseStream(body, signal)) {
2321
+ if (record.data === "[DONE]") return;
2322
+ let event;
2234
2323
  try {
2235
- body = JSON.parse(text2);
2324
+ event = JSON.parse(record.data);
2236
2325
  } catch {
2326
+ continue;
2237
2327
  }
2238
- throw mapOpenAICompatibleError({
2239
- providerId,
2240
- status: response.status,
2241
- body,
2242
- headers: response.headers,
2243
- endpoint: "/responses"
2244
- });
2328
+ yield event;
2245
2329
  }
2246
- let text = "";
2247
- const toolCalls = [];
2248
- let stopReason = "end_turn";
2249
- let inputTokens;
2250
- let outputTokens;
2251
- let reasoningTokens;
2252
- let cacheReadTokens;
2253
- let cacheWriteTokens;
2254
- const pending = {};
2255
- let unclaimedReasoning = [];
2330
+ }
2331
+ async *stream(request, signal) {
2332
+ const providerId = this.options.providerName ?? "openai";
2333
+ const response = await this.post(request, signal);
2334
+ if (!response.ok) throw await this.errorFor(response, providerId);
2335
+ const acc = new ResponsesStreamAccumulator(
2336
+ (callId, items) => this.rememberReasoning(callId, items)
2337
+ );
2256
2338
  if (response.body !== null) {
2257
- for await (const record of parseSseStream(response.body, signal)) {
2258
- if (record.data === "[DONE]") break;
2259
- let event;
2260
- try {
2261
- event = JSON.parse(record.data);
2262
- } catch {
2263
- continue;
2264
- }
2265
- const t = event.type;
2266
- if (t === "response.output_text.delta") {
2267
- const d = event.delta ?? "";
2268
- if (d.length > 0) {
2269
- text += d;
2270
- yield { type: "text_delta", text: d };
2271
- }
2272
- } else if (t === "response.reasoning_summary_text.delta" || t === "response.reasoning_text.delta") {
2273
- const d = event.delta ?? "";
2274
- if (d.length > 0) yield { type: "reasoning_delta", text: d };
2275
- } else if (t === "response.output_item.done" && event.item?.type === "reasoning") {
2276
- const id = event.item.id;
2277
- const encrypted = event.item.encrypted_content;
2278
- if (id !== void 0 && encrypted !== void 0 && encrypted.length > 0) {
2279
- unclaimedReasoning.push({ id, encrypted_content: encrypted });
2280
- }
2281
- } else if (t === "response.output_item.added" && event.item?.type === "function_call") {
2282
- const id = event.item.id ?? event.item.call_id ?? "call-0";
2283
- pending[id] = {
2284
- callId: event.item.call_id ?? id,
2285
- name: event.item.name ?? "",
2286
- args: event.item.arguments ?? ""
2287
- };
2288
- } else if (t === "response.function_call_arguments.delta") {
2289
- const c = event.item_id !== void 0 ? pending[event.item_id] : void 0;
2290
- if (c !== void 0) c.args += event.delta ?? "";
2291
- } else if (t === "response.output_item.done" && event.item?.type === "function_call") {
2292
- const id = event.item.id ?? event.item.call_id ?? "call-0";
2293
- const c = pending[id] ?? {
2294
- callId: event.item.call_id ?? id,
2295
- name: event.item.name ?? "",
2296
- args: event.item.arguments ?? ""
2297
- };
2298
- const rawArgs = event.item.arguments ?? c.args;
2299
- const call = {
2300
- type: "tool_use",
2301
- id: c.callId,
2302
- name: c.name.length > 0 ? c.name : event.item.name ?? "",
2303
- input: parseToolArguments(rawArgs)
2304
- };
2305
- toolCalls.push(call);
2306
- if (unclaimedReasoning.length > 0) {
2307
- this.rememberReasoning(call.id, unclaimedReasoning);
2308
- unclaimedReasoning = [];
2309
- }
2310
- delete pending[id];
2311
- } else if (t === "response.completed" || t === "response.incomplete") {
2312
- const usage = event.response?.usage;
2313
- if (usage !== void 0) {
2314
- inputTokens = usage.input_tokens;
2315
- outputTokens = usage.output_tokens;
2316
- reasoningTokens = usage.output_tokens_details?.reasoning_tokens;
2317
- cacheReadTokens = usage.input_tokens_details?.cached_tokens;
2318
- cacheWriteTokens = usage.input_tokens_details?.cache_write_tokens;
2319
- }
2320
- stopReason = t === "response.incomplete" ? "max_tokens" : "end_turn";
2321
- } else if (t === "response.failed" || t === "error") {
2322
- const msg = event.response?.error?.message ?? event.message ?? "responses stream failed";
2323
- yield { type: "error", message: msg };
2339
+ for await (const event of this.decode(response.body, signal)) {
2340
+ const failure = ResponsesStreamAccumulator.failureMessage(event);
2341
+ if (failure !== void 0) {
2342
+ yield { type: "error", message: failure };
2324
2343
  throw mapOpenAICompatibleError({
2325
2344
  providerId,
2326
2345
  status: 502,
2327
- body: { error: { message: msg } },
2346
+ body: { error: { message: failure } },
2328
2347
  headers: response.headers,
2329
2348
  endpoint: "/responses"
2330
2349
  });
2331
2350
  }
2351
+ yield* acc.consume(event);
2332
2352
  }
2333
2353
  }
2334
- if (toolCalls.length > 0 && stopReason === "end_turn") stopReason = "tool_use";
2335
- return makeLlmFinish({
2336
- stopReason,
2337
- text,
2338
- toolCalls,
2339
- inputTokens,
2340
- outputTokens,
2341
- reasoningTokens,
2342
- cacheReadTokens,
2343
- cacheWriteTokens
2344
- });
2354
+ return acc.finish();
2345
2355
  }
2346
2356
  };
2347
2357
 
2348
- // src/internal/llm/abort-error.ts
2349
- function abortError2(signal) {
2350
- if (signal.reason instanceof Error) return signal.reason;
2351
- return new Error(signal.reason !== void 0 ? String(signal.reason) : "aborted");
2352
- }
2353
-
2354
2358
  // src/internal/llm/retrying-client.ts
2355
2359
  var MAX_ATTEMPTS = 3;
2356
2360
  function isRetriableError(err) {
@@ -2421,7 +2425,7 @@ var RetryingLlmClient = class {
2421
2425
  async *stream(request, signal) {
2422
2426
  let lastError;
2423
2427
  for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
2424
- if (signal.aborted) throw lastError ?? abortError2(signal);
2428
+ if (signal.aborted) throw lastError ?? abortError(signal);
2425
2429
  const state = { emitted: false };
2426
2430
  try {
2427
2431
  return yield* consume(this.#inner.stream(request, signal), state);
@@ -2444,14 +2448,14 @@ var VERTEX_RULES = [
2444
2448
  test: (s, e) => s === 400 || e === "INVALID_ARGUMENT" || e === "FAILED_PRECONDITION" || e === "NOT_FOUND",
2445
2449
  code: "invalid_request"
2446
2450
  },
2447
- { test: (s, e) => s === 408 || e === "DEADLINE_EXCEEDED", code: "timeout" },
2448
- { test: (s) => s >= 500, code: "server_error" }
2451
+ { test: (s, e) => s === 408 || e === "DEADLINE_EXCEEDED", code: "timeout" }
2449
2452
  ];
2450
2453
  function classifyVertexError(args, errStatus) {
2451
2454
  for (const rule of VERTEX_RULES) {
2452
2455
  if (rule.test(args.status, errStatus)) return rule.code;
2453
2456
  }
2454
- return "unknown";
2457
+ const shared = httpStatusToErrorCode(args.status);
2458
+ return shared === "auth_failed" ? "auth_permission" : shared;
2455
2459
  }
2456
2460
  function vertexMetadata(args, code) {
2457
2461
  return buildErrorMetadata({
@@ -2476,6 +2480,9 @@ var VERTEX_ERROR_BUILDERS = {
2476
2480
  invalid_request: (args, msg) => new ConfigurationError(`Vertex validation: ${msg}`, {
2477
2481
  metadata: vertexMetadata(args, "invalid_request")
2478
2482
  }),
2483
+ quota_exceeded: (args, msg) => new RateLimitError(`Vertex quota exceeded: ${msg}`, {
2484
+ metadata: vertexMetadata(args, "quota_exceeded")
2485
+ }),
2479
2486
  timeout: (args, msg) => new NetworkError(`Vertex timeout: ${msg}`, { metadata: vertexMetadata(args, "timeout") }),
2480
2487
  server_error: (args, msg) => new NetworkError(`Vertex server error: ${msg}`, {
2481
2488
  metadata: vertexMetadata(args, "server_error")
@@ -2483,23 +2490,12 @@ var VERTEX_ERROR_BUILDERS = {
2483
2490
  unknown: (args, msg) => new UnknownAgentError(`Vertex unknown: ${msg}`, { metadata: vertexMetadata(args, "unknown") })
2484
2491
  };
2485
2492
  function mapVertexError(args) {
2486
- const parsed = parseBody2(args.body);
2493
+ const parsed = parseErrorBody(args.body);
2487
2494
  const errStatus = parsed.error?.status ?? "";
2488
2495
  const message = parsed.error?.message ?? "Vertex request failed";
2489
2496
  const code = classifyVertexError(args, errStatus);
2490
2497
  return VERTEX_ERROR_BUILDERS[code](args, message);
2491
2498
  }
2492
- function parseBody2(body) {
2493
- if (body !== null && typeof body === "object") return body;
2494
- if (typeof body === "string") {
2495
- try {
2496
- return JSON.parse(body);
2497
- } catch {
2498
- return {};
2499
- }
2500
- }
2501
- return {};
2502
- }
2503
2499
  var cachedAuthClient;
2504
2500
  var SCOPE_CLOUD_PLATFORM = "https://www.googleapis.com/auth/cloud-platform";
2505
2501
  async function resolveVertexAccessToken() {
@@ -2685,20 +2681,18 @@ function buildChain(options) {
2685
2681
  }
2686
2682
  return clients;
2687
2683
  }
2688
- function buildClient(name, routerOptions, perCallBaseUrl) {
2684
+ function buildTransport(name, routerOptions, perCallBaseUrl) {
2689
2685
  const baseProfile = getProviderProfile(name);
2690
2686
  if (baseProfile === void 0) return void 0;
2691
2687
  const profile = routerOptions.extractToolCallsFromContent === true && baseProfile.extractToolCallsFromContent !== true ? { ...baseProfile, extractToolCallsFromContent: true } : baseProfile;
2692
2688
  const resilience = routerOptions.onRateLimit !== void 0 ? { onRateLimit: routerOptions.onRateLimit } : {};
2693
2689
  const ambient = currentCredentialPool(name);
2694
2690
  if (ambient !== void 0) {
2695
- return new RetryingLlmClient(
2696
- new PoolAwareLlmClient(
2697
- ambient,
2698
- (apiKey) => selectTransport(profile, apiKey, perCallBaseUrl),
2699
- void 0,
2700
- resilience
2701
- )
2691
+ return new PoolAwareLlmClient(
2692
+ ambient,
2693
+ (apiKey) => selectTransport(profile, apiKey, perCallBaseUrl),
2694
+ void 0,
2695
+ resilience
2702
2696
  );
2703
2697
  }
2704
2698
  const poolKeys = filterPoolKeys(routerOptions.apiKeys?.[name]);
@@ -2706,6 +2700,10 @@ function buildClient(name, routerOptions, perCallBaseUrl) {
2706
2700
  if (noAuthOverride !== void 0) return noAuthOverride;
2707
2701
  return buildPoolOrSingle({ name, profile, poolKeys, routerOptions, perCallBaseUrl });
2708
2702
  }
2703
+ function buildClient(name, routerOptions, perCallBaseUrl) {
2704
+ const transport = buildTransport(name, routerOptions, perCallBaseUrl);
2705
+ return transport === void 0 ? void 0 : new RetryingLlmClient(transport);
2706
+ }
2709
2707
  function maybeBuildNoAuthTransport(profile, poolKeys, baseUrl) {
2710
2708
  if (profile.authType !== "none" || poolKeys === void 0 || poolKeys.length === 0) {
2711
2709
  return void 0;
@@ -2724,18 +2722,16 @@ function buildPoolOrSingle(args) {
2724
2722
  );
2725
2723
  const pool = new CredentialPool(name, entries, strategy);
2726
2724
  const resilience = routerOptions.onRateLimit !== void 0 ? { onRateLimit: routerOptions.onRateLimit } : {};
2727
- return new RetryingLlmClient(
2728
- new PoolAwareLlmClient(
2729
- pool,
2730
- (apiKey2) => selectTransport(profile, apiKey2, perCallBaseUrl),
2731
- void 0,
2732
- resilience
2733
- )
2725
+ return new PoolAwareLlmClient(
2726
+ pool,
2727
+ (apiKey2) => selectTransport(profile, apiKey2, perCallBaseUrl),
2728
+ void 0,
2729
+ resilience
2734
2730
  );
2735
2731
  }
2736
2732
  const apiKey = poolKeys?.[0] ?? resolveApiKey(profile.envVars) ?? sentinelForNoAuth(profile) ?? sentinelForLazyAuth(profile);
2737
2733
  if (apiKey === void 0) return void 0;
2738
- return new RetryingLlmClient(selectTransport(profile, apiKey, perCallBaseUrl));
2734
+ return selectTransport(profile, apiKey, perCallBaseUrl);
2739
2735
  }
2740
2736
  function resolveBaseUrlEnvOverride(providerName) {
2741
2737
  switch (providerName) {
@@ -2804,7 +2800,7 @@ function selectTransport(profile, apiKey, baseUrl) {
2804
2800
  const ctx = { apiKey };
2805
2801
  return { fetch: profile.transform.fetch?.(ctx), headers: profile.transform.headers?.(ctx) };
2806
2802
  };
2807
- const comTransform = (opts, construct) => {
2803
+ const withTransform = (opts, construct) => {
2808
2804
  const t = applyTransform();
2809
2805
  assertOAuthResolved(t);
2810
2806
  if (t.fetch !== void 0) opts.fetch = t.fetch;
@@ -2841,7 +2837,7 @@ function selectTransport(profile, apiKey, baseUrl) {
2841
2837
  const envOverride = resolveBaseUrlEnvOverride(profile.name);
2842
2838
  if (envOverride !== void 0) opts.baseUrl = envOverride;
2843
2839
  if (baseUrl !== void 0) opts.baseUrl = baseUrl;
2844
- return comTransform(opts, (o) => new OpenAIClient(o));
2840
+ return withTransform(opts, (o) => new OpenAIClient(o));
2845
2841
  }
2846
2842
  if (profile.apiMode === "anthropic_messages") {
2847
2843
  if (profile.name === "vertex") {
@@ -2850,7 +2846,7 @@ function selectTransport(profile, apiKey, baseUrl) {
2850
2846
  }
2851
2847
  const opts = { apiKey };
2852
2848
  opts.baseUrl = baseUrl ?? process.env.ANTHROPIC_API_BASE_URL ?? profile.baseUrl;
2853
- return comTransform(opts, (o) => new AnthropicClient(o));
2849
+ return withTransform(opts, (o) => new AnthropicClient(o));
2854
2850
  }
2855
2851
  if (profile.apiMode === "bedrock_anthropic") {
2856
2852
  const realKey = apiKey === "__bedrock_lazy_token__" ? void 0 : apiKey;
@@ -2876,11 +2872,166 @@ function selectTransport(profile, apiKey, baseUrl) {
2876
2872
  });
2877
2873
  }
2878
2874
  throw new ConfigurationError(
2879
- `Provider "${profile.name}" requires apiMode "${profile.apiMode}" but no transport is registered. Install a third-party transport plugin (@theokit-transport-${profile.apiMode}) or use a provider with apiMode "chat_completions" or "anthropic_messages".`,
2875
+ `Provider "${profile.name}" declares apiMode "${profile.apiMode}", which this SDK has no transport for. Transports are built in and cannot be extended by a plugin; the supported modes are "chat_completions", "anthropic_messages", "bedrock_anthropic" and "responses_api". Change the provider's apiMode to one of those, or open an issue if the provider genuinely speaks a fifth protocol.`,
2880
2876
  { code: "transport_unavailable" }
2881
2877
  );
2882
2878
  }
2883
2879
 
2880
+ // src/internal/auth/api-key-validator.ts
2881
+ var FIXTURE_KEY_PREFIX = "theo_test_";
2882
+ var LOCAL_RUNTIME_MOCK_KEY = "local";
2883
+ var MIN_KEY_LENGTH = 16;
2884
+ var KNOWN_PROVIDER_PREFIXES = [
2885
+ { provider: "openai", prefix: "sk-" },
2886
+ { provider: "anthropic", prefix: "sk-ant-" },
2887
+ { provider: "openrouter", prefix: "sk-or-" }
2888
+ ];
2889
+ function validateApiKeyShape(key, options = {}) {
2890
+ const opts = typeof options === "string" ? { provider: options } : options;
2891
+ const tier1 = checkTier1(key);
2892
+ if (tier1.malformed) return tier1;
2893
+ const validKey = key;
2894
+ if (validKey.startsWith(FIXTURE_KEY_PREFIX) || validKey === LOCAL_RUNTIME_MOCK_KEY) {
2895
+ return { malformed: false };
2896
+ }
2897
+ if (opts.strict === false) return { malformed: false };
2898
+ return checkTier2(validKey, opts.provider);
2899
+ }
2900
+ function checkTier1(key) {
2901
+ if (key === void 0 || key.length === 0) {
2902
+ return { malformed: true, reason: "empty", message: "API key is empty." };
2903
+ }
2904
+ if (key.trim().length === 0) {
2905
+ return {
2906
+ malformed: true,
2907
+ reason: "whitespace_only",
2908
+ message: "API key contains only whitespace."
2909
+ };
2910
+ }
2911
+ if (key.length < 4) {
2912
+ return {
2913
+ malformed: true,
2914
+ reason: "too_short",
2915
+ message: `API key must be at least 4 chars (got ${key.length}).`
2916
+ };
2917
+ }
2918
+ return { malformed: false };
2919
+ }
2920
+ function checkTier2(key, provider) {
2921
+ if (key.length < MIN_KEY_LENGTH) {
2922
+ return {
2923
+ malformed: true,
2924
+ reason: "too_short",
2925
+ message: `API key must be at least ${MIN_KEY_LENGTH} chars (got ${key.length}).`
2926
+ };
2927
+ }
2928
+ if (/\s/.test(key)) {
2929
+ return {
2930
+ malformed: true,
2931
+ reason: "embedded_whitespace",
2932
+ message: "API key contains embedded whitespace."
2933
+ };
2934
+ }
2935
+ return checkProviderPrefix(key, provider);
2936
+ }
2937
+ function checkProviderPrefix(key, provider) {
2938
+ if (provider === void 0) return { malformed: false };
2939
+ const hint = KNOWN_PROVIDER_PREFIXES.find((p) => p.provider === provider.toLowerCase());
2940
+ if (hint === void 0) return { malformed: false };
2941
+ if (!key.startsWith(hint.prefix)) {
2942
+ return {
2943
+ malformed: true,
2944
+ reason: "missing_known_prefix",
2945
+ message: `API key for provider "${hint.provider}" expected to start with "${hint.prefix}".`
2946
+ };
2947
+ }
2948
+ return { malformed: false };
2949
+ }
2950
+
2951
+ // src/internal/providers/register-plugin-providers.ts
2952
+ function registerPluginProviderProfiles(entries) {
2953
+ let registered = 0;
2954
+ for (const entry of entries) {
2955
+ registerProvider(entry.profile);
2956
+ registered += 1;
2957
+ }
2958
+ return registered;
2959
+ }
2960
+ var PROVIDER_CREDENTIAL_ENV_VARS = [
2961
+ "ANTHROPIC_API_KEY",
2962
+ "OPENAI_API_KEY",
2963
+ "OPENROUTER_API_KEY"
2964
+ ];
2965
+ function presentProviderCredentialEnvVars() {
2966
+ return PROVIDER_CREDENTIAL_ENV_VARS.filter((name) => {
2967
+ const value = process.env[name];
2968
+ return typeof value === "string" && value.length > 0;
2969
+ });
2970
+ }
2971
+ var AMBIENT_STORE = {
2972
+ home: homedir(),
2973
+ dirName: ".theokit",
2974
+ fileName: "auth.json",
2975
+ homeEnvVar: "THEOKIT_AUTH_HOME"
2976
+ };
2977
+ function isStoredOAuthAvailable(env = process.env) {
2978
+ try {
2979
+ return readStoredOAuth(AMBIENT_STORE, env) !== void 0;
2980
+ } catch {
2981
+ return false;
2982
+ }
2983
+ }
2984
+ function isAwsBedrockAuthAvailable() {
2985
+ if (typeof process.env.AWS_BEARER_TOKEN_BEDROCK === "string" && process.env.AWS_BEARER_TOKEN_BEDROCK.length > 0) {
2986
+ return true;
2987
+ }
2988
+ if (typeof process.env.AWS_ACCESS_KEY_ID === "string" && process.env.AWS_ACCESS_KEY_ID.length > 0) {
2989
+ return true;
2990
+ }
2991
+ if (typeof process.env.AWS_PROFILE === "string" && process.env.AWS_PROFILE.length > 0) {
2992
+ return true;
2993
+ }
2994
+ return awsCredentialsFileExists();
2995
+ }
2996
+ function awsCredentialsFileExists() {
2997
+ try {
2998
+ const home = process.env.HOME ?? process.env.USERPROFILE;
2999
+ if (home === void 0 || home.length === 0) return false;
3000
+ return existsSync(`${home}/.aws/credentials`) || existsSync(`${home}/.aws/config`);
3001
+ } catch {
3002
+ return false;
3003
+ }
3004
+ }
3005
+ function isGcpVertexAuthAvailable() {
3006
+ if (typeof process.env.GOOGLE_APPLICATION_CREDENTIALS === "string" && process.env.GOOGLE_APPLICATION_CREDENTIALS.length > 0) {
3007
+ return true;
3008
+ }
3009
+ if (typeof process.env.GOOGLE_CLOUD_PROJECT === "string" && process.env.GOOGLE_CLOUD_PROJECT.length > 0) {
3010
+ return true;
3011
+ }
3012
+ return false;
3013
+ }
3014
+ function isLocalNoAuthProviderAvailable() {
3015
+ return true;
3016
+ }
3017
+
3018
+ // src/internal/runtime/fixtures/fixture-mode.ts
3019
+ var FIXTURE_API_KEY_PREFIX = "theo_test_";
3020
+ function isFixtureApiKey(apiKey) {
3021
+ if (apiKey === void 0) return false;
3022
+ return apiKey.startsWith(FIXTURE_API_KEY_PREFIX);
3023
+ }
3024
+ function shouldUseFixtureMode(apiKey) {
3025
+ if (getConfiguredBaseUrl() !== void 0) return false;
3026
+ return isFixtureApiKey(apiKey);
3027
+ }
3028
+ function shouldUseRealLocalRuntime(apiKey) {
3029
+ if (isFixtureApiKey(apiKey)) return false;
3030
+ if (isStoredOAuthAvailable()) return true;
3031
+ if (apiKey === void 0 || apiKey.length === 0) return false;
3032
+ return presentProviderCredentialEnvVars().length > 0 || isAwsBedrockAuthAvailable() || isGcpVertexAuthAvailable() || isLocalNoAuthProviderAvailable();
3033
+ }
3034
+
2884
3035
  // src/internal/local-agent/real-local-run-provider.ts
2885
3036
  function inferProviderFromApiKey(apiKey) {
2886
3037
  const provider = providerFromApiKeyPrefix(apiKey);
@@ -2910,6 +3061,32 @@ function warnProviderPrecedenceOnce(asked, used) {
2910
3061
  `
2911
3062
  );
2912
3063
  }
3064
+ var pluginProvidersAnnounced = false;
3065
+ function resolveRunProvider(options) {
3066
+ registerBuiltins();
3067
+ const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
3068
+ const registered = registerPluginProviderProfiles(profiles);
3069
+ if (registered > 0 && !pluginProvidersAnnounced) {
3070
+ pluginProvidersAnnounced = true;
3071
+ const names = profiles.map((e) => e.profile.name).join(", ");
3072
+ diag(`[theokit-sdk] registered ${registered} plugin provider profile(s): ${names}
3073
+ `);
3074
+ }
3075
+ const parsedModel = parseModelId(options.model?.id);
3076
+ const modelInferredProvider = parsedModel.provider !== void 0 && getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
3077
+ const keyInferredProvider = inferProviderFromApiKey(options.agentOptions.apiKey);
3078
+ const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? detectPrimaryProvider();
3079
+ warnProviderPrecedenceOnce(modelInferredProvider, primary);
3080
+ const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
3081
+ return { primary, effectiveModelId };
3082
+ }
3083
+ function mergeExplicitApiKey(pools, primary, apiKey) {
3084
+ if (apiKey === void 0 || apiKey.length === 0) return pools;
3085
+ if (isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
3086
+ const existing = pools?.[primary];
3087
+ if (existing !== void 0 && existing.length > 0) return pools;
3088
+ return { ...pools ?? {}, [primary]: [apiKey] };
3089
+ }
2913
3090
 
2914
3091
  // src/internal/runtime/compression/compression-model-registry.ts
2915
3092
  var EXACT_REGISTRY = /* @__PURE__ */ new Map([
@@ -2946,12 +3123,13 @@ var WILDCARD_REGISTRY = [
2946
3123
  ["bedrock/anthropic.claude-3-5-sonnet*", "bedrock/anthropic.claude-3-5-haiku*"]
2947
3124
  ];
2948
3125
  var NO_AUTH_PROVIDERS = /* @__PURE__ */ new Set(["ollama", "lmstudio", "llamacpp"]);
2949
- var CompressionModelUnresolvedError = class extends Error {
3126
+ var CompressionModelUnresolvedError = class extends TheokitAgentError {
2950
3127
  name = "CompressionModelUnresolvedError";
2951
3128
  agentModel;
2952
3129
  constructor(agentModel) {
2953
3130
  super(
2954
- `Could not resolve a same-family-cheaper-tier compression model for "${agentModel}". Provide Agent.create({compression: {model: "<your-cheaper-model>"}}) OR add "${agentModel}" to the compression-model-registry (see ADR D440).`
3131
+ `Could not resolve a same-family-cheaper-tier compression model for "${agentModel}". Provide Agent.create({compression: {model: "<your-cheaper-model>"}}) OR add "${agentModel}" to the compression-model-registry (see ADR D440).`,
3132
+ { code: "compression_model_unresolved", isRetryable: false }
2955
3133
  );
2956
3134
  this.agentModel = agentModel;
2957
3135
  }
@@ -2981,8 +3159,11 @@ function isNoAuthProvider(agentModel) {
2981
3159
  }
2982
3160
 
2983
3161
  // src/internal/runtime/compression/compression-summarizer.ts
2984
- var CompressionFailedError = class extends Error {
3162
+ var CompressionFailedError = class extends TheokitAgentError {
2985
3163
  name = "CompressionFailedError";
3164
+ constructor(message, options = {}) {
3165
+ super(message, { ...options, code: "compression_failed", isRetryable: true });
3166
+ }
2986
3167
  };
2987
3168
  function buildCompressionPrompt(messages) {
2988
3169
  const formatted = messages.map((m) => `[${m.role}]: ${m.content}`).join("\n\n");
@@ -3131,12 +3312,10 @@ function shouldAutoCompact(opts) {
3131
3312
  if (opts.usageTotal <= 0 || opts.contextWindow <= 0) return false;
3132
3313
  return opts.usageTotal >= Math.floor(opts.contextWindow * 9 / 10);
3133
3314
  }
3134
- var autoCompactAttempts = (() => {
3135
- const g = globalThis;
3136
- const sym = /* @__PURE__ */ Symbol.for("theokit-sdk.session.auto-compact-attempts");
3137
- if (g[sym] === void 0) g[sym] = /* @__PURE__ */ new Map();
3138
- return g[sym];
3139
- })();
3315
+ var autoCompactAttempts = globalSingleton(
3316
+ "theokit-sdk.session.auto-compact-attempts",
3317
+ () => /* @__PURE__ */ new Map()
3318
+ );
3140
3319
  async function autoCompactIfNeeded(opts) {
3141
3320
  if (!shouldAutoCompact(opts)) return false;
3142
3321
  const key = `${opts.loc.cwd}::${opts.loc.agentId}`;
@@ -3159,6 +3338,6 @@ async function autoCompactIfNeeded(opts) {
3159
3338
  }
3160
3339
  }
3161
3340
 
3162
- export { COMPACT_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, CircuitBreaker, autoCompactIfNeeded, buildDefaultSummarizer, compactSessionTranscript, detectPrimaryProvider, discoverProviderPlugins, getConfiguredBaseUrl, httpRequest, inferProviderFromApiKey, isCompactSummary, isFixtureApiKey, mapOllamaHttpError, mapOllamaTransportError, parseSseStream, presentProviderCredentialEnvVars, readErrorResponseBody, relayStream, renderToolResultContentText, resolveProviderChain, resolveSummarizerRoute, shouldAutoCompact, shouldUseFixtureMode, shouldUseRealLocalRuntime, tryFirstEvent, warnProviderPrecedenceOnce };
3163
- //# sourceMappingURL=chunk-DN2PACRI.js.map
3164
- //# sourceMappingURL=chunk-DN2PACRI.js.map
3341
+ export { COMPACT_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, CircuitBreaker, abortError, autoCompactIfNeeded, buildDefaultSummarizer, compactSessionTranscript, discoverProviderPlugins, getConfiguredBaseUrl, httpRequest, isCompactSummary, isFixtureApiKey, mapOllamaHttpError, mapOllamaTransportError, mergeExplicitApiKey, parseSseStream, presentProviderCredentialEnvVars, readErrorResponseBody, relayStream, renderToolResultContentText, resolveProviderChain, resolveRunProvider, resolveSummarizerRoute, shouldAutoCompact, shouldUseFixtureMode, shouldUseRealLocalRuntime, tryFirstEvent, validateApiKeyShape };
3342
+ //# sourceMappingURL=chunk-K3NH62DG.js.map
3343
+ //# sourceMappingURL=chunk-K3NH62DG.js.map