@nyte-ai/ai 0.0.0-stage → 0.0.18

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 (314) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +170 -2
  3. package/THIRD-PARTY-NOTICES.md +800 -0
  4. package/dist/chunks/account-limits-cache-031vfpt3.js +37 -0
  5. package/dist/chunks/account-limits-cache-09vs98g6.js +41 -0
  6. package/dist/chunks/account-limits-cache-0af5gqeg.js +15 -0
  7. package/dist/chunks/account-limits-cache-0yd6bde8.js +103 -0
  8. package/dist/chunks/account-limits-cache-1jv43fhh.js +22 -0
  9. package/dist/chunks/account-limits-cache-3ykqmnj5.js +88 -0
  10. package/dist/chunks/account-limits-cache-4b8ckwqw.js +293 -0
  11. package/dist/chunks/account-limits-cache-4fn5w63p.js +295 -0
  12. package/dist/chunks/account-limits-cache-4hptgd2h.js +49 -0
  13. package/dist/chunks/account-limits-cache-53e64mhx.js +417 -0
  14. package/dist/chunks/account-limits-cache-5jdhn0e1.js +562 -0
  15. package/dist/chunks/account-limits-cache-5rx2pfm5.js +8 -0
  16. package/dist/chunks/account-limits-cache-5ygxyyss.js +19 -0
  17. package/dist/chunks/account-limits-cache-6250ykn6.js +21 -0
  18. package/dist/chunks/account-limits-cache-6x05n06z.js +49 -0
  19. package/dist/chunks/account-limits-cache-736tdyme.js +6 -0
  20. package/dist/chunks/account-limits-cache-75smws02.js +213 -0
  21. package/dist/chunks/account-limits-cache-7z9s8j16.js +139 -0
  22. package/dist/chunks/account-limits-cache-8137j3zp.js +37 -0
  23. package/dist/chunks/account-limits-cache-8qzk56vj.js +160 -0
  24. package/dist/chunks/account-limits-cache-8s8bz4dr.js +36 -0
  25. package/dist/chunks/account-limits-cache-8vzx8k6r.js +166 -0
  26. package/dist/chunks/account-limits-cache-8wfqg73s.js +135 -0
  27. package/dist/chunks/account-limits-cache-90c9c2eb.js +50 -0
  28. package/dist/chunks/account-limits-cache-9wqk28n5.js +25 -0
  29. package/dist/chunks/account-limits-cache-a1jyaq00.js +56 -0
  30. package/dist/chunks/account-limits-cache-a558rjbg.js +138 -0
  31. package/dist/chunks/account-limits-cache-a55e14fr.js +70 -0
  32. package/dist/chunks/account-limits-cache-a6cgeagz.js +77 -0
  33. package/dist/chunks/account-limits-cache-ag5b8dja.js +38 -0
  34. package/dist/chunks/account-limits-cache-b0x2sfya.js +45 -0
  35. package/dist/chunks/account-limits-cache-b23sbrke.js +26 -0
  36. package/dist/chunks/account-limits-cache-b4edaybk.js +8 -0
  37. package/dist/chunks/account-limits-cache-bsknrh6t.js +74 -0
  38. package/dist/chunks/account-limits-cache-c7v93krb.js +235 -0
  39. package/dist/chunks/account-limits-cache-csbxvam7.js +12 -0
  40. package/dist/chunks/account-limits-cache-cw7q7vfy.js +293 -0
  41. package/dist/chunks/account-limits-cache-d1ypzqzp.js +27 -0
  42. package/dist/chunks/account-limits-cache-d2a51dka.js +17 -0
  43. package/dist/chunks/account-limits-cache-dejeygdt.js +114 -0
  44. package/dist/chunks/account-limits-cache-eejm0vth.js +11 -0
  45. package/dist/chunks/account-limits-cache-ehy0ze2b.js +33 -0
  46. package/dist/chunks/account-limits-cache-emg5b4hj.js +53 -0
  47. package/dist/chunks/account-limits-cache-eqwweapz.js +6 -0
  48. package/dist/chunks/account-limits-cache-eyx1jcxc.js +8 -0
  49. package/dist/chunks/account-limits-cache-f9z00x8c.js +36 -0
  50. package/dist/chunks/account-limits-cache-fbkaq46e.js +113 -0
  51. package/dist/chunks/account-limits-cache-fdwad56n.js +399 -0
  52. package/dist/chunks/account-limits-cache-fht68jp2.js +22 -0
  53. package/dist/chunks/account-limits-cache-fp03ztsw.js +17 -0
  54. package/dist/chunks/account-limits-cache-fsktnetm.js +69 -0
  55. package/dist/chunks/account-limits-cache-fvadc36m.js +110 -0
  56. package/dist/chunks/account-limits-cache-ghe9ne4j.js +69 -0
  57. package/dist/chunks/account-limits-cache-gknnm1kv.js +13 -0
  58. package/dist/chunks/account-limits-cache-gqsrbky9.js +40 -0
  59. package/dist/chunks/account-limits-cache-gr671dr2.js +0 -0
  60. package/dist/chunks/account-limits-cache-gs8a3fhw.js +32 -0
  61. package/dist/chunks/account-limits-cache-gsa5tzck.js +37 -0
  62. package/dist/chunks/account-limits-cache-h92bzz1j.js +235 -0
  63. package/dist/chunks/account-limits-cache-hemxtapd.js +142 -0
  64. package/dist/chunks/account-limits-cache-hj1h48sc.js +92 -0
  65. package/dist/chunks/account-limits-cache-hj3ek3ty.js +128 -0
  66. package/dist/chunks/account-limits-cache-hwehc67r.js +509 -0
  67. package/dist/chunks/account-limits-cache-hyzn1jmk.js +46 -0
  68. package/dist/chunks/account-limits-cache-j2bt392s.js +63 -0
  69. package/dist/chunks/account-limits-cache-k0pkzhbx.js +74 -0
  70. package/dist/chunks/account-limits-cache-kjx405q0.js +277 -0
  71. package/dist/chunks/account-limits-cache-ks1sjym9.js +37 -0
  72. package/dist/chunks/account-limits-cache-me1x57bs.js +89 -0
  73. package/dist/chunks/account-limits-cache-n3yk6g5c.js +314 -0
  74. package/dist/chunks/account-limits-cache-nbhht7xz.js +72 -0
  75. package/dist/chunks/account-limits-cache-nbkyhs6v.js +42 -0
  76. package/dist/chunks/account-limits-cache-nn9jebsj.js +26 -0
  77. package/dist/chunks/account-limits-cache-nxkprk3g.js +13 -0
  78. package/dist/chunks/account-limits-cache-nyy770yd.js +38 -0
  79. package/dist/chunks/account-limits-cache-pfa86y8e.js +45 -0
  80. package/dist/chunks/account-limits-cache-pfr14mcn.js +59 -0
  81. package/dist/chunks/account-limits-cache-q1ebtvet.js +8 -0
  82. package/dist/chunks/account-limits-cache-q63mc41j.js +51 -0
  83. package/dist/chunks/account-limits-cache-re8hpzwn.js +104 -0
  84. package/dist/chunks/account-limits-cache-rz8p1g5y.js +9 -0
  85. package/dist/chunks/account-limits-cache-skbfmzqe.js +7 -0
  86. package/dist/chunks/account-limits-cache-tc38g0ca.js +20 -0
  87. package/dist/chunks/account-limits-cache-v4n30az2.js +24 -0
  88. package/dist/chunks/account-limits-cache-vwgfz727.js +281 -0
  89. package/dist/chunks/account-limits-cache-x9fvb3s5.js +8 -0
  90. package/dist/chunks/account-limits-cache-xds88kxd.js +209 -0
  91. package/dist/chunks/account-limits-cache-xz65wyd1.js +428 -0
  92. package/dist/chunks/account-limits-cache-ydq8p8qp.js +39 -0
  93. package/dist/chunks/account-limits-cache-ykbqsvv6.js +134 -0
  94. package/dist/chunks/account-limits-cache-za42x8a3.js +25 -0
  95. package/dist/chunks/account-limits-cache-zcbkmrvy.js +79 -0
  96. package/dist/chunks/account-limits-cache-zgzptd0z.js +62 -0
  97. package/dist/chunks/account-limits-cache-zn01kscn.js +252 -0
  98. package/dist/chunks/account-limits-cache-zpjmeyt0.js +113 -0
  99. package/dist/chunks/account-limits-cache-zqdb4yh4.js +8 -0
  100. package/dist/src/account-limits-cache.d.ts +16 -0
  101. package/dist/src/account-limits-cache.js +7 -0
  102. package/dist/src/api/anthropic-client.d.ts +25 -0
  103. package/dist/src/api/anthropic-client.js +30 -0
  104. package/dist/src/api/anthropic-convert.d.ts +17 -0
  105. package/dist/src/api/anthropic-convert.js +14 -0
  106. package/dist/src/api/anthropic-events.d.ts +101 -0
  107. package/dist/src/api/anthropic-events.js +11 -0
  108. package/dist/src/api/anthropic-messages.d.ts +88 -0
  109. package/dist/src/api/anthropic-messages.js +578 -0
  110. package/dist/src/api/anthropic-messages.lazy.d.ts +2 -0
  111. package/dist/src/api/anthropic-messages.lazy.js +11 -0
  112. package/dist/src/api/assistant-stream.d.ts +23 -0
  113. package/dist/src/api/assistant-stream.js +15 -0
  114. package/dist/src/api/claude-code.d.ts +12 -0
  115. package/dist/src/api/claude-code.js +12 -0
  116. package/dist/src/api/cloudflare.d.ts +8 -0
  117. package/dist/src/api/cloudflare.js +11 -0
  118. package/dist/src/api/constrained-sampling.d.ts +24 -0
  119. package/dist/src/api/constrained-sampling.js +16 -0
  120. package/dist/src/api/deferred.d.ts +7 -0
  121. package/dist/src/api/deferred.js +10 -0
  122. package/dist/src/api/github-copilot-headers.d.ts +15 -0
  123. package/dist/src/api/github-copilot-headers.js +12 -0
  124. package/dist/src/api/google-generative-ai.d.ts +22 -0
  125. package/dist/src/api/google-generative-ai.js +583 -0
  126. package/dist/src/api/google-generative-ai.lazy.d.ts +2 -0
  127. package/dist/src/api/google-generative-ai.lazy.js +11 -0
  128. package/dist/src/api/lazy.d.ts +18 -0
  129. package/dist/src/api/lazy.js +12 -0
  130. package/dist/src/api/openai-codex-compact.d.ts +14 -0
  131. package/dist/src/api/openai-codex-compact.js +389 -0
  132. package/dist/src/api/openai-codex-compaction-error.d.ts +7 -0
  133. package/dist/src/api/openai-codex-compaction-error.js +6 -0
  134. package/dist/src/api/openai-codex-protocol.d.ts +125 -0
  135. package/dist/src/api/openai-codex-protocol.js +48 -0
  136. package/dist/src/api/openai-codex-responses.d.ts +4 -0
  137. package/dist/src/api/openai-codex-responses.js +175 -0
  138. package/dist/src/api/openai-codex-responses.lazy.d.ts +2 -0
  139. package/dist/src/api/openai-codex-responses.lazy.js +11 -0
  140. package/dist/src/api/openai-codex-websocket.d.ts +13 -0
  141. package/dist/src/api/openai-codex-websocket.js +37 -0
  142. package/dist/src/api/openai-codex-wire.d.ts +44 -0
  143. package/dist/src/api/openai-codex-wire.js +34 -0
  144. package/dist/src/api/openai-compact.d.ts +9 -0
  145. package/dist/src/api/openai-compact.js +12 -0
  146. package/dist/src/api/openai-completions-convert.d.ts +58 -0
  147. package/dist/src/api/openai-completions-convert.js +21 -0
  148. package/dist/src/api/openai-completions-params.d.ts +29 -0
  149. package/dist/src/api/openai-completions-params.js +20 -0
  150. package/dist/src/api/openai-completions-reasoning.d.ts +54 -0
  151. package/dist/src/api/openai-completions-reasoning.js +22 -0
  152. package/dist/src/api/openai-completions.d.ts +22 -0
  153. package/dist/src/api/openai-completions.js +484 -0
  154. package/dist/src/api/openai-completions.lazy.d.ts +5 -0
  155. package/dist/src/api/openai-completions.lazy.js +11 -0
  156. package/dist/src/api/openai-prompt-cache.d.ts +1 -0
  157. package/dist/src/api/openai-prompt-cache.js +6 -0
  158. package/dist/src/api/openai-responses-convert.d.ts +58 -0
  159. package/dist/src/api/openai-responses-convert.js +16 -0
  160. package/dist/src/api/openai-responses-events.d.ts +379 -0
  161. package/dist/src/api/openai-responses-events.js +12 -0
  162. package/dist/src/api/openai-responses-stream.d.ts +36 -0
  163. package/dist/src/api/openai-responses-stream.js +25 -0
  164. package/dist/src/api/openai-responses.d.ts +18 -0
  165. package/dist/src/api/openai-responses.js +276 -0
  166. package/dist/src/api/openai-responses.lazy.d.ts +2 -0
  167. package/dist/src/api/openai-responses.lazy.js +11 -0
  168. package/dist/src/api/simple-options.d.ts +17 -0
  169. package/dist/src/api/simple-options.js +18 -0
  170. package/dist/src/api/token-count.d.ts +5 -0
  171. package/dist/src/api/token-count.js +8 -0
  172. package/dist/src/api/transform-messages.d.ts +9 -0
  173. package/dist/src/api/transform-messages.js +6 -0
  174. package/dist/src/api-options.d.ts +27 -0
  175. package/dist/src/api-options.js +0 -0
  176. package/dist/src/auth/context.d.ts +11 -0
  177. package/dist/src/auth/context.js +6 -0
  178. package/dist/src/auth/credential-store.d.ts +17 -0
  179. package/dist/src/auth/credential-store.js +7 -0
  180. package/dist/src/auth/helpers.d.ts +24 -0
  181. package/dist/src/auth/helpers.js +8 -0
  182. package/dist/src/auth/oauth/anthropic.d.ts +7 -0
  183. package/dist/src/auth/oauth/anthropic.js +12 -0
  184. package/dist/src/auth/oauth/authorization-input.d.ts +14 -0
  185. package/dist/src/auth/oauth/authorization-input.js +6 -0
  186. package/dist/src/auth/oauth/device-code.d.ts +29 -0
  187. package/dist/src/auth/oauth/device-code.js +9 -0
  188. package/dist/src/auth/oauth/github-copilot.d.ts +23 -0
  189. package/dist/src/auth/oauth/github-copilot.js +12 -0
  190. package/dist/src/auth/oauth/load.d.ts +14 -0
  191. package/dist/src/auth/oauth/load.js +10 -0
  192. package/dist/src/auth/oauth/oauth-page.d.ts +13 -0
  193. package/dist/src/auth/oauth/oauth-page.js +8 -0
  194. package/dist/src/auth/oauth/openai-codex.d.ts +10 -0
  195. package/dist/src/auth/oauth/openai-codex.js +18 -0
  196. package/dist/src/auth/oauth/pkce.d.ts +12 -0
  197. package/dist/src/auth/oauth/pkce.js +6 -0
  198. package/dist/src/auth/resolve.d.ts +38 -0
  199. package/dist/src/auth/resolve.js +12 -0
  200. package/dist/src/auth/store.d.ts +29 -0
  201. package/dist/src/auth/store.js +10 -0
  202. package/dist/src/auth/types.d.ts +291 -0
  203. package/dist/src/auth/types.js +8 -0
  204. package/dist/src/auth/verify.d.ts +13 -0
  205. package/dist/src/auth/verify.js +7 -0
  206. package/dist/src/bun-oauth.d.ts +2 -0
  207. package/dist/src/bun-oauth.js +25 -0
  208. package/dist/src/env-api-keys.d.ts +32 -0
  209. package/dist/src/env-api-keys.js +27 -0
  210. package/dist/src/file-models-store.d.ts +18 -0
  211. package/dist/src/file-models-store.js +9 -0
  212. package/dist/src/index.d.ts +62 -0
  213. package/dist/src/index.js +372 -0
  214. package/dist/src/model-capabilities.d.ts +21 -0
  215. package/dist/src/model-capabilities.js +14 -0
  216. package/dist/src/model-pricing.d.ts +6 -0
  217. package/dist/src/model-pricing.js +10 -0
  218. package/dist/src/model-variants.d.ts +21 -0
  219. package/dist/src/model-variants.js +19 -0
  220. package/dist/src/models-refresh.d.ts +27 -0
  221. package/dist/src/models-refresh.js +9 -0
  222. package/dist/src/models-store.d.ts +31 -0
  223. package/dist/src/models-store.js +6 -0
  224. package/dist/src/models-types.d.ts +206 -0
  225. package/dist/src/models-types.js +0 -0
  226. package/dist/src/models.d.ts +7 -0
  227. package/dist/src/models.js +44 -0
  228. package/dist/src/prompt-cache.d.ts +5 -0
  229. package/dist/src/prompt-cache.js +9 -0
  230. package/dist/src/provider.d.ts +23 -0
  231. package/dist/src/provider.js +14 -0
  232. package/dist/src/providers/account-limits.d.ts +13 -0
  233. package/dist/src/providers/account-limits.js +8 -0
  234. package/dist/src/providers/anthropic-limits.d.ts +9 -0
  235. package/dist/src/providers/anthropic-limits.js +10 -0
  236. package/dist/src/providers/anthropic.d.ts +2 -0
  237. package/dist/src/providers/anthropic.js +25 -0
  238. package/dist/src/providers/github-copilot-catalog.d.ts +5 -0
  239. package/dist/src/providers/github-copilot-catalog.js +7 -0
  240. package/dist/src/providers/github-copilot.d.ts +2 -0
  241. package/dist/src/providers/github-copilot.js +23 -0
  242. package/dist/src/providers/nyte-catalog.d.ts +15 -0
  243. package/dist/src/providers/nyte-catalog.js +63 -0
  244. package/dist/src/providers/openai-codex-limits.d.ts +8 -0
  245. package/dist/src/providers/openai-codex-limits.js +14 -0
  246. package/dist/src/providers/openai-codex.d.ts +2 -0
  247. package/dist/src/providers/openai-codex.js +23 -0
  248. package/dist/src/providers/openai.d.ts +2 -0
  249. package/dist/src/providers/openai.js +19 -0
  250. package/dist/src/providers/opencode-go.d.ts +5 -0
  251. package/dist/src/providers/opencode-go.js +22 -0
  252. package/dist/src/providers/opencode-headers.d.ts +5 -0
  253. package/dist/src/providers/opencode-headers.js +6 -0
  254. package/dist/src/providers/opencode.d.ts +14 -0
  255. package/dist/src/providers/opencode.js +23 -0
  256. package/dist/src/providers/openrouter.d.ts +2 -0
  257. package/dist/src/providers/openrouter.js +19 -0
  258. package/dist/src/providers/vercel-ai-gateway.d.ts +3 -0
  259. package/dist/src/providers/vercel-ai-gateway.js +19 -0
  260. package/dist/src/session-resources.d.ts +9 -0
  261. package/dist/src/session-resources.js +10 -0
  262. package/dist/src/types.d.ts +210 -0
  263. package/dist/src/types.js +1 -0
  264. package/dist/src/utils/abort.d.ts +12 -0
  265. package/dist/src/utils/abort.js +10 -0
  266. package/dist/src/utils/deferred-tools.d.ts +11 -0
  267. package/dist/src/utils/deferred-tools.js +6 -0
  268. package/dist/src/utils/diagnostics.d.ts +11 -0
  269. package/dist/src/utils/diagnostics.js +12 -0
  270. package/dist/src/utils/error-body.d.ts +26 -0
  271. package/dist/src/utils/error-body.js +10 -0
  272. package/dist/src/utils/estimate.d.ts +20 -0
  273. package/dist/src/utils/estimate.js +14 -0
  274. package/dist/src/utils/event-stream.d.ts +22 -0
  275. package/dist/src/utils/event-stream.js +11 -0
  276. package/dist/src/utils/failure.d.ts +49 -0
  277. package/dist/src/utils/failure.js +10 -0
  278. package/dist/src/utils/fifo-queue.d.ts +11 -0
  279. package/dist/src/utils/fifo-queue.js +6 -0
  280. package/dist/src/utils/hash.d.ts +5 -0
  281. package/dist/src/utils/hash.js +6 -0
  282. package/dist/src/utils/headers.d.ts +12 -0
  283. package/dist/src/utils/headers.js +14 -0
  284. package/dist/src/utils/json-parse.d.ts +33 -0
  285. package/dist/src/utils/json-parse.js +12 -0
  286. package/dist/src/utils/node-http-proxy.d.ts +6 -0
  287. package/dist/src/utils/node-http-proxy.js +9 -0
  288. package/dist/src/utils/nyte-home.d.ts +2 -0
  289. package/dist/src/utils/nyte-home.js +6 -0
  290. package/dist/src/utils/nyte-user-agent.d.ts +1 -0
  291. package/dist/src/utils/nyte-user-agent.js +6 -0
  292. package/dist/src/utils/overflow.d.ts +18 -0
  293. package/dist/src/utils/overflow.js +9 -0
  294. package/dist/src/utils/provider-env.d.ts +9 -0
  295. package/dist/src/utils/provider-env.js +6 -0
  296. package/dist/src/utils/provider-retry.d.ts +22 -0
  297. package/dist/src/utils/provider-retry.js +9 -0
  298. package/dist/src/utils/retry.d.ts +66 -0
  299. package/dist/src/utils/retry.js +18 -0
  300. package/dist/src/utils/sanitize-unicode.d.ts +24 -0
  301. package/dist/src/utils/sanitize-unicode.js +6 -0
  302. package/dist/src/utils/sse.d.ts +21 -0
  303. package/dist/src/utils/sse.js +6 -0
  304. package/dist/src/utils/text.d.ts +5 -0
  305. package/dist/src/utils/text.js +10 -0
  306. package/dist/src/utils/transcript.d.ts +5 -0
  307. package/dist/src/utils/transcript.js +36 -0
  308. package/dist/src/utils/typebox-helpers.d.ts +19 -0
  309. package/dist/src/utils/typebox-helpers.js +6 -0
  310. package/dist/src/utils/uuid.d.ts +2 -0
  311. package/dist/src/utils/uuid.js +6 -0
  312. package/dist/src/utils/validation.d.ts +13 -0
  313. package/dist/src/utils/validation.js +8 -0
  314. package/package.json +152 -3
