| 1 | //! OpenCode Go's provider-owned transport roster. |
| 2 | //! |
| 3 | //! Reviewed against <https://opencode.ai/docs/go/#endpoints> on 2026-09-12. |
| 4 | //! Previously accepted Chat ids remain compatible absent explicit deprecation. |
| 5 | //! Membership proves a wire protocol, not live availability, limits or pricing. |
| 6 | |
| 7 | /// Every documented Go wire id, in stable picker order. |
| 8 | #[must_use] |
| 9 | pub fn opencode_go_models() -> Vec<&'static str> { |
| 10 | crate::catalog::reviewed::constants::OPENCODE_GO_MODELS.to_vec() |
| 11 | } |
| 12 | |
| 13 | /// Canonicalize only IDs whose Go protocol is known. Unknown models cannot |
| 14 | /// silently fall through to Chat, another provider, or the default model. |
| 15 | #[must_use] |
| 16 | pub fn opencode_go_model_id(model: &str) -> Option<&'static str> { |
| 17 | let normalized = model.trim().to_ascii_lowercase().replace(['_', ' '], "-"); |
| 18 | let normalized = normalized |
| 19 | .strip_prefix("opencode-go/") |
| 20 | .unwrap_or(&normalized); |
| 21 | let reviewed = crate::catalog::reviewed::bundled_reviewed(); |
| 22 | let normalized = reviewed |
| 23 | .go_aliases |
| 24 | .get(normalized) |
| 25 | .map_or(normalized, String::as_str); |
| 26 | crate::catalog::reviewed::constants::OPENCODE_GO_MODELS |
| 27 | .iter() |
| 28 | .copied() |
| 29 | .find(|id| *id == normalized) |
| 30 | } |
| 31 | |
| 32 | /// The documented endpoint for a Go model, independent of stale catalog metadata. |
| 33 | #[must_use] |
| 34 | pub fn opencode_go_endpoint_key(model: &str) -> Option<&'static str> { |
| 35 | let canonical = opencode_go_model_id(model)?; |
| 36 | crate::catalog::reviewed::reviewed_transport("opencode-go", canonical) |
| 37 | .map(|row| row.endpoint_key.as_str()) |
| 38 | } |
| 39 |