opencode-anthropic-fix 0.1.21 → 0.1.23

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.
Files changed (3) hide show
  1. package/cli.mjs +0 -0
  2. package/index.mjs +24 -5
  3. package/package.json +9 -1
package/cli.mjs CHANGED
File without changes
package/index.mjs CHANGED
@@ -5390,18 +5390,22 @@ process.once("beforeExit", _beforeExitHandler);
5390
5390
  // Request building helpers (extracted from original fetch interceptor)
5391
5391
  // ---------------------------------------------------------------------------
5392
5392
 
5393
- const FALLBACK_CLAUDE_CLI_VERSION = "2.1.114";
5393
+ const FALLBACK_CLAUDE_CLI_VERSION = "2.1.117";
5394
5394
  const CLAUDE_CODE_NPM_LATEST_URL = "https://registry.npmjs.org/@anthropic-ai/claude-code/latest";
5395
- const CLAUDE_CODE_BUILD_TIME = "2026-04-17T22:37:24Z";
5395
+ const CLAUDE_CODE_BUILD_TIME = "2026-04-21T17:58:52Z";
5396
5396
 
5397
5397
  // The @anthropic-ai/sdk version bundled with Claude Code.
5398
5398
  // This is distinct from the CLI version and goes in X-Stainless-Package-Version.
5399
5399
  // v2.1.107 switched from @anthropic-ai/sdk v0.208.0 to v0.81.0 (confirmed via bundle var x$H="0.81.0").
5400
- // Still 0.81.0 in v2.1.114 (verified via strings extraction from native Bun binary).
5400
+ // Still 0.81.0 in v2.1.117 (verified via strings extraction from native Bun binary;
5401
+ // 84 beta flags + x-headers byte-identical to 2.1.116 — cosmetic bump).
5401
5402
  const ANTHROPIC_SDK_VERSION = "0.81.0";
5402
5403
 
5403
5404
  // Map of CLI version → bundled SDK version (update when CLI version changes)
5404
5405
  const CLI_TO_SDK_VERSION = new Map([
5406
+ ["2.1.117", "0.81.0"],
5407
+ ["2.1.116", "0.81.0"],
5408
+ ["2.1.115", "0.81.0"],
5405
5409
  ["2.1.114", "0.81.0"],
5406
5410
  ["2.1.113", "0.81.0"],
5407
5411
  ["2.1.112", "0.81.0"],
@@ -6934,13 +6938,28 @@ function isTitleGeneratorSystemBlocks(system) {
6934
6938
  * @param {any[] | undefined} system
6935
6939
  * @returns {Array<{type: string, text: string, cache_control?: {type: string}}>}
6936
6940
  */
6941
+ // Env-context fingerprint rewrite: opencode emits
6942
+ // "Here is some useful information about the environment you are running in:"
6943
+ // Real CC 2.1.117 emits
6944
+ // "Here is useful information about the environment you are running in:"
6945
+ // Removing "some " gives byte-level parity with the CC fingerprint and saves
6946
+ // ~1 token in the non-cached portion. Unconditional, every request.
6947
+ const OPENCODE_ENV_CONTEXT_PREFIX = "Here is some useful information about the environment you are running in:";
6948
+ const CC_ENV_CONTEXT_PREFIX = "Here is useful information about the environment you are running in:";
6949
+
6950
+ function rewriteEnvContextPhrasing(text) {
6951
+ if (typeof text !== "string" || text.length === 0) return text;
6952
+ if (text.indexOf(OPENCODE_ENV_CONTEXT_PREFIX) === -1) return text;
6953
+ return text.split(OPENCODE_ENV_CONTEXT_PREFIX).join(CC_ENV_CONTEXT_PREFIX);
6954
+ }
6955
+
6937
6956
  function normalizeSystemTextBlocks(system) {
6938
6957
  const output = [];
6939
6958
  if (!Array.isArray(system)) return output;
6940
6959
 
6941
6960
  for (const item of system) {
6942
6961
  if (typeof item === "string") {
6943
- output.push({ type: "text", text: item });
6962
+ output.push({ type: "text", text: rewriteEnvContextPhrasing(item) });
6944
6963
  continue;
6945
6964
  }
6946
6965
 
@@ -6949,7 +6968,7 @@ function normalizeSystemTextBlocks(system) {
6949
6968
 
6950
6969
  const normalized = {
6951
6970
  type: typeof item.type === "string" ? item.type : "text",
6952
- text: item.text,
6971
+ text: rewriteEnvContextPhrasing(item.text),
6953
6972
  };
6954
6973
 
6955
6974
  // Intentionally strip cache_control from incoming system blocks.
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "opencode-anthropic-fix",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "license": "GPL-3.0-or-later",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/marco-jardim/opencode-anthropic-fix.git"
8
+ },
9
+ "homepage": "https://github.com/marco-jardim/opencode-anthropic-fix#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/marco-jardim/opencode-anthropic-fix/issues"
12
+ },
5
13
  "main": "./index.mjs",
6
14
  "files": [
7
15
  "index.mjs",