@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,379 @@
1
+ /**
2
+ * The Responses stream events the shared processor acts on, as TypeBox schemas. Both the
3
+ * OpenAI SDK stream and Codex's raw frames are checked against them once, at the processor's
4
+ * ingress; events of other types, or missing the fields read, are skipped.
5
+ */
6
+ import { type Static, Type } from "typebox";
7
+ declare const OutputItemSchema: Type.TUnion<[Type.TObject<{
8
+ type: Type.TLiteral<"reasoning">;
9
+ id: Type.TString;
10
+ summary: Type.TOptional<Type.TArray<Type.TObject<{
11
+ text: Type.TString;
12
+ }>>>;
13
+ content: Type.TOptional<Type.TArray<Type.TObject<{
14
+ text: Type.TString;
15
+ }>>>;
16
+ encrypted_content: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
17
+ }>, Type.TObject<{
18
+ type: Type.TLiteral<"message">;
19
+ id: Type.TOptional<Type.TString>;
20
+ phase: Type.TOptional<Type.TUnion<[Type.TLiteral<"commentary">, Type.TLiteral<"final_answer">, Type.TNull]>>;
21
+ content: Type.TOptional<Type.TArray<Type.TUnion<[Type.TObject<{
22
+ type: Type.TLiteral<"output_text">;
23
+ text: Type.TString;
24
+ }>, Type.TObject<{
25
+ type: Type.TLiteral<"refusal">;
26
+ refusal: Type.TString;
27
+ }>]>>>;
28
+ }>, Type.TObject<{
29
+ type: Type.TLiteral<"function_call">;
30
+ id: Type.TOptional<Type.TString>;
31
+ call_id: Type.TString;
32
+ name: Type.TString;
33
+ arguments: Type.TOptional<Type.TString>;
34
+ namespace: Type.TOptional<Type.TString>;
35
+ }>, Type.TObject<{
36
+ type: Type.TLiteral<"custom_tool_call">;
37
+ id: Type.TOptional<Type.TString>;
38
+ call_id: Type.TString;
39
+ name: Type.TString;
40
+ input: Type.TOptional<Type.TString>;
41
+ namespace: Type.TOptional<Type.TString>;
42
+ }>]>;
43
+ export type ResponsesOutputItem = Static<typeof OutputItemSchema>;
44
+ /** A reasoning item in a terminal response's output, for backfilling its encrypted content. */
45
+ export declare const TerminalReasoningItemSchema: Type.TObject<{
46
+ type: Type.TLiteral<"reasoning">;
47
+ id: Type.TString;
48
+ encrypted_content: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
49
+ }>;
50
+ /** A stored reasoning item: what the processor serialized into a thinking signature. */
51
+ export declare const StoredReasoningItemSchema: Type.TObject<{
52
+ type: Type.TLiteral<"reasoning">;
53
+ encrypted_content: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
54
+ }>;
55
+ declare const ResponseStatusSchema: Type.TUnion<[Type.TLiteral<"completed">, Type.TLiteral<"failed">, Type.TLiteral<"in_progress">, Type.TLiteral<"cancelled">, Type.TLiteral<"queued">, Type.TLiteral<"incomplete">]>;
56
+ export type ResponsesStatus = Static<typeof ResponseStatusSchema>;
57
+ /** A service tier as the Responses API reports it; GPT-6 reports Fast mode as `fast`. */
58
+ export declare const ServiceTierSchema: Type.TUnion<[Type.TLiteral<"auto">, Type.TLiteral<"default">, Type.TLiteral<"flex">, Type.TLiteral<"scale">, Type.TLiteral<"priority">, Type.TLiteral<"fast">, Type.TNull]>;
59
+ export type ResponsesServiceTier = Static<typeof ServiceTierSchema>;
60
+ /**
61
+ * The terminal response metadata the processor reads. Usage and service tier stay unknown
62
+ * here: the finalizer validates usage itself so an invalid count fails as a usage error, and an
63
+ * unrecognized tier is ignored rather than dropping the terminal event.
64
+ */
65
+ declare const TerminalResponseSchema: Type.TObject<{
66
+ id: Type.TOptional<Type.TString>;
67
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"completed">, Type.TLiteral<"failed">, Type.TLiteral<"in_progress">, Type.TLiteral<"cancelled">, Type.TLiteral<"queued">, Type.TLiteral<"incomplete">]>>;
68
+ incomplete_details: Type.TOptional<Type.TUnion<[Type.TObject<{
69
+ reason: Type.TOptional<Type.TString>;
70
+ }>, Type.TNull]>>;
71
+ error: Type.TOptional<Type.TUnion<[Type.TObject<{
72
+ code: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
73
+ message: Type.TOptional<Type.TString>;
74
+ }>, Type.TNull]>>;
75
+ output: Type.TOptional<Type.TArray<Type.TUnknown>>;
76
+ usage: Type.TOptional<Type.TUnknown>;
77
+ service_tier: Type.TOptional<Type.TUnknown>;
78
+ }>;
79
+ export type ResponsesTerminalResponse = Static<typeof TerminalResponseSchema>;
80
+ /** Checks a raw event; compiled once because it runs for every streamed delta. */
81
+ export declare const ResponsesStreamEventCheck: import("typebox/compile").Validator<{}, Type.TUnion<[Type.TObject<{
82
+ type: Type.TLiteral<"response.created">;
83
+ response: Type.TObject<{
84
+ id: Type.TOptional<Type.TString>;
85
+ }>;
86
+ }>, Type.TObject<{
87
+ type: Type.TUnion<[Type.TLiteral<"response.output_item.added">, Type.TLiteral<"response.output_item.done">]>;
88
+ output_index: Type.TOptional<Type.TNumber>;
89
+ item: Type.TUnion<[Type.TObject<{
90
+ type: Type.TLiteral<"reasoning">;
91
+ id: Type.TString;
92
+ summary: Type.TOptional<Type.TArray<Type.TObject<{
93
+ text: Type.TString;
94
+ }>>>;
95
+ content: Type.TOptional<Type.TArray<Type.TObject<{
96
+ text: Type.TString;
97
+ }>>>;
98
+ encrypted_content: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
99
+ }>, Type.TObject<{
100
+ type: Type.TLiteral<"message">;
101
+ id: Type.TOptional<Type.TString>;
102
+ phase: Type.TOptional<Type.TUnion<[Type.TLiteral<"commentary">, Type.TLiteral<"final_answer">, Type.TNull]>>;
103
+ content: Type.TOptional<Type.TArray<Type.TUnion<[Type.TObject<{
104
+ type: Type.TLiteral<"output_text">;
105
+ text: Type.TString;
106
+ }>, Type.TObject<{
107
+ type: Type.TLiteral<"refusal">;
108
+ refusal: Type.TString;
109
+ }>]>>>;
110
+ }>, Type.TObject<{
111
+ type: Type.TLiteral<"function_call">;
112
+ id: Type.TOptional<Type.TString>;
113
+ call_id: Type.TString;
114
+ name: Type.TString;
115
+ arguments: Type.TOptional<Type.TString>;
116
+ namespace: Type.TOptional<Type.TString>;
117
+ }>, Type.TObject<{
118
+ type: Type.TLiteral<"custom_tool_call">;
119
+ id: Type.TOptional<Type.TString>;
120
+ call_id: Type.TString;
121
+ name: Type.TString;
122
+ input: Type.TOptional<Type.TString>;
123
+ namespace: Type.TOptional<Type.TString>;
124
+ }>]>;
125
+ }>, Type.TObject<{
126
+ type: Type.TLiteral<"response.reasoning_summary_text.delta">;
127
+ output_index: Type.TOptional<Type.TNumber>;
128
+ delta: Type.TString;
129
+ }>, Type.TObject<{
130
+ type: Type.TLiteral<"response.reasoning_summary_part.done">;
131
+ output_index: Type.TOptional<Type.TNumber>;
132
+ }>, Type.TObject<{
133
+ type: Type.TLiteral<"response.reasoning_text.delta">;
134
+ output_index: Type.TOptional<Type.TNumber>;
135
+ delta: Type.TString;
136
+ }>, Type.TObject<{
137
+ type: Type.TLiteral<"response.output_text.delta">;
138
+ output_index: Type.TOptional<Type.TNumber>;
139
+ delta: Type.TString;
140
+ }>, Type.TObject<{
141
+ type: Type.TLiteral<"response.refusal.delta">;
142
+ output_index: Type.TOptional<Type.TNumber>;
143
+ delta: Type.TString;
144
+ }>, Type.TObject<{
145
+ type: Type.TLiteral<"response.function_call_arguments.delta">;
146
+ output_index: Type.TOptional<Type.TNumber>;
147
+ delta: Type.TString;
148
+ }>, Type.TObject<{
149
+ type: Type.TLiteral<"response.function_call_arguments.done">;
150
+ output_index: Type.TOptional<Type.TNumber>;
151
+ arguments: Type.TString;
152
+ }>, Type.TObject<{
153
+ type: Type.TLiteral<"response.custom_tool_call_input.delta">;
154
+ output_index: Type.TOptional<Type.TNumber>;
155
+ delta: Type.TString;
156
+ }>, Type.TObject<{
157
+ type: Type.TLiteral<"response.custom_tool_call_input.done">;
158
+ output_index: Type.TOptional<Type.TNumber>;
159
+ input: Type.TString;
160
+ }>, Type.TObject<{
161
+ type: Type.TUnion<[Type.TLiteral<"response.completed">, Type.TLiteral<"response.incomplete">, Type.TLiteral<"response.failed">]>;
162
+ response: Type.TObject<{
163
+ id: Type.TOptional<Type.TString>;
164
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"completed">, Type.TLiteral<"failed">, Type.TLiteral<"in_progress">, Type.TLiteral<"cancelled">, Type.TLiteral<"queued">, Type.TLiteral<"incomplete">]>>;
165
+ incomplete_details: Type.TOptional<Type.TUnion<[Type.TObject<{
166
+ reason: Type.TOptional<Type.TString>;
167
+ }>, Type.TNull]>>;
168
+ error: Type.TOptional<Type.TUnion<[Type.TObject<{
169
+ code: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
170
+ message: Type.TOptional<Type.TString>;
171
+ }>, Type.TNull]>>;
172
+ output: Type.TOptional<Type.TArray<Type.TUnknown>>;
173
+ usage: Type.TOptional<Type.TUnknown>;
174
+ service_tier: Type.TOptional<Type.TUnknown>;
175
+ }>;
176
+ }>, Type.TObject<{
177
+ type: Type.TLiteral<"error">;
178
+ code: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
179
+ message: Type.TOptional<Type.TString>;
180
+ }>]>, {
181
+ type: "response.created";
182
+ response: {
183
+ id?: string | undefined;
184
+ };
185
+ } | {
186
+ output_index?: number | undefined;
187
+ type: "response.output_item.added" | "response.output_item.done";
188
+ item: {
189
+ content?: {
190
+ text: string;
191
+ }[] | undefined;
192
+ summary?: {
193
+ text: string;
194
+ }[] | undefined;
195
+ encrypted_content?: string | null | undefined;
196
+ id: string;
197
+ type: "reasoning";
198
+ } | {
199
+ id?: string | undefined;
200
+ content?: ({
201
+ text: string;
202
+ type: "output_text";
203
+ } | {
204
+ type: "refusal";
205
+ refusal: string;
206
+ })[] | undefined;
207
+ phase?: "commentary" | "final_answer" | null | undefined;
208
+ type: "message";
209
+ } | {
210
+ id?: string | undefined;
211
+ arguments?: string | undefined;
212
+ namespace?: string | undefined;
213
+ name: string;
214
+ type: "function_call";
215
+ call_id: string;
216
+ } | {
217
+ id?: string | undefined;
218
+ input?: string | undefined;
219
+ namespace?: string | undefined;
220
+ name: string;
221
+ type: "custom_tool_call";
222
+ call_id: string;
223
+ };
224
+ } | {
225
+ output_index?: number | undefined;
226
+ type: "response.reasoning_summary_text.delta";
227
+ delta: string;
228
+ } | {
229
+ output_index?: number | undefined;
230
+ type: "response.reasoning_summary_part.done";
231
+ } | {
232
+ output_index?: number | undefined;
233
+ type: "response.reasoning_text.delta";
234
+ delta: string;
235
+ } | {
236
+ output_index?: number | undefined;
237
+ type: "response.output_text.delta";
238
+ delta: string;
239
+ } | {
240
+ output_index?: number | undefined;
241
+ type: "response.refusal.delta";
242
+ delta: string;
243
+ } | {
244
+ output_index?: number | undefined;
245
+ type: "response.function_call_arguments.delta";
246
+ delta: string;
247
+ } | {
248
+ output_index?: number | undefined;
249
+ arguments: string;
250
+ type: "response.function_call_arguments.done";
251
+ } | {
252
+ output_index?: number | undefined;
253
+ type: "response.custom_tool_call_input.delta";
254
+ delta: string;
255
+ } | {
256
+ output_index?: number | undefined;
257
+ input: string;
258
+ type: "response.custom_tool_call_input.done";
259
+ } | {
260
+ type: "response.completed" | "response.incomplete" | "response.failed";
261
+ response: {
262
+ error?: {
263
+ message?: string | undefined;
264
+ code?: string | null | undefined;
265
+ } | null | undefined;
266
+ id?: string | undefined;
267
+ service_tier?: unknown;
268
+ status?: "failed" | "completed" | "in_progress" | "incomplete" | "cancelled" | "queued" | undefined;
269
+ usage?: unknown;
270
+ output?: unknown[] | undefined;
271
+ incomplete_details?: {
272
+ reason?: string | undefined;
273
+ } | null | undefined;
274
+ };
275
+ } | {
276
+ message?: string | undefined;
277
+ code?: string | null | undefined;
278
+ type: "error";
279
+ }, {
280
+ type: "response.created";
281
+ response: {
282
+ id?: string | undefined;
283
+ };
284
+ } | {
285
+ output_index?: number | undefined;
286
+ type: "response.output_item.added" | "response.output_item.done";
287
+ item: {
288
+ content?: {
289
+ text: string;
290
+ }[] | undefined;
291
+ summary?: {
292
+ text: string;
293
+ }[] | undefined;
294
+ encrypted_content?: string | null | undefined;
295
+ id: string;
296
+ type: "reasoning";
297
+ } | {
298
+ id?: string | undefined;
299
+ content?: ({
300
+ text: string;
301
+ type: "output_text";
302
+ } | {
303
+ type: "refusal";
304
+ refusal: string;
305
+ })[] | undefined;
306
+ phase?: "commentary" | "final_answer" | null | undefined;
307
+ type: "message";
308
+ } | {
309
+ id?: string | undefined;
310
+ arguments?: string | undefined;
311
+ namespace?: string | undefined;
312
+ name: string;
313
+ type: "function_call";
314
+ call_id: string;
315
+ } | {
316
+ id?: string | undefined;
317
+ input?: string | undefined;
318
+ namespace?: string | undefined;
319
+ name: string;
320
+ type: "custom_tool_call";
321
+ call_id: string;
322
+ };
323
+ } | {
324
+ output_index?: number | undefined;
325
+ type: "response.reasoning_summary_text.delta";
326
+ delta: string;
327
+ } | {
328
+ output_index?: number | undefined;
329
+ type: "response.reasoning_summary_part.done";
330
+ } | {
331
+ output_index?: number | undefined;
332
+ type: "response.reasoning_text.delta";
333
+ delta: string;
334
+ } | {
335
+ output_index?: number | undefined;
336
+ type: "response.output_text.delta";
337
+ delta: string;
338
+ } | {
339
+ output_index?: number | undefined;
340
+ type: "response.refusal.delta";
341
+ delta: string;
342
+ } | {
343
+ output_index?: number | undefined;
344
+ type: "response.function_call_arguments.delta";
345
+ delta: string;
346
+ } | {
347
+ output_index?: number | undefined;
348
+ arguments: string;
349
+ type: "response.function_call_arguments.done";
350
+ } | {
351
+ output_index?: number | undefined;
352
+ type: "response.custom_tool_call_input.delta";
353
+ delta: string;
354
+ } | {
355
+ output_index?: number | undefined;
356
+ input: string;
357
+ type: "response.custom_tool_call_input.done";
358
+ } | {
359
+ type: "response.completed" | "response.incomplete" | "response.failed";
360
+ response: {
361
+ error?: {
362
+ message?: string | undefined;
363
+ code?: string | null | undefined;
364
+ } | null | undefined;
365
+ id?: string | undefined;
366
+ service_tier?: unknown;
367
+ status?: "failed" | "completed" | "in_progress" | "incomplete" | "cancelled" | "queued" | undefined;
368
+ usage?: unknown;
369
+ output?: unknown[] | undefined;
370
+ incomplete_details?: {
371
+ reason?: string | undefined;
372
+ } | null | undefined;
373
+ };
374
+ } | {
375
+ message?: string | undefined;
376
+ code?: string | null | undefined;
377
+ type: "error";
378
+ }>;
379
+ export {};
@@ -0,0 +1,12 @@
1
+ import {
2
+ TerminalReasoningItemSchema2,
3
+ StoredReasoningItemSchema2,
4
+ ServiceTierSchema2,
5
+ ResponsesStreamEventCheck2
6
+ } from "../../chunks/account-limits-cache-a558rjbg.js";
7
+ export {
8
+ ResponsesStreamEventCheck2 as ResponsesStreamEventCheck,
9
+ ServiceTierSchema2 as ServiceTierSchema,
10
+ StoredReasoningItemSchema2 as StoredReasoningItemSchema,
11
+ TerminalReasoningItemSchema2 as TerminalReasoningItemSchema
12
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The Responses API event stream processor, shared by the OpenAI Responses and
3
+ * Codex adapters.
4
+ */
5
+ import type { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
6
+ import type { Api, AssistantMessage, Model, Usage } from "../types.ts";
7
+ import type { AssistantMessageEventStream } from "../utils/event-stream.ts";
8
+ import { type ResponsesServiceTier } from "./openai-responses-events.ts";
9
+ export declare function withPriorityTier<O extends {
10
+ fast?: boolean;
11
+ serviceTier?: ResponseCreateParamsStreaming["service_tier"];
12
+ }>(options: O | undefined): O | undefined;
13
+ export interface OpenAIResponsesStreamOptions {
14
+ serviceTier?: ResponseCreateParamsStreaming["service_tier"];
15
+ grammarToolInputProperties?: ReadonlyMap<string, string>;
16
+ resolveServiceTier?: (responseServiceTier: ResponsesServiceTier | undefined, requestServiceTier: ResponseCreateParamsStreaming["service_tier"] | undefined) => ResponsesServiceTier | undefined;
17
+ applyServiceTierPricing?: (usage: Usage, serviceTier: ResponsesServiceTier | undefined) => void;
18
+ }
19
+ export declare class ResponsesUsageError extends Error {
20
+ }
21
+ /**
22
+ * Maps a Responses event stream onto `output`. Each raw event is checked against the event
23
+ * schemas first; others are skipped.
24
+ *
25
+ * - A tool call whose `output_item.done` never arrived may have cut-off or mixed-up arguments,
26
+ * e.g. when a non-compliant server omits `output_index`: a `toolUse` stop with one fails the
27
+ * stream, and any other stop marks it with `argumentsError` so it is reported, not run.
28
+ * Finished calls drop their scratch buffers, so replay carries only parsed arguments.
29
+ * - Azure OpenAI can omit `encrypted_content` from `output_item.done` and send it only in the
30
+ * terminal response's output; it is backfilled into the stored reasoning item, keeping
31
+ * `store: false` multi-turn replay stateless.
32
+ * - `input_tokens` includes cached and cache-write tokens, so both are subtracted.
33
+ * - An incomplete response keeps its specific reason in `rawStopReason`, so output truncation
34
+ * and content filtering stay distinct.
35
+ */
36
+ export declare function processResponsesStream<TApi extends Api>(openaiStream: AsyncIterable<unknown>, output: AssistantMessage, stream: AssistantMessageEventStream, model: Model<TApi>, options?: OpenAIResponsesStreamOptions): Promise<void>;
@@ -0,0 +1,25 @@
1
+ import {
2
+ withPriorityTier2,
3
+ ResponsesUsageError2,
4
+ processResponsesStream2
5
+ } from "../../chunks/account-limits-cache-53e64mhx.js";
6
+ import"../../chunks/account-limits-cache-a558rjbg.js";
7
+ import"../../chunks/account-limits-cache-n3yk6g5c.js";
8
+ import"../../chunks/account-limits-cache-8qzk56vj.js";
9
+ import"../../chunks/account-limits-cache-736tdyme.js";
10
+ import"../../chunks/account-limits-cache-h92bzz1j.js";
11
+ import"../../chunks/account-limits-cache-eqwweapz.js";
12
+ import"../../chunks/account-limits-cache-0af5gqeg.js";
13
+ import"../../chunks/account-limits-cache-b4edaybk.js";
14
+ import"../../chunks/account-limits-cache-6250ykn6.js";
15
+ import"../../chunks/account-limits-cache-fbkaq46e.js";
16
+ import"../../chunks/account-limits-cache-fsktnetm.js";
17
+ import"../../chunks/account-limits-cache-zcbkmrvy.js";
18
+ import"../../chunks/account-limits-cache-a6cgeagz.js";
19
+ import"../../chunks/account-limits-cache-nn9jebsj.js";
20
+ import"../../chunks/account-limits-cache-zgzptd0z.js";
21
+ export {
22
+ ResponsesUsageError2 as ResponsesUsageError,
23
+ processResponsesStream2 as processResponsesStream,
24
+ withPriorityTier2 as withPriorityTier
25
+ };
@@ -0,0 +1,18 @@
1
+ import type { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
2
+ import type { Context, Model, SimpleStreamOptions, StreamFunction, StreamOptions } from "../types.ts";
3
+ import { type OpenAICompactResult } from "./openai-compact.ts";
4
+ export interface OpenAIResponsesOptions extends StreamOptions {
5
+ reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
6
+ reasoningSummary?: "auto" | "detailed" | "concise" | null;
7
+ serviceTier?: ResponseCreateParamsStreaming["service_tier"];
8
+ toolChoice?: ResponseCreateParamsStreaming["tool_choice"];
9
+ }
10
+ /**
11
+ * Compact through OpenAI's stateless endpoint, preserving its complete output window.
12
+ * https://developers.openai.com/api/docs/guides/compaction#standalone-compact-endpoint
13
+ * Instructions travel separately, so the input does not repeat the system message.
14
+ */
15
+ export declare function compactOpenAIResponsesContext(model: Model<"openai-responses">, context: Context, requested?: OpenAIResponsesOptions): Promise<OpenAICompactResult>;
16
+ /** Streams an OpenAI Responses request. */
17
+ export declare const stream: StreamFunction<"openai-responses", OpenAIResponsesOptions>;
18
+ export declare const streamSimple: StreamFunction<"openai-responses", SimpleStreamOptions>;