()
| 4393 | } |
| 4394 | |
| 4395 | async fn list_agents() -> Result<Json<Vec<AgentInfo>>> { |
| 4396 | let mut config = std::env::current_dir() |
| 4397 | .ok() |
| 4398 | .and_then(|cwd| load_config(&cwd).ok()); |
| 4399 | |
| 4400 | if let (Some(loader), Some(config)) = (get_plugin_loader(), config.as_mut()) { |
| 4401 | apply_plugin_config_hooks(loader, config).await; |
| 4402 | } |
| 4403 | |
| 4404 | let registry = AgentRegistry::from_optional_config(config.as_ref()); |
| 4405 | let agents = registry |
| 4406 | .list() |
| 4407 | .into_iter() |
| 4408 | .filter(|agent| !matches!(agent.mode, AgentMode::Subagent)) |
| 4409 | .map(|agent| AgentInfo { |
| 4410 | id: agent.name.clone(), |
| 4411 | name: agent.name.clone(), |
| 4412 | description: agent.description.clone(), |
| 4413 | }) |
| 4414 | .collect(); |
| 4415 | Ok(Json(agents)) |
| 4416 | } |
| 4417 | |
| 4418 | async fn apply_plugin_config_hooks(loader: &Arc<PluginLoader>, config: &mut AppConfig) { |
| 4419 | let mut config_value = match serde_json::to_value(config.clone()) { |
nothing calls this directly
no test coverage detected