opencode-anthropic-fix 0.0.15 → 0.0.17

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
@@ -2,6 +2,16 @@
2
2
 
3
3
  Use your Claude Pro or Max subscription with [OpenCode](https://github.com/anomalyco/opencode). Supports multiple accounts with automatic rotation when you hit rate limits.
4
4
 
5
+ ## Background
6
+
7
+ [AnomalyCo](https://github.com/anomalyco/opencode-anthropic-auth) originally published this as a built-in plugin shipped with OpenCode itself. The repo was archived following a legal request from Anthropic. Before it was archived, [rmk40](https://github.com/rmk40/opencode-anthropic-auth) — a frequent contributor unrelated to AnomalyCo — had developed multi-account support that never made it upstream.
8
+
9
+ This fork continues that work and extends it with deeper research into how the official Claude Code CLI identifies itself to the API. The mimicry was derived by analyzing [Claude Code's open source code on GitHub](https://github.com/anthropics/claude-code). This isn't just a system prompt injection — see the [full mimicry analysis](https://github.com/marco-jardim/opencode-anthropic-fix/blob/master/docs/mimese-http-header-system-prompt.md) for details.
10
+
11
+ > **Educational purpose.** This code exists to study how Anthropic's OAuth protocol and Claude Code's HTTP communication pattern work. It is not intended to be used in violation of Anthropic's Terms of Service.
12
+
13
+ > **Account risk.** There is a real risk of account suspension if Anthropic detects requests are not coming from Claude Code. The mimicry tries hard to make every request look as close as possible to a genuine Claude Code request, but that reduces rather than eliminates the risk. Use at your own risk.
14
+
5
15
  ## Quick Start
6
16
 
7
17
  **Prerequisites:** [OpenCode](https://github.com/anomalyco/opencode) installed, a Claude Pro or Max subscription, Node.js 18+.
@@ -23,16 +33,16 @@ opencode
23
33
 
24
34
  That's it. OpenCode will now use your Claude subscription directly. All model costs show as $0.00.
25
35
 
26
- ## Why This Fork?
36
+ ## What This Fork Adds
27
37
 
28
- The [upstream plugin](https://github.com/anomalyco/opencode-anthropic-auth) ships as a built-in default with OpenCode. This fork adds:
38
+ The [original plugin](https://github.com/anomalyco/opencode-anthropic-auth) provided basic OAuth support. This fork adds:
29
39
 
30
40
  - **Multi-account support** — add up to 10 Claude accounts and rotate between them
31
41
  - **Automatic rate limit handling** — when one account hits a limit, the plugin switches to another
32
42
  - **Health scoring** — tracks account reliability and prefers healthy accounts
33
43
  - **Standalone CLI** — manage accounts without opening OpenCode
34
44
  - **Configurable strategies** — sticky, round-robin, or hybrid account selection
35
- - **Claude Code signature emulation** — optional Claude-style request headers with startup version lookup
45
+ - **Claude Code signature emulation** — full HTTP header, system prompt, beta flag, and metadata mimicry derived from Claude Code's open source code
36
46
  - **Adaptive thinking for Opus 4.6** — automatically uses `adaptive-thinking-2026-01-28` and maps `budgetTokens` to effort levels (`low`/`medium`/`high`/`max`)
37
47
  - **1M context limit override** — patches `model.limit.context` so OpenCode compacts at the right threshold while `models.dev` catches up
38
48
 
package/cli.mjs CHANGED
@@ -160,6 +160,7 @@ export async function refreshAccessToken(account) {
160
160
  account.access = json.access_token;
161
161
  account.expires = Date.now() + json.expires_in * 1000;
162
162
  if (json.refresh_token) account.refreshToken = json.refresh_token;
163
+ account.token_updated_at = Date.now();
163
164
  return json.access_token;
164
165
  } catch {
165
166
  return null;
@@ -393,6 +394,7 @@ export async function cmdLogin() {
393
394
  refreshToken: credentials.refresh,
394
395
  access: credentials.access,
395
396
  expires: credentials.expires,
397
+ token_updated_at: now,
396
398
  addedAt: now,
397
399
  lastUsed: 0,
398
400
  enabled: true,