using Microsoft.AspNetCore.Mvc; using Nexus.Api.Services; namespace Nexus.Api.Controllers; [ApiController] [Route("api/v1/team")] public class TeamController(IAgentService agentService) : ControllerBase { [HttpGet] public async Task GetTeam(CancellationToken ct) { var agents = await agentService.GetAgentsAsync(ct); var team = new List(); foreach (var agent in agents) { string identity = ""; string workspace = agent.Workspace ?? ""; if (!string.IsNullOrWhiteSpace(workspace) && Directory.Exists(workspace)) { var identityFile = Path.Combine(workspace, "IDENTITY.md"); if (System.IO.File.Exists(identityFile)) { var content = await System.IO.File.ReadAllTextAsync(identityFile, ct); var lines = content.Split('\n').Where(l => l.StartsWith("- **")).Take(8); identity = string.Join("\n", lines); } } team.Add(new { agent.Id, agent.Name, agent.Role, agent.Model, agent.Status, agent.LastSeen, agent.Workspace, agent.Description, identity }); } return Results.Ok(team); } }