Documentation
¶
Overview ¶
Package tier defines the tiered credit system for Hanzo billing.
Each IAM user has a "tier" property stored in hanzo.id (Casdoor) user properties and propagated via JWT claims. The tier determines:
- daily replenishing free credits (non-accumulating)
- maximum concurrent agents
- which model prefixes are allowed
Free-tier users receive a daily replenishing balance that resets each UTC day and does not roll over. Paid tiers (starter, pro, enterprise) use prepaid balances managed by the existing billing engine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Name is the canonical tier identifier.
Name Name `json:"name"`
// DisplayName is the human-readable tier label.
DisplayName string `json:"displayName"`
// MaxAgents is the maximum concurrent agents allowed.
MaxAgents int `json:"maxAgents"`
// DailyCreditsCents is the daily replenishing credit allowance in cents.
// Only applies to tiers where credits reset every UTC day (i.e. free).
// For prepaid tiers this is 0 -- balance is managed externally.
DailyCreditsCents int64 `json:"dailyCreditsCents"`
// AllowedModels lists the model prefixes the tier may invoke.
// A single entry of "*" means all models are allowed.
AllowedModels []string `json:"allowedModels"`
}
Config describes the billing limits for a single tier.
func Get ¶
Get returns the Config for a given tier name. Unknown tiers fall back to Free so callers never receive nil.
func (*Config) HasDailyCredits ¶
HasDailyCredits returns true if the tier receives daily replenishing credits.
func (*Config) IsModelAllowed ¶
IsModelAllowed checks whether the given model identifier is permitted under the tier's allowedModels list. Matching is prefix-based: an entry "claude-sonnet" matches "claude-sonnet-4-20250514".
func (*Config) IsUnlimitedAgents ¶
IsUnlimitedAgents returns true if MaxAgents is 0 (unlimited).