@slkiser/opencode-quota 2.11.1 → 2.12.0
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 +18 -15
- package/dist/lib/anthropic.d.ts +44 -34
- package/dist/lib/anthropic.d.ts.map +1 -1
- package/dist/lib/anthropic.js +393 -117
- package/dist/lib/anthropic.js.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +9 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/entries.d.ts +1 -0
- package/dist/lib/entries.d.ts.map +1 -1
- package/dist/lib/quota-status.d.ts +1 -0
- package/dist/lib/quota-status.d.ts.map +1 -1
- package/dist/lib/quota-status.js +26 -0
- package/dist/lib/quota-status.js.map +1 -1
- package/dist/lib/types.d.ts +2 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +1 -0
- package/dist/lib/types.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +52 -23
- package/dist/plugin.js.map +1 -1
- package/dist/providers/anthropic.d.ts +2 -4
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +10 -6
- package/dist/providers/anthropic.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ That is enough for most installs. Providers are auto-detected from your existing
|
|
|
78
78
|
|
|
79
79
|
| Provider | Auto setup | How it works |
|
|
80
80
|
| --- | --- | --- |
|
|
81
|
-
| **Anthropic (Claude)** | Needs [quick setup](#anthropic-quick-setup) | Claude
|
|
81
|
+
| **Anthropic (Claude)** | Needs [quick setup](#anthropic-quick-setup) | Local Claude CLI auth/status probe. |
|
|
82
82
|
| **GitHub Copilot** | Usually | OpenCode auth; PAT only for managed billing. |
|
|
83
83
|
| **OpenAI** | Yes | OpenCode auth. |
|
|
84
84
|
| **Cursor** | Needs [quick setup](#cursor-quick-setup) | Companion auth plugin + `provider.cursor`. |
|
|
@@ -94,20 +94,18 @@ That is enough for most installs. Providers are auto-detected from your existing
|
|
|
94
94
|
<details>
|
|
95
95
|
<summary><strong>Quick setup: Anthropic (Claude)</strong></summary>
|
|
96
96
|
|
|
97
|
-
Anthropic quota support
|
|
97
|
+
Anthropic quota support now checks the local Claude CLI instead of passing Claude consumer OAuth tokens directly to Anthropic APIs.
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
1. `~/.claude/.credentials.json` → `claudeAiOauth.accessToken`
|
|
102
|
-
2. `CLAUDE_CODE_OAUTH_TOKEN` environment variable
|
|
99
|
+
If Claude Code is already installed and authenticated, this usually works automatically. Otherwise:
|
|
103
100
|
|
|
104
|
-
|
|
101
|
+
1. Install Claude Code so `claude` is available on your `PATH`.
|
|
102
|
+
2. Run `claude auth login`.
|
|
103
|
+
3. Confirm `claude auth status` succeeds locally.
|
|
104
|
+
4. Confirm OpenCode is configured with the `anthropic` provider.
|
|
105
105
|
|
|
106
|
-
If Claude
|
|
106
|
+
If Claude lives at a custom path, set `experimental.quotaToast.anthropicBinaryPath`. The default is `claude`.
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
2. If needed, set `CLAUDE_CODE_OAUTH_TOKEN` manually as a fallback.
|
|
110
|
-
3. Confirm OpenCode is configured with the `anthropic` provider.
|
|
108
|
+
If you use Anthropic via API key in OpenCode, model usage still works normally. This plugin only shows Anthropic quota rows when the local Claude CLI exposes quota windows.
|
|
111
109
|
|
|
112
110
|
For behavior details and troubleshooting, see [Anthropic notes](#anthropic-notes).
|
|
113
111
|
|
|
@@ -202,14 +200,18 @@ There is no `/token` command. The reporting commands are the `/tokens_*` family.
|
|
|
202
200
|
<details>
|
|
203
201
|
<summary><strong>Anthropic (Claude)</strong></summary>
|
|
204
202
|
|
|
205
|
-
|
|
203
|
+
The plugin probes the local Claude CLI with `anthropicBinaryPath --version` and `anthropicBinaryPath auth status`. By default `anthropicBinaryPath` is `claude`, so standard installs work without extra config. It does not pass Claude Free/Pro/Max OAuth tokens directly to Anthropic endpoints.
|
|
204
|
+
|
|
205
|
+
If the Claude CLI exposes 5-hour and 7-day quota windows in local structured output, the plugin shows them. If the CLI only exposes auth state, Anthropic quota rows are skipped and `/quota_status` explains why.
|
|
206
206
|
|
|
207
207
|
**Troubleshooting:**
|
|
208
208
|
|
|
209
209
|
| Problem | Solution |
|
|
210
210
|
| --- | --- |
|
|
211
|
-
|
|
|
212
|
-
|
|
|
211
|
+
| `claude` not found | Install Claude Code and make sure `claude` is on your `PATH` |
|
|
212
|
+
| Claude installed at a custom path | Set `experimental.quotaToast.anthropicBinaryPath` to the Claude executable path |
|
|
213
|
+
| Not authenticated | Run `claude auth login`, then confirm `claude auth status` works |
|
|
214
|
+
| Authenticated but no quota rows | Your local Claude CLI version did not expose quota windows; run `/quota_status` for the exact probe result |
|
|
213
215
|
| Plugin not detected | Confirm OpenCode is configured with the `anthropic` provider |
|
|
214
216
|
|
|
215
217
|
</details>
|
|
@@ -418,6 +420,7 @@ Workspace-local config can still customize display/report behavior, but user/glo
|
|
|
418
420
|
| `enableToast` | `true` | Show popup toasts |
|
|
419
421
|
| `toastStyle` | `classic` | Toast layout: `classic` or `grouped` |
|
|
420
422
|
| `enabledProviders` | `"auto"` | Auto-detect providers, or set an explicit provider list |
|
|
423
|
+
| `anthropicBinaryPath` | `"claude"` | Command/path used for local Claude CLI probing; override this for custom installs or shim locations |
|
|
421
424
|
| `minIntervalMs` | `300000` | Minimum fetch interval between provider updates |
|
|
422
425
|
| `toastDurationMs` | `9000` | Toast duration in milliseconds |
|
|
423
426
|
| `showOnIdle` | `true` | Show toast on idle trigger |
|
|
@@ -479,7 +482,7 @@ MIT
|
|
|
479
482
|
|
|
480
483
|
OpenCode Quota is not built by the OpenCode team and is not affiliated with OpenCode or any provider listed above.
|
|
481
484
|
|
|
482
|
-
|
|
485
|
+
Anthropic quota detection is delegated to the local Claude CLI/runtime. OpenCode Anthropic API-key usage is unaffected, but this plugin only surfaces Anthropic quota rows when the local Claude CLI exposes them.
|
|
483
486
|
|
|
484
487
|
## Star History
|
|
485
488
|
|
package/dist/lib/anthropic.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Anthropic Claude quota
|
|
2
|
+
* Anthropic Claude quota probing.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Supported credential sources:
|
|
9
|
-
* 1. ~/.claude/.credentials.json → claudeAiOauth.accessToken
|
|
10
|
-
* 2. CLAUDE_CODE_OAUTH_TOKEN environment variable
|
|
4
|
+
* Uses the local Claude CLI/runtime to detect install/auth state and surface
|
|
5
|
+
* quota windows only when the official runtime exposes them locally. This
|
|
6
|
+
* module does not read Claude consumer OAuth tokens or call Anthropic's OAuth
|
|
7
|
+
* usage endpoint directly.
|
|
11
8
|
*/
|
|
12
|
-
declare const CREDENTIALS_PATH: string;
|
|
13
9
|
export interface AnthropicQuotaWindow {
|
|
14
|
-
|
|
15
|
-
used_percentage
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
utilization?: number;
|
|
11
|
+
used_percentage?: number;
|
|
12
|
+
usedPercentage?: number;
|
|
13
|
+
used_percent?: number;
|
|
14
|
+
usedPercent?: number;
|
|
15
|
+
percent_used?: number;
|
|
16
|
+
percentUsed?: number;
|
|
17
|
+
resets_at?: string;
|
|
18
|
+
resetsAt?: string;
|
|
19
|
+
reset_at?: string;
|
|
20
|
+
resetAt?: string;
|
|
18
21
|
}
|
|
19
22
|
export interface AnthropicUsageResponse {
|
|
20
23
|
five_hour: AnthropicQuotaWindow;
|
|
@@ -36,28 +39,35 @@ export interface AnthropicQuotaError {
|
|
|
36
39
|
error: string;
|
|
37
40
|
}
|
|
38
41
|
export type AnthropicResult = AnthropicQuotaResult | AnthropicQuotaError | null;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
export type AnthropicAuthStatus = "authenticated" | "unauthenticated" | "unknown";
|
|
43
|
+
export type AnthropicQuotaSource = "claude-auth-status-json" | "none";
|
|
44
|
+
export interface AnthropicDiagnostics {
|
|
45
|
+
installed: boolean;
|
|
46
|
+
version: string | null;
|
|
47
|
+
authStatus: AnthropicAuthStatus;
|
|
48
|
+
quotaSupported: boolean;
|
|
49
|
+
quotaSource: AnthropicQuotaSource;
|
|
50
|
+
checkedCommands: string[];
|
|
51
|
+
message?: string;
|
|
52
|
+
quota?: AnthropicQuotaResult;
|
|
44
53
|
}
|
|
45
|
-
export interface
|
|
46
|
-
|
|
47
|
-
expiresAt?: number;
|
|
48
|
-
source: "file" | "env";
|
|
54
|
+
export interface AnthropicProbeOptions {
|
|
55
|
+
binaryPath?: string;
|
|
49
56
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
export type ClaudeCommandInvocation = {
|
|
58
|
+
file: string;
|
|
59
|
+
args: string[];
|
|
60
|
+
display: string;
|
|
61
|
+
};
|
|
62
|
+
export declare function resolveAnthropicBinaryPath(binaryPath?: string): string;
|
|
63
|
+
export declare function buildClaudeCommandInvocation(binaryPath: string, args: string[], runtime?: {
|
|
64
|
+
platform?: NodeJS.Platform;
|
|
65
|
+
comspec?: string;
|
|
66
|
+
}): ClaudeCommandInvocation;
|
|
54
67
|
declare function parseUsageResponse(data: unknown): AnthropicQuotaResult | null;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*/
|
|
61
|
-
export declare function queryAnthropicQuota(): Promise<AnthropicResult>;
|
|
62
|
-
export { CREDENTIALS_PATH, parseUsageResponse, readCredentialsFile };
|
|
68
|
+
export declare function clearAnthropicDiagnosticsCacheForTests(): void;
|
|
69
|
+
export declare function getAnthropicDiagnostics(options?: AnthropicProbeOptions): Promise<AnthropicDiagnostics>;
|
|
70
|
+
export declare function hasAnthropicCredentialsConfigured(options?: AnthropicProbeOptions): Promise<boolean>;
|
|
71
|
+
export declare function queryAnthropicQuota(options?: AnthropicProbeOptions): Promise<AnthropicResult>;
|
|
72
|
+
export { parseUsageResponse };
|
|
63
73
|
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/lib/anthropic.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/lib/anthropic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,oBAAoB,CAAC;IAChC,SAAS,EAAE,oBAAoB,CAAC;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,SAAS,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChE;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,M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