opencode-anthropic-fix 0.0.39 → 0.0.41

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
@@ -51,9 +51,19 @@ The [original plugin](https://github.com/anomalyco/opencode-anthropic-auth) prov
51
51
  - **Runtime config + custom betas** — `/anthropic set`, `/anthropic config`, and `/anthropic betas` slash commands for live feature toggling without restarting OpenCode
52
52
  - **Files API integration** — upload, list, download, and manage files via `/anthropic files` with endpoint/content-scoped `files-api-2025-04-14` beta injection
53
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)
54
+ - **Deep QA conformance** — 680+ tests across 26 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
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
+ - **API preconnect** — fire-and-forget HEAD request on init to pre-warm TCP+TLS connection, skipped when proxy/mTLS detected
57
+ - **8K default output cap** — limits `max_tokens` to 8K by default, auto-escalates to 64K after output truncation, resets after one turn
58
+ - **Context overflow auto-recovery** — parses structured `prompt_too_long` errors to auto-reduce `max_tokens` before falling back to message trimming
59
+ - **Cache break detection** — hashes system prompt and tool schemas per turn, alerts when `cache_read_input_tokens` drops >2K
60
+ - **`/anthropic context` command** — token breakdown by role, tool_result grouping, duplicate content detection via SHA-256
61
+ - **Token budget parsing** — natural-language budget expressions (`+500k`, `use 2M tokens`) with system prompt injection and diminishing returns detection
62
+ - **Microcompact context trimming** — injects `clear_tool_uses` / `clear_thinking` betas at >80% context utilization
63
+ - **FG/BG request classification** — reduced retry budget for background requests (title generation, short queries)
64
+ - **Smart 529 overload recovery** — quota-aware account switching on overload exhaustion with cooldown and progressive error messaging
56
65
  - **Proactive rate limit detection** — reads `anthropic-ratelimit-unified-*-utilization` headers (tokens, requests, input-tokens) and applies health penalties before hitting 429
66
+ - **OAuth usage polling** — periodic polling of `/api/oauth/usage` endpoint with progressive warning toasts (caution/warning/danger)
57
67
  - **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
68
  - **OAuth CSRF protection** — state parameter stored and validated on callback, independent from PKCE verifier
59
69
  - **Telemetry emulation (opt-in)** — minimal `tengu_started`/`tengu_exit` events matching Claude Code's schema; disabled by default for privacy
@@ -467,6 +477,67 @@ Configuration is stored at `~/.config/opencode/anthropic-auth.json`. All setting
467
477
  // Minimum seconds between account-switch toasts (0-300)
468
478
  "debounce_seconds": 30,
469
479
  },
480
+
481
+ // API preconnect: fire-and-forget HEAD to pre-warm TCP+TLS on init.
482
+ // Skipped automatically when proxy/mTLS environment is detected.
483
+ "preconnect": {
484
+ "enabled": true,
485
+ "timeout_ms": 10000,
486
+ },
487
+
488
+ // Output cap: default max_tokens per request. Escalates to 64K
489
+ // after stop_reason: "max_tokens", then resets after one turn.
490
+ "output_cap": {
491
+ "enabled": true,
492
+ "default_max_tokens": 8000,
493
+ "escalated_max_tokens": 64000,
494
+ },
495
+
496
+ // Overflow recovery: auto-reduce max_tokens when the API returns
497
+ // a structured "prompt_too_long" error, before falling back to
498
+ // message trimming.
499
+ "overflow_recovery": {
500
+ "enabled": true,
501
+ "safety_margin": 1000,
502
+ },
503
+
504
+ // Cache break detection: toast alert when cache_read_input_tokens
505
+ // drops significantly between turns (system prompt or tool change).
506
+ "cache_break_detection": {
507
+ "enabled": true,
508
+ "alert_threshold": 2000,
509
+ },
510
+
511
+ // Request classification: reduced retry budget for background
512
+ // requests (title generation, short context queries).
513
+ "request_classification": {
514
+ "enabled": true,
515
+ "background_max_service_retries": 0,
516
+ "background_max_should_retries": 1,
517
+ },
518
+
519
+ // Token budget: parse natural-language budget expressions in user
520
+ // messages (e.g. "+500k", "use 2M tokens"). Disabled by default.
521
+ "token_budget": {
522
+ "enabled": false,
523
+ "default": 0,
524
+ "completion_threshold": 0.9,
525
+ },
526
+
527
+ // Microcompact: inject clear_tool_uses/clear_thinking betas
528
+ // when context utilization exceeds threshold_percent.
529
+ "microcompact": {
530
+ "enabled": true,
531
+ "threshold_percent": 80,
532
+ },
533
+
534
+ // Overload recovery: quota-aware account switching on 529
535
+ // exhaustion, with cooldown and error messaging.
536
+ "overload_recovery": {
537
+ "enabled": true,
538
+ "default_cooldown_ms": 60000,
539
+ "poll_quota_on_overload": true,
540
+ },
470
541
  }
471
542
  ```
472
543