@theokit/sdk 0.0.0-compat-580-20260905204608

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 (1141) hide show
  1. package/CHANGELOG.md +7923 -0
  2. package/LICENSE +201 -0
  3. package/README.md +114 -0
  4. package/dist/a2a/agent-mailbox.d.cts +54 -0
  5. package/dist/a2a/agent-mailbox.d.ts +54 -0
  6. package/dist/a2a/index.cjs +138 -0
  7. package/dist/a2a/index.cjs.map +1 -0
  8. package/dist/a2a/index.d.cts +10 -0
  9. package/dist/a2a/index.d.ts +10 -0
  10. package/dist/a2a/index.js +125 -0
  11. package/dist/a2a/index.js.map +1 -0
  12. package/dist/a2a/message-bus.d.cts +118 -0
  13. package/dist/a2a/message-bus.d.ts +118 -0
  14. package/dist/a2a/subagent.d.cts +231 -0
  15. package/dist/a2a/subagent.d.ts +231 -0
  16. package/dist/a2a/types.d.cts +45 -0
  17. package/dist/a2a/types.d.ts +45 -0
  18. package/dist/agent-ARLOD4JX.cjs +67 -0
  19. package/dist/agent-ARLOD4JX.cjs.map +1 -0
  20. package/dist/agent-C3KO5LKm.d.cts +1871 -0
  21. package/dist/agent-CvmTR9uf.d.ts +1871 -0
  22. package/dist/agent-N6WJ54ML.js +58 -0
  23. package/dist/agent-N6WJ54ML.js.map +1 -0
  24. package/dist/agent-builder.d.ts +72 -0
  25. package/dist/agent-factory-registry-UU46BUMU.cjs +16 -0
  26. package/dist/agent-factory-registry-UU46BUMU.cjs.map +1 -0
  27. package/dist/agent-factory-registry-ZVTABLEY.js +3 -0
  28. package/dist/agent-factory-registry-ZVTABLEY.js.map +1 -0
  29. package/dist/agent-factory.d.ts +24 -0
  30. package/dist/agent-generate.d.ts +12 -0
  31. package/dist/agent-session-store-AFML3AXC.js +6 -0
  32. package/dist/agent-session-store-AFML3AXC.js.map +1 -0
  33. package/dist/agent-session-store-MTSIY3MH.cjs +23 -0
  34. package/dist/agent-session-store-MTSIY3MH.cjs.map +1 -0
  35. package/dist/agent.d.ts +276 -0
  36. package/dist/auth/index.cjs +306 -0
  37. package/dist/auth/index.cjs.map +1 -0
  38. package/dist/auth/index.d.cts +34 -0
  39. package/dist/auth/index.d.ts +34 -0
  40. package/dist/auth/index.js +247 -0
  41. package/dist/auth/index.js.map +1 -0
  42. package/dist/batch-I6T6MXZO.cjs +263 -0
  43. package/dist/batch-I6T6MXZO.cjs.map +1 -0
  44. package/dist/batch-US4F6WPK.js +260 -0
  45. package/dist/batch-US4F6WPK.js.map +1 -0
  46. package/dist/chunk-24MGQDK3.js +31 -0
  47. package/dist/chunk-24MGQDK3.js.map +1 -0
  48. package/dist/chunk-24SYBZPL.cjs +121 -0
  49. package/dist/chunk-24SYBZPL.cjs.map +1 -0
  50. package/dist/chunk-2HPNT6HH.cjs +3373 -0
  51. package/dist/chunk-2HPNT6HH.cjs.map +1 -0
  52. package/dist/chunk-2SFBB54R.js +23 -0
  53. package/dist/chunk-2SFBB54R.js.map +1 -0
  54. package/dist/chunk-2WXHA33T.js +105 -0
  55. package/dist/chunk-2WXHA33T.js.map +1 -0
  56. package/dist/chunk-2XC6KDJM.js +22 -0
  57. package/dist/chunk-2XC6KDJM.js.map +1 -0
  58. package/dist/chunk-2XRAWOZZ.js +172 -0
  59. package/dist/chunk-2XRAWOZZ.js.map +1 -0
  60. package/dist/chunk-2ZPEDVLM.cjs +59 -0
  61. package/dist/chunk-2ZPEDVLM.cjs.map +1 -0
  62. package/dist/chunk-3EE6LVWT.cjs +29 -0
  63. package/dist/chunk-3EE6LVWT.cjs.map +1 -0
  64. package/dist/chunk-3JHIFQ4I.js +102 -0
  65. package/dist/chunk-3JHIFQ4I.js.map +1 -0
  66. package/dist/chunk-44I6UYVH.js +133 -0
  67. package/dist/chunk-44I6UYVH.js.map +1 -0
  68. package/dist/chunk-47TF32NQ.js +79 -0
  69. package/dist/chunk-47TF32NQ.js.map +1 -0
  70. package/dist/chunk-4A3SKJ53.cjs +297 -0
  71. package/dist/chunk-4A3SKJ53.cjs.map +1 -0
  72. package/dist/chunk-4HS6FFGL.cjs +433 -0
  73. package/dist/chunk-4HS6FFGL.cjs.map +1 -0
  74. package/dist/chunk-4MMWFSCD.js +25 -0
  75. package/dist/chunk-4MMWFSCD.js.map +1 -0
  76. package/dist/chunk-4NLCWGH7.cjs +177 -0
  77. package/dist/chunk-4NLCWGH7.cjs.map +1 -0
  78. package/dist/chunk-55GB6JYQ.js +208 -0
  79. package/dist/chunk-55GB6JYQ.js.map +1 -0
  80. package/dist/chunk-5WKQDIGO.js +136 -0
  81. package/dist/chunk-5WKQDIGO.js.map +1 -0
  82. package/dist/chunk-67SBTGMA.cjs +457 -0
  83. package/dist/chunk-67SBTGMA.cjs.map +1 -0
  84. package/dist/chunk-6LHQPOMI.cjs +193 -0
  85. package/dist/chunk-6LHQPOMI.cjs.map +1 -0
  86. package/dist/chunk-6M2OIS4Y.js +158 -0
  87. package/dist/chunk-6M2OIS4Y.js.map +1 -0
  88. package/dist/chunk-6PWOWXMC.js +121 -0
  89. package/dist/chunk-6PWOWXMC.js.map +1 -0
  90. package/dist/chunk-6X6ID4MO.js +20 -0
  91. package/dist/chunk-6X6ID4MO.js.map +1 -0
  92. package/dist/chunk-7A6535RA.cjs +231 -0
  93. package/dist/chunk-7A6535RA.cjs.map +1 -0
  94. package/dist/chunk-7FDKWDA2.cjs +135 -0
  95. package/dist/chunk-7FDKWDA2.cjs.map +1 -0
  96. package/dist/chunk-7I5Z3UBJ.js +10 -0
  97. package/dist/chunk-7I5Z3UBJ.js.map +1 -0
  98. package/dist/chunk-7JJ3A6AT.cjs +88 -0
  99. package/dist/chunk-7JJ3A6AT.cjs.map +1 -0
  100. package/dist/chunk-7SZAV6QG.js +593 -0
  101. package/dist/chunk-7SZAV6QG.js.map +1 -0
  102. package/dist/chunk-A4RAL2ER.cjs +51 -0
  103. package/dist/chunk-A4RAL2ER.cjs.map +1 -0
  104. package/dist/chunk-AA27GEYS.cjs +12 -0
  105. package/dist/chunk-AA27GEYS.cjs.map +1 -0
  106. package/dist/chunk-AAEZSPTC.js +133 -0
  107. package/dist/chunk-AAEZSPTC.js.map +1 -0
  108. package/dist/chunk-AGACYRJ2.js +11 -0
  109. package/dist/chunk-AGACYRJ2.js.map +1 -0
  110. package/dist/chunk-ALUN2B4W.js +356 -0
  111. package/dist/chunk-ALUN2B4W.js.map +1 -0
  112. package/dist/chunk-ANMJJD6D.cjs +18 -0
  113. package/dist/chunk-ANMJJD6D.cjs.map +1 -0
  114. package/dist/chunk-ATT276RD.cjs +173 -0
  115. package/dist/chunk-ATT276RD.cjs.map +1 -0
  116. package/dist/chunk-AW6F6HZR.js +166 -0
  117. package/dist/chunk-AW6F6HZR.js.map +1 -0
  118. package/dist/chunk-AWINL3ZC.js +109 -0
  119. package/dist/chunk-AWINL3ZC.js.map +1 -0
  120. package/dist/chunk-BJUJT5ED.cjs +186 -0
  121. package/dist/chunk-BJUJT5ED.cjs.map +1 -0
  122. package/dist/chunk-BUUUWQMB.cjs +34 -0
  123. package/dist/chunk-BUUUWQMB.cjs.map +1 -0
  124. package/dist/chunk-BV2MWEMV.cjs +26 -0
  125. package/dist/chunk-BV2MWEMV.cjs.map +1 -0
  126. package/dist/chunk-CFE6QF2Q.js +221 -0
  127. package/dist/chunk-CFE6QF2Q.js.map +1 -0
  128. package/dist/chunk-CZJ6Q7CW.js +183 -0
  129. package/dist/chunk-CZJ6Q7CW.js.map +1 -0
  130. package/dist/chunk-D3CCY3A2.cjs +10995 -0
  131. package/dist/chunk-D3CCY3A2.cjs.map +1 -0
  132. package/dist/chunk-D6POWE7E.cjs +210 -0
  133. package/dist/chunk-D6POWE7E.cjs.map +1 -0
  134. package/dist/chunk-DMRT67Y6.js +100 -0
  135. package/dist/chunk-DMRT67Y6.js.map +1 -0
  136. package/dist/chunk-DQZU7JK6.cjs +125 -0
  137. package/dist/chunk-DQZU7JK6.cjs.map +1 -0
  138. package/dist/chunk-EFMFILPG.js +77 -0
  139. package/dist/chunk-EFMFILPG.js.map +1 -0
  140. package/dist/chunk-EH6XD3FY.js +222 -0
  141. package/dist/chunk-EH6XD3FY.js.map +1 -0
  142. package/dist/chunk-EIQFAOFD.js +229 -0
  143. package/dist/chunk-EIQFAOFD.js.map +1 -0
  144. package/dist/chunk-EPSICJLZ.js +79 -0
  145. package/dist/chunk-EPSICJLZ.js.map +1 -0
  146. package/dist/chunk-EXTRW7GW.cjs +155 -0
  147. package/dist/chunk-EXTRW7GW.cjs.map +1 -0
  148. package/dist/chunk-FD2UT76F.js +3 -0
  149. package/dist/chunk-FD2UT76F.js.map +1 -0
  150. package/dist/chunk-FJWQP6EE.js +122 -0
  151. package/dist/chunk-FJWQP6EE.js.map +1 -0
  152. package/dist/chunk-FRITRLZQ.cjs +24 -0
  153. package/dist/chunk-FRITRLZQ.cjs.map +1 -0
  154. package/dist/chunk-FUSDYC2B.cjs +280 -0
  155. package/dist/chunk-FUSDYC2B.cjs.map +1 -0
  156. package/dist/chunk-G7BLGBRN.js +43 -0
  157. package/dist/chunk-G7BLGBRN.js.map +1 -0
  158. package/dist/chunk-GBCVPKHE.js +282 -0
  159. package/dist/chunk-GBCVPKHE.js.map +1 -0
  160. package/dist/chunk-GHX4P3V2.cjs +34 -0
  161. package/dist/chunk-GHX4P3V2.cjs.map +1 -0
  162. package/dist/chunk-GZV6AVRL.cjs +282 -0
  163. package/dist/chunk-GZV6AVRL.cjs.map +1 -0
  164. package/dist/chunk-H73MEMQB.js +31 -0
  165. package/dist/chunk-H73MEMQB.js.map +1 -0
  166. package/dist/chunk-HCT4HPCL.cjs +235 -0
  167. package/dist/chunk-HCT4HPCL.cjs.map +1 -0
  168. package/dist/chunk-HFEJE7AC.js +424 -0
  169. package/dist/chunk-HFEJE7AC.js.map +1 -0
  170. package/dist/chunk-HKCKOAIO.js +57 -0
  171. package/dist/chunk-HKCKOAIO.js.map +1 -0
  172. package/dist/chunk-HUFSABUZ.cjs +48 -0
  173. package/dist/chunk-HUFSABUZ.cjs.map +1 -0
  174. package/dist/chunk-HW7SEELD.cjs +46 -0
  175. package/dist/chunk-HW7SEELD.cjs.map +1 -0
  176. package/dist/chunk-HY66GLM6.js +13 -0
  177. package/dist/chunk-HY66GLM6.js.map +1 -0
  178. package/dist/chunk-I2PWY7VM.cjs +27 -0
  179. package/dist/chunk-I2PWY7VM.cjs.map +1 -0
  180. package/dist/chunk-IJ7M6GOG.cjs +28 -0
  181. package/dist/chunk-IJ7M6GOG.cjs.map +1 -0
  182. package/dist/chunk-IU5N5224.cjs +288 -0
  183. package/dist/chunk-IU5N5224.cjs.map +1 -0
  184. package/dist/chunk-IUMAQURF.js +130 -0
  185. package/dist/chunk-IUMAQURF.js.map +1 -0
  186. package/dist/chunk-J7J7J2GN.cjs +377 -0
  187. package/dist/chunk-J7J7J2GN.cjs.map +1 -0
  188. package/dist/chunk-JLRLCBJ4.cjs +108 -0
  189. package/dist/chunk-JLRLCBJ4.cjs.map +1 -0
  190. package/dist/chunk-JMDDYA22.js +171 -0
  191. package/dist/chunk-JMDDYA22.js.map +1 -0
  192. package/dist/chunk-JNAA4G4H.js +43 -0
  193. package/dist/chunk-JNAA4G4H.js.map +1 -0
  194. package/dist/chunk-JOFVLOFY.js +268 -0
  195. package/dist/chunk-JOFVLOFY.js.map +1 -0
  196. package/dist/chunk-K2BQQ445.js +30 -0
  197. package/dist/chunk-K2BQQ445.js.map +1 -0
  198. package/dist/chunk-K2VMFZQ5.js +487 -0
  199. package/dist/chunk-K2VMFZQ5.js.map +1 -0
  200. package/dist/chunk-K3NH62DG.js +3343 -0
  201. package/dist/chunk-K3NH62DG.js.map +1 -0
  202. package/dist/chunk-KGANQYP7.cjs +172 -0
  203. package/dist/chunk-KGANQYP7.cjs.map +1 -0
  204. package/dist/chunk-KRD3GQAA.cjs +71 -0
  205. package/dist/chunk-KRD3GQAA.cjs.map +1 -0
  206. package/dist/chunk-KTTHHYEW.cjs +45 -0
  207. package/dist/chunk-KTTHHYEW.cjs.map +1 -0
  208. package/dist/chunk-KVNWIAO4.js +68 -0
  209. package/dist/chunk-KVNWIAO4.js.map +1 -0
  210. package/dist/chunk-KVSAY6NZ.cjs +497 -0
  211. package/dist/chunk-KVSAY6NZ.cjs.map +1 -0
  212. package/dist/chunk-LOHMT36V.cjs +178 -0
  213. package/dist/chunk-LOHMT36V.cjs.map +1 -0
  214. package/dist/chunk-LX7SEXOQ.js +152 -0
  215. package/dist/chunk-LX7SEXOQ.js.map +1 -0
  216. package/dist/chunk-MUUQ2WFJ.cjs +4 -0
  217. package/dist/chunk-MUUQ2WFJ.cjs.map +1 -0
  218. package/dist/chunk-N6OOOYFZ.js +281 -0
  219. package/dist/chunk-N6OOOYFZ.js.map +1 -0
  220. package/dist/chunk-NAF4L3T6.js +22 -0
  221. package/dist/chunk-NAF4L3T6.js.map +1 -0
  222. package/dist/chunk-NINIJCHU.cjs +23 -0
  223. package/dist/chunk-NINIJCHU.cjs.map +1 -0
  224. package/dist/chunk-NJWYQWDL.js +43 -0
  225. package/dist/chunk-NJWYQWDL.js.map +1 -0
  226. package/dist/chunk-NQTD6QOW.cjs +226 -0
  227. package/dist/chunk-NQTD6QOW.cjs.map +1 -0
  228. package/dist/chunk-NQTNSHSB.cjs +843 -0
  229. package/dist/chunk-NQTNSHSB.cjs.map +1 -0
  230. package/dist/chunk-NVXXWAU7.cjs +13 -0
  231. package/dist/chunk-NVXXWAU7.cjs.map +1 -0
  232. package/dist/chunk-NYQ3IS7K.cjs +130 -0
  233. package/dist/chunk-NYQ3IS7K.cjs.map +1 -0
  234. package/dist/chunk-O6USDERH.js +165 -0
  235. package/dist/chunk-O6USDERH.js.map +1 -0
  236. package/dist/chunk-OBA6YK2R.cjs +8 -0
  237. package/dist/chunk-OBA6YK2R.cjs.map +1 -0
  238. package/dist/chunk-OQRGVTQF.js +169 -0
  239. package/dist/chunk-OQRGVTQF.js.map +1 -0
  240. package/dist/chunk-OR6XIWLB.js +19 -0
  241. package/dist/chunk-OR6XIWLB.js.map +1 -0
  242. package/dist/chunk-OYD3U3LY.js +10981 -0
  243. package/dist/chunk-OYD3U3LY.js.map +1 -0
  244. package/dist/chunk-PRZ3BES7.cjs +79 -0
  245. package/dist/chunk-PRZ3BES7.cjs.map +1 -0
  246. package/dist/chunk-PY2RQOA7.js +6 -0
  247. package/dist/chunk-PY2RQOA7.js.map +1 -0
  248. package/dist/chunk-Q5EWJPRY.js +18 -0
  249. package/dist/chunk-Q5EWJPRY.js.map +1 -0
  250. package/dist/chunk-QATRS7JD.cjs +158 -0
  251. package/dist/chunk-QATRS7JD.cjs.map +1 -0
  252. package/dist/chunk-QC55H6RJ.cjs +601 -0
  253. package/dist/chunk-QC55H6RJ.cjs.map +1 -0
  254. package/dist/chunk-QDM3OHUT.cjs +134 -0
  255. package/dist/chunk-QDM3OHUT.cjs.map +1 -0
  256. package/dist/chunk-QKLOP4VC.cjs +90 -0
  257. package/dist/chunk-QKLOP4VC.cjs.map +1 -0
  258. package/dist/chunk-QOGNZMHD.cjs +34 -0
  259. package/dist/chunk-QOGNZMHD.cjs.map +1 -0
  260. package/dist/chunk-QWD3CZWE.cjs +108 -0
  261. package/dist/chunk-QWD3CZWE.cjs.map +1 -0
  262. package/dist/chunk-QWD4RDZ3.cjs +136 -0
  263. package/dist/chunk-QWD4RDZ3.cjs.map +1 -0
  264. package/dist/chunk-QYLZQ43D.cjs +172 -0
  265. package/dist/chunk-QYLZQ43D.cjs.map +1 -0
  266. package/dist/chunk-R7WIIPUR.js +27 -0
  267. package/dist/chunk-R7WIIPUR.js.map +1 -0
  268. package/dist/chunk-RQMCOFAI.cjs +85 -0
  269. package/dist/chunk-RQMCOFAI.cjs.map +1 -0
  270. package/dist/chunk-SA6K24NB.cjs +25 -0
  271. package/dist/chunk-SA6K24NB.cjs.map +1 -0
  272. package/dist/chunk-SADXXGWU.js +809 -0
  273. package/dist/chunk-SADXXGWU.js.map +1 -0
  274. package/dist/chunk-SAGRF4IB.js +25 -0
  275. package/dist/chunk-SAGRF4IB.js.map +1 -0
  276. package/dist/chunk-SVQIW5RJ.js +81 -0
  277. package/dist/chunk-SVQIW5RJ.js.map +1 -0
  278. package/dist/chunk-TA3K7SBK.js +180 -0
  279. package/dist/chunk-TA3K7SBK.js.map +1 -0
  280. package/dist/chunk-TFG5IBZS.cjs +139 -0
  281. package/dist/chunk-TFG5IBZS.cjs.map +1 -0
  282. package/dist/chunk-TMKTSYDS.cjs +21 -0
  283. package/dist/chunk-TMKTSYDS.cjs.map +1 -0
  284. package/dist/chunk-UADQJBHR.cjs +172 -0
  285. package/dist/chunk-UADQJBHR.cjs.map +1 -0
  286. package/dist/chunk-UBR5PWD7.js +275 -0
  287. package/dist/chunk-UBR5PWD7.js.map +1 -0
  288. package/dist/chunk-UKMBRMGT.js +22 -0
  289. package/dist/chunk-UKMBRMGT.js.map +1 -0
  290. package/dist/chunk-V22DZIXO.js +147 -0
  291. package/dist/chunk-V22DZIXO.js.map +1 -0
  292. package/dist/chunk-VE6DFSKU.js +107 -0
  293. package/dist/chunk-VE6DFSKU.js.map +1 -0
  294. package/dist/chunk-VPK6PHIE.cjs +211 -0
  295. package/dist/chunk-VPK6PHIE.cjs.map +1 -0
  296. package/dist/chunk-VTYY7XL5.cjs +15 -0
  297. package/dist/chunk-VTYY7XL5.cjs.map +1 -0
  298. package/dist/chunk-VWUXIVEI.js +583 -0
  299. package/dist/chunk-VWUXIVEI.js.map +1 -0
  300. package/dist/chunk-WE22OXQA.js +48 -0
  301. package/dist/chunk-WE22OXQA.js.map +1 -0
  302. package/dist/chunk-WMWEI3NS.js +120 -0
  303. package/dist/chunk-WMWEI3NS.js.map +1 -0
  304. package/dist/chunk-WS5ULCL4.js +204 -0
  305. package/dist/chunk-WS5ULCL4.js.map +1 -0
  306. package/dist/chunk-XB4GI5RZ.js +115 -0
  307. package/dist/chunk-XB4GI5RZ.js.map +1 -0
  308. package/dist/chunk-XU6MLSC6.js +455 -0
  309. package/dist/chunk-XU6MLSC6.js.map +1 -0
  310. package/dist/chunk-XYFGKVZ7.js +15 -0
  311. package/dist/chunk-XYFGKVZ7.js.map +1 -0
  312. package/dist/chunk-Y2KYR2ED.cjs +118 -0
  313. package/dist/chunk-Y2KYR2ED.cjs.map +1 -0
  314. package/dist/chunk-YIFFF23U.cjs +109 -0
  315. package/dist/chunk-YIFFF23U.cjs.map +1 -0
  316. package/dist/chunk-YJNYDJ2T.cjs +27 -0
  317. package/dist/chunk-YJNYDJ2T.cjs.map +1 -0
  318. package/dist/chunk-YSTXFWQE.cjs +127 -0
  319. package/dist/chunk-YSTXFWQE.cjs.map +1 -0
  320. package/dist/chunk-Z2JFX372.cjs +595 -0
  321. package/dist/chunk-Z2JFX372.cjs.map +1 -0
  322. package/dist/chunk-Z3NTRKIC.cjs +111 -0
  323. package/dist/chunk-Z3NTRKIC.cjs.map +1 -0
  324. package/dist/chunk-ZF2LDKQQ.cjs +20 -0
  325. package/dist/chunk-ZF2LDKQQ.cjs.map +1 -0
  326. package/dist/client/index.cjs +73 -0
  327. package/dist/client/index.cjs.map +1 -0
  328. package/dist/client/index.d.cts +12 -0
  329. package/dist/client/index.d.ts +12 -0
  330. package/dist/client/index.js +71 -0
  331. package/dist/client/index.js.map +1 -0
  332. package/dist/client/theokit-client.d.cts +60 -0
  333. package/dist/client/theokit-client.d.ts +60 -0
  334. package/dist/client/types.d.cts +51 -0
  335. package/dist/client/types.d.ts +51 -0
  336. package/dist/compact-session-BHTPCIHA.cjs +61 -0
  337. package/dist/compact-session-BHTPCIHA.cjs.map +1 -0
  338. package/dist/compact-session-W4WLJTHA.js +24 -0
  339. package/dist/compact-session-W4WLJTHA.js.map +1 -0
  340. package/dist/compaction.cjs +66 -0
  341. package/dist/compaction.cjs.map +1 -0
  342. package/dist/compaction.d.cts +240 -0
  343. package/dist/compaction.d.ts +240 -0
  344. package/dist/compaction.js +5 -0
  345. package/dist/compaction.js.map +1 -0
  346. package/dist/concurrency.cjs +23 -0
  347. package/dist/concurrency.cjs.map +1 -0
  348. package/dist/concurrency.d.cts +22 -0
  349. package/dist/concurrency.d.ts +22 -0
  350. package/dist/concurrency.js +17 -0
  351. package/dist/concurrency.js.map +1 -0
  352. package/dist/context/index.cjs +37 -0
  353. package/dist/context/index.cjs.map +1 -0
  354. package/dist/context/index.d.cts +78 -0
  355. package/dist/context/index.d.ts +78 -0
  356. package/dist/context/index.js +20 -0
  357. package/dist/context/index.js.map +1 -0
  358. package/dist/context-4QOEWRDF.cjs +23 -0
  359. package/dist/context-4QOEWRDF.cjs.map +1 -0
  360. package/dist/context-Z3CFTT3H.js +6 -0
  361. package/dist/context-Z3CFTT3H.js.map +1 -0
  362. package/dist/create-skill.d.ts +40 -0
  363. package/dist/cron-C3PhZED0.d.cts +246 -0
  364. package/dist/cron-crfMMdAw.d.ts +246 -0
  365. package/dist/cron.cjs +68 -0
  366. package/dist/cron.cjs.map +1 -0
  367. package/dist/cron.d.cts +7 -0
  368. package/dist/cron.d.ts +7 -0
  369. package/dist/cron.js +59 -0
  370. package/dist/cron.js.map +1 -0
  371. package/dist/define-tool.d.ts +86 -0
  372. package/dist/errors-CLOAyuiv.d.ts +569 -0
  373. package/dist/errors-DrDEgyz1.d.cts +569 -0
  374. package/dist/errors-base-B5g01neU.d.cts +75 -0
  375. package/dist/errors-base-B5g01neU.d.ts +75 -0
  376. package/dist/errors-base.d.ts +73 -0
  377. package/dist/errors.cjs +89 -0
  378. package/dist/errors.cjs.map +1 -0
  379. package/dist/errors.d.cts +4 -0
  380. package/dist/errors.d.ts +4 -0
  381. package/dist/errors.js +4 -0
  382. package/dist/errors.js.map +1 -0
  383. package/dist/eval.cjs +1056 -0
  384. package/dist/eval.cjs.map +1 -0
  385. package/dist/eval.d.cts +77 -0
  386. package/dist/eval.d.ts +77 -0
  387. package/dist/eval.js +1042 -0
  388. package/dist/eval.js.map +1 -0
  389. package/dist/event-bus.d.ts +42 -0
  390. package/dist/executor-XQAOQOHD.cjs +993 -0
  391. package/dist/executor-XQAOQOHD.cjs.map +1 -0
  392. package/dist/executor-ZNDQDX6Q.js +989 -0
  393. package/dist/executor-ZNDQDX6Q.js.map +1 -0
  394. package/dist/filesystem/index.cjs +204 -0
  395. package/dist/filesystem/index.cjs.map +1 -0
  396. package/dist/filesystem/index.d.cts +12 -0
  397. package/dist/filesystem/index.d.ts +12 -0
  398. package/dist/filesystem/index.js +195 -0
  399. package/dist/filesystem/index.js.map +1 -0
  400. package/dist/filesystem/local-filesystem.d.cts +54 -0
  401. package/dist/filesystem/local-filesystem.d.ts +54 -0
  402. package/dist/filesystem/types.d.cts +136 -0
  403. package/dist/filesystem/types.d.ts +136 -0
  404. package/dist/fork-agent-S2EPIML7.js +61 -0
  405. package/dist/fork-agent-S2EPIML7.js.map +1 -0
  406. package/dist/fork-agent-WAEQI2DL.cjs +64 -0
  407. package/dist/fork-agent-WAEQI2DL.cjs.map +1 -0
  408. package/dist/fs-session-store-77JU46UZ.js +10 -0
  409. package/dist/fs-session-store-77JU46UZ.js.map +1 -0
  410. package/dist/fs-session-store-E4U3P56L.cjs +19 -0
  411. package/dist/fs-session-store-E4U3P56L.cjs.map +1 -0
  412. package/dist/generate-object-BXV7BZRP.js +7 -0
  413. package/dist/generate-object-BXV7BZRP.js.map +1 -0
  414. package/dist/generate-object-YBI2TDJ3.cjs +20 -0
  415. package/dist/generate-object-YBI2TDJ3.cjs.map +1 -0
  416. package/dist/generate-object.d.ts +111 -0
  417. package/dist/index-manager-3UNPYH34.cjs +26 -0
  418. package/dist/index-manager-3UNPYH34.cjs.map +1 -0
  419. package/dist/index-manager-W7FDMGEG.js +17 -0
  420. package/dist/index-manager-W7FDMGEG.js.map +1 -0
  421. package/dist/index.cjs +2487 -0
  422. package/dist/index.cjs.map +1 -0
  423. package/dist/index.d.cts +4166 -0
  424. package/dist/index.d.ts +4166 -0
  425. package/dist/index.js +2289 -0
  426. package/dist/index.js.map +1 -0
  427. package/dist/inject-session-SUM6TDJF.js +27 -0
  428. package/dist/inject-session-SUM6TDJF.js.map +1 -0
  429. package/dist/inject-session-W6A46J3E.cjs +29 -0
  430. package/dist/inject-session-W6A46J3E.cjs.map +1 -0
  431. package/dist/interactive/index.cjs +35 -0
  432. package/dist/interactive/index.cjs.map +1 -0
  433. package/dist/interactive/index.d.cts +12 -0
  434. package/dist/interactive/index.d.ts +12 -0
  435. package/dist/interactive/index.js +30 -0
  436. package/dist/interactive/index.js.map +1 -0
  437. package/dist/interactive/types.d.cts +95 -0
  438. package/dist/interactive/types.d.ts +95 -0
  439. package/dist/internal/agent/batch.d.ts +11 -0
  440. package/dist/internal/agent/helpers.d.ts +1 -0
  441. package/dist/internal/agent-loop/budget-gate.d.ts +1 -0
  442. package/dist/internal/agent-loop/doom-loop-tracker.d.ts +22 -0
  443. package/dist/internal/agent-loop/live-events.d.ts +46 -0
  444. package/dist/internal/agent-loop/loop-context-init.d.ts +2 -0
  445. package/dist/internal/agent-loop/loop-finalize.d.ts +25 -0
  446. package/dist/internal/agent-loop/loop-llm-stream.d.ts +1 -0
  447. package/dist/internal/agent-loop/loop-thinking-steps.d.ts +28 -0
  448. package/dist/internal/agent-loop/loop.d.ts +7 -0
  449. package/dist/internal/agent-loop/message-builders.d.ts +21 -0
  450. package/dist/internal/agent-loop/replay-messages.d.ts +41 -0
  451. package/dist/internal/agent-loop/tool-dispatch.d.ts +27 -0
  452. package/dist/internal/agent-loop/tool-executors.d.ts +1 -0
  453. package/dist/internal/agent-loop/tool-result-guard.d.ts +20 -0
  454. package/dist/internal/agent-loop/tool-timeout.d.ts +23 -0
  455. package/dist/internal/agent-loop/types.d.ts +43 -0
  456. package/dist/internal/agent-loop/usage-and-cost.d.ts +25 -0
  457. package/dist/internal/auth/api-key-prefix.d.ts +23 -0
  458. package/dist/internal/auth/api-key-validator.d.ts +46 -0
  459. package/dist/internal/auth/credential-availability.d.ts +61 -0
  460. package/dist/internal/auth/credential-store.d.ts +77 -0
  461. package/dist/internal/auth/oauth-device.d.ts +54 -0
  462. package/dist/internal/auth/oauth-engine.d.ts +21 -0
  463. package/dist/internal/auth/resolve-credential.d.ts +56 -0
  464. package/dist/internal/auth/types.d.ts +175 -0
  465. package/dist/internal/base-url.d.ts +14 -0
  466. package/dist/internal/budget/compute-cost.d.ts +28 -0
  467. package/dist/internal/budget/pricing-registry.d.ts +36 -0
  468. package/dist/internal/budget/tracker/budget-tracker.d.ts +11 -0
  469. package/dist/internal/budget/tracker/budget.d.ts +34 -0
  470. package/dist/internal/budget/usage-accumulator.d.ts +46 -0
  471. package/dist/internal/cloud-agent/cloud-agent.d.ts +1 -0
  472. package/dist/internal/cloud-agent/cloud-config-serializer.d.ts +3 -0
  473. package/dist/internal/cloud-agent/cloud-run.d.ts +1 -0
  474. package/dist/internal/cloud-agent/cloud-tool-parity.d.ts +1 -0
  475. package/dist/internal/cloud-agent/index.d.ts +7 -0
  476. package/dist/internal/cloud-agent/real-cloud-run.d.ts +2 -0
  477. package/dist/internal/cloud-agent/types.d.ts +56 -0
  478. package/dist/internal/concurrency/abort-utils.d.ts +21 -0
  479. package/dist/internal/concurrency/async-local-storage.d.ts +20 -0
  480. package/dist/internal/concurrency/async-semaphore.d.ts +24 -0
  481. package/dist/internal/concurrency/delegation-depth.d.ts +27 -0
  482. package/dist/internal/concurrency/map-with-concurrency.d.ts +28 -0
  483. package/dist/internal/concurrency/subagent-credentials.d.ts +112 -0
  484. package/dist/internal/diagnostics.d.ts +69 -0
  485. package/dist/internal/emit-run-event.d.ts +16 -0
  486. package/dist/internal/env.d.ts +1 -0
  487. package/dist/internal/error-mappers/anthropic.d.ts +30 -0
  488. package/dist/internal/error-mappers/bedrock.d.ts +16 -0
  489. package/dist/internal/error-mappers/default-retriable.d.ts +1 -0
  490. package/dist/internal/error-mappers/ollama.d.ts +41 -0
  491. package/dist/internal/error-mappers/openai-compatible.d.ts +25 -0
  492. package/dist/internal/error-mappers/shared.d.ts +23 -0
  493. package/dist/internal/error-mappers/vertex.d.ts +15 -0
  494. package/dist/internal/eval/aggregate.d.ts +9 -0
  495. package/dist/internal/eval/assert.d.ts +27 -0
  496. package/dist/internal/eval/code-runner.d.ts +28 -0
  497. package/dist/internal/eval/dataset-iter.d.ts +9 -0
  498. package/dist/internal/eval/runner.d.ts +9 -0
  499. package/dist/internal/eval/single-flight.d.ts +17 -0
  500. package/dist/internal/eval/telemetry.d.ts +23 -0
  501. package/dist/internal/eval/trials.d.ts +19 -0
  502. package/dist/internal/global-singleton.d.ts +16 -0
  503. package/dist/internal/http.d.ts +1 -0
  504. package/dist/internal/ids.d.ts +1 -0
  505. package/dist/internal/judge/judge-call.d.ts +48 -0
  506. package/dist/internal/judge/parse-verdict.d.ts +11 -0
  507. package/dist/internal/llm/abort-error.d.ts +1 -0
  508. package/dist/internal/llm/anthropic-shared.d.ts +100 -0
  509. package/dist/internal/llm/anthropic.d.ts +9 -0
  510. package/dist/internal/llm/bedrock-anthropic.d.ts +36 -0
  511. package/dist/internal/llm/bedrock-token-cache.d.ts +18 -0
  512. package/dist/internal/llm/credential-pool-context.d.ts +11 -0
  513. package/dist/internal/llm/credential-pool-types.d.ts +22 -0
  514. package/dist/internal/llm/credential-pool.d.ts +18 -0
  515. package/dist/internal/llm/fallback-client.d.ts +1 -0
  516. package/dist/internal/llm/fault-injection.d.ts +50 -0
  517. package/dist/internal/llm/finish.d.ts +1 -0
  518. package/dist/internal/llm/hermes-tool-extract.d.ts +11 -0
  519. package/dist/internal/llm/model-capabilities.d.ts +40 -0
  520. package/dist/internal/llm/model-identifier.d.ts +58 -0
  521. package/dist/internal/llm/model-option.d.ts +38 -0
  522. package/dist/internal/llm/ollama-native.d.ts +27 -0
  523. package/dist/internal/llm/openai-messages.d.ts +2 -0
  524. package/dist/internal/llm/openai.d.ts +146 -0
  525. package/dist/internal/llm/pool-aware-client.d.ts +16 -0
  526. package/dist/internal/llm/prompt-cache-key.d.ts +1 -0
  527. package/dist/internal/llm/responses.d.ts +97 -0
  528. package/dist/internal/llm/retry.d.ts +22 -0
  529. package/dist/internal/llm/retrying-client.d.ts +53 -0
  530. package/dist/internal/llm/router.d.ts +40 -0
  531. package/dist/internal/llm/sse.d.ts +21 -0
  532. package/dist/internal/llm/stream-relay.d.ts +17 -0
  533. package/dist/internal/llm/tool-result-content.d.ts +40 -0
  534. package/dist/internal/llm/transport-error.d.ts +9 -0
  535. package/dist/internal/llm/types.d.ts +226 -0
  536. package/dist/internal/llm/vertex-anthropic.d.ts +40 -0
  537. package/dist/internal/llm/vertex-auth.d.ts +30 -0
  538. package/dist/internal/llm/vertex-gemini.d.ts +28 -0
  539. package/dist/internal/llm/vertex-router.d.ts +21 -0
  540. package/dist/internal/local-agent/index.d.ts +6 -0
  541. package/dist/internal/local-agent/local-agent-bootstrap.d.ts +37 -0
  542. package/dist/internal/local-agent/local-agent-capabilities.d.ts +38 -0
  543. package/dist/internal/local-agent/local-agent-dispatch.d.ts +57 -0
  544. package/dist/internal/local-agent/local-agent-invalidate.d.ts +1 -0
  545. package/dist/internal/local-agent/local-agent-lifecycle.d.ts +13 -0
  546. package/dist/internal/local-agent/local-agent-memory-direct.d.ts +12 -0
  547. package/dist/internal/local-agent/local-agent-memory-hooks.d.ts +41 -0
  548. package/dist/internal/local-agent/local-agent-memory-provider.d.ts +57 -0
  549. package/dist/internal/local-agent/local-agent-memory.d.ts +1 -0
  550. package/dist/internal/local-agent/local-agent-personality-extensions.d.ts +43 -0
  551. package/dist/internal/local-agent/local-agent-runtime-extensions.d.ts +13 -0
  552. package/dist/internal/local-agent/local-agent-send.d.ts +42 -0
  553. package/dist/internal/local-agent/local-agent-task-wrap.d.ts +11 -0
  554. package/dist/internal/local-agent/local-agent.d.ts +1 -0
  555. package/dist/internal/local-agent/local-option-keys.d.ts +2 -0
  556. package/dist/internal/local-agent/local-run.d.ts +1 -0
  557. package/dist/internal/local-agent/mcp-pool.d.ts +43 -0
  558. package/dist/internal/local-agent/real-local-run-mcp.d.ts +26 -0
  559. package/dist/internal/local-agent/real-local-run-options.d.ts +26 -0
  560. package/dist/internal/local-agent/real-local-run-provider.d.ts +13 -0
  561. package/dist/internal/local-agent/real-local-run-tools.d.ts +55 -0
  562. package/dist/internal/local-agent/real-local-run.d.ts +4 -0
  563. package/dist/internal/mcp/client.d.ts +16 -0
  564. package/dist/internal/mcp/handshake-timeout.d.ts +53 -0
  565. package/dist/internal/mcp/oauth.d.ts +19 -0
  566. package/dist/internal/mcp/token-storage.d.ts +52 -0
  567. package/dist/internal/memory/active-memory-cache.d.ts +10 -0
  568. package/dist/internal/memory/active-memory-types.d.ts +8 -0
  569. package/dist/internal/memory/active-memory.d.ts +56 -0
  570. package/dist/internal/memory/adapters/azure-openai-embedding.d.cts +2 -0
  571. package/dist/internal/memory/adapters/azure-openai-embedding.d.ts +2 -0
  572. package/dist/internal/memory/adapters/catalog.d.cts +1 -0
  573. package/dist/internal/memory/adapters/catalog.d.ts +1 -0
  574. package/dist/internal/memory/adapters/cohere-embedding.d.cts +2 -0
  575. package/dist/internal/memory/adapters/cohere-embedding.d.ts +2 -0
  576. package/dist/internal/memory/adapters/deepinfra-embedding.d.cts +2 -0
  577. package/dist/internal/memory/adapters/deepinfra-embedding.d.ts +2 -0
  578. package/dist/internal/memory/adapters/gemini-embedding.d.cts +2 -0
  579. package/dist/internal/memory/adapters/gemini-embedding.d.ts +2 -0
  580. package/dist/internal/memory/adapters/index.cjs +30 -0
  581. package/dist/internal/memory/adapters/index.cjs.map +1 -0
  582. package/dist/internal/memory/adapters/index.d.cts +18 -0
  583. package/dist/internal/memory/adapters/index.d.ts +18 -0
  584. package/dist/internal/memory/adapters/index.js +13 -0
  585. package/dist/internal/memory/adapters/index.js.map +1 -0
  586. package/dist/internal/memory/adapters/jina-embedding.d.cts +2 -0
  587. package/dist/internal/memory/adapters/jina-embedding.d.ts +2 -0
  588. package/dist/internal/memory/adapters/mistral-embedding.d.cts +2 -0
  589. package/dist/internal/memory/adapters/mistral-embedding.d.ts +2 -0
  590. package/dist/internal/memory/adapters/ollama-embedding.d.cts +34 -0
  591. package/dist/internal/memory/adapters/ollama-embedding.d.ts +34 -0
  592. package/dist/internal/memory/adapters/openai-compatible.d.cts +96 -0
  593. package/dist/internal/memory/adapters/openai-compatible.d.ts +96 -0
  594. package/dist/internal/memory/adapters/openai-embedding.d.cts +12 -0
  595. package/dist/internal/memory/adapters/openai-embedding.d.ts +12 -0
  596. package/dist/internal/memory/adapters/openrouter-embedding.d.cts +2 -0
  597. package/dist/internal/memory/adapters/openrouter-embedding.d.ts +2 -0
  598. package/dist/internal/memory/adapters/voyage-embedding.d.cts +2 -0
  599. package/dist/internal/memory/adapters/voyage-embedding.d.ts +2 -0
  600. package/dist/internal/memory/corpus-sync.d.ts +23 -0
  601. package/dist/internal/memory/dreaming/diary.d.ts +41 -0
  602. package/dist/internal/memory/dreaming/phases.d.ts +35 -0
  603. package/dist/internal/memory/dreaming/run.d.ts +10 -0
  604. package/dist/internal/memory/embedding-adapter.d.ts +42 -0
  605. package/dist/internal/memory/embedding-cache.d.ts +42 -0
  606. package/dist/internal/memory/escape-like-pattern.d.ts +22 -0
  607. package/dist/internal/memory/index-db.d.ts +67 -0
  608. package/dist/internal/memory/index-manager-contract.d.ts +48 -0
  609. package/dist/internal/memory/index-manager-dispatch.d.ts +23 -0
  610. package/dist/internal/memory/index-manager-helpers.d.ts +20 -0
  611. package/dist/internal/memory/index-manager.d.ts +44 -0
  612. package/dist/internal/memory/index-repository.d.ts +58 -0
  613. package/dist/internal/memory/index-schema.d.ts +21 -0
  614. package/dist/internal/memory/lance-index.d.ts +46 -0
  615. package/dist/internal/memory/lance-memory-adapter.d.ts +45 -0
  616. package/dist/internal/memory/memory-index.d.ts +67 -0
  617. package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +58 -0
  618. package/dist/internal/memory/migration.d.ts +9 -0
  619. package/dist/internal/memory/sdk-memory-peer-loader.d.ts +74 -0
  620. package/dist/internal/memory/sqlite-vec-loader.d.ts +1 -0
  621. package/dist/internal/memory/storage/chunk-markdown.d.cts +2 -0
  622. package/dist/internal/memory/storage/chunk-markdown.d.ts +2 -0
  623. package/dist/internal/memory/storage/index.cjs +141 -0
  624. package/dist/internal/memory/storage/index.cjs.map +1 -0
  625. package/dist/internal/memory/storage/index.d.cts +28 -0
  626. package/dist/internal/memory/storage/index.d.ts +28 -0
  627. package/dist/internal/memory/storage/index.js +16 -0
  628. package/dist/internal/memory/storage/index.js.map +1 -0
  629. package/dist/internal/memory/storage/list-markdown.d.cts +1 -0
  630. package/dist/internal/memory/storage/list-markdown.d.ts +1 -0
  631. package/dist/internal/memory/storage/markdown-store.d.cts +48 -0
  632. package/dist/internal/memory/storage/markdown-store.d.ts +48 -0
  633. package/dist/internal/memory/storage/memory-file.d.cts +90 -0
  634. package/dist/internal/memory/storage/memory-file.d.ts +90 -0
  635. package/dist/internal/memory/storage/memory-root.d.cts +119 -0
  636. package/dist/internal/memory/storage/memory-root.d.ts +119 -0
  637. package/dist/internal/memory/storage/reader.d.cts +8 -0
  638. package/dist/internal/memory/storage/reader.d.ts +8 -0
  639. package/dist/internal/memory/storage/session-loader.d.cts +35 -0
  640. package/dist/internal/memory/storage/session-loader.d.ts +35 -0
  641. package/dist/internal/memory/storage/session-summary-writer.d.cts +50 -0
  642. package/dist/internal/memory/storage/session-summary-writer.d.ts +50 -0
  643. package/dist/internal/memory/storage/threat-scan.d.cts +62 -0
  644. package/dist/internal/memory/storage/threat-scan.d.ts +62 -0
  645. package/dist/internal/memory/storage/transcript-store.d.cts +38 -0
  646. package/dist/internal/memory/storage/transcript-store.d.ts +38 -0
  647. package/dist/internal/memory/storage/wiki-loader.d.cts +27 -0
  648. package/dist/internal/memory/storage/wiki-loader.d.ts +27 -0
  649. package/dist/internal/memory/tools.d.ts +21 -0
  650. package/dist/internal/memory/types.d.ts +78 -0
  651. package/dist/internal/memory/vec-index.d.ts +28 -0
  652. package/dist/internal/persistence/atomic-write.d.cts +107 -0
  653. package/dist/internal/persistence/atomic-write.d.ts +107 -0
  654. package/dist/internal/persistence/cwd-mutex.d.cts +35 -0
  655. package/dist/internal/persistence/cwd-mutex.d.ts +35 -0
  656. package/dist/internal/persistence/exclusive-create.d.cts +53 -0
  657. package/dist/internal/persistence/exclusive-create.d.ts +53 -0
  658. package/dist/internal/persistence/file-lock.d.cts +54 -0
  659. package/dist/internal/persistence/file-lock.d.ts +54 -0
  660. package/dist/internal/persistence/fs-session-store.d.cts +68 -0
  661. package/dist/internal/persistence/fs-session-store.d.ts +68 -0
  662. package/dist/internal/persistence/fts5-sanitize.d.cts +44 -0
  663. package/dist/internal/persistence/fts5-sanitize.d.ts +44 -0
  664. package/dist/internal/persistence/index.cjs +127 -0
  665. package/dist/internal/persistence/index.cjs.map +1 -0
  666. package/dist/internal/persistence/index.d.cts +33 -0
  667. package/dist/internal/persistence/index.d.ts +33 -0
  668. package/dist/internal/persistence/index.js +40 -0
  669. package/dist/internal/persistence/index.js.map +1 -0
  670. package/dist/internal/persistence/jsonl.d.cts +43 -0
  671. package/dist/internal/persistence/jsonl.d.ts +43 -0
  672. package/dist/internal/persistence/markdown-config-loader.d.cts +35 -0
  673. package/dist/internal/persistence/markdown-config-loader.d.ts +35 -0
  674. package/dist/internal/persistence/pagination.d.cts +21 -0
  675. package/dist/internal/persistence/pagination.d.ts +21 -0
  676. package/dist/internal/persistence/paths.d.cts +137 -0
  677. package/dist/internal/persistence/paths.d.ts +137 -0
  678. package/dist/internal/persistence/persistence-schema.d.cts +29 -0
  679. package/dist/internal/persistence/persistence-schema.d.ts +29 -0
  680. package/dist/internal/persistence/schema-version.d.cts +227 -0
  681. package/dist/internal/persistence/schema-version.d.ts +227 -0
  682. package/dist/internal/persistence/session-artifacts.d.cts +27 -0
  683. package/dist/internal/persistence/session-artifacts.d.ts +27 -0
  684. package/dist/internal/persistence/session-dir.d.cts +1 -0
  685. package/dist/internal/persistence/session-dir.d.ts +1 -0
  686. package/dist/internal/persistence/session-transcript.d.cts +128 -0
  687. package/dist/internal/persistence/session-transcript.d.ts +128 -0
  688. package/dist/internal/persistence/session-writer.d.cts +104 -0
  689. package/dist/internal/persistence/session-writer.d.ts +104 -0
  690. package/dist/internal/persistence/sqlite-cas.d.cts +61 -0
  691. package/dist/internal/persistence/sqlite-cas.d.ts +61 -0
  692. package/dist/internal/persistence/sqlite-open.d.cts +61 -0
  693. package/dist/internal/persistence/sqlite-open.d.ts +61 -0
  694. package/dist/internal/persistence/sqlite-wal.d.cts +54 -0
  695. package/dist/internal/persistence/sqlite-wal.d.ts +54 -0
  696. package/dist/internal/persistence/transcript-ops.d.cts +99 -0
  697. package/dist/internal/persistence/transcript-ops.d.ts +99 -0
  698. package/dist/internal/personality/context.d.ts +17 -0
  699. package/dist/internal/personality/registry.d.ts +17 -0
  700. package/dist/internal/personality/store.d.ts +27 -0
  701. package/dist/internal/personality/switch.d.ts +36 -0
  702. package/dist/internal/personality/types.d.ts +18 -0
  703. package/dist/internal/plugins/context.d.cts +21 -0
  704. package/dist/internal/plugins/context.d.ts +21 -0
  705. package/dist/internal/plugins/enabled-names.d.cts +1 -0
  706. package/dist/internal/plugins/enabled-names.d.ts +1 -0
  707. package/dist/internal/plugins/index.d.cts +9 -0
  708. package/dist/internal/plugins/index.d.ts +9 -0
  709. package/dist/internal/plugins/lifecycle.d.cts +15 -0
  710. package/dist/internal/plugins/lifecycle.d.ts +15 -0
  711. package/dist/internal/plugins/manager.d.cts +57 -0
  712. package/dist/internal/plugins/manager.d.ts +57 -0
  713. package/dist/internal/plugins/plugin-guards.d.cts +13 -0
  714. package/dist/internal/plugins/plugin-guards.d.ts +13 -0
  715. package/dist/internal/plugins/types.d.cts +26 -0
  716. package/dist/internal/plugins/types.d.ts +26 -0
  717. package/dist/internal/providers/builtin/anthropic.d.ts +2 -0
  718. package/dist/internal/providers/builtin/bedrock.d.ts +25 -0
  719. package/dist/internal/providers/builtin/cerebras.d.ts +5 -0
  720. package/dist/internal/providers/builtin/cohere.d.ts +8 -0
  721. package/dist/internal/providers/builtin/deepinfra.d.ts +2 -0
  722. package/dist/internal/providers/builtin/gemini.d.ts +10 -0
  723. package/dist/internal/providers/builtin/google.d.ts +6 -0
  724. package/dist/internal/providers/builtin/groq.d.ts +2 -0
  725. package/dist/internal/providers/builtin/index.d.ts +20 -0
  726. package/dist/internal/providers/builtin/llamacpp.d.ts +1 -0
  727. package/dist/internal/providers/builtin/lmstudio.d.ts +1 -0
  728. package/dist/internal/providers/builtin/mistral.d.ts +2 -0
  729. package/dist/internal/providers/builtin/ollama.d.ts +17 -0
  730. package/dist/internal/providers/builtin/openai-chatgpt.d.ts +14 -0
  731. package/dist/internal/providers/builtin/openai-compatible.d.ts +1 -0
  732. package/dist/internal/providers/builtin/openai.d.ts +2 -0
  733. package/dist/internal/providers/builtin/openrouter.d.ts +2 -0
  734. package/dist/internal/providers/builtin/perplexity.d.ts +5 -0
  735. package/dist/internal/providers/builtin/together.d.ts +2 -0
  736. package/dist/internal/providers/builtin/vertex.d.ts +27 -0
  737. package/dist/internal/providers/builtin/xai.d.ts +2 -0
  738. package/dist/internal/providers/catalog-loader.d.ts +55 -0
  739. package/dist/internal/providers/catalog-schema.d.ts +202 -0
  740. package/dist/internal/providers/catalog-source-models-dev.d.ts +80 -0
  741. package/dist/internal/providers/discovery.d.ts +14 -0
  742. package/dist/internal/providers/index.d.ts +8 -0
  743. package/dist/internal/providers/register-plugin-providers.d.ts +22 -0
  744. package/dist/internal/providers/registry.d.ts +13 -0
  745. package/dist/internal/providers/types.d.ts +11 -0
  746. package/dist/internal/retry/circuit-breaker.d.ts +26 -0
  747. package/dist/internal/retry/with-retry.d.ts +40 -0
  748. package/dist/internal/runtime/compat/compat-config-file.d.ts +31 -0
  749. package/dist/internal/runtime/compat/foreign-config-sources.d.ts +139 -0
  750. package/dist/internal/runtime/compression/compression-attempt.d.ts +24 -0
  751. package/dist/internal/runtime/compression/compression-config.d.ts +33 -0
  752. package/dist/internal/runtime/compression/compression-decision.d.ts +10 -0
  753. package/dist/internal/runtime/compression/compression-helpers.d.ts +18 -0
  754. package/dist/internal/runtime/compression/compression-model-registry.d.ts +41 -0
  755. package/dist/internal/runtime/compression/compression-summarizer.d.ts +34 -0
  756. package/dist/internal/runtime/config/default-model.d.ts +1 -0
  757. package/dist/internal/runtime/config/providers-manager.d.ts +1 -0
  758. package/dist/internal/runtime/config/workspace-dir.d.ts +9 -0
  759. package/dist/internal/runtime/context/context-aggregator.d.ts +26 -0
  760. package/dist/internal/runtime/context/context-discovery-runner.d.ts +80 -0
  761. package/dist/internal/runtime/context/context-discovery.d.ts +79 -0
  762. package/dist/internal/runtime/context/context-frontmatter.d.ts +16 -0
  763. package/dist/internal/runtime/context/context-glob.d.ts +1 -0
  764. package/dist/internal/runtime/context/context-import-resolver.d.ts +41 -0
  765. package/dist/internal/runtime/context/context-loaders.d.ts +42 -0
  766. package/dist/internal/runtime/context/context-manager.d.ts +28 -0
  767. package/dist/internal/runtime/context/context-mdc-parser.d.ts +25 -0
  768. package/dist/internal/runtime/context/context-rules-frontmatter.d.ts +99 -0
  769. package/dist/internal/runtime/context/context-yaml-lite.d.ts +26 -0
  770. package/dist/internal/runtime/context/project-instructions.d.ts +66 -0
  771. package/dist/internal/runtime/context/yaml-frontmatter.d.ts +20 -0
  772. package/dist/internal/runtime/fixtures/fixture-events.d.ts +12 -0
  773. package/dist/internal/runtime/fixtures/fixture-mode.d.ts +24 -0
  774. package/dist/internal/runtime/fixtures/fixture-responder.d.ts +1 -0
  775. package/dist/internal/runtime/fixtures/fixture-run-base.d.ts +96 -0
  776. package/dist/internal/runtime/fixtures/fixture-scripts.d.ts +21 -0
  777. package/dist/internal/runtime/fixtures/types.d.ts +1 -0
  778. package/dist/internal/runtime/hooks/hooks-executor.d.ts +49 -0
  779. package/dist/internal/runtime/hooks/hooks-source.d.ts +35 -0
  780. package/dist/internal/runtime/lifecycle/context-budget-event.d.ts +25 -0
  781. package/dist/internal/runtime/lifecycle/env-policy.d.ts +29 -0
  782. package/dist/internal/runtime/lifecycle/fork-agent.d.ts +15 -0
  783. package/dist/internal/runtime/lifecycle/goal-marker.d.ts +13 -0
  784. package/dist/internal/runtime/lifecycle/post-run-lifecycle.d.ts +16 -0
  785. package/dist/internal/runtime/lifecycle/run-to-completion.d.ts +22 -0
  786. package/dist/internal/runtime/lifecycle/run-until.d.ts +21 -0
  787. package/dist/internal/runtime/lifecycle/spawn-collect.d.ts +8 -0
  788. package/dist/internal/runtime/lifecycle/stream-to-completion.d.ts +31 -0
  789. package/dist/internal/runtime/lifecycle/wrap-completion-check-run.d.ts +30 -0
  790. package/dist/internal/runtime/memory-glue/memory-provider.d.ts +11 -0
  791. package/dist/internal/runtime/memory-glue/memory-store.d.ts +4 -0
  792. package/dist/internal/runtime/memory-glue/select-facts.d.ts +63 -0
  793. package/dist/internal/runtime/model-selection.d.ts +14 -0
  794. package/dist/internal/runtime/plugin-loader/plugin-bundles.d.ts +22 -0
  795. package/dist/internal/runtime/plugin-loader/plugin-frontmatter.d.ts +17 -0
  796. package/dist/internal/runtime/plugin-loader/plugins-manager.d.ts +1 -0
  797. package/dist/internal/runtime/processors/run-processors.d.ts +10 -0
  798. package/dist/internal/runtime/processors/tripwire-run.d.ts +16 -0
  799. package/dist/internal/runtime/processors/wrap-output-run.d.ts +18 -0
  800. package/dist/internal/runtime/registry/agent-factory-registry.d.ts +19 -0
  801. package/dist/internal/runtime/registry/agent-registry-contract.d.ts +31 -0
  802. package/dist/internal/runtime/registry/agent-registry-store.d.ts +75 -0
  803. package/dist/internal/runtime/registry/agent-registry.d.ts +6 -0
  804. package/dist/internal/runtime/registry/live-agent-registry.d.ts +132 -0
  805. package/dist/internal/runtime/registry/run-registry.d.ts +4 -0
  806. package/dist/internal/runtime/skills/discover-skills.d.ts +103 -0
  807. package/dist/internal/runtime/skills/skill-frontmatter.d.ts +6 -0
  808. package/dist/internal/runtime/skills/skills-block.d.ts +18 -0
  809. package/dist/internal/runtime/skills/skills-manager.d.ts +1 -0
  810. package/dist/internal/runtime/skills/subagent-tool-scope.d.ts +25 -0
  811. package/dist/internal/runtime/skills/subagents-loader.d.ts +1 -0
  812. package/dist/internal/runtime/system-prompt/escape.d.ts +1 -0
  813. package/dist/internal/runtime/system-prompt/local-assembly.d.ts +2 -0
  814. package/dist/internal/runtime/system-prompt/native-reasoning.d.ts +25 -0
  815. package/dist/internal/runtime/system-prompt/pipeline.d.ts +1 -0
  816. package/dist/internal/runtime/system-prompt/safe-call.d.ts +1 -0
  817. package/dist/internal/runtime/system-prompt/sources/active-memory-provider.d.ts +1 -0
  818. package/dist/internal/runtime/system-prompt/sources/base-provider.d.ts +1 -0
  819. package/dist/internal/runtime/system-prompt/sources/context-provider.d.ts +1 -0
  820. package/dist/internal/runtime/system-prompt/sources/memory-provider.d.ts +6 -0
  821. package/dist/internal/runtime/system-prompt/sources/reasoning-provider.d.ts +1 -0
  822. package/dist/internal/runtime/system-prompt/sources/skills-provider.d.ts +1 -0
  823. package/dist/internal/runtime/system-prompt/system-prompt.d.ts +1 -0
  824. package/dist/internal/runtime/system-prompt/types.d.ts +5 -0
  825. package/dist/internal/runtime/tools/shell-tool.d.ts +7 -0
  826. package/dist/internal/runtime/validation/validate-agent-options.d.ts +1 -0
  827. package/dist/internal/runtime/validation/validate-response.d.ts +18 -0
  828. package/dist/internal/scorers/levenshtein.d.ts +11 -0
  829. package/dist/internal/scorers/llm-judge.d.ts +41 -0
  830. package/dist/internal/security/index.cjs +52 -0
  831. package/dist/internal/security/index.cjs.map +1 -0
  832. package/dist/internal/security/index.d.cts +19 -0
  833. package/dist/internal/security/index.d.ts +19 -0
  834. package/dist/internal/security/index.js +7 -0
  835. package/dist/internal/security/index.js.map +1 -0
  836. package/dist/internal/security/path-containment.d.cts +24 -0
  837. package/dist/internal/security/path-containment.d.ts +24 -0
  838. package/dist/internal/security/path-guard.d.cts +166 -0
  839. package/dist/internal/security/path-guard.d.ts +166 -0
  840. package/dist/internal/security/redact.d.cts +74 -0
  841. package/dist/internal/security/redact.d.ts +74 -0
  842. package/dist/internal/security/test-reset.d.cts +10 -0
  843. package/dist/internal/security/test-reset.d.ts +10 -0
  844. package/dist/internal/session/agent-session-store.d.ts +65 -0
  845. package/dist/internal/session/agent-session.d.ts +48 -0
  846. package/dist/internal/session/compact-session.d.ts +97 -0
  847. package/dist/internal/session/index.d.ts +7 -0
  848. package/dist/internal/session/inject-session.d.ts +15 -0
  849. package/dist/internal/session/session-cache.d.ts +31 -0
  850. package/dist/internal/session/types.d.ts +46 -0
  851. package/dist/internal/structured-output-helpers.d.ts +54 -0
  852. package/dist/internal/task/registry.d.ts +60 -0
  853. package/dist/internal/task/ring-buffer.d.ts +10 -0
  854. package/dist/internal/task/store.d.ts +145 -0
  855. package/dist/internal/task/subscribe.d.ts +15 -0
  856. package/dist/internal/task/task-id.d.ts +22 -0
  857. package/dist/internal/task/task-run-event-bridge.d.ts +10 -0
  858. package/dist/internal/task/telemetry.d.ts +27 -0
  859. package/dist/internal/telemetry/adapter-registry.d.ts +12 -0
  860. package/dist/internal/telemetry/adapters/arize.d.ts +2 -0
  861. package/dist/internal/telemetry/adapters/braintrust.d.ts +7 -0
  862. package/dist/internal/telemetry/adapters/datadog.d.ts +2 -0
  863. package/dist/internal/telemetry/adapters/langfuse.d.ts +2 -0
  864. package/dist/internal/telemetry/adapters/langsmith.d.ts +7 -0
  865. package/dist/internal/telemetry/adapters/posthog.d.ts +2 -0
  866. package/dist/internal/telemetry/adapters/sentry.d.ts +2 -0
  867. package/dist/internal/telemetry/safe-require.d.ts +1 -0
  868. package/dist/internal/telemetry/span-names.d.ts +10 -0
  869. package/dist/internal/telemetry/tracer-loader.d.ts +20 -0
  870. package/dist/internal/telemetry/tracer.d.ts +57 -0
  871. package/dist/internal/tool-dispatch/repair-middleware.d.ts +34 -0
  872. package/dist/internal/tool-dispatch/strip-think.d.ts +22 -0
  873. package/dist/internal/tool-registry/personality-filter.d.ts +37 -0
  874. package/dist/internal/workflow/ctx.d.ts +24 -0
  875. package/dist/internal/workflow/error-shape.d.ts +7 -0
  876. package/dist/internal/workflow/event-stream.d.ts +13 -0
  877. package/dist/internal/workflow/evented-executor.d.ts +42 -0
  878. package/dist/internal/workflow/executor-helpers.d.ts +30 -0
  879. package/dist/internal/workflow/executor.d.ts +16 -0
  880. package/dist/internal/workflow/retry-policy.d.ts +14 -0
  881. package/dist/internal/workflow/run-id.d.ts +9 -0
  882. package/dist/internal/workflow/scheduler.d.ts +23 -0
  883. package/dist/internal/workflow/single-flight.d.ts +18 -0
  884. package/dist/internal/workflow/snapshot-store.d.ts +23 -0
  885. package/dist/internal/workflow/step-agent.d.ts +12 -0
  886. package/dist/internal/workflow/step-branch.d.ts +10 -0
  887. package/dist/internal/workflow/step-dowhile.d.ts +8 -0
  888. package/dist/internal/workflow/step-execution.d.ts +25 -0
  889. package/dist/internal/workflow/step-fn.d.ts +10 -0
  890. package/dist/internal/workflow/step-foreach.d.ts +11 -0
  891. package/dist/internal/workflow/step-parallel.d.ts +17 -0
  892. package/dist/internal/workflow/step-sleep.d.ts +7 -0
  893. package/dist/internal/workflow/telemetry.d.ts +21 -0
  894. package/dist/internal/zod-to-json-schema.d.ts +11 -0
  895. package/dist/job-queue.d.ts +68 -0
  896. package/dist/judge-call-46M2E5FA.cjs +22 -0
  897. package/dist/judge-call-46M2E5FA.cjs.map +1 -0
  898. package/dist/judge-call-FGUNNWEI.js +5 -0
  899. package/dist/judge-call-FGUNNWEI.js.map +1 -0
  900. package/dist/mcp-auth.cjs +314 -0
  901. package/dist/mcp-auth.cjs.map +1 -0
  902. package/dist/mcp-auth.d.cts +19 -0
  903. package/dist/mcp-auth.d.ts +19 -0
  904. package/dist/mcp-auth.js +307 -0
  905. package/dist/mcp-auth.js.map +1 -0
  906. package/dist/messages.cjs +24 -0
  907. package/dist/messages.cjs.map +1 -0
  908. package/dist/messages.d.cts +33 -0
  909. package/dist/messages.d.ts +33 -0
  910. package/dist/messages.js +20 -0
  911. package/dist/messages.js.map +1 -0
  912. package/dist/models.cjs +295 -0
  913. package/dist/models.cjs.map +1 -0
  914. package/dist/models.d.cts +18 -0
  915. package/dist/models.d.ts +18 -0
  916. package/dist/models.js +286 -0
  917. package/dist/models.js.map +1 -0
  918. package/dist/oauth-transaction-store-5RIR6D5C.js +5 -0
  919. package/dist/oauth-transaction-store-5RIR6D5C.js.map +1 -0
  920. package/dist/oauth-transaction-store-SXIE57OD.cjs +38 -0
  921. package/dist/oauth-transaction-store-SXIE57OD.cjs.map +1 -0
  922. package/dist/path-safety.cjs +39 -0
  923. package/dist/path-safety.cjs.map +1 -0
  924. package/dist/path-safety.d.cts +16 -0
  925. package/dist/path-safety.d.ts +16 -0
  926. package/dist/path-safety.js +6 -0
  927. package/dist/path-safety.js.map +1 -0
  928. package/dist/permission-engine.d.ts +134 -0
  929. package/dist/persistence.cjs +197 -0
  930. package/dist/persistence.cjs.map +1 -0
  931. package/dist/persistence.d.cts +40 -0
  932. package/dist/persistence.d.ts +40 -0
  933. package/dist/persistence.js +100 -0
  934. package/dist/persistence.js.map +1 -0
  935. package/dist/project.cjs +45 -0
  936. package/dist/project.cjs.map +1 -0
  937. package/dist/project.d.cts +14 -0
  938. package/dist/project.d.ts +14 -0
  939. package/dist/project.js +42 -0
  940. package/dist/project.js.map +1 -0
  941. package/dist/provider-catalog.json +1295 -0
  942. package/dist/providers.cjs +23 -0
  943. package/dist/providers.cjs.map +1 -0
  944. package/dist/providers.d.cts +31 -0
  945. package/dist/providers.d.ts +31 -0
  946. package/dist/providers.js +10 -0
  947. package/dist/providers.js.map +1 -0
  948. package/dist/registry-BZQFYRTL.cjs +46 -0
  949. package/dist/registry-BZQFYRTL.cjs.map +1 -0
  950. package/dist/registry-DMWCJKRF.js +9 -0
  951. package/dist/registry-DMWCJKRF.js.map +1 -0
  952. package/dist/retry.cjs +14 -0
  953. package/dist/retry.cjs.map +1 -0
  954. package/dist/retry.d.cts +35 -0
  955. package/dist/retry.d.ts +35 -0
  956. package/dist/retry.js +5 -0
  957. package/dist/retry.js.map +1 -0
  958. package/dist/run-CTAdRU3U.d.cts +1813 -0
  959. package/dist/run-CTAdRU3U.d.ts +1813 -0
  960. package/dist/run-to-completion-DRO77625.js +3 -0
  961. package/dist/run-to-completion-DRO77625.js.map +1 -0
  962. package/dist/run-to-completion-X4OWM673.cjs +48 -0
  963. package/dist/run-to-completion-X4OWM673.cjs.map +1 -0
  964. package/dist/run-until-6D6TQ4JN.js +146 -0
  965. package/dist/run-until-6D6TQ4JN.js.map +1 -0
  966. package/dist/run-until-DG2KXWB2.cjs +149 -0
  967. package/dist/run-until-DG2KXWB2.cjs.map +1 -0
  968. package/dist/sandbox/bwrap.d.cts +112 -0
  969. package/dist/sandbox/bwrap.d.ts +112 -0
  970. package/dist/sandbox/index.cjs +495 -0
  971. package/dist/sandbox/index.cjs.map +1 -0
  972. package/dist/sandbox/index.d.cts +13 -0
  973. package/dist/sandbox/index.d.ts +13 -0
  974. package/dist/sandbox/index.js +451 -0
  975. package/dist/sandbox/index.js.map +1 -0
  976. package/dist/sandbox/linux-sandbox.d.cts +218 -0
  977. package/dist/sandbox/linux-sandbox.d.ts +218 -0
  978. package/dist/sandbox/local-sandbox.d.cts +66 -0
  979. package/dist/sandbox/local-sandbox.d.ts +66 -0
  980. package/dist/sandbox/provision.d.cts +60 -0
  981. package/dist/sandbox/provision.d.ts +60 -0
  982. package/dist/sandbox/seccomp.d.cts +16 -0
  983. package/dist/sandbox/seccomp.d.ts +16 -0
  984. package/dist/sandbox/shell-escape.d.cts +8 -0
  985. package/dist/sandbox/shell-escape.d.ts +8 -0
  986. package/dist/sandbox/types.d.cts +143 -0
  987. package/dist/sandbox/types.d.ts +143 -0
  988. package/dist/sanitize/coerce.d.cts +1 -0
  989. package/dist/sanitize/coerce.d.ts +1 -0
  990. package/dist/sanitize/index.cjs +12 -0
  991. package/dist/sanitize/index.cjs.map +1 -0
  992. package/dist/sanitize/index.d.cts +9 -0
  993. package/dist/sanitize/index.d.ts +9 -0
  994. package/dist/sanitize/index.js +3 -0
  995. package/dist/sanitize/index.js.map +1 -0
  996. package/dist/sanitize/sanitize-tool-input.d.cts +11 -0
  997. package/dist/sanitize/sanitize-tool-input.d.ts +11 -0
  998. package/dist/sanitize/types.d.cts +52 -0
  999. package/dist/sanitize/types.d.ts +52 -0
  1000. package/dist/scorers.d.ts +181 -0
  1001. package/dist/sdk-agent-BOiKqOgL.d.cts +940 -0
  1002. package/dist/sdk-agent-D4a_BR_6.d.ts +940 -0
  1003. package/dist/server/auth/errors.d.cts +54 -0
  1004. package/dist/server/auth/errors.d.ts +54 -0
  1005. package/dist/server/auth/index.cjs +210 -0
  1006. package/dist/server/auth/index.cjs.map +1 -0
  1007. package/dist/server/auth/index.d.cts +244 -0
  1008. package/dist/server/auth/index.d.ts +244 -0
  1009. package/dist/server/auth/index.js +189 -0
  1010. package/dist/server/auth/index.js.map +1 -0
  1011. package/dist/server/auth/oauth-transaction-store.d.cts +52 -0
  1012. package/dist/server/auth/oauth-transaction-store.d.ts +52 -0
  1013. package/dist/server/auth/orchestrator.d.cts +15 -0
  1014. package/dist/server/auth/orchestrator.d.ts +15 -0
  1015. package/dist/server/auth/types.d.cts +109 -0
  1016. package/dist/server/auth/types.d.ts +109 -0
  1017. package/dist/server/auth/validate-return-to.d.cts +27 -0
  1018. package/dist/server/auth/validate-return-to.d.ts +27 -0
  1019. package/dist/server/errors-envelope.cjs +101 -0
  1020. package/dist/server/errors-envelope.cjs.map +1 -0
  1021. package/dist/server/errors-envelope.d.cts +67 -0
  1022. package/dist/server/errors-envelope.d.ts +67 -0
  1023. package/dist/server/errors-envelope.js +95 -0
  1024. package/dist/server/errors-envelope.js.map +1 -0
  1025. package/dist/session-transcript-LGHSNVY5.cjs +62 -0
  1026. package/dist/session-transcript-LGHSNVY5.cjs.map +1 -0
  1027. package/dist/session-transcript-VTBTCGQX.js +5 -0
  1028. package/dist/session-transcript-VTBTCGQX.js.map +1 -0
  1029. package/dist/skills.cjs +25 -0
  1030. package/dist/skills.cjs.map +1 -0
  1031. package/dist/skills.d.cts +19 -0
  1032. package/dist/skills.d.ts +19 -0
  1033. package/dist/skills.js +8 -0
  1034. package/dist/skills.js.map +1 -0
  1035. package/dist/stream-object-HBFMIZLD.js +7 -0
  1036. package/dist/stream-object-HBFMIZLD.js.map +1 -0
  1037. package/dist/stream-object-QSKHISDJ.cjs +20 -0
  1038. package/dist/stream-object-QSKHISDJ.cjs.map +1 -0
  1039. package/dist/stream-object.d.ts +73 -0
  1040. package/dist/stream-to-completion-QV5HCL3J.js +30 -0
  1041. package/dist/stream-to-completion-QV5HCL3J.js.map +1 -0
  1042. package/dist/stream-to-completion-SRISU5AB.cjs +32 -0
  1043. package/dist/stream-to-completion-SRISU5AB.cjs.map +1 -0
  1044. package/dist/subagents-loader-DOBTTICM.js +7 -0
  1045. package/dist/subagents-loader-DOBTTICM.js.map +1 -0
  1046. package/dist/subagents-loader-GEHYCMEX.cjs +16 -0
  1047. package/dist/subagents-loader-GEHYCMEX.cjs.map +1 -0
  1048. package/dist/subagents-loader.cjs +35 -0
  1049. package/dist/subagents-loader.cjs.map +1 -0
  1050. package/dist/subagents-loader.d.cts +90 -0
  1051. package/dist/subagents-loader.d.ts +90 -0
  1052. package/dist/subagents-loader.js +32 -0
  1053. package/dist/subagents-loader.js.map +1 -0
  1054. package/dist/subagents.cjs +18 -0
  1055. package/dist/subagents.cjs.map +1 -0
  1056. package/dist/subagents.d.cts +14 -0
  1057. package/dist/subagents.d.ts +14 -0
  1058. package/dist/subagents.js +15 -0
  1059. package/dist/subagents.js.map +1 -0
  1060. package/dist/subscription/define-subscription.d.cts +71 -0
  1061. package/dist/subscription/define-subscription.d.ts +71 -0
  1062. package/dist/subscription/index.cjs +408 -0
  1063. package/dist/subscription/index.cjs.map +1 -0
  1064. package/dist/subscription/index.d.cts +20 -0
  1065. package/dist/subscription/index.d.ts +20 -0
  1066. package/dist/subscription/index.js +400 -0
  1067. package/dist/subscription/index.js.map +1 -0
  1068. package/dist/subscription/internal/backpressure.d.cts +24 -0
  1069. package/dist/subscription/internal/backpressure.d.ts +24 -0
  1070. package/dist/subscription/internal/server-integration.d.cts +22 -0
  1071. package/dist/subscription/internal/server-integration.d.ts +22 -0
  1072. package/dist/subscription/internal/sse-encoder.d.cts +13 -0
  1073. package/dist/subscription/internal/sse-encoder.d.ts +13 -0
  1074. package/dist/subscription/internal/sse-parser.d.cts +15 -0
  1075. package/dist/subscription/internal/sse-parser.d.ts +15 -0
  1076. package/dist/subscription/internal/subscription-runtime.d.cts +21 -0
  1077. package/dist/subscription/internal/subscription-runtime.d.ts +21 -0
  1078. package/dist/subscription/internal/types.d.cts +11 -0
  1079. package/dist/subscription/internal/types.d.ts +11 -0
  1080. package/dist/subscription/internal/ws-adapter-node.d.cts +10 -0
  1081. package/dist/subscription/internal/ws-adapter-node.d.ts +10 -0
  1082. package/dist/subscription/theokit-subscribe.d.cts +54 -0
  1083. package/dist/subscription/theokit-subscribe.d.ts +54 -0
  1084. package/dist/subscription/types.d.cts +158 -0
  1085. package/dist/subscription/types.d.ts +158 -0
  1086. package/dist/task-errors.d.ts +58 -0
  1087. package/dist/task-store.cjs +23 -0
  1088. package/dist/task-store.cjs.map +1 -0
  1089. package/dist/task-store.d.cts +10 -0
  1090. package/dist/task-store.d.ts +10 -0
  1091. package/dist/task-store.js +6 -0
  1092. package/dist/task-store.js.map +1 -0
  1093. package/dist/tool-error.d.ts +30 -0
  1094. package/dist/types/agent-prims.d.ts +137 -0
  1095. package/dist/types/agent.d.ts +947 -0
  1096. package/dist/types/batch.d.ts +121 -0
  1097. package/dist/types/budget-tracker.d.ts +80 -0
  1098. package/dist/types/budget.d.ts +97 -0
  1099. package/dist/types/content-blocks.d.ts +50 -0
  1100. package/dist/types/context.d.ts +96 -0
  1101. package/dist/types/conversation.d.ts +127 -0
  1102. package/dist/types/cron.d.ts +172 -0
  1103. package/dist/types/env-policy.d.ts +21 -0
  1104. package/dist/types/eval.d.ts +255 -0
  1105. package/dist/types/fork.d.ts +52 -0
  1106. package/dist/types/goal-events.d.ts +144 -0
  1107. package/dist/types/index.d.ts +19 -0
  1108. package/dist/types/mcp.d.ts +90 -0
  1109. package/dist/types/memory-adapter.d.ts +189 -0
  1110. package/dist/types/memory-provider.d.ts +206 -0
  1111. package/dist/types/messages-base.d.ts +24 -0
  1112. package/dist/types/messages.d.ts +161 -0
  1113. package/dist/types/plugin.d.ts +308 -0
  1114. package/dist/types/processors.d.ts +87 -0
  1115. package/dist/types/provider-profile.d.ts +116 -0
  1116. package/dist/types/providers.d.ts +116 -0
  1117. package/dist/types/run-events.d.ts +197 -0
  1118. package/dist/types/run.d.ts +671 -0
  1119. package/dist/types/sdk-agent.d.ts +342 -0
  1120. package/dist/types/session-message.d.ts +62 -0
  1121. package/dist/types/session-record.d.ts +103 -0
  1122. package/dist/types/session-store.d.ts +104 -0
  1123. package/dist/types/task.d.ts +146 -0
  1124. package/dist/types/theokit.d.ts +73 -0
  1125. package/dist/types/trajectory.d.ts +52 -0
  1126. package/dist/types/updates.d.ts +184 -0
  1127. package/dist/types/usage.d.ts +64 -0
  1128. package/dist/types/workflow.d.ts +426 -0
  1129. package/dist/workflow-as-tool.d.ts +66 -0
  1130. package/dist/workflow-errors.d.ts +164 -0
  1131. package/dist/workflow.cjs +100 -0
  1132. package/dist/workflow.cjs.map +1 -0
  1133. package/dist/workflow.d.cts +911 -0
  1134. package/dist/workflow.d.ts +911 -0
  1135. package/dist/workflow.js +11 -0
  1136. package/dist/workflow.js.map +1 -0
  1137. package/docs/adr/README.md +2604 -0
  1138. package/docs/error-codes.md +253 -0
  1139. package/docs/harness-capability-map.md +1435 -0
  1140. package/docs/memory-decisions.md +265 -0
  1141. package/package.json +455 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,2487 @@
