opencode-anthropic-fix 0.6.0 → 1.0.0

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
@@ -58,7 +58,7 @@ The [original plugin](https://github.com/anomalyco/opencode-anthropic-auth) prov
58
58
  - **Health scoring** — tracks account reliability and prefers healthy accounts
59
59
  - **Standalone CLI** — manage accounts without opening OpenCode
60
60
  - **Configurable strategies** — sticky, round-robin, or hybrid account selection
61
- - **Claude Code signature emulation** — full HTTP header, system prompt, beta flag, and metadata mimicry derived from Claude Code's open source code. System prompt cache scoping follows the real CC's three-path `splitSysPromptPrefix()` architecture (boundary/global/org) with exact marker detection and scope-aware `cache_control` generation
61
+ - **Claude Code signature emulation** — full HTTP header, system prompt, beta flag, and metadata mimicry derived from Claude Code's open source code. Canonical Claude Code protocol composition (headers, body, system prefix, betas, URL) is sourced from [`@tormentalabs/claude-code-wire-compat`](https://www.npmjs.com/package/@tormentalabs/claude-code-wire-compat); system prompt cache scoping stays host policy (`splitSystemCacheScopes`, boundary/global/org) with exact marker detection and scope-aware `cache_control` generation
62
62
  - **OAuth endpoint fingerprint parity** — matches the real CLI's bundled axios 1.13.6 HTTP client signature (`Accept`, `User-Agent`, `Content-Type`) on all OAuth token endpoint calls, required since 2026-03-21 server-side enforcement
63
63
  - **Billing header fingerprint parity** — `cc_version` suffix uses the real CLI's 3-char fingerprint hash (SHA-256 of salt + first user message chars + version), `cch=00000` is a static placeholder (xxHash64 attestation was removed in Claude Code v2.1.97), system prompt is sanitized to match Claude Code's pattern validation, and `X-Claude-Code-Session-Id` header is sent on all requests
64
64
  - **Adaptive thinking for Opus/Sonnet 4.6** — automatically normalizes thinking to `{type: "adaptive"}` for supported models, with `effort-2025-11-24` beta
@@ -597,9 +597,36 @@ The plugin also:
597
597
  - Emulates Claude-style request headers and beta flags by default
598
598
  - Sanitizes "OpenCode" references to "Claude Code" in system prompts (required by Anthropic's API)
599
599
  - In `prompt_compaction="minimal"`, deduplicates repeated/contained system blocks and uses a compact dedicated prompt for internal title-generation requests
600
- - Adds `?beta=true` to `/v1/messages` and `/v1/messages/count_tokens` requests
600
+ - With signature emulation on, adds `?beta=true` to `/v1/messages` and `/v1/messages/count_tokens` requests (and
601
+ normalizes a `/messages` path to `/v1/messages`). With it off, the host's URL is sent untouched.
601
602
 
602
- When signature emulation is disabled (`signature_emulation.enabled=false`), the plugin falls back to legacy behavior including the Claude Code system prompt prefix.
603
+ ### Signature emulation
604
+
605
+ `signature_emulation.enabled` is a strictly binary switch — there is no half-way mode.
606
+
607
+ **On (default):** every `/v1/messages` and `/v1/messages/count_tokens` turn is built by the shared
608
+ `@tormentalabs/claude-code-wire-compat` package: full Claude Code header set, beta list, identity/billing system
609
+ blocks and `metadata.user_id`.
610
+
611
+ **Off: pure passthrough plus the auth envelope.** The plugin forges nothing. Your request goes out as your client wrote
612
+ it — same `user-agent`, same headers, same body bytes — with only three changes, all of which belong to the OAuth
613
+ transport rather than to the disguise:
614
+
615
+ - `authorization: Bearer <account token>` — without it there is no request and no account rotation;
616
+ - `anthropic-beta` — **additive**: your value is preserved verbatim and `oauth-2025-04-20` is appended only when
617
+ missing, because the API rejects an OAuth bearer that does not carry it;
618
+ - `x-api-key` and `x-session-affinity` are removed — a second credential must not travel next to your bearer, and the
619
+ affinity hint leaks session identity upstream.
620
+
621
+ The body is not transformed either. Two fields are stripped because the API rejects them outright: the body-level
622
+ `betas` field and any stainless-helper markers your client attached.
623
+
624
+ > **Changed in the unreleased version.** Emulation-off used to still forge a `claude-cli` user-agent and REPLACE your
625
+ > `anthropic-beta` with a minimal list, and it ran structural body normalizations (which also emptied your `system`
626
+ > prompt and injected a `temperature` you never sent). All of that is gone. See the CHANGELOG.
627
+
628
+ The system-prompt side is unchanged: with emulation off the plugin uses the legacy system transform path, including
629
+ the Claude Code system prompt prefix.
603
630
 
604
631
  ## Files
605
632