@theokit/sdk 4.39.4 → 4.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +2 -2
  3. package/dist/agent-35MGOZVH.js +46 -0
  4. package/dist/{agent-UNWZCXBS.js.map → agent-35MGOZVH.js.map} +1 -1
  5. package/dist/agent-6C2ODKFU.cjs +55 -0
  6. package/dist/{agent-DB245YMC.cjs.map → agent-6C2ODKFU.cjs.map} +1 -1
  7. package/dist/{agent-ZCZa7YQv.d.ts → agent-BiCINq25.d.ts} +2 -2
  8. package/dist/{agent-D7bRK9Kg.d.cts → agent-Zta1kvGH.d.cts} +2 -2
  9. package/dist/agent-session-store-EPUERCUU.cjs +23 -0
  10. package/dist/{agent-session-store-RHTLZ5OX.cjs.map → agent-session-store-EPUERCUU.cjs.map} +1 -1
  11. package/dist/agent-session-store-TXP5ZVOD.js +6 -0
  12. package/dist/{agent-session-store-EGTTYSKS.js.map → agent-session-store-TXP5ZVOD.js.map} +1 -1
  13. package/dist/auth/index.cjs +19 -15
  14. package/dist/auth/index.d.cts +1 -1
  15. package/dist/auth/index.d.ts +1 -1
  16. package/dist/auth/index.js +4 -4
  17. package/dist/{batch-WX2HLXX2.js → batch-OUF4N2TM.js} +9 -9
  18. package/dist/{batch-WX2HLXX2.js.map → batch-OUF4N2TM.js.map} +1 -1
  19. package/dist/{batch-FO2KZN7W.cjs → batch-URTEXK77.cjs} +26 -26
  20. package/dist/{batch-FO2KZN7W.cjs.map → batch-URTEXK77.cjs.map} +1 -1
  21. package/dist/{chunk-PDOLUFGY.cjs → chunk-27DYRARU.cjs} +4 -4
  22. package/dist/{chunk-PDOLUFGY.cjs.map → chunk-27DYRARU.cjs.map} +1 -1
  23. package/dist/{chunk-LYD3ALDT.js → chunk-2S6B5B2A.js} +5 -5
  24. package/dist/{chunk-LYD3ALDT.js.map → chunk-2S6B5B2A.js.map} +1 -1
  25. package/dist/{chunk-VTDQRUAJ.js → chunk-2WB6EIYW.js} +4 -4
  26. package/dist/{chunk-VTDQRUAJ.js.map → chunk-2WB6EIYW.js.map} +1 -1
  27. package/dist/{chunk-3CAQCFVZ.js → chunk-35NFZ7QB.js} +3 -3
  28. package/dist/{chunk-3CAQCFVZ.js.map → chunk-35NFZ7QB.js.map} +1 -1
  29. package/dist/{chunk-HCRCNI7A.js → chunk-3KY7MHR4.js} +3 -3
  30. package/dist/{chunk-HCRCNI7A.js.map → chunk-3KY7MHR4.js.map} +1 -1
  31. package/dist/{chunk-BURYFNOM.cjs → chunk-4JBHSLQO.cjs} +2 -2
  32. package/dist/chunk-4JBHSLQO.cjs.map +1 -0
  33. package/dist/{chunk-V7CA3CX5.cjs → chunk-4JRRFRV4.cjs} +5 -4
  34. package/dist/chunk-4JRRFRV4.cjs.map +1 -0
  35. package/dist/{chunk-5KOW3GLE.js → chunk-4QEC4CCS.js} +2 -2
  36. package/dist/chunk-4QEC4CCS.js.map +1 -0
  37. package/dist/{chunk-ALDFVGQQ.cjs → chunk-57KX5WTP.cjs} +9 -9
  38. package/dist/{chunk-ALDFVGQQ.cjs.map → chunk-57KX5WTP.cjs.map} +1 -1
  39. package/dist/{chunk-CJHBSSAF.cjs → chunk-64TJCXY5.cjs} +15 -15
  40. package/dist/{chunk-CJHBSSAF.cjs.map → chunk-64TJCXY5.cjs.map} +1 -1
  41. package/dist/{chunk-IEKSEAIV.js → chunk-6FSQ3CHQ.js} +3 -3
  42. package/dist/{chunk-IEKSEAIV.js.map → chunk-6FSQ3CHQ.js.map} +1 -1
  43. package/dist/{chunk-ZVQJHY4Y.cjs → chunk-6W4U2G3J.cjs} +5 -5
  44. package/dist/{chunk-ZVQJHY4Y.cjs.map → chunk-6W4U2G3J.cjs.map} +1 -1
  45. package/dist/{chunk-FMDZZRYE.cjs → chunk-6X2HUT4A.cjs} +8 -8
  46. package/dist/{chunk-FMDZZRYE.cjs.map → chunk-6X2HUT4A.cjs.map} +1 -1
  47. package/dist/{chunk-X2LDDKFM.cjs → chunk-7PESI6YD.cjs} +10 -10
  48. package/dist/{chunk-X2LDDKFM.cjs.map → chunk-7PESI6YD.cjs.map} +1 -1
  49. package/dist/{chunk-EYUZZXHZ.js → chunk-AF4BBKIF.js} +4 -4
  50. package/dist/chunk-AF4BBKIF.js.map +1 -0
  51. package/dist/{chunk-7GFX45DD.js → chunk-AM2CNBKE.js} +2 -2
  52. package/dist/chunk-AM2CNBKE.js.map +1 -0
  53. package/dist/{chunk-XKGOIGTJ.js → chunk-AZ6FKDQR.js} +3 -3
  54. package/dist/{chunk-XKGOIGTJ.js.map → chunk-AZ6FKDQR.js.map} +1 -1
  55. package/dist/{chunk-WPZTYOUX.cjs → chunk-BBZYXVLZ.cjs} +2 -2
  56. package/dist/chunk-BBZYXVLZ.cjs.map +1 -0
  57. package/dist/{chunk-P3ZVI46Y.js → chunk-BHWHE453.js} +5 -5
  58. package/dist/{chunk-P3ZVI46Y.js.map → chunk-BHWHE453.js.map} +1 -1
  59. package/dist/{chunk-LY4KEOOY.cjs → chunk-BRHRQOJA.cjs} +4 -4
  60. package/dist/{chunk-LY4KEOOY.cjs.map → chunk-BRHRQOJA.cjs.map} +1 -1
  61. package/dist/{chunk-4H2QARXM.cjs → chunk-BV42CCRP.cjs} +7 -7
  62. package/dist/{chunk-4H2QARXM.cjs.map → chunk-BV42CCRP.cjs.map} +1 -1
  63. package/dist/{chunk-SGGH3B2W.js → chunk-DCKIS53K.js} +63 -52
  64. package/dist/chunk-DCKIS53K.js.map +1 -0
  65. package/dist/{chunk-SKWVAQAY.js → chunk-DEZ75ET5.js} +3 -3
  66. package/dist/{chunk-SKWVAQAY.js.map → chunk-DEZ75ET5.js.map} +1 -1
  67. package/dist/{chunk-WJOLIPEM.js → chunk-EON4YTR6.js} +8 -8
  68. package/dist/{chunk-WJOLIPEM.js.map → chunk-EON4YTR6.js.map} +1 -1
  69. package/dist/{chunk-MI3OKONE.js → chunk-F4RUADRC.js} +3 -3
  70. package/dist/{chunk-MI3OKONE.js.map → chunk-F4RUADRC.js.map} +1 -1
  71. package/dist/{chunk-SHQEZ6Q2.cjs → chunk-F5DSDDBY.cjs} +323 -312
  72. package/dist/chunk-F5DSDDBY.cjs.map +1 -0
  73. package/dist/{chunk-SEWAPWAF.cjs → chunk-FMIKUGF2.cjs} +124 -124
  74. package/dist/chunk-FMIKUGF2.cjs.map +1 -0
  75. package/dist/{chunk-XZ7PO2FM.js → chunk-FRQ6F44U.js} +4 -4
  76. package/dist/{chunk-XZ7PO2FM.js.map → chunk-FRQ6F44U.js.map} +1 -1
  77. package/dist/{chunk-3LK3ZDL5.cjs → chunk-FZ4YMZA3.cjs} +5 -5
  78. package/dist/{chunk-3LK3ZDL5.cjs.map → chunk-FZ4YMZA3.cjs.map} +1 -1
  79. package/dist/{chunk-MM2JKFQV.cjs → chunk-GC44RATP.cjs} +10 -10
  80. package/dist/{chunk-MM2JKFQV.cjs.map → chunk-GC44RATP.cjs.map} +1 -1
  81. package/dist/{chunk-LNTQRD23.cjs → chunk-GH52NOCL.cjs} +26 -26
  82. package/dist/chunk-GH52NOCL.cjs.map +1 -0
  83. package/dist/{chunk-T6KFGMNY.cjs → chunk-GLEKLAUW.cjs} +12 -12
  84. package/dist/chunk-GLEKLAUW.cjs.map +1 -0
  85. package/dist/{chunk-UIPTINIF.js → chunk-GNMPCZNN.js} +6 -6
  86. package/dist/chunk-GNMPCZNN.js.map +1 -0
  87. package/dist/{chunk-K6TWHNT4.cjs → chunk-HECR7KF5.cjs} +11 -11
  88. package/dist/{chunk-K6TWHNT4.cjs.map → chunk-HECR7KF5.cjs.map} +1 -1
  89. package/dist/{chunk-NHXPQN44.js → chunk-HK4HRLWE.js} +3 -3
  90. package/dist/{chunk-NHXPQN44.js.map → chunk-HK4HRLWE.js.map} +1 -1
  91. package/dist/{chunk-LWVKI75U.js → chunk-HKSSM5RK.js} +3 -3
  92. package/dist/{chunk-LWVKI75U.js.map → chunk-HKSSM5RK.js.map} +1 -1
  93. package/dist/{chunk-ELYGL52R.cjs → chunk-HLNLYLNN.cjs} +4 -4
  94. package/dist/{chunk-ELYGL52R.cjs.map → chunk-HLNLYLNN.cjs.map} +1 -1
  95. package/dist/{chunk-ONVIALVV.js → chunk-IMX5YODO.js} +15 -15
  96. package/dist/chunk-IMX5YODO.js.map +1 -0
  97. package/dist/{chunk-C64E2EJS.js → chunk-J5RW43IR.js} +4 -4
  98. package/dist/{chunk-C64E2EJS.js.map → chunk-J5RW43IR.js.map} +1 -1
  99. package/dist/{chunk-4E3HLSYE.cjs → chunk-JA4FEA5Z.cjs} +4 -4
  100. package/dist/{chunk-4E3HLSYE.cjs.map → chunk-JA4FEA5Z.cjs.map} +1 -1
  101. package/dist/{chunk-EJNFZET4.cjs → chunk-JO76RWCA.cjs} +11 -11
  102. package/dist/{chunk-EJNFZET4.cjs.map → chunk-JO76RWCA.cjs.map} +1 -1
  103. package/dist/{chunk-QMIG7TKG.cjs → chunk-KCQUYQ3V.cjs} +17 -17
  104. package/dist/chunk-KCQUYQ3V.cjs.map +1 -0
  105. package/dist/{chunk-AKMPQJPX.js → chunk-L4JFQCG4.js} +5 -5
  106. package/dist/chunk-L4JFQCG4.js.map +1 -0
  107. package/dist/{chunk-HJMFPIRM.js → chunk-LLE7HPRI.js} +5 -5
  108. package/dist/{chunk-HJMFPIRM.js.map → chunk-LLE7HPRI.js.map} +1 -1
  109. package/dist/{chunk-4H2DCO6P.js → chunk-LXKNENHK.js} +3 -3
  110. package/dist/{chunk-4H2DCO6P.js.map → chunk-LXKNENHK.js.map} +1 -1
  111. package/dist/{chunk-PY7G7YWK.cjs → chunk-MMZX557L.cjs} +5 -5
  112. package/dist/{chunk-PY7G7YWK.cjs.map → chunk-MMZX557L.cjs.map} +1 -1
  113. package/dist/{chunk-VQ33XLC6.js → chunk-MRKSSN36.js} +3 -3
  114. package/dist/{chunk-VQ33XLC6.js.map → chunk-MRKSSN36.js.map} +1 -1
  115. package/dist/{chunk-33B2BSME.cjs → chunk-NETYW4V3.cjs} +13 -5
  116. package/dist/chunk-NETYW4V3.cjs.map +1 -0
  117. package/dist/{chunk-OVGNXGCK.cjs → chunk-NNNUQELM.cjs} +9 -9
  118. package/dist/{chunk-OVGNXGCK.cjs.map → chunk-NNNUQELM.cjs.map} +1 -1
  119. package/dist/{chunk-BM7VYZED.js → chunk-NOM2YWFP.js} +5 -5
  120. package/dist/{chunk-BM7VYZED.js.map → chunk-NOM2YWFP.js.map} +1 -1
  121. package/dist/{chunk-WMWZAJMJ.cjs → chunk-NRA36JKG.cjs} +11 -11
  122. package/dist/{chunk-WMWZAJMJ.cjs.map → chunk-NRA36JKG.cjs.map} +1 -1
  123. package/dist/{chunk-4HKAZRTC.js → chunk-O3IZ7JEL.js} +3 -3
  124. package/dist/{chunk-4HKAZRTC.js.map → chunk-O3IZ7JEL.js.map} +1 -1
  125. package/dist/{chunk-RHQJX3EI.cjs → chunk-OEFFPR2S.cjs} +4 -4
  126. package/dist/{chunk-RHQJX3EI.cjs.map → chunk-OEFFPR2S.cjs.map} +1 -1
  127. package/dist/{chunk-4GGXF7YM.js → chunk-OLLOUAUJ.js} +3 -3
  128. package/dist/{chunk-4GGXF7YM.js.map → chunk-OLLOUAUJ.js.map} +1 -1
  129. package/dist/{chunk-RA2UZBYP.js → chunk-PAV4ZPSW.js} +3 -3
  130. package/dist/{chunk-RA2UZBYP.js.map → chunk-PAV4ZPSW.js.map} +1 -1
  131. package/dist/{chunk-RNCN2TTP.js → chunk-PBML2FHN.js} +2 -2
  132. package/dist/{chunk-A76OFN2B.cjs.map → chunk-PBML2FHN.js.map} +1 -1
  133. package/dist/{chunk-XRKFWV7K.js → chunk-PYM5OUL4.js} +5 -5
  134. package/dist/{chunk-XRKFWV7K.js.map → chunk-PYM5OUL4.js.map} +1 -1
  135. package/dist/{chunk-F4SQTWVR.js → chunk-Q4DTGCSD.js} +3 -3
  136. package/dist/{chunk-F4SQTWVR.js.map → chunk-Q4DTGCSD.js.map} +1 -1
  137. package/dist/{chunk-S7OEXQMI.cjs → chunk-R3CKCRK3.cjs} +4 -4
  138. package/dist/{chunk-S7OEXQMI.cjs.map → chunk-R3CKCRK3.cjs.map} +1 -1
  139. package/dist/{chunk-5COPO3H4.cjs → chunk-RBQYHEZD.cjs} +4 -4
  140. package/dist/{chunk-5COPO3H4.cjs.map → chunk-RBQYHEZD.cjs.map} +1 -1
  141. package/dist/{chunk-KRPEPZQY.js → chunk-RJBHWM6D.js} +7 -7
  142. package/dist/chunk-RJBHWM6D.js.map +1 -0
  143. package/dist/{chunk-U53AYSHS.cjs → chunk-S4Q5OMIK.cjs} +11 -11
  144. package/dist/{chunk-U53AYSHS.cjs.map → chunk-S4Q5OMIK.cjs.map} +1 -1
  145. package/dist/{chunk-FUP3ZA5T.js → chunk-SNKY3C2L.js} +4 -4
  146. package/dist/{chunk-FUP3ZA5T.js.map → chunk-SNKY3C2L.js.map} +1 -1
  147. package/dist/{chunk-BBMN4O6E.js → chunk-TJRPNBY5.js} +4 -4
  148. package/dist/{chunk-BBMN4O6E.js.map → chunk-TJRPNBY5.js.map} +1 -1
  149. package/dist/{chunk-27E4EMR6.cjs → chunk-UJMEWGO6.cjs} +4 -4
  150. package/dist/{chunk-27E4EMR6.cjs.map → chunk-UJMEWGO6.cjs.map} +1 -1
  151. package/dist/{chunk-X627TO3A.js → chunk-UTYCG4RB.js} +12 -12
  152. package/dist/chunk-UTYCG4RB.js.map +1 -0
  153. package/dist/{chunk-5XPKYDK7.js → chunk-VQFSEKU5.js} +12 -5
  154. package/dist/chunk-VQFSEKU5.js.map +1 -0
  155. package/dist/{chunk-NJVV5OAV.cjs → chunk-WCXOKGOQ.cjs} +8 -8
  156. package/dist/chunk-WCXOKGOQ.cjs.map +1 -0
  157. package/dist/{chunk-PIBXDEZM.cjs → chunk-WIGJGFH4.cjs} +5 -5
  158. package/dist/{chunk-PIBXDEZM.cjs.map → chunk-WIGJGFH4.cjs.map} +1 -1
  159. package/dist/{chunk-LOTWA65Z.cjs → chunk-X2YQP452.cjs} +11 -11
  160. package/dist/{chunk-LOTWA65Z.cjs.map → chunk-X2YQP452.cjs.map} +1 -1
  161. package/dist/{chunk-ZAKTZ5B4.cjs → chunk-XA3TSBAH.cjs} +8 -8
  162. package/dist/{chunk-ZAKTZ5B4.cjs.map → chunk-XA3TSBAH.cjs.map} +1 -1
  163. package/dist/{chunk-H2V6CXM7.cjs → chunk-XR4LPBXH.cjs} +9 -9
  164. package/dist/{chunk-H2V6CXM7.cjs.map → chunk-XR4LPBXH.cjs.map} +1 -1
  165. package/dist/{chunk-KV3HR7KL.cjs → chunk-Y33IGXCJ.cjs} +24 -24
  166. package/dist/{chunk-KV3HR7KL.cjs.map → chunk-Y33IGXCJ.cjs.map} +1 -1
  167. package/dist/{chunk-E7WWIX34.cjs → chunk-YULF6FPB.cjs} +8 -8
  168. package/dist/{chunk-E7WWIX34.cjs.map → chunk-YULF6FPB.cjs.map} +1 -1
  169. package/dist/{chunk-23HI77BZ.js → chunk-Z6N6SDNR.js} +4 -4
  170. package/dist/chunk-Z6N6SDNR.js.map +1 -0
  171. package/dist/{chunk-A76OFN2B.cjs → chunk-ZHPET3LZ.cjs} +2 -2
  172. package/dist/chunk-ZHPET3LZ.cjs.map +1 -0
  173. package/dist/{chunk-5VKUZ26Q.js → chunk-ZNW2TXLO.js} +3 -3
  174. package/dist/{chunk-5VKUZ26Q.js.map → chunk-ZNW2TXLO.js.map} +1 -1
  175. package/dist/{chunk-N4JNY5DT.cjs → chunk-ZO2L5U6F.cjs} +32 -32
  176. package/dist/chunk-ZO2L5U6F.cjs.map +1 -0
  177. package/dist/{chunk-RMCHJZNZ.js → chunk-ZS6SLELQ.js} +4 -4
  178. package/dist/{chunk-RMCHJZNZ.js.map → chunk-ZS6SLELQ.js.map} +1 -1
  179. package/dist/{chunk-7PBAJ2WA.js → chunk-ZTEAJAE6.js} +3 -3
  180. package/dist/{chunk-7PBAJ2WA.js.map → chunk-ZTEAJAE6.js.map} +1 -1
  181. package/dist/compact-session-65XCKO6H.js +18 -0
  182. package/dist/{compact-session-AZU2LEAE.js.map → compact-session-65XCKO6H.js.map} +1 -1
  183. package/dist/compact-session-OU6SRPVJ.cjs +55 -0
  184. package/dist/{compact-session-TRCEYCPG.cjs.map → compact-session-OU6SRPVJ.cjs.map} +1 -1
  185. package/dist/compaction.cjs +16 -16
  186. package/dist/compaction.js +3 -3
  187. package/dist/concurrency.cjs +6 -6
  188. package/dist/concurrency.js +4 -4
  189. package/dist/context-2G4375BZ.cjs +22 -0
  190. package/dist/{context-DNFT4B5D.cjs.map → context-2G4375BZ.cjs.map} +1 -1
  191. package/dist/context-GSQYVVMJ.js +5 -0
  192. package/dist/{context-LYE6TJL5.js.map → context-GSQYVVMJ.js.map} +1 -1
  193. package/dist/{cron-D-DVjGQe.d.cts → cron-DgHJnMAK.d.cts} +2 -2
  194. package/dist/{cron-Bx7tzm5R.d.ts → cron-DyWQsEG6.d.ts} +2 -2
  195. package/dist/cron.cjs +33 -33
  196. package/dist/cron.d.cts +3 -3
  197. package/dist/cron.d.ts +3 -3
  198. package/dist/cron.js +32 -32
  199. package/dist/{errors-DjBQ4Tn8.d.ts → errors-BSoXcl3F.d.cts} +3 -3
  200. package/dist/{errors-DMY-gLSK.d.cts → errors-CHllybaU.d.ts} +3 -3
  201. package/dist/errors.cjs +21 -21
  202. package/dist/errors.d.cts +2 -2
  203. package/dist/errors.d.ts +2 -2
  204. package/dist/errors.js +2 -2
  205. package/dist/eval.cjs +43 -43
  206. package/dist/eval.cjs.map +1 -1
  207. package/dist/eval.js +33 -33
  208. package/dist/eval.js.map +1 -1
  209. package/dist/{executor-TQ3FSZ7F.cjs → executor-CB75B5BH.cjs} +24 -24
  210. package/dist/{executor-TQ3FSZ7F.cjs.map → executor-CB75B5BH.cjs.map} +1 -1
  211. package/dist/{executor-PCRX3533.js → executor-VQLTQY53.js} +7 -7
  212. package/dist/{executor-PCRX3533.js.map → executor-VQLTQY53.js.map} +1 -1
  213. package/dist/filesystem/index.cjs +7 -7
  214. package/dist/filesystem/index.js +3 -3
  215. package/dist/fs-session-store-MAZV5FXJ.cjs +19 -0
  216. package/dist/{fs-session-store-KRZZIG3O.cjs.map → fs-session-store-MAZV5FXJ.cjs.map} +1 -1
  217. package/dist/fs-session-store-ZNUYZHYI.js +10 -0
  218. package/dist/{fs-session-store-I6GUIFRO.js.map → fs-session-store-ZNUYZHYI.js.map} +1 -1
  219. package/dist/generate-object-6PWGH5DZ.cjs +20 -0
  220. package/dist/{generate-object-QILSGTEJ.cjs.map → generate-object-6PWGH5DZ.cjs.map} +1 -1
  221. package/dist/generate-object-IXMJ7FUX.js +7 -0
  222. package/dist/{generate-object-DLHT5RXH.js.map → generate-object-IXMJ7FUX.js.map} +1 -1
  223. package/dist/index-manager-X5IPG2JL.js +11 -0
  224. package/dist/{index-manager-SXF3FAQV.js.map → index-manager-X5IPG2JL.js.map} +1 -1
  225. package/dist/index-manager-YFFEPISE.cjs +20 -0
  226. package/dist/{index-manager-LEMQ73A7.cjs.map → index-manager-YFFEPISE.cjs.map} +1 -1
  227. package/dist/index.cjs +139 -139
  228. package/dist/index.cjs.map +1 -1
  229. package/dist/index.d.cts +13 -13
  230. package/dist/index.d.ts +13 -13
  231. package/dist/index.js +53 -53
  232. package/dist/index.js.map +1 -1
  233. package/dist/{inject-session-BVSERZCI.cjs → inject-session-DDC36KKP.cjs} +11 -11
  234. package/dist/{inject-session-BVSERZCI.cjs.map → inject-session-DDC36KKP.cjs.map} +1 -1
  235. package/dist/{inject-session-E75EP3LL.js → inject-session-UBM4KVSV.js} +8 -8
  236. package/dist/{inject-session-E75EP3LL.js.map → inject-session-UBM4KVSV.js.map} +1 -1
  237. package/dist/internal/auth/credential-store.d.ts +13 -0
  238. package/dist/internal/diagnostics.d.ts +2 -2
  239. package/dist/internal/error-mappers/anthropic.d.ts +1 -1
  240. package/dist/internal/eval/code-runner.d.ts +1 -1
  241. package/dist/internal/global-singleton.d.ts +1 -1
  242. package/dist/internal/judge/judge-call.d.ts +1 -1
  243. package/dist/internal/memory/adapters/index.cjs +8 -8
  244. package/dist/internal/memory/adapters/index.js +7 -7
  245. package/dist/internal/memory/embedding-adapter.d.ts +1 -1
  246. package/dist/internal/memory/memory-index.d.ts +1 -1
  247. package/dist/internal/persistence/atomic-write.d.cts +14 -1
  248. package/dist/internal/persistence/atomic-write.d.ts +14 -1
  249. package/dist/internal/persistence/index.cjs +25 -25
  250. package/dist/internal/persistence/index.js +6 -6
  251. package/dist/internal/persistence/jsonl.d.cts +2 -2
  252. package/dist/internal/persistence/jsonl.d.ts +2 -2
  253. package/dist/internal/persistence/session-artifacts.d.cts +27 -0
  254. package/dist/internal/persistence/session-artifacts.d.ts +27 -0
  255. package/dist/internal/persistence/session-transcript.d.cts +1 -1
  256. package/dist/internal/persistence/session-transcript.d.ts +1 -1
  257. package/dist/internal/runtime/lifecycle/env-policy.d.ts +1 -1
  258. package/dist/internal/security/index.cjs +13 -13
  259. package/dist/internal/security/index.js +3 -3
  260. package/dist/internal/session/agent-session.d.ts +1 -1
  261. package/dist/internal/session/compact-session.d.ts +1 -1
  262. package/dist/internal/session/session-cache.d.ts +1 -1
  263. package/dist/judge-call-3QZO5H5N.js +5 -0
  264. package/dist/{judge-call-NPRU7JIQ.js.map → judge-call-3QZO5H5N.js.map} +1 -1
  265. package/dist/judge-call-J5EETJL3.cjs +22 -0
  266. package/dist/{judge-call-AIT3EULV.cjs.map → judge-call-J5EETJL3.cjs.map} +1 -1
  267. package/dist/models.cjs +20 -20
  268. package/dist/models.cjs.map +1 -1
  269. package/dist/models.js +5 -5
  270. package/dist/models.js.map +1 -1
  271. package/dist/path-safety.cjs +10 -10
  272. package/dist/path-safety.js +3 -3
  273. package/dist/persistence.cjs +44 -30
  274. package/dist/persistence.cjs.map +1 -1
  275. package/dist/persistence.d.cts +4 -3
  276. package/dist/persistence.d.ts +4 -3
  277. package/dist/persistence.js +22 -12
  278. package/dist/persistence.js.map +1 -1
  279. package/dist/project.cjs +5 -5
  280. package/dist/project.js +3 -3
  281. package/dist/registry-KB3TS6BM.cjs +46 -0
  282. package/dist/{registry-VKDFTK6L.cjs.map → registry-KB3TS6BM.cjs.map} +1 -1
  283. package/dist/registry-PPFMCM4A.js +9 -0
  284. package/dist/{registry-AXQXPLFH.js.map → registry-PPFMCM4A.js.map} +1 -1
  285. package/dist/retry.cjs +4 -4
  286. package/dist/retry.js +3 -3
  287. package/dist/{run-i2-fUohR.d.ts → run-C8FBAC8o.d.cts} +36 -2
  288. package/dist/{run-i2-fUohR.d.cts → run-C8FBAC8o.d.ts} +36 -2
  289. package/dist/{run-until-BK56WG4P.js → run-until-HEQOUVU6.js} +2 -2
  290. package/dist/run-until-HEQOUVU6.js.map +1 -0
  291. package/dist/{run-until-L5KQD3PV.cjs → run-until-U2B5FJJI.cjs} +2 -2
  292. package/dist/run-until-U2B5FJJI.cjs.map +1 -0
  293. package/dist/sandbox/bwrap.d.cts +15 -1
  294. package/dist/sandbox/bwrap.d.ts +15 -1
  295. package/dist/sandbox/index.cjs +39 -24
  296. package/dist/sandbox/index.cjs.map +1 -1
  297. package/dist/sandbox/index.d.cts +1 -1
  298. package/dist/sandbox/index.d.ts +1 -1
  299. package/dist/sandbox/index.js +24 -10
  300. package/dist/sandbox/index.js.map +1 -1
  301. package/dist/sandbox/provision.d.cts +1 -1
  302. package/dist/sandbox/provision.d.ts +1 -1
  303. package/dist/server/errors-envelope.cjs +14 -14
  304. package/dist/server/errors-envelope.d.cts +3 -3
  305. package/dist/server/errors-envelope.d.ts +3 -3
  306. package/dist/server/errors-envelope.js +3 -3
  307. package/dist/session-transcript-7FWTO4BK.js +5 -0
  308. package/dist/{session-transcript-X3UMSVL2.js.map → session-transcript-7FWTO4BK.js.map} +1 -1
  309. package/dist/session-transcript-FYRKWRWV.cjs +50 -0
  310. package/dist/{session-transcript-SLQRKQ72.cjs.map → session-transcript-FYRKWRWV.cjs.map} +1 -1
  311. package/dist/skills.cjs +7 -7
  312. package/dist/skills.js +5 -5
  313. package/dist/stream-object-3R3HZPQN.cjs +20 -0
  314. package/dist/{stream-object-3HEUGMQY.cjs.map → stream-object-3R3HZPQN.cjs.map} +1 -1
  315. package/dist/stream-object-NPJXDZXO.js +7 -0
  316. package/dist/{stream-object-VWYW7FJ2.js.map → stream-object-NPJXDZXO.js.map} +1 -1
  317. package/dist/subagents-loader-5KQVYUNS.js +6 -0
  318. package/dist/{subagents-loader-QUIK6GMV.js.map → subagents-loader-5KQVYUNS.js.map} +1 -1
  319. package/dist/subagents-loader-FDXPBBRA.cjs +15 -0
  320. package/dist/{subagents-loader-F52ARQ62.cjs.map → subagents-loader-FDXPBBRA.cjs.map} +1 -1
  321. package/dist/subagents-loader.cjs +15 -15
  322. package/dist/subagents-loader.cjs.map +1 -1
  323. package/dist/subagents-loader.d.cts +2 -2
  324. package/dist/subagents-loader.d.ts +2 -2
  325. package/dist/subagents-loader.js +14 -14
  326. package/dist/subagents-loader.js.map +1 -1
  327. package/dist/subscription/index.cjs +3 -3
  328. package/dist/subscription/index.js +2 -2
  329. package/dist/task-store.cjs +7 -7
  330. package/dist/task-store.js +4 -4
  331. package/dist/types/run-events.d.ts +20 -1
  332. package/dist/types/run.d.ts +15 -0
  333. package/dist/types/session-record.d.ts +1 -1
  334. package/dist/types/usage.d.ts +1 -1
  335. package/dist/workflow.cjs +27 -27
  336. package/dist/workflow.js +6 -6
  337. package/docs/error-codes.md +22 -0
  338. package/docs/harness-capability-map.md +22 -0
  339. package/package.json +1 -1
  340. package/dist/agent-DB245YMC.cjs +0 -55
  341. package/dist/agent-UNWZCXBS.js +0 -46
  342. package/dist/agent-session-store-EGTTYSKS.js +0 -6
  343. package/dist/agent-session-store-RHTLZ5OX.cjs +0 -23
  344. package/dist/chunk-23HI77BZ.js.map +0 -1
  345. package/dist/chunk-33B2BSME.cjs.map +0 -1
  346. package/dist/chunk-5KOW3GLE.js.map +0 -1
  347. package/dist/chunk-5XPKYDK7.js.map +0 -1
  348. package/dist/chunk-7GFX45DD.js.map +0 -1
  349. package/dist/chunk-AKMPQJPX.js.map +0 -1
  350. package/dist/chunk-BURYFNOM.cjs.map +0 -1
  351. package/dist/chunk-EYUZZXHZ.js.map +0 -1
  352. package/dist/chunk-KRPEPZQY.js.map +0 -1
  353. package/dist/chunk-LNTQRD23.cjs.map +0 -1
  354. package/dist/chunk-N4JNY5DT.cjs.map +0 -1
  355. package/dist/chunk-NJVV5OAV.cjs.map +0 -1
  356. package/dist/chunk-ONVIALVV.js.map +0 -1
  357. package/dist/chunk-QMIG7TKG.cjs.map +0 -1
  358. package/dist/chunk-RNCN2TTP.js.map +0 -1
  359. package/dist/chunk-SEWAPWAF.cjs.map +0 -1
  360. package/dist/chunk-SGGH3B2W.js.map +0 -1
  361. package/dist/chunk-SHQEZ6Q2.cjs.map +0 -1
  362. package/dist/chunk-T6KFGMNY.cjs.map +0 -1
  363. package/dist/chunk-UIPTINIF.js.map +0 -1
  364. package/dist/chunk-V7CA3CX5.cjs.map +0 -1
  365. package/dist/chunk-WPZTYOUX.cjs.map +0 -1
  366. package/dist/chunk-X627TO3A.js.map +0 -1
  367. package/dist/compact-session-AZU2LEAE.js +0 -18
  368. package/dist/compact-session-TRCEYCPG.cjs +0 -55
  369. package/dist/context-DNFT4B5D.cjs +0 -22
  370. package/dist/context-LYE6TJL5.js +0 -5
  371. package/dist/fs-session-store-I6GUIFRO.js +0 -10
  372. package/dist/fs-session-store-KRZZIG3O.cjs +0 -19
  373. package/dist/generate-object-DLHT5RXH.js +0 -7
  374. package/dist/generate-object-QILSGTEJ.cjs +0 -20
  375. package/dist/index-manager-LEMQ73A7.cjs +0 -20
  376. package/dist/index-manager-SXF3FAQV.js +0 -11
  377. package/dist/judge-call-AIT3EULV.cjs +0 -22
  378. package/dist/judge-call-NPRU7JIQ.js +0 -5
  379. package/dist/registry-AXQXPLFH.js +0 -9
  380. package/dist/registry-VKDFTK6L.cjs +0 -46
  381. package/dist/run-until-BK56WG4P.js.map +0 -1
  382. package/dist/run-until-L5KQD3PV.cjs.map +0 -1
  383. package/dist/session-transcript-SLQRKQ72.cjs +0 -50
  384. package/dist/session-transcript-X3UMSVL2.js +0 -5
  385. package/dist/stream-object-3HEUGMQY.cjs +0 -20
  386. package/dist/stream-object-VWYW7FJ2.js +0 -7
  387. package/dist/subagents-loader-F52ARQ62.cjs +0 -15
  388. package/dist/subagents-loader-QUIK6GMV.js +0 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,75 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.41.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ea99026: Three facts the SDK already knew are now answerable, instead of being re-derived by every consumer.
