refactor(translator): P4 concern #2 encodeDataUri — dedupe base64 data-uri building

- imageHelper.encodeDataUri(mime, base64) replaces 5 inline `data:${m};base64,${d}` templates
- Applied to gemini/claude/antigravity request + gemini response translators
- Golden tests pass, identical output

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
decoluaandCursor committed 2026-06-13 21:23:32 +07:00
1 parent 4cc667253a
commit 252bf56a9f
5 files changed
+13 -4

No files matched your search

@@ -1,6 +1,7 @@
import { register } from "../index.js";
import { FORMATS } from "../formats.js";
import { adjustMaxTokens } from "../helpers/maxTokensHelper.js";
import { encodeDataUri } from "../helpers/imageHelper.js";
function stripAnthropicBillingHeader(text) {
if (typeof text !== "string") return "";
@@ -140,7 +141,7 @@ function convertClaudeMessage(msg) {
parts.push({
type: "image_url",
image_url: {
url: `data:${block.source.media_type};base64,${block.source.data}`
url: encodeDataUri(block.source.media_type, block.source.data)
}
});
}