@theokit/sdk 4.23.0 → 4.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (374) hide show
  1. package/dist/a2a/index.cjs +10 -171
  2. package/dist/a2a/index.cjs.map +1 -1
  3. package/dist/a2a/index.js +3 -170
  4. package/dist/a2a/index.js.map +1 -1
  5. package/dist/agent-factory-registry-UU46BUMU.cjs +16 -0
  6. package/dist/agent-factory-registry-UU46BUMU.cjs.map +1 -0
  7. package/dist/agent-factory-registry-ZVTABLEY.js +3 -0
  8. package/dist/agent-factory-registry-ZVTABLEY.js.map +1 -0
  9. package/dist/auth/index.cjs +63 -343
  10. package/dist/auth/index.cjs.map +1 -1
  11. package/dist/auth/index.js +6 -318
  12. package/dist/auth/index.js.map +1 -1
  13. package/dist/batch-2FSD2UNL.cjs +244 -0
  14. package/dist/batch-2FSD2UNL.cjs.map +1 -0
  15. package/dist/batch-MR2HKYMS.js +241 -0
  16. package/dist/batch-MR2HKYMS.js.map +1 -0
  17. package/dist/chunk-2HRYBRD7.cjs +31 -0
  18. package/dist/chunk-2HRYBRD7.cjs.map +1 -0
  19. package/dist/chunk-2MF3IE2D.cjs +2863 -0
  20. package/dist/chunk-2MF3IE2D.cjs.map +1 -0
  21. package/dist/chunk-2ONFGMBV.js +6 -0
  22. package/dist/chunk-2ONFGMBV.js.map +1 -0
  23. package/dist/chunk-2SFBB54R.js +23 -0
  24. package/dist/chunk-2SFBB54R.js.map +1 -0
  25. package/dist/chunk-2XLKLVVR.js +18 -0
  26. package/dist/chunk-2XLKLVVR.js.map +1 -0
  27. package/dist/chunk-4HKMQEPX.js +458 -0
  28. package/dist/chunk-4HKMQEPX.js.map +1 -0
  29. package/dist/chunk-4SXHEZIV.cjs +240 -0
  30. package/dist/chunk-4SXHEZIV.cjs.map +1 -0
  31. package/dist/chunk-4VPXM6UU.js +10 -0
  32. package/dist/chunk-4VPXM6UU.js.map +1 -0
  33. package/dist/chunk-4WL52CXU.cjs +148 -0
  34. package/dist/chunk-4WL52CXU.cjs.map +1 -0
  35. package/dist/chunk-5NBUH3NO.js +39 -0
  36. package/dist/chunk-5NBUH3NO.js.map +1 -0
  37. package/dist/chunk-5PZMMF4H.js +43 -0
  38. package/dist/chunk-5PZMMF4H.js.map +1 -0
  39. package/dist/chunk-6CLRANZA.js +289 -0
  40. package/dist/chunk-6CLRANZA.js.map +1 -0
  41. package/dist/chunk-6JSIEDKL.cjs +121 -0
  42. package/dist/chunk-6JSIEDKL.cjs.map +1 -0
  43. package/dist/chunk-6M4ODB2V.cjs +145 -0
  44. package/dist/chunk-6M4ODB2V.cjs.map +1 -0
  45. package/dist/chunk-6X6ID4MO.js +20 -0
  46. package/dist/chunk-6X6ID4MO.js.map +1 -0
  47. package/dist/chunk-77FOZCOT.js +165 -0
  48. package/dist/chunk-77FOZCOT.js.map +1 -0
  49. package/dist/chunk-7AD3ZTZL.js +25 -0
  50. package/dist/chunk-7AD3ZTZL.js.map +1 -0
  51. package/dist/chunk-7GFX45DD.js +57 -0
  52. package/dist/chunk-7GFX45DD.js.map +1 -0
  53. package/dist/chunk-7RMWOMDB.cjs +460 -0
  54. package/dist/chunk-7RMWOMDB.cjs.map +1 -0
  55. package/dist/chunk-7S7KKUO6.cjs +45 -0
  56. package/dist/chunk-7S7KKUO6.cjs.map +1 -0
  57. package/dist/chunk-7W7ZWMLQ.js +99 -0
  58. package/dist/chunk-7W7ZWMLQ.js.map +1 -0
  59. package/dist/chunk-A44COQJJ.cjs +353 -0
  60. package/dist/chunk-A44COQJJ.cjs.map +1 -0
  61. package/dist/chunk-AKSBP7OO.js +185 -0
  62. package/dist/chunk-AKSBP7OO.js.map +1 -0
  63. package/dist/chunk-ANIZEWTU.cjs +196 -0
  64. package/dist/chunk-ANIZEWTU.cjs.map +1 -0
  65. package/dist/chunk-BEURCLDV.cjs +139 -0
  66. package/dist/chunk-BEURCLDV.cjs.map +1 -0
  67. package/dist/chunk-BFWPZMG7.js +379 -0
  68. package/dist/chunk-BFWPZMG7.js.map +1 -0
  69. package/dist/chunk-BUUUWQMB.cjs +34 -0
  70. package/dist/chunk-BUUUWQMB.cjs.map +1 -0
  71. package/dist/chunk-BV2MWEMV.cjs +26 -0
  72. package/dist/chunk-BV2MWEMV.cjs.map +1 -0
  73. package/dist/chunk-BWT67BI4.cjs +268 -0
  74. package/dist/chunk-BWT67BI4.cjs.map +1 -0
  75. package/dist/chunk-BXV2QUIC.js +191 -0
  76. package/dist/chunk-BXV2QUIC.js.map +1 -0
  77. package/dist/chunk-C6Y6CWYD.cjs +44 -0
  78. package/dist/chunk-C6Y6CWYD.cjs.map +1 -0
  79. package/dist/chunk-C7PICHRF.cjs +68 -0
  80. package/dist/chunk-C7PICHRF.cjs.map +1 -0
  81. package/dist/chunk-CAH3G4IS.js +13 -0
  82. package/dist/chunk-CAH3G4IS.js.map +1 -0
  83. package/dist/chunk-CJ6YJ2L3.cjs +10590 -0
  84. package/dist/chunk-CJ6YJ2L3.cjs.map +1 -0
  85. package/dist/chunk-D42XHI4O.cjs +565 -0
  86. package/dist/chunk-D42XHI4O.cjs.map +1 -0
  87. package/dist/chunk-DGRZNMTU.js +104 -0
  88. package/dist/chunk-DGRZNMTU.js.map +1 -0
  89. package/dist/chunk-DUK5WMKJ.js +71 -0
  90. package/dist/chunk-DUK5WMKJ.js.map +1 -0
  91. package/dist/chunk-EEZ7CFMM.js +14 -0
  92. package/dist/chunk-EEZ7CFMM.js.map +1 -0
  93. package/dist/chunk-EPYZOCOL.cjs +82 -0
  94. package/dist/chunk-EPYZOCOL.cjs.map +1 -0
  95. package/dist/chunk-EVADEGM7.cjs +168 -0
  96. package/dist/chunk-EVADEGM7.cjs.map +1 -0
  97. package/dist/chunk-F3XVLFLM.js +10573 -0
  98. package/dist/chunk-F3XVLFLM.js.map +1 -0
  99. package/dist/chunk-FD2UT76F.js +3 -0
  100. package/dist/chunk-FD2UT76F.js.map +1 -0
  101. package/dist/chunk-FV3YEMQ7.js +179 -0
  102. package/dist/chunk-FV3YEMQ7.js.map +1 -0
  103. package/dist/chunk-G2F67XUR.cjs +184 -0
  104. package/dist/chunk-G2F67XUR.cjs.map +1 -0
  105. package/dist/chunk-G6GO6BXD.js +994 -0
  106. package/dist/chunk-G6GO6BXD.js.map +1 -0
  107. package/dist/chunk-GIW4L6HY.cjs +27 -0
  108. package/dist/chunk-GIW4L6HY.cjs.map +1 -0
  109. package/dist/chunk-GJAGKFTR.js +74 -0
  110. package/dist/chunk-GJAGKFTR.js.map +1 -0
  111. package/dist/chunk-HFPGOTVF.cjs +324 -0
  112. package/dist/chunk-HFPGOTVF.cjs.map +1 -0
  113. package/dist/chunk-HRA3CPGG.js +486 -0
  114. package/dist/chunk-HRA3CPGG.js.map +1 -0
  115. package/dist/chunk-HZQEDNF6.js +66 -0
  116. package/dist/chunk-HZQEDNF6.js.map +1 -0
  117. package/dist/chunk-IT3PWBW4.cjs +19 -0
  118. package/dist/chunk-IT3PWBW4.cjs.map +1 -0
  119. package/dist/chunk-JD74LN7R.cjs +171 -0
  120. package/dist/chunk-JD74LN7R.cjs.map +1 -0
  121. package/dist/chunk-JTFYYKDT.js +135 -0
  122. package/dist/chunk-JTFYYKDT.js.map +1 -0
  123. package/dist/chunk-K2BQQ445.js +30 -0
  124. package/dist/chunk-K2BQQ445.js.map +1 -0
  125. package/dist/chunk-KAP4GJHO.js +546 -0
  126. package/dist/chunk-KAP4GJHO.js.map +1 -0
  127. package/dist/chunk-KIO7QFIV.cjs +223 -0
  128. package/dist/chunk-KIO7QFIV.cjs.map +1 -0
  129. package/dist/chunk-KSKU6JY6.cjs +71 -0
  130. package/dist/chunk-KSKU6JY6.cjs.map +1 -0
  131. package/dist/chunk-LSLPF6OI.cjs +192 -0
  132. package/dist/chunk-LSLPF6OI.cjs.map +1 -0
  133. package/dist/chunk-LU7VALW5.js +312 -0
  134. package/dist/chunk-LU7VALW5.js.map +1 -0
  135. package/dist/chunk-LUSXDZPV.cjs +296 -0
  136. package/dist/chunk-LUSXDZPV.cjs.map +1 -0
  137. package/dist/chunk-M72RJVPC.js +69 -0
  138. package/dist/chunk-M72RJVPC.js.map +1 -0
  139. package/dist/chunk-MQLCZ4HJ.cjs +1010 -0
  140. package/dist/chunk-MQLCZ4HJ.cjs.map +1 -0
  141. package/dist/chunk-MUUQ2WFJ.cjs +4 -0
  142. package/dist/chunk-MUUQ2WFJ.cjs.map +1 -0
  143. package/dist/chunk-MZ5ZRORA.cjs +496 -0
  144. package/dist/chunk-MZ5ZRORA.cjs.map +1 -0
  145. package/dist/chunk-N24XBYNX.cjs +140 -0
  146. package/dist/chunk-N24XBYNX.cjs.map +1 -0
  147. package/dist/chunk-NINIJCHU.cjs +23 -0
  148. package/dist/chunk-NINIJCHU.cjs.map +1 -0
  149. package/dist/chunk-NRSH7RJY.js +2841 -0
  150. package/dist/chunk-NRSH7RJY.js.map +1 -0
  151. package/dist/chunk-OIYQBUW4.cjs +111 -0
  152. package/dist/chunk-OIYQBUW4.cjs.map +1 -0
  153. package/dist/chunk-PNVDQL5Y.cjs +15 -0
  154. package/dist/chunk-PNVDQL5Y.cjs.map +1 -0
  155. package/dist/chunk-POQT2OIF.js +214 -0
  156. package/dist/chunk-POQT2OIF.js.map +1 -0
  157. package/dist/chunk-QUTUJ6P6.cjs +76 -0
  158. package/dist/chunk-QUTUJ6P6.cjs.map +1 -0
  159. package/dist/chunk-S2BBRVQX.js +68 -0
  160. package/dist/chunk-S2BBRVQX.js.map +1 -0
  161. package/dist/chunk-S5RCBTSF.js +145 -0
  162. package/dist/chunk-S5RCBTSF.js.map +1 -0
  163. package/dist/chunk-S7OEXQMI.cjs +136 -0
  164. package/dist/chunk-S7OEXQMI.cjs.map +1 -0
  165. package/dist/chunk-SKWVAQAY.js +129 -0
  166. package/dist/chunk-SKWVAQAY.js.map +1 -0
  167. package/dist/chunk-SQLZ7ONU.js +152 -0
  168. package/dist/chunk-SQLZ7ONU.js.map +1 -0
  169. package/dist/chunk-TIZ4TS5V.cjs +72 -0
  170. package/dist/chunk-TIZ4TS5V.cjs.map +1 -0
  171. package/dist/chunk-TQKCU7CL.js +142 -0
  172. package/dist/chunk-TQKCU7CL.js.map +1 -0
  173. package/dist/chunk-U54XCYG3.js +116 -0
  174. package/dist/chunk-U54XCYG3.js.map +1 -0
  175. package/dist/chunk-U6QGZHPN.js +29 -0
  176. package/dist/chunk-U6QGZHPN.js.map +1 -0
  177. package/dist/chunk-UCFONJBG.js +79 -0
  178. package/dist/chunk-UCFONJBG.js.map +1 -0
  179. package/dist/chunk-UJ7IQJAG.js +141 -0
  180. package/dist/chunk-UJ7IQJAG.js.map +1 -0
  181. package/dist/chunk-UVNG67DG.js +253 -0
  182. package/dist/chunk-UVNG67DG.js.map +1 -0
  183. package/dist/chunk-V4XRLPEF.js +25 -0
  184. package/dist/chunk-V4XRLPEF.js.map +1 -0
  185. package/dist/chunk-VJ26EKGJ.cjs +28 -0
  186. package/dist/chunk-VJ26EKGJ.cjs.map +1 -0
  187. package/dist/chunk-VK7MAV65.cjs +90 -0
  188. package/dist/chunk-VK7MAV65.cjs.map +1 -0
  189. package/dist/chunk-VYCKUKPA.cjs +106 -0
  190. package/dist/chunk-VYCKUKPA.cjs.map +1 -0
  191. package/dist/chunk-VYHJZVL5.cjs +29 -0
  192. package/dist/chunk-VYHJZVL5.cjs.map +1 -0
  193. package/dist/chunk-WA3FO4R7.js +155 -0
  194. package/dist/chunk-WA3FO4R7.js.map +1 -0
  195. package/dist/chunk-WJVHMTKB.cjs +12 -0
  196. package/dist/chunk-WJVHMTKB.cjs.map +1 -0
  197. package/dist/chunk-WLKFWQSJ.js +333 -0
  198. package/dist/chunk-WLKFWQSJ.js.map +1 -0
  199. package/dist/chunk-WPZTYOUX.cjs +59 -0
  200. package/dist/chunk-WPZTYOUX.cjs.map +1 -0
  201. package/dist/chunk-X2FR4OIT.js +27 -0
  202. package/dist/chunk-X2FR4OIT.js.map +1 -0
  203. package/dist/chunk-XIG2IE3L.js +134 -0
  204. package/dist/chunk-XIG2IE3L.js.map +1 -0
  205. package/dist/chunk-YLQQX5W2.cjs +20 -0
  206. package/dist/chunk-YLQQX5W2.cjs.map +1 -0
  207. package/dist/chunk-YPEPCZHF.cjs +147 -0
  208. package/dist/chunk-YPEPCZHF.cjs.map +1 -0
  209. package/dist/chunk-YPQF26X7.cjs +8 -0
  210. package/dist/chunk-YPQF26X7.cjs.map +1 -0
  211. package/dist/chunk-YU6KON2I.cjs +160 -0
  212. package/dist/chunk-YU6KON2I.cjs.map +1 -0
  213. package/dist/chunk-Z2OC3UIW.cjs +388 -0
  214. package/dist/chunk-Z2OC3UIW.cjs.map +1 -0
  215. package/dist/chunk-ZZWTY3RX.js +230 -0
  216. package/dist/chunk-ZZWTY3RX.js.map +1 -0
  217. package/dist/compact-session-OO2GD76G.js +17 -0
  218. package/dist/compact-session-OO2GD76G.js.map +1 -0
  219. package/dist/compact-session-OO7NVWPB.cjs +54 -0
  220. package/dist/compact-session-OO7NVWPB.cjs.map +1 -0
  221. package/dist/compaction.cjs +54 -303
  222. package/dist/compaction.cjs.map +1 -1
  223. package/dist/compaction.js +3 -292
  224. package/dist/compaction.js.map +1 -1
  225. package/dist/concurrency.cjs +9 -81
  226. package/dist/concurrency.cjs.map +1 -1
  227. package/dist/concurrency.js +5 -80
  228. package/dist/concurrency.js.map +1 -1
  229. package/dist/context-GWANQLX4.js +5 -0
  230. package/dist/context-GWANQLX4.js.map +1 -0
  231. package/dist/context-KNWVTZSY.cjs +22 -0
  232. package/dist/context-KNWVTZSY.cjs.map +1 -0
  233. package/dist/cron.cjs +44 -20675
  234. package/dist/cron.cjs.map +1 -1
  235. package/dist/cron.js +38 -20675
  236. package/dist/cron.js.map +1 -1
  237. package/dist/errors.cjs +78 -470
  238. package/dist/errors.cjs.map +1 -1
  239. package/dist/errors.js +2 -455
  240. package/dist/errors.js.map +1 -1
  241. package/dist/eval.cjs +72 -20410
  242. package/dist/eval.cjs.map +1 -1
  243. package/dist/eval.js +59 -20401
  244. package/dist/eval.js.map +1 -1
  245. package/dist/executor-ORJS5GV2.js +981 -0
  246. package/dist/executor-ORJS5GV2.js.map +1 -0
  247. package/dist/executor-Y4MKPIUD.cjs +985 -0
  248. package/dist/executor-Y4MKPIUD.cjs.map +1 -0
  249. package/dist/filesystem/index.cjs +7 -112
  250. package/dist/filesystem/index.cjs.map +1 -1
  251. package/dist/filesystem/index.js +4 -109
  252. package/dist/filesystem/index.js.map +1 -1
  253. package/dist/fork-agent-RSV4E3EA.js +61 -0
  254. package/dist/fork-agent-RSV4E3EA.js.map +1 -0
  255. package/dist/fork-agent-Y2IK2RYU.cjs +64 -0
  256. package/dist/fork-agent-Y2IK2RYU.cjs.map +1 -0
  257. package/dist/fs-session-store-KAUQYSGI.cjs +17 -0
  258. package/dist/fs-session-store-KAUQYSGI.cjs.map +1 -0
  259. package/dist/fs-session-store-ZKB5NN37.js +8 -0
  260. package/dist/fs-session-store-ZKB5NN37.js.map +1 -0
  261. package/dist/generate-object-H3RNAM6S.cjs +20 -0
  262. package/dist/generate-object-H3RNAM6S.cjs.map +1 -0
  263. package/dist/generate-object-YJPDV5BS.js +7 -0
  264. package/dist/generate-object-YJPDV5BS.js.map +1 -0
  265. package/dist/index-manager-CB6I7XFQ.cjs +19 -0
  266. package/dist/index-manager-CB6I7XFQ.cjs.map +1 -0
  267. package/dist/index-manager-L27Q3QAC.js +10 -0
  268. package/dist/index-manager-L27Q3QAC.js.map +1 -0
  269. package/dist/index.cjs +371 -22887
  270. package/dist/index.cjs.map +1 -1
  271. package/dist/index.js +92 -22712
  272. package/dist/index.js.map +1 -1
  273. package/dist/inject-session-6MJUSGZP.cjs +27 -0
  274. package/dist/inject-session-6MJUSGZP.cjs.map +1 -0
  275. package/dist/inject-session-KOFHS5K3.js +25 -0
  276. package/dist/inject-session-KOFHS5K3.js.map +1 -0
  277. package/dist/internal/auth/credential-store.d.ts +20 -3
  278. package/dist/internal/persistence/index.cjs +93 -508
  279. package/dist/internal/persistence/index.cjs.map +1 -1
  280. package/dist/internal/persistence/index.js +11 -489
  281. package/dist/internal/persistence/index.js.map +1 -1
  282. package/dist/internal/security/index.cjs +44 -361
  283. package/dist/internal/security/index.cjs.map +1 -1
  284. package/dist/internal/security/index.js +4 -355
  285. package/dist/internal/security/index.js.map +1 -1
  286. package/dist/judge-call-7CF7D334.cjs +95 -0
  287. package/dist/judge-call-7CF7D334.cjs.map +1 -0
  288. package/dist/judge-call-VIMNK5TA.js +92 -0
  289. package/dist/judge-call-VIMNK5TA.js.map +1 -0
  290. package/dist/models.cjs +24 -913
  291. package/dist/models.cjs.map +1 -1
  292. package/dist/models.js +11 -901
  293. package/dist/models.js.map +1 -1
  294. package/dist/oauth-transaction-store-7CKHPQRN.cjs +32 -0
  295. package/dist/oauth-transaction-store-7CKHPQRN.cjs.map +1 -0
  296. package/dist/oauth-transaction-store-W74I6EFD.js +3 -0
  297. package/dist/oauth-transaction-store-W74I6EFD.js.map +1 -0
  298. package/dist/path-safety.cjs +31 -200
  299. package/dist/path-safety.cjs.map +1 -1
  300. package/dist/path-safety.js +3 -197
  301. package/dist/path-safety.js.map +1 -1
  302. package/dist/persistence.cjs +73 -393
  303. package/dist/persistence.cjs.map +1 -1
  304. package/dist/persistence.js +9 -381
  305. package/dist/persistence.js.map +1 -1
  306. package/dist/project.cjs +8 -112
  307. package/dist/project.cjs.map +1 -1
  308. package/dist/project.js +6 -110
  309. package/dist/project.js.map +1 -1
  310. package/dist/registry-34IWWDQQ.js +9 -0
  311. package/dist/registry-34IWWDQQ.js.map +1 -0
  312. package/dist/registry-APYDISL6.cjs +46 -0
  313. package/dist/registry-APYDISL6.cjs.map +1 -0
  314. package/dist/retry.cjs +7 -87
  315. package/dist/retry.cjs.map +1 -1
  316. package/dist/retry.js +3 -90
  317. package/dist/retry.js.map +1 -1
  318. package/dist/run-to-completion-J73I6IY4.cjs +48 -0
  319. package/dist/run-to-completion-J73I6IY4.cjs.map +1 -0
  320. package/dist/run-to-completion-JDPIUKSH.js +3 -0
  321. package/dist/run-to-completion-JDPIUKSH.js.map +1 -0
  322. package/dist/run-until-2PX4QBHZ.js +168 -0
  323. package/dist/run-until-2PX4QBHZ.js.map +1 -0
  324. package/dist/run-until-DB3LVGZS.cjs +171 -0
  325. package/dist/run-until-DB3LVGZS.cjs.map +1 -0
  326. package/dist/sandbox/index.cjs +35 -337
  327. package/dist/sandbox/index.cjs.map +1 -1
  328. package/dist/sandbox/index.js +7 -323
  329. package/dist/sandbox/index.js.map +1 -1
  330. package/dist/sanitize/index.cjs +5 -112
  331. package/dist/sanitize/index.cjs.map +1 -1
  332. package/dist/sanitize/index.js +1 -114
  333. package/dist/sanitize/index.js.map +1 -1
  334. package/dist/server/auth/index.cjs +35 -175
  335. package/dist/server/auth/index.cjs.map +1 -1
  336. package/dist/server/auth/index.js +7 -161
  337. package/dist/server/auth/index.js.map +1 -1
  338. package/dist/server/errors-envelope.cjs +17 -328
  339. package/dist/server/errors-envelope.cjs.map +1 -1
  340. package/dist/server/errors-envelope.js +4 -317
  341. package/dist/server/errors-envelope.js.map +1 -1
  342. package/dist/session-transcript-LPNZR3YS.cjs +46 -0
  343. package/dist/session-transcript-LPNZR3YS.cjs.map +1 -0
  344. package/dist/session-transcript-T7LGJUGW.js +5 -0
  345. package/dist/session-transcript-T7LGJUGW.js.map +1 -0
  346. package/dist/skills.cjs +12 -280
  347. package/dist/skills.cjs.map +1 -1
  348. package/dist/skills.js +4 -282
  349. package/dist/skills.js.map +1 -1
  350. package/dist/stream-object-QEQJJDTI.cjs +20 -0
  351. package/dist/stream-object-QEQJJDTI.cjs.map +1 -0
  352. package/dist/stream-object-WUQSSRY2.js +7 -0
  353. package/dist/stream-object-WUQSSRY2.js.map +1 -0
  354. package/dist/stream-to-completion-DFJ5T3BK.js +30 -0
  355. package/dist/stream-to-completion-DFJ5T3BK.js.map +1 -0
  356. package/dist/stream-to-completion-H2MHISSK.cjs +32 -0
  357. package/dist/stream-to-completion-H2MHISSK.cjs.map +1 -0
  358. package/dist/subagents.cjs +2 -8
  359. package/dist/subagents.cjs.map +1 -1
  360. package/dist/subagents.js +1 -7
  361. package/dist/subagents.js.map +1 -1
  362. package/dist/subscription/index.cjs +4 -17
  363. package/dist/subscription/index.cjs.map +1 -1
  364. package/dist/subscription/index.js +3 -16
  365. package/dist/subscription/index.js.map +1 -1
  366. package/dist/task-store.cjs +16 -258
  367. package/dist/task-store.cjs.map +1 -1
  368. package/dist/task-store.js +4 -259
  369. package/dist/task-store.js.map +1 -1
  370. package/dist/workflow.cjs +71 -2797
  371. package/dist/workflow.cjs.map +1 -1
  372. package/dist/workflow.js +8 -2812
  373. package/dist/workflow.js.map +1 -1
  374. package/package.json +1 -1