1
+ 'use strict';
2
+
3
+ var chunkTFG5IBZS_cjs = require('./chunk-TFG5IBZS.cjs');
4
+ var chunkOBA6YK2R_cjs = require('./chunk-OBA6YK2R.cjs');
5
+ var chunkQDM3OHUT_cjs = require('./chunk-QDM3OHUT.cjs');
6
+ var chunkVPK6PHIE_cjs = require('./chunk-VPK6PHIE.cjs');
7
+ var chunkQWD4RDZ3_cjs = require('./chunk-QWD4RDZ3.cjs');
8
+ require('./chunk-7JJ3A6AT.cjs');
9
+ var chunk4HS6FFGL_cjs = require('./chunk-4HS6FFGL.cjs');
10
+ require('./chunk-4A3SKJ53.cjs');
11
+ require('./chunk-VTYY7XL5.cjs');
12
+ var chunk67SBTGMA_cjs = require('./chunk-67SBTGMA.cjs');
13
+ var chunkD3CCY3A2_cjs = require('./chunk-D3CCY3A2.cjs');
14
+ var chunkKVSAY6NZ_cjs = require('./chunk-KVSAY6NZ.cjs');
15
+ require('./chunk-Y2KYR2ED.cjs');
16
+ require('./chunk-BUUUWQMB.cjs');
17
+ require('./chunk-Z2JFX372.cjs');
18
+ require('./chunk-KGANQYP7.cjs');
19
+ require('./chunk-BV2MWEMV.cjs');
20
+ require('./chunk-D6POWE7E.cjs');
21
+ require('./chunk-GHX4P3V2.cjs');
22
+ require('./chunk-TMKTSYDS.cjs');
23
+ var chunkNQTNSHSB_cjs = require('./chunk-NQTNSHSB.cjs');
24
+ var chunk7FDKWDA2_cjs = require('./chunk-7FDKWDA2.cjs');
25
+ var chunk2HPNT6HH_cjs = require('./chunk-2HPNT6HH.cjs');
26
+ require('./chunk-FUSDYC2B.cjs');
27
+ require('./chunk-YJNYDJ2T.cjs');
28
+ require('./chunk-24SYBZPL.cjs');
29
+ require('./chunk-QOGNZMHD.cjs');
30
+ var chunkYIFFF23U_cjs = require('./chunk-YIFFF23U.cjs');
31
+ require('./chunk-2ZPEDVLM.cjs');
32
+ require('./chunk-IU5N5224.cjs');
33
+ require('./chunk-KRD3GQAA.cjs');
34
+ require('./chunk-RQMCOFAI.cjs');
35
+ require('./chunk-MUUQ2WFJ.cjs');
36
+ var chunkAA27GEYS_cjs = require('./chunk-AA27GEYS.cjs');
37
+ require('./chunk-YSTXFWQE.cjs');
38
+ require('./chunk-FRITRLZQ.cjs');
39
+ require('./chunk-NQTD6QOW.cjs');
40
+ require('./chunk-NINIJCHU.cjs');
41
+ require('./chunk-QATRS7JD.cjs');
42
+ require('./chunk-LOHMT36V.cjs');
43
+ require('./chunk-IJ7M6GOG.cjs');
44
+ require('./chunk-7A6535RA.cjs');
45
+ require('./chunk-SA6K24NB.cjs');
46
+ require('./chunk-I2PWY7VM.cjs');
47
+ require('./chunk-KTTHHYEW.cjs');
48
+ require('./chunk-Z3NTRKIC.cjs');
49
+ require('./chunk-GZV6AVRL.cjs');
50
+ require('./chunk-A4RAL2ER.cjs');
51
+ require('./chunk-DQZU7JK6.cjs');
52
+ require('./chunk-BJUJT5ED.cjs');
53
+ var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
54
+ var chunkHCT4HPCL_cjs = require('./chunk-HCT4HPCL.cjs');
55
+ var chunkJLRLCBJ4_cjs = require('./chunk-JLRLCBJ4.cjs');
56
+ require('./chunk-QYLZQ43D.cjs');
57
+ require('./chunk-NYQ3IS7K.cjs');
58
+ require('./chunk-HW7SEELD.cjs');
59
+ var chunkATT276RD_cjs = require('./chunk-ATT276RD.cjs');
60
+ var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
61
+ require('./chunk-ANMJJD6D.cjs');
62
+ var chunkQC55H6RJ_cjs = require('./chunk-QC55H6RJ.cjs');
63
+ require('./chunk-NVXXWAU7.cjs');
64
+ require('./chunk-4NLCWGH7.cjs');
65
+ require('./chunk-EXTRW7GW.cjs');
66
+ require('./chunk-HUFSABUZ.cjs');
67
+ var chunkJ7J7J2GN_cjs = require('./chunk-J7J7J2GN.cjs');
68
+ var chunk6LHQPOMI_cjs = require('./chunk-6LHQPOMI.cjs');
69
+ var crypto = require('crypto');
70
+ var zod = require('zod');
71
+ var promises = require('fs/promises');
72
+ var path = require('path');
73
+
74
+ // src/agent-factory.ts
75
+ function createAgentFactory(common) {
76
+ return {
77
+ forSession: (agentId, overrides) => chunkD3CCY3A2_cjs.Agent.create(mergeAgentOptions(common, overrides, agentId)),
78
+ getOrCreate: (agentId, overrides) => chunkD3CCY3A2_cjs.Agent.getOrCreate(agentId, mergeAgentOptions(common, overrides, agentId))
79
+ };
80
+ }
81
+ function mergeAgentOptions(common, overrides, agentId) {
82
+ const o = overrides ?? {};
83
+ const merged = { ...common, ...o };
84
+ const local = deepMergeLocal(common.local, o.local);
85
+ if (local !== void 0) merged.local = local;
86
+ const memory = deepMergeMemory(common.memory, o.memory);
87
+ if (memory !== void 0) merged.memory = memory;
88
+ const cloud = deepMergeCloud(common.cloud, o.cloud);
89
+ if (cloud !== void 0) merged.cloud = cloud;
90
+ merged.agentId = agentId;
91
+ return merged;
92
+ }
93
+ function deepMergeLocal(base, top) {
94
+ if (base === void 0 && top === void 0) return void 0;
95
+ return { ...base ?? {}, ...top ?? {} };
96
+ }
97
+ function deepMergeMemory(base, top) {
98
+ if (base === void 0 && top === void 0) return void 0;
99
+ return {
100
+ ...base ?? {},
101
+ ...top ?? {},
102
+ enabled: top?.enabled ?? base?.enabled ?? false
103
+ };
104
+ }
105
+ function deepMergeCloud(base, top) {
106
+ if (base === void 0 && top === void 0) return void 0;
107
+ return { ...base ?? {}, ...top ?? {} };
108
+ }
109
+ var AgentFactory = class {
110
+ constructor() {
111
+ }
112
+ static create(common) {
113
+ return createAgentFactory(common);
114
+ }
115
+ };
116
+
117
+ // src/approval-policy.ts
118
+ var BY_MODE = {
119
+ ask: { outcome: "ask", reason: "mode-ask" },
120
+ "never-ask": { outcome: "allow", reason: "mode-never-ask" },
121
+ "refuse-all": { outcome: "deny", reason: "mode-refuse-all" }
122
+ };
123
+ function decideApproval(input) {
124
+ const { tool } = input;
125
+ if ((input.denied ?? []).includes(tool)) {
126
+ return { outcome: "deny", reason: "explicitly-denied", tool };
127
+ }
128
+ if ((input.allowed ?? []).includes(tool)) {
129
+ return { outcome: "allow", reason: "explicitly-allowed", tool };
130
+ }
131
+ const fromMode = BY_MODE[input.mode];
132
+ return { outcome: fromMode.outcome, reason: fromMode.reason, tool };
133
+ }
134
+
135
+ // src/blast-radius.ts
136
+ function evaluateBlastRadius(input) {
137
+ const { scope, reversible } = input.action;
138
+ if (scope.length === 0) {
139
+ return { outcome: "refuse", reason: "scope-undeclared", scope };
140
+ }
141
+ if (!input.granted.includes(scope)) {
142
+ return { outcome: "refuse", reason: "scope-not-granted", scope };
143
+ }
144
+ if (!reversible && !(input.irreversibleAllowed ?? []).includes(scope)) {
145
+ return { outcome: "require-approval", reason: "irreversible", scope };
146
+ }
147
+ return { outcome: "allow", reason: "within-granted-scope", scope };
148
+ }
149
+
150
+ // src/internal/budget/calendar-window.ts
151
+ function startOfDayUtc(now = /* @__PURE__ */ new Date()) {
152
+ return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()));
153
+ }
154
+ function startOfWeekUtc(now = /* @__PURE__ */ new Date()) {
155
+ const dayOfWeek = now.getUTCDay();
156
+ const daysSinceMonday = (dayOfWeek + 6) % 7;
157
+ const start = startOfDayUtc(now);
158
+ start.setUTCDate(start.getUTCDate() - daysSinceMonday);
159
+ return start;
160
+ }
161
+ var MS_PER_HOUR = 60 * 60 * 1e3;
162
+ var MS_PER_DAY = 24 * MS_PER_HOUR;
163
+ function windowStartMs(window, now = /* @__PURE__ */ new Date()) {
164
+ switch (window) {
165
+ case "1h":
166
+ return now.getTime() - MS_PER_HOUR;
167
+ case "1d":
168
+ return startOfDayUtc(now).getTime();
169
+ case "1w":
170
+ return startOfWeekUtc(now).getTime();
171
+ case "30d":
172
+ return now.getTime() - 30 * MS_PER_DAY;
173
+ case "365d":
174
+ return now.getTime() - 365 * MS_PER_DAY;
175
+ default: {
176
+ const _exhaustive = window;
177
+ throw new Error(`unreachable window: ${_exhaustive}`);
178
+ }
179
+ }
180
+ }
181
+
182
+ // src/internal/budget/ledger.ts
183
+ var MS_PER_YEAR = 365 * 24 * 60 * 60 * 1e3;
184
+ var GC_INTERVAL_MS = 5 * 60 * 1e3;
185
+ var GC_LOGS_THRESHOLD = 1e4;
186
+ var state = {
187
+ logs: /* @__PURE__ */ new Map(),
188
+ lastGcAt: Date.now()
189
+ };
190
+ var MUTEX_KEY = "budget-ledger";
191
+ function shouldGc(now) {
192
+ if (now - state.lastGcAt < GC_INTERVAL_MS) return false;
193
+ let totalLogs = 0;
194
+ for (const arr of state.logs.values()) totalLogs += arr.length;
195
+ return totalLogs > GC_LOGS_THRESHOLD;
196
+ }
197
+ function gcOlderThanOneYear(now) {
198
+ const cutoff = now - MS_PER_YEAR;
199
+ for (const [name, arr] of state.logs.entries()) {
200
+ const kept = arr.filter((l) => l.timestamp >= cutoff);
201
+ if (kept.length === 0) state.logs.delete(name);
202
+ else state.logs.set(name, kept);
203
+ }
204
+ state.lastGcAt = now;
205
+ }
206
+ async function charge(name, amountUsd) {
207
+ if (amountUsd <= 0) return;
208
+ await chunkZF2LDKQQ_cjs.withCwdMutex(MUTEX_KEY, async () => {
209
+ const now = Date.now();
210
+ const list2 = state.logs.get(name) ?? [];
211
+ list2.push({ timestamp: now, amountUsd });
212
+ state.logs.set(name, list2);
213
+ if (shouldGc(now)) gcOlderThanOneYear(now);
214
+ });
215
+ }
216
+ function spentIn(name, window, now = /* @__PURE__ */ new Date()) {
217
+ const arr = state.logs.get(name);
218
+ if (arr === void 0) return 0;
219
+ const sinceMs = windowStartMs(window, now);
220
+ let total = 0;
221
+ for (const log of arr) {
222
+ if (log.timestamp >= sinceMs) total += log.amountUsd;
223
+ }
224
+ return total;
225
+ }
226
+
227
+ // src/internal/budget/registry.ts
228
+ var NAME_GRAMMAR = /^[a-z0-9][a-z0-9_-]*$/;
229
+ var registry = /* @__PURE__ */ new Map();
230
+ function validateBudgetName(name) {
231
+ if (typeof name !== "string" || name.length === 0) {
232
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError("Budget name must be a non-empty string", {
233
+ code: "invalid_budget_name"
234
+ });
235
+ }
236
+ if (!NAME_GRAMMAR.test(name)) {
237
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(
238
+ `Budget name "${name}" must match ^[a-z0-9][a-z0-9_-]*$ (lowercase + dash/underscore, start alphanumeric)`,
239
+ { code: "invalid_budget_name" }
240
+ );
241
+ }
242
+ }
243
+ function assertImplementedScope(scope) {
244
+ if (scope === "process") return;
245
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(
246
+ `Budget scope "${scope}" is declared but not implemented \u2014 only "process" is honoured. A budget created with it would have been accounted process-wide with no warning.`,
247
+ { code: "unimplemented_budget_scope" }
248
+ );
249
+ }
250
+ function createBudget(opts) {
251
+ validateBudgetName(opts.name);
252
+ assertImplementedScope(opts.scope);
253
+ if (registry.has(opts.name)) {
254
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(`Budget "${opts.name}" already exists`, {
255
+ code: "invalid_budget_name"
256
+ });
257
+ }
258
+ registry.set(opts.name, opts);
259
+ return buildHandle(opts);
260
+ }
261
+ function getBudget(name) {
262
+ const opts = registry.get(name);
263
+ if (opts === void 0) return void 0;
264
+ return buildHandle(opts);
265
+ }
266
+ function listBudgets() {
267
+ return [...registry.values()].map(buildHandle);
268
+ }
269
+ function deleteBudget(name) {
270
+ return registry.delete(name);
271
+ }
272
+ function snapshotAll() {
273
+ const result = [];
274
+ for (const opts of registry.values()) {
275
+ for (const lim of opts.limits) {
276
+ const spent = spentIn(opts.name, lim.window);
277
+ result.push({
278
+ name: opts.name,
279
+ window: lim.window,
280
+ spentUsd: spent,
281
+ limitUsd: lim.limitUsd,
282
+ ratio: lim.limitUsd > 0 ? spent / lim.limitUsd : 0
283
+ });
284
+ }
285
+ }
286
+ return result;
287
+ }
288
+ function getBudgetOptionsRaw(name) {
289
+ return registry.get(name);
290
+ }
291
+ function defaultMode(opts) {
292
+ return opts.mode ?? "warn";
293
+ }
294
+ function buildHandle(opts) {
295
+ return {
296
+ name: opts.name,
297
+ mode: defaultMode(opts),
298
+ scope: opts.scope,
299
+ limits: opts.limits,
300
+ spentIn: (window) => spentIn(opts.name, window),
301
+ remainingIn: (window) => {
302
+ const lim = opts.limits.find((l) => l.window === window);
303
+ if (lim === void 0) return Number.POSITIVE_INFINITY;
304
+ return Math.max(0, lim.limitUsd - spentIn(opts.name, window));
305
+ }
306
+ };
307
+ }
308
+
309
+ // src/internal/budget/enforcement.ts
310
+ var THRESHOLDS = [0.8, 0.95];
311
+ function preflightCheck(name, estimatedUsd) {
312
+ const opts = getBudgetOptionsRaw(name);
313
+ if (opts === void 0) return;
314
+ if (defaultMode(opts) !== "block") return;
315
+ for (const lim of opts.limits) {
316
+ const currentSpent = spentIn(opts.name, lim.window);
317
+ if (currentSpent + estimatedUsd > lim.limitUsd) {
318
+ throw new chunkJ7J7J2GN_cjs.BudgetExceededError({
319
+ budgetName: opts.name,
320
+ window: lim.window,
321
+ spentUsd: currentSpent + estimatedUsd,
322
+ limitUsd: lim.limitUsd,
323
+ mode: "block"
324
+ });
325
+ }
326
+ }
327
+ }
328
+ async function chargeAndCheckThresholds(name, actualUsd) {
329
+ const opts = getBudgetOptionsRaw(name);
330
+ if (opts === void 0) {
331
+ chunk6LHQPOMI_cjs.diag(
332
+ `[budget] charge for deleted budget "${name}" is a no-op (was the budget removed during in-flight send?)
333
+ `
334
+ );
335
+ return;
336
+ }
337
+ const mode = defaultMode(opts);
338
+ await charge(opts.name, actualUsd);
339
+ if (mode === "audit") return;
340
+ await dispatchCallbacksFor(opts, mode);
341
+ }
342
+ async function dispatchCallbacksFor(opts, mode) {
343
+ for (const lim of opts.limits) {
344
+ const spent = spentIn(opts.name, lim.window);
345
+ if (lim.limitUsd <= 0) {
346
+ if (spent > 0) await dispatchExceed(opts, lim.window, spent, lim.limitUsd, mode);
347
+ continue;
348
+ }
349
+ const ratio = spent / lim.limitUsd;
350
+ if (ratio >= 1) {
351
+ await dispatchExceed(opts, lim.window, spent, lim.limitUsd, mode);
352
+ } else {
353
+ for (const t of [...THRESHOLDS].reverse()) {
354
+ if (ratio >= t) {
355
+ await dispatchThreshold(opts, lim.window, spent, lim.limitUsd, t);
356
+ break;
357
+ }
358
+ }
359
+ }
360
+ }
361
+ }
362
+ async function dispatchThreshold(opts, window, spentUsd, limitUsd, threshold) {
363
+ if (opts.onThreshold === void 0) return;
364
+ try {
365
+ await opts.onThreshold({
366
+ budgetName: opts.name,
367
+ window,
368
+ threshold,
369
+ spentUsd,
370
+ limitUsd
371
+ });
372
+ } catch (err) {
373
+ const msg = err instanceof Error ? err.message : String(err);
374
+ chunk6LHQPOMI_cjs.diag(`[budget] onThreshold callback threw: ${msg}
375
+ `);
376
+ }
377
+ }
378
+ async function dispatchExceed(opts, window, spentUsd, limitUsd, mode) {
379
+ if (opts.onExceed === void 0) {
380
+ if (mode === "warn") {
381
+ chunk6LHQPOMI_cjs.diag(
382
+ `[budget] "${opts.name}" exceeded ${window} limit: $${spentUsd.toFixed(4)} > $${limitUsd.toFixed(4)}
383
+ `
384
+ );
385
+ }
386
+ return;
387
+ }
388
+ try {
389
+ await opts.onExceed({
390
+ budgetName: opts.name,
391
+ window,
392
+ spentUsd,
393
+ limitUsd,
394
+ mode
395
+ });
396
+ } catch (err) {
397
+ const msg = err instanceof Error ? err.message : String(err);
398
+ chunk6LHQPOMI_cjs.diag(`[budget] onExceed callback threw: ${msg}
399
+ `);
400
+ }
401
+ }
402
+
403
+ // src/internal/budget/normalize-usage.ts
404
+ function int(v) {
405
+ if (typeof v === "number") return Number.isFinite(v) ? Math.max(0, Math.trunc(v)) : 0;
406
+ if (typeof v === "string") {
407
+ const n = Number.parseInt(v, 10);
408
+ return Number.isFinite(n) ? Math.max(0, n) : 0;
409
+ }
410
+ return 0;
411
+ }
412
+ function buildTotal(buckets) {
413
+ return buckets.inputTokens + buckets.outputTokens + buckets.cacheReadTokens + buckets.cacheWriteTokens;
414
+ }
415
+ function omitUndefined(usage) {
416
+ return {
417
+ inputTokens: usage.inputTokens,
418
+ outputTokens: usage.outputTokens,
419
+ ...usage.cacheReadTokens > 0 ? { cacheReadTokens: usage.cacheReadTokens } : {},
420
+ ...usage.cacheWriteTokens > 0 ? { cacheWriteTokens: usage.cacheWriteTokens } : {},
421
+ ...usage.reasoningTokens > 0 ? { reasoningTokens: usage.reasoningTokens } : {},
422
+ totalTokens: usage.totalTokens
423
+ };
424
+ }
425
+ function inferApiMode(provider) {
426
+ const p = provider.toLowerCase();
427
+ if (p === "anthropic" || p === "claude" || p === "bedrock_anthropic") {
428
+ return "anthropic_messages";
429
+ }
430
+ if (p === "openai-codex" || p === "codex") return "openai_responses";
431
+ return "openai_chat_completions";
432
+ }
433
+ function normalizeUsage(rawUsage, opts) {
434
+ if (rawUsage === null || rawUsage === void 0) {
435
+ return { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
436
+ }
437
+ if (typeof rawUsage !== "object") {
438
+ return { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
439
+ }
440
+ const raw = rawUsage;
441
+ const mode = opts.apiMode ?? inferApiMode(opts.provider);
442
+ if (mode === "anthropic_messages") return normalizeAnthropic(raw);
443
+ if (mode === "openai_responses") return normalizeOpenAIResponses(raw);
444
+ return normalizeOpenAIChat(raw);
445
+ }
446
+ function normalizeAnthropic(raw) {
447
+ const inputTokens = int(raw.input_tokens);
448
+ const outputTokens = int(raw.output_tokens);
449
+ const cacheReadTokens = int(raw.cache_read_input_tokens);
450
+ const cacheWriteTokens = int(raw.cache_creation_input_tokens);
451
+ const usage = {
452
+ inputTokens,
453
+ outputTokens,
454
+ cacheReadTokens,
455
+ cacheWriteTokens,
456
+ reasoningTokens: 0,
457
+ totalTokens: buildTotal({ inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens })
458
+ };
459
+ return omitUndefined(usage);
460
+ }
461
+ function normalizeOpenAIResponses(raw) {
462
+ const inputTotal = int(raw.input_tokens);
463
+ const outputTokens = int(raw.output_tokens);
464
+ const inputDetails = raw.input_tokens_details ?? {};
465
+ const outputDetails = raw.output_tokens_details ?? {};
466
+ const cacheReadTokens = int(inputDetails.cached_tokens);
467
+ const cacheWriteTokens = int(inputDetails.cache_creation_tokens);
468
+ const reasoningTokens = int(outputDetails.reasoning_tokens);
469
+ const inputTokens = Math.max(0, inputTotal - cacheReadTokens - cacheWriteTokens);
470
+ const usage = {
471
+ inputTokens,
472
+ outputTokens,
473
+ cacheReadTokens,
474
+ cacheWriteTokens,
475
+ reasoningTokens,
476
+ totalTokens: buildTotal({ inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens })
477
+ };
478
+ return omitUndefined(usage);
479
+ }
480
+ function normalizeOpenAIChat(raw) {
481
+ const promptTotal = int(raw.prompt_tokens);
482
+ const outputTokens = int(raw.completion_tokens);
483
+ const promptDetails = raw.prompt_tokens_details ?? {};
484
+ const completionDetails = raw.completion_tokens_details ?? {};
485
+ const cacheReadTokens = int(promptDetails.cached_tokens) || int(raw.cache_read_input_tokens);
486
+ const cacheWriteTokens = int(promptDetails.cache_write_tokens) || int(raw.cache_creation_input_tokens);
487
+ const reasoningTokens = int(completionDetails.reasoning_tokens);
488
+ const inputTokens = Math.max(0, promptTotal - cacheReadTokens - cacheWriteTokens);
489
+ const usage = {
490
+ inputTokens,
491
+ outputTokens,
492
+ cacheReadTokens,
493
+ cacheWriteTokens,
494
+ reasoningTokens,
495
+ totalTokens: buildTotal({ inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens })
496
+ };
497
+ return omitUndefined(usage);
498
+ }
499
+
500
+ // src/budget.ts
501
+ var Budget = class {
502
+ // D375 — static class with private constructor.
503
+ constructor() {
504
+ throw new Error("Budget is static; do not instantiate");
505
+ }
506
+ /**
507
+ * Create a budget. `name` must match `^[a-z0-9][a-z0-9_-]*$` (EC-7).
508
+ * Throws `ConfigurationError` if name is invalid OR already exists
509
+ * (EC-16: duplicate surface caller bug).
510
+ *
511
+ * `limits` is stacked (D384) — ANY exceeded triggers enforcement.
512
+ * Empty `limits[]` is valid: pure tracking, no thresholds/exceed
513
+ * callbacks fire (EC-19).
514
+ *
515
+ * Default `mode` is `"warn"` (D383). For emergency stop, use
516
+ * `mode: "block", limits: [{ window: "1d", limitUsd: 0 }]` (EC-18).
517
+ */
518
+ static create(options) {
519
+ return createBudget(options);
520
+ }
521
+ /** Returns the handle for an active budget, or `undefined`. */
522
+ static get(name) {
523
+ return getBudget(name);
524
+ }
525
+ /** Returns all active budgets. */
526
+ static list() {
527
+ return listBudgets();
528
+ }
529
+ /**
530
+ * Deletes a budget from the registry. Returns `true` if it existed.
531
+ * In-flight `agent.send` calls referencing the name treat the
532
+ * subsequent charge as a silent no-op + stderr warn (EC-20).
533
+ */
534
+ static delete(name) {
535
+ return deleteBudget(name);
536
+ }
537
+ /**
538
+ * Returns per-window spend snapshot for all active budgets. Each
539
+ * entry has `{ name, window, spentUsd, limitUsd, ratio }`.
540
+ */
541
+ static snapshot() {
542
+ return snapshotAll();
543
+ }
544
+ };
545
+
546
+ // src/built-in-processors.ts
547
+ var CONTROL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g;
548
+ function createUnicodeNormalizer(opts = {}) {
549
+ const stripControlChars = opts.stripControlChars ?? false;
550
+ const collapseWhitespace = opts.collapseWhitespace ?? false;
551
+ return {
552
+ id: "unicode-normalizer",
553
+ processInput(ctx) {
554
+ let s = ctx.message.normalize("NFC");
555
+ if (stripControlChars) s = s.replace(CONTROL_CHARS, "");
556
+ if (collapseWhitespace) {
557
+ s = s.replace(/[^\S\n]+/g, " ").replace(/ *\n */g, "\n").replace(/\n{3,}/g, "\n\n").trim();
558
+ }
559
+ return s;
560
+ }
561
+ };
562
+ }
563
+ function createTokenLimiter(opts) {
564
+ if (!Number.isInteger(opts.limit) || opts.limit <= 0) {
565
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError("createTokenLimiter: `limit` must be a positive integer.", {
566
+ code: "invalid_processor_options"
567
+ });
568
+ }
569
+ const limit = opts.limit;
570
+ const strategy = opts.strategy ?? "truncate";
571
+ const cap = (text, controls) => {
572
+ const estimated = chunkATT276RD_cjs.estimateTokens(text);
573
+ if (estimated <= limit) return text;
574
+ if (strategy === "block") {
575
+ controls.abort(`exceeds token limit ${limit} (~${estimated} estimated)`);
576
+ }
577
+ return [...text].slice(0, limit * chunkATT276RD_cjs.CHARS_PER_TOKEN).join("");
578
+ };
579
+ return {
580
+ id: "token-limiter",
581
+ processInput: (ctx) => cap(ctx.message, ctx),
582
+ processOutput: (ctx) => cap(ctx.text, ctx)
583
+ };
584
+ }
585
+ var TokenLimiter = class {
586
+ constructor() {
587
+ }
588
+ static create(opts) {
589
+ return createTokenLimiter(opts);
590
+ }
591
+ };
592
+ var UnicodeNormalizer = class {
593
+ constructor() {
594
+ }
595
+ static create(opts = {}) {
596
+ return createUnicodeNormalizer(opts);
597
+ }
598
+ };
599
+
600
+ // src/create-skill.ts
601
+ function createSkill(spec) {
602
+ if (!spec.name) {
603
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError("createSkill: `name` is required.", {
604
+ code: "invalid_skill_spec"
605
+ });
606
+ }
607
+ if (!spec.description) {
608
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError("createSkill: `description` is required.", {
609
+ code: "invalid_skill_spec"
610
+ });
611
+ }
612
+ return {
613
+ name: spec.name,
614
+ description: spec.description,
615
+ source: `inline://${spec.name}`,
616
+ instructions: spec.instructions,
617
+ ...spec.category !== void 0 ? { category: spec.category } : {},
618
+ ...spec.dependencies !== void 0 ? { dependencies: spec.dependencies } : {},
619
+ ...spec.references !== void 0 ? { references: spec.references } : {}
620
+ };
621
+ }
622
+ var Skill = class {
623
+ constructor() {
624
+ }
625
+ static create(spec) {
626
+ return createSkill(spec);
627
+ }
628
+ };
629
+ function describeCredential(input) {
630
+ const secret = (input.value ?? "").trim();
631
+ if (secret.length === 0) {
632
+ return { provider: input.provider, present: false, source: input.source };
633
+ }
634
+ return {
635
+ provider: input.provider,
636
+ present: true,
637
+ source: input.source,
638
+ fingerprint: crypto.createHash("sha256").update(secret).digest("hex").slice(0, 8)
639
+ };
640
+ }
641
+
642
+ // src/define-provider.ts
643
+ function defineProvider(profile, opts) {
644
+ return {
645
+ name: profile.name,
646
+ version: opts?.version ?? "1.0.0",
647
+ kind: "model-provider",
648
+ profile
649
+ };
650
+ }
651
+ var Provider = class _Provider {
652
+ constructor() {
653
+ }
654
+ static create(profile, opts) {
655
+ return defineProvider(profile, opts);
656
+ }
657
+ /**
658
+ * Every first-party builtin provider (anthropic, openai, openrouter, gemini, ollama, the ChatGPT/Codex
659
+ * `openai-chatgpt`, …) as model-provider plugins, ready to hand to `Agent.create({ plugins })` or any
660
+ * runtime that consumes model-provider plugins (e.g. the `theokit` agent server / `@theokit/agents`, whose
661
+ * own model resolution does NOT share this registry). Enables a consumer to route to ANY SDK builtin —
662
+ * including one added later in a single SDK file — with ZERO provider-specific code: just
663
+ * `.plugins(Provider.builtins())` once, then pick a `provider/model` id. @public
664
+ */
665
+ static builtins() {
666
+ chunkQC55H6RJ_cjs.registerBuiltins();
667
+ return chunkQC55H6RJ_cjs.listProviders().map((profile) => defineProvider(profile));
668
+ }
669
+ /**
670
+ * The builtin serving `modelId`, or `undefined` when none does.
671
+ *
672
+ * The grammar of a model id — `provider/model` — now has **one** owner. M94: the consumer
673
+ * redid it by hand with `modelId.slice(0, modelId.indexOf('/'))`, which on an id **without a slash** returns the
674
+ * id minus its last character (`claude-opus-5` -> `claude-opus-`): it matches no provider and the
675
+ * caller fell through to the default, without distinguishing that from a hit. A non-routable model was
676
+ * indistinguishable from the happy path.
677
+ *
678
+ * Returns `undefined` instead of throwing: the caller decides whether absence is an error, and only they
679
+ * know whether the model came from an explicit `--model` (an error) or from the default (normal).
680
+ *
681
+ * @public
682
+ */
683
+ static forModel(modelId) {
684
+ const { provider } = chunk3EE6LVWT_cjs.parseModelId(modelId);
685
+ if (provider === void 0) return void 0;
686
+ return _Provider.builtins().find((p) => p.name === provider);
687
+ }
688
+ };
689
+ var SkillReadInputSchema = zod.z.object({
690
+ name: zod.z.string().min(1, "skill_read: `name` is required.")
691
+ });
692
+ function renderSkill(skill) {
693
+ const parts = [`# Skill: ${skill.name}`, "", skill.instructions];
694
+ const refs = skill.references;
695
+ if (refs !== void 0 && Object.keys(refs).length > 0) {
696
+ parts.push("", "## References");
697
+ for (const [file, content] of Object.entries(refs)) {
698
+ parts.push("", `### ${file}`, content);
699
+ }
700
+ }
701
+ return parts.join("\n");
702
+ }
703
+ function defineSkillReadTool(skills) {
704
+ const seen = /* @__PURE__ */ new Set();
705
+ for (const skill of skills) {
706
+ if (seen.has(skill.name)) {
707
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(`defineSkillReadTool: duplicate skill name "${skill.name}".`, {
708
+ code: "duplicate_skill_name"
709
+ });
710
+ }
711
+ seen.add(skill.name);
712
+ }
713
+ return {
714
+ name: "skill_read",
715
+ description: "Read a skill's full instructions (and any bundled reference documents) by its name. Use this to load the body of a skill listed in the <skills> block before acting on it.",
716
+ inputSchema: chunkAA27GEYS_cjs.toJsonSchema(SkillReadInputSchema),
717
+ handler: (input) => {
718
+ const { name } = SkillReadInputSchema.parse(input);
719
+ const skill = skills.find((s) => s.name === name);
720
+ if (skill === void 0) {
721
+ const available = skills.map((s) => s.name).join(", ");
722
+ return `Skill "${name}" not found. Available skills: ${available.length > 0 ? available : "(none)"}.`;
723
+ }
724
+ return renderSkill(skill);
725
+ }
726
+ };
727
+ }
728
+ var SkillReadTool = class {
729
+ constructor() {
730
+ }
731
+ static create(skills) {
732
+ return defineSkillReadTool(skills);
733
+ }
734
+ };
735
+
736
+ // src/env-reachability.ts
737
+ function auditEnvReachability(input) {
738
+ const reachable = new Set(input.reachable);
739
+ const exempt = new Set(input.optOuts.map((o) => o.key));
740
+ const declared = new Set(input.keys);
741
+ return {
742
+ unreachable: input.keys.filter((k) => !reachable.has(k) && !exempt.has(k)),
743
+ staleOptOuts: input.optOuts.filter((o) => !declared.has(o.key) || reachable.has(o.key)).map((o) => o.key)
744
+ };
745
+ }
746
+
747
+ // src/event-bus.ts
748
+ var EventBus = class {
749
+ handlers = /* @__PURE__ */ new Map();
750
+ // M3 #64 — a swallowed handler error used to vanish without a trace (fail-loud
751
+ // violation). We now log it AND expose an observable count so ops/tests can see
752
+ // that a subscriber is silently failing, without breaking the EC-2 contract.
753
+ #handlerErrorCount = 0;
754
+ /** M3 #64 — number of handler invocations that threw (and were logged). */
755
+ get handlerErrorCount() {
756
+ return this.#handlerErrorCount;
757
+ }
758
+ /**
759
+ * Subscribe to an event. Returns an unsubscribe function.
760
+ */
761
+ subscribe(event, handler) {
762
+ if (!this.handlers.has(event)) {
763
+ this.handlers.set(event, /* @__PURE__ */ new Set());
764
+ }
765
+ const set = this.handlers.get(event);
766
+ set.add(handler);
767
+ return () => {
768
+ set.delete(handler);
769
+ };
770
+ }
771
+ /**
772
+ * Publish an event to all subscribers. EC-2: try-catch per handler.
773
+ */
774
+ publish(event, payload) {
775
+ const set = this.handlers.get(event);
776
+ if (!set) return;
777
+ for (const handler of set) {
778
+ try {
779
+ handler(payload);
780
+ } catch (cause) {
781
+ this.#handlerErrorCount += 1;
782
+ const message = cause instanceof Error ? cause.message : String(cause);
783
+ chunk6LHQPOMI_cjs.diag(`[theokit-sdk] event-bus: handler for "${String(event)}" threw: ${message}
784
+ `);
785
+ }
786
+ }
787
+ }
788
+ /**
789
+ * Subscribe to an event for a single firing. Returns an unsubscribe function.
790
+ */
791
+ once(event, handler) {
792
+ const wrapped = (payload) => {
793
+ unsub();
794
+ handler(payload);
795
+ };
796
+ const unsub = this.subscribe(event, wrapped);
797
+ return unsub;
798
+ }
799
+ };
800
+
801
+ // src/goal-loop.ts
802
+ function runGoalLoop(agent, goal, options, depsOverride) {
803
+ async function* wrap() {
804
+ const { runUntilImpl } = await import('./run-until-DG2KXWB2.cjs');
805
+ const deps = depsOverride ?? await (async () => {
806
+ const { judgeCallImpl } = await import('./judge-call-46M2E5FA.cjs');
807
+ const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
808
+ const create = getAgentFacade().create;
809
+ return {
810
+ judge: (ctx, opts) => judgeCallImpl(ctx, opts, { create })
811
+ };
812
+ })();
813
+ return yield* runUntilImpl(agent, goal, options, deps);
814
+ }
815
+ return wrap();
816
+ }
817
+
818
+ // src/internal/budget/tracker/budget-tracker-counter.ts
819
+ function createCounterBudgetTracker(options = {}) {
820
+ let totalTokens = 0;
821
+ let iterations = 0;
822
+ const maxTokens = options.maxTokens;
823
+ const maxIterations = options.maxIterations;
824
+ return {
825
+ track(event) {
826
+ const t = Number.isFinite(event.tokens) && event.tokens > 0 ? event.tokens : 0;
827
+ totalTokens += t;
828
+ },
829
+ check() {
830
+ if (maxTokens !== void 0 && totalTokens >= maxTokens) {
831
+ return {
832
+ allowed: false,
833
+ reason: "token_limit",
834
+ detail: `${totalTokens} >= maxTokens ${maxTokens}`
835
+ };
836
+ }
837
+ if (maxIterations !== void 0 && iterations >= maxIterations) {
838
+ return {
839
+ allowed: false,
840
+ reason: "iteration_limit",
841
+ detail: `${iterations} >= maxIterations ${maxIterations}`
842
+ };
843
+ }
844
+ return { allowed: true };
845
+ },
846
+ getTotal() {
847
+ return { tokens: totalTokens, iterations };
848
+ },
849
+ nextIteration() {
850
+ iterations += 1;
851
+ }
852
+ };
853
+ }
854
+
855
+ // src/internal/plugins/types.ts
856
+ function definePlugin(p) {
857
+ return p;
858
+ }
859
+ var Plugin = { create: definePlugin };
860
+
861
+ // src/internal/runtime/memory-glue/memory-provider-noop.ts
862
+ var NOOP_ADAPTER_ID = "noop";
863
+ var NOOP_CAPABILITIES = {
864
+ history: false,
865
+ sessions: false,
866
+ tenancy: false,
867
+ reasoning: false,
868
+ toolSchemas: false,
869
+ prefetch: false
870
+ };
871
+ function createNoopMemoryAdapter() {
872
+ return {
873
+ id: NOOP_ADAPTER_ID,
874
+ capabilities: NOOP_CAPABILITIES,
875
+ isAvailable() {
876
+ return true;
877
+ },
878
+ async write(_content, _ctx) {
879
+ return `${NOOP_ADAPTER_ID}:noop`;
880
+ },
881
+ async recall(_query, _ctx, _k) {
882
+ return [];
883
+ },
884
+ async delete(_id) {
885
+ return;
886
+ }
887
+ };
888
+ }
889
+ function createNoopMemoryProvider() {
890
+ return {
891
+ async init(_opts) {
892
+ return {
893
+ adapter: createNoopMemoryAdapter()
894
+ };
895
+ },
896
+ buildTools(_handle) {
897
+ return [];
898
+ },
899
+ async runActivePass(_handle, _args) {
900
+ return { facts: [] };
901
+ },
902
+ recordSessionSummary() {
903
+ return;
904
+ },
905
+ dispose(_handle) {
906
+ return;
907
+ }
908
+ };
909
+ }
910
+ var NoopMemoryProvider = class {
911
+ constructor() {
912
+ }
913
+ static create() {
914
+ return createNoopMemoryProvider();
915
+ }
916
+ };
917
+ var JobQueue = class {
918
+ jobs = /* @__PURE__ */ new Map();
919
+ controllers = /* @__PURE__ */ new Map();
920
+ maxConcurrency;
921
+ running = 0;
922
+ waiting = [];
923
+ constructor(options = {}) {
924
+ this.maxConcurrency = options.maxConcurrency === void 0 ? Number.POSITIVE_INFINITY : Math.max(1, options.maxConcurrency);
925
+ }
926
+ /**
927
+ * Enqueue a background function. Returns the job ID immediately. The function
928
+ * receives an `AbortSignal` that fires when the job is cancelled (#58) — a
929
+ * cooperative job should observe it to stop early. Existing `() => Promise<T>`
930
+ * callers are unaffected (the signal argument is simply ignored).
931
+ */
932
+ enqueue(fn2) {
933
+ const id = crypto.randomUUID();
934
+ const job = { id, status: "pending" };
935
+ this.jobs.set(id, job);
936
+ const controller = new AbortController();
937
+ this.controllers.set(id, controller);
938
+ void this.#acquire().then(() => {
939
+ if (job.status === "cancelled") {
940
+ this.#release(id);
941
+ return;
942
+ }
943
+ job.status = "running";
944
+ Promise.resolve().then(() => fn2(controller.signal)).then((result) => {
945
+ if (job.status === "cancelled") return;
946
+ job.result = result;
947
+ job.status = "completed";
948
+ }).catch((err) => {
949
+ if (job.status === "cancelled") return;
950
+ job.error = err instanceof Error ? err.message : String(err);
951
+ job.status = "failed";
952
+ }).finally(() => this.#release(id));
953
+ });
954
+ return id;
955
+ }
956
+ getJob(id) {
957
+ return this.jobs.get(id);
958
+ }
959
+ list() {
960
+ return [...this.jobs.values()];
961
+ }
962
+ /**
963
+ * Cancel a pending or running job. Returns true if cancelled. #58 — aborts the
964
+ * job's `AbortSignal` so a cooperative running job is actually interrupted.
965
+ */
966
+ cancel(id) {
967
+ const job = this.jobs.get(id);
968
+ if (!job) return false;
969
+ if (job.status === "pending" || job.status === "running") {
970
+ const wasRunning = job.status === "running";
971
+ job.status = "cancelled";
972
+ this.controllers.get(id)?.abort();
973
+ if (wasRunning) this.#release(id);
974
+ return true;
975
+ }
976
+ return false;
977
+ }
978
+ /** Acquire a concurrency slot (resolves immediately when unbounded/free). */
979
+ #acquire() {
980
+ if (this.running < this.maxConcurrency) {
981
+ this.running += 1;
982
+ return Promise.resolve();
983
+ }
984
+ return new Promise((resolve) => {
985
+ this.waiting.push(() => {
986
+ this.running += 1;
987
+ resolve();
988
+ });
989
+ });
990
+ }
991
+ /**
992
+ * Release a slot + clean up the controller; start the next waiting job.
993
+ * Idempotent — keyed on the controller's presence, so a running job that was
994
+ * cancelled (released early) does not double-decrement when its `.finally`
995
+ * eventually fires.
996
+ */
997
+ #release(id) {
998
+ if (!this.controllers.has(id)) return;
999
+ this.controllers.delete(id);
1000
+ this.running -= 1;
1001
+ const next = this.waiting.shift();
1002
+ if (next !== void 0) next();
1003
+ }
1004
+ };
1005
+
1006
+ // src/layer-fold.ts
1007
+ var LayerOrderError = class extends chunkJ7J7J2GN_cjs.TheokitAgentError {
1008
+ name = "LayerOrderError";
1009
+ };
1010
+ function verifyLayerOrdering(layers) {
1011
+ let previous;
1012
+ for (const current of layers) {
1013
+ if (current.precedence === void 0) continue;
1014
+ const declared = { layer: current.layer, precedence: current.precedence };
1015
+ if (previous !== void 0 && declared.precedence <= previous.precedence) {
1016
+ throw new LayerOrderError(
1017
+ `layers out of order: \`${declared.layer}\` (precedence ${String(declared.precedence)}) comes after \`${previous.layer}\` (precedence ${String(previous.precedence)}) but does not outrank it`
1018
+ );
1019
+ }
1020
+ previous = declared;
1021
+ }
1022
+ }
1023
+ function foldLayers(entries, accumulatingKeys = []) {
1024
+ verifyLayerOrdering(entries);
1025
+ const accumulated = new Map(accumulatingKeys.map((k) => [k, []]));
1026
+ const combined = {};
1027
+ for (const { values } of entries) {
1028
+ for (const [key, value] of Object.entries(values)) {
1029
+ if (value === void 0) continue;
1030
+ const stack = accumulated.get(key);
1031
+ if (stack !== void 0 && Array.isArray(value)) {
1032
+ stack.push(...value);
1033
+ combined[key] = [...stack];
1034
+ continue;
1035
+ }
1036
+ combined[key] = value;
1037
+ }
1038
+ }
1039
+ return combined;
1040
+ }
1041
+
1042
+ // src/internal/memory/dreaming/phases.ts
1043
+ var DEFAULT_DEDUP_THRESHOLD = 0.95;
1044
+ var DEFAULT_CLUSTER_THRESHOLD = 0.75;
1045
+ var CONSOLIDATABLE_KINDS = /* @__PURE__ */ new Set(["project"]);
1046
+ var ATOMIC_KINDS = /* @__PURE__ */ new Set(["user", "feedback", "reference"]);
1047
+ function dedupPolicy(fact) {
1048
+ if (fact.kind === void 0) return "exact";
1049
+ if (ATOMIC_KINDS.has(fact.kind)) return "never";
1050
+ return CONSOLIDATABLE_KINDS.has(fact.kind) ? "similar" : "never";
1051
+ }
1052
+ function normalizeForExactMatch(text) {
1053
+ return text.trim().toLowerCase().replace(/\s+/g, " ").replace(/[.!?]+$/, "");
1054
+ }
1055
+ async function lightPhase(facts, embedding, threshold = DEFAULT_DEDUP_THRESHOLD) {
1056
+ if (facts.length <= 1) return { kept: [...facts], duplicatesRemoved: 0 };
1057
+ const never = facts.filter((f) => dedupPolicy(f) === "never");
1058
+ const exact = facts.filter((f) => dedupPolicy(f) === "exact");
1059
+ const similar = facts.filter((f) => dedupPolicy(f) === "similar");
1060
+ const seen = /* @__PURE__ */ new Set();
1061
+ const exactKept = [];
1062
+ let removed = 0;
1063
+ for (const f of exact) {
1064
+ const key = normalizeForExactMatch(f.text);
1065
+ if (seen.has(key)) {
1066
+ removed += 1;
1067
+ continue;
1068
+ }
1069
+ seen.add(key);
1070
+ exactKept.push(f);
1071
+ }
1072
+ const sim = similar.length > 1 ? await dedupCandidates(similar, embedding, threshold) : { kept: [...similar], duplicatesRemoved: 0 };
1073
+ return {
1074
+ kept: [...never, ...exactKept, ...sim.kept],
1075
+ duplicatesRemoved: removed + sim.duplicatesRemoved
1076
+ };
1077
+ }
1078
+ async function dedupCandidates(facts, embedding, threshold) {
1079
+ if (facts.length <= 1) return { kept: [...facts], duplicatesRemoved: 0 };
1080
+ const vectors = await embedding.embed(facts.map((f) => f.text));
1081
+ const keptIdx = [];
1082
+ const keptVecs = [];
1083
+ for (let i = 0; i < facts.length; i++) {
1084
+ const vec = vectors[i] ?? [];
1085
+ const isDup = keptVecs.some((kept2) => cosineSimilarity(vec, kept2) >= threshold);
1086
+ if (isDup) continue;
1087
+ keptIdx.push(i);
1088
+ keptVecs.push(vec);
1089
+ }
1090
+ const kept = keptIdx.map((i) => facts[i]);
1091
+ return { kept, duplicatesRemoved: facts.length - kept.length };
1092
+ }
1093
+ var DEFAULT_MAX_FACTS_PER_SWEEP = 500;
1094
+ async function remPhase(facts, embedding, threshold = DEFAULT_CLUSTER_THRESHOLD, maxFactsPerSweep = DEFAULT_MAX_FACTS_PER_SWEEP) {
1095
+ if (facts.length === 0) return { clusters: [] };
1096
+ const capped = facts.length > maxFactsPerSweep ? facts.slice(0, maxFactsPerSweep) : facts;
1097
+ const vectors = await embedding.embed(capped.map((f) => f.text));
1098
+ const clusterOfIdx = unionFindByPairs(vectors, threshold);
1099
+ const groups = bucketFactsByClusterRoot(capped, clusterOfIdx);
1100
+ return { clusters: [...groups.values()].map(buildClusterFromMembers) };
1101
+ }
1102
+ function unionFindByPairs(vectors, threshold) {
1103
+ const clusterOfIdx = vectors.map((_, i) => i);
1104
+ for (let i = 0; i < vectors.length; i++) {
1105
+ for (let j = i + 1; j < vectors.length; j++) {
1106
+ if (cosineSimilarity(vectors[i] ?? [], vectors[j] ?? []) >= threshold) {
1107
+ unifyClusters(clusterOfIdx, i, j);
1108
+ }
1109
+ }
1110
+ }
1111
+ return clusterOfIdx;
1112
+ }
1113
+ function bucketFactsByClusterRoot(facts, clusterOfIdx) {
1114
+ const groups = /* @__PURE__ */ new Map();
1115
+ for (let i = 0; i < facts.length; i++) {
1116
+ const root = findRoot(clusterOfIdx, i);
1117
+ const list2 = groups.get(root) ?? [];
1118
+ list2.push(facts[i]);
1119
+ groups.set(root, list2);
1120
+ }
1121
+ return groups;
1122
+ }
1123
+ function buildClusterFromMembers(members) {
1124
+ const sorted = [...members].sort((a, b) => b.text.length - a.text.length);
1125
+ return { representativeText: sorted[0]?.text ?? "", members };
1126
+ }
1127
+ function deepPhase(clusters, timestampMs) {
1128
+ if (clusters.length === 0) return "";
1129
+ const isoStamp = new Date(timestampMs).toISOString();
1130
+ const lines = [`# Dreamed ${isoStamp}`, ""];
1131
+ for (let i = 0; i < clusters.length; i++) {
1132
+ const c = clusters[i];
1133
+ if (c === void 0) continue;
1134
+ lines.push(`## Cluster ${i + 1}: ${c.representativeText}`);
1135
+ lines.push("");
1136
+ for (const member of c.members) lines.push(`- ${member.text}`);
1137
+ lines.push("");
1138
+ }
1139
+ return `${lines.join("\n")}
1140
+ `;
1141
+ }
1142
+ function cosineSimilarity(a, b) {
1143
+ if (a.length === 0 || b.length === 0 || a.length !== b.length) return 0;
1144
+ let dot = 0;
1145
+ let aNorm = 0;
1146
+ let bNorm = 0;
1147
+ for (let i = 0; i < a.length; i++) {
1148
+ const ai = a[i] ?? 0;
1149
+ const bi = b[i] ?? 0;
1150
+ dot += ai * bi;
1151
+ aNorm += ai * ai;
1152
+ bNorm += bi * bi;
1153
+ }
1154
+ const denom = Math.sqrt(aNorm) * Math.sqrt(bNorm);
1155
+ return denom === 0 ? 0 : dot / denom;
1156
+ }
1157
+ function findRoot(parents, i) {
1158
+ let root = i;
1159
+ while (parents[root] !== root) {
1160
+ const next = parents[root] ?? root;
1161
+ if (next === root) break;
1162
+ root = next;
1163
+ }
1164
+ parents[i] = root;
1165
+ return root;
1166
+ }
1167
+ function unifyClusters(parents, a, b) {
1168
+ const rootA = findRoot(parents, a);
1169
+ const rootB = findRoot(parents, b);
1170
+ if (rootA !== rootB) parents[rootB] = rootA;
1171
+ }
1172
+
1173
+ // src/internal/memory/dreaming/run.ts
1174
+ function runDreamingSweep(options) {
1175
+ return chunkZF2LDKQQ_cjs.withCwdMutex(`dream:${options.cwd}`, () => runInner(options));
1176
+ }
1177
+ async function runInner(options) {
1178
+ const now = options.now ?? Date.now;
1179
+ const timestampMs = now();
1180
+ try {
1181
+ const root = options.memoryRoot ?? chunkNQTNSHSB_cjs.resolveMemoryRoot(options.cwd);
1182
+ const facts = await chunkNQTNSHSB_cjs.readFactsFromMarkdown(
1183
+ options.cwd,
1184
+ options.memoryRoot ? { directory: options.memoryRoot } : void 0
1185
+ );
1186
+ if (facts.length === 0) {
1187
+ return emptyResult("skipped");
1188
+ }
1189
+ const dedup = await lightPhase(facts, options.embedding, options.dedupThreshold);
1190
+ const rem = await remPhase(dedup.kept, options.embedding, options.clusterThreshold);
1191
+ const notesWritten = await writeConsolidatedNotes(root, rem.clusters, timestampMs);
1192
+ const result = {
1193
+ status: "ok",
1194
+ factsBefore: facts.length,
1195
+ factsAfter: dedup.kept.length,
1196
+ duplicatesRemoved: dedup.duplicatesRemoved,
1197
+ clustersCreated: rem.clusters.length,
1198
+ notesWritten,
1199
+ diaryEntryHash: void 0
1200
+ };
1201
+ await chunkVPK6PHIE_cjs.appendDiaryEntry(root, {
1202
+ timestampMs,
1203
+ factsBefore: result.factsBefore,
1204
+ factsAfter: result.factsAfter,
1205
+ duplicatesRemoved: result.duplicatesRemoved,
1206
+ clustersCreated: result.clustersCreated,
1207
+ notesWritten: result.notesWritten
1208
+ });
1209
+ return result;
1210
+ } catch (cause) {
1211
+ const message = cause instanceof Error ? cause.message : String(cause);
1212
+ chunk6LHQPOMI_cjs.diag(`[theokit-sdk] dreaming sweep failed: ${message}
1213
+ `);
1214
+ return emptyResult("error");
1215
+ }
1216
+ }
1217
+ async function writeConsolidatedNotes(root, clusters, timestampMs) {
1218
+ if (clusters.length === 0) return 0;
1219
+ const notesDir = path.join(root, "notes");
1220
+ await promises.mkdir(notesDir, { recursive: true });
1221
+ const isoSlug = new Date(timestampMs).toISOString().replace(/[^\dT]/g, "-");
1222
+ const file = path.join(notesDir, `dreamed-${isoSlug}.md`);
1223
+ const body = deepPhase(clusters, timestampMs);
1224
+ await chunkJLRLCBJ4_cjs.replaceFileAtomic(file, body);
1225
+ return 1;
1226
+ }
1227
+ function emptyResult(status) {
1228
+ return {
1229
+ status,
1230
+ factsBefore: 0,
1231
+ factsAfter: 0,
1232
+ duplicatesRemoved: 0,
1233
+ clustersCreated: 0,
1234
+ notesWritten: 0,
1235
+ diaryEntryHash: void 0
1236
+ };
1237
+ }
1238
+
1239
+ // src/internal/memory/sdk-memory-peer-loader.ts
1240
+ var cachedAttempt;
1241
+ async function loadPeer() {
1242
+ try {
1243
+ const spec = "@theokit/sdk-memory";
1244
+ const mod = await import(spec);
1245
+ if (hasExpectedSurface(mod)) return mod;
1246
+ chunk6LHQPOMI_cjs.diag(
1247
+ "sdk-memory peer loaded but does not expose the expected surface (runDreamingSweep / MEMORY_EMBEDDING_ADAPTERS / IndexManager / migrateSqliteToLance) \u2014 falling back to the legacy memory path"
1248
+ );
1249
+ return null;
1250
+ } catch (err) {
1251
+ if (err?.code !== "ERR_MODULE_NOT_FOUND") {
1252
+ chunk6LHQPOMI_cjs.diag(
1253
+ `sdk-memory peer is installed but failed to load \u2014 falling back to the legacy memory path: ${err instanceof Error ? err.message : String(err)}`
1254
+ );
1255
+ }
1256
+ return null;
1257
+ }
1258
+ }
1259
+ function hasExpectedSurface(mod) {
1260
+ return typeof mod.runDreamingSweep === "function" && mod.MEMORY_EMBEDDING_ADAPTERS !== void 0 && mod.IndexManager !== void 0 && typeof mod.migrateSqliteToLance === "function";
1261
+ }
1262
+ function tryLoadSdkMemoryPeer() {
1263
+ if (cachedAttempt !== void 0) return cachedAttempt;
1264
+ cachedAttempt = loadPeer();
1265
+ return cachedAttempt;
1266
+ }
1267
+
1268
+ // src/memory.ts
1269
+ var Memory = {
1270
+ /**
1271
+ * Open a memory index. Dispatches to SQLite-vec (default, zero deps) or
1272
+ * LanceDB (opt-in via `backend: "lance"`, requires `@lancedb/lancedb`
1273
+ * peer dep + an embedding runtime).
1274
+ *
1275
+ * Returns a `MemoryIndex` with `sync()`, `search(query, opts?)`,
1276
+ * `status()`, and `close()`. Use this when you want a direct index
1277
+ * handle outside of `Agent.create({ memory: ... })`.
1278
+ *
1279
+ * @throws ConfigurationError({code:"invalid_memory_backend"}) for typos
1280
+ * like `"lancedb"`.
1281
+ * @throws ConfigurationError({code:"lance_requires_embedding"}) when
1282
+ * `backend: "lance"` is requested without `embedding`.
1283
+ * @throws ConfigurationError({code:"lance_backend_unavailable"}) when
1284
+ * `backend: "lance"` is requested but the peer dep is absent.
1285
+ *
1286
+ * @public
1287
+ */
1288
+ async openIndex(opts) {
1289
+ const peer = await tryLoadSdkMemoryPeer();
1290
+ const openArgs = buildIndexOpenArgs(opts);
1291
+ if (peer !== null) {
1292
+ openArgs.embedding = await resolveEmbedding(opts.embedding, peer.MEMORY_EMBEDDING_ADAPTERS);
1293
+ return await peer.IndexManager.open(openArgs);
1294
+ }
1295
+ const { IndexManager } = await import('./index-manager-3UNPYH34.cjs');
1296
+ openArgs.embedding = await resolveEmbedding(opts.embedding, chunkD3CCY3A2_cjs.MEMORY_EMBEDDING_ADAPTERS);
1297
+ return await IndexManager.open(openArgs);
1298
+ },
1299
+ /**
1300
+ * Run a dreaming sweep: dedup near-duplicate facts, cluster thematically
1301
+ * related ones, and write a consolidated note + diary entry.
1302
+ *
1303
+ * @public
1304
+ */
1305
+ async runDreamingSweep(opts) {
1306
+ const peer = await tryLoadSdkMemoryPeer();
1307
+ const catalog = peer !== null ? peer.MEMORY_EMBEDDING_ADAPTERS : chunkD3CCY3A2_cjs.MEMORY_EMBEDDING_ADAPTERS;
1308
+ const sweepArgs = await buildDreamingSweepArgs(opts, catalog);
1309
+ const result = peer !== null ? (
1310
+ // biome-ignore lint/suspicious/noExplicitAny: peer is dynamically loaded — structural compat ensured by sdk-memory
1311
+ await peer.runDreamingSweep(sweepArgs)
1312
+ ) : (
1313
+ // biome-ignore lint/suspicious/noExplicitAny: legacy path accepts the same shape
1314
+ await runDreamingSweep(sweepArgs)
1315
+ );
1316
+ return toDreamingSweepResult(result);
1317
+ }
1318
+ };
1319
+ async function resolveEmbedding(embeddingOpts, catalog) {
1320
+ if (embeddingOpts === void 0) return void 0;
1321
+ const adapter = catalog[embeddingOpts.provider];
1322
+ if (adapter === void 0) {
1323
+ throw new Error(
1324
+ `Unknown embedding provider "${embeddingOpts.provider}". Supported: ${Object.keys(catalog).join(", ")}.`
1325
+ );
1326
+ }
1327
+ return adapter.create(embeddingOpts.model !== void 0 ? { model: embeddingOpts.model } : {});
1328
+ }
1329
+ function buildIndexOpenArgs(opts, embedding) {
1330
+ return {
1331
+ cwd: opts.cwd,
1332
+ ...opts.filePath !== void 0 ? { filePath: opts.filePath } : {},
1333
+ ...{},
1334
+ ...opts.backend !== void 0 ? { backend: opts.backend } : {}
1335
+ };
1336
+ }
1337
+ async function buildDreamingSweepArgs(opts, catalog) {
1338
+ const runtime = await resolveEmbedding(opts.embedding, catalog);
1339
+ return {
1340
+ cwd: opts.cwd,
1341
+ memoryRoot: chunkNQTNSHSB_cjs.resolveMemoryRoot(opts.cwd, { directory: opts.directory }),
1342
+ embedding: runtime,
1343
+ ...opts.dedupThreshold !== void 0 ? { dedupThreshold: opts.dedupThreshold } : {},
1344
+ ...opts.clusterThreshold !== void 0 ? { clusterThreshold: opts.clusterThreshold } : {}
1345
+ };
1346
+ }
1347
+ function toDreamingSweepResult(result) {
1348
+ return {
1349
+ status: result.status,
1350
+ factsBefore: result.factsBefore,
1351
+ factsAfter: result.factsAfter,
1352
+ duplicatesRemoved: result.duplicatesRemoved,
1353
+ clustersCreated: result.clustersCreated,
1354
+ notesWritten: result.notesWritten
1355
+ };
1356
+ }
1357
+
1358
+ // src/memory-adapter-helpers.ts
1359
+ function mkMemoryId(adapterId, rawId) {
1360
+ return `${adapterId}:${rawId}`;
1361
+ }
1362
+ function extractRawId(id, expectedAdapterId) {
1363
+ const prefix = `${expectedAdapterId}:`;
1364
+ if (!id.startsWith(prefix)) {
1365
+ const sourcePrefix = id.split(":", 1)[0] ?? "<malformed>";
1366
+ throw new chunkJ7J7J2GN_cjs.MemoryAdapterError(
1367
+ `MemoryId belongs to a different adapter (expected "${expectedAdapterId}", got "${sourcePrefix}")`,
1368
+ { adapterId: expectedAdapterId, code: "invalid_input" }
1369
+ );
1370
+ }
1371
+ return id.slice(prefix.length);
1372
+ }
1373
+
1374
+ // src/migrate.ts
1375
+ async function migrateSqliteToLance2(options) {
1376
+ const peer = await tryLoadSdkMemoryPeer();
1377
+ if (peer !== null) {
1378
+ return peer.migrateSqliteToLance(options);
1379
+ }
1380
+ return chunkVPK6PHIE_cjs.migrateSqliteToLance(options);
1381
+ }
1382
+
1383
+ // src/permission-engine.ts
1384
+ function applyMode(verdict, mode, explicit) {
1385
+ if (verdict === "deny") return "deny";
1386
+ switch (mode) {
1387
+ case "default":
1388
+ return verdict;
1389
+ case "plan":
1390
+ return verdict === "allow" ? "allow" : "deny";
1391
+ case "acceptEdits":
1392
+ if (verdict === "ask") return explicit ? "ask" : "allow";
1393
+ return verdict;
1394
+ // allow stays allow
1395
+ case "bypass":
1396
+ case "bypassPermissions":
1397
+ return "allow";
1398
+ }
1399
+ }
1400
+ function argMatches(matcher, value) {
1401
+ if (value === void 0) return false;
1402
+ if (typeof matcher === "function") return matcher(value);
1403
+ if (matcher instanceof RegExp) {
1404
+ matcher.lastIndex = 0;
1405
+ return matcher.test(String(value));
1406
+ }
1407
+ return matcher === value;
1408
+ }
1409
+ var PermissionEngine = class {
1410
+ constructor(rules, options = {}) {
1411
+ this.rules = rules;
1412
+ this.defaultAction = options.defaultAction ?? "ask";
1413
+ }
1414
+ rules;
1415
+ defaultAction;
1416
+ /**
1417
+ * Evaluate a tool name (and optional arguments) against the rules. First
1418
+ * match wins; falls back to the configured `defaultAction` (default `"ask"`,
1419
+ * fail-closed) when no rule matches. #55 — a rule with `args` gates on the
1420
+ * argument values, so the same tool name can resolve to different actions
1421
+ * depending on what it is asked to do.
1422
+ */
1423
+ evaluate(toolName, args, mode = "default") {
1424
+ for (const rule of this.rules) {
1425
+ const nameMatches = typeof rule.tool === "string" ? rule.tool === toolName : rule.tool.test(toolName);
1426
+ if (!nameMatches) continue;
1427
+ if (rule.args !== void 0 && !this.#argsMatch(rule.args, args)) continue;
1428
+ return applyMode(rule.action, mode, true);
1429
+ }
1430
+ return applyMode(this.defaultAction, mode, false);
1431
+ }
1432
+ #argsMatch(matchers, args) {
1433
+ const call = args ?? {};
1434
+ for (const [key, matcher] of Object.entries(matchers)) {
1435
+ if (!argMatches(matcher, call[key])) return false;
1436
+ }
1437
+ return true;
1438
+ }
1439
+ };
1440
+
1441
+ // src/permission-plugin.ts
1442
+ async function resolveAsk(opts, name, args, mode) {
1443
+ if (opts.canUseTool !== void 0) {
1444
+ let decision;
1445
+ try {
1446
+ decision = await opts.canUseTool(name, args, { toolName: name, mode });
1447
+ } catch {
1448
+ return { block: true, message: `permission gate error (fail-closed): ${name}` };
1449
+ }
1450
+ return decision?.behavior === "allow" ? void 0 : { block: true, message: decision?.message ?? `denied: ${name}` };
1451
+ }
1452
+ return opts.onAsk ? opts.onAsk(name) : { block: true, message: `requires approval: ${name}` };
1453
+ }
1454
+ function createPermissionPlugin(engine, opts = {}) {
1455
+ return definePlugin({
1456
+ name: opts.name ?? "permission-engine",
1457
+ version: "1.0.0",
1458
+ kind: "general",
1459
+ register(ctx) {
1460
+ ctx.on("pre_tool_call", async (rawCtx) => {
1461
+ const { name, args, permissionMode } = rawCtx;
1462
+ const mode = permissionMode ?? opts.mode ?? "default";
1463
+ const action = engine.evaluate(name, args, mode);
1464
+ if (action === "deny") {
1465
+ return { block: true, message: `denied by permission engine: ${name}` };
1466
+ }
1467
+ if (action === "ask") return resolveAsk(opts, name, args, mode);
1468
+ return void 0;
1469
+ });
1470
+ }
1471
+ });
1472
+ }
1473
+ var PermissionPlugin = class {
1474
+ constructor() {
1475
+ }
1476
+ static create(engine, opts = {}) {
1477
+ return createPermissionPlugin(engine, opts);
1478
+ }
1479
+ };
1480
+
1481
+ // src/project-env.ts
1482
+ var SOVEREIGN_ENV_KEYS = [
1483
+ /** Locates the SDK home — sessions, and the credential store beneath it. */
1484
+ "THEOKIT_HOME",
1485
+ /** Locates the credential store explicitly, independently of `THEOKIT_HOME`. */
1486
+ "THEOKIT_AUTH_HOME",
1487
+ /** A trust decision: which providers are honoured without further checks. */
1488
+ "THEOKIT_TRUSTED_PROVIDERS",
1489
+ /** Turning redaction off from a repository's `.env` would put secrets into logs. */
1490
+ "THEOKIT_REDACT_SECRETS",
1491
+ /** Cryptographic material for the OAuth transaction cookie. */
1492
+ "THEOKIT_OAUTH_TX_SALT"
1493
+ ];
1494
+ function loadProjectEnv(env = process.env, load = typeof process.loadEnvFile === "function" ? () => {
1495
+ process.loadEnvFile();
1496
+ } : void 0) {
1497
+ if (load === void 0) return;
1498
+ const sovereign = new Map(
1499
+ SOVEREIGN_ENV_KEYS.map((key) => [key, env[key]])
1500
+ );
1501
+ try {
1502
+ load();
1503
+ } catch {
1504
+ return;
1505
+ }
1506
+ for (const [key, original] of sovereign) {
1507
+ if (original === void 0) delete env[key];
1508
+ else env[key] = original;
1509
+ }
1510
+ }
1511
+
1512
+ // src/reap-plan.ts
1513
+ var RetentionPolicyError = class extends chunkJ7J7J2GN_cjs.TheokitAgentError {
1514
+ name = "RetentionPolicyError";
1515
+ };
1516
+ function assertPolicy(retention) {
1517
+ const { maxAgeMs, keepLast } = retention;
1518
+ if (!Number.isFinite(maxAgeMs) || maxAgeMs < 0) {
1519
+ throw new RetentionPolicyError(
1520
+ `retention.maxAgeMs must be a non-negative number of milliseconds, got ${String(maxAgeMs)}`
1521
+ );
1522
+ }
1523
+ if (!Number.isInteger(keepLast) || keepLast < 0) {
1524
+ throw new RetentionPolicyError(
1525
+ `retention.keepLast must be a non-negative integer, got ${String(keepLast)}`
1526
+ );
1527
+ }
1528
+ }
1529
+ function classifyByOwnReason(input) {
1530
+ const keep = [];
1531
+ const atRisk = [];
1532
+ for (const artifact of input.artifacts) {
1533
+ if (artifact.live === "unknown") continue;
1534
+ if (artifact.live === true) {
1535
+ keep.push({ ...artifact, reason: "live" });
1536
+ continue;
1537
+ }
1538
+ if (input.nowMs - artifact.lastModifiedMs <= input.retention.maxAgeMs) {
1539
+ keep.push({ ...artifact, reason: "within-retention" });
1540
+ continue;
1541
+ }
1542
+ atRisk.push(artifact);
1543
+ }
1544
+ return { keep, atRisk };
1545
+ }
1546
+ function applyFloor(kept, atRisk, keepLast) {
1547
+ const shortfall = Math.max(0, keepLast - kept.length);
1548
+ const newestFirst = [...atRisk].sort((a, b) => b.lastModifiedMs - a.lastModifiedMs);
1549
+ const spared = new Set(newestFirst.slice(0, shortfall).map((a) => a.id));
1550
+ const rescued = [];
1551
+ const reap = [];
1552
+ for (const artifact of atRisk) {
1553
+ if (spared.has(artifact.id)) rescued.push({ ...artifact, reason: "keep-last" });
1554
+ else reap.push(artifact);
1555
+ }
1556
+ return { rescued, reap };
1557
+ }
1558
+ function planReaping(input) {
1559
+ assertPolicy(input.retention);
1560
+ const undetermined = input.artifacts.filter((a) => a.live === "unknown");
1561
+ const { keep, atRisk } = classifyByOwnReason(input);
1562
+ const { rescued, reap } = applyFloor(keep, atRisk, input.retention.keepLast);
1563
+ return { reap, keep: [...keep, ...rescued], undetermined };
1564
+ }
1565
+
1566
+ // src/schema-normalizer.ts
1567
+ function isJsonSchemaObject(s) {
1568
+ if (typeof s !== "object" || s === null) return false;
1569
+ const o = s;
1570
+ if ("$schema" in o) return true;
1571
+ return o.type === "object" && typeof o.properties === "object" && o.properties !== null;
1572
+ }
1573
+ function hasToJsonSchemaMethod(s) {
1574
+ return typeof s === "object" && s !== null && typeof s.toJsonSchema === "function";
1575
+ }
1576
+ function isZodSchema(s) {
1577
+ if (typeof s !== "object" || s === null) return false;
1578
+ const o = s;
1579
+ return typeof o.safeParse === "function" && ("_def" in o || "def" in o);
1580
+ }
1581
+ function isValibotSchema(s) {
1582
+ if (typeof s !== "object" || s === null) return false;
1583
+ const o = s;
1584
+ return o.kind === "schema" && "type" in o && typeof o.toJsonSchema !== "function";
1585
+ }
1586
+ function isMissingModuleError(err) {
1587
+ if (err?.code === "ERR_MODULE_NOT_FOUND") return true;
1588
+ return err instanceof Error && /Cannot find|Cannot resolve|ERR_MODULE_NOT_FOUND/.test(err.message);
1589
+ }
1590
+ async function normalizeValibotSchema(schema) {
1591
+ const specifier = "@valibot/to-json-schema";
1592
+ try {
1593
+ const mod = await import(specifier);
1594
+ return mod.toJsonSchema(schema);
1595
+ } catch (err) {
1596
+ if (!isMissingModuleError(err)) throw err;
1597
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(
1598
+ "normalizeSchema: a Valibot schema requires the optional '@valibot/to-json-schema' package. Install it, or use a Zod schema (the default recommendation).",
1599
+ { code: "valibot_converter_missing" }
1600
+ );
1601
+ }
1602
+ }
1603
+ async function normalizeSchema(schema) {
1604
+ if (isJsonSchemaObject(schema)) return schema;
1605
+ if (isValibotSchema(schema)) return await normalizeValibotSchema(schema);
1606
+ if (isZodSchema(schema)) {
1607
+ return chunkAA27GEYS_cjs.toJsonSchema(schema, { unrepresentable: "any" });
1608
+ }
1609
+ if (hasToJsonSchemaMethod(schema)) return schema.toJsonSchema();
1610
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(
1611
+ "normalizeSchema: unsupported schema. Supported: Zod (default), JSON Schema, ArkType (.toJsonSchema()), Valibot (with @valibot/to-json-schema).",
1612
+ { code: "unsupported_schema" }
1613
+ );
1614
+ }
1615
+
1616
+ // src/security.ts
1617
+ var Security = class {
1618
+ constructor() {
1619
+ }
1620
+ /**
1621
+ * Redact known credential patterns from `text` and return the masked
1622
+ * string. Use this at any consumer output boundary the SDK does not
1623
+ * directly own (custom stdout loggers, app-level metrics, debug-share
1624
+ * artifacts, etc.).
1625
+ *
1626
+ * Coerces non-strings (objects via JSON.stringify, null/undefined → "").
1627
+ * Two-bucket masking: tokens shorter than 18 chars → `***`; longer
1628
+ * tokens preserve `prefix...suffix` for debuggability without revealing
1629
+ * the secret middle.
1630
+ *
1631
+ * @param text - The value to redact. Strings, objects, primitives all OK.
1632
+ * @param opts.codeFile - When `true`, skips the parametric `key=value`
1633
+ * matcher so file content like `.env.example` placeholders is left
1634
+ * intact. Built-in pattern matches still apply.
1635
+ *
1636
+ * @example
1637
+ * console.log(`[bot] received: ${Security.redact(userText)}`);
1638
+ * // → "[bot] received: please remember sk-abc...xyz1"
1639
+ */
1640
+ static redact(text, opts) {
1641
+ return chunk6LHQPOMI_cjs.redactSecrets(text, opts);
1642
+ }
1643
+ /**
1644
+ * Register a custom redaction pattern. Additive — built-in patterns
1645
+ * (OpenAI, Anthropic, GitHub PAT, AWS, etc.) cannot be removed.
1646
+ *
1647
+ * @param re - RegExp with `/g` flag. Throws if `/g` is missing
1648
+ * (without /g, only first match is replaced and the rest
1649
+ * leaks).
1650
+ *
1651
+ * Process-global mutable state. The SDK is designed for single-tenant
1652
+ * processes (Theo PaaS user runtime, local CLI). Multi-tenant
1653
+ * deployments running multiple SDK consumers in the same Node process
1654
+ * share this list — patterns added by tenant A apply to tenant B's
1655
+ * redactions. Acceptable for v1; future isolate-aware refactor would
1656
+ * thread patterns through a context if needed.
1657
+ *
1658
+ * @example
1659
+ * Security.addPattern(/MYORG-[A-Z0-9]{32}/g);
1660
+ * // → text containing "MYORG-AAAA...AAAA" now masks like a builtin.
1661
+ */
1662
+ static addPattern(re) {
1663
+ if (!re.global) {
1664
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(
1665
+ "Security.addPattern: regex must have /g flag for replace-all semantics",
1666
+ { code: "invalid_redaction_pattern" }
1667
+ );
1668
+ }
1669
+ chunk6LHQPOMI_cjs.addPattern(re);
1670
+ }
1671
+ };
1672
+
1673
+ // src/security-floor.ts
1674
+ function permissivenessOf(order, value) {
1675
+ if (value === void 0) return -1;
1676
+ return order.indexOf(value);
1677
+ }
1678
+ function baseline(input) {
1679
+ const { restricted, override, layers } = input;
1680
+ let value;
1681
+ for (const [name, candidate] of Object.entries(layers)) {
1682
+ if (name === override || restricted.includes(name)) continue;
1683
+ if (candidate !== void 0) value = candidate;
1684
+ }
1685
+ return value;
1686
+ }
1687
+ function tightenOnly(input, start) {
1688
+ const { permissiveness, restricted, layers } = input;
1689
+ let resolved = start;
1690
+ let ceiling = permissivenessOf(permissiveness, start);
1691
+ for (const layer of restricted) {
1692
+ const candidate = layers[layer];
1693
+ if (candidate === void 0) continue;
1694
+ const level = permissivenessOf(permissiveness, candidate);
1695
+ if (level < 0) continue;
1696
+ if (ceiling >= 0 && level > ceiling) continue;
1697
+ resolved = candidate;
1698
+ ceiling = level;
1699
+ }
1700
+ return resolved;
1701
+ }
1702
+ function applySecurityFloor(input) {
1703
+ return input.layers[input.override] ?? tightenOnly(input, baseline(input));
1704
+ }
1705
+
1706
+ // src/session-guard.ts
1707
+ var LiveSessionError = class extends chunkJ7J7J2GN_cjs.TheokitAgentError {
1708
+ name = "LiveSessionError";
1709
+ sessionId;
1710
+ reason;
1711
+ constructor(sessionId, reason) {
1712
+ super(
1713
+ reason === "session-is-live" ? `refusing to destroy session ${sessionId}: it is live \u2014 another process is probably still appending to it. Switch to another session first.` : `refusing to destroy session ${sessionId}: the set of live sessions could not be determined, so this cannot be shown to be safe. Resolve that before deleting.`
1714
+ );
1715
+ this.sessionId = sessionId;
1716
+ this.reason = reason;
1717
+ }
1718
+ };
1719
+ function guardSessionDestruction(sessionId, live) {
1720
+ if (live === void 0) {
1721
+ throw new LiveSessionError(sessionId, "liveness-undetermined");
1722
+ }
1723
+ if (live.includes(sessionId)) {
1724
+ throw new LiveSessionError(sessionId, "session-is-live");
1725
+ }
1726
+ }
1727
+
1728
+ // src/session-messages.ts
1729
+ async function readSessionMessages2(options) {
1730
+ const cwd = options.cwd ?? process.cwd();
1731
+ const baseDir = chunkD3CCY3A2_cjs.resolveSessionDir({ sessionDir: options.sessionDir });
1732
+ return chunkYIFFF23U_cjs.readSessionMessages(new chunk7FDKWDA2_cjs.FsSessionStore({ baseDir, cwd }), options.sessionId);
1733
+ }
1734
+
1735
+ // src/session-scope.ts
1736
+ function scopedConversationId(scope, id) {
1737
+ return `${scope}__${id}`;
1738
+ }
1739
+ function sessionScopePrefix(scope) {
1740
+ return `${scope}__`;
1741
+ }
1742
+
1743
+ // src/squad.ts
1744
+ function isBuiltAgent(m) {
1745
+ return typeof m.send === "function";
1746
+ }
1747
+ async function materialize(def, index) {
1748
+ const { Agent: Agent2 } = await import('./agent-ARLOD4JX.cjs');
1749
+ return Agent2.create({
1750
+ // `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
1751
+ // here means "declare nothing and let the default apply" — forwarding the literal would create
1752
+ // an agent asking for a model literally named `inherit`.
1753
+ ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model } : {},
1754
+ ...def.prompt !== void 0 ? { systemPrompt: def.prompt } : {},
1755
+ agentId: `squad-member-${String(index)}`,
1756
+ local: {}
1757
+ });
1758
+ }
1759
+ function createSquad(options) {
1760
+ const { agents } = options;
1761
+ if (!Array.isArray(agents) || agents.length === 0) {
1762
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError("createSquad requires a non-empty `agents` array", {
1763
+ code: "invalid_squad"
1764
+ });
1765
+ }
1766
+ if (options.process !== void 0 && options.process !== "sequential") {
1767
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(
1768
+ `createSquad only supports process "sequential"; for manager\u2192worker delegation use subagents or @theokit/sdk-handoff`,
1769
+ { code: "squad_process_unsupported" }
1770
+ );
1771
+ }
1772
+ return {
1773
+ run: async (input) => {
1774
+ const run = await (await buildPipeline(agents, options.name)).run(input);
1775
+ return { result: run.output, status: run.status, steps: run.stepResults };
1776
+ }
1777
+ };
1778
+ }
1779
+ async function buildPipeline(agents, name) {
1780
+ let builder = chunk4HS6FFGL_cjs.Workflow.create({ name: name ?? "squad" });
1781
+ for (let i = 0; i < agents.length; i++) {
1782
+ const member = agents[i];
1783
+ if (member === void 0) continue;
1784
+ const agent = isBuiltAgent(member) ? member : await materialize(member, i);
1785
+ const opts = i > 0 ? { origin: { kind: "peer", from: `agent-${i - 1}` } } : void 0;
1786
+ builder = builder.then(chunk4HS6FFGL_cjs.agentStep(`agent-${i}`, agent, (prev) => String(prev), opts));
1787
+ }
1788
+ return builder.commit();
1789
+ }
1790
+ var Squad = class {
1791
+ constructor() {
1792
+ }
1793
+ static create(options) {
1794
+ return createSquad(options);
1795
+ }
1796
+ };
1797
+
1798
+ // src/task.ts
1799
+ var Task = class {
1800
+ // D361 — static class with private constructor.
1801
+ constructor() {
1802
+ throw new Error("Task is static; do not instantiate");
1803
+ }
1804
+ /**
1805
+ * Configure the registry. **Must be called before the first `submit`**
1806
+ * (EC-13). Available knobs: pluggable store (D364), concurrency cap
1807
+ * (D369), and retention (D373).
1808
+ */
1809
+ static configure(opts) {
1810
+ chunkKVSAY6NZ_cjs.configure(opts);
1811
+ }
1812
+ /**
1813
+ * Submit a unit of asynchronous work to the registry.
1814
+ *
1815
+ * The `work` function receives `{ signal, emit }` — `signal` is the
1816
+ * AbortSignal honored on cancel; `emit(payload)` produces a
1817
+ * `progress` event observable via `Task.subscribe`.
1818
+ *
1819
+ * Returns a `TaskHandle` in `state: "queued"`. Subsequent state
1820
+ * transitions are observable via `Task.subscribe(handle.id)` OR
1821
+ * polled via `Task.get(handle.id)`.
1822
+ *
1823
+ * **Idempotency (D367):** submitting twice with the same `id` returns
1824
+ * the existing handle without re-invoking work.
1825
+ *
1826
+ * **Grammar (D368):** user-supplied ids must match
1827
+ * `^[a-z0-9][a-z0-9_-]*$` and must not start with reserved prefixes
1828
+ * `wf-` / `b-` / `cron-`. Otherwise `InvalidTaskIdError` is thrown.
1829
+ *
1830
+ * **Pre-aborted signal (EC-4):** if `options.signal` is already
1831
+ * aborted, the task short-circuits to `cancelled` without acquiring
1832
+ * a semaphore slot and without invoking `work`.
1833
+ */
1834
+ static async submit(kind, work, options = {}) {
1835
+ return chunkKVSAY6NZ_cjs.submit({
1836
+ kind,
1837
+ work,
1838
+ ...options.id !== void 0 ? { id: options.id } : {},
1839
+ ...options.meta !== void 0 ? { meta: options.meta } : {},
1840
+ ...options.signal !== void 0 ? { signal: options.signal } : {},
1841
+ ...options.onRunEvent !== void 0 ? { onRunEvent: options.onRunEvent } : {}
1842
+ });
1843
+ }
1844
+ /** Returns matching handles, capped at `filter.limit ?? 100`. */
1845
+ static list(filter = {}) {
1846
+ return chunkKVSAY6NZ_cjs.list(filter);
1847
+ }
1848
+ /** Returns a single handle by id, or `undefined` if unknown / evicted. */
1849
+ static get(id) {
1850
+ return chunkKVSAY6NZ_cjs.get(id);
1851
+ }
1852
+ /**
1853
+ * Idempotent cancel (D365). Returns:
1854
+ * - `{ cancelled: true, alreadyTerminal: false }` — transitioned
1855
+ * queued/running task to `cancelled`.
1856
+ * - `{ cancelled: false, alreadyTerminal: true }` — task already
1857
+ * terminal.
1858
+ * - `{ cancelled: false, alreadyTerminal: false }` — task unknown.
1859
+ *
1860
+ * Never throws.
1861
+ */
1862
+ static cancel(id, reason) {
1863
+ return chunkKVSAY6NZ_cjs.cancel(id, reason);
1864
+ }
1865
+ /**
1866
+ * Subscribe to a task's event stream. The returned `AsyncIterable<TaskEvent>`
1867
+ * starts by replaying buffered events (ring buffer cap 64, D372) and
1868
+ * then yields live events until a terminal event (finished / errored
1869
+ * / cancelled) is emitted, at which point it closes automatically.
1870
+ *
1871
+ * Calling `.return()` on the iterator (or `break` in a `for await`)
1872
+ * cleans up the subscriber callback (EC-10).
1873
+ *
1874
+ * Throws `TaskNotFoundError` if the id is unknown or has been evicted.
1875
+ */
1876
+ static subscribe(id) {
1877
+ return chunkKVSAY6NZ_cjs.subscribe(id);
1878
+ }
1879
+ };
1880
+
1881
+ // src/internal/catalog/fixtures.ts
1882
+ var FIXTURE_TIMESTAMP = "2024-01-01T00:00:00.000Z";
1883
+ var FIXTURE_USER = {
1884
+ apiKeyName: "Contract Test Key",
1885
+ userEmail: "sdk-contract@example.com",
1886
+ createdAt: FIXTURE_TIMESTAMP
1887
+ };
1888
+ var FIXTURE_MODELS = [
1889
+ {
1890
+ id: chunkD3CCY3A2_cjs.DEFAULT_AGENTIC_MODEL_ID,
1891
+ name: "Gemini 2.0 Flash",
1892
+ displayName: "Gemini 2.0 Flash",
1893
+ parameters: [
1894
+ {
1895
+ id: "thinking",
1896
+ displayName: "Thinking",
1897
+ values: [
1898
+ { value: "low", displayName: "Low" },
1899
+ { value: "high", displayName: "High" }
1900
+ ]
1901
+ }
1902
+ ],
1903
+ variants: [
1904
+ {
1905
+ displayName: "High thinking",
1906
+ params: [{ id: "thinking", value: "high" }],
1907
+ isDefault: false
1908
+ }
1909
+ ]
1910
+ }
1911
+ ];
1912
+ var FIXTURE_REPOSITORIES = [
1913
+ { url: "https://github.com/usetheo/example" }
1914
+ ];
1915
+ var GENERIC_SETUP_SCHEMA = {
1916
+ type: "object",
1917
+ description: "Configuration values for this provider.",
1918
+ required: ["credential"],
1919
+ properties: { credential: { type: "string" } }
1920
+ };
1921
+ var FIXTURE_PROVIDERS = [
1922
+ {
1923
+ name: "anthropic",
1924
+ displayName: "Anthropic",
1925
+ capabilities: ["chat"],
1926
+ isAvailable: true,
1927
+ setupSchema: GENERIC_SETUP_SCHEMA
1928
+ },
1929
+ {
1930
+ name: "openai",
1931
+ displayName: "OpenAI",
1932
+ capabilities: ["chat", "embedding", "image"],
1933
+ isAvailable: false,
1934
+ setupSchema: GENERIC_SETUP_SCHEMA
1935
+ },
1936
+ {
1937
+ name: "openrouter",
1938
+ displayName: "OpenRouter",
1939
+ capabilities: ["chat"],
1940
+ isAvailable: true,
1941
+ setupSchema: GENERIC_SETUP_SCHEMA
1942
+ },
1943
+ {
1944
+ name: "nous",
1945
+ displayName: "Nous Research",
1946
+ capabilities: ["chat"],
1947
+ isAvailable: true,
1948
+ setupSchema: GENERIC_SETUP_SCHEMA
1949
+ },
1950
+ {
1951
+ name: "fixture-search",
1952
+ displayName: "Fixture Search",
1953
+ capabilities: ["web_search"],
1954
+ isAvailable: true,
1955
+ setupSchema: GENERIC_SETUP_SCHEMA
1956
+ }
1957
+ ];
1958
+
1959
+ // src/internal/catalog/local-models.ts
1960
+ async function listLocalModelsViaOpenAiCompat(baseUrl) {
1961
+ const url = `${baseUrl}/v1/models`;
1962
+ let response;
1963
+ try {
1964
+ response = await fetch(url, { method: "GET" });
1965
+ } catch (fetchErr) {
1966
+ const mapped = chunk2HPNT6HH_cjs.mapOllamaTransportError({
1967
+ providerId: "ollama",
1968
+ cause: fetchErr,
1969
+ endpoint: "/v1/models"
1970
+ });
1971
+ if (mapped !== void 0) throw mapped;
1972
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(
1973
+ `Failed to reach local provider at ${baseUrl}: ${fetchErr.message}`,
1974
+ { code: "local_provider_unreachable" }
1975
+ );
1976
+ }
1977
+ if (!response.ok) {
1978
+ const body = await chunk2HPNT6HH_cjs.readErrorResponseBody(response);
1979
+ const mapped = chunk2HPNT6HH_cjs.mapOllamaHttpError({
1980
+ providerId: "ollama",
1981
+ status: response.status,
1982
+ body,
1983
+ headers: response.headers,
1984
+ endpoint: "/v1/models"
1985
+ });
1986
+ if (mapped !== void 0) throw mapped;
1987
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(
1988
+ `Local provider at ${baseUrl} returned HTTP ${response.status} on /v1/models`,
1989
+ { code: "local_provider_http_error" }
1990
+ );
1991
+ }
1992
+ let parsed;
1993
+ try {
1994
+ parsed = await response.json();
1995
+ } catch {
1996
+ return [];
1997
+ }
1998
+ const data = parsed.data ?? [];
1999
+ return data.filter(
2000
+ (entry) => typeof entry?.id === "string" && entry.id.length > 0
2001
+ ).map((entry) => ({
2002
+ id: entry.id,
2003
+ displayName: entry.id,
2004
+ name: entry.id
2005
+ }));
2006
+ }
2007
+
2008
+ // src/theokit.ts
2009
+ var Theokit = class {
2010
+ constructor() {
2011
+ }
2012
+ /**
2013
+ * Return the user behind the current API key.
2014
+ *
2015
+ * @public
2016
+ */
2017
+ static me(options = {}) {
2018
+ return executeCatalogRequest({
2019
+ apiKey: options.apiKey,
2020
+ fixture: FIXTURE_USER,
2021
+ path: "/v1/me"
2022
+ });
2023
+ }
2024
+ /**
2025
+ * Model catalog reads.
2026
+ *
2027
+ * @public
2028
+ */
2029
+ static models = {
2030
+ list: async (options = {}) => {
2031
+ if (options.provider !== void 0) {
2032
+ const localModels = await maybeListLocalModels(options.provider);
2033
+ if (localModels !== void 0) return localModels;
2034
+ }
2035
+ return executeCatalogRequest({
2036
+ apiKey: options.apiKey,
2037
+ fixture: FIXTURE_MODELS,
2038
+ path: "/v1/models"
2039
+ });
2040
+ },
2041
+ capabilities: (providerOrModelId) => {
2042
+ chunkQC55H6RJ_cjs.registerBuiltins();
2043
+ const providerId = providerOrModelId.includes("/") ? providerOrModelId.split("/")[0] ?? providerOrModelId : providerOrModelId;
2044
+ return chunkQC55H6RJ_cjs.getCatalogCapabilities(providerId);
2045
+ }
2046
+ };
2047
+ /**
2048
+ * Connected GitHub repositories for the calling user's team. Cloud only.
2049
+ *
2050
+ * @public
2051
+ */
2052
+ static repositories = {
2053
+ list: (options = {}) => executeCatalogRequest({
2054
+ apiKey: options.apiKey,
2055
+ fixture: FIXTURE_REPOSITORIES,
2056
+ path: "/v1/repositories"
2057
+ })
2058
+ };
2059
+ /**
2060
+ * Provider catalog. Lists every provider known to the platform, including
2061
+ * plugin-registered ones, with capability and availability metadata.
2062
+ *
2063
+ * @public
2064
+ */
2065
+ static providers = {
2066
+ list: (options = {}) => executeCatalogRequest({
2067
+ apiKey: options.apiKey,
2068
+ fixture: FIXTURE_PROVIDERS,
2069
+ path: "/v1/providers"
2070
+ })
2071
+ };
2072
+ /**
2073
+ * Local introspection of bundled SDK assets (ADR D201). Unlike the
2074
+ * cloud-catalog `providers.list()` (which hits the TheoCloud HTTP API),
2075
+ * `inspect.*` reads the SDK's own bundled registries — useful for
2076
+ * tooling (e.g. `@theokit/cli`'s `theokit inspect`) that needs to know
2077
+ * what's available WITHOUT a network round-trip.
2078
+ *
2079
+ * @public
2080
+ */
2081
+ static inspect = {
2082
+ builtinProviders: () => {
2083
+ chunkQC55H6RJ_cjs.registerBuiltins();
2084
+ return chunkQC55H6RJ_cjs.listProviders().map((p) => ({
2085
+ name: p.name,
2086
+ apiMode: p.apiMode,
2087
+ authType: p.authType,
2088
+ baseUrl: p.baseUrl,
2089
+ ...p.aliases !== void 0 ? { aliases: p.aliases } : {},
2090
+ envVars: p.envVars
2091
+ }));
2092
+ },
2093
+ embeddingAdapters: () => Object.entries(chunkD3CCY3A2_cjs.MEMORY_EMBEDDING_ADAPTERS).map(([id, adapter]) => ({
2094
+ id,
2095
+ transport: adapter.transport,
2096
+ defaultModel: adapter.defaultModel
2097
+ }))
2098
+ };
2099
+ // NOTE: `Theokit.subscribe` is exported from `@theokit/sdk/subscription`
2100
+ // sub-path entry instead of the main `Theokit` static class to avoid
2101
+ // pulling the subscription module into the main `index.ts` DTS bundle
2102
+ // (which trips on the pre-existing `types/agent.ts ↔ fork-agent.ts` cycle
2103
+ // — same pattern as `path-safety` per ADR D425/D429 + see tsup.config.ts
2104
+ // header comment). Consumers import via:
2105
+ // `import { subscribe } from "@theokit/sdk/subscription"`
2106
+ // The function shape mirrors a hypothetical `Theokit.subscribe(name, input, opts)`
2107
+ // and may be promoted onto Theokit once the agent.ts cycle is broken.
2108
+ };
2109
+ async function maybeListLocalModels(providerName) {
2110
+ chunkQC55H6RJ_cjs.registerBuiltins();
2111
+ await chunk2HPNT6HH_cjs.discoverProviderPlugins();
2112
+ const profile = chunkQC55H6RJ_cjs.getProviderProfile(providerName);
2113
+ if (profile === void 0) return void 0;
2114
+ if (profile.authType !== "none") return void 0;
2115
+ const baseUrl = resolveLocalProviderBaseUrl(profile.name, profile.baseUrl);
2116
+ return listLocalModelsViaOpenAiCompat(baseUrl);
2117
+ }
2118
+ function resolveLocalProviderBaseUrl(providerName, fallback) {
2119
+ if (providerName === "ollama" && process.env.OLLAMA_HOST !== void 0) {
2120
+ return process.env.OLLAMA_HOST;
2121
+ }
2122
+ return fallback;
2123
+ }
2124
+ async function executeCatalogRequest(request) {
2125
+ const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(request.apiKey);
2126
+ if (apiKey === void 0) {
2127
+ throw new chunkJ7J7J2GN_cjs.AuthenticationError("Missing API key", { code: "missing_api_key" });
2128
+ }
2129
+ if (chunk2HPNT6HH_cjs.shouldUseFixtureMode(apiKey)) {
2130
+ return request.fixture;
2131
+ }
2132
+ if (!chunk2HPNT6HH_cjs.isFixtureApiKey(apiKey) && process.env.THEOKIT_API_BASE_URL === void 0) {
2133
+ throw new chunkJ7J7J2GN_cjs.AuthenticationError("Invalid API key", { code: "authentication_error" });
2134
+ }
2135
+ return chunk2HPNT6HH_cjs.httpRequest(request.path, { apiKey });
2136
+ }
2137
+
2138
+ // src/tool-blast-radius.ts
2139
+ var DECLARED = /* @__PURE__ */ Symbol.for("@theokit/sdk.blastRadius");
2140
+ function withBlastRadius(tool, action) {
2141
+ return Object.defineProperty(tool, DECLARED, {
2142
+ value: action,
2143
+ // `enumerable: false` is defensive and NOT load-bearing — checked, not assumed. Flipping it to
2144
+ // true leaves every case green, because the symbol key already excludes this from `Object.keys`
2145
+ // and `JSON.stringify`. It stays because a future string-keyed variant would need it, and the
2146
+ // next reader should not have to discover that the flag has no test behind it.
2147
+ enumerable: false,
2148
+ configurable: true
2149
+ });
2150
+ }
2151
+ function describeAction(tool) {
2152
+ return tool[DECLARED];
2153
+ }
2154
+
2155
+ // src/trajectory-helpers.ts
2156
+ function toShareGptTrajectory(result, options) {
2157
+ if (!result.ok) return null;
2158
+ const conversations = buildConversations(result, options?.messages);
2159
+ const trajectory = {
2160
+ conversations,
2161
+ metadata: {
2162
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2163
+ durationMs: result.durationMs,
2164
+ promptIndex: result.index,
2165
+ ...options?.model !== void 0 ? { model: options.model } : {}
2166
+ },
2167
+ completed: true
2168
+ };
2169
+ const usage = extractUsage(result.result);
2170
+ if (usage !== void 0) trajectory.usage = usage;
2171
+ return trajectory;
2172
+ }
2173
+ function buildConversations(result, messages) {
2174
+ const conversations = [{ from: "human", value: result.prompt }];
2175
+ if (Array.isArray(messages) && messages.length > 0) {
2176
+ for (const m of messages) {
2177
+ for (const entry of mapSdkMessage(m)) conversations.push(entry);
2178
+ }
2179
+ return conversations;
2180
+ }
2181
+ const finalText = typeof result.result.result === "string" ? result.result.result : "";
2182
+ conversations.push({ from: "gpt", value: finalText });
2183
+ return conversations;
2184
+ }
2185
+ function extractUsage(runResult) {
2186
+ const usage = runResult?.usage;
2187
+ if (usage === void 0) return void 0;
2188
+ if (typeof usage.inputTokens !== "number" || typeof usage.outputTokens !== "number") {
2189
+ return void 0;
2190
+ }
2191
+ return { inputTokens: usage.inputTokens, outputTokens: usage.outputTokens };
2192
+ }
2193
+ function mapSdkMessage(m) {
2194
+ if (m === null || typeof m !== "object") return [];
2195
+ switch (m.type) {
2196
+ case "assistant":
2197
+ return mapAssistant(m);
2198
+ case "tool_call":
2199
+ return mapToolCall(m);
2200
+ case "thinking":
2201
+ case "system":
2202
+ case "user":
2203
+ case "status":
2204
+ case "task":
2205
+ case "request":
2206
+ case "object_delta":
2207
+ return [];
2208
+ default: {
2209
+ return [];
2210
+ }
2211
+ }
2212
+ }
2213
+ function mapAssistant(m) {
2214
+ const content = m.message?.content;
2215
+ if (!Array.isArray(content)) return [];
2216
+ const textParts = [];
2217
+ const toolCalls = [];
2218
+ for (const block of content) {
2219
+ appendBlock(block, textParts, toolCalls);
2220
+ }
2221
+ const entry = { from: "gpt", value: textParts.join("") };
2222
+ if (toolCalls.length > 0) entry.tool_calls = toolCalls;
2223
+ return [entry];
2224
+ }
2225
+ function appendBlock(block, textParts, toolCalls) {
2226
+ if (block === null || typeof block !== "object") return;
2227
+ const text = block;
2228
+ if (text.type === "text" && typeof text.text === "string") {
2229
+ textParts.push(text.text);
2230
+ return;
2231
+ }
2232
+ const tu = block;
2233
+ if (tu.type !== "tool_use") return;
2234
+ const args = tu.input !== null && typeof tu.input === "object" ? tu.input : {};
2235
+ toolCalls.push({ name: tu.name, arguments: args });
2236
+ }
2237
+ function mapToolCall(m) {
2238
+ if (m.status !== "completed") return [];
2239
+ const value = typeof m.result === "string" ? m.result : m.result === void 0 ? "" : safeStringify(m.result);
2240
+ return [{ from: "tool", value }];
2241
+ }
2242
+ function safeStringify(v) {
2243
+ try {
2244
+ return JSON.stringify(v);
2245
+ } catch {
2246
+ return String(v);
2247
+ }
2248
+ }
2249
+
2250
+ // src/trust-posture.ts
2251
+ function resolveTrustPosture(input) {
2252
+ const source = input.envOverride === true ? "env" : input.isTrusted() ? "store" : "default";
2253
+ const level = source === "default" ? "untrusted" : "trusted";
2254
+ const granted = level === "trusted";
2255
+ const allows = Object.fromEntries(input.capabilities.map((key) => [key, granted]));
2256
+ return { level, source, allows };
2257
+ }
2258
+
2259
+ // src/wiring-record.ts
2260
+ var UngatedCapabilityError = class extends chunkJ7J7J2GN_cjs.TheokitAgentError {
2261
+ name = "UngatedCapabilityError";
2262
+ };
2263
+ function recordWiring(input) {
2264
+ const record = {};
2265
+ for (const [capability, requested] of Object.entries(input.requested)) {
2266
+ const allowed = input.posture.allows[capability];
2267
+ if (allowed === void 0) {
2268
+ throw new UngatedCapabilityError(
2269
+ `capability \`${capability}\` was recorded as wired but the posture does not gate it; gated capabilities are: ${Object.keys(input.posture.allows).join(", ") || "(none)"}`
2270
+ );
2271
+ }
2272
+ record[capability] = {
2273
+ // Copied, not aliased. See the @returns note.
2274
+ active: allowed ? [...requested] : [],
2275
+ requested: [...requested],
2276
+ suppressedByTrust: !allowed && requested.length > 0
2277
+ };
2278
+ }
2279
+ return record;
2280
+ }
2281
+
2282
+ Object.defineProperty(exports, "StreamObjectError", {
2283
+ enumerable: true,
2284
+ get: function () { return chunkTFG5IBZS_cjs.StreamObjectError; }
2285
+ });
2286
+ Object.defineProperty(exports, "GOAL_CONTINUATION_MARKER", {
2287
+ enumerable: true,
2288
+ get: function () { return chunkOBA6YK2R_cjs.GOAL_CONTINUATION_MARKER; }
2289
+ });
2290
+ Object.defineProperty(exports, "JudgeCredentialError", {
2291
+ enumerable: true,
2292
+ get: function () { return chunkQDM3OHUT_cjs.JudgeCredentialError; }
2293
+ });
2294
+ Object.defineProperty(exports, "GenerateObjectError", {
2295
+ enumerable: true,
2296
+ get: function () { return chunkQWD4RDZ3_cjs.GenerateObjectError; }
2297
+ });
2298
+ Object.defineProperty(exports, "Workflow", {
2299
+ enumerable: true,
2300
+ get: function () { return chunk4HS6FFGL_cjs.Workflow; }
2301
+ });
2302
+ Object.defineProperty(exports, "agentStep", {
2303
+ enumerable: true,
2304
+ get: function () { return chunk4HS6FFGL_cjs.agentStep; }
2305
+ });
2306
+ Object.defineProperty(exports, "fn", {
2307
+ enumerable: true,
2308
+ get: function () { return chunk4HS6FFGL_cjs.fn; }
2309
+ });
2310
+ Object.defineProperty(exports, "Cron", {
2311
+ enumerable: true,
2312
+ get: function () { return chunk67SBTGMA_cjs.Cron; }
2313
+ });
2314
+ Object.defineProperty(exports, "Agent", {
2315
+ enumerable: true,
2316
+ get: function () { return chunkD3CCY3A2_cjs.Agent; }
2317
+ });
2318
+ Object.defineProperty(exports, "AgentBuilder", {
2319
+ enumerable: true,
2320
+ get: function () { return chunkD3CCY3A2_cjs.AgentBuilder; }
2321
+ });
2322
+ Object.defineProperty(exports, "Tool", {
2323
+ enumerable: true,
2324
+ get: function () { return chunkD3CCY3A2_cjs.Tool; }
2325
+ });
2326
+ Object.defineProperty(exports, "ToolError", {
2327
+ enumerable: true,
2328
+ get: function () { return chunkD3CCY3A2_cjs.ToolError; }
2329
+ });
2330
+ Object.defineProperty(exports, "UsageAccumulator", {
2331
+ enumerable: true,
2332
+ get: function () { return chunkD3CCY3A2_cjs.UsageAccumulator; }
2333
+ });
2334
+ Object.defineProperty(exports, "computeCost", {
2335
+ enumerable: true,
2336
+ get: function () { return chunkD3CCY3A2_cjs.computeCost; }
2337
+ });
2338
+ Object.defineProperty(exports, "getPricingEntry", {
2339
+ enumerable: true,
2340
+ get: function () { return chunkD3CCY3A2_cjs.getPricingEntry; }
2341
+ });
2342
+ Object.defineProperty(exports, "emitRunEvent", {
2343
+ enumerable: true,
2344
+ get: function () { return chunkKVSAY6NZ_cjs.emitRunEvent; }
2345
+ });
2346
+ Object.defineProperty(exports, "withCwdMutex", {
2347
+ enumerable: true,
2348
+ get: function () { return chunkZF2LDKQQ_cjs.withCwdMutex; }
2349
+ });
2350
+ Object.defineProperty(exports, "TASK_RESERVED_PREFIXES", {
2351
+ enumerable: true,
2352
+ get: function () { return chunkHCT4HPCL_cjs.TASK_RESERVED_PREFIXES; }
2353
+ });
2354
+ Object.defineProperty(exports, "isValidTaskId", {
2355
+ enumerable: true,
2356
+ get: function () { return chunkHCT4HPCL_cjs.isValidTaskId; }
2357
+ });
2358
+ Object.defineProperty(exports, "estimateTokens", {
2359
+ enumerable: true,
2360
+ get: function () { return chunkATT276RD_cjs.estimateTokens; }
2361
+ });
2362
+ Object.defineProperty(exports, "AgentDisposedError", {
2363
+ enumerable: true,
2364
+ get: function () { return chunkJ7J7J2GN_cjs.AgentDisposedError; }
2365
+ });
2366
+ Object.defineProperty(exports, "AgentRunError", {
2367
+ enumerable: true,
2368
+ get: function () { return chunkJ7J7J2GN_cjs.AgentRunError; }
2369
+ });
2370
+ Object.defineProperty(exports, "AuthenticationError", {
2371
+ enumerable: true,
2372
+ get: function () { return chunkJ7J7J2GN_cjs.AuthenticationError; }
2373
+ });
2374
+ Object.defineProperty(exports, "BudgetExceededError", {
2375
+ enumerable: true,
2376
+ get: function () { return chunkJ7J7J2GN_cjs.BudgetExceededError; }
2377
+ });
2378
+ Object.defineProperty(exports, "ConfigurationError", {
2379
+ enumerable: true,
2380
+ get: function () { return chunkJ7J7J2GN_cjs.ConfigurationError; }
2381
+ });
2382
+ Object.defineProperty(exports, "IntegrationNotConnectedError", {
2383
+ enumerable: true,
2384
+ get: function () { return chunkJ7J7J2GN_cjs.IntegrationNotConnectedError; }
2385
+ });
2386
+ Object.defineProperty(exports, "InvalidTaskIdError", {
2387
+ enumerable: true,
2388
+ get: function () { return chunkJ7J7J2GN_cjs.InvalidTaskIdError; }
2389
+ });
2390
+ Object.defineProperty(exports, "MemoryAdapterError", {
2391
+ enumerable: true,
2392
+ get: function () { return chunkJ7J7J2GN_cjs.MemoryAdapterError; }
2393
+ });
2394
+ Object.defineProperty(exports, "NetworkError", {
2395
+ enumerable: true,
2396
+ get: function () { return chunkJ7J7J2GN_cjs.NetworkError; }
2397
+ });
2398
+ Object.defineProperty(exports, "RateLimitError", {
2399
+ enumerable: true,
2400
+ get: function () { return chunkJ7J7J2GN_cjs.RateLimitError; }
2401
+ });
2402
+ Object.defineProperty(exports, "TaskNotFoundError", {
2403
+ enumerable: true,
2404
+ get: function () { return chunkJ7J7J2GN_cjs.TaskNotFoundError; }
2405
+ });
2406
+ Object.defineProperty(exports, "TheokitAgentError", {
2407
+ enumerable: true,
2408
+ get: function () { return chunkJ7J7J2GN_cjs.TheokitAgentError; }
2409
+ });
2410
+ Object.defineProperty(exports, "UnknownAgentError", {
2411
+ enumerable: true,
2412
+ get: function () { return chunkJ7J7J2GN_cjs.UnknownAgentError; }
2413
+ });
2414
+ Object.defineProperty(exports, "UnsupportedBudgetOperationError", {
2415
+ enumerable: true,
2416
+ get: function () { return chunkJ7J7J2GN_cjs.UnsupportedBudgetOperationError; }
2417
+ });
2418
+ Object.defineProperty(exports, "UnsupportedRunOperationError", {
2419
+ enumerable: true,
2420
+ get: function () { return chunkJ7J7J2GN_cjs.UnsupportedRunOperationError; }
2421
+ });
2422
+ Object.defineProperty(exports, "UnsupportedTaskOperationError", {
2423
+ enumerable: true,
2424
+ get: function () { return chunkJ7J7J2GN_cjs.UnsupportedTaskOperationError; }
2425
+ });
2426
+ Object.defineProperty(exports, "isTransientError", {
2427
+ enumerable: true,
2428
+ get: function () { return chunkJ7J7J2GN_cjs.isTransientError; }
2429
+ });
2430
+ Object.defineProperty(exports, "setDiagnosticsSink", {
2431
+ enumerable: true,
2432
+ get: function () { return chunk6LHQPOMI_cjs.setDiagnosticsSink; }
2433
+ });
2434
+ exports.AgentFactory = AgentFactory;
2435
+ exports.Budget = Budget;
2436
+ exports.EventBus = EventBus;
2437
+ exports.JobQueue = JobQueue;
2438
+ exports.LayerOrderError = LayerOrderError;
2439
+ exports.LiveSessionError = LiveSessionError;
2440
+ exports.Memory = Memory;
2441
+ exports.NoopMemoryProvider = NoopMemoryProvider;
2442
+ exports.PermissionEngine = PermissionEngine;
2443
+ exports.PermissionPlugin = PermissionPlugin;
2444
+ exports.Plugin = Plugin;
2445
+ exports.Provider = Provider;
2446
+ exports.RetentionPolicyError = RetentionPolicyError;
2447
+ exports.SOVEREIGN_ENV_KEYS = SOVEREIGN_ENV_KEYS;
2448
+ exports.Security = Security;
2449
+ exports.Skill = Skill;
2450
+ exports.SkillReadTool = SkillReadTool;
2451
+ exports.Squad = Squad;
2452
+ exports.Task = Task;
2453
+ exports.Theokit = Theokit;
2454
+ exports.TokenLimiter = TokenLimiter;
2455
+ exports.UngatedCapabilityError = UngatedCapabilityError;
2456
+ exports.UnicodeNormalizer = UnicodeNormalizer;
2457
+ exports.applyMode = applyMode;
2458
+ exports.applySecurityFloor = applySecurityFloor;
2459
+ exports.auditEnvReachability = auditEnvReachability;
2460
+ exports.chargeAndCheckThresholds = chargeAndCheckThresholds;
2461
+ exports.createCounterBudgetTracker = createCounterBudgetTracker;
2462
+ exports.decideApproval = decideApproval;
2463
+ exports.describeAction = describeAction;
2464
+ exports.describeCredential = describeCredential;
2465
+ exports.evaluateBlastRadius = evaluateBlastRadius;
2466
+ exports.extractRawId = extractRawId;
2467
+ exports.foldLayers = foldLayers;
2468
+ exports.guardSessionDestruction = guardSessionDestruction;
2469
+ exports.inferApiMode = inferApiMode;
2470
+ exports.loadProjectEnv = loadProjectEnv;
2471
+ exports.migrateSqliteToLance = migrateSqliteToLance2;
2472
+ exports.mkMemoryId = mkMemoryId;
2473
+ exports.normalizeSchema = normalizeSchema;
2474
+ exports.normalizeUsage = normalizeUsage;
2475
+ exports.planReaping = planReaping;
2476
+ exports.preflightCheck = preflightCheck;
2477
+ exports.readSessionMessages = readSessionMessages2;
2478
+ exports.recordWiring = recordWiring;
2479
+ exports.resolveTrustPosture = resolveTrustPosture;
2480
+ exports.runGoalLoop = runGoalLoop;
2481
+ exports.scopedConversationId = scopedConversationId;
2482
+ exports.sessionScopePrefix = sessionScopePrefix;
2483
+ exports.toShareGptTrajectory = toShareGptTrajectory;
2484
+ exports.verifyLayerOrdering = verifyLayerOrdering;
2485
+ exports.withBlastRadius = withBlastRadius;
2486
+ //# sourceMappingURL=index.cjs.map
2487
+ //# sourceMappingURL=index.cjs.map