opencode-anthropic-multi-account 0.2.51 → 0.2.53
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-LPFBTDOZ.js → chunk-FJPFERYW.js} +2 -2
- package/dist/{chunk-LPFBTDOZ.js.map → chunk-FJPFERYW.js.map} +1 -1
- package/dist/fingerprint-capture.d.ts +1 -1
- package/dist/fingerprint-capture.js +1 -1
- package/dist/index.js +78 -21
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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-FJPFERYW.js";
|
|
29
29
|
import "./chunk-IIROTFG6.js";
|
|
30
30
|
|
|
31
31
|
// ../providers/claude-code/src/opencode-shared.ts
|
|
@@ -1208,6 +1208,34 @@ var BILLING_SEED = "59cf53e54c78";
|
|
|
1208
1208
|
var templateMetadata = getClaudeCodeTemplateMetadata();
|
|
1209
1209
|
var templateHeaders = templateMetadata.headerValues;
|
|
1210
1210
|
var CLAUDE_CODE_VERSION = templateMetadata.ccVersion ?? "2.1.137";
|
|
1211
|
+
var CLAUDE_FABLE_MODEL_ID = "claude-fable-5";
|
|
1212
|
+
var CLAUDE_FABLE_1M_MODEL_ID = `${CLAUDE_FABLE_MODEL_ID}[1m]`;
|
|
1213
|
+
var CLAUDE_CODE_MODEL_ALIASES = {
|
|
1214
|
+
fable: CLAUDE_FABLE_MODEL_ID,
|
|
1215
|
+
fable1m: CLAUDE_FABLE_1M_MODEL_ID
|
|
1216
|
+
};
|
|
1217
|
+
function stripClaudeCodeProviderPrefix(modelId) {
|
|
1218
|
+
const slash = modelId.indexOf("/");
|
|
1219
|
+
if (slash === -1) return modelId;
|
|
1220
|
+
const provider = modelId.slice(0, slash).toLowerCase();
|
|
1221
|
+
return provider === "anthropic" || provider === "claude-code" ? modelId.slice(slash + 1) : modelId;
|
|
1222
|
+
}
|
|
1223
|
+
function resolveClaudeCodeModelAlias(modelId) {
|
|
1224
|
+
const unprefixed = stripClaudeCodeProviderPrefix(modelId.trim());
|
|
1225
|
+
return CLAUDE_CODE_MODEL_ALIASES[unprefixed.toLowerCase()] ?? unprefixed;
|
|
1226
|
+
}
|
|
1227
|
+
function stripClaudeCodeContext1mTag(modelId) {
|
|
1228
|
+
return modelId.replace(/\[1m\]$/i, "");
|
|
1229
|
+
}
|
|
1230
|
+
function toClaudeCodeWireModelId(modelId) {
|
|
1231
|
+
return stripClaudeCodeContext1mTag(resolveClaudeCodeModelAlias(modelId));
|
|
1232
|
+
}
|
|
1233
|
+
function isClaudeCode1mModelLabel(modelId) {
|
|
1234
|
+
return /\[1m\]$/i.test(resolveClaudeCodeModelAlias(modelId));
|
|
1235
|
+
}
|
|
1236
|
+
function isClaudeFableModel(modelId) {
|
|
1237
|
+
return resolveClaudeCodeModelAlias(modelId).toLowerCase().includes("fable");
|
|
1238
|
+
}
|
|
1211
1239
|
function loadClaudeCodeSharedRequestProfile() {
|
|
1212
1240
|
return {
|
|
1213
1241
|
anthropicBeta: templateMetadata.anthropicBeta ?? templateHeaders["anthropic-beta"] ?? "oauth-2025-04-20",
|
|
@@ -2842,6 +2870,9 @@ import { TokenRefreshError } from "opencode-multi-account-core";
|
|
|
2842
2870
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
2843
2871
|
|
|
2844
2872
|
// src/model/config.ts
|
|
2873
|
+
var FABLE_FALLBACK_CREDIT_BETA = "fallback-credit-2026-06-01";
|
|
2874
|
+
var MID_CONVERSATION_SYSTEM_BETA = "mid-conversation-system-2026-04-07";
|
|
2875
|
+
var EFFORT_BETA = "effort-2025-11-24";
|
|
2845
2876
|
function splitBetaFlags(value) {
|
|
2846
2877
|
return value.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
2847
2878
|
}
|
|
@@ -2849,13 +2880,25 @@ var config = {
|
|
|
2849
2880
|
baseBetas: splitBetaFlags(ANTHROPIC_OAUTH_ADAPTER.requestBetaHeader),
|
|
2850
2881
|
longContextBetas: ["context-1m-2025-08-07", "context-management-2025-06-27"],
|
|
2851
2882
|
modelOverrides: {
|
|
2883
|
+
fable: {
|
|
2884
|
+
add: [FABLE_FALLBACK_CREDIT_BETA]
|
|
2885
|
+
},
|
|
2886
|
+
sonnet: {
|
|
2887
|
+
exclude: [MID_CONVERSATION_SYSTEM_BETA],
|
|
2888
|
+
add: [EFFORT_BETA]
|
|
2889
|
+
},
|
|
2890
|
+
haiku: {
|
|
2891
|
+
exclude: [MID_CONVERSATION_SYSTEM_BETA, EFFORT_BETA]
|
|
2892
|
+
},
|
|
2852
2893
|
"4-6": {
|
|
2853
|
-
add: [
|
|
2894
|
+
add: [EFFORT_BETA]
|
|
2854
2895
|
}
|
|
2855
2896
|
}
|
|
2856
2897
|
};
|
|
2857
2898
|
function getRequiredBetas() {
|
|
2858
|
-
return splitBetaFlags(
|
|
2899
|
+
return splitBetaFlags(
|
|
2900
|
+
process.env.ANTHROPIC_BETA_FLAGS ?? claudeCodeIntegration.loadRequestProfile().betaHeader ?? config.baseBetas.join(",")
|
|
2901
|
+
);
|
|
2859
2902
|
}
|
|
2860
2903
|
function getModelOverride(modelId) {
|
|
2861
2904
|
const lowerModelId = modelId.toLowerCase();
|
|
@@ -2907,26 +2950,30 @@ function ensureOauthBeta(betas) {
|
|
|
2907
2950
|
return betas.includes(OAUTH_BETA) ? betas : [OAUTH_BETA, ...betas];
|
|
2908
2951
|
}
|
|
2909
2952
|
function supports1mContext(modelId) {
|
|
2910
|
-
const lowerModelId = modelId.toLowerCase();
|
|
2911
|
-
if (
|
|
2953
|
+
const lowerModelId = resolveClaudeCodeModelAlias(modelId).toLowerCase();
|
|
2954
|
+
if (isClaudeCode1mModelLabel(modelId)) {
|
|
2955
|
+
return lowerModelId.includes("fable") || lowerModelId.includes("opus") || lowerModelId.includes("sonnet");
|
|
2956
|
+
}
|
|
2957
|
+
if (!lowerModelId.includes("opus") && !lowerModelId.includes("sonnet") && !lowerModelId.includes("fable")) {
|
|
2912
2958
|
return false;
|
|
2913
2959
|
}
|
|
2914
|
-
const versionMatch = lowerModelId.match(/(opus|sonnet)-(\d+)
|
|
2960
|
+
const versionMatch = lowerModelId.match(/(opus|sonnet|fable)-(\d+)(?:-(\d+))?/);
|
|
2915
2961
|
if (!versionMatch) {
|
|
2916
2962
|
return false;
|
|
2917
2963
|
}
|
|
2918
2964
|
const major = Number.parseInt(versionMatch[2], 10);
|
|
2919
|
-
const minor = Number.parseInt(versionMatch[3], 10);
|
|
2965
|
+
const minor = versionMatch[3] ? Number.parseInt(versionMatch[3], 10) : 0;
|
|
2920
2966
|
const effectiveMinor = minor > 99 ? 0 : minor;
|
|
2921
2967
|
return major > 4 || major === 4 && effectiveMinor >= 6;
|
|
2922
2968
|
}
|
|
2923
2969
|
function getModelBetas(modelId, excluded) {
|
|
2970
|
+
const normalizedModelId = resolveClaudeCodeModelAlias(modelId);
|
|
2924
2971
|
const betas = [...getRequiredBetas()];
|
|
2925
2972
|
const longContextBeta = config.longContextBetas[0];
|
|
2926
|
-
if (longContextBeta && process.env.ANTHROPIC_ENABLE_1M_CONTEXT === "true" && supports1mContext(
|
|
2973
|
+
if (longContextBeta && (process.env.ANTHROPIC_ENABLE_1M_CONTEXT === "true" || isClaudeCode1mModelLabel(normalizedModelId)) && supports1mContext(normalizedModelId)) {
|
|
2927
2974
|
betas.push(longContextBeta);
|
|
2928
2975
|
}
|
|
2929
|
-
const override = getModelOverride(
|
|
2976
|
+
const override = getModelOverride(normalizedModelId);
|
|
2930
2977
|
if (override?.exclude) {
|
|
2931
2978
|
for (const excludedBeta of override.exclude) {
|
|
2932
2979
|
const index = betas.indexOf(excludedBeta);
|
|
@@ -3407,15 +3454,18 @@ function getClientOutputEffort(inputBody) {
|
|
|
3407
3454
|
const thinking = isRecord3(inputBody.thinking) ? inputBody.thinking : void 0;
|
|
3408
3455
|
return readOutputEffortValue(outputConfig?.effort) ?? readOutputEffortValue(inputBody.effort) ?? readOutputEffortValue(reasoning?.effort) ?? readOutputEffortValue(inputBody.reasoning_effort) ?? readOutputEffortValue(inputBody.reasoningEffort) ?? readOutputEffortValue(thinking?.effort) ?? effortFromThinkingBudget(thinking);
|
|
3409
3456
|
}
|
|
3410
|
-
function resolveOutputEffort(inputBody, configuredEffort = getConfiguredOutputEffort()) {
|
|
3457
|
+
function resolveOutputEffort(inputBody, configuredEffort = getConfiguredOutputEffort(), modelId) {
|
|
3411
3458
|
if (configuredEffort && configuredEffort !== "client") {
|
|
3412
|
-
return normalizeEffortForWire(configuredEffort);
|
|
3459
|
+
return clampFableEffort(normalizeEffortForWire(configuredEffort), modelId);
|
|
3413
3460
|
}
|
|
3414
3461
|
const clientEffort = getClientOutputEffort(inputBody);
|
|
3415
|
-
return normalizeEffortForWire(clientEffort ?? DEFAULT_OUTPUT_EFFORT);
|
|
3462
|
+
return clampFableEffort(normalizeEffortForWire(clientEffort ?? DEFAULT_OUTPUT_EFFORT), modelId);
|
|
3416
3463
|
}
|
|
3417
3464
|
function isHaikuModel(modelId) {
|
|
3418
|
-
return modelId
|
|
3465
|
+
return resolveClaudeCodeModelAlias(modelId).toLowerCase().includes("haiku");
|
|
3466
|
+
}
|
|
3467
|
+
function clampFableEffort(effort, modelId) {
|
|
3468
|
+
return modelId && isClaudeFableModel(modelId) && (effort === "max" || effort === "xhigh") ? "high" : effort;
|
|
3419
3469
|
}
|
|
3420
3470
|
function collectToolUseIds(message) {
|
|
3421
3471
|
if (!Array.isArray(message.content)) {
|
|
@@ -3456,7 +3506,8 @@ function getDanglingToolUseError(messages) {
|
|
|
3456
3506
|
var ADAPTIVE_THINKING_MODEL_MATCHERS = [
|
|
3457
3507
|
(modelId) => modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-sonnet-4.6"),
|
|
3458
3508
|
(modelId) => modelId.includes("claude-opus-4-6") || modelId.includes("claude-opus-4.6"),
|
|
3459
|
-
(modelId) => /claude-opus-4[-._]([7-9]|\d{2,})/.test(modelId)
|
|
3509
|
+
(modelId) => /claude-opus-4[-._]([7-9]|\d{2,})/.test(modelId),
|
|
3510
|
+
(modelId) => /claude-fable-(?:[5-9]|\d{2,})(?:[-._]\d+)?(?:\[1m\])?$/.test(modelId)
|
|
3460
3511
|
];
|
|
3461
3512
|
var DEFAULT_MAX_OUTPUT_TOKENS = 32e3;
|
|
3462
3513
|
function supportsAdaptiveThinking(modelId) {
|
|
@@ -3464,7 +3515,7 @@ function supportsAdaptiveThinking(modelId) {
|
|
|
3464
3515
|
if (typeof runtimeCapability?.supportsThinking === "boolean") {
|
|
3465
3516
|
return runtimeCapability.supportsThinking;
|
|
3466
3517
|
}
|
|
3467
|
-
const normalized = modelId
|
|
3518
|
+
const normalized = resolveClaudeCodeModelAlias(modelId).toLowerCase();
|
|
3468
3519
|
if (normalized.includes("haiku")) {
|
|
3469
3520
|
return false;
|
|
3470
3521
|
}
|
|
@@ -3535,17 +3586,24 @@ function buildUpstreamRequest(inputBody, identity, template2, options) {
|
|
|
3535
3586
|
const activeSessionId = options?.sessionId ?? getActiveSessionId();
|
|
3536
3587
|
const configuredEffort = getConfiguredOutputEffort() ?? options?.outputEffort;
|
|
3537
3588
|
const incomingTools = Array.isArray(body.tools) ? body.tools : [];
|
|
3538
|
-
|
|
3589
|
+
const selectedTools = selectOpenCodeNativeTools({
|
|
3539
3590
|
incomingTools,
|
|
3540
3591
|
templateTools: template2.tools
|
|
3541
|
-
})
|
|
3542
|
-
|
|
3592
|
+
});
|
|
3593
|
+
body.tools = selectedTools.tools;
|
|
3594
|
+
const modelId = typeof body.model === "string" ? resolveClaudeCodeModelAlias(body.model) : "";
|
|
3595
|
+
if (typeof body.model === "string") {
|
|
3596
|
+
body.model = toClaudeCodeWireModelId(body.model);
|
|
3597
|
+
}
|
|
3598
|
+
if (isClaudeFableModel(modelId) && incomingTools.length === 0 && selectedTools.tools.length > 0) {
|
|
3599
|
+
body.tool_choice = { type: "none" };
|
|
3600
|
+
}
|
|
3543
3601
|
if (supportsAdaptiveThinking(modelId)) {
|
|
3544
3602
|
body.thinking = { type: "adaptive" };
|
|
3545
3603
|
body.context_management = DEFAULT_CONTEXT_MANAGEMENT;
|
|
3546
3604
|
}
|
|
3547
3605
|
if (modelId && !isHaikuModel(modelId)) {
|
|
3548
|
-
body.output_config = { effort: resolveOutputEffort(inputBody, configuredEffort) };
|
|
3606
|
+
body.output_config = { effort: resolveOutputEffort(inputBody, configuredEffort, modelId) };
|
|
3549
3607
|
}
|
|
3550
3608
|
body.max_tokens = resolveMaxTokens(body.max_tokens);
|
|
3551
3609
|
return applyClaudeCodeUpstreamBodyFields(body, {
|
|
@@ -3836,7 +3894,7 @@ function extractModelIdFromBody(body) {
|
|
|
3836
3894
|
}
|
|
3837
3895
|
try {
|
|
3838
3896
|
const parsed = JSON.parse(body);
|
|
3839
|
-
return typeof parsed.model === "string" ? parsed.model : "unknown";
|
|
3897
|
+
return typeof parsed.model === "string" ? resolveClaudeCodeModelAlias(parsed.model) : "unknown";
|
|
3840
3898
|
} catch {
|
|
3841
3899
|
return "unknown";
|
|
3842
3900
|
}
|
|
@@ -4219,7 +4277,6 @@ var AccountRuntimeFactory = class {
|
|
|
4219
4277
|
}
|
|
4220
4278
|
buildOutboundHeaders(incomingHeaders, sessionId2, accessToken, modelId, excludedBetas2) {
|
|
4221
4279
|
const mergedBetas = deduplicateBetas(ensureOauthBeta([
|
|
4222
|
-
...excludeBetas(splitBetaValues(getBetaHeader()), excludedBetas2),
|
|
4223
4280
|
...getModelBetas(modelId, excludedBetas2),
|
|
4224
4281
|
...excludeBetas(splitBetaValues(incomingHeaders["anthropic-beta"]), excludedBetas2)
|
|
4225
4282
|
])).join(",");
|