Fix : Updated Anthropic-Beta header.

This commit is contained in:
decolua
2026-04-05 07:46:26 +07:00
parent d076c7d7f5
commit 67e0db77da
7 changed files with 143 additions and 27 deletions

View File

@@ -1,6 +1,7 @@
import { FORMATS } from "./formats.js";
import { ensureToolCallIds, fixMissingToolResponses } from "./helpers/toolCallHelper.js";
import { prepareClaudeRequest } from "./helpers/claudeHelper.js";
import { cloakClaudeTools } from "../utils/claudeCloaking.js";
import { filterToOpenAIFormat } from "./helpers/openaiHelper.js";
import { normalizeThinkingConfig } from "../services/provider.js";
import { AntigravityExecutor } from "../executors/antigravity.js";
@@ -67,7 +68,7 @@ function stripUnsupportedMultimodal(body, multimodal = {}) {
}
// Translate request: source -> openai -> target
export function translateRequest(sourceFormat, targetFormat, model, body, stream = true, credentials = null, provider = null, reqLogger = null, caps = null) {
export function translateRequest(sourceFormat, targetFormat, model, body, stream = true, credentials = null, provider = null, reqLogger = null, caps = null, connectionId = null) {
ensureInitialized();
let result = body;
@@ -122,7 +123,20 @@ export function translateRequest(sourceFormat, targetFormat, model, body, stream
// Final step: prepare request for Claude format endpoints
if (targetFormat === FORMATS.CLAUDE) {
const apiKey = credentials?.accessToken || credentials?.apiKey || null;
result = prepareClaudeRequest(result, provider, apiKey);
result = prepareClaudeRequest(result, provider, apiKey, connectionId);
}
// Claude cloaking: rename client tools with _cc suffix (anti-ban)
// Only for claude provider (not anthropic-compatible-*) with OAuth token
if (provider === "claude") {
const apiKey = credentials?.accessToken || credentials?.apiKey || null;
if (apiKey?.includes("sk-ant-oat")) {
const { body: cloakedBody, toolNameMap } = cloakClaudeTools(result);
result = cloakedBody;
if (toolNameMap?.size > 0) {
result._toolNameMap = toolNameMap;
}
}
}
// Antigravity cloaking: rename client tools + inject decoys (anti-ban)