@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,14 @@
|
|
|
1
|
+
import type { Provider } from "../models-types.ts";
|
|
2
|
+
export type OpenCodeApi = "anthropic-messages" | "google-generative-ai" | "openai-completions" | "openai-responses";
|
|
3
|
+
/**
|
|
4
|
+
* OpenCode models route to several upstream APIs whose long-retention windows differ
|
|
5
|
+
* (1h on Anthropic, 24h on OpenAI), and some catalog entries do not support long
|
|
6
|
+
* retention at all, so the providers publish only the floor every route guarantees.
|
|
7
|
+
*/
|
|
8
|
+
export declare const OPENCODE_PROMPT_CACHE: {
|
|
9
|
+
minimumRetentionMs: {
|
|
10
|
+
short: number;
|
|
11
|
+
long: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function opencodeProvider(): Provider<OpenCodeApi>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OPENCODE_PROMPT_CACHE2,
|
|
3
|
+
opencodeProvider2
|
|
4
|
+
} from "../../chunks/account-limits-cache-nbkyhs6v.js";
|
|
5
|
+
import"../../chunks/account-limits-cache-x9fvb3s5.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-fht68jp2.js";
|
|
7
|
+
import"../../chunks/account-limits-cache-q1ebtvet.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-eyx1jcxc.js";
|
|
9
|
+
import"../../chunks/account-limits-cache-zqdb4yh4.js";
|
|
10
|
+
import"../../chunks/account-limits-cache-6x05n06z.js";
|
|
11
|
+
import"../../chunks/account-limits-cache-ykbqsvv6.js";
|
|
12
|
+
import"../../chunks/account-limits-cache-90c9c2eb.js";
|
|
13
|
+
import"../../chunks/account-limits-cache-fsktnetm.js";
|
|
14
|
+
import"../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
15
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
16
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
17
|
+
import"../../chunks/account-limits-cache-7z9s8j16.js";
|
|
18
|
+
import"../../chunks/account-limits-cache-9wqk28n5.js";
|
|
19
|
+
import"../../chunks/account-limits-cache-j2bt392s.js";
|
|
20
|
+
export {
|
|
21
|
+
OPENCODE_PROMPT_CACHE2 as OPENCODE_PROMPT_CACHE,
|
|
22
|
+
opencodeProvider2 as opencodeProvider
|
|
23
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openrouterProvider2
|
|
3
|
+
} from "../../chunks/account-limits-cache-pfa86y8e.js";
|
|
4
|
+
import"../../chunks/account-limits-cache-ydq8p8qp.js";
|
|
5
|
+
import"../../chunks/account-limits-cache-eyx1jcxc.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-6x05n06z.js";
|
|
7
|
+
import"../../chunks/account-limits-cache-ag5b8dja.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-ykbqsvv6.js";
|
|
9
|
+
import"../../chunks/account-limits-cache-90c9c2eb.js";
|
|
10
|
+
import"../../chunks/account-limits-cache-fsktnetm.js";
|
|
11
|
+
import"../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
12
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
13
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
14
|
+
import"../../chunks/account-limits-cache-7z9s8j16.js";
|
|
15
|
+
import"../../chunks/account-limits-cache-9wqk28n5.js";
|
|
16
|
+
import"../../chunks/account-limits-cache-j2bt392s.js";
|
|
17
|
+
export {
|
|
18
|
+
openrouterProvider2 as openrouterProvider
|
|
19
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Provider } from "../models-types.ts";
|
|
2
|
+
/** Vercel AI Gateway. Nyte-only: OIDC tokens authenticate only as a bearer, which API keys also accept, so every key is sent as `Authorization: Bearer`. */
|
|
3
|
+
export declare function vercelAiGatewayProvider(): Provider<"anthropic-messages">;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
vercelAiGatewayProvider2
|
|
3
|
+
} from "../../chunks/account-limits-cache-q63mc41j.js";
|
|
4
|
+
import"../../chunks/account-limits-cache-ydq8p8qp.js";
|
|
5
|
+
import"../../chunks/account-limits-cache-zqdb4yh4.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-6x05n06z.js";
|
|
7
|
+
import"../../chunks/account-limits-cache-ag5b8dja.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-ykbqsvv6.js";
|
|
9
|
+
import"../../chunks/account-limits-cache-90c9c2eb.js";
|
|
10
|
+
import"../../chunks/account-limits-cache-fsktnetm.js";
|
|
11
|
+
import"../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
12
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
13
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
14
|
+
import"../../chunks/account-limits-cache-7z9s8j16.js";
|
|
15
|
+
import"../../chunks/account-limits-cache-9wqk28n5.js";
|
|
16
|
+
import"../../chunks/account-limits-cache-j2bt392s.js";
|
|
17
|
+
export {
|
|
18
|
+
vercelAiGatewayProvider2 as vercelAiGatewayProvider
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type SessionResourceCleanup = (sessionId?: string) => void;
|
|
2
|
+
export declare function registerSessionResourceCleanup(cleanup: SessionResourceCleanup): () => void;
|
|
3
|
+
export declare function cleanupSessionResources(sessionId?: string): void;
|
|
4
|
+
/**
|
|
5
|
+
* Keep provider caches for a durable session alive while at least one harness
|
|
6
|
+
* owns them. Runtime/model replacement briefly overlaps harnesses, so cleanup
|
|
7
|
+
* belongs to the last release rather than to each harness independently.
|
|
8
|
+
*/
|
|
9
|
+
export declare function acquireSessionResources(sessionId: string): () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerSessionResourceCleanup2,
|
|
3
|
+
cleanupSessionResources2,
|
|
4
|
+
acquireSessionResources2
|
|
5
|
+
} from "../chunks/account-limits-cache-gqsrbky9.js";
|
|
6
|
+
export {
|
|
7
|
+
acquireSessionResources2 as acquireSessionResources,
|
|
8
|
+
cleanupSessionResources2 as cleanupSessionResources,
|
|
9
|
+
registerSessionResourceCleanup2 as registerSessionResourceCleanup
|
|
10
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request option and adapter contract types for @nyte-ai/ai. The neutral message,
|
|
3
|
+
* model, and tool types live in @nyte-ai/schema and are re-exported here so
|
|
4
|
+
* callers can import everything from one place; this
|
|
5
|
+
* file adds only what a provider request needs on top of them: transport and
|
|
6
|
+
* auth options, and the stream function contract.
|
|
7
|
+
*/
|
|
8
|
+
import type { Api, CacheRetention, DeferredHandle, Model, ThinkingLevel, TranscriptContext } from "@nyte-ai/schema/model";
|
|
9
|
+
import type { AssistantMessageEventStream } from "./utils/event-stream.ts";
|
|
10
|
+
export type { AssistantMessageEventStream } from "./utils/event-stream.ts";
|
|
11
|
+
export type { KnownProvider, OpenAICompletionsCompat, BedrockCompat, CacheRetention, ModelPromptCache, OpenRouterRouting, VercelGatewayRouting, ChatTemplateKwargValue, ThinkingTokenBudgetField, AnthropicAllowedFallbackModel, AnthropicMessagesCompat, Api, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, ConstrainedSamplingConfig, Context, ProviderCheckpointMaterial, DeferredHandle, DiagnosticErrorInfo, GrammarFormat, GrammarVariants, ImageContent, JsonValue, KnownApi, Message, Model, ModelCost, ModelCostRates, ModelCostTier, ModelMode, ModelThinkingLevel, OpenAIResponsesCompat, ProviderId, SessionAffinityFormat, StopReason, SystemMessage, TextContent, TextSignatureV1, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolReference, ToolResultMessage, TranscriptContext, Usage, UserMessage, } from "@nyte-ai/schema/model";
|
|
12
|
+
export type ToolChoice = "auto" | "none";
|
|
13
|
+
/** Token budgets for each thinking level (token-based providers only) */
|
|
14
|
+
export interface ThinkingBudgets {
|
|
15
|
+
minimal?: number;
|
|
16
|
+
low?: number;
|
|
17
|
+
medium?: number;
|
|
18
|
+
high?: number;
|
|
19
|
+
}
|
|
20
|
+
export type CachedRetention = Exclude<CacheRetention, "none">;
|
|
21
|
+
/** Provider-owned lower bounds for prompt-cache lifetime after a confirmed read or write. */
|
|
22
|
+
export interface PromptCachePolicy {
|
|
23
|
+
readonly minimumRetentionMs: Readonly<Record<CachedRetention, number>>;
|
|
24
|
+
}
|
|
25
|
+
export type Transport = "sse" | "websocket" | "websocket-cached" | "auto";
|
|
26
|
+
/** Provider-scoped environment overrides. Values take precedence over process.env. */
|
|
27
|
+
export type ProviderEnv = Record<string, string>;
|
|
28
|
+
export type ProviderHeaders = Record<string, string | null>;
|
|
29
|
+
export type FetchFunction = typeof globalThis.fetch;
|
|
30
|
+
export interface ProviderResponse {
|
|
31
|
+
status: number;
|
|
32
|
+
headers: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
/** One provider subscription window, normalized as percent consumed. */
|
|
35
|
+
export interface AccountLimitWindow {
|
|
36
|
+
/** Stable provider-owned bucket id, for example `five_hour` or `seven_day`. */
|
|
37
|
+
id: string;
|
|
38
|
+
/** Display name, for example `5-hour`, `Weekly`, or `Opus weekly`. */
|
|
39
|
+
label: string;
|
|
40
|
+
usedPercent: number;
|
|
41
|
+
/** Unix timestamp in milliseconds. */
|
|
42
|
+
resetsAt?: number;
|
|
43
|
+
windowMinutes?: number;
|
|
44
|
+
}
|
|
45
|
+
/** Ephemeral account-scoped subscription state. Never conversation usage. */
|
|
46
|
+
export interface AccountLimits {
|
|
47
|
+
providerId: string;
|
|
48
|
+
plan?: string;
|
|
49
|
+
windows: readonly AccountLimitWindow[];
|
|
50
|
+
/** Unix timestamp in milliseconds when the provider supplied this state. */
|
|
51
|
+
observedAt: number;
|
|
52
|
+
}
|
|
53
|
+
/** Account windows from a cached refresh, retaining the last reading on failure. */
|
|
54
|
+
export type AccountLimitsResult = {
|
|
55
|
+
readonly kind: "ready";
|
|
56
|
+
readonly limits: AccountLimits;
|
|
57
|
+
readonly stale: boolean;
|
|
58
|
+
readonly error: string | null;
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: "unavailable";
|
|
61
|
+
readonly reason: "unsupported" | "unconfigured" | "failed";
|
|
62
|
+
readonly message: string;
|
|
63
|
+
};
|
|
64
|
+
/** Account endpoint metadata, independent of a provider's model catalog. */
|
|
65
|
+
export type AccountLimitsTarget = Pick<Model<Api>, "provider" | "baseUrl" | "headers">;
|
|
66
|
+
/** Auth and transport for a provider's non-generating account usage request. */
|
|
67
|
+
export type AccountLimitsFetchOptions = Pick<ProviderRequestOptions, "apiKey" | "headers" | "fetch" | "signal" | "timeoutMs">;
|
|
68
|
+
/** Authentication, HTTP transport, and lifecycle callbacks shared by provider requests. */
|
|
69
|
+
export interface ProviderRequestOptions<TModel = Model<Api>> {
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
/** Request the model's advertised fast inference mode; each API maps it to its own field. */
|
|
72
|
+
fast?: boolean;
|
|
73
|
+
apiKey?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Optional fetch implementation for provider HTTP requests.
|
|
76
|
+
* Defaults to `globalThis.fetch`. Provider adapters that cannot inject a custom implementation may reject it.
|
|
77
|
+
* This does not affect WebSocket transports.
|
|
78
|
+
*/
|
|
79
|
+
fetch?: FetchFunction;
|
|
80
|
+
/**
|
|
81
|
+
* Provider-scoped environment values. These take precedence over process.env for
|
|
82
|
+
* provider configuration such as regional settings, endpoint placeholders, and
|
|
83
|
+
* proxy variables.
|
|
84
|
+
*/
|
|
85
|
+
env?: ProviderEnv;
|
|
86
|
+
/** Inspects the provider request body just before it is sent. */
|
|
87
|
+
onPayload?: (payload: unknown, model: TModel) => void | Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Optional callback invoked after an HTTP response is received.
|
|
90
|
+
*/
|
|
91
|
+
onResponse?: (response: ProviderResponse, model: TModel) => void | Promise<void>;
|
|
92
|
+
/** Account-limit telemetry observed during a provider request. */
|
|
93
|
+
onAccountLimits?: (limits: AccountLimits, model: TModel) => void | Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Optional custom HTTP headers to include in API requests.
|
|
96
|
+
* Merged with provider defaults; caller values override default headers.
|
|
97
|
+
* A null value suppresses a provider/API default header with the same name.
|
|
98
|
+
*/
|
|
99
|
+
headers?: ProviderHeaders;
|
|
100
|
+
/**
|
|
101
|
+
* HTTP request timeout in milliseconds for providers/SDKs that support it.
|
|
102
|
+
* For example, OpenAI and Anthropic SDK clients default to 10 minutes.
|
|
103
|
+
*/
|
|
104
|
+
timeoutMs?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Maximum retry attempts for providers/SDKs that support client-side retries.
|
|
107
|
+
* For example, OpenAI and Anthropic SDK clients default to 2.
|
|
108
|
+
*/
|
|
109
|
+
maxRetries?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Maximum delay in milliseconds to wait for a retry when the server requests a long wait.
|
|
112
|
+
* If the server's requested delay exceeds this value, the request fails immediately
|
|
113
|
+
* with an error containing the requested delay, allowing higher-level retry logic
|
|
114
|
+
* to handle it with user visibility.
|
|
115
|
+
* Default: 60000 (60 seconds). Set to 0 to disable the cap.
|
|
116
|
+
*/
|
|
117
|
+
maxRetryDelayMs?: number;
|
|
118
|
+
}
|
|
119
|
+
export interface StreamOptions extends ProviderRequestOptions<Model<Api>> {
|
|
120
|
+
/**
|
|
121
|
+
* Optional callback invoked after an HTTP response is received and before
|
|
122
|
+
* its body stream is consumed.
|
|
123
|
+
*/
|
|
124
|
+
onResponse?: (response: ProviderResponse, model: Model<Api>) => void | Promise<void>;
|
|
125
|
+
temperature?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Arbitrary sampling parameters merged into the request body as-is, after the named request
|
|
128
|
+
* fields, so keys here override them. Lets custom OpenAI-compatible servers receive parameters
|
|
129
|
+
* Nyte does not model, e.g. `top_p`, `top_k`, `min_p`, `repetition_penalty`. Merged over
|
|
130
|
+
* `Model.samplingParams` per key. Only applied by OpenAI-compatible adapters; other APIs ignore it.
|
|
131
|
+
*/
|
|
132
|
+
samplingParams?: Record<string, unknown>;
|
|
133
|
+
maxTokens?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Preferred transport for providers that support multiple transports.
|
|
136
|
+
* Providers that do not support this option ignore it.
|
|
137
|
+
*/
|
|
138
|
+
transport?: Transport;
|
|
139
|
+
/**
|
|
140
|
+
* Prompt cache retention preference. Providers map this to their supported values.
|
|
141
|
+
* Default: "long".
|
|
142
|
+
*/
|
|
143
|
+
cacheRetention?: CacheRetention;
|
|
144
|
+
/**
|
|
145
|
+
* Optional session identifier for providers that support session-based caching.
|
|
146
|
+
* Providers can use this to enable prompt caching, request routing, or other
|
|
147
|
+
* session-aware features. Ignored by providers that don't support it.
|
|
148
|
+
*/
|
|
149
|
+
sessionId?: string;
|
|
150
|
+
/**
|
|
151
|
+
* WebSocket connect timeout in milliseconds for providers that support
|
|
152
|
+
* WebSocket transports. This covers the connection/open handshake only;
|
|
153
|
+
* stream idleness after connection uses timeoutMs.
|
|
154
|
+
*/
|
|
155
|
+
websocketConnectTimeoutMs?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Optional metadata to include in API requests.
|
|
158
|
+
* Providers extract the fields they understand and ignore the rest.
|
|
159
|
+
* For example, Anthropic uses `user_id` for abuse tracking and rate limiting.
|
|
160
|
+
*/
|
|
161
|
+
metadata?: Record<string, unknown>;
|
|
162
|
+
}
|
|
163
|
+
export type ProviderStreamOptions = StreamOptions & Record<string, unknown>;
|
|
164
|
+
export interface DeferredFetchOptions extends ProviderRequestOptions<Model<Api>> {
|
|
165
|
+
/**
|
|
166
|
+
* Maximum provider long-poll duration in milliseconds.
|
|
167
|
+
* Defaults to 0, which performs one status check.
|
|
168
|
+
*/
|
|
169
|
+
wait?: number;
|
|
170
|
+
}
|
|
171
|
+
/** Request options for best-effort deferred-response cancellation. */
|
|
172
|
+
export type DeferredCancelOptions = ProviderRequestOptions<Model<Api>>;
|
|
173
|
+
/**
|
|
174
|
+
* The uniform stream contract of an API implementation module: every module
|
|
175
|
+
* under `src/api/` exports `stream` and `streamSimple`; capable modules may also
|
|
176
|
+
* export deferred-response methods. Lazy wrappers (`lazyApi()`) and provider
|
|
177
|
+
* factories pass these around as values. This is the untyped dispatch shape;
|
|
178
|
+
* per-API option typing lives on the implementation modules themselves and on
|
|
179
|
+
* `Provider.stream()` via `ApiStreamOptions`.
|
|
180
|
+
*/
|
|
181
|
+
export interface ProviderStreams {
|
|
182
|
+
stream(model: Model<Api>, context: TranscriptContext, options?: StreamOptions): AssistantMessageEventStream;
|
|
183
|
+
streamSimple(model: Model<Api>, context: TranscriptContext, options?: SimpleStreamOptions): AssistantMessageEventStream;
|
|
184
|
+
fetchDeferred?(model: Model<Api>, handle: DeferredHandle, options?: DeferredFetchOptions): AssistantMessageEventStream;
|
|
185
|
+
cancelDeferred?(model: Model<Api>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;
|
|
186
|
+
}
|
|
187
|
+
export interface SimpleStreamOptions extends StreamOptions {
|
|
188
|
+
/** Provider-neutral tool selection for simple requests. Default: "auto". */
|
|
189
|
+
toolChoice?: ToolChoice;
|
|
190
|
+
reasoning?: ThinkingLevel;
|
|
191
|
+
/** Ask a capable provider to return a durable handle and continue the request asynchronously. */
|
|
192
|
+
deferred?: boolean | {
|
|
193
|
+
window?: "15m" | "1h" | "24h";
|
|
194
|
+
};
|
|
195
|
+
/** Custom token budgets for thinking levels (token-based providers only) */
|
|
196
|
+
thinkingBudgets?: ThinkingBudgets;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Generic StreamFunction with typed options.
|
|
200
|
+
*
|
|
201
|
+
* Contract:
|
|
202
|
+
* - Receives a normalized transcript: the system prompt and tools live in the
|
|
203
|
+
* leading system message, never on the context itself.
|
|
204
|
+
* - Must return an AssistantMessageEventStream.
|
|
205
|
+
* - Once invoked, request/model/runtime failures should be encoded in the
|
|
206
|
+
* returned stream, not thrown.
|
|
207
|
+
* - Error termination must produce an AssistantMessage with stopReason
|
|
208
|
+
* "error" or "aborted" and errorMessage, emitted via the stream protocol.
|
|
209
|
+
*/
|
|
210
|
+
export type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (model: Model<TApi>, context: TranscriptContext, options?: TOptions) => AssistantMessageEventStream;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../chunks/account-limits-cache-gr671dr2.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve after `ms`, or reject with `abortError()` once `signal` aborts.
|
|
3
|
+
* The abort listener is detached when the timer fires.
|
|
4
|
+
*/
|
|
5
|
+
export declare function sleep(ms: number, signal: AbortSignal | undefined, abortError: () => Error): Promise<void>;
|
|
6
|
+
/** Create an operation-local signal for public APIs whose signal is optional. */
|
|
7
|
+
export declare function operationSignal(signal?: AbortSignal): AbortSignal;
|
|
8
|
+
/**
|
|
9
|
+
* Stop waiting for an operation when its signal aborts while continuing to
|
|
10
|
+
* observe the abandoned promise so a later rejection is always handled.
|
|
11
|
+
*/
|
|
12
|
+
export declare function raceWithAbortSignal<T>(operation: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits the current tool list into the definitions sent up front and those the transcript loaded later (marked by `addedToolNames` on a tool result), for providers with native deferred tool loading.
|
|
3
|
+
*/
|
|
4
|
+
import type { Context, Tool } from "@nyte-ai/schema/model";
|
|
5
|
+
type ToolNameNormalizer = (name: string) => string;
|
|
6
|
+
/** Split current tools into prefix and transcript-loaded definitions. */
|
|
7
|
+
export declare function splitDeferredTools(context: Context, enabled: boolean, normalizeName?: ToolNameNormalizer): {
|
|
8
|
+
immediate: Tool<import("typebox").TSchema>[];
|
|
9
|
+
deferred: Map<string, Tool<import("typebox").TSchema>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redacted diagnostics attached to an AssistantMessage for failures and recoveries (retries, transport errors).
|
|
3
|
+
*/
|
|
4
|
+
import type { AssistantMessageDiagnostic, DiagnosticErrorInfo } from "@nyte-ai/schema/model";
|
|
5
|
+
export type { AssistantMessageDiagnostic, DiagnosticErrorInfo };
|
|
6
|
+
export declare function formatThrownValue(cause: unknown): string;
|
|
7
|
+
export declare function extractDiagnosticError(cause: unknown): DiagnosticErrorInfo;
|
|
8
|
+
export declare function createAssistantMessageDiagnostic(type: string, cause: unknown, details?: AssistantMessageDiagnostic["details"]): AssistantMessageDiagnostic;
|
|
9
|
+
export declare function appendAssistantMessageDiagnostic<T extends {
|
|
10
|
+
diagnostics?: AssistantMessageDiagnostic[];
|
|
11
|
+
}>(message: T, diagnostic: AssistantMessageDiagnostic): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatThrownValue2,
|
|
3
|
+
extractDiagnosticError2,
|
|
4
|
+
createAssistantMessageDiagnostic2,
|
|
5
|
+
appendAssistantMessageDiagnostic2
|
|
6
|
+
} from "../../chunks/account-limits-cache-9wqk28n5.js";
|
|
7
|
+
export {
|
|
8
|
+
appendAssistantMessageDiagnostic2 as appendAssistantMessageDiagnostic,
|
|
9
|
+
createAssistantMessageDiagnostic2 as createAssistantMessageDiagnostic,
|
|
10
|
+
extractDiagnosticError2 as extractDiagnosticError,
|
|
11
|
+
formatThrownValue2 as formatThrownValue
|
|
12
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared normalization for provider HTTP error objects. Gateways and proxies can return non-2xx bodies the SDK cannot fold into `error.message`; this probes the known SDK field shapes so adapters can surface status and body instead of an opaque message.
|
|
3
|
+
*/
|
|
4
|
+
export declare const MAX_PROVIDER_ERROR_BODY_CHARS = 4000;
|
|
5
|
+
interface NormalizedProviderError {
|
|
6
|
+
/** HTTP status code, when one could be extracted from the SDK error object. */
|
|
7
|
+
status?: number;
|
|
8
|
+
/** Raw HTTP body reason, already trimmed and truncated to the cap. */
|
|
9
|
+
body?: string;
|
|
10
|
+
/** `error.message`, or `safeJsonStringify(error)` for a non-`Error` throw. */
|
|
11
|
+
message: string;
|
|
12
|
+
/** True when `message` already contains the body (no separate body to add). */
|
|
13
|
+
messageCarriesBody: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function normalizeProviderError(cause: unknown): NormalizedProviderError;
|
|
16
|
+
/**
|
|
17
|
+
* Compose a display string from a normalized error. When the message already
|
|
18
|
+
* carries the body (Anthropic / `@google/genai` happy path) or no body/status
|
|
19
|
+
* was extracted, the message is returned unchanged. Otherwise the status and
|
|
20
|
+
* body are surfaced, with an optional provider prefix.
|
|
21
|
+
*
|
|
22
|
+
* - no prefix: `"<status>: <body>"`
|
|
23
|
+
* - prefix: `"<prefix> (<status>): <body>"`
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatProviderError(norm: NormalizedProviderError, prefix?: string): string;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MAX_PROVIDER_ERROR_BODY_CHARS2,
|
|
3
|
+
normalizeProviderError2,
|
|
4
|
+
formatProviderError2
|
|
5
|
+
} from "../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
6
|
+
export {
|
|
7
|
+
MAX_PROVIDER_ERROR_BODY_CHARS2 as MAX_PROVIDER_ERROR_BODY_CHARS,
|
|
8
|
+
formatProviderError2 as formatProviderError,
|
|
9
|
+
normalizeProviderError2 as normalizeProviderError
|
|
10
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context size estimation. Uses the most recent applicable assistant usage block as the anchor and estimates only the messages after it, so the number tracks the provider's count instead of a chars-per-token guess over the whole history.
|
|
3
|
+
*/
|
|
4
|
+
import type { Context, ImageContent, Message, TextContent, TranscriptContext, Usage } from "@nyte-ai/schema/model";
|
|
5
|
+
export interface ContextUsageEstimate {
|
|
6
|
+
/** Estimated total context tokens. */
|
|
7
|
+
tokens: number;
|
|
8
|
+
/** Tokens reported by the most recent applicable assistant usage block. */
|
|
9
|
+
usageTokens: number;
|
|
10
|
+
/** Estimated tokens after the most recent applicable assistant usage block. */
|
|
11
|
+
trailingTokens: number;
|
|
12
|
+
/** Index of the applicable message that provided usage, or null when none exists. */
|
|
13
|
+
lastUsageIndex: number | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function calculateContextTokens(usage: Usage): number;
|
|
16
|
+
export declare function estimateTextTokens(text: string): number;
|
|
17
|
+
export declare function estimateTextAndImageContentTokens(content: string | Array<TextContent | ImageContent>): number;
|
|
18
|
+
export declare function estimateMessageTokens(message: Message): number;
|
|
19
|
+
/** Estimates a context's tokens. A transcript carries its prompt and tools in system messages, so only a legacy context adds them separately. */
|
|
20
|
+
export declare function estimateContextTokens(context: Context | TranscriptContext | readonly Message[]): ContextUsageEstimate;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calculateContextTokens2,
|
|
3
|
+
estimateTextTokens2,
|
|
4
|
+
estimateTextAndImageContentTokens2,
|
|
5
|
+
estimateMessageTokens2,
|
|
6
|
+
estimateContextTokens2
|
|
7
|
+
} from "../../chunks/account-limits-cache-dejeygdt.js";
|
|
8
|
+
export {
|
|
9
|
+
calculateContextTokens2 as calculateContextTokens,
|
|
10
|
+
estimateContextTokens2 as estimateContextTokens,
|
|
11
|
+
estimateMessageTokens2 as estimateMessageTokens,
|
|
12
|
+
estimateTextAndImageContentTokens2 as estimateTextAndImageContentTokens,
|
|
13
|
+
estimateTextTokens2 as estimateTextTokens
|
|
14
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async event queue with a promise for the terminal result. AssistantMessageEventStream is the stream every adapter returns: events are pushed as they arrive, and `result()` resolves with the final AssistantMessage once `done` or `error` is pushed.
|
|
3
|
+
*/
|
|
4
|
+
import type { AssistantMessage, AssistantMessageEvent } from "@nyte-ai/schema/model";
|
|
5
|
+
export declare class EventStream<T, R = T> implements AsyncIterable<T> {
|
|
6
|
+
private queue;
|
|
7
|
+
private waiting;
|
|
8
|
+
private done;
|
|
9
|
+
private finalResult;
|
|
10
|
+
private isComplete;
|
|
11
|
+
private extractResult;
|
|
12
|
+
constructor(isComplete: (event: T) => boolean, extractResult: (event: T) => R);
|
|
13
|
+
push(event: T): void;
|
|
14
|
+
end(result?: R): void;
|
|
15
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
16
|
+
result(): Promise<R>;
|
|
17
|
+
}
|
|
18
|
+
export declare class AssistantMessageEventStream extends EventStream<AssistantMessageEvent, AssistantMessage> {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
/** Factory function for AssistantMessageEventStream (for use in extensions) */
|
|
22
|
+
export declare function createAssistantMessageEventStream(): AssistantMessageEventStream;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EventStream2,
|
|
3
|
+
AssistantMessageEventStream2,
|
|
4
|
+
createAssistantMessageEventStream2
|
|
5
|
+
} from "../../chunks/account-limits-cache-a6cgeagz.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
7
|
+
export {
|
|
8
|
+
AssistantMessageEventStream2 as AssistantMessageEventStream,
|
|
9
|
+
EventStream2 as EventStream,
|
|
10
|
+
createAssistantMessageEventStream2 as createAssistantMessageEventStream
|
|
11
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place that reads provider error text. An assistant message that
|
|
3
|
+
* stopped with `error` or `aborted` is classified here, once, into a closed
|
|
4
|
+
* `FailureClass`; everything downstream switches on the class.
|
|
5
|
+
*
|
|
6
|
+
* Context-window examples by provider:
|
|
7
|
+
*
|
|
8
|
+
* - Anthropic: "prompt is too long: 213462 tokens > 200000 maximum"
|
|
9
|
+
* - Anthropic: "413 {\"error\":{\"type\":\"request_too_large\",\"message\":\"Request exceeds the maximum size\"}}"
|
|
10
|
+
* - OpenAI: "Your input exceeds the context window of this model"
|
|
11
|
+
* - OpenAI/LiteLLM: "Requested token count exceeds the model's maximum context length of 131072 tokens"
|
|
12
|
+
* - OpenAI-compatible: "Input length (265330) exceeds model's maximum context length (262144)."
|
|
13
|
+
* - Google: "The input token count (1196265) exceeds the maximum number of tokens allowed (1048575)"
|
|
14
|
+
* - xAI: "This model's maximum prompt length is 131072 but the request contains 537812 tokens"
|
|
15
|
+
* - Groq: "Please reduce the length of the messages or completion"
|
|
16
|
+
* - OpenRouter: "This endpoint's maximum context length is X tokens. However, you requested about Y tokens"
|
|
17
|
+
* - OpenRouter/Poolside: "Input length X exceeds the maximum allowed input length of Y tokens."
|
|
18
|
+
* - Together AI: "The input (X tokens) is longer than the model's context length (Y tokens)."
|
|
19
|
+
* - llama.cpp: "the request exceeds the available context size, try increasing it"
|
|
20
|
+
* - LM Studio: "tokens to keep from the initial prompt is greater than the context length"
|
|
21
|
+
* - GitHub Copilot: "prompt token count of X exceeds the limit of Y"
|
|
22
|
+
* - MiniMax: "invalid params, context window exceeds limit"
|
|
23
|
+
* - Kimi For Coding: "Your request exceeded model token limit: X (requested: Y)"
|
|
24
|
+
* - DS4: "Prompt has X tokens, but the configured context size is Y tokens"
|
|
25
|
+
* - Cerebras: "400/413 status code (no body)", only from the cerebras provider
|
|
26
|
+
* - Mistral: "Prompt contains X tokens ... too large for model with Y maximum context length"
|
|
27
|
+
* - z.ai: "Prompt too long", "Prompt exceeds max length" (CN endpoint), or silent
|
|
28
|
+
* overflow detected via usage.input > contextWindow
|
|
29
|
+
* - Xiaomi MiMo: truncates input to fill contextWindow, then returns finish_reason "length"
|
|
30
|
+
* with output=0; detected via stopReason "length" + zero output + input filling the window.
|
|
31
|
+
* - DashScope/Qwen: "Range of input length should be [1, X]"
|
|
32
|
+
* - Ollama: "prompt too long; exceeded max context length by X tokens"
|
|
33
|
+
*/
|
|
34
|
+
import type { Failure, FailureClass } from "@nyte-ai/schema";
|
|
35
|
+
import type { Api, AssistantMessage, Model } from "@nyte-ai/schema/model";
|
|
36
|
+
/**
|
|
37
|
+
* Whether provider error text reports spent quota or credit, which waiting does not lift. It
|
|
38
|
+
* outranks a 429 status: providers answer exhausted credit with 429, e.g. Anthropic's
|
|
39
|
+
* `extra_usage_out_of_credits`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function reportsQuotaExhaustion(text: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Classify an assistant message's failure. `model` enables detecting the
|
|
44
|
+
* overflow a provider accepts without an error. A message that did not fail
|
|
45
|
+
* and did not overflow answers `provider` with an empty message.
|
|
46
|
+
*/
|
|
47
|
+
export declare function classifyAssistantFailure(message: AssistantMessage, model?: Pick<Model<Api>, "contextWindow">): Failure;
|
|
48
|
+
/** Whether another attempt can change the answer: load, limits that lift, and transport. */
|
|
49
|
+
export declare function retryCanHelp(failureClass: FailureClass): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
reportsQuotaExhaustion2,
|
|
3
|
+
classifyAssistantFailure2,
|
|
4
|
+
retryCanHelp2
|
|
5
|
+
} from "../../chunks/account-limits-cache-xds88kxd.js";
|
|
6
|
+
export {
|
|
7
|
+
classifyAssistantFailure2 as classifyAssistantFailure,
|
|
8
|
+
reportsQuotaExhaustion2 as reportsQuotaExhaustion,
|
|
9
|
+
retryCanHelp2 as retryCanHelp
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-in, first-out storage with amortized constant-time dequeue: values enter one stack and leave the other, which is refilled in reverse only when empty.
|
|
3
|
+
*/
|
|
4
|
+
export declare class FifoQueue<T> {
|
|
5
|
+
private incoming;
|
|
6
|
+
private outgoing;
|
|
7
|
+
get length(): number;
|
|
8
|
+
enqueue(value: T): void;
|
|
9
|
+
dequeue(): T | undefined;
|
|
10
|
+
clear(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header helpers: flatten a fetch Headers object, and merge caller-supplied ProviderHeaders case-insensitively, where a later source replaces an earlier header. A null survives the merge for SDKs that use it to suppress their defaults; the string record drops it instead. Presence checks ignore null and blank values.
|
|
3
|
+
*/
|
|
4
|
+
import type { ProviderHeaders } from "../types.ts";
|
|
5
|
+
export declare function headersToRecord(headers: Headers): {
|
|
6
|
+
[k: string]: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function mergeProviderHeaders(...headerSources: (ProviderHeaders | undefined)[]): ProviderHeaders;
|
|
9
|
+
export declare function providerHeadersToRecord(...headerSources: (ProviderHeaders | undefined)[]): Record<string, string> | undefined;
|
|
10
|
+
export declare function hasHeader(headers: ProviderHeaders | undefined, name: string): boolean;
|
|
11
|
+
/** The OpenAI SDK requires a key; a caller-supplied authorization header stands in for one. */
|
|
12
|
+
export declare function getClientApiKey(provider: string, apiKey: string | undefined, headers: ProviderHeaders | undefined): string;
|