opencode-anthropic-multi-account 0.2.39 → 0.2.41
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/README.md +13 -0
- package/dist/index.js +45 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,6 +47,19 @@ Claude tool handling is OpenCode-first:
|
|
|
47
47
|
|
|
48
48
|
This is an internal compatibility policy, not a third user-facing mode.
|
|
49
49
|
|
|
50
|
+
## Claude Code effort
|
|
51
|
+
|
|
52
|
+
For non-Haiku Claude Code requests, the plugin forwards a client-provided effort
|
|
53
|
+
from `output_config.effort`, `reasoning.effort`, `reasoning_effort`, or
|
|
54
|
+
`reasoningEffort`. It also maps OpenCode/Anthropic `thinking.budgetTokens`
|
|
55
|
+
or Anthropic wire `thinking.budget_tokens` into an output effort. If the client
|
|
56
|
+
does not provide one, it falls back to `high`.
|
|
57
|
+
|
|
58
|
+
Operators can pin the outbound effort with `CLAUDE_MULTI_ACCOUNT_EFFORT` or
|
|
59
|
+
`ANTHROPIC_MULTI_ACCOUNT_EFFORT`. Supported values are `low`, `medium`, `high`,
|
|
60
|
+
`xhigh`, `max`, `ultracode`, and `client`; `ultracode` is normalized to `xhigh`
|
|
61
|
+
on the wire.
|
|
62
|
+
|
|
50
63
|
## Server Mode migration
|
|
51
64
|
|
|
52
65
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -3407,7 +3407,8 @@ function enrichIncomingToolsWithTemplateSchemas(incomingTools, templateTools) {
|
|
|
3407
3407
|
// src/request/upstream-request.ts
|
|
3408
3408
|
var SESSION_IDLE_ROTATE_MS = 15 * 60 * 1e3;
|
|
3409
3409
|
var DEFAULT_CONTEXT_MANAGEMENT = {};
|
|
3410
|
-
var
|
|
3410
|
+
var DEFAULT_OUTPUT_EFFORT = "high";
|
|
3411
|
+
var VALID_OUTPUT_EFFORT_VALUES = /* @__PURE__ */ new Set(["low", "medium", "high", "xhigh", "ultracode", "max", "client"]);
|
|
3411
3412
|
var upstreamRequestTestOverrides = {};
|
|
3412
3413
|
var sessionId = randomUUID4();
|
|
3413
3414
|
var sessionLastUsed = 0;
|
|
@@ -3431,6 +3432,46 @@ function getUpstreamSessionId() {
|
|
|
3431
3432
|
function isRecord3(value) {
|
|
3432
3433
|
return typeof value === "object" && value !== null;
|
|
3433
3434
|
}
|
|
3435
|
+
function readString(value) {
|
|
3436
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
3437
|
+
}
|
|
3438
|
+
function readOutputEffortValue(value) {
|
|
3439
|
+
const normalized = readString(value)?.toLowerCase();
|
|
3440
|
+
return normalized && VALID_OUTPUT_EFFORT_VALUES.has(normalized) ? normalized : void 0;
|
|
3441
|
+
}
|
|
3442
|
+
function normalizeEffortForWire(effort) {
|
|
3443
|
+
return effort === "ultracode" ? "xhigh" : effort;
|
|
3444
|
+
}
|
|
3445
|
+
function readPositiveNumber(value) {
|
|
3446
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
3447
|
+
}
|
|
3448
|
+
function effortFromThinkingBudget(thinking) {
|
|
3449
|
+
const budgetTokens = readPositiveNumber(thinking?.budget_tokens) ?? readPositiveNumber(thinking?.budgetTokens);
|
|
3450
|
+
if (budgetTokens === void 0) return void 0;
|
|
3451
|
+
if (budgetTokens >= 32e3) return "max";
|
|
3452
|
+
if (budgetTokens >= 16e3) return "high";
|
|
3453
|
+
if (budgetTokens >= 8e3) return "medium";
|
|
3454
|
+
return "low";
|
|
3455
|
+
}
|
|
3456
|
+
function getConfiguredOutputEffort() {
|
|
3457
|
+
return upstreamRequestTestOverrides.outputEffort ?? readOutputEffortValue(process.env.CLAUDE_MULTI_ACCOUNT_EFFORT) ?? readOutputEffortValue(process.env.ANTHROPIC_MULTI_ACCOUNT_EFFORT);
|
|
3458
|
+
}
|
|
3459
|
+
function getClientOutputEffort(inputBody) {
|
|
3460
|
+
const outputConfig = isRecord3(inputBody.output_config) ? inputBody.output_config : void 0;
|
|
3461
|
+
const reasoning = isRecord3(inputBody.reasoning) ? inputBody.reasoning : void 0;
|
|
3462
|
+
const thinking = isRecord3(inputBody.thinking) ? inputBody.thinking : void 0;
|
|
3463
|
+
return readOutputEffortValue(outputConfig?.effort) ?? readOutputEffortValue(reasoning?.effort) ?? readOutputEffortValue(inputBody.reasoning_effort) ?? readOutputEffortValue(inputBody.reasoningEffort) ?? readOutputEffortValue(thinking?.effort) ?? effortFromThinkingBudget(thinking);
|
|
3464
|
+
}
|
|
3465
|
+
function resolveOutputEffort(inputBody, configuredEffort = getConfiguredOutputEffort()) {
|
|
3466
|
+
if (configuredEffort && configuredEffort !== "client") {
|
|
3467
|
+
return normalizeEffortForWire(configuredEffort);
|
|
3468
|
+
}
|
|
3469
|
+
const clientEffort = getClientOutputEffort(inputBody);
|
|
3470
|
+
return normalizeEffortForWire(clientEffort ?? DEFAULT_OUTPUT_EFFORT);
|
|
3471
|
+
}
|
|
3472
|
+
function isHaikuModel(modelId) {
|
|
3473
|
+
return modelId.trim().toLowerCase().includes("haiku");
|
|
3474
|
+
}
|
|
3434
3475
|
function collectToolUseIds(message) {
|
|
3435
3476
|
if (!Array.isArray(message.content)) {
|
|
3436
3477
|
return [];
|
|
@@ -3556,7 +3597,9 @@ function buildUpstreamRequest(inputBody, identity, template2, options) {
|
|
|
3556
3597
|
if (supportsAdaptiveThinking(modelId)) {
|
|
3557
3598
|
body.thinking = { type: "adaptive" };
|
|
3558
3599
|
body.context_management = DEFAULT_CONTEXT_MANAGEMENT;
|
|
3559
|
-
|
|
3600
|
+
}
|
|
3601
|
+
if (modelId && !isHaikuModel(modelId)) {
|
|
3602
|
+
body.output_config = { effort: resolveOutputEffort(inputBody) };
|
|
3560
3603
|
}
|
|
3561
3604
|
body.max_tokens = resolveMaxTokens(body.max_tokens);
|
|
3562
3605
|
return applyClaudeCodeUpstreamBodyFields(body, {
|