@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.
- package/LICENSE +21 -0
- package/README.md +170 -2
- package/THIRD-PARTY-NOTICES.md +800 -0
- package/dist/chunks/account-limits-cache-031vfpt3.js +37 -0
- package/dist/chunks/account-limits-cache-09vs98g6.js +41 -0
- package/dist/chunks/account-limits-cache-0af5gqeg.js +15 -0
- package/dist/chunks/account-limits-cache-0yd6bde8.js +103 -0
- package/dist/chunks/account-limits-cache-1jv43fhh.js +22 -0
- package/dist/chunks/account-limits-cache-3ykqmnj5.js +88 -0
- package/dist/chunks/account-limits-cache-4b8ckwqw.js +293 -0
- package/dist/chunks/account-limits-cache-4fn5w63p.js +295 -0
- package/dist/chunks/account-limits-cache-4hptgd2h.js +49 -0
- package/dist/chunks/account-limits-cache-53e64mhx.js +417 -0
- package/dist/chunks/account-limits-cache-5jdhn0e1.js +562 -0
- package/dist/chunks/account-limits-cache-5rx2pfm5.js +8 -0
- package/dist/chunks/account-limits-cache-5ygxyyss.js +19 -0
- package/dist/chunks/account-limits-cache-6250ykn6.js +21 -0
- package/dist/chunks/account-limits-cache-6x05n06z.js +49 -0
- package/dist/chunks/account-limits-cache-736tdyme.js +6 -0
- package/dist/chunks/account-limits-cache-75smws02.js +213 -0
- package/dist/chunks/account-limits-cache-7z9s8j16.js +139 -0
- package/dist/chunks/account-limits-cache-8137j3zp.js +37 -0
- package/dist/chunks/account-limits-cache-8qzk56vj.js +160 -0
- package/dist/chunks/account-limits-cache-8s8bz4dr.js +36 -0
- package/dist/chunks/account-limits-cache-8vzx8k6r.js +166 -0
- package/dist/chunks/account-limits-cache-8wfqg73s.js +135 -0
- package/dist/chunks/account-limits-cache-90c9c2eb.js +50 -0
- package/dist/chunks/account-limits-cache-9wqk28n5.js +25 -0
- package/dist/chunks/account-limits-cache-a1jyaq00.js +56 -0
- package/dist/chunks/account-limits-cache-a558rjbg.js +138 -0
- package/dist/chunks/account-limits-cache-a55e14fr.js +70 -0
- package/dist/chunks/account-limits-cache-a6cgeagz.js +77 -0
- package/dist/chunks/account-limits-cache-ag5b8dja.js +38 -0
- package/dist/chunks/account-limits-cache-b0x2sfya.js +45 -0
- package/dist/chunks/account-limits-cache-b23sbrke.js +26 -0
- package/dist/chunks/account-limits-cache-b4edaybk.js +8 -0
- package/dist/chunks/account-limits-cache-bsknrh6t.js +74 -0
- package/dist/chunks/account-limits-cache-c7v93krb.js +235 -0
- package/dist/chunks/account-limits-cache-csbxvam7.js +12 -0
- package/dist/chunks/account-limits-cache-cw7q7vfy.js +293 -0
- package/dist/chunks/account-limits-cache-d1ypzqzp.js +27 -0
- package/dist/chunks/account-limits-cache-d2a51dka.js +17 -0
- package/dist/chunks/account-limits-cache-dejeygdt.js +114 -0
- package/dist/chunks/account-limits-cache-eejm0vth.js +11 -0
- package/dist/chunks/account-limits-cache-ehy0ze2b.js +33 -0
- package/dist/chunks/account-limits-cache-emg5b4hj.js +53 -0
- package/dist/chunks/account-limits-cache-eqwweapz.js +6 -0
- package/dist/chunks/account-limits-cache-eyx1jcxc.js +8 -0
- package/dist/chunks/account-limits-cache-f9z00x8c.js +36 -0
- package/dist/chunks/account-limits-cache-fbkaq46e.js +113 -0
- package/dist/chunks/account-limits-cache-fdwad56n.js +399 -0
- package/dist/chunks/account-limits-cache-fht68jp2.js +22 -0
- package/dist/chunks/account-limits-cache-fp03ztsw.js +17 -0
- package/dist/chunks/account-limits-cache-fsktnetm.js +69 -0
- package/dist/chunks/account-limits-cache-fvadc36m.js +110 -0
- package/dist/chunks/account-limits-cache-ghe9ne4j.js +69 -0
- package/dist/chunks/account-limits-cache-gknnm1kv.js +13 -0
- package/dist/chunks/account-limits-cache-gqsrbky9.js +40 -0
- package/dist/chunks/account-limits-cache-gr671dr2.js +0 -0
- package/dist/chunks/account-limits-cache-gs8a3fhw.js +32 -0
- package/dist/chunks/account-limits-cache-gsa5tzck.js +37 -0
- package/dist/chunks/account-limits-cache-h92bzz1j.js +235 -0
- package/dist/chunks/account-limits-cache-hemxtapd.js +142 -0
- package/dist/chunks/account-limits-cache-hj1h48sc.js +92 -0
- package/dist/chunks/account-limits-cache-hj3ek3ty.js +128 -0
- package/dist/chunks/account-limits-cache-hwehc67r.js +509 -0
- package/dist/chunks/account-limits-cache-hyzn1jmk.js +46 -0
- package/dist/chunks/account-limits-cache-j2bt392s.js +63 -0
- package/dist/chunks/account-limits-cache-k0pkzhbx.js +74 -0
- package/dist/chunks/account-limits-cache-kjx405q0.js +277 -0
- package/dist/chunks/account-limits-cache-ks1sjym9.js +37 -0
- package/dist/chunks/account-limits-cache-me1x57bs.js +89 -0
- package/dist/chunks/account-limits-cache-n3yk6g5c.js +314 -0
- package/dist/chunks/account-limits-cache-nbhht7xz.js +72 -0
- package/dist/chunks/account-limits-cache-nbkyhs6v.js +42 -0
- package/dist/chunks/account-limits-cache-nn9jebsj.js +26 -0
- package/dist/chunks/account-limits-cache-nxkprk3g.js +13 -0
- package/dist/chunks/account-limits-cache-nyy770yd.js +38 -0
- package/dist/chunks/account-limits-cache-pfa86y8e.js +45 -0
- package/dist/chunks/account-limits-cache-pfr14mcn.js +59 -0
- package/dist/chunks/account-limits-cache-q1ebtvet.js +8 -0
- package/dist/chunks/account-limits-cache-q63mc41j.js +51 -0
- package/dist/chunks/account-limits-cache-re8hpzwn.js +104 -0
- package/dist/chunks/account-limits-cache-rz8p1g5y.js +9 -0
- package/dist/chunks/account-limits-cache-skbfmzqe.js +7 -0
- package/dist/chunks/account-limits-cache-tc38g0ca.js +20 -0
- package/dist/chunks/account-limits-cache-v4n30az2.js +24 -0
- package/dist/chunks/account-limits-cache-vwgfz727.js +281 -0
- package/dist/chunks/account-limits-cache-x9fvb3s5.js +8 -0
- package/dist/chunks/account-limits-cache-xds88kxd.js +209 -0
- package/dist/chunks/account-limits-cache-xz65wyd1.js +428 -0
- package/dist/chunks/account-limits-cache-ydq8p8qp.js +39 -0
- package/dist/chunks/account-limits-cache-ykbqsvv6.js +134 -0
- package/dist/chunks/account-limits-cache-za42x8a3.js +25 -0
- package/dist/chunks/account-limits-cache-zcbkmrvy.js +79 -0
- package/dist/chunks/account-limits-cache-zgzptd0z.js +62 -0
- package/dist/chunks/account-limits-cache-zn01kscn.js +252 -0
- package/dist/chunks/account-limits-cache-zpjmeyt0.js +113 -0
- package/dist/chunks/account-limits-cache-zqdb4yh4.js +8 -0
- package/dist/src/account-limits-cache.d.ts +16 -0
- package/dist/src/account-limits-cache.js +7 -0
- package/dist/src/api/anthropic-client.d.ts +25 -0
- package/dist/src/api/anthropic-client.js +30 -0
- package/dist/src/api/anthropic-convert.d.ts +17 -0
- package/dist/src/api/anthropic-convert.js +14 -0
- package/dist/src/api/anthropic-events.d.ts +101 -0
- package/dist/src/api/anthropic-events.js +11 -0
- package/dist/src/api/anthropic-messages.d.ts +88 -0
- package/dist/src/api/anthropic-messages.js +578 -0
- package/dist/src/api/anthropic-messages.lazy.d.ts +2 -0
- package/dist/src/api/anthropic-messages.lazy.js +11 -0
- package/dist/src/api/assistant-stream.d.ts +23 -0
- package/dist/src/api/assistant-stream.js +15 -0
- package/dist/src/api/claude-code.d.ts +12 -0
- package/dist/src/api/claude-code.js +12 -0
- package/dist/src/api/cloudflare.d.ts +8 -0
- package/dist/src/api/cloudflare.js +11 -0
- package/dist/src/api/constrained-sampling.d.ts +24 -0
- package/dist/src/api/constrained-sampling.js +16 -0
- package/dist/src/api/deferred.d.ts +7 -0
- package/dist/src/api/deferred.js +10 -0
- package/dist/src/api/github-copilot-headers.d.ts +15 -0
- package/dist/src/api/github-copilot-headers.js +12 -0
- package/dist/src/api/google-generative-ai.d.ts +22 -0
- package/dist/src/api/google-generative-ai.js +583 -0
- package/dist/src/api/google-generative-ai.lazy.d.ts +2 -0
- package/dist/src/api/google-generative-ai.lazy.js +11 -0
- package/dist/src/api/lazy.d.ts +18 -0
- package/dist/src/api/lazy.js +12 -0
- package/dist/src/api/openai-codex-compact.d.ts +14 -0
- package/dist/src/api/openai-codex-compact.js +389 -0
- package/dist/src/api/openai-codex-compaction-error.d.ts +7 -0
- package/dist/src/api/openai-codex-compaction-error.js +6 -0
- package/dist/src/api/openai-codex-protocol.d.ts +125 -0
- package/dist/src/api/openai-codex-protocol.js +48 -0
- package/dist/src/api/openai-codex-responses.d.ts +4 -0
- package/dist/src/api/openai-codex-responses.js +175 -0
- package/dist/src/api/openai-codex-responses.lazy.d.ts +2 -0
- package/dist/src/api/openai-codex-responses.lazy.js +11 -0
- package/dist/src/api/openai-codex-websocket.d.ts +13 -0
- package/dist/src/api/openai-codex-websocket.js +37 -0
- package/dist/src/api/openai-codex-wire.d.ts +44 -0
- package/dist/src/api/openai-codex-wire.js +34 -0
- package/dist/src/api/openai-compact.d.ts +9 -0
- package/dist/src/api/openai-compact.js +12 -0
- package/dist/src/api/openai-completions-convert.d.ts +58 -0
- package/dist/src/api/openai-completions-convert.js +21 -0
- package/dist/src/api/openai-completions-params.d.ts +29 -0
- package/dist/src/api/openai-completions-params.js +20 -0
- package/dist/src/api/openai-completions-reasoning.d.ts +54 -0
- package/dist/src/api/openai-completions-reasoning.js +22 -0
- package/dist/src/api/openai-completions.d.ts +22 -0
- package/dist/src/api/openai-completions.js +484 -0
- package/dist/src/api/openai-completions.lazy.d.ts +5 -0
- package/dist/src/api/openai-completions.lazy.js +11 -0
- package/dist/src/api/openai-prompt-cache.d.ts +1 -0
- package/dist/src/api/openai-prompt-cache.js +6 -0
- package/dist/src/api/openai-responses-convert.d.ts +58 -0
- package/dist/src/api/openai-responses-convert.js +16 -0
- package/dist/src/api/openai-responses-events.d.ts +379 -0
- package/dist/src/api/openai-responses-events.js +12 -0
- package/dist/src/api/openai-responses-stream.d.ts +36 -0
- package/dist/src/api/openai-responses-stream.js +25 -0
- package/dist/src/api/openai-responses.d.ts +18 -0
- package/dist/src/api/openai-responses.js +276 -0
- package/dist/src/api/openai-responses.lazy.d.ts +2 -0
- package/dist/src/api/openai-responses.lazy.js +11 -0
- package/dist/src/api/simple-options.d.ts +17 -0
- package/dist/src/api/simple-options.js +18 -0
- package/dist/src/api/token-count.d.ts +5 -0
- package/dist/src/api/token-count.js +8 -0
- package/dist/src/api/transform-messages.d.ts +9 -0
- package/dist/src/api/transform-messages.js +6 -0
- package/dist/src/api-options.d.ts +27 -0
- package/dist/src/api-options.js +0 -0
- package/dist/src/auth/context.d.ts +11 -0
- package/dist/src/auth/context.js +6 -0
- package/dist/src/auth/credential-store.d.ts +17 -0
- package/dist/src/auth/credential-store.js +7 -0
- package/dist/src/auth/helpers.d.ts +24 -0
- package/dist/src/auth/helpers.js +8 -0
- package/dist/src/auth/oauth/anthropic.d.ts +7 -0
- package/dist/src/auth/oauth/anthropic.js +12 -0
- package/dist/src/auth/oauth/authorization-input.d.ts +14 -0
- package/dist/src/auth/oauth/authorization-input.js +6 -0
- package/dist/src/auth/oauth/device-code.d.ts +29 -0
- package/dist/src/auth/oauth/device-code.js +9 -0
- package/dist/src/auth/oauth/github-copilot.d.ts +23 -0
- package/dist/src/auth/oauth/github-copilot.js +12 -0
- package/dist/src/auth/oauth/load.d.ts +14 -0
- package/dist/src/auth/oauth/load.js +10 -0
- package/dist/src/auth/oauth/oauth-page.d.ts +13 -0
- package/dist/src/auth/oauth/oauth-page.js +8 -0
- package/dist/src/auth/oauth/openai-codex.d.ts +10 -0
- package/dist/src/auth/oauth/openai-codex.js +18 -0
- package/dist/src/auth/oauth/pkce.d.ts +12 -0
- package/dist/src/auth/oauth/pkce.js +6 -0
- package/dist/src/auth/resolve.d.ts +38 -0
- package/dist/src/auth/resolve.js +12 -0
- package/dist/src/auth/store.d.ts +29 -0
- package/dist/src/auth/store.js +10 -0
- package/dist/src/auth/types.d.ts +291 -0
- package/dist/src/auth/types.js +8 -0
- package/dist/src/auth/verify.d.ts +13 -0
- package/dist/src/auth/verify.js +7 -0
- package/dist/src/bun-oauth.d.ts +2 -0
- package/dist/src/bun-oauth.js +25 -0
- package/dist/src/env-api-keys.d.ts +32 -0
- package/dist/src/env-api-keys.js +27 -0
- package/dist/src/file-models-store.d.ts +18 -0
- package/dist/src/file-models-store.js +9 -0
- package/dist/src/index.d.ts +62 -0
- package/dist/src/index.js +372 -0
- package/dist/src/model-capabilities.d.ts +21 -0
- package/dist/src/model-capabilities.js +14 -0
- package/dist/src/model-pricing.d.ts +6 -0
- package/dist/src/model-pricing.js +10 -0
- package/dist/src/model-variants.d.ts +21 -0
- package/dist/src/model-variants.js +19 -0
- package/dist/src/models-refresh.d.ts +27 -0
- package/dist/src/models-refresh.js +9 -0
- package/dist/src/models-store.d.ts +31 -0
- package/dist/src/models-store.js +6 -0
- package/dist/src/models-types.d.ts +206 -0
- package/dist/src/models-types.js +0 -0
- package/dist/src/models.d.ts +7 -0
- package/dist/src/models.js +44 -0
- package/dist/src/prompt-cache.d.ts +5 -0
- package/dist/src/prompt-cache.js +9 -0
- package/dist/src/provider.d.ts +23 -0
- package/dist/src/provider.js +14 -0
- package/dist/src/providers/account-limits.d.ts +13 -0
- package/dist/src/providers/account-limits.js +8 -0
- package/dist/src/providers/anthropic-limits.d.ts +9 -0
- package/dist/src/providers/anthropic-limits.js +10 -0
- package/dist/src/providers/anthropic.d.ts +2 -0
- package/dist/src/providers/anthropic.js +25 -0
- package/dist/src/providers/github-copilot-catalog.d.ts +5 -0
- package/dist/src/providers/github-copilot-catalog.js +7 -0
- package/dist/src/providers/github-copilot.d.ts +2 -0
- package/dist/src/providers/github-copilot.js +23 -0
- package/dist/src/providers/nyte-catalog.d.ts +15 -0
- package/dist/src/providers/nyte-catalog.js +63 -0
- package/dist/src/providers/openai-codex-limits.d.ts +8 -0
- package/dist/src/providers/openai-codex-limits.js +14 -0
- package/dist/src/providers/openai-codex.d.ts +2 -0
- package/dist/src/providers/openai-codex.js +23 -0
- package/dist/src/providers/openai.d.ts +2 -0
- package/dist/src/providers/openai.js +19 -0
- package/dist/src/providers/opencode-go.d.ts +5 -0
- package/dist/src/providers/opencode-go.js +22 -0
- package/dist/src/providers/opencode-headers.d.ts +5 -0
- package/dist/src/providers/opencode-headers.js +6 -0
- package/dist/src/providers/opencode.d.ts +14 -0
- package/dist/src/providers/opencode.js +23 -0
- package/dist/src/providers/openrouter.d.ts +2 -0
- package/dist/src/providers/openrouter.js +19 -0
- package/dist/src/providers/vercel-ai-gateway.d.ts +3 -0
- package/dist/src/providers/vercel-ai-gateway.js +19 -0
- package/dist/src/session-resources.d.ts +9 -0
- package/dist/src/session-resources.js +10 -0
- package/dist/src/types.d.ts +210 -0
- package/dist/src/types.js +1 -0
- package/dist/src/utils/abort.d.ts +12 -0
- package/dist/src/utils/abort.js +10 -0
- package/dist/src/utils/deferred-tools.d.ts +11 -0
- package/dist/src/utils/deferred-tools.js +6 -0
- package/dist/src/utils/diagnostics.d.ts +11 -0
- package/dist/src/utils/diagnostics.js +12 -0
- package/dist/src/utils/error-body.d.ts +26 -0
- package/dist/src/utils/error-body.js +10 -0
- package/dist/src/utils/estimate.d.ts +20 -0
- package/dist/src/utils/estimate.js +14 -0
- package/dist/src/utils/event-stream.d.ts +22 -0
- package/dist/src/utils/event-stream.js +11 -0
- package/dist/src/utils/failure.d.ts +49 -0
- package/dist/src/utils/failure.js +10 -0
- package/dist/src/utils/fifo-queue.d.ts +11 -0
- package/dist/src/utils/fifo-queue.js +6 -0
- package/dist/src/utils/hash.d.ts +5 -0
- package/dist/src/utils/hash.js +6 -0
- package/dist/src/utils/headers.d.ts +12 -0
- package/dist/src/utils/headers.js +14 -0
- package/dist/src/utils/json-parse.d.ts +33 -0
- package/dist/src/utils/json-parse.js +12 -0
- package/dist/src/utils/node-http-proxy.d.ts +6 -0
- package/dist/src/utils/node-http-proxy.js +9 -0
- package/dist/src/utils/nyte-home.d.ts +2 -0
- package/dist/src/utils/nyte-home.js +6 -0
- package/dist/src/utils/nyte-user-agent.d.ts +1 -0
- package/dist/src/utils/nyte-user-agent.js +6 -0
- package/dist/src/utils/overflow.d.ts +18 -0
- package/dist/src/utils/overflow.js +9 -0
- package/dist/src/utils/provider-env.d.ts +9 -0
- package/dist/src/utils/provider-env.js +6 -0
- package/dist/src/utils/provider-retry.d.ts +22 -0
- package/dist/src/utils/provider-retry.js +9 -0
- package/dist/src/utils/retry.d.ts +66 -0
- package/dist/src/utils/retry.js +18 -0
- package/dist/src/utils/sanitize-unicode.d.ts +24 -0
- package/dist/src/utils/sanitize-unicode.js +6 -0
- package/dist/src/utils/sse.d.ts +21 -0
- package/dist/src/utils/sse.js +6 -0
- package/dist/src/utils/text.d.ts +5 -0
- package/dist/src/utils/text.js +10 -0
- package/dist/src/utils/transcript.d.ts +5 -0
- package/dist/src/utils/transcript.js +36 -0
- package/dist/src/utils/typebox-helpers.d.ts +19 -0
- package/dist/src/utils/typebox-helpers.js +6 -0
- package/dist/src/utils/uuid.d.ts +2 -0
- package/dist/src/utils/uuid.js +6 -0
- package/dist/src/utils/validation.d.ts +13 -0
- package/dist/src/utils/validation.js +8 -0
- package/package.json +152 -3
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
headersToRecord2
|
|
3
|
+
} from "../../chunks/account-limits-cache-ag5b8dja.js";
|
|
4
|
+
import"../../chunks/account-limits-cache-gknnm1kv.js";
|
|
5
|
+
import {
|
|
6
|
+
normalizeTimeoutMs2,
|
|
7
|
+
resolveCodexUrl2,
|
|
8
|
+
extractAccountId2,
|
|
9
|
+
buildSSEHeaders2,
|
|
10
|
+
buildWebSocketHeaders2
|
|
11
|
+
} from "../../chunks/account-limits-cache-fvadc36m.js";
|
|
12
|
+
import"../../chunks/account-limits-cache-ehy0ze2b.js";
|
|
13
|
+
import {
|
|
14
|
+
codexHeaderLimits2
|
|
15
|
+
} from "../../chunks/account-limits-cache-hj3ek3ty.js";
|
|
16
|
+
import {
|
|
17
|
+
formatThrownValue2
|
|
18
|
+
} from "../../chunks/account-limits-cache-9wqk28n5.js";
|
|
19
|
+
import {
|
|
20
|
+
reportsQuotaExhaustion2
|
|
21
|
+
} from "../../chunks/account-limits-cache-xds88kxd.js";
|
|
22
|
+
import"../../chunks/account-limits-cache-j2bt392s.js";
|
|
23
|
+
import {
|
|
24
|
+
retryProviderRequest2
|
|
25
|
+
} from "../../chunks/account-limits-cache-nbhht7xz.js";
|
|
26
|
+
import {
|
|
27
|
+
getDeclaredTools2,
|
|
28
|
+
resolveTranscript2
|
|
29
|
+
} from "../../chunks/account-limits-cache-6250ykn6.js";
|
|
30
|
+
import {
|
|
31
|
+
uuidv72
|
|
32
|
+
} from "../../chunks/account-limits-cache-8137j3zp.js";
|
|
33
|
+
import"../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
34
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
35
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
36
|
+
import {
|
|
37
|
+
runAssistantStream2
|
|
38
|
+
} from "../../chunks/account-limits-cache-fsktnetm.js";
|
|
39
|
+
import {
|
|
40
|
+
createGrammarToolInputProperties2
|
|
41
|
+
} from "../../chunks/account-limits-cache-h92bzz1j.js";
|
|
42
|
+
import"../../chunks/account-limits-cache-f9z00x8c.js";
|
|
43
|
+
import"../../chunks/account-limits-cache-8s8bz4dr.js";
|
|
44
|
+
import"../../chunks/account-limits-cache-me1x57bs.js";
|
|
45
|
+
import"../../chunks/account-limits-cache-b4edaybk.js";
|
|
46
|
+
import"../../chunks/account-limits-cache-0af5gqeg.js";
|
|
47
|
+
import"../../chunks/account-limits-cache-eqwweapz.js";
|
|
48
|
+
import"../../chunks/account-limits-cache-8qzk56vj.js";
|
|
49
|
+
import"../../chunks/account-limits-cache-n3yk6g5c.js";
|
|
50
|
+
import {
|
|
51
|
+
compressRequestBodyZstd2,
|
|
52
|
+
buildRequestBody2,
|
|
53
|
+
codexStreamOptions2,
|
|
54
|
+
CodexRequestError2,
|
|
55
|
+
retryableCodexRequest2,
|
|
56
|
+
mapCodexEvents2,
|
|
57
|
+
parseSSE2,
|
|
58
|
+
parseErrorResponse2
|
|
59
|
+
} from "../../chunks/account-limits-cache-vwgfz727.js";
|
|
60
|
+
import"../../chunks/account-limits-cache-gqsrbky9.js";
|
|
61
|
+
import"../../chunks/account-limits-cache-b23sbrke.js";
|
|
62
|
+
import"../../chunks/account-limits-cache-0yd6bde8.js";
|
|
63
|
+
import"../../chunks/account-limits-cache-zgzptd0z.js";
|
|
64
|
+
import"../../chunks/account-limits-cache-fbkaq46e.js";
|
|
65
|
+
import"../../chunks/account-limits-cache-736tdyme.js";
|
|
66
|
+
import"../../chunks/account-limits-cache-a558rjbg.js";
|
|
67
|
+
import {
|
|
68
|
+
withPriorityTier2,
|
|
69
|
+
processResponsesStream2
|
|
70
|
+
} from "../../chunks/account-limits-cache-53e64mhx.js";
|
|
71
|
+
import {
|
|
72
|
+
streamOverWebSocket2
|
|
73
|
+
} from "../../chunks/account-limits-cache-hwehc67r.js";
|
|
74
|
+
import {
|
|
75
|
+
clampOpenAIPromptCacheKey2
|
|
76
|
+
} from "../../chunks/account-limits-cache-csbxvam7.js";
|
|
77
|
+
import"../../chunks/account-limits-cache-dejeygdt.js";
|
|
78
|
+
import {
|
|
79
|
+
buildBaseOptions2,
|
|
80
|
+
simpleReasoningEffort2
|
|
81
|
+
} from "../../chunks/account-limits-cache-k0pkzhbx.js";
|
|
82
|
+
|
|
83
|
+
// src/api/openai-codex-responses.ts
|
|
84
|
+
async function openCodexSse(model, headers, body, timeoutMs, options) {
|
|
85
|
+
const headerTimeout = new AbortController;
|
|
86
|
+
const timer = timeoutMs !== undefined && timeoutMs > 0 ? setTimeout(() => headerTimeout.abort(), timeoutMs) : undefined;
|
|
87
|
+
const signal = options?.signal ? AbortSignal.any([options.signal, headerTimeout.signal]) : headerTimeout.signal;
|
|
88
|
+
let response;
|
|
89
|
+
try {
|
|
90
|
+
response = await (options?.fetch ?? globalThis.fetch)(resolveCodexUrl2(model.baseUrl), {
|
|
91
|
+
method: "POST",
|
|
92
|
+
headers,
|
|
93
|
+
body,
|
|
94
|
+
signal
|
|
95
|
+
});
|
|
96
|
+
} catch (cause) {
|
|
97
|
+
if (options?.signal?.aborted)
|
|
98
|
+
throw cause;
|
|
99
|
+
throw new CodexRequestError2(headerTimeout.signal.aborted ? `Codex SSE response headers timed out after ${String(timeoutMs)}ms` : formatThrownValue2(cause), undefined, undefined, true, { cause });
|
|
100
|
+
} finally {
|
|
101
|
+
clearTimeout(timer);
|
|
102
|
+
}
|
|
103
|
+
const responseHeaders = headersToRecord2(response.headers);
|
|
104
|
+
await options?.onResponse?.({ status: response.status, headers: responseHeaders }, model);
|
|
105
|
+
if (response.ok) {
|
|
106
|
+
if (options?.onAccountLimits !== undefined) {
|
|
107
|
+
const limits = codexHeaderLimits2(responseHeaders, model.provider);
|
|
108
|
+
if (limits !== undefined)
|
|
109
|
+
await options.onAccountLimits(limits, model);
|
|
110
|
+
}
|
|
111
|
+
return response;
|
|
112
|
+
}
|
|
113
|
+
const errorText = await response.text();
|
|
114
|
+
const info = parseErrorResponse2(errorText, response);
|
|
115
|
+
throw new CodexRequestError2(info.friendlyMessage || info.message, response.status, response.headers, !(response.status === 429 && reportsQuotaExhaustion2(errorText)));
|
|
116
|
+
}
|
|
117
|
+
async function streamOverSse(request, headers, output, stream) {
|
|
118
|
+
const { model, options } = request;
|
|
119
|
+
const bodyJson = JSON.stringify(request.body);
|
|
120
|
+
const compressedBody = compressRequestBodyZstd2(bodyJson);
|
|
121
|
+
if (compressedBody)
|
|
122
|
+
headers.set("content-encoding", "zstd");
|
|
123
|
+
const response = await retryProviderRequest2(() => openCodexSse(model, headers, compressedBody ?? bodyJson, request.timeoutMs, options), {
|
|
124
|
+
maxRetries: options?.maxRetries,
|
|
125
|
+
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
126
|
+
signal: options?.signal,
|
|
127
|
+
retryable: retryableCodexRequest2
|
|
128
|
+
});
|
|
129
|
+
if (!response.body)
|
|
130
|
+
throw new Error("No response body");
|
|
131
|
+
stream.push({ type: "start", partial: output });
|
|
132
|
+
await processResponsesStream2(mapCodexEvents2(parseSSE2(response, options?.signal), output), output, stream, model, codexStreamOptions2(request));
|
|
133
|
+
}
|
|
134
|
+
var stream = (model, context, requested) => {
|
|
135
|
+
const options = withPriorityTier2(requested);
|
|
136
|
+
const normalizedContext = resolveTranscript2(context, model.compat?.supportsMidConvoSystemMessages);
|
|
137
|
+
return runAssistantStream2(model, options?.signal, "Codex", async (output, stream) => {
|
|
138
|
+
const apiKey = options?.apiKey;
|
|
139
|
+
if (!apiKey) {
|
|
140
|
+
throw new Error(`No API key for provider: ${model.provider}`);
|
|
141
|
+
}
|
|
142
|
+
const accountId = extractAccountId2(apiKey);
|
|
143
|
+
const grammarToolInputProperties = createGrammarToolInputProperties2(getDeclaredTools2(normalizedContext.messages), model.compat?.supportsOpenAIGrammarTools ?? false);
|
|
144
|
+
const cacheSessionId = options?.cacheRetention === "none" ? undefined : options?.sessionId;
|
|
145
|
+
const codexSessionId = clampOpenAIPromptCacheKey2(cacheSessionId);
|
|
146
|
+
const body = buildRequestBody2(model, normalizedContext, options, codexSessionId, grammarToolInputProperties);
|
|
147
|
+
await options?.onPayload?.(body, model);
|
|
148
|
+
const request = {
|
|
149
|
+
model,
|
|
150
|
+
body,
|
|
151
|
+
accountId,
|
|
152
|
+
cacheSessionId,
|
|
153
|
+
grammarToolInputProperties,
|
|
154
|
+
timeoutMs: normalizeTimeoutMs2(options?.timeoutMs),
|
|
155
|
+
connectTimeoutMs: normalizeTimeoutMs2(options?.websocketConnectTimeoutMs),
|
|
156
|
+
options
|
|
157
|
+
};
|
|
158
|
+
const websocketHeaders = buildWebSocketHeaders2(model.headers, options?.headers, accountId, apiKey, codexSessionId || uuidv72());
|
|
159
|
+
if (await streamOverWebSocket2(request, websocketHeaders, output, stream))
|
|
160
|
+
return;
|
|
161
|
+
await streamOverSse(request, buildSSEHeaders2(model.headers, options?.headers, accountId, apiKey, codexSessionId), output, stream);
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
var streamSimple = (model, context, options) => {
|
|
165
|
+
if (!options?.apiKey)
|
|
166
|
+
throw new Error(`No API key for provider: ${model.provider}`);
|
|
167
|
+
return stream(model, context, {
|
|
168
|
+
...buildBaseOptions2(model, context, options),
|
|
169
|
+
reasoningEffort: simpleReasoningEffort2(model, options.reasoning)
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
export {
|
|
173
|
+
stream,
|
|
174
|
+
streamSimple
|
|
175
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openAICodexResponsesApi2
|
|
3
|
+
} from "../../chunks/account-limits-cache-5rx2pfm5.js";
|
|
4
|
+
import"../../chunks/account-limits-cache-90c9c2eb.js";
|
|
5
|
+
import"../../chunks/account-limits-cache-fsktnetm.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
7
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
9
|
+
export {
|
|
10
|
+
openAICodexResponsesApi2 as openAICodexResponsesApi
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AssistantMessage } from "../types.ts";
|
|
2
|
+
import type { AssistantMessageEventStream } from "../utils/event-stream.ts";
|
|
3
|
+
import { type CodexRequest } from "./openai-codex-protocol.ts";
|
|
4
|
+
/** Closes the cached sockets of `sessionId`, or of every session, and forgets their SSE fallback. */
|
|
5
|
+
export declare function closeOpenAICodexWebSocketSessions(sessionId?: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Streams `request` over a Codex WebSocket into `output`, pushing `start` on the first event.
|
|
8
|
+
* One retry each covers a missing continuation and a connection limit hit before any event.
|
|
9
|
+
* A transport failure before any event records a diagnostic, moves the session onto SSE and
|
|
10
|
+
* returns false so the caller sends the request over SSE; protocol and API failures, and any
|
|
11
|
+
* failure after the first event, throw.
|
|
12
|
+
*/
|
|
13
|
+
export declare function streamOverWebSocket(request: CodexRequest, headers: Headers, output: AssistantMessage, stream: AssistantMessageEventStream): Promise<boolean>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
closeOpenAICodexWebSocketSessions2,
|
|
3
|
+
streamOverWebSocket2
|
|
4
|
+
} from "../../chunks/account-limits-cache-hwehc67r.js";
|
|
5
|
+
import"../../chunks/account-limits-cache-53e64mhx.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-a558rjbg.js";
|
|
7
|
+
import"../../chunks/account-limits-cache-vwgfz727.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-n3yk6g5c.js";
|
|
9
|
+
import"../../chunks/account-limits-cache-8qzk56vj.js";
|
|
10
|
+
import"../../chunks/account-limits-cache-736tdyme.js";
|
|
11
|
+
import"../../chunks/account-limits-cache-h92bzz1j.js";
|
|
12
|
+
import"../../chunks/account-limits-cache-eqwweapz.js";
|
|
13
|
+
import"../../chunks/account-limits-cache-me1x57bs.js";
|
|
14
|
+
import"../../chunks/account-limits-cache-0af5gqeg.js";
|
|
15
|
+
import"../../chunks/account-limits-cache-0yd6bde8.js";
|
|
16
|
+
import"../../chunks/account-limits-cache-8s8bz4dr.js";
|
|
17
|
+
import"../../chunks/account-limits-cache-hj3ek3ty.js";
|
|
18
|
+
import"../../chunks/account-limits-cache-fvadc36m.js";
|
|
19
|
+
import"../../chunks/account-limits-cache-ehy0ze2b.js";
|
|
20
|
+
import"../../chunks/account-limits-cache-b4edaybk.js";
|
|
21
|
+
import"../../chunks/account-limits-cache-6250ykn6.js";
|
|
22
|
+
import"../../chunks/account-limits-cache-fbkaq46e.js";
|
|
23
|
+
import"../../chunks/account-limits-cache-gknnm1kv.js";
|
|
24
|
+
import"../../chunks/account-limits-cache-ag5b8dja.js";
|
|
25
|
+
import"../../chunks/account-limits-cache-fsktnetm.js";
|
|
26
|
+
import"../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
27
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
28
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
29
|
+
import"../../chunks/account-limits-cache-9wqk28n5.js";
|
|
30
|
+
import"../../chunks/account-limits-cache-gqsrbky9.js";
|
|
31
|
+
import"../../chunks/account-limits-cache-b23sbrke.js";
|
|
32
|
+
import"../../chunks/account-limits-cache-zgzptd0z.js";
|
|
33
|
+
import"../../chunks/account-limits-cache-f9z00x8c.js";
|
|
34
|
+
export {
|
|
35
|
+
closeOpenAICodexWebSocketSessions2 as closeOpenAICodexWebSocketSessions,
|
|
36
|
+
streamOverWebSocket2 as streamOverWebSocket
|
|
37
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ChatGPT Codex backend's wire basics: endpoint URLs, the account id inside the OAuth
|
|
3
|
+
* token, request headers, and the raw frame both transports decode.
|
|
4
|
+
*/
|
|
5
|
+
import { Type } from "typebox";
|
|
6
|
+
import type { ProviderHeaders } from "../types.ts";
|
|
7
|
+
/**
|
|
8
|
+
* The fields this adapter acts on in a raw Codex SSE/WebSocket frame. Frames
|
|
9
|
+
* carry more fields; unlisted ones pass through untouched. Decoding happens once
|
|
10
|
+
* at the two ingress points (`parseSSE`, `parseWebSocket`) so downstream code
|
|
11
|
+
* branches on decoded values instead of re-narrowing raw JSON.
|
|
12
|
+
*/
|
|
13
|
+
export interface CodexFrame {
|
|
14
|
+
readonly type: string;
|
|
15
|
+
readonly code?: unknown;
|
|
16
|
+
readonly message?: unknown;
|
|
17
|
+
readonly error?: unknown;
|
|
18
|
+
readonly response?: unknown;
|
|
19
|
+
readonly item?: unknown;
|
|
20
|
+
}
|
|
21
|
+
export declare const CodexFrameJson: Type.TObject<{
|
|
22
|
+
type: Type.TString;
|
|
23
|
+
}>;
|
|
24
|
+
/** `value` when it is a string. */
|
|
25
|
+
export declare function readText(value: unknown): string | undefined;
|
|
26
|
+
/** `value` when it is a boolean. */
|
|
27
|
+
export declare function readBoolean(value: unknown): boolean | undefined;
|
|
28
|
+
/** `value` when it is a number. */
|
|
29
|
+
export declare function readNumber(value: unknown): number | undefined;
|
|
30
|
+
/** `value` when it is a JSON object. */
|
|
31
|
+
export declare function readRecord(value: unknown): Record<string, unknown> | undefined;
|
|
32
|
+
/** Frame types that end a Codex response. */
|
|
33
|
+
export declare const TERMINAL_RESPONSE_TYPES: ReadonlySet<string>;
|
|
34
|
+
export declare const DEFAULT_CODEX_BASE_URL = "https://chatgpt.com/backend-api";
|
|
35
|
+
/** A caller timeout floored to whole milliseconds; a negative or non-finite one is rejected. */
|
|
36
|
+
export declare function normalizeTimeoutMs(value: number | undefined): number | undefined;
|
|
37
|
+
export declare function resolveCodexUrl(baseUrl?: string): string;
|
|
38
|
+
export declare function resolveCodexWebSocketUrl(baseUrl?: string): string;
|
|
39
|
+
/** The ChatGPT account id from the OAuth access token's JWT payload. */
|
|
40
|
+
export declare function extractAccountId(token: string): string;
|
|
41
|
+
/** Model and caller headers plus the Codex identity every request carries. */
|
|
42
|
+
export declare function buildBaseCodexHeaders(initHeaders: Record<string, string> | undefined, additionalHeaders: ProviderHeaders | undefined, accountId: string, token: string): Headers;
|
|
43
|
+
export declare function buildSSEHeaders(initHeaders: Record<string, string> | undefined, additionalHeaders: ProviderHeaders | undefined, accountId: string, token: string, sessionId?: string): Headers;
|
|
44
|
+
export declare function buildWebSocketHeaders(initHeaders: Record<string, string> | undefined, additionalHeaders: ProviderHeaders | undefined, accountId: string, token: string, requestId: string): Headers;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodexFrameJson2,
|
|
3
|
+
readText2,
|
|
4
|
+
readBoolean2,
|
|
5
|
+
readNumber2,
|
|
6
|
+
readRecord2,
|
|
7
|
+
TERMINAL_RESPONSE_TYPES2,
|
|
8
|
+
DEFAULT_CODEX_BASE_URL2,
|
|
9
|
+
normalizeTimeoutMs2,
|
|
10
|
+
resolveCodexUrl2,
|
|
11
|
+
resolveCodexWebSocketUrl2,
|
|
12
|
+
extractAccountId2,
|
|
13
|
+
buildBaseCodexHeaders2,
|
|
14
|
+
buildSSEHeaders2,
|
|
15
|
+
buildWebSocketHeaders2
|
|
16
|
+
} from "../../chunks/account-limits-cache-fvadc36m.js";
|
|
17
|
+
import"../../chunks/account-limits-cache-gknnm1kv.js";
|
|
18
|
+
import"../../chunks/account-limits-cache-ag5b8dja.js";
|
|
19
|
+
export {
|
|
20
|
+
CodexFrameJson2 as CodexFrameJson,
|
|
21
|
+
DEFAULT_CODEX_BASE_URL2 as DEFAULT_CODEX_BASE_URL,
|
|
22
|
+
TERMINAL_RESPONSE_TYPES2 as TERMINAL_RESPONSE_TYPES,
|
|
23
|
+
buildBaseCodexHeaders2 as buildBaseCodexHeaders,
|
|
24
|
+
buildSSEHeaders2 as buildSSEHeaders,
|
|
25
|
+
buildWebSocketHeaders2 as buildWebSocketHeaders,
|
|
26
|
+
extractAccountId2 as extractAccountId,
|
|
27
|
+
normalizeTimeoutMs2 as normalizeTimeoutMs,
|
|
28
|
+
readBoolean2 as readBoolean,
|
|
29
|
+
readNumber2 as readNumber,
|
|
30
|
+
readRecord2 as readRecord,
|
|
31
|
+
readText2 as readText,
|
|
32
|
+
resolveCodexUrl2 as resolveCodexUrl,
|
|
33
|
+
resolveCodexWebSocketUrl2 as resolveCodexWebSocketUrl
|
|
34
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
|
|
2
|
+
import type { Api, JsonValue, Model, Usage } from "../types.ts";
|
|
3
|
+
export interface OpenAICompactResult {
|
|
4
|
+
/** The complete opaque window, replayed unchanged to the matching provider. */
|
|
5
|
+
readonly data: JsonValue;
|
|
6
|
+
readonly usage?: Usage;
|
|
7
|
+
}
|
|
8
|
+
/** Decode the JSON envelope; provider-owned item contents remain opaque. */
|
|
9
|
+
export declare function readOpenAICompactResponse(response: Response, model: Model<Api>, requestedServiceTier?: ResponseCreateParamsStreaming["service_tier"]): Promise<OpenAICompactResult>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readOpenAICompactResponse2
|
|
3
|
+
} from "../../chunks/account-limits-cache-pfr14mcn.js";
|
|
4
|
+
import"../../chunks/account-limits-cache-fsktnetm.js";
|
|
5
|
+
import"../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
7
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-zgzptd0z.js";
|
|
9
|
+
import"../../chunks/account-limits-cache-f9z00x8c.js";
|
|
10
|
+
export {
|
|
11
|
+
readOpenAICompactResponse2 as readOpenAICompactResponse
|
|
12
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion of the neutral transcript and tools into Chat Completions
|
|
3
|
+
* messages, the catalog compat they follow, and Anthropic-style cache control.
|
|
4
|
+
*/
|
|
5
|
+
import OpenAI from "openai";
|
|
6
|
+
import type { ChatCompletionMessageParam } from "openai/resources/chat/completions.js";
|
|
7
|
+
import type { CacheRetention, Model, OpenAICompletionsCompat, Tool, TranscriptContext } from "../types.ts";
|
|
8
|
+
interface ConvertCompletionsMessagesOptions {
|
|
9
|
+
grammarToolInputProperties?: ReadonlyMap<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "cacheControlFormat" | "deferredToolsMode" | "supportsThinkingTokenBudget" | "thinkingTokenBudgetField" | "supportsMidConvoSystemMessages" | "supportsMidConvoToolAdditions"> & {
|
|
12
|
+
cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
|
|
13
|
+
deferredToolsMode?: OpenAICompletionsCompat["deferredToolsMode"];
|
|
14
|
+
supportsThinkingTokenBudget?: OpenAICompletionsCompat["supportsThinkingTokenBudget"];
|
|
15
|
+
thinkingTokenBudgetField?: OpenAICompletionsCompat["thinkingTokenBudgetField"];
|
|
16
|
+
supportsMidConvoSystemMessages?: OpenAICompletionsCompat["supportsMidConvoSystemMessages"];
|
|
17
|
+
supportsMidConvoToolAdditions?: OpenAICompletionsCompat["supportsMidConvoToolAdditions"];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The model's compat over the defaults. The catalog generator stamps every provider quirk onto
|
|
21
|
+
* `model.compat`, so nothing here sniffs the provider name or base URL.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveCompat(model: Model<"openai-completions">): ResolvedOpenAICompletionsCompat;
|
|
24
|
+
type KimiToolSystemMessageParam = {
|
|
25
|
+
role: "system";
|
|
26
|
+
content?: never;
|
|
27
|
+
tools?: OpenAI.Chat.Completions.ChatCompletionTool[];
|
|
28
|
+
};
|
|
29
|
+
export type CompletionsMessage = ChatCompletionMessageParam | KimiToolSystemMessageParam;
|
|
30
|
+
interface OpenAICompatCacheControl {
|
|
31
|
+
type: "ephemeral";
|
|
32
|
+
ttl?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function getCompatCacheControl(compat: ResolvedOpenAICompletionsCompat, cacheRetention: CacheRetention): OpenAICompatCacheControl | undefined;
|
|
35
|
+
export declare function applyAnthropicCacheControl(messages: CompletionsMessage[], tools: OpenAI.Chat.Completions.ChatCompletionTool[] | undefined, cacheControl: OpenAICompatCacheControl): void;
|
|
36
|
+
/**
|
|
37
|
+
* The transcript as Chat Completions messages, shaped by the model's compat.
|
|
38
|
+
*
|
|
39
|
+
* - Tool results load request-list tools through `addedToolNames` only in Kimi mode; anchored
|
|
40
|
+
* additions are not in the request list, so neither path declares a tool twice.
|
|
41
|
+
* - Some providers reject a user message right after tool results, so a synthetic assistant
|
|
42
|
+
* message bridges the gap; some reject null assistant content, so it is an empty string.
|
|
43
|
+
* - Copilot accepts reasoning text only alongside its opaque state; text without the state is
|
|
44
|
+
* dropped rather than replayed as a bare field.
|
|
45
|
+
* - Thinking replayed as text carries no tags, so the model does not mimic them.
|
|
46
|
+
* - `reasoning_details` is the structured alternative to a raw reasoning field; without it the
|
|
47
|
+
* first thinking block's signature names the field (llama.cpp server with gpt-oss).
|
|
48
|
+
* - Assistant messages with neither content nor tool calls are skipped: providers require one
|
|
49
|
+
* of them, and aborted responses can have neither.
|
|
50
|
+
* - Every tool result carries text, a placeholder when it has only images, and its tool name
|
|
51
|
+
* for providers that require it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function convertMessages(model: Model<"openai-completions">, context: TranscriptContext, compat: ResolvedOpenAICompletionsCompat, options?: ConvertCompletionsMessagesOptions): CompletionsMessage[];
|
|
54
|
+
/**
|
|
55
|
+
* Only include strict if provider supports it. Some reject unknown fields.
|
|
56
|
+
*/
|
|
57
|
+
export declare function convertTools(tools: Tool[], compat: ResolvedOpenAICompletionsCompat): OpenAI.Chat.Completions.ChatCompletionTool[];
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveCompat2,
|
|
3
|
+
getCompatCacheControl2,
|
|
4
|
+
applyAnthropicCacheControl2,
|
|
5
|
+
convertMessages2,
|
|
6
|
+
convertTools2
|
|
7
|
+
} from "../../chunks/account-limits-cache-fdwad56n.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-hj1h48sc.js";
|
|
9
|
+
import"../../chunks/account-limits-cache-8qzk56vj.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
|
+
export {
|
|
16
|
+
applyAnthropicCacheControl2 as applyAnthropicCacheControl,
|
|
17
|
+
convertMessages2 as convertMessages,
|
|
18
|
+
convertTools2 as convertTools,
|
|
19
|
+
getCompatCacheControl2 as getCompatCacheControl,
|
|
20
|
+
resolveCompat2 as resolveCompat
|
|
21
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Chat Completions request body: options, token limits, tools, and each
|
|
3
|
+
* server family's reasoning parameters.
|
|
4
|
+
*/
|
|
5
|
+
import OpenAI from "openai";
|
|
6
|
+
import type { CacheRetention, Model, StreamOptions, ThinkingBudgets, TranscriptContext } from "../types.ts";
|
|
7
|
+
import { type ResolvedOpenAICompletionsCompat, type CompletionsMessage } from "./openai-completions-convert.ts";
|
|
8
|
+
export interface OpenAICompletionsOptions extends StreamOptions {
|
|
9
|
+
toolChoice?: OpenAI.Chat.Completions.ChatCompletionToolChoiceOption;
|
|
10
|
+
reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
11
|
+
/** Token budgets per thinking level. Used when `compat.thinkingTokenBudgetField` or `compat.supportsThinkingTokenBudget` is set, or by `{ "$var": "thinking.budget" }`. */
|
|
12
|
+
thinkingBudgets?: ThinkingBudgets;
|
|
13
|
+
}
|
|
14
|
+
type CompletionsRequest = Omit<OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming, "messages"> & {
|
|
15
|
+
messages: CompletionsMessage[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The Chat Completions request body.
|
|
19
|
+
*
|
|
20
|
+
* - A transcript with tool history always sends `tools`, empty if need be: Anthropic behind
|
|
21
|
+
* LiteLLM-style proxies requires it whenever messages carry tool calls or results.
|
|
22
|
+
* - OpenRouter normalizes reasoning across providers through a nested `reasoning` object.
|
|
23
|
+
* - A top-level thinking budget field caps reasoning independently of `thinkingFormat`, since one
|
|
24
|
+
* server can serve zai, qwen or chat-template models. Reasoning and the answer share
|
|
25
|
+
* `max_tokens` there, so uncapped reasoning can consume the whole response.
|
|
26
|
+
* - `samplingParams` merge last, so custom keys override the named request fields.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildParams(model: Model<"openai-completions">, context: TranscriptContext, options?: OpenAICompletionsOptions, compat?: ResolvedOpenAICompletionsCompat, cacheRetention?: CacheRetention, grammarToolInputProperties?: ReadonlyMap<string, string>): CompletionsRequest;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildParams2
|
|
3
|
+
} from "../../chunks/account-limits-cache-zn01kscn.js";
|
|
4
|
+
import"../../chunks/account-limits-cache-fdwad56n.js";
|
|
5
|
+
import"../../chunks/account-limits-cache-hj1h48sc.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-csbxvam7.js";
|
|
7
|
+
import"../../chunks/account-limits-cache-k0pkzhbx.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-8qzk56vj.js";
|
|
9
|
+
import"../../chunks/account-limits-cache-h92bzz1j.js";
|
|
10
|
+
import"../../chunks/account-limits-cache-eqwweapz.js";
|
|
11
|
+
import"../../chunks/account-limits-cache-0af5gqeg.js";
|
|
12
|
+
import"../../chunks/account-limits-cache-b4edaybk.js";
|
|
13
|
+
import"../../chunks/account-limits-cache-6250ykn6.js";
|
|
14
|
+
import"../../chunks/account-limits-cache-dejeygdt.js";
|
|
15
|
+
import"../../chunks/account-limits-cache-d2a51dka.js";
|
|
16
|
+
import"../../chunks/account-limits-cache-b23sbrke.js";
|
|
17
|
+
import"../../chunks/account-limits-cache-zgzptd0z.js";
|
|
18
|
+
export {
|
|
19
|
+
buildParams2 as buildParams
|
|
20
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reasoning replay data on OpenAI-compatible Chat Completions: OpenRouter
|
|
3
|
+
* `reasoning_details`, the raw reasoning fields servers stream, and Copilot's
|
|
4
|
+
* `reasoning_opaque` state.
|
|
5
|
+
*/
|
|
6
|
+
import { Type, type Static } from "typebox";
|
|
7
|
+
export declare const OpenAIReasoningDetailSchema: Type.TUnion<[Type.TObject<{
|
|
8
|
+
type: Type.TLiteral<"reasoning.summary">;
|
|
9
|
+
summary: Type.TString;
|
|
10
|
+
id: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
11
|
+
format: Type.TOptional<Type.TString>;
|
|
12
|
+
index: Type.TOptional<Type.TNumber>;
|
|
13
|
+
}>, Type.TObject<{
|
|
14
|
+
type: Type.TLiteral<"reasoning.encrypted">;
|
|
15
|
+
data: Type.TString;
|
|
16
|
+
id: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
17
|
+
format: Type.TOptional<Type.TString>;
|
|
18
|
+
index: Type.TOptional<Type.TNumber>;
|
|
19
|
+
}>, Type.TObject<{
|
|
20
|
+
type: Type.TLiteral<"reasoning.text">;
|
|
21
|
+
text: Type.TString;
|
|
22
|
+
signature: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
23
|
+
id: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
24
|
+
format: Type.TOptional<Type.TString>;
|
|
25
|
+
index: Type.TOptional<Type.TNumber>;
|
|
26
|
+
}>]>;
|
|
27
|
+
export type OpenAIReasoningDetail = Static<typeof OpenAIReasoningDetailSchema>;
|
|
28
|
+
type OpenAIEncryptedReasoningDetail = Extract<OpenAIReasoningDetail, {
|
|
29
|
+
type: "reasoning.encrypted";
|
|
30
|
+
}>;
|
|
31
|
+
export declare function parseOpenAIReasoningDetails(signature: string | undefined): OpenAIReasoningDetail[] | undefined;
|
|
32
|
+
export declare function parseLegacyEncryptedReasoningDetail(signature: string | undefined): OpenAIEncryptedReasoningDetail | undefined;
|
|
33
|
+
export declare function appendOpenAIReasoningDetail(details: OpenAIReasoningDetail[], detail: OpenAIReasoningDetail): void;
|
|
34
|
+
declare const OPENAI_COMPLETIONS_REASONING_FIELDS: readonly ["reasoning", "reasoning_content", "reasoning_text"];
|
|
35
|
+
export type OpenAICompletionsReasoningField = (typeof OPENAI_COMPLETIONS_REASONING_FIELDS)[number];
|
|
36
|
+
export declare const OpenAICompletionsReasoningFieldSchema: Type.TEnum<["reasoning", "reasoning_content", "reasoning_text"]>;
|
|
37
|
+
/**
|
|
38
|
+
* Copilot continues a model's reasoning across turns only when the assistant
|
|
39
|
+
* message replays `reasoning_opaque`; it rides in the thinking signature.
|
|
40
|
+
*/
|
|
41
|
+
export declare const CopilotReasoningOpaqueSchema: Type.TObject<{
|
|
42
|
+
reasoning_opaque: Type.TString;
|
|
43
|
+
}>;
|
|
44
|
+
export declare const REASONING_DELTA_SCHEMAS: {
|
|
45
|
+
field: "reasoning" | "reasoning_content" | "reasoning_text";
|
|
46
|
+
schema: Type.TObject<{
|
|
47
|
+
[x: string]: Type.TString;
|
|
48
|
+
}>;
|
|
49
|
+
}[];
|
|
50
|
+
export declare const ReasoningDetailsDeltaSchema: Type.TObject<{
|
|
51
|
+
reasoning_details: Type.TArray<Type.TUnknown>;
|
|
52
|
+
}>;
|
|
53
|
+
export declare function parseCopilotReasoningOpaque(signature: string | undefined): string | undefined;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenAIReasoningDetailSchema2,
|
|
3
|
+
parseOpenAIReasoningDetails2,
|
|
4
|
+
parseLegacyEncryptedReasoningDetail2,
|
|
5
|
+
appendOpenAIReasoningDetail2,
|
|
6
|
+
OpenAICompletionsReasoningFieldSchema2,
|
|
7
|
+
CopilotReasoningOpaqueSchema2,
|
|
8
|
+
REASONING_DELTA_SCHEMAS2,
|
|
9
|
+
ReasoningDetailsDeltaSchema2,
|
|
10
|
+
parseCopilotReasoningOpaque2
|
|
11
|
+
} from "../../chunks/account-limits-cache-hj1h48sc.js";
|
|
12
|
+
export {
|
|
13
|
+
CopilotReasoningOpaqueSchema2 as CopilotReasoningOpaqueSchema,
|
|
14
|
+
OpenAICompletionsReasoningFieldSchema2 as OpenAICompletionsReasoningFieldSchema,
|
|
15
|
+
OpenAIReasoningDetailSchema2 as OpenAIReasoningDetailSchema,
|
|
16
|
+
REASONING_DELTA_SCHEMAS2 as REASONING_DELTA_SCHEMAS,
|
|
17
|
+
ReasoningDetailsDeltaSchema2 as ReasoningDetailsDeltaSchema,
|
|
18
|
+
appendOpenAIReasoningDetail2 as appendOpenAIReasoningDetail,
|
|
19
|
+
parseCopilotReasoningOpaque2 as parseCopilotReasoningOpaque,
|
|
20
|
+
parseLegacyEncryptedReasoningDetail2 as parseLegacyEncryptedReasoningDetail,
|
|
21
|
+
parseOpenAIReasoningDetails2 as parseOpenAIReasoningDetails
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SimpleStreamOptions, StreamFunction } from "../types.ts";
|
|
2
|
+
import { type OpenAICompletionsOptions } from "./openai-completions-params.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Streams a Chat Completions response.
|
|
5
|
+
*
|
|
6
|
+
* - The chunk id is the completion id: OpenAI documents it as unique per completion and every
|
|
7
|
+
* chunk of a stream carries the same one.
|
|
8
|
+
* - Usage comes from `chunk.usage`, or from `choice.usage` where providers such as Moonshot put it.
|
|
9
|
+
* - Reasoning text arrives in `reasoning_content` (llama.cpp), `reasoning`, or `reasoning_text`;
|
|
10
|
+
* only the first non-empty field counts, since some servers (chutes.ai) send the same text twice.
|
|
11
|
+
* - `reasoning_details` are replay metadata, not display deltas. OpenRouter streams them as
|
|
12
|
+
* deltas: consecutive text and summary entries merge, encrypted entries stay opaque and
|
|
13
|
+
* discrete. They stay in memory and serialize into the thinking signature once at the end.
|
|
14
|
+
* - Copilot's `reasoning_opaque` arrives with the first text delta or after all reasoning text and
|
|
15
|
+
* is never a display delta. It lives in the thinking signature, which later reasoning text
|
|
16
|
+
* never rewrites; one response carries one state, as in OpenCode's Copilot adapter.
|
|
17
|
+
* - Finished tool calls drop their scratch buffers, so replay carries only parsed arguments.
|
|
18
|
+
* - The SDK rejects a present-but-undefined timeout instead of using its default, so it is set
|
|
19
|
+
* only when given.
|
|
20
|
+
*/
|
|
21
|
+
export declare const stream: StreamFunction<"openai-completions", OpenAICompletionsOptions>;
|
|
22
|
+
export declare const streamSimple: StreamFunction<"openai-completions", SimpleStreamOptions>;
|