fix(claude): decloak tool names in same-format streaming passthrough
translateResponse() short-circuited untouched on claude->claude streaming, so OAuth-cloaked tool names (CLAUDE_TOOL_SUFFIX) leaked to the client and every tool call was rejected as unknown. Add decloakStreamChunk(), the streaming counterpart of decloakToolNames(), and call it on the same-format path using the already-plumbed state.toolNameMap.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { FORMATS } from "./formats.js";
|
||||
import { ensureToolCallIds, fixMissingToolResponses } from "./concerns/toolCall.js";
|
||||
import { prepareClaudeRequest } from "./formats/claude.js";
|
||||
import { cloakClaudeTools } from "../utils/claudeCloaking.js";
|
||||
import { cloakClaudeTools, decloakStreamChunk } from "../utils/claudeCloaking.js";
|
||||
import { filterToOpenAIFormat } from "./formats/openai.js";
|
||||
import { normalizeThinkingConfig } from "../services/provider.js";
|
||||
import { applyThinking, captureThinking } from "./concerns/thinkingUnified.js";
|
||||
@@ -133,7 +133,7 @@ export function translateRequest(sourceFormat, targetFormat, model, body, stream
|
||||
result = prepareClaudeRequest(result, provider, apiKey, connectionId, credentials?.rawHeaders, clientSessionId);
|
||||
}
|
||||
|
||||
// Claude cloaking: rename client tools with _cc suffix (anti-ban)
|
||||
// Claude cloaking: rename client tools with CLAUDE_TOOL_SUFFIX (anti-ban)
|
||||
// quirk: only providers flagged cloakToolsOnOAuth, and only with an OAuth token
|
||||
if (PROVIDERS[provider]?.quirks?.cloakToolsOnOAuth) {
|
||||
const apiKey = credentials?.accessToken || credentials?.apiKey || null;
|
||||
@@ -161,9 +161,12 @@ export function translateRequest(sourceFormat, targetFormat, model, body, stream
|
||||
// Translate response chunk: target -> openai -> source
|
||||
export function translateResponse(targetFormat, sourceFormat, chunk, state) {
|
||||
ensureInitialized();
|
||||
// If same format, return as-is
|
||||
// If same format, return as-is — except the tool name may still be cloaked:
|
||||
// translateRequest() suffixes client tools for OAuth-cloaked Claude providers
|
||||
// even when no format conversion is needed, so streamed tool_use blocks must
|
||||
// be decloaked here or the client sees an unknown ("_ide"-suffixed) tool.
|
||||
if (sourceFormat === targetFormat) {
|
||||
return [chunk];
|
||||
return [decloakStreamChunk(chunk, state?.toolNameMap)];
|
||||
}
|
||||
|
||||
let results = [chunk];
|
||||
|
||||
Reference in New Issue
Block a user