Parses comma-separated agent string and validates each agent. Returns the default agent if none specified.
(&self)
| 68 | /// Parses comma-separated agent string and validates each agent. |
| 69 | /// Returns the default agent if none specified. |
| 70 | pub fn parse_and_validate_agents(&self) -> Result<Vec<String>, Box<dyn Error>> { |
| 71 | let agents: Vec<String> = match &self.agent { |
| 72 | Some(agent_str) => agent_str.split(',').map(|s| s.trim().to_string()).collect(), |
| 73 | None => vec![crate::agent::AgentProvider::default_agent().to_string()], |
| 74 | }; |
| 75 | |
| 76 | for agent in &agents { |
| 77 | if !crate::agent::AgentProvider::is_valid_agent(agent) { |
| 78 | let available = crate::agent::AgentProvider::list_agents().join(", "); |
| 79 | return Err( |
| 80 | format!("Unknown agent '{agent}'. Available agents: {available}").into(), |
| 81 | ); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | Ok(agents) |
| 86 | } |
| 87 | |
| 88 | /// Reads piped stdin and merges with the CLI prompt. |
| 89 | pub fn resolve_prompt(&self) -> Result<Option<String>, Box<dyn Error>> { |