Documentation
¶
Overview ¶
Package usage provides access to the Anthropic quota usage API.
Index ¶
- Variables
- func CountCompactions(transcriptPath string) int
- func ExhaustedResetMinutes(data *Data) int
- func FormatQuotaWindow(win *QuotaWindow, label string) string
- func FormatRateLimitSegment(minutes int) string
- func FormatStaleQuotaWindow(win *QuotaWindow, label string) string
- type Data
- type ExtraUsage
- type QuotaWindow
Constants ¶
This section is empty.
Variables ¶
var CachePath = "/tmp/claude-usage-cache.json"
CachePath is the path to the usage cache file. Replaceable for testing.
var CacheTTL = 10 * time.Minute
CacheTTL is the cache duration for usage data. Configurable at startup.
var HTTPGetFn httpclient.GetFn = httpclient.Get
HTTPGetFn is the function used for HTTP requests. Replaceable for testing.
var LastGoodCachePath = "/tmp/claude-usage-last-good.json"
LastGoodCachePath stores the last successful API response. Replaceable for testing.
Functions ¶
func CountCompactions ¶
CountCompactions counts compact_boundary entries in a session transcript JSONL.
func ExhaustedResetMinutes ¶ added in v0.2.1
ExhaustedResetMinutes returns the reset time for the most saturated active window.
func FormatQuotaWindow ¶
func FormatQuotaWindow(win *QuotaWindow, label string) string
FormatQuotaWindow formats a single quota window for display.
func FormatRateLimitSegment ¶ added in v0.2.1
FormatRateLimitSegment formats the explicit exhausted-limit segment.
func FormatStaleQuotaWindow ¶ added in v0.2.0
func FormatStaleQuotaWindow(win *QuotaWindow, label string) string
FormatStaleQuotaWindow formats a window with ?% but real time and indicator.
Types ¶
type Data ¶
type Data struct {
FiveHour *QuotaWindow
SevenDay *QuotaWindow
Extra *ExtraUsage
ErrorType string
}
Data is the parsed response from Anthropic usage API.
func FetchLastGood ¶ added in v0.2.0
func FetchLastGood() *Data
FetchLastGood returns the last successful usage data (no TTL).
type ExtraUsage ¶
ExtraUsage represents monthly extra/overuse budget.