opencode-anthropic-fix 0.0.33 → 0.0.34

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
@@ -3023,7 +3023,7 @@ class TelemetryEmitter {
3023
3023
  node_version: process.version,
3024
3024
  terminal: process.env.TERM_PROGRAM || process.env.TERM || "",
3025
3025
  version: this.#cliVersion,
3026
- build_time: "", // omit — we don't know the real build time
3026
+ build_time: CLAUDE_CODE_BUILD_TIME,
3027
3027
  is_ci: false,
3028
3028
  },
3029
3029
  ...extras,
@@ -3133,16 +3133,18 @@ process.once("beforeExit", () => {
3133
3133
  // Request building helpers (extracted from original fetch interceptor)
3134
3134
  // ---------------------------------------------------------------------------
3135
3135
 
3136
- const FALLBACK_CLAUDE_CLI_VERSION = "2.1.83";
3136
+ const FALLBACK_CLAUDE_CLI_VERSION = "2.1.84";
3137
3137
  const CLAUDE_CODE_NPM_LATEST_URL = "https://registry.npmjs.org/@anthropic-ai/claude-code/latest";
3138
+ const CLAUDE_CODE_BUILD_TIME = "2026-03-25T23:48:41Z";
3138
3139
 
3139
- // The @anthropic-ai/sdk version bundled with Claude Code v2.1.83.
3140
+ // The @anthropic-ai/sdk version bundled with Claude Code v2.1.84.
3140
3141
  // This is distinct from the CLI version and goes in X-Stainless-Package-Version.
3141
- // Verified by extracting VERSION="0.208.0" from the bundled cli.js of v2.1.80/2.1.81/2.1.83.
3142
+ // Verified by extracting VERSION="0.208.0" from the bundled cli.js of v2.1.84.
3142
3143
  const ANTHROPIC_SDK_VERSION = "0.208.0";
3143
3144
 
3144
3145
  // Map of CLI version → bundled SDK version (update when CLI version changes)
3145
3146
  const CLI_TO_SDK_VERSION = new Map([
3147
+ ["2.1.84", "0.208.0"],
3146
3148
  ["2.1.83", "0.208.0"],
3147
3149
  ["2.1.81", "0.208.0"],
3148
3150
  ["2.1.80", "0.208.0"],
@@ -3593,9 +3595,9 @@ function buildRequestMetadata(input) {
3593
3595
 
3594
3596
  /**
3595
3597
  * Build the billing header block for Claude Code system prompt injection.
3596
- * Claude Code v2.1.81+: cch computed via NP1() from first user message, cc_version includes model ID.
3598
+ * Claude Code v2.1.84: cch computed via NP1() from first user message, cc_version includes model ID.
3597
3599
  *
3598
- * @param {string} version - CLI version (e.g., "2.1.83")
3600
+ * @param {string} version - CLI version (e.g., "2.1.84")
3599
3601
  * @param {string} [modelId] - Model ID to append (e.g., "claude-opus-4-6")
3600
3602
  * @param {string} [firstUserMessage] - First user message text for cch hash computation
3601
3603
  * @returns {string}
@@ -3920,7 +3922,7 @@ function buildAnthropicBetaHeader(
3920
3922
  const haiku = isHaikuModel(model);
3921
3923
  const isRoundRobin = strategy === "round-robin";
3922
3924
 
3923
- // === ALWAYS-ON BETAS (Claude Code v2.1.83 base set) ===
3925
+ // === ALWAYS-ON BETAS (Claude Code v2.1.84 base set) ===
3924
3926
  // These are ALWAYS included regardless of env vars or feature flags.
3925
3927
  if (!haiku) {
3926
3928
  betas.push(CLAUDE_CODE_BETA_FLAG); // "claude-code-20250219"
@@ -4230,6 +4232,9 @@ function buildRequestHeaders(input, requestInit, accessToken, requestBody, reque
4230
4232
  if (isTruthyEnv(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION)) {
4231
4233
  requestHeaders.set("x-anthropic-additional-protection", "true");
4232
4234
  }
4235
+
4236
+ // Claude Code v2.1.84: x-client-request-id — unique UUID per request for debugging timeouts.
4237
+ requestHeaders.set("x-client-request-id", randomUUID());
4233
4238
  }
4234
4239
  requestHeaders.delete("x-api-key");
4235
4240
 
@@ -4282,6 +4287,15 @@ function transformRequestBody(body, signature, runtime, betaHeader) {
4282
4287
  if (thinkingActive) {
4283
4288
  // Anthropic API rejects temperature when thinking is enabled
4284
4289
  delete parsed.temperature;
4290
+
4291
+ // Claude Code v2.1.84: inject context_management body field when thinking
4292
+ // is active and context-management beta is in use. This tells the API how
4293
+ // to handle thinking blocks during context management operations.
4294
+ if (!parsed.context_management) {
4295
+ parsed.context_management = {
4296
+ edits: [{ type: "clear_thinking_20251015", keep: "all" }],
4297
+ };
4298
+ }
4285
4299
  } else {
4286
4300
  // Claude Code always uses temperature: 1 for non-thinking requests (RE doc §5.2, never 0)
4287
4301
  parsed.temperature = 1;
package/lib/oauth.mjs CHANGED
@@ -13,7 +13,7 @@ const OAUTH_TOKEN_URL = `https://${OAUTH_CONSOLE_HOST}/v1/oauth/token`;
13
13
  const OAUTH_REVOKE_URL = `https://${OAUTH_CONSOLE_HOST}/v1/oauth/revoke`;
14
14
  // Real Claude Code uses axios 1.13.6 for OAuth calls — axios sets User-Agent
15
15
  // automatically and adds Accept header. We must match this fingerprint exactly.
16
- // CLI version profile: 2.1.83 (for reference; not sent on OAuth calls)
16
+ // CLI version profile: 2.1.84 (for reference; not sent on OAuth calls)
17
17
  const OAUTH_AXIOS_VERSION = "1.13.6";
18
18
  const OAUTH_USER_AGENT = `axios/${OAUTH_AXIOS_VERSION}`;
19
19
  const OAUTH_ACCEPT = "application/json, text/plain, */*";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-anthropic-fix",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "license": "GPL-3.0-or-later",
5
5
  "main": "./index.mjs",
6
6
  "files": [