Documentation
¶
Index ¶
- func Main()
- type Account
- type AccountConfig
- type AccountDetail
- type AccountInfo
- type AccountSetup
- type AllTime
- type Block
- type BlockRow
- type Config
- type DayPoint
- type Entry
- type HourCell
- type LimitWindow
- type ListedPrice
- type ModelLimit
- type ModelRow
- type Period
- type PlanLimits
- type Price
- type PriceView
- type Pricer
- type PricesReport
- type ProjectRow
- type RangeDetail
- type Report
- type SessionRow
- type Summary
- type Totals
- type UsedPrice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
type Account struct {
Cfg AccountConfig
// contains filtered or unexported fields
}
Account holds the parsed usage of one config dir and scans it incrementally: each .jsonl file is read from where the last scan stopped.
type AccountConfig ¶
type AccountConfig struct {
Name string `json:"name"`
Dir string `json:"dir"`
// Optional limits, in equivalent API cost (USD). When zero, the meter
// falls back to your own 30-day peak for the 5-hour window.
BlockLimitUSD float64 `json:"block_limit_usd,omitempty"`
WeeklyLimitUSD float64 `json:"weekly_limit_usd,omitempty"`
// Archived keeps the account and its history but leaves it out of the
// table, the dashboard and background plan-limit checks.
Archived bool `json:"archived,omitempty"`
}
AccountConfig describes one Claude Code account, identified by its config dir.
type AccountDetail ¶
type AccountDetail struct {
Summary
AllTime *AllTime `json:"all_time,omitempty"`
Setup AccountSetup `json:"setup"`
Range RangeDetail `json:"range"`
}
AccountDetail is everything the dashboard's account page shows: the same Summary as the overview, plus a breakdown of a chosen range of days.
type AccountInfo ¶
type AccountInfo struct {
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
Organization string `json:"organization,omitempty"`
Plan string `json:"plan,omitempty"` // "Max 5x", "Pro"
Role string `json:"role,omitempty"`
ExtraUsage bool `json:"extra_usage"`
AccountCreated *time.Time `json:"account_created,omitempty"`
SubscriptionSince *time.Time `json:"subscription_since,omitempty"`
ProfileUpdated *time.Time `json:"profile_updated,omitempty"`
}
AccountInfo is who an account is logged in as. It comes from the profile Claude Code saves in .claude.json, which holds no login tokens. Only the fields named here are ever read, so nothing else in that file can reach the dashboard.
type AccountSetup ¶
type AccountSetup struct {
Hooks bool `json:"hooks"`
Plugin bool `json:"plugin"`
StatusLine bool `json:"status_line"`
SettingsError string `json:"settings_error,omitempty"`
LastAttempt time.Time `json:"last_attempt,omitzero"`
LastOK time.Time `json:"last_ok,omitzero"`
NextAllowed time.Time `json:"next_allowed,omitzero"`
LastError string `json:"last_error,omitempty"`
}
AccountSetup says how plan limits reach this account. It only reports yes or no from settings.json, never the settings themselves.
type AllTime ¶
type AllTime struct {
Totals
Since string `json:"since"` // local date of the earliest response, 2006-01-02
}
AllTime is an account's usage over everything ccmeter has seen.
type Block ¶
type Block struct {
Active bool `json:"active"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
RemainingMin int `json:"remaining_min"`
Totals
BurnUSDPerHour float64 `json:"burn_usd_per_hour"`
ProjectedUSD float64 `json:"projected_usd"`
LimitUSD float64 `json:"limit_usd"`
LimitSource string `json:"limit_source"` // "config", "peak" or ""
Pct float64 `json:"pct"`
}
type Config ¶
type Config struct {
Accounts []AccountConfig `json:"accounts"`
// Pricing overrides, keyed by a substring of the model name, USD per million tokens.
Pricing map[string]Price `json:"pricing,omitempty"`
}
Config is the whole ccmeter config file.
type Entry ¶
type Entry struct {
T time.Time
Model string
In int64 // input tokens
Out int64 // output tokens
CW5 int64 // cache write, 5-minute TTL
CW1h int64 // cache write, 1-hour TTL
CR int64 // cache read
Project string // the log folder under projects/, one per folder a session started in
Session string // session id, or the log file's name in older logs
}
Entry is one billed assistant response.
type LimitWindow ¶
type LimitWindow struct {
UsedPct float64 `json:"used_pct"`
ResetsAt time.Time `json:"resets_at"`
// Reset is set when resets_at has passed since the last report, so the
// saved percentage no longer applies.
Reset bool `json:"reset,omitempty"`
}
LimitWindow is one plan window as last reported by Claude Code.
type ListedPrice ¶
ListedPrice is one row of a price list.
type ModelLimit ¶
type ModelLimit struct {
Name string `json:"name"`
LimitWindow
}
ModelLimit is a weekly limit of its own for one model, such as Fable on a Max plan. Only `claude /usage` reports these, and only on plans that have one.
type PlanLimits ¶
type PlanLimits struct {
Source string `json:"source"` // "statusline" or "usage-endpoint"
UpdatedAt time.Time `json:"updated_at"`
AgeMin int `json:"age_min"`
FiveHour *LimitWindow `json:"five_hour,omitempty"`
SevenDay *LimitWindow `json:"seven_day,omitempty"`
Models []ModelLimit `json:"models,omitempty"`
}
PlanLimits is what the dashboard and table read.
type Price ¶
type Price struct {
Input float64 `json:"input"`
Output float64 `json:"output"`
CacheWrite float64 `json:"cache_write,omitempty"` // 5-minute cache write (default 1.25x input)
CacheWrite1h float64 `json:"cache_write_1h,omitempty"` // 1-hour cache write (default 2x input)
CacheRead float64 `json:"cache_read,omitempty"` // default 0.1x input
}
Price is USD per million tokens. Cache prices default to the standard multipliers of the input price when left at zero.
type PriceView ¶
type PriceView struct {
Input float64 `json:"input"`
Output float64 `json:"output"`
CacheWrite float64 `json:"cache_write"`
CacheWrite1h float64 `json:"cache_write_1h"`
CacheRead float64 `json:"cache_read"`
}
PriceView is a Price with its cache prices filled in, all of them always sent.
type Pricer ¶
type Pricer struct {
// contains filtered or unexported fields
}
Pricer resolves a model name to a price. User overrides win (longest matching substring), then the built-in rules.
type PricesReport ¶
type PricesReport struct {
CheckedOn string `json:"checked_on"`
SourceURL string `json:"source_url"`
ConfigPath string `json:"config_path"`
Used []UsedPrice `json:"used"`
Overrides []ListedPrice `json:"overrides"`
Builtin []ListedPrice `json:"builtin"`
}
PricesReport is what the dashboard's Prices page shows.
type ProjectRow ¶
type RangeDetail ¶
type RangeDetail struct {
Days int `json:"days"`
From string `json:"from"` // first day, 2006-01-02
To string `json:"to"` // today
Totals
Daily []DayPoint `json:"daily"` // oldest first, every day present
Models []ModelRow `json:"models"`
Projects []ProjectRow `json:"projects"`
Sessions []SessionRow `json:"sessions"` // most recent first
SessionCount int `json:"session_count"`
Blocks []BlockRow `json:"blocks"` // 5-hour windows, most recent first
Hours []HourCell `json:"hours"` // only the hours with usage
}
RangeDetail covers the last Days calendar days, including today.
type Report ¶
type Report struct {
GeneratedAt time.Time `json:"generated_at"`
Accounts []Summary `json:"accounts"`
// Archived accounts keep their data but stay out of the totals.
Archived []Summary `json:"archived,omitempty"`
Total struct {
Today Totals `json:"today"`
Week Totals `json:"week"`
Month Totals `json:"month"`
} `json:"total"`
}
type SessionRow ¶
type Summary ¶
type Summary struct {
Name string `json:"name"`
Dir string `json:"dir"`
Archived bool `json:"archived,omitempty"`
Found bool `json:"found"`
Error string `json:"error,omitempty"`
Files int `json:"files"`
LastActivity *time.Time `json:"last_activity,omitempty"`
Block Block `json:"block"`
Today Period `json:"today"`
Week Period `json:"week"` // rolling 7 days
Month Period `json:"month"` // rolling 30 days
Daily []DayPoint `json:"daily"` // last 30 days, oldest first
Models []ModelRow `json:"models"`
Unpriced []string `json:"unpriced,omitempty"`
Account *AccountInfo `json:"account,omitempty"` // left out of the status line, which must stay quick
Plan *PlanLimits `json:"plan,omitempty"` // real plan limits
PlanError string `json:"plan_error,omitempty"` // last fetch problem, if recent
}
type UsedPrice ¶
type UsedPrice struct {
Model string `json:"model"`
Source string `json:"source"` // "override", "builtin", or "" when unpriced
Match string `json:"match,omitempty"`
Price *PriceView `json:"price,omitempty"`
Accounts []string `json:"accounts"`
Messages int `json:"messages"`
Tokens int64 `json:"tokens"`
CostUSD float64 `json:"cost_usd"`
}
UsedPrice is a model found in the logs and the price ccmeter charges it at.