package/dist/models.cjs CHANGED
@@ -1,185 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var fs = require('fs');
4
- var path = require('path');
5
- var url = require('url');
6
- var zod = require('zod');
3
+ var chunkKSKU6JY6_cjs = require('./chunk-KSKU6JY6.cjs');
4
+ var chunkVYHJZVL5_cjs = require('./chunk-VYHJZVL5.cjs');
5
+ var chunkD42XHI4O_cjs = require('./chunk-D42XHI4O.cjs');
6
+ require('./chunk-HFPGOTVF.cjs');
7
+ require('./chunk-C6Y6CWYD.cjs');
8
+ require('./chunk-A44COQJJ.cjs');
9
+ require('./chunk-BEURCLDV.cjs');
7
10
  var crypto = require('crypto');
11
+ var fs = require('fs');
8
12
  var os = require('os');
9
-
10
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
- // src/internal/providers/catalog-loader.ts
12
-
13
- // src/internal/global-singleton.ts
14
- function globalSingleton(key, create) {
15
- const g = globalThis;
16
- const sym = Symbol.for(key);
17
- if (g[sym] === void 0) g[sym] = create();
18
- return g[sym];
19
- }
20
- var MODALITIES = ["text", "audio", "image", "video", "pdf"];
21
- var costSchema = zod.z.object({
22
- /** USD per 1M tokens (models.dev convention). */
23
- input: zod.z.number().nonnegative(),
24
- output: zod.z.number().nonnegative(),
25
- cache_read: zod.z.number().nonnegative().optional(),
26
- cache_write: zod.z.number().nonnegative().optional()
27
- }).loose();
28
- var limitSchema = zod.z.object({
29
- context: zod.z.number().positive(),
30
- input: zod.z.number().positive().optional(),
31
- output: zod.z.number().positive().optional()
32
- }).loose();
33
- var modalitiesSchema = zod.z.object({
34
- input: zod.z.array(zod.z.enum(MODALITIES)).optional(),
35
- output: zod.z.array(zod.z.enum(MODALITIES)).optional()
36
- }).loose();
37
- var catalogModelSchema = zod.z.object({
38
- name: zod.z.string().optional(),
39
- release_date: zod.z.string().optional(),
40
- attachment: zod.z.boolean().optional(),
41
- reasoning: zod.z.boolean().optional(),
42
- temperature: zod.z.boolean().optional(),
43
- tool_call: zod.z.boolean().optional(),
44
- /** theokit extension — maps to ModelCapabilities.supportsStructuredOutput. */
45
- structured_output: zod.z.boolean().optional(),
46
- /** theokit extension — maps to ModelCapabilities.supportsCacheControl. */
47
- cache_control: zod.z.boolean().optional(),
48
- cost: costSchema.optional(),
49
- limit: limitSchema.optional(),
50
- modalities: modalitiesSchema.optional(),
51
- status: zod.z.enum(["alpha", "beta", "deprecated"]).optional()
52
- }).loose();
53
-
54
- // src/internal/providers/registry.ts
55
- var REGISTRY = globalSingleton(
56
- "theokit-sdk.providers.registry",
57
- () => /* @__PURE__ */ new Map()
58
- );
59
- var ALIASES = globalSingleton("theokit-sdk.providers.aliases", () => /* @__PURE__ */ new Map());
60
- function registerProvider(profile) {
61
- if (REGISTRY.has(profile.name)) {
62
- process.stderr.write(`[theokit-sdk] Provider "${profile.name}" overridden by user plugin.
63
- `);
64
- }
65
- REGISTRY.set(profile.name, profile);
66
- for (const alias of profile.aliases ?? []) {
67
- const previous = ALIASES.get(alias);
68
- if (previous !== void 0 && previous !== profile.name) {
69
- process.stderr.write(
70
- `[theokit-sdk] Alias "${alias}" collision: was "${previous}", now "${profile.name}".
71
- `
72
- );
73
- }
74
- ALIASES.set(alias, profile.name);
75
- }
76
- }
77
- function getProviderProfile(name) {
78
- const canonical = ALIASES.get(name) ?? name;
79
- return REGISTRY.get(canonical);
80
- }
81
-
82
- // src/internal/providers/catalog-loader.ts
83
- var __dirname_resolved = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('models.cjs', document.baseURI).href))));
84
- var modelInfoIndex = globalSingleton(
85
- "theokit-sdk.providers.model-info-index",
86
- () => /* @__PURE__ */ new Map()
87
- );
88
- var patchedModelKeys = globalSingleton(
89
- "theokit-sdk.providers.model-info-patched",
90
- () => /* @__PURE__ */ new Set()
91
- );
92
- var indexState = globalSingleton("theokit-sdk.providers.model-info-loaded", () => ({
93
- loaded: false
94
- }));
95
- function getCatalogModelInfo(key) {
96
- ensureModelIndexLoaded();
97
- return modelInfoIndex.get(key);
98
- }
99
- function patchModelInfo(key, model) {
100
- ensureModelIndexLoaded();
101
- const existing = modelInfoIndex.get(key);
102
- modelInfoIndex.set(key, existing === void 0 ? model : { ...existing, ...model });
103
- patchedModelKeys.add(key);
104
- }
105
- function ensureModelIndexLoaded() {
106
- if (indexState.loaded) return;
107
- indexState.loaded = true;
108
- try {
109
- const catalog = loadProviderCatalog();
110
- for (const entry of Object.values(catalog)) {
111
- indexEntryModels(entry);
112
- }
113
- } catch (err) {
114
- process.stderr.write(
115
- `[theokit-sdk] WARN: provider catalog unavailable (${err.message}) \u2014 per-model data disabled
116
- `
117
- );
118
- }
119
- }
120
- function indexEntryModels(entry) {
121
- if (entry.models === void 0 || typeof entry.models !== "object") return;
122
- for (const [modelId, raw] of Object.entries(entry.models)) {
123
- const parsed = catalogModelSchema.safeParse(raw);
124
- if (!parsed.success) {
125
- process.stderr.write(
126
- `[theokit-sdk] WARN: Skipping malformed catalog model "${entry.id}/${modelId}": ${parsed.error.issues[0]?.message ?? "invalid"}
127
- `
128
- );
129
- continue;
130
- }
131
- modelInfoIndex.set(`${entry.id}/${modelId}`, parsed.data);
132
- for (const alias of entry.aliases ?? []) {
133
- const key = `${alias}/${modelId}`;
134
- if (!modelInfoIndex.has(key)) modelInfoIndex.set(key, parsed.data);
135
- }
136
- }
137
- }
138
- function validateEntry(raw) {
139
- if (typeof raw.id !== "string" || typeof raw.displayName !== "string" || typeof raw.apiMode !== "string" || typeof raw.authType !== "string" || typeof raw.baseUrl !== "string" || !Array.isArray(raw.envVars) || !Array.isArray(raw.fallbackModels) || raw.capabilities == null || typeof raw.capabilities !== "object") {
140
- return null;
141
- }
142
- return raw;
143
- }
144
- function loadProviderCatalog(opts) {
145
- const catalogPath = path.join(__dirname_resolved, "provider-catalog.json");
146
- const rawText = fs.readFileSync(catalogPath, "utf-8");
147
- let entries = JSON.parse(rawText);
148
- const result = {};
149
- for (const raw of entries) {
150
- const validated = validateEntry(raw);
151
- if (validated === null) {
152
- process.stderr.write(
153
- `[theokit-sdk] WARN: Skipping malformed catalog entry: ${JSON.stringify(raw).slice(0, 100)}
154
- `
155
- );
156
- continue;
157
- }
158
- result[validated.id] = validated;
159
- }
160
- return result;
161
- }
162
- function registerCatalogProviders(opts) {
163
- const catalog = loadProviderCatalog();
164
- for (const entry of Object.values(catalog)) {
165
- if (getProviderProfile(entry.id) !== void 0) continue;
166
- if (entry.aliases?.some((a) => getProviderProfile(a) !== void 0)) continue;
167
- const profile = {
168
- name: entry.id,
169
- apiMode: entry.apiMode,
170
- authType: entry.authType,
171
- baseUrl: entry.baseUrl,
172
- envVars: entry.envVars,
173
- fallbackModels: entry.fallbackModels,
174
- displayName: entry.displayName,
175
- aliases: entry.aliases,
176
- modelsUrl: entry.modelsUrl,
177
- hostname: entry.hostname,
178
- extraHeaders: entry.extraHeaders
179
- };
180
- registerProvider(profile);
181
- }
182
- }
13
+ var path = require('path');
183
14
 
