@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.
- package/LICENSE +21 -0
- package/README.md +170 -2
- package/THIRD-PARTY-NOTICES.md +866 -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-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-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-wtg64ez7.js +69 -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-yzyp0c2h.js +251 -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,484 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calculateCost2
|
|
3
|
+
} from "../../chunks/account-limits-cache-zgzptd0z.js";
|
|
4
|
+
import"../../chunks/account-limits-cache-b23sbrke.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveCacheRetention2
|
|
7
|
+
} from "../../chunks/account-limits-cache-d2a51dka.js";
|
|
8
|
+
import {
|
|
9
|
+
normalizeProviderError2,
|
|
10
|
+
formatProviderError2
|
|
11
|
+
} from "../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
12
|
+
import {
|
|
13
|
+
headersToRecord2,
|
|
14
|
+
mergeProviderHeaders2,
|
|
15
|
+
getClientApiKey2
|
|
16
|
+
} from "../../chunks/account-limits-cache-ag5b8dja.js";
|
|
17
|
+
import {
|
|
18
|
+
parseStreamingJson2,
|
|
19
|
+
parseToolCallArguments2
|
|
20
|
+
} from "../../chunks/account-limits-cache-fbkaq46e.js";
|
|
21
|
+
import {
|
|
22
|
+
getNyteUserAgent2
|
|
23
|
+
} from "../../chunks/account-limits-cache-gknnm1kv.js";
|
|
24
|
+
import"../../chunks/account-limits-cache-j2bt392s.js";
|
|
25
|
+
import {
|
|
26
|
+
retryProviderRequest2
|
|
27
|
+
} from "../../chunks/account-limits-cache-nbhht7xz.js";
|
|
28
|
+
import {
|
|
29
|
+
getDeclaredTools2,
|
|
30
|
+
resolveTranscript2
|
|
31
|
+
} from "../../chunks/account-limits-cache-6250ykn6.js";
|
|
32
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
33
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
34
|
+
import {
|
|
35
|
+
emptyCost2,
|
|
36
|
+
runAssistantStream2
|
|
37
|
+
} from "../../chunks/account-limits-cache-fsktnetm.js";
|
|
38
|
+
import {
|
|
39
|
+
appendGrammarToolInputJsonDelta2,
|
|
40
|
+
createGrammarToolInputProperties2
|
|
41
|
+
} from "../../chunks/account-limits-cache-h92bzz1j.js";
|
|
42
|
+
import {
|
|
43
|
+
buildCopilotDynamicHeaders2
|
|
44
|
+
} from "../../chunks/account-limits-cache-za42x8a3.js";
|
|
45
|
+
import"../../chunks/account-limits-cache-dejeygdt.js";
|
|
46
|
+
import {
|
|
47
|
+
buildBaseOptions2,
|
|
48
|
+
simpleReasoningEffort2
|
|
49
|
+
} from "../../chunks/account-limits-cache-k0pkzhbx.js";
|
|
50
|
+
import {
|
|
51
|
+
NullableTokenCount2
|
|
52
|
+
} from "../../chunks/account-limits-cache-736tdyme.js";
|
|
53
|
+
import {
|
|
54
|
+
OpenAIReasoningDetailSchema2,
|
|
55
|
+
appendOpenAIReasoningDetail2,
|
|
56
|
+
CopilotReasoningOpaqueSchema2,
|
|
57
|
+
REASONING_DELTA_SCHEMAS2,
|
|
58
|
+
ReasoningDetailsDeltaSchema2
|
|
59
|
+
} from "../../chunks/account-limits-cache-hj1h48sc.js";
|
|
60
|
+
import"../../chunks/account-limits-cache-0af5gqeg.js";
|
|
61
|
+
import"../../chunks/account-limits-cache-eqwweapz.js";
|
|
62
|
+
import"../../chunks/account-limits-cache-b4edaybk.js";
|
|
63
|
+
import"../../chunks/account-limits-cache-8qzk56vj.js";
|
|
64
|
+
import {
|
|
65
|
+
resolveCompat2
|
|
66
|
+
} from "../../chunks/account-limits-cache-fdwad56n.js";
|
|
67
|
+
import"../../chunks/account-limits-cache-csbxvam7.js";
|
|
68
|
+
import {
|
|
69
|
+
buildParams2
|
|
70
|
+
} from "../../chunks/account-limits-cache-zn01kscn.js";
|
|
71
|
+
|
|
72
|
+
// src/api/openai-completions.ts
|
|
73
|
+
import OpenAI from "openai";
|
|
74
|
+
import { Type } from "typebox";
|
|
75
|
+
import { Value } from "typebox/value";
|
|
76
|
+
var ChoiceUsageSchema = Type.Object({
|
|
77
|
+
usage: Type.Object({
|
|
78
|
+
prompt_tokens: NullableTokenCount2,
|
|
79
|
+
completion_tokens: NullableTokenCount2,
|
|
80
|
+
cached_tokens: NullableTokenCount2,
|
|
81
|
+
prompt_cache_hit_tokens: NullableTokenCount2,
|
|
82
|
+
prompt_tokens_details: Type.Optional(Type.Union([
|
|
83
|
+
Type.Object({ cached_tokens: NullableTokenCount2, cache_write_tokens: NullableTokenCount2 }),
|
|
84
|
+
Type.Null()
|
|
85
|
+
])),
|
|
86
|
+
completion_tokens_details: Type.Optional(Type.Union([Type.Object({ reasoning_tokens: NullableTokenCount2 }), Type.Null()]))
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
var OpenRouterErrorMetadataSchema = Type.Object({
|
|
90
|
+
error: Type.Object({ metadata: Type.Object({ raw: Type.Unknown() }) })
|
|
91
|
+
});
|
|
92
|
+
var stream = (model, context, options) => {
|
|
93
|
+
const normalizedContext = resolveTranscript2(context, resolveCompat2(model).supportsMidConvoSystemMessages);
|
|
94
|
+
return runAssistantStream2(model, options?.signal, "OpenAI Completions", async (output, stream) => {
|
|
95
|
+
const blocks = [];
|
|
96
|
+
output.content = blocks;
|
|
97
|
+
let streamedReasoningDetails;
|
|
98
|
+
const applyStreamedReasoningDetails = (block) => {
|
|
99
|
+
if (streamedReasoningDetails === undefined)
|
|
100
|
+
return;
|
|
101
|
+
block.thinkingSignature = JSON.stringify(streamedReasoningDetails);
|
|
102
|
+
};
|
|
103
|
+
const apiKey = getClientApiKey2(model.provider, options?.apiKey, options?.headers);
|
|
104
|
+
const compat = resolveCompat2(model);
|
|
105
|
+
const grammarToolInputProperties = createGrammarToolInputProperties2(getDeclaredTools2(normalizedContext.messages), compat.supportsOpenAIGrammarTools);
|
|
106
|
+
const cacheRetention = resolveCacheRetention2(options?.cacheRetention, options?.env);
|
|
107
|
+
const client = createClient({
|
|
108
|
+
model,
|
|
109
|
+
context: normalizedContext,
|
|
110
|
+
apiKey,
|
|
111
|
+
options,
|
|
112
|
+
cacheRetention,
|
|
113
|
+
compat
|
|
114
|
+
});
|
|
115
|
+
const params = buildParams2(model, normalizedContext, options, compat, cacheRetention, grammarToolInputProperties);
|
|
116
|
+
await options?.onPayload?.(params, model);
|
|
117
|
+
const requestOptions = {
|
|
118
|
+
signal: options?.signal,
|
|
119
|
+
maxRetries: 0
|
|
120
|
+
};
|
|
121
|
+
if (options?.timeoutMs !== undefined)
|
|
122
|
+
requestOptions.timeout = options.timeoutMs;
|
|
123
|
+
const result = await retryProviderRequest2(() => client.post("/chat/completions", {
|
|
124
|
+
body: params,
|
|
125
|
+
...requestOptions,
|
|
126
|
+
stream: true,
|
|
127
|
+
__security: { bearerAuth: true }
|
|
128
|
+
}).withResponse(), {
|
|
129
|
+
maxRetries: options?.maxRetries,
|
|
130
|
+
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
131
|
+
signal: options?.signal
|
|
132
|
+
});
|
|
133
|
+
await options?.onResponse?.({ status: result.response.status, headers: headersToRecord2(result.response.headers) }, model);
|
|
134
|
+
stream.push({ type: "start", partial: output });
|
|
135
|
+
let textBlock = null;
|
|
136
|
+
let thinkingBlock = null;
|
|
137
|
+
let copilotReasoningOpaque;
|
|
138
|
+
let hasFinishReason = false;
|
|
139
|
+
const toolCallBlocksByIndex = new Map;
|
|
140
|
+
const toolCallBlocksById = new Map;
|
|
141
|
+
const getContentIndex = (block) => blocks.findIndex((candidate) => candidate === block);
|
|
142
|
+
const appendCustomToolCallInput = (block, nextInput, close) => {
|
|
143
|
+
const customInput = block.customInput;
|
|
144
|
+
if (!customInput)
|
|
145
|
+
return;
|
|
146
|
+
const delta = appendGrammarToolInputJsonDelta2(customInput.jsonBuffer, customInput.property, nextInput, close);
|
|
147
|
+
customInput.input = nextInput;
|
|
148
|
+
block.arguments = { [customInput.property]: nextInput };
|
|
149
|
+
return delta;
|
|
150
|
+
};
|
|
151
|
+
const finishBlock = (block) => {
|
|
152
|
+
const contentIndex = getContentIndex(block);
|
|
153
|
+
if (contentIndex === -1) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (block.type === "text") {
|
|
157
|
+
stream.push({
|
|
158
|
+
type: "text_end",
|
|
159
|
+
contentIndex,
|
|
160
|
+
content: block.text,
|
|
161
|
+
partial: output
|
|
162
|
+
});
|
|
163
|
+
} else if (block.type === "thinking") {
|
|
164
|
+
stream.push({
|
|
165
|
+
type: "thinking_end",
|
|
166
|
+
contentIndex,
|
|
167
|
+
content: block.thinking,
|
|
168
|
+
partial: output
|
|
169
|
+
});
|
|
170
|
+
} else if (block.type === "toolCall") {
|
|
171
|
+
if (block.customInput) {
|
|
172
|
+
const delta = appendCustomToolCallInput(block, block.customInput.input, true);
|
|
173
|
+
if (delta !== undefined) {
|
|
174
|
+
stream.push({
|
|
175
|
+
type: "toolcall_delta",
|
|
176
|
+
contentIndex,
|
|
177
|
+
delta,
|
|
178
|
+
partial: output
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
Object.assign(block, parseToolCallArguments2(block.partialArgs));
|
|
183
|
+
}
|
|
184
|
+
delete block.partialArgs;
|
|
185
|
+
delete block.customInput;
|
|
186
|
+
delete block.streamIndex;
|
|
187
|
+
stream.push({
|
|
188
|
+
type: "toolcall_end",
|
|
189
|
+
contentIndex,
|
|
190
|
+
toolCall: block,
|
|
191
|
+
partial: output
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const ensureTextBlock = () => {
|
|
196
|
+
if (!textBlock) {
|
|
197
|
+
textBlock = { type: "text", text: "" };
|
|
198
|
+
blocks.push(textBlock);
|
|
199
|
+
stream.push({
|
|
200
|
+
type: "text_start",
|
|
201
|
+
contentIndex: getContentIndex(textBlock),
|
|
202
|
+
partial: output
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return textBlock;
|
|
206
|
+
};
|
|
207
|
+
const ensureThinkingBlock = (thinkingSignature) => {
|
|
208
|
+
if (!thinkingBlock) {
|
|
209
|
+
thinkingBlock = {
|
|
210
|
+
type: "thinking",
|
|
211
|
+
thinking: "",
|
|
212
|
+
thinkingSignature
|
|
213
|
+
};
|
|
214
|
+
blocks.push(thinkingBlock);
|
|
215
|
+
stream.push({
|
|
216
|
+
type: "thinking_start",
|
|
217
|
+
contentIndex: getContentIndex(thinkingBlock),
|
|
218
|
+
partial: output
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
return thinkingBlock;
|
|
222
|
+
};
|
|
223
|
+
const ensureToolCallBlock = (toolCall) => {
|
|
224
|
+
const streamIndex = toolCall.index;
|
|
225
|
+
const name = toolCall.function?.name ?? toolCall.custom?.name ?? "";
|
|
226
|
+
let block = streamIndex !== undefined ? toolCallBlocksByIndex.get(streamIndex) : undefined;
|
|
227
|
+
if (!block && toolCall.id) {
|
|
228
|
+
block = toolCallBlocksById.get(toolCall.id);
|
|
229
|
+
}
|
|
230
|
+
if (!block) {
|
|
231
|
+
const customInputProperty = toolCall.custom && !toolCall.function ? grammarToolInputProperties.get(name) ?? "input" : undefined;
|
|
232
|
+
const hasCustomInput = customInputProperty !== undefined;
|
|
233
|
+
block = {
|
|
234
|
+
type: "toolCall",
|
|
235
|
+
id: toolCall.id || "",
|
|
236
|
+
name,
|
|
237
|
+
arguments: hasCustomInput ? { [customInputProperty]: "" } : {},
|
|
238
|
+
partialArgs: hasCustomInput ? undefined : "",
|
|
239
|
+
customInput: hasCustomInput ? {
|
|
240
|
+
property: customInputProperty,
|
|
241
|
+
input: "",
|
|
242
|
+
jsonBuffer: { input: "", started: false, closed: false }
|
|
243
|
+
} : undefined,
|
|
244
|
+
streamIndex
|
|
245
|
+
};
|
|
246
|
+
if (streamIndex !== undefined) {
|
|
247
|
+
toolCallBlocksByIndex.set(streamIndex, block);
|
|
248
|
+
}
|
|
249
|
+
if (toolCall.id) {
|
|
250
|
+
toolCallBlocksById.set(toolCall.id, block);
|
|
251
|
+
}
|
|
252
|
+
blocks.push(block);
|
|
253
|
+
stream.push({
|
|
254
|
+
type: "toolcall_start",
|
|
255
|
+
contentIndex: getContentIndex(block),
|
|
256
|
+
partial: output
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
if (streamIndex !== undefined && block.streamIndex === undefined) {
|
|
260
|
+
block.streamIndex = streamIndex;
|
|
261
|
+
toolCallBlocksByIndex.set(streamIndex, block);
|
|
262
|
+
}
|
|
263
|
+
if (toolCall.id) {
|
|
264
|
+
toolCallBlocksById.set(toolCall.id, block);
|
|
265
|
+
}
|
|
266
|
+
if (!block.name && name) {
|
|
267
|
+
block.name = name;
|
|
268
|
+
}
|
|
269
|
+
if (toolCall.custom && !toolCall.function && !block.customInput) {
|
|
270
|
+
const customInputProperty = grammarToolInputProperties.get(block.name) ?? "input";
|
|
271
|
+
block.arguments = { [customInputProperty]: "" };
|
|
272
|
+
block.customInput = {
|
|
273
|
+
property: customInputProperty,
|
|
274
|
+
input: "",
|
|
275
|
+
jsonBuffer: { input: "", started: false, closed: false }
|
|
276
|
+
};
|
|
277
|
+
delete block.partialArgs;
|
|
278
|
+
}
|
|
279
|
+
return block;
|
|
280
|
+
};
|
|
281
|
+
try {
|
|
282
|
+
for await (const chunk of result.data) {
|
|
283
|
+
if (!chunk)
|
|
284
|
+
continue;
|
|
285
|
+
output.responseId ||= chunk.id;
|
|
286
|
+
if (chunk.model && chunk.model !== model.id) {
|
|
287
|
+
output.responseModel ||= chunk.model;
|
|
288
|
+
}
|
|
289
|
+
if (chunk.usage) {
|
|
290
|
+
output.usage = parseChunkUsage(chunk.usage, model);
|
|
291
|
+
}
|
|
292
|
+
const choice = Array.isArray(chunk.choices) ? chunk.choices[0] : undefined;
|
|
293
|
+
if (!choice)
|
|
294
|
+
continue;
|
|
295
|
+
if (!chunk.usage && Value.Check(ChoiceUsageSchema, choice)) {
|
|
296
|
+
output.usage = parseChunkUsage(choice.usage, model);
|
|
297
|
+
}
|
|
298
|
+
if (choice.finish_reason) {
|
|
299
|
+
output.rawStopReason = choice.finish_reason;
|
|
300
|
+
const finishReasonResult = mapStopReason(choice.finish_reason);
|
|
301
|
+
output.stopReason = finishReasonResult.stopReason;
|
|
302
|
+
if (finishReasonResult.errorMessage) {
|
|
303
|
+
output.errorMessage = finishReasonResult.errorMessage;
|
|
304
|
+
}
|
|
305
|
+
hasFinishReason = true;
|
|
306
|
+
}
|
|
307
|
+
if (choice.delta) {
|
|
308
|
+
if (choice.delta.content !== null && choice.delta.content !== undefined && choice.delta.content.length > 0) {
|
|
309
|
+
const block = ensureTextBlock();
|
|
310
|
+
block.text += choice.delta.content;
|
|
311
|
+
stream.push({
|
|
312
|
+
type: "text_delta",
|
|
313
|
+
contentIndex: getContentIndex(block),
|
|
314
|
+
delta: choice.delta.content,
|
|
315
|
+
partial: output
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
const deltaFields = choice.delta;
|
|
319
|
+
for (const { field, schema } of REASONING_DELTA_SCHEMAS2) {
|
|
320
|
+
if (!Value.Check(schema, deltaFields))
|
|
321
|
+
continue;
|
|
322
|
+
const delta = deltaFields[field];
|
|
323
|
+
const thinkingSignature = model.provider === "opencode-go" && field === "reasoning" ? "reasoning_content" : field;
|
|
324
|
+
const block = ensureThinkingBlock(thinkingSignature);
|
|
325
|
+
block.thinking += delta;
|
|
326
|
+
stream.push({
|
|
327
|
+
type: "thinking_delta",
|
|
328
|
+
contentIndex: getContentIndex(block),
|
|
329
|
+
delta,
|
|
330
|
+
partial: output
|
|
331
|
+
});
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
if (model.provider === "github-copilot" && Value.Check(CopilotReasoningOpaqueSchema2, deltaFields)) {
|
|
335
|
+
const reasoningOpaque = deltaFields.reasoning_opaque;
|
|
336
|
+
if (copilotReasoningOpaque !== undefined && copilotReasoningOpaque !== reasoningOpaque) {
|
|
337
|
+
throw new Error("GitHub Copilot sent multiple reasoning_opaque values in one response");
|
|
338
|
+
}
|
|
339
|
+
copilotReasoningOpaque = reasoningOpaque;
|
|
340
|
+
const block = ensureThinkingBlock("");
|
|
341
|
+
block.thinkingSignature = JSON.stringify({ reasoning_opaque: reasoningOpaque });
|
|
342
|
+
}
|
|
343
|
+
if (choice?.delta?.tool_calls) {
|
|
344
|
+
const toolCalls = choice.delta.tool_calls;
|
|
345
|
+
for (const toolCall of toolCalls) {
|
|
346
|
+
const block = ensureToolCallBlock(toolCall);
|
|
347
|
+
if (!block.id && toolCall.id) {
|
|
348
|
+
block.id = toolCall.id;
|
|
349
|
+
toolCallBlocksById.set(toolCall.id, block);
|
|
350
|
+
}
|
|
351
|
+
const name = toolCall.function?.name ?? toolCall.custom?.name;
|
|
352
|
+
if (!block.name && name) {
|
|
353
|
+
block.name = name;
|
|
354
|
+
}
|
|
355
|
+
let delta = "";
|
|
356
|
+
if (toolCall.function?.arguments) {
|
|
357
|
+
delta = toolCall.function.arguments;
|
|
358
|
+
block.partialArgs = (block.partialArgs ?? "") + toolCall.function.arguments;
|
|
359
|
+
block.arguments = parseStreamingJson2(block.partialArgs);
|
|
360
|
+
} else if (toolCall.custom?.input) {
|
|
361
|
+
const nextInput = (block.customInput?.input ?? "") + toolCall.custom.input;
|
|
362
|
+
delta = appendCustomToolCallInput(block, nextInput, false) ?? "";
|
|
363
|
+
}
|
|
364
|
+
stream.push({
|
|
365
|
+
type: "toolcall_delta",
|
|
366
|
+
contentIndex: getContentIndex(block),
|
|
367
|
+
delta,
|
|
368
|
+
partial: output
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (Value.Check(ReasoningDetailsDeltaSchema2, deltaFields)) {
|
|
373
|
+
for (const detail of deltaFields.reasoning_details) {
|
|
374
|
+
if (!Value.Check(OpenAIReasoningDetailSchema2, detail))
|
|
375
|
+
continue;
|
|
376
|
+
ensureThinkingBlock("");
|
|
377
|
+
streamedReasoningDetails ??= [];
|
|
378
|
+
appendOpenAIReasoningDetail2(streamedReasoningDetails, detail);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
} finally {
|
|
384
|
+
for (const block of blocks) {
|
|
385
|
+
if (block.type === "thinking")
|
|
386
|
+
applyStreamedReasoningDetails(block);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
for (const block of blocks) {
|
|
390
|
+
finishBlock(block);
|
|
391
|
+
}
|
|
392
|
+
if (!hasFinishReason && !compat.supportsFinishReason) {
|
|
393
|
+
output.stopReason = output.content.some((block) => block.type === "toolCall") ? "toolUse" : "stop";
|
|
394
|
+
}
|
|
395
|
+
if (compat.supportsFinishReason && !hasFinishReason) {
|
|
396
|
+
throw new Error("Stream ended without finish_reason");
|
|
397
|
+
}
|
|
398
|
+
}, formatCompletionsError);
|
|
399
|
+
};
|
|
400
|
+
function formatCompletionsError(error) {
|
|
401
|
+
const message = formatProviderError2(normalizeProviderError2(error));
|
|
402
|
+
const rawMetadata = Value.Check(OpenRouterErrorMetadataSchema, error) ? error.error.metadata.raw : undefined;
|
|
403
|
+
return rawMetadata && !message.includes(String(rawMetadata)) ? `${message}
|
|
404
|
+
${rawMetadata}` : message;
|
|
405
|
+
}
|
|
406
|
+
var streamSimple = (model, context, options) => {
|
|
407
|
+
getClientApiKey2(model.provider, options?.apiKey, options?.headers);
|
|
408
|
+
return stream(model, context, {
|
|
409
|
+
...buildBaseOptions2(model, context, options),
|
|
410
|
+
reasoningEffort: simpleReasoningEffort2(model, options?.reasoning),
|
|
411
|
+
thinkingBudgets: options?.thinkingBudgets
|
|
412
|
+
});
|
|
413
|
+
};
|
|
414
|
+
function createClient(input) {
|
|
415
|
+
const copilotHeaders = input.model.provider === "github-copilot" ? buildCopilotDynamicHeaders2({
|
|
416
|
+
messages: input.context.messages,
|
|
417
|
+
sessionId: input.options?.sessionId
|
|
418
|
+
}) : undefined;
|
|
419
|
+
const cacheSessionId = input.cacheRetention === "none" ? undefined : input.options?.sessionId;
|
|
420
|
+
const affinityHeaders = {};
|
|
421
|
+
if (cacheSessionId && input.compat.sendSessionAffinityHeaders) {
|
|
422
|
+
if (input.compat.sessionAffinityFormat === "openrouter") {
|
|
423
|
+
affinityHeaders["x-session-id"] = cacheSessionId;
|
|
424
|
+
} else {
|
|
425
|
+
if (input.compat.sessionAffinityFormat === "openai") {
|
|
426
|
+
affinityHeaders.session_id = cacheSessionId;
|
|
427
|
+
}
|
|
428
|
+
affinityHeaders["x-client-request-id"] = cacheSessionId;
|
|
429
|
+
affinityHeaders["x-session-affinity"] = cacheSessionId;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return new OpenAI({
|
|
433
|
+
apiKey: input.apiKey,
|
|
434
|
+
baseURL: input.model.baseUrl,
|
|
435
|
+
dangerouslyAllowBrowser: true,
|
|
436
|
+
fetch: input.options?.fetch,
|
|
437
|
+
defaultHeaders: mergeProviderHeaders2({ "User-Agent": getNyteUserAgent2() }, input.model.headers, copilotHeaders, affinityHeaders, input.options?.headers)
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
function parseChunkUsage(rawUsage, model) {
|
|
441
|
+
const promptTokens = rawUsage.prompt_tokens || 0;
|
|
442
|
+
const cacheReadTokens = rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.prompt_cache_hit_tokens ?? rawUsage.cached_tokens ?? 0;
|
|
443
|
+
const cacheWriteTokens = rawUsage.prompt_tokens_details?.cache_write_tokens || 0;
|
|
444
|
+
const input = Math.max(0, promptTokens - cacheReadTokens - cacheWriteTokens);
|
|
445
|
+
const outputTokens = rawUsage.completion_tokens || 0;
|
|
446
|
+
const usage = {
|
|
447
|
+
input,
|
|
448
|
+
output: outputTokens,
|
|
449
|
+
cacheRead: cacheReadTokens,
|
|
450
|
+
cacheWrite: cacheWriteTokens,
|
|
451
|
+
reasoning: rawUsage.completion_tokens_details?.reasoning_tokens || 0,
|
|
452
|
+
totalTokens: input + outputTokens + cacheReadTokens + cacheWriteTokens,
|
|
453
|
+
cost: emptyCost2()
|
|
454
|
+
};
|
|
455
|
+
calculateCost2(model, usage);
|
|
456
|
+
return usage;
|
|
457
|
+
}
|
|
458
|
+
function mapStopReason(reason) {
|
|
459
|
+
if (reason === null)
|
|
460
|
+
return { stopReason: "stop" };
|
|
461
|
+
switch (reason) {
|
|
462
|
+
case "stop":
|
|
463
|
+
case "end":
|
|
464
|
+
return { stopReason: "stop" };
|
|
465
|
+
case "length":
|
|
466
|
+
return { stopReason: "length" };
|
|
467
|
+
case "function_call":
|
|
468
|
+
case "tool_calls":
|
|
469
|
+
return { stopReason: "toolUse" };
|
|
470
|
+
case "content_filter":
|
|
471
|
+
return { stopReason: "error", errorMessage: "Provider finish_reason: content_filter" };
|
|
472
|
+
case "network_error":
|
|
473
|
+
return { stopReason: "error", errorMessage: "Provider finish_reason: network_error" };
|
|
474
|
+
default:
|
|
475
|
+
return {
|
|
476
|
+
stopReason: "error",
|
|
477
|
+
errorMessage: `Provider finish_reason: ${reason}`
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
export {
|
|
482
|
+
stream,
|
|
483
|
+
streamSimple
|
|
484
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openAICompletionsApi2
|
|
3
|
+
} from "../../chunks/account-limits-cache-eyx1jcxc.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
|
+
openAICompletionsApi2 as openAICompletionsApi
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clampOpenAIPromptCacheKey(key: string | undefined): string | undefined;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion of the neutral transcript and tools into Responses API input,
|
|
3
|
+
* shared by the OpenAI Responses and Codex adapters.
|
|
4
|
+
*/
|
|
5
|
+
import type { CustomTool, FunctionTool, ResponseInputItem, ResponseToolSearchOutputItemParam } from "openai/resources/responses/responses.js";
|
|
6
|
+
import { type Static, Type } from "typebox";
|
|
7
|
+
import type { Model, TextSignatureV1, Tool, TranscriptContext } from "../types.ts";
|
|
8
|
+
/** A function tool as sent; `strict` is omitted for providers that reject or ignore the field. */
|
|
9
|
+
type ResponsesFunctionTool = Omit<FunctionTool, "strict"> & Partial<Pick<FunctionTool, "strict">>;
|
|
10
|
+
export type ResponsesTool = CustomTool | ResponsesFunctionTool;
|
|
11
|
+
/** Loads deferred tools in place, for providers that support `additional_tools`. */
|
|
12
|
+
interface ResponsesAdditionalToolsItem {
|
|
13
|
+
type: "additional_tools";
|
|
14
|
+
role: "developer";
|
|
15
|
+
tools: ResponsesTool[];
|
|
16
|
+
}
|
|
17
|
+
/** A client-executed tool search result, which loads deferred tools for `tool-search` providers. */
|
|
18
|
+
interface ResponsesToolSearchOutputItem extends Omit<ResponseToolSearchOutputItemParam, "tools"> {
|
|
19
|
+
tools: ResponsesTool[];
|
|
20
|
+
}
|
|
21
|
+
/** An item the matching provider produced, replayed verbatim. */
|
|
22
|
+
declare const ReplayedItemSchema: Type.TObject<{
|
|
23
|
+
type: Type.TString;
|
|
24
|
+
}>;
|
|
25
|
+
type ReplayedResponsesItem = Static<typeof ReplayedItemSchema>;
|
|
26
|
+
type ResponsesInputItem = ResponseInputItem | ResponsesAdditionalToolsItem | ResponsesToolSearchOutputItem | ReplayedResponsesItem;
|
|
27
|
+
export type ResponsesInput = ResponsesInputItem[];
|
|
28
|
+
export declare function encodeTextSignatureV1(id: string, phase?: TextSignatureV1["phase"]): string;
|
|
29
|
+
interface ConvertResponsesMessagesOptions {
|
|
30
|
+
includeSystemPrompt?: boolean;
|
|
31
|
+
grammarToolInputProperties?: ReadonlyMap<string, string>;
|
|
32
|
+
/** Whether later system messages are sent in place; otherwise they are folded into the leading prompt. */
|
|
33
|
+
supportsMidConvoSystemMessages?: boolean;
|
|
34
|
+
/** Request-list tools that tool results load via `addedToolNames`. */
|
|
35
|
+
deferredTools?: ReadonlyMap<string, Tool>;
|
|
36
|
+
/** How late tools reach the model: system-message anchors and `addedToolNames` loads share it. */
|
|
37
|
+
deferredToolsMode?: "additional-tools" | "tool-search";
|
|
38
|
+
toolOptions?: ConvertResponsesToolsOptions;
|
|
39
|
+
}
|
|
40
|
+
interface ConvertResponsesToolsOptions {
|
|
41
|
+
strict?: boolean | null;
|
|
42
|
+
supportsStrictMode?: boolean;
|
|
43
|
+
supportsOpenAIGrammarTools?: boolean;
|
|
44
|
+
deferLoading?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The transcript as Responses input items.
|
|
48
|
+
*
|
|
49
|
+
* - Tool call item ids must start with `fc_`, and message ids are at most 64 characters.
|
|
50
|
+
* - Tool calls from a different model drop their item id: OpenAI tracks which item ids were
|
|
51
|
+
* paired with `rs_*` reasoning items, and omitting the id avoids that pairing validation, as
|
|
52
|
+
* for cross-provider calls. Ids that do not match the replayed item type are dropped too:
|
|
53
|
+
* `function_call` ids must be `fc_*` and `custom_tool_call` ids `ctc_*`. Foreign ids normalize
|
|
54
|
+
* to `fc_*`, and a call switches type when grammar tool support differs.
|
|
55
|
+
*/
|
|
56
|
+
export declare function convertResponsesMessages(model: Model<"openai-responses" | "azure-openai-responses" | "openai-codex-responses">, context: TranscriptContext, allowedToolCallProviders: ReadonlySet<string>, options?: ConvertResponsesMessagesOptions): ResponsesInput;
|
|
57
|
+
export declare function convertResponsesTools(tools: readonly Tool[], options?: ConvertResponsesToolsOptions): ResponsesTool[];
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
encodeTextSignatureV12,
|
|
3
|
+
convertResponsesMessages2,
|
|
4
|
+
convertResponsesTools2
|
|
5
|
+
} from "../../chunks/account-limits-cache-n3yk6g5c.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-8qzk56vj.js";
|
|
7
|
+
import"../../chunks/account-limits-cache-h92bzz1j.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-eqwweapz.js";
|
|
9
|
+
import"../../chunks/account-limits-cache-0af5gqeg.js";
|
|
10
|
+
import"../../chunks/account-limits-cache-b4edaybk.js";
|
|
11
|
+
import"../../chunks/account-limits-cache-6250ykn6.js";
|
|
12
|
+
export {
|
|
13
|
+
convertResponsesMessages2 as convertResponsesMessages,
|
|
14
|
+
convertResponsesTools2 as convertResponsesTools,
|
|
15
|
+
encodeTextSignatureV12 as encodeTextSignatureV1
|
|
16
|
+
};
|