@linxiraos/pi-catalog 1.1.7 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -8
- package/README.md +9 -8
- package/package.json +96 -100
- package/src/build.ts +165 -48
- package/src/cline-pass-model-id.ts +11 -0
- package/src/compat/anthropic.ts +15 -136
- package/src/compat/auth-ids.ts +157 -0
- package/src/compat/auth.ts +60 -0
- package/src/compat/axes.ts +301 -0
- package/src/compat/behavior.ts +207 -0
- package/src/compat/cascade.ts +230 -0
- package/src/{variant-collapse.ts → compat/collapse.ts} +381 -773
- package/src/compat/delegation.ts +37 -0
- package/src/compat/openai.ts +17 -848
- package/src/compat/resolve.ts +1231 -0
- package/src/compat/revision.ts +154 -0
- package/src/compat/rules/README.md +315 -0
- package/src/compat/rules/auth/_order.kdl +13 -0
- package/src/compat/rules/auth/abliteration.kdl +9 -0
- package/src/compat/rules/auth/aiand.kdl +9 -0
- package/src/compat/rules/auth/aimlapi.kdl +3 -0
- package/src/compat/rules/auth/alibaba-coding-plan.kdl +5 -0
- package/src/compat/rules/auth/alibaba-token-plan.kdl +11 -0
- package/src/compat/rules/auth/amazon-bedrock.kdl +5 -0
- package/src/compat/rules/auth/anthropic.kdl +53 -0
- package/src/compat/rules/auth/azure.kdl +3 -0
- package/src/compat/rules/auth/baseten.kdl +9 -0
- package/src/compat/rules/auth/bedrock-mantle.kdl +5 -0
- package/src/compat/rules/auth/cerebras.kdl +9 -0
- package/src/compat/rules/auth/cline-pass.kdl +12 -0
- package/src/compat/rules/auth/cloudflare-ai-gateway.kdl +4 -0
- package/src/compat/rules/auth/coreweave.kdl +9 -0
- package/src/compat/rules/auth/cursor.kdl +5 -0
- package/src/compat/rules/auth/deepinfra.kdl +11 -0
- package/src/compat/rules/auth/deepseek.kdl +10 -0
- package/src/compat/rules/auth/devin.kdl +28 -0
- package/src/compat/rules/auth/exa.kdl +9 -0
- package/src/compat/rules/auth/firepass.kdl +14 -0
- package/src/compat/rules/auth/fireworks.kdl +16 -0
- package/src/compat/rules/auth/github-copilot.kdl +7 -0
- package/src/compat/rules/auth/gitlab-duo-agent.kdl +23 -0
- package/src/compat/rules/auth/gitlab-duo.kdl +24 -0
- package/src/compat/rules/auth/gmi-cloud.kdl +9 -0
- package/src/compat/rules/auth/google-antigravity.kdl +28 -0
- package/src/compat/rules/auth/google-gemini-cli.kdl +26 -0
- package/src/compat/rules/auth/google-vertex.kdl +5 -0
- package/src/compat/rules/auth/google.kdl +3 -0
- package/src/compat/rules/auth/groq.kdl +3 -0
- package/src/compat/rules/auth/huggingface.kdl +9 -0
- package/src/compat/rules/auth/kagi.kdl +9 -0
- package/src/compat/rules/auth/kilo.kdl +4 -0
- package/src/compat/rules/auth/kimi-code.kdl +18 -0
- package/src/compat/rules/auth/litellm.kdl +8 -0
- package/src/compat/rules/auth/llama.cpp.kdl +10 -0
- package/src/compat/rules/auth/lm-studio.kdl +7 -0
- package/src/compat/rules/auth/meta.kdl +9 -0
- package/src/compat/rules/auth/minimax-code-cn.kdl +9 -0
- package/src/compat/rules/auth/minimax-code.kdl +9 -0
- package/src/compat/rules/auth/minimax.kdl +3 -0
- package/src/compat/rules/auth/mistral.kdl +3 -0
- package/src/compat/rules/auth/moonshot.kdl +9 -0
- package/src/compat/rules/auth/nanogpt.kdl +9 -0
- package/src/compat/rules/auth/novita.kdl +12 -0
- package/src/compat/rules/auth/nvidia.kdl +11 -0
- package/src/compat/rules/auth/ollama-cloud.kdl +8 -0
- package/src/compat/rules/auth/ollama.kdl +9 -0
- package/src/compat/rules/auth/openai-codex-device.kdl +20 -0
- package/src/compat/rules/auth/openai-codex.kdl +33 -0
- package/src/compat/rules/auth/openai.kdl +3 -0
- package/src/compat/rules/auth/opencode-go.kdl +10 -0
- package/src/compat/rules/auth/opencode-zen.kdl +9 -0
- package/src/compat/rules/auth/openrouter.kdl +32 -0
- package/src/compat/rules/auth/parallel.kdl +9 -0
- package/src/compat/rules/auth/perplexity.kdl +7 -0
- package/src/compat/rules/auth/qianfan.kdl +9 -0
- package/src/compat/rules/auth/qwen-portal.kdl +9 -0
- package/src/compat/rules/auth/sakana.kdl +9 -0
- package/src/compat/rules/auth/siliconflow-cn.kdl +9 -0
- package/src/compat/rules/auth/siliconflow.kdl +9 -0
- package/src/compat/rules/auth/synthetic.kdl +9 -0
- package/src/compat/rules/auth/tavily.kdl +9 -0
- package/src/compat/rules/auth/together.kdl +14 -0
- package/src/compat/rules/auth/umans.kdl +9 -0
- package/src/compat/rules/auth/venice.kdl +9 -0
- package/src/compat/rules/auth/vercel-ai-gateway.kdl +8 -0
- package/src/compat/rules/auth/vllm.kdl +9 -0
- package/src/compat/rules/auth/wafer-serverless.kdl +11 -0
- package/src/compat/rules/auth/xai-oauth.kdl +27 -0
- package/src/compat/rules/auth/xai.kdl +9 -0
- package/src/compat/rules/auth/xiaomi-token-plan-ams.kdl +9 -0
- package/src/compat/rules/auth/xiaomi-token-plan-cn.kdl +9 -0
- package/src/compat/rules/auth/xiaomi-token-plan-sgp.kdl +9 -0
- package/src/compat/rules/auth/xiaomi.kdl +6 -0
- package/src/compat/rules/auth/yolo-auto.kdl +11 -0
- package/src/compat/rules/auth/zai-coding-plan.kdl +33 -0
- package/src/compat/rules/auth/zai.kdl +9 -0
- package/src/compat/rules/auth/zenmux.kdl +9 -0
- package/src/compat/rules/auth/zhipu-coding-plan.kdl +9 -0
- package/src/compat/rules/classes/amazon.kdl +21 -0
- package/src/compat/rules/classes/anthropic.kdl +285 -0
- package/src/compat/rules/classes/baidu.kdl +9 -0
- package/src/compat/rules/classes/bytedance.kdl +9 -0
- package/src/compat/rules/classes/cohere.kdl +7 -0
- package/src/compat/rules/classes/deepseek.kdl +80 -0
- package/src/compat/rules/classes/gemini.kdl +107 -0
- package/src/compat/rules/classes/gemma.kdl +14 -0
- package/src/compat/rules/classes/glm.kdl +115 -0
- package/src/compat/rules/classes/gpt-oss.kdl +16 -0
- package/src/compat/rules/classes/kimi.kdl +113 -0
- package/src/compat/rules/classes/meta.kdl +15 -0
- package/src/compat/rules/classes/mimo.kdl +32 -0
- package/src/compat/rules/classes/minimax.kdl +79 -0
- package/src/compat/rules/classes/mistral.kdl +19 -0
- package/src/compat/rules/classes/openai.kdl +58 -0
- package/src/compat/rules/classes/qwen.kdl +72 -0
- package/src/compat/rules/classes/stepfun.kdl +10 -0
- package/src/compat/rules/classes/xai.kdl +45 -0
- package/src/compat/rules/providers/abliteration.kdl +8 -0
- package/src/compat/rules/providers/aiand.kdl +19 -0
- package/src/compat/rules/providers/aimlapi.kdl +24 -0
- package/src/compat/rules/providers/alibaba-coding-plan.kdl +20 -0
- package/src/compat/rules/providers/alibaba-token-plan.kdl +35 -0
- package/src/compat/rules/providers/amazon-bedrock.kdl +36 -0
- package/src/compat/rules/providers/anthropic.kdl +24 -0
- package/src/compat/rules/providers/azure.kdl +19 -0
- package/src/compat/rules/providers/baseten.kdl +19 -0
- package/src/compat/rules/providers/bedrock-mantle.kdl +15 -0
- package/src/compat/rules/providers/cerebras.kdl +19 -0
- package/src/compat/rules/providers/cline-pass.kdl +8 -0
- package/src/compat/rules/providers/cloudflare-ai-gateway.kdl +26 -0
- package/src/compat/rules/providers/coreweave.kdl +16 -0
- package/src/compat/rules/providers/cursor.kdl +52 -0
- package/src/compat/rules/providers/deepseek.kdl +21 -0
- package/src/compat/rules/providers/firepass.kdl +15 -0
- package/src/compat/rules/providers/fireworks.kdl +43 -0
- package/src/compat/rules/providers/github-copilot.kdl +62 -0
- package/src/compat/rules/providers/gitlab-duo.kdl +24 -0
- package/src/compat/rules/providers/gmi-cloud.kdl +8 -0
- package/src/compat/rules/providers/google-antigravity.kdl +59 -0
- package/src/compat/rules/providers/google-gemini-cli.kdl +12 -0
- package/src/compat/rules/providers/google-vertex.kdl +25 -0
- package/src/compat/rules/providers/google.kdl +17 -0
- package/src/compat/rules/providers/groq.kdl +8 -0
- package/src/compat/rules/providers/huggingface.kdl +24 -0
- package/src/compat/rules/providers/kilo.kdl +51 -0
- package/src/compat/rules/providers/kimi-code.kdl +37 -0
- package/src/compat/rules/providers/llama.cpp.kdl +6 -0
- package/src/compat/rules/providers/lm-studio.kdl +6 -0
- package/src/compat/rules/providers/meta.kdl +10 -0
- package/src/compat/rules/providers/minimax-code-cn.kdl +13 -0
- package/src/compat/rules/providers/minimax-code.kdl +13 -0
- package/src/compat/rules/providers/minimax.kdl +6 -0
- package/src/compat/rules/providers/mistral.kdl +8 -0
- package/src/compat/rules/providers/moonshot.kdl +36 -0
- package/src/compat/rules/providers/nanogpt.kdl +100 -0
- package/src/compat/rules/providers/novita.kdl +34 -0
- package/src/compat/rules/providers/nvidia.kdl +27 -0
- package/src/compat/rules/providers/ollama-cloud.kdl +20 -0
- package/src/compat/rules/providers/ollama.kdl +12 -0
- package/src/compat/rules/providers/openai-codex.kdl +121 -0
- package/src/compat/rules/providers/openai.kdl +82 -0
- package/src/compat/rules/providers/opencode-go.kdl +97 -0
- package/src/compat/rules/providers/opencode-zen.kdl +103 -0
- package/src/compat/rules/providers/openrouter.kdl +66 -0
- package/src/compat/rules/providers/qianfan.kdl +8 -0
- package/src/compat/rules/providers/sakana.kdl +10 -0
- package/src/compat/rules/providers/synthetic.kdl +16 -0
- package/src/compat/rules/providers/together.kdl +22 -0
- package/src/compat/rules/providers/umans.kdl +28 -0
- package/src/compat/rules/providers/venice.kdl +46 -0
- package/src/compat/rules/providers/vercel-ai-gateway.kdl +73 -0
- package/src/compat/rules/providers/vllm.kdl +8 -0
- package/src/compat/rules/providers/wafer-serverless.kdl +35 -0
- package/src/compat/rules/providers/xai-oauth.kdl +48 -0
- package/src/compat/rules/providers/xai.kdl +50 -0
- package/src/compat/rules/providers/xiaomi-token-plan-ams.kdl +9 -0
- package/src/compat/rules/providers/xiaomi-token-plan-cn.kdl +9 -0
- package/src/compat/rules/providers/xiaomi-token-plan-sgp.kdl +9 -0
- package/src/compat/rules/providers/xiaomi.kdl +22 -0
- package/src/compat/rules/providers/yolo-auto.kdl +16 -0
- package/src/compat/rules/providers/zai.kdl +36 -0
- package/src/compat/rules/providers/zenmux.kdl +108 -0
- package/src/compat/rules/providers/zhipu-coding-plan.kdl +49 -0
- package/src/compat/rules/runtime/behavior.kdl +254 -0
- package/src/compat/rules/taxonomy/_collapse.kdl +747 -0
- package/src/compat/rules/taxonomy/_discovery.kdl +60 -0
- package/src/compat/rules/taxonomy/ai21.kdl +6 -0
- package/src/compat/rules/taxonomy/amazon.kdl +8 -0
- package/src/compat/rules/taxonomy/anthropic.kdl +17 -0
- package/src/compat/rules/taxonomy/baidu.kdl +5 -0
- package/src/compat/rules/taxonomy/bytedance.kdl +5 -0
- package/src/compat/rules/taxonomy/cohere.kdl +6 -0
- package/src/compat/rules/taxonomy/deepseek.kdl +18 -0
- package/src/compat/rules/taxonomy/gemini.kdl +9 -0
- package/src/compat/rules/taxonomy/gemma.kdl +3 -0
- package/src/compat/rules/taxonomy/glm.kdl +17 -0
- package/src/compat/rules/taxonomy/gpt-oss.kdl +11 -0
- package/src/compat/rules/taxonomy/kimi.kdl +20 -0
- package/src/compat/rules/taxonomy/meta.kdl +10 -0
- package/src/compat/rules/taxonomy/mimo.kdl +7 -0
- package/src/compat/rules/taxonomy/minimax.kdl +9 -0
- package/src/compat/rules/taxonomy/mistral.kdl +7 -0
- package/src/compat/rules/taxonomy/openai.kdl +43 -0
- package/src/compat/rules/taxonomy/qwen.kdl +33 -0
- package/src/compat/rules/taxonomy/stepfun.kdl +5 -0
- package/src/compat/rules/taxonomy/unknown.kdl +3 -0
- package/src/compat/rules/taxonomy/xai.kdl +12 -0
- package/src/compat/rules.d.json.ts +5 -0
- package/src/compat/rules.json +16984 -0
- package/src/compat/taxonomy.ts +452 -0
- package/src/compat/types.ts +588 -0
- package/src/discovery/antigravity.ts +5 -6
- package/src/discovery/codex.ts +22 -7
- package/src/discovery/cursor-proto.ts +7 -7
- package/src/discovery/cursor.ts +47 -58
- package/src/discovery/devin-proto.ts +613 -0
- package/src/discovery/devin.ts +358 -52
- package/src/discovery/gemini-cli.ts +14 -11
- package/src/discovery/gemini.ts +2 -0
- package/src/identity/dialect.ts +2 -2
- package/src/identity/id.ts +12 -0
- package/src/identity/index.ts +3 -3
- package/src/identity/metrics.ts +165 -0
- package/src/identity/reference.ts +37 -5
- package/src/index.ts +1 -1
- package/src/model-manager.ts +19 -6
- package/src/model-thinking.ts +6 -810
- package/src/model-tokenizer.ts +37 -44
- package/src/models.json +89584 -22358
- package/src/models.ts +6 -1
- package/src/provider-models/bundled-references.ts +3 -1
- package/src/provider-models/cline-pass.ts +226 -0
- package/src/provider-models/descriptors.ts +18 -0
- package/src/provider-models/google.ts +14 -5
- package/src/provider-models/models-dev-policies.ts +4 -29
- package/src/provider-models/ollama.ts +15 -2
- package/src/provider-models/openai-compat.ts +798 -520
- package/src/provider-models/special.ts +211 -12
- package/src/types.ts +214 -11
- package/src/wire/cline-pass.ts +35 -0
- package/src/wire/codex.ts +23 -2
- package/src/wire/devin-proto.ts +30 -0
- package/src/wire/devin.ts +72 -0
- package/src/wire/github-copilot.ts +49 -7
- package/THIRD-PARTY-NOTICES.txt +0 -22909
- package/dist/types/build.d.ts +0 -19
- package/dist/types/compat/anthropic.d.ts +0 -18
- package/dist/types/compat/apply.d.ts +0 -7
- package/dist/types/compat/bedrock.d.ts +0 -3
- package/dist/types/compat/devin.d.ts +0 -9
- package/dist/types/compat/openai.d.ts +0 -28
- package/dist/types/discovery/antigravity.d.ts +0 -70
- package/dist/types/discovery/codex.d.ts +0 -36
- package/dist/types/discovery/cursor-proto.d.ts +0 -5368
- package/dist/types/discovery/cursor.d.ts +0 -29
- package/dist/types/discovery/devin-proto.d.ts +0 -1549
- package/dist/types/discovery/devin.d.ts +0 -24
- package/dist/types/discovery/gemini-cli.d.ts +0 -33
- package/dist/types/discovery/gemini.d.ts +0 -25
- package/dist/types/discovery/gitlab-duo-workflow.d.ts +0 -30
- package/dist/types/discovery/index.d.ts +0 -7
- package/dist/types/discovery/openai-compatible.d.ts +0 -89
- package/dist/types/discovery/protobuf.d.ts +0 -102
- package/dist/types/effort.d.ts +0 -10
- package/dist/types/fireworks-model-id.d.ts +0 -23
- package/dist/types/hosts.d.ts +0 -169
- package/dist/types/identity/bundled.d.ts +0 -3
- package/dist/types/identity/classify.d.ts +0 -69
- package/dist/types/identity/dialect.d.ts +0 -3
- package/dist/types/identity/family.d.ts +0 -243
- package/dist/types/identity/id.d.ts +0 -12
- package/dist/types/identity/index.d.ts +0 -8
- package/dist/types/identity/markers.d.ts +0 -4
- package/dist/types/identity/priority.d.ts +0 -1
- package/dist/types/identity/reference.d.ts +0 -29
- package/dist/types/index.d.ts +0 -19
- package/dist/types/model-cache.d.ts +0 -23
- package/dist/types/model-manager.d.ts +0 -93
- package/dist/types/model-thinking.d.ts +0 -81
- package/dist/types/model-tokenizer.d.ts +0 -8
- package/dist/types/models.d.ts +0 -17
- package/dist/types/openai-pricing.d.ts +0 -17
- package/dist/types/provider-models/bundled-references.d.ts +0 -13
- package/dist/types/provider-models/cache-provider-id.d.ts +0 -11
- package/dist/types/provider-models/descriptor-types.d.ts +0 -76
- package/dist/types/provider-models/descriptors.d.ts +0 -524
- package/dist/types/provider-models/google.d.ts +0 -29
- package/dist/types/provider-models/index.d.ts +0 -7
- package/dist/types/provider-models/models-dev-policies.d.ts +0 -8
- package/dist/types/provider-models/ollama.d.ts +0 -22
- package/dist/types/provider-models/openai-compat.d.ts +0 -703
- package/dist/types/provider-models/special.d.ts +0 -53
- package/dist/types/types.d.ts +0 -879
- package/dist/types/utils.d.ts +0 -20
- package/dist/types/variant-collapse.d.ts +0 -146
- package/dist/types/wire/alibaba-token-plan.d.ts +0 -22
- package/dist/types/wire/cloudflare-ai-gateway.d.ts +0 -18
- package/dist/types/wire/codex.d.ts +0 -66
- package/dist/types/wire/coreweave.d.ts +0 -12
- package/dist/types/wire/gemini-headers.d.ts +0 -62
- package/dist/types/wire/github-copilot.d.ts +0 -47
- package/dist/types/wire/image-fetchers.d.ts +0 -76
- package/src/compat/bedrock.ts +0 -153
- package/src/compat/devin.ts +0 -12
- package/src/identity/classify.ts +0 -242
- package/src/identity/family.ts +0 -496
- package/src/identity/markers.ts +0 -49
- package/src/openai-pricing.ts +0 -29
package/src/compat/anthropic.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Anthropic-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Anthropic endpoint-shape predicates: which URLs are the official first-party
|
|
3
|
+
* API, and which non-official hosts enforce Anthropic's thinking-signature
|
|
4
|
+
* protocol on replay. Compat resolution (`./resolve`) and runtime routing in
|
|
5
|
+
* pi-ai both consume these; URL matching is the one detection surface that
|
|
6
|
+
* stays in code.
|
|
6
7
|
*/
|
|
7
|
-
import { hostMatchesUrl
|
|
8
|
-
import {
|
|
9
|
-
hasOpus47ApiRestrictions,
|
|
10
|
-
isAnthropicFableOrMythosModel,
|
|
11
|
-
isKimiK3ModelId,
|
|
12
|
-
supportsMidConversationSystemMessages,
|
|
13
|
-
} from "../identity/family";
|
|
14
|
-
import type { ModelSpec, ResolvedAnthropicCompat } from "../types";
|
|
15
|
-
import { applyCompatOverrides } from "./apply";
|
|
8
|
+
import { hostMatchesUrl } from "../hosts";
|
|
16
9
|
|
|
17
10
|
const OFFICIAL_ANTHROPIC_URL = "https://api.anthropic.com";
|
|
18
11
|
|
|
@@ -29,75 +22,25 @@ export function isOfficialAnthropicApiUrl(baseUrl?: string): boolean {
|
|
|
29
22
|
return lower === OFFICIAL_ANTHROPIC_URL || lower.startsWith(`${OFFICIAL_ANTHROPIC_URL}/`);
|
|
30
23
|
}
|
|
31
24
|
|
|
32
|
-
/**
|
|
33
|
-
* Kimi models whose native endpoints (api.kimi.com, api.moonshot.ai) keep
|
|
34
|
-
* thinking enabled server-side no matter what the request carries: they
|
|
35
|
-
* reject disabled thinking (#3852) AND reject forced tool_choice
|
|
36
|
-
* (`tool_choice 'specified' is incompatible with thinking enabled`), so compat
|
|
37
|
-
* must keep thinking on and downgrade forced choices to `auto`. Covers the
|
|
38
|
-
* K2.7 Code family — public id, its Highspeed variant, and the kimi-code
|
|
39
|
-
* `kimi-for-coding[-highspeed]` aliases — plus K3 (`kimi-k3`, bare `k3` on
|
|
40
|
-
* kimi-code). Broader than the `compat/openai.ts` mirror: the OpenAI surface
|
|
41
|
-
* has its own per-dialect policies (K3 forced-choice guard, explicit disable
|
|
42
|
-
* shapes), while this surface has no working way to force a tool.
|
|
43
|
-
* Native-only host gating is the caller's responsibility.
|
|
44
|
-
*/
|
|
45
|
-
const KIMI_K27_CODE_MODEL_PATTERN = /(?:^|\/)kimi[-._]?k2(?:[._-]?|p)7[-._]?code(?:[-._]?highspeed)?$/i;
|
|
46
|
-
|
|
47
|
-
function matchesKimiMandatoryThinkingModel(spec: ModelSpec<"anthropic-messages">): boolean {
|
|
48
|
-
if (KIMI_K27_CODE_MODEL_PATTERN.test(spec.id)) return true;
|
|
49
|
-
if (spec.id === "kimi-for-coding" || spec.id === "kimi-for-coding-highspeed") return true;
|
|
50
|
-
return isKimiK3ModelId(spec.id) || spec.id === "k3";
|
|
51
|
-
}
|
|
52
|
-
|
|
53
25
|
const CLOUDFLARE_ANTHROPIC_GATEWAY_URL_MARKER = /gateway\.ai\.cloudflare\.com\/.+\/anthropic(?:\/|$)/i;
|
|
54
26
|
const VERTEX_ANTHROPIC_URL_MARKER = /aiplatform\.googleapis\.com\/.+\/publishers\/anthropic\//i;
|
|
55
27
|
const BEDROCK_ANTHROPIC_URL_MARKER = /(?:^|\/\/|\.)bedrock-runtime\.[a-z0-9-]+\.amazonaws\.com/i;
|
|
56
28
|
const AZURE_ANTHROPIC_URL_MARKER = /(?:^|\/\/|\.)[a-z0-9-]+\.(?:inference|services)\.ai\.azure\.com/i;
|
|
57
29
|
|
|
58
|
-
/**
|
|
59
|
-
* Cloudflare AI Gateway's `/anthropic` route forwards to signature-enforcing
|
|
60
|
-
* Anthropic (same failure class as GitHub Copilot #2851 / ZenMux #4192).
|
|
61
|
-
* Detection is by baseUrl marker rather than provider id: users routinely
|
|
62
|
-
* declare `provider: "custom"` (or other free-form ids) in `models.yml` for
|
|
63
|
-
* their own Cloudflare gateway account.
|
|
64
|
-
*/
|
|
65
|
-
function isCloudflareAnthropicGateway(baseUrl?: string): boolean {
|
|
66
|
-
return baseUrl !== undefined && CLOUDFLARE_ANTHROPIC_GATEWAY_URL_MARKER.test(baseUrl);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Google Vertex's `publishers/anthropic/models/…:streamRawPredict` route
|
|
71
|
-
* proxies Claude through Google's identity layer and returns full thinking
|
|
72
|
-
* signatures, so it is a SIGNING endpoint.
|
|
73
|
-
*/
|
|
74
|
-
function isVertexAnthropicRoute(baseUrl?: string): boolean {
|
|
75
|
-
return baseUrl !== undefined && VERTEX_ANTHROPIC_URL_MARKER.test(baseUrl);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* AWS Bedrock's Anthropic route (`bedrock-runtime.<region>.amazonaws.com`)
|
|
80
|
-
* forwards Claude requests through Anthropic's signature protocol. Users can
|
|
81
|
-
* front Bedrock with a custom `anthropic-messages` provider entry in
|
|
82
|
-
* `models.yml`; the URL marker makes those signing by default without
|
|
83
|
-
* requiring a provider-id list.
|
|
84
|
-
*/
|
|
85
|
-
function isBedrockAnthropicRoute(baseUrl?: string): boolean {
|
|
86
|
-
return baseUrl !== undefined && BEDROCK_ANTHROPIC_URL_MARKER.test(baseUrl);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
30
|
/**
|
|
90
31
|
* Azure AI Inference / Foundry Anthropic route
|
|
91
32
|
* (`<resource>.inference.ai.azure.com`, `<resource>.services.ai.azure.com`).
|
|
92
33
|
* Fronts Claude behind Azure identity and enforces Anthropic signatures on
|
|
93
|
-
* replay.
|
|
34
|
+
* replay; it also rejects the top-level `strict` tool field.
|
|
94
35
|
*/
|
|
95
|
-
function isAzureAnthropicRoute(baseUrl?: string): boolean {
|
|
36
|
+
export function isAzureAnthropicRoute(baseUrl?: string): boolean {
|
|
96
37
|
return baseUrl !== undefined && AZURE_ANTHROPIC_URL_MARKER.test(baseUrl);
|
|
97
38
|
}
|
|
98
39
|
|
|
99
40
|
/**
|
|
100
|
-
* Known non-official URLs that enforce Anthropic thinking signatures on replay
|
|
41
|
+
* Known non-official URLs that enforce Anthropic thinking signatures on replay
|
|
42
|
+
* (GitHub Copilot, ZenMux, Cloudflare AI Gateway `/anthropic`, Google Vertex
|
|
43
|
+
* `publishers/anthropic`, AWS Bedrock, Azure Foundry).
|
|
101
44
|
*
|
|
102
45
|
* Runtime routing calls this with the effective URL because a model's resolved
|
|
103
46
|
* compat can be stale after Foundry or a provider base-URL override reroutes it.
|
|
@@ -106,74 +49,10 @@ export function isAnthropicSigningProxyUrl(baseUrl?: string): boolean {
|
|
|
106
49
|
return (
|
|
107
50
|
hostMatchesUrl(baseUrl, "githubCopilot") ||
|
|
108
51
|
hostMatchesUrl(baseUrl, "zenmux") ||
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
52
|
+
(baseUrl !== undefined &&
|
|
53
|
+
(CLOUDFLARE_ANTHROPIC_GATEWAY_URL_MARKER.test(baseUrl) ||
|
|
54
|
+
VERTEX_ANTHROPIC_URL_MARKER.test(baseUrl) ||
|
|
55
|
+
BEDROCK_ANTHROPIC_URL_MARKER.test(baseUrl))) ||
|
|
112
56
|
isAzureAnthropicRoute(baseUrl)
|
|
113
57
|
);
|
|
114
58
|
}
|
|
115
|
-
|
|
116
|
-
/** Build the resolved anthropic-messages compat record for a model spec. */
|
|
117
|
-
export function buildAnthropicCompat(spec: ModelSpec<"anthropic-messages">): ResolvedAnthropicCompat {
|
|
118
|
-
const baseUrl = spec.baseUrl;
|
|
119
|
-
const official = isOfficialAnthropicApiUrl(baseUrl);
|
|
120
|
-
// Z.AI's Anthropic-compatible proxy lives at `api.z.ai/api/anthropic`.
|
|
121
|
-
const isZai = modelMatchesHost(spec, "zai");
|
|
122
|
-
// GitHub Copilot's `anthropic-messages` proxy (api.githubcopilot.com/v1/messages)
|
|
123
|
-
// rejects the per-tool `eager_input_streaming` field with
|
|
124
|
-
// `tools.0.custom.eager_input_streaming: Extra inputs are not permitted` and
|
|
125
|
-
// doesn't whitelist the `fine-grained-tool-streaming-2025-05-14` beta either
|
|
126
|
-
// (issue #2558), so eager tool-input streaming is unavailable on this host.
|
|
127
|
-
const isCopilot = modelMatchesHost(spec, "githubCopilot");
|
|
128
|
-
// ZenMux's `anthropic-messages` route (zenmux.ai/api/anthropic) forwards to
|
|
129
|
-
// signature-enforcing Anthropic — same failure class as GitHub Copilot #2851
|
|
130
|
-
// (issue #4192).
|
|
131
|
-
const isZenmux = modelMatchesHost(spec, "zenmux");
|
|
132
|
-
const requiresThinkingEnabled = modelMatchesHost(spec, "moonshotNative") && matchesKimiMandatoryThinkingModel(spec);
|
|
133
|
-
const isAzure = isAzureAnthropicRoute(baseUrl);
|
|
134
|
-
const signingEndpoint = official || isCopilot || isZenmux || isAnthropicSigningProxyUrl(baseUrl);
|
|
135
|
-
const compat: ResolvedAnthropicCompat = {
|
|
136
|
-
officialEndpoint: official,
|
|
137
|
-
signingEndpoint,
|
|
138
|
-
disableStrictTools: isAzure,
|
|
139
|
-
disableAdaptiveThinking: false,
|
|
140
|
-
allowAnthropicHeaderOverrides: false,
|
|
141
|
-
supportsEagerToolInputStreaming: official,
|
|
142
|
-
// Long cache retention is only sent to the official API by default;
|
|
143
|
-
// proxies opt in explicitly via `compat.supportsLongCacheRetention: true`.
|
|
144
|
-
supportsLongCacheRetention: official,
|
|
145
|
-
// First-party Claude API only. Bedrock/Vertex/Foundry and other
|
|
146
|
-
// Anthropic-compatible gateways reject mid-conversation system roles, so
|
|
147
|
-
// detection requires the canonical api.anthropic.com host plus a
|
|
148
|
-
// supported model id.
|
|
149
|
-
supportsMidConversationSystem: official && supportsMidConversationSystemMessages(spec.id),
|
|
150
|
-
supportsForcedToolChoice: !requiresThinkingEnabled && !isAnthropicFableOrMythosModel(spec.id),
|
|
151
|
-
// Opus 4.7+ and Fable/Mythos reject temperature/top_p/top_k with a 400.
|
|
152
|
-
supportsSamplingParams: !hasOpus47ApiRestrictions(spec.id),
|
|
153
|
-
// Z.AI workaround (issue #814): its proxy deserializes tool_result blocks
|
|
154
|
-
// into a class that reads `.id`.
|
|
155
|
-
requiresToolResultId: isZai,
|
|
156
|
-
requiresThinkingEnabled,
|
|
157
|
-
// Official Anthropic and Anthropic-compatible signing proxies enforce
|
|
158
|
-
// signature-based thinking-chain integrity, so unsigned thinking blocks
|
|
159
|
-
// must stay text there. Every other `anthropic-messages` reasoning
|
|
160
|
-
// endpoint replays unsigned thinking natively so the reasoning chain
|
|
161
|
-
// survives continuation and doesn't destabilize the next tool-call
|
|
162
|
-
// arguments (#2005, #2257, #2265, #3288, #3433, #3434). Opaque custom
|
|
163
|
-
// signing proxies remain the reporter's responsibility to mark with
|
|
164
|
-
// `compat.replayUnsignedThinking: false`; the transport surfaces a
|
|
165
|
-
// pointed remediation the first time the signing 400 fires (#4297).
|
|
166
|
-
//
|
|
167
|
-
// Known signing Anthropic-messages hosts (Copilot, ZenMux, Cloudflare
|
|
168
|
-
// AI Gateway `/anthropic`, Google Vertex `publishers/anthropic`, AWS
|
|
169
|
-
// Bedrock `bedrock-runtime.<region>.amazonaws.com`, and Azure
|
|
170
|
-
// AI Inference / Foundry `<res>.(inference|services).ai.azure.com`)
|
|
171
|
-
// are excluded automatically because they can be recognised by provider
|
|
172
|
-
// id or baseUrl marker.
|
|
173
|
-
replayUnsignedThinking: !signingEndpoint && (Boolean(spec.reasoning) || modelMatchesHost(spec, "deepseekFamily")),
|
|
174
|
-
escapeBuiltinToolNames: modelMatchesHost(spec, "umans"),
|
|
175
|
-
streamIdleTimeoutMs: spec.compat?.streamIdleTimeoutMs,
|
|
176
|
-
};
|
|
177
|
-
applyCompatOverrides(compat, spec.compat);
|
|
178
|
-
return compat;
|
|
179
|
-
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Generated by `bun run gen:compat` from `src/compat/rules/auth/*.kdl`; do not edit.
|
|
2
|
+
|
|
3
|
+
/** Every provider with an `auth/<id>.kdl` policy. */
|
|
4
|
+
export type AuthProviderId =
|
|
5
|
+
| "abliteration"
|
|
6
|
+
| "aiand"
|
|
7
|
+
| "aimlapi"
|
|
8
|
+
| "alibaba-coding-plan"
|
|
9
|
+
| "alibaba-token-plan"
|
|
10
|
+
| "amazon-bedrock"
|
|
11
|
+
| "anthropic"
|
|
12
|
+
| "azure"
|
|
13
|
+
| "baseten"
|
|
14
|
+
| "bedrock-mantle"
|
|
15
|
+
| "cerebras"
|
|
16
|
+
| "cline-pass"
|
|
17
|
+
| "cloudflare-ai-gateway"
|
|
18
|
+
| "coreweave"
|
|
19
|
+
| "cursor"
|
|
20
|
+
| "deepinfra"
|
|
21
|
+
| "deepseek"
|
|
22
|
+
| "devin"
|
|
23
|
+
| "exa"
|
|
24
|
+
| "firepass"
|
|
25
|
+
| "fireworks"
|
|
26
|
+
| "github-copilot"
|
|
27
|
+
| "gitlab-duo"
|
|
28
|
+
| "gitlab-duo-agent"
|
|
29
|
+
| "gmi-cloud"
|
|
30
|
+
| "google"
|
|
31
|
+
| "google-antigravity"
|
|
32
|
+
| "google-gemini-cli"
|
|
33
|
+
| "google-vertex"
|
|
34
|
+
| "groq"
|
|
35
|
+
| "huggingface"
|
|
36
|
+
| "kagi"
|
|
37
|
+
| "kilo"
|
|
38
|
+
| "kimi-code"
|
|
39
|
+
| "litellm"
|
|
40
|
+
| "llama.cpp"
|
|
41
|
+
| "lm-studio"
|
|
42
|
+
| "meta"
|
|
43
|
+
| "minimax"
|
|
44
|
+
| "minimax-code"
|
|
45
|
+
| "minimax-code-cn"
|
|
46
|
+
| "mistral"
|
|
47
|
+
| "moonshot"
|
|
48
|
+
| "nanogpt"
|
|
49
|
+
| "novita"
|
|
50
|
+
| "nvidia"
|
|
51
|
+
| "ollama"
|
|
52
|
+
| "ollama-cloud"
|
|
53
|
+
| "openai"
|
|
54
|
+
| "openai-codex"
|
|
55
|
+
| "openai-codex-device"
|
|
56
|
+
| "opencode-go"
|
|
57
|
+
| "opencode-zen"
|
|
58
|
+
| "openrouter"
|
|
59
|
+
| "parallel"
|
|
60
|
+
| "perplexity"
|
|
61
|
+
| "qianfan"
|
|
62
|
+
| "qwen-portal"
|
|
63
|
+
| "sakana"
|
|
64
|
+
| "siliconflow"
|
|
65
|
+
| "siliconflow-cn"
|
|
66
|
+
| "synthetic"
|
|
67
|
+
| "tavily"
|
|
68
|
+
| "together"
|
|
69
|
+
| "umans"
|
|
70
|
+
| "venice"
|
|
71
|
+
| "vercel-ai-gateway"
|
|
72
|
+
| "vllm"
|
|
73
|
+
| "wafer-serverless"
|
|
74
|
+
| "xai"
|
|
75
|
+
| "xai-oauth"
|
|
76
|
+
| "xiaomi"
|
|
77
|
+
| "xiaomi-token-plan-ams"
|
|
78
|
+
| "xiaomi-token-plan-cn"
|
|
79
|
+
| "xiaomi-token-plan-sgp"
|
|
80
|
+
| "yolo-auto"
|
|
81
|
+
| "zai"
|
|
82
|
+
| "zai-coding-plan"
|
|
83
|
+
| "zenmux"
|
|
84
|
+
| "zhipu-coding-plan";
|
|
85
|
+
|
|
86
|
+
/** Providers whose policy declares a `login` flow (the `/login` roster). */
|
|
87
|
+
export type LoginProviderId =
|
|
88
|
+
| "abliteration"
|
|
89
|
+
| "aiand"
|
|
90
|
+
| "alibaba-coding-plan"
|
|
91
|
+
| "alibaba-token-plan"
|
|
92
|
+
| "anthropic"
|
|
93
|
+
| "baseten"
|
|
94
|
+
| "cerebras"
|
|
95
|
+
| "cline-pass"
|
|
96
|
+
| "cloudflare-ai-gateway"
|
|
97
|
+
| "coreweave"
|
|
98
|
+
| "cursor"
|
|
99
|
+
| "deepinfra"
|
|
100
|
+
| "deepseek"
|
|
101
|
+
| "devin"
|
|
102
|
+
| "exa"
|
|
103
|
+
| "firepass"
|
|
104
|
+
| "fireworks"
|
|
105
|
+
| "github-copilot"
|
|
106
|
+
| "gitlab-duo"
|
|
107
|
+
| "gitlab-duo-agent"
|
|
108
|
+
| "gmi-cloud"
|
|
109
|
+
| "google-antigravity"
|
|
110
|
+
| "google-gemini-cli"
|
|
111
|
+
| "huggingface"
|
|
112
|
+
| "kagi"
|
|
113
|
+
| "kilo"
|
|
114
|
+
| "kimi-code"
|
|
115
|
+
| "litellm"
|
|
116
|
+
| "llama.cpp"
|
|
117
|
+
| "lm-studio"
|
|
118
|
+
| "meta"
|
|
119
|
+
| "minimax-code"
|
|
120
|
+
| "minimax-code-cn"
|
|
121
|
+
| "moonshot"
|
|
122
|
+
| "nanogpt"
|
|
123
|
+
| "novita"
|
|
124
|
+
| "nvidia"
|
|
125
|
+
| "ollama"
|
|
126
|
+
| "ollama-cloud"
|
|
127
|
+
| "openai-codex"
|
|
128
|
+
| "openai-codex-device"
|
|
129
|
+
| "opencode-go"
|
|
130
|
+
| "opencode-zen"
|
|
131
|
+
| "openrouter"
|
|
132
|
+
| "parallel"
|
|
133
|
+
| "perplexity"
|
|
134
|
+
| "qianfan"
|
|
135
|
+
| "qwen-portal"
|
|
136
|
+
| "sakana"
|
|
137
|
+
| "siliconflow"
|
|
138
|
+
| "siliconflow-cn"
|
|
139
|
+
| "synthetic"
|
|
140
|
+
| "tavily"
|
|
141
|
+
| "together"
|
|
142
|
+
| "umans"
|
|
143
|
+
| "venice"
|
|
144
|
+
| "vercel-ai-gateway"
|
|
145
|
+
| "vllm"
|
|
146
|
+
| "wafer-serverless"
|
|
147
|
+
| "xai"
|
|
148
|
+
| "xai-oauth"
|
|
149
|
+
| "xiaomi"
|
|
150
|
+
| "xiaomi-token-plan-ams"
|
|
151
|
+
| "xiaomi-token-plan-cn"
|
|
152
|
+
| "xiaomi-token-plan-sgp"
|
|
153
|
+
| "yolo-auto"
|
|
154
|
+
| "zai"
|
|
155
|
+
| "zai-coding-plan"
|
|
156
|
+
| "zenmux"
|
|
157
|
+
| "zhipu-coding-plan";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed accessors over the compiled auth stratum (`rules/auth/*.kdl`): per
|
|
3
|
+
* provider display metadata, env-var fallbacks and the declarative login /
|
|
4
|
+
* refresh flow that `@linxiraos/pi-ai`'s registry engines interpret.
|
|
5
|
+
*/
|
|
6
|
+
import rules from "./rules.json";
|
|
7
|
+
import type { CompiledAuthProvider } from "./types";
|
|
8
|
+
|
|
9
|
+
const providers = rules.auth.providers as readonly CompiledAuthProvider[];
|
|
10
|
+
const byId: Record<string, CompiledAuthProvider> = Object.fromEntries(providers.map(p => [p.id, p]));
|
|
11
|
+
|
|
12
|
+
/** Every compiled auth provider in `/login` display order. */
|
|
13
|
+
export function authProviders(): readonly CompiledAuthProvider[] {
|
|
14
|
+
return providers;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The compiled auth policy for one provider id, if declared. */
|
|
18
|
+
export function authPolicyFor(provider: string): CompiledAuthProvider | undefined {
|
|
19
|
+
return byId[provider];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Every hook name referenced anywhere in the auth stratum, for registry completeness checks. */
|
|
23
|
+
export function authHookNames(): Record<string, string[]> {
|
|
24
|
+
const names: Record<string, string[]> = {};
|
|
25
|
+
const add = (kind: string, name: string | undefined) => {
|
|
26
|
+
if (!name) return;
|
|
27
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: destructuring default with assignment inside the compiled stratum walker
|
|
28
|
+
(names[kind] ??= []).push(name);
|
|
29
|
+
};
|
|
30
|
+
for (const p of providers) {
|
|
31
|
+
if (p.env && "hook" in p.env) add("env", p.env.hook);
|
|
32
|
+
const login = p.login;
|
|
33
|
+
if (login?.kind === "custom") add("login", login.hook);
|
|
34
|
+
if (login?.kind === "api-key" && login.validate?.kind === "models-endpoint") {
|
|
35
|
+
add("headers", login.validate.headersHook);
|
|
36
|
+
}
|
|
37
|
+
if (login?.kind === "oauth-code") {
|
|
38
|
+
add("after-exchange", login.afterExchange);
|
|
39
|
+
add("value", login.clientId?.hook);
|
|
40
|
+
add("value", login.authorizeUrl.hook);
|
|
41
|
+
add("value", login.token.url.hook);
|
|
42
|
+
}
|
|
43
|
+
if (login?.kind === "device-code") {
|
|
44
|
+
add("after-exchange", login.afterExchange);
|
|
45
|
+
add("headers", login.headersHook);
|
|
46
|
+
add("value", login.clientId.hook);
|
|
47
|
+
add("value", login.baseUrl?.hook);
|
|
48
|
+
add("value", login.device.url.hook);
|
|
49
|
+
add("value", login.token.url.hook);
|
|
50
|
+
}
|
|
51
|
+
const refresh = p.refresh;
|
|
52
|
+
if (refresh?.kind === "hook") add("refresh", refresh.hook);
|
|
53
|
+
if (refresh?.kind === "request") {
|
|
54
|
+
add("after-exchange", refresh.afterRefresh);
|
|
55
|
+
add("headers", refresh.headersHook);
|
|
56
|
+
add("value", refresh.token.url.hook);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return names;
|
|
60
|
+
}
|