Documentation
¶
Index ¶
- type AccountConfig
- type DashboardColorRole
- type DashboardCompactRow
- type DashboardDisplayStyle
- type DashboardMetricGroupOverride
- type DashboardMetricMatcher
- type DashboardRawGroup
- type DashboardResetStyle
- type DashboardWidget
- type DetailSection
- type DetailSectionStyle
- type DetailWidget
- type Engine
- func (e *Engine) AddAccount(acct AccountConfig)
- func (e *Engine) OnUpdate(fn func(map[string]QuotaSnapshot))
- func (e *Engine) RefreshAll(ctx context.Context)
- func (e *Engine) RegisterProvider(p QuotaProvider)
- func (e *Engine) Run(ctx context.Context)
- func (e *Engine) SetAccounts(accounts []AccountConfig)
- func (e *Engine) Snapshots() map[string]QuotaSnapshot
- type Metric
- type ProviderInfo
- type QuotaProvider
- type QuotaSnapshot
- type Status
- type TimePoint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountConfig ¶
type AccountConfig struct {
ID string `json:"id"`
Provider string `json:"provider"`
Auth string `json:"auth,omitempty"` // "api_key", "oauth", "cli", "local", "token"
APIKeyEnv string `json:"api_key_env,omitempty"` // env var name holding the API key
ProbeModel string `json:"probe_model,omitempty"` // model to use for probe requests
Binary string `json:"binary,omitempty"` // path to CLI binary
BaseURL string `json:"base_url,omitempty"` // custom API base URL (e.g. for OpenRouter)
Token string `json:"-"` // runtime-only: access token (never persisted)
ExtraData map[string]string `json:"-"` // runtime-only: extra detection data
}
func (AccountConfig) ResolveAPIKey ¶
func (c AccountConfig) ResolveAPIKey() string
type DashboardColorRole ¶ added in v0.2.0
type DashboardColorRole string
const ( DashboardColorRoleAuto DashboardColorRole = "auto" DashboardColorRoleGreen DashboardColorRole = "green" DashboardColorRolePeach DashboardColorRole = "peach" DashboardColorRoleLavender DashboardColorRole = "lavender" DashboardColorRoleBlue DashboardColorRole = "blue" DashboardColorRoleTeal DashboardColorRole = "teal" DashboardColorRoleYellow DashboardColorRole = "yellow" DashboardColorRoleSky DashboardColorRole = "sky" DashboardColorRoleSapphire DashboardColorRole = "sapphire" DashboardColorRoleMaroon DashboardColorRole = "maroon" DashboardColorRoleFlamingo DashboardColorRole = "flamingo" DashboardColorRoleRosewater DashboardColorRole = "rosewater" )
type DashboardCompactRow ¶ added in v0.2.0
type DashboardCompactRow struct {
Label string
Keys []string
Matcher DashboardMetricMatcher
MaxSegments int
}
type DashboardDisplayStyle ¶ added in v0.2.0
type DashboardDisplayStyle string
const ( DashboardDisplayStyleDefault DashboardDisplayStyle = "default" // Detailed credits mode shows richer "remaining/today/week/models" messaging // when credit-like metrics are present. DashboardDisplayStyleDetailedCredits DashboardDisplayStyle = "detailed_credits" )
type DashboardMetricGroupOverride ¶ added in v0.2.0
type DashboardMetricMatcher ¶ added in v0.2.0
type DashboardRawGroup ¶ added in v0.2.0
type DashboardResetStyle ¶ added in v0.2.0
type DashboardResetStyle string
const ( DashboardResetStyleDefault DashboardResetStyle = "default" // Compact model resets mode groups many reset rows into model-oriented pills. DashboardResetStyleCompactModelResets DashboardResetStyle = "compact_model_resets" )
type DashboardWidget ¶ added in v0.2.0
type DashboardWidget struct {
DisplayStyle DashboardDisplayStyle
ResetStyle DashboardResetStyle
ColorRole DashboardColorRole
// Opt-in client composition panel (client share + trend) in tile view.
ShowClientComposition bool
// API key provider metadata. APIKeyEnv marks a provider as configurable in API Keys tab.
APIKeyEnv string
DefaultAccountID string
// When ResetStyle is DashboardResetStyleCompactModelResets and the number of active
// reset entries meets/exceeds this value, reset pills are grouped.
ResetCompactThreshold int
GaugePriority []string
GaugeMaxLines int
CompactRows []DashboardCompactRow
RawGroups []DashboardRawGroup
MetricLabelOverrides map[string]string
MetricGroupOverrides map[string]DashboardMetricGroupOverride
CompactMetricLabelOverrides map[string]string
HideMetricKeys []string
HideMetricPrefixes []string
// Hide key-level "credits" row when richer account-level balance metric is present.
HideCreditsWhenBalancePresent bool
// Hide noisy metrics that are often zero-value for this provider.
SuppressZeroMetricKeys []string
// Hide all zero-valued non-quota metrics.
SuppressZeroNonQuotaMetrics bool
}
func DefaultDashboardWidget ¶ added in v0.2.0
func DefaultDashboardWidget() DashboardWidget
type DetailSection ¶ added in v0.3.0
type DetailSection struct {
Name string
Order int
Style DetailSectionStyle
}
type DetailSectionStyle ¶ added in v0.3.0
type DetailSectionStyle string
const ( DetailSectionStyleUsage DetailSectionStyle = "usage" DetailSectionStyleSpending DetailSectionStyle = "spending" DetailSectionStyleTokens DetailSectionStyle = "tokens" DetailSectionStyleActivity DetailSectionStyle = "activity" DetailSectionStyleList DetailSectionStyle = "list" )
type DetailWidget ¶ added in v0.3.0
type DetailWidget struct {
Sections []DetailSection
}
func DefaultDetailWidget ¶ added in v0.3.0
func DefaultDetailWidget() DetailWidget
func (DetailWidget) SectionOrder ¶ added in v0.3.0
func (w DetailWidget) SectionOrder(name string) int
func (DetailWidget) SectionStyle ¶ added in v0.3.0
func (w DetailWidget) SectionStyle(name string) DetailSectionStyle
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) AddAccount ¶ added in v0.2.0
func (e *Engine) AddAccount(acct AccountConfig)
AddAccount appends an account (if not already present) and triggers a refresh for it.
func (*Engine) OnUpdate ¶
func (e *Engine) OnUpdate(fn func(map[string]QuotaSnapshot))
func (*Engine) RefreshAll ¶
func (*Engine) RegisterProvider ¶
func (e *Engine) RegisterProvider(p QuotaProvider)
func (*Engine) SetAccounts ¶
func (e *Engine) SetAccounts(accounts []AccountConfig)
func (*Engine) Snapshots ¶
func (e *Engine) Snapshots() map[string]QuotaSnapshot
type Metric ¶
type ProviderInfo ¶
type QuotaProvider ¶
type QuotaProvider interface {
ID() string
Describe() ProviderInfo
// DashboardWidget defines how provider metrics should be presented in dashboard tiles.
DashboardWidget() DashboardWidget
// DetailWidget defines how sections should be rendered in the details panel.
DetailWidget() DetailWidget
Fetch(ctx context.Context, acct AccountConfig) (QuotaSnapshot, error)
}
type QuotaSnapshot ¶
type QuotaSnapshot struct {
ProviderID string `json:"provider_id"`
AccountID string `json:"account_id"`
Timestamp time.Time `json:"timestamp"`
Status Status `json:"status"`
Metrics map[string]Metric `json:"metrics"` // keys like "rpm", "tpm", "rpd"
Resets map[string]time.Time `json:"resets,omitempty"` // e.g. "rpm_reset"
Raw map[string]string `json:"raw,omitempty"` // redacted header dump / CLI lines
DailySeries map[string][]TimePoint `json:"daily_series,omitempty"` // time-indexed data (e.g. "messages", "cost", "tokens_<model>")
Message string `json:"message,omitempty"` // human-readable summary
}
func (QuotaSnapshot) WorstPercent ¶
func (s QuotaSnapshot) WorstPercent() float64
Click to show internal directories.
Click to hide internal directories.