8
+
9
+ - `assertSecureModes(dir, file)` — the 0700-dir / 0600-file gate, exported from `@theokit/sdk/auth`.
10
+ Its own docstring names the attack it prevents (a writable directory lets someone swap the
11
+ credential file for a symlink to their own), and that reasoning is not specific to this SDK's
12
+ credential file: consumers keep sensitive stores beside it and were reading them with no check at
13
+ all, because the gate was private.
14
+
15
+ - `writableRootsFor(mode, cwd)` — what a sandbox mode may write to, answerable WITHOUT spawning.
16
+ `buildBwrapArgv` knew it, but only while building an argv, and consumers need the answer earlier:
17
+ tools are scoped at agent construction, before any process exists. `[]` means nothing is writable;
18
+ `null` means unrestricted — not `["/"]`, because unrestricted is the absence of a root rather than
19
+ a root that happens to be `/`.
20
+
21
+ - `atomicWriteTempTarget(name)` — the file a leftover `<file>.<pid>.<hex>.tmp` was replacing.
22
+ `replaceFileAtomic` creates those and has no opinion about sweeping them, so a consumer wanting to
23
+ had to know a format that lived only in the implementation. Deliberately strict about pid digits
24
+ and a 16-char hex suffix: matching any `.tmp` would claim other tools' scratch on a path whose
25
+ purpose is deleting files.
26
+
27
+ Each is derived from the same helper its writer uses, so the answer and the behaviour cannot drift
28
+ apart. All three were measured from a consumer that had reimplemented them — one of them by copying
29
+ a regex out of a compiled chunk.
30
+
31
+ - 994808f: Emit `mcp_server_failed` on the typed run-event stream when a configured MCP server's tools cannot be listed. Additive `RunEvent` variant; the sink stays opt-in and no existing signature changed.
32
+ - 4d64479: `classifySessionArtifact(name, isDirectory)` — what a file in a project directory is, when this SDK
33
+ wrote it.
34
+
35
+ Four kinds get created here and reasoned about nowhere: `<id>.jsonl` (`transcriptPath`),
36
+ `<id>.jsonl.writer.lock` (the writer lease), `<id>.jsonl.lock` (`withFileLock`, a DIRECTORY since it
37
+ locks by `mkdir`), and `<file>.<pid>.<hex>.tmp` (`replaceFileAtomic`, left behind by a crash between
38
+ the open and the rename). There is no retention, no collector, and there was no way even to ask what
39
+ an entry is — so a consumer reclaiming disk had to re-derive the suffixes from this source, and a
40
+ suffix changing here would have left its classifier mislabelling files on a path that deletes them.
41
+
42
+ Deliberately NOT a garbage collector. Retention is policy — how many days, how many to keep, which
43
+ session is live, whether to delete at all — and the application is the only one that can answer that.
44
+ What belongs here is the half only the SDK can: what did I write, and what is it.
45
+
46
+ `undefined` means "not written by this SDK", which is the answer that matters most — a caller
47
+ deleting what it does not recognise is how someone's editor swap file gets collected. The `temp` case
48
+ defers to `atomicWriteTempTarget` rather than matching `.tmp`, for that reason.
49
+
50
+ ## 4.40.0
51
+
52
+ ### Minor Changes
53
+
54
+ - 6c6ce8c: `run.events()` now states whether a message's text already streamed, so consumers stop inferring it
55
+ by comparing text.
56
+
57
+ Unifying the timeline in 4.38.0 fixed ordering and the `callId` namespace. It did not stop the same
58
+ text arriving twice: the run's event log carries the complete assistant message, and the deltas are
59
+ additional. A consumer had to relate the two by COMPARING CONTENT — which is where the
60
+ `callId`-namespace and timestamp-fallback bugs came from.
61
+
62
+ The producer knows the answer as a fact. The SDK emits the deltas and emits the message from the
63
+ same scope, so `RunTimelineEvent` of kind `message` now carries an optional `textAlreadyStreamed`,
64
+ and the consumer's dedup becomes a boolean read instead of a text comparison.
65
+
66
+ Marked rather than suppressed: the assistant message also carries tool calls and metadata, so
67
+ dropping it would trade a duplicate for a hole. The field is optional and absent when the question
68
+ does not apply (a message with no text), so no existing `events()` consumer breaks and `stream()` is
69
+ untouched.
70
+
71
+ Closes the contract half of theokit#140.
72
+
3
73
  ## 4.39.4
