opencode-anthropic-fix 0.1.27 → 0.1.28

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/index.mjs CHANGED
@@ -6245,9 +6245,9 @@ function extractFirstUserMessageText(messages) {
6245
6245
  }
6246
6246
 
6247
6247
  const CLAUDE_CODE_BETA_FLAG = "claude-code-20250219";
6248
- const EFFORT_BETA_FLAG = "effort-2025-11-24";
6249
- const ADVANCED_TOOL_USE_BETA_FLAG = "advanced-tool-use-2025-11-20";
6250
- const FAST_MODE_BETA_FLAG = "fast-mode-2026-02-01";
6248
+ const _EFFORT_BETA_FLAG = "effort-2025-11-24";
6249
+ const _ADVANCED_TOOL_USE_BETA_FLAG = "advanced-tool-use-2025-11-20";
6250
+ const _FAST_MODE_BETA_FLAG = "fast-mode-2026-02-01";
6251
6251
  const TOKEN_COUNTING_BETA_FLAG = "token-counting-2024-11-01";
6252
6252
  const CLAUDE_CODE_IDENTITY_STRING = "You are Claude Code, Anthropic's official CLI for Claude.";
6253
6253
  const KNOWN_IDENTITY_STRINGS = new Set([
@@ -7358,24 +7358,12 @@ function buildAnthropicBetaHeader(
7358
7358
  // behavior from the Anthropic API.
7359
7359
  betas.push(CLAUDE_CODE_BETA_FLAG); // "claude-code-20250219"
7360
7360
 
7361
- // Tool search: use provider-aware header.
7362
- // 1P/Foundry u2192 advanced-tool-use-2025-11-20 (enables broader tool capabilities)
7363
- // Vertex/Bedrock u2192 tool-search-tool-2025-10-19 (3P-compatible subset)
7364
- if (provider === "vertex" || provider === "bedrock" || provider === "mantle") {
7365
- betas.push("tool-search-tool-2025-10-19");
7366
- } else {
7367
- betas.push(ADVANCED_TOOL_USE_BETA_FLAG); // "advanced-tool-use-2025-11-20"
7368
- }
7361
+ // v2.1.150: advanced-tool-use / tool-search-tool removed from always-on.
7362
+ // CC 2.1.150 D5q does not push these per-request. Available via custom betas.
7369
7363
 
7370
- betas.push(FAST_MODE_BETA_FLAG); // "fast-mode-2026-02-01"
7364
+ // v2.1.150: fast-mode-2026-02-01 removed from always-on (CC sends only when speed feature active).
7371
7365
 
7372
- // effort-2025-11-24 — real CC's Lyz() only pushes this flag when rE(model)
7373
- // is true (Opus 4.6 / Sonnet 4.6). Pushing it for non-adaptive models like
7374
- // Haiku is a fingerprint mismatch vs real CC and can contaminate billing
7375
- // attribution even when the request body has no effort field.
7376
- if (isAdaptiveThinkingModel(model)) {
7377
- betas.push(EFFORT_BETA_FLAG); // "effort-2025-11-24"
7378
- }
7366
+ // v2.1.150: effort-2025-11-24 removed from always-on (CC sends only when effort is explicitly requested).
7379
7367
 
7380
7368
  // Interleaved thinking — real CC's i01 pushes via hv4(model), which is
7381
7369
  // (firstParty && non-Claude-3). Claude 3.x models don't support interleaved
@@ -7400,18 +7388,20 @@ function buildAnthropicBetaHeader(
7400
7388
  if (!isRoundRobin) {
7401
7389
  betas.push("prompt-caching-scope-2026-01-05");
7402
7390
  }
7391
+ // v2.1.150: extended-cache-ttl for better cache hit rates (opt-out via token_economy.extended_cache_ttl = false).
7392
+ if (te.extended_cache_ttl !== false && !isRoundRobin) {
7393
+ betas.push("extended-cache-ttl-2025-04-11");
7394
+ }
7403
7395
 
7404
7396
  // === CONDITIONAL BETAS (model/context-dependent) ===
7405
7397
 
7406
- // Context management — gated to Claude 4+ models in CC v2.1.90.
7407
- // Excluded for Claude 3.x (not supported). Always-on for Claude 4+ on 1P/Foundry.
7408
- if (!/claude-3-/i.test(model)) {
7398
+ // v2.1.150: context-management gated behind opt-in (CC has hardcoded && false).
7399
+ if (te.context_management && !/claude-3-/i.test(model)) {
7409
7400
  betas.push("context-management-2025-06-27");
7410
7401
  }
7411
7402
 
7412
- // Structured outputs: only -2025-12-15 is active in v2.1.90 runtime.
7413
- // token-efficient-tools-2026-03-28 was fully removed from v90 bundle.
7414
- if (supportsStructuredOutputs(model)) {
7403
+ // v2.1.150: structured-outputs gated behind opt-in (CC has behind tengu_tool_pear flag).
7404
+ if (te.structured_outputs && supportsStructuredOutputs(model)) {
7415
7405
  betas.push("structured-outputs-2025-12-15");
7416
7406
  }
7417
7407
 
@@ -7445,12 +7435,6 @@ function buildAnthropicBetaHeader(
7445
7435
  betas.push("context-hint-2026-04-09");
7446
7436
  }
7447
7437
 
7448
- // extended-cache-ttl-2025-04-11 — found in CC v2.1.143. Extends server-side
7449
- // prompt cache TTL. Auto-on for 1P + Claude 4+ to improve cache hit rates.
7450
- if (isFirstPartyProvider && !/claude-3-/i.test(model)) {
7451
- betas.push("extended-cache-ttl-2025-04-11");
7452
- }
7453
-
7454
7438
  // Files API — scoped to file endpoints/references
7455
7439
  if (isFilesEndpoint || hasFileReferences) {
7456
7440
  betas.push("files-api-2025-04-14");
@@ -7463,13 +7447,18 @@ function buildAnthropicBetaHeader(
7463
7447
 
7464
7448
  // === TOKEN ECONOMY BETAS (on by default for token savings) ===
7465
7449
 
7466
- // redact-thinking: suppresses thinking summaries server-side.
7467
- // CC v108 enables this by default but we keep it off so thinking is visible.
7468
- // Users can opt in via `/anthropic set redact-thinking on`.
7469
- if (te.redact_thinking && !disableExperimentalBetas) {
7450
+ // v2.1.150: redact-thinking is default-ON in CC (first-party, non-SDK, thinking models).
7451
+ // Opt out via `/anthropic set redact-thinking off` to see thinking content.
7452
+ if (te.redact_thinking !== false && !disableExperimentalBetas && !/claude-3-/i.test(model)) {
7470
7453
  betas.push("redact-thinking-2026-02-12");
7471
7454
  }
7472
7455
 
7456
+ // v2.1.150: thinking-token-count for token budget tracking (behind tengu_chert_bezel in CC).
7457
+ // Default ON for token economy visibility. Opt out via token_economy.thinking_token_count = false.
7458
+ if (te.thinking_token_count !== false && !disableExperimentalBetas && !/claude-3-/i.test(model)) {
7459
+ betas.push("thinking-token-count-2026-05-13");
7460
+ }
7461
+
7473
7462
  // compact-2026-01-12 and mcp-client-2025-11-20 exist only in docs, not runtime.
7474
7463
 
7475
7464
  // afk-mode — NOT auto-included (requires user opt-in)
@@ -7704,7 +7693,7 @@ function buildRequestHeaders(
7704
7693
  // the minifier identifier renamed, d66 → g86). Re-verify on every upstream bump:
7705
7694
  // rg -n '"0\.\d+\.\d+"' _tmp_claude_pkg/<version>/package/cli.js | rg -C2 stainless
7706
7695
  // See docs/future-improvements.md §7 and claude-code-reverse-engineering.md §16.
7707
- requestHeaders.set("x-stainless-package-version", "0.81.0");
7696
+ requestHeaders.set("x-stainless-package-version", "0.94.0");
7708
7697
  // Real CC on Windows/Node reports "node" — confirmed via proxy capture.
7709
7698
  requestHeaders.set("x-stainless-runtime", "node");
7710
7699
  requestHeaders.set("x-stainless-runtime-version", process.version);
package/lib/config.mjs CHANGED
@@ -197,9 +197,9 @@ export const DEFAULT_CONFIG = {
197
197
  * This flag is retained for config backward compatibility but has no effect. */
198
198
  token_efficient_tools: false,
199
199
  /** Enable redact-thinking-2026-02-12 beta (suppresses thinking summaries
200
- * server-side for lower bandwidth). Off by default so thinking stays
201
- * visible. Opt in via `/anthropic set redact-thinking on`. */
202
- redact_thinking: false,
200
+ * server-side for lower bandwidth). On by default for non-Claude-3 models
201
+ * (CC v2.1.150+). Opt out via `/anthropic set redact-thinking off`. */
202
+ redact_thinking: true,
203
203
  /** Enable context-hint-2026-04-09 beta (CC v2.1.110+). When on, the server
204
204
  * MAY reject 422/424 and trigger client-side compaction retries.
205
205
  * Default ON (Phase C2). Server-side gating + contextHintState.disabled
@@ -16,7 +16,7 @@
16
16
  // Version / build / SDK constants
17
17
  // ---------------------------------------------------------------------------
18
18
 
19
- export const FALLBACK_CLAUDE_CLI_VERSION = "2.1.143";
19
+ export const FALLBACK_CLAUDE_CLI_VERSION = "2.1.150";
20
20
  export const CLAUDE_CODE_NPM_LATEST_URL = "https://registry.npmjs.org/@anthropic-ai/claude-code/latest";
21
21
  export const CLAUDE_CODE_BUILD_TIME = "2026-05-15T17:39:39Z";
22
22
 
@@ -28,10 +28,11 @@ export const CLAUDE_CODE_BUILD_TIME = "2026-05-15T17:39:39Z";
28
28
  // no SDK version bump; mid-conversation-system-2026-04-07 registered in 2.1.143 but not
29
29
  // auto-emitted; two new conditional x- headers x-claude-code-agent-id /
30
30
  // x-claude-code-parent-agent-id are only emitted in subagent dispatch contexts).
31
- export const ANTHROPIC_SDK_VERSION = "0.81.0";
31
+ export const ANTHROPIC_SDK_VERSION = "0.94.0";
32
32
 
33
33
  // Map of CLI version to bundled SDK version (update when CLI version changes)
34
34
  export const CLI_TO_SDK_VERSION = new Map([
35
+ ["2.1.150", "0.94.0"],
35
36
  ["2.1.143", "0.81.0"],
36
37
  ["2.1.142", "0.81.0"],
37
38
  ["2.1.141", "0.81.0"],
@@ -159,6 +160,18 @@ export const BETA_SHORTCUTS = new Map([
159
160
  ["redact-thinking", "redact-thinking-2026-02-12"],
160
161
  ["mid-conv-system", "mid-conversation-system-2026-04-07"],
161
162
  ["mid-system", "mid-conversation-system-2026-04-07"],
163
+ ["context-management", "context-management-2025-06-27"],
164
+ ["structured-outputs", "structured-outputs-2025-12-15"],
165
+ ["web-search", "web-search-2025-03-05"],
166
+ ["advanced-tool-use", "advanced-tool-use-2025-11-20"],
167
+ ["tool-search-tool", "tool-search-tool-2025-10-19"],
168
+ ["effort", "effort-2025-11-24"],
169
+ ["prompt-caching-scope", "prompt-caching-scope-2026-01-05"],
170
+ ["thinking-token-count", "thinking-token-count-2026-05-13"],
171
+ ["afk-mode", "afk-mode-2026-01-31"],
172
+ ["advisor-tool", "advisor-tool-2026-03-01"],
173
+ ["mcp-servers", "mcp-servers-2025-12-04"],
174
+ ["ccr-byoc", "ccr-byoc-2025-07-29"],
162
175
  ]);
163
176
 
164
177
  // ---------------------------------------------------------------------------
@@ -13,8 +13,8 @@ import {
13
13
  } from "./request-headers.mjs";
14
14
 
15
15
  describe("request-headers constants", () => {
16
- it("FALLBACK_CLAUDE_CLI_VERSION is 2.1.143", () => {
17
- expect(FALLBACK_CLAUDE_CLI_VERSION).toBe("2.1.143");
16
+ it("FALLBACK_CLAUDE_CLI_VERSION is 2.1.150", () => {
17
+ expect(FALLBACK_CLAUDE_CLI_VERSION).toBe("2.1.150");
18
18
  });
19
19
 
20
20
  it("ANTHROPIC_SDK_VERSION matches expected value", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-anthropic-fix",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "license": "GPL-3.0-or-later",
5
5
  "repository": {
6
6
  "type": "git",