opencode-anthropic-fix 0.0.24 → 0.0.26
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/LICENSE +648 -21
- package/README.md +13 -5
- package/index.mjs +930 -156
- package/lib/accounts.mjs +30 -0
- package/lib/backoff.mjs +25 -0
- package/lib/config.mjs +51 -0
- package/lib/oauth.mjs +30 -6
- package/lib/oauth.test.mjs +3 -3
- package/lib/rotation.mjs +19 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -44,11 +44,18 @@ The [original plugin](https://github.com/anomalyco/opencode-anthropic-auth) prov
|
|
|
44
44
|
- **Configurable strategies** — sticky, round-robin, or hybrid account selection
|
|
45
45
|
- **Claude Code signature emulation** — full HTTP header, system prompt, beta flag, and metadata mimicry derived from Claude Code's open source code
|
|
46
46
|
- **OAuth endpoint fingerprint parity** — sends Claude Code-style `User-Agent` on `/v1/oauth/token` and `/v1/oauth/revoke` to match current OAuth validation
|
|
47
|
-
- **
|
|
47
|
+
- **Adaptive thinking for Opus/Sonnet 4.6** — automatically normalizes thinking to `{type: "adaptive"}` for supported models, with `effort-2025-11-24` beta
|
|
48
|
+
- **Upstream-aligned auto betas** — 13+ always-on betas matching Claude Code 2.1.80 (`redact-thinking-2026-02-12` available as opt-in to preserve thinking block visibility)
|
|
48
49
|
- **1M context limit override** — patches `model.limit.context` so OpenCode compacts at the right threshold while `models.dev` catches up
|
|
49
50
|
- **Runtime config + custom betas** — `/anthropic set`, `/anthropic config`, and `/anthropic betas` slash commands for live feature toggling without restarting OpenCode
|
|
50
51
|
- **Files API integration** — upload, list, download, and manage files via `/anthropic files` with endpoint/content-scoped `files-api-2025-04-14` beta injection
|
|
51
52
|
- **Code execution support** — available via explicit custom beta opt-in (`code-execution-2025-08-25`), not auto-enabled
|
|
53
|
+
- **Deep QA conformance** — 491 tests across 11 test files, including 40 regression tests validating every header, body field, OAuth parameter, beta flag, system prompt block, response handling path, and telemetry schema against the [reverse-engineering doc](docs/claude-code-reverse-engineering.md)
|
|
54
|
+
- **Prompt caching with 1h TTL** — extended cache TTL on system prompt blocks, auto-disabled if API rejects; cache hit rate tracking with configurable warning threshold
|
|
55
|
+
- **Proactive rate limit detection** — reads `anthropic-ratelimit-unified-*-utilization` headers (tokens, requests, input-tokens) and applies health penalties before hitting 429
|
|
56
|
+
- **529/503 retry with Stainless backoff** — service-wide overload errors retried up to 2 times using the same exponential backoff formula as the official SDK
|
|
57
|
+
- **OAuth CSRF protection** — state parameter stored and validated on callback, independent from PKCE verifier
|
|
58
|
+
- **Telemetry emulation (opt-in)** — minimal `tengu_started`/`tengu_exit` events matching Claude Code's schema; disabled by default for privacy
|
|
52
59
|
|
|
53
60
|
## Installation
|
|
54
61
|
|
|
@@ -273,7 +280,6 @@ Add or remove beta flags that get included in every `anthropic-beta` header. Per
|
|
|
273
280
|
/anthropic betas add <beta-name> # add a custom beta
|
|
274
281
|
/anthropic betas remove <beta-name> # remove a custom beta
|
|
275
282
|
/anthropic betas add 1m # shortcut => context-1m-2025-08-07
|
|
276
|
-
/anthropic betas add fast # shortcut => fast-mode-2026-02-01
|
|
277
283
|
```
|
|
278
284
|
|
|
279
285
|
**Available preset betas** (shown by `/anthropic betas`):
|
|
@@ -288,7 +294,7 @@ Add or remove beta flags that get included in every `anthropic-beta` header. Per
|
|
|
288
294
|
| `mcp-servers-2025-12-04` | MCP servers in API request payload |
|
|
289
295
|
| `web-search-2025-03-05` | Web search (Vertex/Foundry only) |
|
|
290
296
|
| `context-1m-2025-08-07` | 1M context beta (provider/model dependent) |
|
|
291
|
-
| `
|
|
297
|
+
| `redact-thinking-2026-02-12` | Hide thinking blocks from responses (opt-in) |
|
|
292
298
|
|
|
293
299
|
Example workflow:
|
|
294
300
|
|
|
@@ -492,7 +498,7 @@ When you make a request through OpenCode:
|
|
|
492
498
|
2. It refreshes the OAuth token if expired
|
|
493
499
|
3. It transforms the request (adds OAuth headers, `oauth-2025-04-20`, signature headers, beta flags, tool prefixes)
|
|
494
500
|
4. If the response is account-specific (429/401, plus 400/403 billing/quota/permission errors), it marks that account and immediately tries the next account
|
|
495
|
-
5. If the response is service-wide (
|
|
501
|
+
5. If the response is service-wide (529/503), it retries up to 2 times with exponential backoff before returning the error
|
|
496
502
|
6. It tries each available account at most once per request
|
|
497
503
|
7. Successful responses have tool name prefixes stripped from the stream
|
|
498
504
|
|
|
@@ -597,7 +603,9 @@ export PATH="$HOME/.local/bin:$PATH"
|
|
|
597
603
|
|
|
598
604
|
## License
|
|
599
605
|
|
|
600
|
-
|
|
606
|
+
This project is licensed under the [GNU General Public License v3.0](LICENSE) (GPLv3).
|
|
607
|
+
|
|
608
|
+
Copyright © 2025-2026 Marco Jardim and contributors.
|
|
601
609
|
|
|
602
610
|
---
|
|
603
611
|
|