4
74
 
5
75
  ### Patch Changes
package/README.md CHANGED
@@ -24,11 +24,11 @@
24
24
 
25
25
  > **Public beta.** APIs may change before general availability.
26
26
 
27
- For the full reference, see the [root README](https://github.com/usetheodev/theokit-sdk#readme) and the [**Harness Capability Map**](https://github.com/usetheodev/theokit-sdk/blob/main/docs/harness-capability-map.md). The exported TypeScript types are the canonical contract.
27
+ For the full reference, see the [root README](https://github.com/usetheodev/theokit-sdk#readme) and the [**Harness Capability Map**](https://github.com/usetheodev/theokit-sdk/blob/main/wiki/reference/harness-capability-map.md). The exported TypeScript types are the canonical contract.
28
28
 
29
29
  ## Capability map
30
30
 
31
- New here? The [**Theo Harness Capability Map**](https://github.com/usetheodev/theokit-sdk/blob/main/docs/harness-capability-map.md) is the discovery front-door — every harness primitive with its import path, signature, and a one-line example (find `compactTranscript`, `buildRepoMap`, `isTransientError`, `@theokit/sdk/persistence`, ... without reading source). The exported TypeScript types are the canonical contract.
31
+ New here? The [**Theo Harness Capability Map**](https://github.com/usetheodev/theokit-sdk/blob/main/wiki/reference/harness-capability-map.md) is the discovery front-door — every harness primitive with its import path, signature, and a one-line example (find `compactTranscript`, `buildRepoMap`, `isTransientError`, `@theokit/sdk/persistence`, ... without reading source). The exported TypeScript types are the canonical contract.
32
32
 
33
33
  It also **ships inside this package** — no network needed, and pinned to the version you installed:
34
34
 
@@ -0,0 +1,46 @@
1
+ export { Agent } from './chunk-DCKIS53K.js';
2
+ import './chunk-2SFBB54R.js';
3
+ import './chunk-GNMPCZNN.js';
4
+ import './chunk-K2BQQ445.js';
5
+ import './chunk-IMX5YODO.js';
6
+ import './chunk-PYM5OUL4.js';
7
+ import './chunk-UTYCG4RB.js';
8
+ import './chunk-F4RUADRC.js';
9
+ import './chunk-4QEC4CCS.js';
10
+ import './chunk-ZTEAJAE6.js';
11
+ import './chunk-RJBHWM6D.js';
12
+ import './chunk-J5RW43IR.js';
13
+ import './chunk-AM2CNBKE.js';
14
+ import './chunk-ZS6SLELQ.js';
15
+ import './chunk-LLE7HPRI.js';
16
+ import './chunk-SNKY3C2L.js';
17
+ import './chunk-OXNYIMZZ.js';
18
+ import './chunk-FD2UT76F.js';
19
+ import './chunk-U54XCYG3.js';
20
+ import './chunk-RP5HQVLD.js';
21
+ import './chunk-6X6ID4MO.js';
22
+ import './chunk-UJ7IQJAG.js';
23
+ import './chunk-7AD3ZTZL.js';
24
+ import './chunk-AZ6FKDQR.js';
25
+ import './chunk-Q4DTGCSD.js';
26
+ import './chunk-HKSSM5RK.js';
27
+ import './chunk-AF4BBKIF.js';
28
+ import './chunk-ZNW2TXLO.js';
29
+ import './chunk-2WB6EIYW.js';
30
+ import './chunk-2XLKLVVR.js';
31
+ import './chunk-NOM2YWFP.js';
32
+ import './chunk-4VPXM6UU.js';
33
+ import './chunk-VQFSEKU5.js';
34
+ import './chunk-TJRPNBY5.js';
35
+ import './chunk-FRQ6F44U.js';
36
+ import './chunk-X2FR4OIT.js';
37
+ import './chunk-Z6N6SDNR.js';
38
+ import './chunk-L4JFQCG4.js';
39
+ import './chunk-5NBUH3NO.js';
40
+ import './chunk-2S6B5B2A.js';
41
+ import './chunk-6FSQ3CHQ.js';
42
+ import './chunk-OLLOUAUJ.js';
43
+ import './chunk-MRKSSN36.js';
44
+ import './chunk-PBML2FHN.js';
45
+ //# sourceMappingURL=agent-35MGOZVH.js.map
46
+ //# sourceMappingURL=agent-35MGOZVH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-UNWZCXBS.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-35MGOZVH.js"}
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var chunkF5DSDDBY_cjs = require('./chunk-F5DSDDBY.cjs');
4
+ require('./chunk-BV2MWEMV.cjs');
5
+ require('./chunk-KCQUYQ3V.cjs');
6
+ require('./chunk-BUUUWQMB.cjs');
7
+ require('./chunk-ZO2L5U6F.cjs');
8
+ require('./chunk-NRA36JKG.cjs');
9
+ require('./chunk-FMIKUGF2.cjs');
10
+ require('./chunk-HLNLYLNN.cjs');
11
+ require('./chunk-4JBHSLQO.cjs');
12
+ require('./chunk-FZ4YMZA3.cjs');
13
+ require('./chunk-GH52NOCL.cjs');
14
+ require('./chunk-HECR7KF5.cjs');
15
+ require('./chunk-BBZYXVLZ.cjs');
16
+ require('./chunk-6X2HUT4A.cjs');
17
+ require('./chunk-7PESI6YD.cjs');
18
+ require('./chunk-S4Q5OMIK.cjs');
19
+ require('./chunk-2RW7K6FN.cjs');
20
+ require('./chunk-MUUQ2WFJ.cjs');
21
+ require('./chunk-6JSIEDKL.cjs');
22
+ require('./chunk-B4YA6BRS.cjs');
23
+ require('./chunk-NINIJCHU.cjs');
24
+ require('./chunk-YPEPCZHF.cjs');
25
+ require('./chunk-VJ26EKGJ.cjs');
26
+ require('./chunk-OEFFPR2S.cjs');
27
+ require('./chunk-27DYRARU.cjs');
28
+ require('./chunk-JA4FEA5Z.cjs');
29
+ require('./chunk-WCXOKGOQ.cjs');
30
+ require('./chunk-6W4U2G3J.cjs');
31
+ require('./chunk-BV42CCRP.cjs');
32
+ require('./chunk-YLQQX5W2.cjs');
33
+ require('./chunk-XR4LPBXH.cjs');
34
+ require('./chunk-WJVHMTKB.cjs');
35
+ require('./chunk-NETYW4V3.cjs');
36
+ require('./chunk-X2YQP452.cjs');
37
+ require('./chunk-NNNUQELM.cjs');
38
+ require('./chunk-VYHJZVL5.cjs');
39
+ require('./chunk-GLEKLAUW.cjs');
40
+ require('./chunk-4JRRFRV4.cjs');
41
+ require('./chunk-C6Y6CWYD.cjs');
42
+ require('./chunk-64TJCXY5.cjs');
43
+ require('./chunk-XA3TSBAH.cjs');
44
+ require('./chunk-BRHRQOJA.cjs');
45
+ require('./chunk-YULF6FPB.cjs');
46
+ require('./chunk-ZHPET3LZ.cjs');
47
+
48
+
49
+
50
+ Object.defineProperty(exports, "Agent", {
51
+ enumerable: true,
52
+ get: function () { return chunkF5DSDDBY_cjs.Agent; }
53
+ });
54
+ //# sourceMappingURL=agent-6C2ODKFU.cjs.map
55
+ //# sourceMappingURL=agent-6C2ODKFU.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-DB245YMC.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-6C2ODKFU.cjs"}
@@ -1,4 +1,4 @@
1
- import { M as ModelSelection, ad as SDKUserMessage, af as SendOptions, b as Run, G as GenerateOptions, n as GenerateRunResult, $ as RunToCompletionOptions, a0 as RunToCompletionResult, S as SDKMessage, am as StreamToCompletionResult, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-i2-fUohR.js';
1
+ import { M as ModelSelection, ad as SDKUserMessage, af as SendOptions, b as Run, G as GenerateOptions, n as GenerateRunResult, $ as RunToCompletionOptions, a0 as RunToCompletionResult, S as SDKMessage, am as StreamToCompletionResult, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-C8FBAC8o.js';
2
2
  import * as zod from 'zod';
3
3
 
4
4
  /**
@@ -36,7 +36,7 @@ type TranscriptBlock = {
36
36
  is_error?: boolean;
37
37
  };
38
38
  /**
39
- * O corpo de mensagem de um {@link SessionRecord}.
39
+ * The message body of a {@link SessionRecord}.
40
40
  *
41
41
  * **It is NOT called `SessionMessage`** — that name already exists in
42
42
  * `internal/session/session-types.ts` with the shape `{role, text}`, incompatible with this one.
@@ -1,4 +1,4 @@
1
- import { M as ModelSelection, ad as SDKUserMessage, af as SendOptions, b as Run, G as GenerateOptions, n as GenerateRunResult, $ as RunToCompletionOptions, a0 as RunToCompletionResult, S as SDKMessage, am as StreamToCompletionResult, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-i2-fUohR.cjs';
1
+ import { M as ModelSelection, ad as SDKUserMessage, af as SendOptions, b as Run, G as GenerateOptions, n as GenerateRunResult, $ as RunToCompletionOptions, a0 as RunToCompletionResult, S as SDKMessage, am as StreamToCompletionResult, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-C8FBAC8o.cjs';
2
2
  import * as zod from 'zod';
3
3
 
4
4
  /**
@@ -36,7 +36,7 @@ type TranscriptBlock = {
36
36
  is_error?: boolean;
37
37
  };
38
38
  /**
39
- * O corpo de mensagem de um {@link SessionRecord}.
39
+ * The message body of a {@link SessionRecord}.
40
40
  *
41
41
  * **It is NOT called `SessionMessage`** — that name already exists in
42
42
  * `internal/session/session-types.ts` with the shape `{role, text}`, incompatible with this one.
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var chunkFZ4YMZA3_cjs = require('./chunk-FZ4YMZA3.cjs');
4
+ require('./chunk-WCXOKGOQ.cjs');
5
+ require('./chunk-NETYW4V3.cjs');
6
+ require('./chunk-ZHPET3LZ.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "appendCompactBoundaryRecord", {
11
+ enumerable: true,
12
+ get: function () { return chunkFZ4YMZA3_cjs.appendCompactBoundaryRecord; }
13
+ });
14
+ Object.defineProperty(exports, "persistTurn", {
15
+ enumerable: true,
16
+ get: function () { return chunkFZ4YMZA3_cjs.persistTurn; }
17
+ });
18
+ Object.defineProperty(exports, "readSessionMessages", {
19
+ enumerable: true,
20
+ get: function () { return chunkFZ4YMZA3_cjs.readSessionMessages; }
21
+ });
22
+ //# sourceMappingURL=agent-session-store-EPUERCUU.cjs.map
23
+ //# sourceMappingURL=agent-session-store-EPUERCUU.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-session-store-RHTLZ5OX.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-session-store-EPUERCUU.cjs"}
@@ -0,0 +1,6 @@
1
+ export { appendCompactBoundaryRecord, persistTurn, readSessionMessages } from './chunk-ZTEAJAE6.js';
2
+ import './chunk-AF4BBKIF.js';
3
+ import './chunk-VQFSEKU5.js';
4
+ import './chunk-PBML2FHN.js';
5
+ //# sourceMappingURL=agent-session-store-TXP5ZVOD.js.map
6
+ //# sourceMappingURL=agent-session-store-TXP5ZVOD.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-session-store-EGTTYSKS.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-session-store-TXP5ZVOD.js"}
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkV7CA3CX5_cjs = require('../chunk-V7CA3CX5.cjs');
3
+ var chunk4JRRFRV4_cjs = require('../chunk-4JRRFRV4.cjs');
4
4
  var chunkC6Y6CWYD_cjs = require('../chunk-C6Y6CWYD.cjs');
5
- require('../chunk-E7WWIX34.cjs');
6
- require('../chunk-A76OFN2B.cjs');
5
+ require('../chunk-YULF6FPB.cjs');
6
+ require('../chunk-ZHPET3LZ.cjs');
7
7
 
8
8
  // src/internal/auth/oauth-device.ts
9
9
  var POLLING_SAFETY_MARGIN_MS = 3e3;
@@ -183,7 +183,7 @@ async function openaiDeviceLogin(config, deps, hooks) {
183
183
  "device poll returned no authorization_code"
184
184
  );
185
185
  }
186
- const tokens = await chunkV7CA3CX5_cjs.exchangeCode(
186
+ const tokens = await chunk4JRRFRV4_cjs.exchangeCode(
187
187
  config,
188
188
  { code: data.authorization_code, verifier: data.code_verifier },
189
189
  deps
@@ -227,47 +227,51 @@ function extractAccountId(tokens) {
227
227
 
228
228
  Object.defineProperty(exports, "CredentialError", {
229
229
  enumerable: true,
230
- get: function () { return chunkV7CA3CX5_cjs.CredentialError; }
230
+ get: function () { return chunk4JRRFRV4_cjs.CredentialError; }
231
+ });
232
+ Object.defineProperty(exports, "assertSecureModes", {
233
+ enumerable: true,
234
+ get: function () { return chunk4JRRFRV4_cjs.assertSecureModes; }
231
235
  });
232
236
  Object.defineProperty(exports, "authFilePath", {
233
237
  enumerable: true,
234
- get: function () { return chunkV7CA3CX5_cjs.authFilePath; }
238
+ get: function () { return chunk4JRRFRV4_cjs.authFilePath; }
235
239
  });
236
240
  Object.defineProperty(exports, "credentialHome", {
237
241
  enumerable: true,
238
- get: function () { return chunkV7CA3CX5_cjs.credentialHome; }
242
+ get: function () { return chunk4JRRFRV4_cjs.credentialHome; }
239
243
  });
240
244
  Object.defineProperty(exports, "ensureFreshCredential", {
241
245
  enumerable: true,
242
- get: function () { return chunkV7CA3CX5_cjs.ensureFreshCredential; }
246
+ get: function () { return chunk4JRRFRV4_cjs.ensureFreshCredential; }
243
247
  });
244
248
  Object.defineProperty(exports, "exchangeCode", {
245
249
  enumerable: true,
246
- get: function () { return chunkV7CA3CX5_cjs.exchangeCode; }
250
+ get: function () { return chunk4JRRFRV4_cjs.exchangeCode; }
247
251
  });
248
252
  Object.defineProperty(exports, "persistOAuthTokens", {
249
253
  enumerable: true,
250
- get: function () { return chunkV7CA3CX5_cjs.persistOAuthTokens; }
254
+ get: function () { return chunk4JRRFRV4_cjs.persistOAuthTokens; }
251
255
  });
252
256
  Object.defineProperty(exports, "readAuthFile", {
253
257
  enumerable: true,
254
- get: function () { return chunkV7CA3CX5_cjs.readAuthFile; }
258
+ get: function () { return chunk4JRRFRV4_cjs.readAuthFile; }
255
259
  });
256
260
  Object.defineProperty(exports, "readStoredOAuth", {
257
261
  enumerable: true,
258
- get: function () { return chunkV7CA3CX5_cjs.readStoredOAuth; }
262
+ get: function () { return chunk4JRRFRV4_cjs.readStoredOAuth; }
259
263
  });
260
264
  Object.defineProperty(exports, "refreshOAuthTokens", {
261
265
  enumerable: true,
262
- get: function () { return chunkV7CA3CX5_cjs.refreshOAuthTokens; }
266
+ get: function () { return chunk4JRRFRV4_cjs.refreshOAuthTokens; }
263
267
  });
264
268
  Object.defineProperty(exports, "resolveCredential", {
265
269
  enumerable: true,
266
- get: function () { return chunkV7CA3CX5_cjs.resolveCredential; }
270
+ get: function () { return chunk4JRRFRV4_cjs.resolveCredential; }
267
271
  });
268
272
  Object.defineProperty(exports, "writeCredential", {
269
273
  enumerable: true,
270
- get: function () { return chunkV7CA3CX5_cjs.writeCredential; }
274
+ get: function () { return chunk4JRRFRV4_cjs.writeCredential; }
271
275
  });
272
276
  exports.deviceLogin = deviceLogin;
273
277
  exports.extractAccountId = extractAccountId;
@@ -13,7 +13,7 @@
13
13
  * @packageDocumentation
14
14
  */
15
15
  export type { CredentialStoreConfig, DeviceCodeGrant, DeviceDeps, DeviceOAuthConfig, HttpDeps, OAuthProviderConfig, OAuthTokens, OpenAIDeviceConfig, ResolvedCredential, StoredApiCredential, StoredCredential, StoredOAuthCredential, } from "../internal/auth/auth-types.js";
16
- export { authFilePath, CredentialError, credentialHome, readAuthFile, readStoredOAuth, writeCredential, } from "../internal/auth/credential-store.js";
16
+ export { assertSecureModes, authFilePath, CredentialError, credentialHome, readAuthFile, readStoredOAuth, writeCredential, } from "../internal/auth/credential-store.js";
17
17
  export { deviceLogin, extractAccountId, openaiDeviceLogin, parseJwtClaims, pollDeviceToken, requestDeviceCode, requestOpenAIUsercode, } from "../internal/auth/oauth-device.js";
18
18
  export { ensureFreshCredential, exchangeCode, persistOAuthTokens, refreshOAuthTokens, } from "../internal/auth/oauth-engine.js";
19
19
  export { type ResolveCredentialOptions, resolveCredential, } from "../internal/auth/resolve-credential.js";
@@ -13,7 +13,7 @@
13
13
  * @packageDocumentation
14
14
  */
15
15
  export type { CredentialStoreConfig, DeviceCodeGrant, DeviceDeps, DeviceOAuthConfig, HttpDeps, OAuthProviderConfig, OAuthTokens, OpenAIDeviceConfig, ResolvedCredential, StoredApiCredential, StoredCredential, StoredOAuthCredential, } from "../internal/auth/auth-types.js";
16
- export { authFilePath, CredentialError, credentialHome, readAuthFile, readStoredOAuth, writeCredential, } from "../internal/auth/credential-store.js";
16
+ export { assertSecureModes, authFilePath, CredentialError, credentialHome, readAuthFile, readStoredOAuth, writeCredential, } from "../internal/auth/credential-store.js";
17
17
  export { deviceLogin, extractAccountId, openaiDeviceLogin, parseJwtClaims, pollDeviceToken, requestDeviceCode, requestOpenAIUsercode, } from "../internal/auth/oauth-device.js";
18
18
  export { ensureFreshCredential, exchangeCode, persistOAuthTokens, refreshOAuthTokens, } from "../internal/auth/oauth-engine.js";
19
19
  export { type ResolveCredentialOptions, resolveCredential, } from "../internal/auth/resolve-credential.js";
@@ -1,8 +1,8 @@
1
- import { exchangeCode } from '../chunk-AKMPQJPX.js';
2
- export { CredentialError, authFilePath, credentialHome, ensureFreshCredential, exchangeCode, persistOAuthTokens, readAuthFile, readStoredOAuth, refreshOAuthTokens, resolveCredential, writeCredential } from '../chunk-AKMPQJPX.js';
1
+ import { exchangeCode } from '../chunk-L4JFQCG4.js';
2
+ export { CredentialError, assertSecureModes, authFilePath, credentialHome, ensureFreshCredential, exchangeCode, persistOAuthTokens, readAuthFile, readStoredOAuth, refreshOAuthTokens, resolveCredential, writeCredential } from '../chunk-L4JFQCG4.js';
3
3
  import { AuthCallbackError } from '../chunk-5NBUH3NO.js';
4
- import '../chunk-VQ33XLC6.js';
5
- import '../chunk-RNCN2TTP.js';
4
+ import '../chunk-MRKSSN36.js';
5
+ import '../chunk-PBML2FHN.js';
6
6
 
7
7
  // src/internal/auth/oauth-device.ts
8
8
  var POLLING_SAFETY_MARGIN_MS = 3e3;
@@ -1,12 +1,12 @@
1
- import { submit, get } from './chunk-UIPTINIF.js';
1
+ import { submit, get } from './chunk-GNMPCZNN.js';
2
2
  import './chunk-K2BQQ445.js';
3
- import { newPooledCredential, CredentialPool, withCredentialPool } from './chunk-MI3OKONE.js';
4
- import { createSemaphore } from './chunk-F4SQTWVR.js';
3
+ import { newPooledCredential, CredentialPool, withCredentialPool } from './chunk-F4RUADRC.js';
4
+ import { createSemaphore } from './chunk-Q4DTGCSD.js';
5
5
  import './chunk-2XLKLVVR.js';
6
- import './chunk-BM7VYZED.js';
7
- import './chunk-5XPKYDK7.js';
8
- import { ConfigurationError, TheokitAgentError } from './chunk-VQ33XLC6.js';
9
- import { diag } from './chunk-RNCN2TTP.js';
6
+ import './chunk-NOM2YWFP.js';
7
+ import './chunk-VQFSEKU5.js';
8
+ import { ConfigurationError, TheokitAgentError } from './chunk-MRKSSN36.js';
9
+ import { diag } from './chunk-PBML2FHN.js';
10
10
  import { randomUUID } from 'crypto';
11
11
 
12
12
  function validateBatchInput(prompts, options) {
@@ -237,5 +237,5 @@ function buildPoolsFromApiKeys(apiKeys, strategy) {
237
237
  }
238
238
 
239
239
  export { batchImpl, validateBatchInput };
240
- //# sourceMappingURL=batch-WX2HLXX2.js.map
241
- //# sourceMappingURL=batch-WX2HLXX2.js.map
240
+ //# sourceMappingURL=batch-OUF4N2TM.js.map
241
+ //# sourceMappingURL=batch-OUF4N2TM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/batch.ts"],"names":[],"mappings":";;;;;;;;;;;AAgDO,SAAS,kBAAA,CACd,SACA,OAAA,EACM;AACN,EAAA,MAAM,EAAE,aAAY,GAAI,OAAA;AACxB,EAAA,IAAI,WAAA,KAAgB,WAAc,CAAC,MAAA,CAAO,UAAU,WAAW,CAAA,IAAK,cAAc,CAAA,CAAA,EAAI;AACpF,IAAA,MAAM,IAAI,kBAAA;AAAA,MACR,2DAA2D,WAAW,CAAA,CAAA;AAAA,MACtE,EAAE,MAAM,qBAAA;AAAsB,KAChC;AAAA,EACF;AACA,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,OAAA,CAAQ,QAAQ,CAAA,EAAA,EAAK;AACvC,IAAA,MAAM,IAAA,GAAO,QAAQ,CAAC,CAAA;AACtB,IAAA,MAAM,MAAA,GAAS,OAAO,IAAA,KAAS,QAAA,GAAW,OAAO,IAAA,EAAM,MAAA;AACvD,IAAA,IAAI,OAAO,MAAA,KAAW,QAAA,IAAY,MAAA,CAAO,WAAW,CAAA,EAAG;AACrD,MAAA,MAAM,IAAI,kBAAA,CAAmB,CAAA,4BAAA,EAA+B,CAAC,CAAA,2BAAA,CAAA,EAA+B;AAAA,QAC1F,IAAA,EAAM;AAAA,OACP,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ACF;AACA,EAAA,OAAO,KAAA;AACT","file":"batch-WX2HLXX2.js","sourcesContent":["/**\n * `Agent.batch(prompts, options)` core (ADRs D134-D140).\n *\n * Fans out N prompts via bounded concurrency, isolates failures per-prompt,\n * preserves input order in the result array, supports streaming callbacks\n * + AbortSignal. The credential pool (D131) is shared across all\n * in-flight agents via `withCredentialPool` ALS scope (EC-A fix).\n *\n * @internal\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport { ConfigurationError, TheokitAgentError } from \"./errors.js\";\nimport { diag } from \"./internal/diagnostics.js\";\nimport { CredentialPool, newPooledCredential } from \"./internal/llm/credential-pool.js\";\nimport { withCredentialPool } from \"./internal/llm/credential-pool-context.js\";\nimport type { CredentialPoolStrategy } from \"./internal/llm/credential-pool-types.js\";\nimport { createSemaphore } from \"./internal/runtime/concurrency/async-semaphore.js\";\nimport { get as taskRegistryGet, submit as taskRegistrySubmit } from \"./internal/task/registry.js\";\nimport type { AgentOptions, SDKAgent } from \"./types/agent.js\";\nimport type { BatchItem, BatchOptions, BatchProgress, BatchResult } from \"./types/batch.js\";\n\n/** DI contract — keeps batch.ts cycle-free from agent.ts. @internal */\ninterface BatchDeps {\n create: (options: AgentOptions) => Promise<SDKAgent>;\n}\n\n/**\n * Pre-flight boundary validation for `Agent.batch` (arch-review Gap 3).\n *\n * Mirrors the in-repo `validateAgentOptions` / `validateCronExpression`\n * pattern: throws `ConfigurationError` with a stable code on the first\n * violation, returns silently otherwise. Pure — no I/O.\n *\n * Rules:\n * - `concurrency`, when provided, must be a positive integer (rejects\n * 0/negative/non-integer/NaN/Infinity). Previously this was caught only\n * incidentally deep inside `createSemaphore` with a leaky \"permits\"\n * message, AND after task wrapping (dangling Task on invalid input).\n * - every prompt item must carry a non-empty string prompt. Previously\n * `normalizeItem` passed `prompt: \"\"` / non-string straight to\n * `agent.send`. (Whitespace-only strings are intentionally NOT rejected —\n * an empty string is a structural error; judging content is not this\n * validator's job, and the repo's property tests treat any length>=1\n * string as a valid prompt.)\n *\n * @internal\n */\nexport function validateBatchInput(\n prompts: ReadonlyArray<string | BatchItem>,\n options: BatchOptions,\n): void {\n const { concurrency } = options;\n if (concurrency !== undefined && (!Number.isInteger(concurrency) || concurrency < 1)) {\n throw new ConfigurationError(\n `Agent.batch concurrency must be a positive integer, got ${concurrency}`,\n { code: \"invalid_concurrency\" },\n );\n }\n for (let i = 0; i < prompts.length; i++) {\n const item = prompts[i];\n const prompt = typeof item === \"string\" ? item : item?.prompt;\n if (typeof prompt !== \"string\" || prompt.length === 0) {\n throw new ConfigurationError(`Agent.batch prompt at index ${i} must be a non-empty string`, {\n code: \"invalid_batch_item\",\n });\n }\n }\n}\n\n/**\n * Run N prompts in parallel with bounded concurrency.\n *\n * @internal\n */\nexport async function batchImpl(\n prompts: ReadonlyArray<string | BatchItem>,\n options: BatchOptions,\n deps: BatchDeps,\n): Promise<BatchResult[]> {\n // EC-1: empty array → no work, no agents created.\n if (prompts.length === 0) return [];\n\n // Pre-flight boundary validation (arch-review Gap 3). MUST run before pool\n // build AND before wrapBatchAsTask so invalid input never registers a\n // dangling Task or builds a credential pool (fail-fast, Rule 8).\n validateBatchInput(prompts, options);\n\n // EC-A fix: build credential pools ONCE and share via AsyncLocalStorage.\n // Without this each Agent.create() would build its own pool from identical\n // apiKeys → 4× rate-limit wastage per concurrency window.\n const sharedPools = buildPoolsFromApiKeys(\n options.providers?.apiKeys,\n options.providers?.credentialPoolStrategy,\n );\n const exec = (): Promise<BatchResult[]> => runBatch(prompts, options, deps);\n const withPool = (): Promise<BatchResult[]> =>\n sharedPools.size > 0 ? withCredentialPool(sharedPools, exec) : exec();\n // T3.3: opt-in Task wrapping (ADRs D363, D374). Register the whole\n // batch as a single Task (kind=\"batch\") with `b-` prefix (D368/EC-5).\n if (options.task !== undefined) {\n return wrapBatchAsTask(prompts.length, options.task, withPool);\n }\n return withPool();\n}\n\nasync function wrapBatchAsTask(\n total: number,\n taskOpt: true | { id?: string; meta?: Record<string, unknown> },\n exec: () => Promise<BatchResult[]>,\n): Promise<BatchResult[]> {\n const opts = taskOpt === true ? {} : taskOpt;\n const id = opts.id ?? `b-${randomUUID()}`;\n const meta: Record<string, unknown> = {\n total,\n ...(opts.meta ?? {}),\n };\n let results: BatchResult[] = [];\n await taskRegistrySubmit({\n kind: \"batch\",\n work: async (ctx) => {\n results = await exec();\n const succeeded = results.filter((r) => r.ok).length;\n const failed = results.length - succeeded;\n ctx.emit({ total: results.length, succeeded, failed });\n return { total: results.length, succeeded, failed };\n },\n id,\n meta,\n allowReservedPrefix: true,\n });\n // submit returns immediately with a queued handle. Wait for terminal.\n for (let i = 0; i < 5000; i++) {\n const h = await taskRegistryGet(id);\n if (h?.state === \"finished\" || h?.state === \"error\" || h?.state === \"cancelled\") break;\n await new Promise((r) => setTimeout(r, 5));\n }\n return results;\n}\n\nasync function runBatch(\n prompts: ReadonlyArray<string | BatchItem>,\n options: BatchOptions,\n deps: BatchDeps,\n): Promise<BatchResult[]> {\n const requested = options.concurrency ?? 4;\n // createSemaphore throws on invalid (EC-2).\n // EC-3: cap to prompts.length to avoid idle workers.\n const effective = Math.min(requested, prompts.length);\n const semaphore = createSemaphore(effective);\n const items = prompts.map(normalizeItem);\n const results: BatchResult[] = new Array(items.length);\n const counters = { completed: 0, failed: 0 };\n let aborted = false;\n\n const onAbort = (): void => {\n aborted = true;\n };\n options.signal?.addEventListener(\"abort\", onAbort);\n // EC-C: pre-aborted signal — treat as already-aborted before any work.\n if (options.signal?.aborted === true) aborted = true;\n\n try {\n await Promise.all(\n items.map(async (item, index) => {\n const release = await semaphore.acquire();\n try {\n if (aborted) {\n results[index] = abortResult(item, index, options.signal);\n } else {\n results[index] = await runOne(item, index, options, deps);\n }\n } finally {\n release();\n }\n if (results[index].ok) counters.completed += 1;\n else counters.failed += 1;\n await safeCallResult(options.onResult, results[index]);\n safeCallProgress(options.onProgress, {\n total: items.length,\n completed: counters.completed,\n failed: counters.failed,\n inFlight: semaphore.inFlight(),\n pending: Math.max(0, semaphore.pending() - semaphore.inFlight()),\n });\n }),\n );\n } finally {\n options.signal?.removeEventListener(\"abort\", onAbort);\n }\n\n return options.filter ? results.filter(options.filter) : results;\n}\n\nasync function runOne(\n item: BatchItem,\n index: number,\n options: BatchOptions,\n deps: BatchDeps,\n): Promise<BatchResult> {\n const t0 = Date.now();\n const agentOpts = buildAgentOptions(item, options);\n\n try {\n const agent = await deps.create(agentOpts);\n try {\n const run = await agent.send(item.prompt);\n const result = await run.wait();\n return {\n ok: true,\n index,\n prompt: item.prompt,\n result,\n ...(item.metadata !== undefined ? { metadata: item.metadata } : {}),\n durationMs: Date.now() - t0,\n };\n } finally {\n // EC-8: dispose failure → stderr warn, don't fail the result.\n try {\n await agent.dispose();\n } catch (disposeErr) {\n // theokit#147 — the interceptable channel; a batch run must not write onto a TUI's frame.\n diag(\n `[theokit-sdk] batch: agent.dispose failed for prompt ${index}: ${\n disposeErr instanceof Error ? disposeErr.message : String(disposeErr)\n }\\n`,\n );\n }\n }\n } catch (err) {\n return {\n ok: false,\n index,\n prompt: item.prompt,\n error: toTheokitError(err),\n ...(item.metadata !== undefined ? { metadata: item.metadata } : {}),\n durationMs: Date.now() - t0,\n };\n }\n}\n\nfunction buildAgentOptions(item: BatchItem, options: BatchOptions): AgentOptions {\n const {\n concurrency: _c,\n filter: _f,\n onResult: _or,\n onProgress: _op,\n signal: _s,\n task: _t,\n ...rest\n } = options;\n void _c;\n void _f;\n void _or;\n void _op;\n void _s;\n void _t;\n const agentOpts = rest as AgentOptions;\n if (item.systemPrompt !== undefined) {\n return { ...agentOpts, systemPrompt: item.systemPrompt };\n }\n return agentOpts;\n}\n\nfunction normalizeItem(promptOrItem: string | BatchItem): BatchItem {\n return typeof promptOrItem === \"string\" ? { prompt: promptOrItem } : promptOrItem;\n}\n\nfunction abortResult(item: BatchItem, index: number, signal?: AbortSignal): BatchResult {\n // EC-D: propagate signal.reason when set (preserves caller's error).\n let error: TheokitAgentError;\n if (signal?.reason instanceof TheokitAgentError) {\n error = signal.reason;\n } else if (signal?.reason instanceof Error) {\n error = new TheokitAgentError(signal.reason.message, {\n code: \"aborted\",\n cause: signal.reason,\n });\n } else {\n error = new TheokitAgentError(\"Batch aborted via AbortSignal\", { code: \"aborted\" });\n }\n return {\n ok: false,\n index,\n prompt: item.prompt,\n error,\n ...(item.metadata !== undefined ? { metadata: item.metadata } : {}),\n durationMs: 0,\n };\n}\n\nfunction toTheokitError(err: unknown): TheokitAgentError {\n if (err instanceof TheokitAgentError) return err;\n if (err instanceof Error) {\n return new TheokitAgentError(err.message, { code: \"unknown\", cause: err });\n }\n return new TheokitAgentError(String(err), { code: \"unknown\" });\n}\n\nasync function safeCallResult(cb: BatchOptions[\"onResult\"], result: BatchResult): Promise<void> {\n if (cb === undefined) return;\n try {\n await cb(result);\n } catch (err) {\n diag(\n `[theokit-sdk] batch: onResult callback threw: ${\n err instanceof Error ? err.message : String(err)\n }\\n`,\n );\n }\n}\n\nfunction safeCallProgress(cb: BatchOptions[\"onProgress\"], progress: BatchProgress): void {\n if (cb === undefined) return;\n try {\n cb(progress);\n } catch (err) {\n diag(\n `[theokit-sdk] batch: onProgress callback threw: ${\n err instanceof Error ? err.message : String(err)\n }\\n`,\n );\n }\n}\n\n/**\n * EC-A: construct shared pools from options.apiKeys. Empty/invalid → empty Map.\n *\n * @internal\n */\nfunction buildPoolsFromApiKeys(\n apiKeys: Record<string, string[]> | undefined,\n strategy: Record<string, CredentialPoolStrategy> | undefined,\n): Map<string, CredentialPool> {\n const pools = new Map<string, CredentialPool>();\n if (apiKeys === undefined) return pools;\n for (const [provider, keys] of Object.entries(apiKeys)) {\n if (!Array.isArray(keys)) continue;\n const filtered = keys.filter((k): k is string => typeof k === \"string\" && k.length > 0);\n if (filtered.length < 2) continue; // 1-key pools aren't pools\n const entries = filtered.map((token, i) =>\n newPooledCredential({ provider, accessToken: token, priority: i, source: \"manual\" }),\n );\n pools.set(\n provider,\n new CredentialPool(provider, entries, strategy?.[provider] ?? \"fill_first\"),\n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AAA,CACP,SACA,QAAA,EAC6B;AAC7B,EAAA,MAAM,KAAA,uBAAY,GAAA,EAA4B;AAC9C,EAAA,IAAI,OAAA,KAAY,QAAW,OAAO,KAAA;AAClC,EAAA,KAAA,MAAW,CAAC,QAAA,EAAU,IAAI,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AACtD,IAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG;AAC1B,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,MAAA,CAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAA,IAAY,CAAA,CAAE,MAAA,GAAS,CAAC,CAAA;AACtF,IAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACzB,IAAA,MAAM,UAAU,QAAA,CAAS,GAAA;AAAA,MAAI,CAAC,KAAA,EAAO,CAAA,KACnC,mBAAA,CAAoB,EAAE,QAAA,EAAU,WAAA,EAAa,KAAA,EAAO,QAAA,EAAU,CAAA,EAAG,MAAA,EAAQ,QAAA,EAAU;AAAA,KACrF;AACA,IAAA,KAAA,CAAM,GAAA;AAAA,MACJ,QAAA;AAAA,MACA,IAAI,cAAA,CAAe,QAAA,EAAU,SAAS,QAAA,GAAW,QAAQ,KAAK,YAAY;AAAA,KAC5E;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT","file":"batch-OUF4N2TM.js","sourcesContent":["/**\n * `Agent.batch(prompts, options)` core (ADRs D134-D140).\n *\n * Fans out N prompts via bounded concurrency, isolates failures per-prompt,\n * preserves input order in the result array, supports streaming callbacks\n * + AbortSignal. The credential pool (D131) is shared across all\n * in-flight agents via `withCredentialPool` ALS scope (EC-A fix).\n *\n * @internal\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport { ConfigurationError, TheokitAgentError } from \"./errors.js\";\nimport { diag } from \"./internal/diagnostics.js\";\nimport { CredentialPool, newPooledCredential } from \"./internal/llm/credential-pool.js\";\nimport { withCredentialPool } from \"./internal/llm/credential-pool-context.js\";\nimport type { CredentialPoolStrategy } from \"./internal/llm/credential-pool-types.js\";\nimport { createSemaphore } from \"./internal/runtime/concurrency/async-semaphore.js\";\nimport { get as taskRegistryGet, submit as taskRegistrySubmit } from \"./internal/task/registry.js\";\nimport type { AgentOptions, SDKAgent } from \"./types/agent.js\";\nimport type { BatchItem, BatchOptions, BatchProgress, BatchResult } from \"./types/batch.js\";\n\n/** DI contract — keeps batch.ts cycle-free from agent.ts. @internal */\ninterface BatchDeps {\n create: (options: AgentOptions) => Promise<SDKAgent>;\n}\n\n/**\n * Pre-flight boundary validation for `Agent.batch` (arch-review Gap 3).\n *\n * Mirrors the in-repo `validateAgentOptions` / `validateCronExpression`\n * pattern: throws `ConfigurationError` with a stable code on the first\n * violation, returns silently otherwise. Pure — no I/O.\n *\n * Rules:\n * - `concurrency`, when provided, must be a positive integer (rejects\n * 0/negative/non-integer/NaN/Infinity). Previously this was caught only\n * incidentally deep inside `createSemaphore` with a leaky \"permits\"\n * message, AND after task wrapping (dangling Task on invalid input).\n * - every prompt item must carry a non-empty string prompt. Previously\n * `normalizeItem` passed `prompt: \"\"` / non-string straight to\n * `agent.send`. (Whitespace-only strings are intentionally NOT rejected —\n * an empty string is a structural error; judging content is not this\n * validator's job, and the repo's property tests treat any length>=1\n * string as a valid prompt.)\n *\n * @internal\n */\nexport function validateBatchInput(\n prompts: ReadonlyArray<string | BatchItem>,\n options: BatchOptions,\n): void {\n const { concurrency } = options;\n if (concurrency !== undefined && (!Number.isInteger(concurrency) || concurrency < 1)) {\n throw new ConfigurationError(\n `Agent.batch concurrency must be a positive integer, got ${concurrency}`,\n { code: \"invalid_concurrency\" },\n );\n }\n for (let i = 0; i < prompts.length; i++) {\n const item = prompts[i];\n const prompt = typeof item === \"string\" ? item : item?.prompt;\n if (typeof prompt !== \"string\" || prompt.length === 0) {\n throw new ConfigurationError(`Agent.batch prompt at index ${i} must be a non-empty string`, {\n code: \"invalid_batch_item\",\n });\n }\n }\n}\n\n/**\n * Run N prompts in parallel with bounded concurrency.\n *\n * @internal\n */\nexport async function batchImpl(\n prompts: ReadonlyArray<string | BatchItem>,\n options: BatchOptions,\n deps: BatchDeps,\n): Promise<BatchResult[]> {\n // EC-1: empty array → no work, no agents created.\n if (prompts.length === 0) return [];\n\n // Pre-flight boundary validation (arch-review Gap 3). MUST run before pool\n // build AND before wrapBatchAsTask so invalid input never registers a\n // dangling Task or builds a credential pool (fail-fast, Rule 8).\n validateBatchInput(prompts, options);\n\n // EC-A fix: build credential pools ONCE and share via AsyncLocalStorage.\n // Without this each Agent.create() would build its own pool from identical\n // apiKeys → 4× rate-limit wastage per concurrency window.\n const sharedPools = buildPoolsFromApiKeys(\n options.providers?.apiKeys,\n options.providers?.credentialPoolStrategy,\n );\n const exec = (): Promise<BatchResult[]> => runBatch(prompts, options, deps);\n const withPool = (): Promise<BatchResult[]> =>\n sharedPools.size > 0 ? withCredentialPool(sharedPools, exec) : exec();\n // T3.3: opt-in Task wrapping (ADRs D363, D374). Register the whole\n // batch as a single Task (kind=\"batch\") with `b-` prefix (D368/EC-5).\n if (options.task !== undefined) {\n return wrapBatchAsTask(prompts.length, options.task, withPool);\n }\n return withPool();\n}\n\nasync function wrapBatchAsTask(\n total: number,\n taskOpt: true | { id?: string; meta?: Record<string, unknown> },\n exec: () => Promise<BatchResult[]>,\n): Promise<BatchResult[]> {\n const opts = taskOpt === true ? {} : taskOpt;\n const id = opts.id ?? `b-${randomUUID()}`;\n const meta: Record<string, unknown> = {\n total,\n ...(opts.meta ?? {}),\n };\n let results: BatchResult[] = [];\n await taskRegistrySubmit({\n kind: \"batch\",\n work: async (ctx) => {\n results = await exec();\n const succeeded = results.filter((r) => r.ok).length;\n const failed = results.length - succeeded;\n ctx.emit({ total: results.length, succeeded, failed });\n return { total: results.length, succeeded, failed };\n },\n id,\n meta,\n allowReservedPrefix: true,\n });\n // submit returns immediately with a queued handle. Wait for terminal.\n for (let i = 0; i < 5000; i++) {\n const h = await taskRegistryGet(id);\n if (h?.state === \"finished\" || h?.state === \"error\" || h?.state === \"cancelled\") break;\n await new Promise((r) => setTimeout(r, 5));\n }\n return results;\n}\n\nasync function runBatch(\n prompts: ReadonlyArray<string | BatchItem>,\n options: BatchOptions,\n deps: BatchDeps,\n): Promise<BatchResult[]> {\n const requested = options.concurrency ?? 4;\n // createSemaphore throws on invalid (EC-2).\n // EC-3: cap to prompts.length to avoid idle workers.\n const effective = Math.min(requested, prompts.length);\n const semaphore = createSemaphore(effective);\n const items = prompts.map(normalizeItem);\n const results: BatchResult[] = new Array(items.length);\n const counters = { completed: 0, failed: 0 };\n let aborted = false;\n\n const onAbort = (): void => {\n aborted = true;\n };\n options.signal?.addEventListener(\"abort\", onAbort);\n // EC-C: pre-aborted signal — treat as already-aborted before any work.\n if (options.signal?.aborted === true) aborted = true;\n\n try {\n await Promise.all(\n items.map(async (item, index) => {\n const release = await semaphore.acquire();\n try {\n if (aborted) {\n results[index] = abortResult(item, index, options.signal);\n } else {\n results[index] = await runOne(item, index, options, deps);\n }\n } finally {\n release();\n }\n if (results[index].ok) counters.completed += 1;\n else counters.failed += 1;\n await safeCallResult(options.onResult, results[index]);\n safeCallProgress(options.onProgress, {\n total: items.length,\n completed: counters.completed,\n failed: counters.failed,\n inFlight: semaphore.inFlight(),\n pending: Math.max(0, semaphore.pending() - semaphore.inFlight()),\n });\n }),\n );\n } finally {\n options.signal?.removeEventListener(\"abort\", onAbort);\n }\n\n return options.filter ? results.filter(options.filter) : results;\n}\n\nasync function runOne(\n item: BatchItem,\n index: number,\n options: BatchOptions,\n deps: BatchDeps,\n): Promise<BatchResult> {\n const t0 = Date.now();\n const agentOpts = buildAgentOptions(item, options);\n\n try {\n const agent = await deps.create(agentOpts);\n try {\n const run = await agent.send(item.prompt);\n const result = await run.wait();\n return {\n ok: true,\n index,\n prompt: item.prompt,\n result,\n ...(item.metadata !== undefined ? { metadata: item.metadata } : {}),\n durationMs: Date.now() - t0,\n };\n } finally {\n // EC-8: dispose failure → stderr warn, don't fail the result.\n try {\n await agent.dispose();\n } catch (disposeErr) {\n // theokit#147 — the interceptable channel; a batch run must not write onto a TUI's frame.\n diag(\n `[theokit-sdk] batch: agent.dispose failed for prompt ${index}: ${\n disposeErr instanceof Error ? disposeErr.message : String(disposeErr)\n }\\n`,\n );\n }\n }\n } catch (err) {\n return {\n ok: false,\n index,\n prompt: item.prompt,\n error: toTheokitError(err),\n ...(item.metadata !== undefined ? { metadata: item.metadata } : {}),\n durationMs: Date.now() - t0,\n };\n }\n}\n\nfunction buildAgentOptions(item: BatchItem, options: BatchOptions): AgentOptions {\n const {\n concurrency: _c,\n filter: _f,\n onResult: _or,\n onProgress: _op,\n signal: _s,\n task: _t,\n ...rest\n } = options;\n void _c;\n void _f;\n void _or;\n void _op;\n void _s;\n void _t;\n const agentOpts = rest as AgentOptions;\n if (item.systemPrompt !== undefined) {\n return { ...agentOpts, systemPrompt: item.systemPrompt };\n }\n return agentOpts;\n}\n\nfunction normalizeItem(promptOrItem: string | BatchItem): BatchItem {\n return typeof promptOrItem === \"string\" ? { prompt: promptOrItem } : promptOrItem;\n}\n\nfunction abortResult(item: BatchItem, index: number, signal?: AbortSignal): BatchResult {\n // EC-D: propagate signal.reason when set (preserves caller's error).\n let error: TheokitAgentError;\n if (signal?.reason instanceof TheokitAgentError) {\n error = signal.reason;\n } else if (signal?.reason instanceof Error) {\n error = new TheokitAgentError(signal.reason.message, {\n code: \"aborted\",\n cause: signal.reason,\n });\n } else {\n error = new TheokitAgentError(\"Batch aborted via AbortSignal\", { code: \"aborted\" });\n }\n return {\n ok: false,\n index,\n prompt: item.prompt,\n error,\n ...(item.metadata !== undefined ? { metadata: item.metadata } : {}),\n durationMs: 0,\n };\n}\n\nfunction toTheokitError(err: unknown): TheokitAgentError {\n if (err instanceof TheokitAgentError) return err;\n if (err instanceof Error) {\n return new TheokitAgentError(err.message, { code: \"unknown\", cause: err });\n }\n return new TheokitAgentError(String(err), { code: \"unknown\" });\n}\n\nasync function safeCallResult(cb: BatchOptions[\"onResult\"], result: BatchResult): Promise<void> {\n if (cb === undefined) return;\n try {\n await cb(result);\n } catch (err) {\n diag(\n `[theokit-sdk] batch: onResult callback threw: ${\n err instanceof Error ? err.message : String(err)\n }\\n`,\n );\n }\n}\n\nfunction safeCallProgress(cb: BatchOptions[\"onProgress\"], progress: BatchProgress): void {\n if (cb === undefined) return;\n try {\n cb(progress);\n } catch (err) {\n diag(\n `[theokit-sdk] batch: onProgress callback threw: ${\n err instanceof Error ? err.message : String(err)\n }\\n`,\n );\n }\n}\n\n/**\n * EC-A: construct shared pools from options.apiKeys. Empty/invalid → empty Map.\n *\n * @internal\n */\nfunction buildPoolsFromApiKeys(\n apiKeys: Record<string, string[]> | undefined,\n strategy: Record<string, CredentialPoolStrategy> | undefined,\n): Map<string, CredentialPool> {\n const pools = new Map<string, CredentialPool>();\n if (apiKeys === undefined) return pools;\n for (const [provider, keys] of Object.entries(apiKeys)) {\n if (!Array.isArray(keys)) continue;\n const filtered = keys.filter((k): k is string => typeof k === \"string\" && k.length > 0);\n if (filtered.length < 2) continue; // 1-key pools aren't pools\n const entries = filtered.map((token, i) =>\n newPooledCredential({ provider, accessToken: token, priority: i, source: \"manual\" }),\n );\n pools.set(\n provider,\n new CredentialPool(provider, entries, strategy?.[provider] ?? \"fill_first\"),\n );\n }\n return pools;\n}\n"]}