opencode-anthropic-multi-account 0.2.25 → 0.2.27
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/{chunk-II7N6KHL.js → chunk-I2QRH74W.js} +12 -11
- package/dist/chunk-I2QRH74W.js.map +1 -0
- package/dist/fingerprint-capture.d.ts +1 -1
- package/dist/fingerprint-capture.js +1 -1
- package/dist/index.js +50 -6
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-II7N6KHL.js.map +0 -1
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-I2QRH74W.js";
|
|
29
29
|
import "./chunk-3CTML5AX.js";
|
|
30
30
|
|
|
31
31
|
// src/index.ts
|
|
@@ -2522,6 +2522,7 @@ function resolvePacingConfig(explicit = {}, env = process.env) {
|
|
|
2522
2522
|
|
|
2523
2523
|
// src/runtime/factory.ts
|
|
2524
2524
|
var TOKEN_REFRESH_PERMANENT_FAILURE_STATUS = 401;
|
|
2525
|
+
var ASSISTANT_PREFILL_UNSUPPORTED_MESSAGE = "This model does not support assistant message prefill";
|
|
2525
2526
|
function mergeHeaders(target, headers) {
|
|
2526
2527
|
if (!headers) {
|
|
2527
2528
|
return;
|
|
@@ -2552,6 +2553,41 @@ function extractIncomingHeaders(input, init) {
|
|
|
2552
2553
|
mergeHeaders(headers, init?.headers);
|
|
2553
2554
|
return headers;
|
|
2554
2555
|
}
|
|
2556
|
+
function isRecord4(value) {
|
|
2557
|
+
return typeof value === "object" && value !== null;
|
|
2558
|
+
}
|
|
2559
|
+
function messageHasToolUse(message) {
|
|
2560
|
+
return Array.isArray(message.content) && message.content.some((block) => isRecord4(block) && block.type === "tool_use");
|
|
2561
|
+
}
|
|
2562
|
+
function removeTrailingAssistantPrefillBody(body) {
|
|
2563
|
+
if (typeof body !== "string") {
|
|
2564
|
+
return null;
|
|
2565
|
+
}
|
|
2566
|
+
try {
|
|
2567
|
+
const parsed = JSON.parse(body);
|
|
2568
|
+
if (!isRecord4(parsed) || !Array.isArray(parsed.messages)) {
|
|
2569
|
+
return null;
|
|
2570
|
+
}
|
|
2571
|
+
const messages = parsed.messages;
|
|
2572
|
+
const originalLength = messages.length;
|
|
2573
|
+
while (messages.length > 0) {
|
|
2574
|
+
const lastMessage = messages[messages.length - 1];
|
|
2575
|
+
if (!lastMessage || lastMessage.role !== "assistant" || messageHasToolUse(lastMessage)) {
|
|
2576
|
+
break;
|
|
2577
|
+
}
|
|
2578
|
+
messages.pop();
|
|
2579
|
+
}
|
|
2580
|
+
return messages.length === originalLength ? null : JSON.stringify(parsed);
|
|
2581
|
+
} catch {
|
|
2582
|
+
return null;
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
async function isAssistantPrefillUnsupportedResponse(response) {
|
|
2586
|
+
if (response.status !== 400) {
|
|
2587
|
+
return false;
|
|
2588
|
+
}
|
|
2589
|
+
return (await response.clone().text()).includes(ASSISTANT_PREFILL_UNSUPPORTED_MESSAGE);
|
|
2590
|
+
}
|
|
2555
2591
|
function splitBetaValues(value) {
|
|
2556
2592
|
if (!value) {
|
|
2557
2593
|
return [];
|
|
@@ -2765,13 +2801,13 @@ var AccountRuntimeFactory = class {
|
|
|
2765
2801
|
releaseGate?.();
|
|
2766
2802
|
}
|
|
2767
2803
|
};
|
|
2768
|
-
const performFetch = async (requestHeaders) => {
|
|
2804
|
+
const performFetch = async (requestHeaders, requestBody) => {
|
|
2769
2805
|
await reservePacingSlot();
|
|
2770
2806
|
try {
|
|
2771
2807
|
const response2 = await fetch(transformedInput, {
|
|
2772
2808
|
...init,
|
|
2773
2809
|
headers: requestHeaders,
|
|
2774
|
-
body:
|
|
2810
|
+
body: requestBody
|
|
2775
2811
|
});
|
|
2776
2812
|
return await enrichRateLimitResponse(response2);
|
|
2777
2813
|
} catch (error) {
|
|
@@ -2781,7 +2817,15 @@ var AccountRuntimeFactory = class {
|
|
|
2781
2817
|
throw error;
|
|
2782
2818
|
}
|
|
2783
2819
|
};
|
|
2784
|
-
let
|
|
2820
|
+
let outboundBody = transformedRequest.body;
|
|
2821
|
+
let response = await performFetch(headers, outboundBody);
|
|
2822
|
+
if (await isAssistantPrefillUnsupportedResponse(response)) {
|
|
2823
|
+
const retryBody = removeTrailingAssistantPrefillBody(outboundBody);
|
|
2824
|
+
if (retryBody) {
|
|
2825
|
+
outboundBody = retryBody;
|
|
2826
|
+
response = await performFetch(headers, outboundBody);
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2785
2829
|
for (let attempt = 0; attempt < LONG_CONTEXT_BETAS.length; attempt += 1) {
|
|
2786
2830
|
if (response.status !== 400 && response.status !== 429) {
|
|
2787
2831
|
break;
|
|
@@ -2812,7 +2856,7 @@ var AccountRuntimeFactory = class {
|
|
|
2812
2856
|
modelId,
|
|
2813
2857
|
getExcludedBetas(modelId)
|
|
2814
2858
|
);
|
|
2815
|
-
response = await performFetch(retryHeaders);
|
|
2859
|
+
response = await performFetch(retryHeaders, outboundBody);
|
|
2816
2860
|
}
|
|
2817
2861
|
return applyResponseReverseLookup(response, transformedRequest.reverseLookup);
|
|
2818
2862
|
}
|
|
@@ -3243,7 +3287,7 @@ var ClaudeMultiAuthPlugin = async (ctx) => {
|
|
|
3243
3287
|
await initializeManagerFromStore().catch(() => {
|
|
3244
3288
|
});
|
|
3245
3289
|
return {
|
|
3246
|
-
"experimental.chat.system.transform": (input, output) => {
|
|
3290
|
+
"experimental.chat.system.transform": async (input, output) => {
|
|
3247
3291
|
const billingHeader = composeBillingSystemEntry(extractFirstUserText(input), claudeCodeVersion);
|
|
3248
3292
|
prependMissingSystemEntries(output, [
|
|
3249
3293
|
billingHeader,
|