@@ -0,0 +1,314 @@
1
+ import {
2
+ shortHash2
3
+ } from "./account-limits-cache-0af5gqeg.js";
4
+ import {
5
+ sanitizeSurrogates2
6
+ } from "./account-limits-cache-eqwweapz.js";
7
+ import {
8
+ getSystemMessageText2,
9
+ renderSystemMessageUpdate2
10
+ } from "./account-limits-cache-b4edaybk.js";
11
+ import {
12
+ resolveTranscript2,
13
+ resolveTranscriptTools2
14
+ } from "./account-limits-cache-6250ykn6.js";
15
+ import {
16
+ getJsonSchemaToolParameters2,
17
+ getGrammarToolInput2,
18
+ resolveJsonSchemaStrictSampling2,
19
+ resolveGrammarConstrainedSampling2
20
+ } from "./account-limits-cache-h92bzz1j.js";
21
+ import {
22
+ transformMessages2
23
+ } from "./account-limits-cache-8qzk56vj.js";
24
+
25
+ // src/api/openai-responses-convert.ts
26
+ import { Type } from "typebox";
27
+ import { Value } from "typebox/value";
28
+ import { TextSignatureV1Schema } from "@nyte-ai/schema/model";
29
+ var ReplayedItemSchema = Type.Object({ type: Type.String() });
30
+ var CheckpointItemsSchema = Type.Array(ReplayedItemSchema);
31
+ var ReplayedReasoningSchema = Type.Object({ type: Type.Literal("reasoning") });
32
+ function encodeTextSignatureV12(id, phase) {
33
+ const payload = { v: 1, id };
34
+ if (phase)
35
+ payload.phase = phase;
36
+ return JSON.stringify(payload);
37
+ }
38
+ function parseTextSignature(signature) {
39
+ if (!signature)
40
+ return;
41
+ if (signature.startsWith("{")) {
42
+ try {
43
+ const parsed = JSON.parse(signature);
44
+ if (Value.Check(TextSignatureV1Schema, parsed))
45
+ return parsed;
46
+ } catch {}
47
+ }
48
+ return { id: signature };
49
+ }
50
+ function convertToolResultOutput(model, content) {
51
+ const textResult = content.flatMap((c) => c.type === "text" ? [c.text] : []).join(`
52
+ `);
53
+ const images = content.filter((c) => c.type === "image");
54
+ const hasText = textResult.length > 0;
55
+ if (images.length === 0 || !model.input.includes("image")) {
56
+ return sanitizeSurrogates2(hasText ? textResult : images.length > 0 ? "(see attached image)" : "(no tool output)");
57
+ }
58
+ const output = [];
59
+ if (hasText) {
60
+ output.push({ type: "input_text", text: sanitizeSurrogates2(textResult) });
61
+ }
62
+ for (const image of images) {
63
+ output.push({
64
+ type: "input_image",
65
+ detail: "auto",
66
+ image_url: `data:${image.mimeType};base64,${image.data}`
67
+ });
68
+ }
69
+ return output;
70
+ }
71
+ function convertResponsesMessages2(model, context, allowedToolCallProviders, options) {
72
+ const messages = [];
73
+ const normalizedContext = resolveTranscript2(context, options?.supportsMidConvoSystemMessages);
74
+ const checkpoint = normalizedContext.checkpoint;
75
+ if (checkpoint !== undefined) {
76
+ if (checkpoint.provider !== model.provider || checkpoint.api !== model.api || checkpoint.model !== model.id || !Value.Check(CheckpointItemsSchema, checkpoint.data)) {
77
+ throw new Error(`Checkpoint material does not match ${model.provider}/${model.id}`);
78
+ }
79
+ messages.push(...checkpoint.data);
80
+ }
81
+ const loadedToolNames = new Set;
82
+ const normalizeIdPart = (part) => {
83
+ const sanitized = part.replace(/[^a-zA-Z0-9_-]/g, "_");
84
+ const normalized = sanitized.length > 64 ? sanitized.slice(0, 64) : sanitized;
85
+ return normalized.replace(/_+$/, "");
86
+ };
87
+ const buildForeignResponsesItemId = (itemId) => {
88
+ const normalized = `fc_${shortHash2(itemId)}`;
89
+ return normalized.length > 64 ? normalized.slice(0, 64) : normalized;
90
+ };
91
+ const normalizeToolCallId = (id, _targetModel, source) => {
92
+ if (!allowedToolCallProviders.has(model.provider))
93
+ return normalizeIdPart(id);
94
+ if (!id.includes("|"))
95
+ return normalizeIdPart(id);
96
+ const [callId, itemId] = id.split("|");
97
+ const normalizedCallId = normalizeIdPart(callId);
98
+ const isForeignToolCall = source.provider !== model.provider || source.api !== model.api;
99
+ let normalizedItemId = isForeignToolCall ? buildForeignResponsesItemId(itemId) : normalizeIdPart(itemId);
100
+ if (!normalizedItemId.startsWith("fc_")) {
101
+ normalizedItemId = normalizeIdPart(`fc_${normalizedItemId}`);
102
+ }
103
+ return `${normalizedCallId}|${normalizedItemId}`;
104
+ };
105
+ const transformedMessages = transformMessages2(normalizedContext.messages, model, normalizeToolCallId);
106
+ const transcriptTools = resolveTranscriptTools2(normalizedContext.messages, options?.deferredToolsMode !== undefined);
107
+ const pushToolLoad = (tools, seed) => {
108
+ if (tools.length === 0 || options?.deferredToolsMode === undefined)
109
+ return;
110
+ if (options.deferredToolsMode === "additional-tools") {
111
+ messages.push({
112
+ type: "additional_tools",
113
+ role: "developer",
114
+ tools: convertResponsesTools2(tools, options.toolOptions)
115
+ });
116
+ return;
117
+ }
118
+ const names = tools.map((tool) => tool.name);
119
+ const callId = `pi_tool_load_${shortHash2(`${seed}:${names.join(",")}`)}`;
120
+ messages.push({
121
+ type: "tool_search_call",
122
+ call_id: callId,
123
+ execution: "client",
124
+ status: "completed",
125
+ arguments: { query: names.join(" "), limit: names.length }
126
+ });
127
+ messages.push({
128
+ type: "tool_search_output",
129
+ call_id: callId,
130
+ execution: "client",
131
+ status: "completed",
132
+ tools: convertResponsesTools2(tools, { ...options.toolOptions, deferLoading: true })
133
+ });
134
+ };
135
+ const appendSystemToolAdditions = (message, seed) => {
136
+ const tools = transcriptTools.anchorsAdditions ? message.toolsAdded ?? [] : [];
137
+ for (const tool of tools)
138
+ loadedToolNames.add(tool.name);
139
+ pushToolLoad(tools, seed);
140
+ };
141
+ const includeInitialSystemMessage = options?.includeSystemPrompt ?? true;
142
+ const instructionRole = model.reasoning && model.compat?.supportsDeveloperRole !== false ? "developer" : "system";
143
+ let msgIndex = 0;
144
+ let sourceIndex = 0;
145
+ for (const msg of transformedMessages) {
146
+ const isLeadingSystemMessage = sourceIndex++ === 0 && msg.role === "system";
147
+ if (msg.role === "system") {
148
+ if (!isLeadingSystemMessage)
149
+ appendSystemToolAdditions(msg, `system:${msgIndex}`);
150
+ if (!isLeadingSystemMessage || includeInitialSystemMessage) {
151
+ const text = isLeadingSystemMessage ? getSystemMessageText2(msg) : renderSystemMessageUpdate2(msg);
152
+ if (text.length > 0) {
153
+ messages.push({ role: instructionRole, content: sanitizeSurrogates2(text) });
154
+ }
155
+ }
156
+ } else if (msg.role === "user") {
157
+ if (!Array.isArray(msg.content)) {
158
+ messages.push({
159
+ role: "user",
160
+ content: [{ type: "input_text", text: sanitizeSurrogates2(msg.content) }]
161
+ });
162
+ } else {
163
+ const content = msg.content.map((item) => {
164
+ if (item.type === "text") {
165
+ return {
166
+ type: "input_text",
167
+ text: sanitizeSurrogates2(item.text)
168
+ };
169
+ }
170
+ return {
171
+ type: "input_image",
172
+ detail: "auto",
173
+ image_url: `data:${item.mimeType};base64,${item.data}`
174
+ };
175
+ });
176
+ if (content.length === 0)
177
+ continue;
178
+ messages.push({
179
+ role: "user",
180
+ content
181
+ });
182
+ }
183
+ } else if (msg.role === "assistant") {
184
+ const output = [];
185
+ const isSameProviderAndApi = msg.provider === model.provider && msg.api === model.api;
186
+ const isSameModel = isSameProviderAndApi && msg.model === model.id;
187
+ const isDifferentModel = isSameProviderAndApi && msg.model !== model.id;
188
+ let textBlockIndex = 0;
189
+ for (const block of msg.content) {
190
+ if (block.type === "thinking") {
191
+ const reasoningItem = block.thinkingSignature ? JSON.parse(block.thinkingSignature) : undefined;
192
+ if (Value.Check(ReplayedReasoningSchema, reasoningItem))
193
+ output.push(reasoningItem);
194
+ } else if (block.type === "text") {
195
+ const parsedSignature = parseTextSignature(block.textSignature);
196
+ const fallbackMessageId = textBlockIndex === 0 ? `msg_pi_${msgIndex}` : `msg_pi_${msgIndex}_${textBlockIndex}`;
197
+ textBlockIndex++;
198
+ let msgId = parsedSignature?.id;
199
+ if (!msgId) {
200
+ msgId = fallbackMessageId;
201
+ } else if (msgId.length > 64) {
202
+ msgId = `msg_${shortHash2(msgId)}`;
203
+ }
204
+ output.push({
205
+ type: "message",
206
+ role: "assistant",
207
+ content: [
208
+ { type: "output_text", text: sanitizeSurrogates2(block.text), annotations: [] }
209
+ ],
210
+ status: "completed",
211
+ id: msgId,
212
+ phase: parsedSignature?.phase
213
+ });
214
+ } else if (block.type === "toolCall") {
215
+ const [callId, itemIdRaw] = block.id.split("|");
216
+ const customInputProperty = options?.grammarToolInputProperties?.get(block.name);
217
+ let itemId = itemIdRaw;
218
+ const itemIdPrefix = customInputProperty === undefined ? "fc_" : "ctc_";
219
+ if (isDifferentModel || !itemId?.startsWith(itemIdPrefix)) {
220
+ itemId = undefined;
221
+ }
222
+ const canReplayNamespace = isSameModel || options?.deferredTools?.has(block.name) === true;
223
+ const call = customInputProperty === undefined ? {
224
+ type: "function_call",
225
+ id: itemId,
226
+ call_id: callId,
227
+ name: block.name,
228
+ arguments: JSON.stringify(block.arguments)
229
+ } : {
230
+ type: "custom_tool_call",
231
+ id: itemId,
232
+ call_id: callId,
233
+ name: block.name,
234
+ input: sanitizeSurrogates2(getGrammarToolInput2(block.name, block.arguments, customInputProperty))
235
+ };
236
+ if (canReplayNamespace && block.namespace !== undefined) {
237
+ call.namespace = block.namespace;
238
+ }
239
+ output.push(call);
240
+ }
241
+ }
242
+ if (output.length === 0)
243
+ continue;
244
+ messages.push(...output);
245
+ } else if (msg.role === "toolResult") {
246
+ const [callId] = msg.toolCallId.split("|");
247
+ const output = convertToolResultOutput(model, msg.content);
248
+ if (options?.grammarToolInputProperties?.has(msg.toolName)) {
249
+ messages.push({
250
+ type: "custom_tool_call_output",
251
+ call_id: callId,
252
+ output
253
+ });
254
+ } else {
255
+ messages.push({
256
+ type: "function_call_output",
257
+ call_id: callId,
258
+ output
259
+ });
260
+ }
261
+ const deferredTools = [];
262
+ for (const name of msg.addedToolNames ?? []) {
263
+ const tool = options?.deferredTools?.get(name);
264
+ if (!tool || loadedToolNames.has(name))
265
+ continue;
266
+ loadedToolNames.add(name);
267
+ deferredTools.push(tool);
268
+ }
269
+ pushToolLoad(deferredTools, msg.toolCallId);
270
+ }
271
+ if (!isLeadingSystemMessage)
272
+ msgIndex++;
273
+ }
274
+ return messages;
275
+ }
276
+ function convertResponsesTools2(tools, options) {
277
+ const defaultStrict = options?.strict === undefined ? false : options.strict;
278
+ const supportsStrictMode = options?.supportsStrictMode ?? true;
279
+ const supportsOpenAIGrammarTools = options?.supportsOpenAIGrammarTools ?? false;
280
+ return tools.map((tool) => {
281
+ const grammar = resolveGrammarConstrainedSampling2(tool, supportsOpenAIGrammarTools);
282
+ if (grammar) {
283
+ const customTool = {
284
+ type: "custom",
285
+ name: tool.name,
286
+ description: tool.description,
287
+ format: {
288
+ type: "grammar",
289
+ syntax: grammar.format,
290
+ definition: grammar.definition
291
+ }
292
+ };
293
+ if (options?.deferLoading)
294
+ customTool.defer_loading = true;
295
+ return customTool;
296
+ }
297
+ const constrainedStrict = resolveJsonSchemaStrictSampling2(tool, supportsStrictMode);
298
+ const strict = constrainedStrict ?? defaultStrict;
299
+ const functionTool = {
300
+ type: "function",
301
+ name: tool.name,
302
+ description: tool.description,
303
+ parameters: getJsonSchemaToolParameters2(tool, strict === true)
304
+ };
305
+ if (options?.deferLoading)
306
+ functionTool.defer_loading = true;
307
+ if (supportsStrictMode) {
308
+ functionTool.strict = strict;
309
+ }
310
+ return functionTool;
311
+ });
312
+ }
313
+
314
+ export { encodeTextSignatureV12, convertResponsesMessages2, convertResponsesTools2 };
@@ -0,0 +1,72 @@
1
+ import {
2
+ sleep2
3
+ } from "./account-limits-cache-j2bt392s.js";
4
+
5
+ // src/utils/provider-retry.ts
6
+ var DEFAULT_MAX_RETRY_DELAY_MS = 60000;
7
+
8
+ class RetryDelayExceededError2 extends Error {
9
+ }
10
+ function carriesHttpStatus(error) {
11
+ if (!(error instanceof Error) || !("status" in error) || !("headers" in error))
12
+ return false;
13
+ return (error.status === undefined || typeof error.status === "number") && (error.headers === undefined || error.headers instanceof Headers);
14
+ }
15
+ function sdkPolicyRetries(error) {
16
+ const shouldRetry = error.headers?.get("x-should-retry");
17
+ if (shouldRetry === "true")
18
+ return true;
19
+ if (shouldRetry === "false")
20
+ return false;
21
+ if (error.status === undefined)
22
+ return true;
23
+ return error.status === 408 || error.status === 409 || error.status === 429 || error.status >= 500;
24
+ }
25
+ function validateServerRetryDelayMs(delayMs, maxRetryDelayMs, providerErrorMessage) {
26
+ const maxDelayMs = maxRetryDelayMs ?? DEFAULT_MAX_RETRY_DELAY_MS;
27
+ if (maxDelayMs > 0 && delayMs > maxDelayMs) {
28
+ throw new RetryDelayExceededError2(`Server requested ${Math.ceil(delayMs / 1000)}s retry delay (max: ${Math.ceil(maxDelayMs / 1000)}s). ${providerErrorMessage}`);
29
+ }
30
+ return delayMs;
31
+ }
32
+ function getRetryDelayMs(error, retryIndex, maxRetryDelayMs) {
33
+ const retryAfterMs = error.headers?.get("retry-after-ms");
34
+ if (retryAfterMs) {
35
+ const value = Number.parseFloat(retryAfterMs);
36
+ if (Number.isFinite(value))
37
+ return validateServerRetryDelayMs(value, maxRetryDelayMs, error.message);
38
+ }
39
+ const retryAfter = error.headers?.get("retry-after");
40
+ if (retryAfter) {
41
+ const seconds = Number.parseFloat(retryAfter);
42
+ const delayMs = Number.isNaN(seconds) ? Date.parse(retryAfter) - Date.now() : seconds * 1000;
43
+ if (Number.isFinite(delayMs))
44
+ return validateServerRetryDelayMs(delayMs, maxRetryDelayMs, error.message);
45
+ }
46
+ const exponentialDelay = Math.min(0.5 * 2 ** retryIndex, 8) * 1000;
47
+ return exponentialDelay * (1 - Math.random() * 0.25);
48
+ }
49
+ function createAbortError() {
50
+ const error = new Error("Request aborted");
51
+ error.name = "AbortError";
52
+ return error;
53
+ }
54
+ async function retryProviderRequest2(request, options = {}) {
55
+ const maxRetries = options.maxRetries ?? 0;
56
+ let retriesRemaining = maxRetries;
57
+ for (;; ) {
58
+ try {
59
+ return await request();
60
+ } catch (error) {
61
+ if (options.signal?.aborted)
62
+ throw createAbortError();
63
+ if (retriesRemaining <= 0 || !carriesHttpStatus(error) || !sdkPolicyRetries(error) || options.retryable?.(error) === false)
64
+ throw error;
65
+ const retryIndex = maxRetries - retriesRemaining;
66
+ retriesRemaining--;
67
+ await sleep2(getRetryDelayMs(error, retryIndex, options.maxRetryDelayMs), options.signal, createAbortError);
68
+ }
69
+ }
70
+ }
71
+
72
+ export { RetryDelayExceededError2, retryProviderRequest2 };
@@ -0,0 +1,42 @@
1
+ import {
2
+ anthropicMessagesApi2
3
+ } from "./account-limits-cache-zqdb4yh4.js";
4
+ import {
5
+ googleGenerativeAIApi2
6
+ } from "./account-limits-cache-x9fvb3s5.js";
7
+ import {
8
+ openAICompletionsApi2
9
+ } from "./account-limits-cache-eyx1jcxc.js";
10
+ import {
11
+ openAIResponsesApi2
12
+ } from "./account-limits-cache-q1ebtvet.js";
13
+ import {
14
+ envApiKeyAuth2
15
+ } from "./account-limits-cache-6x05n06z.js";
16
+ import {
17
+ createProvider2
18
+ } from "./account-limits-cache-ykbqsvv6.js";
19
+ import {
20
+ withOpenCodeSessionHeader2
21
+ } from "./account-limits-cache-fht68jp2.js";
22
+
23
+ // src/providers/opencode.ts
24
+ var OPENCODE_PROMPT_CACHE2 = {
25
+ minimumRetentionMs: { short: 5 * 60000, long: 5 * 60000 }
26
+ };
27
+ function opencodeProvider2() {
28
+ return createProvider2({
29
+ id: "opencode",
30
+ name: "OpenCode Zen",
31
+ promptCache: OPENCODE_PROMPT_CACHE2,
32
+ auth: { apiKey: envApiKeyAuth2("OpenCode API key", ["OPENCODE_API_KEY"]) },
33
+ api: {
34
+ "anthropic-messages": withOpenCodeSessionHeader2(anthropicMessagesApi2()),
35
+ "google-generative-ai": withOpenCodeSessionHeader2(googleGenerativeAIApi2()),
36
+ "openai-completions": withOpenCodeSessionHeader2(openAICompletionsApi2()),
37
+ "openai-responses": withOpenCodeSessionHeader2(openAIResponsesApi2())
38
+ }
39
+ });
40
+ }
41
+
42
+ export { OPENCODE_PROMPT_CACHE2, opencodeProvider2 };
@@ -0,0 +1,26 @@
1
+ // src/utils/fifo-queue.ts
2
+ class FifoQueue2 {
3
+ incoming = [];
4
+ outgoing = [];
5
+ get length() {
6
+ return this.incoming.length + this.outgoing.length;
7
+ }
8
+ enqueue(value) {
9
+ this.incoming.push(value);
10
+ }
11
+ dequeue() {
12
+ if (this.outgoing.length === 0) {
13
+ const drained = this.incoming;
14
+ drained.reverse();
15
+ this.incoming = this.outgoing;
16
+ this.outgoing = drained;
17
+ }
18
+ return this.outgoing.pop();
19
+ }
20
+ clear() {
21
+ this.incoming = [];
22
+ this.outgoing = [];
23
+ }
24
+ }
25
+
26
+ export { FifoQueue2 };
@@ -0,0 +1,13 @@
1
+ import {
2
+ classifyAssistantFailure2
3
+ } from "./account-limits-cache-xds88kxd.js";
4
+
5
+ // src/utils/overflow.ts
6
+ function overflowsContext2(message, contextWindow) {
7
+ return classifyAssistantFailure2(message, contextWindow === undefined ? undefined : { contextWindow }).class === "context_window";
8
+ }
9
+ function stoppedShort2(message, desiredMaxOutput) {
10
+ return message.stopReason === "length" && desiredMaxOutput > 0 && message.usage.output < desiredMaxOutput;
11
+ }
12
+
13
+ export { overflowsContext2, stoppedShort2 };
@@ -0,0 +1,38 @@
1
+ import {
2
+ anthropicMessagesApi2
3
+ } from "./account-limits-cache-zqdb4yh4.js";
4
+ import {
5
+ openAICompletionsApi2
6
+ } from "./account-limits-cache-eyx1jcxc.js";
7
+ import {
8
+ openAIResponsesApi2
9
+ } from "./account-limits-cache-q1ebtvet.js";
10
+ import {
11
+ envApiKeyAuth2
12
+ } from "./account-limits-cache-6x05n06z.js";
13
+ import {
14
+ createProvider2
15
+ } from "./account-limits-cache-ykbqsvv6.js";
16
+ import {
17
+ withOpenCodeSessionHeader2
18
+ } from "./account-limits-cache-fht68jp2.js";
19
+ import {
20
+ OPENCODE_PROMPT_CACHE2
21
+ } from "./account-limits-cache-nbkyhs6v.js";
22
+
23
+ // src/providers/opencode-go.ts
24
+ function opencodeGoProvider2() {
25
+ return createProvider2({
26
+ id: "opencode-go",
27
+ name: "OpenCode Go",
28
+ promptCache: OPENCODE_PROMPT_CACHE2,
29
+ auth: { apiKey: envApiKeyAuth2("OpenCode API key", ["OPENCODE_API_KEY"]) },
30
+ api: {
31
+ "anthropic-messages": withOpenCodeSessionHeader2(anthropicMessagesApi2()),
32
+ "openai-completions": withOpenCodeSessionHeader2(openAICompletionsApi2()),
33
+ "openai-responses": withOpenCodeSessionHeader2(openAIResponsesApi2())
34
+ }
35
+ });
36
+ }
37
+
38
+ export { opencodeGoProvider2 };
@@ -0,0 +1,45 @@
1
+ import {
2
+ openAICompletionsApi2
3
+ } from "./account-limits-cache-eyx1jcxc.js";
4
+ import {
5
+ envApiKeyAuth2
6
+ } from "./account-limits-cache-6x05n06z.js";
7
+ import {
8
+ verifyWithRequest2
9
+ } from "./account-limits-cache-ydq8p8qp.js";
10
+ import {
11
+ createProvider2
12
+ } from "./account-limits-cache-ykbqsvv6.js";
13
+
14
+ // src/providers/openrouter.ts
15
+ var OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
16
+ function openrouterProvider2() {
17
+ return createProvider2({
18
+ id: "openrouter",
19
+ name: "OpenRouter",
20
+ baseUrl: OPENROUTER_BASE_URL,
21
+ auth: {
22
+ apiKey: envApiKeyAuth2("OpenRouter API key", ["OPENROUTER_API_KEY"]),
23
+ verify: ({ auth, signal }) => verifyWithRequest2({
24
+ provider: "OpenRouter",
25
+ url: `${auth.baseUrl ?? OPENROUTER_BASE_URL}/key`,
26
+ headers: { ...auth.headers, Authorization: `Bearer ${auth.apiKey ?? ""}` },
27
+ signal,
28
+ detail: (body) => {
29
+ if (typeof body !== "object" || body === null || !("data" in body))
30
+ return;
31
+ const key = body.data;
32
+ if (typeof key !== "object" || key === null)
33
+ return;
34
+ if (!("limit" in key) || typeof key.limit !== "number")
35
+ return "no credit limit";
36
+ const remaining = "limit_remaining" in key && typeof key.limit_remaining === "number" ? `, ${String(key.limit_remaining)} remaining` : "";
37
+ return `credit limit ${String(key.limit)}${remaining}`;
38
+ }
39
+ })
40
+ },
41
+ api: { "openai-completions": openAICompletionsApi2() }
42
+ });
43
+ }
44
+
45
+ export { openrouterProvider2 };
@@ -0,0 +1,59 @@
1
+ import {
2
+ applyServiceTierPricing2
3
+ } from "./account-limits-cache-f9z00x8c.js";
4
+ import {
5
+ calculateCost2
6
+ } from "./account-limits-cache-zgzptd0z.js";
7
+ import {
8
+ emptyCost2
9
+ } from "./account-limits-cache-fsktnetm.js";
10
+
11
+ // src/api/openai-compact.ts
12
+ import { Type } from "typebox";
13
+ import { Value } from "typebox/value";
14
+ var tokenCount = Type.Number({ minimum: 0 });
15
+ var compactResponse = Type.Object({
16
+ output: Type.Array(Type.Object({ type: Type.String({ minLength: 1 }) }), { minItems: 1 }),
17
+ service_tier: Type.Optional(Type.Union([
18
+ Type.Literal("auto"),
19
+ Type.Literal("default"),
20
+ Type.Literal("flex"),
21
+ Type.Literal("priority"),
22
+ Type.Null()
23
+ ])),
24
+ usage: Type.Optional(Type.Object({
25
+ input_tokens: tokenCount,
26
+ output_tokens: tokenCount,
27
+ total_tokens: tokenCount,
28
+ input_tokens_details: Type.Optional(Type.Object({
29
+ cached_tokens: Type.Optional(tokenCount),
30
+ cache_write_tokens: Type.Optional(tokenCount)
31
+ })),
32
+ output_tokens_details: Type.Optional(Type.Object({ reasoning_tokens: Type.Optional(tokenCount) }))
33
+ }))
34
+ });
35
+ async function readOpenAICompactResponse2(response, model, requestedServiceTier) {
36
+ const decoded = await response.json();
37
+ if (!Value.Check(compactResponse, decoded)) {
38
+ throw new Error("OpenAI compact response did not contain valid output items and usage");
39
+ }
40
+ const data = decoded.output;
41
+ if (decoded.usage === undefined)
42
+ return { data };
43
+ const cached = decoded.usage.input_tokens_details?.cached_tokens ?? 0;
44
+ const written = decoded.usage.input_tokens_details?.cache_write_tokens ?? 0;
45
+ const usage = {
46
+ input: Math.max(0, decoded.usage.input_tokens - cached - written),
47
+ output: decoded.usage.output_tokens,
48
+ cacheRead: cached,
49
+ cacheWrite: written,
50
+ reasoning: decoded.usage.output_tokens_details?.reasoning_tokens ?? 0,
51
+ totalTokens: decoded.usage.total_tokens,
52
+ cost: emptyCost2()
53
+ };
54
+ calculateCost2(model, usage);
55
+ applyServiceTierPricing2(usage, decoded.service_tier ?? requestedServiceTier, model);
56
+ return { data, usage };
57
+ }
58
+
59
+ export { readOpenAICompactResponse2 };
@@ -0,0 +1,8 @@
1
+ import {
2
+ lazyApi2
3
+ } from "./account-limits-cache-90c9c2eb.js";
4
+
5
+ // src/api/openai-responses.lazy.ts
6
+ var openAIResponsesApi2 = () => lazyApi2(() => import("../src/api/openai-responses.js"));
7
+
8
+ export { openAIResponsesApi2 };
@@ -0,0 +1,51 @@
1
+ import {
2
+ anthropicMessagesApi2
3
+ } from "./account-limits-cache-zqdb4yh4.js";
4
+ import {
5
+ envApiKeyAuth2
6
+ } from "./account-limits-cache-6x05n06z.js";
7
+ import {
8
+ verifyWithRequest2
9
+ } from "./account-limits-cache-ydq8p8qp.js";
10
+ import {
11
+ createProvider2
12
+ } from "./account-limits-cache-ykbqsvv6.js";
13
+
14
+ // src/providers/vercel-ai-gateway.ts
15
+ var VERCEL_AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh";
16
+ function vercelAiGatewayProvider2() {
17
+ const apiKey = envApiKeyAuth2("Vercel AI Gateway API key", [
18
+ "AI_GATEWAY_API_KEY",
19
+ "VERCEL_OIDC_TOKEN"
20
+ ]);
21
+ return createProvider2({
22
+ id: "vercel-ai-gateway",
23
+ name: "Vercel AI Gateway",
24
+ baseUrl: VERCEL_AI_GATEWAY_BASE_URL,
25
+ auth: {
26
+ apiKey: {
27
+ ...apiKey,
28
+ resolve: async (input) => {
29
+ const result = await apiKey.resolve(input);
30
+ if (!result?.auth.apiKey)
31
+ return result;
32
+ const { apiKey: key, ...auth } = result.auth;
33
+ return {
34
+ ...result,
35
+ auth: { ...auth, headers: { ...auth.headers, Authorization: `Bearer ${key}` } }
36
+ };
37
+ }
38
+ },
39
+ verify: ({ auth, signal }) => verifyWithRequest2({
40
+ provider: "Vercel AI Gateway",
41
+ url: `${auth.baseUrl ?? VERCEL_AI_GATEWAY_BASE_URL}/v1/credits`,
42
+ headers: auth.headers ?? {},
43
+ signal,
44
+ detail: (body) => typeof body === "object" && body !== null && ("balance" in body) && typeof body.balance === "string" ? `balance ${body.balance}` : undefined
45
+ })
46
+ },
47
+ api: { "anthropic-messages": anthropicMessagesApi2() }
48
+ });
49
+ }
50
+
51
+ export { vercelAiGatewayProvider2 };