plugin-claude

command module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: BSD-3-Clause Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-aiquota/plugin-claude

plugin-claude

CI Go Reference

go-aiquota's QuotaProvider plugin for Claude (Max / Team Premium / Team Standard): a hashicorp/go-plugin subprocess, launched and dialed by go-aiquota/tray's quota.Manager, that turns an account's claude.ai session cookies into a QuotaSnapshot.

Credential source "Claude Code" (preferred)

With Credential = {"source": "claude-code"} the plugin reads Claude Code's own login at fetch time and shows the same account, plan, windows and percentages as the VS Code extension's Account & usage panel. It never refreshes or rotates that token (Claude Code renews its own login; a second holder rotating the refresh token would sign it out): an expired token is reported as token expired, open Claude Code.

  • Storage (extension.js yc/bc, authentication docs "Credential management"): macOS Keychain item Claude Code-credentials, account $USER (+ -<sha256(CLAUDE_CONFIG_DIR)[:8]> when that variable is set), read with /usr/bin/security find-generic-password -w, which the item's ACL trusts, so there is no prompt and nothing to re-approve after a reinstall; otherwise ~/.claude/.credentials.json. The secret travels on a pipe — never argv, environment or disk — and is held in a secret.Secret.
  • Request: GET https://api.anthropic.com/api/oauth/usage, Authorization: Bearer …, anthropic-beta: oauth-2025-04-20, User-Agent: claude-code/2.1.319; TLS 1.2+, that host only, no redirects, 1 MiB response cap. Errors are redacted of the token.
  • Every window the endpoint returns, by default. The body is decoded as a map: each top-level value shaped {utilization, resets_at} is a window (known keys keep the panel's labels and order, seven_day_opus included; an unknown key gets a label derived from it, seven_day_oauth_apps becomes Weekly (7 day) oauth apps), then each limits[] entry the top level did not already report (label from its kind, group and scope: a model, or another scope). The pair of places is de-duplicated by an explicit key (session, weekly_all, weekly_scoped/<model>, the limit's own kind, top/<field>), not by label. A window with utilization: null is kept as Unit: "n/a" with a snapshot warning saying why; bare null fields of no known shape are not windows. A limit's severity other than normal/ok is a snapshot warning. At most 64 windows; the body is capped at 1 MiB. Credential = {"source": "claude-code", "view": "overlay"} returns exactly the panel's rows (below), for the equality check against the extension. plugin-claude --raw-usage prints the response body, indented (it holds no credential), and exits: aiquota status -o json --raw runs it.
  • The overlay view's rows and labels as the panel (webview WDn): Session (5hr), Weekly (7 day), Weekly Sonnet (max/team/unknown plans), then Weekly <model> per model-scoped limit; a null window is not shown. Known approximation: the panel filters model-scoped rows through a remote allowlist (tengu_usage_overage_included_models) that this plugin cannot read, so it shows every model-scoped limit other than Sonnet/Opus.
  • Fuzz targets: FuzzDecodeUsage, FuzzDecodeCredential.

GET https://claude.ai/api/organizations/{org_uuid}/usage, authenticated purely by the account's claude.ai session cookies (no separate API key or bearer token). This is the same endpoint claude.ai's own web app calls to show the usage bar under Settings → Usage — found by watching a real, authenticated browsing session's own network traffic (see go-aiquota/tray/capture), not documented anywhere public.

The response's limits[] array — one entry per rate-limit window (session, weekly_all, weekly_scoped, ...), each with a percent and a resets_at — maps directly onto quotapb.QuotaWindow.

Credential shape

FetchQuotaRequest.Credential needs:

  • Every cookie name → value pair for the claude.ai domain (go-aiquota/tray's onboarding hands back the whole jar it captured; this plugin doesn't need to know which one cookie actually matters).
  • org_uuid: the account's organization UUID. There is no page a scripted client can hit to rediscover this from cookies alone the way the real web app does on load — that path itself needs a real browser — so it must be captured once, at onboarding time, from the login response itself (memberships[].organization.uuid), and stored alongside the cookies.

A credential missing org_uuid fails clearly rather than guessing.

Why claude.ai needs a real browser to onboard

claude.ai's own login page is behind Cloudflare's interactive JS challenge (cf-mitigated: challenge, the "Just a moment..." interstitial), which a scripted HTTP client — however TLS-fingerprint-conformant — cannot pass. go-aiquota/tray's onboarding therefore drives a real browser engine (WKWebView on macOS; go-webengine elsewhere, which works for providers without this kind of protection) for the interactive login itself. Once login completes, only the resulting cookies (and the org UUID) ever reach this plugin — the plugin itself talks a plain, TLS-fingerprinted (go-browserhttp/browserhttp) HTTP client to one authenticated JSON endpoint, nothing more.

Building and running standalone

go build -o go-aiquota-plugin-claude .

go-aiquota/tray's quota.Manager looks for exactly that binary name on PATH.

Documentation

Overview

Command plugin-claude is go-aiquota's QuotaProvider plugin for Claude (Max / Team Premium / Team Standard): a hashicorp/go-plugin subprocess, launched and dialed by go-aiquota/tray's quota.Manager, that turns an account's claude.ai session cookies into a QuotaSnapshot.

The endpoint it calls (GET /api/organizations/{org_uuid}/usage) was found by watching claude.ai's own web app in a real WKWebView session — its own login page is behind Cloudflare's interactive JS challenge, which a scripted client cannot pass, so the account is onboarded through a real browser engine and only the resulting cookies (plus the org UUID the login response reveals) ever reach this plugin. See provider.go's own doc comment for the credential shape this expects.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址