pub struct ProviderRegistry { /* private fields */ }Expand description
The provider registry — holds all known providers and their models.
Implementations§
Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub fn load(agent_dir: &Path) -> Result<Self>
pub fn load(agent_dir: &Path) -> Result<Self>
Load the provider registry from built-in + user models.json.
Sourcepub fn reload(&mut self, agent_dir: &Path) -> Result<()>
pub fn reload(&mut self, agent_dir: &Path) -> Result<()>
Reload from disk (for /reload support).
Sourcepub fn resolve(
&self,
model_id: &str,
preferred_provider: Option<&str>,
) -> Result<ResolvedModel>
pub fn resolve( &self, model_id: &str, preferred_provider: Option<&str>, ) -> Result<ResolvedModel>
Resolve a model ID (e.g. “deepseek-v4-flash”) to a ResolvedModel.
Scans all providers for a matching model ID. If preferred_provider is
set, that provider is checked first; otherwise returns the first match.
Also resolves the API key for that provider.
Sourcepub fn list_models(&self) -> Vec<String>
pub fn list_models(&self) -> Vec<String>
List all available model IDs (for UI selector and /model command). Deduplicated: each model ID appears only once even if registered under multiple providers.
Sourcepub fn list_authenticated_model_ids(&self) -> Vec<String>
pub fn list_authenticated_model_ids(&self) -> Vec<String>
List model IDs from providers that have valid authentication. Used by the model cycle and selector to hide unconfigured providers.
Sourcepub fn list_model_provider_tuples(&self) -> Vec<(String, String, String)>
pub fn list_model_provider_tuples(&self) -> Vec<(String, String, String)>
List all (provider, model_id, model_name) tuples, one per provider entry.
Unlike list_models(), the same model ID can appear under multiple
providers. Used by the model selector to show provider-prefixed entries.
Sourcepub fn provider_for_model(
&self,
model_id: &str,
preferred_provider: Option<&str>,
) -> Option<String>
pub fn provider_for_model( &self, model_id: &str, preferred_provider: Option<&str>, ) -> Option<String>
Get the provider name for a model ID.
When preferred_provider is set and that provider has the model,
returns the preferred provider. Otherwise returns the first match.
Sourcepub fn api_key_for_provider(&self, provider_id: &str) -> Option<String>
pub fn api_key_for_provider(&self, provider_id: &str) -> Option<String>
Get the API key for a provider.
Sourcepub fn count_providers(&self) -> usize
pub fn count_providers(&self) -> usize
Count the number of distinct providers in the registry.
Sourcepub fn list_providers(&self) -> Vec<(String, String)>
pub fn list_providers(&self) -> Vec<(String, String)>
List all provider (id, name) tuples.
Sourcepub fn configured_providers(&self) -> Vec<String>
pub fn configured_providers(&self) -> Vec<String>
Get the list of provider IDs that have stored credentials.
Sourcepub fn provider_has_auth(&self, provider_id: &str) -> bool
pub fn provider_has_auth(&self, provider_id: &str) -> bool
Check whether a provider has valid authentication (stored credential or env var).
Sourcepub fn auth_status_for_provider(&self, provider_id: &str) -> ProviderAuthStatus
pub fn auth_status_for_provider(&self, provider_id: &str) -> ProviderAuthStatus
Get auth status for a provider (for UI display).