@prometheus-ai/ai 0.5.0
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/CHANGELOG.md +7 -0
- package/README.md +1184 -0
- package/dist/types/api-registry.d.ts +30 -0
- package/dist/types/auth-broker/client.d.ts +66 -0
- package/dist/types/auth-broker/index.d.ts +6 -0
- package/dist/types/auth-broker/refresher.d.ts +25 -0
- package/dist/types/auth-broker/remote-store.d.ts +101 -0
- package/dist/types/auth-broker/server.d.ts +32 -0
- package/dist/types/auth-broker/snapshot-cache.d.ts +17 -0
- package/dist/types/auth-broker/types.d.ts +107 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +412 -0
- package/dist/types/auth-gateway/http.d.ts +39 -0
- package/dist/types/auth-gateway/index.d.ts +3 -0
- package/dist/types/auth-gateway/server.d.ts +36 -0
- package/dist/types/auth-gateway/types.d.ts +117 -0
- package/dist/types/auth-storage.d.ts +762 -0
- package/dist/types/index.d.ts +49 -0
- package/dist/types/model-cache.d.ts +17 -0
- package/dist/types/model-manager.d.ts +64 -0
- package/dist/types/model-thinking.d.ts +100 -0
- package/dist/types/models.d.ts +12 -0
- package/dist/types/provider-details.d.ts +24 -0
- package/dist/types/provider-models/bundled-references.d.ts +4 -0
- package/dist/types/provider-models/descriptors.d.ts +50 -0
- package/dist/types/provider-models/google.d.ts +24 -0
- package/dist/types/provider-models/index.d.ts +5 -0
- package/dist/types/provider-models/ollama.d.ts +7 -0
- package/dist/types/provider-models/openai-compat.d.ts +323 -0
- package/dist/types/provider-models/special.d.ts +16 -0
- package/dist/types/providers/amazon-bedrock.d.ts +38 -0
- package/dist/types/providers/anthropic-client.d.ts +99 -0
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +465 -0
- package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
- package/dist/types/providers/anthropic-wire.d.ts +262 -0
- package/dist/types/providers/anthropic.d.ts +206 -0
- package/dist/types/providers/aws-credentials.d.ts +43 -0
- package/dist/types/providers/aws-eventstream.d.ts +38 -0
- package/dist/types/providers/aws-sigv4.d.ts +55 -0
- package/dist/types/providers/azure-openai-responses.d.ts +15 -0
- package/dist/types/providers/cursor/gen/agent_pb.d.ts +13022 -0
- package/dist/types/providers/cursor.d.ts +43 -0
- package/dist/types/providers/error-message.d.ts +27 -0
- package/dist/types/providers/github-copilot-headers.d.ts +40 -0
- package/dist/types/providers/gitlab-duo.d.ts +27 -0
- package/dist/types/providers/google-auth.d.ts +24 -0
- package/dist/types/providers/google-gemini-cli.d.ts +81 -0
- package/dist/types/providers/google-gemini-headers.d.ts +18 -0
- package/dist/types/providers/google-shared.d.ts +171 -0
- package/dist/types/providers/google-types.d.ts +138 -0
- package/dist/types/providers/google-vertex.d.ts +7 -0
- package/dist/types/providers/google.d.ts +4 -0
- package/dist/types/providers/grammar.d.ts +1 -0
- package/dist/types/providers/kimi.d.ts +27 -0
- package/dist/types/providers/mock.d.ts +173 -0
- package/dist/types/providers/ollama.d.ts +6 -0
- package/dist/types/providers/openai-anthropic-shim.d.ts +31 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +817 -0
- package/dist/types/providers/openai-chat-server.d.ts +16 -0
- package/dist/types/providers/openai-codex/constants.d.ts +26 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +49 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +17 -0
- package/dist/types/providers/openai-codex-responses.d.ts +67 -0
- package/dist/types/providers/openai-completions-compat.d.ts +27 -0
- package/dist/types/providers/openai-completions.d.ts +54 -0
- package/dist/types/providers/openai-responses-server-schema.d.ts +392 -0
- package/dist/types/providers/openai-responses-server.d.ts +17 -0
- package/dist/types/providers/openai-responses-shared.d.ts +105 -0
- package/dist/types/providers/openai-responses.d.ts +66 -0
- package/dist/types/providers/prometheus-native-client.d.ts +13 -0
- package/dist/types/providers/prometheus-native-server.d.ts +68 -0
- package/dist/types/providers/register-builtins.d.ts +31 -0
- package/dist/types/providers/synthetic.d.ts +26 -0
- package/dist/types/providers/transform-messages.d.ts +12 -0
- package/dist/types/providers/vision-guard.d.ts +20 -0
- package/dist/types/providers/xai-responses.d.ts +23 -0
- package/dist/types/rate-limit-utils.d.ts +19 -0
- package/dist/types/stream.d.ts +28 -0
- package/dist/types/types.d.ts +819 -0
- package/dist/types/usage/claude.d.ts +4 -0
- package/dist/types/usage/gemini.d.ts +2 -0
- package/dist/types/usage/github-copilot.d.ts +7 -0
- package/dist/types/usage/google-antigravity.d.ts +2 -0
- package/dist/types/usage/kimi.d.ts +2 -0
- package/dist/types/usage/minimax-code.d.ts +2 -0
- package/dist/types/usage/openai-codex.d.ts +3 -0
- package/dist/types/usage/shared.d.ts +1 -0
- package/dist/types/usage/zai.d.ts +2 -0
- package/dist/types/usage.d.ts +260 -0
- package/dist/types/utils/abort.d.ts +19 -0
- package/dist/types/utils/abortable-iterator.d.ts +4 -0
- package/dist/types/utils/anthropic-auth.d.ts +35 -0
- package/dist/types/utils/discovery/antigravity.d.ts +61 -0
- package/dist/types/utils/discovery/codex.d.ts +38 -0
- package/dist/types/utils/discovery/cursor.d.ts +23 -0
- package/dist/types/utils/discovery/gemini.d.ts +25 -0
- package/dist/types/utils/discovery/index.d.ts +4 -0
- package/dist/types/utils/discovery/openai-compatible.d.ts +72 -0
- package/dist/types/utils/event-stream.d.ts +28 -0
- package/dist/types/utils/fireworks-model-id.d.ts +10 -0
- package/dist/types/utils/foundry.d.ts +1 -0
- package/dist/types/utils/http-inspector.d.ts +31 -0
- package/dist/types/utils/idle-iterator.d.ts +78 -0
- package/dist/types/utils/json-parse.d.ts +37 -0
- package/dist/types/utils/oauth/__tests__/xai-oauth.test.d.ts +1 -0
- package/dist/types/utils/oauth/alibaba-coding-plan.d.ts +18 -0
- package/dist/types/utils/oauth/anthropic.d.ts +22 -0
- package/dist/types/utils/oauth/api-key-login.d.ts +35 -0
- package/dist/types/utils/oauth/api-key-validation.d.ts +27 -0
- package/dist/types/utils/oauth/callback-server.d.ts +57 -0
- package/dist/types/utils/oauth/cerebras.d.ts +1 -0
- package/dist/types/utils/oauth/cloudflare-ai-gateway.d.ts +18 -0
- package/dist/types/utils/oauth/cursor.d.ts +15 -0
- package/dist/types/utils/oauth/deepseek.d.ts +10 -0
- package/dist/types/utils/oauth/firepass.d.ts +1 -0
- package/dist/types/utils/oauth/fireworks.d.ts +1 -0
- package/dist/types/utils/oauth/github-copilot.d.ts +38 -0
- package/dist/types/utils/oauth/gitlab-duo.d.ts +3 -0
- package/dist/types/utils/oauth/google-antigravity.d.ts +11 -0
- package/dist/types/utils/oauth/google-gemini-cli.d.ts +10 -0
- package/dist/types/utils/oauth/google-oauth-shared.d.ts +28 -0
- package/dist/types/utils/oauth/huggingface.d.ts +19 -0
- package/dist/types/utils/oauth/index.d.ts +38 -0
- package/dist/types/utils/oauth/kagi.d.ts +17 -0
- package/dist/types/utils/oauth/kilo.d.ts +5 -0
- package/dist/types/utils/oauth/kimi.d.ts +21 -0
- package/dist/types/utils/oauth/litellm.d.ts +18 -0
- package/dist/types/utils/oauth/lm-studio.d.ts +17 -0
- package/dist/types/utils/oauth/minimax-code.d.ts +28 -0
- package/dist/types/utils/oauth/moonshot.d.ts +1 -0
- package/dist/types/utils/oauth/nanogpt.d.ts +1 -0
- package/dist/types/utils/oauth/nvidia.d.ts +18 -0
- package/dist/types/utils/oauth/ollama-cloud.d.ts +2 -0
- package/dist/types/utils/oauth/ollama.d.ts +18 -0
- package/dist/types/utils/oauth/openai-codex.d.ts +21 -0
- package/dist/types/utils/oauth/opencode.d.ts +18 -0
- package/dist/types/utils/oauth/openrouter.d.ts +1 -0
- package/dist/types/utils/oauth/parallel.d.ts +17 -0
- package/dist/types/utils/oauth/perplexity.d.ts +9 -0
- package/dist/types/utils/oauth/pkce.d.ts +8 -0
- package/dist/types/utils/oauth/qianfan.d.ts +17 -0
- package/dist/types/utils/oauth/qwen-portal.d.ts +19 -0
- package/dist/types/utils/oauth/synthetic.d.ts +1 -0
- package/dist/types/utils/oauth/tavily.d.ts +17 -0
- package/dist/types/utils/oauth/together.d.ts +1 -0
- package/dist/types/utils/oauth/types.d.ts +44 -0
- package/dist/types/utils/oauth/venice.d.ts +18 -0
- package/dist/types/utils/oauth/vercel-ai-gateway.d.ts +18 -0
- package/dist/types/utils/oauth/vllm.d.ts +16 -0
- package/dist/types/utils/oauth/wafer.d.ts +2 -0
- package/dist/types/utils/oauth/xai-oauth.d.ts +60 -0
- package/dist/types/utils/oauth/xiaomi.d.ts +25 -0
- package/dist/types/utils/oauth/zai.d.ts +18 -0
- package/dist/types/utils/oauth/zenmux.d.ts +1 -0
- package/dist/types/utils/oauth/zhipu.d.ts +18 -0
- package/dist/types/utils/overflow.d.ts +54 -0
- package/dist/types/utils/parse-bind.d.ts +23 -0
- package/dist/types/utils/provider-response.d.ts +3 -0
- package/dist/types/utils/request-debug.d.ts +29 -0
- package/dist/types/utils/retry-after.d.ts +3 -0
- package/dist/types/utils/retry.d.ts +26 -0
- package/dist/types/utils/schema/adapt.d.ts +24 -0
- package/dist/types/utils/schema/compatibility.d.ts +30 -0
- package/dist/types/utils/schema/dereference.d.ts +11 -0
- package/dist/types/utils/schema/draft.d.ts +10 -0
- package/dist/types/utils/schema/equality.d.ts +4 -0
- package/dist/types/utils/schema/fields.d.ts +49 -0
- package/dist/types/utils/schema/index.d.ts +13 -0
- package/dist/types/utils/schema/json-schema-validator.d.ts +12 -0
- package/dist/types/utils/schema/meta-validator.d.ts +2 -0
- package/dist/types/utils/schema/normalize.d.ts +93 -0
- package/dist/types/utils/schema/spill.d.ts +8 -0
- package/dist/types/utils/schema/stamps.d.ts +25 -0
- package/dist/types/utils/schema/types.d.ts +4 -0
- package/dist/types/utils/schema/wire.d.ts +53 -0
- package/dist/types/utils/schema/zod-decontaminate.d.ts +31 -0
- package/dist/types/utils/sdk-stream-timeout.d.ts +33 -0
- package/dist/types/utils/sse-debug.d.ts +10 -0
- package/dist/types/utils/stream-markup-healing.d.ts +80 -0
- package/dist/types/utils/tool-choice.d.ts +50 -0
- package/dist/types/utils/validation.d.ts +17 -0
- package/dist/types/utils.d.ts +28 -0
- package/package.json +142 -0
- package/src/api-registry.ts +96 -0
- package/src/auth-broker/client.ts +358 -0
- package/src/auth-broker/index.ts +6 -0
- package/src/auth-broker/refresher.ts +117 -0
- package/src/auth-broker/remote-store.ts +637 -0
- package/src/auth-broker/server.ts +644 -0
- package/src/auth-broker/snapshot-cache.ts +174 -0
- package/src/auth-broker/types.ts +130 -0
- package/src/auth-broker/wire-schemas.ts +200 -0
- package/src/auth-gateway/http.ts +194 -0
- package/src/auth-gateway/index.ts +3 -0
- package/src/auth-gateway/server.ts +822 -0
- package/src/auth-gateway/types.ts +143 -0
- package/src/auth-storage.ts +4608 -0
- package/src/index.ts +54 -0
- package/src/model-cache.ts +129 -0
- package/src/model-manager.ts +469 -0
- package/src/model-thinking.ts +756 -0
- package/src/models.json +60287 -0
- package/src/models.json.d.ts +9 -0
- package/src/models.ts +56 -0
- package/src/prompts/turn-aborted-guidance.md +4 -0
- package/src/provider-details.ts +90 -0
- package/src/provider-models/bundled-references.ts +38 -0
- package/src/provider-models/descriptors.ts +364 -0
- package/src/provider-models/google.ts +88 -0
- package/src/provider-models/index.ts +5 -0
- package/src/provider-models/ollama.ts +153 -0
- package/src/provider-models/openai-compat.ts +2904 -0
- package/src/provider-models/special.ts +67 -0
- package/src/providers/amazon-bedrock.ts +873 -0
- package/src/providers/anthropic-client.ts +318 -0
- package/src/providers/anthropic-messages-server-schema.ts +243 -0
- package/src/providers/anthropic-messages-server.ts +681 -0
- package/src/providers/anthropic-wire.ts +268 -0
- package/src/providers/anthropic.ts +3106 -0
- package/src/providers/aws-credentials.ts +501 -0
- package/src/providers/aws-eventstream.ts +185 -0
- package/src/providers/aws-sigv4.ts +218 -0
- package/src/providers/azure-openai-responses.ts +361 -0
- package/src/providers/cursor/gen/agent_pb.ts +15274 -0
- package/src/providers/cursor/proto/agent.proto +3526 -0
- package/src/providers/cursor/proto/buf.gen.yaml +6 -0
- package/src/providers/cursor/proto/buf.yaml +17 -0
- package/src/providers/cursor.ts +2621 -0
- package/src/providers/error-message.ts +21 -0
- package/src/providers/github-copilot-headers.ts +140 -0
- package/src/providers/gitlab-duo.ts +372 -0
- package/src/providers/google-auth.ts +252 -0
- package/src/providers/google-gemini-cli.ts +809 -0
- package/src/providers/google-gemini-headers.ts +41 -0
- package/src/providers/google-shared.ts +917 -0
- package/src/providers/google-types.ts +167 -0
- package/src/providers/google-vertex.ts +91 -0
- package/src/providers/google.ts +41 -0
- package/src/providers/grammar.ts +70 -0
- package/src/providers/kimi.ts +52 -0
- package/src/providers/mock.ts +496 -0
- package/src/providers/ollama.ts +644 -0
- package/src/providers/openai-anthropic-shim.ts +138 -0
- package/src/providers/openai-chat-server-schema.ts +252 -0
- package/src/providers/openai-chat-server.ts +647 -0
- package/src/providers/openai-codex/constants.ts +43 -0
- package/src/providers/openai-codex/request-transformer.ts +161 -0
- package/src/providers/openai-codex/response-handler.ts +81 -0
- package/src/providers/openai-codex-responses.ts +3027 -0
- package/src/providers/openai-completions-compat.ts +320 -0
- package/src/providers/openai-completions.ts +2002 -0
- package/src/providers/openai-responses-server-schema.ts +290 -0
- package/src/providers/openai-responses-server.ts +1183 -0
- package/src/providers/openai-responses-shared.ts +956 -0
- package/src/providers/openai-responses.ts +679 -0
- package/src/providers/prometheus-native-client.ts +228 -0
- package/src/providers/prometheus-native-server.ts +212 -0
- package/src/providers/register-builtins.ts +457 -0
- package/src/providers/synthetic.ts +50 -0
- package/src/providers/transform-messages.ts +382 -0
- package/src/providers/vision-guard.ts +52 -0
- package/src/providers/xai-responses.ts +82 -0
- package/src/rate-limit-utils.ts +91 -0
- package/src/stream.ts +1068 -0
- package/src/types.ts +965 -0
- package/src/usage/claude.ts +482 -0
- package/src/usage/gemini.ts +250 -0
- package/src/usage/github-copilot.ts +421 -0
- package/src/usage/google-antigravity.ts +201 -0
- package/src/usage/kimi.ts +271 -0
- package/src/usage/minimax-code.ts +31 -0
- package/src/usage/openai-codex.ts +503 -0
- package/src/usage/shared.ts +10 -0
- package/src/usage/zai.ts +247 -0
- package/src/usage.ts +185 -0
- package/src/utils/abort.ts +51 -0
- package/src/utils/abortable-iterator.ts +69 -0
- package/src/utils/anthropic-auth.ts +93 -0
- package/src/utils/discovery/antigravity.ts +261 -0
- package/src/utils/discovery/codex.ts +371 -0
- package/src/utils/discovery/cursor.ts +306 -0
- package/src/utils/discovery/gemini.ts +248 -0
- package/src/utils/discovery/index.ts +4 -0
- package/src/utils/discovery/openai-compatible.ts +224 -0
- package/src/utils/event-stream.ts +142 -0
- package/src/utils/fireworks-model-id.ts +30 -0
- package/src/utils/foundry.ts +8 -0
- package/src/utils/http-inspector.ts +176 -0
- package/src/utils/idle-iterator.ts +273 -0
- package/src/utils/json-parse.ts +182 -0
- package/src/utils/oauth/__tests__/xai-oauth.test.ts +107 -0
- package/src/utils/oauth/alibaba-coding-plan.ts +59 -0
- package/src/utils/oauth/anthropic.ts +273 -0
- package/src/utils/oauth/api-key-login.ts +87 -0
- package/src/utils/oauth/api-key-validation.ts +92 -0
- package/src/utils/oauth/callback-server.ts +276 -0
- package/src/utils/oauth/cerebras.ts +16 -0
- package/src/utils/oauth/cloudflare-ai-gateway.ts +48 -0
- package/src/utils/oauth/cursor.ts +157 -0
- package/src/utils/oauth/deepseek.ts +53 -0
- package/src/utils/oauth/firepass.ts +24 -0
- package/src/utils/oauth/fireworks.ts +15 -0
- package/src/utils/oauth/github-copilot.ts +362 -0
- package/src/utils/oauth/gitlab-duo.ts +123 -0
- package/src/utils/oauth/google-antigravity.ts +200 -0
- package/src/utils/oauth/google-gemini-cli.ts +256 -0
- package/src/utils/oauth/google-oauth-shared.ts +110 -0
- package/src/utils/oauth/huggingface.ts +62 -0
- package/src/utils/oauth/index.ts +502 -0
- package/src/utils/oauth/kagi.ts +47 -0
- package/src/utils/oauth/kilo.ts +87 -0
- package/src/utils/oauth/kimi.ts +254 -0
- package/src/utils/oauth/litellm.ts +47 -0
- package/src/utils/oauth/lm-studio.ts +38 -0
- package/src/utils/oauth/minimax-code.ts +80 -0
- package/src/utils/oauth/moonshot.ts +23 -0
- package/src/utils/oauth/nanogpt.ts +15 -0
- package/src/utils/oauth/nvidia.ts +70 -0
- package/src/utils/oauth/oauth.html +199 -0
- package/src/utils/oauth/ollama-cloud.ts +28 -0
- package/src/utils/oauth/ollama.ts +47 -0
- package/src/utils/oauth/openai-codex.ts +299 -0
- package/src/utils/oauth/opencode.ts +49 -0
- package/src/utils/oauth/openrouter.ts +20 -0
- package/src/utils/oauth/parallel.ts +46 -0
- package/src/utils/oauth/perplexity.ts +206 -0
- package/src/utils/oauth/pkce.ts +18 -0
- package/src/utils/oauth/qianfan.ts +58 -0
- package/src/utils/oauth/qwen-portal.ts +60 -0
- package/src/utils/oauth/synthetic.ts +15 -0
- package/src/utils/oauth/tavily.ts +46 -0
- package/src/utils/oauth/together.ts +16 -0
- package/src/utils/oauth/types.ts +102 -0
- package/src/utils/oauth/venice.ts +59 -0
- package/src/utils/oauth/vercel-ai-gateway.ts +47 -0
- package/src/utils/oauth/vllm.ts +40 -0
- package/src/utils/oauth/wafer.ts +50 -0
- package/src/utils/oauth/xai-oauth.ts +342 -0
- package/src/utils/oauth/xiaomi.ts +194 -0
- package/src/utils/oauth/zai.ts +60 -0
- package/src/utils/oauth/zenmux.ts +15 -0
- package/src/utils/oauth/zhipu.ts +60 -0
- package/src/utils/overflow.ts +137 -0
- package/src/utils/parse-bind.ts +54 -0
- package/src/utils/provider-response.ts +30 -0
- package/src/utils/request-debug.ts +336 -0
- package/src/utils/retry-after.ts +110 -0
- package/src/utils/retry.ts +54 -0
- package/src/utils/schema/CONSTRAINTS.md +164 -0
- package/src/utils/schema/adapt.ts +36 -0
- package/src/utils/schema/compatibility.ts +435 -0
- package/src/utils/schema/dereference.ts +98 -0
- package/src/utils/schema/draft.ts +341 -0
- package/src/utils/schema/equality.ts +97 -0
- package/src/utils/schema/fields.ts +191 -0
- package/src/utils/schema/index.ts +13 -0
- package/src/utils/schema/json-schema-validator.ts +577 -0
- package/src/utils/schema/meta-validator.ts +167 -0
- package/src/utils/schema/normalize.ts +1588 -0
- package/src/utils/schema/spill.ts +43 -0
- package/src/utils/schema/stamps.ts +97 -0
- package/src/utils/schema/types.ts +10 -0
- package/src/utils/schema/wire.ts +293 -0
- package/src/utils/schema/zod-decontaminate.ts +331 -0
- package/src/utils/sdk-stream-timeout.ts +43 -0
- package/src/utils/sse-debug.ts +289 -0
- package/src/utils/stream-markup-healing.ts +612 -0
- package/src/utils/tool-choice.ts +99 -0
- package/src/utils/validation.ts +1024 -0
- package/src/utils.ts +166 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export { type ZodType, z } from "zod/v4";
|
|
2
|
+
export * from "./api-registry";
|
|
3
|
+
export * from "./auth-broker";
|
|
4
|
+
export { type AuthGatewayBootOptions, type ModelResolver, startAuthGateway } from "./auth-gateway/server";
|
|
5
|
+
export * from "./auth-gateway/types";
|
|
6
|
+
export * from "./auth-storage";
|
|
7
|
+
export * from "./model-cache";
|
|
8
|
+
export * from "./model-manager";
|
|
9
|
+
export * from "./model-thinking";
|
|
10
|
+
export * from "./models";
|
|
11
|
+
export * from "./provider-details";
|
|
12
|
+
export * from "./provider-models";
|
|
13
|
+
export * from "./providers/anthropic";
|
|
14
|
+
export * from "./providers/anthropic-client";
|
|
15
|
+
export * from "./providers/azure-openai-responses";
|
|
16
|
+
export type * from "./providers/cursor";
|
|
17
|
+
export * from "./providers/gitlab-duo";
|
|
18
|
+
export type * from "./providers/google";
|
|
19
|
+
export type * from "./providers/google-gemini-cli";
|
|
20
|
+
export * from "./providers/google-gemini-headers";
|
|
21
|
+
export type * from "./providers/google-vertex";
|
|
22
|
+
export * from "./providers/kimi";
|
|
23
|
+
export * from "./providers/mock";
|
|
24
|
+
export * from "./providers/ollama";
|
|
25
|
+
export * from "./providers/openai-codex-responses";
|
|
26
|
+
export * from "./providers/openai-completions";
|
|
27
|
+
export * from "./providers/openai-responses";
|
|
28
|
+
export * from "./providers/synthetic";
|
|
29
|
+
export * from "./rate-limit-utils";
|
|
30
|
+
export * from "./stream";
|
|
31
|
+
export * from "./types";
|
|
32
|
+
export * from "./usage";
|
|
33
|
+
export * from "./usage/claude";
|
|
34
|
+
export * from "./usage/gemini";
|
|
35
|
+
export * from "./usage/github-copilot";
|
|
36
|
+
export * from "./usage/google-antigravity";
|
|
37
|
+
export * from "./usage/kimi";
|
|
38
|
+
export * from "./usage/minimax-code";
|
|
39
|
+
export * from "./usage/openai-codex";
|
|
40
|
+
export * from "./usage/zai";
|
|
41
|
+
export * from "./utils/anthropic-auth";
|
|
42
|
+
export * from "./utils/discovery";
|
|
43
|
+
export * from "./utils/event-stream";
|
|
44
|
+
export * from "./utils/oauth";
|
|
45
|
+
export type { OAuthCredentials, OAuthProvider, OAuthProviderId, OAuthProviderInfo, } from "./utils/oauth/types";
|
|
46
|
+
export * from "./utils/overflow";
|
|
47
|
+
export * from "./utils/retry";
|
|
48
|
+
export * from "./utils/schema";
|
|
49
|
+
export * from "./utils/validation";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Api, Model } from "./types";
|
|
2
|
+
interface CacheEntry<TApi extends Api = Api> {
|
|
3
|
+
models: Model<TApi>[];
|
|
4
|
+
fresh: boolean;
|
|
5
|
+
authoritative: boolean;
|
|
6
|
+
updatedAt: number;
|
|
7
|
+
/**
|
|
8
|
+
* Hash of the static catalog slice that was merged into `models` when this
|
|
9
|
+
* row was written. `resolveProviderModels` compares against the current
|
|
10
|
+
* static fingerprint and bypasses the static+cache re-merge when they
|
|
11
|
+
* match — the cache already incorporates the same static state.
|
|
12
|
+
*/
|
|
13
|
+
staticFingerprint: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function readModelCache<TApi extends Api>(providerId: string, ttlMs: number, now: () => number, dbPath?: string): CacheEntry<TApi> | null;
|
|
16
|
+
export declare function writeModelCache<TApi extends Api>(providerId: string, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string): void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Api, Model, Provider } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Controls when dynamic endpoint models should be fetched.
|
|
4
|
+
*/
|
|
5
|
+
export type ModelRefreshStrategy = "online" | "offline" | "online-if-uncached";
|
|
6
|
+
/**
|
|
7
|
+
* Hook for loading and mapping models.dev fallback data into canonical model objects.
|
|
8
|
+
*/
|
|
9
|
+
export interface ModelsDevFallback<TApi extends Api = Api, TPayload = unknown> {
|
|
10
|
+
/** Fetches raw fallback payload (for example from models.dev). */
|
|
11
|
+
fetch(): Promise<TPayload>;
|
|
12
|
+
/** Maps payload into provider models. */
|
|
13
|
+
map(payload: TPayload, providerId: Provider): readonly Model<TApi>[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for provider model resolution.
|
|
17
|
+
*/
|
|
18
|
+
export interface ModelManagerOptions<TApi extends Api = Api, TModelsDevPayload = unknown> {
|
|
19
|
+
/** Provider id used for static lookup and cache namespacing. */
|
|
20
|
+
providerId: Provider;
|
|
21
|
+
/** Optional static list override. When omitted, bundled models.json is used. */
|
|
22
|
+
staticModels?: readonly Model<TApi>[];
|
|
23
|
+
/** Optional override for the cache database path. Default: <agent-dir>/models.db. */
|
|
24
|
+
cacheDbPath?: string;
|
|
25
|
+
/** Maximum cache age in milliseconds before considered stale. Default: 24h. */
|
|
26
|
+
cacheTtlMs?: number;
|
|
27
|
+
/** When true, a successful dynamic fetch is the complete provider catalog and prunes static-only models. */
|
|
28
|
+
dynamicModelsAuthoritative?: boolean;
|
|
29
|
+
/** Optional dynamic endpoint fetcher. */
|
|
30
|
+
fetchDynamicModels?: () => Promise<readonly Model<TApi>[] | null>;
|
|
31
|
+
/** Optional models.dev fallback hook. */
|
|
32
|
+
modelsDev?: ModelsDevFallback<TApi, TModelsDevPayload>;
|
|
33
|
+
/** Clock override for deterministic tests. */
|
|
34
|
+
now?: () => number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolution result.
|
|
38
|
+
*
|
|
39
|
+
* `stale` is false when the resolved catalog is authoritative for the selected provider:
|
|
40
|
+
* - dynamic endpoint data was fetched in this call,
|
|
41
|
+
* - a still-fresh authoritative cache was reused in `online-if-uncached` mode, or
|
|
42
|
+
* - the provider has no dynamic fetcher configured.
|
|
43
|
+
*/
|
|
44
|
+
export interface ModelResolutionResult<TApi extends Api = Api> {
|
|
45
|
+
models: Model<TApi>[];
|
|
46
|
+
stale: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Stateful facade over provider model resolution.
|
|
50
|
+
*/
|
|
51
|
+
export interface ModelManager<TApi extends Api = Api> {
|
|
52
|
+
refresh(strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a reusable provider model manager.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createModelManager<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>): ModelManager<TApi>;
|
|
58
|
+
/**
|
|
59
|
+
* Resolves provider models with source precedence:
|
|
60
|
+
* static -> models.dev -> cache -> dynamic.
|
|
61
|
+
*
|
|
62
|
+
* Later sources override earlier ones by model id.
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveProviderModels<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>, strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Api, Model as ApiModel } from "./types";
|
|
2
|
+
/** User-facing thinking levels, ordered least to most intensive. */
|
|
3
|
+
export declare const enum Effort {
|
|
4
|
+
Minimal = "minimal",
|
|
5
|
+
Low = "low",
|
|
6
|
+
Medium = "medium",
|
|
7
|
+
High = "high",
|
|
8
|
+
XHigh = "xhigh"
|
|
9
|
+
}
|
|
10
|
+
export declare const THINKING_EFFORTS: readonly Effort[];
|
|
11
|
+
/**
|
|
12
|
+
* Static fallback model injected when Cloudflare AI Gateway discovery
|
|
13
|
+
* returns no results. Ensures the provider always has at least one usable
|
|
14
|
+
* model entry in the catalog.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CLOUDFLARE_FALLBACK_MODEL: ApiModel<"anthropic-messages">;
|
|
17
|
+
/**
|
|
18
|
+
* Returns a copy of the model with canonical thinking metadata attached.
|
|
19
|
+
*
|
|
20
|
+
* This helper belongs to catalog enrichment only. Runtime consumers should
|
|
21
|
+
* trust `model.thinking` and avoid inferring capabilities on demand.
|
|
22
|
+
*/
|
|
23
|
+
export declare function enrichModelThinking<TApi extends Api>(model: ApiModel<TApi>): ApiModel<TApi>;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a copy of the model with thinking metadata recomputed from the
|
|
26
|
+
* canonical rules, replacing any existing `thinking`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function refreshModelThinking<TApi extends Api>(model: ApiModel<TApi>): ApiModel<TApi>;
|
|
29
|
+
/**
|
|
30
|
+
* Apply upstream metadata corrections to a mutable array of models.
|
|
31
|
+
*
|
|
32
|
+
* Each model is first normalized through `refreshModelThinking()` so generated
|
|
33
|
+
* catalogs keep canonical thinking metadata and policy fixes in one pass.
|
|
34
|
+
*/
|
|
35
|
+
export declare function applyGeneratedModelPolicies(models: ApiModel<Api>[]): void;
|
|
36
|
+
/**
|
|
37
|
+
* Link OpenAI model variants to their context promotion targets.
|
|
38
|
+
*
|
|
39
|
+
* When a model's context is exhausted, the agent can promote to a sibling
|
|
40
|
+
* model with a larger context window on the same provider:
|
|
41
|
+
* - `codex-spark` variants promote to `gpt-5.5`.
|
|
42
|
+
* - `gpt-5.5` (270K input) promotes to `gpt-5.4` (1M input).
|
|
43
|
+
*/
|
|
44
|
+
export declare function linkOpenAIPromotionTargets(models: ApiModel<Api>[]): void;
|
|
45
|
+
/**
|
|
46
|
+
* True when the model reasons natively but rejects the wire `reasoning.effort`
|
|
47
|
+
* param (compat.supportsReasoningEffort: false on openai-responses*). Callers
|
|
48
|
+
* are expected to omit the effort field; the wire-side omitReasoningEffort
|
|
49
|
+
* gate (providers/xai-responses.ts:78) is the actual strip, and this
|
|
50
|
+
* predicate is the upstream check that prevents a redundant
|
|
51
|
+
* requireSupportedEffort throw from defeating that gate.
|
|
52
|
+
*
|
|
53
|
+
* Scoped to openai-responses* because that's the only API surface where
|
|
54
|
+
* `compat.supportsReasoningEffort: false` is meaningful today. The
|
|
55
|
+
* `in`-narrowed access is necessary because Model.compat is
|
|
56
|
+
* `AnthropicCompat | OpenAICompat` and the api gate doesn't narrow the
|
|
57
|
+
* union for TS.
|
|
58
|
+
*/
|
|
59
|
+
export declare function modelOmitsReasoningEffort<TApi extends Api>(model: ApiModel<TApi>): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the supported thinking efforts declared on the model metadata.
|
|
62
|
+
*
|
|
63
|
+
* Catalog enrichment is responsible for normalizing bundled model metadata up front.
|
|
64
|
+
* Runtime callers must treat explicit `model.thinking` on custom models as authoritative
|
|
65
|
+
* so proxy-specific overrides from `models.yml` survive request construction.
|
|
66
|
+
*
|
|
67
|
+
* @throws Error when a reasoning-capable model is missing thinking metadata
|
|
68
|
+
*/
|
|
69
|
+
export declare function getSupportedEfforts<TApi extends Api>(model: ApiModel<TApi>): readonly Effort[];
|
|
70
|
+
/**
|
|
71
|
+
* Clamps a requested thinking level against explicit model metadata.
|
|
72
|
+
*
|
|
73
|
+
* Non-reasoning models always resolve to `undefined`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function clampThinkingLevelForModel<TApi extends Api>(model: ApiModel<TApi> | undefined, requested: Effort | undefined): Effort | undefined;
|
|
76
|
+
export declare function requireSupportedEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): Effort;
|
|
77
|
+
/** Maps a normalized thinking effort to Google's `thinkingLevel` enum values. */
|
|
78
|
+
export declare function mapEffortToGoogleThinkingLevel<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): "MINIMAL" | "LOW" | "MEDIUM" | "HIGH";
|
|
79
|
+
/** Maps a normalized thinking effort to Anthropic adaptive effort values. */
|
|
80
|
+
export declare function mapEffortToAnthropicAdaptiveEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): "low" | "medium" | "high" | "xhigh" | "max";
|
|
81
|
+
/**
|
|
82
|
+
* Returns true for Anthropic models with Opus 4.7 API restrictions:
|
|
83
|
+
* - Sampling parameters (temperature/top_p/top_k) return 400 error
|
|
84
|
+
* - Thinking content is omitted by default (needs display: "summarized")
|
|
85
|
+
*/
|
|
86
|
+
export declare function hasOpus47ApiRestrictions(modelId: string): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Mid-conversation `role: "system"` messages (system instructions appended at
|
|
89
|
+
* non-first positions in the `messages` array) are supported starting with
|
|
90
|
+
* Claude Opus 4.8. Earlier Claude models reject the role.
|
|
91
|
+
* @see https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages
|
|
92
|
+
*/
|
|
93
|
+
export declare function supportsMidConversationSystemMessages(modelId: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Claude Opus 4.8 must emit at most one tool call per turn: the Anthropic
|
|
96
|
+
* Messages provider sends `tool_choice.disable_parallel_tool_use = true` for
|
|
97
|
+
* this model. Scoped to exactly 4.8 — earlier and later Opus versions keep
|
|
98
|
+
* Anthropic's default parallel tool-calling.
|
|
99
|
+
*/
|
|
100
|
+
export declare function disablesParallelToolUse(modelId: string): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import MODELS from "./models.json";
|
|
2
|
+
import type { Api, KnownProvider, Model, Usage } from "./types";
|
|
3
|
+
export type GeneratedProvider = keyof typeof MODELS;
|
|
4
|
+
export declare function getBundledModel<TApi extends Api = Api>(provider: GeneratedProvider, modelId: string): Model<TApi>;
|
|
5
|
+
export declare function getBundledProviders(): KnownProvider[];
|
|
6
|
+
export declare function getBundledModels(provider: GeneratedProvider): Model<Api>[];
|
|
7
|
+
export declare function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage["cost"];
|
|
8
|
+
/**
|
|
9
|
+
* Check if two models are equal by comparing both their id and provider.
|
|
10
|
+
* Returns false if either model is null or undefined.
|
|
11
|
+
*/
|
|
12
|
+
export declare function modelsAreEqual<TApi extends Api>(a: Model<TApi> | null | undefined, b: Model<TApi> | null | undefined): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Api, Model, Provider, ProviderSessionState } from "./types";
|
|
2
|
+
export interface ProviderDetailField {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ProviderDetails {
|
|
7
|
+
provider: Provider;
|
|
8
|
+
api: Api;
|
|
9
|
+
fields: ProviderDetailField[];
|
|
10
|
+
}
|
|
11
|
+
export interface ProviderDetailsContext {
|
|
12
|
+
model: Model<Api>;
|
|
13
|
+
sessionId?: string;
|
|
14
|
+
authMode?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Human-readable description of the active credential, e.g.
|
|
17
|
+
* `"broker http://can.internal:8765 · oauth #5 (foo@bar.com)"`.
|
|
18
|
+
* Rendered as a `Source` field; omitted when undefined.
|
|
19
|
+
*/
|
|
20
|
+
credentialSource?: string;
|
|
21
|
+
preferWebsockets?: boolean;
|
|
22
|
+
providerSessionState?: Map<string, ProviderSessionState>;
|
|
23
|
+
}
|
|
24
|
+
export declare function getProviderDetails(context: ProviderDetailsContext): ProviderDetails;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getBundledModels } from "../models";
|
|
2
|
+
import type { Api, Model } from "../types";
|
|
3
|
+
export declare function createBundledReferenceMap<TApi extends Api>(provider: Parameters<typeof getBundledModels>[0]): Map<string, Model<TApi>>;
|
|
4
|
+
export declare function createReferenceResolver<TApi extends Api>(providerRefs: Map<string, Model<TApi>>): (modelId: string) => Model<TApi> | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified provider descriptors — single source of truth for provider metadata
|
|
3
|
+
* used by both runtime model discovery (model-registry.ts) and catalog
|
|
4
|
+
* generation (generate-models.ts).
|
|
5
|
+
*/
|
|
6
|
+
import type { ModelManagerOptions } from "../model-manager";
|
|
7
|
+
import type { Api, KnownProvider } from "../types";
|
|
8
|
+
import type { OAuthProvider } from "../utils/oauth/types";
|
|
9
|
+
/** Catalog discovery configuration for providers that support endpoint-based model listing. */
|
|
10
|
+
export interface CatalogDiscoveryConfig {
|
|
11
|
+
/** Human-readable name for log messages. */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Environment variables to check for API keys during catalog generation. */
|
|
14
|
+
envVars: string[];
|
|
15
|
+
/** OAuth provider for credential refresh during catalog generation. */
|
|
16
|
+
oauthProvider?: OAuthProvider;
|
|
17
|
+
/** When true, catalog discovery proceeds even without credentials. */
|
|
18
|
+
allowUnauthenticated?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Unified provider descriptor used by both runtime discovery and catalog generation. */
|
|
21
|
+
export interface ProviderDescriptor {
|
|
22
|
+
providerId: KnownProvider;
|
|
23
|
+
createModelManagerOptions(config: {
|
|
24
|
+
apiKey?: string;
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
}): ModelManagerOptions<Api>;
|
|
27
|
+
/** Preferred model ID when no explicit selection is made. */
|
|
28
|
+
defaultModel: string;
|
|
29
|
+
/** When true, the runtime creates a model manager even without a valid API key (e.g. ollama). */
|
|
30
|
+
allowUnauthenticated?: boolean;
|
|
31
|
+
/** When true, successful runtime discovery replaces bundled provider models instead of merging fallback-only IDs. */
|
|
32
|
+
dynamicModelsAuthoritative?: boolean;
|
|
33
|
+
/** Catalog discovery configuration. Only providers with this field participate in generate-models.ts. */
|
|
34
|
+
catalogDiscovery?: CatalogDiscoveryConfig;
|
|
35
|
+
}
|
|
36
|
+
/** A provider descriptor that has catalog discovery configured. */
|
|
37
|
+
export type CatalogProviderDescriptor = ProviderDescriptor & {
|
|
38
|
+
catalogDiscovery: CatalogDiscoveryConfig;
|
|
39
|
+
};
|
|
40
|
+
/** Type guard for descriptors with catalog discovery. */
|
|
41
|
+
export declare function isCatalogDescriptor(d: ProviderDescriptor): d is CatalogProviderDescriptor;
|
|
42
|
+
/** Whether catalog discovery may run without provider credentials. */
|
|
43
|
+
export declare function allowsUnauthenticatedCatalogDiscovery(descriptor: CatalogProviderDescriptor): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* All standard providers. Special providers (google-antigravity, google-gemini-cli,
|
|
46
|
+
* openai-codex) are handled separately because they require different config shapes.
|
|
47
|
+
*/
|
|
48
|
+
export declare const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[];
|
|
49
|
+
/** Default model IDs for all known providers, built from descriptors + special providers. */
|
|
50
|
+
export declare const DEFAULT_MODEL_PER_PROVIDER: Record<KnownProvider, string>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ModelManagerOptions } from "../model-manager";
|
|
2
|
+
import type { FetchImpl } from "../types";
|
|
3
|
+
export interface GoogleModelManagerConfig {
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GoogleVertexModelManagerConfig {
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
project?: string;
|
|
9
|
+
location?: string;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
fetch?: FetchImpl;
|
|
12
|
+
}
|
|
13
|
+
export interface GoogleAntigravityModelManagerConfig {
|
|
14
|
+
oauthToken?: string;
|
|
15
|
+
endpoint?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface GoogleGeminiCliModelManagerConfig {
|
|
18
|
+
oauthToken?: string;
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function googleModelManagerOptions(config?: GoogleModelManagerConfig): ModelManagerOptions<"google-generative-ai">;
|
|
22
|
+
export declare function googleVertexModelManagerOptions(_config?: GoogleVertexModelManagerConfig): ModelManagerOptions;
|
|
23
|
+
export declare function googleAntigravityModelManagerOptions(config?: GoogleAntigravityModelManagerConfig): ModelManagerOptions<"google-gemini-cli">;
|
|
24
|
+
export declare function googleGeminiCliModelManagerOptions(config?: GoogleGeminiCliModelManagerConfig): ModelManagerOptions<"google-gemini-cli">;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ModelManagerOptions } from "../model-manager";
|
|
2
|
+
export interface OllamaCloudModelManagerConfig {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function normalizeOllamaCloudBaseUrl(baseUrl?: string): string;
|
|
7
|
+
export declare function ollamaCloudModelManagerOptions(config?: OllamaCloudModelManagerConfig): ModelManagerOptions<"ollama-chat">;
|