opencode-anthropic-fix 0.0.25 → 0.0.27

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
@@ -43,13 +43,20 @@ The [original plugin](https://github.com/anomalyco/opencode-anthropic-auth) prov
43
43
  - **Standalone CLI** — manage accounts without opening OpenCode
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
- - **OAuth endpoint fingerprint parity** — sends Claude Code-style `User-Agent` on `/v1/oauth/token` and `/v1/oauth/revoke` to match current OAuth validation
47
- - **Effort-based thinking for Opus 4.6** — maps `budgetTokens` to effort levels (`low`/`medium`/`high`) and includes `effort-2025-11-24`
48
- - **Upstream-aligned auto betas** — `advanced-tool-use-2025-11-20` and `fast-mode-2026-02-01` auto-included to match Claude Code 2.1.79+ (`redact-thinking-2026-02-12` available as opt-in to preserve thinking block visibility)
46
+ - **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
47
+ - **Dynamic billing cache hash** — computes the `cch` field in the billing header using the real CLI's `NP1()` algorithm (SHA-256 of salt + first user message chars + version), replacing the static `00000` placeholder
48
+ - **Adaptive thinking for Opus/Sonnet 4.6** — automatically normalizes thinking to `{type: "adaptive"}` for supported models, with `effort-2025-11-24` beta
49
+ - **Upstream-aligned auto betas** — 13+ always-on betas matching Claude Code 2.1.81 (`redact-thinking-2026-02-12` available as opt-in to preserve thinking block visibility)
49
50
  - **1M context limit override** — patches `model.limit.context` so OpenCode compacts at the right threshold while `models.dev` catches up
50
51
  - **Runtime config + custom betas** — `/anthropic set`, `/anthropic config`, and `/anthropic betas` slash commands for live feature toggling without restarting OpenCode
51
52
  - **Files API integration** — upload, list, download, and manage files via `/anthropic files` with endpoint/content-scoped `files-api-2025-04-14` beta injection
52
53
  - **Code execution support** — available via explicit custom beta opt-in (`code-execution-2025-08-25`), not auto-enabled
54
+ - **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)
55
+ - **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
56
+ - **Proactive rate limit detection** — reads `anthropic-ratelimit-unified-*-utilization` headers (tokens, requests, input-tokens) and applies health penalties before hitting 429
57
+ - **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
58
+ - **OAuth CSRF protection** — state parameter stored and validated on callback, independent from PKCE verifier
59
+ - **Telemetry emulation (opt-in)** — minimal `tengu_started`/`tengu_exit` events matching Claude Code's schema; disabled by default for privacy
53
60
 
54
61
  ## Installation
55
62
 
@@ -492,7 +499,7 @@ When you make a request through OpenCode:
492
499
  2. It refreshes the OAuth token if expired
493
500
  3. It transforms the request (adds OAuth headers, `oauth-2025-04-20`, signature headers, beta flags, tool prefixes)
494
501
  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 (500/503/529), it returns the error directly (switching accounts would not help)
502
+ 5. If the response is service-wide (529/503), it retries up to 2 times with exponential backoff before returning the error
496
503
  6. It tries each available account at most once per request
497
504
  7. Successful responses have tool name prefixes stripped from the stream
498
505
 
@@ -523,6 +530,33 @@ Account credentials are stored with restrictive file permissions (owner read/wri
523
530
 
524
531
  Make sure the plugin is installed in `~/.config/opencode/plugin/`. Restart OpenCode after installing.
525
532
 
533
+ ### "TypeError: undefined is not an object (evaluating 'hook.config')"
534
+
535
+ This usually means OpenCode loaded a broken/missing plugin entry (often a stale file in `~/.config/opencode/plugin/`, or a plugin listed in `opencode.json` that is not actually installed).
536
+
537
+ For OpenCode v1.x, the safest local-dev setup is to link the package directory into OpenCode's `node_modules` and load it by package name:
538
+
539
+ ```powershell
540
+ $link = "$env:USERPROFILE\.config\opencode\node_modules\opencode-anthropic-fix"
541
+ $target = "D:\git\opencode-anthropic-fix"
542
+
543
+ New-Item -ItemType Directory -Force -Path (Split-Path $link) | Out-Null
544
+ if (Test-Path $link) { Remove-Item $link -Recurse -Force }
545
+ New-Item -ItemType Junction -Path $link -Target $target
546
+ ```
547
+
548
+ Then ensure `~/.config/opencode/opencode.json` contains:
549
+
550
+ ```json
551
+ {
552
+ "plugin": ["opencode-anthropic-fix"]
553
+ }
554
+ ```
555
+
556
+ If you still see the error, temporarily keep only `"opencode-anthropic-fix"` in the plugin array and add other plugins back one-by-one to find the broken one.
557
+
558
+ Important: remove stale standalone files like `~/.config/opencode/plugin/opencode-anthropic-auth-plugin.js` if present. They can shadow package loading and trigger `hook.config` crashes.
559
+
526
560
  ### "Auth flow completes but requests fail"
527
561
 
528
562
  Your OAuth token may have expired. Try a quick refresh first, or re-authenticate with fresh browser login:
@@ -597,7 +631,9 @@ export PATH="$HOME/.local/bin:$PATH"
597
631
 
598
632
  ## License
599
633
 
600
- Same as upstream. See [anomalyco/opencode-anthropic-auth](https://github.com/anomalyco/opencode-anthropic-auth).
634
+ This project is licensed under the [GNU General Public License v3.0](LICENSE) (GPLv3).
635
+
636
+ Copyright © 2025-2026 Marco Jardim and contributors.
601
637
 
602
638
  ---
603
639