184
15
  // src/internal/llm/model-capabilities.ts
185
16
  var CONSERVATIVE_DEFAULTS = {
@@ -203,11 +34,11 @@ function capsFromCatalog(m) {
203
34
  }
204
35
  function resolveModelCapabilities(modelId) {
205
36
  const bare = stripVariantSuffix(stripRoutingPrefix(modelId));
206
- const fromIndex = getCatalogModelInfo(bare);
37
+ const fromIndex = chunkD42XHI4O_cjs.getCatalogModelInfo(bare);
207
38
  if (fromIndex !== void 0) return capsFromCatalog(fromIndex);
208
39
  const withVendor = inferVendorPrefix(bare);
209
40
  if (withVendor !== bare) {
210
- const vendored = getCatalogModelInfo(withVendor);
41
+ const vendored = chunkD42XHI4O_cjs.getCatalogModelInfo(withVendor);
211
42
  if (vendored !== void 0) return capsFromCatalog(vendored);
212
43
  }
213
44
  return CONSERVATIVE_DEFAULTS;
@@ -230,30 +61,6 @@ function inferVendorPrefix(bare) {
230
61
  return bare;
231
62
  }
232
63
 
233
- // src/internal/llm/model-identifier.ts
234
- var PROVIDER_ALIASES = {
235
- "llama-cpp": "llamacpp",
236
- "llama.cpp": "llamacpp",
237
- "lm-studio": "lmstudio",
238
- lm_studio: "lmstudio"
239
- };
240
- function parseModelId(modelId) {
241
- if (modelId === void 0 || modelId.length === 0) {
242
- return { provider: void 0, name: "" };
243
- }
244
- const slash = modelId.indexOf("/");
245
- if (slash <= 0 || slash === modelId.length - 1) {
246
- return { provider: void 0, name: modelId };
247
- }
248
- const rawProvider = modelId.slice(0, slash).trim().toLowerCase();
249
- const name = modelId.slice(slash + 1).trim();
250
- if (rawProvider.length === 0 || name.length === 0) {
251
- return { provider: void 0, name: modelId };
252
- }
253
- const canonical = PROVIDER_ALIASES[rawProvider] ?? rawProvider;
254
- return { provider: canonical, name };
255
- }
256
-
257
64
  // src/internal/llm/model-option.ts
258
65
  var ACRONYMS = /* @__PURE__ */ new Set(["gpt", "ai", "hd", "ui", "api", "sdk", "llm", "xl"]);
259
66
  function prettyToken(token) {
@@ -261,7 +68,7 @@ function prettyToken(token) {
261
68
  return token.charAt(0).toUpperCase() + token.slice(1);
262
69
  }
263
70
  function humanizeModelName(modelId) {
264
- const { name } = parseModelId(modelId);
71
+ const { name } = chunkVYHJZVL5_cjs.parseModelId(modelId);
265
72
  if (name.length === 0) return "";
266
73
  const colon = name.indexOf(":");
267
74
  const base = (colon >= 0 ? name.slice(0, colon) : name).replace(/\/+$/, "");
@@ -276,708 +83,9 @@ function toModelOption(modelId) {
276
83
  return {
277
84
  value: modelId,
278
85
  label: humanizeModelName(modelId),
279
- provider: parseModelId(modelId).provider
86
+ provider: chunkVYHJZVL5_cjs.parseModelId(modelId).provider
280
87
  };
281
88
  }
282
-
283
- // src/errors.ts
284
- var TheokitAgentError = class extends Error {
285
- name = "TheokitAgentError";
286
- isRetryable;
287
- code;
288
- protoErrorCode;
289
- metadata;
290
- constructor(message, options = {}) {
291
- super(message, options.cause !== void 0 ? { cause: options.cause } : void 0);
292
- this.isRetryable = options.isRetryable ?? false;
293
- if (options.code !== void 0) this.code = options.code;
294
- if (options.protoErrorCode !== void 0) this.protoErrorCode = options.protoErrorCode;
295
- if (options.metadata !== void 0) this.metadata = options.metadata;
296
- }
297
- };
298
- var ConfigurationError = class extends TheokitAgentError {
299
- name = "ConfigurationError";
300
- constructor(message, options = {}) {
301
- super(message, { ...options, isRetryable: false });
302
- }
303
- };
304
- function isTransientError(err) {
305
- return err instanceof TheokitAgentError && err.isRetryable === true;
306
- }
307
-
308
- // src/internal/runtime/retry/with-retry.ts
309
- function defaultSleep(ms, signal) {
310
- return new Promise((resolve, reject) => {
311
- if (signal?.aborted) {
312
- reject(signal.reason instanceof Error ? signal.reason : new Error("withRetry: aborted"));
313
- return;
314
- }
315
- const timer = setTimeout(() => {
316
- signal?.removeEventListener("abort", onAbort);
317
- resolve();
318
- }, ms);
319
- function onAbort() {
320
- clearTimeout(timer);
321
- reject(signal?.reason instanceof Error ? signal.reason : new Error("withRetry: aborted"));
322
- }
323
- signal?.addEventListener("abort", onAbort, { once: true });
324
- });
325
- }
326
- function resolveRetryOptions(options) {
327
- const retries = options?.retries ?? 3;
328
- if (!Number.isInteger(retries) || retries < 0) {
329
- throw new ConfigurationError(
330
- `withRetry: retries must be a non-negative integer, got ${retries}`,
331
- { code: "invalid_retry_config" }
332
- );
333
- }
334
- return {
335
- retries,
336
- isRetryable: options?.isRetryable ?? isTransientError,
337
- initialDelayMs: options?.initialDelayMs ?? 100,
338
- maxDelayMs: options?.maxDelayMs ?? 3e4,
339
- backoffMultiplier: options?.backoffMultiplier ?? 2,
340
- rng: options?.rng ?? Math.random,
341
- sleep: options?.sleep ?? defaultSleep,
342
- signal: options?.signal
343
- };
344
- }
345
- function backoffMs(cfg, attempt) {
346
- const ceiling = Math.min(cfg.maxDelayMs, cfg.initialDelayMs * cfg.backoffMultiplier ** attempt);
347
- return Math.floor(cfg.rng() * ceiling);
348
- }
349
- async function withRetry(fn, options) {
350
- const cfg = resolveRetryOptions(options);
351
- let attempt = 0;
352
- for (; ; ) {
353
- try {
354
- return await fn();
355
- } catch (err) {
356
- if (attempt >= cfg.retries || !cfg.isRetryable(err)) throw err;
357
- await cfg.sleep(backoffMs(cfg, attempt), cfg.signal);
358
- attempt += 1;
359
- }
360
- }
361
- }
362
-
363
- // src/retry.ts
364
- var Retry = class {
365
- constructor() {
366
- }
367
- static create(fn, options) {
368
- return withRetry(fn, options);
369
- }
370
- };
371
-
372
- // src/internal/providers/builtin/anthropic.ts
373
- var ANTHROPIC = {
374
- name: "anthropic",
375
- apiMode: "anthropic_messages",
376
- envVars: ["ANTHROPIC_API_KEY"],
377
- authType: "api_key",
378
- baseUrl: "https://api.anthropic.com",
379
- modelsUrl: "https://api.anthropic.com/v1/models",
380
- hostname: "api.anthropic.com",
381
- fallbackModels: ["claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"],
382
- // M45 — the Anthropic beta-features header (interleaved thinking + fine-grained tool streaming). An
383
- // Anthropic API constant, adapted verbatim from OpenCode's anthropic plugin (MIT © 2025 opencode). The
384
- // SANCTIONED behavior delta of M45 (ADR D4) — consumed by the anthropic transport's extraHeaders wiring.
385
- extraHeaders: {
386
- "anthropic-beta": "interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"
387
- }
388
- };
389
-
390
- // src/internal/providers/builtin/bedrock.ts
391
- var BEDROCK = {
392
- name: "bedrock",
393
- apiMode: "bedrock_anthropic",
394
- envVars: ["AWS_BEARER_TOKEN_BEDROCK"],
395
- authType: "aws_bearer",
396
- baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
397
- modelsUrl: void 0,
398
- hostname: "bedrock-runtime.amazonaws.com",
399
- fallbackModels: [
400
- "bedrock/us.anthropic.claude-sonnet-4-5-v1:0",
401
- "bedrock/us.anthropic.claude-opus-4-7-v1:0",
402
- "bedrock/global.anthropic.claude-haiku-4-5-v1:0"
403
- ]
404
- };
405
-
406
- // src/internal/providers/builtin/openai-compatible.ts
407
- function openAiCompatibleProfile(p) {
408
- return {
409
- apiMode: "chat_completions",
410
- authType: "api_key",
411
- fallbackModels: [],
412
- ...p
413
- };
414
- }
415
-
416
- // src/internal/providers/builtin/cerebras.ts
417
- var CEREBRAS = openAiCompatibleProfile({
418
- name: "cerebras",
419
- baseUrl: "https://api.cerebras.ai/v1",
420
- envVars: ["CEREBRAS_API_KEY"],
421
- fallbackModels: ["gpt-oss-120b", "zai-glm-4.7"],
422
- extraHeaders: { "X-Cerebras-3rd-Party-Integration": "theokit" },
423
- hostname: "api.cerebras.ai"
424
- });
425
-
426
- // src/internal/providers/builtin/cohere.ts
427
- var COHERE = openAiCompatibleProfile({
428
- name: "cohere",
429
- baseUrl: "https://api.cohere.ai/compatibility/v1",
430
- envVars: ["COHERE_API_KEY", "CO_API_KEY"],
431
- fallbackModels: ["command-a-03-2025"],
432
- hostname: "api.cohere.ai"
433
- });
434
-
435
- // src/internal/providers/builtin/deepinfra.ts
436
- var DEEPINFRA = openAiCompatibleProfile({
437
- name: "deepinfra",
438
- baseUrl: "https://api.deepinfra.com/v1/openai",
439
- envVars: ["DEEPINFRA_API_KEY"],
440
- fallbackModels: ["Qwen/Qwen3-32B"],
441
- hostname: "api.deepinfra.com"
442
- });
443
-
444
- // src/internal/providers/builtin/gemini.ts
445
- var GEMINI = {
446
- name: "gemini",
447
- apiMode: "chat_completions",
448
- envVars: ["OPENROUTER_API_KEY"],
449
- authType: "api_key",
450
- baseUrl: "https://openrouter.ai/api",
451
- hostname: "openrouter.ai",
452
- fallbackModels: ["google/gemini-2.0-flash-001"]
453
- };
454
-
455
- // src/internal/providers/builtin/google.ts
456
- var GOOGLE = openAiCompatibleProfile({
457
- name: "google",
458
- baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
459
- envVars: ["GOOGLE_API_KEY", "GEMINI_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"],
460
- fallbackModels: ["gemini-2.5-pro", "gemini-2.5-flash"],
461
- hostname: "generativelanguage.googleapis.com"
462
- });
463
-
464
- // src/internal/providers/builtin/groq.ts
465
- var GROQ = openAiCompatibleProfile({
466
- name: "groq",
467
- baseUrl: "https://api.groq.com/openai/v1",
468
- envVars: ["GROQ_API_KEY"],
469
- fallbackModels: ["llama-3.3-70b-versatile", "llama-3.1-8b-instant"],
470
- hostname: "api.groq.com"
471
- });
472
-
473
- // src/internal/providers/builtin/llamacpp.ts
474
- var LLAMACPP = {
475
- name: "llamacpp",
476
- aliases: ["llama-cpp", "llama.cpp"],
477
- apiMode: "chat_completions",
478
- envVars: ["LLAMACPP_API_KEY"],
479
- authType: "none",
480
- baseUrl: "http://localhost:8080",
481
- modelsUrl: "http://localhost:8080/v1/models",
482
- hostname: "localhost",
483
- fallbackModels: ["loaded-model"]
484
- };
485
-
486
- // src/internal/providers/builtin/lmstudio.ts
487
- var LMSTUDIO = {
488
- name: "lmstudio",
489
- aliases: ["lm-studio", "lm_studio"],
490
- apiMode: "chat_completions",
491
- envVars: ["LMSTUDIO_API_KEY"],
492
- authType: "none",
493
- baseUrl: "http://localhost:1234",
494
- modelsUrl: "http://localhost:1234/v1/models",
495
- hostname: "localhost",
496
- fallbackModels: ["loaded-model"]
497
- };
498
-
499
- // src/internal/providers/builtin/mistral.ts
500
- var MISTRAL = openAiCompatibleProfile({
501
- name: "mistral",
502
- baseUrl: "https://api.mistral.ai/v1",
503
- envVars: ["MISTRAL_API_KEY"],
504
- fallbackModels: ["mistral-large-latest", "codestral-latest"],
505
- hostname: "api.mistral.ai"
506
- });
507
-
508
- // src/internal/providers/builtin/ollama.ts
509
- var OLLAMA = {
510
- name: "ollama",
511
- apiMode: "chat_completions",
512
- envVars: ["OLLAMA_API_KEY"],
513
- authType: "none",
514
- baseUrl: "http://localhost:11434",
515
- modelsUrl: "http://localhost:11434/v1/models",
516
- hostname: "localhost",
517
- fallbackModels: ["llama3.2", "qwen2.5", "mistral"]
518
- };
519
-
520
- // src/internal/providers/builtin/openai.ts
521
- var OPENAI = {
522
- name: "openai",
523
- apiMode: "chat_completions",
524
- envVars: ["OPENAI_API_KEY"],
525
- authType: "api_key",
526
- baseUrl: "https://api.openai.com",
527
- modelsUrl: "https://api.openai.com/v1/models",
528
- hostname: "api.openai.com",
529
- fallbackModels: ["gpt-4o", "gpt-4o-mini"]
530
- };
531
- function credentialHome(config, env = {}) {
532
- const override = config.homeEnvVar !== void 0 ? env[config.homeEnvVar]?.trim() : void 0;
533
- return override !== void 0 && override.length > 0 ? override : path.join(config.home, config.dirName);
534
- }
535
- function authFilePath(config, env = {}) {
536
- return path.join(credentialHome(config, env), config.fileName);
537
- }
538
- var CredentialError = class extends Error {
539
- constructor(message) {
540
- super(message);
541
- this.name = "CredentialError";
542
- }
543
- };
544
- var apiFileSchema = zod.z.object({
545
- type: zod.z.literal("api").optional(),
546
- provider: zod.z.string().min(1).optional(),
547
- api_key: zod.z.string()
548
- }).strict();
549
- var oauthFileSchema = zod.z.object({
550
- type: zod.z.literal("oauth"),
551
- provider: zod.z.string().min(1),
552
- access: zod.z.string().min(1),
553
- refresh: zod.z.string().min(1),
554
- expires: zod.z.number(),
555
- account_id: zod.z.string().optional()
556
- }).strict();
557
- var fileSchema = zod.z.union([oauthFileSchema, apiFileSchema]);
558
- function assertSecureModes(dirPath, path) {
559
- const dirMode = fs.statSync(dirPath).mode & 511;
560
- if ((dirMode & 18) !== 0) {
561
- throw new CredentialError(
562
- `${dirPath} is writable by other users (mode ${dirMode.toString(8)}), so the credential file inside it can be replaced. Fix it with: chmod 700 ${dirPath}`
563
- );
564
- }
565
- const mode = fs.statSync(path).mode & 511;
566
- if ((mode & 63) !== 0) {
567
- throw new CredentialError(
568
- `${path} is readable by other users (mode ${mode.toString(8)}). A credential file must not be. Fix it with: chmod 600 ${path}`
569
- );
570
- }
571
- }
572
- function describeUnionError(parsed, err, path) {
573
- const looksOAuth = typeof parsed === "object" && parsed !== null && parsed.type === "oauth";
574
- const specific = looksOAuth ? oauthFileSchema.safeParse(parsed) : apiFileSchema.safeParse(parsed);
575
- let issue;
576
- if (!specific.success) {
577
- issue = specific.error.issues[0];
578
- } else if (err instanceof zod.z.ZodError) {
579
- issue = err.issues[0];
580
- }
581
- return new CredentialError(
582
- `${path}: ${issue?.message ?? String(err)} [${issue?.path.join(".") || "root"}]`
583
- );
584
- }
585
- function parseStoredFile(raw, path) {
586
- let parsed;
587
- try {
588
- parsed = JSON.parse(raw);
589
- } catch {
590
- throw new CredentialError(
591
- `${path} is not valid JSON. Expected: {"provider": "<name>", "api_key": "..."}`
592
- );
593
- }
594
- try {
595
- return fileSchema.parse(parsed);
596
- } catch (err) {
597
- throw describeUnionError(parsed, err, path);
598
- }
599
- }
600
- function readAuthFile(config, env = {}) {
601
- const path = authFilePath(config, env);
602
- let raw;
603
- try {
604
- raw = fs.readFileSync(path, "utf8");
605
- } catch (err) {
606
- if (err.code === "ENOENT") return void 0;
607
- throw new CredentialError(`cannot read ${path}: ${err.message}`);
608
- }
609
- assertSecureModes(credentialHome(config, env), path);
610
- return parseStoredFile(raw, path);
611
- }
612
- function readStoredOAuth(config, env = {}) {
613
- const stored = readAuthFile(config, env);
614
- return stored !== void 0 && stored.type === "oauth" ? stored : void 0;
615
- }
616
- function isOAuthWrite(c) {
617
- return "type" in c && c.type === "oauth";
618
- }
619
- function buildStorePayload(cred) {
620
- if (isOAuthWrite(cred)) {
621
- if (cred.access.length === 0 || cred.refresh.length === 0) {
622
- throw new CredentialError(
623
- "refusing to write an oauth credential with an empty access/refresh token"
624
- );
625
- }
626
- return {
627
- type: "oauth",
628
- provider: cred.provider,
629
- access: cred.access,
630
- refresh: cred.refresh,
631
- expires: cred.expires,
632
- ...cred.account_id !== void 0 ? { account_id: cred.account_id } : {}
633
- };
634
- }
635
- if (typeof cred.apiKey !== "string" || cred.apiKey.length === 0) {
636
- throw new CredentialError("refusing to write an empty API key");
637
- }
638
- return { provider: cred.provider, api_key: cred.apiKey };
639
- }
640
- function writeCredential(cred, config, env = {}) {
641
- const payload = buildStorePayload(cred);
642
- const dir = credentialHome(config, env);
643
- fs.mkdirSync(dir, { recursive: true, mode: 448 });
644
- fs.chmodSync(dir, 448);
645
- const path = authFilePath(config, env);
646
- const tmp = `${path}.tmp-${crypto.randomBytes(8).toString("hex")}`;
647
- try {
648
- const fd = fs.openSync(tmp, "wx", 384);
649
- try {
650
- fs.writeFileSync(fd, `${JSON.stringify(payload, null, 2)}
651
- `);
652
- fs.fsyncSync(fd);
653
- } finally {
654
- fs.closeSync(fd);
655
- }
656
- fs.chmodSync(tmp, 384);
657
- fs.renameSync(tmp, path);
658
- } catch (err) {
659
- try {
660
- fs.unlinkSync(tmp);
661
- } catch {
662
- }
663
- throw new CredentialError(`cannot write ${path}: ${err.message}`);
664
- }
665
- return path;
666
- }
667
-
668
- // src/server/auth/errors.ts
669
- var AuthCallbackError = class extends Error {
670
- name = "AuthCallbackError";
671
- code;
672
- constructor(code, message) {
673
- super(message ?? `OAuth callback error: ${code}`);
674
- this.code = code;
675
- }
676
- };
677
-
678
- // src/internal/auth/oauth-engine.ts
679
- var REFRESH_SKEW_MS = 6e4;
680
- function parseTokenResponse(body, now) {
681
- const b = body;
682
- if (typeof b.access_token !== "string" || b.access_token.length === 0) {
683
- throw new AuthCallbackError(
684
- "oauth_token_exchange_failed",
685
- "token response had no access_token"
686
- );
687
- }
688
- if (typeof b.refresh_token !== "string" || b.refresh_token.length === 0) {
689
- throw new AuthCallbackError(
690
- "oauth_token_exchange_failed",
691
- "token response had no refresh_token"
692
- );
693
- }
694
- const expiresIn = typeof b.expires_in === "number" ? b.expires_in : 3600;
695
- return {
696
- access: b.access_token,
697
- refresh: b.refresh_token,
698
- expires: now + expiresIn * 1e3,
699
- ...typeof b.account_id === "string" ? { accountId: b.account_id } : {}
700
- };
701
- }
702
- async function postGrant(config, form, deps) {
703
- let res;
704
- try {
705
- res = await deps.fetch(config.tokenEndpoint, {
706
- method: "POST",
707
- headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
708
- body: new URLSearchParams(form).toString()
709
- });
710
- } catch (err) {
711
- throw new AuthCallbackError(
712
- "oauth_token_exchange_failed",
713
- `token endpoint request failed: ${err.message}`
714
- );
715
- }
716
- if (!res.ok) {
717
- throw new AuthCallbackError(
718
- "oauth_token_exchange_failed",
719
- `token endpoint returned HTTP ${res.status}`
720
- );
721
- }
722
- let json;
723
- try {
724
- json = await res.json();
725
- } catch {
726
- throw new AuthCallbackError("oauth_token_exchange_failed", "token response was not valid JSON");
727
- }
728
- return parseTokenResponse(json, deps.now());
729
- }
730
- function refreshOAuthTokens(config, refresh, deps) {
731
- return postGrant(
732
- config,
733
- { grant_type: "refresh_token", refresh_token: refresh, client_id: config.clientId },
734
- deps
735
- );
736
- }
737
- function persistOAuthTokens(provider, tokens, store, env = {}) {
738
- return writeCredential(
739
- {
740
- type: "oauth",
741
- provider,
742
- access: tokens.access,
743
- refresh: tokens.refresh,
744
- expires: tokens.expires,
745
- ...tokens.accountId !== void 0 ? { account_id: tokens.accountId } : {}
746
- },
747
- store,
748
- env
749
- );
750
- }
751
- var inFlightRefresh = /* @__PURE__ */ new Map();
752
- async function ensureFreshCredential(resolved, opts, deps) {
753
- if (resolved.kind !== "oauth") return resolved;
754
- const now = deps.now();
755
- if (resolved.expiresAt !== void 0 && resolved.expiresAt > now + REFRESH_SKEW_MS) {
756
- return resolved;
757
- }
758
- const env = opts.env ?? {};
759
- const path = authFilePath(opts.store, env);
760
- let refresh = inFlightRefresh.get(path);
761
- if (refresh === void 0) {
762
- refresh = (async () => {
763
- const stored = readStoredOAuth(opts.store, env);
764
- if (stored === void 0) {
765
- throw new AuthCallbackError(
766
- "oauth_token_exchange_failed",
767
- "no stored oauth credential to refresh"
768
- );
769
- }
770
- const fresh2 = await refreshOAuthTokens(opts.config, stored.refresh, deps);
771
- const merged = {
772
- ...fresh2,
773
- accountId: fresh2.accountId ?? stored.account_id
774
- };
775
- persistOAuthTokens(resolved.provider, merged, opts.store, env);
776
- return merged;
777
- })();
778
- inFlightRefresh.set(path, refresh);
779
- refresh.finally(() => inFlightRefresh.delete(path)).catch(() => {
780
- });
781
- }
782
- const fresh = await refresh;
783
- return {
784
- kind: "oauth",
785
- provider: resolved.provider,
786
- apiKey: fresh.access,
787
- source: resolved.source,
788
- inferred: false,
789
- expiresAt: fresh.expires
790
- };
791
- }
792
-
793
- // src/internal/auth/resolve-credential.ts
794
- async function resolveOAuth(stored, path, opts, env) {
795
- if (stored.provider !== opts.provider) return void 0;
796
- const base = {
797
- kind: "oauth",
798
- provider: opts.provider,
799
- apiKey: stored.access,
800
- source: path,
801
- inferred: false,
802
- expiresAt: stored.expires
803
- };
804
- if (opts.oauth === void 0) return base;
805
- const deps = {
806
- fetch: opts.deps?.fetch ?? fetch,
807
- now: opts.deps?.now ?? (() => Date.now())
808
- };
809
- return ensureFreshCredential(base, { config: opts.oauth, store: opts.store, env }, deps);
810
- }
811
- async function resolveCredential(opts) {
812
- const env = opts.env ?? {};
813
- const stored = readAuthFile(opts.store, env);
814
- if (stored === void 0) return void 0;
815
- const path = authFilePath(opts.store, env);
816
- if (stored.type === "oauth") {
817
- return resolveOAuth(stored, path, opts, env);
818
- }
819
- if (stored.api_key.length === 0) return void 0;
820
- if (stored.provider !== opts.provider) return void 0;
821
- return {
822
- kind: "api",
823
- provider: opts.provider,
824
- apiKey: stored.api_key,
825
- source: path,
826
- inferred: false
827
- };
828
- }
829
-
830
- // src/internal/providers/builtin/openai-chatgpt.ts
831
- var DEFAULT_STORE = {
832
- home: os.homedir(),
833
- dirName: ".theokit",
834
- fileName: "auth.json",
835
- homeEnvVar: "THEOKIT_AUTH_HOME"
836
- };
837
- var OPENAI_OAUTH_CONFIG = {
838
- provider: "openai",
839
- authorizeEndpoint: "https://auth.openai.com/oauth/authorize",
840
- tokenEndpoint: "https://auth.openai.com/oauth/token",
841
- clientId: "app_EMoamEEZ73f0CkXaXp7hrann",
842
- scopes: ["openid", "profile", "email", "offline_access"],
843
- redirectUri: "https://auth.openai.com/deviceauth/callback"
844
- };
845
- function codexFetch() {
846
- return (async (input, init) => {
847
- const env = process.env;
848
- const resolved = await resolveCredential({
849
- provider: "openai",
850
- store: DEFAULT_STORE,
851
- oauth: OPENAI_OAUTH_CONFIG,
852
- env
853
- });
854
- if (resolved === void 0) {
855
- throw new Error(
856
- 'openai-chatgpt: no ChatGPT credential found \u2014 run the OpenAI device login (e.g. "/login openai") first.'
857
- );
858
- }
859
- const accountId = readStoredOAuth(DEFAULT_STORE, env)?.account_id;
860
- const headers = new Headers(init?.headers);
861
- headers.set("authorization", `Bearer ${resolved.apiKey}`);
862
- if (accountId !== void 0) headers.set("ChatGPT-Account-Id", accountId);
863
- return fetch(input, { ...init, headers });
864
- });
865
- }
866
- var OPENAI_CHATGPT = {
867
- name: "openai-chatgpt",
868
- apiMode: "responses_api",
869
- authType: "oauth_device_code",
870
- baseUrl: "https://chatgpt.com/backend-api/codex",
871
- envVars: [],
872
- fallbackModels: [
873
- "openai-chatgpt/gpt-5.4",
874
- "openai-chatgpt/gpt-5.4-mini",
875
- "openai-chatgpt/gpt-5.5"
876
- ],
877
- extraHeaders: { originator: "codex_cli_rs" },
878
- transform: {
879
- // Only `fetch` (async) can await the credential refresh; `headers` is sync and cannot.
880
- fetch: () => codexFetch()
881
- }
882
- };
883
-
884
- // src/internal/providers/builtin/openrouter.ts
885
- var OPENROUTER = {
886
- name: "openrouter",
887
- apiMode: "chat_completions",
888
- aliases: ["or"],
889
- // Ordered fallback (EC-10): OPENROUTER_API_KEY preferred, OPENAI_API_KEY as compat.
890
- envVars: ["OPENROUTER_API_KEY", "OPENAI_API_KEY"],
891
- authType: "api_key",
892
- baseUrl: "https://openrouter.ai/api",
893
- modelsUrl: "https://openrouter.ai/api/v1/models",
894
- hostname: "openrouter.ai",
895
- // M45 — models refreshed (claude-3-haiku retired upstream).
896
- fallbackModels: ["openai/gpt-4o-mini", "anthropic/claude-haiku-4-5"],
897
- // M45 — OpenRouter app-attribution headers (mechanism from OpenCode's openrouter plugin, MIT; VALUES are
898
- // theokit's own — copying another app's referer would misattribute traffic).
899
- extraHeaders: { "HTTP-Referer": "https://usetheo.dev", "X-Title": "theokit" }
900
- };
901
-
902
- // src/internal/providers/builtin/perplexity.ts
903
- var PERPLEXITY = openAiCompatibleProfile({
904
- name: "perplexity",
905
- baseUrl: "https://api.perplexity.ai",
906
- chatCompletionsPath: "/chat/completions",
907
- envVars: ["PERPLEXITY_API_KEY"],
908
- fallbackModels: ["sonar-pro", "sonar"],
909
- hostname: "api.perplexity.ai"
910
- });
911
-
912
- // src/internal/providers/builtin/together.ts
913
- var TOGETHER = openAiCompatibleProfile({
914
- name: "together",
915
- aliases: ["togetherai"],
916
- baseUrl: "https://api.together.xyz/v1",
917
- envVars: ["TOGETHER_API_KEY"],
918
- fallbackModels: ["Qwen/Qwen2.5-7B-Instruct-Turbo"],
919
- hostname: "api.together.xyz"
920
- });
921
-
922
- // src/internal/providers/builtin/vertex.ts
923
- var VERTEX = {
924
- name: "vertex",
925
- apiMode: "anthropic_messages",
926
- // sub-dispatched in selectTransport by profile.name
927
- envVars: ["GOOGLE_APPLICATION_CREDENTIALS"],
928
- authType: "gcp_oauth",
929
- baseUrl: "https://us-central1-aiplatform.googleapis.com",
930
- modelsUrl: void 0,
931
- hostname: "aiplatform.googleapis.com",
932
- fallbackModels: [
933
- "vertex/anthropic/claude-sonnet-4-5@20250929",
934
- "vertex/google/gemini-2.0-flash-001"
935
- ]
936
- };
937
-
938
- // src/internal/providers/builtin/xai.ts
939
- var XAI = openAiCompatibleProfile({
940
- name: "xai",
941
- aliases: ["grok"],
942
- baseUrl: "https://api.x.ai/v1",
943
- envVars: ["XAI_API_KEY"],
944
- fallbackModels: ["grok-4.5", "grok-4.3"],
945
- hostname: "api.x.ai"
946
- });
947
-
948
- // src/internal/providers/builtin/index.ts
949
- var _registeredState = (() => {
950
- const g = globalThis;
951
- const sym = /* @__PURE__ */ Symbol.for("theokit-sdk.providers.builtins-registered");
952
- if (g[sym] === void 0) g[sym] = { done: false };
953
- return g[sym];
954
- })();
955
- function registerBuiltins() {
956
- if (_registeredState.done) return;
957
- _registeredState.done = true;
958
- registerProvider(ANTHROPIC);
959
- registerProvider(OPENAI);
960
- registerProvider(OPENAI_CHATGPT);
961
- registerProvider(OPENROUTER);
962
- registerProvider(GEMINI);
963
- registerProvider(OLLAMA);
964
- registerProvider(LMSTUDIO);
965
- registerProvider(LLAMACPP);
966
- registerProvider(BEDROCK);
967
- registerProvider(VERTEX);
968
- registerProvider(GOOGLE);
969
- registerProvider(MISTRAL);
970
- registerProvider(GROQ);
971
- registerProvider(COHERE);
972
- registerProvider(DEEPINFRA);
973
- registerProvider(TOGETHER);
974
- registerProvider(XAI);
975
- registerProvider(PERPLEXITY);
976
- registerProvider(CEREBRAS);
977
- registerCatalogProviders();
978
- }
979
-
980
- // src/internal/providers/catalog-source-models-dev.ts
981
89
  var DEFAULT_URL = "https://models.dev/api.json";
982
90
  var TTL_MS = 60 * 60 * 1e3;
983
91
  var FETCH_TIMEOUT_MS = 1e4;
@@ -1015,7 +123,7 @@ function catalogTargets() {
1015
123
  if (_catalogTargets !== void 0) return _catalogTargets;
1016
124
  _catalogTargets = /* @__PURE__ */ new Map();
1017
125
  try {
1018
- for (const entry of Object.values(loadProviderCatalog())) {
126
+ for (const entry of Object.values(chunkD42XHI4O_cjs.loadProviderCatalog())) {
1019
127
  const keys = [entry.id, ...entry.aliases ?? []];
1020
128
  for (const k of keys) {
1021
129
  if (!_catalogTargets.has(k)) _catalogTargets.set(k, { keys });
@@ -1029,7 +137,7 @@ function resolvePatchKeys(externalId) {
1029
137
  const mapped = MODELS_DEV_ID_MAP[externalId] ?? externalId;
1030
138
  const fromCatalog = catalogTargets().get(mapped);
1031
139
  if (fromCatalog !== void 0) return fromCatalog.keys;
1032
- const profile = getProviderProfile(mapped);
140
+ const profile = chunkD42XHI4O_cjs.getProviderProfile(mapped);
1033
141
  if (profile !== void 0) return [profile.name, ...profile.aliases ?? []];
1034
142
  return void 0;
1035
143
  }
@@ -1046,9 +154,9 @@ function patchIndexFromApiJson(raw) {
1046
154
  continue;
1047
155
  }
1048
156
  for (const [modelId, rawModel] of Object.entries(models)) {
1049
- const parsed = catalogModelSchema.safeParse(rawModel);
157
+ const parsed = chunkD42XHI4O_cjs.catalogModelSchema.safeParse(rawModel);
1050
158
  if (!parsed.success) continue;
1051
- for (const key of keys) patchModelInfo(`${key}/${modelId}`, parsed.data);
159
+ for (const key of keys) chunkD42XHI4O_cjs.patchModelInfo(`${key}/${modelId}`, parsed.data);
1052
160
  patched++;
1053
161
  }
1054
162
  }
@@ -1091,7 +199,7 @@ function loadCacheIntoIndex(url = DEFAULT_URL) {
1091
199
  }
1092
200
  }
1093
201
  async function refreshModelCatalog(opts = {}) {
1094
- registerBuiltins();
202
+ chunkD42XHI4O_cjs.registerBuiltins();
1095
203
  const kill = process.env.THEOKIT_DISABLE_MODELS_FETCH;
1096
204
  if (kill !== void 0 && kill !== "" && kill !== "0" && kill.toLowerCase() !== "false") {
1097
205
  return { source: "skipped", models: 0 };
@@ -1111,7 +219,7 @@ async function refreshModelCatalog(opts = {}) {
1111
219
  const fetchImpl = opts.deps?.fetch ?? fetch;
1112
220
  let body;
1113
221
  try {
1114
- const res = await Retry.create(
222
+ const res = await chunkKSKU6JY6_cjs.Retry.create(
1115
223
  async () => {
1116
224
  const r = await fetchImpl(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
1117
225
  if (!r.ok) throw new Error(`HTTP ${r.status}`);
@@ -1149,12 +257,15 @@ async function refreshModelCatalog(opts = {}) {
1149
257
  }
1150
258
  }
1151
259
  function getModelInfo(modelId) {
1152
- return getCatalogModelInfo(modelId);
260
+ return chunkD42XHI4O_cjs.getCatalogModelInfo(modelId);
1153
261
  }
1154
262
 
263
+ Object.defineProperty(exports, "parseModelId", {
264
+ enumerable: true,
265
+ get: function () { return chunkVYHJZVL5_cjs.parseModelId; }
266
+ });
1155
267
  exports.getModelInfo = getModelInfo;
1156
268
  exports.humanizeModelName = humanizeModelName;
1157
- exports.parseModelId = parseModelId;
1158
269
  exports.refreshModelCatalog = refreshModelCatalog;
1159
270
  exports.resolveModelCapabilities = resolveModelCapabilities;
1160
271
  exports.toModelOption = toModelOption;