pub struct AgentRegistry { /* private fields */ }Expand description
Agent registry with CCS alias and OpenCode dynamic provider/model support.
CCS aliases are eagerly resolved and registered as regular agents
when set via set_ccs_aliases(). This allows get() to work
uniformly for both regular agents and CCS aliases.
OpenCode provider/model combinations are resolved on-the-fly using
the opencode/ prefix.
Implementations§
Source§impl AgentRegistry
impl AgentRegistry
Sourcepub fn set_opencode_catalog(&mut self, catalog: ApiCatalog)
pub fn set_opencode_catalog(&mut self, catalog: ApiCatalog)
Set the OpenCode API catalog for dynamic provider/model resolution.
This enables resolution of opencode/provider/model agent references.
Sourcepub fn set_ccs_aliases(
&mut self,
aliases: &HashMap<String, CcsAliasConfig>,
defaults: CcsConfig,
)
pub fn set_ccs_aliases( &mut self, aliases: &HashMap<String, CcsAliasConfig>, defaults: CcsConfig, )
Set CCS aliases for the registry.
This eagerly registers CCS aliases as agents so they can be
resolved with resolve_config().
Sourcepub fn register(&mut self, name: &str, config: AgentConfig)
pub fn register(&mut self, name: &str, config: AgentConfig)
Register a new agent.
Sourcepub fn resolve_config(&self, name: &str) -> Option<AgentConfig>
pub fn resolve_config(&self, name: &str) -> Option<AgentConfig>
Resolve an agent’s configuration, including on-the-fly CCS and OpenCode references.
CCS supports direct execution via ccs/<alias> even when the alias isn’t
pre-registered in config; those are resolved lazily here.
OpenCode supports dynamic provider/model via opencode/provider/model syntax;
those are validated against the API catalog and resolved lazily here.
Sourcepub fn display_name(&self, name: &str) -> String
pub fn display_name(&self, name: &str) -> String
Get display name for an agent.
Returns the agent’s custom display name if set (e.g., “ccs-glm” for CCS aliases), otherwise returns the agent’s registry name.
§Arguments
name- The agent’s registry name (e.g., “ccs/glm”, “claude”)
§Examples
assert_eq!(registry.display_name("ccs/glm"), "ccs-glm");
assert_eq!(registry.display_name("claude"), "claude");Sourcepub fn resolve_from_logfile_name(&self, logfile_name: &str) -> Option<String>
pub fn resolve_from_logfile_name(&self, logfile_name: &str) -> Option<String>
Find the registry name for an agent given its log file name.
Log file names use a sanitized form of the registry name where / is
replaced with - to avoid creating subdirectories. This function
reverses that sanitization to find the original registry name.
This is used for session continuation, where the agent name is extracted from log file names (e.g., “ccs-glm”, “opencode-anthropic-claude-sonnet-4”) but we need to look up the agent in the registry (which uses names like “ccs/glm”, “opencode/anthropic/claude-sonnet-4”).
§Strategy
- Check if the name is already a valid registry key (no sanitization needed)
- Search registered agents for one whose sanitized name matches
- Try common patterns like “ccs-X” → “ccs/X”, “opencode-X-Y” → “opencode/X/Y”
§Arguments
logfile_name- The agent name extracted from a log file (e.g., “ccs-glm”)
§Returns
The registry name if found (e.g., “ccs/glm”), or None if no match.
§Examples
assert_eq!(registry.resolve_from_logfile_name("ccs-glm"), Some("ccs/glm".to_string()));
assert_eq!(registry.resolve_from_logfile_name("claude"), Some("claude".to_string()));
assert_eq!(registry.resolve_from_logfile_name("opencode-anthropic-claude-sonnet-4"),
Some("opencode/anthropic/claude-sonnet-4".to_string()));Sourcepub fn resolve_fuzzy(&self, name: &str) -> Option<String>
pub fn resolve_fuzzy(&self, name: &str) -> Option<String>
Resolve a fuzzy agent name to a canonical agent name.
This handles common typos and alternative forms:
ccs/<unregistered>: Returns the name as-is for direct CCS executionopencode/provider/model: Returns the name as-is for dynamic resolution- Other fuzzy matches: Returns the canonical name if a match is found
- Exact matches: Returns the name as-is
Returns None if the name cannot be resolved to any known agent.
Sourcepub fn list(&self) -> Vec<(&str, &AgentConfig)>
pub fn list(&self) -> Vec<(&str, &AgentConfig)>
List all registered agents.
Sourcepub fn developer_cmd(&self, agent_name: &str) -> Option<String>
pub fn developer_cmd(&self, agent_name: &str) -> Option<String>
Get command for developer role.
Sourcepub fn reviewer_cmd(&self, agent_name: &str) -> Option<String>
pub fn reviewer_cmd(&self, agent_name: &str) -> Option<String>
Get command for reviewer role.
Sourcepub fn load_from_file<P: AsRef<Path>>(
&mut self,
path: P,
) -> Result<usize, AgentConfigError>
pub fn load_from_file<P: AsRef<Path>>( &mut self, path: P, ) -> Result<usize, AgentConfigError>
Load custom agents from a TOML configuration file.
Sourcepub fn apply_unified_config(&mut self, unified: &UnifiedConfig) -> usize
pub fn apply_unified_config(&mut self, unified: &UnifiedConfig) -> usize
Apply settings from the unified config (~/.config/ralph-workflow.toml).
This merges (in increasing priority):
- Built-in defaults (embedded
examples/agents.toml) - Unified config:
[agents],[ccs_aliases], and[agent_chain](if present)
Returns the number of agents loaded from unified config, including CCS aliases.
Sourcepub const fn fallback_config(&self) -> &FallbackConfig
pub const fn fallback_config(&self) -> &FallbackConfig
Get the fallback configuration.
Sourcepub fn retry_timer(&self) -> Arc<dyn RetryTimerProvider>
pub fn retry_timer(&self) -> Arc<dyn RetryTimerProvider>
Get the retry timer provider.
Sourcepub fn available_fallbacks(&self, role: AgentRole) -> Vec<&str>
pub fn available_fallbacks(&self, role: AgentRole) -> Vec<&str>
Get all fallback agents for a role that are registered in this registry.
Sourcepub fn validate_agent_chains(&self) -> Result<(), String>
pub fn validate_agent_chains(&self) -> Result<(), String>
Validate that agent chains are configured for both roles.
Sourcepub fn is_agent_available(&self, name: &str) -> bool
pub fn is_agent_available(&self, name: &str) -> bool
Check if an agent is available (command exists and is executable).
Sourcepub fn list_available(&self) -> Vec<&str>
pub fn list_available(&self) -> Vec<&str>
List all available (installed) agents.
Auto Trait Implementations§
impl Freeze for AgentRegistry
impl !RefUnwindSafe for AgentRegistry
impl Send for AgentRegistry
impl Sync for AgentRegistry
impl Unpin for AgentRegistry
impl !UnwindSafe for AgentRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more