| 1 | package metered |
| 2 | |
| 3 | import "amadan.net/oficina/equipo/internal/wire" |
| 4 | |
| 5 | // Tiers (connectors spec rev 3.3, §16.2): Equipo's own judgement of each |
| 6 | // priced model, as strong, standard or cheap, with its family, from the |
| 7 | // providers' prices and the models' public descriptions. It sits beside |
| 8 | // the price tables and has its own version: a model is eligible to be |
| 9 | // allowed and chosen only while it is priced (in its connection's price |
| 10 | // version) and tiered (in the current tier version). |
| 11 | const ( |
| 12 | TierStrong = "strong" |
| 13 | TierStandard = "standard" |
| 14 | TierCheap = "cheap" |
| 15 | ) |
| 16 | |
| 17 | // TierRank orders tiers: cheap 1, standard 2, strong 3; 0 for none. |
| 18 | func TierRank(tier string) int { |
| 19 | switch tier { |
| 20 | case TierCheap: |
| 21 | return 1 |
| 22 | case TierStandard: |
| 23 | return 2 |
| 24 | case TierStrong: |
| 25 | return 3 |
| 26 | } |
| 27 | return 0 |
| 28 | } |
| 29 | |
| 30 | // ModelTier is one model's family and tier. |
| 31 | type ModelTier struct { |
| 32 | Family, Tier string |
| 33 | } |
| 34 | |
| 35 | // TierTable is one version of the tier table: Date is the day Equipo |
| 36 | // judged it (the Usage page's source line names it), Models each |
| 37 | // provider's models. |
| 38 | type TierTable struct { |
| 39 | Version, Date string |
| 40 | Models map[string]map[string]ModelTier |
| 41 | } |
| 42 | |
| 43 | // tensorxTiers are the ten TensorX models as §16.2 lists them. |
| 44 | func tensorxTiers() map[string]ModelTier { |
| 45 | return map[string]ModelTier{ |
| 46 | "z-ai/glm-5.3": {"glm", TierStrong}, |
| 47 | "moonshotai/kimi-k3.1-pro": {"kimi", TierStrong}, |
| 48 | "moonshotai/kimi-k3": {"kimi", TierStrong}, |
| 49 | "deepseek/deepseek-v4-pro-0813": {"deepseek", TierStrong}, |
| 50 | "z-ai/glm-5.2": {"glm", TierStandard}, |
| 51 | "qwen/qwen3.8-27b": {"qwen", TierStandard}, |
| 52 | "deepseek/deepseek-v4.1-flash": {"deepseek", TierStandard}, |
| 53 | "z-ai/glm-5.3-flash": {"glm", TierCheap}, |
| 54 | "deepseek/deepseek-v4-flash-0731": {"deepseek", TierCheap}, |
| 55 | "minimax/minimax-m3.1-flash": {"minimax", TierCheap}, |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // opencodeGoTiers are OpenCode Go's priced models, judged the same way |
| 60 | // (S5b, for the controller's review): a model TensorX also serves keeps |
| 61 | // TensorX's tier; the rest by Go's price (output per million: about $4 |
| 62 | // and up strong only for a vendor's flagship, $0.80 to $4.40 standard, |
| 63 | // under $0.80 cheap) and the vendor's own description (flash, small and |
| 64 | // older coding models a tier below their flagship). |
| 65 | func opencodeGoTiers() map[string]ModelTier { |
| 66 | return map[string]ModelTier{ |
| 67 | "glm-5.3": {"glm", TierStrong}, |
| 68 | "kimi-k3.1-pro": {"kimi", TierStrong}, |
| 69 | "kimi-k3": {"kimi", TierStrong}, |
| 70 | "deepseek-v4-pro": {"deepseek", TierStrong}, |
| 71 | "glm-5.2": {"glm", TierStandard}, |
| 72 | "kimi-k2.7-code": {"kimi", TierStandard}, |
| 73 | "deepseek-v4.1-flash": {"deepseek", TierStandard}, |
| 74 | "longcat-2.0": {"longcat", TierStandard}, |
| 75 | "mimo-v2.6-pro": {"mimo", TierStandard}, |
| 76 | "mimo-v2.5-pro": {"mimo", TierStandard}, |
| 77 | "hy4": {"hunyuan", TierStandard}, |
| 78 | "hy4-preview": {"hunyuan", TierStandard}, |
| 79 | "step-5-preview": {"step", TierStandard}, |
| 80 | "glm-5.3-flash": {"glm", TierCheap}, |
| 81 | "mimo-v2.6-flash": {"mimo", TierCheap}, |
| 82 | "mimo-v2.5": {"mimo", TierCheap}, |
| 83 | "minimax-m3.1-flash": {"minimax", TierCheap}, |
| 84 | "hy3": {"hunyuan", TierCheap}, |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // TierTables are every tier table this runner knows, by version. |
| 89 | var TierTables = map[string]TierTable{ |
| 90 | "tiers-2026-11-12": {Version: "tiers-2026-11-12", Date: "2026-11-12", Models: map[string]map[string]ModelTier{ |
| 91 | wire.ProviderTensorX: tensorxTiers(), |
| 92 | wire.ProviderOpenCodeGo: opencodeGoTiers(), |
| 93 | }}, |
| 94 | } |
| 95 | |
| 96 | // CurrentTiers is the tier version every choice reads. |
| 97 | var CurrentTiers = "tiers-2026-11-12" |
| 98 | |
| 99 | // TierOf is a model's family and tier in the current tier table. |
| 100 | func TierOf(provider, model string) (ModelTier, bool) { |
| 101 | t, ok := TierTables[CurrentTiers].Models[provider][model] |
| 102 | return t, ok |
| 103 | } |
| 104 | |
| 105 | // Eligible is whether a model can be allowed on, and chosen for, a |
| 106 | // connection of provider priced under priceVersion: priced there and |
| 107 | // tiered now (§16.1, §16.2). A model tiered under an older table only |
| 108 | // stops being eligible. |
| 109 | func Eligible(provider, priceVersion, model string) (ModelTier, Price, bool) { |
| 110 | table, ok := TableFor(priceVersion) |
| 111 | if !ok || table.Provider != provider { |
| 112 | return ModelTier{}, Price{}, false |
| 113 | } |
| 114 | p, priced := table.Models[model] |
| 115 | t, tiered := TierOf(provider, model) |
| 116 | return t, p, priced && tiered |
| 117 | } |
| 118 | |