Documentation
¶
Overview ¶
Package quota reads the official usage windows from `aiquota status -o json` and keeps a bounded, append-only history of them.
aiquota already shares one reading across processes and serves stale data while it is rate-limited, and keeps only its last reading; this package adds the history. It samples at most every MinInterval and never talks to a provider itself.
Index ¶
Constants ¶
const ( LabelSession = "Session (5hr)" LabelWeek = "Weekly (7 day)" )
Labels aiquota gives the two windows that have a reset the charts align on.
const MinInterval = 5 * time.Minute
MinInterval is the shortest time between two readings.
const (
RotateBytes = 4 << 20 // the history file is rotated past this size
)
Bounds on what is read and kept.
Variables ¶
This section is empty.
Functions ¶
func AccountKey ¶ added in v0.8.0
AccountKey is the stable, short key of an account id: the first 8 hex digits of its SHA-256. The id itself, and the e-mail, are never kept.
func Exec ¶
Exec is the Runner that runs the aiquota binary on PATH, with fixed arguments and no shell.
func LabelKey ¶ added in v0.8.0
LabelKey is the key of an account known only by the label aiquota gave it.
func Tag ¶ added in v0.8.0
Tag sets the accounts' keys. active is the key of the account Claude Code is signed in to ("" when it could not be told, or changed during the reading): with a single account in the output it is that one; with several, each is known by its label alone, since nothing says which of them is the active one.
Types ¶
type Reading ¶
type Reading struct {
At int64 `json:"at"`
Acct string `json:"acct,omitempty"`
Label string `json:"lbl,omitempty"`
Plan string `json:"plan,omitempty"`
Windows []Window `json:"w"`
}
Reading is every window of one account at one instant (Unix seconds).
Acct is the account's stable key (see AccountKey, LabelKey); "" is a reading recorded before accounts were told apart, or taken when the account could not be told: its account is unknown and is never guessed.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the history: JSON lines in dir/quota.jsonl, rotated to quota.jsonl.1 past RotateBytes (the older half of the history is the rotated file).