@code-yeongyu/senpi-ai 2026.9.30 → 2026.10.1
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/README.md +189 -19
- package/dist/api/anthropic-messages.js +168 -32
- package/dist/api/azure-openai-responses.js +23 -10
- package/dist/api/bedrock-converse-stream.js +12 -4
- package/dist/api/cloudflare-workers-ai-system-one.d.ts +4 -0
- package/dist/api/cloudflare-workers-ai-system-one.js +43 -0
- package/dist/api/cloudflare-workers-ai-system-one.lazy.d.ts +3 -0
- package/dist/api/cloudflare-workers-ai-system-one.lazy.js +4 -0
- package/dist/api/cloudflare.d.ts +2 -0
- package/dist/api/cloudflare.js +2 -0
- package/dist/api/context-room.d.ts +2 -2
- package/dist/api/cursor-agent.js +19 -10
- package/dist/api/devin-agent/request.d.ts +9 -9
- package/dist/api/devin-agent/request.js +14 -10
- package/dist/api/google-generative-ai.js +20 -80
- package/dist/api/google-shared.d.ts +13 -4
- package/dist/api/google-shared.js +54 -4
- package/dist/api/google-vertex.js +19 -62
- package/dist/api/llama-cpp-classify.d.ts +33 -0
- package/dist/api/llama-cpp-classify.js +365 -0
- package/dist/api/llama-cpp-classify.lazy.d.ts +3 -0
- package/dist/api/llama-cpp-classify.lazy.js +4 -0
- package/dist/api/mistral-conversations.d.ts +1 -1
- package/dist/api/mistral-conversations.js +36 -29
- package/dist/api/openai-codex-responses.d.ts +1 -1
- package/dist/api/openai-codex-responses.js +72 -37
- package/dist/api/openai-completions.d.ts +3 -2
- package/dist/api/openai-completions.js +76 -50
- package/dist/api/openai-images-params.d.ts +2 -2
- package/dist/api/openai-images.d.ts +1 -1
- package/dist/api/openai-responses-shared.d.ts +31 -8
- package/dist/api/openai-responses-shared.js +115 -27
- package/dist/api/openai-responses.d.ts +1 -1
- package/dist/api/openai-responses.js +38 -33
- package/dist/api/openrouter-images.d.ts +2 -1
- package/dist/api/openrouter-images.js +1 -0
- package/dist/api/pi-messages.d.ts +3 -3
- package/dist/api/pi-messages.js +3 -2
- package/dist/api/simple-options.d.ts +2 -2
- package/dist/api/simple-options.js +1 -0
- package/dist/api/system-one-shared.d.ts +23 -0
- package/dist/api/system-one-shared.js +183 -0
- package/dist/api/transform-messages.js +5 -2
- package/dist/api/typesafe-system-one.d.ts +4 -0
- package/dist/api/typesafe-system-one.js +19 -0
- package/dist/api/typesafe-system-one.lazy.d.ts +3 -0
- package/dist/api/typesafe-system-one.lazy.js +4 -0
- package/dist/api-registry.d.ts +3 -3
- package/dist/auth/helpers.js +1 -1
- package/dist/auth/oauth/anthropic-callback-listener.js +1 -1
- package/dist/auth/oauth/callback-server.d.ts +55 -0
- package/dist/auth/oauth/callback-server.js +146 -0
- package/dist/auth/oauth/chatgpt-subscription.d.ts +1 -1
- package/dist/auth/oauth/chatgpt-subscription.js +20 -124
- package/dist/auth/oauth/devin-callback.js +1 -1
- package/dist/auth/oauth/load.d.ts +4 -0
- package/dist/auth/oauth/load.js +10 -0
- package/dist/auth/oauth/meta.d.ts +17 -0
- package/dist/auth/oauth/meta.js +190 -0
- package/dist/auth/oauth/openai-chatgpt.d.ts +9 -0
- package/dist/auth/oauth/openai-chatgpt.js +266 -0
- package/dist/auth/oauth/openrouter.d.ts +1 -1
- package/dist/auth/oauth/openrouter.js +19 -138
- package/dist/auth/oauth/radius.d.ts +1 -1
- package/dist/auth/oauth/radius.js +21 -89
- package/dist/auth/resolve.d.ts +3 -8
- package/dist/auth/resolve.js +3 -18
- package/dist/auth/types.d.ts +10 -1
- package/dist/bun-oauth.js +4 -0
- package/dist/cli.js +3 -1
- package/dist/compat.js +17 -14
- package/dist/env-api-keys.js +2 -0
- package/dist/image-models.d.ts +19 -8
- package/dist/image-models.js +14 -13
- package/dist/images-api-registry.d.ts +8 -8
- package/dist/images.d.ts +7 -2
- package/dist/images.js +5 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/model-catalog.d.ts +27 -9
- package/dist/model-catalog.js +24 -2
- package/dist/model.d.ts +13 -13
- package/dist/models-store.d.ts +3 -2
- package/dist/models.d.ts +106 -36
- package/dist/models.generated.d.ts +142 -42
- package/dist/models.generated.js +142 -42
- package/dist/models.js +174 -36
- package/dist/providers/alibaba-token-plan.models.d.ts +4 -2
- package/dist/providers/alibaba-token-plan.models.js +4 -2
- package/dist/providers/all.d.ts +72 -19
- package/dist/providers/all.js +28 -22
- package/dist/providers/amazon-bedrock.models.d.ts +4 -2
- package/dist/providers/amazon-bedrock.models.js +4 -2
- package/dist/providers/ant-ling.models.d.ts +4 -2
- package/dist/providers/ant-ling.models.js +4 -2
- package/dist/providers/anthropic.models.d.ts +4 -2
- package/dist/providers/anthropic.models.js +4 -2
- package/dist/providers/azure-openai-responses.models.d.ts +4 -2
- package/dist/providers/azure-openai-responses.models.js +4 -2
- package/dist/providers/bai.models.d.ts +4 -2
- package/dist/providers/bai.models.js +4 -2
- package/dist/providers/baseten.models.d.ts +4 -2
- package/dist/providers/baseten.models.js +4 -2
- package/dist/providers/cerebras.models.d.ts +4 -2
- package/dist/providers/cerebras.models.js +4 -2
- package/dist/providers/chatgpt-subscription.models.d.ts +4 -2
- package/dist/providers/chatgpt-subscription.models.js +4 -2
- package/dist/providers/cloudflare-ai-gateway.models.d.ts +4 -2
- package/dist/providers/cloudflare-ai-gateway.models.js +4 -2
- package/dist/providers/cloudflare-stream.d.ts +6 -2
- package/dist/providers/cloudflare-stream.js +6 -0
- package/dist/providers/cloudflare-workers-ai.js +10 -3
- package/dist/providers/cloudflare-workers-ai.models.d.ts +4 -2
- package/dist/providers/cloudflare-workers-ai.models.js +4 -2
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/alibaba-token-plan.json +1 -1
- package/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/providers/data/ant-ling.json +1 -1
- package/dist/providers/data/anthropic.json +1 -1
- package/dist/providers/data/azure-openai-responses.json +1 -1
- package/dist/providers/data/bai.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/cerebras.json +1 -1
- package/dist/providers/data/chatgpt-subscription.json +1 -1
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/providers/data/deepseek.json +1 -1
- package/dist/providers/data/fireworks.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/google-vertex.json +1 -1
- package/dist/providers/data/google.json +1 -1
- package/dist/providers/data/groq.json +1 -1
- package/dist/providers/data/huggingface.json +1 -1
- package/dist/providers/data/meta.json +1 -0
- package/dist/providers/data/minimax-cn.json +1 -1
- package/dist/providers/data/minimax.json +1 -1
- package/dist/providers/data/mistral.json +1 -1
- package/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/providers/data/moonshotai.json +1 -1
- package/dist/providers/data/nvidia.json +1 -1
- package/dist/providers/data/openai.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/opengateway.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/providers/data/qwen-token-plan.json +1 -1
- package/dist/providers/data/radius.json +1 -0
- package/dist/providers/data/together.json +1 -1
- package/dist/providers/data/typesafe.json +1 -0
- package/dist/providers/data/venice.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/data/xai.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/providers/data/xiaomi.json +1 -1
- package/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/providers/data/zai.json +1 -1
- package/dist/providers/deepseek.models.d.ts +4 -2
- package/dist/providers/deepseek.models.js +4 -2
- package/dist/providers/faux.d.ts +7 -2
- package/dist/providers/faux.js +31 -22
- package/dist/providers/fireworks.models.d.ts +4 -2
- package/dist/providers/fireworks.models.js +4 -2
- package/dist/providers/github-copilot.models.d.ts +4 -2
- package/dist/providers/github-copilot.models.js +4 -2
- package/dist/providers/google-vertex.models.d.ts +4 -2
- package/dist/providers/google-vertex.models.js +4 -2
- package/dist/providers/google.models.d.ts +4 -2
- package/dist/providers/google.models.js +4 -2
- package/dist/providers/groq.models.d.ts +4 -2
- package/dist/providers/groq.models.js +4 -2
- package/dist/providers/huggingface.models.d.ts +4 -2
- package/dist/providers/huggingface.models.js +4 -2
- package/dist/providers/images/register-builtins.d.ts +2 -2
- package/dist/providers/kimi-coding.models.d.ts +54 -7
- package/dist/providers/kimi-coding.models.js +34 -7
- package/dist/providers/meta.d.ts +3 -0
- package/dist/providers/meta.js +24 -0
- package/dist/providers/meta.models.d.ts +6 -0
- package/dist/providers/meta.models.js +8 -0
- package/dist/providers/minimax-cn.models.d.ts +4 -2
- package/dist/providers/minimax-cn.models.js +4 -2
- package/dist/providers/minimax.models.d.ts +4 -2
- package/dist/providers/minimax.models.js +4 -2
- package/dist/providers/mistral.models.d.ts +4 -2
- package/dist/providers/mistral.models.js +4 -2
- package/dist/providers/moonshotai-cn.models.d.ts +4 -2
- package/dist/providers/moonshotai-cn.models.js +4 -2
- package/dist/providers/moonshotai.models.d.ts +4 -2
- package/dist/providers/moonshotai.models.js +4 -2
- package/dist/providers/nvidia.models.d.ts +4 -2
- package/dist/providers/nvidia.models.js +4 -2
- package/dist/providers/openai.js +4 -2
- package/dist/providers/openai.models.d.ts +4 -2
- package/dist/providers/openai.models.js +4 -2
- package/dist/providers/opencode-go.models.d.ts +4 -2
- package/dist/providers/opencode-go.models.js +4 -2
- package/dist/providers/opencode.d.ts +3 -1
- package/dist/providers/opencode.js +5 -2
- package/dist/providers/opencode.models.d.ts +4 -2
- package/dist/providers/opencode.models.js +4 -2
- package/dist/providers/opengateway.models.d.ts +4 -2
- package/dist/providers/opengateway.models.js +4 -2
- package/dist/providers/openrouter.js +11 -2
- package/dist/providers/openrouter.models.d.ts +4 -2
- package/dist/providers/openrouter.models.js +4 -2
- package/dist/providers/qwen-token-plan-cn.models.d.ts +4 -2
- package/dist/providers/qwen-token-plan-cn.models.js +4 -2
- package/dist/providers/qwen-token-plan-individual.models.d.ts +4 -2
- package/dist/providers/qwen-token-plan-individual.models.js +4 -2
- package/dist/providers/qwen-token-plan.models.d.ts +4 -2
- package/dist/providers/qwen-token-plan.models.js +4 -2
- package/dist/providers/radius.js +19 -5
- package/dist/providers/radius.models.d.ts +6 -0
- package/dist/providers/radius.models.js +8 -0
- package/dist/providers/together.models.d.ts +4 -2
- package/dist/providers/together.models.js +4 -2
- package/dist/providers/typesafe.d.ts +3 -0
- package/dist/providers/typesafe.js +18 -0
- package/dist/providers/typesafe.models.d.ts +6 -0
- package/dist/providers/typesafe.models.js +8 -0
- package/dist/providers/venice.models.d.ts +4 -2
- package/dist/providers/venice.models.js +4 -2
- package/dist/providers/vercel-ai-gateway.js +5 -2
- package/dist/providers/vercel-ai-gateway.models.d.ts +4 -2
- package/dist/providers/vercel-ai-gateway.models.js +4 -2
- package/dist/providers/xai.models.d.ts +4 -2
- package/dist/providers/xai.models.js +4 -2
- package/dist/providers/xiaomi-token-plan-ams.models.d.ts +4 -2
- package/dist/providers/xiaomi-token-plan-ams.models.js +4 -2
- package/dist/providers/xiaomi-token-plan-cn.models.d.ts +4 -2
- package/dist/providers/xiaomi-token-plan-cn.models.js +4 -2
- package/dist/providers/xiaomi-token-plan-sgp.models.d.ts +4 -2
- package/dist/providers/xiaomi-token-plan-sgp.models.js +4 -2
- package/dist/providers/xiaomi.models.d.ts +4 -2
- package/dist/providers/xiaomi.models.js +4 -2
- package/dist/providers/zai-coding-cn.models.d.ts +4 -2
- package/dist/providers/zai-coding-cn.models.js +4 -2
- package/dist/providers/zai.models.d.ts +4 -2
- package/dist/providers/zai.models.js +4 -2
- package/dist/tool-call-middleware/context-transformer.d.ts +8 -5
- package/dist/tool-call-middleware/context-transformer.js +44 -15
- package/dist/types.d.ts +262 -28
- package/dist/utils/diagnostics.d.ts +3 -2
- package/dist/utils/estimate.d.ts +2 -2
- package/dist/utils/estimate.js +22 -30
- package/dist/utils/headers.d.ts +1 -1
- package/dist/utils/headers.js +10 -8
- package/dist/utils/model-operations.d.ts +11 -0
- package/dist/utils/model-operations.js +47 -0
- package/dist/utils/models-error.d.ts +8 -0
- package/dist/utils/models-error.js +18 -0
- package/dist/utils/overflow.d.ts +1 -0
- package/dist/utils/overflow.js +11 -5
- package/dist/utils/prompt-cache-ttl.js +10 -3
- package/dist/utils/retry.js +9 -0
- package/dist/utils/text.d.ts +9 -1
- package/dist/utils/text.js +26 -0
- package/dist/utils/transcript.d.ts +85 -0
- package/dist/utils/transcript.js +205 -0
- package/package.json +3 -4
- package/dist/image-models.generated.d.ts +0 -925
- package/dist/image-models.generated.js +0 -927
- package/dist/images-models.d.ts +0 -95
- package/dist/images-models.js +0 -141
- package/dist/providers/openai-images.d.ts +0 -3
- package/dist/providers/openai-images.js +0 -16
- package/dist/providers/openrouter-images.d.ts +0 -3
- package/dist/providers/openrouter-images.js +0 -22
- /package/dist/{auth/oauth → utils}/oauth-page.d.ts +0 -0
- /package/dist/{auth/oauth → utils}/oauth-page.js +0 -0
package/dist/models.generated.js
CHANGED
|
@@ -1,47 +1,50 @@
|
|
|
1
1
|
// This file is auto-generated by scripts/generate-models.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
|
-
import { ALIBABA_TOKEN_PLAN_MODELS } from "./providers/alibaba-token-plan.models.js";
|
|
4
|
-
import { AMAZON_BEDROCK_MODELS } from "./providers/amazon-bedrock.models.js";
|
|
5
|
-
import { ANT_LING_MODELS } from "./providers/ant-ling.models.js";
|
|
6
|
-
import { ANTHROPIC_MODELS } from "./providers/anthropic.models.js";
|
|
7
|
-
import { AZURE_OPENAI_RESPONSES_MODELS } from "./providers/azure-openai-responses.models.js";
|
|
8
|
-
import { BAI_MODELS } from "./providers/bai.models.js";
|
|
9
|
-
import { BASETEN_MODELS } from "./providers/baseten.models.js";
|
|
10
|
-
import { CEREBRAS_MODELS } from "./providers/cerebras.models.js";
|
|
11
|
-
import { CHATGPT_SUBSCRIPTION_MODELS } from "./providers/chatgpt-subscription.models.js";
|
|
12
|
-
import { CLOUDFLARE_AI_GATEWAY_MODELS } from "./providers/cloudflare-ai-gateway.models.js";
|
|
13
|
-
import { CLOUDFLARE_WORKERS_AI_MODELS } from "./providers/cloudflare-workers-ai.models.js";
|
|
14
|
-
import { DEEPSEEK_MODELS } from "./providers/deepseek.models.js";
|
|
15
|
-
import { FIREWORKS_MODELS } from "./providers/fireworks.models.js";
|
|
16
|
-
import { GITHUB_COPILOT_MODELS } from "./providers/github-copilot.models.js";
|
|
17
|
-
import { GOOGLE_MODELS } from "./providers/google.models.js";
|
|
18
|
-
import { GOOGLE_VERTEX_MODELS } from "./providers/google-vertex.models.js";
|
|
19
|
-
import { GROQ_MODELS } from "./providers/groq.models.js";
|
|
20
|
-
import { HUGGINGFACE_MODELS } from "./providers/huggingface.models.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
3
|
+
import { ALIBABA_TOKEN_PLAN_CLASSIFIER_MODELS, ALIBABA_TOKEN_PLAN_IMAGE_MODELS, ALIBABA_TOKEN_PLAN_MODELS } from "./providers/alibaba-token-plan.models.js";
|
|
4
|
+
import { AMAZON_BEDROCK_CLASSIFIER_MODELS, AMAZON_BEDROCK_IMAGE_MODELS, AMAZON_BEDROCK_MODELS } from "./providers/amazon-bedrock.models.js";
|
|
5
|
+
import { ANT_LING_CLASSIFIER_MODELS, ANT_LING_IMAGE_MODELS, ANT_LING_MODELS } from "./providers/ant-ling.models.js";
|
|
6
|
+
import { ANTHROPIC_CLASSIFIER_MODELS, ANTHROPIC_IMAGE_MODELS, ANTHROPIC_MODELS } from "./providers/anthropic.models.js";
|
|
7
|
+
import { AZURE_OPENAI_RESPONSES_CLASSIFIER_MODELS, AZURE_OPENAI_RESPONSES_IMAGE_MODELS, AZURE_OPENAI_RESPONSES_MODELS } from "./providers/azure-openai-responses.models.js";
|
|
8
|
+
import { BAI_CLASSIFIER_MODELS, BAI_IMAGE_MODELS, BAI_MODELS } from "./providers/bai.models.js";
|
|
9
|
+
import { BASETEN_CLASSIFIER_MODELS, BASETEN_IMAGE_MODELS, BASETEN_MODELS } from "./providers/baseten.models.js";
|
|
10
|
+
import { CEREBRAS_CLASSIFIER_MODELS, CEREBRAS_IMAGE_MODELS, CEREBRAS_MODELS } from "./providers/cerebras.models.js";
|
|
11
|
+
import { CHATGPT_SUBSCRIPTION_CLASSIFIER_MODELS, CHATGPT_SUBSCRIPTION_IMAGE_MODELS, CHATGPT_SUBSCRIPTION_MODELS } from "./providers/chatgpt-subscription.models.js";
|
|
12
|
+
import { CLOUDFLARE_AI_GATEWAY_CLASSIFIER_MODELS, CLOUDFLARE_AI_GATEWAY_IMAGE_MODELS, CLOUDFLARE_AI_GATEWAY_MODELS } from "./providers/cloudflare-ai-gateway.models.js";
|
|
13
|
+
import { CLOUDFLARE_WORKERS_AI_CLASSIFIER_MODELS, CLOUDFLARE_WORKERS_AI_IMAGE_MODELS, CLOUDFLARE_WORKERS_AI_MODELS } from "./providers/cloudflare-workers-ai.models.js";
|
|
14
|
+
import { DEEPSEEK_CLASSIFIER_MODELS, DEEPSEEK_IMAGE_MODELS, DEEPSEEK_MODELS } from "./providers/deepseek.models.js";
|
|
15
|
+
import { FIREWORKS_CLASSIFIER_MODELS, FIREWORKS_IMAGE_MODELS, FIREWORKS_MODELS } from "./providers/fireworks.models.js";
|
|
16
|
+
import { GITHUB_COPILOT_CLASSIFIER_MODELS, GITHUB_COPILOT_IMAGE_MODELS, GITHUB_COPILOT_MODELS } from "./providers/github-copilot.models.js";
|
|
17
|
+
import { GOOGLE_CLASSIFIER_MODELS, GOOGLE_IMAGE_MODELS, GOOGLE_MODELS } from "./providers/google.models.js";
|
|
18
|
+
import { GOOGLE_VERTEX_CLASSIFIER_MODELS, GOOGLE_VERTEX_IMAGE_MODELS, GOOGLE_VERTEX_MODELS } from "./providers/google-vertex.models.js";
|
|
19
|
+
import { GROQ_CLASSIFIER_MODELS, GROQ_IMAGE_MODELS, GROQ_MODELS } from "./providers/groq.models.js";
|
|
20
|
+
import { HUGGINGFACE_CLASSIFIER_MODELS, HUGGINGFACE_IMAGE_MODELS, HUGGINGFACE_MODELS } from "./providers/huggingface.models.js";
|
|
21
|
+
import { META_CLASSIFIER_MODELS, META_IMAGE_MODELS, META_MODELS } from "./providers/meta.models.js";
|
|
22
|
+
import { MINIMAX_CLASSIFIER_MODELS, MINIMAX_IMAGE_MODELS, MINIMAX_MODELS } from "./providers/minimax.models.js";
|
|
23
|
+
import { MINIMAX_CN_CLASSIFIER_MODELS, MINIMAX_CN_IMAGE_MODELS, MINIMAX_CN_MODELS } from "./providers/minimax-cn.models.js";
|
|
24
|
+
import { MISTRAL_CLASSIFIER_MODELS, MISTRAL_IMAGE_MODELS, MISTRAL_MODELS } from "./providers/mistral.models.js";
|
|
25
|
+
import { MOONSHOTAI_CLASSIFIER_MODELS, MOONSHOTAI_IMAGE_MODELS, MOONSHOTAI_MODELS } from "./providers/moonshotai.models.js";
|
|
26
|
+
import { MOONSHOTAI_CN_CLASSIFIER_MODELS, MOONSHOTAI_CN_IMAGE_MODELS, MOONSHOTAI_CN_MODELS } from "./providers/moonshotai-cn.models.js";
|
|
27
|
+
import { NVIDIA_CLASSIFIER_MODELS, NVIDIA_IMAGE_MODELS, NVIDIA_MODELS } from "./providers/nvidia.models.js";
|
|
28
|
+
import { OPENAI_CLASSIFIER_MODELS, OPENAI_IMAGE_MODELS, OPENAI_MODELS } from "./providers/openai.models.js";
|
|
29
|
+
import { OPENCODE_CLASSIFIER_MODELS, OPENCODE_IMAGE_MODELS, OPENCODE_MODELS } from "./providers/opencode.models.js";
|
|
30
|
+
import { OPENCODE_GO_CLASSIFIER_MODELS, OPENCODE_GO_IMAGE_MODELS, OPENCODE_GO_MODELS } from "./providers/opencode-go.models.js";
|
|
31
|
+
import { OPENGATEWAY_CLASSIFIER_MODELS, OPENGATEWAY_IMAGE_MODELS, OPENGATEWAY_MODELS } from "./providers/opengateway.models.js";
|
|
32
|
+
import { OPENROUTER_CLASSIFIER_MODELS, OPENROUTER_IMAGE_MODELS, OPENROUTER_MODELS } from "./providers/openrouter.models.js";
|
|
33
|
+
import { QWEN_TOKEN_PLAN_CLASSIFIER_MODELS, QWEN_TOKEN_PLAN_IMAGE_MODELS, QWEN_TOKEN_PLAN_MODELS } from "./providers/qwen-token-plan.models.js";
|
|
34
|
+
import { QWEN_TOKEN_PLAN_CN_CLASSIFIER_MODELS, QWEN_TOKEN_PLAN_CN_IMAGE_MODELS, QWEN_TOKEN_PLAN_CN_MODELS } from "./providers/qwen-token-plan-cn.models.js";
|
|
35
|
+
import { QWEN_TOKEN_PLAN_INDIVIDUAL_CLASSIFIER_MODELS, QWEN_TOKEN_PLAN_INDIVIDUAL_IMAGE_MODELS, QWEN_TOKEN_PLAN_INDIVIDUAL_MODELS } from "./providers/qwen-token-plan-individual.models.js";
|
|
36
|
+
import { RADIUS_CLASSIFIER_MODELS, RADIUS_IMAGE_MODELS, RADIUS_MODELS } from "./providers/radius.models.js";
|
|
37
|
+
import { TOGETHER_CLASSIFIER_MODELS, TOGETHER_IMAGE_MODELS, TOGETHER_MODELS } from "./providers/together.models.js";
|
|
38
|
+
import { TYPESAFE_CLASSIFIER_MODELS, TYPESAFE_IMAGE_MODELS, TYPESAFE_MODELS } from "./providers/typesafe.models.js";
|
|
39
|
+
import { VENICE_CLASSIFIER_MODELS, VENICE_IMAGE_MODELS, VENICE_MODELS } from "./providers/venice.models.js";
|
|
40
|
+
import { VERCEL_AI_GATEWAY_CLASSIFIER_MODELS, VERCEL_AI_GATEWAY_IMAGE_MODELS, VERCEL_AI_GATEWAY_MODELS } from "./providers/vercel-ai-gateway.models.js";
|
|
41
|
+
import { XAI_CLASSIFIER_MODELS, XAI_IMAGE_MODELS, XAI_MODELS } from "./providers/xai.models.js";
|
|
42
|
+
import { XIAOMI_CLASSIFIER_MODELS, XIAOMI_IMAGE_MODELS, XIAOMI_MODELS } from "./providers/xiaomi.models.js";
|
|
43
|
+
import { XIAOMI_TOKEN_PLAN_AMS_CLASSIFIER_MODELS, XIAOMI_TOKEN_PLAN_AMS_IMAGE_MODELS, XIAOMI_TOKEN_PLAN_AMS_MODELS } from "./providers/xiaomi-token-plan-ams.models.js";
|
|
44
|
+
import { XIAOMI_TOKEN_PLAN_CN_CLASSIFIER_MODELS, XIAOMI_TOKEN_PLAN_CN_IMAGE_MODELS, XIAOMI_TOKEN_PLAN_CN_MODELS } from "./providers/xiaomi-token-plan-cn.models.js";
|
|
45
|
+
import { XIAOMI_TOKEN_PLAN_SGP_CLASSIFIER_MODELS, XIAOMI_TOKEN_PLAN_SGP_IMAGE_MODELS, XIAOMI_TOKEN_PLAN_SGP_MODELS } from "./providers/xiaomi-token-plan-sgp.models.js";
|
|
46
|
+
import { ZAI_CLASSIFIER_MODELS, ZAI_IMAGE_MODELS, ZAI_MODELS } from "./providers/zai.models.js";
|
|
47
|
+
import { ZAI_CODING_CN_CLASSIFIER_MODELS, ZAI_CODING_CN_IMAGE_MODELS, ZAI_CODING_CN_MODELS } from "./providers/zai-coding-cn.models.js";
|
|
45
48
|
export const MODELS = {
|
|
46
49
|
"alibaba-token-plan": ALIBABA_TOKEN_PLAN_MODELS,
|
|
47
50
|
"amazon-bedrock": AMAZON_BEDROCK_MODELS,
|
|
@@ -61,6 +64,7 @@ export const MODELS = {
|
|
|
61
64
|
"google-vertex": GOOGLE_VERTEX_MODELS,
|
|
62
65
|
"groq": GROQ_MODELS,
|
|
63
66
|
"huggingface": HUGGINGFACE_MODELS,
|
|
67
|
+
"meta": META_MODELS,
|
|
64
68
|
"minimax": MINIMAX_MODELS,
|
|
65
69
|
"minimax-cn": MINIMAX_CN_MODELS,
|
|
66
70
|
"mistral": MISTRAL_MODELS,
|
|
@@ -75,7 +79,9 @@ export const MODELS = {
|
|
|
75
79
|
"qwen-token-plan": QWEN_TOKEN_PLAN_MODELS,
|
|
76
80
|
"qwen-token-plan-cn": QWEN_TOKEN_PLAN_CN_MODELS,
|
|
77
81
|
"qwen-token-plan-individual": QWEN_TOKEN_PLAN_INDIVIDUAL_MODELS,
|
|
82
|
+
"radius": RADIUS_MODELS,
|
|
78
83
|
"together": TOGETHER_MODELS,
|
|
84
|
+
"typesafe": TYPESAFE_MODELS,
|
|
79
85
|
"venice": VENICE_MODELS,
|
|
80
86
|
"vercel-ai-gateway": VERCEL_AI_GATEWAY_MODELS,
|
|
81
87
|
"xai": XAI_MODELS,
|
|
@@ -86,4 +92,98 @@ export const MODELS = {
|
|
|
86
92
|
"zai": ZAI_MODELS,
|
|
87
93
|
"zai-coding-cn": ZAI_CODING_CN_MODELS,
|
|
88
94
|
};
|
|
95
|
+
export const IMAGE_MODELS = {
|
|
96
|
+
"alibaba-token-plan": ALIBABA_TOKEN_PLAN_IMAGE_MODELS,
|
|
97
|
+
"amazon-bedrock": AMAZON_BEDROCK_IMAGE_MODELS,
|
|
98
|
+
"ant-ling": ANT_LING_IMAGE_MODELS,
|
|
99
|
+
"anthropic": ANTHROPIC_IMAGE_MODELS,
|
|
100
|
+
"azure-openai-responses": AZURE_OPENAI_RESPONSES_IMAGE_MODELS,
|
|
101
|
+
"bai": BAI_IMAGE_MODELS,
|
|
102
|
+
"baseten": BASETEN_IMAGE_MODELS,
|
|
103
|
+
"cerebras": CEREBRAS_IMAGE_MODELS,
|
|
104
|
+
"chatgpt-subscription": CHATGPT_SUBSCRIPTION_IMAGE_MODELS,
|
|
105
|
+
"cloudflare-ai-gateway": CLOUDFLARE_AI_GATEWAY_IMAGE_MODELS,
|
|
106
|
+
"cloudflare-workers-ai": CLOUDFLARE_WORKERS_AI_IMAGE_MODELS,
|
|
107
|
+
"deepseek": DEEPSEEK_IMAGE_MODELS,
|
|
108
|
+
"fireworks": FIREWORKS_IMAGE_MODELS,
|
|
109
|
+
"github-copilot": GITHUB_COPILOT_IMAGE_MODELS,
|
|
110
|
+
"google": GOOGLE_IMAGE_MODELS,
|
|
111
|
+
"google-vertex": GOOGLE_VERTEX_IMAGE_MODELS,
|
|
112
|
+
"groq": GROQ_IMAGE_MODELS,
|
|
113
|
+
"huggingface": HUGGINGFACE_IMAGE_MODELS,
|
|
114
|
+
"meta": META_IMAGE_MODELS,
|
|
115
|
+
"minimax": MINIMAX_IMAGE_MODELS,
|
|
116
|
+
"minimax-cn": MINIMAX_CN_IMAGE_MODELS,
|
|
117
|
+
"mistral": MISTRAL_IMAGE_MODELS,
|
|
118
|
+
"moonshotai": MOONSHOTAI_IMAGE_MODELS,
|
|
119
|
+
"moonshotai-cn": MOONSHOTAI_CN_IMAGE_MODELS,
|
|
120
|
+
"nvidia": NVIDIA_IMAGE_MODELS,
|
|
121
|
+
"openai": OPENAI_IMAGE_MODELS,
|
|
122
|
+
"opencode": OPENCODE_IMAGE_MODELS,
|
|
123
|
+
"opencode-go": OPENCODE_GO_IMAGE_MODELS,
|
|
124
|
+
"opengateway": OPENGATEWAY_IMAGE_MODELS,
|
|
125
|
+
"openrouter": OPENROUTER_IMAGE_MODELS,
|
|
126
|
+
"qwen-token-plan": QWEN_TOKEN_PLAN_IMAGE_MODELS,
|
|
127
|
+
"qwen-token-plan-cn": QWEN_TOKEN_PLAN_CN_IMAGE_MODELS,
|
|
128
|
+
"qwen-token-plan-individual": QWEN_TOKEN_PLAN_INDIVIDUAL_IMAGE_MODELS,
|
|
129
|
+
"radius": RADIUS_IMAGE_MODELS,
|
|
130
|
+
"together": TOGETHER_IMAGE_MODELS,
|
|
131
|
+
"typesafe": TYPESAFE_IMAGE_MODELS,
|
|
132
|
+
"venice": VENICE_IMAGE_MODELS,
|
|
133
|
+
"vercel-ai-gateway": VERCEL_AI_GATEWAY_IMAGE_MODELS,
|
|
134
|
+
"xai": XAI_IMAGE_MODELS,
|
|
135
|
+
"xiaomi": XIAOMI_IMAGE_MODELS,
|
|
136
|
+
"xiaomi-token-plan-ams": XIAOMI_TOKEN_PLAN_AMS_IMAGE_MODELS,
|
|
137
|
+
"xiaomi-token-plan-cn": XIAOMI_TOKEN_PLAN_CN_IMAGE_MODELS,
|
|
138
|
+
"xiaomi-token-plan-sgp": XIAOMI_TOKEN_PLAN_SGP_IMAGE_MODELS,
|
|
139
|
+
"zai": ZAI_IMAGE_MODELS,
|
|
140
|
+
"zai-coding-cn": ZAI_CODING_CN_IMAGE_MODELS,
|
|
141
|
+
};
|
|
142
|
+
export const CLASSIFIER_MODELS = {
|
|
143
|
+
"alibaba-token-plan": ALIBABA_TOKEN_PLAN_CLASSIFIER_MODELS,
|
|
144
|
+
"amazon-bedrock": AMAZON_BEDROCK_CLASSIFIER_MODELS,
|
|
145
|
+
"ant-ling": ANT_LING_CLASSIFIER_MODELS,
|
|
146
|
+
"anthropic": ANTHROPIC_CLASSIFIER_MODELS,
|
|
147
|
+
"azure-openai-responses": AZURE_OPENAI_RESPONSES_CLASSIFIER_MODELS,
|
|
148
|
+
"bai": BAI_CLASSIFIER_MODELS,
|
|
149
|
+
"baseten": BASETEN_CLASSIFIER_MODELS,
|
|
150
|
+
"cerebras": CEREBRAS_CLASSIFIER_MODELS,
|
|
151
|
+
"chatgpt-subscription": CHATGPT_SUBSCRIPTION_CLASSIFIER_MODELS,
|
|
152
|
+
"cloudflare-ai-gateway": CLOUDFLARE_AI_GATEWAY_CLASSIFIER_MODELS,
|
|
153
|
+
"cloudflare-workers-ai": CLOUDFLARE_WORKERS_AI_CLASSIFIER_MODELS,
|
|
154
|
+
"deepseek": DEEPSEEK_CLASSIFIER_MODELS,
|
|
155
|
+
"fireworks": FIREWORKS_CLASSIFIER_MODELS,
|
|
156
|
+
"github-copilot": GITHUB_COPILOT_CLASSIFIER_MODELS,
|
|
157
|
+
"google": GOOGLE_CLASSIFIER_MODELS,
|
|
158
|
+
"google-vertex": GOOGLE_VERTEX_CLASSIFIER_MODELS,
|
|
159
|
+
"groq": GROQ_CLASSIFIER_MODELS,
|
|
160
|
+
"huggingface": HUGGINGFACE_CLASSIFIER_MODELS,
|
|
161
|
+
"meta": META_CLASSIFIER_MODELS,
|
|
162
|
+
"minimax": MINIMAX_CLASSIFIER_MODELS,
|
|
163
|
+
"minimax-cn": MINIMAX_CN_CLASSIFIER_MODELS,
|
|
164
|
+
"mistral": MISTRAL_CLASSIFIER_MODELS,
|
|
165
|
+
"moonshotai": MOONSHOTAI_CLASSIFIER_MODELS,
|
|
166
|
+
"moonshotai-cn": MOONSHOTAI_CN_CLASSIFIER_MODELS,
|
|
167
|
+
"nvidia": NVIDIA_CLASSIFIER_MODELS,
|
|
168
|
+
"openai": OPENAI_CLASSIFIER_MODELS,
|
|
169
|
+
"opencode": OPENCODE_CLASSIFIER_MODELS,
|
|
170
|
+
"opencode-go": OPENCODE_GO_CLASSIFIER_MODELS,
|
|
171
|
+
"opengateway": OPENGATEWAY_CLASSIFIER_MODELS,
|
|
172
|
+
"openrouter": OPENROUTER_CLASSIFIER_MODELS,
|
|
173
|
+
"qwen-token-plan": QWEN_TOKEN_PLAN_CLASSIFIER_MODELS,
|
|
174
|
+
"qwen-token-plan-cn": QWEN_TOKEN_PLAN_CN_CLASSIFIER_MODELS,
|
|
175
|
+
"qwen-token-plan-individual": QWEN_TOKEN_PLAN_INDIVIDUAL_CLASSIFIER_MODELS,
|
|
176
|
+
"radius": RADIUS_CLASSIFIER_MODELS,
|
|
177
|
+
"together": TOGETHER_CLASSIFIER_MODELS,
|
|
178
|
+
"typesafe": TYPESAFE_CLASSIFIER_MODELS,
|
|
179
|
+
"venice": VENICE_CLASSIFIER_MODELS,
|
|
180
|
+
"vercel-ai-gateway": VERCEL_AI_GATEWAY_CLASSIFIER_MODELS,
|
|
181
|
+
"xai": XAI_CLASSIFIER_MODELS,
|
|
182
|
+
"xiaomi": XIAOMI_CLASSIFIER_MODELS,
|
|
183
|
+
"xiaomi-token-plan-ams": XIAOMI_TOKEN_PLAN_AMS_CLASSIFIER_MODELS,
|
|
184
|
+
"xiaomi-token-plan-cn": XIAOMI_TOKEN_PLAN_CN_CLASSIFIER_MODELS,
|
|
185
|
+
"xiaomi-token-plan-sgp": XIAOMI_TOKEN_PLAN_SGP_CLASSIFIER_MODELS,
|
|
186
|
+
"zai": ZAI_CLASSIFIER_MODELS,
|
|
187
|
+
"zai-coding-cn": ZAI_CODING_CN_CLASSIFIER_MODELS,
|
|
188
|
+
};
|
|
89
189
|
//# sourceMappingURL=models.generated.js.map
|
package/dist/models.js
CHANGED
|
@@ -4,9 +4,22 @@ import { InMemoryCredentialStore } from "./auth/credential-store.js";
|
|
|
4
4
|
import { appendLoginSlot, removeSlot } from "./auth/pool/slots.js";
|
|
5
5
|
import { resolveRefreshCredential } from "./auth/refresh-credential.js";
|
|
6
6
|
import { ModelsError, providerNotConfiguredMessage, resolveProviderAuth, } from "./auth/resolve.js";
|
|
7
|
+
import { builtinCatalogAdvertisesMax } from "./model-catalog.js";
|
|
7
8
|
import { InMemoryModelsStore } from "./models-store.js";
|
|
8
9
|
import { operationSignal, raceWithAbortSignal } from "./utils/abort.js";
|
|
10
|
+
import { assertChatModel, assertClassifierModel, assertImageModel, classifierErrorResult, getModelType, imageErrorResult, isModelType, } from "./utils/model-operations.js";
|
|
11
|
+
import { normalizeContext } from "./utils/transcript.js";
|
|
9
12
|
export { ModelsError, PROVIDER_NOT_CONFIGURED_PREFIX, providerNotConfiguredMessage, } from "./auth/resolve.js";
|
|
13
|
+
export { getModelType, isModelType } from "./utils/model-operations.js";
|
|
14
|
+
const KNOWN_MODEL_TYPES = { chat: true, image: true, classifier: true };
|
|
15
|
+
/** Models from stores and remote sources may have types that only newer versions know. */
|
|
16
|
+
function hasKnownModelType(model) {
|
|
17
|
+
return Object.hasOwn(KNOWN_MODEL_TYPES, getModelType(model));
|
|
18
|
+
}
|
|
19
|
+
/** Drops stored models whose type this version does not know. */
|
|
20
|
+
function withKnownModelTypes(entry) {
|
|
21
|
+
return { ...entry, models: entry.models.filter(hasKnownModelType) };
|
|
22
|
+
}
|
|
10
23
|
function mergeHeaders(base, override) {
|
|
11
24
|
if (!base && !override)
|
|
12
25
|
return undefined;
|
|
@@ -74,9 +87,38 @@ class ModelsImpl {
|
|
|
74
87
|
}
|
|
75
88
|
return models;
|
|
76
89
|
}
|
|
90
|
+
getAllModels(provider) {
|
|
91
|
+
if (provider !== undefined) {
|
|
92
|
+
const entry = this.providers.get(provider);
|
|
93
|
+
if (!entry)
|
|
94
|
+
return [];
|
|
95
|
+
try {
|
|
96
|
+
return entry.getAllModels?.() ?? entry.getModels();
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const models = [];
|
|
103
|
+
for (const entry of this.providers.values()) {
|
|
104
|
+
try {
|
|
105
|
+
models.push(...(entry.getAllModels?.() ?? entry.getModels()));
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Best-effort: ill-behaved providers yield no models.
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return models;
|
|
112
|
+
}
|
|
113
|
+
getModelsOfType(type, provider) {
|
|
114
|
+
return this.getAllModels(provider).filter((model) => isModelType(model, type));
|
|
115
|
+
}
|
|
77
116
|
getModel(provider, id) {
|
|
78
117
|
return this.getModels(provider).find((model) => model.id === id);
|
|
79
118
|
}
|
|
119
|
+
getModelOfType(type, provider, id) {
|
|
120
|
+
return this.getModelsOfType(type, provider).find((model) => model.id === id);
|
|
121
|
+
}
|
|
80
122
|
supersedeProviderRefresh(providerId) {
|
|
81
123
|
const generation = (this.refreshGenerations.get(providerId) ?? 0) + 1;
|
|
82
124
|
this.refreshGenerations.set(providerId, generation);
|
|
@@ -122,7 +164,7 @@ class ModelsImpl {
|
|
|
122
164
|
const stored = await this.modelsStore.read(provider.id, { signal });
|
|
123
165
|
await provider.refreshModels({
|
|
124
166
|
credential,
|
|
125
|
-
stored: stored ? structuredClone(stored) : undefined,
|
|
167
|
+
stored: stored ? withKnownModelTypes(structuredClone(stored)) : undefined,
|
|
126
168
|
publish: (publication) => this.publishProviderModels(provider.id, generation, signal, publication),
|
|
127
169
|
allowNetwork,
|
|
128
170
|
force: allowNetwork ? force : undefined,
|
|
@@ -250,26 +292,47 @@ class ModelsImpl {
|
|
|
250
292
|
})();
|
|
251
293
|
return raceWithAbortSignal(check, signal);
|
|
252
294
|
}
|
|
295
|
+
async getAuthenticatedProviders(providerId, signal) {
|
|
296
|
+
signal.throwIfAborted();
|
|
297
|
+
const providers = providerId
|
|
298
|
+
? [this.providers.get(providerId)].filter((entry) => entry !== undefined)
|
|
299
|
+
: this.getProviders();
|
|
300
|
+
const checks = await Promise.all(providers.map(async (provider) => {
|
|
301
|
+
const credential = await this.readCredential(provider.id, signal);
|
|
302
|
+
return { provider, credential, auth: await this.checkProviderAuth(provider, credential, signal) };
|
|
303
|
+
}));
|
|
304
|
+
return checks.filter((entry) => entry.auth !== undefined);
|
|
305
|
+
}
|
|
253
306
|
getAvailable(providerId, options) {
|
|
254
307
|
const signal = operationSignal(options?.signal);
|
|
255
308
|
const available = (async () => {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
? [this.providers.get(providerId)].filter((entry) => entry !== undefined)
|
|
259
|
-
: this.getProviders();
|
|
260
|
-
const checks = await Promise.all(providers.map(async (provider) => {
|
|
261
|
-
const credential = await this.readCredential(provider.id, signal);
|
|
262
|
-
return { provider, credential, auth: await this.checkProviderAuth(provider, credential, signal) };
|
|
263
|
-
}));
|
|
264
|
-
return checks.flatMap(({ provider, credential, auth }) => {
|
|
265
|
-
if (!auth)
|
|
266
|
-
return [];
|
|
309
|
+
const providers = await this.getAuthenticatedProviders(providerId, signal);
|
|
310
|
+
return providers.flatMap(({ provider, credential }) => {
|
|
267
311
|
const models = provider.getModels();
|
|
268
312
|
return provider.filterModels?.(models, credential) ?? models;
|
|
269
313
|
});
|
|
270
314
|
})();
|
|
271
315
|
return raceWithAbortSignal(available, signal);
|
|
272
316
|
}
|
|
317
|
+
async getAvailableOfType(type, providerId, options) {
|
|
318
|
+
return (await this.getAllAvailable(providerId, options)).filter((model) => isModelType(model, type));
|
|
319
|
+
}
|
|
320
|
+
getAllAvailable(providerId, options) {
|
|
321
|
+
const signal = operationSignal(options?.signal);
|
|
322
|
+
const available = (async () => {
|
|
323
|
+
const providers = await this.getAuthenticatedProviders(providerId, signal);
|
|
324
|
+
return providers.flatMap(({ provider, credential }) => {
|
|
325
|
+
const models = provider.getAllModels?.() ?? provider.getModels();
|
|
326
|
+
if (provider.filterAllModels)
|
|
327
|
+
return provider.filterAllModels(models, credential);
|
|
328
|
+
if (!provider.filterModels)
|
|
329
|
+
return models;
|
|
330
|
+
const availableChatIds = new Set(provider.filterModels(provider.getModels(), credential).map((model) => model.id));
|
|
331
|
+
return models.filter((model) => !isModelType(model, "chat") || availableChatIds.has(model.id));
|
|
332
|
+
});
|
|
333
|
+
})();
|
|
334
|
+
return raceWithAbortSignal(available, signal);
|
|
335
|
+
}
|
|
273
336
|
async getAuth(providerOrModel, overrides) {
|
|
274
337
|
const signal = operationSignal(overrides?.signal);
|
|
275
338
|
const providerId = typeof providerOrModel === "string" ? providerOrModel : providerOrModel.provider;
|
|
@@ -287,7 +350,7 @@ class ModelsImpl {
|
|
|
287
350
|
},
|
|
288
351
|
};
|
|
289
352
|
}
|
|
290
|
-
async login(providerId, type, interaction) {
|
|
353
|
+
async login(providerId, type, interaction, options) {
|
|
291
354
|
const signal = operationSignal(interaction.signal);
|
|
292
355
|
signal.throwIfAborted();
|
|
293
356
|
const provider = this.providers.get(providerId);
|
|
@@ -298,7 +361,7 @@ class ModelsImpl {
|
|
|
298
361
|
throw new ModelsError("auth", `${provider.name} does not support ${type} login`);
|
|
299
362
|
}
|
|
300
363
|
const { onAccountCommitted, ...providerInteraction } = interaction;
|
|
301
|
-
const loginOperation = method.login({ ...providerInteraction, signal });
|
|
364
|
+
const loginOperation = method.login({ ...providerInteraction, signal }, options);
|
|
302
365
|
const credential = await raceWithAbortSignal(loginOperation, signal);
|
|
303
366
|
let committedName;
|
|
304
367
|
let committedOrigin;
|
|
@@ -372,6 +435,10 @@ class ModelsImpl {
|
|
|
372
435
|
}
|
|
373
436
|
return provider;
|
|
374
437
|
}
|
|
438
|
+
requireChatProvider(model) {
|
|
439
|
+
assertChatModel(model);
|
|
440
|
+
return this.requireProvider(model);
|
|
441
|
+
}
|
|
375
442
|
async applyAuth(model, options) {
|
|
376
443
|
this.requireProvider(model);
|
|
377
444
|
const resolution = await this.getAuth(model, {
|
|
@@ -395,20 +462,22 @@ class ModelsImpl {
|
|
|
395
462
|
return { requestModel, requestOptions };
|
|
396
463
|
}
|
|
397
464
|
stream(model, context, options) {
|
|
465
|
+
const transcript = normalizeContext(context);
|
|
398
466
|
return lazyStream(model, async () => {
|
|
399
|
-
const provider = this.
|
|
467
|
+
const provider = this.requireChatProvider(model);
|
|
400
468
|
const { requestModel, requestOptions } = await this.applyAuth(model, options);
|
|
401
|
-
return provider.stream(requestModel,
|
|
469
|
+
return provider.stream(requestModel, transcript, requestOptions);
|
|
402
470
|
});
|
|
403
471
|
}
|
|
404
472
|
async complete(model, context, options) {
|
|
405
473
|
return this.stream(model, context, options).result();
|
|
406
474
|
}
|
|
407
475
|
streamSimple(model, context, options) {
|
|
476
|
+
const transcript = normalizeContext(context);
|
|
408
477
|
return lazyStream(model, async () => {
|
|
409
|
-
const provider = this.
|
|
478
|
+
const provider = this.requireChatProvider(model);
|
|
410
479
|
const { requestModel, requestOptions } = await this.applyAuth(model, options);
|
|
411
|
-
return provider.streamSimple(requestModel,
|
|
480
|
+
return provider.streamSimple(requestModel, transcript, requestOptions);
|
|
412
481
|
});
|
|
413
482
|
}
|
|
414
483
|
async completeSimple(model, context, options) {
|
|
@@ -416,7 +485,7 @@ class ModelsImpl {
|
|
|
416
485
|
}
|
|
417
486
|
streamDeferred(model, handle, options) {
|
|
418
487
|
return lazyStream(model, async () => {
|
|
419
|
-
const provider = this.
|
|
488
|
+
const provider = this.requireChatProvider(model);
|
|
420
489
|
if (!provider.fetchDeferred) {
|
|
421
490
|
throw new ModelsError("provider", `Provider ${model.provider} does not support deferred responses`);
|
|
422
491
|
}
|
|
@@ -428,31 +497,73 @@ class ModelsImpl {
|
|
|
428
497
|
return this.streamDeferred(model, handle, options).result();
|
|
429
498
|
}
|
|
430
499
|
async cancelDeferred(model, handle, options) {
|
|
431
|
-
const provider = this.
|
|
500
|
+
const provider = this.requireChatProvider(model);
|
|
432
501
|
if (!provider.cancelDeferred) {
|
|
433
502
|
throw new ModelsError("provider", `Provider ${model.provider} does not support deferred responses`);
|
|
434
503
|
}
|
|
435
504
|
const { requestModel, requestOptions } = await this.applyAuth(model, options);
|
|
436
505
|
await provider.cancelDeferred(requestModel, handle, requestOptions);
|
|
437
506
|
}
|
|
507
|
+
async generateImages(model, context, options) {
|
|
508
|
+
try {
|
|
509
|
+
assertImageModel(model);
|
|
510
|
+
const provider = this.requireProvider(model);
|
|
511
|
+
if (!provider.generateImages) {
|
|
512
|
+
throw new ModelsError("provider", `Provider ${model.provider} does not support image generation`);
|
|
513
|
+
}
|
|
514
|
+
const { requestModel, requestOptions } = await this.applyAuth(model, options);
|
|
515
|
+
return await provider.generateImages(requestModel, context, requestOptions);
|
|
516
|
+
}
|
|
517
|
+
catch (error) {
|
|
518
|
+
return imageErrorResult(model, error, options?.signal?.aborted);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
async classify(model, context, options) {
|
|
522
|
+
try {
|
|
523
|
+
assertClassifierModel(model);
|
|
524
|
+
const provider = this.requireProvider(model);
|
|
525
|
+
if (!provider.classify) {
|
|
526
|
+
throw new ModelsError("provider", `Provider ${model.provider} does not support classification`);
|
|
527
|
+
}
|
|
528
|
+
const { requestModel, requestOptions } = await this.applyAuth(model, options);
|
|
529
|
+
return await provider.classify(requestModel, context, requestOptions);
|
|
530
|
+
}
|
|
531
|
+
catch (error) {
|
|
532
|
+
return classifierErrorResult(model, error, options?.signal?.aborted);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
438
535
|
}
|
|
439
536
|
export function createModels(options) {
|
|
440
537
|
return new ModelsImpl(options);
|
|
441
538
|
}
|
|
442
539
|
/**
|
|
443
540
|
* Builds a provider from parts. Built-in provider factories and models.json
|
|
444
|
-
* custom providers both go through this. A single `api` streams all
|
|
445
|
-
* an `api` map dispatches on `model.api`, and a model whose api has
|
|
446
|
-
* produces a stream error.
|
|
541
|
+
* custom providers both go through this. A single `api` streams all chat
|
|
542
|
+
* models; an `api` map dispatches on `model.api`, and a model whose api has
|
|
543
|
+
* no entry produces a stream error. One-shot operation maps dispatch on
|
|
544
|
+
* `model.api` the same way. At least one concrete implementation across
|
|
545
|
+
* `api`/`images`/`classifiers` is required; empty maps are rejected.
|
|
447
546
|
*/
|
|
448
547
|
export function createProvider(input) {
|
|
548
|
+
const single = input.api && typeof input.api.stream === "function"
|
|
549
|
+
? input.api
|
|
550
|
+
: undefined;
|
|
551
|
+
const byApi = single || !input.api ? undefined : input.api;
|
|
552
|
+
const images = input.images;
|
|
553
|
+
const classifiers = input.classifiers;
|
|
554
|
+
const streams = single ? [single] : Object.values(byApi ?? {}).filter((entry) => entry !== undefined);
|
|
555
|
+
const imageImplementations = Object.values(images ?? {}).filter((entry) => entry !== undefined);
|
|
556
|
+
const classifierImplementations = Object.values(classifiers ?? {}).filter((entry) => entry !== undefined);
|
|
557
|
+
if (streams.length === 0 && imageImplementations.length === 0 && classifierImplementations.length === 0) {
|
|
558
|
+
throw new Error(`Provider ${input.id}: at least one of "api", "images", or "classifiers" is required.`);
|
|
559
|
+
}
|
|
449
560
|
const baselineModels = input.models;
|
|
450
561
|
let dynamicModels = [];
|
|
451
562
|
const fetchModels = input.fetchModels;
|
|
452
563
|
const currentModels = () => {
|
|
453
564
|
const merged = [...baselineModels];
|
|
454
565
|
for (const model of dynamicModels) {
|
|
455
|
-
const index = merged.findIndex((entry) => entry.id === model.id);
|
|
566
|
+
const index = merged.findIndex((entry) => getModelType(entry) === getModelType(model) && entry.id === model.id);
|
|
456
567
|
if (index >= 0)
|
|
457
568
|
merged[index] = model;
|
|
458
569
|
else
|
|
@@ -460,8 +571,6 @@ export function createProvider(input) {
|
|
|
460
571
|
}
|
|
461
572
|
return merged;
|
|
462
573
|
};
|
|
463
|
-
const single = typeof input.api.stream === "function" ? input.api : undefined;
|
|
464
|
-
const byApi = single ? undefined : input.api;
|
|
465
574
|
const apiFor = (model) => single ?? byApi?.[model.api];
|
|
466
575
|
const dispatch = (model, run) => {
|
|
467
576
|
const streams = apiFor(model);
|
|
@@ -479,7 +588,8 @@ export function createProvider(input) {
|
|
|
479
588
|
headers: input.headers,
|
|
480
589
|
retryPolicy: input.retryPolicy,
|
|
481
590
|
auth: input.auth,
|
|
482
|
-
getModels: currentModels,
|
|
591
|
+
getModels: () => currentModels().filter((model) => isModelType(model, "chat")),
|
|
592
|
+
getAllModels: currentModels,
|
|
483
593
|
refreshModels: fetchModels
|
|
484
594
|
? async (context) => {
|
|
485
595
|
if (context.stored) {
|
|
@@ -488,7 +598,9 @@ export function createProvider(input) {
|
|
|
488
598
|
.map((model) => model);
|
|
489
599
|
if (input.restoreModels) {
|
|
490
600
|
try {
|
|
491
|
-
|
|
601
|
+
const chatModels = restored.filter((model) => isModelType(model, "chat"));
|
|
602
|
+
const otherModels = restored.filter((model) => !isModelType(model, "chat"));
|
|
603
|
+
restored = [...input.restoreModels(chatModels), ...otherModels];
|
|
492
604
|
}
|
|
493
605
|
catch {
|
|
494
606
|
// The stored list is the last usable catalog; publish it unchanged.
|
|
@@ -504,8 +616,11 @@ export function createProvider(input) {
|
|
|
504
616
|
}
|
|
505
617
|
if (!context.allowNetwork || context.signal.aborted)
|
|
506
618
|
return;
|
|
507
|
-
const
|
|
508
|
-
if (context.signal.aborted
|
|
619
|
+
const fetched = await fetchModels(context);
|
|
620
|
+
if (context.signal.aborted)
|
|
621
|
+
return;
|
|
622
|
+
const refreshed = fetched.filter(hasKnownModelType);
|
|
623
|
+
if (refreshed.length === 0)
|
|
509
624
|
return;
|
|
510
625
|
await context.publish({
|
|
511
626
|
persist: { models: refreshed, checkedAt: Date.now() },
|
|
@@ -516,10 +631,10 @@ export function createProvider(input) {
|
|
|
516
631
|
}
|
|
517
632
|
: undefined,
|
|
518
633
|
filterModels: input.filterModels,
|
|
634
|
+
filterAllModels: input.filterAllModels,
|
|
519
635
|
stream: (model, context, options) => dispatch(model, (streams) => streams.stream(model, context, options)),
|
|
520
636
|
streamSimple: (model, context, options) => dispatch(model, (streams) => streams.streamSimple(model, context, options)),
|
|
521
637
|
};
|
|
522
|
-
const streams = single ? [single] : Object.values(byApi ?? {}).filter((entry) => entry !== undefined);
|
|
523
638
|
if (streams.some((entry) => entry.fetchDeferred !== undefined)) {
|
|
524
639
|
provider.fetchDeferred = (model, handle, options) => lazyStream(model, async () => {
|
|
525
640
|
const implementation = apiFor(model);
|
|
@@ -538,6 +653,24 @@ export function createProvider(input) {
|
|
|
538
653
|
await implementation.cancelDeferred(model, handle, options);
|
|
539
654
|
};
|
|
540
655
|
}
|
|
656
|
+
if (images && imageImplementations.length > 0) {
|
|
657
|
+
provider.generateImages = async (model, context, options) => {
|
|
658
|
+
const implementation = images[model.api];
|
|
659
|
+
if (!implementation) {
|
|
660
|
+
return imageErrorResult(model, new ModelsError("provider", `Provider ${input.id} has no image generation implementation for "${model.api}"`));
|
|
661
|
+
}
|
|
662
|
+
return implementation.generateImages(model, context, options);
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
if (classifiers && classifierImplementations.length > 0) {
|
|
666
|
+
provider.classify = async (model, context, options) => {
|
|
667
|
+
const implementation = classifiers[model.api];
|
|
668
|
+
if (!implementation) {
|
|
669
|
+
return classifierErrorResult(model, new ModelsError("provider", `Provider ${input.id} has no classifier implementation for "${model.api}"`));
|
|
670
|
+
}
|
|
671
|
+
return implementation.classify(model, context, options);
|
|
672
|
+
};
|
|
673
|
+
}
|
|
541
674
|
return provider;
|
|
542
675
|
}
|
|
543
676
|
/**
|
|
@@ -549,9 +682,11 @@ export function createProvider(input) {
|
|
|
549
682
|
* // model: Model<"anthropic-messages">, stream options fully typed
|
|
550
683
|
* }
|
|
551
684
|
* ```
|
|
685
|
+
*
|
|
686
|
+
* Non-chat models never match, even when their api id equals `api`.
|
|
552
687
|
*/
|
|
553
688
|
export function hasApi(model, api) {
|
|
554
|
-
return model.api === api;
|
|
689
|
+
return isModelType(model, "chat") && model.api === api;
|
|
555
690
|
}
|
|
556
691
|
export function calculateCost(model, usage) {
|
|
557
692
|
const inputTokens = usage.input + usage.cacheRead + usage.cacheWrite;
|
|
@@ -692,8 +827,9 @@ function supportsXhighModelId(modelId) {
|
|
|
692
827
|
/**
|
|
693
828
|
* Whether the model exposes the `max` tier.
|
|
694
829
|
*
|
|
695
|
-
*
|
|
696
|
-
*
|
|
830
|
+
* Discovery writes valid endpoint efforts as an authoritative `thinkingLevelMap`; unusable
|
|
831
|
+
* advertised efforts disable reasoning, while absent metadata leaves the model map-less. A map-less
|
|
832
|
+
* model then inherits max from an exact-id built-in catalog entry before the legacy id floors apply.
|
|
697
833
|
*/
|
|
698
834
|
export function supportsMax(model) {
|
|
699
835
|
const mapped = inferOpenAIThinkingLevelMap(model)?.max;
|
|
@@ -743,17 +879,19 @@ const MAX_MODEL_IDS = [
|
|
|
743
879
|
function supportsMaxModel(model) {
|
|
744
880
|
if (!model.reasoning)
|
|
745
881
|
return false;
|
|
882
|
+
if (builtinCatalogAdvertisesMax(model.id))
|
|
883
|
+
return true;
|
|
746
884
|
if (OPENAI_MAX_APIS.includes(model.api) && OPENAI_MAX_MODEL_IDS.some((id) => matchesModelFamily(model.id, id)))
|
|
747
885
|
return true;
|
|
748
886
|
return MAX_MODEL_IDS.some((id) => matchesModelFamily(model.id, id));
|
|
749
887
|
}
|
|
750
888
|
/**
|
|
751
|
-
* Check if two models are equal by comparing
|
|
889
|
+
* Check if two models are equal by comparing their type, id, and provider.
|
|
752
890
|
* Returns false if either model is null or undefined.
|
|
753
891
|
*/
|
|
754
892
|
export function modelsAreEqual(a, b) {
|
|
755
893
|
if (!a || !b)
|
|
756
894
|
return false;
|
|
757
|
-
return a.id === b.id && a.provider === b.provider;
|
|
895
|
+
return getModelType(a) === getModelType(b) && a.id === b.id && a.provider === b.provider;
|
|
758
896
|
}
|
|
759
897
|
//# sourceMappingURL=models.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import values from "./data/alibaba-token-plan.json";
|
|
2
|
-
import { type
|
|
3
|
-
export declare const ALIBABA_TOKEN_PLAN_MODELS:
|
|
2
|
+
import { type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from "../model-catalog.ts";
|
|
3
|
+
export declare const ALIBABA_TOKEN_PLAN_MODELS: ChatModelCatalog<typeof values, "alibaba-token-plan">;
|
|
4
|
+
export declare const ALIBABA_TOKEN_PLAN_IMAGE_MODELS: ImageModelCatalog<typeof values, "alibaba-token-plan">;
|
|
5
|
+
export declare const ALIBABA_TOKEN_PLAN_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, "alibaba-token-plan">;
|
|
4
6
|
//# sourceMappingURL=alibaba-token-plan.models.d.ts.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// This file is auto-generated by scripts/generate-models.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/alibaba-token-plan.json" with { type: "json" };
|
|
4
|
-
import {
|
|
5
|
-
export const ALIBABA_TOKEN_PLAN_MODELS =
|
|
4
|
+
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
5
|
+
export const ALIBABA_TOKEN_PLAN_MODELS = flattenChatModelCatalog("alibaba-token-plan", values);
|
|
6
|
+
export const ALIBABA_TOKEN_PLAN_IMAGE_MODELS = flattenImageModelCatalog("alibaba-token-plan", values);
|
|
7
|
+
export const ALIBABA_TOKEN_PLAN_CLASSIFIER_MODELS = flattenClassifierModelCatalog("alibaba-token-plan", values);
|
|
6
8
|
//# sourceMappingURL=alibaba-token-plan.models.js.map
|