package metered import "amadan.net/oficina/equipo/internal/wire" // Tiers (connectors spec rev 3.3, §16.2): Equipo's own judgement of each // priced model, as strong, standard or cheap, with its family, from the // providers' prices and the models' public descriptions. It sits beside // the price tables and has its own version: a model is eligible to be // allowed and chosen only while it is priced (in its connection's price // version) and tiered (in the current tier version). const ( TierStrong = "strong" TierStandard = "standard" TierCheap = "cheap" ) // TierRank orders tiers: cheap 1, standard 2, strong 3; 0 for none. func TierRank(tier string) int { switch tier { case TierCheap: return 1 case TierStandard: return 2 case TierStrong: return 3 } return 0 } // ModelTier is one model's family and tier. type ModelTier struct { Family, Tier string } // TierTable is one version of the tier table: Date is the day Equipo // judged it (the Usage page's source line names it), Models each // provider's models. type TierTable struct { Version, Date string Models map[string]map[string]ModelTier } // tensorxTiers are the ten TensorX models as §16.2 lists them. func tensorxTiers() map[string]ModelTier { return map[string]ModelTier{ "z-ai/glm-5.3": {"glm", TierStrong}, "moonshotai/kimi-k3.1-pro": {"kimi", TierStrong}, "moonshotai/kimi-k3": {"kimi", TierStrong}, "deepseek/deepseek-v4-pro-0813": {"deepseek", TierStrong}, "z-ai/glm-5.2": {"glm", TierStandard}, "qwen/qwen3.8-27b": {"qwen", TierStandard}, "deepseek/deepseek-v4.1-flash": {"deepseek", TierStandard}, "z-ai/glm-5.3-flash": {"glm", TierCheap}, "deepseek/deepseek-v4-flash-0731": {"deepseek", TierCheap}, "minimax/minimax-m3.1-flash": {"minimax", TierCheap}, } } // opencodeGoTiers are OpenCode Go's priced models, judged the same way // (S5b, for the controller's review): a model TensorX also serves keeps // TensorX's tier; the rest by Go's price (output per million: about $4 // and up strong only for a vendor's flagship, $0.80 to $4.40 standard, // under $0.80 cheap) and the vendor's own description (flash, small and // older coding models a tier below their flagship). func opencodeGoTiers() map[string]ModelTier { return map[string]ModelTier{ "glm-5.3": {"glm", TierStrong}, "kimi-k3.1-pro": {"kimi", TierStrong}, "kimi-k3": {"kimi", TierStrong}, "deepseek-v4-pro": {"deepseek", TierStrong}, "glm-5.2": {"glm", TierStandard}, "kimi-k2.7-code": {"kimi", TierStandard}, "deepseek-v4.1-flash": {"deepseek", TierStandard}, "longcat-2.0": {"longcat", TierStandard}, "mimo-v2.6-pro": {"mimo", TierStandard}, "mimo-v2.5-pro": {"mimo", TierStandard}, "hy4": {"hunyuan", TierStandard}, "hy4-preview": {"hunyuan", TierStandard}, "step-5-preview": {"step", TierStandard}, "glm-5.3-flash": {"glm", TierCheap}, "mimo-v2.6-flash": {"mimo", TierCheap}, "mimo-v2.5": {"mimo", TierCheap}, "minimax-m3.1-flash": {"minimax", TierCheap}, "hy3": {"hunyuan", TierCheap}, } } // TierTables are every tier table this runner knows, by version. var TierTables = map[string]TierTable{ "tiers-2026-11-12": {Version: "tiers-2026-11-12", Date: "2026-11-12", Models: map[string]map[string]ModelTier{ wire.ProviderTensorX: tensorxTiers(), wire.ProviderOpenCodeGo: opencodeGoTiers(), }}, } // CurrentTiers is the tier version every choice reads. var CurrentTiers = "tiers-2026-11-12" // TierOf is a model's family and tier in the current tier table. func TierOf(provider, model string) (ModelTier, bool) { t, ok := TierTables[CurrentTiers].Models[provider][model] return t, ok } // Eligible is whether a model can be allowed on, and chosen for, a // connection of provider priced under priceVersion: priced there and // tiered now (§16.1, §16.2). A model tiered under an older table only // stops being eligible. func Eligible(provider, priceVersion, model string) (ModelTier, Price, bool) { table, ok := TableFor(priceVersion) if !ok || table.Provider != provider { return ModelTier{}, Price{}, false } p, priced := table.Models[model] t, tiered := TierOf(provider, model) return t, p, priced && tiered }