@prometheus-ai/ai 0.5.4 → 0.5.8
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/dist/types/auth-broker/remote-store.d.ts +2 -1
- package/dist/types/auth-broker/wire-schemas.d.ts +4 -1
- package/dist/types/auth-gateway/server.d.ts +19 -0
- package/dist/types/auth-gateway/types.d.ts +9 -3
- package/dist/types/auth-retry.d.ts +119 -0
- package/dist/types/auth-storage.d.ts +217 -8
- package/dist/types/errors.d.ts +24 -0
- package/dist/types/index.d.ts +5 -9
- package/dist/types/provider-details.d.ts +1 -1
- package/dist/types/providers/amazon-bedrock.d.ts +12 -6
- package/dist/types/providers/anthropic-client.d.ts +10 -3
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +2 -2
- package/dist/types/providers/anthropic-messages-server.d.ts +3 -3
- package/dist/types/providers/anthropic-wire.d.ts +3 -3
- package/dist/types/providers/anthropic.d.ts +41 -34
- package/dist/types/providers/aws-credentials.d.ts +8 -0
- package/dist/types/providers/azure-openai-responses.d.ts +1 -0
- package/dist/types/providers/google-gemini-cli.d.ts +22 -1
- package/dist/types/providers/google-shared.d.ts +22 -0
- package/dist/types/providers/google-types.d.ts +13 -1
- package/dist/types/providers/mock.d.ts +8 -3
- package/dist/types/providers/ollama.d.ts +6 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +6 -3
- package/dist/types/providers/openai-chat-server.d.ts +3 -3
- package/dist/types/providers/openai-chat-wire.d.ts +644 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +8 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +9 -0
- package/dist/types/providers/openai-codex-responses.d.ts +31 -2
- package/dist/types/providers/openai-completions-compat.d.ts +2 -25
- package/dist/types/providers/openai-completions.d.ts +2 -10
- package/dist/types/providers/openai-responses-server-schema.d.ts +4 -4
- package/dist/types/providers/openai-responses-server.d.ts +2 -2
- package/dist/types/providers/openai-responses-shared.d.ts +49 -9
- package/dist/types/providers/openai-responses-wire.d.ts +6065 -0
- package/dist/types/providers/openai-responses.d.ts +13 -4
- package/dist/types/providers/prometheus-native-client.d.ts +9 -0
- package/dist/types/providers/prometheus-native-server.d.ts +4 -3
- package/dist/types/providers/transform-messages.d.ts +1 -2
- package/dist/types/rate-limit-utils.d.ts +3 -2
- package/dist/types/registry/aimlapi.d.ts +4 -0
- package/dist/types/registry/alibaba-coding-plan.d.ts +7 -0
- package/dist/types/registry/amazon-bedrock.d.ts +5 -0
- package/dist/types/registry/anthropic.d.ts +10 -0
- package/dist/types/{utils/oauth → registry}/api-key-login.d.ts +8 -2
- package/dist/types/{utils/oauth → registry}/api-key-validation.d.ts +15 -0
- package/dist/types/registry/cerebras.d.ts +7 -0
- package/dist/types/registry/cloudflare-ai-gateway.d.ts +13 -0
- package/dist/types/registry/cursor.d.ts +7 -0
- package/dist/types/registry/deepseek.d.ts +8 -0
- package/dist/types/registry/derived.d.ts +5 -0
- package/dist/types/registry/firepass.d.ts +16 -0
- package/dist/types/registry/fireworks.d.ts +7 -0
- package/dist/types/registry/github-copilot.d.ts +7 -0
- package/dist/types/registry/gitlab-duo.d.ts +9 -0
- package/dist/types/registry/google-antigravity.d.ts +9 -0
- package/dist/types/registry/google-gemini-cli.d.ts +9 -0
- package/dist/types/registry/google-vertex.d.ts +5 -0
- package/dist/types/registry/google.d.ts +4 -0
- package/dist/types/registry/groq.d.ts +4 -0
- package/dist/types/registry/huggingface.d.ts +7 -0
- package/dist/types/registry/index.d.ts +4 -0
- package/dist/types/registry/kagi.d.ts +14 -0
- package/dist/types/registry/kilo.d.ts +7 -0
- package/dist/types/registry/kimi-code.d.ts +7 -0
- package/dist/types/registry/litellm.d.ts +13 -0
- package/dist/types/registry/lm-studio.d.ts +8 -0
- package/dist/types/registry/minimax-code-cn.d.ts +6 -0
- package/dist/types/registry/minimax-code.d.ts +6 -0
- package/dist/types/registry/minimax.d.ts +4 -0
- package/dist/types/registry/mistral.d.ts +4 -0
- package/dist/types/registry/moonshot.d.ts +7 -0
- package/dist/types/registry/nanogpt.d.ts +7 -0
- package/dist/types/registry/nvidia.d.ts +7 -0
- package/dist/types/registry/oauth/__tests__/xai-oauth.test.d.ts +1 -0
- package/dist/types/{utils → registry}/oauth/anthropic.d.ts +2 -1
- package/dist/types/{utils → registry}/oauth/github-copilot.d.ts +15 -23
- package/dist/types/{utils → registry}/oauth/index.d.ts +1 -0
- package/dist/types/{utils → registry}/oauth/minimax-code.d.ts +5 -5
- package/dist/types/{utils → registry}/oauth/types.d.ts +6 -1
- package/dist/types/{utils → registry}/oauth/xai-oauth.d.ts +2 -1
- package/dist/types/registry/ollama-cloud.d.ts +7 -0
- package/dist/types/registry/ollama.d.ts +12 -0
- package/dist/types/registry/openai-codex-device.d.ts +8 -0
- package/dist/types/registry/openai-codex.d.ts +9 -0
- package/dist/types/registry/openai.d.ts +4 -0
- package/dist/types/registry/opencode-go.d.ts +6 -0
- package/dist/types/registry/opencode-zen.d.ts +6 -0
- package/dist/types/registry/openrouter.d.ts +13 -0
- package/dist/types/registry/parallel.d.ts +14 -0
- package/dist/types/registry/perplexity.d.ts +7 -0
- package/dist/types/registry/qianfan.d.ts +7 -0
- package/dist/types/registry/qwen-portal.d.ts +7 -0
- package/dist/types/registry/registry.d.ts +272 -0
- package/dist/types/registry/synthetic.d.ts +6 -0
- package/dist/types/registry/tavily.d.ts +14 -0
- package/dist/types/registry/together.d.ts +6 -0
- package/dist/types/registry/types.d.ts +51 -0
- package/dist/types/registry/venice.d.ts +13 -0
- package/dist/types/registry/vercel-ai-gateway.d.ts +7 -0
- package/dist/types/registry/vllm.d.ts +7 -0
- package/dist/types/registry/wafer-pass.d.ts +6 -0
- package/dist/types/registry/wafer-serverless.d.ts +6 -0
- package/dist/types/registry/xai-oauth.d.ts +7 -0
- package/dist/types/registry/xai.d.ts +4 -0
- package/dist/types/registry/xiaomi-token-plan-ams.d.ts +6 -0
- package/dist/types/registry/xiaomi-token-plan-cn.d.ts +6 -0
- package/dist/types/registry/xiaomi-token-plan-sgp.d.ts +6 -0
- package/dist/types/registry/xiaomi.d.ts +6 -0
- package/dist/types/registry/zai.d.ts +7 -0
- package/dist/types/registry/zenmux.d.ts +7 -0
- package/dist/types/registry/zhipu-coding-plan.d.ts +7 -0
- package/dist/types/stream.d.ts +9 -1
- package/dist/types/types.d.ts +56 -295
- package/dist/types/usage/google-antigravity.d.ts +15 -1
- package/dist/types/usage/openai-codex-reset.d.ts +79 -0
- package/dist/types/usage/openai-codex.d.ts +1 -0
- package/dist/types/usage.d.ts +77 -4
- package/dist/types/utils/abort.d.ts +6 -0
- package/dist/types/utils/event-stream.d.ts +2 -0
- package/dist/types/utils/http-inspector.d.ts +0 -1
- package/dist/types/utils/idle-iterator.d.ts +35 -0
- package/dist/types/utils/openai-http.d.ts +58 -0
- package/dist/types/utils/request-debug.d.ts +3 -0
- package/dist/types/utils/retry-after.d.ts +1 -0
- package/dist/types/utils/schema/fields.d.ts +5 -0
- package/dist/types/utils/schema/json-schema-validator.d.ts +8 -0
- package/dist/types/utils/schema/stamps.d.ts +7 -15
- package/dist/types/utils/sse-debug.d.ts +0 -5
- package/dist/types/utils/stream-markup-healing.d.ts +2 -0
- package/dist/types/utils.d.ts +1 -5
- package/package.json +17 -29
- package/src/auth-broker/remote-store.ts +10 -1
- package/src/auth-broker/snapshot-cache.ts +1 -1
- package/src/auth-broker/wire-schemas.ts +1 -1
- package/src/auth-gateway/http.ts +1 -1
- package/src/auth-gateway/server.ts +95 -30
- package/src/auth-gateway/types.ts +10 -2
- package/src/auth-retry.ts +238 -0
- package/src/auth-storage.ts +935 -430
- package/src/errors.ts +32 -0
- package/src/index.ts +9 -14
- package/src/provider-details.ts +1 -1
- package/src/providers/__tests__/google-auth.test.ts +144 -0
- package/src/providers/amazon-bedrock.ts +70 -40
- package/src/providers/anthropic-client.ts +15 -13
- package/src/providers/anthropic-messages-server-schema.ts +17 -7
- package/src/providers/anthropic-messages-server.ts +88 -20
- package/src/providers/anthropic-wire.ts +4 -3
- package/src/providers/anthropic.ts +1234 -621
- package/src/providers/aws-credentials.ts +47 -5
- package/src/providers/aws-eventstream.ts +5 -0
- package/src/providers/azure-openai-responses.ts +117 -67
- package/src/providers/cursor.ts +30 -30
- package/src/providers/github-copilot-headers.ts +1 -1
- package/src/providers/gitlab-duo.ts +36 -29
- package/src/providers/google-auth.ts +71 -8
- package/src/providers/google-gemini-cli.ts +118 -22
- package/src/providers/google-shared.ts +163 -43
- package/src/providers/google-types.ts +10 -1
- package/src/providers/kimi.ts +1 -1
- package/src/providers/mock.ts +11 -3
- package/src/providers/ollama.ts +64 -7
- package/src/providers/openai-anthropic-shim.ts +17 -8
- package/src/providers/openai-chat-server-schema.ts +9 -3
- package/src/providers/openai-chat-server.ts +82 -16
- package/src/providers/openai-chat-wire.ts +847 -0
- package/src/providers/openai-codex/request-transformer.ts +129 -34
- package/src/providers/openai-codex/response-handler.ts +22 -1
- package/src/providers/openai-codex-responses.ts +699 -247
- package/src/providers/openai-completions-compat.ts +8 -308
- package/src/providers/openai-completions.ts +416 -267
- package/src/providers/openai-responses-server-schema.ts +15 -9
- package/src/providers/openai-responses-server.ts +162 -114
- package/src/providers/openai-responses-shared.ts +320 -82
- package/src/providers/openai-responses-wire.ts +6391 -0
- package/src/providers/openai-responses.ts +382 -176
- package/src/providers/prometheus-native-client.ts +27 -11
- package/src/providers/prometheus-native-server.ts +44 -17
- package/src/providers/transform-messages.ts +311 -120
- package/src/providers/vision-guard.ts +5 -3
- package/src/rate-limit-utils.ts +13 -3
- package/src/registry/aimlapi.ts +6 -0
- package/src/{utils/oauth → registry}/alibaba-coding-plan.ts +8 -18
- package/src/registry/amazon-bedrock.ts +22 -0
- package/src/registry/anthropic.ts +26 -0
- package/src/{utils/oauth → registry}/api-key-login.ts +25 -3
- package/src/{utils/oauth → registry}/api-key-validation.ts +62 -2
- package/src/{utils/oauth → registry}/cerebras.ts +8 -1
- package/src/{utils/oauth → registry}/cloudflare-ai-gateway.ts +8 -12
- package/src/registry/cursor.ts +20 -0
- package/src/{utils/oauth → registry}/deepseek.ts +9 -17
- package/src/registry/derived.ts +9 -0
- package/src/{utils/oauth → registry}/firepass.ts +10 -2
- package/src/{utils/oauth → registry}/fireworks.ts +8 -1
- package/src/registry/github-copilot.ts +22 -0
- package/src/registry/gitlab-duo.ts +19 -0
- package/src/registry/google-antigravity.ts +21 -0
- package/src/registry/google-gemini-cli.ts +21 -0
- package/src/registry/google-vertex.ts +38 -0
- package/src/registry/google.ts +6 -0
- package/src/registry/groq.ts +6 -0
- package/src/{utils/oauth → registry}/huggingface.ts +8 -19
- package/src/registry/index.ts +4 -0
- package/src/{utils/oauth → registry}/kagi.ts +9 -11
- package/src/{utils/oauth → registry}/kilo.ts +11 -6
- package/src/registry/kimi-code.ts +17 -0
- package/src/{utils/oauth → registry}/litellm.ts +8 -12
- package/src/{utils/oauth → registry}/lm-studio.ts +9 -17
- package/src/registry/minimax-code-cn.ts +12 -0
- package/src/registry/minimax-code.ts +12 -0
- package/src/registry/minimax.ts +6 -0
- package/src/registry/mistral.ts +6 -0
- package/src/{utils/oauth → registry}/moonshot.ts +8 -9
- package/src/{utils/oauth → registry}/nanogpt.ts +8 -1
- package/src/{utils/oauth → registry}/nvidia.ts +8 -18
- package/src/{utils → registry}/oauth/__tests__/xai-oauth.test.ts +4 -7
- package/src/{utils → registry}/oauth/anthropic.ts +38 -17
- package/src/{utils → registry}/oauth/github-copilot.ts +79 -115
- package/src/registry/oauth/gitlab-duo.ts +198 -0
- package/src/{utils → registry}/oauth/google-antigravity.ts +1 -4
- package/src/{utils → registry}/oauth/google-gemini-cli.ts +1 -4
- package/src/registry/oauth/index.ts +164 -0
- package/src/{utils → registry}/oauth/minimax-code.ts +16 -14
- package/src/{utils → registry}/oauth/types.ts +7 -51
- package/src/{utils → registry}/oauth/wafer.ts +1 -1
- package/src/{utils → registry}/oauth/xai-oauth.ts +16 -8
- package/src/{utils → registry}/oauth/xiaomi.ts +9 -4
- package/src/{utils/oauth → registry}/ollama-cloud.ts +8 -1
- package/src/{utils/oauth → registry}/ollama.ts +8 -13
- package/src/registry/openai-codex-device.ts +18 -0
- package/src/registry/openai-codex.ts +19 -0
- package/src/registry/openai.ts +6 -0
- package/src/registry/opencode-go.ts +12 -0
- package/src/registry/opencode-zen.ts +12 -0
- package/src/{utils/oauth → registry}/openrouter.ts +10 -2
- package/src/{utils/oauth → registry}/parallel.ts +9 -11
- package/src/registry/perplexity.ts +13 -0
- package/src/{utils/oauth → registry}/qianfan.ts +8 -17
- package/src/{utils/oauth → registry}/qwen-portal.ts +8 -19
- package/src/registry/registry.ts +149 -0
- package/src/{utils/oauth → registry}/synthetic.ts +7 -1
- package/src/{utils/oauth → registry}/tavily.ts +10 -12
- package/src/{utils/oauth → registry}/together.ts +7 -1
- package/src/registry/types.ts +56 -0
- package/src/{utils/oauth → registry}/venice.ts +8 -12
- package/src/{utils/oauth → registry}/vercel-ai-gateway.ts +8 -18
- package/src/{utils/oauth → registry}/vllm.ts +9 -16
- package/src/registry/wafer-pass.ts +12 -0
- package/src/registry/wafer-serverless.ts +12 -0
- package/src/registry/xai-oauth.ts +17 -0
- package/src/registry/xai.ts +6 -0
- package/src/registry/xiaomi-token-plan-ams.ts +12 -0
- package/src/registry/xiaomi-token-plan-cn.ts +12 -0
- package/src/registry/xiaomi-token-plan-sgp.ts +12 -0
- package/src/registry/xiaomi.ts +12 -0
- package/src/{utils/oauth → registry}/zai.ts +10 -22
- package/src/{utils/oauth → registry}/zenmux.ts +8 -1
- package/src/{utils/oauth/zhipu.ts → registry/zhipu-coding-plan.ts} +9 -21
- package/src/stream.ts +229 -199
- package/src/types.ts +63 -384
- package/src/usage/claude.ts +4 -2
- package/src/usage/github-copilot.ts +4 -2
- package/src/usage/google-antigravity.ts +196 -28
- package/src/usage/kimi.ts +1 -1
- package/src/usage/minimax-code.ts +5 -6
- package/src/usage/openai-codex-reset.ts +174 -0
- package/src/usage/openai-codex.ts +19 -2
- package/src/usage/zai.ts +2 -1
- package/src/usage.ts +93 -4
- package/src/utils/abort.ts +14 -0
- package/src/utils/event-stream.ts +17 -0
- package/src/utils/http-inspector.ts +4 -12
- package/src/utils/idle-iterator.ts +250 -79
- package/src/utils/openai-http.ts +157 -0
- package/src/utils/request-debug.ts +67 -19
- package/src/utils/retry-after.ts +1 -1
- package/src/utils/retry.ts +23 -2
- package/src/utils/schema/CONSTRAINTS.md +4 -2
- package/src/utils/schema/fields.ts +16 -0
- package/src/utils/schema/json-schema-validator.ts +19 -1
- package/src/utils/schema/normalize.ts +80 -8
- package/src/utils/schema/stamps.ts +22 -10
- package/src/utils/schema/wire.ts +2 -2
- package/src/utils/sse-debug.ts +0 -271
- package/src/utils/stream-markup-healing.ts +50 -8
- package/src/utils/validation.ts +49 -13
- package/src/utils.ts +2 -26
- package/dist/types/model-cache.d.ts +0 -17
- package/dist/types/model-manager.d.ts +0 -64
- package/dist/types/model-thinking.d.ts +0 -100
- package/dist/types/models.d.ts +0 -12
- package/dist/types/provider-models/bundled-references.d.ts +0 -4
- package/dist/types/provider-models/descriptors.d.ts +0 -50
- package/dist/types/provider-models/google.d.ts +0 -24
- package/dist/types/provider-models/index.d.ts +0 -5
- package/dist/types/provider-models/ollama.d.ts +0 -7
- package/dist/types/provider-models/openai-compat.d.ts +0 -323
- package/dist/types/provider-models/special.d.ts +0 -16
- package/dist/types/utils/discovery/antigravity.d.ts +0 -61
- package/dist/types/utils/discovery/codex.d.ts +0 -38
- package/dist/types/utils/discovery/cursor.d.ts +0 -23
- package/dist/types/utils/discovery/gemini.d.ts +0 -25
- package/dist/types/utils/discovery/index.d.ts +0 -4
- package/dist/types/utils/discovery/openai-compatible.d.ts +0 -72
- package/dist/types/utils/oauth/alibaba-coding-plan.d.ts +0 -18
- package/dist/types/utils/oauth/cerebras.d.ts +0 -1
- package/dist/types/utils/oauth/cloudflare-ai-gateway.d.ts +0 -18
- package/dist/types/utils/oauth/deepseek.d.ts +0 -10
- package/dist/types/utils/oauth/firepass.d.ts +0 -1
- package/dist/types/utils/oauth/fireworks.d.ts +0 -1
- package/dist/types/utils/oauth/huggingface.d.ts +0 -19
- package/dist/types/utils/oauth/kagi.d.ts +0 -17
- package/dist/types/utils/oauth/kilo.d.ts +0 -5
- package/dist/types/utils/oauth/litellm.d.ts +0 -18
- package/dist/types/utils/oauth/lm-studio.d.ts +0 -17
- package/dist/types/utils/oauth/moonshot.d.ts +0 -1
- package/dist/types/utils/oauth/nanogpt.d.ts +0 -1
- package/dist/types/utils/oauth/nvidia.d.ts +0 -18
- package/dist/types/utils/oauth/ollama-cloud.d.ts +0 -2
- package/dist/types/utils/oauth/ollama.d.ts +0 -18
- package/dist/types/utils/oauth/openrouter.d.ts +0 -1
- package/dist/types/utils/oauth/parallel.d.ts +0 -17
- package/dist/types/utils/oauth/qianfan.d.ts +0 -17
- package/dist/types/utils/oauth/qwen-portal.d.ts +0 -19
- package/dist/types/utils/oauth/synthetic.d.ts +0 -1
- package/dist/types/utils/oauth/tavily.d.ts +0 -17
- package/dist/types/utils/oauth/together.d.ts +0 -1
- package/dist/types/utils/oauth/venice.d.ts +0 -18
- package/dist/types/utils/oauth/vercel-ai-gateway.d.ts +0 -18
- package/dist/types/utils/oauth/vllm.d.ts +0 -16
- package/dist/types/utils/oauth/zai.d.ts +0 -18
- package/dist/types/utils/oauth/zenmux.d.ts +0 -1
- package/dist/types/utils/oauth/zhipu.d.ts +0 -18
- package/src/model-cache.ts +0 -129
- package/src/model-manager.ts +0 -469
- package/src/model-thinking.ts +0 -756
- package/src/models.json +0 -60287
- package/src/models.json.d.ts +0 -9
- package/src/models.ts +0 -56
- package/src/provider-models/bundled-references.ts +0 -38
- package/src/provider-models/descriptors.ts +0 -364
- package/src/provider-models/google.ts +0 -88
- package/src/provider-models/index.ts +0 -5
- package/src/provider-models/ollama.ts +0 -153
- package/src/provider-models/openai-compat.ts +0 -2904
- package/src/provider-models/special.ts +0 -67
- package/src/utils/discovery/antigravity.ts +0 -261
- package/src/utils/discovery/codex.ts +0 -371
- package/src/utils/discovery/cursor.ts +0 -306
- package/src/utils/discovery/gemini.ts +0 -248
- package/src/utils/discovery/index.ts +0 -4
- package/src/utils/discovery/openai-compatible.ts +0 -224
- package/src/utils/oauth/gitlab-duo.ts +0 -123
- package/src/utils/oauth/index.ts +0 -502
- /package/dist/types/{utils/oauth/__tests__/xai-oauth.test.d.ts → providers/__tests__/google-auth.test.d.ts} +0 -0
- /package/dist/types/{utils → registry}/oauth/callback-server.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/cursor.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/gitlab-duo.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/google-antigravity.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/google-gemini-cli.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/google-oauth-shared.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/kimi.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/openai-codex.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/opencode.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/perplexity.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/pkce.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/wafer.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/xiaomi.d.ts +0 -0
- /package/src/{utils → registry}/oauth/callback-server.ts +0 -0
- /package/src/{utils → registry}/oauth/cursor.ts +0 -0
- /package/src/{utils → registry}/oauth/google-oauth-shared.ts +0 -0
- /package/src/{utils → registry}/oauth/kimi.ts +0 -0
- /package/src/{utils → registry}/oauth/oauth.html +0 -0
- /package/src/{utils → registry}/oauth/openai-codex.ts +0 -0
- /package/src/{utils → registry}/oauth/opencode.ts +0 -0
- /package/src/{utils → registry}/oauth/perplexity.ts +0 -0
- /package/src/{utils → registry}/oauth/pkce.ts +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { isDashscopeCompatibleModeUrl } from "@prometheus-ai/catalog/hosts";
|
|
2
|
+
import { isQwenModelId } from "@prometheus-ai/catalog/identity";
|
|
3
|
+
|
|
1
4
|
import type { ImageContent, Model, TextContent } from "../types";
|
|
2
5
|
|
|
3
6
|
export const NON_VISION_IMAGE_PLACEHOLDER = "[image omitted: model does not support vision]";
|
|
@@ -42,11 +45,10 @@ export function joinTextWithImagePlaceholder(text: string, omittedImages: boolea
|
|
|
42
45
|
* provider (issue #1859) can't drive the request into an unrecoverable 400.
|
|
43
46
|
*/
|
|
44
47
|
export function isDashscopeCompatibleModeTextOnlyQwen(model: Model<"openai-completions">): boolean {
|
|
45
|
-
|
|
46
|
-
if (!baseUrl.includes("dashscope") || !baseUrl.includes("aliyuncs.com") || !baseUrl.includes("/compatible-mode")) {
|
|
48
|
+
if (!isDashscopeCompatibleModeUrl(model.baseUrl)) {
|
|
47
49
|
return false;
|
|
48
50
|
}
|
|
49
51
|
const id = model.id.toLowerCase();
|
|
50
|
-
if (!id
|
|
52
|
+
if (!isQwenModelId(model.id)) return false;
|
|
51
53
|
return /\bqwen(?:[\d.]+)?-max\b/.test(id) || /\bqwen(?:[\d.]+)?-coder\b/.test(id);
|
|
52
54
|
}
|
package/src/rate-limit-utils.ts
CHANGED
|
@@ -21,14 +21,24 @@ const ACCOUNT_RATE_LIMIT_PATTERN =
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Classify a rate-limit error message into a reason category.
|
|
24
|
-
* Priority order:
|
|
24
|
+
* Priority order: QUOTA (Antigravity "quota will reset") > MODEL_CAPACITY > QUOTA (account) >
|
|
25
|
+
* RATE_LIMIT > QUOTA (generic) > SERVER_ERROR > UNKNOWN.
|
|
25
26
|
*
|
|
26
27
|
* "resource exhausted" maps to MODEL_CAPACITY (transient, short wait)
|
|
27
|
-
* "quota exceeded" maps to QUOTA_EXHAUSTED (long wait, switch account)
|
|
28
|
+
* "quota exceeded" / "quota will reset" maps to QUOTA_EXHAUSTED (long wait, switch account)
|
|
28
29
|
*/
|
|
29
30
|
export function parseRateLimitReason(errorMessage: string): RateLimitReason {
|
|
30
31
|
const lower = errorMessage.toLowerCase();
|
|
31
32
|
|
|
33
|
+
// Antigravity / Cloud Code Assist surface multi-hour daily-quota exhaustion as
|
|
34
|
+
// "You have exhausted your capacity on this model. Your quota will reset after …".
|
|
35
|
+
// The literal "capacity" used to pre-empt the QUOTA branch even though "quota
|
|
36
|
+
// will reset" is the long-wait signal — short-circuit here before the
|
|
37
|
+
// MODEL_CAPACITY fallthrough so credential rotation (not 60s backoff) kicks in.
|
|
38
|
+
if (lower.includes("quota will reset") || lower.includes("exhausted your capacity")) {
|
|
39
|
+
return "QUOTA_EXHAUSTED";
|
|
40
|
+
}
|
|
41
|
+
|
|
32
42
|
if (
|
|
33
43
|
lower.includes("capacity") ||
|
|
34
44
|
lower.includes("overloaded") ||
|
|
@@ -84,7 +94,7 @@ export function calculateRateLimitBackoffMs(reason: RateLimitReason): number {
|
|
|
84
94
|
|
|
85
95
|
/** Detect usage/quota limit errors in error messages (persistent, requires credential switch). */
|
|
86
96
|
const USAGE_LIMIT_PATTERN =
|
|
87
|
-
/usage.?limit|usage_limit_reached|usage_not_included|limit_reached|quota.?exceeded|resource.?exhausted/i;
|
|
97
|
+
/usage.?limit|usage_limit_reached|usage_not_included|limit_reached|quota.?exceeded|quota.?reached|resource.?exhausted|exhausted your capacity|quota will reset/i;
|
|
88
98
|
|
|
89
99
|
export function isUsageLimitError(errorMessage: string): boolean {
|
|
90
100
|
return USAGE_LIMIT_PATTERN.test(errorMessage) || ACCOUNT_RATE_LIMIT_PATTERN.test(errorMessage);
|
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Alibaba Coding Plan login flow.
|
|
3
|
-
*
|
|
4
|
-
* Alibaba Coding Plan provides OpenAI-compatible models via https://coding-intl.dashscope.aliyuncs.com/v1.
|
|
5
|
-
*
|
|
6
|
-
* This is not OAuth - it's a simple API key flow:
|
|
7
|
-
* 1. Open browser to Alibaba Cloud DashScope API key settings
|
|
8
|
-
* 2. User copies their API key
|
|
9
|
-
* 3. User pastes the API key into the CLI
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
import { validateOpenAICompatibleApiKey } from "./api-key-validation";
|
|
13
|
-
import type { OAuthController } from "./types";
|
|
2
|
+
import type { OAuthController, OAuthLoginCallbacks } from "./oauth/types";
|
|
3
|
+
import type { ProviderDefinition } from "./types";
|
|
14
4
|
|
|
15
5
|
const AUTH_URL = "https://modelstudio.console.alibabacloud.com/";
|
|
16
6
|
const API_BASE_URL = "https://coding-intl.dashscope.aliyuncs.com/v1";
|
|
17
7
|
const VALIDATION_MODEL = "qwen3.5-plus";
|
|
18
8
|
|
|
19
|
-
/**
|
|
20
|
-
* Login to Alibaba Coding Plan.
|
|
21
|
-
*
|
|
22
|
-
* Opens browser to API keys page, prompts user to paste their API key.
|
|
23
|
-
* Returns the API key directly (not OAuthCredentials - this isn't OAuth).
|
|
24
|
-
*/
|
|
25
9
|
export async function loginAlibabaCodingPlan(options: OAuthController): Promise<string> {
|
|
26
10
|
if (!options.onPrompt) {
|
|
27
11
|
throw new Error("Alibaba Coding Plan login requires onPrompt callback");
|
|
@@ -57,3 +41,9 @@ export async function loginAlibabaCodingPlan(options: OAuthController): Promise<
|
|
|
57
41
|
|
|
58
42
|
return trimmed;
|
|
59
43
|
}
|
|
44
|
+
|
|
45
|
+
export const alibabaCodingPlanProvider = {
|
|
46
|
+
id: "alibaba-coding-plan",
|
|
47
|
+
name: "Alibaba Coding Plan",
|
|
48
|
+
login: (cb: OAuthLoginCallbacks) => loginAlibabaCodingPlan(cb),
|
|
49
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { $env } from "@prometheus-ai/utils";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const amazonBedrockProvider = {
|
|
5
|
+
id: "amazon-bedrock",
|
|
6
|
+
name: "Amazon Bedrock",
|
|
7
|
+
// Amazon Bedrock accepts bearer tokens, IAM keys, profiles, ECS/IRSA credential chains.
|
|
8
|
+
envKeys: () => {
|
|
9
|
+
const hasEcsCredentials =
|
|
10
|
+
!!$env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI || !!$env.AWS_CONTAINER_CREDENTIALS_FULL_URI;
|
|
11
|
+
const hasWebIdentity = !!$env.AWS_WEB_IDENTITY_TOKEN_FILE && !!$env.AWS_ROLE_ARN;
|
|
12
|
+
if (
|
|
13
|
+
$env.AWS_PROFILE ||
|
|
14
|
+
($env.AWS_ACCESS_KEY_ID && $env.AWS_SECRET_ACCESS_KEY) ||
|
|
15
|
+
$env.AWS_BEARER_TOKEN_BEDROCK ||
|
|
16
|
+
hasEcsCredentials ||
|
|
17
|
+
hasWebIdentity
|
|
18
|
+
) {
|
|
19
|
+
return "<authenticated>";
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { $pickenv } from "@prometheus-ai/utils";
|
|
2
|
+
import { isFoundryEnabled } from "../utils/foundry";
|
|
3
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "./oauth/types";
|
|
4
|
+
import type { ProviderDefinition } from "./types";
|
|
5
|
+
|
|
6
|
+
export const anthropicProvider = {
|
|
7
|
+
id: "anthropic",
|
|
8
|
+
name: "Anthropic (Claude Pro/Max)",
|
|
9
|
+
// Foundry mode optionally switches Anthropic auth to enterprise gateway credentials.
|
|
10
|
+
envKeys: () =>
|
|
11
|
+
isFoundryEnabled()
|
|
12
|
+
? $pickenv("ANTHROPIC_FOUNDRY_API_KEY", "ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY")
|
|
13
|
+
: $pickenv("ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY"),
|
|
14
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
15
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
16
|
+
const { loginAnthropic } = await import("./oauth/anthropic");
|
|
17
|
+
return loginAnthropic(cb);
|
|
18
|
+
},
|
|
19
|
+
refreshToken: async (credentials: OAuthCredentials) => {
|
|
20
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
21
|
+
const { refreshAnthropicToken } = await import("./oauth/anthropic");
|
|
22
|
+
return refreshAnthropicToken(credentials.refresh);
|
|
23
|
+
},
|
|
24
|
+
callbackPort: 54545,
|
|
25
|
+
pasteCodeFlow: true,
|
|
26
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
* optionally validate it, and return the trimmed key.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
validateAnthropicCompatibleApiKey,
|
|
11
|
+
validateApiKeyAgainstModelsEndpoint,
|
|
12
|
+
validateOpenAICompatibleApiKey,
|
|
13
|
+
} from "./api-key-validation";
|
|
14
|
+
import type { OAuthController } from "./oauth/types";
|
|
11
15
|
|
|
12
16
|
type ChatCompletionsValidation = {
|
|
13
17
|
kind: "chat-completions";
|
|
@@ -16,6 +20,13 @@ type ChatCompletionsValidation = {
|
|
|
16
20
|
model: string;
|
|
17
21
|
};
|
|
18
22
|
|
|
23
|
+
type AnthropicMessagesValidation = {
|
|
24
|
+
kind: "anthropic-messages";
|
|
25
|
+
provider: string;
|
|
26
|
+
baseUrl: string;
|
|
27
|
+
model: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
19
30
|
type ModelsEndpointValidation = {
|
|
20
31
|
kind: "models-endpoint";
|
|
21
32
|
provider: string;
|
|
@@ -34,7 +45,7 @@ export type ApiKeyLoginConfig = {
|
|
|
34
45
|
/** Placeholder string for the prompt (e.g. "sk-...", "csk-..."). */
|
|
35
46
|
placeholder: string;
|
|
36
47
|
/** Validation strategy, or `null` to skip validation. */
|
|
37
|
-
validation: ChatCompletionsValidation | ModelsEndpointValidation | null;
|
|
48
|
+
validation: ChatCompletionsValidation | AnthropicMessagesValidation | ModelsEndpointValidation | null;
|
|
38
49
|
};
|
|
39
50
|
|
|
40
51
|
export function createApiKeyLogin(config: ApiKeyLoginConfig): (options: OAuthController) => Promise<string> {
|
|
@@ -71,6 +82,16 @@ export function createApiKeyLogin(config: ApiKeyLoginConfig): (options: OAuthCon
|
|
|
71
82
|
baseUrl: config.validation.baseUrl,
|
|
72
83
|
model: config.validation.model,
|
|
73
84
|
signal: options.signal,
|
|
85
|
+
fetch: options.fetch,
|
|
86
|
+
});
|
|
87
|
+
} else if (config.validation.kind === "anthropic-messages") {
|
|
88
|
+
await validateAnthropicCompatibleApiKey({
|
|
89
|
+
provider: config.validation.provider,
|
|
90
|
+
apiKey: trimmed,
|
|
91
|
+
baseUrl: config.validation.baseUrl,
|
|
92
|
+
model: config.validation.model,
|
|
93
|
+
signal: options.signal,
|
|
94
|
+
fetch: options.fetch,
|
|
74
95
|
});
|
|
75
96
|
} else {
|
|
76
97
|
await validateApiKeyAgainstModelsEndpoint({
|
|
@@ -78,6 +99,7 @@ export function createApiKeyLogin(config: ApiKeyLoginConfig): (options: OAuthCon
|
|
|
78
99
|
apiKey: trimmed,
|
|
79
100
|
modelsUrl: config.validation.modelsUrl,
|
|
80
101
|
signal: options.signal,
|
|
102
|
+
fetch: options.fetch,
|
|
81
103
|
});
|
|
82
104
|
}
|
|
83
105
|
}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import type { FetchImpl } from "../types";
|
|
2
|
+
|
|
1
3
|
type OpenAICompatibleValidationOptions = {
|
|
2
4
|
provider: string;
|
|
3
5
|
apiKey: string;
|
|
4
6
|
baseUrl: string;
|
|
5
7
|
model: string;
|
|
6
8
|
signal?: AbortSignal;
|
|
9
|
+
fetch?: FetchImpl;
|
|
10
|
+
};
|
|
11
|
+
type AnthropicCompatibleValidationOptions = {
|
|
12
|
+
provider: string;
|
|
13
|
+
apiKey: string;
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
model: string;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
fetch?: FetchImpl;
|
|
7
18
|
};
|
|
8
19
|
|
|
9
20
|
type ModelListValidationOptions = {
|
|
@@ -11,10 +22,16 @@ type ModelListValidationOptions = {
|
|
|
11
22
|
apiKey: string;
|
|
12
23
|
modelsUrl: string;
|
|
13
24
|
signal?: AbortSignal;
|
|
25
|
+
fetch?: FetchImpl;
|
|
14
26
|
};
|
|
15
27
|
|
|
16
28
|
const VALIDATION_TIMEOUT_MS = 15_000;
|
|
17
29
|
|
|
30
|
+
function normalizeAnthropicCompatibleBaseUrl(baseUrl: string): string {
|
|
31
|
+
const trimmed = baseUrl.trim().replace(/\/+$/, "");
|
|
32
|
+
return trimmed.endsWith("/v1") ? trimmed.slice(0, -3) : trimmed;
|
|
33
|
+
}
|
|
34
|
+
|
|
18
35
|
/**
|
|
19
36
|
* Validate an API key against an OpenAI-compatible chat completions endpoint.
|
|
20
37
|
*
|
|
@@ -23,8 +40,9 @@ const VALIDATION_TIMEOUT_MS = 15_000;
|
|
|
23
40
|
export async function validateOpenAICompatibleApiKey(options: OpenAICompatibleValidationOptions): Promise<void> {
|
|
24
41
|
const timeoutSignal = AbortSignal.timeout(VALIDATION_TIMEOUT_MS);
|
|
25
42
|
const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
|
|
43
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
26
44
|
|
|
27
|
-
const response = await
|
|
45
|
+
const response = await fetchImpl(`${options.baseUrl}/chat/completions`, {
|
|
28
46
|
method: "POST",
|
|
29
47
|
headers: {
|
|
30
48
|
"Content-Type": "application/json",
|
|
@@ -56,6 +74,47 @@ export async function validateOpenAICompatibleApiKey(options: OpenAICompatibleVa
|
|
|
56
74
|
throw new Error(message);
|
|
57
75
|
}
|
|
58
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Validate an API key against an Anthropic-compatible messages endpoint.
|
|
79
|
+
*/
|
|
80
|
+
export async function validateAnthropicCompatibleApiKey(options: AnthropicCompatibleValidationOptions): Promise<void> {
|
|
81
|
+
const timeoutSignal = AbortSignal.timeout(VALIDATION_TIMEOUT_MS);
|
|
82
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
|
|
83
|
+
const baseUrl = normalizeAnthropicCompatibleBaseUrl(options.baseUrl);
|
|
84
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
85
|
+
|
|
86
|
+
const response = await fetchImpl(`${baseUrl}/v1/messages`, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: {
|
|
89
|
+
"Content-Type": "application/json",
|
|
90
|
+
"anthropic-version": "2023-06-01",
|
|
91
|
+
"x-api-key": options.apiKey,
|
|
92
|
+
},
|
|
93
|
+
body: JSON.stringify({
|
|
94
|
+
model: options.model,
|
|
95
|
+
messages: [{ role: "user", content: "ping" }],
|
|
96
|
+
max_tokens: 1,
|
|
97
|
+
}),
|
|
98
|
+
signal,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (response.ok) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let details = "";
|
|
106
|
+
try {
|
|
107
|
+
details = (await response.text()).trim();
|
|
108
|
+
} catch {
|
|
109
|
+
// ignore body parse errors, status is enough
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const message = details
|
|
113
|
+
? `${options.provider} API key validation failed (${response.status}): ${details}`
|
|
114
|
+
: `${options.provider} API key validation failed (${response.status})`;
|
|
115
|
+
throw new Error(message);
|
|
116
|
+
}
|
|
117
|
+
|
|
59
118
|
/**
|
|
60
119
|
* Validate an API key against a provider models endpoint.
|
|
61
120
|
*
|
|
@@ -65,8 +124,9 @@ export async function validateOpenAICompatibleApiKey(options: OpenAICompatibleVa
|
|
|
65
124
|
export async function validateApiKeyAgainstModelsEndpoint(options: ModelListValidationOptions): Promise<void> {
|
|
66
125
|
const timeoutSignal = AbortSignal.timeout(VALIDATION_TIMEOUT_MS);
|
|
67
126
|
const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
|
|
127
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
68
128
|
|
|
69
|
-
const response = await
|
|
129
|
+
const response = await fetchImpl(options.modelsUrl, {
|
|
70
130
|
method: "GET",
|
|
71
131
|
headers: {
|
|
72
132
|
Authorization: `Bearer ${options.apiKey}`,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/** Cerebras login flow (API key paste against https://api.cerebras.ai/v1). */
|
|
2
1
|
import { createApiKeyLogin } from "./api-key-login";
|
|
2
|
+
import type { OAuthLoginCallbacks } from "./oauth/types";
|
|
3
|
+
import type { ProviderDefinition } from "./types";
|
|
3
4
|
|
|
4
5
|
export const loginCerebras = createApiKeyLogin({
|
|
5
6
|
providerLabel: "Cerebras",
|
|
@@ -14,3 +15,9 @@ export const loginCerebras = createApiKeyLogin({
|
|
|
14
15
|
model: "gpt-oss-120b",
|
|
15
16
|
},
|
|
16
17
|
});
|
|
18
|
+
|
|
19
|
+
export const cerebrasProvider = {
|
|
20
|
+
id: "cerebras",
|
|
21
|
+
name: "Cerebras",
|
|
22
|
+
login: (cb: OAuthLoginCallbacks) => loginCerebras(cb),
|
|
23
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Cloudflare AI Gateway proxies upstream model providers.
|
|
5
|
-
*
|
|
6
|
-
* This is not OAuth - it's a simple API key flow:
|
|
7
|
-
* 1. Open Cloudflare AI Gateway docs/dashboard
|
|
8
|
-
* 2. User copies their Cloudflare AI Gateway token/API key
|
|
9
|
-
* 3. User pastes the API key into the CLI
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type { OAuthController } from "./types";
|
|
1
|
+
import type { OAuthController, OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
13
3
|
|
|
14
4
|
const AUTH_URL = "https://developers.cloudflare.com/ai-gateway/configuration/authentication/";
|
|
15
5
|
|
|
@@ -46,3 +36,9 @@ export async function loginCloudflareAiGateway(options: OAuthController): Promis
|
|
|
46
36
|
|
|
47
37
|
return trimmed;
|
|
48
38
|
}
|
|
39
|
+
|
|
40
|
+
export const cloudflareAiGatewayProvider = {
|
|
41
|
+
id: "cloudflare-ai-gateway",
|
|
42
|
+
name: "Cloudflare AI Gateway",
|
|
43
|
+
login: (cb: OAuthLoginCallbacks) => loginCloudflareAiGateway(cb),
|
|
44
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const cursorProvider = {
|
|
5
|
+
id: "cursor",
|
|
6
|
+
name: "Cursor (Claude, GPT, etc.)",
|
|
7
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
8
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
9
|
+
const { loginCursor } = await import("./oauth/cursor");
|
|
10
|
+
return loginCursor(
|
|
11
|
+
url => cb.onAuth({ url }),
|
|
12
|
+
cb.onProgress ? () => cb.onProgress?.("Waiting for browser authentication...") : undefined,
|
|
13
|
+
);
|
|
14
|
+
},
|
|
15
|
+
refreshToken: async (credentials: OAuthCredentials) => {
|
|
16
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
17
|
+
const { refreshCursorToken } = await import("./oauth/cursor");
|
|
18
|
+
return refreshCursorToken(credentials.refresh);
|
|
19
|
+
},
|
|
20
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DeepSeek login flow (API key paste against https://api.deepseek.com).
|
|
3
|
-
*
|
|
4
|
-
* Validation hits `GET /v1/models` so it authenticates the key without
|
|
5
|
-
* depending on a specific model being enabled on the account. The previous
|
|
6
|
-
* implementation issued a chat-completion against `deepseek-v4-pro`, which
|
|
7
|
-
* 404s for accounts without that preview model even when the key is valid.
|
|
8
|
-
*/
|
|
9
1
|
import { createApiKeyLogin } from "./api-key-login";
|
|
10
|
-
import type { OAuthController, OAuthPrompt } from "./types";
|
|
2
|
+
import type { OAuthController, OAuthLoginCallbacks, OAuthPrompt } from "./oauth/types";
|
|
3
|
+
import type { ProviderDefinition } from "./types";
|
|
11
4
|
|
|
12
5
|
const innerLogin = createApiKeyLogin({
|
|
13
6
|
providerLabel: "DeepSeek",
|
|
@@ -22,17 +15,10 @@ const innerLogin = createApiKeyLogin({
|
|
|
22
15
|
},
|
|
23
16
|
});
|
|
24
17
|
|
|
25
|
-
/**
|
|
26
|
-
* Normalize a pasted DeepSeek API key.
|
|
27
|
-
*
|
|
28
|
-
* Users frequently copy keys out of `curl` snippets that include the
|
|
29
|
-
* `Authorization: Bearer …` prefix. Strip it so validation does not fail
|
|
30
|
-
* with a confusing 401, and reject obviously empty input early.
|
|
31
|
-
*/
|
|
32
18
|
export function normalizeDeepSeekApiKey(raw: string): string {
|
|
33
19
|
const trimmed = raw.trim();
|
|
34
20
|
if (!trimmed) {
|
|
35
|
-
return trimmed;
|
|
21
|
+
return trimmed;
|
|
36
22
|
}
|
|
37
23
|
const stripped = trimmed.replace(/^bearer\b\s*/i, "");
|
|
38
24
|
if (!stripped) {
|
|
@@ -51,3 +37,9 @@ export const loginDeepSeek = async (options: OAuthController): Promise<string> =
|
|
|
51
37
|
: options;
|
|
52
38
|
return innerLogin(wrapped);
|
|
53
39
|
};
|
|
40
|
+
|
|
41
|
+
export const deepseekProvider = {
|
|
42
|
+
id: "deepseek",
|
|
43
|
+
name: "DeepSeek",
|
|
44
|
+
login: (cb: OAuthLoginCallbacks) => loginDeepSeek(cb),
|
|
45
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PROVIDER_REGISTRY } from "./registry";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Providers whose OAuth flow needs a pasted code/redirect URL rather than a
|
|
5
|
+
* local callback server. Consumed by the coding-agent login UX.
|
|
6
|
+
*/
|
|
7
|
+
export const PASTE_CODE_LOGIN_PROVIDERS: ReadonlySet<string> = new Set(
|
|
8
|
+
PROVIDER_REGISTRY.filter(p => p.pasteCodeFlow).map(p => p.id),
|
|
9
|
+
);
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createApiKeyLogin } from "./api-key-login";
|
|
2
|
+
import type { OAuthLoginCallbacks } from "./oauth/types";
|
|
3
|
+
import type { ProviderDefinition } from "./types";
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Fire Pass login flow.
|
|
3
7
|
*
|
|
@@ -7,8 +11,6 @@
|
|
|
7
11
|
* pings the chat completions endpoint with the router id directly.
|
|
8
12
|
* See https://docs.fireworks.ai/firepass.
|
|
9
13
|
*/
|
|
10
|
-
import { createApiKeyLogin } from "./api-key-login";
|
|
11
|
-
|
|
12
14
|
export const loginFirepass = createApiKeyLogin({
|
|
13
15
|
providerLabel: "Fire Pass",
|
|
14
16
|
authUrl: "https://app.fireworks.ai/settings/users/api-keys",
|
|
@@ -22,3 +24,9 @@ export const loginFirepass = createApiKeyLogin({
|
|
|
22
24
|
model: "accounts/fireworks/routers/kimi-k2p6-turbo",
|
|
23
25
|
},
|
|
24
26
|
});
|
|
27
|
+
|
|
28
|
+
export const firepassProvider = {
|
|
29
|
+
id: "firepass",
|
|
30
|
+
name: "Fire Pass (Fireworks Kimi K2.6 Turbo subscription)",
|
|
31
|
+
login: (cb: OAuthLoginCallbacks) => loginFirepass(cb),
|
|
32
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/** Fireworks login flow (API key paste against https://api.fireworks.ai/inference/v1). */
|
|
2
1
|
import { createApiKeyLogin } from "./api-key-login";
|
|
2
|
+
import type { OAuthLoginCallbacks } from "./oauth/types";
|
|
3
|
+
import type { ProviderDefinition } from "./types";
|
|
3
4
|
|
|
4
5
|
export const loginFireworks = createApiKeyLogin({
|
|
5
6
|
providerLabel: "Fireworks",
|
|
@@ -13,3 +14,9 @@ export const loginFireworks = createApiKeyLogin({
|
|
|
13
14
|
modelsUrl: "https://api.fireworks.ai/inference/v1/models",
|
|
14
15
|
},
|
|
15
16
|
});
|
|
17
|
+
|
|
18
|
+
export const fireworksProvider = {
|
|
19
|
+
id: "fireworks",
|
|
20
|
+
name: "Fireworks",
|
|
21
|
+
login: (cb: OAuthLoginCallbacks) => loginFireworks(cb),
|
|
22
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const githubCopilotProvider = {
|
|
5
|
+
id: "github-copilot",
|
|
6
|
+
name: "GitHub Copilot",
|
|
7
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
8
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
9
|
+
const { loginGitHubCopilot } = await import("./oauth/github-copilot");
|
|
10
|
+
return loginGitHubCopilot({
|
|
11
|
+
onAuth: (url, instructions) => cb.onAuth({ url, instructions }),
|
|
12
|
+
onPrompt: cb.onPrompt,
|
|
13
|
+
onProgress: cb.onProgress,
|
|
14
|
+
signal: cb.signal,
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
refreshToken: async (credentials: OAuthCredentials) => {
|
|
18
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
19
|
+
const { refreshGitHubCopilotToken } = await import("./oauth/github-copilot");
|
|
20
|
+
return refreshGitHubCopilotToken(credentials.refresh, credentials.enterpriseUrl);
|
|
21
|
+
},
|
|
22
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const gitlabDuoProvider = {
|
|
5
|
+
id: "gitlab-duo",
|
|
6
|
+
name: "GitLab Duo",
|
|
7
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
8
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
9
|
+
const { loginGitLabDuo } = await import("./oauth/gitlab-duo");
|
|
10
|
+
return loginGitLabDuo(cb);
|
|
11
|
+
},
|
|
12
|
+
refreshToken: async (credentials: OAuthCredentials) => {
|
|
13
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
14
|
+
const { refreshGitLabDuoToken } = await import("./oauth/gitlab-duo");
|
|
15
|
+
return refreshGitLabDuoToken(credentials);
|
|
16
|
+
},
|
|
17
|
+
callbackPort: 8080,
|
|
18
|
+
pasteCodeFlow: true,
|
|
19
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const googleAntigravityProvider = {
|
|
5
|
+
id: "google-antigravity",
|
|
6
|
+
name: "Antigravity (Gemini 3, Claude, GPT-OSS)",
|
|
7
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
8
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
9
|
+
const { loginAntigravity } = await import("./oauth/google-antigravity");
|
|
10
|
+
return loginAntigravity(cb);
|
|
11
|
+
},
|
|
12
|
+
refreshToken: async (credentials: OAuthCredentials) => {
|
|
13
|
+
if (!credentials.projectId) {
|
|
14
|
+
throw new Error("Antigravity credentials missing projectId");
|
|
15
|
+
}
|
|
16
|
+
const { refreshAntigravityToken } = await import("./oauth/google-antigravity");
|
|
17
|
+
return refreshAntigravityToken(credentials.refresh, credentials.projectId);
|
|
18
|
+
},
|
|
19
|
+
callbackPort: 51121,
|
|
20
|
+
pasteCodeFlow: true,
|
|
21
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const googleGeminiCliProvider = {
|
|
5
|
+
id: "google-gemini-cli",
|
|
6
|
+
name: "Google Cloud Code Assist (Gemini CLI)",
|
|
7
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
8
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
9
|
+
const { loginGeminiCli } = await import("./oauth/google-gemini-cli");
|
|
10
|
+
return loginGeminiCli(cb);
|
|
11
|
+
},
|
|
12
|
+
refreshToken: async (credentials: OAuthCredentials) => {
|
|
13
|
+
if (!credentials.projectId) {
|
|
14
|
+
throw new Error("Google Cloud credentials missing projectId");
|
|
15
|
+
}
|
|
16
|
+
const { refreshGoogleCloudToken } = await import("./oauth/google-gemini-cli");
|
|
17
|
+
return refreshGoogleCloudToken(credentials.refresh, credentials.projectId);
|
|
18
|
+
},
|
|
19
|
+
callbackPort: 8085,
|
|
20
|
+
pasteCodeFlow: true,
|
|
21
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { $env } from "@prometheus-ai/utils";
|
|
5
|
+
import type { ProviderDefinition } from "./types";
|
|
6
|
+
|
|
7
|
+
let cachedVertexAdcCredentialsExists: boolean | null = null;
|
|
8
|
+
|
|
9
|
+
function hasVertexAdcCredentials(): boolean {
|
|
10
|
+
if (cachedVertexAdcCredentialsExists === null) {
|
|
11
|
+
const gacPath = $env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
12
|
+
if (gacPath) {
|
|
13
|
+
cachedVertexAdcCredentialsExists = fs.existsSync(gacPath);
|
|
14
|
+
} else {
|
|
15
|
+
cachedVertexAdcCredentialsExists = fs.existsSync(
|
|
16
|
+
path.join(os.homedir(), ".config", "gcloud", "application_default_credentials.json"),
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return cachedVertexAdcCredentialsExists;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const googleVertexProvider = {
|
|
24
|
+
id: "google-vertex",
|
|
25
|
+
name: "Google Vertex AI",
|
|
26
|
+
// Vertex AI supports either GOOGLE_CLOUD_API_KEY or Application Default Credentials.
|
|
27
|
+
envKeys: () => {
|
|
28
|
+
if ($env.GOOGLE_CLOUD_API_KEY) {
|
|
29
|
+
return $env.GOOGLE_CLOUD_API_KEY;
|
|
30
|
+
}
|
|
31
|
+
const hasCredentials = hasVertexAdcCredentials();
|
|
32
|
+
const hasProject = !!($env.GOOGLE_CLOUD_PROJECT || $env.GCP_PROJECT || $env.GCLOUD_PROJECT);
|
|
33
|
+
const hasLocation = !!($env.GOOGLE_VERTEX_LOCATION || $env.GOOGLE_CLOUD_LOCATION || $env.VERTEX_LOCATION);
|
|
34
|
+
if (hasCredentials && hasProject && hasLocation) {
|
|
35
|
+
return "<authenticated>";
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
} as const satisfies ProviderDefinition;
|