opencode-anthropic-multi-account 0.2.39 → 0.2.40

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 CHANGED
@@ -47,6 +47,17 @@ 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`. If the client does not provide one, it falls back to `high`.
55
+
56
+ Operators can pin the outbound effort with `CLAUDE_MULTI_ACCOUNT_EFFORT` or
57
+ `ANTHROPIC_MULTI_ACCOUNT_EFFORT`. Supported values are `low`, `medium`, `high`,
58
+ `xhigh`, `max`, `ultracode`, and `client`; `ultracode` is normalized to `xhigh`
59
+ on the wire.
60
+
50
61
  ## Server Mode migration
51
62
 
52
63
  ```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 DEFAULT_OUTPUT_CONFIG = { effort: "high" };
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,35 @@ 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 getConfiguredOutputEffort() {
3446
+ return upstreamRequestTestOverrides.outputEffort ?? readOutputEffortValue(process.env.CLAUDE_MULTI_ACCOUNT_EFFORT) ?? readOutputEffortValue(process.env.ANTHROPIC_MULTI_ACCOUNT_EFFORT);
3447
+ }
3448
+ function getClientOutputEffort(inputBody) {
3449
+ const outputConfig = isRecord3(inputBody.output_config) ? inputBody.output_config : void 0;
3450
+ const reasoning = isRecord3(inputBody.reasoning) ? inputBody.reasoning : void 0;
3451
+ const thinking = isRecord3(inputBody.thinking) ? inputBody.thinking : void 0;
3452
+ return readOutputEffortValue(outputConfig?.effort) ?? readOutputEffortValue(reasoning?.effort) ?? readOutputEffortValue(inputBody.reasoning_effort) ?? readOutputEffortValue(inputBody.reasoningEffort) ?? readOutputEffortValue(thinking?.effort);
3453
+ }
3454
+ function resolveOutputEffort(inputBody, configuredEffort = getConfiguredOutputEffort()) {
3455
+ if (configuredEffort && configuredEffort !== "client") {
3456
+ return normalizeEffortForWire(configuredEffort);
3457
+ }
3458
+ const clientEffort = getClientOutputEffort(inputBody);
3459
+ return normalizeEffortForWire(clientEffort ?? DEFAULT_OUTPUT_EFFORT);
3460
+ }
3461
+ function isHaikuModel(modelId) {
3462
+ return modelId.trim().toLowerCase().includes("haiku");
3463
+ }
3434
3464
  function collectToolUseIds(message) {
3435
3465
  if (!Array.isArray(message.content)) {
3436
3466
  return [];
@@ -3556,7 +3586,9 @@ function buildUpstreamRequest(inputBody, identity, template2, options) {
3556
3586
  if (supportsAdaptiveThinking(modelId)) {
3557
3587
  body.thinking = { type: "adaptive" };
3558
3588
  body.context_management = DEFAULT_CONTEXT_MANAGEMENT;
3559
- body.output_config = DEFAULT_OUTPUT_CONFIG;
3589
+ }
3590
+ if (modelId && !isHaikuModel(modelId)) {
3591
+ body.output_config = { effort: resolveOutputEffort(inputBody) };
3560
3592
  }
3561
3593
  body.max_tokens = resolveMaxTokens(body.max_tokens);
3562
3594
  return applyClaudeCodeUpstreamBodyFields(body, {