@vib-rato/ai 0.16.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 +3354 -0
- package/README.md +1194 -0
- package/dist/types/adapter-internals/provider-safety-stop.d.ts +45 -0
- package/dist/types/api-registry.d.ts +30 -0
- package/dist/types/auth-broker/client.d.ts +80 -0
- package/dist/types/auth-broker/index.d.ts +5 -0
- package/dist/types/auth-broker/redact.d.ts +7 -0
- package/dist/types/auth-broker/refresher.d.ts +25 -0
- package/dist/types/auth-broker/remote-store.d.ts +153 -0
- package/dist/types/auth-broker/server.d.ts +32 -0
- package/dist/types/auth-broker/types.d.ts +132 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +555 -0
- package/dist/types/auth-gateway/http.d.ts +40 -0
- package/dist/types/auth-gateway/index.d.ts +3 -0
- package/dist/types/auth-gateway/server.d.ts +70 -0
- package/dist/types/auth-gateway/types.d.ts +129 -0
- package/dist/types/auth-storage.d.ts +1074 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/codex-tools.d.ts +4 -0
- package/dist/types/context-cap-policy.d.ts +68 -0
- package/dist/types/core.d.ts +35 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/model-cache.d.ts +24 -0
- package/dist/types/model-manager.d.ts +77 -0
- package/dist/types/model-pricing.d.ts +3 -0
- package/dist/types/model-retirements.d.ts +6 -0
- package/dist/types/model-thinking.d.ts +100 -0
- package/dist/types/models.d.ts +21 -0
- package/dist/types/openai-completions-compat.d.ts +34 -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 +48 -0
- package/dist/types/provider-models/google.d.ts +20 -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 +293 -0
- package/dist/types/provider-models/special.d.ts +29 -0
- package/dist/types/providers/amazon-bedrock.d.ts +60 -0
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +450 -0
- package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
- package/dist/types/providers/anthropic.d.ts +280 -0
- package/dist/types/providers/aws-credential-config.d.ts +19 -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 +22 -0
- package/dist/types/providers/composer-discipline.d.ts +32 -0
- package/dist/types/providers/cursor/client-version.d.ts +10 -0
- package/dist/types/providers/cursor/exec-modern.d.ts +98 -0
- package/dist/types/providers/cursor/gen/agent_pb.d.ts +16769 -0
- package/dist/types/providers/cursor-pi-args.d.ts +119 -0
- package/dist/types/providers/cursor.d.ts +72 -0
- package/dist/types/providers/dashscope-token-plan-headers.d.ts +57 -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 +26 -0
- package/dist/types/providers/google-gemini-cli.d.ts +75 -0
- package/dist/types/providers/google-gemini-headers.d.ts +43 -0
- package/dist/types/providers/google-shared.d.ts +183 -0
- package/dist/types/providers/google-types.d.ts +138 -0
- package/dist/types/providers/google-vertex.d.ts +11 -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/kiro-api-key.d.ts +50 -0
- package/dist/types/providers/kiro-codewhisperer.d.ts +11 -0
- package/dist/types/providers/mock.d.ts +189 -0
- package/dist/types/providers/ollama.d.ts +41 -0
- package/dist/types/providers/openai-anthropic-shim.d.ts +31 -0
- package/dist/types/providers/openai-bounded-rate-limits.d.ts +3 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +1733 -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 +50 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +18 -0
- package/dist/types/providers/openai-codex-responses.d.ts +71 -0
- package/dist/types/providers/openai-completions-compat.d.ts +6 -0
- package/dist/types/providers/openai-completions.d.ts +35 -0
- package/dist/types/providers/openai-opencodex-responses.d.ts +10 -0
- package/dist/types/providers/openai-request-transform.d.ts +4 -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 +106 -0
- package/dist/types/providers/openai-responses.d.ts +37 -0
- package/dist/types/providers/pi-native-client.d.ts +29 -0
- package/dist/types/providers/pi-native-server.d.ts +60 -0
- package/dist/types/providers/register-builtins.d.ts +59 -0
- package/dist/types/providers/synthetic.d.ts +26 -0
- package/dist/types/providers/transform-messages.d.ts +33 -0
- package/dist/types/providers/vision-guard.d.ts +8 -0
- package/dist/types/rate-limit-utils.d.ts +19 -0
- package/dist/types/stream.d.ts +45 -0
- package/dist/types/types.d.ts +1073 -0
- package/dist/types/usage/claude.d.ts +3 -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/grok-cli.d.ts +17 -0
- package/dist/types/usage/kimi.d.ts +4 -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 +264 -0
- package/dist/types/utils/abort.d.ts +19 -0
- package/dist/types/utils/anthropic-auth.d.ts +39 -0
- package/dist/types/utils/block-symbols.d.ts +6 -0
- package/dist/types/utils/discovery/antigravity.d.ts +67 -0
- package/dist/types/utils/discovery/codex.d.ts +38 -0
- package/dist/types/utils/discovery/cursor.d.ts +49 -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 +81 -0
- package/dist/types/utils/event-stream.d.ts +41 -0
- package/dist/types/utils/fallback-transport.d.ts +110 -0
- package/dist/types/utils/fireworks-model-id.d.ts +10 -0
- package/dist/types/utils/foundry.d.ts +11 -0
- package/dist/types/utils/h2-fetch.d.ts +22 -0
- package/dist/types/utils/http-inspector.d.ts +59 -0
- package/dist/types/utils/idle-iterator.d.ts +122 -0
- package/dist/types/utils/json-parse.d.ts +98 -0
- package/dist/types/utils/oauth/alibaba-token-plan.d.ts +19 -0
- package/dist/types/utils/oauth/anthropic.d.ts +41 -0
- package/dist/types/utils/oauth/api-key-login.d.ts +38 -0
- package/dist/types/utils/oauth/api-key-validation.d.ts +39 -0
- package/dist/types/utils/oauth/bizrouter.d.ts +1 -0
- package/dist/types/utils/oauth/callback-server.d.ts +80 -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/commandcode.d.ts +1 -0
- package/dist/types/utils/oauth/cursor.d.ts +15 -0
- package/dist/types/utils/oauth/deepinfra.d.ts +1 -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/fugu.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/glm-zcode.d.ts +71 -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 +39 -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 +17 -0
- package/dist/types/utils/oauth/kiro.d.ts +71 -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/mara.d.ts +1 -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/opengateway.d.ts +1 -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 +4 -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/sglang.d.ts +16 -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 +56 -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/xai.d.ts +30 -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/overflow.d.ts +14 -0
- package/dist/types/utils/parse-bind.d.ts +26 -0
- package/dist/types/utils/provider-response.d.ts +6 -0
- package/dist/types/utils/provider-safety-stop.d.ts +8 -0
- package/dist/types/utils/proxy.d.ts +7 -0
- package/dist/types/utils/retry-after.d.ts +3 -0
- package/dist/types/utils/retry-budget.d.ts +1 -0
- package/dist/types/utils/retry.d.ts +29 -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 +14 -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/root-combinator.d.ts +12 -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 +54 -0
- package/dist/types/utils/schema/zod-decontaminate.d.ts +31 -0
- package/dist/types/utils/sse-debug.d.ts +10 -0
- package/dist/types/utils/tool-call-healing.d.ts +80 -0
- package/dist/types/utils/tool-choice-capability.d.ts +57 -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 +117 -0
- package/package.json +152 -0
- package/src/adapter-internals/provider-safety-stop.d.ts +45 -0
- package/src/adapter-internals/provider-safety-stop.ts +156 -0
- package/src/api-registry.d.ts +30 -0
- package/src/api-registry.ts +96 -0
- package/src/auth-broker/client.ts +444 -0
- package/src/auth-broker/index.ts +5 -0
- package/src/auth-broker/redact.ts +39 -0
- package/src/auth-broker/refresher.ts +130 -0
- package/src/auth-broker/remote-store.ts +1576 -0
- package/src/auth-broker/server.ts +764 -0
- package/src/auth-broker/types.ts +164 -0
- package/src/auth-broker/wire-schemas.ts +261 -0
- package/src/auth-gateway/http.ts +198 -0
- package/src/auth-gateway/index.ts +3 -0
- package/src/auth-gateway/server.ts +1315 -0
- package/src/auth-gateway/types.ts +160 -0
- package/src/auth-storage.ts +7312 -0
- package/src/cli.ts +269 -0
- package/src/codex-tools.d.ts +4 -0
- package/src/codex-tools.ts +24 -0
- package/src/context-cap-policy.d.ts +68 -0
- package/src/context-cap-policy.ts +123 -0
- package/src/core.ts +44 -0
- package/src/index.ts +61 -0
- package/src/model-cache.ts +236 -0
- package/src/model-manager.ts +744 -0
- package/src/model-pricing.d.ts +3 -0
- package/src/model-pricing.ts +68 -0
- package/src/model-retirements.d.ts +6 -0
- package/src/model-retirements.ts +19 -0
- package/src/model-thinking.d.ts +100 -0
- package/src/model-thinking.ts +1054 -0
- package/src/models.d.ts +21 -0
- package/src/models.json +94672 -0
- package/src/models.json.d.ts +9 -0
- package/src/models.ts +126 -0
- package/src/openai-completions-compat.d.ts +34 -0
- package/src/openai-completions-compat.ts +383 -0
- package/src/prompts/composer-bash-policy-recovery.md +1 -0
- package/src/prompts/cursor-composer-bash-policy-recovery.md +1 -0
- package/src/prompts/cursor-composer-edit-discipline.md +7 -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 +392 -0
- package/src/provider-models/google.ts +92 -0
- package/src/provider-models/index.ts +5 -0
- package/src/provider-models/ollama.ts +159 -0
- package/src/provider-models/openai-compat.ts +2920 -0
- package/src/provider-models/special.ts +185 -0
- package/src/providers/amazon-bedrock.d.ts +60 -0
- package/src/providers/amazon-bedrock.ts +939 -0
- package/src/providers/anthropic-messages-server-schema.ts +229 -0
- package/src/providers/anthropic-messages-server.ts +839 -0
- package/src/providers/anthropic.d.ts +280 -0
- package/src/providers/anthropic.ts +4421 -0
- package/src/providers/aws-credential-config.d.ts +19 -0
- package/src/providers/aws-credential-config.ts +179 -0
- package/src/providers/aws-credentials.d.ts +43 -0
- package/src/providers/aws-credentials.ts +457 -0
- package/src/providers/aws-eventstream.d.ts +38 -0
- package/src/providers/aws-eventstream.ts +185 -0
- package/src/providers/aws-sigv4.d.ts +55 -0
- package/src/providers/aws-sigv4.ts +218 -0
- package/src/providers/azure-openai-responses.d.ts +22 -0
- package/src/providers/azure-openai-responses.ts +447 -0
- package/src/providers/composer-discipline.d.ts +32 -0
- package/src/providers/composer-discipline.ts +95 -0
- package/src/providers/cursor/client-version.d.ts +10 -0
- package/src/providers/cursor/client-version.ts +10 -0
- package/src/providers/cursor/exec-modern.d.ts +98 -0
- package/src/providers/cursor/exec-modern.ts +497 -0
- package/src/providers/cursor/gen/agent_pb.d.ts +16769 -0
- package/src/providers/cursor/gen/agent_pb.ts +19780 -0
- package/src/providers/cursor/proto/agent.proto +4533 -0
- package/src/providers/cursor/proto/buf.gen.yaml +6 -0
- package/src/providers/cursor/proto/buf.yaml +17 -0
- package/src/providers/cursor-pi-args.d.ts +119 -0
- package/src/providers/cursor-pi-args.ts +187 -0
- package/src/providers/cursor.d.ts +72 -0
- package/src/providers/cursor.ts +3396 -0
- package/src/providers/dashscope-token-plan-headers.d.ts +57 -0
- package/src/providers/dashscope-token-plan-headers.ts +84 -0
- package/src/providers/error-message.d.ts +27 -0
- package/src/providers/error-message.ts +21 -0
- package/src/providers/github-copilot-headers.d.ts +40 -0
- package/src/providers/github-copilot-headers.ts +140 -0
- package/src/providers/gitlab-duo.d.ts +27 -0
- package/src/providers/gitlab-duo.ts +393 -0
- package/src/providers/google-auth.d.ts +26 -0
- package/src/providers/google-auth.ts +262 -0
- package/src/providers/google-gemini-cli.d.ts +75 -0
- package/src/providers/google-gemini-cli.ts +969 -0
- package/src/providers/google-gemini-headers.d.ts +43 -0
- package/src/providers/google-gemini-headers.ts +100 -0
- package/src/providers/google-shared.d.ts +183 -0
- package/src/providers/google-shared.ts +1105 -0
- package/src/providers/google-types.d.ts +138 -0
- package/src/providers/google-types.ts +167 -0
- package/src/providers/google-vertex.d.ts +11 -0
- package/src/providers/google-vertex.ts +124 -0
- package/src/providers/google.d.ts +4 -0
- package/src/providers/google.ts +41 -0
- package/src/providers/grammar.d.ts +1 -0
- package/src/providers/grammar.ts +70 -0
- package/src/providers/kimi.d.ts +27 -0
- package/src/providers/kimi.ts +52 -0
- package/src/providers/kiro-api-key.d.ts +50 -0
- package/src/providers/kiro-api-key.ts +786 -0
- package/src/providers/kiro-codewhisperer.d.ts +11 -0
- package/src/providers/kiro-codewhisperer.ts +600 -0
- package/src/providers/mock.ts +526 -0
- package/src/providers/ollama.d.ts +41 -0
- package/src/providers/ollama.ts +645 -0
- package/src/providers/openai-anthropic-shim.d.ts +31 -0
- package/src/providers/openai-anthropic-shim.ts +156 -0
- package/src/providers/openai-bounded-rate-limits.d.ts +3 -0
- package/src/providers/openai-bounded-rate-limits.ts +57 -0
- package/src/providers/openai-chat-server-schema.ts +254 -0
- package/src/providers/openai-chat-server.ts +724 -0
- package/src/providers/openai-codex/constants.d.ts +26 -0
- package/src/providers/openai-codex/constants.ts +43 -0
- package/src/providers/openai-codex/request-transformer.d.ts +50 -0
- package/src/providers/openai-codex/request-transformer.ts +219 -0
- package/src/providers/openai-codex/response-handler.d.ts +18 -0
- package/src/providers/openai-codex/response-handler.ts +111 -0
- package/src/providers/openai-codex-responses.d.ts +71 -0
- package/src/providers/openai-codex-responses.ts +3288 -0
- package/src/providers/openai-completions-compat.d.ts +6 -0
- package/src/providers/openai-completions-compat.ts +6 -0
- package/src/providers/openai-completions.d.ts +35 -0
- package/src/providers/openai-completions.ts +2294 -0
- package/src/providers/openai-opencodex-responses.ts +174 -0
- package/src/providers/openai-request-transform.d.ts +4 -0
- package/src/providers/openai-request-transform.ts +136 -0
- package/src/providers/openai-responses-server-schema.ts +290 -0
- package/src/providers/openai-responses-server.ts +1268 -0
- package/src/providers/openai-responses-shared.d.ts +106 -0
- package/src/providers/openai-responses-shared.ts +1253 -0
- package/src/providers/openai-responses.d.ts +37 -0
- package/src/providers/openai-responses.ts +989 -0
- package/src/providers/pi-native-client.d.ts +29 -0
- package/src/providers/pi-native-client.ts +243 -0
- package/src/providers/pi-native-server.ts +488 -0
- package/src/providers/register-builtins.d.ts +59 -0
- package/src/providers/register-builtins.ts +544 -0
- package/src/providers/synthetic.d.ts +26 -0
- package/src/providers/synthetic.ts +50 -0
- package/src/providers/transform-messages.d.ts +33 -0
- package/src/providers/transform-messages.ts +408 -0
- package/src/providers/vision-guard.d.ts +8 -0
- package/src/providers/vision-guard.ts +31 -0
- package/src/rate-limit-utils.d.ts +19 -0
- package/src/rate-limit-utils.ts +102 -0
- package/src/stream.d.ts +45 -0
- package/src/stream.ts +1306 -0
- package/src/types.d.ts +1073 -0
- package/src/types.ts +1305 -0
- package/src/usage/claude.ts +449 -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/grok-cli.ts +259 -0
- package/src/usage/kimi.ts +285 -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 +190 -0
- package/src/utils/abort.d.ts +19 -0
- package/src/utils/abort.ts +51 -0
- package/src/utils/anthropic-auth.ts +95 -0
- package/src/utils/block-symbols.d.ts +6 -0
- package/src/utils/block-symbols.ts +11 -0
- package/src/utils/discovery/antigravity.ts +275 -0
- package/src/utils/discovery/codex.ts +362 -0
- package/src/utils/discovery/cursor.ts +388 -0
- package/src/utils/discovery/gemini.ts +248 -0
- package/src/utils/discovery/index.ts +4 -0
- package/src/utils/discovery/openai-compatible.ts +379 -0
- package/src/utils/event-stream.d.ts +41 -0
- package/src/utils/event-stream.ts +269 -0
- package/src/utils/fallback-transport.d.ts +110 -0
- package/src/utils/fallback-transport.ts +411 -0
- package/src/utils/fireworks-model-id.d.ts +10 -0
- package/src/utils/fireworks-model-id.ts +30 -0
- package/src/utils/foundry.d.ts +11 -0
- package/src/utils/foundry.ts +18 -0
- package/src/utils/h2-fetch.ts +60 -0
- package/src/utils/http-inspector.d.ts +59 -0
- package/src/utils/http-inspector.ts +380 -0
- package/src/utils/idle-iterator.d.ts +122 -0
- package/src/utils/idle-iterator.ts +410 -0
- package/src/utils/json-parse.d.ts +98 -0
- package/src/utils/json-parse.ts +607 -0
- package/src/utils/oauth/alibaba-token-plan.ts +60 -0
- package/src/utils/oauth/anthropic.ts +233 -0
- package/src/utils/oauth/api-key-login.ts +98 -0
- package/src/utils/oauth/api-key-validation.ts +344 -0
- package/src/utils/oauth/bizrouter.ts +15 -0
- package/src/utils/oauth/callback-server.d.ts +80 -0
- package/src/utils/oauth/callback-server.ts +359 -0
- package/src/utils/oauth/cerebras.ts +16 -0
- package/src/utils/oauth/cloudflare-ai-gateway.ts +48 -0
- package/src/utils/oauth/commandcode.ts +17 -0
- package/src/utils/oauth/cursor.ts +157 -0
- package/src/utils/oauth/deepinfra.ts +15 -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/fugu.ts +15 -0
- package/src/utils/oauth/github-copilot.d.ts +38 -0
- package/src/utils/oauth/github-copilot.ts +362 -0
- package/src/utils/oauth/gitlab-duo.ts +123 -0
- package/src/utils/oauth/glm-zcode.d.ts +71 -0
- package/src/utils/oauth/glm-zcode.ts +433 -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 +558 -0
- package/src/utils/oauth/kagi.ts +47 -0
- package/src/utils/oauth/kilo.ts +87 -0
- package/src/utils/oauth/kimi.d.ts +17 -0
- package/src/utils/oauth/kimi.ts +275 -0
- package/src/utils/oauth/kiro.ts +448 -0
- package/src/utils/oauth/litellm.ts +47 -0
- package/src/utils/oauth/lm-studio.ts +38 -0
- package/src/utils/oauth/mara.ts +16 -0
- package/src/utils/oauth/minimax-code.ts +78 -0
- package/src/utils/oauth/moonshot.ts +16 -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/opengateway.ts +15 -0
- package/src/utils/oauth/openrouter.ts +16 -0
- package/src/utils/oauth/parallel.ts +46 -0
- package/src/utils/oauth/perplexity.ts +225 -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/sglang.ts +42 -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.d.ts +56 -0
- package/src/utils/oauth/types.ts +122 -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 +42 -0
- package/src/utils/oauth/xai.ts +246 -0
- package/src/utils/oauth/xiaomi.ts +199 -0
- package/src/utils/oauth/zai.ts +60 -0
- package/src/utils/oauth/zenmux.ts +15 -0
- package/src/utils/overflow.ts +275 -0
- package/src/utils/parse-bind.ts +81 -0
- package/src/utils/provider-response.d.ts +6 -0
- package/src/utils/provider-response.ts +30 -0
- package/src/utils/provider-safety-stop.ts +8 -0
- package/src/utils/proxy.d.ts +7 -0
- package/src/utils/proxy.ts +652 -0
- package/src/utils/retry-after.d.ts +3 -0
- package/src/utils/retry-after.ts +110 -0
- package/src/utils/retry-budget.d.ts +1 -0
- package/src/utils/retry-budget.ts +4 -0
- package/src/utils/retry.d.ts +29 -0
- package/src/utils/retry.ts +67 -0
- package/src/utils/schema/CONSTRAINTS.md +164 -0
- package/src/utils/schema/adapt.d.ts +24 -0
- package/src/utils/schema/adapt.ts +36 -0
- package/src/utils/schema/compatibility.d.ts +30 -0
- package/src/utils/schema/compatibility.ts +435 -0
- package/src/utils/schema/dereference.d.ts +11 -0
- package/src/utils/schema/dereference.ts +98 -0
- package/src/utils/schema/draft.d.ts +10 -0
- package/src/utils/schema/draft.ts +341 -0
- package/src/utils/schema/equality.d.ts +4 -0
- package/src/utils/schema/equality.ts +97 -0
- package/src/utils/schema/fields.d.ts +49 -0
- package/src/utils/schema/fields.ts +190 -0
- package/src/utils/schema/index.d.ts +14 -0
- package/src/utils/schema/index.ts +14 -0
- package/src/utils/schema/json-schema-validator.d.ts +12 -0
- package/src/utils/schema/json-schema-validator.ts +577 -0
- package/src/utils/schema/meta-validator.d.ts +2 -0
- package/src/utils/schema/meta-validator.ts +167 -0
- package/src/utils/schema/normalize.d.ts +93 -0
- package/src/utils/schema/normalize.ts +1588 -0
- package/src/utils/schema/root-combinator.d.ts +12 -0
- package/src/utils/schema/root-combinator.ts +143 -0
- package/src/utils/schema/spill.d.ts +8 -0
- package/src/utils/schema/spill.ts +43 -0
- package/src/utils/schema/stamps.d.ts +25 -0
- package/src/utils/schema/stamps.ts +97 -0
- package/src/utils/schema/types.d.ts +4 -0
- package/src/utils/schema/types.ts +11 -0
- package/src/utils/schema/wire.d.ts +54 -0
- package/src/utils/schema/wire.ts +213 -0
- package/src/utils/schema/zod-decontaminate.d.ts +31 -0
- package/src/utils/schema/zod-decontaminate.ts +331 -0
- package/src/utils/sse-debug.d.ts +10 -0
- package/src/utils/sse-debug.ts +289 -0
- package/src/utils/tool-call-healing.d.ts +80 -0
- package/src/utils/tool-call-healing.ts +298 -0
- package/src/utils/tool-choice-capability.d.ts +57 -0
- package/src/utils/tool-choice-capability.ts +633 -0
- package/src/utils/tool-choice.d.ts +50 -0
- package/src/utils/tool-choice.ts +99 -0
- package/src/utils/validation.ts +1080 -0
- package/src/utils.d.ts +117 -0
- package/src/utils.ts +523 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Maps a canonical tool name to the name Codex accepts on the wire. */
|
|
2
|
+
export declare function codexToolWireName(name: string): string;
|
|
3
|
+
/** Maps a Codex wire tool name back to the canonical harness tool name. */
|
|
4
|
+
export declare function codexToolCanonicalName(wireName: string): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Api, Model } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Codex GPT-5.6 OAuth context-window policy.
|
|
4
|
+
*
|
|
5
|
+
* Authoritative source and ownership path
|
|
6
|
+
* ---------------------------------------
|
|
7
|
+
* The authenticated Codex backend discovery endpoint (`GET {base}/codex/models`
|
|
8
|
+
* with an OAuth bearer token) is the authoritative runtime source of Codex OAuth
|
|
9
|
+
* model context-window metadata (`models[].context_window`). OpenAI owns that
|
|
10
|
+
* value; Vibrato consumes it read-only via `fetchCodexModels` and must not silently
|
|
11
|
+
* invent a larger limit without upstream evidence.
|
|
12
|
+
*
|
|
13
|
+
* This bundled policy is a client-side conservative guard, not a primary source.
|
|
14
|
+
* It exists because OpenAI temporarily reverted the GPT-5.6 Sol product context
|
|
15
|
+
* limit from 372K to 272K on 2026-07-13 (staff announcement quoted in
|
|
16
|
+
* vib-rato issues #2240 / #2260), while planning to restore 372K later.
|
|
17
|
+
* `ceiling` must only be raised with an upstream evidence citation; an
|
|
18
|
+
* unverified report that "372K is live again" is not sufficient.
|
|
19
|
+
*
|
|
20
|
+
* Precedence (highest -> lowest)
|
|
21
|
+
* ------------------------------
|
|
22
|
+
* 1. Explicit user per-model override (`contextWindow` in `modelOverrides`).
|
|
23
|
+
* The model registry merges it into `model.contextWindow` before this cap and
|
|
24
|
+
* passes it here; it is honored when a positive finite number, with
|
|
25
|
+
* diagnostics emitted at the registry. Never silently discarded.
|
|
26
|
+
* 2. Live OAuth discovery metadata (`context_window`), forced to the enforced
|
|
27
|
+
* product window for the GPT-5.6 tier.
|
|
28
|
+
* 3. Bundled conservative generic window (`CODEX_GENERIC_CONTEXT_WINDOW`),
|
|
29
|
+
* used when discovery metadata is absent or invalid.
|
|
30
|
+
*/
|
|
31
|
+
export interface CodexGpt56ContextCapPolicy {
|
|
32
|
+
/**
|
|
33
|
+
* Usable prompt budget forced for the GPT-5.6 tier on the Codex product
|
|
34
|
+
* transport. The live OpenAI code backend metadata still reports the old
|
|
35
|
+
* 272K budget (or the total-window figure), so this is an explicit product
|
|
36
|
+
* override: the tier is forced to the enforced window regardless of what
|
|
37
|
+
* discovery reports.
|
|
38
|
+
*/
|
|
39
|
+
enforced: number;
|
|
40
|
+
}
|
|
41
|
+
export declare const CODEX_GPT_5_6_CONTEXT_CAP: CodexGpt56ContextCapPolicy;
|
|
42
|
+
/**
|
|
43
|
+
* Generic usable prompt budget for OpenAI code backend models outside the
|
|
44
|
+
* GPT-5.6 tier (e.g. gpt-5.5, gpt-5.4-codex, gpt-5.6-codex). Kept separate from
|
|
45
|
+
* {@link CODEX_GPT_5_6_CONTEXT_CAP} so the forced 5.6-tier window never leaks
|
|
46
|
+
* into unrelated Codex discovery rows.
|
|
47
|
+
*/
|
|
48
|
+
export declare const CODEX_GENERIC_CONTEXT_WINDOW = 272000;
|
|
49
|
+
export declare function isCodexProductTransport(model: Pick<Model<Api>, "api" | "provider">): boolean;
|
|
50
|
+
export declare function isCodexGpt56Tier(model: Pick<Model<Api>, "id">): boolean;
|
|
51
|
+
export declare function codexContextOverrideKey(provider: string, modelId: string): string;
|
|
52
|
+
export declare function resolveCodexGpt56DiscoveryContext(model: Pick<Model<Api>, "api" | "id" | "provider">, rawContextWindow: unknown, policy?: CodexGpt56ContextCapPolicy): number;
|
|
53
|
+
/**
|
|
54
|
+
* Applies the final Codex GPT-5.6 context ceiling, honoring explicit user
|
|
55
|
+
* overrides.
|
|
56
|
+
*
|
|
57
|
+
* `userContextWindowOverrides` maps provider-qualified composite keys
|
|
58
|
+
* (`provider:modelId`, both lowercased, built by
|
|
59
|
+
* {@link codexContextOverrideKey}) to the user's explicit `contextWindow` value
|
|
60
|
+
* (already merged into `model.contextWindow` by the model registry). A tier
|
|
61
|
+
* model present with a positive finite value keeps its value even above
|
|
62
|
+
* `enforced` — the user's explicit, diagnosed choice. Every other tier
|
|
63
|
+
* model is forced to `enforced`, so a stale larger live/cached observation
|
|
64
|
+
* (e.g. a pre-rollback 373K cache) cannot resurface without an override.
|
|
65
|
+
* Because the key is provider-qualified, an override only exempts the exact
|
|
66
|
+
* provider+model pair it was configured for.
|
|
67
|
+
*/
|
|
68
|
+
export declare function applyFinalCodexGpt56ContextCap<TApi extends Api>(models: readonly Model<TApi>[], policy?: CodexGpt56ContextCapPolicy, userContextWindowOverrides?: ReadonlyMap<string, number>): Model<TApi>[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight public AI runtime surface.
|
|
3
|
+
*
|
|
4
|
+
* This entrypoint intentionally exports core types, schemas, model metadata,
|
|
5
|
+
* stream dispatch, and lazy provider descriptors only. Concrete provider
|
|
6
|
+
* implementations stay behind `register-builtins` loaders and are not
|
|
7
|
+
* re-exported here.
|
|
8
|
+
*/
|
|
9
|
+
export { type ZodType, z } from "zod/v4";
|
|
10
|
+
export * from "./api-registry";
|
|
11
|
+
export * from "./auth-broker";
|
|
12
|
+
export * from "./auth-gateway/types";
|
|
13
|
+
export * from "./auth-storage";
|
|
14
|
+
export * from "./codex-tools";
|
|
15
|
+
export * from "./context-cap-policy";
|
|
16
|
+
export * from "./model-cache";
|
|
17
|
+
export * from "./model-manager";
|
|
18
|
+
export * from "./model-thinking";
|
|
19
|
+
export * from "./models";
|
|
20
|
+
export * from "./provider-models";
|
|
21
|
+
export { getProviderRuntimeDescriptor, PROVIDER_RUNTIME_DESCRIPTORS, type ProviderRuntimeDescriptor, } from "./providers/register-builtins";
|
|
22
|
+
export { hasAdjacentPrivateThinkingBlocks } from "./providers/transform-messages";
|
|
23
|
+
export * from "./rate-limit-utils";
|
|
24
|
+
export * from "./stream";
|
|
25
|
+
export * from "./types";
|
|
26
|
+
export * from "./usage";
|
|
27
|
+
export * from "./utils/event-stream";
|
|
28
|
+
export * from "./utils/fallback-transport";
|
|
29
|
+
export * from "./utils/oauth";
|
|
30
|
+
export type { OAuthCredentials, OAuthProvider, OAuthProviderId, OAuthProviderInfo, } from "./utils/oauth/types";
|
|
31
|
+
export * from "./utils/overflow";
|
|
32
|
+
export * from "./utils/retry";
|
|
33
|
+
export * from "./utils/schema";
|
|
34
|
+
export * from "./utils/tool-choice-capability";
|
|
35
|
+
export * from "./utils/validation";
|
|
@@ -0,0 +1,55 @@
|
|
|
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 "./context-cap-policy";
|
|
8
|
+
export * from "./model-cache";
|
|
9
|
+
export * from "./model-manager";
|
|
10
|
+
export * from "./model-thinking";
|
|
11
|
+
export * from "./models";
|
|
12
|
+
export * from "./provider-details";
|
|
13
|
+
export * from "./provider-models";
|
|
14
|
+
export * from "./providers/anthropic";
|
|
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-opencodex-responses";
|
|
28
|
+
export * from "./providers/openai-responses";
|
|
29
|
+
export * from "./providers/synthetic";
|
|
30
|
+
export * from "./rate-limit-utils";
|
|
31
|
+
export * from "./stream";
|
|
32
|
+
export * from "./types";
|
|
33
|
+
export * from "./usage";
|
|
34
|
+
export * from "./usage/claude";
|
|
35
|
+
export * from "./usage/gemini";
|
|
36
|
+
export * from "./usage/github-copilot";
|
|
37
|
+
export * from "./usage/google-antigravity";
|
|
38
|
+
export * from "./usage/grok-cli";
|
|
39
|
+
export * from "./usage/kimi";
|
|
40
|
+
export * from "./usage/minimax-code";
|
|
41
|
+
export * from "./usage/openai-codex";
|
|
42
|
+
export * from "./usage/zai";
|
|
43
|
+
export * from "./utils/anthropic-auth";
|
|
44
|
+
export * from "./utils/discovery";
|
|
45
|
+
export * from "./utils/event-stream";
|
|
46
|
+
export * from "./utils/fallback-transport";
|
|
47
|
+
export * from "./utils/h2-fetch";
|
|
48
|
+
export * from "./utils/oauth";
|
|
49
|
+
export type { OAuthCredentials, OAuthLoginOptions, OAuthProvider, OAuthProviderId, OAuthProviderInfo, } from "./utils/oauth/types";
|
|
50
|
+
export * from "./utils/overflow";
|
|
51
|
+
export * from "./utils/provider-safety-stop";
|
|
52
|
+
export * from "./utils/retry";
|
|
53
|
+
export * from "./utils/schema";
|
|
54
|
+
export * from "./utils/tool-choice-capability";
|
|
55
|
+
export * from "./utils/validation";
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
/** IDs returned by the authoritative dynamic provider catalog, when retained. */
|
|
15
|
+
dynamicModelIds: string[] | undefined;
|
|
16
|
+
dynamicModelProvenance: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** Close the shared cache only when it owns the exact requested database path. */
|
|
19
|
+
export declare function closeModelCache(dbPath?: string): boolean;
|
|
20
|
+
export declare function readModelCache<TApi extends Api>(providerId: string, ttlMs: number, now: () => number, dbPath?: string): CacheEntry<TApi> | null;
|
|
21
|
+
export declare function writeModelCache<TApi extends Api>(providerId: string, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, dynamicModelIds?: readonly string[], dynamicModelProvenance?: string): void;
|
|
22
|
+
export declare function insertModelCacheIfAbsent<TApi extends Api>(providerId: string, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, dynamicModelIds?: readonly string[], dynamicModelProvenance?: string): boolean;
|
|
23
|
+
export declare function updateModelCacheIfUnchanged<TApi extends Api>(providerId: string, expectedUpdatedAt: number, expectedDynamicModelIds: readonly string[] | undefined, expectedDynamicModelProvenance: string | undefined, expectedModels: readonly Model<TApi>[], updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, dynamicModelIds?: readonly string[], dynamicModelProvenance?: string): boolean;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
/** Optional dynamic endpoint fetcher. */
|
|
28
|
+
fetchDynamicModels?: () => Promise<readonly Model<TApi>[] | null>;
|
|
29
|
+
/** Optional models.dev fallback hook. */
|
|
30
|
+
modelsDev?: ModelsDevFallback<TApi, TModelsDevPayload>;
|
|
31
|
+
/** Clock override for deterministic tests. */
|
|
32
|
+
now?: () => number;
|
|
33
|
+
/** Optional guard that must permit cache publication. Default: writes are permitted. */
|
|
34
|
+
canPublishCache?: () => boolean;
|
|
35
|
+
/** Credential-and-endpoint identity required to reuse dynamic catalog IDs. */
|
|
36
|
+
cacheDynamicModelProvenance?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolution result.
|
|
40
|
+
*
|
|
41
|
+
* `stale` is false when the resolved catalog is authoritative for the selected provider:
|
|
42
|
+
* - dynamic endpoint data was fetched in this call,
|
|
43
|
+
* - a still-fresh authoritative cache was reused in `online-if-uncached` mode, or
|
|
44
|
+
* - the provider has no dynamic fetcher configured.
|
|
45
|
+
*/
|
|
46
|
+
export interface ModelResolutionResult<TApi extends Api = Api> {
|
|
47
|
+
models: Model<TApi>[];
|
|
48
|
+
stale: boolean;
|
|
49
|
+
/** Whether the cache row consulted for this resolution was still within its TTL. */
|
|
50
|
+
cacheFresh: boolean;
|
|
51
|
+
/** Whether the consulted cache row was authoritative. */
|
|
52
|
+
cacheAuthoritative: boolean;
|
|
53
|
+
/** Whether this resolution successfully fetched dynamic models. */
|
|
54
|
+
fetched: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* IDs returned by a current authoritative dynamic provider catalog. This is
|
|
57
|
+
* deliberately distinct from `models`, which merges static and cached data.
|
|
58
|
+
*/
|
|
59
|
+
dynamicModelIds?: readonly string[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Stateful facade over provider model resolution.
|
|
63
|
+
*/
|
|
64
|
+
export interface ModelManager<TApi extends Api = Api> {
|
|
65
|
+
refresh(strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a reusable provider model manager.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createModelManager<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>): ModelManager<TApi>;
|
|
71
|
+
/**
|
|
72
|
+
* Resolves provider models with source precedence:
|
|
73
|
+
* static -> models.dev -> cache -> dynamic.
|
|
74
|
+
*
|
|
75
|
+
* Later sources override earlier ones by model id.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveProviderModels<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>, strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Api, Model, ModelCost } from "./types";
|
|
2
|
+
export declare function getOpenAIModelCost<TApi extends Api>(model: Model<TApi>, inputTokens: number): ModelCost | undefined;
|
|
3
|
+
export declare function applyOpenAIModelPricing<TApi extends Api>(model: Model<TApi>): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const RETIRED_MODEL_KEYS: readonly ["google-antigravity/gemini-3.1-pro-high", "google-antigravity/gemini-3.7-flash-high", "google-antigravity/gemini-3.7-flash-low", "google-antigravity/gemini-3.7-flash-medium"];
|
|
2
|
+
export declare function isRetiredModelKey(provider: string, modelId: string): boolean;
|
|
3
|
+
export declare function isRetiredModel(model: {
|
|
4
|
+
provider: string;
|
|
5
|
+
id: string;
|
|
6
|
+
}): boolean;
|
|
@@ -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
|
+
Max = "max"
|
|
10
|
+
}
|
|
11
|
+
export declare const THINKING_EFFORTS: readonly Effort[];
|
|
12
|
+
/**
|
|
13
|
+
* Static fallback model injected when Cloudflare AI Gateway discovery
|
|
14
|
+
* returns no results. Ensures the provider always has at least one usable
|
|
15
|
+
* model entry in the catalog.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CLOUDFLARE_FALLBACK_MODEL: ApiModel<"anthropic-messages">;
|
|
18
|
+
export declare function isGroqCompoundReasoningUnsupported(model: Pick<ApiModel<Api>, "provider" | "id">): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Returns a copy of the model with canonical thinking metadata attached.
|
|
21
|
+
*
|
|
22
|
+
* This helper belongs to catalog enrichment only. Runtime consumers should
|
|
23
|
+
* trust `model.thinking` and avoid inferring capabilities on demand.
|
|
24
|
+
*/
|
|
25
|
+
export declare function enrichModelThinking<TApi extends Api>(model: ApiModel<TApi>): ApiModel<TApi>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a copy of the model with thinking metadata recomputed from the
|
|
28
|
+
* canonical rules, replacing any existing `thinking`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function refreshModelThinking<TApi extends Api>(model: ApiModel<TApi>): ApiModel<TApi>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns whether the configured transport has an audited user-facing reasoning control.
|
|
33
|
+
*
|
|
34
|
+
* Custom OpenAI-compatible endpoints fail closed: declaring a model as reasoning-capable
|
|
35
|
+
* is not enough to prove that the proxy accepts OpenAI reasoning parameters. Unknown
|
|
36
|
+
* endpoints must opt in with `compat.supportsReasoningEffort: true`; providers using a
|
|
37
|
+
* non-OpenAI request shape must also declare `compat.thinkingFormat`. Bundled providers
|
|
38
|
+
* remain governed by their catalog and compatibility metadata.
|
|
39
|
+
*/
|
|
40
|
+
export declare function modelSupportsReasoningControl<TApi extends Api>(model: ApiModel<TApi>, resolvedBaseUrl?: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Apply upstream metadata corrections to a mutable array of models.
|
|
43
|
+
*
|
|
44
|
+
* Each model is first normalized through `refreshModelThinking()` so generated
|
|
45
|
+
* catalogs keep canonical thinking metadata and policy fixes in one pass.
|
|
46
|
+
*/
|
|
47
|
+
export declare function applyGeneratedModelPolicies(models: ApiModel<Api>[]): void;
|
|
48
|
+
/**
|
|
49
|
+
* Link OpenAI model variants to their context promotion targets.
|
|
50
|
+
*
|
|
51
|
+
* When a model's context is exhausted, the agent can promote to a sibling
|
|
52
|
+
* model with a larger context window on the same provider:
|
|
53
|
+
* - `OpenAI code backend-spark` variants promote to `gpt-5.5`.
|
|
54
|
+
*
|
|
55
|
+
* `gpt-5.5` itself is a 1M-context model and is not demoted to `gpt-5.4`
|
|
56
|
+
* (which has a smaller window), so it has no promotion target.
|
|
57
|
+
*/
|
|
58
|
+
export declare function linkOpenAIPromotionTargets(models: ApiModel<Api>[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the supported thinking efforts declared on the model metadata.
|
|
61
|
+
*
|
|
62
|
+
* Catalog enrichment is responsible for normalizing bundled model metadata up front.
|
|
63
|
+
* Runtime callers must treat explicit `model.thinking` on custom models as authoritative
|
|
64
|
+
* so proxy-specific overrides from `models.yml` survive request construction.
|
|
65
|
+
*
|
|
66
|
+
* @throws Error when a reasoning-capable model is missing thinking metadata
|
|
67
|
+
*/
|
|
68
|
+
export declare function getSupportedEfforts<TApi extends Api>(model: ApiModel<TApi>): readonly Effort[];
|
|
69
|
+
/**
|
|
70
|
+
* Clamps a requested thinking level against explicit model metadata.
|
|
71
|
+
*
|
|
72
|
+
* Non-reasoning models always resolve to `undefined`.
|
|
73
|
+
*/
|
|
74
|
+
export declare function clampThinkingLevelForModel<TApi extends Api>(model: ApiModel<TApi> | undefined, requested: Effort | undefined): Effort | undefined;
|
|
75
|
+
export declare function requireSupportedEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): Effort;
|
|
76
|
+
/** Maps a normalized thinking effort to Google's `thinkingLevel` enum values. */
|
|
77
|
+
export declare function mapEffortToGoogleThinkingLevel<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): "MINIMAL" | "LOW" | "MEDIUM" | "HIGH";
|
|
78
|
+
/** Maps a normalized thinking effort to Anthropic adaptive effort values. */
|
|
79
|
+
export declare function mapEffortToAnthropicAdaptiveEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): "low" | "medium" | "high" | "xhigh" | "max";
|
|
80
|
+
/**
|
|
81
|
+
* Returns true for Anthropic models with Opus 4.7 API restrictions:
|
|
82
|
+
* - Sampling parameters (temperature/top_p/top_k) return 400 error
|
|
83
|
+
* - Thinking content is omitted by default (needs display: "summarized")
|
|
84
|
+
*/
|
|
85
|
+
export declare function hasOpus47ApiRestrictions(modelId: string): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Adaptive thinking `display` is supported starting with Anthropic Opus 4.7.
|
|
88
|
+
* Older adaptive-thinking models (Opus 4.6, Sonnet 4.6+) reject the field.
|
|
89
|
+
* Fable (5+) postdates Opus 4.7, accepts `display`, and defaults it to
|
|
90
|
+
* "omitted" — thinking tokens are billed but no content streams back — so it
|
|
91
|
+
* must opt in like Opus 4.7+ (issue #2791).
|
|
92
|
+
*
|
|
93
|
+
* Shares `hasOpus47ApiRestrictions` version parsing on purpose: the two
|
|
94
|
+
* predicates describe the same API generation, and a private `claude-opus-(\d+)-(\d+)`
|
|
95
|
+
* regex silently disagreed with it for single-component aliases (`claude-opus-5`
|
|
96
|
+
* matched nothing while `claude-opus-5-20260101` matched), so the same model sent
|
|
97
|
+
* a different thinking shape and beta set depending on which id string was used.
|
|
98
|
+
* Bedrock region/inference-profile prefixes are handled by the canonical parser.
|
|
99
|
+
*/
|
|
100
|
+
export declare function supportsAnthropicAdaptiveThinkingDisplay(modelId: string): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Api, KnownProvider, Model, Usage } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Static bundled model registry loaded lazily from `models.json`.
|
|
4
|
+
*
|
|
5
|
+
* This module intentionally exposes compile-time defaults only.
|
|
6
|
+
* It does not include runtime discovery, models.dev overlays, or on-disk cache state.
|
|
7
|
+
*
|
|
8
|
+
* For runtime-aware resolution, use `createModelManager()` / `resolveProviderModels()`.
|
|
9
|
+
*/
|
|
10
|
+
type BundledCatalog = typeof import("./models.json");
|
|
11
|
+
export type GeneratedProvider = keyof BundledCatalog;
|
|
12
|
+
export declare function getBundledModel<TApi extends Api = Api>(provider: GeneratedProvider, modelId: string): Model<TApi>;
|
|
13
|
+
export declare function getBundledProviders(): KnownProvider[];
|
|
14
|
+
export declare function getBundledModels(provider: GeneratedProvider): Model<Api>[];
|
|
15
|
+
export declare function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage["cost"];
|
|
16
|
+
/**
|
|
17
|
+
* Check if two models are equal by comparing both their id and provider.
|
|
18
|
+
* Returns false if either model is null or undefined.
|
|
19
|
+
*/
|
|
20
|
+
export declare function modelsAreEqual<TApi extends Api>(a: Model<TApi> | null | undefined, b: Model<TApi> | null | undefined): boolean;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Model, OpenAICompat } from "./types";
|
|
2
|
+
type ResolvedToolStrictMode = NonNullable<OpenAICompat["toolStrictMode"]> | "mixed";
|
|
3
|
+
/** Returns whether the request endpoint is an audited reasoning-control transport. */
|
|
4
|
+
export declare function isAuditedOpenAIReasoningTransport(model: {
|
|
5
|
+
provider: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}, resolvedBaseUrl?: string): boolean;
|
|
8
|
+
export type ResolvedOpenAICompat = Required<Omit<OpenAICompat, "openRouterRouting" | "vercelGatewayRouting" | "extraBody" | "toolStrictMode" | "toolChoiceSupport" | "supportsResponsesSessionAffinity" | "supportsServiceTier" | "reservedToolNames">> & {
|
|
9
|
+
openRouterRouting?: OpenAICompat["openRouterRouting"];
|
|
10
|
+
vercelGatewayRouting?: OpenAICompat["vercelGatewayRouting"];
|
|
11
|
+
extraBody?: OpenAICompat["extraBody"];
|
|
12
|
+
toolStrictMode: ResolvedToolStrictMode;
|
|
13
|
+
supportsResponsesSessionAffinity?: OpenAICompat["supportsResponsesSessionAffinity"];
|
|
14
|
+
supportsServiceTier?: OpenAICompat["supportsServiceTier"];
|
|
15
|
+
/** Optional explicit capability override; resolved via deriveToolChoiceSupport. */
|
|
16
|
+
toolChoiceSupport?: OpenAICompat["toolChoiceSupport"];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Detect compatibility settings from provider and baseUrl for known providers.
|
|
20
|
+
* Provider takes precedence over URL-based detection since it's explicitly configured.
|
|
21
|
+
* @param model - The model configuration
|
|
22
|
+
* @param resolvedBaseUrl - Optional resolved base URL (e.g., after GitHub Copilot proxy-ep resolution).
|
|
23
|
+
* If provided, this takes precedence over model.baseUrl for URL-based checks.
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectOpenAICompat(model: Model<"openai-completions">, resolvedBaseUrl?: string): ResolvedOpenAICompat;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve compatibility settings by layering explicit model.compat overrides onto
|
|
28
|
+
* the detected defaults. This is the canonical compat view for both metadata and transport.
|
|
29
|
+
* @param model - The model configuration
|
|
30
|
+
* @param resolvedBaseUrl - Optional resolved base URL (e.g., after GitHub Copilot proxy-ep resolution).
|
|
31
|
+
* If provided, this takes precedence over model.baseUrl for URL-based checks.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveOpenAICompat(model: Model<"openai-completions">, resolvedBaseUrl?: string): ResolvedOpenAICompat;
|
|
34
|
+
export {};
|
|
@@ -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,48 @@
|
|
|
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
|
+
/** Catalog discovery configuration. Only providers with this field participate in generate-models.ts. */
|
|
32
|
+
catalogDiscovery?: CatalogDiscoveryConfig;
|
|
33
|
+
}
|
|
34
|
+
/** A provider descriptor that has catalog discovery configured. */
|
|
35
|
+
export type CatalogProviderDescriptor = ProviderDescriptor & {
|
|
36
|
+
catalogDiscovery: CatalogDiscoveryConfig;
|
|
37
|
+
};
|
|
38
|
+
/** Type guard for descriptors with catalog discovery. */
|
|
39
|
+
export declare function isCatalogDescriptor(d: ProviderDescriptor): d is CatalogProviderDescriptor;
|
|
40
|
+
/** Whether catalog discovery may run without provider credentials. */
|
|
41
|
+
export declare function allowsUnauthenticatedCatalogDiscovery(descriptor: CatalogProviderDescriptor): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* All standard providers. Special providers (google-antigravity, google-gemini-cli,
|
|
44
|
+
* OpenAI code provider) are handled separately because they require different config shapes.
|
|
45
|
+
*/
|
|
46
|
+
export declare const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[];
|
|
47
|
+
/** Default model IDs for all known providers, built from descriptors + special providers. */
|
|
48
|
+
export declare const DEFAULT_MODEL_PER_PROVIDER: Record<KnownProvider, string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ModelManagerOptions } from "../model-manager";
|
|
2
|
+
export interface GoogleModelManagerConfig {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GoogleVertexModelManagerConfig {
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GoogleAntigravityModelManagerConfig {
|
|
10
|
+
oauthToken?: string;
|
|
11
|
+
endpoint?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface GoogleGeminiCliModelManagerConfig {
|
|
14
|
+
oauthToken?: string;
|
|
15
|
+
endpoint?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function googleModelManagerOptions(config?: GoogleModelManagerConfig): ModelManagerOptions<"google-generative-ai">;
|
|
18
|
+
export declare function googleVertexModelManagerOptions(_config?: GoogleVertexModelManagerConfig): ModelManagerOptions<"google-vertex">;
|
|
19
|
+
export declare function googleAntigravityModelManagerOptions(config?: GoogleAntigravityModelManagerConfig): ModelManagerOptions<"google-gemini-cli">;
|
|
20
|
+
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">;
|