@vacbo/opencode-anthropic-fix 0.1.8 → 0.1.9
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 +88 -88
- package/dist/opencode-anthropic-auth-cli.mjs +804 -507
- package/dist/opencode-anthropic-auth-plugin.js +4751 -4109
- package/package.json +67 -67
- package/src/__tests__/billing-edge-cases.test.ts +59 -59
- package/src/__tests__/bun-proxy.parallel.test.ts +388 -382
- package/src/__tests__/cc-comparison.test.ts +87 -87
- package/src/__tests__/cc-credentials.test.ts +254 -250
- package/src/__tests__/cch-drift-checker.test.ts +51 -51
- package/src/__tests__/cch-native-style.test.ts +56 -56
- package/src/__tests__/debug-gating.test.ts +42 -42
- package/src/__tests__/decomposition-smoke.test.ts +68 -68
- package/src/__tests__/fingerprint-regression.test.ts +575 -566
- package/src/__tests__/helpers/conversation-history.smoke.test.ts +271 -271
- package/src/__tests__/helpers/conversation-history.ts +119 -119
- package/src/__tests__/helpers/deferred.smoke.test.ts +103 -103
- package/src/__tests__/helpers/deferred.ts +69 -69
- package/src/__tests__/helpers/in-memory-storage.smoke.test.ts +155 -155
- package/src/__tests__/helpers/in-memory-storage.ts +88 -88
- package/src/__tests__/helpers/mock-bun-proxy.smoke.test.ts +68 -68
- package/src/__tests__/helpers/mock-bun-proxy.ts +189 -189
- package/src/__tests__/helpers/plugin-fetch-harness.smoke.test.ts +273 -273
- package/src/__tests__/helpers/plugin-fetch-harness.ts +288 -288
- package/src/__tests__/helpers/sse.smoke.test.ts +236 -236
- package/src/__tests__/helpers/sse.ts +209 -209
- package/src/__tests__/index.parallel.test.ts +605 -595
- package/src/__tests__/sanitization-regex.test.ts +112 -112
- package/src/__tests__/state-bounds.test.ts +90 -90
- package/src/account-identity.test.ts +197 -192
- package/src/account-identity.ts +69 -67
- package/src/account-state.test.ts +86 -86
- package/src/account-state.ts +25 -25
- package/src/accounts/matching.test.ts +335 -0
- package/src/accounts/matching.ts +167 -0
- package/src/accounts/persistence.test.ts +345 -0
- package/src/accounts/persistence.ts +432 -0
- package/src/accounts/repair.test.ts +276 -0
- package/src/accounts/repair.ts +407 -0
- package/src/accounts.dedup.test.ts +621 -621
- package/src/accounts.test.ts +933 -929
- package/src/accounts.ts +633 -989
- package/src/backoff.test.ts +345 -345
- package/src/backoff.ts +219 -219
- package/src/betas.ts +124 -124
- package/src/bun-fetch.test.ts +345 -342
- package/src/bun-fetch.ts +424 -424
- package/src/bun-proxy.test.ts +25 -25
- package/src/bun-proxy.ts +209 -209
- package/src/cc-credentials.ts +111 -111
- package/src/circuit-breaker.test.ts +184 -184
- package/src/circuit-breaker.ts +169 -169
- package/src/cli/commands/auth.ts +963 -0
- package/src/cli/commands/config.ts +547 -0
- package/src/cli/formatting.test.ts +406 -0
- package/src/cli/formatting.ts +219 -0
- package/src/cli.ts +255 -2022
- package/src/commands/handlers/betas.ts +100 -0
- package/src/commands/handlers/config.ts +99 -0
- package/src/commands/handlers/files.ts +375 -0
- package/src/commands/oauth-flow.ts +181 -166
- package/src/commands/prompts.ts +61 -61
- package/src/commands/router.test.ts +421 -0
- package/src/commands/router.ts +143 -635
- package/src/config.test.ts +482 -482
- package/src/config.ts +412 -404
- package/src/constants.ts +48 -48
- package/src/drift/cch-constants.ts +95 -95
- package/src/env.ts +111 -105
- package/src/headers/billing.ts +33 -33
- package/src/headers/builder.ts +130 -130
- package/src/headers/cch.ts +75 -75
- package/src/headers/stainless.ts +25 -25
- package/src/headers/user-agent.ts +23 -23
- package/src/index.ts +436 -828
- package/src/models.ts +27 -27
- package/src/oauth.test.ts +102 -102
- package/src/oauth.ts +178 -178
- package/src/parent-pid-watcher.test.ts +148 -148
- package/src/parent-pid-watcher.ts +69 -69
- package/src/plugin-helpers.ts +82 -82
- package/src/refresh-helpers.ts +145 -139
- package/src/refresh-lock.test.ts +94 -94
- package/src/refresh-lock.ts +93 -93
- package/src/request/body.history.test.ts +579 -571
- package/src/request/body.ts +255 -255
- package/src/request/metadata.ts +65 -65
- package/src/request/retry.test.ts +156 -156
- package/src/request/retry.ts +67 -67
- package/src/request/url.ts +21 -21
- package/src/request-orchestration-helpers.ts +648 -0
- package/src/response/index.ts +5 -5
- package/src/response/mcp.ts +58 -58
- package/src/response/streaming.test.ts +313 -311
- package/src/response/streaming.ts +412 -410
- package/src/rotation.test.ts +304 -301
- package/src/rotation.ts +205 -205
- package/src/storage.test.ts +547 -547
- package/src/storage.ts +315 -291
- package/src/system-prompt/builder.ts +38 -38
- package/src/system-prompt/index.ts +5 -5
- package/src/system-prompt/normalize.ts +60 -60
- package/src/system-prompt/sanitize.ts +30 -30
- package/src/thinking.ts +21 -20
- package/src/token-refresh.test.ts +265 -265
- package/src/token-refresh.ts +219 -214
- package/src/types.ts +30 -30
package/README.md
CHANGED
|
@@ -82,11 +82,11 @@ Control the feature via `~/.config/opencode/anthropic-auth.json`:
|
|
|
82
82
|
|
|
83
83
|
```jsonc
|
|
84
84
|
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
"cc_credential_reuse": {
|
|
86
|
+
"enabled": true, // Enable/disable the feature (default: true)
|
|
87
|
+
"auto_detect": true, // Auto-load on plugin startup (default: true)
|
|
88
|
+
"prefer_over_oauth": true, // Use CC credentials first when available (default: true)
|
|
89
|
+
},
|
|
90
90
|
}
|
|
91
91
|
```
|
|
92
92
|
|
|
@@ -132,7 +132,7 @@ Add to your `opencode.json`:
|
|
|
132
132
|
|
|
133
133
|
```json
|
|
134
134
|
{
|
|
135
|
-
|
|
135
|
+
"plugins": ["opencode-anthropic-fix@latest"]
|
|
136
136
|
}
|
|
137
137
|
```
|
|
138
138
|
|
|
@@ -390,10 +390,10 @@ Supported formats: PDF, DOCX, TXT, CSV, Excel, Markdown, images (max 350 MB per
|
|
|
390
390
|
|
|
391
391
|
- `/anthropic files list` (no `--account`) queries **all** enabled accounts, labeling each file with its owner email
|
|
392
392
|
- Use `--account <email|index>` to target a specific account for any action:
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
```text
|
|
394
|
+
/anthropic files list --account alice@example.com
|
|
395
|
+
/anthropic files upload ./data.csv --account 2
|
|
396
|
+
```
|
|
397
397
|
- **Auto-pinning:** When you upload or list files, the plugin remembers which account owns each `file_id`. If a subsequent Messages API request references that `file_id`, the plugin automatically routes it to the correct account — even with round-robin or hybrid strategies.
|
|
398
398
|
|
|
399
399
|
### OAuth flows from slash command
|
|
@@ -469,84 +469,84 @@ Configuration is stored at `~/.config/opencode/anthropic-auth.json`. All setting
|
|
|
469
469
|
|
|
470
470
|
```jsonc
|
|
471
471
|
{
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
472
|
+
// Account selection strategy: "sticky" | "round-robin" | "hybrid"
|
|
473
|
+
"account_selection_strategy": "sticky",
|
|
474
|
+
|
|
475
|
+
// Seconds before consecutive failure count resets (60-7200)
|
|
476
|
+
"failure_ttl_seconds": 3600,
|
|
477
|
+
|
|
478
|
+
// Enable debug logging
|
|
479
|
+
"debug": false,
|
|
480
|
+
|
|
481
|
+
// Claude Code signature emulation behavior
|
|
482
|
+
"signature_emulation": {
|
|
483
|
+
// Enable Claude-style attribution/stainless headers and betas
|
|
484
|
+
"enabled": true,
|
|
485
|
+
// Resolve latest @anthropic-ai/claude-code version once on plugin startup
|
|
486
|
+
"fetch_claude_code_version_on_startup": true,
|
|
487
|
+
// Compact long injected system instructions to reduce token usage.
|
|
488
|
+
// In "minimal" mode, repeated/contained blocks are deduplicated and title-generator
|
|
489
|
+
// requests are replaced with a compact dedicated prompt.
|
|
490
|
+
// "minimal" | "off"
|
|
491
|
+
"prompt_compaction": "minimal",
|
|
492
|
+
// Run the legacy regex-based sanitizer that rewrites OpenCode / Sisyphus /
|
|
493
|
+
// morph_edit identifiers in system prompt text. Default false because the
|
|
494
|
+
// plugin's primary defense is now aggressive relocation: non-CC blocks are
|
|
495
|
+
// moved into the first user message wrapped in <system-instructions>, and
|
|
496
|
+
// CC's system prompt is kept byte-for-byte pristine. Set this to true if
|
|
497
|
+
// you want belt-and-suspenders rewriting on top of relocation. The new
|
|
498
|
+
// regex uses negative lookarounds for [\w\-/] so hyphenated identifiers
|
|
499
|
+
// and file paths survive verbatim.
|
|
500
|
+
"sanitize_system_prompt": false,
|
|
501
|
+
},
|
|
502
|
+
|
|
503
|
+
// Top-level alias for signature_emulation.sanitize_system_prompt. When set,
|
|
504
|
+
// takes precedence over the nested value. Provided so you can flip the
|
|
505
|
+
// sanitizer without learning the nested schema.
|
|
500
506
|
"sanitize_system_prompt": false,
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
//
|
|
517
|
-
"
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
"
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
"
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
"toasts": {
|
|
545
|
-
// Suppress non-error toasts (account status, switching)
|
|
546
|
-
"quiet": false,
|
|
547
|
-
// Minimum seconds between account-switch toasts (0-300)
|
|
548
|
-
"debounce_seconds": 30,
|
|
549
|
-
},
|
|
507
|
+
|
|
508
|
+
// Context limit override for 1M-window models.
|
|
509
|
+
// Prevents OpenCode from compacting too early when models.dev hasn't been
|
|
510
|
+
// updated yet (e.g. claude-opus-4-6 and any *-1m model variants).
|
|
511
|
+
// Only applied for OAuth (Max Plan) sessions — API key users use the
|
|
512
|
+
// context-1m-2025-08-07 beta header instead.
|
|
513
|
+
"override_model_limits": {
|
|
514
|
+
// Enable/disable the override (default: off — enable if you need 1M context)
|
|
515
|
+
"enabled": false,
|
|
516
|
+
// Context window to inject (tokens). Default: 1_000_000.
|
|
517
|
+
"context": 1000000,
|
|
518
|
+
// Max output tokens to inject. 0 = leave the model's default unchanged.
|
|
519
|
+
"output": 0,
|
|
520
|
+
},
|
|
521
|
+
|
|
522
|
+
// Health score tuning (0-100 scale)
|
|
523
|
+
"health_score": {
|
|
524
|
+
"initial": 70,
|
|
525
|
+
"success_reward": 1,
|
|
526
|
+
"rate_limit_penalty": -10,
|
|
527
|
+
"failure_penalty": -20,
|
|
528
|
+
"recovery_rate_per_hour": 2,
|
|
529
|
+
"min_usable": 50,
|
|
530
|
+
"max_score": 100,
|
|
531
|
+
},
|
|
532
|
+
|
|
533
|
+
// Client-side rate limiting (token bucket)
|
|
534
|
+
"token_bucket": {
|
|
535
|
+
"max_tokens": 50,
|
|
536
|
+
"regeneration_rate_per_minute": 6,
|
|
537
|
+
"initial_tokens": 50,
|
|
538
|
+
},
|
|
539
|
+
|
|
540
|
+
// Custom beta headers (added to every request via /anthropic betas add)
|
|
541
|
+
"custom_betas": [],
|
|
542
|
+
|
|
543
|
+
// Toast notification settings
|
|
544
|
+
"toasts": {
|
|
545
|
+
// Suppress non-error toasts (account status, switching)
|
|
546
|
+
"quiet": false,
|
|
547
|
+
// Minimum seconds between account-switch toasts (0-300)
|
|
548
|
+
"debounce_seconds": 30,
|
|
549
|
+
},
|
|
550
550
|
}
|
|
551
551
|
```
|
|
552
552
|
|
|
@@ -675,7 +675,7 @@ To suppress non-error toasts, set `quiet` mode in your config:
|
|
|
675
675
|
```jsonc
|
|
676
676
|
// ~/.config/opencode/anthropic-auth.json
|
|
677
677
|
{
|
|
678
|
-
|
|
678
|
+
"toasts": { "quiet": true },
|
|
679
679
|
}
|
|
680
680
|
```
|
|
681
681
|
|