@nyte-ai/ai 0.0.0-stage → 0.0.19

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 +866 -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-csbxvam7.js +12 -0
  39. package/dist/chunks/account-limits-cache-cw7q7vfy.js +293 -0
  40. package/dist/chunks/account-limits-cache-d1ypzqzp.js +27 -0
  41. package/dist/chunks/account-limits-cache-d2a51dka.js +17 -0
  42. package/dist/chunks/account-limits-cache-dejeygdt.js +114 -0
  43. package/dist/chunks/account-limits-cache-eejm0vth.js +11 -0
  44. package/dist/chunks/account-limits-cache-ehy0ze2b.js +33 -0
  45. package/dist/chunks/account-limits-cache-emg5b4hj.js +53 -0
  46. package/dist/chunks/account-limits-cache-eqwweapz.js +6 -0
  47. package/dist/chunks/account-limits-cache-eyx1jcxc.js +8 -0
  48. package/dist/chunks/account-limits-cache-f9z00x8c.js +36 -0
  49. package/dist/chunks/account-limits-cache-fbkaq46e.js +113 -0
  50. package/dist/chunks/account-limits-cache-fdwad56n.js +399 -0
  51. package/dist/chunks/account-limits-cache-fht68jp2.js +22 -0
  52. package/dist/chunks/account-limits-cache-fp03ztsw.js +17 -0
  53. package/dist/chunks/account-limits-cache-fsktnetm.js +69 -0
  54. package/dist/chunks/account-limits-cache-fvadc36m.js +110 -0
  55. package/dist/chunks/account-limits-cache-gknnm1kv.js +13 -0
  56. package/dist/chunks/account-limits-cache-gqsrbky9.js +40 -0
  57. package/dist/chunks/account-limits-cache-gr671dr2.js +0 -0
  58. package/dist/chunks/account-limits-cache-gs8a3fhw.js +32 -0
  59. package/dist/chunks/account-limits-cache-gsa5tzck.js +37 -0
  60. package/dist/chunks/account-limits-cache-h92bzz1j.js +235 -0
  61. package/dist/chunks/account-limits-cache-hemxtapd.js +142 -0
  62. package/dist/chunks/account-limits-cache-hj1h48sc.js +92 -0
  63. package/dist/chunks/account-limits-cache-hj3ek3ty.js +128 -0
  64. package/dist/chunks/account-limits-cache-hwehc67r.js +509 -0
  65. package/dist/chunks/account-limits-cache-hyzn1jmk.js +46 -0
  66. package/dist/chunks/account-limits-cache-j2bt392s.js +63 -0
  67. package/dist/chunks/account-limits-cache-k0pkzhbx.js +74 -0
  68. package/dist/chunks/account-limits-cache-kjx405q0.js +277 -0
  69. package/dist/chunks/account-limits-cache-ks1sjym9.js +37 -0
  70. package/dist/chunks/account-limits-cache-me1x57bs.js +89 -0
  71. package/dist/chunks/account-limits-cache-n3yk6g5c.js +314 -0
  72. package/dist/chunks/account-limits-cache-nbhht7xz.js +72 -0
  73. package/dist/chunks/account-limits-cache-nbkyhs6v.js +42 -0
  74. package/dist/chunks/account-limits-cache-nn9jebsj.js +26 -0
  75. package/dist/chunks/account-limits-cache-nxkprk3g.js +13 -0
  76. package/dist/chunks/account-limits-cache-nyy770yd.js +38 -0
  77. package/dist/chunks/account-limits-cache-pfa86y8e.js +45 -0
  78. package/dist/chunks/account-limits-cache-pfr14mcn.js +59 -0
  79. package/dist/chunks/account-limits-cache-q1ebtvet.js +8 -0
  80. package/dist/chunks/account-limits-cache-q63mc41j.js +51 -0
  81. package/dist/chunks/account-limits-cache-re8hpzwn.js +104 -0
  82. package/dist/chunks/account-limits-cache-rz8p1g5y.js +9 -0
  83. package/dist/chunks/account-limits-cache-skbfmzqe.js +7 -0
  84. package/dist/chunks/account-limits-cache-tc38g0ca.js +20 -0
  85. package/dist/chunks/account-limits-cache-v4n30az2.js +24 -0
  86. package/dist/chunks/account-limits-cache-vwgfz727.js +281 -0
  87. package/dist/chunks/account-limits-cache-wtg64ez7.js +69 -0
  88. package/dist/chunks/account-limits-cache-x9fvb3s5.js +8 -0
  89. package/dist/chunks/account-limits-cache-xds88kxd.js +209 -0
  90. package/dist/chunks/account-limits-cache-xz65wyd1.js +428 -0
  91. package/dist/chunks/account-limits-cache-ydq8p8qp.js +39 -0
  92. package/dist/chunks/account-limits-cache-ykbqsvv6.js +134 -0
  93. package/dist/chunks/account-limits-cache-yzyp0c2h.js +251 -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,399 @@
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
+ import {
25
+ parseOpenAIReasoningDetails2,
26
+ parseLegacyEncryptedReasoningDetail2,
27
+ OpenAICompletionsReasoningFieldSchema2,
28
+ parseCopilotReasoningOpaque2
29
+ } from "./account-limits-cache-hj1h48sc.js";
30
+
31
+ // src/api/openai-completions-convert.ts
32
+ import { Value } from "typebox/value";
33
+ var DEFAULT_COMPAT = {
34
+ supportsStore: true,
35
+ supportsDeveloperRole: true,
36
+ supportsReasoningEffort: true,
37
+ supportsUsageInStreaming: true,
38
+ supportsFinishReason: true,
39
+ maxTokensField: "max_completion_tokens",
40
+ requiresToolResultName: false,
41
+ requiresAssistantAfterToolResult: false,
42
+ requiresThinkingAsText: false,
43
+ requiresReasoningContentOnAssistantMessages: false,
44
+ thinkingFormat: "openai",
45
+ openRouterRouting: {},
46
+ vercelGatewayRouting: {},
47
+ chatTemplateKwargs: {},
48
+ chatTemplateArgs: {},
49
+ zaiToolStream: false,
50
+ supportsStrictMode: false,
51
+ supportsOpenAIGrammarTools: false,
52
+ sendSessionAffinityHeaders: false,
53
+ sessionAffinityFormat: "openai",
54
+ supportsLongCacheRetention: true
55
+ };
56
+ function resolveCompat2(model) {
57
+ return { ...DEFAULT_COMPAT, ...model.compat };
58
+ }
59
+ function kimiToolSystemMessage(tools, compat) {
60
+ return {
61
+ role: "system",
62
+ tools: convertTools2(tools, compat)
63
+ };
64
+ }
65
+ function getToolsByName(tools, names) {
66
+ if (!tools)
67
+ return [];
68
+ const toolsByName = new Map(tools.map((tool) => [tool.name, tool]));
69
+ return Array.from(names).map((name) => toolsByName.get(name)).filter((tool) => tool !== undefined);
70
+ }
71
+ function getCompatCacheControl2(compat, cacheRetention) {
72
+ if (compat.cacheControlFormat !== "anthropic" || cacheRetention === "none") {
73
+ return;
74
+ }
75
+ const cacheControl = { type: "ephemeral" };
76
+ if (cacheRetention === "long" && compat.supportsLongCacheRetention)
77
+ cacheControl.ttl = "1h";
78
+ return cacheControl;
79
+ }
80
+ function applyAnthropicCacheControl2(messages, tools, cacheControl) {
81
+ addCacheControlToSystemPrompt(messages, cacheControl);
82
+ addCacheControlToLastTool(tools, cacheControl);
83
+ addCacheControlToLastConversationMessage(messages, cacheControl);
84
+ }
85
+ function addCacheControlToSystemPrompt(messages, cacheControl) {
86
+ for (const message of messages) {
87
+ if (message.role === "system" || message.role === "developer") {
88
+ addCacheControlToTextContent(message, cacheControl);
89
+ return;
90
+ }
91
+ }
92
+ }
93
+ function addCacheControlToLastConversationMessage(messages, cacheControl) {
94
+ for (let i = messages.length - 1;i >= 0; i--) {
95
+ const message = messages[i];
96
+ if (message.role === "user" || message.role === "assistant" || message.role === "tool") {
97
+ if (addCacheControlToMessage(message, cacheControl)) {
98
+ return;
99
+ }
100
+ }
101
+ }
102
+ }
103
+ function addCacheControlToLastTool(tools, cacheControl) {
104
+ if (!tools || tools.length === 0) {
105
+ return;
106
+ }
107
+ Object.assign(tools[tools.length - 1], { cache_control: cacheControl });
108
+ }
109
+ function addCacheControlToMessage(message, cacheControl) {
110
+ if (message.role === "user" || message.role === "assistant" || message.role === "tool") {
111
+ return addCacheControlToTextContent(message, cacheControl);
112
+ }
113
+ return false;
114
+ }
115
+ function addCacheControlToTextContent(message, cacheControl) {
116
+ const content = message.content;
117
+ if (Array.isArray(content)) {
118
+ const textPart = content.findLast((part) => part?.type === "text");
119
+ if (textPart === undefined)
120
+ return false;
121
+ Object.assign(textPart, { cache_control: cacheControl });
122
+ return true;
123
+ }
124
+ if (!content) {
125
+ return false;
126
+ }
127
+ const textPart = {
128
+ type: "text",
129
+ text: content,
130
+ cache_control: cacheControl
131
+ };
132
+ message.content = [textPart];
133
+ return true;
134
+ }
135
+ function normalizeToolCallId(id, provider) {
136
+ if (id.includes("|")) {
137
+ const [rawCallId, ...itemParts] = id.split("|");
138
+ const callId = rawCallId.replace(/[^a-zA-Z0-9_-]/g, "_");
139
+ const itemId = itemParts.join("|").replace(/[^a-zA-Z0-9_-]/g, "_");
140
+ const combinedId = itemId.length > 0 ? `${callId}_${itemId}` : callId;
141
+ if (combinedId.length <= 40) {
142
+ return combinedId;
143
+ }
144
+ const hash = shortHash2(id).slice(0, 8);
145
+ const prefix = callId.slice(0, Math.max(1, 40 - hash.length - 1));
146
+ return `${prefix}_${hash}`;
147
+ }
148
+ if (provider === "openai")
149
+ return id.length > 40 ? id.slice(0, 40) : id;
150
+ return id;
151
+ }
152
+ function convertMessages2(model, context, compat, options) {
153
+ const normalizedContext = resolveTranscript2(context, compat.supportsMidConvoSystemMessages);
154
+ const params = [];
155
+ const transformedMessages = transformMessages2(normalizedContext.messages, model, (id) => normalizeToolCallId(id, model.provider));
156
+ const transcriptTools = resolveTranscriptTools2(normalizedContext.messages, compat.supportsMidConvoSystemMessages === true && compat.supportsMidConvoToolAdditions === true);
157
+ const requestTools = compat.deferredToolsMode === "kimi" ? transcriptTools.requestTools : [];
158
+ const instructionRole = model.reasoning && compat.supportsDeveloperRole ? "developer" : "system";
159
+ let lastRole = null;
160
+ for (let i = 0;i < transformedMessages.length; i++) {
161
+ const msg = transformedMessages[i];
162
+ if (compat.requiresAssistantAfterToolResult && lastRole === "toolResult" && msg.role === "user") {
163
+ params.push({
164
+ role: "assistant",
165
+ content: "I have processed the tool results."
166
+ });
167
+ }
168
+ if (msg.role === "system") {
169
+ const addedTools = i > 0 && transcriptTools.anchorsAdditions ? msg.toolsAdded ?? [] : [];
170
+ if (addedTools.length > 0) {
171
+ params.push(kimiToolSystemMessage(addedTools, compat));
172
+ }
173
+ const text = i === 0 ? getSystemMessageText2(msg) : renderSystemMessageUpdate2(msg);
174
+ if (text.length > 0) {
175
+ params.push({ role: instructionRole, content: sanitizeSurrogates2(text) });
176
+ }
177
+ } else if (msg.role === "user") {
178
+ if (!Array.isArray(msg.content)) {
179
+ params.push({
180
+ role: "user",
181
+ content: sanitizeSurrogates2(msg.content)
182
+ });
183
+ } else {
184
+ const content = msg.content.filter((item) => item.type !== "text" || item.text.length > 0).map((item) => {
185
+ if (item.type === "text") {
186
+ return {
187
+ type: "text",
188
+ text: sanitizeSurrogates2(item.text)
189
+ };
190
+ } else {
191
+ return {
192
+ type: "image_url",
193
+ image_url: {
194
+ url: `data:${item.mimeType};base64,${item.data}`
195
+ }
196
+ };
197
+ }
198
+ });
199
+ if (content.length === 0)
200
+ continue;
201
+ params.push({
202
+ role: "user",
203
+ content
204
+ });
205
+ }
206
+ } else if (msg.role === "assistant") {
207
+ const assistantMsg = {
208
+ role: "assistant",
209
+ content: compat.requiresAssistantAfterToolResult ? "" : null
210
+ };
211
+ const assistantTextParts = msg.content.filter((block) => block.type === "text").filter((block) => block.text.trim().length > 0).map((block) => ({
212
+ type: "text",
213
+ text: sanitizeSurrogates2(block.text)
214
+ }));
215
+ const assistantText = assistantTextParts.map((part) => part.text).join("");
216
+ const thinkingBlocks = msg.content.filter((block) => block.type === "thinking");
217
+ const toolCalls = msg.content.filter((block) => block.type === "toolCall");
218
+ const signedReasoningDetails = thinkingBlocks.map((block) => parseOpenAIReasoningDetails2(block.thinkingSignature)).find((details) => details !== undefined);
219
+ const legacyReasoningDetails = toolCalls.map((toolCall) => parseLegacyEncryptedReasoningDetail2(toolCall.thoughtSignature)).filter((detail) => detail !== undefined);
220
+ const preservedReasoningDetails = signedReasoningDetails ?? (legacyReasoningDetails.length > 0 ? legacyReasoningDetails : undefined);
221
+ const nonEmptyThinkingBlocks = thinkingBlocks.filter((block) => block.thinking.trim().length > 0);
222
+ const copilotReasoningOpaque = model.provider === "github-copilot" ? thinkingBlocks.map((block) => parseCopilotReasoningOpaque2(block.thinkingSignature)).find((opaque) => opaque !== undefined) : undefined;
223
+ if (model.provider === "github-copilot") {
224
+ if (assistantText.length > 0) {
225
+ assistantMsg.content = assistantText;
226
+ }
227
+ if (copilotReasoningOpaque !== undefined) {
228
+ assistantMsg.reasoning_opaque = copilotReasoningOpaque;
229
+ if (nonEmptyThinkingBlocks.length > 0) {
230
+ assistantMsg.reasoning_text = nonEmptyThinkingBlocks.map((block) => block.thinking).join(`
231
+ `);
232
+ }
233
+ }
234
+ } else if (nonEmptyThinkingBlocks.length > 0) {
235
+ if (compat.requiresThinkingAsText) {
236
+ const thinkingText = nonEmptyThinkingBlocks.map((block) => sanitizeSurrogates2(block.thinking)).join(`
237
+
238
+ `);
239
+ assistantMsg.content = [{ type: "text", text: thinkingText }, ...assistantTextParts];
240
+ } else {
241
+ if (assistantText.length > 0) {
242
+ assistantMsg.content = assistantText;
243
+ }
244
+ if (!preservedReasoningDetails) {
245
+ let signature = nonEmptyThinkingBlocks[0].thinkingSignature;
246
+ if (model.provider === "opencode-go" && signature === "reasoning") {
247
+ signature = "reasoning_content";
248
+ }
249
+ if (signature && Value.Check(OpenAICompletionsReasoningFieldSchema2, signature)) {
250
+ assistantMsg[signature] = nonEmptyThinkingBlocks.map((block) => block.thinking).join(`
251
+ `);
252
+ }
253
+ }
254
+ }
255
+ } else if (assistantText.length > 0) {
256
+ assistantMsg.content = assistantText;
257
+ }
258
+ if (toolCalls.length > 0) {
259
+ assistantMsg.tool_calls = toolCalls.map((tc) => {
260
+ const customInputProperty = options?.grammarToolInputProperties?.get(tc.name);
261
+ if (customInputProperty !== undefined) {
262
+ return {
263
+ id: tc.id,
264
+ type: "custom",
265
+ custom: {
266
+ name: tc.name,
267
+ input: sanitizeSurrogates2(getGrammarToolInput2(tc.name, tc.arguments, customInputProperty))
268
+ }
269
+ };
270
+ }
271
+ return {
272
+ id: tc.id,
273
+ type: "function",
274
+ function: {
275
+ name: tc.name,
276
+ arguments: JSON.stringify(tc.arguments)
277
+ }
278
+ };
279
+ });
280
+ }
281
+ if (preservedReasoningDetails) {
282
+ assistantMsg.reasoning_details = preservedReasoningDetails;
283
+ }
284
+ if (compat.requiresReasoningContentOnAssistantMessages && model.reasoning && assistantMsg.reasoning_content === undefined) {
285
+ assistantMsg.reasoning_content = "";
286
+ }
287
+ const content = assistantMsg.content;
288
+ const hasContent = content !== null && content !== undefined && content.length > 0;
289
+ if (!hasContent && !assistantMsg.tool_calls) {
290
+ continue;
291
+ }
292
+ params.push(assistantMsg);
293
+ } else if (msg.role === "toolResult") {
294
+ const imageBlocks = [];
295
+ const deferredToolNames = new Set;
296
+ let j = i;
297
+ for (;j < transformedMessages.length; j++) {
298
+ const toolMsg = transformedMessages[j];
299
+ if (toolMsg.role !== "toolResult")
300
+ break;
301
+ const textResult = toolMsg.content.filter((block) => block.type === "text").map((block) => block.text).join(`
302
+ `);
303
+ const hasImages = toolMsg.content.some((c) => c.type === "image");
304
+ const hasText = textResult.length > 0;
305
+ const toolResultText = hasText ? textResult : hasImages ? "(see attached image)" : "(no tool output)";
306
+ const toolResultMsg = {
307
+ role: "tool",
308
+ content: sanitizeSurrogates2(toolResultText),
309
+ tool_call_id: toolMsg.toolCallId
310
+ };
311
+ if (compat.requiresToolResultName && toolMsg.toolName) {
312
+ toolResultMsg.name = toolMsg.toolName;
313
+ }
314
+ params.push(toolResultMsg);
315
+ if (compat.deferredToolsMode === "kimi") {
316
+ for (const name of toolMsg.addedToolNames ?? []) {
317
+ deferredToolNames.add(name);
318
+ }
319
+ }
320
+ if (hasImages && model.input.includes("image")) {
321
+ for (const block of toolMsg.content) {
322
+ if (block.type === "image") {
323
+ imageBlocks.push({
324
+ type: "image_url",
325
+ image_url: {
326
+ url: `data:${block.mimeType};base64,${block.data}`
327
+ }
328
+ });
329
+ }
330
+ }
331
+ }
332
+ }
333
+ i = j - 1;
334
+ if (imageBlocks.length > 0) {
335
+ if (compat.requiresAssistantAfterToolResult) {
336
+ params.push({
337
+ role: "assistant",
338
+ content: "I have processed the tool results."
339
+ });
340
+ }
341
+ params.push({
342
+ role: "user",
343
+ content: [
344
+ {
345
+ type: "text",
346
+ text: "Attached image(s) from tool result:"
347
+ },
348
+ ...imageBlocks
349
+ ]
350
+ });
351
+ lastRole = "user";
352
+ } else {
353
+ lastRole = "toolResult";
354
+ }
355
+ if (deferredToolNames.size > 0) {
356
+ const deferredTools = getToolsByName(requestTools, deferredToolNames);
357
+ if (deferredTools.length > 0) {
358
+ params.push(kimiToolSystemMessage(deferredTools, compat));
359
+ }
360
+ }
361
+ continue;
362
+ }
363
+ lastRole = msg.role;
364
+ }
365
+ return params;
366
+ }
367
+ function convertTools2(tools, compat) {
368
+ return tools.map((tool) => {
369
+ const grammar = resolveGrammarConstrainedSampling2(tool, compat.supportsOpenAIGrammarTools);
370
+ if (grammar) {
371
+ return {
372
+ type: "custom",
373
+ custom: {
374
+ name: tool.name,
375
+ description: tool.description,
376
+ format: {
377
+ type: "grammar",
378
+ grammar: {
379
+ syntax: grammar.format,
380
+ definition: grammar.definition
381
+ }
382
+ }
383
+ }
384
+ };
385
+ }
386
+ const strict = resolveJsonSchemaStrictSampling2(tool, compat.supportsStrictMode !== false);
387
+ return {
388
+ type: "function",
389
+ function: {
390
+ name: tool.name,
391
+ description: tool.description,
392
+ parameters: getJsonSchemaToolParameters2(tool, strict),
393
+ ...compat.supportsStrictMode !== false && { strict: strict ?? false }
394
+ }
395
+ };
396
+ });
397
+ }
398
+
399
+ export { resolveCompat2, getCompatCacheControl2, applyAnthropicCacheControl2, convertMessages2, convertTools2 };
@@ -0,0 +1,22 @@
1
+ // src/providers/opencode-headers.ts
2
+ var OPENCODE_SESSION_HEADER = "x-opencode-session";
3
+ function withSessionHeader(options) {
4
+ if (!options?.sessionId)
5
+ return options;
6
+ const overridden = Object.keys(options.headers ?? {}).some((key) => key.toLowerCase() === OPENCODE_SESSION_HEADER);
7
+ if (overridden)
8
+ return options;
9
+ return {
10
+ ...options,
11
+ headers: { ...options.headers, [OPENCODE_SESSION_HEADER]: options.sessionId }
12
+ };
13
+ }
14
+ function withOpenCodeSessionHeader2(streams) {
15
+ return {
16
+ ...streams,
17
+ stream: (model, context, options) => streams.stream(model, context, withSessionHeader(options)),
18
+ streamSimple: (model, context, options) => streams.streamSimple(model, context, withSessionHeader(options))
19
+ };
20
+ }
21
+
22
+ export { withOpenCodeSessionHeader2 };
@@ -0,0 +1,17 @@
1
+ import {
2
+ providerRequest2
3
+ } from "./account-limits-cache-031vfpt3.js";
4
+
5
+ // src/api/deferred.ts
6
+ async function compactOpenAICodexContext2(selected, context, selectedOptions) {
7
+ const api = await import("../src/api/openai-codex-compact.js");
8
+ const { model, options } = providerRequest2(selected, selectedOptions);
9
+ return api.compactOpenAICodexContext(model, context, options);
10
+ }
11
+ async function compactOpenAIResponsesContext2(selected, context, selectedOptions) {
12
+ const api = await import("../src/api/openai-responses.js");
13
+ const { model, options } = providerRequest2(selected, selectedOptions);
14
+ return api.compactOpenAIResponsesContext(model, context, options);
15
+ }
16
+
17
+ export { compactOpenAICodexContext2, compactOpenAIResponsesContext2 };
@@ -0,0 +1,69 @@
1
+ import {
2
+ normalizeProviderError2,
3
+ formatProviderError2
4
+ } from "./account-limits-cache-zcbkmrvy.js";
5
+ import {
6
+ AssistantMessageEventStream2
7
+ } from "./account-limits-cache-a6cgeagz.js";
8
+
9
+ // src/api/assistant-stream.ts
10
+ function emptyCost2() {
11
+ return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 };
12
+ }
13
+ function emptyUsage() {
14
+ return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: emptyCost2() };
15
+ }
16
+ function emptyAssistantOutput2(model) {
17
+ return {
18
+ role: "assistant",
19
+ content: [],
20
+ api: model.api,
21
+ provider: model.provider,
22
+ model: model.id,
23
+ usage: emptyUsage(),
24
+ stopReason: "pending",
25
+ timestamp: Date.now()
26
+ };
27
+ }
28
+ function stripStreamingScratchState2(content) {
29
+ for (const block of content) {
30
+ if ("partialJson" in block)
31
+ delete block.partialJson;
32
+ if ("partialArgs" in block)
33
+ delete block.partialArgs;
34
+ if ("customInput" in block)
35
+ delete block.customInput;
36
+ if ("streamIndex" in block)
37
+ delete block.streamIndex;
38
+ }
39
+ }
40
+ function formatStreamError(error) {
41
+ return formatProviderError2(normalizeProviderError2(error));
42
+ }
43
+ function runAssistantStream2(model, signal, label, body, formatError = formatStreamError) {
44
+ const stream = new AssistantMessageEventStream2;
45
+ const output = emptyAssistantOutput2(model);
46
+ (async () => {
47
+ try {
48
+ await body(output, stream);
49
+ if (signal?.aborted)
50
+ throw new Error("Request was aborted");
51
+ if (output.stopReason === "pending") {
52
+ throw new Error(`${label} stream ended without a stop reason`);
53
+ }
54
+ if (output.stopReason === "aborted" || output.stopReason === "error") {
55
+ throw new Error(output.errorMessage || "An unknown error occurred");
56
+ }
57
+ stream.push({ type: "done", reason: output.stopReason, message: output });
58
+ } catch (error) {
59
+ stripStreamingScratchState2(output.content);
60
+ output.stopReason = signal?.aborted ? "aborted" : "error";
61
+ output.errorMessage = formatError(error);
62
+ stream.push({ type: "error", reason: output.stopReason, error: output });
63
+ }
64
+ stream.end();
65
+ })();
66
+ return stream;
67
+ }
68
+
69
+ export { emptyCost2, emptyAssistantOutput2, stripStreamingScratchState2, runAssistantStream2 };
@@ -0,0 +1,110 @@
1
+ import {
2
+ providerHeadersToRecord2
3
+ } from "./account-limits-cache-ag5b8dja.js";
4
+ import {
5
+ getNyteUserAgent2
6
+ } from "./account-limits-cache-gknnm1kv.js";
7
+
8
+ // src/api/openai-codex-wire.ts
9
+ import { Type } from "typebox";
10
+ import { Value } from "typebox/value";
11
+ var CodexFrameJson2 = Type.Object({ type: Type.String() });
12
+ var TextJson = Type.String();
13
+ var BooleanJson = Type.Boolean();
14
+ var NumberJson = Type.Number();
15
+ var JsonObjectJson = Type.Record(Type.String(), Type.Unknown());
16
+ function readText2(value) {
17
+ return Value.Check(TextJson, value) ? value : undefined;
18
+ }
19
+ function readBoolean2(value) {
20
+ return Value.Check(BooleanJson, value) ? value : undefined;
21
+ }
22
+ function readNumber2(value) {
23
+ return Value.Check(NumberJson, value) ? value : undefined;
24
+ }
25
+ function readRecord2(value) {
26
+ return Value.Check(JsonObjectJson, value) ? value : undefined;
27
+ }
28
+ var TERMINAL_RESPONSE_TYPES2 = new Set([
29
+ "response.completed",
30
+ "response.done",
31
+ "response.incomplete",
32
+ "response.failed"
33
+ ]);
34
+ var DEFAULT_CODEX_BASE_URL2 = "https://chatgpt.com/backend-api";
35
+ var OPENAI_BETA_RESPONSES_WEBSOCKETS = "responses_websockets=2026-02-06";
36
+ var AccessTokenClaimsSchema = Type.Object({
37
+ "https://api.openai.com/auth": Type.Object({
38
+ chatgpt_account_id: Type.String({ minLength: 1 })
39
+ })
40
+ });
41
+ function normalizeTimeoutMs2(value) {
42
+ if (value === undefined)
43
+ return;
44
+ if (!Number.isFinite(value) || value < 0) {
45
+ throw new Error(`Invalid timeoutMs: ${String(value)}`);
46
+ }
47
+ return Math.floor(value);
48
+ }
49
+ function resolveCodexUrl2(baseUrl) {
50
+ const raw = baseUrl && baseUrl.trim().length > 0 ? baseUrl : DEFAULT_CODEX_BASE_URL2;
51
+ const normalized = raw.replace(/\/+$/, "");
52
+ if (normalized.endsWith("/codex/responses"))
53
+ return normalized;
54
+ if (normalized.endsWith("/codex"))
55
+ return `${normalized}/responses`;
56
+ return `${normalized}/codex/responses`;
57
+ }
58
+ function resolveCodexWebSocketUrl2(baseUrl) {
59
+ const url = new URL(resolveCodexUrl2(baseUrl));
60
+ if (url.protocol === "https:")
61
+ url.protocol = "wss:";
62
+ if (url.protocol === "http:")
63
+ url.protocol = "ws:";
64
+ return url.toString();
65
+ }
66
+ function extractAccountId2(token) {
67
+ const parts = token.split(".");
68
+ let claims;
69
+ try {
70
+ claims = parts.length === 3 ? JSON.parse(atob(parts[1])) : undefined;
71
+ } catch {
72
+ claims = undefined;
73
+ }
74
+ if (!Value.Check(AccessTokenClaimsSchema, claims)) {
75
+ throw new Error("Failed to extract accountId from token");
76
+ }
77
+ return claims["https://api.openai.com/auth"].chatgpt_account_id;
78
+ }
79
+ function buildBaseCodexHeaders2(initHeaders, additionalHeaders, accountId, token) {
80
+ const headers = new Headers(Object.entries(providerHeadersToRecord2(initHeaders, additionalHeaders) ?? {}));
81
+ headers.set("Authorization", `Bearer ${token}`);
82
+ headers.set("chatgpt-account-id", accountId);
83
+ headers.set("originator", "nyte");
84
+ headers.set("User-Agent", getNyteUserAgent2());
85
+ return headers;
86
+ }
87
+ function buildSSEHeaders2(initHeaders, additionalHeaders, accountId, token, sessionId) {
88
+ const headers = buildBaseCodexHeaders2(initHeaders, additionalHeaders, accountId, token);
89
+ headers.set("OpenAI-Beta", "responses=experimental");
90
+ headers.set("accept", "text/event-stream");
91
+ headers.set("content-type", "application/json");
92
+ if (sessionId) {
93
+ headers.set("session-id", sessionId);
94
+ headers.set("x-client-request-id", sessionId);
95
+ }
96
+ return headers;
97
+ }
98
+ function buildWebSocketHeaders2(initHeaders, additionalHeaders, accountId, token, requestId) {
99
+ const headers = buildBaseCodexHeaders2(initHeaders, additionalHeaders, accountId, token);
100
+ headers.delete("accept");
101
+ headers.delete("content-type");
102
+ headers.delete("OpenAI-Beta");
103
+ headers.delete("openai-beta");
104
+ headers.set("OpenAI-Beta", OPENAI_BETA_RESPONSES_WEBSOCKETS);
105
+ headers.set("x-client-request-id", requestId);
106
+ headers.set("session-id", requestId);
107
+ return headers;
108
+ }
109
+
110
+ export { CodexFrameJson2, readText2, readBoolean2, readNumber2, readRecord2, TERMINAL_RESPONSE_TYPES2, DEFAULT_CODEX_BASE_URL2, normalizeTimeoutMs2, resolveCodexUrl2, resolveCodexWebSocketUrl2, extractAccountId2, buildBaseCodexHeaders2, buildSSEHeaders2, buildWebSocketHeaders2 };
@@ -0,0 +1,13 @@
1
+ // src/utils/nyte-user-agent.ts
2
+ function loadNodeOs() {
3
+ if (typeof process === "undefined" || !(process.versions?.node || process.versions?.bun)) {
4
+ return null;
5
+ }
6
+ return process.getBuiltinModule?.("node:os") ?? null;
7
+ }
8
+ var nodeOs = loadNodeOs();
9
+ function getNyteUserAgent2() {
10
+ return nodeOs ? `nyte (${nodeOs.platform()} ${nodeOs.release()}; ${nodeOs.arch()})` : "nyte (browser)";
11
+ }
12
+
13
+ export { getNyteUserAgent2 };
@@ -0,0 +1,40 @@
1
+ // src/session-resources.ts
2
+ var sessionResourceCleanups = new Set;
3
+ var sessionResourceLeases = new Map;
4
+ function registerSessionResourceCleanup2(cleanup) {
5
+ sessionResourceCleanups.add(cleanup);
6
+ return () => {
7
+ sessionResourceCleanups.delete(cleanup);
8
+ };
9
+ }
10
+ function cleanupSessionResources2(sessionId) {
11
+ const errors = [];
12
+ for (const cleanup of sessionResourceCleanups) {
13
+ try {
14
+ cleanup(sessionId);
15
+ } catch (error) {
16
+ errors.push(error);
17
+ }
18
+ }
19
+ if (errors.length > 0) {
20
+ throw new AggregateError(errors, "Failed to cleanup session resources");
21
+ }
22
+ }
23
+ function acquireSessionResources2(sessionId) {
24
+ sessionResourceLeases.set(sessionId, (sessionResourceLeases.get(sessionId) ?? 0) + 1);
25
+ let released = false;
26
+ return () => {
27
+ if (released)
28
+ return;
29
+ released = true;
30
+ const remaining = (sessionResourceLeases.get(sessionId) ?? 1) - 1;
31
+ if (remaining > 0) {
32
+ sessionResourceLeases.set(sessionId, remaining);
33
+ return;
34
+ }
35
+ sessionResourceLeases.delete(sessionId);
36
+ cleanupSessionResources2(sessionId);
37
+ };
38
+ }
39
+
40
+ export { registerSessionResourceCleanup2, cleanupSessionResources2, acquireSessionResources2 };
File without changes