An AI agent built to do Ralph loops - plan mode for planning and ralph mode for implementing.
at new-directions 37 lines 1.0 kB view raw
1use super::{ApiError, AppState}; 2use crate::graph::{NodeStatus, NodeType}; 3use axum::Json; 4use axum::extract::{Path, State}; 5use serde::Serialize; 6 7#[derive(Serialize)] 8pub struct ActiveAgent { 9 pub agent_id: String, 10 pub task_id: String, 11 pub task_title: String, 12 pub task_status: NodeStatus, 13} 14 15/// GET /api/goals/:id/agents 16pub async fn list_agents( 17 State(state): State<AppState>, 18 Path(goal_id): Path<String>, 19) -> Result<Json<Vec<ActiveAgent>>, ApiError> { 20 let subtree = state.graph_store.get_subtree(&goal_id).await?; 21 let agents: Vec<ActiveAgent> = subtree 22 .into_iter() 23 .filter(|n| { 24 n.node_type == NodeType::Task 25 && n.status == NodeStatus::InProgress 26 && n.assigned_to.is_some() 27 }) 28 .map(|n| ActiveAgent { 29 agent_id: n.assigned_to.clone().unwrap_or_default(), 30 task_id: n.id.clone(), 31 task_title: n.title.clone(), 32 task_status: n.status, 33 }) 34 .collect(); 35 36 Ok(Json(agents)) 37}