//! Gates access to the retained startup model catalog on current managed provider requirements. use std::sync::Arc; use codex_core::config::Config; use codex_models_manager::manager::RefreshStrategy; use codex_models_manager::manager::SharedModelsManager; use codex_protocol::openai_models::ModelPreset; use crate::config_manager::ConfigManager; /// Checks the retained catalog route before model/list and background refreshes. pub(crate) struct ModelCatalog { config_manager: ConfigManager, config: Arc, models_manager: SharedModelsManager, } impl ModelCatalog { pub(crate) fn new( config_manager: ConfigManager, config: Arc, models_manager: SharedModelsManager, ) -> Self { Self { config_manager, config, models_manager, } } pub(crate) async fn list_models( &self, refresh_strategy: RefreshStrategy, ) -> std::io::Result> { // Check before consulting even a warm cache, just as turn admission checks // the retained session route before using it. self.config_manager .check_thread_model_provider(&self.config) .await?; Ok(self .models_manager .list_models(refresh_strategy, self.config.http_client_factory()) .await) } }