Documentation
¶
Index ¶
- func CalculateCost(tokens TokenUsage, model string) float64
- func ContextPctColor(pct float64) lipgloss.Color
- func ContextWindowPct(lastInput int64, capacity int64) float64
- func ModelContextCapacity(model string) int64
- func RenderContextGauge(pct float64, width int) string
- type ModelPrice
- type Parser
- type PollResult
- type SessionCost
- type SessionTokens
- type TokenUsage
- type Tracker
- type UsageSummary
- type UsageUpdateMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateCost ¶
func CalculateCost(tokens TokenUsage, model string) float64
func ContextPctColor ¶ added in v0.7.0
ContextPctColor returns a Nord-palette color based on context fill percentage. <60% green, 60-80% yellow, 80%+ red.
func ContextWindowPct ¶ added in v0.7.0
ContextWindowPct computes how full the context window is based on the last API call's input tokens and the model's capacity.
func ModelContextCapacity ¶ added in v0.7.0
ModelContextCapacity returns the context window size for a given model string. Uses prefix matching after stripping the "claude-" prefix and date suffix.
func RenderContextGauge ¶ added in v0.7.0
RenderContextGauge renders a bar gauge like [████░░░░] 67%
Types ¶
type ModelPrice ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) Poll ¶
func (p *Parser) Poll() PollResult
type PollResult ¶ added in v0.6.0
type PollResult struct {
Total TokenUsage
Model string
PerSession map[string]SessionTokens
}
PollResult contains both aggregate and per-session usage data.
type SessionCost ¶ added in v0.6.0
type SessionCost struct {
Tokens TokenUsage
Cost float64
Model string
}
SessionCost holds computed cost for a single session.
type SessionTokens ¶ added in v0.6.0
type SessionTokens struct {
Tokens TokenUsage
Model string
}
SessionTokens holds per-session token usage and model.
type TokenUsage ¶
type TokenUsage struct {
InputTokens int64
OutputTokens int64
CacheCreationTokens int64
CacheReadTokens int64
LastInput int64 // most recent API call's total input (overwrites, not accumulates)
}
TokenUsage holds aggregated token counts.
type UsageSummary ¶
type UsageSummary struct {
Tokens TokenUsage
Cost float64
BurnRate float64
PerSession map[string]SessionCost
}
UsageSummary is the aggregate sent to the TUI.
type UsageUpdateMsg ¶
type UsageUpdateMsg struct {
Summary UsageSummary
}
UsageUpdateMsg is sent to the TUI with updated usage data.