opencode-anthropic-multi-account 0.2.48 → 0.2.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
showToast,
|
|
26
26
|
sleep,
|
|
27
27
|
updateConfigField
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-PYLGLNP2.js";
|
|
29
29
|
import "./chunk-ENOL3OQJ.js";
|
|
30
30
|
|
|
31
31
|
// ../providers/claude-code/src/opencode-shared.ts
|
|
@@ -1239,7 +1239,7 @@ If the result says the push wasn't sent, that's expected \u2014 no action needed
|
|
|
1239
1239
|
"Write"
|
|
1240
1240
|
],
|
|
1241
1241
|
anthropic_beta: "claude-code-20250219,oauth-2025-04-20,context-1m-2025-08-07,interleaved-thinking-2025-05-14,thinking-token-count-2026-05-13,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advisor-tool-2026-03-01,effort-2025-11-24,extended-cache-ttl-2025-04-11",
|
|
1242
|
-
cc_version: "2.1.
|
|
1242
|
+
cc_version: "2.1.169",
|
|
1243
1243
|
header_order: [
|
|
1244
1244
|
"Accept",
|
|
1245
1245
|
"Authorization",
|
|
@@ -1269,7 +1269,7 @@ If the result says the push wasn't sent, that's expected \u2014 no action needed
|
|
|
1269
1269
|
"anthropic-dangerous-direct-browser-access": "true",
|
|
1270
1270
|
"anthropic-version": "2023-06-01",
|
|
1271
1271
|
"content-type": "application/json",
|
|
1272
|
-
"user-agent": "claude-cli/2.1.
|
|
1272
|
+
"user-agent": "claude-cli/2.1.169 (external, sdk-cli)",
|
|
1273
1273
|
"x-app": "cli",
|
|
1274
1274
|
"x-stainless-timeout": "600"
|
|
1275
1275
|
},
|
|
@@ -1379,6 +1379,34 @@ function composeClaudeCodeBillingSystemEntry(firstUserMessage, version, cch = "0
|
|
|
1379
1379
|
const buildTag = computeClaudeCodeBuildTag(firstUserMessage, version);
|
|
1380
1380
|
return `x-anthropic-billing-header: cc_version=${version}.${buildTag}; cc_entrypoint=sdk-cli; cch=${cch};`;
|
|
1381
1381
|
}
|
|
1382
|
+
function applyClaudeCodePromptCaching(body, cacheControl = { type: "ephemeral" }) {
|
|
1383
|
+
const tools = body.tools;
|
|
1384
|
+
if (Array.isArray(tools) && tools.length > 0) {
|
|
1385
|
+
const clonedTools = tools.map((tool) => {
|
|
1386
|
+
const cloned = { ...tool };
|
|
1387
|
+
delete cloned.cache_control;
|
|
1388
|
+
return cloned;
|
|
1389
|
+
});
|
|
1390
|
+
clonedTools[clonedTools.length - 1] = {
|
|
1391
|
+
...clonedTools[clonedTools.length - 1],
|
|
1392
|
+
cache_control: cacheControl
|
|
1393
|
+
};
|
|
1394
|
+
body.tools = clonedTools;
|
|
1395
|
+
}
|
|
1396
|
+
const messages = body.messages;
|
|
1397
|
+
if (!Array.isArray(messages) || messages.length === 0) {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
const lastMessage = messages[messages.length - 1];
|
|
1401
|
+
const content = lastMessage?.content;
|
|
1402
|
+
if (!Array.isArray(content) || content.length === 0) {
|
|
1403
|
+
return;
|
|
1404
|
+
}
|
|
1405
|
+
content[content.length - 1] = {
|
|
1406
|
+
...content[content.length - 1],
|
|
1407
|
+
cache_control: cacheControl
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1382
1410
|
function applyClaudeCodeUpstreamBodyFields(body, input) {
|
|
1383
1411
|
const firstUserMessage = input.firstUserMessage ?? extractFirstUserText(body.messages);
|
|
1384
1412
|
const billingHeader = composeClaudeCodeBillingSystemEntry(
|
|
@@ -1419,6 +1447,7 @@ function applyClaudeCodeUpstreamBodyFields(body, input) {
|
|
|
1419
1447
|
if (input.defaultTools && (!Array.isArray(body.tools) || body.tools.length === 0)) {
|
|
1420
1448
|
body.tools = input.defaultTools.map((tool) => ({ ...tool }));
|
|
1421
1449
|
}
|
|
1450
|
+
applyClaudeCodePromptCaching(body);
|
|
1422
1451
|
return orderClaudeCodeBodyForOutbound(body, input.bodyFieldOrder);
|
|
1423
1452
|
}
|
|
1424
1453
|
function orderClaudeCodeBodyForOutbound(body, fieldOrder) {
|
|
@@ -3108,6 +3137,10 @@ var FRAMEWORK_PATTERNS = [
|
|
|
3108
3137
|
/\bgateway\b/gi,
|
|
3109
3138
|
/\bsessions_[a-z_]+\b/gi
|
|
3110
3139
|
];
|
|
3140
|
+
var CONTENT_FRAMEWORK_PATTERNS = [
|
|
3141
|
+
/\b(roo[- ]?cline|roo[- ]?code|big[- ]?agi|claude[- ]?bridge)\b/gi,
|
|
3142
|
+
/\b(librechat|typingmind)\b/gi
|
|
3143
|
+
];
|
|
3111
3144
|
function normalizeAnthropicClientRequest(inputBody) {
|
|
3112
3145
|
const body = structuredClone(inputBody);
|
|
3113
3146
|
const messages = Array.isArray(body.messages) ? body.messages : [];
|
|
@@ -3117,7 +3150,7 @@ function normalizeAnthropicClientRequest(inputBody) {
|
|
|
3117
3150
|
stripAssistantThinkingBlocks(messages);
|
|
3118
3151
|
for (const message of messages) {
|
|
3119
3152
|
if (typeof message.content === "string") {
|
|
3120
|
-
message.content =
|
|
3153
|
+
message.content = sanitizeAndScrubContent(message.content);
|
|
3121
3154
|
continue;
|
|
3122
3155
|
}
|
|
3123
3156
|
if (!Array.isArray(message.content)) {
|
|
@@ -3166,9 +3199,9 @@ function sanitizeMessages(body) {
|
|
|
3166
3199
|
});
|
|
3167
3200
|
}
|
|
3168
3201
|
}
|
|
3169
|
-
function
|
|
3202
|
+
function scrubWithPatterns(text, patterns) {
|
|
3170
3203
|
let result = text;
|
|
3171
|
-
for (const pattern of
|
|
3204
|
+
for (const pattern of patterns) {
|
|
3172
3205
|
pattern.lastIndex = 0;
|
|
3173
3206
|
result = result.replace(pattern, (match, ...args) => {
|
|
3174
3207
|
const offset = args.at(-2);
|
|
@@ -3189,6 +3222,12 @@ function scrubFrameworkIdentifiers(text) {
|
|
|
3189
3222
|
}
|
|
3190
3223
|
return result;
|
|
3191
3224
|
}
|
|
3225
|
+
function scrubFrameworkIdentifiers(text) {
|
|
3226
|
+
return scrubWithPatterns(text, FRAMEWORK_PATTERNS);
|
|
3227
|
+
}
|
|
3228
|
+
function scrubFrameworkIdentifiersInContent(text) {
|
|
3229
|
+
return scrubWithPatterns(text, CONTENT_FRAMEWORK_PATTERNS);
|
|
3230
|
+
}
|
|
3192
3231
|
function truncateToolResultText(text) {
|
|
3193
3232
|
if (text.length <= MAX_TOOL_RESULT_TEXT_LENGTH) {
|
|
3194
3233
|
return text;
|
|
@@ -3209,6 +3248,9 @@ function sanitizeContent(text) {
|
|
|
3209
3248
|
function sanitizeAndScrubText(text) {
|
|
3210
3249
|
return scrubFrameworkIdentifiers(sanitizeContent(text)).replace(/\n{3,}/g, "\n\n").trim();
|
|
3211
3250
|
}
|
|
3251
|
+
function sanitizeAndScrubContent(text) {
|
|
3252
|
+
return scrubFrameworkIdentifiersInContent(sanitizeContent(text)).replace(/\n{3,}/g, "\n\n").trim();
|
|
3253
|
+
}
|
|
3212
3254
|
function stripCacheControl(value) {
|
|
3213
3255
|
if (Array.isArray(value)) {
|
|
3214
3256
|
for (const item of value) {
|
|
@@ -3226,13 +3268,13 @@ function stripCacheControl(value) {
|
|
|
3226
3268
|
}
|
|
3227
3269
|
function sanitizeMessageBlock(block) {
|
|
3228
3270
|
if (typeof block.text === "string") {
|
|
3229
|
-
block.text =
|
|
3271
|
+
block.text = sanitizeAndScrubContent(block.text);
|
|
3230
3272
|
}
|
|
3231
3273
|
if (block.type !== "tool_result") {
|
|
3232
3274
|
return;
|
|
3233
3275
|
}
|
|
3234
3276
|
if (typeof block.content === "string") {
|
|
3235
|
-
block.content = truncateToolResultText(
|
|
3277
|
+
block.content = truncateToolResultText(sanitizeAndScrubContent(block.content));
|
|
3236
3278
|
return;
|
|
3237
3279
|
}
|
|
3238
3280
|
if (!Array.isArray(block.content)) {
|
|
@@ -3242,7 +3284,7 @@ function sanitizeMessageBlock(block) {
|
|
|
3242
3284
|
if (isRecord2(item) && typeof item.text === "string") {
|
|
3243
3285
|
return {
|
|
3244
3286
|
...item,
|
|
3245
|
-
text: truncateToolResultText(
|
|
3287
|
+
text: truncateToolResultText(sanitizeAndScrubContent(item.text))
|
|
3246
3288
|
};
|
|
3247
3289
|
}
|
|
3248
3290
|
return item;
|