# v0.4.30 (2026-05-11)

## Features
- MCP stdio→SSE bridge: expose local stdio MCP plugins over SSE (api/mcp/[plugin]/sse, /message)
- Dynamic Linux cert resolution + NSS DB injection (Debian/Arch/Fedora/openSUSE, Chrome/Chromium/Firefox incl. snap) (#1010)
- Cowork tool: expanded settings UI & API
- GitBook docs (DocsContent, DocsLayout)
## Fixes
- OAuth callback postMessage scoped to expected origins (CWE-1385) (#998)
- Re-enable TLS verification on DNS-bypass fetch (CWE-295) (#998)
- Normalize `developer` role → `system` for OpenAI-format providers (Deepseek, Groq, …) (#1011, closes #773)
- Respect `PORT` env in internal model-test fetch (#1014)
- Dropdown text readability in dark theme on usage page (#997)
## Improvements
- Refactor Claude CLI spoof headers into shared constant
- Tool deduper utility in open-sse handlers
This commit is contained in:
decolua
2026-05-12 09:19:50 +07:00
parent 76f3d4b74e
commit 8f4d29caa4
23 changed files with 1198 additions and 155 deletions
+146
View File
@@ -601,6 +601,152 @@ export const PROVIDER_MODELS = {
{ id: "openai/whisper-large-v3", name: "Whisper Large v3 (HF)", type: "stt", params: ["language"] },
{ id: "openai/whisper-small", name: "Whisper Small (HF)", type: "stt", params: ["language"] },
],
// === Free-tier providers (synced from OmniRoute) ===
agentrouter: [
{ id: "claude-opus-4-6", name: "Claude 4.6 Opus" },
{ id: "claude-haiku-4-5-20251001", name: "Claude 4.5 Haiku" },
{ id: "glm-5.1", name: "GLM 5.1" },
{ id: "deepseek-v3.2", name: "DeepSeek V3.2" },
],
aimlapi: [
{ id: "gpt-4o", name: "GPT-4o" },
{ id: "gpt-4o-mini", name: "GPT-4o Mini" },
{ id: "claude-3-5-sonnet-20241022", name: "Claude 3.5 Sonnet" },
{ id: "gemini-2.0-flash-exp", name: "Gemini 2.0 Flash" },
{ id: "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", name: "Llama 3.1 70B" },
],
novita: [
{ id: "deepseek/deepseek-r1", name: "DeepSeek R1" },
{ id: "deepseek/deepseek-v3", name: "DeepSeek V3" },
{ id: "meta-llama/llama-3.3-70b-instruct", name: "Llama 3.3 70B" },
{ id: "qwen/qwen-2.5-72b-instruct", name: "Qwen 2.5 72B" },
],
modal: [
{ id: "auto", name: "Auto (User-hosted)" },
],
reka: [
{ id: "reka-flash-3", name: "Reka Flash 3" },
{ id: "reka-edge-2603", name: "Reka Edge 2603" },
],
nlpcloud: [
{ id: "chatdolphin", name: "ChatDolphin" },
{ id: "dolphin", name: "Dolphin" },
{ id: "finetuned-llama-3-70b", name: "Llama 3 70B (Finetuned)" },
],
bazaarlink: [
{ id: "auto:free", name: "Auto Free (Zero Cost)" },
{ id: "auto", name: "Auto (Best Model)" },
],
completions: [
{ id: "claude-opus-4", name: "Claude Opus 4" },
{ id: "claude-sonnet-4", name: "Claude Sonnet 4" },
{ id: "gpt-4o", name: "GPT-4o" },
{ id: "gemini-2.0-flash", name: "Gemini 2.0 Flash" },
],
enally: [
{ id: "gpt-4o", name: "GPT-4o" },
{ id: "gpt-4o-mini", name: "GPT-4o Mini" },
{ id: "claude-3-5-sonnet", name: "Claude 3.5 Sonnet" },
],
freetheai: [
{ id: "gpt-4o", name: "GPT-4o" },
{ id: "claude-3-5-sonnet", name: "Claude 3.5 Sonnet" },
{ id: "gemini-1.5-pro", name: "Gemini 1.5 Pro" },
{ id: "deepseek-chat", name: "DeepSeek Chat" },
],
llm7: [
{ id: "gpt-4o-mini", name: "GPT-4o Mini" },
{ id: "gpt-4.1-mini", name: "GPT-4.1 Mini" },
{ id: "gemini-1.5-flash", name: "Gemini 1.5 Flash" },
],
lepton: [
{ id: "llama3-1-405b", name: "Llama 3.1 405B" },
{ id: "llama3-1-70b", name: "Llama 3.1 70B" },
{ id: "llama3-1-8b", name: "Llama 3.1 8B" },
{ id: "mixtral-8x7b", name: "Mixtral 8x7B" },
],
kluster: [
{ id: "deepseek-ai/DeepSeek-R1", name: "DeepSeek R1" },
{ id: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", name: "Llama 4 Maverick" },
{ id: "meta-llama/Llama-4-Scout-17B-16E-Instruct", name: "Llama 4 Scout" },
{ id: "Qwen/Qwen3-235B-A22B-Instruct", name: "Qwen3 235B" },
],
ai21: [
{ id: "jamba-large", name: "Jamba 1.5 Large" },
{ id: "jamba-mini", name: "Jamba 1.5 Mini" },
],
"inference-net": [
{ id: "meta-llama/llama-3.3-70b-instruct/fp-16", name: "Llama 3.3 70B" },
{ id: "deepseek/deepseek-v3-0324", name: "DeepSeek V3" },
{ id: "mistralai/mistral-nemo-12b-instruct/fp-16", name: "Mistral Nemo 12B" },
],
predibase: [
{ id: "llama-3-2-3b-instruct", name: "Llama 3.2 3B" },
{ id: "llama-3-1-8b-instruct", name: "Llama 3.1 8B" },
{ id: "qwen2-5-7b-instruct", name: "Qwen 2.5 7B" },
],
bytez: [
{ id: "meta-llama/Llama-3.3-70B-Instruct", name: "Llama 3.3 70B" },
{ id: "mistralai/Mistral-7B-Instruct-v0.3", name: "Mistral 7B v0.3" },
{ id: "Qwen/Qwen2.5-72B-Instruct", name: "Qwen 2.5 72B" },
],
morph: [
{ id: "morph-v3-large", name: "Morph V3 Large" },
{ id: "morph-v3-fast", name: "Morph V3 Fast" },
],
longcat: [
{ id: "LongCat-Flash-Chat", name: "LongCat Flash Chat" },
{ id: "LongCat-Flash-Thinking", name: "LongCat Flash Thinking" },
{ id: "LongCat-Flash-Lite", name: "LongCat Flash Lite" },
],
puter: [
{ id: "gpt-5", name: "GPT-5" },
{ id: "claude-opus-4", name: "Claude Opus 4" },
{ id: "gemini-3-pro-preview", name: "Gemini 3 Pro" },
{ id: "grok-4", name: "Grok 4" },
{ id: "deepseek-chat", name: "DeepSeek V3" },
],
uncloseai: [
{ id: "auto", name: "Auto (Free)" },
{ id: "gpt-4o-mini", name: "GPT-4o Mini" },
],
scaleway: [
{ id: "qwen3-235b-a22b-instruct-2507", name: "Qwen3 235B" },
{ id: "llama-3.3-70b-instruct", name: "Llama 3.3 70B" },
{ id: "mistral-small-3.1-24b-instruct-2503", name: "Mistral Small 3.1" },
],
deepinfra: [
{ id: "meta-llama/Meta-Llama-3.1-70B-Instruct", name: "Llama 3.1 70B" },
{ id: "deepseek-ai/DeepSeek-V3", name: "DeepSeek V3" },
{ id: "Qwen/Qwen2.5-72B-Instruct", name: "Qwen 2.5 72B" },
],
sambanova: [
{ id: "Meta-Llama-3.1-405B-Instruct", name: "Llama 3.1 405B" },
{ id: "Meta-Llama-3.1-70B-Instruct", name: "Llama 3.1 70B" },
{ id: "Meta-Llama-3.1-8B-Instruct", name: "Llama 3.1 8B" },
],
nscale: [
{ id: "meta-llama/Llama-3.3-70B-Instruct", name: "Llama 3.3 70B" },
{ id: "Qwen/Qwen2.5-Coder-32B-Instruct", name: "Qwen 2.5 Coder 32B" },
],
baseten: [
{ id: "deepseek-ai/DeepSeek-R1", name: "DeepSeek R1" },
{ id: "meta-llama/Llama-3.3-70B-Instruct", name: "Llama 3.3 70B" },
],
publicai: [
{ id: "auto", name: "Auto (Community)" },
],
"nous-research": [
{ id: "Hermes-4-405B", name: "Hermes 4 405B" },
{ id: "Hermes-4-70B", name: "Hermes 4 70B" },
],
glhf: [
{ id: "hf:meta-llama/Meta-Llama-3.1-405B-Instruct", name: "Llama 3.1 405B" },
{ id: "hf:meta-llama/Meta-Llama-3.1-70B-Instruct", name: "Llama 3.1 70B" },
{ id: "hf:Qwen/Qwen2.5-72B-Instruct", name: "Qwen 2.5 72B" },
],
deepgram: [
{ id: "nova-3", name: "Nova 3", type: "stt", params: ["language"] },
{ id: "nova-2", name: "Nova 2", type: "stt", params: ["language"] },
+52 -16
View File
@@ -26,6 +26,24 @@ const CLAUDE_API_HEADERS = {
"Anthropic-Beta": "claude-code-20250219,interleaved-thinking-2025-05-14"
};
// Full Claude CLI fingerprint — required by providers that gate on client identity (e.g. agentrouter)
const CLAUDE_CLI_SPOOF_HEADERS = {
"Anthropic-Version": "2023-06-01",
"Anthropic-Beta": "claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,advanced-tool-use-2025-11-20,effort-2025-11-24,structured-outputs-2025-12-15,fast-mode-2026-02-01,redact-thinking-2026-02-12,token-efficient-tools-2026-03-28",
"Anthropic-Dangerous-Direct-Browser-Access": "true",
"User-Agent": "claude-cli/2.1.92 (external, sdk-cli)",
"X-App": "cli",
"X-Stainless-Helper-Method": "stream",
"X-Stainless-Retry-Count": "0",
"X-Stainless-Runtime-Version": "v24.14.0",
"X-Stainless-Package-Version": "0.80.0",
"X-Stainless-Runtime": "node",
"X-Stainless-Lang": "js",
"X-Stainless-Arch": mapStainlessArch(),
"X-Stainless-Os": mapStainlessOs(),
"X-Stainless-Timeout": "600"
};
// Shared baseUrls
const KIMI_CODING_BASE_URL = "https://api.kimi.com/coding/v1/messages";
@@ -33,22 +51,7 @@ export const PROVIDERS = {
claude: {
baseUrl: "https://api.anthropic.com/v1/messages",
format: "claude",
headers: {
"Anthropic-Version": "2023-06-01",
"Anthropic-Beta": "claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,advanced-tool-use-2025-11-20,effort-2025-11-24,structured-outputs-2025-12-15,fast-mode-2026-02-01,redact-thinking-2026-02-12,token-efficient-tools-2026-03-28",
"Anthropic-Dangerous-Direct-Browser-Access": "true",
"User-Agent": "claude-cli/2.1.92 (external, sdk-cli)",
"X-App": "cli",
"X-Stainless-Helper-Method": "stream",
"X-Stainless-Retry-Count": "0",
"X-Stainless-Runtime-Version": "v24.14.0",
"X-Stainless-Package-Version": "0.80.0",
"X-Stainless-Runtime": "node",
"X-Stainless-Lang": "js",
"X-Stainless-Arch": mapStainlessArch(),
"X-Stainless-Os": mapStainlessOs(),
"X-Stainless-Timeout": "600"
},
headers: { ...CLAUDE_CLI_SPOOF_HEADERS },
clientId: "9d1c250a-e61b-44d9-88ed-5944d1962f5e",
tokenUrl: "https://api.anthropic.com/v1/oauth/token"
},
@@ -384,6 +387,39 @@ export const PROVIDERS = {
baseUrl: "https://api.xiaomimimo.com/v1/chat/completions",
format: "openai"
},
// === Free-tier providers (synced from OmniRoute) ===
// Claude-format with Claude CLI header spoofing (auth: x-api-key)
agentrouter: { baseUrl: "https://agentrouter.org/v1/messages", format: "claude", headers: { ...CLAUDE_CLI_SPOOF_HEADERS } },
// OpenAI-compatible (auth: bearer)
aimlapi: { baseUrl: "https://api.aimlapi.com/v1/chat/completions", format: "openai" },
novita: { baseUrl: "https://api.novita.ai/v3/openai/chat/completions", format: "openai" },
modal: { baseUrl: "https://api.modal.com/v1/chat/completions", format: "openai" },
reka: { baseUrl: "https://api.reka.ai/v1/chat/completions", format: "openai" },
nlpcloud: { baseUrl: "https://api.nlpcloud.io/v1/gpu/chatbot", format: "openai" },
bazaarlink: { baseUrl: "https://bazaarlink.ai/api/v1/chat/completions", format: "openai" },
completions: { baseUrl: "https://completions.me/api/v1/chat/completions", format: "openai" },
// enally uses X-API-Key header (not bearer); handled in validate route
enally: { baseUrl: "https://ai.enally.in/v1/chat/completions", format: "openai", authHeader: "x-api-key" },
freetheai: { baseUrl: "https://api.freetheai.xyz/v1/chat/completions", format: "openai" },
llm7: { baseUrl: "https://api.llm7.io/v1/chat/completions", format: "openai" },
lepton: { baseUrl: "https://api.lepton.ai/api/v1/chat/completions", format: "openai" },
kluster: { baseUrl: "https://api.kluster.ai/v1/chat/completions", format: "openai" },
ai21: { baseUrl: "https://api.ai21.com/studio/v1/chat/completions", format: "openai" },
"inference-net": { baseUrl: "https://api.inference.net/v1/chat/completions", format: "openai" },
predibase: { baseUrl: "https://serving.app.predibase.com/v1/chat/completions", format: "openai" },
bytez: { baseUrl: "https://api.bytez.com/models/v2", format: "openai" },
morph: { baseUrl: "https://api.morphllm.com/v1/chat/completions", format: "openai" },
longcat: { baseUrl: "https://api.longcat.chat/openai/v1/chat/completions", format: "openai" },
puter: { baseUrl: "https://api.puter.com/puterai/openai/v1/chat/completions", format: "openai" },
uncloseai: { baseUrl: "https://hermes.ai.unturf.com/v1/chat/completions", format: "openai", noAuth: true },
scaleway: { baseUrl: "https://api.scaleway.ai/v1/chat/completions", format: "openai" },
deepinfra: { baseUrl: "https://api.deepinfra.com/v1/openai/chat/completions", format: "openai" },
sambanova: { baseUrl: "https://api.sambanova.ai/v1/chat/completions", format: "openai" },
nscale: { baseUrl: "https://inference.api.nscale.com/v1/chat/completions", format: "openai" },
baseten: { baseUrl: "https://inference.baseten.co/v1/chat/completions", format: "openai" },
publicai: { baseUrl: "https://api.publicai.co/v1/chat/completions", format: "openai" },
"nous-research": { baseUrl: "https://inference-api.nousresearch.com/v1/chat/completions", format: "openai" },
glhf: { baseUrl: "https://glhf.chat/api/openai/v1/chat/completions", format: "openai" },
};
export const OLLAMA_LOCAL_DEFAULT_HOST = "http://localhost:11434";
+6 -4
View File
@@ -96,11 +96,9 @@ export class DefaultExecutor extends BaseExecutor {
case "kimi":
case "minimax":
case "minimax-cn":
headers["x-api-key"] = credentials.apiKey || credentials.accessToken;
break;
case "kimi-coding":
headers["Authorization"] = `Bearer ${credentials.accessToken}`;
Object.assign(headers, buildKimiHeaders());
headers["x-api-key"] = credentials.apiKey || credentials.accessToken;
if (this.provider === "kimi-coding") Object.assign(headers, buildKimiHeaders());
break;
default:
if (this.provider?.startsWith?.("anthropic-compatible-")) {
@@ -124,6 +122,10 @@ export class DefaultExecutor extends BaseExecutor {
}
} else if (this.provider === "cline") {
Object.assign(headers, buildClineHeaders(credentials.apiKey || credentials.accessToken));
} else if (this.config?.format === "claude") {
// Generic claude-format provider (e.g. agentrouter): x-api-key + anthropic-version
headers["x-api-key"] = credentials.apiKey || credentials.accessToken;
if (!headers["anthropic-version"]) headers["anthropic-version"] = "2023-06-01";
} else {
headers["Authorization"] = `Bearer ${credentials.apiKey || credentials.accessToken}`;
}
+10
View File
@@ -16,6 +16,7 @@ import { handleForcedSSEToJson } from "./chatCore/sseToJsonHandler.js";
import { handleNonStreamingResponse } from "./chatCore/nonStreamingHandler.js";
import { handleStreamingResponse, buildOnStreamComplete } from "./chatCore/streamingHandler.js";
import { detectClientTool, isNativePassthrough } from "../utils/clientDetector.js";
import { dedupeTools } from "../utils/toolDeduper.js";
import { injectCaveman } from "../rtk/caveman.js";
import { compressMessages, formatRtkLog } from "../rtk/index.js";
@@ -94,6 +95,15 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
translatedBody.model = model;
}
// Dedupe duplicate built-in tools when equivalent MCP tools are present (Claude clients only).
if (clientTool === "claude" && Array.isArray(translatedBody.tools)) {
const { tools: deduped, stripped } = dedupeTools(translatedBody.tools);
if (stripped.length > 0) {
translatedBody.tools = deduped;
log?.debug?.("TOOLDEDUP", `stripped ${stripped.length}: ${stripped.slice(0, 3).join(", ")}${stripped.length > 3 ? "..." : ""}`);
}
}
// Token savers: applied at the final body just before dispatch
// Covers both passthrough (source shape) and translated (target shape) flows
const finalFormat = passthrough ? sourceFormat : targetFormat;
+44
View File
@@ -86,6 +86,50 @@ const ALIAS_TO_PROVIDER_ID = {
// TTS
polly: "aws-polly",
"aws-polly": "aws-polly",
// Free-tier providers (synced from OmniRoute)
agentrouter: "agentrouter",
aimlapi: "aimlapi",
aiml: "aimlapi",
novita: "novita",
modal: "modal",
mdl: "modal",
reka: "reka",
nlpcloud: "nlpcloud",
nlpc: "nlpcloud",
bazaarlink: "bazaarlink",
bzl: "bazaarlink",
completions: "completions",
cpl: "completions",
enally: "enally",
enly: "enally",
freetheai: "freetheai",
fta: "freetheai",
llm7: "llm7",
lepton: "lepton",
kluster: "kluster",
ai21: "ai21",
"inference-net": "inference-net",
inet: "inference-net",
predibase: "predibase",
bytez: "bytez",
morph: "morph",
longcat: "longcat",
lc: "longcat",
puter: "puter",
pu: "puter",
uncloseai: "uncloseai",
unc: "uncloseai",
scaleway: "scaleway",
scw: "scaleway",
deepinfra: "deepinfra",
sambanova: "sambanova",
samba: "sambanova",
nscale: "nscale",
baseten: "baseten",
publicai: "publicai",
"nous-research": "nous-research",
nous: "nous-research",
glhf: "glhf",
};
/**
+49
View File
@@ -0,0 +1,49 @@
/**
* Strip built-in/duplicate tools when equivalent MCP tools are present.
* Goal: reduce tool definitions token bloat for Claude clients.
*/
const DEDUP_RULES = [
{
// Exa MCP present → drop built-in web tools (Exa is preferred).
triggers: ["mcp__exa__web_search_exa", "mcp__exa__web_fetch_exa"],
strip: ["WebSearch", "WebFetch", "mcp__workspace__web_fetch"],
},
{
// Tavily MCP present → drop built-in web tools.
triggers: ["mcp__tavily__tavily_search", "mcp__tavily__tavily_extract"],
strip: ["WebSearch", "WebFetch", "mcp__workspace__web_fetch"],
},
{
// Browser MCP present → drop Cowork's duplicate Claude_in_Chrome connector.
triggers: [/^mcp__browsermcp__/],
strip: [/^mcp__Claude_in_Chrome__/],
},
];
function getToolName(t) {
return t?.name || t?.function?.name || "";
}
function matches(name, pattern) {
if (typeof pattern === "string") return name === pattern;
return pattern instanceof RegExp ? pattern.test(name) : false;
}
function dedupeTools(tools) {
if (!Array.isArray(tools) || tools.length === 0) return { tools, stripped: [] };
const names = tools.map(getToolName);
const toStrip = new Set();
for (const rule of DEDUP_RULES) {
const hasTrigger = names.some((n) => rule.triggers.some((p) => matches(n, p)));
if (!hasTrigger) continue;
for (const n of names) {
if (rule.strip.some((p) => matches(n, p))) toStrip.add(n);
}
}
if (toStrip.size === 0) return { tools, stripped: [] };
const out = tools.filter((t) => !toStrip.has(getToolName(t)));
return { tools: out, stripped: Array.from(toStrip) };
}
export { dedupeTools };