This commit is contained in:
decolua
2026-03-30 12:21:24 +07:00
parent abbf8ec86f
commit e6299eef56
6 changed files with 241 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ import { ensureToolCallIds, fixMissingToolResponses } from "./helpers/toolCallHe
import { prepareClaudeRequest } from "./helpers/claudeHelper.js";
import { filterToOpenAIFormat } from "./helpers/openaiHelper.js";
import { normalizeThinkingConfig } from "../services/provider.js";
import { AntigravityExecutor } from "../executors/antigravity.js";
// Registry for translators
const requestRegistry = new Map();
@@ -97,6 +98,16 @@ export function translateRequest(sourceFormat, targetFormat, model, body, stream
result = prepareClaudeRequest(result, provider, apiKey);
}
// Antigravity cloaking: rename client tools + inject decoys (anti-ban)
// Skip if client is native AG (userAgent = antigravity)
if (provider === FORMATS.ANTIGRAVITY && body.userAgent !== FORMATS.ANTIGRAVITY) {
const { cloakedBody, toolNameMap } = AntigravityExecutor.cloakTools(result);
result = cloakedBody;
if (toolNameMap?.size > 0) {
result._toolNameMap = toolNameMap;
}
}
return result;
}

View File

@@ -59,7 +59,9 @@ export function geminiToOpenAIResponse(chunk, state) {
}
if (hasFunctionCall) {
const fcName = part.functionCall.name;
const rawName = part.functionCall.name;
// Restore original tool name from mapping (AG cloaking)
const fcName = state.toolNameMap?.get(rawName) || rawName;
const fcArgs = part.functionCall.args || {};
const toolCallIndex = state.functionIndex++;
@@ -107,7 +109,9 @@ export function geminiToOpenAIResponse(chunk, state) {
// Function call
if (part.functionCall) {
const fcName = part.functionCall.name;
const rawName = part.functionCall.name;
// Restore original tool name from mapping (AG cloaking)
const fcName = state.toolNameMap?.get(rawName) || rawName;
const fcArgs = part.functionCall.args || {};
const toolCallIndex = state.functionIndex++;

View File

@@ -59,9 +59,11 @@ export function openaiToAntigravityResponse(chunk, state) {
const accum = state._toolCallAccum[idx];
let args = {};
try { args = JSON.parse(accum.arguments); } catch { /* empty */ }
// Restore original tool name if it was prefixed during cloaking
const originalName = state.toolNameMap?.get(accum.name) || accum.name;
parts.push({
functionCall: {
name: accum.name,
name: originalName,
args
}
});