@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,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MiniMax
|
|
2
|
+
* MiniMax Token Plan login flow.
|
|
3
3
|
*
|
|
4
|
-
* MiniMax
|
|
5
|
-
* MiniMax models (M2
|
|
4
|
+
* MiniMax Token Plan is a subscription service that provides access to
|
|
5
|
+
* MiniMax models (M2 and newer) through an OpenAI-compatible API.
|
|
6
6
|
*
|
|
7
7
|
* This is not OAuth - it's a simple API key flow:
|
|
8
8
|
* 1. Open browser to the matching regional MiniMax subscription page
|
|
@@ -13,23 +13,23 @@
|
|
|
13
13
|
* China: https://api.minimaxi.com/v1
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { validateOpenAICompatibleApiKey } from "
|
|
16
|
+
import { validateOpenAICompatibleApiKey } from "../api-key-validation";
|
|
17
17
|
import type { OAuthController } from "./types";
|
|
18
18
|
|
|
19
|
-
const AUTH_URL_INTL = "https://platform.minimax.io/subscribe/
|
|
20
|
-
const AUTH_URL_CN = "https://platform.minimaxi.com/subscribe/
|
|
19
|
+
const AUTH_URL_INTL = "https://platform.minimax.io/subscribe/token-plan";
|
|
20
|
+
const AUTH_URL_CN = "https://platform.minimaxi.com/subscribe/token-plan";
|
|
21
21
|
const API_BASE_URL_INTL = "https://api.minimax.io/v1";
|
|
22
22
|
const API_BASE_URL_CN = "https://api.minimaxi.com/v1";
|
|
23
|
-
const VALIDATION_MODEL = "MiniMax-
|
|
23
|
+
const VALIDATION_MODEL = "MiniMax-M3";
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Login to MiniMax
|
|
26
|
+
* Login to MiniMax Token Plan (international).
|
|
27
27
|
*
|
|
28
28
|
* Opens browser to subscription page, prompts user to paste their API key.
|
|
29
29
|
* Returns the API key directly (not OAuthCredentials - this isn't OAuth).
|
|
30
30
|
*/
|
|
31
31
|
export async function loginMiniMaxCode(options: OAuthController): Promise<string> {
|
|
32
|
-
return loginMiniMaxCodeWithBaseUrl(options, AUTH_URL_INTL, API_BASE_URL_INTL, "MiniMax
|
|
32
|
+
return loginMiniMaxCodeWithBaseUrl(options, AUTH_URL_INTL, API_BASE_URL_INTL, "MiniMax Token Plan");
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async function loginMiniMaxCodeWithBaseUrl(
|
|
@@ -38,17 +38,18 @@ async function loginMiniMaxCodeWithBaseUrl(
|
|
|
38
38
|
baseUrl: string,
|
|
39
39
|
providerName: string,
|
|
40
40
|
): Promise<string> {
|
|
41
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
41
42
|
if (!options.onPrompt) {
|
|
42
|
-
throw new Error("MiniMax
|
|
43
|
+
throw new Error("MiniMax Token Plan login requires onPrompt callback");
|
|
43
44
|
}
|
|
44
45
|
// Open browser to subscription page
|
|
45
46
|
options.onAuth?.({
|
|
46
47
|
url: authUrl,
|
|
47
|
-
instructions: "Subscribe to
|
|
48
|
+
instructions: "Subscribe to Token Plan and copy your API key",
|
|
48
49
|
});
|
|
49
50
|
// Prompt user to paste their API key
|
|
50
51
|
const apiKey = await options.onPrompt({
|
|
51
|
-
message: "Paste your MiniMax
|
|
52
|
+
message: "Paste your MiniMax Token Plan API key",
|
|
52
53
|
placeholder: "sk-...",
|
|
53
54
|
});
|
|
54
55
|
if (options.signal?.aborted) {
|
|
@@ -66,15 +67,16 @@ async function loginMiniMaxCodeWithBaseUrl(
|
|
|
66
67
|
baseUrl,
|
|
67
68
|
model: VALIDATION_MODEL,
|
|
68
69
|
signal: options.signal,
|
|
70
|
+
fetch: fetchImpl,
|
|
69
71
|
});
|
|
70
72
|
return trimmed;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
/**
|
|
74
|
-
* Login to MiniMax
|
|
76
|
+
* Login to MiniMax Token Plan (China).
|
|
75
77
|
*
|
|
76
78
|
* Same flow as international but uses China endpoint.
|
|
77
79
|
*/
|
|
78
80
|
export async function loginMiniMaxCodeCn(options: OAuthController): Promise<string> {
|
|
79
|
-
return loginMiniMaxCodeWithBaseUrl(options, AUTH_URL_CN, API_BASE_URL_CN, "MiniMax
|
|
81
|
+
return loginMiniMaxCodeWithBaseUrl(options, AUTH_URL_CN, API_BASE_URL_CN, "MiniMax Token Plan (China)");
|
|
80
82
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { FetchImpl } from "../../types";
|
|
2
|
+
import type { OAuthProviderUnion } from "../registry";
|
|
3
|
+
|
|
1
4
|
export type OAuthCredentials = {
|
|
2
5
|
refresh: string;
|
|
3
6
|
access: string;
|
|
@@ -8,57 +11,7 @@ export type OAuthCredentials = {
|
|
|
8
11
|
accountId?: string;
|
|
9
12
|
};
|
|
10
13
|
|
|
11
|
-
export type OAuthProvider =
|
|
12
|
-
| "alibaba-coding-plan"
|
|
13
|
-
| "anthropic"
|
|
14
|
-
| "cerebras"
|
|
15
|
-
| "cloudflare-ai-gateway"
|
|
16
|
-
| "cursor"
|
|
17
|
-
| "deepseek"
|
|
18
|
-
| "fireworks"
|
|
19
|
-
| "firepass"
|
|
20
|
-
| "github-copilot"
|
|
21
|
-
| "google-gemini-cli"
|
|
22
|
-
| "google-antigravity"
|
|
23
|
-
| "gitlab-duo"
|
|
24
|
-
| "huggingface"
|
|
25
|
-
| "kimi-code"
|
|
26
|
-
| "kilo"
|
|
27
|
-
| "kagi"
|
|
28
|
-
| "litellm"
|
|
29
|
-
| "lm-studio"
|
|
30
|
-
| "minimax-code"
|
|
31
|
-
| "minimax-code-cn"
|
|
32
|
-
| "moonshot"
|
|
33
|
-
| "nvidia"
|
|
34
|
-
| "nanogpt"
|
|
35
|
-
| "ollama"
|
|
36
|
-
| "ollama-cloud"
|
|
37
|
-
| "openai-codex"
|
|
38
|
-
| "openai-codex-device"
|
|
39
|
-
| "opencode-go"
|
|
40
|
-
| "openrouter"
|
|
41
|
-
| "opencode-zen"
|
|
42
|
-
| "parallel"
|
|
43
|
-
| "perplexity"
|
|
44
|
-
| "qianfan"
|
|
45
|
-
| "qwen-portal"
|
|
46
|
-
| "synthetic"
|
|
47
|
-
| "tavily"
|
|
48
|
-
| "together"
|
|
49
|
-
| "venice"
|
|
50
|
-
| "vercel-ai-gateway"
|
|
51
|
-
| "wafer-pass"
|
|
52
|
-
| "wafer-serverless"
|
|
53
|
-
| "vllm"
|
|
54
|
-
| "xai-oauth"
|
|
55
|
-
| "xiaomi"
|
|
56
|
-
| "xiaomi-token-plan-sgp"
|
|
57
|
-
| "xiaomi-token-plan-ams"
|
|
58
|
-
| "xiaomi-token-plan-cn"
|
|
59
|
-
| "zenmux"
|
|
60
|
-
| "zai"
|
|
61
|
-
| "zhipu-coding-plan";
|
|
14
|
+
export type OAuthProvider = OAuthProviderUnion;
|
|
62
15
|
|
|
63
16
|
export type OAuthProviderId = OAuthProvider | (string & {});
|
|
64
17
|
|
|
@@ -85,6 +38,7 @@ export interface OAuthController {
|
|
|
85
38
|
onManualCodeInput?(): Promise<string>;
|
|
86
39
|
onPrompt?(prompt: OAuthPrompt): Promise<string>;
|
|
87
40
|
signal?: AbortSignal;
|
|
41
|
+
fetch?: FetchImpl;
|
|
88
42
|
}
|
|
89
43
|
|
|
90
44
|
export interface OAuthLoginCallbacks extends OAuthController {
|
|
@@ -99,4 +53,6 @@ export interface OAuthProviderInterface {
|
|
|
99
53
|
login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials | string>;
|
|
100
54
|
refreshToken?(credentials: OAuthCredentials): Promise<OAuthCredentials>;
|
|
101
55
|
getApiKey?(credentials: OAuthCredentials): string;
|
|
56
|
+
/** Store resulting OAuth credentials under a different provider id. */
|
|
57
|
+
readonly storeCredentialsAs?: string;
|
|
102
58
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Validation uses the shared `/v1/models` endpoint, which works for both
|
|
19
19
|
* tiers and is cheap (no token spend).
|
|
20
20
|
*/
|
|
21
|
-
import { createApiKeyLogin } from "
|
|
21
|
+
import { createApiKeyLogin } from "../api-key-login";
|
|
22
22
|
|
|
23
23
|
const WAFER_AUTH_URL = "https://wafer.ai/dashboard";
|
|
24
24
|
const WAFER_MODELS_URL = "https://pass.wafer.ai/v1/models";
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* rejected on every call site, not just the first.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import type { FetchImpl } from "../../types";
|
|
13
14
|
import { OAuthCallbackFlow, type OAuthCallbackFlowOptions } from "./callback-server";
|
|
14
15
|
import { generatePKCE } from "./pkce";
|
|
15
16
|
import type { OAuthController, OAuthCredentials } from "./types";
|
|
@@ -70,10 +71,14 @@ export function validateXAIEndpoint(url: string, field: string): string {
|
|
|
70
71
|
*
|
|
71
72
|
* Hermes `_xai_oauth_discovery` L3038-3084.
|
|
72
73
|
*/
|
|
73
|
-
async function xaiOAuthDiscovery(
|
|
74
|
+
async function xaiOAuthDiscovery(
|
|
75
|
+
timeoutMs: number = DISCOVERY_TIMEOUT_MS,
|
|
76
|
+
fetchOverride?: FetchImpl,
|
|
77
|
+
): Promise<XAIOAuthDiscovery> {
|
|
78
|
+
const fetchImpl = fetchOverride ?? fetch;
|
|
74
79
|
let response: Response;
|
|
75
80
|
try {
|
|
76
|
-
response = await
|
|
81
|
+
response = await fetchImpl(XAI_OAUTH_DISCOVERY_URL, {
|
|
77
82
|
method: "GET",
|
|
78
83
|
headers: { Accept: "application/json" },
|
|
79
84
|
signal: AbortSignal.timeout(timeoutMs),
|
|
@@ -179,6 +184,7 @@ function buildXAIAuthorizeUrl(opts: BuildXAIAuthorizeUrlOptions): string {
|
|
|
179
184
|
*/
|
|
180
185
|
export class XAIOAuthFlow extends OAuthCallbackFlow {
|
|
181
186
|
#verifier: string = "";
|
|
187
|
+
#fetch: FetchImpl;
|
|
182
188
|
|
|
183
189
|
constructor(ctrl: OAuthController) {
|
|
184
190
|
super(ctrl, {
|
|
@@ -187,6 +193,7 @@ export class XAIOAuthFlow extends OAuthCallbackFlow {
|
|
|
187
193
|
callbackHostname: XAI_OAUTH_REDIRECT_HOST,
|
|
188
194
|
redirectUri: `http://${XAI_OAUTH_REDIRECT_HOST}:${XAI_OAUTH_REDIRECT_PORT}${XAI_OAUTH_REDIRECT_PATH}`,
|
|
189
195
|
} satisfies OAuthCallbackFlowOptions);
|
|
196
|
+
this.#fetch = ctrl.fetch ?? fetch;
|
|
190
197
|
}
|
|
191
198
|
|
|
192
199
|
async generateAuthUrl(state: string, redirectUri: string): Promise<{ url: string; instructions?: string }> {
|
|
@@ -194,7 +201,7 @@ export class XAIOAuthFlow extends OAuthCallbackFlow {
|
|
|
194
201
|
this.#verifier = pkce.verifier;
|
|
195
202
|
const nonce = crypto.randomUUID().replace(/-/g, "");
|
|
196
203
|
|
|
197
|
-
const discovery = await xaiOAuthDiscovery();
|
|
204
|
+
const discovery = await xaiOAuthDiscovery(DISCOVERY_TIMEOUT_MS, this.#fetch);
|
|
198
205
|
const url = buildXAIAuthorizeUrl({
|
|
199
206
|
authorizationEndpoint: discovery.authorization_endpoint,
|
|
200
207
|
redirectUri,
|
|
@@ -210,7 +217,7 @@ export class XAIOAuthFlow extends OAuthCallbackFlow {
|
|
|
210
217
|
}
|
|
211
218
|
|
|
212
219
|
async exchangeToken(code: string, _state: string, redirectUri: string): Promise<OAuthCredentials> {
|
|
213
|
-
const discovery = await xaiOAuthDiscovery();
|
|
220
|
+
const discovery = await xaiOAuthDiscovery(DISCOVERY_TIMEOUT_MS, this.#fetch);
|
|
214
221
|
const tokenEndpoint = validateXAIEndpoint(discovery.token_endpoint, "token_endpoint");
|
|
215
222
|
|
|
216
223
|
const body = new URLSearchParams({
|
|
@@ -221,7 +228,7 @@ export class XAIOAuthFlow extends OAuthCallbackFlow {
|
|
|
221
228
|
code_verifier: this.#verifier,
|
|
222
229
|
});
|
|
223
230
|
|
|
224
|
-
const response = await fetch(tokenEndpoint, {
|
|
231
|
+
const response = await this.#fetch(tokenEndpoint, {
|
|
225
232
|
method: "POST",
|
|
226
233
|
headers: {
|
|
227
234
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -282,12 +289,13 @@ export async function loginXAIOAuth(ctrl: OAuthController): Promise<OAuthCredent
|
|
|
282
289
|
* re-validates the cached `token_endpoint` on the refresh hot path so a
|
|
283
290
|
* cached-but-poisoned endpoint cannot silently leak a refresh_token.
|
|
284
291
|
*/
|
|
285
|
-
export async function refreshXAIOAuthToken(refreshToken: string): Promise<OAuthCredentials> {
|
|
292
|
+
export async function refreshXAIOAuthToken(refreshToken: string, fetchOverride?: FetchImpl): Promise<OAuthCredentials> {
|
|
293
|
+
const fetchImpl = fetchOverride ?? fetch;
|
|
286
294
|
if (typeof refreshToken !== "string" || !refreshToken.trim()) {
|
|
287
295
|
throw new Error("missing refresh_token");
|
|
288
296
|
}
|
|
289
297
|
|
|
290
|
-
const discovery = await xaiOAuthDiscovery();
|
|
298
|
+
const discovery = await xaiOAuthDiscovery(DISCOVERY_TIMEOUT_MS, fetchImpl);
|
|
291
299
|
const tokenEndpoint = validateXAIEndpoint(discovery.token_endpoint, "token_endpoint");
|
|
292
300
|
|
|
293
301
|
const body = new URLSearchParams({
|
|
@@ -296,7 +304,7 @@ export async function refreshXAIOAuthToken(refreshToken: string): Promise<OAuthC
|
|
|
296
304
|
refresh_token: refreshToken,
|
|
297
305
|
});
|
|
298
306
|
|
|
299
|
-
const response = await
|
|
307
|
+
const response = await fetchImpl(tokenEndpoint, {
|
|
300
308
|
method: "POST",
|
|
301
309
|
headers: {
|
|
302
310
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* login opens plan management so users copy the regional `tp-...` key.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import type { FetchImpl } from "../../types";
|
|
11
12
|
import type { OAuthController } from "./types";
|
|
12
13
|
|
|
13
14
|
const PROVIDER_ID = "xiaomi";
|
|
@@ -50,9 +51,11 @@ const VALIDATION_TIMEOUT_MS = 15_000;
|
|
|
50
51
|
|
|
51
52
|
async function validateXiaomiApiKey(
|
|
52
53
|
apiKey: string,
|
|
54
|
+
tokenPlanRegion: XiaomiTokenPlanRegion | undefined,
|
|
53
55
|
signal?: AbortSignal,
|
|
54
|
-
|
|
56
|
+
fetchOverride?: FetchImpl,
|
|
55
57
|
): Promise<void> {
|
|
58
|
+
const fetchImpl = fetchOverride ?? fetch;
|
|
56
59
|
// Region-specific Token Plan logins must validate against the selected
|
|
57
60
|
// cluster. Generic Xiaomi login keeps the historical SGP → AMS → CN fallback.
|
|
58
61
|
const endpoints = tokenPlanRegion
|
|
@@ -74,7 +77,7 @@ async function validateXiaomiApiKey(
|
|
|
74
77
|
const timeoutSignal = AbortSignal.timeout(VALIDATION_TIMEOUT_MS);
|
|
75
78
|
const requestSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
76
79
|
try {
|
|
77
|
-
const response = await
|
|
80
|
+
const response = await fetchImpl(`${ep.baseUrl}/chat/completions`, {
|
|
78
81
|
method: "POST",
|
|
79
82
|
headers: {
|
|
80
83
|
"Content-Type": "application/json",
|
|
@@ -139,6 +142,7 @@ async function validateXiaomiApiKey(
|
|
|
139
142
|
* Returns the API key directly (not OAuthCredentials - this isn't OAuth).
|
|
140
143
|
*/
|
|
141
144
|
export async function loginXiaomi(options: OAuthController): Promise<string> {
|
|
145
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
142
146
|
if (!options.onPrompt) {
|
|
143
147
|
throw new Error(`${PROVIDER_NAME} login requires onPrompt callback`);
|
|
144
148
|
}
|
|
@@ -159,7 +163,7 @@ export async function loginXiaomi(options: OAuthController): Promise<string> {
|
|
|
159
163
|
}
|
|
160
164
|
|
|
161
165
|
options.onProgress?.(`Validating ${PROVIDER_ID} API key...`);
|
|
162
|
-
await validateXiaomiApiKey(trimmed, options.signal);
|
|
166
|
+
await validateXiaomiApiKey(trimmed, undefined, options.signal, fetchImpl);
|
|
163
167
|
return trimmed;
|
|
164
168
|
}
|
|
165
169
|
|
|
@@ -169,6 +173,7 @@ export async function loginXiaomi(options: OAuthController): Promise<string> {
|
|
|
169
173
|
* Prompts for a token-plan API key and validates it against the selected region.
|
|
170
174
|
*/
|
|
171
175
|
export async function loginXiaomiTokenPlan(options: OAuthController, region: XiaomiTokenPlanRegion): Promise<string> {
|
|
176
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
172
177
|
if (!options.onPrompt) {
|
|
173
178
|
throw new Error(`Xiaomi Token Plan (${TOKEN_PLAN_REGION_NAMES[region]}) login requires onPrompt callback`);
|
|
174
179
|
}
|
|
@@ -189,6 +194,6 @@ export async function loginXiaomiTokenPlan(options: OAuthController, region: Xia
|
|
|
189
194
|
}
|
|
190
195
|
|
|
191
196
|
options.onProgress?.(`Validating Xiaomi Token Plan (${TOKEN_PLAN_REGION_NAMES[region]}) API key...`);
|
|
192
|
-
await validateXiaomiApiKey(trimmed, options.signal,
|
|
197
|
+
await validateXiaomiApiKey(trimmed, region, options.signal, fetchImpl);
|
|
193
198
|
return trimmed;
|
|
194
199
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { OAuthController } from "./types";
|
|
1
|
+
import type { OAuthController, OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
2
3
|
|
|
3
4
|
const OLLAMA_CLOUD_KEYS_URL = "https://ollama.com/settings/keys";
|
|
4
5
|
|
|
@@ -26,3 +27,9 @@ export async function loginOllamaCloud(options: OAuthController): Promise<string
|
|
|
26
27
|
}
|
|
27
28
|
return trimmed;
|
|
28
29
|
}
|
|
30
|
+
|
|
31
|
+
export const ollamaCloudProvider = {
|
|
32
|
+
id: "ollama-cloud",
|
|
33
|
+
name: "Ollama Cloud",
|
|
34
|
+
login: (cb: OAuthLoginCallbacks) => loginOllamaCloud(cb),
|
|
35
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Ollama is typically used locally without authentication, but some hosted
|
|
5
|
-
* deployments require a bearer token/API key.
|
|
6
|
-
*
|
|
7
|
-
* This flow is API-key based (not OAuth):
|
|
8
|
-
* 1. Optionally open Ollama docs
|
|
9
|
-
* 2. Prompt user for API key/token (optional)
|
|
10
|
-
* 3. Persist key only when provided
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type { OAuthController } from "./types";
|
|
1
|
+
import type { OAuthController } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
14
3
|
|
|
15
4
|
const OLLAMA_DOCS_URL = "https://github.com/ollama/ollama/blob/main/docs/api.md";
|
|
16
5
|
|
|
@@ -45,3 +34,9 @@ export async function loginOllama(options: OAuthController): Promise<string> {
|
|
|
45
34
|
|
|
46
35
|
return apiKey.trim();
|
|
47
36
|
}
|
|
37
|
+
|
|
38
|
+
export const ollamaProvider = {
|
|
39
|
+
id: "ollama",
|
|
40
|
+
name: "Ollama (Local OpenAI-compatible)",
|
|
41
|
+
login: loginOllama,
|
|
42
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const openaiCodexDeviceProvider = {
|
|
5
|
+
id: "openai-codex-device",
|
|
6
|
+
name: "ChatGPT Plus/Pro (Codex, headless/device)",
|
|
7
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
8
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
9
|
+
const { loginOpenAICodexDevice } = await import("./oauth/openai-codex");
|
|
10
|
+
return loginOpenAICodexDevice(cb);
|
|
11
|
+
},
|
|
12
|
+
refreshToken: async (credentials: OAuthCredentials) => {
|
|
13
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
14
|
+
const { refreshOpenAICodexToken } = await import("./oauth/openai-codex");
|
|
15
|
+
return refreshOpenAICodexToken(credentials.refresh);
|
|
16
|
+
},
|
|
17
|
+
storeCredentialsAs: "openai-codex",
|
|
18
|
+
} 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 openaiCodexProvider = {
|
|
5
|
+
id: "openai-codex",
|
|
6
|
+
name: "ChatGPT Plus/Pro (Codex Subscription)",
|
|
7
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
8
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
9
|
+
const { loginOpenAICodex } = await import("./oauth/openai-codex");
|
|
10
|
+
return loginOpenAICodex(cb);
|
|
11
|
+
},
|
|
12
|
+
refreshToken: async (credentials: OAuthCredentials) => {
|
|
13
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
14
|
+
const { refreshOpenAICodexToken } = await import("./oauth/openai-codex");
|
|
15
|
+
return refreshOpenAICodexToken(credentials.refresh);
|
|
16
|
+
},
|
|
17
|
+
callbackPort: 1455,
|
|
18
|
+
pasteCodeFlow: true,
|
|
19
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const opencodeGoProvider = {
|
|
5
|
+
id: "opencode-go",
|
|
6
|
+
name: "OpenCode Go",
|
|
7
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
8
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
9
|
+
const { loginOpenCode } = await import("./oauth/opencode");
|
|
10
|
+
return loginOpenCode(cb);
|
|
11
|
+
},
|
|
12
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const opencodeZenProvider = {
|
|
5
|
+
id: "opencode-zen",
|
|
6
|
+
name: "OpenCode Zen",
|
|
7
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
8
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
9
|
+
const { loginOpenCode } = await import("./oauth/opencode");
|
|
10
|
+
return loginOpenCode(cb);
|
|
11
|
+
},
|
|
12
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { createApiKeyLogin } from "./api-key-login";
|
|
2
|
+
import type { OAuthLoginCallbacks } from "./oauth/types";
|
|
3
|
+
import type { ProviderDefinition } from "./types";
|
|
4
|
+
|
|
1
5
|
/** OpenRouter login flow (API key paste, validated via /auth/key).
|
|
2
6
|
*
|
|
3
7
|
* `/api/v1/models` is public and returns 200 for any bearer (including bogus),
|
|
4
8
|
* so it cannot validate auth. `/api/v1/auth/key` is the canonical "who am I"
|
|
5
9
|
* endpoint — 200 for valid keys, 401 otherwise.
|
|
6
10
|
*/
|
|
7
|
-
import { createApiKeyLogin } from "./api-key-login";
|
|
8
|
-
|
|
9
11
|
export const loginOpenRouter = createApiKeyLogin({
|
|
10
12
|
providerLabel: "OpenRouter",
|
|
11
13
|
authUrl: "https://openrouter.ai/keys",
|
|
@@ -18,3 +20,9 @@ export const loginOpenRouter = createApiKeyLogin({
|
|
|
18
20
|
modelsUrl: "https://openrouter.ai/api/v1/auth/key",
|
|
19
21
|
},
|
|
20
22
|
});
|
|
23
|
+
|
|
24
|
+
export const openrouterProvider = {
|
|
25
|
+
id: "openrouter",
|
|
26
|
+
name: "OpenRouter",
|
|
27
|
+
login: (cb: OAuthLoginCallbacks) => loginOpenRouter(cb),
|
|
28
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Parallel uses an API key from the account settings page.
|
|
5
|
-
* This is an API key flow:
|
|
6
|
-
* 1. Open browser to Parallel API key settings
|
|
7
|
-
* 2. User copies API key
|
|
8
|
-
* 3. User pastes key into the CLI/TUI
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { OAuthController } from "./types";
|
|
1
|
+
import type { OAuthController, OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
12
3
|
|
|
13
4
|
const AUTH_URL = "https://platform.parallel.ai/settings?tab=api-keys";
|
|
14
5
|
|
|
@@ -44,3 +35,10 @@ export async function loginParallel(options: OAuthController): Promise<string> {
|
|
|
44
35
|
|
|
45
36
|
return trimmed;
|
|
46
37
|
}
|
|
38
|
+
|
|
39
|
+
export const parallelProvider = {
|
|
40
|
+
id: "parallel",
|
|
41
|
+
name: "Parallel",
|
|
42
|
+
envKeys: "PARALLEL_API_KEY",
|
|
43
|
+
login: (cb: OAuthLoginCallbacks) => loginParallel(cb),
|
|
44
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OAuthLoginCallbacks } from "./oauth/types";
|
|
2
|
+
import type { ProviderDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
export const perplexityProvider = {
|
|
5
|
+
id: "perplexity",
|
|
6
|
+
name: "Perplexity (Pro/Max)",
|
|
7
|
+
envKeys: "PERPLEXITY_API_KEY",
|
|
8
|
+
login: async (cb: OAuthLoginCallbacks) => {
|
|
9
|
+
// Lazy import: keep heavy OAuth flow modules out of the eager registry graph.
|
|
10
|
+
const { loginPerplexity } = await import("./oauth/perplexity");
|
|
11
|
+
return loginPerplexity(cb);
|
|
12
|
+
},
|
|
13
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Qianfan login flow.
|
|
3
|
-
*
|
|
4
|
-
* Qianfan provides an OpenAI-compatible API endpoint.
|
|
5
|
-
* Login is API-key based:
|
|
6
|
-
* 1. Open browser to Qianfan API key console
|
|
7
|
-
* 2. User copies API key
|
|
8
|
-
* 3. User pastes key into CLI prompt
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
1
|
import { validateOpenAICompatibleApiKey } from "./api-key-validation";
|
|
12
|
-
import type { OAuthController } from "./types";
|
|
2
|
+
import type { OAuthController, OAuthLoginCallbacks } from "./oauth/types";
|
|
3
|
+
import type { ProviderDefinition } from "./types";
|
|
13
4
|
|
|
14
5
|
const AUTH_URL = "https://console.bce.baidu.com/qianfan/ais/console/apiKey";
|
|
15
6
|
const API_BASE_URL = "https://qianfan.baidubce.com/v2";
|
|
16
7
|
const VALIDATION_MODEL = "deepseek-v3.2";
|
|
17
8
|
|
|
18
|
-
/**
|
|
19
|
-
* Login to Qianfan.
|
|
20
|
-
*
|
|
21
|
-
* Opens browser to API key page, prompts user to paste their API key.
|
|
22
|
-
* Returns the API key directly (not OAuthCredentials - this isn't OAuth).
|
|
23
|
-
*/
|
|
24
9
|
export async function loginQianfan(options: OAuthController): Promise<string> {
|
|
25
10
|
if (!options.onPrompt) {
|
|
26
11
|
throw new Error("Qianfan login requires onPrompt callback");
|
|
@@ -56,3 +41,9 @@ export async function loginQianfan(options: OAuthController): Promise<string> {
|
|
|
56
41
|
|
|
57
42
|
return trimmed;
|
|
58
43
|
}
|
|
44
|
+
|
|
45
|
+
export const qianfanProvider = {
|
|
46
|
+
id: "qianfan",
|
|
47
|
+
name: "Qianfan",
|
|
48
|
+
login: (cb: OAuthLoginCallbacks) => loginQianfan(cb),
|
|
49
|
+
} as const satisfies ProviderDefinition;
|
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Qwen Portal login flow.
|
|
3
|
-
*
|
|
4
|
-
* Qwen Portal exposes an OpenAI-compatible endpoint at https://portal.qwen.ai/v1
|
|
5
|
-
* and accepts OAuth bearer tokens or API keys.
|
|
6
|
-
*
|
|
7
|
-
* This is a token/API-key flow:
|
|
8
|
-
* 1. Open Qwen Portal
|
|
9
|
-
* 2. Copy either your OAuth token or API key
|
|
10
|
-
* 3. Paste it into the CLI
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
1
|
import { validateOpenAICompatibleApiKey } from "./api-key-validation";
|
|
14
|
-
import type { OAuthController } from "./types";
|
|
2
|
+
import type { OAuthController, OAuthLoginCallbacks } from "./oauth/types";
|
|
3
|
+
import type { ProviderDefinition } from "./types";
|
|
15
4
|
|
|
16
5
|
const AUTH_URL = "https://chat.qwen.ai";
|
|
17
6
|
const API_BASE_URL = "https://portal.qwen.ai/v1";
|
|
18
7
|
const VALIDATION_MODEL = "coder-model";
|
|
19
8
|
|
|
20
|
-
/**
|
|
21
|
-
* Login to Qwen Portal.
|
|
22
|
-
*
|
|
23
|
-
* Prompts for either `QWEN_OAUTH_TOKEN` or `QWEN_PORTAL_API_KEY` value.
|
|
24
|
-
* Returns the value directly (stored as api_key credential in auth storage).
|
|
25
|
-
*/
|
|
26
9
|
export async function loginQwenPortal(options: OAuthController): Promise<string> {
|
|
27
10
|
if (!options.onPrompt) {
|
|
28
11
|
throw new Error("Qwen Portal login requires onPrompt callback");
|
|
@@ -58,3 +41,9 @@ export async function loginQwenPortal(options: OAuthController): Promise<string>
|
|
|
58
41
|
|
|
59
42
|
return trimmed;
|
|
60
43
|
}
|
|
44
|
+
|
|
45
|
+
export const qwenPortalProvider = {
|
|
46
|
+
id: "qwen-portal",
|
|
47
|
+
name: "Qwen Portal",
|
|
48
|
+
login: (cb: OAuthLoginCallbacks) => loginQwenPortal(cb),
|
|
49
|
+
} as const satisfies ProviderDefinition;
|